@ai-matrx/office 0.8.0 → 0.8.1

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,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.8.1
4
+
5
+ - Docs room: `encode` writes ops with canonical key order (`canonicalKeys`). The log stores groups as jsonb, which hands keys back in its own order, so the session's acknowledgement check saw every one of this seat's own edits as a mismatch and reloaded the seat on each ack (found in the live two-browser run: keystrokes lost). Test: the two-seat suite now runs over a transport that returns rows in jsonb key order and asserts zero ack mismatches (red without the fix).
6
+
7
+ ### Consumer action
8
+
9
+ None.
10
+
3
11
  ## 0.8.0
4
12
 
5
13
  Docs co-editing on the ordered log (COLLAB-DESIGN unit C3), in `./univer/collab` (loaded on demand):
@@ -41,6 +41,7 @@ __export(collab_exports, {
41
41
  applyDocsOp: () => applyDocsOp,
42
42
  canonicalDocsSnapshot: () => canonicalDocsSnapshot,
43
43
  canonicalDocsString: () => canonicalDocsString,
44
+ canonicalKeys: () => canonicalKeys,
44
45
  composeDocsOps: () => composeDocsOps,
45
46
  docsStateHash: () => docsStateHash,
46
47
  documentOtFactory: () => documentOtFactory,
@@ -1038,6 +1039,15 @@ function stampDeterministicIds(snapshot) {
1038
1039
  var import_collab2 = require("@ai-matrx/data/realtime/collab");
1039
1040
  var RICH_TEXT_EDITING = "doc.mutation.rich-text-editing";
1040
1041
  var DOCS_COLLAB_PROTO = 1;
1042
+ function canonicalKeys(v) {
1043
+ if (Array.isArray(v)) return v.map(canonicalKeys);
1044
+ if (v && typeof v === "object") {
1045
+ const out = {};
1046
+ for (const k of Object.keys(v).sort()) out[k] = canonicalKeys(v[k]);
1047
+ return out;
1048
+ }
1049
+ return v;
1050
+ }
1041
1051
  function branches(op) {
1042
1052
  if (!Array.isArray(op) || op.length === 0) return [];
1043
1053
  return Array.isArray(op[0]) ? op : [op];
@@ -1128,7 +1138,7 @@ function openDocsOtRoom(o) {
1128
1138
  },
1129
1139
  compose: (a, b) => composeDocsOps(a, b),
1130
1140
  isNoop: (op) => isNoopDocsOp(op),
1131
- encode: (op) => [{ cmd: "docs.edit", mutations: [{ id: RICH_TEXT_EDITING, params: { segmentId: "", actions: op } }] }],
1141
+ encode: (op) => [{ cmd: "docs.edit", mutations: [{ id: RICH_TEXT_EDITING, params: { segmentId: "", actions: canonicalKeys(op) } }] }],
1132
1142
  decode(groups) {
1133
1143
  let op = null;
1134
1144
  for (const g of groups) {