@univerjs/core 0.7.0-beta.0 → 0.7.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.
package/lib/facade.js CHANGED
@@ -1,9 +1,9 @@
1
1
  var L = Object.defineProperty;
2
2
  var F = (n, e, t) => e in n ? L(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
3
  var d = (n, e, t) => F(n, typeof e != "symbol" ? e + "" : e, t);
4
- import { Disposable as V, Inject as p, Injector as m, AbsoluteRefType as W, UniverInstanceType as R, LifecycleStages as f, DataValidationType as q, DataValidationErrorStyle as J, DataValidationRenderMode as G, DataValidationOperator as K, DataValidationStatus as Q, CommandType as X, BaselineOffset as Y, BooleanNumber as Z, HorizontalAlign as k, TextDecoration as ee, TextDirection as te, VerticalAlign as re, WrapStrategy as ne, BorderType as ie, BorderStyleTypes as oe, AutoFillSeries as se, ColorType as ce, CommonHideTypes as ae, CopyPasteType as de, DeleteDirection as le, DeveloperMetadataVisibility as pe, Dimension as he, Direction as ue, InterpolationPointType as ye, LocaleType as ge, MentionType as ve, ProtectionType as fe, RelativeDate as me, SheetTypes as _e, ThemeColorType as Ee, LifecycleService as $, toDisposable as l, ICommandService as y, UndoCommand as h, IUndoRedoService as E, RedoCommand as u, Registry as be, UserManagerService as Se, Rectangle as Ce, numfmt as De, Tools as we, IUniverInstanceService as A, Univer as xe, CanceledError as w, ColorBuilder as Te, RichTextBuilder as Re, RichTextValue as Oe, ParagraphStyleBuilder as Pe, ParagraphStyleValue as je, TextStyleBuilder as Be, TextStyleValue as Ue, TextDecorationBuilder as He } from "@univerjs/core";
4
+ import { Disposable as I, Inject as l, Injector as _, AbsoluteRefType as W, UniverInstanceType as R, LifecycleStages as f, DataValidationType as q, DataValidationErrorStyle as G, DataValidationRenderMode as J, DataValidationOperator as K, DataValidationStatus as Q, CommandType as X, BaselineOffset as Y, BooleanNumber as Z, HorizontalAlign as k, TextDecoration as ee, TextDirection as te, VerticalAlign as re, WrapStrategy as ne, BorderType as ie, BorderStyleTypes as oe, AutoFillSeries as se, ColorType as ce, CommonHideTypes as ae, CopyPasteType as de, DeleteDirection as pe, DeveloperMetadataVisibility as le, Dimension as he, Direction as ue, InterpolationPointType as ye, LocaleType as ge, MentionType as ve, ProtectionType as fe, RelativeDate as _e, SheetTypes as me, ThemeColorType as Ee, LifecycleService as $, toDisposable as p, ICommandService as y, UndoCommand as h, IUndoRedoService as E, RedoCommand as u, Registry as be, UserManagerService as Se, Rectangle as Ce, numfmt as De, Tools as xe, IUniverInstanceService as N, Univer as Te, CanceledError as x, ColorBuilder as we, RichTextBuilder as Re, RichTextValue as Oe, ParagraphStyleBuilder as Pe, ParagraphStyleValue as je, TextStyleBuilder as Be, TextStyleValue as He, TextDecorationBuilder as Ue } from "@univerjs/core";
5
5
  import { filter as b } from "rxjs";
6
- class M extends V {
6
+ class M extends I {
7
7
  /**
8
8
  * @ignore
9
9
  */
@@ -15,11 +15,11 @@ class M extends V {
15
15
  });
16
16
  }
17
17
  }
