@univerjs/core 0.15.3 → 0.15.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/facade.js CHANGED
@@ -1,9 +1,9 @@
1
- var W = Object.defineProperty;
2
- var q = (i, e, t) => e in i ? W(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
1
+ var F = Object.defineProperty;
2
+ var q = (i, e, t) => e in i ? F(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
3
  var d = (i, e, t) => q(i, typeof e != "symbol" ? e + "" : e, t);
4
- import { Disposable as M, Inject as p, Injector as _, AbsoluteRefType as G, UniverInstanceType as R, LifecycleStages as f, DataValidationType as J, DataValidationErrorStyle as K, DataValidationRenderMode as Q, DataValidationOperator as X, DataValidationStatus as Y, CommandType as Z, BaselineOffset as k, BooleanNumber as ee, HorizontalAlign as te, TextDecoration as re, TextDirection as ie, VerticalAlign as ne, WrapStrategy as oe, BorderType as se, BorderStyleTypes as ce, AutoFillSeries as ae, ColorType as de, CommonHideTypes as le, CopyPasteType as pe, DeleteDirection as he, DeveloperMetadataVisibility as ue, Dimension as ge, Direction as ye, InterpolationPointType as ve, LocaleType as fe, MentionType as _e, ProtectionType as me, RelativeDate as Ee, SheetTypes as be, ThemeColorType as Se, LifecycleService as V, toDisposable as l, ICommandService as g, UndoCommand as h, IUndoRedoService as E, RedoCommand as u, Registry as Ce, UserManagerService as De, Rectangle as xe, numfmt as Te, Tools as we, IUniverInstanceService as F, Univer as Re, CanceledError as T, ThemeService as Oe, LocaleService as z, ColorBuilder as je, RichTextBuilder as Pe, RichTextValue as Be, ParagraphStyleBuilder as He, ParagraphStyleValue as Ue, TextStyleBuilder as Ie, TextStyleValue as Me, TextDecorationBuilder as Ve } from "@univerjs/core";
4
+ import { Disposable as I, Inject as p, Injector as _, AbsoluteRefType as G, UniverInstanceType as R, LifecycleStages as f, DataValidationType as J, DataValidationErrorStyle as K, DataValidationRenderMode as Q, DataValidationOperator as X, DataValidationStatus as Y, CommandType as Z, BaselineOffset as k, BooleanNumber as ee, HorizontalAlign as te, TextDecoration as re, TextDirection as ie, VerticalAlign as ne, WrapStrategy as oe, BorderType as se, BorderStyleTypes as ce, AutoFillSeries as ae, ColorType as de, CommonHideTypes as le, CopyPasteType as pe, DeleteDirection as he, DeveloperMetadataVisibility as ue, Dimension as ye, Direction as ge, InterpolationPointType as ve, LocaleType as fe, MentionType as _e, ProtectionType as me, RelativeDate as Ee, SheetTypes as be, ThemeColorType as Se, LifecycleService as V, toDisposable as l, ICommandService as y, UndoCommand as h, IUndoRedoService as E, RedoCommand as u, Registry as Ce, UserManagerService as De, Rectangle as xe, numfmt as Te, Tools as we, IUniverInstanceService as W, Univer as Re, CanceledError as T, ThemeService as Oe, LocaleService as z, ColorBuilder as je, RichTextBuilder as Pe, RichTextValue as Be, ParagraphStyleBuilder as He, ParagraphStyleValue as Me, TextStyleBuilder as Ue, TextStyleValue as Ie, TextDecorationBuilder as Ve } from "@univerjs/core";
5
5
  import { filter as b } from "rxjs";
6
- class $ extends M {
6
+ class $ extends I {
7
7
  /**
8
8
  * @ignore
9
9
  */
@@ -16,7 +16,7 @@ class $ extends M {
16
16
  }
17
17
  }
18
18
  const S = /* @__PURE__ */ Symbol("initializers"), A = /* @__PURE__ */ Symbol("manualInit");
19
- class $e extends M {
19
+ class $e extends I {
20
20
  constructor(e) {
21
21
  if (super(), this._injector = e, !!this.constructor[A]) return;
22
22
  const n = this, o = Object.getPrototypeOf(this)[S];
@@ -160,11 +160,11 @@ let D = class extends $ {
160
160
  D = Ae([
161
161
  Le(1, p(_))
162
162
  ], D);
163
- const y = class y {
163
+ const g = class g {
164
164
  static get() {
165
165
  if (this._instance)
166
166
  return this._instance;
167
- const e = new y();
167
+ const e = new g();
168
168
  return this._instance = e, e;
169
169
  }
170
170
  /**
@@ -178,8 +178,8 @@ const y = class y {
178
178
  });
179
179
  }
180
180
  constructor() {
181
- for (const e in y.prototype)
182
- this[e] = y.prototype[e];
181
+ for (const e in g.prototype)
182
+ this[e] = g.prototype[e];
183
183
  }
184
184
  /**
185
185
  * Defines different types of absolute references
@@ -454,7 +454,7 @@ const y = class y {
454
454
  * ```
455
455
  */
456
456
  get Dimension() {
457
- return ge;
457
+ return ye;
458
458
  }
459
459
  /**
460
460
  * Direction types
@@ -465,7 +465,7 @@ const y = class y {
465
465
  * ```
466
466
  */
467
467
  get Direction() {
468
- return ye;
468
+ return ge;
469
469
  }
470
470
  /**
471
471
  * Interpolation point types
@@ -548,8 +548,8 @@ const y = class y {
548
548
  /**
549
549
  * @ignore
550
550
  */
551
- d(y, "_instance");
552
- let O = y;
551
+ d(g, "_instance");
552
+ let O = g;
553
553
  const v = class v {
554
554
  static get() {
555
555
  if (this._instance)
@@ -730,7 +730,7 @@ const v = class v {
730
730
  */
731
731
  d(v, "_instance");
732
732
  let j = v;
733
- var Ne = Object.getOwnPropertyDescriptor, Fe = (i, e, t, r) => {
733
+ var Ne = Object.getOwnPropertyDescriptor, We = (i, e, t, r) => {
734
734
  for (var n = r > 1 ? void 0 : r ? Ne(e, t) : e, o = i.length - 1, s; o >= 0; o--)
735
735
  (s = i[o]) && (n = s(n) || n);
736
736
  return n;
@@ -772,7 +772,7 @@ let P = class extends $ {
772
772
  * @deprecated use `univerAPI.addEvent(univerAPI.Event.BeforeUndo, (event) => {})` as instead
773
773
  */
774
774
  onBeforeUndo(i) {
775
- return this._injector.get(g).beforeCommandExecuted((t) => {
775
+ return this._injector.get(y).beforeCommandExecuted((t) => {
776
776
  if (t.id === h.id) {
777
777
  const n = this._injector.get(E).pitchTopUndoElement();
778
778
  n && i(n);
@@ -784,7 +784,7 @@ let P = class extends $ {
784
784
  * @deprecated use `univerAPI.addEvent(univerAPI.Event.Undo, (event) => {})` as instead
785
785
  */
786
786
  onUndo(i) {
787
- return this._injector.get(g).onCommandExecuted((t) => {
787
+ return this._injector.get(y).onCommandExecuted((t) => {
788
788
  if (t.id === h.id) {
789
789
  const n = this._injector.get(E).pitchTopUndoElement();
790
790
  n && i(n);
@@ -796,7 +796,7 @@ let P = class extends $ {
796
796
  * @deprecated use `univerAPI.addEvent(univerAPI.Event.BeforeRedo, (event) => {})` as instead
797
797
  */
798
798
  onBeforeRedo(i) {
799
- return this._injector.get(g).beforeCommandExecuted((t) => {
799
+ return this._injector.get(y).beforeCommandExecuted((t) => {
800
800
  if (t.id === u.id) {
801
801
  const n = this._injector.get(E).pitchTopRedoElement();
802
802
  n && i(n);
@@ -808,7 +808,7 @@ let P = class extends $ {
808
808
  * @deprecated use `univerAPI.addEvent(univerAPI.Event.Redo, (event) => {})` as instead
809
809
  */
810
810
  onRedo(i) {
811
- return this._injector.get(g).onCommandExecuted((t) => {
811
+ return this._injector.get(y).onCommandExecuted((t) => {
812
812
  if (t.id === u.id) {
813
813
  const n = this._injector.get(E).pitchTopRedoElement();
814
814
  n && i(n);
@@ -816,12 +816,12 @@ let P = class extends $ {
816
816
  });
817
817
  }
818
818
  };
819
- P = Fe([
819
+ P = We([
820
820
  L(0, p(_)),
821
821
  L(1, p(V))
822
822
  ], P);
823
- var We = Object.getOwnPropertyDescriptor, qe = (i, e, t, r) => {
824
- for (var n = r > 1 ? void 0 : r ? We(e, t) : e, o = i.length - 1, s; o >= 0; o--)
823
+ var Fe = Object.getOwnPropertyDescriptor, qe = (i, e, t, r) => {
824
+ for (var n = r > 1 ? void 0 : r ? Fe(e, t) : e, o = i.length - 1, s; o >= 0; o--)
825
825
  (s = i[o]) && (n = s(n) || n);
826
826
  return n;
827
827
  }, Ge = (i, e) => (t, r) => e(t, r, i);
@@ -842,11 +842,6 @@ class Je {
842
842
  _ensureEventRegistry(e) {
843
843
  return this._eventRegistry.has(e) || this._eventRegistry.set(e, new Ce()), this._eventRegistry.get(e);
844
844
  }
845
- dispose() {
846
- this._eventRegistry.clear(), this._eventHandlerMap.clear(), this._eventHandlerRegisted.forEach((e) => {
847
- e.forEach((t) => t.dispose()), e.clear();
848
- }), this._eventHandlerRegisted.clear();
849
- }
850
845
  registerEventHandler(e, t) {
851
846
  const r = this._eventHandlerMap.get(e);
852
847
  return r ? r.add(t) : this._eventHandlerMap.set(e, /* @__PURE__ */ new Set([t])), this._ensureEventRegistry(e).getData().length && this._initEventHandler(e), l(() => {
@@ -864,9 +859,9 @@ class Je {
864
859
  _initEventHandler(e) {
865
860
  let t = this._eventHandlerRegisted.get(e);
866
861
  const r = this._eventHandlerMap.get(e);
867
- r && (t || (t = /* @__PURE__ */ new Map(), this._eventHandlerRegisted.set(e, t), r == null || r.forEach((n) => {
862
+ r && (!t || t.size === 0) && (t = /* @__PURE__ */ new Map(), this._eventHandlerRegisted.set(e, t), r == null || r.forEach((n) => {
868
863
  t == null || t.set(n, l(n()));
869
- })));
864
+ }));
870
865
  }
871
866
  /**
872
867
  * Add an event listener
@@ -988,24 +983,26 @@ const x = class x {
988
983
  * @ignore
989
984
  */
990
985
  d(x, "_instance");
991
- let U = x;
986
+ let M = x;
992
987
  var Xe = Object.getOwnPropertyDescriptor, Ye = (i, e, t, r) => {
993
988
  for (var n = r > 1 ? void 0 : r ? Xe(e, t) : e, o = i.length - 1, s; o >= 0; o--)
994
989
  (s = i[o]) && (n = s(n) || n);
995
990
  return n;
996
991
  }, C = (i, e) => (t, r) => e(t, r, i);
997
992
  const w = /* @__PURE__ */ Symbol("initializers");
998
- let I = class extends M {
993
+ let U = class extends I {
999
994
  constructor(e, t, r, n) {
1000
995
  super();
1001
996
  d(this, "_eventRegistry", new Je());
1002
997
  d(this, "registerEventHandler", (e, t) => this._eventRegistry.registerEventHandler(e, t));
1003
- this._injector = e, this._commandService = t, this._univerInstanceService = r, this._lifecycleService = n, this.registerEventHandler(
1004
- this.Event.LifeCycleChanged,
1005
- () => l(
1006
- this._lifecycleService.lifecycle$.subscribe((s) => {
1007
- this.fireEvent(this.Event.LifeCycleChanged, { stage: s });
1008
- })
998
+ this._injector = e, this._commandService = t, this._univerInstanceService = r, this._lifecycleService = n, this.disposeWithMe(
999
+ this.registerEventHandler(
1000
+ this.Event.LifeCycleChanged,
1001
+ () => l(
1002
+ this._lifecycleService.lifecycle$.subscribe((s) => {
1003
+ this.fireEvent(this.Event.LifeCycleChanged, { stage: s });
1004
+ })
1005
+ )
1009
1006
  )
1010
1007
  ), this._initUnitEvent(this._injector), this._initBeforeCommandEvent(this._injector), this._initCommandEvent(this._injector), this._injector.onDispose(() => {
1011
1008
  this.dispose();
@@ -1030,7 +1027,7 @@ let I = class extends M {
1030
1027
  * ```
1031
1028
  */
1032
1029
  static newAPI(e) {
1033
- return (e instanceof Re ? e.__getInjector() : e).createInstance(I);
1030
+ return (e instanceof Re ? e.__getInjector() : e).createInstance(U);
1034
1031
  }
1035
1032
  /**
1036
1033
  * @ignore
@@ -1051,94 +1048,110 @@ let I = class extends M {
1051
1048
  });
1052
1049
  }
1053
1050
  _initCommandEvent(e) {
1054
- const t = e.get(g);
1055
- this.registerEventHandler(
1056
- this.Event.Redo,
1057
- () => t.onCommandExecuted((r) => {
1058
- const { id: n, type: o, params: s } = r;
1059
- if (r.id === u.id) {
1060
- const a = { id: n, type: o, params: s };
1061
- this.fireEvent(this.Event.Redo, a);
1062
- }
1063
- })
1064
- ), this.registerEventHandler(
1065
- this.Event.Undo,
1066
- () => t.onCommandExecuted((r) => {
1067
- const { id: n, type: o, params: s } = r;
1068
- if (r.id === h.id) {
1069
- const a = { id: n, type: o, params: s };
1070
- this.fireEvent(this.Event.Undo, a);
1071
- }
1072
- })
1073
- ), this.registerEventHandler(
1074
- this.Event.CommandExecuted,
1075
- () => t.onCommandExecuted((r, n) => {
1076
- const { id: o, type: s, params: c } = r;
1077
- if (r.id !== u.id && r.id !== h.id) {
1078
- const m = { id: o, type: s, params: c, options: n };
1079
- this.fireEvent(this.Event.CommandExecuted, m);
1080
- }
1081
- })
1051
+ const t = e.get(y);
1052
+ this.disposeWithMe(
1053
+ this.registerEventHandler(
1054
+ this.Event.Redo,
1055
+ () => t.onCommandExecuted((r) => {
1056
+ const { id: n, type: o, params: s } = r;
1057
+ if (r.id === u.id) {
1058
+ const a = { id: n, type: o, params: s };
1059
+ this.fireEvent(this.Event.Redo, a);
1060
+ }
1061
+ })
1062
+ )
1063
+ ), this.disposeWithMe(
1064
+ this.registerEventHandler(
1065
+ this.Event.Undo,
1066
+ () => t.onCommandExecuted((r) => {
1067
+ const { id: n, type: o, params: s } = r;
1068
+ if (r.id === h.id) {
1069
+ const a = { id: n, type: o, params: s };
1070
+ this.fireEvent(this.Event.Undo, a);
1071
+ }
1072
+ })
1073
+ )
1074
+ ), this.disposeWithMe(
1075
+ this.registerEventHandler(
1076
+ this.Event.CommandExecuted,
1077
+ () => t.onCommandExecuted((r, n) => {
1078
+ const { id: o, type: s, params: c } = r;
1079
+ if (r.id !== u.id && r.id !== h.id) {
1080
+ const m = { id: o, type: s, params: c, options: n };
1081
+ this.fireEvent(this.Event.CommandExecuted, m);
1082
+ }
1083
+ })
1084
+ )
1082
1085
  );
1083
1086
  }
1084
1087
  _initBeforeCommandEvent(e) {
1085
- const t = e.get(g);
1086
- this.registerEventHandler(
1087
- this.Event.BeforeRedo,
1088
- () => t.beforeCommandExecuted((r) => {
1089
- const { id: n, type: o, params: s } = r;
1090
- if (r.id === u.id) {
1091
- const a = { id: n, type: o, params: s };
1092
- if (this.fireEvent(this.Event.BeforeRedo, a), a.cancel)
1093
- throw new T();
1094
- }
1095
- })
1096
- ), this.registerEventHandler(
1097
- this.Event.BeforeUndo,
1098
- () => t.beforeCommandExecuted((r) => {
1099
- const { id: n, type: o, params: s } = r;
1100
- if (r.id === h.id) {
1101
- const a = { id: n, type: o, params: s };
1102
- if (this.fireEvent(this.Event.BeforeUndo, a), a.cancel)
1103
- throw new T();
1104
- }
1105
- })
1106
- ), this.registerEventHandler(
1107
- this.Event.BeforeCommandExecute,
1108
- () => t.beforeCommandExecuted((r, n) => {
1109
- const { id: o, type: s, params: c } = r;
1110
- if (r.id !== u.id && r.id !== h.id) {
1111
- const m = { id: o, type: s, params: c, options: n };
1112
- if (this.fireEvent(this.Event.BeforeCommandExecute, m), m.cancel)
1113
- throw new T();
1114
- }
1115
- })
1088
+ const t = e.get(y);
1089
+ this.disposeWithMe(
1090
+ this.registerEventHandler(
1091
+ this.Event.BeforeRedo,
1092
+ () => t.beforeCommandExecuted((r) => {
1093
+ const { id: n, type: o, params: s } = r;
1094
+ if (r.id === u.id) {
1095
+ const a = { id: n, type: o, params: s };
1096
+ if (this.fireEvent(this.Event.BeforeRedo, a), a.cancel)
1097
+ throw new T();
1098
+ }
1099
+ })
1100
+ )
1101
+ ), this.disposeWithMe(
1102
+ this.registerEventHandler(
1103
+ this.Event.BeforeUndo,
1104
+ () => t.beforeCommandExecuted((r) => {
1105
+ const { id: n, type: o, params: s } = r;
1106
+ if (r.id === h.id) {
1107
+ const a = { id: n, type: o, params: s };
1108
+ if (this.fireEvent(this.Event.BeforeUndo, a), a.cancel)
1109
+ throw new T();
1110
+ }
1111
+ })
1112
+ )
1113
+ ), this.disposeWithMe(
1114
+ this.registerEventHandler(
1115
+ this.Event.BeforeCommandExecute,
1116
+ () => t.beforeCommandExecuted((r, n) => {
1117
+ const { id: o, type: s, params: c } = r;
1118
+ if (r.id !== u.id && r.id !== h.id) {
1119
+ const m = { id: o, type: s, params: c, options: n };
1120
+ if (this.fireEvent(this.Event.BeforeCommandExecute, m), m.cancel)
1121
+ throw new T();
1122
+ }
1123
+ })
1124
+ )
1116
1125
  );
1117
1126
  }
1118
1127
  _initUnitEvent(e) {
1119
- const t = e.get(F);
1120
- this.registerEventHandler(
1121
- this.Event.DocDisposed,
1122
- () => t.unitDisposed$.subscribe((r) => {
1123
- r.type === R.UNIVER_DOC && this.fireEvent(this.Event.DocDisposed, {
1124
- unitId: r.getUnitId(),
1125
- unitType: r.type,
1126
- snapshot: r.getSnapshot()
1127
- });
1128
- })
1129
- ), this.registerEventHandler(
1130
- this.Event.DocCreated,
1131
- () => t.unitAdded$.subscribe((r) => {
1132
- if (r.type === R.UNIVER_DOC) {
1133
- const n = r, o = e.createInstance(B, n);
1134
- this.fireEvent(this.Event.DocCreated, {
1128
+ const t = e.get(W);
1129
+ this.disposeWithMe(
1130
+ this.registerEventHandler(
1131
+ this.Event.DocDisposed,
1132
+ () => t.unitDisposed$.subscribe((r) => {
1133
+ r.type === R.UNIVER_DOC && this.fireEvent(this.Event.DocDisposed, {
1135
1134
  unitId: r.getUnitId(),
1136
- type: r.type,
1137
- doc: o,
1138
- unit: o
1135
+ unitType: r.type,
1136
+ snapshot: r.getSnapshot()
1139
1137
  });
1140
- }
1141
- })
1138
+ })
1139
+ )
1140
+ ), this.disposeWithMe(
1141
+ this.registerEventHandler(
1142
+ this.Event.DocCreated,
1143
+ () => t.unitAdded$.subscribe((r) => {
1144
+ if (r.type === R.UNIVER_DOC) {
1145
+ const n = r, o = e.createInstance(B, n);
1146
+ this.fireEvent(this.Event.DocCreated, {
1147
+ unitId: r.getUnitId(),
1148
+ type: r.type,
1149
+ doc: o,
1150
+ unit: o
1151
+ });
1152
+ }
1153
+ })
1154
+ )
1142
1155
  );
1143
1156
  }
1144
1157
  /**
@@ -1157,8 +1170,7 @@ let I = class extends M {
1157
1170
  * ```
1158
1171
  */
1159
1172
  disposeUnit(e) {
1160
- const t = this._univerInstanceService.disposeUnit(e);
1161
- return this._eventRegistry.dispose(), t;
1173
+ return this._univerInstanceService.disposeUnit(e);
1162
1174
  }
1163
1175
  /**
1164
1176
  * Get the current lifecycle stage.
@@ -1307,7 +1319,7 @@ let I = class extends M {
1307
1319
  return j.get();
1308
1320
  }
1309
1321
  get Util() {
1310
- return U.get();
1322
+ return M.get();
1311
1323
  }
1312
1324
  /**
1313
1325
  * Add an event listener
@@ -1422,7 +1434,7 @@ let I = class extends M {
1422
1434
  * ```
1423
1435
  */
1424
1436
  newParagraphStyleValue(e) {
1425
- return Ue.create(e);
1437
+ return Me.create(e);
1426
1438
  }
1427
1439
  /**
1428
1440
  * Create a new text style.
@@ -1434,7 +1446,7 @@ let I = class extends M {
1434
1446
  * ```
1435
1447
  */
1436
1448
  newTextStyle(e) {
1437
- return Ie.create(e);
1449
+ return Ue.create(e);
1438
1450
  }
1439
1451
  /**
1440
1452
  * Create a new text style value.
@@ -1446,7 +1458,7 @@ let I = class extends M {
1446
1458
  * ```
1447
1459
  */
1448
1460
  newTextStyleValue(e) {
1449
- return Me.create(e);
1461
+ return Ie.create(e);
1450
1462
  }
1451
1463
  /**
1452
1464
  * Create a new text decoration.
@@ -1461,12 +1473,12 @@ let I = class extends M {
1461
1473
  return new Ve(e);
1462
1474
  }
1463
1475
  };
1464
- I = Ye([
1476
+ U = Ye([
1465
1477
  C(0, p(_)),
1466
- C(1, g),
1467
- C(2, F),
1478
+ C(1, y),
1479
+ C(2, W),
1468
1480
  C(3, p(V))
1469
- ], I);
1481
+ ], U);
1470
1482
  export {
1471
1483
  $ as FBase,
1472
1484
  $e as FBaseInitialable,
@@ -1474,6 +1486,6 @@ export {
1474
1486
  O as FEnum,
1475
1487
  j as FEventName,
1476
1488
  P as FHooks,
1477
- I as FUniver,
1478
- U as FUtil
1489
+ U as FUniver,
1490
+ M as FUtil
1479
1491
  };