UNPKG

10.7 kBJavaScriptView Raw
1!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.reduxLogger=t():e.reduxLogger=t()}(this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){r(2),e.exports=r(2)},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=t.repeat=function(e,t){return new Array(t+1).join(e)},n=t.pad=function(e,t){return r("0",t-e.toString().length)+e};t.formatTime=function(e){return n(e.getHours(),2)+":"+n(e.getMinutes(),2)+":"+n(e.getSeconds(),2)+"."+n(e.getMilliseconds(),3)},t.timer="undefined"!=typeof performance&&null!==performance&&"function"==typeof performance.now?performance:Date},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=a({},c.default,e),r=t.logger,n=t.transformer,o=t.stateTransformer,f=t.errorTransformer,l=t.predicate,s=t.logErrors,p=t.diffPredicate;if("undefined"==typeof r)return function(){return function(e){return function(t){return e(t)}}};if(n&&console.error("Option 'transformer' is deprecated, use 'stateTransformer' instead!"),e.getState&&e.dispatch)return console.error("redux-logger not installed. Make sure to pass logger instance as middleware:\n\nimport createLogger from 'redux-logger';\n\nconst logger = createLogger();\nconst store = createStore(\n reducer,\n applyMiddleware(logger)\n);"),function(){return function(e){return function(t){return e(t)}}};var d=[];return function(e){var r=e.getState;return function(e){return function(n){if("function"==typeof l&&!l(r,n))return e(n);var c={};d.push(c),c.started=u.timer.now(),c.startedTime=new Date,c.prevState=o(r()),c.action=n;var h=void 0;if(s)try{h=e(n)}catch(e){c.error=f(e)}else h=e(n);c.took=u.timer.now()-c.started,c.nextState=o(r());var g=t.diff&&"function"==typeof p?p(r,n):t.diff;if((0,i.printBuffer)(d,a({},t,{diff:g})),d.length=0,c.error)throw c.error;return h}}}}Object.defineProperty(t,"__esModule",{value:!0});var a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},i=r(3),u=r(1),f=r(4),c=n(f);t.default=o,e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)}function a(e,t,r,n){switch("undefined"==typeof e?"undefined":f(e)){case"object":return"function"==typeof e[n]?e[n].apply(e,o(r)):e[n];case"function":return e(t);default:return e}}function i(e){var t=e.timestamp,r=e.duration;return function(e,n,o){var a=["action"];return t&&a.push("@ "+n),a.push(String(e.type)),r&&a.push("(in "+o.toFixed(2)+" ms)"),a.join(" ")}}function u(e,t){var r=t.logger,n=t.actionTransformer,o=t.titleFormatter,u=void 0===o?i(t):o,f=t.collapsed,l=t.colors,p=t.level,d=t.diff;e.forEach(function(t,o){var i=t.started,h=t.startedTime,g=t.action,y=t.prevState,v=t.error,b=t.took,m=t.nextState,x=e[o+1];x&&(m=x.prevState,b=x.started-i);var j=n(g),w="function"==typeof f?f(function(){return m},g,t):f,k=(0,c.formatTime)(h),S=l.title?"color: "+l.title(j)+";":null,A=u(j,k,b);try{w?l.title?r.groupCollapsed("%c "+A,S):r.groupCollapsed(A):l.title?r.group("%c "+A,S):r.group(A)}catch(e){r.log(A)}var D=a(p,j,[y],"prevState"),E=a(p,j,[j],"action"),O=a(p,j,[v,y],"error"),_=a(p,j,[m],"nextState");D&&(l.prevState?r[D]("%c prev state","color: "+l.prevState(y)+"; font-weight: bold",y):r[D]("prev state",y)),E&&(l.action?r[E]("%c action","color: "+l.action(j)+"; font-weight: bold",j):r[E]("action",j)),v&&O&&(l.error?r[O]("%c error","color: "+l.error(v,y)+"; font-weight: bold",v):r[O]("error",v)),_&&(l.nextState?r[_]("%c next state","color: "+l.nextState(m)+"; font-weight: bold",m):r[_]("next state",m)),d&&(0,s.default)(y,m,r,w);try{r.groupEnd()}catch(e){r.log("—— log end ——")}})}Object.defineProperty(t,"__esModule",{value:!0});var f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.printBuffer=u;var c=r(1),l=r(5),s=n(l)},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={level:"log",logger:console,logErrors:!0,collapsed:void 0,predicate:void 0,duration:!1,timestamp:!0,stateTransformer:function(e){return e},actionTransformer:function(e){return e},errorTransformer:function(e){return e},colors:{title:function(){return"inherit"},prevState:function(){return"#9E9E9E"},action:function(){return"#03A9F4"},nextState:function(){return"#4CAF50"},error:function(){return"#F20404"}},diff:!1,diffPredicate:void 0,transformer:void 0},e.exports=t.default},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function o(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)}function a(e){return"color: "+l[e].color+"; font-weight: bold"}function i(e){var t=e.kind,r=e.path,n=e.lhs,o=e.rhs,a=e.index,i=e.item;switch(t){case"E":return[r.join("."),n,"→",o];case"N":return[r.join("."),o];case"D":return[r.join(".")];case"A":return[r.join(".")+"["+a+"]",i];default:return[]}}function u(e,t,r,n){var u=(0,c.default)(e,t);try{n?r.groupCollapsed("diff"):r.group("diff")}catch(e){r.log("diff")}u?u.forEach(function(e){var t=e.kind,n=i(e);r.log.apply(r,["%c "+l[t].text,a(t)].concat(o(n)))}):r.log("—— no diff ——");try{r.groupEnd()}catch(e){r.log("—— diff end —— ")}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=u;var f=r(6),c=n(f),l={E:{color:"#2196F3",text:"CHANGED:"},N:{color:"#4CAF50",text:"ADDED:"},D:{color:"#F44336",text:"DELETED:"},A:{color:"#2196F3",text:"ARRAY:"}};e.exports=t.default},function(e,t,r){var n,o;(function(r){!function(r,a){"use strict";n=[],o=function(){return a()}.apply(t,n),!(void 0!==o&&(e.exports=o))}(this,function(e){"use strict";function t(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}function n(e,t){Object.defineProperty(this,"kind",{value:e,enumerable:!0}),t&&t.length&&Object.defineProperty(this,"path",{value:t,enumerable:!0})}function o(e,t,r){o.super_.call(this,"E",e),Object.defineProperty(this,"lhs",{value:t,enumerable:!0}),Object.defineProperty(this,"rhs",{value:r,enumerable:!0})}function a(e,t){a.super_.call(this,"N",e),Object.defineProperty(this,"rhs",{value:t,enumerable:!0})}function i(e,t){i.super_.call(this,"D",e),Object.defineProperty(this,"lhs",{value:t,enumerable:!0})}function u(e,t,r){u.super_.call(this,"A",e),Object.defineProperty(this,"index",{value:t,enumerable:!0}),Object.defineProperty(this,"item",{value:r,enumerable:!0})}function f(e,t,r){var n=e.slice((r||t)+1||e.length);return e.length=t<0?e.length+t:t,e.push.apply(e,n),e}function c(e){var t=typeof e;return"object"!==t?t:e===Math?"math":null===e?"null":Array.isArray(e)?"array":"[object Date]"===Object.prototype.toString.call(e)?"date":"undefined"!=typeof e.toString&&/^\/.*\//.test(e.toString())?"regexp":"object"}function l(t,r,n,s,p,d,h){p=p||[];var g=p.slice(0);if("undefined"!=typeof d){if(s){if("function"==typeof s&&s(g,d))return;if("object"==typeof s){if(s.prefilter&&s.prefilter(g,d))return;if(s.normalize){var y=s.normalize(g,d,t,r);y&&(t=y[0],r=y[1])}}}g.push(d)}"regexp"===c(t)&&"regexp"===c(r)&&(t=t.toString(),r=r.toString());var v=typeof t,b=typeof r;if("undefined"===v)"undefined"!==b&&n(new a(g,r));else if("undefined"===b)n(new i(g,t));else if(c(t)!==c(r))n(new o(g,t,r));else if("[object Date]"===Object.prototype.toString.call(t)&&"[object Date]"===Object.prototype.toString.call(r)&&t-r!==0)n(new o(g,t,r));else if("object"===v&&null!==t&&null!==r){if(h=h||[],h.indexOf(t)<0){if(h.push(t),Array.isArray(t)){var m;t.length;for(m=0;m<t.length;m++)m>=r.length?n(new u(g,m,new i(e,t[m]))):l(t[m],r[m],n,s,g,m,h);for(;m<r.length;)n(new u(g,m,new a(e,r[m++])))}else{var x=Object.keys(t),j=Object.keys(r);x.forEach(function(o,a){var i=j.indexOf(o);i>=0?(l(t[o],r[o],n,s,g,o,h),j=f(j,i)):l(t[o],e,n,s,g,o,h)}),j.forEach(function(t){l(e,r[t],n,s,g,t,h)})}h.length=h.length-1}}else t!==r&&("number"===v&&isNaN(t)&&isNaN(r)||n(new o(g,t,r)))}function s(t,r,n,o){return o=o||[],l(t,r,function(e){e&&o.push(e)},n),o.length?o:e}function p(e,t,r){if(r.path&&r.path.length){var n,o=e[t],a=r.path.length-1;for(n=0;n<a;n++)o=o[r.path[n]];switch(r.kind){case"A":p(o[r.path[n]],r.index,r.item);break;case"D":delete o[r.path[n]];break;case"E":case"N":o[r.path[n]]=r.rhs}}else switch(r.kind){case"A":p(e[t],r.index,r.item);break;case"D":e=f(e,t);break;case"E":case"N":e[t]=r.rhs}return e}function d(e,t,r){if(e&&t&&r&&r.kind){for(var n=e,o=-1,a=r.path?r.path.length-1:0;++o<a;)"undefined"==typeof n[r.path[o]]&&(n[r.path[o]]="number"==typeof r.path[o]?[]:{}),n=n[r.path[o]];switch(r.kind){case"A":p(r.path?n[r.path[o]]:n,r.index,r.item);break;case"D":delete n[r.path[o]];break;case"E":case"N":n[r.path[o]]=r.rhs}}}function h(e,t,r){if(r.path&&r.path.length){var n,o=e[t],a=r.path.length-1;for(n=0;n<a;n++)o=o[r.path[n]];switch(r.kind){case"A":h(o[r.path[n]],r.index,r.item);break;case"D":o[r.path[n]]=r.lhs;break;case"E":o[r.path[n]]=r.lhs;break;case"N":delete o[r.path[n]]}}else switch(r.kind){case"A":h(e[t],r.index,r.item);break;case"D":e[t]=r.lhs;break;case"E":e[t]=r.lhs;break;case"N":e=f(e,t)}return e}function g(e,t,r){if(e&&t&&r&&r.kind){var n,o,a=e;for(o=r.path.length-1,n=0;n<o;n++)"undefined"==typeof a[r.path[n]]&&(a[r.path[n]]={}),a=a[r.path[n]];switch(r.kind){case"A":h(a[r.path[n]],r.index,r.item);break;case"D":a[r.path[n]]=r.lhs;break;case"E":a[r.path[n]]=r.lhs;break;case"N":delete a[r.path[n]]}}}function y(e,t,r){if(e&&t){var n=function(n){r&&!r(e,t,n)||d(e,t,n)};l(e,t,n)}}var v,b,m=[];return v="object"==typeof r&&r?r:"undefined"!=typeof window?window:{},b=v.DeepDiff,b&&m.push(function(){"undefined"!=typeof b&&v.DeepDiff===s&&(v.DeepDiff=b,b=e)}),t(o,n),t(a,n),t(i,n),t(u,n),Object.defineProperties(s,{diff:{value:s,enumerable:!0},observableDiff:{value:l,enumerable:!0},applyDiff:{value:y,enumerable:!0},applyChange:{value:d,enumerable:!0},revertChange:{value:g,enumerable:!0},isConflict:{value:function(){return"undefined"!=typeof b},enumerable:!0},noConflict:{value:function(){return m&&(m.forEach(function(e){e()}),m=null),s},enumerable:!0}}),s})}).call(t,function(){return this}())}])});
\No newline at end of file