New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.11-7d8a170431bac9b23de7c7c8468348ff668d61d0 to 0.0.11-906f01f6023971bcb9a7054634690bcc36335fa4

dist/index.browser.inline.js

383

dist/browser.es.js

@@ -1,6 +0,10 @@

import { create, parse, set, struct, subscribe } from 'brisky-struct';
import hash from 'string-hash';
import { c, create, parse, set, struct, subscribe } from 'brisky-struct';
import bs from 'brisky-stamp';
import hash from 'string-hash';
import ua from 'vigour-ua';
const uniq = global.navigator.userAgent +
global.navigator.userLanguage +
global.navigator.language;
var id = hash(`b-${Date.now()}-${(Math.random() * 10000) | 0}-${uniq}`);
const next = typeof window === 'undefined'

@@ -10,8 +14,19 @@ ? process.nextTick

const serialize = (hub, t, struct$$1, val, level) => {
if (!struct$$1.isHub || struct$$1.key === 'clients' || (struct$$1._p && struct$$1._p.key === 'clients')) {
return
const parse$1 = (stamp, hub, t) => {
const src = bs.src(stamp);
if (!src) {
return bs.create(bs.type(stamp), hub.id, bs.val(stamp))
} else {
const val = bs.val(stamp);
if (!t[1]) t[1] = {};
const meta = t[1];
if (!meta.resolve) meta.resolve = {};
const resolve = meta.resolve[src];
if (!resolve || val < resolve) meta.resolve[src] = val;
return stamp
}
};
const path = struct$$1.path(); // cached version (later)
const serialize = (hub, t, struct$$1, val, level) => {
const path = struct$$1.path();
const len = path.length;

@@ -32,3 +47,3 @@

s.stamp = struct$$1.stamp;
s.stamp = parse$1(struct$$1.stamp, hub, t);

@@ -43,9 +58,5 @@ if (val === null) {

} else if (struct$$1.val && struct$$1.val.inherits) {
// make a bit more secure...
// if (!s.val) {
s.val = struct$$1.val.path();
s.val.unshift('@', 'root');
// if allrdy serialized stop it!
serialize(hub, t, struct$$1.val, val, level);
// }
} else if (struct$$1.val !== void 0) {

@@ -58,37 +69,29 @@ s.val = struct$$1.val;

const meta = hub => {
if (!hub.receiveOnly) {
const store = inProgress(hub, bs.inProgress ? bs.on : next);
if (!store[1]) store[1] = {};
if (hub.context) {
if (hub.context.keys().length > 0) {
store[1].context = hub.context.compute() ? hub.context.serialize() : false;
} else {
store[1].context = hub.context.compute() || false;
}
}
store[1].id = hub.client.key;
store[1].subscriptions = hub.upstreamSubscriptions;
}
const store = inProgress(hub, bs.inProgress ? bs.on : next);
if (!store[1]) store[1] = {};
store[1].context = hub.clientContext;
store[1].id = hub.id;
store[1].subscriptions = hub.upstreamSubscriptions;
};
const send = (val, stamp, struct$$1) => {
// -1 means upsteam (floats for extra speed)
let hub;
let p = struct$$1;
while (p) {
if (p._url_ && !p._c) hub = p;
p = p.parent(); // needs to walk over context (for multi server)
}
if (hub && !hub.receiveOnly) {
if (struct$$1 === hub) {
if (val === null) {
return
if (bs.type(stamp) !== 'upstream') {
let hub;
let p = struct$$1;
while (p) {
if (p.url && !p._c) { hub = p; }
p = p.parent(); // needs to walk over context (for multi server)
}
if (hub && !hub.receiveOnly && struct$$1.key !== 'clients') {
if (struct$$1 === hub) {
if (val === null) {
return
}
} else if (struct$$1._p.key === 'clients') {
if (struct$$1.key !== hub.id) {
return
}
}
} else if (struct$$1._p.key === 'clients') {
if (struct$$1.key !== hub.client.key) {
return
}
serialize(hub, inProgress(hub, bs.on), struct$$1, val, hub.urlIndex);
}
serialize(hub, inProgress(hub, bs.on), struct$$1, val, hub.urlIndex);
}

@@ -134,7 +137,6 @@ };

const parse$1 = (struct$$1, obj, key, root) => {
const parse$2 = (struct$$1, obj, key, root) => {
const result = {};
if (!root) { root = result; }
// need to be done before the rest of subs to sync correctly
if (obj.type) result.type = parse$1(struct$$1, obj.type, 'type');
if (obj.type) result.type = obj.type; // need to be done before the rest of subs to sync correctly
for (let i in obj) {

@@ -146,3 +148,3 @@ if (i !== '_' && i !== 'type') {

// console.log('CLIENT NEED TO HANDLE MORE SPECIAL THEN JUST ROOT')
// let id = state._uid_
// let id = state.id
// if (!root.clients) { root.clients = {} }

@@ -176,3 +178,3 @@ // if (!root.clients[id]) { root.clients[id] = {} }

// empty objects are very uninteresetting maybe just skip them
let parsed = parse$1(struct$$1, obj[i], i, root);
let parsed = parse$2(struct$$1, obj[i], i, root);

@@ -195,19 +197,10 @@ // if (i === 'root' || i === 'parent') {

const uniq = global.navigator.userAgent +
global.navigator.userLanguage +
global.navigator.language;
var uid = () => hash(`b-${Date.now()}-${(Math.random() * 10000) | 0}-${uniq}`);
var createClient = (t, val, stamp, useragent, id) => {
if (!id) id = t._uid_ || uid();
ua(useragent, val);
t.set({ clients: { [id]: val } }, stamp);
return t.clients[id]
};
const connect = (hub, url, reconnect) => {
const socket = new WebSocket(url);
// t, val, stamp, useragent, id
const client = hub.client || createClient(hub, {}, false);
const id = hub.id;
hub.set({ clients: { [id]: { } } }, false);
const client = hub.clients[id];
hub.set({ client }, false);

@@ -218,7 +211,7 @@

const close = () => {
const stamp = bs.create();
const stamp = bs.create('disconnect', hub.id);
hub.socket = false;
hub.set({ connected: false }, stamp);
bs.close();
if (!socket.blockReconnect && hub._url_) {
if (!socket.blockReconnect && hub.url) {
reconnect = Math.min((reconnect * 1.5), 2000);

@@ -231,12 +224,12 @@ hub.reconnect = setTimeout(connect, reconnect, hub, url, reconnect);

if (typeof window === 'undefined') {
socket.hackyOnClose = close;
}
socket.onerror = () => {
if (typeof window === 'undefined') {
close();
} else {
socket.close();
}
};
socket.onerror = typeof window === 'undefined'
? close
: () => socket.close();
socket.onopen = () => {
const stamp = bs.create();
const stamp = bs.create('connected', hub.id);
hub.socket = socket;

@@ -248,13 +241,7 @@ meta(hub);

socket.onmessage = (data) => {
data = data.data;
// console.warn('INCOMING\n', JSON.parse(data))
if (!hub.receiveOnly) {
hub.receiveOnly = true;
hub.set(JSON.parse(data), false);
hub.receiveOnly = null;
} else {
hub.set(JSON.parse(data), false);
}
bs.close();
socket.onmessage = ({ data }) => {
const stamp = bs.create('upstream');
// console.log(JSON.stringify(JSON.parse(data), false, 2))
hub.set(JSON.parse(data), stamp);
bs.close(stamp);
};

@@ -264,3 +251,4 @@ };

const removeUrl = hub => {
hub.url = hub._url_ = hub.urlIndex = null;
hub.url = null;
hub.urlIndex = null;
hub.emitters.set({ data: { url$: null } }, false);

@@ -276,14 +264,7 @@ };

hub.socket.blockReconnect = true;
console.log('GO GO GOREMOVE', hub.socket._readyState);
if (hub.connected.compute() === false || !hub.socket._readyState) {
console.log('hacky!');
hub.socket.hackyOnClose();
} else {
hub.socket.close();
}
hub.socket.close();
}
// hub.socket = false
};
const url = (hub, val, key, stamp) => {
const url = (hub, val, stamp) => {
hub.on((val, stamp, t) => {

@@ -296,34 +277,15 @@ if (val === null && !t._c && t === hub) {

}, 'url$');
if (!val) val = null;
if ((!hub.url && val) || (hub.url.compute() !== val)) {
if (val !== hub.url) {
removeSocket(hub);
hub.set({ connected: false }, stamp);
if (!val) {
hub.set({ connected: false }, stamp);
hub._url_ = null;
if (hub.url) hub.url.set(null, stamp);
removeUrl(hub);
} else {
if (!hub.url) {
create({
on: {
data: {
url: (val, stamp, struct$$1) => {
val = struct$$1.compute();
if (val) {
hub.set({ connected: false }, stamp);
let i = -1;
if (hub.key) i++;
hub.parent(() => { i++; });
hub.urlIndex = i; // use this for checks
hub._url_ = val;
connect(hub, val, 50);
} else {
hub._url_ = null;
}
}
}
}
}, stamp, struct, hub, key);
}
hub.url.set(val, stamp);
let i = -1;
if (hub.key) i++;
hub.parent(() => { i++; });
hub.urlIndex = i;
hub.url = val;
connect(hub, val, 50);
}

@@ -333,69 +295,27 @@ }

const removeClients = (hub, stamp) => {
const clients = hub.clients;
if (clients && clients.keys().length > 1) {
clients.forEach((client, key) => {
if (
client.val !== null &&
client !== hub.client
) {
client.set(null, stamp);
delete clients[key];
}
});
}
};
// very context as well
// const clients => (val, stamp) {
// const hub = this.cParent()
// if (this.compute() === false && hub.upstream) {
// // put this in clients (the file)
// const clients = hub.clients
// if (clients && clients.keys().length > 1) {
// clients.each((client) => {
// if (
// client.val !== null &&
// !client.socket &&
// client.key != hub.id // eslint-disable-line
// ) {
// client.remove(stamp)
// }
// })
// }
// }
// }
const connected = {
type: 'struct',
on: {
data: {
removeClients: (val, stamp, t) => {
if (t.compute() === false) {
// all instances! -- fix this
removeClients(t._p, stamp);
}
}
}
}
};
const connected = { type: 'struct' };
const contextStruct = struct.create({
props: {
default: {
on: {
data: {
updateParent: (val, stamp, t) => {
console.log('👻 GO UPDATE PARENT!!! 👻');
t.parent().emit('data', val, stamp);
}
}
}
}
}
});
const contextIsNotEqual = (val, context) => {
if (val && typeof val === 'object') {
for (let field in val) {
if (!context[field] || val[field] !== context[field].compute()) {
console.log('😜', field);
return true
}
}
} else {
console.log('😜 ?????');
return val !== context.compute()
}
};
const context = (hub, val, key, stamp) => {
if (!hub.context || contextIsNotEqual(val, hub.context)) {
console.log('⚽️ fire fire fire FLAME context ⚽️', val, stamp);
if (!hub.context) {
create(val, stamp, contextStruct, hub, key);
} else {
removeClients(hub, stamp);
hub.context.set(val, stamp);
}
const context = (hub, val) => {
if (val !== hub.clientContext) {
hub.clientContext = val;
if (hub.connected && hub.connected.compute() === true) meta(hub);

@@ -421,13 +341,11 @@ }

if (!raw) subs = parse(subs);
if (!this.receiveOnly) {
const parsed = parse$1(this, subs);
if (parsed) {
const key = hash(JSON.stringify(parsed));
if (!this.upstreamSubscriptions) {
this.upstreamSubscriptions = { [key]: parsed };
if (this.url) meta(this);
} else if (!this.upstreamSubscriptions[key]) {
this.upstreamSubscriptions[key] = parsed;
if (this.url) meta(this);
}
const parsed = parse$2(this, subs);
if (parsed) {
const key = hash(JSON.stringify(parsed));
if (!this.upstreamSubscriptions) {
this.upstreamSubscriptions = { [key]: parsed };
if (this.url) meta(this);
} else if (!this.upstreamSubscriptions[key]) {
this.upstreamSubscriptions[key] = parsed;
if (this.url) meta(this);
}

@@ -457,24 +375,12 @@ }

var context$1 = {
props: {
contextKey: true,
getContext: (t, fn) => {
t.set({
define: {
getContext (key, socket) {
return fn(key, (key) => createContext(this, key), this, socket)
}
}
});
const props$1 = { contextKey: true };
const define$1 = {
getContext (val) {
var result = find(this, val);
if (!result) {
result = this.create({ contextKey: val }, false);
}
},
getContext: (key, context) => context()
};
const createContext = (hub, val) => {
var result = find(hub, val);
if (!result) {
result = hub.create({ contextKey: val }, false);
return result
}
return result
};

@@ -487,3 +393,6 @@

while (i--) {
if (instances[i].contextKey === val) return instances[i]
if (instances[i].contextKey === val) {
// console.log('found context --->', val, instances[i].clients.keys())
return instances[i]
}
}

@@ -493,2 +402,8 @@ }

var context$1 = Object.freeze({
props: props$1,
define: define$1
});
const types = struct.props.types;

@@ -502,7 +417,6 @@

default: 'self',
_uid_: (t, val) => { t.set({ define: { _uid_: val } }); },
// why nto call this client id -- thats what it is
id: (t, val) => { t.set({ define: { id: val } }); },
clients: (t, val, key, stamp) => {
if (!t.clients) {
t.clients = create(val, stamp, clients, t, key);
t.clients = c(clients, val, stamp, t, key);
} else {

@@ -515,12 +429,13 @@ set(t.clients, val, stamp);

client: true
}
},
id
});
hub.props.types.struct = hub.create({
hub.props.types.struct = c(hub, {
props: { default: types.struct.props.default.bind() }
}, false);
});
hub.props.types.struct.props.default.struct = hub.props.type.struct = hub;
hub.set({ types: { hub: 'self' }, inject: [ server, client, context$1 ] }, false);
hub.set({ types: { hub: 'self' }, inject: [ server, context$1, client ] }, false);

@@ -539,13 +454,21 @@ hub.types._ks = void 0;

}
}, false)
})
}
}, false);
});
if (typeof __filename !== 'undefined') console.log('hub.js:', __filename);
// import bs from 'brisky-stamp'
const fn = (val, stamp) => hub.create(val, stamp);
var index = (val, stamp) => {
if (stamp === void 0) {
const r = hub.create(val, bs.create());
bs.close();
return r
} else {
return hub.create(val, stamp)
}
};
// add uids to stamps else it sucks -- dont compromise for tests think of that as an after thought
export default fn;
export default index;
//# sourceMappingURL=browser.es.js.map

@@ -5,7 +5,11 @@ 'use strict';

var hash = _interopDefault(require('string-hash'));
var briskyStruct = require('brisky-struct');
var bs = _interopDefault(require('brisky-stamp'));
var hash = _interopDefault(require('string-hash'));
var ua = _interopDefault(require('vigour-ua'));
const uniq = global.navigator.userAgent +
global.navigator.userLanguage +
global.navigator.language;
var id = hash(`b-${Date.now()}-${(Math.random() * 10000) | 0}-${uniq}`);
const next = typeof window === 'undefined'

@@ -15,8 +19,19 @@ ? process.nextTick

const serialize = (hub, t, struct$$1, val, level) => {
if (!struct$$1.isHub || struct$$1.key === 'clients' || (struct$$1._p && struct$$1._p.key === 'clients')) {
return
const parse$1 = (stamp, hub, t) => {
const src = bs.src(stamp);
if (!src) {
return bs.create(bs.type(stamp), hub.id, bs.val(stamp))
} else {
const val = bs.val(stamp);
if (!t[1]) t[1] = {};
const meta = t[1];
if (!meta.resolve) meta.resolve = {};
const resolve = meta.resolve[src];
if (!resolve || val < resolve) meta.resolve[src] = val;
return stamp
}
};
const path = struct$$1.path(); // cached version (later)
const serialize = (hub, t, struct$$1, val, level) => {
const path = struct$$1.path();
const len = path.length;

@@ -37,3 +52,3 @@

s.stamp = struct$$1.stamp;
s.stamp = parse$1(struct$$1.stamp, hub, t);

@@ -48,9 +63,5 @@ if (val === null) {

} else if (struct$$1.val && struct$$1.val.inherits) {
// make a bit more secure...
// if (!s.val) {
s.val = struct$$1.val.path();
s.val.unshift('@', 'root');
// if allrdy serialized stop it!
serialize(hub, t, struct$$1.val, val, level);
// }
} else if (struct$$1.val !== void 0) {

@@ -63,37 +74,29 @@ s.val = struct$$1.val;

const meta = hub => {
if (!hub.receiveOnly) {
const store = inProgress(hub, bs.inProgress ? bs.on : next);
if (!store[1]) store[1] = {};
if (hub.context) {
if (hub.context.keys().length > 0) {
store[1].context = hub.context.compute() ? hub.context.serialize() : false;
} else {
store[1].context = hub.context.compute() || false;
}
}
store[1].id = hub.client.key;
store[1].subscriptions = hub.upstreamSubscriptions;
}
const store = inProgress(hub, bs.inProgress ? bs.on : next);
if (!store[1]) store[1] = {};
store[1].context = hub.clientContext;
store[1].id = hub.id;
store[1].subscriptions = hub.upstreamSubscriptions;
};
const send = (val, stamp, struct$$1) => {
// -1 means upsteam (floats for extra speed)
let hub;
let p = struct$$1;
while (p) {
if (p._url_ && !p._c) hub = p;
p = p.parent(); // needs to walk over context (for multi server)
}
if (hub && !hub.receiveOnly) {
if (struct$$1 === hub) {
if (val === null) {
return
if (bs.type(stamp) !== 'upstream') {
let hub;
let p = struct$$1;
while (p) {
if (p.url && !p._c) { hub = p; }
p = p.parent(); // needs to walk over context (for multi server)
}
if (hub && !hub.receiveOnly && struct$$1.key !== 'clients') {
if (struct$$1 === hub) {
if (val === null) {
return
}
} else if (struct$$1._p.key === 'clients') {
if (struct$$1.key !== hub.id) {
return
}
}
} else if (struct$$1._p.key === 'clients') {
if (struct$$1.key !== hub.client.key) {
return
}
serialize(hub, inProgress(hub, bs.on), struct$$1, val, hub.urlIndex);
}
serialize(hub, inProgress(hub, bs.on), struct$$1, val, hub.urlIndex);
}

@@ -139,7 +142,6 @@ };

const parse$1 = (struct$$1, obj, key, root) => {
const parse$2 = (struct$$1, obj, key, root) => {
const result = {};
if (!root) { root = result; }
// need to be done before the rest of subs to sync correctly
if (obj.type) result.type = parse$1(struct$$1, obj.type, 'type');
if (obj.type) result.type = obj.type; // need to be done before the rest of subs to sync correctly
for (let i in obj) {

@@ -151,3 +153,3 @@ if (i !== '_' && i !== 'type') {

// console.log('CLIENT NEED TO HANDLE MORE SPECIAL THEN JUST ROOT')
// let id = state._uid_
// let id = state.id
// if (!root.clients) { root.clients = {} }

@@ -181,3 +183,3 @@ // if (!root.clients[id]) { root.clients[id] = {} }

// empty objects are very uninteresetting maybe just skip them
let parsed = parse$1(struct$$1, obj[i], i, root);
let parsed = parse$2(struct$$1, obj[i], i, root);

@@ -200,19 +202,10 @@ // if (i === 'root' || i === 'parent') {

const uniq = global.navigator.userAgent +
global.navigator.userLanguage +
global.navigator.language;
var uid = () => hash(`b-${Date.now()}-${(Math.random() * 10000) | 0}-${uniq}`);
var createClient = (t, val, stamp, useragent, id) => {
if (!id) id = t._uid_ || uid();
ua(useragent, val);
t.set({ clients: { [id]: val } }, stamp);
return t.clients[id]
};
const connect = (hub, url, reconnect) => {
const socket = new WebSocket(url);
// t, val, stamp, useragent, id
const client = hub.client || createClient(hub, {}, false);
const id = hub.id;
hub.set({ clients: { [id]: { } } }, false);
const client = hub.clients[id];
hub.set({ client }, false);

@@ -223,7 +216,7 @@

const close = () => {
const stamp = bs.create();
const stamp = bs.create('disconnect', hub.id);
hub.socket = false;
hub.set({ connected: false }, stamp);
bs.close();
if (!socket.blockReconnect && hub._url_) {
if (!socket.blockReconnect && hub.url) {
reconnect = Math.min((reconnect * 1.5), 2000);

@@ -236,12 +229,12 @@ hub.reconnect = setTimeout(connect, reconnect, hub, url, reconnect);

if (typeof window === 'undefined') {
socket.hackyOnClose = close;
}
socket.onerror = () => {
if (typeof window === 'undefined') {
close();
} else {
socket.close();
}
};
socket.onerror = typeof window === 'undefined'
? close
: () => socket.close();
socket.onopen = () => {
const stamp = bs.create();
const stamp = bs.create('connected', hub.id);
hub.socket = socket;

@@ -253,13 +246,7 @@ meta(hub);

socket.onmessage = (data) => {
data = data.data;
// console.warn('INCOMING\n', JSON.parse(data))
if (!hub.receiveOnly) {
hub.receiveOnly = true;
hub.set(JSON.parse(data), false);
hub.receiveOnly = null;
} else {
hub.set(JSON.parse(data), false);
}
bs.close();
socket.onmessage = ({ data }) => {
const stamp = bs.create('upstream');
// console.log(JSON.stringify(JSON.parse(data), false, 2))
hub.set(JSON.parse(data), stamp);
bs.close(stamp);
};

@@ -269,3 +256,4 @@ };

const removeUrl = hub => {
hub.url = hub._url_ = hub.urlIndex = null;
hub.url = null;
hub.urlIndex = null;
hub.emitters.set({ data: { url$: null } }, false);

@@ -281,14 +269,7 @@ };

hub.socket.blockReconnect = true;
console.log('GO GO GOREMOVE', hub.socket._readyState);
if (hub.connected.compute() === false || !hub.socket._readyState) {
console.log('hacky!');
hub.socket.hackyOnClose();
} else {
hub.socket.close();
}
hub.socket.close();
}
// hub.socket = false
};
const url = (hub, val, key, stamp) => {
const url = (hub, val, stamp) => {
hub.on((val, stamp, t) => {

@@ -301,34 +282,15 @@ if (val === null && !t._c && t === hub) {

}, 'url$');
if (!val) val = null;
if ((!hub.url && val) || (hub.url.compute() !== val)) {
if (val !== hub.url) {
removeSocket(hub);
hub.set({ connected: false }, stamp);
if (!val) {
hub.set({ connected: false }, stamp);
hub._url_ = null;
if (hub.url) hub.url.set(null, stamp);
removeUrl(hub);
} else {
if (!hub.url) {
briskyStruct.create({
on: {
data: {
url: (val, stamp, struct$$1) => {
val = struct$$1.compute();
if (val) {
hub.set({ connected: false }, stamp);
let i = -1;
if (hub.key) i++;
hub.parent(() => { i++; });
hub.urlIndex = i; // use this for checks
hub._url_ = val;
connect(hub, val, 50);
} else {
hub._url_ = null;
}
}
}
}
}, stamp, briskyStruct.struct, hub, key);
}
hub.url.set(val, stamp);
let i = -1;
if (hub.key) i++;
hub.parent(() => { i++; });
hub.urlIndex = i;
hub.url = val;
connect(hub, val, 50);
}

@@ -338,69 +300,27 @@ }

const removeClients = (hub, stamp) => {
const clients = hub.clients;
if (clients && clients.keys().length > 1) {
clients.forEach((client, key) => {
if (
client.val !== null &&
client !== hub.client
) {
client.set(null, stamp);
delete clients[key];
}
});
}
};
// very context as well
// const clients => (val, stamp) {
// const hub = this.cParent()
// if (this.compute() === false && hub.upstream) {
// // put this in clients (the file)
// const clients = hub.clients
// if (clients && clients.keys().length > 1) {
// clients.each((client) => {
// if (
// client.val !== null &&
// !client.socket &&
// client.key != hub.id // eslint-disable-line
// ) {
// client.remove(stamp)
// }
// })
// }
// }
// }
const connected = {
type: 'struct',
on: {
data: {
removeClients: (val, stamp, t) => {
if (t.compute() === false) {
// all instances! -- fix this
removeClients(t._p, stamp);
}
}
}
}
};
const connected = { type: 'struct' };
const contextStruct = briskyStruct.struct.create({
props: {
default: {
on: {
data: {
updateParent: (val, stamp, t) => {
console.log('👻 GO UPDATE PARENT!!! 👻');
t.parent().emit('data', val, stamp);
}
}
}
}
}
});
const contextIsNotEqual = (val, context) => {
if (val && typeof val === 'object') {
for (let field in val) {
if (!context[field] || val[field] !== context[field].compute()) {
console.log('😜', field);
return true
}
}
} else {
console.log('😜 ?????');
return val !== context.compute()
}
};
const context = (hub, val, key, stamp) => {
if (!hub.context || contextIsNotEqual(val, hub.context)) {
console.log('⚽️ fire fire fire FLAME context ⚽️', val, stamp);
if (!hub.context) {
briskyStruct.create(val, stamp, contextStruct, hub, key);
} else {
removeClients(hub, stamp);
hub.context.set(val, stamp);
}
const context = (hub, val) => {
if (val !== hub.clientContext) {
hub.clientContext = val;
if (hub.connected && hub.connected.compute() === true) meta(hub);

@@ -426,13 +346,11 @@ }

if (!raw) subs = briskyStruct.parse(subs);
if (!this.receiveOnly) {
const parsed = parse$1(this, subs);
if (parsed) {
const key = hash(JSON.stringify(parsed));
if (!this.upstreamSubscriptions) {
this.upstreamSubscriptions = { [key]: parsed };
if (this.url) meta(this);
} else if (!this.upstreamSubscriptions[key]) {
this.upstreamSubscriptions[key] = parsed;
if (this.url) meta(this);
}
const parsed = parse$2(this, subs);
if (parsed) {
const key = hash(JSON.stringify(parsed));
if (!this.upstreamSubscriptions) {
this.upstreamSubscriptions = { [key]: parsed };
if (this.url) meta(this);
} else if (!this.upstreamSubscriptions[key]) {
this.upstreamSubscriptions[key] = parsed;
if (this.url) meta(this);
}

@@ -462,24 +380,12 @@ }

var context$1 = {
props: {
contextKey: true,
getContext: (t, fn) => {
t.set({
define: {
getContext (key, socket) {
return fn(key, (key) => createContext(this, key), this, socket)
}
}
});
const props$1 = { contextKey: true };
const define$1 = {
getContext (val) {
var result = find(this, val);
if (!result) {
result = this.create({ contextKey: val }, false);
}
},
getContext: (key, context) => context()
};
const createContext = (hub, val) => {
var result = find(hub, val);
if (!result) {
result = hub.create({ contextKey: val }, false);
return result
}
return result
};

@@ -492,3 +398,6 @@

while (i--) {
if (instances[i].contextKey === val) return instances[i]
if (instances[i].contextKey === val) {
// console.log('found context --->', val, instances[i].clients.keys())
return instances[i]
}
}

@@ -498,2 +407,8 @@ }

var context$1 = Object.freeze({
props: props$1,
define: define$1
});
const types = briskyStruct.struct.props.types;

@@ -507,7 +422,6 @@

default: 'self',
_uid_: (t, val) => { t.set({ define: { _uid_: val } }); },
// why nto call this client id -- thats what it is
id: (t, val) => { t.set({ define: { id: val } }); },
clients: (t, val, key, stamp) => {
if (!t.clients) {
t.clients = briskyStruct.create(val, stamp, clients, t, key);
t.clients = briskyStruct.c(clients, val, stamp, t, key);
} else {

@@ -520,12 +434,13 @@ briskyStruct.set(t.clients, val, stamp);

client: true
}
},
id
});
hub.props.types.struct = hub.create({
hub.props.types.struct = briskyStruct.c(hub, {
props: { default: types.struct.props.default.bind() }
}, false);
});
hub.props.types.struct.props.default.struct = hub.props.type.struct = hub;
hub.set({ types: { hub: 'self' }, inject: [ server, client, context$1 ] }, false);
hub.set({ types: { hub: 'self' }, inject: [ server, context$1, client ] }, false);

@@ -544,13 +459,21 @@ hub.types._ks = void 0;

}
}, false)
})
}
}, false);
});
if (typeof __filename !== 'undefined') console.log('hub.js:', __filename);
// import bs from 'brisky-stamp'
const fn = (val, stamp) => hub.create(val, stamp);
var index = (val, stamp) => {
if (stamp === void 0) {
const r = hub.create(val, bs.create());
bs.close();
return r
} else {
return hub.create(val, stamp)
}
};
// add uids to stamps else it sucks -- dont compromise for tests think of that as an after thought
module.exports = fn;
module.exports = index;
//# sourceMappingURL=browser.js.map

@@ -1,8 +0,9 @@

import { create, get, getKeys, getType, getVal, parse, puid, set, struct, subscribe } from 'brisky-struct';
import hash from 'string-hash';
import { c, create, get, getKeys, getType, parse, set, struct, subscribe } from 'brisky-struct';
import bs from 'brisky-stamp';
import { w3cwebsocket } from 'websocket';
import hash from 'string-hash';
import ua from 'vigour-ua';
import uws from 'uws';
import WebSocket from 'uws';
const uniq = process.pid;
var id = hash(`b-${Date.now()}-${(Math.random() * 10000) | 0}-${uniq}`);
const next = typeof window === 'undefined'

@@ -12,8 +13,19 @@ ? process.nextTick

const serialize = (hub, t, struct$$1, val, level) => {
if (!struct$$1.isHub || struct$$1.key === 'clients' || (struct$$1._p && struct$$1._p.key === 'clients')) {
return
const parse$1 = (stamp, hub, t) => {
const src = bs.src(stamp);
if (!src) {
return bs.create(bs.type(stamp), hub.id, bs.val(stamp))
} else {
const val = bs.val(stamp);
if (!t[1]) t[1] = {};
const meta = t[1];
if (!meta.resolve) meta.resolve = {};
const resolve = meta.resolve[src];
if (!resolve || val < resolve) meta.resolve[src] = val;
return stamp
}
};
const path = struct$$1.path(); // cached version (later)
const serialize = (hub, t, struct$$1, val, level) => {
const path = struct$$1.path();
const len = path.length;

@@ -34,3 +46,3 @@

s.stamp = struct$$1.stamp;
s.stamp = parse$1(struct$$1.stamp, hub, t);

@@ -45,9 +57,5 @@ if (val === null) {

} else if (struct$$1.val && struct$$1.val.inherits) {
// make a bit more secure...
// if (!s.val) {
s.val = struct$$1.val.path();
s.val.unshift('@', 'root');
// if allrdy serialized stop it!
serialize(hub, t, struct$$1.val, val, level);
// }
} else if (struct$$1.val !== void 0) {

@@ -60,37 +68,29 @@ s.val = struct$$1.val;

const meta = hub => {
if (!hub.receiveOnly) {
const store = inProgress(hub, bs.inProgress ? bs.on : next);
if (!store[1]) store[1] = {};
if (hub.context) {
if (hub.context.keys().length > 0) {
store[1].context = hub.context.compute() ? hub.context.serialize() : false;
} else {
store[1].context = hub.context.compute() || false;
}
}
store[1].id = hub.client.key;
store[1].subscriptions = hub.upstreamSubscriptions;
}
const store = inProgress(hub, bs.inProgress ? bs.on : next);
if (!store[1]) store[1] = {};
store[1].context = hub.clientContext;
store[1].id = hub.id;
store[1].subscriptions = hub.upstreamSubscriptions;
};
const send = (val, stamp, struct$$1) => {
// -1 means upsteam (floats for extra speed)
let hub;
let p = struct$$1;
while (p) {
if (p._url_ && !p._c) hub = p;
p = p.parent(); // needs to walk over context (for multi server)
}
if (hub && !hub.receiveOnly) {
if (struct$$1 === hub) {
if (val === null) {
return
if (bs.type(stamp) !== 'upstream') {
let hub;
let p = struct$$1;
while (p) {
if (p.url && !p._c) { hub = p; }
p = p.parent(); // needs to walk over context (for multi server)
}
if (hub && !hub.receiveOnly && struct$$1.key !== 'clients') {
if (struct$$1 === hub) {
if (val === null) {
return
}
} else if (struct$$1._p.key === 'clients') {
if (struct$$1.key !== hub.id) {
return
}
}
} else if (struct$$1._p.key === 'clients') {
if (struct$$1.key !== hub.client.key) {
return
}
serialize(hub, inProgress(hub, bs.on), struct$$1, val, hub.urlIndex);
}
serialize(hub, inProgress(hub, bs.on), struct$$1, val, hub.urlIndex);
}

@@ -118,5 +118,2 @@ };

// import WebSocket from 'uws'
// export default WebSocket
const isEmpty = t => {

@@ -137,7 +134,6 @@ for (let i in t) { return false }

const parse$1 = (struct$$1, obj, key, root) => {
const parse$2 = (struct$$1, obj, key, root) => {
const result = {};
if (!root) { root = result; }
// need to be done before the rest of subs to sync correctly
if (obj.type) result.type = parse$1(struct$$1, obj.type, 'type');
if (obj.type) result.type = obj.type; // need to be done before the rest of subs to sync correctly
for (let i in obj) {

@@ -149,3 +145,3 @@ if (i !== '_' && i !== 'type') {

// console.log('CLIENT NEED TO HANDLE MORE SPECIAL THEN JUST ROOT')
// let id = state._uid_
// let id = state.id
// if (!root.clients) { root.clients = {} }

@@ -179,3 +175,3 @@ // if (!root.clients[id]) { root.clients[id] = {} }

// empty objects are very uninteresetting maybe just skip them
let parsed = parse$1(struct$$1, obj[i], i, root);
let parsed = parse$2(struct$$1, obj[i], i, root);

@@ -198,16 +194,9 @@ // if (i === 'root' || i === 'parent') {

const uniq = process.pid;
var uid = () => hash(`b-${Date.now()}-${(Math.random() * 10000) | 0}-${uniq}`);
const connect = (hub, url, reconnect) => {
const socket = new WebSocket(url);
const id = hub.id;
var createClient = (t, val, stamp, useragent, id) => {
if (!id) id = t._uid_ || uid();
ua(useragent, val);
t.set({ clients: { [id]: val } }, stamp);
return t.clients[id]
};
hub.set({ clients: { [id]: { } } }, false);
const connect = (hub, url, reconnect) => {
const socket = new w3cwebsocket(url);
// t, val, stamp, useragent, id
const client = hub.client || createClient(hub, {}, false);
const client = hub.clients[id];

@@ -219,7 +208,7 @@ hub.set({ client }, false);

const close = () => {
const stamp = bs.create();
const stamp = bs.create('disconnect', hub.id);
hub.socket = false;
hub.set({ connected: false }, stamp);
bs.close();
if (!socket.blockReconnect && hub._url_) {
if (!socket.blockReconnect && hub.url) {
reconnect = Math.min((reconnect * 1.5), 2000);

@@ -232,12 +221,12 @@ hub.reconnect = setTimeout(connect, reconnect, hub, url, reconnect);

if (typeof window === 'undefined') {
socket.hackyOnClose = close;
}
socket.onerror = () => {
if (typeof window === 'undefined') {
close();
} else {
socket.close();
}
};
socket.onerror = typeof window === 'undefined'
? close
: () => socket.close();
socket.onopen = () => {
const stamp = bs.create();
const stamp = bs.create('connected', hub.id);
hub.socket = socket;

@@ -249,13 +238,7 @@ meta(hub);

socket.onmessage = (data) => {
data = data.data;
// console.warn('INCOMING\n', JSON.parse(data))
if (!hub.receiveOnly) {
hub.receiveOnly = true;
hub.set(JSON.parse(data), false);
hub.receiveOnly = null;
} else {
hub.set(JSON.parse(data), false);
}
bs.close();
socket.onmessage = ({ data }) => {
const stamp = bs.create('upstream');
// console.log(JSON.stringify(JSON.parse(data), false, 2))
hub.set(JSON.parse(data), stamp);
bs.close(stamp);
};

@@ -265,3 +248,4 @@ };

const removeUrl = hub => {
hub.url = hub._url_ = hub.urlIndex = null;
hub.url = null;
hub.urlIndex = null;
hub.emitters.set({ data: { url$: null } }, false);

@@ -277,14 +261,7 @@ };

hub.socket.blockReconnect = true;
console.log('GO GO GOREMOVE', hub.socket._readyState);
if (hub.connected.compute() === false || !hub.socket._readyState) {
console.log('hacky!');
hub.socket.hackyOnClose();
} else {
hub.socket.close();
}
hub.socket.close();
}
// hub.socket = false
};
const url = (hub, val, key, stamp) => {
const url = (hub, val, stamp) => {
hub.on((val, stamp, t) => {

@@ -297,34 +274,15 @@ if (val === null && !t._c && t === hub) {

}, 'url$');
if (!val) val = null;
if ((!hub.url && val) || (hub.url.compute() !== val)) {
if (val !== hub.url) {
removeSocket(hub);
hub.set({ connected: false }, stamp);
if (!val) {
hub.set({ connected: false }, stamp);
hub._url_ = null;
if (hub.url) hub.url.set(null, stamp);
removeUrl(hub);
} else {
if (!hub.url) {
create({
on: {
data: {
url: (val, stamp, struct$$1) => {
val = struct$$1.compute();
if (val) {
hub.set({ connected: false }, stamp);
let i = -1;
if (hub.key) i++;
hub.parent(() => { i++; });
hub.urlIndex = i; // use this for checks
hub._url_ = val;
connect(hub, val, 50);
} else {
hub._url_ = null;
}
}
}
}
}, stamp, struct, hub, key);
}
hub.url.set(val, stamp);
let i = -1;
if (hub.key) i++;
hub.parent(() => { i++; });
hub.urlIndex = i;
hub.url = val;
connect(hub, val, 50);
}

@@ -334,69 +292,27 @@ }

const removeClients = (hub, stamp) => {
const clients = hub.clients;
if (clients && clients.keys().length > 1) {
clients.forEach((client, key) => {
if (
client.val !== null &&
client !== hub.client
) {
client.set(null, stamp);
delete clients[key];
}
});
}
};
// very context as well
// const clients => (val, stamp) {
// const hub = this.cParent()
// if (this.compute() === false && hub.upstream) {
// // put this in clients (the file)
// const clients = hub.clients
// if (clients && clients.keys().length > 1) {
// clients.each((client) => {
// if (
// client.val !== null &&
// !client.socket &&
// client.key != hub.id // eslint-disable-line
// ) {
// client.remove(stamp)
// }
// })
// }
// }
// }
const connected = {
type: 'struct',
on: {
data: {
removeClients: (val, stamp, t) => {
if (t.compute() === false) {
// all instances! -- fix this
removeClients(t._p, stamp);
}
}
}
}
};
const connected = { type: 'struct' };
const contextStruct = struct.create({
props: {
default: {
on: {
data: {
updateParent: (val, stamp, t) => {
console.log('👻 GO UPDATE PARENT!!! 👻');
t.parent().emit('data', val, stamp);
}
}
}
}
}
});
const contextIsNotEqual = (val, context) => {
if (val && typeof val === 'object') {
for (let field in val) {
if (!context[field] || val[field] !== context[field].compute()) {
console.log('😜', field);
return true
}
}
} else {
console.log('😜 ?????');
return val !== context.compute()
}
};
const context = (hub, val, key, stamp) => {
if (!hub.context || contextIsNotEqual(val, hub.context)) {
console.log('⚽️ fire fire fire FLAME context ⚽️', val, stamp);
if (!hub.context) {
create(val, stamp, contextStruct, hub, key);
} else {
removeClients(hub, stamp);
hub.context.set(val, stamp);
}
const context = (hub, val) => {
if (val !== hub.clientContext) {
hub.clientContext = val;
if (hub.connected && hub.connected.compute() === true) meta(hub);

@@ -422,13 +338,11 @@ }

if (!raw) subs = parse(subs);
if (!this.receiveOnly) {
const parsed = parse$1(this, subs);
if (parsed) {
const key = hash(JSON.stringify(parsed));
if (!this.upstreamSubscriptions) {
this.upstreamSubscriptions = { [key]: parsed };
if (this.url) meta(this);
} else if (!this.upstreamSubscriptions[key]) {
this.upstreamSubscriptions[key] = parsed;
if (this.url) meta(this);
}
const parsed = parse$2(this, subs);
if (parsed) {
const key = hash(JSON.stringify(parsed));
if (!this.upstreamSubscriptions) {
this.upstreamSubscriptions = { [key]: parsed };
if (this.url) meta(this);
} else if (!this.upstreamSubscriptions[key]) {
this.upstreamSubscriptions[key] = parsed;
if (this.url) meta(this);
}

@@ -485,3 +399,3 @@ }

const parse$2 = (obj, state, key) => {
const parse$3 = (obj, state, key) => {
const result = {};

@@ -507,7 +421,7 @@ for (let i in obj) {

let msg;
// if (!pass) {
msg = `cannot parse function ${key}.exec\n${val}`;
// } else {
// msg = `cannot run function ${key}.exec\n${val}`
// }
if (!pass) {
msg = `cannot parse function ${key}.exec\n${val}`;
} else {
msg = `cannot run function ${key}.exec\n${val}`;
}
state.emit('error', new Error(msg));

@@ -520,3 +434,3 @@ obj[i] = dummy;

} else {
result[i] = parse$2(obj[i], state, i);
result[i] = parse$3(obj[i], state, i);
}

@@ -527,17 +441,2 @@ }

const cache = (client, struct$$1, stamp) => {
if (!client.cache) client.cache = {};
client.cache[puid(struct$$1)] = stamp;
};
const isCached = (client, struct$$1, stamp) => client.cache &&
client.cache[puid(struct$$1)] === stamp;
const isEmpty$1 = obj => {
for (let i in obj) { //eslint-disable-line
return false
}
return true
};
const progress = (client) => {

@@ -548,7 +447,11 @@ if (!client.inProgress) {

if (client.val !== null) {
if (!isEmpty$1(client.inProgress)) {
var isEmpty = true;
for (let i in client.inProgress) { //eslint-disable-line
isEmpty = false;
break
}
if (!isEmpty) {
// bit hacky...
if (client.inProgress.types) {
for (let i in client.inProgress) {
// order is still important since settign types after the facts is still broken
// this will be a big update
if (i === 'types') {

@@ -572,96 +475,134 @@ break

const send$1 = (hub, client, struct$$1, type, subs, tree) => {
if (struct$$1.isHub && client.val !== null) {
let isRemoved;
if (type === 'remove') {
if (!struct$$1._p[struct$$1.key]) isRemoved = true;
} else if (type === 'update' && tree.$t !== struct$$1) {
if (tree.$t && tree.$t._p && !tree.$t._p[tree.$t.key]) {
let previous = tree.$t;
let prop = previous;
while (previous) {
if (previous._p && previous._p[previous.key]) {
// think of something fast for level...
serialize$2(client, progress(client), subs, prop, get(hub, 'serverIndex'), true);
}
prop = previous;
previous = previous._p;
}
const send$1 = (hub, client, t, type, subs, tree) => {
var val;
if (type === 'remove') {
if (!t._p[t.key]) {
val = null;
if (bs.src(t._p.tStamp) === client.key) {
return
}
}
serialize$2(client, progress(client), subs, struct$$1, get(hub, 'serverIndex'), isRemoved);
} else if (type === 'update' && tree.$t !== t) {
if (tree.$t && tree.$t._p && !tree.$t._p[tree.$t.key]) {
serialize$2(hub.id, client, progress(client), subs, tree.$t, null, get(hub, 'serverIndex'), tree);
}
}
if (t.val !== void 0 || val === null || subs.val === true) {
// opt this line (the get) just use a define or something
serialize$2(hub.id, client, progress(client), subs, t, val, get(hub, 'serverIndex'), tree);
}
};
const serialize$2 = (client, t, subs, struct$$1, level, isRemoved) => {
const stamp = get(struct$$1, 'stamp') || 1; // remove the need for this default (feels wrong)
const val = isRemoved ? null : getVal(struct$$1);
const cache = (client, struct$$1, stamp, level, val) => {
if (!client.cache) client.cache = {};
client.cache[struct$$1.uid()] = stamp[0];
};
if (val !== void 0 && stamp && !isCached(client, struct$$1, stamp)) {
// val === null -- double chck if this is nessecary
const path = struct$$1.path();
const len = path.length;
let s = t;
for (let i = level; i < len; i++) {
let tt = s[path[i]];
if (!tt) {
s = s[path[i]] = {};
const isCached = (client, struct$$1, stamp) => {
return client.cache && client.cache[struct$$1.uid()] === stamp[0]
};
const setStamp = (s, stamp, src, struct$$1, id, client, level) => {
cache(client, struct$$1, stamp, level);
s.stamp = !src
? bs.create(bs.type(stamp), id, bs.val(stamp))
: stamp;
};
// clean the cached up a bit
const serialize$2 = (id, client, t, subs, struct$$1, val, level) => {
const stamp = get(struct$$1, 'stamp');
var cached, isType;
if (stamp && (val === null || !(cached = isCached(client, struct$$1, stamp))) || subs.val === true) {
const src = bs.src(stamp);
if (
src !== client.key && bs.src(t.tStamp) !== client.key ||
(isType = struct$$1.key === 'type')
) {
if (
client.resolve &&
client.resolve[src] &&
bs.val(stamp) >= client.resolve[src]
) {
if (val !== null) {
if (struct$$1.val !== void 0) cache(client, struct$$1, stamp, level);
if (subs.val === true) {
const keys = getKeys(struct$$1);
if (keys) deepSerialize(keys, id, client, t, subs, struct$$1, val, level);
}
}
} else {
s = tt;
if (s.val === null) return
}
}
if (subs.type) {
// simple but will make it better need more checks
var p = struct$$1;
while (p) {
if (p.key === 'types') {
return
}
p = p._p;
}
}
if (isRemoved) {
cache(client, struct$$1, stamp);
s.stamp = stamp;
s.val = val;
} else {
if (subs.type) {
const type = get(struct$$1, 'type'); // make getType (fast)
if (getVal(type) !== 'hub') {
serialize$2(client, t, subs.type, type, level);
if (isType) { // means its blocked otherwise (could be a set form own client)
typeSerialize(id, client, t, subs, struct$$1, val, level);
} else if (!cached && (struct$$1.val !== void 0 || val === null)) {
const path = struct$$1.path();
const len = path.length;
var s = t;
for (let i = level; i < len; i++) {
let tt = s[path[i]];
if (!tt) {
s = s[path[i]] = {};
} else {
s = tt;
if (s.val === null) return
}
}
if (val === null) {
setStamp(s, stamp, src, struct$$1, id, client, level, val);
s.val = null;
} else {
if (struct$$1.key === 'type') {
typeSerialize(id, client, t, subs, struct$$1, val, level);
}
setStamp(s, stamp, src, struct$$1, id, client, level);
if (struct$$1.val && struct$$1.val.inherits) {
s.val = struct$$1.val.path();
s.val.unshift('@', 'root');
serialize$2(id, client, t, subs, struct$$1.val, val, level);
} else if (struct$$1.val !== void 0) {
s.val = struct$$1.val;
}
}
}
}
cache(client, struct$$1, stamp);
s.stamp = stamp;
if (struct$$1.key === 'type') {
if (val === 'hub') return
serialize$2(client, t, subs, getType(struct$$1.parent(2), val), level);
// allways need a stamp!
if (subs.val === true) {
const keys = getKeys(struct$$1);
if (keys) deepSerialize(keys, id, client, t, subs, struct$$1, val, level);
}
}
if (typeof val === 'object' && val.inherits) {
s.val = val.path();
s.val.unshift('@', 'root');
serialize$2(client, t, subs, val, level);
} else if (val !== void 0) {
s.val = val;
}
}
} else if (val && typeof val === 'object' && val.inherits) {
// can send a bit too much data when val: true and overlapping keys
serialize$2(client, t, subs, val, level);
}
};
if (subs.val === true && !isRemoved) {
deepSerialize(getKeys(struct$$1), client, t, subs, struct$$1, level);
}
const typeSerialize = (id, client, t, subs, struct$$1, val, level) => {
serialize$2(id, client, t, subs, getType(struct$$1.parent(2), struct$$1.compute()), val, level);
};
const deepSerialize = (keys, client, t, subs, struct$$1, level) => {
if (struct$$1.get('type') && struct$$1.get('type').compute() !== 'hub') {
serialize$2(client, t, subs, struct$$1.get('type'), level);
}
const deepSerialize = (keys, id, client, t, subs, struct$$1, val, level) => {
if (keys) {
for (let i = 0, len = keys.length; i < len; i++) {
let prop = get(struct$$1, keys[i]);
if (prop && prop.isHub) serialize$2(client, t, subs, prop, level);
if (prop && prop.isHub) serialize$2(id, client, t, subs, prop, val, level);
}
}
// feels really shacky /w context :/ needs tests
if (struct$$1._removed) {
for (let i = 0, len = struct$$1._removed.length; i < len; i++) {
let prop = struct$$1._removed[i];
serialize$2(client, t, subs, prop, level, true);
if (prop && prop.isHub) serialize$2(id, client, t, subs, prop, null, level);
}

@@ -671,28 +612,2 @@ }

const removeSubscriptions = (t, id) => {
if (t.subscriptions) {
let i = t.subscriptions.length;
while (i--) { // clean this up with unsubscribe in struct
if (t.subscriptions[i]._uid_ == id) { //eslint-disable-line
t.subscriptions.splice(i, 1);
}
}
}
};
const removeClient = (client) => {
const id = client.key;
client.val = null;
if (client.socket) {
client.socket.client = null;
client.socket = null;
}
const t = client.parent(2);
removeSubscriptions(t, id);
client.set(null);
// if (client.context && t.clients.keys().length === (t.url ? 1 : 0)) {
// t.set(null, stamp)
// }
};
var incoming = (hub, socket, data) => {

@@ -702,74 +617,45 @@ const payload = data[0];

var client = socket.client;
var t;
if (meta) {
let t;
if (client) {
t = hub;
if ('context' in meta && client.context != meta.context) { // eslint-disable-line
removeClient(client);
create$1(hub, socket, meta, payload);
if (client.context != meta.context) { // eslint-disable-line
client.set(null);
t = create$2(hub, socket, meta);
client = socket.client;
} else if (meta.subscriptions) {
if (payload) setPayload(t, payload, client);
incomingSubscriptions(t, client, meta, client.key);
incomingSubscriptions(t, client, meta, client.id);
bs.close();
}
} else {
create$1(hub, socket, meta, payload);
t = create$2(hub, socket, meta);
client = socket.client;
}
} else {
setPayload(client.parent(2), payload, client);
bs.close();
t = client.parent(2);
}
};
const addToCache = (client, hub, payload) => {
if (typeof payload === 'object' && payload) {
for (let key in payload) {
if (key !== 'val' && key !== 'stamp') {
let struct$$1 = hub[key];
if (struct$$1 && struct$$1.isHub) {
addToCache(client, hub[key], payload[key]);
}
}
if (payload) {
if (meta && meta.resolve) {
client.resolve = meta.resolve;
t.set(payload, false);
bs.on(() => { client.resolve = false; });
} else {
t.set(payload, false);
}
if (payload.val !== void 0 && payload.stamp) {
cache(client, hub, payload.stamp);
}
bs.close();
}
};
const setPayload = (hub, payload, client) => {
hub.set(payload, false);
addToCache(client, hub, payload);
};
const set$1 = (meta, socket, t, payload) => {
const stamp = bs.create();
const create$2 = (hub, socket, meta) => {
const stamp = bs.create('connect');
const id = meta.id;
const context = meta.context;
// const ip = socket._socket.remoteAddress
const client = socket.client = createClient(
t, { socket, context }, stamp, socket.useragent, id
);
if (payload) setPayload(t, payload, client);
const t = meta.context ? hub.getContext(meta.context) : hub;
t.set({ clients: { [id]: { socket, context: meta.context } } }, stamp);
const client = socket.client = t.clients[id];
if (meta.subscriptions) incomingSubscriptions(t, client, meta, id);
bs.close();
bs.close(stamp);
return t
};
const create$1 = (hub, socket, meta, payload) => {
const t = meta.context ? hub.getContext(meta.context, socket) : hub;
if (!t.inherits && t.then) {
t.then((t) => {
if (socket.external !== null) {
console.log('client connected and found informations');
set$1(meta, socket, t, payload);
} else {
console.log('client discconected when logging in');
}
}).catch(err => hub.emit('error', err));
} else {
set$1(meta, socket, t, payload);
}
};
const incomingSubscriptions = (hub, client, meta, id) => {

@@ -781,6 +667,6 @@ const update = (t, type, subs, tree) => send$1(hub, client, t, type, subs, tree);

if (!client.upstreamSubscriptions[uid]) {
let subs = parse$2(meta.subscriptions[key], hub);
let subs = parse$3(meta.subscriptions[key], hub);
client.upstreamSubscriptions[uid] = subs;
subscribe(hub, subs, update);
hub.subscriptions[hub.subscriptions.length - 1]._uid_ = id;
hub.subscriptions[hub.subscriptions.length - 1].id = id;
}

@@ -790,35 +676,9 @@ }

var removedInProgress;
const on$1 = {
data: {
remove$: (val, stamp, struct$$1) => {
// just do a diff with the payload rly the best way for now...
if (val === null && (!struct$$1._c || struct$$1._cLevel === 1)) {
let p = struct$$1;
let hub;
while (p) {
if (p.port && !p._c) { hub = p; }
p = p.parent();
}
if (hub) {
// probably not working correctly with context
const target = struct$$1.parent();
if (target) {
if (!target._removed) {
target._removed = [];
if (!removedInProgress) {
removedInProgress = [];
bs.on(() => {
let i = removedInProgress.length;
while (i--) {
delete removedInProgress[i]._removed;
}
});
}
removedInProgress.push(target);
}
target._removed.push(struct$$1);
}
}
}
const Server = WebSocket.Server;
const removeSubscriptions = (t, id) => {
if (t.subscriptions) {
let i = t.subscriptions.length;
while (i--) { // clean this up with unsubscribe in struct
if (t.subscriptions[i].id === id) t.subscriptions.splice(i, 1);
}

@@ -828,11 +688,5 @@ }

const Server = uws.Server;
const createServer = (hub, port) => {
const create$1 = (hub, port) => {
const server = new Server({ port });
console.log(`💫 hub listening on ${port} 💫`);
server.on('connection', socket => {
socket.useragent = socket.upgradeReq && socket.upgradeReq.headers['user-agent'];
// need to remove when done -- its the best thing todo (mem!!!)
server.on('connection', (socket) => {
socket.on('message', (data) => {

@@ -844,3 +698,14 @@ data = JSON.parse(data);

const close = () => {
if (socket.client) removeClient(socket.client);
const client = socket.client;
if (client) {
const stamp = bs.create('disconnect');
const id = client.key;
const t = client.parent(2);
removeSubscriptions(t, id);
client.set(null, stamp);
if (client.context && t.clients.keys().length === (t.url ? 1 : 0)) {
t.set(null, stamp);
}
bs.close();
}
};

@@ -855,3 +720,3 @@

const removeServer = hub => {
const server = hub._server_;
const server = hub.server;
const instances = hub.instances;

@@ -862,6 +727,5 @@ closeConnections(hub);

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

@@ -871,3 +735,3 @@

const clients = hub.clients;
const id = hub._uid_; // to exclude the client (not nessecary)
const id = hub.id; // to exclude the client (not nessecary)
if (clients) {

@@ -890,4 +754,3 @@ clients.forEach(client => {

const port = (hub, val, key, stamp) => {
// use remove
const port = (hub, val) => {
hub.on((val, stamp, t) => {

@@ -900,29 +763,15 @@ if (val === null && !t._c && t === hub) {

if (!val) val = null;
if ((!hub.port && val) || (hub.port.compute() !== val)) {
if (hub._server_) {
if (val !== hub.port) {
if (hub.server) {
removeServer(hub);
}
if (!val) {
if (hub.port) hub.port.set(null, stamp);
removePort(hub);
} else {
if (!hub.port) {
create({
on: {
data: {
port: (val, stamp, struct$$1) => {
val = struct$$1.compute();
if (val) {
let i = -1;
if (hub.key) i++;
hub.parent(() => { i++; });
hub.serverIndex = i;
hub._server_ = createServer(hub, val);
}
}
}
}
}, stamp, struct, hub, key);
}
hub.port.set(val, stamp);
hub.port = val;
let i = -1;
if (hub.key) i++;
hub.parent(() => { i++; });
hub.serverIndex = i;
hub.server = create$1(hub, val);
}

@@ -933,3 +782,3 @@ }

const props$1 = {
_server_: true,
server: true,
serverIndex: true,

@@ -939,5 +788,40 @@ port

var removedInProgress;
const on$1 = {
data: {
remove$: (val, stamp, struct$$1) => {
if (val === null && (!struct$$1._c || struct$$1._cLevel === 1)) {
let p = struct$$1;
let hub;
while (p) {
if (p.port && !p._c) { hub = p; }
p = p.parent();
}
if (hub) {
const target = struct$$1.parent();
if (target) {
if (!target._removed) {
target._removed = [];
if (!removedInProgress) {
removedInProgress = [];
bs.on(() => {
let i = removedInProgress.length;
while (i--) {
delete removedInProgress[i]._removed;
}
});
}
removedInProgress.push(target);
}
struct$$1._p._removed.push(struct$$1);
}
}
}
}
}
};
var server = Object.freeze({

@@ -948,24 +832,12 @@ props: props$1,

var context$1 = {
props: {
contextKey: true,
getContext: (t, fn) => {
t.set({
define: {
getContext (key, socket) {
return fn(key, (key) => createContext(this, key), this, socket)
}
}
});
const props$2 = { contextKey: true };
const define$1 = {
getContext (val) {
var result = find(this, val);
if (!result) {
result = this.create({ contextKey: val }, false);
}
},
getContext: (key, context) => context()
};
const createContext = (hub, val) => {
var result = find(hub, val);
if (!result) {
result = hub.create({ contextKey: val }, false);
return result
}
return result
};

@@ -978,3 +850,6 @@

while (i--) {
if (instances[i].contextKey === val) return instances[i]
if (instances[i].contextKey === val) {
// console.log('found context --->', val, instances[i].clients.keys())
return instances[i]
}
}

@@ -984,2 +859,8 @@ }

var context$1 = Object.freeze({
props: props$2,
define: define$1
});
const types = struct.props.types;

@@ -993,7 +874,6 @@

default: 'self',
_uid_: (t, val) => { t.set({ define: { _uid_: val } }); },
// why nto call this client id -- thats what it is
id: (t, val) => { t.set({ define: { id: val } }); },
clients: (t, val, key, stamp) => {
if (!t.clients) {
t.clients = create(val, stamp, clients, t, key);
t.clients = c(clients, val, stamp, t, key);
} else {

@@ -1006,12 +886,13 @@ set(t.clients, val, stamp);

client: true
}
},
id
});
hub.props.types.struct = hub.create({
hub.props.types.struct = c(hub, {
props: { default: types.struct.props.default.bind() }
}, false);
});
hub.props.types.struct.props.default.struct = hub.props.type.struct = hub;
hub.set({ types: { hub: 'self' }, inject: [ server, client, context$1 ] }, false);
hub.set({ types: { hub: 'self' }, inject: [ server, context$1, client ] }, false);

@@ -1030,13 +911,21 @@ hub.types._ks = void 0;

}
}, false)
})
}
}, false);
});
if (typeof __filename !== 'undefined') console.log('hub.js:', __filename);
// import bs from 'brisky-stamp'
const fn = (val, stamp) => hub.create(val, stamp);
var index = (val, stamp) => {
if (stamp === void 0) {
const r = hub.create(val, bs.create());
bs.close();
return r
} else {
return hub.create(val, stamp)
}
};
// add uids to stamps else it sucks -- dont compromise for tests think of that as an after thought
export default fn;
export default index;
//# sourceMappingURL=index.es.js.map
const $2563227135 = require('brisky-struct/dist/index.js')
const $3040487635 = require('brisky-stamp/dist/index.js')
// FILE EXTERNAL: /Users/jimdebeer/Desktop/brisky/brisky-struct/dist/index.js
var $3410192572 = require('brisky-struct');
// FILE EXTERNAL: /Users/jimdebeer/Desktop/brisky/hub.js/node_modules/brisky-stamp/dist/index.js
var $3965338702 = require('brisky-stamp');
// FILE: /Users/jimdebeer/Desktop/brisky/hub.js/src/client/send.js
const $4125568599_next = typeof window === 'undefined'
const $538340170_next = typeof window === 'undefined'
? process.nextTick
: global.requestAnimationFrame
const $4125568599_serialize = (hub, t, struct, val, level) => {
const $538340170_serialize = (hub, t, struct, val, level) => {
if (!struct.isHub || struct.key === 'clients' || (struct._p && struct._p.key === 'clients')) {

@@ -46,3 +49,3 @@ return

// if allrdy serialized stop it!
$4125568599_serialize(hub, t, struct.val, val, level)
$538340170_serialize(hub, t, struct.val, val, level)
// }

@@ -55,5 +58,5 @@ } else if (struct.val !== void 0) {

const $4125568599_meta = hub => {
const $538340170_meta = hub => {
if (!hub.receiveOnly) {
const store = $4125568599_inProgress(hub, $3040487635.inProgress ? $3040487635.on : $4125568599_next)
const store = $538340170_inProgress(hub, $3965338702.inProgress ? $3965338702.on : $538340170_next)
if (!store[1]) store[1] = {}

@@ -69,6 +72,24 @@ if (hub.context) {

store[1].subscriptions = hub.upstreamSubscriptions
} else if (hub.upstreamSubscriptions) {
let override
for (let key in hub.upstreamSubscriptions) {
if (hub.upstreamSubscriptions[key].__force__) {
if (!override) override = []
override.push(key)
}
}
if (override) {
const store = $538340170_inProgress(hub, $3965338702.inProgress ? $3965338702.on : $538340170_next)
if (!store[1]) store[1] = {}
const obj = {}
let i = override.length
while (i--) {
obj[override[i]] = hub.upstreamSubscriptions[override[i]]
}
store[1].subscriptions = obj
}
}
}
const $4125568599_send = (val, stamp, struct) => {
const $538340170_send = (val, stamp, struct) => {
// -1 means upsteam (floats for extra speed)

@@ -82,17 +103,19 @@ let hub

if (hub && !hub.receiveOnly) {
if (struct === hub) {
if (val === null) {
return
if (hub) {
if (!hub.receiveOnly) {
if (struct === hub) {
if (val === null) {
return
}
} else if (struct._p.key === 'clients') {
if (struct.key !== hub.client.key) {
return
}
}
} else if (struct._p.key === 'clients') {
if (struct.key !== hub.client.key) {
return
}
$538340170_serialize(hub, $538340170_inProgress(hub, $3965338702.on), struct, val, hub.urlIndex)
}
$4125568599_serialize(hub, $4125568599_inProgress(hub, $3040487635.on), struct, val, hub.urlIndex)
}
}
const $4125568599_inProgress = (hub, tick) => {
const $538340170_inProgress = (hub, tick) => {
if (!hub.inProgress) {

@@ -102,5 +125,5 @@ hub.inProgress = []

if (hub.connected.compute() === true) {
$4125568599_out(hub)
$538340170_out(hub)
} else {
hub.connected.once(true, () => $4125568599_out(hub))
hub.connected.once(true, () => $538340170_out(hub))
}

@@ -112,3 +135,3 @@ })

const $4125568599_out = t => {
const $538340170_out = t => {
t.socket.send(JSON.stringify(t.inProgress))

@@ -118,17 +141,20 @@ t.inProgress = false

const $4125568599_export_meta = $4125568599_meta
const $4125568599_export_send = $4125568599_send
const $4125568599_$ALL$ = {
meta: $4125568599_export_meta,
send: $4125568599_export_send
}
const $4020852141 = require('websocket/index.js')
// import WebSocket from 'uws'
// export default WebSocket
var $538340170_$ALL$ = {
meta: $538340170_meta,
send: $538340170_send
};
// FILE EXTERNAL: /Users/jimdebeer/Desktop/brisky/hub.js/node_modules/uws/uws.js
var $963985755 = require('uws');
// FILE: /Users/jimdebeer/Desktop/brisky/hub.js/src/client/websocket/index.js
const $2878564687 = $4020852141.w3cwebsocket
var $58967378 = $963985755
const $2711378567_isEmpty = t => {
// need to get this fixed on now!
// import { w3cwebsocket } from 'websocket'
// export default w3cwebsocket
;
// FILE: /Users/jimdebeer/Desktop/brisky/hub.js/src/subscription/serialize.js
const $301620890_isEmpty = t => {
for (let i in t) { return false }

@@ -138,30 +164,15 @@ return true

// function merge (a, b) {
// for (let i in b) {
// if ((!a[i] || typeof a[i] !== 'object')) {
// a[i] = b[i]
// } else {
// merge(a[i], b[i])
// }
// }
// }
const $2711378567_parse = (struct, obj, key, root) => {
const $301620890_parse = (struct, obj, key, root) => {
const result = {}
if (!root) { root = result }
// need to be done before the rest of subs to sync correctly
if (obj.type) result.type = $2711378567_parse(struct, obj.type, 'type')
if (obj.type) result.type = $301620890_parse(struct, obj.type, 'type')
for (let i in obj) {
if (i !== '_' && i !== 'type') {
// @todo more resolve for parent and client
// need more just use client (since milti hub)
if (i === 'client') { // && (!key || key === 'root' || key === 'parent')
// console.log('CLIENT NEED TO HANDLE MORE SPECIAL THEN JUST ROOT')
// let id = state._uid_
// if (!root.clients) { root.clients = {} }
// if (!root.clients[id]) { root.clients[id] = {} }
// merge(root.clients[id], parse(obj.client, i, root, state))
} else if (typeof obj[i] === 'function') {
if (typeof obj[i] === 'function') {
let val = obj[i].toString()
if (!/^(function|\()/.test(val)) {
// this can all be done on the hub itself of course
// hash will also be used for sec purposes
// this will just be send up and done on the hub -- not here!
if (/^.+=>/.test(val)) {

@@ -181,20 +192,5 @@ if (!/^(\(){0, 1}.+(\)){0, 1} +=>/.test(val)) {

} else if (typeof obj[i] !== 'object') {
// sync later!
// if (obj._ && obj._.sync) {
// if (obj._.sync !== true) { result[i] = obj._.sync }
// } else {
result[i] = obj[i]
// }
} else {
// empty objects are very uninteresetting maybe just skip them
let parsed = $2711378567_parse(struct, obj[i], i, root)
// if (i === 'root' || i === 'parent') {
// if (isEmpty(parsed)) {
// parsed = void 0
// }
// }
// does disable the weird bla: {} construct
let parsed = $301620890_parse(struct, obj[i], i, root)
if (parsed !== void 0) { result[i] = parsed }

@@ -205,23 +201,28 @@ }

// if result is empty ignore -- may not be a good idea
return $2711378567_isEmpty(result) ? void 0 : result
return $301620890_isEmpty(result) ? void 0 : result
}
// can be one less fn...
const $2711378567 = $2711378567_parse
var $301620890 = $301620890_parse
;
// FILE EXTERNAL: /Users/jimdebeer/Desktop/brisky/hub.js/node_modules/string-hash/index.js
var $488579407 = require('string-hash');
// FILE EXTERNAL: /Users/jimdebeer/Desktop/brisky/ua/index.js
var $309230799 = require('vigour-ua');
// FILE: /Users/jimdebeer/Desktop/brisky/hub.js/src/client/uid/index.js
const $257117234 = require('string-hash/index.js')
const $1190737809 = require('vigour-ua/index.js')
const $1397647999_uniq = process.pid
var $1397647999 = () => $488579407(`b-${Date.now()}-${(Math.random() * 10000) | 0}-${$1397647999_uniq}`)
;
// FILE: /Users/jimdebeer/Desktop/brisky/hub.js/src/client/create.js
const $1123050690_uniq = process.pid
const $1123050690 = () => $257117234(`b-${Date.now()}-${(Math.random() * 10000) | 0}-${$1123050690_uniq}`)
const $3376394415 = (t, val, stamp, useragent, id) => {
if (!id) id = t._uid_ || $1123050690()
$1190737809(useragent, val)
var $2627226290 = (t, val, stamp, useragent, id) => {
if (!id) id = t._uid_ || $1397647999()
$309230799(useragent, val)
t.set({ clients: { [id]: val } }, stamp)
return t.clients[id]
}
;
// FILE: /Users/jimdebeer/Desktop/brisky/hub.js/src/client/index.js

@@ -235,8 +236,6 @@

const $3098744616_connect = (hub, url, reconnect) => {
const socket = new $58967378(url)
const client = hub.client || $2627226290(hub, {}, false)
const $48594293_connect = (hub, url, reconnect) => {
const socket = new $2878564687(url)
// t, val, stamp, useragent, id
const client = hub.client || $3376394415(hub, {}, false)
hub.set({ client }, false)

@@ -247,9 +246,9 @@

const close = () => {
const stamp = $3040487635.create()
const stamp = $3965338702.create()
hub.socket = false
hub.set({ connected: false }, stamp)
$3040487635.close()
$3965338702.close()
if (!socket.blockReconnect && hub._url_) {
reconnect = Math.min((reconnect * 1.5), 2000)
hub.reconnect = setTimeout($48594293_connect, reconnect, hub, url, reconnect)
hub.reconnect = setTimeout($3098744616_connect, reconnect, hub, url, reconnect)
}

@@ -260,6 +259,2 @@ }

if (typeof window === 'undefined') {
socket.hackyOnClose = close
}
socket.onerror = typeof window === 'undefined'

@@ -270,12 +265,15 @@ ? close

socket.onopen = () => {
const stamp = $3040487635.create()
const stamp = $3965338702.create()
hub.socket = socket
$4125568599_export_meta(hub)
if (hub.emitters && hub.emitters.incoming) {
$3098744616_enableIncomingListener(socket, hub)
}
$538340170_meta(hub)
hub.set({ connected: true }, stamp)
$3040487635.close()
$3965338702.close()
}
// use outside function non anon since its slowe apprantly
socket.onmessage = (data) => {
data = data.data
// console.warn('INCOMING\n', JSON.parse(data))
if (!hub.receiveOnly) {

@@ -288,7 +286,7 @@ hub.receiveOnly = true

}
$3040487635.close()
$3965338702.close()
}
}
const $48594293_removeUrl = hub => {
const $3098744616_removeUrl = hub => {
hub.url = hub._url_ = hub.urlIndex = null

@@ -298,3 +296,3 @@ hub.emitters.set({ data: { url$: null } }, false)

const $48594293_removeSocket = hub => {
const $3098744616_removeSocket = hub => {
if (hub.reconnect) {

@@ -306,19 +304,13 @@ clearTimeout(hub.reconnect)

hub.socket.blockReconnect = true
console.log('GO GO GOREMOVE', hub.socket._readyState)
if (hub.connected.compute() === false || !hub.socket._readyState) {
console.log('hacky!')
hub.socket.hackyOnClose()
} else {
hub.socket.close()
}
hub.socket.close()
}
// hub.socket = false
hub.socket = false
}
const $48594293_url = (hub, val, key, stamp) => {
const $3098744616_url = (hub, val, key, stamp) => {
hub.on((val, stamp, t) => {
if (val === null && !t._c && t === hub) {
hub.subscriptions = []
$48594293_removeUrl(hub)
$48594293_removeSocket(hub)
$3098744616_removeUrl(hub)
$3098744616_removeSocket(hub)
}

@@ -329,3 +321,3 @@ }, 'url$')

if ((!hub.url && val) || (hub.url.compute() !== val)) {
$48594293_removeSocket(hub)
$3098744616_removeSocket(hub)
if (!val) {

@@ -337,3 +329,3 @@ hub.set({ connected: false }, stamp)

if (!hub.url) {
$2563227135.create({
$3410192572.create({
on: {

@@ -350,3 +342,3 @@ data: {

hub._url_ = val
$48594293_connect(hub, val, 50)
$3098744616_connect(hub, val, 50)
} else {

@@ -358,3 +350,3 @@ hub._url_ = null

}
}, stamp, $2563227135.struct, hub, key)
}, stamp, $3410192572.struct, hub, key)
}

@@ -366,3 +358,3 @@ hub.url.set(val, stamp)

const $48594293_removeClients = (hub, stamp) => {
const $3098744616_removeClients = (hub, stamp) => {
const clients = hub.clients

@@ -382,3 +374,3 @@ if (clients && clients.keys().length > 1) {

const $48594293_connected = {
const $3098744616_connected = {
type: 'struct',

@@ -390,3 +382,3 @@ on: {

// all instances! -- fix this
$48594293_removeClients(t._p, stamp)
$3098744616_removeClients(t._p, stamp)
}

@@ -398,3 +390,3 @@ }

const $48594293_contextStruct = $2563227135.struct.create({
const $3098744616_contextStruct = $3410192572.struct.create({
props: {

@@ -414,3 +406,3 @@ default: {

const $48594293_contextIsNotEqual = (val, context) => {
const $3098744616_contextIsNotEqual = (val, context) => {
if (val && typeof val === 'object') {

@@ -424,3 +416,2 @@ for (let field in val) {

} else {
console.log('😜 ?????')
return val !== context.compute()

@@ -430,16 +421,16 @@ }

const $48594293_context = (hub, val, key, stamp) => {
if (!hub.context || $48594293_contextIsNotEqual(val, hub.context)) {
console.log('⚽️ fire fire fire FLAME context ⚽️', val, stamp)
const $3098744616_context = (hub, val, key, stamp) => {
if ((!hub.context && val) || (hub.context && $3098744616_contextIsNotEqual(val, hub.context))) {
// console.log('⚽️ fire fire fire FLAME context ⚽️', val, stamp)
if (!hub.context) {
$2563227135.create(val, stamp, $48594293_contextStruct, hub, key)
$3410192572.create(val, stamp, $3098744616_contextStruct, hub, key)
} else {
$48594293_removeClients(hub, stamp)
$3098744616_removeClients(hub, stamp)
hub.context.set(val, stamp)
}
if (hub.connected && hub.connected.compute() === true) $4125568599_export_meta(hub)
if (hub.connected && hub.connected.compute() === true) $538340170_meta(hub)
}
}
const $48594293_props = {
const $3098744616_props = {
reconnect: true,

@@ -450,90 +441,150 @@ socket: true,

receiveOnly: true,
url: $48594293_url,
context: $48594293_context,
connected: $48594293_connected
url: $3098744616_url,
context: $3098744616_context,
connected: $3098744616_connected
}
const $48594293_stub = () => {}
const $3098744616_stub = () => {}
const $48594293_define = {
subscribe (subs, cb, raw, tree) {
if (!raw) subs = $2563227135.parse(subs)
if (!this.receiveOnly) {
const parsed = $2711378567(this, subs)
const $3098744616_define = {
subscribe (subs, cb, raw, tree, forceUpstream) {
if (!raw) subs = $3410192572.parse(subs)
if (!this.receiveOnly || forceUpstream) {
const parsed = $301620890(this, subs)
if (parsed) {
const key = $257117234(JSON.stringify(parsed))
if (forceUpstream) {
parsed.__force__ = true
}
// why not keep it stringified? -- saves lots of speed
const key = $488579407(JSON.stringify(parsed))
if (!this.upstreamSubscriptions) {
this.upstreamSubscriptions = { [key]: parsed }
if (this.url) $4125568599_export_meta(this)
this.upstreamSubscriptions = {}
this.upstreamSubscriptions[key] = parsed
if (this.url) $538340170_meta(this)
} else if (!this.upstreamSubscriptions[key]) {
this.upstreamSubscriptions[key] = parsed
if (this.url) $4125568599_export_meta(this)
if (this.url) $538340170_meta(this)
}
}
}
return $2563227135.subscribe(this, subs, cb || $48594293_stub, tree)
return $3410192572.subscribe(this, subs, cb || $3098744616_stub, tree)
}
}
const $48594293_on = { data: { send: $4125568599_export_send } }
const $3098744616_enableIncomingListener = (socket, hub) => {
if (!socket.incomingOverride) {
socket.incomingOverride = true
const field = typeof window === 'undefined' ? 'internalOnMessage' : 'onmessage'
const msg = hub.socket[field]
socket[field] = (data) => {
hub.emit('incoming', data)
msg(data)
}
}
}
const $48594293_export_props = $48594293_props
const $48594293_export_on = $48594293_on
const $48594293_export_define = $48594293_define
const $3098744616_on = {
data: { send: $538340170_send },
props: {
incoming: (t, val, key, stamp) => {
const hub = t._p
if (hub.socket) $3098744616_enableIncomingListener(hub.socket, hub)
return $3410192572.emitterProperty(t, val, key, stamp)
}
}
}
const $48594293_$ALL$ = {
props: $48594293_export_props,
on: $48594293_export_on,
define: $48594293_export_define
var $3098744616_$ALL$ = {
props: $3098744616_props,
on: $3098744616_on,
define: $3098744616_define
};
// FILE: /Users/jimdebeer/Desktop/brisky/hub.js/src/context.js
var $2193415007 = {
props: {
contextKey: true,
getContext: (t, fn) => {
t.set({
define: {
getContext (key, socket) {
return fn(key, (key) => $2193415007_createContext(this, key), this, socket)
}
}
})
}
},
getContext: (key, context) => context()
}
const $911301798 = require('uws/uws.js')
const $3742651364_isFn = /^\$fn\|/
const $3742651364_dummy = () => false
// const client = (tree) => {
// while (tree) {
// if (tree._ && tree._.client) {
// return tree._.client
// }
// tree = tree._p
// }
// }
// const clientContext = fn => (state, subs, tree, key) => {
// if (state) {
// const $root = state.root
// const inContext = $root._client
// var prev
// if (inContext) {
// $root._client = client(tree)
// } else {
// prev = $root.client
// $root.client = client(tree)
// }
// const ret = fn(state, tree, subs, key)
// if (inContext) {
// $root._client = inContext
// } else {
// $root.client = prev
// }
// return ret
// } else {
// return fn(state, tree, subs, key)
// }
// }
const $2193415007_createContext = (hub, val) => {
var result = $2193415007_find(hub, val)
if (!result) {
result = hub.create({ contextKey: val }, false)
}
return result
}
const $3742651364_parse = (obj, state, key) => {
const $2193415007_find = (hub, val) => {
const instances = hub.instances
if (instances) {
let i = instances.length
while (i--) {
if (instances[i].contextKey === val) return instances[i]
}
}
}
;
// FILE: /Users/jimdebeer/Desktop/brisky/hub.js/src/subscription/parse.js
const $500722009_isFn = /^\$fn\|/
const $500722009_dummy = () => false
function $500722009_merge (a, b) {
for (let i in b) {
if ((!a[i] || typeof a[i] !== 'object')) {
a[i] = b[i]
} else {
$500722009_merge(a[i], b[i])
}
}
}
// this will all be done with an ast later!
const $500722009_replaceClient = /\.client[^a-z0-9]/g
// can also check for dangeorus stuff and maybe even allow some requires
// needs hashing algo
const $500722009_clientContext = (val, client) => {
const matches = val.match($500722009_replaceClient)
for (let i = 0, len = matches.length; i < len; i++) {
val = val.replace(matches[i].slice(0, -1), '.clients.' + client.key)
}
return val
}
const $500722009_parse = (obj, state, key, client, root) => {
const result = {}
if (!root) root = result
for (let i in obj) {
if ($3742651364_isFn.test(i)) {
let block
if (i === 'client' && (!key || key === 'root' || key === 'parent')) {
block = true
console.log('client subs parsing work in progress, missing parent and references')
let id = client.key // wrong need to get client
if (!root.clients) { root.clients = {} }
if (!root.clients[id]) { root.clients[id] = {} }
$500722009_merge(root.clients[id], $500722009_parse(obj.client, i, key, client, root))
} else if ($500722009_isFn.test(i)) {
let val = obj[i]
i = i.slice(4)
// need to fix bublé stuff in these fn creations -- prop need to add buble
// runtime in a hub
let pass
// need to fix bublé / babel stuff in these fn creations -- prop need to add buble
// runtime in a hub, and ast
// let pass
try {
if ($500722009_replaceClient.test(val)) { // eslint-disable-line
val = $500722009_clientContext(val, client)
}
obj[i] = new Function('return ' + val)() // eslint-disable-line
// if (/\.client|\[['"']client['"]\]/.test(val)) { // eslint-disable-line
// obj[i] = clientContext(obj[i])
// }
pass = true
// pass = true
// do dry run with your own key in a props object

@@ -551,9 +602,14 @@ // 2 options for this ofcourse

state.emit('error', new Error(msg))
obj[i] = $3742651364_dummy
obj[i] = $500722009_dummy
}
}
if (typeof obj[i] !== 'object') {
result[i] = obj[i]
} else {
result[i] = $3742651364_parse(obj[i], state, i)
// can go to client as well...
if (!block && i !== '__force__') {
if (i === 'clients' && result.clients) {
$500722009_merge(result[i], obj[i])
} else if (typeof obj[i] !== 'object') {
result[i] = obj[i]
} else {
result[i] = $500722009_parse(obj[i], state, i, client, root)
}
}

@@ -564,28 +620,29 @@ }

const $3742651364 = $3742651364_parse
var $500722009 = $500722009_parse
;
// FILE: /Users/jimdebeer/Desktop/brisky/hub.js/src/server/cache.js
const $3904796091_cache = (client, struct, stamp) => {
const $2991935526_cache = (client, struct, stamp) => {
if (!client.cache) client.cache = {}
client.cache[$2563227135.puid(struct)] = stamp
client.cache[$3410192572.puid(struct)] = stamp
}
const $3904796091_isCached = (client, struct, stamp) => client.cache &&
client.cache[$2563227135.puid(struct)] === stamp
const $2991935526_isCached = (client, struct, stamp) => client.cache &&
client.cache[$3410192572.puid(struct)] === stamp
// const isCached = () => false
const $3904796091_export_cache = $3904796091_cache
const $3904796091_export_isCached = $3904796091_isCached
const $3904796091_$ALL$ = {
cache: $3904796091_export_cache,
isCached: $3904796091_export_isCached
}
var $2991935526_$ALL$ = {
cache: $2991935526_cache,
isCached: $2991935526_isCached
};
// FILE: /Users/jimdebeer/Desktop/brisky/hub.js/src/server/send.js
const $1622386187_isEmpty = obj => {
const $1815910806_isEmpty = obj => {
for (let i in obj) { //eslint-disable-line

@@ -597,11 +654,23 @@ return false

const $1622386187_progress = (client) => {
// const size = str => {
// // returns the byte length of an utf8 string
// var s = str.length
// for (var i= str.length - 1; i >= 0; i--) {
// var code = str.charCodeAt(i)
// if (code > 0x7f && code <= 0x7ff) { s++ }
// else if (code > 0x7ff && code <= 0xffff) { s += 2 }
// if (code >= 0xDC00 && code <= 0xDFFF) i-- // trail surrogate
// }
// return s
// }
const $1815910806_progress = (client) => {
if (!client.inProgress) {
client.inProgress = {}
$3040487635.on(() => {
$3965338702.on(() => {
if (client.val !== null) {
if (!$1622386187_isEmpty(client.inProgress)) {
if (!$1815910806_isEmpty(client.inProgress)) {
if (client.inProgress.types) {
for (let i in client.inProgress) {
// order is still important since settign types after the facts is still broken
// order is still important since setting types after the fact is still broken
// this will be a big update

@@ -617,3 +686,5 @@ if (i === 'types') {

}
client.socket.send(JSON.stringify(client.inProgress))
const raw = JSON.stringify(client.inProgress)
// console.log(size(raw))
client.socket.send(raw)
}

@@ -627,7 +698,7 @@ client.inProgress = false

const $1622386187_send = (hub, client, struct, type, subs, tree) => {
const $1815910806_send = (hub, client, struct, type, subs, tree) => {
if (struct.isHub && client.val !== null) {
let isRemoved
if (type === 'remove') {
if (!struct._p[struct.key]) isRemoved = true
if (!struct._p || !struct._p[struct.key]) isRemoved = true
} else if (type === 'update' && tree.$t !== struct) {

@@ -640,3 +711,3 @@ if (tree.$t && tree.$t._p && !tree.$t._p[tree.$t.key]) {

// think of something fast for level...
$1622386187_serialize(client, $1622386187_progress(client), subs, prop, $2563227135.get(hub, 'serverIndex'), true)
$1815910806_serialize(client, $1815910806_progress(client), subs, prop, $3410192572.get(hub, 'serverIndex'), true)
}

@@ -648,11 +719,11 @@ prop = previous

}
$1622386187_serialize(client, $1622386187_progress(client), subs, struct, $2563227135.get(hub, 'serverIndex'), isRemoved)
$1815910806_serialize(client, $1815910806_progress(client), subs, struct, $3410192572.get(hub, 'serverIndex'), isRemoved)
}
}
const $1622386187_serialize = (client, t, subs, struct, level, isRemoved) => {
const stamp = $2563227135.get(struct, 'stamp') || 1 // remove the need for this default (feels wrong)
const val = isRemoved ? null : $2563227135.getVal(struct)
const $1815910806_serialize = (client, t, subs, struct, level, isRemoved) => {
const stamp = $3410192572.get(struct, 'stamp') || 1 // remove the need for this default (feels wrong)
const val = isRemoved ? null : $3410192572.getVal(struct)
if (val !== void 0 && stamp && !$3904796091_export_isCached(client, struct, stamp)) {
if (val !== void 0 && stamp && !$2991935526_isCached(client, struct, stamp)) {
// val === null -- double chck if this is nessecary

@@ -673,3 +744,3 @@ const path = struct.path()

if (isRemoved) {
$3904796091_export_cache(client, struct, stamp)
$2991935526_cache(client, struct, stamp)
s.stamp = stamp

@@ -679,20 +750,20 @@ s.val = val

if (subs.type) {
const type = $2563227135.get(struct, 'type') // make getType (fast)
if ($2563227135.getVal(type) !== 'hub') {
$1622386187_serialize(client, t, subs.type, type, level)
const type = $3410192572.get(struct, 'type') // make getType (fast)
if ($3410192572.getVal(type) !== 'hub') {
$1815910806_serialize(client, t, subs.type, type, level)
}
}
$3904796091_export_cache(client, struct, stamp)
$2991935526_cache(client, struct, stamp)
s.stamp = stamp
if (struct.key === 'type') {
if (val === 'hub') return
$1622386187_serialize(client, t, subs, $2563227135.getType(struct.parent(2), val), level)
$1815910806_serialize(client, t, subs, $3410192572.getType(struct.parent(2), val), level)
// allways need a stamp!
}
if (typeof val === 'object' && val.inherits) {
if (typeof val === 'object' && val !== null && val.inherits) {
s.val = val.path()
s.val.unshift('@', 'root')
$1622386187_serialize(client, t, subs, val, level)
$1815910806_serialize(client, t, subs, val, level)
} else if (val !== void 0) {

@@ -704,18 +775,18 @@ s.val = val

// can send a bit too much data when val: true and overlapping keys
$1622386187_serialize(client, t, subs, val, level)
$1815910806_serialize(client, t, subs, val, level)
}
if (subs.val === true && !isRemoved) {
$1622386187_deepSerialize($2563227135.getKeys(struct), client, t, subs, struct, level)
$1815910806_deepSerialize($3410192572.getKeys(struct), client, t, subs, struct, level)
}
}
const $1622386187_deepSerialize = (keys, client, t, subs, struct, level) => {
const $1815910806_deepSerialize = (keys, client, t, subs, struct, level) => {
if (struct.get('type') && struct.get('type').compute() !== 'hub') {
$1622386187_serialize(client, t, subs, struct.get('type'), level)
$1815910806_serialize(client, t, subs, struct.get('type'), level)
}
if (keys) {
for (let i = 0, len = keys.length; i < len; i++) {
let prop = $2563227135.get(struct, keys[i])
if (prop && prop.isHub) $1622386187_serialize(client, t, subs, prop, level)
let prop = $3410192572.get(struct, keys[i])
if (prop && prop.isHub) $1815910806_serialize(client, t, subs, prop, level)
}

@@ -726,3 +797,3 @@ }

let prop = struct._removed[i]
$1622386187_serialize(client, t, subs, prop, level, true)
$1815910806_serialize(client, t, subs, prop, level, true)
}

@@ -732,5 +803,6 @@ }

const $1622386187 = $1622386187_send
const $2931540049_removeSubscriptions = (t, id) => {
var $1815910806 = $1815910806_send
;
// FILE: /Users/jimdebeer/Desktop/brisky/hub.js/src/server/remove.js
const $2794538380_removeSubscriptions = (t, id) => {
if (t.subscriptions) {

@@ -746,3 +818,3 @@ let i = t.subscriptions.length

const $2931540049_removeClient = (client) => {
const $2794538380_removeClient = (client) => {
const id = client.key

@@ -755,3 +827,3 @@ client.val = null

const t = client.parent(2)
$2931540049_removeSubscriptions(t, id)
$2794538380_removeSubscriptions(t, id)
client.set(null)

@@ -763,10 +835,9 @@ // if (client.context && t.clients.keys().length === (t.url ? 1 : 0)) {

const $2931540049_export_removeSubscriptions = $2931540049_removeSubscriptions
const $2931540049_export_removeClient = $2931540049_removeClient
const $2931540049_$ALL$ = {
removeSubscriptions: $2931540049_export_removeSubscriptions,
removeClient: $2931540049_export_removeClient
}
var $2794538380_$ALL$ = {
removeSubscriptions: $2794538380_removeSubscriptions,
removeClient: $2794538380_removeClient
};
// FILE: /Users/jimdebeer/Desktop/brisky/hub.js/src/server/incoming.js

@@ -779,3 +850,4 @@

const $1353865041 = (hub, socket, data) => {
var $3877567628 = (hub, socket, data) => {
const payload = data[0]

@@ -790,19 +862,19 @@ const meta = data[1]

if ('context' in meta && client.context != meta.context) { // eslint-disable-line
$2931540049_export_removeClient(client)
$1353865041_create(hub, socket, meta, payload)
$2794538380_removeClient(client)
$3877567628_create(hub, socket, meta, payload)
} else if (meta.subscriptions) {
if (payload) $1353865041_setPayload(t, payload, client)
$1353865041_incomingSubscriptions(t, client, meta, client.key)
$3040487635.close()
if (payload) $3877567628_setPayload(t, payload, client)
$3877567628_incomingSubscriptions(t, client, meta, client.key)
$3965338702.close()
}
} else {
$1353865041_create(hub, socket, meta, payload)
$3877567628_create(hub, socket, meta, payload)
}
} else {
$1353865041_setPayload(client.parent(2), payload, client)
$3040487635.close()
$3877567628_setPayload(client.parent(2), payload, client)
$3965338702.close()
}
}
const $1353865041_addToCache = (client, hub, payload) => {
const $3877567628_addToCache = (client, hub, payload) => {
if (typeof payload === 'object' && payload) {

@@ -813,3 +885,3 @@ for (let key in payload) {

if (struct && struct.isHub) {
$1353865041_addToCache(client, hub[key], payload[key])
$3877567628_addToCache(client, hub[key], payload[key])
}

@@ -819,3 +891,3 @@ }

if (payload.val !== void 0 && payload.stamp) {
$3904796091_export_cache(client, hub, payload.stamp)
$2991935526_cache(client, hub, payload.stamp)
}

@@ -825,21 +897,21 @@ }

const $1353865041_setPayload = (hub, payload, client) => {
const $3877567628_setPayload = (hub, payload, client) => {
hub.set(payload, false)
$1353865041_addToCache(client, hub, payload)
$3877567628_addToCache(client, hub, payload)
}
const $1353865041_set = (meta, socket, t, payload) => {
const stamp = $3040487635.create()
const $3877567628_set = (meta, socket, t, payload) => {
const stamp = $3965338702.create()
const id = meta.id
const context = meta.context
// const ip = socket._socket.remoteAddress
const client = socket.client = $3376394415(
const client = socket.client = $2627226290(
t, { socket, context }, stamp, socket.useragent, id
)
if (payload) $1353865041_setPayload(t, payload, client)
if (meta.subscriptions) $1353865041_incomingSubscriptions(t, client, meta, id)
$3040487635.close()
if (payload) $3877567628_setPayload(t, payload, client)
if (meta.subscriptions) $3877567628_incomingSubscriptions(t, client, meta, id)
$3965338702.close()
}
const $1353865041_create = (hub, socket, meta, payload) => {
const $3877567628_create = (hub, socket, meta, payload) => {
const t = meta.context ? hub.getContext(meta.context, socket) : hub

@@ -850,3 +922,3 @@ if (!t.inherits && t.then) {

console.log('client connected and found informations')
$1353865041_set(meta, socket, t, payload)
$3877567628_set(meta, socket, t, payload)
} else {

@@ -857,15 +929,15 @@ console.log('client discconected when logging in')

} else {
$1353865041_set(meta, socket, t, payload)
$3877567628_set(meta, socket, t, payload)
}
}
const $1353865041_incomingSubscriptions = (hub, client, meta, id) => {
const update = (t, type, subs, tree) => $1622386187(hub, client, t, type, subs, tree)
const $3877567628_incomingSubscriptions = (hub, client, meta, id) => {
const update = (t, type, subs, tree) => $1815910806(hub, client, t, type, subs, tree)
if (!client.upstreamSubscriptions) client.upstreamSubscriptions = {}
for (let key in meta.subscriptions) {
let uid = key + '-' + id
const uid = key + '-' + id
if (!client.upstreamSubscriptions[uid]) {
let subs = $3742651364(meta.subscriptions[key], hub)
const subs = $500722009(meta.subscriptions[key], hub, void 0, client)
client.upstreamSubscriptions[uid] = subs
$2563227135.subscribe(hub, subs, update)
$3410192572.subscribe(hub, subs, update)
hub.subscriptions[hub.subscriptions.length - 1]._uid_ = id

@@ -875,7 +947,8 @@ }

}
;
// FILE: /Users/jimdebeer/Desktop/brisky/hub.js/src/server/on.js
var $2138030230_removedInProgress
const $2138030230_on = {
var $1024955051_removedInProgress
const $1024955051_on = {
data: {

@@ -897,12 +970,12 @@ remove$: (val, stamp, struct) => {

target._removed = []
if (!$2138030230_removedInProgress) {
$2138030230_removedInProgress = []
$3040487635.on(() => {
let i = $2138030230_removedInProgress.length
if (!$1024955051_removedInProgress) {
$1024955051_removedInProgress = []
$3965338702.on(() => {
let i = $1024955051_removedInProgress.length
while (i--) {
delete $2138030230_removedInProgress[i]._removed
delete $1024955051_removedInProgress[i]._removed
}
})
}
$2138030230_removedInProgress.push(target)
$1024955051_removedInProgress.push(target)
}

@@ -917,3 +990,5 @@ target._removed.push(struct)

const $2138030230 = $2138030230_on
var $1024955051 = $1024955051_on
;
// FILE: /Users/jimdebeer/Desktop/brisky/hub.js/src/server/index.js

@@ -925,7 +1000,6 @@

const $802868340_Server = $963985755.Server
const $3248609833_Server = $911301798.Server
const $3248609833_createServer = (hub, port) => {
const server = new $3248609833_Server({ port })
const $802868340_createServer = (hub, port) => {
const server = new $802868340_Server({ port })
console.log(`💫 hub listening on ${port} 💫`)

@@ -938,7 +1012,7 @@

data = JSON.parse(data)
if (data) { $1353865041(hub, socket, data) }
if (data) { $3877567628(hub, socket, data) }
})
const close = () => {
if (socket.client) $2931540049_export_removeClient(socket.client)
if (socket.client) $2794538380_removeClient(socket.client)
}

@@ -952,8 +1026,8 @@

const $3248609833_removeServer = hub => {
const $802868340_removeServer = hub => {
const server = hub._server_
const instances = hub.instances
$3248609833_closeConnections(hub)
$802868340_closeConnections(hub)
for (let i = 0, len = instances && instances.length; i < len; i++) {
$3248609833_closeConnections(instances[i])
$802868340_closeConnections(instances[i])
}

@@ -966,3 +1040,3 @@

const $3248609833_closeConnections = hub => {
const $802868340_closeConnections = hub => {
const clients = hub.clients

@@ -974,3 +1048,3 @@ const id = hub._uid_ // to exclude the client (not nessecary)

client.val = null
$2931540049_export_removeSubscriptions(hub, client.key)
$2794538380_removeSubscriptions(hub, client.key)
client.socket.close()

@@ -982,3 +1056,3 @@ }

const $3248609833_removePort = hub => {
const $802868340_removePort = hub => {
hub.port = null

@@ -989,8 +1063,8 @@ hub.serverIndex = null

const $3248609833_port = (hub, val, key, stamp) => {
const $802868340_port = (hub, val, key, stamp) => {
// use remove
hub.on((val, stamp, t) => {
if (val === null && !t._c && t === hub) {
$3248609833_removeServer(hub)
$3248609833_removePort(hub)
$802868340_removeServer(hub)
$802868340_removePort(hub)
}

@@ -1001,10 +1075,10 @@ }, 'port$')

if (hub._server_) {
$3248609833_removeServer(hub)
$802868340_removeServer(hub)
}
if (!val) {
if (hub.port) hub.port.set(null, stamp)
$3248609833_removePort(hub)
$802868340_removePort(hub)
} else {
if (!hub.port) {
$2563227135.create({
$3410192572.create({
on: {

@@ -1019,3 +1093,3 @@ data: {

hub.serverIndex = i
hub._server_ = $3248609833_createServer(hub, val)
hub._server_ = $802868340_createServer(hub, val)
}

@@ -1025,3 +1099,3 @@ }

}
}, stamp, $2563227135.struct, hub, key)
}, stamp, $3410192572.struct, hub, key)
}

@@ -1033,57 +1107,20 @@ hub.port.set(val, stamp)

const $3248609833_props = {
const $802868340_props = {
_server_: true,
serverIndex: true,
port: $3248609833_port
port: $802868340_port
}
const $3248609833_export_props = $3248609833_props
const $3248609833_export_on = $2138030230
var $802868340 = { props: $802868340_props, on: $1024955051 }
const $3248609833_$ALL$ = {
props: $3248609833_export_props,
on: $3248609833_export_on
}
const $25049122 = {
props: {
contextKey: true,
getContext: (t, fn) => {
t.set({
define: {
getContext (key, socket) {
return fn(key, (key) => $25049122_createContext(this, key), this, socket)
}
}
})
}
},
getContext: (key, context) => context()
}
;
// FILE: /Users/jimdebeer/Desktop/brisky/hub.js/src/hub.js
const $25049122_createContext = (hub, val) => {
var result = $25049122_find(hub, val)
if (!result) {
result = hub.create({ contextKey: val }, false)
}
return result
}
const $25049122_find = (hub, val) => {
const instances = hub.instances
if (instances) {
let i = instances.length
while (i--) {
if (instances[i].contextKey === val) return instances[i]
}
}
}
const $499364063_types = $3410192572.struct.props.types
const $302300578_types = $2563227135.struct.props.types
const $302300578_hub = $2563227135.create({
const $499364063_hub = $3410192572.create({
type: 'hub',

@@ -1098,9 +1135,9 @@ instances: false,

if (!t.clients) {
t.clients = $2563227135.create(val, stamp, $302300578_clients, t, key)
t.clients = $3410192572.create(val, stamp, $499364063_clients, t, key)
} else {
$2563227135.set(t.clients, val, stamp)
$3410192572.set(t.clients, val, stamp)
}
},
types: $302300578_types.bind(), // to not interfere with struct type
type: $2563227135.struct.props.type.bind(),
types: $499364063_types.bind(), // to not interfere with struct type
type: $3410192572.struct.props.type.bind(),
client: true

@@ -1110,15 +1147,15 @@ }

$302300578_hub.props.types.struct = $302300578_hub.create({
props: { default: $302300578_types.struct.props.default.bind() }
$499364063_hub.props.types.struct = $499364063_hub.create({
props: { default: $499364063_types.struct.props.default.bind() }
}, false)
$302300578_hub.props.types.struct.props.default.struct = $302300578_hub.props.type.struct = $302300578_hub
$499364063_hub.props.types.struct.props.default.struct = $499364063_hub.props.type.struct = $499364063_hub
$302300578_hub.set({ types: { hub: 'self' }, inject: [ $3248609833_$ALL$, $48594293_$ALL$, $25049122 ] }, false)
$499364063_hub.set({ types: { hub: 'self' }, inject: [ $802868340, $3098744616_$ALL$, $2193415007 ] }, false)
$302300578_hub.types._ks = void 0
$499364063_hub.types._ks = void 0
const $302300578_clients = $2563227135.create({
const $499364063_clients = $3410192572.create({
props: {
default: $302300578_hub.create({
default: $499364063_hub.create({
props: {

@@ -1135,14 +1172,15 @@ cache: true,

const $302300578 = $302300578_hub
var $499364063 = $499364063_hub
;
// FILE: /Users/jimdebeer/Desktop/brisky/hub.js/src/index.js
if (typeof __filename !== 'undefined') console.log('hub.js:', __filename)
const $621652771_fn = (val, stamp) => $302300578.create(val, stamp)
const $621652771 = $621652771_fn
const $439939774_fn = (val, stamp) => $499364063.create(val, stamp)
var $439939774 = $439939774_fn
// add uids to stamps else it sucks -- dont compromise for tests think of that as an after thought
;
module.exports = $621652771
module.exports = $439939774
{
"name": "hub.js",
"description": "Seamless realtime communcation",
"version": "0.0.11-7d8a170431bac9b23de7c7c8468348ff668d61d0",
"version": "0.0.11-906f01f6023971bcb9a7054634690bcc36335fa4",
"main": "dist/index.js",
"browser": {
"./dist/index.js": "./dist/browser.js",
"./dist/index.es.js": "./dist/browser.es.js",
"./dist/index.js": "./dist/index.browser.js",
"./src/client/uid/index.js": "./src/client/uid/browser.js",

@@ -15,4 +14,8 @@ "./src/server/index.js": "./src/server/browser.js",

"scripts": {
"build": "builder-boy src/index.js dist/index.js",
"lint": "standard --fix",
"build": "builder-boy src/index.js dist/index.js -r -t node -t browser",
"watch": "builder-boy src/index.js dist/index.js -w -r -t node -t browser",
"dev": "nodemon --watch dist --watch test --exec 'node test/index.js'",
"pretest": "npm run build",
"preversion": "npm run precommit",
"precommit": "npm run test && standard --fix",
"version-commit": "npm --no-git-tag-version version $(node -pe \"require('./package.json').version.split('-')[0]\")-$(git log -n 1 --pretty=format:'%H')",

@@ -25,3 +28,3 @@ "publish-branch": "npm run version-commit && npm publish --tag $(git rev-parse --abbrev-ref HEAD | sed 's/\\//-/g')",

},
"precommit": "lint, test",
"precommit": "precommit",
"repository": {

@@ -45,7 +48,6 @@ "type": "git",

"brisky-stamp": "^4.0.0",
"brisky-struct": "feature-enhancements",
"brisky-struct": "^1.3.0",
"string-hash": "^1.1.0",
"uws": "0.12.0",
"vigour-ua": "^3.0.0",
"websocket": "^1.0.24"
"vigour-ua": "^3.0.0"
},

@@ -61,3 +63,2 @@ "nyc": {

"builder-boy": "latest",
"buble": "0.15.1",
"coveralls": "^2.11.9",

@@ -67,3 +68,2 @@ "nodemon": "^1.11.0",

"pre-commit": "^1.1.3",
"rollup-watch": "^2.5.0",
"standard": "^8.1.0",

@@ -70,0 +70,0 @@ "tape": "4.6.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

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