Server render the main page

Also, add hashes to asset file names and use the "entry manifest" plugin
in dev to get auto-reloading.
This commit is contained in:
Michael Jackson
2019-01-12 19:27:28 -08:00
parent 45c48cba26
commit 09914c1db4
176 changed files with 2725 additions and 119822 deletions

View File

@ -0,0 +1,10 @@
MIT License
-----------
Copyright (C) 2013-2018 Guy Bedford
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -0,0 +1,179 @@
# SystemJS 2.0
[![Build Status][travis-image]][travis-url]
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/systemjs/systemjs?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Sponsor](https://cdn.canopytax.com/images/canopy-sponsorship.svg)](https://canopytax.github.io/post/systemjs-sponsorship/?utm_source=systemjs)
Configurable module loader enabling backwards compatibility workflows for ES modules in browsers.
[Read the SystemJS 2.0 announcement post](https://guybedford.com/systemjs-2.0-alpha)
_[For the previous release see the SystemJS 0.21.x branch](https://github.com/systemjs/systemjs/tree/0.21)_
_SystemJS is [currently sponsored by Canopy Tax](https://canopytax.github.io/post/systemjs-sponsorship/?utm_source=systemjs)._
SystemJS 2.0 provides two hookable base builds:
#### 1. s.js minimal loader
The minimal [1.5KB s.js loader](dist/s.min.js) provides a workflow where code written for production workflows of native ES modules in browsers ([like Rollup code-splitting builds](https://rollupjs.org/guide/en#experimental-code-splitting)), can be transpiled to the [System.register module format](docs/system-register.md) to work in older browsers that don't supporting native modules, including IE11++.
Since the ES module semantics such as live bindings, circular references, contextual metadata, dynamic import and top-level await [can all be fully supported this way](docs/system-register.md#semantics), while supporting CSP and cross-origin support, this workflow can be relied upon as a polyfill-like path.
* Loads and resolves modules as URLs, throwing for bare specifier names (eg `import 'lodash'`) like the native module loader.
* Loads System.register modules.
* Core hookable extensible loader supporting [custom extensions](docs/hooks.md).
#### 2. system.js loader
The [3KB system.js loader](dist/system.min.js) loader builds on the s.js core and adds support for upcoming module specifications (currently [package name maps](https://github.com/domenic/package-name-maps) and [WASM integration](https://github.com/WebAssembly/esm-integration) with module loading) as well as development and convenience features.
* Support for loading [bare specifier names](docs/package-name-maps.md) through package name maps (formerly map configuration), loaded via `<script type="system-packagenamemap">` (requires a `fetch` polyfill for eg IE11).
* Includes the [global loading extra](#extras) for loading global scripts, useful for loading library dependencies traditionally loaded with script tags.
* [Tracing hooks](docs/hooks.md#trace-hooks) and [registry deletion API](docs/api.md#registry) for reloading workflows
* Supports loading WASM based on the `.wasm` file extension
#### Extras
The following [pluggable extras](dist/extras) are provided which can be dropped in with either the s.js or system.js loader:
* [AMD loading](dist/extras/amd.js) support (through `Window.define` which is created).
* [Global loading](dist/extras/global.js) support for loading global scripts and detecting the defined global as the default export. Useful for loading common library scripts from CDN like `System.import('//unpkg.com/lodash')`. _(Already included in the system.js loader build)_.
* [Named exports](dist/extras/named-exports.js) convenience extension support for global and AMD module formats (`import { x } from './global.js'` instead of `import G from './global.js'; G.x`)
* [Transform loader](dist/extras/transform.js) support, using fetch and eval, supporting a hookable `loader.transform`
Since all loader features are hookable, custom extensions can be easily made following the same approach as the bundled extras. See the [hooks documentation](docs/hooks.md) for more information.
For discussion, join the [Gitter Room](https://gitter.im/systemjs/systemjs).
## Installation
```
npm install systemjs@alpha
```
## Documentation
* [Package Name Maps](docs/package-name-maps.md)
* [API](docs/api.md)
* [System.register](docs/system-register.md)
* [Loader Hooks](docs/hooks.md)
## Example Usage
### Loading a System.register module
```html
<script src="system.js"></script>
<script>
System.import('/js/main.js');
</script>
```
where `main.js` is a module available in the System.register module format.
### Package Name Maps
Say `main.js` depends on loading `'lodash'`, then we can define a package name map:
```html
<script type="systemjs-packagemap">
{
"packages": {
"lodash": "https://unpkg.com/lodash@4.17.10/lodash.js"
}
}
</script>
<!-- Alternatively:
<script type="systemjs-packagemap" src="path/to/map.json">
-->
<!-- SystemJS must be loaded after the package map -->
<script src="system.js"></script>
<script>
System.import('/js/main.js');
</script>
```
### Browser transpilation
To load ES modules directly in older browsers with SystemJS we can install and use the Babel plugin:
```html
<script src="system.js"></script>
<script src="extras/transform.js"></script>
<script src="plugin-babel/dist/babel-transform.js"></script>
<script>
// main and all its dependencies will now run through transform before loading
System.import('/js/main.js');
</script>
```
## Compatibility with Webpack
Code-splitting builds on top of native ES modules, like Rollup offers, are an alternative to the Webpack-style chunking approach - offering a way to utilize the native module loader for loading shared and dynamic chunks instead of using a custom registry and loader as Webpack bundles include. Scope-level optimizations can be performed on ES modules when they are combined, while ensuring no duplicate code is loaded through dynamic loading and code-sharing in the module registry, using the features of the native module loader and its dynamic runtime nature.
There is currently no support for SystemJS in Webpack. If building code using the `System` global in Webpack, the following config is needed to avoid rewriting:
```js
{
module: {
rules: [
{ parser: { system: false } }
]
}
}
```
## Polyfills for Older Browsers
### Promises
Both builds of SystemJS need Promises in the environment to work, which aren't supported in older browsers like IE11.
Promises can be conditionally polyfilled using, for example, [Bluebird](http://bluebirdjs.com/docs/getting-started.html) (generally the fastest Promise polyfill):
```html
<script>
if (typeof Promise === 'undefined')
document.write('<script src="node_modules/bluebird/js/browser/bluebird.core.js"><\/script>');
</script>
```
> Generally `document.write` is not recommended when writing web applications, but for this use case
it works really well and will only apply in older browsers anyway.
### Fetch
To support package maps in the system.js build, a fetch polyfill is need. The [GitHub polyfill](https://github.github.io/fetch/) is recommended:
```html
<script>
if (typeof fetch === 'undefined')
document.write('<script src="node_modules/whatwg-fetch/fetch.js"><\/script>');
</script>
```
## Loader Extensions
This list can be extended to include third-party loader extensions. Feel free to [post a PR to share your work](https://github.com/systemjs/systemjs/edit/2.0/README.md).
* [transform-babel](https://github.com/systemjs/systemjs-transform-babel) Supports ES module transformation into System.register with Babel.
* [json-plugin](https://github.com/Jamaks/systemjs2-json-plugin) JSON loader plugin
## Contributing to SystemJS
Project bug fixes and changes are welcome for discussion, provided the project footprint remains minimal.
To run the tests:
```
npm run build && npm run test
```
## License
MIT
[travis-url]: https://travis-ci.org/systemjs/systemjs
[travis-image]: https://travis-ci.org/systemjs/systemjs.svg?branch=master

116
public/systemjs@2.0.0/dist/extras/amd.js vendored Normal file
View File

@ -0,0 +1,116 @@
/*
* Support for AMD loading
*/
(function (global) {
const systemPrototype = System.constructor.prototype;
const emptyInstantiation = [[], function () { return {} }];
function unsupportedRequire () {
throw new Error('AMD require not supported.');
}
function unsupportedNamed () {
throw new Error('Named AMD not supported.');
}
const requireExportsModule = ['require', 'exports', 'module'];
// hook System.register to know the last declaration binding
let lastRegisterDeclare;
const systemRegister = systemPrototype.register;
systemPrototype.register = function (deps, declare) {
lastRegisterDeclare = declare;
systemRegister.call(this, deps, declare);
};
const getRegister = systemPrototype.getRegister;
systemPrototype.getRegister = function () {
const register = getRegister.call(this);
// if its an actual System.register leave it
if (register && register[1] === lastRegisterDeclare)
return register;
// otherwise AMD takes priority
// no registration -> attempt AMD detection
if (!amdDefineDeps)
return register || emptyInstantiation;
const exports = {};
const module = { exports: exports };
const depModules = [];
const setters = [];
let splice = 0;
for (let i = 0; i < amdDefineDeps.length; i++) {
const id = amdDefineDeps[i];
const index = setters.length;
if (id === 'require') {
depModules[i] = unsupportedRequire;
splice++;
}
else if (id === 'module') {
depModules[i] = module;
splice++;
}
else if (id === 'exports') {
depModules[i] = exports;
splice++;
}
else {
// needed for ie11 lack of iteration scope
const idx = i;
setters.push(function (ns) {
depModules[idx] = ns.default;
});
}
if (splice)
amdDefineDeps[index] = id;
}
if (splice)
amdDefineDeps.length -= splice;
const amdExec = amdDefineExec;
const registration = [amdDefineDeps, function (_export) {
_export('default', exports);
return {
setters: setters,
execute: function () {
_export('default', amdExec.apply(exports, depModules) || module.exports);
}
};
}];
amdDefineDeps = null;
return registration;
};
let amdDefineDeps;
let amdDefineExec;
global.define = function (name, deps, execute) {
// define('', [], function () {})
if (typeof name === 'string') {
if (amdDefineDeps) {
amdDefineDeps = [];
amdDefineExec = unsupportedNamed;
return;
}
else {
name = deps;
deps = execute;
}
}
// define([], function () {})
if (name instanceof Array) {
amdDefineDeps = name;
amdDefineExec = deps;
}
// define({})
else if (typeof name === 'object') {
amdDefineDeps = [];
amdDefineExec = function () { return name };
}
// define(function () {})
else if (typeof name === 'function') {
amdDefineDeps = requireExportsModule;
amdDefineExec = name;
}
};
global.define.amd = {};
})(typeof self !== 'undefined' ? self : global);

View File

@ -0,0 +1 @@
!function(e){const t=System.constructor.prototype,n=[[],function(){return{}}];function o(){throw new Error("AMD require not supported.")}function r(){throw new Error("Named AMD not supported.")}const i=["require","exports","module"];let u;const f=t.register;t.register=function(e,t){u=t,f.call(this,e,t)};const s=t.getRegister;let c,l;t.getRegister=function(){const e=s.call(this);if(e&&e[1]===u)return e;if(!c)return e||n;const t={},r={exports:t},i=[],f=[];let p=0;for(let e=0;e<c.length;e++){const n=c[e],u=f.length;if("require"===n)i[e]=o,p++;else if("module"===n)i[e]=r,p++;else if("exports"===n)i[e]=t,p++;else{const t=e;f.push(function(e){i[t]=e.default})}p&&(c[u]=n)}p&&(c.length-=p);const d=l,a=[c,function(e){return e("default",t),{setters:f,execute:function(){e("default",d.apply(t,i)||r.exports)}}}];return c=null,a},e.define=function(e,t,n){if("string"==typeof e){if(c)return c=[],void(l=r);e=t,t=n}e instanceof Array?(c=e,l=t):"object"==typeof e?(c=[],l=function(){return e}):"function"==typeof e&&(c=i,l=e)},e.define.amd={}}("undefined"!=typeof self?self:global);

View File

@ -0,0 +1 @@
{"version":3,"sources":["amd.js"],"names":["global","systemPrototype","System","constructor","prototype","emptyInstantiation","unsupportedRequire","Error","unsupportedNamed","requireExportsModule","lastRegisterDeclare","systemRegister","register","deps","declare","call","this","getRegister","amdDefineDeps","amdDefineExec","exports","module","depModules","setters","splice","i","length","id","index","idx","push","ns","default","amdExec","registration","_export","execute","apply","define","name","Array","amd","self"],"mappings":"CAGA,SAAWA,GACT,MAAMC,EAAkBC,OAAOC,YAAYC,UAErCC,EAAqB,CAAC,GAAI,WAAc,MAAO,KAErD,SAASC,IACP,MAAM,IAAIC,MAAM,8BAGlB,SAASC,IACP,MAAM,IAAID,MAAM,4BAGlB,MAAME,EAAuB,CAAC,UAAW,UAAW,UAGpD,IAAIC,EACJ,MAAMC,EAAiBV,EAAgBW,SACvCX,EAAgBW,SAAW,SAAUC,EAAMC,GACzCJ,EAAsBI,EACtBH,EAAeI,KAAKC,KAAMH,EAAMC,IAGlC,MAAMG,EAAchB,EAAgBgB,YAyDpC,IAAIC,EACAC,EAzDJlB,EAAgBgB,YAAc,WAC5B,MAAML,EAAWK,EAAYF,KAAKC,MAElC,GAAIJ,GAAYA,EAAS,KAAOF,EAC9B,OAAOE,EAIT,IAAKM,EACH,OAAON,GAAYP,EAErB,MAAMe,EAAU,GACVC,EAAS,CAAED,QAASA,GACpBE,EAAa,GACbC,EAAU,GAChB,IAAIC,EAAS,EACb,IAAK,IAAIC,EAAI,EAAGA,EAAIP,EAAcQ,OAAQD,IAAK,CAC7C,MAAME,EAAKT,EAAcO,GACnBG,EAAQL,EAAQG,OACtB,GAAW,YAAPC,EACFL,EAAWG,GAAKnB,EAChBkB,SAEG,GAAW,WAAPG,EACPL,EAAWG,GAAKJ,EAChBG,SAEG,GAAW,YAAPG,EACPL,EAAWG,GAAKL,EAChBI,QAEG,CAEH,MAAMK,EAAMJ,EACZF,EAAQO,KAAK,SAAUC,GACrBT,EAAWO,GAAOE,EAAGC,UAGrBR,IACFN,EAAcU,GAASD,GAEvBH,IACFN,EAAcQ,QAAUF,GAC1B,MAAMS,EAAUd,EACVe,EAAe,CAAChB,EAAe,SAAUiB,GAE7C,OADAA,EAAQ,UAAWf,GACZ,CACLG,QAASA,EACTa,QAAS,WACPD,EAAQ,UAAWF,EAAQI,MAAMjB,EAASE,IAAeD,EAAOD,aAKtE,OADAF,EAAgB,KACTgB,GAITlC,EAAOsC,OAAS,SAAUC,EAAM1B,EAAMuB,GAEpC,GAAoB,iBAATG,EAAmB,CAC5B,GAAIrB,EAGF,OAFAA,EAAgB,QAChBC,EAAgBX,GAIhB+B,EAAO1B,EACPA,EAAOuB,EAIPG,aAAgBC,OAClBtB,EAAgBqB,EAChBpB,EAAgBN,GAGO,iBAAT0B,GACdrB,EAAgB,GAChBC,EAAgB,WAAc,OAAOoB,IAGd,mBAATA,IACdrB,EAAgBT,EAChBU,EAAgBoB,IAGpBvC,EAAOsC,OAAOG,IAAM,GA/GtB,CAgHmB,oBAATC,KAAuBA,KAAO1C"}

View File

@ -0,0 +1,57 @@
/*
* SystemJS global script loading support
* Extra for the s.js build only
* (Included by default in system.js build)
*/
(function (global) {
const systemJSPrototype = System.constructor.prototype;
function getLastGlobalProp () {
// alternatively Object.keys(global).pop()
// but this may be faster (pending benchmarks)
let lastProp;
for (let p in global)
if (global.hasOwnProperty(p))
lastProp = p;
return lastProp;
}
let lastGlobalProp;
const impt = systemJSPrototype.import;
systemJSPrototype.import = function (id, parentUrl) {
lastGlobalProp = getLastGlobalProp();
return impt.call(this, id, parentUrl);
};
const emptyInstantiation = [[], function () { return {} }];
const getRegister = systemJSPrototype.getRegister;
systemJSPrototype.getRegister = function () {
const lastRegister = getRegister.call(this);
if (lastRegister)
return lastRegister;
// no registration -> attempt a global detection as difference from snapshot
// when multiple globals, we take the global value to be the last defined new global object property
// for performance, this will not support multi-version / global collisions as previous SystemJS versions did
// note in Edge, deleting and re-adding a global does not change its ordering
const globalProp = getLastGlobalProp();
if (lastGlobalProp === globalProp)
return emptyInstantiation;
lastGlobalProp = globalProp;
let globalExport;
try {
globalExport = global[globalProp];
}
catch (e) {
return emptyInstantiation;
}
return [[], function (_export) {
return { execute: function () { _export('default', globalExport) } };
}];
};
})(typeof self !== 'undefined' ? self : global);

View File

@ -0,0 +1 @@
!function(t){const n=System.constructor.prototype;function e(){let n;for(let e in t)t.hasOwnProperty(e)&&(n=e);return n}let r;const o=n.import;n.import=function(t,n){return r=e(),o.call(this,t,n)};const c=[[],function(){return{}}],u=n.getRegister;n.getRegister=function(){const n=u.call(this);if(n)return n;const o=e();if(r===o)return c;let i;r=o;try{i=t[o]}catch(t){return c}return[[],function(t){return{execute:function(){t("default",i)}}}]}}("undefined"!=typeof self?self:global);

View File

@ -0,0 +1 @@
{"version":3,"sources":["global.js"],"names":["global","systemJSPrototype","System","constructor","prototype","getLastGlobalProp","lastProp","p","hasOwnProperty","lastGlobalProp","impt","import","id","parentUrl","call","this","emptyInstantiation","getRegister","lastRegister","globalProp","globalExport","e","_export","execute","self"],"mappings":"CAKA,SAAWA,GAEX,MAAMC,EAAoBC,OAAOC,YAAYC,UAE7C,SAASC,IAGP,IAAIC,EACJ,IAAK,IAAIC,KAAKP,EACRA,EAAOQ,eAAeD,KACxBD,EAAWC,GACf,OAAOD,EAGT,IAAIG,EACJ,MAAMC,EAAOT,EAAkBU,OAC/BV,EAAkBU,OAAS,SAAUC,EAAIC,GAEvC,OADAJ,EAAiBJ,IACVK,EAAKI,KAAKC,KAAMH,EAAIC,IAG7B,MAAMG,EAAqB,CAAC,GAAI,WAAc,MAAO,KAE/CC,EAAchB,EAAkBgB,YACtChB,EAAkBgB,YAAc,WAC9B,MAAMC,EAAeD,EAAYH,KAAKC,MACtC,GAAIG,EACF,OAAOA,EAMT,MAAMC,EAAad,IACnB,GAAII,IAAmBU,EACrB,OAAOH,EAGT,IAAII,EADJX,EAAiBU,EAEjB,IACEC,EAAepB,EAAOmB,GAExB,MAAOE,GACL,OAAOL,EAGT,MAAO,CAAC,GAAI,SAAUM,GACpB,MAAO,CAAEC,QAAS,WAAcD,EAAQ,UAAWF,QA/CvD,CAmDmB,oBAATI,KAAuBA,KAAOxB"}

View File

@ -0,0 +1,48 @@
/*
* Named exports support for legacy module formats in SystemJS 2.0
*/
(function () {
const systemPrototype = System.constructor.prototype;
// hook System.register to know the last declaration binding
let lastRegisterDeclare;
const systemRegister = systemPrototype.register;
systemPrototype.register = function (deps, declare) {
lastRegisterDeclare = declare;
systemRegister.call(this, deps, declare);
};
const getRegister = systemPrototype.getRegister;
systemPrototype.getRegister = function () {
const register = getRegister.call(this);
// if it is an actual System.register call, then its ESM
// -> dont add named exports
if (!register || register[1] === lastRegisterDeclare || register[1].length === 0)
return register;
// otherwise it was provided by a custom instantiator
// -> extend the registration with named exports support
const registerDeclare = register[1];
register[1] = function (_export, _context) {
// hook the _export function to note the default export
let defaultExport;
const declaration = registerDeclare.call(this, function (name, value) {
if (name === 'default')
defaultExport = value;
_export(name, value);
}, _context);
// hook the execute function
const execute = declaration.execute;
if (execute)
declaration.execute = function () {
execute.call(this);
// do a bulk export of the default export object
// to export all its names as named exports
if (typeof defaultExport === 'object')
_export(defaultExport);
};
return declaration;
};
return register;
};
})();

View File

@ -0,0 +1 @@
!function(){const t=System.constructor.prototype;let e;const n=t.register;t.register=function(t,c){e=c,n.call(this,t,c)};const c=t.getRegister;t.getRegister=function(){const t=c.call(this);if(!t||t[1]===e||0===t[1].length)return t;const n=t[1];return t[1]=function(t,e){let c;const o=n.call(this,function(e,n){"default"===e&&(c=n),t(e,n)},e),s=o.execute;return s&&(o.execute=function(){s.call(this),"object"==typeof c&&t(c)}),o},t}}();

View File

@ -0,0 +1 @@
{"version":3,"sources":["named-exports.js"],"names":["systemPrototype","System","constructor","prototype","lastRegisterDeclare","systemRegister","register","deps","declare","call","this","getRegister","length","registerDeclare","_export","_context","defaultExport","declaration","name","value","execute"],"mappings":"CAGA,WACE,MAAMA,EAAkBC,OAAOC,YAAYC,UAG3C,IAAIC,EACJ,MAAMC,EAAiBL,EAAgBM,SACvCN,EAAgBM,SAAW,SAAUC,EAAMC,GACzCJ,EAAsBI,EACtBH,EAAeI,KAAKC,KAAMH,EAAMC,IAGlC,MAAMG,EAAcX,EAAgBW,YACpCX,EAAgBW,YAAc,WAC5B,MAAML,EAAWK,EAAYF,KAAKC,MAGlC,IAAKJ,GAAYA,EAAS,KAAOF,GAA8C,IAAvBE,EAAS,GAAGM,OAClE,OAAON,EAIT,MAAMO,EAAkBP,EAAS,GAqBjC,OApBAA,EAAS,GAAK,SAAUQ,EAASC,GAE/B,IAAIC,EACJ,MAAMC,EAAcJ,EAAgBJ,KAAKC,KAAM,SAAUQ,EAAMC,GAChD,YAATD,IACFF,EAAgBG,GAClBL,EAAQI,EAAMC,IACbJ,GAEGK,EAAUH,EAAYG,QAS5B,OARIA,IACFH,EAAYG,QAAU,WACpBA,EAAQX,KAAKC,MAGgB,iBAAlBM,GACTF,EAAQE,KAEPC,GAEFX,GA1CX"}

View File

@ -0,0 +1,32 @@
/*
* Support for a "transform" loader interface
*/
(function () {
const systemJSPrototype = System.constructor.prototype;
const instantiate = systemJSPrototype.instantiate;
systemJSPrototype.instantiate = function (url, parent) {
if (url.slice(-5) === '.wasm')
return instantiate.call(this, url, parent);
const loader = this;
return fetch(url)
.then(function (res) {
if (!res.ok)
throw new Error('Fetch error: ' + res.status + ' ' + res.statusText + (parent ? ' loading from ' + parent : ''));
return res.text();
})
.then(function (source) {
return loader.transform.call(this, url, source);
})
.then(function (source) {
(0, eval)(source + '\n//# sourceURL=' + url);
return loader.getRegister();
});
};
// Hookable transform function!
systemJSPrototype.transform = function (_id, source) {
return source;
};
})();

View File

@ -0,0 +1 @@
!function(){const t=System.constructor.prototype,n=t.instantiate;t.instantiate=function(t,r){if(".wasm"===t.slice(-5))return n.call(this,t,r);const e=this;return fetch(t).then(function(t){if(!t.ok)throw new Error("Fetch error: "+t.status+" "+t.statusText+(r?" loading from "+r:""));return t.text()}).then(function(n){return e.transform.call(this,t,n)}).then(function(n){return(0,eval)(n+"\n//# sourceURL="+t),e.getRegister()})},t.transform=function(t,n){return n}}();

View File

@ -0,0 +1 @@
{"version":3,"sources":["transform.js"],"names":["systemJSPrototype","System","constructor","prototype","instantiate","url","parent","slice","call","this","loader","fetch","then","res","ok","Error","status","statusText","text","source","transform","eval","getRegister","_id"],"mappings":"CAGA,WACE,MAAMA,EAAoBC,OAAOC,YAAYC,UAEvCC,EAAcJ,EAAkBI,YACtCJ,EAAkBI,YAAc,SAAUC,EAAKC,GAC7C,GAAsB,UAAlBD,EAAIE,OAAO,GACb,OAAOH,EAAYI,KAAKC,KAAMJ,EAAKC,GAErC,MAAMI,EAASD,KACf,OAAOE,MAAMN,GACZO,KAAK,SAAUC,GACd,IAAKA,EAAIC,GACP,MAAM,IAAIC,MAAM,gBAAkBF,EAAIG,OAAS,IAAMH,EAAII,YAAcX,EAAS,kBAAoBA,EAAS,KAC/G,OAAOO,EAAIK,SAEZN,KAAK,SAAUO,GACd,OAAOT,EAAOU,UAAUZ,KAAKC,KAAMJ,EAAKc,KAEzCP,KAAK,SAAUO,GAEd,OADA,EAAIE,MAAMF,EAAS,mBAAqBd,GACjCK,EAAOY,iBAKlBtB,EAAkBoB,UAAY,SAAUG,EAAKJ,GAC3C,OAAOA,GA1BX"}

403
public/systemjs@2.0.0/dist/s.js vendored Normal file
View File

@ -0,0 +1,403 @@
/*
* SJS 2.0.0
* Minimal SystemJS Build
*/
(function () {
const hasSelf = typeof self !== 'undefined';
const envGlobal = hasSelf ? self : global;
let baseUrl;
if (typeof location !== 'undefined') {
baseUrl = location.href.split('#')[0].split('?')[0];
const lastSepIndex = baseUrl.lastIndexOf('/');
if (lastSepIndex !== -1)
baseUrl = baseUrl.slice(0, lastSepIndex + 1);
}
const backslashRegEx = /\\/g;
function resolveIfNotPlainOrUrl (relUrl, parentUrl) {
if (relUrl.indexOf('\\') !== -1)
relUrl = relUrl.replace(backslashRegEx, '/');
// protocol-relative
if (relUrl[0] === '/' && relUrl[1] === '/') {
return parentUrl.slice(0, parentUrl.indexOf(':') + 1) + relUrl;
}
// relative-url
else if (relUrl[0] === '.' && (relUrl[1] === '/' || relUrl[1] === '.' && (relUrl[2] === '/' || relUrl.length === 2 && (relUrl += '/')) ||
relUrl.length === 1 && (relUrl += '/')) ||
relUrl[0] === '/') {
const parentProtocol = parentUrl.slice(0, parentUrl.indexOf(':') + 1);
// Disabled, but these cases will give inconsistent results for deep backtracking
//if (parentUrl[parentProtocol.length] !== '/')
// throw new Error('Cannot resolve');
// read pathname from parent URL
// pathname taken to be part after leading "/"
let pathname;
if (parentUrl[parentProtocol.length + 1] === '/') {
// resolving to a :// so we need to read out the auth and host
if (parentProtocol !== 'file:') {
pathname = parentUrl.slice(parentProtocol.length + 2);
pathname = pathname.slice(pathname.indexOf('/') + 1);
}
else {
pathname = parentUrl.slice(8);
}
}
else {
// resolving to :/ so pathname is the /... part
pathname = parentUrl.slice(parentProtocol.length + 1);
}
if (relUrl[0] === '/')
return parentUrl.slice(0, parentUrl.length - pathname.length - 1) + relUrl;
// join together and split for removal of .. and . segments
// looping the string instead of anything fancy for perf reasons
// '../../../../../z' resolved to 'x/y' is just 'z'
const segmented = pathname.slice(0, pathname.lastIndexOf('/') + 1) + relUrl;
const output = [];
let segmentIndex = -1;
for (let i = 0; i < segmented.length; i++) {
// busy reading a segment - only terminate on '/'
if (segmentIndex !== -1) {
if (segmented[i] === '/') {
output.push(segmented.slice(segmentIndex, i + 1));
segmentIndex = -1;
}
}
// new segment - check if it is relative
else if (segmented[i] === '.') {
// ../ segment
if (segmented[i + 1] === '.' && (segmented[i + 2] === '/' || i + 2 === segmented.length)) {
output.pop();
i += 2;
}
// ./ segment
else if (segmented[i + 1] === '/' || i + 1 === segmented.length) {
i += 1;
}
else {
// the start of a new segment as below
segmentIndex = i;
}
}
// it is the start of a new segment
else {
segmentIndex = i;
}
}
// finish reading out the last segment
if (segmentIndex !== -1)
output.push(segmented.slice(segmentIndex));
return parentUrl.slice(0, parentUrl.length - pathname.length) + output.join('');
}
}
/*
* SystemJS Core
*
* Provides
* - System.import
* - System.register support for
* live bindings, function hoisting through circular references,
* reexports, dynamic import, import.meta.url, top-level await
* - System.getRegister to get the registration
* - Symbol.toStringTag support in Module objects
* - Hookable System.createContext to customize import.meta
* - System.onload(id, err?) handler for tracing / hot-reloading
*
* Core comes with no System.prototype.resolve or
* System.prototype.instantiate implementations
*/
const hasSymbol = typeof Symbol !== 'undefined';
const toStringTag = hasSymbol && Symbol.toStringTag;
const REGISTRY = hasSymbol ? Symbol() : '@';
function SystemJS () {
this[REGISTRY] = {};
}
const systemJSPrototype = SystemJS.prototype;
systemJSPrototype.import = function (id, parentUrl) {
const loader = this;
return Promise.resolve(loader.resolve(id, parentUrl))
.then(function (id) {
const load = getOrCreateLoad(loader, id);
return load.C || topLevelLoad(loader, load);
});
};
// Hookable createContext function -> allowing eg custom import meta
systemJSPrototype.createContext = function (parentId) {
return {
url: parentId
};
};
let lastRegister;
systemJSPrototype.register = function (deps, declare) {
lastRegister = [deps, declare];
};
/*
* getRegister provides the last anonymous System.register call
*/
systemJSPrototype.getRegister = function () {
const _lastRegister = lastRegister;
lastRegister = undefined;
return _lastRegister;
};
function getOrCreateLoad (loader, id, firstParentUrl) {
let load = loader[REGISTRY][id];
if (load)
return load;
const importerSetters = [];
const ns = Object.create(null);
if (toStringTag)
Object.defineProperty(ns, toStringTag, { value: 'Module' });
let instantiatePromise = Promise.resolve()
.then(function () {
return loader.instantiate(id, firstParentUrl);
})
.then(function (registration) {
if (!registration)
throw new Error('Module ' + id + ' did not instantiate');
function _export (name, value) {
// note if we have hoisted exports (including reexports)
load.h = true;
let changed = false;
if (typeof name !== 'object') {
if (!(name in ns) || ns[name] !== value) {
ns[name] = value;
changed = true;
}
}
else {
for (let p in name) {
let value = name[p];
if (!(p in ns) || ns[p] !== value) {
ns[p] = value;
changed = true;
}
}
}
if (changed)
for (let i = 0; i < importerSetters.length; i++)
importerSetters[i](ns);
return value;
}
const declared = registration[1](_export, registration[1].length === 2 ? {
import: function (importId) {
return loader.import(importId, id);
},
meta: loader.createContext(id)
} : undefined);
load.e = declared.execute || function () {};
return [registration[0], declared.setters || []];
});
const linkPromise = instantiatePromise
.then(function (instantiation) {
return Promise.all(instantiation[0].map(function (dep, i) {
const setter = instantiation[1][i];
return Promise.resolve(loader.resolve(dep, id))
.then(function (depId) {
const depLoad = getOrCreateLoad(loader, depId, id);
// depLoad.I may be undefined for already-evaluated
return Promise.resolve(depLoad.I)
.then(function () {
if (setter) {
depLoad.i.push(setter);
// only run early setters when there are hoisted exports of that module
// the timing works here as pending hoisted export calls will trigger through importerSetters
if (depLoad.h || !depLoad.I)
setter(depLoad.n);
}
return depLoad;
});
})
}))
.then(function (depLoads) {
load.d = depLoads;
});
});
// disable unhandled rejections
linkPromise.catch(function () {});
// Captial letter = a promise function
return load = loader[REGISTRY][id] = {
id: id,
// importerSetters, the setters functions registered to this dependency
// we retain this to add more later
i: importerSetters,
// module namespace object
n: ns,
// instantiate
I: instantiatePromise,
// link
L: linkPromise,
// whether it has hoisted exports
h: false,
// On instantiate completion we have populated:
// dependency load records
d: undefined,
// execution function
// set to NULL immediately after execution (or on any failure) to indicate execution has happened
// in such a case, pC should be used, and pLo, pLi will be emptied
e: undefined,
// On execution we have populated:
// the execution error if any
eE: undefined,
// in the case of TLA, the execution promise
E: undefined,
// On execution, pLi, pLo, e cleared
// Promise for top-level completion
C: undefined
};
}
function instantiateAll (loader, load, loaded) {
if (!loaded[load.id]) {
loaded[load.id] = true;
// load.L may be undefined for already-instantiated
return Promise.resolve(load.L)
.then(function () {
return Promise.all(load.d.map(function (dep) {
return instantiateAll(loader, dep, loaded);
}));
})
}
}
function topLevelLoad (loader, load) {
return load.C = instantiateAll(loader, load, {})
.then(function () {
return postOrderExec(loader, load, {});
})
.then(function () {
return load.n;
});
}
// the closest we can get to call(undefined)
const nullContext = Object.freeze(Object.create(null));
// returns a promise if and only if a top-level await subgraph
// throws on sync errors
function postOrderExec (loader, load, seen) {
if (seen[load.id])
return;
seen[load.id] = true;
if (!load.e) {
if (load.eE)
throw load.eE;
if (load.E)
return load.E;
return;
}
// deps execute first, unless circular
let depLoadPromises;
load.d.forEach(function (depLoad) {
{
const depLoadPromise = postOrderExec(loader, depLoad, seen);
if (depLoadPromise)
(depLoadPromises = depLoadPromises || []).push(depLoadPromise);
}
});
if (depLoadPromises) {
return load.E = Promise.all(depLoadPromises).then(doExec);
}
return doExec();
function doExec () {
try {
let execPromise = load.e.call(nullContext);
if (execPromise) {
execPromise.then(function () {
load.C = load.n;
load.E = null;
});
execPromise.catch(function () {});
return load.E = load.E || execPromise;
}
// (should be a promise, but a minify optimization to leave out Promise.resolve)
load.C = load.n;
}
catch (err) {
load.eE = err;
throw err;
}
finally {
load.L = load.I = undefined;
load.e = null;
}
}
}
envGlobal.System = new SystemJS();
/*
* Supports loading System.register via script tag injection
*/
let err$1;
if (typeof window !== 'undefined')
window.addEventListener('error', function (e) {
err$1 = e.error;
});
const systemRegister = systemJSPrototype.register;
systemJSPrototype.register = function (deps, declare) {
err$1 = undefined;
systemRegister.call(this, deps, declare);
};
systemJSPrototype.instantiate = function (url, firstParentUrl) {
const loader = this;
return new Promise(function (resolve, reject) {
const script = document.createElement('script');
script.charset = 'utf-8';
script.async = true;
script.addEventListener('error', function () {
reject(new Error('Error loading ' + url + (firstParentUrl ? ' from ' + firstParentUrl : '')));
});
script.addEventListener('load', function () {
document.head.removeChild(script);
// Note URL normalization issues are going to be a careful concern here
if (err$1)
return reject(err$1);
else
resolve(loader.getRegister());
});
script.src = url;
document.head.appendChild(script);
});
};
systemJSPrototype.resolve = function (id, parentUrl) {
const resolved = resolveIfNotPlainOrUrl(id, parentUrl || baseUrl);
if (!resolved) {
if (id.indexOf(':') !== -1)
return id;
throw new Error('Cannot resolve "' + id + (parentUrl ? '" from ' + parentUrl : '"'));
}
return resolved;
};
}());

1
public/systemjs@2.0.0/dist/s.min.js vendored Normal file
View File

@ -0,0 +1 @@
!function(){const e="undefined"!=typeof self?self:global;let n;if("undefined"!=typeof location){const e=(n=location.href.split("#")[0].split("?")[0]).lastIndexOf("/");-1!==e&&(n=n.slice(0,e+1))}const t=/\\/g,r="undefined"!=typeof Symbol,i=r&&Symbol.toStringTag,o=r?Symbol():"@";function c(){this[o]={}}const l=c.prototype;let u;l.import=function(e,n){const t=this;return Promise.resolve(t.resolve(e,n)).then(function(e){const n=function e(n,t,r){let c=n[o][t];if(c)return c;const l=[],u=Object.create(null);i&&Object.defineProperty(u,i,{value:"Module"});let f=Promise.resolve().then(function(){return n.instantiate(t,r)}).then(function(e){if(!e)throw new Error("Module "+t+" did not instantiate");const r=e[1](function(e,n){c.h=!0;let t=!1;if("object"!=typeof e)e in u&&u[e]===n||(u[e]=n,t=!0);else for(let n in e){let r=e[n];n in u&&u[n]===r||(u[n]=r,t=!0)}if(t)for(let e=0;e<l.length;e++)l[e](u);return n},2===e[1].length?{import:function(e){return n.import(e,t)},meta:n.createContext(t)}:void 0);return c.e=r.execute||function(){},[e[0],r.setters||[]]});const s=f.then(function(r){return Promise.all(r[0].map(function(i,o){const c=r[1][o];return Promise.resolve(n.resolve(i,t)).then(function(r){const i=e(n,r,t);return Promise.resolve(i.I).then(function(){return c&&(i.i.push(c),!i.h&&i.I||c(i.n)),i})})})).then(function(e){c.d=e})});return s.catch(function(){}),c=n[o][t]={id:t,i:l,n:u,I:f,L:s,h:!1,d:void 0,e:void 0,eE:void 0,E:void 0,C:void 0}}(t,e);return n.C||function(e,n){return n.C=function e(n,t,r){if(!r[t.id])return r[t.id]=!0,Promise.resolve(t.L).then(function(){return Promise.all(t.d.map(function(t){return e(n,t,r)}))})}(e,n,{}).then(function(){return function e(n,t,r){if(r[t.id])return;if(r[t.id]=!0,!t.e){if(t.eE)throw t.eE;return t.E?t.E:void 0}let i;return t.d.forEach(function(t){{const o=e(n,t,r);o&&(i=i||[]).push(o)}}),i?t.E=Promise.all(i).then(o):o();function o(){try{let e=t.e.call(f);if(e)return e.then(function(){t.C=t.n,t.E=null}),e.catch(function(){}),t.E=t.E||e;t.C=t.n}catch(e){throw t.eE=e,e}finally{t.L=t.I=void 0,t.e=null}}}(e,n,{})}).then(function(){return n.n})}(t,n)})},l.createContext=function(e){return{url:e}},l.register=function(e,n){u=[e,n]},l.getRegister=function(){const e=u;return u=void 0,e};const f=Object.freeze(Object.create(null));let s;e.System=new c,"undefined"!=typeof window&&window.addEventListener("error",function(e){s=e.error});const d=l.register;l.register=function(e,n){s=void 0,d.call(this,e,n)},l.instantiate=function(e,n){const t=this;return new Promise(function(r,i){const o=document.createElement("script");o.charset="utf-8",o.async=!0,o.addEventListener("error",function(){i(new Error("Error loading "+e+(n?" from "+n:"")))}),o.addEventListener("load",function(){if(document.head.removeChild(o),s)return i(s);r(t.getRegister())}),o.src=e,document.head.appendChild(o)})},l.resolve=function(e,r){const i=function(e,n){if(-1!==e.indexOf("\\")&&(e=e.replace(t,"/")),"/"===e[0]&&"/"===e[1])return n.slice(0,n.indexOf(":")+1)+e;if("."===e[0]&&("/"===e[1]||"."===e[1]&&("/"===e[2]||2===e.length&&(e+="/"))||1===e.length&&(e+="/"))||"/"===e[0]){const t=n.slice(0,n.indexOf(":")+1);let r;if(r="/"===n[t.length+1]?"file:"!==t?(r=n.slice(t.length+2)).slice(r.indexOf("/")+1):n.slice(8):n.slice(t.length+1),"/"===e[0])return n.slice(0,n.length-r.length-1)+e;const i=r.slice(0,r.lastIndexOf("/")+1)+e,o=[];let c=-1;for(let e=0;e<i.length;e++)-1!==c?"/"===i[e]&&(o.push(i.slice(c,e+1)),c=-1):"."===i[e]?"."!==i[e+1]||"/"!==i[e+2]&&e+2!==i.length?"/"===i[e+1]||e+1===i.length?e+=1:c=e:(o.pop(),e+=2):c=e;return-1!==c&&o.push(i.slice(c)),n.slice(0,n.length-r.length)+o.join("")}}(e,r||n);if(!i){if(-1!==e.indexOf(":"))return e;throw new Error('Cannot resolve "'+e+(r?'" from '+r:'"'))}return i}}();

File diff suppressed because one or more lines are too long

712
public/systemjs@2.0.0/dist/system.js vendored Normal file
View File

@ -0,0 +1,712 @@
/*
* SystemJS 2.0.0
*/
(function () {
const hasSelf = typeof self !== 'undefined';
const envGlobal = hasSelf ? self : global;
let baseUrl;
if (typeof location !== 'undefined') {
baseUrl = location.href.split('#')[0].split('?')[0];
const lastSepIndex = baseUrl.lastIndexOf('/');
if (lastSepIndex !== -1)
baseUrl = baseUrl.slice(0, lastSepIndex + 1);
}
const backslashRegEx = /\\/g;
function resolveIfNotPlainOrUrl (relUrl, parentUrl) {
if (relUrl.indexOf('\\') !== -1)
relUrl = relUrl.replace(backslashRegEx, '/');
// protocol-relative
if (relUrl[0] === '/' && relUrl[1] === '/') {
return parentUrl.slice(0, parentUrl.indexOf(':') + 1) + relUrl;
}
// relative-url
else if (relUrl[0] === '.' && (relUrl[1] === '/' || relUrl[1] === '.' && (relUrl[2] === '/' || relUrl.length === 2 && (relUrl += '/')) ||
relUrl.length === 1 && (relUrl += '/')) ||
relUrl[0] === '/') {
const parentProtocol = parentUrl.slice(0, parentUrl.indexOf(':') + 1);
// Disabled, but these cases will give inconsistent results for deep backtracking
//if (parentUrl[parentProtocol.length] !== '/')
// throw new Error('Cannot resolve');
// read pathname from parent URL
// pathname taken to be part after leading "/"
let pathname;
if (parentUrl[parentProtocol.length + 1] === '/') {
// resolving to a :// so we need to read out the auth and host
if (parentProtocol !== 'file:') {
pathname = parentUrl.slice(parentProtocol.length + 2);
pathname = pathname.slice(pathname.indexOf('/') + 1);
}
else {
pathname = parentUrl.slice(8);
}
}
else {
// resolving to :/ so pathname is the /... part
pathname = parentUrl.slice(parentProtocol.length + 1);
}
if (relUrl[0] === '/')
return parentUrl.slice(0, parentUrl.length - pathname.length - 1) + relUrl;
// join together and split for removal of .. and . segments
// looping the string instead of anything fancy for perf reasons
// '../../../../../z' resolved to 'x/y' is just 'z'
const segmented = pathname.slice(0, pathname.lastIndexOf('/') + 1) + relUrl;
const output = [];
let segmentIndex = -1;
for (let i = 0; i < segmented.length; i++) {
// busy reading a segment - only terminate on '/'
if (segmentIndex !== -1) {
if (segmented[i] === '/') {
output.push(segmented.slice(segmentIndex, i + 1));
segmentIndex = -1;
}
}
// new segment - check if it is relative
else if (segmented[i] === '.') {
// ../ segment
if (segmented[i + 1] === '.' && (segmented[i + 2] === '/' || i + 2 === segmented.length)) {
output.pop();
i += 2;
}
// ./ segment
else if (segmented[i + 1] === '/' || i + 1 === segmented.length) {
i += 1;
}
else {
// the start of a new segment as below
segmentIndex = i;
}
}
// it is the start of a new segment
else {
segmentIndex = i;
}
}
// finish reading out the last segment
if (segmentIndex !== -1)
output.push(segmented.slice(segmentIndex));
return parentUrl.slice(0, parentUrl.length - pathname.length) + output.join('');
}
}
/*
* Package name maps implementation
*
* Reduced implementation - only a single scope level is supported
*
* To make lookups fast we pre-resolve the entire package name map
* and then match based on backtracked hash lookups
*
* path_prefix in scopes not supported
* nested scopes not supported
*/
function resolveUrl (relUrl, parentUrl) {
return resolveIfNotPlainOrUrl(relUrl, parentUrl) ||
relUrl.indexOf(':') !== -1 && relUrl ||
resolveIfNotPlainOrUrl('./' + relUrl, parentUrl);
}
function createPackageMap (json, baseUrl) {
if (json.path_prefix) {
baseUrl = resolveUrl(json.path_prefix, baseUrl);
if (baseUrl[baseUrl.length - 1] !== '/')
baseUrl += '/';
}
const basePackages = json.packages || {};
const scopes = {};
if (json.scopes) {
for (let scopeName in json.scopes) {
const scope = json.scopes[scopeName];
if (scope.path_prefix)
throw new Error('Scope path_prefix not currently supported');
if (scope.scopes)
throw new Error('Nested scopes not currently supported');
let resolvedScopeName = resolveUrl(scopeName, baseUrl);
if (resolvedScopeName[resolvedScopeName.length - 1] === '/')
resolvedScopeName = resolvedScopeName.substr(0, resolvedScopeName.length - 1);
scopes[resolvedScopeName] = scope.packages || {};
}
}
function getMatch (path, matchObj) {
let sepIndex = path.length;
do {
const segment = path.slice(0, sepIndex);
if (segment in matchObj)
return segment;
} while ((sepIndex = path.lastIndexOf('/', sepIndex - 1)) !== -1)
}
function applyPackages (id, packages, baseUrl) {
const pkgName = getMatch(id, packages);
if (pkgName) {
const pkg = packages[pkgName];
if (pkgName === id) {
if (typeof pkg === 'string')
return resolveUrl(pkg, baseUrl + pkgName + '/');
if (!pkg.main)
throw new Error('Package ' + pkgName + ' has no main');
return resolveUrl(
(pkg.path ? pkg.path + (pkg.path[pkg.path.length - 1] === '/' ? '' : '/') : pkgName + '/') + pkg.main,
baseUrl
);
}
else {
return resolveUrl(
(typeof pkg === 'string' || !pkg.path
? pkgName + '/'
: pkg.path + (pkg.path[pkg.path.length - 1] === '/' ? '' : '/')
) + id.slice(pkgName.length + 1)
, baseUrl);
}
}
}
return function (id, parentUrl) {
const scopeName = getMatch(parentUrl, scopes);
if (scopeName) {
const scopePackages = scopes[scopeName];
const packageResolution = applyPackages(id, scopePackages, scopeName + '/');
if (packageResolution)
return packageResolution;
}
return applyPackages(id, basePackages, baseUrl) || throwBare(id, parentUrl);
};
}
function throwBare (id, parentUrl) {
throw new Error('Unable to resolve bare specifier "' + id + (parentUrl ? '" from ' + parentUrl : '"'));
}
/*
* SystemJS Core
*
* Provides
* - System.import
* - System.register support for
* live bindings, function hoisting through circular references,
* reexports, dynamic import, import.meta.url, top-level await
* - System.getRegister to get the registration
* - Symbol.toStringTag support in Module objects
* - Hookable System.createContext to customize import.meta
* - System.onload(id, err?) handler for tracing / hot-reloading
*
* Core comes with no System.prototype.resolve or
* System.prototype.instantiate implementations
*/
const hasSymbol = typeof Symbol !== 'undefined';
const toStringTag = hasSymbol && Symbol.toStringTag;
const REGISTRY = hasSymbol ? Symbol() : '@';
function SystemJS () {
this[REGISTRY] = {};
}
const systemJSPrototype = SystemJS.prototype;
systemJSPrototype.import = function (id, parentUrl) {
const loader = this;
return Promise.resolve(loader.resolve(id, parentUrl))
.then(function (id) {
const load = getOrCreateLoad(loader, id);
return load.C || topLevelLoad(loader, load);
});
};
// Hookable createContext function -> allowing eg custom import meta
systemJSPrototype.createContext = function (parentId) {
return {
url: parentId
};
};
// onLoad(id, err) provided for tracing / hot-reloading
systemJSPrototype.onload = function () {};
let lastRegister;
systemJSPrototype.register = function (deps, declare) {
lastRegister = [deps, declare];
};
/*
* getRegister provides the last anonymous System.register call
*/
systemJSPrototype.getRegister = function () {
const _lastRegister = lastRegister;
lastRegister = undefined;
return _lastRegister;
};
function getOrCreateLoad (loader, id, firstParentUrl) {
let load = loader[REGISTRY][id];
if (load)
return load;
const importerSetters = [];
const ns = Object.create(null);
if (toStringTag)
Object.defineProperty(ns, toStringTag, { value: 'Module' });
let instantiatePromise = Promise.resolve()
.then(function () {
return loader.instantiate(id, firstParentUrl);
})
.then(function (registration) {
if (!registration)
throw new Error('Module ' + id + ' did not instantiate');
function _export (name, value) {
// note if we have hoisted exports (including reexports)
load.h = true;
let changed = false;
if (typeof name !== 'object') {
if (!(name in ns) || ns[name] !== value) {
ns[name] = value;
changed = true;
}
}
else {
for (let p in name) {
let value = name[p];
if (!(p in ns) || ns[p] !== value) {
ns[p] = value;
changed = true;
}
}
}
if (changed)
for (let i = 0; i < importerSetters.length; i++)
importerSetters[i](ns);
return value;
}
const declared = registration[1](_export, registration[1].length === 2 ? {
import: function (importId) {
return loader.import(importId, id);
},
meta: loader.createContext(id)
} : undefined);
load.e = declared.execute || function () {};
return [registration[0], declared.setters || []];
});
instantiatePromise = instantiatePromise.catch(function (err) {
loader.onload(load.id, err);
throw err;
});
const linkPromise = instantiatePromise
.then(function (instantiation) {
return Promise.all(instantiation[0].map(function (dep, i) {
const setter = instantiation[1][i];
return Promise.resolve(loader.resolve(dep, id))
.then(function (depId) {
const depLoad = getOrCreateLoad(loader, depId, id);
// depLoad.I may be undefined for already-evaluated
return Promise.resolve(depLoad.I)
.then(function () {
if (setter) {
depLoad.i.push(setter);
// only run early setters when there are hoisted exports of that module
// the timing works here as pending hoisted export calls will trigger through importerSetters
if (depLoad.h || !depLoad.I)
setter(depLoad.n);
}
return depLoad;
});
})
}))
.then(function (depLoads) {
load.d = depLoads;
});
});
// disable unhandled rejections
linkPromise.catch(function () {});
// Captial letter = a promise function
return load = loader[REGISTRY][id] = {
id: id,
// importerSetters, the setters functions registered to this dependency
// we retain this to add more later
i: importerSetters,
// module namespace object
n: ns,
// instantiate
I: instantiatePromise,
// link
L: linkPromise,
// whether it has hoisted exports
h: false,
// On instantiate completion we have populated:
// dependency load records
d: undefined,
// execution function
// set to NULL immediately after execution (or on any failure) to indicate execution has happened
// in such a case, pC should be used, and pLo, pLi will be emptied
e: undefined,
// On execution we have populated:
// the execution error if any
eE: undefined,
// in the case of TLA, the execution promise
E: undefined,
// On execution, pLi, pLo, e cleared
// Promise for top-level completion
C: undefined
};
}
function instantiateAll (loader, load, loaded) {
if (!loaded[load.id]) {
loaded[load.id] = true;
// load.L may be undefined for already-instantiated
return Promise.resolve(load.L)
.then(function () {
return Promise.all(load.d.map(function (dep) {
return instantiateAll(loader, dep, loaded);
}));
})
}
}
function topLevelLoad (loader, load) {
return load.C = instantiateAll(loader, load, {})
.then(function () {
return postOrderExec(loader, load, {});
})
.then(function () {
return load.n;
});
}
// the closest we can get to call(undefined)
const nullContext = Object.freeze(Object.create(null));
// returns a promise if and only if a top-level await subgraph
// throws on sync errors
function postOrderExec (loader, load, seen) {
if (seen[load.id])
return;
seen[load.id] = true;
if (!load.e) {
if (load.eE)
throw load.eE;
if (load.E)
return load.E;
return;
}
// deps execute first, unless circular
let depLoadPromises;
load.d.forEach(function (depLoad) {
{
try {
const depLoadPromise = postOrderExec(loader, depLoad, seen);
if (depLoadPromise)
(depLoadPromises = depLoadPromises || []).push(depLoadPromise);
}
catch (err) {
loader.onload(load.id, err);
throw err;
}
}
});
if (depLoadPromises) {
return Promise.all(depLoadPromises)
.then(doExec)
.catch(function (err) {
loader.onload(load.id, err);
throw err;
});
}
return doExec();
function doExec () {
try {
let execPromise = load.e.call(nullContext);
if (execPromise) {
execPromise = execPromise.then(function () {
load.C = load.n;
load.E = null; // indicates completion
loader.onload(load.id, null);
}, function () {
loader.onload(load.id, err);
throw err;
});
execPromise.catch(function () {});
return load.E = load.E || execPromise;
}
// (should be a promise, but a minify optimization to leave out Promise.resolve)
load.C = load.n;
loader.onload(load.id, null);
}
catch (err) {
loader.onload(load.id, err);
load.eE = err;
throw err;
}
finally {
load.L = load.I = undefined;
load.e = null;
}
}
}
envGlobal.System = new SystemJS();
/*
* Supports loading System.register via script tag injection
*/
let err$1;
if (typeof window !== 'undefined')
window.addEventListener('error', function (e) {
err$1 = e.error;
});
const systemRegister = systemJSPrototype.register;
systemJSPrototype.register = function (deps, declare) {
err$1 = undefined;
systemRegister.call(this, deps, declare);
};
systemJSPrototype.instantiate = function (url, firstParentUrl) {
const loader = this;
return new Promise(function (resolve, reject) {
const script = document.createElement('script');
script.charset = 'utf-8';
script.async = true;
script.addEventListener('error', function () {
reject(new Error('Error loading ' + url + (firstParentUrl ? ' from ' + firstParentUrl : '')));
});
script.addEventListener('load', function () {
document.head.removeChild(script);
// Note URL normalization issues are going to be a careful concern here
if (err$1)
return reject(err$1);
else
resolve(loader.getRegister());
});
script.src = url;
document.head.appendChild(script);
});
};
/*
* Supports loading System.register in workers
*/
if (hasSelf && typeof importScripts === 'function')
systemJSPrototype.instantiate = function (url) {
const loader = this;
return new Promise(function (resolve, reject) {
try {
importScripts(url);
}
catch (e) {
reject(e);
}
resolve(loader.getRegister());
});
};
/*
* SystemJS global script loading support
* Extra for the s.js build only
* (Included by default in system.js build)
*/
(function (global) {
const systemJSPrototype = System.constructor.prototype;
function getLastGlobalProp () {
// alternatively Object.keys(global).pop()
// but this may be faster (pending benchmarks)
let lastProp;
for (let p in global)
if (global.hasOwnProperty(p))
lastProp = p;
return lastProp;
}
let lastGlobalProp;
const impt = systemJSPrototype.import;
systemJSPrototype.import = function (id, parentUrl) {
lastGlobalProp = getLastGlobalProp();
return impt.call(this, id, parentUrl);
};
const emptyInstantiation = [[], function () { return {} }];
const getRegister = systemJSPrototype.getRegister;
systemJSPrototype.getRegister = function () {
const lastRegister = getRegister.call(this);
if (lastRegister)
return lastRegister;
// no registration -> attempt a global detection as difference from snapshot
// when multiple globals, we take the global value to be the last defined new global object property
// for performance, this will not support multi-version / global collisions as previous SystemJS versions did
// note in Edge, deleting and re-adding a global does not change its ordering
const globalProp = getLastGlobalProp();
if (lastGlobalProp === globalProp)
return emptyInstantiation;
lastGlobalProp = globalProp;
let globalExport;
try {
globalExport = global[globalProp];
}
catch (e) {
return emptyInstantiation;
}
return [[], function (_export) {
return { execute: function () { _export('default', globalExport); } };
}];
};
})(typeof self !== 'undefined' ? self : global);
/*
* Loads WASM based on file extension detection
* Assumes successive instantiate will handle other files
*/
const instantiate = systemJSPrototype.instantiate;
systemJSPrototype.instantiate = function (url, parent) {
if (url.slice(-5) !== '.wasm')
return instantiate.call(this, url, parent);
return fetch(url)
.then(function (res) {
if (!res.ok)
throw new Error(res.status + ' ' + res.statusText + ' ' + res.url + (parent ? ' loading from ' + parent : ''));
return WebAssembly.compileStreaming(res);
})
.then(function (module) {
const deps = [];
const setters = [];
const importObj = {};
// we can only set imports if supported (eg early Safari doesnt support)
if (WebAssembly.Module.imports)
WebAssembly.Module.imports(module).forEach(function (impt) {
const key = impt.module;
setters.push(function (m) {
importObj[key] = m;
});
if (deps.indexOf(key) === -1)
deps.push(key);
});
return [deps, function (_export) {
return {
setters: setters,
execute: function () {
_export(new WebAssembly.Instance(module, importObj).exports);
}
};
}];
});
};
/*
* Package name map support for SystemJS
*
* <script type="systemjs-packagemap">{}</script>
* OR
* <script type="systemjs-packagemap" src=package.json></script>
*
* Only supports loading the first package map
*/
let packageMapPromise, packageMapResolve;
if (typeof document !== 'undefined') {
const scripts = document.getElementsByTagName('script');
for (let i = 0; i < scripts.length; i++) {
const script = scripts[i];
if (script.type !== 'systemjs-packagemap')
continue;
if (!script.src) {
packageMapResolve = createPackageMap(JSON.parse(script.innerHTML), baseUrl);
packageMapPromise = Promise.resolve();
}
else {
packageMapPromise = fetch(script.src)
.then(function (res) {
return res.json();
})
.then(function (json) {
packageMapResolve = createPackageMap(json, script.src);
packageMapPromise = undefined;
}, function () {
packageMapResolve = throwBare;
packageMapPromise = undefined;
});
}
break;
}
}
if (!packageMapPromise)
packageMapResolve = throwBare;
systemJSPrototype.resolve = function (id, parentUrl) {
parentUrl = parentUrl || baseUrl;
const resolvedIfNotPlainOrUrl = resolveIfNotPlainOrUrl(id, parentUrl);
if (resolvedIfNotPlainOrUrl)
return resolvedIfNotPlainOrUrl;
if (id.indexOf(':') !== -1)
return id;
// now just left with plain
// (if not package map, packageMapResolve just throws)
if (packageMapPromise)
return packageMapPromise
.then(function () {
return packageMapResolve(id, parentUrl);
});
return packageMapResolve(id, parentUrl);
};
systemJSPrototype.get = function (id) {
const load = this[REGISTRY][id];
if (load && load.e === null && !load.E) {
if (load.eE)
return null;
return load.n;
}
};
// Delete function provided for hot-reloading use cases
systemJSPrototype.delete = function (id) {
const load = this.get(id);
if (load === undefined)
return false;
// remove from importerSetters
// (release for gc)
if (load && load.d)
load.d.forEach(function (depLoad) {
const importerIndex = depLoad.i.indexOf(load);
if (importerIndex !== -1)
depLoad.i.splice(importerIndex, 1);
});
return delete this[REGISTRY][id];
};
}());

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,76 @@
{
"_from": "systemjs@2.0.0",
"_id": "systemjs@2.0.0",
"_inBundle": false,
"_integrity": "sha512-DQooqEwNevJ/3sYYfzbCzrdlCIuuicqDVCNP5JpMxIj7j+cw36VJPP4djH9Xd7OBU3G/LJNNQPROpAHwlCxBMw==",
"_location": "/systemjs",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "systemjs@2.0.0",
"name": "systemjs",
"escapedName": "systemjs",
"rawSpec": "2.0.0",
"saveSpec": null,
"fetchSpec": "2.0.0"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/systemjs/-/systemjs-2.0.0.tgz",
"_shasum": "77b4420cbeaa852fcdf2f8faafbaf76d2218692c",
"_spec": "systemjs@2.0.0",
"_where": "/Users/michael/Projects/unpkg.com",
"author": {
"name": "Guy Bedford"
},
"bugs": {
"url": "https://github.com/systemjs/systemjs/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "Dynamic ES module loader",
"devDependencies": {
"@babel/cli": "^7.0.0-rc.1",
"@babel/core": "^7.0.0-rc.1",
"@babel/plugin-syntax-import-meta": "^7.0.0-rc.1",
"@babel/plugin-transform-modules-systemjs": "^7.0.0-rc.1",
"bluebird": "^3.5.1",
"esm": "^3.0.77",
"mocha": "^5.2.0",
"rollup": "^0.64.1",
"rollup-plugin-replace": "^2.0.0",
"terser": "^3.8.1",
"whatwg-fetch": "^2.0.4"
},
"files": [
"dist"
],
"homepage": "https://github.com/systemjs/systemjs#readme",
"license": "MIT",
"name": "systemjs",
"repository": {
"type": "git",
"url": "git://github.com/systemjs/systemjs.git"
},
"scripts": {
"build": "npm run build:systemjs && npm run build:sjs && npm run min && npm run build:extras",
"build:extras": "bash minify-extras.sh",
"build:sjs": "rollup -c --environment sjs",
"build:systemjs": "rollup -c",
"footprint": "npm run footprint:systemjs && npm run footprint:sjs",
"footprint:sjs": "terser dist/s.js -c passes=2 -m | gzip -9f | wc -c",
"footprint:systemjs": "terser dist/system.js -c passes=2 -m | gzip -9f | wc -c",
"min": "npm run min:systemjs && npm run min:sjs",
"min:sjs": "cd dist && terser s.js -c passes=2 -m --source-map -o s.min.js",
"min:systemjs": "cd dist && terser system.js -c passes=2 -m --source-map --comments \"/SystemJS \\d/\" -o system.min.js",
"prepublish": "npm run build",
"test": "mocha -b -r esm",
"test:rebuild": "babel test/fixtures/es-modules --plugins=@babel/plugin-syntax-import-meta,@babel/plugin-transform-modules-systemjs --out-dir test/fixtures/register-modules",
"test:sjs": "mocha test/test-production.js -u tdd --reporter dot",
"test:systemjs": "mocha test/test-traceur.js -u tdd --reporter dot"
},
"version": "2.0.0"
}