Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hocuspocus/provider

Package Overview
Dependencies
Maintainers
3
Versions
104
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hocuspocus/provider - npm Package Compare versions

Comparing version 1.0.0-alpha.32 to 1.0.0-alpha.33

dist/packages/common/src/types.d.ts

1

dist/packages/common/src/index.d.ts
export * from './auth';
export * from './CloseEvents';
export * from './awarenessStatesToArray';
export * from './types';

4

dist/packages/extension-monitor/src/index.d.ts
/// <reference types="node" />
import { Extension, onChangePayload, onConfigurePayload, onConnectPayload, onLoadDocumentPayload, onDisconnectPayload, onRequestPayload, onUpgradePayload } from '@hocuspocus/server';
import { Extension, onChangePayload, onConfigurePayload, onLoadDocumentPayload, onDisconnectPayload, onRequestPayload, onUpgradePayload, connectedPayload } from '@hocuspocus/server';
import { IncomingMessage, ServerResponse } from 'http';

@@ -33,3 +33,3 @@ import WebSocket from 'ws';

onUpgrade({ request, socket, head }: onUpgradePayload): Promise<void>;
onConnect(data: onConnectPayload): Promise<void>;
connected(data: connectedPayload): Promise<void>;
onDisconnect(data: onDisconnectPayload): Promise<void>;

@@ -36,0 +36,0 @@ onLoadDocument(data: onLoadDocumentPayload): Promise<void>;

@@ -136,2 +136,3 @@ import * as Y from 'yjs';

resolveConnectionAttempt(): void;
stopConnectionAttempt(): void;
rejectConnectionAttempt(): void;

@@ -153,5 +154,4 @@ get document(): Y.Doc;

disconnect(): void;
onOpen(event: Event): void;
onOpen(event: Event): Promise<void>;
getToken(): Promise<string | null>;
webSocketConnectionEstablished(): Promise<void>;
startSync(): void;

@@ -158,0 +158,0 @@ send(Message: ConstructableOutgoingMessage, args: any, broadcast?: boolean): void;

@@ -15,12 +15,2 @@ /// <reference types="node" />

}
/**
* State of the WebSocket connection.
* https://developer.mozilla.org/de/docs/Web/API/WebSocket/readyState
*/
export declare enum WsReadyStates {
Connecting = 0,
Open = 1,
Closing = 2,
Closed = 3
}
export interface AwarenessUpdate {

@@ -27,0 +17,0 @@ added: Array<any>;

{
"name": "@hocuspocus/provider",
"version": "1.0.0-alpha.32",
"version": "1.0.0-alpha.33",
"description": "hocuspocus provider",

@@ -31,3 +31,3 @@ "homepage": "https://hocuspocus.dev",

"dependencies": {
"@hocuspocus/common": "^1.0.0-alpha.7",
"@hocuspocus/common": "^1.0.0-alpha.8",
"@lifeomic/attempt": "^3.0.2",

@@ -38,3 +38,3 @@ "lib0": "^0.2.43",

},
"gitHead": "41c2ca3452f17e7dab914c633cde04ae68f45929"
"gitHead": "771a8cbad1016dd12080ff4b35fabb9680ec69a7"
}

@@ -9,3 +9,5 @@ import * as Y from 'yjs'

import { retry } from '@lifeomic/attempt'
import { awarenessStatesToArray, Forbidden, Unauthorized } from '@hocuspocus/common'
import {
awarenessStatesToArray, Forbidden, Unauthorized, WsReadyStates,
} from '@hocuspocus/common'
import EventEmitter from './EventEmitter'

@@ -328,4 +330,12 @@ import { IncomingMessage } from './IncomingMessage'

this.connectionAttempt = null
this.status = WebSocketStatus.Connected
this.emit('status', { status: 'connected' })
this.emit('connect')
}
stopConnectionAttempt() {
this.connectionAttempt = null
}
rejectConnectionAttempt() {

@@ -462,8 +472,13 @@ this.connectionAttempt?.reject()

onOpen(event: Event) {
async onOpen(event: Event) {
this.emit('open', { event })
if (this.status !== WebSocketStatus.Connected) {
this.webSocketConnectionEstablished()
if (this.isAuthenticationRequired) {
this.send(AuthenticationMessage, {
token: await this.getToken(),
})
return
}
this.startSync()
}

@@ -480,17 +495,2 @@

async webSocketConnectionEstablished() {
this.status = WebSocketStatus.Connected
this.emit('status', { status: 'connected' })
this.emit('connect')
if (this.isAuthenticationRequired) {
this.send(AuthenticationMessage, {
token: await this.getToken(),
})
return
}
this.startSync()
}
startSync() {

@@ -512,3 +512,3 @@ this.send(SyncStepOneMessage, { document: this.document })

if (this.status === WebSocketStatus.Connected) {
if (this.webSocket?.readyState === WsReadyStates.Open) {
const messageSender = new MessageSender(Message, args)

@@ -602,6 +602,6 @@

// If there is still a connection attempt outstanding then we should resolve
// If there is still a connection attempt outstanding then we should stop
// it before calling disconnect, otherwise it will be rejected in the onClose
// handler and trigger a retry
this.resolveConnectionAttempt()
this.stopConnectionAttempt()

@@ -608,0 +608,0 @@ this.disconnect()

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc