@ai-matrx/office 0.8.18 → 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 +10 -0
- package/dist/univer-collab.cjs +29 -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 +33 -40
- package/dist/univer-collab.js.map +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
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
|
+
|
|
8
|
+
## 0.8.19
|
|
9
|
+
### C7a: the browser editor's plugin resources
|
|
10
|
+
|
|
11
|
+
- **Docs state hash: plugin resources by content, zoom never.** The browser editor (full docs preset) writes one `resources` entry per plugin on every save (`"[]"`, `""`, `{"links":[]}`, `{"data":{},"order":[]}`) and `settings.zoomRatio`; a stored row and a headless load have neither, so live seats still refused a restore after 0.8.18. The canonical form now parses each resource, drops empty ones, sorts by name, and drops the zoom. Forcing case: the live row and what the browser held after loading it (red on 0.8.18, green). Consumer action: none.
|
|
12
|
+
|
|
3
13
|
## 0.8.18
|
|
4
14
|
### C7a restore hash, stale checkpoints, collaborator colours
|
|
5
15
|
|
package/dist/univer-collab.cjs
CHANGED
|
@@ -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");
|
|
@@ -1134,9 +1111,32 @@ function asLoadedDocsSnapshot(snapshot) {
|
|
|
1134
1111
|
model.dispose();
|
|
1135
1112
|
}
|
|
1136
1113
|
}
|
|
1114
|
+
var isEmptyDeep = (v) => v == null || v === "" || (Array.isArray(v) ? v.every(isEmptyDeep) : typeof v === "object" ? Object.values(v).every(isEmptyDeep) : false);
|
|
1115
|
+
function canonicalResources(resources) {
|
|
1116
|
+
if (!Array.isArray(resources)) return [];
|
|
1117
|
+
const out = [];
|
|
1118
|
+
for (const r of resources) {
|
|
1119
|
+
if (!r || typeof r.name !== "string") continue;
|
|
1120
|
+
let data = r.data;
|
|
1121
|
+
if (typeof data === "string" && data !== "") {
|
|
1122
|
+
try {
|
|
1123
|
+
data = JSON.parse(data);
|
|
1124
|
+
} catch {
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
if (isEmptyDeep(data)) continue;
|
|
1128
|
+
out.push({ name: r.name, data: sortDeep(data) });
|
|
1129
|
+
}
|
|
1130
|
+
return out.sort((a, b) => a.name.localeCompare(b.name));
|
|
1131
|
+
}
|
|
1137
1132
|
function canonicalDocsSnapshot(snapshot) {
|
|
1138
1133
|
const s = asLoadedDocsSnapshot(snapshot);
|
|
1139
1134
|
delete s.id;
|
|
1135
|
+
s.resources = canonicalResources(s.resources);
|
|
1136
|
+
if (s.settings && typeof s.settings === "object") {
|
|
1137
|
+
s.settings = { ...s.settings };
|
|
1138
|
+
delete s.settings.zoomRatio;
|
|
1139
|
+
}
|
|
1140
1140
|
for (const k of DOC_LOCAL_KEYS) delete s[k];
|
|
1141
1141
|
s.body = canonicalBody(s.body);
|
|
1142
1142
|
for (const seg of ["headers", "footers", "notes"]) {
|
|
@@ -3620,15 +3620,6 @@ async function workbookUsesOrderedRoom(workbookId, knob, isNewWorkbook) {
|
|
|
3620
3620
|
if (knob === "new") return isNewWorkbook();
|
|
3621
3621
|
return false;
|
|
3622
3622
|
}
|
|
3623
|
-
function pickColor2(uid) {
|
|
3624
|
-
const palette = ["#ef4444", "#f59e0b", "#10b981", "#3b82f6", "#8b5cf6", "#ec4899", "#14b8a6", "#f97316"];
|
|
3625
|
-
let h = 2166136261;
|
|
3626
|
-
for (let i = 0; i < uid.length; i++) {
|
|
3627
|
-
h ^= uid.charCodeAt(i);
|
|
3628
|
-
h = Math.imul(h, 16777619);
|
|
3629
|
-
}
|
|
3630
|
-
return palette[Math.abs(h) % palette.length] ?? "#ec4899";
|
|
3631
|
-
}
|
|
3632
3623
|
async function startWorkbookOtRoom(port, o) {
|
|
3633
3624
|
const latest = await getLatestSnapshot(o.workbookId);
|
|
3634
3625
|
if (!latest.success) throw new Error(latest.error);
|
|
@@ -3645,12 +3636,12 @@ async function startWorkbookOtRoom(port, o) {
|
|
|
3645
3636
|
uid: o.uid,
|
|
3646
3637
|
clientId: o.clientId,
|
|
3647
3638
|
name: o.displayName ?? o.uid.slice(0, 8),
|
|
3648
|
-
color: pickColor2(o.uid),
|
|
3649
3639
|
sheetId: null,
|
|
3650
3640
|
row: null,
|
|
3651
3641
|
col: null,
|
|
3652
3642
|
ts: Date.now()
|
|
3653
3643
|
});
|
|
3644
|
+
const stopColor = (0, import_collab6.claimCollaboratorColor)(awareness, { uid: o.uid, clientId: o.clientId });
|
|
3654
3645
|
const publishAwareness = () => o.onAwareness?.(new Map(awareness.getStates()));
|
|
3655
3646
|
awareness.on("change", publishAwareness);
|
|
3656
3647
|
const provider = new import_collab6.SupabaseYjsProvider({
|
|
@@ -3696,6 +3687,7 @@ async function startWorkbookOtRoom(port, o) {
|
|
|
3696
3687
|
awareness.setLocalState({ ...current, sheetId: c.sheetId, row: c.row, col: c.col, ts: Date.now() });
|
|
3697
3688
|
},
|
|
3698
3689
|
stop() {
|
|
3690
|
+
stopColor();
|
|
3699
3691
|
room.stop();
|
|
3700
3692
|
port.dispose?.();
|
|
3701
3693
|
awareness.off("change", publishAwareness);
|