mirror of
https://github.com/systemjs/systemjs.git
synced 2026-01-25 14:57:38 +00:00
8 lines
12 KiB
JavaScript
8 lines
12 KiB
JavaScript
/*
|
|
* SystemJS
|
|
*
|
|
* Copyright (c) 2013 Guy Bedford
|
|
* MIT License
|
|
*/
|
|
|
|
!function(e){e.upgradeSystemLoader=function(){delete e.upgradeSystemLoader,function(e){if("undefined"==typeof System)throw"System not defined. Include the `es6-module-loader.js` polyfill before SystemJS.";var t=System,r=function(e){if(!(e instanceof Module)){for(var t=[],n=0;n<e.length;n++)t[n]=r(e[n]);return t}return e.__useDefault?e["default"]:e};System.getModule=function(e){return r(System.get(e))},System.set("@empty",Module({}));var n=System["import"];System["import"]=function(e,t){return new Promise(function(r){r(System.normalize.call(this,e,t&&t.name,t&&t.address))}).then(function(e){return Promise.resolve(n.call(System,e,t)).then(function(e){return r(e)})})},System.__exec=function(r){try{Function("global","with(global) { "+r.source+" \n }"+(r.address&&!r.source.match(/\/\/[@#] ?(sourceURL|sourceMappingURL)=([^\n'"]+)/)?"\n//# sourceURL="+r.address:"")).call(e,e)}catch(n){throw"SyntaxError"==n.name&&(n.message="Evaluating "+r.address+"\n "+n.message),n}"@traceur"==r.name&&(e.System=t)}}("undefined"==typeof window?e:window),function(e){if(System.format={},System.formats=[],"undefined"!=typeof window){var t=document.getElementsByTagName("script");t=t[t.length-1];var r=t.getAttribute("data-traceur-src")||t.src.substr(0,t.src.lastIndexOf("/")+1)+"traceur.js"}var n=/(?:^\s*|[}{\(\);,\n]\s*)(import\s+['"]|(import|module)\s+[^"'\(\)\n;]+\s+from\s+['"]|export\s+(\*|\{|default|function|var|const|let|[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*))/,s=/^\s*export\s*\*\s*from\s*(?:'([^']+)'|"([^"]+)")/,a=/^(\s*(\/\*.*\*\/)|(\/\/[^\n]*))*(["']use strict["'];?)?["']([^'"]+)["'][;\n]/,o=System.instantiate;System.instantiate=function(t){var u=t.name||"";if(t.source=t.source||"","traceur"==u)return o.call(this,t);var i=t.metadata.format;if(!i){var m=t.source.match(a);m&&(i=t.metadata.format=m[5])}"@traceur"==u&&(i="global");var l;if(!e.traceur&&("es6"==i||!i)&&(l=t.source.match(s)))return{deps:[l[1]||l[2]],execute:function(e){return System.get(e)}};if("es6"==i||!i&&t.source.match(n))return e.traceur?o.call(System,t):System.import("@traceur",{address:r}).then(function(){return o.call(System,t)});if(System.shim&&System.shim[t.name]&&(i="global"),!i||!this.format[i])for(var f=0;f<this.formats.length;f++){var d=this.formats[f],c=this.format[d];if(c.detect(t)){i=d;break}}var c=this.format[i];if(!i||!c)throw new TypeError("No format found for "+(i?i:t.address));for(var p=c.deps(t,e),f=0;f<p.length;f++)p.lastIndexOf(p[f])!=f&&p.splice(f--,1);return{deps:p,execute:function(){var r=c.execute.call(this,Array.prototype.splice.call(arguments,0),t,e);return r instanceof e.Module?r:new e.Module(r&&r.__esModule?r:{__useDefault:!0,"default":r})}}}}("undefined"!=typeof window?window:e),function(){function e(e,t,r){return function(n,a,o){return"string"==typeof n&&-1!=t.indexOf(n)?System.getModule(r[t.indexOf(n)]):s(n,a,o,{name:e})}}function t(e,t){for(var r=0;r<e.length;r++)e.lastIndexOf(e[r])!=r&&e.splice(r--,1);var n;return-1!=(n=e.indexOf("require"))&&(t.requireIndex=n,e.splice(n,1)),-1!=(n=e.indexOf("exports"))&&(t.exportsIndex=n,e.splice(n,1)),-1!=(n=e.indexOf("module"))&&(t.moduleIndex=n,e.splice(n,1)),e}function r(t,r){for(var n=r.metadata,s=[],a=0;a<t.length;a++){var o=System.get(t[a]);if(o.__useDefault)o=o["default"];else if(!o.__esModule){var u={__esModule:!0};for(var i in o)u[i]=o[i];o=u}s[a]=o}var o,m;return void 0!==n.moduleIndex&&s.splice(n.moduleIndex,0,m={},o={id:r.name,uri:r.address,config:function(){return{}},exports:m}),void 0!==n.exportsIndex&&s.splice(n.exportsIndex,0,m=m||{}),void 0!==n.requireIndex&&s.splice(n.requireIndex,0,e(r.name,n.deps,t)),{deps:s,module:o||m&&{exports:m}}}System.formats.push("amd");var n=/(?:^\s*|[}{\(\);,\n\?\&]\s*)define\s*\(\s*("[^"]+"\s*,|'[^']+'\s*,\s*)?(\[(\s*("[^"]+"|'[^']+')\s*,)*(\s*("[^"]+"|'[^']+')\s*)?\]|function\s*|{|[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*\))/,s=System.requirejs=function(e,t,r,n){if("object"==typeof e&&!(e instanceof Array))return s.apply(null,Array.prototype.splice.call(arguments,1));if(!(e instanceof Array)){if("string"==typeof e)return System.getModule(e);throw"Invalid require"}Promise.all(e.map(function(e){return System["import"](e,n)})).then(function(e){t.apply(null,e)},r)};System.format.amd={detect:function(e){return!!e.source.match(n)},deps:function(e,n){var s,a=e.metadata,o=!1;return n.define=function(u,i,m){if(!o){if("string"!=typeof u?(m=i,i=u,u=null):a.bundle||(u=null),u||(o=!0),!(i instanceof Array)){m=i;var l=e.source;e.source=m.toString(),i=["require","exports","module"].concat(System.format.cjs.deps(e,n)),e.source=l}if("function"!=typeof m&&(m=function(e){return function(){return e}}(m)),u&&u!=e.name){var f={name:u,address:u,metadata:{}};i=t(i,f.metadata),System.defined[u]={deps:i,execute:function(){var e=r(Array.prototype.splice.call(arguments,0),f),t=m.apply(n,e.deps)||e.module&&e.module.exports;return t instanceof n.Module?t:new n.Module(t&&t.__esModule?t:{__useDefault:!0,"default":t})}}}else s=i,a.factory=m}},n.define.amd={},delete n.module,delete n.exports,System.__exec(e),s=s||[],s=t(s,a),delete n.define,a.deps=s,s},execute:function(e,t,n){if(t.metadata.factory){var s=r(e,t);return t.metadata.factory.apply(n,s.deps)||s.module&&s.module.exports}}}}(),function(){System.formats.push("cjs");var e=/(?:^\s*|[}{\(\);,\n=:\?\&]\s*|module\.)(exports\s*\[\s*('[^']+'|"[^"]+")\s*\]|\exports\s*\.\s*[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*|exports\s*\=)/,t=/(?:^\s*|[}{\(\);,\n=:\?\&]\s*)require\s*\(\s*("([^"]+)"|'([^']+)')\s*\)/g,r=/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/gm,n={nextTick:function(e){setTimeout(e,7)}};System.set("@@nodeProcess",Module(n)),System.format.cjs={detect:function(r){return e.lastIndex=0,t.lastIndex=0,!(!t.exec(r.source)&&!e.exec(r.source))},deps:function(n){e.lastIndex=0,t.lastIndex=0;for(var s,a=[],o=n.source.replace(r,"");s=t.exec(o);)a.push(s[2]||s[3]);return n.metadata.deps=a,a},execute:function(e,t,r){var s=t.address.split("/");s.pop(),s=s.join("/");var a=t.metadata.deps,o=r._g={global:r,exports:{},process:n,require:function(t){var r=a.indexOf(t);return-1!=r?System.getModule(e[r]):void 0},__filename:t.address,__dirname:s};o.module={exports:o.exports};var u="";for(var i in o)u+="var "+i+" = _g."+i+";";return t.source=u+t.source,System.__exec(t),delete r._g,o.module.exports}}}(),function(){System.formats.push("global");var e=/(["']global["'];\s*)((['"]import [^'"]+['"];\s*)*)(['"]export ([^'"]+)["'])?/,t=/(["']import [^'"]+)+/g,r={};System.shim={},System.format.global={detect:function(){return!0},deps:function(r){var n,s;if(n=r.source.match(e)){if(s=n[2].match(t))for(var a=0;a<s.length;a++)s[a]=s[a].substr(8);r.metadata.globalExport=n[5]}s=s||[];var o;return(o=System.shim[r.name])&&("object"==typeof o&&(o.exports&&(r.metadata.globalExport=o.exports),(o.deps||o.imports)&&(o=o.deps||o.imports)),o instanceof Array&&(s=s.concat(o))),s},execute:function(e,t,n){for(var s=t.metadata.globalExport,a=0;a<e.length;a++){var o=r[e[a]];if(o)for(var u in o)n[u]=o[u]}var i={};for(var m in n)n.hasOwnProperty(m)&&(i[m]=n[m]);s&&(t.source+='\nthis["'+s+'"] = '+s),System.__exec(t);var l,o;if(s){var f=s.split(".")[0];l=eval.call(n,s),o={},o[f]=n[f]}else{o={};for(var m in n)n.hasOwnProperty(m)&&m!=n&&i[m]!=n[m]&&(o[m]=n[m],l?l!==n[m]&&(l=!1):l!==!1&&(l=n[m]))}return r[t.name]=o,l?l:new Module(o)}}}(),function(){function e(e,t){var r=t.split("/"),n=e.split("/");if(r.length>n.length)return 0;for(var s=0;s<r.length;s++)if(n[s]!=r[s])return 0;return r.length}function t(t,r){var n,s,a=0,o=0;if(r){for(var u in System.map){var i=System.map[u];if("object"==typeof i&&!(e(r,u)<=o))for(var m in i)e(t,m)<=a||(n=m,a=m.split("/").length,s=u,o=u.split("/").length)}if(n){var l=t.split("/").splice(a).join("/");return System.map[s][n]+(l?"/"+l:"")}}for(var u in System.map){var i=System.map[u];"string"==typeof i&&(e(t,u)<=a||(n=u,a=u.split("/").length))}if(!n)return t;var l=t.split("/").splice(a).join("/");return System.map[n]+(l?"/"+l:"")}System.map=System.map||{};var r=System.normalize.bind(System);System.normalize=function(e,n,s){return Promise.resolve(r(e,n,s)).then(function(e){return t(e,n)})}}(),function(){var e=System.normalize;System.normalize=function(t,r,n){var s;return r&&-1!=(s=r.indexOf("!"))&&(r=r.substr(0,s)),Promise.resolve(e(t,r,n)).then(function(e){e=e.trim();var t=e.lastIndexOf("!");if(-1!=t){var s=e.substr(0,t),a=e.substr(t+1)||s.substr(s.lastIndexOf(".")+1);return new Promise(function(e){e(System.normalize(a,r,n))}).then(function(e){return a=e,System.normalize(s,r,n)}).then(function(e){return e+"!"+a})}return e})};var t=System.locate;System.locate=function(e){var r=e.name,n=r.lastIndexOf("!");if(-1!=n){var s=r.substr(n+1);return e.name=r.substr(0,n),System.load(s).then(function(){var t=System.get(s);return t=t["default"]||t,e.metadata.plugin=t,e.metadata.pluginName=s,e.metadata.pluginArgument=e.name,t.locate?t.locate.call(System,e):new Promise(function(t){t(System.locate(e))}).then(function(e){return e.substr(0,e.length-3)})})}return t.call(this,e)};var r=System.fetch;System.fetch=function(e){var t=this;return"function"==typeof e.metadata.plugin?new Promise(function(n,s){e.metadata.plugin(e.metadata.pluginArgument,e.address,function(n,s,a){r.call(t,{name:e.name,address:n,metadata:{}}).then(s,a)},n,s)}):(e.metadata.plugin&&e.metadata.plugin.fetch||r).call(this,e)};var n=System.translate;System.translate=function(e){var t=e.metadata.plugin;return t&&t.translate?t.translate.call(this,e):n.call(this,e)}}(),function(){System.bundles=System.bundles||{};var e=System.fetch;System.fetch=function(t){for(var r in System.bundles)if(-1!=System.bundles[r].indexOf(t.name))return Promise.resolve(System.normalize(r)).then(function(e){return System.bundles[e]=System.bundles[e]||System.bundles[r],System.load(e)}).then(function(){return""});return e.apply(this,arguments)};var t=System.locate;System.locate=function(e){return System.bundles[e.name]&&(e.metadata.bundle=!0),t.call(this,e)};var r=System.instantiate;System.instantiate=function(e){return e.metadata.bundle?{deps:[],execute:function(){return System.__exec(e),new Module({})}}:r.apply(this,arguments)}}(),function(){System.defined={},System.register=function(e,t,r){System.defined[e]={deps:t,execute:function(){return Module(r.apply(this,arguments))}}};var e=System.fetch;System.fetch=function(t){return System.defined[t.name]?"":e.apply(this,arguments)};var t=System.instantiate;System.instantiate=function(e){if(System.defined[e.name]){var r=System.defined[e.name];return delete System.defined[e.name],r}return t.apply(this,arguments)}}(),function(){var e=/^(\d+)(?:\.(\d+)(?:\.(\d+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?)?)?$/,t=function(e,t){var r,n=e.split("."),s=t.split(".");n[2]&&-1!=(r=n[2].indexOf("-"))&&n.splice(2,1,n[2].substr(0,r),n[2].substr(r+1)),s[2]&&-1!=(r=s[2].indexOf("-"))&&s.splice(2,1,s[2].substr(0,r),s[2].substr(r+1));for(var a=0;a<Math.max(n.length,s.length);a++){if(!n[a])return 1;if(!s[a])return-1;if(n[a]!=s[a])return parseInt(n[a])>parseInt(s[a])?1:-1}return 0},r=System.normalize;System.versions=System.versions||{},System.normalize=function(n,s,a){var o=System.versions;return Promise.resolve(r.call(this,n,s,a)).then(function(r){var n,s,a,u,i=r.indexOf("@");if(-1==i){for(var m in o)if(u=o[m],r.substr(0,m.length)==m&&(a=r.charAt(m.length),!a||"/"==a))return m+"@"+("string"==typeof u?u:u[u.length-1])+r.substr(m.length);return r}n=r.substr(i+1).split("/")[0];var l,f=n.length;if("^"==n.substr(0,1)&&(n=n.substr(1),l=!0),s=n.match(e),!s)return r;l&&(s[2]||(l=!1),s[3]||(s[2]>0?s[3]="0":l=!1)),l&&(s[1]>0?(s[2]||(n=s[1]+".0.0"),s[3]||(n=s[1]+".0"),l=n,s=[s[1]]):s[2]>0?(l=n,s=[0,s[2]]):(l=!1,s=[0,0,s[3]]),n=s.join("."));var d=r.substr(0,i);if(u=o[d]||[],"string"==typeof u&&(u=[u]),!s[3]||l)for(var c=u.length-1;c>=0;c--){var p=u[c];if(p.substr(0,n.length)==n&&p.charAt(n.length).match(/^[\.\-]?$/)&&(!l||l&&-1!=t(p,l)))return d+"@"+p+r.substr(d.length+f+1)}return-1==u.indexOf(n)&&(u.push(n),u.sort(t),r=d+"@"+n+r.substr(d.length+f+1),s[3]&&-1!=(i=u.indexOf(s[1]+"."+s[2]))&&u.splice(i,1),s[2]&&-1!=(i=u.indexOf(s[1]))&&u.splice(i,1),o[d]=1==u.length?u[0]:u),r})}}()},function(){if(!e.System||e.System.registerModule)if("undefined"!=typeof window){var t=document.getElementsByTagName("script"),r=t[t.length-1].src,n=r.substr(0,r.lastIndexOf("/")+1);document.write('<script type="text/javascript" src="'+n+'es6-module-loader.js" data-init="upgradeSystemLoader"></script>')}else{var s=require("es6-module-loader");e.System=s.System,e.Loader=s.Loader,e.Module=s.Module,module.exports=e.System,e.upgradeSystemLoader()}else e.upgradeSystemLoader()}()}("undefined"!=typeof window?window:global); |