Comparing version 5.0.1 to 5.0.2
{ | ||
"name": "reflux", | ||
"version": "5.0.2", | ||
"homepage": "https://github.com/spoike/reflux", | ||
@@ -4,0 +5,0 @@ "authors": [ |
@@ -7,2 +7,14 @@ # Changelog | ||
## v5.0.2 | ||
Reduced the need for `defineReact` by better detecting of React. Updated to run on `reflux-core` v0.4.1, which solves some memory leaks. | ||
## v5.0.1 | ||
Adding of full ES6 API, most notably `Reflux.Component` and `Reflux.Store` (and their sub-methods/properties). Also `defineReact`, `initializeGlobalStore`, `GlobalState`, `getGlobalState`, `setGlobalState`. | ||
## v0.4.x | ||
* ?? | ||
## v0.3.0 | ||
@@ -9,0 +21,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.Reflux=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){"use strict";function d(a,b,c){this.fn=a,this.context=b,this.once=c||!1}function e(){}var f=Object.prototype.hasOwnProperty,g="function"!=typeof Object.create?"~":!1;e.prototype._events=void 0,e.prototype.eventNames=function(){var a,b=this._events,c=[];if(!b)return c;for(a in b)f.call(b,a)&&c.push(g?a.slice(1):a);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(b)):c},e.prototype.listeners=function(a,b){var c=g?g+a:a,d=this._events&&this._events[c];if(b)return!!d;if(!d)return[];if(d.fn)return[d.fn];for(var e=0,f=d.length,h=new Array(f);f>e;e++)h[e]=d[e].fn;return h},e.prototype.emit=function(a,b,c,d,e,f){var h=g?g+a:a;if(!this._events||!this._events[h])return!1;var i,j,k=this._events[h],l=arguments.length;if("function"==typeof k.fn){switch(k.once&&this.removeListener(a,k.fn,void 0,!0),l){case 1:return k.fn.call(k.context),!0;case 2:return k.fn.call(k.context,b),!0;case 3:return k.fn.call(k.context,b,c),!0;case 4:return k.fn.call(k.context,b,c,d),!0;case 5:return k.fn.call(k.context,b,c,d,e),!0;case 6:return k.fn.call(k.context,b,c,d,e,f),!0}for(j=1,i=new Array(l-1);l>j;j++)i[j-1]=arguments[j];k.fn.apply(k.context,i)}else{var m,n=k.length;for(j=0;n>j;j++)switch(k[j].once&&this.removeListener(a,k[j].fn,void 0,!0),l){case 1:k[j].fn.call(k[j].context);break;case 2:k[j].fn.call(k[j].context,b);break;case 3:k[j].fn.call(k[j].context,b,c);break;default:if(!i)for(m=1,i=new Array(l-1);l>m;m++)i[m-1]=arguments[m];k[j].fn.apply(k[j].context,i)}}return!0},e.prototype.on=function(a,b,c){var e=new d(b,c||this),f=g?g+a:a;return this._events||(this._events=g?{}:Object.create(null)),this._events[f]?this._events[f].fn?this._events[f]=[this._events[f],e]:this._events[f].push(e):this._events[f]=e,this},e.prototype.once=function(a,b,c){var e=new d(b,c||this,!0),f=g?g+a:a;return this._events||(this._events=g?{}:Object.create(null)),this._events[f]?this._events[f].fn?this._events[f]=[this._events[f],e]:this._events[f].push(e):this._events[f]=e,this},e.prototype.removeListener=function(a,b,c,d){var e=g?g+a:a;if(!this._events||!this._events[e])return this;var f=this._events[e],h=[];if(b)if(f.fn)(f.fn!==b||d&&!f.once||c&&f.context!==c)&&h.push(f);else for(var i=0,j=f.length;j>i;i++)(f[i].fn!==b||d&&!f[i].once||c&&f[i].context!==c)&&h.push(f[i]);return h.length?this._events[e]=1===h.length?h[0]:h:delete this._events[e],this},e.prototype.removeAllListeners=function(a){return this._events?(a?delete this._events[g?g+a:a]:this._events=g?{}:Object.create(null),this):this},e.prototype.off=e.prototype.removeListener,e.prototype.addListener=e.prototype.on,e.prototype.setMaxListeners=function(){return this},e.prefixed=g,"undefined"!=typeof b&&(b.exports=e)},{}],2:[function(a,b,c){"use strict";b.exports={}},{}],3:[function(a,b,c){"use strict";c.createdStores=[],c.createdActions=[],c.reset=function(){for(;c.createdStores.length;)c.createdStores.pop();for(;c.createdActions.length;)c.createdActions.pop()}},{}],4:[function(a,b,c){"use strict";var d=a("./utils"),e=a("./joins").instanceJoinCreator,f=function(a){for(var b,c=0,d={};c<(a.children||[]).length;++c)b=a.children[c],a[b]&&(d[b]=a[b]);return d},g=function h(a){var b={};for(var c in a){var e=a[c],g=f(e),i=h(g);b[c]=e;for(var j in i){var k=i[j];b[c+d.capitalize(j)]=k}}return b};b.exports={hasListener:function(a){for(var b,c,d,e=0;e<(this.subscriptions||[]).length;++e)for(d=[].concat(this.subscriptions[e].listenable),b=0;b<d.length;b++)if(c=d[b],c===a||c.hasListener&&c.hasListener(a))return!0;return!1},listenToMany:function(a){var b=g(a);for(var c in b){var e=d.callbackName(c),f=this[e]?e:this[c]?c:void 0;f&&this.listenTo(b[c],f,this[e+"Default"]||this[f+"Default"]||f)}},validateListening:function(a){return a===this?"Listener is not able to listen to itself":d.isFunction(a.listen)?a.hasListener&&a.hasListener(this)?"Listener cannot listen to this listenable because of circular loop":void 0:a+" is missing a listen method"},listenTo:function(a,b,c){var e,f,g,h=this.subscriptions=this.subscriptions||[];return d.throwIf(this.validateListening(a)),this.fetchInitialState(a,c),e=a.listen(this[b]||b,this),f=function(){var a=h.indexOf(g);d.throwIf(-1===a,"Tried to remove listen already gone from subscriptions list!"),h.splice(a,1),e()},g={stop:f,listenable:a},h.push(g),g},stopListeningTo:function(a){for(var b,c=0,e=this.subscriptions||[];c<e.length;c++)if(b=e[c],b.listenable===a)return b.stop(),d.throwIf(-1!==e.indexOf(b),"Failed to remove listen from subscriptions list!"),!0;return!1},stopListeningToAll:function(){for(var a,b=this.subscriptions||[];a=b.length;)b[0].stop(),d.throwIf(b.length!==a-1,"Failed to remove listen from subscriptions list!")},fetchInitialState:function(a,b){b=b&&this[b]||b;var c=this;if(d.isFunction(b)&&d.isFunction(a.getInitialState)){var e=a.getInitialState();e&&d.isFunction(e.then)?e.then(function(){b.apply(c,arguments)}):b.call(this,e)}},joinTrailing:e("last"),joinLeading:e("first"),joinConcat:e("all"),joinStrict:e("strict")}},{"./joins":11,"./utils":13}],5:[function(a,b,c){"use strict";var d=a("./utils");b.exports={preEmit:function(){},shouldEmit:function(){return!0},listen:function(a,b){b=b||this;var c=function(c){e||a.apply(b,c)},d=this,e=!1;return this.emitter.addListener(this.eventLabel,c),function(){e=!0,d.emitter.removeListener(d.eventLabel,c)}},trigger:function(){var a=arguments,b=this.preEmit.apply(this,a);a=void 0===b?a:d.isArguments(b)?b:[].concat(b),this.shouldEmit.apply(this,a)&&this.emitter.emit(this.eventLabel,a)},triggerAsync:function(){var a=arguments,b=this;d.nextTick(function(){b.trigger.apply(b,a)})},deferWith:function(a){var b=this.trigger,c=this,d=function(){b.apply(c,arguments)};this.trigger=function(){a.apply(c,[d].concat([].splice.call(arguments,0)))}}}},{"./utils":13}],6:[function(a,b,c){"use strict";b.exports={}},{}],7:[function(a,b,c){"use strict";b.exports=function(a,b){for(var c in b)if(Object.getOwnPropertyDescriptor&&Object.defineProperty){var d=Object.getOwnPropertyDescriptor(b,c);if(!d.value||"function"!=typeof d.value||!b.hasOwnProperty(c))continue;a[c]=b[c].bind(a)}else{var e=b[c];if("function"!=typeof e||!b.hasOwnProperty(c))continue;a[c]=e.bind(a)}return a}},{}],8:[function(a,b,c){"use strict";var d=a("./utils"),e=a("./ActionMethods"),f=a("./PublisherMethods"),g=a("./Keep"),h={preEmit:1,shouldEmit:1},i=function j(a){a=a||{},d.isObject(a)||(a={actionName:a});for(var b in e)if(!h[b]&&f[b])throw new Error("Cannot override API method "+b+" in Reflux.ActionMethods. Use another method name or override it on Reflux.PublisherMethods instead.");for(var c in a)if(!h[c]&&f[c])throw new Error("Cannot override API method "+c+" in action creation. Use another method name or override it on Reflux.PublisherMethods instead.");a.children=a.children||[],a.asyncResult&&(a.children=a.children.concat(["completed","failed"]));for(var i=0,k={};i<a.children.length;i++){var l=a.children[i];k[l]=j(l)}var m=d.extend({eventLabel:"action",emitter:new d.EventEmitter,_isAction:!0},f,e,a),n=function o(){var a=o.sync?"trigger":"triggerAsync";return o[a].apply(o,arguments)};return d.extend(n,k,m),g.createdActions.push(n),n};b.exports=i},{"./ActionMethods":2,"./Keep":3,"./PublisherMethods":5,"./utils":13}],9:[function(a,b,c){"use strict";var d=a("./utils"),e=a("./Keep"),f=a("./mixer"),g=a("./bindMethods"),h={preEmit:1,shouldEmit:1};b.exports=function(b){function c(){var a,c=0;if(this.subscriptions=[],this.emitter=new d.EventEmitter,this.eventLabel="change",g(this,b),this.init&&d.isFunction(this.init)&&this.init(),this.listenables)for(a=[].concat(this.listenables);c<a.length;c++)this.listenToMany(a[c])}var i=a("./StoreMethods"),j=a("./PublisherMethods"),k=a("./ListenerMethods");b=b||{};for(var l in i)if(!h[l]&&(j[l]||k[l]))throw new Error("Cannot override API method "+l+" in Reflux.StoreMethods. Use another method name or override it on Reflux.PublisherMethods / Reflux.ListenerMethods instead.");for(var m in b)if(!h[m]&&(j[m]||k[m]))throw new Error("Cannot override API method "+m+" in store creation. Use another method name or override it on Reflux.PublisherMethods / Reflux.ListenerMethods instead.");b=f(b),d.extend(c.prototype,k,j,i,b);var n=new c;return e.createdStores.push(n),n}},{"./Keep":3,"./ListenerMethods":4,"./PublisherMethods":5,"./StoreMethods":6,"./bindMethods":7,"./mixer":12,"./utils":13}],10:[function(a,b,c){"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d={version:{"reflux-core":"0.3.0"}};d.ActionMethods=a("./ActionMethods"),d.ListenerMethods=a("./ListenerMethods"),d.PublisherMethods=a("./PublisherMethods"),d.StoreMethods=a("./StoreMethods"),d.createAction=a("./createAction"),d.createStore=a("./createStore");var e=a("./joins").staticJoinCreator;d.joinTrailing=d.all=e("last"),d.joinLeading=e("first"),d.joinStrict=e("strict"),d.joinConcat=e("all");var f=d.utils=a("./utils");d.EventEmitter=f.EventEmitter,d.Promise=f.Promise,d.createActions=function(){var a=function(a,b){Object.keys(a).forEach(function(c){var e=a[c];b[c]=d.createAction(e)})};return function(b){var c={};return b instanceof Array?b.forEach(function(b){f.isObject(b)?a(b,c):c[b]=d.createAction(b)}):a(b,c),c}}(),d.setEventEmitter=function(a){d.EventEmitter=f.EventEmitter=a},d.nextTick=function(a){f.nextTick=a},d.use=function(a){a(d)},d.__keep=a("./Keep"),Function.prototype.bind||console.error("Function.prototype.bind not available. ES5 shim required. https://github.com/spoike/refluxjs#es5"),c["default"]=d,b.exports=c["default"]},{"./ActionMethods":2,"./Keep":3,"./ListenerMethods":4,"./PublisherMethods":5,"./StoreMethods":6,"./createAction":8,"./createStore":9,"./joins":11,"./utils":13}],11:[function(a,b,c){"use strict";function d(a,b,c){return function(){var d,e=c.subscriptions,f=e?e.indexOf(a):-1;for(i.throwIf(-1===f,"Tried to remove join already gone from subscriptions list!"),d=0;d<b.length;d++)b[d]();e.splice(f,1)}}function e(a){a.listenablesEmitted=new Array(a.numberOfListenables),a.args=new Array(a.numberOfListenables)}function f(a,b){return function(){var c=j.call(arguments);if(b.listenablesEmitted[a])switch(b.strategy){case"strict":throw new Error("Strict join failed because listener triggered twice.");case"last":b.args[a]=c;break;case"all":b.args[a].push(c)}else b.listenablesEmitted[a]=!0,b.args[a]="all"===b.strategy?[c]:c;g(b)}}function g(a){for(var b=0;b<a.numberOfListenables;b++)if(!a.listenablesEmitted[b])return;a.callback.apply(a.listener,a.args),e(a)}var h=a("./createStore"),i=a("./utils"),j=Array.prototype.slice,k={strict:"joinStrict",first:"joinLeading",last:"joinTrailing",all:"joinConcat"};c.staticJoinCreator=function(a){return function(){var b=j.call(arguments);return h({init:function(){this[k[a]].apply(this,b.concat("triggerAsync"))}})}},c.instanceJoinCreator=function(a){return function(){i.throwIf(arguments.length<2,"Cannot create a join with less than 2 listenables!");var b,c,g=j.call(arguments),h=g.pop(),k=g.length,l={numberOfListenables:k,callback:this[h]||h,listener:this,strategy:a},m=[];for(b=0;k>b;b++)i.throwIf(this.validateListening(g[b]));for(b=0;k>b;b++)m.push(g[b].listen(f(b,l),this));return e(l),c={listenable:g},c.stop=d(c,m,this),this.subscriptions=(this.subscriptions||[]).concat(c),c}}},{"./createStore":9,"./utils":13}],12:[function(a,b,c){"use strict";var d=a("./utils");b.exports=function(a){var b={init:[],preEmit:[],shouldEmit:[]},c=function e(a){var c={};return a.mixins&&a.mixins.forEach(function(a){d.extend(c,e(a))}),d.extend(c,a),Object.keys(b).forEach(function(c){a.hasOwnProperty(c)&&b[c].push(a[c])}),c}(a);return b.init.length>1&&(c.init=function(){var a=arguments;b.init.forEach(function(b){b.apply(this,a)},this)}),b.preEmit.length>1&&(c.preEmit=function(){return b.preEmit.reduce(function(a,b){var c=b.apply(this,a);return void 0===c?a:[c]}.bind(this),arguments)}),b.shouldEmit.length>1&&(c.shouldEmit=function(){var a=arguments;return!b.shouldEmit.some(function(b){return!b.apply(this,a)},this)}),Object.keys(b).forEach(function(a){1===b[a].length&&(c[a]=b[a][0])}),c}},{"./utils":13}],13:[function(a,b,c){"use strict";function d(a){return a.charAt(0).toUpperCase()+a.slice(1)}function e(a,b){return b=b||"on",b+c.capitalize(a)}function f(a){var b=typeof a;return"function"===b||"object"===b&&!!a}function g(a){if(!f(a))return a;for(var b,c,d=1,e=arguments.length;e>d;d++){b=arguments[d];for(c in b)if(Object.getOwnPropertyDescriptor&&Object.defineProperty){var g=Object.getOwnPropertyDescriptor(b,c);Object.defineProperty(a,c,g)}else a[c]=b[c]}return a}function h(a){return"function"==typeof a}function i(a,b){for(var c={},d=0;d<a.length;d++)c[a[d]]=b[d];return c}function j(a){return"object"==typeof a&&"callee"in a&&"number"==typeof a.length}function k(a,b){if(a)throw Error(b||a)}Object.defineProperty(c,"__esModule",{value:!0}),c.capitalize=d,c.callbackName=e,c.isObject=f,c.extend=g,c.isFunction=h,c.object=i,c.isArguments=j,c.throwIf=k,c.EventEmitter=a("eventemitter3"),c.nextTick=function(a){setTimeout(a,0)}},{eventemitter3:1}],14:[function(a,b,c){var d=a("reflux-core/lib/utils"),e=a("reflux-core/lib/ListenerMethods");b.exports=d.extend({componentWillUnmount:e.stopListeningToAll},e)},{"reflux-core/lib/ListenerMethods":4,"reflux-core/lib/utils":13}],15:[function(a,b,c){var d=a("reflux-core/lib/ListenerMethods"),e=a("./ListenerMixin"),f=a("reflux-core/lib/utils");b.exports=function(a,b){return f.throwIf("undefined"==typeof b,"Reflux.connect() requires a key."),{getInitialState:function(){return f.isFunction(a.getInitialState)?f.object([b],[a.getInitialState()]):{}},componentDidMount:function(){var c=this;f.extend(c,d),this.listenTo(a,function(a){c.setState(f.object([b],[a]))})},componentWillUnmount:e.componentWillUnmount}}},{"./ListenerMixin":14,"reflux-core/lib/ListenerMethods":4,"reflux-core/lib/utils":13}],16:[function(a,b,c){var d=a("reflux-core/lib/ListenerMethods"),e=a("./ListenerMixin"),f=a("reflux-core/lib/utils");b.exports=function(a,b,c){return f.throwIf(f.isFunction(b),"Reflux.connectFilter() requires a key."),{getInitialState:function(){if(!f.isFunction(a.getInitialState))return{};var d=c.call(this,a.getInitialState());return"undefined"!=typeof d?f.object([b],[d]):{}},componentDidMount:function(){var e=this;f.extend(this,d),this.listenTo(a,function(a){var d=c.call(e,a);e.setState(f.object([b],[d]))})},componentWillUnmount:e.componentWillUnmount}}},{"./ListenerMixin":14,"reflux-core/lib/ListenerMethods":4,"reflux-core/lib/utils":13}],17:[function(a,b,c){function d(a,b,c){var k,l;try{i=b||i||Reflux,h=a||h||React,l=c||h.Component}catch(m){return}if(i&&h&&l&&(!j||c)){var n=function(a){l.call(this,a)};if(f(n,l),k=n.prototype,k.storeKeys=null,k.componentWillMount=function(){if(this.store&&(Array.isArray(this.stores)?this.stores.unshift(this.store):this.stores=[this.store]),this.stores){this.__storeunsubscribes__=this.__storeunsubscribes__||[];for(var a=this.setState.bind(this),b=function(b){var c=e(this.storeKeys,b);c&&a(c)}.bind(this),c=0,d=this.stores.length;d>c;c++){var f=this.stores[c];if(f.isES6Store){var g=f.id;if(f.singleton||(f.singleton=new f,g&&(i.stores[g]=f.singleton)),this.stores[c]=f=f.singleton,f.id=g,g&&i.GlobalState[g]){for(var h in i.GlobalState[g])f.state[h]=i.GlobalState[g][h];i.GlobalState[g]=f.state}else g&&(i.GlobalState[g]=f.state)}this.__storeunsubscribes__.push(f.listen(b));var j=e(this.storeKeys,f.state);j&&this.setState(j)}}this.__readytomap__=!0;var k=this.__delayedmaps__;if(k)for(var l=0,m=k.length;m>l;l++)k[l].func(k[l].state);this.__delayedmaps__=null},k.componentWillUnmount=function(){for(var a=0,b=this.__storeunsubscribes__.length;b>a;a++)this.__storeunsubscribes__[a]();this.__readytomap__=!1},k.mapStoreToState=function(a,b){function c(a){var c=b.call(d,a);if(c){var e=!1;for(var f in c){e=!0;break}e&&d.setState(c)}}a.isES6Store&&(a=a.singleton?a.singleton:a.id?Reflux.initializeGlobalStore(a):a.singleton=new a);var d=this;this.__storeunsubscribes__=this.__storeunsubscribes__||[],this.__storeunsubscribes__.push(a.listen(c)),this.__readytomap__?c(a.state):(this.__delayedmaps__=this.__delayedmaps__||[],this.__delayedmaps__.push({func:c,state:a.state}))},n.extend=function(a){return d(null,null,a)},c)return n;i.Component=n;var o=function(){this.__store__=i.createStore(),this.state={};var a=this;for(var b in this.__store__)!function(b){Object.defineProperty(a,b,{get:function(){return a.__store__[b]},set:function(c){a.__store__[b]=c}})}(b)};k=o.prototype,Object.defineProperty(k,"listenables",{get:function(){return this.__listenables__},set:function(a){var b={};Array.isArray(a)?a.forEach(function(a){for(var c in a)b[c]=a[c]}):b=a,this.__listenables__=b,this.listenToMany(b)},enumerable:!0,configurable:!0}),k.setState=function(a){for(var b in a)this.state[b]=a[b];this.id&&(i.GlobalState[this.id]=this.state),this.trigger(a)},Object.defineProperty(o,"isES6Store",{get:function(){return!0},enumerable:!0,configurable:!0}),i.Store=o,i.GlobalState=i.GlobalState||{},i.stores={},i.getGlobalState=function(){return g(i.GlobalState)},i.setGlobalState=function(a){for(var b in a)i.stores[b]?i.stores[b].setState(a[b]):i.GlobalState[b]=a[b]},i.initializeGlobalStore=function(a){var b=a.id;if(!b)throw new Error("Invalid store id.");if(a.singleton)throw new Error("Store already initialized.");var c=a.singleton=new a;if(i.stores[b]=c,c.id=b,i.GlobalState[b]){for(var d in i.GlobalState[b])c.state[d]=i.GlobalState[b][d];i.GlobalState[b]=c.state}else i.GlobalState[b]=c.state;return c},j=!0}}function e(a,b){if(!a)return b;for(var c=!1,d={},e=0,f=a.length;f>e;e++){var g=a[e];b.hasOwnProperty(g)&&(c=!0,d[g]=b[g])}return c?d:!1}function f(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)}function g(a,b){if(null===a||"object"!=typeof a)return a;if(a.constructor!==Object&&a.constructor!==Array)return a;if(a.constructor===Date||a.constructor===RegExp||a.constructor===Function||a.constructor===String||a.constructor===Number||a.constructor===Boolean)return new a.constructor(a);b=b||new a.constructor;for(var c in a)b[c]="undefined"==typeof b[c]?g(a[c],null):b[c];return b}var h,i,j=!1;b.exports=d},{}],18:[function(a,b,c){var d=a("reflux-core");d.connect=a("./connect"),d.connectFilter=a("./connectFilter"),d.ListenerMixin=a("./ListenerMixin"),d.listenTo=a("./listenTo"),d.listenToMany=a("./listenToMany"),d.defineReact=a("./defineReact"),"undefined"!=typeof React&&React&&d.defineReact(React,d),b.exports=d},{"./ListenerMixin":14,"./connect":15,"./connectFilter":16,"./defineReact":17,"./listenTo":19,"./listenToMany":20,"reflux-core":10}],19:[function(a,b,c){var d=a("reflux-core/lib/ListenerMethods");b.exports=function(a,b,c){return{componentDidMount:function(){for(var e in d)if(this[e]!==d[e]){if(this[e])throw"Can't have other property '"+e+"' when using Reflux.listenTo!";this[e]=d[e]}this.listenTo(a,b,c)},componentWillUnmount:d.stopListeningToAll}}},{"reflux-core/lib/ListenerMethods":4}],20:[function(a,b,c){var d=a("reflux-core/lib/ListenerMethods");b.exports=function(a){return{componentDidMount:function(){for(var b in d)if(this[b]!==d[b]){if(this[b])throw"Can't have other property '"+b+"' when using Reflux.listenToMany!";this[b]=d[b]}this.listenToMany(a)},componentWillUnmount:d.stopListeningToAll}}},{"reflux-core/lib/ListenerMethods":4}]},{},[18])(18)}); | ||
!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.Reflux=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){"use strict";function d(a,b,c){this.fn=a,this.context=b,this.once=c||!1}function e(){}var f=Object.prototype.hasOwnProperty,g="function"!=typeof Object.create?"~":!1;e.prototype._events=void 0,e.prototype.eventNames=function(){var a,b=this._events,c=[];if(!b)return c;for(a in b)f.call(b,a)&&c.push(g?a.slice(1):a);return Object.getOwnPropertySymbols?c.concat(Object.getOwnPropertySymbols(b)):c},e.prototype.listeners=function(a,b){var c=g?g+a:a,d=this._events&&this._events[c];if(b)return!!d;if(!d)return[];if(d.fn)return[d.fn];for(var e=0,f=d.length,h=new Array(f);f>e;e++)h[e]=d[e].fn;return h},e.prototype.emit=function(a,b,c,d,e,f){var h=g?g+a:a;if(!this._events||!this._events[h])return!1;var i,j,k=this._events[h],l=arguments.length;if("function"==typeof k.fn){switch(k.once&&this.removeListener(a,k.fn,void 0,!0),l){case 1:return k.fn.call(k.context),!0;case 2:return k.fn.call(k.context,b),!0;case 3:return k.fn.call(k.context,b,c),!0;case 4:return k.fn.call(k.context,b,c,d),!0;case 5:return k.fn.call(k.context,b,c,d,e),!0;case 6:return k.fn.call(k.context,b,c,d,e,f),!0}for(j=1,i=new Array(l-1);l>j;j++)i[j-1]=arguments[j];k.fn.apply(k.context,i)}else{var m,n=k.length;for(j=0;n>j;j++)switch(k[j].once&&this.removeListener(a,k[j].fn,void 0,!0),l){case 1:k[j].fn.call(k[j].context);break;case 2:k[j].fn.call(k[j].context,b);break;case 3:k[j].fn.call(k[j].context,b,c);break;default:if(!i)for(m=1,i=new Array(l-1);l>m;m++)i[m-1]=arguments[m];k[j].fn.apply(k[j].context,i)}}return!0},e.prototype.on=function(a,b,c){var e=new d(b,c||this),f=g?g+a:a;return this._events||(this._events=g?{}:Object.create(null)),this._events[f]?this._events[f].fn?this._events[f]=[this._events[f],e]:this._events[f].push(e):this._events[f]=e,this},e.prototype.once=function(a,b,c){var e=new d(b,c||this,!0),f=g?g+a:a;return this._events||(this._events=g?{}:Object.create(null)),this._events[f]?this._events[f].fn?this._events[f]=[this._events[f],e]:this._events[f].push(e):this._events[f]=e,this},e.prototype.removeListener=function(a,b,c,d){var e=g?g+a:a;if(!this._events||!this._events[e])return this;var f=this._events[e],h=[];if(b)if(f.fn)(f.fn!==b||d&&!f.once||c&&f.context!==c)&&h.push(f);else for(var i=0,j=f.length;j>i;i++)(f[i].fn!==b||d&&!f[i].once||c&&f[i].context!==c)&&h.push(f[i]);return h.length?this._events[e]=1===h.length?h[0]:h:delete this._events[e],this},e.prototype.removeAllListeners=function(a){return this._events?(a?delete this._events[g?g+a:a]:this._events=g?{}:Object.create(null),this):this},e.prototype.off=e.prototype.removeListener,e.prototype.addListener=e.prototype.on,e.prototype.setMaxListeners=function(){return this},e.prefixed=g,"undefined"!=typeof b&&(b.exports=e)},{}],2:[function(a,b,c){"use strict";Object.defineProperty(c,"__esModule",{value:!0})},{}],3:[function(a,b,c){"use strict";function d(){var a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:!0;h=a}function e(a){h&&i.push(a)}function f(a){h&&j.push(a)}function g(){for(;i.length;)i.pop();for(;j.length;)j.pop()}Object.defineProperty(c,"__esModule",{value:!0});var h=!1,i=[],j=[];c.useKeep=d,c.addStore=e,c.addAction=f,c.createdStores=i,c.createdActions=j,c.reset=g},{}],4:[function(a,b,c){"use strict";function d(a){if(a&&a.__esModule)return a;var b={};if(null!=a)for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&(b[c]=a[c]);return b["default"]=a,b}Object.defineProperty(c,"__esModule",{value:!0}),c.joinStrict=c.joinConcat=c.joinLeading=c.joinTrailing=c.fetchInitialState=c.stopListeningToAll=c.stopListeningTo=c.listenTo=c.validateListening=c.listenToMany=c.hasListener=void 0;var e=a("./utils"),f=d(e),g=a("./joins"),h=function(a){for(var b,c=0,d={};c<(a.children||[]).length;++c)b=a.children[c],a[b]&&(d[b]=a[b]);return d},i=function j(a){var b={};for(var c in a){var d=a[c],e=h(d),g=j(e);b[c]=d;for(var i in g){var k=g[i];b[c+f.capitalize(i)]=k}}return b};c.hasListener=function(a){for(var b,c,d,e=0;e<(this.subscriptions||[]).length;++e)for(d=[].concat(this.subscriptions[e].listenable),b=0;b<d.length;b++)if(c=d[b],c===a||c.hasListener&&c.hasListener(a))return!0;return!1},c.listenToMany=function(a){var b=i(a);for(var c in b){var d=f.callbackName(c),e=this[d]?d:this[c]?c:void 0;e&&this.listenTo(b[c],e,this[d+"Default"]||this[e+"Default"]||e)}},c.validateListening=function(a){return a===this?"Listener is not able to listen to itself":f.isFunction(a.listen)?a.hasListener&&a.hasListener(this)?"Listener cannot listen to this listenable because of circular loop":void 0:a+" is missing a listen method"},c.listenTo=function(a,b,c){var d,e,g,h=this.subscriptions=this.subscriptions||[];return f.throwIf(this.validateListening(a)),this.fetchInitialState(a,c),d=a.listen(this[b]||b,this),e=function(){var a=h.indexOf(g);f.throwIf(-1===a,"Tried to remove listen already gone from subscriptions list!"),h.splice(a,1),d()},g={stop:e,listenable:a},h.push(g),g},c.stopListeningTo=function(a){for(var b,c=0,d=this.subscriptions||[];c<d.length;c++)if(b=d[c],b.listenable===a)return b.stop(),f.throwIf(-1!==d.indexOf(b),"Failed to remove listen from subscriptions list!"),!0;return!1},c.stopListeningToAll=function(){for(var a,b=this.subscriptions||[];a=b.length;)b[0].stop(),f.throwIf(b.length!==a-1,"Failed to remove listen from subscriptions list!")},c.fetchInitialState=function(a,b){b=b&&this[b]||b;var c=this;if(f.isFunction(b)&&f.isFunction(a.getInitialState)){var d=a.getInitialState();d&&f.isFunction(d.then)?d.then(function(){b.apply(c,arguments)}):b.call(this,d)}},c.joinTrailing=(0,g.instanceJoinCreator)("last"),c.joinLeading=(0,g.instanceJoinCreator)("first"),c.joinConcat=(0,g.instanceJoinCreator)("all"),c.joinStrict=(0,g.instanceJoinCreator)("strict")},{"./joins":11,"./utils":13}],5:[function(a,b,c){"use strict";function d(a){if(a&&a.__esModule)return a;var b={};if(null!=a)for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&(b[c]=a[c]);return b["default"]=a,b}Object.defineProperty(c,"__esModule",{value:!0}),c.deferWith=c.triggerAsync=c.trigger=c.listen=c.shouldEmit=c.preEmit=void 0;var e=a("./utils"),f=d(e);c.preEmit=function(){},c.shouldEmit=function(){return!0},c.listen=function(a,b){b=b||this;var c=function(c){e||a.apply(b,c)},d=this,e=!1;return this.emitter.addListener(this.eventLabel,c),function(){e=!0,d.emitter.removeListener(d.eventLabel,c)}},c.trigger=function(){var a=arguments,b=this.preEmit.apply(this,a);a=void 0===b?a:f.isArguments(b)?b:[].concat(b),this.shouldEmit.apply(this,a)&&this.emitter.emit(this.eventLabel,a)},c.triggerAsync=function(){var a=arguments,b=this;f.nextTick(function(){b.trigger.apply(b,a)})},c.deferWith=function(a){var b=this.trigger,c=this,d=function(){b.apply(c,arguments)};this.trigger=function(){a.apply(c,[d].concat([].splice.call(arguments,0)))}}},{"./utils":13}],6:[function(a,b,c){arguments[4][2][0].apply(c,arguments)},{dup:2}],7:[function(a,b,c){"use strict";function d(a,b){for(var c in b)if(Object.getOwnPropertyDescriptor&&Object.defineProperty){var d=Object.getOwnPropertyDescriptor(b,c);if(!d.value||"function"!=typeof d.value||!b.hasOwnProperty(c))continue;a[c]=b[c].bind(a)}else{var e=b[c];if("function"!=typeof e||!b.hasOwnProperty(c))continue;a[c]=e.bind(a)}return a}Object.defineProperty(c,"__esModule",{value:!0}),c.bindMethods=d},{}],8:[function(a,b,c){"use strict";function d(a){if(a&&a.__esModule)return a;var b={};if(null!=a)for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&(b[c]=a[c]);return b["default"]=a,b}function e(a){a=a||{},g.isObject(a)||(a={actionName:a});for(var b in i)if(!n[b]&&k[b])throw new Error("Cannot override API method "+b+" in Reflux.ActionMethods. Use another method name or override it on Reflux.PublisherMethods instead.");for(var c in a)if(!n[c]&&k[c])throw new Error("Cannot override API method "+c+" in action creation. Use another method name or override it on Reflux.PublisherMethods instead.");a.children=a.children||[],a.asyncResult&&(a.children=a.children.concat(["completed","failed"]));for(var d=0,f={};d<a.children.length;d++){var h=a.children[d];f[h]=e(h)}var j=g.extend({eventLabel:"action",emitter:new g.EventEmitter,_isAction:!0},k,i,a),l=function o(){var a=o.sync?"trigger":"triggerAsync";return o[a].apply(o,arguments)};return g.extend(l,f,j),m.addAction(l),l}Object.defineProperty(c,"__esModule",{value:!0}),c.createAction=e;var f=a("./utils"),g=d(f),h=a("./ActionMethods"),i=d(h),j=a("./PublisherMethods"),k=d(j),l=a("./Keep"),m=d(l),n={preEmit:1,shouldEmit:1}},{"./ActionMethods":2,"./Keep":3,"./PublisherMethods":5,"./utils":13}],9:[function(a,b,c){"use strict";function d(a){if(a&&a.__esModule)return a;var b={};if(null!=a)for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&(b[c]=a[c]);return b["default"]=a,b}function e(a){function b(){var b,c=0;if(this.subscriptions=[],this.emitter=new g.EventEmitter,this.eventLabel="change",(0,k.bindMethods)(this,a),this.init&&g.isFunction(this.init)&&this.init(),this.listenables)for(b=[].concat(this.listenables);c<b.length;c++)this.listenToMany(b[c])}a=a||{};for(var c in m)if(!r[c]&&(o[c]||q[c]))throw new Error("Cannot override API method "+c+" in Reflux.StoreMethods. Use another method name or override it on Reflux.PublisherMethods / Reflux.ListenerMethods instead.");for(var d in a)if(!r[d]&&(o[d]||q[d]))throw new Error("Cannot override API method "+d+" in store creation. Use another method name or override it on Reflux.PublisherMethods / Reflux.ListenerMethods instead.");a=(0,j.mix)(a),g.extend(b.prototype,q,o,m,a);var e=new b;return i.addStore(e),e}Object.defineProperty(c,"__esModule",{value:!0}),c.createStore=e;var f=a("./utils"),g=d(f),h=a("./Keep"),i=d(h),j=a("./mixer"),k=a("./bindMethods"),l=a("./StoreMethods"),m=d(l),n=a("./PublisherMethods"),o=d(n),p=a("./ListenerMethods"),q=d(p),r={preEmit:1,shouldEmit:1}},{"./Keep":3,"./ListenerMethods":4,"./PublisherMethods":5,"./StoreMethods":6,"./bindMethods":7,"./mixer":12,"./utils":13}],10:[function(a,b,c){"use strict";function d(a){if(a&&a.__esModule)return a;var b={};if(null!=a)for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&(b[c]=a[c]);return b["default"]=a,b}function e(a){r.EventEmitter=a}function f(a){r.nextTick=a}function g(a){a(this)}Object.defineProperty(c,"__esModule",{value:!0}),c.__keep=c.joinConcat=c.joinStrict=c.joinLeading=c.all=c.joinTrailing=c.use=c.nextTick=c.setEventEmitter=c.createActions=c.createStore=c.createAction=c.utils=c.StoreMethods=c.PublisherMethods=c.ListenerMethods=c.ActionMethods=c.version=void 0;var h=a("./ActionMethods"),i=d(h),j=a("./ListenerMethods"),k=d(j),l=a("./PublisherMethods"),m=d(l),n=a("./StoreMethods"),o=d(n),p=a("./joins"),q=a("./utils"),r=d(q),s=a("./createAction"),t=a("./createStore"),u=a("./Keep"),v=d(u),w={"reflux-core":"0.4.1"},x=(0,p.staticJoinCreator)("last"),y=x,z=(0,p.staticJoinCreator)("first"),A=(0,p.staticJoinCreator)("strict"),B=(0,p.staticJoinCreator)("all"),C=r,D=function(){var a=function(a,b){Object.keys(a).forEach(function(c){var d=a[c];b[c]=(0,s.createAction)(d)})};return function(b){var c={};return b instanceof Array?b.forEach(function(b){r.isObject(b)?a(b,c):c[b]=(0,s.createAction)(b)}):a(b,c),c}}();c.version=w,c.ActionMethods=i,c.ListenerMethods=k,c.PublisherMethods=m,c.StoreMethods=o,c.utils=C,c.createAction=s.createAction,c.createStore=t.createStore,c.createActions=D,c.setEventEmitter=e,c.nextTick=f,c.use=g,c.joinTrailing=x,c.all=y,c.joinLeading=z,c.joinStrict=A,c.joinConcat=B,c.__keep=v,Function.prototype.bind||console.error("Function.prototype.bind not available. ES5 shim required. https://github.com/spoike/refluxjs#es5")},{"./ActionMethods":2,"./Keep":3,"./ListenerMethods":4,"./PublisherMethods":5,"./StoreMethods":6,"./createAction":8,"./createStore":9,"./joins":11,"./utils":13}],11:[function(a,b,c){"use strict";function d(a){if(a&&a.__esModule)return a;var b={};if(null!=a)for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&(b[c]=a[c]);return b["default"]=a,b}function e(a){return function(){var b=n.call(arguments);return(0,k.createStore)({init:function(){this[o[a]].apply(this,b.concat("triggerAsync"))}})}}function f(a){return function(){m.throwIf(arguments.length<2,"Cannot create a join with less than 2 listenables!");var b,c,d=n.call(arguments),e=d.pop(),f=d.length,j={numberOfListenables:f,callback:this[e]||e,listener:this,strategy:a},k=[];for(b=0;f>b;b++)m.throwIf(this.validateListening(d[b]));for(b=0;f>b;b++)k.push(d[b].listen(i(b,j),this));return h(j),c={listenable:d},c.stop=g(c,k,this),this.subscriptions=(this.subscriptions||[]).concat(c),c}}function g(a,b,c){return function(){var d,e=c.subscriptions,f=e?e.indexOf(a):-1;for(m.throwIf(-1===f,"Tried to remove join already gone from subscriptions list!"),d=0;d<b.length;d++)b[d]();e.splice(f,1)}}function h(a){a.listenablesEmitted=new Array(a.numberOfListenables),a.args=new Array(a.numberOfListenables)}function i(a,b){return function(){var c=n.call(arguments);if(b.listenablesEmitted[a])switch(b.strategy){case"strict":throw new Error("Strict join failed because listener triggered twice.");case"last":b.args[a]=c;break;case"all":b.args[a].push(c)}else b.listenablesEmitted[a]=!0,b.args[a]="all"===b.strategy?[c]:c;j(b)}}function j(a){for(var b=0;b<a.numberOfListenables;b++)if(!a.listenablesEmitted[b])return;a.callback.apply(a.listener,a.args),h(a)}Object.defineProperty(c,"__esModule",{value:!0}),c.staticJoinCreator=e,c.instanceJoinCreator=f;var k=a("./createStore"),l=a("./utils"),m=d(l),n=Array.prototype.slice,o={strict:"joinStrict",first:"joinLeading",last:"joinTrailing",all:"joinConcat"}},{"./createStore":9,"./utils":13}],12:[function(a,b,c){"use strict";function d(a){if(a&&a.__esModule)return a;var b={};if(null!=a)for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&(b[c]=a[c]);return b["default"]=a,b}function e(a){var b={init:[],preEmit:[],shouldEmit:[]},c=function d(a){var c={};return a.mixins&&a.mixins.forEach(function(a){g.extend(c,d(a))}),g.extend(c,a),Object.keys(b).forEach(function(c){a.hasOwnProperty(c)&&b[c].push(a[c])}),c}(a);return b.init.length>1&&(c.init=function(){var a=arguments;b.init.forEach(function(b){b.apply(this,a)},this)}),b.preEmit.length>1&&(c.preEmit=function(){return b.preEmit.reduce(function(a,b){var c=b.apply(this,a);return void 0===c?a:[c]}.bind(this),arguments)}),b.shouldEmit.length>1&&(c.shouldEmit=function(){var a=arguments;return!b.shouldEmit.some(function(b){return!b.apply(this,a)},this)}),Object.keys(b).forEach(function(a){1===b[a].length&&(c[a]=b[a][0])}),c}Object.defineProperty(c,"__esModule",{value:!0}),c.mix=e;var f=a("./utils"),g=d(f)},{"./utils":13}],13:[function(a,b,c){"use strict";function d(a){return a.charAt(0).toUpperCase()+a.slice(1)}function e(a,b){return b=b||"on",b+c.capitalize(a)}function f(a){var b="undefined"==typeof a?"undefined":m(a);return"function"===b||"object"===b&&!!a}function g(a){if(!f(a))return a;for(var b,c,d,e=1,g=arguments.length;g>e;e++){b=arguments[e],c=Object.keys(b);for(var h=0;h<c.length;h++)if(d=c[h],Object.getOwnPropertyDescriptor&&Object.defineProperty){var i=Object.getOwnPropertyDescriptor(b,d);Object.defineProperty(a,d,i)}else a[d]=b[d]}return a}function h(a){return"function"==typeof a}function i(a){setTimeout(a,0)}function j(a,b){for(var c={},d=0;d<a.length;d++)c[a[d]]=b[d];return c}function k(a){return"object"===("undefined"==typeof a?"undefined":m(a))&&"callee"in a&&"number"==typeof a.length}function l(a,b){if(a)throw Error(b||a)}Object.defineProperty(c,"__esModule",{value:!0});var m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a};c.capitalize=d,c.callbackName=e,c.isObject=f,c.extend=g,c.isFunction=h,c.nextTick=i,c.object=j,c.isArguments=k,c.throwIf=l,c.EventEmitter=a("eventemitter3")},{eventemitter3:1}],14:[function(a,b,c){var d=a("reflux-core/lib/utils"),e=a("reflux-core/lib/ListenerMethods");b.exports=d.extend({componentWillUnmount:e.stopListeningToAll},e)},{"reflux-core/lib/ListenerMethods":4,"reflux-core/lib/utils":13}],15:[function(a,b,c){var d=a("reflux-core");if(d.defineReact=a("./defineReact"),"undefined"!=typeof React&&React)d.defineReact(React);else try{var e=a("react");d.defineReact(e)}catch(f){}},{"./defineReact":18,react:void 0,"reflux-core":10}],16:[function(a,b,c){var d=a("reflux-core/lib/ListenerMethods"),e=a("./ListenerMixin"),f=a("reflux-core/lib/utils");b.exports=function(a,b){return f.throwIf("undefined"==typeof b,"Reflux.connect() requires a key."),{getInitialState:function(){return f.isFunction(a.getInitialState)?f.object([b],[a.getInitialState()]):{}},componentDidMount:function(){var c=this;f.extend(c,d),this.listenTo(a,function(a){c.setState(f.object([b],[a]))})},componentWillUnmount:e.componentWillUnmount}}},{"./ListenerMixin":14,"reflux-core/lib/ListenerMethods":4,"reflux-core/lib/utils":13}],17:[function(a,b,c){var d=a("reflux-core/lib/ListenerMethods"),e=a("./ListenerMixin"),f=a("reflux-core/lib/utils");b.exports=function(a,b,c){return f.throwIf(f.isFunction(b),"Reflux.connectFilter() requires a key."),{getInitialState:function(){if(!f.isFunction(a.getInitialState))return{};var d=c.call(this,a.getInitialState());return"undefined"!=typeof d?f.object([b],[d]):{}},componentDidMount:function(){var e=this;f.extend(this,d),this.listenTo(a,function(a){var d=c.call(e,a);e.setState(f.object([b],[d]))})},componentWillUnmount:e.componentWillUnmount}}},{"./ListenerMixin":14,"reflux-core/lib/ListenerMethods":4,"reflux-core/lib/utils":13}],18:[function(a,b,c){function d(a,b,c){var k,l;try{h=a||h||React,l=c||h.Component}catch(m){return}if(h&&l&&(!j||c)){var n=function(a){l.call(this,a)};if(f(n,l),k=n.prototype,k.storeKeys=null,k.componentWillMount=function(){if(this.store&&(Array.isArray(this.stores)?this.stores.unshift(this.store):this.stores=[this.store]),this.stores){this.__storeunsubscribes__=this.__storeunsubscribes__||[];for(var a=this.setState.bind(this),b=function(b){var c=e(this.storeKeys,b);c&&a(c)}.bind(this),c=0,d=this.stores.length;d>c;c++){var f=this.stores[c];if(f.isES6Store){var g=f.id;if(f.singleton||(f.singleton=new f,g&&(i.stores[g]=f.singleton)),this.stores[c]=f=f.singleton,f.id=g,g&&i.GlobalState[g]){for(var h in i.GlobalState[g])f.state[h]=i.GlobalState[g][h];i.GlobalState[g]=f.state}else g&&(i.GlobalState[g]=f.state)}this.__storeunsubscribes__.push(f.listen(b));var j=e(this.storeKeys,f.state);j&&this.setState(j)}}this.__readytomap__=!0;var k=this.__delayedmaps__;if(k)for(var l=0,m=k.length;m>l;l++)k[l].func(k[l].state);this.__delayedmaps__=null},k.componentWillUnmount=function(){for(var a=0,b=this.__storeunsubscribes__.length;b>a;a++)this.__storeunsubscribes__[a]();this.__readytomap__=!1},k.mapStoreToState=function(a,b){function c(a){var c=b.call(d,a);if(c){var e=!1;for(var f in c){e=!0;break}e&&d.setState(c)}}a.isES6Store&&(a=a.singleton?a.singleton:a.id?i.initializeGlobalStore(a):a.singleton=new a);var d=this;this.__storeunsubscribes__=this.__storeunsubscribes__||[],this.__storeunsubscribes__.push(a.listen(c)),this.__readytomap__?c(a.state):(this.__delayedmaps__=this.__delayedmaps__||[],this.__delayedmaps__.push({func:c,state:a.state}))},n.extend=function(a){return d(null,null,a)},c)return n;i.Component=n;var o=function(){this.__store__=i.createStore(),this.state={};var a=this;for(var b in this.__store__)!function(b){Object.defineProperty(a,b,{get:function(){return a.__store__[b]},set:function(c){a.__store__[b]=c}})}(b)};k=o.prototype,Object.defineProperty(k,"listenables",{get:function(){return this.__listenables__},set:function(a){var b={};Array.isArray(a)?a.forEach(function(a){for(var c in a)b[c]=a[c]}):b=a,this.__listenables__=b,this.listenToMany(b)},enumerable:!0,configurable:!0}),k.setState=function(a){for(var b in a)this.state[b]=a[b];this.id&&(i.GlobalState[this.id]=this.state),this.trigger(a)},Object.defineProperty(o,"isES6Store",{get:function(){return!0},enumerable:!0,configurable:!0}),i.Store=o,i.GlobalState=i.GlobalState||{},i.stores={},i.getGlobalState=function(){return g(i.GlobalState)},i.setGlobalState=function(a){for(var b in a)i.stores[b]?i.stores[b].setState(a[b]):i.GlobalState[b]=a[b]},i.initializeGlobalStore=function(a){var b=a.id;if(!b)throw new Error("Invalid store id.");if(a.singleton)throw new Error("Store already initialized.");var c=a.singleton=new a;if(i.stores[b]=c,c.id=b,i.GlobalState[b]){for(var d in i.GlobalState[b])c.state[d]=i.GlobalState[b][d];i.GlobalState[b]=c.state}else i.GlobalState[b]=c.state;return c},j=!0}}function e(a,b){if(!a)return b;for(var c=!1,d={},e=0,f=a.length;f>e;e++){var g=a[e];b.hasOwnProperty(g)&&(c=!0,d[g]=b[g])}return c?d:!1}function f(a,b){function c(){this.constructor=a}for(var d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);a.prototype=null===b?Object.create(b):(c.prototype=b.prototype,new c)}function g(a,b){if(null===a||"object"!=typeof a)return a;if(a.constructor!==Object&&a.constructor!==Array)return a;if(a.constructor===Date||a.constructor===RegExp||a.constructor===Function||a.constructor===String||a.constructor===Number||a.constructor===Boolean)return new a.constructor(a);b=b||new a.constructor;for(var c in a)b[c]="undefined"==typeof b[c]?g(a[c],null):b[c];return b}var h,i=a("reflux-core"),j=!1;b.exports=d},{"reflux-core":10}],19:[function(a,b,c){var d=a("reflux-core");d.connect=a("./connect"),d.connectFilter=a("./connectFilter"),d.ListenerMixin=a("./ListenerMixin"),d.listenTo=a("./listenTo"),d.listenToMany=a("./listenToMany"),a("./addES6"),b.exports=d},{"./ListenerMixin":14,"./addES6":15,"./connect":16,"./connectFilter":17,"./listenTo":20,"./listenToMany":21,"reflux-core":10}],20:[function(a,b,c){var d=a("reflux-core/lib/ListenerMethods");b.exports=function(a,b,c){return{componentDidMount:function(){for(var e in d)if(this[e]!==d[e]){if(this[e])throw"Can't have other property '"+e+"' when using Reflux.listenTo!";this[e]=d[e]}this.listenTo(a,b,c)},componentWillUnmount:d.stopListeningToAll}}},{"reflux-core/lib/ListenerMethods":4}],21:[function(a,b,c){var d=a("reflux-core/lib/ListenerMethods");b.exports=function(a){return{componentDidMount:function(){for(var b in d)if(this[b]!==d[b]){if(this[b])throw"Can't have other property '"+b+"' when using Reflux.listenToMany!";this[b]=d[b]}this.listenToMany(a)},componentWillUnmount:d.stopListeningToAll}}},{"reflux-core/lib/ListenerMethods":4}]},{},[19])(19)}); |
@@ -25,2 +25,3 @@ require('es6-promise').polyfill(); | ||
options: { | ||
exclude: ['react'], | ||
browserifyOptions: { | ||
@@ -27,0 +28,0 @@ standalone: 'Reflux' |
{ | ||
"name": "reflux", | ||
"version": "5.0.1", | ||
"version": "5.0.2", | ||
"description": "A simple library for uni-directional dataflow application architecture inspired by ReactJS Flux", | ||
@@ -33,3 +33,3 @@ "main": "src/index.js", | ||
"eventemitter3": "^1.1.1", | ||
"reflux-core": "^0.3.0" | ||
"reflux-core": "^0.4.1" | ||
}, | ||
@@ -36,0 +36,0 @@ "devDependencies": { |
@@ -116,6 +116,9 @@ # RefluxJS | ||
bower install reflux | ||
Then the files may be embedded in your html file via `bower_components/reflux/dist/reflux.js` or `bower_components/reflux/dist/reflux.min.js`. | ||
### CDN | ||
Reflux is available at [jsdelivr](http://www.jsdelivr.com/#!refluxjs). | ||
Reflux is available at [jsdelivr](http://www.jsdelivr.com/#!refluxjs). | ||
jsdelivr [v5.0.1](https://cdn.jsdelivr.net/refluxjs/5.0.1/reflux.min.js) | ||
@@ -975,11 +978,10 @@ ### ES5 | ||
`Reflux.Component` extends `React.Component`. Therefore Reflux needs to be able to access React in order to expose it. If you need to load Reflux before React or if you are in an environment where `React` is not a global variable then there is an exposed method `Reflux.defineReact` that you can use to manually give Reflux a reference to the React object so that it may create the `Reflux.Component` class to extend from. A second optional argument also allows manually giving it a Reflux reference in case that isn't global either. An example on Node.js would be: | ||
`Reflux.Component` extends `React.Component`. Therefore Reflux needs to be able to access React in order to expose it. In the browser as long as React is loaded before Reflux then Reflux will automatically find it. Likewise in node-like environments where `require('react')` will function Reflux will try to access React that way. So in almost all situations Reflux will find React on its own. | ||
However, Reflux also exposes the method `Reflux.defineReact` that you can use to manually give Reflux a reference to the React object in case you need to: | ||
```javascript | ||
// only needed on some environments, usually Reflux just uses the globals! | ||
// In Node.js, for example there won't be a global Reflux/React though...so: | ||
var Reflux = require('reflux'); | ||
var React = require('react'); | ||
Reflux.defineReact(React, Reflux); | ||
// only needed if, for some reason, Reflux can't get reference to React: | ||
var React = /* however you access React */; | ||
Reflux.defineReact(React); | ||
// now Reflux.Component is accessible! | ||
@@ -986,0 +988,0 @@ ``` |
@@ -1,4 +0,5 @@ | ||
/* globals Reflux: false */ | ||
/* globals React: false */ | ||
var Reflux = require('reflux-core'); | ||
/** | ||
@@ -8,8 +9,7 @@ * Reflux.defineReact function where you can manually supply | ||
* React or there is a modular environment where there won't be a global | ||
* React variable. If Reflux is not global either then it can be included | ||
* as a second parameter. | ||
* React variable. | ||
* @note The third param is for internal usage only. | ||
*/ | ||
var _react, _reflux, _defined = false; | ||
function defineReact(react, reflux, extend) | ||
var _react, _defined = false; | ||
function defineReact(react, noLongerUsed, extend) | ||
{ | ||
@@ -20,3 +20,2 @@ var proto, _extend; | ||
try { | ||
_reflux = reflux || _reflux || Reflux; | ||
_react = react || _react || React; | ||
@@ -30,3 +29,3 @@ _extend = extend || _react.Component; | ||
// also ignore if it's been called before UNLESS there's manual extending happening | ||
if (!_reflux || !_react || !_extend || (_defined && !extend)) { | ||
if (!_react || !_extend || (_defined && !extend)) { | ||
return; | ||
@@ -100,3 +99,3 @@ } | ||
if (storeId) { | ||
_reflux.stores[storeId] = str.singleton; | ||
Reflux.stores[storeId] = str.singleton; | ||
} | ||
@@ -112,10 +111,10 @@ } | ||
// set the global state to that new state (since it may have previously been partial) | ||
if (storeId && _reflux.GlobalState[storeId]) { | ||
for (var key in _reflux.GlobalState[storeId]) { | ||
str.state[key] = _reflux.GlobalState[storeId][key]; | ||
if (storeId && Reflux.GlobalState[storeId]) { | ||
for (var key in Reflux.GlobalState[storeId]) { | ||
str.state[key] = Reflux.GlobalState[storeId][key]; | ||
} | ||
_reflux.GlobalState[storeId] = str.state; | ||
Reflux.GlobalState[storeId] = str.state; | ||
// otherwise (if it has an id) set the global state to the default state of the store | ||
} else if (storeId) { | ||
_reflux.GlobalState[storeId] = str.state; | ||
Reflux.GlobalState[storeId] = str.state; | ||
} | ||
@@ -234,3 +233,3 @@ // if no id, then no messing with global state | ||
// otherwise set as Reflux.Component and continue with other normal definitions | ||
_reflux.Component = RefluxComponent; | ||
Reflux.Component = RefluxComponent; | ||
// ------------ END Reflux.Component ------------ | ||
@@ -253,3 +252,3 @@ | ||
// that will actually be getting and setting on that internal instance. | ||
this.__store__ = _reflux.createStore(); | ||
this.__store__ = Reflux.createStore(); | ||
this.state = {}; | ||
@@ -303,3 +302,3 @@ var self = this; | ||
if (this.id) { | ||
_reflux.GlobalState[this.id] = this.state; | ||
Reflux.GlobalState[this.id] = this.state; | ||
} | ||
@@ -325,3 +324,3 @@ // trigger, because any component it's attached to is listening and will merge the store state into its own on a store trigger | ||
_reflux.Store = RefluxStore; | ||
Reflux.Store = RefluxStore; | ||
// ----------- END Reflux.Store ------------- | ||
@@ -340,3 +339,3 @@ | ||
*/ | ||
_reflux.GlobalState = _reflux.GlobalState || {}; | ||
Reflux.GlobalState = Reflux.GlobalState || {}; | ||
@@ -347,3 +346,3 @@ /** | ||
*/ | ||
_reflux.stores = {}; | ||
Reflux.stores = {}; | ||
@@ -355,4 +354,4 @@ /** | ||
*/ | ||
_reflux.getGlobalState = function() { | ||
return clone(_reflux.GlobalState); | ||
Reflux.getGlobalState = function() { | ||
return clone(Reflux.GlobalState); | ||
}; | ||
@@ -367,8 +366,8 @@ | ||
*/ | ||
_reflux.setGlobalState = function(obj) { | ||
Reflux.setGlobalState = function(obj) { | ||
for (var storeID in obj) { | ||
if (_reflux.stores[storeID]) { | ||
_reflux.stores[storeID].setState(obj[storeID]); | ||
if (Reflux.stores[storeID]) { | ||
Reflux.stores[storeID].setState(obj[storeID]); | ||
} else { | ||
_reflux.GlobalState[storeID] = obj[storeID]; | ||
Reflux.GlobalState[storeID] = obj[storeID]; | ||
} | ||
@@ -384,3 +383,3 @@ } | ||
*/ | ||
_reflux.initializeGlobalStore = function(str) { | ||
Reflux.initializeGlobalStore = function(str) { | ||
var storeId = str.id; | ||
@@ -398,3 +397,3 @@ // this is primarily for making stores work with global state when not in a component, so if no id then notify something is wrong | ||
// store it on the Reflux.stores array to be accessible later | ||
_reflux.stores[storeId] = inst; | ||
Reflux.stores[storeId] = inst; | ||
// the singleton instance itself should also have the id property of the class | ||
@@ -404,10 +403,10 @@ inst.id = storeId; | ||
// make sure to set the global state to the end result, since it may have only been partial | ||
if (_reflux.GlobalState[storeId]) { | ||
for (var key in _reflux.GlobalState[storeId]) { | ||
inst.state[key] = _reflux.GlobalState[storeId][key]; | ||
if (Reflux.GlobalState[storeId]) { | ||
for (var key in Reflux.GlobalState[storeId]) { | ||
inst.state[key] = Reflux.GlobalState[storeId][key]; | ||
} | ||
_reflux.GlobalState[storeId] = inst.state; | ||
Reflux.GlobalState[storeId] = inst.state; | ||
// otherwise just set the global state to the default state of the class | ||
} else { | ||
_reflux.GlobalState[storeId] = inst.state; | ||
Reflux.GlobalState[storeId] = inst.state; | ||
} | ||
@@ -414,0 +413,0 @@ // returns the singleton itself, though it will also be accessible as as `MyClass.singleton` |
@@ -13,8 +13,4 @@ var Reflux = require('reflux-core'); | ||
/* globals React: false */ | ||
Reflux.defineReact = require('./defineReact'); | ||
if (typeof React !== 'undefined' && React) { | ||
Reflux.defineReact(React, Reflux); | ||
} | ||
require('./addES6'); | ||
module.exports = Reflux; |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
182170
21
2408
1027
0
+ Addedreflux-core@0.4.3(transitive)
- Removedreflux-core@0.3.0(transitive)
Updatedreflux-core@^0.4.1