@univerjs/core 1.0.0-alpha.8 → 1.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/lib/cjs/facade.js +43 -1
  2. package/lib/cjs/index.js +6660 -6243
  3. package/lib/es/facade.js +43 -1
  4. package/lib/es/index.js +6646 -6249
  5. package/lib/facade.js +43 -1
  6. package/lib/index.js +6646 -6249
  7. package/lib/types/bases/formula-table-name.d.ts +28 -0
  8. package/lib/types/bases/index.d.ts +4 -2
  9. package/lib/types/bases/record-identity.d.ts +22 -0
  10. package/lib/types/bases/typedef.d.ts +265 -32
  11. package/lib/types/common/drawing-order.d.ts +20 -0
  12. package/lib/types/docs/data-model/document-data-model.d.ts +16 -0
  13. package/lib/types/{shared/object-matrix-query.d.ts → docs/data-model/document-statistics.d.ts} +2 -7
  14. package/lib/types/docs/data-model/index.d.ts +1 -1
  15. package/lib/types/docs/data-model/rich-text-builder.d.ts +17 -8
  16. package/lib/types/docs/data-model/types.d.ts +0 -6
  17. package/lib/types/facade/f-event.d.ts +9 -9
  18. package/lib/types/facade/f-univer.d.ts +37 -0
  19. package/lib/types/index.d.ts +1 -0
  20. package/lib/types/services/undoredo/undoredo.service.d.ts +14 -1
  21. package/lib/types/shared/cache/image-cache.d.ts +1 -1
  22. package/lib/types/shared/index.d.ts +0 -1
  23. package/lib/types/sheets/sheet-skeleton.d.ts +1 -1
  24. package/lib/types/types/enum/text-style.d.ts +3 -1
  25. package/lib/types/types/interfaces/i-document-data.d.ts +56 -0
  26. package/lib/types/types/interfaces/i-need-check-disposable.d.ts +1 -1
  27. package/lib/types/types/interfaces/i-style-data.d.ts +3 -1
  28. package/lib/types/univer.d.ts +6 -0
  29. package/lib/umd/facade.js +1 -1
  30. package/lib/umd/index.js +24 -21
  31. package/package.json +4 -4
