@hocuspocus/extension-database 2.13.5 → 2.13.6
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/hocuspocus-database.cjs +0 -1
- package/dist/hocuspocus-database.cjs.map +1 -1
- package/dist/hocuspocus-database.esm.js +0 -1
- package/dist/hocuspocus-database.esm.js.map +1 -1
- package/dist/packages/server/src/Hocuspocus.d.ts +1 -1
- package/dist/packages/server/src/Server.d.ts +2 -2
- package/package.json +2 -2
- package/src/Database.ts +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hocuspocus-database.cjs","sources":["../src/Database.ts"],"sourcesContent":["import {\n Extension,\n onChangePayload,\n onLoadDocumentPayload,\n storePayload,\n fetchPayload,\n} from '@hocuspocus/server'\nimport * as Y from 'yjs'\n\nexport interface DatabaseConfiguration {\n /**\n * Pass a Promise to retrieve updates from your database. The Promise should resolve to\n * an array of items with Y.js-compatible binary data.\n */\n fetch: (data: fetchPayload) => Promise<Uint8Array | null>,\n /**\n * Pass a function to store updates in your database.\n */\n store: (data: storePayload) => Promise<void>,\n}\n\nexport class Database implements Extension {\n /**\n * Default configuration\n */\n configuration: DatabaseConfiguration = {\n fetch: async () => null,\n store: async () => {},\n }\n\n /**\n * Constructor\n */\n constructor(configuration: Partial<DatabaseConfiguration>) {\n this.configuration = {\n ...this.configuration,\n ...configuration,\n }\n }\n\n /**\n * Get stored data from the database.\n */\n async onLoadDocument(data: onLoadDocumentPayload): Promise<any> {\n const update = await this.configuration.fetch(data)\n\n if (update) {\n Y.applyUpdate(data.document, update)\n }\n
|
|
1
|
+
{"version":3,"file":"hocuspocus-database.cjs","sources":["../src/Database.ts"],"sourcesContent":["import {\n Extension,\n onChangePayload,\n onLoadDocumentPayload,\n storePayload,\n fetchPayload,\n} from '@hocuspocus/server'\nimport * as Y from 'yjs'\n\nexport interface DatabaseConfiguration {\n /**\n * Pass a Promise to retrieve updates from your database. The Promise should resolve to\n * an array of items with Y.js-compatible binary data.\n */\n fetch: (data: fetchPayload) => Promise<Uint8Array | null>,\n /**\n * Pass a function to store updates in your database.\n */\n store: (data: storePayload) => Promise<void>,\n}\n\nexport class Database implements Extension {\n /**\n * Default configuration\n */\n configuration: DatabaseConfiguration = {\n fetch: async () => null,\n store: async () => {},\n }\n\n /**\n * Constructor\n */\n constructor(configuration: Partial<DatabaseConfiguration>) {\n this.configuration = {\n ...this.configuration,\n ...configuration,\n }\n }\n\n /**\n * Get stored data from the database.\n */\n async onLoadDocument(data: onLoadDocumentPayload): Promise<any> {\n const update = await this.configuration.fetch(data)\n\n if (update) {\n Y.applyUpdate(data.document, update)\n }\n }\n\n /**\n * Store new updates in the database.\n */\n async onStoreDocument(data: onChangePayload) {\n await this.configuration.store({\n ...data,\n state: Buffer.from(\n Y.encodeStateAsUpdate(data.document),\n ),\n })\n }\n}\n"],"names":["Y"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;MAqBa,QAAQ,CAAA;AASnB;;AAEG;AACH,IAAA,WAAA,CAAY,aAA6C,EAAA;AAXzD;;AAEG;AACH,QAAA,IAAA,CAAA,aAAa,GAA0B;AACrC,YAAA,KAAK,EAAE,YAAY,IAAI;AACvB,YAAA,KAAK,EAAE,eAAc;SACtB,CAAA;QAMC,IAAI,CAAC,aAAa,GAAG;YACnB,GAAG,IAAI,CAAC,aAAa;AACrB,YAAA,GAAG,aAAa;SACjB,CAAA;KACF;AAED;;AAEG;IACH,MAAM,cAAc,CAAC,IAA2B,EAAA;QAC9C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;AAEnD,QAAA,IAAI,MAAM,EAAE;YACVA,YAAC,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;AACrC,SAAA;KACF;AAED;;AAEG;IACH,MAAM,eAAe,CAAC,IAAqB,EAAA;AACzC,QAAA,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;AAC7B,YAAA,GAAG,IAAI;AACP,YAAA,KAAK,EAAE,MAAM,CAAC,IAAI,CAChBA,YAAC,CAAC,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,CACrC;AACF,SAAA,CAAC,CAAA;KACH;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hocuspocus-database.esm.js","sources":["../src/Database.ts"],"sourcesContent":["import {\n Extension,\n onChangePayload,\n onLoadDocumentPayload,\n storePayload,\n fetchPayload,\n} from '@hocuspocus/server'\nimport * as Y from 'yjs'\n\nexport interface DatabaseConfiguration {\n /**\n * Pass a Promise to retrieve updates from your database. The Promise should resolve to\n * an array of items with Y.js-compatible binary data.\n */\n fetch: (data: fetchPayload) => Promise<Uint8Array | null>,\n /**\n * Pass a function to store updates in your database.\n */\n store: (data: storePayload) => Promise<void>,\n}\n\nexport class Database implements Extension {\n /**\n * Default configuration\n */\n configuration: DatabaseConfiguration = {\n fetch: async () => null,\n store: async () => {},\n }\n\n /**\n * Constructor\n */\n constructor(configuration: Partial<DatabaseConfiguration>) {\n this.configuration = {\n ...this.configuration,\n ...configuration,\n }\n }\n\n /**\n * Get stored data from the database.\n */\n async onLoadDocument(data: onLoadDocumentPayload): Promise<any> {\n const update = await this.configuration.fetch(data)\n\n if (update) {\n Y.applyUpdate(data.document, update)\n }\n
|
|
1
|
+
{"version":3,"file":"hocuspocus-database.esm.js","sources":["../src/Database.ts"],"sourcesContent":["import {\n Extension,\n onChangePayload,\n onLoadDocumentPayload,\n storePayload,\n fetchPayload,\n} from '@hocuspocus/server'\nimport * as Y from 'yjs'\n\nexport interface DatabaseConfiguration {\n /**\n * Pass a Promise to retrieve updates from your database. The Promise should resolve to\n * an array of items with Y.js-compatible binary data.\n */\n fetch: (data: fetchPayload) => Promise<Uint8Array | null>,\n /**\n * Pass a function to store updates in your database.\n */\n store: (data: storePayload) => Promise<void>,\n}\n\nexport class Database implements Extension {\n /**\n * Default configuration\n */\n configuration: DatabaseConfiguration = {\n fetch: async () => null,\n store: async () => {},\n }\n\n /**\n * Constructor\n */\n constructor(configuration: Partial<DatabaseConfiguration>) {\n this.configuration = {\n ...this.configuration,\n ...configuration,\n }\n }\n\n /**\n * Get stored data from the database.\n */\n async onLoadDocument(data: onLoadDocumentPayload): Promise<any> {\n const update = await this.configuration.fetch(data)\n\n if (update) {\n Y.applyUpdate(data.document, update)\n }\n }\n\n /**\n * Store new updates in the database.\n */\n async onStoreDocument(data: onChangePayload) {\n await this.configuration.store({\n ...data,\n state: Buffer.from(\n Y.encodeStateAsUpdate(data.document),\n ),\n })\n }\n}\n"],"names":[],"mappings":";;MAqBa,QAAQ,CAAA;AASnB;;AAEG;AACH,IAAA,WAAA,CAAY,aAA6C,EAAA;AAXzD;;AAEG;AACH,QAAA,IAAA,CAAA,aAAa,GAA0B;AACrC,YAAA,KAAK,EAAE,YAAY,IAAI;AACvB,YAAA,KAAK,EAAE,eAAc;SACtB,CAAA;QAMC,IAAI,CAAC,aAAa,GAAG;YACnB,GAAG,IAAI,CAAC,aAAa;AACrB,YAAA,GAAG,aAAa;SACjB,CAAA;KACF;AAED;;AAEG;IACH,MAAM,cAAc,CAAC,IAA2B,EAAA;QAC9C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;AAEnD,QAAA,IAAI,MAAM,EAAE;YACV,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;AACrC,SAAA;KACF;AAED;;AAEG;IACH,MAAM,eAAe,CAAC,IAAqB,EAAA;AACzC,QAAA,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;AAC7B,YAAA,GAAG,IAAI;AACP,YAAA,KAAK,EAAE,MAAM,CAAC,IAAI,CAChB,CAAC,CAAC,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,CACrC;AACF,SAAA,CAAC,CAAA;KACH;AACF;;;;"}
|
|
@@ -44,7 +44,7 @@ export declare class Hocuspocus {
|
|
|
44
44
|
/**
|
|
45
45
|
* Start the server
|
|
46
46
|
*/
|
|
47
|
-
listen(portOrCallback?: number | ((data: onListenPayload) => Promise<any>) | null, callback?: any): Promise<Hocuspocus>;
|
|
47
|
+
listen(portOrCallback?: number | ((data: onListenPayload) => Promise<any>) | null, callback?: any, websocketOptions?: WebSocket.ServerOptions): Promise<Hocuspocus>;
|
|
48
48
|
get address(): AddressInfo;
|
|
49
49
|
get URL(): string;
|
|
50
50
|
get webSocketURL(): string;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { IncomingMessage, Server as HTTPServer, ServerResponse } from 'http';
|
|
3
|
-
import { WebSocketServer } from 'ws';
|
|
3
|
+
import { ServerOptions, WebSocketServer } from 'ws';
|
|
4
4
|
import { Hocuspocus } from './Hocuspocus.js';
|
|
5
5
|
export declare class Server {
|
|
6
6
|
httpServer: HTTPServer;
|
|
7
7
|
webSocketServer: WebSocketServer;
|
|
8
8
|
hocuspocus: Hocuspocus;
|
|
9
|
-
constructor(hocuspocus: Hocuspocus);
|
|
9
|
+
constructor(hocuspocus: Hocuspocus, websocketOptions?: ServerOptions);
|
|
10
10
|
setupWebsocketConnection: () => void;
|
|
11
11
|
setupHttpUpgrade: () => void;
|
|
12
12
|
requestHandler: (request: IncomingMessage, response: ServerResponse) => Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hocuspocus/extension-database",
|
|
3
3
|
"description": "a generic Hocuspocus persistence driver for the database",
|
|
4
|
-
"version": "2.13.
|
|
4
|
+
"version": "2.13.6",
|
|
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/server": "^2.13.
|
|
30
|
+
"@hocuspocus/server": "^2.13.6"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"yjs": "^13.6.8"
|