@univerjs/core 0.2.9 → 0.2.10

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
@@ -3752,7 +3752,7 @@ function covertTextRunToHtml(dataStream, textRun) {
3752
3752
  return it === BooleanNumber.TRUE && (html = `<i>${html}</i>`), va === BaselineOffset.SUPERSCRIPT ? html = `<sup>${html}</sup>` : va === BaselineOffset.SUBSCRIPT && (html = `<sub>${html}</sub>`), (ul == null ? void 0 : ul.s) === BooleanNumber.TRUE && (html = `<u>${html}</u>`), (st == null ? void 0 : st.s) === BooleanNumber.TRUE && (html = `<s>${html}</s>`), bl === BooleanNumber.TRUE && (html = `<strong>${html}</strong>`), ff && style.push(`font-family: ${ff}`), cl && style.push(`color: ${cl.rgb}`), fs && style.push(`font-size: ${fs}pt`), ol && style.push("text-decoration: overline"), bg && style.push(`background: ${bg.rgb}`), style.length ? `<span style="${style.join("; ")};">${html}</span>` : html;
3753
3753
  }
3754
3754
  __name(covertTextRunToHtml, "covertTextRunToHtml");
3755
- var numfmt$1 = { exports: {} };
3755
+ var numfmt$2 = { exports: {} };
3756
3756
  (function(module, exports) {
3757
3757
  (function(e, t) {
3758
3758
  module.exports = t();
@@ -4036,8 +4036,8 @@ var numfmt$1 = { exports: {} };
4036
4036
  return t2 === 6 ? A(a2) : t2 === -1 ? E(a2) : C(a2, n2);
4037
4037
  }
4038
4038
  __name(Y, "Y");
4039
- const T = Math.floor, N2 = 86400;
4040
- function P2(e2, t2) {
4039
+ const T = Math.floor, N = 86400;
4040
+ function P(e2, t2) {
4041
4041
  let n2 = null;
4042
4042
  if (Array.isArray(e2)) {
4043
4043
  const [t3, a2, r2, i2, s2, o2] = e2;
@@ -4052,13 +4052,13 @@ var numfmt$1 = { exports: {} };
4052
4052
  }
4053
4053
  return e2;
4054
4054
  }
4055
- __name(P2, "P");
4055
+ __name(P, "P");
4056
4056
  function I2(e2, t2) {
4057
4057
  let n2 = 0 | e2;
4058
- const a2 = N2 * (e2 - n2);
4058
+ const a2 = N * (e2 - n2);
4059
4059
  let r2 = T(a2);
4060
- a2 - r2 > 0.9999 && (r2 += 1, r2 === N2 && (r2 = 0, n2 += 1));
4061
- const i2 = r2 < 0 ? N2 + r2 : r2, [s2, o2, l2] = Y(e2, 0, t2 && t2.leap1900), d2 = T(i2 / 60 / 60) % 60, m2 = T(i2 / 60) % 60, u2 = T(i2) % 60;
4060
+ a2 - r2 > 0.9999 && (r2 += 1, r2 === N && (r2 = 0, n2 += 1));
4061
+ const i2 = r2 < 0 ? N + r2 : r2, [s2, o2, l2] = Y(e2, 0, t2 && t2.leap1900), d2 = T(i2 / 60 / 60) % 60, m2 = T(i2 / 60) % 60, u2 = T(i2) % 60;
4062
4062
  if (t2 && t2.nativeDate) {
4063
4063
  const e3 = /* @__PURE__ */ new Date(0);
4064
4064
  return e3.setUTCFullYear(s2, o2 - 1, l2), e3.setUTCHours(d2, m2, u2), e3;
@@ -4450,13 +4450,13 @@ var numfmt$1 = { exports: {} };
4450
4450
  }
4451
4451
  const i3 = q(e4, t4);
4452
4452
  return i3 ? K(e4, i3, n4, a3) : n4.overflow;
4453
- }(P2(e3, n3), a2, n3);
4453
+ }(P(e3, n3), a2, n3);
4454
4454
  }, "s");
4455
4455
  s2.color = (e3, t3) => function(e4, t4) {
4456
4456
  if (typeof e4 != "number" || !isFinite(e4)) return (t4[3] ? t4[3].color : V.color) || Q;
4457
4457
  const n3 = q(e4, t4);
4458
4458
  return n3 && n3.color || Q;
4459
- }(P2(e3, i2(t3)), a2);
4459
+ }(P(e3, i2(t3)), a2);
4460
4460
  const o2 = function(e3) {
4461
4461
  var t3;
4462
4462
  let n3 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : null;
@@ -4493,13 +4493,13 @@ var numfmt$1 = { exports: {} };
4493
4493
  }
4494
4494
  }(e2), n2.error || (me[e2] = n2)), ue(n2, t2);
4495
4495
  }
4496
- __name(ce, "ce"), ce.isDate = (e2) => ce(e2, { throws: !1 }).isDate(), ce.isPercent = (e2) => ce(e2, { throws: !1 }).isPercent(), ce.isText = (e2) => ce(e2, { throws: !1 }).isText(), ce.getInfo = (e2, t2) => ce(e2, { ...t2, throws: !1 }).info, ce.getDateInfo = (e2, t2) => ce(e2, { ...t2, throws: !1 }).dateInfo, ce.dateToSerial = P2, ce.dateFromSerial = I2, ce.options = h, ce.dec2frac = p, ce.round = c, ce.codeToLocale = n, ce.parseLocale = s, ce.getLocale = l, ce.addLocale = (e2, t2) => {
4496
+ __name(ce, "ce"), ce.isDate = (e2) => ce(e2, { throws: !1 }).isDate(), ce.isPercent = (e2) => ce(e2, { throws: !1 }).isPercent(), ce.isText = (e2) => ce(e2, { throws: !1 }).isText(), ce.getInfo = (e2, t2) => ce(e2, { ...t2, throws: !1 }).info, ce.getDateInfo = (e2, t2) => ce(e2, { ...t2, throws: !1 }).dateInfo, ce.dateToSerial = P, ce.dateFromSerial = I2, ce.options = h, ce.dec2frac = p, ce.round = c, ce.codeToLocale = n, ce.parseLocale = s, ce.getLocale = l, ce.addLocale = (e2, t2) => {
4497
4497
  const n2 = s(t2);
4498
4498
  return delete me[n2.lang], delete me[n2.language], m(e2, n2);
4499
4499
  }, ce.format = function(e2, t2, n2) {
4500
4500
  let a2 = arguments.length > 3 && arguments[3] !== void 0 && arguments[3];
4501
4501
  const r2 = n2 && typeof n2 == "object" ? n2 : { locale: n2, throws: !a2 };
4502
- return ce(e2, r2)(P2(t2, r2), r2);
4502
+ return ce(e2, r2)(P(t2, r2), r2);
4503
4503
  }, ce.is_date = ce.isDate, ce.parseNumber = ie, ce.parseDate = oe, ce.parseTime = le, ce.parseBool = de, ce.parseValue = function(e2, t2) {
4504
4504
  var n2, a2, r2;
4505
4505
  return (n2 = (a2 = (r2 = ie(e2)) !== null && r2 !== void 0 ? r2 : oe(e2, t2)) !== null && a2 !== void 0 ? a2 : le(e2)) !== null && n2 !== void 0 ? n2 : de(e2);
@@ -4508,9 +4508,9 @@ var numfmt$1 = { exports: {} };
4508
4508
  return t = t.default;
4509
4509
  }();
4510
4510
  });
