guess-webpack
Version:
Webpack plugins for the Machine Learning-driven bundler
1 lines • 3.9 kB
JavaScript
!function(t,e){for(var n in e)t[n]=e[n]}(exports,function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(1),o=function(t){if("undefined"==typeof document)return!1;var e=document.createElement("link");try{if(e.relList&&"function"==typeof e.relList.supports)return e.relList.supports(t)}catch(t){return!1}}("prefetch")?function(t){if("undefined"!=typeof document){var e=document.createElement("link");e.setAttribute("rel","prefetch"),e.setAttribute("href",t),(document.getElementsByTagName("head")[0]||document.getElementsByName("script")[0].parentNode).appendChild(e)}}:function(t){return Promise.resolve().then((function(){return n(2)(t)}))},i={},u=function(t,e){var n=r.guess({path:e});Object.keys(n).forEach((function(e){var r=n[e].chunk;r&&function(t,e){i[e=t+e]||(i[e]=!0,o(e))}(t,r)}))};e.initialize=function(t,e,n,o,i,c){if(r.initialize(t,c,n,o),"Window"===t.constructor.name&&t.location){"function"==typeof t.addEventListener&&t.addEventListener("popstate",(function(t){return u(i,location.pathname)}));var a=e.pushState;e.pushState=function(t){return"function"==typeof e.onpushstate&&e.onpushstate({state:t}),u(i,arguments[2]),a.apply(e,arguments)},u(i,location.pathname)}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(t,e){this._node=t,this._map=e}return Object.defineProperty(t.prototype,"probability",{get:function(){return this._node[0]},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"route",{get:function(){return this._map.routes[this._node[1]]},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"chunk",{get:function(){return this._map.chunks[this._node[2]]},enumerable:!0,configurable:!0}),t}(),o=function(){function t(t,e){this._graph=t,this._map=e}return t.prototype.findMatch=function(t){var e=this,n=this._graph.filter((function(n,r){return function(t,e){var n=t.split("/"),r=e.split("/");return n.length>0&&""===n[n.length-1]&&n.pop(),r.length>0&&""===r[r.length-1]&&r.pop(),n.length===r.length&&r.reduce((function(t,e,r){return":"===e[0]?t:t&&e===n[r]}),!0)}(e._map.routes[r],t)})).pop();return n?n.map((function(t){return new r(t,e._map)})):[]},t}();e.guess=function(t){throw new Error("Guess is not initialized")},e.initialize=function(t,n,r,i){var u=new o(r,i);t.__GUESS__=t.__GUESS__||{},t.__GUESS__.guess=e.guess=function(e){return(e=e||{}).path||(e.path=(t.location||{pathname:""}).pathname),e.connection||(e.connection=t.navigator&&t.navigator&&t.navigator.connection&&t.navigator.connection.effectiveType||"3g"),e.thresholds||(e.thresholds=n),function(t,e){return t.findMatch(e.path).reduce((function(t,n){if(n.probability>=e.thresholds[e.connection]){var r={probability:n.probability};n.chunk&&(r.chunk=n.chunk),t[n.route]=r}return t}),{})}(u,e)}}},function(t,e){function n(t){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}n.keys=function(){return[]},n.resolve=n,t.exports=n,n.id=2}]));