@ai-matrx/office 0.8.37 → 0.8.38

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/CHANGELOG.md CHANGED
@@ -1,9 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.8.38
4
+
5
+ **Undo and redo never touch other people's text in a co-edited document.** The room rebased both sides of every
6
+ undo item (and every mutation of a batched item) against the same collaborator edit, so undo → a peer types →
7
+ redo → undo deleted the peer's letters on every seat. Each side now meets the edit in the order it applies, each
8
+ mutation in turn, and Univer's still-open typing burst is stacked before a collaborator's edit applies
9
+ (`DocumentViewPort.docHistory`, new and optional). Consumer action: pass `docHistory` (the view's
10
+ `DocStateChangeManagerService`) from the editor that attaches a view.
11
+
3
12
  ## 0.8.37
4
13
 
5
- UNVERIFIED: this release has no Unreleased entry and the source comparison could not be made (the caller supplied no source comparison). Whether source changed is unknown; consumer action is unknown.
6
- Check the package's gitHead on npm against this version's gitHead: `git diff <previous gitHead> <this gitHead> -- apps/shared/office/src`.
14
+ SOURCE CHANGED WITH NO RELEASE NOTE. This release shipped source changes that nobody described in an Unreleased entry,
15
+ so they may include breaking API changes. Consumer action is UNKNOWN: read the diff before upgrading.
16
+ Diff: `git diff 1700d8bdd6 c1e46e1043 -- apps/shared/office/src`
17
+
18
+ Changed shipped source files (1):
19
+ - `apps/shared/office/src/collab/sheets/transform/registry.ts`
7
20
 
8
21
  ## 0.8.36
9
22
 
