@fileverse-dev/ddoc 4.2.4 → 4.3.1-mv-yjs-1

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 (32) hide show
  1. package/dist/{index-DPuANynY.mjs → index-Bghx3ull.mjs} +28368 -33551
  2. package/dist/{index-BHEcRC2F.mjs → index-BwmvbHh1.mjs} +1 -1
  3. package/dist/index.d.ts +2 -0
  4. package/dist/index.es.js +13 -9
  5. package/dist/{markdown-source-pane-BDPSou1J.mjs → markdown-source-pane-CUGwYz0i.mjs} +2 -2
  6. package/dist/package/components/editor-bubble-menu/types.d.ts +1 -1
  7. package/dist/package/components/inline-comment/comment-drawer-desktop.d.ts +1 -2
  8. package/dist/package/components/inline-comment/comment-drawer-mobile.d.ts +1 -2
  9. package/dist/package/components/inline-comment/comment-drawer.d.ts +1 -1
  10. package/dist/package/components/inline-comment/comment-input-field.d.ts +1 -2
  11. package/dist/package/components/inline-comment/comment-reply-input.d.ts +1 -2
  12. package/dist/package/components/inline-comment/comment-section.d.ts +1 -1
  13. package/dist/package/components/inline-comment/floating-comment/comment-floating-container.d.ts +1 -1
  14. package/dist/package/components/inline-comment/floating-comment/suggestion-thread-floating-card.d.ts +1 -1
  15. package/dist/package/components/inline-comment/floating-comment/thread-floating-card.d.ts +1 -1
  16. package/dist/package/components/inline-comment/floating-comment/types.d.ts +0 -2
  17. package/dist/package/components/inline-comment/types.d.ts +0 -2
  18. package/dist/package/hooks/use-tab-editor.d.ts +3 -3
  19. package/dist/package/hooks/use-yjs-setup.d.ts +7 -1
  20. package/dist/package/sync-local/SyncManager.d.ts +44 -7
  21. package/dist/package/sync-local/crypto/room-key.d.ts +2 -0
  22. package/dist/package/sync-local/floor.d.ts +8 -0
  23. package/dist/package/sync-local/presence.d.ts +11 -0
  24. package/dist/package/sync-local/session-tools.d.ts +31 -0
  25. package/dist/package/sync-local/socketClient.d.ts +74 -8
  26. package/dist/package/sync-local/types/index.d.ts +105 -12
  27. package/dist/package/sync-local/useSyncManager.d.ts +4 -0
  28. package/dist/package/types.d.ts +2 -1
  29. package/dist/package/use-ddoc-editor.d.ts +5 -0
  30. package/dist/{split-view-toolbar-BXnE-1Ad.mjs → split-view-toolbar-DCkttBMO.mjs} +2 -2
  31. package/dist/style.css +1 -1
  32. package/package.json +6 -6
