@docx-editor.dev/pro 2.38.0 → 2.39.0-canary.20261118032846.sha-764bd09
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-4UYICEW4.cjs +11 -0
- package/dist/{chunk-CNQG7JPW.js → chunk-5OK2UOME.js} +1 -1
- package/dist/chunk-6WITPFTY.js +11 -0
- package/dist/{chunk-664SJBNS.js → chunk-KQ4A2C2I.js} +10 -10
- package/dist/{chunk-HMIXD27V.js → chunk-QVYUMMPG.js} +1 -1
- package/dist/{chunk-VW2UA4EW.cjs → chunk-UEIXRTAG.cjs} +1 -1
- package/dist/{chunk-KPF2TI6O.cjs → chunk-UZT77RTY.cjs} +1 -1
- package/dist/{chunk-35PECGD2.cjs → chunk-XLGO5HZY.cjs} +10 -10
- package/dist/collaboration/hocuspocus.cjs +1 -1
- package/dist/collaboration/hocuspocus.js +1 -1
- package/dist/collaboration/index.cjs +2 -2
- package/dist/collaboration/index.js +1 -1
- package/dist/collaboration/webrtc.cjs +1 -1
- package/dist/collaboration/webrtc.js +1 -1
- package/dist/{document-session-UQQ5J2K4.js → document-session-34MWMPX2.js} +1 -1
- package/dist/{document-session-O4SGT36R.cjs → document-session-V36OWTGE.cjs} +1 -1
- 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/react/index.cjs +2 -2
- package/dist/react/index.js +2 -2
- package/dist/vue/index.cjs +2 -2
- package/dist/vue/index.js +1 -1
- package/package.json +4 -4
- package/dist/chunk-A4FYA5OD.cjs +0 -11
- package/dist/chunk-EPSDX3UA.js +0 -11
|
@@ -3,4 +3,4 @@ Copyright (c) 2026 Eigenpal, Inc. All rights reserved.
|
|
|
3
3
|
Licensed under the EigenPal Pro Evaluation License 1.0. See LICENSE.md in this package.
|
|
4
4
|
Production use requires a commercial agreement: licensing@eigenpal.com
|
|
5
5
|
*/
|
|
6
|
-
'use strict';var
|
|
6
|
+
'use strict';var chunkUZT77RTY_cjs=require('../chunk-UZT77RTY.cjs'),chunkLUUFBXJ5_cjs=require('../chunk-LUUFBXJ5.cjs'),chunkXLGO5HZY_cjs=require('../chunk-XLGO5HZY.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 chunkXLGO5HZY_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 chunkXLGO5HZY_cjs.b("initialization-aborted"));},d=()=>{i(),n();},t=a=>{i(),r(new chunkXLGO5HZY_cjs.b(collaboration.isCollaborationFailureCode(a.reason)?a.reason:"initialization-aborted",`authentication failed: ${a.reason}`));},u=setTimeout(()=>{i(),r(new chunkXLGO5HZY_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?.(chunkUZT77RTY_cjs.d(n))),e},s=null,d=null;try{if(o.bootstrap.kind!=="create"&&o.bootstrap.signal?.aborted)throw new chunkXLGO5HZY_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 chunkXLGO5HZY_cjs.s({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||!chunkUZT77RTY_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;
|
|
@@ -3,4 +3,4 @@ Copyright (c) 2026 Eigenpal, Inc. All rights reserved.
|
|
|
3
3
|
Licensed under the EigenPal Pro Evaluation License 1.0. See LICENSE.md in this package.
|
|
4
4
|
Production use requires a commercial agreement: licensing@eigenpal.com
|
|
5
5
|
*/
|
|
6
|
-
import {d,e}from'../chunk-
|
|
6
|
+
import {d,e}from'../chunk-5OK2UOME.js';import {b}from'../chunk-6DEUT2RQ.js';export{a as createCollaborationRoomId,b as validateRoomId}from'../chunk-6DEUT2RQ.js';import {b as b$1,s}from'../chunk-KQ4A2C2I.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=new 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?.(d(n))),e},s$1=null,d$1=null;try{if(o.bootstrap.kind!=="create"&&o.bootstrap.signal?.aborted)throw new b$1("initialization-aborted");s$1=i(),await R(s$1,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 s({ydoc:n,awareness:r,documentId:m,identity:o.identity,bootstrap:e,offlineEditing:o.offlineEditing});}catch(e){throw d$1?.destroy(),s$1?.destroy(),r.destroy(),n.destroy(),e}let t=s$1,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.destroy(),n.destroy());}})}export{L as createHocuspocusCollaboration};
|
|
@@ -3,5 +3,5 @@ Copyright (c) 2026 Eigenpal, Inc. All rights reserved.
|
|
|
3
3
|
Licensed under the EigenPal Pro Evaluation License 1.0. See LICENSE.md in this package.
|
|
4
4
|
Production use requires a commercial agreement: licensing@eigenpal.com
|
|
5
5
|
*/
|
|
6
|
-
'use strict';var chunkQEULTKCT_cjs=require('../chunk-QEULTKCT.cjs'),
|
|
7
|
-
Object.defineProperty(exports,"collaborationModule",{enumerable:true,get:function(){return chunkQEULTKCT_cjs.a}});Object.defineProperty(exports,"checkCollaborationRoomGeneration",{enumerable:true,get:function(){return
|
|
6
|
+
'use strict';var chunkQEULTKCT_cjs=require('../chunk-QEULTKCT.cjs'),chunkUZT77RTY_cjs=require('../chunk-UZT77RTY.cjs'),chunkXLGO5HZY_cjs=require('../chunk-XLGO5HZY.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 K=1,J=1,M=20971520;function W(o){return chunkXLGO5HZY_cjs.a(o)}async function q(o,t){let n=chunkXLGO5HZY_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 chunkUZT77RTY_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=>chunkXLGO5HZY_cjs.c[o]));function Q(o){if(o!==b)throw new chunkXLGO5HZY_cjs.b("collaboration-format-mismatch","The collaboration format version is missing or incompatible with this deployment.")}function R(o){if(!o.share.has(chunkXLGO5HZY_cjs.e))throw new chunkXLGO5HZY_cjs.b("not-initialized");let t;try{t=o.getMap(chunkXLGO5HZY_cjs.e);}catch{throw new chunkXLGO5HZY_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 chunkXLGO5HZY_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 chunkXLGO5HZY_cjs.b("collaboration-format-mismatch","The saved room has missing or invalid collaboration version information.");return r});return T(n)}function oo(o){return N(o,t=>L(F(t)))}async function to(o){let t=N(o.state,l=>({format:F(l),documentId:ro(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 chunkXLGO5HZY_cjs.b("invalid-document-id","The earlier room holds no document ID. Pass the ID its clients use as documentId.");let r=chunkXLGO5HZY_cjs.i(a),i=await chunkUZT77RTY_cjs.c(o.exported,r,{keepBound:true}),p=N(i,l=>chunkXLGO5HZY_cjs.r(l)),m=await P(o.exported),e=eo(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 N(o,t){let n=new O__namespace.Doc;try{try{O__namespace.applyUpdate(n,o);}catch{throw new chunkXLGO5HZY_cjs.b("invalid-baseline","The bytes are not room state.")}return t(n)}finally{n.destroy();}}function ro(o){try{return o.getMap(chunkXLGO5HZY_cjs.e).get("documentId")}catch{return}}function F(o){try{return R(o)}catch(t){if(t instanceof chunkXLGO5HZY_cjs.b&&t.code==="collaboration-format-mismatch")return null;throw t}}function L(o){if(o===null)return "earlier-format";let t=mo(o,b);return t===0?"current":t<0?"earlier-format":"later-format"}var D=20;function eo(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=no(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 no(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 ao(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 chunkXLGO5HZY_cjs.b("invalid-baseline",t.reason);let n=lo(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:ao(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 so(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 io="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 lo(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===io?{...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 so(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 mo(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}
|
|
7
|
+
Object.defineProperty(exports,"collaborationModule",{enumerable:true,get:function(){return chunkQEULTKCT_cjs.a}});Object.defineProperty(exports,"checkCollaborationRoomGeneration",{enumerable:true,get:function(){return chunkUZT77RTY_cjs.f}});Object.defineProperty(exports,"compactCollaborationState",{enumerable:true,get:function(){return chunkUZT77RTY_cjs.b}});Object.defineProperty(exports,"readCollaborationRoomGeneration",{enumerable:true,get:function(){return chunkUZT77RTY_cjs.a}});Object.defineProperty(exports,"CollaborationSchemaError",{enumerable:true,get:function(){return chunkXLGO5HZY_cjs.b}});Object.defineProperty(exports,"CollaborationUndoGroupError",{enumerable:true,get:function(){return chunkXLGO5HZY_cjs.p}});Object.defineProperty(exports,"DOCUMENT_COLLABORATION_VERSIONS",{enumerable:true,get:function(){return chunkXLGO5HZY_cjs.c}});Object.defineProperty(exports,"assertDocumentCollaborationCompatibility",{enumerable:true,get:function(){return chunkXLGO5HZY_cjs.d}});Object.defineProperty(exports,"createDocumentCollaboration",{enumerable:true,get:function(){return chunkXLGO5HZY_cjs.s}});Object.defineProperty(exports,"readCollaborationDocument",{enumerable:true,get:function(){return chunkXLGO5HZY_cjs.q}});Object.defineProperty(exports,"readCollaborationResourceUsage",{enumerable:true,get:function(){return chunkXLGO5HZY_cjs.o}});exports.COLLABORATION_FORMAT_VERSION=b;exports.MAX_BASELINE_BYTES=M;exports.PROTOCOL_VERSION=K;exports.SCHEMA_VERSION=J;exports.assertCollaborationFormatCompatibility=Q;exports.collaborationMigrationNeed=oo;exports.createCollaborationState=q;exports.migrateCollaborationRoom=to;exports.prepareCollaborationServerDocument=W;exports.readCollaborationFormatVersion=R;
|
|
@@ -3,5 +3,5 @@ Copyright (c) 2026 Eigenpal, Inc. All rights reserved.
|
|
|
3
3
|
Licensed under the EigenPal Pro Evaluation License 1.0. See LICENSE.md in this package.
|
|
4
4
|
Production use requires a commercial agreement: licensing@eigenpal.com
|
|
5
5
|
*/
|
|
6
|
-
export{a as collaborationModule}from'../chunk-EOZ44UA7.js';import {c as c$1}from'../chunk-
|
|
6
|
+
export{a as collaborationModule}from'../chunk-EOZ44UA7.js';import {c as c$1}from'../chunk-5OK2UOME.js';export{f as checkCollaborationRoomGeneration,b as compactCollaborationState,a as readCollaborationRoomGeneration}from'../chunk-5OK2UOME.js';import {c,a,i,b as b$1,e,r}from'../chunk-KQ4A2C2I.js';export{b as CollaborationSchemaError,p as CollaborationUndoGroupError,c as DOCUMENT_COLLABORATION_VERSIONS,d as assertDocumentCollaborationCompatibility,s as createDocumentCollaboration,q as readCollaborationDocument,o as readCollaborationResourceUsage}from'../chunk-KQ4A2C2I.js';import'../chunk-HMU7J34H.js';import*as O from'yjs';import {readOoxmlPackage,canonicalOoxmlFingerprint}from'@docx-editor.dev/core/store';var K=1,J=1,M=20971520;function W(o){return a(o)}async function q(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 R(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 oo(o){return N(o,t=>L(F(t)))}async function to(o){let t=N(o.state,l=>({format:F(l),documentId:ro(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$1=i(a),i$1=await c$1(o.exported,r$1,{keepBound:true}),p=N(i$1,l=>r(l)),m=await P(o.exported),e=eo(m,await P(p),{from:t.format??"unversioned",to:b,documentId:r$1});return e.ok?{ok:true,state:i$1,report:e}:{ok:false,reason:"check-failed",report:e}}function N(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 ro(o){try{return o.getMap(e).get("documentId")}catch{return}}function F(o){try{return R(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=mo(o,b);return t===0?"current":t<0?"earlier-format":"later-format"}var D=20;function eo(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=no(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 no(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 ao(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=lo(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:ao(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 so(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 io="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 lo(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===io?{...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 so(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 mo(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}
|
|
7
7
|
export{b as COLLABORATION_FORMAT_VERSION,M as MAX_BASELINE_BYTES,K as PROTOCOL_VERSION,J as SCHEMA_VERSION,Q as assertCollaborationFormatCompatibility,oo as collaborationMigrationNeed,q as createCollaborationState,to as migrateCollaborationRoom,W as prepareCollaborationServerDocument,R as readCollaborationFormatVersion};
|
|
@@ -3,5 +3,5 @@ Copyright (c) 2026 Eigenpal, Inc. All rights reserved.
|
|
|
3
3
|
Licensed under the EigenPal Pro Evaluation License 1.0. See LICENSE.md in this package.
|
|
4
4
|
Production use requires a commercial agreement: licensing@eigenpal.com
|
|
5
5
|
*/
|
|
6
|
-
'use strict';var chunkLUUFBXJ5_cjs=require('../chunk-LUUFBXJ5.cjs'),
|
|
6
|
+
'use strict';var chunkLUUFBXJ5_cjs=require('../chunk-LUUFBXJ5.cjs'),chunkXLGO5HZY_cjs=require('../chunk-XLGO5HZY.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 chunkXLGO5HZY_cjs.s({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());}})}
|
|
7
7
|
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;
|
|
@@ -3,5 +3,5 @@ Copyright (c) 2026 Eigenpal, Inc. All rights reserved.
|
|
|
3
3
|
Licensed under the EigenPal Pro Evaluation License 1.0. See LICENSE.md in this package.
|
|
4
4
|
Production use requires a commercial agreement: licensing@eigenpal.com
|
|
5
5
|
*/
|
|
6
|
-
import {b}from'../chunk-6DEUT2RQ.js';export{a as createCollaborationRoomId,b as validateRoomId}from'../chunk-6DEUT2RQ.js';import {s}from'../chunk-
|
|
6
|
+
import {b}from'../chunk-6DEUT2RQ.js';export{a as createCollaborationRoomId,b as validateRoomId}from'../chunk-6DEUT2RQ.js';import {s}from'../chunk-KQ4A2C2I.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=null,s$1={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$1.abandoned(v),delivered:v=>s$1.delivered(v)}),y},g;try{e.bootstrap.kind!=="create"&&(r=b$1()),g=await s({ydoc:i,awareness:a,documentId:n,identity:e.identity,bootstrap:e.bootstrap,offlineEditing:e.offlineEditing}),r||(r=b$1());}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$1=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());}})}
|
|
7
7
|
export{Ue as DEMO_SIGNALING_ENDPOINTS,xe as createWebrtcCollaboration,be as requireSignaling,he as resolveWebrtcRoomPassword};
|
|
@@ -3,4 +3,4 @@ Copyright (c) 2026 Eigenpal, Inc. All rights reserved.
|
|
|
3
3
|
Licensed under the EigenPal Pro Evaluation License 1.0. See LICENSE.md in this package.
|
|
4
4
|
Production use requires a commercial agreement: licensing@eigenpal.com
|
|
5
5
|
*/
|
|
6
|
-
export{h as ATTACH_WATCHDOG_MS_FOR_TESTS,s as createDocumentCollaboration,q as readCollaborationDocument}from'./chunk-
|
|
6
|
+
export{h as ATTACH_WATCHDOG_MS_FOR_TESTS,s as createDocumentCollaboration,q as readCollaborationDocument}from'./chunk-KQ4A2C2I.js';
|
|
@@ -3,4 +3,4 @@ Copyright (c) 2026 Eigenpal, Inc. All rights reserved.
|
|
|
3
3
|
Licensed under the EigenPal Pro Evaluation License 1.0. See LICENSE.md in this package.
|
|
4
4
|
Production use requires a commercial agreement: licensing@eigenpal.com
|
|
5
5
|
*/
|
|
6
|
-
'use strict';var
|
|
6
|
+
'use strict';var chunkXLGO5HZY_cjs=require('./chunk-XLGO5HZY.cjs');Object.defineProperty(exports,"ATTACH_WATCHDOG_MS_FOR_TESTS",{enumerable:true,get:function(){return chunkXLGO5HZY_cjs.h}});Object.defineProperty(exports,"createDocumentCollaboration",{enumerable:true,get:function(){return chunkXLGO5HZY_cjs.s}});Object.defineProperty(exports,"readCollaborationDocument",{enumerable:true,get:function(){return chunkXLGO5HZY_cjs.q}});
|
package/dist/drawing/index.cjs
CHANGED
|
@@ -3,4 +3,4 @@ Copyright (c) 2026 Eigenpal, Inc. All rights reserved.
|
|
|
3
3
|
Licensed under the EigenPal Pro Evaluation License 1.0. See LICENSE.md in this package.
|
|
4
4
|
Production use requires a commercial agreement: licensing@eigenpal.com
|
|
5
5
|
*/
|
|
6
|
-
'use strict';var
|
|
6
|
+
'use strict';var chunk4UYICEW4_cjs=require('../chunk-4UYICEW4.cjs');require('../chunk-IULA3QRZ.cjs');Object.defineProperty(exports,"drawingModule",{enumerable:true,get:function(){return chunk4UYICEW4_cjs.b}});Object.defineProperty(exports,"installDrawing",{enumerable:true,get:function(){return chunk4UYICEW4_cjs.a}});
|
package/dist/drawing/index.js
CHANGED
|
@@ -3,4 +3,4 @@ Copyright (c) 2026 Eigenpal, Inc. All rights reserved.
|
|
|
3
3
|
Licensed under the EigenPal Pro Evaluation License 1.0. See LICENSE.md in this package.
|
|
4
4
|
Production use requires a commercial agreement: licensing@eigenpal.com
|
|
5
5
|
*/
|
|
6
|
-
export{b as drawingModule,a as installDrawing}from'../chunk-
|
|
6
|
+
export{b as drawingModule,a as installDrawing}from'../chunk-6WITPFTY.js';import'../chunk-HMU7J34H.js';
|
package/dist/index.cjs
CHANGED
|
@@ -3,4 +3,4 @@ Copyright (c) 2026 Eigenpal, Inc. All rights reserved.
|
|
|
3
3
|
Licensed under the EigenPal Pro Evaluation License 1.0. See LICENSE.md in this package.
|
|
4
4
|
Production use requires a commercial agreement: licensing@eigenpal.com
|
|
5
5
|
*/
|
|
6
|
-
'use strict';var
|
|
6
|
+
'use strict';var chunkUEIXRTAG_cjs=require('./chunk-UEIXRTAG.cjs'),chunkVJOGWUUQ_cjs=require('./chunk-VJOGWUUQ.cjs'),chunkQEULTKCT_cjs=require('./chunk-QEULTKCT.cjs');require('./chunk-4UYICEW4.cjs'),require('./chunk-IULA3QRZ.cjs');var store=require('@docx-editor.dev/core/store');function L(t,n={}){let r=F(t);if(!r)return [];let o=n.nodes??t.getCustomNodeDefinitions().filter(chunkUEIXRTAG_cjs.j);if(o.length===0)return [];let s=r.session.currentPackage(),d=r.session.part().name,m=n.onDiagnostic??(e=>{t.reportCustomNodeDiagnostic(e);});return r.session.storyParts().flatMap(e=>chunkUEIXRTAG_cjs.n(e,o,{payloads:store.customNodePayloadsByControl(s,e.name,d),onDiagnostic:m}))}function F(t){return t.surface??null}function E(t,n,r={}){if(r.destination==="internal")return {ok:true,bytes:t,unwrapped:0,removed:0};let o=store.readOoxmlPackage(t);if(!o.ok)return {ok:false,reason:`the document could not be read: ${o.reason}`};let s=new Map;for(let i of n)s.set(`${i.tagPrefix}:${i.name}`,i);let d=i=>{let p=chunkUEIXRTAG_cjs.c(i);if(!p)return "keep";let x=s.get(`${p.prefix}:${p.name}`);return x?x.preserveOnExport==="text"?"text":x.preserveOnExport===false?"remove":"keep":"keep"},m=[...new Set(n.filter(i=>i.preserveOnExport!==void 0).filter(i=>i.preserveOnExport!==true).map(chunkUEIXRTAG_cjs.h))],e=o.package,u=0,c=0,N=G(e);for(let i of N){let p=store.withExportedCustomNodes(e,{storyPartName:i,namespaces:[],decide:d});if(!p.ok)return {ok:false,reason:p.reason};e=p.pkg,u+=p.unwrapped,c+=p.removed;}let l=store.withExportedCustomNodes(e,{storyPartName:e.mainDocumentPart,namespaces:m,decide:()=>"keep"});return l.ok?(e=l.pkg,{ok:true,bytes:store.writeOoxmlPackage(e),unwrapped:u,removed:c}):{ok:false,reason:l.reason}}function G(t){let n=[];for(let[r,o]of t.parts)r!==t.mainDocumentPart&&store.isStoryPart(o)&&n.push(r);return [t.mainDocumentPart,...n]}async function H(t,n={}){let r=n.nodes??t.getCustomNodeDefinitions().filter(chunkUEIXRTAG_cjs.j),o=await t.save();return E(new Uint8Array(o),r,{...n.destination===void 0?{}:{destination:n.destination}})}function a(t){return t.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Q(t,n,r,o={}){if(!chunkUEIXRTAG_cjs.k.test(t.tagPrefix)||!chunkUEIXRTAG_cjs.k.test(t.name))return {ok:false,code:"invalidArgs",reason:"the definition identity must match defineCustomNode\u2019s charset ([A-Za-z0-9_.-])"};let s=chunkUEIXRTAG_cjs.b(t.tagPrefix,t.name,n);if(!s.ok)return {ok:false,code:"invalidArgs",reason:`the encoded tag is ${s.length} characters; Word caps w:tag at 64 \u2014 shorten the attrs`};let d=o.lock===void 0?"contentLocked":o.lock,m=o.id!==void 0&&Number.isInteger(o.id)&&o.id>0?o.id:store.fnv1a32(`${s.tag}\0${r}`)&2147483647||1,e=o.data===void 0?null:ee(t,o,r);if(e&&"reason"in e)return {ok:false,code:"invalidArgs",reason:e.reason};let u=(o.alias!==void 0?`<w:alias w:val="${a(o.alias)}"/>`:"")+`<w:tag w:val="${a(s.tag)}"/><w:id w:val="${m}"/>`+(d===false?"":`<w:lock w:val="${d}"/>`)+(e?`<w:dataBinding w:prefixMappings="${a(e.binding.prefixMappings)}" w:xpath="${a(e.binding.xpath)}" w:storeItemID="${a(e.binding.storeItemId)}"/>`:""),c=`<w:r><w:t xml:space="preserve">${a(r)}</w:t></w:r>`;return {ok:true,xml:`<w:sdt><w:sdtPr>${u}</w:sdtPr><w:sdtContent>${c}</w:sdtContent></w:sdt>`,...e?{store:e.store}:{}}}function ee(t,n,r){let o=chunkUEIXRTAG_cjs.i(t,n.data);if(!o.ok)return {reason:o.reason};let s=chunkUEIXRTAG_cjs.h(t),d=n.storeIndex!==void 0&&Number.isInteger(n.storeIndex)&&n.storeIndex>0?n.storeIndex:1,m=n.nodeId??"cx1",e=`/customXml/item${String(d)}.xml`,u=`/customXml/itemProps${String(d)}.xml`,c=store.datastoreItemIdFor(`${s} ${e} ${m}`),N=store.customNodeBinding({partName:e,propsPartName:u,itemId:c,namespaceUri:s},chunkUEIXRTAG_cjs.g,m);if(!N)return {reason:`the payload cannot be addressed by an XPath: check nodeId (${m}) and payloadNamespace`};let l=r===r.trim()?`<label>${a(r)}</label>`:`<label xml:space="preserve">${a(r)}</label>`;return {binding:N,store:{itemPartName:e,itemXml:`<${chunkUEIXRTAG_cjs.g} xmlns="${a(s)}"><node id="${a(m)}">${l}<data>${a(o.data)}</data></node></${chunkUEIXRTAG_cjs.g}>`,propsPartName:u,propsXml:`<ds:datastoreItem ds:itemID="${a(c)}" xmlns:ds="${store.DATASTORE_NAMESPACE_URI}"><ds:schemaRefs><ds:schemaRef ds:uri="${a(s)}"/></ds:schemaRefs></ds:datastoreItem>`,storeItemId:c,relationships:[{from:"/word/document.xml",type:store.CUSTOM_XML_REL,target:`../customXml/item${String(d)}.xml`},{from:e,type:store.CUSTOM_XML_PROPS_REL,target:`itemProps${String(d)}.xml`}],contentTypeOverride:{partName:u,contentType:store.CUSTOM_XML_PROPS_TYPE}}}}Object.defineProperty(exports,"CUSTOM_NODE_STORE_ROOT",{enumerable:true,get:function(){return chunkUEIXRTAG_cjs.g}});Object.defineProperty(exports,"MAX_CUSTOM_NODE_DATA_LENGTH",{enumerable:true,get:function(){return chunkUEIXRTAG_cjs.d}});Object.defineProperty(exports,"MAX_TAG_LENGTH",{enumerable:true,get:function(){return chunkUEIXRTAG_cjs.a}});Object.defineProperty(exports,"customNodeNamespace",{enumerable:true,get:function(){return chunkUEIXRTAG_cjs.h}});Object.defineProperty(exports,"customNodesModule",{enumerable:true,get:function(){return chunkUEIXRTAG_cjs.m}});Object.defineProperty(exports,"decodeCustomNodeTag",{enumerable:true,get:function(){return chunkUEIXRTAG_cjs.c}});Object.defineProperty(exports,"defineCustomNode",{enumerable:true,get:function(){return chunkUEIXRTAG_cjs.l}});Object.defineProperty(exports,"encodeCustomNodeTag",{enumerable:true,get:function(){return chunkUEIXRTAG_cjs.b}});Object.defineProperty(exports,"insertCustomNode",{enumerable:true,get:function(){return chunkUEIXRTAG_cjs.p}});Object.defineProperty(exports,"isCustomNodeDefinition",{enumerable:true,get:function(){return chunkUEIXRTAG_cjs.j}});Object.defineProperty(exports,"parseCustomNodeData",{enumerable:true,get:function(){return chunkUEIXRTAG_cjs.e}});Object.defineProperty(exports,"recognizeCustomNodes",{enumerable:true,get:function(){return chunkUEIXRTAG_cjs.n}});Object.defineProperty(exports,"removeCustomNode",{enumerable:true,get:function(){return chunkUEIXRTAG_cjs.q}});Object.defineProperty(exports,"reviewModule",{enumerable:true,get:function(){return chunkUEIXRTAG_cjs.o}});Object.defineProperty(exports,"serializeCustomNodeData",{enumerable:true,get:function(){return chunkUEIXRTAG_cjs.f}});Object.defineProperty(exports,"updateCustomNode",{enumerable:true,get:function(){return chunkUEIXRTAG_cjs.r}});Object.defineProperty(exports,"compareDocuments",{enumerable:true,get:function(){return chunkVJOGWUUQ_cjs.a}});Object.defineProperty(exports,"collaborationModule",{enumerable:true,get:function(){return chunkQEULTKCT_cjs.a}});exports.customNodeXml=Q;exports.customNodesOf=L;exports.prepareForExport=E;exports.saveForExport=H;
|
package/dist/index.js
CHANGED
|
@@ -3,4 +3,4 @@ Copyright (c) 2026 Eigenpal, Inc. All rights reserved.
|
|
|
3
3
|
Licensed under the EigenPal Pro Evaluation License 1.0. See LICENSE.md in this package.
|
|
4
4
|
Production use requires a commercial agreement: licensing@eigenpal.com
|
|
5
5
|
*/
|
|
6
|
-
import {j,n,h,k,b,i,g,c}from'./chunk-
|
|
6
|
+
import {j,n,h,k,b,i,g,c}from'./chunk-QVYUMMPG.js';export{g as CUSTOM_NODE_STORE_ROOT,d as MAX_CUSTOM_NODE_DATA_LENGTH,a as MAX_TAG_LENGTH,h as customNodeNamespace,m as customNodesModule,c as decodeCustomNodeTag,l as defineCustomNode,b as encodeCustomNodeTag,p as insertCustomNode,j as isCustomNodeDefinition,e as parseCustomNodeData,n as recognizeCustomNodes,q as removeCustomNode,o as reviewModule,f as serializeCustomNodeData,r as updateCustomNode}from'./chunk-QVYUMMPG.js';export{a as compareDocuments}from'./chunk-B4OWKZIG.js';export{a as collaborationModule}from'./chunk-EOZ44UA7.js';import'./chunk-6WITPFTY.js';import'./chunk-HMU7J34H.js';import {customNodePayloadsByControl,readOoxmlPackage,withExportedCustomNodes,writeOoxmlPackage,isStoryPart,fnv1a32,datastoreItemIdFor,customNodeBinding,CUSTOM_XML_PROPS_TYPE,CUSTOM_XML_REL,CUSTOM_XML_PROPS_REL,DATASTORE_NAMESPACE_URI}from'@docx-editor.dev/core/store';function L(t,n$1={}){let r=F(t);if(!r)return [];let o=n$1.nodes??t.getCustomNodeDefinitions().filter(j);if(o.length===0)return [];let s=r.session.currentPackage(),d=r.session.part().name,m=n$1.onDiagnostic??(e=>{t.reportCustomNodeDiagnostic(e);});return r.session.storyParts().flatMap(e=>n(e,o,{payloads:customNodePayloadsByControl(s,e.name,d),onDiagnostic:m}))}function F(t){return t.surface??null}function E(t,n,r={}){if(r.destination==="internal")return {ok:true,bytes:t,unwrapped:0,removed:0};let o=readOoxmlPackage(t);if(!o.ok)return {ok:false,reason:`the document could not be read: ${o.reason}`};let s=new Map;for(let i of n)s.set(`${i.tagPrefix}:${i.name}`,i);let d=i=>{let p=c(i);if(!p)return "keep";let x=s.get(`${p.prefix}:${p.name}`);return x?x.preserveOnExport==="text"?"text":x.preserveOnExport===false?"remove":"keep":"keep"},m=[...new Set(n.filter(i=>i.preserveOnExport!==void 0).filter(i=>i.preserveOnExport!==true).map(h))],e=o.package,u=0,c$1=0,N=G(e);for(let i of N){let p=withExportedCustomNodes(e,{storyPartName:i,namespaces:[],decide:d});if(!p.ok)return {ok:false,reason:p.reason};e=p.pkg,u+=p.unwrapped,c$1+=p.removed;}let l=withExportedCustomNodes(e,{storyPartName:e.mainDocumentPart,namespaces:m,decide:()=>"keep"});return l.ok?(e=l.pkg,{ok:true,bytes:writeOoxmlPackage(e),unwrapped:u,removed:c$1}):{ok:false,reason:l.reason}}function G(t){let n=[];for(let[r,o]of t.parts)r!==t.mainDocumentPart&&isStoryPart(o)&&n.push(r);return [t.mainDocumentPart,...n]}async function H(t,n={}){let r=n.nodes??t.getCustomNodeDefinitions().filter(j),o=await t.save();return E(new Uint8Array(o),r,{...n.destination===void 0?{}:{destination:n.destination}})}function a(t){return t.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Q(t,n,r,o={}){if(!k.test(t.tagPrefix)||!k.test(t.name))return {ok:false,code:"invalidArgs",reason:"the definition identity must match defineCustomNode\u2019s charset ([A-Za-z0-9_.-])"};let s=b(t.tagPrefix,t.name,n);if(!s.ok)return {ok:false,code:"invalidArgs",reason:`the encoded tag is ${s.length} characters; Word caps w:tag at 64 \u2014 shorten the attrs`};let d=o.lock===void 0?"contentLocked":o.lock,m=o.id!==void 0&&Number.isInteger(o.id)&&o.id>0?o.id:fnv1a32(`${s.tag}\0${r}`)&2147483647||1,e=o.data===void 0?null:ee(t,o,r);if(e&&"reason"in e)return {ok:false,code:"invalidArgs",reason:e.reason};let u=(o.alias!==void 0?`<w:alias w:val="${a(o.alias)}"/>`:"")+`<w:tag w:val="${a(s.tag)}"/><w:id w:val="${m}"/>`+(d===false?"":`<w:lock w:val="${d}"/>`)+(e?`<w:dataBinding w:prefixMappings="${a(e.binding.prefixMappings)}" w:xpath="${a(e.binding.xpath)}" w:storeItemID="${a(e.binding.storeItemId)}"/>`:""),c=`<w:r><w:t xml:space="preserve">${a(r)}</w:t></w:r>`;return {ok:true,xml:`<w:sdt><w:sdtPr>${u}</w:sdtPr><w:sdtContent>${c}</w:sdtContent></w:sdt>`,...e?{store:e.store}:{}}}function ee(t,n,r){let o=i(t,n.data);if(!o.ok)return {reason:o.reason};let s=h(t),d=n.storeIndex!==void 0&&Number.isInteger(n.storeIndex)&&n.storeIndex>0?n.storeIndex:1,m=n.nodeId??"cx1",e=`/customXml/item${String(d)}.xml`,u=`/customXml/itemProps${String(d)}.xml`,c=datastoreItemIdFor(`${s} ${e} ${m}`),N=customNodeBinding({partName:e,propsPartName:u,itemId:c,namespaceUri:s},g,m);if(!N)return {reason:`the payload cannot be addressed by an XPath: check nodeId (${m}) and payloadNamespace`};let l=r===r.trim()?`<label>${a(r)}</label>`:`<label xml:space="preserve">${a(r)}</label>`;return {binding:N,store:{itemPartName:e,itemXml:`<${g} xmlns="${a(s)}"><node id="${a(m)}">${l}<data>${a(o.data)}</data></node></${g}>`,propsPartName:u,propsXml:`<ds:datastoreItem ds:itemID="${a(c)}" xmlns:ds="${DATASTORE_NAMESPACE_URI}"><ds:schemaRefs><ds:schemaRef ds:uri="${a(s)}"/></ds:schemaRefs></ds:datastoreItem>`,storeItemId:c,relationships:[{from:"/word/document.xml",type:CUSTOM_XML_REL,target:`../customXml/item${String(d)}.xml`},{from:e,type:CUSTOM_XML_PROPS_REL,target:`itemProps${String(d)}.xml`}],contentTypeOverride:{partName:u,contentType:CUSTOM_XML_PROPS_TYPE}}}}export{Q as customNodeXml,L as customNodesOf,E as prepareForExport,H as saveForExport};
|