@hocuspocus/provider 3.4.3 → 3.4.5-rc.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 (146) hide show
  1. package/dist/hocuspocus-provider.cjs +1836 -2083
  2. package/dist/hocuspocus-provider.cjs.map +1 -1
  3. package/dist/hocuspocus-provider.esm.js +1803 -2060
  4. package/dist/hocuspocus-provider.esm.js.map +1 -1
  5. package/dist/index.d.ts +558 -0
  6. package/dist/index.js +1940 -0
  7. package/package.json +4 -4
  8. package/src/HocuspocusProvider.ts +16 -9
  9. package/src/HocuspocusProviderWebsocket.ts +16 -4
  10. package/src/MessageReceiver.ts +2 -2
  11. package/src/types.ts +3 -1
  12. package/dist/node_modules/@tiptap/pm/model/index.d.ts +0 -1
  13. package/dist/node_modules/@tiptap/pm/state/index.d.ts +0 -1
  14. package/dist/node_modules/@tiptap/pm/transform/index.d.ts +0 -1
  15. package/dist/node_modules/@tiptap/pm/view/index.d.ts +0 -1
  16. package/dist/packages/common/src/CloseEvents.d.ts +0 -29
  17. package/dist/packages/common/src/auth.d.ts +0 -12
  18. package/dist/packages/common/src/awarenessStatesToArray.d.ts +0 -3
  19. package/dist/packages/common/src/index.d.ts +0 -4
  20. package/dist/packages/common/src/types.d.ts +0 -10
  21. package/dist/packages/extension-database/src/Database.d.ts +0 -30
  22. package/dist/packages/extension-database/src/index.d.ts +0 -1
  23. package/dist/packages/extension-logger/src/Logger.d.ts +0 -67
  24. package/dist/packages/extension-logger/src/index.d.ts +0 -1
  25. package/dist/packages/extension-redis/src/Redis.d.ts +0 -124
  26. package/dist/packages/extension-redis/src/index.d.ts +0 -1
  27. package/dist/packages/extension-s3/src/S3.d.ts +0 -44
  28. package/dist/packages/extension-s3/src/index.d.ts +0 -1
  29. package/dist/packages/extension-sqlite/src/SQLite.d.ts +0 -27
  30. package/dist/packages/extension-sqlite/src/index.d.ts +0 -1
  31. package/dist/packages/extension-throttle/src/index.d.ts +0 -30
  32. package/dist/packages/extension-webhook/src/index.d.ts +0 -56
  33. package/dist/packages/provider/src/EventEmitter.d.ts +0 -9
  34. package/dist/packages/provider/src/HocuspocusProvider.d.ts +0 -116
  35. package/dist/packages/provider/src/HocuspocusProviderWebsocket.d.ts +0 -114
  36. package/dist/packages/provider/src/IncomingMessage.d.ts +0 -17
  37. package/dist/packages/provider/src/MessageReceiver.d.ts +0 -12
  38. package/dist/packages/provider/src/MessageSender.d.ts +0 -9
  39. package/dist/packages/provider/src/OutgoingMessage.d.ts +0 -9
  40. package/dist/packages/provider/src/OutgoingMessages/AuthenticationMessage.d.ts +0 -8
  41. package/dist/packages/provider/src/OutgoingMessages/AwarenessMessage.d.ts +0 -9
  42. package/dist/packages/provider/src/OutgoingMessages/CloseMessage.d.ts +0 -9
  43. package/dist/packages/provider/src/OutgoingMessages/QueryAwarenessMessage.d.ts +0 -9
  44. package/dist/packages/provider/src/OutgoingMessages/StatelessMessage.d.ts +0 -8
  45. package/dist/packages/provider/src/OutgoingMessages/SyncStepOneMessage.d.ts +0 -9
  46. package/dist/packages/provider/src/OutgoingMessages/SyncStepTwoMessage.d.ts +0 -9
  47. package/dist/packages/provider/src/OutgoingMessages/UpdateMessage.d.ts +0 -8
  48. package/dist/packages/provider/src/index.d.ts +0 -3
  49. package/dist/packages/provider/src/types.d.ts +0 -92
  50. package/dist/packages/server/src/ClientConnection.d.ts +0 -63
  51. package/dist/packages/server/src/Connection.d.ts +0 -71
  52. package/dist/packages/server/src/DirectConnection.d.ts +0 -14
  53. package/dist/packages/server/src/Document.d.ts +0 -92
  54. package/dist/packages/server/src/Hocuspocus.d.ts +0 -80
  55. package/dist/packages/server/src/IncomingMessage.d.ts +0 -25
  56. package/dist/packages/server/src/MessageReceiver.d.ts +0 -11
  57. package/dist/packages/server/src/OutgoingMessage.d.ts +0 -23
  58. package/dist/packages/server/src/Server.d.ts +0 -32
  59. package/dist/packages/server/src/index.d.ts +0 -9
  60. package/dist/packages/server/src/types.d.ts +0 -342
  61. package/dist/packages/server/src/util/debounce.d.ts +0 -6
  62. package/dist/packages/server/src/util/getParameters.d.ts +0 -6
  63. package/dist/packages/transformer/src/Prosemirror.d.ts +0 -11
  64. package/dist/packages/transformer/src/Tiptap.d.ts +0 -10
  65. package/dist/packages/transformer/src/index.d.ts +0 -3
  66. package/dist/packages/transformer/src/types.d.ts +0 -5
  67. package/dist/playground/backend/src/default.d.ts +0 -1
  68. package/dist/playground/backend/src/deno.d.ts +0 -1
  69. package/dist/playground/backend/src/express.d.ts +0 -1
  70. package/dist/playground/backend/src/hono.d.ts +0 -1
  71. package/dist/playground/backend/src/koa.d.ts +0 -1
  72. package/dist/playground/backend/src/load-document.d.ts +0 -1
  73. package/dist/playground/backend/src/redis.d.ts +0 -1
  74. package/dist/playground/backend/src/s3-redis.d.ts +0 -1
  75. package/dist/playground/backend/src/s3.d.ts +0 -1
  76. package/dist/playground/backend/src/slow.d.ts +0 -1
  77. package/dist/playground/backend/src/tiptapcollab.d.ts +0 -1
  78. package/dist/playground/backend/src/webhook.d.ts +0 -1
  79. package/dist/playground/frontend/app/SocketContext1.d.ts +0 -2
  80. package/dist/playground/frontend/app/SocketContext2.d.ts +0 -2
  81. package/dist/playground/frontend/next.config.d.ts +0 -3
  82. package/dist/tests/extension-database/fetch.d.ts +0 -1
  83. package/dist/tests/extension-logger/onListen.d.ts +0 -1
  84. package/dist/tests/extension-redis/onAwarenessChange.d.ts +0 -1
  85. package/dist/tests/extension-redis/onChange.d.ts +0 -1
  86. package/dist/tests/extension-redis/onStateless.d.ts +0 -1
  87. package/dist/tests/extension-redis/onStoreDocument.d.ts +0 -1
  88. package/dist/tests/extension-s3/fetch.d.ts +0 -1
  89. package/dist/tests/extension-throttle/banning.d.ts +0 -1
  90. package/dist/tests/extension-throttle/configuration.d.ts +0 -1
  91. package/dist/tests/provider/hasUnsyncedChanges.d.ts +0 -1
  92. package/dist/tests/provider/observe.d.ts +0 -1
  93. package/dist/tests/provider/observeDeep.d.ts +0 -1
  94. package/dist/tests/provider/onAuthenticated.d.ts +0 -1
  95. package/dist/tests/provider/onAuthenticationFailed.d.ts +0 -1
  96. package/dist/tests/provider/onAwarenessChange.d.ts +0 -1
  97. package/dist/tests/provider/onAwarenessUpdate.d.ts +0 -1
  98. package/dist/tests/provider/onClose.d.ts +0 -1
  99. package/dist/tests/provider/onConnect.d.ts +0 -1
  100. package/dist/tests/provider/onDisconnect.d.ts +0 -1
  101. package/dist/tests/provider/onMessage.d.ts +0 -1
  102. package/dist/tests/provider/onOpen.d.ts +0 -1
  103. package/dist/tests/provider/onStateless.d.ts +0 -1
  104. package/dist/tests/provider/onSynced.d.ts +0 -1
  105. package/dist/tests/providerwebsocket/configuration.d.ts +0 -1
  106. package/dist/tests/server/address.d.ts +0 -1
  107. package/dist/tests/server/afterLoadDocument.d.ts +0 -1
  108. package/dist/tests/server/afterStoreDocument.d.ts +0 -1
  109. package/dist/tests/server/afterUnloadDocument.d.ts +0 -1
  110. package/dist/tests/server/beforeBroadcastStateless.d.ts +0 -1
  111. package/dist/tests/server/beforeHandleMessage.d.ts +0 -1
  112. package/dist/tests/server/beforeSync.d.ts +0 -1
  113. package/dist/tests/server/beforeUnloadDocument.d.ts +0 -1
  114. package/dist/tests/server/closeConnections.d.ts +0 -1
  115. package/dist/tests/server/getConnectionsCount.d.ts +0 -1
  116. package/dist/tests/server/getDocumentsCount.d.ts +0 -1
  117. package/dist/tests/server/listen.d.ts +0 -1
  118. package/dist/tests/server/onAuthenticate.d.ts +0 -1
  119. package/dist/tests/server/onAwarenessUpdate.d.ts +0 -1
  120. package/dist/tests/server/onChange.d.ts +0 -1
  121. package/dist/tests/server/onClose.d.ts +0 -1
  122. package/dist/tests/server/onConfigure.d.ts +0 -1
  123. package/dist/tests/server/onConnect.d.ts +0 -1
  124. package/dist/tests/server/onDestroy.d.ts +0 -1
  125. package/dist/tests/server/onDisconnect.d.ts +0 -1
  126. package/dist/tests/server/onListen.d.ts +0 -1
  127. package/dist/tests/server/onLoadDocument.d.ts +0 -1
  128. package/dist/tests/server/onRequest.d.ts +0 -1
  129. package/dist/tests/server/onStateless.d.ts +0 -1
  130. package/dist/tests/server/onStoreDocument.d.ts +0 -1
  131. package/dist/tests/server/onTokenSync.d.ts +0 -1
  132. package/dist/tests/server/onUpgrade.d.ts +0 -1
  133. package/dist/tests/server/openDirectConnection.d.ts +0 -1
  134. package/dist/tests/server/websocketError.d.ts +0 -1
  135. package/dist/tests/transformer/TiptapTransformer.d.ts +0 -1
  136. package/dist/tests/utils/createDirectory.d.ts +0 -1
  137. package/dist/tests/utils/flushRedis.d.ts +0 -1
  138. package/dist/tests/utils/index.d.ts +0 -9
  139. package/dist/tests/utils/newHocuspocus.d.ts +0 -2
  140. package/dist/tests/utils/newHocuspocusProvider.d.ts +0 -3
  141. package/dist/tests/utils/newHocuspocusProviderWebsocket.d.ts +0 -4
  142. package/dist/tests/utils/randomInteger.d.ts +0 -1
  143. package/dist/tests/utils/redisConnectionSettings.d.ts +0 -4
  144. package/dist/tests/utils/removeDirectory.d.ts +0 -1
  145. package/dist/tests/utils/retryableAssertion.d.ts +0 -2
  146. package/dist/tests/utils/sleep.d.ts +0 -1
@@ -1,92 +0,0 @@
1
- import { Mutex } from "async-mutex";
2
- import type WebSocket from "ws";
3
- import { Awareness } from "y-protocols/awareness";
4
- import { Doc } from "yjs";
5
- import type Connection from "./Connection.ts";
6
- export declare class Document extends Doc {
7
- awareness: Awareness;
8
- callbacks: {
9
- onUpdate: (document: Document, connection: Connection, update: Uint8Array) => void;
10
- beforeBroadcastStateless: (document: Document, stateless: string) => void;
11
- };
12
- connections: Map<WebSocket, {
13
- clients: Set<any>;
14
- connection: Connection;
15
- }>;
16
- directConnectionsCount: number;
17
- name: string;
18
- isLoading: boolean;
19
- isDestroyed: boolean;
20
- saveMutex: Mutex;
21
- lastChangeTime: number;
22
- /**
23
- * Constructor.
24
- */
25
- constructor(name: string, yDocOptions?: object);
26
- /**
27
- * Check if the Document (XMLFragment or Map) is empty
28
- */
29
- isEmpty(fieldName: string): boolean;
30
- /**
31
- * Merge the given document(s) into this one
32
- */
33
- merge(documents: Doc | Array<Doc>): Document;
34
- /**
35
- * Set a callback that will be triggered when the document is updated
36
- */
37
- onUpdate(callback: (document: Document, connection: Connection, update: Uint8Array) => void): Document;
38
- /**
39
- * Set a callback that will be triggered before a stateless message is broadcasted
40
- */
41
- beforeBroadcastStateless(callback: (document: Document, stateless: string) => void): Document;
42
- /**
43
- * Register a connection and a set of clients on this document keyed by the
44
- * underlying websocket connection
45
- */
46
- addConnection(connection: Connection): Document;
47
- /**
48
- * Is the given connection registered on this document
49
- */
50
- hasConnection(connection: Connection): boolean;
51
- /**
52
- * Remove the given connection from this document
53
- */
54
- removeConnection(connection: Connection): Document;
55
- addDirectConnection(): Document;
56
- removeDirectConnection(): Document;
57
- /**
58
- * Get the number of active connections for this document
59
- */
60
- getConnectionsCount(): number;
61
- /**
62
- * Get an array of registered connections
63
- */
64
- getConnections(): Array<Connection>;
65
- /**
66
- * Get the client ids for the given connection instance
67
- */
68
- getClients(connectionInstance: WebSocket): Set<any>;
69
- /**
70
- * Has the document awareness states
71
- */
72
- hasAwarenessStates(): boolean;
73
- /**
74
- * Apply the given awareness update
75
- */
76
- applyAwarenessUpdate(connection: Connection, update: Uint8Array): Document;
77
- /**
78
- * Handle an awareness update and sync changes to clients
79
- * @private
80
- */
81
- private handleAwarenessUpdate;
82
- /**
83
- * Handle an updated document and sync changes to clients
84
- */
85
- private handleUpdate;
86
- /**
87
- * Broadcast stateless message to all connections
88
- */
89
- broadcastStateless(payload: string, filter?: (conn: Connection) => boolean): void;
90
- destroy(): void;
91
- }
92
- export default Document;
@@ -1,80 +0,0 @@
1
- import type { IncomingMessage } from "node:http";
2
- import type WebSocket from "ws";
3
- import { DirectConnection } from "./DirectConnection.ts";
4
- import Document from "./Document.ts";
5
- import type { Server } from "./Server.ts";
6
- import type { Configuration, ConnectionConfiguration, HookName, HookPayloadByName, onStoreDocumentPayload } from "./types.ts";
7
- export declare const defaultConfiguration: {
8
- name: null;
9
- timeout: number;
10
- debounce: number;
11
- maxDebounce: number;
12
- quiet: boolean;
13
- yDocOptions: {
14
- gc: boolean;
15
- gcFilter: () => boolean;
16
- };
17
- unloadImmediately: boolean;
18
- };
19
- export declare class Hocuspocus {
20
- configuration: Configuration;
21
- loadingDocuments: Map<string, Promise<Document>>;
22
- unloadingDocuments: Map<string, Promise<void>>;
23
- documents: Map<string, Document>;
24
- server?: Server;
25
- debouncer: {
26
- debounce: (id: string, func: () => any | Promise<() => any>, debounce: number, maxDebounce: number) => Promise<any>;
27
- isDebounced: (id: string) => boolean;
28
- isCurrentlyExecuting: (id: string) => boolean;
29
- executeNow: (id: string) => any;
30
- };
31
- constructor(configuration?: Partial<Configuration>);
32
- /**
33
- * Configure Hocuspocus
34
- */
35
- configure(configuration: Partial<Configuration>): Hocuspocus;
36
- /**
37
- * Get the total number of active documents
38
- */
39
- getDocumentsCount(): number;
40
- /**
41
- * Get the total number of active connections
42
- */
43
- getConnectionsCount(): number;
44
- /**
45
- * Force close one or more connections
46
- */
47
- closeConnections(documentName?: string): void;
48
- /**
49
- * The `handleConnection` method receives incoming WebSocket connections,
50
- * runs all hooks:
51
- *
52
- * - onConnect for all connections
53
- * - onAuthenticate only if required
54
- *
55
- * … and if nothing fails it’ll fully establish the connection and
56
- * load the Document then.
57
- */
58
- handleConnection(incoming: WebSocket, request: IncomingMessage, defaultContext?: any): void;
59
- /**
60
- * Handle update of the given document
61
- *
62
- * "connection" is not necessarily type "Connection", it's the Yjs "origin" (which is "Connection" if
63
- * the update is incoming from the provider, but can be anything if the updates is originated from an extension.
64
- */
65
- private handleDocumentUpdate;
66
- /**
67
- * Create a new document by the given request
68
- */
69
- createDocument(documentName: string, request: Partial<Pick<IncomingMessage, "headers" | "url">>, socketId: string, connection: ConnectionConfiguration, context?: any): Promise<Document>;
70
- loadDocument(documentName: string, request: Partial<Pick<IncomingMessage, "headers" | "url">>, socketId: string, connectionConfig: ConnectionConfiguration, context?: any): Promise<Document>;
71
- storeDocumentHooks(document: Document, hookPayload: onStoreDocumentPayload, immediately?: boolean): Promise<any>;
72
- /**
73
- * Run the given hook on all configured extensions.
74
- * Runs the given callback after each hook.
75
- */
76
- hooks<T extends HookName>(name: T, payload: HookPayloadByName[T], callback?: Function | null): Promise<any>;
77
- shouldUnloadDocument(document: Document): boolean;
78
- unloadDocument(document: Document): Promise<any>;
79
- openDirectConnection(documentName: string, context?: any): Promise<DirectConnection>;
80
- }
@@ -1,25 +0,0 @@
1
- import type { Decoder } from "lib0/decoding";
2
- import type { Encoder } from "lib0/encoding";
3
- import type { MessageType } from "./types.ts";
4
- export declare class IncomingMessage {
5
- /**
6
- * Access to the received message.
7
- */
8
- decoder: Decoder;
9
- /**
10
- * Private encoder; can be undefined.
11
- *
12
- * Lazy creation of the encoder speeds up IncomingMessages that need only a decoder.
13
- */
14
- private encoderInternal?;
15
- constructor(input: any);
16
- get encoder(): Encoder;
17
- readVarUint8Array(): Uint8Array<ArrayBufferLike>;
18
- peekVarUint8Array(): Uint8Array<ArrayBufferLike>;
19
- readVarUint(): number;
20
- readVarString(): string;
21
- toUint8Array(): Uint8Array<ArrayBufferLike>;
22
- writeVarUint(type: MessageType): void;
23
- writeVarString(string: string): void;
24
- get length(): number;
25
- }
@@ -1,11 +0,0 @@
1
- import type Connection from "./Connection.ts";
2
- import type Document from "./Document.ts";
3
- import type { IncomingMessage } from "./IncomingMessage.ts";
4
- export declare class MessageReceiver {
5
- message: IncomingMessage;
6
- defaultTransactionOrigin?: string;
7
- constructor(message: IncomingMessage, defaultTransactionOrigin?: string);
8
- apply(document: Document, connection?: Connection, reply?: (message: Uint8Array) => void): void;
9
- readSyncMessage(message: IncomingMessage, document: Document, connection?: Connection, reply?: (message: Uint8Array) => void, requestFirstSync?: boolean): 0 | 1 | 2;
10
- applyQueryAwarenessMessage(document: Document, reply?: (message: Uint8Array) => void): void;
11
- }
@@ -1,23 +0,0 @@
1
- import type { Encoder } from "lib0/encoding";
2
- import type { Awareness } from "y-protocols/awareness";
3
- import type Document from "./Document.ts";
4
- export declare class OutgoingMessage {
5
- encoder: Encoder;
6
- type?: number;
7
- category?: string;
8
- constructor(documentName: string);
9
- createSyncMessage(): OutgoingMessage;
10
- createSyncReplyMessage(): OutgoingMessage;
11
- createAwarenessUpdateMessage(awareness: Awareness, changedClients?: Array<any>): OutgoingMessage;
12
- writeQueryAwareness(): OutgoingMessage;
13
- writeTokenSyncRequest(): OutgoingMessage;
14
- writeAuthenticated(readonly: boolean): OutgoingMessage;
15
- writePermissionDenied(reason: string): OutgoingMessage;
16
- writeFirstSyncStepFor(document: Document): OutgoingMessage;
17
- writeUpdate(update: Uint8Array): OutgoingMessage;
18
- writeStateless(payload: string): OutgoingMessage;
19
- writeBroadcastStateless(payload: string): OutgoingMessage;
20
- writeSyncStatus(updateSaved: boolean): OutgoingMessage;
21
- writeCloseMessage(reason: string): OutgoingMessage;
22
- toUint8Array(): Uint8Array;
23
- }
@@ -1,32 +0,0 @@
1
- import type { Server as HTTPServer, IncomingMessage, ServerResponse } from "node:http";
2
- import { WebSocketServer } from "ws";
3
- import type { AddressInfo, ServerOptions } from "ws";
4
- import { Hocuspocus } from "./Hocuspocus.ts";
5
- import type { Configuration } from "./types.ts";
6
- export interface ServerConfiguration extends Configuration {
7
- port?: number;
8
- address?: string;
9
- stopOnSignals?: boolean;
10
- }
11
- export declare const defaultServerConfiguration: {
12
- port: number;
13
- address: string;
14
- stopOnSignals: boolean;
15
- };
16
- export declare class Server {
17
- httpServer: HTTPServer;
18
- webSocketServer: WebSocketServer;
19
- hocuspocus: Hocuspocus;
20
- configuration: ServerConfiguration;
21
- constructor(configuration?: Partial<ServerConfiguration>, websocketOptions?: ServerOptions);
22
- setupWebsocketConnection: () => void;
23
- setupHttpUpgrade: () => void;
24
- requestHandler: (request: IncomingMessage, response: ServerResponse) => Promise<void>;
25
- listen(port?: number, callback?: any): Promise<Hocuspocus>;
26
- get address(): AddressInfo;
27
- destroy(): Promise<any>;
28
- get URL(): string;
29
- get webSocketURL(): string;
30
- get httpURL(): string;
31
- private showStartScreen;
32
- }
@@ -1,9 +0,0 @@
1
- export * from "./Connection.ts";
2
- export * from "./Document.ts";
3
- export * from "./Hocuspocus.ts";
4
- export * from "./IncomingMessage.ts";
5
- export * from "./MessageReceiver.ts";
6
- export * from "./OutgoingMessage.ts";
7
- export * from "./Server.ts";
8
- export * from "./types.ts";
9
- export * from "./util/debounce.ts";
@@ -1,342 +0,0 @@
1
- import type { IncomingHttpHeaders, IncomingMessage, ServerResponse } from "node:http";
2
- import type { URLSearchParams } from "node:url";
3
- import type { Awareness } from "y-protocols/awareness";
4
- import type Connection from "./Connection.ts";
5
- import type Document from "./Document.ts";
6
- import type { Hocuspocus } from "./Hocuspocus.ts";
7
- export declare enum MessageType {
8
- Unknown = -1,
9
- Sync = 0,
10
- Awareness = 1,
11
- Auth = 2,
12
- QueryAwareness = 3,
13
- SyncReply = 4,// same as Sync, but won't trigger another 'SyncStep1'
14
- Stateless = 5,
15
- BroadcastStateless = 6,
16
- CLOSE = 7,
17
- SyncStatus = 8
18
- }
19
- export interface AwarenessUpdate {
20
- added: Array<any>;
21
- updated: Array<any>;
22
- removed: Array<any>;
23
- }
24
- export interface ConnectionConfiguration {
25
- readOnly: boolean;
26
- isAuthenticated: boolean;
27
- }
28
- export interface Extension {
29
- priority?: number;
30
- extensionName?: string;
31
- onConfigure?(data: onConfigurePayload): Promise<any>;
32
- onListen?(data: onListenPayload): Promise<any>;
33
- onUpgrade?(data: onUpgradePayload): Promise<any>;
34
- onConnect?(data: onConnectPayload): Promise<any>;
35
- connected?(data: connectedPayload): Promise<any>;
36
- onAuthenticate?(data: onAuthenticatePayload): Promise<any>;
37
- onTokenSync?(data: onTokenSyncPayload): Promise<any>;
38
- onCreateDocument?(data: onCreateDocumentPayload): Promise<any>;
39
- onLoadDocument?(data: onLoadDocumentPayload): Promise<any>;
40
- afterLoadDocument?(data: afterLoadDocumentPayload): Promise<any>;
41
- beforeHandleMessage?(data: beforeHandleMessagePayload): Promise<any>;
42
- beforeSync?(data: beforeSyncPayload): Promise<any>;
43
- beforeBroadcastStateless?(data: beforeBroadcastStatelessPayload): Promise<any>;
44
- onStateless?(payload: onStatelessPayload): Promise<any>;
45
- onChange?(data: onChangePayload): Promise<any>;
46
- onStoreDocument?(data: onStoreDocumentPayload): Promise<any>;
47
- afterStoreDocument?(data: afterStoreDocumentPayload): Promise<any>;
48
- onAwarenessUpdate?(data: onAwarenessUpdatePayload): Promise<any>;
49
- onRequest?(data: onRequestPayload): Promise<any>;
50
- onDisconnect?(data: onDisconnectPayload): Promise<any>;
51
- beforeUnloadDocument?(data: beforeUnloadDocumentPayload): Promise<any>;
52
- afterUnloadDocument?(data: afterUnloadDocumentPayload): Promise<any>;
53
- onDestroy?(data: onDestroyPayload): Promise<any>;
54
- }
55
- export type HookName = "onConfigure" | "onListen" | "onUpgrade" | "onConnect" | "connected" | "onAuthenticate" | "onTokenSync" | "onCreateDocument" | "onLoadDocument" | "afterLoadDocument" | "beforeHandleMessage" | "beforeBroadcastStateless" | "beforeSync" | "onStateless" | "onChange" | "onStoreDocument" | "afterStoreDocument" | "onAwarenessUpdate" | "onRequest" | "onDisconnect" | "beforeUnloadDocument" | "afterUnloadDocument" | "onDestroy";
56
- export type HookPayloadByName = {
57
- onConfigure: onConfigurePayload;
58
- onListen: onListenPayload;
59
- onUpgrade: onUpgradePayload;
60
- onConnect: onConnectPayload;
61
- connected: connectedPayload;
62
- onAuthenticate: onAuthenticatePayload;
63
- onTokenSync: onTokenSyncPayload;
64
- onCreateDocument: onCreateDocumentPayload;
65
- onLoadDocument: onLoadDocumentPayload;
66
- afterLoadDocument: afterLoadDocumentPayload;
67
- beforeHandleMessage: beforeHandleMessagePayload;
68
- beforeBroadcastStateless: beforeBroadcastStatelessPayload;
69
- beforeSync: beforeSyncPayload;
70
- onStateless: onStatelessPayload;
71
- onChange: onChangePayload;
72
- onStoreDocument: onStoreDocumentPayload;
73
- afterStoreDocument: afterStoreDocumentPayload;
74
- onAwarenessUpdate: onAwarenessUpdatePayload;
75
- onRequest: onRequestPayload;
76
- onDisconnect: onDisconnectPayload;
77
- afterUnloadDocument: afterUnloadDocumentPayload;
78
- beforeUnloadDocument: beforeUnloadDocumentPayload;
79
- onDestroy: onDestroyPayload;
80
- };
81
- export interface Configuration extends Extension {
82
- /**
83
- * A name for the instance, used for logging.
84
- */
85
- name: string | null;
86
- /**
87
- * A list of hocuspocus extensions.
88
- */
89
- extensions: Array<Extension>;
90
- /**
91
- * Defines in which interval the server sends a ping, and closes the connection when no pong is sent back.
92
- */
93
- timeout: number;
94
- /**
95
- * Debounces the call of the `onStoreDocument` hook for the given amount of time in ms.
96
- * Otherwise every single update would be persisted.
97
- */
98
- debounce: number;
99
- /**
100
- * Makes sure to call `onStoreDocument` at least in the given amount of time (ms).
101
- */
102
- maxDebounce: number;
103
- /**
104
- * By default, the servers show a start screen. If passed false, the server will start quietly.
105
- */
106
- quiet: boolean;
107
- /**
108
- * If set to false, respects the debounce time of `onStoreDocument` before unloading a document.
109
- * Otherwise, the document will be unloaded immediately.
110
- *
111
- * This prevents a client from DOSing the server by repeatedly connecting and disconnecting when
112
- * your onStoreDocument is rate-limited.
113
- */
114
- unloadImmediately: boolean;
115
- /**
116
- * options to pass to the ydoc document
117
- */
118
- yDocOptions: {
119
- gc: boolean;
120
- gcFilter: () => boolean;
121
- };
122
- }
123
- export interface onStatelessPayload {
124
- connection: Connection;
125
- documentName: string;
126
- document: Document;
127
- payload: string;
128
- }
129
- export interface onAuthenticatePayload {
130
- context: any;
131
- documentName: string;
132
- instance: Hocuspocus;
133
- requestHeaders: IncomingHttpHeaders;
134
- requestParameters: URLSearchParams;
135
- request: IncomingMessage;
136
- socketId: string;
137
- token: string;
138
- connectionConfig: ConnectionConfiguration;
139
- }
140
- export interface onTokenSyncPayload {
141
- context: any;
142
- document: Document;
143
- documentName: string;
144
- instance: Hocuspocus;
145
- requestHeaders: IncomingHttpHeaders;
146
- requestParameters: URLSearchParams;
147
- socketId: string;
148
- token: string;
149
- connectionConfig: ConnectionConfiguration;
150
- connection: Connection;
151
- }
152
- export interface onCreateDocumentPayload {
153
- context: any;
154
- documentName: string;
155
- instance: Hocuspocus;
156
- requestHeaders: IncomingHttpHeaders;
157
- requestParameters: URLSearchParams;
158
- socketId: string;
159
- connectionConfig: ConnectionConfiguration;
160
- }
161
- export interface onConnectPayload {
162
- context: any;
163
- documentName: string;
164
- instance: Hocuspocus;
165
- request: IncomingMessage;
166
- requestHeaders: IncomingHttpHeaders;
167
- requestParameters: URLSearchParams;
168
- socketId: string;
169
- connectionConfig: ConnectionConfiguration;
170
- }
171
- export interface connectedPayload {
172
- context: any;
173
- documentName: string;
174
- instance: Hocuspocus;
175
- request: IncomingMessage;
176
- requestHeaders: IncomingHttpHeaders;
177
- requestParameters: URLSearchParams;
178
- socketId: string;
179
- connectionConfig: ConnectionConfiguration;
180
- connection: Connection;
181
- }
182
- export interface onLoadDocumentPayload {
183
- context: any;
184
- document: Document;
185
- documentName: string;
186
- instance: Hocuspocus;
187
- requestHeaders: IncomingHttpHeaders;
188
- requestParameters: URLSearchParams;
189
- socketId: string;
190
- connectionConfig: ConnectionConfiguration;
191
- }
192
- export interface afterLoadDocumentPayload {
193
- context: any;
194
- document: Document;
195
- documentName: string;
196
- instance: Hocuspocus;
197
- requestHeaders: IncomingHttpHeaders;
198
- requestParameters: URLSearchParams;
199
- socketId: string;
200
- connectionConfig: ConnectionConfiguration;
201
- }
202
- export interface onChangePayload {
203
- clientsCount: number;
204
- context: any;
205
- document: Document;
206
- documentName: string;
207
- instance: Hocuspocus;
208
- requestHeaders: IncomingHttpHeaders;
209
- requestParameters: URLSearchParams;
210
- update: Uint8Array;
211
- socketId: string;
212
- transactionOrigin: any;
213
- }
214
- export interface beforeHandleMessagePayload {
215
- clientsCount: number;
216
- context: any;
217
- document: Document;
218
- documentName: string;
219
- instance: Hocuspocus;
220
- requestHeaders: IncomingHttpHeaders;
221
- requestParameters: URLSearchParams;
222
- update: Uint8Array;
223
- socketId: string;
224
- connection: Connection;
225
- }
226
- export interface beforeSyncPayload {
227
- clientsCount: number;
228
- context: any;
229
- document: Document;
230
- documentName: string;
231
- connection: Connection;
232
- /**
233
- * The y-protocols/sync message type
234
- * @example
235
- * 0: SyncStep1
236
- * 1: SyncStep2
237
- * 2: YjsUpdate
238
- *
239
- * @see https://github.com/yjs/y-protocols/blob/master/sync.js#L13-L40
240
- */
241
- type: number;
242
- /**
243
- * The payload of the y-sync message.
244
- */
245
- payload: Uint8Array;
246
- }
247
- export interface beforeBroadcastStatelessPayload {
248
- document: Document;
249
- documentName: string;
250
- payload: string;
251
- }
252
- export interface onStoreDocumentPayload {
253
- clientsCount: number;
254
- context: any;
255
- document: Document;
256
- documentName: string;
257
- instance: Hocuspocus;
258
- requestHeaders: IncomingHttpHeaders;
259
- requestParameters: URLSearchParams;
260
- socketId: string;
261
- transactionOrigin?: any;
262
- }
263
- export interface afterStoreDocumentPayload extends onStoreDocumentPayload {
264
- }
265
- export interface onAwarenessUpdatePayload {
266
- context: any;
267
- document: Document;
268
- documentName: string;
269
- instance: Hocuspocus;
270
- requestHeaders: IncomingHttpHeaders;
271
- requestParameters: URLSearchParams;
272
- socketId: string;
273
- added: number[];
274
- updated: number[];
275
- removed: number[];
276
- awareness: Awareness;
277
- states: StatesArray;
278
- }
279
- export type StatesArray = {
280
- clientId: number;
281
- [key: string | number]: any;
282
- }[];
283
- export interface fetchPayload {
284
- context: any;
285
- document: Document;
286
- documentName: string;
287
- instance: Hocuspocus;
288
- requestHeaders: IncomingHttpHeaders;
289
- requestParameters: URLSearchParams;
290
- socketId: string;
291
- connectionConfig: ConnectionConfiguration;
292
- }
293
- export interface storePayload extends onStoreDocumentPayload {
294
- state: Buffer;
295
- }
296
- export interface onDisconnectPayload {
297
- clientsCount: number;
298
- context: any;
299
- document: Document;
300
- documentName: string;
301
- instance: Hocuspocus;
302
- requestHeaders: IncomingHttpHeaders;
303
- requestParameters: URLSearchParams;
304
- socketId: string;
305
- }
306
- export interface onRequestPayload {
307
- request: IncomingMessage;
308
- response: ServerResponse;
309
- instance: Hocuspocus;
310
- }
311
- export interface onUpgradePayload {
312
- request: IncomingMessage;
313
- socket: any;
314
- head: any;
315
- instance: Hocuspocus;
316
- }
317
- export interface onListenPayload {
318
- instance: Hocuspocus;
319
- configuration: Configuration;
320
- port: number;
321
- }
322
- export interface onDestroyPayload {
323
- instance: Hocuspocus;
324
- }
325
- export interface onConfigurePayload {
326
- instance: Hocuspocus;
327
- configuration: Configuration;
328
- version: string;
329
- }
330
- export interface afterUnloadDocumentPayload {
331
- instance: Hocuspocus;
332
- documentName: string;
333
- }
334
- export interface beforeUnloadDocumentPayload {
335
- instance: Hocuspocus;
336
- documentName: string;
337
- document: Document;
338
- }
339
- export interface DirectConnection {
340
- transact(transaction: (document: Document) => void): Promise<void>;
341
- disconnect(): void;
342
- }
@@ -1,6 +0,0 @@
1
- export declare const useDebounce: () => {
2
- debounce: (id: string, func: () => any | Promise<() => any>, debounce: number, maxDebounce: number) => Promise<any>;
3
- isDebounced: (id: string) => boolean;
4
- isCurrentlyExecuting: (id: string) => boolean;
5
- executeNow: (id: string) => any;
6
- };
@@ -1,6 +0,0 @@
1
- import type { IncomingMessage } from "node:http";
2
- import { URLSearchParams } from "node:url";
3
- /**
4
- * Get parameters by the given request
5
- */
6
- export declare function getParameters(request?: Pick<IncomingMessage, "url">): URLSearchParams;
@@ -1,11 +0,0 @@
1
- import { Doc } from "yjs";
2
- import { Schema } from "@tiptap/pm/model";
3
- import type { Transformer } from "./types.ts";
4
- declare class Prosemirror implements Transformer {
5
- defaultSchema: Schema;
6
- schema(schema: Schema): Prosemirror;
7
- fromYdoc(document: Doc, fieldName?: string | Array<string>): any;
8
- toYdoc(document: any, fieldName?: string | Array<string>, schema?: Schema): Doc;
9
- }
10
- export declare const ProsemirrorTransformer: Prosemirror;
11
- export {};
@@ -1,10 +0,0 @@
1
- import type { Doc } from "yjs";
2
- import type { Extensions } from "@tiptap/core";
3
- import type { Transformer } from "./types.ts";
4
- export declare class Tiptap implements Transformer {
5
- defaultExtensions: Extensions;
6
- extensions(extensions: Extensions): Tiptap;
7
- fromYdoc(document: Doc, fieldName?: string | Array<string>): any;
8
- toYdoc(document: any, fieldName?: string | Array<string>, extensions?: Extensions): Doc;
9
- }
10
- export declare const TiptapTransformer: Tiptap;
@@ -1,3 +0,0 @@
1
- export * from "./Prosemirror.ts";
2
- export * from "./Tiptap.ts";
3
- export * from "./types.ts";
@@ -1,5 +0,0 @@
1
- import type { Doc } from "yjs";
2
- export interface Transformer {
3
- fromYdoc: (document: Doc, fieldName?: string | Array<string>) => any;
4
- toYdoc: (document: any, fieldName: string) => Doc;
5
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};