diff --git a/gun.js b/gun.js index 29921d9c..21167029 100644 --- a/gun.js +++ b/gun.js @@ -832,8 +832,6 @@ if(typeof window !== "undefined"){ window.Gun = Gun } if(typeof common !== "undefined"){ common.exports = Gun } module.exports = Gun; - - Gun.log.once("0.8", "0.8 WARNING! Breaking changes, test that your app works before upgrading! The adapter interface has been upgraded (non-default storage and transport layers probably won't work). Also, `.path()` and `.not()` are outside core and now in 'lib/'."); })(require, './root'); ;require(function(module){ diff --git a/gun.min.js b/gun.min.js index ac01f399..13c3d127 100644 --- a/gun.min.js +++ b/gun.min.js @@ -1 +1 @@ -!function(){function t(n){function o(t){return t.split("/").slice(-1).toString().replace(".js","")}return n.slice?t[o(n)]:function(e,i){n(e={exports:{}}),t[o(i)]=e.exports}}var n;"undefined"!=typeof window&&(n=window),"undefined"!=typeof global&&(n=global);var o=(n=n||{}).console||{log:function(){}};if("undefined"!=typeof module)var e=module;t(function(t){var n={};n.fns=n.fn={is:function(t){return!!t&&"function"==typeof t}},n.bi={is:function(t){return t instanceof Boolean||"boolean"==typeof t}},n.num={is:function(t){return!e(t)&&(t-parseFloat(t)+1>=0||1/0===t||-1/0===t)}},n.text={is:function(t){return"string"==typeof t}},n.text.ify=function(t){return n.text.is(t)?t:"undefined"!=typeof JSON?JSON.stringify(t):t&&t.toString?t.toString():t},n.text.random=function(t,n){var o="";for(t=t||24,n=n||"0123456789ABCDEFGHIJKLMNOPQRSTUVWXZabcdefghijklmnopqrstuvwxyz";t>0;)o+=n.charAt(Math.floor(Math.random()*n.length)),t--;return o},n.text.match=function(t,o){var e=!1;if(t=t||"",o=n.text.is(o)?{"=":o}:o||{},n.obj.has(o,"~")&&(t=t.toLowerCase(),o["="]=(o["="]||o["~"]).toLowerCase()),n.obj.has(o,"="))return t===o["="];if(n.obj.has(o,"*")){if(t.slice(0,o["*"].length)!==o["*"])return!1;e=!0,t=t.slice(o["*"].length)}if(n.obj.has(o,"!")){if(t.slice(-o["!"].length)!==o["!"])return!1;e=!0}if(n.obj.has(o,"+")&&n.list.map(n.list.is(o["+"])?o["+"]:[o["+"]],function(n){if(!(t.indexOf(n)>=0))return!0;e=!0}))return!1;if(n.obj.has(o,"-")&&n.list.map(n.list.is(o["-"])?o["-"]:[o["-"]],function(n){if(!(t.indexOf(n)<0))return!0;e=!0}))return!1;if(n.obj.has(o,">")){if(!(t>o[">"]))return!1;e=!0}if(n.obj.has(o,"<")){if(!(to?1:0):0}},n.list.map=function(t,n,o){return a(t,n,o)},n.list.index=1,n.obj={is:function(t){return!!t&&(t instanceof Object&&t.constructor===Object||"Object"===Object.prototype.toString.call(t).match(/^\[object (\w+)\]$/)[1])}},n.obj.put=function(t,n,o){return(t||{})[n]=o,t},n.obj.has=function(t,n){return t&&Object.prototype.hasOwnProperty.call(t,n)},n.obj.del=function(t,n){if(t)return t[n]=null,delete t[n],t},n.obj.as=function(t,n,o,e){return t[n]=t[n]||(e===o?{}:o)},n.obj.ify=function(t){if(r(t))return t;try{t=JSON.parse(t)}catch(n){t={}}return t},function(){function t(t,n){u(this,n)&&o!==this[n]||(this[n]=t)}var o;n.obj.to=function(n,o){return o=o||{},a(n,t,o),o}}(),n.obj.copy=function(t){return t?JSON.parse(JSON.stringify(t)):t},function(){function t(t,n){var o=this.n;if(!o||!(n===o||r(o)&&u(o,n)))return!!n||void 0}n.obj.empty=function(n,o){return!n||!a(n,t,{n:o})}}(),function(){function t(n,o){if(2===arguments.length)return t.r=t.r||{},void(t.r[n]=o);t.r=t.r||[],t.r.push(n)}var i=Object.keys;n.obj.map=function(a,s,f){var c,l,p,g,h,d=0,v=o(s);if(t.r=null,i&&r(a)&&(g=i(a),h=!0),e(a)||g)for(l=(g||a).length;d",o.drift=0,o.is=function(t,n,e){var i=n&&t&&t[k]&&t[k][o._]||e;if(i)return b(i=i[n])?i:-1/0},o.ify=function(t,n,e,r,u){if(!t||!t[k]){if(!u)return;t=i.soul.ify(t,u)}var a=g(t[k],o._);return l!==n&&n!==k&&(b(e)&&(a[n]=e),l!==r&&(t[n]=r)),t},o.to=function(t,n,e){var r=t[n];return d(r)&&(r=_(r)),o.ify(e,n,o.is(t,n),r,i.soul(t))},function(){function t(t,n){k!==n&&o.ify(this.o,n,this.s)}o.map=function(n,e,i){var r,u=d(u=n||e)?u:null;return n=m(n=n||e)?n:null,u&&!n?(e=b(e)?e:o(),u[k]=u[k]||{},v(u,t,{o:u,s:e}),u):(i=i||d(e)?e:r,e=b(e)?e:o(),function(o,u,a,s){if(!n)return t.call({o:a,s:e},o,u),o;n.call(i||this||{},o,u,a,s),h(a,u)&&r===a[u]||t.call({o:a,s:e},o,u)})}}();var l,p=e.obj,g=p.as,h=p.has,d=p.is,v=p.map,_=p.copy,b=e.num.is,m=e.fn.is,k=i._;n.exports=o})(t,"./state"),t(function(n){var o=t("./type"),e=t("./val"),i=t("./node"),r={};!function(){function t(t,o){if(!t||o!==i.soul(t)||!i.is(t,this.fn,this.as))return!0;this.cb&&(n.n=t,n.as=this.as,this.cb.call(n.as,t,o,n))}function n(t){t&&i.is(n.n,t,n.as)}r.is=function(n,o,e,i){return!(!n||!s(n)||l(n))&&!g(n,t,{cb:o,fn:e,as:i})}}(),function(){function t(t,r){var u;return(u=l(t,r))?u:(r.env=t,r.soul=o,i.ify(r.obj,n,r)&&(t.graph[e.rel.is(r.rel)]=r.node),r)}function n(n,o,r){var s,l,p=this,g=p.env;if(i._===o&&c(n,e.rel._))return r._;if(s=a(n,o,r,p,g)){if(o||(p.node=p.node||r||{},c(n,i._)&&(p.node._=h(n._)),p.node=i.soul.ify(p.node,e.rel.is(p.rel)),p.rel=p.rel||e.rel.ify(i.soul(p.node))),(l=g.map)&&(l.call(g.as||{},n,o,r,p),c(r,o))){if(n=r[o],u===n)return void f(r,o);if(!(s=a(n,o,r,p,g)))return}if(!o)return p.node;if(!0===s)return n;if((l=t(g,{obj:n,path:p.path.concat(o)})).node)return l.rel}}function o(t){var n=this,o=e.rel.is(n.rel),r=n.env.graph;n.rel=n.rel||e.rel.ify(t),n.rel[e.rel._]=t,n.node&&n.node[i._]&&(n.node[i._][e.rel._]=t),c(r,o)&&(r[t]=r[o],f(r,o))}function a(t,n,o,i,r){var u;return!!e.is(t)||(s(t)?1:(u=r.invalid)?(t=u.call(r.as||{},t,n,o),a(t,n,o,i,r)):void(r.err="Invalid value at '"+i.path.concat(n).join(".")+"'!"))}function l(t,n){for(var o,e=t.seen,i=e.length;i--;)if(o=e[i],n.obj===o.obj)return o;e.push(n)}r.ify=function(n,o,i){var r={path:[],obj:n};return o?"string"==typeof o?o={soul:o}:o instanceof Function&&(o.map=o):o={},o.soul&&(r.rel=e.rel.ify(o.soul)),o.graph=o.graph||{},o.seen=o.seen||[],o.as=o.as||i,t(o,r),o.root=r.node,o.graph}}(),r.node=function(t){var n=i.soul(t);if(n)return p({},n,t)},function(){function t(t,n){var o,u;if(i._!==n)(o=e.rel.is(t))?(u=this.opt.seen[o])?this.obj[n]=u:this.obj[n]=this.opt.seen[o]=r.to(this.graph,o,this.opt):this.obj[n]=t;else{if(l(t,e.rel._))return;this.obj[n]=h(t)}}r.to=function(n,o,e){if(n){var i={};return e=e||{seen:{}},g(n[o],t,{obj:i,graph:n,opt:e}),i}}}();o.fn.is;var u,a=o.obj,s=a.is,f=a.del,c=a.has,l=a.empty,p=a.put,g=a.map,h=a.copy;n.exports=r})(t,"./graph"),t(function(n){t("./onto"),n.exports=function(t,n){if(this.on){if(!(t instanceof Function)){if(!t||!n)return;var o=t["#"]||t,e=(this.tag||empty)[o];if(!e)return;return e=this.on(o,n),clearTimeout(e.err),!0}o=n&&n["#"]||Math.random().toString(36).slice(2);if(!t)return o;var i=this.on(o,t,n);return i.err=i.err||setTimeout(function(){i.next({err:"Error: No ACK received yet."}),i.off()},9e3),o}}})(t,"./ask"),t(function(n){var o=t("./type"),e=o.time.is;n.exports=function(t){var n={s:{}};return t=t||{max:1e3,age:9e3},n.check=function(t){return!!n.s[t]&&n.track(t)},n.track=function(i){return n.s[i]=e(),n.to||(n.to=setTimeout(function(){o.obj.map(n.s,function(i,r){t.age>e()-i||o.obj.del(n.s,r)}),n.to=null},t.age)),i},n}})(t,"./dup"),t(function(n){function i(t){return t instanceof i?(this._={gun:this}).gun:this instanceof i?i.create(this._={gun:this,opt:t}):new i(t)}i.is=function(t){return t instanceof i},i.version=.8,i.chain=i.prototype,i.chain.toJSON=function(){};var r=t("./type");r.obj.to(r,i),i.HAM=t("./HAM"),i.val=t("./val"),i.node=t("./node"),i.state=t("./state"),i.graph=t("./graph"),i.on=t("./onto"),i.ask=t("./ask"),i.dup=t("./dup"),i._={node:i.node._,soul:i.val.rel._,state:i.state._,field:".",value:"="},function(){function t(t){var n,o=this.as,e=o.gun;(n=t["#"])||(n=t["#"]=c(9)),o.dup.check(n)||(o.dup.track(n),t=h(t),o.ask(t["@"],t)||(t.get&&i.on.get(t,e),t.put&&i.on.put(t,e)),o.on("out",t))}i.create=function(n){n.root=n.root||n.gun,n.graph=n.graph||{},n.on=n.on||i.on,n.ask=n.ask||i.ask,n.dup=n.dup||i.dup();var o=n.gun.opt(n.opt);return n.once||(n.on("in",t,n),n.on("out",t,n)),n.once=1,o}}(),function(){function t(t,n,o,e){var r=this,u=i.state.is(o,n);if(!u)return r.err="Error: No state on '"+n+"' in node '"+e+"'!";var a=r.graph[e]||m,s=i.state.is(a,n,!0),f=a[n],c=i.HAM(r.machine,u,s,t,f);c.incoming?(r.put[e]=i.state.to(o,n,r.put[e]),(r.diff||(r.diff={}))[e]=i.state.to(o,n,r.diff[e])):c.defer&&(r.defer=u<(r.defer||1/0)?u:r.defer)}function n(t,n){var e=(this.gun._.next||m)[n];if(e){var i=this.map[n]={put:this.node=t,get:this.soul=n,gun:this.at=e};this.ack&&(i["@"]=this.ack),d(t,o,this)}}function o(t,n){var o=this.graph,e=this.soul,r=this.at._;o[e]=i.state.to(this.node,n,o[e]),r.put=i.state.to(this.node,n,r.put)}function e(t,n){var o;if(t.gun)return(o=this.gun._).tag.node?o.on("node",function(t){this.off(),t.gun._.on("in",t)}).on.on("node",t):void t.gun._.on("in",t)}i.on.put=function(o,r){var a=r._,s={gun:r,graph:a.graph,put:{},map:{},machine:i.state(),ack:o["@"]};if(i.graph.is(o.put,null,t,s)||(s.err="Error: Invalid graph!"),s.err)return a.on("in",{"@":o["#"],err:i.log(s.err)});d(s.put,n,s),d(s.map,e,s),u!==s.defer&&setTimeout(function(){i.on.put(o,r)},s.defer-a.machine),s.diff&&a.on("put",h(o,{put:s.diff}))},i.on.get=function(t,n){var o=n._,e=t.get[_],r=o.graph[e],u=t.get[b],a=((o.next||(o.next={}))[e]||m)._;if(!r||!a)return o.on("get",t);if(u){if(!g(r,u))return o.on("get",t);r=i.state.to(r,u)}else r=i.obj.copy(r);r=i.graph.node(r),o.on("in",{"@":t["#"],put:r,gun:n}),o.on("get",t)}}(),i.chain.opt=function(t){t=t||{};var n=this,o=n._,e=t.peers||t;return p(t)||(t={}),p(o.opt)||(o.opt=t),f(e)&&(e=[e]),a(e)&&(e=d(e,function(t,n,o){o(t,{url:t})}),p(o.opt.peers)||(o.opt.peers={}),o.opt.peers=h(e,o.opt.peers)),o.opt.uuid=o.opt.uuid||function(){return v().toString(36).replace(".","")+c(12)},o.opt.peers=o.opt.peers||{},h(t,o.opt),i.on("opt",o),n};var u,a=i.list.is,s=i.text,f=s.is,c=s.random,l=i.obj,p=l.is,g=l.has,h=l.to,d=l.map,v=(l.copy,i.state),_=i._.soul,b=i._.field,m=(i._.node,i.val.rel.is,{});o.debug=function(t,n){return o.debug.i&&t===o.debug.i&&o.debug.i++&&(o.log.apply(o,arguments)||n)},i.log=function(){return!i.log.off&&o.log.apply(o,arguments),[].slice.call(arguments).join(" ")},i.log.once=function(t,n,o){return(o=i.log.once)[t]=o[t]||0,o[t]++||i.log(n)},i.log.once("welcome","Hello wonderful person! :) Thanks for using GUN, feel free to ask for help on https://gitter.im/amark/gun and ask StackOverflow questions tagged with 'gun'!"),"undefined"!=typeof window&&(window.Gun=i),void 0!==e&&(e.exports=i),n.exports=i,i.log.once("0.8","0.8 WARNING! Breaking changes, test that your app works before upgrading! The adapter interface has been upgraded (non-default storage and transport layers probably won't work). Also, `.path()` and `.not()` are outside core and now in 'lib/'.")})(t,"./root"),t(function(n){t("./root").chain.back=function(t,n){if(-1===(t=t||1)||1/0===t)return this._.root;if(1===t)return this._.back||this;var i=this,r=i._;if("string"==typeof t&&(t=t.split(".")),!(t instanceof Array)){if(t instanceof Function){for(var u,a={back:i};(a=a.back)&&(a=a._)&&!(u=t(a,n)););return u}return this}var s=0,f=t.length,a=r;for(s;s=(n.batch||1e3))return s();o||(o=setTimeout(s,n.wait||1))}),t.on("get",function(o){this.to.next(o);var e,i,r=o.get;if(r&&(e=r[Gun._.soul])){var a=r["."];(i=u[e]||void 0)&&a&&(i=Gun.state.to(i,a)),(i||Gun.obj.empty(n.peers))&&t.on("in",{"@":o["#"],put:Gun.graph.node(i),how:"lS"})}});var a=function(t,n,o,e){u[e]=Gun.state.to(o,n,u[e])},s=function(){var a;r=0,clearTimeout(o),o=!1;var s=i;i={};try{e.setItem(n.file,JSON.stringify(u))}catch(t){Gun.log(a=t||"localStorage failure")}(a||Gun.obj.empty(n.peers))&&Gun.obj.map(s,function(n,o){t.on("in",{"@":o,err:a,ok:0})})}}})}})(t,"./adapters/localStorage"),t(function(n){var o,e=t("./index");"undefined"!=typeof WebSocket?o=WebSocket:("undefined"!=typeof webkitWebSocket&&(o=webkitWebSocket),"undefined"!=typeof mozWebSocket&&(o=mozWebSocket)),e.on("opt",function(t){function n(t){var n=this,o=c,e=t.wire||u(t,n);e&&(e.readyState!==e.OPEN?(t.queue=t.queue||[]).push(o):e.send(o))}function r(t,n,o){if(o&&t){try{t=JSON.parse(t.data||t)}catch(t){}if(t instanceof Array)for(var e,u=0;e=t[u++];)r(e,n,o);else 1==f.who&&(t.ws=i),o.on("in",t)}}function u(i,u){if(i&&i.url){var s=i.url.replace("http","ws"),f=i.wire=new o(s);return f.onclose=function(){t.on("bye",i),a(i,u)},f.onerror=function(t){a(i,u),t&&t.code},f.onopen=function(){t.on("hi",i);var o=i.queue;i.queue=[],e.obj.map(o,function(t){c=t,n.call(u,i)})},f.onmessage=function(t){r(t,i,u)},f}}function a(t,n){clearTimeout(t.defer),t.defer=setTimeout(function(){u(t,n)},2e3)}this.to.next(t);var s=t.opt;if(!t.once&&o&&!1!==s.WebSocket){var f=s.ws||(s.ws={});if(f.who=0,e.obj.map(s.peers,function(){++f.who}),!t.once){var c;t.on("out",function(o){this.to.next(o),o.ws&&1==f.who||(c=JSON.stringify(o),f.drain?f.drain.push(c):(f.drain=[],setTimeout(function(){if(f.drain){var o=f.drain;f.drain=null,o.length&&(c=JSON.stringify(o),e.obj.map(s.peers,n,t))}},s.wait||1),e.obj.map(s.peers,n,t)))})}}});var i=function(){}})(t,"./adapters/websocket")}(); \ No newline at end of file +!function(){function t(n){function o(t){return t.split("/").slice(-1).toString().replace(".js","")}return n.slice?t[o(n)]:function(e,i){n(e={exports:{}}),t[o(i)]=e.exports}}var n;"undefined"!=typeof window&&(n=window),"undefined"!=typeof global&&(n=global);var o=(n=n||{}).console||{log:function(){}};if("undefined"!=typeof module)var e=module;t(function(t){var n={};n.fns=n.fn={is:function(t){return!!t&&"function"==typeof t}},n.bi={is:function(t){return t instanceof Boolean||"boolean"==typeof t}},n.num={is:function(t){return!e(t)&&(t-parseFloat(t)+1>=0||1/0===t||-1/0===t)}},n.text={is:function(t){return"string"==typeof t}},n.text.ify=function(t){return n.text.is(t)?t:"undefined"!=typeof JSON?JSON.stringify(t):t&&t.toString?t.toString():t},n.text.random=function(t,n){var o="";for(t=t||24,n=n||"0123456789ABCDEFGHIJKLMNOPQRSTUVWXZabcdefghijklmnopqrstuvwxyz";t>0;)o+=n.charAt(Math.floor(Math.random()*n.length)),t--;return o},n.text.match=function(t,o){var e=!1;if(t=t||"",o=n.text.is(o)?{"=":o}:o||{},n.obj.has(o,"~")&&(t=t.toLowerCase(),o["="]=(o["="]||o["~"]).toLowerCase()),n.obj.has(o,"="))return t===o["="];if(n.obj.has(o,"*")){if(t.slice(0,o["*"].length)!==o["*"])return!1;e=!0,t=t.slice(o["*"].length)}if(n.obj.has(o,"!")){if(t.slice(-o["!"].length)!==o["!"])return!1;e=!0}if(n.obj.has(o,"+")&&n.list.map(n.list.is(o["+"])?o["+"]:[o["+"]],function(n){if(!(t.indexOf(n)>=0))return!0;e=!0}))return!1;if(n.obj.has(o,"-")&&n.list.map(n.list.is(o["-"])?o["-"]:[o["-"]],function(n){if(!(t.indexOf(n)<0))return!0;e=!0}))return!1;if(n.obj.has(o,">")){if(!(t>o[">"]))return!1;e=!0}if(n.obj.has(o,"<")){if(!(to?1:0):0}},n.list.map=function(t,n,o){return a(t,n,o)},n.list.index=1,n.obj={is:function(t){return!!t&&(t instanceof Object&&t.constructor===Object||"Object"===Object.prototype.toString.call(t).match(/^\[object (\w+)\]$/)[1])}},n.obj.put=function(t,n,o){return(t||{})[n]=o,t},n.obj.has=function(t,n){return t&&Object.prototype.hasOwnProperty.call(t,n)},n.obj.del=function(t,n){if(t)return t[n]=null,delete t[n],t},n.obj.as=function(t,n,o,e){return t[n]=t[n]||(e===o?{}:o)},n.obj.ify=function(t){if(r(t))return t;try{t=JSON.parse(t)}catch(n){t={}}return t},function(){function t(t,n){u(this,n)&&o!==this[n]||(this[n]=t)}var o;n.obj.to=function(n,o){return o=o||{},a(n,t,o),o}}(),n.obj.copy=function(t){return t?JSON.parse(JSON.stringify(t)):t},function(){function t(t,n){var o=this.n;if(!o||!(n===o||r(o)&&u(o,n)))return!!n||void 0}n.obj.empty=function(n,o){return!n||!a(n,t,{n:o})}}(),function(){function t(n,o){if(2===arguments.length)return t.r=t.r||{},void(t.r[n]=o);t.r=t.r||[],t.r.push(n)}var i=Object.keys;n.obj.map=function(a,s,f){var c,l,p,g,h,d=0,v=o(s);if(t.r=null,i&&r(a)&&(g=i(a),h=!0),e(a)||g)for(l=(g||a).length;d",o.drift=0,o.is=function(t,n,e){var i=n&&t&&t[k]&&t[k][o._]||e;if(i)return b(i=i[n])?i:-1/0},o.ify=function(t,n,e,r,u){if(!t||!t[k]){if(!u)return;t=i.soul.ify(t,u)}var a=g(t[k],o._);return l!==n&&n!==k&&(b(e)&&(a[n]=e),l!==r&&(t[n]=r)),t},o.to=function(t,n,e){var r=t[n];return d(r)&&(r=_(r)),o.ify(e,n,o.is(t,n),r,i.soul(t))},function(){function t(t,n){k!==n&&o.ify(this.o,n,this.s)}o.map=function(n,e,i){var r,u=d(u=n||e)?u:null;return n=m(n=n||e)?n:null,u&&!n?(e=b(e)?e:o(),u[k]=u[k]||{},v(u,t,{o:u,s:e}),u):(i=i||d(e)?e:r,e=b(e)?e:o(),function(o,u,a,s){if(!n)return t.call({o:a,s:e},o,u),o;n.call(i||this||{},o,u,a,s),h(a,u)&&r===a[u]||t.call({o:a,s:e},o,u)})}}();var l,p=e.obj,g=p.as,h=p.has,d=p.is,v=p.map,_=p.copy,b=e.num.is,m=e.fn.is,k=i._;n.exports=o})(t,"./state"),t(function(n){var o=t("./type"),e=t("./val"),i=t("./node"),r={};!function(){function t(t,o){if(!t||o!==i.soul(t)||!i.is(t,this.fn,this.as))return!0;this.cb&&(n.n=t,n.as=this.as,this.cb.call(n.as,t,o,n))}function n(t){t&&i.is(n.n,t,n.as)}r.is=function(n,o,e,i){return!(!n||!s(n)||l(n))&&!g(n,t,{cb:o,fn:e,as:i})}}(),function(){function t(t,r){var u;return(u=l(t,r))?u:(r.env=t,r.soul=o,i.ify(r.obj,n,r)&&(t.graph[e.rel.is(r.rel)]=r.node),r)}function n(n,o,r){var s,l,p=this,g=p.env;if(i._===o&&c(n,e.rel._))return r._;if(s=a(n,o,r,p,g)){if(o||(p.node=p.node||r||{},c(n,i._)&&(p.node._=h(n._)),p.node=i.soul.ify(p.node,e.rel.is(p.rel)),p.rel=p.rel||e.rel.ify(i.soul(p.node))),(l=g.map)&&(l.call(g.as||{},n,o,r,p),c(r,o))){if(n=r[o],u===n)return void f(r,o);if(!(s=a(n,o,r,p,g)))return}if(!o)return p.node;if(!0===s)return n;if((l=t(g,{obj:n,path:p.path.concat(o)})).node)return l.rel}}function o(t){var n=this,o=e.rel.is(n.rel),r=n.env.graph;n.rel=n.rel||e.rel.ify(t),n.rel[e.rel._]=t,n.node&&n.node[i._]&&(n.node[i._][e.rel._]=t),c(r,o)&&(r[t]=r[o],f(r,o))}function a(t,n,o,i,r){var u;return!!e.is(t)||(s(t)?1:(u=r.invalid)?(t=u.call(r.as||{},t,n,o),a(t,n,o,i,r)):void(r.err="Invalid value at '"+i.path.concat(n).join(".")+"'!"))}function l(t,n){for(var o,e=t.seen,i=e.length;i--;)if(o=e[i],n.obj===o.obj)return o;e.push(n)}r.ify=function(n,o,i){var r={path:[],obj:n};return o?"string"==typeof o?o={soul:o}:o instanceof Function&&(o.map=o):o={},o.soul&&(r.rel=e.rel.ify(o.soul)),o.graph=o.graph||{},o.seen=o.seen||[],o.as=o.as||i,t(o,r),o.root=r.node,o.graph}}(),r.node=function(t){var n=i.soul(t);if(n)return p({},n,t)},function(){function t(t,n){var o,u;if(i._!==n)(o=e.rel.is(t))?(u=this.opt.seen[o])?this.obj[n]=u:this.obj[n]=this.opt.seen[o]=r.to(this.graph,o,this.opt):this.obj[n]=t;else{if(l(t,e.rel._))return;this.obj[n]=h(t)}}r.to=function(n,o,e){if(n){var i={};return e=e||{seen:{}},g(n[o],t,{obj:i,graph:n,opt:e}),i}}}();o.fn.is;var u,a=o.obj,s=a.is,f=a.del,c=a.has,l=a.empty,p=a.put,g=a.map,h=a.copy;n.exports=r})(t,"./graph"),t(function(n){t("./onto"),n.exports=function(t,n){if(this.on){if(!(t instanceof Function)){if(!t||!n)return;var o=t["#"]||t,e=(this.tag||empty)[o];if(!e)return;return e=this.on(o,n),clearTimeout(e.err),!0}o=n&&n["#"]||Math.random().toString(36).slice(2);if(!t)return o;var i=this.on(o,t,n);return i.err=i.err||setTimeout(function(){i.next({err:"Error: No ACK received yet."}),i.off()},9e3),o}}})(t,"./ask"),t(function(n){var o=t("./type"),e=o.time.is;n.exports=function(t){var n={s:{}};return t=t||{max:1e3,age:9e3},n.check=function(t){return!!n.s[t]&&n.track(t)},n.track=function(i){return n.s[i]=e(),n.to||(n.to=setTimeout(function(){o.obj.map(n.s,function(i,r){t.age>e()-i||o.obj.del(n.s,r)}),n.to=null},t.age)),i},n}})(t,"./dup"),t(function(n){function i(t){return t instanceof i?(this._={gun:this}).gun:this instanceof i?i.create(this._={gun:this,opt:t}):new i(t)}i.is=function(t){return t instanceof i},i.version=.8,i.chain=i.prototype,i.chain.toJSON=function(){};var r=t("./type");r.obj.to(r,i),i.HAM=t("./HAM"),i.val=t("./val"),i.node=t("./node"),i.state=t("./state"),i.graph=t("./graph"),i.on=t("./onto"),i.ask=t("./ask"),i.dup=t("./dup"),i._={node:i.node._,soul:i.val.rel._,state:i.state._,field:".",value:"="},function(){function t(t){var n,o=this.as,e=o.gun;(n=t["#"])||(n=t["#"]=c(9)),o.dup.check(n)||(o.dup.track(n),t=h(t),o.ask(t["@"],t)||(t.get&&i.on.get(t,e),t.put&&i.on.put(t,e)),o.on("out",t))}i.create=function(n){n.root=n.root||n.gun,n.graph=n.graph||{},n.on=n.on||i.on,n.ask=n.ask||i.ask,n.dup=n.dup||i.dup();var o=n.gun.opt(n.opt);return n.once||(n.on("in",t,n),n.on("out",t,n)),n.once=1,o}}(),function(){function t(t,n,o,e){var r=this,u=i.state.is(o,n);if(!u)return r.err="Error: No state on '"+n+"' in node '"+e+"'!";var a=r.graph[e]||m,s=i.state.is(a,n,!0),f=a[n],c=i.HAM(r.machine,u,s,t,f);c.incoming?(r.put[e]=i.state.to(o,n,r.put[e]),(r.diff||(r.diff={}))[e]=i.state.to(o,n,r.diff[e])):c.defer&&(r.defer=u<(r.defer||1/0)?u:r.defer)}function n(t,n){var e=(this.gun._.next||m)[n];if(e){var i=this.map[n]={put:this.node=t,get:this.soul=n,gun:this.at=e};this.ack&&(i["@"]=this.ack),d(t,o,this)}}function o(t,n){var o=this.graph,e=this.soul,r=this.at._;o[e]=i.state.to(this.node,n,o[e]),r.put=i.state.to(this.node,n,r.put)}function e(t,n){var o;if(t.gun)return(o=this.gun._).tag.node?o.on("node",function(t){this.off(),t.gun._.on("in",t)}).on.on("node",t):void t.gun._.on("in",t)}i.on.put=function(o,r){var a=r._,s={gun:r,graph:a.graph,put:{},map:{},machine:i.state(),ack:o["@"]};if(i.graph.is(o.put,null,t,s)||(s.err="Error: Invalid graph!"),s.err)return a.on("in",{"@":o["#"],err:i.log(s.err)});d(s.put,n,s),d(s.map,e,s),u!==s.defer&&setTimeout(function(){i.on.put(o,r)},s.defer-a.machine),s.diff&&a.on("put",h(o,{put:s.diff}))},i.on.get=function(t,n){var o=n._,e=t.get[_],r=o.graph[e],u=t.get[b],a=((o.next||(o.next={}))[e]||m)._;if(!r||!a)return o.on("get",t);if(u){if(!g(r,u))return o.on("get",t);r=i.state.to(r,u)}else r=i.obj.copy(r);r=i.graph.node(r),o.on("in",{"@":t["#"],put:r,gun:n}),o.on("get",t)}}(),i.chain.opt=function(t){t=t||{};var n=this,o=n._,e=t.peers||t;return p(t)||(t={}),p(o.opt)||(o.opt=t),f(e)&&(e=[e]),a(e)&&(e=d(e,function(t,n,o){o(t,{url:t})}),p(o.opt.peers)||(o.opt.peers={}),o.opt.peers=h(e,o.opt.peers)),o.opt.uuid=o.opt.uuid||function(){return v().toString(36).replace(".","")+c(12)},o.opt.peers=o.opt.peers||{},h(t,o.opt),i.on("opt",o),n};var u,a=i.list.is,s=i.text,f=s.is,c=s.random,l=i.obj,p=l.is,g=l.has,h=l.to,d=l.map,v=(l.copy,i.state),_=i._.soul,b=i._.field,m=(i._.node,i.val.rel.is,{});o.debug=function(t,n){return o.debug.i&&t===o.debug.i&&o.debug.i++&&(o.log.apply(o,arguments)||n)},i.log=function(){return!i.log.off&&o.log.apply(o,arguments),[].slice.call(arguments).join(" ")},i.log.once=function(t,n,o){return(o=i.log.once)[t]=o[t]||0,o[t]++||i.log(n)},i.log.once("welcome","Hello wonderful person! :) Thanks for using GUN, feel free to ask for help on https://gitter.im/amark/gun and ask StackOverflow questions tagged with 'gun'!"),"undefined"!=typeof window&&(window.Gun=i),void 0!==e&&(e.exports=i),n.exports=i})(t,"./root"),t(function(n){t("./root").chain.back=function(t,n){if(-1===(t=t||1)||1/0===t)return this._.root;if(1===t)return this._.back||this;var i=this,r=i._;if("string"==typeof t&&(t=t.split(".")),!(t instanceof Array)){if(t instanceof Function){for(var u,a={back:i};(a=a.back)&&(a=a._)&&!(u=t(a,n)););return u}return this}var s=0,f=t.length,a=r;for(s;s=(n.batch||1e3))return s();o||(o=setTimeout(s,n.wait||1))}),t.on("get",function(o){this.to.next(o);var e,i,r=o.get;if(r&&(e=r[Gun._.soul])){var a=r["."];(i=u[e]||void 0)&&a&&(i=Gun.state.to(i,a)),(i||Gun.obj.empty(n.peers))&&t.on("in",{"@":o["#"],put:Gun.graph.node(i),how:"lS"})}});var a=function(t,n,o,e){u[e]=Gun.state.to(o,n,u[e])},s=function(){var a;r=0,clearTimeout(o),o=!1;var s=i;i={};try{e.setItem(n.file,JSON.stringify(u))}catch(t){Gun.log(a=t||"localStorage failure")}(a||Gun.obj.empty(n.peers))&&Gun.obj.map(s,function(n,o){t.on("in",{"@":o,err:a,ok:0})})}}})}})(t,"./adapters/localStorage"),t(function(n){var o,e=t("./index");"undefined"!=typeof WebSocket?o=WebSocket:("undefined"!=typeof webkitWebSocket&&(o=webkitWebSocket),"undefined"!=typeof mozWebSocket&&(o=mozWebSocket)),e.on("opt",function(t){function n(t){var n=this,o=c,e=t.wire||u(t,n);e&&(e.readyState!==e.OPEN?(t.queue=t.queue||[]).push(o):e.send(o))}function r(t,n,o){if(o&&t){try{t=JSON.parse(t.data||t)}catch(t){}if(t instanceof Array)for(var e,u=0;e=t[u++];)r(e,n,o);else 1==f.who&&(t.ws=i),o.on("in",t)}}function u(i,u){if(i&&i.url){var s=i.url.replace("http","ws"),f=i.wire=new o(s);return f.onclose=function(){t.on("bye",i),a(i,u)},f.onerror=function(t){a(i,u),t&&t.code},f.onopen=function(){t.on("hi",i);var o=i.queue;i.queue=[],e.obj.map(o,function(t){c=t,n.call(u,i)})},f.onmessage=function(t){r(t,i,u)},f}}function a(t,n){clearTimeout(t.defer),t.defer=setTimeout(function(){u(t,n)},2e3)}this.to.next(t);var s=t.opt;if(!t.once&&o&&!1!==s.WebSocket){var f=s.ws||(s.ws={});if(f.who=0,e.obj.map(s.peers,function(){++f.who}),!t.once){var c;t.on("out",function(o){this.to.next(o),o.ws&&1==f.who||(c=JSON.stringify(o),f.drain?f.drain.push(c):(f.drain=[],setTimeout(function(){if(f.drain){var o=f.drain;f.drain=null,o.length&&(c=JSON.stringify(o),e.obj.map(s.peers,n,t))}},s.wait||1),e.obj.map(s.peers,n,t)))})}}});var i=function(){}})(t,"./adapters/websocket")}(); \ No newline at end of file diff --git a/lib/file.js b/lib/file.js index 89db500c..f5f781c2 100644 --- a/lib/file.js +++ b/lib/file.js @@ -10,6 +10,7 @@ Gun.on('opt', function(ctx){ this.to.next(ctx); var opt = ctx.opt; if(ctx.once){ return } + if(process.env.AWS_S3_BUCKET){ return } opt.file = String(opt.file || 'data.json'); var graph = ctx.graph, acks = {}, count = 0, to; var disk = Gun.obj.ify((fs.existsSync || require('path').existsSync)(opt.file)? diff --git a/lib/radisk.js b/lib/radisk.js index 87fef577..01da2da7 100644 --- a/lib/radisk.js +++ b/lib/radisk.js @@ -177,7 +177,6 @@ function Radisk(opt){ // TODO: BUG!!! If a node spans multiple file chunks, it won't return all! // TODO: BUG!!! If a node spans multiple file chunks, it won't return all! // TODO: BUG!!! If a node spans multiple file chunks, it won't return all! - var id = Gun.text.random(3); if(RAD){ // cache var val = RAD(key); if(u !== val){ @@ -188,10 +187,10 @@ function Radisk(opt){ g.lex = function(file){ if(!file || file > key){ if(tmp = q[g.file]){ - tmp.push(cb); + tmp.push({key: key, ack: cb}); return true; } - q[g.file] = [cb]; + q[g.file] = [{key: key, ack: cb}]; r.parse(g.file, g.it); return true; } @@ -199,15 +198,13 @@ function Radisk(opt){ } g.it = function(err, disk){ if(g.err = err){ Gun.log(err) } - if(disk){ - RAD = disk; - g.val = disk(key); - } + if(disk){ RAD = disk } disk = q[g.file]; Gun.obj.del(q, g.file); Gun.obj.map(disk, g.ack); } - g.ack = function(ack){ - ack(g.err, g.val); + g.ack = function(as){ + if(!as.ack){ return } + as.ack(g.err, RAD(as.key)); } opt.store.list(g.lex); } diff --git a/lib/radisk_.js b/lib/radisk_.js deleted file mode 100644 index 6f457ee6..00000000 --- a/lib/radisk_.js +++ /dev/null @@ -1,242 +0,0 @@ -var fs = require('fs'); -var Gun = require('../gun'); -var Radix = require('./radix'); - -function Radisk(opt){ - /* - Any and all storage adapters should... - 1. If not busy, write to disk immediately. - 2. If busy, batch to disk. (Improves performance, reduces potential disk corruption) - 3. If a batch exceeds a certain number of writes, force atomic batch to disk. (This caps total performance, but reduces potential loss) - */ - var radisk = function(key, val, cb){ - key = ''+key; - if(0 <= key.indexOf('_') || 0 <= key.indexOf('$')){ // TODO: BUG! Fix! - var err = "ERROR: Radix and Radisk not tested against _ or $ keys!"; - console.log(err); - cb = cb || val; - if(cb instanceof Function){ cb(err) } - return; - } - if(val instanceof Function){ - cb = val; - val = radisk.batch(key); - if(u !== val){ - return cb(null, val); - } - if(radisk.was){ - val = radisk.was(key); - if(u !== val){ - return cb(null, val); - } - } - console.log("READ FROM DISK"); - return cb(null, val); - } - radisk.batch(key, val); - if(cb){ radisk.batch.acks.push(cb) } - if(!count++){ return thrash() } // (1) - if(opt.batch <= count){ return thrash() } // (3) - clearTimeout(to); // (2) - to = setTimeout(thrash, opt.wait); - }; - radisk.batch = Radix(); - radisk.batch.acks = []; - var count = 0, wait, to, u; - - opt = opt || {}; - opt.file = String(opt.file || 'radata'); - opt.size = opt.size || (1024 * 1024 * 10); // 10MB - opt.batch = opt.batch || 10 * 1000; - opt.wait = opt.wait || 1; - opt.nest = opt.nest || ' '; - - console.log("Warning: Radix storage engine has not been tested with all types of values and keys yet."); - if(!fs.existsSync(opt.file)){ fs.mkdirSync(opt.file) } - - var thrash = function(){ - if(wait){ return } - clearTimeout(to); - wait = true; - var was = radisk.was = radisk.batch; - radisk.batch = null; - radisk.batch = Radix(); - radisk.batch.acks = []; - chunk(radisk.was, function(err, ok){ - radisk.was = null; - wait = false; - var tmp = count; - count = 0; - Gun.obj.map(was.acks, function(cb){cb(err, ok)}); - if(1 < tmp){ thrash() } - }); - } - - /* - 1. Find the first radix item in memory. - 2. Use that as the starting index in the directory of files. - 3. Find the first file that is lexically larger than it, - 4. Read the previous file to that into memory - 5. Scan through the in memory radix for all values lexically less than the limit. - 6. Merge and write all of those to the in-memory file and back to disk. - 7. If file to large, split. More details needed here. - */ - function chunk(radix, cb){ - var step = { - check: function(tree, key){ - if(key < step.start){ return } - step.start = key; - fs.readdir(opt.file, step.match); - return true; - }, - match: function(err, dir){ - step.dir = dir; - if(!dir.length){ - step.file = '0'; - return step.merge(null, Radix()); - } - Gun.obj.map(dir, step.lex); - read(step.file, step.merge); - }, - lex: function(file){ - if(file > step.start){ - return step.end = file; - } - step.file = file; - }, - merge: function(err, disk){ - if(err){ return console.log("ERROR!!!", err) } - step.disk = disk; - Radix.map(radix, step.add); - write(step.file, step.disk, step.done); - }, - add: function(val, key){ - if(key < step.start){ return } - if(step.end && step.end < key){ return step.next = key; } - step.disk(key, val); - }, - done: function(err){ - if(err){ console.log("ERROR!!!", err) } - if(!step.next){ - return cb(err); - } - step.start = step.next; - step.end = step.next = step.file = u; - Radix.map(radix, step.check); - } - } - Radix.map(radix, step.check); - } - - /* - Any storage engine at some point will have to do a read in order to write. - This is true of even systems that use an append only log, if they support updates. - Therefore it is unavoidable that a read will have to happen, - the question is just how long you delay it. - */ - var write = function(file, radix, cb){ - var step = { - rest: "", - count: 0, - file: file, - each: function(val, key, k, pre){ - step.count++; - if(opt.size < step.rest.length){ - step.rest = ""; - step.limit = Math.ceil(step.count/2); - step.count = 0; - step.sub = Radix(); - Radix.map(radix, step.slice); - return true; - } - var i = pre.length; - while(i--){ step.rest += opt.nest }; - step.rest += encode(k) + (u === val? '' : '=' + encode(val)) + '\n'; - }, - dump: function(){ - var rest = step.rest; - step.rest = ""; - fs.writeFile(opt.file +'/'+ file, rest, cb); - console.log("DUMP"); - if(opt.disk){ opt.disk(opt.file+'/'+file, rest, cb) } - }, - slice: function(val, key){ - if(key < step.file){ return } - if(step.limit < (++step.count)){ - var name = step.file; - step.file = key; - step.count = 0; - write(name, step.sub, step.next); - return true; - } - step.sub(key, val); - }, - next: function(err){ - if(err){ console.log("ERR!!!!") } - step.sub = Radix(); - if(!Radix.map(radix, step.slice)){ - write(step.file, step.sub, cb); - } - } - }; - if(!Radix.map(radix, step.each, true)){ step.dump() } - } - - var split = String.fromCharCode(31), esc = JSON.stringify, fix = JSON.parse; - function encode(data){ - return split + esc(data) + split; - } - function decode(data){ - if(!data){ return '' } - var i = -1, c, f, t = ''; - while(c = data[++i]){ - if(f){ - if(split === c){ - try{ t = fix(t); - }catch(e){ t = '' } - return t; - } - t += c; - } else - if(split === c){ - f = true; - } - } - return ''; - } - - /* - Let us start by assuming we are the only process that is - changing the directory or bucket. Not because we do not want - to be multi-process/machine, but because we want to experiment - with how much performance and scale we can get out of only one. - Then we can work on the harder problem of being multi-process. - */ - var read = function(file, cb){ - var step = { - nest: 0, - rad: Radix(), - data: function(err, data){ - if(err){ return console.log("ERROR READING FILE!", err) } - step.pre = []; - Gun.obj.map(data.toString().split('\n'), step.split); // TODO: Escape! - cb(null, step.rad); - }, - split: function(line){ var LINE = line; - var nest = -1; while(opt.nest === line[++nest]){}; - if(nest){ line = line.slice(nest) } - if(nest <= step.nest){ step.pre = step.pre.slice(0, nest - step.nest - 1) } - line = line.split('='); step.pre.push(line[0]); - if(1 < line.length){ step.rad(step.pre.join(''), line[1]) } - step.nest = nest; - } - } - fs.readFile(opt.file +'/'+ file, step.data); - } - - radisk.read = read; - - return radisk; -} - -module.exports = Radisk; \ No newline at end of file diff --git a/lib/radix.js b/lib/radix.js index bc5a9b89..1fef14cb 100644 --- a/lib/radix.js +++ b/lib/radix.js @@ -12,14 +12,16 @@ var Gun = require('../gun'); k += key[++i]; } if(!at){ - if(u === val && i == l){ return } if(!map(t, function(r, s){ var ii = 0, kk = ''; while(s[ii] == key[ii]){ kk += s[ii++]; } if(kk){ - if(u === val){ return (tmp || (tmp = {}))[s.slice(ii)] = r; } + if(u === val){ + if(ii <= l){ return } + return (tmp || (tmp = {}))[s.slice(ii)] = r; + } var __ = {}; __[s.slice(ii)] = r; (__[key.slice(ii)] = {})[$] = val; @@ -30,7 +32,7 @@ var Gun = require('../gun'); })){ if(u === val){ return; } (t[k] || (t[k] = {}))[$] = val; - } else + } if(u === val){ return tmp; } @@ -65,4 +67,4 @@ var Gun = require('../gun'); Object.keys = Object.keys || function(o){ return map(o, function(v,k,t){t(k)}) } module.exports = Radix; -}()); \ No newline at end of file +}()); diff --git a/lib/rs3.js b/lib/rs3.js index 1e2ff958..e11638ff 100644 --- a/lib/rs3.js +++ b/lib/rs3.js @@ -10,8 +10,8 @@ Gun.on('opt', function(ctx){ var opt = ctx.opt; if(ctx.once){ return } if(!process.env.AWS_S3_BUCKET){ return } - opt.batch = opt.batch || 10 * 1000; - opt.wait = opt.wait || 1000 * 15; + opt.batch = opt.batch || (1000 * 10); + opt.wait = opt.wait || (1000 * 15); opt.size = opt.size || (1024 * 1024 * 10); // 10MB var opts = opt.s3 || (opt.s3 = {}); @@ -43,12 +43,11 @@ function Store(opt){ s3.putObject(params, cb); }; store.get = function(file, cb){ - var params = {Bucket: opts.bucket, Key: file}; + var params = {Bucket: opts.bucket, Key: file||''}; s3.getObject(params, function(err, ack){ - if(!ack){ return cb(err) } - var data = ack.Body; + if(!ack){ return cb(null) } + var data = (ack||{}).Body; if(data){ data = data.toString() } - console.log("HERE WE GO!", data); cb(err, data); }); }; @@ -61,7 +60,6 @@ function Store(opt){ })){ return } if(!data.IsTruncated){ return cb() } // Stream interface requires a final call to know when to be done. params.ContinuationToken = data.NextContinuationToken; - console.log("get further list..."); store.list(cb, match, params); }); }; diff --git a/lib/server.js b/lib/server.js index 45762f4d..e8caddfb 100644 --- a/lib/server.js +++ b/lib/server.js @@ -2,7 +2,8 @@ var Gun = require('../gun'); Gun.serve = require('./serve'); require('../nts'); - require('./s3'); + require('./store'); + require('./rs3'); try{require('./ws');}catch(e){require('./wsp/server');} require('./verify'); require('./file'); diff --git a/lib/store.js b/lib/store.js index bb8d423e..1626a904 100644 --- a/lib/store.js +++ b/lib/store.js @@ -1,4 +1,4 @@ -var Gun = require('gun/gun'); +var Gun = require('../gun'); var Radisk = require('./radisk'); var fs = require('fs'); var Radix = Radisk.Radix; @@ -8,6 +8,7 @@ Gun.on('opt', function(ctx){ this.to.next(ctx); var opt = ctx.opt; if(ctx.once){ return } + if(!process.env.AWS_S3_BUCKET){ return } // TODO: Remove this after migration. opt.store = opt.store || Store(opt); var rad = Radisk(opt); @@ -88,13 +89,17 @@ function Store(opt){ module.exports = Store; -;(function(){//return; - global.Gun = require('../gun'); - - /*process.env.AWS_S3_BUCKET = 'test-s3'; +;(function(){return; + process.env.AWS_S3_BUCKET = 'test-s3'; process.env.AWS_ACCESS_KEY_ID = 'asdf'; process.env.AWS_SECRET_ACCESS_KEY = 'fdsa'; process.env.fakes3 = 'http://localhost:4567'; - process.env.AWS_S3_THROTTLE = 0;*/ + process.env.AWS_S3_THROTTLE = 0; + + return; + global.Gun = require('../gun'); + require('./rs3'); + + require('../test/abc'); }()); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index a6346176..1bda82fb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "gun", - "version": "0.8.8", + "version": "0.9.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -16,15 +16,15 @@ "integrity": "sha1-Q96AKTD4JvxZj/73VtqBR42GEaM=", "dev": true, "requires": { - "asn1.js": "4.9.1", + "asn1.js": "4.9.2", "base64url": "2.0.0", "elliptic": "6.4.0" } }, "@trust/webcrypto": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/@trust/webcrypto/-/webcrypto-0.5.0.tgz", - "integrity": "sha1-XURt2vp1WIJDVuhSQqMdlGj9ayE=", + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/@trust/webcrypto/-/webcrypto-0.7.1.tgz", + "integrity": "sha512-aix+LOG/3Ku3MzClfVxVH88QbSdIL1HcBQ+gjXL/VnX05uyORf28CaQZOvsoEcCzGnWIVBUNwE2gxLBapWANWw==", "dev": true, "requires": { "@trust/keyto": "0.3.1", @@ -74,9 +74,9 @@ "dev": true }, "asn1.js": { - "version": "4.9.1", - "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.9.1.tgz", - "integrity": "sha1-SLokC0WpKA6UdImQull9IWYX/UA=", + "version": "4.9.2", + "resolved": "https://registry.npmjs.org/asn1.js/-/asn1.js-4.9.2.tgz", + "integrity": "sha512-b/OsSjvWEo8Pi8H0zsDd2P6Uqo2TK2pH8gNLSJtNLM2Db0v2QaAZ0pBQJXVjAn4gBuugeVDr7s63ZogpUIwWDg==", "dev": true, "requires": { "bn.js": "4.11.8", @@ -85,9 +85,9 @@ } }, "aws-sdk": { - "version": "2.133.0", - "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.133.0.tgz", - "integrity": "sha1-am2JiL01kowRu9PbZ3rVs+rnEHo=", + "version": "2.153.0", + "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.153.0.tgz", + "integrity": "sha1-a6IuhJruFq1wdxihjGS3Vtjx6Bo=", "requires": { "buffer": "4.9.1", "crypto-browserify": "1.0.9", diff --git a/package.json b/package.json index 947ce4e4..9ad6bdc2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gun", - "version": "0.8.9", + "version": "0.9.0", "description": "Graph engine", "main": "index.js", "browser": "gun.min.js", @@ -45,10 +45,10 @@ }, "homepage": "https://github.com/amark/gun#readme", "engines": { - "node": ">=0.6.6" + "node": ">=0.8.4" }, "dependencies": { - "aws-sdk": ">=2.86.0", + "aws-sdk": ">=2.153.0", "ws": "~>2.2.3" }, "devDependencies": { diff --git a/src/root.js b/src/root.js index e031a6d8..8439bc5b 100644 --- a/src/root.js +++ b/src/root.js @@ -191,6 +191,4 @@ Gun.log.once("welcome", "Hello wonderful person! :) Thanks for using GUN, feel f if(typeof window !== "undefined"){ window.Gun = Gun } if(typeof common !== "undefined"){ common.exports = Gun } module.exports = Gun; - -Gun.log.once("0.8", "0.8 WARNING! Breaking changes, test that your app works before upgrading! The adapter interface has been upgraded (non-default storage and transport layers probably won't work). Also, `.path()` and `.not()` are outside core and now in 'lib/'."); \ No newline at end of file diff --git a/test/common.js b/test/common.js index dc05bf5d..73bde148 100644 --- a/test/common.js +++ b/test/common.js @@ -3176,7 +3176,6 @@ describe('Gun', function(){ setTimeout(function(){ var gun2 = Gun(); //console.log(require('fs').readFileSync('./radata/!').toString()); - //console.debug.i=1;console.log("-----------------"); gun2.get('stef').get('address').val(function(data){ // Object {_: Object, country: "Netherlands", zip: "1766KP"} "adress" //console.log("******", data); done.a = true; @@ -3346,7 +3345,6 @@ describe('Gun', function(){ it('multiple times', function(done){ var gun = Gun(); - var app = gun.get('mult/times'); app.get('alias').get('mark').set(gun.get('ASDF').put({ @@ -3389,7 +3387,8 @@ describe('Gun', function(){ }, s)}); var app = gun.get(s.soul); - + + //console.debug.i=1;console.log("==================="); app.get('alias').get('mark').map().val(function(alias){ //console.log("***", alias); done.alias = alias; diff --git a/test/ptsd/radisk.js b/test/ptsd/radisk.js index 6860e402..81339310 100644 --- a/test/ptsd/radisk.js +++ b/test/ptsd/radisk.js @@ -1,7 +1,7 @@ var Radix = require('../../lib/radix'); var Radisk = require('../../lib/radisk'); var Store = require('../../lib/store'); -//var Store = require('../../lib/rs3'); +var Store = require('../../lib/rs3'); var Gun = require('../../gun'); var fs = require('fs'); @@ -21,8 +21,8 @@ var diff; var last = start; var t = Gun.time.is; var at = c; - ;(function(){ + ;(function(){return; start = Gun.time.is(); gun.get('j59an5jj2LUW8IJXl0u3').get('foo').on(function(data){ /*Radix.map(data, function(val, key){ @@ -39,8 +39,6 @@ var diff; }); }()); - return; - var toc, alldone = function(){ acked++; if(acked < TOTAL){ return } diff --git a/test/radix.js b/test/radix.js new file mode 100644 index 00000000..27a17199 --- /dev/null +++ b/test/radix.js @@ -0,0 +1,16 @@ +var expect = global.expect = require("./expect"); + +var Radix = require('../lib/radix'); +var _ = String.fromCharCode(29); + +describe('Radix', function(){ + it('read', function(){ + var rad = Radix(); + rad('asdf.pub', 'yum'); + rad('ablah', 'cool'); + rad('node/circle.bob', 'awesome'); + + expect(rad('asdf.')).to.be.eql({pub: {'\u001e': 'yum'}}); + expect(rad('nv/foo.bar')).to.be(undefined); + }); +}); \ No newline at end of file