@hocuspocus/common 2.13.5-rc.0 → 3.0.0-rc.0

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.
Files changed (48) hide show
  1. package/dist/hocuspocus-common.cjs +4 -2
  2. package/dist/hocuspocus-common.cjs.map +1 -1
  3. package/dist/hocuspocus-common.esm.js +4 -0
  4. package/dist/hocuspocus-common.esm.js.map +1 -1
  5. package/dist/packages/common/src/auth.d.ts +1 -1
  6. package/dist/packages/extension-database/src/Database.d.ts +1 -1
  7. package/dist/packages/extension-logger/src/Logger.d.ts +1 -1
  8. package/dist/packages/extension-redis/src/Redis.d.ts +4 -3
  9. package/dist/packages/extension-sqlite/src/SQLite.d.ts +2 -1
  10. package/dist/packages/extension-throttle/src/index.d.ts +2 -3
  11. package/dist/packages/extension-webhook/src/index.d.ts +3 -4
  12. package/dist/packages/provider/src/HocuspocusProvider.d.ts +4 -13
  13. package/dist/packages/provider/src/HocuspocusProviderWebsocket.d.ts +5 -5
  14. package/dist/packages/provider/src/IncomingMessage.d.ts +3 -3
  15. package/dist/packages/provider/src/MessageReceiver.d.ts +2 -2
  16. package/dist/packages/provider/src/MessageSender.d.ts +2 -2
  17. package/dist/packages/provider/src/OutgoingMessage.d.ts +2 -2
  18. package/dist/packages/provider/src/OutgoingMessages/AuthenticationMessage.d.ts +2 -1
  19. package/dist/packages/provider/src/OutgoingMessages/AwarenessMessage.d.ts +2 -1
  20. package/dist/packages/provider/src/OutgoingMessages/CloseMessage.d.ts +2 -1
  21. package/dist/packages/provider/src/OutgoingMessages/QueryAwarenessMessage.d.ts +2 -1
  22. package/dist/packages/provider/src/OutgoingMessages/StatelessMessage.d.ts +2 -1
  23. package/dist/packages/provider/src/OutgoingMessages/SyncStepOneMessage.d.ts +2 -1
  24. package/dist/packages/provider/src/OutgoingMessages/SyncStepTwoMessage.d.ts +2 -1
  25. package/dist/packages/provider/src/OutgoingMessages/UpdateMessage.d.ts +2 -1
  26. package/dist/packages/provider/src/TiptapCollabProvider.d.ts +2 -1
  27. package/dist/packages/provider/src/TiptapCollabProviderWebsocket.d.ts +2 -1
  28. package/dist/packages/provider/src/types.d.ts +12 -12
  29. package/dist/packages/server/src/ClientConnection.d.ts +6 -7
  30. package/dist/packages/server/src/Connection.d.ts +7 -9
  31. package/dist/packages/server/src/DirectConnection.d.ts +1 -1
  32. package/dist/packages/server/src/Document.d.ts +5 -5
  33. package/dist/packages/server/src/Hocuspocus.d.ts +6 -27
  34. package/dist/packages/server/src/IncomingMessage.d.ts +3 -3
  35. package/dist/packages/server/src/MessageReceiver.d.ts +4 -4
  36. package/dist/packages/server/src/OutgoingMessage.d.ts +3 -3
  37. package/dist/packages/server/src/Server.d.ts +22 -3
  38. package/dist/packages/server/src/index.d.ts +1 -0
  39. package/dist/packages/server/src/types.d.ts +7 -24
  40. package/dist/packages/server/src/util/getParameters.d.ts +1 -3
  41. package/dist/packages/transformer/src/Prosemirror.d.ts +1 -1
  42. package/dist/packages/transformer/src/Tiptap.d.ts +3 -3
  43. package/dist/packages/transformer/src/types.d.ts +1 -1
  44. package/dist/tests/utils/newHocuspocus.d.ts +2 -2
  45. package/dist/tests/utils/newHocuspocusProvider.d.ts +2 -2
  46. package/dist/tests/utils/newHocuspocusProviderWebsocket.d.ts +4 -3
  47. package/dist/tests/utils/retryableAssertion.d.ts +1 -1
  48. package/package.json +1 -1
