@docx-editor.dev/pro 2.33.0 → 2.34.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/dist/chunk-4TS2D6OV.js +11 -0
- package/dist/chunk-5HK5RAD7.cjs +11 -0
- package/dist/{chunk-46N5DWZV.cjs → chunk-GSBQ5AHL.cjs} +1 -1
- package/dist/chunk-IFDU5O5J.js +1 -0
- package/dist/chunk-L6ZMFFBX.cjs +1 -0
- package/dist/{chunk-SINNHH3H.js → chunk-NTBGYQX4.js} +1 -1
- package/dist/chunk-UPKBD6AH.cjs +1 -0
- package/dist/chunk-VQOLBCW6.js +1 -0
- package/dist/{chunk-SL6K2CUL.js → chunk-ZMBZ7CWZ.js} +1 -1
- package/dist/{chunk-GLYQ72LS.cjs → chunk-ZZ33FL6V.cjs} +1 -1
- package/dist/collaboration/hocuspocus.cjs +1 -1
- package/dist/collaboration/hocuspocus.d.cts +1 -1
- package/dist/collaboration/hocuspocus.d.ts +1 -1
- package/dist/collaboration/hocuspocus.js +1 -1
- package/dist/collaboration/index.cjs +2 -2
- package/dist/collaboration/index.d.cts +1 -1
- package/dist/collaboration/index.d.ts +1 -1
- package/dist/collaboration/index.js +2 -2
- package/dist/collaboration/webrtc.cjs +1 -1
- package/dist/collaboration/webrtc.d.cts +1 -1
- package/dist/collaboration/webrtc.d.ts +1 -1
- package/dist/collaboration/webrtc.js +1 -1
- package/dist/{document-session-B-iH-YCU.d.ts → document-session-B6v5LZIK.d.ts} +94 -9
- package/dist/{document-session-B-MlORjE.d.cts → document-session-DZK2tAr4.d.cts} +94 -9
- package/dist/document-session-RPP3WEJ7.cjs +1 -0
- package/dist/document-session-S2N54WP6.js +1 -0
- package/dist/drawing/index.cjs +1 -1
- package/dist/drawing/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/metafile-replay-SDHSTWYT.js +1 -0
- package/dist/metafile-replay-YZ2LHLBT.cjs +1 -0
- package/dist/react/index.cjs +2 -2
- package/dist/react/index.js +2 -2
- package/dist/vue/index.cjs +2 -2
- package/dist/vue/index.js +2 -2
- package/package.json +4 -4
- package/dist/chunk-25A5N6OL.js +0 -1
- package/dist/chunk-65JEI6FY.cjs +0 -5
- package/dist/chunk-VY7374QP.cjs +0 -1
- package/dist/chunk-WGBOER6G.js +0 -1
- package/dist/chunk-WX43PF3Z.cjs +0 -1
- package/dist/chunk-WYVEFRAM.js +0 -5
- package/dist/document-session-4NUOLWKQ.cjs +0 -1
- package/dist/document-session-5VAD24RH.js +0 -1
- package/dist/metafile-replay-GHPEUR2W.js +0 -1
- package/dist/metafile-replay-NZWGGGZR.cjs +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkUPKBD6AH_cjs=require('../chunk-UPKBD6AH.cjs'),chunkLUUFBXJ5_cjs=require('../chunk-LUUFBXJ5.cjs'),chunk5HK5RAD7_cjs=require('../chunk-5HK5RAD7.cjs'),H=require('yjs'),awareness=require('y-protocols/awareness'),provider=require('@hocuspocus/provider'),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 H__namespace=/*#__PURE__*/_interopNamespace(H);var S=Symbol("createHocuspocusCollaboration.provider");var E=3e4,I=o=>new provider.HocuspocusProvider({url:o.url,name:o.name,document:o.document,awareness:o.awareness,...o.token!==void 0?{token:o.token}:{}});function R(o,m,l){return new Promise((n,r)=>{if(l?.aborted){r(new chunk5HK5RAD7_cjs.b("initialization-aborted"));return}if(o.isSynced){n();return}let i=()=>{clearTimeout(u),o.off("synced",d),o.off("authenticationFailed",t),l?.removeEventListener("abort",s);},s=()=>{i(),r(new chunk5HK5RAD7_cjs.b("initialization-aborted"));},d=()=>{i(),n();},t=a=>{i(),r(new chunk5HK5RAD7_cjs.b(collaboration.isCollaborationFailureCode(a.reason)?a.reason:"initialization-aborted",`authentication failed: ${a.reason}`));},u=setTimeout(()=>{i(),r(new chunk5HK5RAD7_cjs.b("initialization-timeout"));},m);o.on("synced",d),o.on("authenticationFailed",t),l?.addEventListener("abort",s,{once:true});})}async function L(o){let m=chunkLUUFBXJ5_cjs.b(o.roomId),l=o[S]??I,n=new H__namespace.Doc,r=new awareness.Awareness(n),i=()=>{let e=l({url:o.url,name:m,document:n,awareness:r,...o.token!==void 0?{token:o.token}:{}});return e.on("open",()=>e.sendStateless?.(chunkUPKBD6AH_cjs.d(n))),e},s=null,d=null;try{if(o.bootstrap.kind!=="create"&&o.bootstrap.signal?.aborted)throw new chunk5HK5RAD7_cjs.b("initialization-aborted");s=i(),await R(s,o.syncedTimeoutMs??E,o.bootstrap.kind==="create"?void 0:o.bootstrap.signal);let e=o.bootstrap.kind==="create-or-join"&&o.bootstrap.probeTimeoutMs===void 0?{...o.bootstrap,probeTimeoutMs:0}:o.bootstrap;d=await chunk5HK5RAD7_cjs.r({ydoc:n,awareness:r,documentId:m,identity:o.identity,bootstrap:e,offlineEditing:o.offlineEditing});}catch(e){throw d?.destroy(),s?.destroy(),r.destroy(),n.destroy(),e}let t=s,u=d,a=u.session,b=e=>{a.setTransportStatus(e.status==="connected"?"ready":"disconnected",e.status==="connected"?void 0:"transport-disconnected",e.status==="connected"?void 0:"websocket disconnected");};t.on("status",b);let p=e=>{a.setTransportStatus("error",collaboration.isCollaborationFailureCode(e.reason)?e.reason:"authentication-failed",`authentication failed: ${e.reason}`);};t.on("authenticationFailed",p);let y=false,v=e=>{y||!e.event||!chunkUPKBD6AH_cjs.e(e.event)||(y=true,a.setTransportStatus("error","room-generation-changed"),t.destroy());};t.on("close",v);let g=false;return Object.freeze({document:u.document,session:a,ydoc:n,provider:t,destroy(){g||(g=true,t.off("status",b),t.off("authenticationFailed",p),t.off("close",v),u.destroy(),y||t.destroy(),r.destroy(),n.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.createHocuspocusCollaboration=L;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import * as Y from 'yjs';
|
|
9
9
|
import { HocuspocusProvider } from '@hocuspocus/provider';
|
|
10
10
|
import { CollaborationIdentity } from '@docx-editor.dev/core/collaboration';
|
|
11
|
-
import { D as DocumentCollaborationHandle } from '../document-session-
|
|
11
|
+
import { D as DocumentCollaborationHandle } from '../document-session-DZK2tAr4.cjs';
|
|
12
12
|
import { a as CollaborationBootstrap } from '../types-DvGpDOcZ.cjs';
|
|
13
13
|
export { c as createCollaborationRoomId, v as validateRoomId } from '../room-id-BfudXOZz.cjs';
|
|
14
14
|
import '../document-session-options-CxR0F5xT.cjs';
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import * as Y from 'yjs';
|
|
9
9
|
import { HocuspocusProvider } from '@hocuspocus/provider';
|
|
10
10
|
import { CollaborationIdentity } from '@docx-editor.dev/core/collaboration';
|
|
11
|
-
import { D as DocumentCollaborationHandle } from '../document-session-
|
|
11
|
+
import { D as DocumentCollaborationHandle } from '../document-session-B6v5LZIK.js';
|
|
12
12
|
import { a as CollaborationBootstrap } from '../types-DvGpDOcZ.js';
|
|
13
13
|
export { c as createCollaborationRoomId, v as validateRoomId } from '../room-id-BfudXOZz.js';
|
|
14
14
|
import '../document-session-options-CdOH-TNn.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {d,e}from'../chunk-
|
|
1
|
+
import {d,e}from'../chunk-IFDU5O5J.js';import {b}from'../chunk-6DEUT2RQ.js';export{a as createCollaborationRoomId,b as validateRoomId}from'../chunk-6DEUT2RQ.js';import {b as b$1,r}from'../chunk-4TS2D6OV.js';import*as H from'yjs';import {Awareness}from'y-protocols/awareness';import {HocuspocusProvider}from'@hocuspocus/provider';import {isCollaborationFailureCode}from'@docx-editor.dev/core/collaboration';var S=Symbol("createHocuspocusCollaboration.provider");var E=3e4,I=o=>new HocuspocusProvider({url:o.url,name:o.name,document:o.document,awareness:o.awareness,...o.token!==void 0?{token:o.token}:{}});function R(o,m,l){return new Promise((n,r)=>{if(l?.aborted){r(new b$1("initialization-aborted"));return}if(o.isSynced){n();return}let i=()=>{clearTimeout(u),o.off("synced",d),o.off("authenticationFailed",t),l?.removeEventListener("abort",s);},s=()=>{i(),r(new b$1("initialization-aborted"));},d=()=>{i(),n();},t=a=>{i(),r(new b$1(isCollaborationFailureCode(a.reason)?a.reason:"initialization-aborted",`authentication failed: ${a.reason}`));},u=setTimeout(()=>{i(),r(new b$1("initialization-timeout"));},m);o.on("synced",d),o.on("authenticationFailed",t),l?.addEventListener("abort",s,{once:true});})}async function L(o){let m=b(o.roomId),l=o[S]??I,n=new H.Doc,r$1=new Awareness(n),i=()=>{let e=l({url:o.url,name:m,document:n,awareness:r$1,...o.token!==void 0?{token:o.token}:{}});return e.on("open",()=>e.sendStateless?.(d(n))),e},s=null,d$1=null;try{if(o.bootstrap.kind!=="create"&&o.bootstrap.signal?.aborted)throw new b$1("initialization-aborted");s=i(),await R(s,o.syncedTimeoutMs??E,o.bootstrap.kind==="create"?void 0:o.bootstrap.signal);let e=o.bootstrap.kind==="create-or-join"&&o.bootstrap.probeTimeoutMs===void 0?{...o.bootstrap,probeTimeoutMs:0}:o.bootstrap;d$1=await r({ydoc:n,awareness:r$1,documentId:m,identity:o.identity,bootstrap:e,offlineEditing:o.offlineEditing});}catch(e){throw d$1?.destroy(),s?.destroy(),r$1.destroy(),n.destroy(),e}let t=s,u=d$1,a=u.session,b$2=e=>{a.setTransportStatus(e.status==="connected"?"ready":"disconnected",e.status==="connected"?void 0:"transport-disconnected",e.status==="connected"?void 0:"websocket disconnected");};t.on("status",b$2);let p=e=>{a.setTransportStatus("error",isCollaborationFailureCode(e.reason)?e.reason:"authentication-failed",`authentication failed: ${e.reason}`);};t.on("authenticationFailed",p);let y=false,v=e$1=>{y||!e$1.event||!e(e$1.event)||(y=true,a.setTransportStatus("error","room-generation-changed"),t.destroy());};t.on("close",v);let g=false;return Object.freeze({document:u.document,session:a,ydoc:n,provider:t,destroy(){g||(g=true,t.off("status",b$2),t.off("authenticationFailed",p),t.off("close",v),u.destroy(),y||t.destroy(),r$1.destroy(),n.destroy());}})}export{L as createHocuspocusCollaboration};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var chunkQEULTKCT_cjs=require('../chunk-QEULTKCT.cjs'),
|
|
2
|
-
Object.defineProperty(exports,"collaborationModule",{enumerable:true,get:function(){return chunkQEULTKCT_cjs.a}});Object.defineProperty(exports,"checkCollaborationRoomGeneration",{enumerable:true,get:function(){return
|
|
1
|
+
'use strict';var chunkQEULTKCT_cjs=require('../chunk-QEULTKCT.cjs'),chunkUPKBD6AH_cjs=require('../chunk-UPKBD6AH.cjs'),chunk5HK5RAD7_cjs=require('../chunk-5HK5RAD7.cjs');require('../chunk-IULA3QRZ.cjs');var O=require('yjs'),store=require('@docx-editor.dev/core/store');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 O__namespace=/*#__PURE__*/_interopNamespace(O);var j=1,K=1,M=20971520;function J(o){return chunk5HK5RAD7_cjs.a(o)}async function W(o,t){let n=chunk5HK5RAD7_cjs.i(t.documentId),a=t.maxBytes??20971520;if(!Number.isSafeInteger(a)||a<=0||a>20971520)throw new TypeError(`maxBytes must be a whole number of bytes from 1 to ${20971520}`);return chunkUPKBD6AH_cjs.c(o,n,{maxBytes:a})}var A=["protocolVersion","sharedSchemaVersion","repairVersion","canonicalModelVersion"];function T(o){return `docx-collaboration:${o.join(".")}`}var b=T(A.map(o=>chunk5HK5RAD7_cjs.c[o]));function q(o){if(o!==b)throw new chunk5HK5RAD7_cjs.b("collaboration-format-mismatch","The collaboration format version is missing or incompatible with this deployment.")}function k(o){if(!o.share.has(chunk5HK5RAD7_cjs.e))throw new chunk5HK5RAD7_cjs.b("not-initialized");let t;try{t=o.getMap(chunk5HK5RAD7_cjs.e);}catch{throw new chunk5HK5RAD7_cjs.b("collaboration-format-mismatch","The saved room has invalid collaboration version information.")}if(t.get("initialized")!==true||typeof t.get("documentId")!="string")throw new chunk5HK5RAD7_cjs.b("not-initialized");let n=A.map(a=>{let r=t.get(a);if(typeof r!="number"||!Number.isSafeInteger(r)||r<0)throw new chunk5HK5RAD7_cjs.b("collaboration-format-mismatch","The saved room has missing or invalid collaboration version information.");return r});return T(n)}function Z(o){return w(o,t=>L(F(t)))}async function oo(o){let t=w(o.state,l=>({format:F(l),documentId:to(l)})),n=L(t.format);if(n==="current")return {ok:false,reason:"current"};if(n==="later-format")return {ok:false,reason:"later-format"};let a=o.documentId??t.documentId;if(typeof a!="string")throw new chunk5HK5RAD7_cjs.b("invalid-document-id","The earlier room holds no document ID. Pass the ID its clients use as documentId.");let r=chunk5HK5RAD7_cjs.i(a),i=await chunkUPKBD6AH_cjs.c(o.exported,r,{keepBound:true}),p=w(i,l=>chunk5HK5RAD7_cjs.q(l)),m=await P(o.exported),e=ro(m,await P(p),{from:t.format??"unversioned",to:b,documentId:r});return e.ok?{ok:true,state:i,report:e}:{ok:false,reason:"check-failed",report:e}}function w(o,t){let n=new O__namespace.Doc;try{try{O__namespace.applyUpdate(n,o);}catch{throw new chunk5HK5RAD7_cjs.b("invalid-baseline","The bytes are not room state.")}return t(n)}finally{n.destroy();}}function to(o){try{return o.getMap(chunk5HK5RAD7_cjs.e).get("documentId")}catch{return}}function F(o){try{return k(o)}catch(t){if(t instanceof chunk5HK5RAD7_cjs.b&&t.code==="collaboration-format-mismatch")return null;throw t}}function L(o){if(o===null)return "earlier-format";let t=so(o,b);return t===0?"current":t<0?"earlier-format":"later-format"}var D=20;function ro(o,t,n){let a=[],r=0,i=new Set;o.paragraphs.length!==t.paragraphs.length&&i.add("paragraphs");let p=Math.max(o.paragraphs.length,t.paragraphs.length);for(let d=0;d<p;d+=1){let g=o.paragraphs[d],u=t.paragraphs[d],y=u?g?g.text!==u.text?"text":g.formatting!==u.formatting?"formatting":null:"added":"missing";if(y===null||((y==="text"||y==="formatting")&&i.add(y),r+=1,a.length>=D))continue;let v=g??u;a.push({part:v.part,paragraph:v.index,kind:y,expected:g?.text??null,actual:u?.text??null});}let m=[...o.media].filter(([d])=>!t.media.has(d)).map(([,d])=>d).sort();m.length>0&&i.add("media");let e=eo(o.links,t.links);e.length>0&&i.add("links");let l=[...new Set([...o.parts.keys(),...t.parts.keys()])].filter(d=>o.parts.get(d)!==t.parts.get(d)).sort();l.length>0&&i.add("structure");let c=t.paragraphs.filter(d=>!d.shown),s=["paragraphs","text","formatting","structure","media","links"];return {ok:i.size===0,failed:s.filter(d=>i.has(d)),from:n.from,to:n.to,documentId:n.documentId,paragraphs:o.paragraphs.length,hidden:c.length,hiddenAt:c.slice(0,D).map(d=>({part:d.part,paragraph:d.index})),changedParts:l,differenceCount:r,differences:a,missingMedia:m,missingLinks:e}}function eo(o,t){let n=new Map;for(let r of t)n.set(r,(n.get(r)??0)+1);let a=new Set;for(let r of o){let i=n.get(r)??0;i===0?a.add(r):n.set(r,i-1);}return [...a].sort()}function I(o){if(o.kind==="textValue")return o.value;let t=a=>o.attributes.find(r=>r.localName===a)?.value??"";return (o.localName==="fldSimple"?`[${t("instr")}]`:o.localName==="sym"?`[${t("font")} ${t("char")}]`:"")+o.children.map(I).join("")}function no(o){let t=[],n=[],a=r=>{if(!(r.kind==="textValue"||r.localName==="p")){if(r.localName==="r"){let i=I(r);if(i==="")return;let p=r.children.find(c=>c.kind!=="textValue"&&c.localName==="rPr"),e=!p||p.kind==="textValue"||p.children.length===0&&p.attributes.length===0?"":store.canonicalOoxmlFingerprint(p),l=n.at(-1);l&&l.format===e?l.text+=i:n.push({format:e,text:i});return}for(let i of r.children)a(i);}};for(let r of o.children)r.kind!=="textValue"&&r.localName==="pPr"?t.push(store.canonicalOoxmlFingerprint(r)):a(r);return JSON.stringify([t,n.map(r=>[r.format,r.text.length])])}async function P(o){let t=store.readOoxmlPackage(o);if(!t.ok)throw new chunk5HK5RAD7_cjs.b("invalid-baseline",t.reason);let n=io(t.package.parts),a=[];for(let[m,e]of n){let l=0,c=s=>{if(s.kind!=="textValue"){if(s.localName==="p"){l+=1,a.push({part:m,index:l,text:I(s),formatting:no(s),shown:s.kind==="paragraph"});return}for(let d of s.children)c(d);}};c(e);}let r=new Map;for(let[m,e]of [...t.package.partBytes].sort(([l],[c])=>l<c?-1:1)){if(t.package.parts.has(m)||/\.(xml|rels)$/i.test(m))continue;let l=await lo(e);r.has(l)||r.set(l,m);}let i=t.package.externalTargets.map(m=>`${m.type} ${m.rawTarget}`),p=new Map;for(let[m,e]of n)/\.rels$/i.test(m)||p.set(m,store.canonicalOoxmlFingerprint(e));return {paragraphs:a,media:r,links:i,parts:p}}var ao="http://schemas.openxmlformats.org/wordprocessingml/2006/main",_=new Set(["paraId","paraIdParent"]),V={moveFromRangeStart:"moveFrom",moveFromRangeEnd:"moveFrom",moveToRangeStart:"moveTo",moveToRangeEnd:"moveTo",customXmlInsRangeStart:"customXmlIns",customXmlInsRangeEnd:"customXmlIns",customXmlDelRangeStart:"customXmlDel",customXmlDelRangeEnd:"customXmlDel",customXmlMoveFromRangeStart:"customXmlMoveFrom",customXmlMoveFromRangeEnd:"customXmlMoveFrom",customXmlMoveToRangeStart:"customXmlMoveTo",customXmlMoveToRangeEnd:"customXmlMoveTo",comment:"comment",commentRangeStart:"comment",commentRangeEnd:"comment",commentReference:"comment",footnote:"footnote",footnoteReference:"footnote",endnote:"endnote",endnoteReference:"endnote",bookmarkStart:"bookmark",bookmarkEnd:"bookmark",permStart:"permission",permEnd:"permission"};function io(o){let t=new Map,n=(e,l)=>{let c=t.get(e);c||t.set(e,c=new Map);let s=c.get(l);return s===void 0&&c.set(l,s=c.size),String(s)},a=[...o.keys()].sort(),r=new Map,i=e=>{if(e.kind!=="textValue"){if(e.localName==="p"){let l=e.attributes.find(c=>c.localName==="paraId")?.value;l!==void 0&&!r.has(l)&&r.set(l,r.size);}for(let l of e.children)i(l);}};for(let e of a)i(o.get(e).root);let p=e=>{if(e.kind==="textValue")return e;let l=Object.hasOwn(V,e.localName)?V[e.localName]:null,c=e.localName==="p";return {...e,attributes:e.attributes.filter(s=>s.localName!=="textId"&&!(c&&_.has(s.localName))).map(s=>s.localName==="id"&&s.namespaceUri===ao?{...s,value:l?n(l,s.value):""}:_.has(s.localName)?{...s,value:`p${r.get(s.value)??"?"}`}:s),children:e.children.map(p)}},m=new Map;for(let e of a)m.set(e,p(o.get(e).root));return m}async function lo(o){let t=o.buffer instanceof ArrayBuffer?o:o.slice(),n=new Uint8Array(await globalThis.crypto.subtle.digest("SHA-256",t)),a="";for(let r of n)a+=r.toString(16).padStart(2,"0");return a}function so(o,t){let n=i=>i.slice(i.indexOf(":")+1).split(".").map(Number),a=n(o),r=n(t);for(let i=0;i<Math.max(a.length,r.length);i+=1){let p=(a[i]??0)-(r[i]??0);if(p!==0)return p}return 0}
|
|
2
|
+
Object.defineProperty(exports,"collaborationModule",{enumerable:true,get:function(){return chunkQEULTKCT_cjs.a}});Object.defineProperty(exports,"checkCollaborationRoomGeneration",{enumerable:true,get:function(){return chunkUPKBD6AH_cjs.f}});Object.defineProperty(exports,"compactCollaborationState",{enumerable:true,get:function(){return chunkUPKBD6AH_cjs.b}});Object.defineProperty(exports,"readCollaborationRoomGeneration",{enumerable:true,get:function(){return chunkUPKBD6AH_cjs.a}});Object.defineProperty(exports,"CollaborationSchemaError",{enumerable:true,get:function(){return chunk5HK5RAD7_cjs.b}});Object.defineProperty(exports,"CollaborationUndoGroupError",{enumerable:true,get:function(){return chunk5HK5RAD7_cjs.p}});Object.defineProperty(exports,"DOCUMENT_COLLABORATION_VERSIONS",{enumerable:true,get:function(){return chunk5HK5RAD7_cjs.c}});Object.defineProperty(exports,"assertDocumentCollaborationCompatibility",{enumerable:true,get:function(){return chunk5HK5RAD7_cjs.d}});Object.defineProperty(exports,"createDocumentCollaboration",{enumerable:true,get:function(){return chunk5HK5RAD7_cjs.r}});Object.defineProperty(exports,"readCollaborationDocument",{enumerable:true,get:function(){return chunk5HK5RAD7_cjs.q}});Object.defineProperty(exports,"readCollaborationResourceUsage",{enumerable:true,get:function(){return chunk5HK5RAD7_cjs.o}});exports.COLLABORATION_FORMAT_VERSION=b;exports.MAX_BASELINE_BYTES=M;exports.PROTOCOL_VERSION=j;exports.SCHEMA_VERSION=K;exports.assertCollaborationFormatCompatibility=q;exports.collaborationMigrationNeed=Z;exports.createCollaborationState=W;exports.migrateCollaborationRoom=oo;exports.prepareCollaborationServerDocument=J;exports.readCollaborationFormatVersion=k;
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
export { C as CollaborationModuleOptions, c as collaborationModule } from '../collaboration-module-02CIP5sN.cjs';
|
|
12
12
|
export { a as CollaborationBootstrap, c as CollaborationHandle, b as CollaborationIdentityUpdate, C as CollaborationSession } from '../types-DvGpDOcZ.cjs';
|
|
13
|
-
export { C as
|
|
13
|
+
export { C as CollaborationResourceLimit, a as CollaborationResourcePressure, b as CollaborationResourcePressureOptions, c as CollaborationResourceUsage, d as CollaborationUndoGroup, e as CollaborationUndoGroupError, f as CollaborationUndoGroupErrorCode, D as DocumentCollaborationHandle, g as DocumentCollaborationSession, h as createDocumentCollaboration, r as readCollaborationResourceUsage } from '../document-session-DZK2tAr4.cjs';
|
|
14
14
|
import * as Y from 'yjs';
|
|
15
15
|
import { CollaborationFailureCode, EditorCollaborationSession } from '@docx-editor.dev/core/collaboration';
|
|
16
16
|
export { C as CreateDocumentCollaborationOptions } from '../document-session-options-CxR0F5xT.cjs';
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
export { C as CollaborationModuleOptions, c as collaborationModule } from '../collaboration-module-COZAgqwg.js';
|
|
12
12
|
export { a as CollaborationBootstrap, c as CollaborationHandle, b as CollaborationIdentityUpdate, C as CollaborationSession } from '../types-DvGpDOcZ.js';
|
|
13
|
-
export { C as
|
|
13
|
+
export { C as CollaborationResourceLimit, a as CollaborationResourcePressure, b as CollaborationResourcePressureOptions, c as CollaborationResourceUsage, d as CollaborationUndoGroup, e as CollaborationUndoGroupError, f as CollaborationUndoGroupErrorCode, D as DocumentCollaborationHandle, g as DocumentCollaborationSession, h as createDocumentCollaboration, r as readCollaborationResourceUsage } from '../document-session-B6v5LZIK.js';
|
|
14
14
|
import * as Y from 'yjs';
|
|
15
15
|
import { CollaborationFailureCode, EditorCollaborationSession } from '@docx-editor.dev/core/collaboration';
|
|
16
16
|
export { C as CreateDocumentCollaborationOptions } from '../document-session-options-CdOH-TNn.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export{a as collaborationModule}from'../chunk-EOZ44UA7.js';import {c as c$1}from'../chunk-
|
|
2
|
-
export{b as COLLABORATION_FORMAT_VERSION,M as MAX_BASELINE_BYTES,j as PROTOCOL_VERSION,K as SCHEMA_VERSION,q as assertCollaborationFormatCompatibility,Z as collaborationMigrationNeed,W as createCollaborationState,oo as migrateCollaborationRoom,J as prepareCollaborationServerDocument,
|
|
1
|
+
export{a as collaborationModule}from'../chunk-EOZ44UA7.js';import {c as c$1}from'../chunk-IFDU5O5J.js';export{f as checkCollaborationRoomGeneration,b as compactCollaborationState,a as readCollaborationRoomGeneration}from'../chunk-IFDU5O5J.js';import {c,a,i,b as b$1,e,q as q$1}from'../chunk-4TS2D6OV.js';export{b as CollaborationSchemaError,p as CollaborationUndoGroupError,c as DOCUMENT_COLLABORATION_VERSIONS,d as assertDocumentCollaborationCompatibility,r as createDocumentCollaboration,q as readCollaborationDocument,o as readCollaborationResourceUsage}from'../chunk-4TS2D6OV.js';import'../chunk-HMU7J34H.js';import*as O from'yjs';import {readOoxmlPackage,canonicalOoxmlFingerprint}from'@docx-editor.dev/core/store';var j=1,K=1,M=20971520;function J(o){return a(o)}async function W(o,t){let n=i(t.documentId),a=t.maxBytes??20971520;if(!Number.isSafeInteger(a)||a<=0||a>20971520)throw new TypeError(`maxBytes must be a whole number of bytes from 1 to ${20971520}`);return c$1(o,n,{maxBytes:a})}var A=["protocolVersion","sharedSchemaVersion","repairVersion","canonicalModelVersion"];function T(o){return `docx-collaboration:${o.join(".")}`}var b=T(A.map(o=>c[o]));function q(o){if(o!==b)throw new b$1("collaboration-format-mismatch","The collaboration format version is missing or incompatible with this deployment.")}function k(o){if(!o.share.has(e))throw new b$1("not-initialized");let t;try{t=o.getMap(e);}catch{throw new b$1("collaboration-format-mismatch","The saved room has invalid collaboration version information.")}if(t.get("initialized")!==true||typeof t.get("documentId")!="string")throw new b$1("not-initialized");let n=A.map(a=>{let r=t.get(a);if(typeof r!="number"||!Number.isSafeInteger(r)||r<0)throw new b$1("collaboration-format-mismatch","The saved room has missing or invalid collaboration version information.");return r});return T(n)}function Z(o){return w(o,t=>L(F(t)))}async function oo(o){let t=w(o.state,l=>({format:F(l),documentId:to(l)})),n=L(t.format);if(n==="current")return {ok:false,reason:"current"};if(n==="later-format")return {ok:false,reason:"later-format"};let a=o.documentId??t.documentId;if(typeof a!="string")throw new b$1("invalid-document-id","The earlier room holds no document ID. Pass the ID its clients use as documentId.");let r=i(a),i$1=await c$1(o.exported,r,{keepBound:true}),p=w(i$1,l=>q$1(l)),m=await P(o.exported),e=ro(m,await P(p),{from:t.format??"unversioned",to:b,documentId:r});return e.ok?{ok:true,state:i$1,report:e}:{ok:false,reason:"check-failed",report:e}}function w(o,t){let n=new O.Doc;try{try{O.applyUpdate(n,o);}catch{throw new b$1("invalid-baseline","The bytes are not room state.")}return t(n)}finally{n.destroy();}}function to(o){try{return o.getMap(e).get("documentId")}catch{return}}function F(o){try{return k(o)}catch(t){if(t instanceof b$1&&t.code==="collaboration-format-mismatch")return null;throw t}}function L(o){if(o===null)return "earlier-format";let t=so(o,b);return t===0?"current":t<0?"earlier-format":"later-format"}var D=20;function ro(o,t,n){let a=[],r=0,i=new Set;o.paragraphs.length!==t.paragraphs.length&&i.add("paragraphs");let p=Math.max(o.paragraphs.length,t.paragraphs.length);for(let d=0;d<p;d+=1){let g=o.paragraphs[d],u=t.paragraphs[d],y=u?g?g.text!==u.text?"text":g.formatting!==u.formatting?"formatting":null:"added":"missing";if(y===null||((y==="text"||y==="formatting")&&i.add(y),r+=1,a.length>=D))continue;let v=g??u;a.push({part:v.part,paragraph:v.index,kind:y,expected:g?.text??null,actual:u?.text??null});}let m=[...o.media].filter(([d])=>!t.media.has(d)).map(([,d])=>d).sort();m.length>0&&i.add("media");let e=eo(o.links,t.links);e.length>0&&i.add("links");let l=[...new Set([...o.parts.keys(),...t.parts.keys()])].filter(d=>o.parts.get(d)!==t.parts.get(d)).sort();l.length>0&&i.add("structure");let c=t.paragraphs.filter(d=>!d.shown),s=["paragraphs","text","formatting","structure","media","links"];return {ok:i.size===0,failed:s.filter(d=>i.has(d)),from:n.from,to:n.to,documentId:n.documentId,paragraphs:o.paragraphs.length,hidden:c.length,hiddenAt:c.slice(0,D).map(d=>({part:d.part,paragraph:d.index})),changedParts:l,differenceCount:r,differences:a,missingMedia:m,missingLinks:e}}function eo(o,t){let n=new Map;for(let r of t)n.set(r,(n.get(r)??0)+1);let a=new Set;for(let r of o){let i=n.get(r)??0;i===0?a.add(r):n.set(r,i-1);}return [...a].sort()}function I(o){if(o.kind==="textValue")return o.value;let t=a=>o.attributes.find(r=>r.localName===a)?.value??"";return (o.localName==="fldSimple"?`[${t("instr")}]`:o.localName==="sym"?`[${t("font")} ${t("char")}]`:"")+o.children.map(I).join("")}function no(o){let t=[],n=[],a=r=>{if(!(r.kind==="textValue"||r.localName==="p")){if(r.localName==="r"){let i=I(r);if(i==="")return;let p=r.children.find(c=>c.kind!=="textValue"&&c.localName==="rPr"),e=!p||p.kind==="textValue"||p.children.length===0&&p.attributes.length===0?"":canonicalOoxmlFingerprint(p),l=n.at(-1);l&&l.format===e?l.text+=i:n.push({format:e,text:i});return}for(let i of r.children)a(i);}};for(let r of o.children)r.kind!=="textValue"&&r.localName==="pPr"?t.push(canonicalOoxmlFingerprint(r)):a(r);return JSON.stringify([t,n.map(r=>[r.format,r.text.length])])}async function P(o){let t=readOoxmlPackage(o);if(!t.ok)throw new b$1("invalid-baseline",t.reason);let n=io(t.package.parts),a=[];for(let[m,e]of n){let l=0,c=s=>{if(s.kind!=="textValue"){if(s.localName==="p"){l+=1,a.push({part:m,index:l,text:I(s),formatting:no(s),shown:s.kind==="paragraph"});return}for(let d of s.children)c(d);}};c(e);}let r=new Map;for(let[m,e]of [...t.package.partBytes].sort(([l],[c])=>l<c?-1:1)){if(t.package.parts.has(m)||/\.(xml|rels)$/i.test(m))continue;let l=await lo(e);r.has(l)||r.set(l,m);}let i=t.package.externalTargets.map(m=>`${m.type} ${m.rawTarget}`),p=new Map;for(let[m,e]of n)/\.rels$/i.test(m)||p.set(m,canonicalOoxmlFingerprint(e));return {paragraphs:a,media:r,links:i,parts:p}}var ao="http://schemas.openxmlformats.org/wordprocessingml/2006/main",_=new Set(["paraId","paraIdParent"]),V={moveFromRangeStart:"moveFrom",moveFromRangeEnd:"moveFrom",moveToRangeStart:"moveTo",moveToRangeEnd:"moveTo",customXmlInsRangeStart:"customXmlIns",customXmlInsRangeEnd:"customXmlIns",customXmlDelRangeStart:"customXmlDel",customXmlDelRangeEnd:"customXmlDel",customXmlMoveFromRangeStart:"customXmlMoveFrom",customXmlMoveFromRangeEnd:"customXmlMoveFrom",customXmlMoveToRangeStart:"customXmlMoveTo",customXmlMoveToRangeEnd:"customXmlMoveTo",comment:"comment",commentRangeStart:"comment",commentRangeEnd:"comment",commentReference:"comment",footnote:"footnote",footnoteReference:"footnote",endnote:"endnote",endnoteReference:"endnote",bookmarkStart:"bookmark",bookmarkEnd:"bookmark",permStart:"permission",permEnd:"permission"};function io(o){let t=new Map,n=(e,l)=>{let c=t.get(e);c||t.set(e,c=new Map);let s=c.get(l);return s===void 0&&c.set(l,s=c.size),String(s)},a=[...o.keys()].sort(),r=new Map,i=e=>{if(e.kind!=="textValue"){if(e.localName==="p"){let l=e.attributes.find(c=>c.localName==="paraId")?.value;l!==void 0&&!r.has(l)&&r.set(l,r.size);}for(let l of e.children)i(l);}};for(let e of a)i(o.get(e).root);let p=e=>{if(e.kind==="textValue")return e;let l=Object.hasOwn(V,e.localName)?V[e.localName]:null,c=e.localName==="p";return {...e,attributes:e.attributes.filter(s=>s.localName!=="textId"&&!(c&&_.has(s.localName))).map(s=>s.localName==="id"&&s.namespaceUri===ao?{...s,value:l?n(l,s.value):""}:_.has(s.localName)?{...s,value:`p${r.get(s.value)??"?"}`}:s),children:e.children.map(p)}},m=new Map;for(let e of a)m.set(e,p(o.get(e).root));return m}async function lo(o){let t=o.buffer instanceof ArrayBuffer?o:o.slice(),n=new Uint8Array(await globalThis.crypto.subtle.digest("SHA-256",t)),a="";for(let r of n)a+=r.toString(16).padStart(2,"0");return a}function so(o,t){let n=i=>i.slice(i.indexOf(":")+1).split(".").map(Number),a=n(o),r=n(t);for(let i=0;i<Math.max(a.length,r.length);i+=1){let p=(a[i]??0)-(r[i]??0);if(p!==0)return p}return 0}
|
|
2
|
+
export{b as COLLABORATION_FORMAT_VERSION,M as MAX_BASELINE_BYTES,j as PROTOCOL_VERSION,K as SCHEMA_VERSION,q as assertCollaborationFormatCompatibility,Z as collaborationMigrationNeed,W as createCollaborationState,oo as migrateCollaborationRoom,J as prepareCollaborationServerDocument,k as readCollaborationFormatVersion};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var chunkLUUFBXJ5_cjs=require('../chunk-LUUFBXJ5.cjs'),
|
|
1
|
+
'use strict';var chunkLUUFBXJ5_cjs=require('../chunk-LUUFBXJ5.cjs'),chunk5HK5RAD7_cjs=require('../chunk-5HK5RAD7.cjs'),Q=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 Q__namespace=/*#__PURE__*/_interopNamespace(Q);function N(e,n){let t=0,o=null,i=new Set,a=()=>{o!==null&&clearInterval(o),o=null;},r=l=>{if(l!==t){t=l,t===0&&a();for(let f of [...i])f();}},s=()=>{let l=n.room;if(l===null)return false;if(l.bcConns.size>0)return true;for(let f of l.webrtcConns.values())if(f.connected&&f.synced)return true;return false},b=()=>{t>0&&s()&&r(0);},g=(l,f)=>{f===n.room||s()||(r(t+1),o??=setInterval(b,1e3));};return e.on("update",g),n.on("peers",b),n.on("synced",b),{count:()=>t,subscribe(l){return i.add(l),()=>{i.delete(l);}},destroy(){a(),e.off("update",g),n.off("peers",b),n.off("synced",b),i.clear();}}}var O=new WeakSet,k=(e,n)=>(e[n]<<24|e[n+1]<<16|e[n+2]<<8|e[n+3])>>>0,P=(e,n,t)=>{e[n]=t>>>24&255,e[n+1]=t>>>16&255,e[n+2]=t>>>8&255,e[n+3]=t&255;},te=e=>e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):null,oe=e=>new Promise(n=>{setTimeout(n,e);});function W(e,n){if(O.has(e))return;O.add(e);let t=e.send.bind(e),o=e._onChannelMessage.bind(e),i=n?.partialTimeoutMs,a=typeof i=="number"&&Number.isFinite(i)&&i>0?i:3e4,r=n?.onAbandonedMessage,s=n?.onDeliveredMessage,b=Math.min(n?.maxPartialBytes??1/0,134111232),g=[],l=new Map,f=false,_=1,E=0,C=(c,d)=>{d.timer!==void 0&&clearTimeout(d.timer),l.delete(c),E-=d.bytes;},m=c=>{let d=l.get(c);d&&(C(c,d),e.destroyed!==true&&(r?.(),e.destroy?.()));},R=c=>{let d=l.get(c);d&&(d.timer!==void 0&&clearTimeout(d.timer),d.timer=setTimeout(()=>{m(c);},a));},y=()=>e._channel?.bufferedAmount??0,v=async()=>{let c=0;for(;y()>1048576;){if(e.destroyed===true||c>=3e4)return false;await oe(20),c+=20;}return e.destroyed!==true},V=async c=>{let d=Math.ceil(c.byteLength/16371);if(d>8192)throw new Error(`collaboration message needs ${d} chunks, above the 8192 limit`);let S=_;_=_+1>>>0||1;for(let A=0;A<d;A+=1){if(!await v()){e.destroyed!==true&&e.destroy?.();return}let h=A*16371,u=c.subarray(h,Math.min(h+16371,c.byteLength)),p=new Uint8Array(13+u.byteLength);p[0]=251,P(p,1,S),P(p,5,A),P(p,9,d),p.set(u,13),t(p);}},ee=async()=>{if(!f){f=true;try{for(;g.length>0;){let c=g.shift();if(c){if(e.destroyed===!0)return;await V(c);}}}finally{f=false;}}};e.send=c=>{if(typeof c=="string"||c.byteLength<=16371){t(c);return}g.push(c),ee();},e._onChannelMessage=c=>{let d=te(c.data);if(!d||d.byteLength<13||d[0]!==251){o(c);return}let S=k(d,1),A=k(d,5),h=k(d,9);if(h===0||h>8192||A>=h)return;if(d.byteLength>16384){m(S);return}let u=l.get(S);if(!u){if(l.size>=4){let M=l.keys().next();M.done||m(M.value);}u={chunks:new Array(h),count:h,received:0,bytes:0,timer:void 0},l.set(S,u);}if(u.count!==h||u.chunks[A])return;let p=d.subarray(13);if(u.chunks[A]=p,u.received+=1,u.bytes+=p.byteLength,E+=p.byteLength,E>b){m(S);return}if(u.received!==u.count){R(S);return}C(S,u);let Y=new Uint8Array(u.bytes),F=0;for(let M of u.chunks){if(!M)return;Y.set(M,F),F+=M.byteLength;}e.destroyed!==true&&(e.push(Y),s?.());};}function j(e,n){return t=>{n()&&(t?e.setTransportStatus("ready","transport-disconnected","a peer link cannot carry large updates"):e.setTransportStatus("ready"));}}var re=3,ie=6e4;function X(e,n={set:(t,o)=>setTimeout(t,o),clear:t=>clearTimeout(t)}){let t=new Map,o=new Map,i=new Set,a=r=>{t.delete(r);let s=o.get(r);s!==void 0&&n.clear(s),o.delete(r),i.delete(r)&&i.size===0&&e(false);};return {abandoned(r){let s=(t.get(r)??0)+1;t.set(r,s);let b=o.get(r);b!==void 0&&n.clear(b),o.set(r,n.set(()=>a(r),ie)),!(s<re||i.has(r))&&(i.add(r),i.size===1&&e(true));},delivered:a,reset(){for(let r of [...t.keys(),...i])a(r);},destroy(){for(let r of o.values())n.clear(r);o.clear(),t.clear(),i.clear();}}}var K=Symbol.for("docx-editor.webrtc-signaling-scope"),U=new WeakMap,I=new WeakSet,B=new WeakSet,z=new WeakSet,q=e=>{let n=U.get(e);return n||(n=new Set,U.set(e,n)),n};function se(e){B.add(e),I.add(e);}function ae(e){B.add(e),I.delete(e);}var ce=e=>e?B.has(e)?I.has(e):e.bcconnected===true:false;function x(e,n){if(typeof n!="string")return false;for(let t of e.providers)if(t.roomName===n&&t.shouldConnect!==false&&ce(t.room))return true;return false}var $=e=>Array.isArray(e)?e.filter(n=>typeof n=="string"):[];function de(e,n){if(n===null||typeof n!="object")return n;let{type:t,topic:o,topics:i}=n;switch(t){case "subscribe":{let a=$(i).filter(s=>x(e,s));if(a.length===0)return null;let r=q(e);for(let s of a)r.add(s);return {...n,topics:a}}case "unsubscribe":{let a=q(e),r=$(i).filter(s=>a.has(s));if(r.length===0)return null;for(let s of r)a.delete(s);return {...n,topics:r}}case "publish":return x(e,o)?n:null;default:return n}}function le(e,n){if(n===null||typeof n!="object")return true;let{type:t,topic:o}=n;return t!=="publish"||x(e,o)}function ue(e){U.delete(e);}var w=(e,n,t)=>{let o=e;o[n]=t(o[n]);};function Z(){let e=yWebrtc.SignalingConn.prototype;e[K]||(e[K]=true,w(yWebrtc.SignalingConn.prototype,"send",n=>function(o){let i=de(this,o);i!==null&&n.call(this,i);}),w(yWebrtc.SignalingConn.prototype,"emit",n=>function(o,i){o==="disconnect"&&ue(this);let a=Array.isArray(i)?i[0]:void 0;if(!(o==="message"&&!le(this,a)))return n.call(this,o,i)}),w(yWebrtc.Room.prototype,"connect",n=>function(){return se(this),n.call(this)}),w(yWebrtc.Room.prototype,"disconnect",n=>function(){return ae(this),n.call(this)}),w(yWebrtc.WebrtcProvider.prototype,"disconnect",n=>function(){this.shouldConnect&&(n.call(this),this.signalingConns=[...new Set(this.signalingConns.filter(o=>o.providers.has(this)))]);}),w(yWebrtc.WebrtcProvider.prototype,"destroy",n=>function(){return z.add(this),this.shouldConnect&&this.disconnect(),n.call(this)}),w(yWebrtc.WebrtcProvider.prototype,"connect",n=>function(){if(!z.has(this))return n.call(this)}));}var Ue=Object.freeze(["wss://turn.0docker.com/ws"]);function be(e){if(!Array.isArray(e))throw new TypeError("WebRTC collaboration requires `signaling`, an array of signaling server URLs. Pass your own URLs in production. For demos, pass `signaling: DEMO_SIGNALING_ENDPOINTS` from '@docx-editor.dev/pro/collaboration/webrtc'. To connect only tabs of the same browser, pass `signaling: []`.");return e.forEach((n,t)=>{if(!ge(n))throw new TypeError(`WebRTC collaboration needs signaling[${t}] to be a ws:// or wss:// URL without a #fragment.`)}),e}var ge=e=>{if(typeof e!="string")return false;try{let{protocol:n}=new URL(e);return (n==="ws:"||n==="wss:")&&!e.includes("#")}catch{return false}},pe=/^[A-Za-z0-9_-]{24,256}$/,J="#collab=";function he(e){let n=e.password?.trim()??"";return n.length>0?n:me(e.href)}var me=e=>{let n=e??(typeof globalThis.location=="object"&&globalThis.location!==null?String(globalThis.location.href??""):"");if(n.length===0)return;let t;try{t=new URL(n).hash;}catch{return}if(!t.startsWith(J))return;let o;try{o=decodeURIComponent(t.slice(J.length));}catch{return}if(pe.test(o))return o},Se=(e,n)=>{Promise.resolve(e.key).then(()=>{let t=e.room;if(!t)return;let o=t.webrtcConns,i=(r,s)=>{W(s.peer,{onAbandonedMessage:()=>n.abandoned(r),onDeliveredMessage:()=>n.delivered(r)});};for(let[r,s]of o)i(r,s);let a=o.set.bind(o);o.set=(r,s)=>(i(r,s),a(r,s));});};async function xe(e){let n=chunkLUUFBXJ5_cjs.b(e.roomId),t=be(e.signaling);Z();let o=he({password:e.password}),i=new Q__namespace.Doc,a=new awareness.Awareness(i),r=null,s={abandoned(){},delivered(){}},b=()=>{let y=new yWebrtc.WebrtcProvider(n,i,{awareness:a,signaling:[...t],...o!==void 0?{password:o}:{},...e.iceServers?{peerOpts:{config:{iceServers:e.iceServers.map(v=>({...v}))}}}:{}});return Se(y,{abandoned:v=>s.abandoned(v),delivered:v=>s.delivered(v)}),y},g;try{e.bootstrap.kind!=="create"&&(r=b()),g=await chunk5HK5RAD7_cjs.r({ydoc:i,awareness:a,documentId:n,identity:e.identity,bootstrap:e.bootstrap,offlineEditing:e.offlineEditing}),r||(r=b());}catch(y){throw r?.destroy(),a.destroy(),i.destroy(),y}if(!r)throw g.destroy(),a.destroy(),i.destroy(),new Error("WebRTC provider did not initialize");let l=r,f=g.session,_=true,E=X(j(f,()=>_));s=E;let C=y=>{_=y.connected,y.connected&&E.reset(),f.setTransportStatus(y.connected?"ready":"disconnected",y.connected?void 0:"transport-disconnected",y.connected?void 0:"webrtc disconnected");};l.on("status",C);let m=N(i,l),R=false;return Object.freeze({document:g.document,session:f,ydoc:i,provider:l,unsyncedChanges:()=>m.count(),subscribeUnsyncedChanges:y=>m.subscribe(y),destroy(){R||(R=true,l.off("status",C),m.destroy(),E.destroy(),g.destroy(),l.destroy(),a.destroy(),i.destroy());}})}
|
|
2
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=Ue;exports.createWebrtcCollaboration=xe;exports.requireSignaling=be;exports.resolveWebrtcRoomPassword=he;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import * as Y from 'yjs';
|
|
9
9
|
import { WebrtcProvider } from 'y-webrtc';
|
|
10
10
|
import { CollaborationIdentity } from '@docx-editor.dev/core/collaboration';
|
|
11
|
-
import { D as DocumentCollaborationHandle } from '../document-session-
|
|
11
|
+
import { D as DocumentCollaborationHandle } from '../document-session-DZK2tAr4.cjs';
|
|
12
12
|
import { a as CollaborationBootstrap } from '../types-DvGpDOcZ.cjs';
|
|
13
13
|
export { c as createCollaborationRoomId, v as validateRoomId } from '../room-id-BfudXOZz.cjs';
|
|
14
14
|
import '../document-session-options-CxR0F5xT.cjs';
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import * as Y from 'yjs';
|
|
9
9
|
import { WebrtcProvider } from 'y-webrtc';
|
|
10
10
|
import { CollaborationIdentity } from '@docx-editor.dev/core/collaboration';
|
|
11
|
-
import { D as DocumentCollaborationHandle } from '../document-session-
|
|
11
|
+
import { D as DocumentCollaborationHandle } from '../document-session-B6v5LZIK.js';
|
|
12
12
|
import { a as CollaborationBootstrap } from '../types-DvGpDOcZ.js';
|
|
13
13
|
export { c as createCollaborationRoomId, v as validateRoomId } from '../room-id-BfudXOZz.js';
|
|
14
14
|
import '../document-session-options-CdOH-TNn.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {b}from'../chunk-6DEUT2RQ.js';export{a as createCollaborationRoomId,b as validateRoomId}from'../chunk-6DEUT2RQ.js';import {r}from'../chunk-
|
|
1
|
+
import {b}from'../chunk-6DEUT2RQ.js';export{a as createCollaborationRoomId,b as validateRoomId}from'../chunk-6DEUT2RQ.js';import {r}from'../chunk-4TS2D6OV.js';import*as Q from'yjs';import {Awareness}from'y-protocols/awareness';import {WebrtcProvider,SignalingConn,Room}from'y-webrtc';function N(e,n){let t=0,o=null,i=new Set,a=()=>{o!==null&&clearInterval(o),o=null;},r=l=>{if(l!==t){t=l,t===0&&a();for(let f of [...i])f();}},s=()=>{let l=n.room;if(l===null)return false;if(l.bcConns.size>0)return true;for(let f of l.webrtcConns.values())if(f.connected&&f.synced)return true;return false},b=()=>{t>0&&s()&&r(0);},g=(l,f)=>{f===n.room||s()||(r(t+1),o??=setInterval(b,1e3));};return e.on("update",g),n.on("peers",b),n.on("synced",b),{count:()=>t,subscribe(l){return i.add(l),()=>{i.delete(l);}},destroy(){a(),e.off("update",g),n.off("peers",b),n.off("synced",b),i.clear();}}}var O=new WeakSet,k=(e,n)=>(e[n]<<24|e[n+1]<<16|e[n+2]<<8|e[n+3])>>>0,P=(e,n,t)=>{e[n]=t>>>24&255,e[n+1]=t>>>16&255,e[n+2]=t>>>8&255,e[n+3]=t&255;},te=e=>e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):null,oe=e=>new Promise(n=>{setTimeout(n,e);});function W(e,n){if(O.has(e))return;O.add(e);let t=e.send.bind(e),o=e._onChannelMessage.bind(e),i=n?.partialTimeoutMs,a=typeof i=="number"&&Number.isFinite(i)&&i>0?i:3e4,r=n?.onAbandonedMessage,s=n?.onDeliveredMessage,b=Math.min(n?.maxPartialBytes??1/0,134111232),g=[],l=new Map,f=false,_=1,E=0,C=(c,d)=>{d.timer!==void 0&&clearTimeout(d.timer),l.delete(c),E-=d.bytes;},m=c=>{let d=l.get(c);d&&(C(c,d),e.destroyed!==true&&(r?.(),e.destroy?.()));},R=c=>{let d=l.get(c);d&&(d.timer!==void 0&&clearTimeout(d.timer),d.timer=setTimeout(()=>{m(c);},a));},y=()=>e._channel?.bufferedAmount??0,v=async()=>{let c=0;for(;y()>1048576;){if(e.destroyed===true||c>=3e4)return false;await oe(20),c+=20;}return e.destroyed!==true},V=async c=>{let d=Math.ceil(c.byteLength/16371);if(d>8192)throw new Error(`collaboration message needs ${d} chunks, above the 8192 limit`);let S=_;_=_+1>>>0||1;for(let A=0;A<d;A+=1){if(!await v()){e.destroyed!==true&&e.destroy?.();return}let h=A*16371,u=c.subarray(h,Math.min(h+16371,c.byteLength)),p=new Uint8Array(13+u.byteLength);p[0]=251,P(p,1,S),P(p,5,A),P(p,9,d),p.set(u,13),t(p);}},ee=async()=>{if(!f){f=true;try{for(;g.length>0;){let c=g.shift();if(c){if(e.destroyed===!0)return;await V(c);}}}finally{f=false;}}};e.send=c=>{if(typeof c=="string"||c.byteLength<=16371){t(c);return}g.push(c),ee();},e._onChannelMessage=c=>{let d=te(c.data);if(!d||d.byteLength<13||d[0]!==251){o(c);return}let S=k(d,1),A=k(d,5),h=k(d,9);if(h===0||h>8192||A>=h)return;if(d.byteLength>16384){m(S);return}let u=l.get(S);if(!u){if(l.size>=4){let M=l.keys().next();M.done||m(M.value);}u={chunks:new Array(h),count:h,received:0,bytes:0,timer:void 0},l.set(S,u);}if(u.count!==h||u.chunks[A])return;let p=d.subarray(13);if(u.chunks[A]=p,u.received+=1,u.bytes+=p.byteLength,E+=p.byteLength,E>b){m(S);return}if(u.received!==u.count){R(S);return}C(S,u);let Y=new Uint8Array(u.bytes),F=0;for(let M of u.chunks){if(!M)return;Y.set(M,F),F+=M.byteLength;}e.destroyed!==true&&(e.push(Y),s?.());};}function j(e,n){return t=>{n()&&(t?e.setTransportStatus("ready","transport-disconnected","a peer link cannot carry large updates"):e.setTransportStatus("ready"));}}var re=3,ie=6e4;function X(e,n={set:(t,o)=>setTimeout(t,o),clear:t=>clearTimeout(t)}){let t=new Map,o=new Map,i=new Set,a=r=>{t.delete(r);let s=o.get(r);s!==void 0&&n.clear(s),o.delete(r),i.delete(r)&&i.size===0&&e(false);};return {abandoned(r){let s=(t.get(r)??0)+1;t.set(r,s);let b=o.get(r);b!==void 0&&n.clear(b),o.set(r,n.set(()=>a(r),ie)),!(s<re||i.has(r))&&(i.add(r),i.size===1&&e(true));},delivered:a,reset(){for(let r of [...t.keys(),...i])a(r);},destroy(){for(let r of o.values())n.clear(r);o.clear(),t.clear(),i.clear();}}}var K=Symbol.for("docx-editor.webrtc-signaling-scope"),U=new WeakMap,I=new WeakSet,B=new WeakSet,z=new WeakSet,q=e=>{let n=U.get(e);return n||(n=new Set,U.set(e,n)),n};function se(e){B.add(e),I.add(e);}function ae(e){B.add(e),I.delete(e);}var ce=e=>e?B.has(e)?I.has(e):e.bcconnected===true:false;function x(e,n){if(typeof n!="string")return false;for(let t of e.providers)if(t.roomName===n&&t.shouldConnect!==false&&ce(t.room))return true;return false}var $=e=>Array.isArray(e)?e.filter(n=>typeof n=="string"):[];function de(e,n){if(n===null||typeof n!="object")return n;let{type:t,topic:o,topics:i}=n;switch(t){case "subscribe":{let a=$(i).filter(s=>x(e,s));if(a.length===0)return null;let r=q(e);for(let s of a)r.add(s);return {...n,topics:a}}case "unsubscribe":{let a=q(e),r=$(i).filter(s=>a.has(s));if(r.length===0)return null;for(let s of r)a.delete(s);return {...n,topics:r}}case "publish":return x(e,o)?n:null;default:return n}}function le(e,n){if(n===null||typeof n!="object")return true;let{type:t,topic:o}=n;return t!=="publish"||x(e,o)}function ue(e){U.delete(e);}var w=(e,n,t)=>{let o=e;o[n]=t(o[n]);};function Z(){let e=SignalingConn.prototype;e[K]||(e[K]=true,w(SignalingConn.prototype,"send",n=>function(o){let i=de(this,o);i!==null&&n.call(this,i);}),w(SignalingConn.prototype,"emit",n=>function(o,i){o==="disconnect"&&ue(this);let a=Array.isArray(i)?i[0]:void 0;if(!(o==="message"&&!le(this,a)))return n.call(this,o,i)}),w(Room.prototype,"connect",n=>function(){return se(this),n.call(this)}),w(Room.prototype,"disconnect",n=>function(){return ae(this),n.call(this)}),w(WebrtcProvider.prototype,"disconnect",n=>function(){this.shouldConnect&&(n.call(this),this.signalingConns=[...new Set(this.signalingConns.filter(o=>o.providers.has(this)))]);}),w(WebrtcProvider.prototype,"destroy",n=>function(){return z.add(this),this.shouldConnect&&this.disconnect(),n.call(this)}),w(WebrtcProvider.prototype,"connect",n=>function(){if(!z.has(this))return n.call(this)}));}var Ue=Object.freeze(["wss://turn.0docker.com/ws"]);function be(e){if(!Array.isArray(e))throw new TypeError("WebRTC collaboration requires `signaling`, an array of signaling server URLs. Pass your own URLs in production. For demos, pass `signaling: DEMO_SIGNALING_ENDPOINTS` from '@docx-editor.dev/pro/collaboration/webrtc'. To connect only tabs of the same browser, pass `signaling: []`.");return e.forEach((n,t)=>{if(!ge(n))throw new TypeError(`WebRTC collaboration needs signaling[${t}] to be a ws:// or wss:// URL without a #fragment.`)}),e}var ge=e=>{if(typeof e!="string")return false;try{let{protocol:n}=new URL(e);return (n==="ws:"||n==="wss:")&&!e.includes("#")}catch{return false}},pe=/^[A-Za-z0-9_-]{24,256}$/,J="#collab=";function he(e){let n=e.password?.trim()??"";return n.length>0?n:me(e.href)}var me=e=>{let n=e??(typeof globalThis.location=="object"&&globalThis.location!==null?String(globalThis.location.href??""):"");if(n.length===0)return;let t;try{t=new URL(n).hash;}catch{return}if(!t.startsWith(J))return;let o;try{o=decodeURIComponent(t.slice(J.length));}catch{return}if(pe.test(o))return o},Se=(e,n)=>{Promise.resolve(e.key).then(()=>{let t=e.room;if(!t)return;let o=t.webrtcConns,i=(r,s)=>{W(s.peer,{onAbandonedMessage:()=>n.abandoned(r),onDeliveredMessage:()=>n.delivered(r)});};for(let[r,s]of o)i(r,s);let a=o.set.bind(o);o.set=(r,s)=>(i(r,s),a(r,s));});};async function xe(e){let n=b(e.roomId),t=be(e.signaling);Z();let o=he({password:e.password}),i=new Q.Doc,a=new Awareness(i),r$1=null,s={abandoned(){},delivered(){}},b$1=()=>{let y=new WebrtcProvider(n,i,{awareness:a,signaling:[...t],...o!==void 0?{password:o}:{},...e.iceServers?{peerOpts:{config:{iceServers:e.iceServers.map(v=>({...v}))}}}:{}});return Se(y,{abandoned:v=>s.abandoned(v),delivered:v=>s.delivered(v)}),y},g;try{e.bootstrap.kind!=="create"&&(r$1=b$1()),g=await r({ydoc:i,awareness:a,documentId:n,identity:e.identity,bootstrap:e.bootstrap,offlineEditing:e.offlineEditing}),r$1||(r$1=b$1());}catch(y){throw r$1?.destroy(),a.destroy(),i.destroy(),y}if(!r$1)throw g.destroy(),a.destroy(),i.destroy(),new Error("WebRTC provider did not initialize");let l=r$1,f=g.session,_=true,E=X(j(f,()=>_));s=E;let C=y=>{_=y.connected,y.connected&&E.reset(),f.setTransportStatus(y.connected?"ready":"disconnected",y.connected?void 0:"transport-disconnected",y.connected?void 0:"webrtc disconnected");};l.on("status",C);let m=N(i,l),R=false;return Object.freeze({document:g.document,session:f,ydoc:i,provider:l,unsyncedChanges:()=>m.count(),subscribeUnsyncedChanges:y=>m.subscribe(y),destroy(){R||(R=true,l.off("status",C),m.destroy(),E.destroy(),g.destroy(),l.destroy(),a.destroy(),i.destroy());}})}
|
|
2
2
|
export{Ue as DEMO_SIGNALING_ENDPOINTS,xe as createWebrtcCollaboration,be as requireSignaling,he as resolveWebrtcRoomPassword};
|
|
@@ -11,7 +11,8 @@ import { C as CreateDocumentCollaborationOptions } from './document-session-opti
|
|
|
11
11
|
* count that growth, so a long-lived room walks toward a terminal `too-many-nodes` or
|
|
12
12
|
* `blob-store-full` failure. Until compaction exists (the generation reset of issue #554),
|
|
13
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.
|
|
14
|
+
* before the caps end the session for it. This is the probe; the push signal is
|
|
15
|
+
* `subscribeResourcePressure`, in `resource-pressure.ts`.
|
|
15
16
|
*/
|
|
16
17
|
|
|
17
18
|
/**
|
|
@@ -20,7 +21,7 @@ import { C as CreateDocumentCollaborationOptions } from './document-session-opti
|
|
|
20
21
|
* Every `max*` value is the cap whose crossing turns the session status terminal.
|
|
21
22
|
* `tombstonedNodes` is included in `nodes`: a tombstone is never map-deleted, so it keeps
|
|
22
23
|
* counting against `maxNodes` for the life of the room. A reading is a snapshot — take a new
|
|
23
|
-
* one to observe growth
|
|
24
|
+
* one to observe growth, or subscribe with `subscribeResourcePressure`.
|
|
24
25
|
*
|
|
25
26
|
* @public
|
|
26
27
|
*/
|
|
@@ -62,6 +63,59 @@ interface CollaborationResourceUsage {
|
|
|
62
63
|
*/
|
|
63
64
|
declare function readCollaborationResourceUsage(ydoc: Y.Doc): CollaborationResourceUsage;
|
|
64
65
|
|
|
66
|
+
/**
|
|
67
|
+
* How close a room is to the caps that end it, and a push signal when it gets close.
|
|
68
|
+
*
|
|
69
|
+
* A room only grows: deletion is a tombstone, and deleted blob bytes stay in the shared blob
|
|
70
|
+
* map. Every record, tombstones included, counts against `maxNodes`, so a long-lived room walks
|
|
71
|
+
* toward a terminal `too-many-nodes`. Until compaction exists (issue #554), a host that is told
|
|
72
|
+
* before the cap can export the room and seed a new one.
|
|
73
|
+
*
|
|
74
|
+
* The enforcement and the push signal read the same levels, so a notification never claims
|
|
75
|
+
* more headroom than `limitFailure` allows.
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* A cap whose crossing ends a room.
|
|
80
|
+
*
|
|
81
|
+
* - `nodes`: document node records, deleted nodes included.
|
|
82
|
+
* - `parts`: package parts.
|
|
83
|
+
* - `relationships`: relationship records.
|
|
84
|
+
* - `blobBytes`: bytes in the shared blob map, including bytes no part references any more.
|
|
85
|
+
*
|
|
86
|
+
* @public
|
|
87
|
+
*/
|
|
88
|
+
type CollaborationResourceLimit = 'nodes' | 'parts' | 'relationships' | 'blobBytes';
|
|
89
|
+
/**
|
|
90
|
+
* The cap a room is closest to, delivered when the room crosses a threshold.
|
|
91
|
+
*
|
|
92
|
+
* @public
|
|
93
|
+
*/
|
|
94
|
+
interface CollaborationResourcePressure {
|
|
95
|
+
/** The cap with the highest fraction used. */
|
|
96
|
+
readonly limit: CollaborationResourceLimit;
|
|
97
|
+
/** `used / max` for that cap. A value over 1 means the cap is crossed and the room has ended. */
|
|
98
|
+
readonly fraction: number;
|
|
99
|
+
/** The highest threshold `fraction` reaches, or 0 when it is below every threshold. */
|
|
100
|
+
readonly threshold: number;
|
|
101
|
+
/** The replicated count for that cap. */
|
|
102
|
+
readonly used: number;
|
|
103
|
+
/** The cap. */
|
|
104
|
+
readonly max: number;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Options for {@link DocumentCollaborationSession.subscribeResourcePressure}.
|
|
108
|
+
*
|
|
109
|
+
* @public
|
|
110
|
+
*/
|
|
111
|
+
interface CollaborationResourcePressureOptions {
|
|
112
|
+
/**
|
|
113
|
+
* Fractions of a cap that notify, each greater than 0 and at most 1. Order and duplicates do
|
|
114
|
+
* not matter. At most 16 values. Default: `[0.75, 0.9]`.
|
|
115
|
+
*/
|
|
116
|
+
readonly thresholds?: readonly number[];
|
|
117
|
+
}
|
|
118
|
+
|
|
65
119
|
/**
|
|
66
120
|
* Why `beginUndoGroup` refused.
|
|
67
121
|
*
|
|
@@ -136,10 +190,40 @@ interface DocumentCollaborationSession extends EditorCollaborationSession {
|
|
|
136
190
|
*
|
|
137
191
|
* A room only grows — deletion is a tombstone — and the limits that bound hostile
|
|
138
192
|
* amplification turn terminal when crossed. Watch this to archive and re-room before that
|
|
139
|
-
* happens. The tombstone
|
|
140
|
-
* schedule rather than per keystroke.
|
|
193
|
+
* happens. The tombstone and formatting marker counts walk the node map once per call, so
|
|
194
|
+
* read it on your own schedule rather than per keystroke. To be told when growth matters, use
|
|
195
|
+
* {@link DocumentCollaborationSession.subscribeResourcePressure}.
|
|
141
196
|
*/
|
|
142
197
|
resourceUsage(): CollaborationResourceUsage;
|
|
198
|
+
/**
|
|
199
|
+
* Call `listener` when the room crosses a fraction of any cap that would end it.
|
|
200
|
+
*
|
|
201
|
+
* The session checks the caps after every local or remote transaction. The node count is
|
|
202
|
+
* maintained, and the part, relationship and media totals are measured again only after
|
|
203
|
+
* they change, so typing costs no walk of the document. `listener` runs when the highest
|
|
204
|
+
* threshold the room reaches changes, in either direction: a lower `threshold` (0 below
|
|
205
|
+
* every threshold) tells the host to clear its warning. It also runs once, synchronously, at subscription when the room
|
|
206
|
+
* already reaches a threshold, so a participant joining a large room learns of it at once.
|
|
207
|
+
*
|
|
208
|
+
* The reading names the cap closest to its limit. Call
|
|
209
|
+
* {@link DocumentCollaborationSession.resourceUsage} for every count. Destroying the session
|
|
210
|
+
* ends every subscription. A listener that throws is reported with `console.error` and does
|
|
211
|
+
* not stop the edit or other listeners.
|
|
212
|
+
*
|
|
213
|
+
* @param options - `thresholds` sets the fractions that notify. Default: `[0.75, 0.9]`.
|
|
214
|
+
* @returns A function that ends the subscription.
|
|
215
|
+
* @throws RangeError when `thresholds` is empty, holds more than 16 values, or holds a value
|
|
216
|
+
* that is not greater than 0 and at most 1.
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```ts
|
|
220
|
+
* const stop = session.subscribeResourcePressure(({ limit, fraction, threshold }) => {
|
|
221
|
+
* if (threshold === 0) hideRoomSizeWarning();
|
|
222
|
+
* else showRoomSizeWarning(limit, fraction); // Export the room and create a new one.
|
|
223
|
+
* });
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
226
|
+
subscribeResourcePressure(listener: (pressure: CollaborationResourcePressure) => void, options?: CollaborationResourcePressureOptions): () => void;
|
|
143
227
|
/**
|
|
144
228
|
* Open an explicit undo group: every local write this session publishes until `end()` is
|
|
145
229
|
* one undo step. For a server or headless replica, such as an agent's.
|
|
@@ -159,9 +243,10 @@ interface DocumentCollaborationSession extends EditorCollaborationSession {
|
|
|
159
243
|
* - A refused write does not end the group. Later writes join the same step as the
|
|
160
244
|
* earlier ones. To revert the whole operation, end the group and call `undo()` once.
|
|
161
245
|
* - Only local writes join the group. Other participants' edits stay out of it, and an
|
|
162
|
-
* undo of the group keeps them.
|
|
163
|
-
*
|
|
164
|
-
* its undo changes nothing and
|
|
246
|
+
* undo of the group keeps them. Text that others typed in a paragraph the group
|
|
247
|
+
* inserted joins the paragraph before it, or the paragraph after it when none comes
|
|
248
|
+
* before. When they removed everything the group wrote, its undo changes nothing and
|
|
249
|
+
* never reverts an older step.
|
|
165
250
|
* - An undo of an ungrouped step never reverts a group's step below it. Ungrouped history
|
|
166
251
|
* otherwise undoes as it does without groups. If a peer removed everything that the top
|
|
167
252
|
* ungrouped step wrote, that `undo()` changes nothing and returns true. Call `undo()`
|
|
@@ -238,5 +323,5 @@ type DocumentCollaborationHandle = CollaborationHandle<DocumentCollaborationSess
|
|
|
238
323
|
*/
|
|
239
324
|
declare function createDocumentCollaboration(options: CreateDocumentCollaborationOptions): Promise<DocumentCollaborationHandle>;
|
|
240
325
|
|
|
241
|
-
export { CollaborationUndoGroupError as
|
|
242
|
-
export type {
|
|
326
|
+
export { CollaborationUndoGroupError as e, createDocumentCollaboration as h, readCollaborationResourceUsage as r };
|
|
327
|
+
export type { CollaborationResourceLimit as C, DocumentCollaborationHandle as D, CollaborationResourcePressure as a, CollaborationResourcePressureOptions as b, CollaborationResourceUsage as c, CollaborationUndoGroup as d, CollaborationUndoGroupErrorCode as f, DocumentCollaborationSession as g };
|
|
@@ -11,7 +11,8 @@ import { C as CreateDocumentCollaborationOptions } from './document-session-opti
|
|
|
11
11
|
* count that growth, so a long-lived room walks toward a terminal `too-many-nodes` or
|
|
12
12
|
* `blob-store-full` failure. Until compaction exists (the generation reset of issue #554),
|
|
13
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.
|
|
14
|
+
* before the caps end the session for it. This is the probe; the push signal is
|
|
15
|
+
* `subscribeResourcePressure`, in `resource-pressure.ts`.
|
|
15
16
|
*/
|
|
16
17
|
|
|
17
18
|
/**
|
|
@@ -20,7 +21,7 @@ import { C as CreateDocumentCollaborationOptions } from './document-session-opti
|
|
|
20
21
|
* Every `max*` value is the cap whose crossing turns the session status terminal.
|
|
21
22
|
* `tombstonedNodes` is included in `nodes`: a tombstone is never map-deleted, so it keeps
|
|
22
23
|
* counting against `maxNodes` for the life of the room. A reading is a snapshot — take a new
|
|
23
|
-
* one to observe growth
|
|
24
|
+
* one to observe growth, or subscribe with `subscribeResourcePressure`.
|
|
24
25
|
*
|
|
25
26
|
* @public
|
|
26
27
|
*/
|
|
@@ -62,6 +63,59 @@ interface CollaborationResourceUsage {
|
|
|
62
63
|
*/
|
|
63
64
|
declare function readCollaborationResourceUsage(ydoc: Y.Doc): CollaborationResourceUsage;
|
|
64
65
|
|
|
66
|
+
/**
|
|
67
|
+
* How close a room is to the caps that end it, and a push signal when it gets close.
|
|
68
|
+
*
|
|
69
|
+
* A room only grows: deletion is a tombstone, and deleted blob bytes stay in the shared blob
|
|
70
|
+
* map. Every record, tombstones included, counts against `maxNodes`, so a long-lived room walks
|
|
71
|
+
* toward a terminal `too-many-nodes`. Until compaction exists (issue #554), a host that is told
|
|
72
|
+
* before the cap can export the room and seed a new one.
|
|
73
|
+
*
|
|
74
|
+
* The enforcement and the push signal read the same levels, so a notification never claims
|
|
75
|
+
* more headroom than `limitFailure` allows.
|
|
76
|
+
*/
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* A cap whose crossing ends a room.
|
|
80
|
+
*
|
|
81
|
+
* - `nodes`: document node records, deleted nodes included.
|
|
82
|
+
* - `parts`: package parts.
|
|
83
|
+
* - `relationships`: relationship records.
|
|
84
|
+
* - `blobBytes`: bytes in the shared blob map, including bytes no part references any more.
|
|
85
|
+
*
|
|
86
|
+
* @public
|
|
87
|
+
*/
|
|
88
|
+
type CollaborationResourceLimit = 'nodes' | 'parts' | 'relationships' | 'blobBytes';
|
|
89
|
+
/**
|
|
90
|
+
* The cap a room is closest to, delivered when the room crosses a threshold.
|
|
91
|
+
*
|
|
92
|
+
* @public
|
|
93
|
+
*/
|
|
94
|
+
interface CollaborationResourcePressure {
|
|
95
|
+
/** The cap with the highest fraction used. */
|
|
96
|
+
readonly limit: CollaborationResourceLimit;
|
|
97
|
+
/** `used / max` for that cap. A value over 1 means the cap is crossed and the room has ended. */
|
|
98
|
+
readonly fraction: number;
|
|
99
|
+
/** The highest threshold `fraction` reaches, or 0 when it is below every threshold. */
|
|
100
|
+
readonly threshold: number;
|
|
101
|
+
/** The replicated count for that cap. */
|
|
102
|
+
readonly used: number;
|
|
103
|
+
/** The cap. */
|
|
104
|
+
readonly max: number;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Options for {@link DocumentCollaborationSession.subscribeResourcePressure}.
|
|
108
|
+
*
|
|
109
|
+
* @public
|
|
110
|
+
*/
|
|
111
|
+
interface CollaborationResourcePressureOptions {
|
|
112
|
+
/**
|
|
113
|
+
* Fractions of a cap that notify, each greater than 0 and at most 1. Order and duplicates do
|
|
114
|
+
* not matter. At most 16 values. Default: `[0.75, 0.9]`.
|
|
115
|
+
*/
|
|
116
|
+
readonly thresholds?: readonly number[];
|
|
117
|
+
}
|
|
118
|
+
|
|
65
119
|
/**
|
|
66
120
|
* Why `beginUndoGroup` refused.
|
|
67
121
|
*
|
|
@@ -136,10 +190,40 @@ interface DocumentCollaborationSession extends EditorCollaborationSession {
|
|
|
136
190
|
*
|
|
137
191
|
* A room only grows — deletion is a tombstone — and the limits that bound hostile
|
|
138
192
|
* amplification turn terminal when crossed. Watch this to archive and re-room before that
|
|
139
|
-
* happens. The tombstone
|
|
140
|
-
* schedule rather than per keystroke.
|
|
193
|
+
* happens. The tombstone and formatting marker counts walk the node map once per call, so
|
|
194
|
+
* read it on your own schedule rather than per keystroke. To be told when growth matters, use
|
|
195
|
+
* {@link DocumentCollaborationSession.subscribeResourcePressure}.
|
|
141
196
|
*/
|
|
142
197
|
resourceUsage(): CollaborationResourceUsage;
|
|
198
|
+
/**
|
|
199
|
+
* Call `listener` when the room crosses a fraction of any cap that would end it.
|
|
200
|
+
*
|
|
201
|
+
* The session checks the caps after every local or remote transaction. The node count is
|
|
202
|
+
* maintained, and the part, relationship and media totals are measured again only after
|
|
203
|
+
* they change, so typing costs no walk of the document. `listener` runs when the highest
|
|
204
|
+
* threshold the room reaches changes, in either direction: a lower `threshold` (0 below
|
|
205
|
+
* every threshold) tells the host to clear its warning. It also runs once, synchronously, at subscription when the room
|
|
206
|
+
* already reaches a threshold, so a participant joining a large room learns of it at once.
|
|
207
|
+
*
|
|
208
|
+
* The reading names the cap closest to its limit. Call
|
|
209
|
+
* {@link DocumentCollaborationSession.resourceUsage} for every count. Destroying the session
|
|
210
|
+
* ends every subscription. A listener that throws is reported with `console.error` and does
|
|
211
|
+
* not stop the edit or other listeners.
|
|
212
|
+
*
|
|
213
|
+
* @param options - `thresholds` sets the fractions that notify. Default: `[0.75, 0.9]`.
|
|
214
|
+
* @returns A function that ends the subscription.
|
|
215
|
+
* @throws RangeError when `thresholds` is empty, holds more than 16 values, or holds a value
|
|
216
|
+
* that is not greater than 0 and at most 1.
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```ts
|
|
220
|
+
* const stop = session.subscribeResourcePressure(({ limit, fraction, threshold }) => {
|
|
221
|
+
* if (threshold === 0) hideRoomSizeWarning();
|
|
222
|
+
* else showRoomSizeWarning(limit, fraction); // Export the room and create a new one.
|
|
223
|
+
* });
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
226
|
+
subscribeResourcePressure(listener: (pressure: CollaborationResourcePressure) => void, options?: CollaborationResourcePressureOptions): () => void;
|
|
143
227
|
/**
|
|
144
228
|
* Open an explicit undo group: every local write this session publishes until `end()` is
|
|
145
229
|
* one undo step. For a server or headless replica, such as an agent's.
|
|
@@ -159,9 +243,10 @@ interface DocumentCollaborationSession extends EditorCollaborationSession {
|
|
|
159
243
|
* - A refused write does not end the group. Later writes join the same step as the
|
|
160
244
|
* earlier ones. To revert the whole operation, end the group and call `undo()` once.
|
|
161
245
|
* - Only local writes join the group. Other participants' edits stay out of it, and an
|
|
162
|
-
* undo of the group keeps them.
|
|
163
|
-
*
|
|
164
|
-
* its undo changes nothing and
|
|
246
|
+
* undo of the group keeps them. Text that others typed in a paragraph the group
|
|
247
|
+
* inserted joins the paragraph before it, or the paragraph after it when none comes
|
|
248
|
+
* before. When they removed everything the group wrote, its undo changes nothing and
|
|
249
|
+
* never reverts an older step.
|
|
165
250
|
* - An undo of an ungrouped step never reverts a group's step below it. Ungrouped history
|
|
166
251
|
* otherwise undoes as it does without groups. If a peer removed everything that the top
|
|
167
252
|
* ungrouped step wrote, that `undo()` changes nothing and returns true. Call `undo()`
|
|
@@ -238,5 +323,5 @@ type DocumentCollaborationHandle = CollaborationHandle<DocumentCollaborationSess
|
|
|
238
323
|
*/
|
|
239
324
|
declare function createDocumentCollaboration(options: CreateDocumentCollaborationOptions): Promise<DocumentCollaborationHandle>;
|
|
240
325
|
|
|
241
|
-
export { CollaborationUndoGroupError as
|
|
242
|
-
export type {
|
|
326
|
+
export { CollaborationUndoGroupError as e, createDocumentCollaboration as h, readCollaborationResourceUsage as r };
|
|
327
|
+
export type { CollaborationResourceLimit as C, DocumentCollaborationHandle as D, CollaborationResourcePressure as a, CollaborationResourcePressureOptions as b, CollaborationResourceUsage as c, CollaborationUndoGroup as d, CollaborationUndoGroupErrorCode as f, DocumentCollaborationSession as g };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';var chunk5HK5RAD7_cjs=require('./chunk-5HK5RAD7.cjs');Object.defineProperty(exports,"ATTACH_WATCHDOG_MS_FOR_TESTS",{enumerable:true,get:function(){return chunk5HK5RAD7_cjs.h}});Object.defineProperty(exports,"createDocumentCollaboration",{enumerable:true,get:function(){return chunk5HK5RAD7_cjs.r}});Object.defineProperty(exports,"readCollaborationDocument",{enumerable:true,get:function(){return chunk5HK5RAD7_cjs.q}});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{h as ATTACH_WATCHDOG_MS_FOR_TESTS,r as createDocumentCollaboration,q as readCollaborationDocument}from'./chunk-4TS2D6OV.js';
|
package/dist/drawing/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkZZ33FL6V_cjs=require('../chunk-ZZ33FL6V.cjs');require('../chunk-IULA3QRZ.cjs');Object.defineProperty(exports,"drawingModule",{enumerable:true,get:function(){return chunkZZ33FL6V_cjs.b}});Object.defineProperty(exports,"installDrawing",{enumerable:true,get:function(){return chunkZZ33FL6V_cjs.a}});
|