@arbidocs/coedit 0.5.30 → 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.d.cts
CHANGED
|
@@ -6,16 +6,29 @@ import { TreePackageStore, PackageTransactResult, HeadlessDocumentView, ImageDec
|
|
|
6
6
|
import { R as ReferencesPort } from './port-BbN5OZHx.cjs';
|
|
7
7
|
import { R as Revision } from './track-eYC94jTp.cjs';
|
|
8
8
|
import { D as DocxCollaborationSession } from './session-WGvWs6yO.cjs';
|
|
9
|
-
export { C as COLLAB_PROTOCOL, D as DOCUMENT_COLLABORATION_VERSIONS } from './versions-
|
|
9
|
+
export { C as COLLAB_PROTOCOL, D as DOCUMENT_COLLABORATION_VERSIONS, F as FORMAT_REFUSAL } from './versions-ClPpc7Sg.cjs';
|
|
10
10
|
import 'y-protocols/awareness';
|
|
11
11
|
import '@docx-editor.dev/core/collaboration/replication';
|
|
12
12
|
|
|
13
13
|
declare class CollaborationCompatibilityError extends Error {
|
|
14
|
-
|
|
14
|
+
/** What Hocuspocus sends the refused client (`onAuthenticationFailed`'s reason). */
|
|
15
|
+
readonly reason: string;
|
|
16
|
+
constructor(message: string, reason?: string);
|
|
15
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Throws unless the client runs this build's room format and protocol. The refusal's `reason` names
|
|
20
|
+
* this server's format (`formatRefusal` on the client), so the editor can reload into the matching
|
|
21
|
+
* build, or wait for this server's update, instead of failing.
|
|
22
|
+
*/
|
|
16
23
|
declare function assertCompatibleVersions(versions: unknown): void;
|
|
17
|
-
/** Throws unless the room
|
|
24
|
+
/** Throws unless the room is in this build's format. */
|
|
18
25
|
declare function assertRoomFormat(doc: Y.Doc): void;
|
|
26
|
+
/**
|
|
27
|
+
* A stored room state of an earlier room format, re-encoded in this one: its package is read out
|
|
28
|
+
* (elements are read the same way whatever form an earlier format gave them) and seeded again, so
|
|
29
|
+
* nothing the room held is lost. Throws `MaterializeError` when the state cannot be read.
|
|
30
|
+
*/
|
|
31
|
+
declare function reencodeRoom(doc: Y.Doc, state: Uint8Array): void;
|
|
19
32
|
/**
|
|
20
33
|
* DOCX bytes as the editor would save them. Saving stamps a `w14:paraId` on every paragraph that
|
|
21
34
|
* lacks one; seeding from the stamped bytes puts those ids in the room, so every participant
|
|
@@ -79,4 +92,4 @@ declare function roomCommandsPort(room: RoomStore, { revision, actorId }?: {
|
|
|
79
92
|
actorId?: string;
|
|
80
93
|
}): ReferencesPort;
|
|
81
94
|
|
|
82
|
-
export { CollaborationCompatibilityError, type RoomAutomation, type RoomStore, assertCompatibleVersions, assertRoomFormat, normalizeDocx, openRoomAutomation, openRoomStore, readRoom, roomCommandsPort, seedRoom };
|
|
95
|
+
export { CollaborationCompatibilityError, type RoomAutomation, type RoomStore, assertCompatibleVersions, assertRoomFormat, normalizeDocx, openRoomAutomation, openRoomStore, readRoom, reencodeRoom, roomCommandsPort, seedRoom };
|
package/dist/server.d.ts
CHANGED
|
@@ -6,16 +6,29 @@ import { TreePackageStore, PackageTransactResult, HeadlessDocumentView, ImageDec
|
|
|
6
6
|
import { R as ReferencesPort } from './port-BbN5OZHx.js';
|
|
7
7
|
import { R as Revision } from './track-eYC94jTp.js';
|
|
8
8
|
import { D as DocxCollaborationSession } from './session-WGvWs6yO.js';
|
|
9
|
-
export { C as COLLAB_PROTOCOL, D as DOCUMENT_COLLABORATION_VERSIONS } from './versions-
|
|
9
|
+
export { C as COLLAB_PROTOCOL, D as DOCUMENT_COLLABORATION_VERSIONS, F as FORMAT_REFUSAL } from './versions-ClPpc7Sg.js';
|
|
10
10
|
import 'y-protocols/awareness';
|
|
11
11
|
import '@docx-editor.dev/core/collaboration/replication';
|
|
12
12
|
|
|
13
13
|
declare class CollaborationCompatibilityError extends Error {
|
|
14
|
-
|
|
14
|
+
/** What Hocuspocus sends the refused client (`onAuthenticationFailed`'s reason). */
|
|
15
|
+
readonly reason: string;
|
|
16
|
+
constructor(message: string, reason?: string);
|
|
15
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Throws unless the client runs this build's room format and protocol. The refusal's `reason` names
|
|
20
|
+
* this server's format (`formatRefusal` on the client), so the editor can reload into the matching
|
|
21
|
+
* build, or wait for this server's update, instead of failing.
|
|
22
|
+
*/
|
|
16
23
|
declare function assertCompatibleVersions(versions: unknown): void;
|
|
17
|
-
/** Throws unless the room
|
|
24
|
+
/** Throws unless the room is in this build's format. */
|
|
18
25
|
declare function assertRoomFormat(doc: Y.Doc): void;
|
|
26
|
+
/**
|
|
27
|
+
* A stored room state of an earlier room format, re-encoded in this one: its package is read out
|
|
28
|
+
* (elements are read the same way whatever form an earlier format gave them) and seeded again, so
|
|
29
|
+
* nothing the room held is lost. Throws `MaterializeError` when the state cannot be read.
|
|
30
|
+
*/
|
|
31
|
+
declare function reencodeRoom(doc: Y.Doc, state: Uint8Array): void;
|
|
19
32
|
/**
|
|
20
33
|
* DOCX bytes as the editor would save them. Saving stamps a `w14:paraId` on every paragraph that
|
|
21
34
|
* lacks one; seeding from the stamped bytes puts those ids in the room, so every participant
|
|
@@ -79,4 +92,4 @@ declare function roomCommandsPort(room: RoomStore, { revision, actorId }?: {
|
|
|
79
92
|
actorId?: string;
|
|
80
93
|
}): ReferencesPort;
|
|
81
94
|
|
|
82
|
-
export { CollaborationCompatibilityError, type RoomAutomation, type RoomStore, assertCompatibleVersions, assertRoomFormat, normalizeDocx, openRoomAutomation, openRoomStore, readRoom, roomCommandsPort, seedRoom };
|
|
95
|
+
export { CollaborationCompatibilityError, type RoomAutomation, type RoomStore, assertCompatibleVersions, assertRoomFormat, normalizeDocx, openRoomAutomation, openRoomStore, readRoom, reencodeRoom, roomCommandsPort, seedRoom };
|
package/dist/server.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import * as Y from 'yjs';
|
|
1
2
|
import { Awareness } from 'y-protocols/awareness';
|
|
2
3
|
import { createServerAutomationHost } from '@docx-editor.dev/core/automation';
|
|
3
4
|
import { createCollaborationDocumentPort, historyGroupOfJournal, mapOffsetAcrossText } from '@docx-editor.dev/core/collaboration/replication';
|
|
4
5
|
import { TreePackageStore, validateRasterHeader, headlessViewOfStore, ORIGIN_IDS, readOoxmlPackage, writeOoxmlPackage, readOoxmlPart, validateExternalTarget, relsPartNameFor, contentTypesPartBytes, withContentTypeOverride, readXml, XML_NAMESPACE_URI } from '@docx-editor.dev/core/store';
|
|
5
6
|
import { resolveNumberingLevel, resolveStoryListItems, buildStyleCascadeTable, withNumberingStyleLinks, buildNumberingIndex } from '@docx-editor.dev/core/layout';
|
|
6
7
|
import { zipSync, strToU8, strFromU8, unzipSync } from 'fflate';
|
|
7
|
-
import * as Y from 'yjs';
|
|
8
8
|
import { createCollaborationStatusTracker, safeParticipantColor } from '@docx-editor.dev/core/collaboration';
|
|
9
9
|
|
|
10
10
|
// src/server.ts
|
|
@@ -1077,10 +1077,6 @@ function serializeLive(el2, scope) {
|
|
|
1077
1077
|
|
|
1078
1078
|
// src/encoding.ts
|
|
1079
1079
|
var COLLAB_FORMAT = "arbi-docx/2";
|
|
1080
|
-
var READABLE_FORMATS = /* @__PURE__ */ new Set(["arbi-docx/1", COLLAB_FORMAT]);
|
|
1081
|
-
function isReadableFormat(format) {
|
|
1082
|
-
return format !== void 0 && READABLE_FORMATS.has(format);
|
|
1083
|
-
}
|
|
1084
1080
|
function isText(node) {
|
|
1085
1081
|
return node.kind === "textValue";
|
|
1086
1082
|
}
|
|
@@ -2202,7 +2198,7 @@ var DocxCollaborationSession = class {
|
|
|
2202
2198
|
this.setStatus("error", "not-initialized");
|
|
2203
2199
|
return;
|
|
2204
2200
|
}
|
|
2205
|
-
if (
|
|
2201
|
+
if (readFormat(this.doc) !== COLLAB_FORMAT) {
|
|
2206
2202
|
this.setStatus("error", "collaboration-format-mismatch", readFormat(this.doc));
|
|
2207
2203
|
return;
|
|
2208
2204
|
}
|
|
@@ -2490,29 +2486,45 @@ var DOCUMENT_COLLABORATION_VERSIONS = {
|
|
|
2490
2486
|
format: COLLAB_FORMAT,
|
|
2491
2487
|
protocol: COLLAB_PROTOCOL
|
|
2492
2488
|
};
|
|
2489
|
+
var FORMAT_REFUSAL = "collaboration-format:";
|
|
2493
2490
|
|
|
2494
2491
|
// src/server.ts
|
|
2495
2492
|
var CollaborationCompatibilityError = class extends Error {
|
|
2496
|
-
|
|
2493
|
+
/** What Hocuspocus sends the refused client (`onAuthenticationFailed`'s reason). */
|
|
2494
|
+
reason;
|
|
2495
|
+
constructor(message, reason = "permission-denied") {
|
|
2497
2496
|
super(message);
|
|
2498
2497
|
this.name = "CollaborationCompatibilityError";
|
|
2498
|
+
this.reason = reason;
|
|
2499
2499
|
}
|
|
2500
2500
|
};
|
|
2501
2501
|
function assertCompatibleVersions(versions) {
|
|
2502
2502
|
const v = versions;
|
|
2503
2503
|
if (!v || v.format !== COLLAB_FORMAT || v.protocol !== COLLAB_PROTOCOL) {
|
|
2504
2504
|
throw new CollaborationCompatibilityError(
|
|
2505
|
-
"This editor build is not compatible with the collaboration server. Reload the page."
|
|
2505
|
+
"This editor build is not compatible with the collaboration server. Reload the page.",
|
|
2506
|
+
FORMAT_REFUSAL + COLLAB_FORMAT
|
|
2506
2507
|
);
|
|
2507
2508
|
}
|
|
2508
2509
|
}
|
|
2509
2510
|
function assertRoomFormat(doc) {
|
|
2510
2511
|
if (!isBootstrapped(doc)) throw new CollaborationCompatibilityError("The room holds no document.");
|
|
2511
2512
|
const format = readFormat(doc);
|
|
2512
|
-
if (
|
|
2513
|
+
if (format !== COLLAB_FORMAT) {
|
|
2513
2514
|
throw new CollaborationCompatibilityError(`Unsupported room format ${String(format)}.`);
|
|
2514
2515
|
}
|
|
2515
2516
|
}
|
|
2517
|
+
function reencodeRoom(doc, state) {
|
|
2518
|
+
if (isBootstrapped(doc)) throw new CollaborationCompatibilityError("The room is already seeded.");
|
|
2519
|
+
const stored = new Y.Doc();
|
|
2520
|
+
Y.applyUpdate(stored, state);
|
|
2521
|
+
try {
|
|
2522
|
+
if (!isBootstrapped(stored)) throw new MaterializeError("the stored state holds no document");
|
|
2523
|
+
bootstrapFromBytes(doc, materializeBytes(stored));
|
|
2524
|
+
} finally {
|
|
2525
|
+
stored.destroy();
|
|
2526
|
+
}
|
|
2527
|
+
}
|
|
2516
2528
|
function normalizeDocx(bytes) {
|
|
2517
2529
|
const opened = createServerAutomationHost(bytes);
|
|
2518
2530
|
if (!opened.ok) throw new MaterializeError(`not a readable DOCX: ${opened.reason}`);
|
|
@@ -2711,6 +2723,6 @@ function roomCommandsPort(room, { revision, actorId } = {}) {
|
|
|
2711
2723
|
};
|
|
2712
2724
|
}
|
|
2713
2725
|
|
|
2714
|
-
export { COLLAB_PROTOCOL, CollaborationCompatibilityError, DOCUMENT_COLLABORATION_VERSIONS, assertCompatibleVersions, assertRoomFormat, normalizeDocx, openRoomAutomation, openRoomStore, readRoom, roomCommandsPort, seedRoom };
|
|
2726
|
+
export { COLLAB_PROTOCOL, CollaborationCompatibilityError, DOCUMENT_COLLABORATION_VERSIONS, FORMAT_REFUSAL, assertCompatibleVersions, assertRoomFormat, normalizeDocx, openRoomAutomation, openRoomStore, readRoom, reencodeRoom, roomCommandsPort, seedRoom };
|
|
2715
2727
|
//# sourceMappingURL=server.js.map
|
|
2716
2728
|
//# sourceMappingURL=server.js.map
|