diff --git a/lib/axe.js b/lib/axe.js index dfc1ebfb..81fe8c1d 100644 --- a/lib/axe.js +++ b/lib/axe.js @@ -61,6 +61,10 @@ function start(root){ if(!msg || !msg.get){ return ref } if('string' == typeof (soul = msg.get['#'])){ ref = root.$.get(soul) } if('string' == typeof (tmp = msg.get['.'])){ has = tmp } else { has = '' } + + var via = (msg._||'').via, sub = (via.sub || (via.sub = new Object.Map)); (sub.get(soul) || (sub.set(soul, tmp = new Object.Map) && tmp)).set(has, 1); // {soul: {'':1, has: 1}} // TEMPORARILY REVERT AXE TOWER TYING TO SUBSCRIBING TO EVERYTHING. UNDO THIS! + via.id && ref._ && (ref._.route || (ref._.route = new Object.Map)).set(via.id, via); // SAME AS ^ + return ref; } function LEX(lex){ return (lex = lex || '')['='] || lex['*'] || lex['>'] || lex } diff --git a/package.json b/package.json index 7426cd13..4443403d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gun", - "version": "0.2020.1238", + "version": "0.2020.1239", "description": "A realtime, decentralized, offline-first, graph data synchronization engine.", "types": "index.d.ts", "main": "index.js", diff --git a/sea.js b/sea.js index d5090b4a..af227821 100644 --- a/sea.js +++ b/sea.js @@ -1,7 +1,5 @@ ;(function(){ - var window = this || self || window; - /* UNBUILD */ function USE(arg, req){ return req? require(arg) : arg.slice? USE[R(arg)] : function(mod, path){ @@ -21,6 +19,7 @@ // IT IS IMPLEMENTED IN A POLYFILL/SHIM APPROACH. // THIS IS AN EARLY ALPHA! + if(typeof self !== "undefined"){ module.window = self } // should be safe for at least browser/worker/nodejs, need to check other envs like RN etc. if(typeof window !== "undefined"){ module.window = window } var tmp = module.window || module, u; @@ -179,10 +178,10 @@ })} if(SEA.window){ - api.crypto = window.crypto || window.msCrypto + api.crypto = SEA.window.crypto || SEA.window.msCrypto api.subtle = (api.crypto||o).subtle || (api.crypto||o).webkitSubtle; - api.TextEncoder = window.TextEncoder; - api.TextDecoder = window.TextDecoder; + api.TextEncoder = SEA.window.TextEncoder; + api.TextDecoder = SEA.window.TextDecoder; api.random = (len) => api.Buffer.from(api.crypto.getRandomValues(new Uint8Array(api.Buffer.alloc(len)))); } if(!api.TextDecoder) @@ -846,7 +845,7 @@ })(USE, './user'); ;USE(function(module){ - var u, Gun = (''+u != typeof window)? (window.Gun||{chain:{}}) : USE((''+u === typeof MODULE?'.':'')+'./gun', 1); + var u, Gun = (''+u != typeof GUN)? (GUN||{chain:{}}) : USE((''+u === typeof MODULE?'.':'')+'./gun', 1); Gun.chain.then = function(cb, opt){ var gun = this, p = (new Promise(function(res, rej){ gun.once(res, opt); @@ -951,7 +950,7 @@ } if(SEA.window){ try{var sS = {}; - sS = window.sessionStorage; + sS = SEA.window.sessionStorage; delete sS.recall; delete sS.pair; }catch(e){}; @@ -1040,7 +1039,7 @@ if(SEA.window && ((gun.back('user')._).opt||opt).remember){ // TODO: this needs to be modular. try{var sS = {}; - sS = window.sessionStorage; // TODO: FIX BUG putting on `.is`! + sS = SEA.window.sessionStorage; // TODO: FIX BUG putting on `.is`! sS.recall = true; sS.pair = JSON.stringify(pair); // auth using pair is more reliable than alias/pass }catch(e){} @@ -1131,7 +1130,7 @@ if(SEA.window){ try{ var sS = {}; - sS = window.sessionStorage; // TODO: FIX BUG putting on `.is`! + sS = SEA.window.sessionStorage; // TODO: FIX BUG putting on `.is`! if(sS){ (root._).opt.remember = true; ((gun.back('user')._).opt||opt).remember = true; @@ -1289,7 +1288,7 @@ ;USE(function(module){ var SEA = USE('./sea'), S = USE('./settings'), noop = function() {}, u; - var Gun = (''+u != typeof window)? (window.Gun||{on:noop}) : USE((''+u === typeof MODULE?'.':'')+'./gun', 1); + var Gun = (SEA.window||'').GUN || USE((''+u === typeof MODULE?'.':'')+'./gun', 1); // After we have a GUN extension to make user registration/login easy, we then need to handle everything else. // We do this with a GUN adapter, we first listen to when a gun instance is created (and when its options change) diff --git a/test/panic/4putackdedup.js b/test/panic/4putackdedup.js index 2ce65823..20f29772 100644 --- a/test/panic/4putackdedup.js +++ b/test/panic/4putackdedup.js @@ -104,10 +104,12 @@ describe("Dedup load balancing GETs", function(){ return; } - var gun = Gun({peers: peers, web: server, rad: false, radisk: false, file: false, localStorage: false, axe: false}); + var gun = Gun({peers: peers, web: server, rad: false, radisk: false, file: false, localStorage: false}); server.listen(port, function(){ test.done(); }); + + //gun.get('test').put({tmp: 1}); // temporary workaround for bug. }, {i: i += 1, config: config})); }); return Promise.all(tests); @@ -168,7 +170,6 @@ describe("Dedup load balancing GETs", function(){ return; } if(Math.random() > (ok['@'] / ok['/'])){ return } - console.log('ack?', JSON.stringify(msg)); //console.log("WAS THE SPECIAL ONE TO ACK!", JSON.stringify(msg)); gun.on('out', {'@': msg['#'], ok: {yay: 1}}); });