@docx-editor.dev/pro 2.10.0 → 2.11.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.
Files changed (78) hide show
  1. package/README.md +1 -7
  2. package/dist/chunk-32RB7HPL.js +3 -0
  3. package/dist/chunk-4HGT2OVX.cjs +3 -0
  4. package/dist/chunk-6DEUT2RQ.js +1 -0
  5. package/dist/chunk-7QSJBMZV.js +3 -0
  6. package/dist/chunk-EMO6YTKO.cjs +1 -0
  7. package/dist/chunk-GDTCNTK7.cjs +1 -0
  8. package/dist/chunk-HJB77VBO.js +1 -0
  9. package/dist/chunk-LUUFBXJ5.cjs +1 -0
  10. package/dist/chunk-NQW54J56.js +1 -0
  11. package/dist/chunk-Q2VBO66F.js +1 -0
  12. package/dist/chunk-Q4YPX2DT.cjs +1 -0
  13. package/dist/chunk-QLZH2Q2C.cjs +1 -0
  14. package/dist/chunk-W3V54DWZ.js +1 -0
  15. package/dist/chunk-YJM6R76M.cjs +3 -0
  16. package/dist/collaboration/hocuspocus.cjs +1 -0
  17. package/dist/collaboration/hocuspocus.d.cts +58 -0
  18. package/dist/collaboration/hocuspocus.d.ts +58 -0
  19. package/dist/collaboration/hocuspocus.js +1 -0
  20. package/dist/collaboration/index.cjs +2 -0
  21. package/dist/collaboration/index.d.cts +22 -0
  22. package/dist/collaboration/index.d.ts +22 -0
  23. package/dist/collaboration/index.js +2 -0
  24. package/dist/collaboration/webrtc.cjs +2 -0
  25. package/dist/collaboration/webrtc.d.cts +86 -0
  26. package/dist/collaboration/webrtc.d.ts +86 -0
  27. package/dist/collaboration/webrtc.js +2 -0
  28. package/dist/collaboration-module-BgRxhW5b.d.cts +45 -0
  29. package/dist/collaboration-module-BgRxhW5b.d.ts +45 -0
  30. package/dist/{define-custom-node-Bk8kFO27.d.cts → define-custom-node-B_p2nr9T.d.cts} +2 -20
  31. package/dist/{define-custom-node-Bk8kFO27.d.ts → define-custom-node-BehI3jWX.d.ts} +2 -20
  32. package/dist/document-session-2B3QFWBQ.cjs +1 -0
  33. package/dist/document-session-6UET6BWT.js +1 -0
  34. package/dist/document-session-DVa53DAw.d.cts +94 -0
  35. package/dist/document-session-DiBuzWwA.d.ts +94 -0
  36. package/dist/document-session-RGNZHMWF.js +1 -0
  37. package/dist/document-session-TU7WVBRB.cjs +1 -0
  38. package/dist/hocuspocus-EUC4BGDD.js +1 -0
  39. package/dist/hocuspocus-YIKH6ENE.cjs +1 -0
  40. package/dist/index.cjs +1 -1
  41. package/dist/index.d.cts +4 -2
  42. package/dist/index.d.ts +4 -2
  43. package/dist/index.js +1 -1
  44. package/dist/react/hocuspocus.cjs +1 -0
  45. package/dist/react/hocuspocus.d.cts +104 -0
  46. package/dist/react/hocuspocus.d.ts +104 -0
  47. package/dist/react/hocuspocus.js +1 -0
  48. package/dist/react/index.cjs +2 -2
  49. package/dist/react/index.d.cts +320 -5
  50. package/dist/react/index.d.ts +320 -5
  51. package/dist/react/index.js +2 -2
  52. package/dist/react/webrtc.cjs +1 -0
  53. package/dist/react/webrtc.d.cts +98 -0
  54. package/dist/react/webrtc.d.ts +98 -0
  55. package/dist/react/webrtc.js +1 -0
  56. package/dist/room-id-BfudXOZz.d.cts +13 -0
  57. package/dist/room-id-BfudXOZz.d.ts +13 -0
  58. package/dist/session-BH7Qgyp6.d.cts +140 -0
  59. package/dist/session-BH7Qgyp6.d.ts +140 -0
  60. package/dist/session-okdqygLg.d.cts +82 -0
  61. package/dist/session-okdqygLg.d.ts +82 -0
  62. package/dist/vue/hocuspocus.cjs +1 -0
  63. package/dist/vue/hocuspocus.d.cts +105 -0
  64. package/dist/vue/hocuspocus.d.ts +105 -0
  65. package/dist/vue/hocuspocus.js +1 -0
  66. package/dist/vue/index.cjs +2 -2
  67. package/dist/vue/index.d.cts +437 -1
  68. package/dist/vue/index.d.ts +437 -1
  69. package/dist/vue/index.js +2 -2
  70. package/dist/vue/webrtc.cjs +1 -0
  71. package/dist/vue/webrtc.d.cts +99 -0
  72. package/dist/vue/webrtc.d.ts +99 -0
  73. package/dist/vue/webrtc.js +1 -0
  74. package/dist/webrtc-36GPPCW4.js +2 -0
  75. package/dist/webrtc-CDIFHCQY.cjs +2 -0
  76. package/package.json +62 -7
  77. package/dist/chunk-4LFF2FXG.cjs +0 -1
  78. package/dist/chunk-TH5PXU6L.js +0 -1
