@hocuspocus/provider 3.3.1 → 3.4.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.
@@ -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
  }
@@ -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/provider",
3
- "version": "3.3.1",
3
+ "version": "3.4.0",
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.3.1",
32
+ "@hocuspocus/common": "^3.4.0",
33
33
  "@lifeomic/attempt": "^3.0.2",
34
34
  "lib0": "^0.2.87",
35
35
  "ws": "^8.17.1"