@@ -7,6 +7,60 @@ export interface CollabConnectionConfig {
7
7
  roomId: string;
8
8
  wsUrl: string;
9
9
  isOwner: boolean;
10
+ /** Host signal: doc is in an active live-collaboration context (shared / peers present). Keeps the socket connected. */
11
+ livePresence?: boolean;
12
+ /** Host signal: connect once on open to initialise durability even without an edit. */
13
+ connectOnOpen?: boolean;
14
+ /** Host signal (owner-only): wrapped roomKey bytes (owner-lock construction), uploaded as the server editLock recovery artifact. Opaque to the package. */
15
+ editLock?: string;
16
+ /** Host signal (owner-only): the document title encrypted with the roomKey, uploaded as the server title recovery artifact. Opaque to the package. */
17
+ encryptedTitle?: string;
18
+ /** Host signal (owner-only): Ed25519 UCAN proving the owner identity, sent on /auth so the server binds the CRYPTOGRAPHICALLY PROVEN owner DID (not a bare asserted string). Opaque to the package. */
19
+ identityToken?: string;
20
+ /** Host signal (non-owner editor): the gate-minted edit-admission UCAN, forwarded on /auth so the
21
+ * server admits this connection as a GP-rail editor. Opaque to the package. */
22
+ editUcan?: string;
23
+ /** Host signal (non-owner editor): re-mints a CURRENT-epoch editUcan. Called at every /auth
24
+ * (incl. reconnect after a force-drop). Tri-state: `ok` (fresh token; overrides the static
25
+ * `editUcan`), `demoted` (no longer an editor → terminal, drop to viewer), or `unavailable`
26
+ * (transient/network → retry on the last-good claim). Opaque to the package. */
27
+ refreshEditClaim?: () => Promise<{
28
+ status: 'ok';
29
+ token: string;
30
+ } | {
31
+ status: 'demoted';
32
+ } | {
33
+ status: 'unavailable';
34
+ }>;
35
+ /** Host signal: resolves the rotated roomKey for the given epoch payload (GP: gate release
36
+ * unwrap of `gp`; workspace: app-key unwrap of `appLock`). Returns the new base64 roomKey —
37
+ * or, for a gate-admitted editor, `{ roomKey, editUcan }`: the same gate release that unwraps
38
+ * the relay also mints the new-epoch editUcan, and the cutover re-auth must present THAT token
39
+ * (a re-mint through the host's fresh-open flow can race the deferred publish and hand back a
40
+ * stale-epoch claim). `null` if this actor can't resolve it (falls back to the decrypt-miss
41
+ * self-heal path). Opaque to the package. */
42
+ onRotationPrepare?: (inner: {
43
+ epoch: number;
44
+ gp: string;
45
+ appLock?: string;
46
+ }) => Promise<string | {
47
+ roomKey: string;
48
+ editUcan?: string;
49
+ } | null>;
50
+ /** Host signal: an anonymous per-connection actor handle (public rail). Record-only; opaque. */
51
+ actorHandle?: string;
52
+ /** Host signal (non-creator workspace member): join-only. The server never creates or
53
+ * binds a session for this connection and caps the role at editor; every handshake
54
+ * rejection resolves to a quiet terminated state ('ROOM_NOT_ESTABLISHED' when the room
55
+ * was never established, 'JOIN_REJECTED' otherwise) instead of an error. */
56
+ joinOnly?: boolean;
57
+ /** Host signal (editor): produces the view-plane mirror ciphertext from the live Yjs state. The app
58
+ * AES-GCM-encrypts `{ file: base64(yjsUpdate), source }` under the fileKey in the publish wire
59
+ * format. Absent ⇒ the mirror is not written. The package never sees the fileKey or the crypto. */
60
+ encryptMirror?: (yjsUpdate: Uint8Array) => Promise<string>;
61
+ /** Host signal: the fileKey's rotation epoch (the gate `currentEpoch` / fileKey version — NOT
62
+ * `editGrantEpoch`; default 0 for non-rotating plain-public docs). */
63
+ fileKeyEpoch?: number;
10
64
  ownerEdSecret?: string;
11
65
  contractAddress?: string;
12
66
  ownerAddress?: string;
@@ -21,18 +75,14 @@ export interface CollabSessionMeta {
21
75
  username: string;
22
76
  isEns?: boolean;
23
77
  }
24
- /** Storage integrations the sync engine depends on */
25
- export interface CollabServices {
26
- commitToStorage?: (file: File) => Promise<string>;
27
- fetchFromStorage?: (cid: string) => Promise<any>;
28
- }
78
+ export type CollabServices = Record<string, never>;
29
79
  export type CollabErrorCode = 'CONNECTION_FAILED' | 'AUTH_FAILED' | 'SYNC_FAILED' | 'TIMEOUT' | 'UNKNOWN';
30
80
  export type CollabError = {
31
81
  code: CollabErrorCode;
32
82
  message: string;
33
83
  recoverable: boolean;
34
84
  };
35
- export type CollabStatus = 'idle' | 'connecting' | 'syncing' | 'ready' | 'reconnecting' | 'error' | 'terminated';
85
+ export type CollabStatus = 'idle' | 'connecting' | 'syncing' | 'ready' | 'reconnecting' | 'rotating' | 'error' | 'terminated';
36
86
  export type CollabState = {
37
87
  status: 'idle';
38
88
  } | {
@@ -46,6 +96,10 @@ export type CollabState = {
46
96
  status: 'reconnecting';
47
97
  attempt: number;
48
98
  maxAttempts: number;
99
+ }
100
+ /** roomKey migration in flight — distinct from `terminated` so consumers don't mistake it for a kick. */
101
+ | {
102
+ status: 'rotating';
49
103
  } | {
50
104
  status: 'error';
51
105
  error: CollabError;
@@ -74,6 +128,10 @@ export type CollabEvent = {
74
128
  } | {
75
129
  type: 'SESSION_TERMINATED';
76
130
  reason?: string;
131
+ }
132
+ /** roomKey cutover in progress; no-op on status — lets the manager gate re-entrancy itself. */
133
+ | {
134
+ type: 'CUTOVER';
77
135
  } | {
78
136
  type: 'RESET';
79
137
  };
@@ -93,6 +151,13 @@ export interface CollabCallbacks {
93
151
  data: AckResponse;
94
152
  roomKey: string;
95
153
  }) => void;
154
+ /** Live rename from the room owner; title is roomKey-encrypted. */
155
+ onTitleUpdate?: (encryptedTitle: string | null) => void;
156
+ /** Decrypt-miss self-heal: resolves the CURRENT-epoch roomKey (same resolution the host
157
+ * uses for `onRotationPrepare`, minus the relay payload — re-read the blob's
158
+ * `wrappedRoomKey` / appLock). Returns the new base64 roomKey, or `null` if this actor
159
+ * can't resolve one (the miss is then a real revocation, not a rotation lag). */
160
+ onRotationSelfHeal?: () => Promise<string | null>;
96
161
  }
97
162
  /** Discriminated union — TypeScript enforces config+services only when enabled */
98
163
  export type CollaborationProps = {
@@ -127,7 +192,10 @@ export declare enum ServerErrorCode {
127
192
  INVALID_ADDRESS = "INVALID_ADDRESS",
128
193
  NOT_AUTHENTICATED = "NOT_AUTHENTICATED",
129
194
  DB_ERROR = "DB_ERROR",
130
- INTERNAL_ERROR = "INTERNAL_ERROR"
195
+ INTERNAL_ERROR = "INTERNAL_ERROR",
196
+ JOIN_DISABLED = "JOIN_DISABLED",
197
+ EDIT_REVOKED = "EDIT_REVOKED",
198
+ ROOM_NOT_ESTABLISHED = "ROOM_NOT_ESTABLISHED"
131
199
  }
132
200
  export interface AckResponse<T = Record<string, any>> {
133
201
  status: boolean;
@@ -145,11 +213,30 @@ export interface SendUpdateResponse extends AckResponse<{
145
213
  createdAt: number;
146
214
  }> {
147
215
  }
148
- export interface CommitResponse extends AckResponse<{
149
- cid: string;
150
- createdAt: number;
216
+ export interface HydrationRow {
217
+ id: string;
151
218
  documentId: string;
152
- updates: string[];
219
+ seq: number;
220
+ data: string;
221
+ updateType: string;
222
+ committed?: boolean;
223
+ commitCid?: string | null;
224
+ createdAt?: number;
225
+ sessionDid?: string;
226
+ publishedMarker?: string | null;
227
+ floorSeq?: number | null;
228
+ }
229
+ export interface HydrationResponse extends AckResponse<{
230
+ history: HydrationRow[];
231
+ total: number;
232
+ snapshot: HydrationRow | null;
233
+ nextSeq: number | null;
234
+ hasMore: boolean;
235
+ }> {
236
+ }
237
+ export interface SnapshotResponse extends AckResponse<{
238
+ id: string;
239
+ seq: number;
153
240
  }> {
154
241
  }
155
242
  export interface ISocketInitConfig {
@@ -157,7 +244,7 @@ export interface ISocketInitConfig {
157
244
  onDisconnect: () => void;
158
245
  onSocketDropped: () => void;
159
246
  onError: (err: Error) => void;
160
- onHandShakeError: (err: Error, statusCode?: number) => void;
247
+ onHandShakeError: (err: Error, statusCode?: number, errorCode?: ServerErrorCode) => void;
161
248
  onContentUpdate: (data: {
162
249
  id: string;
163
250
  data: string;
@@ -171,6 +258,8 @@ export interface ISocketInitConfig {
171
258
  };
172
259
  roomId: string;
173
260
  }) => void;
261
+ onPresenceChange?: (collaborators: IDocCollabUsers[]) => void;
262
+ onTitleUpdate?: (encryptedTitle: string | null) => void;
174
263
  onSessionTerminated: (data: {
175
264
  roomId: string;
176
265
  }) => void;
@@ -196,4 +285,8 @@ export interface IAuthArgs {
196
285
  contractAddress?: string;
197
286
  sessionDid?: string;
198
287
  roomInfo?: string;
288
+ identityToken?: string;
289
+ editUcan?: string;
290
+ actorHandle?: string;
291
+ joinOnly?: boolean;
199
292
  }
@@ -5,6 +5,10 @@ export declare const useSyncManager: (config: SyncManagerConfig) => {
5
5
  connect: (connectConfig: CollabConnectionConfig) => void;
6
6
  disconnect: () => void;
7
7
  terminateSession: () => void;
8
+ updateTitle: (args: {
9
+ encryptedTitle: string;
10
+ documentTitle: string;
11
+ }) => void;
8
12
  isReady: boolean;
9
13
  isSyncing: boolean;
10
14
  awareness: import('y-protocols/awareness.js').Awareness | null;
@@ -9,10 +9,11 @@ import { CollaborationProps } from './sync-local/types';
9
9
  export type { CollaborationProps, CollabConnectionConfig, CollabSessionMeta, CollabServices, CollabCallbacks, CollabState, CollabError, CollabErrorCode, CollabStatus, } from './sync-local/types';
10
10
  export declare const DdocEditorProps: EditorProps;
11
11
  export interface IDocCollabUsers {
12
- clientId: number;
12
+ clientId: string | number;
13
13
  name: string;
14
14
  isEns: string;
15
15
  color: string;
16
+ isPlaceholder?: boolean;
16
17
  }
17
18
  export type InlineCommentData = {
18
19
  inlineCommentText: string;
@@ -28,8 +28,13 @@ export declare const useDdocEditor: ({ isPreviewMode, viewerMode, initialContent
28
28
  duplicateTab: (tabId: string) => string | undefined;
29
29
  orderTab: (destinationTabId: string, movedTabId: string) => void;
30
30
  onConnect: (connectConfig: import('./types').CollabConnectionConfig) => void;
31
+ onDisconnect: () => void;
31
32
  isReady: boolean;
32
33
  isSyncing: boolean;
34
+ updateTitle: (args: {
35
+ encryptedTitle: string;
36
+ documentTitle: string;
37
+ }) => void;
33
38
  hasCollabContentInitialised: boolean;
34
39
  isIndexeddbSynced: boolean;
35
40
  initialiseYjsIndexedDbProvider: () => Promise<void>;
@@ -1,7 +1,7 @@
1
- import { j as d } from "./index-DPuANynY.mjs";
1
+ import { j as d } from "./index-Bghx3ull.mjs";
2
2
  import { useRef as I, useState as N, useEffect as D } from "react";
3
3
  import { DynamicDropdown as E, Tooltip as R, IconButton as O } from "@fileverse/ui";
4
- import { a3 as A, a4 as P, c as y } from "./index-BHEcRC2F.mjs";
4
+ import { a3 as A, a4 as P, c as y } from "./index-BwmvbHh1.mjs";
5
5
  const p = (e, t, o = t) => {
6
6
  const { state: s } = e, l = s.changeByRange((n) => {
7
7
  const u = s.sliceDoc(n.from, n.to), r = s.sliceDoc(