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

hub.js

Package Overview
Dependencies
Maintainers
1
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hub.js - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

23

dist/browser.es.js

@@ -196,4 +196,7 @@ import hash from 'string-hash';

hub.set({ clients: { [id]: { } } }, false);
const client = hub.clients[id];
hub.set({ client }, false);
hub.reconnect = null;

@@ -206,3 +209,3 @@

bs.close();
if (!socket.blockReconnect) {
if (!socket.blockReconnect && hub.url) {
reconnect = Math.min((reconnect * 1.5), 2000);

@@ -224,4 +227,4 @@ hub.reconnect = setTimeout(connect, reconnect, hub, url, reconnect);

socket.onopen = () => {
hub.socket = socket;
const stamp = bs.create('connected', hub.id);
hub.socket = socket;
meta(hub);

@@ -245,11 +248,11 @@ hub.set({ connected: true }, stamp);

hub.urlIndex = null;
hub.emitters.set({ data: { url$: null } });
hub.emitters.set({ data: { url$: null } }, false);
};
const removeSocket = hub => {
if (hub.reconnect) {
clearTimeout(hub.reconnect);
hub.reconnect = null;
}
if (hub.socket) {
if (hub.reconnect) {
clearTimeout(hub.reconnect);
hub.reconnect = null;
}
hub.socket.blockReconnect = true;

@@ -263,3 +266,5 @@ hub.socket.close();

if (val === null && !t.context && t === hub) {
// console.log('☠️ REMOVE CLIENT ☠️')
console.log('remove subs');
hub.subscriptions = [];
// console.log(`☠️ REMOVE CLIENT ${hub.id} ☠️`)
removeUrl(hub);

@@ -356,2 +361,3 @@ removeSocket(hub);

// export { props, define }

@@ -406,2 +412,3 @@

type: 'hub',
instances: false,
types: { hub: 'self' },

@@ -408,0 +415,0 @@ props: {

@@ -200,4 +200,7 @@ 'use strict';

hub.set({ clients: { [id]: { } } }, false);
const client = hub.clients[id];
hub.set({ client }, false);
hub.reconnect = null;

@@ -210,3 +213,3 @@

bs.close();
if (!socket.blockReconnect) {
if (!socket.blockReconnect && hub.url) {
reconnect = Math.min((reconnect * 1.5), 2000);

@@ -228,4 +231,4 @@ hub.reconnect = setTimeout(connect, reconnect, hub, url, reconnect);

socket.onopen = () => {
hub.socket = socket;
const stamp = bs.create('connected', hub.id);
hub.socket = socket;
meta(hub);

@@ -249,11 +252,11 @@ hub.set({ connected: true }, stamp);

hub.urlIndex = null;
hub.emitters.set({ data: { url$: null } });
hub.emitters.set({ data: { url$: null } }, false);
};
const removeSocket = hub => {
if (hub.reconnect) {
clearTimeout(hub.reconnect);
hub.reconnect = null;
}
if (hub.socket) {
if (hub.reconnect) {
clearTimeout(hub.reconnect);
hub.reconnect = null;
}
hub.socket.blockReconnect = true;

@@ -267,3 +270,5 @@ hub.socket.close();

if (val === null && !t.context && t === hub) {
// console.log('☠️ REMOVE CLIENT ☠️')
console.log('remove subs');
hub.subscriptions = [];
// console.log(`☠️ REMOVE CLIENT ${hub.id} ☠️`)
removeUrl(hub);

@@ -360,2 +365,3 @@ removeSocket(hub);

// export { props, define }

@@ -410,2 +416,3 @@

type: 'hub',
instances: false,
types: { hub: 'self' },

@@ -412,0 +419,0 @@ props: {

@@ -192,4 +192,7 @@ import hash from 'string-hash';

hub.set({ clients: { [id]: { } } }, false);
const client = hub.clients[id];
hub.set({ client }, false);
hub.reconnect = null;

@@ -202,3 +205,3 @@

bs.close();
if (!socket.blockReconnect) {
if (!socket.blockReconnect && hub.url) {
reconnect = Math.min((reconnect * 1.5), 2000);

@@ -220,4 +223,4 @@ hub.reconnect = setTimeout(connect, reconnect, hub, url, reconnect);

socket.onopen = () => {
hub.socket = socket;
const stamp = bs.create('connected', hub.id);
hub.socket = socket;
meta(hub);

@@ -241,11 +244,11 @@ hub.set({ connected: true }, stamp);

hub.urlIndex = null;
hub.emitters.set({ data: { url$: null } });
hub.emitters.set({ data: { url$: null } }, false);
};
const removeSocket = hub => {
if (hub.reconnect) {
clearTimeout(hub.reconnect);
hub.reconnect = null;
}
if (hub.socket) {
if (hub.reconnect) {
clearTimeout(hub.reconnect);
hub.reconnect = null;
}
hub.socket.blockReconnect = true;

@@ -259,3 +262,5 @@ hub.socket.close();

if (val === null && !t.context && t === hub) {
// console.log('☠️ REMOVE CLIENT ☠️')
console.log('remove subs');
hub.subscriptions = [];
// console.log(`☠️ REMOVE CLIENT ${hub.id} ☠️`)
removeUrl(hub);

@@ -352,2 +357,3 @@ removeSocket(hub);

// export { props, define }

@@ -401,3 +407,4 @@

i = i.slice(4);
// need to fix buble stuff in these fn creations -- prop need to add babel runtime in a hub
// need to fix buble stuff in these fn creations -- prop need to add buble
// runtime in a hub
let pass;

@@ -438,9 +445,11 @@ try {

bs.on(() => {
var isEmpty = true;
for (let i in client.inProgress) { //eslint-disable-line
isEmpty = false;
break
if (client.val !== null) {
var isEmpty = true;
for (let i in client.inProgress) { //eslint-disable-line
isEmpty = false;
break
}
if (!isEmpty) { client.socket.send(JSON.stringify(client.inProgress)); }
client.inProgress = false;
}
if (!isEmpty) { client.socket.send(JSON.stringify(client.inProgress)); }
client.inProgress = false;
});

@@ -654,2 +663,11 @@ }

const removeSubscriptions = (t, id) => {
let i = t.subscriptions ? t.subscriptions.length : 0;
while (i--) { // clean this up with system in struct
if (t.subscriptions[i].id === id) {
t.subscriptions.splice(i, 1);
}
}
};
const create$1 = (hub, port) => {

@@ -668,10 +686,5 @@ const server = new Server({ port });

const id = client.key;
console.log(`CLIENT DC ${hub.id} - REMOVE THE CLIENT CONTEXT (missing)`);
// console.log(`CLIENT DC ${hub.id} - REMOVE THE CLIENT CONTEXT (missing)`)
const t = client.parent(2);
let i = t.subscriptions ? t.subscriptions.length : 0;
while (i--) { // clean this up with system in struct
if (t.subscriptions[i].id === id) {
t.subscriptions.splice(i, 1);
}
}
removeSubscriptions(t, id);
client.set(null, stamp);

@@ -697,2 +710,3 @@ bs.close();

server.httpServer.close();
// remove all clients subscriptions
hub.server = null;

@@ -707,2 +721,4 @@ };

if (client.socket && client.key !== id) {
client.val = null;
removeSubscriptions(hub, client.key);
client.socket.close();

@@ -723,3 +739,3 @@ }

if (val === null && !t.context && t === hub) {
console.log('☠️ REMOVE server ☠️');
// console.log(`☠️ REMOVE ${hub.id} SERVER ☠️`)
removeServer(hub);

@@ -732,3 +748,3 @@ removePort(hub);

if (hub.server) {
console.log('πŸš€ SWITCH SERVER πŸš€');
// console.log('πŸš€ SWITCH SERVER πŸš€')
removeServer(hub);

@@ -835,2 +851,3 @@ }

type: 'hub',
instances: false,
types: { hub: 'self' },

@@ -837,0 +854,0 @@ props: {

@@ -196,4 +196,7 @@ 'use strict';

hub.set({ clients: { [id]: { } } }, false);
const client = hub.clients[id];
hub.set({ client }, false);
hub.reconnect = null;

@@ -206,3 +209,3 @@

bs.close();
if (!socket.blockReconnect) {
if (!socket.blockReconnect && hub.url) {
reconnect = Math.min((reconnect * 1.5), 2000);

@@ -224,4 +227,4 @@ hub.reconnect = setTimeout(connect, reconnect, hub, url, reconnect);

socket.onopen = () => {
hub.socket = socket;
const stamp = bs.create('connected', hub.id);
hub.socket = socket;
meta(hub);

@@ -245,11 +248,11 @@ hub.set({ connected: true }, stamp);

hub.urlIndex = null;
hub.emitters.set({ data: { url$: null } });
hub.emitters.set({ data: { url$: null } }, false);
};
const removeSocket = hub => {
if (hub.reconnect) {
clearTimeout(hub.reconnect);
hub.reconnect = null;
}
if (hub.socket) {
if (hub.reconnect) {
clearTimeout(hub.reconnect);
hub.reconnect = null;
}
hub.socket.blockReconnect = true;

@@ -263,3 +266,5 @@ hub.socket.close();

if (val === null && !t.context && t === hub) {
// console.log('☠️ REMOVE CLIENT ☠️')
console.log('remove subs');
hub.subscriptions = [];
// console.log(`☠️ REMOVE CLIENT ${hub.id} ☠️`)
removeUrl(hub);

@@ -356,2 +361,3 @@ removeSocket(hub);

// export { props, define }

@@ -405,3 +411,4 @@

i = i.slice(4);
// need to fix buble stuff in these fn creations -- prop need to add babel runtime in a hub
// need to fix buble stuff in these fn creations -- prop need to add buble
// runtime in a hub
let pass;

@@ -442,9 +449,11 @@ try {

bs.on(() => {
var isEmpty = true;
for (let i in client.inProgress) { //eslint-disable-line
isEmpty = false;
break
if (client.val !== null) {
var isEmpty = true;
for (let i in client.inProgress) { //eslint-disable-line
isEmpty = false;
break
}
if (!isEmpty) { client.socket.send(JSON.stringify(client.inProgress)); }
client.inProgress = false;
}
if (!isEmpty) { client.socket.send(JSON.stringify(client.inProgress)); }
client.inProgress = false;
});

@@ -658,2 +667,11 @@ }

const removeSubscriptions = (t, id) => {
let i = t.subscriptions ? t.subscriptions.length : 0;
while (i--) { // clean this up with system in struct
if (t.subscriptions[i].id === id) {
t.subscriptions.splice(i, 1);
}
}
};
const create$1 = (hub, port) => {

@@ -672,10 +690,5 @@ const server = new Server({ port });

const id = client.key;
console.log(`CLIENT DC ${hub.id} - REMOVE THE CLIENT CONTEXT (missing)`);
// console.log(`CLIENT DC ${hub.id} - REMOVE THE CLIENT CONTEXT (missing)`)
const t = client.parent(2);
let i = t.subscriptions ? t.subscriptions.length : 0;
while (i--) { // clean this up with system in struct
if (t.subscriptions[i].id === id) {
t.subscriptions.splice(i, 1);
}
}
removeSubscriptions(t, id);
client.set(null, stamp);

@@ -701,2 +714,3 @@ bs.close();

server.httpServer.close();
// remove all clients subscriptions
hub.server = null;

@@ -711,2 +725,4 @@ };

if (client.socket && client.key !== id) {
client.val = null;
removeSubscriptions(hub, client.key);
client.socket.close();

@@ -727,3 +743,3 @@ }

if (val === null && !t.context && t === hub) {
console.log('☠️ REMOVE server ☠️');
// console.log(`☠️ REMOVE ${hub.id} SERVER ☠️`)
removeServer(hub);

@@ -736,3 +752,3 @@ removePort(hub);

if (hub.server) {
console.log('πŸš€ SWITCH SERVER πŸš€');
// console.log('πŸš€ SWITCH SERVER πŸš€')
removeServer(hub);

@@ -839,2 +855,3 @@ }

type: 'hub',
instances: false,
types: { hub: 'self' },

@@ -841,0 +858,0 @@ props: {

{
"name": "hub.js",
"description": "Seamless realtime communcation",
"version": "0.0.3",
"version": "0.0.4",
"main": "dist/index.js",

@@ -19,2 +19,3 @@ "module": "dist/index.es.js",

"prepublish": "npm run build",
"watch": "node rollup/watch",
"postinstall": "[ -d dist ] || npm run build || ( mkdir dist && yarn && npm run build )",

@@ -44,3 +45,3 @@ "test": "node test/index.js",

"brisky-stamp": "^3.0.11",
"brisky-struct": "^1.0.2",
"brisky-struct": "^1.0.6",
"string-hash": "^1.1.0",

@@ -47,0 +48,0 @@ "uws": "0.12.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 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