@hocuspocus/extension-webhook 3.3.2 → 3.4.1

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.
@@ -100,7 +100,7 @@ export declare class Redis implements Extension {
100
100
  /**
101
101
  * Handle awareness update messages received directly by this Hocuspocus instance.
102
102
  */
103
- onAwarenessUpdate({ documentName, awareness, added, updated, removed, }: onAwarenessUpdatePayload): Promise<number>;
103
+ onAwarenessUpdate({ documentName, awareness, added, updated, removed, document, }: onAwarenessUpdatePayload): Promise<number | undefined>;
104
104
  /**
105
105
  * Handle incoming messages published on subscribed document channels.
106
106
  * Note that this will also include messages from ourselves as it is not possible
@@ -2,7 +2,7 @@ import type { IncomingMessage as HTTPIncomingMessage } from "node:http";
2
2
  import { type CloseEvent } from "@hocuspocus/common";
3
3
  import type WebSocket from "ws";
4
4
  import type Document from "./Document.ts";
5
- import type { beforeSyncPayload, onTokenSyncPayload, onStatelessPayload } from "./types.ts";
5
+ import type { beforeSyncPayload, onStatelessPayload, onTokenSyncPayload } from "./types.ts";
6
6
  export declare class Connection {
7
7
  webSocket: WebSocket;
8
8
  context: any;
@@ -38,8 +38,8 @@ export declare class Connection {
38
38
  */
39
39
  beforeSync(callback: (connection: Connection, payload: Pick<beforeSyncPayload, "type" | "payload">) => Promise<any>): Connection;
40
40
  /**
41
- * Set a callback that will be triggered when on token sync message is received
42
- */
41
+ * Set a callback that will be triggered when on token sync message is received
42
+ */
43
43
  onTokenSyncCallback(callback: (payload: onTokenSyncPayload) => Promise<void>): Connection;
44
44
  /**
45
45
  * Send the given message
@@ -1,8 +1,8 @@
1
+ import { Mutex } from "async-mutex";
1
2
  import type WebSocket from "ws";
2
3
  import { Awareness } from "y-protocols/awareness";
3
4
  import { Doc } from "yjs";
4
5
  import type Connection from "./Connection.ts";
5
- import { Mutex } from "async-mutex";
6
6
  export declare class Document extends Doc {
7
7
  awareness: Awareness;
8
8
  callbacks: {
@@ -18,6 +18,7 @@ export declare class Document extends Doc {
18
18
  isLoading: boolean;
19
19
  isDestroyed: boolean;
20
20
  saveMutex: Mutex;
21
+ lastChangeTime: number;
21
22
  /**
22
23
  * Constructor.
23
24
  */
@@ -23,8 +23,9 @@ export declare class Hocuspocus {
23
23
  documents: Map<string, Document>;
24
24
  server?: Server;
25
25
  debouncer: {
26
- debounce: (id: string, func: Function, debounce: number, maxDebounce: number) => any;
26
+ debounce: (id: string, func: () => any | Promise<() => any>, debounce: number, maxDebounce: number) => Promise<any>;
27
27
  isDebounced: (id: string) => boolean;
28
+ isCurrentlyExecuting: (id: string) => boolean;
28
29
  executeNow: (id: string) => any;
29
30
  };
30
31
  constructor(configuration?: Partial<Configuration>);
@@ -67,12 +68,13 @@ export declare class Hocuspocus {
67
68
  */
68
69
  createDocument(documentName: string, request: Partial<Pick<IncomingMessage, "headers" | "url">>, socketId: string, connection: ConnectionConfiguration, context?: any): Promise<Document>;
69
70
  loadDocument(documentName: string, request: Partial<Pick<IncomingMessage, "headers" | "url">>, socketId: string, connectionConfig: ConnectionConfiguration, context?: any): Promise<Document>;
70
- storeDocumentHooks(document: Document, hookPayload: onStoreDocumentPayload, immediately?: boolean): any;
71
+ storeDocumentHooks(document: Document, hookPayload: onStoreDocumentPayload, immediately?: boolean): Promise<any>;
71
72
  /**
72
73
  * Run the given hook on all configured extensions.
73
74
  * Runs the given callback after each hook.
74
75
  */
75
76
  hooks<T extends HookName>(name: T, payload: HookPayloadByName[T], callback?: Function | null): Promise<any>;
77
+ shouldUnloadDocument(document: Document): boolean;
76
78
  unloadDocument(document: Document): Promise<any>;
77
79
  openDirectConnection(documentName: string, context?: any): Promise<DirectConnection>;
78
80
  }
@@ -5,7 +5,7 @@ export declare class MessageReceiver {
5
5
  message: IncomingMessage;
6
6
  defaultTransactionOrigin?: string;
7
7
  constructor(message: IncomingMessage, defaultTransactionOrigin?: string);
8
- apply(document: Document, connection?: Connection, reply?: (message: Uint8Array) => void): Promise<void>;
9
- readSyncMessage(message: IncomingMessage, document: Document, connection?: Connection, reply?: (message: Uint8Array) => void, requestFirstSync?: boolean): Promise<0 | 1 | 2>;
8
+ apply(document: Document, connection?: Connection, reply?: (message: Uint8Array) => void): void;
9
+ readSyncMessage(message: IncomingMessage, document: Document, connection?: Connection, reply?: (message: Uint8Array) => void, requestFirstSync?: boolean): 0 | 1 | 2;
10
10
  applyQueryAwarenessMessage(document: Document, reply?: (message: Uint8Array) => void): void;
11
11
  }
@@ -1,5 +1,6 @@
1
1
  export declare const useDebounce: () => {
2
- debounce: (id: string, func: Function, debounce: number, maxDebounce: number) => any;
2
+ debounce: (id: string, func: () => any | Promise<() => any>, debounce: number, maxDebounce: number) => Promise<any>;
3
3
  isDebounced: (id: string) => boolean;
4
+ isCurrentlyExecuting: (id: string) => boolean;
4
5
  executeNow: (id: string) => any;
5
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hocuspocus/extension-webhook",
3
- "version": "3.3.2",
3
+ "version": "3.4.1",
4
4
  "description": "hocuspocus webhook extension",
5
5
  "homepage": "https://hocuspocus.dev",
6
6
  "keywords": [
@@ -30,9 +30,9 @@
30
30
  "dist"
31
31
  ],
32
32
  "dependencies": {
33
- "@hocuspocus/common": "^3.3.2",
34
- "@hocuspocus/server": "^3.3.2",
35
- "@hocuspocus/transformer": "^3.3.2",
33
+ "@hocuspocus/common": "^3.4.1",
34
+ "@hocuspocus/server": "^3.4.1",
35
+ "@hocuspocus/transformer": "^3.4.1",
36
36
  "axios": "^1.12.2"
37
37
  },
38
38
  "peerDependencies": {