UNPKG

rxact-debugger

Version:

Debugger for rxact

1 lines 12.6 kB
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.rxcat=e():t.rxcat=e()}(this,function(){return function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var r={};return e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=4)}([function(t,e,r){"use strict";var n=r(7),o=r.n(n);e.a=function(t){return!!t&&(!!t[o.a]||!(!t.prototype||!t.prototype[o.a]))}},function(t,e,r){"use strict";function n(t){if(Array.isArray(t)){for(var e=0,r=Array(t.length);t.length>e;e++)r[e]=t[e];return r}return Array.from(t)}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var i=r(2),u=r(12),a=r(13),c=r(14),f=function(){function t(t,e){for(var r=0;e.length>r;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),s=function(){function t(e,r,n){var f=this;if(o(this,t),this.emitters={},this.subscriptions=[],this.observers=[],this.dispose=function(){f.subscriptions.forEach(function(t){t.unsubscribe()})},this.installPlugins=function(){var e=f;return t.plugins.forEach(function(t){if("function"!=typeof t)throw Error("Expected plugin to be a function.");var r=t(e);r&&(e=r)}),e},"string"!=typeof e||!e)throw Error("Expected the streamName to be a not none string.");return this.streamName=e,this.Observable=Object(i.b)(),this.state$=u.a.call(this,r),this.state$=a.a.call(this,this.state$,e,n),this.eventRunner=Object(c.a)(this.Observable,this.getState),this.installPlugins()}return f(t,[{key:"emitter",value:function(t,e){var r=this;if(!t)throw Error("emitter(): name should not be blank.");if("function"!=typeof e)throw Error("emitter(): expect second parameter to be a function.");this[t]=function(){r.next(e.apply(void 0,arguments))},this.emitters[t]=this[t]}}]),t}();s.plugins=[],s.addPlugin=function(){for(var t=arguments.length,e=Array(t),r=0;t>r;r++)e[r]=arguments[r];e.forEach(function(t){if("function"!=typeof t)throw Error("Expected plugin to be a function.")}),s.plugins=[].concat(n(s.plugins),e)},s.removePlugin=function(){for(var t=arguments.length,e=Array(t),r=0;t>r;r++)e[r]=arguments[r];var n=[];0!==e.length&&(n=s.plugins.filter(function(t){return!e.find(function(e){return e===t})})),s.plugins=n},e.a=s},function(t,e,r){"use strict";r.d(e,"c",function(){return i}),r.d(e,"b",function(){return u}),r.d(e,"a",function(){return a});var n=r(0),o=null,i=function(t){if(Object(n.a)(o))throw Error("Expected setup once in your app lifetime.");o=t},u=function(){if(!o)throw Error("You must configure Observable first.");return o},a=function(){o=null}},function(t,e,r){"use strict";function n(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}Object.defineProperty(e,"__esModule",{value:!0}),e.clean=e.decorator=e.plugin=void 0;var u=r(5),a=function(t){return t&&t.__esModule?t:{default:t}}(u),c=a.default,f=function(t){var e=(0,a.default)(t);return function(t){return function(t){function r(){var t,i,u;n(this,r);for(var a=arguments.length,c=Array(a),f=0;a>f;f++)c[f]=arguments[f];var s=i=o(this,(t=r.__proto__||Object.getPrototypeOf(r)).call.apply(t,[this].concat(c)));return u=e(s),o(i,u)}return i(r,t),r}(t)}};e.plugin=c,e.decorator=f,e.clean=u.clean},function(t,e,r){r(3),t.exports=r(3)},function(t,e,r){"use strict";function n(t){var e=this,r=t.streamName,n={get:function(t,n){if((0,f.isDebugger)(n))return{start:function(){e.isStarted=!0},stop:function(){e.isStarted=!1}};var o="operator";return(0,f.isPresent)(t,n)||console.warn("Operator does not exist: "+r+"."+n),!(0,f.isOperator)(t,n)||(0,f.isEmitter)(t.emitters,n)?t[n]:((0,f.isDispose)(n)&&(o="dispose"),function(){return e.isStarted&&(0,c.operatorLogger)(o,"log",r,n),t[n].apply(t,arguments)})},set:function(t,e,n){return t[e]&&console.warn("Operator redefined: "+r+"."+e),t[e]=n,!0}};return new Proxy(t,n)}function o(t){var e=this,r={apply:function(r,n,o){var i=a(o,2),u=i[0],f=i[1];return r.call(n,u,function(){for(var r=arguments.length,n=Array(r),o=0;r>o;o++)n[o]=arguments[o];return function(r){var o=f.apply(void 0,n)(r);return e.isStarted&&(0,c.emitterLogger)(t.streamName,u,r,o),o}})}};return new Proxy(t.emitter,r)}Object.defineProperty(e,"__esModule",{value:!0}),e.clean=void 0;var i=Object.assign||function(t){for(var e=1;arguments.length>e;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t},u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a=function(){function t(t,e){var r=[],n=!0,o=!1,i=void 0;try{for(var u,a=t[Symbol.iterator]();!(n=(u=a.next()).done)&&(r.push(u.value),!e||r.length!==e);n=!0);}catch(t){o=!0,i=t}finally{try{!n&&a.return&&a.return()}finally{if(o)throw i}}return r}return function(e,r){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return t(e,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),c=(r(6),r(16)),f=r(17),s=(e.clean=function(){window.rxactDebugger=void 0},function(t,e){return!0===t||Array.isArray(t)&&t.find(function(t){return t===e})}),l={start:!1};e.default=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if("object"!==(void 0===t?"undefined":u(t))||Array.isArray(t))throw Error("rxact-debugger: Expect options to be an object.");return function(e){var r=i({},l,t),u=r.start,a=s(u,e.streamName),c={isStarted:!1},f=n.call(c,e);return e.emitter=o.call(c,e),window.rxactDebugger||(window.rxactDebugger={}),window.rxactDebugger[e.streamName]=f,a&&f.debugger.start(),f}}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=r(1),o=r(15),i=r(2),u=r(0);r.d(e,"StateStream",function(){return n.a}),r.d(e,"setup",function(){return o.a}),r.d(e,"teardown",function(){return o.b}),r.d(e,"getObservable",function(){return i.b}),r.d(e,"isObservable",function(){return u.a})},function(t,e,r){t.exports=r(8)},function(t,e,r){"use strict";(function(t,n){Object.defineProperty(e,"__esModule",{value:!0});var o,i=r(11),u=function(t){return t&&t.__esModule?t:{default:t}}(i);o="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==t?t:n;var a=(0,u.default)(o);e.default=a}).call(e,r(9),r(10)(t))},function(t,e){var r;r=function(){return this}();try{r=r||Function("return this")()||(0,eval)("this")}catch(t){"object"==typeof window&&(r=window)}t.exports=r},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e,r){"use strict";function n(t){var e,r=t.Symbol;return"function"==typeof r?r.observable?e=r.observable:(e=r("observable"),r.observable=e):e="@@observable",e}Object.defineProperty(e,"__esModule",{value:!0}),e.default=n},function(t,e,r){"use strict";function n(t){var e=this,r=!1,n=t;this.observers=[],this.getState=function(){return n},this.next=function(t){if(!r){if("function"!=typeof t)throw Error("Expected passing a function to emitState.");var o=t(n);n=o,e.observers.forEach(function(t){t.next(o)})}};var i=new this.Observable(function(t){return e.observers.push(t),t.next(n),{unsubscribe:function(){e.observers=e.observers.filter(function(e){return e!==t})}}});return this.subscriptions.push({unsubscribe:function(){r=!0,e.next=o,e.observers.forEach(function(t){t.complete()}),e.observers=[]}}),i}var o=function(){console.warn("You are calling function on a disposed StateStream.")};e.a=n},function(t,e,r){"use strict";function n(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function o(t){if(Array.isArray(t)){for(var e=0,r=Array(t.length);t.length>e;e++)r[e]=t[e];return r}return Array.from(t)}function i(t,e,r){var i=this;if(!r||0===r.length)return t;var f={},s=[].concat(o(r),[{streamName:e,state$:t}]);if(s.forEach(function(t){if(!(t instanceof u.a||Object(a.a)(t.state$)&&t.streamName))throw Error("Expected the element of stateStreams to be instance of StateStream.");f[t.streamName]=!0}),Object.keys(f).length!==s.length)throw Error("StateStreams' name should be unique.");return new this.Observable(function(t){var e={},r=s.map(function(r){return r.state$.subscribe(function(o){var i=r.streamName,u=c({},e,n({},i,o));e=u,Object.keys(e).length===s.length&&t.next(e)})});return i.subscriptions=i.subscriptions.concat(r),{unsubscribe:function(){r.forEach(function(t){t.unsubscribe()})}}})}var u=r(1),a=r(0),c=Object.assign||function(t){for(var e=1;arguments.length>e;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t};e.a=i},function(t,e,r){"use strict";var n=r(0),o=function(t){return t},i=function(t,e,r){return void 0===t?e.of(r()):Object(n.a)(t)?t:e.of(t)};e.a=function(t,e){return function(r,u){var a=i(u,t,e);if(null!==r&&void 0!==r||(r=o),"function"!=typeof r)throw Error("Expected first parameter of eventRunner to be a function.");var c=r(a);if(!c||!Object(n.a)(c))throw Error("Expected an Observable object returned by factory in eventRunner");var f=void 0,s=void 0,l=void 0,p=new t(function(t){return void 0!==f&&t.next(f),s=function(e){return t.next(e)},{unsubscribe:function(){l.unsubscribe()}}});return l=c.subscribe(function(t){"function"==typeof s&&s(t),f=t}),p}}},function(t,e,r){"use strict";function n(t){if(Array.isArray(t)){for(var e=0,r=Array(t.length);t.length>e;e++)r[e]=t[e];return r}return Array.from(t)}r.d(e,"a",function(){return f}),r.d(e,"b",function(){return s});var o=r(1),i=r(2),u=r(0),a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},c=o.a,f=function(t){var e;if("object"!==(void 0===t?"undefined":a(t)))throw Error("setup(): Expected options to be an object.");var r=t.Observable,f=t.plugins,s=void 0===f?[]:f,l=t.HOStateStream,p=void 0===l?o.a:l;if(!Object(u.a)(r))throw Error("setup(): Expected an ES Observable. For more info: https://github.com/tc39/proposal-observable");if(Object(i.c)(r),!Array.isArray(s))throw Error("setup(): Expected plugins to be an array");c=p,(e=c).addPlugin.apply(e,n(s))},s=function(){Object(i.a)(),c.removePlugin()}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n="font-weight:bold;",o=function(t){return"color:"+t+";"},i=function(t){return t.toJS?t.toJS():t},u=e.operatorLogger=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"log",r=arguments[2],i=arguments[3],u="",a="",c="";switch(t){case"emitter":u="STATE ",a="updated",c="#3dbd7d";break;case"dispose":u="DISPOSE ",a="disposed",c="#f04134";break;default:u="OPERATOR",a="called ",c="#948aec"}console[e]("%c"+u+" %c "+a+" %c"+r+"->"+i,n+o(c),n+o("#108ee9"),"text-decoration:underline;"+n+o("#5a5a5a"))},a=function(t,e,r){console.log("%c"+e,o(t)+n,r)};e.emitterLogger=function(t,e,r,n){u("emitter","groupCollapsed",t,e),a("#5a5a5a","prevState:",i(r)),a("#ffce3d","nextState:",i(n)),console.groupEnd()}},function(t,e,r){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=e.METHOD_BLACK_LIST=["constructor","next","eventRunner","getState","emitter"];e.isOperator=function(t,e){return"function"==typeof t[e]&&!n.find(function(t){return t===e})},e.isEmitter=function(t,e){return!!t[e]},e.isDispose=function(t){return"dispose"===t},e.isDebugger=function(t){return"debugger"===t},e.isPresent=function(t,e){return!!t[e]}}])});