@hocuspocus/extension-sqlite 2.4.0-rc.1 → 2.5.0-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.
- package/dist/packages/server/src/Connection.d.ts +2 -3
- package/dist/packages/server/src/DirectConnection.d.ts +1 -1
- package/dist/packages/server/src/Hocuspocus.d.ts +9 -5
- package/dist/packages/server/src/Server.d.ts +13 -0
- package/dist/packages/server/src/types.d.ts +10 -0
- package/package.json +2 -2
|
@@ -25,7 +25,6 @@ export declare class Connection {
|
|
|
25
25
|
*/
|
|
26
26
|
constructor(connection: WebSocket, request: HTTPIncomingMessage, document: Document, timeout: number, socketId: string, context: any, readOnly: boolean | undefined, logger: Debugger);
|
|
27
27
|
boundClose: (event?: CloseEvent) => void;
|
|
28
|
-
boundHandleMessage: (data: Uint8Array) => void;
|
|
29
28
|
boundHandlePong: () => void;
|
|
30
29
|
handlePong(): void;
|
|
31
30
|
/**
|
|
@@ -64,8 +63,8 @@ export declare class Connection {
|
|
|
64
63
|
private sendCurrentAwareness;
|
|
65
64
|
/**
|
|
66
65
|
* Handle an incoming message
|
|
67
|
-
* @
|
|
66
|
+
* @public
|
|
68
67
|
*/
|
|
69
|
-
|
|
68
|
+
handleMessage(data: Uint8Array): void;
|
|
70
69
|
}
|
|
71
70
|
export default Connection;
|
|
@@ -9,6 +9,6 @@ export declare class DirectConnection implements DirectConnectionInterface {
|
|
|
9
9
|
* Constructor.
|
|
10
10
|
*/
|
|
11
11
|
constructor(document: Document, instance: Hocuspocus, context?: any);
|
|
12
|
-
transact(transaction: (document: Document) => void): Promise<void>;
|
|
12
|
+
transact(transaction: (document: Document) => void, transactionOrigin?: any): Promise<void>;
|
|
13
13
|
disconnect(): void;
|
|
14
14
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import {
|
|
4
|
-
import WebSocket, { AddressInfo
|
|
3
|
+
import { IncomingMessage } from 'http';
|
|
4
|
+
import WebSocket, { AddressInfo } from 'ws';
|
|
5
|
+
import { Server as HocuspocusServer } from './Server';
|
|
5
6
|
import { Debugger } from './Debugger.js';
|
|
6
7
|
import { DirectConnection } from './DirectConnection.js';
|
|
7
8
|
import Document from './Document.js';
|
|
@@ -18,6 +19,7 @@ export declare const defaultConfiguration: {
|
|
|
18
19
|
gc: boolean;
|
|
19
20
|
gcFilter: () => boolean;
|
|
20
21
|
};
|
|
22
|
+
unloadImmediately: boolean;
|
|
21
23
|
};
|
|
22
24
|
/**
|
|
23
25
|
* Hocuspocus Server
|
|
@@ -25,8 +27,7 @@ export declare const defaultConfiguration: {
|
|
|
25
27
|
export declare class Hocuspocus {
|
|
26
28
|
configuration: Configuration;
|
|
27
29
|
documents: Map<string, Document>;
|
|
28
|
-
|
|
29
|
-
webSocketServer?: WebSocketServer;
|
|
30
|
+
server?: HocuspocusServer;
|
|
30
31
|
debugger: Debugger;
|
|
31
32
|
constructor(configuration?: Partial<Configuration>);
|
|
32
33
|
/**
|
|
@@ -66,12 +67,15 @@ export declare class Hocuspocus {
|
|
|
66
67
|
* - onConnect for all connections
|
|
67
68
|
* - onAuthenticate only if required
|
|
68
69
|
*
|
|
69
|
-
* … and if
|
|
70
|
+
* … and if nothing fails it’ll fully establish the connection and
|
|
70
71
|
* load the Document then.
|
|
71
72
|
*/
|
|
72
73
|
handleConnection(incoming: WebSocket, request: IncomingMessage, defaultContext?: any): void;
|
|
73
74
|
/**
|
|
74
75
|
* Handle update of the given document
|
|
76
|
+
*
|
|
77
|
+
* "connection" is not necessarily type "Connection", it's the Yjs "origin" (which is "Connection" if
|
|
78
|
+
* the update is incoming from the provider, but can be anything if the updates is originated from an extension.
|
|
75
79
|
*/
|
|
76
80
|
private handleDocumentUpdate;
|
|
77
81
|
timers: Map<string, {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { IncomingMessage, Server as HTTPServer, ServerResponse } from 'http';
|
|
3
|
+
import { WebSocketServer } from 'ws';
|
|
4
|
+
import { Hocuspocus } from './Hocuspocus';
|
|
5
|
+
export declare class Server {
|
|
6
|
+
httpServer: HTTPServer;
|
|
7
|
+
webSocketServer: WebSocketServer;
|
|
8
|
+
hocuspocus: Hocuspocus;
|
|
9
|
+
constructor(hocuspocus: Hocuspocus);
|
|
10
|
+
setupWebsocketConnection: () => void;
|
|
11
|
+
setupHttpUpgrade: () => void;
|
|
12
|
+
requestHandler: (request: IncomingMessage, response: ServerResponse) => Promise<void>;
|
|
13
|
+
}
|
|
@@ -108,6 +108,14 @@ export interface Configuration extends Extension {
|
|
|
108
108
|
* By default, the servers show a start screen. If passed false, the server will start quietly.
|
|
109
109
|
*/
|
|
110
110
|
quiet: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* If set to false, respects the debounce time of `onStoreDocument` before unloading a document.
|
|
113
|
+
* Otherwise, the document will be unloaded immediately.
|
|
114
|
+
*
|
|
115
|
+
* This prevents a client from DOSing the server by repeatedly connecting and disconnecting when
|
|
116
|
+
* your onStoreDocument is rate-limited.
|
|
117
|
+
*/
|
|
118
|
+
unloadImmediately: boolean;
|
|
111
119
|
/**
|
|
112
120
|
* options to pass to the ydoc document
|
|
113
121
|
*/
|
|
@@ -190,6 +198,7 @@ export interface onChangePayload {
|
|
|
190
198
|
requestParameters: URLSearchParams;
|
|
191
199
|
update: Uint8Array;
|
|
192
200
|
socketId: string;
|
|
201
|
+
transactionOrigin: any;
|
|
193
202
|
}
|
|
194
203
|
export interface beforeHandleMessagePayload {
|
|
195
204
|
clientsCount: number;
|
|
@@ -217,6 +226,7 @@ export interface onStoreDocumentPayload {
|
|
|
217
226
|
requestHeaders: IncomingHttpHeaders;
|
|
218
227
|
requestParameters: URLSearchParams;
|
|
219
228
|
socketId: string;
|
|
229
|
+
transactionOrigin?: any;
|
|
220
230
|
}
|
|
221
231
|
export interface afterStoreDocumentPayload extends onStoreDocumentPayload {
|
|
222
232
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hocuspocus/extension-sqlite",
|
|
3
3
|
"description": "a generic Hocuspocus persistence driver for the sqlite",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.5.0-rc.0",
|
|
5
5
|
"homepage": "https://hocuspocus.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"hocuspocus",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"dist"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@hocuspocus/extension-database": "^2.
|
|
30
|
+
"@hocuspocus/extension-database": "^2.5.0-rc.0",
|
|
31
31
|
"kleur": "^4.1.4",
|
|
32
32
|
"sqlite3": "^5.0.11"
|
|
33
33
|
},
|