@hocuspocus/extension-redis 1.0.0-alpha.58 → 1.0.0-alpha.61

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.
@@ -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 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;;;;;;"}
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,CAAA;AAQhB;;AAEG;AACH,IAAA,WAAA,CAAY,aAAsC,EAAA;QATlD,IAAa,CAAA,aAAA,GAAkB,EAAE,CAAA;QAEjC,IAAO,CAAA,OAAA,GAAG,KAAK,CAAA;QAQb,IAAI,CAAC,aAAa,GAAG;YACnB,GAAG,IAAI,CAAC,aAAa;AACrB,YAAA,GAAG,aAAa;SACjB,CAAA;KACF;AAED;;AAEG;IACH,MAAM,cAAc,CAAC,IAA2B,EAAA;AAC9C,QAAA,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACrB,OAAM;AACP,SAAA;;AAGD,QAAA,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;AAE5D,QAAA,IAAI,OAAO,EAAE;YACX,OAAO,OAAO,CAAC,GAAG,CAAA;AACnB,SAAA;AAED,QAAA,MAAM,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAA;KAC1E;IAED,MAAM,SAAS,CAAC,IAAsB,EAAA;;QAEpC,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,OAAM;AACP,SAAA;AAED,QAAA,IAAI,CAAC,WAAW,GAAG,IAAIA,uBAAgB;;AAErC,QAAA,IAAI,CAAC,OAAO;AACV,cAAE,EAAE,gBAAgB,EAAE,IAAI,CAAC,aAAa,EAAE;cACxC,EAAE,SAAS,EAAE,IAAI,CAAC,aAAa,EAAE,CACtC,CAAA;KAEF;IAED,MAAM,YAAY,CAAC,IAAyB,EAAA;;AAE1C,QAAA,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACrB,OAAM;AACP,SAAA;;AAGD,QAAA,IAAI,IAAI,CAAC,YAAY,GAAG,CAAC,EAAE;YACzB,OAAM;AACP,SAAA;;AAGD,QAAA,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAA;AAC1B,QAAA,IAAI,CAAC,WAAW,GAAG,SAAS,CAAA;KAE7B;AAEF;;AC7EK,MAAO,YAAa,SAAQ,KAAK,CAAA;AAAvC,IAAA,WAAA,GAAA;;QAEE,IAAO,CAAA,OAAA,GAAG,IAAI,CAAA;KAEf;AAAA;;;;;"}
@@ -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 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
+ {"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,CAAA;AAQhB;;AAEG;AACH,IAAA,WAAA,CAAY,aAAsC,EAAA;QATlD,IAAa,CAAA,aAAA,GAAkB,EAAE,CAAA;QAEjC,IAAO,CAAA,OAAA,GAAG,KAAK,CAAA;QAQb,IAAI,CAAC,aAAa,GAAG;YACnB,GAAG,IAAI,CAAC,aAAa;AACrB,YAAA,GAAG,aAAa;SACjB,CAAA;KACF;AAED;;AAEG;IACH,MAAM,cAAc,CAAC,IAA2B,EAAA;AAC9C,QAAA,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACrB,OAAM;AACP,SAAA;;AAGD,QAAA,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;AAE5D,QAAA,IAAI,OAAO,EAAE;YACX,OAAO,OAAO,CAAC,GAAG,CAAA;AACnB,SAAA;AAED,QAAA,MAAM,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAA;KAC1E;IAED,MAAM,SAAS,CAAC,IAAsB,EAAA;;QAEpC,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,OAAM;AACP,SAAA;AAED,QAAA,IAAI,CAAC,WAAW,GAAG,IAAI,gBAAgB;;AAErC,QAAA,IAAI,CAAC,OAAO;AACV,cAAE,EAAE,gBAAgB,EAAE,IAAI,CAAC,aAAa,EAAE;cACxC,EAAE,SAAS,EAAE,IAAI,CAAC,aAAa,EAAE,CACtC,CAAA;KAEF;IAED,MAAM,YAAY,CAAC,IAAyB,EAAA;;AAE1C,QAAA,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;YACrB,OAAM;AACP,SAAA;;AAGD,QAAA,IAAI,IAAI,CAAC,YAAY,GAAG,CAAC,EAAE;YACzB,OAAM;AACP,SAAA;;AAGD,QAAA,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAA;AAC1B,QAAA,IAAI,CAAC,WAAW,GAAG,SAAS,CAAA;KAE7B;AAEF;;AC7EK,MAAO,YAAa,SAAQ,KAAK,CAAA;AAAvC,IAAA,WAAA,GAAA;;QAEE,IAAO,CAAA,OAAA,GAAG,IAAI,CAAA;KAEf;AAAA;;;;"}
@@ -1,3 +1,4 @@
1
1
  export * from './auth';
