forked from systemjs/systemjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodule-types.min.js
1 lines (1 loc) · 1.37 KB
/
module-types.min.js
1
!function(t){const e=t.System.constructor.prototype,n=e.instantiate;e.instantiate=function(t,e){const r=this;switch(t.slice(t.lastIndexOf("."))){case".css":return o(function(t,e){const n=new CSSStyleSheet;n.replaceSync(e),t("default",n)});case".html":return s().then(function(t){return u(t)||c("'.html' modules not implemented")});case".json":return o(function(t,e){t("default",JSON.parse(e))});case".wasm":return s().then(function(t){return u(t)||(WebAssembly.compileStreaming?WebAssembly.compileStreaming(t):t.arrayBuffer().then(WebAssembly.compile))}).then(function(t){const e=[],n=[],r={};return WebAssembly.Module.imports&&WebAssembly.Module.imports(t).forEach(function(t){const s=t.module;-1===e.indexOf(s)&&(e.push(s),n.push(function(t){r[s]=t}))}),[e,function(e){return{setters:n,execute:function(){return WebAssembly.instantiate(t,r).then(function(t){e(t.exports)})}}}]})}return n.apply(this,arguments);function s(){return fetch(t).then(function(t){return t.ok||c(t.status+" "+t.statusText),t})}function u(t){const e=t.headers.get("content-type");if(e&&e.match(/^application\/javascript(;|$)/))return t.text().then(function(t){return(0,eval)(t),r.getRegister()})}function o(t){return s().then(function(e){return u(e)||e.text().then(function(e){return[[],function(n){return{execute:t(n,e)}}]})})}function c(n){throw Error(n+", loading "+t+(e?" from "+e:""))}}}("undefined"!=typeof self?self:global);