@hocuspocus/extension-logger 1.0.0-alpha.73 → 1.0.0-alpha.76
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-logger.cjs.map +1 -1
- package/dist/hocuspocus-logger.esm.js.map +1 -1
- package/dist/packages/extension-database/src/Database.d.ts +3 -5
- package/dist/packages/extension-monitor/src/Collector.d.ts +2 -1
- package/dist/packages/extension-redis/src/Redis.d.ts +2 -2
- package/dist/packages/server/src/Hocuspocus.d.ts +2 -2
- package/dist/packages/server/src/types.d.ts +17 -5
- package/dist/tests/extension-database/fetch.d.ts +1 -0
- package/dist/tests/utils/index.d.ts +1 -0
- package/dist/tests/utils/randomInteger.d.ts +1 -0
- package/package.json +4 -4
- package/src/Logger.ts +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hocuspocus-logger.cjs","sources":["../src/Logger.ts"],"sourcesContent":["import {\n Extension,\n onChangePayload,\n onConfigurePayload,\n onConnectPayload,\n onLoadDocumentPayload,\n onDestroyPayload,\n onDisconnectPayload,\n onRequestPayload,\n onUpgradePayload,\n} from '@hocuspocus/server'\n\nexport interface LoggerConfiguration {\n /**\n * Prepend all logging message with a string.\n *\n * @deprecated\n */\n prefix: null | string,\n /**\n * Whether to log something for the `onLoadDocument` hook.\n */\n onLoadDocument: boolean,\n /**\n * Whether to log something for the `onChange` hook.\n */\n onChange: boolean,\n /**\n * Whether to log something for the `onStoreDocument` hook.\n */\n onStoreDocument: boolean,\n /**\n * Whether to log something for the `onConnect` hook.\n */\n onConnect: boolean,\n /**\n * Whether to log something for the `onDisconnect` hook.\n */\n onDisconnect: boolean,\n /**\n * Whether to log something for the `onUpgrade` hook.\n */\n onUpgrade: boolean,\n /**\n * Whether to log something for the `onRequest` hook.\n */\n onRequest: boolean,\n /**\n * Whether to log something for the `onDestroy` hook.\n */\n onDestroy: boolean,\n /**\n * Whether to log something for the `onConfigure` hook.\n */\n onConfigure: boolean,\n /**\n * A log function, if none is provided output will go to console\n */\n log: (...args: any[]) => void,\n}\n\nexport class Logger implements Extension {\n name: string | null = null\n\n configuration: LoggerConfiguration = {\n prefix: null,\n onLoadDocument: true,\n onChange: true,\n onStoreDocument: true,\n onConnect: true,\n onDisconnect: true,\n onUpgrade: true,\n onRequest: true,\n onDestroy: true,\n onConfigure: true,\n log: console.log, // eslint-disable-line\n }\n\n /**\n * Constructor\n */\n constructor(configuration?: Partial<LoggerConfiguration>) {\n this.configuration = {\n ...this.configuration,\n ...configuration,\n }\n }\n\n async onConfigure(data: onConfigurePayload) {\n this.name = data.instance.configuration.name\n\n if (!this.configuration.onConfigure) {\n return\n }\n\n if (this.configuration.prefix) {\n console.warn('[hocuspocus warn] The Logger \\'prefix\\' is deprecated. Pass a \\'name\\' to the Hocuspocus configuration instead.')\n }\n }\n\n async onLoadDocument(data: onLoadDocumentPayload) {\n if (this.configuration.onLoadDocument) {\n this.log(`Loaded document \"${data.documentName}\".`)\n }\n }\n\n async onChange(data: onChangePayload) {\n if (this.configuration.onChange) {\n this.log(`Document \"${data.documentName}\" changed.`)\n }\n }\n\n async onStoreDocument(data: onDisconnectPayload) {\n if (this.configuration.onStoreDocument) {\n this.log(`Store \"${data.documentName}\".`)\n }\n }\n\n async onConnect(data: onConnectPayload) {\n if (this.configuration.onConnect) {\n this.log(`New connection to \"${data.documentName}\".`)\n }\n }\n\n async onDisconnect(data: onDisconnectPayload) {\n if (this.configuration.onDisconnect) {\n this.log(`Connection to \"${data.documentName}\" closed.`)\n }\n }\n\n async onUpgrade(data: onUpgradePayload) {\n if (this.configuration.onUpgrade) {\n this.log('Upgrading connection …')\n }\n }\n\n async onRequest(data: onRequestPayload) {\n if (this.configuration.onRequest) {\n this.log(`Incoming HTTP Request to ${data.request.url}`)\n }\n }\n\n async onDestroy(data: onDestroyPayload) {\n if (this.configuration.onDestroy) {\n this.log('Shut down.')\n }\n }\n\n private log(message: string) {\n const date = (new Date()).toISOString()\n let meta = `${date}`\n\n if (this.name) {\n meta = `${this.name} ${meta}`\n }\n\n message = `[${meta}] ${message}`\n\n this.configuration.log(message)\n }\n
|
|
1
|
+
{"version":3,"file":"hocuspocus-logger.cjs","sources":["../src/Logger.ts"],"sourcesContent":["import {\n Extension,\n onChangePayload,\n onConfigurePayload,\n onConnectPayload,\n onLoadDocumentPayload,\n onDestroyPayload,\n onDisconnectPayload,\n onRequestPayload,\n onUpgradePayload,\n} from '@hocuspocus/server'\n\nexport interface LoggerConfiguration {\n /**\n * Prepend all logging message with a string.\n *\n * @deprecated\n */\n prefix: null | string,\n /**\n * Whether to log something for the `onLoadDocument` hook.\n */\n onLoadDocument: boolean,\n /**\n * Whether to log something for the `onChange` hook.\n */\n onChange: boolean,\n /**\n * Whether to log something for the `onStoreDocument` hook.\n */\n onStoreDocument: boolean,\n /**\n * Whether to log something for the `onConnect` hook.\n */\n onConnect: boolean,\n /**\n * Whether to log something for the `onDisconnect` hook.\n */\n onDisconnect: boolean,\n /**\n * Whether to log something for the `onUpgrade` hook.\n */\n onUpgrade: boolean,\n /**\n * Whether to log something for the `onRequest` hook.\n */\n onRequest: boolean,\n /**\n * Whether to log something for the `onDestroy` hook.\n */\n onDestroy: boolean,\n /**\n * Whether to log something for the `onConfigure` hook.\n */\n onConfigure: boolean,\n /**\n * A log function, if none is provided output will go to console\n */\n log: (...args: any[]) => void,\n}\n\nexport class Logger implements Extension {\n name: string | null = null\n\n configuration: LoggerConfiguration = {\n prefix: null,\n onLoadDocument: true,\n onChange: true,\n onStoreDocument: true,\n onConnect: true,\n onDisconnect: true,\n onUpgrade: true,\n onRequest: true,\n onDestroy: true,\n onConfigure: true,\n log: console.log, // eslint-disable-line\n }\n\n /**\n * Constructor\n */\n constructor(configuration?: Partial<LoggerConfiguration>) {\n this.configuration = {\n ...this.configuration,\n ...configuration,\n }\n }\n\n async onConfigure(data: onConfigurePayload) {\n this.name = data.instance.configuration.name\n\n if (!this.configuration.onConfigure) {\n return\n }\n\n if (this.configuration.prefix) {\n console.warn('[hocuspocus warn] The Logger \\'prefix\\' is deprecated. Pass a \\'name\\' to the Hocuspocus configuration instead.')\n }\n }\n\n async onLoadDocument(data: onLoadDocumentPayload) {\n if (this.configuration.onLoadDocument) {\n this.log(`Loaded document \"${data.documentName}\".`)\n }\n }\n\n async onChange(data: onChangePayload) {\n if (this.configuration.onChange) {\n this.log(`Document \"${data.documentName}\" changed.`)\n }\n }\n\n async onStoreDocument(data: onDisconnectPayload) {\n if (this.configuration.onStoreDocument) {\n this.log(`Store \"${data.documentName}\".`)\n }\n }\n\n async onConnect(data: onConnectPayload) {\n if (this.configuration.onConnect) {\n this.log(`New connection to \"${data.documentName}\".`)\n }\n }\n\n async onDisconnect(data: onDisconnectPayload) {\n if (this.configuration.onDisconnect) {\n this.log(`Connection to \"${data.documentName}\" closed.`)\n }\n }\n\n async onUpgrade(data: onUpgradePayload) {\n if (this.configuration.onUpgrade) {\n this.log('Upgrading connection …')\n }\n }\n\n async onRequest(data: onRequestPayload) {\n if (this.configuration.onRequest) {\n this.log(`Incoming HTTP Request to ${data.request.url}`)\n }\n }\n\n async onDestroy(data: onDestroyPayload) {\n if (this.configuration.onDestroy) {\n this.log('Shut down.')\n }\n }\n\n private log(message: string) {\n const date = (new Date()).toISOString()\n let meta = `${date}`\n\n if (this.name) {\n meta = `${this.name} ${meta}`\n }\n\n message = `[${meta}] ${message}`\n\n this.configuration.log(message)\n }\n}\n"],"names":[],"mappings":";;;;MA6Da,MAAM,CAAA;AAiBjB;;AAEG;AACH,IAAA,WAAA,CAAY,aAA4C,EAAA;QAnBxD,IAAI,CAAA,IAAA,GAAkB,IAAI,CAAA;AAE1B,QAAA,IAAA,CAAA,aAAa,GAAwB;AACnC,YAAA,MAAM,EAAE,IAAI;AACZ,YAAA,cAAc,EAAE,IAAI;AACpB,YAAA,QAAQ,EAAE,IAAI;AACd,YAAA,eAAe,EAAE,IAAI;AACrB,YAAA,SAAS,EAAE,IAAI;AACf,YAAA,YAAY,E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9B,SAAA;AAED,QAAA,OAAO,GAAG,CAAI,CAAA,EAAA,IAAI,CAAK,EAAA,EAAA,OAAO,EAAE,CAAA;AAEhC,QAAA,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;KAChC;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hocuspocus-logger.esm.js","sources":["../src/Logger.ts"],"sourcesContent":["import {\n Extension,\n onChangePayload,\n onConfigurePayload,\n onConnectPayload,\n onLoadDocumentPayload,\n onDestroyPayload,\n onDisconnectPayload,\n onRequestPayload,\n onUpgradePayload,\n} from '@hocuspocus/server'\n\nexport interface LoggerConfiguration {\n /**\n * Prepend all logging message with a string.\n *\n * @deprecated\n */\n prefix: null | string,\n /**\n * Whether to log something for the `onLoadDocument` hook.\n */\n onLoadDocument: boolean,\n /**\n * Whether to log something for the `onChange` hook.\n */\n onChange: boolean,\n /**\n * Whether to log something for the `onStoreDocument` hook.\n */\n onStoreDocument: boolean,\n /**\n * Whether to log something for the `onConnect` hook.\n */\n onConnect: boolean,\n /**\n * Whether to log something for the `onDisconnect` hook.\n */\n onDisconnect: boolean,\n /**\n * Whether to log something for the `onUpgrade` hook.\n */\n onUpgrade: boolean,\n /**\n * Whether to log something for the `onRequest` hook.\n */\n onRequest: boolean,\n /**\n * Whether to log something for the `onDestroy` hook.\n */\n onDestroy: boolean,\n /**\n * Whether to log something for the `onConfigure` hook.\n */\n onConfigure: boolean,\n /**\n * A log function, if none is provided output will go to console\n */\n log: (...args: any[]) => void,\n}\n\nexport class Logger implements Extension {\n name: string | null = null\n\n configuration: LoggerConfiguration = {\n prefix: null,\n onLoadDocument: true,\n onChange: true,\n onStoreDocument: true,\n onConnect: true,\n onDisconnect: true,\n onUpgrade: true,\n onRequest: true,\n onDestroy: true,\n onConfigure: true,\n log: console.log, // eslint-disable-line\n }\n\n /**\n * Constructor\n */\n constructor(configuration?: Partial<LoggerConfiguration>) {\n this.configuration = {\n ...this.configuration,\n ...configuration,\n }\n }\n\n async onConfigure(data: onConfigurePayload) {\n this.name = data.instance.configuration.name\n\n if (!this.configuration.onConfigure) {\n return\n }\n\n if (this.configuration.prefix) {\n console.warn('[hocuspocus warn] The Logger \\'prefix\\' is deprecated. Pass a \\'name\\' to the Hocuspocus configuration instead.')\n }\n }\n\n async onLoadDocument(data: onLoadDocumentPayload) {\n if (this.configuration.onLoadDocument) {\n this.log(`Loaded document \"${data.documentName}\".`)\n }\n }\n\n async onChange(data: onChangePayload) {\n if (this.configuration.onChange) {\n this.log(`Document \"${data.documentName}\" changed.`)\n }\n }\n\n async onStoreDocument(data: onDisconnectPayload) {\n if (this.configuration.onStoreDocument) {\n this.log(`Store \"${data.documentName}\".`)\n }\n }\n\n async onConnect(data: onConnectPayload) {\n if (this.configuration.onConnect) {\n this.log(`New connection to \"${data.documentName}\".`)\n }\n }\n\n async onDisconnect(data: onDisconnectPayload) {\n if (this.configuration.onDisconnect) {\n this.log(`Connection to \"${data.documentName}\" closed.`)\n }\n }\n\n async onUpgrade(data: onUpgradePayload) {\n if (this.configuration.onUpgrade) {\n this.log('Upgrading connection …')\n }\n }\n\n async onRequest(data: onRequestPayload) {\n if (this.configuration.onRequest) {\n this.log(`Incoming HTTP Request to ${data.request.url}`)\n }\n }\n\n async onDestroy(data: onDestroyPayload) {\n if (this.configuration.onDestroy) {\n this.log('Shut down.')\n }\n }\n\n private log(message: string) {\n const date = (new Date()).toISOString()\n let meta = `${date}`\n\n if (this.name) {\n meta = `${this.name} ${meta}`\n }\n\n message = `[${meta}] ${message}`\n\n this.configuration.log(message)\n }\n
|
|
1
|
+
{"version":3,"file":"hocuspocus-logger.esm.js","sources":["../src/Logger.ts"],"sourcesContent":["import {\n Extension,\n onChangePayload,\n onConfigurePayload,\n onConnectPayload,\n onLoadDocumentPayload,\n onDestroyPayload,\n onDisconnectPayload,\n onRequestPayload,\n onUpgradePayload,\n} from '@hocuspocus/server'\n\nexport interface LoggerConfiguration {\n /**\n * Prepend all logging message with a string.\n *\n * @deprecated\n */\n prefix: null | string,\n /**\n * Whether to log something for the `onLoadDocument` hook.\n */\n onLoadDocument: boolean,\n /**\n * Whether to log something for the `onChange` hook.\n */\n onChange: boolean,\n /**\n * Whether to log something for the `onStoreDocument` hook.\n */\n onStoreDocument: boolean,\n /**\n * Whether to log something for the `onConnect` hook.\n */\n onConnect: boolean,\n /**\n * Whether to log something for the `onDisconnect` hook.\n */\n onDisconnect: boolean,\n /**\n * Whether to log something for the `onUpgrade` hook.\n */\n onUpgrade: boolean,\n /**\n * Whether to log something for the `onRequest` hook.\n */\n onRequest: boolean,\n /**\n * Whether to log something for the `onDestroy` hook.\n */\n onDestroy: boolean,\n /**\n * Whether to log something for the `onConfigure` hook.\n */\n onConfigure: boolean,\n /**\n * A log function, if none is provided output will go to console\n */\n log: (...args: any[]) => void,\n}\n\nexport class Logger implements Extension {\n name: string | null = null\n\n configuration: LoggerConfiguration = {\n prefix: null,\n onLoadDocument: true,\n onChange: true,\n onStoreDocument: true,\n onConnect: true,\n onDisconnect: true,\n onUpgrade: true,\n onRequest: true,\n onDestroy: true,\n onConfigure: true,\n log: console.log, // eslint-disable-line\n }\n\n /**\n * Constructor\n */\n constructor(configuration?: Partial<LoggerConfiguration>) {\n this.configuration = {\n ...this.configuration,\n ...configuration,\n }\n }\n\n async onConfigure(data: onConfigurePayload) {\n this.name = data.instance.configuration.name\n\n if (!this.configuration.onConfigure) {\n return\n }\n\n if (this.configuration.prefix) {\n console.warn('[hocuspocus warn] The Logger \\'prefix\\' is deprecated. Pass a \\'name\\' to the Hocuspocus configuration instead.')\n }\n }\n\n async onLoadDocument(data: onLoadDocumentPayload) {\n if (this.configuration.onLoadDocument) {\n this.log(`Loaded document \"${data.documentName}\".`)\n }\n }\n\n async onChange(data: onChangePayload) {\n if (this.configuration.onChange) {\n this.log(`Document \"${data.documentName}\" changed.`)\n }\n }\n\n async onStoreDocument(data: onDisconnectPayload) {\n if (this.configuration.onStoreDocument) {\n this.log(`Store \"${data.documentName}\".`)\n }\n }\n\n async onConnect(data: onConnectPayload) {\n if (this.configuration.onConnect) {\n this.log(`New connection to \"${data.documentName}\".`)\n }\n }\n\n async onDisconnect(data: onDisconnectPayload) {\n if (this.configuration.onDisconnect) {\n this.log(`Connection to \"${data.documentName}\" closed.`)\n }\n }\n\n async onUpgrade(data: onUpgradePayload) {\n if (this.configuration.onUpgrade) {\n this.log('Upgrading connection …')\n }\n }\n\n async onRequest(data: onRequestPayload) {\n if (this.configuration.onRequest) {\n this.log(`Incoming HTTP Request to ${data.request.url}`)\n }\n }\n\n async onDestroy(data: onDestroyPayload) {\n if (this.configuration.onDestroy) {\n this.log('Shut down.')\n }\n }\n\n private log(message: string) {\n const date = (new Date()).toISOString()\n let meta = `${date}`\n\n if (this.name) {\n meta = `${this.name} ${meta}`\n }\n\n message = `[${meta}] ${message}`\n\n this.configuration.log(message)\n }\n}\n"],"names":[],"mappings":"MA6Da,MAAM,CAAA;AAiBjB;;AAEG;AACH,IAAA,WAAA,CAAY,aAA4C,EAAA;QAnBxD,IAAI,CAAA,IAAA,GAAkB,IAAI,CAAA;AAE1B,QAAA,IAAA,CAAA,aAAa,GAAwB;AACnC,YAAA,MAAM,EAAE,IAAI;AACZ,YAAA,cAAc,EAAE,IAAI;AACpB,YAAA,QAAQ,EAAE,IAAI;AACd,YAAA,eAAe,EAAE,IAAI;AACrB,YAAA,SAAS,EAAE,IAAI;AACf,YAAA,YAAY,EAAE,IAAI;AAClB,YAAA,SAAS,EAAE,IAAI;AACf,YAAA,SAAS,EAAE,IAAI;AACf,YAAA,SAAS,EAAE,IAAI;AACf,YAAA,WAAW,EAAE,IAAI;AACjB,YAAA,GAAG,EAAE,OAAO,CAAC,GAAG;SACjB,CAAA;QAMC,IAAI,CAAC,aAAa,GAAG;YACnB,GAAG,IAAI,CAAC,aAAa;AACrB,YAAA,GAAG,aAAa;SACjB,CAAA;KACF;IAED,MAAM,WAAW,CAAC,IAAwB,EAAA;QACxC,IA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AA,eAAA,EAAkB,IAAI,CAAC,YAAY,CAAW,SAAA,CAAA,CAAC,CAAA;AACzD,SAAA;KACF;IAED,MAAM,SAAS,CAAC,IAAsB,EAAA;AACpC,QAAA,IAAI,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE;AAChC,YAAA,IAAI,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAA;AACnC,SAAA;KACF;IAED,MAAM,SAAS,CAAC,IAAsB,EAAA;AACpC,QAAA,IAAI,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE;YAChC,IAAI,CAAC,GAAG,CAAC,CAA4B,yBAAA,EAAA,IAAI,CAAC,OAAO,CAAC,GAAG,CAAE,CAAA,CAAC,CAAA;AACzD,SAAA;KACF;IAED,MAAM,SAAS,CAAC,IAAsB,EAAA;AACpC,QAAA,IAAI,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE;AAChC,YAAA,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;AACvB,SAAA;KACF;AAEO,IAAA,GAAG,CAAC,OAAe,EAAA;QACzB,MAAM,IAAI,GAAG,CAAC,IAAI,IAAI,EAAE,EAAE,WAAW,EAAE,CAAA;AACvC,QAAA,IAAI,IAAI,GAAG,CAAG,EAAA,IAAI,EAAE,CAAA;QAEpB,IAAI,IAAI,CAAC,IAAI,EAAE;YACb,IAAI,GAAG,GAAG,IAAI,CAAC,IAAI,CAAI,CAAA,EAAA,IAAI,EAAE,CAAA;AAC9B,SAAA;AAED,QAAA,OAAO,GAAG,CAAI,CAAA,EAAA,IAAI,CAAK,EAAA,EAAA,OAAO,EAAE,CAAA;AAEhC,QAAA,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;KAChC;AACF;;;;"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { Extension, onChangePayload, onLoadDocumentPayload, storePayload } from '@hocuspocus/server';
|
|
1
|
+
import { 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
|
|
5
5
|
* an array of items with Y.js-compatible binary data.
|
|
6
6
|
*/
|
|
7
|
-
fetch: (
|
|
8
|
-
documentName: string;
|
|
9
|
-
}) => Promise<Uint8Array | null>;
|
|
7
|
+
fetch: (data: fetchPayload) => Promise<Uint8Array | null>;
|
|
10
8
|
/**
|
|
11
9
|
* Pass a function to store updates in your database.
|
|
12
10
|
*/
|
|
@@ -24,7 +22,7 @@ export declare class Database implements Extension {
|
|
|
24
22
|
/**
|
|
25
23
|
* Get stored data from the database.
|
|
26
24
|
*/
|
|
27
|
-
onLoadDocument(
|
|
25
|
+
onLoadDocument(data: onLoadDocumentPayload): Promise<any>;
|
|
28
26
|
/**
|
|
29
27
|
* Store new updates in the database.
|
|
30
28
|
*/
|
|
@@ -50,11 +50,12 @@ export declare class Collector {
|
|
|
50
50
|
documents(): {};
|
|
51
51
|
info(): Promise<{
|
|
52
52
|
configuration: Partial<Configuration>;
|
|
53
|
-
ipAddress: string;
|
|
53
|
+
ipAddress: string | null;
|
|
54
54
|
nodeVersion: string;
|
|
55
55
|
platform: NodeJS.Platform;
|
|
56
56
|
started: string;
|
|
57
57
|
version: string;
|
|
58
58
|
}>;
|
|
59
|
+
private getIpAddress;
|
|
59
60
|
private static readableYDoc;
|
|
60
61
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import RedisClient from 'ioredis';
|
|
2
2
|
import Redlock from 'redlock';
|
|
3
|
-
import { Document, Extension, afterLoadDocumentPayload, afterStoreDocumentPayload, onDisconnectPayload, onStoreDocumentPayload, onAwarenessUpdatePayload, Debugger, onConfigurePayload } from '@hocuspocus/server';
|
|
3
|
+
import { Document, Extension, afterLoadDocumentPayload, afterStoreDocumentPayload, onDisconnectPayload, onStoreDocumentPayload, onAwarenessUpdatePayload, Debugger, onConfigurePayload, onListenPayload } from '@hocuspocus/server';
|
|
4
4
|
export interface Configuration {
|
|
5
5
|
/**
|
|
6
6
|
* Redis port
|
|
@@ -46,7 +46,7 @@ export declare class Redis implements Extension {
|
|
|
46
46
|
logger: Debugger;
|
|
47
47
|
constructor(configuration: Partial<Configuration>);
|
|
48
48
|
onConfigure({ instance }: onConfigurePayload): Promise<void>;
|
|
49
|
-
onListen(): Promise<void>;
|
|
49
|
+
onListen({ configuration }: onListenPayload): Promise<void>;
|
|
50
50
|
private getKey;
|
|
51
51
|
private pubKey;
|
|
52
52
|
private subKey;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import WebSocket, { AddressInfo, WebSocketServer } from 'ws';
|
|
3
3
|
import { IncomingMessage, Server as HTTPServer } from 'http';
|
|
4
|
-
import { Configuration,
|
|
4
|
+
import { Configuration, HookName, HookPayload } from './types';
|
|
5
5
|
import Document from './Document';
|
|
6
6
|
import { Debugger } from './Debugger';
|
|
7
7
|
import { onListenPayload } from '.';
|
|
@@ -88,7 +88,7 @@ export declare class Hocuspocus {
|
|
|
88
88
|
* Run the given hook on all configured extensions.
|
|
89
89
|
* Runs the given callback after each hook.
|
|
90
90
|
*/
|
|
91
|
-
hooks(name:
|
|
91
|
+
hooks(name: HookName, payload: HookPayload, callback?: Function | null): Promise<any>;
|
|
92
92
|
/**
|
|
93
93
|
* Get parameters by the given request
|
|
94
94
|
*/
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'http';
|
|
3
3
|
import { URLSearchParams } from 'url';
|
|
4
|
-
import { Socket } from 'net';
|
|
5
4
|
import { Awareness } from 'y-protocols/awareness';
|
|
6
5
|
import Document from './Document';
|
|
7
6
|
import { Hocuspocus } from './Hocuspocus';
|
|
@@ -44,11 +43,12 @@ export interface Extension {
|
|
|
44
43
|
onDisconnect?(data: onDisconnectPayload): Promise<any>;
|
|
45
44
|
onDestroy?(data: onDestroyPayload): Promise<any>;
|
|
46
45
|
}
|
|
47
|
-
export declare type
|
|
46
|
+
export declare type HookName = 'onConfigure' | 'onListen' | 'onUpgrade' | 'onConnect' | 'connected' | 'onAuthenticate' |
|
|
48
47
|
/**
|
|
49
48
|
* @deprecated onCreateDocument is deprecated, use onLoadDocument instead
|
|
50
49
|
*/
|
|
51
50
|
'onCreateDocument' | 'onLoadDocument' | 'afterLoadDocument' | 'onChange' | 'onStoreDocument' | 'afterStoreDocument' | 'onAwarenessUpdate' | 'onRequest' | 'onDisconnect' | 'onDestroy';
|
|
51
|
+
export declare type HookPayload = onConfigurePayload | onListenPayload | onUpgradePayload | onConnectPayload | connectedPayload | onAuthenticatePayload | onLoadDocumentPayload | onChangePayload | onStoreDocumentPayload | afterStoreDocumentPayload | onAwarenessUpdatePayload | onRequestPayload | onDisconnectPayload | onDestroyPayload;
|
|
52
52
|
export interface Configuration extends Extension {
|
|
53
53
|
/**
|
|
54
54
|
* A name for the instance, used for logging.
|
|
@@ -179,6 +179,16 @@ export declare type StatesArray = {
|
|
|
179
179
|
clientId: number;
|
|
180
180
|
[key: string | number]: any;
|
|
181
181
|
}[];
|
|
182
|
+
export interface fetchPayload {
|
|
183
|
+
context: any;
|
|
184
|
+
document: Document;
|
|
185
|
+
documentName: string;
|
|
186
|
+
instance: Hocuspocus;
|
|
187
|
+
requestHeaders: IncomingHttpHeaders;
|
|
188
|
+
requestParameters: URLSearchParams;
|
|
189
|
+
socketId: string;
|
|
190
|
+
connection: ConnectionConfiguration;
|
|
191
|
+
}
|
|
182
192
|
export interface storePayload extends onStoreDocumentPayload {
|
|
183
193
|
state: Buffer;
|
|
184
194
|
}
|
|
@@ -198,19 +208,21 @@ export interface onRequestPayload {
|
|
|
198
208
|
instance: Hocuspocus;
|
|
199
209
|
}
|
|
200
210
|
export interface onUpgradePayload {
|
|
201
|
-
head: any;
|
|
202
211
|
request: IncomingMessage;
|
|
203
|
-
socket:
|
|
212
|
+
socket: any;
|
|
213
|
+
head: any;
|
|
204
214
|
instance: Hocuspocus;
|
|
205
215
|
}
|
|
206
216
|
export interface onListenPayload {
|
|
217
|
+
instance: Hocuspocus;
|
|
218
|
+
configuration: Configuration;
|
|
207
219
|
port: number;
|
|
208
220
|
}
|
|
209
221
|
export interface onDestroyPayload {
|
|
210
222
|
instance: Hocuspocus;
|
|
211
223
|
}
|
|
212
224
|
export interface onConfigurePayload {
|
|
225
|
+
instance: Hocuspocus;
|
|
213
226
|
configuration: Configuration;
|
|
214
227
|
version: string;
|
|
215
|
-
instance: Hocuspocus;
|
|
216
228
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -2,6 +2,7 @@ export * from './createDirectory';
|
|
|
2
2
|
export * from './flushRedis';
|
|
3
3
|
export * from './newHocuspocus';
|
|
4
4
|
export * from './newHocuspocusProvider';
|
|
5
|
+
export * from './randomInteger';
|
|
5
6
|
export * from './redisConnectionSettings';
|
|
6
7
|
export * from './removeDirectory';
|
|
7
8
|
export * from './sleep';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const randomInteger: (min: number, max: number) => number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hocuspocus/extension-logger",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.76",
|
|
4
4
|
"description": "hocuspocus logging extension",
|
|
5
5
|
"homepage": "https://hocuspocus.dev",
|
|
6
6
|
"keywords": [
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
],
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"type": "module",
|
|
14
|
-
"main": "dist/hocuspocus-logger.
|
|
14
|
+
"main": "dist/hocuspocus-logger.cjs",
|
|
15
15
|
"module": "dist/hocuspocus-logger.esm.js",
|
|
16
16
|
"types": "dist/packages/extension-logger/src/index.d.ts",
|
|
17
17
|
"exports": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@hocuspocus/server": "^1.0.0-alpha.
|
|
31
|
+
"@hocuspocus/server": "^1.0.0-alpha.102"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "450e12c89b027bc62683f151330a98074cd8e8fb"
|
|
34
34
|
}
|