fix SEA GUN reference

This commit is contained in:
Mark Nadal 2018-06-01 09:41:07 -07:00
parent 24eb1d31c0
commit b37b26ef22
3 changed files with 29 additions and 18 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "gun", "name": "gun",
"version": "0.9.997", "version": "0.9.998",
"description": "A realtime, decentralized, offline-first, graph data synchronization engine.", "description": "A realtime, decentralized, offline-first, graph data synchronization engine.",
"main": "index.js", "main": "index.js",
"browser": "gun.min.js", "browser": "gun.min.js",

12
sea.js
View File

@ -741,10 +741,9 @@
})(USE, './authenticate'); })(USE, './authenticate');
;USE(function(module){ ;USE(function(module){
// TODO: BUG! `SEA` needs to be USED!
const Gun = (typeof window !== 'undefined' ? window : global).Gun || USE('gun/gun')
const authsettings = USE('./settings') const authsettings = USE('./settings')
const SEA = USE('./sea'); const SEA = USE('./sea');
const Gun = SEA.Gun;
//const { scope: seaIndexedDb } = USE('./indexed') //const { scope: seaIndexedDb } = USE('./indexed')
// This updates sessionStorage & IndexedDB to persist authenticated "session" // This updates sessionStorage & IndexedDB to persist authenticated "session"
const updateStorage = (proof, key, pin) => async (props) => { const updateStorage = (proof, key, pin) => async (props) => {
@ -790,7 +789,8 @@
})(USE, './update'); })(USE, './update');
;USE(function(module){ ;USE(function(module){
const Gun = (typeof window !== 'undefined' ? window : global).Gun || USE('gun/gun') const SEA = USE('./sea');
const Gun = SEA.Gun;
const Buffer = USE('./buffer') const Buffer = USE('./buffer')
const authsettings = USE('./settings') const authsettings = USE('./settings')
const updateStorage = USE('./update') const updateStorage = USE('./update')
@ -857,9 +857,6 @@
})(USE, './login'); })(USE, './login');
;USE(function(module){ ;USE(function(module){
// TODO: BUG! `SEA` needs to be USEd!
const Gun = (typeof window !== 'undefined' ? window : global).Gun || USE('gun/gun')
const Buffer = USE('./buffer') const Buffer = USE('./buffer')
const authsettings = USE('./settings') const authsettings = USE('./settings')
//const { scope: seaIndexedDb } = USE('./indexed') //const { scope: seaIndexedDb } = USE('./indexed')
@ -867,6 +864,7 @@
const parseProps = USE('./parse') const parseProps = USE('./parse')
const updateStorage = USE('./update') const updateStorage = USE('./update')
const SEA = USE('./sea') const SEA = USE('./sea')
const Gun = SEA.Gun;
const finalizeLogin = USE('./login') const finalizeLogin = USE('./login')
// This internal func recalls persisted User authentication if so configured // This internal func recalls persisted User authentication if so configured
@ -1347,8 +1345,8 @@
})(USE, './create'); })(USE, './create');
;USE(function(module){ ;USE(function(module){
const Gun = (typeof window !== 'undefined' ? window : global).Gun || USE('gun/gun')
const SEA = USE('./sea') const SEA = USE('./sea')
const Gun = SEA.Gun;
// After we have a GUN extension to make user registration/login easy, we then need to handle everything else. // 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) // We do this with a GUN adapter, we first listen to when a gun instance is created (and when its options change)

View File

@ -3,8 +3,8 @@ var config = {
port: 8080, port: 8080,
servers: 2, servers: 2,
browsers: 2, browsers: 2,
each: 10000000, each: 25000,
burst: 12000, burst: 50,
wait: 1, wait: 1,
dir: __dirname, dir: __dirname,
route: { route: {
@ -67,7 +67,7 @@ describe("Make sure the Radix Storage Engine (RSE) works.", function(){
res.end("I am "+ env.i +"!"); res.end("I am "+ env.i +"!");
}); });
var Gun = require('gun'); var Gun = require('gun');
require('gun/lib/store'); //require('gun/lib/store');
var gun = Gun({web: server, localStorage: false, until: 6000}); var gun = Gun({web: server, localStorage: false, until: 6000});
server.listen(port, function(){ server.listen(port, function(){
test.done(); test.done();
@ -108,6 +108,9 @@ describe("Make sure the Radix Storage Engine (RSE) works.", function(){
if(c < l){ return } if(c < l){ return }
setTimeout(function(){ setTimeout(function(){
test.done(); test.done();
setTimeout(function(){
location = 'http://asdf';
}, 1500)
}, 1000); }, 1000);
}); });
} }
@ -122,7 +125,12 @@ describe("Make sure the Radix Storage Engine (RSE) works.", function(){
it("Shut server down!", function(){ it("Shut server down!", function(){
return server.run(function(test){ return server.run(function(test){
process.exit(); test.async();
console.log("giving server 20seconds to cool down...");
setTimeout(function(){
process.exit();
test.done();
}, 20 * 1000);
}); });
}); });
@ -145,8 +153,8 @@ describe("Make sure the Radix Storage Engine (RSE) works.", function(){
res.end("I am "+ env.i +"!"); res.end("I am "+ env.i +"!");
}); });
var Gun = require('gun'); var Gun = require('gun');
require('gun/lib/store'); //require('gun/lib/store');
var gun = Gun({web: server, localStorage: false, thrash: 6000}); var gun = Gun({web: server, localStorage: false, until: 6000});
server.listen(port, function(){ server.listen(port, function(){
test.done(); test.done();
}); });
@ -156,8 +164,6 @@ describe("Make sure the Radix Storage Engine (RSE) works.", function(){
it("Bob read data", function(){ it("Bob read data", function(){
return bob.run(function(test){ return bob.run(function(test){
test.async(); test.async();
test.done();
return;asdf;
console.log("I AM BOB"); console.log("I AM BOB");
localStorage.clear(); localStorage.clear();
var env = test.props; var env = test.props;
@ -168,13 +174,17 @@ describe("Make sure the Radix Storage Engine (RSE) works.", function(){
var raw = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
function check(i){ function check(i){
if(i > l){
return;
}
var d; var d;
var ref = window.gun.get('asdf' + i); var ref = window.gun.get('asdf' + i);
ref.on(function(data){ ref.on(function(data){
if((raw+i) !== data.hello){ return test.fail('wrong ' + i) } if((raw+i) !== data.hello){ return test.fail('wrong ' + i) }
if(d){ return } d = true; if(d){ return } d = true;
!(i % b) && console.log(i+'/'+l);//, '@'+Math.floor(b/((-n + (n = Gun.time.is()))/1000))+'/sec')); //!(c % b) &&
c++; console.log(c+'/'+l);//, '@'+Math.floor(b/((-n + (n = Gun.time.is()))/1000))+'/sec'));
window.GOT = c++;
//localStorage.clear(); //localStorage.clear();
ref.off(); ref.off();
//console.log("gl:", Object.keys(window.gun._.graph).length); //console.log("gl:", Object.keys(window.gun._.graph).length);
@ -184,6 +194,9 @@ describe("Make sure the Radix Storage Engine (RSE) works.", function(){
}); });
} }
function burst(){ function burst(){
if(i > l){
return;
}
for(var j = 0; j <= b; j++){ for(var j = 0; j <= b; j++){
check(++i); check(++i);
} }