@hocuspocus/provider 3.2.3 → 3.2.5
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-provider.cjs +9 -2
- package/dist/hocuspocus-provider.cjs.map +1 -1
- package/dist/hocuspocus-provider.esm.js +9 -2
- package/dist/hocuspocus-provider.esm.js.map +1 -1
- package/dist/packages/extension-redis/src/Redis.d.ts +2 -2
- package/dist/packages/extension-s3/src/S3.d.ts +44 -0
- package/dist/packages/extension-s3/src/index.d.ts +1 -0
- package/dist/packages/extension-webhook/src/index.d.ts +3 -3
- package/dist/packages/provider/src/HocuspocusProvider.d.ts +7 -5
- package/dist/packages/server/src/Document.d.ts +2 -0
- package/dist/playground/backend/src/s3-redis.d.ts +1 -0
- package/dist/playground/backend/src/s3.d.ts +1 -0
- package/dist/tests/extension-s3/fetch.d.ts +1 -0
- package/package.json +2 -2
- package/src/HocuspocusProvider.ts +22 -4
- package/src/HocuspocusProviderWebsocket.ts +2 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Extension, Hocuspocus, afterLoadDocumentPayload, afterStoreDocumentPayload, beforeBroadcastStatelessPayload, onAwarenessUpdatePayload, onChangePayload, onConfigurePayload, onDisconnectPayload, onStoreDocumentPayload } from "@hocuspocus/server";
|
|
2
|
-
import {
|
|
2
|
+
import { type ExecutionResult, type Lock, Redlock } from "@sesamecare-oss/redlock";
|
|
3
3
|
import type { Cluster, ClusterNode, ClusterOptions, RedisOptions } from "ioredis";
|
|
4
4
|
import RedisClient from "ioredis";
|
|
5
5
|
export type RedisInstance = RedisClient | Cluster;
|
|
@@ -101,7 +101,7 @@ export declare class Redis implements Extension {
|
|
|
101
101
|
/**
|
|
102
102
|
* Release the Redis lock, so other instances can store documents.
|
|
103
103
|
*/
|
|
104
|
-
afterStoreDocument({ documentName, socketId }: afterStoreDocumentPayload): Promise<void>;
|
|
104
|
+
afterStoreDocument({ documentName, socketId, }: afterStoreDocumentPayload): Promise<void>;
|
|
105
105
|
/**
|
|
106
106
|
* Handle awareness update messages received directly by this Hocuspocus instance.
|
|
107
107
|
*/
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { DatabaseConfiguration } from "@hocuspocus/extension-database";
|
|
2
|
+
import { Database } from "@hocuspocus/extension-database";
|
|
3
|
+
import { S3Client } from "@aws-sdk/client-s3";
|
|
4
|
+
export interface S3Configuration extends DatabaseConfiguration {
|
|
5
|
+
/**
|
|
6
|
+
* AWS S3 region
|
|
7
|
+
*/
|
|
8
|
+
region?: string;
|
|
9
|
+
/**
|
|
10
|
+
* S3 bucket name
|
|
11
|
+
*/
|
|
12
|
+
bucket: string;
|
|
13
|
+
/**
|
|
14
|
+
* S3 key prefix for documents (optional)
|
|
15
|
+
*/
|
|
16
|
+
prefix?: string;
|
|
17
|
+
/**
|
|
18
|
+
* AWS credentials
|
|
19
|
+
*/
|
|
20
|
+
credentials?: {
|
|
21
|
+
accessKeyId: string;
|
|
22
|
+
secretAccessKey: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* S3 endpoint URL (for S3-compatible services like MinIO)
|
|
26
|
+
*/
|
|
27
|
+
endpoint?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Force path style URLs (required for MinIO)
|
|
30
|
+
*/
|
|
31
|
+
forcePathStyle?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Custom S3 client
|
|
34
|
+
*/
|
|
35
|
+
s3Client?: S3Client;
|
|
36
|
+
}
|
|
37
|
+
export declare class S3 extends Database {
|
|
38
|
+
private s3Client?;
|
|
39
|
+
configuration: S3Configuration;
|
|
40
|
+
constructor(configuration: Partial<S3Configuration>);
|
|
41
|
+
private getObjectKey;
|
|
42
|
+
onConfigure(): Promise<void>;
|
|
43
|
+
onListen(): Promise<void>;
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./S3.ts";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Extension, onChangePayload, onConnectPayload,
|
|
2
|
-
import type { Doc } from "yjs";
|
|
1
|
+
import type { Extension, onChangePayload, onConnectPayload, onDisconnectPayload, onLoadDocumentPayload } from "@hocuspocus/server";
|
|
3
2
|
import type { Transformer } from "@hocuspocus/transformer";
|
|
3
|
+
import type { Doc } from "yjs";
|
|
4
4
|
export declare enum Events {
|
|
5
5
|
onChange = "change",
|
|
6
6
|
onConnect = "connect",
|
|
@@ -39,7 +39,7 @@ export declare class Webhook implements Extension {
|
|
|
39
39
|
/**
|
|
40
40
|
* Send a request to the given url containing the given data
|
|
41
41
|
*/
|
|
42
|
-
sendRequest(event: Events, payload: any): Promise<import("axios").AxiosResponse<any, any>>;
|
|
42
|
+
sendRequest(event: Events, payload: any): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
43
43
|
/**
|
|
44
44
|
* onChange hook
|
|
45
45
|
*/
|
|
@@ -4,7 +4,7 @@ import * as Y from "yjs";
|
|
|
4
4
|
import EventEmitter from "./EventEmitter.ts";
|
|
5
5
|
import type { CompleteHocuspocusProviderWebsocketConfiguration } from "./HocuspocusProviderWebsocket.ts";
|
|
6
6
|
import { HocuspocusProviderWebsocket } from "./HocuspocusProviderWebsocket.ts";
|
|
7
|
-
import type { ConstructableOutgoingMessage, onAuthenticatedParameters, onAuthenticationFailedParameters, onAwarenessChangeParameters, onAwarenessUpdateParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatelessParameters, onSyncedParameters, onUnsyncedChangesParameters } from "./types.ts";
|
|
7
|
+
import type { ConstructableOutgoingMessage, onAuthenticatedParameters, onAuthenticationFailedParameters, onAwarenessChangeParameters, onAwarenessUpdateParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatelessParameters, onStatusParameters, onSyncedParameters, onUnsyncedChangesParameters } from "./types.ts";
|
|
8
8
|
export type HocuspocusProviderConfiguration = Required<Pick<CompleteHocuspocusProviderConfiguration, "name">> & Partial<CompleteHocuspocusProviderConfiguration> & (Required<Pick<CompleteHocuspocusProviderWebsocketConfiguration, "url">> | Required<Pick<CompleteHocuspocusProviderConfiguration, "websocketProvider">>);
|
|
9
9
|
export interface CompleteHocuspocusProviderConfiguration {
|
|
10
10
|
/**
|
|
@@ -40,6 +40,7 @@ export interface CompleteHocuspocusProviderConfiguration {
|
|
|
40
40
|
onAuthenticationFailed: (data: onAuthenticationFailedParameters) => void;
|
|
41
41
|
onOpen: (data: onOpenParameters) => void;
|
|
42
42
|
onConnect: () => void;
|
|
43
|
+
onStatus: (data: onStatusParameters) => void;
|
|
43
44
|
onMessage: (data: onMessageParameters) => void;
|
|
44
45
|
onOutgoingMessage: (data: onOutgoingMessageParameters) => void;
|
|
45
46
|
onSynced: (data: onSyncedParameters) => void;
|
|
@@ -69,10 +70,11 @@ export declare class HocuspocusProvider extends EventEmitter {
|
|
|
69
70
|
boundPageHide: () => void;
|
|
70
71
|
boundOnOpen: (event: Event) => Promise<void>;
|
|
71
72
|
boundOnClose: () => void;
|
|
72
|
-
forwardConnect: (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
forwardConnect: () => this;
|
|
74
|
+
forwardStatus: (e: onStatusParameters) => this;
|
|
75
|
+
forwardClose: (e: onCloseParameters) => this;
|
|
76
|
+
forwardDisconnect: (e: onDisconnectParameters) => this;
|
|
77
|
+
forwardDestroy: () => this;
|
|
76
78
|
setConfiguration(configuration?: Partial<HocuspocusProviderConfiguration>): void;
|
|
77
79
|
get document(): Y.Doc;
|
|
78
80
|
get isAttached(): boolean;
|
|
@@ -2,6 +2,7 @@ import type WebSocket from "ws";
|
|
|
2
2
|
import { Awareness } from "y-protocols/awareness";
|
|
3
3
|
import { Doc } from "yjs";
|
|
4
4
|
import type Connection from "./Connection.ts";
|
|
5
|
+
import { Mutex } from "async-mutex";
|
|
5
6
|
export declare class Document extends Doc {
|
|
6
7
|
awareness: Awareness;
|
|
7
8
|
callbacks: {
|
|
@@ -16,6 +17,7 @@ export declare class Document extends Doc {
|
|
|
16
17
|
name: string;
|
|
17
18
|
isLoading: boolean;
|
|
18
19
|
isDestroyed: boolean;
|
|
20
|
+
saveMutex: Mutex;
|
|
19
21
|
/**
|
|
20
22
|
* Constructor.
|
|
21
23
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hocuspocus/provider",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.5",
|
|
4
4
|
"description": "hocuspocus provider",
|
|
5
5
|
"homepage": "https://hocuspocus.dev",
|
|
6
6
|
"keywords": [
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@hocuspocus/common": "^3.2.
|
|
32
|
+
"@hocuspocus/common": "^3.2.5",
|
|
33
33
|
"@lifeomic/attempt": "^3.0.2",
|
|
34
34
|
"lib0": "^0.2.87",
|
|
35
35
|
"ws": "^8.17.1"
|
|
@@ -25,6 +25,7 @@ import type {
|
|
|
25
25
|
onOpenParameters,
|
|
26
26
|
onOutgoingMessageParameters,
|
|
27
27
|
onStatelessParameters,
|
|
28
|
+
onStatusParameters,
|
|
28
29
|
onSyncedParameters,
|
|
29
30
|
onUnsyncedChangesParameters,
|
|
30
31
|
} from "./types.ts";
|
|
@@ -79,6 +80,7 @@ export interface CompleteHocuspocusProviderConfiguration {
|
|
|
79
80
|
onAuthenticationFailed: (data: onAuthenticationFailedParameters) => void;
|
|
80
81
|
onOpen: (data: onOpenParameters) => void;
|
|
81
82
|
onConnect: () => void;
|
|
83
|
+
onStatus: (data: onStatusParameters) => void;
|
|
82
84
|
onMessage: (data: onMessageParameters) => void;
|
|
83
85
|
onOutgoingMessage: (data: onOutgoingMessageParameters) => void;
|
|
84
86
|
onSynced: (data: onSyncedParameters) => void;
|
|
@@ -111,6 +113,7 @@ export class HocuspocusProvider extends EventEmitter {
|
|
|
111
113
|
onMessage: () => null,
|
|
112
114
|
onOutgoingMessage: () => null,
|
|
113
115
|
onSynced: () => null,
|
|
116
|
+
onStatus: () => null,
|
|
114
117
|
onDisconnect: () => null,
|
|
115
118
|
onClose: () => null,
|
|
116
119
|
onDestroy: () => null,
|
|
@@ -204,13 +207,15 @@ export class HocuspocusProvider extends EventEmitter {
|
|
|
204
207
|
|
|
205
208
|
boundOnClose = this.onClose.bind(this);
|
|
206
209
|
|
|
207
|
-
forwardConnect = (
|
|
210
|
+
forwardConnect = () => this.emit("connect");
|
|
208
211
|
|
|
209
|
-
|
|
212
|
+
forwardStatus = (e: onStatusParameters) => this.emit("status", e);
|
|
210
213
|
|
|
211
|
-
|
|
214
|
+
forwardClose = (e: onCloseParameters) => this.emit("close", e);
|
|
212
215
|
|
|
213
|
-
|
|
216
|
+
forwardDisconnect = (e: onDisconnectParameters) => this.emit("disconnect", e);
|
|
217
|
+
|
|
218
|
+
forwardDestroy = () => this.emit("destroy");
|
|
214
219
|
|
|
215
220
|
public setConfiguration(
|
|
216
221
|
configuration: Partial<HocuspocusProviderConfiguration> = {},
|
|
@@ -489,6 +494,13 @@ export class HocuspocusProvider extends EventEmitter {
|
|
|
489
494
|
this.configuration.onConnect,
|
|
490
495
|
);
|
|
491
496
|
this.configuration.websocketProvider.off("connect", this.forwardConnect);
|
|
497
|
+
|
|
498
|
+
this.configuration.websocketProvider.off("status", this.forwardStatus);
|
|
499
|
+
this.configuration.websocketProvider.off(
|
|
500
|
+
"status",
|
|
501
|
+
this.configuration.onStatus,
|
|
502
|
+
);
|
|
503
|
+
|
|
492
504
|
this.configuration.websocketProvider.off("open", this.boundOnOpen);
|
|
493
505
|
this.configuration.websocketProvider.off("close", this.boundOnClose);
|
|
494
506
|
this.configuration.websocketProvider.off(
|
|
@@ -524,6 +536,12 @@ export class HocuspocusProvider extends EventEmitter {
|
|
|
524
536
|
);
|
|
525
537
|
this.configuration.websocketProvider.on("connect", this.forwardConnect);
|
|
526
538
|
|
|
539
|
+
this.configuration.websocketProvider.on(
|
|
540
|
+
"status",
|
|
541
|
+
this.configuration.onStatus,
|
|
542
|
+
);
|
|
543
|
+
this.configuration.websocketProvider.on("status", this.forwardStatus);
|
|
544
|
+
|
|
527
545
|
this.configuration.websocketProvider.on("open", this.boundOnOpen);
|
|
528
546
|
|
|
529
547
|
this.configuration.websocketProvider.on("close", this.boundOnClose);
|
|
@@ -195,6 +195,8 @@ export class HocuspocusProviderWebsocket extends EventEmitter {
|
|
|
195
195
|
|
|
196
196
|
async onOpen(event: Event) {
|
|
197
197
|
this.status = WebSocketStatus.Connected;
|
|
198
|
+
this.emit("status", { status: WebSocketStatus.Connected });
|
|
199
|
+
|
|
198
200
|
this.cancelWebsocketRetry = undefined;
|
|
199
201
|
this.receivedOnOpenPayload = event;
|
|
200
202
|
}
|