@ai-matrx/office 0.8.19 → 0.8.20

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,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.8.20
4
+
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`.
7
+
3
8
  ## 0.8.19
4
9
  ### C7a: the browser editor's plugin resources
5
10
 
@@ -119,6 +119,7 @@ var WorkbookCollabSession = class {
119
119
  muted = 0;
120
120
  started = false;
121
121
  disposed = false;
122
+ stopColor = null;
122
123
  /** Room entries this seat holds in its content: applied from a peer, or made here. */
123
124
  applied = /* @__PURE__ */ new Set();
124
125
  /** Entries without an id (a peer on an older build) are applied once, by identity. */
@@ -140,12 +141,12 @@ var WorkbookCollabSession = class {
140
141
  uid: this.options.uid,
141
142
  clientId: this.options.clientId,
142
143
  name: this.options.uid.slice(0, 8),
143
- color: pickColor(this.options.uid),
144
144
  sheetId: null,
145
145
  row: null,
146
146
  col: null,
147
147
  ts: Date.now()
148
148
  });
149
+ this.stopColor = (0, import_collab.claimCollaboratorColor)(this.awareness, { uid: this.options.uid, clientId: this.options.clientId });
149
150
  this.provider = this.options.makeProvider({
150
151
  workbookId: this.options.workbookId,
151
152
  clientId: this.options.clientId,
@@ -206,6 +207,8 @@ var WorkbookCollabSession = class {
206
207
  this.awareness.off("change", this.awarenessObserver);
207
208
  this.awarenessObserver = null;
208
209
  }
210
+ this.stopColor?.();
211
+ this.stopColor = null;
209
212
  this.provider?.disconnect();
210
213
  this.provider = null;
211
214
  if (this.awareness) {
@@ -412,32 +415,6 @@ function stripSenderView(params) {
412
415
  function isCellEditorScratch(info) {
413
416
  return typeof info.id === "string" && info.id.startsWith("doc.mutation.");
414
417
  }
415
- var CURSOR_PALETTE = [
416
- "#3b82f6",
417
- // blue
418
- "#10b981",
419
- // emerald
420
- "#f59e0b",
421
- // amber
422
- "#ef4444",
423
- // red
424
- "#8b5cf6",
425
- // violet
426
- "#06b6d4",
427
- // cyan
428
- "#ec4899",
429
- // pink
430
- "#84cc16"
431
- // lime
432
- ];
433
- function pickColor(uid) {
434
- let h = 2166136261;
435
- for (let i = 0; i < uid.length; i++) {
436
- h ^= uid.charCodeAt(i);
437
- h = Math.imul(h, 16777619);
438
- }
439
- return CURSOR_PALETTE[Math.abs(h) % CURSOR_PALETTE.length] ?? "#ec4899";
440
- }
441
418
 
442
419
  // src/univer/collab/docs-ot/transform.ts
443
420
  var import_core = require("@univerjs/core");
@@ -3643,15 +3620,6 @@ async function workbookUsesOrderedRoom(workbookId, knob, isNewWorkbook) {
3643
3620
  if (knob === "new") return isNewWorkbook();
3644
3621
  return false;
3645
3622
  }
3646
- function pickColor2(uid) {
3647
- const palette = ["#ef4444", "#f59e0b", "#10b981", "#3b82f6", "#8b5cf6", "#ec4899", "#14b8a6", "#f97316"];
3648
- let h = 2166136261;
3649
- for (let i = 0; i < uid.length; i++) {
3650
- h ^= uid.charCodeAt(i);
3651
- h = Math.imul(h, 16777619);
3652
- }
3653
- return palette[Math.abs(h) % palette.length] ?? "#ec4899";
3654
- }
3655
3623
  async function startWorkbookOtRoom(port, o) {
3656
3624
  const latest = await getLatestSnapshot(o.workbookId);
3657
3625
  if (!latest.success) throw new Error(latest.error);
@@ -3668,12 +3636,12 @@ async function startWorkbookOtRoom(port, o) {
3668
3636
  uid: o.uid,
3669
3637
  clientId: o.clientId,
3670
3638
  name: o.displayName ?? o.uid.slice(0, 8),
3671
- color: pickColor2(o.uid),
3672
3639
  sheetId: null,
3673
3640
  row: null,
3674
3641
  col: null,
3675
3642
  ts: Date.now()
3676
3643
  });
3644
+ const stopColor = (0, import_collab6.claimCollaboratorColor)(awareness, { uid: o.uid, clientId: o.clientId });
3677
3645
  const publishAwareness = () => o.onAwareness?.(new Map(awareness.getStates()));
3678
3646
  awareness.on("change", publishAwareness);
3679
3647
  const provider = new import_collab6.SupabaseYjsProvider({
@@ -3719,6 +3687,7 @@ async function startWorkbookOtRoom(port, o) {
3719
3687
  awareness.setLocalState({ ...current, sheetId: c.sheetId, row: c.row, col: c.col, ts: Date.now() });
3720
3688
  },
3721
3689
  stop() {
3690
+ stopColor();
3722
3691
  room.stop();
3723
3692
  port.dispose?.();
3724
3693
  awareness.off("change", publishAwareness);