From ae68b1352840acd361cb22aec3cb493fc6414f25 Mon Sep 17 00:00:00 2001 From: mhelander Date: Mon, 11 Sep 2017 07:49:18 +0300 Subject: [PATCH 01/27] Added conditional testing support to test/common.js --- test/common.js | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/test/common.js b/test/common.js index 1637cbe6..56935148 100644 --- a/test/common.js +++ b/test/common.js @@ -1,13 +1,26 @@ var root; (function(env){ root = env.window? env.window : global; - env.window && root.localStorage && root.localStorage.clear(); + if(!root.sessionStorage){ + root.sessionStorage = new require('node-localstorage').LocalStorage('session'); + } + root.sessionStorage.clear(); + if(!root.localStorage){ + root.localStorage = new require('node-localstorage').LocalStorage('local'); + } + root.localStorage.clear(); try{ require('fs').unlinkSync('data.json') }catch(e){} //root.Gun = root.Gun || require('../gun'); if(root.Gun){ root.Gun = root.Gun; + if (process.env.SEA && !root.Gun.SEA) { + root.Gun.SEA = require('../sea'); + } } else { root.Gun = require('../gun'); + if (process.env.SEA) { + Gun.SEA = require('../sea'); + } Gun.serve = require('../lib/serve'); //require('./s3'); //require('./uws'); @@ -167,7 +180,7 @@ describe('Performance', function(){ return; // performance tests describe('Gun', function(){ var t = {}; - describe('Utility', function(){ + !Gun.SEA && describe('Utility', function(){ var u; /* // causes logger to no longer log. it('verbose console.log debugging', function(done) { @@ -1395,7 +1408,7 @@ describe('Gun', function(){ }); }); - describe('API', function(){ + !Gun.SEA && describe('API', function(){ var gopt = {wire:{put:function(n,cb){cb()},get:function(k,cb){cb()}}}; var gun = Gun(); @@ -2982,13 +2995,13 @@ describe('Gun', function(){ var parent = gun.get('parent'); var child = gun.get('child'); - + child.put({ way: 'down' }); - + parent.get('sub').put(child); - + parent.get('sub').on(function(data){ //console.log("sub", data); done.sub = data; @@ -3018,7 +3031,7 @@ describe('Gun', function(){ }); it('map val get put', function(done){ - + var gun = Gun().get('chat/asdf'); var check = {}, count = {}; @@ -3492,7 +3505,7 @@ describe('Gun', function(){ var bb = b.get("key"); bb.put({msg: "hello"}); - + d = Gun({file: "ddata"}); var db = d.get("key"); db.map().on(function(val,field){ @@ -3534,11 +3547,11 @@ describe('Gun', function(){ var gun = Gun(); gun.get('ds/safe').put({a: 1}); - + gun.get('ds/safe').on(function(data){ data.b = 2; }); - + gun.get('ds/safe').val(function(data){ expect(gun._.root._.graph['ds/safe'].b).to.not.be.ok(); if(done.c){ return } done.c = 1; @@ -3576,7 +3589,7 @@ describe('Gun', function(){ context._.valid = false; chain._.on('in', {get: key, gun: this}); return false; - } else { + } else { _tags = Gun.obj.ify(obj.tags); if(Array.isArray(filter)){ context._.valid = filter.every(function(f){ return ( _tags[f] && _tags[f]==1) }); From ccdf936304ab583776bda1eeb35b178a6aa1914f Mon Sep 17 00:00:00 2001 From: mhelander Date: Mon, 11 Sep 2017 12:51:24 +0300 Subject: [PATCH 02/27] sea.js bugfix & Gun chat to have SEA & User stuff in comments --- .eslintrc | 29 + .gitignore | 1 + examples/chat/index.html | 13 +- index.js | 9 +- lib/cryptography.js | 12051 +++++++++++++++++++------------------ lib/gunwrapper.js | 15 + lib/serve.mjs | 41 + lib/server.mjs | 7 + package.json | 8 +- sea.js | 7 +- 10 files changed, 6150 insertions(+), 6031 deletions(-) create mode 100644 .eslintrc create mode 100644 lib/gunwrapper.js create mode 100644 lib/serve.mjs create mode 100644 lib/server.mjs diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 00000000..1e642a74 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,29 @@ +{ + "parser": "babel-eslint", + "extends": [ + "standard", + "eslint:recommended" + ], + "plugins": [ + "babel", + "promise" + ], + "env": { + "browser" : true + }, + "globals": { + "__DEV__" : false, + "__TEST__" : false, + "__PROD__" : false, + "__COVERAGE__" : false + }, + "rules": { + "key-spacing" : 0, + "jsx-quotes" : [2, "prefer-single"], + "max-len" : [2, 80, 2], + "object-curly-spacing" : [2, "always"], + "semi" : [2, "never"], + "no-mixed-spaces-and-tabs": [2], + "arrow-parens" : [2, "always"] + } +} diff --git a/.gitignore b/.gitignore index 3080e15d..d29ca697 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ yarn.lock *.bak *.new *.DS_store +.esm-cache diff --git a/examples/chat/index.html b/examples/chat/index.html index 201b8e82..2724b1af 100644 --- a/examples/chat/index.html +++ b/examples/chat/index.html @@ -34,7 +34,7 @@ .poiret { font-family: 'Poiret One', sans-serif; } - .large { + .large { font-size: 200%; } #converse .what, #converse .who { @@ -68,8 +68,19 @@ +