Comparing version
/*! | ||
* fluir v0.2.12 | ||
* fluir v1.0.2 | ||
* Url: https://github.com/z5h/fluir | ||
@@ -7,3 +7,3 @@ * Copyright (c) Mark Bolusmjak | ||
*/ | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.fluir=t()}}(function(){var t;return function e(t,n,r){function i(s,u){if(!n[s]){if(!t[s]){var a="function"==typeof require&&require;if(!u&&a)return a(s,!0);if(o)return o(s,!0);var h=new Error("Cannot find module '"+s+"'");throw h.code="MODULE_NOT_FOUND",h}var c=n[s]={exports:{}};t[s][0].call(c.exports,function(e){var n=t[s][1][e];return i(n?n:e)},c,c.exports,e,t,n,r)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(t,e,n){(function(e){function r(t){this._stores=i.values(t),o.call(this),i.extend(this,o.prototype),s.call(this,t),this.get=s.prototype.get,u.call(this,this._stores),i.extend(this,u.prototype),a.call(this,this._stores),this.dispatch=i.bind(function(t,e){return a.prototype.dispatch.call(this,t,e)},this),this.emitChange=i.bind(function(){return r.prototype.emitChange.call(this)},this);var e=this;i.each(this._stores,function(t){t.on("change",function(){e.emitChange(t)}),t.go=i.bind(e.go,e),t.scope=i.bind(e.push,e)})}var i="undefined"!=typeof window?window._:"undefined"!=typeof e?e._:null,o=t("events").EventEmitter,s=t("./lib/scope").Scope,u=t("./lib/routeHandler").RouteHandler,a=t("./lib/dispatchHandler").DispatchHandler;r.prototype.push=function(t){var e=s.prototype.push.call(this,t);return e.dispatch=this.dispatch,e.emitChange=this.emitChange,e.push=r.prototype.push,e},r.prototype.emitChange=function(){this.emit("change")};var h={scope:function(t){return t?this.props.scope.push(t):this.props.scope},resolve:function(t){return this.props.scope.get(t)},dispatch:function(t,e){return this.props.scope.dispatch(t,e)},dispatcher:function(t){return i.bind(function(e){this.props.scope.dispatch(t,e.target.value)},this)}},c={debounceTime:10,componentWillMount:function(){this.callback=function(){this.forceUpdate()}.bind(this),this.props.scope.on("change",i.debounce(this.callback,this.debounceTime))}};i.extend(c,h),n.Application=r,n.ViewMixin=h,n.RootViewMixin=c,n.Scope=s,n.Promise=t("es6-promise").Promise}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./lib/dispatchHandler":2,"./lib/routeHandler":3,"./lib/scope":4,"es6-promise":8,events:5}],2:[function(t,e,n){(function(e){function r(t){this._listeners=t}var i="undefined"!=typeof window?window._:"undefined"!=typeof e?e._:null,o=t("es6-promise").Promise;r.prototype.dispatch=function(t,e){var n=[];return i.each(this._listeners,function(r){var i=r[t];"function"==typeof i&&n.push(i.call(r,e))}),o.all(n)},n.DispatchHandler=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"es6-promise":8}],3:[function(t,e,n){(function(e){function r(t){function e(e){this._router=new t;var n={},r=this;i.each(e,function(t){i.chain(t).functions().filter(function(t){return"/"===t.charAt(0)}).each(function(e){var i=function(){var n=Array.prototype.slice.call(arguments);t[e].apply(t,n),r.emitChange()};n[e]=i,r._router.on(e,i)}),i.chain(t).keys().filter(function(e){return"/"===e.charAt(0)&&"string"==typeof t[e]}).each(function(e){var i=t[e];r._router.on(e,n[i])})})}return e.prototype.initRoute=function(t){this._router.init(t)},e.prototype.go=function(t){this._router.setRoute(t)},e}var i="undefined"!=typeof window?window._:"undefined"!=typeof e?e._:null,o=t("director").Router;n.RouteHandler=r(o),n.defineRouteHandler=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{director:7}],4:[function(t,e,n){function r(t){t&&(this._values=t)}r.prototype.push=function(t){var e=new r(t||{});return e._parent=this,e},r.prototype.get=function(t){for(var e=this,n=e._values[t];void 0===n&&e;)e=e._parent,n=e?e._values[t]:n;if(e)return n;throw t+" not found"},n.Scope=r},{}],5:[function(t,e){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function r(t){return"function"==typeof t}function i(t){return"number"==typeof t}function o(t){return"object"==typeof t&&null!==t}function s(t){return void 0===t}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(t){if(!i(t)||0>t||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},n.prototype.emit=function(t){var e,n,i,u,a,h;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;throw TypeError('Uncaught, unspecified "error" event.')}if(n=this._events[t],s(n))return!1;if(r(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:for(i=arguments.length,u=new Array(i-1),a=1;i>a;a++)u[a-1]=arguments[a];n.apply(this,u)}else if(o(n)){for(i=arguments.length,u=new Array(i-1),a=1;i>a;a++)u[a-1]=arguments[a];for(h=n.slice(),i=h.length,a=0;i>a;a++)h[a].apply(this,u)}return!0},n.prototype.addListener=function(t,e){var i;if(!r(e))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,r(e.listener)?e.listener:e),this._events[t]?o(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,o(this._events[t])&&!this._events[t].warned){var i;i=s(this._maxListeners)?n.defaultMaxListeners:this._maxListeners,i&&i>0&&this._events[t].length>i&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())}return this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){function n(){this.removeListener(t,n),i||(i=!0,e.apply(this,arguments))}if(!r(e))throw TypeError("listener must be a function");var i=!1;return n.listener=e,this.on(t,n),this},n.prototype.removeListener=function(t,e){var n,i,s,u;if(!r(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(n=this._events[t],s=n.length,i=-1,n===e||r(n.listener)&&n.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(n)){for(u=s;u-->0;)if(n[u]===e||n[u].listener&&n[u].listener===e){i=u;break}if(0>i)return this;1===n.length?(n.length=0,delete this._events[t]):n.splice(i,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},n.prototype.removeAllListeners=function(t){var e,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[t],r(n))this.removeListener(t,n);else for(;n.length;)this.removeListener(t,n[n.length-1]);return delete this._events[t],this},n.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?r(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.listenerCount=function(t,e){var n;return n=t._events&&t._events[e]?r(t._events[e])?1:t._events[e].length:0}},{}],6:[function(t,e){function n(){}var r=e.exports={};r.nextTick=function(){var t="undefined"!=typeof window&&window.setImmediate,e="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(t)return function(t){return window.setImmediate(t)};if(e){var n=[];return window.addEventListener("message",function(t){var e=t.source;if((e===window||null===e)&&"process-tick"===t.data&&(t.stopPropagation(),n.length>0)){var r=n.shift();r()}},!0),function(t){n.push(t),window.postMessage("process-tick","*")}}return function(t){setTimeout(t,0)}}(),r.title="browser",r.browser=!0,r.env={},r.argv=[],r.on=n,r.addListener=n,r.once=n,r.off=n,r.removeListener=n,r.removeAllListeners=n,r.emit=n,r.binding=function(){throw new Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(){throw new Error("process.chdir is not supported")}},{}],7:[function(t,e,n){!function(t){function e(){return""===h.hash||"#"===h.hash}function n(t,e){for(var n=0;n<t.length;n+=1)if(e(t[n],n,t)===!1)return}function r(t){for(var e=[],n=0,r=t.length;r>n;n++)e=e.concat(t[n]);return e}function i(t,e,n){if(!t.length)return n();var r=0;!function i(){e(t[r],function(e){e||e===!1?(n(e),n=function(){}):(r+=1,r===t.length?n():i())})}()}function o(t,e,n){n=t;for(var r in e)if(e.hasOwnProperty(r)&&(n=e[r](t),n!==t))break;return n===t?"([._a-zA-Z0-9-]+)":n}function u(t,e){for(var n,r=0,i="";n=t.substr(r).match(/[^\w\d\- %@&]*\*[^\w\d\- %@&]*/);)r=n.index+n[0].length,n[0]=n[0].replace(/^\*/,"([_.()!\\ %@&a-zA-Z0-9-]+)"),i+=t.substr(0,n.index)+n[0];t=i+=t.substr(r);var s,u,a=t.match(/:([^\/]+)/gi);if(a){u=a.length;for(var h=0;u>h;h++)s=a[h],t="::"===s.slice(0,2)?s.slice(1):t.replace(s,o(s,e))}return t}function a(t,e,n,r){var i,o=0,s=0,u=0,n=(n||"(").toString(),r=(r||")").toString();for(i=0;i<t.length;i++){var a=t[i];if(a.indexOf(n,o)>a.indexOf(r,o)||~a.indexOf(n,o)&&!~a.indexOf(r,o)||!~a.indexOf(n,o)&&~a.indexOf(r,o)){if(s=a.indexOf(n,o),u=a.indexOf(r,o),~s&&!~u||!~s&&~u){var h=t.slice(0,(i||1)+1).join(e);t=[h].concat(t.slice((i||1)+1))}o=(u>s?u:s)+1,i=0}else o=0}return t}Array.prototype.filter||(Array.prototype.filter=function(t,e){for(var n,r=[],i=0,o=this.length;o>i;i++)i in this&&t.call(e,n=this[i],i,this)&&r.push(n);return r}),Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)});var h=document.location,c={mode:"modern",hash:h.hash,history:!1,check:function(){var t=h.hash;t!=this.hash&&(this.hash=t,this.onHashChanged())},fire:function(){"modern"===this.mode?this.history===!0?window.onpopstate():window.onhashchange():this.onHashChanged()},init:function(t,e){function n(t){for(var e=0,n=f.listeners.length;n>e;e++)f.listeners[e](t)}var r=this;if(this.history=e,f.listeners||(f.listeners=[]),"onhashchange"in window&&(void 0===document.documentMode||document.documentMode>7))this.history===!0?setTimeout(function(){window.onpopstate=n},500):window.onhashchange=n,this.mode="modern";else{var i=document.createElement("iframe");i.id="state-frame",i.style.display="none",document.body.appendChild(i),this.writeFrame(""),"onpropertychange"in document&&"attachEvent"in document&&document.attachEvent("onpropertychange",function(){"location"===event.propertyName&&r.check()}),window.setInterval(function(){r.check()},50),this.onHashChanged=n,this.mode="legacy"}return f.listeners.push(t),this.mode},destroy:function(t){if(f&&f.listeners)for(var e=f.listeners,n=e.length-1;n>=0;n--)e[n]===t&&e.splice(n,1)},setHash:function(t){return"legacy"===this.mode&&this.writeFrame(t),this.history===!0?(window.history.pushState({},document.title,t),this.fire()):h.hash="/"===t[0]?t:"/"+t,this},writeFrame:function(t){var e=document.getElementById("state-frame"),n=e.contentDocument||e.contentWindow.document;n.open(),n.write("<script>_hash = '"+t+"'; onload = parent.listener.syncHash;<script>"),n.close()},syncHash:function(){var t=this._hash;return t!=h.hash&&(h.hash=t),this},onHashChanged:function(){}},f=t.Router=function(t){return this instanceof f?(this.params={},this.routes={},this.methods=["on","once","after","before"],this.scope=[],this._methods={},this._insert=this.insert,this.insert=this.insertEx,this.historySupport=null!=(null!=window.history?window.history.pushState:null),this.configure(),void this.mount(t||{})):new f(t)};f.prototype.init=function(t){var n=this;if(this.handler=function(t){var e=t&&t.newURL||window.location.hash,r=n.history===!0?n.getPath():e.replace(/.*#/,"");n.dispatch("on","/"===r.charAt(0)?r:"/"+r)},c.init(this.handler,this.history),this.history===!1)e()&&t?h.hash=t:e()||n.dispatch("on","/"+h.hash.replace(/^(#\/|#|\/)/,""));else{var r=e()&&t?t:e()?null:h.hash.replace(/^#/,"");r&&window.history.replaceState({},document.title,r),(r||this.run_in_init===!0)&&this.handler()}return this},f.prototype.explode=function(){var t=this.history===!0?this.getPath():h.hash;return"/"===t.charAt(1)&&(t=t.slice(1)),t.slice(1,t.length).split("/")},f.prototype.setRoute=function(t,e,n){var r=this.explode();return"number"==typeof t&&"string"==typeof e?r[t]=e:"string"==typeof n?r.splice(t,e,s):r=[t],c.setHash(r.join("/")),r},f.prototype.insertEx=function(t,e,n,r){return"once"===t&&(t="on",n=function(t){var e=!1;return function(){return e?void 0:(e=!0,t.apply(this,arguments))}}(n)),this._insert(t,e,n,r)},f.prototype.getRoute=function(t){var e=t;if("number"==typeof t)e=this.explode()[t];else if("string"==typeof t){var n=this.explode();e=n.indexOf(t)}else e=this.explode();return e},f.prototype.destroy=function(){return c.destroy(this.handler),this},f.prototype.getPath=function(){var t=window.location.pathname;return"/"!==t.substr(0,1)&&(t="/"+t),t},f.prototype.configure=function(t){t=t||{};for(var e=0;e<this.methods.length;e++)this._methods[this.methods[e]]=!0;return this.recurse=t.recurse||this.recurse||!1,this.async=t.async||!1,this.delimiter=t.delimiter||"/",this.strict="undefined"==typeof t.strict?!0:t.strict,this.notfound=t.notfound,this.resource=t.resource,this.history=t.html5history&&this.historySupport||!1,this.run_in_init=this.history===!0&&t.run_handler_in_init!==!1,this.every={after:t.after||null,before:t.before||null,on:t.on||null},this},f.prototype.param=function(t,e){":"!==t[0]&&(t=":"+t);var n=new RegExp(t,"g");this.params[t]=function(t){return t.replace(n,e.source||e)}},f.prototype.on=f.prototype.route=function(t,e,n){var r=this;return n||"function"!=typeof e||(n=e,e=t,t="on"),Array.isArray(e)?e.forEach(function(e){r.on(t,e,n)}):(e.source&&(e=e.source.replace(/\\\//gi,"/")),Array.isArray(t)?t.forEach(function(t){r.on(t.toLowerCase(),e,n)}):(e=e.split(new RegExp(this.delimiter)),e=a(e,this.delimiter),void this.insert(t,this.scope.concat(e),n)))},f.prototype.dispatch=function(t,e,n){function r(){o.last=s.after,o.invoke(o.runlist(s),o,n)}var i,o=this,s=this.traverse(t,e,this.routes,""),u=this._invoked;return this._invoked=!0,s&&0!==s.length?("forward"===this.recurse&&(s=s.reverse()),i=this.every&&this.every.after?[this.every.after].concat(this.last):[this.last],i&&i.length>0&&u?(this.async?this.invoke(i,this,r):(this.invoke(i,this),r()),!0):(r(),!0)):(this.last=[],"function"==typeof this.notfound&&this.invoke([this.notfound],{method:t,path:e},n),!1)},f.prototype.invoke=function(t,e,r){var o,s=this;this.async?(o=function(n,r){return Array.isArray(n)?i(n,o,r):void("function"==typeof n&&n.apply(e,t.captures.concat(r)))},i(t,o,function(){r&&r.apply(e,arguments)})):(o=function(r){return Array.isArray(r)?n(r,o):"function"==typeof r?r.apply(e,t.captures||[]):void("string"==typeof r&&s.resource&&s.resource[r].apply(e,t.captures||[]))},n(t,o))},f.prototype.traverse=function(t,e,n,r,i){function o(t){function e(t){for(var n=[],r=0;r<t.length;r++)n[r]=Array.isArray(t[r])?e(t[r]):t[r];return n}function n(t){for(var e=t.length-1;e>=0;e--)Array.isArray(t[e])?(n(t[e]),0===t[e].length&&t.splice(e,1)):i(t[e])||t.splice(e,1)}if(!i)return t;var r=e(t);return r.matched=t.matched,r.captures=t.captures,r.after=t.after.filter(i),n(r),r}var s,u,a,h,c=[];if(e===this.delimiter&&n[t])return h=[[n.before,n[t]].filter(Boolean)],h.after=[n.after].filter(Boolean),h.matched=!0,h.captures=[],o(h);for(var f in n)if(n.hasOwnProperty(f)&&(!this._methods[f]||this._methods[f]&&"object"==typeof n[f]&&!Array.isArray(n[f]))){if(s=u=r+this.delimiter+f,this.strict||(u+="["+this.delimiter+"]?"),a=e.match(new RegExp("^"+u)),!a)continue;if(a[0]&&a[0]==e&&n[f][t])return h=[[n[f].before,n[f][t]].filter(Boolean)],h.after=[n[f].after].filter(Boolean),h.matched=!0,h.captures=a.slice(1),this.recurse&&n===this.routes&&(h.push([n.before,n.on].filter(Boolean)),h.after=h.after.concat([n.after].filter(Boolean))),o(h);if(h=this.traverse(t,e,n[f],s),h.matched)return h.length>0&&(c=c.concat(h)),this.recurse&&(c.push([n[f].before,n[f].on].filter(Boolean)),h.after=h.after.concat([n[f].after].filter(Boolean)),n===this.routes&&(c.push([n.before,n.on].filter(Boolean)),h.after=h.after.concat([n.after].filter(Boolean)))),c.matched=!0,c.captures=h.captures,c.after=h.after,o(c)}return!1},f.prototype.insert=function(t,e,n,r){var i,o,s,a,h;if(e=e.filter(function(t){return t&&t.length>0}),r=r||this.routes,h=e.shift(),/\:|\*/.test(h)&&!/\\d|\\w/.test(h)&&(h=u(h,this.params)),e.length>0)return r[h]=r[h]||{},this.insert(t,e,n,r[h]);if(h||e.length||r!==this.routes){if(o=typeof r[h],s=Array.isArray(r[h]),r[h]&&!s&&"object"==o)switch(i=typeof r[h][t]){case"function":return void(r[h][t]=[r[h][t],n]);case"object":return void r[h][t].push(n);case"undefined":return void(r[h][t]=n)}else if("undefined"==o)return a={},a[t]=n,void(r[h]=a);throw new Error("Invalid route context: "+o)}switch(i=typeof r[t]){case"function":return void(r[t]=[r[t],n]);case"object":return void r[t].push(n);case"undefined":return void(r[t]=n)}},f.prototype.extend=function(t){function e(t){r._methods[t]=!0,r[t]=function(){var e=1===arguments.length?[t,""]:[t];r.on.apply(r,e.concat(Array.prototype.slice.call(arguments)))}}var n,r=this,i=t.length;for(n=0;i>n;n++)e(t[n])},f.prototype.runlist=function(t){var e=this.every&&this.every.before?[this.every.before].concat(r(t)):r(t);return this.every&&this.every.on&&e.push(this.every.on),e.captures=t.captures,e.source=t.source,e},f.prototype.mount=function(t,e){function n(e,n){var i=e,o=e.split(r.delimiter),s=typeof t[e],u=""===o[0]||!r._methods[o[0]],h=u?"on":i;return u&&(i=i.slice((i.match(new RegExp("^"+r.delimiter))||[""])[0].length),o.shift()),u&&"object"===s&&!Array.isArray(t[e])?(n=n.concat(o),void r.mount(t[e],n)):(u&&(n=n.concat(i.split(r.delimiter)),n=a(n,r.delimiter)),void r.insert(h,n,t[e]))}if(t&&"object"==typeof t&&!Array.isArray(t)){var r=this;e=e||[],Array.isArray(e)||(e=e.split(r.delimiter));for(var i in t)t.hasOwnProperty(i)&&n(i,e.slice(0))}}}("object"==typeof n?n:window)},{}],8:[function(e,n){(function(e,r){/*! | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.fluir=t()}}(function(){var t;return function e(t,n,r){function i(s,a){if(!n[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var h=n[s]={exports:{}};t[s][0].call(h.exports,function(e){var n=t[s][1][e];return i(n?n:e)},h,h.exports,e,t,n,r)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(t,e,n){(function(e){function r(t){this._stores=i.values(t),s.call(this),i.extend(this,s.prototype),u.call(this,this._stores),i.extend(this,u.prototype),this.dispatchHandler=new c(this._stores),this.dispatch=i.bind(this.dispatchHandler.dispatch,this.dispatchHandler);var e=new a;this.state=e;var n=i.bind(this.go,this);i.each(t,function(t,r){t.go=n,t.setState=function(t){return e.setState(r,t)},t.replaceState=function(t){return e.replaceState(r,t)},t.forceUpdate=function(){e.forceUpdate(r)},t.state=function(t){return e.value[t||r]},t.addStateChangeListener=function(t){e.addListener("change",t)},t.removeStateChangeListener=function(t){e.removeListener("change",t)},e.replaceState(r,{})}),i.each(this._stores,function(t){t.initialize&&t.initialize()}),e.on("change",function(){this.emit("change",e.value)}.bind(this))}var i="undefined"!=typeof window?window._:"undefined"!=typeof e?e._:null,o="undefined"!=typeof window?window.React:"undefined"!=typeof e?e.React:null,s=t("events").EventEmitter,a=t("./lib/state").State,u=t("./lib/routeHandler").RouteHandler,c=t("./lib/dispatchHandler").DispatchHandler,h={resolve:function(t){return this.props[t]||this.props.scope&&this.props.scope[t]},resolveWith:function(t,e){return e[t]||e.scope&&e.scope[t]},scope:function(t){var e=o.addons.update(this.props.scope,{$merge:this.props});return t&&(e=o.addons.update(e,{$merge:t})),e}},f={debounceTime:10,resolve:function(t){var e=this.props.application.state.value;return this.props[t]||e[t]},resolveWith:function(t,e){var n=e.application.state.value;return e[t]||n[t]},scope:function(t){var e=this.props.application.state.value,n=o.addons.update(e,{$merge:this.props});return t&&(n=o.addons.update(n,{$merge:t})),n},componentWillMount:function(){var t=this.props.application;this.callback=function(){this.forceUpdate()}.bind(this),this.dispatch=t.dispatch,t.on("change",i.debounce(this.callback,this.debounceTime))}};n.Application=r,n.ViewMixin=h,n.RootViewMixin=f,n.Promise=t("es6-promise").Promise}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./lib/dispatchHandler":2,"./lib/routeHandler":3,"./lib/state":4,"es6-promise":8,events:5}],2:[function(t,e,n){(function(e){function r(t){this._listeners=t}var i="undefined"!=typeof window?window._:"undefined"!=typeof e?e._:null,o=t("es6-promise").Promise;r.prototype.dispatch=function(t,e){var n=[];return i.each(this._listeners,function(r){var i=r[t];"function"==typeof i&&n.push(i.call(r,e))}),o.all(n)},n.DispatchHandler=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"es6-promise":8}],3:[function(t,e,n){(function(e){function r(t){function e(e){this._router=new t;var n={},r=this;i.each(e,function(t){i.chain(t).functions().filter(function(t){return"/"===t.charAt(0)}).each(function(e){var i=function(){var n=Array.prototype.slice.call(arguments);t[e].apply(t,n)};n[e]=i,r._router.on(e,i)}),i.chain(t).keys().filter(function(e){return"/"===e.charAt(0)&&"string"==typeof t[e]}).each(function(e){var i=t[e];r._router.on(e,n[i])})})}return e.prototype.initRoute=function(t){this._router.init(t)},e.prototype.go=function(t){this._router.setRoute(t)},e}var i="undefined"!=typeof window?window._:"undefined"!=typeof e?e._:null,o=t("director").Router;n.RouteHandler=r(o),n.defineRouteHandler=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{director:7}],4:[function(t,e,n){(function(e){function r(){o.call(this),this.value={}}var i="undefined"!=typeof window?window.React:"undefined"!=typeof e?e.React:null,o=t("events").EventEmitter;r.prototype=Object.create(o.prototype),r.prototype.constructor=r,r.prototype.setState=function(t,e){var n={};return n[t]=this.value[t]?{$merge:e}:{$set:e},this.value=i.addons.update(this.value,n),this.emit("change",t,this.value[t]),this.value},r.prototype.replaceState=function(t,e){var n={};return n[t]={$set:e},this.value=i.addons.update(this.value,n),this.emit("change",t,this.value[t]),this.value},r.prototype.forceUpdate=function(t){var e={};e[t]={$set:this.value[t]},this.value=i.addons.update(this.value,e),this.emit("change",t,this.value[t])},n.State=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{events:5}],5:[function(t,e){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function r(t){return"function"==typeof t}function i(t){return"number"==typeof t}function o(t){return"object"==typeof t&&null!==t}function s(t){return void 0===t}e.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(t){if(!i(t)||0>t||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},n.prototype.emit=function(t){var e,n,i,a,u,c;if(this._events||(this._events={}),"error"===t&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;throw TypeError('Uncaught, unspecified "error" event.')}if(n=this._events[t],s(n))return!1;if(r(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:for(i=arguments.length,a=new Array(i-1),u=1;i>u;u++)a[u-1]=arguments[u];n.apply(this,a)}else if(o(n)){for(i=arguments.length,a=new Array(i-1),u=1;i>u;u++)a[u-1]=arguments[u];for(c=n.slice(),i=c.length,u=0;i>u;u++)c[u].apply(this,a)}return!0},n.prototype.addListener=function(t,e){var i;if(!r(e))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,r(e.listener)?e.listener:e),this._events[t]?o(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,o(this._events[t])&&!this._events[t].warned){var i;i=s(this._maxListeners)?n.defaultMaxListeners:this._maxListeners,i&&i>0&&this._events[t].length>i&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),"function"==typeof console.trace&&console.trace())}return this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(t,e){function n(){this.removeListener(t,n),i||(i=!0,e.apply(this,arguments))}if(!r(e))throw TypeError("listener must be a function");var i=!1;return n.listener=e,this.on(t,n),this},n.prototype.removeListener=function(t,e){var n,i,s,a;if(!r(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(n=this._events[t],s=n.length,i=-1,n===e||r(n.listener)&&n.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(o(n)){for(a=s;a-->0;)if(n[a]===e||n[a].listener&&n[a].listener===e){i=a;break}if(0>i)return this;1===n.length?(n.length=0,delete this._events[t]):n.splice(i,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},n.prototype.removeAllListeners=function(t){var e,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[t]&&delete this._events[t],this;if(0===arguments.length){for(e in this._events)"removeListener"!==e&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[t],r(n))this.removeListener(t,n);else for(;n.length;)this.removeListener(t,n[n.length-1]);return delete this._events[t],this},n.prototype.listeners=function(t){var e;return e=this._events&&this._events[t]?r(this._events[t])?[this._events[t]]:this._events[t].slice():[]},n.listenerCount=function(t,e){var n;return n=t._events&&t._events[e]?r(t._events[e])?1:t._events[e].length:0}},{}],6:[function(t,e){function n(){}var r=e.exports={};r.nextTick=function(){var t="undefined"!=typeof window&&window.setImmediate,e="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(t)return function(t){return window.setImmediate(t)};if(e){var n=[];return window.addEventListener("message",function(t){var e=t.source;if((e===window||null===e)&&"process-tick"===t.data&&(t.stopPropagation(),n.length>0)){var r=n.shift();r()}},!0),function(t){n.push(t),window.postMessage("process-tick","*")}}return function(t){setTimeout(t,0)}}(),r.title="browser",r.browser=!0,r.env={},r.argv=[],r.on=n,r.addListener=n,r.once=n,r.off=n,r.removeListener=n,r.removeAllListeners=n,r.emit=n,r.binding=function(){throw new Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(){throw new Error("process.chdir is not supported")}},{}],7:[function(t,e,n){!function(t){function e(){return""===c.hash||"#"===c.hash}function n(t,e){for(var n=0;n<t.length;n+=1)if(e(t[n],n,t)===!1)return}function r(t){for(var e=[],n=0,r=t.length;r>n;n++)e=e.concat(t[n]);return e}function i(t,e,n){if(!t.length)return n();var r=0;!function i(){e(t[r],function(e){e||e===!1?(n(e),n=function(){}):(r+=1,r===t.length?n():i())})}()}function o(t,e,n){n=t;for(var r in e)if(e.hasOwnProperty(r)&&(n=e[r](t),n!==t))break;return n===t?"([._a-zA-Z0-9-]+)":n}function a(t,e){for(var n,r=0,i="";n=t.substr(r).match(/[^\w\d\- %@&]*\*[^\w\d\- %@&]*/);)r=n.index+n[0].length,n[0]=n[0].replace(/^\*/,"([_.()!\\ %@&a-zA-Z0-9-]+)"),i+=t.substr(0,n.index)+n[0];t=i+=t.substr(r);var s,a,u=t.match(/:([^\/]+)/gi);if(u){a=u.length;for(var c=0;a>c;c++)s=u[c],t="::"===s.slice(0,2)?s.slice(1):t.replace(s,o(s,e))}return t}function u(t,e,n,r){var i,o=0,s=0,a=0,n=(n||"(").toString(),r=(r||")").toString();for(i=0;i<t.length;i++){var u=t[i];if(u.indexOf(n,o)>u.indexOf(r,o)||~u.indexOf(n,o)&&!~u.indexOf(r,o)||!~u.indexOf(n,o)&&~u.indexOf(r,o)){if(s=u.indexOf(n,o),a=u.indexOf(r,o),~s&&!~a||!~s&&~a){var c=t.slice(0,(i||1)+1).join(e);t=[c].concat(t.slice((i||1)+1))}o=(a>s?a:s)+1,i=0}else o=0}return t}Array.prototype.filter||(Array.prototype.filter=function(t,e){for(var n,r=[],i=0,o=this.length;o>i;i++)i in this&&t.call(e,n=this[i],i,this)&&r.push(n);return r}),Array.isArray||(Array.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)});var c=document.location,h={mode:"modern",hash:c.hash,history:!1,check:function(){var t=c.hash;t!=this.hash&&(this.hash=t,this.onHashChanged())},fire:function(){"modern"===this.mode?this.history===!0?window.onpopstate():window.onhashchange():this.onHashChanged()},init:function(t,e){function n(t){for(var e=0,n=f.listeners.length;n>e;e++)f.listeners[e](t)}var r=this;if(this.history=e,f.listeners||(f.listeners=[]),"onhashchange"in window&&(void 0===document.documentMode||document.documentMode>7))this.history===!0?setTimeout(function(){window.onpopstate=n},500):window.onhashchange=n,this.mode="modern";else{var i=document.createElement("iframe");i.id="state-frame",i.style.display="none",document.body.appendChild(i),this.writeFrame(""),"onpropertychange"in document&&"attachEvent"in document&&document.attachEvent("onpropertychange",function(){"location"===event.propertyName&&r.check()}),window.setInterval(function(){r.check()},50),this.onHashChanged=n,this.mode="legacy"}return f.listeners.push(t),this.mode},destroy:function(t){if(f&&f.listeners)for(var e=f.listeners,n=e.length-1;n>=0;n--)e[n]===t&&e.splice(n,1)},setHash:function(t){return"legacy"===this.mode&&this.writeFrame(t),this.history===!0?(window.history.pushState({},document.title,t),this.fire()):c.hash="/"===t[0]?t:"/"+t,this},writeFrame:function(t){var e=document.getElementById("state-frame"),n=e.contentDocument||e.contentWindow.document;n.open(),n.write("<script>_hash = '"+t+"'; onload = parent.listener.syncHash;<script>"),n.close()},syncHash:function(){var t=this._hash;return t!=c.hash&&(c.hash=t),this},onHashChanged:function(){}},f=t.Router=function(t){return this instanceof f?(this.params={},this.routes={},this.methods=["on","once","after","before"],this.scope=[],this._methods={},this._insert=this.insert,this.insert=this.insertEx,this.historySupport=null!=(null!=window.history?window.history.pushState:null),this.configure(),void this.mount(t||{})):new f(t)};f.prototype.init=function(t){var n=this;if(this.handler=function(t){var e=t&&t.newURL||window.location.hash,r=n.history===!0?n.getPath():e.replace(/.*#/,"");n.dispatch("on","/"===r.charAt(0)?r:"/"+r)},h.init(this.handler,this.history),this.history===!1)e()&&t?c.hash=t:e()||n.dispatch("on","/"+c.hash.replace(/^(#\/|#|\/)/,""));else{var r=e()&&t?t:e()?null:c.hash.replace(/^#/,"");r&&window.history.replaceState({},document.title,r),(r||this.run_in_init===!0)&&this.handler()}return this},f.prototype.explode=function(){var t=this.history===!0?this.getPath():c.hash;return"/"===t.charAt(1)&&(t=t.slice(1)),t.slice(1,t.length).split("/")},f.prototype.setRoute=function(t,e,n){var r=this.explode();return"number"==typeof t&&"string"==typeof e?r[t]=e:"string"==typeof n?r.splice(t,e,s):r=[t],h.setHash(r.join("/")),r},f.prototype.insertEx=function(t,e,n,r){return"once"===t&&(t="on",n=function(t){var e=!1;return function(){return e?void 0:(e=!0,t.apply(this,arguments))}}(n)),this._insert(t,e,n,r)},f.prototype.getRoute=function(t){var e=t;if("number"==typeof t)e=this.explode()[t];else if("string"==typeof t){var n=this.explode();e=n.indexOf(t)}else e=this.explode();return e},f.prototype.destroy=function(){return h.destroy(this.handler),this},f.prototype.getPath=function(){var t=window.location.pathname;return"/"!==t.substr(0,1)&&(t="/"+t),t},f.prototype.configure=function(t){t=t||{};for(var e=0;e<this.methods.length;e++)this._methods[this.methods[e]]=!0;return this.recurse=t.recurse||this.recurse||!1,this.async=t.async||!1,this.delimiter=t.delimiter||"/",this.strict="undefined"==typeof t.strict?!0:t.strict,this.notfound=t.notfound,this.resource=t.resource,this.history=t.html5history&&this.historySupport||!1,this.run_in_init=this.history===!0&&t.run_handler_in_init!==!1,this.every={after:t.after||null,before:t.before||null,on:t.on||null},this},f.prototype.param=function(t,e){":"!==t[0]&&(t=":"+t);var n=new RegExp(t,"g");this.params[t]=function(t){return t.replace(n,e.source||e)}},f.prototype.on=f.prototype.route=function(t,e,n){var r=this;return n||"function"!=typeof e||(n=e,e=t,t="on"),Array.isArray(e)?e.forEach(function(e){r.on(t,e,n)}):(e.source&&(e=e.source.replace(/\\\//gi,"/")),Array.isArray(t)?t.forEach(function(t){r.on(t.toLowerCase(),e,n)}):(e=e.split(new RegExp(this.delimiter)),e=u(e,this.delimiter),void this.insert(t,this.scope.concat(e),n)))},f.prototype.dispatch=function(t,e,n){function r(){o.last=s.after,o.invoke(o.runlist(s),o,n)}var i,o=this,s=this.traverse(t,e,this.routes,""),a=this._invoked;return this._invoked=!0,s&&0!==s.length?("forward"===this.recurse&&(s=s.reverse()),i=this.every&&this.every.after?[this.every.after].concat(this.last):[this.last],i&&i.length>0&&a?(this.async?this.invoke(i,this,r):(this.invoke(i,this),r()),!0):(r(),!0)):(this.last=[],"function"==typeof this.notfound&&this.invoke([this.notfound],{method:t,path:e},n),!1)},f.prototype.invoke=function(t,e,r){var o,s=this;this.async?(o=function(n,r){return Array.isArray(n)?i(n,o,r):void("function"==typeof n&&n.apply(e,t.captures.concat(r)))},i(t,o,function(){r&&r.apply(e,arguments)})):(o=function(r){return Array.isArray(r)?n(r,o):"function"==typeof r?r.apply(e,t.captures||[]):void("string"==typeof r&&s.resource&&s.resource[r].apply(e,t.captures||[]))},n(t,o))},f.prototype.traverse=function(t,e,n,r,i){function o(t){function e(t){for(var n=[],r=0;r<t.length;r++)n[r]=Array.isArray(t[r])?e(t[r]):t[r];return n}function n(t){for(var e=t.length-1;e>=0;e--)Array.isArray(t[e])?(n(t[e]),0===t[e].length&&t.splice(e,1)):i(t[e])||t.splice(e,1)}if(!i)return t;var r=e(t);return r.matched=t.matched,r.captures=t.captures,r.after=t.after.filter(i),n(r),r}var s,a,u,c,h=[];if(e===this.delimiter&&n[t])return c=[[n.before,n[t]].filter(Boolean)],c.after=[n.after].filter(Boolean),c.matched=!0,c.captures=[],o(c);for(var f in n)if(n.hasOwnProperty(f)&&(!this._methods[f]||this._methods[f]&&"object"==typeof n[f]&&!Array.isArray(n[f]))){if(s=a=r+this.delimiter+f,this.strict||(a+="["+this.delimiter+"]?"),u=e.match(new RegExp("^"+a)),!u)continue;if(u[0]&&u[0]==e&&n[f][t])return c=[[n[f].before,n[f][t]].filter(Boolean)],c.after=[n[f].after].filter(Boolean),c.matched=!0,c.captures=u.slice(1),this.recurse&&n===this.routes&&(c.push([n.before,n.on].filter(Boolean)),c.after=c.after.concat([n.after].filter(Boolean))),o(c);if(c=this.traverse(t,e,n[f],s),c.matched)return c.length>0&&(h=h.concat(c)),this.recurse&&(h.push([n[f].before,n[f].on].filter(Boolean)),c.after=c.after.concat([n[f].after].filter(Boolean)),n===this.routes&&(h.push([n.before,n.on].filter(Boolean)),c.after=c.after.concat([n.after].filter(Boolean)))),h.matched=!0,h.captures=c.captures,h.after=c.after,o(h)}return!1},f.prototype.insert=function(t,e,n,r){var i,o,s,u,c;if(e=e.filter(function(t){return t&&t.length>0}),r=r||this.routes,c=e.shift(),/\:|\*/.test(c)&&!/\\d|\\w/.test(c)&&(c=a(c,this.params)),e.length>0)return r[c]=r[c]||{},this.insert(t,e,n,r[c]);if(c||e.length||r!==this.routes){if(o=typeof r[c],s=Array.isArray(r[c]),r[c]&&!s&&"object"==o)switch(i=typeof r[c][t]){case"function":return void(r[c][t]=[r[c][t],n]);case"object":return void r[c][t].push(n);case"undefined":return void(r[c][t]=n)}else if("undefined"==o)return u={},u[t]=n,void(r[c]=u);throw new Error("Invalid route context: "+o)}switch(i=typeof r[t]){case"function":return void(r[t]=[r[t],n]);case"object":return void r[t].push(n);case"undefined":return void(r[t]=n)}},f.prototype.extend=function(t){function e(t){r._methods[t]=!0,r[t]=function(){var e=1===arguments.length?[t,""]:[t];r.on.apply(r,e.concat(Array.prototype.slice.call(arguments)))}}var n,r=this,i=t.length;for(n=0;i>n;n++)e(t[n])},f.prototype.runlist=function(t){var e=this.every&&this.every.before?[this.every.before].concat(r(t)):r(t);return this.every&&this.every.on&&e.push(this.every.on),e.captures=t.captures,e.source=t.source,e},f.prototype.mount=function(t,e){function n(e,n){var i=e,o=e.split(r.delimiter),s=typeof t[e],a=""===o[0]||!r._methods[o[0]],c=a?"on":i;return a&&(i=i.slice((i.match(new RegExp("^"+r.delimiter))||[""])[0].length),o.shift()),a&&"object"===s&&!Array.isArray(t[e])?(n=n.concat(o),void r.mount(t[e],n)):(a&&(n=n.concat(i.split(r.delimiter)),n=u(n,r.delimiter)),void r.insert(c,n,t[e]))}if(t&&"object"==typeof t&&!Array.isArray(t)){var r=this;e=e||[],Array.isArray(e)||(e=e.split(r.delimiter));for(var i in t)t.hasOwnProperty(i)&&n(i,e.slice(0))}}}("object"==typeof n?n:window)},{}],8:[function(e,n){(function(e,r){/*! | ||
* @overview es6-promise - a tiny implementation of Promises/A+. | ||
@@ -15,2 +15,2 @@ * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald) | ||
*/ | ||
(function(){"use strict";function i(t){return"function"==typeof t||"object"==typeof t&&null!==t}function o(t){return"function"==typeof t}function s(t){return"object"==typeof t&&null!==t}function u(){}function a(){return function(){e.nextTick(l)}}function h(){var t=0,e=new F(l),n=document.createTextNode("");return e.observe(n,{characterData:!0}),function(){n.data=t=++t%2}}function c(){var t=new MessageChannel;return t.port1.onmessage=l,function(){t.port2.postMessage(0)}}function f(){return function(){setTimeout(l,1)}}function l(){for(var t=0;I>t;t+=2){var e=W[t],n=W[t+1];e(n),W[t]=void 0,W[t+1]=void 0}I=0}function p(){}function d(){return new TypeError("You cannot resolve a promise with itself")}function v(){return new TypeError("A promises callback cannot return that same promise.")}function y(t){try{return t.then}catch(e){return Z.error=e,Z}}function m(t,e,n,r){try{t.call(e,n,r)}catch(i){return i}}function _(t,e,n){U(function(t){var r=!1,i=m(n,e,function(n){r||(r=!0,e!==n?b(t,n):x(t,n))},function(e){r||(r=!0,E(t,e))},"Settle: "+(t._label||" unknown promise"));!r&&i&&(r=!0,E(t,i))},t)}function w(t,e){e._state===z?x(t,e._result):t._state===V?E(t,e._result):L(e,void 0,function(e){b(t,e)},function(e){E(t,e)})}function g(t,e){if(e.constructor===t.constructor)w(t,e);else{var n=y(e);n===Z?E(t,Z.error):void 0===n?x(t,e):o(n)?_(t,e,n):x(t,e)}}function b(t,e){t===e?E(t,d()):i(e)?g(t,e):x(t,e)}function A(t){t._onerror&&t._onerror(t._result),k(t)}function x(t,e){t._state===Y&&(t._result=e,t._state=z,0===t._subscribers.length||U(k,t))}function E(t,e){t._state===Y&&(t._state=V,t._result=e,U(A,t))}function L(t,e,n,r){var i=t._subscribers,o=i.length;t._onerror=null,i[o]=e,i[o+z]=n,i[o+V]=r,0===o&&t._state&&U(k,t)}function k(t){var e=t._subscribers,n=t._state;if(0!==e.length){for(var r,i,o=t._result,s=0;s<e.length;s+=3)r=e[s],i=e[s+n],r?P(n,r,i,o):i(o);t._subscribers.length=0}}function j(){this.error=null}function O(t,e){try{return t(e)}catch(n){return K.error=n,K}}function P(t,e,n,r){var i,s,u,a,h=o(n);if(h){if(i=O(n,r),i===K?(a=!0,s=i.error,i=null):u=!0,e===i)return void E(e,v())}else i=r,u=!0;e._state!==Y||(h&&u?b(e,i):a?E(e,s):t===z?x(e,i):t===V&&E(e,i))}function T(t,e){try{e(function(e){b(t,e)},function(e){E(t,e)})}catch(n){E(t,n)}}function C(t,e,n,r){this._instanceConstructor=t,this.promise=new t(p,r),this._abortOnReject=n,this._validateInput(e)?(this._input=e,this.length=e.length,this._remaining=e.length,this._init(),0===this.length?x(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&x(this.promise,this._result))):E(this.promise,this._validationError())}function R(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function S(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function M(t,e){this._id=te++,this._label=e,this._state=void 0,this._result=void 0,this._subscribers=[],p!==t&&(o(t)||R(),this instanceof M||S(),T(this,t))}var H;H=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};var B,D=H,I=(Date.now||function(){return(new Date).getTime()},Object.create||function(t){if(arguments.length>1)throw new Error("Second argument not supported");if("object"!=typeof t)throw new TypeError("Argument must be an object");return u.prototype=t,new u},0),U=function(t,e){W[I]=t,W[I+1]=e,I+=2,2===I&&B()},N="undefined"!=typeof window?window:{},F=N.MutationObserver||N.WebKitMutationObserver,q="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,W=new Array(1e3);B="undefined"!=typeof e&&"[object process]"==={}.toString.call(e)?a():F?h():q?c():f();var Y=void 0,z=1,V=2,Z=new j,K=new j;C.prototype._validateInput=function(t){return D(t)},C.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")},C.prototype._init=function(){this._result=new Array(this.length)};var G=C;C.prototype._enumerate=function(){for(var t=this.length,e=this.promise,n=this._input,r=0;e._state===Y&&t>r;r++)this._eachEntry(n[r],r)},C.prototype._eachEntry=function(t,e){var n=this._instanceConstructor;s(t)?t.constructor===n&&t._state!==Y?(t._onerror=null,this._settledAt(t._state,e,t._result)):this._willSettleAt(n.resolve(t),e):(this._remaining--,this._result[e]=this._makeResult(z,e,t))},C.prototype._settledAt=function(t,e,n){var r=this.promise;r._state===Y&&(this._remaining--,this._abortOnReject&&t===V?E(r,n):this._result[e]=this._makeResult(t,e,n)),0===this._remaining&&x(r,this._result)},C.prototype._makeResult=function(t,e,n){return n},C.prototype._willSettleAt=function(t,e){var n=this;L(t,void 0,function(t){n._settledAt(z,e,t)},function(t){n._settledAt(V,e,t)})};var J=function(t,e){return new G(this,t,!0,e).promise},Q=function(t,e){function n(t){b(o,t)}function r(t){E(o,t)}var i=this,o=new i(p,e);if(!D(t))return E(o,new TypeError("You must pass an array to race.")),o;for(var s=t.length,u=0;o._state===Y&&s>u;u++)L(i.resolve(t[u]),void 0,n,r);return o},X=function(t,e){var n=this;if(t&&"object"==typeof t&&t.constructor===n)return t;var r=new n(p,e);return b(r,t),r},$=function(t,e){var n=this,r=new n(p,e);return E(r,t),r},te=0,ee=M;M.all=J,M.race=Q,M.resolve=X,M.reject=$,M.prototype={constructor:M,then:function(t,e,n){var r=this,i=r._state;if(i===z&&!t||i===V&&!e)return this;r._onerror=null;var o=new this.constructor(p,n),s=r._result;if(i){var u=arguments[i-1];U(function(){P(i,o,u,s)})}else L(r,o,t,e);return o},"catch":function(t,e){return this.then(null,t,e)}};var ne=function(){var t;t="undefined"!=typeof r?r:"undefined"!=typeof window&&window.document?window:self;var e="Promise"in t&&"resolve"in t.Promise&&"reject"in t.Promise&&"all"in t.Promise&&"race"in t.Promise&&function(){var e;return new t.Promise(function(t){e=t}),o(e)}();e||(t.Promise=ee)},re={Promise:ee,polyfill:ne};"function"==typeof t&&t.amd?t(function(){return re}):"undefined"!=typeof n&&n.exports?n.exports=re:"undefined"!=typeof this&&(this.ES6Promise=re)}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:6}]},{},[1])(1)}),fluir.version="0.2.12"; | ||
(function(){"use strict";function i(t){return"function"==typeof t||"object"==typeof t&&null!==t}function o(t){return"function"==typeof t}function s(t){return"object"==typeof t&&null!==t}function a(){}function u(){return function(){e.nextTick(l)}}function c(){var t=0,e=new N(l),n=document.createTextNode("");return e.observe(n,{characterData:!0}),function(){n.data=t=++t%2}}function h(){var t=new MessageChannel;return t.port1.onmessage=l,function(){t.port2.postMessage(0)}}function f(){return function(){setTimeout(l,1)}}function l(){for(var t=0;D>t;t+=2){var e=W[t],n=W[t+1];e(n),W[t]=void 0,W[t+1]=void 0}D=0}function p(){}function d(){return new TypeError("You cannot resolve a promise with itself")}function v(){return new TypeError("A promises callback cannot return that same promise.")}function y(t){try{return t.then}catch(e){return V.error=e,V}}function m(t,e,n,r){try{t.call(e,n,r)}catch(i){return i}}function w(t,e,n){$(function(t){var r=!1,i=m(n,e,function(n){r||(r=!0,e!==n?b(t,n):x(t,n))},function(e){r||(r=!0,E(t,e))},"Settle: "+(t._label||" unknown promise"));!r&&i&&(r=!0,E(t,i))},t)}function _(t,e){e._state===z?x(t,e._result):t._state===Y?E(t,e._result):L(e,void 0,function(e){b(t,e)},function(e){E(t,e)})}function g(t,e){if(e.constructor===t.constructor)_(t,e);else{var n=y(e);n===V?E(t,V.error):void 0===n?x(t,e):o(n)?w(t,e,n):x(t,e)}}function b(t,e){t===e?E(t,d()):i(e)?g(t,e):x(t,e)}function A(t){t._onerror&&t._onerror(t._result),j(t)}function x(t,e){t._state===q&&(t._result=e,t._state=z,0===t._subscribers.length||$(j,t))}function E(t,e){t._state===q&&(t._state=Y,t._result=e,$(A,t))}function L(t,e,n,r){var i=t._subscribers,o=i.length;t._onerror=null,i[o]=e,i[o+z]=n,i[o+Y]=r,0===o&&t._state&&$(j,t)}function j(t){var e=t._subscribers,n=t._state;if(0!==e.length){for(var r,i,o=t._result,s=0;s<e.length;s+=3)r=e[s],i=e[s+n],r?R(n,r,i,o):i(o);t._subscribers.length=0}}function k(){this.error=null}function S(t,e){try{return t(e)}catch(n){return Z.error=n,Z}}function R(t,e,n,r){var i,s,a,u,c=o(n);if(c){if(i=S(n,r),i===Z?(u=!0,s=i.error,i=null):a=!0,e===i)return void E(e,v())}else i=r,a=!0;e._state!==q||(c&&a?b(e,i):u?E(e,s):t===z?x(e,i):t===Y&&E(e,i))}function O(t,e){try{e(function(e){b(t,e)},function(e){E(t,e)})}catch(n){E(t,n)}}function P(t,e,n,r){this._instanceConstructor=t,this.promise=new t(p,r),this._abortOnReject=n,this._validateInput(e)?(this._input=e,this.length=e.length,this._remaining=e.length,this._init(),0===this.length?x(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&x(this.promise,this._result))):E(this.promise,this._validationError())}function T(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function H(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function M(t,e){this._id=te++,this._label=e,this._state=void 0,this._result=void 0,this._subscribers=[],p!==t&&(o(t)||T(),this instanceof M||H(),O(this,t))}var C;C=Array.isArray?Array.isArray:function(t){return"[object Array]"===Object.prototype.toString.call(t)};var B,U=C,D=(Date.now||function(){return(new Date).getTime()},Object.create||function(t){if(arguments.length>1)throw new Error("Second argument not supported");if("object"!=typeof t)throw new TypeError("Argument must be an object");return a.prototype=t,new a},0),$=function(t,e){W[D]=t,W[D+1]=e,D+=2,2===D&&B()},I="undefined"!=typeof window?window:{},N=I.MutationObserver||I.WebKitMutationObserver,F="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,W=new Array(1e3);B="undefined"!=typeof e&&"[object process]"==={}.toString.call(e)?u():N?c():F?h():f();var q=void 0,z=1,Y=2,V=new k,Z=new k;P.prototype._validateInput=function(t){return U(t)},P.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")},P.prototype._init=function(){this._result=new Array(this.length)};var K=P;P.prototype._enumerate=function(){for(var t=this.length,e=this.promise,n=this._input,r=0;e._state===q&&t>r;r++)this._eachEntry(n[r],r)},P.prototype._eachEntry=function(t,e){var n=this._instanceConstructor;s(t)?t.constructor===n&&t._state!==q?(t._onerror=null,this._settledAt(t._state,e,t._result)):this._willSettleAt(n.resolve(t),e):(this._remaining--,this._result[e]=this._makeResult(z,e,t))},P.prototype._settledAt=function(t,e,n){var r=this.promise;r._state===q&&(this._remaining--,this._abortOnReject&&t===Y?E(r,n):this._result[e]=this._makeResult(t,e,n)),0===this._remaining&&x(r,this._result)},P.prototype._makeResult=function(t,e,n){return n},P.prototype._willSettleAt=function(t,e){var n=this;L(t,void 0,function(t){n._settledAt(z,e,t)},function(t){n._settledAt(Y,e,t)})};var G=function(t,e){return new K(this,t,!0,e).promise},J=function(t,e){function n(t){b(o,t)}function r(t){E(o,t)}var i=this,o=new i(p,e);if(!U(t))return E(o,new TypeError("You must pass an array to race.")),o;for(var s=t.length,a=0;o._state===q&&s>a;a++)L(i.resolve(t[a]),void 0,n,r);return o},Q=function(t,e){var n=this;if(t&&"object"==typeof t&&t.constructor===n)return t;var r=new n(p,e);return b(r,t),r},X=function(t,e){var n=this,r=new n(p,e);return E(r,t),r},te=0,ee=M;M.all=G,M.race=J,M.resolve=Q,M.reject=X,M.prototype={constructor:M,then:function(t,e,n){var r=this,i=r._state;if(i===z&&!t||i===Y&&!e)return this;r._onerror=null;var o=new this.constructor(p,n),s=r._result;if(i){var a=arguments[i-1];$(function(){R(i,o,a,s)})}else L(r,o,t,e);return o},"catch":function(t,e){return this.then(null,t,e)}};var ne=function(){var t;t="undefined"!=typeof r?r:"undefined"!=typeof window&&window.document?window:self;var e="Promise"in t&&"resolve"in t.Promise&&"reject"in t.Promise&&"all"in t.Promise&&"race"in t.Promise&&function(){var e;return new t.Promise(function(t){e=t}),o(e)}();e||(t.Promise=ee)},re={Promise:ee,polyfill:ne};"function"==typeof t&&t.amd?t(function(){return re}):"undefined"!=typeof n&&n.exports?n.exports=re:"undefined"!=typeof this&&(this.ES6Promise=re)}).call(this)}).call(this,e("_process"),"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{_process:6}]},{},[1])(1)}),fluir.version="1.0.2"; |
@@ -56,4 +56,9 @@ /** @jsx React.DOM */ | ||
clock : clock, | ||
on : function(event, f){ | ||
this.clock.on(event, f); | ||
initialize : function(){ | ||
this.setState({time : this.clock.time()}); | ||
this.clock.on('change', function(){ | ||
this.setState({time : this.clock.time()}) | ||
}.bind(this)); | ||
} | ||
@@ -80,4 +85,6 @@ }; | ||
phoneBook : phoneBook, | ||
on : function(event, f){ | ||
this.phoneBook.on(event, f); | ||
initialize : function(){ | ||
this.phoneBook.on('change',function(){ | ||
this.forceUpdate(); | ||
}.bind(this)) | ||
}, | ||
@@ -101,25 +108,33 @@ | ||
'/phonebook' : function(){ | ||
this.viewData = { | ||
this.setState({ | ||
viewClass : PhoneBookView, | ||
scope : this.scope({phoneBook : this.phoneBook}) | ||
}; | ||
viewData : { | ||
phoneBook : this.phoneBook | ||
}, | ||
key : 'phonebook', | ||
phoneBook : this.phoneBook | ||
}); | ||
}, | ||
'/contact/:id' : function(id){ | ||
var contact = this.phoneBook.getContact(id); | ||
this.viewData = { | ||
this.setState({ | ||
viewClass : ContactView, | ||
scope : this.scope({ | ||
viewData : { | ||
contact : contact | ||
}) | ||
}; | ||
}, | ||
key : 'contact/' + id, | ||
phoneBook : this.phoneBook | ||
}); | ||
}, | ||
'/contact/:id/:phoneIndex' : function(id, phoneKey){ | ||
var contact = this.phoneBook.getContact(id); | ||
this.viewData = { | ||
this.setState({ | ||
viewClass : PhoneView, | ||
scope : this.scope({ | ||
viewData : { | ||
contact : contact, | ||
phoneKey : phoneKey | ||
}) | ||
}; | ||
}, | ||
key : 'contact/' + id + '/' + phoneKey, | ||
phoneBook : this.phoneBook | ||
}); | ||
} | ||
@@ -146,9 +161,8 @@ }; | ||
var time = this.resolve('clockStore').clock.time(); | ||
var time = this.resolve('clockStore').time; | ||
var viewClass = this.resolve('phoneBookStore').viewClass; | ||
var viewData = this.resolve('phoneBookStore').viewData; | ||
var key = this.resolve('phoneBookStore').key; | ||
if (viewData) { | ||
//our main content is driven by URL, so URL is a fine key to use for | ||
//React's key functionality that tells it when something has changed. | ||
var key = document.location.toString(); | ||
if (viewData && viewClass) { | ||
return <div> | ||
@@ -159,3 +173,3 @@ <div className="time">Time : {time}</div> | ||
<ReactCSSTransitionGroup transitionName="slide"> | ||
<viewData.viewClass key={key} scope={viewData.scope}/> | ||
<viewClass key={key} scope={viewData} dispatch={this.dispatch}/> | ||
</ReactCSSTransitionGroup> | ||
@@ -174,2 +188,3 @@ </div>; | ||
var phoneBook = this.resolve('phoneBook'); | ||
var dispatch = this.resolve('dispatch'); | ||
var contactViews = _.map(phoneBook.contacts, function(contact){ | ||
@@ -208,3 +223,4 @@ /** | ||
this.dispatch('ADD_CONTACT', { | ||
var dispatch = this.resolve('dispatch'); | ||
dispatch('ADD_CONTACT', { | ||
name : this.refs.name.getDOMNode().value, | ||
@@ -236,3 +252,4 @@ phoneNumbers : phoneNumbers | ||
deleteSelf : function(){ | ||
this.dispatch('DELETE_CONTACT', this.resolve('contact').id); | ||
this.resolve('dispatch')('DELETE_CONTACT', this.resolve('contact').id); | ||
return false; | ||
@@ -283,3 +300,3 @@ }, | ||
React.renderComponent( | ||
<RootAppView scope={application} />, | ||
<RootAppView application={application} />, | ||
document.getElementById('app') | ||
@@ -286,0 +303,0 @@ ); |
@@ -11,3 +11,3 @@ var gulp = require('gulp'); | ||
var source = require('vinyl-source-stream'); | ||
var buffer = require('vinyl-buffer') | ||
var buffer = require('vinyl-buffer'); | ||
@@ -14,0 +14,0 @@ var del = require('del'); |
114
index.js
var | ||
_ = require('underscore'), | ||
React = require('react/addons'), | ||
EventEmitter = require('events').EventEmitter, | ||
Scope = require('./lib/scope').Scope, | ||
State = require('./lib/state').State, | ||
RouteHandler = require('./lib/routeHandler').RouteHandler, | ||
DispatchHandler = require('./lib/dispatchHandler').DispatchHandler; | ||
/** | ||
@@ -18,39 +18,48 @@ * Application | ||
Scope.call(this, nameToStores); | ||
this.get = Scope.prototype.get; | ||
RouteHandler.call(this, this._stores); | ||
_.extend(this, RouteHandler.prototype); | ||
DispatchHandler.call(this, this._stores); | ||
this.dispatch = _.bind(function(event, payload){ | ||
return DispatchHandler.prototype.dispatch.call(this, event, payload); | ||
}, this); | ||
this.emitChange = _.bind(function(){ | ||
return Application.prototype.emitChange.call(this); | ||
}, this); | ||
this.dispatchHandler = new DispatchHandler(this._stores); | ||
this.dispatch = _.bind(this.dispatchHandler.dispatch, this.dispatchHandler); | ||
var self = this; | ||
//keep track of state. | ||
//when it changes, we emit a change and the payload is a state object (with a dispatcher) | ||
var state = new State(); | ||
this.state = state; | ||
var go = _.bind(this.go, this); | ||
_.each(nameToStores, function(store, name){ | ||
//add a 'go' function to each store so they can write code like | ||
//this.go('some/url') | ||
store.go = go; | ||
store.setState = function(params){ | ||
return state.setState(name, params); | ||
}; | ||
store.replaceState = function(params){ | ||
return state.replaceState(name, params); | ||
}; | ||
store.forceUpdate = function(){ | ||
state.forceUpdate(name); | ||
}; | ||
store.state = function(namespace){ | ||
return state.value[namespace || name]; | ||
}; | ||
store.addStateChangeListener = function(callback){ | ||
state.addListener('change', callback); | ||
}; | ||
store.removeStateChangeListener = function(callback){ | ||
state.removeListener('change', callback); | ||
}; | ||
state.replaceState(name, {}); | ||
}); | ||
_.each(this._stores, function(store){ | ||
//when a store fires a change event, we forward to the root view listening | ||
store.on('change', function(){ | ||
self.emitChange(store); | ||
}); | ||
store.go = _.bind(self.go, self); | ||
store.scope = _.bind(self.push, self); | ||
store.initialize && store.initialize(); | ||
}); | ||
state.on('change', function(namespace, value){ | ||
this.emit('change', state.value); | ||
}.bind(this)); | ||
} | ||
Application.prototype.push = function(map){ | ||
var result = Scope.prototype.push.call(this, map); | ||
result.dispatch = this.dispatch; | ||
result.emitChange = this.emitChange; | ||
result.push = Application.prototype.push; | ||
return result; | ||
}; | ||
Application.prototype.emitChange = function(){ | ||
this.emit('change'); | ||
}; | ||
/** | ||
@@ -60,15 +69,12 @@ * ViewMixin | ||
var ViewMixin = { | ||
scope: function(values){ | ||
return values ? this.props.scope.push(values) : this.props.scope; | ||
resolve : function(key){ | ||
return this.props[key] || (this.props.scope && this.props.scope[key]); | ||
}, | ||
resolve: function(key){ | ||
return this.props.scope.get(key); | ||
resolveWith : function(key, props){ | ||
return props[key] || (props.scope && props.scope[key]); | ||
}, | ||
dispatch: function(event, payload){ | ||
return this.props.scope.dispatch(event, payload); | ||
}, | ||
dispatcher: function(event){ | ||
return _.bind(function(e){ | ||
this.props.scope.dispatch(event, e.target.value); | ||
}, this); | ||
scope: function(values){ | ||
var result = React.addons.update(this.props.scope, {$merge : this.props}); | ||
if (values) result = React.addons.update(result, {$merge: values}); | ||
return result; | ||
} | ||
@@ -82,20 +88,32 @@ }; | ||
debounceTime: 10, | ||
resolve : function(key){ | ||
var scope = this.props.application.state.value; | ||
return this.props[key] || scope[key]; | ||
}, | ||
resolveWith : function(key, props){ | ||
var scope = props.application.state.value; | ||
return props[key] || scope[key]; | ||
}, | ||
scope: function(values){ | ||
var scope = this.props.application.state.value; | ||
var result = React.addons.update(scope, {$merge : this.props}); | ||
if (values) | ||
result = React.addons.update(result, {$merge: values}); | ||
return result; | ||
}, | ||
componentWillMount: function(){ | ||
var app = this.props.application; | ||
this.callback = (function(){ | ||
this.forceUpdate(); | ||
}).bind(this); | ||
this.props.scope.on('change', _.debounce(this.callback, this.debounceTime)); | ||
this.dispatch = app.dispatch; | ||
app.on('change', _.debounce(this.callback, this.debounceTime)); | ||
} | ||
}; | ||
_.extend(RootViewMixin, ViewMixin); | ||
exports.Application = Application; | ||
exports.ViewMixin = ViewMixin; | ||
exports.RootViewMixin = RootViewMixin; | ||
//export to make testing easier | ||
exports.Scope = Scope; | ||
//export for users of standalone build. | ||
//(perhaps this should be browserify-shim-ed instead) | ||
exports.Promise = require('es6-promise').Promise; |
@@ -23,3 +23,2 @@ var | ||
routeDelegate[route].apply(routeDelegate, args); | ||
self.emitChange(); | ||
}; | ||
@@ -26,0 +25,0 @@ actions[route] = action; |
{ | ||
"name": "fluir", | ||
"version": "0.2.12", | ||
"version": "1.0.2", | ||
"description": "Dispatcher, router, store helper for React apps.", | ||
@@ -12,3 +12,4 @@ "main": "index.js", | ||
"browserify-shim": { | ||
"underscore": "global:_" | ||
"underscore": "global:_", | ||
"react/addons": "global:React" | ||
}, | ||
@@ -42,3 +43,2 @@ "scripts": { | ||
"z5h.nodeunit-asserts": "^0.0.4", | ||
"react": "^0.11.2", | ||
"react-tools": "^0.11.2", | ||
@@ -62,4 +62,5 @@ "watchify": "^1.0.2", | ||
"es6-promise": "^2.0.0", | ||
"director": "^1.2.3" | ||
"director": "^1.2.3", | ||
"react": "^0.11.2" | ||
} | ||
} |
#fluir# | ||
[](https://travis-ci.org/z5h/fluir) | ||
##important## | ||
Upgrading to 1.0 will break many things for you. | ||
Sorry. | ||
The good news is I'm using 1.0 for real work. So it's in a more stable/usable state. | ||
##what## | ||
@@ -10,2 +15,6 @@ | ||
##important!## | ||
The API is a bit of a moving target right now and the upcoming [1.0.0 branch](https://github.com/z5h/fluir/tree/1.0.0) contains significant changes. | ||
##install## | ||
@@ -12,0 +21,0 @@ ```npm install fluir``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
188736
4.21%18
-5.26%2767
1.1%1
-50%29
45%4
33.33%36
-2.7%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added