@docx-editor.dev/pro 2.10.0 → 2.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/README.md +1 -7
  2. package/dist/chunk-32RB7HPL.js +3 -0
  3. package/dist/chunk-4HGT2OVX.cjs +3 -0
  4. package/dist/chunk-6DEUT2RQ.js +1 -0
  5. package/dist/chunk-7QSJBMZV.js +3 -0
  6. package/dist/chunk-EMO6YTKO.cjs +1 -0
  7. package/dist/chunk-GDTCNTK7.cjs +1 -0
  8. package/dist/chunk-HJB77VBO.js +1 -0
  9. package/dist/chunk-LUUFBXJ5.cjs +1 -0
  10. package/dist/chunk-NQW54J56.js +1 -0
  11. package/dist/chunk-Q2VBO66F.js +1 -0
  12. package/dist/chunk-Q4YPX2DT.cjs +1 -0
  13. package/dist/chunk-QLZH2Q2C.cjs +1 -0
  14. package/dist/chunk-W3V54DWZ.js +1 -0
  15. package/dist/chunk-YJM6R76M.cjs +3 -0
  16. package/dist/collaboration/hocuspocus.cjs +1 -0
  17. package/dist/collaboration/hocuspocus.d.cts +58 -0
  18. package/dist/collaboration/hocuspocus.d.ts +58 -0
  19. package/dist/collaboration/hocuspocus.js +1 -0
  20. package/dist/collaboration/index.cjs +2 -0
  21. package/dist/collaboration/index.d.cts +22 -0
  22. package/dist/collaboration/index.d.ts +22 -0
  23. package/dist/collaboration/index.js +2 -0
  24. package/dist/collaboration/webrtc.cjs +2 -0
  25. package/dist/collaboration/webrtc.d.cts +86 -0
  26. package/dist/collaboration/webrtc.d.ts +86 -0
  27. package/dist/collaboration/webrtc.js +2 -0
  28. package/dist/collaboration-module-BgRxhW5b.d.cts +45 -0
  29. package/dist/collaboration-module-BgRxhW5b.d.ts +45 -0
  30. package/dist/{define-custom-node-Bk8kFO27.d.cts → define-custom-node-B_p2nr9T.d.cts} +2 -20
  31. package/dist/{define-custom-node-Bk8kFO27.d.ts → define-custom-node-BehI3jWX.d.ts} +2 -20
  32. package/dist/document-session-2B3QFWBQ.cjs +1 -0
  33. package/dist/document-session-6UET6BWT.js +1 -0
  34. package/dist/document-session-DVa53DAw.d.cts +94 -0
  35. package/dist/document-session-DiBuzWwA.d.ts +94 -0
  36. package/dist/document-session-RGNZHMWF.js +1 -0
  37. package/dist/document-session-TU7WVBRB.cjs +1 -0
  38. package/dist/hocuspocus-EUC4BGDD.js +1 -0
  39. package/dist/hocuspocus-YIKH6ENE.cjs +1 -0
  40. package/dist/index.cjs +1 -1
  41. package/dist/index.d.cts +4 -2
  42. package/dist/index.d.ts +4 -2
  43. package/dist/index.js +1 -1
  44. package/dist/react/hocuspocus.cjs +1 -0
  45. package/dist/react/hocuspocus.d.cts +104 -0
  46. package/dist/react/hocuspocus.d.ts +104 -0
  47. package/dist/react/hocuspocus.js +1 -0
  48. package/dist/react/index.cjs +2 -2
  49. package/dist/react/index.d.cts +320 -5
  50. package/dist/react/index.d.ts +320 -5
  51. package/dist/react/index.js +2 -2
  52. package/dist/react/webrtc.cjs +1 -0
  53. package/dist/react/webrtc.d.cts +98 -0
  54. package/dist/react/webrtc.d.ts +98 -0
  55. package/dist/react/webrtc.js +1 -0
  56. package/dist/room-id-BfudXOZz.d.cts +13 -0
  57. package/dist/room-id-BfudXOZz.d.ts +13 -0
  58. package/dist/session-BH7Qgyp6.d.cts +140 -0
  59. package/dist/session-BH7Qgyp6.d.ts +140 -0
  60. package/dist/session-okdqygLg.d.cts +82 -0
  61. package/dist/session-okdqygLg.d.ts +82 -0
  62. package/dist/vue/hocuspocus.cjs +1 -0
  63. package/dist/vue/hocuspocus.d.cts +105 -0
  64. package/dist/vue/hocuspocus.d.ts +105 -0
  65. package/dist/vue/hocuspocus.js +1 -0
  66. package/dist/vue/index.cjs +2 -2
  67. package/dist/vue/index.d.cts +437 -1
  68. package/dist/vue/index.d.ts +437 -1
  69. package/dist/vue/index.js +2 -2
  70. package/dist/vue/webrtc.cjs +1 -0
  71. package/dist/vue/webrtc.d.cts +99 -0
  72. package/dist/vue/webrtc.d.ts +99 -0
  73. package/dist/vue/webrtc.js +1 -0
  74. package/dist/webrtc-36GPPCW4.js +2 -0
  75. package/dist/webrtc-CDIFHCQY.cjs +2 -0
  76. package/package.json +62 -7
  77. package/dist/chunk-4LFF2FXG.cjs +0 -1
  78. package/dist/chunk-TH5PXU6L.js +0 -1
