This repository has been archived by the owner on Jun 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
VueInBrowserLoader.js
1 lines (1 loc) · 2.25 KB
/
VueInBrowserLoader.js
1
(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):a.VueInBrowserLoader=b()})(this,function(){"use strict";function a(a,b,c){var d=document.createElement(a);return d.innerHTML=b,Object.assign(d,c),d}function b(a,b,c){void 0===b&&(b=null),void 0===c&&(c={});var d=Object.values(c),e=Object.keys(c);return new(Function.prototype.bind.apply(Function,[null].concat(e,[a])))().apply(b,d)}function c(a,b){return Object.prototype.hasOwnProperty.call(a,b)}function d(a,b){for(var c=[],d=arguments.length-2;0<d--;)c[d]=arguments[d+2];return c.forEach(function(c){c.startsWith(a)&&(c=c.slice(a.length)),b.endsWith(a)||(b+=a),b+=c}),b}function e(){for(var a=[],b=arguments.length;b--;)a[b]=arguments[b];return d.apply(void 0,["/"].concat(a))}function f(b){return a("a",null,{href:b}).href}function g(a,b){return a.startsWith("/")?a:e(b,"..",a)}function h(a){return new Promise(function(b,c){var d=new XMLHttpRequest;d.open("GET",a),d.onreadystatechange=function(){4===d.readyState&&(200<=d.status&&300>d.status?b(d.responseText):c(d.status))},d.send(null)})}function i(a,b){return a.hasAttribute("src")?h(g(a.getAttribute("src"),b)):Promise.resolve(a.innerHTML)}function j(b){return h(b).then(function(c){var d=Array.from(a("div",c).children),e=[],f=[],g=[];d.forEach(function(a){switch(a.tagName){case"TEMPLATE":e.push(a);break;case"SCRIPT":f.push(a);break;case"STYLE":g.push(a);}});var h;if(0<e.length){var j=e.shift();h=i(j,b)}var k;if(0<f.length){var l=f.shift();k=i(l,b)}var m=[],n=[];return g.forEach(function(a){a.hasAttribute("scoped")?n.push(i(a,b)):m.push(i(a,b))}),Promise.all([h,k,Promise.all(m),Promise.all(n)])})}function k(a){return f(a.endsWith(".vue")?a:e(a,"index.vue"))}var l={},m=function(d){return d=k(d),function(){return c(l,d)?l[d]:l[d]=j(d).then(function(c){var h=c[0],i=c[1],j=c[2],k={};if(i){var l={},n={exports:l};b(i,l,{module:n,exports:l,__filename:d,__dirname:f(e(d,"..")),VueInBrowserLoader:function(a){for(var b=[],c=arguments.length-1;0<c--;)b[c]=arguments[c+1];return m.apply(void 0,[g(a,d)].concat(b))},require:function(a){return window[a]}}),Object.assign(k,n.exports)}return h&&Object.assign(k,{template:h}),j.forEach(function(b){document.head.appendChild(a("style",b))}),k})}};return m});