-
Notifications
You must be signed in to change notification settings - Fork 3
/
loxe.min.js
16 lines (16 loc) · 15.7 KB
/
loxe.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/**
* Modules in this bundle
*
* loxe:
* license: MIT
* author: ahomu
* version: 0.5.0
*
* object-assign:
* license: MIT
* author: Sindre Sorhus <[email protected]>
* maintainers: sindresorhus <[email protected]>
* version: 3.0.0
*
*/
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Loxe=e()}}(function(){return function e(t,n,r){function o(u,a){if(!n[u]){if(!t[u]){var s="function"==typeof require&&require;if(!a&&s)return s(u,!0);if(i)return i(u,!0);var l=new Error("Cannot find module '"+u+"'");throw l.code="MODULE_NOT_FOUND",l}var c=n[u]={exports:{}};t[u][0].call(c.exports,function(e){var n=t[u][1][e];return o(n?n:e)},c,c.exports,e,t,n,r)}return n[u].exports}for(var i="function"==typeof require&&require,u=0;u<r.length;u++)o(r[u]);return o}({1:[function(e,t){"use strict";function n(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}function r(e){var t=Object.getOwnPropertyNames(e);return Object.getOwnPropertySymbols&&(t=t.concat(Object.getOwnPropertySymbols(e))),t.filter(function(t){return o.call(e,t)})}var o=Object.prototype.propertyIsEnumerable;t.exports=Object.assign||function(e){for(var t,o,i=n(e),u=1;u<arguments.length;u++){t=arguments[u],o=r(Object(t));for(var a=0;a<o.length;a++)i[o[a]]=t[o[a]]}return i}},{}],2:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=e("./Subject"),u=e("../implements/ReflectionImpl"),a=function(){function e(){r(this,e),this.eventStream$=i["default"].stream()}return o(e,[{key:"publish",value:function(e,t){this.eventStream$.next({event:e,payload:t})}},{key:"do",value:function(e,t){return this.publish(e,t)}},{key:"getClassName",value:function(){return u["default"].getClassName.apply(this)}}]),e}();n["default"]=a},{"../implements/ReflectionImpl":6,"./Subject":5}],3:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=window.React,u=i,a=e("../implements/ReflectionImpl"),s=e("./Action"),l=e("./Store"),c=function(){function e(){r(this,e),this.stores=new Map,this.actions=new Map}return o(e,[{key:"registerAction",value:function(e){if(!(e instanceof s["default"]))throw new Error("Given instance of "+e.getClassName()+" is not Action");var t=Object.getPrototypeOf(e).constructor;if(this.actions.has(t))throw new Error(""+e.getClassName()+" already exists in this domain.");this.actions.set(t,e)}},{key:"getAction",value:function(e){if(!this.actions.has(e))throw new Error(""+e.constructor.name+" is not registered as Action.");return this.actions.get(e)}},{key:"registerStore",value:function(e){if(!(e instanceof l["default"]))throw new Error("Given instance of "+e.getClassName()+" is not Store");var t=Object.getPrototypeOf(e).constructor;if(this.stores.has(t))throw new Error(""+e.getClassName()+" already exists in this domain.");this.stores.set(t,e)}},{key:"getStore",value:function(e){if(!this.stores.has(e))throw new Error(""+e.constructor.name+" is not registered as Store.");return this.stores.get(e)}},{key:"subscribeActionObservableFromStore",value:function(){var e=this;this.stores.forEach(function(t){e.actions.forEach(function(e){t.plugAction(e)})})}},{key:"mountRootComponent",value:function(e,t){return this.subscribeActionObservableFromStore(),u.render(u.createElement(e,{domain:this}),t)}},{key:"getObservables",value:function(){throw new Error(this.getClassName()+":`getObservables` is abstract method.You should implements in sub-class")}},{key:"getClassName",value:function(){return a["default"].getClassName.apply(this)}}]),e}();n["default"]=c},{"../implements/ReflectionImpl":6,"./Action":2,"./Store":4}],4:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=e("./Subject"),u=e("../implements/ReflectionImpl"),a=e("../implements/SubscriberImpl"),s=function(){function e(){r(this,e),this.plugStream$=i["default"].stream()}return o(e,[{key:"plugAction",value:function(e){this.subscribe(e.eventStream$,this.plugStream$.next.bind(this.plugStream$))}},{key:"getEvent",value:function(e){return this.plugStream$.filter(function(t){var n=t.event;return n===e}).map(function(e){var t=e.payload;return t})}},{key:"subscribeEvent",value:function(e,t){this.subscribe(this.getEvent(e),t)}},{key:"subscribe",value:function(e,t){"string"==typeof e&&(e=this.getEvent(e)),a["default"].subscribe.apply(this,[e,t])}},{key:"unsubscribeAll",value:function(){a["default"].unsubscribeAll.apply(this)}},{key:"getClassName",value:function(){return u["default"].getClassName.apply(this)}}]),e}();n["default"]=s},{"../implements/ReflectionImpl":6,"../implements/SubscriberImpl":7,"./Subject":5}],5:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=function(){function e(t){r(this,e),this.MyRx=null,this.MyRx=t}return o(e,[{key:"stream",value:function(){return this.create(this.MyRx.Subject)}},{key:"property",value:function(e){return this.create(this.MyRx.BehaviorSubject,e)}},{key:"create",value:function(e,t){function n(){n.onNext.apply(n,arguments)}for(var r in e.prototype)n[r]=e.prototype[r];return n.next=n.onNext,n["throw"]=n.onError,n["return"]=n.onCompleted,e.call(n,t),n}}]),e}();n.RxBuilder=i;var u=function(){function e(t){r(this,e),this.MyKefir=null,this.MyKefir=t}return o(e,[{key:"stream",value:function(){return this.create(this.MyKefir.Stream)}},{key:"property",value:function(e){return this.create(this.MyKefir.Property,e)}},{key:"create",value:function(e,t){function n(){n._emitValue.apply(n,arguments)}for(var r in e.prototype)n[r]=e.prototype[r];return n.next=n._emitValue,n["throw"]=n._emitError,n["return"]=n._emitEnd,e.call(n),void 0!==t&&(n._active=!0,n._currentEvent={type:"value",value:t,current:!0}),n}}]),e}();n.KefirBuilder=u;var a=function(){function e(){r(this,e)}return o(e,null,[{key:"stream",value:function(){return e._builder.stream.apply(e._builder,arguments)}},{key:"property",value:function(){return e._builder.property.apply(e._builder,arguments)}},{key:"combineTemplate",value:function(){return e._combineTemplate.apply(e._combineTemplate,arguments)}},{key:"setBuilder",value:function(t){e._builder=t}},{key:"setCombineTemplate",value:function(t){e._combineTemplate=t}},{key:"KefirBuilder",value:u,enumerable:!0},{key:"RxBuilder",value:i,enumerable:!0}]),e}();n["default"]=a},{}],6:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=function(){function e(){r(this,e)}return o(e,null,[{key:"getClassName",value:function(){return Object.getPrototypeOf(this).constructor.name}}]),e}();n["default"]=i},{}],7:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),i=function(){function e(){r(this,e),this._subscriptions=[]}return o(e,null,[{key:"subscribe",value:function(e,t){if(null!=e){var n=void 0;e.subscribe?n=e.subscribe(t):(e.onValue(t),n=[e,t]),this._subscriptions=this._subscriptions||[],this._subscriptions.push(n)}}},{key:"unsubscribeAll",value:function(){this._subscriptions=this._subscriptions||[],this._subscriptions.forEach(function(e){e.dispose?e.dispose():e[0].offValue(e[1])}),this._subscriptions=[]}}]),e}();n["default"]=i},{}],8:[function(e,t,n){"use strict";var r=e("./classes/Action"),o=e("./classes/Domain"),i=e("./classes/Store"),u=e("./classes/Subject"),a=e("./providers/provideContext"),s=e("./providers/provideObservables"),l=e("./providers/provideActions");n.Action=r["default"],n.Domain=o["default"],n.Store=i["default"],n.Subject=u["default"],n.provideActions=l["default"],n.provideContext=a["default"],n.provideObservables=s["default"]},{"./classes/Action":2,"./classes/Domain":3,"./classes/Store":4,"./classes/Subject":5,"./providers/provideActions":9,"./providers/provideContext":10,"./providers/provideObservables":11}],9:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)}function i(e,t){var n=function(n){function i(){r(this,i),null!=n&&n.apply(this,arguments)}return o(i,n),u(i,[{key:"getDisplayName",value:function(){return f["default"].getClassName.apply(this)}},{key:"render",value:function(){var n=this;if(!this.context.getAction)throw new Error("The context does not have `getAction`.Make sure the ancestral component provides the domain context, use `@provideContext`.");var r={};return t.reduce(function(e,t){e[t.name]=n.context.getAction(t)},r),s.createElement(e,c(r,this.props))}}],[{key:"_originalComponent",value:e,enumerable:!0},{key:"contextTypes",value:{getAction:s.PropTypes.func.isRequired},enumerable:!0}]),i}(s.Component);return p["default"](e,n),n}var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=window.React,s=a,l=e("object-assign"),c=l,f=e("../implements/ReflectionImpl"),p=e("../utils/copy-statics"),b=e("../utils/decoratable");n["default"]=b["default"](i)},{"../implements/ReflectionImpl":6,"../utils/copy-statics":12,"../utils/decoratable":13,"object-assign":1}],10:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)}function i(e){var t=function(t){function n(){r(this,n),null!=t&&t.apply(this,arguments),this.childContexts=null}return o(n,t),u(n,[{key:"componentWillMount",value:function(){if(!this.props.domain)throw new Error("@provideContext higher-ordered component must have `props.domain`");this.childContexts={getAction:this.props.domain.getAction.bind(this.props.domain),getObservables:this.props.domain.getObservables.bind(this.props.domain)}}},{key:"getDisplayName",value:function(){return c["default"].getClassName.apply(this)}},{key:"getChildContext",value:function(){return this.childContexts}},{key:"render",value:function(){return s.createElement(e,this.props)}}],[{key:"_originalComponent",value:e,enumerable:!0},{key:"propTypes",value:{domain:s.PropTypes.instanceOf(l["default"]).isRequired},enumerable:!0},{key:"childContextTypes",value:{getAction:s.PropTypes.func.isRequired,getObservables:s.PropTypes.func.isRequired},enumerable:!0}]),n}(s.Component);return f["default"](e,t),t}var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=window.React,s=a,l=e("../classes/Domain"),c=e("../implements/ReflectionImpl"),f=e("../utils/copy-statics"),p=e("../utils/decoratable");n["default"]=p["default"](i)},{"../classes/Domain":3,"../implements/ReflectionImpl":6,"../utils/copy-statics":12,"../utils/decoratable":13}],11:[function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)}function i(e,t){var n=function(n){function i(){r(this,i),null!=n&&n.apply(this,arguments)}return o(i,n),u(i,[{key:"subscribe",value:function(e,t){p["default"].subscribe.apply(this,[e,t])}},{key:"unsubscribeAll",value:function(){p["default"].unsubscribeAll.apply(this)}},{key:"getDisplayName",value:function(){return b["default"].getClassName.apply(this)}},{key:"componentWillMount",value:function(){if(!this.context.getObservables)throw new Error("The context does not have `getObservables`.Make sure the ancestral component provides the domain context, use `@provideContext`.");var e=this.context.getObservables(),n=t(e),r=f["default"].combineTemplate(n);this.subscribe(r,this.setState.bind(this))}},{key:"componentWillUnmount",value:function(){this.unsubscribeAll()}},{key:"render",value:function(){return s.createElement(e,c({},this.props,this.state))}}],[{key:"_originalComponent",value:e,enumerable:!0},{key:"contextTypes",value:{getObservables:s.PropTypes.func.isRequired},enumerable:!0}]),i}(s.Component);return m["default"](e,n),n}var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=window.React,s=a,l=e("object-assign"),c=l,f=e("../classes/Subject"),p=e("../implements/SubscriberImpl"),b=e("../implements/ReflectionImpl"),m=e("../utils/copy-statics"),y=e("../utils/decoratable");n["default"]=y["default"](i)},{"../classes/Subject":5,"../implements/ReflectionImpl":6,"../implements/SubscriberImpl":7,"../utils/copy-statics":12,"../utils/decoratable":13,"object-assign":1}],12:[function(e,t,n){"use strict";function r(e,t){Object.getOwnPropertyNames(e).filter(function(t){return e.hasOwnProperty(t)&&!o[t]}).forEach(function(n){t[n]=e[n]})}n["default"]=r;var o={arguments:!0,caller:!0,key:!0,length:!0,name:!0,prototype:!0,ref:!0,type:!0}},{}],13:[function(e,t,n){"use strict";function r(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}function o(e){return function(){for(var t=arguments.length,n=Array(t),o=0;t>o;o++)n[o]=arguments[o];if(n.length<e.length){var i=function(){var t=e.length-n.length;return{v:function(){for(var o=arguments.length,i=Array(o),u=0;o>u;u++)i[u]=arguments[u];return e.apply(null,[].concat(r(i.slice(0,t)),n))}}}();if("object"==typeof i)return i.v}return e.apply(null,n)}}n["default"]=o},{}]},{},[8])(8)});