@docx-editor.dev/pro 2.10.0 → 2.12.0
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/README.md +1 -7
- package/dist/chunk-6DEUT2RQ.js +1 -0
- package/dist/chunk-C4RVARMI.cjs +3 -0
- package/dist/chunk-DHIPX767.js +3 -0
- package/dist/chunk-EMO6YTKO.cjs +1 -0
- package/dist/chunk-GDTCNTK7.cjs +1 -0
- package/dist/chunk-HJB77VBO.js +1 -0
- package/dist/chunk-KOGVHJ7U.js +3 -0
- package/dist/chunk-LUUFBXJ5.cjs +1 -0
- package/dist/chunk-NQW54J56.js +1 -0
- package/dist/chunk-Q2VBO66F.js +1 -0
- package/dist/chunk-Q4YPX2DT.cjs +1 -0
- package/dist/chunk-QA3F5EUJ.cjs +3 -0
- package/dist/chunk-QLZH2Q2C.cjs +1 -0
- package/dist/chunk-W3V54DWZ.js +1 -0
- package/dist/collaboration/hocuspocus.cjs +1 -0
- package/dist/collaboration/hocuspocus.d.cts +58 -0
- package/dist/collaboration/hocuspocus.d.ts +58 -0
- package/dist/collaboration/hocuspocus.js +1 -0
- package/dist/collaboration/index.cjs +2 -0
- package/dist/collaboration/index.d.cts +54 -0
- package/dist/collaboration/index.d.ts +54 -0
- package/dist/collaboration/index.js +2 -0
- package/dist/collaboration/webrtc.cjs +2 -0
- package/dist/collaboration/webrtc.d.cts +86 -0
- package/dist/collaboration/webrtc.d.ts +86 -0
- package/dist/collaboration/webrtc.js +2 -0
- package/dist/collaboration-module-BgRxhW5b.d.cts +45 -0
- package/dist/collaboration-module-BgRxhW5b.d.ts +45 -0
- package/dist/{define-custom-node-Bk8kFO27.d.cts → define-custom-node-B_p2nr9T.d.cts} +2 -20
- package/dist/{define-custom-node-Bk8kFO27.d.ts → define-custom-node-BehI3jWX.d.ts} +2 -20
- package/dist/document-session-1VSzWYaC.d.ts +123 -0
- package/dist/document-session-I77CU7RQ.cjs +1 -0
- package/dist/document-session-KYavjw8A.d.cts +123 -0
- package/dist/document-session-MTK2LEYT.cjs +1 -0
- package/dist/document-session-NFUE7UBO.js +1 -0
- package/dist/document-session-WEZH77T3.js +1 -0
- package/dist/hocuspocus-3FLNEX7M.cjs +1 -0
- package/dist/hocuspocus-FC5NXRLW.js +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +1 -1
- package/dist/react/hocuspocus.cjs +1 -0
- package/dist/react/hocuspocus.d.cts +104 -0
- package/dist/react/hocuspocus.d.ts +104 -0
- package/dist/react/hocuspocus.js +1 -0
- package/dist/react/index.cjs +2 -2
- package/dist/react/index.d.cts +320 -5
- package/dist/react/index.d.ts +320 -5
- package/dist/react/index.js +2 -2
- package/dist/react/webrtc.cjs +1 -0
- package/dist/react/webrtc.d.cts +98 -0
- package/dist/react/webrtc.d.ts +98 -0
- package/dist/react/webrtc.js +1 -0
- package/dist/room-id-BfudXOZz.d.cts +13 -0
- package/dist/room-id-BfudXOZz.d.ts +13 -0
- package/dist/session-BH7Qgyp6.d.cts +140 -0
- package/dist/session-BH7Qgyp6.d.ts +140 -0
- package/dist/session-okdqygLg.d.cts +82 -0
- package/dist/session-okdqygLg.d.ts +82 -0
- package/dist/vue/hocuspocus.cjs +1 -0
- package/dist/vue/hocuspocus.d.cts +105 -0
- package/dist/vue/hocuspocus.d.ts +105 -0
- package/dist/vue/hocuspocus.js +1 -0
- package/dist/vue/index.cjs +2 -2
- package/dist/vue/index.d.cts +439 -3
- package/dist/vue/index.d.ts +439 -3
- package/dist/vue/index.js +2 -2
- package/dist/vue/webrtc.cjs +1 -0
- package/dist/vue/webrtc.d.cts +99 -0
- package/dist/vue/webrtc.d.ts +99 -0
- package/dist/vue/webrtc.js +1 -0
- package/dist/webrtc-UAS5I63G.cjs +2 -0
- package/dist/webrtc-V2JQ2NO7.js +2 -0
- package/package.json +62 -7
- package/dist/chunk-4LFF2FXG.cjs +0 -1
- package/dist/chunk-TH5PXU6L.js +0 -1
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import * as Y from 'yjs';
|
|
2
|
+
import { Awareness } from 'y-protocols/awareness';
|
|
3
|
+
import { CollaborationIdentity } from '@docx-editor.dev/core/collaboration';
|
|
4
|
+
import { a as CollaborationBootstrap, c as CollaborationHandle, e as TextCollaborationSession, b as CollaborationIdentityUpdate } from './session-BH7Qgyp6.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Room-size observability.
|
|
8
|
+
*
|
|
9
|
+
* A room only grows: deletion is a tombstone, and deleted blob bytes stay in the shared blob
|
|
10
|
+
* map. The resource caps that bound hostile amplification run on every received edit and
|
|
11
|
+
* count that growth, so a long-lived room walks toward a terminal `too-many-nodes` or
|
|
12
|
+
* `blob-store-full` failure. Until compaction exists (the generation reset of issue #554),
|
|
13
|
+
* the honest interim is visibility: a host that can SEE the walk can archive and re-room
|
|
14
|
+
* before the caps end the session for it.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* One reading of a room's replicated size against this replica's hard limits.
|
|
19
|
+
*
|
|
20
|
+
* Every `max*` value is the cap whose crossing turns the session status terminal.
|
|
21
|
+
* `tombstonedNodes` is included in `nodes`: a tombstone is never map-deleted, so it keeps
|
|
22
|
+
* counting against `maxNodes` for the life of the room. A reading is a snapshot — take a new
|
|
23
|
+
* one to observe growth.
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
interface CollaborationResourceUsage {
|
|
28
|
+
/** Replicated node records, tombstones included. */
|
|
29
|
+
readonly nodes: number;
|
|
30
|
+
/** The subset of `nodes` that is tombstoned: permanent, and only compaction reclaims it. */
|
|
31
|
+
readonly tombstonedNodes: number;
|
|
32
|
+
readonly maxNodes: number;
|
|
33
|
+
readonly relationships: number;
|
|
34
|
+
readonly maxRelationships: number;
|
|
35
|
+
readonly parts: number;
|
|
36
|
+
readonly maxParts: number;
|
|
37
|
+
/** Bytes in the shared blob map, unreferenced bytes included. */
|
|
38
|
+
readonly blobBytes: number;
|
|
39
|
+
readonly maxBlobBytes: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Read a room's resource usage from a synchronized `Y.Doc`, joining nothing.
|
|
43
|
+
*
|
|
44
|
+
* The server-side sibling of `readCollaborationDocument`: call it from the same jobs — an
|
|
45
|
+
* autosave hook, a metrics scraper — to watch a room's growth against the caps that would
|
|
46
|
+
* end it. It creates no session and writes nothing, and it walks the node map once per call.
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
declare function readCollaborationResourceUsage(ydoc: Y.Doc): CollaborationResourceUsage;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Full-document collaboration over the canonical primitive journal.
|
|
54
|
+
*
|
|
55
|
+
* Local direction: the canonical store commits, emits ONE journal, and the journal is applied
|
|
56
|
+
* to shared state in one Yjs transaction. Remote direction: a shared-state change materializes
|
|
57
|
+
* one canonical package, which the port publishes as one revision. The two never chase each
|
|
58
|
+
* other, because a remote publication deliberately emits no journal.
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Full-document collaboration session.
|
|
63
|
+
*
|
|
64
|
+
* The seam matches {@link TextCollaborationSession}, plus a live display-identity update.
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
interface DocumentCollaborationSession extends TextCollaborationSession {
|
|
68
|
+
/**
|
|
69
|
+
* Update the display identity for the rest of this session and republish presence.
|
|
70
|
+
*
|
|
71
|
+
* `name` revalidates with the construction rules (trimmed, 1 to 256 characters) and an
|
|
72
|
+
* invalid value throws. `color` longer than 64 characters throws; a color
|
|
73
|
+
* `safeParticipantColor` refuses is dropped, so peers fall back to the accent color.
|
|
74
|
+
* `actorId` and `role` are immutable — the update type cannot name them, and any extra
|
|
75
|
+
* runtime property is ignored.
|
|
76
|
+
*/
|
|
77
|
+
setIdentity(update: CollaborationIdentityUpdate): void;
|
|
78
|
+
/**
|
|
79
|
+
* One reading of the room's replicated size against this replica's hard limits.
|
|
80
|
+
*
|
|
81
|
+
* A room only grows — deletion is a tombstone — and the limits that bound hostile
|
|
82
|
+
* amplification turn terminal when crossed. Watch this to archive and re-room before that
|
|
83
|
+
* happens. The tombstone count walks the node map once per call, so read it on your own
|
|
84
|
+
* schedule rather than per keystroke.
|
|
85
|
+
*/
|
|
86
|
+
resourceUsage(): CollaborationResourceUsage;
|
|
87
|
+
}
|
|
88
|
+
/** Owned full-document collaboration replica. @public */
|
|
89
|
+
type DocumentCollaborationHandle = CollaborationHandle<DocumentCollaborationSession>;
|
|
90
|
+
/**
|
|
91
|
+
* Options for one full-document collaboration replica.
|
|
92
|
+
*
|
|
93
|
+
* The caller owns `ydoc`.
|
|
94
|
+
* @public
|
|
95
|
+
*/
|
|
96
|
+
interface CreateDocumentCollaborationOptions {
|
|
97
|
+
readonly ydoc: Y.Doc;
|
|
98
|
+
readonly awareness: Awareness;
|
|
99
|
+
readonly documentId: string;
|
|
100
|
+
/** Unique attachment identity. Omit it to generate a new identity for this session. */
|
|
101
|
+
readonly sessionId?: string;
|
|
102
|
+
readonly identity: CollaborationIdentity;
|
|
103
|
+
readonly bootstrap: CollaborationBootstrap;
|
|
104
|
+
/**
|
|
105
|
+
* Admit local edits while the transport is `disconnected`.
|
|
106
|
+
*
|
|
107
|
+
* A journal applies to the local `Y.Doc` either way, so buffered offline edits merge on
|
|
108
|
+
* reconnect exactly as concurrent online edits do. Off by default: a host that shows no
|
|
109
|
+
* offline indicator would let users type into a document no peer receives yet. `error`
|
|
110
|
+
* stays terminal and `initializing` stays refused regardless of this option.
|
|
111
|
+
*/
|
|
112
|
+
readonly offlineEditing?: boolean;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Create or join one full-document collaboration replica.
|
|
117
|
+
*
|
|
118
|
+
* The caller owns `ydoc`.
|
|
119
|
+
* @public
|
|
120
|
+
*/
|
|
121
|
+
declare function createDocumentCollaboration(options: CreateDocumentCollaborationOptions): Promise<DocumentCollaborationHandle>;
|
|
122
|
+
|
|
123
|
+
export { type CreateDocumentCollaborationOptions as C, type DocumentCollaborationHandle as D, type CollaborationResourceUsage as a, type DocumentCollaborationSession as b, createDocumentCollaboration as c, readCollaborationResourceUsage as r };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkQA3F5EUJ_cjs=require('./chunk-QA3F5EUJ.cjs');Object.defineProperty(exports,"ATTACH_WATCHDOG_MS_FOR_TESTS",{enumerable:true,get:function(){return chunkQA3F5EUJ_cjs.c}});Object.defineProperty(exports,"createDocumentCollaboration",{enumerable:true,get:function(){return chunkQA3F5EUJ_cjs.d}});Object.defineProperty(exports,"readCollaborationDocument",{enumerable:true,get:function(){return chunkQA3F5EUJ_cjs.b}});
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import * as Y from 'yjs';
|
|
2
|
+
import { Awareness } from 'y-protocols/awareness';
|
|
3
|
+
import { CollaborationIdentity } from '@docx-editor.dev/core/collaboration';
|
|
4
|
+
import { a as CollaborationBootstrap, c as CollaborationHandle, e as TextCollaborationSession, b as CollaborationIdentityUpdate } from './session-BH7Qgyp6.cjs';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Room-size observability.
|
|
8
|
+
*
|
|
9
|
+
* A room only grows: deletion is a tombstone, and deleted blob bytes stay in the shared blob
|
|
10
|
+
* map. The resource caps that bound hostile amplification run on every received edit and
|
|
11
|
+
* count that growth, so a long-lived room walks toward a terminal `too-many-nodes` or
|
|
12
|
+
* `blob-store-full` failure. Until compaction exists (the generation reset of issue #554),
|
|
13
|
+
* the honest interim is visibility: a host that can SEE the walk can archive and re-room
|
|
14
|
+
* before the caps end the session for it.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* One reading of a room's replicated size against this replica's hard limits.
|
|
19
|
+
*
|
|
20
|
+
* Every `max*` value is the cap whose crossing turns the session status terminal.
|
|
21
|
+
* `tombstonedNodes` is included in `nodes`: a tombstone is never map-deleted, so it keeps
|
|
22
|
+
* counting against `maxNodes` for the life of the room. A reading is a snapshot — take a new
|
|
23
|
+
* one to observe growth.
|
|
24
|
+
*
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
interface CollaborationResourceUsage {
|
|
28
|
+
/** Replicated node records, tombstones included. */
|
|
29
|
+
readonly nodes: number;
|
|
30
|
+
/** The subset of `nodes` that is tombstoned: permanent, and only compaction reclaims it. */
|
|
31
|
+
readonly tombstonedNodes: number;
|
|
32
|
+
readonly maxNodes: number;
|
|
33
|
+
readonly relationships: number;
|
|
34
|
+
readonly maxRelationships: number;
|
|
35
|
+
readonly parts: number;
|
|
36
|
+
readonly maxParts: number;
|
|
37
|
+
/** Bytes in the shared blob map, unreferenced bytes included. */
|
|
38
|
+
readonly blobBytes: number;
|
|
39
|
+
readonly maxBlobBytes: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Read a room's resource usage from a synchronized `Y.Doc`, joining nothing.
|
|
43
|
+
*
|
|
44
|
+
* The server-side sibling of `readCollaborationDocument`: call it from the same jobs — an
|
|
45
|
+
* autosave hook, a metrics scraper — to watch a room's growth against the caps that would
|
|
46
|
+
* end it. It creates no session and writes nothing, and it walks the node map once per call.
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
declare function readCollaborationResourceUsage(ydoc: Y.Doc): CollaborationResourceUsage;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Full-document collaboration over the canonical primitive journal.
|
|
54
|
+
*
|
|
55
|
+
* Local direction: the canonical store commits, emits ONE journal, and the journal is applied
|
|
56
|
+
* to shared state in one Yjs transaction. Remote direction: a shared-state change materializes
|
|
57
|
+
* one canonical package, which the port publishes as one revision. The two never chase each
|
|
58
|
+
* other, because a remote publication deliberately emits no journal.
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Full-document collaboration session.
|
|
63
|
+
*
|
|
64
|
+
* The seam matches {@link TextCollaborationSession}, plus a live display-identity update.
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
interface DocumentCollaborationSession extends TextCollaborationSession {
|
|
68
|
+
/**
|
|
69
|
+
* Update the display identity for the rest of this session and republish presence.
|
|
70
|
+
*
|
|
71
|
+
* `name` revalidates with the construction rules (trimmed, 1 to 256 characters) and an
|
|
72
|
+
* invalid value throws. `color` longer than 64 characters throws; a color
|
|
73
|
+
* `safeParticipantColor` refuses is dropped, so peers fall back to the accent color.
|
|
74
|
+
* `actorId` and `role` are immutable — the update type cannot name them, and any extra
|
|
75
|
+
* runtime property is ignored.
|
|
76
|
+
*/
|
|
77
|
+
setIdentity(update: CollaborationIdentityUpdate): void;
|
|
78
|
+
/**
|
|
79
|
+
* One reading of the room's replicated size against this replica's hard limits.
|
|
80
|
+
*
|
|
81
|
+
* A room only grows — deletion is a tombstone — and the limits that bound hostile
|
|
82
|
+
* amplification turn terminal when crossed. Watch this to archive and re-room before that
|
|
83
|
+
* happens. The tombstone count walks the node map once per call, so read it on your own
|
|
84
|
+
* schedule rather than per keystroke.
|
|
85
|
+
*/
|
|
86
|
+
resourceUsage(): CollaborationResourceUsage;
|
|
87
|
+
}
|
|
88
|
+
/** Owned full-document collaboration replica. @public */
|
|
89
|
+
type DocumentCollaborationHandle = CollaborationHandle<DocumentCollaborationSession>;
|
|
90
|
+
/**
|
|
91
|
+
* Options for one full-document collaboration replica.
|
|
92
|
+
*
|
|
93
|
+
* The caller owns `ydoc`.
|
|
94
|
+
* @public
|
|
95
|
+
*/
|
|
96
|
+
interface CreateDocumentCollaborationOptions {
|
|
97
|
+
readonly ydoc: Y.Doc;
|
|
98
|
+
readonly awareness: Awareness;
|
|
99
|
+
readonly documentId: string;
|
|
100
|
+
/** Unique attachment identity. Omit it to generate a new identity for this session. */
|
|
101
|
+
readonly sessionId?: string;
|
|
102
|
+
readonly identity: CollaborationIdentity;
|
|
103
|
+
readonly bootstrap: CollaborationBootstrap;
|
|
104
|
+
/**
|
|
105
|
+
* Admit local edits while the transport is `disconnected`.
|
|
106
|
+
*
|
|
107
|
+
* A journal applies to the local `Y.Doc` either way, so buffered offline edits merge on
|
|
108
|
+
* reconnect exactly as concurrent online edits do. Off by default: a host that shows no
|
|
109
|
+
* offline indicator would let users type into a document no peer receives yet. `error`
|
|
110
|
+
* stays terminal and `initializing` stays refused regardless of this option.
|
|
111
|
+
*/
|
|
112
|
+
readonly offlineEditing?: boolean;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Create or join one full-document collaboration replica.
|
|
117
|
+
*
|
|
118
|
+
* The caller owns `ydoc`.
|
|
119
|
+
* @public
|
|
120
|
+
*/
|
|
121
|
+
declare function createDocumentCollaboration(options: CreateDocumentCollaborationOptions): Promise<DocumentCollaborationHandle>;
|
|
122
|
+
|
|
123
|
+
export { type CreateDocumentCollaborationOptions as C, type DocumentCollaborationHandle as D, type CollaborationResourceUsage as a, type DocumentCollaborationSession as b, createDocumentCollaboration as c, readCollaborationResourceUsage as r };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkC4RVARMI_cjs=require('./chunk-C4RVARMI.cjs');Object.defineProperty(exports,"ATTACH_WATCHDOG_MS_FOR_TESTS",{enumerable:true,get:function(){return chunkC4RVARMI_cjs.l}});Object.defineProperty(exports,"createDocumentCollaboration",{enumerable:true,get:function(){return chunkC4RVARMI_cjs.m}});Object.defineProperty(exports,"readCollaborationDocument",{enumerable:true,get:function(){return chunkC4RVARMI_cjs.k}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{l as ATTACH_WATCHDOG_MS_FOR_TESTS,m as createDocumentCollaboration,k as readCollaborationDocument}from'./chunk-KOGVHJ7U.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{c as ATTACH_WATCHDOG_MS_FOR_TESTS,d as createDocumentCollaboration,b as readCollaborationDocument}from'./chunk-DHIPX767.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkLUUFBXJ5_cjs=require('./chunk-LUUFBXJ5.cjs'),chunkQA3F5EUJ_cjs=require('./chunk-QA3F5EUJ.cjs'),P=require('yjs'),awareness=require('y-protocols/awareness'),provider=require('@hocuspocus/provider');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var P__namespace=/*#__PURE__*/_interopNamespace(P);var g=3e4,S=Symbol("createHocuspocusCollaboration.provider"),O=o=>new provider.HocuspocusProvider({url:o.url,name:o.name,document:o.document,awareness:o.awareness,...o.token!==void 0?{token:o.token}:{}});function F(o,d){return new Promise((c,e)=>{if(o.isSynced){c();return}let n=()=>{clearTimeout(s),o.off("synced",a),o.off("authenticationFailed",t);},a=()=>{n(),c();},t=r=>{n(),e(new chunkQA3F5EUJ_cjs.a("initialization-aborted",`authentication failed: ${r.reason}`));},s=setTimeout(()=>{n(),e(new chunkQA3F5EUJ_cjs.a("initialization-timeout"));},d);o.on("synced",a),o.on("authenticationFailed",t);})}async function E(o){let d=chunkLUUFBXJ5_cjs.b(o.roomId),c=o[S]??O,e=new P__namespace.Doc,n=new awareness.Awareness(e),a=()=>c({url:o.url,name:d,document:e,awareness:n,...o.token!==void 0?{token:o.token}:{}}),t=null,s=null;try{o.bootstrap.kind!=="create"&&(t=a(),await F(t,o.syncedTimeoutMs??g)),s=await chunkQA3F5EUJ_cjs.d({ydoc:e,awareness:n,documentId:d,identity:o.identity,bootstrap:o.bootstrap,offlineEditing:o.offlineEditing}),t||(t=a());}catch(i){throw s?.destroy(),t?.destroy(),n.destroy(),e.destroy(),i}let r=t,u=s,l=u.session,f=i=>{l.setTransportStatus(i.status==="connected"?"ready":"disconnected",i.status==="connected"?void 0:"transport-disconnected",i.status==="connected"?void 0:"websocket disconnected");};r.on("status",f);let p=()=>{l.setTransportStatus("error","authentication-failed");};r.on("authenticationFailed",p);let b=false;return Object.freeze({document:u.document,session:l,ydoc:e,provider:r,destroy(){b||(b=true,r.off("status",f),r.off("authenticationFailed",p),u.destroy(),r.destroy(),n.destroy(),e.destroy());}})}Object.defineProperty(exports,"createCollaborationRoomId",{enumerable:true,get:function(){return chunkLUUFBXJ5_cjs.a}});Object.defineProperty(exports,"validateRoomId",{enumerable:true,get:function(){return chunkLUUFBXJ5_cjs.b}});exports.HOCUSPOCUS_PROVIDER_FOR_TESTS=S;exports.createHocuspocusCollaboration=E;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {b}from'./chunk-6DEUT2RQ.js';export{a as createCollaborationRoomId,b as validateRoomId}from'./chunk-6DEUT2RQ.js';import {d,a}from'./chunk-DHIPX767.js';import*as P from'yjs';import {Awareness}from'y-protocols/awareness';import {HocuspocusProvider}from'@hocuspocus/provider';var g=3e4,S=Symbol("createHocuspocusCollaboration.provider"),O=o=>new HocuspocusProvider({url:o.url,name:o.name,document:o.document,awareness:o.awareness,...o.token!==void 0?{token:o.token}:{}});function F(o,d){return new Promise((c,e)=>{if(o.isSynced){c();return}let n=()=>{clearTimeout(s),o.off("synced",a$1),o.off("authenticationFailed",t);},a$1=()=>{n(),c();},t=r=>{n(),e(new a("initialization-aborted",`authentication failed: ${r.reason}`));},s=setTimeout(()=>{n(),e(new a("initialization-timeout"));},d);o.on("synced",a$1),o.on("authenticationFailed",t);})}async function E(o){let d$1=b(o.roomId),c=o[S]??O,e=new P.Doc,n=new Awareness(e),a=()=>c({url:o.url,name:d$1,document:e,awareness:n,...o.token!==void 0?{token:o.token}:{}}),t=null,s=null;try{o.bootstrap.kind!=="create"&&(t=a(),await F(t,o.syncedTimeoutMs??g)),s=await d({ydoc:e,awareness:n,documentId:d$1,identity:o.identity,bootstrap:o.bootstrap,offlineEditing:o.offlineEditing}),t||(t=a());}catch(i){throw s?.destroy(),t?.destroy(),n.destroy(),e.destroy(),i}let r=t,u=s,l=u.session,f=i=>{l.setTransportStatus(i.status==="connected"?"ready":"disconnected",i.status==="connected"?void 0:"transport-disconnected",i.status==="connected"?void 0:"websocket disconnected");};r.on("status",f);let p=()=>{l.setTransportStatus("error","authentication-failed");};r.on("authenticationFailed",p);let b$1=false;return Object.freeze({document:u.document,session:l,ydoc:e,provider:r,destroy(){b$1||(b$1=true,r.off("status",f),r.off("authenticationFailed",p),u.destroy(),r.destroy(),n.destroy(),e.destroy());}})}export{S as HOCUSPOCUS_PROVIDER_FOR_TESTS,E as createHocuspocusCollaboration};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkEMO6YTKO_cjs=require('./chunk-EMO6YTKO.cjs'),chunkQLZH2Q2C_cjs=require('./chunk-QLZH2Q2C.cjs'),store=require('@docx-editor.dev/core/store');function U(t,n={}){let r=L(t);if(!r)return [];let o=n.nodes??t.getCustomNodeDefinitions().filter(chunkEMO6YTKO_cjs.j);if(o.length===0)return [];let s=r.session.currentPackage(),d=r.session.part().name,m=n.onDiagnostic??(e=>{t.reportCustomNodeDiagnostic(e);});return r.session.storyParts().flatMap(e=>chunkEMO6YTKO_cjs.n(e,o,{payloads:store.customNodePayloadsByControl(s,e.name,d),onDiagnostic:m}))}function L(t){return t.surface??null}function E(t,n,r={}){if(r.destination==="internal")return {ok:true,bytes:t,unwrapped:0,removed:0};let o=store.readOoxmlPackage(t);if(!o.ok)return {ok:false,reason:`the document could not be read: ${o.reason}`};let s=new Map;for(let i of n)s.set(`${i.tagPrefix}:${i.name}`,i);let d=i=>{let p=chunkEMO6YTKO_cjs.c(i);if(!p)return "keep";let x=s.get(`${p.prefix}:${p.name}`);return x?x.preserveOnExport==="text"?"text":x.preserveOnExport===false?"remove":"keep":"keep"},m=[...new Set(n.filter(i=>i.preserveOnExport!==void 0).filter(i=>i.preserveOnExport!==true).map(chunkEMO6YTKO_cjs.h))],e=o.package,u=0,c=0,g=V(e);for(let i of g){let p=store.withExportedCustomNodes(e,{storyPartName:i,namespaces:[],decide:d});if(!p.ok)return {ok:false,reason:p.reason};e=p.pkg,u+=p.unwrapped,c+=p.removed;}let l=store.withExportedCustomNodes(e,{storyPartName:e.mainDocumentPart,namespaces:m,decide:()=>"keep"});return l.ok?(e=l.pkg,{ok:true,bytes:store.writeOoxmlPackage(e),unwrapped:u,removed:c}):{ok:false,reason:l.reason}}function V(t){let n=[];for(let[r,o]of t.parts)r!==t.mainDocumentPart&&store.isStoryPart(o)&&n.push(r);return [t.mainDocumentPart,...n]}async function G(t,n={}){let r=n.nodes??t.getCustomNodeDefinitions().filter(chunkEMO6YTKO_cjs.j),o=await t.save();return E(new Uint8Array(o),r,{...n.destination===void 0?{}:{destination:n.destination}})}function a(t){return t.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function K(t,n,r,o={}){if(!chunkEMO6YTKO_cjs.k.test(t.tagPrefix)||!chunkEMO6YTKO_cjs.k.test(t.name))return {ok:false,code:"invalidArgs",reason:"the definition identity must match defineCustomNode\u2019s charset ([A-Za-z0-9_.-])"};let s=chunkEMO6YTKO_cjs.b(t.tagPrefix,t.name,n);if(!s.ok)return {ok:false,code:"invalidArgs",reason:`the encoded tag is ${s.length} characters; Word caps w:tag at 64 \u2014 shorten the attrs`};let d=o.lock===void 0?"contentLocked":o.lock,m=o.id!==void 0&&Number.isInteger(o.id)&&o.id>0?o.id:store.fnv1a32(`${s.tag}\0${r}`)&2147483647||1,e=o.data===void 0?null:Q(t,o,r);if(e&&"reason"in e)return {ok:false,code:"invalidArgs",reason:e.reason};let u=(o.alias!==void 0?`<w:alias w:val="${a(o.alias)}"/>`:"")+`<w:tag w:val="${a(s.tag)}"/><w:id w:val="${m}"/>`+(d===false?"":`<w:lock w:val="${d}"/>`)+(e?`<w:dataBinding w:prefixMappings="${a(e.binding.prefixMappings)}" w:xpath="${a(e.binding.xpath)}" w:storeItemID="${a(e.binding.storeItemId)}"/>`:""),c=`<w:r><w:t xml:space="preserve">${a(r)}</w:t></w:r>`;return {ok:true,xml:`<w:sdt><w:sdtPr>${u}</w:sdtPr><w:sdtContent>${c}</w:sdtContent></w:sdt>`,...e?{store:e.store}:{}}}function Q(t,n,r){let o=chunkEMO6YTKO_cjs.i(t,n.data);if(!o.ok)return {reason:o.reason};let s=chunkEMO6YTKO_cjs.h(t),d=n.storeIndex!==void 0&&Number.isInteger(n.storeIndex)&&n.storeIndex>0?n.storeIndex:1,m=n.nodeId??"cx1",e=`/customXml/item${String(d)}.xml`,u=`/customXml/itemProps${String(d)}.xml`,c=store.datastoreItemIdFor(`${s} ${e} ${m}`),g=store.customNodeBinding({partName:e,propsPartName:u,itemId:c,namespaceUri:s},chunkEMO6YTKO_cjs.g,m);if(!g)return {reason:`the payload cannot be addressed by an XPath: check nodeId (${m}) and payloadNamespace`};let l=r===r.trim()?`<label>${a(r)}</label>`:`<label xml:space="preserve">${a(r)}</label>`;return {binding:g,store:{itemPartName:e,itemXml:`<${chunkEMO6YTKO_cjs.g} xmlns="${a(s)}"><node id="${a(m)}">${l}<data>${a(o.data)}</data></node></${chunkEMO6YTKO_cjs.g}>`,propsPartName:u,propsXml:`<ds:datastoreItem ds:itemID="${a(c)}" xmlns:ds="${store.DATASTORE_NAMESPACE_URI}"><ds:schemaRefs><ds:schemaRef ds:uri="${a(s)}"/></ds:schemaRefs></ds:datastoreItem>`,storeItemId:c,relationships:[{from:"/word/document.xml",type:store.CUSTOM_XML_REL,target:`../customXml/item${String(d)}.xml`},{from:e,type:store.CUSTOM_XML_PROPS_REL,target:`itemProps${String(d)}.xml`}],contentTypeOverride:{partName:u,contentType:store.CUSTOM_XML_PROPS_TYPE}}}}Object.defineProperty(exports,"CUSTOM_NODE_STORE_ROOT",{enumerable:true,get:function(){return chunkEMO6YTKO_cjs.g}});Object.defineProperty(exports,"MAX_CUSTOM_NODE_DATA_LENGTH",{enumerable:true,get:function(){return chunkEMO6YTKO_cjs.d}});Object.defineProperty(exports,"MAX_TAG_LENGTH",{enumerable:true,get:function(){return chunkEMO6YTKO_cjs.a}});Object.defineProperty(exports,"customNodeNamespace",{enumerable:true,get:function(){return chunkEMO6YTKO_cjs.h}});Object.defineProperty(exports,"customNodesModule",{enumerable:true,get:function(){return chunkEMO6YTKO_cjs.m}});Object.defineProperty(exports,"decodeCustomNodeTag",{enumerable:true,get:function(){return chunkEMO6YTKO_cjs.c}});Object.defineProperty(exports,"defineCustomNode",{enumerable:true,get:function(){return chunkEMO6YTKO_cjs.l}});Object.defineProperty(exports,"encodeCustomNodeTag",{enumerable:true,get:function(){return chunkEMO6YTKO_cjs.b}});Object.defineProperty(exports,"insertCustomNode",{enumerable:true,get:function(){return chunkEMO6YTKO_cjs.p}});Object.defineProperty(exports,"isCustomNodeDefinition",{enumerable:true,get:function(){return chunkEMO6YTKO_cjs.j}});Object.defineProperty(exports,"parseCustomNodeData",{enumerable:true,get:function(){return chunkEMO6YTKO_cjs.e}});Object.defineProperty(exports,"recognizeCustomNodes",{enumerable:true,get:function(){return chunkEMO6YTKO_cjs.n}});Object.defineProperty(exports,"removeCustomNode",{enumerable:true,get:function(){return chunkEMO6YTKO_cjs.q}});Object.defineProperty(exports,"reviewModule",{enumerable:true,get:function(){return chunkEMO6YTKO_cjs.o}});Object.defineProperty(exports,"serializeCustomNodeData",{enumerable:true,get:function(){return chunkEMO6YTKO_cjs.f}});Object.defineProperty(exports,"updateCustomNode",{enumerable:true,get:function(){return chunkEMO6YTKO_cjs.r}});Object.defineProperty(exports,"collaborationModule",{enumerable:true,get:function(){return chunkQLZH2Q2C_cjs.b}});exports.customNodeXml=K;exports.customNodesOf=U;exports.prepareForExport=E;exports.saveForExport=G;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { A as AnyCustomNodeDefinition, C as CustomNodeDiagnostic, R as RecognizedCustomNode, S as StandardSchemaV1, I as InferSchemaInput, a as CustomNodeDefinition } from './define-custom-node-
|
|
2
|
-
export { b as ActivatedCustomNode, c as CustomNode, d as CustomNodeDataRejection, e as CustomNodeDataResult, f as CustomNodePayloadSource, g as CustomNodesModuleOptions, h as InferSchemaOutput, M as MAX_CUSTOM_NODE_DATA_LENGTH,
|
|
1
|
+
import { A as AnyCustomNodeDefinition, C as CustomNodeDiagnostic, R as RecognizedCustomNode, S as StandardSchemaV1, I as InferSchemaInput, a as CustomNodeDefinition } from './define-custom-node-B_p2nr9T.cjs';
|
|
2
|
+
export { b as ActivatedCustomNode, c as CustomNode, d as CustomNodeDataRejection, e as CustomNodeDataResult, f as CustomNodePayloadSource, g as CustomNodesModuleOptions, h as InferSchemaOutput, M as MAX_CUSTOM_NODE_DATA_LENGTH, i as RecognizeCustomNodesOptions, j as ReviewModuleOptions, k as StandardSchemaIssue, l as StandardSchemaResult, m as customNodesModule, n as defineCustomNode, o as isCustomNodeDefinition, p as parseCustomNodeData, r as recognizeCustomNodes, q as reviewModule, s as serializeCustomNodeData } from './define-custom-node-B_p2nr9T.cjs';
|
|
3
|
+
export { C as CollaborationModuleOptions, P as ProLicenseOptions, c as collaborationModule } from './collaboration-module-BgRxhW5b.cjs';
|
|
3
4
|
import { Editor, ExecResult } from '@docx-editor.dev/core/contracts/editor';
|
|
4
5
|
import '@docx-editor.dev/core/editor';
|
|
5
6
|
import '@docx-editor.dev/core/store';
|
|
7
|
+
import '@docx-editor.dev/core/collaboration';
|
|
6
8
|
|
|
7
9
|
/** How {@link customNodesOf} narrows what it answers. */
|
|
8
10
|
interface CustomNodesOfOptions {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { A as AnyCustomNodeDefinition, C as CustomNodeDiagnostic, R as RecognizedCustomNode, S as StandardSchemaV1, I as InferSchemaInput, a as CustomNodeDefinition } from './define-custom-node-
|
|
2
|
-
export { b as ActivatedCustomNode, c as CustomNode, d as CustomNodeDataRejection, e as CustomNodeDataResult, f as CustomNodePayloadSource, g as CustomNodesModuleOptions, h as InferSchemaOutput, M as MAX_CUSTOM_NODE_DATA_LENGTH,
|
|
1
|
+
import { A as AnyCustomNodeDefinition, C as CustomNodeDiagnostic, R as RecognizedCustomNode, S as StandardSchemaV1, I as InferSchemaInput, a as CustomNodeDefinition } from './define-custom-node-BehI3jWX.js';
|
|
2
|
+
export { b as ActivatedCustomNode, c as CustomNode, d as CustomNodeDataRejection, e as CustomNodeDataResult, f as CustomNodePayloadSource, g as CustomNodesModuleOptions, h as InferSchemaOutput, M as MAX_CUSTOM_NODE_DATA_LENGTH, i as RecognizeCustomNodesOptions, j as ReviewModuleOptions, k as StandardSchemaIssue, l as StandardSchemaResult, m as customNodesModule, n as defineCustomNode, o as isCustomNodeDefinition, p as parseCustomNodeData, r as recognizeCustomNodes, q as reviewModule, s as serializeCustomNodeData } from './define-custom-node-BehI3jWX.js';
|
|
3
|
+
export { C as CollaborationModuleOptions, P as ProLicenseOptions, c as collaborationModule } from './collaboration-module-BgRxhW5b.js';
|
|
3
4
|
import { Editor, ExecResult } from '@docx-editor.dev/core/contracts/editor';
|
|
4
5
|
import '@docx-editor.dev/core/editor';
|
|
5
6
|
import '@docx-editor.dev/core/store';
|
|
7
|
+
import '@docx-editor.dev/core/collaboration';
|
|
6
8
|
|
|
7
9
|
/** How {@link customNodesOf} narrows what it answers. */
|
|
8
10
|
interface CustomNodesOfOptions {
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {j,n,h,k,b
|
|
1
|
+
import {j,n,h,k,b,i,g,c}from'./chunk-NQW54J56.js';export{g as CUSTOM_NODE_STORE_ROOT,d as MAX_CUSTOM_NODE_DATA_LENGTH,a as MAX_TAG_LENGTH,h as customNodeNamespace,m as customNodesModule,c as decodeCustomNodeTag,l as defineCustomNode,b as encodeCustomNodeTag,p as insertCustomNode,j as isCustomNodeDefinition,e as parseCustomNodeData,n as recognizeCustomNodes,q as removeCustomNode,o as reviewModule,f as serializeCustomNodeData,r as updateCustomNode}from'./chunk-NQW54J56.js';export{b as collaborationModule}from'./chunk-Q2VBO66F.js';import {customNodePayloadsByControl,readOoxmlPackage,withExportedCustomNodes,writeOoxmlPackage,isStoryPart,fnv1a32,datastoreItemIdFor,customNodeBinding,CUSTOM_XML_PROPS_TYPE,CUSTOM_XML_REL,CUSTOM_XML_PROPS_REL,DATASTORE_NAMESPACE_URI}from'@docx-editor.dev/core/store';function U(t,n$1={}){let r=L(t);if(!r)return [];let o=n$1.nodes??t.getCustomNodeDefinitions().filter(j);if(o.length===0)return [];let s=r.session.currentPackage(),d=r.session.part().name,m=n$1.onDiagnostic??(e=>{t.reportCustomNodeDiagnostic(e);});return r.session.storyParts().flatMap(e=>n(e,o,{payloads:customNodePayloadsByControl(s,e.name,d),onDiagnostic:m}))}function L(t){return t.surface??null}function E(t,n,r={}){if(r.destination==="internal")return {ok:true,bytes:t,unwrapped:0,removed:0};let o=readOoxmlPackage(t);if(!o.ok)return {ok:false,reason:`the document could not be read: ${o.reason}`};let s=new Map;for(let i of n)s.set(`${i.tagPrefix}:${i.name}`,i);let d=i=>{let p=c(i);if(!p)return "keep";let x=s.get(`${p.prefix}:${p.name}`);return x?x.preserveOnExport==="text"?"text":x.preserveOnExport===false?"remove":"keep":"keep"},m=[...new Set(n.filter(i=>i.preserveOnExport!==void 0).filter(i=>i.preserveOnExport!==true).map(h))],e=o.package,u=0,c$1=0,g=V(e);for(let i of g){let p=withExportedCustomNodes(e,{storyPartName:i,namespaces:[],decide:d});if(!p.ok)return {ok:false,reason:p.reason};e=p.pkg,u+=p.unwrapped,c$1+=p.removed;}let l=withExportedCustomNodes(e,{storyPartName:e.mainDocumentPart,namespaces:m,decide:()=>"keep"});return l.ok?(e=l.pkg,{ok:true,bytes:writeOoxmlPackage(e),unwrapped:u,removed:c$1}):{ok:false,reason:l.reason}}function V(t){let n=[];for(let[r,o]of t.parts)r!==t.mainDocumentPart&&isStoryPart(o)&&n.push(r);return [t.mainDocumentPart,...n]}async function G(t,n={}){let r=n.nodes??t.getCustomNodeDefinitions().filter(j),o=await t.save();return E(new Uint8Array(o),r,{...n.destination===void 0?{}:{destination:n.destination}})}function a(t){return t.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function K(t,n,r,o={}){if(!k.test(t.tagPrefix)||!k.test(t.name))return {ok:false,code:"invalidArgs",reason:"the definition identity must match defineCustomNode\u2019s charset ([A-Za-z0-9_.-])"};let s=b(t.tagPrefix,t.name,n);if(!s.ok)return {ok:false,code:"invalidArgs",reason:`the encoded tag is ${s.length} characters; Word caps w:tag at 64 \u2014 shorten the attrs`};let d=o.lock===void 0?"contentLocked":o.lock,m=o.id!==void 0&&Number.isInteger(o.id)&&o.id>0?o.id:fnv1a32(`${s.tag}\0${r}`)&2147483647||1,e=o.data===void 0?null:Q(t,o,r);if(e&&"reason"in e)return {ok:false,code:"invalidArgs",reason:e.reason};let u=(o.alias!==void 0?`<w:alias w:val="${a(o.alias)}"/>`:"")+`<w:tag w:val="${a(s.tag)}"/><w:id w:val="${m}"/>`+(d===false?"":`<w:lock w:val="${d}"/>`)+(e?`<w:dataBinding w:prefixMappings="${a(e.binding.prefixMappings)}" w:xpath="${a(e.binding.xpath)}" w:storeItemID="${a(e.binding.storeItemId)}"/>`:""),c=`<w:r><w:t xml:space="preserve">${a(r)}</w:t></w:r>`;return {ok:true,xml:`<w:sdt><w:sdtPr>${u}</w:sdtPr><w:sdtContent>${c}</w:sdtContent></w:sdt>`,...e?{store:e.store}:{}}}function Q(t,n,r){let o=i(t,n.data);if(!o.ok)return {reason:o.reason};let s=h(t),d=n.storeIndex!==void 0&&Number.isInteger(n.storeIndex)&&n.storeIndex>0?n.storeIndex:1,m=n.nodeId??"cx1",e=`/customXml/item${String(d)}.xml`,u=`/customXml/itemProps${String(d)}.xml`,c=datastoreItemIdFor(`${s} ${e} ${m}`),g$1=customNodeBinding({partName:e,propsPartName:u,itemId:c,namespaceUri:s},g,m);if(!g$1)return {reason:`the payload cannot be addressed by an XPath: check nodeId (${m}) and payloadNamespace`};let l=r===r.trim()?`<label>${a(r)}</label>`:`<label xml:space="preserve">${a(r)}</label>`;return {binding:g$1,store:{itemPartName:e,itemXml:`<${g} xmlns="${a(s)}"><node id="${a(m)}">${l}<data>${a(o.data)}</data></node></${g}>`,propsPartName:u,propsXml:`<ds:datastoreItem ds:itemID="${a(c)}" xmlns:ds="${DATASTORE_NAMESPACE_URI}"><ds:schemaRefs><ds:schemaRef ds:uri="${a(s)}"/></ds:schemaRefs></ds:datastoreItem>`,storeItemId:c,relationships:[{from:"/word/document.xml",type:CUSTOM_XML_REL,target:`../customXml/item${String(d)}.xml`},{from:e,type:CUSTOM_XML_PROPS_REL,target:`itemProps${String(d)}.xml`}],contentTypeOverride:{partName:u,contentType:CUSTOM_XML_PROPS_TYPE}}}}export{K as customNodeXml,U as customNodesOf,E as prepareForExport,G as saveForExport};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunkGDTCNTK7_cjs=require('../chunk-GDTCNTK7.cjs');require('../chunk-QLZH2Q2C.cjs');var react=require('react');var i=Symbol("useHocuspocusCollaboration.createRoom");function u(o){return o?`${o.url}:${o.roomId}:${o.bootstrap.kind}:${o.identity.actorId}`:""}async function c(o){let{createHocuspocusCollaboration:n}=await import('../collaboration/hocuspocus.cjs');return n(o)}function p(o){return o[i]??c}function d(o={}){let n=react.useId(),e=chunkGDTCNTK7_cjs.b({ownerKey:`react-hocuspocus:${n}`,hookName:"useHocuspocusCollaboration",createRoom:p(o),hostModules:o.modules??chunkGDTCNTK7_cjs.a,autoRoom:o.room??null,autoKey:u(o.room??null),rejoinOptionsOf:t=>({...t,bootstrap:{kind:"join"}}),identityOf:t=>t.identity});return react.useMemo(()=>({document:e.document,modules:e.modules,session:e.session,ydoc:e.room?.ydoc??null,provider:e.room?.provider??null,pending:e.pending,error:e.error,connect:e.connect,leave:e.leave,rejoin:e.rejoin}),[e])}exports.useHocuspocusCollaboration=d;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import * as Y from 'yjs';
|
|
2
|
+
import { HocuspocusProvider } from '@hocuspocus/provider';
|
|
3
|
+
import { CollaborationIdentity, CollaborationFailure } from '@docx-editor.dev/core/collaboration';
|
|
4
|
+
import { EditorModule } from '@docx-editor.dev/core/editor';
|
|
5
|
+
import { a as CollaborationBootstrap, C as CollaborationSession } from '../session-BH7Qgyp6.cjs';
|
|
6
|
+
export { b as CollaborationIdentityUpdate } from '../session-BH7Qgyp6.cjs';
|
|
7
|
+
import 'y-protocols/awareness';
|
|
8
|
+
|
|
9
|
+
/** Bootstrap for one Hocuspocus room. @public */
|
|
10
|
+
type UseHocuspocusCollaborationBootstrap = CollaborationBootstrap;
|
|
11
|
+
/** Arguments for {@link UseHocuspocusCollaborationReturn.connect}. @public */
|
|
12
|
+
interface UseHocuspocusCollaborationConnectOptions {
|
|
13
|
+
/** Hocuspocus server WebSocket URL, for example `wss://collab.example.test`. */
|
|
14
|
+
readonly url: string;
|
|
15
|
+
readonly roomId: string;
|
|
16
|
+
/**
|
|
17
|
+
* Authentication token the provider sends in its auth handshake. Pass a callback and the
|
|
18
|
+
* provider re-evaluates it on every reconnect, which is how expiring JWTs renew.
|
|
19
|
+
*/
|
|
20
|
+
readonly token?: string | (() => string | Promise<string>);
|
|
21
|
+
readonly identity: CollaborationIdentity;
|
|
22
|
+
readonly bootstrap: UseHocuspocusCollaborationBootstrap;
|
|
23
|
+
/** Bound on the wait for the server's initial sync. Default 30000 ms. */
|
|
24
|
+
readonly syncedTimeoutMs?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Admit local edits while the transport is `disconnected`. Buffered updates merge on
|
|
27
|
+
* reconnect. See {@link CreateDocumentCollaborationOptions.offlineEditing}.
|
|
28
|
+
*/
|
|
29
|
+
readonly offlineEditing?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** Input for {@link useHocuspocusCollaboration}. @public */
|
|
32
|
+
interface UseHocuspocusCollaborationOptions {
|
|
33
|
+
/**
|
|
34
|
+
* Host modules. The hook adds `collaborationModule` when a room is ready.
|
|
35
|
+
* A host collaboration contribution is a configuration error and throws.
|
|
36
|
+
*/
|
|
37
|
+
readonly modules?: readonly EditorModule[];
|
|
38
|
+
/**
|
|
39
|
+
* Connect this room on mount. Omit it and call
|
|
40
|
+
* {@link UseHocuspocusCollaborationReturn.connect} after the user chooses a room.
|
|
41
|
+
*/
|
|
42
|
+
readonly room?: UseHocuspocusCollaborationConnectOptions | null;
|
|
43
|
+
}
|
|
44
|
+
/** Values {@link useHocuspocusCollaboration} returns. @public */
|
|
45
|
+
interface UseHocuspocusCollaborationReturn {
|
|
46
|
+
readonly document: Uint8Array | null;
|
|
47
|
+
readonly modules: readonly EditorModule[];
|
|
48
|
+
readonly session: CollaborationSession | null;
|
|
49
|
+
/**
|
|
50
|
+
* The room's shared Yjs document, owned by the hook. Null while no room is connected.
|
|
51
|
+
*
|
|
52
|
+
* Read-only escape hatch: observe it or wire additional providers, but leave teardown to
|
|
53
|
+
* the hook.
|
|
54
|
+
*/
|
|
55
|
+
readonly ydoc: Y.Doc | null;
|
|
56
|
+
/**
|
|
57
|
+
* The owned `@hocuspocus/provider` instance. Null while no room is connected.
|
|
58
|
+
*
|
|
59
|
+
* Read-only escape hatch for transport-level access (`disconnect()`/`connect()`,
|
|
60
|
+
* server events). The hook destroys it on leave and unmount.
|
|
61
|
+
*/
|
|
62
|
+
readonly provider: HocuspocusProvider | null;
|
|
63
|
+
readonly pending: boolean;
|
|
64
|
+
readonly error: CollaborationFailure | null;
|
|
65
|
+
/**
|
|
66
|
+
* Connect a room. RESOLVES with the failure, or null on success — it does not reject.
|
|
67
|
+
*
|
|
68
|
+
* A rejection carried nothing the resolved value does not, and it made the ordinary call
|
|
69
|
+
* site wrong by default: `onClick={() => connect(options)}` produced an unhandled rejection
|
|
70
|
+
* on every failed connect. `error` reports the same failure for renderers.
|
|
71
|
+
*/
|
|
72
|
+
readonly connect: (options: UseHocuspocusCollaborationConnectOptions) => Promise<CollaborationFailure | null>;
|
|
73
|
+
/**
|
|
74
|
+
* Destroy the room and carry on editing locally.
|
|
75
|
+
*
|
|
76
|
+
* The current bytes live in the editor, not in this hook, so the argument is required:
|
|
77
|
+
* pass `await editor.save()` to keep what the room typed. The hook remounts the editor
|
|
78
|
+
* from exactly these bytes.
|
|
79
|
+
*/
|
|
80
|
+
readonly leave: (nextDocument: Uint8Array) => void;
|
|
81
|
+
/**
|
|
82
|
+
* Recover a session that reached status `error`: leave with `nextDocument`, then connect
|
|
83
|
+
* again to the same room with the same identity, url, and token.
|
|
84
|
+
*
|
|
85
|
+
* The reconnect always uses bootstrap `{ kind: 'join' }`, because the server still holds
|
|
86
|
+
* the room. When the server no longer holds it, the join rejects with
|
|
87
|
+
* `initialization-timeout` — nothing is lost, because `nextDocument` (your saved bytes)
|
|
88
|
+
* stays mounted locally. A connect that failed also counts as the prior attempt, so
|
|
89
|
+
* rejoin retries it as a joiner.
|
|
90
|
+
*/
|
|
91
|
+
readonly rejoin: (nextDocument: Uint8Array) => Promise<CollaborationFailure | null>;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Own a Hocuspocus collaboration room for a React host.
|
|
95
|
+
*
|
|
96
|
+
* The default Pro React entry does not import this hook. Import it from
|
|
97
|
+
* `@docx-editor.dev/pro/react/hocuspocus` so a review-only bundle does not load
|
|
98
|
+
* a network provider.
|
|
99
|
+
*
|
|
100
|
+
* @public
|
|
101
|
+
*/
|
|
102
|
+
declare function useHocuspocusCollaboration(options?: UseHocuspocusCollaborationOptions): UseHocuspocusCollaborationReturn;
|
|
103
|
+
|
|
104
|
+
export { CollaborationSession, type UseHocuspocusCollaborationBootstrap, type UseHocuspocusCollaborationConnectOptions, type UseHocuspocusCollaborationOptions, type UseHocuspocusCollaborationReturn, useHocuspocusCollaboration };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import * as Y from 'yjs';
|
|
2
|
+
import { HocuspocusProvider } from '@hocuspocus/provider';
|
|
3
|
+
import { CollaborationIdentity, CollaborationFailure } from '@docx-editor.dev/core/collaboration';
|
|
4
|
+
import { EditorModule } from '@docx-editor.dev/core/editor';
|
|
5
|
+
import { a as CollaborationBootstrap, C as CollaborationSession } from '../session-BH7Qgyp6.js';
|
|
6
|
+
export { b as CollaborationIdentityUpdate } from '../session-BH7Qgyp6.js';
|
|
7
|
+
import 'y-protocols/awareness';
|
|
8
|
+
|
|
9
|
+
/** Bootstrap for one Hocuspocus room. @public */
|
|
10
|
+
type UseHocuspocusCollaborationBootstrap = CollaborationBootstrap;
|
|
11
|
+
/** Arguments for {@link UseHocuspocusCollaborationReturn.connect}. @public */
|
|
12
|
+
interface UseHocuspocusCollaborationConnectOptions {
|
|
13
|
+
/** Hocuspocus server WebSocket URL, for example `wss://collab.example.test`. */
|
|
14
|
+
readonly url: string;
|
|
15
|
+
readonly roomId: string;
|
|
16
|
+
/**
|
|
17
|
+
* Authentication token the provider sends in its auth handshake. Pass a callback and the
|
|
18
|
+
* provider re-evaluates it on every reconnect, which is how expiring JWTs renew.
|
|
19
|
+
*/
|
|
20
|
+
readonly token?: string | (() => string | Promise<string>);
|
|
21
|
+
readonly identity: CollaborationIdentity;
|
|
22
|
+
readonly bootstrap: UseHocuspocusCollaborationBootstrap;
|
|
23
|
+
/** Bound on the wait for the server's initial sync. Default 30000 ms. */
|
|
24
|
+
readonly syncedTimeoutMs?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Admit local edits while the transport is `disconnected`. Buffered updates merge on
|
|
27
|
+
* reconnect. See {@link CreateDocumentCollaborationOptions.offlineEditing}.
|
|
28
|
+
*/
|
|
29
|
+
readonly offlineEditing?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** Input for {@link useHocuspocusCollaboration}. @public */
|
|
32
|
+
interface UseHocuspocusCollaborationOptions {
|
|
33
|
+
/**
|
|
34
|
+
* Host modules. The hook adds `collaborationModule` when a room is ready.
|
|
35
|
+
* A host collaboration contribution is a configuration error and throws.
|
|
36
|
+
*/
|
|
37
|
+
readonly modules?: readonly EditorModule[];
|
|
38
|
+
/**
|
|
39
|
+
* Connect this room on mount. Omit it and call
|
|
40
|
+
* {@link UseHocuspocusCollaborationReturn.connect} after the user chooses a room.
|
|
41
|
+
*/
|
|
42
|
+
readonly room?: UseHocuspocusCollaborationConnectOptions | null;
|
|
43
|
+
}
|
|
44
|
+
/** Values {@link useHocuspocusCollaboration} returns. @public */
|
|
45
|
+
interface UseHocuspocusCollaborationReturn {
|
|
46
|
+
readonly document: Uint8Array | null;
|
|
47
|
+
readonly modules: readonly EditorModule[];
|
|
48
|
+
readonly session: CollaborationSession | null;
|
|
49
|
+
/**
|
|
50
|
+
* The room's shared Yjs document, owned by the hook. Null while no room is connected.
|
|
51
|
+
*
|
|
52
|
+
* Read-only escape hatch: observe it or wire additional providers, but leave teardown to
|
|
53
|
+
* the hook.
|
|
54
|
+
*/
|
|
55
|
+
readonly ydoc: Y.Doc | null;
|
|
56
|
+
/**
|
|
57
|
+
* The owned `@hocuspocus/provider` instance. Null while no room is connected.
|
|
58
|
+
*
|
|
59
|
+
* Read-only escape hatch for transport-level access (`disconnect()`/`connect()`,
|
|
60
|
+
* server events). The hook destroys it on leave and unmount.
|
|
61
|
+
*/
|
|
62
|
+
readonly provider: HocuspocusProvider | null;
|
|
63
|
+
readonly pending: boolean;
|
|
64
|
+
readonly error: CollaborationFailure | null;
|
|
65
|
+
/**
|
|
66
|
+
* Connect a room. RESOLVES with the failure, or null on success — it does not reject.
|
|
67
|
+
*
|
|
68
|
+
* A rejection carried nothing the resolved value does not, and it made the ordinary call
|
|
69
|
+
* site wrong by default: `onClick={() => connect(options)}` produced an unhandled rejection
|
|
70
|
+
* on every failed connect. `error` reports the same failure for renderers.
|
|
71
|
+
*/
|
|
72
|
+
readonly connect: (options: UseHocuspocusCollaborationConnectOptions) => Promise<CollaborationFailure | null>;
|
|
73
|
+
/**
|
|
74
|
+
* Destroy the room and carry on editing locally.
|
|
75
|
+
*
|
|
76
|
+
* The current bytes live in the editor, not in this hook, so the argument is required:
|
|
77
|
+
* pass `await editor.save()` to keep what the room typed. The hook remounts the editor
|
|
78
|
+
* from exactly these bytes.
|
|
79
|
+
*/
|
|
80
|
+
readonly leave: (nextDocument: Uint8Array) => void;
|
|
81
|
+
/**
|
|
82
|
+
* Recover a session that reached status `error`: leave with `nextDocument`, then connect
|
|
83
|
+
* again to the same room with the same identity, url, and token.
|
|
84
|
+
*
|
|
85
|
+
* The reconnect always uses bootstrap `{ kind: 'join' }`, because the server still holds
|
|
86
|
+
* the room. When the server no longer holds it, the join rejects with
|
|
87
|
+
* `initialization-timeout` — nothing is lost, because `nextDocument` (your saved bytes)
|
|
88
|
+
* stays mounted locally. A connect that failed also counts as the prior attempt, so
|
|
89
|
+
* rejoin retries it as a joiner.
|
|
90
|
+
*/
|
|
91
|
+
readonly rejoin: (nextDocument: Uint8Array) => Promise<CollaborationFailure | null>;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Own a Hocuspocus collaboration room for a React host.
|
|
95
|
+
*
|
|
96
|
+
* The default Pro React entry does not import this hook. Import it from
|
|
97
|
+
* `@docx-editor.dev/pro/react/hocuspocus` so a review-only bundle does not load
|
|
98
|
+
* a network provider.
|
|
99
|
+
*
|
|
100
|
+
* @public
|
|
101
|
+
*/
|
|
102
|
+
declare function useHocuspocusCollaboration(options?: UseHocuspocusCollaborationOptions): UseHocuspocusCollaborationReturn;
|
|
103
|
+
|
|
104
|
+
export { CollaborationSession, type UseHocuspocusCollaborationBootstrap, type UseHocuspocusCollaborationConnectOptions, type UseHocuspocusCollaborationOptions, type UseHocuspocusCollaborationReturn, useHocuspocusCollaboration };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import {b,a}from'../chunk-HJB77VBO.js';import'../chunk-Q2VBO66F.js';import {useId,useMemo}from'react';var i=Symbol("useHocuspocusCollaboration.createRoom");function u(o){return o?`${o.url}:${o.roomId}:${o.bootstrap.kind}:${o.identity.actorId}`:""}async function c(o){let{createHocuspocusCollaboration:n}=await import('../collaboration/hocuspocus.js');return n(o)}function p(o){return o[i]??c}function d(o={}){let n=useId(),e=b({ownerKey:`react-hocuspocus:${n}`,hookName:"useHocuspocusCollaboration",createRoom:p(o),hostModules:o.modules??a,autoRoom:o.room??null,autoKey:u(o.room??null),rejoinOptionsOf:t=>({...t,bootstrap:{kind:"join"}}),identityOf:t=>t.identity});return useMemo(()=>({document:e.document,modules:e.modules,session:e.session,ydoc:e.room?.ydoc??null,provider:e.room?.provider??null,pending:e.pending,error:e.error,connect:e.connect,leave:e.leave,rejoin:e.rejoin}),[e])}export{d as useHocuspocusCollaboration};
|