@@ -0,0 +1,58 @@
1
+ import * as Y from 'yjs';
2
+ import { HocuspocusProvider } from '@hocuspocus/provider';
3
+ import { CollaborationIdentity } from '@docx-editor.dev/core/collaboration';
4
+ import { D as DocumentCollaborationHandle } from '../document-session-DVa53DAw.cjs';
5
+ import { a as CollaborationBootstrap } from '../session-BH7Qgyp6.cjs';
6
+ export { c as createCollaborationRoomId, v as validateRoomId } from '../room-id-BfudXOZz.cjs';
7
+ import 'y-protocols/awareness';
8
+
9
+ /**
10
+ * Server-backed convenience wrapper: one owned Hocuspocus room over the
11
+ * full-document collaboration replica.
12
+ *
13
+ * @packageDocumentation
14
+ * @public
15
+ */
16
+
17
+ /** Options for the owned Hocuspocus collaboration convenience wrapper. @public */
18
+ interface CreateHocuspocusCollaborationOptions {
19
+ /** Hocuspocus server WebSocket URL, for example `wss://collab.example.test`. */
20
+ readonly url: string;
21
+ readonly roomId: string;
22
+ /**
23
+ * Authentication token the provider sends in its auth handshake. The server queues all
24
+ * traffic until that message arrives, so the provider always sends one; omit this and it
25
+ * sends an empty token. Pass a callback and the provider re-evaluates it on every
26
+ * reconnect, which is how expiring JWTs renew.
27
+ */
28
+ readonly token?: string | (() => string | Promise<string>);
29
+ readonly identity: CollaborationIdentity;
30
+ readonly bootstrap: CollaborationBootstrap;
31
+ /**
32
+ * Bound on the wait for the server's initial sync in the `join` and `create-or-join`
33
+ * flows. Default 30000 ms. On expiry the factory destroys everything it owns and
34
+ * rejects with the failure code `initialization-timeout`.
35
+ */
36
+ readonly syncedTimeoutMs?: number;
37
+ /**
38
+ * Admit local edits while the transport is `disconnected`. Buffered updates merge on
39
+ * reconnect. See {@link CreateDocumentCollaborationOptions.offlineEditing}.
40
+ */
41
+ readonly offlineEditing?: boolean;
42
+ }
43
+ /** Owned Hocuspocus provider and provider-neutral collaboration resources. @public */
44
+ interface HocuspocusCollaborationRoom extends DocumentCollaborationHandle {
45
+ readonly ydoc: Y.Doc;
46
+ readonly provider: HocuspocusProvider;
47
+ }
48
+ /**
49
+ * Test-only provider factory. Not re-exported from
50
+ * `@docx-editor.dev/pro/collaboration/hocuspocus`.
51
+ *
52
+ * @internal
53
+ */
54
+ declare const HOCUSPOCUS_PROVIDER_FOR_TESTS: unique symbol;
55
+ /** Create one owned Hocuspocus room and provider-neutral collaboration session. @public */
56
+ declare function createHocuspocusCollaboration(options: CreateHocuspocusCollaborationOptions): Promise<HocuspocusCollaborationRoom>;
57
+
58
+ export { type CreateHocuspocusCollaborationOptions, HOCUSPOCUS_PROVIDER_FOR_TESTS, type HocuspocusCollaborationRoom, createHocuspocusCollaboration };
@@ -0,0 +1,58 @@
1
+ import * as Y from 'yjs';
2
+ import { HocuspocusProvider } from '@hocuspocus/provider';
3
+ import { CollaborationIdentity } from '@docx-editor.dev/core/collaboration';
4
+ import { D as DocumentCollaborationHandle } from '../document-session-DiBuzWwA.js';
5
+ import { a as CollaborationBootstrap } from '../session-BH7Qgyp6.js';
6
+ export { c as createCollaborationRoomId, v as validateRoomId } from '../room-id-BfudXOZz.js';
7
+ import 'y-protocols/awareness';
8
+
9
+ /**
10
+ * Server-backed convenience wrapper: one owned Hocuspocus room over the
11
+ * full-document collaboration replica.
12
+ *
13
+ * @packageDocumentation
14
+ * @public
15
+ */
16
+
17
+ /** Options for the owned Hocuspocus collaboration convenience wrapper. @public */
18
+ interface CreateHocuspocusCollaborationOptions {
19
+ /** Hocuspocus server WebSocket URL, for example `wss://collab.example.test`. */
20
+ readonly url: string;
21
+ readonly roomId: string;
22
+ /**
23
+ * Authentication token the provider sends in its auth handshake. The server queues all
24
+ * traffic until that message arrives, so the provider always sends one; omit this and it
25
+ * sends an empty token. Pass a callback and the provider re-evaluates it on every
26
+ * reconnect, which is how expiring JWTs renew.
27
+ */
28
+ readonly token?: string | (() => string | Promise<string>);
29
+ readonly identity: CollaborationIdentity;
30
+ readonly bootstrap: CollaborationBootstrap;
31
+ /**
32
+ * Bound on the wait for the server's initial sync in the `join` and `create-or-join`
33
+ * flows. Default 30000 ms. On expiry the factory destroys everything it owns and
34
+ * rejects with the failure code `initialization-timeout`.
35
+ */
36
+ readonly syncedTimeoutMs?: number;
37
+ /**
38
+ * Admit local edits while the transport is `disconnected`. Buffered updates merge on
39
+ * reconnect. See {@link CreateDocumentCollaborationOptions.offlineEditing}.
40
+ */
41
+ readonly offlineEditing?: boolean;
42
+ }
43
+ /** Owned Hocuspocus provider and provider-neutral collaboration resources. @public */
44
+ interface HocuspocusCollaborationRoom extends DocumentCollaborationHandle {
45
+ readonly ydoc: Y.Doc;
46
+ readonly provider: HocuspocusProvider;
47
+ }
48
+ /**
49
+ * Test-only provider factory. Not re-exported from
50
+ * `@docx-editor.dev/pro/collaboration/hocuspocus`.
51
+ *
52
+ * @internal
53
+ */
54
+ declare const HOCUSPOCUS_PROVIDER_FOR_TESTS: unique symbol;
55
+ /** Create one owned Hocuspocus room and provider-neutral collaboration session. @public */
56
+ declare function createHocuspocusCollaboration(options: CreateHocuspocusCollaborationOptions): Promise<HocuspocusCollaborationRoom>;
57
+
58
+ export { type CreateHocuspocusCollaborationOptions, HOCUSPOCUS_PROVIDER_FOR_TESTS, type HocuspocusCollaborationRoom, createHocuspocusCollaboration };
@@ -0,0 +1 @@
1
+ import {b}from'../chunk-6DEUT2RQ.js';export{a as createCollaborationRoomId,b as validateRoomId}from'../chunk-6DEUT2RQ.js';import {l,d}from'../chunk-32RB7HPL.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$1){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 d("initialization-aborted",`authentication failed: ${r.reason}`));},s=setTimeout(()=>{n(),e(new d("initialization-timeout"));},d$1);o.on("synced",a),o.on("authenticationFailed",t);})}async function E(o){let d=b(o.roomId),c=o[S]??O,e=new P.Doc,n=new 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 l({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$1=u.session,f=i=>{l$1.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$1.setTransportStatus("error","authentication-failed");};r.on("authenticationFailed",p);let b$1=false;return Object.freeze({document:u.document,session:l$1,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};
@@ -0,0 +1,2 @@
1
+ 'use strict';var chunkQLZH2Q2C_cjs=require('../chunk-QLZH2Q2C.cjs'),chunk4HGT2OVX_cjs=require('../chunk-4HGT2OVX.cjs'),l=require('yjs'),store=require('@docx-editor.dev/core/store'),collaboration=require('@docx-editor.dev/core/collaboration');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 l__namespace=/*#__PURE__*/_interopNamespace(l);var C="docxEditor",h=256,O=256,I=1e6,D=3e4;function U(a){let t=a.actorId.trim(),n=a.name.trim();if(t.length===0||t.length>h||n.length===0||n.length>h)throw new chunk4HGT2OVX_cjs.d("invalid-identity");if(a.color!==void 0&&a.color.length>64)throw new chunk4HGT2OVX_cjs.d("invalid-identity-color");return Object.freeze({actorId:t,name:n,...a.color?{color:a.color}:{},role:a.role??"human"})}function B(a){let t=a.trim();if(t.length===0||t.length>h)throw new chunk4HGT2OVX_cjs.d("invalid-document-id");return t}function F(a){let t=a?.trim()||globalThis.crypto.randomUUID();if(t.length===0||t.length>h)throw new chunk4HGT2OVX_cjs.d("invalid-session-id");return t}function N(a,t){let n=a.toString();if(n===t)return;let o=0;for(;o<n.length&&o<t.length&&n.charCodeAt(o)===t.charCodeAt(o);)o+=1;let e=0;for(;e<n.length-o&&e<t.length-o&&n.charCodeAt(n.length-e-1)===t.charCodeAt(t.length-e-1);)e+=1;let r=n.length-o-e;r>0&&a.delete(o,r);let i=t.slice(o,t.length-e);i.length>0&&a.insert(o,i);}function L(a){if(typeof a!="object"||a===null||Array.isArray(a))return null;let t=a;return typeof t.paragraphId!="string"||t.paragraphId.length!==8||typeof t.position!="string"||t.position.length===0||t.position.length>2048||!/^[A-Za-z0-9_-]+$/.test(t.position)?null:{paragraphId:t.paragraphId,position:t.position}}function H(a){if(a===void 0||typeof a!="object"||a===null||Array.isArray(a))return;let t=a,n=L(t.anchor),o=L(t.head);if(n&&o)return {anchor:n,head:o};if(typeof t.paragraphId=="string"&&t.paragraphId.length===8&&typeof t.anchor=="string"&&typeof t.head=="string"&&t.anchor.length>0&&t.head.length>0&&t.anchor.length<=2048&&t.head.length<=2048&&/^[A-Za-z0-9_-]+$/.test(t.anchor)&&/^[A-Za-z0-9_-]+$/.test(t.head))return {anchor:{paragraphId:t.paragraphId,position:t.anchor},head:{paragraphId:t.paragraphId,position:t.head}}}function R(a){if(typeof a!="object"||a===null||Array.isArray(a))return null;let t=a;if(typeof t.actorId!="string"||t.actorId.length===0||t.actorId.length>h||typeof t.name!="string"||t.name.length===0||t.name.length>h)return null;let n=typeof t.color=="string"&&t.color.length<=64?t.color:void 0,o=t.role==="agent"?"agent":"human",e=H(t.selection);return {actorId:t.actorId,name:t.name,...n?{color:n}:{},role:o,...e?{selection:e}:{}}}function V(a){let t="";for(let n of a)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function X(a){let t=a.replace(/-/g,"+").replace(/_/g,"/"),n=atob(t+"=".repeat((4-t.length%4)%4));return Uint8Array.from(n,o=>o.charCodeAt(0))}var w=class{constructor(t,n,o,e,r,i){this.ydoc=t;this.awareness=n;this.baseline=i;this.documentId=o,this.sessionId=e,this.identity=r;let{root:d,paragraphs:p}=chunk4HGT2OVX_cjs.e(t);this.baselineSha256=String(d.get("baselineSha256")),this.initializedBy=String(d.get("initializedBy")),this.undoManager=new l__namespace.UndoManager([...p.values()],{trackedOrigins:new Set([this.localOrigin]),captureTimeout:0}),t.on("afterTransaction",this.onYjsTransaction),n.on("change",this.onAwarenessChange),this.publishAwareness(),this.setStatus("ready");}ydoc;awareness;baseline;documentId;sessionId;identity;statusState=collaboration.createCollaborationStatusTracker();statusListeners=new Set;selectionListeners=new Set;participantListeners=new Set;localOrigin=Object.freeze({kind:"docx-collaboration-local"});undoManager;baselineSha256;initializedBy;port=null;detachPort=null;applyingSharedState=false;remoteCounter=0;destroyed=false;status(){return this.statusState.status()}statusSnapshot(){return this.statusState.snapshot()}subscribeStatus(t){return this.statusListeners.add(t),()=>this.statusListeners.delete(t)}setTransportStatus(t,n,o){if(!this.destroyed&&!(this.statusState.status()==="error"&&t!=="error")){if(n!==void 0){this.setStatus(t,n,o);return}this.setStatus(t);}}get attached(){return this.port!==null}attach(t){if(this.destroyed)return ()=>{};if(this.port)return ()=>{};if(t.documentId!==this.documentId)return this.setStatus("error","document-id-mismatch"),()=>{};this.validateParagraphSet(t),this.port=t,this.reconcilePortFromYjs();let n=t.subscribe(o=>{if(!(this.destroyed||this.applyingSharedState)&&!(o.origin===store.ORIGIN_IDS.mutationRemote||o.origin===store.ORIGIN_IDS.projection||o.origin===store.ORIGIN_IDS.awareness))try{this.reconcileYjsFromPort();}catch(e){this.setStatus("error",e instanceof chunk4HGT2OVX_cjs.d?e.code:"local-mirror-failed",e instanceof chunk4HGT2OVX_cjs.d?e.detail:void 0);}});return this.detachPort=()=>{this.flushPendingJournals(),n(),this.port===t&&(this.port=null),this.detachPort=null;},()=>this.detachPort?.()}gateOperations(t,n){if(this.destroyed)return "collaboration-session-destroyed";if(this.statusState.status()!=="ready")return "collaboration-session-not-ready";if(!this.port)return "collaboration-session-not-attached";if(n.kind!=="body")return "experimental-collaboration-body-text-only";let o=new Map(this.port.paragraphs().map(e=>[e.nodeId,e.text.length]));for(let e of t){if(e.op!=="insertText"&&e.op!=="deleteText")return "experimental-collaboration-text-only";if("revision"in e&&e.revision!==void 0)return "experimental-collaboration-untracked-text-only";if(!this.port.paragraphByNodeId(e.paragraphId))return "experimental-collaboration-existing-paragraphs-only";let r=o.get(e.paragraphId);if(r===void 0)return "experimental-collaboration-existing-paragraphs-only";let i=e.op==="insertText"?r+e.text.length:r-Math.max(0,e.end-e.start);if(i>I)return "collaboration-text-limit";o.set(e.paragraphId,Math.max(0,i));}return null}canUndo(){return !this.destroyed&&this.undoManager.undoStack.length>0}canRedo(){return !this.destroyed&&this.undoManager.redoStack.length>0}undo(){return this.canUndo()?(this.undoManager.undo(),true):false}redo(){return this.canRedo()?(this.undoManager.redo(),true):false}setLocalSelection(t){if(this.destroyed)return;let{paragraphs:n}=chunk4HGT2OVX_cjs.e(this.ydoc),o=(r,i)=>{let d=n.get(r.toUpperCase());if(d)return {paragraphId:r.toUpperCase(),position:V(l__namespace.encodeRelativePosition(l__namespace.createRelativePositionFromTypeIndex(d,Math.max(0,Math.min(i,d.length)))))}},e;if(t){let r=o(t.anchor.paragraphId,t.anchor.offset),i=o(t.head.paragraphId,t.head.offset);r&&i&&(e={anchor:r,head:i});}this.publishAwareness(e);}participants(){let t=[],n=[...this.awareness.getStates().entries()].slice(0,O);for(let[o,e]of n){let r=R(e[C]);r&&t.push({actorId:r.actorId,name:r.name,...r.color?{color:r.color}:{},role:r.role??"human",isLocal:o===this.awareness.clientID});}return Object.freeze(t)}subscribeParticipants(t){return this.participantListeners.add(t),()=>this.participantListeners.delete(t)}remoteSelections(){if(!this.port)return [];let t=[...this.awareness.getStates().entries()].slice(0,O),{paragraphs:n}=chunk4HGT2OVX_cjs.e(this.ydoc),o=[];for(let[e,r]of t){if(e===this.awareness.clientID)continue;let i=R(r[C]);if(!i?.selection)continue;let d=y=>{let x=n.get(y.paragraphId);if(!x)return null;let u;try{u=l__namespace.createAbsolutePositionFromRelativePosition(l__namespace.decodeRelativePosition(X(y.position)),this.ydoc);}catch{return null}if(!u||u.type!==x)return null;let f=this.port?.paragraphs().find(M=>M.paragraphId===y.paragraphId);return f?{paragraphId:f.paragraphId,nodeId:f.nodeId,offset:u.index}:null},p=d(i.selection.anchor),v=d(i.selection.head);!p||!v||o.push(Object.freeze({actorId:i.actorId,name:i.name,...i.color?{color:i.color}:{},anchor:Object.freeze(p),head:Object.freeze(v)}));}return Object.freeze(o)}subscribeRemoteSelections(t){return this.selectionListeners.add(t),()=>this.selectionListeners.delete(t)}destroy(){this.destroyed||(this.flushPendingJournals(),this.detachPort?.(),this.destroyed=true,this.ydoc.off("afterTransaction",this.onYjsTransaction),this.awareness.off("change",this.onAwarenessChange),this.awareness.setLocalState(null),this.undoManager.destroy(),this.setStatus("destroyed"),this.statusListeners.clear(),this.selectionListeners.clear(),this.participantListeners.clear());}flushPendingJournals(){this.port?.flushPendingJournals();}onYjsTransaction=t=>{if(!this.destroyed&&t.origin!==this.localOrigin){try{this.validateImmutableSchema();}catch(n){this.setStatus("error",n instanceof chunk4HGT2OVX_cjs.d?n.code:"shared-schema-invalid",n instanceof chunk4HGT2OVX_cjs.d?n.detail:void 0);return}this.port&&this.reconcilePortFromYjs();}};onAwarenessChange=()=>{if(this.destroyed)return;let t=this.remoteSelections();for(let o of [...this.selectionListeners])o(t);let n=this.participants();for(let o of [...this.participantListeners])o(n);};publishAwareness(t){let n={actorId:this.identity.actorId,name:this.identity.name,...this.identity.color?{color:this.identity.color}:{},role:this.identity.role??"human",...t?{selection:t}:{}};this.awareness.setLocalStateField(C,n);}validateParagraphSet(t){let{paragraphs:n}=chunk4HGT2OVX_cjs.e(this.ydoc),o=t.paragraphs();if(o.length!==n.size||o.some(e=>!n.has(e.paragraphId)||!(n.get(e.paragraphId)instanceof l__namespace.Text)||n.get(e.paragraphId).length>I))throw new chunk4HGT2OVX_cjs.d("paragraph-set-mismatch")}validateImmutableSchema(){let{root:t,paragraphs:n}=chunk4HGT2OVX_cjs.e(this.ydoc),o=new Set(["protocolVersion","schemaVersion","documentId","baselineSha256","baselineByteLength","initializedBy","baseline","initialized"]);if([...t.keys()].some(r=>!o.has(r)))throw new chunk4HGT2OVX_cjs.d("unsupported-root-key");if(t.get("protocolVersion")!==chunk4HGT2OVX_cjs.a||t.get("schemaVersion")!==chunk4HGT2OVX_cjs.b||t.get("documentId")!==this.documentId||t.get("baselineSha256")!==this.baselineSha256||t.get("baselineByteLength")!==this.baseline.bytes.byteLength||t.get("initializedBy")!==this.initializedBy||t.get("initialized")!==true)throw new chunk4HGT2OVX_cjs.d("immutable-metadata-changed");let e=t.get("baseline");if(!(e instanceof Uint8Array)||e.byteLength!==this.baseline.bytes.byteLength||e.some((r,i)=>r!==this.baseline.bytes[i]))throw new chunk4HGT2OVX_cjs.d("immutable-baseline-changed");for(let[r,i]of n)if(!this.baseline.paragraphs.some(d=>d.paragraphId===r)||!(i instanceof l__namespace.Text)||i.length>I)throw new chunk4HGT2OVX_cjs.d("paragraph-set-mismatch")}reconcileYjsFromPort(){let t=this.port;if(!t)return;let{paragraphs:n}=chunk4HGT2OVX_cjs.e(this.ydoc);this.ydoc.transact(()=>{for(let o of t.paragraphs()){let e=n.get(o.paragraphId);if(!e)throw new chunk4HGT2OVX_cjs.d("paragraph-set-mismatch");N(e,o.text);}},this.localOrigin),this.undoManager.stopCapturing();}reconcilePortFromYjs(){let t=this.port;if(!t||this.applyingSharedState)return;let{paragraphs:n}=chunk4HGT2OVX_cjs.e(this.ydoc);this.applyingSharedState=true;try{this.validateParagraphSet(t);let o=[];for(let e of t.paragraphs()){let r=n.get(e.paragraphId);if(!r)throw new chunk4HGT2OVX_cjs.d("paragraph-set-mismatch");let i=r.toString();i!==e.text&&o.push({paragraphId:e.paragraphId,text:i});}if(o.length>0){this.remoteCounter+=1;let e=t.applyParagraphTexts(o,{origin:store.ORIGIN_IDS.mutationRemote,actorId:"remote",operationId:`remote:${this.remoteCounter}`});if(!e.ok)throw new chunk4HGT2OVX_cjs.d(collaboration.isCollaborationFailureCode(e.reason)?e.reason:"remote-apply-failed",collaboration.isCollaborationFailureCode(e.reason)?void 0:e.reason)}}catch(o){this.setStatus("error",o instanceof chunk4HGT2OVX_cjs.d?o.code:"remote-apply-failed",o instanceof chunk4HGT2OVX_cjs.d?o.detail:void 0);}finally{this.applyingSharedState=false;}}setStatus(t,n,o){if(!this.statusState.set(t,n,o))return;let e=this.statusState.snapshot();for(let r of [...this.statusListeners])r(e.status,e.reason?.code,e.reason?.detail);}};async function $(a,t,n){if(a.bootstrap.kind==="create-or-join")throw new TypeError("createTextCollaboration does not support bootstrap kind 'create-or-join'. Use createDocumentCollaboration.");if(a.bootstrap.kind==="create"){let o=chunk4HGT2OVX_cjs.f(a.bootstrap.document,t);return await chunk4HGT2OVX_cjs.g(a.ydoc,t,n.actorId,o),chunk4HGT2OVX_cjs.h(a.ydoc,t)}return await chunk4HGT2OVX_cjs.i(a.ydoc,a.bootstrap.timeoutMs??D,a.bootstrap.signal),chunk4HGT2OVX_cjs.h(a.ydoc,t)}async function J(a){let t=B(a.documentId),n=F(a.sessionId),o=U(a.identity),e=await $(a,t,o),r=new w(a.ydoc,a.awareness,t,n,o,e);return Object.freeze({document:new Uint8Array(e.bytes),session:r,destroy:()=>r.destroy()})}
2
+ Object.defineProperty(exports,"collaborationModule",{enumerable:true,get:function(){return chunkQLZH2Q2C_cjs.b}});Object.defineProperty(exports,"CollaborationSchemaError",{enumerable:true,get:function(){return chunk4HGT2OVX_cjs.d}});Object.defineProperty(exports,"MAX_BASELINE_BYTES",{enumerable:true,get:function(){return chunk4HGT2OVX_cjs.c}});Object.defineProperty(exports,"PROTOCOL_VERSION",{enumerable:true,get:function(){return chunk4HGT2OVX_cjs.a}});Object.defineProperty(exports,"SCHEMA_VERSION",{enumerable:true,get:function(){return chunk4HGT2OVX_cjs.b}});Object.defineProperty(exports,"createDocumentCollaboration",{enumerable:true,get:function(){return chunk4HGT2OVX_cjs.l}});Object.defineProperty(exports,"readCollaborationDocument",{enumerable:true,get:function(){return chunk4HGT2OVX_cjs.k}});exports.createTextCollaboration=J;
@@ -0,0 +1,22 @@
1
+ export { C as CollaborationModuleOptions, c as collaborationModule } from '../collaboration-module-BgRxhW5b.cjs';
2
+ export { a as CollaborationBootstrap, c as CollaborationHandle, b as CollaborationIdentityUpdate, C as CollaborationSession, d as CreateTextCollaborationOptions, T as TextCollaborationHandle, e as TextCollaborationSession, f as createTextCollaboration } from '../session-BH7Qgyp6.cjs';
3
+ export { C as CreateDocumentCollaborationOptions, D as DocumentCollaborationHandle, a as DocumentCollaborationSession, c as createDocumentCollaboration, r as readCollaborationDocument } from '../document-session-DVa53DAw.cjs';
4
+ import { CollaborationFailureCode } from '@docx-editor.dev/core/collaboration';
5
+ import '@docx-editor.dev/core/editor';
6
+ import 'yjs';
7
+ import 'y-protocols/awareness';
8
+
9
+ /** Wire protocol version a replica writes into shared metadata and refuses to mismatch. @public */
10
+ declare const PROTOCOL_VERSION = 1;
11
+ /** Shared Yjs schema version a replica writes into shared metadata and refuses to mismatch. @public */
12
+ declare const SCHEMA_VERSION = 1;
13
+ /** Maximum accepted creator baseline size in bytes. @public */
14
+ declare const MAX_BASELINE_BYTES: number;
15
+ /** Typed collaboration schema or trust-boundary failure. @public */
16
+ declare class CollaborationSchemaError extends Error {
17
+ readonly code: CollaborationFailureCode;
18
+ readonly detail?: string | undefined;
19
+ constructor(code: CollaborationFailureCode, detail?: string | undefined);
20
+ }
21
+
22
+ export { CollaborationSchemaError, MAX_BASELINE_BYTES, PROTOCOL_VERSION, SCHEMA_VERSION };
@@ -0,0 +1,22 @@
1
+ export { C as CollaborationModuleOptions, c as collaborationModule } from '../collaboration-module-BgRxhW5b.js';
2
+ export { a as CollaborationBootstrap, c as CollaborationHandle, b as CollaborationIdentityUpdate, C as CollaborationSession, d as CreateTextCollaborationOptions, T as TextCollaborationHandle, e as TextCollaborationSession, f as createTextCollaboration } from '../session-BH7Qgyp6.js';
3
+ export { C as CreateDocumentCollaborationOptions, D as DocumentCollaborationHandle, a as DocumentCollaborationSession, c as createDocumentCollaboration, r as readCollaborationDocument } from '../document-session-DiBuzWwA.js';
4
+ import { CollaborationFailureCode } from '@docx-editor.dev/core/collaboration';
5
+ import '@docx-editor.dev/core/editor';
6
+ import 'yjs';
7
+ import 'y-protocols/awareness';
8
+
9
+ /** Wire protocol version a replica writes into shared metadata and refuses to mismatch. @public */
10
+ declare const PROTOCOL_VERSION = 1;
11
+ /** Shared Yjs schema version a replica writes into shared metadata and refuses to mismatch. @public */
12
+ declare const SCHEMA_VERSION = 1;
13
+ /** Maximum accepted creator baseline size in bytes. @public */
14
+ declare const MAX_BASELINE_BYTES: number;
15
+ /** Typed collaboration schema or trust-boundary failure. @public */
16
+ declare class CollaborationSchemaError extends Error {
17
+ readonly code: CollaborationFailureCode;
18
+ readonly detail?: string | undefined;
19
+ constructor(code: CollaborationFailureCode, detail?: string | undefined);
20
+ }
21
+
22
+ export { CollaborationSchemaError, MAX_BASELINE_BYTES, PROTOCOL_VERSION, SCHEMA_VERSION };
@@ -0,0 +1,2 @@
1
+ export{b as collaborationModule}from'../chunk-Q2VBO66F.js';import {d,f,g,h as h$1,i,e,a,b}from'../chunk-32RB7HPL.js';export{d as CollaborationSchemaError,c as MAX_BASELINE_BYTES,a as PROTOCOL_VERSION,b as SCHEMA_VERSION,l as createDocumentCollaboration,k as readCollaborationDocument}from'../chunk-32RB7HPL.js';import*as l from'yjs';import {ORIGIN_IDS}from'@docx-editor.dev/core/store';import {createCollaborationStatusTracker,isCollaborationFailureCode}from'@docx-editor.dev/core/collaboration';var C="docxEditor",h=256,O=256,I=1e6,D=3e4;function U(a){let t=a.actorId.trim(),n=a.name.trim();if(t.length===0||t.length>h||n.length===0||n.length>h)throw new d("invalid-identity");if(a.color!==void 0&&a.color.length>64)throw new d("invalid-identity-color");return Object.freeze({actorId:t,name:n,...a.color?{color:a.color}:{},role:a.role??"human"})}function B(a){let t=a.trim();if(t.length===0||t.length>h)throw new d("invalid-document-id");return t}function F(a){let t=a?.trim()||globalThis.crypto.randomUUID();if(t.length===0||t.length>h)throw new d("invalid-session-id");return t}function N(a,t){let n=a.toString();if(n===t)return;let o=0;for(;o<n.length&&o<t.length&&n.charCodeAt(o)===t.charCodeAt(o);)o+=1;let e=0;for(;e<n.length-o&&e<t.length-o&&n.charCodeAt(n.length-e-1)===t.charCodeAt(t.length-e-1);)e+=1;let r=n.length-o-e;r>0&&a.delete(o,r);let i=t.slice(o,t.length-e);i.length>0&&a.insert(o,i);}function L(a){if(typeof a!="object"||a===null||Array.isArray(a))return null;let t=a;return typeof t.paragraphId!="string"||t.paragraphId.length!==8||typeof t.position!="string"||t.position.length===0||t.position.length>2048||!/^[A-Za-z0-9_-]+$/.test(t.position)?null:{paragraphId:t.paragraphId,position:t.position}}function H(a){if(a===void 0||typeof a!="object"||a===null||Array.isArray(a))return;let t=a,n=L(t.anchor),o=L(t.head);if(n&&o)return {anchor:n,head:o};if(typeof t.paragraphId=="string"&&t.paragraphId.length===8&&typeof t.anchor=="string"&&typeof t.head=="string"&&t.anchor.length>0&&t.head.length>0&&t.anchor.length<=2048&&t.head.length<=2048&&/^[A-Za-z0-9_-]+$/.test(t.anchor)&&/^[A-Za-z0-9_-]+$/.test(t.head))return {anchor:{paragraphId:t.paragraphId,position:t.anchor},head:{paragraphId:t.paragraphId,position:t.head}}}function R(a){if(typeof a!="object"||a===null||Array.isArray(a))return null;let t=a;if(typeof t.actorId!="string"||t.actorId.length===0||t.actorId.length>h||typeof t.name!="string"||t.name.length===0||t.name.length>h)return null;let n=typeof t.color=="string"&&t.color.length<=64?t.color:void 0,o=t.role==="agent"?"agent":"human",e=H(t.selection);return {actorId:t.actorId,name:t.name,...n?{color:n}:{},role:o,...e?{selection:e}:{}}}function V(a){let t="";for(let n of a)t+=String.fromCharCode(n);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function X(a){let t=a.replace(/-/g,"+").replace(/_/g,"/"),n=atob(t+"=".repeat((4-t.length%4)%4));return Uint8Array.from(n,o=>o.charCodeAt(0))}var w=class{constructor(t,n,o,e$1,r,i){this.ydoc=t;this.awareness=n;this.baseline=i;this.documentId=o,this.sessionId=e$1,this.identity=r;let{root:d,paragraphs:p}=e(t);this.baselineSha256=String(d.get("baselineSha256")),this.initializedBy=String(d.get("initializedBy")),this.undoManager=new l.UndoManager([...p.values()],{trackedOrigins:new Set([this.localOrigin]),captureTimeout:0}),t.on("afterTransaction",this.onYjsTransaction),n.on("change",this.onAwarenessChange),this.publishAwareness(),this.setStatus("ready");}ydoc;awareness;baseline;documentId;sessionId;identity;statusState=createCollaborationStatusTracker();statusListeners=new Set;selectionListeners=new Set;participantListeners=new Set;localOrigin=Object.freeze({kind:"docx-collaboration-local"});undoManager;baselineSha256;initializedBy;port=null;detachPort=null;applyingSharedState=false;remoteCounter=0;destroyed=false;status(){return this.statusState.status()}statusSnapshot(){return this.statusState.snapshot()}subscribeStatus(t){return this.statusListeners.add(t),()=>this.statusListeners.delete(t)}setTransportStatus(t,n,o){if(!this.destroyed&&!(this.statusState.status()==="error"&&t!=="error")){if(n!==void 0){this.setStatus(t,n,o);return}this.setStatus(t);}}get attached(){return this.port!==null}attach(t){if(this.destroyed)return ()=>{};if(this.port)return ()=>{};if(t.documentId!==this.documentId)return this.setStatus("error","document-id-mismatch"),()=>{};this.validateParagraphSet(t),this.port=t,this.reconcilePortFromYjs();let n=t.subscribe(o=>{if(!(this.destroyed||this.applyingSharedState)&&!(o.origin===ORIGIN_IDS.mutationRemote||o.origin===ORIGIN_IDS.projection||o.origin===ORIGIN_IDS.awareness))try{this.reconcileYjsFromPort();}catch(e){this.setStatus("error",e instanceof d?e.code:"local-mirror-failed",e instanceof d?e.detail:void 0);}});return this.detachPort=()=>{this.flushPendingJournals(),n(),this.port===t&&(this.port=null),this.detachPort=null;},()=>this.detachPort?.()}gateOperations(t,n){if(this.destroyed)return "collaboration-session-destroyed";if(this.statusState.status()!=="ready")return "collaboration-session-not-ready";if(!this.port)return "collaboration-session-not-attached";if(n.kind!=="body")return "experimental-collaboration-body-text-only";let o=new Map(this.port.paragraphs().map(e=>[e.nodeId,e.text.length]));for(let e of t){if(e.op!=="insertText"&&e.op!=="deleteText")return "experimental-collaboration-text-only";if("revision"in e&&e.revision!==void 0)return "experimental-collaboration-untracked-text-only";if(!this.port.paragraphByNodeId(e.paragraphId))return "experimental-collaboration-existing-paragraphs-only";let r=o.get(e.paragraphId);if(r===void 0)return "experimental-collaboration-existing-paragraphs-only";let i=e.op==="insertText"?r+e.text.length:r-Math.max(0,e.end-e.start);if(i>I)return "collaboration-text-limit";o.set(e.paragraphId,Math.max(0,i));}return null}canUndo(){return !this.destroyed&&this.undoManager.undoStack.length>0}canRedo(){return !this.destroyed&&this.undoManager.redoStack.length>0}undo(){return this.canUndo()?(this.undoManager.undo(),true):false}redo(){return this.canRedo()?(this.undoManager.redo(),true):false}setLocalSelection(t){if(this.destroyed)return;let{paragraphs:n}=e(this.ydoc),o=(r,i)=>{let d=n.get(r.toUpperCase());if(d)return {paragraphId:r.toUpperCase(),position:V(l.encodeRelativePosition(l.createRelativePositionFromTypeIndex(d,Math.max(0,Math.min(i,d.length)))))}},e$1;if(t){let r=o(t.anchor.paragraphId,t.anchor.offset),i=o(t.head.paragraphId,t.head.offset);r&&i&&(e$1={anchor:r,head:i});}this.publishAwareness(e$1);}participants(){let t=[],n=[...this.awareness.getStates().entries()].slice(0,O);for(let[o,e]of n){let r=R(e[C]);r&&t.push({actorId:r.actorId,name:r.name,...r.color?{color:r.color}:{},role:r.role??"human",isLocal:o===this.awareness.clientID});}return Object.freeze(t)}subscribeParticipants(t){return this.participantListeners.add(t),()=>this.participantListeners.delete(t)}remoteSelections(){if(!this.port)return [];let t=[...this.awareness.getStates().entries()].slice(0,O),{paragraphs:n}=e(this.ydoc),o=[];for(let[e,r]of t){if(e===this.awareness.clientID)continue;let i=R(r[C]);if(!i?.selection)continue;let d=y=>{let x=n.get(y.paragraphId);if(!x)return null;let u;try{u=l.createAbsolutePositionFromRelativePosition(l.decodeRelativePosition(X(y.position)),this.ydoc);}catch{return null}if(!u||u.type!==x)return null;let f=this.port?.paragraphs().find(M=>M.paragraphId===y.paragraphId);return f?{paragraphId:f.paragraphId,nodeId:f.nodeId,offset:u.index}:null},p=d(i.selection.anchor),v=d(i.selection.head);!p||!v||o.push(Object.freeze({actorId:i.actorId,name:i.name,...i.color?{color:i.color}:{},anchor:Object.freeze(p),head:Object.freeze(v)}));}return Object.freeze(o)}subscribeRemoteSelections(t){return this.selectionListeners.add(t),()=>this.selectionListeners.delete(t)}destroy(){this.destroyed||(this.flushPendingJournals(),this.detachPort?.(),this.destroyed=true,this.ydoc.off("afterTransaction",this.onYjsTransaction),this.awareness.off("change",this.onAwarenessChange),this.awareness.setLocalState(null),this.undoManager.destroy(),this.setStatus("destroyed"),this.statusListeners.clear(),this.selectionListeners.clear(),this.participantListeners.clear());}flushPendingJournals(){this.port?.flushPendingJournals();}onYjsTransaction=t=>{if(!this.destroyed&&t.origin!==this.localOrigin){try{this.validateImmutableSchema();}catch(n){this.setStatus("error",n instanceof d?n.code:"shared-schema-invalid",n instanceof d?n.detail:void 0);return}this.port&&this.reconcilePortFromYjs();}};onAwarenessChange=()=>{if(this.destroyed)return;let t=this.remoteSelections();for(let o of [...this.selectionListeners])o(t);let n=this.participants();for(let o of [...this.participantListeners])o(n);};publishAwareness(t){let n={actorId:this.identity.actorId,name:this.identity.name,...this.identity.color?{color:this.identity.color}:{},role:this.identity.role??"human",...t?{selection:t}:{}};this.awareness.setLocalStateField(C,n);}validateParagraphSet(t){let{paragraphs:n}=e(this.ydoc),o=t.paragraphs();if(o.length!==n.size||o.some(e=>!n.has(e.paragraphId)||!(n.get(e.paragraphId)instanceof l.Text)||n.get(e.paragraphId).length>I))throw new d("paragraph-set-mismatch")}validateImmutableSchema(){let{root:t,paragraphs:n}=e(this.ydoc),o=new Set(["protocolVersion","schemaVersion","documentId","baselineSha256","baselineByteLength","initializedBy","baseline","initialized"]);if([...t.keys()].some(r=>!o.has(r)))throw new d("unsupported-root-key");if(t.get("protocolVersion")!==a||t.get("schemaVersion")!==b||t.get("documentId")!==this.documentId||t.get("baselineSha256")!==this.baselineSha256||t.get("baselineByteLength")!==this.baseline.bytes.byteLength||t.get("initializedBy")!==this.initializedBy||t.get("initialized")!==true)throw new d("immutable-metadata-changed");let e$1=t.get("baseline");if(!(e$1 instanceof Uint8Array)||e$1.byteLength!==this.baseline.bytes.byteLength||e$1.some((r,i)=>r!==this.baseline.bytes[i]))throw new d("immutable-baseline-changed");for(let[r,i]of n)if(!this.baseline.paragraphs.some(d=>d.paragraphId===r)||!(i instanceof l.Text)||i.length>I)throw new d("paragraph-set-mismatch")}reconcileYjsFromPort(){let t=this.port;if(!t)return;let{paragraphs:n}=e(this.ydoc);this.ydoc.transact(()=>{for(let o of t.paragraphs()){let e=n.get(o.paragraphId);if(!e)throw new d("paragraph-set-mismatch");N(e,o.text);}},this.localOrigin),this.undoManager.stopCapturing();}reconcilePortFromYjs(){let t=this.port;if(!t||this.applyingSharedState)return;let{paragraphs:n}=e(this.ydoc);this.applyingSharedState=true;try{this.validateParagraphSet(t);let o=[];for(let e of t.paragraphs()){let r=n.get(e.paragraphId);if(!r)throw new d("paragraph-set-mismatch");let i=r.toString();i!==e.text&&o.push({paragraphId:e.paragraphId,text:i});}if(o.length>0){this.remoteCounter+=1;let e=t.applyParagraphTexts(o,{origin:ORIGIN_IDS.mutationRemote,actorId:"remote",operationId:`remote:${this.remoteCounter}`});if(!e.ok)throw new d(isCollaborationFailureCode(e.reason)?e.reason:"remote-apply-failed",isCollaborationFailureCode(e.reason)?void 0:e.reason)}}catch(o){this.setStatus("error",o instanceof d?o.code:"remote-apply-failed",o instanceof d?o.detail:void 0);}finally{this.applyingSharedState=false;}}setStatus(t,n,o){if(!this.statusState.set(t,n,o))return;let e=this.statusState.snapshot();for(let r of [...this.statusListeners])r(e.status,e.reason?.code,e.reason?.detail);}};async function $(a,t,n){if(a.bootstrap.kind==="create-or-join")throw new TypeError("createTextCollaboration does not support bootstrap kind 'create-or-join'. Use createDocumentCollaboration.");if(a.bootstrap.kind==="create"){let o=f(a.bootstrap.document,t);return await g(a.ydoc,t,n.actorId,o),h$1(a.ydoc,t)}return await i(a.ydoc,a.bootstrap.timeoutMs??D,a.bootstrap.signal),h$1(a.ydoc,t)}async function J(a){let t=B(a.documentId),n=F(a.sessionId),o=U(a.identity),e=await $(a,t,o),r=new w(a.ydoc,a.awareness,t,n,o,e);return Object.freeze({document:new Uint8Array(e.bytes),session:r,destroy:()=>r.destroy()})}
2
+ export{J as createTextCollaboration};
@@ -0,0 +1,2 @@
1
+ 'use strict';var chunkLUUFBXJ5_cjs=require('../chunk-LUUFBXJ5.cjs'),chunk4HGT2OVX_cjs=require('../chunk-4HGT2OVX.cjs'),F=require('yjs'),awareness=require('y-protocols/awareness'),yWebrtc=require('y-webrtc');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 F__namespace=/*#__PURE__*/_interopNamespace(F);var D=new WeakSet,T=(e,n)=>(e[n]<<24|e[n+1]<<16|e[n+2]<<8|e[n+3])>>>0,w=(e,n,i)=>{e[n]=i>>>24&255,e[n+1]=i>>>16&255,e[n+2]=i>>>8&255,e[n+3]=i&255;},B=e=>e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):null,Y=e=>new Promise(n=>{setTimeout(n,e);});function L(e,n){if(D.has(e))return;D.add(e);let i=e.send.bind(e),o=e._onChannelMessage.bind(e),d=n?.partialTimeoutMs,c=typeof d=="number"&&Number.isFinite(d)&&d>0?d:3e4,l=n?.onAbandonedMessage,f=[],s=new Map,b=false,E=1,h=t=>{let r=s.get(t);r&&(r.timer!==void 0&&clearTimeout(r.timer),s.delete(t),e.destroyed!==true&&l?.());},S=t=>{let r=s.get(t);r&&(r.timer!==void 0&&clearTimeout(r.timer),r.timer=setTimeout(()=>{h(t);},c));},u=()=>e._channel?.bufferedAmount??0,p=async()=>{let t=0;for(;u()>1048576;){if(e.destroyed===true||t>=3e4)return false;await Y(20),t+=20;}return e.destroyed!==true},I=async t=>{let r=Math.ceil(t.byteLength/16371);if(r>8192)throw new Error(`collaboration message needs ${r} chunks, above the 8192 limit`);let g=E;E=E+1>>>0||1;for(let A=0;A<r;A+=1){if(!await p())return;let y=A*16371,a=t.subarray(y,Math.min(y+16371,t.byteLength)),m=new Uint8Array(13+a.byteLength);m[0]=251,w(m,1,g),w(m,5,A),w(m,9,r),m.set(a,13),i(m);}},k=async()=>{if(!b){b=true;try{for(;f.length>0;){let t=f.shift();if(t){if(e.destroyed===!0)return;await I(t);}}}finally{b=false;}}};e.send=t=>{if(typeof t=="string"||t.byteLength<=16371){i(t);return}f.push(t),k();},e._onChannelMessage=t=>{let r=B(t.data);if(!r||r.byteLength<13||r[0]!==251){o(t);return}let g=T(r,1),A=T(r,5),y=T(r,9);if(y===0||y>8192||A>=y)return;let a=s.get(g);if(!a){if(s.size>=4){let _=s.keys().next();_.done||h(_.value);}a={chunks:new Array(y),count:y,received:0,bytes:0,timer:void 0},s.set(g,a);}if(a.count!==y||a.chunks[A])return;let m=r.subarray(13);if(a.chunks[A]=m,a.received+=1,a.bytes+=m.byteLength,a.received!==a.count){S(g);return}a.timer!==void 0&&clearTimeout(a.timer),s.delete(g);let v=new Uint8Array(a.bytes),P=0;for(let _ of a.chunks){if(!_)return;v.set(_,P),P+=_.byteLength;}e.destroyed!==true&&e.push(v);};}var W=Object.freeze(["wss://turn.0docker.com/ws"]),R=false;function H(e){e===void 0&&(R||(R=true,console.warn("[docx-editor] createWebrtcCollaboration was called without `signaling`, so it uses the public demo endpoints. They are shared, unauthenticated, and can go away. Pass your own `signaling` URLs (and TURN `iceServers`) in production, or pass `signaling: DEMO_SIGNALING_ENDPOINTS` explicitly to accept the demo endpoints.")));}function V(){R=false;}var G=/^[A-Za-z0-9_-]{24,256}$/,U="#collab=";function X(e){let n=e.password?.trim()??"";return n.length>0?n:K(e.href)}var K=e=>{let n=e??(typeof globalThis.location=="object"&&globalThis.location!==null?String(globalThis.location.href??""):"");if(n.length===0)return;let i;try{i=new URL(n).hash;}catch{return}if(!i.startsWith(U))return;let o;try{o=decodeURIComponent(i.slice(U.length));}catch{return}if(G.test(o))return o},z=(e,n)=>{Promise.resolve(e.key).then(()=>{let i=e.room;if(!i)return;let o=i.webrtcConns,d=l=>{L(l.peer,{onAbandonedMessage:n});};for(let l of o.values())d(l);let c=o.set.bind(o);o.set=(l,f)=>(d(f),c(l,f));});};async function ee(e){let n=chunkLUUFBXJ5_cjs.b(e.roomId);H(e.signaling);let i=X({password:e.password}),o=new F__namespace.Doc,d=new awareness.Awareness(o),c=null,l=()=>{},f=()=>{let u=new yWebrtc.WebrtcProvider(n,o,{awareness:d,signaling:[...e.signaling??W],...i!==void 0?{password:i}:{},...e.iceServers?{peerOpts:{config:{iceServers:e.iceServers.map(p=>({...p}))}}}:{}});return z(u,()=>l()),u},s;try{e.bootstrap.kind!=="create"&&(c=f()),s=await chunk4HGT2OVX_cjs.l({ydoc:o,awareness:d,documentId:n,identity:e.identity,bootstrap:e.bootstrap,offlineEditing:e.offlineEditing}),c||(c=f());}catch(u){throw c?.destroy(),d.destroy(),o.destroy(),u}if(!c)throw s.destroy(),d.destroy(),o.destroy(),new Error("WebRTC provider did not initialize");let b=c,E=s.session;l=()=>{E.setTransportStatus("error","transport","incomplete chunk");};let h=u=>{E.setTransportStatus(u.connected?"ready":"disconnected",u.connected?void 0:"transport-disconnected",u.connected?void 0:"webrtc disconnected");};b.on("status",h);let S=false;return Object.freeze({document:s.document,session:E,ydoc:o,provider:b,destroy(){S||(S=true,b.off("status",h),s.destroy(),b.destroy(),d.destroy(),o.destroy());}})}
2
+ 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.DEMO_SIGNALING_ENDPOINTS=W;exports.createWebrtcCollaboration=ee;exports.resetDemoSignalingWarningForTests=V;exports.resolveWebrtcRoomPassword=X;exports.warnOnDemoSignalingFallback=H;
@@ -0,0 +1,86 @@
1
+ import * as Y from 'yjs';
2
+ import { WebrtcProvider } from 'y-webrtc';
3
+ import { CollaborationIdentity } from '@docx-editor.dev/core/collaboration';
4
+ import { D as DocumentCollaborationHandle } from '../document-session-DVa53DAw.cjs';
5
+ import { a as CollaborationBootstrap } from '../session-BH7Qgyp6.cjs';
6
+ export { c as createCollaborationRoomId, v as validateRoomId } from '../room-id-BfudXOZz.cjs';
7
+ import 'y-protocols/awareness';
8
+
9
+ /**
10
+ * Peer-to-peer convenience wrapper: one owned `y-webrtc` room over the
11
+ * full-document collaboration replica.
12
+ *
13
+ * @packageDocumentation
14
+ * @public
15
+ */
16
+
17
+ /**
18
+ * Public demo signaling endpoints. Use these endpoints for demos only.
19
+ *
20
+ * Production deployments must pass their own `signaling` URLs and TURN
21
+ * servers. WebRTC peers cannot connect across many networks without TURN.
22
+ * @public
23
+ */
24
+ declare const DEMO_SIGNALING_ENDPOINTS: readonly string[];
25
+ /**
26
+ * Warn once per process when a room silently falls back to the demo signaling endpoints.
27
+ *
28
+ * Passing `signaling: DEMO_SIGNALING_ENDPOINTS` is a deliberate choice and never warns —
29
+ * only an omitted `signaling` does.
30
+ *
31
+ * @internal
32
+ */
33
+ declare function warnOnDemoSignalingFallback(signaling: readonly string[] | undefined): void;
34
+ /** Test-only reset for the once-per-process demo signaling warning. @internal */
35
+ declare function resetDemoSignalingWarningForTests(): void;
36
+ /** Options for the owned WebRTC collaboration convenience wrapper. @public */
37
+ interface CreateWebrtcCollaborationOptions {
38
+ readonly roomId: string;
39
+ readonly identity: CollaborationIdentity;
40
+ readonly bootstrap: CollaborationBootstrap;
41
+ /**
42
+ * Admit local edits while the transport is `disconnected`. Buffered updates merge on
43
+ * reconnect. See {@link CreateDocumentCollaborationOptions.offlineEditing}.
44
+ */
45
+ readonly offlineEditing?: boolean;
46
+ readonly signaling?: readonly string[];
47
+ readonly iceServers?: readonly RTCIceServer[];
48
+ /**
49
+ * Signaling encryption secret for `y-webrtc`.
50
+ *
51
+ * Do not pass the room id. That value is in shareable join URLs and is the
52
+ * signaling topic, so the signaling host already has it. Put a secret in the
53
+ * URL fragment as `#collab=...` — fragments are not sent to the server — and
54
+ * pass the same value here, or omit both and accept plaintext signaling.
55
+ */
56
+ readonly password?: string;
57
+ }
58
+ /** Owned WebRTC provider and provider-neutral collaboration resources. @public */
59
+ interface WebrtcCollaborationHandle extends DocumentCollaborationHandle {
60
+ readonly ydoc: Y.Doc;
61
+ readonly provider: WebrtcProvider;
62
+ }
63
+
64
+ /**
65
+ * Resolve the `y-webrtc` signaling password.
66
+ *
67
+ * The room id is public (query string and signaling topic), so it is never the
68
+ * default key. An explicit `password` wins. Otherwise a `#collab=` URL fragment
69
+ * is used: the fragment never reaches the signaling host, and two peers who
70
+ * opened the same link share it.
71
+ *
72
+ * Residual: a host that passes neither value gets no encryption. Anyone who
73
+ * has the full link, including the fragment, can decrypt — that is join
74
+ * access, not a separate authorization check. A secret that never appears in
75
+ * the URL at all cannot be agreed from the link alone.
76
+ *
77
+ * @internal
78
+ */
79
+ declare function resolveWebrtcRoomPassword(options: {
80
+ readonly password?: string;
81
+ readonly href?: string;
82
+ }): string | undefined;
83
+ /** Create one owned `y-webrtc` room and provider-neutral collaboration session. @public */
84
+ declare function createWebrtcCollaboration(options: CreateWebrtcCollaborationOptions): Promise<WebrtcCollaborationHandle>;
85
+
86
+ export { type CreateWebrtcCollaborationOptions, DEMO_SIGNALING_ENDPOINTS, type WebrtcCollaborationHandle, createWebrtcCollaboration, resetDemoSignalingWarningForTests, resolveWebrtcRoomPassword, warnOnDemoSignalingFallback };
@@ -0,0 +1,86 @@
1
+ import * as Y from 'yjs';
2
+ import { WebrtcProvider } from 'y-webrtc';
3
+ import { CollaborationIdentity } from '@docx-editor.dev/core/collaboration';
4
+ import { D as DocumentCollaborationHandle } from '../document-session-DiBuzWwA.js';
5
+ import { a as CollaborationBootstrap } from '../session-BH7Qgyp6.js';
6
+ export { c as createCollaborationRoomId, v as validateRoomId } from '../room-id-BfudXOZz.js';
7
+ import 'y-protocols/awareness';
8
+
9
+ /**
10
+ * Peer-to-peer convenience wrapper: one owned `y-webrtc` room over the
11
+ * full-document collaboration replica.
12
+ *
13
+ * @packageDocumentation
14
+ * @public
15
+ */
16
+
17
+ /**
18
+ * Public demo signaling endpoints. Use these endpoints for demos only.
19
+ *
20
+ * Production deployments must pass their own `signaling` URLs and TURN
21
+ * servers. WebRTC peers cannot connect across many networks without TURN.
22
+ * @public
23
+ */
24
+ declare const DEMO_SIGNALING_ENDPOINTS: readonly string[];
25
+ /**
26
+ * Warn once per process when a room silently falls back to the demo signaling endpoints.
27
+ *
28
+ * Passing `signaling: DEMO_SIGNALING_ENDPOINTS` is a deliberate choice and never warns —
29
+ * only an omitted `signaling` does.
30
+ *
31
+ * @internal
32
+ */
33
+ declare function warnOnDemoSignalingFallback(signaling: readonly string[] | undefined): void;
34
+ /** Test-only reset for the once-per-process demo signaling warning. @internal */
35
+ declare function resetDemoSignalingWarningForTests(): void;
36
+ /** Options for the owned WebRTC collaboration convenience wrapper. @public */
37
+ interface CreateWebrtcCollaborationOptions {
38
+ readonly roomId: string;
39
+ readonly identity: CollaborationIdentity;
40
+ readonly bootstrap: CollaborationBootstrap;
41
+ /**
42
+ * Admit local edits while the transport is `disconnected`. Buffered updates merge on
43
+ * reconnect. See {@link CreateDocumentCollaborationOptions.offlineEditing}.
44
+ */
45
+ readonly offlineEditing?: boolean;
46
+ readonly signaling?: readonly string[];
47
+ readonly iceServers?: readonly RTCIceServer[];
48
+ /**
49
+ * Signaling encryption secret for `y-webrtc`.
50
+ *
51
+ * Do not pass the room id. That value is in shareable join URLs and is the
52
+ * signaling topic, so the signaling host already has it. Put a secret in the
53
+ * URL fragment as `#collab=...` — fragments are not sent to the server — and
54
+ * pass the same value here, or omit both and accept plaintext signaling.
55
+ */
56
+ readonly password?: string;
57
+ }
58
+ /** Owned WebRTC provider and provider-neutral collaboration resources. @public */
59
+ interface WebrtcCollaborationHandle extends DocumentCollaborationHandle {
60
+ readonly ydoc: Y.Doc;
61
+ readonly provider: WebrtcProvider;
62
+ }
63
+
64
+ /**
65
+ * Resolve the `y-webrtc` signaling password.
66
+ *
67
+ * The room id is public (query string and signaling topic), so it is never the
68
+ * default key. An explicit `password` wins. Otherwise a `#collab=` URL fragment
69
+ * is used: the fragment never reaches the signaling host, and two peers who
70
+ * opened the same link share it.
71
+ *
72
+ * Residual: a host that passes neither value gets no encryption. Anyone who
73
+ * has the full link, including the fragment, can decrypt — that is join
74
+ * access, not a separate authorization check. A secret that never appears in
75
+ * the URL at all cannot be agreed from the link alone.
76
+ *
77
+ * @internal
78
+ */
79
+ declare function resolveWebrtcRoomPassword(options: {
80
+ readonly password?: string;
81
+ readonly href?: string;
82
+ }): string | undefined;
83
+ /** Create one owned `y-webrtc` room and provider-neutral collaboration session. @public */
84
+ declare function createWebrtcCollaboration(options: CreateWebrtcCollaborationOptions): Promise<WebrtcCollaborationHandle>;
85
+
86
+ export { type CreateWebrtcCollaborationOptions, DEMO_SIGNALING_ENDPOINTS, type WebrtcCollaborationHandle, createWebrtcCollaboration, resetDemoSignalingWarningForTests, resolveWebrtcRoomPassword, warnOnDemoSignalingFallback };
@@ -0,0 +1,2 @@
1
+ import {b}from'../chunk-6DEUT2RQ.js';export{a as createCollaborationRoomId,b as validateRoomId}from'../chunk-6DEUT2RQ.js';import {l}from'../chunk-32RB7HPL.js';import*as F from'yjs';import {Awareness}from'y-protocols/awareness';import {WebrtcProvider}from'y-webrtc';var D=new WeakSet,T=(e,n)=>(e[n]<<24|e[n+1]<<16|e[n+2]<<8|e[n+3])>>>0,w=(e,n,i)=>{e[n]=i>>>24&255,e[n+1]=i>>>16&255,e[n+2]=i>>>8&255,e[n+3]=i&255;},B=e=>e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):null,Y=e=>new Promise(n=>{setTimeout(n,e);});function L(e,n){if(D.has(e))return;D.add(e);let i=e.send.bind(e),o=e._onChannelMessage.bind(e),d=n?.partialTimeoutMs,c=typeof d=="number"&&Number.isFinite(d)&&d>0?d:3e4,l=n?.onAbandonedMessage,f=[],s=new Map,b=false,E=1,h=t=>{let r=s.get(t);r&&(r.timer!==void 0&&clearTimeout(r.timer),s.delete(t),e.destroyed!==true&&l?.());},S=t=>{let r=s.get(t);r&&(r.timer!==void 0&&clearTimeout(r.timer),r.timer=setTimeout(()=>{h(t);},c));},u=()=>e._channel?.bufferedAmount??0,p=async()=>{let t=0;for(;u()>1048576;){if(e.destroyed===true||t>=3e4)return false;await Y(20),t+=20;}return e.destroyed!==true},I=async t=>{let r=Math.ceil(t.byteLength/16371);if(r>8192)throw new Error(`collaboration message needs ${r} chunks, above the 8192 limit`);let g=E;E=E+1>>>0||1;for(let A=0;A<r;A+=1){if(!await p())return;let y=A*16371,a=t.subarray(y,Math.min(y+16371,t.byteLength)),m=new Uint8Array(13+a.byteLength);m[0]=251,w(m,1,g),w(m,5,A),w(m,9,r),m.set(a,13),i(m);}},k=async()=>{if(!b){b=true;try{for(;f.length>0;){let t=f.shift();if(t){if(e.destroyed===!0)return;await I(t);}}}finally{b=false;}}};e.send=t=>{if(typeof t=="string"||t.byteLength<=16371){i(t);return}f.push(t),k();},e._onChannelMessage=t=>{let r=B(t.data);if(!r||r.byteLength<13||r[0]!==251){o(t);return}let g=T(r,1),A=T(r,5),y=T(r,9);if(y===0||y>8192||A>=y)return;let a=s.get(g);if(!a){if(s.size>=4){let _=s.keys().next();_.done||h(_.value);}a={chunks:new Array(y),count:y,received:0,bytes:0,timer:void 0},s.set(g,a);}if(a.count!==y||a.chunks[A])return;let m=r.subarray(13);if(a.chunks[A]=m,a.received+=1,a.bytes+=m.byteLength,a.received!==a.count){S(g);return}a.timer!==void 0&&clearTimeout(a.timer),s.delete(g);let v=new Uint8Array(a.bytes),P=0;for(let _ of a.chunks){if(!_)return;v.set(_,P),P+=_.byteLength;}e.destroyed!==true&&e.push(v);};}var W=Object.freeze(["wss://turn.0docker.com/ws"]),R=false;function H(e){e===void 0&&(R||(R=true,console.warn("[docx-editor] createWebrtcCollaboration was called without `signaling`, so it uses the public demo endpoints. They are shared, unauthenticated, and can go away. Pass your own `signaling` URLs (and TURN `iceServers`) in production, or pass `signaling: DEMO_SIGNALING_ENDPOINTS` explicitly to accept the demo endpoints.")));}function V(){R=false;}var G=/^[A-Za-z0-9_-]{24,256}$/,U="#collab=";function X(e){let n=e.password?.trim()??"";return n.length>0?n:K(e.href)}var K=e=>{let n=e??(typeof globalThis.location=="object"&&globalThis.location!==null?String(globalThis.location.href??""):"");if(n.length===0)return;let i;try{i=new URL(n).hash;}catch{return}if(!i.startsWith(U))return;let o;try{o=decodeURIComponent(i.slice(U.length));}catch{return}if(G.test(o))return o},z=(e,n)=>{Promise.resolve(e.key).then(()=>{let i=e.room;if(!i)return;let o=i.webrtcConns,d=l=>{L(l.peer,{onAbandonedMessage:n});};for(let l of o.values())d(l);let c=o.set.bind(o);o.set=(l,f)=>(d(f),c(l,f));});};async function ee(e){let n=b(e.roomId);H(e.signaling);let i=X({password:e.password}),o=new F.Doc,d=new Awareness(o),c=null,l$1=()=>{},f=()=>{let u=new WebrtcProvider(n,o,{awareness:d,signaling:[...e.signaling??W],...i!==void 0?{password:i}:{},...e.iceServers?{peerOpts:{config:{iceServers:e.iceServers.map(p=>({...p}))}}}:{}});return z(u,()=>l$1()),u},s;try{e.bootstrap.kind!=="create"&&(c=f()),s=await l({ydoc:o,awareness:d,documentId:n,identity:e.identity,bootstrap:e.bootstrap,offlineEditing:e.offlineEditing}),c||(c=f());}catch(u){throw c?.destroy(),d.destroy(),o.destroy(),u}if(!c)throw s.destroy(),d.destroy(),o.destroy(),new Error("WebRTC provider did not initialize");let b$1=c,E=s.session;l$1=()=>{E.setTransportStatus("error","transport","incomplete chunk");};let h=u=>{E.setTransportStatus(u.connected?"ready":"disconnected",u.connected?void 0:"transport-disconnected",u.connected?void 0:"webrtc disconnected");};b$1.on("status",h);let S=false;return Object.freeze({document:s.document,session:E,ydoc:o,provider:b$1,destroy(){S||(S=true,b$1.off("status",h),s.destroy(),b$1.destroy(),d.destroy(),o.destroy());}})}
2
+ export{W as DEMO_SIGNALING_ENDPOINTS,ee as createWebrtcCollaboration,V as resetDemoSignalingWarningForTests,X as resolveWebrtcRoomPassword,H as warnOnDemoSignalingFallback};
@@ -0,0 +1,45 @@
1
+ import { EditorModule } from '@docx-editor.dev/core/editor';
2
+ import { EditorCollaborationSession } from '@docx-editor.dev/core/collaboration';
3
+
4
+ /**
5
+ * Licensing, v1: honor system.
6
+ *
7
+ * The key is accepted and remembered so that adding offline (Ed25519)
8
+ * verification later is not a breaking change — but nothing validates it,
9
+ * nothing warns, nothing renders differently, and NOTHING EVER LEAVES THE
10
+ * PROCESS: no network request is made for licensing, ever. That last property
11
+ * is a spec requirement (`pro-licensing`), not an implementation detail.
12
+ */
13
+ /** Accepted by every pro entry point. */
14
+ interface ProLicenseOptions {
15
+ /**
16
+ * Your license key from docx-editor.dev. Optional in v1: unlicensed use in
17
+ * development and evaluation is permitted, production use requires a
18
+ * license (see LICENSE.md) — the package trusts you either way.
19
+ */
20
+ readonly licenseKey?: string;
21
+ }
22
+
23
+ /**
24
+ * The collaboration module: a replica as an `EditorModule` for
25
+ * `createDocxEditor({ modules })`.
26
+ *
27
+ * Registering it is the whole enablement story: the surface attaches the
28
+ * session, remote selections paint, and undo routes through the session.
29
+ * This file imports no Yjs, so the main Pro entry can re-export it without
30
+ * pulling a CRDT into a review-only bundle.
31
+ */
32
+
33
+ /**
34
+ * How {@link collaborationModule} is configured. The session is required;
35
+ * the licence key is optional and never validated.
36
+ *
37
+ * @public
38
+ */
39
+ interface CollaborationModuleOptions extends ProLicenseOptions {
40
+ readonly session: EditorCollaborationSession;
41
+ }
42
+ /** Build the collaboration module. Construction never validates the key and never touches the network. */
43
+ declare function collaborationModule(options: CollaborationModuleOptions): EditorModule;
44
+
45
+ export { type CollaborationModuleOptions as C, type ProLicenseOptions as P, collaborationModule as c };
@@ -0,0 +1,45 @@
1
+ import { EditorModule } from '@docx-editor.dev/core/editor';
2
+ import { EditorCollaborationSession } from '@docx-editor.dev/core/collaboration';
3
+
4
+ /**
5
+ * Licensing, v1: honor system.
6
+ *
7
+ * The key is accepted and remembered so that adding offline (Ed25519)
8
+ * verification later is not a breaking change — but nothing validates it,
9
+ * nothing warns, nothing renders differently, and NOTHING EVER LEAVES THE
10
+ * PROCESS: no network request is made for licensing, ever. That last property
11
+ * is a spec requirement (`pro-licensing`), not an implementation detail.
12
+ */
13
+ /** Accepted by every pro entry point. */
14
+ interface ProLicenseOptions {
15
+ /**
16
+ * Your license key from docx-editor.dev. Optional in v1: unlicensed use in
17
+ * development and evaluation is permitted, production use requires a
18
+ * license (see LICENSE.md) — the package trusts you either way.
19
+ */
20
+ readonly licenseKey?: string;
21
+ }
22
+
23
+ /**
24
+ * The collaboration module: a replica as an `EditorModule` for
25
+ * `createDocxEditor({ modules })`.
26
+ *
27
+ * Registering it is the whole enablement story: the surface attaches the
28
+ * session, remote selections paint, and undo routes through the session.
29
+ * This file imports no Yjs, so the main Pro entry can re-export it without
30
+ * pulling a CRDT into a review-only bundle.
31
+ */
32
+
33
+ /**
34
+ * How {@link collaborationModule} is configured. The session is required;
35
+ * the licence key is optional and never validated.
36
+ *
37
+ * @public
38
+ */
39
+ interface CollaborationModuleOptions extends ProLicenseOptions {
40
+ readonly session: EditorCollaborationSession;
41
+ }
42
+ /** Build the collaboration module. Construction never validates the key and never touches the network. */
43
+ declare function collaborationModule(options: CollaborationModuleOptions): EditorModule;
44
+
45
+ export { type CollaborationModuleOptions as C, type ProLicenseOptions as P, collaborationModule as c };
@@ -1,25 +1,7 @@
1
1
  import { EditorModule } from '@docx-editor.dev/core/editor';