@@ -0,0 +1,94 @@
1
+ import * as Y from 'yjs';
2
+ import { Awareness } from 'y-protocols/awareness';
3
+ import { CollaborationIdentity } from '@docx-editor.dev/core/collaboration';
4
+ import { a as CollaborationBootstrap, c as CollaborationHandle, e as TextCollaborationSession, b as CollaborationIdentityUpdate } from './session-BH7Qgyp6.cjs';
5
+
6
+ /**
7
+ * Full-document collaboration over the canonical primitive journal.
8
+ *
9
+ * Local direction: the canonical store commits, emits ONE journal, and the journal is applied
10
+ * to shared state in one Yjs transaction. Remote direction: a shared-state change materializes
11
+ * one canonical package, which the port publishes as one revision. The two never chase each
12
+ * other, because a remote publication deliberately emits no journal.
13
+ */
14
+
15
+ /**
16
+ * Full-document collaboration session.
17
+ *
18
+ * The seam matches {@link TextCollaborationSession}, plus a live display-identity update.
19
+ * @public
20
+ */
21
+ interface DocumentCollaborationSession extends TextCollaborationSession {
22
+ /**
23
+ * Update the display identity for the rest of this session and republish presence.
24
+ *
25
+ * `name` revalidates with the construction rules (trimmed, 1 to 256 characters) and an
26
+ * invalid value throws. `color` longer than 64 characters throws; a color
27
+ * `safeParticipantColor` refuses is dropped, so peers fall back to the accent color.
28
+ * `actorId` and `role` are immutable — the update type cannot name them, and any extra
29
+ * runtime property is ignored.
30
+ */
31
+ setIdentity(update: CollaborationIdentityUpdate): void;
32
+ }
33
+ /** Owned full-document collaboration replica. @public */
34
+ type DocumentCollaborationHandle = CollaborationHandle<DocumentCollaborationSession>;
35
+ /**
36
+ * Options for one full-document collaboration replica.
37
+ *
38
+ * The caller owns `ydoc`.
39
+ * @public
40
+ */
41
+ interface CreateDocumentCollaborationOptions {
42
+ readonly ydoc: Y.Doc;
43
+ readonly awareness: Awareness;
44
+ readonly documentId: string;
45
+ /** Unique attachment identity. Omit it to generate a new identity for this session. */
46
+ readonly sessionId?: string;
47
+ readonly identity: CollaborationIdentity;
48
+ readonly bootstrap: CollaborationBootstrap;
49
+ /**
50
+ * Admit local edits while the transport is `disconnected`.
51
+ *
52
+ * A journal applies to the local `Y.Doc` either way, so buffered offline edits merge on
53
+ * reconnect exactly as concurrent online edits do. Off by default: a host that shows no
54
+ * offline indicator would let users type into a document no peer receives yet. `error`
55
+ * stays terminal and `initializing` stays refused regardless of this option.
56
+ */
57
+ readonly offlineEditing?: boolean;
58
+ }
59
+ /**
60
+ * Read the document a synchronized `Y.Doc` holds, as `.docx` bytes.
61
+ *
62
+ * This is the server side of a room: export, autosave to your own storage, search indexing, a
63
+ * nightly PDF, a webhook. It JOINS NOTHING. There is no identity, no `Awareness` and no
64
+ * session, so the job that calls it never appears in anyone's avatar stack, and it creates no
65
+ * editing gate, so it cannot write back.
66
+ *
67
+ * `ydoc` must already hold the room's state: connect your provider and wait for its initial
68
+ * sync first, exactly as a `{ kind: \'join\' }` bootstrap does. A document that was never
69
+ * seeded refuses with `not-initialized` rather than returning a truncated file.
70
+ *
71
+ * ```ts
72
+ * // Hocuspocus hands `onStoreDocument` the synced Y.Doc already:
73
+ * async onStoreDocument({ documentName, document }) {
74
+ * await writeFile(`${documentName}.docx`, readCollaborationDocument(document));
75
+ * }
76
+ * ```
77
+ *
78
+ * Synchronous, and it materializes the whole package per call — this is a job, not a render.
79
+ *
80
+ * @throws CollaborationSchemaError — `not-initialized`, `concurrent-seed`,
81
+ * `blob-digest-mismatch`, or a limit code: the same refusals a joining replica makes, for the
82
+ * same reasons.
83
+ * @public
84
+ */
85
+ declare function readCollaborationDocument(ydoc: Y.Doc): Uint8Array;
86
+ /**
87
+ * Create or join one full-document collaboration replica.
88
+ *
89
+ * The caller owns `ydoc`.
90
+ * @public
91
+ */
92
+ declare function createDocumentCollaboration(options: CreateDocumentCollaborationOptions): Promise<DocumentCollaborationHandle>;
93
+
94
+ export { type CreateDocumentCollaborationOptions as C, type DocumentCollaborationHandle as D, type DocumentCollaborationSession as a, createDocumentCollaboration as c, readCollaborationDocument as r };
@@ -0,0 +1,94 @@
1
+ import * as Y from 'yjs';
2
+ import { Awareness } from 'y-protocols/awareness';
3
+ import { CollaborationIdentity } from '@docx-editor.dev/core/collaboration';
4
+ import { a as CollaborationBootstrap, c as CollaborationHandle, e as TextCollaborationSession, b as CollaborationIdentityUpdate } from './session-BH7Qgyp6.js';
5
+
6
+ /**
7
+ * Full-document collaboration over the canonical primitive journal.
8
+ *
9
+ * Local direction: the canonical store commits, emits ONE journal, and the journal is applied
10
+ * to shared state in one Yjs transaction. Remote direction: a shared-state change materializes
11
+ * one canonical package, which the port publishes as one revision. The two never chase each
12
+ * other, because a remote publication deliberately emits no journal.
13
+ */
14
+
15
+ /**
16
+ * Full-document collaboration session.
17
+ *
18
+ * The seam matches {@link TextCollaborationSession}, plus a live display-identity update.
19
+ * @public
20
+ */
21
+ interface DocumentCollaborationSession extends TextCollaborationSession {
22
+ /**
23
+ * Update the display identity for the rest of this session and republish presence.
24
+ *
25
+ * `name` revalidates with the construction rules (trimmed, 1 to 256 characters) and an
26
+ * invalid value throws. `color` longer than 64 characters throws; a color
27
+ * `safeParticipantColor` refuses is dropped, so peers fall back to the accent color.
28
+ * `actorId` and `role` are immutable — the update type cannot name them, and any extra
29
+ * runtime property is ignored.
30
+ */
31
+ setIdentity(update: CollaborationIdentityUpdate): void;
32
+ }
33
+ /** Owned full-document collaboration replica. @public */
34
+ type DocumentCollaborationHandle = CollaborationHandle<DocumentCollaborationSession>;
35
+ /**
36
+ * Options for one full-document collaboration replica.
37
+ *
38
+ * The caller owns `ydoc`.
39
+ * @public
40
+ */
41
+ interface CreateDocumentCollaborationOptions {
42
+ readonly ydoc: Y.Doc;
43
+ readonly awareness: Awareness;
44
+ readonly documentId: string;
45
+ /** Unique attachment identity. Omit it to generate a new identity for this session. */
46
+ readonly sessionId?: string;
47
+ readonly identity: CollaborationIdentity;
48
+ readonly bootstrap: CollaborationBootstrap;
49
+ /**
50
+ * Admit local edits while the transport is `disconnected`.
51
+ *
52
+ * A journal applies to the local `Y.Doc` either way, so buffered offline edits merge on
53
+ * reconnect exactly as concurrent online edits do. Off by default: a host that shows no
54
+ * offline indicator would let users type into a document no peer receives yet. `error`
55
+ * stays terminal and `initializing` stays refused regardless of this option.
56
+ */
57
+ readonly offlineEditing?: boolean;
58
+ }
59
+ /**
60
+ * Read the document a synchronized `Y.Doc` holds, as `.docx` bytes.
61
+ *
62
+ * This is the server side of a room: export, autosave to your own storage, search indexing, a
63
+ * nightly PDF, a webhook. It JOINS NOTHING. There is no identity, no `Awareness` and no
64
+ * session, so the job that calls it never appears in anyone's avatar stack, and it creates no
65
+ * editing gate, so it cannot write back.
66
+ *
67
+ * `ydoc` must already hold the room's state: connect your provider and wait for its initial
68
+ * sync first, exactly as a `{ kind: \'join\' }` bootstrap does. A document that was never
69
+ * seeded refuses with `not-initialized` rather than returning a truncated file.
70
+ *
71
+ * ```ts
72
+ * // Hocuspocus hands `onStoreDocument` the synced Y.Doc already:
73
+ * async onStoreDocument({ documentName, document }) {
74
+ * await writeFile(`${documentName}.docx`, readCollaborationDocument(document));
75
+ * }
76
+ * ```
77
+ *
78
+ * Synchronous, and it materializes the whole package per call — this is a job, not a render.
79
+ *
80
+ * @throws CollaborationSchemaError — `not-initialized`, `concurrent-seed`,
81
+ * `blob-digest-mismatch`, or a limit code: the same refusals a joining replica makes, for the
82
+ * same reasons.
83
+ * @public
84
+ */
85
+ declare function readCollaborationDocument(ydoc: Y.Doc): Uint8Array;
86
+ /**
87
+ * Create or join one full-document collaboration replica.
88
+ *
89
+ * The caller owns `ydoc`.
90
+ * @public
91
+ */
92
+ declare function createDocumentCollaboration(options: CreateDocumentCollaborationOptions): Promise<DocumentCollaborationHandle>;
93
+
94
+ export { type CreateDocumentCollaborationOptions as C, type DocumentCollaborationHandle as D, type DocumentCollaborationSession as a, createDocumentCollaboration as c, readCollaborationDocument as r };
@@ -0,0 +1 @@
1
+ export{b as ATTACH_WATCHDOG_MS_FOR_TESTS,d as createDocumentCollaboration,c as readCollaborationDocument}from'./chunk-7QSJBMZV.js';
@@ -0,0 +1 @@
1
+ 'use strict';var chunkYJM6R76M_cjs=require('./chunk-YJM6R76M.cjs');Object.defineProperty(exports,"ATTACH_WATCHDOG_MS_FOR_TESTS",{enumerable:true,get:function(){return chunkYJM6R76M_cjs.b}});Object.defineProperty(exports,"createDocumentCollaboration",{enumerable:true,get:function(){return chunkYJM6R76M_cjs.d}});Object.defineProperty(exports,"readCollaborationDocument",{enumerable:true,get:function(){return chunkYJM6R76M_cjs.c}});
@@ -0,0 +1 @@
1
+ import {b}from'./chunk-6DEUT2RQ.js';export{a as createCollaborationRoomId,b as validateRoomId}from'./chunk-6DEUT2RQ.js';import {d,a}from'./chunk-7QSJBMZV.js';import*as P from'yjs';import {Awareness}from'y-protocols/awareness';import {HocuspocusProvider}from'@hocuspocus/provider';var g=3e4,S=Symbol("createHocuspocusCollaboration.provider"),O=o=>new HocuspocusProvider({url:o.url,name:o.name,document:o.document,awareness:o.awareness,...o.token!==void 0?{token:o.token}:{}});function F(o,d){return new Promise((c,e)=>{if(o.isSynced){c();return}let n=()=>{clearTimeout(s),o.off("synced",a$1),o.off("authenticationFailed",t);},a$1=()=>{n(),c();},t=r=>{n(),e(new a("initialization-aborted",`authentication failed: ${r.reason}`));},s=setTimeout(()=>{n(),e(new a("initialization-timeout"));},d);o.on("synced",a$1),o.on("authenticationFailed",t);})}async function E(o){let d$1=b(o.roomId),c=o[S]??O,e=new P.Doc,n=new Awareness(e),a=()=>c({url:o.url,name:d$1,document:e,awareness:n,...o.token!==void 0?{token:o.token}:{}}),t=null,s=null;try{o.bootstrap.kind!=="create"&&(t=a(),await F(t,o.syncedTimeoutMs??g)),s=await d({ydoc:e,awareness:n,documentId:d$1,identity:o.identity,bootstrap:o.bootstrap,offlineEditing:o.offlineEditing}),t||(t=a());}catch(i){throw s?.destroy(),t?.destroy(),n.destroy(),e.destroy(),i}let r=t,u=s,l=u.session,f=i=>{l.setTransportStatus(i.status==="connected"?"ready":"disconnected",i.status==="connected"?void 0:"transport-disconnected",i.status==="connected"?void 0:"websocket disconnected");};r.on("status",f);let p=()=>{l.setTransportStatus("error","authentication-failed");};r.on("authenticationFailed",p);let b$1=false;return Object.freeze({document:u.document,session:l,ydoc:e,provider:r,destroy(){b$1||(b$1=true,r.off("status",f),r.off("authenticationFailed",p),u.destroy(),r.destroy(),n.destroy(),e.destroy());}})}export{S as HOCUSPOCUS_PROVIDER_FOR_TESTS,E as createHocuspocusCollaboration};
@@ -0,0 +1 @@
1
+ 'use strict';var chunkLUUFBXJ5_cjs=require('./chunk-LUUFBXJ5.cjs'),chunkYJM6R76M_cjs=require('./chunk-YJM6R76M.cjs'),P=require('yjs'),awareness=require('y-protocols/awareness'),provider=require('@hocuspocus/provider');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var P__namespace=/*#__PURE__*/_interopNamespace(P);var g=3e4,S=Symbol("createHocuspocusCollaboration.provider"),O=o=>new provider.HocuspocusProvider({url:o.url,name:o.name,document:o.document,awareness:o.awareness,...o.token!==void 0?{token:o.token}:{}});function F(o,d){return new Promise((c,e)=>{if(o.isSynced){c();return}let n=()=>{clearTimeout(s),o.off("synced",a),o.off("authenticationFailed",t);},a=()=>{n(),c();},t=r=>{n(),e(new chunkYJM6R76M_cjs.a("initialization-aborted",`authentication failed: ${r.reason}`));},s=setTimeout(()=>{n(),e(new chunkYJM6R76M_cjs.a("initialization-timeout"));},d);o.on("synced",a),o.on("authenticationFailed",t);})}async function E(o){let d=chunkLUUFBXJ5_cjs.b(o.roomId),c=o[S]??O,e=new P__namespace.Doc,n=new awareness.Awareness(e),a=()=>c({url:o.url,name:d,document:e,awareness:n,...o.token!==void 0?{token:o.token}:{}}),t=null,s=null;try{o.bootstrap.kind!=="create"&&(t=a(),await F(t,o.syncedTimeoutMs??g)),s=await chunkYJM6R76M_cjs.d({ydoc:e,awareness:n,documentId:d,identity:o.identity,bootstrap:o.bootstrap,offlineEditing:o.offlineEditing}),t||(t=a());}catch(i){throw s?.destroy(),t?.destroy(),n.destroy(),e.destroy(),i}let r=t,u=s,l=u.session,f=i=>{l.setTransportStatus(i.status==="connected"?"ready":"disconnected",i.status==="connected"?void 0:"transport-disconnected",i.status==="connected"?void 0:"websocket disconnected");};r.on("status",f);let p=()=>{l.setTransportStatus("error","authentication-failed");};r.on("authenticationFailed",p);let b=false;return Object.freeze({document:u.document,session:l,ydoc:e,provider:r,destroy(){b||(b=true,r.off("status",f),r.off("authenticationFailed",p),u.destroy(),r.destroy(),n.destroy(),e.destroy());}})}Object.defineProperty(exports,"createCollaborationRoomId",{enumerable:true,get:function(){return chunkLUUFBXJ5_cjs.a}});Object.defineProperty(exports,"validateRoomId",{enumerable:true,get:function(){return chunkLUUFBXJ5_cjs.b}});exports.HOCUSPOCUS_PROVIDER_FOR_TESTS=S;exports.createHocuspocusCollaboration=E;
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- 'use strict';var chunk4LFF2FXG_cjs=require('./chunk-4LFF2FXG.cjs'),store=require('@docx-editor.dev/core/store');function b(t,n={}){let r=U(t);if(!r)return [];let o=n.nodes??t.getCustomNodeDefinitions().filter(chunk4LFF2FXG_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=>chunk4LFF2FXG_cjs.n(e,o,{payloads:store.customNodePayloadsByControl(s,e.name,d),onDiagnostic:m}))}function U(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=chunk4LFF2FXG_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(chunk4LFF2FXG_cjs.h))],e=o.package,u=0,c=0,g=B(e);for(let i of g){let p=store.withExportedCustomNodes(e,{storyPartName:i,namespaces:[],decide:d});if(!p.ok)return {ok:false,reason:p.reason};e=p.pkg,u+=p.unwrapped,c+=p.removed;}let l=store.withExportedCustomNodes(e,{storyPartName:e.mainDocumentPart,namespaces:m,decide:()=>"keep"});return l.ok?(e=l.pkg,{ok:true,bytes:store.writeOoxmlPackage(e),unwrapped:u,removed:c}):{ok:false,reason:l.reason}}function B(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 V(t,n={}){let r=n.nodes??t.getCustomNodeDefinitions().filter(chunk4LFF2FXG_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,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function J(t,n,r,o={}){if(!chunk4LFF2FXG_cjs.k.test(t.tagPrefix)||!chunk4LFF2FXG_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=chunk4LFF2FXG_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:K(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 K(t,n,r){let o=chunk4LFF2FXG_cjs.i(t,n.data);if(!o.ok)return {reason:o.reason};let s=chunk4LFF2FXG_cjs.h(t),d=n.storeIndex!==void 0&&Number.isInteger(n.storeIndex)&&n.storeIndex>0?n.storeIndex:1,m=n.nodeId??"cx1",e=`/customXml/item${String(d)}.xml`,u=`/customXml/itemProps${String(d)}.xml`,c=store.datastoreItemIdFor(`${s} ${e} ${m}`),g=store.customNodeBinding({partName:e,propsPartName:u,itemId:c,namespaceUri:s},chunk4LFF2FXG_cjs.g,m);if(!g)return {reason:`the payload cannot be addressed by an XPath: check nodeId (${m}) and payloadNamespace`};let l=r===r.trim()?`<label>${a(r)}</label>`:`<label xml:space="preserve">${a(r)}</label>`;return {binding:g,store:{itemPartName:e,itemXml:`<${chunk4LFF2FXG_cjs.g} xmlns="${a(s)}"><node id="${a(m)}">${l}<data>${a(o.data)}</data></node></${chunk4LFF2FXG_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 chunk4LFF2FXG_cjs.g}});Object.defineProperty(exports,"MAX_CUSTOM_NODE_DATA_LENGTH",{enumerable:true,get:function(){return chunk4LFF2FXG_cjs.d}});Object.defineProperty(exports,"MAX_TAG_LENGTH",{enumerable:true,get:function(){return chunk4LFF2FXG_cjs.a}});Object.defineProperty(exports,"customNodeNamespace",{enumerable:true,get:function(){return chunk4LFF2FXG_cjs.h}});Object.defineProperty(exports,"customNodesModule",{enumerable:true,get:function(){return chunk4LFF2FXG_cjs.m}});Object.defineProperty(exports,"decodeCustomNodeTag",{enumerable:true,get:function(){return chunk4LFF2FXG_cjs.c}});Object.defineProperty(exports,"defineCustomNode",{enumerable:true,get:function(){return chunk4LFF2FXG_cjs.l}});Object.defineProperty(exports,"encodeCustomNodeTag",{enumerable:true,get:function(){return chunk4LFF2FXG_cjs.b}});Object.defineProperty(exports,"insertCustomNode",{enumerable:true,get:function(){return chunk4LFF2FXG_cjs.p}});Object.defineProperty(exports,"isCustomNodeDefinition",{enumerable:true,get:function(){return chunk4LFF2FXG_cjs.j}});Object.defineProperty(exports,"parseCustomNodeData",{enumerable:true,get:function(){return chunk4LFF2FXG_cjs.e}});Object.defineProperty(exports,"recognizeCustomNodes",{enumerable:true,get:function(){return chunk4LFF2FXG_cjs.n}});Object.defineProperty(exports,"removeCustomNode",{enumerable:true,get:function(){return chunk4LFF2FXG_cjs.q}});Object.defineProperty(exports,"reviewModule",{enumerable:true,get:function(){return chunk4LFF2FXG_cjs.o}});Object.defineProperty(exports,"serializeCustomNodeData",{enumerable:true,get:function(){return chunk4LFF2FXG_cjs.f}});Object.defineProperty(exports,"updateCustomNode",{enumerable:true,get:function(){return chunk4LFF2FXG_cjs.r}});exports.customNodeXml=J;exports.customNodesOf=b;exports.prepareForExport=E;exports.saveForExport=V;
1
+ 'use strict';var chunkEMO6YTKO_cjs=require('./chunk-EMO6YTKO.cjs'),chunkQLZH2Q2C_cjs=require('./chunk-QLZH2Q2C.cjs'),store=require('@docx-editor.dev/core/store');function U(t,n={}){let r=L(t);if(!r)return [];let o=n.nodes??t.getCustomNodeDefinitions().filter(chunkEMO6YTKO_cjs.j);if(o.length===0)return [];let s=r.session.currentPackage(),d=r.session.part().name,m=n.onDiagnostic??(e=>{t.reportCustomNodeDiagnostic(e);});return r.session.storyParts().flatMap(e=>chunkEMO6YTKO_cjs.n(e,o,{payloads:store.customNodePayloadsByControl(s,e.name,d),onDiagnostic:m}))}function L(t){return t.surface??null}function E(t,n,r={}){if(r.destination==="internal")return {ok:true,bytes:t,unwrapped:0,removed:0};let o=store.readOoxmlPackage(t);if(!o.ok)return {ok:false,reason:`the document could not be read: ${o.reason}`};let s=new Map;for(let i of n)s.set(`${i.tagPrefix}:${i.name}`,i);let d=i=>{let p=chunkEMO6YTKO_cjs.c(i);if(!p)return "keep";let x=s.get(`${p.prefix}:${p.name}`);return x?x.preserveOnExport==="text"?"text":x.preserveOnExport===false?"remove":"keep":"keep"},m=[...new Set(n.filter(i=>i.preserveOnExport!==void 0).filter(i=>i.preserveOnExport!==true).map(chunkEMO6YTKO_cjs.h))],e=o.package,u=0,c=0,g=V(e);for(let i of g){let p=store.withExportedCustomNodes(e,{storyPartName:i,namespaces:[],decide:d});if(!p.ok)return {ok:false,reason:p.reason};e=p.pkg,u+=p.unwrapped,c+=p.removed;}let l=store.withExportedCustomNodes(e,{storyPartName:e.mainDocumentPart,namespaces:m,decide:()=>"keep"});return l.ok?(e=l.pkg,{ok:true,bytes:store.writeOoxmlPackage(e),unwrapped:u,removed:c}):{ok:false,reason:l.reason}}function V(t){let n=[];for(let[r,o]of t.parts)r!==t.mainDocumentPart&&store.isStoryPart(o)&&n.push(r);return [t.mainDocumentPart,...n]}async function G(t,n={}){let r=n.nodes??t.getCustomNodeDefinitions().filter(chunkEMO6YTKO_cjs.j),o=await t.save();return E(new Uint8Array(o),r,{...n.destination===void 0?{}:{destination:n.destination}})}function a(t){return t.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function K(t,n,r,o={}){if(!chunkEMO6YTKO_cjs.k.test(t.tagPrefix)||!chunkEMO6YTKO_cjs.k.test(t.name))return {ok:false,code:"invalidArgs",reason:"the definition identity must match defineCustomNode\u2019s charset ([A-Za-z0-9_.-])"};let s=chunkEMO6YTKO_cjs.b(t.tagPrefix,t.name,n);if(!s.ok)return {ok:false,code:"invalidArgs",reason:`the encoded tag is ${s.length} characters; Word caps w:tag at 64 \u2014 shorten the attrs`};let d=o.lock===void 0?"contentLocked":o.lock,m=o.id!==void 0&&Number.isInteger(o.id)&&o.id>0?o.id:store.fnv1a32(`${s.tag}\0${r}`)&2147483647||1,e=o.data===void 0?null:Q(t,o,r);if(e&&"reason"in e)return {ok:false,code:"invalidArgs",reason:e.reason};let u=(o.alias!==void 0?`<w:alias w:val="${a(o.alias)}"/>`:"")+`<w:tag w:val="${a(s.tag)}"/><w:id w:val="${m}"/>`+(d===false?"":`<w:lock w:val="${d}"/>`)+(e?`<w:dataBinding w:prefixMappings="${a(e.binding.prefixMappings)}" w:xpath="${a(e.binding.xpath)}" w:storeItemID="${a(e.binding.storeItemId)}"/>`:""),c=`<w:r><w:t xml:space="preserve">${a(r)}</w:t></w:r>`;return {ok:true,xml:`<w:sdt><w:sdtPr>${u}</w:sdtPr><w:sdtContent>${c}</w:sdtContent></w:sdt>`,...e?{store:e.store}:{}}}function Q(t,n,r){let o=chunkEMO6YTKO_cjs.i(t,n.data);if(!o.ok)return {reason:o.reason};let s=chunkEMO6YTKO_cjs.h(t),d=n.storeIndex!==void 0&&Number.isInteger(n.storeIndex)&&n.storeIndex>0?n.storeIndex:1,m=n.nodeId??"cx1",e=`/customXml/item${String(d)}.xml`,u=`/customXml/itemProps${String(d)}.xml`,c=store.datastoreItemIdFor(`${s} ${e} ${m}`),g=store.customNodeBinding({partName:e,propsPartName:u,itemId:c,namespaceUri:s},chunkEMO6YTKO_cjs.g,m);if(!g)return {reason:`the payload cannot be addressed by an XPath: check nodeId (${m}) and payloadNamespace`};let l=r===r.trim()?`<label>${a(r)}</label>`:`<label xml:space="preserve">${a(r)}</label>`;return {binding:g,store:{itemPartName:e,itemXml:`<${chunkEMO6YTKO_cjs.g} xmlns="${a(s)}"><node id="${a(m)}">${l}<data>${a(o.data)}</data></node></${chunkEMO6YTKO_cjs.g}>`,propsPartName:u,propsXml:`<ds:datastoreItem ds:itemID="${a(c)}" xmlns:ds="${store.DATASTORE_NAMESPACE_URI}"><ds:schemaRefs><ds:schemaRef ds:uri="${a(s)}"/></ds:schemaRefs></ds:datastoreItem>`,storeItemId:c,relationships:[{from:"/word/document.xml",type:store.CUSTOM_XML_REL,target:`../customXml/item${String(d)}.xml`},{from:e,type:store.CUSTOM_XML_PROPS_REL,target:`itemProps${String(d)}.xml`}],contentTypeOverride:{partName:u,contentType:store.CUSTOM_XML_PROPS_TYPE}}}}Object.defineProperty(exports,"CUSTOM_NODE_STORE_ROOT",{enumerable:true,get:function(){return chunkEMO6YTKO_cjs.g}});Object.defineProperty(exports,"MAX_CUSTOM_NODE_DATA_LENGTH",{enumerable:true,get:function(){return chunkEMO6YTKO_cjs.d}});Object.defineProperty(exports,"MAX_TAG_LENGTH",{enumerable:true,get:function(){return chunkEMO6YTKO_cjs.a}});Object.defineProperty(exports,"customNodeNamespace",{enumerable:true,get:function(){return chunkEMO6YTKO_cjs.h}});Object.defineProperty(exports,"customNodesModule",{enumerable:true,get:function(){return chunkEMO6YTKO_cjs.m}});Object.defineProperty(exports,"decodeCustomNodeTag",{enumerable:true,get:function(){return chunkEMO6YTKO_cjs.c}});Object.defineProperty(exports,"defineCustomNode",{enumerable:true,get:function(){return chunkEMO6YTKO_cjs.l}});Object.defineProperty(exports,"encodeCustomNodeTag",{enumerable:true,get:function(){return chunkEMO6YTKO_cjs.b}});Object.defineProperty(exports,"insertCustomNode",{enumerable:true,get:function(){return chunkEMO6YTKO_cjs.p}});Object.defineProperty(exports,"isCustomNodeDefinition",{enumerable:true,get:function(){return chunkEMO6YTKO_cjs.j}});Object.defineProperty(exports,"parseCustomNodeData",{enumerable:true,get:function(){return chunkEMO6YTKO_cjs.e}});Object.defineProperty(exports,"recognizeCustomNodes",{enumerable:true,get:function(){return chunkEMO6YTKO_cjs.n}});Object.defineProperty(exports,"removeCustomNode",{enumerable:true,get:function(){return chunkEMO6YTKO_cjs.q}});Object.defineProperty(exports,"reviewModule",{enumerable:true,get:function(){return chunkEMO6YTKO_cjs.o}});Object.defineProperty(exports,"serializeCustomNodeData",{enumerable:true,get:function(){return chunkEMO6YTKO_cjs.f}});Object.defineProperty(exports,"updateCustomNode",{enumerable:true,get:function(){return chunkEMO6YTKO_cjs.r}});Object.defineProperty(exports,"collaborationModule",{enumerable:true,get:function(){return chunkQLZH2Q2C_cjs.b}});exports.customNodeXml=K;exports.customNodesOf=U;exports.prepareForExport=E;exports.saveForExport=G;
package/dist/index.d.cts CHANGED
@@ -1,8 +1,10 @@
1
- import { A as AnyCustomNodeDefinition, C as CustomNodeDiagnostic, R as RecognizedCustomNode, S as StandardSchemaV1, I as InferSchemaInput, a as CustomNodeDefinition } from './define-custom-node-Bk8kFO27.cjs';
2
- export { b as ActivatedCustomNode, c as CustomNode, d as CustomNodeDataRejection, e as CustomNodeDataResult, f as CustomNodePayloadSource, g as CustomNodesModuleOptions, h as InferSchemaOutput, M as MAX_CUSTOM_NODE_DATA_LENGTH, P as ProLicenseOptions, i as RecognizeCustomNodesOptions, j as ReviewModuleOptions, k as StandardSchemaIssue, l as StandardSchemaResult, m as customNodesModule, n as defineCustomNode, o as isCustomNodeDefinition, p as parseCustomNodeData, r as recognizeCustomNodes, q as reviewModule, s as serializeCustomNodeData } from './define-custom-node-Bk8kFO27.cjs';
1
+ import { A as AnyCustomNodeDefinition, C as CustomNodeDiagnostic, R as RecognizedCustomNode, S as StandardSchemaV1, I as InferSchemaInput, a as CustomNodeDefinition } from './define-custom-node-B_p2nr9T.cjs';
2
+ export { b as ActivatedCustomNode, c as CustomNode, d as CustomNodeDataRejection, e as CustomNodeDataResult, f as CustomNodePayloadSource, g as CustomNodesModuleOptions, h as InferSchemaOutput, M as MAX_CUSTOM_NODE_DATA_LENGTH, i as RecognizeCustomNodesOptions, j as ReviewModuleOptions, k as StandardSchemaIssue, l as StandardSchemaResult, m as customNodesModule, n as defineCustomNode, o as isCustomNodeDefinition, p as parseCustomNodeData, r as recognizeCustomNodes, q as reviewModule, s as serializeCustomNodeData } from './define-custom-node-B_p2nr9T.cjs';
3
+ export { C as CollaborationModuleOptions, P as ProLicenseOptions, c as collaborationModule } from './collaboration-module-BgRxhW5b.cjs';
3
4
  import { Editor, ExecResult } from '@docx-editor.dev/core/contracts/editor';
4
5
  import '@docx-editor.dev/core/editor';
5
6
  import '@docx-editor.dev/core/store';
7
+ import '@docx-editor.dev/core/collaboration';
6
8
 
7
9
  /** How {@link customNodesOf} narrows what it answers. */
8
10
  interface CustomNodesOfOptions {
package/dist/index.d.ts CHANGED
@@ -1,8 +1,10 @@
1
- import { A as AnyCustomNodeDefinition, C as CustomNodeDiagnostic, R as RecognizedCustomNode, S as StandardSchemaV1, I as InferSchemaInput, a as CustomNodeDefinition } from './define-custom-node-Bk8kFO27.js';
2
- export { b as ActivatedCustomNode, c as CustomNode, d as CustomNodeDataRejection, e as CustomNodeDataResult, f as CustomNodePayloadSource, g as CustomNodesModuleOptions, h as InferSchemaOutput, M as MAX_CUSTOM_NODE_DATA_LENGTH, P as ProLicenseOptions, i as RecognizeCustomNodesOptions, j as ReviewModuleOptions, k as StandardSchemaIssue, l as StandardSchemaResult, m as customNodesModule, n as defineCustomNode, o as isCustomNodeDefinition, p as parseCustomNodeData, r as recognizeCustomNodes, q as reviewModule, s as serializeCustomNodeData } from './define-custom-node-Bk8kFO27.js';
1
+ import { A as AnyCustomNodeDefinition, C as CustomNodeDiagnostic, R as RecognizedCustomNode, S as StandardSchemaV1, I as InferSchemaInput, a as CustomNodeDefinition } from './define-custom-node-BehI3jWX.js';
2
+ export { b as ActivatedCustomNode, c as CustomNode, d as CustomNodeDataRejection, e as CustomNodeDataResult, f as CustomNodePayloadSource, g as CustomNodesModuleOptions, h as InferSchemaOutput, M as MAX_CUSTOM_NODE_DATA_LENGTH, i as RecognizeCustomNodesOptions, j as ReviewModuleOptions, k as StandardSchemaIssue, l as StandardSchemaResult, m as customNodesModule, n as defineCustomNode, o as isCustomNodeDefinition, p as parseCustomNodeData, r as recognizeCustomNodes, q as reviewModule, s as serializeCustomNodeData } from './define-custom-node-BehI3jWX.js';
3
+ export { C as CollaborationModuleOptions, P as ProLicenseOptions, c as collaborationModule } from './collaboration-module-BgRxhW5b.js';
3
4
  import { Editor, ExecResult } from '@docx-editor.dev/core/contracts/editor';
4
5
  import '@docx-editor.dev/core/editor';
5
6
  import '@docx-editor.dev/core/store';
7
+ import '@docx-editor.dev/core/collaboration';
6
8
 
7
9
  /** How {@link customNodesOf} narrows what it answers. */
8
10
  interface CustomNodesOfOptions {
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import {j,n,h,k,b as b$1,i,g,c}from'./chunk-TH5PXU6L.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-TH5PXU6L.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 b(t,n$1={}){let r=U(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 U(t){return t.surface??null}function E(t,n,r={}){if(r.destination==="internal")return {ok:true,bytes:t,unwrapped:0,removed:0};let o=readOoxmlPackage(t);if(!o.ok)return {ok:false,reason:`the document could not be read: ${o.reason}`};let s=new Map;for(let i of n)s.set(`${i.tagPrefix}:${i.name}`,i);let d=i=>{let p=c(i);if(!p)return "keep";let x=s.get(`${p.prefix}:${p.name}`);return x?x.preserveOnExport==="text"?"text":x.preserveOnExport===false?"remove":"keep":"keep"},m=[...new Set(n.filter(i=>i.preserveOnExport!==void 0).filter(i=>i.preserveOnExport!==true).map(h))],e=o.package,u=0,c$1=0,g=B(e);for(let i of g){let p=withExportedCustomNodes(e,{storyPartName:i,namespaces:[],decide:d});if(!p.ok)return {ok:false,reason:p.reason};e=p.pkg,u+=p.unwrapped,c$1+=p.removed;}let l=withExportedCustomNodes(e,{storyPartName:e.mainDocumentPart,namespaces:m,decide:()=>"keep"});return l.ok?(e=l.pkg,{ok:true,bytes:writeOoxmlPackage(e),unwrapped:u,removed:c$1}):{ok:false,reason:l.reason}}function B(t){let n=[];for(let[r,o]of t.parts)r!==t.mainDocumentPart&&isStoryPart(o)&&n.push(r);return [t.mainDocumentPart,...n]}async function V(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,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function J(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$1(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:K(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 K(t,n,r){let o=i(t,n.data);if(!o.ok)return {reason:o.reason};let s=h(t),d=n.storeIndex!==void 0&&Number.isInteger(n.storeIndex)&&n.storeIndex>0?n.storeIndex:1,m=n.nodeId??"cx1",e=`/customXml/item${String(d)}.xml`,u=`/customXml/itemProps${String(d)}.xml`,c=datastoreItemIdFor(`${s} ${e} ${m}`),g$1=customNodeBinding({partName:e,propsPartName:u,itemId:c,namespaceUri:s},g,m);if(!g$1)return {reason:`the payload cannot be addressed by an XPath: check nodeId (${m}) and payloadNamespace`};let l=r===r.trim()?`<label>${a(r)}</label>`:`<label xml:space="preserve">${a(r)}</label>`;return {binding:g$1,store:{itemPartName:e,itemXml:`<${g} xmlns="${a(s)}"><node id="${a(m)}">${l}<data>${a(o.data)}</data></node></${g}>`,propsPartName:u,propsXml:`<ds:datastoreItem ds:itemID="${a(c)}" xmlns:ds="${DATASTORE_NAMESPACE_URI}"><ds:schemaRefs><ds:schemaRef ds:uri="${a(s)}"/></ds:schemaRefs></ds:datastoreItem>`,storeItemId:c,relationships:[{from:"/word/document.xml",type:CUSTOM_XML_REL,target:`../customXml/item${String(d)}.xml`},{from:e,type:CUSTOM_XML_PROPS_REL,target:`itemProps${String(d)}.xml`}],contentTypeOverride:{partName:u,contentType:CUSTOM_XML_PROPS_TYPE}}}}export{J as customNodeXml,b as customNodesOf,E as prepareForExport,V as saveForExport};
1
+ import {j,n,h,k,b,i,g,c}from'./chunk-NQW54J56.js';export{g as CUSTOM_NODE_STORE_ROOT,d as MAX_CUSTOM_NODE_DATA_LENGTH,a as MAX_TAG_LENGTH,h as customNodeNamespace,m as customNodesModule,c as decodeCustomNodeTag,l as defineCustomNode,b as encodeCustomNodeTag,p as insertCustomNode,j as isCustomNodeDefinition,e as parseCustomNodeData,n as recognizeCustomNodes,q as removeCustomNode,o as reviewModule,f as serializeCustomNodeData,r as updateCustomNode}from'./chunk-NQW54J56.js';export{b as collaborationModule}from'./chunk-Q2VBO66F.js';import {customNodePayloadsByControl,readOoxmlPackage,withExportedCustomNodes,writeOoxmlPackage,isStoryPart,fnv1a32,datastoreItemIdFor,customNodeBinding,CUSTOM_XML_PROPS_TYPE,CUSTOM_XML_REL,CUSTOM_XML_PROPS_REL,DATASTORE_NAMESPACE_URI}from'@docx-editor.dev/core/store';function U(t,n$1={}){let r=L(t);if(!r)return [];let o=n$1.nodes??t.getCustomNodeDefinitions().filter(j);if(o.length===0)return [];let s=r.session.currentPackage(),d=r.session.part().name,m=n$1.onDiagnostic??(e=>{t.reportCustomNodeDiagnostic(e);});return r.session.storyParts().flatMap(e=>n(e,o,{payloads:customNodePayloadsByControl(s,e.name,d),onDiagnostic:m}))}function L(t){return t.surface??null}function E(t,n,r={}){if(r.destination==="internal")return {ok:true,bytes:t,unwrapped:0,removed:0};let o=readOoxmlPackage(t);if(!o.ok)return {ok:false,reason:`the document could not be read: ${o.reason}`};let s=new Map;for(let i of n)s.set(`${i.tagPrefix}:${i.name}`,i);let d=i=>{let p=c(i);if(!p)return "keep";let x=s.get(`${p.prefix}:${p.name}`);return x?x.preserveOnExport==="text"?"text":x.preserveOnExport===false?"remove":"keep":"keep"},m=[...new Set(n.filter(i=>i.preserveOnExport!==void 0).filter(i=>i.preserveOnExport!==true).map(h))],e=o.package,u=0,c$1=0,g=V(e);for(let i of g){let p=withExportedCustomNodes(e,{storyPartName:i,namespaces:[],decide:d});if(!p.ok)return {ok:false,reason:p.reason};e=p.pkg,u+=p.unwrapped,c$1+=p.removed;}let l=withExportedCustomNodes(e,{storyPartName:e.mainDocumentPart,namespaces:m,decide:()=>"keep"});return l.ok?(e=l.pkg,{ok:true,bytes:writeOoxmlPackage(e),unwrapped:u,removed:c$1}):{ok:false,reason:l.reason}}function V(t){let n=[];for(let[r,o]of t.parts)r!==t.mainDocumentPart&&isStoryPart(o)&&n.push(r);return [t.mainDocumentPart,...n]}async function G(t,n={}){let r=n.nodes??t.getCustomNodeDefinitions().filter(j),o=await t.save();return E(new Uint8Array(o),r,{...n.destination===void 0?{}:{destination:n.destination}})}function a(t){return t.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function K(t,n,r,o={}){if(!k.test(t.tagPrefix)||!k.test(t.name))return {ok:false,code:"invalidArgs",reason:"the definition identity must match defineCustomNode\u2019s charset ([A-Za-z0-9_.-])"};let s=b(t.tagPrefix,t.name,n);if(!s.ok)return {ok:false,code:"invalidArgs",reason:`the encoded tag is ${s.length} characters; Word caps w:tag at 64 \u2014 shorten the attrs`};let d=o.lock===void 0?"contentLocked":o.lock,m=o.id!==void 0&&Number.isInteger(o.id)&&o.id>0?o.id:fnv1a32(`${s.tag}\0${r}`)&2147483647||1,e=o.data===void 0?null:Q(t,o,r);if(e&&"reason"in e)return {ok:false,code:"invalidArgs",reason:e.reason};let u=(o.alias!==void 0?`<w:alias w:val="${a(o.alias)}"/>`:"")+`<w:tag w:val="${a(s.tag)}"/><w:id w:val="${m}"/>`+(d===false?"":`<w:lock w:val="${d}"/>`)+(e?`<w:dataBinding w:prefixMappings="${a(e.binding.prefixMappings)}" w:xpath="${a(e.binding.xpath)}" w:storeItemID="${a(e.binding.storeItemId)}"/>`:""),c=`<w:r><w:t xml:space="preserve">${a(r)}</w:t></w:r>`;return {ok:true,xml:`<w:sdt><w:sdtPr>${u}</w:sdtPr><w:sdtContent>${c}</w:sdtContent></w:sdt>`,...e?{store:e.store}:{}}}function Q(t,n,r){let o=i(t,n.data);if(!o.ok)return {reason:o.reason};let s=h(t),d=n.storeIndex!==void 0&&Number.isInteger(n.storeIndex)&&n.storeIndex>0?n.storeIndex:1,m=n.nodeId??"cx1",e=`/customXml/item${String(d)}.xml`,u=`/customXml/itemProps${String(d)}.xml`,c=datastoreItemIdFor(`${s} ${e} ${m}`),g$1=customNodeBinding({partName:e,propsPartName:u,itemId:c,namespaceUri:s},g,m);if(!g$1)return {reason:`the payload cannot be addressed by an XPath: check nodeId (${m}) and payloadNamespace`};let l=r===r.trim()?`<label>${a(r)}</label>`:`<label xml:space="preserve">${a(r)}</label>`;return {binding:g$1,store:{itemPartName:e,itemXml:`<${g} xmlns="${a(s)}"><node id="${a(m)}">${l}<data>${a(o.data)}</data></node></${g}>`,propsPartName:u,propsXml:`<ds:datastoreItem ds:itemID="${a(c)}" xmlns:ds="${DATASTORE_NAMESPACE_URI}"><ds:schemaRefs><ds:schemaRef ds:uri="${a(s)}"/></ds:schemaRefs></ds:datastoreItem>`,storeItemId:c,relationships:[{from:"/word/document.xml",type:CUSTOM_XML_REL,target:`../customXml/item${String(d)}.xml`},{from:e,type:CUSTOM_XML_PROPS_REL,target:`itemProps${String(d)}.xml`}],contentTypeOverride:{partName:u,contentType:CUSTOM_XML_PROPS_TYPE}}}}export{K as customNodeXml,U as customNodesOf,E as prepareForExport,G as saveForExport};
@@ -0,0 +1 @@
1
+ 'use strict';var chunkGDTCNTK7_cjs=require('../chunk-GDTCNTK7.cjs');require('../chunk-QLZH2Q2C.cjs');var react=require('react');var i=Symbol("useHocuspocusCollaboration.createRoom");function u(o){return o?`${o.url}:${o.roomId}:${o.bootstrap.kind}:${o.identity.actorId}`:""}async function c(o){let{createHocuspocusCollaboration:n}=await import('../collaboration/hocuspocus.cjs');return n(o)}function p(o){return o[i]??c}function d(o={}){let n=react.useId(),e=chunkGDTCNTK7_cjs.b({ownerKey:`react-hocuspocus:${n}`,hookName:"useHocuspocusCollaboration",createRoom:p(o),hostModules:o.modules??chunkGDTCNTK7_cjs.a,autoRoom:o.room??null,autoKey:u(o.room??null),rejoinOptionsOf:t=>({...t,bootstrap:{kind:"join"}}),identityOf:t=>t.identity});return react.useMemo(()=>({document:e.document,modules:e.modules,session:e.session,ydoc:e.room?.ydoc??null,provider:e.room?.provider??null,pending:e.pending,error:e.error,connect:e.connect,leave:e.leave,rejoin:e.rejoin}),[e])}exports.useHocuspocusCollaboration=d;
@@ -0,0 +1,104 @@
1
+ import * as Y from 'yjs';
2
+ import { HocuspocusProvider } from '@hocuspocus/provider';
3
+ import { CollaborationIdentity, CollaborationFailure } from '@docx-editor.dev/core/collaboration';
4
+ import { EditorModule } from '@docx-editor.dev/core/editor';
5
+ import { a as CollaborationBootstrap, C as CollaborationSession } from '../session-BH7Qgyp6.cjs';
6
+ export { b as CollaborationIdentityUpdate } from '../session-BH7Qgyp6.cjs';
7
+ import 'y-protocols/awareness';
8
+
9
+ /** Bootstrap for one Hocuspocus room. @public */
10
+ type UseHocuspocusCollaborationBootstrap = CollaborationBootstrap;
11
+ /** Arguments for {@link UseHocuspocusCollaborationReturn.connect}. @public */
12
+ interface UseHocuspocusCollaborationConnectOptions {
13
+ /** Hocuspocus server WebSocket URL, for example `wss://collab.example.test`. */
14
+ readonly url: string;
15
+ readonly roomId: string;
16
+ /**
17
+ * Authentication token the provider sends in its auth handshake. Pass a callback and the
18
+ * provider re-evaluates it on every reconnect, which is how expiring JWTs renew.
19
+ */
20
+ readonly token?: string | (() => string | Promise<string>);
21
+ readonly identity: CollaborationIdentity;
22
+ readonly bootstrap: UseHocuspocusCollaborationBootstrap;
23
+ /** Bound on the wait for the server's initial sync. Default 30000 ms. */
24
+ readonly syncedTimeoutMs?: number;
25
+ /**
26
+ * Admit local edits while the transport is `disconnected`. Buffered updates merge on
27
+ * reconnect. See {@link CreateDocumentCollaborationOptions.offlineEditing}.
28
+ */
29
+ readonly offlineEditing?: boolean;
30
+ }
31
+ /** Input for {@link useHocuspocusCollaboration}. @public */
32
+ interface UseHocuspocusCollaborationOptions {
33
+ /**
34
+ * Host modules. The hook adds `collaborationModule` when a room is ready.
35
+ * A host collaboration contribution is a configuration error and throws.
36
+ */
37
+ readonly modules?: readonly EditorModule[];
38
+ /**
39
+ * Connect this room on mount. Omit it and call
40
+ * {@link UseHocuspocusCollaborationReturn.connect} after the user chooses a room.
41
+ */
42
+ readonly room?: UseHocuspocusCollaborationConnectOptions | null;
43
+ }
44
+ /** Values {@link useHocuspocusCollaboration} returns. @public */
45
+ interface UseHocuspocusCollaborationReturn {
46
+ readonly document: Uint8Array | null;
47
+ readonly modules: readonly EditorModule[];
48
+ readonly session: CollaborationSession | null;
49
+ /**
50
+ * The room's shared Yjs document, owned by the hook. Null while no room is connected.
51
+ *
52
+ * Read-only escape hatch: observe it or wire additional providers, but leave teardown to
53
+ * the hook.
54
+ */
55
+ readonly ydoc: Y.Doc | null;
56
+ /**
57
+ * The owned `@hocuspocus/provider` instance. Null while no room is connected.
58
+ *
59
+ * Read-only escape hatch for transport-level access (`disconnect()`/`connect()`,
60
+ * server events). The hook destroys it on leave and unmount.
61
+ */
62
+ readonly provider: HocuspocusProvider | null;
63
+ readonly pending: boolean;
64
+ readonly error: CollaborationFailure | null;
65
+ /**
66
+ * Connect a room. RESOLVES with the failure, or null on success — it does not reject.
67
+ *
68
+ * A rejection carried nothing the resolved value does not, and it made the ordinary call
69
+ * site wrong by default: `onClick={() => connect(options)}` produced an unhandled rejection
70
+ * on every failed connect. `error` reports the same failure for renderers.
71
+ */
72
+ readonly connect: (options: UseHocuspocusCollaborationConnectOptions) => Promise<CollaborationFailure | null>;
73
+ /**
74
+ * Destroy the room and carry on editing locally.
75
+ *
76
+ * The current bytes live in the editor, not in this hook, so the argument is required:
77
+ * pass `await editor.save()` to keep what the room typed. The hook remounts the editor
78
+ * from exactly these bytes.
79
+ */
80
+ readonly leave: (nextDocument: Uint8Array) => void;
81
+ /**
82
+ * Recover a session that reached status `error`: leave with `nextDocument`, then connect
83
+ * again to the same room with the same identity, url, and token.
84
+ *
85
+ * The reconnect always uses bootstrap `{ kind: 'join' }`, because the server still holds
86
+ * the room. When the server no longer holds it, the join rejects with
87
+ * `initialization-timeout` — nothing is lost, because `nextDocument` (your saved bytes)
88
+ * stays mounted locally. A connect that failed also counts as the prior attempt, so
89
+ * rejoin retries it as a joiner.
90
+ */
91
+ readonly rejoin: (nextDocument: Uint8Array) => Promise<CollaborationFailure | null>;
92
+ }
93
+ /**
94
+ * Own a Hocuspocus collaboration room for a React host.
95
+ *
96
+ * The default Pro React entry does not import this hook. Import it from
97
+ * `@docx-editor.dev/pro/react/hocuspocus` so a review-only bundle does not load
98
+ * a network provider.
99
+ *
100
+ * @public
101
+ */
102
+ declare function useHocuspocusCollaboration(options?: UseHocuspocusCollaborationOptions): UseHocuspocusCollaborationReturn;
103
+
104
+ export { CollaborationSession, type UseHocuspocusCollaborationBootstrap, type UseHocuspocusCollaborationConnectOptions, type UseHocuspocusCollaborationOptions, type UseHocuspocusCollaborationReturn, useHocuspocusCollaboration };
@@ -0,0 +1,104 @@
1
+ import * as Y from 'yjs';
2
+ import { HocuspocusProvider } from '@hocuspocus/provider';
3
+ import { CollaborationIdentity, CollaborationFailure } from '@docx-editor.dev/core/collaboration';
4
+ import { EditorModule } from '@docx-editor.dev/core/editor';
5
+ import { a as CollaborationBootstrap, C as CollaborationSession } from '../session-BH7Qgyp6.js';
6
+ export { b as CollaborationIdentityUpdate } from '../session-BH7Qgyp6.js';
7
+ import 'y-protocols/awareness';
8
+
9
+ /** Bootstrap for one Hocuspocus room. @public */
10
+ type UseHocuspocusCollaborationBootstrap = CollaborationBootstrap;
11
+ /** Arguments for {@link UseHocuspocusCollaborationReturn.connect}. @public */
12
+ interface UseHocuspocusCollaborationConnectOptions {
13
+ /** Hocuspocus server WebSocket URL, for example `wss://collab.example.test`. */
14
+ readonly url: string;
15
+ readonly roomId: string;
16
+ /**
17
+ * Authentication token the provider sends in its auth handshake. Pass a callback and the
18
+ * provider re-evaluates it on every reconnect, which is how expiring JWTs renew.
19
+ */
20
+ readonly token?: string | (() => string | Promise<string>);
21
+ readonly identity: CollaborationIdentity;
22
+ readonly bootstrap: UseHocuspocusCollaborationBootstrap;
23
+ /** Bound on the wait for the server's initial sync. Default 30000 ms. */
24
+ readonly syncedTimeoutMs?: number;
25
+ /**
26
+ * Admit local edits while the transport is `disconnected`. Buffered updates merge on
27
+ * reconnect. See {@link CreateDocumentCollaborationOptions.offlineEditing}.
28
+ */
29
+ readonly offlineEditing?: boolean;
30
+ }
31
+ /** Input for {@link useHocuspocusCollaboration}. @public */
32
+ interface UseHocuspocusCollaborationOptions {
33
+ /**
34
+ * Host modules. The hook adds `collaborationModule` when a room is ready.
35
+ * A host collaboration contribution is a configuration error and throws.
36
+ */
37
+ readonly modules?: readonly EditorModule[];
38
+ /**
39
+ * Connect this room on mount. Omit it and call
40
+ * {@link UseHocuspocusCollaborationReturn.connect} after the user chooses a room.
41
+ */
42
+ readonly room?: UseHocuspocusCollaborationConnectOptions | null;
43
+ }
44
+ /** Values {@link useHocuspocusCollaboration} returns. @public */
45
+ interface UseHocuspocusCollaborationReturn {
46
+ readonly document: Uint8Array | null;
47
+ readonly modules: readonly EditorModule[];
48
+ readonly session: CollaborationSession | null;
49
+ /**
50
+ * The room's shared Yjs document, owned by the hook. Null while no room is connected.
51
+ *
52
+ * Read-only escape hatch: observe it or wire additional providers, but leave teardown to
53
+ * the hook.
54
+ */
55
+ readonly ydoc: Y.Doc | null;
56
+ /**
57
+ * The owned `@hocuspocus/provider` instance. Null while no room is connected.
58
+ *
59
+ * Read-only escape hatch for transport-level access (`disconnect()`/`connect()`,
60
+ * server events). The hook destroys it on leave and unmount.
61
+ */
62
+ readonly provider: HocuspocusProvider | null;
63
+ readonly pending: boolean;
64
+ readonly error: CollaborationFailure | null;
65
+ /**
66
+ * Connect a room. RESOLVES with the failure, or null on success — it does not reject.
67
+ *
68
+ * A rejection carried nothing the resolved value does not, and it made the ordinary call
69
+ * site wrong by default: `onClick={() => connect(options)}` produced an unhandled rejection
70
+ * on every failed connect. `error` reports the same failure for renderers.
71
+ */
72
+ readonly connect: (options: UseHocuspocusCollaborationConnectOptions) => Promise<CollaborationFailure | null>;
73
+ /**
74
+ * Destroy the room and carry on editing locally.
75
+ *
76
+ * The current bytes live in the editor, not in this hook, so the argument is required:
77
+ * pass `await editor.save()` to keep what the room typed. The hook remounts the editor
78
+ * from exactly these bytes.
79
+ */
80
+ readonly leave: (nextDocument: Uint8Array) => void;
81
+ /**
82
+ * Recover a session that reached status `error`: leave with `nextDocument`, then connect
83
+ * again to the same room with the same identity, url, and token.
84
+ *
85
+ * The reconnect always uses bootstrap `{ kind: 'join' }`, because the server still holds
86
+ * the room. When the server no longer holds it, the join rejects with
87
+ * `initialization-timeout` — nothing is lost, because `nextDocument` (your saved bytes)
88
+ * stays mounted locally. A connect that failed also counts as the prior attempt, so
89
+ * rejoin retries it as a joiner.
90
+ */
91
+ readonly rejoin: (nextDocument: Uint8Array) => Promise<CollaborationFailure | null>;
92
+ }
93
+ /**
94
+ * Own a Hocuspocus collaboration room for a React host.
95
+ *
96
+ * The default Pro React entry does not import this hook. Import it from
97
+ * `@docx-editor.dev/pro/react/hocuspocus` so a review-only bundle does not load
98
+ * a network provider.
99
+ *
100
+ * @public
101
+ */
102
+ declare function useHocuspocusCollaboration(options?: UseHocuspocusCollaborationOptions): UseHocuspocusCollaborationReturn;
103
+
104
+ export { CollaborationSession, type UseHocuspocusCollaborationBootstrap, type UseHocuspocusCollaborationConnectOptions, type UseHocuspocusCollaborationOptions, type UseHocuspocusCollaborationReturn, useHocuspocusCollaboration };
@@ -0,0 +1 @@
1
+ import {b,a}from'../chunk-HJB77VBO.js';import'../chunk-Q2VBO66F.js';import {useId,useMemo}from'react';var i=Symbol("useHocuspocusCollaboration.createRoom");function u(o){return o?`${o.url}:${o.roomId}:${o.bootstrap.kind}:${o.identity.actorId}`:""}async function c(o){let{createHocuspocusCollaboration:n}=await import('../collaboration/hocuspocus.js');return n(o)}function p(o){return o[i]??c}function d(o={}){let n=useId(),e=b({ownerKey:`react-hocuspocus:${n}`,hookName:"useHocuspocusCollaboration",createRoom:p(o),hostModules:o.modules??a,autoRoom:o.room??null,autoKey:u(o.room??null),rejoinOptionsOf:t=>({...t,bootstrap:{kind:"join"}}),identityOf:t=>t.identity});return useMemo(()=>({document:e.document,modules:e.modules,session:e.session,ydoc:e.room?.ydoc??null,provider:e.room?.provider??null,pending:e.pending,error:e.error,connect:e.connect,leave:e.leave,rejoin:e.rejoin}),[e])}export{d as useHocuspocusCollaboration};