@@ -103,7 +103,7 @@ export declare class FEventName {
103
103
  * // Remove the event listener, use `disposable.dispose()`
104
104
  * ```
105
105
  */
106
- get DocCreated(): "DocCreated";
106
+ get DocCreated(): 'DocCreated';
107
107
  /**
108
108
  * Event fired when a document is disposed
109
109
  * @see {@link IDocDisposedEvent}
@@ -117,7 +117,7 @@ export declare class FEventName {
117
117
  * // Remove the event listener, use `disposable.dispose()`
118
118
  * ```
119
119
  */
120
- get DocDisposed(): "DocDisposed";
120
+ get DocDisposed(): 'DocDisposed';
121
121
  /**
122
122
  * Event fired when life cycle is changed
123
123
  * @see {@link ILifeCycleChangedEvent}
@@ -131,7 +131,7 @@ export declare class FEventName {
131
131
  * // Remove the event listener, use `disposable.dispose()`
132
132
  * ```
133
133
  */
134
- get LifeCycleChanged(): "LifeCycleChanged";
134
+ get LifeCycleChanged(): 'LifeCycleChanged';
135
135
  /**
136
136
  * Event fired when a redo command is executed
137
137
  * @see {@link ICommandEvent}
@@ -145,7 +145,7 @@ export declare class FEventName {
145
145
  * // Remove the event listener, use `disposable.dispose()`
146
146
  * ```
147
147
  */
148
- get Redo(): "Redo";
148
+ get Redo(): 'Redo';
149
149
  /**
150
150
  * Event fired when an undo command is executed
151
151
  * @see {@link ICommandEvent}
@@ -159,7 +159,7 @@ export declare class FEventName {
159
159
  * // Remove the event listener, use `disposable.dispose()`
160
160
  * ```
161
161
  */
162
- get Undo(): "Undo";
162
+ get Undo(): 'Undo';
163
163
  /**
164
164
  * Event fired before a redo command is executed
165
165
  * @see {@link ICommandEvent}
@@ -176,7 +176,7 @@ export declare class FEventName {
176
176
  * // Remove the event listener, use `disposable.dispose()`
177
177
  * ```
178
178
  */
179
- get BeforeRedo(): "BeforeRedo";
179
+ get BeforeRedo(): 'BeforeRedo';
180
180
  /**
181
181
  * Event fired before an undo command is executed
182
182
  * @see {@link ICommandEvent}
@@ -193,7 +193,7 @@ export declare class FEventName {
193
193
  * // Remove the event listener, use `disposable.dispose()`
194
194
  * ```
195
195
  */
196
- get BeforeUndo(): "BeforeUndo";
196
+ get BeforeUndo(): 'BeforeUndo';
197
197
  /**
198
198
  * Event fired when a command is executed
199
199
  * @see {@link ICommandEvent}
@@ -207,7 +207,7 @@ export declare class FEventName {
207
207
  * // Remove the event listener, use `disposable.dispose()`
208
208
  * ```
209
209
  */
210
- get CommandExecuted(): "CommandExecuted";
210
+ get CommandExecuted(): 'CommandExecuted';
211
211
  /**
212
212
  * Event fired before a command is executed
213
213
  * @see {@link ICommandEvent}
@@ -224,7 +224,7 @@ export declare class FEventName {
224
224
  * // Remove the event listener, use `disposable.dispose()`
225
225
  * ```
226
226
  */
227
- get BeforeCommandExecute(): "BeforeCommandExecute";
227
+ get BeforeCommandExecute(): 'BeforeCommandExecute';
228
228
  }
