vconsole-stat-plugin.min.js 9.3 KB

123456
  1. /*!
  2. * vconsole-stats-plugin v0.0.4 (https://github.com/smackgg/vconsole-stats)
  3. * Copyright 2020, Smackgg <smackgg@gmail.com>
  4. * MIT license
  5. */
  6. !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("vconsole-stats-plugin",[],t):"object"==typeof exports?exports["vconsole-stats-plugin"]=t():e["vconsole-stats-plugin"]=t()}(window,(function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t,n){var o;e.exports=((o=function(){function e(e){return r.appendChild(e.dom),e}function t(e){for(var t=0;t<r.children.length;t++)r.children[t].style.display=t===e?"block":"none";n=e}var n=0,r=document.createElement("div");r.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",r.addEventListener("click",(function(e){e.preventDefault(),t(++n%r.children.length)}),!1);var a=(performance||Date).now(),i=a,s=0,l=e(new o.Panel("FPS","#0ff","#002")),c=e(new o.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var u=e(new o.Panel("MB","#f08","#201"));return t(0),{REVISION:16,dom:r,addPanel:e,showPanel:t,begin:function(){a=(performance||Date).now()},end:function(){s++;var e=(performance||Date).now();if(c.update(e-a,200),e>i+1e3&&(l.update(1e3*s/(e-i),100),i=e,s=0,u)){var t=performance.memory;u.update(t.usedJSHeapSize/1048576,t.jsHeapSizeLimit/1048576)}return e},update:function(){a=this.end()},domElement:r,setMode:t}}).Panel=function(e,t,n){var o=1/0,r=0,a=Math.round,i=a(window.devicePixelRatio||1),s=80*i,l=48*i,c=3*i,u=2*i,f=3*i,d=15*i,p=74*i,h=30*i,v=document.createElement("canvas");v.width=s,v.height=l,v.style.cssText="width:80px;height:48px";var m=v.getContext("2d");return m.font="bold "+9*i+"px Helvetica,Arial,sans-serif",m.textBaseline="top",m.fillStyle=n,m.fillRect(0,0,s,l),m.fillStyle=t,m.fillText(e,c,u),m.fillRect(f,d,p,h),m.fillStyle=n,m.globalAlpha=.9,m.fillRect(f,d,p,h),{dom:v,update:function(l,b){o=Math.min(o,l),r=Math.max(r,l),m.fillStyle=n,m.globalAlpha=1,m.fillRect(0,0,s,d),m.fillStyle=t,m.fillText(a(l)+" "+e+" ("+a(o)+"-"+a(r)+")",c,u),m.drawImage(v,f+i,d,p-i,h,f,d,p-i,h),m.fillRect(f+p-i,d,i,h),m.fillStyle=n,m.globalAlpha=.9,m.fillRect(f+p-i,d,i,a((1-l/b)*h))}}},o)},function(e,t,n){"use strict";n.r(t);n(2);var o=n(0),r=n.n(o);function a(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}var i=function(){function e(t){var n=this;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.show=function(){n.stats||(n.stats=new r.a,n.stats.showPanel(1),n.dom=n.stats.dom,document.body.appendChild(n.dom),n.requestID=requestAnimationFrame(n.loop))},this.changePanel=function(e){n.stats||n.show(),n.stats.setMode(Number(e))},this.loop=function(){n.stats.update(),n.requestID=requestAnimationFrame(n.loop)},this.close=function(){n.requestID&&cancelAnimationFrame(n.requestID),n.dom&&document.body.removeChild(n.dom),n.stats=null,n.requestID=null,n.dom=null},this.vConsole=t,this.$=t.$,this.dom=null,this.requestID=null,this.stats=null,this.init()}var t,n,o;return t=e,(n=[{key:"init",value:function(){var e=this,t=new window.VConsole.VConsolePlugin("Stats","Stats");return t.on("ready",(function(){var t=e.$;t.delegate(t.one(".vc-stats-buttons"),"click",".vc-stats-button",(function(t){var n=t.target.dataset.type;e.changePanel(n)}))})),t.on("renderTab",(function(e){e('<div class="vc-stats-buttons">\n <p>\n <button class="vc-stats-button" data-type="0">show FPS</button>\n <span>: Frames rendered in the last second. The higher the number the better.</span>\n </p>\n <p>\n <button class="vc-stats-button" data-type="1">show MS</button>\n <span>: Milliseconds needed to render a frame. The lower the number the better..</span>\n </p>\n <p>\n <button class="vc-stats-button" data-type="2">show MB</button>\n <span>: MB MBytes of allocated memory. (Run Chrome with --enable-precise-memory-info).</span>\n </p>\n </div>')})),t.on("addTool",(function(t){t([{name:"Show Stats",onClick:e.show},{name:"Close Stats",onClick:e.close}])})),this.vConsole.addPlugin(t),t}}])&&a(t.prototype,n),o&&a(t,o),e}();window.VConsoleStatsPlugin=i,t.default=i},function(e,t,n){var o=n(3);"string"==typeof o&&(o=[[e.i,o,""]]);n(5)(o,{});o.locals&&(e.exports=o.locals)},function(e,t,n){(t=n(4)(!1)).push([e.i,".vc-stats-button {\n margin: 10px 10px;\n background-color: #fbf9fe;\n padding: 2px 4px;\n}\n",""]),e.exports=t},function(e,t,n){"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var n=function(e,t){var n=e[1]||"",o=e[3];if(!o)return n;if(t&&"function"==typeof btoa){var r=(i=o,s=btoa(unescape(encodeURIComponent(JSON.stringify(i)))),l="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(s),"/*# ".concat(l," */")),a=o.sources.map((function(e){return"/*# sourceURL=".concat(o.sourceRoot||"").concat(e," */")}));return[n].concat(a).concat([r]).join("\n")}var i,s,l;return[n].join("\n")}(t,e);return t[2]?"@media ".concat(t[2]," {").concat(n,"}"):n})).join("")},t.i=function(e,n,o){"string"==typeof e&&(e=[[null,e,""]]);var r={};if(o)for(var a=0;a<this.length;a++){var i=this[a][0];null!=i&&(r[i]=!0)}for(var s=0;s<e.length;s++){var l=[].concat(e[s]);o&&r[l[0]]||(n&&(l[2]?l[2]="".concat(n," and ").concat(l[2]):l[2]=n),t.push(l))}},t}},function(e,t){var n={},o=function(e){var t;return function(){return void 0===t&&(t=e.apply(this,arguments)),t}},r=o((function(){return/msie [6-9]\b/.test(self.navigator.userAgent.toLowerCase())})),a=o((function(){return document.head||document.getElementsByTagName("head")[0]})),i=null,s=0,l=[];function c(e,t){for(var o=0;o<e.length;o++){var r=e[o],a=n[r.id];if(a){a.refs++;for(var i=0;i<a.parts.length;i++)a.parts[i](r.parts[i]);for(;i<r.parts.length;i++)a.parts.push(h(r.parts[i],t))}else{var s=[];for(i=0;i<r.parts.length;i++)s.push(h(r.parts[i],t));n[r.id]={id:r.id,refs:1,parts:s}}}}function u(e){for(var t=[],n={},o=0;o<e.length;o++){var r=e[o],a=r[0],i={css:r[1],media:r[2],sourceMap:r[3]};n[a]?n[a].parts.push(i):t.push(n[a]={id:a,parts:[i]})}return t}function f(e,t){var n=a(),o=l[l.length-1];if("top"===e.insertAt)o?o.nextSibling?n.insertBefore(t,o.nextSibling):n.appendChild(t):n.insertBefore(t,n.firstChild),l.push(t);else{if("bottom"!==e.insertAt)throw new Error("Invalid value for parameter 'insertAt'. Must be 'top' or 'bottom'.");n.appendChild(t)}}function d(e){e.parentNode.removeChild(e);var t=l.indexOf(e);t>=0&&l.splice(t,1)}function p(e){var t=document.createElement("style");return t.type="text/css",f(e,t),t}function h(e,t){var n,o,r;if(t.singleton){var a=s++;n=i||(i=p(t)),o=b.bind(null,n,a,!1),r=b.bind(null,n,a,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=function(e){var t=document.createElement("link");return t.rel="stylesheet",f(e,t),t}(t),o=g.bind(null,n),r=function(){d(n),n.href&&URL.revokeObjectURL(n.href)}):(n=p(t),o=y.bind(null,n),r=function(){d(n)});return o(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;o(e=t)}else r()}}e.exports=function(e,t){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");void 0===(t=t||{}).singleton&&(t.singleton=r()),void 0===t.insertAt&&(t.insertAt="bottom");var o=u(e);return c(o,t),function(e){for(var r=[],a=0;a<o.length;a++){var i=o[a];(s=n[i.id]).refs--,r.push(s)}e&&c(u(e),t);for(a=0;a<r.length;a++){var s;if(0===(s=r[a]).refs){for(var l=0;l<s.parts.length;l++)s.parts[l]();delete n[s.id]}}}};var v,m=(v=[],function(e,t){return v[e]=t,v.filter(Boolean).join("\n")});function b(e,t,n,o){var r=n?"":o.css;if(e.styleSheet)e.styleSheet.cssText=m(t,r);else{var a=document.createTextNode(r),i=e.childNodes;i[t]&&e.removeChild(i[t]),i.length?e.insertBefore(a,i[t]):e.appendChild(a)}}function y(e,t){var n=t.css,o=t.media;if(o&&e.setAttribute("media",o),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}function g(e,t){var n=t.css,o=t.sourceMap;o&&(n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */");var r=new Blob([n],{type:"text/css"}),a=e.href;e.href=URL.createObjectURL(r),a&&URL.revokeObjectURL(a)}}])}));