@hocuspocus/extension-database 2.13.5-rc.0 → 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.
@@ -49,7 +49,6 @@ class Database {
49
49
  if (update) {
50
50
  Y__namespace.applyUpdate(data.document, update);
51
51
  }
52
- return data.document;
53
52
  }
54
53
  /**
55
54
  * Store new updates in the database.
@@ -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\n return data.document\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;QAED,OAAO,IAAI,CAAC,QAAQ,CAAA;KACrB;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
+ {"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;;;;"}
@@ -25,7 +25,6 @@ class Database {
25
25
  if (update) {
26
26
  Y.applyUpdate(data.document, update);
27
27
  }
28
- return data.document;
29
28
  }
30
29
  /**
31
30
  * Store new updates in the database.
@@ -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\n return data.document\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;QAED,OAAO,IAAI,CAAC,QAAQ,CAAA;KACrB;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;;;;"}
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.5-rc.0",
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.5-rc.0"
30
+ "@hocuspocus/server": "^2.13.6"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "yjs": "^13.6.8"
package/src/Database.ts CHANGED
@@ -47,8 +47,6 @@ export class Database implements Extension {
47
47
  if (update) {
48
48
  Y.applyUpdate(data.document, update)
49
49
  }
50
-
51
- return data.document
52
50
  }
53
51
 
54
52
  /**