@hocuspocus/provider
Advanced tools
Comparing version 1.0.0-alpha.34 to 1.0.0-alpha.35
@@ -6,3 +6,2 @@ /// <reference types="node" /> | ||
version: string; | ||
yjsVersion: string; | ||
connections: {}; | ||
@@ -60,5 +59,4 @@ messages: {}; | ||
version: string; | ||
yjsVersion: string; | ||
}>; | ||
private static readableYDoc; | ||
} |
@@ -6,10 +6,4 @@ import * as Y from 'yjs'; | ||
import EventEmitter from './EventEmitter'; | ||
import { OutgoingMessage } from './OutgoingMessage'; | ||
import { ConstructableOutgoingMessage } from './types'; | ||
import { ConstructableOutgoingMessage, onAuthenticationFailedParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatusParameters, onSyncedParameters, WebSocketStatus } from './types'; | ||
import { onAwarenessChangeParameters, onAwarenessUpdateParameters } from '.'; | ||
export declare enum WebSocketStatus { | ||
Connecting = "connecting", | ||
Connected = "connected", | ||
Disconnected = "disconnected" | ||
} | ||
export declare type HocuspocusProviderConfiguration = Required<Pick<CompleteHocuspocusProviderConfiguration, 'url' | 'name'>> & Partial<CompleteHocuspocusProviderConfiguration>; | ||
@@ -96,18 +90,14 @@ export interface CompleteHocuspocusProviderConfiguration { | ||
onAuthenticated: () => void; | ||
onAuthenticationFailed: ({ reason }: { | ||
reason: string; | ||
}) => void; | ||
onOpen: (event: Event) => void; | ||
onAuthenticationFailed: (data: onAuthenticationFailedParameters) => void; | ||
onOpen: (data: onOpenParameters) => void; | ||
onConnect: () => void; | ||
onMessage: (event: MessageEvent) => void; | ||
onOutgoingMessage: (message: OutgoingMessage) => void; | ||
onStatus: (status: any) => void; | ||
onSynced: ({ state }: { | ||
state: boolean; | ||
}) => void; | ||
onDisconnect: (event: CloseEvent) => void; | ||
onClose: (event: CloseEvent) => void; | ||
onMessage: (data: onMessageParameters) => void; | ||
onOutgoingMessage: (data: onOutgoingMessageParameters) => void; | ||
onStatus: (data: onStatusParameters) => void; | ||
onSynced: (data: onSyncedParameters) => void; | ||
onDisconnect: (data: onDisconnectParameters) => void; | ||
onClose: (data: onCloseParameters) => void; | ||
onDestroy: () => void; | ||
onAwarenessUpdate: ({ states }: onAwarenessUpdateParameters) => void; | ||
onAwarenessChange: ({ states }: onAwarenessChangeParameters) => void; | ||
onAwarenessUpdate: (data: onAwarenessUpdateParameters) => void; | ||
onAwarenessChange: (data: onAwarenessChangeParameters) => void; | ||
/** | ||
@@ -114,0 +104,0 @@ * Don’t output any warnings. |
import { Awareness } from 'y-protocols/awareness'; | ||
import * as Y from 'yjs'; | ||
import { Encoder } from 'lib0/encoding'; | ||
import type { Event, CloseEvent, MessageEvent } from 'ws'; | ||
import { AuthenticationMessage } from './OutgoingMessages/AuthenticationMessage'; | ||
@@ -10,2 +11,4 @@ import { AwarenessMessage } from './OutgoingMessages/AwarenessMessage'; | ||
import { UpdateMessage } from './OutgoingMessages/UpdateMessage'; | ||
import { IncomingMessage } from './IncomingMessage'; | ||
import { OutgoingMessage } from './OutgoingMessage'; | ||
export declare enum MessageType { | ||
@@ -17,2 +20,7 @@ Sync = 0, | ||
} | ||
export declare enum WebSocketStatus { | ||
Connecting = "connecting", | ||
Connected = "connected", | ||
Disconnected = "disconnected" | ||
} | ||
export interface OutgoingMessageInterface { | ||
@@ -37,2 +45,27 @@ encoder: Encoder; | ||
export declare type ConstructableOutgoingMessage = Constructable<AuthenticationMessage> | Constructable<AwarenessMessage> | Constructable<QueryAwarenessMessage> | Constructable<SyncStepOneMessage> | Constructable<SyncStepTwoMessage> | Constructable<UpdateMessage>; | ||
export declare type onAuthenticationFailedParameters = { | ||
reason: string; | ||
}; | ||
export declare type onOpenParameters = { | ||
event: Event; | ||
}; | ||
export declare type onMessageParameters = { | ||
event: MessageEvent; | ||
message: IncomingMessage; | ||
}; | ||
export declare type onOutgoingMessageParameters = { | ||
message: OutgoingMessage; | ||
}; | ||
export declare type onStatusParameters = { | ||
status: WebSocketStatus; | ||
}; | ||
export declare type onSyncedParameters = { | ||
state: boolean; | ||
}; | ||
export declare type onDisconnectParameters = { | ||
event: CloseEvent; | ||
}; | ||
export declare type onCloseParameters = { | ||
event: CloseEvent; | ||
}; | ||
export declare type onAwarenessUpdateParameters = { | ||
@@ -39,0 +72,0 @@ states: StatesArray; |
@@ -215,4 +215,3 @@ /// <reference types="node" /> | ||
version: string; | ||
yjsVersion: string; | ||
instance: Hocuspocus; | ||
} |
{ | ||
"name": "@hocuspocus/provider", | ||
"version": "1.0.0-alpha.34", | ||
"version": "1.0.0-alpha.35", | ||
"description": "hocuspocus provider", | ||
@@ -31,9 +31,9 @@ "homepage": "https://hocuspocus.dev", | ||
"dependencies": { | ||
"@hocuspocus/common": "^1.0.0-alpha.9", | ||
"@hocuspocus/common": "^1.0.0-alpha.10", | ||
"@lifeomic/attempt": "^3.0.2", | ||
"lib0": "^0.2.46", | ||
"y-protocols": "^1.0.5", | ||
"yjs": "^13.5.28" | ||
"yjs": "^13.5.29" | ||
}, | ||
"gitHead": "673dd4b2c723e71bf9b33b8f7804ab35c8417417" | ||
"gitHead": "1fc2a6cff1b5fd626b8dd7c486755111965da20d" | ||
} |
@@ -22,12 +22,7 @@ import * as Y from 'yjs' | ||
import { UpdateMessage } from './OutgoingMessages/UpdateMessage' | ||
import { OutgoingMessage } from './OutgoingMessage' | ||
import { ConstructableOutgoingMessage } from './types' | ||
import { | ||
ConstructableOutgoingMessage, onAuthenticationFailedParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatusParameters, onSyncedParameters, WebSocketStatus, | ||
} from './types' | ||
import { onAwarenessChangeParameters, onAwarenessUpdateParameters } from '.' | ||
export enum WebSocketStatus { | ||
Connecting = 'connecting', | ||
Connected = 'connected', | ||
Disconnected = 'disconnected', | ||
} | ||
export type HocuspocusProviderConfiguration = | ||
@@ -115,14 +110,14 @@ Required<Pick<CompleteHocuspocusProviderConfiguration, 'url' | 'name'>> | ||
onAuthenticated: () => void, | ||
onAuthenticationFailed: ({ reason }: { reason: string }) => void, | ||
onOpen: (event: Event) => void, | ||
onAuthenticationFailed: (data: onAuthenticationFailedParameters) => void, | ||
onOpen: (data: onOpenParameters) => void, | ||
onConnect: () => void, | ||
onMessage: (event: MessageEvent) => void, | ||
onOutgoingMessage: (message: OutgoingMessage) => void, | ||
onStatus: (status: any) => void, | ||
onSynced: ({ state }: { state: boolean }) => void, | ||
onDisconnect: (event: CloseEvent) => void, | ||
onClose: (event: CloseEvent) => void, | ||
onMessage: (data: onMessageParameters) => void, | ||
onOutgoingMessage: (data: onOutgoingMessageParameters) => void, | ||
onStatus: (data: onStatusParameters) => void, | ||
onSynced: (data: onSyncedParameters) => void, | ||
onDisconnect: (data: onDisconnectParameters) => void, | ||
onClose: (data: onCloseParameters) => void, | ||
onDestroy: () => void, | ||
onAwarenessUpdate: ({ states }: onAwarenessUpdateParameters) => void, | ||
onAwarenessChange: ({ states }: onAwarenessChangeParameters) => void, | ||
onAwarenessUpdate: (data: onAwarenessUpdateParameters) => void, | ||
onAwarenessChange: (data: onAwarenessChangeParameters) => void, | ||
/** | ||
@@ -318,3 +313,3 @@ * Don’t output any warnings. | ||
this.status = WebSocketStatus.Connecting | ||
this.emit('status', { status: 'connecting' }) | ||
this.emit('status', { status: WebSocketStatus.Connecting }) | ||
@@ -334,3 +329,3 @@ // Store resolve/reject for later use | ||
this.status = WebSocketStatus.Connected | ||
this.emit('status', { status: 'connected' }) | ||
this.emit('status', { status: WebSocketStatus.Connected }) | ||
this.emit('connect') | ||
@@ -548,3 +543,3 @@ } | ||
this.status = WebSocketStatus.Disconnected | ||
this.emit('status', { status: 'disconnected' }) | ||
this.emit('status', { status: WebSocketStatus.Disconnected }) | ||
this.emit('disconnect', { event }) | ||
@@ -587,3 +582,3 @@ } | ||
this.status = WebSocketStatus.Disconnected | ||
this.emit('status', { status: 'disconnected' }) | ||
this.emit('status', { status: WebSocketStatus.Disconnected }) | ||
this.emit('disconnect', { event }) | ||
@@ -590,0 +585,0 @@ } |
import { Awareness } from 'y-protocols/awareness' | ||
import * as Y from 'yjs' | ||
import { Encoder } from 'lib0/encoding' | ||
import type { Event, CloseEvent, MessageEvent } from 'ws' | ||
import { AuthenticationMessage } from './OutgoingMessages/AuthenticationMessage' | ||
@@ -10,2 +11,4 @@ import { AwarenessMessage } from './OutgoingMessages/AwarenessMessage' | ||
import { UpdateMessage } from './OutgoingMessages/UpdateMessage' | ||
import { IncomingMessage } from './IncomingMessage' | ||
import { OutgoingMessage } from './OutgoingMessage' | ||
@@ -19,2 +22,8 @@ export enum MessageType { | ||
export enum WebSocketStatus { | ||
Connecting = 'connecting', | ||
Connected = 'connected', | ||
Disconnected = 'disconnected', | ||
} | ||
export interface OutgoingMessageInterface { | ||
@@ -47,2 +56,35 @@ encoder: Encoder | ||
export type onAuthenticationFailedParameters = { | ||
reason: string, | ||
} | ||
export type onOpenParameters = { | ||
event: Event, | ||
} | ||
export type onMessageParameters = { | ||
event: MessageEvent, | ||
message: IncomingMessage, | ||
} | ||
export type onOutgoingMessageParameters = { | ||
message: OutgoingMessage, | ||
} | ||
export type onStatusParameters = { | ||
status: WebSocketStatus, | ||
} | ||
export type onSyncedParameters = { | ||
state: boolean, | ||
} | ||
export type onDisconnectParameters = { | ||
event: CloseEvent, | ||
} | ||
export type onCloseParameters = { | ||
event: CloseEvent, | ||
} | ||
export type onAwarenessUpdateParameters = { | ||
@@ -49,0 +91,0 @@ states: StatesArray |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
564334
6511
Updatedyjs@^13.5.29