@@ -1,6 +1,7 @@
1
1
  import type { AbstractType, YArrayEvent } from 'yjs';
2
2
  import * as Y from 'yjs';
3
- import { HocuspocusProvider, HocuspocusProviderConfiguration } from './HocuspocusProvider.js';
3
+ import type { HocuspocusProviderConfiguration } from './HocuspocusProvider.js';
4
+ import { HocuspocusProvider } from './HocuspocusProvider.js';
4
5
  import { TiptapCollabProviderWebsocket } from './TiptapCollabProviderWebsocket.js';
5
6
  import type { TCollabComment, TCollabThread, THistoryVersion } from './types.js';
6
7
  export type TiptapCollabProviderConfiguration = Required<Pick<HocuspocusProviderConfiguration, 'name'>> & Partial<HocuspocusProviderConfiguration> & (Required<Pick<AdditionalTiptapCollabProviderConfiguration, 'websocketProvider'>> | Required<Pick<AdditionalTiptapCollabProviderConfiguration, 'appId'>> | Required<Pick<AdditionalTiptapCollabProviderConfiguration, 'baseUrl'>>) & Pick<AdditionalTiptapCollabProviderConfiguration, 'user'>;
@@ -1,4 +1,5 @@
1
- import { CompleteHocuspocusProviderWebsocketConfiguration, HocuspocusProviderWebsocket } from './HocuspocusProviderWebsocket.js';
1
+ import type { CompleteHocuspocusProviderWebsocketConfiguration } from './HocuspocusProviderWebsocket.js';
2
+ import { HocuspocusProviderWebsocket } from './HocuspocusProviderWebsocket.js';
2
3
  export type TiptapCollabProviderWebsocketConfiguration = Partial<CompleteHocuspocusProviderWebsocketConfiguration> & AdditionalTiptapCollabProviderWebsocketConfiguration;
