@univerjs/core 0.20.1 → 0.21.0
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 +1631 -1
- package/lib/cjs/index.js +20565 -9
- package/lib/es/facade.js +1608 -1
- package/lib/es/index.js +19904 -9
- package/lib/facade.js +1608 -1
- package/lib/index.js +19904 -9
- package/lib/types/common/unit.d.ts +3 -4
- package/lib/types/index.d.ts +1 -2
- package/lib/types/services/instance/instance.service.d.ts +23 -22
- package/lib/types/services/plugin/plugin.service.d.ts +5 -5
- package/lib/types/slides/slide-data-model.d.ts +27 -0
- package/lib/types/types/const/const.d.ts +0 -8
- package/lib/types/types/enum/index.d.ts +0 -1
- package/lib/types/types/interfaces/index.d.ts +0 -1
- package/lib/types/univer.d.ts +3 -21
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +9 -9
- package/package.json +7 -7
- package/lib/types/slides/slide-model.d.ts +0 -62
- package/lib/types/types/enum/prst-geom-type.d.ts +0 -118
- package/lib/types/types/interfaces/i-slide-data.d.ts +0 -167
|
@@ -13,15 +13,14 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import type { UniverType } from '@univerjs/protocol';
|
|
17
16
|
import type { Observable } from 'rxjs';
|
|
17
|
+
import { UniverType as UniverInstanceType } from '@univerjs/protocol';
|
|
18
18
|
import { Disposable } from '../shared/lifecycle';
|
|
19
|
-
export {
|
|
20
|
-
export type UnitType = UniverType | number;
|
|
19
|
+
export { UniverInstanceType };
|
|
21
20
|
/**
|
|
22
21
|
* The base class for all units.
|
|
23
22
|
*/
|
|
24
|
-
export declare abstract class UnitModel<D = object, T extends
|
|
23
|
+
export declare abstract class UnitModel<D = object, T extends UniverInstanceType = UniverInstanceType> extends Disposable {
|
|
25
24
|
abstract readonly type: T;
|
|
26
25
|
abstract getUnitId(): string;
|
|
27
26
|
abstract name$: Observable<string>;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export { Registry, RegistryAsMap } from './common/registry';
|
|
|
35
35
|
export { requestImmediateMacroTask } from './common/request-immediate-macro-task';
|
|
36
36
|
export { type ISequenceExecuteResult, sequence, sequenceAsync } from './common/sequence';
|
|
37
37
|
export { mergeSets } from './common/set';
|
|
38
|
-
export { UnitModel,
|
|
38
|
+
export { UnitModel, UniverInstanceType } from './common/unit';
|
|
39
39
|
export { resolveWithBasePath } from './common/url';
|
|
40
40
|
export * from './docs/data-model';
|
|
41
41
|
export { JSON1, JSONX } from './docs/data-model/json-x/json-x';
|
|
@@ -115,7 +115,6 @@ export { SheetViewModel } from './sheets/view-model';
|
|
|
115
115
|
export { getWorksheetUID, Workbook } from './sheets/workbook';
|
|
116
116
|
export { extractPureTextFromCell, getOriginCellValue, Worksheet } from './sheets/worksheet';
|
|
117
117
|
export { Skeleton } from './skeleton';
|
|
118
|
-
export { SlideDataModel } from './slides/slide-model';
|
|
119
118
|
export * from './types/const';
|
|
120
119
|
export { skipParseTagNames } from './types/const/clipboard';
|
|
121
120
|
export * from './types/enum';
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import type { Observable } from 'rxjs';
|
|
17
17
|
import type { IDisposable } from '../../common/di';
|
|
18
|
-
import type { UnitModel
|
|
18
|
+
import type { UnitModel } from '../../common/unit';
|
|
19
19
|
import type { Nullable } from '../../shared';
|
|
20
20
|
import { Injector } from '../../common/di';
|
|
21
21
|
import { UniverInstanceType } from '../../common/unit';
|
|
@@ -43,13 +43,13 @@ export interface IUniverInstanceService {
|
|
|
43
43
|
/** Omits value when a new UnitModel is created. */
|
|
44
44
|
unitAdded$: Observable<UnitModel>;
|
|
45
45
|
/** Subscribe to curtain type of units' creation. */
|
|
46
|
-
getTypeOfUnitAdded$<T extends UnitModel>(type:
|
|
46
|
+
getTypeOfUnitAdded$<T extends UnitModel>(type: UniverInstanceType): Observable<T>;
|
|
47
47
|
/** @ignore */
|
|
48
48
|
__addUnit(unit: UnitModel): void;
|
|
49
49
|
/** Omits value when a UnitModel is disposed. */
|
|
50
50
|
unitDisposed$: Observable<UnitModel>;
|
|
51
51
|
/** Subscribe to curtain type of units' disposing. */
|
|
52
|
-
getTypeOfUnitDisposed$<T extends UnitModel>(type:
|
|
52
|
+
getTypeOfUnitDisposed$<T extends UnitModel>(type: UniverInstanceType): Observable<T>;
|
|
53
53
|
/**
|
|
54
54
|
* An observable value that emits the id of the focused unit. A Univer app instance
|
|
55
55
|
* can only have 1 focused unit.
|
|
@@ -63,20 +63,20 @@ export interface IUniverInstanceService {
|
|
|
63
63
|
/** Get the currently focused unit. */
|
|
64
64
|
getFocusedUnit(): Nullable<UnitModel>;
|
|
65
65
|
/** @deprecated Use `getCurrentUnitOfType` instead. */
|
|
66
|
-
getCurrentUnitForType<T extends UnitModel>(type:
|
|
67
|
-
getCurrentUnitOfType<T extends UnitModel>(type:
|
|
66
|
+
getCurrentUnitForType<T extends UnitModel>(type: UniverInstanceType): Nullable<T>;
|
|
67
|
+
getCurrentUnitOfType<T extends UnitModel>(type: UniverInstanceType): Nullable<T>;
|
|
68
68
|
setCurrentUnitForType(unitId: string): void;
|
|
69
|
-
getCurrentTypeOfUnit$<T extends UnitModel>(type:
|
|
69
|
+
getCurrentTypeOfUnit$<T extends UnitModel>(type: UniverInstanceType): Observable<Nullable<T>>;
|
|
70
70
|
/** Create a unit with snapshot info. */
|
|
71
|
-
createUnit<T, U extends UnitModel>(type:
|
|
71
|
+
createUnit<T, U extends UnitModel>(type: UniverInstanceType, data: Partial<T>, options?: ICreateUnitOptions): U;
|
|
72
72
|
/** Dispose a unit */
|
|
73
73
|
disposeUnit(unitId: string): boolean;
|
|
74
|
-
registerCtorForType<T extends UnitModel>(type:
|
|
74
|
+
registerCtorForType<T extends UnitModel>(type: UniverInstanceType, ctor: new (...args: any[]) => T): IDisposable;
|
|
75
75
|
/** @deprecated */
|
|
76
76
|
changeDoc(unitId: string, doc: DocumentDataModel): void;
|
|
77
|
-
getUnit<T extends UnitModel>(id: string, type?:
|
|
78
|
-
getAllUnitsForType<T>(type:
|
|
79
|
-
getUnitType(unitId: string):
|
|
77
|
+
getUnit<T extends UnitModel>(id: string, type?: UniverInstanceType): Nullable<T>;
|
|
78
|
+
getAllUnitsForType<T>(type: UniverInstanceType): T[];
|
|
79
|
+
getUnitType(unitId: string): UniverInstanceType;
|
|
80
80
|
/** @deprecated */
|
|
81
81
|
getUniverSheetInstance(unitId: string): Nullable<Workbook>;
|
|
82
82
|
/** @deprecated */
|
|
@@ -93,20 +93,21 @@ export declare class UniverInstanceService extends Disposable implements IUniver
|
|
|
93
93
|
constructor(_injector: Injector, _contextService: IContextService, _logService: ILogService);
|
|
94
94
|
dispose(): void;
|
|
95
95
|
private _createHandler;
|
|
96
|
-
__setCreateHandler(handler: (type:
|
|
97
|
-
createUnit<T, U extends UnitModel>(type:
|
|
96
|
+
__setCreateHandler(handler: (type: UniverInstanceType, data: unknown, ctor: UnitCtor, options?: ICreateUnitOptions) => UnitModel): void;
|
|
97
|
+
createUnit<T, U extends UnitModel>(type: UniverInstanceType, data: T, options?: ICreateUnitOptions): U;
|
|
98
98
|
private readonly _ctorByType;
|
|
99
|
-
registerCtorForType<T extends UnitModel>(type:
|
|
99
|
+
registerCtorForType<T extends UnitModel>(type: UniverInstanceType, ctor: new () => T): IDisposable;
|
|
100
|
+
__getCtorByType(type: UniverInstanceType): UnitCtor | undefined;
|
|
100
101
|
private _currentUnits;
|
|
101
102
|
private readonly _currentUnits$;
|
|
102
|
-
readonly currentUnits$: Observable<Map<
|
|
103
|
+
readonly currentUnits$: Observable<Map<UniverInstanceType, Nullable<UnitModel<object, UniverInstanceType>>>>;
|
|
103
104
|
getCurrentTypeOfUnit$<T>(type: number): Observable<Nullable<T>>;
|
|
104
|
-
getCurrentUnitForType<T extends UnitModel>(type:
|
|
105
|
-
getCurrentUnitOfType<T extends UnitModel>(type:
|
|
105
|
+
getCurrentUnitForType<T extends UnitModel>(type: UniverInstanceType): Nullable<T>;
|
|
106
|
+
getCurrentUnitOfType<T extends UnitModel>(type: UniverInstanceType): Nullable<T>;
|
|
106
107
|
setCurrentUnitForType(unitId: string): void;
|
|
107
108
|
private readonly _unitAdded$;
|
|
108
|
-
readonly unitAdded$: Observable<UnitModel<object,
|
|
109
|
-
getTypeOfUnitAdded$<T extends UnitModel<object, number>>(type:
|
|
109
|
+
readonly unitAdded$: Observable<UnitModel<object, UniverInstanceType>>;
|
|
110
|
+
getTypeOfUnitAdded$<T extends UnitModel<object, number>>(type: UniverInstanceType): Observable<T>;
|
|
110
111
|
/**
|
|
111
112
|
* Add a unit into Univer.
|
|
112
113
|
*
|
|
@@ -116,13 +117,13 @@ export declare class UniverInstanceService extends Disposable implements IUniver
|
|
|
116
117
|
*/
|
|
117
118
|
__addUnit(unit: UnitModel, options?: ICreateUnitOptions): void;
|
|
118
119
|
private _unitDisposed$;
|
|
119
|
-
readonly unitDisposed$: Observable<UnitModel<object,
|
|
120
|
+
readonly unitDisposed$: Observable<UnitModel<object, UniverInstanceType>>;
|
|
120
121
|
getTypeOfUnitDisposed$<T extends UnitModel<object, number>>(type: UniverInstanceType): Observable<T>;
|
|
121
|
-
getUnit<T extends UnitModel = UnitModel>(id: string, type?:
|
|
122
|
+
getUnit<T extends UnitModel = UnitModel>(id: string, type?: UniverInstanceType): Nullable<T>;
|
|
122
123
|
getCurrentUniverDocInstance(): Nullable<DocumentDataModel>;
|
|
123
124
|
getUniverDocInstance(unitId: string): Nullable<DocumentDataModel>;
|
|
124
125
|
getUniverSheetInstance(unitId: string): Nullable<Workbook>;
|
|
125
|
-
getAllUnitsForType<T>(type:
|
|
126
|
+
getAllUnitsForType<T>(type: UniverInstanceType): T[];
|
|
126
127
|
changeDoc(unitId: string, doc: DocumentDataModel): void;
|
|
127
128
|
private readonly _focused$;
|
|
128
129
|
readonly focused$: Observable<Nullable<string>>;
|
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { Ctor, IDisposable } from '../../common/di';
|
|
17
|
-
import type { UnitType } from '../../common/unit';
|
|
18
17
|
import { Injector } from '../../common/di';
|
|
18
|
+
import { UniverInstanceType } from '../../common/unit';
|
|
19
19
|
import { Disposable } from '../../shared/lifecycle';
|
|
20
20
|
import { LifecycleService } from '../lifecycle/lifecycle.service';
|
|
21
21
|
import { ILogService } from '../log/log.service';
|
|
22
22
|
export declare const DependentOnSymbol: unique symbol;
|
|
23
23
|
export type PluginCtor<T extends Plugin = Plugin> = Ctor<T> & {
|
|
24
|
-
type:
|
|
24
|
+
type: UniverInstanceType;
|
|
25
25
|
pluginName: string;
|
|
26
26
|
packageName: string;
|
|
27
27
|
version: string;
|
|
@@ -34,13 +34,13 @@ export declare abstract class Plugin extends Disposable {
|
|
|
34
34
|
static pluginName: string;
|
|
35
35
|
static packageName: string;
|
|
36
36
|
static version: string;
|
|
37
|
-
static type:
|
|
37
|
+
static type: UniverInstanceType;
|
|
38
38
|
protected abstract _injector: Injector;
|
|
39
39
|
onStarting(): void;
|
|
40
40
|
onReady(): void;
|
|
41
41
|
onRendered(): void;
|
|
42
42
|
onSteady(): void;
|
|
43
|
-
getUnitType():
|
|
43
|
+
getUnitType(): UniverInstanceType;
|
|
44
44
|
getPluginName(): string;
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
@@ -85,7 +85,7 @@ export declare class PluginService implements IDisposable {
|
|
|
85
85
|
* @param {ConstructorParameters} [config] The configuration for the plugin.
|
|
86
86
|
*/
|
|
87
87
|
registerPlugin<T extends PluginCtor>(ctor: T, config?: ConstructorParameters<T>[0]): void;
|
|
88
|
-
startPluginsForType(type:
|
|
88
|
+
startPluginsForType(type: UniverInstanceType): void;
|
|
89
89
|
private _loadPluginsForType;
|
|
90
90
|
private _assertPluginValid;
|
|
91
91
|
private _flushTimerByType;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023-present DreamNum Co., Ltd.
|
|
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
|
+
import type { Observable } from 'rxjs';
|
|
17
|
+
import { UnitModel } from '../common/unit';
|
|
18
|
+
export declare class SlideDataModel extends UnitModel {
|
|
19
|
+
type: number;
|
|
20
|
+
getUnitId(): string;
|
|
21
|
+
name$: Observable<string>;
|
|
22
|
+
setName(name: string): void;
|
|
23
|
+
getSnapshot(): object;
|
|
24
|
+
getRev(): number;
|
|
25
|
+
incrementRev(): void;
|
|
26
|
+
setRev(rev: number): void;
|
|
27
|
+
}
|
|
@@ -155,14 +155,6 @@ export declare const DEFAULT_STYLES: {
|
|
|
155
155
|
t: null;
|
|
156
156
|
};
|
|
157
157
|
};
|
|
158
|
-
export declare const DEFAULT_SLIDE: {
|
|
159
|
-
id: string;
|
|
160
|
-
title: string;
|
|
161
|
-
pageSize: {
|
|
162
|
-
width: number;
|
|
163
|
-
height: number;
|
|
164
|
-
};
|
|
165
|
-
};
|
|
166
158
|
export declare const SHEET_EDITOR_UNITS: string[];
|
|
167
159
|
export declare const NAMED_STYLE_MAP: Record<NamedStyleType, Nullable<ITextStyle>>;
|
|
168
160
|
export declare const NAMED_STYLE_SPACE_MAP: Record<NamedStyleType, Nullable<IParagraphStyle>>;
|
|
@@ -26,7 +26,6 @@ export * from './interpolation-point-type';
|
|
|
26
26
|
export * from './locale-type';
|
|
27
27
|
export * from './mention-type';
|
|
28
28
|
export * from './protection-type';
|
|
29
|
-
export * from './prst-geom-type';
|
|
30
29
|
export * from './relative-date';
|
|
31
30
|
export * from './sheet-types';
|
|
32
31
|
export * from './text-style';
|
package/lib/types/univer.d.ts
CHANGED
|
@@ -15,18 +15,14 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import type { Theme } from '@univerjs/themes';
|
|
17
17
|
import type { IDisposable } from './common/di';
|
|
18
|
-
import type { UnitModel
|
|
18
|
+
import type { UnitModel } from './common/unit';
|
|
19
19
|
import type { LogLevel } from './services/log/log.service';
|
|
20
20
|
import type { DependencyOverride } from './services/plugin/plugin-override';
|
|
21
21
|
import type { Plugin, PluginCtor } from './services/plugin/plugin.service';
|
|
22
22
|
import type { ILocales } from './shared';
|
|
23
|
-
import type { IWorkbookData } from './sheets/typedef';
|
|
24
23
|
import type { LocaleType } from './types/enum/locale-type';
|
|
25
|
-
import type { IDocumentData, ISlideData } from './types/interfaces';
|
|
26
24
|
import { Injector } from './common/di';
|
|
27
|
-
import {
|
|
28
|
-
import { Workbook } from './sheets/workbook';
|
|
29
|
-
import { SlideDataModel } from './slides/slide-model';
|
|
25
|
+
import { UniverInstanceType } from './common/unit';
|
|
30
26
|
export interface IUniverConfig {
|
|
31
27
|
/**
|
|
32
28
|
* The theme of the Univer instance, default using the default theme.
|
|
@@ -89,21 +85,7 @@ export declare class Univer implements IDisposable {
|
|
|
89
85
|
onDispose(callback: () => void): IDisposable;
|
|
90
86
|
dispose(): void;
|
|
91
87
|
setLocale(locale: LocaleType): void;
|
|
92
|
-
createUnit<T, U extends UnitModel>(type:
|
|
93
|
-
/**
|
|
94
|
-
* Create a univer sheet instance with internal dependency injection.
|
|
95
|
-
*
|
|
96
|
-
* @deprecated use `createUnit` instead
|
|
97
|
-
*/
|
|
98
|
-
createUniverSheet(data: Partial<IWorkbookData>): Workbook;
|
|
99
|
-
/**
|
|
100
|
-
* @deprecated use `createUnit` instead
|
|
101
|
-
*/
|
|
102
|
-
createUniverDoc(data: Partial<IDocumentData>): DocumentDataModel;
|
|
103
|
-
/**
|
|
104
|
-
* @deprecated use `createUnit` instead
|
|
105
|
-
*/
|
|
106
|
-
createUniverSlide(data: Partial<ISlideData>): SlideDataModel;
|
|
88
|
+
createUnit<T, U extends UnitModel>(type: UniverInstanceType, data: Partial<T>): U;
|
|
107
89
|
private _init;
|
|
108
90
|
private _tryProgressToReady;
|
|
109
91
|
/** Register a plugin into univer. */
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/core`),require(`rxjs`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`rxjs`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCoreFacade={},e.UniverCore,e.rxjs))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=class extends t.Disposable{static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}};let i=Symbol(`initializers`),a=Symbol(`manualInit`);var o=class extends t.Disposable{constructor(e){if(super(),this._injector=e,this.constructor[a])return;let t=this,n=Object.getPrototypeOf(this)[i];n&&n.forEach(function(n){n.apply(t,[e])})}_initialize(e,...t){}_runInitializers(...e){let t=Object.getPrototypeOf(this)[i];t!=null&&t.length&&t.forEach(t=>t.apply(this,e))}static _enableManualInit(){this[a]=!0}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`_initialize`){let t=this.prototype[i];t||(t=[],this.prototype[i]=t),t.push(e.prototype._initialize)}else t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}};function s(e,t){return function(n,r){t(n,r,e)}}function c(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var l;let u=l=class extends r{constructor(e,t){super(),this._blob=e,this._injector=t}copyBlob(){return this._injector.createInstance(l,this._blob)}getAs(e){let t=this.copyBlob();return t.setContentType(e),t}getDataAsString(e){return this._blob===null?Promise.resolve(``):e===void 0?this._blob.text():new Promise((t,n)=>{this._blob.arrayBuffer().then(n=>{t(new TextDecoder(e).decode(n))}).catch(e=>{n(Error(`Failed to read Blob as ArrayBuffer: ${e.message}`))})})}getBytes(){return this._blob?this._blob.arrayBuffer().then(e=>new Uint8Array(e)):Promise.reject(Error(`Blob is undefined or null.`))}setBytes(e){return this._blob=new Blob([e.buffer]),this}setDataFromString(e,t){let n=t==null?`text/plain`:t;return this._blob=new Blob([e],{type:n}),this}getContentType(){var e;return(e=this._blob)==null?void 0:e.type}setContentType(e){var t;return this._blob=(t=this._blob)==null?void 0:t.slice(0,this._blob.size,e),this}};u=l=c([s(1,(0,t.Inject)(t.Injector))],u);function d(e){"@babel/helpers - typeof";return d=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},d(e)}function f(e,t){if(d(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(d(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function p(e){var t=f(e,`string`);return d(t)==`symbol`?t:t+``}function m(e,t,n){return(t=p(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var h=class e{static get(){if(this._instance)return this._instance;let t=new e;return this._instance=t,t}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}constructor(){for(let t in e.prototype)this[t]=e.prototype[t]}get AbsoluteRefType(){return t.AbsoluteRefType}get UniverInstanceType(){return t.UniverInstanceType}get LifecycleStages(){return t.LifecycleStages}get DataValidationType(){return t.DataValidationType}get DataValidationErrorStyle(){return t.DataValidationErrorStyle}get DataValidationRenderMode(){return t.DataValidationRenderMode}get DataValidationOperator(){return t.DataValidationOperator}get DataValidationStatus(){return t.DataValidationStatus}get CommandType(){return t.CommandType}get BaselineOffset(){return t.BaselineOffset}get BooleanNumber(){return t.BooleanNumber}get HorizontalAlign(){return t.HorizontalAlign}get TextDecoration(){return t.TextDecoration}get TextDirection(){return t.TextDirection}get VerticalAlign(){return t.VerticalAlign}get WrapStrategy(){return t.WrapStrategy}get BorderType(){return t.BorderType}get BorderStyleTypes(){return t.BorderStyleTypes}get AutoFillSeries(){return t.AutoFillSeries}get ColorType(){return t.ColorType}get CommonHideTypes(){return t.CommonHideTypes}get CopyPasteType(){return t.CopyPasteType}get DeleteDirection(){return t.DeleteDirection}get DeveloperMetadataVisibility(){return t.DeveloperMetadataVisibility}get Dimension(){return t.Dimension}get Direction(){return t.Direction}get InterpolationPointType(){return t.InterpolationPointType}get LocaleType(){return t.LocaleType}get MentionType(){return t.MentionType}get ProtectionType(){return t.ProtectionType}get RelativeDate(){return t.RelativeDate}get SheetTypes(){return t.SheetTypes}get ThemeColorType(){return t.ThemeColorType}};m(h,`_instance`,void 0);var g=class e{static get(){if(this._instance)return this._instance;let t=new e;return this._instance=t,t}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}constructor(){for(let t in e.prototype)this[t]=e.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`}};m(g,`_instance`,void 0);let _=class extends r{constructor(e,t){super(),this._injector=e,this._lifecycleService=t}onStarting(e){return(0,t.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,n.filter)(e=>e===t.LifecycleStages.Starting)).subscribe(e))}onReady(e){return(0,t.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,n.filter)(e=>e===t.LifecycleStages.Ready)).subscribe(e))}onRendered(e){return(0,t.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,n.filter)(e=>e===t.LifecycleStages.Rendered)).subscribe(e))}onSteady(e){return(0,t.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,n.filter)(e=>e===t.LifecycleStages.Steady)).subscribe(e))}onBeforeUndo(e){return this._injector.get(t.ICommandService).beforeCommandExecuted(n=>{if(n.id===t.UndoCommand.id){let n=this._injector.get(t.IUndoRedoService).pitchTopUndoElement();n&&e(n)}})}onUndo(e){return this._injector.get(t.ICommandService).onCommandExecuted(n=>{if(n.id===t.UndoCommand.id){let n=this._injector.get(t.IUndoRedoService).pitchTopUndoElement();n&&e(n)}})}onBeforeRedo(e){return this._injector.get(t.ICommandService).beforeCommandExecuted(n=>{if(n.id===t.RedoCommand.id){let n=this._injector.get(t.IUndoRedoService).pitchTopRedoElement();n&&e(n)}})}onRedo(e){return this._injector.get(t.ICommandService).onCommandExecuted(n=>{if(n.id===t.RedoCommand.id){let n=this._injector.get(t.IUndoRedoService).pitchTopRedoElement();n&&e(n)}})}};_=c([s(0,(0,t.Inject)(t.Injector)),s(1,(0,t.Inject)(t.LifecycleService))],_);let v=class extends o{constructor(e,t){super(t),this.doc=e}};v=c([s(1,(0,t.Inject)(t.Injector))],v);var y=class{constructor(){m(this,`_eventRegistry`,new Map),m(this,`_eventHandlerMap`,new Map),m(this,`_eventHandlerRegisted`,new Map)}_ensureEventRegistry(e){return this._eventRegistry.has(e)||this._eventRegistry.set(e,new t.Registry),this._eventRegistry.get(e)}registerEventHandler(e,n){let r=this._eventHandlerMap.get(e);return r?r.add(n):this._eventHandlerMap.set(e,new Set([n])),this._ensureEventRegistry(e).getData().length&&this._initEventHandler(e),(0,t.toDisposable)(()=>{var t,r,i;(t=this._eventHandlerMap.get(e))==null||t.delete(n),(r=this._eventHandlerRegisted.get(e))==null||(r=r.get(n))==null||r.dispose(),(i=this._eventHandlerRegisted.get(e))==null||i.delete(n)})}removeEvent(e,t){let n=this._ensureEventRegistry(e);if(n.delete(t),n.getData().length===0){let t=this._eventHandlerRegisted.get(e);t==null||t.forEach(e=>e.dispose()),this._eventHandlerRegisted.delete(e)}}_initEventHandler(e){let n=this._eventHandlerRegisted.get(e),r=this._eventHandlerMap.get(e);r&&(!n||n.size===0)&&(n=new Map,this._eventHandlerRegisted.set(e,n),r==null||r.forEach(e=>{n==null||n.set(e,(0,t.toDisposable)(e()))}))}addEvent(e,n){return this._ensureEventRegistry(e).add(n),this._initEventHandler(e),(0,t.toDisposable)(()=>this.removeEvent(e,n))}fireEvent(e,t){var n;return(n=this._eventRegistry.get(e))==null||n.getData().forEach(e=>{e(t)}),t.cancel}};let b=class extends r{constructor(e,t){super(),this._injector=e,this._userManagerService=t}getCurrentUser(){return this._userManagerService.getCurrentUser()}};b=c([s(0,(0,t.Inject)(t.Injector)),s(1,(0,t.Inject)(t.UserManagerService))],b);var x=class e{static get(){if(this._instance)return this._instance;let t=new e;return this._instance=t,t}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}get rectangle(){return t.Rectangle}get numfmt(){return t.numfmt}get tools(){return t.Tools}};m(x,`_instance`,void 0);var S;let C=Symbol(`initializers`),w=S=class extends t.Disposable{static newAPI(e){return(e instanceof t.Univer?e.__getInjector():e).createInstance(S)}_initialize(e){}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`_initialize`){let t=this.prototype[C];t||(t=[],this.prototype[C]=t),t.push(e.prototype._initialize)}else t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}constructor(e,n,r,i){super(),this._injector=e,this._commandService=n,this._univerInstanceService=r,this._lifecycleService=i,m(this,`_eventRegistry`,new y),m(this,`registerEventHandler`,(e,t)=>this._eventRegistry.registerEventHandler(e,t)),this.disposeWithMe(this.registerEventHandler(this.Event.LifeCycleChanged,()=>(0,t.toDisposable)(this._lifecycleService.lifecycle$.subscribe(e=>{this.fireEvent(this.Event.LifeCycleChanged,{stage:e})})))),this._initUnitEvent(this._injector),this._initBeforeCommandEvent(this._injector),this._initCommandEvent(this._injector),this._injector.onDispose(()=>{this.dispose()});let a=Object.getPrototypeOf(this)[C];if(a){let t=this;a.forEach(function(n){n.apply(t,[e])})}}_initCommandEvent(e){let n=e.get(t.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.Redo,()=>n.onCommandExecuted(e=>{let{id:n,type:r,params:i}=e;if(e.id===t.RedoCommand.id){let e={id:n,type:r,params:i};this.fireEvent(this.Event.Redo,e)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.Undo,()=>n.onCommandExecuted(e=>{let{id:n,type:r,params:i}=e;if(e.id===t.UndoCommand.id){let e={id:n,type:r,params:i};this.fireEvent(this.Event.Undo,e)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.CommandExecuted,()=>n.onCommandExecuted((e,n)=>{let{id:r,type:i,params:a}=e;if(e.id!==t.RedoCommand.id&&e.id!==t.UndoCommand.id){let e={id:r,type:i,params:a,options:n};this.fireEvent(this.Event.CommandExecuted,e)}})))}_initBeforeCommandEvent(e){let n=e.get(t.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.BeforeRedo,()=>n.beforeCommandExecuted(e=>{let{id:n,type:r,params:i}=e;if(e.id===t.RedoCommand.id){let e={id:n,type:r,params:i};if(this.fireEvent(this.Event.BeforeRedo,e),e.cancel)throw new t.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeUndo,()=>n.beforeCommandExecuted(e=>{let{id:n,type:r,params:i}=e;if(e.id===t.UndoCommand.id){let e={id:n,type:r,params:i};if(this.fireEvent(this.Event.BeforeUndo,e),e.cancel)throw new t.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommandExecute,()=>n.beforeCommandExecuted((e,n)=>{let{id:r,type:i,params:a}=e;if(e.id!==t.RedoCommand.id&&e.id!==t.UndoCommand.id){let e={id:r,type:i,params:a,options:n};if(this.fireEvent(this.Event.BeforeCommandExecute,e),e.cancel)throw new t.CanceledError}})))}_initUnitEvent(e){let n=e.get(t.IUniverInstanceService);this.disposeWithMe(this.registerEventHandler(this.Event.DocDisposed,()=>n.unitDisposed$.subscribe(e=>{e.type===t.UniverInstanceType.UNIVER_DOC&&this.fireEvent(this.Event.DocDisposed,{unitId:e.getUnitId(),unitType:e.type,snapshot:e.getSnapshot()})}))),this.disposeWithMe(this.registerEventHandler(this.Event.DocCreated,()=>n.unitAdded$.subscribe(n=>{if(n.type===t.UniverInstanceType.UNIVER_DOC){let t=n,r=e.createInstance(v,t);this.fireEvent(this.Event.DocCreated,{unitId:n.getUnitId(),type:n.type,doc:r,unit:r})}})))}disposeUnit(e){return this._univerInstanceService.disposeUnit(e)}getCurrentLifecycleStage(){return this._injector.get(t.LifecycleService).stage}undo(){return this._commandService.executeCommand(t.UndoCommand.id)}redo(){return this._commandService.executeCommand(t.RedoCommand.id)}toggleDarkMode(e){this._injector.get(t.ThemeService).setDarkMode(e)}loadLocales(e,n){this._injector.get(t.LocaleService).load({[e]:n})}setLocale(e){this._injector.get(t.LocaleService).setLocale(e)}onBeforeCommandExecute(e){return this._commandService.beforeCommandExecuted((t,n)=>{e(t,n)})}onCommandExecuted(e){return this._commandService.onCommandExecuted((t,n)=>{e(t,n)})}executeCommand(e,t,n){return this._commandService.executeCommand(e,t,n)}syncExecuteCommand(e,t,n){return this._commandService.syncExecuteCommand(e,t,n)}getHooks(){return this._injector.createInstance(_)}get Enum(){return h.get()}get Event(){return g.get()}get Util(){return x.get()}addEvent(e,t){if(!e||!t)throw Error(`Cannot add empty event`);return this._eventRegistry.addEvent(e,t)}fireEvent(e,t){return this._eventRegistry.fireEvent(e,t)}getUserManager(){return this._injector.createInstance(b)}newBlob(){return this._injector.createInstance(u,null)}newRichText(e){return t.RichTextBuilder.create(e)}newRichTextValue(e){return t.RichTextValue.create(e)}newParagraphStyle(e){return t.ParagraphStyleBuilder.create(e)}newParagraphStyleValue(e){return t.ParagraphStyleValue.create(e)}newTextStyle(e){return t.TextStyleBuilder.create(e)}newTextStyleValue(e){return t.TextStyleValue.create(e)}newTextDecoration(e){return new t.TextDecorationBuilder(e)}};w=S=c([s(0,(0,t.Inject)(t.Injector)),s(1,t.ICommandService),s(2,t.IUniverInstanceService),s(3,(0,t.Inject)(t.LifecycleService))],w),e.FBase=r,e.FBaseInitialable=o,Object.defineProperty(e,`FBlob`,{enumerable:!0,get:function(){return u}}),e.FEnum=h,e.FEventName=g,Object.defineProperty(e,`FHooks`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,`FUniver`,{enumerable:!0,get:function(){return w}}),e.FUtil=x});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/core`),require(`rxjs`)):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`,`rxjs`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCoreFacade={},e.UniverCore,e.rxjs))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=class extends t.Disposable{static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}};let i=Symbol(`initializers`),a=Symbol(`manualInit`);var o=class extends t.Disposable{constructor(e){if(super(),this._injector=e,this.constructor[a])return;let t=this,n=Object.getPrototypeOf(this)[i];n&&n.forEach(function(n){n.apply(t,[e])})}_initialize(e,...t){}_runInitializers(...e){let t=Object.getPrototypeOf(this)[i];t!=null&&t.length&&t.forEach(t=>t.apply(this,e))}static _enableManualInit(){this[a]=!0}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`_initialize`){let t=this.prototype[i];t||(t=[],this.prototype[i]=t),t.push(e.prototype._initialize)}else t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}};function s(e,t){return function(n,r){t(n,r,e)}}function c(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var l;let u=l=class extends r{constructor(e,t){super(),this._blob=e,this._injector=t}copyBlob(){return this._injector.createInstance(l,this._blob)}getAs(e){let t=this.copyBlob();return t.setContentType(e),t}getDataAsString(e){return this._blob===null?Promise.resolve(``):e===void 0?this._blob.text():new Promise((t,n)=>{this._blob.arrayBuffer().then(n=>{t(new TextDecoder(e).decode(n))}).catch(e=>{n(Error(`Failed to read Blob as ArrayBuffer: ${e.message}`))})})}getBytes(){return this._blob?this._blob.arrayBuffer().then(e=>new Uint8Array(e)):Promise.reject(Error(`Blob is undefined or null.`))}setBytes(e){return this._blob=new Blob([e.buffer]),this}setDataFromString(e,t){return this._blob=new Blob([e],{type:t==null?`text/plain`:t}),this}getContentType(){var e;return(e=this._blob)==null?void 0:e.type}setContentType(e){var t;return this._blob=(t=this._blob)==null?void 0:t.slice(0,this._blob.size,e),this}};u=l=c([s(1,(0,t.Inject)(t.Injector))],u);function d(e){"@babel/helpers - typeof";return d=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},d(e)}function f(e,t){if(d(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(d(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function p(e){var t=f(e,`string`);return d(t)==`symbol`?t:t+``}function m(e,t,n){return(t=p(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var h=class e{static get(){if(this._instance)return this._instance;let t=new e;return this._instance=t,t}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}constructor(){for(let t in e.prototype)this[t]=e.prototype[t]}get AbsoluteRefType(){return t.AbsoluteRefType}get UniverInstanceType(){return t.UniverInstanceType}get LifecycleStages(){return t.LifecycleStages}get DataValidationType(){return t.DataValidationType}get DataValidationErrorStyle(){return t.DataValidationErrorStyle}get DataValidationRenderMode(){return t.DataValidationRenderMode}get DataValidationOperator(){return t.DataValidationOperator}get DataValidationStatus(){return t.DataValidationStatus}get CommandType(){return t.CommandType}get BaselineOffset(){return t.BaselineOffset}get BooleanNumber(){return t.BooleanNumber}get HorizontalAlign(){return t.HorizontalAlign}get TextDecoration(){return t.TextDecoration}get TextDirection(){return t.TextDirection}get VerticalAlign(){return t.VerticalAlign}get WrapStrategy(){return t.WrapStrategy}get BorderType(){return t.BorderType}get BorderStyleTypes(){return t.BorderStyleTypes}get AutoFillSeries(){return t.AutoFillSeries}get ColorType(){return t.ColorType}get CommonHideTypes(){return t.CommonHideTypes}get CopyPasteType(){return t.CopyPasteType}get DeleteDirection(){return t.DeleteDirection}get DeveloperMetadataVisibility(){return t.DeveloperMetadataVisibility}get Dimension(){return t.Dimension}get Direction(){return t.Direction}get InterpolationPointType(){return t.InterpolationPointType}get LocaleType(){return t.LocaleType}get MentionType(){return t.MentionType}get ProtectionType(){return t.ProtectionType}get RelativeDate(){return t.RelativeDate}get SheetTypes(){return t.SheetTypes}get ThemeColorType(){return t.ThemeColorType}};m(h,`_instance`,void 0);var g=class e{static get(){if(this._instance)return this._instance;let t=new e;return this._instance=t,t}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}constructor(){for(let t in e.prototype)this[t]=e.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`}};m(g,`_instance`,void 0);let _=class extends r{constructor(e,t){super(),this._injector=e,this._lifecycleService=t}onStarting(e){return(0,t.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,n.filter)(e=>e===t.LifecycleStages.Starting)).subscribe(e))}onReady(e){return(0,t.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,n.filter)(e=>e===t.LifecycleStages.Ready)).subscribe(e))}onRendered(e){return(0,t.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,n.filter)(e=>e===t.LifecycleStages.Rendered)).subscribe(e))}onSteady(e){return(0,t.toDisposable)(this._lifecycleService.lifecycle$.pipe((0,n.filter)(e=>e===t.LifecycleStages.Steady)).subscribe(e))}onBeforeUndo(e){return this._injector.get(t.ICommandService).beforeCommandExecuted(n=>{if(n.id===t.UndoCommand.id){let n=this._injector.get(t.IUndoRedoService).pitchTopUndoElement();n&&e(n)}})}onUndo(e){return this._injector.get(t.ICommandService).onCommandExecuted(n=>{if(n.id===t.UndoCommand.id){let n=this._injector.get(t.IUndoRedoService).pitchTopUndoElement();n&&e(n)}})}onBeforeRedo(e){return this._injector.get(t.ICommandService).beforeCommandExecuted(n=>{if(n.id===t.RedoCommand.id){let n=this._injector.get(t.IUndoRedoService).pitchTopRedoElement();n&&e(n)}})}onRedo(e){return this._injector.get(t.ICommandService).onCommandExecuted(n=>{if(n.id===t.RedoCommand.id){let n=this._injector.get(t.IUndoRedoService).pitchTopRedoElement();n&&e(n)}})}};_=c([s(0,(0,t.Inject)(t.Injector)),s(1,(0,t.Inject)(t.LifecycleService))],_);let v=class extends o{constructor(e,t){super(t),this.doc=e}};v=c([s(1,(0,t.Inject)(t.Injector))],v);var y=class{constructor(){m(this,`_eventRegistry`,new Map),m(this,`_eventHandlerMap`,new Map),m(this,`_eventHandlerRegisted`,new Map)}_ensureEventRegistry(e){return this._eventRegistry.has(e)||this._eventRegistry.set(e,new t.Registry),this._eventRegistry.get(e)}registerEventHandler(e,n){let r=this._eventHandlerMap.get(e);return r?r.add(n):this._eventHandlerMap.set(e,new Set([n])),this._ensureEventRegistry(e).getData().length&&this._initEventHandler(e),(0,t.toDisposable)(()=>{var t,r,i;(t=this._eventHandlerMap.get(e))==null||t.delete(n),(r=this._eventHandlerRegisted.get(e))==null||(r=r.get(n))==null||r.dispose(),(i=this._eventHandlerRegisted.get(e))==null||i.delete(n)})}removeEvent(e,t){let n=this._ensureEventRegistry(e);if(n.delete(t),n.getData().length===0){let t=this._eventHandlerRegisted.get(e);t==null||t.forEach(e=>e.dispose()),this._eventHandlerRegisted.delete(e)}}_initEventHandler(e){let n=this._eventHandlerRegisted.get(e),r=this._eventHandlerMap.get(e);r&&(!n||n.size===0)&&(n=new Map,this._eventHandlerRegisted.set(e,n),r==null||r.forEach(e=>{n==null||n.set(e,(0,t.toDisposable)(e()))}))}addEvent(e,n){return this._ensureEventRegistry(e).add(n),this._initEventHandler(e),(0,t.toDisposable)(()=>this.removeEvent(e,n))}fireEvent(e,t){var n;return(n=this._eventRegistry.get(e))==null||n.getData().forEach(e=>{e(t)}),t.cancel}};let b=class extends r{constructor(e,t){super(),this._injector=e,this._userManagerService=t}getCurrentUser(){return this._userManagerService.getCurrentUser()}};b=c([s(0,(0,t.Inject)(t.Injector)),s(1,(0,t.Inject)(t.UserManagerService))],b);var x=class e{static get(){if(this._instance)return this._instance;let t=new e;return this._instance=t,t}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}get rectangle(){return t.Rectangle}get numfmt(){return t.numfmt}get tools(){return t.Tools}};m(x,`_instance`,void 0);var S;let C=Symbol(`initializers`),w=S=class extends t.Disposable{static newAPI(e){return(e instanceof t.Univer?e.__getInjector():e).createInstance(S)}_initialize(e){}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`_initialize`){let t=this.prototype[C];t||(t=[],this.prototype[C]=t),t.push(e.prototype._initialize)}else t!==`constructor`&&(this.prototype[t]=e.prototype[t])}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}constructor(e,n,r,i){super(),this._injector=e,this._commandService=n,this._univerInstanceService=r,this._lifecycleService=i,m(this,`_eventRegistry`,new y),m(this,`registerEventHandler`,(e,t)=>this._eventRegistry.registerEventHandler(e,t)),this.disposeWithMe(this.registerEventHandler(this.Event.LifeCycleChanged,()=>(0,t.toDisposable)(this._lifecycleService.lifecycle$.subscribe(e=>{this.fireEvent(this.Event.LifeCycleChanged,{stage:e})})))),this._initUnitEvent(this._injector),this._initBeforeCommandEvent(this._injector),this._initCommandEvent(this._injector),this._injector.onDispose(()=>{this.dispose()});let a=Object.getPrototypeOf(this)[C];if(a){let t=this;a.forEach(function(n){n.apply(t,[e])})}}_initCommandEvent(e){let n=e.get(t.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.Redo,()=>n.onCommandExecuted(e=>{let{id:n,type:r,params:i}=e;if(e.id===t.RedoCommand.id){let e={id:n,type:r,params:i};this.fireEvent(this.Event.Redo,e)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.Undo,()=>n.onCommandExecuted(e=>{let{id:n,type:r,params:i}=e;if(e.id===t.UndoCommand.id){let e={id:n,type:r,params:i};this.fireEvent(this.Event.Undo,e)}}))),this.disposeWithMe(this.registerEventHandler(this.Event.CommandExecuted,()=>n.onCommandExecuted((e,n)=>{let{id:r,type:i,params:a}=e;if(e.id!==t.RedoCommand.id&&e.id!==t.UndoCommand.id){let e={id:r,type:i,params:a,options:n};this.fireEvent(this.Event.CommandExecuted,e)}})))}_initBeforeCommandEvent(e){let n=e.get(t.ICommandService);this.disposeWithMe(this.registerEventHandler(this.Event.BeforeRedo,()=>n.beforeCommandExecuted(e=>{let{id:n,type:r,params:i}=e;if(e.id===t.RedoCommand.id){let e={id:n,type:r,params:i};if(this.fireEvent(this.Event.BeforeRedo,e),e.cancel)throw new t.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeUndo,()=>n.beforeCommandExecuted(e=>{let{id:n,type:r,params:i}=e;if(e.id===t.UndoCommand.id){let e={id:n,type:r,params:i};if(this.fireEvent(this.Event.BeforeUndo,e),e.cancel)throw new t.CanceledError}}))),this.disposeWithMe(this.registerEventHandler(this.Event.BeforeCommandExecute,()=>n.beforeCommandExecuted((e,n)=>{let{id:r,type:i,params:a}=e;if(e.id!==t.RedoCommand.id&&e.id!==t.UndoCommand.id){let e={id:r,type:i,params:a,options:n};if(this.fireEvent(this.Event.BeforeCommandExecute,e),e.cancel)throw new t.CanceledError}})))}_initUnitEvent(e){let n=e.get(t.IUniverInstanceService);this.disposeWithMe(this.registerEventHandler(this.Event.DocDisposed,()=>n.unitDisposed$.subscribe(e=>{e.type===t.UniverInstanceType.UNIVER_DOC&&this.fireEvent(this.Event.DocDisposed,{unitId:e.getUnitId(),unitType:e.type,snapshot:e.getSnapshot()})}))),this.disposeWithMe(this.registerEventHandler(this.Event.DocCreated,()=>n.unitAdded$.subscribe(n=>{if(n.type===t.UniverInstanceType.UNIVER_DOC){let t=n,r=e.createInstance(v,t);this.fireEvent(this.Event.DocCreated,{unitId:n.getUnitId(),type:n.type,doc:r,unit:r})}})))}disposeUnit(e){return this._univerInstanceService.disposeUnit(e)}getCurrentLifecycleStage(){return this._injector.get(t.LifecycleService).stage}undo(){return this._commandService.executeCommand(t.UndoCommand.id)}redo(){return this._commandService.executeCommand(t.RedoCommand.id)}toggleDarkMode(e){this._injector.get(t.ThemeService).setDarkMode(e)}loadLocales(e,n){this._injector.get(t.LocaleService).load({[e]:n})}setLocale(e){this._injector.get(t.LocaleService).setLocale(e)}onBeforeCommandExecute(e){return this._commandService.beforeCommandExecuted((t,n)=>{e(t,n)})}onCommandExecuted(e){return this._commandService.onCommandExecuted((t,n)=>{e(t,n)})}executeCommand(e,t,n){return this._commandService.executeCommand(e,t,n)}syncExecuteCommand(e,t,n){return this._commandService.syncExecuteCommand(e,t,n)}getHooks(){return this._injector.createInstance(_)}get Enum(){return h.get()}get Event(){return g.get()}get Util(){return x.get()}addEvent(e,t){if(!e||!t)throw Error(`Cannot add empty event`);return this._eventRegistry.addEvent(e,t)}fireEvent(e,t){return this._eventRegistry.fireEvent(e,t)}getUserManager(){return this._injector.createInstance(b)}newBlob(){return this._injector.createInstance(u,null)}newRichText(e){return t.RichTextBuilder.create(e)}newRichTextValue(e){return t.RichTextValue.create(e)}newParagraphStyle(e){return t.ParagraphStyleBuilder.create(e)}newParagraphStyleValue(e){return t.ParagraphStyleValue.create(e)}newTextStyle(e){return t.TextStyleBuilder.create(e)}newTextStyleValue(e){return t.TextStyleValue.create(e)}newTextDecoration(e){return new t.TextDecorationBuilder(e)}};w=S=c([s(0,(0,t.Inject)(t.Injector)),s(1,t.ICommandService),s(2,t.IUniverInstanceService),s(3,(0,t.Inject)(t.LifecycleService))],w),e.FBase=r,e.FBaseInitialable=o,Object.defineProperty(e,`FBlob`,{enumerable:!0,get:function(){return u}}),e.FEnum=h,e.FEventName=g,Object.defineProperty(e,`FHooks`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,`FUniver`,{enumerable:!0,get:function(){return w}}),e.FUtil=x});
|