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.17 to 1.0.0-alpha.18

47

dist/hocuspocus-provider.esm.js

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

}
connect() {
async connect() {
if (this.status === WebSocketStatus.Connected) {

@@ -1872,17 +1872,26 @@ return;

this.subscribeToBroadcastChannel();
retry(this.createWebSocketConnection.bind(this), {
delay: this.options.delay,
initialDelay: this.options.initialDelay,
factor: this.options.factor,
maxAttempts: this.options.maxAttempts,
minDelay: this.options.minDelay,
maxDelay: this.options.maxDelay,
jitter: this.options.jitter,
timeout: this.options.timeout,
beforeAttempt: context => {
if (!this.shouldConnect) {
context.abort();
}
},
});
try {
await retry(this.createWebSocketConnection.bind(this), {
delay: this.options.delay,
initialDelay: this.options.initialDelay,
factor: this.options.factor,
maxAttempts: this.options.maxAttempts,
minDelay: this.options.minDelay,
maxDelay: this.options.maxDelay,
jitter: this.options.jitter,
timeout: this.options.timeout,
beforeAttempt: context => {
if (!this.shouldConnect) {
context.abort();
}
},
});
}
catch (err) {
// If we aborted the connection attempt then don't throw an error
// ref: https://github.com/lifeomic/attempt/blob/master/src/index.ts#L136
if (err.code !== 'ATTEMPT_ABORTED') {
throw err;
}
}
}

@@ -2109,4 +2118,8 @@ createWebSocketConnection() {

clearInterval(this.intervals.connectionChecker);
removeAwarenessStates(this.awareness, [this.document.clientID], 'provider destroy');
// If there is still a connection attempt outstanding then we should resolve
// it before calling disconnect, otherwise it will be rejected in the onClose
// handler and trigger a retry
this.resolveConnectionAttempt();
this.disconnect();
removeAwarenessStates(this.awareness, [this.document.clientID], 'provider destroy');
this.awareness.off('update', this.awarenessUpdateHandler);

@@ -2113,0 +2126,0 @@ this.document.off('update', this.documentUpdateHandler);

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

setOptions(options?: Partial<HocuspocusProviderOptions>): void;
connect(): void;
connect(): Promise<void>;
createWebSocketConnection(): Promise<unknown>;

@@ -128,0 +128,0 @@ resolveConnectionAttempt(): void;

{
"name": "@hocuspocus/provider",
"version": "1.0.0-alpha.17",
"version": "1.0.0-alpha.18",
"description": "hocuspocus provider",

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

},
"gitHead": "b2c6c6711d5de4dd352aaaf32e43e4f33d46068e",
"gitHead": "b3f043fa2f99dd35bd68940efcb0d5b86a165585",
"publishConfig": {

@@ -34,0 +34,0 @@ "access": "public"

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

connect() {
async connect() {
if (this.status === WebSocketStatus.Connected) {

@@ -263,17 +263,25 @@ return

retry(this.createWebSocketConnection.bind(this), {
delay: this.options.delay,
initialDelay: this.options.initialDelay,
factor: this.options.factor,
maxAttempts: this.options.maxAttempts,
minDelay: this.options.minDelay,
maxDelay: this.options.maxDelay,
jitter: this.options.jitter,
timeout: this.options.timeout,
beforeAttempt: context => {
if (!this.shouldConnect) {
context.abort()
}
},
})
try {
await retry(this.createWebSocketConnection.bind(this), {
delay: this.options.delay,
initialDelay: this.options.initialDelay,
factor: this.options.factor,
maxAttempts: this.options.maxAttempts,
minDelay: this.options.minDelay,
maxDelay: this.options.maxDelay,
jitter: this.options.jitter,
timeout: this.options.timeout,
beforeAttempt: context => {
if (!this.shouldConnect) {
context.abort()
}
},
})
} catch (err: any) {
// If we aborted the connection attempt then don't throw an error
// ref: https://github.com/lifeomic/attempt/blob/master/src/index.ts#L136
if (err.code !== 'ATTEMPT_ABORTED') {
throw err
}
}
}

@@ -562,6 +570,11 @@

removeAwarenessStates(this.awareness, [this.document.clientID], 'provider destroy')
// If there is still a connection attempt outstanding then we should resolve
// it before calling disconnect, otherwise it will be rejected in the onClose
// handler and trigger a retry
this.resolveConnectionAttempt()
this.disconnect()
removeAwarenessStates(this.awareness, [this.document.clientID], 'provider destroy')
this.awareness.off('update', this.awarenessUpdateHandler)

@@ -568,0 +581,0 @@ this.document.off('update', this.documentUpdateHandler)

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 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