@hocuspocus/extension-throttle 2.0.0 → 2.0.2

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.
@@ -39,7 +39,7 @@ export declare class Connection {
39
39
  /**
40
40
  * Set a callback that will be triggered before an message is handled
41
41
  */
42
- beforeHandleMessage(callback: (payload: Document, update: Uint8Array) => Promise<any>): Connection;
42
+ beforeHandleMessage(callback: (connection: Connection, update: Uint8Array) => Promise<any>): Connection;
43
43
  /**
44
44
  * Send the given message
45
45
  */
@@ -176,6 +176,7 @@ export interface beforeHandleMessagePayload {
176
176
  requestParameters: URLSearchParams;
177
177
  update: Uint8Array;
178
178
  socketId: string;
179
+ connection: Connection;
179
180
  }
180
181
  export interface beforeBroadcastStatelessPayload {
181
182
  document: Document;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ declare const _default: import("vite").UserConfigExport;
2
+ export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hocuspocus/extension-throttle",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "hocuspocus throttle extension",
5
5
  "homepage": "https://hocuspocus.dev",
6
6
  "keywords": [
@@ -27,7 +27,7 @@
27
27
  "dist"
28
28
  ],
29
29
  "dependencies": {
30
- "@hocuspocus/server": "^2.0.0"
30
+ "@hocuspocus/server": "^2.0.2"
31
31
  },
32
32
  "gitHead": "b3454a4ca289a84ddfb7fa5607a2d4b8d5c37e9d"
33
33
  }
@@ -1,61 +0,0 @@
1
- /// <reference types="node" />
2
- import { Configuration, onConnectPayload, onDisconnectPayload, onLoadDocumentPayload, onChangePayload } from '@hocuspocus/server';
3
- export declare class Collector {
4
- serverConfiguration: Partial<Configuration>;
5
- version: string;
6
- connections: {};
7
- messages: {};
8
- messageCounter: number;
9
- memory(): Promise<{
10
- free: number;
11
- total: number;
12
- usage: number;
13
- }>;
14
- cpu(): Promise<{
15
- count: number;
16
- model: string;
17
- usage: number;
18
- }>;
19
- connect(data: onConnectPayload): {
20
- action: string;
21
- documentName: string;
22
- socketId: string;
23
- };
24
- disconnect(data: onDisconnectPayload): {
25
- action: string;
26
- documentName: string;
27
- socketId: string;
28
- };
29
- connectionCount(): {
30
- count: string | number;
31
- };
32
- createDocument(data: onLoadDocumentPayload): {
33
- action: string;
34
- document: any;
35
- documentName: string;
36
- socketId: string;
37
- };
38
- changeDocument(data: onChangePayload): {
39
- action: string;
40
- document: any;
41
- documentName: string;
42
- socketId: string;
43
- };
44
- messageCount(): {
45
- count: number;
46
- };
47
- documentCount(): {
48
- count: number;
49
- };
50
- documents(): {};
51
- info(): Promise<{
52
- configuration: Partial<Configuration>;
53
- ipAddress: string | null;
54
- nodeVersion: string;
55
- platform: NodeJS.Platform;
56
- started: string;
57
- version: string;
58
- }>;
59
- private getIpAddress;
60
- private static readableYDoc;
61
- }
@@ -1,30 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import { IncomingMessage, ServerResponse } from 'http';
4
- import { Socket } from 'net';
5
- import WebSocket, { WebSocketServer } from 'ws';
6
- import { Storage } from './Storage';
7
- export interface Configuration {
8
- password: string | undefined;
9
- path: string;
10
- port: number | undefined;
11
- storage: Storage | undefined;
12
- user: string | undefined;
13
- }
14
- export declare class Dashboard {
15
- configuration: Configuration;
16
- websocketServer: WebSocketServer;
17
- connections: Map<WebSocket, any>;
18
- /**
19
- * Constructor
20
- */
21
- constructor(configuration?: Partial<Configuration>);
22
- createServer(): void;
23
- handleRequest(request: IncomingMessage, response: ServerResponse): boolean;
24
- handleUpgrade(request: IncomingMessage, socket: Socket, head: any): boolean;
25
- handleConnection(connection: WebSocket, request: IncomingMessage): void;
26
- close(connection: WebSocket): void;
27
- send(message: string): void;
28
- private sendInitialDataToClient;
29
- private basicAuth;
30
- }
@@ -1,35 +0,0 @@
1
- /// <reference types="node" />
2
- import EventEmitter from 'events';
3
- export declare class Storage extends EventEmitter {
4
- timed: Map<string, any>;
5
- constant: Map<string, any>;
6
- /**
7
- * Get all constant values.
8
- */
9
- all(): Promise<any>;
10
- /**
11
- * Get a constant value by the given key.
12
- */
13
- get(key: string, defaultValue?: any): Promise<any>;
14
- /**
15
- * Set a constant value by the given key.
16
- */
17
- set(key: string, value: any): Promise<any>;
18
- /**
19
- * Delete a constant value by the given key.
20
- * @param key
21
- */
22
- delete(key: string): Promise<any>;
23
- /**
24
- * Get all timed values.
25
- */
26
- allTimed(): Promise<any>;
27
- /**
28
- * Add a timed value by the given key.
29
- */
30
- add(key: string, value: any): Promise<any>;
31
- /**
32
- * Remove a timed value by the given timestamp and key.
33
- */
34
- remove(key: string, timestamp: string): Promise<any>;
35
- }
@@ -1,38 +0,0 @@
1
- /// <reference types="node" />
2
- import { IncomingMessage, ServerResponse } from 'http';
3
- import { Extension, onChangePayload, onConfigurePayload, onLoadDocumentPayload, onDisconnectPayload, onRequestPayload, onUpgradePayload, connectedPayload } from '@hocuspocus/server';
4
- import WebSocket from 'ws';
5
- import { Storage } from './Storage';
6
- import { Dashboard } from './Dashboard';
7
- import { Collector } from './Collector';
8
- export interface Configuration {
9
- dashboardPath: string;
10
- enableDashboard: boolean;
11
- metricsInterval: number;
12
- osMetricsInterval: number;
13
- password: string | undefined;
14
- port: number | undefined;
15
- user: string | undefined;
16
- }
17
- export declare class Monitor implements Extension {
18
- configuration: Configuration;
19
- storage: Storage;
20
- collector: Collector;
21
- dashboard?: Dashboard;
22
- /**
23
- * Constructor
24
- */
25
- constructor(configuration?: Partial<Configuration>);
26
- private collectOsMetrics;
27
- private collectConnectionMetrics;
28
- private cleanMetrics;
29
- handleRequest(request: IncomingMessage, response: ServerResponse): boolean | undefined;
30
- handleConnection(websocket: WebSocket, request: IncomingMessage): void | undefined;
31
- onRequest({ request, response }: onRequestPayload): Promise<void>;
32
- onUpgrade({ request, socket, head }: onUpgradePayload): Promise<void>;
33
- connected(data: connectedPayload): Promise<void>;
34
- onDisconnect(data: onDisconnectPayload): Promise<void>;
35
- onLoadDocument(data: onLoadDocumentPayload): Promise<void>;
36
- onChange(data: onChangePayload): Promise<void>;
37
- onConfigure(data: onConfigurePayload): Promise<void>;
38
- }