2
+ import { P as ProLicenseOptions } from './collaboration-module-BgRxhW5b.cjs';
2
3
  import { OoxmlPart } from '@docx-editor.dev/core/store';
3
4
 
4
- /**
5
- * Licensing, v1: honor system.
6
- *
7
- * The key is accepted and remembered so that adding offline (Ed25519)
8
- * verification later is not a breaking change — but nothing validates it,
9
- * nothing warns, nothing renders differently, and NOTHING EVER LEAVES THE
10
- * PROCESS: no network request is made for licensing, ever. That last property
11
- * is a spec requirement (`pro-licensing`), not an implementation detail.
12
- */
13
- /** Accepted by every pro entry point. */
14
- interface ProLicenseOptions {
15
- /**
16
- * Your license key from docx-editor.dev. Optional in v1: unlicensed use in
17
- * development and evaluation is permitted, production use requires a
18
- * license (see LICENSE.md) — the package trusts you either way.
19
- */
20
- readonly licenseKey?: string;
21
- }
22
-
23
5
  /**
24
6
  * The review module: comments, tracked changes, and markup rendering as an
25
7
  * `EditorModule` for `createDocxEditor({ modules })`.
@@ -508,4 +490,4 @@ interface RecognizeCustomNodesOptions {
508
490
  }
509
491
  declare function recognizeCustomNodes(part: OoxmlPart, definitions: readonly AnyCustomNodeDefinition[], options?: RecognizeCustomNodesOptions): RecognizedCustomNode[];
510
492
 
511
- export { type AnyCustomNodeDefinition as A, type CustomNodeDiagnostic as C, type InferSchemaInput as I, MAX_CUSTOM_NODE_DATA_LENGTH as M, type ProLicenseOptions as P, type RecognizedCustomNode as R, type StandardSchemaV1 as S, type CustomNodeDefinition as a, type ActivatedCustomNode as b, type CustomNode as c, type CustomNodeDataRejection as d, type CustomNodeDataResult as e, type CustomNodePayloadSource as f, type CustomNodesModuleOptions as g, type InferSchemaOutput as h, type RecognizeCustomNodesOptions as i, type ReviewModuleOptions as j, type StandardSchemaIssue as k, type StandardSchemaResult as l, customNodesModule as m, defineCustomNode as n, isCustomNodeDefinition as o, parseCustomNodeData as p, reviewModule as q, recognizeCustomNodes as r, serializeCustomNodeData as s };
493
+ export { type AnyCustomNodeDefinition as A, type CustomNodeDiagnostic as C, type InferSchemaInput as I, MAX_CUSTOM_NODE_DATA_LENGTH as M, type RecognizedCustomNode as R, type StandardSchemaV1 as S, type CustomNodeDefinition as a, type ActivatedCustomNode as b, type CustomNode as c, type CustomNodeDataRejection as d, type CustomNodeDataResult as e, type CustomNodePayloadSource as f, type CustomNodesModuleOptions as g, type InferSchemaOutput as h, type RecognizeCustomNodesOptions as i, type ReviewModuleOptions as j, type StandardSchemaIssue as k, type StandardSchemaResult as l, customNodesModule as m, defineCustomNode as n, isCustomNodeDefinition as o, parseCustomNodeData as p, reviewModule as q, recognizeCustomNodes as r, serializeCustomNodeData as s };
@@ -1,25 +1,7 @@
1
1
  import { EditorModule } from '@docx-editor.dev/core/editor';
2
+ import { P as ProLicenseOptions } from './collaboration-module-BgRxhW5b.js';
2
3
  import { OoxmlPart } from '@docx-editor.dev/core/store';
3
4
 
4
- /**
5
- * Licensing, v1: honor system.
6
- *
7
- * The key is accepted and remembered so that adding offline (Ed25519)
8
- * verification later is not a breaking change — but nothing validates it,
9
- * nothing warns, nothing renders differently, and NOTHING EVER LEAVES THE
10
- * PROCESS: no network request is made for licensing, ever. That last property
11
- * is a spec requirement (`pro-licensing`), not an implementation detail.
12
- */
13
- /** Accepted by every pro entry point. */
14
- interface ProLicenseOptions {
15
- /**
16
- * Your license key from docx-editor.dev. Optional in v1: unlicensed use in
17
- * development and evaluation is permitted, production use requires a
18
- * license (see LICENSE.md) — the package trusts you either way.
19
- */
20
- readonly licenseKey?: string;
21
- }
22
-
23
5
  /**
24
6
  * The review module: comments, tracked changes, and markup rendering as an
25
7
  * `EditorModule` for `createDocxEditor({ modules })`.
@@ -508,4 +490,4 @@ interface RecognizeCustomNodesOptions {
508
490
  }
509
491
  declare function recognizeCustomNodes(part: OoxmlPart, definitions: readonly AnyCustomNodeDefinition[], options?: RecognizeCustomNodesOptions): RecognizedCustomNode[];
510
492
 
511
- export { type AnyCustomNodeDefinition as A, type CustomNodeDiagnostic as C, type InferSchemaInput as I, MAX_CUSTOM_NODE_DATA_LENGTH as M, type ProLicenseOptions as P, type RecognizedCustomNode as R, type StandardSchemaV1 as S, type CustomNodeDefinition as a, type ActivatedCustomNode as b, type CustomNode as c, type CustomNodeDataRejection as d, type CustomNodeDataResult as e, type CustomNodePayloadSource as f, type CustomNodesModuleOptions as g, type InferSchemaOutput as h, type RecognizeCustomNodesOptions as i, type ReviewModuleOptions as j, type StandardSchemaIssue as k, type StandardSchemaResult as l, customNodesModule as m, defineCustomNode as n, isCustomNodeDefinition as o, parseCustomNodeData as p, reviewModule as q, recognizeCustomNodes as r, serializeCustomNodeData as s };
493
+ export { type AnyCustomNodeDefinition as A, type CustomNodeDiagnostic as C, type InferSchemaInput as I, MAX_CUSTOM_NODE_DATA_LENGTH as M, type RecognizedCustomNode as R, type StandardSchemaV1 as S, type CustomNodeDefinition as a, type ActivatedCustomNode as b, type CustomNode as c, type CustomNodeDataRejection as d, type CustomNodeDataResult as e, type CustomNodePayloadSource as f, type CustomNodesModuleOptions as g, type InferSchemaOutput as h, type RecognizeCustomNodesOptions as i, type ReviewModuleOptions as j, type StandardSchemaIssue as k, type StandardSchemaResult as l, customNodesModule as m, defineCustomNode as n, isCustomNodeDefinition as o, parseCustomNodeData as p, reviewModule as q, recognizeCustomNodes as r, serializeCustomNodeData as s };
@@ -0,0 +1 @@
1
+ 'use strict';var chunk4HGT2OVX_cjs=require('./chunk-4HGT2OVX.cjs');Object.defineProperty(exports,"ATTACH_WATCHDOG_MS_FOR_TESTS",{enumerable:true,get:function(){return chunk4HGT2OVX_cjs.j}});Object.defineProperty(exports,"createDocumentCollaboration",{enumerable:true,get:function(){return chunk4HGT2OVX_cjs.l}});Object.defineProperty(exports,"readCollaborationDocument",{enumerable:true,get:function(){return chunk4HGT2OVX_cjs.k}});
@@ -0,0 +1 @@
1
+ export{j as ATTACH_WATCHDOG_MS_FOR_TESTS,l as createDocumentCollaboration,k as readCollaborationDocument}from'./chunk-32RB7HPL.js';