@arbidocs/coedit 0.5.29 → 0.5.31
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/dist/encoding.cjs +0 -5
- package/dist/encoding.cjs.map +1 -1
- package/dist/encoding.d.cts +5 -5
- package/dist/encoding.d.ts +5 -5
- package/dist/encoding.js +1 -5
- package/dist/encoding.js.map +1 -1
- package/dist/hocuspocus.cjs +1 -5
- package/dist/hocuspocus.cjs.map +1 -1
- package/dist/hocuspocus.js +1 -5
- package/dist/hocuspocus.js.map +1 -1
- package/dist/index.cjs +10 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -6
- package/dist/index.js.map +1 -1
- package/dist/server.cjs +23 -9
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +17 -4
- package/dist/server.d.ts +17 -4
- package/dist/server.js +22 -10
- package/dist/server.js.map +1 -1
- package/dist/versions-ClPpc7Sg.d.cts +21 -0
- package/dist/versions-ClPpc7Sg.d.ts +21 -0
- package/package.json +1 -1
- package/dist/versions-XSYTVmOU.d.cts +0 -8
- package/dist/versions-XSYTVmOU.d.ts +0 -8
package/dist/server.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var Y = require('yjs');
|
|
3
4
|
var awareness = require('y-protocols/awareness');
|
|
4
5
|
var automation = require('@docx-editor.dev/core/automation');
|
|
5
6
|
var replication = require('@docx-editor.dev/core/collaboration/replication');
|
|
6
7
|
var store = require('@docx-editor.dev/core/store');
|
|
7
8
|
var layout = require('@docx-editor.dev/core/layout');
|
|
8
9
|
var fflate = require('fflate');
|
|
9
|
-
var Y = require('yjs');
|
|
10
10
|
var collaboration = require('@docx-editor.dev/core/collaboration');
|
|
11
11
|
|
|
12
12
|
function _interopNamespace(e) {
|
|
@@ -1099,10 +1099,6 @@ function serializeLive(el2, scope) {
|
|
|
1099
1099
|
|
|
1100
1100
|
// src/encoding.ts
|
|
1101
1101
|
var COLLAB_FORMAT = "arbi-docx/2";
|
|
1102
|
-
var READABLE_FORMATS = /* @__PURE__ */ new Set(["arbi-docx/1", COLLAB_FORMAT]);
|
|
1103
|
-
function isReadableFormat(format) {
|
|
1104
|
-
return format !== void 0 && READABLE_FORMATS.has(format);
|
|
1105
|
-
}
|
|
1106
1102
|
function isText(node) {
|
|
1107
1103
|
return node.kind === "textValue";
|
|
1108
1104
|
}
|
|
@@ -2224,7 +2220,7 @@ var DocxCollaborationSession = class {
|
|
|
2224
2220
|
this.setStatus("error", "not-initialized");
|
|
2225
2221
|
return;
|
|
2226
2222
|
}
|
|
2227
|
-
if (
|
|
2223
|
+
if (readFormat(this.doc) !== COLLAB_FORMAT) {
|
|
2228
2224
|
this.setStatus("error", "collaboration-format-mismatch", readFormat(this.doc));
|
|
2229
2225
|
return;
|
|
2230
2226
|
}
|
|
@@ -2512,29 +2508,45 @@ var DOCUMENT_COLLABORATION_VERSIONS = {
|
|
|
2512
2508
|
format: COLLAB_FORMAT,
|
|
2513
2509
|
protocol: COLLAB_PROTOCOL
|
|
2514
2510
|
};
|
|
2511
|
+
var FORMAT_REFUSAL = "collaboration-format:";
|
|
2515
2512
|
|
|
2516
2513
|
// src/server.ts
|
|
2517
2514
|
var CollaborationCompatibilityError = class extends Error {
|
|
2518
|
-
|
|
2515
|
+
/** What Hocuspocus sends the refused client (`onAuthenticationFailed`'s reason). */
|
|
2516
|
+
reason;
|
|
2517
|
+
constructor(message, reason = "permission-denied") {
|
|
2519
2518
|
super(message);
|
|
2520
2519
|
this.name = "CollaborationCompatibilityError";
|
|
2520
|
+
this.reason = reason;
|
|
2521
2521
|
}
|
|
2522
2522
|
};
|
|
2523
2523
|
function assertCompatibleVersions(versions) {
|
|
2524
2524
|
const v = versions;
|
|
2525
2525
|
if (!v || v.format !== COLLAB_FORMAT || v.protocol !== COLLAB_PROTOCOL) {
|
|
2526
2526
|
throw new CollaborationCompatibilityError(
|
|
2527
|
-
"This editor build is not compatible with the collaboration server. Reload the page."
|
|
2527
|
+
"This editor build is not compatible with the collaboration server. Reload the page.",
|
|
2528
|
+
FORMAT_REFUSAL + COLLAB_FORMAT
|
|
2528
2529
|
);
|
|
2529
2530
|
}
|
|
2530
2531
|
}
|
|
2531
2532
|
function assertRoomFormat(doc) {
|
|
2532
2533
|
if (!isBootstrapped(doc)) throw new CollaborationCompatibilityError("The room holds no document.");
|
|
2533
2534
|
const format = readFormat(doc);
|
|
2534
|
-
if (
|
|
2535
|
+
if (format !== COLLAB_FORMAT) {
|
|
2535
2536
|
throw new CollaborationCompatibilityError(`Unsupported room format ${String(format)}.`);
|
|
2536
2537
|
}
|
|
2537
2538
|
}
|
|
2539
|
+
function reencodeRoom(doc, state) {
|
|
2540
|
+
if (isBootstrapped(doc)) throw new CollaborationCompatibilityError("The room is already seeded.");
|
|
2541
|
+
const stored = new Y__namespace.Doc();
|
|
2542
|
+
Y__namespace.applyUpdate(stored, state);
|
|
2543
|
+
try {
|
|
2544
|
+
if (!isBootstrapped(stored)) throw new MaterializeError("the stored state holds no document");
|
|
2545
|
+
bootstrapFromBytes(doc, materializeBytes(stored));
|
|
2546
|
+
} finally {
|
|
2547
|
+
stored.destroy();
|
|
2548
|
+
}
|
|
2549
|
+
}
|
|
2538
2550
|
function normalizeDocx(bytes) {
|
|
2539
2551
|
const opened = automation.createServerAutomationHost(bytes);
|
|
2540
2552
|
if (!opened.ok) throw new MaterializeError(`not a readable DOCX: ${opened.reason}`);
|
|
@@ -2736,12 +2748,14 @@ function roomCommandsPort(room, { revision, actorId } = {}) {
|
|
|
2736
2748
|
exports.COLLAB_PROTOCOL = COLLAB_PROTOCOL;
|
|
2737
2749
|
exports.CollaborationCompatibilityError = CollaborationCompatibilityError;
|
|
2738
2750
|
exports.DOCUMENT_COLLABORATION_VERSIONS = DOCUMENT_COLLABORATION_VERSIONS;
|
|
2751
|
+
exports.FORMAT_REFUSAL = FORMAT_REFUSAL;
|
|
2739
2752
|
exports.assertCompatibleVersions = assertCompatibleVersions;
|
|
2740
2753
|
exports.assertRoomFormat = assertRoomFormat;
|
|
2741
2754
|
exports.normalizeDocx = normalizeDocx;
|
|
2742
2755
|
exports.openRoomAutomation = openRoomAutomation;
|
|
2743
2756
|
exports.openRoomStore = openRoomStore;
|
|
2744
2757
|
exports.readRoom = readRoom;
|
|
2758
|
+
exports.reencodeRoom = reencodeRoom;
|
|
2745
2759
|
exports.roomCommandsPort = roomCommandsPort;
|
|
2746
2760
|
exports.seedRoom = seedRoom;
|
|
2747
2761
|
//# sourceMappingURL=server.cjs.map
|