@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 +5 -0
- package/dist/univer-collab.cjs +6 -37
- package/dist/univer-collab.cjs.map +1 -1
- package/dist/univer-collab.d.cts +1 -0
- package/dist/univer-collab.d.ts +1 -0
- package/dist/univer-collab.js +10 -40
- package/dist/univer-collab.js.map +1 -1
- package/package.json +4 -4
package/dist/univer-collab.d.cts
CHANGED
|
@@ -128,6 +128,7 @@ declare class WorkbookCollabSession {
|
|
|
128
128
|
private muted;
|
|
129
129
|
private started;
|
|
130
130
|
private disposed;
|
|
131
|
+
private stopColor;
|
|
131
132
|
/** Room entries this seat holds in its content: applied from a peer, or made here. */
|
|
132
133
|
private readonly applied;
|
|
133
134
|
/** Entries without an id (a peer on an older build) are applied once, by identity. */
|
package/dist/univer-collab.d.ts
CHANGED
|
@@ -128,6 +128,7 @@ declare class WorkbookCollabSession {
|
|
|
128
128
|
private muted;
|
|
129
129
|
private started;
|
|
130
130
|
private disposed;
|
|
131
|
+
private stopColor;
|
|
131
132
|
/** Room entries this seat holds in its content: applied from a peer, or made here. */
|
|
132
133
|
private readonly applied;
|
|
133
134
|
/** Entries without an id (a peer on an older build) are applied once, by identity. */
|
package/dist/univer-collab.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// src/univer/collab/WorkbookCollabSession.ts
|
|
4
4
|
import * as Y from "yjs";
|
|
5
5
|
import { Awareness } from "y-protocols/awareness";
|
|
6
|
-
import { electCollabHost, remoteOriginOf, REMOTE_PARAM_TAG } from "@ai-matrx/data/realtime/collab";
|
|
6
|
+
import { claimCollaboratorColor, electCollabHost, remoteOriginOf, REMOTE_PARAM_TAG } from "@ai-matrx/data/realtime/collab";
|
|
7
7
|
|
|
8
8
|
// src/univer/collab/covered.ts
|
|
9
9
|
var COLLAB_COVERED_KEY = "__matrxCollabCovered";
|
|
@@ -39,6 +39,7 @@ var WorkbookCollabSession = class {
|
|
|
39
39
|
muted = 0;
|
|
40
40
|
started = false;
|
|
41
41
|
disposed = false;
|
|
42
|
+
stopColor = null;
|
|
42
43
|
/** Room entries this seat holds in its content: applied from a peer, or made here. */
|
|
43
44
|
applied = /* @__PURE__ */ new Set();
|
|
44
45
|
/** Entries without an id (a peer on an older build) are applied once, by identity. */
|
|
@@ -60,12 +61,12 @@ var WorkbookCollabSession = class {
|
|
|
60
61
|
uid: this.options.uid,
|
|
61
62
|
clientId: this.options.clientId,
|
|
62
63
|
name: this.options.uid.slice(0, 8),
|
|
63
|
-
color: pickColor(this.options.uid),
|
|
64
64
|
sheetId: null,
|
|
65
65
|
row: null,
|
|
66
66
|
col: null,
|
|
67
67
|
ts: Date.now()
|
|
68
68
|
});
|
|
69
|
+
this.stopColor = claimCollaboratorColor(this.awareness, { uid: this.options.uid, clientId: this.options.clientId });
|
|
69
70
|
this.provider = this.options.makeProvider({
|
|
70
71
|
workbookId: this.options.workbookId,
|
|
71
72
|
clientId: this.options.clientId,
|
|
@@ -126,6 +127,8 @@ var WorkbookCollabSession = class {
|
|
|
126
127
|
this.awareness.off("change", this.awarenessObserver);
|
|
127
128
|
this.awarenessObserver = null;
|
|
128
129
|
}
|
|
130
|
+
this.stopColor?.();
|
|
131
|
+
this.stopColor = null;
|
|
129
132
|
this.provider?.disconnect();
|
|
130
133
|
this.provider = null;
|
|
131
134
|
if (this.awareness) {
|
|
@@ -332,32 +335,6 @@ function stripSenderView(params) {
|
|
|
332
335
|
function isCellEditorScratch(info) {
|
|
333
336
|
return typeof info.id === "string" && info.id.startsWith("doc.mutation.");
|
|
334
337
|
}
|
|
335
|
-
var CURSOR_PALETTE = [
|
|
336
|
-
"#3b82f6",
|
|
337
|
-
// blue
|
|
338
|
-
"#10b981",
|
|
339
|
-
// emerald
|
|
340
|
-
"#f59e0b",
|
|
341
|
-
// amber
|
|
342
|
-
"#ef4444",
|
|
343
|
-
// red
|
|
344
|
-
"#8b5cf6",
|
|
345
|
-
// violet
|
|
346
|
-
"#06b6d4",
|
|
347
|
-
// cyan
|
|
348
|
-
"#ec4899",
|
|
349
|
-
// pink
|
|
350
|
-
"#84cc16"
|
|
351
|
-
// lime
|
|
352
|
-
];
|
|
353
|
-
function pickColor(uid) {
|
|
354
|
-
let h = 2166136261;
|
|
355
|
-
for (let i = 0; i < uid.length; i++) {
|
|
356
|
-
h ^= uid.charCodeAt(i);
|
|
357
|
-
h = Math.imul(h, 16777619);
|
|
358
|
-
}
|
|
359
|
-
return CURSOR_PALETTE[Math.abs(h) % CURSOR_PALETTE.length] ?? "#ec4899";
|
|
360
|
-
}
|
|
361
338
|
|
|
362
339
|
// src/univer/collab/docs-ot/transform.ts
|
|
363
340
|
import { JSONX, TextX, getBodySliceForSplitTextXAction, normalizeTextRuns, merge as univerMerge } from "@univerjs/core";
|
|
@@ -1351,7 +1328,7 @@ import * as Y2 from "yjs";
|
|
|
1351
1328
|
import { Awareness as Awareness2 } from "y-protocols/awareness";
|
|
1352
1329
|
import {
|
|
1353
1330
|
awarenessOpPresence,
|
|
1354
|
-
claimCollaboratorColor,
|
|
1331
|
+
claimCollaboratorColor as claimCollaboratorColor2,
|
|
1355
1332
|
collabReplace,
|
|
1356
1333
|
collabRoomExists,
|
|
1357
1334
|
SupabaseYjsProvider,
|
|
@@ -1530,7 +1507,7 @@ function documentOtFactory(o) {
|
|
|
1530
1507
|
const doc = new Y2.Doc();
|
|
1531
1508
|
const awareness = new Awareness2(doc);
|
|
1532
1509
|
awareness.setLocalState({ uid: o.uid, clientId: o.clientId, name: o.displayName ?? o.uid.slice(0, 8), ts: Date.now() });
|
|
1533
|
-
const stopColor =
|
|
1510
|
+
const stopColor = claimCollaboratorColor2(awareness, { uid: o.uid, clientId: o.clientId });
|
|
1534
1511
|
const carets = new RemoteCaretBook(awareness.clientID);
|
|
1535
1512
|
const emit = () => onAwareness({ states: new Map(awareness.getStates()), selfUid: o.uid, carets: carets.list() });
|
|
1536
1513
|
const publishAwareness = () => {
|
|
@@ -3516,6 +3493,7 @@ import * as Y3 from "yjs";
|
|
|
3516
3493
|
import { Awareness as Awareness3 } from "y-protocols/awareness";
|
|
3517
3494
|
import {
|
|
3518
3495
|
awarenessOpPresence as awarenessOpPresence2,
|
|
3496
|
+
claimCollaboratorColor as claimCollaboratorColor3,
|
|
3519
3497
|
collabReplace as collabReplace3,
|
|
3520
3498
|
collabRoomExists as collabRoomExists3,
|
|
3521
3499
|
SupabaseYjsProvider as SupabaseYjsProvider2,
|
|
@@ -3585,15 +3563,6 @@ async function workbookUsesOrderedRoom(workbookId, knob, isNewWorkbook) {
|
|
|
3585
3563
|
if (knob === "new") return isNewWorkbook();
|
|
3586
3564
|
return false;
|
|
3587
3565
|
}
|
|
3588
|
-
function pickColor2(uid) {
|
|
3589
|
-
const palette = ["#ef4444", "#f59e0b", "#10b981", "#3b82f6", "#8b5cf6", "#ec4899", "#14b8a6", "#f97316"];
|
|
3590
|
-
let h = 2166136261;
|
|
3591
|
-
for (let i = 0; i < uid.length; i++) {
|
|
3592
|
-
h ^= uid.charCodeAt(i);
|
|
3593
|
-
h = Math.imul(h, 16777619);
|
|
3594
|
-
}
|
|
3595
|
-
return palette[Math.abs(h) % palette.length] ?? "#ec4899";
|
|
3596
|
-
}
|
|
3597
3566
|
async function startWorkbookOtRoom(port, o) {
|
|
3598
3567
|
const latest = await getLatestSnapshot(o.workbookId);
|
|
3599
3568
|
if (!latest.success) throw new Error(latest.error);
|
|
@@ -3610,12 +3579,12 @@ async function startWorkbookOtRoom(port, o) {
|
|
|
3610
3579
|
uid: o.uid,
|
|
3611
3580
|
clientId: o.clientId,
|
|
3612
3581
|
name: o.displayName ?? o.uid.slice(0, 8),
|
|
3613
|
-
color: pickColor2(o.uid),
|
|
3614
3582
|
sheetId: null,
|
|
3615
3583
|
row: null,
|
|
3616
3584
|
col: null,
|
|
3617
3585
|
ts: Date.now()
|
|
3618
3586
|
});
|
|
3587
|
+
const stopColor = claimCollaboratorColor3(awareness, { uid: o.uid, clientId: o.clientId });
|
|
3619
3588
|
const publishAwareness = () => o.onAwareness?.(new Map(awareness.getStates()));
|
|
3620
3589
|
awareness.on("change", publishAwareness);
|
|
3621
3590
|
const provider = new SupabaseYjsProvider2({
|
|
@@ -3661,6 +3630,7 @@ async function startWorkbookOtRoom(port, o) {
|
|
|
3661
3630
|
awareness.setLocalState({ ...current, sheetId: c.sheetId, row: c.row, col: c.col, ts: Date.now() });
|
|
3662
3631
|
},
|
|
3663
3632
|
stop() {
|
|
3633
|
+
stopColor();
|
|
3664
3634
|
room.stop();
|
|
3665
3635
|
port.dispose?.();
|
|
3666
3636
|
awareness.off("change", publishAwareness);
|