229
229
  export interface IEventParamConfig {
230
230
  LifeCycleChanged: ILifeCycleChangedEvent;
@@ -14,6 +14,7 @@
14
14
  * limitations under the License.
15
15
  */
16
16
  import type { IDisposable, IDocumentData, IExecutionOptions, ILanguagePack, IParagraphStyle, ITextDecoration, ITextStyle, LifecycleStages } from '@univerjs/core';
17
+ import type { Theme } from '@univerjs/themes';
17
18
  import type { Subscription } from 'rxjs';
18
19
  import type { IEventParamConfig } from './f-event';
19
20
  import { Disposable, ICommandService, Injector, IUniverInstanceService, LifecycleService, ParagraphStyleBuilder, ParagraphStyleValue, RichTextBuilder, RichTextValue, TextDecorationBuilder, TextStyleBuilder, TextStyleValue, Univer } from '@univerjs/core';
@@ -112,6 +113,42 @@ export declare class FUniver extends Disposable {
112
113
  * ```
113
114
  */
114
115
  redo(): Promise<boolean>;
116
+ /**
117
+ * Set the theme used by Univer.
118
+ * @param {Theme} theme - The complete theme to use.
119
+ * @example
120
+ * ```ts
121
+ * import { defaultTheme } from '@univerjs/themes';
122
+ *
123
+ * univerAPI.setTheme({
124
+ * ...defaultTheme,
125
+ * primary: {
126
+ * ...defaultTheme.primary,
127
+ * 600: '#274fee',
128
+ * },
129
+ * });
130
+ * ```
131
+ */
132
+ setTheme(theme: Theme): void;
133
+ /**
134
+ * Get the theme currently used by Univer.
135
+ * @returns {Theme} The current theme.
136
+ * @example
137
+ * ```ts
138
+ * const theme = univerAPI.getCurrentTheme();
139
+ * console.log(theme.primary[600]);
140
+ * ```
141
+ */
142
+ getCurrentTheme(): Theme;
143
+ /**
144
+ * Whether Univer is currently using dark mode.
145
+ * @returns {boolean} Whether dark mode is enabled.
146
+ * @example
147
+ * ```ts
148
+ * const darkMode = univerAPI.isDarkMode();
149
+ * ```
150
+ */
151
+ isDarkMode(): boolean;
115
152
  /**
116
153
  * Toggle dark mode on or off.
117
154
  * @param {boolean} isDarkMode - Whether the dark mode is enabled.
@@ -19,6 +19,7 @@ export * from './common/async';
19
19
  export { isBooleanString } from './common/boolean';
20
20
  export * from './common/const';
21
21
  export * from './common/di';
22
+ export { getDrawingOrderIndex, normalizeDrawingOrderIndex } from './common/drawing-order';
22
23
  export { shallowEqual } from './common/equal';
23
24
  export { CanceledError, CustomCommandExecutionError } from './common/error';
24
25
  export { noop, throttle } from './common/function';
@@ -20,6 +20,7 @@ import type { IMutationInfo } from '../command/command.service';
20
20
  import { BehaviorSubject } from 'rxjs';
21
21
  import { Disposable } from '../../shared/lifecycle';
22
22
  import { CommandType, ICommandService } from '../command/command.service';
23
+ import { IConfigService } from '../config/config.service';
23
24
  import { IContextService } from '../context/context.service';
24
25
  import { IUniverInstanceService } from '../instance/instance.service';
25
26
  export interface IUndoRedoItem {
@@ -35,6 +36,12 @@ export interface IUndoRedoItem {
35
36
  export interface IUndoRedoService {
36
37
  undoRedoStatus$: Observable<IUndoRedoStatus>;
37
38
  pushUndoRedo(item: IUndoRedoItem): void;
39
+ /**
40
+ * Group undo redo items pushed while the returned scope is active.
41
+ * Reusing the same group id joins consecutive scopes without exposing the
42
+ * group to commands or undo redo items.
43
+ */
44
+ beginUndoRedoGroup(unitId: string, groupId: string, mode?: 'replace' | 'append'): IDisposable;
38
45
  /** Pitch the top redo element of the currently focused Univer document instance. */
39
46
  pitchTopUndoElement(): Nullable<IUndoRedoItem>;
40
47
  /** Pitch the top undo element of the currently focused Univer document instance. */
@@ -72,6 +79,8 @@ export interface IUndoRedoStatus {
72
79
  undos: number;
73
80
  redos: number;
74
81
  }
82
+ export declare const DEFAULT_UNDO_REDO_HISTORY_LIMIT = 50;
83
+ export declare const UNDO_REDO_HISTORY_LIMIT_CONFIG_KEY = "undoRedo.historyLimit";
75
84
  export declare const RedoCommandId = "univer.command.redo";
76
85
  export declare const UndoCommandId = "univer.command.undo";
77
86
  export declare const UndoCommand: {
@@ -103,8 +112,12 @@ export declare class LocalUndoRedoService extends Disposable implements IUndoRed
103
112
  protected readonly _undoStacks: Map<string, IUndoRedoItem[]>;
104
113
  protected readonly _redoStacks: Map<string, IUndoRedoItem[]>;
105
114
  private _batchingStatus;
106
- constructor(_univerInstanceService: IUniverInstanceService, _commandService: ICommandService, _contextService: IContextService);
115
+ private readonly _activeGroups;
116
+ private readonly _itemGroups;
117
+ private readonly _historyLimit;
118
+ constructor(_univerInstanceService: IUniverInstanceService, _commandService: ICommandService, _contextService: IContextService, configService: IConfigService);
107
119
  pushUndoRedo(item: IUndoRedoItem): void;
120
+ beginUndoRedoGroup(unitId: string, groupId: string, mode?: 'replace' | 'append'): IDisposable;
108
121
  clearUndoRedo(unitID: string): void;
109
122
  pitchTopUndoElement(): Nullable<IUndoRedoItem>;
110
123
  pitchTopRedoElement(): Nullable<IUndoRedoItem>;
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import type { Injector } from '@wendellhu/redi';
16
+ import type { Injector } from '../../common/di';
17
17
  import { ImageSourceType } from '../../services/image-io/image-io.service';
18
18
  export declare class ImageCacheMap {
19
19
  private _injector;
@@ -34,7 +34,6 @@ export * from './max-row-column';
34
34
  export type { INumfmtLocaleTag } from './numfmt';
35
35
  export { currencySymbols, DEFAULT_NUMBER_FORMAT, DEFAULT_TEXT_FORMAT, DEFAULT_TEXT_FORMAT_EXCEL, getNumfmtParseValueFilter, isDefaultFormat, isPatternEqualWithoutDecimal, isTextFormat, numfmt, } from './numfmt';
36
36
  export * from './object-matrix';
37
- export { queryObjectMatrix } from './object-matrix-query';
38
37
  export * from './random-id';
39
38
  export { moveRangeByOffset, splitIntoGrid } from './range';
40
39
  export * from './rectangle';
@@ -18,7 +18,7 @@ import type { IDocumentData, IDocumentRenderConfig, IPaddingData } from '../type
18
18
  import type { Styles } from './styles';
19
19
  import type { ICellData, ICellInfo, ICellWithCoord, IPosition, IRange, ISelectionCell, IWorksheetData } from './typedef';
20
20
  import type { Worksheet } from './worksheet';
21
- import { Injector } from '@wendellhu/redi';
21
+ import { Injector } from '../common/di';
22
22
  import { DocumentDataModel } from '../docs/data-model/document-data-model';
23
23
  import { IConfigService } from '../services/config/config.service';
24
24
  import { IContextService } from '../services/context/context.service';
@@ -42,7 +42,9 @@ export declare enum TextDecoration {
42
42
  WAVE = 14,
43
43
  WAVY_DOUBLE = 15,
44
44
  WAVY_HEAVY = 16,
45
- WORDS = 17
45
+ WORDS = 17,
46
+ SINGLE_ACCOUNTING = 18,
47
+ DOUBLE_ACCOUNTING = 19
46
48
  }
47
49
  /**
48
50
  * An enum that specifies the horizontal alignment of text.
@@ -111,6 +111,12 @@ export interface IDocStyles {
111
111
  */
112
112
  export interface IDocumentBody {
113
113
  dataStream: string;
114
+ /**
115
+ * UTF-16 offsets of soft page-break tokens (`\f`) produced by the layout engine that last
116
+ * saved the source document. Renderers may honor them for traditional/paginated fidelity;
117
+ * exporters must keep them soft rather than converting them to authored page breaks.
118
+ */
119
+ renderedPageBreaks?: number[];
114
120
  textRuns?: ITextRun[];
115
121
  paragraphs?: IParagraph[];
116
122
  sectionBreaks?: ISectionBreak[];
@@ -413,6 +419,10 @@ export interface IDocStyleBase extends IMargin {
413
419
  export interface IDocumentLayout {
414
420
  defaultTabStop?: number;
415
421
  characterSpacingControl?: characterSpacingControlType;
422
+ /** Use the legacy East Asian Word layout rules stored as OOXML `useFELayout`. */
423
+ useFELayout?: BooleanNumber;
424
+ /** Align automatic line height inside tables to the active document line grid. */
425
+ adjustLineHeightInTable?: BooleanNumber;
416
426
  paragraphLineGapDefault?: number;
417
427
  spaceWidthEastAsian?: BooleanNumber;
418
428
  autoHyphenation?: BooleanNumber;
@@ -543,6 +553,10 @@ export interface IBullet {
543
553
  listType: string;
544
554
  listId: string;
545
555
  nestingLevel: number;
556
+ startNumber?: number;
557
+ image?: {
558
+ source: string;
559
+ };
546
560
  textStyle?: ITextStyle;
547
561
  }
548
562
  /**
@@ -562,6 +576,12 @@ export interface IDocDrawingBase extends IDrawingParam {
562
576
  docTransform: IDocDrawingPosition;
563
577
  layoutType: PositionedObjectLayoutType;
564
578
  behindDoc?: BooleanNumber;
579
+ /** Keeps the anchor constrained to its containing table cell when enabled. */
580
+ layoutInCell?: BooleanNumber;
581
+ /** Allows this floating object to overlap other floating objects. */
582
+ allowOverlap?: BooleanNumber;
583
+ /** WordprocessingML stacking order for anchored objects. */
584
+ relativeHeight?: number;
565
585
  start?: number[];
566
586
  lineTo?: number[][];
567
587
  wrapText?: WrapTextType;
@@ -658,11 +678,16 @@ export interface IDocTextFill {
658
678
  offsetY?: number;
659
679
  };
660
680
  }
681
+ export interface IDocTextOutline {
682
+ color?: string;
683
+ width?: number;
684
+ }
661
685
  export interface ITextStyle extends IStyleBase {
662
686
  sc?: number;
663
687
  pos?: number;
664
688
  sa?: number;
665
689
  textFill?: IDocTextFill;
690
+ textOutline?: IDocTextOutline;
666
691
  /**
667
692
  * DrawingML-style glow around the rendered glyphs.
668
693
  *
@@ -685,6 +710,11 @@ export interface IIndentStart {
685
710
  tabStops?: ITabStop[];
686
711
  indentEnd?: INumberUnit;
687
712
  }
713
+ /**
714
+ * Vertical alignment of text runs inside a paragraph line box.
715
+ * This is the normalized form of DrawingML `fontAlgn`.
716
+ */
717
+ export type ParagraphFontAlign = 'auto' | 'top' | 'center' | 'baseline' | 'bottom';
688
718
  /**
689
719
  * Properties of paragraph style
690
720
  */
@@ -699,6 +729,12 @@ export type IDocumentDefaultParagraphStyle = Omit<IParagraphStyle, 'headingId' |
699
729
  export interface IParagraphProperties extends IIndentStart {
700
730
  headingId?: string;
701
731
  namedStyleType?: NamedStyleType;
732
+ defaultTabStop?: number;
733
+ /** Whether East Asian kinsoku line-breaking rules apply to this paragraph. */
734
+ eastAsianLineBreak?: BooleanNumber;
735
+ /** Whether punctuation may hang outside the paragraph text bounds. */
736
+ hangingPunctuation?: BooleanNumber;
737
+ fontAlign?: ParagraphFontAlign;
702
738
  horizontalAlign?: HorizontalAlign;
703
739
  lineSpacing?: number;
704
740
  direction?: TextDirection;
@@ -706,6 +742,12 @@ export interface IParagraphProperties extends IIndentStart {
706
742
  snapToGrid?: BooleanNumber;
707
743
  spaceAbove?: INumberUnit;
708
744
  spaceBelow?: INumberUnit;
745
+ /** Whether the layout engine should derive paragraph-before spacing from the active compatibility policy. */
746
+ beforeAutoSpacing?: BooleanNumber;
747
+ /** Whether the layout engine should derive paragraph-after spacing from the active compatibility policy. */
748
+ afterAutoSpacing?: BooleanNumber;
749
+ /** Suppresses spacing between consecutive paragraphs that share the same named style. */
750
+ contextualSpacing?: BooleanNumber;
709
751
  borderBetween?: IParagraphBorder;
710
752
  borderTop?: IParagraphBorder;
711
753
  borderBottom?: IParagraphBorder;
@@ -817,6 +859,7 @@ export declare enum DashStyleType {
817
859
  export interface ITabStop {
818
860
  offset: number;
819
861
  alignment: TabStopAlignment;
862
+ leader?: TabStopLeader;
820
863
  }
821
864
  /**
822
865
  * The alignment of the tab stop.
@@ -827,6 +870,15 @@ export declare enum TabStopAlignment {
827
870
  CENTER = 2,// The tab stop is aligned to the center of the line.
828
871
  END = 3
829
872
  }
873
+ export declare enum TabStopLeader {
874
+ TAB_STOP_LEADER_UNSPECIFIED = 0,
875
+ NONE = 1,
876
+ DOT = 2,
877
+ HYPHEN = 3,
878
+ UNDERSCORE = 4,
879
+ HEAVY = 5,
880
+ MIDDLE_DOT = 6
881
+ }
830
882
  /**
831
883
  * Properties of shading
832
884
  */
@@ -943,6 +995,10 @@ export interface ITableRow {
943
995
  * corresponding `TABLE_ROW_START`/`TABLE_ROW_END` pair in `dataStream`.
944
996
  */
945
997
  tableCells: ITableCell[];
998
+ /** Number of table-grid columns omitted before the first cell in this row. */
999
+ gridBefore?: number;
1000
+ /** Number of table-grid columns omitted after the last cell in this row. */
1001
+ gridAfter?: number;
946
1002
  trHeight: ITableRowSize;
947
1003
  cantSplit?: BooleanNumber;
948
1004
  isFirstRow?: BooleanNumber;
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import type { IDisposable } from '@wendellhu/redi';
16
+ import type { IDisposable } from '../../common/di';
17
17
  export interface INeedCheckDisposable extends IDisposable {
18
18
  canDispose: () => boolean;
19
19
  }
@@ -213,6 +213,8 @@ export interface IStyleBase {
213
213
  * fontFamily
214
214
  */
215
215
  ff?: Nullable<string>;
216
+ /** Font family used for East Asian characters in rich text. */
217
+ eastAsiaFontFamily?: Nullable<string>;
216
218
  /** Font size in points (pt), where 1 pt is 1/72 inch. */
217
219
  fs?: number;
218
220
  /**
@@ -301,7 +303,7 @@ export interface IStyleData extends IStyleBase {
301
303
  /**
302
304
  * Exact keys of {@link IStyleData}.
303
305
  */
304
- export declare const STYLE_KEYS: readonly ["ff", "fs", "it", "bl", "ul", "bbl", "st", "ol", "bg", "bd", "cl", "va", "n", "stf", "tr", "td", "ht", "vt", "tb", "pd"];
306
+ export declare const STYLE_KEYS: readonly ["ff", "eastAsiaFontFamily", "fs", "it", "bl", "ul", "bbl", "st", "ol", "bg", "bd", "cl", "va", "n", "stf", "tr", "td", "ht", "vt", "tb", "pd"];
305
307
  /**
306
308
  * Key union of {@link IStyleData}.
307
309
  */
@@ -59,6 +59,12 @@ export interface IUniverConfig {
59
59
  * @default false
60
60
  */
61
61
  logCommandExecution?: boolean;
62
+ /**
63
+ * The maximum number of undoable command groups retained for each unit.
64
+ * Set to `0` to disable undo history.
65
+ * @default 50
66
+ */
67
+ undoRedoHistoryLimit?: number;
62
68
  /**
63
69
  * The override dependencies of the Univer instance.
64
70
  */
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=this,n=Object.getPrototypeOf(this)[r];n&&n.forEach(function(n){n.apply(t,[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(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=new Blob([e],{type:t==null?`text/plain`:t});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{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 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`,new Map),p(this,`_eventHandlerMap`,new Map),p(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 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 t=this.prototype[x];t||(t=[],this.prototype[x]=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,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];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=>{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)}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)}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=this,n=Object.getPrototypeOf(this)[r];n&&n.forEach(function(n){n.apply(t,[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(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=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{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 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`,new Map),p(this,`_eventHandlerMap`,new Map),p(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 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 t=this.prototype[x];t||(t=[],this.prototype[x]=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,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];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=>{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)}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});