@hocuspocus/extension-redis 1.0.0-alpha.37 → 1.0.0-alpha.41

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.
@@ -17,9 +17,9 @@ class Redis {
17
17
  };
18
18
  }
19
19
  /*
20
- * onCreateDocument hook
20
+ * onLoadDocument hook
21
21
  */
22
- async onCreateDocument(data) {
22
+ async onLoadDocument(data) {
23
23
  if (!this.persistence) {
24
24
  return;
25
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"hocuspocus-redis.cjs","sources":["../src/Redis.ts","../src/RedisCluster.ts"],"sourcesContent":["import { RedisPersistence } from 'y-redis'\nimport {\n Extension,\n onConnectPayload,\n onCreateDocumentPayload,\n onDisconnectPayload,\n} from '@hocuspocus/server'\n\nexport interface Configuration {\n}\n\nexport class Redis implements Extension {\n\n configuration: Configuration = {}\n\n cluster = false\n\n persistence!: RedisPersistence | undefined\n\n /**\n * Constructor\n */\n constructor(configuration?: Partial<Configuration>) {\n this.configuration = {\n ...this.configuration,\n ...configuration,\n }\n }\n\n /*\n * onCreateDocument hook\n */\n async onCreateDocument(data: onCreateDocumentPayload) {\n if (!this.persistence) {\n return\n }\n\n // If another connection has already loaded this doc, return this one instead\n const binding = this.persistence.docs.get(data.documentName)\n\n if (binding) {\n return binding.doc\n }\n\n await this.persistence.bindState(data.documentName, data.document).synced\n }\n\n async onConnect(data: onConnectPayload) {\n // Bind to Redis already? Ok, no worries.\n if (this.persistence) {\n return\n }\n\n this.persistence = new RedisPersistence(\n // @ts-ignore\n this.cluster\n ? { redisClusterOpts: this.configuration }\n : { redisOpts: this.configuration },\n )\n\n }\n\n async onDisconnect(data: onDisconnectPayload) {\n // Not binded to Redis? Never mind!\n if (!this.persistence) {\n return\n }\n\n // Still clients connected?\n if (data.clientsCount > 0) {\n return\n }\n\n // Fine, let’s remove the binding …\n this.persistence.destroy()\n this.persistence = undefined\n\n }\n\n}\n","import { Redis } from './Redis'\n\nexport class RedisCluster extends Redis {\n\n cluster = true\n\n}\n"],"names":["RedisPersistence"],"mappings":";;;;;;MAWa,KAAK;;;;IAWhB,YAAY,aAAsC;QATlD,kBAAa,GAAkB,EAAE,CAAA;QAEjC,YAAO,GAAG,KAAK,CAAA;QAQb,IAAI,CAAC,aAAa,GAAG;YACnB,GAAG,IAAI,CAAC,aAAa;YACrB,GAAG,aAAa;SACjB,CAAA;KACF;;;;IAKD,MAAM,gBAAgB,CAAC,IAA6B;QAClD,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACrB,OAAM;SACP;;QAGD,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;QAE5D,IAAI,OAAO,EAAE;YACX,OAAO,OAAO,CAAC,GAAG,CAAA;SACnB;QAED,MAAM,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAA;KAC1E;IAED,MAAM,SAAS,CAAC,IAAsB;;QAEpC,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,OAAM;SACP;QAED,IAAI,CAAC,WAAW,GAAG,IAAIA,uBAAgB;;QAErC,IAAI,CAAC,OAAO;cACR,EAAE,gBAAgB,EAAE,IAAI,CAAC,aAAa,EAAE;cACxC,EAAE,SAAS,EAAE,IAAI,CAAC,aAAa,EAAE,CACtC,CAAA;KAEF;IAED,MAAM,YAAY,CAAC,IAAyB;;QAE1C,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACrB,OAAM;SACP;;QAGD,IAAI,IAAI,CAAC,YAAY,GAAG,CAAC,EAAE;YACzB,OAAM;SACP;;QAGD,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAA;QAC1B,IAAI,CAAC,WAAW,GAAG,SAAS,CAAA;KAE7B;;;MC3EU,YAAa,SAAQ,KAAK;IAAvC;;QAEE,YAAO,GAAG,IAAI,CAAA;KAEf;;;;;;"}
1
+ {"version":3,"file":"hocuspocus-redis.cjs","sources":["../src/Redis.ts","../src/RedisCluster.ts"],"sourcesContent":["import { RedisPersistence } from 'y-redis'\nimport {\n Extension,\n onConnectPayload,\n onLoadDocumentPayload,\n onDisconnectPayload,\n} from '@hocuspocus/server'\n\nexport interface Configuration {\n}\n\nexport class Redis implements Extension {\n\n configuration: Configuration = {}\n\n cluster = false\n\n persistence!: RedisPersistence | undefined\n\n /**\n * Constructor\n */\n constructor(configuration?: Partial<Configuration>) {\n this.configuration = {\n ...this.configuration,\n ...configuration,\n }\n }\n\n /*\n * onLoadDocument hook\n */\n async onLoadDocument(data: onLoadDocumentPayload) {\n if (!this.persistence) {\n return\n }\n\n // If another connection has already loaded this doc, return this one instead\n const binding = this.persistence.docs.get(data.documentName)\n\n if (binding) {\n return binding.doc\n }\n\n await this.persistence.bindState(data.documentName, data.document).synced\n }\n\n async onConnect(data: onConnectPayload) {\n // Bind to Redis already? Ok, no worries.\n if (this.persistence) {\n return\n }\n\n this.persistence = new RedisPersistence(\n // @ts-ignore\n this.cluster\n ? { redisClusterOpts: this.configuration }\n : { redisOpts: this.configuration },\n )\n\n }\n\n async onDisconnect(data: onDisconnectPayload) {\n // Not binded to Redis? Never mind!\n if (!this.persistence) {\n return\n }\n\n // Still clients connected?\n if (data.clientsCount > 0) {\n return\n }\n\n // Fine, let’s remove the binding …\n this.persistence.destroy()\n this.persistence = undefined\n\n }\n\n}\n","import { Redis } from './Redis'\n\nexport class RedisCluster extends Redis {\n\n cluster = true\n\n}\n"],"names":["RedisPersistence"],"mappings":";;;;;;MAWa,KAAK;;;;IAWhB,YAAY,aAAsC;QATlD,kBAAa,GAAkB,EAAE,CAAA;QAEjC,YAAO,GAAG,KAAK,CAAA;QAQb,IAAI,CAAC,aAAa,GAAG;YACnB,GAAG,IAAI,CAAC,aAAa;YACrB,GAAG,aAAa;SACjB,CAAA;KACF;;;;IAKD,MAAM,cAAc,CAAC,IAA2B;QAC9C,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACrB,OAAM;SACP;;QAGD,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;QAE5D,IAAI,OAAO,EAAE;YACX,OAAO,OAAO,CAAC,GAAG,CAAA;SACnB;QAED,MAAM,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAA;KAC1E;IAED,MAAM,SAAS,CAAC,IAAsB;;QAEpC,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,OAAM;SACP;QAED,IAAI,CAAC,WAAW,GAAG,IAAIA,uBAAgB;;QAErC,IAAI,CAAC,OAAO;cACR,EAAE,gBAAgB,EAAE,IAAI,CAAC,aAAa,EAAE;cACxC,EAAE,SAAS,EAAE,IAAI,CAAC,aAAa,EAAE,CACtC,CAAA;KAEF;IAED,MAAM,YAAY,CAAC,IAAyB;;QAE1C,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACrB,OAAM;SACP;;QAGD,IAAI,IAAI,CAAC,YAAY,GAAG,CAAC,EAAE;YACzB,OAAM;SACP;;QAGD,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAA;QAC1B,IAAI,CAAC,WAAW,GAAG,SAAS,CAAA;KAE7B;;;MC3EU,YAAa,SAAQ,KAAK;IAAvC;;QAEE,YAAO,GAAG,IAAI,CAAA;KAEf;;;;;;"}
@@ -13,9 +13,9 @@ class Redis {
13
13
  };
14
14
  }
15
15
  /*
16
- * onCreateDocument hook
16
+ * onLoadDocument hook
17
17
  */
18
- async onCreateDocument(data) {
18
+ async onLoadDocument(data) {
19
19
  if (!this.persistence) {
20
20
  return;
21
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"hocuspocus-redis.esm.js","sources":["../src/Redis.ts","../src/RedisCluster.ts"],"sourcesContent":["import { RedisPersistence } from 'y-redis'\nimport {\n Extension,\n onConnectPayload,\n onCreateDocumentPayload,\n onDisconnectPayload,\n} from '@hocuspocus/server'\n\nexport interface Configuration {\n}\n\nexport class Redis implements Extension {\n\n configuration: Configuration = {}\n\n cluster = false\n\n persistence!: RedisPersistence | undefined\n\n /**\n * Constructor\n */\n constructor(configuration?: Partial<Configuration>) {\n this.configuration = {\n ...this.configuration,\n ...configuration,\n }\n }\n\n /*\n * onCreateDocument hook\n */\n async onCreateDocument(data: onCreateDocumentPayload) {\n if (!this.persistence) {\n return\n }\n\n // If another connection has already loaded this doc, return this one instead\n const binding = this.persistence.docs.get(data.documentName)\n\n if (binding) {\n return binding.doc\n }\n\n await this.persistence.bindState(data.documentName, data.document).synced\n }\n\n async onConnect(data: onConnectPayload) {\n // Bind to Redis already? Ok, no worries.\n if (this.persistence) {\n return\n }\n\n this.persistence = new RedisPersistence(\n // @ts-ignore\n this.cluster\n ? { redisClusterOpts: this.configuration }\n : { redisOpts: this.configuration },\n )\n\n }\n\n async onDisconnect(data: onDisconnectPayload) {\n // Not binded to Redis? Never mind!\n if (!this.persistence) {\n return\n }\n\n // Still clients connected?\n if (data.clientsCount > 0) {\n return\n }\n\n // Fine, let’s remove the binding …\n this.persistence.destroy()\n this.persistence = undefined\n\n }\n\n}\n","import { Redis } from './Redis'\n\nexport class RedisCluster extends Redis {\n\n cluster = true\n\n}\n"],"names":[],"mappings":";;MAWa,KAAK;;;;IAWhB,YAAY,aAAsC;QATlD,kBAAa,GAAkB,EAAE,CAAA;QAEjC,YAAO,GAAG,KAAK,CAAA;QAQb,IAAI,CAAC,aAAa,GAAG;YACnB,GAAG,IAAI,CAAC,aAAa;YACrB,GAAG,aAAa;SACjB,CAAA;KACF;;;;IAKD,MAAM,gBAAgB,CAAC,IAA6B;QAClD,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACrB,OAAM;SACP;;QAGD,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;QAE5D,IAAI,OAAO,EAAE;YACX,OAAO,OAAO,CAAC,GAAG,CAAA;SACnB;QAED,MAAM,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAA;KAC1E;IAED,MAAM,SAAS,CAAC,IAAsB;;QAEpC,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,OAAM;SACP;QAED,IAAI,CAAC,WAAW,GAAG,IAAI,gBAAgB;;QAErC,IAAI,CAAC,OAAO;cACR,EAAE,gBAAgB,EAAE,IAAI,CAAC,aAAa,EAAE;cACxC,EAAE,SAAS,EAAE,IAAI,CAAC,aAAa,EAAE,CACtC,CAAA;KAEF;IAED,MAAM,YAAY,CAAC,IAAyB;;QAE1C,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACrB,OAAM;SACP;;QAGD,IAAI,IAAI,CAAC,YAAY,GAAG,CAAC,EAAE;YACzB,OAAM;SACP;;QAGD,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAA;QAC1B,IAAI,CAAC,WAAW,GAAG,SAAS,CAAA;KAE7B;;;MC3EU,YAAa,SAAQ,KAAK;IAAvC;;QAEE,YAAO,GAAG,IAAI,CAAA;KAEf;;;;;"}
1
+ {"version":3,"file":"hocuspocus-redis.esm.js","sources":["../src/Redis.ts","../src/RedisCluster.ts"],"sourcesContent":["import { RedisPersistence } from 'y-redis'\nimport {\n Extension,\n onConnectPayload,\n onLoadDocumentPayload,\n onDisconnectPayload,\n} from '@hocuspocus/server'\n\nexport interface Configuration {\n}\n\nexport class Redis implements Extension {\n\n configuration: Configuration = {}\n\n cluster = false\n\n persistence!: RedisPersistence | undefined\n\n /**\n * Constructor\n */\n constructor(configuration?: Partial<Configuration>) {\n this.configuration = {\n ...this.configuration,\n ...configuration,\n }\n }\n\n /*\n * onLoadDocument hook\n */\n async onLoadDocument(data: onLoadDocumentPayload) {\n if (!this.persistence) {\n return\n }\n\n // If another connection has already loaded this doc, return this one instead\n const binding = this.persistence.docs.get(data.documentName)\n\n if (binding) {\n return binding.doc\n }\n\n await this.persistence.bindState(data.documentName, data.document).synced\n }\n\n async onConnect(data: onConnectPayload) {\n // Bind to Redis already? Ok, no worries.\n if (this.persistence) {\n return\n }\n\n this.persistence = new RedisPersistence(\n // @ts-ignore\n this.cluster\n ? { redisClusterOpts: this.configuration }\n : { redisOpts: this.configuration },\n )\n\n }\n\n async onDisconnect(data: onDisconnectPayload) {\n // Not binded to Redis? Never mind!\n if (!this.persistence) {\n return\n }\n\n // Still clients connected?\n if (data.clientsCount > 0) {\n return\n }\n\n // Fine, let’s remove the binding …\n this.persistence.destroy()\n this.persistence = undefined\n\n }\n\n}\n","import { Redis } from './Redis'\n\nexport class RedisCluster extends Redis {\n\n cluster = true\n\n}\n"],"names":[],"mappings":";;MAWa,KAAK;;;;IAWhB,YAAY,aAAsC;QATlD,kBAAa,GAAkB,EAAE,CAAA;QAEjC,YAAO,GAAG,KAAK,CAAA;QAQb,IAAI,CAAC,aAAa,GAAG;YACnB,GAAG,IAAI,CAAC,aAAa;YACrB,GAAG,aAAa;SACjB,CAAA;KACF;;;;IAKD,MAAM,cAAc,CAAC,IAA2B;QAC9C,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACrB,OAAM;SACP;;QAGD,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;QAE5D,IAAI,OAAO,EAAE;YACX,OAAO,OAAO,CAAC,GAAG,CAAA;SACnB;QAED,MAAM,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAA;KAC1E;IAED,MAAM,SAAS,CAAC,IAAsB;;QAEpC,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,OAAM;SACP;QAED,IAAI,CAAC,WAAW,GAAG,IAAI,gBAAgB;;QAErC,IAAI,CAAC,OAAO;cACR,EAAE,gBAAgB,EAAE,IAAI,CAAC,aAAa,EAAE;cACxC,EAAE,SAAS,EAAE,IAAI,CAAC,aAAa,EAAE,CACtC,CAAA;KAEF;IAED,MAAM,YAAY,CAAC,IAAyB;;QAE1C,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACrB,OAAM;SACP;;QAGD,IAAI,IAAI,CAAC,YAAY,GAAG,CAAC,EAAE;YACzB,OAAM;SACP;;QAGD,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAA;QAC1B,IAAI,CAAC,WAAW,GAAG,SAAS,CAAA;KAE7B;;;MC3EU,YAAa,SAAQ,KAAK;IAAvC;;QAEE,YAAO,GAAG,IAAI,CAAA;KAEf;;;;;"}
@@ -1,6 +1,17 @@
1
- import { Extension, onChangePayload, onConfigurePayload, onConnectPayload, onCreateDocumentPayload, onDestroyPayload, onDisconnectPayload, onListenPayload, onRequestPayload, onUpgradePayload } from '@hocuspocus/server';
1
+ import { Extension, onChangePayload, onConfigurePayload, onConnectPayload, onLoadDocumentPayload, onDestroyPayload, onDisconnectPayload, onListenPayload, onRequestPayload, onUpgradePayload } from '@hocuspocus/server';
2
+ export interface LoggerConfiguration {
3
+ /**
4
+ * Prepend all logging message with a string.
5
+ */
6
+ prefix: null | string;
7
+ }
2
8
  export declare class Logger implements Extension {
3
- onCreateDocument(data: onCreateDocumentPayload): Promise<void>;
9
+ configuration: LoggerConfiguration;
10
+ /**
11
+ * Constructor
12
+ */
13
+ constructor(configuration?: Partial<LoggerConfiguration>);
14
+ onLoadDocument(data: onLoadDocumentPayload): Promise<void>;
4
15
  onChange(data: onChangePayload): Promise<void>;
5
16
  onConnect(data: onConnectPayload): Promise<void>;
6
17
  onDisconnect(data: onDisconnectPayload): Promise<void>;
@@ -9,5 +20,5 @@ export declare class Logger implements Extension {
9
20
  onListen(data: onListenPayload): Promise<void>;
10
21
  onDestroy(data: onDestroyPayload): Promise<void>;
11
22
  onConfigure(data: onConfigurePayload): Promise<void>;
12
- private static log;
23
+ private log;
13
24
  }
@@ -0,0 +1 @@
1
+ export * from './Logger';
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { Configuration, onConnectPayload, onDisconnectPayload, onCreateDocumentPayload, onChangePayload } from '@hocuspocus/server';
2
+ import { Configuration, onConnectPayload, onDisconnectPayload, onLoadDocumentPayload, onChangePayload } from '@hocuspocus/server';
3
3
  export declare class Collector {
4
4
  serverConfiguration: Partial<Configuration>;
5
5
  version: string;
@@ -30,7 +30,7 @@ export declare class Collector {
30
30
  connectionCount(): {
31
31
  count: string | number;
32
32
  };
33
- createDocument(data: onCreateDocumentPayload): {
33
+ createDocument(data: onLoadDocumentPayload): {
34
34
  action: string;
35
35
  document: any;
36
36
  documentName: string;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { IncomingMessage, ServerResponse } from 'http';
3
- import WebSocket from 'ws';
3
+ import WebSocket, { WebSocketServer } from 'ws';
4
4
  import { Socket } from 'net';
5
5
  import { Storage } from './Storage';
6
6
  export interface Configuration {
@@ -12,7 +12,7 @@ export interface Configuration {
12
12
  }
13
13
  export declare class Dashboard {
14
14
  configuration: Configuration;
15
- websocketServer: WebSocket.Server;
15
+ websocketServer: WebSocketServer;
16
16
  connections: Map<WebSocket, any>;
17
17
  /**
18
18
  * Constructor
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { Extension, onChangePayload, onConfigurePayload, onConnectPayload, onCreateDocumentPayload, onDisconnectPayload, onRequestPayload, onUpgradePayload } from '@hocuspocus/server';
2
+ import { Extension, onChangePayload, onConfigurePayload, onConnectPayload, onLoadDocumentPayload, onDisconnectPayload, onRequestPayload, onUpgradePayload } from '@hocuspocus/server';
3
3
  import { IncomingMessage, ServerResponse } from 'http';
4
4
  import WebSocket from 'ws';
5
5
  import { Storage } from './Storage';
@@ -32,7 +32,7 @@ export declare class Monitor implements Extension {
32
32
  onUpgrade({ request, socket, head }: onUpgradePayload): Promise<void>;
33
33
  onConnect(data: onConnectPayload): Promise<void>;
34
34
  onDisconnect(data: onDisconnectPayload): Promise<void>;
35
- onCreateDocument(data: onCreateDocumentPayload): Promise<void>;
35
+ onLoadDocument(data: onLoadDocumentPayload): Promise<void>;
36
36
  onChange(data: onChangePayload): Promise<void>;
37
37
  onConfigure(data: onConfigurePayload): Promise<void>;
38
38
  }
@@ -1,5 +1,5 @@
1
1
  import { RedisPersistence } from 'y-redis';
2
- import { Extension, onConnectPayload, onCreateDocumentPayload, onDisconnectPayload } from '@hocuspocus/server';
2
+ import { Extension, onConnectPayload, onLoadDocumentPayload, onDisconnectPayload } from '@hocuspocus/server';
3
3
  export interface Configuration {
4
4
  }
5
5
  export declare class Redis implements Extension {
@@ -10,7 +10,7 @@ export declare class Redis implements Extension {
10
10
  * Constructor
11
11
  */
12
12
  constructor(configuration?: Partial<Configuration>);
13
- onCreateDocument(data: onCreateDocumentPayload): Promise<import("yjs").Doc | undefined>;
13
+ onLoadDocument(data: onLoadDocumentPayload): Promise<import("yjs").Doc | undefined>;
14
14
  onConnect(data: onConnectPayload): Promise<void>;
15
15
  onDisconnect(data: onDisconnectPayload): Promise<void>;
16
16
  }
@@ -1,4 +1,4 @@
1
- import { Extension, onCreateDocumentPayload } from '@hocuspocus/server';
1
+ import { Extension, onLoadDocumentPayload } from '@hocuspocus/server';
2
2
  import { LeveldbPersistence } from 'y-leveldb';
3
3
  export interface Configuration {
4
4
  options: object | undefined;
@@ -12,9 +12,9 @@ export declare class RocksDB implements Extension {
12
12
  */
13
13
  constructor(configuration?: Partial<Configuration>);
14
14
  /**
15
- * onCreateDocument hook
15
+ * onLoadDocument hook
16
16
  */
17
- onCreateDocument(data: onCreateDocumentPayload): Promise<any>;
17
+ onLoadDocument(data: onLoadDocumentPayload): Promise<any>;
18
18
  /**
19
19
  * store updates in y-leveldb persistence
20
20
  */
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { Extension, onChangePayload, onConnectPayload, onCreateDocumentPayload, onDisconnectPayload } from '@hocuspocus/server';
2
+ import { Extension, onChangePayload, onConnectPayload, onLoadDocumentPayload, onDisconnectPayload } from '@hocuspocus/server';
3
3
  import { Doc } from 'yjs';
4
4
  import { Transformer } from '@hocuspocus/transformer';
5
5
  import { AxiosResponse } from 'axios';
@@ -42,15 +42,15 @@ export declare class Webhook implements Extension {
42
42
  /**
43
43
  * Send a request to the given url containing the given data
44
44
  */
45
- sendRequest(event: Events, payload: any): Promise<AxiosResponse<any>>;
45
+ sendRequest(event: Events, payload: any): Promise<AxiosResponse<unknown, any>>;
46
46
  /**
47
47
  * onChange hook
48
48
  */
49
49
  onChange(data: onChangePayload): Promise<void>;
50
50
  /**
51
- * onCreateDocument hook
51
+ * onLoadDocument hook
52
52
  */
53
- onCreateDocument(data: onCreateDocumentPayload): Promise<void>;
53
+ onLoadDocument(data: onLoadDocumentPayload): Promise<void>;
54
54
  /**
55
55
  * onConnect hook
56
56
  */
@@ -1,7 +1,7 @@
1
1
  import * as Y from 'yjs';
2
2
  import { Awareness } from 'y-protocols/awareness';
3
3
  import * as mutex from 'lib0/mutex';
4
- import { CloseEvent, MessageEvent, OpenEvent } from 'ws';
4
+ import { Event, CloseEvent, MessageEvent } from 'ws';
5
5
  import EventEmitter from './EventEmitter';
6
6
  import { OutgoingMessage } from './OutgoingMessage';
7
7
  import { ConstructableOutgoingMessage } from './types';
@@ -93,7 +93,7 @@ export interface HocuspocusProviderOptions {
93
93
  onAuthenticationFailed: ({ reason }: {
94
94
  reason: string;
95
95
  }) => void;
96
- onOpen: (event: OpenEvent) => void;
96
+ onOpen: (event: Event) => void;
97
97
  onConnect: () => void;
98
98
  onMessage: (event: MessageEvent) => void;
99
99
  onOutgoingMessage: (message: OutgoingMessage) => void;
@@ -108,7 +108,7 @@ export interface HocuspocusProviderOptions {
108
108
  export declare class HocuspocusProvider extends EventEmitter {
109
109
  options: HocuspocusProviderOptions;
110
110
  subscribedToBroadcastChannel: boolean;
111
- webSocket: any;
111
+ webSocket: WebSocket | null;
112
112
  shouldConnect: boolean;
113
113
  status: WebSocketStatus;
114
114
  isSynced: boolean;
@@ -141,7 +141,7 @@ export declare class HocuspocusProvider extends EventEmitter {
141
141
  set synced(state: boolean);
142
142
  get isAuthenticationRequired(): boolean;
143
143
  disconnect(): void;
144
- onOpen(event: OpenEvent): void;
144
+ onOpen(event: Event): void;
145
145
  getToken(): Promise<string | null>;
146
146
  webSocketConnectionEstablished(): Promise<void>;
147
147
  startSync(): void;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import WebSocket from 'ws';
2
+ import WebSocket, { WebSocketServer } from 'ws';
3
3
  import { IncomingMessage, Server as HTTPServer } from 'http';
4
4
  import { Configuration } from './types';
5
5
  import { MessageLogger } from './Debugger';
@@ -14,7 +14,7 @@ export declare class Hocuspocus {
14
14
  configuration: Configuration;
15
15
  documents: Map<any, any>;
16
16
  httpServer?: HTTPServer;
17
- webSocketServer?: WebSocket.Server;
17
+ webSocketServer?: WebSocketServer;
18
18
  debugger: MessageLogger;
19
19
  /**
20
20
  * Configure the server
@@ -34,7 +34,11 @@ export interface Extension {
34
34
  onChange?(data: onChangePayload): Promise<any>;
35
35
  onConnect?(data: onConnectPayload): Promise<any>;
36
36
  onConfigure?(data: onConfigurePayload): Promise<any>;
37
- onCreateDocument?(data: onCreateDocumentPayload): Promise<any>;
37
+ /**
38
+ * @deprecated onCreateDocument is deprecated, use onLoadDocument instead
39
+ */
40
+ onCreateDocument?(data: onLoadDocumentPayload): Promise<any>;
41
+ onLoadDocument?(data: onLoadDocumentPayload): Promise<any>;
38
42
  onDestroy?(data: onDestroyPayload): Promise<any>;
39
43
  onDisconnect?(data: onDisconnectPayload): Promise<any>;
40
44
  onListen?(data: onListenPayload): Promise<any>;
@@ -73,7 +77,7 @@ export interface onConnectPayload {
73
77
  socketId: string;
74
78
  connection: ConnectionConfig;
75
79
  }
76
- export interface onCreateDocumentPayload {
80
+ export interface onLoadDocumentPayload {
77
81
  context: any;
78
82
  document: Document;
79
83
  documentName: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hocuspocus/extension-redis",
3
- "version": "1.0.0-alpha.37",
3
+ "version": "1.0.0-alpha.41",
4
4
  "description": "hocuspocus persistence driver for Redis",
5
5
  "homepage": "https://hocuspocus.dev",
6
6
  "keywords": [
@@ -12,7 +12,7 @@
12
12
  "type": "module",
13
13
  "main": "dist/hocuspocus-redis.esm.js",
14
14
  "module": "dist/hocuspocus-redis.esm.js",
15
- "types": "dist/packages/redis/src/index.d.ts",
15
+ "types": "dist/packages/extension-redis/src/index.d.ts",
16
16
  "exports": {
17
17
  "import": "./dist/hocuspocus-redis.esm.js",
18
18
  "require": "./dist/hocuspocus-redis.cjs"
@@ -22,9 +22,9 @@
22
22
  "dist"
23
23
  ],
24
24
  "dependencies": {
25
- "@hocuspocus/server": "^1.0.0-alpha.74",
25
+ "@hocuspocus/server": "^1.0.0-alpha.78",
26
26
  "y-redis": "^1.0.2",
27
27
  "yjs": "^13.5.0"
28
28
  },
29
- "gitHead": "d5699cebc1fa14412a4e2cec00a842f01e90a69b"
29
+ "gitHead": "0cc0acea1bbc8ba2106d9b5faa9384f4dc34f57d"
30
30
  }
package/src/Redis.ts CHANGED
@@ -2,7 +2,7 @@ import { RedisPersistence } from 'y-redis'
2
2
  import {
3
3
  Extension,
4
4
  onConnectPayload,
5
- onCreateDocumentPayload,
5
+ onLoadDocumentPayload,
6
6
  onDisconnectPayload,
7
7
  } from '@hocuspocus/server'
8
8
 
@@ -28,9 +28,9 @@ export class Redis implements Extension {
28
28
  }
29
29
 
30
30
  /*
31
- * onCreateDocument hook
31
+ * onLoadDocument hook
32
32
  */
33
- async onCreateDocument(data: onCreateDocumentPayload) {
33
+ async onLoadDocument(data: onLoadDocumentPayload) {
34
34
  if (!this.persistence) {
35
35
  return
36
36
  }