Comparing version 0.0.10 to 0.0.11-56a16229a5f5f7943db0ee0fcada5e37692fb0fc
1331
dist/index.js
@@ -1,45 +0,27 @@ | ||
'use strict'; | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
const $2563227135 = require('brisky-struct/dist/index.js') | ||
const $3040487635 = require('brisky-stamp/dist/index.js') | ||
var hash = _interopDefault(require('string-hash')); | ||
var briskyStruct = require('brisky-struct'); | ||
var bs = _interopDefault(require('brisky-stamp')); | ||
var WebSocket = _interopDefault(require('uws')); | ||
const uniq = process.pid; | ||
var id = hash(`b-${Date.now()}-${(Math.random() * 10000) | 0}-${uniq}`); | ||
const next = typeof window === 'undefined' | ||
const $4125568599_next = typeof window === 'undefined' | ||
? process.nextTick | ||
: global.requestAnimationFrame; | ||
: global.requestAnimationFrame | ||
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 $4125568599_serialize = (hub, t, struct, val, level) => { | ||
if (!struct.isHub || struct.key === 'clients' || (struct._p && struct._p.key === 'clients')) { | ||
return | ||
} | ||
}; | ||
const serialize = (hub, t, struct$$1, val, level) => { | ||
const path = struct$$1.path(); | ||
const len = path.length; | ||
const path = struct.path() // cached version (later) | ||
const len = path.length | ||
if (struct$$1.val !== void 0 || val === null) { | ||
var s = t[0] || (t[0] = {}); | ||
if (struct.val !== void 0 || val === null) { | ||
var s = t[0] || (t[0] = {}) | ||
for (let i = level; i < len; i++) { | ||
let t = s[path[i]]; | ||
let t = s[path[i]] | ||
if (!t) { | ||
s = s[path[i]] = {}; | ||
s = s[path[i]] = {} | ||
} else { | ||
s = t; | ||
s = t | ||
if (s.val === null) { return } | ||
@@ -49,3 +31,3 @@ } | ||
s.stamp = parse$1(struct$$1.stamp, hub, t); | ||
s.stamp = struct.stamp | ||
@@ -55,70 +37,96 @@ if (val === null) { | ||
if (key !== 'stamp') { | ||
delete s[key]; | ||
delete s[key] | ||
} | ||
} | ||
s.val = null; | ||
} else if (struct$$1.val && struct$$1.val.inherits) { | ||
s.val = struct$$1.val.path(); | ||
s.val.unshift('@', 'root'); | ||
serialize(hub, t, struct$$1.val, val, level); | ||
} else if (struct$$1.val !== void 0) { | ||
s.val = struct$$1.val; | ||
s.val = null | ||
} else if (struct.val && struct.val.inherits) { | ||
// make a bit more secure... | ||
// if (!s.val) { | ||
s.val = struct.val.path() | ||
s.val.unshift('@', 'root') | ||
// if allrdy serialized stop it! | ||
$4125568599_serialize(hub, t, struct.val, val, level) | ||
// } | ||
} else if (struct.val !== void 0) { | ||
s.val = struct.val | ||
} | ||
} | ||
}; | ||
} | ||
const meta = hub => { | ||
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 $4125568599_meta = hub => { | ||
if (!hub.receiveOnly) { | ||
const store = $4125568599_inProgress(hub, $3040487635.inProgress ? $3040487635.on : $4125568599_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 send = (val, stamp, struct$$1) => { | ||
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 | ||
} | ||
const $4125568599_send = (val, stamp, struct) => { | ||
// -1 means upsteam (floats for extra speed) | ||
let hub | ||
let p = struct | ||
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 === hub) { | ||
if (val === null) { | ||
return | ||
} | ||
serialize(hub, inProgress(hub, bs.on), struct$$1, val, hub.urlIndex); | ||
} else if (struct._p.key === 'clients') { | ||
if (struct.key !== hub.client.key) { | ||
return | ||
} | ||
} | ||
$4125568599_serialize(hub, $4125568599_inProgress(hub, $3040487635.on), struct, val, hub.urlIndex) | ||
} | ||
}; | ||
} | ||
const inProgress = (hub, tick) => { | ||
const $4125568599_inProgress = (hub, tick) => { | ||
if (!hub.inProgress) { | ||
hub.inProgress = []; | ||
hub.inProgress = [] | ||
tick(() => { | ||
if (hub.connected.compute() === true) { | ||
out(hub); | ||
$4125568599_out(hub) | ||
} else { | ||
hub.connected.once(true, () => out(hub)); | ||
hub.connected.once(true, () => $4125568599_out(hub)) | ||
} | ||
}); | ||
}) | ||
} | ||
return hub.inProgress | ||
}; | ||
} | ||
const out = t => { | ||
t.socket.send(JSON.stringify(t.inProgress)); | ||
t.inProgress = false; | ||
}; | ||
const $4125568599_out = t => { | ||
t.socket.send(JSON.stringify(t.inProgress)) | ||
t.inProgress = false | ||
} | ||
const isEmpty = t => { | ||
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 | ||
const $2878564687 = $4020852141.w3cwebsocket | ||
const $2711378567_isEmpty = t => { | ||
for (let i in t) { return false } | ||
return true | ||
}; | ||
} | ||
@@ -135,6 +143,7 @@ // function merge (a, b) { | ||
const parse$2 = (struct$$1, obj, key, root) => { | ||
const result = {}; | ||
if (!root) { root = result; } | ||
if (obj.type) result.type = obj.type; // need to be done before the rest of subs to sync correctly | ||
const $2711378567_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') | ||
for (let i in obj) { | ||
@@ -146,3 +155,3 @@ if (i !== '_' && i !== 'type') { | ||
// console.log('CLIENT NEED TO HANDLE MORE SPECIAL THEN JUST ROOT') | ||
// let id = state.id | ||
// let id = state._uid_ | ||
// if (!root.clients) { root.clients = {} } | ||
@@ -152,16 +161,16 @@ // if (!root.clients[id]) { root.clients[id] = {} } | ||
} else if (typeof obj[i] === 'function') { | ||
let val = obj[i].toString(); | ||
let val = obj[i].toString() | ||
if (!/^(function|\()/.test(val)) { | ||
if (/^.+=>/.test(val)) { | ||
if (!/^(\(){0, 1}.+(\)){0, 1} +=>/.test(val)) { | ||
val = val.replace(/^(.*?)( +=>)/, '($1)$2'); | ||
val = val.replace(/^(.*?)( +=>)/, '($1)$2') | ||
} | ||
if (!/^(.*?)+=> +{(.*?)}$/.test(val) && val.indexOf('return ') === -1) { | ||
val = val.replace(/^(.+=> *?)(.*?)/, '$1 { return $2') + ' }'; | ||
val = val.replace(/^(.+=> *?)(.*?)/, '$1 { return $2') + ' }' | ||
} | ||
val = val.replace('=>', ''); | ||
val = val.replace('=>', '') | ||
} | ||
val = 'function ' + val; | ||
val = 'function ' + val | ||
} | ||
result['$fn|' + i] = val; | ||
result['$fn|' + i] = val | ||
// also here we need to rewrite client to use client id | ||
@@ -173,7 +182,7 @@ } else if (typeof obj[i] !== 'object') { | ||
// } else { | ||
result[i] = obj[i]; | ||
result[i] = obj[i] | ||
// } | ||
} else { | ||
// empty objects are very uninteresetting maybe just skip them | ||
let parsed = parse$2(struct$$1, obj[i], i, root); | ||
let parsed = $2711378567_parse(struct, obj[i], i, root) | ||
@@ -188,3 +197,3 @@ // if (i === 'root' || i === 'parent') { | ||
if (parsed !== void 0) { result[i] = parsed; } | ||
if (parsed !== void 0) { result[i] = parsed } | ||
} | ||
@@ -194,126 +203,223 @@ } | ||
// if result is empty ignore -- may not be a good idea | ||
return isEmpty(result) ? void 0 : result | ||
}; | ||
return $2711378567_isEmpty(result) ? void 0 : result | ||
} | ||
const connect = (hub, url, reconnect) => { | ||
const socket = new WebSocket(url); | ||
const id = hub.id; | ||
// can be one less fn... | ||
const $2711378567 = $2711378567_parse | ||
hub.set({ clients: { [id]: { } } }, false); | ||
const $257117234 = require('string-hash/index.js') | ||
const $1190737809 = require('vigour-ua/index.js') | ||
const client = hub.clients[id]; | ||
const $1123050690_uniq = process.pid | ||
const $1123050690 = () => $257117234(`b-${Date.now()}-${(Math.random() * 10000) | 0}-${$1123050690_uniq}`) | ||
hub.set({ client }, false); | ||
hub.reconnect = null; | ||
const $3376394415 = (t, val, stamp, useragent, id) => { | ||
if (!id) id = t._uid_ || $1123050690() | ||
$1190737809(useragent, val) | ||
t.set({ clients: { [id]: val } }, stamp) | ||
return t.clients[id] | ||
} | ||
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) | ||
hub.reconnect = null | ||
const close = () => { | ||
const stamp = bs.create('disconnect', hub.id); | ||
hub.socket = false; | ||
hub.set({ connected: false }, stamp); | ||
bs.close(); | ||
if (!socket.blockReconnect && hub.url) { | ||
reconnect = Math.min((reconnect * 1.5), 2000); | ||
hub.reconnect = setTimeout(connect, reconnect, hub, url, reconnect); | ||
const stamp = $3040487635.create() | ||
hub.socket = false | ||
hub.set({ connected: false }, stamp) | ||
$3040487635.close() | ||
if (!socket.blockReconnect && hub._url_) { | ||
reconnect = Math.min((reconnect * 1.5), 2000) | ||
hub.reconnect = setTimeout($48594293_connect, reconnect, hub, url, reconnect) | ||
} | ||
}; | ||
} | ||
socket.onclose = close; | ||
socket.onclose = close | ||
socket.onerror = () => { | ||
if (typeof window === 'undefined') { | ||
close(); | ||
} else { | ||
socket.close(); | ||
} | ||
}; | ||
if (typeof window === 'undefined') { | ||
socket.hackyOnClose = close | ||
} | ||
socket.onerror = typeof window === 'undefined' | ||
? close | ||
: () => socket.close() | ||
socket.onopen = () => { | ||
const stamp = bs.create('connected', hub.id); | ||
hub.socket = socket; | ||
meta(hub); | ||
hub.set({ connected: true }, stamp); | ||
bs.close(); | ||
}; | ||
const stamp = $3040487635.create() | ||
hub.socket = socket | ||
$4125568599_export_meta(hub) | ||
hub.set({ connected: true }, stamp) | ||
$3040487635.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); | ||
}; | ||
}; | ||
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) | ||
} | ||
$3040487635.close() | ||
} | ||
} | ||
const removeUrl = hub => { | ||
hub.url = null; | ||
hub.urlIndex = null; | ||
hub.emitters.set({ data: { url$: null } }, false); | ||
}; | ||
const $48594293_removeUrl = hub => { | ||
hub.url = hub._url_ = hub.urlIndex = null | ||
hub.emitters.set({ data: { url$: null } }, false) | ||
} | ||
const removeSocket = hub => { | ||
const $48594293_removeSocket = hub => { | ||
if (hub.reconnect) { | ||
clearTimeout(hub.reconnect); | ||
hub.reconnect = null; | ||
clearTimeout(hub.reconnect) | ||
hub.reconnect = null | ||
} | ||
if (hub.socket) { | ||
hub.socket.blockReconnect = true; | ||
hub.socket.close(); | ||
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 = false | ||
} | ||
const url = (hub, val, stamp) => { | ||
const $48594293_url = (hub, val, key, stamp) => { | ||
hub.on((val, stamp, t) => { | ||
if (val === null && !t._c && t === hub) { | ||
hub.subscriptions = []; | ||
removeUrl(hub); | ||
removeSocket(hub); | ||
hub.subscriptions = [] | ||
$48594293_removeUrl(hub) | ||
$48594293_removeSocket(hub) | ||
} | ||
}, 'url$'); | ||
if (!val) val = null; | ||
if (val !== hub.url) { | ||
removeSocket(hub); | ||
hub.set({ connected: false }, stamp); | ||
}, 'url$') | ||
if (!val) val = null | ||
if ((!hub.url && val) || (hub.url.compute() !== val)) { | ||
$48594293_removeSocket(hub) | ||
if (!val) { | ||
removeUrl(hub); | ||
hub.set({ connected: false }, stamp) | ||
hub._url_ = null | ||
if (hub.url) hub.url.set(null, stamp) | ||
} else { | ||
let i = -1; | ||
if (hub.key) i++; | ||
hub.parent(() => { i++; }); | ||
hub.urlIndex = i; | ||
hub.url = val; | ||
connect(hub, val, 50); | ||
if (!hub.url) { | ||
$2563227135.create({ | ||
on: { | ||
data: { | ||
url: (val, stamp, struct) => { | ||
val = struct.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 | ||
$48594293_connect(hub, val, 50) | ||
} else { | ||
hub._url_ = null | ||
} | ||
} | ||
} | ||
} | ||
}, stamp, $2563227135.struct, hub, key) | ||
} | ||
hub.url.set(val, stamp) | ||
} | ||
} | ||
}; | ||
} | ||
// 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 $48594293_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] | ||
} | ||
}) | ||
} | ||
} | ||
const connected = { type: 'struct' }; | ||
const $48594293_connected = { | ||
type: 'struct', | ||
on: { | ||
data: { | ||
removeClients: (val, stamp, t) => { | ||
if (t.compute() === false) { | ||
// all instances! -- fix this | ||
$48594293_removeClients(t._p, stamp) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
const context = (hub, val) => { | ||
if (val !== hub.clientContext) { | ||
hub.clientContext = val; | ||
if (hub.connected && hub.connected.compute() === true) meta(hub); | ||
const $48594293_contextStruct = $2563227135.struct.create({ | ||
props: { | ||
default: { | ||
on: { | ||
data: { | ||
updateParent: (val, stamp, t) => { | ||
console.log('👻 GO UPDATE PARENT!!! 👻') | ||
t.parent().emit('data', val, stamp) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
}) | ||
const props = { | ||
const $48594293_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 $48594293_context = (hub, val, key, stamp) => { | ||
if (!hub.context || $48594293_contextIsNotEqual(val, hub.context)) { | ||
console.log('⚽️ fire fire fire FLAME context ⚽️', val, stamp) | ||
if (!hub.context) { | ||
$2563227135.create(val, stamp, $48594293_contextStruct, hub, key) | ||
} else { | ||
$48594293_removeClients(hub, stamp) | ||
hub.context.set(val, stamp) | ||
} | ||
if (hub.connected && hub.connected.compute() === true) $4125568599_export_meta(hub) | ||
} | ||
} | ||
const $48594293_props = { | ||
reconnect: true, | ||
@@ -324,40 +430,43 @@ socket: true, | ||
receiveOnly: true, | ||
url, | ||
context, | ||
connected | ||
}; | ||
url: $48594293_url, | ||
context: $48594293_context, | ||
connected: $48594293_connected | ||
} | ||
const stub = () => {}; | ||
const $48594293_stub = () => {} | ||
const define = { | ||
const $48594293_define = { | ||
subscribe (subs, cb, raw, tree) { | ||
if (!raw) subs = briskyStruct.parse(subs); | ||
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); | ||
if (!raw) subs = $2563227135.parse(subs) | ||
if (!this.receiveOnly) { | ||
const parsed = $2711378567(this, subs) | ||
if (parsed) { | ||
const key = $257117234(JSON.stringify(parsed)) | ||
if (!this.upstreamSubscriptions) { | ||
this.upstreamSubscriptions = { [key]: parsed } | ||
if (this.url) $4125568599_export_meta(this) | ||
} else if (!this.upstreamSubscriptions[key]) { | ||
this.upstreamSubscriptions[key] = parsed | ||
if (this.url) $4125568599_export_meta(this) | ||
} | ||
} | ||
} | ||
return briskyStruct.subscribe(this, subs, cb || stub, tree) | ||
return $2563227135.subscribe(this, subs, cb || $48594293_stub, tree) | ||
} | ||
}; | ||
} | ||
const on = { data: { send } }; | ||
const $48594293_on = { data: { send: $4125568599_export_send } } | ||
const $48594293_export_props = $48594293_props | ||
const $48594293_export_on = $48594293_on | ||
const $48594293_export_define = $48594293_define | ||
var client = Object.freeze({ | ||
props: props, | ||
on: on, | ||
define: define | ||
}); | ||
const isFn = /^\$fn\|/; | ||
const dummy = () => false; | ||
const $48594293_$ALL$ = { | ||
props: $48594293_export_props, | ||
on: $48594293_export_on, | ||
define: $48594293_export_define | ||
} | ||
const $911301798 = require('uws/uws.js') | ||
const $3742651364_isFn = /^\$fn\|/ | ||
const $3742651364_dummy = () => false | ||
// const client = (tree) => { | ||
@@ -395,17 +504,17 @@ // while (tree) { | ||
const parse$3 = (obj, state, key) => { | ||
const result = {}; | ||
const $3742651364_parse = (obj, state, key) => { | ||
const result = {} | ||
for (let i in obj) { | ||
if (isFn.test(i)) { | ||
let val = obj[i]; | ||
i = i.slice(4); | ||
if ($3742651364_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; | ||
let pass | ||
try { | ||
obj[i] = new Function('return ' + val)(); // eslint-disable-line | ||
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 | ||
@@ -416,430 +525,516 @@ // 2 options for this ofcourse | ||
} catch (e) { | ||
let msg; | ||
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)); | ||
obj[i] = dummy; | ||
let msg | ||
// 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)) | ||
obj[i] = $3742651364_dummy | ||
} | ||
} | ||
if (typeof obj[i] !== 'object') { | ||
result[i] = obj[i]; | ||
result[i] = obj[i] | ||
} else { | ||
result[i] = parse$3(obj[i], state, i); | ||
result[i] = $3742651364_parse(obj[i], state, i) | ||
} | ||
} | ||
return result | ||
}; | ||
} | ||
const progress = (client) => { | ||
const $3742651364 = $3742651364_parse | ||
const $3904796091_cache = (client, struct, stamp) => { | ||
if (!client.cache) client.cache = {} | ||
client.cache[$2563227135.puid(struct)] = stamp | ||
} | ||
const $3904796091_isCached = (client, struct, stamp) => client.cache && | ||
client.cache[$2563227135.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 | ||
} | ||
const $1622386187_isEmpty = obj => { | ||
for (let i in obj) { //eslint-disable-line | ||
return false | ||
} | ||
return true | ||
} | ||
const $1622386187_progress = (client) => { | ||
if (!client.inProgress) { | ||
client.inProgress = {}; | ||
bs.on(() => { | ||
client.inProgress = {} | ||
$3040487635.on(() => { | ||
if (client.val !== null) { | ||
var isEmpty = true; | ||
for (let i in client.inProgress) { //eslint-disable-line | ||
isEmpty = false; | ||
break | ||
} | ||
if (!isEmpty) { | ||
// bit hacky... | ||
if (!$1622386187_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 | ||
// this will be a big update | ||
if (i === 'types') { | ||
break | ||
} else { | ||
let tmp = client.inProgress[i]; | ||
delete client.inProgress[i]; | ||
client.inProgress[i] = tmp; | ||
let tmp = client.inProgress[i] | ||
delete client.inProgress[i] | ||
client.inProgress[i] = tmp | ||
} | ||
} | ||
} | ||
client.socket.send(JSON.stringify(client.inProgress)); | ||
client.socket.send(JSON.stringify(client.inProgress)) | ||
} | ||
client.inProgress = false; | ||
client.inProgress = false | ||
} | ||
}); | ||
}) | ||
} | ||
return client.inProgress | ||
}; | ||
} | ||
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 | ||
const $1622386187_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 | ||
} else if (type === 'update' && tree.$t !== struct) { | ||
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... | ||
$1622386187_serialize(client, $1622386187_progress(client), subs, prop, $2563227135.get(hub, 'serverIndex'), true) | ||
} | ||
prop = previous | ||
previous = previous._p | ||
} | ||
} | ||
} | ||
} 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, briskyStruct.get(hub, 'serverIndex'), tree); | ||
} | ||
$1622386187_serialize(client, $1622386187_progress(client), subs, struct, $2563227135.get(hub, 'serverIndex'), isRemoved) | ||
} | ||
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, briskyStruct.get(hub, 'serverIndex'), tree); | ||
} | ||
}; | ||
} | ||
const cache = (client, struct$$1, stamp, level, val) => { | ||
if (!client.cache) client.cache = {}; | ||
client.cache[struct$$1.uid()] = stamp[0]; | ||
}; | ||
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 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 = briskyStruct.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 = briskyStruct.getKeys(struct$$1); | ||
if (keys) deepSerialize(keys, id, client, t, subs, struct$$1, val, level); | ||
} | ||
} | ||
if (val !== void 0 && stamp && !$3904796091_export_isCached(client, struct, stamp)) { | ||
// val === null -- double chck if this is nessecary | ||
const path = struct.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]] = {} | ||
} else { | ||
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; | ||
} | ||
} | ||
s = tt | ||
if (s.val === null) return | ||
} | ||
} | ||
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; | ||
} | ||
} | ||
if (isRemoved) { | ||
$3904796091_export_cache(client, struct, stamp) | ||
s.stamp = stamp | ||
s.val = val | ||
} else { | ||
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) | ||
} | ||
} | ||
if (subs.val === true) { | ||
const keys = briskyStruct.getKeys(struct$$1); | ||
if (keys) deepSerialize(keys, id, client, t, subs, struct$$1, val, level); | ||
} | ||
$3904796091_export_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) | ||
// allways need a stamp! | ||
} | ||
if (typeof val === 'object' && val.inherits) { | ||
s.val = val.path() | ||
s.val.unshift('@', 'root') | ||
$1622386187_serialize(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 | ||
$1622386187_serialize(client, t, subs, val, level) | ||
} | ||
}; | ||
const typeSerialize = (id, client, t, subs, struct$$1, val, level) => { | ||
serialize$2(id, client, t, subs, briskyStruct.getType(struct$$1.parent(2), struct$$1.compute()), val, level); | ||
}; | ||
if (subs.val === true && !isRemoved) { | ||
$1622386187_deepSerialize($2563227135.getKeys(struct), client, t, subs, struct, level) | ||
} | ||
} | ||
const deepSerialize = (keys, id, client, t, subs, struct$$1, val, level) => { | ||
const $1622386187_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) | ||
} | ||
if (keys) { | ||
for (let i = 0, len = keys.length; i < len; i++) { | ||
let prop = briskyStruct.get(struct$$1, keys[i]); | ||
if (prop && prop.isHub) serialize$2(id, client, t, subs, prop, val, level); | ||
let prop = $2563227135.get(struct, keys[i]) | ||
if (prop && prop.isHub) $1622386187_serialize(client, t, subs, prop, 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]; | ||
if (prop && prop.isHub) serialize$2(id, client, t, subs, prop, null, level); | ||
if (struct._removed) { | ||
for (let i = 0, len = struct._removed.length; i < len; i++) { | ||
let prop = struct._removed[i] | ||
$1622386187_serialize(client, t, subs, prop, level, true) | ||
} | ||
} | ||
}; | ||
} | ||
var incoming = (hub, socket, data) => { | ||
const payload = data[0]; | ||
const meta = data[1]; | ||
var client = socket.client; | ||
var t; | ||
const $1622386187 = $1622386187_send | ||
const $2931540049_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 $2931540049_removeClient = (client) => { | ||
const id = client.key | ||
client.val = null | ||
if (client.socket) { | ||
client.socket.client = null | ||
client.socket = null | ||
} | ||
const t = client.parent(2) | ||
$2931540049_removeSubscriptions(t, id) | ||
client.set(null) | ||
// if (client.context && t.clients.keys().length === (t.url ? 1 : 0)) { | ||
// t.set(null, stamp) | ||
// } | ||
} | ||
const $2931540049_export_removeSubscriptions = $2931540049_removeSubscriptions | ||
const $2931540049_export_removeClient = $2931540049_removeClient | ||
const $2931540049_$ALL$ = { | ||
removeSubscriptions: $2931540049_export_removeSubscriptions, | ||
removeClient: $2931540049_export_removeClient | ||
} | ||
const $1353865041 = (hub, socket, data) => { | ||
const payload = data[0] | ||
const meta = data[1] | ||
var client = socket.client | ||
if (meta) { | ||
let t | ||
if (client) { | ||
t = hub; | ||
if (client.context != meta.context) { // eslint-disable-line | ||
client.set(null); | ||
t = create$2(hub, socket, meta); | ||
client = socket.client; | ||
t = hub | ||
if ('context' in meta && client.context != meta.context) { // eslint-disable-line | ||
$2931540049_export_removeClient(client) | ||
$1353865041_create(hub, socket, meta, payload) | ||
} else if (meta.subscriptions) { | ||
incomingSubscriptions(t, client, meta, client.id); | ||
bs.close(); | ||
if (payload) $1353865041_setPayload(t, payload, client) | ||
$1353865041_incomingSubscriptions(t, client, meta, client.key) | ||
$3040487635.close() | ||
} | ||
} else { | ||
t = create$2(hub, socket, meta); | ||
client = socket.client; | ||
$1353865041_create(hub, socket, meta, payload) | ||
} | ||
} else { | ||
t = client.parent(2); | ||
$1353865041_setPayload(client.parent(2), payload, client) | ||
$3040487635.close() | ||
} | ||
} | ||
if (payload) { | ||
if (meta && meta.resolve) { | ||
client.resolve = meta.resolve; | ||
t.set(payload, false); | ||
bs.on(() => { client.resolve = false; }); | ||
} else { | ||
t.set(payload, false); | ||
const $1353865041_addToCache = (client, hub, payload) => { | ||
if (typeof payload === 'object' && payload) { | ||
for (let key in payload) { | ||
if (key !== 'val' && key !== 'stamp') { | ||
let struct = hub[key] | ||
if (struct && struct.isHub) { | ||
$1353865041_addToCache(client, hub[key], payload[key]) | ||
} | ||
} | ||
} | ||
bs.close(); | ||
if (payload.val !== void 0 && payload.stamp) { | ||
$3904796091_export_cache(client, hub, payload.stamp) | ||
} | ||
} | ||
}; | ||
} | ||
const create$2 = (hub, socket, meta) => { | ||
const stamp = bs.create('connect'); | ||
const id = meta.id; | ||
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(stamp); | ||
return t | ||
}; | ||
const $1353865041_setPayload = (hub, payload, client) => { | ||
hub.set(payload, false) | ||
$1353865041_addToCache(client, hub, payload) | ||
} | ||
const incomingSubscriptions = (hub, client, meta, id) => { | ||
const update = (t, type, subs, tree) => send$1(hub, client, t, type, subs, tree); | ||
if (!client.upstreamSubscriptions) client.upstreamSubscriptions = {}; | ||
const $1353865041_set = (meta, socket, t, payload) => { | ||
const stamp = $3040487635.create() | ||
const id = meta.id | ||
const context = meta.context | ||
// const ip = socket._socket.remoteAddress | ||
const client = socket.client = $3376394415( | ||
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() | ||
} | ||
const $1353865041_create = (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') | ||
$1353865041_set(meta, socket, t, payload) | ||
} else { | ||
console.log('client discconected when logging in') | ||
} | ||
}).catch(err => hub.emit('error', err)) | ||
} else { | ||
$1353865041_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) | ||
if (!client.upstreamSubscriptions) client.upstreamSubscriptions = {} | ||
for (let key in meta.subscriptions) { | ||
let uid = key + '-' + id; | ||
let uid = key + '-' + id | ||
if (!client.upstreamSubscriptions[uid]) { | ||
let subs = parse$3(meta.subscriptions[key], hub); | ||
client.upstreamSubscriptions[uid] = subs; | ||
briskyStruct.subscribe(hub, subs, update); | ||
hub.subscriptions[hub.subscriptions.length - 1].id = id; | ||
let subs = $3742651364(meta.subscriptions[key], hub) | ||
client.upstreamSubscriptions[uid] = subs | ||
$2563227135.subscribe(hub, subs, update) | ||
hub.subscriptions[hub.subscriptions.length - 1]._uid_ = id | ||
} | ||
} | ||
}; | ||
} | ||
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); | ||
var $2138030230_removedInProgress | ||
const $2138030230_on = { | ||
data: { | ||
remove$: (val, stamp, struct) => { | ||
// just do a diff with the payload rly the best way for now... | ||
if (val === null && (!struct._c || struct._cLevel === 1)) { | ||
let p = struct | ||
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.parent() | ||
if (target) { | ||
if (!target._removed) { | ||
target._removed = [] | ||
if (!$2138030230_removedInProgress) { | ||
$2138030230_removedInProgress = [] | ||
$3040487635.on(() => { | ||
let i = $2138030230_removedInProgress.length | ||
while (i--) { | ||
delete $2138030230_removedInProgress[i]._removed | ||
} | ||
}) | ||
} | ||
$2138030230_removedInProgress.push(target) | ||
} | ||
target._removed.push(struct) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
const create$1 = (hub, port) => { | ||
const server = new Server({ port }); | ||
server.on('connection', (socket) => { | ||
const $2138030230 = $2138030230_on | ||
const $3248609833_Server = $911301798.Server | ||
const $3248609833_createServer = (hub, port) => { | ||
const server = new $3248609833_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!!!) | ||
socket.on('message', (data) => { | ||
data = JSON.parse(data); | ||
if (data) { incoming(hub, socket, data); } | ||
}); | ||
data = JSON.parse(data) | ||
if (data) { $1353865041(hub, socket, data) } | ||
}) | ||
const close = () => { | ||
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(); | ||
} | ||
}; | ||
if (socket.client) $2931540049_export_removeClient(socket.client) | ||
} | ||
socket.on('close', close); | ||
socket.on('close', close) | ||
// socket.on('error', () => close()) // need to do something here as well no leaks! | ||
}); | ||
}) | ||
return server | ||
}; | ||
} | ||
const removeServer = hub => { | ||
const server = hub.server; | ||
const instances = hub.instances; | ||
closeConnections(hub); | ||
const $3248609833_removeServer = hub => { | ||
const server = hub._server_ | ||
const instances = hub.instances | ||
$3248609833_closeConnections(hub) | ||
for (let i = 0, len = instances && instances.length; i < len; i++) { | ||
closeConnections(instances[i]); | ||
$3248609833_closeConnections(instances[i]) | ||
} | ||
server.httpServer.close(); | ||
server.httpServer.close() | ||
// remove all clients subscriptions | ||
hub.server = null; | ||
}; | ||
hub._server_ = null | ||
} | ||
const closeConnections = hub => { | ||
const clients = hub.clients; | ||
const id = hub.id; // to exclude the client (not nessecary) | ||
const $3248609833_closeConnections = hub => { | ||
const clients = hub.clients | ||
const id = hub._uid_ // to exclude the client (not nessecary) | ||
if (clients) { | ||
clients.forEach(client => { | ||
if (client.socket && client.key !== id) { | ||
client.val = null; | ||
removeSubscriptions(hub, client.key); | ||
client.socket.close(); | ||
client.val = null | ||
$2931540049_export_removeSubscriptions(hub, client.key) | ||
client.socket.close() | ||
} | ||
}); | ||
}) | ||
} | ||
}; | ||
} | ||
const removePort = hub => { | ||
hub.port = null; | ||
hub.serverIndex = null; | ||
hub.emitters.set({ data: { port$: null } }); | ||
}; | ||
const $3248609833_removePort = hub => { | ||
hub.port = null | ||
hub.serverIndex = null | ||
hub.emitters.set({ data: { port$: null } }) | ||
} | ||
const port = (hub, val) => { | ||
const $3248609833_port = (hub, val, key, stamp) => { | ||
// use remove | ||
hub.on((val, stamp, t) => { | ||
if (val === null && !t._c && t === hub) { | ||
removeServer(hub); | ||
removePort(hub); | ||
$3248609833_removeServer(hub) | ||
$3248609833_removePort(hub) | ||
} | ||
}, 'port$'); | ||
if (!val) val = null; | ||
if (val !== hub.port) { | ||
if (hub.server) { | ||
removeServer(hub); | ||
}, 'port$') | ||
if (!val) val = null | ||
if ((!hub.port && val) || (hub.port.compute() !== val)) { | ||
if (hub._server_) { | ||
$3248609833_removeServer(hub) | ||
} | ||
if (!val) { | ||
removePort(hub); | ||
if (hub.port) hub.port.set(null, stamp) | ||
$3248609833_removePort(hub) | ||
} else { | ||
hub.port = val; | ||
let i = -1; | ||
if (hub.key) i++; | ||
hub.parent(() => { i++; }); | ||
hub.serverIndex = i; | ||
hub.server = create$1(hub, val); | ||
} | ||
} | ||
}; | ||
const props$1 = { | ||
server: true, | ||
serverIndex: true, | ||
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; | ||
} | ||
}); | ||
if (!hub.port) { | ||
$2563227135.create({ | ||
on: { | ||
data: { | ||
port: (val, stamp, struct) => { | ||
val = struct.compute() | ||
if (val) { | ||
let i = -1 | ||
if (hub.key) i++ | ||
hub.parent(() => { i++ }) | ||
hub.serverIndex = i | ||
hub._server_ = $3248609833_createServer(hub, val) | ||
} | ||
} | ||
removedInProgress.push(target); | ||
} | ||
struct$$1._p._removed.push(struct$$1); | ||
} | ||
} | ||
}, stamp, $2563227135.struct, hub, key) | ||
} | ||
hub.port.set(val, stamp) | ||
} | ||
} | ||
}; | ||
} | ||
const $3248609833_props = { | ||
_server_: true, | ||
serverIndex: true, | ||
port: $3248609833_port | ||
} | ||
const $3248609833_export_props = $3248609833_props | ||
const $3248609833_export_on = $2138030230 | ||
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() | ||
} | ||
var server = Object.freeze({ | ||
props: props$1, | ||
on: on$1 | ||
}); | ||
const props$2 = { contextKey: true }; | ||
const define$1 = { | ||
getContext (val) { | ||
var result = find(this, val); | ||
if (!result) { | ||
result = this.create({ contextKey: val }, false); | ||
} | ||
return result | ||
const $25049122_createContext = (hub, val) => { | ||
var result = $25049122_find(hub, val) | ||
if (!result) { | ||
result = hub.create({ contextKey: val }, false) | ||
} | ||
}; | ||
return result | ||
} | ||
const find = (hub, val) => { | ||
const instances = hub.instances; | ||
const $25049122_find = (hub, val) => { | ||
const instances = hub.instances | ||
if (instances) { | ||
let i = instances.length; | ||
let i = instances.length | ||
while (i--) { | ||
if (instances[i].contextKey === val) { | ||
// console.log('found context --->', val, instances[i].clients.keys()) | ||
return instances[i] | ||
} | ||
if (instances[i].contextKey === val) return instances[i] | ||
} | ||
} | ||
}; | ||
} | ||
var context$1 = Object.freeze({ | ||
props: props$2, | ||
define: define$1 | ||
}); | ||
const types = briskyStruct.struct.props.types; | ||
const hub = briskyStruct.create({ | ||
if (typeof window === 'undefined') { | ||
// dont do this gets added to client... | ||
require('source-map-support').install() | ||
} | ||
const $302300578_types = $2563227135.struct.props.types | ||
const $302300578_hub = $2563227135.create({ | ||
type: 'hub', | ||
@@ -850,30 +1045,30 @@ instances: false, | ||
default: 'self', | ||
id: (t, val) => { t.set({ define: { id: val } }); }, | ||
_uid_: (t, val) => { t.set({ define: { _uid_: val } }) }, | ||
// why nto call this client id -- thats what it is | ||
clients: (t, val, key, stamp) => { | ||
if (!t.clients) { | ||
t.clients = briskyStruct.c(clients, val, stamp, t, key); | ||
t.clients = $2563227135.create(val, stamp, $302300578_clients, t, key) | ||
} else { | ||
briskyStruct.set(t.clients, val, stamp); | ||
$2563227135.set(t.clients, val, stamp) | ||
} | ||
}, | ||
types: types.bind(), // to not interfere with struct type | ||
type: briskyStruct.struct.props.type.bind(), | ||
types: $302300578_types.bind(), // to not interfere with struct type | ||
type: $2563227135.struct.props.type.bind(), | ||
client: true | ||
}, | ||
id | ||
}); | ||
} | ||
}) | ||
hub.props.types.struct = briskyStruct.c(hub, { | ||
props: { default: types.struct.props.default.bind() } | ||
}); | ||
$302300578_hub.props.types.struct = $302300578_hub.create({ | ||
props: { default: $302300578_types.struct.props.default.bind() } | ||
}, false) | ||
hub.props.types.struct.props.default.struct = hub.props.type.struct = hub; | ||
$302300578_hub.props.types.struct.props.default.struct = $302300578_hub.props.type.struct = $302300578_hub | ||
hub.set({ types: { hub: 'self' }, inject: [ server, context$1, client ] }, false); | ||
$302300578_hub.set({ types: { hub: 'self' }, inject: [ $3248609833_$ALL$, $48594293_$ALL$, $25049122 ] }, false) | ||
hub.types._ks = void 0; | ||
$302300578_hub.types._ks = void 0 | ||
const clients = briskyStruct.create({ | ||
const $302300578_clients = $2563227135.create({ | ||
props: { | ||
default: hub.create({ | ||
default: $302300578_hub.create({ | ||
props: { | ||
@@ -886,21 +1081,15 @@ cache: true, | ||
} | ||
}) | ||
}, false) | ||
} | ||
}); | ||
}, false) | ||
// import bs from 'brisky-stamp' | ||
const $302300578 = $302300578_hub | ||
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) | ||
} | ||
}; | ||
const $621652771_fn = (val, stamp) => $302300578.create(val, stamp) | ||
const $621652771 = $621652771_fn | ||
// add uids to stamps else it sucks -- dont compromise for tests think of that as an after thought | ||
module.exports = index; | ||
//# sourceMappingURL=index.js.map | ||
module.exports = $621652771 |
{ | ||
"name": "hub.js", | ||
"description": "Seamless realtime communcation", | ||
"version": "0.0.10", | ||
"version": "0.0.11-56a16229a5f5f7943db0ee0fcada5e37692fb0fc", | ||
"main": "dist/index.js", | ||
"module": "dist/index.es.js", | ||
"jsnext:main": "dist/index.es.js", | ||
"browser": { | ||
"./dist/index.js": "./dist/browser.js", | ||
"./dist/index.es.js": "./dist/browser.es.js", | ||
"./lib/uid/index.js": "./lib/uid/browser.js", | ||
"./lib/server/index.js": "./lib/server/browser.js", | ||
"./lib/client/websocket/index.js": "./lib/client/websocket/browser.js" | ||
"./src/client/uid/index.js": "./src/client/uid/browser.js", | ||
"./src/server/index.js": "./src/server/browser.js", | ||
"./src/client/websocket/index.js": "./src/client/websocket/browser.js", | ||
"source-map-support": false | ||
}, | ||
"scripts": { | ||
"build": "node rollup/build", | ||
"pretest": "npm run build && standard", | ||
"build": "builder-boy src/index.js dist/index.js", | ||
"lint": "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')", | ||
"publish-unstable": "npm run version-commit && npm publish --tag unstable", | ||
"pretest": "npm run build", | ||
"prepublish": "npm run build", | ||
"watch": "node rollup/watch", | ||
"postinstall": "[ -d dist ] || npm run build || ( mkdir dist && yarn && npm run build )", | ||
"test": "node test/index.js", | ||
"dev": "node rollup/watch & nodemon --harmony-async-await test/index.js", | ||
"cover": "nyc npm test", | ||
"travis": "nyc npm test && nyc report --reporter=text-lcov | coveralls" | ||
}, | ||
"precommit": "lint, test", | ||
"repository": { | ||
@@ -43,7 +43,8 @@ "type": "git", | ||
"dependencies": { | ||
"brisky-stamp": "^3.0.12", | ||
"brisky-struct": "^1.1.7", | ||
"brisky-stamp": "^4.0.0", | ||
"brisky-struct": "unstable", | ||
"string-hash": "^1.1.0", | ||
"uws": "0.12.0", | ||
"vigour-ua": "^2.2.3" | ||
"vigour-ua": "^3.0.0", | ||
"websocket": "^1.0.24" | ||
}, | ||
@@ -58,13 +59,10 @@ "nyc": { | ||
"devDependencies": { | ||
"source-map-support": "^0.4.7", | ||
"builder-boy": "latest", | ||
"buble": "0.15.1", | ||
"coveralls": "^2.11.9", | ||
"nodemon": "^1.11.0", | ||
"coveralls": "^2.11.9", | ||
"nyc": "^10.0.0", | ||
"pre-commit": "^1.1.3", | ||
"rollup": "^0.37.0", | ||
"rollup-plugin-commonjs": "^6.0.0", | ||
"rollup-plugin-istanbul": "^1.1.0", | ||
"rollup-plugin-node-resolve": "^2.0.0", | ||
"rollup-watch": "^2.5.0", | ||
"source-map-support": "^0.4.7", | ||
"standard": "^8.1.0", | ||
@@ -71,0 +69,0 @@ "tape": "4.6.0" |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
10
0
136189
6
5
932
+ Addedwebsocket@^1.0.24
+ Addedbrisky-stamp@4.0.1(transitive)
+ Addedbrisky-struct@1.1.7-7f398b2252470239555121110f7ee1cd796df8cd(transitive)
+ Addedbufferutil@4.0.9(transitive)
+ Addedd@1.0.2(transitive)
+ Addeddebug@2.6.9(transitive)
+ Addedes5-ext@0.10.64(transitive)
+ Addedes6-iterator@2.0.3(transitive)
+ Addedes6-symbol@3.1.4(transitive)
+ Addedesniff@2.0.1(transitive)
+ Addedevent-emitter@0.3.5(transitive)
+ Addedext@1.7.0(transitive)
+ Addedis-typedarray@1.0.0(transitive)
+ Addedms@2.0.0(transitive)
+ Addednext-tick@1.1.0(transitive)
+ Addednode-gyp-build@4.8.4(transitive)
+ Addedtype@2.7.3(transitive)
+ Addedtypedarray-to-buffer@3.1.5(transitive)
+ Addedutf-8-validate@5.0.10(transitive)
+ Addedvigour-ua@3.1.6(transitive)
+ Addedwebsocket@1.0.35(transitive)
+ Addedyaeti@0.0.6(transitive)
- Removedbrisky-stamp@3.0.12(transitive)
- Removedbrisky-struct@1.10.13(transitive)
- Removeddom-walk@0.1.2(transitive)
- Removedglobal@4.4.0(transitive)
- Removedmin-document@2.19.0(transitive)
- Removedprocess@0.11.10(transitive)
- Removedstamp@4.0.2(transitive)
- Removedvigour-ua@2.2.3(transitive)
Updatedbrisky-stamp@^4.0.0
Updatedbrisky-struct@unstable
Updatedvigour-ua@^3.0.0