package/dist/docs.cjs CHANGED
@@ -291,15 +291,15 @@ var DocumentModel = (_class = class {
291
291
  return editor;
292
292
  }
293
293
  onViewMutation(viewId, info, options) {
294
- if (this.relaying || _optionalChain([options, 'optionalAccess', _19 => _19.fromCollab]) || _optionalChain([options, 'optionalAccess', _20 => _20.fromChangeset])) return;
294
+ if (this.relaying || _optionalChain([options, 'optionalAccess', _23 => _23.fromCollab]) || _optionalChain([options, 'optionalAccess', _24 => _24.fromChangeset])) return;
295
295
  const view = this.views.get(viewId);
296
296
  if (!view) return;
297
297
  const editable = view.port.editable();
298
- if (!editable && !(_optionalChain([view, 'access', _21 => _21.port, 'access', _22 => _22.commentOnly, 'optionalCall', _23 => _23()]) === true && isCommentAnchorMutation(info))) return;
298
+ if (!editable && !(_optionalChain([view, 'access', _25 => _25.port, 'access', _26 => _26.commentOnly, 'optionalCall', _27 => _27()]) === true && isCommentAnchorMutation(info))) return;
299
299
  this.lastEditedView = viewId;
300
300
  this.relay(info, viewId);
301
301
  for (const listener of this.collabListeners) listener(info, options);
302
- if (this.otListeners.size && !_optionalChain([options, 'optionalAccess', _24 => _24.onlyLocal])) {
302
+ if (this.otListeners.size && !_optionalChain([options, 'optionalAccess', _28 => _28.onlyLocal])) {
303
303
  const m = {
304
304
  id: info.id,
305
305
  params: info.params,
@@ -359,7 +359,7 @@ var DocumentModel = (_class = class {
359
359
  /** The unit id a view's document has (what a replayed mutation must be addressed to). */
360
360
  unitIdOf(view) {
361
361
  try {
362
- return _nullishCoalesce(_nullishCoalesce(_optionalChain([view, 'access', _25 => _25.port, 'access', _26 => _26.unitId, 'optionalCall', _27 => _27()]), () => ( _optionalChain([view, 'access', _28 => _28.port, 'access', _29 => _29.snapshot, 'call', _30 => _30(), 'optionalAccess', _31 => _31.id]))), () => ( null));
362
+ return _nullishCoalesce(_nullishCoalesce(_optionalChain([view, 'access', _29 => _29.port, 'access', _30 => _30.unitId, 'optionalCall', _31 => _31()]), () => ( _optionalChain([view, 'access', _32 => _32.port, 'access', _33 => _33.snapshot, 'call', _34 => _34(), 'optionalAccess', _35 => _35.id]))), () => ( null));
363
363
  } catch (e6) {
364
364
  return null;
365
365
  }
@@ -393,7 +393,7 @@ var DocumentModel = (_class = class {
393
393
  /** A view could not follow an edit: say so, then show the saved version (unless this tab has unsaved edits of its own). */
394
394
  applyFailed(mutationId, error) {
395
395
  try {
396
- _optionalChain([this, 'access', _32 => _32.deps, 'access', _33 => _33.onApplyFailed, 'optionalCall', _34 => _34(this.documentId, mutationId, error)]);
396
+ _optionalChain([this, 'access', _36 => _36.deps, 'access', _37 => _37.onApplyFailed, 'optionalCall', _38 => _38(this.documentId, mutationId, error)]);
397
397
  } catch (notifyError) {
398
398
  console.warn(`[document-model] the notice for ${this.documentId}'s failed apply also failed`, notifyError);
399
399
  }
@@ -421,7 +421,7 @@ var DocumentModel = (_class = class {
421
421
  async write(reason) {
422
422
  if (this.ot) {
423
423
  const wrote = await this.ot.write(reason);
424
- if (wrote) _optionalChain([this, 'access', _35 => _35.deps, 'access', _36 => _36.onSaved, 'optionalCall', _37 => _37(this.documentId, reason === "manual" ? "manual" : "autosave")]);
424
+ if (wrote) _optionalChain([this, 'access', _39 => _39.deps, 'access', _40 => _40.onSaved, 'optionalCall', _41 => _41(this.documentId, reason === "manual" ? "manual" : "autosave")]);
425
425
  return wrote;
426
426
  }
427
427
  const snapshot = this.latest();
@@ -446,7 +446,7 @@ var DocumentModel = (_class = class {
446
446
  this.saving = false;
447
447
  }
448
448
  if (this.views.size === 0) this.stored = snapshot;
449
- _optionalChain([this, 'access', _38 => _38.deps, 'access', _39 => _39.onSaved, 'optionalCall', _40 => _40(this.documentId, origin)]);
449
+ _optionalChain([this, 'access', _42 => _42.deps, 'access', _43 => _43.onSaved, 'optionalCall', _44 => _44(this.documentId, origin)]);
450
450
  return true;
451
451
  }
452
452
  hasUnsaved() {
@@ -489,7 +489,7 @@ var DocumentModel = (_class = class {
489
489
  replaceContent(row) {
490
490
  if (this.ot) return this.ot.replace(row.snapshot);
491
491
  this.show(row);
492
- _optionalChain([this, 'access', _41 => _41.collab, 'optionalAccess', _42 => _42.announceReplaced, 'call', _43 => _43(row.id)]);
492
+ _optionalChain([this, 'access', _45 => _45.collab, 'optionalAccess', _46 => _46.announceReplaced, 'call', _47 => _47(row.id)]);
493
493
  }
494
494
  /** A peer replaced the document: show the newest save (once). */
495
495
  async onPeerReplaced() {
@@ -512,7 +512,7 @@ var DocumentModel = (_class = class {
512
512
  this.relaying = true;
513
513
  try {
514
514
  for (const view of this.views.values()) view.port.remount(snapshot);
515
- _optionalChain([this, 'access', _44 => _44.parked, 'optionalAccess', _45 => _45.remount, 'call', _46 => _46(snapshot)]);
515
+ _optionalChain([this, 'access', _48 => _48.parked, 'optionalAccess', _49 => _49.remount, 'call', _50 => _50(snapshot)]);
516
516
  } finally {
517
517
  this.relaying = false;
518
518
  }
@@ -586,7 +586,7 @@ var DocumentModel = (_class = class {
586
586
  const input = Array.isArray(params.actions) ? params.actions.length : 0;
587
587
  let sel = null;
588
588
  try {
589
- sel = _nullishCoalesce(_optionalChain([view, 'access', _47 => _47.port, 'access', _48 => _48.selection, 'optionalAccess', _49 => _49.get, 'call', _50 => _50()]), () => ( null));
589
+ sel = _nullishCoalesce(_optionalChain([view, 'access', _51 => _51.port, 'access', _52 => _52.selection, 'optionalAccess', _53 => _53.get, 'call', _54 => _54()]), () => ( null));
590
590
  } catch (e7) {
591
591
  sel = null;
592
592
  }
@@ -597,7 +597,7 @@ var DocumentModel = (_class = class {
597
597
  const moved = sel && sel.length && sel.every((r) => !r.segmentId) ? moveRangesThroughBodyEdit(sel, params.actions) : null;
598
598
  if (moved) {
599
599
  try {
600
- _optionalChain([view, 'access', _51 => _51.port, 'access', _52 => _52.selection, 'optionalAccess', _53 => _53.set, 'call', _54 => _54(moved)]);
600
+ _optionalChain([view, 'access', _55 => _55.port, 'access', _56 => _56.selection, 'optionalAccess', _57 => _57.set, 'call', _58 => _58(moved)]);
601
601
  } catch (error) {
602
602
  console.warn(`[document-model] could not move this view's caret past a collaborator's edit`, error);
603
603
  }
@@ -616,7 +616,7 @@ var DocumentModel = (_class = class {
616
616
  this.relaying = true;
617
617
  try {
618
618
  for (const view of this.views.values()) view.port.remount(s2);
619
- _optionalChain([this, 'access', _55 => _55.parked, 'optionalAccess', _56 => _56.remount, 'call', _57 => _57(s2)]);
619
+ _optionalChain([this, 'access', _59 => _59.parked, 'optionalAccess', _60 => _60.remount, 'call', _61 => _61(s2)]);
620
620
  } finally {
621
621
  this.relaying = false;
622
622
  }
@@ -625,8 +625,20 @@ var DocumentModel = (_class = class {
625
625
  const out = [];
626
626
  for (const view of this.views.values()) {
627
627
  const unitId = this.unitIdOf(view);
628
- const service = _optionalChain([view, 'access', _58 => _58.port, 'access', _59 => _59.undoRedo, 'optionalCall', _60 => _60()]);
629
- if (unitId && service) out.push({ service, unitId });
628
+ const service = _optionalChain([view, 'access', _62 => _62.port, 'access', _63 => _63.undoRedo, 'optionalCall', _64 => _64()]);
629
+ if (!unitId || !service) continue;
630
+ const port = view.port;
631
+ out.push({
632
+ service,
633
+ unitId,
634
+ flushHistory: () => {
635
+ try {
636
+ _optionalChain([port, 'access', _65 => _65.docHistory, 'optionalCall', _66 => _66(), 'optionalAccess', _67 => _67.flushPendingChanges, 'call', _68 => _68(unitId)]);
637
+ } catch (error) {
638
+ console.warn(`[document-model] could not close this view's typing burst before a collaborator's edit`, error);
639
+ }
640
+ }
641
+ });
630
642
  }
631
643
  return out;
632
644
  },
@@ -634,7 +646,7 @@ var DocumentModel = (_class = class {
634
646
  selection: () => {
635
647
  for (const view of this.views.values()) {
636
648
  try {
637
- const sel = _optionalChain([view, 'access', _61 => _61.port, 'access', _62 => _62.selection, 'optionalAccess', _63 => _63.get, 'call', _64 => _64()]);
649
+ const sel = _optionalChain([view, 'access', _69 => _69.port, 'access', _70 => _70.selection, 'optionalAccess', _71 => _71.get, 'call', _72 => _72()]);
638
650
  if (sel) return sel;
639
651
  } catch (e8) {
640
652
  }
@@ -693,9 +705,9 @@ var DocumentModel = (_class = class {
693
705
  * so a collaborator's save still reaches the body a returning view boots from.
694
706
  */
695
707
  rest() {
696
- _optionalChain([this, 'access', _65 => _65.collab, 'optionalAccess', _66 => _66.stop, 'call', _67 => _67()]);
708
+ _optionalChain([this, 'access', _73 => _73.collab, 'optionalAccess', _74 => _74.stop, 'call', _75 => _75()]);
697
709
  this.collab = null;
698
- _optionalChain([this, 'access', _68 => _68.ot, 'optionalAccess', _69 => _69.stop, 'call', _70 => _70()]);
710
+ _optionalChain([this, 'access', _76 => _76.ot, 'optionalAccess', _77 => _77.stop, 'call', _78 => _78()]);
699
711
  this.ot = null;
700
712
  this.awareness = null;
701
713
  }
@@ -711,9 +723,9 @@ var DocumentModel = (_class = class {
711
723
  console.warn(`[document-model] could not dispose ${this.documentId}'s kept editor`, error);
712
724
  }
713
725
  }
714
- _optionalChain([this, 'access', _71 => _71.realtimeClose, 'optionalCall', _72 => _72()]);
726
+ _optionalChain([this, 'access', _79 => _79.realtimeClose, 'optionalCall', _80 => _80()]);
715
727
  this.realtimeClose = null;
716
- _optionalChain([this, 'access', _73 => _73.pageClose, 'optionalCall', _74 => _74()]);
728
+ _optionalChain([this, 'access', _81 => _81.pageClose, 'optionalCall', _82 => _82()]);
717
729
  this.pageClose = null;
718
730
  }
719
731
  }, _class);
@@ -991,12 +1003,12 @@ function movePeerRangesThroughBodyEdit(ranges, actions) {
991
1003
  }
992
1004
  var sameRanges = (a, b) => a.length === b.length && a.every((r, i) => r.start === b[i].start && r.end === b[i].end);
993
1005
  function readCaret(raw) {
994
- const c = _optionalChain([raw, 'optionalAccess', _75 => _75.caret]);
1006
+ const c = _optionalChain([raw, 'optionalAccess', _83 => _83.caret]);
995
1007
  if (!c || !Array.isArray(c.ranges) || typeof c.at !== "number") return null;
996
1008
  const ranges = [];
997
1009
  for (const r of c.ranges.slice(0, CARET_MAX_RANGES)) {
998
- const s2 = _optionalChain([r, 'optionalAccess', _76 => _76.start]);
999
- const e2 = _optionalChain([r, 'optionalAccess', _77 => _77.end]);
1010
+ const s2 = _optionalChain([r, 'optionalAccess', _84 => _84.start]);
1011
+ const e2 = _optionalChain([r, 'optionalAccess', _85 => _85.end]);
1000
1012
  if (typeof s2 !== "number" || typeof e2 !== "number" || !Number.isFinite(s2) || !Number.isFinite(e2) || s2 < 0 || e2 < 0) return null;
1001
1013
  ranges.push({ start: s2, end: e2 });
1002
1014
  }