18
- const x = Symbol("initializers");
19
- class Ie extends V {
18
+ const T = Symbol("initializers");
19
+ class Ve extends I {
20
20
  constructor(e) {
21
21
  super(), this._injector = e;
22
- const t = this, r = Object.getPrototypeOf(this)[x];
22
+ const t = this, r = Object.getPrototypeOf(this)[T];
23
23
  r && r.forEach(function(i) {
24
24
  i.apply(t, [e]);
25
25
  });
@@ -35,16 +35,16 @@ class Ie extends V {
35
35
  static extend(e) {
36
36
  Object.getOwnPropertyNames(e.prototype).forEach((t) => {
37
37
  if (t === "_initialize") {
38
- let r = this.prototype[x];
39
- r || (r = [], this.prototype[x] = r), r.push(e.prototype._initialize);
38
+ let r = this.prototype[T];
39
+ r || (r = [], this.prototype[T] = r), r.push(e.prototype._initialize);
40
40
  } else t !== "constructor" && (this.prototype[t] = e.prototype[t]);
41
41
  }), Object.getOwnPropertyNames(e).forEach((t) => {
42
42
  t !== "prototype" && t !== "name" && t !== "length" && (this[t] = e[t]);
43
43
  });
44
44
  }
45
45
  }
46
- var Ve = Object.getOwnPropertyDescriptor, $e = (n, e, t, r) => {
47
- for (var i = r > 1 ? void 0 : r ? Ve(e, t) : e, o = n.length - 1, s; o >= 0; o--)
46
+ var Ie = Object.getOwnPropertyDescriptor, $e = (n, e, t, r) => {
47
+ for (var i = r > 1 ? void 0 : r ? Ie(e, t) : e, o = n.length - 1, s; o >= 0; o--)
48
48
  (s = n[o]) && (i = s(i) || i);
49
49
  return i;
50
50
  }, Me = (n, e) => (t, r) => e(t, r, n);
@@ -151,7 +151,7 @@ let C = class extends M {
151
151
  }
152
152
  };
153
153
  C = $e([
154
- Me(1, p(m))
154
+ Me(1, l(_))
155
155
  ], C);
156
156
  const g = class g {
157
157
  static get() {
@@ -227,7 +227,7 @@ const g = class g {
227
227
  * ```
228
228
  */
229
229
  get DataValidationErrorStyle() {
230
- return J;
230
+ return G;
231
231
  }
232
232
  /**
233
233
  * Different validation rendering modes
@@ -238,7 +238,7 @@ const g = class g {
238
238
  * ```
239
239
  */
240
240
  get DataValidationRenderMode() {
241
- return G;
241
+ return J;
242
242
  }
243
243
  /**
244
244
  * Different validation operators
@@ -425,7 +425,7 @@ const g = class g {
425
425
  * ```
426
426
  */
427
427
  get DeleteDirection() {
428
- return le;
428
+ return pe;
429
429
  }
430
430
  /**
431
431
  * Developer metadata visibility types
@@ -436,7 +436,7 @@ const g = class g {
436
436
  * ```
437
437
  */
438
438
  get DeveloperMetadataVisibility() {
439
- return pe;
439
+ return le;
440
440
  }
441
441
  /**
442
442
  * Dimension types
@@ -513,7 +513,7 @@ const g = class g {
513
513
  * ```
514
514
  */
515
515
  get RelativeDate() {
516
- return me;
516
+ return _e;
517
517
  }
518
518
  /**
519
519
  * Sheet types
@@ -524,7 +524,7 @@ const g = class g {
524
524
  * ```
525
525
  */
526
526
  get SheetTypes() {
527
- return _e;
527
+ return me;
528
528
  }
529
529
  /**
530
530
  * Theme color types
@@ -723,7 +723,7 @@ const v = class v {
723
723
  */
724
724
  d(v, "_instance");
725
725
  let P = v;
726
- var ze = Object.getOwnPropertyDescriptor, Ne = (n, e, t, r) => {
726
+ var ze = Object.getOwnPropertyDescriptor, Ae = (n, e, t, r) => {
727
727
  for (var i = r > 1 ? void 0 : r ? ze(e, t) : e, o = n.length - 1, s; o >= 0; o--)
728
728
  (s = n[o]) && (i = s(i) || i);
729
729
  return i;
@@ -737,28 +737,28 @@ let j = class extends M {
737
737
  * @deprecated use `univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, ({ stage }) => {})` as instead
738
738
  */
739
739
  onStarting(n) {
740
- return l(this._lifecycleService.lifecycle$.pipe(b((e) => e === f.Starting)).subscribe(n));
740
+ return p(this._lifecycleService.lifecycle$.pipe(b((e) => e === f.Starting)).subscribe(n));
741
741
  }
742
742
  /**
743
743
  * @param callback
744
744
  * @deprecated use `univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, ({ stage }) => {})` as instead
745
745
  */
746
746
  onReady(n) {
747
- return l(this._lifecycleService.lifecycle$.pipe(b((e) => e === f.Ready)).subscribe(n));
747
+ return p(this._lifecycleService.lifecycle$.pipe(b((e) => e === f.Ready)).subscribe(n));
748
748
  }
749
749
  /**
750
750
  * @param callback
751
751
  * @deprecated use `univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, ({ stage }) => {})` as instead
752
752
  */
753
753
  onRendered(n) {
754
- return l(this._lifecycleService.lifecycle$.pipe(b((e) => e === f.Rendered)).subscribe(n));
754
+ return p(this._lifecycleService.lifecycle$.pipe(b((e) => e === f.Rendered)).subscribe(n));
755
755
  }
756
756
  /**
757
757
  * @param callback
758
758
  * @deprecated use `univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, ({ stage }) => {})` as instead
759
759
  */
760
760
  onSteady(n) {
761
- return l(this._lifecycleService.lifecycle$.pipe(b((e) => e === f.Steady)).subscribe(n));
761
+ return p(this._lifecycleService.lifecycle$.pipe(b((e) => e === f.Steady)).subscribe(n));
762
762
  }
763
763
  /**
764
764
  * @param callback
@@ -809,22 +809,22 @@ let j = class extends M {
809
809
  });
810
810
  }
811
811
  };
812
- j = Ne([
813
- z(0, p(m)),
814
- z(1, p($))
812
+ j = Ae([
813
+ z(0, l(_)),
814
+ z(1, l($))
815
815
  ], j);
816
- var Ae = Object.getOwnPropertyDescriptor, Le = (n, e, t, r) => {
817
- for (var i = r > 1 ? void 0 : r ? Ae(e, t) : e, o = n.length - 1, s; o >= 0; o--)
816
+ var Ne = Object.getOwnPropertyDescriptor, Le = (n, e, t, r) => {
817
+ for (var i = r > 1 ? void 0 : r ? Ne(e, t) : e, o = n.length - 1, s; o >= 0; o--)
818
818
  (s = n[o]) && (i = s(i) || i);
819
819
  return i;
820
820
  }, Fe = (n, e) => (t, r) => e(t, r, n);
821
- let B = class extends Ie {
821
+ let B = class extends Ve {
822
822
  constructor(n, e) {
823
823
  super(e), this.doc = n;
824
824
  }
825
825
  };
826
826
  B = Le([
827
- Fe(1, p(m))
827
+ Fe(1, l(_))
828
828
  ], B);
829
829
  class We {
830
830
  constructor() {
@@ -837,7 +837,7 @@ class We {
837
837
  }
838
838
  registerEventHandler(e, t) {
839
839
  const r = this._eventHandlerMap.get(e);
840
- return r ? r.add(t) : this._eventHandlerMap.set(e, /* @__PURE__ */ new Set([t])), this._ensureEventRegistry(e).getData().length && this._initEventHandler(e), l(() => {
840
+ return r ? r.add(t) : this._eventHandlerMap.set(e, /* @__PURE__ */ new Set([t])), this._ensureEventRegistry(e).getData().length && this._initEventHandler(e), p(() => {
841
841
  var i, o, s, c;
842
842
  (i = this._eventHandlerMap.get(e)) == null || i.delete(t), (s = (o = this._eventHandlerRegisted.get(e)) == null ? void 0 : o.get(t)) == null || s.dispose(), (c = this._eventHandlerRegisted.get(e)) == null || c.delete(t);
843
843
  });
@@ -853,7 +853,7 @@ class We {
853
853
  let t = this._eventHandlerRegisted.get(e);
854
854
  const r = this._eventHandlerMap.get(e);
855
855
  r && (t || (t = /* @__PURE__ */ new Map(), this._eventHandlerRegisted.set(e, t), r == null || r.forEach((i) => {
856
- t == null || t.set(i, l(i()));
856
+ t == null || t.set(i, p(i()));
857
857
  })));
858
858
  }
859
859
  /**
@@ -870,7 +870,7 @@ class We {
870
870
  * ```
871
871
  */
872
872
  addEvent(e, t) {
873
- return this._ensureEventRegistry(e).add(t), this._initEventHandler(e), l(() => this.removeEvent(e, t));
873
+ return this._ensureEventRegistry(e).add(t), this._initEventHandler(e), p(() => this.removeEvent(e, t));
874
874
  }
875
875
  /**
876
876
  * Fire an event, used in internal only.
@@ -889,12 +889,12 @@ class We {
889
889
  }), t.cancel;
890
890
  }
891
891
  }
892
- var qe = Object.getOwnPropertyDescriptor, Je = (n, e, t, r) => {
892
+ var qe = Object.getOwnPropertyDescriptor, Ge = (n, e, t, r) => {
893
893
  for (var i = r > 1 ? void 0 : r ? qe(e, t) : e, o = n.length - 1, s; o >= 0; o--)
894
894
  (s = n[o]) && (i = s(i) || i);
895
895
  return i;
896
- }, N = (n, e) => (t, r) => e(t, r, n);
897
- let U = class extends M {
896
+ }, A = (n, e) => (t, r) => e(t, r, n);
897
+ let H = class extends M {
898
898
  constructor(n, e) {
899
899
  super(), this._injector = n, this._userManagerService = e;
900
900
  }
@@ -910,10 +910,10 @@ let U = class extends M {
910
910
  return this._userManagerService.getCurrentUser();
911
911
  }
912
912
  };
913
- U = Je([
914
- N(0, p(m)),
915
- N(1, p(Se))
916
- ], U);
913
+ H = Ge([
914
+ A(0, l(_)),
915
+ A(1, l(Se))
916
+ ], H);
917
917
  const D = class D {
918
918
  static get() {
919
919
  if (this._instance)
@@ -969,28 +969,28 @@ const D = class D {
969
969
  * ```
970
970
  */
971
971
  get tools() {
972
- return we;
972
+ return xe;
973
973
  }
974
974
  };
975
975
  /**
976
976
  * @ignore
977
977
  */
978
978
  d(D, "_instance");
979
- let H = D;
980
- var Ge = Object.getOwnPropertyDescriptor, Ke = (n, e, t, r) => {
981
- for (var i = r > 1 ? void 0 : r ? Ge(e, t) : e, o = n.length - 1, s; o >= 0; o--)
979
+ let U = D;
980
+ var Je = Object.getOwnPropertyDescriptor, Ke = (n, e, t, r) => {
981
+ for (var i = r > 1 ? void 0 : r ? Je(e, t) : e, o = n.length - 1, s; o >= 0; o--)
982
982
  (s = n[o]) && (i = s(i) || i);
983
983
  return i;
984
984
  }, S = (n, e) => (t, r) => e(t, r, n);
985
- const T = Symbol("initializers");
986
- let I = class extends V {
985
+ const w = Symbol("initializers");
986
+ let V = class extends I {
987
987
  constructor(e, t, r, i) {
988
988
  super();
989
989
  d(this, "_eventRegistry", new We());
990
990
  d(this, "registerEventHandler", (e, t) => this._eventRegistry.registerEventHandler(e, t));
991
991
  this._injector = e, this._commandService = t, this._univerInstanceService = r, this._lifecycleService = i, this.registerEventHandler(
992
992
  this.Event.LifeCycleChanged,
993
- () => l(
993
+ () => p(
994
994
  this._lifecycleService.lifecycle$.subscribe((s) => {
995
995
  this.fireEvent(this.Event.LifeCycleChanged, { stage: s });
996
996
  })
@@ -998,7 +998,7 @@ let I = class extends V {
998
998
  ), this._initUnitEvent(this._injector), this._initBeforeCommandEvent(this._injector), this._initCommandEvent(this._injector), this._injector.onDispose(() => {
999
999
  this.dispose();
1000
1000
  });
1001
- const o = Object.getPrototypeOf(this)[T];
1001
+ const o = Object.getPrototypeOf(this)[w];
1002
1002
  if (o) {
1003
1003
  const s = this;
1004
1004
  o.forEach(function(c) {
@@ -1018,16 +1018,7 @@ let I = class extends V {
1018
1018
  * ```
1019
1019
  */
1020
1020
  static newAPI(e) {
1021
- const r = (e instanceof xe ? e.__getInjector() : e).createInstance(I);
1022
- return new Proxy(r, {
1023
- get(i, o) {
1024
- if (o in Object.prototype || typeof o == "symbol" || ["toString", "valueOf", "toJSON", "constructor", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable", "inspect", "then", "catch", "finally"].includes(String(o)) || o in i)
1025
- return Reflect.get(i, o);
1026
- throw new TypeError(
1027
- `[FUniver]: The method '${String(o)}' does not exist on the FUniver instance. This may occur if you haven't imported the required facade package or if you're calling an incorrect method. Please verify the method name and ensure all necessary modules are imported.`
1028
- );
1029
- }
1030
- });
1021
+ return (e instanceof Te ? e.__getInjector() : e).createInstance(V);
1031
1022
  }
1032
1023
  /**
1033
1024
  * @ignore
@@ -1040,8 +1031,8 @@ let I = class extends V {
1040
1031
  static extend(e) {
1041
1032
  Object.getOwnPropertyNames(e.prototype).forEach((t) => {
1042
1033
  if (t === "_initialize") {
1043
- let r = this.prototype[T];
1044
- r || (r = [], this.prototype[T] = r), r.push(e.prototype._initialize);
1034
+ let r = this.prototype[w];
1035
+ r || (r = [], this.prototype[w] = r), r.push(e.prototype._initialize);
1045
1036
  } else t !== "constructor" && (this.prototype[t] = e.prototype[t]);
1046
1037
  }), Object.getOwnPropertyNames(e).forEach((t) => {
1047
1038
  t !== "prototype" && t !== "name" && t !== "length" && (this[t] = e[t]);
@@ -1072,8 +1063,8 @@ let I = class extends V {
1072
1063
  () => t.onCommandExecuted((r, i) => {
1073
1064
  const { id: o, type: s, params: c } = r;
1074
1065
  if (r.id !== u.id && r.id !== h.id) {
1075
- const _ = { id: o, type: s, params: c, options: i };
1076
- this.fireEvent(this.Event.CommandExecuted, _);
1066
+ const m = { id: o, type: s, params: c, options: i };
1067
+ this.fireEvent(this.Event.CommandExecuted, m);
1077
1068
  }
1078
1069
  })
1079
1070
  );
@@ -1087,7 +1078,7 @@ let I = class extends V {
1087
1078
  if (r.id === u.id) {
1088
1079
  const a = { id: i, type: o, params: s };
1089
1080
  if (this.fireEvent(this.Event.BeforeRedo, a), a.cancel)
1090
- throw new w();
1081
+ throw new x();
1091
1082
  }
1092
1083
  })
1093
1084
  ), this.registerEventHandler(
@@ -1097,7 +1088,7 @@ let I = class extends V {
1097
1088
  if (r.id === h.id) {
1098
1089
  const a = { id: i, type: o, params: s };
1099
1090
  if (this.fireEvent(this.Event.BeforeUndo, a), a.cancel)
1100
- throw new w();
1091
+ throw new x();
1101
1092
  }
1102
1093
  })
1103
1094
  ), this.registerEventHandler(
@@ -1105,15 +1096,15 @@ let I = class extends V {
1105
1096
  () => t.beforeCommandExecuted((r, i) => {
1106
1097
  const { id: o, type: s, params: c } = r;
1107
1098
  if (r.id !== u.id && r.id !== h.id) {
1108
- const _ = { id: o, type: s, params: c, options: i };
1109
- if (this.fireEvent(this.Event.BeforeCommandExecute, _), _.cancel)
1110
- throw new w();
1099
+ const m = { id: o, type: s, params: c, options: i };
1100
+ if (this.fireEvent(this.Event.BeforeCommandExecute, m), m.cancel)
1101
+ throw new x();
1111
1102
  }
1112
1103
  })
1113
1104
  );
1114
1105
  }
1115
1106
  _initUnitEvent(e) {
1116
- const t = e.get(A);
1107
+ const t = e.get(N);
1117
1108
  this.registerEventHandler(
1118
1109
  this.Event.DocDisposed,
1119
1110
  () => t.unitDisposed$.subscribe((r) => {
@@ -1266,7 +1257,7 @@ let I = class extends V {
1266
1257
  return P.get();
1267
1258
  }
1268
1259
  get Util() {
1269
- return H.get();
1260
+ return U.get();
1270
1261
  }
1271
1262
  /**
1272
1263
  * Add an event listener
@@ -1302,7 +1293,7 @@ let I = class extends V {
1302
1293
  return this._eventRegistry.fireEvent(e, t);
1303
1294
  }
1304
1295
  getUserManager() {
1305
- return this._injector.createInstance(U);
1296
+ return this._injector.createInstance(H);
1306
1297
  }
1307
1298
  /**
1308
1299
  * Create a new blob.
@@ -1322,9 +1313,10 @@ let I = class extends V {
1322
1313
  * ```ts
1323
1314
  * const color = univerAPI.newColor();
1324
1315
  * ```
1316
+ * @deprecated
1325
1317
  */
1326
1318
  newColor() {
1327
- return new Te();
1319
+ return new we();
1328
1320
  }
1329
1321
  /**
1330
1322
  * Create a new rich text.
@@ -1404,7 +1396,7 @@ let I = class extends V {
1404
1396
  * ```
1405
1397
  */
1406
1398
  newTextStyleValue(e) {
1407
- return Ue.create(e);
1399
+ return He.create(e);
1408
1400
  }
1409
1401
  /**
1410
1402
  * Create a new text decoration.
@@ -1416,22 +1408,22 @@ let I = class extends V {
1416
1408
  * ```
1417
1409
  */
1418
1410
  newTextDecoration(e) {
1419
- return new He(e);
1411
+ return new Ue(e);
1420
1412
  }
1421
1413
  };
1422
- I = Ke([
1423
- S(0, p(m)),
1414
+ V = Ke([
1415
+ S(0, l(_)),
1424
1416
  S(1, y),
1425
- S(2, A),
1426
- S(3, p($))
1427
- ], I);
1417
+ S(2, N),
1418
+ S(3, l($))
1419
+ ], V);
1428
1420
  export {
1429
1421
  M as FBase,
1430
- Ie as FBaseInitialable,
1422
+ Ve as FBaseInitialable,
1431
1423
  C as FBlob,
1432
1424
  O as FEnum,
1433
1425
  P as FEventName,
1434
1426
  j as FHooks,
1435
- I as FUniver,
1436
- H as FUtil
1427
+ V as FUniver,
1428
+ U as FUtil
1437
1429
  };