@hocuspocus/extension-database 3.1.3 → 3.1.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-database.cjs.map +1 -1
- package/dist/hocuspocus-database.esm.js.map +1 -1
- package/dist/packages/common/src/auth.d.ts +2 -2
- package/dist/packages/common/src/index.d.ts +4 -4
- package/dist/packages/extension-database/src/Database.d.ts +1 -1
- package/dist/packages/extension-database/src/index.d.ts +1 -1
- package/dist/packages/extension-logger/src/Logger.d.ts +1 -1
- package/dist/packages/extension-logger/src/index.d.ts +1 -1
- package/dist/packages/extension-redis/src/index.d.ts +1 -1
- package/dist/packages/extension-sqlite/src/SQLite.d.ts +3 -3
- package/dist/packages/extension-sqlite/src/index.d.ts +1 -1
- package/dist/packages/extension-throttle/src/index.d.ts +1 -1
- package/dist/packages/extension-webhook/src/index.d.ts +3 -3
- package/dist/packages/provider/src/HocuspocusProvider.d.ts +10 -10
- package/dist/packages/provider/src/IncomingMessage.d.ts +3 -3
- package/dist/packages/provider/src/MessageReceiver.d.ts +2 -2
- package/dist/packages/provider/src/OutgoingMessage.d.ts +2 -2
- package/dist/packages/provider/src/OutgoingMessages/AuthenticationMessage.d.ts +3 -3
- package/dist/packages/provider/src/OutgoingMessages/AwarenessMessage.d.ts +4 -4
- package/dist/packages/provider/src/OutgoingMessages/CloseMessage.d.ts +4 -4
- package/dist/packages/provider/src/OutgoingMessages/QueryAwarenessMessage.d.ts +4 -4
- package/dist/packages/provider/src/OutgoingMessages/StatelessMessage.d.ts +3 -3
- package/dist/packages/provider/src/OutgoingMessages/SyncStepOneMessage.d.ts +4 -4
- package/dist/packages/provider/src/OutgoingMessages/SyncStepTwoMessage.d.ts +4 -4
- package/dist/packages/provider/src/OutgoingMessages/UpdateMessage.d.ts +3 -3
- package/dist/packages/provider/src/index.d.ts +3 -3
- package/dist/packages/provider/src/types.d.ts +14 -14
- package/dist/packages/server/src/ClientConnection.d.ts +17 -17
- package/dist/packages/server/src/Connection.d.ts +6 -6
- package/dist/packages/server/src/DirectConnection.d.ts +3 -3
- package/dist/packages/server/src/Document.d.ts +4 -4
- package/dist/packages/server/src/Hocuspocus.d.ts +8 -8
- package/dist/packages/server/src/IncomingMessage.d.ts +3 -3
- package/dist/packages/server/src/MessageReceiver.d.ts +3 -3
- package/dist/packages/server/src/OutgoingMessage.d.ts +3 -3
- package/dist/packages/server/src/Server.d.ts +5 -5
- package/dist/packages/server/src/index.d.ts +9 -9
- package/dist/packages/server/src/types.d.ts +7 -7
- package/dist/packages/server/src/util/getParameters.d.ts +5 -5
- package/dist/packages/transformer/src/Prosemirror.d.ts +3 -3
- package/dist/packages/transformer/src/Tiptap.d.ts +3 -3
- package/dist/packages/transformer/src/index.d.ts +3 -3
- package/dist/packages/transformer/src/types.d.ts +1 -1
- package/dist/playground/frontend/app/SocketContext1.d.ts +2 -0
- package/dist/playground/frontend/app/SocketContext2.d.ts +2 -0
- package/package.json +37 -37
- package/src/Database.ts +50 -52
- package/src/index.ts +1 -1
- package/dist/playground/frontend/app/SocketContext.d.ts +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hocuspocus-database.cjs","sources":["../src/Database.ts"],"sourcesContent":[null],"names":["Y"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;MAqBa,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"hocuspocus-database.cjs","sources":["../src/Database.ts"],"sourcesContent":[null],"names":["Y"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;MAqBa,QAAQ,CAAA;AASpB;;AAEG;AACH,IAAA,WAAA,CAAY,aAA6C,EAAA;AAXzD;;AAEG;AACH,QAAA,IAAA,CAAA,aAAa,GAA0B;AACtC,YAAA,KAAK,EAAE,YAAY,IAAI;AACvB,YAAA,KAAK,EAAE,eAAc;SACrB;QAMA,IAAI,CAAC,aAAa,GAAG;YACpB,GAAG,IAAI,CAAC,aAAa;AACrB,YAAA,GAAG,aAAa;SAChB;;AAGF;;AAEG;IACH,MAAM,cAAc,CAAC,IAA2B,EAAA;QAC/C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC;QAEnD,IAAI,MAAM,EAAE;YACXA,YAAC,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC;;;AAItC;;AAEG;IACH,MAAM,eAAe,CAAC,IAAqB,EAAA;AAC1C,QAAA,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;AAC9B,YAAA,GAAG,IAAI;AACP,YAAA,KAAK,EAAE,MAAM,CAAC,IAAI,CAACA,YAAC,CAAC,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACxD,SAAA,CAAC;;AAEH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hocuspocus-database.esm.js","sources":["../src/Database.ts"],"sourcesContent":[null],"names":[],"mappings":";;MAqBa,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"hocuspocus-database.esm.js","sources":["../src/Database.ts"],"sourcesContent":[null],"names":[],"mappings":";;MAqBa,QAAQ,CAAA;AASpB;;AAEG;AACH,IAAA,WAAA,CAAY,aAA6C,EAAA;AAXzD;;AAEG;AACH,QAAA,IAAA,CAAA,aAAa,GAA0B;AACtC,YAAA,KAAK,EAAE,YAAY,IAAI;AACvB,YAAA,KAAK,EAAE,eAAc;SACrB;QAMA,IAAI,CAAC,aAAa,GAAG;YACpB,GAAG,IAAI,CAAC,aAAa;AACrB,YAAA,GAAG,aAAa;SAChB;;AAGF;;AAEG;IACH,MAAM,cAAc,CAAC,IAA2B,EAAA;QAC/C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC;QAEnD,IAAI,MAAM,EAAE;YACX,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC;;;AAItC;;AAEG;IACH,MAAM,eAAe,CAAC,IAAqB,EAAA;AAC1C,QAAA,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;AAC9B,YAAA,GAAG,IAAI;AACP,YAAA,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACxD,SAAA,CAAC;;AAEH;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as encoding from
|
|
2
|
-
import * as decoding from
|
|
1
|
+
import * as encoding from "lib0/encoding";
|
|
2
|
+
import * as decoding from "lib0/decoding";
|
|
3
3
|
export declare const writeAuthentication: (encoder: encoding.Encoder, auth: string) => void;
|
|
4
4
|
export declare const writePermissionDenied: (encoder: encoding.Encoder, reason: string) => void;
|
|
5
5
|
export declare const writeAuthenticated: (encoder: encoding.Encoder, scope: "readonly" | "read-write") => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
1
|
+
export * from "./auth.ts";
|
|
2
|
+
export * from "./CloseEvents.ts";
|
|
3
|
+
export * from "./awarenessStatesToArray.ts";
|
|
4
|
+
export * from "./types.ts";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Extension, onChangePayload, onLoadDocumentPayload, storePayload, fetchPayload } from
|
|
1
|
+
import type { Extension, onChangePayload, onLoadDocumentPayload, storePayload, fetchPayload } from "@hocuspocus/server";
|
|
2
2
|
export interface DatabaseConfiguration {
|
|
3
3
|
/**
|
|
4
4
|
* Pass a Promise to retrieve updates from your database. The Promise should resolve to
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./Database.ts";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Extension, onChangePayload, onConfigurePayload, onConnectPayload, onLoadDocumentPayload, onDestroyPayload, onDisconnectPayload, onRequestPayload, onUpgradePayload } from
|
|
1
|
+
import type { Extension, onChangePayload, onConfigurePayload, onConnectPayload, onLoadDocumentPayload, onDestroyPayload, onDisconnectPayload, onRequestPayload, onUpgradePayload } from "@hocuspocus/server";
|
|
2
2
|
export interface LoggerConfiguration {
|
|
3
3
|
/**
|
|
4
4
|
* Prepend all logging message with a string.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./Logger.ts";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./Redis.ts";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { DatabaseConfiguration } from
|
|
2
|
-
import { Database } from
|
|
3
|
-
import sqlite3 from
|
|
1
|
+
import type { DatabaseConfiguration } from "@hocuspocus/extension-database";
|
|
2
|
+
import { Database } from "@hocuspocus/extension-database";
|
|
3
|
+
import sqlite3 from "sqlite3";
|
|
4
4
|
export declare const schema = "CREATE TABLE IF NOT EXISTS \"documents\" (\n \"name\" varchar(255) NOT NULL,\n \"data\" blob NOT NULL,\n UNIQUE(name)\n)";
|
|
5
5
|
export declare const selectQuery = "\n SELECT data FROM \"documents\" WHERE name = $name ORDER BY rowid DESC\n";
|
|
6
6
|
export declare const upsertQuery = "\n INSERT INTO \"documents\" (\"name\", \"data\") VALUES ($name, $data)\n ON CONFLICT(name) DO UPDATE SET data = $data\n";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./SQLite.ts";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Extension, onChangePayload, onConnectPayload, onLoadDocumentPayload, onDisconnectPayload } from
|
|
2
|
-
import type { Doc } from
|
|
3
|
-
import type { Transformer } from
|
|
1
|
+
import type { Extension, onChangePayload, onConnectPayload, onLoadDocumentPayload, onDisconnectPayload } from "@hocuspocus/server";
|
|
2
|
+
import type { Doc } from "yjs";
|
|
3
|
+
import type { Transformer } from "@hocuspocus/transformer";
|
|
4
4
|
export declare enum Events {
|
|
5
5
|
onChange = "change",
|
|
6
6
|
onConnect = "connect",
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type { Event, MessageEvent } from
|
|
2
|
-
import { Awareness } from
|
|
3
|
-
import * as Y from
|
|
4
|
-
import EventEmitter from
|
|
5
|
-
import type { CompleteHocuspocusProviderWebsocketConfiguration } from
|
|
6
|
-
import { HocuspocusProviderWebsocket } from
|
|
7
|
-
import type { ConstructableOutgoingMessage, onAuthenticatedParameters, onAuthenticationFailedParameters, onAwarenessChangeParameters, onAwarenessUpdateParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatelessParameters, onSyncedParameters, onUnsyncedChangesParameters } from
|
|
8
|
-
export type HocuspocusProviderConfiguration = Required<Pick<CompleteHocuspocusProviderConfiguration,
|
|
1
|
+
import type { Event, MessageEvent } from "ws";
|
|
2
|
+
import { Awareness } from "y-protocols/awareness";
|
|
3
|
+
import * as Y from "yjs";
|
|
4
|
+
import EventEmitter from "./EventEmitter.ts";
|
|
5
|
+
import type { CompleteHocuspocusProviderWebsocketConfiguration } from "./HocuspocusProviderWebsocket.ts";
|
|
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";
|
|
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
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
* The identifier/name of your document
|
|
12
|
+
*/
|
|
13
13
|
name: string;
|
|
14
14
|
/**
|
|
15
15
|
* The actual Y.js document
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Decoder } from
|
|
2
|
-
import type { Encoder } from
|
|
3
|
-
import type { MessageType } from
|
|
1
|
+
import type { Decoder } from "lib0/decoding";
|
|
2
|
+
import type { Encoder } from "lib0/encoding";
|
|
3
|
+
import type { MessageType } from "./types.ts";
|
|
4
4
|
export declare class IncomingMessage {
|
|
5
5
|
data: any;
|
|
6
6
|
encoder: Encoder;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { HocuspocusProvider } from
|
|
2
|
-
import type { IncomingMessage } from
|
|
1
|
+
import type { HocuspocusProvider } from "./HocuspocusProvider.ts";
|
|
2
|
+
import type { IncomingMessage } from "./IncomingMessage.ts";
|
|
3
3
|
export declare class MessageReceiver {
|
|
4
4
|
message: IncomingMessage;
|
|
5
5
|
constructor(message: IncomingMessage);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Encoder } from
|
|
2
|
-
import type { MessageType, OutgoingMessageArguments, OutgoingMessageInterface } from
|
|
1
|
+
import type { Encoder } from "lib0/encoding";
|
|
2
|
+
import type { MessageType, OutgoingMessageArguments, OutgoingMessageInterface } from "./types.ts";
|
|
3
3
|
export declare class OutgoingMessage implements OutgoingMessageInterface {
|
|
4
4
|
encoder: Encoder;
|
|
5
5
|
type?: MessageType;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { OutgoingMessageArguments } from
|
|
2
|
-
import { MessageType } from
|
|
3
|
-
import { OutgoingMessage } from
|
|
1
|
+
import type { OutgoingMessageArguments } from "../types.ts";
|
|
2
|
+
import { MessageType } from "../types.ts";
|
|
3
|
+
import { OutgoingMessage } from "../OutgoingMessage.ts";
|
|
4
4
|
export declare class AuthenticationMessage extends OutgoingMessage {
|
|
5
5
|
type: MessageType;
|
|
6
6
|
description: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as encoding from
|
|
2
|
-
import type { OutgoingMessageArguments } from
|
|
3
|
-
import { MessageType } from
|
|
4
|
-
import { OutgoingMessage } from
|
|
1
|
+
import * as encoding from "lib0/encoding";
|
|
2
|
+
import type { OutgoingMessageArguments } from "../types.ts";
|
|
3
|
+
import { MessageType } from "../types.ts";
|
|
4
|
+
import { OutgoingMessage } from "../OutgoingMessage.ts";
|
|
5
5
|
export declare class AwarenessMessage extends OutgoingMessage {
|
|
6
6
|
type: MessageType;
|
|
7
7
|
description: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as encoding from
|
|
2
|
-
import type { OutgoingMessageArguments } from
|
|
3
|
-
import { MessageType } from
|
|
4
|
-
import { OutgoingMessage } from
|
|
1
|
+
import * as encoding from "lib0/encoding";
|
|
2
|
+
import type { OutgoingMessageArguments } from "../types.ts";
|
|
3
|
+
import { MessageType } from "../types.ts";
|
|
4
|
+
import { OutgoingMessage } from "../OutgoingMessage.ts";
|
|
5
5
|
export declare class CloseMessage extends OutgoingMessage {
|
|
6
6
|
type: MessageType;
|
|
7
7
|
description: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as encoding from
|
|
2
|
-
import type { OutgoingMessageArguments } from
|
|
3
|
-
import { MessageType } from
|
|
4
|
-
import { OutgoingMessage } from
|
|
1
|
+
import * as encoding from "lib0/encoding";
|
|
2
|
+
import type { OutgoingMessageArguments } from "../types.ts";
|
|
3
|
+
import { MessageType } from "../types.ts";
|
|
4
|
+
import { OutgoingMessage } from "../OutgoingMessage.ts";
|
|
5
5
|
export declare class QueryAwarenessMessage extends OutgoingMessage {
|
|
6
6
|
type: MessageType;
|
|
7
7
|
description: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { OutgoingMessageArguments } from
|
|
2
|
-
import { MessageType } from
|
|
3
|
-
import { OutgoingMessage } from
|
|
1
|
+
import type { OutgoingMessageArguments } from "../types.ts";
|
|
2
|
+
import { MessageType } from "../types.ts";
|
|
3
|
+
import { OutgoingMessage } from "../OutgoingMessage.ts";
|
|
4
4
|
export declare class StatelessMessage extends OutgoingMessage {
|
|
5
5
|
type: MessageType;
|
|
6
6
|
description: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as encoding from
|
|
2
|
-
import type { OutgoingMessageArguments } from
|
|
3
|
-
import { MessageType } from
|
|
4
|
-
import { OutgoingMessage } from
|
|
1
|
+
import * as encoding from "lib0/encoding";
|
|
2
|
+
import type { OutgoingMessageArguments } from "../types.ts";
|
|
3
|
+
import { MessageType } from "../types.ts";
|
|
4
|
+
import { OutgoingMessage } from "../OutgoingMessage.ts";
|
|
5
5
|
export declare class SyncStepOneMessage extends OutgoingMessage {
|
|
6
6
|
type: MessageType;
|
|
7
7
|
description: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as encoding from
|
|
2
|
-
import type { OutgoingMessageArguments } from
|
|
3
|
-
import { MessageType } from
|
|
4
|
-
import { OutgoingMessage } from
|
|
1
|
+
import * as encoding from "lib0/encoding";
|
|
2
|
+
import type { OutgoingMessageArguments } from "../types.ts";
|
|
3
|
+
import { MessageType } from "../types.ts";
|
|
4
|
+
import { OutgoingMessage } from "../OutgoingMessage.ts";
|
|
5
5
|
export declare class SyncStepTwoMessage extends OutgoingMessage {
|
|
6
6
|
type: MessageType;
|
|
7
7
|
description: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { OutgoingMessageArguments } from
|
|
2
|
-
import { MessageType } from
|
|
3
|
-
import { OutgoingMessage } from
|
|
1
|
+
import type { OutgoingMessageArguments } from "../types.ts";
|
|
2
|
+
import { MessageType } from "../types.ts";
|
|
3
|
+
import { OutgoingMessage } from "../OutgoingMessage.ts";
|
|
4
4
|
export declare class UpdateMessage extends OutgoingMessage {
|
|
5
5
|
type: MessageType;
|
|
6
6
|
description: string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
1
|
+
export * from "./HocuspocusProvider.ts";
|
|
2
|
+
export * from "./HocuspocusProviderWebsocket.ts";
|
|
3
|
+
export * from "./types.ts";
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type { Encoder } from
|
|
2
|
-
import type { Event, MessageEvent } from
|
|
3
|
-
import type { Awareness } from
|
|
4
|
-
import type * as Y from
|
|
5
|
-
import type { CloseEvent } from
|
|
6
|
-
import type { IncomingMessage } from
|
|
7
|
-
import type { OutgoingMessage } from
|
|
8
|
-
import type { AuthenticationMessage } from
|
|
9
|
-
import type { AwarenessMessage } from
|
|
10
|
-
import type { QueryAwarenessMessage } from
|
|
11
|
-
import type { SyncStepOneMessage } from
|
|
12
|
-
import type { SyncStepTwoMessage } from
|
|
13
|
-
import type { UpdateMessage } from
|
|
1
|
+
import type { Encoder } from "lib0/encoding";
|
|
2
|
+
import type { Event, MessageEvent } from "ws";
|
|
3
|
+
import type { Awareness } from "y-protocols/awareness";
|
|
4
|
+
import type * as Y from "yjs";
|
|
5
|
+
import type { CloseEvent } from "@hocuspocus/common";
|
|
6
|
+
import type { IncomingMessage } from "./IncomingMessage.ts";
|
|
7
|
+
import type { OutgoingMessage } from "./OutgoingMessage.ts";
|
|
8
|
+
import type { AuthenticationMessage } from "./OutgoingMessages/AuthenticationMessage.ts";
|
|
9
|
+
import type { AwarenessMessage } from "./OutgoingMessages/AwarenessMessage.ts";
|
|
10
|
+
import type { QueryAwarenessMessage } from "./OutgoingMessages/QueryAwarenessMessage.ts";
|
|
11
|
+
import type { SyncStepOneMessage } from "./OutgoingMessages/SyncStepOneMessage.ts";
|
|
12
|
+
import type { SyncStepTwoMessage } from "./OutgoingMessages/SyncStepTwoMessage.ts";
|
|
13
|
+
import type { UpdateMessage } from "./OutgoingMessages/UpdateMessage.ts";
|
|
14
14
|
export declare enum MessageType {
|
|
15
15
|
Sync = 0,
|
|
16
16
|
Awareness = 1,
|
|
@@ -50,7 +50,7 @@ export type onAuthenticationFailedParameters = {
|
|
|
50
50
|
reason: string;
|
|
51
51
|
};
|
|
52
52
|
export type onAuthenticatedParameters = {
|
|
53
|
-
scope:
|
|
53
|
+
scope: "read-write" | "readonly";
|
|
54
54
|
};
|
|
55
55
|
export type onOpenParameters = {
|
|
56
56
|
event: Event;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { IncomingMessage } from
|
|
2
|
-
import { type CloseEvent } from
|
|
3
|
-
import type WebSocket from
|
|
4
|
-
import type Document from
|
|
5
|
-
import type { Hocuspocus } from
|
|
6
|
-
import type { onDisconnectPayload } from
|
|
1
|
+
import type { IncomingMessage } from "http";
|
|
2
|
+
import { type CloseEvent } from "@hocuspocus/common";
|
|
3
|
+
import type WebSocket from "ws";
|
|
4
|
+
import type Document from "./Document.ts";
|
|
5
|
+
import type { Hocuspocus } from "./Hocuspocus.ts";
|
|
6
|
+
import type { onDisconnectPayload } from "./types.ts";
|
|
7
7
|
/**
|
|
8
8
|
* The `ClientConnection` class is responsible for handling an incoming WebSocket
|
|
9
9
|
*
|
|
@@ -27,18 +27,18 @@ export declare class ClientConnection {
|
|
|
27
27
|
pingInterval: NodeJS.Timeout;
|
|
28
28
|
pongReceived: boolean;
|
|
29
29
|
/**
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
* The `ClientConnection` class receives incoming WebSocket connections,
|
|
31
|
+
* runs all hooks:
|
|
32
|
+
*
|
|
33
|
+
* - onConnect for all connections
|
|
34
|
+
* - onAuthenticate only if required
|
|
35
|
+
*
|
|
36
|
+
* … and if nothings fails it’ll fully establish the connection and
|
|
37
|
+
* load the Document then.
|
|
38
|
+
*/
|
|
39
39
|
constructor(websocket: WebSocket, request: IncomingMessage, documentProvider: {
|
|
40
|
-
createDocument: Hocuspocus[
|
|
41
|
-
}, hooks: Hocuspocus[
|
|
40
|
+
createDocument: Hocuspocus["createDocument"];
|
|
41
|
+
}, hooks: Hocuspocus["hooks"], opts: {
|
|
42
42
|
timeout: number;
|
|
43
43
|
}, defaultContext?: any);
|
|
44
44
|
private handleWebsocketClose;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { IncomingMessage as HTTPIncomingMessage } from
|
|
2
|
-
import { type CloseEvent } from
|
|
3
|
-
import type WebSocket from
|
|
4
|
-
import type Document from
|
|
5
|
-
import type { beforeSyncPayload, onStatelessPayload } from
|
|
1
|
+
import type { IncomingMessage as HTTPIncomingMessage } from "http";
|
|
2
|
+
import { type CloseEvent } from "@hocuspocus/common";
|
|
3
|
+
import type WebSocket from "ws";
|
|
4
|
+
import type Document from "./Document.ts";
|
|
5
|
+
import type { beforeSyncPayload, onStatelessPayload } from "./types.ts";
|
|
6
6
|
export declare class Connection {
|
|
7
7
|
webSocket: WebSocket;
|
|
8
8
|
context: any;
|
|
@@ -35,7 +35,7 @@ export declare class Connection {
|
|
|
35
35
|
/**
|
|
36
36
|
* Set a callback that will be triggered before a sync message is handled
|
|
37
37
|
*/
|
|
38
|
-
beforeSync(callback: (connection: Connection, payload: Pick<beforeSyncPayload,
|
|
38
|
+
beforeSync(callback: (connection: Connection, payload: Pick<beforeSyncPayload, "type" | "payload">) => Promise<any>): Connection;
|
|
39
39
|
/**
|
|
40
40
|
* Send the given message
|
|
41
41
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type Document from
|
|
2
|
-
import type { Hocuspocus } from
|
|
3
|
-
import type { DirectConnection as DirectConnectionInterface } from
|
|
1
|
+
import type Document from "./Document.ts";
|
|
2
|
+
import type { Hocuspocus } from "./Hocuspocus.ts";
|
|
3
|
+
import type { DirectConnection as DirectConnectionInterface } from "./types.ts";
|
|
4
4
|
export declare class DirectConnection implements DirectConnectionInterface {
|
|
5
5
|
document: Document | null;
|
|
6
6
|
instance: Hocuspocus;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type WebSocket from
|
|
2
|
-
import { Awareness } from
|
|
3
|
-
import { Doc } from
|
|
4
|
-
import type Connection from
|
|
1
|
+
import type WebSocket from "ws";
|
|
2
|
+
import { Awareness } from "y-protocols/awareness";
|
|
3
|
+
import { Doc } from "yjs";
|
|
4
|
+
import type Connection from "./Connection.ts";
|
|
5
5
|
export declare class Document extends Doc {
|
|
6
6
|
awareness: Awareness;
|
|
7
7
|
callbacks: {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { IncomingMessage } from
|
|
2
|
-
import type WebSocket from
|
|
3
|
-
import { DirectConnection } from
|
|
4
|
-
import Document from
|
|
5
|
-
import type { Server } from
|
|
6
|
-
import type { Configuration, ConnectionConfiguration, HookName, HookPayloadByName, onStoreDocumentPayload } from
|
|
1
|
+
import type { IncomingMessage } from "http";
|
|
2
|
+
import type WebSocket from "ws";
|
|
3
|
+
import { DirectConnection } from "./DirectConnection.ts";
|
|
4
|
+
import Document from "./Document.ts";
|
|
5
|
+
import type { Server } from "./Server.ts";
|
|
6
|
+
import type { Configuration, ConnectionConfiguration, HookName, HookPayloadByName, onStoreDocumentPayload } from "./types.ts";
|
|
7
7
|
export declare const defaultConfiguration: {
|
|
8
8
|
name: null;
|
|
9
9
|
timeout: number;
|
|
@@ -64,8 +64,8 @@ export declare class Hocuspocus {
|
|
|
64
64
|
/**
|
|
65
65
|
* Create a new document by the given request
|
|
66
66
|
*/
|
|
67
|
-
createDocument(documentName: string, request: Partial<Pick<IncomingMessage,
|
|
68
|
-
loadDocument(documentName: string, request: Partial<Pick<IncomingMessage,
|
|
67
|
+
createDocument(documentName: string, request: Partial<Pick<IncomingMessage, "headers" | "url">>, socketId: string, connection: ConnectionConfiguration, context?: any): Promise<Document>;
|
|
68
|
+
loadDocument(documentName: string, request: Partial<Pick<IncomingMessage, "headers" | "url">>, socketId: string, connectionConfig: ConnectionConfiguration, context?: any): Promise<Document>;
|
|
69
69
|
storeDocumentHooks(document: Document, hookPayload: onStoreDocumentPayload, immediately?: boolean): any;
|
|
70
70
|
/**
|
|
71
71
|
* Run the given hook on all configured extensions.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Decoder } from
|
|
2
|
-
import type { Encoder } from
|
|
3
|
-
import type { MessageType } from
|
|
1
|
+
import type { Decoder } from "lib0/decoding";
|
|
2
|
+
import type { Encoder } from "lib0/encoding";
|
|
3
|
+
import type { MessageType } from "./types.ts";
|
|
4
4
|
export declare class IncomingMessage {
|
|
5
5
|
/**
|
|
6
6
|
* Access to the received message.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type Connection from
|
|
2
|
-
import type Document from
|
|
3
|
-
import type { IncomingMessage } from
|
|
1
|
+
import type Connection from "./Connection.ts";
|
|
2
|
+
import type Document from "./Document.ts";
|
|
3
|
+
import type { IncomingMessage } from "./IncomingMessage.ts";
|
|
4
4
|
export declare class MessageReceiver {
|
|
5
5
|
message: IncomingMessage;
|
|
6
6
|
defaultTransactionOrigin?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Encoder } from
|
|
2
|
-
import type { Awareness } from
|
|
3
|
-
import type Document from
|
|
1
|
+
import type { Encoder } from "lib0/encoding";
|
|
2
|
+
import type { Awareness } from "y-protocols/awareness";
|
|
3
|
+
import type Document from "./Document.ts";
|
|
4
4
|
export declare class OutgoingMessage {
|
|
5
5
|
encoder: Encoder;
|
|
6
6
|
type?: number;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { WebSocketServer } from
|
|
3
|
-
import type { AddressInfo, ServerOptions } from
|
|
4
|
-
import { Hocuspocus } from
|
|
5
|
-
import type { Configuration } from
|
|
1
|
+
import type { Server as HTTPServer, IncomingMessage, ServerResponse } from "http";
|
|
2
|
+
import { WebSocketServer } from "ws";
|
|
3
|
+
import type { AddressInfo, ServerOptions } from "ws";
|
|
4
|
+
import { Hocuspocus } from "./Hocuspocus.ts";
|
|
5
|
+
import type { Configuration } from "./types.ts";
|
|
6
6
|
export interface ServerConfiguration extends Configuration {
|
|
7
7
|
port?: number;
|
|
8
8
|
address?: string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
1
|
+
export * from "./Connection.ts";
|
|
2
|
+
export * from "./Document.ts";
|
|
3
|
+
export * from "./Hocuspocus.ts";
|
|
4
|
+
export * from "./IncomingMessage.ts";
|
|
5
|
+
export * from "./MessageReceiver.ts";
|
|
6
|
+
export * from "./OutgoingMessage.ts";
|
|
7
|
+
export * from "./Server.ts";
|
|
8
|
+
export * from "./types.ts";
|
|
9
|
+
export * from "./util/debounce.ts";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { IncomingHttpHeaders, IncomingMessage, ServerResponse } from
|
|
2
|
-
import type { URLSearchParams } from
|
|
3
|
-
import type { Awareness } from
|
|
4
|
-
import type Connection from
|
|
5
|
-
import type Document from
|
|
6
|
-
import type { Hocuspocus } from
|
|
1
|
+
import type { IncomingHttpHeaders, IncomingMessage, ServerResponse } from "http";
|
|
2
|
+
import type { URLSearchParams } from "url";
|
|
3
|
+
import type { Awareness } from "y-protocols/awareness";
|
|
4
|
+
import type Connection from "./Connection.ts";
|
|
5
|
+
import type Document from "./Document.ts";
|
|
6
|
+
import type { Hocuspocus } from "./Hocuspocus.ts";
|
|
7
7
|
export declare enum MessageType {
|
|
8
8
|
Unknown = -1,
|
|
9
9
|
Sync = 0,
|
|
@@ -51,7 +51,7 @@ export interface Extension {
|
|
|
51
51
|
afterUnloadDocument?(data: afterUnloadDocumentPayload): Promise<any>;
|
|
52
52
|
onDestroy?(data: onDestroyPayload): Promise<any>;
|
|
53
53
|
}
|
|
54
|
-
export type HookName =
|
|
54
|
+
export type HookName = "onConfigure" | "onListen" | "onUpgrade" | "onConnect" | "connected" | "onAuthenticate" | "onCreateDocument" | "onLoadDocument" | "afterLoadDocument" | "beforeHandleMessage" | "beforeBroadcastStateless" | "beforeSync" | "onStateless" | "onChange" | "onStoreDocument" | "afterStoreDocument" | "onAwarenessUpdate" | "onRequest" | "onDisconnect" | "beforeUnloadDocument" | "afterUnloadDocument" | "onDestroy";
|
|
55
55
|
export type HookPayloadByName = {
|
|
56
56
|
onConfigure: onConfigurePayload;
|
|
57
57
|
onListen: onListenPayload;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { IncomingMessage } from
|
|
2
|
-
import { URLSearchParams } from
|
|
1
|
+
import type { IncomingMessage } from "http";
|
|
2
|
+
import { URLSearchParams } from "url";
|
|
3
3
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export declare function getParameters(request?: Pick<IncomingMessage,
|
|
4
|
+
* Get parameters by the given request
|
|
5
|
+
*/
|
|
6
|
+
export declare function getParameters(request?: Pick<IncomingMessage, "url">): URLSearchParams;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Doc } from
|
|
2
|
-
import { Schema } from
|
|
3
|
-
import type { Transformer } from
|
|
1
|
+
import { Doc } from "yjs";
|
|
2
|
+
import { Schema } from "@tiptap/pm/model";
|
|
3
|
+
import type { Transformer } from "./types.ts";
|
|
4
4
|
declare class Prosemirror implements Transformer {
|
|
5
5
|
defaultSchema: Schema;
|
|
6
6
|
schema(schema: Schema): Prosemirror;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Doc } from
|
|
2
|
-
import type { Extensions } from
|
|
3
|
-
import type { Transformer } from
|
|
1
|
+
import type { Doc } from "yjs";
|
|
2
|
+
import type { Extensions } from "@tiptap/core";
|
|
3
|
+
import type { Transformer } from "./types.ts";
|
|
4
4
|
export declare class Tiptap implements Transformer {
|
|
5
5
|
defaultExtensions: Extensions;
|
|
6
6
|
extensions(extensions: Extensions): Tiptap;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
1
|
+
export * from "./Prosemirror.ts";
|
|
2
|
+
export * from "./Tiptap.ts";
|
|
3
|
+
export * from "./types.ts";
|
package/package.json
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
2
|
+
"name": "@hocuspocus/extension-database",
|
|
3
|
+
"description": "a generic Hocuspocus persistence driver for the database",
|
|
4
|
+
"version": "3.1.5",
|
|
5
|
+
"homepage": "https://hocuspocus.dev",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"hocuspocus",
|
|
8
|
+
"yjs"
|
|
9
|
+
],
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "dist/hocuspocus-database.cjs",
|
|
13
|
+
"module": "dist/hocuspocus-database.esm.js",
|
|
14
|
+
"types": "dist/packages/extension-database/src/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
"source": {
|
|
17
|
+
"import": "./src/index.ts"
|
|
18
|
+
},
|
|
19
|
+
"default": {
|
|
20
|
+
"import": "./dist/hocuspocus-database.esm.js",
|
|
21
|
+
"require": "./dist/hocuspocus-database.cjs",
|
|
22
|
+
"types": "./dist/packages/extension-database/src/index.d.ts"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"src",
|
|
27
|
+
"dist"
|
|
28
|
+
],
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@hocuspocus/server": "^3.1.5"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"yjs": "^13.6.8"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"gitHead": "b3454a4ca289a84ddfb7fa5607a2d4b8d5c37e9d"
|
|
39
39
|
}
|
package/src/Database.ts
CHANGED
|
@@ -1,63 +1,61 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from
|
|
8
|
-
import * as Y from
|
|
2
|
+
Extension,
|
|
3
|
+
onChangePayload,
|
|
4
|
+
onLoadDocumentPayload,
|
|
5
|
+
storePayload,
|
|
6
|
+
fetchPayload,
|
|
7
|
+
} from "@hocuspocus/server";
|
|
8
|
+
import * as Y from "yjs";
|
|
9
9
|
|
|
10
10
|
export interface DatabaseConfiguration {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Pass a Promise to retrieve updates from your database. The Promise should resolve to
|
|
13
|
+
* an array of items with Y.js-compatible binary data.
|
|
14
|
+
*/
|
|
15
|
+
fetch: (data: fetchPayload) => Promise<Uint8Array | null>;
|
|
16
|
+
/**
|
|
17
|
+
* Pass a function to store updates in your database.
|
|
18
|
+
*/
|
|
19
|
+
store: (data: storePayload) => Promise<void>;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export class Database implements Extension {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Default configuration
|
|
25
|
+
*/
|
|
26
|
+
configuration: DatabaseConfiguration = {
|
|
27
|
+
fetch: async () => null,
|
|
28
|
+
store: async () => {},
|
|
29
|
+
};
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Constructor
|
|
33
|
+
*/
|
|
34
|
+
constructor(configuration: Partial<DatabaseConfiguration>) {
|
|
35
|
+
this.configuration = {
|
|
36
|
+
...this.configuration,
|
|
37
|
+
...configuration,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Get stored data from the database.
|
|
43
|
+
*/
|
|
44
|
+
async onLoadDocument(data: onLoadDocumentPayload): Promise<any> {
|
|
45
|
+
const update = await this.configuration.fetch(data);
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
if (update) {
|
|
48
|
+
Y.applyUpdate(data.document, update);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
})
|
|
62
|
-
}
|
|
52
|
+
/**
|
|
53
|
+
* Store new updates in the database.
|
|
54
|
+
*/
|
|
55
|
+
async onStoreDocument(data: onChangePayload) {
|
|
56
|
+
await this.configuration.store({
|
|
57
|
+
...data,
|
|
58
|
+
state: Buffer.from(Y.encodeStateAsUpdate(data.document)),
|
|
59
|
+
});
|
|
60
|
+
}
|
|
63
61
|
}
|
package/src/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./Database.ts";
|