2
2
  export * from './CloseEvents';
3
3
  export * from './awarenessStatesToArray';
4
+ export * from './types';
@@ -0,0 +1,10 @@
1
+ /**
2
+ * State of the WebSocket connection.
3
+ * https://developer.mozilla.org/de/docs/Web/API/WebSocket/readyState
4
+ */
5
+ export declare enum WsReadyStates {
6
+ Connecting = 0,
7
+ Open = 1,
8
+ Closing = 2,
9
+ Closed = 3
10
+ }
@@ -3,7 +3,6 @@ import { Configuration, onConnectPayload, onDisconnectPayload, onLoadDocumentPay
3
3
  export declare class Collector {
4
4
  serverConfiguration: Partial<Configuration>;
5
5
  version: string;
6
- yjsVersion: string;
7
6
  connections: {};
8
7
  messages: {};
9
8
  messageCounter: number;
@@ -56,7 +55,6 @@ export declare class Collector {
56
55
  platform: NodeJS.Platform;
57
56
  started: string;
58
57
  version: string;
59
- yjsVersion: string;
60
58
  }>;
61
59
  private static readableYDoc;
62
60
  }
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { Extension, onChangePayload, onConfigurePayload, onConnectPayload, onLoadDocumentPayload, onDisconnectPayload, onRequestPayload, onUpgradePayload } from '@hocuspocus/server';
2
+ import { Extension, onChangePayload, onConfigurePayload, onLoadDocumentPayload, onDisconnectPayload, onRequestPayload, onUpgradePayload, connectedPayload } from '@hocuspocus/server';
3
3
  import { IncomingMessage, ServerResponse } from 'http';
4
4
  import WebSocket from 'ws';
5
5
  import { Storage } from './Storage';
@@ -30,7 +30,7 @@ export declare class Monitor implements Extension {
30
30
  handleConnection(websocket: WebSocket, request: IncomingMessage): void | undefined;
31
31
  onRequest({ request, response }: onRequestPayload): Promise<void>;
32
32
  onUpgrade({ request, socket, head }: onUpgradePayload): Promise<void>;
33
- onConnect(data: onConnectPayload): Promise<void>;
33
+ connected(data: connectedPayload): Promise<void>;
34
34
  onDisconnect(data: onDisconnectPayload): Promise<void>;
35
35
  onLoadDocument(data: onLoadDocumentPayload): Promise<void>;
36
36
  onChange(data: onChangePayload): Promise<void>;
@@ -3,14 +3,8 @@ import { Awareness } from 'y-protocols/awareness';
3
3
  import * as mutex from 'lib0/mutex';
4
4
  import type { Event, CloseEvent, MessageEvent } from 'ws';
5
5
  import EventEmitter from './EventEmitter';
6
- import { OutgoingMessage } from './OutgoingMessage';
7
- import { ConstructableOutgoingMessage } from './types';
6
+ import { ConstructableOutgoingMessage, onAuthenticationFailedParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatusParameters, onSyncedParameters, WebSocketStatus } from './types';
8
7
  import { onAwarenessChangeParameters, onAwarenessUpdateParameters } from '.';
9
- export declare enum WebSocketStatus {
10
- Connecting = "connecting",
11
- Connected = "connected",
12
- Disconnected = "disconnected"
13
- }
14
8
  export declare type HocuspocusProviderConfiguration = Required<Pick<CompleteHocuspocusProviderConfiguration, 'url' | 'name'>> & Partial<CompleteHocuspocusProviderConfiguration>;
15
9
  export interface CompleteHocuspocusProviderConfiguration {
16
10
  /**
@@ -92,22 +86,18 @@ export interface CompleteHocuspocusProviderConfiguration {
92
86
  */
93
87
  timeout: number;
94
88
  onAuthenticated: () => void;
95
- onAuthenticationFailed: ({ reason }: {
96
- reason: string;
97
- }) => void;
98
- onOpen: (event: Event) => void;
89
+ onAuthenticationFailed: (data: onAuthenticationFailedParameters) => void;
90
+ onOpen: (data: onOpenParameters) => void;
99
91
  onConnect: () => void;
100
- onMessage: (event: MessageEvent) => void;
101
- onOutgoingMessage: (message: OutgoingMessage) => void;
102
- onStatus: (status: any) => void;
103
- onSynced: ({ state }: {
104
- state: boolean;
105
- }) => void;
106
- onDisconnect: (event: CloseEvent) => void;
107
- onClose: (event: CloseEvent) => void;
92
+ onMessage: (data: onMessageParameters) => void;
93
+ onOutgoingMessage: (data: onOutgoingMessageParameters) => void;
94
+ onStatus: (data: onStatusParameters) => void;
95
+ onSynced: (data: onSyncedParameters) => void;
96
+ onDisconnect: (data: onDisconnectParameters) => void;
97
+ onClose: (data: onCloseParameters) => void;
108
98
  onDestroy: () => void;
109
- onAwarenessUpdate: ({ states }: onAwarenessUpdateParameters) => void;
110
- onAwarenessChange: ({ states }: onAwarenessChangeParameters) => void;
99
+ onAwarenessUpdate: (data: onAwarenessUpdateParameters) => void;
100
+ onAwarenessChange: (data: onAwarenessChangeParameters) => void;
111
101
  /**
112
102
  * Don’t output any warnings.
113
103
  */
@@ -133,6 +123,7 @@ export declare class HocuspocusProvider extends EventEmitter {
133
123
  connect(): Promise<void>;
134
124
  createWebSocketConnection(): Promise<unknown>;
135
125
  resolveConnectionAttempt(): void;
126
+ stopConnectionAttempt(): void;
136
127
  rejectConnectionAttempt(): void;
137
128
  get document(): Y.Doc;
138
129
  get awareness(): Awareness;
@@ -149,9 +140,8 @@ export declare class HocuspocusProvider extends EventEmitter {
149
140
  set synced(state: boolean);
150
141
  get isAuthenticationRequired(): boolean;
151
142
  disconnect(): void;
152
- onOpen(event: Event): void;
143
+ onOpen(event: Event): Promise<void>;
153
144
  getToken(): Promise<string | null>;
154
- webSocketConnectionEstablished(): Promise<void>;
155
145
  startSync(): void;
156
146
  send(Message: ConstructableOutgoingMessage, args: any, broadcast?: boolean): void;
157
147
  onMessage(event: MessageEvent): void;
@@ -1,18 +1,26 @@
1
1
  import { Awareness } from 'y-protocols/awareness';
2
2
  import * as Y from 'yjs';
3
3
  import { Encoder } from 'lib0/encoding';
4
+ import type { Event, CloseEvent, MessageEvent } from 'ws';
4
5
  import { AuthenticationMessage } from './OutgoingMessages/AuthenticationMessage';
5
6
  import { AwarenessMessage } from './OutgoingMessages/AwarenessMessage';
6
7
  import { QueryAwarenessMessage } from './OutgoingMessages/QueryAwarenessMessage';
7
8
  import { SyncStepOneMessage } from './OutgoingMessages/SyncStepOneMessage';
8
9
  import { SyncStepTwoMessage } from './OutgoingMessages/SyncStepTwoMessage';
9
10
  import { UpdateMessage } from './OutgoingMessages/UpdateMessage';
11
+ import { IncomingMessage } from './IncomingMessage';
12
+ import { OutgoingMessage } from './OutgoingMessage';
10
13
  export declare enum MessageType {
11
14
  Sync = 0,
12
15
  Awareness = 1,
13
16
  Auth = 2,
14
17
  QueryAwareness = 3
15
18
  }
19
+ export declare enum WebSocketStatus {
20
+ Connecting = "connecting",
21
+ Connected = "connected",
22
+ Disconnected = "disconnected"
23
+ }
16
24
  export interface OutgoingMessageInterface {
17
25
  encoder: Encoder;
18
26
  type?: MessageType;
@@ -32,6 +40,31 @@ export interface Constructable<T> {
32
40
  new (...args: any): T;
33
41
  }
34
42
  export declare type ConstructableOutgoingMessage = Constructable<AuthenticationMessage> | Constructable<AwarenessMessage> | Constructable<QueryAwarenessMessage> | Constructable<SyncStepOneMessage> | Constructable<SyncStepTwoMessage> | Constructable<UpdateMessage>;
43
+ export declare type onAuthenticationFailedParameters = {
44
+ reason: string;
45
+ };
46
+ export declare type onOpenParameters = {
47
+ event: Event;
48
+ };
49
+ export declare type onMessageParameters = {
50
+ event: MessageEvent;
51
+ message: IncomingMessage;
52
+ };
53
+ export declare type onOutgoingMessageParameters = {
54
+ message: OutgoingMessage;
55
+ };
56
+ export declare type onStatusParameters = {
57
+ status: WebSocketStatus;
58
+ };
59
+ export declare type onSyncedParameters = {
60
+ state: boolean;
61
+ };
62
+ export declare type onDisconnectParameters = {
63
+ event: CloseEvent;
64
+ };
65
+ export declare type onCloseParameters = {
66
+ event: CloseEvent;
67
+ };
35
68
  export declare type onAwarenessUpdateParameters = {
36
69
  states: StatesArray;
37
70
  };
@@ -12,16 +12,6 @@ export declare enum MessageType {
12
12
  Auth = 2,
13
13
  QueryAwareness = 3
14
14
  }
15
- /**
16
- * State of the WebSocket connection.
17
- * https://developer.mozilla.org/de/docs/Web/API/WebSocket/readyState
18
- */
19
- export declare enum WsReadyStates {
20
- Connecting = 0,
21
- Open = 1,
22
- Closing = 2,
23
- Closed = 3
24
- }
25
15
  export interface AwarenessUpdate {
26
16
  added: Array<any>;
27
17
  updated: Array<any>;
@@ -222,6 +212,5 @@ export interface onDestroyPayload {
222
212
  export interface onConfigurePayload {
223
213
  configuration: Configuration;
224
214
  version: string;
225
- yjsVersion: string;
226
215
  instance: Hocuspocus;
227
216
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hocuspocus/extension-redis",
3
- "version": "1.0.0-alpha.58",
3
+ "version": "1.0.0-alpha.61",
4
4
  "description": "hocuspocus persistence driver for Redis",
5
5
  "homepage": "https://hocuspocus.dev",
6
6
  "keywords": [
@@ -27,9 +27,9 @@
27
27
  "dist"
28
28
  ],
29
29
  "dependencies": {
30
- "@hocuspocus/server": "^1.0.0-alpha.95",
30
+ "@hocuspocus/server": "^1.0.0-alpha.98",
31
31
  "y-redis": "^1.0.3",
32
- "yjs": "^13.5.24"
32
+ "yjs": "^13.5.29"
33
33
  },
34
- "gitHead": "41c2ca3452f17e7dab914c633cde04ae68f45929"
34
+ "gitHead": "1fc2a6cff1b5fd626b8dd7c486755111965da20d"
35
35
  }