3
4
  export interface AdditionalTiptapCollabProviderWebsocketConfiguration {
4
5
  /**
@@ -1,16 +1,16 @@
1
- import { Encoder } from 'lib0/encoding';
1
+ import type { Encoder } from 'lib0/encoding';
2
2
  import type { Event, MessageEvent } from 'ws';
3
- import { Awareness } from 'y-protocols/awareness';
4
- import * as Y from 'yjs';
5
- import { CloseEvent } from '@hocuspocus/common';
6
- import { IncomingMessage } from './IncomingMessage.js';
7
- import { OutgoingMessage } from './OutgoingMessage.js';
8
- import { AuthenticationMessage } from './OutgoingMessages/AuthenticationMessage.js';
9
- import { AwarenessMessage } from './OutgoingMessages/AwarenessMessage.js';
10
- import { QueryAwarenessMessage } from './OutgoingMessages/QueryAwarenessMessage.js';
11
- import { SyncStepOneMessage } from './OutgoingMessages/SyncStepOneMessage.js';
12
- import { SyncStepTwoMessage } from './OutgoingMessages/SyncStepTwoMessage.js';
13
- import { UpdateMessage } from './OutgoingMessages/UpdateMessage.js';
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.js';
7
+ import type { OutgoingMessage } from './OutgoingMessage.js';
8
+ import type { AuthenticationMessage } from './OutgoingMessages/AuthenticationMessage.js';
9
+ import type { AwarenessMessage } from './OutgoingMessages/AwarenessMessage.js';
10
+ import type { QueryAwarenessMessage } from './OutgoingMessages/QueryAwarenessMessage.js';
11
+ import type { SyncStepOneMessage } from './OutgoingMessages/SyncStepOneMessage.js';
12
+ import type { SyncStepTwoMessage } from './OutgoingMessages/SyncStepTwoMessage.js';
13
+ import type { UpdateMessage } from './OutgoingMessages/UpdateMessage.js';
14
14
  export declare enum MessageType {
15
15
  Sync = 0,
16
16
  Awareness = 1,
@@ -1,10 +1,9 @@
1
- /// <reference types="node" />
2
- import { IncomingMessage } from 'http';
3
- import WebSocket from 'ws';
4
- import { Debugger } from './Debugger.js';
5
- import Document from './Document.js';
6
- import { Hocuspocus } from './Hocuspocus.js';
7
- import { onDisconnectPayload } from './types.js';
1
+ import type { IncomingMessage } from 'http';
2
+ import type WebSocket from 'ws';
3
+ import type { Debugger } from './Debugger.js';
4
+ import type Document from './Document.js';
5
+ import type { Hocuspocus } from './Hocuspocus.js';
6
+ import type { onDisconnectPayload } from './types.js';
8
7
  /**
9
8
  * The `ClientConnection` class is responsible for handling an incoming WebSocket
10
9
  *
@@ -1,12 +1,10 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import { IncomingMessage as HTTPIncomingMessage } from 'http';
1
+ import type { IncomingMessage as HTTPIncomingMessage } from 'http';
4
2
  import AsyncLock from 'async-lock';
5
- import WebSocket from 'ws';
6
- import { CloseEvent } from '@hocuspocus/common';
7
- import Document from './Document.js';
8
- import { Debugger } from './Debugger.js';
9
- import { onStatelessPayload } from './types.js';
3
+ import type WebSocket from 'ws';
4
+ import type { CloseEvent } from '@hocuspocus/common';
5
+ import type Document from './Document.js';
6
+ import type { Debugger } from './Debugger.js';
7
+ import type { onStatelessPayload } from './types.js';
10
8
  export declare class Connection {
11
9
  webSocket: WebSocket;
12
10
  context: any;
@@ -18,7 +16,7 @@ export declare class Connection {
18
16
  callbacks: any;
19
17
  socketId: string;
20
18
  lock: AsyncLock;
21
- readOnly: Boolean;
19
+ readOnly: boolean;
22
20
  logger: Debugger;
23
21
  /**
24
22
  * Constructor.
@@ -1,4 +1,4 @@
1
- import Document from './Document.js';
1
+ import type Document from './Document.js';
2
2
  import type { Hocuspocus } from './Hocuspocus.js';
3
3
  import type { DirectConnection as DirectConnectionInterface } from './types.js';
4
4
  export declare class DirectConnection implements DirectConnectionInterface {
@@ -1,9 +1,9 @@
1
- import WebSocket from 'ws';
1
+ import type WebSocket from 'ws';
2
2
  import { Awareness } from 'y-protocols/awareness';
3
3
  import { Doc } from 'yjs';
4
- import { mutex } from 'lib0/mutex.js';
5
- import Connection from './Connection.js';
6
- import { Debugger } from './Debugger.js';
4
+ import type { mutex } from 'lib0/mutex.js';
5
+ import type Connection from './Connection.js';
6
+ import type { Debugger } from './Debugger.js';
7
7
  export declare class Document extends Doc {
8
8
  awareness: Awareness;
9
9
  callbacks: {
@@ -23,7 +23,7 @@ export declare class Document extends Doc {
23
23
  /**
24
24
  * Constructor.
25
25
  */
26
- constructor(name: string, logger?: Debugger, yDocOptions?: {});
26
+ constructor(name: string, logger?: Debugger, yDocOptions?: object);
27
27
  /**
28
28
  * Check if the Document (XMLFragment or Map) is empty
29
29
  */
@@ -1,15 +1,12 @@
1
- /// <reference types="node" />
2
- import { IncomingMessage } from 'http';
3
- import WebSocket, { AddressInfo } from 'ws';
4
- import { Server as HocuspocusServer } from './Server.js';
1
+ import type { IncomingMessage } from 'http';
2
+ import type WebSocket from 'ws';
3
+ import type { Server } from './Server.js';
5
4
  import { Debugger } from './Debugger.js';
6
5
  import { DirectConnection } from './DirectConnection.js';
7
6
  import Document from './Document.js';
8
- import { Configuration, ConnectionConfiguration, HookName, HookPayloadByName, onListenPayload, onStoreDocumentPayload } from './types.js';
7
+ import type { Configuration, ConnectionConfiguration, HookName, HookPayloadByName, onStoreDocumentPayload } from './types.js';
9
8
  export declare const defaultConfiguration: {
10
9
  name: null;
11
- port: number;
12
- address: string;
13
10
  timeout: number;
14
11
  debounce: number;
15
12
  maxDebounce: number;
@@ -19,16 +16,12 @@ export declare const defaultConfiguration: {
19
16
  gcFilter: () => boolean;
20
17
  };
21
18
  unloadImmediately: boolean;
22
- stopOnSignals: boolean;
23
19
  };
24
- /**
25
- * Hocuspocus Server
26
- */
27
20
  export declare class Hocuspocus {
28
21
  configuration: Configuration;
29
22
  loadingDocuments: Map<string, Promise<Document>>;
30
23
  documents: Map<string, Document>;
31
- server?: HocuspocusServer;
24
+ server?: Server;
32
25
  debugger: Debugger;
33
26
  debouncer: {
34
27
  debounce: (id: string, func: Function, debounce: number, maxDebounce: number) => any;
@@ -37,19 +30,10 @@ export declare class Hocuspocus {
37
30
  };
38
31
  constructor(configuration?: Partial<Configuration>);
39
32
  /**
40
- * Configure the server
33
+ * Configure Hocuspocus
41
34
  */
42
35
  configure(configuration: Partial<Configuration>): Hocuspocus;
43
36
  get requiresAuthentication(): boolean;
44
- /**
45
- * Start the server
46
- */
47
- listen(portOrCallback?: number | ((data: onListenPayload) => Promise<any>) | null, callback?: any): Promise<Hocuspocus>;
48
- get address(): AddressInfo;
49
- get URL(): string;
50
- get webSocketURL(): string;
51
- get httpURL(): string;
52
- private showStartScreen;
53
37
  /**
54
38
  * Get the total number of active documents
55
39
  */
@@ -62,10 +46,6 @@ export declare class Hocuspocus {
62
46
  * Force close one or more connections
63
47
  */
64
48
  closeConnections(documentName?: string): void;
65
- /**
66
- * Destroy the server
67
- */
68
- destroy(): Promise<any>;
69
49
  /**
70
50
  * The `handleConnection` method receives incoming WebSocket connections,
71
51
  * runs all hooks:
@@ -104,4 +84,3 @@ export declare class Hocuspocus {
104
84
  getMessageLogs(): any[];
105
85
  openDirectConnection(documentName: string, context?: any): Promise<DirectConnection>;
106
86
  }
107
- export declare const Server: Hocuspocus;
@@ -1,6 +1,6 @@
1
- import { Decoder } from 'lib0/decoding';
2
- import { Encoder } from 'lib0/encoding';
3
- import { MessageType } from './types.js';
1
+ import type { Decoder } from 'lib0/decoding';
2
+ import type { Encoder } from 'lib0/encoding';
3
+ import type { MessageType } from './types.js';
4
4
  export declare class IncomingMessage {
5
5
  /**
6
6
  * Access to the received message.
@@ -1,7 +1,7 @@
1
- import Connection from './Connection.js';
2
- import { Debugger } from './Debugger.js';
3
- import Document from './Document.js';
4
- import { IncomingMessage } from './IncomingMessage.js';
1
+ import type Connection from './Connection.js';
2
+ import type { Debugger } from './Debugger.js';
3
+ import type Document from './Document.js';
4
+ import type { IncomingMessage } from './IncomingMessage.js';
5
5
  export declare class MessageReceiver {
6
6
  message: IncomingMessage;
7
7
  logger: Debugger;
@@ -1,6 +1,6 @@
1
- import { Encoder } from 'lib0/encoding';
2
- import { Awareness } from 'y-protocols/awareness';
3
- import Document from './Document.js';
1
+ import type { Encoder } from 'lib0/encoding';
2
+ import type { Awareness } from 'y-protocols/awareness';
3
+ import type Document from './Document.js';
4
4
  export declare class OutgoingMessage {
5
5
  encoder: Encoder;
6
6
  type?: number;
@@ -1,13 +1,32 @@
1
- /// <reference types="node" />
2
- import { IncomingMessage, Server as HTTPServer, ServerResponse } from 'http';
1
+ import type { IncomingMessage, Server as HTTPServer, ServerResponse } from 'http';
2
+ import type { AddressInfo } from 'ws';
3
3
  import { WebSocketServer } from 'ws';
4
4
  import { Hocuspocus } from './Hocuspocus.js';
5
+ import type { Configuration } from './types';
6
+ export interface ServerConfiguration extends Configuration {
7
+ port?: number;
8
+ address?: string;
9
+ stopOnSignals?: boolean;
10
+ }
11
+ export declare const defaultServerConfiguration: {
12
+ port: number;
13
+ address: string;
14
+ stopOnSignals: boolean;
15
+ };
5
16
  export declare class Server {
6
17
  httpServer: HTTPServer;
7
18
  webSocketServer: WebSocketServer;
8
19
  hocuspocus: Hocuspocus;
9
- constructor(hocuspocus: Hocuspocus);
20
+ configuration: ServerConfiguration;
21
+ constructor(configuration?: Partial<ServerConfiguration>);
10
22
  setupWebsocketConnection: () => void;
11
23
  setupHttpUpgrade: () => void;
12
24
  requestHandler: (request: IncomingMessage, response: ServerResponse) => Promise<void>;
25
+ listen(port?: number, callback?: any): Promise<Hocuspocus>;
26
+ get address(): AddressInfo;
27
+ destroy(): Promise<any>;
28
+ get URL(): string;
29
+ get webSocketURL(): string;
30
+ get httpURL(): string;
31
+ private showStartScreen;
13
32
  }
@@ -5,5 +5,6 @@ export * from './Hocuspocus.js';
5
5
  export * from './IncomingMessage.js';
6
6
  export * from './MessageReceiver.js';
7
7
  export * from './OutgoingMessage.js';
8
+ export * from './Server.js';
8
9
  export * from './types.js';
9
10
  export * from './util/debounce.js';
@@ -1,19 +1,16 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
- import { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'http';
5
- import { URLSearchParams } from 'url';
6
- import { Awareness } from 'y-protocols/awareness';
7
- import Connection from './Connection.js';
8
- import Document from './Document.js';
9
- import { Hocuspocus } from './Hocuspocus.js';
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.js';
5
+ import type Document from './Document.js';
6
+ import type { Hocuspocus } from './Hocuspocus.js';
10
7
  export declare enum MessageType {
11
8
  Unknown = -1,
12
9
  Sync = 0,
13
10
  Awareness = 1,
14
11
  Auth = 2,
15
12
  QueryAwareness = 3,
16
- SyncReply = 4,
13
+ SyncReply = 4,// same as Sync, but won't trigger another 'SyncStep1'
17
14
  Stateless = 5,
18
15
  BroadcastStateless = 6,
19
16
  CLOSE = 7,
@@ -85,14 +82,6 @@ export interface Configuration extends Extension {
85
82
  * A list of hocuspocus extensions.
86
83
  */
87
84
  extensions: Array<Extension>;
88
- /**
89
- * The port which the server listens on.
90
- */
91
- port?: number;
92
- /**
93
- * The address which the server listens on.
94
- */
95
- address?: string;
96
85
  /**
97
86
  * Defines in which interval the server sends a ping, and closes the connection when no pong is sent back.
98
87
  */
@@ -118,12 +107,6 @@ export interface Configuration extends Extension {
118
107
  * your onStoreDocument is rate-limited.
119
108
  */
120
109
  unloadImmediately: boolean;
121
- /**
122
- * the server will gracefully stop if SIGINT, SIGQUIT or SIGTERM is received.
123
- *
124
- * Set this to false if you don't want that.
125
- */
126
- stopOnSignals: boolean;
127
110
  /**
128
111
  * options to pass to the ydoc document
129
112
  */
@@ -1,6 +1,4 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import { IncomingMessage } from 'http';
1
+ import type { IncomingMessage } from 'http';
4
2
  import { URLSearchParams } from 'url';
5
3
  /**
6
4
  * Get parameters by the given request
@@ -1,6 +1,6 @@
1
1
  import { Doc } from 'yjs';
2
2
  import { Schema } from '@tiptap/pm/model';
3
- import { Transformer } from './types.js';
3
+ import type { Transformer } from './types.js';
4
4
  declare class Prosemirror implements Transformer {
5
5
  defaultSchema: Schema;
6
6
  schema(schema: Schema): Prosemirror;
@@ -1,6 +1,6 @@
1
- import { Doc } from 'yjs';
2
- import { Extensions } from '@tiptap/core';
3
- import { Transformer } from './types.js';
1
+ import type { Doc } from 'yjs';
2
+ import type { Extensions } from '@tiptap/core';
3
+ import type { Transformer } from './types.js';
4
4
  export declare class Tiptap implements Transformer {
5
5
  defaultExtensions: Extensions;
6
6
  extensions(extensions: Extensions): Tiptap;
@@ -1,4 +1,4 @@
1
- import { Doc } from 'yjs';
1
+ import type { Doc } from 'yjs';
2
2
  export interface Transformer {
3
3
  fromYdoc: (document: Doc, fieldName?: string | Array<string>) => any;
4
4
  toYdoc: (document: any, fieldName: string) => Doc;
@@ -1,2 +1,2 @@
1
- import { Hocuspocus, Configuration } from '@hocuspocus/server';
2
- export declare const newHocuspocus: (options?: Partial<Configuration>) => Promise<Hocuspocus>;
1
+ import type { ServerConfiguration } from '@hocuspocus/server';
2
+ export declare const newHocuspocus: (options?: Partial<ServerConfiguration>) => Promise<import("@hocuspocus/server").Hocuspocus>;
@@ -1,3 +1,3 @@
1
- import { HocuspocusProvider, HocuspocusProviderConfiguration, HocuspocusProviderWebsocketConfiguration } from '@hocuspocus/provider';
2
- import { Hocuspocus } from '@hocuspocus/server';
1
+ import { HocuspocusProvider, type HocuspocusProviderConfiguration, type HocuspocusProviderWebsocketConfiguration } from '@hocuspocus/provider';
2
+ import type { Hocuspocus } from '@hocuspocus/server';
3
3
  export declare const newHocuspocusProvider: (server: Hocuspocus, options?: Partial<HocuspocusProviderConfiguration>, websocketOptions?: Partial<HocuspocusProviderWebsocketConfiguration>) => HocuspocusProvider;
@@ -1,3 +1,4 @@
1
- import { HocuspocusProviderWebsocket, HocuspocusProviderWebsocketConfiguration } from '@hocuspocus/provider';
2
- import { Hocuspocus } from '@hocuspocus/server';
3
- export declare const newHocuspocusProviderWebsocket: (server: Hocuspocus, options?: Partial<Omit<HocuspocusProviderWebsocketConfiguration, 'url'>>) => HocuspocusProviderWebsocket;
1
+ import type { HocuspocusProviderWebsocketConfiguration } from '@hocuspocus/provider';
2
+ import { HocuspocusProviderWebsocket } from '@hocuspocus/provider';
3
+ import type { Hocuspocus } from '@hocuspocus/server';
4
+ export declare const newHocuspocusProviderWebsocket: (hocuspocus: Hocuspocus, options?: Partial<Omit<HocuspocusProviderWebsocketConfiguration, "url">>) => HocuspocusProviderWebsocket;
@@ -1,2 +1,2 @@
1
- import { ExecutionContext } from 'ava';
1
+ import type { ExecutionContext } from 'ava';
2
2
  export declare const retryableAssertion: (t: ExecutionContext, recoverableTry: (tt: ExecutionContext) => void) => Promise<void>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hocuspocus/common",
3
3
  "description": "shared code for multiple Hocuspocus packages",
4
- "version": "2.13.5-rc.0",
4
+ "version": "3.0.0-rc.0",
5
5
  "homepage": "https://hocuspocus.dev",
6
6
  "keywords": [
7
7
  "hocuspocus"