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-907b71c23cfe12c87eda9584e8e9705300a123d5 to 0.0.11-988eecf1d7cfbc9c5e1eb98e07e72737306a6eab

dist/browser.es.js

402

dist/index.browser.js

@@ -0,14 +1,10 @@

var $1662971556 = require('brisky-struct')
;var $2822145224 = require('brisky-stamp')
;
// FILE: brisky-struct
const $1213768903 = require('brisky-struct')
// FILE: brisky-stamp
const $932573643 = require('brisky-stamp')
// FILE: /Users/youzi/dev/hub.js/src/client/send.js
const $4125568599_next = typeof window === 'undefined'
const $1094503762_next = typeof window === 'undefined'
? process.nextTick
: global.requestAnimationFrame
const $4125568599_serialize = (hub, t, struct, val, level) => {
const $1094503762_serialize = (hub, t, struct, val, level) => {
if (!struct.isHub || struct.key === 'clients' || (struct._p && struct._p.key === 'clients')) {

@@ -49,3 +45,3 @@ return

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

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

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

@@ -72,6 +68,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 = $1094503762_inProgress(hub, $2822145224.inProgress ? $2822145224.on : $1094503762_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 $1094503762_send = (val, stamp, struct) => {
// -1 means upsteam (floats for extra speed)

@@ -85,17 +99,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
}
$1094503762_serialize(hub, $1094503762_inProgress(hub, $2822145224.on), struct, val, hub.urlIndex)
}
$4125568599_serialize(hub, $4125568599_inProgress(hub, $932573643.on), struct, val, hub.urlIndex)
}
}
const $4125568599_inProgress = (hub, tick) => {
const $1094503762_inProgress = (hub, tick) => {
if (!hub.inProgress) {

@@ -105,5 +121,5 @@ hub.inProgress = []

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

@@ -115,3 +131,3 @@ })

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

@@ -123,12 +139,10 @@ t.inProgress = false

const $4125568599_$ALL$ = {
meta: $4125568599_meta,
send: $4125568599_send
var $1094503762_$ALL$ = {
meta: $1094503762_meta,
send: $1094503762_send
}
// FILE: /Users/youzi/dev/hub.js/src/client/websocket/browser.js
const $2878564687 = global.WebSocket
;var $1704955210 = global.WebSocket
// if ! native websocket construct a fallback (can use exception builder)
// FILE: /Users/youzi/dev/hub.js/src/subscription/serialize.js
const $2711378567_isEmpty = t => {
;const $3851780354_isEmpty = t => {
for (let i in t) { return false }

@@ -138,30 +152,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 $3851780354_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 = $3851780354_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 +180,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 = $3851780354_parse(struct, obj[i], i, root)
if (parsed !== void 0) { result[i] = parsed }

@@ -205,26 +189,21 @@ }

// if result is empty ignore -- may not be a good idea
return $2711378567_isEmpty(result) ? void 0 : result
return $3851780354_isEmpty(result) ? void 0 : result
}
// can be one less fn...
const $2711378567 = $2711378567_parse
var $3851780354 = $3851780354_parse
// FILE: string-hash
const $1851648559 = require('string-hash')
// FILE: vigour-ua
const $1888714796 = require('vigour-ua')
// FILE: /Users/youzi/dev/hub.js/src/client/uid/browser.js
const $1123050690_uniq = global.navigator.userAgent +
;var $2180032073 = require('string-hash')
;var $3305006410 = require('vigour-ua')
;
const $1384736615_uniq = global.navigator.userAgent +
global.navigator.userLanguage +
global.navigator.language
const $1123050690 = () => $1851648559(`b-${Date.now()}-${(Math.random() * 10000) | 0}-${$1123050690_uniq}`)
var $1384736615 = () => $2180032073(`b-${Date.now()}-${(Math.random() * 10000) | 0}-${$1384736615_uniq}`)
// FILE: /Users/youzi/dev/hub.js/src/client/create.js
;
const $3376394415 = (t, val, stamp, useragent, id) => {
if (!id) id = t._uid_ || $1123050690()
$1888714796(useragent, val)
var $2828932010 = (t, val, stamp, useragent, id) => {
if (!id) id = t._uid_ || $1384736615()
$3305006410(useragent, val)
t.set({ clients: { [id]: val } }, stamp)

@@ -234,3 +213,3 @@ return t.clients[id]

// FILE: /Users/youzi/dev/hub.js/src/client/index.js
;

@@ -243,8 +222,6 @@

const $3357289264_connect = (hub, url, reconnect) => {
const socket = new $1704955210(url)
const client = hub.client || $2828932010(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)

@@ -255,9 +232,9 @@

const close = () => {
const stamp = $932573643.create()
const stamp = $2822145224.create()
hub.socket = false
hub.set({ connected: false }, stamp)
$932573643.close()
$2822145224.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($3357289264_connect, reconnect, hub, url, reconnect)
}

@@ -268,6 +245,2 @@ }

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

@@ -278,12 +251,15 @@ ? close

socket.onopen = () => {
const stamp = $932573643.create()
const stamp = $2822145224.create()
hub.socket = socket
$4125568599_meta(hub)
if (hub.emitters && hub.emitters.incoming) {
$3357289264_enableIncomingListener(socket, hub)
}
$1094503762_meta(hub)
hub.set({ connected: true }, stamp)
$932573643.close()
$2822145224.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) {

@@ -296,7 +272,7 @@ hub.receiveOnly = true

}
$932573643.close()
$2822145224.close()
}
}
const $48594293_removeUrl = hub => {
const $3357289264_removeUrl = hub => {
hub.url = hub._url_ = hub.urlIndex = null

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

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

@@ -314,19 +290,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 $3357289264_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)
$3357289264_removeUrl(hub)
$3357289264_removeSocket(hub)
}

@@ -337,3 +307,3 @@ }, 'url$')

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

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

if (!hub.url) {
$1213768903.create({
$1662971556.create({
on: {

@@ -358,3 +328,3 @@ data: {

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

@@ -366,3 +336,3 @@ hub._url_ = null

}
}, stamp, $1213768903.struct, hub, key)
}, stamp, $1662971556.struct, hub, key)
}

@@ -374,3 +344,3 @@ hub.url.set(val, stamp)

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

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

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

@@ -398,3 +368,3 @@ on: {

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

@@ -406,3 +376,3 @@ }

const $48594293_contextStruct = $1213768903.struct.create({
const $3357289264_contextStruct = $1662971556.struct.create({
props: {

@@ -422,3 +392,3 @@ default: {

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

@@ -432,3 +402,2 @@ for (let field in val) {

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

@@ -438,16 +407,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 $3357289264_context = (hub, val, key, stamp) => {
if ((!hub.context && val) || (hub.context && $3357289264_contextIsNotEqual(val, hub.context))) {
// console.log('⚽️ fire fire fire FLAME context ⚽️', val, stamp)
if (!hub.context) {
$1213768903.create(val, stamp, $48594293_contextStruct, hub, key)
$1662971556.create(val, stamp, $3357289264_contextStruct, hub, key)
} else {
$48594293_removeClients(hub, stamp)
$3357289264_removeClients(hub, stamp)
hub.context.set(val, stamp)
}
if (hub.connected && hub.connected.compute() === true) $4125568599_meta(hub)
if (hub.connected && hub.connected.compute() === true) $1094503762_meta(hub)
}
}
const $48594293_props = {
const $3357289264_props = {
reconnect: true,

@@ -458,47 +427,65 @@ socket: true,

receiveOnly: true,
url: $48594293_url,
context: $48594293_context,
connected: $48594293_connected
url: $3357289264_url,
context: $3357289264_context,
connected: $3357289264_connected
}
const $48594293_stub = () => {}
const $3357289264_stub = () => {}
const $48594293_define = {
subscribe (subs, cb, raw, tree) {
if (!raw) subs = $1213768903.parse(subs)
if (!this.receiveOnly) {
const parsed = $2711378567(this, subs)
const $3357289264_define = {
subscribe (subs, cb, raw, tree, forceUpstream) {
if (!raw) subs = $1662971556.parse(subs)
if (!this.receiveOnly || forceUpstream) {
const parsed = $3851780354(this, subs)
if (parsed) {
const key = $1851648559(JSON.stringify(parsed))
if (forceUpstream) {
parsed.__force__ = true
}
// why not keep it stringified? -- saves lots of speed
const key = $2180032073(JSON.stringify(parsed))
if (!this.upstreamSubscriptions) {
this.upstreamSubscriptions = { [key]: parsed }
if (this.url) $4125568599_meta(this)
this.upstreamSubscriptions = {}
this.upstreamSubscriptions[key] = parsed
if (this.url) $1094503762_meta(this)
} else if (!this.upstreamSubscriptions[key]) {
this.upstreamSubscriptions[key] = parsed
if (this.url) $4125568599_meta(this)
if (this.url) $1094503762_meta(this)
}
}
}
return $1213768903.subscribe(this, subs, cb || $48594293_stub, tree)
return $1662971556.subscribe(this, subs, cb || $3357289264_stub, tree)
}
}
const $48594293_on = { data: { send: $4125568599_send } }
const $3357289264_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 $3357289264_on = {
data: { send: $1094503762_send },
props: {
incoming: (t, val, key, stamp) => {
const hub = t._p
if (hub.socket) $3357289264_enableIncomingListener(hub.socket, hub)
return $1662971556.emitterProperty(t, val, key, stamp)
}
}
}
const $48594293_$ALL$ = {
props: $48594293_props,
on: $48594293_on,
define: $48594293_define
}
// FILE: /Users/youzi/dev/hub.js/src/server/browser.js
// no server in the browser -- yet
const $3248609833_stub = {}
const $3248609833_$ALL$ = {
stub: $3248609833_stub
var $3357289264_$ALL$ = {
props: $3357289264_props,
on: $3357289264_on,
define: $3357289264_define
}
// FILE: /Users/youzi/dev/hub.js/src/context.js
const $25049122 = {
;var $2549126471 = {
props: {

@@ -510,3 +497,3 @@ contextKey: true,

getContext (key, socket) {
return fn(key, (key) => $25049122_createContext(this, key), this, socket)
return fn(key, (key) => $2549126471_createContext(this, key), this, socket)
}

@@ -520,4 +507,4 @@ }

const $25049122_createContext = (hub, val) => {
var result = $25049122_find(hub, val)
const $2549126471_createContext = (hub, val) => {
var result = $2549126471_find(hub, val)
if (!result) {

@@ -529,3 +516,3 @@ result = hub.create({ contextKey: val }, false)

const $25049122_find = (hub, val) => {
const $2549126471_find = (hub, val) => {
const instances = hub.instances

@@ -540,4 +527,6 @@ if (instances) {

// FILE: /Users/youzi/dev/hub.js/src/hub.js
;// no server in the browser -- yet
var $899748844 = {}
;

@@ -547,5 +536,5 @@

const $302300578_types = $1213768903.struct.props.types
const $4043401927_types = $1662971556.struct.props.types
const $302300578_hub = $1213768903.create({
const $4043401927_hub = $1662971556.create({
type: 'hub',

@@ -557,12 +546,4 @@ instances: false,

_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 = $1213768903.create(val, stamp, $302300578_clients, t, key)
} else {
$1213768903.set(t.clients, val, stamp)
}
},
types: $302300578_types.bind(), // to not interfere with struct type
type: $1213768903.struct.props.type.bind(),
types: $4043401927_types.bind(), // to not interfere with struct type
type: $1662971556.struct.props.type.bind(),
client: true

@@ -572,36 +553,57 @@ }

$302300578_hub.props.types.struct = $302300578_hub.create({
props: { default: $302300578_types.struct.props.default.bind() }
$4043401927_hub.props.types.struct = $4043401927_hub.create({
props: { default: $4043401927_types.struct.props.default.bind() }
}, false)
$302300578_hub.props.types.struct.props.default.struct = $302300578_hub.props.type.struct = $302300578_hub
$4043401927_hub.props.types.struct.props.default.struct = $4043401927_hub.props.type.struct = $4043401927_hub
$302300578_hub.set({ types: { hub: 'self' }, inject: [ $3248609833_$ALL$, $48594293_$ALL$, $25049122 ] }, false)
$302300578_hub.types._ks = void 0
const $302300578_clients = $1213768903.create({
props: {
default: $302300578_hub.create({
$4043401927_hub.set({
types: {
hub: 'self',
clients: {
type: 'struct',
instances: false,
props: {
cache: true,
upstreamSubscriptions: true,
resolve: true,
socket: true,
context: true
default: $4043401927_hub.create({
instances: false,
props: {
cache: true,
upstreamSubscriptions: true,
resolve: true,
socket: true,
context: true
}
}, false)
}
}, false)
}
}
},
props: {
// why nto call this client id -- thats what it is
clients: (t, val, key, stamp) => {
if (!t.clients) {
const clients = $1662971556.getType(t, key)
console.log('CLIENTS TYPE:', clients)
t.clients = $1662971556.create(val, stamp, clients, t, key)
} else {
$1662971556.set(t.clients, val, stamp)
}
}
},
inject: [ $899748844, $3357289264_$ALL$, $2549126471 ]
}, false)
const $302300578 = $302300578_hub
$4043401927_hub.types._ks = void 0
// FILE: /Users/youzi/dev/hub.js/src/index.js
var $4043401927 = $4043401927_hub
;
if (typeof __filename !== 'undefined') console.log('hub.js:', __filename)
const $621652771_fn = (val, stamp) => $302300578.create(val, stamp)
const $621652771 = $621652771_fn
const $3474573222_fn = (val, stamp) => $4043401927.create(val, stamp)
var $3474573222 = $3474573222_fn
// add uids to stamps else it sucks -- dont compromise for tests think of that as an after thought
module.exports = $3474573222

@@ -0,14 +1,10 @@

var $1662971556 = require('brisky-struct')
;var $2822145224 = require('brisky-stamp')
;
// FILE: brisky-struct
const $1213768903 = require('brisky-struct')
// FILE: brisky-stamp
const $932573643 = require('brisky-stamp')
// FILE: /Users/youzi/dev/hub.js/src/client/send.js
const $4125568599_next = typeof window === 'undefined'
const $1094503762_next = typeof window === 'undefined'
? process.nextTick
: global.requestAnimationFrame
const $4125568599_serialize = (hub, t, struct, val, level) => {
const $1094503762_serialize = (hub, t, struct, val, level) => {
if (!struct.isHub || struct.key === 'clients' || (struct._p && struct._p.key === 'clients')) {

@@ -49,3 +45,3 @@ return

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

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

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

@@ -72,6 +68,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 = $1094503762_inProgress(hub, $2822145224.inProgress ? $2822145224.on : $1094503762_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 $1094503762_send = (val, stamp, struct) => {
// -1 means upsteam (floats for extra speed)

@@ -85,17 +99,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
}
$1094503762_serialize(hub, $1094503762_inProgress(hub, $2822145224.on), struct, val, hub.urlIndex)
}
$4125568599_serialize(hub, $4125568599_inProgress(hub, $932573643.on), struct, val, hub.urlIndex)
}
}
const $4125568599_inProgress = (hub, tick) => {
const $1094503762_inProgress = (hub, tick) => {
if (!hub.inProgress) {

@@ -105,5 +121,5 @@ hub.inProgress = []

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

@@ -115,3 +131,3 @@ })

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

@@ -123,17 +139,15 @@ t.inProgress = false

const $4125568599_$ALL$ = {
meta: $4125568599_meta,
send: $4125568599_send
var $1094503762_$ALL$ = {
meta: $1094503762_meta,
send: $1094503762_send
}
// FILE: websocket
const $3096720 = require('websocket')
// FILE: /Users/youzi/dev/hub.js/src/client/websocket/index.js
// import WebSocket from 'uws'
// export default WebSocket
;var $1971361117 = require('uws')
;
var $1704955210 = $1971361117
// need to get this fixed on now!
// import { w3cwebsocket } from 'websocket'
// export default w3cwebsocket
const $2878564687 = $3096720.w3cwebsocket
// FILE: /Users/youzi/dev/hub.js/src/subscription/serialize.js
const $2711378567_isEmpty = t => {
;const $3851780354_isEmpty = t => {
for (let i in t) { return false }

@@ -143,30 +157,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 $3851780354_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 = $3851780354_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)) {

@@ -186,20 +185,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 = $3851780354_parse(struct, obj[i], i, root)
if (parsed !== void 0) { result[i] = parsed }

@@ -210,24 +194,19 @@ }

// if result is empty ignore -- may not be a good idea
return $2711378567_isEmpty(result) ? void 0 : result
return $3851780354_isEmpty(result) ? void 0 : result
}
// can be one less fn...
const $2711378567 = $2711378567_parse
var $3851780354 = $3851780354_parse
// FILE: string-hash
const $1851648559 = require('string-hash')
// FILE: vigour-ua
const $1888714796 = require('vigour-ua')
// FILE: /Users/youzi/dev/hub.js/src/client/uid/index.js
;var $2180032073 = require('string-hash')
;var $3305006410 = require('vigour-ua')
;
const $1384736615_uniq = process.pid
var $1384736615 = () => $2180032073(`b-${Date.now()}-${(Math.random() * 10000) | 0}-${$1384736615_uniq}`)
const $1123050690_uniq = process.pid
const $1123050690 = () => $1851648559(`b-${Date.now()}-${(Math.random() * 10000) | 0}-${$1123050690_uniq}`)
;
// FILE: /Users/youzi/dev/hub.js/src/client/create.js
const $3376394415 = (t, val, stamp, useragent, id) => {
if (!id) id = t._uid_ || $1123050690()
$1888714796(useragent, val)
var $2828932010 = (t, val, stamp, useragent, id) => {
if (!id) id = t._uid_ || $1384736615()
$3305006410(useragent, val)
t.set({ clients: { [id]: val } }, stamp)

@@ -237,3 +216,3 @@ return t.clients[id]

// FILE: /Users/youzi/dev/hub.js/src/client/index.js
;

@@ -246,8 +225,6 @@

const $3357289264_connect = (hub, url, reconnect) => {
const socket = new $1704955210(url)
const client = hub.client || $2828932010(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)

@@ -258,9 +235,9 @@

const close = () => {
const stamp = $932573643.create()
const stamp = $2822145224.create()
hub.socket = false
hub.set({ connected: false }, stamp)
$932573643.close()
$2822145224.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($3357289264_connect, reconnect, hub, url, reconnect)
}

@@ -271,6 +248,2 @@ }

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

@@ -281,12 +254,15 @@ ? close

socket.onopen = () => {
const stamp = $932573643.create()
const stamp = $2822145224.create()
hub.socket = socket
$4125568599_meta(hub)
if (hub.emitters && hub.emitters.incoming) {
$3357289264_enableIncomingListener(socket, hub)
}
$1094503762_meta(hub)
hub.set({ connected: true }, stamp)
$932573643.close()
$2822145224.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) {

@@ -299,7 +275,7 @@ hub.receiveOnly = true

}
$932573643.close()
$2822145224.close()
}
}
const $48594293_removeUrl = hub => {
const $3357289264_removeUrl = hub => {
hub.url = hub._url_ = hub.urlIndex = null

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

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

@@ -317,19 +293,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 $3357289264_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)
$3357289264_removeUrl(hub)
$3357289264_removeSocket(hub)
}

@@ -340,3 +310,3 @@ }, 'url$')

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

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

if (!hub.url) {
$1213768903.create({
$1662971556.create({
on: {

@@ -361,3 +331,3 @@ data: {

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

@@ -369,3 +339,3 @@ hub._url_ = null

}
}, stamp, $1213768903.struct, hub, key)
}, stamp, $1662971556.struct, hub, key)
}

@@ -377,3 +347,3 @@ hub.url.set(val, stamp)

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

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

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

@@ -401,3 +371,3 @@ on: {

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

@@ -409,3 +379,3 @@ }

const $48594293_contextStruct = $1213768903.struct.create({
const $3357289264_contextStruct = $1662971556.struct.create({
props: {

@@ -425,3 +395,3 @@ default: {

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

@@ -435,3 +405,2 @@ for (let field in val) {

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

@@ -441,16 +410,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 $3357289264_context = (hub, val, key, stamp) => {
if ((!hub.context && val) || (hub.context && $3357289264_contextIsNotEqual(val, hub.context))) {
// console.log('⚽️ fire fire fire FLAME context ⚽️', val, stamp)
if (!hub.context) {
$1213768903.create(val, stamp, $48594293_contextStruct, hub, key)
$1662971556.create(val, stamp, $3357289264_contextStruct, hub, key)
} else {
$48594293_removeClients(hub, stamp)
$3357289264_removeClients(hub, stamp)
hub.context.set(val, stamp)
}
if (hub.connected && hub.connected.compute() === true) $4125568599_meta(hub)
if (hub.connected && hub.connected.compute() === true) $1094503762_meta(hub)
}
}
const $48594293_props = {
const $3357289264_props = {
reconnect: true,

@@ -461,90 +430,148 @@ socket: true,

receiveOnly: true,
url: $48594293_url,
context: $48594293_context,
connected: $48594293_connected
url: $3357289264_url,
context: $3357289264_context,
connected: $3357289264_connected
}
const $48594293_stub = () => {}
const $3357289264_stub = () => {}
const $48594293_define = {
subscribe (subs, cb, raw, tree) {
if (!raw) subs = $1213768903.parse(subs)
if (!this.receiveOnly) {
const parsed = $2711378567(this, subs)
const $3357289264_define = {
subscribe (subs, cb, raw, tree, forceUpstream) {
if (!raw) subs = $1662971556.parse(subs)
if (!this.receiveOnly || forceUpstream) {
const parsed = $3851780354(this, subs)
if (parsed) {
const key = $1851648559(JSON.stringify(parsed))
if (forceUpstream) {
parsed.__force__ = true
}
// why not keep it stringified? -- saves lots of speed
const key = $2180032073(JSON.stringify(parsed))
if (!this.upstreamSubscriptions) {
this.upstreamSubscriptions = { [key]: parsed }
if (this.url) $4125568599_meta(this)
this.upstreamSubscriptions = {}
this.upstreamSubscriptions[key] = parsed
if (this.url) $1094503762_meta(this)
} else if (!this.upstreamSubscriptions[key]) {
this.upstreamSubscriptions[key] = parsed
if (this.url) $4125568599_meta(this)
if (this.url) $1094503762_meta(this)
}
}
}
return $1213768903.subscribe(this, subs, cb || $48594293_stub, tree)
return $1662971556.subscribe(this, subs, cb || $3357289264_stub, tree)
}
}
const $48594293_on = { data: { send: $4125568599_send } }
const $3357289264_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 $3357289264_on = {
data: { send: $1094503762_send },
props: {
incoming: (t, val, key, stamp) => {
const hub = t._p
if (hub.socket) $3357289264_enableIncomingListener(hub.socket, hub)
return $1662971556.emitterProperty(t, val, key, stamp)
}
}
}
const $48594293_$ALL$ = {
props: $48594293_props,
on: $48594293_on,
define: $48594293_define
var $3357289264_$ALL$ = {
props: $3357289264_props,
on: $3357289264_on,
define: $3357289264_define
}
// FILE: uws
const $193432948 = require('uws')
// FILE: /Users/youzi/dev/hub.js/src/subscription/parse.js
const $3742651364_isFn = /^\$fn\|/
const $3742651364_dummy = () => false
// const client = (tree) => {
// while (tree) {
// if (tree._ && tree._.client) {
// return tree._.client
// }
// tree = tree._p
// }
// }
;var $2549126471 = {
props: {
contextKey: true,
getContext: (t, fn) => {
t.set({
define: {
getContext (key, socket) {
return fn(key, (key) => $2549126471_createContext(this, key), this, socket)
}
}
})
}
},
getContext: (key, context) => context()
}
// 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 $2549126471_createContext = (hub, val) => {
var result = $2549126471_find(hub, val)
if (!result) {
result = hub.create({ contextKey: val }, false)
}
return result
}
const $3742651364_parse = (obj, state, key) => {
const $2549126471_find = (hub, val) => {
const instances = hub.instances
if (instances) {
let i = instances.length
while (i--) {
if (instances[i].contextKey === val) return instances[i]
}
}
}
;const $2381345089_isFn = /^\$fn\|/
const $2381345089_dummy = () => false
function $2381345089_merge (a, b) {
for (let i in b) {
if ((!a[i] || typeof a[i] !== 'object')) {
a[i] = b[i]
} else {
$2381345089_merge(a[i], b[i])
}
}
}
// this will all be done with an ast later!
const $2381345089_replaceClient = /\.client[^a-z0-9]/g
// can also check for dangeorus stuff and maybe even allow some requires
// needs hashing algo
const $2381345089_clientContext = (val, client) => {
const matches = val.match($2381345089_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 $2381345089_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] = {} }
$2381345089_merge(root.clients[id], $2381345089_parse(obj.client, i, key, client, root))
} else if ($2381345089_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 ($2381345089_replaceClient.test(val)) { // eslint-disable-line
val = $2381345089_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

@@ -562,9 +589,14 @@ // 2 options for this ofcourse

state.emit('error', new Error(msg))
obj[i] = $3742651364_dummy
obj[i] = $2381345089_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) {
$2381345089_merge(result[i], obj[i])
} else if (typeof obj[i] !== 'object') {
result[i] = obj[i]
} else {
result[i] = $2381345089_parse(obj[i], state, i, client, root)
}
}

@@ -575,14 +607,13 @@ }

const $3742651364 = $3742651364_parse
var $2381345089 = $2381345089_parse
// FILE: /Users/youzi/dev/hub.js/src/server/cache.js
;
const $3904796091_cache = (client, struct, stamp) => {
const $2641472318_cache = (client, struct, stamp) => {
if (!client.cache) client.cache = {}
client.cache[$1213768903.puid(struct)] = stamp
client.cache[$1662971556.puid(struct)] = stamp
}
const $3904796091_isCached = (client, struct, stamp) => client.cache &&
client.cache[$1213768903.puid(struct)] === stamp
const $2641472318_isCached = (client, struct, stamp) => client.cache &&
client.cache[$1662971556.puid(struct)] === stamp

@@ -593,12 +624,11 @@ // const isCached = () => false

const $3904796091_$ALL$ = {
cache: $3904796091_cache,
isCached: $3904796091_isCached
var $2641472318_$ALL$ = {
cache: $2641472318_cache,
isCached: $2641472318_isCached
}
// FILE: /Users/youzi/dev/hub.js/src/server/send.js
;
const $1622386187_isEmpty = obj => {
const $727036942_isEmpty = obj => {
for (let i in obj) { //eslint-disable-line

@@ -610,11 +640,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 $727036942_progress = (client) => {
if (!client.inProgress) {
client.inProgress = {}
$932573643.on(() => {
$2822145224.on(() => {
if (client.val !== null) {
if (!$1622386187_isEmpty(client.inProgress)) {
if (!$727036942_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

@@ -630,3 +672,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)
}

@@ -640,7 +684,7 @@ client.inProgress = false

const $1622386187_send = (hub, client, struct, type, subs, tree) => {
const $727036942_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) {

@@ -653,3 +697,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, $1213768903.get(hub, 'serverIndex'), true)
$727036942_serialize(client, $727036942_progress(client), subs, prop, $1662971556.get(hub, 'serverIndex'), true)
}

@@ -661,11 +705,11 @@ prop = previous

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

@@ -686,3 +730,3 @@ const path = struct.path()

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

@@ -692,20 +736,20 @@ s.val = val

if (subs.type) {
const type = $1213768903.get(struct, 'type') // make getType (fast)
if ($1213768903.getVal(type) !== 'hub') {
$1622386187_serialize(client, t, subs.type, type, level)
const type = $1662971556.get(struct, 'type') // make getType (fast)
if ($1662971556.getVal(type) !== 'hub') {
$727036942_serialize(client, t, subs.type, type, level)
}
}
$3904796091_cache(client, struct, stamp)
$2641472318_cache(client, struct, stamp)
s.stamp = stamp
if (struct.key === 'type') {
if (val === 'hub') return
$1622386187_serialize(client, t, subs, $1213768903.getType(struct.parent(2), val), level)
$727036942_serialize(client, t, subs, $1662971556.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)
$727036942_serialize(client, t, subs, val, level)
} else if (val !== void 0) {

@@ -717,18 +761,18 @@ s.val = val

// can send a bit too much data when val: true and overlapping keys
$1622386187_serialize(client, t, subs, val, level)
$727036942_serialize(client, t, subs, val, level)
}
if (subs.val === true && !isRemoved) {
$1622386187_deepSerialize($1213768903.getKeys(struct), client, t, subs, struct, level)
$727036942_deepSerialize($1662971556.getKeys(struct), client, t, subs, struct, level)
}
}
const $1622386187_deepSerialize = (keys, client, t, subs, struct, level) => {
const $727036942_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)
$727036942_serialize(client, t, subs, struct.get('type'), level)
}
if (keys) {
for (let i = 0, len = keys.length; i < len; i++) {
let prop = $1213768903.get(struct, keys[i])
if (prop && prop.isHub) $1622386187_serialize(client, t, subs, prop, level)
let prop = $1662971556.get(struct, keys[i])
if (prop && prop.isHub) $727036942_serialize(client, t, subs, prop, level)
}

@@ -739,3 +783,3 @@ }

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

@@ -745,6 +789,5 @@ }

const $1622386187 = $1622386187_send
var $727036942 = $727036942_send
// FILE: /Users/youzi/dev/hub.js/src/server/remove.js
const $2931540049_removeSubscriptions = (t, id) => {
;const $1380346132_removeSubscriptions = (t, id) => {
if (t.subscriptions) {

@@ -760,3 +803,3 @@ let i = t.subscriptions.length

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

@@ -769,3 +812,3 @@ client.val = null

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

@@ -779,7 +822,7 @@ // if (client.context && t.clients.keys().length === (t.url ? 1 : 0)) {

const $2931540049_$ALL$ = {
removeSubscriptions: $2931540049_removeSubscriptions,
removeClient: $2931540049_removeClient
var $1380346132_$ALL$ = {
removeSubscriptions: $1380346132_removeSubscriptions,
removeClient: $1380346132_removeClient
}
// FILE: /Users/youzi/dev/hub.js/src/server/incoming.js
;

@@ -792,4 +835,3 @@

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

@@ -804,19 +846,18 @@ const meta = data[1]

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

@@ -827,3 +868,3 @@ for (let key in payload) {

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

@@ -833,3 +874,3 @@ }

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

@@ -839,21 +880,21 @@ }

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

@@ -864,3 +905,4 @@ if (!t.inherits && t.then) {

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

@@ -871,15 +913,16 @@ console.log('client discconected when logging in')

} else {
$1353865041_set(meta, socket, t, payload)
if (client) $1380346132_removeClient(client)
$834150420_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 $834150420_incomingSubscriptions = (hub, client, meta, id) => {
const update = (t, type, subs, tree) => $727036942(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 = $2381345089(meta.subscriptions[key], hub, void 0, client)
client.upstreamSubscriptions[uid] = subs
$1213768903.subscribe(hub, subs, update)
$1662971556.subscribe(hub, subs, update)
hub.subscriptions[hub.subscriptions.length - 1]._uid_ = id

@@ -890,7 +933,6 @@ }

// FILE: /Users/youzi/dev/hub.js/src/server/on.js
;
var $2138030230_removedInProgress
const $2138030230_on = {
var $4215278899_removedInProgress
const $4215278899_on = {
data: {

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

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

@@ -932,5 +974,5 @@ target._removed.push(struct)

const $2138030230 = $2138030230_on
var $4215278899 = $4215278899_on
// FILE: /Users/youzi/dev/hub.js/src/server/index.js
;

@@ -941,7 +983,6 @@

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

@@ -954,7 +995,7 @@

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

@@ -965,11 +1006,12 @@

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

@@ -982,3 +1024,3 @@

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

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

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

@@ -998,3 +1040,3 @@ }

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

@@ -1005,8 +1047,8 @@ hub.serverIndex = null

const $3248609833_port = (hub, val, key, stamp) => {
const $899748844_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)
$899748844_removeServer(hub)
$899748844_removePort(hub)
}

@@ -1017,10 +1059,10 @@ }, 'port$')

if (hub._server_) {
$3248609833_removeServer(hub)
$899748844_removeServer(hub)
}
if (!val) {
if (hub.port) hub.port.set(null, stamp)
$3248609833_removePort(hub)
$899748844_removePort(hub)
} else {
if (!hub.port) {
$1213768903.create({
$1662971556.create({
on: {

@@ -1035,3 +1077,3 @@ data: {

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

@@ -1041,3 +1083,3 @@ }

}
}, stamp, $1213768903.struct, hub, key)
}, stamp, $1662971556.struct, hub, key)
}

@@ -1049,58 +1091,19 @@ hub.port.set(val, stamp)

const $3248609833_props = {
const $899748844_props = {
_server_: true,
serverIndex: true,
port: $3248609833_port
port: $899748844_port
}
var $899748844 = { props: $899748844_props, on: $4215278899 }
const $3248609833_$ALL$ = {
props: $3248609833_props,
on: $2138030230
}
// FILE: /Users/youzi/dev/hub.js/src/context.js
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()
}
;
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]
}
}
}
// FILE: /Users/youzi/dev/hub.js/src/hub.js
const $4043401927_types = $1662971556.struct.props.types
const $302300578_types = $1213768903.struct.props.types
const $302300578_hub = $1213768903.create({
const $4043401927_hub = $1662971556.create({
type: 'hub',

@@ -1112,12 +1115,4 @@ instances: false,

_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 = $1213768903.create(val, stamp, $302300578_clients, t, key)
} else {
$1213768903.set(t.clients, val, stamp)
}
},
types: $302300578_types.bind(), // to not interfere with struct type
type: $1213768903.struct.props.type.bind(),
types: $4043401927_types.bind(), // to not interfere with struct type
type: $1662971556.struct.props.type.bind(),
client: true

@@ -1127,35 +1122,53 @@ }

$302300578_hub.props.types.struct = $302300578_hub.create({
props: { default: $302300578_types.struct.props.default.bind() }
$4043401927_hub.props.types.struct = $4043401927_hub.create({
props: { default: $4043401927_types.struct.props.default.bind() }
}, false)
$302300578_hub.props.types.struct.props.default.struct = $302300578_hub.props.type.struct = $302300578_hub
$4043401927_hub.props.types.struct.props.default.struct = $4043401927_hub.props.type.struct = $4043401927_hub
$302300578_hub.set({ types: { hub: 'self' }, inject: [ $3248609833_$ALL$, $48594293_$ALL$, $25049122 ] }, false)
$302300578_hub.types._ks = void 0
const $302300578_clients = $1213768903.create({
props: {
default: $302300578_hub.create({
$4043401927_hub.set({
types: {
hub: 'self',
clients: {
type: 'struct',
instances: false,
props: {
cache: true,
upstreamSubscriptions: true,
resolve: true,
socket: true,
context: true
default: $4043401927_hub.create({
instances: false,
props: {
cache: true,
upstreamSubscriptions: true,
resolve: true,
socket: true,
context: true
}
}, false)
}
}, false)
}
}
},
props: {
// why nto call this client id -- thats what it is
clients: (t, val, key, stamp) => {
if (!t.clients) {
const clients = $1662971556.getType(t, key)
console.log('CLIENTS TYPE:', clients)
t.clients = $1662971556.create(val, stamp, clients, t, key)
} else {
$1662971556.set(t.clients, val, stamp)
}
}
},
inject: [ $899748844, $3357289264_$ALL$, $2549126471 ]
}, false)
const $302300578 = $302300578_hub
$4043401927_hub.types._ks = void 0
// FILE: /Users/youzi/dev/hub.js/src/index.js
var $4043401927 = $4043401927_hub
;
if (typeof __filename !== 'undefined') console.log('hub.js:', __filename)
const $621652771_fn = (val, stamp) => $302300578.create(val, stamp)
const $621652771 = $621652771_fn
const $3474573222_fn = (val, stamp) => $4043401927.create(val, stamp)
var $3474573222 = $3474573222_fn

@@ -1165,2 +1178,2 @@ // add uids to stamps else it sucks -- dont compromise for tests think of that as an after thought

module.exports = $621652771
module.exports = $3474573222
{
"name": "hub.js",
"description": "Seamless realtime communcation",
"version": "0.0.11-907b71c23cfe12c87eda9584e8e9705300a123d5",
"version": "0.0.11-988eecf1d7cfbc9c5e1eb98e07e72737306a6eab",
"main": "dist/index.js",

@@ -14,4 +14,8 @@ "browser": {

"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')",

@@ -24,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": {

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

"brisky-stamp": "^4.0.0",
"brisky-struct": "feature-builder-boy",
"brisky-struct": "^1.3.1",
"string-hash": "^1.1.0",
"uws": "0.12.0",
"vigour-ua": "^3.0.0",
"websocket": "^1.0.24"
"uws": "0.13.0",
"vigour-ua": "^3.0.0"
},

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

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

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

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

@@ -69,0 +70,0 @@ "tape": "4.6.0"

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