@univerjs/core 0.3.0-alpha.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/es/index.js CHANGED
@@ -2513,6 +2513,8 @@ let CommandService = (_a = class extends Disposable {
2513
2513
  }
2514
2514
  throw new Error(`[CommandService]: command "${id}" is not registered.`);
2515
2515
  } catch (error) {
2516
+ if (error instanceof CustomCommandExecutionError)
2517
+ return !1;
2516
2518
  throw this._logService.error(error), error;
2517
2519
  }
2518
2520
  }
@@ -11117,7 +11119,7 @@ const FOCUSING_UNIT = "FOCUSING_UNIT", FOCUSING_SHEET = "FOCUSING_SHEET", FOCUSI
11117
11119
  };
11118
11120
  __name(_ErrorService, "ErrorService");
11119
11121
  let ErrorService = _ErrorService;
11120
- const version = "0.3.0-alpha.0";
11122
+ const version = "0.3.0";
11121
11123
  function getEmptySnapshot(unitID = "", locale = LocaleType.ZH_CN, name = "") {
11122
11124
  return {
11123
11125
  id: unitID,
@@ -11471,15 +11473,23 @@ const _SpanModel = class _SpanModel extends Disposable {
11471
11473
  /**
11472
11474
  * @property Cache for RANGE_TYPE.NORMAL
11473
11475
  */
11474
- __publicField(this, "_cellCache", {});
11476
+ __publicField(this, "_cellCache", /* @__PURE__ */ new Map());
11475
11477
  /**
11476
11478
  * @property Cache for RANGE_TYPE.ROW
11477
11479
  */
11478
- __publicField(this, "_rowCache", {});
11480
+ __publicField(this, "_rowCache", /* @__PURE__ */ new Map());
11479
11481
  /**
11480
11482
  * @property Cache for RANGE_TYPE.COLUMN
11481
11483
  */
11482
- __publicField(this, "_columnCache", {});
11484
+ __publicField(this, "_columnCache", /* @__PURE__ */ new Map());
11485
+ /**
11486
+ * @property Whether has RANGE_TYPE.ROW
11487
+ */
11488
+ __publicField(this, "_hasRow", !1);
11489
+ /**
11490
+ * @property Whether has RANGE_TYPE.COLUMN
11491
+ */
11492
+ __publicField(this, "_hasColumn", !1);
11483
11493
  /**
11484
11494
  * @property Whether has RANGE_TYPE.ALL
11485
11495
  */
@@ -11500,7 +11510,7 @@ const _SpanModel = class _SpanModel extends Disposable {
11500
11510
  this._mergeData = mergeData, this._createCache(mergeData);
11501
11511
  }
11502
11512
  _clearCache() {
11503
- this._cellCache = {}, this._rowCache = {}, this._columnCache = {}, this._hasAll = !1, this._allIndex = -1, this._rangeMap.clear(), this._skeletonCache.clear();
11513
+ this._cellCache.clear(), this._rowCache.clear(), this._columnCache.clear(), this._hasAll = !1, this._allIndex = -1, this._rangeMap.clear(), this._skeletonCache.clear(), this._hasColumn = !1, this._hasRow = !1;
11504
11514
  }
11505
11515
  _createCache(mergeData) {
11506
11516
  let index2 = 0;
@@ -11518,25 +11528,24 @@ const _SpanModel = class _SpanModel extends Disposable {
11518
11528
  }
11519
11529
  _createRowCache(range, index2) {
11520
11530
  const { startRow, endRow } = range;
11521
- for (let i = startRow; i <= endRow; i++) {
11522
- const key = `${i}`;
11523
- this._rowCache[key] = index2;
11524
- }
11531
+ for (let i = startRow; i <= endRow; i++)
11532
+ this._rowCache.set(i, index2), this._hasRow = !0;
11525
11533
  }
11526
11534
  _createColumnCache(range, index2) {
11527
11535
  const { startColumn, endColumn } = range;
11528
- for (let i = startColumn; i <= endColumn; i++) {
11529
- const key = `${i}`;
11530
- this._columnCache[key] = index2;
11531
- }
11536
+ for (let i = startColumn; i <= endColumn; i++)
11537
+ this._columnCache.set(i, index2), this._hasColumn = !0;
11532
11538
  }
11533
11539
  _createCellAllCache(index2) {
11534
11540
  this._hasAll = !0, this._allIndex = index2;
11535
11541
  }
11536
11542
  _createCellCache(range, index2) {
11537
- for (let i = range.startRow; i <= range.endRow; i++)
11543
+ for (let i = range.startRow; i <= range.endRow; i++) {
11544
+ let columnCache = this._cellCache.get(i);
11545
+ columnCache == null && (columnCache = /* @__PURE__ */ new Map(), this._cellCache.set(i, columnCache));
11538
11546
  for (let j = range.startColumn; j <= range.endColumn; j++)
11539
- this._cellCache[`${i}-${j}`] = index2;
11547
+ columnCache.set(j, index2);
11548
+ }
11540
11549
  }
11541
11550
  add(range) {
11542
11551
  this._mergeData.push(range), this._clearCache(), this._createCache(this._mergeData);
@@ -11626,15 +11635,21 @@ const _SpanModel = class _SpanModel extends Disposable {
11626
11635
  return ranges;
11627
11636
  }
11628
11637
  _getMergeDataIndex(row, column) {
11638
+ var _a13;
11629
11639
  if (this._hasAll)
11630
11640
  return this._allIndex;
11631
- const rowKey = `${row}`, columnKey = `${column}`;
11632
- if (this._rowCache[rowKey] !== void 0)
11633
- return this._rowCache[rowKey];
11634
- if (this._columnCache[columnKey] !== void 0)
11635
- return this._columnCache[columnKey];
11636
- const key = `${row}-${column}`;
11637
- return this._cellCache[key] !== void 0 ? this._cellCache[key] : -1;
11641
+ if (this._hasRow) {
11642
+ const rowValue = this._rowCache.get(row);
11643
+ if (rowValue !== void 0)
11644
+ return rowValue;
11645
+ }
11646
+ if (this._hasColumn) {
11647
+ const columnValue = this._columnCache.get(column);
11648
+ if (columnValue !== void 0)
11649
+ return columnValue;
11650
+ }
11651
+ const cellValue = (_a13 = this._cellCache.get(row)) == null ? void 0 : _a13.get(column);
11652
+ return cellValue !== void 0 ? cellValue : -1;
11638
11653
  }
11639
11654
  getMergeDataSnapshot() {
11640
11655
  return this._mergeData;
@@ -13,6 +13,14 @@ export declare class SpanModel extends Disposable {
13
13
  * @property Cache for RANGE_TYPE.COLUMN
14
14
  */
15
15
  private _columnCache;
16
+ /**
17
+ * @property Whether has RANGE_TYPE.ROW
18
+ */
19
+ private _hasRow;
20
+ /**
21
+ * @property Whether has RANGE_TYPE.COLUMN
22
+ */
23
+ private _hasColumn;
16
24
  /**
17
25
  * @property Whether has RANGE_TYPE.ALL
18
26
  */