@hocuspocus/provider
Advanced tools
Comparing version 2.2.1 to 2.2.2
@@ -75,2 +75,13 @@ import * as Y from 'yjs'; | ||
constructor(configuration: HocuspocusProviderConfiguration); | ||
boundBroadcastChannelSubscriber: (data: ArrayBuffer) => void; | ||
boundBeforeUnload: () => void; | ||
boundOnOpen: (event: Event) => Promise<void>; | ||
boundOnMessage: (event: MessageEvent) => void; | ||
boundOnClose: (event: CloseEvent) => void; | ||
boundOnStatus: ({ status }: onStatusParameters) => void; | ||
forwardConnect: (e: any) => this; | ||
forwardOpen: (e: any) => this; | ||
forwardClose: (e: any) => this; | ||
forwardDisconnect: (e: any) => this; | ||
forwardDestroy: (e: any) => this; | ||
onStatus({ status }: onStatusParameters): void; | ||
@@ -83,3 +94,2 @@ setConfiguration(configuration?: Partial<HocuspocusProviderConfiguration>): void; | ||
forceSync(): void; | ||
boundBeforeUnload: () => void; | ||
beforeUnload(): void; | ||
@@ -106,3 +116,2 @@ registerEventListeners(): void; | ||
get broadcastChannel(): string; | ||
boundBroadcastChannelSubscriber: (data: ArrayBuffer) => void; | ||
broadcastChannelSubscriber(data: ArrayBuffer): void; | ||
@@ -109,0 +118,0 @@ subscribeToBroadcastChannel(): void; |
import { HocuspocusProvider, HocuspocusProviderConfiguration } from './HocuspocusProvider.js'; | ||
export type TiptapCollabProviderConfiguration = Required<Pick<HocuspocusProviderConfiguration, 'name'>> & Partial<HocuspocusProviderConfiguration> & AdditionalTiptapCollabProviderConfiguration; | ||
import { TiptapCollabProviderWebsocket } from './TiptapCollabProviderWebsocket.js'; | ||
export type TiptapCollabProviderConfiguration = Required<Pick<HocuspocusProviderConfiguration, 'name'>> & Partial<HocuspocusProviderConfiguration> & (Required<Pick<AdditionalTiptapCollabProviderConfiguration, 'websocketProvider'>> | Required<Pick<AdditionalTiptapCollabProviderConfiguration, 'appId'>>); | ||
export interface AdditionalTiptapCollabProviderConfiguration { | ||
@@ -7,3 +8,4 @@ /** | ||
*/ | ||
appId: string; | ||
appId?: string; | ||
websocketProvider?: TiptapCollabProviderWebsocket; | ||
} | ||
@@ -10,0 +12,0 @@ export declare class TiptapCollabProvider extends HocuspocusProvider { |
import Document from './Document.js'; | ||
import type { Hocuspocus } from './Hocuspocus.js'; | ||
import type { DirectConnection as DirectConnectionInterface } from './types'; | ||
import type { DirectConnection as DirectConnectionInterface } from './types.js'; | ||
export declare class DirectConnection implements DirectConnectionInterface { | ||
@@ -5,0 +5,0 @@ document: Document | null; |
{ | ||
"name": "@hocuspocus/provider", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"description": "hocuspocus provider", | ||
@@ -32,3 +32,3 @@ "homepage": "https://hocuspocus.dev", | ||
"dependencies": { | ||
"@hocuspocus/common": "^2.2.1", | ||
"@hocuspocus/common": "^2.2.2", | ||
"@lifeomic/attempt": "^3.0.2", | ||
@@ -35,0 +35,0 @@ "lib0": "^0.2.47", |
@@ -169,20 +169,20 @@ import * as Y from 'yjs' | ||
this.configuration.websocketProvider.on('connect', this.configuration.onConnect) | ||
this.configuration.websocketProvider.on('connect', (e: Event) => this.emit('connect', e)) | ||
this.configuration.websocketProvider.on('connect', this.forwardConnect) | ||
this.configuration.websocketProvider.on('open', this.onOpen.bind(this)) | ||
this.configuration.websocketProvider.on('open', (e: Event) => this.emit('open', e)) | ||
this.configuration.websocketProvider.on('open', this.boundOnOpen) | ||
this.configuration.websocketProvider.on('open', this.forwardOpen) | ||
this.configuration.websocketProvider.on('message', this.onMessage.bind(this)) | ||
this.configuration.websocketProvider.on('message', this.boundOnMessage) | ||
this.configuration.websocketProvider.on('close', this.onClose.bind(this)) | ||
this.configuration.websocketProvider.on('close', this.boundOnClose) | ||
this.configuration.websocketProvider.on('close', this.configuration.onClose) | ||
this.configuration.websocketProvider.on('close', (e: Event) => this.emit('close', e)) | ||
this.configuration.websocketProvider.on('close', this.forwardClose) | ||
this.configuration.websocketProvider.on('status', this.onStatus.bind(this)) | ||
this.configuration.websocketProvider.on('status', this.boundOnStatus) | ||
this.configuration.websocketProvider.on('disconnect', this.configuration.onDisconnect) | ||
this.configuration.websocketProvider.on('disconnect', (e: Event) => this.emit('disconnect', e)) | ||
this.configuration.websocketProvider.on('disconnect', this.forwardDisconnect) | ||
this.configuration.websocketProvider.on('destroy', this.configuration.onDestroy) | ||
this.configuration.websocketProvider.on('destroy', (e: Event) => this.emit('destroy', e)) | ||
this.configuration.websocketProvider.on('destroy', this.forwardDestroy) | ||
@@ -211,2 +211,24 @@ this.awareness.on('update', () => { | ||
boundBroadcastChannelSubscriber = this.broadcastChannelSubscriber.bind(this) | ||
boundBeforeUnload = this.beforeUnload.bind(this) | ||
boundOnOpen = this.onOpen.bind(this) | ||
boundOnMessage = this.onMessage.bind(this) | ||
boundOnClose = this.onClose.bind(this) | ||
boundOnStatus = this.onStatus.bind(this) | ||
forwardConnect = (e: any) => this.emit('connect', e) | ||
forwardOpen = (e: any) => this.emit('open', e) | ||
forwardClose = (e: any) => this.emit('close', e) | ||
forwardDisconnect = (e: any) => this.emit('disconnect', e) | ||
forwardDestroy = (e: any) => this.emit('destroy', e) | ||
public onStatus({ status } : onStatusParameters) { | ||
@@ -253,4 +275,2 @@ this.status = status | ||
boundBeforeUnload = this.beforeUnload.bind(this) | ||
beforeUnload() { | ||
@@ -420,2 +440,16 @@ removeAwarenessStates(this.awareness, [this.document.clientID], 'window unload') | ||
this.configuration.websocketProvider.off('connect', this.configuration.onConnect) | ||
this.configuration.websocketProvider.off('connect', this.forwardConnect) | ||
this.configuration.websocketProvider.off('open', this.boundOnOpen) | ||
this.configuration.websocketProvider.off('open', this.forwardOpen) | ||
this.configuration.websocketProvider.off('message', this.boundOnMessage) | ||
this.configuration.websocketProvider.off('close', this.boundOnClose) | ||
this.configuration.websocketProvider.off('close', this.configuration.onClose) | ||
this.configuration.websocketProvider.off('close', this.forwardClose) | ||
this.configuration.websocketProvider.off('status', this.boundOnStatus) | ||
this.configuration.websocketProvider.off('disconnect', this.configuration.onDisconnect) | ||
this.configuration.websocketProvider.off('disconnect', this.forwardDisconnect) | ||
this.configuration.websocketProvider.off('destroy', this.configuration.onDestroy) | ||
this.configuration.websocketProvider.off('destroy', this.forwardDestroy) | ||
this.send(CloseMessage, { documentName: this.configuration.name }) | ||
@@ -450,4 +484,2 @@ this.isConnected = false | ||
boundBroadcastChannelSubscriber = this.broadcastChannelSubscriber.bind(this) | ||
broadcastChannelSubscriber(data: ArrayBuffer) { | ||
@@ -454,0 +486,0 @@ this.mux(() => { |
@@ -11,3 +11,4 @@ import { | ||
Partial<HocuspocusProviderConfiguration> & | ||
AdditionalTiptapCollabProviderConfiguration | ||
(Required<Pick<AdditionalTiptapCollabProviderConfiguration, 'websocketProvider'>> | | ||
Required<Pick<AdditionalTiptapCollabProviderConfiguration, 'appId'>>) | ||
@@ -18,3 +19,5 @@ export interface AdditionalTiptapCollabProviderConfiguration { | ||
*/ | ||
appId: string, | ||
appId?: string, | ||
websocketProvider?: TiptapCollabProviderWebsocket | ||
} | ||
@@ -25,3 +28,3 @@ | ||
if (!configuration.websocketProvider) { | ||
configuration.websocketProvider = new TiptapCollabProviderWebsocket({ appId: configuration.appId }) | ||
configuration.websocketProvider = new TiptapCollabProviderWebsocket({ appId: (configuration as Required<Pick<AdditionalTiptapCollabProviderConfiguration, 'appId'>>).appId }) | ||
} | ||
@@ -28,0 +31,0 @@ |
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
691978
7916
0
Updated@hocuspocus/common@^2.2.2