@univerjs/core 1.0.0-rc.0 → 1.0.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 (32) hide show
  1. package/lib/cjs/facade.js +96 -40
  2. package/lib/cjs/index.js +985 -362
  3. package/lib/es/facade.js +97 -41
  4. package/lib/es/index.js +979 -362
  5. package/lib/facade.js +97 -41
  6. package/lib/index.js +979 -362
  7. package/lib/types/docs/data-model/text-x/action-types.d.ts +19 -1
  8. package/lib/types/docs/data-model/text-x/apply-utils/common.d.ts +1 -1
  9. package/lib/types/docs/data-model/text-x/apply-utils/delete-apply.d.ts +1 -1
  10. package/lib/types/docs/data-model/text-x/apply-utils/insert-apply.d.ts +1 -1
  11. package/lib/types/docs/data-model/text-x/apply.d.ts +1 -1
  12. package/lib/types/docs/data-model/text-x/build-utils/text-x-utils.d.ts +2 -1
  13. package/lib/types/docs/data-model/text-x/custom-range-update.d.ts +30 -0
  14. package/lib/types/docs/data-model/text-x/structure-validator.d.ts +1 -1
  15. package/lib/types/docs/data-model/text-x/text-x.d.ts +7 -3
  16. package/lib/types/docs/data-model/text-x/utils.d.ts +7 -1
  17. package/lib/types/docs/sdt-binding.d.ts +19 -0
  18. package/lib/types/facade/f-blob.d.ts +11 -11
  19. package/lib/types/facade/f-enum.d.ts +9 -1
  20. package/lib/types/facade/f-event-registry.d.ts +18 -6
  21. package/lib/types/facade/f-event.d.ts +4 -0
  22. package/lib/types/facade/f-univer.d.ts +43 -19
  23. package/lib/types/index.d.ts +2 -0
  24. package/lib/types/sheets/typedef.d.ts +38 -7
  25. package/lib/types/sheets/workbook.d.ts +1 -1
  26. package/lib/types/sheets/worksheet.d.ts +8 -7
  27. package/lib/types/types/enum/record-filter.d.ts +30 -0
  28. package/lib/types/types/interfaces/i-document-data.d.ts +256 -9
  29. package/lib/types/types/interfaces/i-drawing.d.ts +9 -1
  30. package/lib/umd/facade.js +1 -1
  31. package/lib/umd/index.js +26 -26
  32. package/package.json +7 -7
package/lib/cjs/facade.js CHANGED
@@ -81,7 +81,7 @@ var FBaseInitialable = class extends _univerjs_core.Disposable {
81
81
  };
82
82
 
83
83
  //#endregion