4511
- })(numfmt$1);
4512
- var numfmtExports = numfmt$1.exports, numfmt = numfmtExports;
4513
- const index$2 = /* @__PURE__ */ getDefaultExportFromCjs(numfmt), DEFAULT_RANGE_ARRAY = {
4511
+ })(numfmt$2);
4512
+ var numfmtExports = numfmt$2.exports, numfmt$1 = numfmtExports;
4513
+ const _numfmt = /* @__PURE__ */ getDefaultExportFromCjs(numfmt$1), numfmt = _numfmt, DEFAULT_RANGE_ARRAY = {
4514
4514
  sheetId: "",
4515
4515
  range: {
4516
4516
  startRow: -1,
@@ -4626,7 +4626,7 @@ const index$2 = /* @__PURE__ */ getDefaultExportFromCjs(numfmt), DEFAULT_RANGE_A
4626
4626
  width: 300,
4627
4627
  height: 300
4628
4628
  }
4629
- };
4629
+ }, UNIVER_INTERNAL = "__univer_internal__";
4630
4630
  var EXTENSION_NAMES = /* @__PURE__ */ ((EXTENSION_NAMES2) => (EXTENSION_NAMES2.ARRAY_CONVERTOR = "ARRAY_CONVERTOR", EXTENSION_NAMES2.MATRIX_CONVERTOR = "MATRIX_CONVERTOR", EXTENSION_NAMES2))(EXTENSION_NAMES || {});
4631
4631
  function isAllFormatInTextRuns(key, body) {
4632
4632
  const { textRuns = [] } = body;
@@ -6324,8 +6324,7 @@ const ICommandService = createIdentifier("anywhere.command-service"), _CommandRe
6324
6324
  if (this._commands.has(command.id))
6325
6325
  throw new Error(`[CommandRegistry]: command "${command.id}" has been registered before.`);
6326
6326
  return this._commands.set(command.id, command), this._commandTypes.set(command.id, command.type), toDisposable(() => {
6327
- var _a13;
6328
- this._commands.delete(command.id), this._commandTypes.delete(command.id), (_a13 = command.onDispose) == null || _a13.call(command);
6327
+ this._commands.delete(command.id), this._commandTypes.delete(command.id);
6329
6328
  });
6330
6329
  }
