@hocuspocus/provider 1.0.0-alpha.21 → 1.0.0-alpha.25
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-provider.cjs +278 -68
- package/dist/hocuspocus-provider.cjs.map +1 -1
- package/dist/hocuspocus-provider.esm.js +278 -68
- package/dist/hocuspocus-provider.esm.js.map +1 -1
- package/dist/{shared/protocols → packages/common/src}/auth.d.ts +0 -0
- package/dist/packages/common/src/index.d.ts +1 -0
- package/dist/packages/extension-logger/src/Logger.d.ts +44 -0
- package/dist/packages/server/src/Hocuspocus.d.ts +3 -3
- package/dist/packages/server/src/types.d.ts +9 -0
- package/package.json +9 -4
- package/src/HocuspocusProvider.ts +6 -6
- package/src/MessageReceiver.ts +1 -1
- package/src/OutgoingMessages/AuthenticationMessage.ts +1 -1
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './auth';
|
|
@@ -2,10 +2,53 @@ import { Extension, onChangePayload, onConfigurePayload, onConnectPayload, onLoa
|
|
|
2
2
|
export interface LoggerConfiguration {
|
|
3
3
|
/**
|
|
4
4
|
* Prepend all logging message with a string.
|
|
5
|
+
*
|
|
6
|
+
* @deprecated
|
|
5
7
|
*/
|
|
6
8
|
prefix: null | string;
|
|
9
|
+
/**
|
|
10
|
+
* Whether to log something for the `onLoadDocument` hook.
|
|
11
|
+
*/
|
|
12
|
+
onLoadDocument: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Whether to log something for the `onChange` hook.
|
|
15
|
+
*/
|
|
16
|
+
onChange: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Whether to log something for the `onConnect` hook.
|
|
19
|
+
*/
|
|
20
|
+
onConnect: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Whether to log something for the `onDisconnect` hook.
|
|
23
|
+
*/
|
|
24
|
+
onDisconnect: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Whether to log something for the `onUpgrade` hook.
|
|
27
|
+
*/
|
|
28
|
+
onUpgrade: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Whether to log something for the `onRequest` hook.
|
|
31
|
+
*/
|
|
32
|
+
onRequest: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Whether to log something for the `onListen` hook.
|
|
35
|
+
*/
|
|
36
|
+
onListen: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Whether to log something for the `onDestroy` hook.
|
|
39
|
+
*/
|
|
40
|
+
onDestroy: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Whether to log something for the `onConfigure` hook.
|
|
43
|
+
*/
|
|
44
|
+
onConfigure: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* A log function, if none is provided output will go to console
|
|
47
|
+
*/
|
|
48
|
+
log: (...args: any[]) => void;
|
|
7
49
|
}
|
|
8
50
|
export declare class Logger implements Extension {
|
|
51
|
+
name: string | null;
|
|
9
52
|
configuration: LoggerConfiguration;
|
|
10
53
|
/**
|
|
11
54
|
* Constructor
|
|
@@ -20,5 +63,6 @@ export declare class Logger implements Extension {
|
|
|
20
63
|
onListen(data: onListenPayload): Promise<void>;
|
|
21
64
|
onDestroy(data: onDestroyPayload): Promise<void>;
|
|
22
65
|
onConfigure(data: onConfigurePayload): Promise<void>;
|
|
66
|
+
private logRawText;
|
|
23
67
|
private log;
|
|
24
68
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import WebSocket, { WebSocketServer } from 'ws';
|
|
3
3
|
import { IncomingMessage, Server as HTTPServer } from 'http';
|
|
4
|
-
import { Configuration } from './types';
|
|
4
|
+
import { Configuration, Hook } from './types';
|
|
5
5
|
import { MessageLogger } from './Debugger';
|
|
6
6
|
export declare const defaultConfiguration: {
|
|
7
|
+
name: null;
|
|
7
8
|
port: number;
|
|
8
9
|
timeout: number;
|
|
9
10
|
};
|
|
@@ -63,9 +64,8 @@ export declare class Hocuspocus {
|
|
|
63
64
|
/**
|
|
64
65
|
* Run the given hook on all configured extensions
|
|
65
66
|
* Runs the given callback after each hook
|
|
66
|
-
* @private
|
|
67
67
|
*/
|
|
68
|
-
|
|
68
|
+
hooks(name: Hook, payload: any, callback?: Function | null): Promise<any>;
|
|
69
69
|
/**
|
|
70
70
|
* Get parameters by the given request
|
|
71
71
|
* @private
|
|
@@ -45,7 +45,16 @@ export interface Extension {
|
|
|
45
45
|
onRequest?(data: onRequestPayload): Promise<any>;
|
|
46
46
|
onUpgrade?(data: onUpgradePayload): Promise<any>;
|
|
47
47
|
}
|
|
48
|
+
export declare type Hook = 'onAuthenticate' | 'onChange' | 'onConnect' | 'onConfigure' |
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated onCreateDocument is deprecated, use onLoadDocument instead
|
|
51
|
+
*/
|
|
52
|
+
'onCreateDocument' | 'onLoadDocument' | 'onDestroy' | 'onDisconnect' | 'onListen' | 'onRequest' | 'onUpgrade';
|
|
48
53
|
export interface Configuration extends Extension {
|
|
54
|
+
/**
|
|
55
|
+
* A name for the instance, used for logging.
|
|
56
|
+
*/
|
|
57
|
+
name: string | null;
|
|
49
58
|
/**
|
|
50
59
|
* A list of hocuspocus extenions.
|
|
51
60
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hocuspocus/provider",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.25",
|
|
4
4
|
"description": "hocuspocus provider",
|
|
5
5
|
"homepage": "https://hocuspocus.dev",
|
|
6
6
|
"keywords": [
|
|
@@ -15,8 +15,13 @@
|
|
|
15
15
|
"module": "dist/hocuspocus-provider.esm.js",
|
|
16
16
|
"types": "dist/packages/provider/src/index.d.ts",
|
|
17
17
|
"exports": {
|
|
18
|
-
"
|
|
19
|
-
|
|
18
|
+
"source": {
|
|
19
|
+
"import": "./src"
|
|
20
|
+
},
|
|
21
|
+
"default": {
|
|
22
|
+
"import": "./dist/hocuspocus-provider.esm.js",
|
|
23
|
+
"require": "./dist/hocuspocus-provider.cjs"
|
|
24
|
+
}
|
|
20
25
|
},
|
|
21
26
|
"files": [
|
|
22
27
|
"src",
|
|
@@ -28,7 +33,7 @@
|
|
|
28
33
|
"y-protocols": "^1.0.5",
|
|
29
34
|
"yjs": "^13.5.0"
|
|
30
35
|
},
|
|
31
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "cd788b6a315f608ef531524409abdce1e6790726",
|
|
32
37
|
"publishConfig": {
|
|
33
38
|
"access": "public"
|
|
34
39
|
}
|
|
@@ -275,11 +275,11 @@ export class HocuspocusProvider extends EventEmitter {
|
|
|
275
275
|
}
|
|
276
276
|
},
|
|
277
277
|
})
|
|
278
|
-
} catch (
|
|
279
|
-
// If we aborted the connection attempt then don
|
|
278
|
+
} catch (error: any) {
|
|
279
|
+
// If we aborted the connection attempt then don’t throw an error
|
|
280
280
|
// ref: https://github.com/lifeomic/attempt/blob/master/src/index.ts#L136
|
|
281
|
-
if (
|
|
282
|
-
throw
|
|
281
|
+
if (error && error.code !== 'ATTEMPT_ABORTED') {
|
|
282
|
+
throw error
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
285
|
}
|
|
@@ -475,8 +475,6 @@ export class HocuspocusProvider extends EventEmitter {
|
|
|
475
475
|
}
|
|
476
476
|
|
|
477
477
|
this.startSync()
|
|
478
|
-
|
|
479
|
-
this.resolveConnectionAttempt()
|
|
480
478
|
}
|
|
481
479
|
|
|
482
480
|
startSync() {
|
|
@@ -504,6 +502,8 @@ export class HocuspocusProvider extends EventEmitter {
|
|
|
504
502
|
}
|
|
505
503
|
|
|
506
504
|
onMessage(event: MessageEvent) {
|
|
505
|
+
this.resolveConnectionAttempt()
|
|
506
|
+
|
|
507
507
|
this.lastMessageReceived = time.getUnixTime()
|
|
508
508
|
|
|
509
509
|
const message = new IncomingMessage(event.data)
|
package/src/MessageReceiver.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as awarenessProtocol from 'y-protocols/awareness'
|
|
2
2
|
import { readSyncMessage, messageYjsSyncStep2 } from 'y-protocols/sync'
|
|
3
|
+
import { readAuthMessage } from '@hocuspocus/common'
|
|
3
4
|
import { MessageType } from './types'
|
|
4
5
|
import { HocuspocusProvider } from './HocuspocusProvider'
|
|
5
6
|
import { IncomingMessage } from './IncomingMessage'
|
|
6
|
-
import { readAuthMessage } from '../../../shared/protocols/auth'
|
|
7
7
|
import { OutgoingMessage } from './OutgoingMessage'
|
|
8
8
|
|
|
9
9
|
export class MessageReceiver {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { writeVarUint } from 'lib0/encoding'
|
|
2
|
-
import { writeAuthentication } from '
|
|
2
|
+
import { writeAuthentication } from '@hocuspocus/common'
|
|
3
3
|
import { MessageType, OutgoingMessageArguments } from '../types'
|
|
4
4
|
import { OutgoingMessage } from '../OutgoingMessage'
|
|
5
5
|
|