@univerjs/core 1.4.0 → 1.5.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/README.md +7 -5
- package/lib/cjs/facade.js +11 -11
- package/lib/cjs/index.js +57 -22
- package/lib/es/facade.js +11 -11
- package/lib/es/index.js +57 -22
- package/lib/facade.js +11 -11
- package/lib/index.js +57 -22
- package/lib/types/common/interceptor.d.ts +6 -3
- package/lib/types/sheets/typedef.d.ts +8 -3
- package/lib/types/types/enum/sheet-types.d.ts +2 -1
- package/lib/umd/facade.js +1 -1
- package/lib/umd/index.js +2 -2
- package/package.json +6 -6
package/lib/index.js
CHANGED
|
@@ -12,18 +12,18 @@ import KDBush from "kdbush";
|
|
|
12
12
|
|
|
13
13
|
// \0rolldown/runtime.js
|
|
14
14
|
var __defProp = Object.defineProperty;
|
|
15
|
-
var __exportAll = (all,
|
|
16
|
-
let target = {};
|
|
15
|
+
var __exportAll = (all, flags) => {
|
|
16
|
+
let target = Object.setPrototypeOf({}, null);
|
|
17
17
|
for (var name in all) {
|
|
18
18
|
__defProp(target, name, {
|
|
19
19
|
get: all[name],
|
|
20
20
|
enumerable: true
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
|
-
if (!
|
|
23
|
+
if (!(flags & 1)) {
|
|
24
24
|
__defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
25
25
|
}
|
|
26
|
-
return target;
|
|
26
|
+
return flags & 2 ? target : Object.preventExtensions(target);
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
// src/common/shims.ts
|
|
@@ -121,7 +121,7 @@ function installShims() {
|
|
|
121
121
|
installStringAt();
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
// \0@oxc-project+runtime@0.
|
|
124
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
|
|
125
125
|
function _typeof(o) {
|
|
126
126
|
"@babel/helpers - typeof";
|
|
127
127
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -131,25 +131,25 @@ function _typeof(o) {
|
|
|
131
131
|
}, _typeof(o);
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
-
// \0@oxc-project+runtime@0.
|
|
135
|
-
function toPrimitive(t,
|
|
134
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
|
|
135
|
+
function toPrimitive(t, e) {
|
|
136
136
|
if ("object" != _typeof(t) || !t) return t;
|
|
137
|
-
var
|
|
138
|
-
if (void 0 !==
|
|
139
|
-
var i =
|
|
137
|
+
var r;
|
|
138
|
+
if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
|
|
139
|
+
var i = r.call(t, e || "default");
|
|
140
140
|
if ("object" != _typeof(i)) return i;
|
|
141
141
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
142
142
|
}
|
|
143
|
-
return ("string" ===
|
|
143
|
+
return ("string" === e ? String : Number)(t);
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
// \0@oxc-project+runtime@0.
|
|
146
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
|
|
147
147
|
function toPropertyKey(t) {
|
|
148
148
|
var i = toPrimitive(t, "string");
|
|
149
149
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
-
// \0@oxc-project+runtime@0.
|
|
152
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
|
|
153
153
|
function _defineProperty(e, r, t) {
|
|
154
154
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
155
155
|
value: t,
|
|
@@ -1421,6 +1421,7 @@ let SheetTypes = /* @__PURE__ */ function(SheetTypes) {
|
|
|
1421
1421
|
SheetTypes[SheetTypes["GRID"] = 0] = "GRID";
|
|
1422
1422
|
SheetTypes[SheetTypes["KANBAN"] = 1] = "KANBAN";
|
|
1423
1423
|
SheetTypes[SheetTypes["GANTT"] = 2] = "GANTT";
|
|
1424
|
+
SheetTypes[SheetTypes["CHART"] = 3] = "CHART";
|
|
1424
1425
|
return SheetTypes;
|
|
1425
1426
|
}({});
|
|
1426
1427
|
|
|
@@ -1642,7 +1643,7 @@ let ThemeColors = /* @__PURE__ */ function(ThemeColors) {
|
|
|
1642
1643
|
|
|
1643
1644
|
// package.json
|
|
1644
1645
|
var name = "@univerjs/core";
|
|
1645
|
-
var version = "1.
|
|
1646
|
+
var version = "1.5.0";
|
|
1646
1647
|
|
|
1647
1648
|
// src/common/array.ts
|
|
1648
1649
|
/**
|
|
@@ -1980,14 +1981,14 @@ function hashLogContent(...args) {
|
|
|
1980
1981
|
return args.map((a) => JSON.stringify(a)).join("");
|
|
1981
1982
|
}
|
|
1982
1983
|
|
|
1983
|
-
// \0@oxc-project+runtime@0.
|
|
1984
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/decorateParam.js
|
|
1984
1985
|
function __decorateParam(paramIndex, decorator) {
|
|
1985
1986
|
return function(target, key) {
|
|
1986
1987
|
decorator(target, key, paramIndex);
|
|
1987
1988
|
};
|
|
1988
1989
|
}
|
|
1989
1990
|
|
|
1990
|
-
// \0@oxc-project+runtime@0.
|
|
1991
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/decorate.js
|
|
1991
1992
|
function __decorate(decorators, target, key, desc) {
|
|
1992
1993
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1993
1994
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -11747,8 +11748,9 @@ const composeInterceptors = (interceptors) => function(initialValue, context) {
|
|
|
11747
11748
|
}
|
|
11748
11749
|
return value;
|
|
11749
11750
|
};
|
|
11750
|
-
var InterceptorManager = class {
|
|
11751
|
+
var InterceptorManager = class extends Disposable {
|
|
11751
11752
|
constructor(interceptorPoints) {
|
|
11753
|
+
super();
|
|
11752
11754
|
_defineProperty(this, "_interceptorsByName", /* @__PURE__ */ new Map());
|
|
11753
11755
|
_defineProperty(this, "_interceptorPoints", void 0);
|
|
11754
11756
|
this._interceptorPoints = interceptorPoints;
|
|
@@ -11759,26 +11761,41 @@ var InterceptorManager = class {
|
|
|
11759
11761
|
* @param filter A callback function to filter the interceptors.
|
|
11760
11762
|
* @returns It will return a composed interceptor function. If you will perform the interceptor repeatedly,
|
|
11761
11763
|
* you should cache the result instead of calling this function multiple times.
|
|
11764
|
+
* A cached chain cannot start a new call after this manager is disposed.
|
|
11762
11765
|
*/
|
|
11763
11766
|
fetchThroughInterceptors(name, filter) {
|
|
11767
|
+
this.ensureNotDisposed();
|
|
11764
11768
|
const key = name;
|
|
11765
11769
|
let interceptors = this._interceptorsByName.get(key);
|
|
11766
11770
|
if (filter) interceptors = interceptors.filter(filter);
|
|
11767
|
-
|
|
11771
|
+
const handler = composeInterceptors(interceptors || []);
|
|
11772
|
+
return (initialValue, context) => {
|
|
11773
|
+
this.ensureNotDisposed();
|
|
11774
|
+
return handler(initialValue, context);
|
|
11775
|
+
};
|
|
11768
11776
|
}
|
|
11769
11777
|
intercept(name, interceptor) {
|
|
11778
|
+
this.ensureNotDisposed();
|
|
11770
11779
|
const key = name;
|
|
11771
11780
|
if (!this._interceptorsByName.has(key)) this._interceptorsByName.set(key, []);
|
|
11772
11781
|
const interceptors = this._interceptorsByName.get(key);
|
|
11773
11782
|
interceptors.push(interceptor);
|
|
11774
11783
|
this._interceptorsByName.set(key, interceptors.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0)));
|
|
11775
|
-
|
|
11784
|
+
let registration = interceptor;
|
|
11785
|
+
return () => {
|
|
11786
|
+
const current = registration;
|
|
11787
|
+
registration = void 0;
|
|
11788
|
+
if (!current || this._disposed) return false;
|
|
11789
|
+
const list = this._interceptorsByName.get(key);
|
|
11790
|
+
return list ? remove(list, current) : false;
|
|
11791
|
+
};
|
|
11776
11792
|
}
|
|
11777
11793
|
getInterceptPoints() {
|
|
11778
11794
|
return this._interceptorPoints;
|
|
11779
11795
|
}
|
|
11780
11796
|
dispose() {
|
|
11781
11797
|
this._interceptorsByName.clear();
|
|
11798
|
+
super.dispose();
|
|
11782
11799
|
}
|
|
11783
11800
|
};
|
|
11784
11801
|
function createAsyncInterceptorKey(key) {
|
|
@@ -11803,8 +11820,9 @@ const composeAsyncInterceptors = (interceptors) => {
|
|
|
11803
11820
|
return value;
|
|
11804
11821
|
};
|
|
11805
11822
|
};
|
|
11806
|
-
var AsyncInterceptorManager = class {
|
|
11823
|
+
var AsyncInterceptorManager = class extends Disposable {
|
|
11807
11824
|
constructor(asyncInterceptorPoints) {
|
|
11825
|
+
super();
|
|
11808
11826
|
_defineProperty(this, "_asyncInterceptorsByName", /* @__PURE__ */ new Map());
|
|
11809
11827
|
_defineProperty(this, "_asyncInterceptorPoints", void 0);
|
|
11810
11828
|
this._asyncInterceptorPoints = asyncInterceptorPoints;
|
|
@@ -11815,26 +11833,41 @@ var AsyncInterceptorManager = class {
|
|
|
11815
11833
|
* @param filter A callback function to filter the interceptors.
|
|
11816
11834
|
* @returns It will return a composed interceptor function. If you will perform the interceptor repeatedly,
|
|
11817
11835
|
* you should cache the result instead of calling this function multiple times.
|
|
11836
|
+
* A cached chain cannot start a new call after this manager is disposed.
|
|
11818
11837
|
*/
|
|
11819
11838
|
fetchThroughAsyncInterceptors(name, filter) {
|
|
11839
|
+
this.ensureNotDisposed();
|
|
11820
11840
|
const key = name;
|
|
11821
11841
|
let interceptors = this._asyncInterceptorsByName.get(key);
|
|
11822
11842
|
if (filter) interceptors = interceptors.filter(filter);
|
|
11823
|
-
|
|
11843
|
+
const handler = composeAsyncInterceptors(interceptors || []);
|
|
11844
|
+
return async (initialValue, context) => {
|
|
11845
|
+
this.ensureNotDisposed();
|
|
11846
|
+
return handler(initialValue, context);
|
|
11847
|
+
};
|
|
11824
11848
|
}
|
|
11825
11849
|
async interceptAsync(name, interceptor) {
|
|
11850
|
+
this.ensureNotDisposed();
|
|
11826
11851
|
const key = name;
|
|
11827
11852
|
if (!this._asyncInterceptorsByName.has(key)) this._asyncInterceptorsByName.set(key, []);
|
|
11828
11853
|
const interceptors = this._asyncInterceptorsByName.get(key);
|
|
11829
11854
|
interceptors.push(interceptor);
|
|
11830
11855
|
this._asyncInterceptorsByName.set(key, interceptors.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0)));
|
|
11831
|
-
|
|
11856
|
+
let registration = interceptor;
|
|
11857
|
+
return () => {
|
|
11858
|
+
const current = registration;
|
|
11859
|
+
registration = void 0;
|
|
11860
|
+
if (!current || this._disposed) return false;
|
|
11861
|
+
const list = this._asyncInterceptorsByName.get(key);
|
|
11862
|
+
return list ? remove(list, current) : false;
|
|
11863
|
+
};
|
|
11832
11864
|
}
|
|
11833
11865
|
getInterceptPoints() {
|
|
11834
11866
|
return this._asyncInterceptorPoints;
|
|
11835
11867
|
}
|
|
11836
11868
|
dispose() {
|
|
11837
11869
|
this._asyncInterceptorsByName.clear();
|
|
11870
|
+
super.dispose();
|
|
11838
11871
|
}
|
|
11839
11872
|
};
|
|
11840
11873
|
|
|
@@ -27429,12 +27462,14 @@ function cloneMergeData(ranges) {
|
|
|
27429
27462
|
function cloneWorksheetData(worksheet) {
|
|
27430
27463
|
const result = {
|
|
27431
27464
|
id: worksheet.id,
|
|
27465
|
+
...worksheet.type === void 0 ? {} : { type: worksheet.type },
|
|
27432
27466
|
name: worksheet.name,
|
|
27433
27467
|
tabColor: worksheet.tabColor,
|
|
27434
27468
|
hidden: worksheet.hidden,
|
|
27435
27469
|
rowCount: worksheet.rowCount,
|
|
27436
27470
|
columnCount: worksheet.columnCount,
|
|
27437
27471
|
zoomRatio: worksheet.zoomRatio,
|
|
27472
|
+
...worksheet.zoomToFit === void 0 ? {} : { zoomToFit: worksheet.zoomToFit },
|
|
27438
27473
|
scrollTop: worksheet.scrollTop,
|
|
27439
27474
|
scrollLeft: worksheet.scrollLeft,
|
|
27440
27475
|
defaultColumnWidth: worksheet.defaultColumnWidth,
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import type { Nullable } from '../shared/types';
|
|
17
|
+
import { Disposable } from '../shared/lifecycle';
|
|
17
18
|
export type InterceptorHandler<M = unknown, C = unknown> = (value: Nullable<M>, context: C, next: (value: Nullable<M>) => Nullable<M>) => Nullable<M>;
|
|
18
19
|
export declare enum InterceptorEffectEnum {
|
|
19
20
|
Style = 1,// 1<< 0
|
|
@@ -38,7 +39,7 @@ export type IComposeInterceptors<T = any, C = any> = (interceptors: Array<IInter
|
|
|
38
39
|
* A helper to compose a certain type of interceptors.
|
|
39
40
|
*/
|
|
40
41
|
export declare const composeInterceptors: <T, C>(interceptors: Array<IInterceptor<T, C>>) => ReturnType<IComposeInterceptors<T, C>>;
|
|
41
|
-
export declare class InterceptorManager<P extends Record<string, IInterceptor<any, any>>> {
|
|
42
|
+
export declare class InterceptorManager<P extends Record<string, IInterceptor<any, any>>> extends Disposable {
|
|
42
43
|
private _interceptorsByName;
|
|
43
44
|
private _interceptorPoints;
|
|
44
45
|
constructor(interceptorPoints: P);
|
|
@@ -48,8 +49,9 @@ export declare class InterceptorManager<P extends Record<string, IInterceptor<an
|
|
|
48
49
|
* @param filter A callback function to filter the interceptors.
|
|
49
50
|
* @returns It will return a composed interceptor function. If you will perform the interceptor repeatedly,
|
|
50
51
|
* you should cache the result instead of calling this function multiple times.
|
|
52
|
+
* A cached chain cannot start a new call after this manager is disposed.
|
|
51
53
|
*/
|
|
52
|
-
fetchThroughInterceptors<T, C>(name: IInterceptor<T, C>, filter?: (interceptor: IInterceptor<any, any>) => boolean): (
|
|
54
|
+
fetchThroughInterceptors<T, C>(name: IInterceptor<T, C>, filter?: (interceptor: IInterceptor<any, any>) => boolean): (initialValue: Nullable<T>, context: C) => Nullable<T>;
|
|
53
55
|
intercept<T extends IInterceptor<any, any>>(name: T, interceptor: T): () => boolean;
|
|
54
56
|
getInterceptPoints(): P;
|
|
55
57
|
dispose(): void;
|
|
@@ -66,7 +68,7 @@ export interface IAsyncInterceptor<M, C> {
|
|
|
66
68
|
}
|
|
67
69
|
export type IComposeAsyncInterceptors<T = any, C = any> = (interceptors: Array<IAsyncInterceptor<T, C>>) => (initValue: Nullable<T>, initContext: C) => Promise<Nullable<T>>;
|
|
68
70
|
export declare const composeAsyncInterceptors: <T, C>(interceptors: Array<IAsyncInterceptor<T, C>>) => ((initialValue: Nullable<T>, context: C) => Promise<Nullable<T>>);
|
|
69
|
-
export declare class AsyncInterceptorManager<P extends Record<string, IAsyncInterceptor<any, any>>> {
|
|
71
|
+
export declare class AsyncInterceptorManager<P extends Record<string, IAsyncInterceptor<any, any>>> extends Disposable {
|
|
70
72
|
private _asyncInterceptorsByName;
|
|
71
73
|
private _asyncInterceptorPoints;
|
|
72
74
|
constructor(asyncInterceptorPoints: P);
|
|
@@ -76,6 +78,7 @@ export declare class AsyncInterceptorManager<P extends Record<string, IAsyncInte
|
|
|
76
78
|
* @param filter A callback function to filter the interceptors.
|
|
77
79
|
* @returns It will return a composed interceptor function. If you will perform the interceptor repeatedly,
|
|
78
80
|
* you should cache the result instead of calling this function multiple times.
|
|
81
|
+
* A cached chain cannot start a new call after this manager is disposed.
|
|
79
82
|
*/
|
|
80
83
|
fetchThroughAsyncInterceptors<T, C>(name: IAsyncInterceptor<T, C>, filter?: (interceptor: IAsyncInterceptor<any, any>) => boolean): (initialValue: Nullable<T>, context: C) => Promise<Nullable<T>>;
|
|
81
84
|
interceptAsync<T extends IAsyncInterceptor<any, any>>(name: T, interceptor: T): Promise<() => boolean>;
|
|
@@ -16,14 +16,15 @@
|
|
|
16
16
|
import type { ImageSourceType } from '../services/image-io/image-io.service';
|
|
17
17
|
import type { IResources } from '../services/resource-manager/type';
|
|
18
18
|
import type { IObjectArrayPrimitiveType, IObjectMatrixPrimitiveType, Nullable } from '../shared';
|
|
19
|
-
import type { BooleanNumber } from '../types/enum';
|
|
20
19
|
import type { DateSystem } from '../types/enum/date-system';
|
|
21
20
|
import type { LocaleType } from '../types/enum/locale-type';
|
|
22
|
-
import type {
|
|
21
|
+
import type { SheetTypes } from '../types/enum/sheet-types';
|
|
22
|
+
import type { BooleanNumber } from '../types/enum/text-style';
|
|
23
23
|
import type { ICellCustomRender } from '../types/interfaces/i-cell-custom-render';
|
|
24
|
+
import type { IDocumentData } from '../types/interfaces/i-document-data';
|
|
24
25
|
import type { IStyleData } from '../types/interfaces/i-style-data';
|
|
25
26
|
import type { IWorkbookCalculationSettings } from './calculation-settings';
|
|
26
|
-
import { CellValueType } from '../types/enum';
|
|
27
|
+
import { CellValueType } from '../types/enum/text-style';
|
|
27
28
|
/**
|
|
28
29
|
* Snapshot of a workbook.
|
|
29
30
|
*/
|
|
@@ -106,6 +107,8 @@ export interface IWorksheetBackgroundImage {
|
|
|
106
107
|
* Snapshot of a worksheet.
|
|
107
108
|
*/
|
|
108
109
|
export interface IWorksheetData {
|
|
110
|
+
/** Sheet kind. Historical snapshots without this field use SheetTypes.GRID. */
|
|
111
|
+
type?: SheetTypes;
|
|
109
112
|
/**
|
|
110
113
|
* Id of the worksheet. This should be unique and immutable across the lifecycle of the worksheet.
|
|
111
114
|
*/
|
|
@@ -124,6 +127,8 @@ export interface IWorksheetData {
|
|
|
124
127
|
rowCount: number;
|
|
125
128
|
columnCount: number;
|
|
126
129
|
zoomRatio: number;
|
|
130
|
+
/** CHART view mode: omitted historical snapshots use fixed zoom; TRUE continuously fits the primary chart. */
|
|
131
|
+
zoomToFit?: BooleanNumber;
|
|
127
132
|
scrollTop: number;
|
|
128
133
|
scrollLeft: number;
|
|
129
134
|
defaultColumnWidth: number;
|
package/lib/umd/facade.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCoreFacade={},e.UniverCore))})(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var n=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 r=Symbol(`initializers`),i=Symbol(`manualInit`);var a=class extends t.Disposable{constructor(e){if(super(),this._injector=e,this.constructor[i])return;let t=Object.getPrototypeOf(this)[r];t&&t.forEach(t=>{t.apply(this,[e])})}_initialize(e,...t){}_runInitializers(...e){let t=Object.getPrototypeOf(this)[r];t!=null&&t.length&&t.forEach(t=>t.apply(this,e))}static _enableManualInit(){this[i]=!0}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`_initialize`){let t=this.prototype[r];t||(t=[],this.prototype[r]=t),t.push(e.prototype._initialize)}else if(t!==`constructor`){let n=Object.getOwnPropertyDescriptor(e.prototype,t);n?Object.defineProperty(this.prototype,t,n):this.prototype[t]=e.prototype[t]}}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}};function o(e,t){return function(n,r){t(n,r,e)}}function s(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 c;let l=c=class extends n{constructor(e,t){super(),this._blob=e,this._injector=t}copyBlob(){return this._injector.createInstance(c,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(/* @__PURE__ */ Error(`Failed to read Blob as ArrayBuffer: ${e.message}`))})})}getBytes(){return this._blob?this._blob.arrayBuffer().then(e=>new Uint8Array(e)):Promise.reject(/* @__PURE__ */ Error(`Blob is undefined or null.`))}setBytes(e){return this._blob=new Blob([e.buffer]),this}setDataFromString(e,t){let n=new Blob([e],{type:t??`text/plain`});return this._blob=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}};l=c=s([o(1,(0,t.Inject)(t.Injector))],l);function u(e){"@babel/helpers - typeof";return u=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},u(e)}function d(e,t){if(u(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(u(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function f(e){var t=d(e,`string`);return u(t)==`symbol`?t:t+``}function p(e,t,n){return(t=f(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var m=class e{get FormulaType(){return t.FormulaType}get WorksheetHiddenState(){return t.WorksheetHiddenState}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 NamedStyleType(){return t.NamedStyleType}get SpacingRule(){return t.SpacingRule}get NumberUnitType(){return t.NumberUnitType}get PresetListType(){return t.PresetListType}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}get ImageSourceType(){return t.ImageSourceType}};p(m,`_instance`,void 0);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 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`}};p(h,`_instance`,void 0);let g=class extends a{constructor(e,t){super(t),this.doc=e}};g=s([o(1,(0,t.Inject)(t.Injector))],g);var _=class{constructor(){p(this,`_eventRegistry`,/* @__PURE__ */ new Map),p(this,`_eventHandlerMap`,/* @__PURE__ */ new Map),p(this,`_eventHandlerRegisted`,/* @__PURE__ */ 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,/* @__PURE__ */ 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=/* @__PURE__ */ 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 v=class extends n{constructor(e,t){super(),this._injector=e,this._userManagerService=t}getCurrentUser(){return this._userManagerService.getCurrentUser()}};v=s([o(0,(0,t.Inject)(t.Injector)),o(1,(0,t.Inject)(t.UserManagerService))],v);var y=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}};p(y,`_instance`,void 0);var b;let x=Symbol(`initializers`),S=b=class extends t.Disposable{static newAPI(e){return(e instanceof t.Univer?e.__getInjector():e).createInstance(b)}_initialize(e){}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`_initialize`){let n=this.prototype[x];n||(n=[],this.prototype[x]=n),n.push(Reflect.get(e.prototype,t))}else t!==`constructor`&&Reflect.set(this.prototype,t,Reflect.get(e.prototype,t))}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&Reflect.set(this,t,Reflect.get(e,t))})}constructor(e,n,r,i){super(),this._injector=e,this._commandService=n,this._univerInstanceService=r,this._lifecycleService=i,p(this,`_eventRegistry`,new _),p(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)[x];a&&a.forEach(e=>{e.call(this,this._injector)})}_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=>{let{unit:r}=n;if(r.type===t.UniverInstanceType.UNIVER_DOC){let t=r,n=e.createInstance(g,t);this.fireEvent(this.Event.DocCreated,{unitId:r.getUnitId(),type:r.type,doc:n,unit:n})}})))}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)}setTheme(e){this._injector.get(t.ThemeService).setTheme(e)}getCurrentTheme(){return this._injector.get(t.ThemeService).getCurrentTheme()}isDarkMode(){return this._injector.get(t.ThemeService).darkMode}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)}setRegion(e){this._injector.get(t.RegionService).setRegion(e)}getCurrentRegion(){return this._injector.get(t.RegionService).getCurrentRegion()}setDirection(e){this._injector.get(t.LocaleService).setDirection(e)}getCurrentLocale(){return this._injector.get(t.LocaleService).getCurrentLocale()}getLocales(){return this._injector.get(t.LocaleService).getLocales()}executeCommand(e,t,n){return this._commandService.executeCommand(e,t,n)}syncExecuteCommand(e,t,n){return this._commandService.syncExecuteCommand(e,t,n)}get Enum(){return m.get()}get Event(){return h.get()}get Util(){return y.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(v)}newBlob(){return this._injector.createInstance(l,null)}newRichText(){return t.RichTextBuilder.create()}newRichTextFromDocumentData(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)}};S=b=s([o(0,(0,t.Inject)(t.Injector)),o(1,t.ICommandService),o(2,t.IUniverInstanceService),o(3,(0,t.Inject)(t.LifecycleService))],S),e.FBase=n,e.FBaseInitialable=a,Object.defineProperty(e,"FBlob",{enumerable:!0,get:function(){return l}}),e.FEnum=m,e.FEventName=h,Object.defineProperty(e,"FUniver",{enumerable:!0,get:function(){return S}}),e.FUtil=y});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/core")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/core`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverCoreFacade={},e.UniverCore))})(this,function(e,t){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var n=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 r=Symbol(`initializers`),i=Symbol(`manualInit`);var a=class extends t.Disposable{constructor(e){if(super(),this._injector=e,this.constructor[i])return;let t=Object.getPrototypeOf(this)[r];t&&t.forEach(t=>{t.apply(this,[e])})}_initialize(e,...t){}_runInitializers(...e){let t=Object.getPrototypeOf(this)[r];t!=null&&t.length&&t.forEach(t=>t.apply(this,e))}static _enableManualInit(){this[i]=!0}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`_initialize`){let t=this.prototype[r];t||(t=[],this.prototype[r]=t),t.push(e.prototype._initialize)}else if(t!==`constructor`){let n=Object.getOwnPropertyDescriptor(e.prototype,t);n?Object.defineProperty(this.prototype,t,n):this.prototype[t]=e.prototype[t]}}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&(this[t]=e[t])})}};function o(e,t){return function(n,r){t(n,r,e)}}function s(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 c;let l=c=class extends n{constructor(e,t){super(),this._blob=e,this._injector=t}copyBlob(){return this._injector.createInstance(c,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(/* @__PURE__ */ Error(`Failed to read Blob as ArrayBuffer: ${e.message}`))})})}getBytes(){return this._blob?this._blob.arrayBuffer().then(e=>new Uint8Array(e)):Promise.reject(/* @__PURE__ */ Error(`Blob is undefined or null.`))}setBytes(e){return this._blob=new Blob([e.buffer]),this}setDataFromString(e,t){let n=new Blob([e],{type:t??`text/plain`});return this._blob=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}};l=c=s([o(1,(0,t.Inject)(t.Injector))],l);function u(e){"@babel/helpers - typeof";return u=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},u(e)}function d(e,t){if(u(e)!=`object`||!e)return e;var n;if(typeof Symbol<`u`&&(n=e[Symbol.toPrimitive])!==void 0){var r=n.call(e,t||`default`);if(u(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function f(e){var t=d(e,`string`);return u(t)==`symbol`?t:t+``}function p(e,t,n){return(t=f(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var m=class e{get FormulaType(){return t.FormulaType}get WorksheetHiddenState(){return t.WorksheetHiddenState}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 NamedStyleType(){return t.NamedStyleType}get SpacingRule(){return t.SpacingRule}get NumberUnitType(){return t.NumberUnitType}get PresetListType(){return t.PresetListType}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}get ImageSourceType(){return t.ImageSourceType}};p(m,`_instance`,void 0);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 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`}};p(h,`_instance`,void 0);let g=class extends a{constructor(e,t){super(t),this.doc=e}};g=s([o(1,(0,t.Inject)(t.Injector))],g);var _=class{constructor(){p(this,`_eventRegistry`,/* @__PURE__ */ new Map),p(this,`_eventHandlerMap`,/* @__PURE__ */ new Map),p(this,`_eventHandlerRegisted`,/* @__PURE__ */ 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,/* @__PURE__ */ 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=/* @__PURE__ */ 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 v=class extends n{constructor(e,t){super(),this._injector=e,this._userManagerService=t}getCurrentUser(){return this._userManagerService.getCurrentUser()}};v=s([o(0,(0,t.Inject)(t.Injector)),o(1,(0,t.Inject)(t.UserManagerService))],v);var y=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}};p(y,`_instance`,void 0);var b;let x=Symbol(`initializers`),S=b=class extends t.Disposable{static newAPI(e){return(e instanceof t.Univer?e.__getInjector():e).createInstance(b)}_initialize(e){}static extend(e){Object.getOwnPropertyNames(e.prototype).forEach(t=>{if(t===`_initialize`){let n=this.prototype[x];n||(n=[],this.prototype[x]=n),n.push(Reflect.get(e.prototype,t))}else t!==`constructor`&&Reflect.set(this.prototype,t,Reflect.get(e.prototype,t))}),Object.getOwnPropertyNames(e).forEach(t=>{t!==`prototype`&&t!==`name`&&t!==`length`&&Reflect.set(this,t,Reflect.get(e,t))})}constructor(e,n,r,i){super(),this._injector=e,this._commandService=n,this._univerInstanceService=r,this._lifecycleService=i,p(this,`_eventRegistry`,new _),p(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)[x];a&&a.forEach(e=>{e.call(this,this._injector)})}_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=>{let{unit:r}=n;if(r.type===t.UniverInstanceType.UNIVER_DOC){let t=r,n=e.createInstance(g,t);this.fireEvent(this.Event.DocCreated,{unitId:r.getUnitId(),type:r.type,doc:n,unit:n})}})))}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)}setTheme(e){this._injector.get(t.ThemeService).setTheme(e)}getCurrentTheme(){return this._injector.get(t.ThemeService).getCurrentTheme()}isDarkMode(){return this._injector.get(t.ThemeService).darkMode}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)}setRegion(e){this._injector.get(t.RegionService).setRegion(e)}getCurrentRegion(){return this._injector.get(t.RegionService).getCurrentRegion()}setDirection(e){this._injector.get(t.LocaleService).setDirection(e)}getCurrentLocale(){return this._injector.get(t.LocaleService).getCurrentLocale()}getLocales(){return this._injector.get(t.LocaleService).getLocales()}executeCommand(e,t,n){return this._commandService.executeCommand(e,t,n)}syncExecuteCommand(e,t,n){return this._commandService.syncExecuteCommand(e,t,n)}get Enum(){return m.get()}get Event(){return h.get()}get Util(){return y.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(v)}newBlob(){return this._injector.createInstance(l,null)}newRichText(){return t.RichTextBuilder.create()}newRichTextFromDocumentData(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)}};S=b=s([o(0,(0,t.Inject)(t.Injector)),o(1,t.ICommandService),o(2,t.IUniverInstanceService),o(3,(0,t.Inject)(t.LifecycleService))],S),e.FBase=n,e.FBaseInitialable=a,Object.defineProperty(e,"FBlob",{enumerable:!0,get:function(){return l}}),e.FEnum=m,e.FEventName=h,Object.defineProperty(e,"FUniver",{enumerable:!0,get:function(){return S}}),e.FUtil=y});
|