6331
6330
  hasCommand(id) {
@@ -6516,9 +6515,8 @@ const _MultiCommand = class _MultiCommand {
6516
6515
  registerImplementation(implementation) {
6517
6516
  const registry = { command: implementation };
6518
6517
  return this._implementations.push(registry), this._implementations.sort((a, b) => b.command.priority - a.command.priority), toDisposable(() => {
6519
- var _a13;
6520
6518
  const index2 = this._implementations.indexOf(registry);
6521
- this._implementations.splice(index2, 1), (_a13 = implementation.onDispose) == null || _a13.call(implementation);
6519
+ this._implementations.splice(index2, 1);
6522
6520
  });
6523
6521
  }
6524
6522
  hasImplementations() {
@@ -6564,12 +6562,7 @@ const afterInitApply = /* @__PURE__ */ __name((commandService) => new Promise((r
6564
6562
  res();
6565
6563
  });
6566
6564
  }), "afterInitApply");
6567
- var N = /* @__PURE__ */ ((E) => (E[E.UNDEFINED = 0] = "UNDEFINED", E[E.OK = 1] = "OK", E[E.INTERNAL_ERROR = 2] = "INTERNAL_ERROR", E[E.PERMISSION_DENIED = 3] = "PERMISSION_DENIED", E[E.NOT_FOUND = 4] = "NOT_FOUND", E[E.UNAUTHENTICATED = 5] = "UNAUTHENTICATED", E[E.ALREADY_EXISTS = 6] = "ALREADY_EXISTS", E[E.INVALID_ARGUMENT = 7] = "INVALID_ARGUMENT", E[E.TOO_MANY_REQUESTS = 8] = "TOO_MANY_REQUESTS", E[E.COMPLETION_FINISHED = 9] = "COMPLETION_FINISHED", E[E.CHANGESET_REVISION_CONFILICT = 5001] = "CHANGESET_REVISION_CONFILICT", E[E.SNAPSHOT_INVALID_SNAPSHOT = 6001] = "SNAPSHOT_INVALID_SNAPSHOT", E[E.SNAPSHOT_HAS_BEEN_REMOVED = 6002] = "SNAPSHOT_HAS_BEEN_REMOVED", E[E.APPLY_REJECT = 7001] = "APPLY_REJECT", E[E.APPLY_NON_SEQUENTIAL_REVISION = 7002] = "APPLY_NON_SEQUENTIAL_REVISION", E[E.APPLY_REVISION_CONFILICT = 7003] = "APPLY_REVISION_CONFILICT", E[E.APPLY_PERMISSION_DENIED = 7004] = "APPLY_PERMISSION_DENIED", E[E.CONNECTOR_DATA_TOO_LARGE = 8001] = "CONNECTOR_DATA_TOO_LARGE", E[E.LICENSE_MAX_UNITS_EXCEEDED = 9001] = "LICENSE_MAX_UNITS_EXCEEDED", E[E.LICENSE_MAX_MEMBERS_PER_UNIT_EXCEEDED = 9002] = "LICENSE_MAX_MEMBERS_PER_UNIT_EXCEEDED", E[E.LICENSE_IMPORT_SIZE_EXCEEDED = 9003] = "LICENSE_IMPORT_SIZE_EXCEEDED", E[E.LICENSE_EXPORT_SIZE_EXCEEDED = 9004] = "LICENSE_EXPORT_SIZE_EXCEEDED", E[E.LICENSE_DISTRO_REJECTED = 9005] = "LICENSE_DISTRO_REJECTED", E[E.YUUMI_UNABLE_LOAD_URL = 10001] = "YUUMI_UNABLE_LOAD_URL", E[E.YUUMI_URL_COL_OUT_OF_RANGE = 10002] = "YUUMI_URL_COL_OUT_OF_RANGE", E[E.YUUMI_RATE_OVER_LIMIT = 10003] = "YUUMI_RATE_OVER_LIMIT", E[E.YUUMI_SUBSCRIPTION_NOT_FOUND = 10004] = "YUUMI_SUBSCRIPTION_NOT_FOUND", E[E.UNRECOGNIZED = -1] = "UNRECOGNIZED", E))(N || {});
6568
- function H(E) {
6569
- return !!(E && E.code && E.code !== N.OK && E.code !== "OK");
6570
- }
6571
- __name(H, "H");
6572
- var I = /* @__PURE__ */ ((E) => (E[E.UNIVER_UNKNOWN = 0] = "UNIVER_UNKNOWN", E[E.UNIVER_DOC = 1] = "UNIVER_DOC", E[E.UNIVER_SHEET = 2] = "UNIVER_SHEET", E[E.UNIVER_SLIDE = 3] = "UNIVER_SLIDE", E[E.UNIVER_PROJECT = 4] = "UNIVER_PROJECT", E[E.UNRECOGNIZED = -1] = "UNRECOGNIZED", E))(I || {}), P = /* @__PURE__ */ ((E) => (E[E.Reader = 0] = "Reader", E[E.Editor = 1] = "Editor", E[E.Owner = 2] = "Owner", E[E.UNRECOGNIZED = -1] = "UNRECOGNIZED", E))(P || {}), G = /* @__PURE__ */ ((E) => (E[E.SomeCollaborator = 0] = "SomeCollaborator", E[E.AllCollaborator = 1] = "AllCollaborator", E[E.OneSelf = 2] = "OneSelf", E[E.UNRECOGNIZED = -1] = "UNRECOGNIZED", E))(G || {});
6565
+ var I = /* @__PURE__ */ ((E) => (E[E.UNIVER_UNKNOWN = 0] = "UNIVER_UNKNOWN", E[E.UNIVER_DOC = 1] = "UNIVER_DOC", E[E.UNIVER_SHEET = 2] = "UNIVER_SHEET", E[E.UNIVER_SLIDE = 3] = "UNIVER_SLIDE", E[E.UNIVER_PROJECT = 4] = "UNIVER_PROJECT", E[E.UNRECOGNIZED = -1] = "UNRECOGNIZED", E))(I || {}), G = /* @__PURE__ */ ((E) => (E[E.Reader = 0] = "Reader", E[E.Editor = 1] = "Editor", E[E.Owner = 2] = "Owner", E[E.UNRECOGNIZED = -1] = "UNRECOGNIZED", E))(G || {}), H = /* @__PURE__ */ ((E) => (E[E.SomeCollaborator = 0] = "SomeCollaborator", E[E.AllCollaborator = 1] = "AllCollaborator", E[E.OneSelf = 2] = "OneSelf", E[E.UNRECOGNIZED = -1] = "UNRECOGNIZED", E))(H || {});
6573
6566
  const _UnitModel = class _UnitModel extends Disposable {
6574
6567
  };
6575
6568
  __name(_UnitModel, "UnitModel");
@@ -7060,14 +7053,16 @@ function deleteTextRuns(body, textLength, currentIndex) {
7060
7053
  const newTextRuns = [];
7061
7054
  for (let i = 0, len = textRuns.length; i < len; i++) {
7062
7055
  const textRun = textRuns[i], { st, ed } = textRun;
7063
- if (startIndex <= st && endIndex >= ed) {
7064
- removeTextRuns.push({
7056
+ if (startIndex <= st && endIndex >= ed)
7057
+ if (removeTextRuns.push({
7065
7058
  ...textRun,
7066
7059
  st: st - startIndex,
7067
7060
  ed: ed - startIndex
7068
- });
7069
- continue;
7070
- } else st <= startIndex && ed >= endIndex ? (removeTextRuns.push({
7061
+ }), startIndex === st)
7062
+ textRun.ed = st;
7063
+ else
7064
+ continue;
7065
+ else st <= startIndex && ed >= endIndex ? (removeTextRuns.push({
7071
7066
  ...textRun,
7072
7067
  st: startIndex - startIndex,
7073
7068
  ed: endIndex - startIndex
@@ -10690,7 +10685,7 @@ function extractPureTextFromCell(cell) {
10690
10685
  return typeof rawValue == "string" ? cell.t === CellValueType.BOOLEAN ? rawValue.toUpperCase() : rawValue.replace(/[\r\n]/g, "") : typeof rawValue == "number" ? cell.t === CellValueType.BOOLEAN ? rawValue ? "TRUE" : "FALSE" : rawValue.toString() : typeof rawValue == "boolean" ? rawValue ? "TRUE" : "FALSE" : "";
10691
10686
  }
10692
10687
  __name(extractPureTextFromCell, "extractPureTextFromCell");
10693
- const version = "0.2.9";
10688
+ const version = "0.2.10";
10694
10689
  function getEmptySnapshot(unitID = "", locale = LocaleType.ZH_CN, name = "") {
10695
10690
  return {
10696
10691
  id: unitID,
@@ -11222,13 +11217,9 @@ let LifecycleService = (_a5 = class extends Disposable {
11222
11217
  return this._lifecycle$.getValue();
11223
11218
  }
11224
11219
  set stage(stage) {
11225
- if (stage < this.stage)
11226
- throw new Error("[LifecycleService]: lifecycle stage cannot go backward!");
11227
- if (stage !== this.stage) {
11228
- if (this._lock)
11229
- throw new Error("[LifecycleService]: cannot set new stage when related logic is all handled!");
11230
- this._lock = !0, this._reportProgress(stage), this._lifecycle$.next(stage), this._lock = !1;
11231
- }
11220
+ if (this._lock) throw new Error("[LifecycleService]: cannot set new stage when related logic is all handled!");
11221
+ if (stage < this.stage) throw new Error("[LifecycleService]: lifecycle stage cannot go backward!");
11222
+ stage !== this.stage && (this._lock = !0, this._reportProgress(stage), this._lifecycle$.next(stage), this._lock = !1);
11232
11223
  }
11233
11224
  dispose() {
11234
11225
  this._lifecycle$.complete(), super.dispose();
@@ -11993,10 +11984,10 @@ function mergeOverrideWithDependencies(dependencies, override) {
11993
11984
  }
11994
11985
  __name(mergeOverrideWithDependencies, "mergeOverrideWithDependencies");
11995
11986
  const nameMap = {
11996
- [P.Editor]: "Editor",
11997
- [P.Owner]: "Owner",
11998
- [P.Reader]: "Reader",
11999
- [P.UNRECOGNIZED]: "UNRECOGNIZED"
11987
+ [G.Editor]: "Editor",
11988
+ [G.Owner]: "Owner",
11989
+ [G.Reader]: "Reader",
11990
+ [G.UNRECOGNIZED]: "UNRECOGNIZED"
12000
11991
  }, createDefaultUser = /* @__PURE__ */ __name((type2) => type2 ? {
12001
11992
  userID: `${nameMap[type2]}_${Tools.generateRandomId(8)}`,
12002
11993
  name: nameMap[type2],
@@ -12067,7 +12058,7 @@ let AuthzIoLocalService = (_a12 = class {
12067
12058
  }
12068
12059
  _initDefaultUser() {
12069
12060
  const currentUser = this._userManagerService.getCurrentUser();
12070
- currentUser && currentUser.userID || this._userManagerService.setCurrentUser(createDefaultUser(P.Owner));
12061
+ currentUser && currentUser.userID || this._userManagerService.setCurrentUser(createDefaultUser(G.Owner));
12071
12062
  }
12072
12063
  _getRole(type2) {
12073
12064
  const user = this._userManagerService.getCurrentUser();
@@ -12115,13 +12106,13 @@ let AuthzIoLocalService = (_a12 = class {
12115
12106
  objectType: rule.objectType,
12116
12107
  name: rule.name,
12117
12108
  shareOn: !1,
12118
- shareRole: P.Owner,
12109
+ shareRole: G.Owner,
12119
12110
  shareScope: -1,
12120
12111
  scope: {
12121
- read: G.AllCollaborator,
12122
- edit: G.AllCollaborator
12112
+ read: H.AllCollaborator,
12113
+ edit: H.AllCollaborator
12123
12114
  },
12124
- creator: createDefaultUser(P.Owner),
12115
+ creator: createDefaultUser(G.Owner),
12125
12116
  strategies: [
12126
12117
  {
12127
12118
  action: 6,
@@ -12176,7 +12167,7 @@ let AuthzIoLocalService = (_a12 = class {
12176
12167
  role: 1
12177
12168
  }
12178
12169
  ],
12179
- actions: config.actions.map((a) => ({ action: a, allowed: this._getRole(P.Owner) || this._getRole(P.Editor) }))
12170
+ actions: config.actions.map((a) => ({ action: a, allowed: this._getRole(G.Owner) || this._getRole(G.Editor) }))
12180
12171
  };
12181
12172
  result.push(item);
12182
12173
  }
@@ -12522,447 +12513,7 @@ let InterceptorManager = _InterceptorManager;
12522
12513
  const isRangesEqual = /* @__PURE__ */ __name((oldRanges, ranges) => ranges.length === oldRanges.length && !oldRanges.some((oldRange) => ranges.some((range) => !Rectangle.equals(range, oldRange))), "isRangesEqual"), isUnitRangesEqual = /* @__PURE__ */ __name((oldRanges, ranges) => ranges.length === oldRanges.length && oldRanges.every((oldRange, i) => {
12523
12514
  const current = ranges[i];
12524
12515
  return current.unitId === oldRange.unitId && current.sheetId === oldRange.sheetId && Rectangle.equals(oldRange.range, current.range);
12525
- }), "isUnitRangesEqual"), ISnapshotServerService = createIdentifier(
12526
- "univer.snapshot-server-service"
12527
- ), _ClientSnapshotServerService = class _ClientSnapshotServerService {
12528
- constructor() {
12529
- __publicField(this, "_sheetBlockCache", /* @__PURE__ */ new Map());
12530
- }
12531
- /** Load snapshot from a database. */
12532
- getUnitOnRev(context, params) {
12533
- return Promise.resolve({
12534
- snapshot: {
12535
- unitID: "",
12536
- type: I.UNIVER_SHEET,
12537
- rev: 0,
12538
- workbook: void 0,
12539
- doc: void 0
12540
- },
12541
- changesets: [],
12542
- error: {
12543
- code: N.OK,
12544
- message: ""
12545
- }
12546
- });
12547
- }
12548
- /** Load sheet block from a database. */
12549
- getSheetBlock(context, params) {
12550
- const block = this._sheetBlockCache.get(params.blockID);
12551
- return Promise.resolve({
12552
- block,
12553
- error: {
12554
- code: N.OK,
12555
- message: ""
12556
- }
12557
- });
12558
- }
12559
- /** Fetch missing changeset */
12560
- fetchMissingChangesets(context, params) {
12561
- return Promise.resolve({
12562
- changesets: [],
12563
- error: {
12564
- code: N.OK,
12565
- message: ""
12566
- }
12567
- });
12568
- }
12569
- getResourcesRequest(context, params) {
12570
- return Promise.resolve({
12571
- resources: {},
12572
- error: {
12573
- code: N.OK,
12574
- message: ""
12575
- }
12576
- });
12577
- }
12578
- /** Save snapshot to a database. */
12579
- saveSnapshot(context, params) {
12580
- return Promise.resolve({
12581
- error: {
12582
- code: N.OK,
12583
- message: ""
12584
- }
12585
- });
12586
- }
12587
- /** Save sheet block to a database. */
12588
- saveSheetBlock(context, params) {
12589
- const { block } = params;
12590
- return block ? (this._sheetBlockCache.set(block.id, block), Promise.resolve({
12591
- error: {
12592
- code: N.OK,
12593
- message: ""
12594
- },
12595
- blockID: block.id
12596
- })) : Promise.resolve({
12597
- error: {
12598
- code: N.UNDEFINED,
12599
- message: "block is required"
12600
- },
12601
- blockID: ""
12602
- });
12603
- }
12604
- /** Save changeset to a database. */
12605
- saveChangeset(context, params) {
12606
- return Promise.resolve({
12607
- error: {
12608
- code: N.OK,
12609
- message: ""
12610
- },
12611
- concurrent: []
12612
- });
12613
- }
12614
- };
12615
- __name(_ClientSnapshotServerService, "ClientSnapshotServerService");
12616
- let ClientSnapshotServerService = _ClientSnapshotServerService;
12617
- function b64EncodeUnicode(str) {
12618
- return btoa(
12619
- encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, (match, p1) => String.fromCharCode(Number.parseInt(p1, 16)))
12620
- );
12621
- }
12622
- __name(b64EncodeUnicode, "b64EncodeUnicode");
12623
- function b64DecodeUnicode(str) {
12624
- return decodeURIComponent(
12625
- Array.prototype.map.call(atob(str), (c) => `%${`00${c.charCodeAt(0).toString(16)}`.slice(-2)}`).join("")
12626
- );
12627
- }
12628
- __name(b64DecodeUnicode, "b64DecodeUnicode");
12629
- const textEncoder = new TextEncoder(), textDecoder = new TextDecoder();
12630
- function encodeWorksheetOtherMetas(worksheet) {
12631
- const cloned = Tools.deepClone(worksheet);
12632
- return delete cloned.id, delete cloned.name, delete cloned.rowCount, delete cloned.columnCount, delete cloned.cellData, textEncoder.encode(JSON.stringify(cloned));
12633
- }
12634
- __name(encodeWorksheetOtherMetas, "encodeWorksheetOtherMetas");
12635
- function encodeWorkbookOtherMetas(workbook) {
12636
- const cloned = Tools.deepClone(workbook);
12637
- return delete cloned.id, delete cloned.rev, delete cloned.name, delete cloned.sheetOrder, delete cloned.sheets, textEncoder.encode(JSON.stringify(cloned));
12638
- }
12639
- __name(encodeWorkbookOtherMetas, "encodeWorkbookOtherMetas");
12640
- function encodeDocOriginalMeta(document2) {
12641
- const cloned = Tools.deepClone(document2);
12642
- return delete cloned.id, delete cloned.rev, delete cloned.title, delete cloned.resources, textEncoder.encode(JSON.stringify(cloned));
12643
- }
12644
- __name(encodeDocOriginalMeta, "encodeDocOriginalMeta");
12645
- function decodeWorksheetOtherMetas(buffer) {
12646
- return JSON.parse(typeof buffer == "string" ? b64DecodeUnicode(buffer) : textDecoder.decode(buffer));
12647
- }
12648
- __name(decodeWorksheetOtherMetas, "decodeWorksheetOtherMetas");
12649
- function decodePartOfCellData(buffer) {
12650
- return JSON.parse(typeof buffer == "string" ? b64DecodeUnicode(buffer) : textDecoder.decode(buffer));
12651
- }
12652
- __name(decodePartOfCellData, "decodePartOfCellData");
12653
- function decodeDocOriginalMeta(buffer) {
12654
- return JSON.parse(typeof buffer == "string" ? b64DecodeUnicode(buffer) : textDecoder.decode(buffer));
12655
- }
12656
- __name(decodeDocOriginalMeta, "decodeDocOriginalMeta");
12657
- const FRAGMENT_ROW_COUNT = 256 * 20;
12658
- function splitCellDataToBlocks(cellData, maxColumn) {
12659
- const utilObjectMatrix = new ObjectMatrix(cellData), length = utilObjectMatrix.getLength(), blocks = [];
12660
- let i = 0;
12661
- for (; i < length; ) {
12662
- const endRow = Math.min(i + FRAGMENT_ROW_COUNT, length - 1), slice = utilObjectMatrix.getSlice(i, Math.min(i + FRAGMENT_ROW_COUNT, length - 1), 0, maxColumn), data = serializeCellDataSlice(slice);
12663
- blocks.push({
12664
- id: Tools.generateRandomId(19, "0123456789"),
12665
- // an random ID for client, this would be changed after the block is saved in the server
12666
- startRow: i,
12667
- endRow,
12668
- data
12669
- }), i += FRAGMENT_ROW_COUNT;
12670
- }
12671
- return blocks;
12672
- }
12673
- __name(splitCellDataToBlocks, "splitCellDataToBlocks");
12674
- function serializeCellDataSlice(slice) {
12675
- const data = slice.getData();
12676
- return textEncoder.encode(JSON.stringify(data));
12677
- }
12678
- __name(serializeCellDataSlice, "serializeCellDataSlice");
12679
- async function generateTempDocumentSnapshot(_context, document2, unitID, rev) {
12680
- var _a13;
12681
- const documentMeta = {
12682
- unitID: document2.id,
12683
- rev,
12684
- creator: "",
12685
- name: (_a13 = document2.title) != null ? _a13 : "",
12686
- resources: document2.resources || [],
12687
- originalMeta: encodeDocOriginalMeta(document2)
12688
- };
12689
- return {
12690
- snapshot: {
12691
- unitID,
12692
- rev: documentMeta.rev,
12693
- type: I.UNIVER_DOC,
12694
- workbook: void 0,
12695
- doc: documentMeta
12696
- }
12697
- };
12698
- }
12699
- __name(generateTempDocumentSnapshot, "generateTempDocumentSnapshot");
12700
- async function generateTemporarySnap(context, workbook, unitID, rev, snapshotService) {
12701
- const blockMeta = {}, sheetMetas = {};
12702
- if (!await Promise.all(
12703
- Object.entries(workbook.sheets).map(async ([sheetID, worksheet]) => {
12704
- const sheetMeta = {
12705
- id: worksheet.id,
12706
- type: SheetTypes.GRID,
12707
- name: worksheet.name,
12708
- rowCount: worksheet.rowCount,
12709
- columnCount: worksheet.columnCount,
12710
- originalMeta: encodeWorksheetOtherMetas(worksheet)
12711
- };
12712
- if (sheetMetas[sheetID] = sheetMeta, worksheet.cellData) {
12713
- const sheetBlocks = splitCellDataToBlocks(worksheet.cellData, worksheet.columnCount), responses = await Promise.all(
12714
- sheetBlocks.map(
12715
- (block) => snapshotService.saveSheetBlock(context, {
12716
- unitID,
12717
- type: I.UNIVER_SHEET,
12718
- block
12719
- })
12720
- )
12721
- );
12722
- if (responses.some((response) => {
12723
- var _a13;
12724
- return ((_a13 = response.error) == null ? void 0 : _a13.code) !== N.OK;
12725
- }))
12726
- return !1;
12727
- blockMeta[sheetID] = {
12728
- sheetID,
12729
- blocks: responses.map((response) => response.blockID)
12730
- };
12731
- }
12732
- return !0;
12733
- })
12734
- ))
12735
- throw new Error("[transformWorkbookDataToSnapshot()]: Failed to save sheet blocks.");
12736
- const originalMeta = encodeWorkbookOtherMetas(workbook), workbookMeta = {
12737
- unitID: workbook.id,
12738
- rev,
12739
- creator: "",
12740
- name: workbook.name,
12741
- sheetOrder: workbook.sheetOrder,
12742
- sheets: sheetMetas,
12743
- blockMeta,
12744
- // this should not be empty
12745
- resources: workbook.resources || [],
12746
- originalMeta
12747
- };
12748
- return {
12749
- snapshotRes: {
12750
- unitID,
12751
- rev: workbookMeta.rev,
12752
- type: I.UNIVER_SHEET,
12753
- workbook: workbookMeta,
12754
- doc: void 0
12755
- }
12756
- };
12757
- }
12758
- __name(generateTemporarySnap, "generateTemporarySnap");
12759
- async function transformWorkbookDataToSnapshot(context, workbook, unitID, rev, snapshotService) {
12760
- var _a13, _b2;
12761
- const blockMeta = {}, sheetMetas = {};
12762
- if (!await Promise.all(
12763
- Object.entries(workbook.sheets).map(async ([sheetID, worksheet]) => {
12764
- const sheetMeta = {
12765
- id: worksheet.id,
12766
- type: SheetTypes.GRID,
12767
- name: worksheet.name,
12768
- rowCount: worksheet.rowCount,
12769
- columnCount: worksheet.columnCount,
12770
- originalMeta: encodeWorksheetOtherMetas(worksheet)
12771
- };
12772
- if (sheetMetas[sheetID] = sheetMeta, worksheet.cellData) {
12773
- const sheetBlocks = splitCellDataToBlocks(worksheet.cellData, worksheet.columnCount), responses = await Promise.all(
12774
- sheetBlocks.map(
12775
- (block) => snapshotService.saveSheetBlock(context, {
12776
- unitID,
12777
- type: I.UNIVER_SHEET,
12778
- block
12779
- })
12780
- )
12781
- );
12782
- if (responses.some((response) => {
12783
- var _a14;
12784
- return ((_a14 = response.error) == null ? void 0 : _a14.code) !== N.OK;
12785
- }))
12786
- return !1;
12787
- blockMeta[sheetID] = {
12788
- sheetID,
12789
- blocks: responses.map((response) => response.blockID)
12790
- };
12791
- }
12792
- return !0;
12793
- })
12794
- ))
12795
- throw new Error("[transformWorkbookDataToSnapshot()]: Failed to save sheet blocks.");
12796
- const originalMeta = encodeWorkbookOtherMetas(workbook), workbookMeta = {
12797
- unitID: workbook.id,
12798
- rev,
12799
- creator: "",
12800
- name: workbook.name,
12801
- sheetOrder: workbook.sheetOrder,
12802
- sheets: sheetMetas,
12803
- blockMeta,
12804
- // this should not be empty
12805
- resources: workbook.resources || [],
12806
- originalMeta
12807
- }, snapshot = {
12808
- unitID,
12809
- rev: workbookMeta.rev,
12810
- type: I.UNIVER_SHEET,
12811
- workbook: workbookMeta,
12812
- doc: void 0
12813
- }, saveResult = await snapshotService.saveSnapshot(context, {
12814
- unitID,
12815
- type: I.UNIVER_SHEET,
12816
- snapshot
12817
- });
12818
- if (H(saveResult.error))
12819
- throw new Error(
12820
- `transformWorkbookDataToSnapshot(): Failed to save snapshot.
12821
- ErrorCode: ${(_a13 = saveResult.error) == null ? void 0 : _a13.code}:${(_b2 = saveResult.error) == null ? void 0 : _b2.message}`
12822
- );
12823
- return {
12824
- snapshot
12825
- };
12826
- }
12827
- __name(transformWorkbookDataToSnapshot, "transformWorkbookDataToSnapshot");
12828
- function transformSnapshotToWorkbookData(snapshot, sheetBlocks, _context) {
12829
- const workbookMeta = snapshot.workbook;
12830
- if (!workbookMeta)
12831
- throw new Error("");
12832
- const sheetMap = {};
12833
- Object.entries(workbookMeta.sheets).forEach(([sheetID, sheetMeta]) => {
12834
- const otherMeta2 = decodeWorksheetOtherMetas(sheetMeta.originalMeta);
12835
- sheetMap[sheetID] = {
12836
- id: sheetMeta.id,
12837
- name: sheetMeta.name,
12838
- rowCount: sheetMeta.rowCount,
12839
- columnCount: sheetMeta.columnCount,
12840
- ...otherMeta2
12841
- };
12842
- });
12843
- const sheetBlocksMap = /* @__PURE__ */ new Map();
12844
- sheetBlocks.forEach((block) => {
12845
- sheetBlocksMap.set(block.id, block);
12846
- }), workbookMeta.blockMeta && Object.entries(workbookMeta.blockMeta).forEach(([sheetID, blocksOfSheet]) => {
12847
- var _a13;
12848
- const worksheetConfig = sheetMap[sheetID];
12849
- worksheetConfig.cellData = {};
12850
- const blocks = [];
12851
- (_a13 = blocksOfSheet.blocks) == null || _a13.forEach((blockID) => {
12852
- const block = sheetBlocksMap.get(blockID);
12853
- if (block)
12854
- blocks.push(block);
12855
- else
12856
- throw new Error("");
12857
- }), blocks.forEach((block) => {
12858
- const partOfCellData = decodePartOfCellData(block.data);
12859
- Object.entries(partOfCellData).forEach(([rowNumber, rowData]) => {
12860
- const row = worksheetConfig.cellData[+rowNumber] = {};
12861
- Object.entries(rowData).forEach(([columnNumber, cellData]) => {
12862
- row[+columnNumber] = cellData;
12863
- });
12864
- });
12865
- });
12866
- });
12867
- const otherMeta = decodeWorksheetOtherMetas(workbookMeta.originalMeta);
12868
- return {
12869
- id: snapshot.unitID || workbookMeta.unitID,
12870
- rev: snapshot.rev || workbookMeta.rev,
12871
- name: workbookMeta.name,
12872
- sheetOrder: workbookMeta.sheetOrder,
12873
- appVersion: "",
12874
- locale: LocaleType.EN_US,
12875
- sheets: sheetMap,
12876
- styles: {},
12877
- resources: workbookMeta.resources || [],
12878
- ...otherMeta
12879
- };
12880
- }
12881
- __name(transformSnapshotToWorkbookData, "transformSnapshotToWorkbookData");
12882
- function transformSnapshotToDocumentData(snapshot) {
12883
- const documentMeta = snapshot.doc;
12884
- if (documentMeta == null)
12885
- throw new Error("transformSnapshotToDocumentData(): snapshot.doc is undefined.");
12886
- const { unitID, rev, name, originalMeta, resources = [] } = documentMeta, {
12887
- body,
12888
- documentStyle = {},
12889
- settings = {},
12890
- drawings = {},
12891
- drawingsOrder = [],
12892
- tableSource = {},
12893
- headers = {},
12894
- footers = {},
12895
- lists = {}
12896
- } = decodeDocOriginalMeta(originalMeta);
12897
- return {
12898
- id: unitID,
12899
- rev,
12900
- locale: LocaleType.EN_US,
12901
- title: name,
12902
- body,
12903
- documentStyle,
12904
- settings,
12905
- drawings,
12906
- drawingsOrder,
12907
- resources,
12908
- tableSource,
12909
- headers,
12910
- footers,
12911
- lists
12912
- };
12913
- }
12914
- __name(transformSnapshotToDocumentData, "transformSnapshotToDocumentData");
12915
- async function transformDocumentDataToSnapshot(context, document2, unitID, rev, snapshotService) {
12916
- var _a13, _b2, _c;
12917
- const documentMeta = {
12918
- unitID: document2.id,
12919
- rev,
12920
- creator: "",
12921
- name: (_a13 = document2.title) != null ? _a13 : "",
12922
- resources: document2.resources || [],
12923
- originalMeta: encodeDocOriginalMeta(document2)
12924
- }, snapshot = {
12925
- unitID,
12926
- rev: documentMeta.rev,
12927
- type: I.UNIVER_DOC,
12928
- workbook: void 0,
12929
- doc: documentMeta
12930
- }, saveResult = await snapshotService.saveSnapshot(context, {
12931
- unitID,
12932
- type: I.UNIVER_DOC,
12933
- snapshot
12934
- });
12935
- if (H(saveResult.error))
12936
- throw new Error(
12937
- `transformDocumentDataToSnapshot(): Failed to save snapshot.
12938
- ErrorCode: ${(_b2 = saveResult.error) == null ? void 0 : _b2.code}:${(_c = saveResult.error) == null ? void 0 : _c.message}`
12939
- );
12940
- return {
12941
- snapshot
12942
- };
12943
- }
12944
- __name(transformDocumentDataToSnapshot, "transformDocumentDataToSnapshot");
12945
- async function getSheetBlocksFromSnapshot(snapshot, snapshotService) {
12946
- const workbookMeta = snapshot.workbook;
12947
- if (!workbookMeta)
12948
- throw new Error("Workbook metadata is not available");
12949
- const blocks = [], promises = [];
12950
- return Object.entries(workbookMeta.blockMeta).forEach(([_, blocksOfSheet]) => {
12951
- const blockPromises = blocksOfSheet.blocks.map(async (blockID) => {
12952
- const params = {
12953
- unitID: workbookMeta.unitID,
12954
- type: I.UNIVER_SHEET,
12955
- blockID
12956
- }, { block } = await snapshotService.getSheetBlock({}, params);
12957
- if (block)
12958
- blocks.push(block);
12959
- else
12960
- throw new Error("Block not found");
12961
- });
12962
- promises.push(...blockPromises);
12963
- }), await Promise.all(promises), blocks;
12964
- }
12965
- __name(getSheetBlocksFromSnapshot, "getSheetBlocksFromSnapshot");
12516
+ }), "isUnitRangesEqual");
12966
12517
  var DataValidationErrorStyle = /* @__PURE__ */ ((DataValidationErrorStyle2) => (DataValidationErrorStyle2[DataValidationErrorStyle2.INFO = 0] = "INFO", DataValidationErrorStyle2[DataValidationErrorStyle2.STOP = 1] = "STOP", DataValidationErrorStyle2[DataValidationErrorStyle2.WARNING = 2] = "WARNING", DataValidationErrorStyle2))(DataValidationErrorStyle || {}), DataValidationImeMode = /* @__PURE__ */ ((DataValidationImeMode2) => (DataValidationImeMode2[DataValidationImeMode2.DISABLED = 0] = "DISABLED", DataValidationImeMode2[DataValidationImeMode2.FULL_ALPHA = 1] = "FULL_ALPHA", DataValidationImeMode2[DataValidationImeMode2.FULL_HANGUL = 2] = "FULL_HANGUL", DataValidationImeMode2[DataValidationImeMode2.FULL_KATAKANA = 3] = "FULL_KATAKANA", DataValidationImeMode2[DataValidationImeMode2.HALF_ALPHA = 4] = "HALF_ALPHA", DataValidationImeMode2[DataValidationImeMode2.HALF_HANGUL = 5] = "HALF_HANGUL", DataValidationImeMode2[DataValidationImeMode2.HALF_KATAKANA = 6] = "HALF_KATAKANA", DataValidationImeMode2[DataValidationImeMode2.HIRAGANA = 7] = "HIRAGANA", DataValidationImeMode2[DataValidationImeMode2.NO_CONTROL = 8] = "NO_CONTROL", DataValidationImeMode2[DataValidationImeMode2.OFF = 9] = "OFF", DataValidationImeMode2[DataValidationImeMode2.ON = 10] = "ON", DataValidationImeMode2))(DataValidationImeMode || {}), DataValidationOperator = /* @__PURE__ */ ((DataValidationOperator2) => (DataValidationOperator2.BETWEEN = "between", DataValidationOperator2.EQUAL = "equal", DataValidationOperator2.GREATER_THAN = "greaterThan", DataValidationOperator2.GREATER_THAN_OR_EQUAL = "greaterThanOrEqual", DataValidationOperator2.LESS_THAN = "lessThan", DataValidationOperator2.LESS_THAN_OR_EQUAL = "lessThanOrEqual", DataValidationOperator2.NOT_BETWEEN = "notBetween", DataValidationOperator2.NOT_EQUAL = "notEqual", DataValidationOperator2))(DataValidationOperator || {}), DataValidationType = /* @__PURE__ */ ((DataValidationType2) => (DataValidationType2.CUSTOM = "custom", DataValidationType2.LIST = "list", DataValidationType2.LIST_MULTIPLE = "listMultiple", DataValidationType2.NONE = "none", DataValidationType2.TEXT_LENGTH = "textLength", DataValidationType2.DATE = "date", DataValidationType2.TIME = "time", DataValidationType2.WHOLE = "whole", DataValidationType2.DECIMAL = "decimal", DataValidationType2.CHECKBOX = "checkbox", DataValidationType2))(DataValidationType || {}), DataValidationStatus = /* @__PURE__ */ ((DataValidationStatus2) => (DataValidationStatus2.VALID = "valid", DataValidationStatus2.INVALID = "invalid", DataValidationStatus2.VALIDATING = "validating", DataValidationStatus2))(DataValidationStatus || {});
12967
12518
  const skipParseTagNames = ["script", "style", "meta", "comment", "link"];
12968
12519
  function nameCharacterCheck(name) {
@@ -12994,7 +12545,6 @@ export {
12994
12545
  BulletAlignment,
12995
12546
  COLORS,
12996
12547
  CellValueType,
12997
- ClientSnapshotServerService,
12998
12548
  Color,
12999
12549
  ColorBuilder,
13000
12550
  ColorKit,
@@ -13090,7 +12640,6 @@ export {
13090
12640
  IPermissionService,
13091
12641
  IResourceLoaderService,
13092
12642
  IResourceManagerService,
13093
- ISnapshotServerService,
13094
12643
  IUndoRedoService,
13095
12644
  IUniverInstanceService,
13096
12645
  Inject,
@@ -13185,6 +12734,7 @@ export {
13185
12734
  ThemeColors,
13186
12735
  ThemeService,
13187
12736
  Tools,
12737
+ UNIVER_INTERNAL,
13188
12738
  UndoCommand,
13189
12739
  UndoCommandId,
13190
12740
  UnitModel,
@@ -13203,8 +12753,6 @@ export {
13203
12753
  WrapStrategy,
13204
12754
  WrapTextType,
13205
12755
  afterInitApply,
13206
- b64DecodeUnicode,
13207
- b64EncodeUnicode,
13208
12756
  binarySearchArray,
13209
12757
  cellToRange,
13210
12758
  characterSpacingControlType,
@@ -13236,8 +12784,6 @@ export {
13236
12784
  fromEventSubject,
13237
12785
  fromObservable,
13238
12786
  generateRandomId,
13239
- generateTempDocumentSnapshot,
13240
- generateTemporarySnap,
13241
12787
  getArrayLength,
13242
12788
  getBodySlice,
13243
12789
  getBodySliceHtml,
@@ -13249,7 +12795,6 @@ export {
13249
12795
  getCustomRangeSlice,
13250
12796
  getDocsUpdateBody,
13251
12797
  getReverseDirection,
13252
- getSheetBlocksFromSnapshot,
13253
12798
  getWorksheetUID,
13254
12799
  groupBy,
13255
12800
  handleStyleToString,
@@ -13297,7 +12842,7 @@ export {
13297
12842
  normalizeTextRuns,
13298
12843
  numberToABC,
13299
12844
  numberToListABC,
13300
- index$2 as numfmt,
12845
+ numfmt,
13301
12846
  orderSearchArray,
13302
12847
  queryObjectMatrix,
13303
12848
  remove,
@@ -13321,14 +12866,8 @@ export {
13321
12866
  sortRulesFactory,
13322
12867
  spliceArray,
13323
12868
  takeAfter,
13324
- textDecoder,
13325
- textEncoder,
13326
12869
  throttle,
13327
12870
  toDisposable,
13328
- transformDocumentDataToSnapshot,
13329
- transformSnapshotToDocumentData,
13330
- transformSnapshotToWorkbookData,
13331
- transformWorkbookDataToSnapshot,
13332
12871
  updateAttributeByDelete,
13333
12872
  updateAttributeByInsert,
13334
12873
  useDependency,