4 lines
6.8 KiB
JavaScript
4 lines
6.8 KiB
JavaScript
/*
|
|
* SystemJS 2.0.0
|
|
*/
|
|
!function(){const t="undefined"!=typeof self,n=t?self:global;let e;if("undefined"!=typeof location){const t=(e=location.href.split("#")[0].split("?")[0]).lastIndexOf("/");-1!==t&&(e=e.slice(0,t+1))}const o=/\\/g;function r(t,n){if(-1!==t.indexOf("\\")&&(t=t.replace(o,"/")),"/"===t[0]&&"/"===t[1])return n.slice(0,n.indexOf(":")+1)+t;if("."===t[0]&&("/"===t[1]||"."===t[1]&&("/"===t[2]||2===t.length&&(t+="/"))||1===t.length&&(t+="/"))||"/"===t[0]){const e=n.slice(0,n.indexOf(":")+1);let o;if(o="/"===n[e.length+1]?"file:"!==e?(o=n.slice(e.length+2)).slice(o.indexOf("/")+1):n.slice(8):n.slice(e.length+1),"/"===t[0])return n.slice(0,n.length-o.length-1)+t;const r=o.slice(0,o.lastIndexOf("/")+1)+t,i=[];let c=-1;for(let t=0;t<r.length;t++)-1!==c?"/"===r[t]&&(i.push(r.slice(c,t+1)),c=-1):"."===r[t]?"."!==r[t+1]||"/"!==r[t+2]&&t+2!==r.length?"/"===r[t+1]||t+1===r.length?t+=1:c=t:(i.pop(),t+=2):c=t;return-1!==c&&i.push(r.slice(c)),n.slice(0,n.length-o.length)+i.join("")}}function i(t,n){return r(t,n)||-1!==t.indexOf(":")&&t||r("./"+t,n)}function c(t,n){t.path_prefix&&"/"!==(n=i(t.path_prefix,n))[n.length-1]&&(n+="/");const e=t.packages||{},o={};if(t.scopes)for(let e in t.scopes){const r=t.scopes[e];if(r.path_prefix)throw new Error("Scope path_prefix not currently supported");if(r.scopes)throw new Error("Nested scopes not currently supported");let c=i(e,n);"/"===c[c.length-1]&&(c=c.substr(0,c.length-1)),o[c]=r.packages||{}}function r(t,n){let e=t.length;do{const o=t.slice(0,e);if(o in n)return o}while(-1!==(e=t.lastIndexOf("/",e-1)))}function c(t,n,e){const o=r(t,n);if(o){const r=n[o];if(o===t){if("string"==typeof r)return i(r,e+o+"/");if(!r.main)throw new Error("Package "+o+" has no main");return i((r.path?r.path+("/"===r.path[r.path.length-1]?"":"/"):o+"/")+r.main,e)}return i(("string"!=typeof r&&r.path?r.path+("/"===r.path[r.path.length-1]?"":"/"):o+"/")+t.slice(o.length+1),e)}}return function(t,i){const u=r(i,o);if(u){const n=c(t,o[u],u+"/");if(n)return n}return c(t,e,n)||s(t,i)}}function s(t,n){throw new Error('Unable to resolve bare specifier "'+t+(n?'" from '+n:'"'))}const u="undefined"!=typeof Symbol,l=u&&Symbol.toStringTag,f=u?Symbol():"@";function a(){this[f]={}}const h=a.prototype;let d;h.import=function(t,n){const e=this;return Promise.resolve(e.resolve(t,n)).then(function(t){const n=function t(n,e,o){let r=n[f][e];if(r)return r;const i=[],c=Object.create(null);l&&Object.defineProperty(c,l,{value:"Module"});let s=Promise.resolve().then(function(){return n.instantiate(e,o)}).then(function(t){if(!t)throw new Error("Module "+e+" did not instantiate");const o=t[1](function(t,n){r.h=!0;let e=!1;if("object"!=typeof t)t in c&&c[t]===n||(c[t]=n,e=!0);else for(let n in t){let o=t[n];n in c&&c[n]===o||(c[n]=o,e=!0)}if(e)for(let t=0;t<i.length;t++)i[t](c);return n},2===t[1].length?{import:function(t){return n.import(t,e)},meta:n.createContext(e)}:void 0);return r.e=o.execute||function(){},[t[0],o.setters||[]]});const u=(s=s.catch(function(t){throw n.onload(r.id,t),t})).then(function(o){return Promise.all(o[0].map(function(r,i){const c=o[1][i];return Promise.resolve(n.resolve(r,e)).then(function(o){const r=t(n,o,e);return Promise.resolve(r.I).then(function(){return c&&(r.i.push(c),!r.h&&r.I||c(r.n)),r})})})).then(function(t){r.d=t})});return u.catch(function(){}),r=n[f][e]={id:e,i:i,n:c,I:s,L:u,h:!1,d:void 0,e:void 0,eE:void 0,E:void 0,C:void 0}}(e,t);return n.C||function(t,n){return n.C=function t(n,e,o){if(!o[e.id])return o[e.id]=!0,Promise.resolve(e.L).then(function(){return Promise.all(e.d.map(function(e){return t(n,e,o)}))})}(t,n,{}).then(function(){return function t(n,e,o){if(o[e.id])return;if(o[e.id]=!0,!e.e){if(e.eE)throw e.eE;return e.E?e.E:void 0}let r;return e.d.forEach(function(i){try{const c=t(n,i,o);c&&(r=r||[]).push(c)}catch(t){throw n.onload(e.id,t),t}}),r?Promise.all(r).then(i).catch(function(t){throw n.onload(e.id,t),t}):i();function i(){try{let t=e.e.call(p);if(t)return(t=t.then(function(){e.C=e.n,e.E=null,n.onload(e.id,null)},function(){throw n.onload(e.id,err),err})).catch(function(){}),e.E=e.E||t;e.C=e.n,n.onload(e.id,null)}catch(t){throw n.onload(e.id,t),e.eE=t,t}finally{e.L=e.I=void 0,e.e=null}}}(t,n,{})}).then(function(){return n.n})}(e,n)})},h.createContext=function(t){return{url:t}},h.onload=function(){},h.register=function(t,n){d=[t,n]},h.getRegister=function(){const t=d;return d=void 0,t};const p=Object.freeze(Object.create(null));let g;n.System=new a,"undefined"!=typeof window&&window.addEventListener("error",function(t){g=t.error});const m=h.register;h.register=function(t,n){g=void 0,m.call(this,t,n)},h.instantiate=function(t,n){const e=this;return new Promise(function(o,r){const i=document.createElement("script");i.charset="utf-8",i.async=!0,i.addEventListener("error",function(){r(new Error("Error loading "+t+(n?" from "+n:"")))}),i.addEventListener("load",function(){if(document.head.removeChild(i),g)return r(g);o(e.getRegister())}),i.src=t,document.head.appendChild(i)})},t&&"function"==typeof importScripts&&(h.instantiate=function(t){const n=this;return new Promise(function(e,o){try{importScripts(t)}catch(t){o(t)}e(n.getRegister())})}),function(t){const n=System.constructor.prototype;function e(){let n;for(let e in t)t.hasOwnProperty(e)&&(n=e);return n}let o;const r=n.import;n.import=function(t,n){return o=e(),r.call(this,t,n)};const i=[[],function(){return{}}],c=n.getRegister;n.getRegister=function(){const n=c.call(this);if(n)return n;const r=e();if(o===r)return i;let s;o=r;try{s=t[r]}catch(t){return i}return[[],function(t){return{execute:function(){t("default",s)}}}]}}("undefined"!=typeof self?self:global);const y=h.instantiate;let w,v;if(h.instantiate=function(t,n){return".wasm"!==t.slice(-5)?y.call(this,t,n):fetch(t).then(function(t){if(!t.ok)throw new Error(t.status+" "+t.statusText+" "+t.url+(n?" loading from "+n:""));return WebAssembly.compileStreaming(t)}).then(function(t){const n=[],e=[],o={};return WebAssembly.Module.imports&&WebAssembly.Module.imports(t).forEach(function(t){const r=t.module;e.push(function(t){o[r]=t}),-1===n.indexOf(r)&&n.push(r)}),[n,function(n){return{setters:e,execute:function(){n(new WebAssembly.Instance(t,o).exports)}}}]})},"undefined"!=typeof document){const t=document.getElementsByTagName("script");for(let n=0;n<t.length;n++){const o=t[n];if("systemjs-packagemap"===o.type){o.src?w=fetch(o.src).then(function(t){return t.json()}).then(function(t){v=c(t,o.src),w=void 0},function(){v=s,w=void 0}):(v=c(JSON.parse(o.innerHTML),e),w=Promise.resolve());break}}}w||(v=s),h.resolve=function(t,n){return r(t,n=n||e)||(-1!==t.indexOf(":")?t:w?w.then(function(){return v(t,n)}):v(t,n))},h.get=function(t){const n=this[f][t];if(n&&null===n.e&&!n.E)return n.eE?null:n.n},h.delete=function(t){const n=this.get(t);return void 0!==n&&(n&&n.d&&n.d.forEach(function(t){const e=t.i.indexOf(n);-1!==e&&t.i.splice(e,1)}),delete this[f][t])}}(); |