├── .gitignore ├── README.md ├── dist ├── bundle.js └── index.html ├── lib └── nts.js ├── package-lock.json ├── package.json ├── server ├── game │ ├── clock.js │ ├── expire.js │ └── index.js ├── gun.js ├── server.js └── waitroom │ ├── confirm.js │ ├── index.js │ └── next.js ├── shared ├── options.js └── sync.js ├── web ├── canvas.js ├── claim.js ├── clock.js ├── collision.js ├── find.js ├── index.js ├── input.js ├── invincibility.js ├── join.js ├── kick.js ├── line.js ├── local.js ├── path.js ├── position.js ├── render.js ├── sort.js └── turn.js └── webpack.config.js /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | data.json 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Trace 2 | 3 | A simple game meant to showcase [gunDB](http://gun.js.org/) in a real-time app. 4 | 5 | ## Trying it out 6 | 7 | > **Note:** this isn't actively maintained, but it still runs! You can play it live [over here](http://tracegame.herokuapp.com/). 8 | 9 | In your terminal, run: 10 | 11 | 1. `git clone https://github.com/PsychoLlama/Trace.git` 12 | 2. `cd Trace` 13 | 3. `npm install` 14 | 4. `npm start` 15 | 16 | Now the game should be available at `http://localhost:8080`. 17 | -------------------------------------------------------------------------------- /dist/bundle.js: -------------------------------------------------------------------------------- 1 | /******/ (function(modules) { // webpackBootstrap 2 | /******/ // The module cache 3 | /******/ var installedModules = {}; 4 | 5 | /******/ // The require function 6 | /******/ function __webpack_require__(moduleId) { 7 | 8 | /******/ // Check if module is in cache 9 | /******/ if(installedModules[moduleId]) 10 | /******/ return installedModules[moduleId].exports; 11 | 12 | /******/ // Create a new module (and put it into the cache) 13 | /******/ var module = installedModules[moduleId] = { 14 | /******/ exports: {}, 15 | /******/ id: moduleId, 16 | /******/ loaded: false 17 | /******/ }; 18 | 19 | /******/ // Execute the module function 20 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 21 | 22 | /******/ // Flag the module as loaded 23 | /******/ module.loaded = true; 24 | 25 | /******/ // Return the exports of the module 26 | /******/ return module.exports; 27 | /******/ } 28 | 29 | 30 | /******/ // expose the modules object (__webpack_modules__) 31 | /******/ __webpack_require__.m = modules; 32 | 33 | /******/ // expose the module cache 34 | /******/ __webpack_require__.c = installedModules; 35 | 36 | /******/ // __webpack_public_path__ 37 | /******/ __webpack_require__.p = ""; 38 | 39 | /******/ // Load entry module and return exports 40 | /******/ return __webpack_require__(0); 41 | /******/ }) 42 | /************************************************************************/ 43 | /******/ ([ 44 | /* 0 */ 45 | /***/ function(module, exports, __webpack_require__) { 46 | 47 | /*jslint node: true*/ 48 | 'use strict'; 49 | localStorage.clear(); 50 | 51 | var join = __webpack_require__(1); 52 | var render = __webpack_require__(10); 53 | var collision = __webpack_require__(14); 54 | //var time = require('./clock'); 55 | 56 | // join the waitroom 57 | //time(join); 58 | join(); 59 | 60 | // initialize keyboard listeners 61 | __webpack_require__(17); 62 | 63 | // main rendering/collision detection loop 64 | window.requestAnimationFrame(function loop() { 65 | render(); 66 | collision(); 67 | window.requestAnimationFrame(loop); 68 | }); 69 | 70 | 71 | /***/ }, 72 | /* 1 */ 73 | /***/ function(module, exports, __webpack_require__) { 74 | 75 | /*jslint node: true*/ 76 | 'use strict'; 77 | var Gun = __webpack_require__(2); 78 | var local = __webpack_require__(3); 79 | var claim = __webpack_require__(5); 80 | var kick = __webpack_require__(9); 81 | var waiting = local.gun.get('waitlist'); 82 | var chosen = local.gun.get('chosen'); 83 | var token; 84 | 85 | function leave() { 86 | kick(local.player, true); 87 | } 88 | chosen.map(function (serving, player) { 89 | 90 | if (serving === token) { 91 | // accept the invite 92 | chosen.path(player).put(null); 93 | 94 | // take the position in the game 95 | claim(player); 96 | 97 | // no support in firefox :( 98 | window.addEventListener('beforeunload', leave); 99 | 100 | // uncomment for production 101 | // window.addEventListener('blur', leave); 102 | } 103 | }); 104 | 105 | module.exports = function () { 106 | token = Gun.text.random(); 107 | return waiting.path(token).put(token); 108 | }; 109 | 110 | 111 | /***/ }, 112 | /* 2 */ 113 | /***/ function(module, exports) { 114 | 115 | ;(function(){ 116 | 117 | function Gun(o){ 118 | var gun = this; 119 | if(!Gun.is(gun)){ return new Gun(o) } 120 | if(Gun.is(o)){ return gun } 121 | return gun.opt(o); 122 | } 123 | 124 | ;(function(Util){ // Generic javascript utilities. 125 | ;(function(Type){ 126 | Type.fns = {is: function(fn){ return (fn instanceof Function)? true : false }}; 127 | Type.bi = {is: function(b){ return (b instanceof Boolean || typeof b == 'boolean')? true : false }} 128 | Type.num = {is: function(n){ return !Type.list.is(n) && (Infinity === n || n - parseFloat(n) + 1 >= 0) }} 129 | Type.text = {is: function(t){ return typeof t == 'string'? true : false }} 130 | Type.text.ify = function(t){ 131 | if(Type.text.is(t)){ return t } 132 | if(typeof JSON !== "undefined"){ return JSON.stringify(t) } 133 | return (t && t.toString)? t.toString() : t; 134 | } 135 | Type.text.random = function(l, c){ 136 | var s = ''; 137 | l = l || 24; // you are not going to make a 0 length random number, so no need to check type 138 | c = c || '0123456789ABCDEFGHIJKLMNOPQRSTUVWXZabcdefghijklmnopqrstuvwxyz'; 139 | while(l > 0){ s += c.charAt(Math.floor(Math.random() * c.length)); l-- } 140 | return s; 141 | } 142 | Type.text.match = function(t, o){ var r = false; 143 | t = t || ''; 144 | o = Gun.text.is(o)? {'=': o} : o || {}; // {'~', '=', '*', '<', '>', '+', '-', '?', '!'} // ignore uppercase, exactly equal, anything after, lexically larger, lexically lesser, added in, subtacted from, questionable fuzzy match, and ends with. 145 | if(Type.obj.has(o,'~')){ t = t.toLowerCase() } 146 | if(Type.obj.has(o,'=')){ return t === o['='] } 147 | if(Type.obj.has(o,'*')){ if(t.slice(0, o['*'].length) === o['*']){ r = true; t = t.slice(o['*'].length) } else { return false }} 148 | if(Type.obj.has(o,'!')){ if(t.slice(-o['!'].length) === o['!']){ r = true } else { return false }} 149 | if(Type.obj.has(o,'+')){ 150 | if(Type.list.map(Type.list.is(o['+'])? o['+'] : [o['+']], function(m){ 151 | if(t.indexOf(m) >= 0){ r = true } else { return true } 152 | })){ return false } 153 | } 154 | if(Type.obj.has(o,'-')){ 155 | if(Type.list.map(Type.list.is(o['-'])? o['-'] : [o['-']], function(m){ 156 | if(t.indexOf(m) < 0){ r = true } else { return true } 157 | })){ return false } 158 | } 159 | if(Type.obj.has(o,'>')){ if(t > o['>']){ r = true } else { return false }} 160 | if(Type.obj.has(o,'<')){ if(t < o['<']){ r = true } else { return false }} 161 | function fuzzy(t,f){ var n = -1, i = 0, c; for(;c = f[i++];){ if(!~(n = t.indexOf(c, n+1))){ return false }} return true } // via http://stackoverflow.com/questions/9206013/javascript-fuzzy-search 162 | if(Type.obj.has(o,'?')){ if(fuzzy(t, o['?'])){ r = true } else { return false }} // change name! 163 | return r; 164 | } 165 | Type.list = {is: function(l){ return (l instanceof Array)? true : false }} 166 | Type.list.slit = Array.prototype.slice; 167 | Type.list.sort = function(k){ // creates a new sort function based off some field 168 | return function(A,B){ 169 | if(!A || !B){ return 0 } A = A[k]; B = B[k]; 170 | if(A < B){ return -1 }else if(A > B){ return 1 } 171 | else { return 0 } 172 | } 173 | } 174 | Type.list.map = function(l, c, _){ return Type.obj.map(l, c, _) } 175 | Type.list.index = 1; // change this to 0 if you want non-logical, non-mathematical, non-matrix, non-convenient array notation 176 | Type.obj = {is: function(o) { return !o || !o.constructor? false : o.constructor === Object? true : !o.constructor.call || o.constructor.toString().match(/\[native\ code\]/)? false : true }} 177 | Type.obj.put = function(o, f, v){ return (o||{})[f] = v, o } 178 | Type.obj.del = function(o, k){ 179 | if(!o){ return } 180 | o[k] = null; 181 | delete o[k]; 182 | return true; 183 | } 184 | Type.obj.ify = function(o){ 185 | if(Type.obj.is(o)){ return o } 186 | try{o = JSON.parse(o); 187 | }catch(e){o={}}; 188 | return o; 189 | } 190 | Type.obj.copy = function(o){ // because http://web.archive.org/web/20140328224025/http://jsperf.com/cloning-an-object/2 191 | return !o? o : JSON.parse(JSON.stringify(o)); // is shockingly faster than anything else, and our data has to be a subset of JSON anyways! 192 | } 193 | Type.obj.as = function(b, f, d){ return b[f] = b[f] || (arguments.length >= 3? d : {}) } 194 | Type.obj.has = function(o, t){ return o && Object.prototype.hasOwnProperty.call(o, t) } 195 | Type.obj.empty = function(o, n){ 196 | if(!o){ return true } 197 | return Type.obj.map(o,function(v,i){ 198 | if(n && (i === n || (Type.obj.is(n) && Type.obj.has(n, i)))){ return } 199 | if(i){ return true } 200 | })? false : true; 201 | } 202 | Type.obj.map = function(l, c, _){ 203 | var u, i = 0, ii = 0, x, r, rr, ll, lle, f = Type.fns.is(c), 204 | t = function(k,v){ 205 | if(2 === arguments.length){ 206 | rr = rr || {}; 207 | rr[k] = v; 208 | return; 209 | } rr = rr || []; 210 | rr.push(k); 211 | }; 212 | if(Object.keys && Type.obj.is(l)){ 213 | ll = Object.keys(l); lle = true; 214 | } 215 | if(Type.list.is(l) || ll){ 216 | x = (ll || l).length; 217 | for(;i < x; i++){ 218 | ii = (i + Type.list.index); 219 | if(f){ 220 | r = lle? c.call(_ || this, l[ll[i]], ll[i], t) : c.call(_ || this, l[i], ii, t); 221 | if(r !== u){ return r } 222 | } else { 223 | //if(Type.test.is(c,l[i])){ return ii } // should implement deep equality testing! 224 | if(c === l[lle? ll[i] : i]){ return ll? ll[i] : ii } // use this for now 225 | } 226 | } 227 | } else { 228 | for(i in l){ 229 | if(f){ 230 | if(Type.obj.has(l,i)){ 231 | r = _? c.call(_, l[i], i, t) : c(l[i], i, t); 232 | if(r !== u){ return r } 233 | } 234 | } else { 235 | //if(a.test.is(c,l[i])){ return i } // should implement deep equality testing! 236 | if(c === l[i]){ return i } // use this for now 237 | } 238 | } 239 | } 240 | return f? rr : Type.list.index? 0 : -1; 241 | } 242 | Type.time = {}; 243 | Type.time.is = function(t){ return t? t instanceof Date : (+new Date().getTime()) } 244 | Type.time.now = function(t){ 245 | return ((t=t||Type.time.is()) > (Type.time.now.last || -Infinity)? (Type.time.now.last = t) : Type.time.now(t + 1)) + (Type.time.now.drift || 0); // TODO: BUG? Should this go on the inside? 246 | }; 247 | }(Util)); 248 | ;(function(exports){ // On event emitter generic javascript utility. 249 | function On(){}; 250 | On.create = function(){ 251 | var on = function(e){ 252 | on.event.e = e; 253 | on.event.s[e] = on.event.s[e] || []; 254 | return on; 255 | }; 256 | on.emit = function(a){ 257 | var e = on.event.e, s = on.event.s[e], args = arguments, l = args.length; 258 | exports.list.map(s, function(hear, i){ 259 | if(!hear.fn){ s.splice(i-1, 0); return; } 260 | if(1 === l){ hear.fn(a); return; } 261 | hear.fn.apply(hear, args); 262 | }); 263 | if(!s.length){ delete on.event.s[e] } 264 | } 265 | on.event = function(fn, i){ 266 | var s = on.event.s[on.event.e]; if(!s){ return } 267 | var e = {fn: fn, i: i || 0, off: function(){ return !(e.fn = false) }}; 268 | return s.push(e), i? s.sort(sort) : i, e; 269 | } 270 | on.event.s = {}; 271 | return on; 272 | } 273 | var sort = exports.list.sort('i'); 274 | exports.on = On.create(); 275 | exports.on.create = On.create; 276 | }(Util)); 277 | ;(function(exports){ // Generic javascript scheduler utility. 278 | var schedule = function(state, cb){ // maybe use lru-cache? 279 | schedule.waiting.push({when: state, event: cb || function(){}}); 280 | if(schedule.soonest < state){ return } 281 | schedule.set(state); 282 | } 283 | schedule.waiting = []; 284 | schedule.soonest = Infinity; 285 | schedule.sort = exports.list.sort('when'); 286 | schedule.set = function(future){ 287 | if(Infinity <= (schedule.soonest = future)){ return } 288 | var now = exports.time.now(); // WAS time.is() TODO: Hmmm, this would make it hard for every gun instance to have their own version of time. 289 | future = (future <= now)? 0 : (future - now); 290 | clearTimeout(schedule.id); 291 | schedule.id = setTimeout(schedule.check, future); 292 | } 293 | schedule.check = function(){ 294 | var now = exports.time.now(), soonest = Infinity; // WAS time.is() TODO: Same as above about time. Hmmm. 295 | schedule.waiting.sort(schedule.sort); 296 | schedule.waiting = exports.list.map(schedule.waiting, function(wait, i, map){ 297 | if(!wait){ return } 298 | if(wait.when <= now){ 299 | if(exports.fns.is(wait.event)){ 300 | setTimeout(function(){ wait.event() },0); 301 | } 302 | } else { 303 | soonest = (soonest < wait.when)? soonest : wait.when; 304 | map(wait); 305 | } 306 | }) || []; 307 | schedule.set(soonest); 308 | } 309 | exports.schedule = schedule; 310 | }(Util)); 311 | }(Gun)); 312 | 313 | ;(function(Gun){ // Gun specific utilities. 314 | 315 | Gun.version = 0.3; 316 | 317 | Gun._ = { // some reserved key words, these are not the only ones. 318 | meta: '_' // all metadata of the node is stored in the meta property on the node. 319 | ,soul: '#' // a soul is a UUID of a node but it always points to the "latest" data known. 320 | ,field: '.' // a field is a property on a node which points to a value. 321 | ,state: '>' // other than the soul, we store HAM metadata. 322 | ,'#':'soul' 323 | ,'.':'field' 324 | ,'=':'value' 325 | ,'>':'state' 326 | } 327 | 328 | Gun.is = function(gun){ return (gun instanceof Gun)? true : false } // check to see if it is a GUN instance. 329 | 330 | Gun.is.val = function(v){ // Valid values are a subset of JSON: null, binary, number (!Infinity), text, or a soul relation. Arrays need special algorithms to handle concurrency, so they are not supported directly. Use an extension that supports them if needed but research their problems first. 331 | if(v === null){ return true } // "deletes", nulling out fields. 332 | if(v === Infinity){ return false } // we want this to be, but JSON does not support it, sad face. 333 | if(Gun.bi.is(v) // by "binary" we mean boolean. 334 | || Gun.num.is(v) 335 | || Gun.text.is(v)){ // by "text" we mean strings. 336 | return true; // simple values are valid. 337 | } 338 | return Gun.is.rel(v) || false; // is the value a soul relation? Then it is valid and return it. If not, everything else remaining is an invalid data type. Custom extensions can be built on top of these primitives to support other types. 339 | } 340 | 341 | Gun.is.rel = function(v){ // this defines whether an object is a soul relation or not, they look like this: {'#': 'UUID'} 342 | if(Gun.obj.is(v)){ // must be an object. 343 | var id; 344 | Gun.obj.map(v, function(s, f){ // map over the object... 345 | if(id){ return id = false } // if ID is already defined AND we're still looping through the object, it is considered invalid. 346 | if(f == Gun._.soul && Gun.text.is(s)){ // the field should be '#' and have a text value. 347 | id = s; // we found the soul! 348 | } else { 349 | return id = false; // if there exists anything else on the object that isn't the soul, then it is considered invalid. 350 | } 351 | }); 352 | if(id){ // a valid id was found. 353 | return id; // yay! Return it. 354 | } 355 | } 356 | return false; // the value was not a valid soul relation. 357 | } 358 | 359 | Gun.is.rel.ify = function(s){ var r = {}; return Gun.obj.put(r, Gun._.soul, s), r } // convert a soul into a relation and return it. 360 | 361 | Gun.is.lex = function(l){ var r = true; 362 | if(!Gun.obj.is(l)){ return false } 363 | Gun.obj.map(l, function(v,f){ 364 | if(!Gun.obj.has(Gun._,f) || !(Gun.text.is(v) || Gun.obj.is(v))){ return r = false } 365 | }); // TODO: What if the lex cursor has a document on the match, that shouldn't be allowed! 366 | return r; 367 | } 368 | 369 | Gun.is.node = function(n, cb, t){ var s; // checks to see if an object is a valid node. 370 | if(!Gun.obj.is(n)){ return false } // must be an object. 371 | if(s = Gun.is.node.soul(n)){ // must have a soul on it. 372 | return !Gun.obj.map(n, function(v, f){ // we invert this because the way we check for this is via a negation. 373 | if(f == Gun._.meta){ return } // skip over the metadata. 374 | if(!Gun.is.val(v)){ return true } // it is true that this is an invalid node. 375 | if(cb){ cb.call(t, v, f, n) } // optionally callback each field/value. 376 | }); 377 | } 378 | return false; // nope! This was not a valid node. 379 | } 380 | 381 | Gun.is.node.ify = function(n, s, o){ // convert a shallow object into a node. 382 | o = Gun.bi.is(o)? {force: o} : o || {}; // detect options. 383 | n = Gun.is.node.soul.ify(n, s, o.force); // put a soul on it. 384 | Gun.obj.map(n, function(v, f){ // iterate over each field/value. 385 | if(Gun._.meta === f){ return } // ignore meta. 386 | Gun.is.node.state.ify([n], f, v, o.state = o.state || Gun.time.now()); // and set the state for this field and value on this node. 387 | }); 388 | return n; // This will only be a valid node if the object wasn't already deep! 389 | } 390 | 391 | Gun.is.node.soul = function(n, s){ return (n && n._ && n._[s || Gun._.soul]) || false } // convenience function to check to see if there is a soul on a node and return it. 392 | 393 | Gun.is.node.soul.ify = function(n, s, o){ // put a soul on an object. 394 | n = n || {}; // make sure it exists. 395 | n._ = n._ || {}; // make sure meta exists. 396 | n._[Gun._.soul] = o? s : n._[Gun._.soul] || s || Gun.text.random(); // if it already has a soul then use that instead - unless you force the soul you want with an option. 397 | return n; 398 | } 399 | 400 | Gun.is.node.state = function(n, f){ return (f && n && n._ && n._[Gun._.state] && Gun.num.is(n._[Gun._.state][f]))? n._[Gun._.state][f] : false } // convenience function to get the state on a field on a node and return it. 401 | 402 | Gun.is.node.state.ify = function(l, f, v, state){ // put a field's state and value on some nodes. 403 | l = Gun.list.is(l)? l : [l]; // handle a list of nodes or just one node. 404 | var l = l.reverse(), d = l[0]; // we might want to inherit the state from the last node in the list. 405 | Gun.list.map(l, function(n, i){ // iterate over each node. 406 | n = n || {}; // make sure it exists. 407 | if(Gun.is.val(v)){ n[f] = v } // if we have a value, then put it. 408 | n._ = n._ || {}; // make sure meta exists. 409 | n = n._[Gun._.state] = n._[Gun._.state] || {}; // make sure HAM state exists. 410 | if(i = d._[Gun._.state][f]){ n[f] = i } // inherit the state! 411 | if(Gun.num.is(state)){ n[f] = state } // or manually set the state. 412 | }); 413 | } 414 | 415 | Gun.is.graph = function(g, cb, fn, t){ // checks to see if an object is a valid graph. 416 | var exist = false; 417 | if(!Gun.obj.is(g)){ return false } // must be an object. 418 | return !Gun.obj.map(g, function(n, s){ // we invert this because the way we check for this is via a negation. 419 | if(!n || s !== Gun.is.node.soul(n) || !Gun.is.node(n, fn)){ return true } // it is true that this is an invalid graph. 420 | (cb || function(){}).call(t, n, s, function(fn){ // optional callback for each node. 421 | if(fn){ Gun.is.node(n, fn, t) } // where we then have an optional callback for each field/value. 422 | }); 423 | exist = true; 424 | }) && exist; // makes sure it wasn't an empty object. 425 | } 426 | 427 | Gun.is.graph.ify = function(n){ var s; // wrap a node into a graph. 428 | if(s = Gun.is.node.soul(n)){ // grab the soul from the node, if it is a node. 429 | return Gun.obj.put({}, s, n); // then create and return a graph which has a node on the matching soul property. 430 | } 431 | } 432 | 433 | 434 | Gun.HAM = function(machineState, incomingState, currentState, incomingValue, currentValue){ // TODO: Lester's comments on roll backs could be vulnerable to divergence, investigate! 435 | if(machineState < incomingState){ 436 | // the incoming value is outside the boundary of the machine's state, it must be reprocessed in another state. 437 | return {defer: true}; 438 | } 439 | if(incomingState < currentState){ 440 | // the incoming value is within the boundary of the machine's state, but not within the range. 441 | return {historical: true}; 442 | } 443 | if(currentState < incomingState){ 444 | // the incoming value is within both the boundary and the range of the machine's state. 445 | return {converge: true, incoming: true}; 446 | } 447 | if(incomingState === currentState){ 448 | if(incomingValue === currentValue){ // Note: while these are practically the same, the deltas could be technically different 449 | return {state: true}; 450 | } 451 | /* 452 | The following is a naive implementation, but will always work. 453 | Never change it unless you have specific needs that absolutely require it. 454 | If changed, your data will diverge unless you guarantee every peer's algorithm has also been changed to be the same. 455 | As a result, it is highly discouraged to modify despite the fact that it is naive, 456 | because convergence (data integrity) is generally more important. 457 | Any difference in this algorithm must be given a new and different name. 458 | */ 459 | if(String(incomingValue) < String(currentValue)){ // String only works on primitive values! 460 | return {converge: true, current: true}; 461 | } 462 | if(String(currentValue) < String(incomingValue)){ // String only works on primitive values! 463 | return {converge: true, incoming: true}; 464 | } 465 | } 466 | return {err: "you have not properly handled recursion through your data or filtered it as JSON"}; 467 | } 468 | 469 | Gun.union = function(gun, prime, cb, opt){ // merge two graphs into the first. 470 | var opt = opt || Gun.obj.is(cb)? cb : {}; 471 | var ctx = {graph: gun.__.graph, count: 0}; 472 | ctx.cb = function(){ 473 | cb = Gun.fns.is(cb)? cb() && null : null; 474 | } 475 | if(!ctx.graph){ ctx.err = {err: Gun.log("No graph!") } } 476 | if(!prime){ ctx.err = {err: Gun.log("No data to merge!") } } 477 | if(ctx.soul = Gun.is.node.soul(prime)){ prime = Gun.is.graph.ify(prime) } 478 | if(!Gun.is.graph(prime, null, function(val, field, node){ var meta; 479 | if(!Gun.num.is(Gun.is.node.state(node, field))){ 480 | return ctx.err = {err: Gun.log("No state on '" + field + "'!") } 481 | } 482 | }) || ctx.err){ return ctx.err = ctx.err || {err: Gun.log("Invalid graph!", prime)}, ctx } 483 | function emit(at){ 484 | Gun.on('operating').emit(gun, at); 485 | } 486 | (function union(graph, prime){ 487 | var prime = Gun.obj.map(prime, function(n,s,t){t(n)}).sort(function(A,B){ 488 | var s = Gun.is.node.soul(A); 489 | if(graph[s]){ return 1 } 490 | return 0; 491 | }); 492 | ctx.count += 1; 493 | ctx.err = Gun.list.map(prime, function(node, soul){ 494 | soul = Gun.is.node.soul(node); 495 | if(!soul){ return {err: Gun.log("Soul missing or mismatching!")} } 496 | ctx.count += 1; 497 | var vertex = graph[soul]; 498 | if(!vertex){ graph[soul] = vertex = Gun.is.node.ify({}, soul) } 499 | Gun.union.HAM(vertex, node, function(vertex, field, val, state){ 500 | Gun.on('historical').emit(gun, {soul: soul, field: field, value: val, state: state, change: node}); 501 | gun.__.on('historical').emit({soul: soul, field: field, change: node}); 502 | }, function(vertex, field, val, state){ 503 | if(!vertex){ return } 504 | var change = Gun.is.node.soul.ify({}, soul); 505 | if(field){ 506 | Gun.is.node.state.ify([vertex, change, node], field, val); 507 | } 508 | emit({soul: soul, field: field, value: val, state: state, change: change}); 509 | }, function(vertex, field, val){})(function(){ 510 | emit({soul: soul, change: node}); 511 | if(opt.soul){ opt.soul(soul) } 512 | if(!(ctx.count -= 1)){ ctx.cb() } 513 | }); // TODO: BUG? Handle error! 514 | }); 515 | ctx.count -= 1; 516 | })(ctx.graph, prime); 517 | if(!ctx.count){ ctx.cb() } 518 | return ctx; 519 | } 520 | 521 | Gun.union.ify = function(gun, prime, cb, opt){ 522 | if(gun){ gun = (gun.__ && gun.__.graph)? gun.__.graph : gun } 523 | if(Gun.text.is(prime)){ 524 | if(gun && gun[prime]){ 525 | prime = gun[prime]; 526 | } else { 527 | return Gun.is.node.ify({}, prime); 528 | } 529 | } 530 | var vertex = Gun.is.node.soul.ify({}, Gun.is.node.soul(prime)), prime = Gun.is.graph.ify(prime) || prime; 531 | if(Gun.is.graph(prime, null, function(val, field){ var node; 532 | function merge(a, f, v){ Gun.is.node.state.ify(a, f, v) } 533 | if(Gun.is.rel(val)){ node = gun? gun[field] || prime[field] : prime[field] } 534 | Gun.union.HAM(vertex, node, function(){}, function(vert, f, v){ 535 | merge([vertex, node], f, v); 536 | }, function(){})(function(err){ 537 | if(err){ merge([vertex], field, val) } 538 | }) 539 | })){ return vertex } 540 | } 541 | 542 | Gun.union.HAM = function(vertex, delta, lower, now, upper){ 543 | upper.max = -Infinity; 544 | now.end = true; 545 | delta = delta || {}; 546 | vertex = vertex || {}; 547 | Gun.obj.map(delta._, function(v,f){ 548 | if(Gun._.state === f || Gun._.soul === f){ return } 549 | vertex._[f] = v; 550 | }); 551 | if(!Gun.is.node(delta, function update(incoming, field){ 552 | now.end = false; 553 | var ctx = {incoming: {}, current: {}}, state; 554 | ctx.drift = Gun.time.now(); // DANGEROUS! 555 | ctx.incoming.value = Gun.is.rel(incoming) || incoming; 556 | ctx.current.value = Gun.is.rel(vertex[field]) || vertex[field]; 557 | ctx.incoming.state = Gun.num.is(ctx.tmp = ((delta._||{})[Gun._.state]||{})[field])? ctx.tmp : -Infinity; 558 | ctx.current.state = Gun.num.is(ctx.tmp = ((vertex._||{})[Gun._.state]||{})[field])? ctx.tmp : -Infinity; 559 | upper.max = ctx.incoming.state > upper.max? ctx.incoming.state : upper.max; 560 | state = Gun.HAM(ctx.drift, ctx.incoming.state, ctx.current.state, ctx.incoming.value, ctx.current.value); 561 | if(state.err){ 562 | root.console.log(".!HYPOTHETICAL AMNESIA MACHINE ERR!.", state.err); // this error should never happen. 563 | return; 564 | } 565 | if(state.state || state.historical || state.current){ 566 | lower.call(state, vertex, field, incoming, ctx.incoming.state); 567 | return; 568 | } 569 | if(state.incoming){ 570 | now.call(state, vertex, field, incoming, ctx.incoming.state); 571 | return; 572 | } 573 | if(state.defer){ 574 | upper.wait = true; 575 | upper.call(state, vertex, field, incoming, ctx.incoming.state); // signals that there are still future modifications. 576 | Gun.schedule(ctx.incoming.state, function(){ 577 | update(incoming, field); 578 | if(ctx.incoming.state === upper.max){ (upper.last || function(){})() } 579 | }); 580 | } 581 | })){ return function(fn){ if(fn){ fn({err: 'Not a node!'}) } } } 582 | if(now.end){ now.call({}, vertex) } // TODO: Should HAM handle empty updates? YES. 583 | return function(fn){ 584 | upper.last = fn || function(){}; 585 | if(!upper.wait){ upper.last() } 586 | } 587 | } 588 | 589 | Gun.on.at = function(on){ // On event emitter customized for gun. 590 | var proxy = function(e){ return proxy.e = e, proxy } 591 | proxy.emit = function(at){ 592 | if(at.soul){ 593 | at.hash = Gun.on.at.hash(at); 594 | //Gun.obj.as(proxy.mem, proxy.e)[at.soul] = at; 595 | Gun.obj.as(proxy.mem, proxy.e)[at.hash] = at; 596 | } 597 | if(proxy.all.cb){ proxy.all.cb(at, proxy.e) } 598 | on(proxy.e).emit(at); 599 | return {chain: function(c){ 600 | if(!c || !c._ || !c._.at){ return } 601 | return c._.at(proxy.e).emit(at) 602 | }}; 603 | } 604 | proxy.only = function(cb){ 605 | if(proxy.only.cb){ return } 606 | return proxy.event(proxy.only.cb = cb); 607 | } 608 | proxy.all = function(cb){ 609 | proxy.all.cb = cb; 610 | Gun.obj.map(proxy.mem, function(mem, e){ 611 | Gun.obj.map(mem, function(at, i){ 612 | cb(at, e); 613 | }); 614 | }); 615 | } 616 | proxy.event = function(cb, i){ 617 | i = on(proxy.e).event(cb, i); 618 | return Gun.obj.map(proxy.mem[proxy.e], function(at){ 619 | i.stat = {first: true}; 620 | cb.call(i, at); 621 | }), i.stat = {}, i; 622 | } 623 | proxy.map = function(cb, i){ 624 | return proxy.event(cb, i); 625 | }; 626 | proxy.mem = {}; 627 | return proxy; 628 | } 629 | 630 | Gun.on.at.hash = function(at){ return (at.at && at.at.soul)? at.at.soul + (at.at.field || '') : at.soul + (at.field || '') } 631 | 632 | Gun.on.at.copy = function(at){ return Gun.obj.del(at, 'hash'), Gun.obj.map(at, function(v,f,t){t(f,v)}) } 633 | 634 | }(Gun)); 635 | 636 | ;(function(Gun){ // Gun prototype chain methods. 637 | 638 | Gun.chain = Gun.prototype; 639 | 640 | Gun.chain.opt = function(opt, stun){ 641 | opt = opt || {}; 642 | var gun = this, root = (gun.__ && gun.__.gun)? gun.__.gun : (gun._ = gun.__ = {gun: gun}).gun.chain(); // if root does not exist, then create a root chain. 643 | root.__.by = root.__.by || function(f){ return gun.__.by[f] = gun.__.by[f] || {} }; 644 | root.__.graph = root.__.graph || {}; 645 | root.__.opt = root.__.opt || {}; 646 | root.__.opt.wire = root.__.opt.wire || {}; 647 | if(Gun.text.is(opt)){ opt = {peers: opt} } 648 | if(Gun.list.is(opt)){ opt = {peers: opt} } 649 | if(Gun.text.is(opt.peers)){ opt.peers = [opt.peers] } 650 | if(Gun.list.is(opt.peers)){ opt.peers = Gun.obj.map(opt.peers, function(n,f,m){ m(n,{}) }) } 651 | root.__.opt.peers = opt.peers || gun.__.opt.peers || {}; 652 | Gun.obj.map(opt.wire, function(h, f){ 653 | if(!Gun.fns.is(h)){ return } 654 | root.__.opt.wire[f] = h; 655 | }); 656 | Gun.obj.map(['key', 'on', 'path', 'map', 'not', 'init'], function(f){ 657 | if(!opt[f]){ return } 658 | root.__.opt[f] = opt[f] || root.__.opt[f]; 659 | }); 660 | if(!stun){ Gun.on('opt').emit(root, opt) } 661 | return gun; 662 | } 663 | 664 | Gun.chain.chain = function(s){ 665 | var from = this, gun = !from.back? from : Gun(from); 666 | gun.back = gun.back || from; 667 | gun.__ = gun.__ || from.__; 668 | gun._ = gun._ || {}; 669 | gun._.on = gun._.on || Gun.on.create(); 670 | gun._.at = gun._.at || Gun.on.at(gun._.on); 671 | return gun; 672 | } 673 | 674 | Gun.chain.put = function(val, cb, opt){ 675 | opt = opt || {}; 676 | cb = cb || function(){}; cb.hash = {}; 677 | var gun = this, chain = gun.chain(), tmp = {val: val}, drift = Gun.time.now(); 678 | function put(at){ 679 | var val = tmp.val; 680 | var ctx = {obj: val}; // prep the value for serialization 681 | ctx.soul = at.field? at.soul : (at.at && at.at.soul) || at.soul; // figure out where we are 682 | ctx.field = at.field? at.field : (at.at && at.at.field) || at.field; // did we come from some where? 683 | if(Gun.is(val)){ 684 | if(!ctx.field){ return cb.call(chain, {err: ctx.err = Gun.log('No field to link node to!')}), chain._.at('err').emit(ctx.err) } 685 | return val.val(function(node){ 686 | var soul = Gun.is.node.soul(node); 687 | if(!soul){ return cb.call(chain, {err: ctx.err = Gun.log('Only a node can be linked! Not "' + node + '"!')}), chain._.at('err').emit(ctx.err) } 688 | tmp.val = Gun.is.rel.ify(soul); 689 | put(at); 690 | }); 691 | } 692 | if(cb.hash[at.hash = at.hash || Gun.on.at.hash(at)]){ return } // if we have already seen this hash... 693 | cb.hash[at.hash] = true; // else mark that we're processing the data (failure to write could still occur). 694 | ctx.by = chain.__.by(ctx.soul); 695 | ctx.not = at.not || (at.at && at.at.not); 696 | Gun.obj.del(at, 'not'); Gun.obj.del(at.at || at, 'not'); // the data is no longer not known! // TODO: BUG! It could have been asynchronous by the time we now delete these properties. Don't other parts of the code assume their deletion is synchronous? 697 | if(ctx.field){ Gun.obj.as(ctx.obj = {}, ctx.field, val) } // if there is a field, then data is actually getting put on the parent. 698 | else if(!Gun.obj.is(val)){ return cb.call(chain, ctx.err = {err: Gun.log("No node exists to put " + (typeof val) + ' "' + val + '" in!')}), chain._.at('err').emit(ctx.err) } // if the data is a primitive and there is no context for it yet, then we have an error. 699 | // TODO: BUG? gun.get(key).path(field).put() isn't doing it as pseudo. 700 | function soul(env, cb, map){ var eat; 701 | if(!env || !(eat = env.at) || !env.at.node){ return } 702 | if(!eat.node._){ eat.node._ = {} } 703 | if(!eat.node._[Gun._.state]){ eat.node._[Gun._.state] = {} } 704 | if(!Gun.is.node.soul(eat.node)){ 705 | if(ctx.obj === eat.obj){ 706 | Gun.obj.as(env.graph, eat.soul = Gun.obj.as(eat.node._, Gun._.soul, Gun.is.node.soul(eat.obj) || ctx.soul), eat.node); 707 | cb(eat, eat.soul); 708 | } else { 709 | var path = function(err, node){ 710 | if(path.opt && path.opt.on && path.opt.on.off){ path.opt.on.off() } 711 | if(path.opt.done){ return } 712 | path.opt.done = true; 713 | if(err){ env.err = err } 714 | eat.soul = Gun.is.node.soul(node) || Gun.is.node.soul(eat.obj) || Gun.is.node.soul(eat.node) || Gun.text.random(); 715 | Gun.obj.as(env.graph, Gun.obj.as(eat.node._, Gun._.soul, eat.soul), eat.node); 716 | cb(eat, eat.soul); 717 | }; path.opt = {put: true}; 718 | (ctx.not)? path() : ((at.field || at.at)? gun.back : gun).path(eat.path || [], path, path.opt); 719 | } 720 | } 721 | if(!eat.field){ return } 722 | eat.node._[Gun._.state][eat.field] = drift; 723 | } 724 | function end(err, ify){ 725 | ctx.ify = ify; 726 | Gun.on('put').emit(chain, at, ctx, opt, cb, val); 727 | if(err || ify.err){ return cb.call(chain, err || ify.err), chain._.at('err').emit(err || ify.err) } // check for serialization error, emit if so. 728 | if(err = Gun.union(chain, ify.graph, {end: false, soul: function(soul){ 729 | if(chain.__.by(soul).end){ return } 730 | Gun.union(chain, Gun.is.node.soul.ify({}, soul)); // fire off an end node if there hasn't already been one, to comply with the wire spec. 731 | }}).err){ return cb.call(chain, err), chain._.at('err').emit(err) } // now actually union the serialized data, emit error if any occur. 732 | if(Gun.fns.is(end.wire = chain.__.opt.wire.put)){ 733 | var wcb = function(err, ok, info){ 734 | if(err){ return Gun.log(err.err || err), cb.call(chain, err), chain._.at('err').emit(err) } 735 | return cb.call(chain, err, ok); 736 | } 737 | end.wire(ify.graph, wcb, opt); 738 | } else { 739 | if(!Gun.log.count('no-wire-put')){ Gun.log("Warning! You have no persistence layer to save to!") } 740 | cb.call(chain, null); // This is in memory success, hardly "success" at all. 741 | } 742 | if(ctx.field){ 743 | return gun.back.path(ctx.field, null, {chain: opt.chain || chain}); 744 | } 745 | if(ctx.not){ 746 | return gun.__.gun.get(ctx.soul, null, {chain: opt.chain || chain}); 747 | } 748 | chain.get(ctx.soul, null, {chain: opt.chain || chain, at: gun._.at }) 749 | } 750 | Gun.ify(ctx.obj, soul, {pure: true})(end); // serialize the data! 751 | } 752 | if(gun === gun.back){ // if we are the root chain... 753 | put({soul: Gun.is.node.soul(val) || Gun.text.random(), not: true}); // then cause the new chain to save data! 754 | } else { // else if we are on an existing chain then... 755 | gun._.at('soul').map(put); // put data on every soul that flows through this chain. 756 | var back = function(gun){ 757 | if(gun.back === gun || gun._.not){ return } // TODO: CLEAN UP! Would be ideal to accomplish this in a more ideal way. 758 | gun._.at('null').event(function(at){ 759 | if(opt.init || gun.__.opt.init){ return Gun.log("Warning! You have no context to `.put`", val, "!") } 760 | gun.init(); 761 | }, -999); 762 | return back(gun.back); 763 | }; 764 | if(!opt.init && !gun.__.opt.init){ back(gun) } 765 | } 766 | chain.back = gun.back; 767 | return chain; 768 | } 769 | 770 | Gun.chain.get = (function(){ 771 | Gun.on('operating').event(function(gun, at){ 772 | if(!gun.__.by(at.soul).node){ gun.__.by(at.soul).node = gun.__.graph[at.soul] } 773 | if(at.field){ return } // TODO: It would be ideal to reuse HAM's field emit. 774 | gun.__.on(at.soul).emit(at); 775 | }); 776 | Gun.on('get').event(function(gun, at, ctx, opt, cb){ 777 | if(ctx.halt){ return } // TODO: CLEAN UP with event emitter option? 778 | at.change = at.change || gun.__.by(at.soul).node; 779 | if(opt.raw){ return cb.call(opt.on, at) } 780 | if(!ctx.cb.no){ cb.call(ctx.by.chain, null, Gun.obj.copy(ctx.node || gun.__.by(at.soul).node)) } 781 | gun._.at('soul').emit(at).chain(opt.chain); 782 | },0); 783 | Gun.on('get').event(function(gun, at, ctx){ 784 | if(ctx.halt){ ctx.halt = false; return } // TODO: CLEAN UP with event emitter option? 785 | }, Infinity); 786 | return function(lex, cb, opt){ // get opens up a reference to a node and loads it. 787 | var gun = this, ctx = { 788 | opt: opt || {}, 789 | cb: cb || function(){}, 790 | lex: (Gun.text.is(lex) || Gun.num.is(lex))? Gun.is.rel.ify(lex) : lex, 791 | }; 792 | ctx.force = ctx.opt.force; 793 | if(cb !== ctx.cb){ ctx.cb.no = true } 794 | if(!Gun.obj.is(ctx.lex)){ return ctx.cb.call(gun = gun.chain(), {err: Gun.log('Invalid get request!', lex)}), gun } 795 | if(!(ctx.soul = ctx.lex[Gun._.soul])){ return ctx.cb.call(gun = this.chain(), {err: Gun.log('No soul to get!')}), gun } // TODO: With `.all` it'll be okay to not have an exact match! 796 | ctx.by = gun.__.by(ctx.soul); 797 | ctx.by.chain = ctx.by.chain || gun.chain(); 798 | function load(lex){ 799 | var soul = lex[Gun._.soul]; 800 | var cached = gun.__.by(soul).node || gun.__.graph[soul]; 801 | if(ctx.force){ ctx.force = false } 802 | else if(cached){ return false } 803 | wire(lex, stream, ctx.opt); 804 | return true; 805 | } 806 | function stream(err, data, info){ 807 | //console.log("wire.get <--", err, data); 808 | Gun.on('wire.get').emit(ctx.by.chain, ctx, err, data, info); 809 | if(err){ 810 | Gun.log(err.err || err); 811 | ctx.cb.call(ctx.by.chain, err); 812 | return ctx.by.chain._.at('err').emit({soul: ctx.soul, err: err.err || err}).chain(ctx.opt.chain); 813 | } 814 | if(!data){ 815 | ctx.cb.call(ctx.by.chain, null); 816 | return ctx.by.chain._.at('null').emit({soul: ctx.soul, not: true}).chain(ctx.opt.chain); 817 | } 818 | if(Gun.obj.empty(data)){ return } 819 | if(err = Gun.union(ctx.by.chain, data).err){ 820 | ctx.cb.call(ctx.by.chain, err); 821 | return ctx.by.chain._.at('err').emit({soul: Gun.is.node.soul(data) || ctx.soul, err: err.err || err}).chain(ctx.opt.chain); 822 | } 823 | } 824 | function wire(lex, cb, opt){ 825 | Gun.on('get.wire').emit(ctx.by.chain, ctx, lex, cb, opt); 826 | if(Gun.fns.is(gun.__.opt.wire.get)){ return gun.__.opt.wire.get(lex, cb, opt) } 827 | if(!Gun.log.count('no-wire-get')){ Gun.log("Warning! You have no persistence layer to get from!") } 828 | cb(null); // This is in memory success, hardly "success" at all. 829 | } 830 | function on(at){ 831 | if(on.ran = true){ ctx.opt.on = this } 832 | if(load(ctx.lex)){ return } 833 | Gun.on('get').emit(ctx.by.chain, at, ctx, ctx.opt, ctx.cb, ctx.lex); 834 | } 835 | ctx.opt.on = (ctx.opt.at || gun.__.at)(ctx.soul).event(on); 836 | if(!ctx.opt.ran && !on.ran){ on.call(ctx.opt.on, {soul: ctx.soul}) } 837 | return ctx.by.chain; 838 | } 839 | }()); 840 | 841 | Gun.chain.key = (function(){ 842 | Gun.on('put').event(function(gun, at, ctx, opt, cb){ 843 | if(opt.key){ return } 844 | Gun.is.graph(ctx.ify.graph, function(node, soul){ 845 | var key = {node: gun.__.graph[soul]}; 846 | if(!Gun.is.node.soul(key.node, 'key')){ return } 847 | if(!gun.__.by(soul).end){ gun.__.by(soul).end = 1 } 848 | Gun.is.node(key.node, function(rel, s){ 849 | rel = ctx.ify.graph[s] = ctx.ify.graph[s] || Gun.is.node.soul.ify({}, s); 850 | Gun.is.node(node, function(v,f){ Gun.is.node.state.ify([rel, node], f, v) }); 851 | Gun.obj.del(ctx.ify.graph, soul); 852 | }) 853 | }); 854 | }); 855 | Gun.on('get').event(function(gun, at, ctx, opt, cb){ 856 | if(ctx.halt){ return } // TODO: CLEAN UP with event emitter option? 857 | if(opt.key && opt.key.soul){ 858 | at.soul = opt.key.soul; 859 | gun.__.by(opt.key.soul).node = Gun.union.ify(gun, opt.key.soul); // TODO: Check performance? 860 | gun.__.by(opt.key.soul).node._['key'] = 'pseudo'; 861 | at.change = Gun.is.node.soul.ify(Gun.obj.copy(at.change || gun.__.by(at.soul).node), at.soul, true); // TODO: Check performance? 862 | return; 863 | } 864 | if(!(Gun.is.node.soul(gun.__.graph[at.soul], 'key') === 1)){ return } 865 | var node = at.change || gun.__.graph[at.soul]; 866 | function map(rel, soul){ gun.__.gun.get(rel, cb, {key: ctx, chain: opt.chain || gun, force: opt.force}) } 867 | ctx.halt = true; 868 | Gun.is.node(node, map); 869 | },-999); 870 | return function(key, cb, opt){ 871 | var gun = this; 872 | opt = Gun.text.is(opt)? {soul: opt} : opt || {}; 873 | cb = cb || function(){}; cb.hash = {}; 874 | if(!Gun.text.is(key) || !key){ return cb.call(gun, {err: Gun.log('No key!')}), gun } 875 | function index(at){ 876 | var ctx = {node: gun.__.graph[at.soul]}; 877 | if(at.soul === key || at.key === key){ return } 878 | if(cb.hash[at.hash = at.hash || Gun.on.at.hash(at)]){ return } cb.hash[at.hash] = true; 879 | ctx.obj = (1 === Gun.is.node.soul(ctx.node, 'key'))? Gun.obj.copy(ctx.node) : Gun.obj.put({}, at.soul, Gun.is.rel.ify(at.soul)); 880 | Gun.obj.as((ctx.put = Gun.is.node.ify(ctx.obj, key, true))._, 'key', 1); 881 | gun.__.gun.put(ctx.put, function(err, ok){cb.call(this, err, ok)}, {chain: opt.chain, key: true, init: true}); 882 | } 883 | if(opt.soul){ 884 | index({soul: opt.soul}); 885 | return gun; 886 | } 887 | if(gun === gun.back){ 888 | cb.call(gun, {err: Gun.log('You have no context to `.key`', key, '!')}); 889 | } else { 890 | gun._.at('soul').map(index); 891 | } 892 | return gun; 893 | } 894 | }()); 895 | 896 | Gun.chain.on = function(cb, opt){ // on subscribes to any changes on the souls. 897 | var gun = this, u; 898 | opt = Gun.obj.is(opt)? opt : {change: opt}; 899 | cb = cb || function(){}; 900 | function map(at){ 901 | opt.on = opt.on || this; 902 | var ctx = {by: gun.__.by(at.soul)}, change = ctx.by.node; 903 | if(opt.on.stat && opt.on.stat.first){ (at = Gun.on.at.copy(at)).change = ctx.by.node } 904 | if(opt.raw){ return cb.call(opt.on, at) } 905 | if(opt.once){ this.off() } 906 | if(opt.change){ change = at.change } 907 | if(!opt.empty && Gun.obj.empty(change, Gun._.meta)){ return } 908 | cb.call(ctx.by.chain || gun, Gun.obj.copy(at.field? change[at.field] : change), at.field || (at.at && at.at.field)); 909 | }; 910 | opt.on = gun._.at('soul').map(map); 911 | if(gun === gun.back){ Gun.log('You have no context to `.on`!') } 912 | return gun; 913 | } 914 | 915 | Gun.chain.path = (function(){ 916 | Gun.on('get').event(function(gun, at, ctx, opt, cb, lex){ 917 | if(ctx.halt){ return } // TODO: CLEAN UP with event emitter option? 918 | if(opt.path){ at.at = opt.path } 919 | var xtc = {soul: lex[Gun._.soul], field: lex[Gun._.field]}; 920 | xtc.change = at.change || gun.__.by(at.soul).node; 921 | if(xtc.field){ // TODO: future feature! 922 | if(!Gun.obj.has(xtc.change, xtc.field)){ return } 923 | ctx.node = Gun.is.node.soul.ify({}, at.soul); // TODO: CLEAN UP! ctx.node usage. 924 | Gun.is.node.state.ify([ctx.node, xtc.change], xtc.field, xtc.change[xtc.field]); 925 | at.change = ctx.node; at.field = xtc.field; 926 | } 927 | },-99); 928 | Gun.on('get').event(function(gun, at, ctx, opt, cb, lex){ 929 | if(ctx.halt){ return } // TODO: CLEAN UP with event emitter option? 930 | var xtc = {}; xtc.change = at.change || gun.__.by(at.soul).node; 931 | if(!opt.put){ // TODO: CLEAN UP be nice if path didn't have to worry about this. 932 | Gun.is.node(xtc.change, function(v,f){ 933 | var fat = Gun.on.at.copy(at); fat.field = f; fat.value = v; 934 | Gun.obj.del(fat, 'at'); // TODO: CLEAN THIS UP! It would be nice in every other function every where else it didn't matter whether there was a cascading at.at.at.at or not, just and only whether the current context as a field or should rely on a previous field. But maybe that is the gotcha right there? 935 | fat.change = fat.change || xtc.change; 936 | if(v = Gun.is.rel(fat.value)){ fat = {soul: v, at: fat} } 937 | gun._.at('path:' + f).emit(fat).chain(opt.chain); 938 | }); 939 | } 940 | if(!ctx.end){ 941 | ctx.end = gun._.at('end').emit(at).chain(opt.chain); 942 | } 943 | },99); 944 | return function(path, cb, opt){ 945 | opt = opt || {}; 946 | cb = cb || (function(){ var cb = function(){}; cb.no = true; return cb }()); cb.hash = {}; 947 | var gun = this, chain = gun.chain(), f, c, u; 948 | if(!Gun.list.is(path)){ if(!Gun.text.is(path)){ if(!Gun.num.is(path)){ // if not a list, text, or number 949 | return cb.call(chain, {err: Gun.log("Invalid path '" + path + "'!")}), chain; // then complain 950 | } else { return this.path(path + '', cb, opt) } } else { return this.path(path.split('.'), cb, opt) } } // else coerce upward to a list. 951 | if(gun === gun.back){ 952 | cb.call(chain, opt.put? null : {err: Gun.log('You have no context to `.path`', path, '!')}); 953 | return chain; 954 | } 955 | gun._.at('path:' + path[0]).event(function(at){ 956 | if(opt.done){ this.off(); return } // TODO: BUG - THIS IS A FIX FOR A BUG! TEST #"context no double emit", COMMENT THIS LINE OUT AND SEE IT FAIL! 957 | var ctx = {soul: at.soul, field: at.field, by: gun.__.by(at.soul)}, field = path[0]; 958 | var on = Gun.obj.as(cb.hash, at.hash, {off: function(){}}); 959 | if(at.soul === on.soul){ return } 960 | else { on.off() } 961 | if(ctx.rel = (Gun.is.rel(at.value) || Gun.is.rel(at.at && at.at.value))){ 962 | if(opt.put && 1 === path.length){ 963 | return cb.call(ctx.by.chain || chain, null, Gun.is.node.soul.ify({}, ctx.rel)); 964 | } 965 | var get = function(err, node){ 966 | if(!err && 1 !== path.length){ return } 967 | cb.call(this, err, node, field); 968 | }; 969 | ctx.opt = {chain: opt.chain || chain, put: opt.put, path: {soul: (at.at && at.at.soul) || at.soul, field: field }}; 970 | gun.__.gun.get(ctx.rel || at.soul, cb.no? null : get, ctx.opt); 971 | (opt.on = cb.hash[at.hash] = on = ctx.opt.on).soul = at.soul; // TODO: BUG! CB getting reused as the hash point for multiple paths potentially! Could cause problems! 972 | return; 973 | } 974 | if(1 === path.length){ cb.call(ctx.by.chain || chain, null, at.value, ctx.field) } 975 | chain._.at('soul').emit(at).chain(opt.chain); 976 | }); 977 | gun._.at('null').only(function(at){ 978 | if(!at.field){ return } 979 | if(at.not){ 980 | gun.put({}, null, {init: true}); 981 | if(opt.init || gun.__.opt.init){ return } 982 | } 983 | (at = Gun.on.at.copy(at)).field = path[0]; 984 | at.not = true; 985 | chain._.at('null').emit(at).chain(opt.chain); 986 | }); 987 | gun._.at('end').event(function(at){ 988 | this.off(); 989 | if(at.at && at.at.field === path[0]){ return } // TODO: BUG! THIS FIXES SO MANY PROBLEMS BUT DOES IT CATCH VARYING SOULS EDGE CASE? 990 | var ctx = {by: gun.__.by(at.soul)}; 991 | if(Gun.obj.has(ctx.by.node, path[0])){ return } 992 | (at = Gun.on.at.copy(at)).field = path[0]; 993 | at.not = true; 994 | cb.call(ctx.by.chain || chain, null); 995 | chain._.at('null').emit(at).chain(opt.chain); 996 | }); 997 | if(path.length > 1){ 998 | (c = chain.path(path.slice(1), cb, opt)).back = gun; 999 | } 1000 | return c || chain; 1001 | } 1002 | }()); 1003 | 1004 | Gun.chain.map = function(cb, opt){ 1005 | var u, gun = this, chain = gun.chain(); 1006 | cb = cb || function(){}; cb.hash = {}; 1007 | opt = Gun.bi.is(opt)? {change: opt} : opt || {}; 1008 | opt.change = Gun.bi.is(opt.change)? opt.change : true; 1009 | function path(err, val, field){ 1010 | if(err || (val === u)){ return } 1011 | cb.call(this, val, field); 1012 | } 1013 | function each(val, field){ 1014 | //if(!Gun.is.rel(val)){ path.call(this.gun, null, val, field);return;} 1015 | cb.hash[this.soul + field] = cb.hash[this.soul + field] || this.gun.path(field, path, {chain: chain, via: 'map'}); // TODO: path should reuse itself! We shouldn't have to do it ourselves. 1016 | // TODO: 1017 | // 1. Ability to turn off an event. // automatically happens within path since reusing is manual? 1018 | // 2. Ability to pass chain context to fire on. // DONE 1019 | // 3. Pseudoness handled for us. // DONE 1020 | // 4. Reuse. // MANUALLY DONE 1021 | } 1022 | function map(at){ 1023 | var ref = gun.__.by(at.soul).chain || gun; 1024 | Gun.is.node(at.change, each, {gun: ref, soul: at.soul}); 1025 | } 1026 | gun.on(map, {raw: true, change: true}); // TODO: ALLOW USER TO DO map change false! 1027 | if(gun === gun.back){ Gun.log('You have no context to `.map`!') } 1028 | return chain; 1029 | } 1030 | 1031 | Gun.chain.val = (function(){ 1032 | Gun.on('get.wire').event(function(gun, ctx){ 1033 | if(!ctx.soul){ return } var end; 1034 | (end = gun.__.by(ctx.soul)).end = (end.end || -1); // TODO: CLEAN UP! This should be per peer! 1035 | },-999); 1036 | Gun.on('wire.get').event(function(gun, ctx, err, data){ 1037 | if(err || !ctx.soul){ return } 1038 | if(data && !Gun.obj.empty(data, Gun._.meta)){ return } 1039 | var end = gun.__.by(ctx.soul); 1040 | end.end = (!end.end || end.end < 0)? 1 : end.end + 1; 1041 | },-999); 1042 | return function(cb, opt){ 1043 | var gun = this, args = Gun.list.slit.call(arguments); 1044 | cb = Gun.fns.is(cb)? cb : function(val, field){ root.console.log.apply(root.console, args.concat([field && (field += ':'), val])) }; cb.hash = {}; 1045 | opt = opt || {}; 1046 | function val(at){ 1047 | var ctx = {by: gun.__.by(at.soul), at: at.at || at}, node = ctx.by.node, field = ctx.at.field, hash = Gun.on.at.hash({soul: ctx.at.key || ctx.at.soul, field: field}); 1048 | if(cb.hash[hash]){ return } 1049 | if(at.field && Gun.obj.has(node, at.field)){ 1050 | return cb.hash[hash] = true, cb.call(ctx.by.chain || gun, Gun.obj.copy(node[at.field]), at.field); 1051 | } 1052 | if(!opt.empty && Gun.obj.empty(node, Gun._.meta)){ return } // TODO: CLEAN UP! .on already does this without the .raw! 1053 | if(ctx.by.end < 0){ return } 1054 | return cb.hash[hash] = true, cb.call(ctx.by.chain || gun, Gun.obj.copy(node), field); 1055 | } 1056 | gun.on(val, {raw: true}); 1057 | if(gun === gun.back){ Gun.log('You have no context to `.val`!') } 1058 | return gun; 1059 | } 1060 | }()); 1061 | 1062 | Gun.chain.not = function(cb, opt){ 1063 | var gun = this, chain = gun.chain(); 1064 | cb = cb || function(){}; 1065 | opt = opt || {}; 1066 | function not(at,e){ 1067 | if(at.field){ 1068 | if(Gun.obj.has(gun.__.by(at.soul).node, at.field)){ return Gun.obj.del(at, 'not'), chain._.at(e).emit(at) } 1069 | } else 1070 | if(at.soul && gun.__.by(at.soul).node){ return Gun.obj.del(at, 'not'), chain._.at(e).emit(at) } 1071 | if(!at.not){ return } 1072 | var kick = function(next){ 1073 | if(++kick.c){ return Gun.log("Warning! Multiple `not` resumes!"); } 1074 | next._.at.all(function(on ,e){ // TODO: BUG? Switch back to .at? I think .on is actually correct so it doesn't memorize. // TODO: BUG! What about other events? 1075 | chain._.at(e).emit(on); 1076 | }); 1077 | }; 1078 | kick.c = -1 1079 | kick.chain = gun.chain(); 1080 | kick.next = cb.call(kick.chain, opt.raw? at : (at.field || at.soul || at.not), kick); 1081 | kick.soul = Gun.text.random(); 1082 | if(Gun.is(kick.next)){ kick(kick.next) } 1083 | kick.chain._.at('soul').emit({soul: kick.soul, field: at.field, not: true, via: 'not'}); 1084 | } 1085 | gun._.at.all(not); 1086 | if(gun === gun.back){ Gun.log('You have no context to `.not`!') } 1087 | chain._.not = true; // TODO: CLEAN UP! Would be ideal if we could accomplish this in a more elegant way. 1088 | return chain; 1089 | } 1090 | 1091 | Gun.chain.set = function(item, cb, opt){ 1092 | var gun = this, ctx = {}, chain; 1093 | if(!Gun.is(item)){ return cb.call(gun, {err: Gun.log('Set only supports node references currently!')}), gun } // TODO: Bug? Should we return not gun on error? 1094 | (ctx.chain = item.chain()).back = gun; 1095 | ctx.chain._ = item._; 1096 | item.val(function(node){ // TODO: BUG! Return proxy chain with back = list. 1097 | if(ctx.done){ return } ctx.done = true; 1098 | var put = {}, soul = Gun.is.node.soul(node); 1099 | if(!soul){ return cb.call(gun, {err: Gun.log('Only a node can be linked! Not "' + node + '"!')}) } 1100 | gun.put(Gun.obj.put(put, soul, Gun.is.rel.ify(soul)), cb, opt); 1101 | }); 1102 | return ctx.chain; 1103 | } 1104 | 1105 | Gun.chain.init = function(cb, opt){ 1106 | var gun = this; 1107 | gun._.at('null').event(function(at){ 1108 | if(!at.not){ return } // TODO: BUG! This check is synchronous but it could be asynchronous! 1109 | var ctx = {by: gun.__.by(at.soul)}; 1110 | if(at.field){ 1111 | if(Gun.obj.has(ctx.by.node, at.field)){ return } 1112 | gun._.at('soul').emit({soul: at.soul, field: at.field, not: true}); 1113 | return; 1114 | } 1115 | if(at.soul){ 1116 | if(ctx.by.node){ return } 1117 | var soul = Gun.text.random(); 1118 | gun.__.gun.put(Gun.is.node.soul.ify({}, soul), null, {init: true}); 1119 | gun.__.gun.key(at.soul, null, soul); 1120 | } 1121 | }, {raw: true}); 1122 | return gun; 1123 | } 1124 | 1125 | }(Gun)); 1126 | 1127 | ;(function(Gun){ // Javascript to Gun Serializer. 1128 | function ify(data, cb, opt){ 1129 | opt = opt || {}; 1130 | cb = cb || function(env, cb){ cb(env.at, Gun.is.node.soul(env.at.obj) || Gun.is.node.soul(env.at.node) || Gun.text.random()) }; 1131 | var end = function(fn){ 1132 | ctx.end = fn || function(){}; 1133 | unique(ctx); 1134 | }, ctx = {at: {path: [], obj: data}, root: {}, graph: {}, queue: [], seen: [], opt: opt, loop: true}; 1135 | if(!data){ return ctx.err = {err: Gun.log('Serializer does not have correct parameters.')}, end } 1136 | if(ctx.opt.start){ Gun.is.node.soul.ify(ctx.root, ctx.opt.start) } 1137 | ctx.at.node = ctx.root; 1138 | while(ctx.loop && !ctx.err){ 1139 | seen(ctx, ctx.at); 1140 | map(ctx, cb); 1141 | if(ctx.queue.length){ 1142 | ctx.at = ctx.queue.shift(); 1143 | } else { 1144 | ctx.loop = false; 1145 | } 1146 | } 1147 | return end; 1148 | } 1149 | function map(ctx, cb){ 1150 | var u, rel = function(at, soul){ 1151 | at.soul = at.soul || soul || Gun.is.node.soul(at.obj) || Gun.is.node.soul(at.node); 1152 | if(!ctx.opt.pure){ 1153 | ctx.graph[at.soul] = Gun.is.node.soul.ify(at.node, at.soul); 1154 | if(ctx.at.field){ 1155 | Gun.is.node.state.ify([at.node], at.field, u, ctx.opt.state); 1156 | } 1157 | } 1158 | Gun.list.map(at.back, function(rel){ 1159 | rel[Gun._.soul] = at.soul; 1160 | }); 1161 | unique(ctx); 1162 | }, it; 1163 | Gun.obj.map(ctx.at.obj, function(val, field){ 1164 | ctx.at.val = val; 1165 | ctx.at.field = field; 1166 | it = cb(ctx, rel, map) || true; 1167 | if(field === Gun._.meta){ 1168 | ctx.at.node[field] = Gun.obj.copy(val); // TODO: BUG! Is this correct? 1169 | return; 1170 | } 1171 | if(String(field).indexOf('.') != -1 || (false && notValidField(field))){ // TODO: BUG! Do later for ACID "consistency" guarantee. 1172 | return ctx.err = {err: Gun.log("Invalid field name on '" + ctx.at.path.join('.') + "'!")}; 1173 | } 1174 | if(!Gun.is.val(val)){ 1175 | var at = {obj: val, node: {}, back: [], path: [field]}, tmp = {}, was; 1176 | at.path = (ctx.at.path||[]).concat(at.path || []); 1177 | if(!Gun.obj.is(val)){ 1178 | return ctx.err = {err: Gun.log("Invalid value at '" + at.path.join('.') + "'!" )}; 1179 | } 1180 | if(was = seen(ctx, at)){ 1181 | tmp[Gun._.soul] = Gun.is.node.soul(was.node) || null; 1182 | (was.back = was.back || []).push(ctx.at.node[field] = tmp); 1183 | } else { 1184 | ctx.queue.push(at); 1185 | tmp[Gun._.soul] = null; 1186 | at.back.push(ctx.at.node[field] = tmp); 1187 | } 1188 | } else { 1189 | ctx.at.node[field] = Gun.obj.copy(val); 1190 | } 1191 | }); 1192 | if(!it){ cb(ctx, rel) } 1193 | } 1194 | function unique(ctx){ 1195 | if(ctx.err || (!Gun.list.map(ctx.seen, function(at){ 1196 | if(!at.soul){ return true } 1197 | }) && !ctx.loop)){ return ctx.end(ctx.err, ctx), ctx.end = function(){}; } 1198 | } 1199 | function seen(ctx, at){ 1200 | return Gun.list.map(ctx.seen, function(has){ 1201 | if(at.obj === has.obj){ return has } 1202 | }) || (ctx.seen.push(at) && false); 1203 | } 1204 | ify.wire = function(n, cb, opt){ return Gun.text.is(n)? ify.wire.from(n, cb, opt) : ify.wire.to(n, cb, opt) } 1205 | ify.wire.to = function(n, cb, opt){ var t, b; 1206 | if(!n || !(t = Gun.is.node.soul(n))){ return null } 1207 | cb = cb || function(){}; 1208 | t = (b = "#'" + JSON.stringify(t) + "'"); 1209 | Gun.obj.map(n, function(v,f){ 1210 | if(Gun._.meta === f){ return } 1211 | var w = '', s = Gun.is.node.state(n,f); 1212 | if(!s){ return } 1213 | w += ".'" + JSON.stringify(f) + "'"; 1214 | w += "='" + JSON.stringify(v) + "'"; 1215 | w += ">'" + JSON.stringify(s) + "'"; 1216 | t += w; 1217 | w = b + w; 1218 | cb(null, w); 1219 | }); 1220 | return t; 1221 | } 1222 | ify.wire.from = function(n, cb, opt){ 1223 | if(!n){ return null } 1224 | var a = [], s = -1, e = 0, end = 1; 1225 | while((e = n.indexOf("'", s + 1)) >= 0){ 1226 | if(s === e || '\\' === n.charAt(e-1)){}else{ 1227 | a.push(n.slice(s + 1,e)); 1228 | s = e; 1229 | } 1230 | } 1231 | return a; 1232 | } 1233 | Gun.ify = ify; 1234 | }(Gun)); 1235 | 1236 | var root = this || {}; // safe for window, global, root, and 'use strict'. 1237 | if(root.window){ window.Gun = Gun } 1238 | if(typeof module !== "undefined" && module.exports){ module.exports = Gun } 1239 | root.console = root.console || {log: function(s){ return s }}; // safe for old browsers 1240 | var console = { 1241 | log: function(s){return root.console.log.apply(root.console, arguments), s}, 1242 | Log: Gun.log = function(s){ return (!Gun.log.squelch && root.console.log.apply(root.console, arguments)), s } 1243 | }; 1244 | console.debug = function(i, s){ return (Gun.log.debug && i === Gun.log.debug && Gun.log.debug++) && root.console.log.apply(root.console, arguments), s }; 1245 | Gun.log.count = function(s){ return Gun.log.count[s] = Gun.log.count[s] || 0, Gun.log.count[s]++ } 1246 | }()); 1247 | 1248 | 1249 | ;(function(Tab){ 1250 | 1251 | if(!this.Gun){ return } 1252 | if(!window.JSON){ throw new Error("Include JSON first: ajax.cdnjs.com/ajax/libs/json2/20110223/json2.js") } // for old IE use 1253 | 1254 | ;(function(exports){ 1255 | function s(){} 1256 | s.put = function(key, val){ return store.setItem(key, Gun.text.ify(val)) } 1257 | s.get = function(key, cb){ /*setTimeout(function(){*/ return cb(null, Gun.obj.ify(store.getItem(key) || null)) /*},1)*/} 1258 | s.del = function(key){ return store.removeItem(key) } 1259 | var store = this.localStorage || {setItem: function(){}, removeItem: function(){}, getItem: function(){}}; 1260 | exports.store = s; 1261 | }(Tab)); 1262 | 1263 | Gun.on('opt').event(function(gun, opt){ 1264 | opt = opt || {}; 1265 | var tab = gun.tab = gun.tab || {}; 1266 | tab.store = tab.store || Tab.store; 1267 | tab.request = tab.request || request; 1268 | tab.request.s = tab.request.s || {}; 1269 | tab.headers = opt.headers || {}; 1270 | tab.headers['gun-sid'] = tab.headers['gun-sid'] || Gun.text.random(); // stream id 1271 | tab.prefix = tab.prefix || opt.prefix || 'gun/'; 1272 | tab.get = tab.get || function(lex, cb, opt){ 1273 | if(!lex){ return } 1274 | var soul = lex[Gun._.soul]; 1275 | if(!soul){ return } 1276 | cb = cb || function(){}; 1277 | (opt.headers = Gun.obj.copy(tab.headers)).id = tab.msg(); 1278 | (function local(soul, cb){ 1279 | tab.store.get(tab.prefix + soul, function(err, data){ 1280 | if(!data){ return } // let the peers handle no data. 1281 | if(err){ return cb(err) } 1282 | cb(err, cb.node = data); // node 1283 | cb(err, Gun.is.node.soul.ify({}, Gun.is.node.soul(data))); // end 1284 | cb(err, {}); // terminate 1285 | }); 1286 | }(soul, cb)); 1287 | if(!(cb.local = opt.local)){ 1288 | tab.request.s[opt.headers.id] = tab.error(cb, "Error: Get failed!", function(reply){ 1289 | setTimeout(function(){ tab.put(Gun.is.graph.ify(reply.body), function(){}, {local: true, peers: {}}) },1); // and flush the in memory nodes of this graph to localStorage after we've had a chance to union on it. 1290 | }); 1291 | Gun.obj.map(opt.peers || gun.__.opt.peers, function(peer, url){ var p = {}; 1292 | tab.request(url, lex, tab.request.s[opt.headers.id], opt); 1293 | cb.peers = true; 1294 | }); 1295 | var node = gun.__.graph[soul]; 1296 | if(node){ 1297 | tab.put(Gun.is.graph.ify(node)); 1298 | } 1299 | } tab.peers(cb); 1300 | } 1301 | tab.put = tab.put || function(graph, cb, opt){ 1302 | //console.log("SAVE", graph); 1303 | cb = cb || function(){}; 1304 | opt = opt || {}; 1305 | (opt.headers = Gun.obj.copy(tab.headers)).id = tab.msg(); 1306 | Gun.is.graph(graph, function(node, soul){ 1307 | if(!gun.__.graph[soul]){ return } 1308 | tab.store.put(tab.prefix + soul, gun.__.graph[soul]); 1309 | }); 1310 | if(!(cb.local = opt.local)){ 1311 | tab.request.s[opt.headers.id] = tab.error(cb, "Error: Put failed!"); 1312 | Gun.obj.map(opt.peers || gun.__.opt.peers, function(peer, url){ 1313 | tab.request(url, graph, tab.request.s[opt.headers.id], opt); 1314 | cb.peers = true; 1315 | }); 1316 | } tab.peers(cb); 1317 | } 1318 | tab.error = function(cb, error, fn){ 1319 | return function(err, reply){ 1320 | reply.body = reply.body || reply.chunk || reply.end || reply.write; 1321 | if(err || !reply || (err = reply.body && reply.body.err)){ 1322 | return cb({err: Gun.log(err || error) }); 1323 | } 1324 | if(fn){ fn(reply) } 1325 | cb(null, reply.body); 1326 | } 1327 | } 1328 | tab.peers = function(cb, o){ 1329 | if(Gun.text.is(cb)){ return (o = {})[cb] = {}, o } 1330 | if(cb && !cb.peers){ setTimeout(function(){ 1331 | if(!cb.local){ if(!Gun.log.count('no-peers')){ Gun.log("Warning! You have no peers to connect to!") } } 1332 | if(!(cb.graph || cb.node)){ cb(null) } 1333 | },1)} 1334 | } 1335 | tab.msg = tab.msg || function(id){ 1336 | if(!id){ 1337 | return tab.msg.debounce[id = Gun.text.random(9)] = Gun.time.is(), id; 1338 | } 1339 | clearTimeout(tab.msg.clear); 1340 | tab.msg.clear = setTimeout(function(){ 1341 | var now = Gun.time.is(); 1342 | Gun.obj.map(tab.msg.debounce, function(t,id){ 1343 | if(now - t < 1000 * 60 * 5){ return } 1344 | Gun.obj.del(tab.msg.debounce, id); 1345 | }); 1346 | },500); 1347 | if(id = tab.msg.debounce[id]){ 1348 | return tab.msg.debounce[id] = Gun.time.is(), id; 1349 | } 1350 | }; 1351 | tab.msg.debounce = tab.msg.debounce || {}; 1352 | tab.server = tab.server || function(req, res){ 1353 | if(!req || !res || !req.body || !req.headers || !req.headers.id){ return } 1354 | if(tab.request.s[req.headers.rid]){ return tab.request.s[req.headers.rid](null, req) } 1355 | if(tab.msg(req.headers.id)){ return } 1356 | // TODO: Re-emit message to other peers if we have any non-overlaping ones. 1357 | if(req.headers.rid){ return } // no need to process 1358 | if(Gun.is.lex(req.body)){ return tab.server.get(req, res) } 1359 | else { return tab.server.put(req, res) } 1360 | } 1361 | tab.server.json = 'application/json'; 1362 | tab.server.regex = gun.__.opt.route = gun.__.opt.route || opt.route || /^\/gun/i; 1363 | tab.server.get = function(req, cb){ 1364 | var soul = req.body[Gun._.soul], node; 1365 | if(!(node = gun.__.graph[soul])){ return } 1366 | var reply = {headers: {'Content-Type': tab.server.json, rid: req.headers.id, id: tab.msg()}}; 1367 | cb({headers: reply.headers, body: node}); 1368 | } 1369 | tab.server.put = function(req, cb){ 1370 | var reply = {headers: {'Content-Type': tab.server.json, rid: req.headers.id, id: tab.msg()}}, keep; 1371 | if(!req.body){ return cb({headers: reply.headers, body: {err: "No body"}}) } 1372 | if(!Gun.obj.is(req.body, function(node, soul){ 1373 | if(gun.__.graph[soul]){ return true } 1374 | })){ return } 1375 | if(req.err = Gun.union(gun, req.body, function(err, ctx){ 1376 | if(err){ return cb({headers: reply.headers, body: {err: err || "Union failed."}}) } 1377 | var ctx = ctx || {}; ctx.graph = {}; 1378 | Gun.is.graph(req.body, function(node, soul){ ctx.graph[soul] = gun.__.graph[soul] }); 1379 | gun.__.opt.wire.put(ctx.graph, function(err, ok){ 1380 | if(err){ return cb({headers: reply.headers, body: {err: err || "Failed."}}) } 1381 | cb({headers: reply.headers, body: {ok: ok || "Persisted."}}); 1382 | }, {local: true, peers: {}}); 1383 | }).err){ cb({headers: reply.headers, body: {err: req.err || "Union failed."}}) } 1384 | } 1385 | Gun.obj.map(gun.__.opt.peers, function(){ // only create server if peers and do it once by returning immediately. 1386 | return (tab.server.able = tab.server.able || tab.request.createServer(tab.server) || true); 1387 | }); 1388 | gun.__.opt.wire.get = gun.__.opt.wire.get || tab.get; 1389 | gun.__.opt.wire.put = gun.__.opt.wire.put || tab.put; 1390 | gun.__.opt.wire.key = gun.__.opt.wire.key || tab.key; 1391 | }); 1392 | 1393 | var request = (function(){ 1394 | function r(base, body, cb, opt){ 1395 | opt = opt || (base.length? {base: base} : base); 1396 | opt.base = opt.base || base; 1397 | opt.body = opt.body || body; 1398 | cb = cb || function(){}; 1399 | if(!opt.base){ return } 1400 | r.transport(opt, cb); 1401 | } 1402 | r.createServer = function(fn){ r.createServer.s.push(fn) } 1403 | r.createServer.ing = function(req, cb){ 1404 | var i = r.createServer.s.length; 1405 | while(i--){ (r.createServer.s[i] || function(){})(req, cb) } 1406 | } 1407 | r.createServer.s = []; 1408 | r.back = 2; r.backoff = 2; 1409 | r.transport = function(opt, cb){ 1410 | //Gun.log("TRANSPORT:", opt); 1411 | if(r.ws(opt, cb)){ return } 1412 | r.jsonp(opt, cb); 1413 | } 1414 | r.ws = function(opt, cb){ 1415 | var ws, WS = window.WebSocket || window.mozWebSocket || window.webkitWebSocket; 1416 | if(!WS){ return } 1417 | if(ws = r.ws.peers[opt.base]){ 1418 | if(!ws.readyState){ return setTimeout(function(){ r.ws(opt, cb) },10), true } 1419 | var req = {}; 1420 | if(opt.headers){ req.headers = opt.headers } 1421 | if(opt.body){ req.body = opt.body } 1422 | if(opt.url){ req.url = opt.url } 1423 | req.headers = req.headers || {}; 1424 | r.ws.cbs[req.headers['ws-rid'] = 'WS' + (+ new Date()) + '.' + Math.floor((Math.random()*65535)+1)] = function(err,res){ 1425 | if(res.body || res.end){ delete r.ws.cbs[req.headers['ws-rid']] } 1426 | cb(err,res); 1427 | } 1428 | ws.send(JSON.stringify(req)); 1429 | return true; 1430 | } 1431 | if(ws === false){ return } 1432 | ws = r.ws.peers[opt.base] = new WS(opt.base.replace('http','ws')); 1433 | ws.onopen = function(o){ r.back = 2; r.ws(opt, cb) }; 1434 | ws.onclose = window.onbeforeunload = function(c){ 1435 | if(!c){ return } 1436 | if(ws && ws.close instanceof Function){ ws.close() } 1437 | if(1006 === c.code){ // websockets cannot be used 1438 | /*ws = r.ws.peers[opt.base] = false; // 1006 has mixed meanings, therefore we can no longer respect it. 1439 | r.transport(opt, cb); 1440 | return;*/ 1441 | } 1442 | ws = r.ws.peers[opt.base] = null; // this will make the next request try to reconnect 1443 | setTimeout(function(){ 1444 | r.ws(opt, function(){}); // opt here is a race condition, is it not? Does this matter? 1445 | }, r.back *= r.backoff); 1446 | }; 1447 | ws.onmessage = function(m){ 1448 | if(!m || !m.data){ return } 1449 | var res; 1450 | try{res = JSON.parse(m.data); 1451 | }catch(e){ return } 1452 | if(!res){ return } 1453 | res.headers = res.headers || {}; 1454 | if(res.headers['ws-rid']){ return (r.ws.cbs[res.headers['ws-rid']]||function(){})(null, res) } 1455 | //Gun.log("We have a pushed message!", res); 1456 | if(res.body){ r.createServer.ing(res, function(res){ r(opt.base, null, null, res)}) } // emit extra events. 1457 | }; 1458 | ws.onerror = function(e){ Gun.log(e); }; 1459 | return true; 1460 | } 1461 | r.ws.peers = {}; 1462 | r.ws.cbs = {}; 1463 | r.jsonp = function(opt, cb){ 1464 | //Gun.log("jsonp send", opt); 1465 | r.jsonp.ify(opt, function(url){ 1466 | //Gun.log(url); 1467 | if(!url){ return } 1468 | r.jsonp.send(url, function(reply){ 1469 | //Gun.log("jsonp reply", reply); 1470 | cb(null, reply); 1471 | r.jsonp.poll(opt, reply); 1472 | }, opt.jsonp); 1473 | }); 1474 | } 1475 | r.jsonp.send = function(url, cb, id){ 1476 | var js = document.createElement('script'); 1477 | js.src = url; 1478 | window[js.id = id] = function(res){ 1479 | cb(res); 1480 | cb.id = js.id; 1481 | js.parentNode.removeChild(js); 1482 | window[cb.id] = null; // TODO: BUG: This needs to handle chunking! 1483 | try{delete window[cb.id]; 1484 | }catch(e){} 1485 | } 1486 | js.async = true; 1487 | document.getElementsByTagName('head')[0].appendChild(js); 1488 | return js; 1489 | } 1490 | r.jsonp.poll = function(opt, res){ 1491 | if(!opt || !opt.base || !res || !res.headers || !res.headers.poll){ return } 1492 | (r.jsonp.poll.s = r.jsonp.poll.s || {})[opt.base] = r.jsonp.poll.s[opt.base] || setTimeout(function(){ // TODO: Need to optimize for Chrome's 6 req limit? 1493 | //Gun.log("polling again"); 1494 | var o = {base: opt.base, headers: {pull: 1}}; 1495 | r.each(opt.headers, function(v,i){ o.headers[i] = v }) 1496 | r.jsonp(o, function(err, reply){ 1497 | delete r.jsonp.poll.s[opt.base]; 1498 | while(reply.body && reply.body.length && reply.body.shift){ // we're assuming an array rather than chunk encoding. :( 1499 | var res = reply.body.shift(); 1500 | //Gun.log("-- go go go", res); 1501 | if(res && res.body){ r.createServer.ing(res, function(){ r(opt.base, null, null, res) }) } // emit extra events. 1502 | } 1503 | }); 1504 | }, res.headers.poll); 1505 | } 1506 | r.jsonp.ify = function(opt, cb){ 1507 | var uri = encodeURIComponent, q = '?'; 1508 | if(opt.url && opt.url.pathname){ q = opt.url.pathname + q; } 1509 | q = opt.base + q; 1510 | r.each((opt.url||{}).query, function(v, i){ q += uri(i) + '=' + uri(v) + '&' }); 1511 | if(opt.headers){ q += uri('`') + '=' + uri(JSON.stringify(opt.headers)) + '&' } 1512 | if(r.jsonp.max < q.length){ return cb() } 1513 | q += uri('jsonp') + '=' + uri(opt.jsonp = 'P'+Math.floor((Math.random()*65535)+1)); 1514 | if(opt.body){ 1515 | q += '&'; 1516 | var w = opt.body, wls = function(w,l,s){ 1517 | return uri('%') + '=' + uri(w+'-'+(l||w)+'/'+(s||w)) + '&' + uri('$') + '='; 1518 | } 1519 | if(typeof w != 'string'){ 1520 | w = JSON.stringify(w); 1521 | q += uri('^') + '=' + uri('json') + '&'; 1522 | } 1523 | w = uri(w); 1524 | var i = 0, l = w.length 1525 | , s = r.jsonp.max - (q.length + wls(l.toString()).length); 1526 | if(s < 0){ return cb() } 1527 | while(w){ 1528 | cb(q + wls(i, (i = i + s), l) + w.slice(0, i)); 1529 | w = w.slice(i); 1530 | } 1531 | } else { 1532 | cb(q); 1533 | } 1534 | } 1535 | r.jsonp.max = 2000; 1536 | r.each = function(obj, cb){ 1537 | if(!obj || !cb){ return } 1538 | for(var i in obj){ 1539 | if(obj.hasOwnProperty(i)){ 1540 | cb(obj[i], i); 1541 | } 1542 | } 1543 | } 1544 | return r; 1545 | }()); 1546 | }({})); 1547 | 1548 | /***/ }, 1549 | /* 3 */ 1550 | /***/ function(module, exports, __webpack_require__) { 1551 | 1552 | /*jslint node: true*/ 1553 | 'use strict'; 1554 | var Gun = __webpack_require__(2); 1555 | 1556 | var players, gun = new Gun(location + 'gun'); 1557 | 1558 | // synchronous extension 1559 | __webpack_require__(4); 1560 | 1561 | // network time sync extension 1562 | //require('../lib/nts'); 1563 | 1564 | 1565 | 1566 | Gun.chain.stringify = function (obj) { 1567 | return this.put(JSON.stringify(obj)); 1568 | }; 1569 | 1570 | 1571 | module.exports = { 1572 | gun: gun, 1573 | 1574 | players: { 1575 | db: gun.get('players').sync(players = {}), 1576 | list: players 1577 | }, 1578 | 1579 | player: { 1580 | db: null, 1581 | object: null, 1582 | index: null 1583 | }, 1584 | 1585 | justJoined: false 1586 | }; 1587 | 1588 | 1589 | /***/ }, 1590 | /* 4 */ 1591 | /***/ function(module, exports, __webpack_require__) { 1592 | 1593 | (function (env) { 1594 | var Gun = env.window ? env.window.Gun : __webpack_require__(2); 1595 | 1596 | Gun.chain.sync = function (obj, opt) { 1597 | var gun = this; 1598 | if (!Gun.obj.is(obj)) { 1599 | console.log("First parameter is not an object to synchronize too!"); 1600 | return gun; 1601 | } 1602 | if (Gun.bi.is(opt)) { 1603 | opt = { 1604 | meta: opt 1605 | }; 1606 | } 1607 | opt = opt || {}; 1608 | opt.ctx = opt.ctx || {}; 1609 | gun.on(function (change, field) { 1610 | Gun.obj.map(change, function (val, field) { 1611 | if (!obj) { 1612 | return 1613 | } 1614 | if (Gun._.meta == field || field === Gun._.soul) { 1615 | if (opt.meta) { 1616 | obj[field] = val; 1617 | } 1618 | return; 1619 | } 1620 | if (Gun.obj.is(val)) { 1621 | var soul = Gun.is.rel(val); 1622 | if (opt.ctx[soul + field]) { 1623 | return 1624 | } // do not re-subscribe. 1625 | opt.ctx[soul + field] = true; // unique subscribe! 1626 | this.path(field).sync(obj[field] = obj[field] || {}, Gun.obj.copy(opt)); 1627 | return; 1628 | } 1629 | obj[field] = val; 1630 | }, this); 1631 | }); 1632 | return gun; 1633 | } 1634 | 1635 | }(this)); 1636 | 1637 | 1638 | /***/ }, 1639 | /* 5 */ 1640 | /***/ function(module, exports, __webpack_require__) { 1641 | 1642 | /*jslint node: true*/ 1643 | 'use strict'; 1644 | 1645 | var local = __webpack_require__(3); 1646 | var player = local.player; 1647 | var players = local.players; 1648 | var Gun = __webpack_require__(2); 1649 | var position = __webpack_require__(6); 1650 | var options = __webpack_require__(7); 1651 | var invincible = __webpack_require__(8); 1652 | 1653 | 1654 | // join the game 1655 | module.exports = function (number) { 1656 | var start, color, time = Gun.time.is(); 1657 | 1658 | player.db = players.db.path(number).put({}); 1659 | player.index = number; 1660 | player.object = players.list[number]; 1661 | 1662 | // get the player starting point 1663 | start = position(number); 1664 | player.db.path(time).stringify(start); 1665 | 1666 | // give the player a chance to escape 1667 | invincible.player(player.index, true); 1668 | }; 1669 | 1670 | 1671 | /***/ }, 1672 | /* 6 */ 1673 | /***/ function(module, exports) { 1674 | 1675 | /*jslint node: true*/ 1676 | 'use strict'; 1677 | 1678 | // naive static starting point for players 1679 | module.exports = function (player) { 1680 | switch (player) { 1681 | case '1': 1682 | return { 1683 | x: 100, 1684 | y: 100, 1685 | direction: 1, 1686 | axis: 'y' 1687 | }; 1688 | case '2': 1689 | return { 1690 | x: 600, 1691 | y: 100, 1692 | direction: -1, 1693 | axis: 'x' 1694 | }; 1695 | case '3': 1696 | return { 1697 | x: 600, 1698 | y: 600, 1699 | direction: -1, 1700 | axis: 'y' 1701 | }; 1702 | case '4': 1703 | return { 1704 | x: 100, 1705 | y: 600, 1706 | direction: 1, 1707 | axis: 'x' 1708 | }; 1709 | } 1710 | }; 1711 | 1712 | 1713 | /***/ }, 1714 | /* 7 */ 1715 | /***/ function(module, exports) { 1716 | 1717 | /*jslint node: true*/ 1718 | module.exports = { 1719 | speed: 0.1, 1720 | width: 3, 1721 | background: "#202428", 1722 | colors: [ 1723 | "#18c956", 1724 | "#0075c4", 1725 | "#ff6044", 1726 | "#f2cc6d" 1727 | ], 1728 | invincibility: 3000, 1729 | blinkSpeed: 125, 1730 | latency: 3000 1731 | }; 1732 | 1733 | 1734 | /***/ }, 1735 | /* 8 */ 1736 | /***/ function(module, exports, __webpack_require__) { 1737 | 1738 | /*jslint node: true*/ 1739 | 'use strict'; 1740 | 1741 | var options = __webpack_require__(7); 1742 | var local = __webpack_require__(3); 1743 | var style = options.colors; 1744 | var list, timeouts, intervals, colors; 1745 | intervals = {}; 1746 | timeouts = {}; 1747 | 1748 | // create a copy of the colors object 1749 | colors = JSON.parse( 1750 | JSON.stringify(options.colors) 1751 | ); 1752 | var db = local.gun.get('invincible').sync(list = {}); 1753 | 1754 | function blink(player) { 1755 | var index = player - 1; 1756 | intervals[player] = setInterval(function () { 1757 | 1758 | style[index] = style[index] === colors[index] ? 'darkgray' : colors[index]; 1759 | }, options.blinkSpeed); 1760 | } 1761 | 1762 | function invincible(player, bool) { 1763 | db.path(player).put(bool); 1764 | 1765 | if (!bool) { 1766 | clearTimeout(timeouts[player]); 1767 | timeouts[player] = null; 1768 | style[player - 1] = colors[player - 1]; 1769 | } 1770 | } 1771 | 1772 | 1773 | db.map(function (immortal, player) { 1774 | if (!immortal) { 1775 | clearInterval(intervals[player]); 1776 | intervals[player] = null; 1777 | } else if (!intervals[player]) { 1778 | blink(player); 1779 | timeouts[player] = setTimeout(function () { 1780 | invincible(player, false); 1781 | }, options.invincibility); 1782 | } 1783 | }); 1784 | 1785 | module.exports = window.i = { 1786 | player: invincible, 1787 | list: list 1788 | }; 1789 | 1790 | 1791 | /***/ }, 1792 | /* 9 */ 1793 | /***/ function(module, exports, __webpack_require__) { 1794 | 1795 | /*jslint node: true*/ 1796 | /*globals gun, stream, players */ 1797 | 'use strict'; 1798 | 1799 | var local = __webpack_require__(3); 1800 | var invincible = __webpack_require__(8); 1801 | 1802 | module.exports = function (player, done) { 1803 | var join = __webpack_require__(1); 1804 | invincible.player(player.index, false); 1805 | 1806 | local.players.db.path(player.index).put(null); 1807 | player.object = null; 1808 | player.index = null; 1809 | player.db = null; 1810 | 1811 | if (!done) { 1812 | join(); 1813 | } 1814 | }; 1815 | 1816 | 1817 | /***/ }, 1818 | /* 10 */ 1819 | /***/ function(module, exports, __webpack_require__) { 1820 | 1821 | /*jslint node: true*/ 1822 | 'use strict'; 1823 | 1824 | var Gun = __webpack_require__(2); 1825 | var Canvas = __webpack_require__(11); 1826 | var local = __webpack_require__(3); 1827 | var sort = __webpack_require__(12); 1828 | var find = __webpack_require__(13); 1829 | var options = __webpack_require__(7); 1830 | var players = local.players.list; 1831 | 1832 | var canvas = new Canvas({ 1833 | width: 700, 1834 | height: 700 1835 | }); 1836 | 1837 | // self invoke and begin the render loop 1838 | module.exports = function () { 1839 | // start fresh 1840 | canvas.clear(options.background); 1841 | 1842 | // for each player... 1843 | Gun.obj.map(players, function (player, index) { 1844 | // get their lines 1845 | var lines = sort(player); 1846 | if (lines.length) { 1847 | 1848 | // add the player's current location 1849 | lines.push(find(player)); 1850 | 1851 | // draw each turn on the canvas 1852 | canvas.width(options.width); 1853 | lines.forEach(canvas.line); 1854 | canvas.stroke(options.colors[index - 1]); 1855 | } 1856 | }); 1857 | 1858 | }; 1859 | 1860 | 1861 | /***/ }, 1862 | /* 11 */ 1863 | /***/ function(module, exports) { 1864 | 1865 | /*jslint node: true*/ 1866 | 'use strict'; 1867 | 1868 | var line, canvas, context; 1869 | var color = '#303438'; 1870 | var height = 10; 1871 | var width = 10; 1872 | 1873 | var last = { 1874 | dimension: width 1875 | }; 1876 | 1877 | function Canvas(options) { 1878 | if (!(this instanceof Canvas)) { 1879 | return new Canvas(options); 1880 | } 1881 | canvas = canvas || document.querySelector('canvas'); 1882 | context = canvas.getContext('2d'); 1883 | if (options && options.width && options.height) { 1884 | canvas.width = options.width; 1885 | canvas.height = options.height; 1886 | } 1887 | } 1888 | 1889 | Canvas.prototype = { 1890 | constructor: Canvas, 1891 | 1892 | color: function (style) { 1893 | if (!style) { 1894 | return this; 1895 | } 1896 | color = style; 1897 | last.color = style; 1898 | 1899 | return this; 1900 | }, 1901 | 1902 | width: function (setting) { 1903 | width = setting; 1904 | last.dimension = setting; 1905 | 1906 | return this; 1907 | }, 1908 | 1909 | height: function (setting) { 1910 | height = setting; 1911 | last.dimension = setting; 1912 | 1913 | return this; 1914 | }, 1915 | 1916 | ratio: function (string) { 1917 | var setting = string.split(':'); 1918 | return this.width(setting[0]).height(setting[1]); 1919 | }, 1920 | 1921 | rect: function (coord) { 1922 | context.beginPath(); 1923 | context.rect(coord.x, coord.y, width, height); 1924 | 1925 | return this; 1926 | }, 1927 | 1928 | square: function (coord) { 1929 | return this 1930 | .height(last.dimension) 1931 | .width(last.dimension) 1932 | .rect(coord); 1933 | }, 1934 | 1935 | line: function (coord) { 1936 | var c = context; 1937 | c.lineWidth = width; 1938 | c.strokeWidth = width; 1939 | 1940 | if (!line) { 1941 | line = coord; 1942 | c.beginPath(); 1943 | c.moveTo(coord.x, coord.y); 1944 | } else { 1945 | c.lineTo(coord.x, coord.y); 1946 | } 1947 | 1948 | return this; 1949 | }, 1950 | 1951 | stroke: function (style) { 1952 | this.color(style); 1953 | line = undefined; 1954 | context.strokeStyle = color; 1955 | context.stroke(); 1956 | context.closePath(); 1957 | 1958 | return this; 1959 | }, 1960 | 1961 | fill: function (style) { 1962 | this.color(style); 1963 | context.fillStyle = color; 1964 | context.fill(); 1965 | context.closePath(); 1966 | 1967 | return this; 1968 | }, 1969 | 1970 | clear: function (style) { 1971 | var c = canvas; 1972 | if (style) { 1973 | this.color(style); 1974 | } 1975 | 1976 | return this.height( 1977 | c.height 1978 | ).width( 1979 | c.width 1980 | ).rect({ 1981 | x: 0, 1982 | y: 0 1983 | }).fill(); 1984 | } 1985 | }; 1986 | 1987 | module.exports = Canvas; 1988 | 1989 | 1990 | /***/ }, 1991 | /* 12 */ 1992 | /***/ function(module, exports) { 1993 | 1994 | /*jslint node: true*/ 1995 | 'use strict'; 1996 | 1997 | module.exports = function (player) { 1998 | var turns, position; 1999 | if (!player) { 2000 | return []; 2001 | } 2002 | 2003 | return Object.keys(player).sort().map(function (key) { 2004 | var coord = JSON.parse(player[key]); 2005 | coord.time = parseInt(key, 10); 2006 | return coord; 2007 | }); 2008 | 2009 | }; 2010 | 2011 | 2012 | /***/ }, 2013 | /* 13 */ 2014 | /***/ function(module, exports, __webpack_require__) { 2015 | 2016 | /*jslint node: true*/ 2017 | 'use strict'; 2018 | var Gun = __webpack_require__(2); 2019 | var sort = __webpack_require__(12); 2020 | 2021 | 2022 | // for distance traveled 2023 | var options = { 2024 | speed: 0.1 2025 | }; 2026 | 2027 | /* 2028 | figure out where the player 2029 | a player is from where they 2030 | last turned, and how fast they 2031 | are travelling. 2032 | */ 2033 | function distance(coord) { 2034 | var delta, elapsed = Gun.time.is() - coord.time; 2035 | delta = (elapsed * options.speed) * coord.direction; 2036 | 2037 | return delta + coord[coord.axis]; 2038 | } 2039 | 2040 | // find the current coordinate of the player 2041 | module.exports = function find(player) { 2042 | var coord, position; 2043 | coord = sort(player); 2044 | coord = coord[coord.length - 1]; 2045 | 2046 | // if the player has no history 2047 | if (!coord) { 2048 | return null; 2049 | } 2050 | 2051 | // don't mutate the last position, make a copy 2052 | position = Gun.obj.copy(coord); 2053 | 2054 | position[coord.axis] = distance(coord); 2055 | position.time = Gun.time.is(); 2056 | 2057 | return position; 2058 | }; 2059 | 2060 | 2061 | /***/ }, 2062 | /* 14 */ 2063 | /***/ function(module, exports, __webpack_require__) { 2064 | 2065 | /*jslint plusplus: true, node: true */ 2066 | 'use strict'; 2067 | var Gun = __webpack_require__(2); 2068 | var local = __webpack_require__(3); 2069 | var find = __webpack_require__(13); 2070 | var path = __webpack_require__(15); 2071 | var kick = __webpack_require__(9); 2072 | var sort = __webpack_require__(12); 2073 | var line = __webpack_require__(16); 2074 | var invincible = __webpack_require__(8); 2075 | var players = local.players; 2076 | var player = local.player; 2077 | var position, prev, boundary = 700; 2078 | 2079 | function tail() { 2080 | 2081 | // we're not playing yet 2082 | if (!position) { 2083 | return null; 2084 | } 2085 | if (!prev) { 2086 | prev = position; 2087 | } 2088 | 2089 | /* 2090 | If we've turned since the last 2091 | collision check, use that turn 2092 | as our last position. 2093 | */ 2094 | if (prev.axis !== position.axis) { 2095 | prev = sort(player.object); 2096 | prev = prev[prev.length - 1]; 2097 | } 2098 | 2099 | // figure out the path between renders 2100 | return line(prev, position); 2101 | } 2102 | 2103 | 2104 | 2105 | 2106 | 2107 | 2108 | 2109 | 2110 | 2111 | function outOfBounds() { 2112 | var overflow = {}; 2113 | 2114 | overflow.x = position.x > boundary || position.x < 0; 2115 | overflow.y = position.y > boundary || position.y < 0; 2116 | return (overflow.x || overflow.y); 2117 | } 2118 | 2119 | function inPath(line) { 2120 | var onLeft, onRight, perp; 2121 | perp = (position.axis === 'x') ? 'y' : 'x'; 2122 | onLeft = line.start < position[perp]; 2123 | onRight = line.end > position[perp]; 2124 | 2125 | if (onLeft && onRight) { 2126 | return true; 2127 | } 2128 | return false; 2129 | } 2130 | 2131 | function crossing(line) { 2132 | // find the path from your last render 2133 | 2134 | var prev = tail(); 2135 | if (line.offset >= prev.start && line.offset <= prev.end) { 2136 | return true; 2137 | } 2138 | if (line.offset <= prev.start && line.offset >= prev.end) { 2139 | return true; 2140 | } 2141 | return false; 2142 | } 2143 | 2144 | function collision() { 2145 | var lines = []; 2146 | 2147 | // add every player's history to the list of lines 2148 | Gun.obj.map(players.list, function (player, number) { 2149 | var history = path(player); 2150 | lines = lines.concat(history); 2151 | }); 2152 | 2153 | /* 2154 | Filter out lines that aren't dangerous, 2155 | then filter out the ones that aren't in 2156 | your way, then filter out the ones you're 2157 | not overlapping with. 2158 | */ 2159 | return lines.filter(function (line) { 2160 | return line.axis !== position.axis; 2161 | }).filter(inPath).filter(crossing).length; 2162 | } 2163 | 2164 | module.exports = function () { 2165 | position = find(player.object); 2166 | 2167 | if (position) { 2168 | var dead = outOfBounds(); 2169 | if (!invincible.list[player.index]) { 2170 | dead = dead || collision(); 2171 | } 2172 | if (dead) { 2173 | kick(player); 2174 | prev = null; 2175 | } 2176 | } 2177 | 2178 | /* 2179 | After we've run the collision logic, 2180 | update our last position with the 2181 | current position. 2182 | */ 2183 | prev = position; 2184 | }; 2185 | 2186 | 2187 | /***/ }, 2188 | /* 15 */ 2189 | /***/ function(module, exports, __webpack_require__) { 2190 | 2191 | /*jslint node: true*/ 2192 | 'use strict'; 2193 | var find = __webpack_require__(13); 2194 | var sort = __webpack_require__(12); 2195 | var line = __webpack_require__(16); 2196 | 2197 | module.exports = function path(player) { 2198 | var position, lines; 2199 | if (!player) { 2200 | return []; 2201 | } 2202 | 2203 | lines = sort(player); 2204 | position = find(player); 2205 | if (!lines.length) { 2206 | return []; 2207 | } 2208 | 2209 | lines.push(position); 2210 | return lines.map(function (start, i) { 2211 | if (i === lines.length - 1) { 2212 | return; 2213 | } 2214 | var end = lines[i + 1]; 2215 | return line(start, end); 2216 | }).filter(Boolean); 2217 | }; 2218 | 2219 | 2220 | /***/ }, 2221 | /* 16 */ 2222 | /***/ function(module, exports) { 2223 | 2224 | /*jslint node: true*/ 2225 | 'use strict'; 2226 | 2227 | module.exports = function (start, end) { 2228 | if (!start || !end) { 2229 | return null; 2230 | } 2231 | var temp, perp, axis = start.axis; 2232 | perp = (axis === 'x') ? 'y' : 'x'; 2233 | 2234 | // always record going from top to bottom, left to right 2235 | if (start[axis] > end[axis]) { 2236 | temp = start; 2237 | start = end; 2238 | end = temp; 2239 | } 2240 | 2241 | return { 2242 | start: start[axis], 2243 | end: end[axis], 2244 | offset: end[perp], 2245 | axis: axis 2246 | }; 2247 | }; 2248 | 2249 | 2250 | /***/ }, 2251 | /* 17 */ 2252 | /***/ function(module, exports, __webpack_require__) { 2253 | 2254 | /*jslint node: true*/ 2255 | /*globals stream */ 2256 | 'use strict'; 2257 | 2258 | var turn = __webpack_require__(18); 2259 | 2260 | var xDown, yDown, canvas; 2261 | canvas = document.querySelector('canvas'); 2262 | 2263 | function turn(direction) { 2264 | console.log(direction); 2265 | } 2266 | 2267 | function tie(cb) { 2268 | return { 2269 | to: function (event, target) { 2270 | (target || document).addEventListener(event, cb); 2271 | } 2272 | }; 2273 | } 2274 | 2275 | // listen for game input 2276 | function keyboard(e) { 2277 | switch (e.keyCode) { 2278 | case 65: 2279 | case 37: 2280 | return turn('left'); 2281 | case 68: 2282 | case 39: 2283 | return turn('right'); 2284 | case 87: 2285 | case 38: 2286 | return turn('up'); 2287 | case 83: 2288 | case 40: 2289 | return turn('down'); 2290 | } 2291 | } 2292 | 2293 | 2294 | 2295 | /* 2296 | shamelessly copied from 2297 | a stackoverflow post: 2298 | http://stackoverflow.com/questions/2264072/detect-a-finger-swipe-through-javascript-on-the-iphone-and-android#answer-23230280 2299 | */ 2300 | function touch(e) { 2301 | xDown = e.touches[0].clientX; 2302 | yDown = e.touches[0].clientY; 2303 | } 2304 | 2305 | function move(e) { 2306 | if (!xDown || !yDown) { 2307 | return; 2308 | } 2309 | 2310 | var xUp, yUp, xDiff, yDiff; 2311 | xUp = e.touches[0].clientX; 2312 | yUp = e.touches[0].clientY; 2313 | xDiff = xDown - xUp; 2314 | yDiff = yDown - yUp; 2315 | 2316 | xDown = null; 2317 | yDown = null; 2318 | 2319 | if (Math.abs(xDiff) > Math.abs(yDiff)) { 2320 | return xDiff > 0 ? turn('left') : turn('right'); 2321 | } else { 2322 | return yDiff > 0 ? turn('up') : turn('down'); 2323 | } 2324 | } 2325 | 2326 | 2327 | function resize() { 2328 | var width = window.innerWidth, 2329 | height = window.innerHeight; 2330 | 2331 | if (height > width) { 2332 | // Centering 2333 | canvas.style.left = 0; 2334 | canvas.style.top = (height / 2) - (width / 2) + 'px'; 2335 | 2336 | canvas.style.width = width + "px"; 2337 | canvas.style.height = width + "px"; 2338 | } else { 2339 | // Centering 2340 | canvas.style.top = 0; 2341 | canvas.style.left = (width / 2) - (height / 2) + 'px'; 2342 | 2343 | canvas.style.width = height + "px"; 2344 | canvas.style.height = height + "px"; 2345 | } 2346 | } 2347 | 2348 | 2349 | tie(keyboard).to('keydown'); 2350 | tie(touch).to('touchstart'); 2351 | tie(move).to('touchmove'); 2352 | tie(resize).to('resize', window); 2353 | 2354 | // initial canvas sizing 2355 | resize(); 2356 | 2357 | 2358 | /***/ }, 2359 | /* 18 */ 2360 | /***/ function(module, exports, __webpack_require__) { 2361 | 2362 | /*jslint node: true*/ 2363 | 'use strict'; 2364 | 2365 | var Gun = __webpack_require__(2); 2366 | var find = __webpack_require__(13); 2367 | var local = __webpack_require__(3); 2368 | 2369 | function turn(axis, direction) { 2370 | var position = find(local.player.object); 2371 | 2372 | return { 2373 | direction: direction, 2374 | x: position.x, 2375 | y: position.y, 2376 | axis: axis 2377 | }; 2378 | } 2379 | 2380 | function extract(axis, direction) { 2381 | if (!direction) { 2382 | switch (axis) { 2383 | case 'up': 2384 | return extract('y', -1); 2385 | case 'down': 2386 | return extract('y', 1); 2387 | case 'left': 2388 | return extract('x', -1); 2389 | case 'right': 2390 | return extract('x', 1); 2391 | } 2392 | } 2393 | return turn(axis, direction); 2394 | } 2395 | 2396 | 2397 | module.exports = function (direction) { 2398 | var time, turn, position; 2399 | position = find(local.player.object); 2400 | if (!position) { 2401 | return; 2402 | } 2403 | turn = extract(direction); 2404 | time = Gun.time.is(); 2405 | 2406 | if (position.axis === turn.axis) { 2407 | return; 2408 | } 2409 | 2410 | local.player.db.path(time).stringify(turn); 2411 | }; 2412 | 2413 | 2414 | /***/ } 2415 | /******/ ]); 2416 | -------------------------------------------------------------------------------- /dist/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Trace by gunDB 6 | 7 | 8 | 26 | 27 | 28 | 29 | 30 | Your browser doesn't support <canvas>. 31 | Upgrade quick, before your friends find out! 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /lib/nts.js: -------------------------------------------------------------------------------- 1 | Gun.on('opt').event(function(gun, opt){ 2 | if(!gun.tab || !gun.tab.request){ return } 3 | Gun.time.is.drift = 0; 4 | (function ping(){ 5 | Gun.obj.map(opt.peers || gun.__.opt.peers, function(peer, url){ 6 | var NTS = {}; 7 | NTS.start = Gun.time.is(); 8 | gun.tab.request(url, null, function(err, reply){ 9 | if(err || !reply || !reply.body){ 10 | return console.log("Network Time Synchronization not supported", err, (reply || {}).body); 11 | } 12 | NTS.end = Gun.time.is(); 13 | NTS.latency = (NTS.end - NTS.start)/2; 14 | if(!Gun.obj.has(reply.body, 'time')){ return } 15 | console.log(reply.body); 16 | NTS.calc = NTS.latency + reply.body.time; 17 | Gun.time.is.drift -= (NTS.end - NTS.calc)/2; 18 | setTimeout(ping, 50); 19 | }, {url: {pathname: '.nts'}}); 20 | }); 21 | }()); 22 | }); 23 | // You need to figure out how to make me write tests for this! 24 | // maybe we can do human based testing where we load a HTML that just 25 | // prints out in BIG FONT the objectiveTime it thinks it is 26 | // and we open it up on a couple devices. 27 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tron", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "accepts": { 8 | "version": "1.3.4", 9 | "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.4.tgz", 10 | "integrity": "sha1-hiRnWMfdbSGmR0/whKR0DsBesh8=", 11 | "requires": { 12 | "mime-types": "2.1.17", 13 | "negotiator": "0.6.1" 14 | } 15 | }, 16 | "acorn": { 17 | "version": "3.3.0", 18 | "resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz", 19 | "integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=", 20 | "dev": true 21 | }, 22 | "align-text": { 23 | "version": "0.1.4", 24 | "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", 25 | "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", 26 | "dev": true, 27 | "requires": { 28 | "kind-of": "3.2.2", 29 | "longest": "1.0.1", 30 | "repeat-string": "1.6.1" 31 | } 32 | }, 33 | "amdefine": { 34 | "version": "1.0.1", 35 | "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", 36 | "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=", 37 | "dev": true 38 | }, 39 | "anymatch": { 40 | "version": "1.3.2", 41 | "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-1.3.2.tgz", 42 | "integrity": "sha512-0XNayC8lTHQ2OI8aljNCN3sSx6hsr/1+rlcDAotXJR7C1oZZHCNsfpbKwMjRA3Uqb5tF1Rae2oloTr4xpq+WjA==", 43 | "dev": true, 44 | "requires": { 45 | "micromatch": "2.3.11", 46 | "normalize-path": "2.1.1" 47 | } 48 | }, 49 | "arr-diff": { 50 | "version": "2.0.0", 51 | "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz", 52 | "integrity": "sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=", 53 | "dev": true, 54 | "requires": { 55 | "arr-flatten": "1.1.0" 56 | } 57 | }, 58 | "arr-flatten": { 59 | "version": "1.1.0", 60 | "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", 61 | "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", 62 | "dev": true 63 | }, 64 | "array-flatten": { 65 | "version": "1.1.1", 66 | "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", 67 | "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" 68 | }, 69 | "array-unique": { 70 | "version": "0.2.1", 71 | "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz", 72 | "integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM=", 73 | "dev": true 74 | }, 75 | "assert": { 76 | "version": "1.4.1", 77 | "resolved": "https://registry.npmjs.org/assert/-/assert-1.4.1.tgz", 78 | "integrity": "sha1-mZEtWRg2tab1s0XA8H7vwI/GXZE=", 79 | "dev": true, 80 | "requires": { 81 | "util": "0.10.3" 82 | } 83 | }, 84 | "async": { 85 | "version": "1.5.2", 86 | "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", 87 | "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", 88 | "dev": true 89 | }, 90 | "async-each": { 91 | "version": "1.0.1", 92 | "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.1.tgz", 93 | "integrity": "sha1-GdOGodntxufByF04iu28xW0zYC0=", 94 | "dev": true 95 | }, 96 | "aws-sdk": { 97 | "version": "2.0.31", 98 | "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.0.31.tgz", 99 | "integrity": "sha1-5yzx/caQFb2f0r3z07iMFlB9Jo4=", 100 | "requires": { 101 | "xml2js": "0.2.6", 102 | "xmlbuilder": "0.4.2" 103 | } 104 | }, 105 | "balanced-match": { 106 | "version": "1.0.0", 107 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", 108 | "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", 109 | "dev": true 110 | }, 111 | "base64-js": { 112 | "version": "1.2.1", 113 | "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.2.1.tgz", 114 | "integrity": "sha512-dwVUVIXsBZXwTuwnXI9RK8sBmgq09NDHzyR9SAph9eqk76gKK2JSQmZARC2zRC81JC2QTtxD0ARU5qTS25gIGw==", 115 | "dev": true 116 | }, 117 | "big.js": { 118 | "version": "3.2.0", 119 | "resolved": "https://registry.npmjs.org/big.js/-/big.js-3.2.0.tgz", 120 | "integrity": "sha512-+hN/Zh2D08Mx65pZ/4g5bsmNiZUuChDiQfTUQ7qJr4/kuopCr88xZsAXv6mBoZEsUI4OuGHlX59qE94K2mMW8Q==", 121 | "dev": true 122 | }, 123 | "binary-extensions": { 124 | "version": "1.11.0", 125 | "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.11.0.tgz", 126 | "integrity": "sha1-RqoXUftqL5PuXmibsQh9SxTGwgU=", 127 | "dev": true 128 | }, 129 | "body-parser": { 130 | "version": "1.18.2", 131 | "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.2.tgz", 132 | "integrity": "sha1-h2eKGdhLR9hZuDGZvVm84iKxBFQ=", 133 | "requires": { 134 | "bytes": "3.0.0", 135 | "content-type": "1.0.4", 136 | "debug": "2.6.9", 137 | "depd": "1.1.2", 138 | "http-errors": "1.6.2", 139 | "iconv-lite": "0.4.19", 140 | "on-finished": "2.3.0", 141 | "qs": "6.5.1", 142 | "raw-body": "2.3.2", 143 | "type-is": "1.6.15" 144 | } 145 | }, 146 | "brace-expansion": { 147 | "version": "1.1.8", 148 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", 149 | "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", 150 | "dev": true, 151 | "requires": { 152 | "balanced-match": "1.0.0", 153 | "concat-map": "0.0.1" 154 | } 155 | }, 156 | "braces": { 157 | "version": "1.8.5", 158 | "resolved": "https://registry.npmjs.org/braces/-/braces-1.8.5.tgz", 159 | "integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=", 160 | "dev": true, 161 | "requires": { 162 | "expand-range": "1.8.2", 163 | "preserve": "0.2.0", 164 | "repeat-element": "1.1.2" 165 | } 166 | }, 167 | "browserify-aes": { 168 | "version": "0.4.0", 169 | "resolved": "https://registry.npmjs.org/browserify-aes/-/browserify-aes-0.4.0.tgz", 170 | "integrity": "sha1-BnFJtmjfMcS1hTPgLQHoBthgjiw=", 171 | "dev": true, 172 | "requires": { 173 | "inherits": "2.0.3" 174 | } 175 | }, 176 | "browserify-zlib": { 177 | "version": "0.1.4", 178 | "resolved": "https://registry.npmjs.org/browserify-zlib/-/browserify-zlib-0.1.4.tgz", 179 | "integrity": "sha1-uzX4pRn2AOD6a4SFJByXnQFB+y0=", 180 | "dev": true, 181 | "requires": { 182 | "pako": "0.2.9" 183 | } 184 | }, 185 | "buffer": { 186 | "version": "4.9.1", 187 | "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", 188 | "integrity": "sha1-bRu2AbB6TvztlwlBMgkwJ8lbwpg=", 189 | "dev": true, 190 | "requires": { 191 | "base64-js": "1.2.1", 192 | "ieee754": "1.1.8", 193 | "isarray": "1.0.0" 194 | } 195 | }, 196 | "builtin-status-codes": { 197 | "version": "3.0.0", 198 | "resolved": "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz", 199 | "integrity": "sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug=", 200 | "dev": true 201 | }, 202 | "bytes": { 203 | "version": "3.0.0", 204 | "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", 205 | "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" 206 | }, 207 | "camelcase": { 208 | "version": "1.2.1", 209 | "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", 210 | "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", 211 | "dev": true 212 | }, 213 | "center-align": { 214 | "version": "0.1.3", 215 | "resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz", 216 | "integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=", 217 | "dev": true, 218 | "requires": { 219 | "align-text": "0.1.4", 220 | "lazy-cache": "1.0.4" 221 | } 222 | }, 223 | "chokidar": { 224 | "version": "1.7.0", 225 | "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.7.0.tgz", 226 | "integrity": "sha1-eY5ol3gVHIB2tLNg5e3SjNortGg=", 227 | "dev": true, 228 | "requires": { 229 | "anymatch": "1.3.2", 230 | "async-each": "1.0.1", 231 | "fsevents": "1.1.3", 232 | "glob-parent": "2.0.0", 233 | "inherits": "2.0.3", 234 | "is-binary-path": "1.0.1", 235 | "is-glob": "2.0.1", 236 | "path-is-absolute": "1.0.1", 237 | "readdirp": "2.1.0" 238 | } 239 | }, 240 | "cliui": { 241 | "version": "2.1.0", 242 | "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", 243 | "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", 244 | "dev": true, 245 | "requires": { 246 | "center-align": "0.1.3", 247 | "right-align": "0.1.3", 248 | "wordwrap": "0.0.2" 249 | }, 250 | "dependencies": { 251 | "wordwrap": { 252 | "version": "0.0.2", 253 | "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", 254 | "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=", 255 | "dev": true 256 | } 257 | } 258 | }, 259 | "clone": { 260 | "version": "1.0.3", 261 | "resolved": "https://registry.npmjs.org/clone/-/clone-1.0.3.tgz", 262 | "integrity": "sha1-KY1+IjFmD0DAA8LtMUDezz9TCF8=", 263 | "dev": true 264 | }, 265 | "concat-map": { 266 | "version": "0.0.1", 267 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 268 | "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", 269 | "dev": true 270 | }, 271 | "console-browserify": { 272 | "version": "1.1.0", 273 | "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz", 274 | "integrity": "sha1-8CQcRXMKn8YyOyBtvzjtx0HQuxA=", 275 | "dev": true, 276 | "requires": { 277 | "date-now": "0.1.4" 278 | } 279 | }, 280 | "constants-browserify": { 281 | "version": "1.0.0", 282 | "resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-1.0.0.tgz", 283 | "integrity": "sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U=", 284 | "dev": true 285 | }, 286 | "content-disposition": { 287 | "version": "0.5.2", 288 | "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", 289 | "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=" 290 | }, 291 | "content-type": { 292 | "version": "1.0.4", 293 | "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", 294 | "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" 295 | }, 296 | "cookie": { 297 | "version": "0.3.1", 298 | "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", 299 | "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=" 300 | }, 301 | "cookie-signature": { 302 | "version": "1.0.6", 303 | "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", 304 | "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" 305 | }, 306 | "core-util-is": { 307 | "version": "1.0.2", 308 | "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", 309 | "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", 310 | "dev": true 311 | }, 312 | "crypto-browserify": { 313 | "version": "3.3.0", 314 | "resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.3.0.tgz", 315 | "integrity": "sha1-ufx1u0oO1h3PHNXa6W6zDJw+UGw=", 316 | "dev": true, 317 | "requires": { 318 | "browserify-aes": "0.4.0", 319 | "pbkdf2-compat": "2.0.1", 320 | "ripemd160": "0.2.0", 321 | "sha.js": "2.2.6" 322 | } 323 | }, 324 | "date-now": { 325 | "version": "0.1.4", 326 | "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", 327 | "integrity": "sha1-6vQ5/U1ISK105cx9vvIAZyueNFs=", 328 | "dev": true 329 | }, 330 | "debug": { 331 | "version": "2.6.9", 332 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", 333 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", 334 | "requires": { 335 | "ms": "2.0.0" 336 | } 337 | }, 338 | "decamelize": { 339 | "version": "1.2.0", 340 | "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", 341 | "integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA=", 342 | "dev": true 343 | }, 344 | "depd": { 345 | "version": "1.1.2", 346 | "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", 347 | "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" 348 | }, 349 | "destroy": { 350 | "version": "1.0.4", 351 | "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", 352 | "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" 353 | }, 354 | "domain-browser": { 355 | "version": "1.1.7", 356 | "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.1.7.tgz", 357 | "integrity": "sha1-hnqksJP6oF8d4IwG9NeyH9+GmLw=", 358 | "dev": true 359 | }, 360 | "ee-first": { 361 | "version": "1.1.1", 362 | "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", 363 | "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" 364 | }, 365 | "emojis-list": { 366 | "version": "2.1.0", 367 | "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-2.1.0.tgz", 368 | "integrity": "sha1-TapNnbAPmBmIDHn6RXrlsJof04k=", 369 | "dev": true 370 | }, 371 | "encodeurl": { 372 | "version": "1.0.1", 373 | "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.1.tgz", 374 | "integrity": "sha1-eePVhlU0aQn+bw9Fpd5oEDspTSA=" 375 | }, 376 | "enhanced-resolve": { 377 | "version": "0.9.1", 378 | "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-0.9.1.tgz", 379 | "integrity": "sha1-TW5omzcl+GCQknzMhs2fFjW4ni4=", 380 | "dev": true, 381 | "requires": { 382 | "graceful-fs": "4.1.11", 383 | "memory-fs": "0.2.0", 384 | "tapable": "0.1.10" 385 | }, 386 | "dependencies": { 387 | "memory-fs": { 388 | "version": "0.2.0", 389 | "resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.2.0.tgz", 390 | "integrity": "sha1-8rslNovBIeORwlIN6Slpyu4KApA=", 391 | "dev": true 392 | } 393 | } 394 | }, 395 | "errno": { 396 | "version": "0.1.6", 397 | "resolved": "https://registry.npmjs.org/errno/-/errno-0.1.6.tgz", 398 | "integrity": "sha512-IsORQDpaaSwcDP4ZZnHxgE85werpo34VYn1Ud3mq+eUsF593faR8oCZNXrROVkpFu2TsbrNhHin0aUrTsQ9vNw==", 399 | "dev": true, 400 | "requires": { 401 | "prr": "1.0.1" 402 | } 403 | }, 404 | "escape-html": { 405 | "version": "1.0.3", 406 | "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", 407 | "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" 408 | }, 409 | "etag": { 410 | "version": "1.8.1", 411 | "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", 412 | "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" 413 | }, 414 | "events": { 415 | "version": "1.1.1", 416 | "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", 417 | "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=", 418 | "dev": true 419 | }, 420 | "expand-brackets": { 421 | "version": "0.1.5", 422 | "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz", 423 | "integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=", 424 | "dev": true, 425 | "requires": { 426 | "is-posix-bracket": "0.1.1" 427 | } 428 | }, 429 | "expand-range": { 430 | "version": "1.8.2", 431 | "resolved": "https://registry.npmjs.org/expand-range/-/expand-range-1.8.2.tgz", 432 | "integrity": "sha1-opnv/TNf4nIeuujiV+x5ZE/IUzc=", 433 | "dev": true, 434 | "requires": { 435 | "fill-range": "2.2.3" 436 | } 437 | }, 438 | "express": { 439 | "version": "4.16.2", 440 | "resolved": "https://registry.npmjs.org/express/-/express-4.16.2.tgz", 441 | "integrity": "sha1-41xt/i1kt9ygpc1PIXgb4ymeB2w=", 442 | "requires": { 443 | "accepts": "1.3.4", 444 | "array-flatten": "1.1.1", 445 | "body-parser": "1.18.2", 446 | "content-disposition": "0.5.2", 447 | "content-type": "1.0.4", 448 | "cookie": "0.3.1", 449 | "cookie-signature": "1.0.6", 450 | "debug": "2.6.9", 451 | "depd": "1.1.2", 452 | "encodeurl": "1.0.1", 453 | "escape-html": "1.0.3", 454 | "etag": "1.8.1", 455 | "finalhandler": "1.1.0", 456 | "fresh": "0.5.2", 457 | "merge-descriptors": "1.0.1", 458 | "methods": "1.1.2", 459 | "on-finished": "2.3.0", 460 | "parseurl": "1.3.2", 461 | "path-to-regexp": "0.1.7", 462 | "proxy-addr": "2.0.2", 463 | "qs": "6.5.1", 464 | "range-parser": "1.2.0", 465 | "safe-buffer": "5.1.1", 466 | "send": "0.16.1", 467 | "serve-static": "1.13.1", 468 | "setprototypeof": "1.1.0", 469 | "statuses": "1.3.1", 470 | "type-is": "1.6.15", 471 | "utils-merge": "1.0.1", 472 | "vary": "1.1.2" 473 | } 474 | }, 475 | "extglob": { 476 | "version": "0.3.2", 477 | "resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz", 478 | "integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=", 479 | "dev": true, 480 | "requires": { 481 | "is-extglob": "1.0.0" 482 | } 483 | }, 484 | "filename-regex": { 485 | "version": "2.0.1", 486 | "resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz", 487 | "integrity": "sha1-wcS5vuPglyXdsQa3XB4wH+LxiyY=", 488 | "dev": true 489 | }, 490 | "fill-range": { 491 | "version": "2.2.3", 492 | "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.3.tgz", 493 | "integrity": "sha1-ULd9/X5Gm8dJJHCWNpn+eoSFpyM=", 494 | "dev": true, 495 | "requires": { 496 | "is-number": "2.1.0", 497 | "isobject": "2.1.0", 498 | "randomatic": "1.1.7", 499 | "repeat-element": "1.1.2", 500 | "repeat-string": "1.6.1" 501 | } 502 | }, 503 | "finalhandler": { 504 | "version": "1.1.0", 505 | "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.0.tgz", 506 | "integrity": "sha1-zgtoVbRYU+eRsvzGgARtiCU91/U=", 507 | "requires": { 508 | "debug": "2.6.9", 509 | "encodeurl": "1.0.1", 510 | "escape-html": "1.0.3", 511 | "on-finished": "2.3.0", 512 | "parseurl": "1.3.2", 513 | "statuses": "1.3.1", 514 | "unpipe": "1.0.0" 515 | } 516 | }, 517 | "for-in": { 518 | "version": "1.0.2", 519 | "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", 520 | "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", 521 | "dev": true 522 | }, 523 | "for-own": { 524 | "version": "0.1.5", 525 | "resolved": "https://registry.npmjs.org/for-own/-/for-own-0.1.5.tgz", 526 | "integrity": "sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=", 527 | "dev": true, 528 | "requires": { 529 | "for-in": "1.0.2" 530 | } 531 | }, 532 | "formidable": { 533 | "version": "1.0.17", 534 | "resolved": "https://registry.npmjs.org/formidable/-/formidable-1.0.17.tgz", 535 | "integrity": "sha1-71SRSQ+UM7cF+qdyScmQKa40hVk=" 536 | }, 537 | "forwarded": { 538 | "version": "0.1.2", 539 | "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", 540 | "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" 541 | }, 542 | "fresh": { 543 | "version": "0.5.2", 544 | "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", 545 | "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" 546 | }, 547 | "fsevents": { 548 | "version": "1.1.3", 549 | "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.1.3.tgz", 550 | "integrity": "sha512-WIr7iDkdmdbxu/Gh6eKEZJL6KPE74/5MEsf2whTOFNxbIoIixogroLdKYqB6FDav4Wavh/lZdzzd3b2KxIXC5Q==", 551 | "dev": true, 552 | "optional": true, 553 | "requires": { 554 | "nan": "2.8.0", 555 | "node-pre-gyp": "0.6.39" 556 | }, 557 | "dependencies": { 558 | "abbrev": { 559 | "version": "1.1.0", 560 | "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.0.tgz", 561 | "integrity": "sha1-0FVMIlZjbi9W58LlrRg/hZQo2B8=", 562 | "dev": true, 563 | "optional": true 564 | }, 565 | "ajv": { 566 | "version": "4.11.8", 567 | "resolved": "https://registry.npmjs.org/ajv/-/ajv-4.11.8.tgz", 568 | "integrity": "sha1-gv+wKynmYq5TvcIK8VlHcGc5xTY=", 569 | "dev": true, 570 | "optional": true, 571 | "requires": { 572 | "co": "4.6.0", 573 | "json-stable-stringify": "1.0.1" 574 | } 575 | }, 576 | "ansi-regex": { 577 | "version": "2.1.1", 578 | "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", 579 | "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", 580 | "dev": true 581 | }, 582 | "aproba": { 583 | "version": "1.1.1", 584 | "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.1.1.tgz", 585 | "integrity": "sha1-ldNgDwdxCqDpKYxyatXs8urLq6s=", 586 | "dev": true, 587 | "optional": true 588 | }, 589 | "are-we-there-yet": { 590 | "version": "1.1.4", 591 | "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.4.tgz", 592 | "integrity": "sha1-u13KOCu5TwXhUZQ3PRb9O6HKEQ0=", 593 | "dev": true, 594 | "optional": true, 595 | "requires": { 596 | "delegates": "1.0.0", 597 | "readable-stream": "2.2.9" 598 | } 599 | }, 600 | "asn1": { 601 | "version": "0.2.3", 602 | "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", 603 | "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=", 604 | "dev": true, 605 | "optional": true 606 | }, 607 | "assert-plus": { 608 | "version": "0.2.0", 609 | "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", 610 | "integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=", 611 | "dev": true, 612 | "optional": true 613 | }, 614 | "asynckit": { 615 | "version": "0.4.0", 616 | "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", 617 | "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", 618 | "dev": true, 619 | "optional": true 620 | }, 621 | "aws-sign2": { 622 | "version": "0.6.0", 623 | "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", 624 | "integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8=", 625 | "dev": true, 626 | "optional": true 627 | }, 628 | "aws4": { 629 | "version": "1.6.0", 630 | "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.6.0.tgz", 631 | "integrity": "sha1-g+9cqGCysy5KDe7e6MdxudtXRx4=", 632 | "dev": true, 633 | "optional": true 634 | }, 635 | "balanced-match": { 636 | "version": "0.4.2", 637 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.4.2.tgz", 638 | "integrity": "sha1-yz8+PHMtwPAe5wtAPzAuYddwmDg=", 639 | "dev": true 640 | }, 641 | "bcrypt-pbkdf": { 642 | "version": "1.0.1", 643 | "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz", 644 | "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=", 645 | "dev": true, 646 | "optional": true, 647 | "requires": { 648 | "tweetnacl": "0.14.5" 649 | } 650 | }, 651 | "block-stream": { 652 | "version": "0.0.9", 653 | "resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz", 654 | "integrity": "sha1-E+v+d4oDIFz+A3UUgeu0szAMEmo=", 655 | "dev": true, 656 | "requires": { 657 | "inherits": "2.0.3" 658 | } 659 | }, 660 | "boom": { 661 | "version": "2.10.1", 662 | "resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", 663 | "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=", 664 | "dev": true, 665 | "requires": { 666 | "hoek": "2.16.3" 667 | } 668 | }, 669 | "brace-expansion": { 670 | "version": "1.1.7", 671 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.7.tgz", 672 | "integrity": "sha1-Pv/DxQ4ABTH7cg6v+A8K6O8jz1k=", 673 | "dev": true, 674 | "requires": { 675 | "balanced-match": "0.4.2", 676 | "concat-map": "0.0.1" 677 | } 678 | }, 679 | "buffer-shims": { 680 | "version": "1.0.0", 681 | "resolved": "https://registry.npmjs.org/buffer-shims/-/buffer-shims-1.0.0.tgz", 682 | "integrity": "sha1-mXjOMXOIxkmth5MCjDR37wRKi1E=", 683 | "dev": true 684 | }, 685 | "caseless": { 686 | "version": "0.12.0", 687 | "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", 688 | "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", 689 | "dev": true, 690 | "optional": true 691 | }, 692 | "co": { 693 | "version": "4.6.0", 694 | "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", 695 | "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", 696 | "dev": true, 697 | "optional": true 698 | }, 699 | "code-point-at": { 700 | "version": "1.1.0", 701 | "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", 702 | "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=", 703 | "dev": true 704 | }, 705 | "combined-stream": { 706 | "version": "1.0.5", 707 | "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.5.tgz", 708 | "integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=", 709 | "dev": true, 710 | "requires": { 711 | "delayed-stream": "1.0.0" 712 | } 713 | }, 714 | "concat-map": { 715 | "version": "0.0.1", 716 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 717 | "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", 718 | "dev": true 719 | }, 720 | "console-control-strings": { 721 | "version": "1.1.0", 722 | "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", 723 | "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=", 724 | "dev": true 725 | }, 726 | "core-util-is": { 727 | "version": "1.0.2", 728 | "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", 729 | "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", 730 | "dev": true 731 | }, 732 | "cryptiles": { 733 | "version": "2.0.5", 734 | "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", 735 | "integrity": "sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g=", 736 | "dev": true, 737 | "requires": { 738 | "boom": "2.10.1" 739 | } 740 | }, 741 | "dashdash": { 742 | "version": "1.14.1", 743 | "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", 744 | "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", 745 | "dev": true, 746 | "optional": true, 747 | "requires": { 748 | "assert-plus": "1.0.0" 749 | }, 750 | "dependencies": { 751 | "assert-plus": { 752 | "version": "1.0.0", 753 | "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", 754 | "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", 755 | "dev": true, 756 | "optional": true 757 | } 758 | } 759 | }, 760 | "debug": { 761 | "version": "2.6.8", 762 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.8.tgz", 763 | "integrity": "sha1-5zFTHKLt4n0YgiJCfaF4IdaP9Pw=", 764 | "dev": true, 765 | "optional": true, 766 | "requires": { 767 | "ms": "2.0.0" 768 | } 769 | }, 770 | "deep-extend": { 771 | "version": "0.4.2", 772 | "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.4.2.tgz", 773 | "integrity": "sha1-SLaZwn4zS/ifEIkr5DL25MfTSn8=", 774 | "dev": true, 775 | "optional": true 776 | }, 777 | "delayed-stream": { 778 | "version": "1.0.0", 779 | "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", 780 | "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", 781 | "dev": true 782 | }, 783 | "delegates": { 784 | "version": "1.0.0", 785 | "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", 786 | "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=", 787 | "dev": true, 788 | "optional": true 789 | }, 790 | "detect-libc": { 791 | "version": "1.0.2", 792 | "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.2.tgz", 793 | "integrity": "sha1-ca1dIEvxempsqPRQxhRUBm70YeE=", 794 | "dev": true, 795 | "optional": true 796 | }, 797 | "ecc-jsbn": { 798 | "version": "0.1.1", 799 | "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", 800 | "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=", 801 | "dev": true, 802 | "optional": true, 803 | "requires": { 804 | "jsbn": "0.1.1" 805 | } 806 | }, 807 | "extend": { 808 | "version": "3.0.1", 809 | "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.1.tgz", 810 | "integrity": "sha1-p1Xqe8Gt/MWjHOfnYtuq3F5jZEQ=", 811 | "dev": true, 812 | "optional": true 813 | }, 814 | "extsprintf": { 815 | "version": "1.0.2", 816 | "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.0.2.tgz", 817 | "integrity": "sha1-4QgOBljjALBilJkMxw4VAiNf1VA=", 818 | "dev": true 819 | }, 820 | "forever-agent": { 821 | "version": "0.6.1", 822 | "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", 823 | "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", 824 | "dev": true, 825 | "optional": true 826 | }, 827 | "form-data": { 828 | "version": "2.1.4", 829 | "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.1.4.tgz", 830 | "integrity": "sha1-M8GDrPGTJ27KqYFDpp6Uv+4XUNE=", 831 | "dev": true, 832 | "optional": true, 833 | "requires": { 834 | "asynckit": "0.4.0", 835 | "combined-stream": "1.0.5", 836 | "mime-types": "2.1.15" 837 | } 838 | }, 839 | "fs.realpath": { 840 | "version": "1.0.0", 841 | "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", 842 | "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", 843 | "dev": true 844 | }, 845 | "fstream": { 846 | "version": "1.0.11", 847 | "resolved": "https://registry.npmjs.org/fstream/-/fstream-1.0.11.tgz", 848 | "integrity": "sha1-XB+x8RdHcRTwYyoOtLcbPLD9MXE=", 849 | "dev": true, 850 | "requires": { 851 | "graceful-fs": "4.1.11", 852 | "inherits": "2.0.3", 853 | "mkdirp": "0.5.1", 854 | "rimraf": "2.6.1" 855 | } 856 | }, 857 | "fstream-ignore": { 858 | "version": "1.0.5", 859 | "resolved": "https://registry.npmjs.org/fstream-ignore/-/fstream-ignore-1.0.5.tgz", 860 | "integrity": "sha1-nDHa40dnAY/h0kmyTa2mfQktoQU=", 861 | "dev": true, 862 | "optional": true, 863 | "requires": { 864 | "fstream": "1.0.11", 865 | "inherits": "2.0.3", 866 | "minimatch": "3.0.4" 867 | } 868 | }, 869 | "gauge": { 870 | "version": "2.7.4", 871 | "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz", 872 | "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=", 873 | "dev": true, 874 | "optional": true, 875 | "requires": { 876 | "aproba": "1.1.1", 877 | "console-control-strings": "1.1.0", 878 | "has-unicode": "2.0.1", 879 | "object-assign": "4.1.1", 880 | "signal-exit": "3.0.2", 881 | "string-width": "1.0.2", 882 | "strip-ansi": "3.0.1", 883 | "wide-align": "1.1.2" 884 | } 885 | }, 886 | "getpass": { 887 | "version": "0.1.7", 888 | "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", 889 | "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", 890 | "dev": true, 891 | "optional": true, 892 | "requires": { 893 | "assert-plus": "1.0.0" 894 | }, 895 | "dependencies": { 896 | "assert-plus": { 897 | "version": "1.0.0", 898 | "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", 899 | "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", 900 | "dev": true, 901 | "optional": true 902 | } 903 | } 904 | }, 905 | "glob": { 906 | "version": "7.1.2", 907 | "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", 908 | "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", 909 | "dev": true, 910 | "requires": { 911 | "fs.realpath": "1.0.0", 912 | "inflight": "1.0.6", 913 | "inherits": "2.0.3", 914 | "minimatch": "3.0.4", 915 | "once": "1.4.0", 916 | "path-is-absolute": "1.0.1" 917 | } 918 | }, 919 | "graceful-fs": { 920 | "version": "4.1.11", 921 | "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", 922 | "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", 923 | "dev": true 924 | }, 925 | "har-schema": { 926 | "version": "1.0.5", 927 | "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-1.0.5.tgz", 928 | "integrity": "sha1-0mMTX0MwfALGAq/I/pWXDAFRNp4=", 929 | "dev": true, 930 | "optional": true 931 | }, 932 | "har-validator": { 933 | "version": "4.2.1", 934 | "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-4.2.1.tgz", 935 | "integrity": "sha1-M0gdDxu/9gDdID11gSpqX7oALio=", 936 | "dev": true, 937 | "optional": true, 938 | "requires": { 939 | "ajv": "4.11.8", 940 | "har-schema": "1.0.5" 941 | } 942 | }, 943 | "has-unicode": { 944 | "version": "2.0.1", 945 | "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", 946 | "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=", 947 | "dev": true, 948 | "optional": true 949 | }, 950 | "hawk": { 951 | "version": "3.1.3", 952 | "resolved": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", 953 | "integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=", 954 | "dev": true, 955 | "requires": { 956 | "boom": "2.10.1", 957 | "cryptiles": "2.0.5", 958 | "hoek": "2.16.3", 959 | "sntp": "1.0.9" 960 | } 961 | }, 962 | "hoek": { 963 | "version": "2.16.3", 964 | "resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", 965 | "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=", 966 | "dev": true 967 | }, 968 | "http-signature": { 969 | "version": "1.1.1", 970 | "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", 971 | "integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=", 972 | "dev": true, 973 | "optional": true, 974 | "requires": { 975 | "assert-plus": "0.2.0", 976 | "jsprim": "1.4.0", 977 | "sshpk": "1.13.0" 978 | } 979 | }, 980 | "inflight": { 981 | "version": "1.0.6", 982 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", 983 | "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", 984 | "dev": true, 985 | "requires": { 986 | "once": "1.4.0", 987 | "wrappy": "1.0.2" 988 | } 989 | }, 990 | "inherits": { 991 | "version": "2.0.3", 992 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", 993 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", 994 | "dev": true 995 | }, 996 | "ini": { 997 | "version": "1.3.4", 998 | "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.4.tgz", 999 | "integrity": "sha1-BTfLedr1m1mhpRff9wbIbsA5Fi4=", 1000 | "dev": true, 1001 | "optional": true 1002 | }, 1003 | "is-fullwidth-code-point": { 1004 | "version": "1.0.0", 1005 | "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", 1006 | "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=", 1007 | "dev": true, 1008 | "requires": { 1009 | "number-is-nan": "1.0.1" 1010 | } 1011 | }, 1012 | "is-typedarray": { 1013 | "version": "1.0.0", 1014 | "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", 1015 | "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", 1016 | "dev": true, 1017 | "optional": true 1018 | }, 1019 | "isarray": { 1020 | "version": "1.0.0", 1021 | "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", 1022 | "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", 1023 | "dev": true 1024 | }, 1025 | "isstream": { 1026 | "version": "0.1.2", 1027 | "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", 1028 | "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", 1029 | "dev": true, 1030 | "optional": true 1031 | }, 1032 | "jodid25519": { 1033 | "version": "1.0.2", 1034 | "resolved": "https://registry.npmjs.org/jodid25519/-/jodid25519-1.0.2.tgz", 1035 | "integrity": "sha1-BtSRIlUJNBlHfUJWM2BuDpB4KWc=", 1036 | "dev": true, 1037 | "optional": true, 1038 | "requires": { 1039 | "jsbn": "0.1.1" 1040 | } 1041 | }, 1042 | "jsbn": { 1043 | "version": "0.1.1", 1044 | "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", 1045 | "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", 1046 | "dev": true, 1047 | "optional": true 1048 | }, 1049 | "json-schema": { 1050 | "version": "0.2.3", 1051 | "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", 1052 | "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", 1053 | "dev": true, 1054 | "optional": true 1055 | }, 1056 | "json-stable-stringify": { 1057 | "version": "1.0.1", 1058 | "resolved": "https://registry.npmjs.org/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz", 1059 | "integrity": "sha1-mnWdOcXy/1A/1TAGRu1EX4jE+a8=", 1060 | "dev": true, 1061 | "optional": true, 1062 | "requires": { 1063 | "jsonify": "0.0.0" 1064 | } 1065 | }, 1066 | "json-stringify-safe": { 1067 | "version": "5.0.1", 1068 | "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", 1069 | "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", 1070 | "dev": true, 1071 | "optional": true 1072 | }, 1073 | "jsonify": { 1074 | "version": "0.0.0", 1075 | "resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz", 1076 | "integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM=", 1077 | "dev": true, 1078 | "optional": true 1079 | }, 1080 | "jsprim": { 1081 | "version": "1.4.0", 1082 | "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.0.tgz", 1083 | "integrity": "sha1-o7h+QCmNjDgFUtjMdiigu5WiKRg=", 1084 | "dev": true, 1085 | "optional": true, 1086 | "requires": { 1087 | "assert-plus": "1.0.0", 1088 | "extsprintf": "1.0.2", 1089 | "json-schema": "0.2.3", 1090 | "verror": "1.3.6" 1091 | }, 1092 | "dependencies": { 1093 | "assert-plus": { 1094 | "version": "1.0.0", 1095 | "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", 1096 | "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", 1097 | "dev": true, 1098 | "optional": true 1099 | } 1100 | } 1101 | }, 1102 | "mime-db": { 1103 | "version": "1.27.0", 1104 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.27.0.tgz", 1105 | "integrity": "sha1-gg9XIpa70g7CXtVeW13oaeVDbrE=", 1106 | "dev": true 1107 | }, 1108 | "mime-types": { 1109 | "version": "2.1.15", 1110 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.15.tgz", 1111 | "integrity": "sha1-pOv1BkCUVpI3uM9wBGd20J/JKu0=", 1112 | "dev": true, 1113 | "requires": { 1114 | "mime-db": "1.27.0" 1115 | } 1116 | }, 1117 | "minimatch": { 1118 | "version": "3.0.4", 1119 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", 1120 | "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", 1121 | "dev": true, 1122 | "requires": { 1123 | "brace-expansion": "1.1.7" 1124 | } 1125 | }, 1126 | "minimist": { 1127 | "version": "0.0.8", 1128 | "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", 1129 | "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", 1130 | "dev": true 1131 | }, 1132 | "mkdirp": { 1133 | "version": "0.5.1", 1134 | "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", 1135 | "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", 1136 | "dev": true, 1137 | "requires": { 1138 | "minimist": "0.0.8" 1139 | } 1140 | }, 1141 | "ms": { 1142 | "version": "2.0.0", 1143 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 1144 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", 1145 | "dev": true, 1146 | "optional": true 1147 | }, 1148 | "node-pre-gyp": { 1149 | "version": "0.6.39", 1150 | "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.6.39.tgz", 1151 | "integrity": "sha512-OsJV74qxnvz/AMGgcfZoDaeDXKD3oY3QVIbBmwszTFkRisTSXbMQyn4UWzUMOtA5SVhrBZOTp0wcoSBgfMfMmQ==", 1152 | "dev": true, 1153 | "optional": true, 1154 | "requires": { 1155 | "detect-libc": "1.0.2", 1156 | "hawk": "3.1.3", 1157 | "mkdirp": "0.5.1", 1158 | "nopt": "4.0.1", 1159 | "npmlog": "4.1.0", 1160 | "rc": "1.2.1", 1161 | "request": "2.81.0", 1162 | "rimraf": "2.6.1", 1163 | "semver": "5.3.0", 1164 | "tar": "2.2.1", 1165 | "tar-pack": "3.4.0" 1166 | } 1167 | }, 1168 | "nopt": { 1169 | "version": "4.0.1", 1170 | "resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz", 1171 | "integrity": "sha1-0NRoWv1UFRk8jHUFYC0NF81kR00=", 1172 | "dev": true, 1173 | "optional": true, 1174 | "requires": { 1175 | "abbrev": "1.1.0", 1176 | "osenv": "0.1.4" 1177 | } 1178 | }, 1179 | "npmlog": { 1180 | "version": "4.1.0", 1181 | "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.0.tgz", 1182 | "integrity": "sha512-ocolIkZYZt8UveuiDS0yAkkIjid1o7lPG8cYm05yNYzBn8ykQtaiPMEGp8fY9tKdDgm8okpdKzkvu1y9hUYugA==", 1183 | "dev": true, 1184 | "optional": true, 1185 | "requires": { 1186 | "are-we-there-yet": "1.1.4", 1187 | "console-control-strings": "1.1.0", 1188 | "gauge": "2.7.4", 1189 | "set-blocking": "2.0.0" 1190 | } 1191 | }, 1192 | "number-is-nan": { 1193 | "version": "1.0.1", 1194 | "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", 1195 | "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", 1196 | "dev": true 1197 | }, 1198 | "oauth-sign": { 1199 | "version": "0.8.2", 1200 | "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", 1201 | "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=", 1202 | "dev": true, 1203 | "optional": true 1204 | }, 1205 | "object-assign": { 1206 | "version": "4.1.1", 1207 | "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", 1208 | "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", 1209 | "dev": true, 1210 | "optional": true 1211 | }, 1212 | "once": { 1213 | "version": "1.4.0", 1214 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", 1215 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", 1216 | "dev": true, 1217 | "requires": { 1218 | "wrappy": "1.0.2" 1219 | } 1220 | }, 1221 | "os-homedir": { 1222 | "version": "1.0.2", 1223 | "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", 1224 | "integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=", 1225 | "dev": true, 1226 | "optional": true 1227 | }, 1228 | "os-tmpdir": { 1229 | "version": "1.0.2", 1230 | "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", 1231 | "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", 1232 | "dev": true, 1233 | "optional": true 1234 | }, 1235 | "osenv": { 1236 | "version": "0.1.4", 1237 | "resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.4.tgz", 1238 | "integrity": "sha1-Qv5tWVPfBsgGS+bxdsPQWqqjRkQ=", 1239 | "dev": true, 1240 | "optional": true, 1241 | "requires": { 1242 | "os-homedir": "1.0.2", 1243 | "os-tmpdir": "1.0.2" 1244 | } 1245 | }, 1246 | "path-is-absolute": { 1247 | "version": "1.0.1", 1248 | "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", 1249 | "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", 1250 | "dev": true 1251 | }, 1252 | "performance-now": { 1253 | "version": "0.2.0", 1254 | "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-0.2.0.tgz", 1255 | "integrity": "sha1-M+8wxcd9TqIcWlOGnZG1bY8lVeU=", 1256 | "dev": true, 1257 | "optional": true 1258 | }, 1259 | "process-nextick-args": { 1260 | "version": "1.0.7", 1261 | "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", 1262 | "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", 1263 | "dev": true 1264 | }, 1265 | "punycode": { 1266 | "version": "1.4.1", 1267 | "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", 1268 | "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", 1269 | "dev": true, 1270 | "optional": true 1271 | }, 1272 | "qs": { 1273 | "version": "6.4.0", 1274 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.4.0.tgz", 1275 | "integrity": "sha1-E+JtKK1rD/qpExLNO/cI7TUecjM=", 1276 | "dev": true, 1277 | "optional": true 1278 | }, 1279 | "rc": { 1280 | "version": "1.2.1", 1281 | "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.1.tgz", 1282 | "integrity": "sha1-LgPo5C7kULjLPc5lvhv4l04d/ZU=", 1283 | "dev": true, 1284 | "optional": true, 1285 | "requires": { 1286 | "deep-extend": "0.4.2", 1287 | "ini": "1.3.4", 1288 | "minimist": "1.2.0", 1289 | "strip-json-comments": "2.0.1" 1290 | }, 1291 | "dependencies": { 1292 | "minimist": { 1293 | "version": "1.2.0", 1294 | "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", 1295 | "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", 1296 | "dev": true, 1297 | "optional": true 1298 | } 1299 | } 1300 | }, 1301 | "readable-stream": { 1302 | "version": "2.2.9", 1303 | "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.9.tgz", 1304 | "integrity": "sha1-z3jsb0ptHrQ9JkiMrJfwQudLf8g=", 1305 | "dev": true, 1306 | "requires": { 1307 | "buffer-shims": "1.0.0", 1308 | "core-util-is": "1.0.2", 1309 | "inherits": "2.0.3", 1310 | "isarray": "1.0.0", 1311 | "process-nextick-args": "1.0.7", 1312 | "string_decoder": "1.0.1", 1313 | "util-deprecate": "1.0.2" 1314 | } 1315 | }, 1316 | "request": { 1317 | "version": "2.81.0", 1318 | "resolved": "https://registry.npmjs.org/request/-/request-2.81.0.tgz", 1319 | "integrity": "sha1-xpKJRqDgbF+Nb4qTM0af/aRimKA=", 1320 | "dev": true, 1321 | "optional": true, 1322 | "requires": { 1323 | "aws-sign2": "0.6.0", 1324 | "aws4": "1.6.0", 1325 | "caseless": "0.12.0", 1326 | "combined-stream": "1.0.5", 1327 | "extend": "3.0.1", 1328 | "forever-agent": "0.6.1", 1329 | "form-data": "2.1.4", 1330 | "har-validator": "4.2.1", 1331 | "hawk": "3.1.3", 1332 | "http-signature": "1.1.1", 1333 | "is-typedarray": "1.0.0", 1334 | "isstream": "0.1.2", 1335 | "json-stringify-safe": "5.0.1", 1336 | "mime-types": "2.1.15", 1337 | "oauth-sign": "0.8.2", 1338 | "performance-now": "0.2.0", 1339 | "qs": "6.4.0", 1340 | "safe-buffer": "5.0.1", 1341 | "stringstream": "0.0.5", 1342 | "tough-cookie": "2.3.2", 1343 | "tunnel-agent": "0.6.0", 1344 | "uuid": "3.0.1" 1345 | } 1346 | }, 1347 | "rimraf": { 1348 | "version": "2.6.1", 1349 | "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.1.tgz", 1350 | "integrity": "sha1-wjOOxkPfeht/5cVPqG9XQopV8z0=", 1351 | "dev": true, 1352 | "requires": { 1353 | "glob": "7.1.2" 1354 | } 1355 | }, 1356 | "safe-buffer": { 1357 | "version": "5.0.1", 1358 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.0.1.tgz", 1359 | "integrity": "sha1-0mPKVGls2KMGtcplUekt5XkY++c=", 1360 | "dev": true 1361 | }, 1362 | "semver": { 1363 | "version": "5.3.0", 1364 | "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", 1365 | "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=", 1366 | "dev": true, 1367 | "optional": true 1368 | }, 1369 | "set-blocking": { 1370 | "version": "2.0.0", 1371 | "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", 1372 | "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=", 1373 | "dev": true, 1374 | "optional": true 1375 | }, 1376 | "signal-exit": { 1377 | "version": "3.0.2", 1378 | "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", 1379 | "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", 1380 | "dev": true, 1381 | "optional": true 1382 | }, 1383 | "sntp": { 1384 | "version": "1.0.9", 1385 | "resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz", 1386 | "integrity": "sha1-ZUEYTMkK7qbG57NeJlkIJEPGYZg=", 1387 | "dev": true, 1388 | "requires": { 1389 | "hoek": "2.16.3" 1390 | } 1391 | }, 1392 | "sshpk": { 1393 | "version": "1.13.0", 1394 | "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.13.0.tgz", 1395 | "integrity": "sha1-/yo+T9BEl1Vf7Zezmg/YL6+zozw=", 1396 | "dev": true, 1397 | "optional": true, 1398 | "requires": { 1399 | "asn1": "0.2.3", 1400 | "assert-plus": "1.0.0", 1401 | "bcrypt-pbkdf": "1.0.1", 1402 | "dashdash": "1.14.1", 1403 | "ecc-jsbn": "0.1.1", 1404 | "getpass": "0.1.7", 1405 | "jodid25519": "1.0.2", 1406 | "jsbn": "0.1.1", 1407 | "tweetnacl": "0.14.5" 1408 | }, 1409 | "dependencies": { 1410 | "assert-plus": { 1411 | "version": "1.0.0", 1412 | "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", 1413 | "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", 1414 | "dev": true, 1415 | "optional": true 1416 | } 1417 | } 1418 | }, 1419 | "string-width": { 1420 | "version": "1.0.2", 1421 | "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", 1422 | "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=", 1423 | "dev": true, 1424 | "requires": { 1425 | "code-point-at": "1.1.0", 1426 | "is-fullwidth-code-point": "1.0.0", 1427 | "strip-ansi": "3.0.1" 1428 | } 1429 | }, 1430 | "string_decoder": { 1431 | "version": "1.0.1", 1432 | "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.1.tgz", 1433 | "integrity": "sha1-YuIA8DmVWmgQ2N8KM//A8BNmLZg=", 1434 | "dev": true, 1435 | "requires": { 1436 | "safe-buffer": "5.0.1" 1437 | } 1438 | }, 1439 | "stringstream": { 1440 | "version": "0.0.5", 1441 | "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", 1442 | "integrity": "sha1-TkhM1N5aC7vuGORjB3EKioFiGHg=", 1443 | "dev": true, 1444 | "optional": true 1445 | }, 1446 | "strip-ansi": { 1447 | "version": "3.0.1", 1448 | "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", 1449 | "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", 1450 | "dev": true, 1451 | "requires": { 1452 | "ansi-regex": "2.1.1" 1453 | } 1454 | }, 1455 | "strip-json-comments": { 1456 | "version": "2.0.1", 1457 | "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", 1458 | "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", 1459 | "dev": true, 1460 | "optional": true 1461 | }, 1462 | "tar": { 1463 | "version": "2.2.1", 1464 | "resolved": "https://registry.npmjs.org/tar/-/tar-2.2.1.tgz", 1465 | "integrity": "sha1-jk0qJWwOIYXGsYrWlK7JaLg8sdE=", 1466 | "dev": true, 1467 | "requires": { 1468 | "block-stream": "0.0.9", 1469 | "fstream": "1.0.11", 1470 | "inherits": "2.0.3" 1471 | } 1472 | }, 1473 | "tar-pack": { 1474 | "version": "3.4.0", 1475 | "resolved": "https://registry.npmjs.org/tar-pack/-/tar-pack-3.4.0.tgz", 1476 | "integrity": "sha1-I74tf2cagzk3bL2wuP4/3r8xeYQ=", 1477 | "dev": true, 1478 | "optional": true, 1479 | "requires": { 1480 | "debug": "2.6.8", 1481 | "fstream": "1.0.11", 1482 | "fstream-ignore": "1.0.5", 1483 | "once": "1.4.0", 1484 | "readable-stream": "2.2.9", 1485 | "rimraf": "2.6.1", 1486 | "tar": "2.2.1", 1487 | "uid-number": "0.0.6" 1488 | } 1489 | }, 1490 | "tough-cookie": { 1491 | "version": "2.3.2", 1492 | "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.2.tgz", 1493 | "integrity": "sha1-8IH3bkyFcg5sN6X6ztc3FQ2EByo=", 1494 | "dev": true, 1495 | "optional": true, 1496 | "requires": { 1497 | "punycode": "1.4.1" 1498 | } 1499 | }, 1500 | "tunnel-agent": { 1501 | "version": "0.6.0", 1502 | "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", 1503 | "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", 1504 | "dev": true, 1505 | "optional": true, 1506 | "requires": { 1507 | "safe-buffer": "5.0.1" 1508 | } 1509 | }, 1510 | "tweetnacl": { 1511 | "version": "0.14.5", 1512 | "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", 1513 | "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", 1514 | "dev": true, 1515 | "optional": true 1516 | }, 1517 | "uid-number": { 1518 | "version": "0.0.6", 1519 | "resolved": "https://registry.npmjs.org/uid-number/-/uid-number-0.0.6.tgz", 1520 | "integrity": "sha1-DqEOgDXo61uOREnwbaHHMGY7qoE=", 1521 | "dev": true, 1522 | "optional": true 1523 | }, 1524 | "util-deprecate": { 1525 | "version": "1.0.2", 1526 | "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", 1527 | "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", 1528 | "dev": true 1529 | }, 1530 | "uuid": { 1531 | "version": "3.0.1", 1532 | "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.0.1.tgz", 1533 | "integrity": "sha1-ZUS7ot/ajBzxfmKaOjBeK7H+5sE=", 1534 | "dev": true, 1535 | "optional": true 1536 | }, 1537 | "verror": { 1538 | "version": "1.3.6", 1539 | "resolved": "https://registry.npmjs.org/verror/-/verror-1.3.6.tgz", 1540 | "integrity": "sha1-z/XfEpRtKX0rqu+qJoniW+AcAFw=", 1541 | "dev": true, 1542 | "optional": true, 1543 | "requires": { 1544 | "extsprintf": "1.0.2" 1545 | } 1546 | }, 1547 | "wide-align": { 1548 | "version": "1.1.2", 1549 | "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.2.tgz", 1550 | "integrity": "sha512-ijDLlyQ7s6x1JgCLur53osjm/UXUYD9+0PbYKrBsYisYXzCxN+HC3mYDNy/dWdmf3AwqwU3CXwDCvsNgGK1S0w==", 1551 | "dev": true, 1552 | "optional": true, 1553 | "requires": { 1554 | "string-width": "1.0.2" 1555 | } 1556 | }, 1557 | "wrappy": { 1558 | "version": "1.0.2", 1559 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", 1560 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", 1561 | "dev": true 1562 | } 1563 | } 1564 | }, 1565 | "glob-base": { 1566 | "version": "0.3.0", 1567 | "resolved": "https://registry.npmjs.org/glob-base/-/glob-base-0.3.0.tgz", 1568 | "integrity": "sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q=", 1569 | "dev": true, 1570 | "requires": { 1571 | "glob-parent": "2.0.0", 1572 | "is-glob": "2.0.1" 1573 | } 1574 | }, 1575 | "glob-parent": { 1576 | "version": "2.0.0", 1577 | "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz", 1578 | "integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=", 1579 | "dev": true, 1580 | "requires": { 1581 | "is-glob": "2.0.1" 1582 | } 1583 | }, 1584 | "graceful-fs": { 1585 | "version": "4.1.11", 1586 | "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz", 1587 | "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg=", 1588 | "dev": true 1589 | }, 1590 | "gun": { 1591 | "version": "0.3.9991", 1592 | "resolved": "https://registry.npmjs.org/gun/-/gun-0.3.9991.tgz", 1593 | "integrity": "sha1-91XaOeFv6JLyfuH1+LMy9MNKUS8=", 1594 | "requires": { 1595 | "aws-sdk": "2.0.31", 1596 | "formidable": "1.0.17", 1597 | "ws": "1.0.1" 1598 | } 1599 | }, 1600 | "has-flag": { 1601 | "version": "1.0.0", 1602 | "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", 1603 | "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=", 1604 | "dev": true 1605 | }, 1606 | "http-errors": { 1607 | "version": "1.6.2", 1608 | "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz", 1609 | "integrity": "sha1-CgAsyFcHGSp+eUbO7cERVfYOxzY=", 1610 | "requires": { 1611 | "depd": "1.1.1", 1612 | "inherits": "2.0.3", 1613 | "setprototypeof": "1.0.3", 1614 | "statuses": "1.3.1" 1615 | }, 1616 | "dependencies": { 1617 | "depd": { 1618 | "version": "1.1.1", 1619 | "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz", 1620 | "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k=" 1621 | }, 1622 | "setprototypeof": { 1623 | "version": "1.0.3", 1624 | "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz", 1625 | "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=" 1626 | } 1627 | } 1628 | }, 1629 | "https-browserify": { 1630 | "version": "0.0.1", 1631 | "resolved": "https://registry.npmjs.org/https-browserify/-/https-browserify-0.0.1.tgz", 1632 | "integrity": "sha1-P5E2XKvmC3ftDruiS0VOPgnZWoI=", 1633 | "dev": true 1634 | }, 1635 | "iconv-lite": { 1636 | "version": "0.4.19", 1637 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", 1638 | "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==" 1639 | }, 1640 | "ieee754": { 1641 | "version": "1.1.8", 1642 | "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.8.tgz", 1643 | "integrity": "sha1-vjPUCsEO8ZJnAfbwii2G+/0a0+Q=", 1644 | "dev": true 1645 | }, 1646 | "indexof": { 1647 | "version": "0.0.1", 1648 | "resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz", 1649 | "integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=", 1650 | "dev": true 1651 | }, 1652 | "inherits": { 1653 | "version": "2.0.3", 1654 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", 1655 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" 1656 | }, 1657 | "interpret": { 1658 | "version": "0.6.6", 1659 | "resolved": "https://registry.npmjs.org/interpret/-/interpret-0.6.6.tgz", 1660 | "integrity": "sha1-/s16GOfOXKar+5U+H4YhOknxYls=", 1661 | "dev": true 1662 | }, 1663 | "ipaddr.js": { 1664 | "version": "1.5.2", 1665 | "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.5.2.tgz", 1666 | "integrity": "sha1-1LUFvemUaYfM8PxY2QEP+WB+P6A=" 1667 | }, 1668 | "is-binary-path": { 1669 | "version": "1.0.1", 1670 | "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", 1671 | "integrity": "sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg=", 1672 | "dev": true, 1673 | "requires": { 1674 | "binary-extensions": "1.11.0" 1675 | } 1676 | }, 1677 | "is-buffer": { 1678 | "version": "1.1.6", 1679 | "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", 1680 | "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", 1681 | "dev": true 1682 | }, 1683 | "is-dotfile": { 1684 | "version": "1.0.3", 1685 | "resolved": "https://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.3.tgz", 1686 | "integrity": "sha1-pqLzL/0t+wT1yiXs0Pa4PPeYoeE=", 1687 | "dev": true 1688 | }, 1689 | "is-equal-shallow": { 1690 | "version": "0.1.3", 1691 | "resolved": "https://registry.npmjs.org/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz", 1692 | "integrity": "sha1-IjgJj8Ih3gvPpdnqxMRdY4qhxTQ=", 1693 | "dev": true, 1694 | "requires": { 1695 | "is-primitive": "2.0.0" 1696 | } 1697 | }, 1698 | "is-extendable": { 1699 | "version": "0.1.1", 1700 | "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", 1701 | "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", 1702 | "dev": true 1703 | }, 1704 | "is-extglob": { 1705 | "version": "1.0.0", 1706 | "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", 1707 | "integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=", 1708 | "dev": true 1709 | }, 1710 | "is-glob": { 1711 | "version": "2.0.1", 1712 | "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", 1713 | "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", 1714 | "dev": true, 1715 | "requires": { 1716 | "is-extglob": "1.0.0" 1717 | } 1718 | }, 1719 | "is-number": { 1720 | "version": "2.1.0", 1721 | "resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz", 1722 | "integrity": "sha1-Afy7s5NGOlSPL0ZszhbezknbkI8=", 1723 | "dev": true, 1724 | "requires": { 1725 | "kind-of": "3.2.2" 1726 | } 1727 | }, 1728 | "is-posix-bracket": { 1729 | "version": "0.1.1", 1730 | "resolved": "https://registry.npmjs.org/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz", 1731 | "integrity": "sha1-MzTceXdDaOkvAW5vvAqI9c1ua8Q=", 1732 | "dev": true 1733 | }, 1734 | "is-primitive": { 1735 | "version": "2.0.0", 1736 | "resolved": "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz", 1737 | "integrity": "sha1-IHurkWOEmcB7Kt8kCkGochADRXU=", 1738 | "dev": true 1739 | }, 1740 | "isarray": { 1741 | "version": "1.0.0", 1742 | "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", 1743 | "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", 1744 | "dev": true 1745 | }, 1746 | "isobject": { 1747 | "version": "2.1.0", 1748 | "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", 1749 | "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", 1750 | "dev": true, 1751 | "requires": { 1752 | "isarray": "1.0.0" 1753 | } 1754 | }, 1755 | "json5": { 1756 | "version": "0.5.1", 1757 | "resolved": "https://registry.npmjs.org/json5/-/json5-0.5.1.tgz", 1758 | "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=", 1759 | "dev": true 1760 | }, 1761 | "kind-of": { 1762 | "version": "3.2.2", 1763 | "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", 1764 | "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", 1765 | "dev": true, 1766 | "requires": { 1767 | "is-buffer": "1.1.6" 1768 | } 1769 | }, 1770 | "lazy-cache": { 1771 | "version": "1.0.4", 1772 | "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", 1773 | "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=", 1774 | "dev": true 1775 | }, 1776 | "loader-utils": { 1777 | "version": "0.2.17", 1778 | "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-0.2.17.tgz", 1779 | "integrity": "sha1-+G5jdNQyBabmxg6RlvF8Apm/s0g=", 1780 | "dev": true, 1781 | "requires": { 1782 | "big.js": "3.2.0", 1783 | "emojis-list": "2.1.0", 1784 | "json5": "0.5.1", 1785 | "object-assign": "4.1.1" 1786 | } 1787 | }, 1788 | "longest": { 1789 | "version": "1.0.1", 1790 | "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", 1791 | "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", 1792 | "dev": true 1793 | }, 1794 | "media-typer": { 1795 | "version": "0.3.0", 1796 | "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", 1797 | "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" 1798 | }, 1799 | "memory-fs": { 1800 | "version": "0.3.0", 1801 | "resolved": "https://registry.npmjs.org/memory-fs/-/memory-fs-0.3.0.tgz", 1802 | "integrity": "sha1-e8xrYp46Q+hx1+Kaymrop/FcuyA=", 1803 | "dev": true, 1804 | "requires": { 1805 | "errno": "0.1.6", 1806 | "readable-stream": "2.3.3" 1807 | } 1808 | }, 1809 | "merge-descriptors": { 1810 | "version": "1.0.1", 1811 | "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", 1812 | "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" 1813 | }, 1814 | "methods": { 1815 | "version": "1.1.2", 1816 | "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", 1817 | "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" 1818 | }, 1819 | "micromatch": { 1820 | "version": "2.3.11", 1821 | "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz", 1822 | "integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=", 1823 | "dev": true, 1824 | "requires": { 1825 | "arr-diff": "2.0.0", 1826 | "array-unique": "0.2.1", 1827 | "braces": "1.8.5", 1828 | "expand-brackets": "0.1.5", 1829 | "extglob": "0.3.2", 1830 | "filename-regex": "2.0.1", 1831 | "is-extglob": "1.0.0", 1832 | "is-glob": "2.0.1", 1833 | "kind-of": "3.2.2", 1834 | "normalize-path": "2.1.1", 1835 | "object.omit": "2.0.1", 1836 | "parse-glob": "3.0.4", 1837 | "regex-cache": "0.4.4" 1838 | } 1839 | }, 1840 | "mime": { 1841 | "version": "1.4.1", 1842 | "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", 1843 | "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==" 1844 | }, 1845 | "mime-db": { 1846 | "version": "1.30.0", 1847 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.30.0.tgz", 1848 | "integrity": "sha1-dMZD2i3Z1qRTmZY0ZbJtXKfXHwE=" 1849 | }, 1850 | "mime-types": { 1851 | "version": "2.1.17", 1852 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.17.tgz", 1853 | "integrity": "sha1-Cdejk/A+mVp5+K+Fe3Cp4KsWVXo=", 1854 | "requires": { 1855 | "mime-db": "1.30.0" 1856 | } 1857 | }, 1858 | "minimatch": { 1859 | "version": "3.0.4", 1860 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", 1861 | "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", 1862 | "dev": true, 1863 | "requires": { 1864 | "brace-expansion": "1.1.8" 1865 | } 1866 | }, 1867 | "minimist": { 1868 | "version": "0.0.8", 1869 | "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", 1870 | "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", 1871 | "dev": true 1872 | }, 1873 | "mkdirp": { 1874 | "version": "0.5.1", 1875 | "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", 1876 | "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", 1877 | "dev": true, 1878 | "requires": { 1879 | "minimist": "0.0.8" 1880 | } 1881 | }, 1882 | "ms": { 1883 | "version": "2.0.0", 1884 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 1885 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" 1886 | }, 1887 | "nan": { 1888 | "version": "2.8.0", 1889 | "resolved": "https://registry.npmjs.org/nan/-/nan-2.8.0.tgz", 1890 | "integrity": "sha1-7XFfP+neArV6XmJS2QqWZ14fCFo=", 1891 | "dev": true, 1892 | "optional": true 1893 | }, 1894 | "negotiator": { 1895 | "version": "0.6.1", 1896 | "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", 1897 | "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" 1898 | }, 1899 | "node-libs-browser": { 1900 | "version": "0.7.0", 1901 | "resolved": "https://registry.npmjs.org/node-libs-browser/-/node-libs-browser-0.7.0.tgz", 1902 | "integrity": "sha1-PicsCBnjCJNeJmdECNevDhSRuDs=", 1903 | "dev": true, 1904 | "requires": { 1905 | "assert": "1.4.1", 1906 | "browserify-zlib": "0.1.4", 1907 | "buffer": "4.9.1", 1908 | "console-browserify": "1.1.0", 1909 | "constants-browserify": "1.0.0", 1910 | "crypto-browserify": "3.3.0", 1911 | "domain-browser": "1.1.7", 1912 | "events": "1.1.1", 1913 | "https-browserify": "0.0.1", 1914 | "os-browserify": "0.2.1", 1915 | "path-browserify": "0.0.0", 1916 | "process": "0.11.10", 1917 | "punycode": "1.4.1", 1918 | "querystring-es3": "0.2.1", 1919 | "readable-stream": "2.3.3", 1920 | "stream-browserify": "2.0.1", 1921 | "stream-http": "2.8.0", 1922 | "string_decoder": "0.10.31", 1923 | "timers-browserify": "2.0.4", 1924 | "tty-browserify": "0.0.0", 1925 | "url": "0.11.0", 1926 | "util": "0.10.3", 1927 | "vm-browserify": "0.0.4" 1928 | }, 1929 | "dependencies": { 1930 | "string_decoder": { 1931 | "version": "0.10.31", 1932 | "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", 1933 | "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", 1934 | "dev": true 1935 | } 1936 | } 1937 | }, 1938 | "normalize-path": { 1939 | "version": "2.1.1", 1940 | "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", 1941 | "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", 1942 | "dev": true, 1943 | "requires": { 1944 | "remove-trailing-separator": "1.1.0" 1945 | } 1946 | }, 1947 | "object-assign": { 1948 | "version": "4.1.1", 1949 | "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", 1950 | "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", 1951 | "dev": true 1952 | }, 1953 | "object.omit": { 1954 | "version": "2.0.1", 1955 | "resolved": "https://registry.npmjs.org/object.omit/-/object.omit-2.0.1.tgz", 1956 | "integrity": "sha1-Gpx0SCnznbuFjHbKNXmuKlTr0fo=", 1957 | "dev": true, 1958 | "requires": { 1959 | "for-own": "0.1.5", 1960 | "is-extendable": "0.1.1" 1961 | } 1962 | }, 1963 | "on-finished": { 1964 | "version": "2.3.0", 1965 | "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", 1966 | "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", 1967 | "requires": { 1968 | "ee-first": "1.1.1" 1969 | } 1970 | }, 1971 | "optimist": { 1972 | "version": "0.6.1", 1973 | "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", 1974 | "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", 1975 | "dev": true, 1976 | "requires": { 1977 | "minimist": "0.0.8", 1978 | "wordwrap": "0.0.3" 1979 | } 1980 | }, 1981 | "options": { 1982 | "version": "0.0.6", 1983 | "resolved": "https://registry.npmjs.org/options/-/options-0.0.6.tgz", 1984 | "integrity": "sha1-7CLTEoBrtT5zF3Pnza788cZDEo8=" 1985 | }, 1986 | "os-browserify": { 1987 | "version": "0.2.1", 1988 | "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.2.1.tgz", 1989 | "integrity": "sha1-Y/xMzuXS13Y9Jrv4YBB45sLgBE8=", 1990 | "dev": true 1991 | }, 1992 | "pako": { 1993 | "version": "0.2.9", 1994 | "resolved": "https://registry.npmjs.org/pako/-/pako-0.2.9.tgz", 1995 | "integrity": "sha1-8/dSL073gjSNqBYbrZ7P1Rv4OnU=", 1996 | "dev": true 1997 | }, 1998 | "parse-glob": { 1999 | "version": "3.0.4", 2000 | "resolved": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz", 2001 | "integrity": "sha1-ssN2z7EfNVE7rdFz7wu246OIORw=", 2002 | "dev": true, 2003 | "requires": { 2004 | "glob-base": "0.3.0", 2005 | "is-dotfile": "1.0.3", 2006 | "is-extglob": "1.0.0", 2007 | "is-glob": "2.0.1" 2008 | } 2009 | }, 2010 | "parseurl": { 2011 | "version": "1.3.2", 2012 | "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", 2013 | "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=" 2014 | }, 2015 | "path-browserify": { 2016 | "version": "0.0.0", 2017 | "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-0.0.0.tgz", 2018 | "integrity": "sha1-oLhwcpquIUAFt9UDLsLLuw+0RRo=", 2019 | "dev": true 2020 | }, 2021 | "path-is-absolute": { 2022 | "version": "1.0.1", 2023 | "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", 2024 | "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", 2025 | "dev": true 2026 | }, 2027 | "path-to-regexp": { 2028 | "version": "0.1.7", 2029 | "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", 2030 | "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" 2031 | }, 2032 | "pbkdf2-compat": { 2033 | "version": "2.0.1", 2034 | "resolved": "https://registry.npmjs.org/pbkdf2-compat/-/pbkdf2-compat-2.0.1.tgz", 2035 | "integrity": "sha1-tuDI+plJTZTgURV1gCpZpcFC8og=", 2036 | "dev": true 2037 | }, 2038 | "preserve": { 2039 | "version": "0.2.0", 2040 | "resolved": "https://registry.npmjs.org/preserve/-/preserve-0.2.0.tgz", 2041 | "integrity": "sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=", 2042 | "dev": true 2043 | }, 2044 | "process": { 2045 | "version": "0.11.10", 2046 | "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", 2047 | "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=", 2048 | "dev": true 2049 | }, 2050 | "process-nextick-args": { 2051 | "version": "1.0.7", 2052 | "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", 2053 | "integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=", 2054 | "dev": true 2055 | }, 2056 | "proxy-addr": { 2057 | "version": "2.0.2", 2058 | "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.2.tgz", 2059 | "integrity": "sha1-ZXFQT0e7mI7IGAJT+F3X4UlSvew=", 2060 | "requires": { 2061 | "forwarded": "0.1.2", 2062 | "ipaddr.js": "1.5.2" 2063 | } 2064 | }, 2065 | "prr": { 2066 | "version": "1.0.1", 2067 | "resolved": "https://registry.npmjs.org/prr/-/prr-1.0.1.tgz", 2068 | "integrity": "sha1-0/wRS6BplaRexok/SEzrHXj19HY=", 2069 | "dev": true 2070 | }, 2071 | "punycode": { 2072 | "version": "1.4.1", 2073 | "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", 2074 | "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", 2075 | "dev": true 2076 | }, 2077 | "qs": { 2078 | "version": "6.5.1", 2079 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", 2080 | "integrity": "sha512-eRzhrN1WSINYCDCbrz796z37LOe3m5tmW7RQf6oBntukAG1nmovJvhnwHHRMAfeoItc1m2Hk02WER2aQ/iqs+A==" 2081 | }, 2082 | "querystring": { 2083 | "version": "0.2.0", 2084 | "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", 2085 | "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=", 2086 | "dev": true 2087 | }, 2088 | "querystring-es3": { 2089 | "version": "0.2.1", 2090 | "resolved": "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz", 2091 | "integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=", 2092 | "dev": true 2093 | }, 2094 | "randomatic": { 2095 | "version": "1.1.7", 2096 | "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", 2097 | "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", 2098 | "dev": true, 2099 | "requires": { 2100 | "is-number": "3.0.0", 2101 | "kind-of": "4.0.0" 2102 | }, 2103 | "dependencies": { 2104 | "is-number": { 2105 | "version": "3.0.0", 2106 | "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", 2107 | "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", 2108 | "dev": true, 2109 | "requires": { 2110 | "kind-of": "3.2.2" 2111 | }, 2112 | "dependencies": { 2113 | "kind-of": { 2114 | "version": "3.2.2", 2115 | "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", 2116 | "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", 2117 | "dev": true, 2118 | "requires": { 2119 | "is-buffer": "1.1.6" 2120 | } 2121 | } 2122 | } 2123 | }, 2124 | "kind-of": { 2125 | "version": "4.0.0", 2126 | "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", 2127 | "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", 2128 | "dev": true, 2129 | "requires": { 2130 | "is-buffer": "1.1.6" 2131 | } 2132 | } 2133 | } 2134 | }, 2135 | "range-parser": { 2136 | "version": "1.2.0", 2137 | "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", 2138 | "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=" 2139 | }, 2140 | "raw-body": { 2141 | "version": "2.3.2", 2142 | "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.2.tgz", 2143 | "integrity": "sha1-vNYMd9Prk83gBQKVw/N5OJvIj4k=", 2144 | "requires": { 2145 | "bytes": "3.0.0", 2146 | "http-errors": "1.6.2", 2147 | "iconv-lite": "0.4.19", 2148 | "unpipe": "1.0.0" 2149 | } 2150 | }, 2151 | "readable-stream": { 2152 | "version": "2.3.3", 2153 | "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.3.tgz", 2154 | "integrity": "sha512-m+qzzcn7KUxEmd1gMbchF+Y2eIUbieUaxkWtptyHywrX0rE8QEYqPC07Vuy4Wm32/xE16NcdBctb8S0Xe/5IeQ==", 2155 | "dev": true, 2156 | "requires": { 2157 | "core-util-is": "1.0.2", 2158 | "inherits": "2.0.3", 2159 | "isarray": "1.0.0", 2160 | "process-nextick-args": "1.0.7", 2161 | "safe-buffer": "5.1.1", 2162 | "string_decoder": "1.0.3", 2163 | "util-deprecate": "1.0.2" 2164 | } 2165 | }, 2166 | "readdirp": { 2167 | "version": "2.1.0", 2168 | "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.1.0.tgz", 2169 | "integrity": "sha1-TtCtBg3zBzMAxIRANz9y0cxkLXg=", 2170 | "dev": true, 2171 | "requires": { 2172 | "graceful-fs": "4.1.11", 2173 | "minimatch": "3.0.4", 2174 | "readable-stream": "2.3.3", 2175 | "set-immediate-shim": "1.0.1" 2176 | } 2177 | }, 2178 | "regex-cache": { 2179 | "version": "0.4.4", 2180 | "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", 2181 | "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", 2182 | "dev": true, 2183 | "requires": { 2184 | "is-equal-shallow": "0.1.3" 2185 | } 2186 | }, 2187 | "remove-trailing-separator": { 2188 | "version": "1.1.0", 2189 | "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", 2190 | "integrity": "sha1-wkvOKig62tW8P1jg1IJJuSN52O8=", 2191 | "dev": true 2192 | }, 2193 | "repeat-element": { 2194 | "version": "1.1.2", 2195 | "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz", 2196 | "integrity": "sha1-7wiaF40Ug7quTZPrmLT55OEdmQo=", 2197 | "dev": true 2198 | }, 2199 | "repeat-string": { 2200 | "version": "1.6.1", 2201 | "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", 2202 | "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", 2203 | "dev": true 2204 | }, 2205 | "right-align": { 2206 | "version": "0.1.3", 2207 | "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", 2208 | "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=", 2209 | "dev": true, 2210 | "requires": { 2211 | "align-text": "0.1.4" 2212 | } 2213 | }, 2214 | "ripemd160": { 2215 | "version": "0.2.0", 2216 | "resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-0.2.0.tgz", 2217 | "integrity": "sha1-K/GYveFnys+lHAqSjoS2i74XH84=", 2218 | "dev": true 2219 | }, 2220 | "safe-buffer": { 2221 | "version": "5.1.1", 2222 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", 2223 | "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" 2224 | }, 2225 | "sax": { 2226 | "version": "0.4.2", 2227 | "resolved": "https://registry.npmjs.org/sax/-/sax-0.4.2.tgz", 2228 | "integrity": "sha1-OfO2AXM9a+yXEFskKipA/Wl4rDw=" 2229 | }, 2230 | "send": { 2231 | "version": "0.16.1", 2232 | "resolved": "https://registry.npmjs.org/send/-/send-0.16.1.tgz", 2233 | "integrity": "sha512-ElCLJdJIKPk6ux/Hocwhk7NFHpI3pVm/IZOYWqUmoxcgeyM+MpxHHKhb8QmlJDX1pU6WrgaHBkVNm73Sv7uc2A==", 2234 | "requires": { 2235 | "debug": "2.6.9", 2236 | "depd": "1.1.2", 2237 | "destroy": "1.0.4", 2238 | "encodeurl": "1.0.1", 2239 | "escape-html": "1.0.3", 2240 | "etag": "1.8.1", 2241 | "fresh": "0.5.2", 2242 | "http-errors": "1.6.2", 2243 | "mime": "1.4.1", 2244 | "ms": "2.0.0", 2245 | "on-finished": "2.3.0", 2246 | "range-parser": "1.2.0", 2247 | "statuses": "1.3.1" 2248 | } 2249 | }, 2250 | "serve-static": { 2251 | "version": "1.13.1", 2252 | "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.1.tgz", 2253 | "integrity": "sha512-hSMUZrsPa/I09VYFJwa627JJkNs0NrfL1Uzuup+GqHfToR2KcsXFymXSV90hoyw3M+msjFuQly+YzIH/q0MGlQ==", 2254 | "requires": { 2255 | "encodeurl": "1.0.1", 2256 | "escape-html": "1.0.3", 2257 | "parseurl": "1.3.2", 2258 | "send": "0.16.1" 2259 | } 2260 | }, 2261 | "set-immediate-shim": { 2262 | "version": "1.0.1", 2263 | "resolved": "https://registry.npmjs.org/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz", 2264 | "integrity": "sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E=", 2265 | "dev": true 2266 | }, 2267 | "setimmediate": { 2268 | "version": "1.0.5", 2269 | "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", 2270 | "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=", 2271 | "dev": true 2272 | }, 2273 | "setprototypeof": { 2274 | "version": "1.1.0", 2275 | "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", 2276 | "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" 2277 | }, 2278 | "sha.js": { 2279 | "version": "2.2.6", 2280 | "resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.2.6.tgz", 2281 | "integrity": "sha1-F93t3F9yL7ZlAWWIlUYZd4ZzFbo=", 2282 | "dev": true 2283 | }, 2284 | "source-list-map": { 2285 | "version": "0.1.8", 2286 | "resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-0.1.8.tgz", 2287 | "integrity": "sha1-xVCyq1Qn9rPyH1r+rYjE9Vh7IQY=", 2288 | "dev": true 2289 | }, 2290 | "source-map": { 2291 | "version": "0.5.7", 2292 | "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", 2293 | "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", 2294 | "dev": true 2295 | }, 2296 | "statuses": { 2297 | "version": "1.3.1", 2298 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", 2299 | "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=" 2300 | }, 2301 | "stream-browserify": { 2302 | "version": "2.0.1", 2303 | "resolved": "https://registry.npmjs.org/stream-browserify/-/stream-browserify-2.0.1.tgz", 2304 | "integrity": "sha1-ZiZu5fm9uZQKTkUUyvtDu3Hlyds=", 2305 | "dev": true, 2306 | "requires": { 2307 | "inherits": "2.0.3", 2308 | "readable-stream": "2.3.3" 2309 | } 2310 | }, 2311 | "stream-http": { 2312 | "version": "2.8.0", 2313 | "resolved": "https://registry.npmjs.org/stream-http/-/stream-http-2.8.0.tgz", 2314 | "integrity": "sha512-sZOFxI/5xw058XIRHl4dU3dZ+TTOIGJR78Dvo0oEAejIt4ou27k+3ne1zYmCV+v7UucbxIFQuOgnkTVHh8YPnw==", 2315 | "dev": true, 2316 | "requires": { 2317 | "builtin-status-codes": "3.0.0", 2318 | "inherits": "2.0.3", 2319 | "readable-stream": "2.3.3", 2320 | "to-arraybuffer": "1.0.1", 2321 | "xtend": "4.0.1" 2322 | } 2323 | }, 2324 | "string_decoder": { 2325 | "version": "1.0.3", 2326 | "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", 2327 | "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", 2328 | "dev": true, 2329 | "requires": { 2330 | "safe-buffer": "5.1.1" 2331 | } 2332 | }, 2333 | "supports-color": { 2334 | "version": "3.2.3", 2335 | "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.2.3.tgz", 2336 | "integrity": "sha1-ZawFBLOVQXHYpklGsq48u4pfVPY=", 2337 | "dev": true, 2338 | "requires": { 2339 | "has-flag": "1.0.0" 2340 | } 2341 | }, 2342 | "tapable": { 2343 | "version": "0.1.10", 2344 | "resolved": "https://registry.npmjs.org/tapable/-/tapable-0.1.10.tgz", 2345 | "integrity": "sha1-KcNXB8K3DlDQdIK10gLo7URtr9Q=", 2346 | "dev": true 2347 | }, 2348 | "timers-browserify": { 2349 | "version": "2.0.4", 2350 | "resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-2.0.4.tgz", 2351 | "integrity": "sha512-uZYhyU3EX8O7HQP+J9fTVYwsq90Vr68xPEFo7yrVImIxYvHgukBEgOB/SgGoorWVTzGM/3Z+wUNnboA4M8jWrg==", 2352 | "dev": true, 2353 | "requires": { 2354 | "setimmediate": "1.0.5" 2355 | } 2356 | }, 2357 | "to-arraybuffer": { 2358 | "version": "1.0.1", 2359 | "resolved": "https://registry.npmjs.org/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz", 2360 | "integrity": "sha1-fSKbH8xjfkZsoIEYCDanqr/4P0M=", 2361 | "dev": true 2362 | }, 2363 | "tty-browserify": { 2364 | "version": "0.0.0", 2365 | "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz", 2366 | "integrity": "sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY=", 2367 | "dev": true 2368 | }, 2369 | "type-is": { 2370 | "version": "1.6.15", 2371 | "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.15.tgz", 2372 | "integrity": "sha1-yrEPtJCeRByChC6v4a1kbIGARBA=", 2373 | "requires": { 2374 | "media-typer": "0.3.0", 2375 | "mime-types": "2.1.17" 2376 | } 2377 | }, 2378 | "uglify-js": { 2379 | "version": "2.7.5", 2380 | "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.7.5.tgz", 2381 | "integrity": "sha1-RhLAx7qu4rp8SH3kkErhIgefLKg=", 2382 | "dev": true, 2383 | "requires": { 2384 | "async": "0.2.10", 2385 | "source-map": "0.5.7", 2386 | "uglify-to-browserify": "1.0.2", 2387 | "yargs": "3.10.0" 2388 | }, 2389 | "dependencies": { 2390 | "async": { 2391 | "version": "0.2.10", 2392 | "resolved": "https://registry.npmjs.org/async/-/async-0.2.10.tgz", 2393 | "integrity": "sha1-trvgsGdLnXGXCMo43owjfLUmw9E=", 2394 | "dev": true 2395 | } 2396 | } 2397 | }, 2398 | "uglify-to-browserify": { 2399 | "version": "1.0.2", 2400 | "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz", 2401 | "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=", 2402 | "dev": true 2403 | }, 2404 | "ultron": { 2405 | "version": "1.0.2", 2406 | "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.0.2.tgz", 2407 | "integrity": "sha1-rOEWq1V80Zc4ak6I9GhTeMiy5Po=" 2408 | }, 2409 | "unpipe": { 2410 | "version": "1.0.0", 2411 | "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", 2412 | "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" 2413 | }, 2414 | "url": { 2415 | "version": "0.11.0", 2416 | "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", 2417 | "integrity": "sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE=", 2418 | "dev": true, 2419 | "requires": { 2420 | "punycode": "1.3.2", 2421 | "querystring": "0.2.0" 2422 | }, 2423 | "dependencies": { 2424 | "punycode": { 2425 | "version": "1.3.2", 2426 | "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", 2427 | "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=", 2428 | "dev": true 2429 | } 2430 | } 2431 | }, 2432 | "util": { 2433 | "version": "0.10.3", 2434 | "resolved": "https://registry.npmjs.org/util/-/util-0.10.3.tgz", 2435 | "integrity": "sha1-evsa/lCAUkZInj23/g7TeTNqwPk=", 2436 | "dev": true, 2437 | "requires": { 2438 | "inherits": "2.0.1" 2439 | }, 2440 | "dependencies": { 2441 | "inherits": { 2442 | "version": "2.0.1", 2443 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", 2444 | "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=", 2445 | "dev": true 2446 | } 2447 | } 2448 | }, 2449 | "util-deprecate": { 2450 | "version": "1.0.2", 2451 | "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", 2452 | "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", 2453 | "dev": true 2454 | }, 2455 | "utils-merge": { 2456 | "version": "1.0.1", 2457 | "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", 2458 | "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" 2459 | }, 2460 | "vary": { 2461 | "version": "1.1.2", 2462 | "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", 2463 | "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" 2464 | }, 2465 | "vm-browserify": { 2466 | "version": "0.0.4", 2467 | "resolved": "https://registry.npmjs.org/vm-browserify/-/vm-browserify-0.0.4.tgz", 2468 | "integrity": "sha1-XX6kW7755Kb/ZflUOOCofDV9WnM=", 2469 | "dev": true, 2470 | "requires": { 2471 | "indexof": "0.0.1" 2472 | } 2473 | }, 2474 | "watchpack": { 2475 | "version": "0.2.9", 2476 | "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-0.2.9.tgz", 2477 | "integrity": "sha1-Yuqkq15bo1/fwBgnVibjwPXj+ws=", 2478 | "dev": true, 2479 | "requires": { 2480 | "async": "0.9.2", 2481 | "chokidar": "1.7.0", 2482 | "graceful-fs": "4.1.11" 2483 | }, 2484 | "dependencies": { 2485 | "async": { 2486 | "version": "0.9.2", 2487 | "resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz", 2488 | "integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=", 2489 | "dev": true 2490 | } 2491 | } 2492 | }, 2493 | "webpack": { 2494 | "version": "1.15.0", 2495 | "resolved": "https://registry.npmjs.org/webpack/-/webpack-1.15.0.tgz", 2496 | "integrity": "sha1-T/MfU9sDM55VFkqdRo7gMklo/pg=", 2497 | "dev": true, 2498 | "requires": { 2499 | "acorn": "3.3.0", 2500 | "async": "1.5.2", 2501 | "clone": "1.0.3", 2502 | "enhanced-resolve": "0.9.1", 2503 | "interpret": "0.6.6", 2504 | "loader-utils": "0.2.17", 2505 | "memory-fs": "0.3.0", 2506 | "mkdirp": "0.5.1", 2507 | "node-libs-browser": "0.7.0", 2508 | "optimist": "0.6.1", 2509 | "supports-color": "3.2.3", 2510 | "tapable": "0.1.10", 2511 | "uglify-js": "2.7.5", 2512 | "watchpack": "0.2.9", 2513 | "webpack-core": "0.6.9" 2514 | } 2515 | }, 2516 | "webpack-core": { 2517 | "version": "0.6.9", 2518 | "resolved": "https://registry.npmjs.org/webpack-core/-/webpack-core-0.6.9.tgz", 2519 | "integrity": "sha1-/FcViMhVjad76e+23r3Fo7FyvcI=", 2520 | "dev": true, 2521 | "requires": { 2522 | "source-list-map": "0.1.8", 2523 | "source-map": "0.4.4" 2524 | }, 2525 | "dependencies": { 2526 | "source-map": { 2527 | "version": "0.4.4", 2528 | "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", 2529 | "integrity": "sha1-66T12pwNyZneaAMti092FzZSA2s=", 2530 | "dev": true, 2531 | "requires": { 2532 | "amdefine": "1.0.1" 2533 | } 2534 | } 2535 | } 2536 | }, 2537 | "window-size": { 2538 | "version": "0.1.0", 2539 | "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", 2540 | "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=", 2541 | "dev": true 2542 | }, 2543 | "wordwrap": { 2544 | "version": "0.0.3", 2545 | "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", 2546 | "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=", 2547 | "dev": true 2548 | }, 2549 | "ws": { 2550 | "version": "1.0.1", 2551 | "resolved": "https://registry.npmjs.org/ws/-/ws-1.0.1.tgz", 2552 | "integrity": "sha1-fQsqLljN3YGQOcKcneZQReGzEOk=", 2553 | "requires": { 2554 | "options": "0.0.6", 2555 | "ultron": "1.0.2" 2556 | } 2557 | }, 2558 | "xml2js": { 2559 | "version": "0.2.6", 2560 | "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.2.6.tgz", 2561 | "integrity": "sha1-0gnE5N2h/JxFIUHvQcB39a399sQ=", 2562 | "requires": { 2563 | "sax": "0.4.2" 2564 | } 2565 | }, 2566 | "xmlbuilder": { 2567 | "version": "0.4.2", 2568 | "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-0.4.2.tgz", 2569 | "integrity": "sha1-F3bWXz/brUcKCNhgTN6xxOVA/4M=" 2570 | }, 2571 | "xtend": { 2572 | "version": "4.0.1", 2573 | "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", 2574 | "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=", 2575 | "dev": true 2576 | }, 2577 | "yargs": { 2578 | "version": "3.10.0", 2579 | "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", 2580 | "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", 2581 | "dev": true, 2582 | "requires": { 2583 | "camelcase": "1.2.1", 2584 | "cliui": "2.1.0", 2585 | "decamelize": "1.2.0", 2586 | "window-size": "0.1.0" 2587 | } 2588 | } 2589 | } 2590 | } 2591 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tron", 3 | "version": "1.0.0", 4 | "description": "Real-time multiplayer tron game using GunDB", 5 | "main": "server/server.js", 6 | "scripts": { 7 | "start": "node server/server.js", 8 | "test": "echo \"No tests to run!\" && exit 0", 9 | "build": "webpack --watch" 10 | }, 11 | "repository": { 12 | "type": "git", 13 | "url": "git+https://github.com/PsychoLlama/Tron.git" 14 | }, 15 | "keywords": [ 16 | "tron", 17 | "game", 18 | "html5", 19 | "gun", 20 | "javascript", 21 | "canvas" 22 | ], 23 | "author": "Jesse Gibson", 24 | "license": "ISC", 25 | "bugs": { 26 | "url": "https://github.com/PsychoLlama/Tron/issues" 27 | }, 28 | "homepage": "https://github.com/PsychoLlama/Tron#readme", 29 | "dependencies": { 30 | "express": "^4.13.3", 31 | "gun": "^0.3.5" 32 | }, 33 | "devDependencies": { 34 | "webpack": "^1.12.13" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /server/game/clock.js: -------------------------------------------------------------------------------- 1 | /*jslint node: true*/ 2 | 'use strict'; 3 | var clock = require('../gun').get('time'); 4 | 5 | /* 6 | Clients sync towards the server clock. 7 | On a time request, the server immediately 8 | responds with the time, and the client 9 | adjusts their clock to meet server time + latency. 10 | */ 11 | clock.map().val(function (time, request) { 12 | this.path('recieved').put(new Date().getTime()); 13 | }); 14 | 15 | module.exports = clock; 16 | -------------------------------------------------------------------------------- /server/game/expire.js: -------------------------------------------------------------------------------- 1 | /*jslint node: true, nomen: true*/ 2 | 'use strict'; 3 | 4 | var Gun = require('gun/gun'); 5 | var game = require('./index'); 6 | var options = require('../../shared/options'); 7 | 8 | function expired(player) { 9 | var max, vel = options.speed; 10 | max = Math.max.apply(Math, Object.keys(player)); 11 | 12 | // distance travelled is greater than the board, plus latency 13 | return (Gun.time.is() - (max + options.latency)) * vel > 700; 14 | } 15 | 16 | /* 17 | instead of a fixed timeout, 18 | why not detect wall overlap + latency? 19 | That would speed up kicking. 20 | Move to collision.js to 'shared'. 21 | */ 22 | setInterval(function () { 23 | Gun.obj.map(game.players, function (player, number) { 24 | if (!player) { 25 | return; 26 | } 27 | if (expired(player)) { 28 | console.log('Kicking player', number); 29 | game.db.path(number).put(null); 30 | } 31 | }); 32 | }, 1000); 33 | -------------------------------------------------------------------------------- /server/game/index.js: -------------------------------------------------------------------------------- 1 | /*jslint node: true*/ 2 | 'use strict'; 3 | var Gun = require('gun/gun'); 4 | var gun = require('../gun'); 5 | var players = {}; 6 | var waiting = require('../waitroom'); 7 | 8 | gun.get('players').put({ 9 | 1: null, 10 | 2: null, 11 | 3: null, 12 | 4: null 13 | }).sync(players); 14 | 15 | 16 | module.exports = { 17 | vacant: function () { 18 | return Gun.obj.map(players, function (player, num) { 19 | // check for players who've been chosen, but haven't joined yet. 20 | if (!player && !waiting.chosen[num]) { 21 | return num; 22 | } 23 | }) || null; 24 | }, 25 | db: gun.get('players'), 26 | players: players 27 | }; 28 | -------------------------------------------------------------------------------- /server/gun.js: -------------------------------------------------------------------------------- 1 | /*jslint node: true, nomen: true*/ 2 | 'use strict'; 3 | var gun, Gun = require('gun'); 4 | require('../shared/sync'); 5 | 6 | var fs = require('fs'); 7 | var path = require('path'); 8 | 9 | try { 10 | fs.unlinkSync(path.join(__dirname, '../', 'data.json')); 11 | } catch (e) {} 12 | 13 | module.exports = new Gun(); 14 | 15 | -------------------------------------------------------------------------------- /server/server.js: -------------------------------------------------------------------------------- 1 | /*jslint node: true, nomen: true */ 2 | 'use strict'; 3 | var express = require('express'); 4 | var app = express(); 5 | var port = process.env.PORT || process.argv[2] || 8080; 6 | var waiting = require('./waitroom'); 7 | var game = require('./game'); 8 | 9 | // remove inactive players 10 | require('./game/expire'); 11 | 12 | // sync system clock with clients 13 | //require('../lib/nts'); 14 | //require('./game/clock'); 15 | 16 | app.use(express['static'](__dirname + '/../dist')); 17 | 18 | var Gun = require('gun/gun'); 19 | var gun = require('./gun'); 20 | gun.wsp(app); 21 | 22 | app.listen(port, function () { 23 | console.log('Listening on port', port); 24 | }); 25 | 26 | game.db.map(function (change, number) { 27 | if (change === null) { 28 | console.log('Player slot #' + number, 'is available'); 29 | waiting.next(number); 30 | } 31 | }); 32 | 33 | waiting.room.map(function (player) { 34 | if (!player) { 35 | return; 36 | } 37 | waiting.next(); 38 | }); 39 | -------------------------------------------------------------------------------- /server/waitroom/confirm.js: -------------------------------------------------------------------------------- 1 | /*jslint node: true*/ 2 | 'use strict'; 3 | var list, Gun = require('gun/gun'); 4 | var chosen = require('../gun').get('chosen').put({ 5 | 1: null, 6 | 2: null, 7 | 3: null, 8 | 4: null 9 | }).sync(list = {}); 10 | require('./index').chosen = list; 11 | 12 | // if no response, choose another player 13 | module.exports = function confirm(num, soul) { 14 | var waiting = require('./index'); 15 | 16 | chosen.path(num).put(soul); 17 | 18 | return setTimeout(function () { 19 | 20 | // kick unresponsive players 21 | if (list[num] === soul) { 22 | console.log('Rescanning...'); 23 | waiting.next(num); 24 | confirm(num, soul); 25 | } 26 | }, 5000); 27 | }; 28 | -------------------------------------------------------------------------------- /server/waitroom/index.js: -------------------------------------------------------------------------------- 1 | /*jslint node: true*/ 2 | 'use strict'; 3 | var room, list, gun = require('../gun'); 4 | var Gun = require('gun/gun'); 5 | 6 | list = {}; 7 | 8 | function time(soul) { 9 | return Gun.is.node.state(list, soul); 10 | } 11 | 12 | function players() { 13 | var all = []; 14 | Gun.obj.map(list, function (val, field) { 15 | // filter null values and metadata 16 | if (!val || field === '_') { 17 | return; 18 | } 19 | all.push(val); 20 | }); 21 | return all; 22 | } 23 | 24 | function oldest() { 25 | var all = players(); 26 | 27 | if (!all.length) { 28 | return null; 29 | } 30 | 31 | // get the oldest in the list 32 | return all.reduce(function (last, next) { 33 | return time(last) < time(next) ? last : next; 34 | }); 35 | } 36 | 37 | module.exports = { 38 | next: require('./next'), 39 | list: list, 40 | room: gun.get('waitlist').sync(list, true), 41 | 42 | players: players, 43 | oldest: oldest 44 | }; 45 | 46 | -------------------------------------------------------------------------------- /server/waitroom/next.js: -------------------------------------------------------------------------------- 1 | /*jslint node: true*/ 2 | 'use strict'; 3 | var game = require('../game'); 4 | var confirm = require('./confirm'); 5 | 6 | module.exports = function (num) { 7 | var oldest, waiting = require('./index'); 8 | 9 | num = num || game.vacant(); 10 | 11 | oldest = waiting.oldest(); 12 | 13 | if (!oldest || !num) { 14 | return; 15 | } 16 | 17 | console.log('Now serving', oldest, 'as player', num); 18 | waiting.room.path(oldest).put(null); 19 | 20 | return confirm(num, oldest); 21 | }; 22 | -------------------------------------------------------------------------------- /shared/options.js: -------------------------------------------------------------------------------- 1 | /*jslint node: true*/ 2 | module.exports = { 3 | speed: 0.1, 4 | width: 3, 5 | background: "#202428", 6 | colors: [ 7 | "#18c956", 8 | "#0075c4", 9 | "#ff6044", 10 | "#f2cc6d" 11 | ], 12 | invincibility: 3000, 13 | blinkSpeed: 125, 14 | latency: 3000 15 | }; 16 | -------------------------------------------------------------------------------- /shared/sync.js: -------------------------------------------------------------------------------- 1 | (function (env) { 2 | var Gun = env.window ? env.window.Gun : require('gun/gun'); 3 | 4 | Gun.chain.sync = function (obj, opt) { 5 | var gun = this; 6 | if (!Gun.obj.is(obj)) { 7 | console.log("First parameter is not an object to synchronize too!"); 8 | return gun; 9 | } 10 | if (Gun.bi.is(opt)) { 11 | opt = { 12 | meta: opt 13 | }; 14 | } 15 | opt = opt || {}; 16 | opt.ctx = opt.ctx || {}; 17 | gun.on(function (change, field) { 18 | Gun.obj.map(change, function (val, field) { 19 | if (!obj) { 20 | return 21 | } 22 | if (Gun._.meta == field || field === Gun._.soul) { 23 | if (opt.meta) { 24 | obj[field] = val; 25 | } 26 | return; 27 | } 28 | if (Gun.obj.is(val)) { 29 | var soul = Gun.is.rel(val); 30 | if (opt.ctx[soul + field]) { 31 | return 32 | } // do not re-subscribe. 33 | opt.ctx[soul + field] = true; // unique subscribe! 34 | this.path(field).sync(obj[field] = obj[field] || {}, Gun.obj.copy(opt)); 35 | return; 36 | } 37 | obj[field] = val; 38 | }, this); 39 | }); 40 | return gun; 41 | } 42 | 43 | }(this)); 44 | -------------------------------------------------------------------------------- /web/canvas.js: -------------------------------------------------------------------------------- 1 | /*jslint node: true*/ 2 | 'use strict'; 3 | 4 | var line, canvas, context; 5 | var color = '#303438'; 6 | var height = 10; 7 | var width = 10; 8 | 9 | var last = { 10 | dimension: width 11 | }; 12 | 13 | function Canvas(options) { 14 | if (!(this instanceof Canvas)) { 15 | return new Canvas(options); 16 | } 17 | canvas = canvas || document.querySelector('canvas'); 18 | context = canvas.getContext('2d'); 19 | if (options && options.width && options.height) { 20 | canvas.width = options.width; 21 | canvas.height = options.height; 22 | } 23 | } 24 | 25 | Canvas.prototype = { 26 | constructor: Canvas, 27 | 28 | color: function (style) { 29 | if (!style) { 30 | return this; 31 | } 32 | color = style; 33 | last.color = style; 34 | 35 | return this; 36 | }, 37 | 38 | width: function (setting) { 39 | width = setting; 40 | last.dimension = setting; 41 | 42 | return this; 43 | }, 44 | 45 | height: function (setting) { 46 | height = setting; 47 | last.dimension = setting; 48 | 49 | return this; 50 | }, 51 | 52 | ratio: function (string) { 53 | var setting = string.split(':'); 54 | return this.width(setting[0]).height(setting[1]); 55 | }, 56 | 57 | rect: function (coord) { 58 | context.beginPath(); 59 | context.rect(coord.x, coord.y, width, height); 60 | 61 | return this; 62 | }, 63 | 64 | square: function (coord) { 65 | return this 66 | .height(last.dimension) 67 | .width(last.dimension) 68 | .rect(coord); 69 | }, 70 | 71 | line: function (coord) { 72 | var c = context; 73 | c.lineWidth = width; 74 | c.strokeWidth = width; 75 | 76 | if (!line) { 77 | line = coord; 78 | c.beginPath(); 79 | c.moveTo(coord.x, coord.y); 80 | } else { 81 | c.lineTo(coord.x, coord.y); 82 | } 83 | 84 | return this; 85 | }, 86 | 87 | stroke: function (style) { 88 | this.color(style); 89 | line = undefined; 90 | context.strokeStyle = color; 91 | context.stroke(); 92 | context.closePath(); 93 | 94 | return this; 95 | }, 96 | 97 | fill: function (style) { 98 | this.color(style); 99 | context.fillStyle = color; 100 | context.fill(); 101 | context.closePath(); 102 | 103 | return this; 104 | }, 105 | 106 | clear: function (style) { 107 | var c = canvas; 108 | if (style) { 109 | this.color(style); 110 | } 111 | 112 | return this.height( 113 | c.height 114 | ).width( 115 | c.width 116 | ).rect({ 117 | x: 0, 118 | y: 0 119 | }).fill(); 120 | } 121 | }; 122 | 123 | module.exports = Canvas; 124 | -------------------------------------------------------------------------------- /web/claim.js: -------------------------------------------------------------------------------- 1 | /*jslint node: true*/ 2 | 'use strict'; 3 | 4 | var local = require('./local'); 5 | var player = local.player; 6 | var players = local.players; 7 | var Gun = require('gun/gun'); 8 | var position = require('./position'); 9 | var options = require('../shared/options'); 10 | var invincible = require('./invincibility'); 11 | 12 | 13 | // join the game 14 | module.exports = function (number) { 15 | var start, color, time = Gun.time.is(); 16 | 17 | player.db = players.db.path(number).put({}); 18 | player.index = number; 19 | player.object = players.list[number]; 20 | 21 | // get the player starting point 22 | start = position(number); 23 | player.db.path(time).stringify(start); 24 | 25 | // give the player a chance to escape 26 | invincible.player(player.index, true); 27 | }; 28 | -------------------------------------------------------------------------------- /web/clock.js: -------------------------------------------------------------------------------- 1 | /*jslint node: true*/ 2 | 'use strict'; 3 | var Gun = require('gun/gun'); 4 | var processed, gun = require('./local').gun; 5 | var clock = gun.get('time'); 6 | 7 | 8 | 9 | module.exports = function (callback) { 10 | var adjustment = gun.put({ 11 | sent: Gun.time.is() 12 | }).on(function (msg) { 13 | if (msg.recieved && !processed) { 14 | processed = true; 15 | 16 | var now, latency, diff; 17 | now = Gun.time.is(); 18 | 19 | latency = (now - msg.sent) / 2; 20 | 21 | diff = now - (msg.recieved + latency); 22 | 23 | Gun.time.is = function () { 24 | return Gun.time.is() + Math.round(diff); 25 | }; 26 | 27 | (callback || function () {})(); 28 | } 29 | }); 30 | 31 | window.clock = clock.set(adjustment); 32 | }; 33 | -------------------------------------------------------------------------------- /web/collision.js: -------------------------------------------------------------------------------- 1 | /*jslint plusplus: true, node: true */ 2 | 'use strict'; 3 | var Gun = require('gun/gun'); 4 | var local = require('./local'); 5 | var find = require('./find'); 6 | var path = require('./path'); 7 | var kick = require('./kick'); 8 | var sort = require('./sort'); 9 | var line = require('./line'); 10 | var invincible = require('./invincibility'); 11 | var players = local.players; 12 | var player = local.player; 13 | var position, prev, boundary = 700; 14 | 15 | function tail() { 16 | 17 | // we're not playing yet 18 | if (!position) { 19 | return null; 20 | } 21 | if (!prev) { 22 | prev = position; 23 | } 24 | 25 | /* 26 | If we've turned since the last 27 | collision check, use that turn 28 | as our last position. 29 | */ 30 | if (prev.axis !== position.axis) { 31 | prev = sort(player.object); 32 | prev = prev[prev.length - 1]; 33 | } 34 | 35 | // figure out the path between renders 36 | return line(prev, position); 37 | } 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | function outOfBounds() { 48 | var overflow = {}; 49 | 50 | overflow.x = position.x > boundary || position.x < 0; 51 | overflow.y = position.y > boundary || position.y < 0; 52 | return (overflow.x || overflow.y); 53 | } 54 | 55 | function inPath(line) { 56 | var onLeft, onRight, perp; 57 | perp = (position.axis === 'x') ? 'y' : 'x'; 58 | onLeft = line.start < position[perp]; 59 | onRight = line.end > position[perp]; 60 | 61 | if (onLeft && onRight) { 62 | return true; 63 | } 64 | return false; 65 | } 66 | 67 | function crossing(line) { 68 | // find the path from your last render 69 | 70 | var prev = tail(); 71 | if (line.offset >= prev.start && line.offset <= prev.end) { 72 | return true; 73 | } 74 | if (line.offset <= prev.start && line.offset >= prev.end) { 75 | return true; 76 | } 77 | return false; 78 | } 79 | 80 | function collision() { 81 | var lines = []; 82 | 83 | // add every player's history to the list of lines 84 | Gun.obj.map(players.list, function (player, number) { 85 | var history = path(player); 86 | lines = lines.concat(history); 87 | }); 88 | 89 | /* 90 | Filter out lines that aren't dangerous, 91 | then filter out the ones that aren't in 92 | your way, then filter out the ones you're 93 | not overlapping with. 94 | */ 95 | return lines.filter(function (line) { 96 | return line.axis !== position.axis; 97 | }).filter(inPath).filter(crossing).length; 98 | } 99 | 100 | module.exports = function () { 101 | position = find(player.object); 102 | 103 | if (position) { 104 | var dead = outOfBounds(); 105 | if (!invincible.list[player.index]) { 106 | dead = dead || collision(); 107 | } 108 | if (dead) { 109 | kick(player); 110 | prev = null; 111 | } 112 | } 113 | 114 | /* 115 | After we've run the collision logic, 116 | update our last position with the 117 | current position. 118 | */ 119 | prev = position; 120 | }; 121 | -------------------------------------------------------------------------------- /web/find.js: -------------------------------------------------------------------------------- 1 | /*jslint node: true*/ 2 | 'use strict'; 3 | var Gun = require('gun/gun'); 4 | var sort = require('./sort'); 5 | 6 | 7 | // for distance traveled 8 | var options = { 9 | speed: 0.1 10 | }; 11 | 12 | /* 13 | figure out where the player 14 | a player is from where they 15 | last turned, and how fast they 16 | are travelling. 17 | */ 18 | function distance(coord) { 19 | var delta, elapsed = Gun.time.is() - coord.time; 20 | delta = (elapsed * options.speed) * coord.direction; 21 | 22 | return delta + coord[coord.axis]; 23 | } 24 | 25 | // find the current coordinate of the player 26 | module.exports = function find(player) { 27 | var coord, position; 28 | coord = sort(player); 29 | coord = coord[coord.length - 1]; 30 | 31 | // if the player has no history 32 | if (!coord) { 33 | return null; 34 | } 35 | 36 | // don't mutate the last position, make a copy 37 | position = Gun.obj.copy(coord); 38 | 39 | position[coord.axis] = distance(coord); 40 | position.time = Gun.time.is(); 41 | 42 | return position; 43 | }; 44 | -------------------------------------------------------------------------------- /web/index.js: -------------------------------------------------------------------------------- 1 | /*jslint node: true*/ 2 | 'use strict'; 3 | localStorage.clear(); 4 | 5 | var join = require('./join'); 6 | var render = require('./render'); 7 | var collision = require('./collision'); 8 | //var time = require('./clock'); 9 | 10 | // join the waitroom 11 | //time(join); 12 | join(); 13 | 14 | // initialize keyboard listeners 15 | require('./input'); 16 | 17 | // main rendering/collision detection loop 18 | window.requestAnimationFrame(function loop() { 19 | render(); 20 | collision(); 21 | window.requestAnimationFrame(loop); 22 | }); 23 | -------------------------------------------------------------------------------- /web/input.js: -------------------------------------------------------------------------------- 1 | /*jslint node: true*/ 2 | /*globals stream */ 3 | 'use strict'; 4 | 5 | var turn = require('./turn'); 6 | 7 | var xDown, yDown, canvas; 8 | canvas = document.querySelector('canvas'); 9 | 10 | function turn(direction) { 11 | console.log(direction); 12 | } 13 | 14 | function tie(cb) { 15 | return { 16 | to: function (event, target) { 17 | (target || document).addEventListener(event, cb); 18 | } 19 | }; 20 | } 21 | 22 | // listen for game input 23 | function keyboard(e) { 24 | switch (e.keyCode) { 25 | case 65: 26 | case 37: 27 | return turn('left'); 28 | case 68: 29 | case 39: 30 | return turn('right'); 31 | case 87: 32 | case 38: 33 | return turn('up'); 34 | case 83: 35 | case 40: 36 | return turn('down'); 37 | } 38 | } 39 | 40 | 41 | 42 | /* 43 | shamelessly copied from 44 | a stackoverflow post: 45 | http://stackoverflow.com/questions/2264072/detect-a-finger-swipe-through-javascript-on-the-iphone-and-android#answer-23230280 46 | */ 47 | function touch(e) { 48 | xDown = e.touches[0].clientX; 49 | yDown = e.touches[0].clientY; 50 | } 51 | 52 | function move(e) { 53 | if (!xDown || !yDown) { 54 | return; 55 | } 56 | 57 | var xUp, yUp, xDiff, yDiff; 58 | xUp = e.touches[0].clientX; 59 | yUp = e.touches[0].clientY; 60 | xDiff = xDown - xUp; 61 | yDiff = yDown - yUp; 62 | 63 | xDown = null; 64 | yDown = null; 65 | 66 | if (Math.abs(xDiff) > Math.abs(yDiff)) { 67 | return xDiff > 0 ? turn('left') : turn('right'); 68 | } else { 69 | return yDiff > 0 ? turn('up') : turn('down'); 70 | } 71 | } 72 | 73 | 74 | function resize() { 75 | var width = window.innerWidth, 76 | height = window.innerHeight; 77 | 78 | if (height > width) { 79 | // Centering 80 | canvas.style.left = 0; 81 | canvas.style.top = (height / 2) - (width / 2) + 'px'; 82 | 83 | canvas.style.width = width + "px"; 84 | canvas.style.height = width + "px"; 85 | } else { 86 | // Centering 87 | canvas.style.top = 0; 88 | canvas.style.left = (width / 2) - (height / 2) + 'px'; 89 | 90 | canvas.style.width = height + "px"; 91 | canvas.style.height = height + "px"; 92 | } 93 | } 94 | 95 | 96 | tie(keyboard).to('keydown'); 97 | tie(touch).to('touchstart'); 98 | tie(move).to('touchmove'); 99 | tie(resize).to('resize', window); 100 | 101 | // initial canvas sizing 102 | resize(); 103 | -------------------------------------------------------------------------------- /web/invincibility.js: -------------------------------------------------------------------------------- 1 | /*jslint node: true*/ 2 | 'use strict'; 3 | 4 | var options = require('../shared/options'); 5 | var local = require('./local'); 6 | var style = options.colors; 7 | var list, timeouts, intervals, colors; 8 | intervals = {}; 9 | timeouts = {}; 10 | 11 | // create a copy of the colors object 12 | colors = JSON.parse( 13 | JSON.stringify(options.colors) 14 | ); 15 | var db = local.gun.get('invincible').sync(list = {}); 16 | 17 | function blink(player) { 18 | var index = player - 1; 19 | intervals[player] = setInterval(function () { 20 | 21 | style[index] = style[index] === colors[index] ? 'darkgray' : colors[index]; 22 | }, options.blinkSpeed); 23 | } 24 | 25 | function invincible(player, bool) { 26 | db.path(player).put(bool); 27 | 28 | if (!bool) { 29 | clearTimeout(timeouts[player]); 30 | timeouts[player] = null; 31 | style[player - 1] = colors[player - 1]; 32 | } 33 | } 34 | 35 | 36 | db.map(function (immortal, player) { 37 | if (!immortal) { 38 | clearInterval(intervals[player]); 39 | intervals[player] = null; 40 | } else if (!intervals[player]) { 41 | blink(player); 42 | timeouts[player] = setTimeout(function () { 43 | invincible(player, false); 44 | }, options.invincibility); 45 | } 46 | }); 47 | 48 | module.exports = window.i = { 49 | player: invincible, 50 | list: list 51 | }; 52 | -------------------------------------------------------------------------------- /web/join.js: -------------------------------------------------------------------------------- 1 | /*jslint node: true*/ 2 | 'use strict'; 3 | var Gun = require('gun/gun'); 4 | var local = require('./local'); 5 | var claim = require('./claim'); 6 | var kick = require('./kick'); 7 | var waiting = local.gun.get('waitlist'); 8 | var chosen = local.gun.get('chosen'); 9 | var token; 10 | 11 | function leave() { 12 | kick(local.player, true); 13 | } 14 | chosen.map(function (serving, player) { 15 | 16 | if (serving === token) { 17 | // accept the invite 18 | chosen.path(player).put(null); 19 | 20 | // take the position in the game 21 | claim(player); 22 | 23 | // no support in firefox :( 24 | window.addEventListener('beforeunload', leave); 25 | 26 | // uncomment for production 27 | // window.addEventListener('blur', leave); 28 | } 29 | }); 30 | 31 | module.exports = function () { 32 | token = Gun.text.random(); 33 | return waiting.path(token).put(token); 34 | }; 35 | -------------------------------------------------------------------------------- /web/kick.js: -------------------------------------------------------------------------------- 1 | /*jslint node: true*/ 2 | /*globals gun, stream, players */ 3 | 'use strict'; 4 | 5 | var local = require('./local'); 6 | var invincible = require('./invincibility'); 7 | 8 | module.exports = function (player, done) { 9 | var join = require('./join'); 10 | invincible.player(player.index, false); 11 | 12 | local.players.db.path(player.index).put(null); 13 | player.object = null; 14 | player.index = null; 15 | player.db = null; 16 | 17 | if (!done) { 18 | join(); 19 | } 20 | }; 21 | -------------------------------------------------------------------------------- /web/line.js: -------------------------------------------------------------------------------- 1 | /*jslint node: true*/ 2 | 'use strict'; 3 | 4 | module.exports = function (start, end) { 5 | if (!start || !end) { 6 | return null; 7 | } 8 | var temp, perp, axis = start.axis; 9 | perp = (axis === 'x') ? 'y' : 'x'; 10 | 11 | // always record going from top to bottom, left to right 12 | if (start[axis] > end[axis]) { 13 | temp = start; 14 | start = end; 15 | end = temp; 16 | } 17 | 18 | return { 19 | start: start[axis], 20 | end: end[axis], 21 | offset: end[perp], 22 | axis: axis 23 | }; 24 | }; 25 | -------------------------------------------------------------------------------- /web/local.js: -------------------------------------------------------------------------------- 1 | /*jslint node: true*/ 2 | 'use strict'; 3 | var Gun = require('gun/gun'); 4 | 5 | var players, gun = new Gun(location + 'gun'); 6 | 7 | // synchronous extension 8 | require('../shared/sync'); 9 | 10 | // network time sync extension 11 | //require('../lib/nts'); 12 | 13 | 14 | 15 | Gun.chain.stringify = function (obj) { 16 | return this.put(JSON.stringify(obj)); 17 | }; 18 | 19 | 20 | module.exports = { 21 | gun: gun, 22 | 23 | players: { 24 | db: gun.get('players').sync(players = {}), 25 | list: players 26 | }, 27 | 28 | player: { 29 | db: null, 30 | object: null, 31 | index: null 32 | }, 33 | 34 | justJoined: false 35 | }; 36 | -------------------------------------------------------------------------------- /web/path.js: -------------------------------------------------------------------------------- 1 | /*jslint node: true*/ 2 | 'use strict'; 3 | var find = require('./find'); 4 | var sort = require('./sort'); 5 | var line = require('./line'); 6 | 7 | module.exports = function path(player) { 8 | var position, lines; 9 | if (!player) { 10 | return []; 11 | } 12 | 13 | lines = sort(player); 14 | position = find(player); 15 | if (!lines.length) { 16 | return []; 17 | } 18 | 19 | lines.push(position); 20 | return lines.map(function (start, i) { 21 | if (i === lines.length - 1) { 22 | return; 23 | } 24 | var end = lines[i + 1]; 25 | return line(start, end); 26 | }).filter(Boolean); 27 | }; 28 | -------------------------------------------------------------------------------- /web/position.js: -------------------------------------------------------------------------------- 1 | /*jslint node: true*/ 2 | 'use strict'; 3 | 4 | // naive static starting point for players 5 | module.exports = function (player) { 6 | switch (player) { 7 | case '1': 8 | return { 9 | x: 100, 10 | y: 100, 11 | direction: 1, 12 | axis: 'y' 13 | }; 14 | case '2': 15 | return { 16 | x: 600, 17 | y: 100, 18 | direction: -1, 19 | axis: 'x' 20 | }; 21 | case '3': 22 | return { 23 | x: 600, 24 | y: 600, 25 | direction: -1, 26 | axis: 'y' 27 | }; 28 | case '4': 29 | return { 30 | x: 100, 31 | y: 600, 32 | direction: 1, 33 | axis: 'x' 34 | }; 35 | } 36 | }; 37 | -------------------------------------------------------------------------------- /web/render.js: -------------------------------------------------------------------------------- 1 | /*jslint node: true*/ 2 | 'use strict'; 3 | 4 | var Gun = require('gun/gun'); 5 | var Canvas = require('./canvas'); 6 | var local = require('./local'); 7 | var sort = require('./sort'); 8 | var find = require('./find'); 9 | var options = require('../shared/options'); 10 | var players = local.players.list; 11 | 12 | var canvas = new Canvas({ 13 | width: 700, 14 | height: 700 15 | }); 16 | 17 | // self invoke and begin the render loop 18 | module.exports = function () { 19 | // start fresh 20 | canvas.clear(options.background); 21 | 22 | // for each player... 23 | Gun.obj.map(players, function (player, index) { 24 | // get their lines 25 | var lines = sort(player); 26 | if (lines.length) { 27 | 28 | // add the player's current location 29 | lines.push(find(player)); 30 | 31 | // draw each turn on the canvas 32 | canvas.width(options.width); 33 | lines.forEach(canvas.line); 34 | canvas.stroke(options.colors[index - 1]); 35 | } 36 | }); 37 | 38 | }; 39 | -------------------------------------------------------------------------------- /web/sort.js: -------------------------------------------------------------------------------- 1 | /*jslint node: true*/ 2 | 'use strict'; 3 | 4 | module.exports = function (player) { 5 | var turns, position; 6 | if (!player) { 7 | return []; 8 | } 9 | 10 | return Object.keys(player).sort().map(function (key) { 11 | var coord = JSON.parse(player[key]); 12 | coord.time = parseInt(key, 10); 13 | return coord; 14 | }); 15 | 16 | }; 17 | -------------------------------------------------------------------------------- /web/turn.js: -------------------------------------------------------------------------------- 1 | /*jslint node: true*/ 2 | 'use strict'; 3 | 4 | var Gun = require('gun/gun'); 5 | var find = require('./find'); 6 | var local = require('./local'); 7 | 8 | function turn(axis, direction) { 9 | var position = find(local.player.object); 10 | 11 | return { 12 | direction: direction, 13 | x: position.x, 14 | y: position.y, 15 | axis: axis 16 | }; 17 | } 18 | 19 | function extract(axis, direction) { 20 | if (!direction) { 21 | switch (axis) { 22 | case 'up': 23 | return extract('y', -1); 24 | case 'down': 25 | return extract('y', 1); 26 | case 'left': 27 | return extract('x', -1); 28 | case 'right': 29 | return extract('x', 1); 30 | } 31 | } 32 | return turn(axis, direction); 33 | } 34 | 35 | 36 | module.exports = function (direction) { 37 | var time, turn, position; 38 | position = find(local.player.object); 39 | if (!position) { 40 | return; 41 | } 42 | turn = extract(direction); 43 | time = Gun.time.is(); 44 | 45 | if (position.axis === turn.axis) { 46 | return; 47 | } 48 | 49 | local.player.db.path(time).stringify(turn); 50 | }; 51 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | /*jslint node: true, nomen: true*/ 2 | module.exports = { 3 | context: __dirname + '/web', 4 | entry: './index.js', 5 | output: { 6 | path: __dirname + '/dist', 7 | filename: 'bundle.js' 8 | } 9 | }; 10 | --------------------------------------------------------------------------------