84
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorateParam.js
84
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorateParam.js
85
85
  function __decorateParam(paramIndex, decorator) {
86
86
  return function(target, key) {
87
87
  decorator(target, key, paramIndex);
@@ -89,7 +89,7 @@ function __decorateParam(paramIndex, decorator) {
89
89
  }
90
90
 
91
91
  //#endregion
92
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/decorate.js
92
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/decorate.js
93
93
  function __decorate(decorators, target, key, desc) {
94
94
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
95
95
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -120,9 +120,9 @@ let FBlob = _FBlob = class FBlob extends FBase {
120
120
  return this._injector.createInstance(_FBlob, this._blob);
121
121
  }
122
122
  /**
123
- * Return the data inside this object as a blob converted to the specified content type.
123
+ * Returns a copy labeled with the specified MIME type. The data bytes are not converted or re-encoded.
124
124
  * @param contentType the content type refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types
125
- * @returns a new blob by converting the current blob to the specified content type
125
+ * @returns {FBlob} A new facade containing the same data with the specified MIME type.
126
126
  * @example
127
127
  * ```ts
128
128
  * const blob = univerAPI.newBlob();
@@ -148,10 +148,10 @@ let FBlob = _FBlob = class FBlob extends FBase {
148
148
  }
149
149
  /**
150
150
  * Gets the data stored in this blob.
151
- * @returns the blob content as a byte array
151
+ * @returns {Promise<Uint8Array>} A promise resolving to the bytes; rejects if no blob data is set.
152
152
  * @example
153
153
  * ```ts
154
- * const blob = univerAPI.newBlob();
154
+ * const blob = univerAPI.newBlob().setDataFromString('Hello, World!');
155
155
  * const bytes = await blob.getBytes();
156
156
  * console.log(bytes);
157
157
  * ```
@@ -182,7 +182,7 @@ let FBlob = _FBlob = class FBlob extends FBase {
182
182
  }
183
183
  /**
184
184
  * Gets the content type of the data stored in this blob.
185
- * @returns the content type
185
+ * @returns {string | undefined} The MIME type, or `undefined` if no blob data is set.
186
186
  * @example
187
187
  * ```ts
188
188
  * const blob = univerAPI.newBlob();
@@ -195,7 +195,7 @@ let FBlob = _FBlob = class FBlob extends FBase {
195
195
  return (_this$_blob = this._blob) === null || _this$_blob === void 0 ? void 0 : _this$_blob.type;
196
196
  }
197
197
  /**
198
- * Sets the content type of the data stored in this blob.
198
+ * Sets the MIME type without converting or re-encoding the data bytes. Has no effect when no blob data is set.
199
199
  * @param contentType the content type refer to https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types/Common_types
200
200
  * @returns the blob object
201
201
  * @example
@@ -213,7 +213,7 @@ let FBlob = _FBlob = class FBlob extends FBase {
213
213
  FBlob = _FBlob = __decorate([__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector))], FBlob);
214
214
 
215
215
  //#endregion
216
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/typeof.js
216
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/typeof.js
217
217
  function _typeof(o) {
218
218
  "@babel/helpers - typeof";
219
219
  return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
@@ -224,7 +224,7 @@ function _typeof(o) {
224
224
  }
225
225
 
226
226
  //#endregion
227
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPrimitive.js
227
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPrimitive.js
228
228
  function toPrimitive(t, r) {
229
229
  if ("object" != _typeof(t) || !t) return t;
230
230
  var e = t[Symbol.toPrimitive];
@@ -237,14 +237,14 @@ function toPrimitive(t, r) {
237
237
  }
238
238
 
239
239
  //#endregion
240
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/toPropertyKey.js
240
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/toPropertyKey.js
241
241
  function toPropertyKey(t) {
242
242
  var i = toPrimitive(t, "string");
243
243
  return "symbol" == _typeof(i) ? i : i + "";
244
244
  }
245
245
 
246
246
  //#endregion
247
- //#region \0@oxc-project+runtime@0.140.0/helpers/esm/defineProperty.js
247
+ //#region \0@oxc-project+runtime@0.149.0/helpers/esm/defineProperty.js
248
248
  function _defineProperty(e, r, t) {
249
249
  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
250
250
  value: t,
@@ -275,6 +275,18 @@ function _defineProperty(e, r, t) {
275
275
  * @hideconstructor
276
276
  */
277
277
  var FEnum = class FEnum {
278
+ /** SpreadsheetML formula types. */
279
+ get FormulaType() {
280
+ return _univerjs_core.FormulaType;
281
+ }
282
+ /** Worksheet hiding states: VISIBLE (0), HIDDEN (1), VERY_HIDDEN (2). */
283
+ get WorksheetHiddenState() {
284
+ return _univerjs_core.WorksheetHiddenState;
285
+ }
286
+ /**
287
+ * Returns the shared registry of Facade enum values.
288
+ * @returns {FEnum} The registry also exposed by `univerAPI.Enum`.
289
+ */
278
290
  static get() {
279
291
  if (this._instance) return this._instance;
280
292
  const instance = new FEnum();
@@ -725,6 +737,10 @@ _defineProperty(FEnum, "_instance", void 0);
725
737
  * @hideconstructor
726
738
  */
727
739
  var FEventName = class FEventName {
740
+ /**
741
+ * Returns the shared registry of Facade event names.
742
+ * @returns {FEventName} The registry also exposed by `univerAPI.Event`.
743
+ */
728
744
  static get() {
729
745
  if (this._instance) return this._instance;
730
746
  const instance = new FEventName();
@@ -923,6 +939,13 @@ var FEventRegistry = class {
923
939
  if (!this._eventRegistry.has(event)) this._eventRegistry.set(event, new _univerjs_core.Registry());
924
940
  return this._eventRegistry.get(event);
925
941
  }
942
+ /**
943
+ * Registers a factory for the underlying subscription that produces an event.
944
+ * The factory starts when the event has listeners; its subscription is disposed when the last listener is removed.
945
+ * @param {string} event The event name.
946
+ * @param {() => IDisposable | Subscription} handler Creates the underlying event subscription.
947
+ * @returns {IDisposable} Unregisters the factory and disposes its active subscription.
948
+ */
926
949
  registerEventHandler(event, handler) {
927
950
  const current = this._eventHandlerMap.get(event);
928
951
  if (current) current.add(handler);
@@ -935,6 +958,11 @@ var FEventRegistry = class {
935
958
  (_this$_eventHandlerRe2 = this._eventHandlerRegisted.get(event)) === null || _this$_eventHandlerRe2 === void 0 || _this$_eventHandlerRe2.delete(handler);
936
959
  });
937
960
  }
961
+ /**
962
+ * Removes one event listener and stops underlying subscriptions when no listeners remain.
963
+ * @param {T} event The event name.
964
+ * @param {(params: IEventParamConfig[T]) => void} callback The previously registered callback.
965
+ */
938
966
  removeEvent(event, callback) {
939
967
  const map = this._ensureEventRegistry(event);
940
968
  map.delete(callback);
@@ -958,9 +986,9 @@ var FEventRegistry = class {
958
986
  }
959
987
  /**
960
988
  * Add an event listener
961
- * @param {string} event key of event
962
- * @param {(params: IEventParamConfig[typeof event]) => void} callback callback when event triggered
963
- * @returns {Disposable} The Disposable instance, for remove the listener
989
+ * @param {T} event key of event
990
+ * @param {(params: IEventParamConfig[T]) => void} callback callback when event triggered
991
+ * @returns {IDisposable} A disposable that removes the event listener.
964
992
  * @example
965
993
  * ```ts
966
994
  * univerAPI.addEvent(univerAPI.Event.LifeCycleChanged, (params) => {
@@ -976,9 +1004,9 @@ var FEventRegistry = class {
976
1004
  }
977
1005
  /**
978
1006
  * Fire an event, used in internal only.
979
- * @param {string} event key of event
980
- * @param {any} params params of event
981
- * @returns {boolean} should cancel
1007
+ * @param {T} event key of event
1008
+ * @param {IEventParamConfig[T]} params params of event
1009
+ * @returns {boolean | undefined} The event's `cancel` value after listeners run; `undefined` if it was not set.
982
1010
  * @example
983
1011
  * ```ts
984
1012
  * this.fireEvent(univerAPI.Event.LifeCycleChanged, params);
@@ -1105,7 +1133,7 @@ var _FUniver;
1105
1133
  const InitializerSymbol = Symbol("initializers");
1106
1134
  let FUniver = _FUniver = class FUniver extends _univerjs_core.Disposable {
1107
1135
  /**
1108
- * Create an FUniver instance, if the injector is not provided, it will create a new Univer instance.
1136
+ * Creates a Facade API instance for an existing Univer instance or its injector.
1109
1137
  * @static
1110
1138
  * @param {Univer | Injector} wrapped - The Univer instance or injector instance.
1111
1139
  * @returns {FUniver} - The FUniver instance.
@@ -1147,9 +1175,20 @@ let FUniver = _FUniver = class FUniver extends _univerjs_core.Disposable {
1147
1175
  this._univerInstanceService = _univerInstanceService;
1148
1176
  this._lifecycleService = _lifecycleService;
1149
1177
  _defineProperty(this, "_eventRegistry", new FEventRegistry());
1150
- _defineProperty(this, "registerEventHandler", (event, handler) => {
1151
- return this._eventRegistry.registerEventHandler(event, handler);
1152
- });
1178
+ _defineProperty(
1179
+ this,
1180
+ /**
1181
+ * Registers a factory for the subscription that produces an event.
1182
+ * The factory starts when listeners exist and its subscription is disposed when the last listener is removed.
1183
+ * @param event The event name.
1184
+ * @param handler Creates the underlying event subscription.
1185
+ * @returns A disposable that unregisters the factory and disposes its active subscription.
1186
+ */
1187
+ "registerEventHandler",
1188
+ (event, handler) => {
1189
+ return this._eventRegistry.registerEventHandler(event, handler);
1190
+ }
1191
+ );
1153
1192
  this.disposeWithMe(this.registerEventHandler(this.Event.LifeCycleChanged, () => (0, _univerjs_core.toDisposable)(this._lifecycleService.lifecycle$.subscribe((stage) => {
1154
1193
  this.fireEvent(this.Event.LifeCycleChanged, { stage });
1155
1194
  }))));
@@ -1265,8 +1304,8 @@ let FUniver = _FUniver = class FUniver extends _univerjs_core.Disposable {
1265
1304
  })));
1266
1305
  }
1267
1306
  /**
1268
- * Dispose the UniverSheet by the `unitId`. The UniverSheet would be unload from the application.
1269
- * @param unitId The unit id of the UniverSheet.
1307
+ * Disposes the document, workbook, or other Univer unit identified by `unitId`, unloading it from the application.
1308
+ * @param unitId The ID of the unit to dispose.
1270
1309
  * @returns Whether the Univer instance is disposed successfully.
1271
1310
  *
1272
1311
  * @example
@@ -1459,9 +1498,9 @@ let FUniver = _FUniver = class FUniver extends _univerjs_core.Disposable {
1459
1498
  /**
1460
1499
  * Execute a command with the given id and parameters.
1461
1500
  * @param id Identifier of the command.
1462
- * @param params Parameters of this execution.
1463
- * @param options Options of this execution.
1464
- * @returns The result of the execution. It is a boolean value by default which indicates the command is executed.
1501
+ * @param [params] Parameters of this execution.
1502
+ * @param [options] Options of this execution.
1503
+ * @returns {Promise<R>} The result of the execution. It is a boolean value by default which indicates the command is executed.
1465
1504
  *
1466
1505
  * @example
1467
1506
  * ```ts
@@ -1477,8 +1516,8 @@ let FUniver = _FUniver = class FUniver extends _univerjs_core.Disposable {
1477
1516
  /**
1478
1517
  * Execute a command with the given id and parameters synchronously.
1479
1518
  * @param id Identifier of the command.
1480
- * @param params Parameters of this execution.
1481
- * @param options Options of this execution.
1519
+ * @param [params] Parameters of this execution.
1520
+ * @param [options] Options of this execution.
1482
1521
  * @returns The result of the execution. It is a boolean value by default which indicates the command is executed.
1483
1522
  *
1484
1523
  * @example
@@ -1492,20 +1531,29 @@ let FUniver = _FUniver = class FUniver extends _univerjs_core.Disposable {
1492
1531
  syncExecuteCommand(id, params, options) {
1493
1532
  return this._commandService.syncExecuteCommand(id, params, options);
1494
1533
  }
1534
+ /**
1535
+ * Enums exposed by the registered Facade extensions.
1536
+ */
1495
1537
  get Enum() {
1496
1538
  return FEnum.get();
1497
1539
  }
1540
+ /**
1541
+ * Event names to use with `addEvent`.
1542
+ */
1498
1543
  get Event() {
1499
1544
  return FEventName.get();
1500
1545
  }
1546
+ /**
1547
+ * Utility functions exposed by the registered Facade extensions.
1548
+ */
1501
1549
  get Util() {
1502
1550
  return FUtil.get();
1503
1551
  }
1504
1552
  /**
1505
1553
  * Add an event listener
1506
- * @param {string} event key of event
1507
- * @param {(params: IEventParamConfig[typeof event]) => void} callback callback when event triggered
1508
- * @returns {Disposable} The Disposable instance, for remove the listener
1554
+ * @param {T} event key of event
1555
+ * @param {(params: IEventParamConfig[T]) => void} callback callback when event triggered
1556
+ * @returns {IDisposable} A disposable that removes the event listener.
1509
1557
  * @example
1510
1558
  * ```ts
1511
1559
  * // Add life cycle changed event listener
@@ -1523,9 +1571,9 @@ let FUniver = _FUniver = class FUniver extends _univerjs_core.Disposable {
1523
1571
  }
1524
1572
  /**
1525
1573
  * Fire an event, used in internal only.
1526
- * @param {string} event key of event
1527
- * @param {any} params params of event
1528
- * @returns {boolean} should cancel
1574
+ * @param {T} event key of event
1575
+ * @param {IEventParamConfig[T]} params params of event
1576
+ * @returns {boolean | undefined} The event's `cancel` value after listeners run; `undefined` if it was not set.
1529
1577
  * @example
1530
1578
  * ```ts
1531
1579
  * this.fireEvent(univerAPI.Event.LifeCycleChanged, params);
@@ -1534,6 +1582,14 @@ let FUniver = _FUniver = class FUniver extends _univerjs_core.Disposable {
1534
1582
  fireEvent(event, params) {
1535
1583
  return this._eventRegistry.fireEvent(event, params);
1536
1584
  }
1585
+ /**
1586
+ * Gets the facade for reading the current user.
1587
+ * @returns {FUserManager} The user manager facade.
1588
+ * @example
1589
+ * ```ts
1590
+ * const user = univerAPI.getUserManager().getCurrentUser();
1591
+ * ```
1592
+ */
1537
1593
  getUserManager() {
1538
1594
  return this._injector.createInstance(FUserManager);
1539
1595
  }
@@ -1594,7 +1650,7 @@ let FUniver = _FUniver = class FUniver extends _univerjs_core.Disposable {
1594
1650
  * This is an advanced document-model API. Application and agent code should normally use
1595
1651
  * `newRichText().paragraph({ ... })`.
1596
1652
  *
1597
- * @param {IParagraphStyle} style The paragraph style
1653
+ * @param {IParagraphStyle} [style] The paragraph style
1598
1654
  * @returns {ParagraphStyleBuilder} The new paragraph style instance
1599
1655
  * @advanced
1600
1656
  */
@@ -1603,7 +1659,7 @@ let FUniver = _FUniver = class FUniver extends _univerjs_core.Disposable {
1603
1659
  }
1604
1660
  /**
1605
1661
  * Create a new paragraph style value.
1606
- * @param {IParagraphStyle} style - The paragraph style
1662
+ * @param {IParagraphStyle} [style] - The paragraph style
1607
1663
  * @returns {ParagraphStyleValue} The new paragraph style value instance
1608
1664
  * @example
1609
1665
  * ```ts
@@ -1615,7 +1671,7 @@ let FUniver = _FUniver = class FUniver extends _univerjs_core.Disposable {
1615
1671
  }
1616
1672
  /**
1617
1673
  * Create a new text style.
1618
- * @param {ITextStyle} style - The text style
1674
+ * @param {ITextStyle} [style] - The text style
1619
1675
  * @returns {TextStyleBuilder} The new text style instance
1620
1676
  * @example
1621
1677
  * ```ts
@@ -1627,7 +1683,7 @@ let FUniver = _FUniver = class FUniver extends _univerjs_core.Disposable {
1627
1683
  }
1628
1684
  /**
1629
1685
  * Create a new text style value.
1630
- * @param {ITextStyle} style - The text style
1686
+ * @param {ITextStyle} [style] - The text style
1631
1687
  * @returns {TextStyleValue} The new text style value instance
1632
1688
  * @example
1633
1689
  * ```ts
@@ -1639,7 +1695,7 @@ let FUniver = _FUniver = class FUniver extends _univerjs_core.Disposable {
1639
1695
  }
1640
1696
  /**
1641
1697
  * Create a new text decoration.
1642
- * @param {ITextDecoration} decoration - The text decoration
1698
+ * @param {ITextDecoration} [decoration] - The text decoration
1643
1699
  * @returns {TextDecorationBuilder} The new text decoration instance
1644
1700
  * @example
1645
1701
  * ```ts