@hocuspocus/extension-redis 1.0.0-alpha.38 → 1.0.0-alpha.42

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;;;;;"}
@@ -0,0 +1,68 @@
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
+ * @deprecated
7
+ */
8
+ prefix: null | string;
9
+ /**
10
+ * Whether to log something for the `onLoadDocument` hook.
11
+ */
12
+ onLoadDocument: boolean;
13
+ /**
14
+ * Whether to log something for the `onChange` hook.
15
+ */
16
+ onChange: boolean;
17
+ /**
18
+ * Whether to log something for the `onConnect` hook.
19
+ */
20
+ onConnect: boolean;
21
+ /**
22
+ * Whether to log something for the `onDisconnect` hook.
23
+ */
24
+ onDisconnect: boolean;
25
+ /**
26
+ * Whether to log something for the `onUpgrade` hook.
27
+ */
28
+ onUpgrade: boolean;
29
+ /**
30
+ * Whether to log something for the `onRequest` hook.
31
+ */
32
+ onRequest: boolean;
33
+ /**
34
+ * Whether to log something for the `onListen` hook.
35
+ */
36
+ onListen: boolean;
37
+ /**
38
+ * Whether to log something for the `onDestroy` hook.
39
+ */
40
+ onDestroy: boolean;
41
+ /**
42
+ * Whether to log something for the `onConfigure` hook.
43
+ */
44
+ onConfigure: boolean;
45
+ /**
46
+ * A log function, if none is provided output will go to console
47
+ */
48
+ log: (...args: any[]) => void;
49
+ }
50
+ export declare class Logger implements Extension {
51
+ name: string | null;
52
+ configuration: LoggerConfiguration;
53
+ /**
54
+ * Constructor
55
+ */
56
+ constructor(configuration?: Partial<LoggerConfiguration>);
57
+ onLoadDocument(data: onLoadDocumentPayload): Promise<void>;
58
+ onChange(data: onChangePayload): Promise<void>;
59
+ onConnect(data: onConnectPayload): Promise<void>;
60
+ onDisconnect(data: onDisconnectPayload): Promise<void>;
61
+ onUpgrade(data: onUpgradePayload): Promise<void>;
62
+ onRequest(data: onRequestPayload): Promise<void>;
63
+ onListen(data: onListenPayload): Promise<void>;
64
+ onDestroy(data: onDestroyPayload): Promise<void>;
65
+ onConfigure(data: onConfigurePayload): Promise<void>;
66
+ private logRawText;
67
+ private log;
68
+ }
@@ -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,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';
@@ -48,9 +48,9 @@ export declare class Webhook implements Extension {
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
  */
@@ -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;
@@ -4,6 +4,7 @@ import { IncomingMessage, Server as HTTPServer } from 'http';
4
4
  import { Configuration } from './types';
5
5
  import { MessageLogger } from './Debugger';
6
6
  export declare const defaultConfiguration: {
7
+ name: null;
7
8
  port: number;
8
9
  timeout: number;
9
10
  };
@@ -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>;
@@ -42,6 +46,10 @@ export interface Extension {
42
46
  onUpgrade?(data: onUpgradePayload): Promise<any>;
43
47
  }
44
48
  export interface Configuration extends Extension {
49
+ /**
50
+ * A name for the instance, used for logging.
51
+ */
52
+ name: string | null;
45
53
  /**
46
54
  * A list of hocuspocus extenions.
47
55
  */
@@ -73,7 +81,7 @@ export interface onConnectPayload {
73
81
  socketId: string;
74
82
  connection: ConnectionConfig;
75
83
  }
76
- export interface onCreateDocumentPayload {
84
+ export interface onLoadDocumentPayload {
77
85
  context: any;
78
86
  document: Document;
79
87
  documentName: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hocuspocus/extension-redis",
3
- "version": "1.0.0-alpha.38",
3
+ "version": "1.0.0-alpha.42",
4
4
  "description": "hocuspocus persistence driver for Redis",
5
5
  "homepage": "https://hocuspocus.dev",
6
6
  "keywords": [
@@ -12,19 +12,24 @@
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
- "import": "./dist/hocuspocus-redis.esm.js",
18
- "require": "./dist/hocuspocus-redis.cjs"
17
+ "development": {
18
+ "import": "./src"
19
+ },
20
+ "default": {
21
+ "import": "./dist/hocuspocus-redis.esm.js",
22
+ "require": "./dist/hocuspocus-redis.cjs"
23
+ }
19
24
  },
20
25
  "files": [
21
26
  "src",
22
27
  "dist"
23
28
  ],
24
29
  "dependencies": {
25
- "@hocuspocus/server": "^1.0.0-alpha.75",
30
+ "@hocuspocus/server": "^1.0.0-alpha.79",
26
31
  "y-redis": "^1.0.2",
27
32
  "yjs": "^13.5.0"
28
33
  },
29
- "gitHead": "49a520f1b6be37139f5c7243a484dc413640869c"
34
+ "gitHead": "f9f5acf828d4a1f5ae4df8188000b5c3873e18cf"
30
35
  }
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
  }
@@ -1,13 +0,0 @@
1
- import { Extension, onChangePayload, onConfigurePayload, onConnectPayload, onCreateDocumentPayload, onDestroyPayload, onDisconnectPayload, onListenPayload, onRequestPayload, onUpgradePayload } from '@hocuspocus/server';
2
- export declare class Logger implements Extension {
3
- onCreateDocument(data: onCreateDocumentPayload): Promise<void>;
4
- onChange(data: onChangePayload): Promise<void>;
5
- onConnect(data: onConnectPayload): Promise<void>;
6
- onDisconnect(data: onDisconnectPayload): Promise<void>;
7
- onUpgrade(data: onUpgradePayload): Promise<void>;
8
- onRequest(data: onRequestPayload): Promise<void>;
9
- onListen(data: onListenPayload): Promise<void>;
10
- onDestroy(data: onDestroyPayload): Promise<void>;
11
- onConfigure(data: onConfigurePayload): Promise<void>;
12
- private static log;
13
- }