aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-10-10 03:50:11 +0200
committerFlorian Dold <florian.dold@gmail.com>2016-10-10 03:50:11 +0200
commit9af485a584e47fd503ed5c62b9f6482574715f1e (patch)
tree687abbcff412bd4ce5c51d51de030a06e3963cf5
Squashed 'thirdparty/systemjs/' content from commit 5ed69b6
git-subtree-dir: thirdparty/systemjs git-subtree-split: 5ed69b6344e8fc1cd43bf758350b2236f57e1499
-rw-r--r--.agignore1
-rw-r--r--.gitignore3
-rw-r--r--.travis.yml14
-rw-r--r--LICENSE10
-rwxr-xr-xMakefile186
-rw-r--r--README.md149
-rw-r--r--bench/cjs-sample/cjs.js949
-rw-r--r--bench/config-example/config.js1474
-rw-r--r--bench/config-example/normalize-data.js69
-rw-r--r--bench/config-example/pkg-configs.js972
-rw-r--r--bench/get-cjs-deps.js63
-rw-r--r--bench/normalize-perf.js67
-rw-r--r--bower.json17
-rw-r--r--dist/system-csp-production.js6
-rw-r--r--dist/system-csp-production.js.map1
-rw-r--r--dist/system-csp-production.src.js4536
-rw-r--r--dist/system-polyfills.js5
-rw-r--r--dist/system-polyfills.js.map1
-rw-r--r--dist/system-polyfills.src.js1277
-rw-r--r--dist/system-register-only.js5
-rw-r--r--dist/system-register-only.js.map1
-rw-r--r--dist/system-register-only.src.js2198
-rw-r--r--dist/system.js6
-rw-r--r--dist/system.js.map1
-rw-r--r--dist/system.src.js5153
-rw-r--r--docs/config-api.md292
-rw-r--r--docs/creating-plugins.md84
-rw-r--r--docs/es6-modules-overview.md108
-rw-r--r--docs/module-formats.md228
-rw-r--r--docs/overview.md166
-rw-r--r--docs/production-workflows.md83
-rw-r--r--docs/system-api.md141
-rw-r--r--index.js48
-rw-r--r--lib/alias.js38
-rw-r--r--lib/amd-helpers.js245
-rw-r--r--lib/amd.js42
-rw-r--r--lib/bundles.js73
-rw-r--r--lib/cjs-helpers.js43
-rw-r--r--lib/cjs.js138
-rw-r--r--lib/conditionals.js161
-rw-r--r--lib/core.js504
-rw-r--r--lib/createSystem.js3
-rw-r--r--lib/depCache.js44
-rw-r--r--lib/esm.js161
-rw-r--r--lib/global-eval.js142
-rw-r--r--lib/global-helpers.js147
-rw-r--r--lib/global.js70
-rw-r--r--lib/legacy-transpiler.js86
-rw-r--r--lib/loader-wrapper-end.js6
-rw-r--r--lib/loader-wrapper-start.js913
-rw-r--r--lib/meta.js155
-rw-r--r--lib/package.js596
-rw-r--r--lib/paths.js42
-rw-r--r--lib/perf.js227
-rw-r--r--lib/plugins.js263
-rw-r--r--lib/polyfills-bootstrap.js2
-rw-r--r--lib/proto.js268
-rw-r--r--lib/register.js633
-rw-r--r--lib/scriptLoader.js196
-rw-r--r--lib/scriptOnly.js17
-rw-r--r--lib/system-fetch.js125
-rw-r--r--lib/system-only-resolve.js24
-rw-r--r--lib/url-polyfill.js64
-rw-r--r--lib/wrapper-end.js47
-rw-r--r--lib/wrapper-start.js2
-rw-r--r--package.json34
-rw-r--r--test/test-babel-runtime.html44
-rw-r--r--test/test-babel.html29
-rw-r--r--test/test-babel.js3
-rw-r--r--test/test-csp-inline.html61
-rw-r--r--test/test-csp.html280
-rw-r--r--test/test-jsextensions.html112
-rw-r--r--test/test-register-only.html45
-rw-r--r--test/test-tracer.html71
-rw-r--r--test/test-traceur.html34
-rw-r--r--test/test-traceur.js3
-rw-r--r--test/test-typescript.html31
-rw-r--r--test/test-typescript.js4
-rw-r--r--test/test.js1462
-rw-r--r--test/tests/#.js1
-rw-r--r--test/tests/advanced-plugin.js20
-rw-r--r--test/tests/all-circular1.js9
-rw-r--r--test/tests/all-circular2.js3
-rw-r--r--test/tests/all-circular3.js10
-rw-r--r--test/tests/all-circular4.js5
-rw-r--r--test/tests/all-layers1.js3
-rw-r--r--test/tests/all-layers2.js20
-rw-r--r--test/tests/all-layers3.js17
-rw-r--r--test/tests/all-layers4.js1
-rw-r--r--test/tests/amd-bundle.js6
-rw-r--r--test/tests/amd-circular1.js7
-rw-r--r--test/tests/amd-circular2.js6
-rw-r--r--test/tests/amd-cjs-module.js4
-rw-r--r--test/tests/amd-contextual.js6
-rw-r--r--test/tests/amd-dep-A.js1
-rw-r--r--test/tests/amd-dep-B.js1
-rw-r--r--test/tests/amd-dep.js3
-rw-r--r--test/tests/amd-dynamic-require.js19
-rw-r--r--test/tests/amd-dynamic.js3
-rw-r--r--test/tests/amd-extra-deps.js7
-rw-r--r--test/tests/amd-format.js18
-rw-r--r--test/tests/amd-module-2.js6
-rw-r--r--test/tests/amd-module-3.js13
-rw-r--r--test/tests/amd-module-bom.js4
-rw-r--r--test/tests/amd-module.js6
-rw-r--r--test/tests/amd-require.js3
-rw-r--r--test/tests/amd-simplified-cjs-aliased-require1.js7
-rw-r--r--test/tests/amd-simplified-cjs-aliased-require2.js8
-rw-r--r--test/tests/anon-named.js10
-rw-r--r--test/tests/async.js5
-rw-r--r--test/tests/bootstrap@3.1.1/test.coffee1
-rw-r--r--test/tests/branch-boolean.js1
-rw-r--r--test/tests/branch-ie.js1
-rw-r--r--test/tests/bundle.js7
-rw-r--r--test/tests/cjs-circular1.js4
-rw-r--r--test/tests/cjs-circular2.js4
-rw-r--r--test/tests/cjs-exports-bom.js1
-rw-r--r--test/tests/cjs-exports-dep.js1
-rw-r--r--test/tests/cjs-exports.js6
-rw-r--r--test/tests/cjs-format.js4
-rw-r--r--test/tests/cjs-globals.js3
-rw-r--r--test/tests/cjs-loading-plugin.js1
-rw-r--r--test/tests/cjs-module-bom.js1
-rw-r--r--test/tests/cjs-named-export.js5
-rw-r--r--test/tests/cjs-process.js3
-rw-r--r--test/tests/cjs-resolve.js1
-rw-r--r--test/tests/cjs-this.js2
-rw-r--r--test/tests/common-js-dep.js1
-rw-r--r--test/tests/common-js-module.js2
-rw-r--r--test/tests/commonjs-d.js1
-rw-r--r--test/tests/commonjs-d2.js1
-rw-r--r--test/tests/commonjs-globals.js1
-rw-r--r--test/tests/commonjs-requires.js40
-rw-r--r--test/tests/commonjs-variation.js5
-rw-r--r--test/tests/commonjs-variation2.js8
-rw-r--r--test/tests/compiled.coffee1
-rw-r--r--test/tests/compiler-plugin.js4
-rw-r--r--test/tests/compiler-test.coffee1
-rw-r--r--test/tests/connected-tree/a.js9
-rw-r--r--test/tests/connected-tree/b.js6
-rw-r--r--test/tests/connected-tree/c.js3
-rw-r--r--test/tests/contextual-map-dep.js1
-rw-r--r--test/tests/contextual-test/contextual-map.js1
-rw-r--r--test/tests/cs-loader.js3
-rw-r--r--test/tests/cs/dep.js1
-rw-r--r--test/tests/cs/main.js1
-rw-r--r--test/tests/csp/integrity.js5
-rw-r--r--test/tests/csp/nonce.js3
-rw-r--r--test/tests/csp/nonce2.js3
-rw-r--r--test/tests/css.css3
-rw-r--r--test/tests/css.js3
-rw-r--r--test/tests/deep/deep-dep.js1
-rw-r--r--test/tests/deep/deep.js1
-rw-r--r--test/tests/default1-dep.js1
-rw-r--r--test/tests/default1.js3
-rw-r--r--test/tests/default2.js1
-rw-r--r--test/tests/default3.js1
-rw-r--r--test/tests/dep.js1
-rw-r--r--test/tests/duplicateDeps/m1.js23
-rw-r--r--test/tests/duplicateDeps/m2.js13
-rw-r--r--test/tests/eaa-amd.js3
-rw-r--r--test/tests/eaa-es6.js1
-rw-r--r--test/tests/empty-es6.js3
-rw-r--r--test/tests/ep/some-repo/main.js1
-rw-r--r--test/tests/error-loader.js1
-rw-r--r--test/tests/error-loader2.js1
-rw-r--r--test/tests/error.js1
-rw-r--r--test/tests/es-module-flag.js3
-rw-r--r--test/tests/es-named-import-cjs-cjs.js3
-rw-r--r--test/tests/es-named-import-cjs.js2
-rw-r--r--test/tests/es6-and-amd.js2
-rw-r--r--test/tests/es6-circular1.js10
-rw-r--r--test/tests/es6-circular2.js3
-rw-r--r--test/tests/es6-cjs-named-export.js1
-rw-r--r--test/tests/es6-detection1.js1
-rw-r--r--test/tests/es6-format.js6
-rw-r--r--test/tests/es6-import-star-amd.js3
-rw-r--r--test/tests/es6-loading-amd-dep.js3
-rw-r--r--test/tests/es6-loading-amd.js9
-rw-r--r--test/tests/es6-plugin.js3
-rw-r--r--test/tests/esm-dep.js5
-rw-r--r--test/tests/esm-with-deps.js1
-rw-r--r--test/tests/export-star.js2
-rw-r--r--test/tests/foo.js10
-rw-r--r--test/tests/global-dep.js5
-rw-r--r--test/tests/global-encapsulation.js3
-rw-r--r--test/tests/global-exports-array.js5
-rw-r--r--test/tests/global-inaccessible-props.js8
-rw-r--r--test/tests/global-inline-dep.js7
-rw-r--r--test/tests/global-inline-export.js9
-rw-r--r--test/tests/global-multi-diff.js3
-rw-r--r--test/tests/global-multi.js6
-rw-r--r--test/tests/global-shim-amd.js6
-rw-r--r--test/tests/global-shim-config-dep.js1
-rw-r--r--test/tests/global-shim-config-exports.js1
-rw-r--r--test/tests/global-shim-config.js3
-rw-r--r--test/tests/global-single-compiled.js9
-rw-r--r--test/tests/global-single.js1
-rw-r--r--test/tests/global-with-export.js5
-rw-r--r--test/tests/global.js6
-rw-r--r--test/tests/group-test.js34
-rw-r--r--test/tests/hbs.hbs1
-rw-r--r--test/tests/inline-depends-dep.js1
-rw-r--r--test/tests/inline-depends.js1
-rw-r--r--test/tests/jquery-named.js3
-rw-r--r--test/tests/jquery.js2
-rw-r--r--test/tests/legacy-plugin.js5
-rw-r--r--test/tests/loader-scoping.js1
-rw-r--r--test/tests/main-bundle.js3
-rw-r--r--test/tests/main-dep.js1
-rw-r--r--test/tests/main.js1
-rw-r--r--test/tests/map-test-dep.js1
-rw-r--r--test/tests/map-test.js1
-rw-r--r--test/tests/map-test/sub.js1
-rw-r--r--test/tests/map-version.js1
-rw-r--r--test/tests/meta-deps.js21
-rw-r--r--test/tests/meta-override.js2
-rw-r--r--test/tests/mixed-bundle.js68
-rw-r--r--test/tests/modA.js7
-rw-r--r--test/tests/modC.js5
-rw-r--r--test/tests/module-name.js8
-rw-r--r--test/tests/module.js3
-rw-r--r--test/tests/multiple-anonymous.js14
-rw-r--r--test/tests/mypackage/index.js1
-rw-r--r--test/tests/mypackage/lib/bar.js2
-rw-r--r--test/tests/mypackage/src/foo.js3
-rw-r--r--test/tests/nameddefine.js14
-rw-r--r--test/tests/no-default-ext/file.ext1
-rw-r--r--test/tests/normalize-hook-test.js1
-rw-r--r--test/tests/out.js19
-rw-r--r--test/tests/package-local-alias/index-cjs.js6
-rw-r--r--test/tests/package-local-alias/index-default-cjs.js10
-rw-r--r--test/tests/package-local-alias/index-default-esm.js10
-rw-r--r--test/tests/package-local-alias/index-esm.js5
-rw-r--r--test/tests/package-local-alias/local/index-cjs.js1
-rw-r--r--test/tests/package-local-alias/local/index-default-cjs.js1
-rw-r--r--test/tests/package-local-alias/local/index-default-esm.js2
-rw-r--r--test/tests/package-local-alias/local/index-esm.js1
-rw-r--r--test/tests/path/deep.js1
-rw-r--r--test/tests/plugin-dep.js8
-rw-r--r--test/tests/plugin@1.2.3/plugin.js3
-rw-r--r--test/tests/reflection.js1
-rw-r--r--test/tests/register-circular1.js24
-rw-r--r--test/tests/register-circular2.js14
-rw-r--r--test/tests/register-default-extension.js8
-rw-r--r--test/tests/register-regex-2.js15
-rw-r--r--test/tests/register-regex.js18
-rw-r--r--test/tests/registerdynamic-main.js11
-rw-r--r--test/tests/registerdynamic-notbundled.js5
-rw-r--r--test/tests/reldynamic.js5
-rw-r--r--test/tests/reldynamicdep.js1
-rw-r--r--test/tests/shared-dep-bundles/a.js33
-rw-r--r--test/tests/shared-dep-bundles/b.js33
-rw-r--r--test/tests/shim-map-test-dep.js1
-rw-r--r--test/tests/shim-package/shim-map-test.js1
-rw-r--r--test/tests/some-json.json3
-rw-r--r--test/tests/some-text.txt1
-rw-r--r--test/tests/star-dep.js1
-rw-r--r--test/tests/subcontextual-map/submodule.js3
-rw-r--r--test/tests/subcontextual-mapdep.js1
-rw-r--r--test/tests/test.css1
-rw-r--r--test/tests/testpkg/depcache-test.js1
-rw-r--r--test/tests/testpkg/dir/index.js2
-rw-r--r--test/tests/testpkg/dir/self-load.js2
-rw-r--r--test/tests/testpkg/dir2/index.json3
-rw-r--r--test/tests/testpkg/env-module-browser.js1
-rw-r--r--test/tests/testpkg/env-module.js1
-rw-r--r--test/tests/testpkg/index.js1
-rw-r--r--test/tests/testpkg/interpolate.js1
-rw-r--r--test/tests/testpkg/json.js4
-rw-r--r--test/tests/testpkg/json.json3
-rw-r--r--test/tests/testpkg/polate.js1
-rw-r--r--test/tests/testpkg/self-load.js2
-rw-r--r--test/tests/testpkg/self.js1
-rw-r--r--test/tests/testpkg/system.json28
-rw-r--r--test/tests/testpkg/test.ts1
-rw-r--r--test/tests/testpkg2.json6
-rw-r--r--test/tests/testpkg2/asdf.asdf.js3
-rw-r--r--test/tests/typescript.ts1
-rw-r--r--test/tests/umd-dep.js3
-rw-r--r--test/tests/umd.js10
-rw-r--r--test/tests/versioned@2.0.3.js1
-rw-r--r--test/tests/wildcard-test/2.js1
-rw-r--r--test/tests/wildcard-test/2/sub.js1
-rw-r--r--test/tests/wildcard-test/first.js1
-rw-r--r--test/tests/with-global-deps.js1
-rw-r--r--test/tests/with-runtime-babel.js16
-rw-r--r--test/tests/with-runtime-traceur.js14
-rw-r--r--test/tests/worker-babel.js14
-rw-r--r--test/tests/worker-traceur.js12
-rw-r--r--test/tests/worker-typescript.js16
-rw-r--r--test/tests/wrapper.js1
-rw-r--r--test/tests/zero@0.js1
293 files changed, 27198 insertions, 0 deletions
diff --git a/.agignore b/.agignore
new file mode 100644
index 000000000..a261f2917
--- /dev/null
+++ b/.agignore
@@ -0,0 +1 @@
+dist/*
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000..76a84faec
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+node_modules
+bower_components
+.DS_Store
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 000000000..b09421142
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,14 @@
+git:
+ depth: 1
+language: node_js
+node_js:
+ - '0.10'
+ - '0.12'
+ - '4'
+ - '6'
+
+before_install:
+ - npm install
+script:
+ - npm run build
+ - npm run test
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 000000000..1e467a8cf
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,10 @@
+MIT License
+-----------
+
+Copyright (C) 2013-2016 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.
diff --git a/Makefile b/Makefile
new file mode 100755
index 000000000..cc002c540
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,186 @@
+VERSION = $(shell cat package.json | sed -n 's/.*"version": "\([^"]*\)",/\1/p')
+
+define BANNER
+/*
+ * SystemJS v$(VERSION)
+ */
+endef
+export BANNER
+
+define POLYFILLS_BANNER
+/*
+ * SystemJS Promise Polyfill
+ */
+endef
+export POLYFILLS_BANNER
+
+define STANDARD_VERSION
+
+System.version = '$(VERSION) Standard';
+endef
+export STANDARD_VERSION
+
+define REGISTER_VERSION
+
+System.version = '$(VERSION) Register Only';
+endef
+export REGISTER_VERSION
+
+define CSP_VERSION
+
+System.version = '$(VERSION) CSP';
+endef
+export CSP_VERSION
+
+compile: clean-compile dist/system.src.js dist/system.perf.js dist/system-csp-production.src.js dist/system-register-only.src.js
+build: clean dist/system.js dist/system-csp-production.js dist/system-register-only.js dist/system-polyfills.js
+
+version:
+ @echo $(VERSION)
+
+footprint: build
+ @cat dist/system.js | gzip -9f | wc -c
+ @cat dist/system-csp-production.js | gzip -9f | wc -c
+ @cat dist/system-register-only.js | gzip -9f | wc -c
+ @cat dist/system-polyfills.js | gzip -9f | wc -c
+
+clean-compile:
+ @rm -f dist/system.src.js dist/system.perf.js dist/system-csp-production.src.js
+
+clean:
+ @rm -f dist/*
+
+test: compile
+ open test/test-traceur.html test/test-traceur-runtime.html
+ sleep 0.1
+ open test/test-babel.html test/test-babel-runtime.html
+ sleep 0.1
+ open test/test-typescript.html
+ sleep 0.1
+ open test/test-csp.html test/test-tracer.html
+
+dist/system-polyfills.js: dist/system-polyfills.src.js
+ cd dist && ../node_modules/.bin/uglifyjs $(subst dist/,,$<) --compress drop_console --preamble "$$POLYFILLS_BANNER" --mangle --source-map system-polyfills.js.map >> $(subst dist/,,$@) || rm $(subst dist/,,$@)
+
+dist/%.js: dist/%.src.js
+ cd dist && ../node_modules/.bin/uglifyjs $(subst dist/,,$<) --compress drop_console --preamble "$$BANNER" --mangle --source-map $*.js.map >> $(subst dist/,,$@) || rm $(subst dist/,,$@)
+
+dist/system.src.js: lib/*.js
+ ( echo "$$BANNER"; \
+ cat \
+ lib/wrapper-start.js \
+ lib/url-polyfill.js \
+ lib/loader-wrapper-start.js \
+ lib/system-fetch.js \
+ lib/legacy-transpiler.js \
+ lib/proto.js \
+ lib/global-eval.js \
+ lib/core.js \
+ lib/package.js \
+ lib/scriptLoader.js \
+ lib/register.js \
+ lib/esm.js \
+ lib/global.js \
+ lib/global-helpers.js \
+ lib/cjs.js \
+ lib/cjs-helpers.js \
+ lib/amd-helpers.js \
+ lib/amd.js \
+ lib/plugins.js \
+ lib/conditionals.js \
+ lib/alias.js \
+ lib/meta.js \
+ lib/bundles.js \
+ lib/depCache.js \
+ lib/createSystem.js \
+ ; echo "$$STANDARD_VERSION" ; cat \
+ lib/loader-wrapper-end.js \
+ lib/wrapper-end.js \
+ ) > $@;
+
+dist/system.perf.js: lib/*.js
+ ( echo "$$BANNER"; \
+ cat \
+ lib/wrapper-start.js \
+ lib/url-polyfill.js \
+ lib/loader-wrapper-start.js \
+ lib/legacy-transpiler.js \
+ lib/proto.js \
+ lib/perf.js \
+ lib/global-eval.js \
+ lib/core.js \
+ lib/package.js \
+ lib/scriptLoader.js \
+ lib/register.js \
+ lib/esm.js \
+ lib/global.js \
+ lib/global-helpers.js \
+ lib/cjs.js \
+ lib/cjs-helpers.js \
+ lib/amd-helpers.js \
+ lib/amd.js \
+ lib/plugins.js \
+ lib/conditionals.js \
+ lib/alias.js \
+ lib/meta.js \
+ lib/bundles.js \
+ lib/depCache.js \
+ lib/createSystem.js \
+ ; echo "$$STANDARD_VERSION" ; cat \
+ lib/loader-wrapper-end.js \
+ lib/wrapper-end.js \
+ ) > $@;
+
+dist/system-csp-production.src.js: lib/*.js
+ ( echo "$$BANNER"; \
+ cat \
+ lib/wrapper-start.js \
+ lib/url-polyfill.js \
+ lib/loader-wrapper-start.js \
+ lib/proto.js \
+ lib/system-fetch.js \
+ lib/core.js \
+ lib/package.js \
+ lib/scriptLoader.js \
+ lib/register.js \
+ lib/global-helpers.js \
+ lib/cjs-helpers.js \
+ lib/amd-helpers.js \
+ lib/plugins.js \
+ lib/conditionals.js \
+ lib/alias.js \
+ lib/meta.js \
+ lib/bundles.js \
+ lib/depCache.js \
+ lib/scriptOnly.js \
+ lib/createSystem.js \
+ ; echo "$$CSP_VERSION" ; cat \
+ lib/loader-wrapper-end.js \
+ lib/wrapper-end.js \
+ ) > $@;
+
+dist/system-register-only.src.js: lib/*.js
+ ( echo "$$BANNER"; \
+ cat \
+ lib/url-polyfill.js \
+ lib/loader-wrapper-start.js \
+ lib/proto.js \
+ lib/system-only-resolve.js \
+ lib/scriptLoader.js \
+ lib/register.js \
+ lib/bundles.js \
+ lib/scriptOnly.js \
+ lib/createSystem.js \
+ ; echo "$$REGISTER_VERSION" ; cat \
+ lib/loader-wrapper-end.js \
+ ) > $@;
+
+dist/system-polyfills.src.js: lib/*.js
+ ( echo "$$POLYFILLS_BANNER"; \
+ echo "(function(define) {"; \
+ echo ""; \
+ cat \
+ node_modules/when/es6-shim/Promise.js \
+ lib/polyfills-bootstrap.js; \
+ echo "})();" \
+ ) > $@; \ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 000000000..afe998a27
--- /dev/null
+++ b/README.md
@@ -0,0 +1,149 @@
+SystemJS
+========
+
+[![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)
+[![Support](https://supporterhq.com/api/b/33df4abbec4d39260f49015d2457eafe/SystemJS)](https://supporterhq.com/support/33df4abbec4d39260f49015d2457eafe/SystemJS)
+
+Universal dynamic module loader - loads ES6 modules, AMD, CommonJS and global scripts in the browser and NodeJS.
+
+* [Loads any module format](docs/module-formats.md) with [exact circular reference and binding support](https://github.com/ModuleLoader/es6-module-loader/blob/v0.17.0/docs/circular-references-bindings.md).
+* Loads [ES6 modules compiled into the `System.register` bundle format for production](docs/production-workflows.md), maintaining circular references support.
+* Supports RequireJS-style [map](docs/overview.md#map-config), [paths](https://github.com/ModuleLoader/es6-module-loader/blob/master/docs/loader-config.md#paths-implementation), [bundles](docs/production-workflows.md#bundle-extension) and [global shims](docs/module-formats.md#shim-dependencies).
+* [Loader plugins](docs/overview.md#plugin-loaders) allow custom transpilation or asset loading.
+
+Built to the format ES6-specified loader API from [ES6 Specification Draft Rev 27, Section 15](http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts#august_24_2014_draft_rev_27),
+and will be updated to the [WhatWG loader API](https://whatwg.github.io/loader/) as soon as it can be considered stable for implementation.
+
+~19KB minified and gzipped, runs in IE8+ and NodeJS.
+
+For discussion, join the [Gitter Room](https://gitter.im/systemjs/systemjs).
+
+Documentation
+---
+
+* [ES6 Modules Overview](docs/es6-modules-overview.md)
+* [SystemJS Overview](docs/overview.md)
+* [Config API](docs/config-api.md)
+* [Module Formats](docs/module-formats.md)
+* [Production Workflows](docs/production-workflows.md)
+* [System API](docs/system-api.md)
+* [Creating Plugins](docs/creating-plugins.md)
+
+Basic Use
+---
+
+### Browser
+
+```html
+<script src="system.js"></script>
+<script>
+ // set our baseURL reference path
+ SystemJS.config({
+ baseURL: '/js'
+ });
+
+ // loads /js/main.js
+ SystemJS.import('main.js');
+</script>
+```
+
+The above will support loading all module formats, including ES Modules transpiled into the System.register format.
+
+To load ES6 code with in-browser transpilation, configure one of the following transpiler plugins:
+
+* [Babel](https://github.com/systemjs/plugin-babel)
+* [TypeScript](https://github.com/frankwallis/plugin-typescript)
+* [Traceur](http://github.com/systemjs/plugin-traceur)
+
+### Promise Polyfill
+
+SystemJS relies on `Promise` being present in the environment.
+
+For the best performance in IE and older browsers, it is advisable to load a polyfill like [Bluebird](https://github.com/petkaantonov/bluebird) or [es6-promise](https://github.com/stefanpenner/es6-promise) before SystemJS.
+
+Otherwise, when Promise is not available, SystemJS will attempt to load the `system-polyfills.js` file located in the dist folder which contains the when.js Promise polyfill.
+
+### NodeJS
+
+To load modules in NodeJS, install SystemJS with:
+
+```
+ npm install systemjs
+```
+
+If transpiling ES6, also install the transpiler plugin, following the instructions from the transpiler project page.
+
+We can then load modules equivalently in NodeJS as we do in the browser:
+
+```javascript
+var SystemJS = require('systemjs');
+
+// loads './app.js' from the current directory
+SystemJS.import('./app.js').then(function(m) {
+ console.log(m);
+});
+```
+
+If you are using jspm as a package manager you will also need to load the generated configuration.
+The best way to do this in node is to get your `System` instance through jspm, which will automatically load your config correctly for you:
+
+```js
+var Loader = require('jspm').Loader;
+var SystemJS = new Loader();
+
+SystemJS.import('lodash').then(function (_) {
+ console.log(_);
+});
+```
+
+### Plugins
+
+Supported loader plugins:
+
+* [CSS](https://github.com/systemjs/plugin-css)
+* [LESS](https://github.com/systemjs/plugin-less)
+* [Image](https://github.com/systemjs/plugin-image)
+* [JSON](https://github.com/systemjs/plugin-json)
+* [Text](https://github.com/systemjs/plugin-text)
+* [Node Binary](https://github.com/systemjs/plugin-node-binary)
+
+Additional Plugins:
+
+* [Audio](https://github.com/ozsay/plugin-audio)
+* [CoffeeScript](https://github.com/forresto/plugin-coffee)
+* [Ember Handlebars](https://github.com/n-fuse/plugin-ember-hbs)
+* [Handlebars](https://github.com/davis/plugin-hbs)
+* [HTML](https://github.com/Hypercubed/systemjs-plugin-html/)
+* [Image (lazy)](https://github.com/laurentgoudet/plugin-lazyimage)
+* [Jade](https://github.com/johnsoftek/plugin-jade)
+* [Jade VirtualDOM](https://github.com/WorldMaker/system-jade-virtualdom)
+* [jst](https://github.com/podio/plugin-jst)
+* [JSX](https://github.com/floatdrop/plugin-jsx)
+* [Markdown](https://github.com/guybedford/plugin-md)
+* [raw](https://github.com/matthewbauer/plugin-raw)
+* [SASS](https://github.com/screendriver/plugin-sass)
+* [SCSS](https://github.com/kevcjones/plugin-scss)
+* [sofe](https://github.com/CanopyTax/sofe)
+* [SVG](https://github.com/vuzonp/systemjs-plugin-svg)
+* [WebFont](https://github.com/guybedford/plugin-font)
+* [WebWorkers](https://github.com/casperlamboo/plugin-worker)
+* [YAML](https://github.com/tb/plugin-yaml)
+
+Guides:
+
+* [Using plugins](docs/overview.md#plugin-loaders)
+* [Creating plugins](docs/creating-plugins.md)
+
+#### Running the tests
+
+To install the dependencies correctly, run `bower install` from the root of the repo, then open `test/test.html` in a browser with a local server
+or file access flags enabled.
+
+License
+---
+
+MIT
+
+[travis-url]: https://travis-ci.org/systemjs/systemjs
+[travis-image]: https://travis-ci.org/systemjs/systemjs.svg?branch=master
diff --git a/bench/cjs-sample/cjs.js b/bench/cjs-sample/cjs.js
new file mode 100644
index 000000000..376672579
--- /dev/null
+++ b/bench/cjs-sample/cjs.js
@@ -0,0 +1,949 @@
+/**
+ * Copyright 2013-present, Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD-style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ *
+ * @providesModule ReactDOMComponent
+ */
+
+/* global hasOwnProperty:true */
+
+'use strict';
+
+var _assign = require('object-assign');
+
+var AutoFocusUtils = require('./AutoFocusUtils');
+var CSSPropertyOperations = require('./CSSPropertyOperations');
+var DOMLazyTree = require('./DOMLazyTree');
+var DOMNamespaces = require('./DOMNamespaces');
+var DOMProperty = require('./DOMProperty');
+var DOMPropertyOperations = require('./DOMPropertyOperations');
+var EventConstants = require('./EventConstants');
+var EventPluginHub = require('./EventPluginHub');
+var EventPluginRegistry = require('./EventPluginRegistry');
+var ReactBrowserEventEmitter = require('./ReactBrowserEventEmitter');
+var ReactComponentBrowserEnvironment = require('./ReactComponentBrowserEnvironment');
+var ReactDOMButton = require('./ReactDOMButton');
+var ReactDOMComponentFlags = require('./ReactDOMComponentFlags');
+var ReactDOMComponentTree = require('./ReactDOMComponentTree');
+var ReactDOMInput = require('./ReactDOMInput');
+var ReactDOMOption = require('./ReactDOMOption');
+var ReactDOMSelect = require('./ReactDOMSelect');
+var ReactDOMTextarea = require('./ReactDOMTextarea');
+var ReactInstrumentation = require('./ReactInstrumentation');
+var ReactMultiChild = require('./ReactMultiChild');
+var ReactServerRenderingTransaction = require('./ReactServerRenderingTransaction');
+
+var emptyFunction = require('fbjs/lib/emptyFunction');
+var escapeTextContentForBrowser = require('./escapeTextContentForBrowser');
+var invariant = require('fbjs/lib/invariant');
+var isEventSupported = require('./isEventSupported');
+var keyOf = require('fbjs/lib/keyOf');
+var shallowEqual = require('fbjs/lib/shallowEqual');
+var validateDOMNesting = require('./validateDOMNesting');
+var warning = require('fbjs/lib/warning');
+
+var Flags = ReactDOMComponentFlags;
+var deleteListener = EventPluginHub.deleteListener;
+var getNode = ReactDOMComponentTree.getNodeFromInstance;
+var listenTo = ReactBrowserEventEmitter.listenTo;
+var registrationNameModules = EventPluginRegistry.registrationNameModules;
+
+// For quickly matching children type, to test if can be treated as content.
+var CONTENT_TYPES = { 'string': true, 'number': true };
+
+var STYLE = keyOf({ style: null });
+var HTML = keyOf({ __html: null });
+var RESERVED_PROPS = {
+ children: null,
+ dangerouslySetInnerHTML: null,
+ suppressContentEditableWarning: null
+};
+
+// Node type for document fragments (Node.DOCUMENT_FRAGMENT_NODE).
+var DOC_FRAGMENT_TYPE = 11;
+
+function getDeclarationErrorAddendum(internalInstance) {
+ if (internalInstance) {
+ var owner = internalInstance._currentElement._owner || null;
+ if (owner) {
+ var name = owner.getName();
+ if (name) {
+ return ' This DOM node was rendered by `' + name + '`.';
+ }
+ }
+ }
+ return '';
+}
+
+function friendlyStringify(obj) {
+ if (typeof obj === 'object') {
+ if (Array.isArray(obj)) {
+ return '[' + obj.map(friendlyStringify).join(', ') + ']';
+ } else {
+ var pairs = [];
+ for (var key in obj) {
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
+ var keyEscaped = /^[a-z$_][\w$_]*$/i.test(key) ? key : JSON.stringify(key);
+ pairs.push(keyEscaped + ': ' + friendlyStringify(obj[key]));
+ }
+ }
+ return '{' + pairs.join(', ') + '}';
+ }
+ } else if (typeof obj === 'string') {
+ return JSON.stringify(obj);
+ } else if (typeof obj === 'function') {
+ return '[function object]';
+ }
+ // Differs from JSON.stringify in that undefined because undefined and that
+ // inf and nan don't become null
+ return String(obj);
+}
+
+var styleMutationWarning = {};
+
+function checkAndWarnForMutatedStyle(style1, style2, component) {
+ if (style1 == null || style2 == null) {
+ return;
+ }
+ if (shallowEqual(style1, style2)) {
+ return;
+ }
+
+ var componentName = component._tag;
+ var owner = component._currentElement._owner;
+ var ownerName;
+ if (owner) {
+ ownerName = owner.getName();
+ }
+
+ var hash = ownerName + '|' + componentName;
+
+ if (styleMutationWarning.hasOwnProperty(hash)) {
+ return;
+ }
+
+ styleMutationWarning[hash] = true;
+
+ process.env.NODE_ENV !== 'production' ? warning(false, '`%s` was passed a style object that has previously been mutated. ' + 'Mutating `style` is deprecated. Consider cloning it beforehand. Check ' + 'the `render` %s. Previous style: %s. Mutated style: %s.', componentName, owner ? 'of `' + ownerName + '`' : 'using <' + componentName + '>', friendlyStringify(style1), friendlyStringify(style2)) : void 0;
+}
+
+/**
+ * @param {object} component
+ * @param {?object} props
+ */
+function assertValidProps(component, props) {
+ if (!props) {
+ return;
+ }
+ // Note the use of `==` which checks for null or undefined.
+ if (voidElementTags[component._tag]) {
+ !(props.children == null && props.dangerouslySetInnerHTML == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s is a void element tag and must not have `children` or ' + 'use `props.dangerouslySetInnerHTML`.%s', component._tag, component._currentElement._owner ? ' Check the render method of ' + component._currentElement._owner.getName() + '.' : '') : invariant(false) : void 0;
+ }
+ if (props.dangerouslySetInnerHTML != null) {
+ !(props.children == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Can only set one of `children` or `props.dangerouslySetInnerHTML`.') : invariant(false) : void 0;
+ !(typeof props.dangerouslySetInnerHTML === 'object' && HTML in props.dangerouslySetInnerHTML) ? process.env.NODE_ENV !== 'production' ? invariant(false, '`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. ' + 'Please visit https://fb.me/react-invariant-dangerously-set-inner-html ' + 'for more information.') : invariant(false) : void 0;
+ }
+ if (process.env.NODE_ENV !== 'production') {
+ process.env.NODE_ENV !== 'production' ? warning(props.innerHTML == null, 'Directly setting property `innerHTML` is not permitted. ' + 'For more information, lookup documentation on `dangerouslySetInnerHTML`.') : void 0;
+ process.env.NODE_ENV !== 'production' ? warning(props.suppressContentEditableWarning || !props.contentEditable || props.children == null, 'A component is `contentEditable` and contains `children` managed by ' + 'React. It is now your responsibility to guarantee that none of ' + 'those nodes are unexpectedly modified or duplicated. This is ' + 'probably not intentional.') : void 0;
+ process.env.NODE_ENV !== 'production' ? warning(props.onFocusIn == null && props.onFocusOut == null, 'React uses onFocus and onBlur instead of onFocusIn and onFocusOut. ' + 'All React events are normalized to bubble, so onFocusIn and onFocusOut ' + 'are not needed/supported by React.') : void 0;
+ }
+ !(props.style == null || typeof props.style === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'The `style` prop expects a mapping from style properties to values, ' + 'not a string. For example, style={{marginRight: spacing + \'em\'}} when ' + 'using JSX.%s', getDeclarationErrorAddendum(component)) : invariant(false) : void 0;
+}
+
+function enqueuePutListener(inst, registrationName, listener, transaction) {
+ if (transaction instanceof ReactServerRenderingTransaction) {
+ return;
+ }
+ if (process.env.NODE_ENV !== 'production') {
+ // IE8 has no API for event capturing and the `onScroll` event doesn't
+ // bubble.
+ process.env.NODE_ENV !== 'production' ? warning(registrationName !== 'onScroll' || isEventSupported('scroll', true), 'This browser doesn\'t support the `onScroll` event') : void 0;
+ }
+ var containerInfo = inst._nativeContainerInfo;
+ var isDocumentFragment = containerInfo._node && containerInfo._node.nodeType === DOC_FRAGMENT_TYPE;
+ var doc = isDocumentFragment ? containerInfo._node : containerInfo._ownerDocument;
+ listenTo(registrationName, doc);
+ transaction.getReactMountReady().enqueue(putListener, {
+ inst: inst,
+ registrationName: registrationName,
+ listener: listener
+ });
+}
+
+function putListener() {
+ var listenerToPut = this;
+ EventPluginHub.putListener(listenerToPut.inst, listenerToPut.registrationName, listenerToPut.listener);
+}
+
+function optionPostMount() {
+ var inst = this;
+ ReactDOMOption.postMountWrapper(inst);
+}
+
+var setContentChildForInstrumentation = emptyFunction;
+if (process.env.NODE_ENV !== 'production') {
+ setContentChildForInstrumentation = function (contentToUse) {
+ var debugID = this._debugID;
+ var contentDebugID = debugID + '#text';
+ this._contentDebugID = contentDebugID;
+ ReactInstrumentation.debugTool.onSetDisplayName(contentDebugID, '#text');
+ ReactInstrumentation.debugTool.onSetText(contentDebugID, '' + contentToUse);
+ ReactInstrumentation.debugTool.onMountComponent(contentDebugID);
+ ReactInstrumentation.debugTool.onSetChildren(debugID, [contentDebugID]);
+ };
+}
+
+// There are so many media events, it makes sense to just
+// maintain a list rather than create a `trapBubbledEvent` for each
+var mediaEvents = {
+ topAbort: 'abort',
+ topCanPlay: 'canplay',
+ topCanPlayThrough: 'canplaythrough',
+ topDurationChange: 'durationchange',
+ topEmptied: 'emptied',
+ topEncrypted: 'encrypted',
+ topEnded: 'ended',
+ topError: 'error',
+ topLoadedData: 'loadeddata',
+ topLoadedMetadata: 'loadedmetadata',
+ topLoadStart: 'loadstart',
+ topPause: 'pause',
+ topPlay: 'play',
+ topPlaying: 'playing',
+ topProgress: 'progress',
+ topRateChange: 'ratechange',
+ topSeeked: 'seeked',
+ topSeeking: 'seeking',
+ topStalled: 'stalled',
+ topSuspend: 'suspend',
+ topTimeUpdate: 'timeupdate',
+ topVolumeChange: 'volumechange',
+ topWaiting: 'waiting'
+};
+
+function trapBubbledEventsLocal() {
+ var inst = this;
+ // If a component renders to null or if another component fatals and causes
+ // the state of the tree to be corrupted, `node` here can be null.
+ !inst._rootNodeID ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Must be mounted to trap events') : invariant(false) : void 0;
+ var node = getNode(inst);
+ !node ? process.env.NODE_ENV !== 'production' ? invariant(false, 'trapBubbledEvent(...): Requires node to be rendered.') : invariant(false) : void 0;
+
+ switch (inst._tag) {
+ case 'iframe':
+ case 'object':
+ inst._wrapperState.listeners = [ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topLoad, 'load', node)];
+ break;
+ case 'video':
+ case 'audio':
+
+ inst._wrapperState.listeners = [];
+ // Create listener for each media event
+ for (var event in mediaEvents) {
+ if (mediaEvents.hasOwnProperty(event)) {
+ inst._wrapperState.listeners.push(ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes[event], mediaEvents[event], node));
+ }
+ }
+
+ break;
+ case 'img':
+ inst._wrapperState.listeners = [ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topError, 'error', node), ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topLoad, 'load', node)];
+ break;
+ case 'form':
+ inst._wrapperState.listeners = [ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topReset, 'reset', node), ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topSubmit, 'submit', node)];
+ break;
+ case 'input':
+ case 'select':
+ case 'textarea':
+ inst._wrapperState.listeners = [ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topInvalid, 'invalid', node)];
+ break;
+ }
+}
+
+function postUpdateSelectWrapper() {
+ ReactDOMSelect.postUpdateWrapper(this);
+}
+
+// For HTML, certain tags should omit their close tag. We keep a whitelist for
+// those special-case tags.
+
+var omittedCloseTags = {
+ 'area': true,
+ 'base': true,
+ 'br': true,
+ 'col': true,
+ 'embed': true,
+ 'hr': true,
+ 'img': true,
+ 'input': true,
+ 'keygen': true,
+ 'link': true,
+ 'meta': true,
+ 'param': true,
+ 'source': true,
+ 'track': true,
+ 'wbr': true
+};
+
+// NOTE: menuitem's close tag should be omitted, but that causes problems.
+var newlineEatingTags = {
+ 'listing': true,
+ 'pre': true,
+ 'textarea': true
+};
+
+// For HTML, certain tags cannot have children. This has the same purpose as
+// `omittedCloseTags` except that `menuitem` should still have its closing tag.
+
+var voidElementTags = _assign({
+ 'menuitem': true
+}, omittedCloseTags);
+
+// We accept any tag to be rendered but since this gets injected into arbitrary
+// HTML, we want to make sure that it's a safe tag.
+// http://www.w3.org/TR/REC-xml/#NT-Name
+
+var VALID_TAG_REGEX = /^[a-zA-Z][a-zA-Z:_\.\-\d]*$/; // Simplified subset
+var validatedTagCache = {};
+var hasOwnProperty = {}.hasOwnProperty;
+
+function validateDangerousTag(tag) {
+ if (!hasOwnProperty.call(validatedTagCache, tag)) {
+ !VALID_TAG_REGEX.test(tag) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Invalid tag: %s', tag) : invariant(false) : void 0;
+ validatedTagCache[tag] = true;
+ }
+}
+
+function isCustomComponent(tagName, props) {
+ return tagName.indexOf('-') >= 0 || props.is != null;
+}
+
+var globalIdCounter = 1;
+
+/**
+ * Creates a new React class that is idempotent and capable of containing other
+ * React components. It accepts event listeners and DOM properties that are
+ * valid according to `DOMProperty`.
+ *
+ * - Event listeners: `onClick`, `onMouseDown`, etc.
+ * - DOM properties: `className`, `name`, `title`, etc.
+ *
+ * The `style` property functions differently from the DOM API. It accepts an
+ * object mapping of style properties to values.
+ *
+ * @constructor ReactDOMComponent
+ * @extends ReactMultiChild
+ */
+function ReactDOMComponent(element) {
+ var tag = element.type;
+ validateDangerousTag(tag);
+ this._currentElement = element;
+ this._tag = tag.toLowerCase();
+ this._namespaceURI = null;
+ this._renderedChildren = null;
+ this._previousStyle = null;
+ this._previousStyleCopy = null;
+ this._nativeNode = null;
+ this._nativeParent = null;
+ this._rootNodeID = null;
+ this._domID = null;
+ this._nativeContainerInfo = null;
+ this._wrapperState = null;
+ this._topLevelWrapper = null;
+ this._flags = 0;
+ if (process.env.NODE_ENV !== 'production') {
+ this._ancestorInfo = null;
+ this._contentDebugID = null;
+ }
+}
+
+ReactDOMComponent.displayName = 'ReactDOMComponent';
+
+ReactDOMComponent.Mixin = {
+
+ /**
+ * Generates root tag markup then recurses. This method has side effects and
+ * is not idempotent.
+ *
+ * @internal
+ * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
+ * @param {?ReactDOMComponent} the containing DOM component instance
+ * @param {?object} info about the native container
+ * @param {object} context
+ * @return {string} The computed markup.
+ */
+ mountComponent: function (transaction, nativeParent, nativeContainerInfo, context) {
+ this._rootNodeID = globalIdCounter++;
+ this._domID = nativeContainerInfo._idCounter++;
+ this._nativeParent = nativeParent;
+ this._nativeContainerInfo = nativeContainerInfo;
+
+ var props = this._currentElement.props;
+
+ switch (this._tag) {
+ case 'iframe':
+ case 'object':
+ case 'img':
+ case 'form':
+ case 'video':
+ case 'audio':
+ this._wrapperState = {
+ listeners: null
+ };
+ transaction.getReactMountReady().enqueue(trapBubbledEventsLocal, this);
+ break;
+ case 'button':
+ props = ReactDOMButton.getNativeProps(this, props, nativeParent);
+ break;
+ case 'input':
+ ReactDOMInput.mountWrapper(this, props, nativeParent);
+ props = ReactDOMInput.getNativeProps(this, props);
+ transaction.getReactMountReady().enqueue(trapBubbledEventsLocal, this);
+ break;
+ case 'option':
+ ReactDOMOption.mountWrapper(this, props, nativeParent);
+ props = ReactDOMOption.getNativeProps(this, props);
+ break;
+ case 'select':
+ ReactDOMSelect.mountWrapper(this, props, nativeParent);
+ props = ReactDOMSelect.getNativeProps(this, props);
+ transaction.getReactMountReady().enqueue(trapBubbledEventsLocal, this);
+ break;
+ case 'textarea':
+ ReactDOMTextarea.mountWrapper(this, props, nativeParent);
+ props = ReactDOMTextarea.getNativeProps(this, props);
+ transaction.getReactMountReady().enqueue(trapBubbledEventsLocal, this);
+ break;
+ }
+
+ assertValidProps(this, props);
+
+ // We create tags in the namespace of their parent container, except HTML
+ // tags get no namespace.
+ var namespaceURI;
+ var parentTag;
+ if (nativeParent != null) {
+ namespaceURI = nativeParent._namespaceURI;
+ parentTag = nativeParent._tag;
+ } else if (nativeContainerInfo._tag) {
+ namespaceURI = nativeContainerInfo._namespaceURI;
+ parentTag = nativeContainerInfo._tag;
+ }
+ if (namespaceURI == null || namespaceURI === DOMNamespaces.svg && parentTag === 'foreignobject') {
+ namespaceURI = DOMNamespaces.html;
+ }
+ if (namespaceURI === DOMNamespaces.html) {
+ if (this._tag === 'svg') {
+ namespaceURI = DOMNamespaces.svg;
+ } else if (this._tag === 'math') {
+ namespaceURI = DOMNamespaces.mathml;
+ }
+ }
+ this._namespaceURI = namespaceURI;
+
+ if (process.env.NODE_ENV !== 'production') {
+ var parentInfo;
+ if (nativeParent != null) {
+ parentInfo = nativeParent._ancestorInfo;
+ } else if (nativeContainerInfo._tag) {
+ parentInfo = nativeContainerInfo._ancestorInfo;
+ }
+ if (parentInfo) {
+ // parentInfo should always be present except for the top-level
+ // component when server rendering
+ validateDOMNesting(this._tag, this, parentInfo);
+ }
+ this._ancestorInfo = validateDOMNesting.updatedAncestorInfo(parentInfo, this._tag, this);
+ }
+
+ var mountImage;
+ if (transaction.useCreateElement) {
+ var ownerDocument = nativeContainerInfo._ownerDocument;
+ var el;
+ if (namespaceURI === DOMNamespaces.html) {
+ if (this._tag === 'script') {
+ // Create the script via .innerHTML so its "parser-inserted" flag is
+ // set to true and it does not execute
+ var div = ownerDocument.createElement('div');
+ var type = this._currentElement.type;
+ div.innerHTML = '<' + type + '></' + type + '>';
+ el = div.removeChild(div.firstChild);
+ } else {
+ el = ownerDocument.createElement(this._currentElement.type, props.is || null);
+ }
+ } else {
+ el = ownerDocument.createElementNS(namespaceURI, this._currentElement.type);
+ }
+ ReactDOMComponentTree.precacheNode(this, el);
+ this._flags |= Flags.hasCachedChildNodes;
+ if (!this._nativeParent) {
+ DOMPropertyOperations.setAttributeForRoot(el);
+ }
+ this._updateDOMProperties(null, props, transaction);
+ var lazyTree = DOMLazyTree(el);
+ this._createInitialChildren(transaction, props, context, lazyTree);
+ mountImage = lazyTree;
+ } else {
+ var tagOpen = this._createOpenTagMarkupAndPutListeners(transaction, props);
+ var tagContent = this._createContentMarkup(transaction, props, context);
+ if (!tagContent && omittedCloseTags[this._tag]) {
+ mountImage = tagOpen + '/>';
+ } else {
+ mountImage = tagOpen + '>' + tagContent + '</' + this._currentElement.type + '>';
+ }
+ }
+
+ switch (this._tag) {
+ case 'button':
+ case 'input':
+ case 'select':
+ case 'textarea':
+ if (props.autoFocus) {
+ transaction.getReactMountReady().enqueue(AutoFocusUtils.focusDOMComponent, this);
+ }
+ break;
+ case 'option':
+ transaction.getReactMountReady().enqueue(optionPostMount, this);
+ }
+
+ return mountImage;
+ },
+
+ /**
+ * Creates markup for the open tag and all attributes.
+ *
+ * This method has side effects because events get registered.
+ *
+ * Iterating over object properties is faster than iterating over arrays.
+ * @see http://jsperf.com/obj-vs-arr-iteration
+ *
+ * @private
+ * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
+ * @param {object} props
+ * @return {string} Markup of opening tag.
+ */
+ _createOpenTagMarkupAndPutListeners: function (transaction, props) {
+ var ret = '<' + this._currentElement.type;
+
+ for (var propKey in props) {
+ if (!props.hasOwnProperty(propKey)) {
+ continue;
+ }
+ var propValue = props[propKey];
+ if (propValue == null) {
+ continue;
+ }
+ if (registrationNameModules.hasOwnProperty(propKey)) {
+ if (propValue) {
+ enqueuePutListener(this, propKey, propValue, transaction);
+ }
+ } else {
+ if (propKey === STYLE) {
+ if (propValue) {
+ if (process.env.NODE_ENV !== 'production') {
+ // See `_updateDOMProperties`. style block
+ this._previousStyle = propValue;
+ }
+ propValue = this._previousStyleCopy = _assign({}, props.style);
+ }
+ propValue = CSSPropertyOperations.createMarkupForStyles(propValue, this);
+ }
+ var markup = null;
+ if (this._tag != null && isCustomComponent(this._tag, props)) {
+ if (!RESERVED_PROPS.hasOwnProperty(propKey)) {
+ markup = DOMPropertyOperations.createMarkupForCustomAttribute(propKey, propValue);
+ }
+ } else {
+ markup = DOMPropertyOperations.createMarkupForProperty(propKey, propValue);
+ }
+ if (markup) {
+ ret += ' ' + markup;
+ }
+ }
+ }
+
+ // For static pages, no need to put React ID and checksum. Saves lots of
+ // bytes.
+ if (transaction.renderToStaticMarkup) {
+ return ret;
+ }
+
+ if (!this._nativeParent) {
+ ret += ' ' + DOMPropertyOperations.createMarkupForRoot();
+ }
+ ret += ' ' + DOMPropertyOperations.createMarkupForID(this._domID);
+ return ret;
+ },
+
+ /**
+ * Creates markup for the content between the tags.
+ *
+ * @private
+ * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
+ * @param {object} props
+ * @param {object} context
+ * @return {string} Content markup.
+ */
+ _createContentMarkup: function (transaction, props, context) {
+ var ret = '';
+
+ // Intentional use of != to avoid catching zero/false.
+ var innerHTML = props.dangerouslySetInnerHTML;
+ if (innerHTML != null) {
+ if (innerHTML.__html != null) {
+ ret = innerHTML.__html;
+ }
+ } else {
+ var contentToUse = CONTENT_TYPES[typeof props.children] ? props.children : null;
+ var childrenToUse = contentToUse != null ? null : props.children;
+ if (contentToUse != null) {
+ // TODO: Validate that text is allowed as a child of this node
+ ret = escapeTextContentForBrowser(contentToUse);
+ if (process.env.NODE_ENV !== 'production') {
+ setContentChildForInstrumentation.call(this, contentToUse);
+ }
+ } else if (childrenToUse != null) {
+ var mountImages = this.mountChildren(childrenToUse, transaction, context);
+ ret = mountImages.join('');
+ }
+ }
+ if (newlineEatingTags[this._tag] && ret.charAt(0) === '\n') {
+ // text/html ignores the first character in these tags if it's a newline
+ // Prefer to break application/xml over text/html (for now) by adding
+ // a newline specifically to get eaten by the parser. (Alternately for
+ // textareas, replacing "^\n" with "\r\n" doesn't get eaten, and the first
+ // \r is normalized out by HTMLTextAreaElement#value.)
+ // See: <http://www.w3.org/TR/html-polyglot/#newlines-in-textarea-and-pre>
+ // See: <http://www.w3.org/TR/html5/syntax.html#element-restrictions>
+ // See: <http://www.w3.org/TR/html5/syntax.html#newlines>
+ // See: Parsing of "textarea" "listing" and "pre" elements
+ // from <http://www.w3.org/TR/html5/syntax.html#parsing-main-inbody>
+ return '\n' + ret;
+ } else {
+ return ret;
+ }
+ },
+
+ _createInitialChildren: function (transaction, props, context, lazyTree) {
+ // Intentional use of != to avoid catching zero/false.
+ var innerHTML = props.dangerouslySetInnerHTML;
+ if (innerHTML != null) {
+ if (innerHTML.__html != null) {
+ DOMLazyTree.queueHTML(lazyTree, innerHTML.__html);
+ }
+ } else {
+ var contentToUse = CONTENT_TYPES[typeof props.children] ? props.children : null;
+ var childrenToUse = contentToUse != null ? null : props.children;
+ if (contentToUse != null) {
+ // TODO: Validate that text is allowed as a child of this node
+ if (process.env.NODE_ENV !== 'production') {
+ setContentChildForInstrumentation.call(this, contentToUse);
+ }
+ DOMLazyTree.queueText(lazyTree, contentToUse);
+ } else if (childrenToUse != null) {
+ var mountImages = this.mountChildren(childrenToUse, transaction, context);
+ for (var i = 0; i < mountImages.length; i++) {
+ DOMLazyTree.queueChild(lazyTree, mountImages[i]);
+ }
+ }
+ }
+ },
+
+ /**
+ * Receives a next element and updates the component.
+ *
+ * @internal
+ * @param {ReactElement} nextElement
+ * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
+ * @param {object} context
+ */
+ receiveComponent: function (nextElement, transaction, context) {
+ var prevElement = this._currentElement;
+ this._currentElement = nextElement;
+ this.updateComponent(transaction, prevElement, nextElement, context);
+ },
+
+ /**
+ * Updates a native DOM component after it has already been allocated and
+ * attached to the DOM. Reconciles the root DOM node, then recurses.
+ *
+ * @param {ReactReconcileTransaction} transaction
+ * @param {ReactElement} prevElement
+ * @param {ReactElement} nextElement
+ * @internal
+ * @overridable
+ */
+ updateComponent: function (transaction, prevElement, nextElement, context) {
+ var lastProps = prevElement.props;
+ var nextProps = this._currentElement.props;
+
+ switch (this._tag) {
+ case 'button':
+ lastProps = ReactDOMButton.getNativeProps(this, lastProps);
+ nextProps = ReactDOMButton.getNativeProps(this, nextProps);
+ break;
+ case 'input':
+ ReactDOMInput.updateWrapper(this);
+ lastProps = ReactDOMInput.getNativeProps(this, lastProps);
+ nextProps = ReactDOMInput.getNativeProps(this, nextProps);
+ break;
+ case 'option':
+ lastProps = ReactDOMOption.getNativeProps(this, lastProps);
+ nextProps = ReactDOMOption.getNativeProps(this, nextProps);
+ break;
+ case 'select':
+ lastProps = ReactDOMSelect.getNativeProps(this, lastProps);
+ nextProps = ReactDOMSelect.getNativeProps(this, nextProps);
+ break;
+ case 'textarea':
+ ReactDOMTextarea.updateWrapper(this);
+ lastProps = ReactDOMTextarea.getNativeProps(this, lastProps);
+ nextProps = ReactDOMTextarea.getNativeProps(this, nextProps);
+ break;
+ }
+
+ assertValidProps(this, nextProps);
+ this._updateDOMProperties(lastProps, nextProps, transaction);
+ this._updateDOMChildren(lastProps, nextProps, transaction, context);
+
+ if (this._tag === 'select') {
+ // <select> value update needs to occur after <option> children
+ // reconciliation
+ transaction.getReactMountReady().enqueue(postUpdateSelectWrapper, this);
+ }
+ },
+
+ /**
+ * Reconciles the properties by detecting differences in property values and
+ * updating the DOM as necessary. This function is probably the single most
+ * critical path for performance optimization.
+ *
+ * TODO: Benchmark whether checking for changed values in memory actually
+ * improves performance (especially statically positioned elements).
+ * TODO: Benchmark the effects of putting this at the top since 99% of props
+ * do not change for a given reconciliation.
+ * TODO: Benchmark areas that can be improved with caching.
+ *
+ * @private
+ * @param {object} lastProps
+ * @param {object} nextProps
+ * @param {?DOMElement} node
+ */
+ _updateDOMProperties: function (lastProps, nextProps, transaction) {
+ var propKey;
+ var styleName;
+ var styleUpdates;
+ for (propKey in lastProps) {
+ if (nextProps.hasOwnProperty(propKey) || !lastProps.hasOwnProperty(propKey) || lastProps[propKey] == null) {
+ continue;
+ }
+ if (propKey === STYLE) {
+ var lastStyle = this._previousStyleCopy;
+ for (styleName in lastStyle) {
+ if (lastStyle.hasOwnProperty(styleName)) {
+ styleUpdates = styleUpdates || {};
+ styleUpdates[styleName] = '';
+ }
+ }
+ this._previousStyleCopy = null;
+ } else if (registrationNameModules.hasOwnProperty(propKey)) {
+ if (lastProps[propKey]) {
+ // Only call deleteListener if there was a listener previously or
+ // else willDeleteListener gets called when there wasn't actually a
+ // listener (e.g., onClick={null})
+ deleteListener(this, propKey);
+ }
+ } else if (DOMProperty.properties[propKey] || DOMProperty.isCustomAttribute(propKey)) {
+ DOMPropertyOperations.deleteValueForProperty(getNode(this), propKey);
+ }
+ }
+ for (propKey in nextProps) {
+ var nextProp = nextProps[propKey];
+ var lastProp = propKey === STYLE ? this._previousStyleCopy : lastProps != null ? lastProps[propKey] : undefined;
+ if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp || nextProp == null && lastProp == null) {
+ continue;
+ }
+ if (propKey === STYLE) {
+ if (nextProp) {
+ if (process.env.NODE_ENV !== 'production') {
+ checkAndWarnForMutatedStyle(this._previousStyleCopy, this._previousStyle, this);
+ this._previousStyle = nextProp;
+ }
+ nextProp = this._previousStyleCopy = _assign({}, nextProp);
+ } else {
+ this._previousStyleCopy = null;
+ }
+ if (lastProp) {
+ // Unset styles on `lastProp` but not on `nextProp`.
+ for (styleName in lastProp) {
+ if (lastProp.hasOwnProperty(styleName) && (!nextProp || !nextProp.hasOwnProperty(styleName))) {
+ styleUpdates = styleUpdates || {};
+ styleUpdates[styleName] = '';
+ }
+ }
+ // Update styles that changed since `lastProp`.
+ for (styleName in nextProp) {
+ if (nextProp.hasOwnProperty(styleName) && lastProp[styleName] !== nextProp[styleName]) {
+ styleUpdates = styleUpdates || {};
+ styleUpdates[styleName] = nextProp[styleName];
+ }
+ }
+ } else {
+ // Relies on `updateStylesByID` not mutating `styleUpdates`.
+ styleUpdates = nextProp;
+ }
+ } else if (registrationNameModules.hasOwnProperty(propKey)) {
+ if (nextProp) {
+ enqueuePutListener(this, propKey, nextProp, transaction);
+ } else if (lastProp) {
+ deleteListener(this, propKey);
+ }
+ } else if (isCustomComponent(this._tag, nextProps)) {
+ if (!RESERVED_PROPS.hasOwnProperty(propKey)) {
+ DOMPropertyOperations.setValueForAttribute(getNode(this), propKey, nextProp);
+ }
+ } else if (DOMProperty.properties[propKey] || DOMProperty.isCustomAttribute(propKey)) {
+ var node = getNode(this);
+ // If we're updating to null or undefined, we should remove the property
+ // from the DOM node instead of inadvertently setting to a string. This
+ // brings us in line with the same behavior we have on initial render.
+ if (nextProp != null) {
+ DOMPropertyOperations.setValueForProperty(node, propKey, nextProp);
+ } else {
+ DOMPropertyOperations.deleteValueForProperty(node, propKey);
+ }
+ }
+ }
+ if (styleUpdates) {
+ CSSPropertyOperations.setValueForStyles(getNode(this), styleUpdates, this);
+ }
+ },
+
+ /**
+ * Reconciles the children with the various properties that affect the
+ * children content.
+ *
+ * @param {object} lastProps
+ * @param {object} nextProps
+ * @param {ReactReconcileTransaction} transaction
+ * @param {object} context
+ */
+ _updateDOMChildren: function (lastProps, nextProps, transaction, context) {
+ var lastContent = CONTENT_TYPES[typeof lastProps.children] ? lastProps.children : null;
+ var nextContent = CONTENT_TYPES[typeof nextProps.children] ? nextProps.children : null;
+
+ var lastHtml = lastProps.dangerouslySetInnerHTML && lastProps.dangerouslySetInnerHTML.__html;
+ var nextHtml = nextProps.dangerouslySetInnerHTML && nextProps.dangerouslySetInnerHTML.__html;
+
+ // Note the use of `!=` which checks for null or undefined.
+ var lastChildren = lastContent != null ? null : lastProps.children;
+ var nextChildren = nextContent != null ? null : nextProps.children;
+
+ // If we're switching from children to content/html or vice versa, remove
+ // the old content
+ var lastHasContentOrHtml = lastContent != null || lastHtml != null;
+ var nextHasContentOrHtml = nextContent != null || nextHtml != null;
+ if (lastChildren != null && nextChildren == null) {
+ this.updateChildren(null, transaction, context);
+ } else if (lastHasContentOrHtml && !nextHasContentOrHtml) {
+ this.updateTextContent('');
+ if (process.env.NODE_ENV !== 'production') {
+ ReactInstrumentation.debugTool.onSetChildren(this._debugID, []);
+ }
+ }
+
+ if (nextContent != null) {
+ if (lastContent !== nextContent) {
+ this.updateTextContent('' + nextContent);
+ if (process.env.NODE_ENV !== 'production') {
+ this._contentDebugID = this._debugID + '#text';
+ setContentChildForInstrumentation.call(this, nextContent);
+ }
+ }
+ } else if (nextHtml != null) {
+ if (lastHtml !== nextHtml) {
+ this.updateMarkup('' + nextHtml);
+ }
+ if (process.env.NODE_ENV !== 'production') {
+ ReactInstrumentation.debugTool.onSetChildren(this._debugID, []);
+ }
+ } else if (nextChildren != null) {
+ if (process.env.NODE_ENV !== 'production') {
+ if (this._contentDebugID) {
+ ReactInstrumentation.debugTool.onUnmountComponent(this._contentDebugID);
+ this._contentDebugID = null;
+ }
+ }
+
+ this.updateChildren(nextChildren, transaction, context);
+ }
+ },
+
+ getNativeNode: function () {
+ return getNode(this);
+ },
+
+ /**
+ * Destroys all event registrations for this instance. Does not remove from
+ * the DOM. That must be done by the parent.
+ *
+ * @internal
+ */
+ unmountComponent: function (safely) {
+ switch (this._tag) {
+ case 'iframe':
+ case 'object':
+ case 'img':
+ case 'form':
+ case 'video':
+ case 'audio':
+ var listeners = this._wrapperState.listeners;
+ if (listeners) {
+ for (var i = 0; i < listeners.length; i++) {
+ listeners[i].remove();
+ }
+ }
+ break;
+ case 'html':
+ case 'head':
+ case 'body':
+ /**
+ * Components like <html> <head> and <body> can't be removed or added
+ * easily in a cross-browser way, however it's valuable to be able to
+ * take advantage of React's reconciliation for styling and <title>
+ * management. So we just document it and throw in dangerous cases.
+ */
+ !false ? process.env.NODE_ENV !== 'production' ? invariant(false, '<%s> tried to unmount. Because of cross-browser quirks it is ' + 'impossible to unmount some top-level components (eg <html>, ' + '<head>, and <body>) reliably and efficiently. To fix this, have a ' + 'single top-level component that never unmounts render these ' + 'elements.', this._tag) : invariant(false) : void 0;
+ break;
+ }
+
+ this.unmountChildren(safely);
+ ReactDOMComponentTree.uncacheNode(this);
+ EventPluginHub.deleteAllListeners(this);
+ ReactComponentBrowserEnvironment.unmountIDFromEnvironment(this._rootNodeID);
+ this._rootNodeID = null;
+ this._domID = null;
+ this._wrapperState = null;
+
+ if (process.env.NODE_ENV !== 'production') {
+ if (this._contentDebugID) {
+ ReactInstrumentation.debugTool.onUnmountComponent(this._contentDebugID);
+ this._contentDebugID = null;
+ }
+ }
+ },
+
+ getPublicInstance: function () {
+ return getNode(this);
+ }
+
+};
+
+_assign(ReactDOMComponent.prototype, ReactDOMComponent.Mixin, ReactMultiChild.Mixin);
+
+module.exports = ReactDOMComponent; \ No newline at end of file
diff --git a/bench/config-example/config.js b/bench/config-example/config.js
new file mode 100644
index 000000000..fc0dc184a
--- /dev/null
+++ b/bench/config-example/config.js
@@ -0,0 +1,1474 @@
+SystemJS.config({
+ paths: {
+ 'npm:': 'npm/',
+ 'github:': 'github/'
+ },
+ packageConfigPaths: [
+ "npm:@*/*.json",
+ "npm:*.json",
+ "github:*/*.json"
+ ],
+ devConfig: {
+ "map": {
+ "plugin-babel": "npm:systemjs-plugin-babel@0.0.10"
+ }
+ },
+ transpiler: "plugin-babel"
+});
+
+SystemJS.config({
+ map: {
+ "angular": "github:angular/bower-angular@1.4.8",
+ "assert": "github:jspm/nodelibs-assert@0.2.0-alpha",
+ "bootstrap": "github:twbs/bootstrap@3.3.6",
+ "buffer": "github:jspm/nodelibs-buffer@0.2.0-alpha",
+ "builder": "npm:systemjs-builder@0.15.18",
+ "child_process": "github:jspm/nodelibs-child_process@0.2.0-alpha",
+ "clean-css": "npm:clean-css@3.4.9",
+ "cluster": "github:jspm/nodelibs-cluster@0.2.0-alpha",
+ "console": "github:jspm/nodelibs-console@0.2.0-alpha",
+ "constants": "github:jspm/nodelibs-constants@0.2.0-alpha",
+ "core-js": "npm:core-js@1.2.6",
+ "crypto": "github:jspm/nodelibs-crypto@0.2.0-alpha",
+ "css": "github:systemjs/plugin-css@0.1.20",
+ "d3": "github:mbostock/d3@3.5.12",
+ "dgram": "github:jspm/nodelibs-dgram@0.2.0-alpha",
+ "dns": "github:jspm/nodelibs-dns@0.2.0-alpha",
+ "domain": "github:jspm/nodelibs-domain@0.2.0-alpha",
+ "ecc-jsbn": "npm:ecc-jsbn@0.1.1",
+ "ember": "github:components/ember@1.13.2",
+ "events": "github:jspm/nodelibs-events@0.2.0-alpha",
+ "fs": "github:jspm/nodelibs-fs@0.2.0-alpha",
+ "github": "npm:jspm-github@0.14.7",
+ "http": "github:jspm/nodelibs-http@0.2.0-alpha",
+ "https": "github:jspm/nodelibs-https@0.2.0-alpha",
+ "jodid25519": "npm:jodid25519@1.0.2",
+ "jquery": "github:components/jquery@2.1.4",
+ "jsbn": "npm:jsbn@0.1.0",
+ "jspm": "github:jspm/jspm-cli@0.17",
+ "jspm-registry": "npm:jspm-registry@0.4.0",
+ "mocha": "npm:mocha@1.21.5",
+ "module": "github:jspm/nodelibs-module@0.2.0-alpha",
+ "net": "github:jspm/nodelibs-net@0.2.0-alpha",
+ "npm": "npm:jspm-npm@0.28.12",
+ "os": "github:jspm/nodelibs-os@0.2.0-alpha",
+ "path": "github:jspm/nodelibs-path@0.2.0-alpha",
+ "process": "github:jspm/nodelibs-process@0.2.0-alpha",
+ "punycode": "github:jspm/nodelibs-punycode@0.2.0-alpha",
+ "querystring": "github:jspm/nodelibs-querystring@0.2.0-alpha",
+ "readline": "github:jspm/nodelibs-readline@0.2.0-alpha",
+ "repl": "github:jspm/nodelibs-repl@0.2.0-alpha",
+ "rsvp": "npm:rsvp@3.1.0",
+ "source-map": "npm:source-map@0.5.3",
+ "sshpk": "npm:sshpk@1.7.3",
+ "stream": "github:jspm/nodelibs-stream@0.2.0-alpha",
+ "string_decoder": "github:jspm/nodelibs-string_decoder@0.2.0-alpha",
+ "systemjs": "npm:systemjs@0.19.29",
+ "text": "github:systemjs/plugin-text@0.0.2",
+ "timers": "github:jspm/nodelibs-timers@0.2.0-alpha",
+ "tls": "github:jspm/nodelibs-tls@0.2.0-alpha",
+ "tty": "github:jspm/nodelibs-tty@0.2.0-alpha",
+ "tweetnacl": "npm:tweetnacl@0.14.1",
+ "url": "github:jspm/nodelibs-url@0.2.0-alpha",
+ "util": "github:jspm/nodelibs-util@0.2.0-alpha",
+ "vm": "github:jspm/nodelibs-vm@0.2.0-alpha",
+ "voxel-demo": "npm:voxel-demo@0.0.1",
+ "zlib": "github:jspm/nodelibs-zlib@0.2.0-alpha"
+ }
+});
+
+SystemJS.config({
+ packages: {
+ "npm:asn1.js@4.5.1": {
+ "map": {
+ "bn.js": "npm:bn.js@4.11.0",
+ "inherits": "npm:inherits@2.0.1",
+ "minimalistic-assert": "npm:minimalistic-assert@1.0.0"
+ }
+ },
+ "npm:babel-code-frame@6.7.7": {
+ "map": {
+ "babel-runtime": "npm:babel-runtime@5.8.38",
+ "chalk": "npm:chalk@1.1.1",
+ "esutils": "npm:esutils@2.0.2",
+ "js-tokens": "npm:js-tokens@1.0.3"
+ }
+ },
+ "npm:babel-helper-hoist-variables@6.6.5": {
+ "map": {
+ "babel-runtime": "npm:babel-runtime@5.8.38",
+ "babel-types": "npm:babel-types@6.7.7"
+ }
+ },
+ "npm:babel-messages@6.7.2": {
+ "map": {
+ "babel-runtime": "npm:babel-runtime@5.8.38"
+ }
+ },
+ "npm:babel-plugin-transform-es2015-modules-systemjs@6.6.5": {
+ "map": {
+ "babel-helper-hoist-variables": "npm:babel-helper-hoist-variables@6.6.5",
+ "babel-plugin-transform-strict-mode": "npm:babel-plugin-transform-strict-mode@6.6.5",
+ "babel-runtime": "npm:babel-runtime@5.8.38",
+ "babel-template": "npm:babel-template@6.7.0"
+ }
+ },
+ "npm:babel-plugin-transform-strict-mode@6.6.5": {
+ "map": {
+ "babel-runtime": "npm:babel-runtime@5.8.38",
+ "babel-types": "npm:babel-types@6.7.7"
+ }
+ },
+ "npm:babel-template@6.7.0": {
+ "map": {
+ "babel-runtime": "npm:babel-runtime@5.8.38",
+ "babel-traverse": "npm:babel-traverse@6.7.6",
+ "babel-types": "npm:babel-types@6.7.7",
+ "babylon": "npm:babylon@6.7.0",
+ "lodash": "npm:lodash@3.10.1"
+ }
+ },
+ "npm:babel-traverse@6.7.6": {
+ "map": {
+ "babel-code-frame": "npm:babel-code-frame@6.7.7",
+ "babel-messages": "npm:babel-messages@6.7.2",
+ "babel-runtime": "npm:babel-runtime@5.8.38",
+ "babel-types": "npm:babel-types@6.7.7",
+ "babylon": "npm:babylon@6.7.0",
+ "debug": "npm:debug@2.2.0",
+ "globals": "npm:globals@8.18.0",
+ "invariant": "npm:invariant@2.2.1",
+ "lodash": "npm:lodash@3.10.1",
+ "repeating": "npm:repeating@1.1.3"
+ }
+ },
+ "npm:babel-types@6.7.7": {
+ "map": {
+ "babel-runtime": "npm:babel-runtime@5.8.38",
+ "babel-traverse": "npm:babel-traverse@6.7.6",
+ "esutils": "npm:esutils@2.0.2",
+ "lodash": "npm:lodash@3.10.1",
+ "to-fast-properties": "npm:to-fast-properties@1.0.2"
+ }
+ },
+ "npm:babylon@6.7.0": {
+ "map": {
+ "babel-runtime": "npm:babel-runtime@5.8.38"
+ }
+ },
+ "npm:browserify-aes@1.0.6": {
+ "map": {
+ "buffer-xor": "npm:buffer-xor@1.0.3",
+ "cipher-base": "npm:cipher-base@1.0.2",
+ "create-hash": "npm:create-hash@1.1.2",
+ "evp_bytestokey": "npm:evp_bytestokey@1.0.0",
+ "inherits": "npm:inherits@2.0.1"
+ }
+ },
+ "npm:browserify-rsa@4.0.1": {
+ "map": {
+ "bn.js": "npm:bn.js@4.11.0",
+ "randombytes": "npm:randombytes@2.0.3"
+ }
+ },
+ "npm:bser@1.0.2": {
+ "map": {
+ "node-int64": "npm:node-int64@0.4.0"
+ }
+ },
+ "npm:buffer@4.5.0": {
+ "map": {
+ "base64-js": "npm:base64-js@1.1.1",
+ "ieee754": "npm:ieee754@1.1.6",
+ "isarray": "npm:isarray@1.0.0"
+ }
+ },
+ "npm:dashdash@1.13.0": {
+ "map": {
+ "assert-plus": "npm:assert-plus@1.0.0"
+ }
+ },
+ "npm:debug@2.2.0": {
+ "map": {
+ "ms": "npm:ms@0.7.1"
+ }
+ },
+ "npm:detect-indent@3.0.1": {
+ "map": {
+ "get-stdin": "npm:get-stdin@4.0.1",
+ "minimist": "npm:minimist@1.2.0",
+ "repeating": "npm:repeating@1.1.3"
+ }
+ },
+ "npm:diffie-hellman@5.0.2": {
+ "map": {
+ "bn.js": "npm:bn.js@4.11.0",
+ "miller-rabin": "npm:miller-rabin@4.0.0",
+ "randombytes": "npm:randombytes@2.0.3"
+ }
+ },
+ "npm:elliptic@6.2.3": {
+ "map": {
+ "bn.js": "npm:bn.js@4.11.0",
+ "brorand": "npm:brorand@1.0.5",
+ "hash.js": "npm:hash.js@1.0.3",
+ "inherits": "npm:inherits@2.0.1"
+ }
+ },
+ "npm:exec-sh@0.2.0": {
+ "map": {
+ "merge": "npm:merge@1.2.0"
+ }
+ },
+ "npm:fb-watchman@1.9.0": {
+ "map": {
+ "bser": "npm:bser@1.0.2"
+ }
+ },
+ "npm:glob@6.0.4": {
+ "map": {
+ "inflight": "npm:inflight@1.0.4",
+ "inherits": "npm:inherits@2.0.1",
+ "minimatch": "npm:minimatch@3.0.0",
+ "once": "npm:once@1.3.3",
+ "path-is-absolute": "npm:path-is-absolute@1.0.0"
+ }
+ },
+ "npm:glob@7.0.3": {
+ "map": {
+ "inflight": "npm:inflight@1.0.4",
+ "inherits": "npm:inherits@2.0.1",
+ "minimatch": "npm:minimatch@3.0.0",
+ "once": "npm:once@1.3.3",
+ "path-is-absolute": "npm:path-is-absolute@1.0.0"
+ }
+ },
+ "npm:graceful-readlink@1.0.1": {
+ "map": {}
+ },
+ "npm:home-or-tmp@1.0.0": {
+ "map": {
+ "os-tmpdir": "npm:os-tmpdir@1.0.1",
+ "user-home": "npm:user-home@1.1.1"
+ }
+ },
+ "npm:inherits@2.0.1": {
+ "map": {}
+ },
+ "npm:invariant@2.2.1": {
+ "map": {
+ "loose-envify": "npm:loose-envify@1.1.0"
+ }
+ },
+ "npm:is-finite@1.0.1": {
+ "map": {
+ "number-is-nan": "npm:number-is-nan@1.0.0"
+ }
+ },
+ "github:jspm/jspm-cli@0.17": {
+ "map": {
+ "bluebird": "npm:bluebird@3.3.5",
+ "chalk": "npm:chalk@1.1.1",
+ "core-js": "npm:core-js@1.2.6",
+ "glob": "npm:glob@6.0.4",
+ "graceful-fs": "npm:graceful-fs@4.1.2",
+ "jspm-github": "npm:jspm-github@0.14.7",
+ "jspm-npm": "npm:jspm-npm@0.28.12",
+ "jspm-registry": "npm:jspm-registry@0.4.0",
+ "liftoff": "npm:liftoff@2.2.0",
+ "minimatch": "npm:minimatch@3.0.0",
+ "mkdirp": "npm:mkdirp@0.5.1",
+ "ncp": "npm:ncp@2.0.0",
+ "proper-lockfile": "npm:proper-lockfile@1.1.1",
+ "request": "npm:request@2.67.0",
+ "rimraf": "npm:rimraf@2.5.0",
+ "sane": "npm:sane@1.3.3",
+ "semver": "npm:semver@5.1.0",
+ "systemjs": "npm:systemjs@0.19.29",
+ "systemjs-builder": "npm:systemjs-builder@0.15.18",
+ "traceur": "npm:traceur@0.0.105",
+ "uglify-js": "npm:uglify-js@2.6.1",
+ "resolve": "npm:resolve@1.1.7"
+ }
+ },
+ "github:jspm/nodelibs-buffer@0.2.0-alpha": {
+ "map": {
+ "buffer-browserify": "npm:buffer@4.5.0"
+ }
+ },
+ "github:jspm/nodelibs-crypto@0.2.0-alpha": {
+ "map": {
+ "crypto-browserify": "npm:crypto-browserify@3.11.0"
+ }
+ },
+ "github:jspm/nodelibs-http@0.2.0-alpha": {
+ "map": {
+ "http-browserify": "npm:stream-http@2.0.5"
+ }
+ },
+ "github:jspm/nodelibs-os@0.2.0-alpha": {
+ "map": {
+ "os-browserify": "npm:os-browserify@0.2.0"
+ }
+ },
+ "github:jspm/nodelibs-punycode@0.2.0-alpha": {
+ "map": {
+ "punycode-browserify": "npm:punycode@1.3.2"
+ }
+ },
+ "github:jspm/nodelibs-stream@0.2.0-alpha": {
+ "map": {
+ "stream-browserify": "npm:stream-browserify@2.0.1"
+ }
+ },
+ "github:jspm/nodelibs-string_decoder@0.2.0-alpha": {
+ "map": {
+ "string_decoder-browserify": "npm:string_decoder@0.10.31"
+ }
+ },
+ "github:jspm/nodelibs-url@0.2.0-alpha": {
+ "map": {
+ "url-browserify": "npm:url@0.11.0"
+ }
+ },
+ "github:jspm/nodelibs-zlib@0.2.0-alpha": {
+ "map": {
+ "zlib-browserify": "npm:browserify-zlib@0.1.4"
+ }
+ },
+ "npm:loose-envify@1.1.0": {
+ "map": {
+ "js-tokens": "npm:js-tokens@1.0.3"
+ }
+ },
+ "npm:makeerror@1.0.11": {
+ "map": {
+ "tmpl": "npm:tmpl@1.0.4"
+ }
+ },
+ "npm:minimatch@0.2.14": {
+ "map": {
+ "lru-cache": "npm:lru-cache@2.7.3",
+ "sigmund": "npm:sigmund@1.0.1"
+ }
+ },
+ "npm:mocha@1.21.5": {
+ "map": {
+ "css": "github:systemjs/plugin-css@0.1.20"
+ }
+ },
+ "npm:repeating@1.1.3": {
+ "map": {
+ "is-finite": "npm:is-finite@1.0.1"
+ }
+ },
+ "npm:rollup@0.25.8": {
+ "map": {
+ "chalk": "npm:chalk@1.1.1",
+ "minimist": "npm:minimist@1.2.0",
+ "source-map-support": "npm:source-map-support@0.3.3"
+ }
+ },
+ "npm:sane@1.3.3": {
+ "map": {
+ "exec-sh": "npm:exec-sh@0.2.0",
+ "fb-watchman": "npm:fb-watchman@1.9.0",
+ "minimatch": "npm:minimatch@0.2.14",
+ "minimist": "npm:minimist@1.2.0",
+ "walker": "npm:walker@1.0.7",
+ "watch": "npm:watch@0.10.0"
+ }
+ },
+ "npm:sha.js@2.4.5": {
+ "map": {
+ "inherits": "npm:inherits@2.0.1"
+ }
+ },
+ "npm:sshpk@1.7.3": {
+ "map": {
+ "asn1": "npm:asn1@0.2.3",
+ "assert-plus": "npm:assert-plus@0.2.0",
+ "dashdash": "npm:dashdash@1.13.0"
+ }
+ },
+ "npm:stream-browserify@1.0.0": {
+ "map": {
+ "inherits": "npm:inherits@2.0.1",
+ "readable-stream": "npm:readable-stream@1.0.33"
+ }
+ },
+ "npm:stream-http@2.0.5": {
+ "map": {
+ "builtin-status-codes": "npm:builtin-status-codes@1.0.0",
+ "inherits": "npm:inherits@2.0.1",
+ "xtend": "npm:xtend@4.0.1"
+ }
+ },
+ "npm:string_decoder@0.10.31": {
+ "map": {}
+ },
+ "github:twbs/bootstrap@3.3.6": {
+ "map": {
+ "jquery": "github:components/jquery@2.1.4"
+ }
+ },
+ "npm:align-text@0.1.3": {
+ "map": {
+ "kind-of": "npm:kind-of@2.0.1",
+ "longest": "npm:longest@1.0.1",
+ "repeat-string": "npm:repeat-string@1.5.2"
+ }
+ },
+ "npm:ao-mesher@0.2.10": {
+ "map": {
+ "cwise-compiler": "npm:cwise-compiler@0.1.0",
+ "greedy-mesher": "npm:greedy-mesher@1.0.2",
+ "ndarray": "npm:ndarray@1.0.18",
+ "typedarray-pool": "npm:typedarray-pool@0.1.2"
+ }
+ },
+ "npm:ao-shader@0.2.3": {
+ "map": {
+ "brfs": "npm:brfs@0.0.9",
+ "gl-shader": "npm:gl-shader@0.0.6"
+ }
+ },
+ "npm:bl@0.9.4": {
+ "map": {
+ "readable-stream": "npm:readable-stream@1.0.33"
+ }
+ },
+ "npm:bl@1.0.0": {
+ "map": {
+ "readable-stream": "npm:readable-stream@2.0.5"
+ }
+ },
+ "npm:block-stream@0.0.8": {
+ "map": {
+ "inherits": "npm:inherits@2.0.1"
+ }
+ },
+ "npm:boom@2.10.1": {
+ "map": {
+ "hoek": "npm:hoek@2.16.3"
+ }
+ },
+ "npm:brace-expansion@1.1.2": {
+ "map": {
+ "balanced-match": "npm:balanced-match@0.3.0",
+ "concat-map": "npm:concat-map@0.0.1"
+ }
+ },
+ "npm:brfs@0.0.9": {
+ "map": {
+ "escodegen": "npm:escodegen@0.0.17",
+ "falafel": "npm:falafel@0.1.6",
+ "through": "npm:through@2.2.7"
+ }
+ },
+ "npm:browserify-cipher@1.0.0": {
+ "map": {
+ "browserify-aes": "npm:browserify-aes@1.0.6",
+ "browserify-des": "npm:browserify-des@1.0.0",
+ "evp_bytestokey": "npm:evp_bytestokey@1.0.0"
+ }
+ },
+ "npm:browserify-des@1.0.0": {
+ "map": {
+ "cipher-base": "npm:cipher-base@1.0.2",
+ "des.js": "npm:des.js@1.0.0",
+ "inherits": "npm:inherits@2.0.1"
+ }
+ },
+ "npm:browserify-sign@4.0.0": {
+ "map": {
+ "bn.js": "npm:bn.js@4.11.0",
+ "browserify-rsa": "npm:browserify-rsa@4.0.1",
+ "create-hash": "npm:create-hash@1.1.2",
+ "create-hmac": "npm:create-hmac@1.1.4",
+ "elliptic": "npm:elliptic@6.2.3",
+ "inherits": "npm:inherits@2.0.1",
+ "parse-asn1": "npm:parse-asn1@5.0.0"
+ }
+ },
+ "npm:browserify-zlib@0.1.4": {
+ "map": {
+ "pako": "npm:pako@0.2.8",
+ "readable-stream": "npm:readable-stream@1.0.33"
+ }
+ },
+ "npm:center-align@0.1.2": {
+ "map": {
+ "align-text": "npm:align-text@0.1.3",
+ "lazy-cache": "npm:lazy-cache@0.2.7"
+ }
+ },
+ "npm:chalk@1.1.1": {
+ "map": {
+ "ansi-styles": "npm:ansi-styles@2.1.0",
+ "escape-string-regexp": "npm:escape-string-regexp@1.0.4",
+ "has-ansi": "npm:has-ansi@2.0.0",
+ "strip-ansi": "npm:strip-ansi@3.0.0",
+ "supports-color": "npm:supports-color@2.0.0"
+ }
+ },
+ "npm:cipher-base@1.0.2": {
+ "map": {
+ "inherits": "npm:inherits@2.0.1"
+ }
+ },
+ "npm:clean-css@3.4.9": {
+ "map": {
+ "commander": "npm:commander@2.8.1",
+ "source-map": "npm:source-map@0.4.4"
+ }
+ },
+ "npm:cliui@2.1.0": {
+ "map": {
+ "center-align": "npm:center-align@0.1.2",
+ "right-align": "npm:right-align@0.1.3",
+ "wordwrap": "npm:wordwrap@0.0.2"
+ }
+ },
+ "npm:combined-stream@0.0.7": {
+ "map": {
+ "delayed-stream": "npm:delayed-stream@0.0.5"
+ }
+ },
+ "npm:combined-stream@1.0.5": {
+ "map": {
+ "delayed-stream": "npm:delayed-stream@1.0.0"
+ }
+ },
+ "npm:commander@2.8.1": {
+ "map": {
+ "graceful-readlink": "npm:graceful-readlink@1.0.1"
+ }
+ },
+ "npm:commander@2.9.0": {
+ "map": {
+ "graceful-readlink": "npm:graceful-readlink@1.0.1"
+ }
+ },
+ "npm:create-ecdh@4.0.0": {
+ "map": {
+ "bn.js": "npm:bn.js@4.11.0",
+ "elliptic": "npm:elliptic@6.2.3"
+ }
+ },
+ "npm:create-hash@1.1.2": {
+ "map": {
+ "cipher-base": "npm:cipher-base@1.0.2",
+ "inherits": "npm:inherits@2.0.1",
+ "ripemd160": "npm:ripemd160@1.0.1",
+ "sha.js": "npm:sha.js@2.4.5"
+ }
+ },
+ "npm:create-hmac@1.1.4": {
+ "map": {
+ "create-hash": "npm:create-hash@1.1.2",
+ "inherits": "npm:inherits@2.0.1"
+ }
+ },
+ "npm:cryptiles@2.0.5": {
+ "map": {
+ "boom": "npm:boom@2.10.1"
+ }
+ },
+ "npm:crypto-browserify@3.11.0": {
+ "map": {
+ "browserify-cipher": "npm:browserify-cipher@1.0.0",
+ "browserify-sign": "npm:browserify-sign@4.0.0",
+ "create-ecdh": "npm:create-ecdh@4.0.0",
+ "create-hash": "npm:create-hash@1.1.2",
+ "create-hmac": "npm:create-hmac@1.1.4",
+ "diffie-hellman": "npm:diffie-hellman@5.0.2",
+ "inherits": "npm:inherits@2.0.1",
+ "pbkdf2": "npm:pbkdf2@3.0.4",
+ "public-encrypt": "npm:public-encrypt@4.0.0",
+ "randombytes": "npm:randombytes@2.0.3"
+ }
+ },
+ "npm:cwise-compiler@0.0.0": {
+ "map": {
+ "uniq": "npm:uniq@0.0.2"
+ }
+ },
+ "npm:cwise-compiler@0.1.0": {
+ "map": {
+ "uniq": "npm:uniq@0.0.2"
+ }
+ },
+ "npm:cwise-parser@0.0.1": {
+ "map": {
+ "esprima": "npm:esprima@1.0.4",
+ "uniq": "npm:uniq@0.0.2"
+ }
+ },
+ "npm:cwise@0.3.4": {
+ "map": {
+ "cwise-compiler": "npm:cwise-compiler@0.0.0",
+ "cwise-parser": "npm:cwise-parser@0.0.1"
+ }
+ },
+ "npm:d@0.1.1": {
+ "map": {
+ "es5-ext": "npm:es5-ext@0.10.11"
+ }
+ },
+ "npm:decamelize@1.1.2": {
+ "map": {
+ "escape-string-regexp": "npm:escape-string-regexp@1.0.4"
+ }
+ },
+ "npm:des.js@1.0.0": {
+ "map": {
+ "inherits": "npm:inherits@2.0.1",
+ "minimalistic-assert": "npm:minimalistic-assert@1.0.0"
+ }
+ },
+ "npm:ecc-jsbn@0.1.1": {
+ "map": {
+ "jsbn": "npm:jsbn@0.1.0"
+ }
+ },
+ "npm:es5-ext@0.10.11": {
+ "map": {
+ "es6-iterator": "npm:es6-iterator@2.0.0",
+ "es6-symbol": "npm:es6-symbol@3.0.2"
+ }
+ },
+ "npm:es6-iterator@2.0.0": {
+ "map": {
+ "d": "npm:d@0.1.1",
+ "es5-ext": "npm:es5-ext@0.10.11",
+ "es6-symbol": "npm:es6-symbol@3.0.2"
+ }
+ },
+ "npm:es6-symbol@3.0.2": {
+ "map": {
+ "d": "npm:d@0.1.1",
+ "es5-ext": "npm:es5-ext@0.10.11"
+ }
+ },
+ "npm:es6-template-strings@2.0.0": {
+ "map": {
+ "es5-ext": "npm:es5-ext@0.10.11",
+ "esniff": "npm:esniff@1.0.0"
+ }
+ },
+ "npm:escodegen@0.0.17": {
+ "map": {
+ "esprima": "npm:esprima@1.0.4",
+ "estraverse": "npm:estraverse@0.0.4"
+ }
+ },
+ "npm:esniff@1.0.0": {
+ "map": {
+ "d": "npm:d@0.1.1",
+ "es5-ext": "npm:es5-ext@0.10.11"
+ }
+ },
+ "npm:evp_bytestokey@1.0.0": {
+ "map": {
+ "create-hash": "npm:create-hash@1.1.2"
+ }
+ },
+ "npm:expand-tilde@1.2.0": {
+ "map": {
+ "user-home": "npm:user-home@1.1.1"
+ }
+ },
+ "npm:falafel@0.1.6": {
+ "map": {
+ "esprima": "npm:esprima@1.0.4"
+ }
+ },
+ "npm:findup-sync@0.3.0": {
+ "map": {
+ "glob": "npm:glob@5.0.15"
+ }
+ },
+ "npm:form-data@0.2.0": {
+ "map": {
+ "async": "npm:async@0.9.2",
+ "combined-stream": "npm:combined-stream@0.0.7",
+ "mime-types": "npm:mime-types@2.0.14"
+ }
+ },
+ "npm:form-data@1.0.0-rc3": {
+ "map": {
+ "async": "npm:async@1.5.2",
+ "combined-stream": "npm:combined-stream@1.0.5",
+ "mime-types": "npm:mime-types@2.1.9"
+ }
+ },
+ "npm:fstream@1.0.8": {
+ "map": {
+ "graceful-fs": "npm:graceful-fs@4.1.2",
+ "inherits": "npm:inherits@2.0.1",
+ "mkdirp": "npm:mkdirp@0.5.1",
+ "rimraf": "npm:rimraf@2.5.0"
+ }
+ },
+ "npm:game-shell@0.1.4": {
+ "map": {
+ "domready": "npm:domready@0.2.13",
+ "invert-hash": "npm:invert-hash@0.0.0",
+ "iota-array": "npm:iota-array@0.0.1",
+ "lower-bound": "npm:lower-bound@0.0.3",
+ "uniq": "npm:uniq@0.0.2",
+ "vkey": "npm:vkey@0.0.3"
+ }
+ },
+ "npm:generate-object-property@1.2.0": {
+ "map": {
+ "is-property": "npm:is-property@1.0.2"
+ }
+ },
+ "npm:gl-buffer@0.1.2": {
+ "map": {
+ "ndarray": "npm:ndarray@1.0.18",
+ "ndarray-ops": "npm:ndarray-ops@1.1.1",
+ "typedarray-pool": "npm:typedarray-pool@0.1.2"
+ }
+ },
+ "npm:gl-now@0.0.4": {
+ "map": {
+ "game-shell": "npm:game-shell@0.1.4",
+ "webglew": "npm:webglew@0.0.0"
+ }
+ },
+ "npm:gl-shader@0.0.6": {
+ "map": {
+ "glsl-exports": "npm:glsl-exports@0.0.0",
+ "uniq": "npm:uniq@0.0.2"
+ }
+ },
+ "npm:gl-texture2d@0.1.12": {
+ "map": {
+ "bit-twiddle": "npm:bit-twiddle@0.0.2",
+ "cwise-compiler": "npm:cwise-compiler@0.1.0",
+ "ndarray": "npm:ndarray@1.0.18",
+ "ndarray-ops": "npm:ndarray-ops@1.1.1",
+ "typedarray-pool": "npm:typedarray-pool@1.1.0",
+ "webglew": "npm:webglew@0.0.0"
+ }
+ },
+ "npm:gl-tile-map@0.3.0": {
+ "map": {
+ "gl-texture2d": "npm:gl-texture2d@0.1.12",
+ "ndarray": "npm:ndarray@1.0.18",
+ "tile-mip-map": "npm:tile-mip-map@0.2.1",
+ "webglew": "npm:webglew@0.0.0"
+ }
+ },
+ "npm:gl-vao@0.0.3": {
+ "map": {
+ "webglew": "npm:webglew@0.0.0"
+ }
+ },
+ "npm:glob@4.5.3": {
+ "map": {
+ "inflight": "npm:inflight@1.0.4",
+ "inherits": "npm:inherits@2.0.1",
+ "minimatch": "npm:minimatch@2.0.10",
+ "once": "npm:once@1.3.3"
+ }
+ },
+ "npm:glob@5.0.15": {
+ "map": {
+ "inflight": "npm:inflight@1.0.4",
+ "inherits": "npm:inherits@2.0.1",
+ "minimatch": "npm:minimatch@3.0.0",
+ "once": "npm:once@1.3.3",
+ "path-is-absolute": "npm:path-is-absolute@1.0.0"
+ }
+ },
+ "npm:glsl-exports@0.0.0": {
+ "map": {
+ "glsl-parser": "npm:glsl-parser@0.0.9",
+ "glsl-tokenizer": "npm:glsl-tokenizer@0.0.9",
+ "through": "npm:through@2.3.8"
+ }
+ },
+ "npm:glsl-parser@0.0.9": {
+ "map": {
+ "glsl-tokenizer": "npm:glsl-tokenizer@0.0.9",
+ "through": "npm:through@1.1.2"
+ }
+ },
+ "npm:glsl-tokenizer@0.0.9": {
+ "map": {
+ "through": "npm:through@2.3.8"
+ }
+ },
+ "npm:greedy-mesher@1.0.2": {
+ "map": {
+ "iota-array": "npm:iota-array@1.0.0",
+ "typedarray-pool": "npm:typedarray-pool@1.1.0",
+ "uniq": "npm:uniq@1.0.1"
+ }
+ },
+ "npm:har-validator@1.8.0": {
+ "map": {
+ "bluebird": "npm:bluebird@2.10.2",
+ "chalk": "npm:chalk@1.1.1",
+ "commander": "npm:commander@2.9.0",
+ "is-my-json-valid": "npm:is-my-json-valid@2.12.3"
+ }
+ },
+ "npm:har-validator@2.0.3": {
+ "map": {
+ "chalk": "npm:chalk@1.1.1",
+ "commander": "npm:commander@2.9.0",
+ "is-my-json-valid": "npm:is-my-json-valid@2.12.3",
+ "pinkie-promise": "npm:pinkie-promise@2.0.0"
+ }
+ },
+ "npm:has-ansi@2.0.0": {
+ "map": {
+ "ansi-regex": "npm:ansi-regex@2.0.0"
+ }
+ },
+ "npm:hash.js@1.0.3": {
+ "map": {
+ "inherits": "npm:inherits@2.0.1"
+ }
+ },
+ "npm:hawk@2.3.1": {
+ "map": {
+ "boom": "npm:boom@2.10.1",
+ "cryptiles": "npm:cryptiles@2.0.5",
+ "hoek": "npm:hoek@2.16.3",
+ "sntp": "npm:sntp@1.0.9"
+ }
+ },
+ "npm:hawk@3.1.2": {
+ "map": {
+ "boom": "npm:boom@2.10.1",
+ "cryptiles": "npm:cryptiles@2.0.5",
+ "hoek": "npm:hoek@2.16.3",
+ "sntp": "npm:sntp@1.0.9"
+ }
+ },
+ "npm:http-signature@0.10.1": {
+ "map": {
+ "asn1": "npm:asn1@0.1.11",
+ "assert-plus": "npm:assert-plus@0.1.5",
+ "ctype": "npm:ctype@0.5.3"
+ }
+ },
+ "npm:http-signature@0.11.0": {
+ "map": {
+ "asn1": "npm:asn1@0.1.11",
+ "assert-plus": "npm:assert-plus@0.1.5",
+ "ctype": "npm:ctype@0.5.3"
+ }
+ },
+ "npm:http-signature@1.1.0": {
+ "map": {
+ "assert-plus": "npm:assert-plus@0.1.5",
+ "jsprim": "npm:jsprim@1.2.2",
+ "sshpk": "npm:sshpk@1.7.3"
+ }
+ },
+ "npm:inflight@1.0.4": {
+ "map": {
+ "once": "npm:once@1.3.3",
+ "wrappy": "npm:wrappy@1.0.1"
+ }
+ },
+ "npm:is-absolute@0.1.7": {
+ "map": {
+ "is-relative": "npm:is-relative@0.1.3"
+ }
+ },
+ "npm:is-my-json-valid@2.12.3": {
+ "map": {
+ "generate-function": "npm:generate-function@2.0.0",
+ "generate-object-property": "npm:generate-object-property@1.2.0",
+ "jsonpointer": "npm:jsonpointer@2.0.0",
+ "xtend": "npm:xtend@4.0.1"
+ }
+ },
+ "npm:jodid25519@1.0.2": {
+ "map": {
+ "jsbn": "npm:jsbn@0.1.0"
+ }
+ },
+ "npm:jspm-registry@0.4.0": {
+ "map": {
+ "graceful-fs": "npm:graceful-fs@3.0.8",
+ "rimraf": "npm:rimraf@2.5.0",
+ "rsvp": "npm:rsvp@3.1.0",
+ "semver": "npm:semver@4.3.6"
+ }
+ },
+ "npm:jsprim@1.2.2": {
+ "map": {
+ "extsprintf": "npm:extsprintf@1.0.2",
+ "json-schema": "npm:json-schema@0.2.2",
+ "verror": "npm:verror@1.3.6"
+ }
+ },
+ "npm:kind-of@2.0.1": {
+ "map": {
+ "is-buffer": "npm:is-buffer@1.1.1"
+ }
+ },
+ "npm:liftoff@2.2.0": {
+ "map": {
+ "extend": "npm:extend@2.0.1",
+ "findup-sync": "npm:findup-sync@0.3.0",
+ "flagged-respawn": "npm:flagged-respawn@0.3.1",
+ "rechoir": "npm:rechoir@0.6.2",
+ "resolve": "npm:resolve@1.1.6"
+ }
+ },
+ "npm:miller-rabin@4.0.0": {
+ "map": {
+ "bn.js": "npm:bn.js@4.11.0",
+ "brorand": "npm:brorand@1.0.5"
+ }
+ },
+ "npm:mime-types@2.0.14": {
+ "map": {
+ "mime-db": "npm:mime-db@1.12.0"
+ }
+ },
+ "npm:mime-types@2.1.9": {
+ "map": {
+ "mime-db": "npm:mime-db@1.21.0"
+ }
+ },
+ "npm:minimatch@2.0.10": {
+ "map": {
+ "brace-expansion": "npm:brace-expansion@1.1.2"
+ }
+ },
+ "npm:minimatch@3.0.0": {
+ "map": {
+ "brace-expansion": "npm:brace-expansion@1.1.2"
+ }
+ },
+ "npm:mkdirp@0.5.1": {
+ "map": {
+ "minimist": "npm:minimist@0.0.8"
+ }
+ },
+ "npm:ndarray-downsample2x@0.1.1": {
+ "map": {
+ "cwise": "npm:cwise@0.3.4",
+ "ndarray-fft": "npm:ndarray-fft@0.1.0",
+ "ndarray-ops": "npm:ndarray-ops@1.1.1",
+ "ndarray-scratch": "npm:ndarray-scratch@0.0.1"
+ }
+ },
+ "npm:ndarray-fft@0.1.0": {
+ "map": {
+ "bit-twiddle": "npm:bit-twiddle@0.0.2",
+ "cwise": "npm:cwise@0.3.4",
+ "ndarray": "npm:ndarray@1.0.18",
+ "ndarray-ops": "npm:ndarray-ops@1.1.1",
+ "typedarray-pool": "npm:typedarray-pool@0.1.2"
+ }
+ },
+ "npm:ndarray-fill@0.1.0": {
+ "map": {
+ "cwise": "npm:cwise@0.3.4"
+ }
+ },
+ "npm:ndarray-ops@1.1.1": {
+ "map": {
+ "cwise-compiler": "npm:cwise-compiler@0.0.0"
+ }
+ },
+ "npm:ndarray-scratch@0.0.1": {
+ "map": {
+ "ndarray": "npm:ndarray@1.0.18",
+ "typedarray-pool": "npm:typedarray-pool@0.1.2"
+ }
+ },
+ "npm:ndarray@1.0.18": {
+ "map": {
+ "iota-array": "npm:iota-array@1.0.0",
+ "is-buffer": "npm:is-buffer@1.1.1"
+ }
+ },
+ "npm:node.extend@1.0.8": {
+ "map": {
+ "is": "npm:is@0.2.7",
+ "object-keys": "npm:object-keys@0.4.0"
+ }
+ },
+ "npm:node.flow@1.2.3": {
+ "map": {
+ "node.extend": "npm:node.extend@1.0.8"
+ }
+ },
+ "npm:once@1.3.3": {
+ "map": {
+ "wrappy": "npm:wrappy@1.0.1"
+ }
+ },
+ "npm:parse-asn1@5.0.0": {
+ "map": {
+ "asn1.js": "npm:asn1.js@4.5.1",
+ "browserify-aes": "npm:browserify-aes@1.0.6",
+ "create-hash": "npm:create-hash@1.1.2",
+ "evp_bytestokey": "npm:evp_bytestokey@1.0.0",
+ "pbkdf2": "npm:pbkdf2@3.0.4"
+ }
+ },
+ "npm:pbkdf2@3.0.4": {
+ "map": {
+ "create-hmac": "npm:create-hmac@1.1.4"
+ }
+ },
+ "npm:pinkie-promise@2.0.0": {
+ "map": {
+ "pinkie": "npm:pinkie@2.0.1"
+ }
+ },
+ "npm:proper-lockfile@1.1.1": {
+ "map": {
+ "err-code": "npm:err-code@1.0.0",
+ "extend": "npm:extend@3.0.0",
+ "graceful-fs": "npm:graceful-fs@4.1.2",
+ "retry": "npm:retry@0.8.0"
+ }
+ },
+ "npm:public-encrypt@4.0.0": {
+ "map": {
+ "bn.js": "npm:bn.js@4.11.0",
+ "browserify-rsa": "npm:browserify-rsa@4.0.1",
+ "create-hash": "npm:create-hash@1.1.2",
+ "parse-asn1": "npm:parse-asn1@5.0.0",
+ "randombytes": "npm:randombytes@2.0.3"
+ }
+ },
+ "npm:readable-stream@1.0.33": {
+ "map": {
+ "core-util-is": "npm:core-util-is@1.0.2",
+ "inherits": "npm:inherits@2.0.1",
+ "isarray": "npm:isarray@0.0.1",
+ "stream-browserify": "npm:stream-browserify@1.0.0",
+ "string_decoder": "npm:string_decoder@0.10.31"
+ }
+ },
+ "npm:readable-stream@2.0.5": {
+ "map": {
+ "core-util-is": "npm:core-util-is@1.0.2",
+ "inherits": "npm:inherits@2.0.1",
+ "isarray": "npm:isarray@0.0.1",
+ "process-nextick-args": "npm:process-nextick-args@1.0.6",
+ "string_decoder": "npm:string_decoder@0.10.31",
+ "util-deprecate": "npm:util-deprecate@1.0.2"
+ }
+ },
+ "npm:readdirp@2.0.0": {
+ "map": {
+ "graceful-fs": "npm:graceful-fs@4.1.2",
+ "minimatch": "npm:minimatch@2.0.10",
+ "readable-stream": "npm:readable-stream@2.0.5"
+ }
+ },
+ "npm:rechoir@0.6.2": {
+ "map": {
+ "resolve": "npm:resolve@1.1.6"
+ }
+ },
+ "npm:request@2.53.0": {
+ "map": {
+ "aws-sign2": "npm:aws-sign2@0.5.0",
+ "bl": "npm:bl@0.9.4",
+ "caseless": "npm:caseless@0.9.0",
+ "combined-stream": "npm:combined-stream@0.0.7",
+ "forever-agent": "npm:forever-agent@0.5.2",
+ "form-data": "npm:form-data@0.2.0",
+ "hawk": "npm:hawk@2.3.1",
+ "http-signature": "npm:http-signature@0.10.1",
+ "isstream": "npm:isstream@0.1.2",
+ "json-stringify-safe": "npm:json-stringify-safe@5.0.1",
+ "mime-types": "npm:mime-types@2.0.14",
+ "node-uuid": "npm:node-uuid@1.4.7",
+ "oauth-sign": "npm:oauth-sign@0.6.0",
+ "qs": "npm:qs@2.3.3",
+ "stringstream": "npm:stringstream@0.0.5",
+ "tough-cookie": "npm:tough-cookie@2.2.1",
+ "tunnel-agent": "npm:tunnel-agent@0.4.2"
+ }
+ },
+ "npm:request@2.58.0": {
+ "map": {
+ "aws-sign2": "npm:aws-sign2@0.5.0",
+ "bl": "npm:bl@0.9.4",
+ "caseless": "npm:caseless@0.10.0",
+ "combined-stream": "npm:combined-stream@1.0.5",
+ "extend": "npm:extend@2.0.1",
+ "forever-agent": "npm:forever-agent@0.6.1",
+ "form-data": "npm:form-data@1.0.0-rc3",
+ "har-validator": "npm:har-validator@1.8.0",
+ "hawk": "npm:hawk@2.3.1",
+ "http-signature": "npm:http-signature@0.11.0",
+ "isstream": "npm:isstream@0.1.2",
+ "json-stringify-safe": "npm:json-stringify-safe@5.0.1",
+ "mime-types": "npm:mime-types@2.0.14",
+ "node-uuid": "npm:node-uuid@1.4.7",
+ "oauth-sign": "npm:oauth-sign@0.8.0",
+ "qs": "npm:qs@3.1.0",
+ "stringstream": "npm:stringstream@0.0.5",
+ "tough-cookie": "npm:tough-cookie@2.2.1",
+ "tunnel-agent": "npm:tunnel-agent@0.4.2"
+ }
+ },
+ "npm:request@2.67.0": {
+ "map": {
+ "aws-sign2": "npm:aws-sign2@0.6.0",
+ "bl": "npm:bl@1.0.0",
+ "caseless": "npm:caseless@0.11.0",
+ "combined-stream": "npm:combined-stream@1.0.5",
+ "extend": "npm:extend@3.0.0",
+ "forever-agent": "npm:forever-agent@0.6.1",
+ "form-data": "npm:form-data@1.0.0-rc3",
+ "har-validator": "npm:har-validator@2.0.3",
+ "hawk": "npm:hawk@3.1.2",
+ "http-signature": "npm:http-signature@1.1.0",
+ "is-typedarray": "npm:is-typedarray@1.0.0",
+ "isstream": "npm:isstream@0.1.2",
+ "json-stringify-safe": "npm:json-stringify-safe@5.0.1",
+ "mime-types": "npm:mime-types@2.1.9",
+ "node-uuid": "npm:node-uuid@1.4.7",
+ "oauth-sign": "npm:oauth-sign@0.8.0",
+ "qs": "npm:qs@5.2.0",
+ "stringstream": "npm:stringstream@0.0.5",
+ "tough-cookie": "npm:tough-cookie@2.2.1",
+ "tunnel-agent": "npm:tunnel-agent@0.4.2"
+ }
+ },
+ "npm:right-align@0.1.3": {
+ "map": {
+ "align-text": "npm:align-text@0.1.3"
+ }
+ },
+ "npm:rimraf@2.3.4": {
+ "map": {
+ "glob": "npm:glob@4.5.3"
+ }
+ },
+ "npm:rimraf@2.5.0": {
+ "map": {
+ "glob": "npm:glob@6.0.4"
+ }
+ },
+ "npm:rmdir@1.1.0": {
+ "map": {
+ "node.flow": "npm:node.flow@1.2.3"
+ }
+ },
+ "npm:sntp@1.0.9": {
+ "map": {
+ "hoek": "npm:hoek@2.16.3"
+ }
+ },
+ "npm:source-map-support@0.2.10": {
+ "map": {
+ "source-map": "npm:source-map@0.1.32"
+ }
+ },
+ "npm:source-map-support@0.3.3": {
+ "map": {
+ "source-map": "npm:source-map@0.1.32"
+ }
+ },
+ "npm:source-map@0.1.32": {
+ "map": {
+ "amdefine": "npm:amdefine@1.0.0"
+ }
+ },
+ "npm:source-map@0.4.4": {
+ "map": {
+ "amdefine": "npm:amdefine@1.0.0"
+ }
+ },
+ "npm:stream-browserify@2.0.1": {
+ "map": {
+ "inherits": "npm:inherits@2.0.1",
+ "readable-stream": "npm:readable-stream@2.0.5"
+ }
+ },
+ "npm:strip-ansi@3.0.0": {
+ "map": {
+ "ansi-regex": "npm:ansi-regex@2.0.0"
+ }
+ },
+ "npm:systemjs@0.19.29": {
+ "map": {
+ "when": "npm:when@3.7.7"
+ }
+ },
+ "npm:tar@1.0.3": {
+ "map": {
+ "block-stream": "npm:block-stream@0.0.8",
+ "fstream": "npm:fstream@1.0.8",
+ "inherits": "npm:inherits@2.0.1"
+ }
+ },
+ "npm:tar@2.2.1": {
+ "map": {
+ "block-stream": "npm:block-stream@0.0.8",
+ "fstream": "npm:fstream@1.0.8",
+ "inherits": "npm:inherits@2.0.1"
+ }
+ },
+ "npm:through@1.1.2": {
+ "map": {}
+ },
+ "npm:through@2.2.7": {
+ "map": {}
+ },
+ "npm:tile-mip-map@0.2.1": {
+ "map": {
+ "ndarray": "npm:ndarray@1.0.18",
+ "ndarray-downsample2x": "npm:ndarray-downsample2x@0.1.1",
+ "ndarray-ops": "npm:ndarray-ops@1.1.1"
+ }
+ },
+ "npm:traceur@0.0.105": {
+ "map": {
+ "commander": "npm:commander@2.9.0",
+ "glob": "npm:glob@5.0.15",
+ "rsvp": "npm:rsvp@3.1.0",
+ "semver": "npm:semver@4.3.6",
+ "source-map-support": "npm:source-map-support@0.2.10"
+ }
+ },
+ "npm:typedarray-pool@0.1.2": {
+ "map": {
+ "bit-twiddle": "npm:bit-twiddle@0.0.2",
+ "dup": "npm:dup@0.0.0"
+ }
+ },
+ "npm:typedarray-pool@1.1.0": {
+ "map": {
+ "bit-twiddle": "npm:bit-twiddle@1.0.2",
+ "dup": "npm:dup@1.0.0"
+ }
+ },
+ "npm:uglify-js@2.6.1": {
+ "map": {
+ "async": "npm:async@0.2.10",
+ "source-map": "npm:source-map@0.5.3",
+ "uglify-to-browserify": "npm:uglify-to-browserify@1.0.2",
+ "yargs": "npm:yargs@3.10.0"
+ }
+ },
+ "npm:url@0.11.0": {
+ "map": {
+ "punycode": "npm:punycode@1.3.2",
+ "querystring": "npm:querystring@0.2.0"
+ }
+ },
+ "npm:verror@1.3.6": {
+ "map": {
+ "extsprintf": "npm:extsprintf@1.0.2"
+ }
+ },
+ "npm:voxel-demo@0.0.1": {
+ "map": {
+ "ao-mesher": "npm:ao-mesher@0.2.10",
+ "ao-shader": "npm:ao-shader@0.2.3",
+ "gl-buffer": "npm:gl-buffer@0.1.2",
+ "gl-matrix": "npm:gl-matrix@2.0.0",
+ "gl-now": "npm:gl-now@0.0.4",
+ "gl-shader": "npm:gl-shader@0.0.6",
+ "gl-tile-map": "npm:gl-tile-map@0.3.0",
+ "gl-vao": "npm:gl-vao@0.0.3",
+ "ndarray": "npm:ndarray@1.0.18",
+ "ndarray-fill": "npm:ndarray-fill@0.1.0",
+ "ndarray-ops": "npm:ndarray-ops@1.1.1"
+ }
+ },
+ "npm:walker@1.0.7": {
+ "map": {
+ "makeerror": "npm:makeerror@1.0.11"
+ }
+ },
+ "npm:which@1.2.1": {
+ "map": {
+ "is-absolute": "npm:is-absolute@0.1.7"
+ }
+ },
+ "npm:yargs@3.10.0": {
+ "map": {
+ "camelcase": "npm:camelcase@1.2.1",
+ "cliui": "npm:cliui@2.1.0",
+ "decamelize": "npm:decamelize@1.1.2",
+ "window-size": "npm:window-size@0.1.0"
+ }
+ },
+ "github:jspm/nodelibs-domain@0.2.0-alpha": {
+ "map": {
+ "domain-browserify": "npm:domain-browser@1.1.7"
+ }
+ },
+ "github:jspm/nodelibs-timers@0.2.0-alpha": {
+ "map": {
+ "timers-browserify": "npm:timers-browserify@1.4.2"
+ }
+ },
+ "npm:timers-browserify@1.4.2": {
+ "map": {
+ "process": "npm:process@0.11.3"
+ }
+ },
+ "npm:systemjs-builder@0.15.18": {
+ "map": {
+ "babel-plugin-transform-es2015-modules-systemjs": "npm:babel-plugin-transform-es2015-modules-systemjs@6.6.5",
+ "bluebird": "npm:bluebird@3.3.5",
+ "es6-template-strings": "npm:es6-template-strings@2.0.0",
+ "glob": "npm:glob@7.0.3",
+ "mkdirp": "npm:mkdirp@0.5.1",
+ "rollup": "npm:rollup@0.25.8",
+ "source-map": "npm:source-map@0.5.3",
+ "systemjs": "npm:systemjs@0.19.29",
+ "traceur": "npm:traceur@0.0.105",
+ "uglify-js": "npm:uglify-js@2.6.1",
+ "data-uri-to-buffer": "npm:data-uri-to-buffer@0.0.4",
+ "babel-core": "npm:babel-core@6.9.0"
+ }
+ },
+ "npm:babel-core@6.9.0": {
+ "map": {
+ "babylon": "npm:babylon@6.7.0",
+ "convert-source-map": "npm:convert-source-map@1.2.0",
+ "debug": "npm:debug@2.2.0",
+ "json5": "npm:json5@0.4.0",
+ "minimatch": "npm:minimatch@2.0.10",
+ "path-exists": "npm:path-exists@1.0.0",
+ "path-is-absolute": "npm:path-is-absolute@1.0.0",
+ "private": "npm:private@0.1.6",
+ "shebang-regex": "npm:shebang-regex@1.0.0",
+ "slash": "npm:slash@1.0.0",
+ "source-map": "npm:source-map@0.5.3",
+ "babel-code-frame": "npm:babel-code-frame@6.8.0",
+ "babel-messages": "npm:babel-messages@6.8.0",
+ "babel-generator": "npm:babel-generator@6.9.0",
+ "babel-runtime": "npm:babel-runtime@6.9.0",
+ "babel-traverse": "npm:babel-traverse@6.9.0",
+ "babel-types": "npm:babel-types@6.9.0",
+ "babel-register": "npm:babel-register@6.9.0",
+ "babel-template": "npm:babel-template@6.9.0",
+ "lodash": "npm:lodash@4.13.1",
+ "babel-helpers": "npm:babel-helpers@6.8.0"
+ }
+ },
+ "npm:jspm-npm@0.28.12": {
+ "map": {
+ "bluebird": "npm:bluebird@3.3.5",
+ "mkdirp": "npm:mkdirp@0.5.1",
+ "readdirp": "npm:readdirp@2.0.0",
+ "request": "npm:request@2.58.0",
+ "rmdir": "npm:rmdir@1.1.0",
+ "semver": "npm:semver@5.1.0",
+ "systemjs-builder": "npm:systemjs-builder@0.15.18",
+ "tar": "npm:tar@1.0.3",
+ "traceur": "npm:traceur@0.0.105",
+ "which": "npm:which@1.2.1",
+ "graceful-fs": "npm:graceful-fs@4.1.4"
+ }
+ },
+ "npm:babel-runtime@6.9.0": {
+ "map": {
+ "core-js": "npm:core-js@2.4.0"
+ }
+ },
+ "npm:babel-register@6.9.0": {
+ "map": {
+ "core-js": "npm:core-js@2.4.0",
+ "babel-core": "npm:babel-core@6.9.0",
+ "babel-runtime": "npm:babel-runtime@6.9.0",
+ "home-or-tmp": "npm:home-or-tmp@1.0.0",
+ "lodash": "npm:lodash@4.13.1",
+ "mkdirp": "npm:mkdirp@0.5.1",
+ "path-exists": "npm:path-exists@1.0.0",
+ "source-map-support": "npm:source-map-support@0.2.10"
+ }
+ },
+ "npm:babel-code-frame@6.8.0": {
+ "map": {
+ "babel-runtime": "npm:babel-runtime@6.9.0",
+ "chalk": "npm:chalk@1.1.1",
+ "esutils": "npm:esutils@2.0.2",
+ "js-tokens": "npm:js-tokens@1.0.3"
+ }
+ },
+ "npm:babel-generator@6.9.0": {
+ "map": {
+ "babel-messages": "npm:babel-messages@6.8.0",
+ "babel-runtime": "npm:babel-runtime@6.9.0",
+ "babel-types": "npm:babel-types@6.9.0",
+ "detect-indent": "npm:detect-indent@3.0.1",
+ "lodash": "npm:lodash@4.13.1",
+ "source-map": "npm:source-map@0.5.3"
+ }
+ },
+ "npm:babel-traverse@6.9.0": {
+ "map": {
+ "babel-code-frame": "npm:babel-code-frame@6.8.0",
+ "babel-messages": "npm:babel-messages@6.8.0",
+ "babel-runtime": "npm:babel-runtime@6.9.0",
+ "babel-types": "npm:babel-types@6.9.0",
+ "babylon": "npm:babylon@6.7.0",
+ "debug": "npm:debug@2.2.0",
+ "globals": "npm:globals@8.18.0",
+ "invariant": "npm:invariant@2.2.1",
+ "lodash": "npm:lodash@4.13.1"
+ }
+ },
+ "npm:babel-messages@6.8.0": {
+ "map": {
+ "babel-runtime": "npm:babel-runtime@6.9.0"
+ }
+ },
+ "npm:babel-template@6.9.0": {
+ "map": {
+ "babylon": "npm:babylon@6.7.0",
+ "babel-traverse": "npm:babel-traverse@6.9.0",
+ "babel-types": "npm:babel-types@6.9.0",
+ "babel-runtime": "npm:babel-runtime@6.9.0",
+ "lodash": "npm:lodash@4.13.1"
+ }
+ },
+ "npm:babel-types@6.9.0": {
+ "map": {
+ "babel-runtime": "npm:babel-runtime@6.9.0",
+ "babel-traverse": "npm:babel-traverse@6.9.0",
+ "esutils": "npm:esutils@2.0.2",
+ "lodash": "npm:lodash@4.13.1",
+ "to-fast-properties": "npm:to-fast-properties@1.0.2"
+ }
+ },
+ "npm:jspm-github@0.14.7": {
+ "map": {
+ "expand-tilde": "npm:expand-tilde@1.2.0",
+ "bluebird": "npm:bluebird@3.3.5",
+ "mkdirp": "npm:mkdirp@0.5.1",
+ "netrc": "npm:netrc@0.1.4",
+ "request": "npm:request@2.53.0",
+ "rimraf": "npm:rimraf@2.3.4",
+ "semver": "npm:semver@5.1.0",
+ "tar": "npm:tar@2.2.1",
+ "which": "npm:which@1.2.1",
+ "graceful-fs": "npm:graceful-fs@4.1.4"
+ }
+ },
+ "npm:babel-helpers@6.8.0": {
+ "map": {
+ "babel-runtime": "npm:babel-runtime@6.9.0",
+ "babel-template": "npm:babel-template@6.9.0"
+ }
+ }
+ }
+}); \ No newline at end of file
diff --git a/bench/config-example/normalize-data.js b/bench/config-example/normalize-data.js
new file mode 100644
index 000000000..eef3db3e7
--- /dev/null
+++ b/bench/config-example/normalize-data.js
@@ -0,0 +1,69 @@
+module.exports = [
+["npm:mocha@1.21.5/mocha.js", ["./mocha.css!"]],
+['tests/angular.js', ['angular']],
+['tests/jquery.js', ["jquery"]],
+['tests/bootstrap.js', ['bootstrap', 'bootstrap/dist/css/bootstrap.css!', './bootstrap.html!text']],
+['tests/jquery.js', ['jquery']],
+['tests/d3.js', ['d3']],
+['tests/tests.js', ['./angular.js', './bootstrap.js', './jquery.js', './d3.js', './voxel-demo.js']],
+['tests/main.js', ['mocha', './tests/tests.js']],
+['github:jspm/nodelibs-util@0.2.0-alpha/util.js', ["process", "./isBuffer.js"]],
+['npm:game-shell@0.1.4/shell.js', ["events", "util", "domready", "vkey", "invert-hash", "uniq", "lower-bound", "iota-array", "./lib/raf-polyfill.js", "./lib/mousewheel-polyfill.js", "./lib/hrtime-polyfill.js"]],
+['npm:gl-now@0.0.4/index.js', ["game-shell", "webglew"]],
+["npm:ndarray-fft@0.1.0/lib/fft-matrix.js", ["bit-twiddle"]],
+['npm:ndarray-fft@0.1.0/fft.js', ["ndarray-ops", "cwise", "ndarray", "./lib/fft-matrix.js", "typedarray-pool"]],
+['npm:ndarray-scratch@0.0.1/scratch.js', ["ndarray", "typedarray-pool"]],
+['npm:ndarray-downsample2x@0.1.1/downsample.js', ["ndarray-fft", "ndarray-scratch", "ndarray-ops", "cwise", "process"]],
+['npm:tile-mip-map@0.2.1/mipmap.js', ["ndarray", "ndarray-ops", "ndarray-downsample2x"]],
+['npm:gl-texture2d@0.1.12/texture.js', ["ndarray", "ndarray-ops", "typedarray-pool", "webglew"]],
+['npm:gl-tile-map@0.3.0/tilemap.js', ["ndarray", "tile-mip-map", "gl-texture2d"]],
+['npm:gl-buffer@0.1.2/buffer.js', ["typedarray-pool", "ndarray-ops", "ndarray"]],
+['npm:gl-vao@0.0.3/lib/vao-native.js', ["./do-bind.js"]],
+['npm:gl-vao@0.0.3/lib/vao-emulated.js', ["./do-bind.js"]],
+['npm:gl-vao@0.0.3/vao.js', ["webglew", "./lib/vao-native.js", "./lib/vao-emulated.js"]],
+['npm:esprima@1.0.4/esprima.js', ["process"]],
+['npm:cwise-parser@0.0.1/index.js', ["esprima", "uniq"]],
+["npm:cwise@0.3.4/cwise.js", ["cwise-parser", "cwise-compiler"]],
+['npm:ndarray-fill@0.1.0/index.js', ["cwise"]],
+["npm:cwise-compiler@0.0.0/lib/compile.js", ["uniq"]],
+["npm:cwise-compiler@0.0.0/lib/thunk.js", ["./compile.js"]],
+['npm:cwise-compiler@0.0.0/compiler.js', ["./lib/thunk.js"]],
+["npm:ndarray-ops@1.1.1/ndarray-ops.js", ["cwise-compiler"]],
+["npm:ndarray@1.0.18/ndarray.js", ["iota-array", "is-buffer"]],
+["npm:cwise-compiler@0.1.0/lib/compile.js", ["uniq"]],
+["npm:cwise-compiler@0.1.0/lib/thunk.js", ["./compile.js"]],
+["npm:cwise-compiler@0.1.0/compiler.js", ["./lib/thunk.js"]],
+["npm:typedarray-pool@1.1.0/pool.js", ["bit-twiddle", "dup", "buffer/global"]],
+["npm:greedy-mesher@1.0.2/greedy.js", ["typedarray-pool", "uniq", "iota-array"]],
+["npm:typedarray-pool@0.1.2/pool.js", ["bit-twiddle", "dup"]],
+["npm:ao-mesher@0.2.10/mesh.js", ["ndarray", "cwise-compiler", "greedy-mesher", "typedarray-pool"]],
+["npm:glsl-tokenizer@0.0.9/lib/literals.js", ["process"]],
+["npm:glsl-tokenizer@0.0.9/lib/operators.js", ["process"]],
+["npm:glsl-tokenizer@0.0.9/lib/builtins.js", ["process"]],
+["npm:glsl-tokenizer@0.0.9/index.js", ["through", "./lib/literals", "./lib/operators", "./lib/builtins", "process"]],
+["npm:through@1.1.2/index.js", ["stream", "process"]],
+["npm:glsl-parser@0.0.9/lib/index.js", ["through", "./expr", "./scope"]],
+["npm:glsl-parser@0.0.9/index.js", ["./lib/index"]],
+["npm:readable-stream@2.0.5/readable.js", ["./lib/_stream_readable.js", "./lib/_stream_writable.js", "./lib/_stream_duplex.js", "./lib/_stream_transform.js", "./lib/_stream_passthrough.js", "process"]],
+["npm:readable-stream@2.0.5/writable.js", ["./lib/_stream_writable.js", "process"]],
+["npm:readable-stream@2.0.5/duplex.js", ["./lib/_stream_duplex.js", "process"]],
+["npm:readable-stream@2.0.5/transform.js", ["./lib/_stream_transform.js", "process"]],
+["npm:string_decoder@0.10.31/index.js", ["buffer", "buffer/global"]],
+["npm:readable-stream@2.0.5/lib/_stream_readable.js", ["process-nextick-args", "isarray", "buffer", "events", "core-util-is", "inherits", "util", "./_stream_duplex", "string_decoder", "process", "buffer/global"]],
+["npm:process-nextick-args@1.0.6/index.js", ["process"]],
+["npm:readable-stream@2.0.5/lib/_stream_writable.js", ["process-nextick-args", "buffer", "core-util-is", "inherits", "util-deprecate", "events", "./_stream_duplex", "process", "buffer/global"]],
+["npm:readable-stream@2.0.5/lib/_stream_duplex.js", ["process-nextick-args", "core-util-is", "inherits", "./_stream_readable", "./_stream_writable", "process"]],
+["npm:readable-stream@2.0.5/lib/_stream_transform.js", ["./_stream_duplex", "core-util-is", "inherits", "process"]],
+["npm:buffer@4.5.0/index.js", ["base64-js", "ieee754", "isarray", "process"]],
+["github:jspm/nodelibs-buffer@0.2.0-alpha/global.js", ["./buffer.js"]],
+["npm:core-util-is@1.0.2/lib/util.js", ["buffer/global"]],
+["npm:readable-stream@2.0.5/lib/_stream_passthrough.js", ["./_stream_transform", "core-util-is", "inherits", "process"]],
+["npm:readable-stream@2.0.5/passthrough.js", ["./lib/_stream_passthrough.js", "process"]],
+["npm:stream-browserify@2.0.1/index.js", ["events", "inherits", "readable-stream/readable.js", "readable-stream/writable.js", "readable-stream/duplex.js", "readable-stream/transform.js", "readable-stream/passthrough.js"]],
+["github:jspm/nodelibs-process@0.2.0-alpha/process.js", ["@system-env"]],
+["npm:through@2.3.8/index.js", ["stream", "process"]],
+["npm:glsl-exports@0.0.0/index.js", ["glsl-tokenizer", "glsl-parser", "through"]],
+["npm:gl-shader@0.0.6/index.js", ["glsl-exports", "uniq"]],
+["npm:ao-shader@0.2.3/aoshader.js", ["fs", "gl-shader"]],
+["npm:voxel-demo@0.0.1/shader.js", ["gl-now", "gl-tile-map", "gl-buffer", "gl-vao", "gl-matrix", "ndarray", "ndarray-fill", "ndarray-ops", "ao-mesher", "ao-shader"]]
+]; \ No newline at end of file
diff --git a/bench/config-example/pkg-configs.js b/bench/config-example/pkg-configs.js
new file mode 100644
index 000000000..7bbe38627
--- /dev/null
+++ b/bench/config-example/pkg-configs.js
@@ -0,0 +1,972 @@
+System.registerDynamic("npm:mocha@1.21.5.json", [], false, function() {
+ return {
+ "main": "mocha",
+ "meta": {
+ "mocha.js": {
+ "deps": [
+ "./mocha.css!"
+ ],
+ "exports": "mocha"
+ }
+ }
+ };
+});
+
+System.registerDynamic("github:angular/bower-angular@1.4.8.json", [], false, function() {
+ return {
+ "main": "angular",
+ "meta": {
+ "angular.js": {
+ "exports": "angular"
+ }
+ }
+ };
+});
+
+System.registerDynamic("github:systemjs/plugin-css@0.1.20.json", [], false, function() {
+ return {
+ "main": "css"
+ };
+});
+
+System.registerDynamic("github:twbs/bootstrap@3.3.6.json", [], false, function() {
+ return {
+ "main": "dist/js/bootstrap.js",
+ "meta": {
+ "dist/js/bootstrap.js": {
+ "deps": [
+ "jquery"
+ ],
+ "exports": "$"
+ }
+ }
+ };
+});
+
+System.registerDynamic("github:systemjs/plugin-text@0.0.2.json", [], false, function() {
+ return {
+ "main": "text"
+ };
+});
+
+System.registerDynamic("github:components/jquery@2.1.4.json", [], false, function() {
+ return {
+ "main": "jquery"
+ };
+});
+
+System.registerDynamic("github:mbostock/d3@3.5.12.json", [], false, function() {
+ return {
+ "main": "d3",
+ "meta": {
+ "d3.js": {
+ "exports": "d3",
+ "format": "global"
+ }
+ }
+ };
+});
+
+System.registerDynamic("github:jspm/nodelibs-util@0.2.0-alpha.json", [], false, function() {
+ return {
+ "main": "./util.js",
+ "map": {
+ "./isBuffer.js": {
+ "~node": "./isBufferBrowser.js"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:domready@0.2.13.json", [], false, function() {
+ return {
+ "main": "ready.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ },
+ "map": {
+ "domready": "."
+ }
+ };
+});
+
+System.registerDynamic("npm:vkey@0.0.3.json", [], false, function() {
+ return {
+ "main": "index.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:invert-hash@0.0.0.json", [], false, function() {
+ return {
+ "main": "invert.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:lower-bound@0.0.3.json", [], false, function() {
+ return {
+ "main": "lb.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:iota-array@0.0.1.json", [], false, function() {
+ return {
+ "main": "iota.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:game-shell@0.1.4.json", [], false, function() {
+ return {
+ "main": "shell.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:gl-now@0.0.4.json", [], false, function() {
+ return {
+ "main": "index.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:ndarray-fft@0.1.0.json", [], false, function() {
+ return {
+ "main": "fft.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:ndarray-scratch@0.0.1.json", [], false, function() {
+ return {
+ "main": "scratch.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:ndarray-downsample2x@0.1.1.json", [], false, function() {
+ return {
+ "main": "downsample.js",
+ "format": "cjs",
+ "meta": {
+ "*": {
+ "globals": {
+ "process": "process"
+ }
+ },
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:tile-mip-map@0.2.1.json", [], false, function() {
+ return {
+ "main": "mipmap.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:gl-texture2d@0.1.12.json", [], false, function() {
+ return {
+ "main": "texture.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:gl-tile-map@0.3.0.json", [], false, function() {
+ return {
+ "main": "tilemap.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:gl-buffer@0.1.2.json", [], false, function() {
+ return {
+ "main": "buffer.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:webglew@0.0.0.json", [], false, function() {
+ return {
+ "main": "webglew.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:gl-vao@0.0.3.json", [], false, function() {
+ return {
+ "main": "vao.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:gl-matrix@2.0.0.json", [], false, function() {
+ return {
+ "main": "dist/gl-matrix.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ },
+ "dist/gl-matrix-min.js": {
+ "format": "amd"
+ },
+ "src/gl-matrix.js.erb": {
+ "format": "amd"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:esprima@1.0.4.json", [], false, function() {
+ return {
+ "main": "esprima.js",
+ "format": "cjs",
+ "meta": {
+ "*": {
+ "globals": {
+ "process": "process"
+ }
+ },
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:cwise-parser@0.0.1.json", [], false, function() {
+ return {
+ "main": "index.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:cwise@0.3.4.json", [], false, function() {
+ return {
+ "main": "cwise.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:ndarray-fill@0.1.0.json", [], false, function() {
+ return {
+ "main": "index.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:cwise-compiler@0.0.0.json", [], false, function() {
+ return {
+ "main": "compiler.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:ndarray-ops@1.1.1.json", [], false, function() {
+ return {
+ "main": "ndarray-ops.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:is-buffer@1.1.1.json", [], false, function() {
+ return {
+ "main": "index.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ },
+ "test/*": {
+ "globals": {
+ "Buffer": "buffer/global"
+ }
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:ndarray@1.0.18.json", [], false, function() {
+ return {
+ "main": "ndarray.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:cwise-compiler@0.1.0.json", [], false, function() {
+ return {
+ "main": "compiler.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:bit-twiddle@1.0.2.json", [], false, function() {
+ return {
+ "main": "twiddle.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:dup@1.0.0.json", [], false, function() {
+ return {
+ "main": "dup.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:typedarray-pool@1.1.0.json", [], false, function() {
+ return {
+ "main": "pool.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ },
+ "pool.js": {
+ "globals": {
+ "Buffer": "buffer/global"
+ }
+ },
+ "test/*": {
+ "globals": {
+ "Buffer": "buffer/global"
+ }
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:uniq@1.0.1.json", [], false, function() {
+ return {
+ "main": "uniq.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:iota-array@1.0.0.json", [], false, function() {
+ return {
+ "main": "iota.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:greedy-mesher@1.0.2.json", [], false, function() {
+ return {
+ "main": "greedy.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:bit-twiddle@0.0.2.json", [], false, function() {
+ return {
+ "main": "twiddle.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:dup@0.0.0.json", [], false, function() {
+ return {
+ "main": "dup.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:typedarray-pool@0.1.2.json", [], false, function() {
+ return {
+ "main": "pool.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:ao-mesher@0.2.10.json", [], false, function() {
+ return {
+ "main": "mesh.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("github:jspm/nodelibs-fs@0.2.0-alpha.json", [], false, function() {
+ return {
+ "main": "./fs.js"
+ };
+});
+
+System.registerDynamic("npm:glsl-tokenizer@0.0.9.json", [], false, function() {
+ return {
+ "main": "index.js",
+ "format": "cjs",
+ "meta": {
+ "*": {
+ "globals": {
+ "process": "process"
+ }
+ },
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:through@1.1.2.json", [], false, function() {
+ return {
+ "main": "index.js",
+ "format": "cjs",
+ "meta": {
+ "*": {
+ "globals": {
+ "process": "process"
+ }
+ },
+ "*.json": {
+ "format": "json"
+ }
+ },
+ "map": {
+ "./test.js": "./test/index.js"
+ }
+ };
+});
+
+System.registerDynamic("npm:glsl-parser@0.0.9.json", [], false, function() {
+ return {
+ "main": "index.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ },
+ "map": {
+ "./lib.js": "./lib/index.js",
+ "./test.js": "./test/index.js"
+ }
+ };
+});
+
+System.registerDynamic("github:jspm/nodelibs-stream@0.2.0-alpha.json", [], false, function() {
+ return {
+ "main": "./stream.js",
+ "map": {
+ "./stream.js": {
+ "browser": "stream-browserify"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:isarray@0.0.1.json", [], false, function() {
+ return {
+ "main": "index.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:string_decoder@0.10.31.json", [], false, function() {
+ return {
+ "main": "index.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ },
+ "index.js": {
+ "globals": {
+ "Buffer": "buffer/global"
+ }
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:process-nextick-args@1.0.6.json", [], false, function() {
+ return {
+ "main": "index.js",
+ "format": "cjs",
+ "meta": {
+ "*": {
+ "globals": {
+ "process": "process"
+ }
+ },
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:util-deprecate@1.0.2.json", [], false, function() {
+ return {
+ "main": "node.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ },
+ "map": {
+ "./node.js": {
+ "browser": "./browser.js"
+ }
+ }
+ };
+});
+
+System.registerDynamic("github:jspm/nodelibs-events@0.2.0-alpha.json", [], false, function() {
+ return {
+ "main": "./events.js"
+ };
+});
+
+System.registerDynamic("npm:base64-js@1.1.1.json", [], false, function() {
+ return {
+ "main": "lib/b64.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:ieee754@1.1.6.json", [], false, function() {
+ return {
+ "main": "index.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ },
+ "test/*": {
+ "globals": {
+ "Buffer": "buffer/global"
+ }
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:isarray@1.0.0.json", [], false, function() {
+ return {
+ "main": "index.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:buffer@4.5.0.json", [], false, function() {
+ return {
+ "main": "index.js",
+ "format": "cjs",
+ "meta": {
+ "*": {
+ "globals": {
+ "process": "process"
+ }
+ },
+ "*.json": {
+ "format": "json"
+ },
+ "test/constructor.js": {
+ "globals": {
+ "Buffer": "buffer/global"
+ }
+ },
+ "test/node-es6/test-buffer-arraybuffer.js": {
+ "globals": {
+ "Buffer": "buffer/global"
+ }
+ },
+ "test/node-es6/test-buffer-iterator.js": {
+ "globals": {
+ "Buffer": "buffer/global"
+ }
+ },
+ "test/node/test-buffer-ascii.js": {
+ "globals": {
+ "Buffer": "buffer/global"
+ }
+ },
+ "test/node/test-buffer-bytelength.js": {
+ "globals": {
+ "Buffer": "buffer/global"
+ }
+ },
+ "test/node/test-buffer-concat.js": {
+ "globals": {
+ "Buffer": "buffer/global"
+ }
+ },
+ "test/node/test-buffer-indexof.js": {
+ "globals": {
+ "Buffer": "buffer/global"
+ }
+ },
+ "test/node/test-buffer-inspect.js": {
+ "globals": {
+ "Buffer": "buffer/global"
+ }
+ },
+ "test/node/test-buffer.js": {
+ "globals": {
+ "Buffer": "buffer/global"
+ }
+ }
+ }
+ };
+});
+
+System.registerDynamic("github:jspm/nodelibs-buffer@0.2.0-alpha.json", [], false, function() {
+ return {
+ "main": "buffer.js",
+ "map": {
+ "./buffer.js": {
+ "browser": "buffer-browserify"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:core-util-is@1.0.2.json", [], false, function() {
+ return {
+ "main": "lib/util.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ },
+ "lib/*": {
+ "globals": {
+ "Buffer": "buffer/global"
+ }
+ },
+ "test.js": {
+ "globals": {
+ "Buffer": "buffer/global"
+ }
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:inherits@2.0.1.json", [], false, function() {
+ return {
+ "main": "inherits.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ },
+ "map": {
+ "./inherits.js": {
+ "browser": "./inherits_browser.js"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:readable-stream@2.0.5.json", [], false, function() {
+ return {
+ "main": "readable.js",
+ "format": "cjs",
+ "meta": {
+ "*": {
+ "globals": {
+ "process": "process"
+ }
+ },
+ "*.json": {
+ "format": "json"
+ },
+ "lib/_stream_readable.js": {
+ "globals": {
+ "Buffer": "buffer/global"
+ }
+ },
+ "lib/_stream_writable.js": {
+ "globals": {
+ "Buffer": "buffer/global"
+ }
+ }
+ },
+ "map": {
+ "util": {
+ "browser": "@empty"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:stream-browserify@2.0.1.json", [], false, function() {
+ return {
+ "main": "index.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ },
+ "test/*": {
+ "globals": {
+ "Buffer": "buffer/global"
+ }
+ }
+ }
+ };
+});
+
+System.registerDynamic("github:jspm/nodelibs-process@0.2.0-alpha.json", [], false, function() {
+ return {
+ "main": "./process.js"
+ };
+});
+
+System.registerDynamic("npm:through@2.3.8.json", [], false, function() {
+ return {
+ "main": "index.js",
+ "format": "cjs",
+ "meta": {
+ "*": {
+ "globals": {
+ "process": "process"
+ }
+ },
+ "*.json": {
+ "format": "json"
+ }
+ },
+ "map": {
+ "./test.js": "./test/index.js"
+ }
+ };
+});
+
+System.registerDynamic("npm:glsl-exports@0.0.0.json", [], false, function() {
+ return {
+ "main": "index.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:uniq@0.0.2.json", [], false, function() {
+ return {
+ "main": "uniq.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:gl-shader@0.0.6.json", [], false, function() {
+ return {
+ "main": "index.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:ao-shader@0.2.3.json", [], false, function() {
+ return {
+ "main": "aoshader.js",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+});
+
+System.registerDynamic("npm:voxel-demo@0.0.1.json", [], false, function() {
+ return {
+ "main": "shader",
+ "format": "cjs",
+ "meta": {
+ "*.json": {
+ "format": "json"
+ }
+ }
+ };
+}); \ No newline at end of file
diff --git a/bench/get-cjs-deps.js b/bench/get-cjs-deps.js
new file mode 100644
index 000000000..b999a1c16
--- /dev/null
+++ b/bench/get-cjs-deps.js
@@ -0,0 +1,63 @@
+var fs = require('fs');
+
+// require('...') || exports[''] = ... || exports.asd = ... || module.exports = ...
+var cjsExportsRegEx = /(?:^\uFEFF?|[^$_a-zA-Z\xA0-\uFFFF.])(exports\s*(\[['"]|\.)|module(\.exports|\['exports'\]|\["exports"\])\s*(\[['"]|[=,\.]))/;
+// RegEx adjusted from https://github.com/jbrantly/yabble/blob/master/lib/yabble.js#L339
+var cjsRequireRegEx = /(?:^\uFEFF?|[^$_a-zA-Z\xA0-\uFFFF."'])require\s*\(\s*("[^"\\]*(?:\\.[^"\\]*)*"|'[^'\\]*(?:\\.[^'\\]*)*')\s*\)/g;
+var commentRegEx = /(^|[^\\])(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg;
+
+var stringRegEx = /("[^"\\\n\r]*(\\.[^"\\\n\r]*)*"|'[^'\\\n\r]*(\\.[^'\\\n\r]*)*')/g;
+function getCJSDeps(source) {
+ cjsRequireRegEx.lastIndex = commentRegEx.lastIndex = stringRegEx.lastIndex = 0;
+
+ var deps = [];
+
+ var match;
+
+ // track string and comment locations for unminified source
+ var stringLocations = [], commentLocations = [];
+
+ function inLocation(locations, match) {
+ for (var i = 0; i < locations.length; i++)
+ if (locations[i][0] < match.index && locations[i][1] > match.index)
+ return true;
+ return false;
+ }
+
+ if (source.length / source.split('\n').length < 200) {
+ while (match = stringRegEx.exec(source))
+ stringLocations.push([match.index, match.index + match[0].length]);
+
+ // TODO: track template literals here before comments
+
+ while (match = commentRegEx.exec(source)) {
+ // only track comments not starting in strings
+ if (!inLocation(stringLocations, match))
+ commentLocations.push([match.index + match[1].length, match.index + match[0].length - 1]);
+ }
+ }
+
+ while (match = cjsRequireRegEx.exec(source)) {
+ // ensure we're not within a string or comment location
+ if (!inLocation(stringLocations, match) && !inLocation(commentLocations, match)) {
+ var dep = match[1].substr(1, match[1].length - 2);
+ // skip cases like require('" + file + "')
+ if (dep.match(/"|'/))
+ continue;
+ // trailing slash requires are removed as they don't map mains in SystemJS
+ if (dep[dep.length - 1] == '/')
+ dep = dep.substr(0, dep.length - 1);
+ deps.push(dep);
+ }
+ }
+
+ return deps;
+}
+
+var cjs = fs.readFileSync('./cjs-sample/cjs.js').toString();
+
+var startTime = Date.now();
+for (var i = 0; i < 1000; i++)
+ getCJSDeps(cjs);
+console.log(Date.now() - startTime);
+
diff --git a/bench/normalize-perf.js b/bench/normalize-perf.js
new file mode 100644
index 000000000..6749382a2
--- /dev/null
+++ b/bench/normalize-perf.js
@@ -0,0 +1,67 @@
+var systemjs = require('../index.js');
+
+var num = 5;
+
+var startTime, endTime;
+
+startTime = Date.now();
+require('./config-example/config.js');
+endTime = Date.now();
+console.log('Configured in ' + (endTime - startTime) + 'ms');
+
+require('./config-example/pkg-configs.js');
+
+var normalizeData = require('./config-example/normalize-data.js');
+
+// decanonicalize the parentNames (we're not measuring decanonicalize)
+var normalizationCnt = 0;
+normalizeData.forEach(function(item) {
+ normalizationCnt += item[1].length;
+ item[0] = System.decanonicalize(item[0]);
+});
+
+// simulated System.register normalization test
+// timed normalize of 'x', ['./dep'] cases
+function test() {
+ return Promise.all(normalizeData.map(function(item) {
+ var parentName = item[0];
+ var deps = item[1];
+ return Promise.all(deps.map(function(dep) {
+ return System.normalize(dep, parentName);
+ }));
+ }));
+}
+
+return Promise.resolve()
+.then(function() {
+ starTime = Date.now();
+ return test()
+ .then(function() {
+ endTime = Date.now();
+ console.log(normalizationCnt + ' first run normalizations in ' + (endTime - startTime) + 'ms');
+ console.log((endTime - startTime) / normalizationCnt + 'ms per normalization');
+ });
+})
+.then(function() {
+ startTime = Date.now();
+ var testPromise = Promise.resolve();
+ for (var i = 0; i < num; i++)
+ testPromise = testPromise.then(test);
+ return testPromise
+ .then(function() {
+ endTime = Date.now();
+
+ var time = (endTime - startTime) / num;
+
+ console.log(normalizationCnt + ' subsequent normalizations in ' + time + 'ms');
+ console.log(time / normalizationCnt + 'ms per normalization');
+
+ /* System.perfSummary(function(evt) {
+ return evt.name.match(/^normalize\:/);
+ }); */
+ })
+ .catch(function(e) {
+ console.error(e.stack || e);
+ });
+
+}); \ No newline at end of file
diff --git a/bower.json b/bower.json
new file mode 100644
index 000000000..fa64a2d81
--- /dev/null
+++ b/bower.json
@@ -0,0 +1,17 @@
+{
+ "name": "system.js",
+ "main": "./dist/system.js",
+ "ignore": [
+ ".agignore",
+ ".gitignore",
+ ".travis.yml",
+ "index.js",
+ "lib/",
+ "package.json",
+ "Makefile",
+ "test"
+ ],
+ "devDependencies": {
+ "qunit": "~1.12.0"
+ }
+}
diff --git a/dist/system-csp-production.js b/dist/system-csp-production.js
new file mode 100644
index 000000000..048a1e192
--- /dev/null
+++ b/dist/system-csp-production.js
@@ -0,0 +1,6 @@
+/*
+ * SystemJS v0.19.39
+ */
+!function(){function e(){!function(e){function t(e,n){if("string"!=typeof e)throw new TypeError("URL must be a string");var r=String(e).replace(/^\s+|\s+$/g,"").match(/^([^:\/?#]+:)?(?:\/\/(?:([^:@\/?#]*)(?::([^:@\/?#]*))?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/);if(!r)throw new RangeError("Invalid URL format");var a=r[1]||"",o=r[2]||"",i=r[3]||"",s=r[4]||"",l=r[5]||"",u=r[6]||"",d=r[7]||"",c=r[8]||"",f=r[9]||"";if(void 0!==n){var m=n instanceof t?n:new t(n),p=!a&&!s&&!o;!p||d||c||(c=m.search),p&&"/"!==d[0]&&(d=d?(!m.host&&!m.username||m.pathname?"":"/")+m.pathname.slice(0,m.pathname.lastIndexOf("/")+1)+d:m.pathname);var h=[];d.replace(/^(\.\.?(\/|$))+/,"").replace(/\/(\.(\/|$))+/g,"/").replace(/\/\.\.$/,"/../").replace(/\/?[^\/]*/g,function(e){"/.."===e?h.pop():h.push(e)}),d=h.join("").replace(/^\//,"/"===d[0]?"/":""),p&&(u=m.port,l=m.hostname,s=m.host,i=m.password,o=m.username),a||(a=m.protocol)}d=d.replace(/\\/g,"/"),this.origin=s?a+(""!==a||""!==s?"//":"")+s:"",this.href=a+(a&&s||"file:"==a?"//":"")+(""!==o?o+(""!==i?":"+i:"")+"@":"")+s+d+c+f,this.protocol=a,this.username=o,this.password=i,this.host=s,this.hostname=l,this.port=u,this.pathname=d,this.search=c,this.hash=f}e.URLPolyfill=t}("undefined"!=typeof self?self:global),function(e){function t(e,t){if(!e.originalErr)for(var n=((e.message||e)+(e.stack?"\n"+e.stack:"")).toString().split("\n"),r=[],a=0;a<n.length;a++)"undefined"!=typeof $__curScript&&n[a].indexOf($__curScript.src)!=-1||r.push(n[a]);var o="(SystemJS) "+(r?r.join("\n\t"):e.message.substr(11))+"\n\t"+t;q||(o=o.replace(U?/file:\/\/\//g:/file:\/\//g,""));var i=N?new Error(o,e.fileName,e.lineNumber):new Error(o);return i.stack=o,i.originalErr=e.originalErr||e,i}function n(){}function r(t){this._loader={loaderObj:this,loads:[],modules:{},importPromises:{},moduleRecords:{}},A(this,"global",{get:function(){return e}})}function a(){r.call(this),this.paths={},this._loader.paths={},G.call(this)}function o(){}function i(e,t){a.prototype[e]=t(a.prototype[e]||function(){})}function s(e){G=e(G||function(){})}function l(e){return e.match(V)}function u(e){return"."==e[0]&&(!e[1]||"/"==e[1]||"."==e[1])||"/"==e[0]}function d(e){return!u(e)&&!l(e)}function c(e,t){if("."==e[0]){if("/"==e[1]&&"."!=e[2])return(t&&t.substr(0,t.lastIndexOf("/")+1)||$)+e.substr(2)}else if("/"!=e[0]&&e.indexOf(":")==-1)return(t&&t.substr(0,t.lastIndexOf("/")+1)||$)+e;return new H(e,t&&t.replace(/#/g,"%05")||Y).href.replace(/%05/g,"#")}function f(e,t){var n,r="",a=0,o=e.paths,i=e._loader.paths;for(var s in o)if(!o.hasOwnProperty||o.hasOwnProperty(s)){var l=o[s];if(l!==i[s]&&(l=o[s]=i[s]=c(o[s],u(o[s])?$:e.baseURL)),s.indexOf("*")===-1){if(t==s)return o[s];if(t.substr(0,s.length-1)==s.substr(0,s.length-1)&&(t.length<s.length||t[s.length-1]==s[s.length-1])&&("/"==o[s][o[s].length-1]||""==o[s]))return o[s].substr(0,o[s].length-1)+(t.length>s.length?(o[s]&&"/"||"")+t.substr(s.length):"")}else{var d=s.split("*");if(d.length>2)throw new TypeError("Only one wildcard in a path is permitted");var f=d[0].length;f>=a&&t.substr(0,d[0].length)==d[0]&&t.substr(t.length-d[1].length)==d[1]&&(a=f,r=s,n=t.substr(d[0].length,t.length-d[1].length-d[0].length))}}var m=o[r];return"string"==typeof n&&(m=m.replace("*",n)),m}function m(e){for(var t=[],n=[],r=0,a=e.length;r<a;r++){var o=J.call(t,e[r]);o===-1?(t.push(e[r]),n.push([r])):n[o].push(r)}return{names:t,indices:n}}function p(t){var n={};if(("object"==typeof t||"function"==typeof t)&&t!==e)if(Z)for(var r in t)"default"!==r&&h(n,t,r);else g(n,t);return n.default=t,A(n,"__useDefault",{value:!0}),n}function h(e,t,n){try{var r;(r=Object.getOwnPropertyDescriptor(t,n))&&A(e,n,r)}catch(r){return e[n]=t[n],!1}}function g(e,t,n){var r=t&&t.hasOwnProperty;for(var a in t)r&&!t.hasOwnProperty(a)||n&&a in e||(e[a]=t[a]);return e}function v(e,t,n){var r=t&&t.hasOwnProperty;for(var a in t)if(!r||t.hasOwnProperty(a)){var o=t[a];a in e?o instanceof Array&&e[a]instanceof Array?e[a]=[].concat(n?o:e[a]).concat(n?e[a]:o):"object"==typeof o&&null!==o&&"object"==typeof e[a]?e[a]=g(g({},e[a]),o,n):n||(e[a]=o):e[a]=o}}function y(e,t,n,r,a){for(var o in t)if(J.call(["main","format","defaultExtension","basePath"],o)!=-1)e[o]=t[o];else if("map"==o)g(e.map=e.map||{},t.map);else if("meta"==o)g(e.meta=e.meta||{},t.meta);else if("depCache"==o)for(var i in t.depCache){var s;s="./"==i.substr(0,2)?n+"/"+i.substr(2):k.call(r,i),r.depCache[s]=(r.depCache[s]||[]).concat(t.depCache[i])}else!a||J.call(["browserConfig","nodeConfig","devConfig","productionConfig"],o)!=-1||t.hasOwnProperty&&!t.hasOwnProperty(o)||w.call(r,'"'+o+'" is not a valid package configuration option in package '+n)}function b(e,t,n,r){var a;if(e.packages[t]){var o=e.packages[t];a=e.packages[t]={},y(a,r?n:o,t,e,r),y(a,r?o:n,t,e,!r)}else a=e.packages[t]=n;return"object"==typeof a.main&&(a.map=a.map||{},a.map["./@main"]=a.main,a.main.default=a.main.default||"./",a.main="@main"),a}function w(e){this.warnings&&"undefined"!=typeof console&&console.warn}function x(e,t){for(var n=e.split(".");n.length;)t=t[n.shift()];return t}function S(e,t){var n,r=0;for(var a in e)if(t.substr(0,a.length)==a&&(t.length==a.length||"/"==t[a.length])){var o=a.split("/").length;if(o<=r)continue;n=a,r=o}return n}function E(e){this._loader.baseURL!==this.baseURL&&("/"!=this.baseURL[this.baseURL.length-1]&&(this.baseURL+="/"),this._loader.baseURL=this.baseURL=new H(this.baseURL,Y).href)}function _(e,t){this.set("@system-env",W=this.newModule({browser:q,node:!!this._nodeRequire,production:!t&&e,dev:t||!e,build:t,default:!0}))}function P(e,t){if(!d(e))throw new Error("Node module "+e+" can't be loaded as it is not a package require.");if(!ee){var n=this._nodeRequire("module"),r=t.substr(U?8:7);ee=new n(r),ee.paths=n._nodeModulePaths(r)}return ee.require(e)}function k(e,t){if(u(e))return c(e,t);if(l(e))return e;var n=S(this.map,e);if(n){if(e=this.map[n]+e.substr(n.length),u(e))return c(e);if(l(e))return e}if(this.has(e))return e;if("@node/"==e.substr(0,6)){if(!this._nodeRequire)throw new TypeError("Error loading "+e+". Can only load node core modules in Node.");return this.builder?this.set(e,this.newModule({})):this.set(e,this.newModule(p(P.call(this,e.substr(6),this.baseURL)))),e}return E.call(this),f(this,e)||this.baseURL+e}function j(e,t,n){W.browser&&t.browserConfig&&n(t.browserConfig),W.node&&t.nodeConfig&&n(t.nodeConfig),W.dev&&t.devConfig&&n(t.devConfig),W.build&&t.buildConfig&&n(t.buildConfig),W.production&&t.productionConfig&&n(t.productionConfig)}function O(e){var t=e.match(re);return t&&"System.register"==e.substr(t[0].length,15)}function R(){return{name:null,deps:null,originalIndices:null,declare:null,execute:null,executingRequire:!1,declarative:!1,normalizedDeps:null,groupIndex:null,evaluated:!1,module:null,esModule:null,esmExports:!1}}function M(t){if("string"==typeof t)return x(t,e);if(!(t instanceof Array))throw new Error("Global exports must be a string or array.");for(var n={},r=!0,a=0;a<t.length;a++){var o=x(t[a],e);r&&(n.default=o,r=!1),n[t[a].split(".").pop()]=o}return n}function z(e){var t,n,r,r="~"==e[0],a=e.lastIndexOf("|");return a!=-1?(t=e.substr(a+1),n=e.substr(r,a-r),r&&w.call(this,'Condition negation form "'+e+'" is deprecated for "'+n+"|~"+t+'"'),"~"==t[0]&&(r=!0,t=t.substr(1))):(t="default",n=e.substr(r),ae.indexOf(n)!=-1&&(t=n,n=null)),{module:n||"@system-env",prop:t,negate:r}}function I(e){return e.module+"|"+(e.negate?"~":"")+e.prop}function C(e,t,n){var r=this;return this.normalize(e.module,t).then(function(t){return r.load(t).then(function(a){var o=x(e.prop,r.get(t));if(n&&"boolean"!=typeof o)throw new TypeError("Condition "+I(e)+" did not resolve to a boolean.");return e.negate?!o:o})})}function L(e,t){var n=e.match(oe);if(!n)return Promise.resolve(e);var r=z.call(this,n[0].substr(2,n[0].length-3));return this.builder?this.normalize(r.module,t).then(function(t){return r.module=t,e.replace(oe,"#{"+I(r)+"}")}):C.call(this,r,t,!1).then(function(n){if("string"!=typeof n)throw new TypeError("The condition value for "+e+" doesn't resolve to a string.");if(n.indexOf("/")!=-1)throw new TypeError("Unabled to interpolate conditional "+e+(t?" in "+t:"")+"\n\tThe condition value "+n+' cannot contain a "/" separator.');return e.replace(oe,n)})}function T(e,t){var n=e.lastIndexOf("#?");if(n==-1)return Promise.resolve(e);var r=z.call(this,e.substr(n+2));return this.builder?this.normalize(r.module,t).then(function(t){return r.module=t,e.substr(0,n)+"#?"+I(r)}):C.call(this,r,t,!0).then(function(t){return t?e.substr(0,n):"@empty"})}var D="undefined"==typeof window&&"undefined"!=typeof self&&"undefined"!=typeof importScripts,q="undefined"!=typeof window&&"undefined"!=typeof document,U="undefined"!=typeof process&&"undefined"!=typeof process.platform&&!!process.platform.match(/^win/);e.console||(e.console={assert:function(){}});var A,J=Array.prototype.indexOf||function(e){for(var t=0,n=this.length;t<n;t++)if(this[t]===e)return t;return-1};!function(){try{Object.defineProperty({},"a",{})&&(A=Object.defineProperty)}catch(e){A=function(e,t,n){try{e[t]=n.value||n.get.call(e)}catch(e){}}}}();var $,N="_"==new Error(0,"_").fileName;if("undefined"!=typeof document&&document.getElementsByTagName){if($=document.baseURI,!$){var F=document.getElementsByTagName("base");$=F[0]&&F[0].href||window.location.href}}else"undefined"!=typeof location&&($=e.location.href);if($)$=$.split("#")[0].split("?")[0],$=$.substr(0,$.lastIndexOf("/")+1);else{if("undefined"==typeof process||!process.cwd)throw new TypeError("No environment baseURI");$="file://"+(U?"/":"")+process.cwd()+"/",U&&($=$.replace(/\\/g,"/"))}try{var B="test:"==new e.URL("test:///").protocol}catch(e){}var H=B?e.URL:e.URLPolyfill;A(n.prototype,"toString",{value:function(){return"Module"}}),function(){function e(e){return{status:"loading",name:e||"<Anonymous"+ ++b+">",linkSets:[],dependencies:[],metadata:{}}}function a(e,t,n){return new Promise(u({step:n.address?"fetch":"locate",loader:e,moduleName:t,moduleMetadata:n&&n.metadata||{},moduleSource:n.source,moduleAddress:n.address}))}function o(t,n,r,a){return new Promise(function(e,o){e(t.loaderObj.normalize(n,r,a))}).then(function(n){var r;if(t.modules[n])return r=e(n),r.status="linked",r.module=t.modules[n],r;for(var a=0,o=t.loads.length;a<o;a++)if(r=t.loads[a],r.name==n)return r;return r=e(n),t.loads.push(r),i(t,r),r})}function i(e,t){s(e,t,Promise.resolve().then(function(){return e.loaderObj.locate({name:t.name,metadata:t.metadata})}))}function s(e,t,n){l(e,t,n.then(function(n){if("loading"==t.status)return t.address=n,e.loaderObj.fetch({name:t.name,metadata:t.metadata,address:n})}))}function l(e,t,n){n.then(function(n){if("loading"==t.status)return t.address=t.address||t.name,Promise.resolve(e.loaderObj.translate({name:t.name,metadata:t.metadata,address:t.address,source:n})).then(function(n){return t.source=n,e.loaderObj.instantiate({name:t.name,metadata:t.metadata,address:t.address,source:n})}).then(function(e){if(void 0===e)throw new TypeError("Declarative modules unsupported in the polyfill.");if("object"!=typeof e)throw new TypeError("Invalid instantiate return value");t.depsList=e.deps||[],t.execute=e.execute}).then(function(){t.dependencies=[];for(var n=t.depsList,r=[],a=0,i=n.length;a<i;a++)(function(n,a){r.push(o(e,n,t.name,t.address).then(function(e){if(t.dependencies[a]={key:n,value:e.name},"linked"!=e.status)for(var r=t.linkSets.concat([]),o=0,i=r.length;o<i;o++)c(r[o],e)}))})(n[a],a);return Promise.all(r)}).then(function(){t.status="loaded";for(var e=t.linkSets.concat([]),n=0,r=e.length;n<r;n++)m(e[n],t)})}).catch(function(e){t.status="failed",t.exception=e;for(var n=t.linkSets.concat([]),r=0,a=n.length;r<a;r++)p(n[r],t,e)})}function u(t){return function(n,r){var a=t.loader,o=t.moduleName,u=t.step;if(a.modules[o])throw new TypeError('"'+o+'" already exists in the module table');for(var c,f=0,m=a.loads.length;f<m;f++)if(a.loads[f].name==o&&(c=a.loads[f],"translate"!=u||c.source||(c.address=t.moduleAddress,l(a,c,Promise.resolve(t.moduleSource))),c.linkSets.length&&c.linkSets[0].loads[0].name==c.name))return c.linkSets[0].done.then(function(){n(c)});var p=c||e(o);p.metadata=t.moduleMetadata;var h=d(a,p);a.loads.push(p),n(h.done),"locate"==u?i(a,p):"fetch"==u?s(a,p,Promise.resolve(t.moduleAddress)):(p.address=t.moduleAddress,l(a,p,Promise.resolve(t.moduleSource)))}}function d(e,t){var n={loader:e,loads:[],startingLoad:t,loadingCount:0};return n.done=new Promise(function(e,t){n.resolve=e,n.reject=t}),c(n,t),n}function c(e,t){if("failed"!=t.status){for(var n=0,r=e.loads.length;n<r;n++)if(e.loads[n]==t)return;e.loads.push(t),t.linkSets.push(e),"loaded"!=t.status&&e.loadingCount++;for(var a=e.loader,n=0,r=t.dependencies.length;n<r;n++)if(t.dependencies[n]){var o=t.dependencies[n].value;if(!a.modules[o])for(var i=0,s=a.loads.length;i<s;i++)if(a.loads[i].name==o){c(e,a.loads[i]);break}}}}function f(e){var t=!1;try{y(e,function(n,r){p(e,n,r),t=!0})}catch(n){p(e,null,n),t=!0}return t}function m(e,t){if(e.loadingCount--,!(e.loadingCount>0)){var n=e.startingLoad;if(e.loader.loaderObj.execute===!1){for(var r=[].concat(e.loads),a=0,o=r.length;a<o;a++){var t=r[a];t.module={name:t.name,module:w({}),evaluated:!0},t.status="linked",h(e.loader,t)}return e.resolve(n)}var i=f(e);i||e.resolve(n)}}function p(e,n,r){var a=e.loader;e:if(n)if(e.loads[0].name==n.name)r=t(r,"Error loading "+n.name);else{for(var o=0;o<e.loads.length;o++)for(var i=e.loads[o],s=0;s<i.dependencies.length;s++){var l=i.dependencies[s];if(l.value==n.name){r=t(r,"Error loading "+n.name+' as "'+l.key+'" from '+i.name);break e}}r=t(r,"Error loading "+n.name+" from "+e.loads[0].name)}else r=t(r,"Error linking "+e.loads[0].name);for(var u=e.loads.concat([]),o=0,d=u.length;o<d;o++){var n=u[o];a.loaderObj.failed=a.loaderObj.failed||[],J.call(a.loaderObj.failed,n)==-1&&a.loaderObj.failed.push(n);var c=J.call(n.linkSets,e);if(n.linkSets.splice(c,1),0==n.linkSets.length){var f=J.call(e.loader.loads,n);f!=-1&&e.loader.loads.splice(f,1)}}e.reject(r)}function h(e,t){if(e.loaderObj.trace){e.loaderObj.loads||(e.loaderObj.loads={});var n={};t.dependencies.forEach(function(e){n[e.key]=e.value}),e.loaderObj.loads[t.name]={name:t.name,deps:t.dependencies.map(function(e){return e.key}),depMap:n,address:t.address,metadata:t.metadata,source:t.source}}t.name&&(e.modules[t.name]=t.module);var r=J.call(e.loads,t);r!=-1&&e.loads.splice(r,1);for(var a=0,o=t.linkSets.length;a<o;a++)r=J.call(t.linkSets[a].loads,t),r!=-1&&t.linkSets[a].loads.splice(r,1);t.linkSets.splice(0,t.linkSets.length)}function g(e,t,r){try{var a=t.execute()}catch(e){return void r(t,e)}return a&&a instanceof n?a:void r(t,new TypeError("Execution must define a Module instance"))}function v(e,t,n){var r=e._loader.importPromises;return r[t]=n.then(function(e){return r[t]=void 0,e},function(e){throw r[t]=void 0,e})}function y(e,t){var n=e.loader;if(e.loads.length)for(var r=e.loads.concat([]),a=0;a<r.length;a++){var o=r[a],i=g(e,o,t);if(!i)return;o.module={name:o.name,module:i},o.status="linked",h(n,o)}}var b=0;r.prototype={constructor:r,define:function(e,t,n){if(this._loader.importPromises[e])throw new TypeError("Module is already loading.");return v(this,e,new Promise(u({step:"translate",loader:this._loader,moduleName:e,moduleMetadata:n&&n.metadata||{},moduleSource:t,moduleAddress:n&&n.address})))},delete:function(e){var t=this._loader;return delete t.importPromises[e],delete t.moduleRecords[e],!!t.modules[e]&&delete t.modules[e]},get:function(e){if(this._loader.modules[e])return this._loader.modules[e].module},has:function(e){return!!this._loader.modules[e]},import:function(e,t,n){"object"==typeof t&&(t=t.name);var r=this;return Promise.resolve(r.normalize(e,t)).then(function(e){var t=r._loader;return t.modules[e]?t.modules[e].module:t.importPromises[e]||v(r,e,a(t,e,{}).then(function(n){return delete t.importPromises[e],n.module.module}))})},load:function(e){var t=this._loader;return t.modules[e]?Promise.resolve():t.importPromises[e]||v(this,e,new Promise(u({step:"locate",loader:t,moduleName:e,moduleMetadata:{},moduleSource:void 0,moduleAddress:void 0})).then(function(){delete t.importPromises[e]}))},module:function(t,n){var r=e();r.address=n&&n.address;var a=d(this._loader,r),o=Promise.resolve(t),i=this._loader,s=a.done.then(function(){return r.module.module});return l(i,r,o),s},newModule:function(e){if("object"!=typeof e)throw new TypeError("Expected object");var t=new n,r=[];if(Object.getOwnPropertyNames&&null!=e)r=Object.getOwnPropertyNames(e);else for(var a in e)r.push(a);for(var o=0;o<r.length;o++)(function(n){A(t,n,{configurable:!1,enumerable:!0,get:function(){return e[n]},set:function(){throw new Error("Module exports cannot be changed externally.")}})})(r[o]);return Object.freeze&&Object.freeze(t),t},set:function(e,t){if(!(t instanceof n))throw new TypeError("Loader.set("+e+", module) must be a module");this._loader.modules[e]={module:t}},normalize:function(e,t,n){},locate:function(e){return e.name},fetch:function(e){},translate:function(e){return e.source},instantiate:function(e){}};var w=r.prototype.newModule}();var X;o.prototype=r.prototype,a.prototype=new o,a.prototype.constructor=a;var G,V=/^[^\/]+:\/\//,Y=new H($),Z=!0;try{Object.getOwnPropertyDescriptor({a:0},"a")}catch(e){Z=!1}var K;if("undefined"!=typeof XMLHttpRequest)K=function(e,t,n,r){function a(){n(i.responseText)}function o(){r(new Error("XHR error"+(i.status?" ("+i.status+(i.statusText?" "+i.statusText:"")+")":"")+" loading "+e))}var i=new XMLHttpRequest,s=!0,l=!1;if(!("withCredentials"in i)){var u=/^(\w+:)?\/\/([^\/]+)/.exec(e);u&&(s=u[2]===window.location.host,u[1]&&(s&=u[1]===window.location.protocol))}s||"undefined"==typeof XDomainRequest||(i=new XDomainRequest,i.onload=a,i.onerror=o,i.ontimeout=o,i.onprogress=function(){},i.timeout=0,l=!0),i.onreadystatechange=function(){4===i.readyState&&(0==i.status?i.responseText?a():(i.addEventListener("error",o),i.addEventListener("load",a)):200===i.status?a():o())},i.open("GET",e,!0),i.setRequestHeader&&(i.setRequestHeader("Accept","application/x-es-module, */*"),t&&("string"==typeof t&&i.setRequestHeader("Authorization",t),i.withCredentials=!0)),l?setTimeout(function(){i.send()},0):i.send(null)};else if("undefined"!=typeof require&&"undefined"!=typeof process){var Q;K=function(e,t,n,r){if("file:///"!=e.substr(0,8))throw new Error('Unable to fetch "'+e+'". Only file URLs of the form file:/// allowed running in Node.');return Q=Q||require("fs"),e=U?e.replace(/\//g,"\\").substr(8):e.substr(7),Q.readFile(e,function(e,t){if(e)return r(e);var a=t+"";"\ufeff"===a[0]&&(a=a.substr(1)),n(a)})}}else{if("undefined"==typeof self||"undefined"==typeof self.fetch)throw new TypeError("No environment fetch API available.");K=function(e,t,n,r){var a={headers:{Accept:"application/x-es-module, */*"}};t&&("string"==typeof t&&(a.headers.Authorization=t),a.credentials="include"),fetch(e,a).then(function(e){if(e.ok)return e.text();throw new Error("Fetch error: "+e.status+" "+e.statusText)}).then(n,r)}}var W;s(function(e){return function(){e.call(this),this.baseURL=$,this.map={},"undefined"!=typeof $__curScript&&(this.scriptSrc=$__curScript.src),this.warnings=!1,this.defaultJSExtensions=!1,this.pluginFirst=!1,this.loaderErrorStack=!1,this.set("@empty",this.newModule({})),_.call(this,!1,!1)}}),"undefined"==typeof require||"undefined"==typeof process||process.browser||(a.prototype._nodeRequire=require);var ee;i("normalize",function(e){return function(e,t,n){var r=k.call(this,e,t);return!this.defaultJSExtensions||n||".js"==r.substr(r.length-3,3)||d(r)||(r+=".js"),r}});var te="undefined"!=typeof XMLHttpRequest;i("locate",function(e){return function(t){return Promise.resolve(e.call(this,t)).then(function(e){return te?e.replace(/#/g,"%23"):e})}}),i("fetch",function(){return function(e){return new Promise(function(t,n){K(e.address,e.metadata.authorization,t,n)})}}),i("import",function(e){return function(t,n,r){return n&&n.name&&w.call(this,"SystemJS.import(name, { name: parentName }) is deprecated for SystemJS.import(name, parentName), while importing "+t+" from "+n.name),e.call(this,t,n,r).then(function(e){return e.__useDefault?e.default:e})}}),i("translate",function(e){return function(t){return"detect"==t.metadata.format&&(t.metadata.format=void 0),e.apply(this,arguments)}}),i("instantiate",function(e){return function(e){if("json"==e.metadata.format&&!this.builder){var t=e.metadata.entry=R();t.deps=[],t.execute=function(){try{return JSON.parse(e.source)}catch(t){throw new Error("Invalid JSON file "+e.name)}}}}}),a.prototype.getConfig=function(e){var t={},n=this;for(var r in n)n.hasOwnProperty&&!n.hasOwnProperty(r)||r in a.prototype&&"transpiler"!=r||J.call(["_loader","amdDefine","amdRequire","defined","failed","version","loads"],r)==-1&&(t[r]=n[r]);return t.production=W.production,t};var ne;a.prototype.config=function(e,t){function n(e){for(var t in e)if(e.hasOwnProperty(t))return!0}var r=this;if("loaderErrorStack"in e&&(ne=$__curScript,e.loaderErrorStack?$__curScript=void 0:$__curScript=ne),"warnings"in e&&(r.warnings=e.warnings),e.transpilerRuntime===!1&&(r._loader.loadedTranspilerRuntime=!0),("production"in e||"build"in e)&&_.call(r,!!e.production,!!(e.build||W&&W.build)),!t){var a;if(j(r,e,function(e){a=a||e.baseURL}),a=a||e.baseURL){if(n(r.packages)||n(r.meta)||n(r.depCache)||n(r.bundles)||n(r.packageConfigPaths))throw new TypeError("Incorrect configuration order. The baseURL must be configured with the first SystemJS.config call.");this.baseURL=a,E.call(this)}if(e.paths&&g(r.paths,e.paths),j(r,e,function(e){e.paths&&g(r.paths,e.paths)}),this.warnings)for(var o in r.paths)o.indexOf("*")!=-1&&w.call(r,'Paths configuration "'+o+'" -> "'+r.paths[o]+'" uses wildcards which are being deprecated for simpler trailing "/" folder paths.')}if(e.defaultJSExtensions&&(r.defaultJSExtensions=e.defaultJSExtensions,w.call(r,"The defaultJSExtensions configuration option is deprecated, use packages configuration instead.")),e.pluginFirst&&(r.pluginFirst=e.pluginFirst),e.map){var i="";for(var o in e.map){var s=e.map[o];if("string"!=typeof s){i+=(i.length?", ":"")+'"'+o+'"';var l=r.defaultJSExtensions&&".js"!=o.substr(o.length-3,3),u=r.decanonicalize(o);l&&".js"==u.substr(u.length-3,3)&&(u=u.substr(0,u.length-3));var c="";for(var f in r.packages)u.substr(0,f.length)==f&&(!u[f.length]||"/"==u[f.length])&&c.split("/").length<f.split("/").length&&(c=f);c&&r.packages[c].main&&(u=u.substr(0,u.length-r.packages[c].main.length-1));var f=r.packages[u]=r.packages[u]||{};f.map=s}else r.map[o]=s}i&&w.call(r,"The map configuration for "+i+' uses object submaps, which is deprecated in global map.\nUpdate this to use package contextual map with configs like SystemJS.config({ packages: { "'+o+'": { map: {...} } } }).')}if(e.packageConfigPaths){for(var m=[],p=0;p<e.packageConfigPaths.length;p++){var h=e.packageConfigPaths[p],v=Math.max(h.lastIndexOf("*")+1,h.lastIndexOf("/")),y=k.call(r,h.substr(0,v));m[p]=y+h.substr(v)}r.packageConfigPaths=m}if(e.bundles)for(var o in e.bundles){for(var x=[],p=0;p<e.bundles[o].length;p++){var l=r.defaultJSExtensions&&".js"!=e.bundles[o][p].substr(e.bundles[o][p].length-3,3),S=r.decanonicalize(e.bundles[o][p]);l&&".js"==S.substr(S.length-3,3)&&(S=S.substr(0,S.length-3)),x.push(S)}r.bundles[o]=x}if(e.packages)for(var o in e.packages){if(o.match(/^([^\/]+:)?\/\/$/))throw new TypeError('"'+o+'" is not a valid package name.');var u=k.call(r,o);"/"==u[u.length-1]&&(u=u.substr(0,u.length-1)),b(r,u,e.packages[o],!1)}for(var P in e){var s=e[P];if(J.call(["baseURL","map","packages","bundles","paths","warnings","packageConfigPaths","loaderErrorStack","browserConfig","nodeConfig","devConfig","buildConfig","productionConfig"],P)==-1)if("object"!=typeof s||s instanceof Array)r[P]=s;else{r[P]=r[P]||{};for(var o in s)if("meta"==P&&"*"==o[0])g(r[P][o]=r[P][o]||{},s[o]);else if("meta"==P){var O=k.call(r,o);r.defaultJSExtensions&&".js"!=O.substr(O.length-3,3)&&!d(O)&&(O+=".js"),g(r[P][O]=r[P][O]||{},s[o])}else if("depCache"==P){var l=r.defaultJSExtensions&&".js"!=o.substr(o.length-3,3),u=r.decanonicalize(o);l&&".js"==u.substr(u.length-3,3)&&(u=u.substr(0,u.length-3)),r[P][u]=[].concat(s[o])}else r[P][o]=s[o]}}j(r,e,function(e){r.config(e,!0)})},function(){function e(e,t){var n,r,a=0;for(var o in e.packages)t.substr(0,o.length)!==o||t.length!==o.length&&"/"!==t[o.length]||(r=o.split("/").length,r>a&&(n=o,a=r));return n}function t(e,t,n,r,a){if(!r||"/"==r[r.length-1]||a||t.defaultExtension===!1)return r;var o=!1;if(t.meta&&p(t.meta,r,function(e,t,n){if(0==n||e.lastIndexOf("*")!=e.length-1)return o=!0}),!o&&e.meta&&p(e.meta,n+"/"+r,function(e,t,n){if(0==n||e.lastIndexOf("*")!=e.length-1)return o=!0}),o)return r;var i="."+(t.defaultExtension||"js");return r.substr(r.length-i.length)!=i?r+i:r}function n(e,n,r,a,i){if(!a){if(!n.main)return r+(e.defaultJSExtensions?".js":"");a="./"==n.main.substr(0,2)?n.main.substr(2):n.main}if(n.map){var s="./"+a,l=S(n.map,s);if(l||(s="./"+t(e,n,r,a,i),s!="./"+a&&(l=S(n.map,s))),l){var u=o(e,n,r,l,s,i);if(u)return u}}return r+"/"+t(e,n,r,a,i)}function r(e,t,n,r){if("."==e)throw new Error("Package "+n+' has a map entry for "." which is not permitted.');return!(t.substr(0,e.length)==e&&r.length>e.length)}function o(e,n,a,o,i,s){"/"==i[i.length-1]&&(i=i.substr(0,i.length-1));var l=n.map[o];if("object"==typeof l)throw new Error("Synchronous conditional normalization not supported sync normalizing "+o+" in "+a);if(r(o,l,a,i)&&"string"==typeof l){if("."==l)l=a;else if("./"==l.substr(0,2))return a+"/"+t(e,n,a,l.substr(2)+i.substr(o.length),s);return e.normalizeSync(l+i.substr(o.length),a+"/")}}function l(e,n,r,a,o){if(!a){if(!n.main)return Promise.resolve(r+(e.defaultJSExtensions?".js":""));a="./"==n.main.substr(0,2)?n.main.substr(2):n.main}var i,s;return n.map&&(i="./"+a,s=S(n.map,i),s||(i="./"+t(e,n,r,a,o),i!="./"+a&&(s=S(n.map,i)))),(s?d(e,n,r,s,i,o):Promise.resolve()).then(function(i){return i?Promise.resolve(i):Promise.resolve(r+"/"+t(e,n,r,a,o))})}function u(e,n,r,a,o,i,s){if("."==o)o=r;else if("./"==o.substr(0,2))return Promise.resolve(r+"/"+t(e,n,r,o.substr(2)+i.substr(a.length),s)).then(function(t){return L.call(e,t,r+"/")});return e.normalize(o+i.substr(a.length),r+"/")}function d(e,t,n,a,o,i){"/"==o[o.length-1]&&(o=o.substr(0,o.length-1));var s=t.map[a];if("string"==typeof s)return r(a,s,n,o)?u(e,t,n,a,s,o,i):Promise.resolve();if(e.builder)return Promise.resolve(n+"/#:"+o);var l=[],d=[];for(var c in s){var f=z(c);d.push({condition:f,map:s[c]}),l.push(e.import(f.module,n))}return Promise.all(l).then(function(e){for(var t=0;t<d.length;t++){var n=d[t].condition,r=x(n.prop,e[t]);if(!n.negate&&r||n.negate&&!r)return d[t].map}}).then(function(s){if(s){if(!r(a,s,n,o))return;return u(e,t,n,a,s,o,i)}})}function c(e){var t=e.lastIndexOf("*"),n=Math.max(t+1,e.lastIndexOf("/"));return{length:n,regEx:new RegExp("^("+e.substr(0,n).replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,"[^\\/]+")+")(\\/|$)"),wildcard:t!=-1}}function f(e,t){for(var n,r,a=!1,o=0;o<e.packageConfigPaths.length;o++){var i=e.packageConfigPaths[o],s=h[i]||(h[i]=c(i));if(!(t.length<s.length)){var l=t.match(s.regEx);!l||n&&(a&&s.wildcard||!(n.length<l[1].length))||(n=l[1],a=!s.wildcard,r=n+i.substr(s.length))}}if(n)return{packageName:n,configPath:r}}function m(e,t,n){var r=e.pluginLoader||e;return(r.meta[n]=r.meta[n]||{}).format="json",r.meta[n].loader=null,r.load(n).then(function(){var a=r.get(n).default;return a.systemjs&&(a=a.systemjs),a.modules&&(a.meta=a.modules,w.call(e,"Package config file "+n+' is configured with "modules", which is deprecated as it has been renamed to "meta".')),b(e,t,a,!0)})}function p(e,t,n){var r;for(var a in e){var o="./"==a.substr(0,2)?"./":"";if(o&&(a=a.substr(2)),r=a.indexOf("*"),r!==-1&&a.substr(0,r)==t.substr(0,r)&&a.substr(r+1)==t.substr(t.length-a.length+r+1)&&n(a,e[o+a],a.split("/").length))return}var i=e[t]&&e.hasOwnProperty&&e.hasOwnProperty(t)?e[t]:e["./"+t];i&&n(i,i,0)}s(function(e){return function(){e.call(this),this.packages={},this.packageConfigPaths=[]}}),a.prototype.normalizeSync=a.prototype.decanonicalize=a.prototype.normalize,i("decanonicalize",function(t){return function(n,r){if(this.builder)return t.call(this,n,r,!0);var a=t.call(this,n,r,!1);if(!this.defaultJSExtensions)return a;var o=e(this,a),i=this.packages[o],s=i&&i.defaultExtension;return void 0==s&&i&&i.meta&&p(i.meta,a.substr(o),function(e,t,n){if(0==n||e.lastIndexOf("*")!=e.length-1)return s=!1,!0}),(s===!1||s&&".js"!=s)&&".js"!=n.substr(n.length-3,3)&&".js"==a.substr(a.length-3,3)&&(a=a.substr(0,a.length-3)),a}}),i("normalizeSync",function(t){return function(r,a,i){var s=this;if(i=i===!0,a)var l=e(s,a)||s.defaultJSExtensions&&".js"==a.substr(a.length-3,3)&&e(s,a.substr(0,a.length-3));var u=l&&s.packages[l];if(u&&"."!=r[0]){var d=u.map,c=d&&S(d,r);if(c&&"string"==typeof d[c]){var m=o(s,u,l,c,r,i);if(m)return m}}var p=s.defaultJSExtensions&&".js"!=r.substr(r.length-3,3),h=t.call(s,r,a,!1);p&&".js"!=h.substr(h.length-3,3)&&(p=!1),p&&(h=h.substr(0,h.length-3));var g=f(s,h),v=g&&g.packageName||e(s,h);if(!v)return h+(p?".js":"");var y=h.substr(v.length+1);return n(s,s.packages[v]||{},v,y,i)}}),i("normalize",function(t){return function(n,r,a){var o=this;return a=a===!0,Promise.resolve().then(function(){if(r)var t=e(o,r)||o.defaultJSExtensions&&".js"==r.substr(r.length-3,3)&&e(o,r.substr(0,r.length-3));var i=t&&o.packages[t];if(i&&"./"!=n.substr(0,2)){var s=i.map,l=s&&S(s,n);if(l)return d(o,i,t,l,n,a)}return Promise.resolve()}).then(function(i){if(i)return i;var s=o.defaultJSExtensions&&".js"!=n.substr(n.length-3,3),u=t.call(o,n,r,!1);s&&".js"!=u.substr(u.length-3,3)&&(s=!1),s&&(u=u.substr(0,u.length-3));var d=f(o,u),c=d&&d.packageName||e(o,u);if(!c)return Promise.resolve(u+(s?".js":""));var p=o.packages[c],h=p&&(p.configured||!d);return(h?Promise.resolve(p):m(o,c,d.configPath)).then(function(e){var t=u.substr(c.length+1);return l(o,e,c,t,a)})})}});var h={};i("locate",function(t){return function(n){var r=this;return Promise.resolve(t.call(this,n)).then(function(t){var a=e(r,n.name);if(a){var o=r.packages[a],i=n.name.substr(a.length+1),s={};if(o.meta){var l=0;p(o.meta,i,function(e,t,n){n>l&&(l=n),v(s,t,n&&l>n)}),v(n.metadata,s)}o.format&&!n.metadata.loader&&(n.metadata.format=n.metadata.format||o.format)}return t})}})}(),function(){function t(){if(s&&"interactive"===s.script.readyState)return s.load;for(var e=0;e<d.length;e++)if("interactive"==d[e].script.readyState)return s=d[e],s.load}function n(e,t){return new Promise(function(e,n){t.metadata.integrity&&n(new Error("Subresource integrity checking is not supported in web workers.")),l=t;try{importScripts(t.address)}catch(e){l=null,n(e)}l=null,t.metadata.entry||n(new Error(t.address+" did not call System.register or AMD define. If loading a global, ensure the meta format is set to global.")),e("")})}if("undefined"!=typeof document)var r=document.getElementsByTagName("head")[0];var a,o,s,l=null,u=r&&function(){var e=document.createElement("script"),t="undefined"!=typeof opera&&"[object Opera]"===opera.toString();return e.attachEvent&&!(e.attachEvent.toString&&e.attachEvent.toString().indexOf("[native code")<0)&&!t}(),d=[],c=0,f=[];i("pushRegister_",function(e){return function(n){return!e.call(this,n)&&(l?this.reduceRegister_(l,n):u?this.reduceRegister_(t(),n):c?f.push(n):this.reduceRegister_(null,n),!0)}}),i("fetch",function(t){return function(i){var l=this;return"json"!=i.metadata.format&&i.metadata.scriptLoad&&(q||D)?D?n(l,i):new Promise(function(t,n){function m(e){if(!g.readyState||"loaded"==g.readyState||"complete"==g.readyState){if(c--,i.metadata.entry||f.length){if(!u){for(var r=0;r<f.length;r++)l.reduceRegister_(i,f[r]);f=[]}}else l.reduceRegister_(i);h(),i.metadata.entry||i.metadata.bundle||n(new Error(i.name+" did not call System.register or AMD define. If loading a global module configure the global name via the meta exports property for script injection support.")),t("")}}function p(e){h(),n(new Error("Unable to load script "+i.address));
+}function h(){if(e.System=a,e.require=o,g.detachEvent){g.detachEvent("onreadystatechange",m);for(var t=0;t<d.length;t++)d[t].script==g&&(s&&s.script==g&&(s=null),d.splice(t,1))}else g.removeEventListener("load",m,!1),g.removeEventListener("error",p,!1);r.removeChild(g)}var g=document.createElement("script");g.async=!0,i.metadata.crossOrigin&&(g.crossOrigin=i.metadata.crossOrigin),i.metadata.integrity&&g.setAttribute("integrity",i.metadata.integrity),u?(g.attachEvent("onreadystatechange",m),d.push({script:g,load:i})):(g.addEventListener("load",m,!1),g.addEventListener("error",p,!1)),c++,a=e.System,o=e.require,g.src=i.address,r.appendChild(g)}):t.call(this,i)}})}();var re=/^(\s*\/\*[^\*]*(\*(?!\/)[^\*]*)*\*\/|\s*\/\/[^\n]*|\s*"[^"]+"\s*;?|\s*'[^']+'\s*;?)*\s*/;!function(){function t(e,n,r){if(r[e.groupIndex]=r[e.groupIndex]||[],J.call(r[e.groupIndex],e)==-1){r[e.groupIndex].push(e);for(var a=0,o=e.normalizedDeps.length;a<o;a++){var i=e.normalizedDeps[a],s=n.defined[i];if(s&&!s.evaluated){var l=e.groupIndex+(s.declarative!=e.declarative);if(null===s.groupIndex||s.groupIndex<l){if(null!==s.groupIndex&&(r[s.groupIndex].splice(J.call(r[s.groupIndex],s),1),0==r[s.groupIndex].length))throw new Error("Mixed dependency cycle detected");s.groupIndex=l}t(s,n,r)}}}}function r(e,n,r){if(!n.module){n.groupIndex=0;var a=[];t(n,r,a);for(var o=!!n.declarative==a.length%2,i=a.length-1;i>=0;i--){for(var s=a[i],l=0;l<s.length;l++){var d=s[l];o?u(d,r):c(d,r)}o=!o}}}function o(){}function l(e,t){return t[e]||(t[e]={name:e,dependencies:[],exports:new o,importers:[]})}function u(t,n){if(!t.module){var r=n._loader.moduleRecords,a=t.module=l(t.name,r),o=t.module.exports,i=t.declare.call(e,function(e,t){if(a.locked=!0,"object"==typeof e)for(var n in e)o[n]=e[n];else o[e]=t;for(var r=0,i=a.importers.length;r<i;r++){var s=a.importers[r];if(!s.locked){var l=J.call(s.dependencies,a),u=s.setters[l];u&&u(o)}}return a.locked=!1,t},{id:t.name});if("function"==typeof i&&(i={setters:[],execute:i}),i=i||{setters:[],execute:function(){}},a.setters=i.setters,a.execute=i.execute,!a.setters||!a.execute)throw new TypeError("Invalid System.register form for "+t.name);for(var s=0,d=t.normalizedDeps.length;s<d;s++){var c,f=t.normalizedDeps[s],m=n.defined[f],p=r[f];p?c=p.exports:m&&!m.declarative?c=m.esModule:m?(u(m,n),p=m.module,c=p.exports):c=n.get(f),p&&p.importers?(p.importers.push(a),a.dependencies.push(p)):a.dependencies.push(null);for(var h=t.originalIndices[s],g=0,v=h.length;g<v;++g){var y=h[g];a.setters[y]&&a.setters[y](c)}}}}function d(e,t){var n,r=t.defined[e];if(r)r.declarative?f(e,r,[],t):r.evaluated||c(r,t),n=r.module.exports;else if(n=t.get(e),!n)throw new Error("Unable to load dependency "+e+".");return(!r||r.declarative)&&n&&n.__useDefault?n.default:n}function c(t,r){if(!t.module){var a={},o=t.module={exports:a,id:t.name};if(!t.executingRequire)for(var i=0,s=t.normalizedDeps.length;i<s;i++){var l=t.normalizedDeps[i],u=r.defined[l];u&&c(u,r)}t.evaluated=!0;var f=t.execute.call(e,function(e){for(var n=0,a=t.deps.length;n<a;n++)if(t.deps[n]==e)return d(t.normalizedDeps[n],r);var o=r.normalizeSync(e,t.name);if(J.call(t.normalizedDeps,o)!=-1)return d(o,r);throw new Error("Module "+e+" not declared as a dependency of "+t.name)},a,o);void 0!==f&&(o.exports=f),a=o.exports,a&&(a.__esModule||a instanceof n)?t.esModule=r.newModule(a):t.esmExports&&a!==e?t.esModule=r.newModule(p(a)):t.esModule=r.newModule({default:a,__useDefault:!0})}}function f(t,n,r,a){if(n&&!n.evaluated&&n.declarative){r.push(t);for(var o=0,i=n.normalizedDeps.length;o<i;o++){var s=n.normalizedDeps[o];J.call(r,s)==-1&&(a.defined[s]?f(s,a.defined[s],r,a):a.get(s))}n.evaluated||(n.evaluated=!0,n.module.execute.call(e))}}a.prototype.register=function(e,t,n){if("string"!=typeof e&&(n=t,t=e,e=null),"boolean"==typeof n)return this.registerDynamic.apply(this,arguments);var r=R();r.name=e&&(this.decanonicalize||this.normalize).call(this,e),r.declarative=!0,r.deps=t,r.declare=n,this.pushRegister_({amd:!1,entry:r})},a.prototype.registerDynamic=function(e,t,n,r){"string"!=typeof e&&(r=n,n=t,t=e,e=null);var a=R();a.name=e&&(this.decanonicalize||this.normalize).call(this,e),a.deps=t,a.execute=r,a.executingRequire=n,this.pushRegister_({amd:!1,entry:a})},i("reduceRegister_",function(){return function(e,t){if(t){var n=t.entry,r=e&&e.metadata;if(n.name&&(n.name in this.defined||(this.defined[n.name]=n),r&&(r.bundle=!0)),!n.name||e&&!r.entry&&n.name==e.name){if(!r)throw new TypeError("Invalid System.register call. Anonymous System.register calls can only be made by modules loaded by SystemJS.import and not via script tags.");if(r.entry)throw"register"==r.format?new Error("Multiple anonymous System.register calls in module "+e.name+". If loading a bundle, ensure all the System.register calls are named."):new Error("Module "+e.name+" interpreted as "+r.format+" module format, but called System.register.");r.format||(r.format="register"),r.entry=n}}}}),s(function(e){return function(){e.call(this),this.defined={},this._loader.moduleRecords={}}}),A(o,"toString",{value:function(){return"Module"}}),i("delete",function(e){return function(t){return delete this._loader.moduleRecords[t],delete this.defined[t],e.call(this,t)}}),i("fetch",function(e){return function(t){return this.defined[t.name]?(t.metadata.format="defined",""):(t.metadata.deps=t.metadata.deps||[],e.call(this,t))}}),i("translate",function(e){return function(t){return t.metadata.deps=t.metadata.deps||[],Promise.resolve(e.apply(this,arguments)).then(function(e){return("register"==t.metadata.format||!t.metadata.format&&O(t.source))&&(t.metadata.format="register"),e})}}),i("load",function(e){return function(t){var n=this,a=n.defined[t];return!a||a.deps.length?e.apply(this,arguments):(a.originalIndices=a.normalizedDeps=[],r(t,a,n),f(t,a,[],n),a.esModule||(a.esModule=n.newModule(a.module.exports)),n.trace||(n.defined[t]=void 0),n.set(t,a.esModule),Promise.resolve())}}),i("instantiate",function(e){return function(t){"detect"==t.metadata.format&&(t.metadata.format=void 0),e.call(this,t);var n,a=this;if(a.defined[t.name])n=a.defined[t.name],n.declarative||(n.deps=n.deps.concat(t.metadata.deps)),n.deps=n.deps.concat(t.metadata.deps);else if(t.metadata.entry)n=t.metadata.entry,n.deps=n.deps.concat(t.metadata.deps);else if(!(a.builder&&t.metadata.bundle||"register"!=t.metadata.format&&"esm"!=t.metadata.format&&"es6"!=t.metadata.format)){if("undefined"!=typeof __exec&&__exec.call(a,t),!t.metadata.entry&&!t.metadata.bundle)throw new Error(t.name+" detected as "+t.metadata.format+" but didn't execute.");n=t.metadata.entry,n&&t.metadata.deps&&(n.deps=n.deps.concat(t.metadata.deps))}n||(n=R(),n.deps=t.metadata.deps,n.execute=function(){}),a.defined[t.name]=n;var o=m(n.deps);n.deps=o.names,n.originalIndices=o.indices,n.name=t.name,n.esmExports=t.metadata.esmExports!==!1;for(var i=[],s=0,l=n.deps.length;s<l;s++)i.push(Promise.resolve(a.normalize(n.deps[s],t.name)));return Promise.all(i).then(function(e){return n.normalizedDeps=e,{deps:n.deps,execute:function(){return r(t.name,n,a),f(t.name,n,[],a),n.esModule||(n.esModule=a.newModule(n.module.exports)),a.trace||(a.defined[t.name]=void 0),n.esModule}}})}})}(),i("reduceRegister_",function(e){return function(t,n){if(n||!t.metadata.exports&&(!D||"global"!=t.metadata.format))return e.call(this,t,n);t.metadata.format="global";var r=t.metadata.entry=R();r.deps=t.metadata.deps;var a=M(t.metadata.exports);r.execute=function(){return a}}}),s(function(t){return function(){function n(t){if(Object.keys)Object.keys(e).forEach(t);else for(var n in e)i.call(e,n)&&t(n)}function r(t){n(function(n){if(J.call(s,n)==-1){try{var r=e[n]}catch(e){s.push(n)}t(n,r)}})}var a=this;t.call(a);var o,i=Object.prototype.hasOwnProperty,s=["_g","sessionStorage","localStorage","clipboardData","frames","frameElement","external","mozAnimationStartTime","webkitStorageInfo","webkitIndexedDB","mozInnerScreenY","mozInnerScreenX"];a.set("@@global-helpers",a.newModule({prepareGlobal:function(t,n,a,i){var s=e.define;e.define=void 0;var l;if(a){l={};for(var u in a)l[u]=e[u],e[u]=a[u]}return n||(o={},r(function(e,t){o[e]=t})),function(){var t,a=n?M(n):{},u=!!n;if(n&&!i||r(function(r,s){o[r]!==s&&"undefined"!=typeof s&&(i&&(e[r]=void 0),n||(a[r]=s,"undefined"!=typeof t?u||t===s||(u=!0):t=s))}),a=u?a:t,l)for(var d in l)e[d]=l[d];return e.define=s,a}}}))}}),s(function(e){return function(){function t(e){return"file:///"==e.substr(0,8)?e.substr(7+!!U):r&&e.substr(0,r.length)==r?e.substr(r.length):e}var n=this;if(e.call(n),"undefined"!=typeof window&&"undefined"!=typeof document&&window.location)var r=location.protocol+"//"+location.hostname+(location.port?":"+location.port:"");n.set("@@cjs-helpers",n.newModule({requireResolve:function(e,r){return t(n.normalizeSync(e,r))},getPathVars:function(e){var n,r=e.lastIndexOf("!");n=r!=-1?e.substr(0,r):e;var a=n.split("/");return a.pop(),a=a.join("/"),{filename:t(n),dirname:t(a)}}}))}}),i("fetch",function(t){return function(n){return n.metadata.scriptLoad&&q&&(e.define=this.amdDefine),t.call(this,n)}}),s(function(t){return function(){function n(e,t){e=e.replace(s,"");var n=e.match(d),r=(n[1].split(",")[t]||"require").replace(c,""),a=f[r]||(f[r]=new RegExp(l+r+u,"g"));a.lastIndex=0;for(var o,i=[];o=a.exec(e);)i.push(o[2]||o[3]);return i}function r(e,t,n,a){if("object"==typeof e&&!(e instanceof Array))return r.apply(null,Array.prototype.splice.call(arguments,1,arguments.length-1));if("string"==typeof e&&"function"==typeof t&&(e=[e]),!(e instanceof Array)){if("string"==typeof e){var i=o.defaultJSExtensions&&".js"!=e.substr(e.length-3,3),s=o.decanonicalize(e,a);i&&".js"==s.substr(s.length-3,3)&&(s=s.substr(0,s.length-3));var l=o.get(s);if(!l)throw new Error('Module not already loaded loading "'+e+'" as '+s+(a?' from "'+a+'".':"."));return l.__useDefault?l.default:l}throw new TypeError("Invalid require")}for(var u=[],d=0;d<e.length;d++)u.push(o.import(e[d],a));Promise.all(u).then(function(e){t&&t.apply(null,e)},n)}function a(t,a,i){function s(t,n,s){function c(e,n,a){return"string"==typeof e&&"function"!=typeof n?t(e):r.call(o,e,n,a,s.id)}for(var f=[],m=0;m<a.length;m++)f.push(t(a[m]));s.uri=s.id,s.config=function(){},d!=-1&&f.splice(d,0,s),u!=-1&&f.splice(u,0,n),l!=-1&&(c.toUrl=function(e){var t=o.defaultJSExtensions&&".js"!=e.substr(e.length-3,3),n=o.decanonicalize(e,s.id);return t&&".js"==n.substr(n.length-3,3)&&(n=n.substr(0,n.length-3)),n},f.splice(l,0,c));var p=e.require;e.require=r;var h=i.apply(u==-1?e:n,f);if(e.require=p,"undefined"==typeof h&&s&&(h=s.exports),"undefined"!=typeof h)return h}"string"!=typeof t&&(i=a,a=t,t=null),a instanceof Array||(i=a,a=["require","exports","module"].splice(0,i.length)),"function"!=typeof i&&(i=function(e){return function(){return e}}(i)),void 0===a[a.length-1]&&a.pop();var l,u,d;(l=J.call(a,"require"))!=-1&&(a.splice(l,1),t||(a=a.concat(n(i.toString(),l)))),(u=J.call(a,"exports"))!=-1&&a.splice(u,1),(d=J.call(a,"module"))!=-1&&a.splice(d,1);var c=R();c.name=t&&(o.decanonicalize||o.normalize).call(o,t),c.deps=a,c.execute=s,o.pushRegister_({amd:!0,entry:c})}var o=this;t.call(this);var s=/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/gm,l="(?:^|[^$_a-zA-Z\\xA0-\\uFFFF.])",u="\\s*\\(\\s*(\"([^\"]+)\"|'([^']+)')\\s*\\)",d=/\(([^\)]*)\)/,c=/^\s+|\s+$/g,f={};a.amd={},i("reduceRegister_",function(e){return function(t,n){if(!n||!n.amd)return e.call(this,t,n);var r=t&&t.metadata,a=n.entry;if(r)if(r.format&&"detect"!=r.format){if(!a.name&&"amd"!=r.format)throw new Error("AMD define called while executing "+r.format+" module "+t.name)}else r.format="amd";if(a.name)r&&(r.entry||r.bundle?r.entry&&r.entry.name&&r.entry.name!=t.name&&(r.entry=void 0):r.entry=a,r.bundle=!0),a.name in this.defined||(this.defined[a.name]=a);else{if(!r)throw new TypeError("Unexpected anonymous AMD define.");if(r.entry&&!r.entry.name)throw new Error("Multiple anonymous defines in module "+t.name);r.entry=a}}}),o.amdDefine=a,o.amdRequire=r}}),function(){function e(e,t){if(t){var n;if(e.pluginFirst){if((n=t.lastIndexOf("!"))!=-1)return t.substr(n+1)}else if((n=t.indexOf("!"))!=-1)return t.substr(0,n);return t}}function t(e,t){var n,r,a=t.lastIndexOf("!");if(a!=-1)return e.pluginFirst?(n=t.substr(a+1),r=t.substr(0,a)):(n=t.substr(0,a),r=t.substr(a+1)||n.substr(n.lastIndexOf(".")+1)),{argument:n,plugin:r}}function n(e,t,n,r){return r&&".js"==t.substr(t.length-3,3)&&(t=t.substr(0,t.length-3)),e.pluginFirst?n+"!"+t:t+"!"+n}function r(e,t){return e.defaultJSExtensions&&".js"!=t.substr(t.length-3,3)}function a(a){return function(o,i,s){var l=this,u=t(l,o);if(i=e(this,i),!u)return a.call(this,o,i,s);var d=l.normalizeSync(u.argument,i,!0),c=l.normalizeSync(u.plugin,i,!0);return n(l,d,c,r(l,u.argument))}}i("decanonicalize",a),i("normalizeSync",a),i("normalize",function(a){return function(o,i,s){var l=this;i=e(this,i);var u=t(l,o);return u?Promise.all([l.normalize(u.argument,i,!0),l.normalize(u.plugin,i,!1)]).then(function(e){return n(l,e[0],e[1],r(l,u.argument))}):a.call(l,o,i,s)}}),i("locate",function(e){return function(t){var n,r=this,a=t.name;return r.pluginFirst?(n=a.indexOf("!"))!=-1&&(t.metadata.loader=a.substr(0,n),t.name=a.substr(n+1)):(n=a.lastIndexOf("!"))!=-1&&(t.metadata.loader=a.substr(n+1),t.name=a.substr(0,n)),e.call(r,t).then(function(e){return n==-1&&t.metadata.loader?(r.pluginLoader||r).normalize(t.metadata.loader,t.name).then(function(n){return t.metadata.loader=n,e}):e}).then(function(e){var n=t.metadata.loader;if(!n)return e;if(t.name==n)throw new Error("Plugin "+n+" cannot load itself, make sure it is excluded from any wildcard meta configuration via a custom loader: false rule.");if(r.defined&&r.defined[a])return e;var o=r.pluginLoader||r;return o.import(n).then(function(n){return t.metadata.loaderModule=n,t.address=e,n.locate?n.locate.call(r,t):e})})}}),i("fetch",function(e){return function(t){var n=this;return t.metadata.loaderModule&&t.metadata.loaderModule.fetch&&"defined"!=t.metadata.format?(t.metadata.scriptLoad=!1,t.metadata.loaderModule.fetch.call(n,t,function(t){return e.call(n,t)})):e.call(n,t)}}),i("translate",function(e){return function(t){var n=this,r=arguments;return t.metadata.loaderModule&&t.metadata.loaderModule.translate&&"defined"!=t.metadata.format?Promise.resolve(t.metadata.loaderModule.translate.apply(n,r)).then(function(a){var o=t.metadata.sourceMap;if(o){if("object"!=typeof o)throw new Error("load.metadata.sourceMap must be set to an object.");var i=t.address.split("!")[0];o.file&&o.file!=t.address||(o.file=i+"!transpiled"),(!o.sources||o.sources.length<=1&&(!o.sources[0]||o.sources[0]==t.address))&&(o.sources=[i])}return"string"==typeof a?t.source=a:w.call(this,"Plugin "+t.metadata.loader+" should return the source in translate, instead of setting load.source directly. This support will be deprecated."),e.apply(n,r)}):e.apply(n,r)}}),i("instantiate",function(e){return function(t){var n=this,r=!1;return t.metadata.loaderModule&&t.metadata.loaderModule.instantiate&&!n.builder&&"defined"!=t.metadata.format?Promise.resolve(t.metadata.loaderModule.instantiate.call(n,t,function(t){if(r)throw new Error("Instantiate must only be called once.");return r=!0,e.call(n,t)})).then(function(a){return r?a:(t.metadata.entry=R(),t.metadata.entry.execute=function(){return a},t.metadata.entry.deps=t.metadata.deps,t.metadata.format="defined",e.call(n,t))}):e.call(n,t)}})}();var ae=["browser","node","dev","build","production","default"],oe=/#\{[^\}]+\}/;i("normalize",function(e){return function(t,n,r){var a=this;return T.call(a,t,n).then(function(t){return e.call(a,t,n,r)}).then(function(e){return L.call(a,e,n)})}}),function(){i("fetch",function(e){return function(t){var n=t.metadata.alias,r=t.metadata.deps||[];if(n){t.metadata.format="defined";var a=R();return this.defined[t.name]=a,a.declarative=!0,a.deps=r.concat([n]),a.declare=function(e){return{setters:[function(t){for(var n in t)e(n,t[n]);t.__useDefault&&(a.module.exports.__useDefault=!0)}],execute:function(){}}},""}return e.call(this,t)}})}(),function(){function e(e,t,n){for(var r,a=t.split(".");a.length>1;)r=a.shift(),e=e[r]=e[r]||{};r=a.shift(),r in e||(e[r]=n)}s(function(e){return function(){this.meta={},e.call(this)}}),i("locate",function(e){return function(t){var n,r=this.meta,a=t.name,o=0;for(var i in r)if(n=i.indexOf("*"),n!==-1&&i.substr(0,n)===a.substr(0,n)&&i.substr(n+1)===a.substr(a.length-i.length+n+1)){var s=i.split("/").length;s>o&&(o=s),v(t.metadata,r[i],o!=s)}return r[a]&&v(t.metadata,r[a]),e.call(this,t)}});var t=/^(\s*\/\*[^\*]*(\*(?!\/)[^\*]*)*\*\/|\s*\/\/[^\n]*|\s*"[^"]+"\s*;?|\s*'[^']+'\s*;?)+/,n=/\/\*[^\*]*(\*(?!\/)[^\*]*)*\*\/|\/\/[^\n]*|"[^"]+"\s*;?|'[^']+'\s*;?/g;i("translate",function(r){return function(a){if("defined"==a.metadata.format)return a.metadata.deps=a.metadata.deps||[],Promise.resolve(a.source);var o=a.source.match(t);if(o)for(var i=o[0].match(n),s=0;s<i.length;s++){var l=i[s],u=l.length,d=l.substr(0,1);if(";"==l.substr(u-1,1)&&u--,'"'==d||"'"==d){var c=l.substr(1,l.length-3),f=c.substr(0,c.indexOf(" "));if(f){var m=c.substr(f.length+1,c.length-f.length-1);"[]"==f.substr(f.length-2,2)?(f=f.substr(0,f.length-2),a.metadata[f]=a.metadata[f]||[],a.metadata[f].push(m)):a.metadata[f]instanceof Array?(w.call(this,"Module "+a.name+' contains deprecated "deps '+m+'" meta syntax.\nThis should be updated to "deps[] '+m+'" for pushing to array meta.'),a.metadata[f].push(m)):e(a.metadata,f,m)}else a.metadata[c]=!0}}return r.apply(this,arguments)}})}(),function(){s(function(e){return function(){e.call(this),this.bundles={},this._loader.loadedBundles={}}}),i("locate",function(e){return function(t){var n=this,r=!1;if(!(t.name in n.defined))for(var a in n.bundles){for(var o=0;o<n.bundles[a].length;o++){var i=n.bundles[a][o];if(i==t.name){r=!0;break}if(i.indexOf("*")!=-1){var s=i.split("*");if(2!=s.length){n.bundles[a].splice(o--,1);continue}if(t.name.substring(0,s[0].length)==s[0]&&t.name.substr(t.name.length-s[1].length,s[1].length)==s[1]&&t.name.substr(s[0].length,t.name.length-s[1].length-s[0].length).indexOf("/")==-1){r=!0;break}}}if(r)return n.import(a).then(function(){return e.call(n,t)})}return e.call(n,t)}})}(),function(){s(function(e){return function(){e.call(this),this.depCache={}}}),i("locate",function(e){return function(t){var n=this,r=n.depCache[t.name];if(r)for(var a=0;a<r.length;a++)n.import(r[a],t.name);return e.call(n,t)}})}(),s(function(t){return function(){t.apply(this,arguments),e.define=this.amdDefine}}),i("fetch",function(e){return function(t){return t.metadata.scriptLoad=!0,e.call(this,t)}}),X=new a,e.SystemJS=X,X.version="0.19.39 CSP","object"==typeof module&&module.exports&&"object"==typeof exports&&(module.exports=X),e.System=X}("undefined"!=typeof self?self:global)}var t="undefined"==typeof Promise;if("undefined"!=typeof document){var n=document.getElementsByTagName("script");if($__curScript=n[n.length-1],document.currentScript&&($__curScript.defer||$__curScript.async)&&($__curScript=document.currentScript),t){var r=$__curScript.src,a=r.substr(0,r.lastIndexOf("/")+1);window.systemJSBootstrap=e,document.write('<script type="text/javascript" src="'+a+'system-polyfills.js"></script>')}else e()}else if("undefined"!=typeof importScripts){var a="";try{throw new Error("_")}catch(e){e.stack.replace(/(?:at|@).*(http.+):[\d]+:[\d]+/,function(e,t){$__curScript={src:t},a=t.replace(/\/[^\/]*$/,"/")})}t&&importScripts(a+"system-polyfills.js"),e()}else $__curScript="undefined"!=typeof __filename?{src:__filename}:null,e()}();
+//# sourceMappingURL=system-csp-production.js.map
diff --git a/dist/system-csp-production.js.map b/dist/system-csp-production.js.map
new file mode 100644
index 000000000..00237ee6e
--- /dev/null
+++ b/dist/system-csp-production.js.map
@@ -0,0 +1 @@
+{"version":3,"sources":["system-csp-production.src.js"],"names":["bootstrap","global","URLPolyfill","url","baseURL","TypeError","m","String","replace","match","RangeError","protocol","username","password","host","hostname","port","pathname","search","hash","undefined","base","flag","slice","lastIndexOf","output","p","pop","push","join","this","origin","href","self","__global","addToError","err","msg","originalErr","stack","message","toString","split","newStack","i","length","$__curScript","indexOf","src","newMsg","substr","isBrowser","isWindows","newErr","errArgs","Error","fileName","lineNumber","Module","Loader","options","_loader","loaderObj","loads","modules","importPromises","moduleRecords","defineProperty","get","SystemJSLoader","call","paths","systemJSConstructor","SystemProto","hook","name","prototype","hookConstructor","isAbsolute","absURLRegEx","isRel","isPlain","urlResolve","parent","baseURI","URL","baseURIObj","applyPaths","loader","wildcard","pathMatch","maxWildcardPrefixLen","pathsCache","hasOwnProperty","path","pathParts","wildcardPrefixLen","outPath","group","deps","names","indices","l","index","getESModule","exports","esModule","getOwnPropertyDescriptor","defineOrCopyProperty","extend","value","targetObj","sourceObj","propName","d","Object","ex","a","b","prepend","extendMeta","val","Array","concat","extendPkgConfig","pkgCfgA","pkgCfgB","pkgName","warnInvalidProperties","prop","map","meta","depCache","dNormalized","coreResolve","warn","setPkgConfig","cfg","prependConfig","pkg","packages","basePkg","main","warnings","console","readMemberExpression","pParts","shift","getMapMatch","bestMatch","bestMatchLength","curMatchLength","prepareBaseURL","setProduction","isProduction","isBuilder","set","envModule","newModule","browser","node","_nodeRequire","production","dev","build","default","getNodeModule","parentModuleContext","_nodeModulePaths","require","parentName","mapMatch","has","builder","envSet","envCallback","browserConfig","nodeConfig","devConfig","buildConfig","productionConfig","detectRegisterFormat","source","leadingCommentAndMeta","leadingCommentAndMetaRegEx","createEntry","originalIndices","declare","execute","executingRequire","declarative","normalizedDeps","groupIndex","evaluated","module","esmExports","getGlobalValue","globalValue","first","parseCondition","condition","conditionExport","conditionModule","negation","conditionExportIndex","sysConditions","negate","serializeCondition","conditionObj","resolveCondition","bool","normalize","then","normalizedCondition","load","q","interpolateConditional","conditionalMatch","interpolationRegEx","Promise","resolve","conditionValue","booleanConditional","booleanIndex","isWorker","window","importScripts","document","process","platform","assert","item","thisLen","e","obj","opt","getElementsByTagName","bases","location","cwd","nativeURL","createLoad","status","anonCnt","linkSets","dependencies","metadata","loadModule","asyncStartLoadPartwayThrough","step","address","moduleName","moduleMetadata","moduleSource","moduleAddress","requestLoad","request","refererName","refererAddress","reject","proceedToLocate","proceedToFetch","locate","proceedToTranslate","fetch","translate","instantiate","instantiateResult","depsList","loadPromises","depLoad","key","addLoadToLinkSet","all","updateLinkSetOnLoad","exc","exception","linkSetFailed","stepState","existingLoad","done","linkSet","createLinkSet","startingLoad","loadingCount","j","doLink","error","link","_newModule","finishLoad","abrupt","checkError","pLoad","dep","failed","linkIndex","splice","globalLoadsIndex","trace","depMap","forEach","loadIndex","doDynamicExecute","linkError","createImportPromise","promise","constructor","define","delete","import","parentAddress","sourcePromise","pNames","getOwnPropertyNames","configurable","enumerable","freeze","referrerName","referrerAddress","System","fetchTextFromURL","XMLHttpRequest","authorization","fulfill","xhr","responseText","statusText","sameDomain","doTimeout","domainCheck","exec","XDomainRequest","onload","onerror","ontimeout","onprogress","timeout","onreadystatechange","readyState","addEventListener","open","setRequestHeader","withCredentials","setTimeout","send","fs","readFile","data","dataString","opts","headers","Accept","credentials","r","ok","text","scriptSrc","defaultJSExtensions","pluginFirst","loaderErrorStack","skipExt","resolved","httpRequest","systemImport","__useDefault","systemTranslate","format","apply","arguments","entry","JSON","parse","getConfig","curCurScript","config","isEnvConfig","checkHasConfig","transpilerRuntime","loadedTranspilerRuntime","bundles","packageConfigPaths","objMaps","v","defaultJSExtension","decanonicalize","pkgMatch","packageLength","Math","max","normalized","bundle","normalizedBundleDep","c","getPackage","curPkg","pkgLen","curPkgLen","addDefaultExtension","subPath","skipExtensions","defaultExtension","metaMatch","getMetaMatches","metaPattern","matchMeta","matchDepth","applyPackageConfigSync","mapPath","mapped","doMapSync","validMapping","normalizeSync","applyPackageConfig","doMap","doStringMap","conditionPromises","conditions","conditionValues","createPkgConfigPathObj","lastWildcard","regEx","RegExp","getPackageConfigMatch","configPath","exactMatch","packageConfigPath","packageName","loadPackageConfigPath","pkgConfigPath","configLoader","pluginLoader","systemjs","pkgMeta","matchFn","wildcardIndex","dotRel","exactMeta","decanonicalized","isPlugin","parentPackageName","parentPackage","parentMap","parentMapMatch","pkgConfigMatch","isConfigured","configured","bestDepth","getInteractiveScriptLoad","interactiveScript","script","interactiveLoadingScripts","webWorkerImport","integrity","workerLoad","head","curSystem","curRequire","ieEvents","s","createElement","isOpera","opera","attachEvent","loadingCnt","registerQueue","pushRegister","register","reduceRegister_","scriptLoad","complete","evt","cleanup","detachEvent","removeEventListener","removeChild","async","crossOrigin","setAttribute","appendChild","buildGroups","groups","depName","depEntry","defined","depGroupIndex","startEntry","curGroupDeclarative","linkDeclarativeModule","linkDynamicModule","ModuleRecord","getOrCreateModuleRecord","importers","declaration","locked","importerModule","importerIndex","setter","setters","id","depExports","depModule","len","getModule","ensureEvaluated","nameNormalized","__esModule","seen","registerDynamic","pushRegister_","amd","curMeta","del","doLoad","__exec","grouped","normalizePromises","reduceRegister","forEachGlobal","callback","keys","g","forEachGlobalValue","globalName","ignoredGlobalProps","globalSnapshot","prepareGlobal","globals","encapsulate","curDefine","oldGlobals","singleGlobal","multipleExports","stripOrigin","windowOrigin","requireResolve","parentId","getPathVars","moduleId","filename","pluginIndex","dirname","amdDefine","getCJSDeps","requireIndex","commentRegEx","params","fnBracketRegEx","requireAlias","wsRegEx","requireRegEx","requireRegExs","cjsRequirePre","cjsRequirePost","lastIndex","errback","referer","dynamicRequires","factory","req","contextualRequire","depValues","uri","moduleIndex","exportsIndex","toUrl","amdRequire","getParentName","parentPluginIndex","parsePlugin","argumentName","pluginName","argument","plugin","combinePluginParts","checkDefaultExtension","arg","createNormalizeSync","parsed","pluginSyntaxIndex","loaderNormalized","loaderModule","args","result","sourceMap","originalName","file","sources","calledInstantiate","alias","aliasDeps","_export","setMetaProperty","target","curPart","depth","metaRegEx","metaPartRegEx","metaParts","firstChar","metaString","metaName","metaValue","loadedBundles","matched","curModule","parts","substring","SystemJS","version","doPolyfill","scripts","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B,IAAwB,mBAAbQ,UAA0B,CACnC,GAAIgY,GAAUhY,SAASS,qBAAqB,SAI5C,IAHA9L,aAAeqjB,EAAQA,EAAQtjB,OAAS,GACpCsL,SAASiY,gBAAkBtjB,aAAaujB,OAASvjB,aAAa8a,SAChE9a,aAAeqL,SAASiY,eACtBF,EAAY,CACd,GAAII,GAAUxjB,aAAaE,IACvBujB,EAAWD,EAAQpjB,OAAO,EAAGojB,EAAQ9kB,YAAY,KAAO,EAC5DyM,QAAOuY,kBAAoBxmB,EAC3BmO,SAASsY,MACP,uCAA8CF,EAAW,sCAI3DvmB,SAIC,IAA6B,mBAAlBkO,eAA+B,CAC7C,GAAIqY,GAAW,EACf,KACE,KAAM,IAAIhjB,OAAM,KAChB,MAAOkL,GACPA,EAAElM,MAAM/B,QAAQ,iCAAkC,SAASF,EAAGH,GAC5D2C,cAAiBE,IAAK7C,GACtBomB,EAAWpmB,EAAIK,QAAQ,YAAa,OAGpC0lB,GACFhY,cAAcqY,EAAW,uBAC3BvmB,QAGA8C,cAAoC,mBAAd4jB,aAA8B1jB,IAAK0jB,YAAe,KACxE1mB"} \ No newline at end of file
diff --git a/dist/system-csp-production.src.js b/dist/system-csp-production.src.js
new file mode 100644
index 000000000..9c5e56532
--- /dev/null
+++ b/dist/system-csp-production.src.js
@@ -0,0 +1,4536 @@
+/*
+ * SystemJS v0.19.39
+ */
+(function() {
+function bootstrap() {// from https://gist.github.com/Yaffle/1088850
+(function(global) {
+function URLPolyfill(url, baseURL) {
+ if (typeof url != 'string')
+ throw new TypeError('URL must be a string');
+ var m = String(url).replace(/^\s+|\s+$/g, "").match(/^([^:\/?#]+:)?(?:\/\/(?:([^:@\/?#]*)(?::([^:@\/?#]*))?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/);
+ if (!m)
+ throw new RangeError('Invalid URL format');
+ var protocol = m[1] || "";
+ var username = m[2] || "";
+ var password = m[3] || "";
+ var host = m[4] || "";
+ var hostname = m[5] || "";
+ var port = m[6] || "";
+ var pathname = m[7] || "";
+ var search = m[8] || "";
+ var hash = m[9] || "";
+ if (baseURL !== undefined) {
+ var base = baseURL instanceof URLPolyfill ? baseURL : new URLPolyfill(baseURL);
+ var flag = !protocol && !host && !username;
+ if (flag && !pathname && !search)
+ search = base.search;
+ if (flag && pathname[0] !== "/")
+ pathname = (pathname ? (((base.host || base.username) && !base.pathname ? "/" : "") + base.pathname.slice(0, base.pathname.lastIndexOf("/") + 1) + pathname) : base.pathname);
+ // dot segments removal
+ var output = [];
+ pathname.replace(/^(\.\.?(\/|$))+/, "")
+ .replace(/\/(\.(\/|$))+/g, "/")
+ .replace(/\/\.\.$/, "/../")
+ .replace(/\/?[^\/]*/g, function (p) {
+ if (p === "/..")
+ output.pop();
+ else
+ output.push(p);
+ });
+ pathname = output.join("").replace(/^\//, pathname[0] === "/" ? "/" : "");
+ if (flag) {
+ port = base.port;
+ hostname = base.hostname;
+ host = base.host;
+ password = base.password;
+ username = base.username;
+ }
+ if (!protocol)
+ protocol = base.protocol;
+ }
+
+ // convert URLs to use / always
+ pathname = pathname.replace(/\\/g, '/');
+
+ this.origin = host ? protocol + (protocol !== "" || host !== "" ? "//" : "") + host : "";
+ this.href = protocol + (protocol && host || protocol == "file:" ? "//" : "") + (username !== "" ? username + (password !== "" ? ":" + password : "") + "@" : "") + host + pathname + search + hash;
+ this.protocol = protocol;
+ this.username = username;
+ this.password = password;
+ this.host = host;
+ this.hostname = hostname;
+ this.port = port;
+ this.pathname = pathname;
+ this.search = search;
+ this.hash = hash;
+}
+global.URLPolyfill = URLPolyfill;
+})(typeof self != 'undefined' ? self : global);(function(__global) {
+
+ var isWorker = typeof window == 'undefined' && typeof self != 'undefined' && typeof importScripts != 'undefined';
+ var isBrowser = typeof window != 'undefined' && typeof document != 'undefined';
+ var isWindows = typeof process != 'undefined' && typeof process.platform != 'undefined' && !!process.platform.match(/^win/);
+
+ if (!__global.console)
+ __global.console = { assert: function() {} };
+
+ // IE8 support
+ var indexOf = Array.prototype.indexOf || function(item) {
+ for (var i = 0, thisLen = this.length; i < thisLen; i++) {
+ if (this[i] === item) {
+ return i;
+ }
+ }
+ return -1;
+ };
+
+ var defineProperty;
+ (function () {
+ try {
+ if (!!Object.defineProperty({}, 'a', {}))
+ defineProperty = Object.defineProperty;
+ }
+ catch (e) {
+ defineProperty = function(obj, prop, opt) {
+ try {
+ obj[prop] = opt.value || opt.get.call(obj);
+ }
+ catch(e) {}
+ }
+ }
+ })();
+
+ var errArgs = new Error(0, '_').fileName == '_';
+
+ function addToError(err, msg) {
+ // parse the stack removing loader code lines for simplification
+ if (!err.originalErr) {
+ var stack = ((err.message || err) + (err.stack ? '\n' + err.stack : '')).toString().split('\n');
+ var newStack = [];
+ for (var i = 0; i < stack.length; i++) {
+ if (typeof $__curScript == 'undefined' || stack[i].indexOf($__curScript.src) == -1)
+ newStack.push(stack[i]);
+ }
+ }
+
+ var newMsg = '(SystemJS) ' + (newStack ? newStack.join('\n\t') : err.message.substr(11)) + '\n\t' + msg;
+
+ // Convert file:/// URLs to paths in Node
+ if (!isBrowser)
+ newMsg = newMsg.replace(isWindows ? /file:\/\/\//g : /file:\/\//g, '');
+
+ var newErr = errArgs ? new Error(newMsg, err.fileName, err.lineNumber) : new Error(newMsg);
+
+ newErr.stack = newMsg;
+
+ // track the original error
+ newErr.originalErr = err.originalErr || err;
+
+ return newErr;
+ }
+
+ function __eval(source, debugName, context) {
+ try {
+ new Function(source).call(context);
+ }
+ catch(e) {
+ throw addToError(e, 'Evaluating ' + debugName);
+ }
+ }
+
+ var baseURI;
+
+ // environent baseURI detection
+ if (typeof document != 'undefined' && document.getElementsByTagName) {
+ baseURI = document.baseURI;
+
+ if (!baseURI) {
+ var bases = document.getElementsByTagName('base');
+ baseURI = bases[0] && bases[0].href || window.location.href;
+ }
+ }
+ else if (typeof location != 'undefined') {
+ baseURI = __global.location.href;
+ }
+
+ // sanitize out the hash and querystring
+ if (baseURI) {
+ baseURI = baseURI.split('#')[0].split('?')[0];
+ baseURI = baseURI.substr(0, baseURI.lastIndexOf('/') + 1);
+ }
+ else if (typeof process != 'undefined' && process.cwd) {
+ baseURI = 'file://' + (isWindows ? '/' : '') + process.cwd() + '/';
+ if (isWindows)
+ baseURI = baseURI.replace(/\\/g, '/');
+ }
+ else {
+ throw new TypeError('No environment baseURI');
+ }
+
+ try {
+ var nativeURL = new __global.URL('test:///').protocol == 'test:';
+ }
+ catch(e) {}
+
+ var URL = nativeURL ? __global.URL : __global.URLPolyfill;
+
+/*
+*********************************************************************************************
+
+ Dynamic Module Loader Polyfill
+
+ - Implemented exactly to the former 2014-08-24 ES6 Specification Draft Rev 27, Section 15
+ http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts#august_24_2014_draft_rev_27
+
+ - Functions are commented with their spec numbers, with spec differences commented.
+
+ - Spec bugs are commented in this code with links.
+
+ - Abstract functions have been combined where possible, and their associated functions
+ commented.
+
+ - Realm implementation is entirely omitted.
+
+*********************************************************************************************
+*/
+
+function Module() {}
+// http://www.ecma-international.org/ecma-262/6.0/#sec-@@tostringtag
+defineProperty(Module.prototype, 'toString', {
+ value: function() {
+ return 'Module';
+ }
+});
+function Loader(options) {
+ this._loader = {
+ loaderObj: this,
+ loads: [],
+ modules: {},
+ importPromises: {},
+ moduleRecords: {}
+ };
+
+ // 26.3.3.6
+ defineProperty(this, 'global', {
+ get: function() {
+ return __global;
+ }
+ });
+
+ // 26.3.3.13 realm not implemented
+}
+
+(function() {
+
+// Some Helpers
+
+// logs a linkset snapshot for debugging
+/* function snapshot(loader) {
+ console.log('---Snapshot---');
+ for (var i = 0; i < loader.loads.length; i++) {
+ var load = loader.loads[i];
+ var linkSetLog = ' ' + load.name + ' (' + load.status + '): ';
+
+ for (var j = 0; j < load.linkSets.length; j++) {
+ linkSetLog += '{' + logloads(load.linkSets[j].loads) + '} ';
+ }
+ console.log(linkSetLog);
+ }
+ console.log('');
+}
+function logloads(loads) {
+ var log = '';
+ for (var k = 0; k < loads.length; k++)
+ log += loads[k].name + (k != loads.length - 1 ? ' ' : '');
+ return log;
+} */
+
+
+/* function checkInvariants() {
+ // see https://bugs.ecmascript.org/show_bug.cgi?id=2603#c1
+
+ var loads = System._loader.loads;
+ var linkSets = [];
+
+ for (var i = 0; i < loads.length; i++) {
+ var load = loads[i];
+ console.assert(load.status == 'loading' || load.status == 'loaded', 'Each load is loading or loaded');
+
+ for (var j = 0; j < load.linkSets.length; j++) {
+ var linkSet = load.linkSets[j];
+
+ for (var k = 0; k < linkSet.loads.length; k++)
+ console.assert(loads.indexOf(linkSet.loads[k]) != -1, 'linkSet loads are a subset of loader loads');
+
+ if (linkSets.indexOf(linkSet) == -1)
+ linkSets.push(linkSet);
+ }
+ }
+
+ for (var i = 0; i < loads.length; i++) {
+ var load = loads[i];
+ for (var j = 0; j < linkSets.length; j++) {
+ var linkSet = linkSets[j];
+
+ if (linkSet.loads.indexOf(load) != -1)
+ console.assert(load.linkSets.indexOf(linkSet) != -1, 'linkSet contains load -> load contains linkSet');
+
+ if (load.linkSets.indexOf(linkSet) != -1)
+ console.assert(linkSet.loads.indexOf(load) != -1, 'load contains linkSet -> linkSet contains load');
+ }
+ }
+
+ for (var i = 0; i < linkSets.length; i++) {
+ var linkSet = linkSets[i];
+ for (var j = 0; j < linkSet.loads.length; j++) {
+ var load = linkSet.loads[j];
+
+ for (var k = 0; k < load.dependencies.length; k++) {
+ var depName = load.dependencies[k].value;
+ var depLoad;
+ for (var l = 0; l < loads.length; l++) {
+ if (loads[l].name != depName)
+ continue;
+ depLoad = loads[l];
+ break;
+ }
+
+ // loading records are allowed not to have their dependencies yet
+ // if (load.status != 'loading')
+ // console.assert(depLoad, 'depLoad found');
+
+ // console.assert(linkSet.loads.indexOf(depLoad) != -1, 'linkset contains all dependencies');
+ }
+ }
+ }
+} */
+
+ // 15.2.3 - Runtime Semantics: Loader State
+
+ // 15.2.3.11
+ function createLoaderLoad(object) {
+ return {
+ // modules is an object for ES5 implementation
+ modules: {},
+ loads: [],
+ loaderObj: object
+ };
+ }
+
+ // 15.2.3.2 Load Records and LoadRequest Objects
+
+ var anonCnt = 0;
+
+ // 15.2.3.2.1
+ function createLoad(name) {
+ return {
+ status: 'loading',
+ name: name || '<Anonymous' + ++anonCnt + '>',
+ linkSets: [],
+ dependencies: [],
+ metadata: {}
+ };
+ }
+
+ // 15.2.3.2.2 createLoadRequestObject, absorbed into calling functions
+
+ // 15.2.4
+
+ // 15.2.4.1
+ function loadModule(loader, name, options) {
+ return new Promise(asyncStartLoadPartwayThrough({
+ step: options.address ? 'fetch' : 'locate',
+ loader: loader,
+ moduleName: name,
+ // allow metadata for import https://bugs.ecmascript.org/show_bug.cgi?id=3091
+ moduleMetadata: options && options.metadata || {},
+ moduleSource: options.source,
+ moduleAddress: options.address
+ }));
+ }
+
+ // 15.2.4.2
+ function requestLoad(loader, request, refererName, refererAddress) {
+ // 15.2.4.2.1 CallNormalize
+ return new Promise(function(resolve, reject) {
+ resolve(loader.loaderObj.normalize(request, refererName, refererAddress));
+ })
+ // 15.2.4.2.2 GetOrCreateLoad
+ .then(function(name) {
+ var load;
+ if (loader.modules[name]) {
+ load = createLoad(name);
+ load.status = 'linked';
+ // https://bugs.ecmascript.org/show_bug.cgi?id=2795
+ load.module = loader.modules[name];
+ return load;
+ }
+
+ for (var i = 0, l = loader.loads.length; i < l; i++) {
+ load = loader.loads[i];
+ if (load.name != name)
+ continue;
+ return load;
+ }
+
+ load = createLoad(name);
+ loader.loads.push(load);
+
+ proceedToLocate(loader, load);
+
+ return load;
+ });
+ }
+
+ // 15.2.4.3
+ function proceedToLocate(loader, load) {
+ proceedToFetch(loader, load,
+ Promise.resolve()
+ // 15.2.4.3.1 CallLocate
+ .then(function() {
+ return loader.loaderObj.locate({ name: load.name, metadata: load.metadata });
+ })
+ );
+ }
+
+ // 15.2.4.4
+ function proceedToFetch(loader, load, p) {
+ proceedToTranslate(loader, load,
+ p
+ // 15.2.4.4.1 CallFetch
+ .then(function(address) {
+ // adjusted, see https://bugs.ecmascript.org/show_bug.cgi?id=2602
+ if (load.status != 'loading')
+ return;
+ load.address = address;
+
+ return loader.loaderObj.fetch({ name: load.name, metadata: load.metadata, address: address });
+ })
+ );
+ }
+
+ // 15.2.4.5
+ function proceedToTranslate(loader, load, p) {
+ p
+ // 15.2.4.5.1 CallTranslate
+ .then(function(source) {
+ if (load.status != 'loading')
+ return;
+
+ load.address = load.address || load.name;
+
+ return Promise.resolve(loader.loaderObj.translate({ name: load.name, metadata: load.metadata, address: load.address, source: source }))
+
+ // 15.2.4.5.2 CallInstantiate
+ .then(function(source) {
+ load.source = source;
+ return loader.loaderObj.instantiate({ name: load.name, metadata: load.metadata, address: load.address, source: source });
+ })
+
+ // 15.2.4.5.3 InstantiateSucceeded
+ .then(function(instantiateResult) {
+ if (instantiateResult === undefined)
+ throw new TypeError('Declarative modules unsupported in the polyfill.');
+
+ if (typeof instantiateResult != 'object')
+ throw new TypeError('Invalid instantiate return value');
+
+ load.depsList = instantiateResult.deps || [];
+ load.execute = instantiateResult.execute;
+ })
+ // 15.2.4.6 ProcessLoadDependencies
+ .then(function() {
+ load.dependencies = [];
+ var depsList = load.depsList;
+
+ var loadPromises = [];
+ for (var i = 0, l = depsList.length; i < l; i++) (function(request, index) {
+ loadPromises.push(
+ requestLoad(loader, request, load.name, load.address)
+
+ // 15.2.4.6.1 AddDependencyLoad (load is parentLoad)
+ .then(function(depLoad) {
+
+ // adjusted from spec to maintain dependency order
+ // this is due to the System.register internal implementation needs
+ load.dependencies[index] = {
+ key: request,
+ value: depLoad.name
+ };
+
+ if (depLoad.status != 'linked') {
+ var linkSets = load.linkSets.concat([]);
+ for (var i = 0, l = linkSets.length; i < l; i++)
+ addLoadToLinkSet(linkSets[i], depLoad);
+ }
+
+ // console.log('AddDependencyLoad ' + depLoad.name + ' for ' + load.name);
+ // snapshot(loader);
+ })
+ );
+ })(depsList[i], i);
+
+ return Promise.all(loadPromises);
+ })
+
+ // 15.2.4.6.2 LoadSucceeded
+ .then(function() {
+ // console.log('LoadSucceeded ' + load.name);
+ // snapshot(loader);
+
+ load.status = 'loaded';
+
+ var linkSets = load.linkSets.concat([]);
+ for (var i = 0, l = linkSets.length; i < l; i++)
+ updateLinkSetOnLoad(linkSets[i], load);
+ });
+ })
+ // 15.2.4.5.4 LoadFailed
+ ['catch'](function(exc) {
+ load.status = 'failed';
+ load.exception = exc;
+
+ var linkSets = load.linkSets.concat([]);
+ for (var i = 0, l = linkSets.length; i < l; i++) {
+ linkSetFailed(linkSets[i], load, exc);
+ }
+
+ console.assert(load.linkSets.length == 0, 'linkSets not removed');
+ });
+ }
+
+ // 15.2.4.7 PromiseOfStartLoadPartwayThrough absorbed into calling functions
+
+ // 15.2.4.7.1
+ function asyncStartLoadPartwayThrough(stepState) {
+ return function(resolve, reject) {
+ var loader = stepState.loader;
+ var name = stepState.moduleName;
+ var step = stepState.step;
+
+ if (loader.modules[name])
+ throw new TypeError('"' + name + '" already exists in the module table');
+
+ // adjusted to pick up existing loads
+ var existingLoad;
+ for (var i = 0, l = loader.loads.length; i < l; i++) {
+ if (loader.loads[i].name == name) {
+ existingLoad = loader.loads[i];
+
+ if (step == 'translate' && !existingLoad.source) {
+ existingLoad.address = stepState.moduleAddress;
+ proceedToTranslate(loader, existingLoad, Promise.resolve(stepState.moduleSource));
+ }
+
+ // a primary load -> use that existing linkset if it is for the direct load here
+ // otherwise create a new linkset unit
+ if (existingLoad.linkSets.length && existingLoad.linkSets[0].loads[0].name == existingLoad.name)
+ return existingLoad.linkSets[0].done.then(function() {
+ resolve(existingLoad);
+ });
+ }
+ }
+
+ var load = existingLoad || createLoad(name);
+
+ load.metadata = stepState.moduleMetadata;
+
+ var linkSet = createLinkSet(loader, load);
+
+ loader.loads.push(load);
+
+ resolve(linkSet.done);
+
+ if (step == 'locate')
+ proceedToLocate(loader, load);
+
+ else if (step == 'fetch')
+ proceedToFetch(loader, load, Promise.resolve(stepState.moduleAddress));
+
+ else {
+ console.assert(step == 'translate', 'translate step');
+ load.address = stepState.moduleAddress;
+ proceedToTranslate(loader, load, Promise.resolve(stepState.moduleSource));
+ }
+ }
+ }
+
+ // Declarative linking functions run through alternative implementation:
+ // 15.2.5.1.1 CreateModuleLinkageRecord not implemented
+ // 15.2.5.1.2 LookupExport not implemented
+ // 15.2.5.1.3 LookupModuleDependency not implemented
+
+ // 15.2.5.2.1
+ function createLinkSet(loader, startingLoad) {
+ var linkSet = {
+ loader: loader,
+ loads: [],
+ startingLoad: startingLoad, // added see spec bug https://bugs.ecmascript.org/show_bug.cgi?id=2995
+ loadingCount: 0
+ };
+ linkSet.done = new Promise(function(resolve, reject) {
+ linkSet.resolve = resolve;
+ linkSet.reject = reject;
+ });
+ addLoadToLinkSet(linkSet, startingLoad);
+ return linkSet;
+ }
+ // 15.2.5.2.2
+ function addLoadToLinkSet(linkSet, load) {
+ if (load.status == 'failed')
+ return;
+
+ for (var i = 0, l = linkSet.loads.length; i < l; i++)
+ if (linkSet.loads[i] == load)
+ return;
+
+ linkSet.loads.push(load);
+ load.linkSets.push(linkSet);
+
+ // adjustment, see https://bugs.ecmascript.org/show_bug.cgi?id=2603
+ if (load.status != 'loaded') {
+ linkSet.loadingCount++;
+ }
+
+ var loader = linkSet.loader;
+
+ for (var i = 0, l = load.dependencies.length; i < l; i++) {
+ if (!load.dependencies[i])
+ continue;
+
+ var name = load.dependencies[i].value;
+
+ if (loader.modules[name])
+ continue;
+
+ for (var j = 0, d = loader.loads.length; j < d; j++) {
+ if (loader.loads[j].name != name)
+ continue;
+
+ addLoadToLinkSet(linkSet, loader.loads[j]);
+ break;
+ }
+ }
+ // console.log('add to linkset ' + load.name);
+ // snapshot(linkSet.loader);
+ }
+
+ // linking errors can be generic or load-specific
+ // this is necessary for debugging info
+ function doLink(linkSet) {
+ var error = false;
+ try {
+ link(linkSet, function(load, exc) {
+ linkSetFailed(linkSet, load, exc);
+ error = true;
+ });
+ }
+ catch(e) {
+ linkSetFailed(linkSet, null, e);
+ error = true;
+ }
+ return error;
+ }
+
+ // 15.2.5.2.3
+ function updateLinkSetOnLoad(linkSet, load) {
+ // console.log('update linkset on load ' + load.name);
+ // snapshot(linkSet.loader);
+
+ console.assert(load.status == 'loaded' || load.status == 'linked', 'loaded or linked');
+
+ linkSet.loadingCount--;
+
+ if (linkSet.loadingCount > 0)
+ return;
+
+ // adjusted for spec bug https://bugs.ecmascript.org/show_bug.cgi?id=2995
+ var startingLoad = linkSet.startingLoad;
+
+ // non-executing link variation for loader tracing
+ // on the server. Not in spec.
+ /***/
+ if (linkSet.loader.loaderObj.execute === false) {
+ var loads = [].concat(linkSet.loads);
+ for (var i = 0, l = loads.length; i < l; i++) {
+ var load = loads[i];
+ load.module = {
+ name: load.name,
+ module: _newModule({}),
+ evaluated: true
+ };
+ load.status = 'linked';
+ finishLoad(linkSet.loader, load);
+ }
+ return linkSet.resolve(startingLoad);
+ }
+ /***/
+
+ var abrupt = doLink(linkSet);
+
+ if (abrupt)
+ return;
+
+ console.assert(linkSet.loads.length == 0, 'loads cleared');
+
+ linkSet.resolve(startingLoad);
+ }
+
+ // 15.2.5.2.4
+ function linkSetFailed(linkSet, load, exc) {
+ var loader = linkSet.loader;
+ var requests;
+
+ checkError:
+ if (load) {
+ if (linkSet.loads[0].name == load.name) {
+ exc = addToError(exc, 'Error loading ' + load.name);
+ }
+ else {
+ for (var i = 0; i < linkSet.loads.length; i++) {
+ var pLoad = linkSet.loads[i];
+ for (var j = 0; j < pLoad.dependencies.length; j++) {
+ var dep = pLoad.dependencies[j];
+ if (dep.value == load.name) {
+ exc = addToError(exc, 'Error loading ' + load.name + ' as "' + dep.key + '" from ' + pLoad.name);
+ break checkError;
+ }
+ }
+ }
+ exc = addToError(exc, 'Error loading ' + load.name + ' from ' + linkSet.loads[0].name);
+ }
+ }
+ else {
+ exc = addToError(exc, 'Error linking ' + linkSet.loads[0].name);
+ }
+
+
+ var loads = linkSet.loads.concat([]);
+ for (var i = 0, l = loads.length; i < l; i++) {
+ var load = loads[i];
+
+ // store all failed load records
+ loader.loaderObj.failed = loader.loaderObj.failed || [];
+ if (indexOf.call(loader.loaderObj.failed, load) == -1)
+ loader.loaderObj.failed.push(load);
+
+ var linkIndex = indexOf.call(load.linkSets, linkSet);
+ console.assert(linkIndex != -1, 'link not present');
+ load.linkSets.splice(linkIndex, 1);
+ if (load.linkSets.length == 0) {
+ var globalLoadsIndex = indexOf.call(linkSet.loader.loads, load);
+ if (globalLoadsIndex != -1)
+ linkSet.loader.loads.splice(globalLoadsIndex, 1);
+ }
+ }
+ linkSet.reject(exc);
+ }
+
+ // 15.2.5.2.5
+ function finishLoad(loader, load) {
+ // add to global trace if tracing
+ if (loader.loaderObj.trace) {
+ if (!loader.loaderObj.loads)
+ loader.loaderObj.loads = {};
+ var depMap = {};
+ load.dependencies.forEach(function(dep) {
+ depMap[dep.key] = dep.value;
+ });
+ loader.loaderObj.loads[load.name] = {
+ name: load.name,
+ deps: load.dependencies.map(function(dep){ return dep.key }),
+ depMap: depMap,
+ address: load.address,
+ metadata: load.metadata,
+ source: load.source
+ };
+ }
+ // if not anonymous, add to the module table
+ if (load.name) {
+ console.assert(!loader.modules[load.name] || loader.modules[load.name].module === load.module.module, 'load not in module table');
+ loader.modules[load.name] = load.module;
+ }
+ var loadIndex = indexOf.call(loader.loads, load);
+ if (loadIndex != -1)
+ loader.loads.splice(loadIndex, 1);
+ for (var i = 0, l = load.linkSets.length; i < l; i++) {
+ loadIndex = indexOf.call(load.linkSets[i].loads, load);
+ if (loadIndex != -1)
+ load.linkSets[i].loads.splice(loadIndex, 1);
+ }
+ load.linkSets.splice(0, load.linkSets.length);
+ }
+
+ function doDynamicExecute(linkSet, load, linkError) {
+ try {
+ var module = load.execute();
+ }
+ catch(e) {
+ linkError(load, e);
+ return;
+ }
+ if (!module || !(module instanceof Module))
+ linkError(load, new TypeError('Execution must define a Module instance'));
+ else
+ return module;
+ }
+
+ // 26.3 Loader
+
+ // 26.3.1.1
+ // defined at top
+
+ // importPromises adds ability to import a module twice without error - https://bugs.ecmascript.org/show_bug.cgi?id=2601
+ function createImportPromise(loader, name, promise) {
+ var importPromises = loader._loader.importPromises;
+ return importPromises[name] = promise.then(function(m) {
+ importPromises[name] = undefined;
+ return m;
+ }, function(e) {
+ importPromises[name] = undefined;
+ throw e;
+ });
+ }
+
+ Loader.prototype = {
+ // 26.3.3.1
+ constructor: Loader,
+ // 26.3.3.2
+ define: function(name, source, options) {
+ // check if already defined
+ if (this._loader.importPromises[name])
+ throw new TypeError('Module is already loading.');
+ return createImportPromise(this, name, new Promise(asyncStartLoadPartwayThrough({
+ step: 'translate',
+ loader: this._loader,
+ moduleName: name,
+ moduleMetadata: options && options.metadata || {},
+ moduleSource: source,
+ moduleAddress: options && options.address
+ })));
+ },
+ // 26.3.3.3
+ 'delete': function(name) {
+ var loader = this._loader;
+ delete loader.importPromises[name];
+ delete loader.moduleRecords[name];
+ return loader.modules[name] ? delete loader.modules[name] : false;
+ },
+ // 26.3.3.4 entries not implemented
+ // 26.3.3.5
+ get: function(key) {
+ if (!this._loader.modules[key])
+ return;
+ return this._loader.modules[key].module;
+ },
+ // 26.3.3.7
+ has: function(name) {
+ return !!this._loader.modules[name];
+ },
+ // 26.3.3.8
+ 'import': function(name, parentName, parentAddress) {
+ if (typeof parentName == 'object')
+ parentName = parentName.name;
+
+ // run normalize first
+ var loaderObj = this;
+
+ // added, see https://bugs.ecmascript.org/show_bug.cgi?id=2659
+ return Promise.resolve(loaderObj.normalize(name, parentName))
+ .then(function(name) {
+ var loader = loaderObj._loader;
+
+ if (loader.modules[name])
+ return loader.modules[name].module;
+
+ return loader.importPromises[name] || createImportPromise(loaderObj, name,
+ loadModule(loader, name, {})
+ .then(function(load) {
+ delete loader.importPromises[name];
+ return load.module.module;
+ }));
+ });
+ },
+ // 26.3.3.9 keys not implemented
+ // 26.3.3.10
+ load: function(name) {
+ var loader = this._loader;
+ if (loader.modules[name])
+ return Promise.resolve();
+ return loader.importPromises[name] || createImportPromise(this, name, new Promise(asyncStartLoadPartwayThrough({
+ step: 'locate',
+ loader: loader,
+ moduleName: name,
+ moduleMetadata: {},
+ moduleSource: undefined,
+ moduleAddress: undefined
+ }))
+ .then(function() {
+ delete loader.importPromises[name];
+ }));
+ },
+ // 26.3.3.11
+ module: function(source, options) {
+ var load = createLoad();
+ load.address = options && options.address;
+ var linkSet = createLinkSet(this._loader, load);
+ var sourcePromise = Promise.resolve(source);
+ var loader = this._loader;
+ var p = linkSet.done.then(function() {
+ return load.module.module;
+ });
+ proceedToTranslate(loader, load, sourcePromise);
+ return p;
+ },
+ // 26.3.3.12
+ newModule: function (obj) {
+ if (typeof obj != 'object')
+ throw new TypeError('Expected object');
+
+ var m = new Module();
+
+ var pNames = [];
+ if (Object.getOwnPropertyNames && obj != null)
+ pNames = Object.getOwnPropertyNames(obj);
+ else
+ for (var key in obj)
+ pNames.push(key);
+
+ for (var i = 0; i < pNames.length; i++) (function(key) {
+ defineProperty(m, key, {
+ configurable: false,
+ enumerable: true,
+ get: function () {
+ return obj[key];
+ },
+ set: function() {
+ throw new Error('Module exports cannot be changed externally.');
+ }
+ });
+ })(pNames[i]);
+
+ if (Object.freeze)
+ Object.freeze(m);
+
+ return m;
+ },
+ // 26.3.3.14
+ set: function(name, module) {
+ if (!(module instanceof Module))
+ throw new TypeError('Loader.set(' + name + ', module) must be a module');
+ this._loader.modules[name] = {
+ module: module
+ };
+ },
+ // 26.3.3.15 values not implemented
+ // 26.3.3.16 @@iterator not implemented
+ // 26.3.3.17 @@toStringTag not implemented
+
+ // 26.3.3.18.1
+ normalize: function(name, referrerName, referrerAddress) {},
+ // 26.3.3.18.2
+ locate: function(load) {
+ return load.name;
+ },
+ // 26.3.3.18.3
+ fetch: function(load) {
+ },
+ // 26.3.3.18.4
+ translate: function(load) {
+ return load.source;
+ },
+ // 26.3.3.18.5
+ instantiate: function(load) {
+ }
+ };
+
+ var _newModule = Loader.prototype.newModule;
+
+/*
+ * ES6 Module Declarative Linking Code
+ */
+ function link(linkSet, linkError) {
+
+ var loader = linkSet.loader;
+
+ if (!linkSet.loads.length)
+ return;
+
+ var loads = linkSet.loads.concat([]);
+
+ for (var i = 0; i < loads.length; i++) {
+ var load = loads[i];
+
+ var module = doDynamicExecute(linkSet, load, linkError);
+ if (!module)
+ return;
+ load.module = {
+ name: load.name,
+ module: module
+ };
+ load.status = 'linked';
+
+ finishLoad(loader, load);
+ }
+ }
+
+})();
+
+var System;
+
+// SystemJS Loader Class and Extension helpers
+function SystemJSLoader() {
+ Loader.call(this);
+
+ this.paths = {};
+ this._loader.paths = {};
+
+ systemJSConstructor.call(this);
+}
+
+// inline Object.create-style class extension
+function SystemProto() {};
+SystemProto.prototype = Loader.prototype;
+SystemJSLoader.prototype = new SystemProto();
+SystemJSLoader.prototype.constructor = SystemJSLoader;
+
+var systemJSConstructor;
+
+function hook(name, hook) {
+ SystemJSLoader.prototype[name] = hook(SystemJSLoader.prototype[name] || function() {});
+}
+function hookConstructor(hook) {
+ systemJSConstructor = hook(systemJSConstructor || function() {});
+}
+
+
+var absURLRegEx = /^[^\/]+:\/\//;
+function isAbsolute(name) {
+ return name.match(absURLRegEx);
+}
+function isRel(name) {
+ return (name[0] == '.' && (!name[1] || name[1] == '/' || name[1] == '.')) || name[0] == '/';
+}
+function isPlain(name) {
+ return !isRel(name) && !isAbsolute(name);
+}
+
+var baseURIObj = new URL(baseURI);
+
+function urlResolve(name, parent) {
+ // url resolution shortpaths
+ if (name[0] == '.') {
+ // dot-relative url normalization
+ if (name[1] == '/' && name[2] != '.')
+ return (parent && parent.substr(0, parent.lastIndexOf('/') + 1) || baseURI) + name.substr(2);
+ }
+ else if (name[0] != '/' && name.indexOf(':') == -1) {
+ // plain parent normalization
+ return (parent && parent.substr(0, parent.lastIndexOf('/') + 1) || baseURI) + name;
+ }
+
+ return new URL(name, parent && parent.replace(/#/g, '%05') || baseURIObj).href.replace(/%05/g, '#');
+}
+
+// NB no specification provided for System.paths, used ideas discussed in https://github.com/jorendorff/js-loaders/issues/25
+function applyPaths(loader, name) {
+ // most specific (most number of slashes in path) match wins
+ var pathMatch = '', wildcard, maxWildcardPrefixLen = 0;
+
+ var paths = loader.paths;
+ var pathsCache = loader._loader.paths;
+
+ // check to see if we have a paths entry
+ for (var p in paths) {
+ if (paths.hasOwnProperty && !paths.hasOwnProperty(p))
+ continue;
+
+ // paths sanitization
+ var path = paths[p];
+ if (path !== pathsCache[p])
+ path = paths[p] = pathsCache[p] = urlResolve(paths[p], isRel(paths[p]) ? baseURI : loader.baseURL);
+
+ // exact path match
+ if (p.indexOf('*') === -1) {
+ if (name == p)
+ return paths[p];
+
+ // support trailing / in paths rules
+ else if (name.substr(0, p.length - 1) == p.substr(0, p.length - 1) && (name.length < p.length || name[p.length - 1] == p[p.length - 1]) && (paths[p][paths[p].length - 1] == '/' || paths[p] == '')) {
+ return paths[p].substr(0, paths[p].length - 1) + (name.length > p.length ? (paths[p] && '/' || '') + name.substr(p.length) : '');
+ }
+ }
+ // wildcard path match
+ else {
+ var pathParts = p.split('*');
+ if (pathParts.length > 2)
+ throw new TypeError('Only one wildcard in a path is permitted');
+
+ var wildcardPrefixLen = pathParts[0].length;
+ if (wildcardPrefixLen >= maxWildcardPrefixLen &&
+ name.substr(0, pathParts[0].length) == pathParts[0] &&
+ name.substr(name.length - pathParts[1].length) == pathParts[1]) {
+ maxWildcardPrefixLen = wildcardPrefixLen;
+ pathMatch = p;
+ wildcard = name.substr(pathParts[0].length, name.length - pathParts[1].length - pathParts[0].length);
+ }
+ }
+ }
+
+ var outPath = paths[pathMatch];
+ if (typeof wildcard == 'string')
+ outPath = outPath.replace('*', wildcard);
+
+ return outPath;
+}
+
+function dedupe(deps) {
+ var newDeps = [];
+ for (var i = 0, l = deps.length; i < l; i++)
+ if (indexOf.call(newDeps, deps[i]) == -1)
+ newDeps.push(deps[i])
+ return newDeps;
+}
+
+function group(deps) {
+ var names = [];
+ var indices = [];
+ for (var i = 0, l = deps.length; i < l; i++) {
+ var index = indexOf.call(names, deps[i]);
+ if (index === -1) {
+ names.push(deps[i]);
+ indices.push([i]);
+ }
+ else {
+ indices[index].push(i);
+ }
+ }
+ return { names: names, indices: indices };
+}
+
+var getOwnPropertyDescriptor = true;
+try {
+ Object.getOwnPropertyDescriptor({ a: 0 }, 'a');
+}
+catch(e) {
+ getOwnPropertyDescriptor = false;
+}
+
+// converts any module.exports object into an object ready for SystemJS.newModule
+function getESModule(exports) {
+ var esModule = {};
+ // don't trigger getters/setters in environments that support them
+ if ((typeof exports == 'object' || typeof exports == 'function') && exports !== __global) {
+ if (getOwnPropertyDescriptor) {
+ for (var p in exports) {
+ // The default property is copied to esModule later on
+ if (p === 'default')
+ continue;
+ defineOrCopyProperty(esModule, exports, p);
+ }
+ }
+ else {
+ extend(esModule, exports);
+ }
+ }
+ esModule['default'] = exports;
+ defineProperty(esModule, '__useDefault', {
+ value: true
+ });
+ return esModule;
+}
+
+function defineOrCopyProperty(targetObj, sourceObj, propName) {
+ try {
+ var d;
+ if (d = Object.getOwnPropertyDescriptor(sourceObj, propName))
+ defineProperty(targetObj, propName, d);
+ }
+ catch (ex) {
+ // Object.getOwnPropertyDescriptor threw an exception, fall back to normal set property
+ // we dont need hasOwnProperty here because getOwnPropertyDescriptor would have returned undefined above
+ targetObj[propName] = sourceObj[propName];
+ return false;
+ }
+}
+
+function extend(a, b, prepend) {
+ var hasOwnProperty = b && b.hasOwnProperty;
+ for (var p in b) {
+ if (hasOwnProperty && !b.hasOwnProperty(p))
+ continue;
+ if (!prepend || !(p in a))
+ a[p] = b[p];
+ }
+ return a;
+}
+
+// meta first-level extends where:
+// array + array appends
+// object + object extends
+// other properties replace
+function extendMeta(a, b, prepend) {
+ var hasOwnProperty = b && b.hasOwnProperty;
+ for (var p in b) {
+ if (hasOwnProperty && !b.hasOwnProperty(p))
+ continue;
+ var val = b[p];
+ if (!(p in a))
+ a[p] = val;
+ else if (val instanceof Array && a[p] instanceof Array)
+ a[p] = [].concat(prepend ? val : a[p]).concat(prepend ? a[p] : val);
+ else if (typeof val == 'object' && val !== null && typeof a[p] == 'object')
+ a[p] = extend(extend({}, a[p]), val, prepend);
+ else if (!prepend)
+ a[p] = val;
+ }
+}
+
+function extendPkgConfig(pkgCfgA, pkgCfgB, pkgName, loader, warnInvalidProperties) {
+ for (var prop in pkgCfgB) {
+ if (indexOf.call(['main', 'format', 'defaultExtension', 'basePath'], prop) != -1) {
+ pkgCfgA[prop] = pkgCfgB[prop];
+ }
+ else if (prop == 'map') {
+ extend(pkgCfgA.map = pkgCfgA.map || {}, pkgCfgB.map);
+ }
+ else if (prop == 'meta') {
+ extend(pkgCfgA.meta = pkgCfgA.meta || {}, pkgCfgB.meta);
+ }
+ else if (prop == 'depCache') {
+ for (var d in pkgCfgB.depCache) {
+ var dNormalized;
+
+ if (d.substr(0, 2) == './')
+ dNormalized = pkgName + '/' + d.substr(2);
+ else
+ dNormalized = coreResolve.call(loader, d);
+ loader.depCache[dNormalized] = (loader.depCache[dNormalized] || []).concat(pkgCfgB.depCache[d]);
+ }
+ }
+ else if (warnInvalidProperties && indexOf.call(['browserConfig', 'nodeConfig', 'devConfig', 'productionConfig'], prop) == -1 &&
+ (!pkgCfgB.hasOwnProperty || pkgCfgB.hasOwnProperty(prop))) {
+ warn.call(loader, '"' + prop + '" is not a valid package configuration option in package ' + pkgName);
+ }
+ }
+}
+
+// deeply-merge (to first level) config with any existing package config
+function setPkgConfig(loader, pkgName, cfg, prependConfig) {
+ var pkg;
+
+ // first package is config by reference for fast path, cloned after that
+ if (!loader.packages[pkgName]) {
+ pkg = loader.packages[pkgName] = cfg;
+ }
+ else {
+ var basePkg = loader.packages[pkgName];
+ pkg = loader.packages[pkgName] = {};
+
+ extendPkgConfig(pkg, prependConfig ? cfg : basePkg, pkgName, loader, prependConfig);
+ extendPkgConfig(pkg, prependConfig ? basePkg : cfg, pkgName, loader, !prependConfig);
+ }
+
+ // main object becomes main map
+ if (typeof pkg.main == 'object') {
+ pkg.map = pkg.map || {};
+ pkg.map['./@main'] = pkg.main;
+ pkg.main['default'] = pkg.main['default'] || './';
+ pkg.main = '@main';
+ }
+
+ return pkg;
+}
+
+function warn(msg) {
+ if (this.warnings && typeof console != 'undefined' && console.warn)
+ console.warn(msg);
+}
+ var fetchTextFromURL;
+ if (typeof XMLHttpRequest != 'undefined') {
+ fetchTextFromURL = function(url, authorization, fulfill, reject) {
+ var xhr = new XMLHttpRequest();
+ var sameDomain = true;
+ var doTimeout = false;
+ if (!('withCredentials' in xhr)) {
+ // check if same domain
+ var domainCheck = /^(\w+:)?\/\/([^\/]+)/.exec(url);
+ if (domainCheck) {
+ sameDomain = domainCheck[2] === window.location.host;
+ if (domainCheck[1])
+ sameDomain &= domainCheck[1] === window.location.protocol;
+ }
+ }
+ if (!sameDomain && typeof XDomainRequest != 'undefined') {
+ xhr = new XDomainRequest();
+ xhr.onload = load;
+ xhr.onerror = error;
+ xhr.ontimeout = error;
+ xhr.onprogress = function() {};
+ xhr.timeout = 0;
+ doTimeout = true;
+ }
+ function load() {
+ fulfill(xhr.responseText);
+ }
+ function error() {
+ reject(new Error('XHR error' + (xhr.status ? ' (' + xhr.status + (xhr.statusText ? ' ' + xhr.statusText : '') + ')' : '') + ' loading ' + url));
+ }
+
+ xhr.onreadystatechange = function () {
+ if (xhr.readyState === 4) {
+ // in Chrome on file:/// URLs, status is 0
+ if (xhr.status == 0) {
+ if (xhr.responseText) {
+ load();
+ }
+ else {
+ // when responseText is empty, wait for load or error event
+ // to inform if it is a 404 or empty file
+ xhr.addEventListener('error', error);
+ xhr.addEventListener('load', load);
+ }
+ }
+ else if (xhr.status === 200) {
+ load();
+ }
+ else {
+ error();
+ }
+ }
+ };
+ xhr.open("GET", url, true);
+
+ if (xhr.setRequestHeader) {
+ xhr.setRequestHeader('Accept', 'application/x-es-module, */*');
+ // can set "authorization: true" to enable withCredentials only
+ if (authorization) {
+ if (typeof authorization == 'string')
+ xhr.setRequestHeader('Authorization', authorization);
+ xhr.withCredentials = true;
+ }
+ }
+
+ if (doTimeout) {
+ setTimeout(function() {
+ xhr.send();
+ }, 0);
+ } else {
+ xhr.send(null);
+ }
+ };
+ }
+ else if (typeof require != 'undefined' && typeof process != 'undefined') {
+ var fs;
+ fetchTextFromURL = function(url, authorization, fulfill, reject) {
+ if (url.substr(0, 8) != 'file:///')
+ throw new Error('Unable to fetch "' + url + '". Only file URLs of the form file:/// allowed running in Node.');
+ fs = fs || require('fs');
+ if (isWindows)
+ url = url.replace(/\//g, '\\').substr(8);
+ else
+ url = url.substr(7);
+ return fs.readFile(url, function(err, data) {
+ if (err) {
+ return reject(err);
+ }
+ else {
+ // Strip Byte Order Mark out if it's the leading char
+ var dataString = data + '';
+ if (dataString[0] === '\ufeff')
+ dataString = dataString.substr(1);
+
+ fulfill(dataString);
+ }
+ });
+ };
+ }
+ else if (typeof self != 'undefined' && typeof self.fetch != 'undefined') {
+ fetchTextFromURL = function(url, authorization, fulfill, reject) {
+ var opts = {
+ headers: {'Accept': 'application/x-es-module, */*'}
+ };
+
+ if (authorization) {
+ if (typeof authorization == 'string')
+ opts.headers['Authorization'] = authorization;
+ opts.credentials = 'include';
+ }
+
+ fetch(url, opts)
+ .then(function (r) {
+ if (r.ok) {
+ return r.text();
+ } else {
+ throw new Error('Fetch error: ' + r.status + ' ' + r.statusText);
+ }
+ })
+ .then(fulfill, reject);
+ }
+ }
+ else {
+ throw new TypeError('No environment fetch API available.');
+ }
+function readMemberExpression(p, value) {
+ var pParts = p.split('.');
+ while (pParts.length)
+ value = value[pParts.shift()];
+ return value;
+}
+
+function getMapMatch(map, name) {
+ var bestMatch, bestMatchLength = 0;
+
+ for (var p in map) {
+ if (name.substr(0, p.length) == p && (name.length == p.length || name[p.length] == '/')) {
+ var curMatchLength = p.split('/').length;
+ if (curMatchLength <= bestMatchLength)
+ continue;
+ bestMatch = p;
+ bestMatchLength = curMatchLength;
+ }
+ }
+
+ return bestMatch;
+}
+
+function prepareBaseURL(loader) {
+ // ensure baseURl is fully normalized
+ if (this._loader.baseURL !== this.baseURL) {
+ if (this.baseURL[this.baseURL.length - 1] != '/')
+ this.baseURL += '/';
+
+ this._loader.baseURL = this.baseURL = new URL(this.baseURL, baseURIObj).href;
+ }
+}
+
+var envModule;
+function setProduction(isProduction, isBuilder) {
+ this.set('@system-env', envModule = this.newModule({
+ browser: isBrowser,
+ node: !!this._nodeRequire,
+ production: !isBuilder && isProduction,
+ dev: isBuilder || !isProduction,
+ build: isBuilder,
+ 'default': true
+ }));
+}
+
+hookConstructor(function(constructor) {
+ return function() {
+ constructor.call(this);
+
+ // support baseURL
+ this.baseURL = baseURI;
+
+ // support map and paths
+ this.map = {};
+
+ // make the location of the system.js script accessible
+ if (typeof $__curScript != 'undefined')
+ this.scriptSrc = $__curScript.src;
+
+ // global behaviour flags
+ this.warnings = false;
+ this.defaultJSExtensions = false;
+ this.pluginFirst = false;
+ this.loaderErrorStack = false;
+
+ // by default load ".json" files as json
+ // leading * meta doesn't need normalization
+ // NB add this in next breaking release
+ // this.meta['*.json'] = { format: 'json' };
+
+ // support the empty module, as a concept
+ this.set('@empty', this.newModule({}));
+
+ setProduction.call(this, false, false);
+ };
+});
+
+// include the node require since we're overriding it
+if (typeof require != 'undefined' && typeof process != 'undefined' && !process.browser)
+ SystemJSLoader.prototype._nodeRequire = require;
+
+/*
+ Core SystemJS Normalization
+
+ If a name is relative, we apply URL normalization to the page
+ If a name is an absolute URL, we leave it as-is
+
+ Plain names (neither of the above) run through the map and paths
+ normalization phases.
+
+ The paths normalization phase applies last (paths extension), which
+ defines the `decanonicalize` function and normalizes everything into
+ a URL.
+ */
+
+var parentModuleContext;
+function getNodeModule(name, baseURL) {
+ if (!isPlain(name))
+ throw new Error('Node module ' + name + ' can\'t be loaded as it is not a package require.');
+
+ if (!parentModuleContext) {
+ var Module = this._nodeRequire('module');
+ var base = baseURL.substr(isWindows ? 8 : 7);
+ parentModuleContext = new Module(base);
+ parentModuleContext.paths = Module._nodeModulePaths(base);
+ }
+ return parentModuleContext.require(name);
+}
+
+function coreResolve(name, parentName) {
+ // standard URL resolution
+ if (isRel(name))
+ return urlResolve(name, parentName);
+ else if (isAbsolute(name))
+ return name;
+
+ // plain names not starting with './', '://' and '/' go through custom resolution
+ var mapMatch = getMapMatch(this.map, name);
+
+ if (mapMatch) {
+ name = this.map[mapMatch] + name.substr(mapMatch.length);
+
+ if (isRel(name))
+ return urlResolve(name);
+ else if (isAbsolute(name))
+ return name;
+ }
+
+ if (this.has(name))
+ return name;
+
+ // dynamically load node-core modules when requiring `@node/fs` for example
+ if (name.substr(0, 6) == '@node/') {
+ if (!this._nodeRequire)
+ throw new TypeError('Error loading ' + name + '. Can only load node core modules in Node.');
+ if (this.builder)
+ this.set(name, this.newModule({}));
+ else
+ this.set(name, this.newModule(getESModule(getNodeModule.call(this, name.substr(6), this.baseURL))));
+ return name;
+ }
+
+ // prepare the baseURL to ensure it is normalized
+ prepareBaseURL.call(this);
+
+ return applyPaths(this, name) || this.baseURL + name;
+}
+
+hook('normalize', function(normalize) {
+ return function(name, parentName, skipExt) {
+ var resolved = coreResolve.call(this, name, parentName);
+ if (this.defaultJSExtensions && !skipExt && resolved.substr(resolved.length - 3, 3) != '.js' && !isPlain(resolved))
+ resolved += '.js';
+ return resolved;
+ };
+});
+
+// percent encode just '#' in urls if using HTTP requests
+var httpRequest = typeof XMLHttpRequest != 'undefined';
+hook('locate', function(locate) {
+ return function(load) {
+ return Promise.resolve(locate.call(this, load))
+ .then(function(address) {
+ if (httpRequest)
+ return address.replace(/#/g, '%23');
+ return address;
+ });
+ };
+});
+
+/*
+ * Fetch with authorization
+ */
+hook('fetch', function() {
+ return function(load) {
+ return new Promise(function(resolve, reject) {
+ fetchTextFromURL(load.address, load.metadata.authorization, resolve, reject);
+ });
+ };
+});
+
+/*
+ __useDefault
+
+ When a module object looks like:
+ newModule(
+ __useDefault: true,
+ default: 'some-module'
+ })
+
+ Then importing that module provides the 'some-module'
+ result directly instead of the full module.
+
+ Useful for eg module.exports = function() {}
+*/
+hook('import', function(systemImport) {
+ return function(name, parentName, parentAddress) {
+ if (parentName && parentName.name)
+ warn.call(this, 'SystemJS.import(name, { name: parentName }) is deprecated for SystemJS.import(name, parentName), while importing ' + name + ' from ' + parentName.name);
+ return systemImport.call(this, name, parentName, parentAddress).then(function(module) {
+ return module.__useDefault ? module['default'] : module;
+ });
+ };
+});
+
+/*
+ * Allow format: 'detect' meta to enable format detection
+ */
+hook('translate', function(systemTranslate) {
+ return function(load) {
+ if (load.metadata.format == 'detect')
+ load.metadata.format = undefined;
+ return systemTranslate.apply(this, arguments);
+ };
+});
+
+
+/*
+ * JSON format support
+ *
+ * Supports loading JSON files as a module format itself
+ *
+ * Usage:
+ *
+ * SystemJS.config({
+ * meta: {
+ * '*.json': { format: 'json' }
+ * }
+ * });
+ *
+ * Module is returned as if written:
+ *
+ * export default {JSON}
+ *
+ * No named exports are provided
+ *
+ * Files ending in ".json" are treated as json automatically by SystemJS
+ */
+hook('instantiate', function(instantiate) {
+ return function(load) {
+ if (load.metadata.format == 'json' && !this.builder) {
+ var entry = load.metadata.entry = createEntry();
+ entry.deps = [];
+ entry.execute = function() {
+ try {
+ return JSON.parse(load.source);
+ }
+ catch(e) {
+ throw new Error("Invalid JSON file " + load.name);
+ }
+ };
+ }
+ };
+})
+
+/*
+ Extend config merging one deep only
+
+ loader.config({
+ some: 'random',
+ config: 'here',
+ deep: {
+ config: { too: 'too' }
+ }
+ });
+
+ <=>
+
+ loader.some = 'random';
+ loader.config = 'here'
+ loader.deep = loader.deep || {};
+ loader.deep.config = { too: 'too' };
+
+
+ Normalizes meta and package configs allowing for:
+
+ SystemJS.config({
+ meta: {
+ './index.js': {}
+ }
+ });
+
+ To become
+
+ SystemJS.meta['https://thissite.com/index.js'] = {};
+
+ For easy normalization canonicalization with latest URL support.
+
+*/
+function envSet(loader, cfg, envCallback) {
+ if (envModule.browser && cfg.browserConfig)
+ envCallback(cfg.browserConfig);
+ if (envModule.node && cfg.nodeConfig)
+ envCallback(cfg.nodeConfig);
+ if (envModule.dev && cfg.devConfig)
+ envCallback(cfg.devConfig);
+ if (envModule.build && cfg.buildConfig)
+ envCallback(cfg.buildConfig);
+ if (envModule.production && cfg.productionConfig)
+ envCallback(cfg.productionConfig);
+}
+
+SystemJSLoader.prototype.getConfig = function(name) {
+ var cfg = {};
+ var loader = this;
+ for (var p in loader) {
+ if (loader.hasOwnProperty && !loader.hasOwnProperty(p) || p in SystemJSLoader.prototype && p != 'transpiler')
+ continue;
+ if (indexOf.call(['_loader', 'amdDefine', 'amdRequire', 'defined', 'failed', 'version', 'loads'], p) == -1)
+ cfg[p] = loader[p];
+ }
+ cfg.production = envModule.production;
+ return cfg;
+};
+
+var curCurScript;
+SystemJSLoader.prototype.config = function(cfg, isEnvConfig) {
+ var loader = this;
+
+ if ('loaderErrorStack' in cfg) {
+ curCurScript = $__curScript;
+ if (cfg.loaderErrorStack)
+ $__curScript = undefined;
+ else
+ $__curScript = curCurScript;
+ }
+
+ if ('warnings' in cfg)
+ loader.warnings = cfg.warnings;
+
+ // transpiler deprecation path
+ if (cfg.transpilerRuntime === false)
+ loader._loader.loadedTranspilerRuntime = true;
+
+ if ('production' in cfg || 'build' in cfg)
+ setProduction.call(loader, !!cfg.production, !!(cfg.build || envModule && envModule.build));
+
+ if (!isEnvConfig) {
+ // if using nodeConfig / browserConfig / productionConfig, take baseURL from there
+ // these exceptions will be unnecessary when we can properly implement config queuings
+ var baseURL;
+ envSet(loader, cfg, function(cfg) {
+ baseURL = baseURL || cfg.baseURL;
+ });
+ baseURL = baseURL || cfg.baseURL;
+
+ // always configure baseURL first
+ if (baseURL) {
+ var hasConfig = false;
+ function checkHasConfig(obj) {
+ for (var p in obj)
+ if (obj.hasOwnProperty(p))
+ return true;
+ }
+ if (checkHasConfig(loader.packages) || checkHasConfig(loader.meta) || checkHasConfig(loader.depCache) || checkHasConfig(loader.bundles) || checkHasConfig(loader.packageConfigPaths))
+ throw new TypeError('Incorrect configuration order. The baseURL must be configured with the first SystemJS.config call.');
+
+ this.baseURL = baseURL;
+ prepareBaseURL.call(this);
+ }
+
+ if (cfg.paths)
+ extend(loader.paths, cfg.paths);
+
+ envSet(loader, cfg, function(cfg) {
+ if (cfg.paths)
+ extend(loader.paths, cfg.paths);
+ });
+
+ // warn on wildcard path deprecations
+ if (this.warnings) {
+ for (var p in loader.paths)
+ if (p.indexOf('*') != -1)
+ warn.call(loader, 'Paths configuration "' + p + '" -> "' + loader.paths[p] + '" uses wildcards which are being deprecated for simpler trailing "/" folder paths.');
+ }
+ }
+
+ if (cfg.defaultJSExtensions) {
+ loader.defaultJSExtensions = cfg.defaultJSExtensions;
+ warn.call(loader, 'The defaultJSExtensions configuration option is deprecated, use packages configuration instead.');
+ }
+
+ if (cfg.pluginFirst)
+ loader.pluginFirst = cfg.pluginFirst;
+
+ if (cfg.map) {
+ var objMaps = '';
+ for (var p in cfg.map) {
+ var v = cfg.map[p];
+
+ // object map backwards-compat into packages configuration
+ if (typeof v !== 'string') {
+ objMaps += (objMaps.length ? ', ' : '') + '"' + p + '"';
+
+ var defaultJSExtension = loader.defaultJSExtensions && p.substr(p.length - 3, 3) != '.js';
+ var prop = loader.decanonicalize(p);
+ if (defaultJSExtension && prop.substr(prop.length - 3, 3) == '.js')
+ prop = prop.substr(0, prop.length - 3);
+
+ // if a package main, revert it
+ var pkgMatch = '';
+ for (var pkg in loader.packages) {
+ if (prop.substr(0, pkg.length) == pkg
+ && (!prop[pkg.length] || prop[pkg.length] == '/')
+ && pkgMatch.split('/').length < pkg.split('/').length)
+ pkgMatch = pkg;
+ }
+ if (pkgMatch && loader.packages[pkgMatch].main)
+ prop = prop.substr(0, prop.length - loader.packages[pkgMatch].main.length - 1);
+
+ var pkg = loader.packages[prop] = loader.packages[prop] || {};
+ pkg.map = v;
+ }
+ else {
+ loader.map[p] = v;
+ }
+ }
+ if (objMaps)
+ warn.call(loader, 'The map configuration for ' + objMaps + ' uses object submaps, which is deprecated in global map.\nUpdate this to use package contextual map with configs like SystemJS.config({ packages: { "' + p + '": { map: {...} } } }).');
+ }
+
+ if (cfg.packageConfigPaths) {
+ var packageConfigPaths = [];
+ for (var i = 0; i < cfg.packageConfigPaths.length; i++) {
+ var path = cfg.packageConfigPaths[i];
+ var packageLength = Math.max(path.lastIndexOf('*') + 1, path.lastIndexOf('/'));
+ var normalized = coreResolve.call(loader, path.substr(0, packageLength));
+ packageConfigPaths[i] = normalized + path.substr(packageLength);
+ }
+ loader.packageConfigPaths = packageConfigPaths;
+ }
+
+ if (cfg.bundles) {
+ for (var p in cfg.bundles) {
+ var bundle = [];
+ for (var i = 0; i < cfg.bundles[p].length; i++) {
+ var defaultJSExtension = loader.defaultJSExtensions && cfg.bundles[p][i].substr(cfg.bundles[p][i].length - 3, 3) != '.js';
+ var normalizedBundleDep = loader.decanonicalize(cfg.bundles[p][i]);
+ if (defaultJSExtension && normalizedBundleDep.substr(normalizedBundleDep.length - 3, 3) == '.js')
+ normalizedBundleDep = normalizedBundleDep.substr(0, normalizedBundleDep.length - 3);
+ bundle.push(normalizedBundleDep);
+ }
+ loader.bundles[p] = bundle;
+ }
+ }
+
+ if (cfg.packages) {
+ for (var p in cfg.packages) {
+ if (p.match(/^([^\/]+:)?\/\/$/))
+ throw new TypeError('"' + p + '" is not a valid package name.');
+
+ var prop = coreResolve.call(loader, p);
+
+ // allow trailing slash in packages
+ if (prop[prop.length - 1] == '/')
+ prop = prop.substr(0, prop.length - 1);
+
+ setPkgConfig(loader, prop, cfg.packages[p], false);
+ }
+ }
+
+ for (var c in cfg) {
+ var v = cfg[c];
+
+ if (indexOf.call(['baseURL', 'map', 'packages', 'bundles', 'paths', 'warnings', 'packageConfigPaths',
+ 'loaderErrorStack', 'browserConfig', 'nodeConfig', 'devConfig', 'buildConfig', 'productionConfig'], c) != -1)
+ continue;
+
+ if (typeof v != 'object' || v instanceof Array) {
+ loader[c] = v;
+ }
+ else {
+ loader[c] = loader[c] || {};
+
+ for (var p in v) {
+ // base-level wildcard meta does not normalize to retain catch-all quality
+ if (c == 'meta' && p[0] == '*') {
+ extend(loader[c][p] = loader[c][p] || {}, v[p]);
+ }
+ else if (c == 'meta') {
+ // meta can go through global map, with defaultJSExtensions adding
+ var resolved = coreResolve.call(loader, p);
+ if (loader.defaultJSExtensions && resolved.substr(resolved.length - 3, 3) != '.js' && !isPlain(resolved))
+ resolved += '.js';
+ extend(loader[c][resolved] = loader[c][resolved] || {}, v[p]);
+ }
+ else if (c == 'depCache') {
+ var defaultJSExtension = loader.defaultJSExtensions && p.substr(p.length - 3, 3) != '.js';
+ var prop = loader.decanonicalize(p);
+ if (defaultJSExtension && prop.substr(prop.length - 3, 3) == '.js')
+ prop = prop.substr(0, prop.length - 3);
+ loader[c][prop] = [].concat(v[p]);
+ }
+ else {
+ loader[c][p] = v[p];
+ }
+ }
+ }
+ }
+
+ envSet(loader, cfg, function(cfg) {
+ loader.config(cfg, true);
+ });
+};/*
+ * Package Configuration Extension
+ *
+ * Example:
+ *
+ * SystemJS.packages = {
+ * jquery: {
+ * main: 'index.js', // when not set, package name is requested directly
+ * format: 'amd',
+ * defaultExtension: 'ts', // defaults to 'js', can be set to false
+ * modules: {
+ * '*.ts': {
+ * loader: 'typescript'
+ * },
+ * 'vendor/sizzle.js': {
+ * format: 'global'
+ * }
+ * },
+ * map: {
+ * // map internal require('sizzle') to local require('./vendor/sizzle')
+ * sizzle: './vendor/sizzle.js',
+ * // map any internal or external require of 'jquery/vendor/another' to 'another/index.js'
+ * './vendor/another.js': './another/index.js',
+ * // test.js / test -> lib/test.js
+ * './test.js': './lib/test.js',
+ *
+ * // environment-specific map configurations
+ * './index.js': {
+ * '~browser': './index-node.js',
+ * './custom-condition.js|~export': './index-custom.js'
+ * }
+ * },
+ * // allows for setting package-prefixed depCache
+ * // keys are normalized module names relative to the package itself
+ * depCache: {
+ * // import 'package/index.js' loads in parallel package/lib/test.js,package/vendor/sizzle.js
+ * './index.js': ['./test'],
+ * './test.js': ['external-dep'],
+ * 'external-dep/path.js': ['./another.js']
+ * }
+ * }
+ * };
+ *
+ * Then:
+ * import 'jquery' -> jquery/index.js
+ * import 'jquery/submodule' -> jquery/submodule.js
+ * import 'jquery/submodule.ts' -> jquery/submodule.ts loaded as typescript
+ * import 'jquery/vendor/another' -> another/index.js
+ *
+ * Detailed Behaviours
+ * - main can have a leading "./" can be added optionally
+ * - map and defaultExtension are applied to the main
+ * - defaultExtension adds the extension only if the exact extension is not present
+ * - defaultJSExtensions applies after map when defaultExtension is not set
+ * - if a meta value is available for a module, map and defaultExtension are skipped
+ * - like global map, package map also applies to subpaths (sizzle/x, ./vendor/another/sub)
+ * - condition module map is '@env' module in package or '@system-env' globally
+ * - map targets support conditional interpolation ('./x': './x.#{|env}.js')
+ * - internal package map targets cannot use boolean conditionals
+ *
+ * Package Configuration Loading
+ *
+ * Not all packages may already have their configuration present in the System config
+ * For these cases, a list of packageConfigPaths can be provided, which when matched against
+ * a request, will first request a ".json" file by the package name to derive the package
+ * configuration from. This allows dynamic loading of non-predetermined code, a key use
+ * case in SystemJS.
+ *
+ * Example:
+ *
+ * SystemJS.packageConfigPaths = ['packages/test/package.json', 'packages/*.json'];
+ *
+ * // will first request 'packages/new-package/package.json' for the package config
+ * // before completing the package request to 'packages/new-package/path'
+ * SystemJS.import('packages/new-package/path');
+ *
+ * // will first request 'packages/test/package.json' before the main
+ * SystemJS.import('packages/test');
+ *
+ * When a package matches packageConfigPaths, it will always send a config request for
+ * the package configuration.
+ * The package name itself is taken to be the match up to and including the last wildcard
+ * or trailing slash.
+ * The most specific package config path will be used.
+ * Any existing package configurations for the package will deeply merge with the
+ * package config, with the existing package configurations taking preference.
+ * To opt-out of the package configuration request for a package that matches
+ * packageConfigPaths, use the { configured: true } package config option.
+ *
+ */
+(function() {
+
+ hookConstructor(function(constructor) {
+ return function() {
+ constructor.call(this);
+ this.packages = {};
+ this.packageConfigPaths = [];
+ };
+ });
+
+ function getPackage(loader, normalized) {
+ // use most specific package
+ var curPkg, curPkgLen = 0, pkgLen;
+ for (var p in loader.packages) {
+ if (normalized.substr(0, p.length) === p && (normalized.length === p.length || normalized[p.length] === '/')) {
+ pkgLen = p.split('/').length;
+ if (pkgLen > curPkgLen) {
+ curPkg = p;
+ curPkgLen = pkgLen;
+ }
+ }
+ }
+ return curPkg;
+ }
+
+ function addDefaultExtension(loader, pkg, pkgName, subPath, skipExtensions) {
+ // don't apply extensions to folders or if defaultExtension = false
+ if (!subPath || subPath[subPath.length - 1] == '/' || skipExtensions || pkg.defaultExtension === false)
+ return subPath;
+
+ var metaMatch = false;
+
+ // exact meta or meta with any content after the last wildcard skips extension
+ if (pkg.meta)
+ getMetaMatches(pkg.meta, subPath, function(metaPattern, matchMeta, matchDepth) {
+ if (matchDepth == 0 || metaPattern.lastIndexOf('*') != metaPattern.length - 1)
+ return metaMatch = true;
+ });
+
+ // exact global meta or meta with any content after the last wildcard skips extension
+ if (!metaMatch && loader.meta)
+ getMetaMatches(loader.meta, pkgName + '/' + subPath, function(metaPattern, matchMeta, matchDepth) {
+ if (matchDepth == 0 || metaPattern.lastIndexOf('*') != metaPattern.length - 1)
+ return metaMatch = true;
+ });
+
+ if (metaMatch)
+ return subPath;
+
+ // work out what the defaultExtension is and add if not there already
+ // NB reconsider if default should really be ".js"?
+ var defaultExtension = '.' + (pkg.defaultExtension || 'js');
+ if (subPath.substr(subPath.length - defaultExtension.length) != defaultExtension)
+ return subPath + defaultExtension;
+ else
+ return subPath;
+ }
+
+ function applyPackageConfigSync(loader, pkg, pkgName, subPath, skipExtensions) {
+ // main
+ if (!subPath) {
+ if (pkg.main)
+ subPath = pkg.main.substr(0, 2) == './' ? pkg.main.substr(2) : pkg.main;
+ // also no submap if name is package itself (import 'pkg' -> 'path/to/pkg.js')
+ else
+ // NB can add a default package main convention here when defaultJSExtensions is deprecated
+ // if it becomes internal to the package then it would no longer be an exit path
+ return pkgName + (loader.defaultJSExtensions ? '.js' : '');
+ }
+
+ // map config checking without then with extensions
+ if (pkg.map) {
+ var mapPath = './' + subPath;
+
+ var mapMatch = getMapMatch(pkg.map, mapPath);
+
+ // we then check map with the default extension adding
+ if (!mapMatch) {
+ mapPath = './' + addDefaultExtension(loader, pkg, pkgName, subPath, skipExtensions);
+ if (mapPath != './' + subPath)
+ mapMatch = getMapMatch(pkg.map, mapPath);
+ }
+ if (mapMatch) {
+ var mapped = doMapSync(loader, pkg, pkgName, mapMatch, mapPath, skipExtensions);
+ if (mapped)
+ return mapped;
+ }
+ }
+
+ // normal package resolution
+ return pkgName + '/' + addDefaultExtension(loader, pkg, pkgName, subPath, skipExtensions);
+ }
+
+ function validMapping(mapMatch, mapped, pkgName, path) {
+ // disallow internal to subpath maps
+ if (mapMatch == '.')
+ throw new Error('Package ' + pkgName + ' has a map entry for "." which is not permitted.');
+
+ // allow internal ./x -> ./x/y or ./x/ -> ./x/y recursive maps
+ // but only if the path is exactly ./x and not ./x/z
+ if (mapped.substr(0, mapMatch.length) == mapMatch && path.length > mapMatch.length)
+ return false;
+
+ return true;
+ }
+
+ function doMapSync(loader, pkg, pkgName, mapMatch, path, skipExtensions) {
+ if (path[path.length - 1] == '/')
+ path = path.substr(0, path.length - 1);
+ var mapped = pkg.map[mapMatch];
+
+ if (typeof mapped == 'object')
+ throw new Error('Synchronous conditional normalization not supported sync normalizing ' + mapMatch + ' in ' + pkgName);
+
+ if (!validMapping(mapMatch, mapped, pkgName, path) || typeof mapped != 'string')
+ return;
+
+ // package map to main / base-level
+ if (mapped == '.')
+ mapped = pkgName;
+
+ // internal package map
+ else if (mapped.substr(0, 2) == './')
+ return pkgName + '/' + addDefaultExtension(loader, pkg, pkgName, mapped.substr(2) + path.substr(mapMatch.length), skipExtensions);
+
+ // external map reference
+ return loader.normalizeSync(mapped + path.substr(mapMatch.length), pkgName + '/');
+ }
+
+ function applyPackageConfig(loader, pkg, pkgName, subPath, skipExtensions) {
+ // main
+ if (!subPath) {
+ if (pkg.main)
+ subPath = pkg.main.substr(0, 2) == './' ? pkg.main.substr(2) : pkg.main;
+ // also no submap if name is package itself (import 'pkg' -> 'path/to/pkg.js')
+ else
+ // NB can add a default package main convention here when defaultJSExtensions is deprecated
+ // if it becomes internal to the package then it would no longer be an exit path
+ return Promise.resolve(pkgName + (loader.defaultJSExtensions ? '.js' : ''));
+ }
+
+ // map config checking without then with extensions
+ var mapPath, mapMatch;
+
+ if (pkg.map) {
+ mapPath = './' + subPath;
+ mapMatch = getMapMatch(pkg.map, mapPath);
+
+ // we then check map with the default extension adding
+ if (!mapMatch) {
+ mapPath = './' + addDefaultExtension(loader, pkg, pkgName, subPath, skipExtensions);
+ if (mapPath != './' + subPath)
+ mapMatch = getMapMatch(pkg.map, mapPath);
+ }
+ }
+
+ return (mapMatch ? doMap(loader, pkg, pkgName, mapMatch, mapPath, skipExtensions) : Promise.resolve())
+ .then(function(mapped) {
+ if (mapped)
+ return Promise.resolve(mapped);
+
+ // normal package resolution / fallback resolution for no conditional match
+ return Promise.resolve(pkgName + '/' + addDefaultExtension(loader, pkg, pkgName, subPath, skipExtensions));
+ });
+ }
+
+ function doStringMap(loader, pkg, pkgName, mapMatch, mapped, path, skipExtensions) {
+ // NB the interpolation cases should strictly skip subsequent interpolation
+ // package map to main / base-level
+ if (mapped == '.')
+ mapped = pkgName;
+
+ // internal package map
+ else if (mapped.substr(0, 2) == './')
+ return Promise.resolve(pkgName + '/' + addDefaultExtension(loader, pkg, pkgName, mapped.substr(2) + path.substr(mapMatch.length), skipExtensions))
+ .then(function(name) {
+ return interpolateConditional.call(loader, name, pkgName + '/');
+ });
+
+ // external map reference
+ return loader.normalize(mapped + path.substr(mapMatch.length), pkgName + '/');
+ }
+
+ function doMap(loader, pkg, pkgName, mapMatch, path, skipExtensions) {
+ if (path[path.length - 1] == '/')
+ path = path.substr(0, path.length - 1);
+
+ var mapped = pkg.map[mapMatch];
+
+ if (typeof mapped == 'string') {
+ if (!validMapping(mapMatch, mapped, pkgName, path))
+ return Promise.resolve();
+ return doStringMap(loader, pkg, pkgName, mapMatch, mapped, path, skipExtensions);
+ }
+
+ // we use a special conditional syntax to allow the builder to handle conditional branch points further
+ if (loader.builder)
+ return Promise.resolve(pkgName + '/#:' + path);
+
+ // we load all conditions upfront
+ var conditionPromises = [];
+ var conditions = [];
+ for (var e in mapped) {
+ var c = parseCondition(e);
+ conditions.push({
+ condition: c,
+ map: mapped[e]
+ });
+ conditionPromises.push(loader['import'](c.module, pkgName));
+ }
+
+ // map object -> conditional map
+ return Promise.all(conditionPromises)
+ .then(function(conditionValues) {
+ // first map condition to match is used
+ for (var i = 0; i < conditions.length; i++) {
+ var c = conditions[i].condition;
+ var value = readMemberExpression(c.prop, conditionValues[i]);
+ if (!c.negate && value || c.negate && !value)
+ return conditions[i].map;
+ }
+ })
+ .then(function(mapped) {
+ if (mapped) {
+ if (!validMapping(mapMatch, mapped, pkgName, path))
+ return;
+ return doStringMap(loader, pkg, pkgName, mapMatch, mapped, path, skipExtensions);
+ }
+
+ // no environment match -> fallback to original subPath by returning undefined
+ });
+ }
+
+ // normalizeSync = decanonicalize + package resolution
+ SystemJSLoader.prototype.normalizeSync = SystemJSLoader.prototype.decanonicalize = SystemJSLoader.prototype.normalize;
+
+ // decanonicalize must JUST handle package defaultExtension: false case when defaultJSExtensions is set
+ // to be deprecated!
+ hook('decanonicalize', function(decanonicalize) {
+ return function(name, parentName) {
+ if (this.builder)
+ return decanonicalize.call(this, name, parentName, true);
+
+ var decanonicalized = decanonicalize.call(this, name, parentName, false);
+
+ if (!this.defaultJSExtensions)
+ return decanonicalized;
+
+ var pkgName = getPackage(this, decanonicalized);
+
+ var pkg = this.packages[pkgName];
+ var defaultExtension = pkg && pkg.defaultExtension;
+
+ if (defaultExtension == undefined && pkg && pkg.meta)
+ getMetaMatches(pkg.meta, decanonicalized.substr(pkgName), function(metaPattern, matchMeta, matchDepth) {
+ if (matchDepth == 0 || metaPattern.lastIndexOf('*') != metaPattern.length - 1) {
+ defaultExtension = false;
+ return true;
+ }
+ });
+
+ if ((defaultExtension === false || defaultExtension && defaultExtension != '.js') && name.substr(name.length - 3, 3) != '.js' && decanonicalized.substr(decanonicalized.length - 3, 3) == '.js')
+ decanonicalized = decanonicalized.substr(0, decanonicalized.length - 3);
+
+ return decanonicalized;
+ };
+ });
+
+ hook('normalizeSync', function(normalizeSync) {
+ return function(name, parentName, isPlugin) {
+ var loader = this;
+ isPlugin = isPlugin === true;
+
+ // apply contextual package map first
+ // (we assume the parent package config has already been loaded)
+ if (parentName)
+ var parentPackageName = getPackage(loader, parentName) ||
+ loader.defaultJSExtensions && parentName.substr(parentName.length - 3, 3) == '.js' &&
+ getPackage(loader, parentName.substr(0, parentName.length - 3));
+
+ var parentPackage = parentPackageName && loader.packages[parentPackageName];
+
+ // ignore . since internal maps handled by standard package resolution
+ if (parentPackage && name[0] != '.') {
+ var parentMap = parentPackage.map;
+ var parentMapMatch = parentMap && getMapMatch(parentMap, name);
+
+ if (parentMapMatch && typeof parentMap[parentMapMatch] == 'string') {
+ var mapped = doMapSync(loader, parentPackage, parentPackageName, parentMapMatch, name, isPlugin);
+ if (mapped)
+ return mapped;
+ }
+ }
+
+ var defaultJSExtension = loader.defaultJSExtensions && name.substr(name.length - 3, 3) != '.js';
+
+ // apply map, core, paths, contextual package map
+ var normalized = normalizeSync.call(loader, name, parentName, false);
+
+ // undo defaultJSExtension
+ if (defaultJSExtension && normalized.substr(normalized.length - 3, 3) != '.js')
+ defaultJSExtension = false;
+ if (defaultJSExtension)
+ normalized = normalized.substr(0, normalized.length - 3);
+
+ var pkgConfigMatch = getPackageConfigMatch(loader, normalized);
+ var pkgName = pkgConfigMatch && pkgConfigMatch.packageName || getPackage(loader, normalized);
+
+ if (!pkgName)
+ return normalized + (defaultJSExtension ? '.js' : '');
+
+ var subPath = normalized.substr(pkgName.length + 1);
+
+ return applyPackageConfigSync(loader, loader.packages[pkgName] || {}, pkgName, subPath, isPlugin);
+ };
+ });
+
+ hook('normalize', function(normalize) {
+ return function(name, parentName, isPlugin) {
+ var loader = this;
+ isPlugin = isPlugin === true;
+
+ return Promise.resolve()
+ .then(function() {
+ // apply contextual package map first
+ // (we assume the parent package config has already been loaded)
+ if (parentName)
+ var parentPackageName = getPackage(loader, parentName) ||
+ loader.defaultJSExtensions && parentName.substr(parentName.length - 3, 3) == '.js' &&
+ getPackage(loader, parentName.substr(0, parentName.length - 3));
+
+ var parentPackage = parentPackageName && loader.packages[parentPackageName];
+
+ // ignore . since internal maps handled by standard package resolution
+ if (parentPackage && name.substr(0, 2) != './') {
+ var parentMap = parentPackage.map;
+ var parentMapMatch = parentMap && getMapMatch(parentMap, name);
+
+ if (parentMapMatch)
+ return doMap(loader, parentPackage, parentPackageName, parentMapMatch, name, isPlugin);
+ }
+
+ return Promise.resolve();
+ })
+ .then(function(mapped) {
+ if (mapped)
+ return mapped;
+
+ var defaultJSExtension = loader.defaultJSExtensions && name.substr(name.length - 3, 3) != '.js';
+
+ // apply map, core, paths, contextual package map
+ var normalized = normalize.call(loader, name, parentName, false);
+
+ // undo defaultJSExtension
+ if (defaultJSExtension && normalized.substr(normalized.length - 3, 3) != '.js')
+ defaultJSExtension = false;
+ if (defaultJSExtension)
+ normalized = normalized.substr(0, normalized.length - 3);
+
+ var pkgConfigMatch = getPackageConfigMatch(loader, normalized);
+ var pkgName = pkgConfigMatch && pkgConfigMatch.packageName || getPackage(loader, normalized);
+
+ if (!pkgName)
+ return Promise.resolve(normalized + (defaultJSExtension ? '.js' : ''));
+
+ var pkg = loader.packages[pkgName];
+
+ // if package is already configured or not a dynamic config package, use existing package config
+ var isConfigured = pkg && (pkg.configured || !pkgConfigMatch);
+ return (isConfigured ? Promise.resolve(pkg) : loadPackageConfigPath(loader, pkgName, pkgConfigMatch.configPath))
+ .then(function(pkg) {
+ var subPath = normalized.substr(pkgName.length + 1);
+
+ return applyPackageConfig(loader, pkg, pkgName, subPath, isPlugin);
+ });
+ });
+ };
+ });
+
+ // check if the given normalized name matches a packageConfigPath
+ // if so, loads the config
+ var packageConfigPaths = {};
+
+ // data object for quick checks against package paths
+ function createPkgConfigPathObj(path) {
+ var lastWildcard = path.lastIndexOf('*');
+ var length = Math.max(lastWildcard + 1, path.lastIndexOf('/'));
+ return {
+ length: length,
+ regEx: new RegExp('^(' + path.substr(0, length).replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '[^\\/]+') + ')(\\/|$)'),
+ wildcard: lastWildcard != -1
+ };
+ }
+
+ // most specific match wins
+ function getPackageConfigMatch(loader, normalized) {
+ var pkgName, exactMatch = false, configPath;
+ for (var i = 0; i < loader.packageConfigPaths.length; i++) {
+ var packageConfigPath = loader.packageConfigPaths[i];
+ var p = packageConfigPaths[packageConfigPath] || (packageConfigPaths[packageConfigPath] = createPkgConfigPathObj(packageConfigPath));
+ if (normalized.length < p.length)
+ continue;
+ var match = normalized.match(p.regEx);
+ if (match && (!pkgName || (!(exactMatch && p.wildcard) && pkgName.length < match[1].length))) {
+ pkgName = match[1];
+ exactMatch = !p.wildcard;
+ configPath = pkgName + packageConfigPath.substr(p.length);
+ }
+ }
+
+ if (!pkgName)
+ return;
+
+ return {
+ packageName: pkgName,
+ configPath: configPath
+ };
+ }
+
+ function loadPackageConfigPath(loader, pkgName, pkgConfigPath) {
+ var configLoader = loader.pluginLoader || loader;
+
+ // NB remove this when json is default
+ (configLoader.meta[pkgConfigPath] = configLoader.meta[pkgConfigPath] || {}).format = 'json';
+ configLoader.meta[pkgConfigPath].loader = null;
+
+ return configLoader.load(pkgConfigPath)
+ .then(function() {
+ var cfg = configLoader.get(pkgConfigPath)['default'];
+
+ // support "systemjs" prefixing
+ if (cfg.systemjs)
+ cfg = cfg.systemjs;
+
+ // modules backwards compatibility
+ if (cfg.modules) {
+ cfg.meta = cfg.modules;
+ warn.call(loader, 'Package config file ' + pkgConfigPath + ' is configured with "modules", which is deprecated as it has been renamed to "meta".');
+ }
+
+ return setPkgConfig(loader, pkgName, cfg, true);
+ });
+ }
+
+ function getMetaMatches(pkgMeta, subPath, matchFn) {
+ // wildcard meta
+ var meta = {};
+ var wildcardIndex;
+ for (var module in pkgMeta) {
+ // allow meta to start with ./ for flexibility
+ var dotRel = module.substr(0, 2) == './' ? './' : '';
+ if (dotRel)
+ module = module.substr(2);
+
+ wildcardIndex = module.indexOf('*');
+ if (wildcardIndex === -1)
+ continue;
+
+ if (module.substr(0, wildcardIndex) == subPath.substr(0, wildcardIndex)
+ && module.substr(wildcardIndex + 1) == subPath.substr(subPath.length - module.length + wildcardIndex + 1)) {
+ // alow match function to return true for an exit path
+ if (matchFn(module, pkgMeta[dotRel + module], module.split('/').length))
+ return;
+ }
+ }
+ // exact meta
+ var exactMeta = pkgMeta[subPath] && pkgMeta.hasOwnProperty && pkgMeta.hasOwnProperty(subPath) ? pkgMeta[subPath] : pkgMeta['./' + subPath];
+ if (exactMeta)
+ matchFn(exactMeta, exactMeta, 0);
+ }
+
+ hook('locate', function(locate) {
+ return function(load) {
+ var loader = this;
+ return Promise.resolve(locate.call(this, load))
+ .then(function(address) {
+ var pkgName = getPackage(loader, load.name);
+ if (pkgName) {
+ var pkg = loader.packages[pkgName];
+ var subPath = load.name.substr(pkgName.length + 1);
+
+ var meta = {};
+ if (pkg.meta) {
+ var bestDepth = 0;
+
+ // NB support a main shorthand in meta here?
+ getMetaMatches(pkg.meta, subPath, function(metaPattern, matchMeta, matchDepth) {
+ if (matchDepth > bestDepth)
+ bestDepth = matchDepth;
+ extendMeta(meta, matchMeta, matchDepth && bestDepth > matchDepth);
+ });
+
+ extendMeta(load.metadata, meta);
+ }
+
+ // format
+ if (pkg.format && !load.metadata.loader)
+ load.metadata.format = load.metadata.format || pkg.format;
+ }
+
+ return address;
+ });
+ };
+ });
+
+})();
+/*
+ * Script tag fetch
+ *
+ * When load.metadata.scriptLoad is true, we load via script tag injection.
+ */
+(function() {
+
+ if (typeof document != 'undefined')
+ var head = document.getElementsByTagName('head')[0];
+
+ var curSystem;
+ var curRequire;
+
+ // if doing worker executing, this is set to the load record being executed
+ var workerLoad = null;
+
+ // interactive mode handling method courtesy RequireJS
+ var ieEvents = head && (function() {
+ var s = document.createElement('script');
+ var isOpera = typeof opera !== 'undefined' && opera.toString() === '[object Opera]';
+ return s.attachEvent && !(s.attachEvent.toString && s.attachEvent.toString().indexOf('[native code') < 0) && !isOpera;
+ })();
+
+ // IE interactive-only part
+ // we store loading scripts array as { script: <script>, load: {...} }
+ var interactiveLoadingScripts = [];
+ var interactiveScript;
+ function getInteractiveScriptLoad() {
+ if (interactiveScript && interactiveScript.script.readyState === 'interactive')
+ return interactiveScript.load;
+
+ for (var i = 0; i < interactiveLoadingScripts.length; i++)
+ if (interactiveLoadingScripts[i].script.readyState == 'interactive') {
+ interactiveScript = interactiveLoadingScripts[i];
+ return interactiveScript.load;
+ }
+ }
+
+ // System.register, System.registerDynamic, AMD define pipeline
+ // this is called by the above methods when they execute
+ // we then run the reduceRegister_ collection function either immediately
+ // if we are in IE and know the currently executing script (interactive)
+ // or later if we need to wait for the synchronous load callback to know the script
+ var loadingCnt = 0;
+ var registerQueue = [];
+ hook('pushRegister_', function(pushRegister) {
+ return function(register) {
+ // if using eval-execution then skip
+ if (pushRegister.call(this, register))
+ return false;
+
+ // if using worker execution, then we're done
+ if (workerLoad)
+ this.reduceRegister_(workerLoad, register);
+
+ // detect if we know the currently executing load (IE)
+ // if so, immediately call reduceRegister
+ else if (ieEvents)
+ this.reduceRegister_(getInteractiveScriptLoad(), register);
+
+ // otherwise, add to our execution queue
+ // to call reduceRegister on sync script load event
+ else if (loadingCnt)
+ registerQueue.push(register);
+
+ // if we're not currently loading anything though
+ // then do the reduction against a null load
+ // (out of band named define or named register)
+ // note even in non-script environments, this catch is used
+ else
+ this.reduceRegister_(null, register);
+
+ return true;
+ };
+ });
+
+ function webWorkerImport(loader, load) {
+ return new Promise(function(resolve, reject) {
+ if (load.metadata.integrity)
+ reject(new Error('Subresource integrity checking is not supported in web workers.'));
+
+ workerLoad = load;
+ try {
+ importScripts(load.address);
+ }
+ catch(e) {
+ workerLoad = null;
+ reject(e);
+ }
+ workerLoad = null;
+
+ // if nothing registered, then something went wrong
+ if (!load.metadata.entry)
+ reject(new Error(load.address + ' did not call System.register or AMD define. If loading a global, ensure the meta format is set to global.'));
+
+ resolve('');
+ });
+ }
+
+ // override fetch to use script injection
+ hook('fetch', function(fetch) {
+ return function(load) {
+ var loader = this;
+
+ if (load.metadata.format == 'json' || !load.metadata.scriptLoad || (!isBrowser && !isWorker))
+ return fetch.call(this, load);
+
+ if (isWorker)
+ return webWorkerImport(loader, load);
+
+ return new Promise(function(resolve, reject) {
+ var s = document.createElement('script');
+
+ s.async = true;
+
+ if (load.metadata.crossOrigin)
+ s.crossOrigin = load.metadata.crossOrigin;
+
+ if (load.metadata.integrity)
+ s.setAttribute('integrity', load.metadata.integrity);
+
+ if (ieEvents) {
+ s.attachEvent('onreadystatechange', complete);
+ interactiveLoadingScripts.push({
+ script: s,
+ load: load
+ });
+ }
+ else {
+ s.addEventListener('load', complete, false);
+ s.addEventListener('error', error, false);
+ }
+
+ loadingCnt++;
+
+ curSystem = __global.System;
+ curRequire = __global.require;
+
+ s.src = load.address;
+ head.appendChild(s);
+
+ function complete(evt) {
+ if (s.readyState && s.readyState != 'loaded' && s.readyState != 'complete')
+ return;
+
+ loadingCnt--;
+
+ // complete call is sync on execution finish
+ // (in ie already done reductions)
+ if (!load.metadata.entry && !registerQueue.length) {
+ loader.reduceRegister_(load);
+ }
+ else if (!ieEvents) {
+ for (var i = 0; i < registerQueue.length; i++)
+ loader.reduceRegister_(load, registerQueue[i]);
+ registerQueue = [];
+ }
+
+ cleanup();
+
+ // if nothing registered, then something went wrong
+ if (!load.metadata.entry && !load.metadata.bundle)
+ reject(new Error(load.name + ' did not call System.register or AMD define. If loading a global module configure the global name via the meta exports property for script injection support.'));
+
+ resolve('');
+ }
+
+ function error(evt) {
+ cleanup();
+ reject(new Error('Unable to load script ' + load.address));
+ }
+
+ function cleanup() {
+ __global.System = curSystem;
+ __global.require = curRequire;
+
+ if (s.detachEvent) {
+ s.detachEvent('onreadystatechange', complete);
+ for (var i = 0; i < interactiveLoadingScripts.length; i++)
+ if (interactiveLoadingScripts[i].script == s) {
+ if (interactiveScript && interactiveScript.script == s)
+ interactiveScript = null;
+ interactiveLoadingScripts.splice(i, 1);
+ }
+ }
+ else {
+ s.removeEventListener('load', complete, false);
+ s.removeEventListener('error', error, false);
+ }
+
+ head.removeChild(s);
+ }
+ });
+ };
+ });
+})();
+/*
+ * Instantiate registry extension
+ *
+ * Supports Traceur System.register 'instantiate' output for loading ES6 as ES5.
+ *
+ * - Creates the loader.register function
+ * - Also supports metadata.format = 'register' in instantiate for anonymous register modules
+ * - Also supports metadata.deps, metadata.execute and metadata.executingRequire
+ * for handling dynamic modules alongside register-transformed ES6 modules
+ *
+ *
+ * The code here replicates the ES6 linking groups algorithm to ensure that
+ * circular ES6 compiled into System.register can work alongside circular AMD
+ * and CommonJS, identically to the actual ES6 loader.
+ *
+ */
+
+
+/*
+ * Registry side table entries in loader.defined
+ * Registry Entry Contains:
+ * - name
+ * - deps
+ * - declare for declarative modules
+ * - execute for dynamic modules, different to declarative execute on module
+ * - executingRequire indicates require drives execution for circularity of dynamic modules
+ * - declarative optional boolean indicating which of the above
+ *
+ * Can preload modules directly on SystemJS.defined['my/module'] = { deps, execute, executingRequire }
+ *
+ * Then the entry gets populated with derived information during processing:
+ * - normalizedDeps derived from deps, created in instantiate
+ * - groupIndex used by group linking algorithm
+ * - evaluated indicating whether evaluation has happend
+ * - module the module record object, containing:
+ * - exports actual module exports
+ *
+ * For dynamic we track the es module with:
+ * - esModule actual es module value
+ * - esmExports whether to extend the esModule with named exports
+ *
+ * Then for declarative only we track dynamic bindings with the 'module' records:
+ * - name
+ * - exports
+ * - setters declarative setter functions
+ * - dependencies, module records of dependencies
+ * - importers, module records of dependents
+ *
+ * After linked and evaluated, entries are removed, declarative module records remain in separate
+ * module binding table
+ *
+ */
+
+var leadingCommentAndMetaRegEx = /^(\s*\/\*[^\*]*(\*(?!\/)[^\*]*)*\*\/|\s*\/\/[^\n]*|\s*"[^"]+"\s*;?|\s*'[^']+'\s*;?)*\s*/;
+function detectRegisterFormat(source) {
+ var leadingCommentAndMeta = source.match(leadingCommentAndMetaRegEx);
+ return leadingCommentAndMeta && source.substr(leadingCommentAndMeta[0].length, 15) == 'System.register';
+}
+
+function createEntry() {
+ return {
+ name: null,
+ deps: null,
+ originalIndices: null,
+ declare: null,
+ execute: null,
+ executingRequire: false,
+ declarative: false,
+ normalizedDeps: null,
+ groupIndex: null,
+ evaluated: false,
+ module: null,
+ esModule: null,
+ esmExports: false
+ };
+}
+
+(function() {
+
+ /*
+ * There are two variations of System.register:
+ * 1. System.register for ES6 conversion (2-3 params) - System.register([name, ]deps, declare)
+ * see https://github.com/ModuleLoader/es6-module-loader/wiki/System.register-Explained
+ *
+ * 2. System.registerDynamic for dynamic modules (3-4 params) - System.registerDynamic([name, ]deps, executingRequire, execute)
+ * the true or false statement
+ *
+ * this extension implements the linking algorithm for the two variations identical to the spec
+ * allowing compiled ES6 circular references to work alongside AMD and CJS circular references.
+ *
+ */
+ SystemJSLoader.prototype.register = function(name, deps, declare) {
+ if (typeof name != 'string') {
+ declare = deps;
+ deps = name;
+ name = null;
+ }
+
+ // dynamic backwards-compatibility
+ // can be deprecated eventually
+ if (typeof declare == 'boolean')
+ return this.registerDynamic.apply(this, arguments);
+
+ var entry = createEntry();
+ // ideally wouldn't apply map config to bundle names but
+ // dependencies go through map regardless so we can't restrict
+ // could reconsider in shift to new spec
+ entry.name = name && (this.decanonicalize || this.normalize).call(this, name);
+ entry.declarative = true;
+ entry.deps = deps;
+ entry.declare = declare;
+
+ this.pushRegister_({
+ amd: false,
+ entry: entry
+ });
+ };
+ SystemJSLoader.prototype.registerDynamic = function(name, deps, declare, execute) {
+ if (typeof name != 'string') {
+ execute = declare;
+ declare = deps;
+ deps = name;
+ name = null;
+ }
+
+ // dynamic
+ var entry = createEntry();
+ entry.name = name && (this.decanonicalize || this.normalize).call(this, name);
+ entry.deps = deps;
+ entry.execute = execute;
+ entry.executingRequire = declare;
+
+ this.pushRegister_({
+ amd: false,
+ entry: entry
+ });
+ };
+ hook('reduceRegister_', function() {
+ return function(load, register) {
+ if (!register)
+ return;
+
+ var entry = register.entry;
+ var curMeta = load && load.metadata;
+
+ // named register
+ if (entry.name) {
+ if (!(entry.name in this.defined))
+ this.defined[entry.name] = entry;
+
+ if (curMeta)
+ curMeta.bundle = true;
+ }
+ // anonymous register
+ if (!entry.name || load && !curMeta.entry && entry.name == load.name) {
+ if (!curMeta)
+ throw new TypeError('Invalid System.register call. Anonymous System.register calls can only be made by modules loaded by SystemJS.import and not via script tags.');
+ if (curMeta.entry) {
+ if (curMeta.format == 'register')
+ throw new Error('Multiple anonymous System.register calls in module ' + load.name + '. If loading a bundle, ensure all the System.register calls are named.');
+ else
+ throw new Error('Module ' + load.name + ' interpreted as ' + curMeta.format + ' module format, but called System.register.');
+ }
+ if (!curMeta.format)
+ curMeta.format = 'register';
+ curMeta.entry = entry;
+ }
+ };
+ });
+
+ hookConstructor(function(constructor) {
+ return function() {
+ constructor.call(this);
+
+ this.defined = {};
+ this._loader.moduleRecords = {};
+ };
+ });
+
+ function buildGroups(entry, loader, groups) {
+ groups[entry.groupIndex] = groups[entry.groupIndex] || [];
+
+ if (indexOf.call(groups[entry.groupIndex], entry) != -1)
+ return;
+
+ groups[entry.groupIndex].push(entry);
+
+ for (var i = 0, l = entry.normalizedDeps.length; i < l; i++) {
+ var depName = entry.normalizedDeps[i];
+ var depEntry = loader.defined[depName];
+
+ // not in the registry means already linked / ES6
+ if (!depEntry || depEntry.evaluated)
+ continue;
+
+ // now we know the entry is in our unlinked linkage group
+ var depGroupIndex = entry.groupIndex + (depEntry.declarative != entry.declarative);
+
+ // the group index of an entry is always the maximum
+ if (depEntry.groupIndex === null || depEntry.groupIndex < depGroupIndex) {
+
+ // if already in a group, remove from the old group
+ if (depEntry.groupIndex !== null) {
+ groups[depEntry.groupIndex].splice(indexOf.call(groups[depEntry.groupIndex], depEntry), 1);
+
+ // if the old group is empty, then we have a mixed depndency cycle
+ if (groups[depEntry.groupIndex].length == 0)
+ throw new Error("Mixed dependency cycle detected");
+ }
+
+ depEntry.groupIndex = depGroupIndex;
+ }
+
+ buildGroups(depEntry, loader, groups);
+ }
+ }
+
+ function link(name, startEntry, loader) {
+ // skip if already linked
+ if (startEntry.module)
+ return;
+
+ startEntry.groupIndex = 0;
+
+ var groups = [];
+
+ buildGroups(startEntry, loader, groups);
+
+ var curGroupDeclarative = !!startEntry.declarative == groups.length % 2;
+ for (var i = groups.length - 1; i >= 0; i--) {
+ var group = groups[i];
+ for (var j = 0; j < group.length; j++) {
+ var entry = group[j];
+
+ // link each group
+ if (curGroupDeclarative)
+ linkDeclarativeModule(entry, loader);
+ else
+ linkDynamicModule(entry, loader);
+ }
+ curGroupDeclarative = !curGroupDeclarative;
+ }
+ }
+
+ // module binding records
+ function ModuleRecord() {}
+ defineProperty(ModuleRecord, 'toString', {
+ value: function() {
+ return 'Module';
+ }
+ });
+
+ function getOrCreateModuleRecord(name, moduleRecords) {
+ return moduleRecords[name] || (moduleRecords[name] = {
+ name: name,
+ dependencies: [],
+ exports: new ModuleRecord(), // start from an empty module and extend
+ importers: []
+ });
+ }
+
+ function linkDeclarativeModule(entry, loader) {
+ // only link if already not already started linking (stops at circular)
+ if (entry.module)
+ return;
+
+ var moduleRecords = loader._loader.moduleRecords;
+ var module = entry.module = getOrCreateModuleRecord(entry.name, moduleRecords);
+ var exports = entry.module.exports;
+
+ var declaration = entry.declare.call(__global, function(name, value) {
+ module.locked = true;
+
+ if (typeof name == 'object') {
+ for (var p in name)
+ exports[p] = name[p];
+ }
+ else {
+ exports[name] = value;
+ }
+
+ for (var i = 0, l = module.importers.length; i < l; i++) {
+ var importerModule = module.importers[i];
+ if (!importerModule.locked) {
+ var importerIndex = indexOf.call(importerModule.dependencies, module);
+ var setter = importerModule.setters[importerIndex];
+ if (setter)
+ setter(exports);
+ }
+ }
+
+ module.locked = false;
+ return value;
+ }, { id: entry.name });
+
+ if (typeof declaration == 'function')
+ declaration = { setters: [], execute: declaration };
+
+ // allowing undefined declaration was a mistake! To be deprecated.
+ declaration = declaration || { setters: [], execute: function() {} };
+
+ module.setters = declaration.setters;
+ module.execute = declaration.execute;
+
+ if (!module.setters || !module.execute) {
+ throw new TypeError('Invalid System.register form for ' + entry.name);
+ }
+
+ // now link all the module dependencies
+ for (var i = 0, l = entry.normalizedDeps.length; i < l; i++) {
+ var depName = entry.normalizedDeps[i];
+ var depEntry = loader.defined[depName];
+ var depModule = moduleRecords[depName];
+
+ // work out how to set depExports based on scenarios...
+ var depExports;
+
+ if (depModule) {
+ depExports = depModule.exports;
+ }
+ // dynamic, already linked in our registry
+ else if (depEntry && !depEntry.declarative) {
+ depExports = depEntry.esModule;
+ }
+ // in the loader registry
+ else if (!depEntry) {
+ depExports = loader.get(depName);
+ }
+ // we have an entry -> link
+ else {
+ linkDeclarativeModule(depEntry, loader);
+ depModule = depEntry.module;
+ depExports = depModule.exports;
+ }
+
+ // only declarative modules have dynamic bindings
+ if (depModule && depModule.importers) {
+ depModule.importers.push(module);
+ module.dependencies.push(depModule);
+ }
+ else {
+ module.dependencies.push(null);
+ }
+
+ // run setters for all entries with the matching dependency name
+ var originalIndices = entry.originalIndices[i];
+ for (var j = 0, len = originalIndices.length; j < len; ++j) {
+ var index = originalIndices[j];
+ if (module.setters[index]) {
+ module.setters[index](depExports);
+ }
+ }
+ }
+ }
+
+ // An analog to loader.get covering execution of all three layers (real declarative, simulated declarative, simulated dynamic)
+ function getModule(name, loader) {
+ var exports;
+ var entry = loader.defined[name];
+
+ if (!entry) {
+ exports = loader.get(name);
+ if (!exports)
+ throw new Error('Unable to load dependency ' + name + '.');
+ }
+
+ else {
+ if (entry.declarative)
+ ensureEvaluated(name, entry, [], loader);
+
+ else if (!entry.evaluated)
+ linkDynamicModule(entry, loader);
+
+ exports = entry.module.exports;
+ }
+
+ if ((!entry || entry.declarative) && exports && exports.__useDefault)
+ return exports['default'];
+
+ return exports;
+ }
+
+ function linkDynamicModule(entry, loader) {
+ if (entry.module)
+ return;
+
+ var exports = {};
+
+ var module = entry.module = { exports: exports, id: entry.name };
+
+ // AMD requires execute the tree first
+ if (!entry.executingRequire) {
+ for (var i = 0, l = entry.normalizedDeps.length; i < l; i++) {
+ var depName = entry.normalizedDeps[i];
+ // we know we only need to link dynamic due to linking algorithm
+ var depEntry = loader.defined[depName];
+ if (depEntry)
+ linkDynamicModule(depEntry, loader);
+ }
+ }
+
+ // now execute
+ entry.evaluated = true;
+ var output = entry.execute.call(__global, function(name) {
+ for (var i = 0, l = entry.deps.length; i < l; i++) {
+ if (entry.deps[i] != name)
+ continue;
+ return getModule(entry.normalizedDeps[i], loader);
+ }
+ // try and normalize the dependency to see if we have another form
+ var nameNormalized = loader.normalizeSync(name, entry.name);
+ if (indexOf.call(entry.normalizedDeps, nameNormalized) != -1)
+ return getModule(nameNormalized, loader);
+
+ throw new Error('Module ' + name + ' not declared as a dependency of ' + entry.name);
+ }, exports, module);
+
+ if (output !== undefined)
+ module.exports = output;
+
+ // create the esModule object, which allows ES6 named imports of dynamics
+ exports = module.exports;
+
+ // __esModule flag treats as already-named
+ if (exports && (exports.__esModule || exports instanceof Module))
+ entry.esModule = loader.newModule(exports);
+ // set module as 'default' export, then fake named exports by iterating properties
+ else if (entry.esmExports && exports !== __global)
+ entry.esModule = loader.newModule(getESModule(exports));
+ // just use the 'default' export
+ else
+ entry.esModule = loader.newModule({ 'default': exports, __useDefault: true });
+ }
+
+ /*
+ * Given a module, and the list of modules for this current branch,
+ * ensure that each of the dependencies of this module is evaluated
+ * (unless one is a circular dependency already in the list of seen
+ * modules, in which case we execute it)
+ *
+ * Then we evaluate the module itself depth-first left to right
+ * execution to match ES6 modules
+ */
+ function ensureEvaluated(moduleName, entry, seen, loader) {
+ // if already seen, that means it's an already-evaluated non circular dependency
+ if (!entry || entry.evaluated || !entry.declarative)
+ return;
+
+ // this only applies to declarative modules which late-execute
+
+ seen.push(moduleName);
+
+ for (var i = 0, l = entry.normalizedDeps.length; i < l; i++) {
+ var depName = entry.normalizedDeps[i];
+ if (indexOf.call(seen, depName) == -1) {
+ if (!loader.defined[depName])
+ loader.get(depName);
+ else
+ ensureEvaluated(depName, loader.defined[depName], seen, loader);
+ }
+ }
+
+ if (entry.evaluated)
+ return;
+
+ entry.evaluated = true;
+ entry.module.execute.call(__global);
+ }
+
+ // override the delete method to also clear the register caches
+ hook('delete', function(del) {
+ return function(name) {
+ delete this._loader.moduleRecords[name];
+ delete this.defined[name];
+ return del.call(this, name);
+ };
+ });
+
+ hook('fetch', function(fetch) {
+ return function(load) {
+ if (this.defined[load.name]) {
+ load.metadata.format = 'defined';
+ return '';
+ }
+
+ load.metadata.deps = load.metadata.deps || [];
+
+ return fetch.call(this, load);
+ };
+ });
+
+ hook('translate', function(translate) {
+ // we run the meta detection here (register is after meta)
+ return function(load) {
+ load.metadata.deps = load.metadata.deps || [];
+ return Promise.resolve(translate.apply(this, arguments)).then(function(source) {
+ // run detection for register format
+ if (load.metadata.format == 'register' || !load.metadata.format && detectRegisterFormat(load.source))
+ load.metadata.format = 'register';
+ return source;
+ });
+ };
+ });
+
+ // implement a perforance shortpath for System.load with no deps
+ hook('load', function(doLoad) {
+ return function(normalized) {
+ var loader = this;
+ var entry = loader.defined[normalized];
+
+ if (!entry || entry.deps.length)
+ return doLoad.apply(this, arguments);
+
+ entry.originalIndices = entry.normalizedDeps = [];
+
+ // recursively ensure that the module and all its
+ // dependencies are linked (with dependency group handling)
+ link(normalized, entry, loader);
+
+ // now handle dependency execution in correct order
+ ensureEvaluated(normalized, entry, [], loader);
+ if (!entry.esModule)
+ entry.esModule = loader.newModule(entry.module.exports);
+
+ // remove from the registry
+ if (!loader.trace)
+ loader.defined[normalized] = undefined;
+
+ // return the defined module object
+ loader.set(normalized, entry.esModule);
+
+ return Promise.resolve();
+ };
+ });
+
+ hook('instantiate', function(instantiate) {
+ return function(load) {
+ if (load.metadata.format == 'detect')
+ load.metadata.format = undefined;
+
+ // assumes previous instantiate is sync
+ // (core json support)
+ instantiate.call(this, load);
+
+ var loader = this;
+
+ var entry;
+
+ // first we check if this module has already been defined in the registry
+ if (loader.defined[load.name]) {
+ entry = loader.defined[load.name];
+ // don't support deps for ES modules
+ if (!entry.declarative)
+ entry.deps = entry.deps.concat(load.metadata.deps);
+ entry.deps = entry.deps.concat(load.metadata.deps);
+ }
+
+ // picked up already by an anonymous System.register script injection
+ // or via the dynamic formats
+ else if (load.metadata.entry) {
+ entry = load.metadata.entry;
+ entry.deps = entry.deps.concat(load.metadata.deps);
+ }
+
+ // Contains System.register calls
+ // (dont run bundles in the builder)
+ else if (!(loader.builder && load.metadata.bundle)
+ && (load.metadata.format == 'register' || load.metadata.format == 'esm' || load.metadata.format == 'es6')) {
+
+ if (typeof __exec != 'undefined')
+ __exec.call(loader, load);
+
+ if (!load.metadata.entry && !load.metadata.bundle)
+ throw new Error(load.name + ' detected as ' + load.metadata.format + ' but didn\'t execute.');
+
+ entry = load.metadata.entry;
+
+ // support metadata deps for System.register
+ if (entry && load.metadata.deps)
+ entry.deps = entry.deps.concat(load.metadata.deps);
+ }
+
+ // named bundles are just an empty module
+ if (!entry) {
+ entry = createEntry();
+ entry.deps = load.metadata.deps;
+ entry.execute = function() {};
+ }
+
+ // place this module onto defined for circular references
+ loader.defined[load.name] = entry;
+
+ var grouped = group(entry.deps);
+
+ entry.deps = grouped.names;
+ entry.originalIndices = grouped.indices;
+ entry.name = load.name;
+ entry.esmExports = load.metadata.esmExports !== false;
+
+ // first, normalize all dependencies
+ var normalizePromises = [];
+ for (var i = 0, l = entry.deps.length; i < l; i++)
+ normalizePromises.push(Promise.resolve(loader.normalize(entry.deps[i], load.name)));
+
+ return Promise.all(normalizePromises).then(function(normalizedDeps) {
+
+ entry.normalizedDeps = normalizedDeps;
+
+ return {
+ deps: entry.deps,
+ execute: function() {
+ // recursively ensure that the module and all its
+ // dependencies are linked (with dependency group handling)
+ link(load.name, entry, loader);
+
+ // now handle dependency execution in correct order
+ ensureEvaluated(load.name, entry, [], loader);
+
+ if (!entry.esModule)
+ entry.esModule = loader.newModule(entry.module.exports);
+
+ // remove from the registry
+ if (!loader.trace)
+ loader.defined[load.name] = undefined;
+
+ // return the defined module object
+ return entry.esModule;
+ }
+ };
+ });
+ };
+ });
+})();
+
+
+function getGlobalValue(exports) {
+ if (typeof exports == 'string')
+ return readMemberExpression(exports, __global);
+
+ if (!(exports instanceof Array))
+ throw new Error('Global exports must be a string or array.');
+
+ var globalValue = {};
+ var first = true;
+ for (var i = 0; i < exports.length; i++) {
+ var val = readMemberExpression(exports[i], __global);
+ if (first) {
+ globalValue['default'] = val;
+ first = false;
+ }
+ globalValue[exports[i].split('.').pop()] = val;
+ }
+ return globalValue;
+}
+
+hook('reduceRegister_', function(reduceRegister) {
+ return function(load, register) {
+ if (register || (!load.metadata.exports && !(isWorker && load.metadata.format == 'global')))
+ return reduceRegister.call(this, load, register);
+
+ load.metadata.format = 'global';
+ var entry = load.metadata.entry = createEntry();
+ entry.deps = load.metadata.deps;
+ var globalValue = getGlobalValue(load.metadata.exports);
+ entry.execute = function() {
+ return globalValue;
+ };
+ };
+});
+
+hookConstructor(function(constructor) {
+ return function() {
+ var loader = this;
+ constructor.call(loader);
+
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+
+ // bare minimum ignores
+ var ignoredGlobalProps = ['_g', 'sessionStorage', 'localStorage', 'clipboardData', 'frames', 'frameElement', 'external',
+ 'mozAnimationStartTime', 'webkitStorageInfo', 'webkitIndexedDB', 'mozInnerScreenY', 'mozInnerScreenX'];
+
+ var globalSnapshot;
+
+ function forEachGlobal(callback) {
+ if (Object.keys)
+ Object.keys(__global).forEach(callback);
+ else
+ for (var g in __global) {
+ if (!hasOwnProperty.call(__global, g))
+ continue;
+ callback(g);
+ }
+ }
+
+ function forEachGlobalValue(callback) {
+ forEachGlobal(function(globalName) {
+ if (indexOf.call(ignoredGlobalProps, globalName) != -1)
+ return;
+ try {
+ var value = __global[globalName];
+ }
+ catch (e) {
+ ignoredGlobalProps.push(globalName);
+ }
+ callback(globalName, value);
+ });
+ }
+
+ loader.set('@@global-helpers', loader.newModule({
+ prepareGlobal: function(moduleName, exports, globals, encapsulate) {
+ // disable module detection
+ var curDefine = __global.define;
+
+ __global.define = undefined;
+
+ // set globals
+ var oldGlobals;
+ if (globals) {
+ oldGlobals = {};
+ for (var g in globals) {
+ oldGlobals[g] = __global[g];
+ __global[g] = globals[g];
+ }
+ }
+
+ // store a complete copy of the global object in order to detect changes
+ if (!exports) {
+ globalSnapshot = {};
+
+ forEachGlobalValue(function(name, value) {
+ globalSnapshot[name] = value;
+ });
+ }
+
+ // return function to retrieve global
+ return function() {
+ var globalValue = exports ? getGlobalValue(exports) : {};
+
+ var singleGlobal;
+ var multipleExports = !!exports;
+
+ if (!exports || encapsulate)
+ forEachGlobalValue(function(name, value) {
+ if (globalSnapshot[name] === value)
+ return;
+ if (typeof value == 'undefined')
+ return;
+
+ // allow global encapsulation where globals are removed
+ if (encapsulate)
+ __global[name] = undefined;
+
+ if (!exports) {
+ globalValue[name] = value;
+
+ if (typeof singleGlobal != 'undefined') {
+ if (!multipleExports && singleGlobal !== value)
+ multipleExports = true;
+ }
+ else {
+ singleGlobal = value;
+ }
+ }
+ });
+
+ globalValue = multipleExports ? globalValue : singleGlobal;
+
+ // revert globals
+ if (oldGlobals) {
+ for (var g in oldGlobals)
+ __global[g] = oldGlobals[g];
+ }
+ __global.define = curDefine;
+
+ return globalValue;
+ };
+ }
+ }));
+ };
+});
+hookConstructor(function(constructor) {
+ return function() {
+ var loader = this;
+ constructor.call(loader);
+
+ if (typeof window != 'undefined' && typeof document != 'undefined' && window.location)
+ var windowOrigin = location.protocol + '//' + location.hostname + (location.port ? ':' + location.port : '');
+
+ function stripOrigin(path) {
+ if (path.substr(0, 8) == 'file:///')
+ return path.substr(7 + !!isWindows);
+
+ if (windowOrigin && path.substr(0, windowOrigin.length) == windowOrigin)
+ return path.substr(windowOrigin.length);
+
+ return path;
+ }
+
+ loader.set('@@cjs-helpers', loader.newModule({
+ requireResolve: function(request, parentId) {
+ return stripOrigin(loader.normalizeSync(request, parentId));
+ },
+ getPathVars: function(moduleId) {
+ // remove any plugin syntax
+ var pluginIndex = moduleId.lastIndexOf('!');
+ var filename;
+ if (pluginIndex != -1)
+ filename = moduleId.substr(0, pluginIndex);
+ else
+ filename = moduleId;
+
+ var dirname = filename.split('/');
+ dirname.pop();
+ dirname = dirname.join('/');
+
+ return {
+ filename: stripOrigin(filename),
+ dirname: stripOrigin(dirname)
+ };
+ }
+ }))
+ };
+});/*
+ * AMD Helper function module
+ * Separated into its own file as this is the part needed for full AMD support in SFX builds
+ * NB since implementations have now diverged this can be merged back with amd.js
+ */
+
+hook('fetch', function(fetch) {
+ return function(load) {
+ // script load implies define global leak
+ if (load.metadata.scriptLoad && isBrowser)
+ __global.define = this.amdDefine;
+ return fetch.call(this, load);
+ };
+});
+
+hookConstructor(function(constructor) {
+ return function() {
+ var loader = this;
+ constructor.call(this);
+
+ var commentRegEx = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg;
+ var cjsRequirePre = "(?:^|[^$_a-zA-Z\\xA0-\\uFFFF.])";
+ var cjsRequirePost = "\\s*\\(\\s*(\"([^\"]+)\"|'([^']+)')\\s*\\)";
+ var fnBracketRegEx = /\(([^\)]*)\)/;
+ var wsRegEx = /^\s+|\s+$/g;
+
+ var requireRegExs = {};
+
+ function getCJSDeps(source, requireIndex) {
+
+ // remove comments
+ source = source.replace(commentRegEx, '');
+
+ // determine the require alias
+ var params = source.match(fnBracketRegEx);
+ var requireAlias = (params[1].split(',')[requireIndex] || 'require').replace(wsRegEx, '');
+
+ // find or generate the regex for this requireAlias
+ var requireRegEx = requireRegExs[requireAlias] || (requireRegExs[requireAlias] = new RegExp(cjsRequirePre + requireAlias + cjsRequirePost, 'g'));
+
+ requireRegEx.lastIndex = 0;
+
+ var deps = [];
+
+ var match;
+ while (match = requireRegEx.exec(source))
+ deps.push(match[2] || match[3]);
+
+ return deps;
+ }
+
+ /*
+ AMD-compatible require
+ To copy RequireJS, set window.require = window.requirejs = loader.amdRequire
+ */
+ function require(names, callback, errback, referer) {
+ // in amd, first arg can be a config object... we just ignore
+ if (typeof names == 'object' && !(names instanceof Array))
+ return require.apply(null, Array.prototype.splice.call(arguments, 1, arguments.length - 1));
+
+ // amd require
+ if (typeof names == 'string' && typeof callback == 'function')
+ names = [names];
+ if (names instanceof Array) {
+ var dynamicRequires = [];
+ for (var i = 0; i < names.length; i++)
+ dynamicRequires.push(loader['import'](names[i], referer));
+ Promise.all(dynamicRequires).then(function(modules) {
+ if (callback)
+ callback.apply(null, modules);
+ }, errback);
+ }
+
+ // commonjs require
+ else if (typeof names == 'string') {
+ var defaultJSExtension = loader.defaultJSExtensions && names.substr(names.length - 3, 3) != '.js';
+ var normalized = loader.decanonicalize(names, referer);
+ if (defaultJSExtension && normalized.substr(normalized.length - 3, 3) == '.js')
+ normalized = normalized.substr(0, normalized.length - 3);
+ var module = loader.get(normalized);
+ if (!module)
+ throw new Error('Module not already loaded loading "' + names + '" as ' + normalized + (referer ? ' from "' + referer + '".' : '.'));
+ return module.__useDefault ? module['default'] : module;
+ }
+
+ else
+ throw new TypeError('Invalid require');
+ }
+
+ function define(name, deps, factory) {
+ if (typeof name != 'string') {
+ factory = deps;
+ deps = name;
+ name = null;
+ }
+ if (!(deps instanceof Array)) {
+ factory = deps;
+ deps = ['require', 'exports', 'module'].splice(0, factory.length);
+ }
+
+ if (typeof factory != 'function')
+ factory = (function(factory) {
+ return function() { return factory; }
+ })(factory);
+
+ // in IE8, a trailing comma becomes a trailing undefined entry
+ if (deps[deps.length - 1] === undefined)
+ deps.pop();
+
+ // remove system dependencies
+ var requireIndex, exportsIndex, moduleIndex;
+
+ if ((requireIndex = indexOf.call(deps, 'require')) != -1) {
+
+ deps.splice(requireIndex, 1);
+
+ // only trace cjs requires for non-named
+ // named defines assume the trace has already been done
+ if (!name)
+ deps = deps.concat(getCJSDeps(factory.toString(), requireIndex));
+ }
+
+ if ((exportsIndex = indexOf.call(deps, 'exports')) != -1)
+ deps.splice(exportsIndex, 1);
+
+ if ((moduleIndex = indexOf.call(deps, 'module')) != -1)
+ deps.splice(moduleIndex, 1);
+
+ function execute(req, exports, module) {
+ var depValues = [];
+ for (var i = 0; i < deps.length; i++)
+ depValues.push(req(deps[i]));
+
+ module.uri = module.id;
+
+ module.config = function() {};
+
+ // add back in system dependencies
+ if (moduleIndex != -1)
+ depValues.splice(moduleIndex, 0, module);
+
+ if (exportsIndex != -1)
+ depValues.splice(exportsIndex, 0, exports);
+
+ if (requireIndex != -1) {
+ function contextualRequire(names, callback, errback) {
+ if (typeof names == 'string' && typeof callback != 'function')
+ return req(names);
+ return require.call(loader, names, callback, errback, module.id);
+ }
+ contextualRequire.toUrl = function(name) {
+ // normalize without defaultJSExtensions
+ var defaultJSExtension = loader.defaultJSExtensions && name.substr(name.length - 3, 3) != '.js';
+ var url = loader.decanonicalize(name, module.id);
+ if (defaultJSExtension && url.substr(url.length - 3, 3) == '.js')
+ url = url.substr(0, url.length - 3);
+ return url;
+ };
+ depValues.splice(requireIndex, 0, contextualRequire);
+ }
+
+ // set global require to AMD require
+ var curRequire = __global.require;
+ __global.require = require;
+
+ var output = factory.apply(exportsIndex == -1 ? __global : exports, depValues);
+
+ __global.require = curRequire;
+
+ if (typeof output == 'undefined' && module)
+ output = module.exports;
+
+ if (typeof output != 'undefined')
+ return output;
+ }
+
+ var entry = createEntry();
+ entry.name = name && (loader.decanonicalize || loader.normalize).call(loader, name);
+ entry.deps = deps;
+ entry.execute = execute;
+
+ loader.pushRegister_({
+ amd: true,
+ entry: entry
+ });
+ }
+ define.amd = {};
+
+ // reduction function to attach defines to a load record
+ hook('reduceRegister_', function(reduceRegister) {
+ return function(load, register) {
+ // only handle AMD registers here
+ if (!register || !register.amd)
+ return reduceRegister.call(this, load, register);
+
+ var curMeta = load && load.metadata;
+ var entry = register.entry;
+
+ if (curMeta) {
+ if (!curMeta.format || curMeta.format == 'detect')
+ curMeta.format = 'amd';
+ else if (!entry.name && curMeta.format != 'amd')
+ throw new Error('AMD define called while executing ' + curMeta.format + ' module ' + load.name);
+ }
+
+ // anonymous define
+ if (!entry.name) {
+ if (!curMeta)
+ throw new TypeError('Unexpected anonymous AMD define.');
+
+ if (curMeta.entry && !curMeta.entry.name)
+ throw new Error('Multiple anonymous defines in module ' + load.name);
+
+ curMeta.entry = entry;
+ }
+ // named define
+ else {
+ // if we don't have any other defines,
+ // then let this be an anonymous define
+ // this is just to support single modules of the form:
+ // define('jquery')
+ // still loading anonymously
+ // because it is done widely enough to be useful
+ // as soon as there is more than one define, this gets removed though
+ if (curMeta) {
+ if (!curMeta.entry && !curMeta.bundle)
+ curMeta.entry = entry;
+ else if (curMeta.entry && curMeta.entry.name && curMeta.entry.name != load.name)
+ curMeta.entry = undefined;
+
+ // note this is now a bundle
+ curMeta.bundle = true;
+ }
+
+ // define the module through the register registry
+ if (!(entry.name in this.defined))
+ this.defined[entry.name] = entry;
+ }
+ };
+ });
+
+ loader.amdDefine = define;
+ loader.amdRequire = require;
+ };
+});/*
+ SystemJS Loader Plugin Support
+
+ Supports plugin loader syntax with "!", or via metadata.loader
+
+ The plugin name is loaded as a module itself, and can override standard loader hooks
+ for the plugin resource. See the plugin section of the systemjs readme.
+*/
+
+(function() {
+ function getParentName(loader, parentName) {
+ // if parent is a plugin, normalize against the parent plugin argument only
+ if (parentName) {
+ var parentPluginIndex;
+ if (loader.pluginFirst) {
+ if ((parentPluginIndex = parentName.lastIndexOf('!')) != -1)
+ return parentName.substr(parentPluginIndex + 1);
+ }
+ else {
+ if ((parentPluginIndex = parentName.indexOf('!')) != -1)
+ return parentName.substr(0, parentPluginIndex);
+ }
+
+ return parentName;
+ }
+ }
+
+ function parsePlugin(loader, name) {
+ var argumentName;
+ var pluginName;
+
+ var pluginIndex = name.lastIndexOf('!');
+
+ if (pluginIndex == -1)
+ return;
+
+ if (loader.pluginFirst) {
+ argumentName = name.substr(pluginIndex + 1);
+ pluginName = name.substr(0, pluginIndex);
+ }
+ else {
+ argumentName = name.substr(0, pluginIndex);
+ pluginName = name.substr(pluginIndex + 1) || argumentName.substr(argumentName.lastIndexOf('.') + 1);
+ }
+
+ return {
+ argument: argumentName,
+ plugin: pluginName
+ };
+ }
+
+ // put name back together after parts have been normalized
+ function combinePluginParts(loader, argumentName, pluginName, defaultExtension) {
+ if (defaultExtension && argumentName.substr(argumentName.length - 3, 3) == '.js')
+ argumentName = argumentName.substr(0, argumentName.length - 3);
+
+ if (loader.pluginFirst) {
+ return pluginName + '!' + argumentName;
+ }
+ else {
+ return argumentName + '!' + pluginName;
+ }
+ }
+
+ // note if normalize will add a default js extension
+ // if so, remove for backwards compat
+ // this is strange and sucks, but will be deprecated
+ function checkDefaultExtension(loader, arg) {
+ return loader.defaultJSExtensions && arg.substr(arg.length - 3, 3) != '.js';
+ }
+
+ function createNormalizeSync(normalizeSync) {
+ return function(name, parentName, isPlugin) {
+ var loader = this;
+
+ var parsed = parsePlugin(loader, name);
+ parentName = getParentName(this, parentName);
+
+ if (!parsed)
+ return normalizeSync.call(this, name, parentName, isPlugin);
+
+ // if this is a plugin, normalize the plugin name and the argument
+ var argumentName = loader.normalizeSync(parsed.argument, parentName, true);
+ var pluginName = loader.normalizeSync(parsed.plugin, parentName, true);
+ return combinePluginParts(loader, argumentName, pluginName, checkDefaultExtension(loader, parsed.argument));
+ };
+ }
+
+ hook('decanonicalize', createNormalizeSync);
+ hook('normalizeSync', createNormalizeSync);
+
+ hook('normalize', function(normalize) {
+ return function(name, parentName, isPlugin) {
+ var loader = this;
+
+ parentName = getParentName(this, parentName);
+
+ var parsed = parsePlugin(loader, name);
+
+ if (!parsed)
+ return normalize.call(loader, name, parentName, isPlugin);
+
+ return Promise.all([
+ loader.normalize(parsed.argument, parentName, true),
+ loader.normalize(parsed.plugin, parentName, false)
+ ])
+ .then(function(normalized) {
+ return combinePluginParts(loader, normalized[0], normalized[1], checkDefaultExtension(loader, parsed.argument));
+ });
+ }
+ });
+
+ hook('locate', function(locate) {
+ return function(load) {
+ var loader = this;
+
+ var name = load.name;
+
+ // plugin syntax
+ var pluginSyntaxIndex;
+ if (loader.pluginFirst) {
+ if ((pluginSyntaxIndex = name.indexOf('!')) != -1) {
+ load.metadata.loader = name.substr(0, pluginSyntaxIndex);
+ load.name = name.substr(pluginSyntaxIndex + 1);
+ }
+ }
+ else {
+ if ((pluginSyntaxIndex = name.lastIndexOf('!')) != -1) {
+ load.metadata.loader = name.substr(pluginSyntaxIndex + 1);
+ load.name = name.substr(0, pluginSyntaxIndex);
+ }
+ }
+
+ return locate.call(loader, load)
+ .then(function(address) {
+ if (pluginSyntaxIndex != -1 || !load.metadata.loader)
+ return address;
+
+ // normalize plugin relative to parent in locate here when
+ // using plugin via loader metadata
+ return (loader.pluginLoader || loader).normalize(load.metadata.loader, load.name)
+ .then(function(loaderNormalized) {
+ load.metadata.loader = loaderNormalized;
+ return address;
+ });
+ })
+ .then(function(address) {
+ var plugin = load.metadata.loader;
+
+ if (!plugin)
+ return address;
+
+ // don't allow a plugin to load itself
+ if (load.name == plugin)
+ throw new Error('Plugin ' + plugin + ' cannot load itself, make sure it is excluded from any wildcard meta configuration via a custom loader: false rule.');
+
+ // only fetch the plugin itself if this name isn't defined
+ if (loader.defined && loader.defined[name])
+ return address;
+
+ var pluginLoader = loader.pluginLoader || loader;
+
+ // load the plugin module and run standard locate
+ return pluginLoader['import'](plugin)
+ .then(function(loaderModule) {
+ // store the plugin module itself on the metadata
+ load.metadata.loaderModule = loaderModule;
+
+ load.address = address;
+ if (loaderModule.locate)
+ return loaderModule.locate.call(loader, load);
+
+ return address;
+ });
+ });
+ };
+ });
+
+ hook('fetch', function(fetch) {
+ return function(load) {
+ var loader = this;
+ if (load.metadata.loaderModule && load.metadata.loaderModule.fetch && load.metadata.format != 'defined') {
+ load.metadata.scriptLoad = false;
+ return load.metadata.loaderModule.fetch.call(loader, load, function(load) {
+ return fetch.call(loader, load);
+ });
+ }
+ else {
+ return fetch.call(loader, load);
+ }
+ };
+ });
+
+ hook('translate', function(translate) {
+ return function(load) {
+ var loader = this;
+ var args = arguments;
+ if (load.metadata.loaderModule && load.metadata.loaderModule.translate && load.metadata.format != 'defined') {
+ return Promise.resolve(load.metadata.loaderModule.translate.apply(loader, args)).then(function(result) {
+ var sourceMap = load.metadata.sourceMap;
+
+ // sanitize sourceMap if an object not a JSON string
+ if (sourceMap) {
+ if (typeof sourceMap != 'object')
+ throw new Error('load.metadata.sourceMap must be set to an object.');
+
+ var originalName = load.address.split('!')[0];
+
+ // force set the filename of the original file
+ if (!sourceMap.file || sourceMap.file == load.address)
+ sourceMap.file = originalName + '!transpiled';
+
+ // force set the sources list if only one source
+ if (!sourceMap.sources || sourceMap.sources.length <= 1 && (!sourceMap.sources[0] || sourceMap.sources[0] == load.address))
+ sourceMap.sources = [originalName];
+ }
+
+ // if running on file:/// URLs, sourcesContent is necessary
+ // load.metadata.sourceMap.sourcesContent = [load.source];
+
+ if (typeof result == 'string')
+ load.source = result;
+ else
+ warn.call(this, 'Plugin ' + load.metadata.loader + ' should return the source in translate, instead of setting load.source directly. This support will be deprecated.');
+
+ return translate.apply(loader, args);
+ });
+ }
+ else {
+ return translate.apply(loader, args);
+ }
+ };
+ });
+
+ hook('instantiate', function(instantiate) {
+ return function(load) {
+ var loader = this;
+ var calledInstantiate = false;
+
+ if (load.metadata.loaderModule && load.metadata.loaderModule.instantiate && !loader.builder && load.metadata.format != 'defined')
+ return Promise.resolve(load.metadata.loaderModule.instantiate.call(loader, load, function(load) {
+ if (calledInstantiate)
+ throw new Error('Instantiate must only be called once.');
+ calledInstantiate = true;
+ return instantiate.call(loader, load);
+ })).then(function(result) {
+ if (calledInstantiate)
+ return result;
+
+ load.metadata.entry = createEntry();
+ load.metadata.entry.execute = function() {
+ return result;
+ }
+ load.metadata.entry.deps = load.metadata.deps;
+ load.metadata.format = 'defined';
+ return instantiate.call(loader, load);
+ });
+ else
+ return instantiate.call(loader, load);
+ };
+ });
+
+})();/*
+ * Conditions Extension
+ *
+ * Allows a condition module to alter the resolution of an import via syntax:
+ *
+ * import $ from 'jquery/#{browser}';
+ *
+ * Will first load the module 'browser' via `SystemJS.import('browser')` and
+ * take the default export of that module.
+ * If the default export is not a string, an error is thrown.
+ *
+ * We then substitute the string into the require to get the conditional resolution
+ * enabling environment-specific variations like:
+ *
+ * import $ from 'jquery/ie'
+ * import $ from 'jquery/firefox'
+ * import $ from 'jquery/chrome'
+ * import $ from 'jquery/safari'
+ *
+ * It can be useful for a condition module to define multiple conditions.
+ * This can be done via the `|` modifier to specify an export member expression:
+ *
+ * import 'jquery/#{./browser.js|grade.version}'
+ *
+ * Where the `grade` export `version` member in the `browser.js` module is substituted.
+ *
+ *
+ * Boolean Conditionals
+ *
+ * For polyfill modules, that are used as imports but have no module value,
+ * a binary conditional allows a module not to be loaded at all if not needed:
+ *
+ * import 'es5-shim#?./conditions.js|needs-es5shim'
+ *
+ * These conditions can also be negated via:
+ *
+ * import 'es5-shim#?./conditions.js|~es6'
+ *
+ */
+
+ var sysConditions = ['browser', 'node', 'dev', 'build', 'production', 'default'];
+
+ function parseCondition(condition) {
+ var conditionExport, conditionModule, negation;
+
+ var negation = condition[0] == '~';
+ var conditionExportIndex = condition.lastIndexOf('|');
+ if (conditionExportIndex != -1) {
+ conditionExport = condition.substr(conditionExportIndex + 1);
+ conditionModule = condition.substr(negation, conditionExportIndex - negation);
+
+ if (negation)
+ warn.call(this, 'Condition negation form "' + condition + '" is deprecated for "' + conditionModule + '|~' + conditionExport + '"');
+
+ if (conditionExport[0] == '~') {
+ negation = true;
+ conditionExport = conditionExport.substr(1);
+ }
+ }
+ else {
+ conditionExport = 'default';
+ conditionModule = condition.substr(negation);
+ if (sysConditions.indexOf(conditionModule) != -1) {
+ conditionExport = conditionModule;
+ conditionModule = null;
+ }
+ }
+
+ return {
+ module: conditionModule || '@system-env',
+ prop: conditionExport,
+ negate: negation
+ };
+ }
+
+ function serializeCondition(conditionObj) {
+ return conditionObj.module + '|' + (conditionObj.negate ? '~' : '') + conditionObj.prop;
+ }
+
+ function resolveCondition(conditionObj, parentName, bool) {
+ var self = this;
+ return this.normalize(conditionObj.module, parentName)
+ .then(function(normalizedCondition) {
+ return self.load(normalizedCondition)
+ .then(function(q) {
+ var m = readMemberExpression(conditionObj.prop, self.get(normalizedCondition));
+
+ if (bool && typeof m != 'boolean')
+ throw new TypeError('Condition ' + serializeCondition(conditionObj) + ' did not resolve to a boolean.');
+
+ return conditionObj.negate ? !m : m;
+ });
+ });
+ }
+
+ var interpolationRegEx = /#\{[^\}]+\}/;
+ function interpolateConditional(name, parentName) {
+ // first we normalize the conditional
+ var conditionalMatch = name.match(interpolationRegEx);
+
+ if (!conditionalMatch)
+ return Promise.resolve(name);
+
+ var conditionObj = parseCondition.call(this, conditionalMatch[0].substr(2, conditionalMatch[0].length - 3));
+
+ // in builds, return normalized conditional
+ if (this.builder)
+ return this['normalize'](conditionObj.module, parentName)
+ .then(function(conditionModule) {
+ conditionObj.module = conditionModule;
+ return name.replace(interpolationRegEx, '#{' + serializeCondition(conditionObj) + '}');
+ });
+
+ return resolveCondition.call(this, conditionObj, parentName, false)
+ .then(function(conditionValue) {
+ if (typeof conditionValue !== 'string')
+ throw new TypeError('The condition value for ' + name + ' doesn\'t resolve to a string.');
+
+ if (conditionValue.indexOf('/') != -1)
+ throw new TypeError('Unabled to interpolate conditional ' + name + (parentName ? ' in ' + parentName : '') + '\n\tThe condition value ' + conditionValue + ' cannot contain a "/" separator.');
+
+ return name.replace(interpolationRegEx, conditionValue);
+ });
+ }
+
+ function booleanConditional(name, parentName) {
+ // first we normalize the conditional
+ var booleanIndex = name.lastIndexOf('#?');
+
+ if (booleanIndex == -1)
+ return Promise.resolve(name);
+
+ var conditionObj = parseCondition.call(this, name.substr(booleanIndex + 2));
+
+ // in builds, return normalized conditional
+ if (this.builder)
+ return this['normalize'](conditionObj.module, parentName)
+ .then(function(conditionModule) {
+ conditionObj.module = conditionModule;
+ return name.substr(0, booleanIndex) + '#?' + serializeCondition(conditionObj);
+ });
+
+ return resolveCondition.call(this, conditionObj, parentName, true)
+ .then(function(conditionValue) {
+ return conditionValue ? name.substr(0, booleanIndex) : '@empty';
+ });
+ }
+
+ // normalizeSync does not parse conditionals at all although it could
+ hook('normalize', function(normalize) {
+ return function(name, parentName, skipExt) {
+ var loader = this;
+ return booleanConditional.call(loader, name, parentName)
+ .then(function(name) {
+ return normalize.call(loader, name, parentName, skipExt);
+ })
+ .then(function(normalized) {
+ return interpolateConditional.call(loader, normalized, parentName);
+ });
+ };
+ });
+/*
+ * Alias Extension
+ *
+ * Allows a module to be a plain copy of another module by module name
+ *
+ * SystemJS.meta['mybootstrapalias'] = { alias: 'bootstrap' };
+ *
+ */
+(function() {
+ // aliases
+ hook('fetch', function(fetch) {
+ return function(load) {
+ var alias = load.metadata.alias;
+ var aliasDeps = load.metadata.deps || [];
+ if (alias) {
+ load.metadata.format = 'defined';
+ var entry = createEntry();
+ this.defined[load.name] = entry;
+ entry.declarative = true;
+ entry.deps = aliasDeps.concat([alias]);
+ entry.declare = function(_export) {
+ return {
+ setters: [function(module) {
+ for (var p in module)
+ _export(p, module[p]);
+ if (module.__useDefault)
+ entry.module.exports.__useDefault = true;
+ }],
+ execute: function() {}
+ };
+ };
+ return '';
+ }
+
+ return fetch.call(this, load);
+ };
+ });
+})();/*
+ * Meta Extension
+ *
+ * Sets default metadata on a load record (load.metadata) from
+ * loader.metadata via SystemJS.meta function.
+ *
+ *
+ * Also provides an inline meta syntax for module meta in source.
+ *
+ * Eg:
+ *
+ * loader.meta({
+ * 'my/module': { deps: ['jquery'] }
+ * 'my/*': { format: 'amd' }
+ * });
+ *
+ * Which in turn populates loader.metadata.
+ *
+ * load.metadata.deps and load.metadata.format will then be set
+ * for 'my/module'
+ *
+ * The same meta could be set with a my/module.js file containing:
+ *
+ * my/module.js
+ * "format amd";
+ * "deps[] jquery";
+ * "globals.some value"
+ * console.log('this is my/module');
+ *
+ * Configuration meta always takes preference to inline meta.
+ *
+ * Multiple matches in wildcards are supported and ammend the meta.
+ *
+ *
+ * The benefits of the function form is that paths are URL-normalized
+ * supporting say
+ *
+ * loader.meta({ './app': { format: 'cjs' } });
+ *
+ * Instead of needing to set against the absolute URL (https://site.com/app.js)
+ *
+ */
+
+(function() {
+
+ hookConstructor(function(constructor) {
+ return function() {
+ this.meta = {};
+ constructor.call(this);
+ };
+ });
+
+ hook('locate', function(locate) {
+ return function(load) {
+ var meta = this.meta;
+ var name = load.name;
+
+ // NB for perf, maybe introduce a fast-path wildcard lookup cache here
+ // which is checked first
+
+ // apply wildcard metas
+ var bestDepth = 0;
+ var wildcardIndex;
+ for (var module in meta) {
+ wildcardIndex = module.indexOf('*');
+ if (wildcardIndex === -1)
+ continue;
+ if (module.substr(0, wildcardIndex) === name.substr(0, wildcardIndex)
+ && module.substr(wildcardIndex + 1) === name.substr(name.length - module.length + wildcardIndex + 1)) {
+ var depth = module.split('/').length;
+ if (depth > bestDepth)
+ bestDepth = depth;
+ extendMeta(load.metadata, meta[module], bestDepth != depth);
+ }
+ }
+
+ // apply exact meta
+ if (meta[name])
+ extendMeta(load.metadata, meta[name]);
+
+ return locate.call(this, load);
+ };
+ });
+
+ // detect any meta header syntax
+ // only set if not already set
+ var metaRegEx = /^(\s*\/\*[^\*]*(\*(?!\/)[^\*]*)*\*\/|\s*\/\/[^\n]*|\s*"[^"]+"\s*;?|\s*'[^']+'\s*;?)+/;
+ var metaPartRegEx = /\/\*[^\*]*(\*(?!\/)[^\*]*)*\*\/|\/\/[^\n]*|"[^"]+"\s*;?|'[^']+'\s*;?/g;
+
+ function setMetaProperty(target, p, value) {
+ var pParts = p.split('.');
+ var curPart;
+ while (pParts.length > 1) {
+ curPart = pParts.shift();
+ target = target[curPart] = target[curPart] || {};
+ }
+ curPart = pParts.shift();
+ if (!(curPart in target))
+ target[curPart] = value;
+ }
+
+ hook('translate', function(translate) {
+ return function(load) {
+ // shortpath for bundled
+ if (load.metadata.format == 'defined') {
+ load.metadata.deps = load.metadata.deps || [];
+ return Promise.resolve(load.source);
+ }
+
+ // NB meta will be post-translate pending transpiler conversion to plugins
+ var meta = load.source.match(metaRegEx);
+ if (meta) {
+ var metaParts = meta[0].match(metaPartRegEx);
+
+ for (var i = 0; i < metaParts.length; i++) {
+ var curPart = metaParts[i];
+ var len = curPart.length;
+
+ var firstChar = curPart.substr(0, 1);
+ if (curPart.substr(len - 1, 1) == ';')
+ len--;
+
+ if (firstChar != '"' && firstChar != "'")
+ continue;
+
+ var metaString = curPart.substr(1, curPart.length - 3);
+ var metaName = metaString.substr(0, metaString.indexOf(' '));
+
+ if (metaName) {
+ var metaValue = metaString.substr(metaName.length + 1, metaString.length - metaName.length - 1);
+
+ if (metaName.substr(metaName.length - 2, 2) == '[]') {
+ metaName = metaName.substr(0, metaName.length - 2);
+ load.metadata[metaName] = load.metadata[metaName] || [];
+ load.metadata[metaName].push(metaValue);
+ }
+ else if (load.metadata[metaName] instanceof Array) {
+ // temporary backwards compat for previous "deps" syntax
+ warn.call(this, 'Module ' + load.name + ' contains deprecated "deps ' + metaValue + '" meta syntax.\nThis should be updated to "deps[] ' + metaValue + '" for pushing to array meta.');
+ load.metadata[metaName].push(metaValue);
+ }
+ else {
+ setMetaProperty(load.metadata, metaName, metaValue);
+ }
+ }
+ else {
+ load.metadata[metaString] = true;
+ }
+ }
+ }
+
+ return translate.apply(this, arguments);
+ };
+ });
+})();
+/*
+ System bundles
+
+ Allows a bundle module to be specified which will be dynamically
+ loaded before trying to load a given module.
+
+ For example:
+ SystemJS.bundles['mybundle'] = ['jquery', 'bootstrap/js/bootstrap']
+
+ Will result in a load to "mybundle" whenever a load to "jquery"
+ or "bootstrap/js/bootstrap" is made.
+
+ In this way, the bundle becomes the request that provides the module
+*/
+
+(function() {
+ // bundles support (just like RequireJS)
+ // bundle name is module name of bundle itself
+ // bundle is array of modules defined by the bundle
+ // when a module in the bundle is requested, the bundle is loaded instead
+ // of the form SystemJS.bundles['mybundle'] = ['jquery', 'bootstrap/js/bootstrap']
+ hookConstructor(function(constructor) {
+ return function() {
+ constructor.call(this);
+ this.bundles = {};
+ this._loader.loadedBundles = {};
+ };
+ });
+
+ // assign bundle metadata for bundle loads
+ hook('locate', function(locate) {
+ return function(load) {
+ var loader = this;
+ var matched = false;
+
+ if (!(load.name in loader.defined))
+ for (var b in loader.bundles) {
+ for (var i = 0; i < loader.bundles[b].length; i++) {
+ var curModule = loader.bundles[b][i];
+
+ if (curModule == load.name) {
+ matched = true;
+ break;
+ }
+
+ // wildcard in bundles does not include / boundaries
+ if (curModule.indexOf('*') != -1) {
+ var parts = curModule.split('*');
+ if (parts.length != 2) {
+ loader.bundles[b].splice(i--, 1);
+ continue;
+ }
+
+ if (load.name.substring(0, parts[0].length) == parts[0] &&
+ load.name.substr(load.name.length - parts[1].length, parts[1].length) == parts[1] &&
+ load.name.substr(parts[0].length, load.name.length - parts[1].length - parts[0].length).indexOf('/') == -1) {
+ matched = true;
+ break;
+ }
+ }
+ }
+
+ if (matched)
+ return loader['import'](b)
+ .then(function() {
+ return locate.call(loader, load);
+ });
+ }
+
+ return locate.call(loader, load);
+ };
+ });
+})();
+/*
+ * Dependency Tree Cache
+ *
+ * Allows a build to pre-populate a dependency trace tree on the loader of
+ * the expected dependency tree, to be loaded upfront when requesting the
+ * module, avoinding the n round trips latency of module loading, where
+ * n is the dependency tree depth.
+ *
+ * eg:
+ * SystemJS.depCache = {
+ * 'app': ['normalized', 'deps'],
+ * 'normalized': ['another'],
+ * 'deps': ['tree']
+ * };
+ *
+ * SystemJS.import('app')
+ * // simultaneously starts loading all of:
+ * // 'normalized', 'deps', 'another', 'tree'
+ * // before "app" source is even loaded
+ *
+ */
+
+(function() {
+ hookConstructor(function(constructor) {
+ return function() {
+ constructor.call(this);
+ this.depCache = {};
+ }
+ });
+
+ hook('locate', function(locate) {
+ return function(load) {
+ var loader = this;
+ // load direct deps, in turn will pick up their trace trees
+ var deps = loader.depCache[load.name];
+ if (deps)
+ for (var i = 0; i < deps.length; i++)
+ loader['import'](deps[i], load.name);
+
+ return locate.call(loader, load);
+ };
+ });
+})();
+
+/*
+ * Script-only addition used for production loader
+ *
+ */
+hookConstructor(function(constructor) {
+ return function() {
+ constructor.apply(this, arguments);
+ __global.define = this.amdDefine;
+ };
+});
+
+hook('fetch', function(fetch) {
+ return function(load) {
+ load.metadata.scriptLoad = true;
+ return fetch.call(this, load);
+ };
+});System = new SystemJSLoader();
+
+__global.SystemJS = System;
+System.version = '0.19.39 CSP';
+ if (typeof module == 'object' && module.exports && typeof exports == 'object')
+ module.exports = System;
+
+ __global.System = System;
+
+})(typeof self != 'undefined' ? self : global);}
+
+// auto-load Promise polyfill if needed in the browser
+var doPolyfill = typeof Promise === 'undefined';
+
+// document.write
+if (typeof document !== 'undefined') {
+ var scripts = document.getElementsByTagName('script');
+ $__curScript = scripts[scripts.length - 1];
+ if (document.currentScript && ($__curScript.defer || $__curScript.async))
+ $__curScript = document.currentScript;
+ if (doPolyfill) {
+ var curPath = $__curScript.src;
+ var basePath = curPath.substr(0, curPath.lastIndexOf('/') + 1);
+ window.systemJSBootstrap = bootstrap;
+ document.write(
+ '<' + 'script type="text/javascript" src="' + basePath + 'system-polyfills.js">' + '<' + '/script>'
+ );
+ }
+ else {
+ bootstrap();
+ }
+}
+// importScripts
+else if (typeof importScripts !== 'undefined') {
+ var basePath = '';
+ try {
+ throw new Error('_');
+ } catch (e) {
+ e.stack.replace(/(?:at|@).*(http.+):[\d]+:[\d]+/, function(m, url) {
+ $__curScript = { src: url };
+ basePath = url.replace(/\/[^\/]*$/, '/');
+ });
+ }
+ if (doPolyfill)
+ importScripts(basePath + 'system-polyfills.js');
+ bootstrap();
+}
+else {
+ $__curScript = typeof __filename != 'undefined' ? { src: __filename } : null;
+ bootstrap();
+}
+
+
+})(); \ No newline at end of file
diff --git a/dist/system-polyfills.js b/dist/system-polyfills.js
new file mode 100644
index 000000000..ca76c2418
--- /dev/null
+++ b/dist/system-polyfills.js
@@ -0,0 +1,5 @@
+/*
+ * SystemJS Promise Polyfill
+ */
+!function(t){!function(e){"object"==typeof exports?module.exports=e():"function"==typeof t&&t.amd?t(e):"undefined"!=typeof window?window.Promise=e():"undefined"!=typeof global?global.Promise=e():"undefined"!=typeof self&&(self.Promise=e())}(function(){var t;return function t(e,n,o){function r(u,c){if(!n[u]){if(!e[u]){var f="function"==typeof require&&require;if(!c&&f)return f(u,!0);if(i)return i(u,!0);throw new Error("Cannot find module '"+u+"'")}var s=n[u]={exports:{}};e[u][0].call(s.exports,function(t){var n=e[u][1][t];return r(n?n:t)},s,s.exports,t,e,n,o)}return n[u].exports}for(var i="function"==typeof require&&require,u=0;u<o.length;u++)r(o[u]);return r}({1:[function(t,e,n){var o=t("../lib/decorators/unhandledRejection"),r=o(t("../lib/Promise"));e.exports="undefined"!=typeof global?global.Promise=r:"undefined"!=typeof self?self.Promise=r:r},{"../lib/Promise":2,"../lib/decorators/unhandledRejection":4}],2:[function(e,n,o){!function(t){"use strict";t(function(t){var e=t("./makePromise"),n=t("./Scheduler"),o=t("./env").asap;return e({scheduler:new n(o)})})}("function"==typeof t&&t.amd?t:function(t){n.exports=t(e)})},{"./Scheduler":3,"./env":5,"./makePromise":7}],3:[function(e,n,o){!function(t){"use strict";t(function(){function t(t){this._async=t,this._running=!1,this._queue=this,this._queueLen=0,this._afterQueue={},this._afterQueueLen=0;var e=this;this.drain=function(){e._drain()}}return t.prototype.enqueue=function(t){this._queue[this._queueLen++]=t,this.run()},t.prototype.afterQueue=function(t){this._afterQueue[this._afterQueueLen++]=t,this.run()},t.prototype.run=function(){this._running||(this._running=!0,this._async(this.drain))},t.prototype._drain=function(){for(var t=0;t<this._queueLen;++t)this._queue[t].run(),this._queue[t]=void 0;for(this._queueLen=0,this._running=!1,t=0;t<this._afterQueueLen;++t)this._afterQueue[t].run(),this._afterQueue[t]=void 0;this._afterQueueLen=0},t})}("function"==typeof t&&t.amd?t:function(t){n.exports=t()})},{}],4:[function(e,n,o){!function(t){"use strict";t(function(t){function e(t){throw t}function n(){}var o=t("../env").setTimer,r=t("../format");return function(t){function i(t){t.handled||(l.push(t),a("Potentially unhandled rejection ["+t.id+"] "+r.formatError(t.value)))}function u(t){var e=l.indexOf(t);e>=0&&(l.splice(e,1),h("Handled previous rejection ["+t.id+"] "+r.formatObject(t.value)))}function c(t,e){p.push(t,e),null===d&&(d=o(f,0))}function f(){for(d=null;p.length>0;)p.shift()(p.shift())}var s,a=n,h=n;"undefined"!=typeof console&&(s=console,a="undefined"!=typeof s.error?function(t){s.error(t)}:function(t){s.log(t)},h="undefined"!=typeof s.info?function(t){s.info(t)}:function(t){s.log(t)}),t.onPotentiallyUnhandledRejection=function(t){c(i,t)},t.onPotentiallyUnhandledRejectionHandled=function(t){c(u,t)},t.onFatalRejection=function(t){c(e,t.value)};var p=[],l=[],d=null;return t}})}("function"==typeof t&&t.amd?t:function(t){n.exports=t(e)})},{"../env":5,"../format":6}],5:[function(e,n,o){!function(t){"use strict";t(function(t){function e(){return"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process)}function n(){return"function"==typeof MutationObserver&&MutationObserver||"function"==typeof WebKitMutationObserver&&WebKitMutationObserver}function o(t){function e(){var t=n;n=void 0,t()}var n,o=document.createTextNode(""),r=new t(e);r.observe(o,{characterData:!0});var i=0;return function(t){n=t,o.data=i^=1}}var r,i="undefined"!=typeof setTimeout&&setTimeout,u=function(t,e){return setTimeout(t,e)},c=function(t){return clearTimeout(t)},f=function(t){return i(t,0)};if(e())f=function(t){return process.nextTick(t)};else if(r=n())f=o(r);else if(!i){var s=t,a=s("vertx");u=function(t,e){return a.setTimer(e,t)},c=a.cancelTimer,f=a.runOnLoop||a.runOnContext}return{setTimer:u,clearTimer:c,asap:f}})}("function"==typeof t&&t.amd?t:function(t){n.exports=t(e)})},{}],6:[function(e,n,o){!function(t){"use strict";t(function(){function t(t){var n="object"==typeof t&&null!==t&&(t.stack||t.message)?t.stack||t.message:e(t);return t instanceof Error?n:n+" (WARNING: non-Error used)"}function e(t){var e=String(t);return"[object Object]"===e&&"undefined"!=typeof JSON&&(e=n(t,e)),e}function n(t,e){try{return JSON.stringify(t)}catch(t){return e}}return{formatError:t,formatObject:e,tryStringify:n}})}("function"==typeof t&&t.amd?t:function(t){n.exports=t()})},{}],7:[function(e,n,o){!function(t){"use strict";t(function(){return function(t){function e(t,e){this._handler=t===_?e:n(t)}function n(t){function e(t){r.resolve(t)}function n(t){r.reject(t)}function o(t){r.notify(t)}var r=new b;try{t(e,n,o)}catch(t){n(t)}return r}function o(t){return k(t)?t:new e(_,new x(v(t)))}function r(t){return new e(_,new x(new P(t)))}function i(){return $}function u(){return new e(_,new b)}function c(t,e){var n=new b(t.receiver,t.join().context);return new e(_,n)}function f(t){return a(B,null,t)}function s(t,e){return a(M,t,e)}function a(t,n,o){function r(e,r,u){u.resolved||h(o,i,e,t(n,r,e),u)}function i(t,e,n){a[t]=e,0===--s&&n.become(new q(a))}for(var u,c="function"==typeof n?r:i,f=new b,s=o.length>>>0,a=new Array(s),p=0;p<o.length&&!f.resolved;++p)u=o[p],void 0!==u||p in o?h(o,c,p,u,f):--s;return 0===s&&f.become(new q(a)),new e(_,f)}function h(t,e,n,o,r){if(U(o)){var i=m(o),u=i.state();0===u?i.fold(e,n,void 0,r):u>0?e(n,i.value,r):(r.become(i),p(t,n+1,i))}else e(n,o,r)}function p(t,e,n){for(var o=e;o<t.length;++o)l(v(t[o]),n)}function l(t,e){if(t!==e){var n=t.state();0===n?t.visit(t,void 0,t._unreport):n<0&&t._unreport()}}function d(t){return"object"!=typeof t||null===t?r(new TypeError("non-iterable passed to race()")):0===t.length?i():1===t.length?o(t[0]):y(t)}function y(t){var n,o,r,i=new b;for(n=0;n<t.length;++n)if(o=t[n],void 0!==o||n in t){if(r=v(o),0!==r.state()){i.become(r),p(t,n+1,r);break}r.visit(i,i.resolve,i.reject)}return new e(_,i)}function v(t){return k(t)?t._handler.join():U(t)?j(t):new q(t)}function m(t){return k(t)?t._handler.join():j(t)}function j(t){try{var e=t.then;return"function"==typeof e?new g(e,t):new q(t)}catch(t){return new P(t)}}function _(){}function w(){}function b(t,n){e.createContext(this,n),this.consumers=void 0,this.receiver=t,this.handler=void 0,this.resolved=!1}function x(t){this.handler=t}function g(t,e){b.call(this),G.enqueue(new E(t,e,this))}function q(t){e.createContext(this),this.value=t}function P(t){e.createContext(this),this.id=++Y,this.value=t,this.handled=!1,this.reported=!1,this._report()}function R(t,e){this.rejection=t,this.context=e}function C(t){this.rejection=t}function O(){return new P(new TypeError("Promise cycle"))}function T(t,e){this.continuation=t,this.handler=e}function Q(t,e){this.handler=e,this.value=t}function E(t,e,n){this._then=t,this.thenable=e,this.resolver=n}function L(t,e,n,o,r){try{t.call(e,n,o,r)}catch(t){o(t)}}function S(t,e,n,o){this.f=t,this.z=e,this.c=n,this.to=o,this.resolver=X,this.receiver=this}function k(t){return t instanceof e}function U(t){return("object"==typeof t||"function"==typeof t)&&null!==t}function H(t,n,o,r){return"function"!=typeof t?r.become(n):(e.enterContext(n),F(t,n.value,o,r),void e.exitContext())}function N(t,n,o,r,i){return"function"!=typeof t?i.become(o):(e.enterContext(o),W(t,n,o.value,r,i),void e.exitContext())}function J(t,n,o,r,i){return"function"!=typeof t?i.notify(n):(e.enterContext(o),z(t,n,r,i),void e.exitContext())}function M(t,e,n){try{return t(e,n)}catch(t){return r(t)}}function F(t,e,n,o){try{o.become(v(t.call(n,e)))}catch(t){o.become(new P(t))}}function W(t,e,n,o,r){try{t.call(o,e,n,r)}catch(t){r.become(new P(t))}}function z(t,e,n,o){try{o.notify(t.call(n,e))}catch(t){o.notify(t)}}function A(t,e){e.prototype=V(t.prototype),e.prototype.constructor=e}function B(t,e){return e}function K(){}function D(){return"undefined"!=typeof process&&null!==process&&"function"==typeof process.emit?function(t,e){return"unhandledRejection"===t?process.emit(t,e.value,e):process.emit(t,e)}:"undefined"!=typeof self&&"function"==typeof CustomEvent?function(t,e,n){var o=!1;try{var r=new n("unhandledRejection");o=r instanceof n}catch(t){}return o?function(t,o){var r=new n(t,{detail:{reason:o.value,key:o},bubbles:!1,cancelable:!0});return!e.dispatchEvent(r)}:t}(K,self,CustomEvent):K}var G=t.scheduler,I=D(),V=Object.create||function(t){function e(){}return e.prototype=t,new e};e.resolve=o,e.reject=r,e.never=i,e._defer=u,e._handler=v,e.prototype.then=function(t,e,n){var o=this._handler,r=o.join().state();if("function"!=typeof t&&r>0||"function"!=typeof e&&r<0)return new this.constructor(_,o);var i=this._beget(),u=i._handler;return o.chain(u,o.receiver,t,e,n),i},e.prototype.catch=function(t){return this.then(void 0,t)},e.prototype._beget=function(){return c(this._handler,this.constructor)},e.all=f,e.race=d,e._traverse=s,e._visitRemaining=p,_.prototype.when=_.prototype.become=_.prototype.notify=_.prototype.fail=_.prototype._unreport=_.prototype._report=K,_.prototype._state=0,_.prototype.state=function(){return this._state},_.prototype.join=function(){for(var t=this;void 0!==t.handler;)t=t.handler;return t},_.prototype.chain=function(t,e,n,o,r){this.when({resolver:t,receiver:e,fulfilled:n,rejected:o,progress:r})},_.prototype.visit=function(t,e,n,o){this.chain(X,t,e,n,o)},_.prototype.fold=function(t,e,n,o){this.when(new S(t,e,n,o))},A(_,w),w.prototype.become=function(t){t.fail()};var X=new w;A(_,b),b.prototype._state=0,b.prototype.resolve=function(t){this.become(v(t))},b.prototype.reject=function(t){this.resolved||this.become(new P(t))},b.prototype.join=function(){if(!this.resolved)return this;for(var t=this;void 0!==t.handler;)if(t=t.handler,t===this)return this.handler=O();return t},b.prototype.run=function(){var t=this.consumers,e=this.handler;this.handler=this.handler.join(),this.consumers=void 0;for(var n=0;n<t.length;++n)e.when(t[n])},b.prototype.become=function(t){this.resolved||(this.resolved=!0,this.handler=t,void 0!==this.consumers&&G.enqueue(this),void 0!==this.context&&t._report(this.context))},b.prototype.when=function(t){this.resolved?G.enqueue(new T(t,this.handler)):void 0===this.consumers?this.consumers=[t]:this.consumers.push(t)},b.prototype.notify=function(t){this.resolved||G.enqueue(new Q(t,this))},b.prototype.fail=function(t){var e="undefined"==typeof t?this.context:t;this.resolved&&this.handler.join().fail(e)},b.prototype._report=function(t){this.resolved&&this.handler.join()._report(t)},b.prototype._unreport=function(){this.resolved&&this.handler.join()._unreport()},A(_,x),x.prototype.when=function(t){G.enqueue(new T(t,this))},x.prototype._report=function(t){this.join()._report(t)},x.prototype._unreport=function(){this.join()._unreport()},A(b,g),A(_,q),q.prototype._state=1,q.prototype.fold=function(t,e,n,o){N(t,e,this,n,o)},q.prototype.when=function(t){H(t.fulfilled,this,t.receiver,t.resolver)};var Y=0;A(_,P),P.prototype._state=-1,P.prototype.fold=function(t,e,n,o){o.become(this)},P.prototype.when=function(t){"function"==typeof t.rejected&&this._unreport(),H(t.rejected,this,t.receiver,t.resolver)},P.prototype._report=function(t){G.afterQueue(new R(this,t))},P.prototype._unreport=function(){this.handled||(this.handled=!0,G.afterQueue(new C(this)))},P.prototype.fail=function(t){this.reported=!0,I("unhandledRejection",this),e.onFatalRejection(this,void 0===t?this.context:t)},R.prototype.run=function(){this.rejection.handled||this.rejection.reported||(this.rejection.reported=!0,I("unhandledRejection",this.rejection)||e.onPotentiallyUnhandledRejection(this.rejection,this.context))},C.prototype.run=function(){this.rejection.reported&&(I("rejectionHandled",this.rejection)||e.onPotentiallyUnhandledRejectionHandled(this.rejection))},e.createContext=e.enterContext=e.exitContext=e.onPotentiallyUnhandledRejection=e.onPotentiallyUnhandledRejectionHandled=e.onFatalRejection=K;var Z=new _,$=new e(_,Z);return T.prototype.run=function(){this.handler.join().when(this.continuation)},Q.prototype.run=function(){var t=this.handler.consumers;if(void 0!==t)for(var e,n=0;n<t.length;++n)e=t[n],J(e.progress,this.value,this.handler,e.receiver,e.resolver)},E.prototype.run=function(){function t(t){o.resolve(t)}function e(t){o.reject(t)}function n(t){o.notify(t)}var o=this.resolver;L(this._then,this.thenable,t,e,n)},S.prototype.fulfilled=function(t){this.f.call(this.c,this.z,t,this.to)},S.prototype.rejected=function(t){this.to.reject(t)},S.prototype.progress=function(t){this.to.notify(t)},e}})}("function"==typeof t&&t.amd?t:function(t){n.exports=t()})},{}]},{},[1])(1)}),"undefined"!=typeof systemJSBootstrap&&systemJSBootstrap()}();
+//# sourceMappingURL=system-polyfills.js.map
diff --git a/dist/system-polyfills.js.map b/dist/system-polyfills.js.map
new file mode 100644
index 000000000..a53942fea
--- /dev/null
+++ b/dist/system-polyfills.js.map
@@ -0,0 +1 @@
+{"version":3,"sources":["system-polyfills.src.js"],"names":["define","e","exports","module","amd","window","Promise","global","self","t","n","r","s","o","u","a","require","i","Error","f","call","length","1","unhandledRejections","PromiseConstructor","../lib/Promise","../lib/decorators/unhandledRejection","2","makePromise","Scheduler","async","asap","scheduler","factory","./Scheduler","./env","./makePromise","3","this","_async","_running","_queue","_queueLen","_afterQueue","_afterQueueLen","drain","_drain","prototype","enqueue","task","run","afterQueue","4","throwit","noop","setTimer","format","report","handled","reported","push","logError","id","formatError","value","unreport","indexOf","splice","logInfo","formatObject","x","tasks","running","flush","shift","localConsole","console","error","log","info","onPotentiallyUnhandledRejection","rejection","onPotentiallyUnhandledRejectionHandled","onFatalRejection","../env","../format","5","isNode","process","Object","toString","hasMutationObserver","MutationObserver","WebKitMutationObserver","initMutationObserver","scheduled","node","document","createTextNode","observe","characterData","data","MutationObs","capturedSetTimeout","setTimeout","ms","clearTimer","clearTimeout","nextTick","vertxRequire","vertx","cancelTimer","runOnLoop","runOnContext","6","stack","message","String","JSON","tryStringify","defaultValue","stringify","7","environment","resolver","handler","_handler","Handler","init","promiseResolve","resolve","promiseReject","reason","reject","promiseNotify","notify","Pending","isPromise","Async","getHandler","Rejected","never","foreverPendingPromise","defer","begetFrom","parent","child","receiver","join","context","all","promises","traverseWith","snd","traverse","tryCatch2","tryMap","mapAt","resolved","traverseAt","settleAt","results","pending","become","Fulfilled","Array","maybeThenable","h","getHandlerMaybeThenable","state","fold","visitRemaining","start","markAsHandled","visit","_unreport","race","TypeError","runRace","getHandlerUntrusted","untrustedThen","then","Thenable","FailIfRejected","inheritedContext","createContext","consumers","thenable","AssimilateTask","errorId","_report","ReportTask","UnreportTask","cycle","ContinuationTask","continuation","ProgressTask","_then","tryAssimilate","Fold","z","c","to","failIfRejected","runContinuation1","next","enterContext","tryCatchReject","exitContext","runContinuation3","tryCatchReject3","runNotify","tryCatchReturn","b","thisArg","y","inherit","Parent","Child","objectCreate","constructor","initEmitRejection","emit","type","CustomEvent","hasCustomEvent","ev","detail","key","bubbles","cancelable","dispatchEvent","emitRejection","create","proto","_defer","onFulfilled","onRejected","onProgress","p","_beget","chain","_traverse","_visitRemaining","when","fail","_state","fulfilled","rejected","progress","q","cont","foreverPendingHandler","_resolve","_reject","_notify","systemJSBootstrap"],"mappings":";;;CAGA,SAAUA,IAET,SAASC,GAAG,gBAAiBC,SAAQC,OAAOD,QAAQD,IAAI,kBAAmBD,IAAQA,EAAOI,IAAIJ,EAAOC,GAAG,mBAAoBI,QAAOA,OAAOC,QAAQL,IAAI,mBAAoBM,QAAOA,OAAOD,QAAQL,IAAI,mBAAoBO,QAAOA,KAAKF,QAAQL,MAAM,WAAW,GAAID,EAAsB,OAAO,SAAUC,GAAEQ,EAAEC,EAAEC,GAAG,QAASC,GAAEC,EAAEC,GAAG,IAAIJ,EAAEG,GAAG,CAAC,IAAIJ,EAAEI,GAAG,CAAC,GAAIE,GAAkB,kBAATC,UAAqBA,OAAQ,KAAIF,GAAGC,EAAE,MAAOA,GAAEF,GAAE,EAAI,IAAGI,EAAE,MAAOA,GAAEJ,GAAE,EAAI,MAAM,IAAIK,OAAM,uBAAuBL,EAAE,KAAK,GAAIM,GAAET,EAAEG,IAAIX,WAAYO,GAAEI,GAAG,GAAGO,KAAKD,EAAEjB,QAAQ,SAASD,GAAG,GAAIS,GAAED,EAAEI,GAAG,GAAGZ,EAAG,OAAOW,GAAEF,EAAEA,EAAET,IAAIkB,EAAEA,EAAEjB,QAAQD,EAAEQ,EAAEC,EAAEC,GAAG,MAAOD,GAAEG,GAAGX,QAAkD,IAAI,GAA1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D,IAGhBiI,EAAKxJ,UAAU0M,SAAW,SAASnL,GAClChC,KAAKoK,GAAGnE,OAAOjE,IAqJThE,MAGW,kBAAXN,IAAyBA,EAAOI,IAAMJ,EAAS,SAASiC,GAAW9B,EAAOD,QAAU+B,gBAElF,IAEV,KAEiC,mBAAtB+N,oBACVA"} \ No newline at end of file
diff --git a/dist/system-polyfills.src.js b/dist/system-polyfills.src.js
new file mode 100644
index 000000000..45bf75813
--- /dev/null
+++ b/dist/system-polyfills.src.js
@@ -0,0 +1,1277 @@
+/*
+ * SystemJS Promise Polyfill
+ */
+(function(define) {
+
+!function(e){"object"==typeof exports?module.exports=e():"function"==typeof define&&define.amd?define(e):"undefined"!=typeof window?window.Promise=e():"undefined"!=typeof global?global.Promise=e():"undefined"!=typeof self&&(self.Promise=e())}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
+/** @license MIT License (c) copyright 2010-2014 original author or authors */
+/** @author Brian Cavalier */
+/** @author John Hann */
+
+/**
+ * ES6 global Promise shim
+ */
+var unhandledRejections = require('../lib/decorators/unhandledRejection');
+var PromiseConstructor = unhandledRejections(require('../lib/Promise'));
+
+module.exports = typeof global != 'undefined' ? (global.Promise = PromiseConstructor)
+ : typeof self != 'undefined' ? (self.Promise = PromiseConstructor)
+ : PromiseConstructor;
+
+},{"../lib/Promise":2,"../lib/decorators/unhandledRejection":4}],2:[function(require,module,exports){
+/** @license MIT License (c) copyright 2010-2014 original author or authors */
+/** @author Brian Cavalier */
+/** @author John Hann */
+
+(function(define) { 'use strict';
+define(function (require) {
+
+ var makePromise = require('./makePromise');
+ var Scheduler = require('./Scheduler');
+ var async = require('./env').asap;
+
+ return makePromise({
+ scheduler: new Scheduler(async)
+ });
+
+});
+})(typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); });
+
+},{"./Scheduler":3,"./env":5,"./makePromise":7}],3:[function(require,module,exports){
+/** @license MIT License (c) copyright 2010-2014 original author or authors */
+/** @author Brian Cavalier */
+/** @author John Hann */
+
+(function(define) { 'use strict';
+define(function() {
+
+ // Credit to Twisol (https://github.com/Twisol) for suggesting
+ // this type of extensible queue + trampoline approach for next-tick conflation.
+
+ /**
+ * Async task scheduler
+ * @param {function} async function to schedule a single async function
+ * @constructor
+ */
+ function Scheduler(async) {
+ this._async = async;
+ this._running = false;
+
+ this._queue = this;
+ this._queueLen = 0;
+ this._afterQueue = {};
+ this._afterQueueLen = 0;
+
+ var self = this;
+ this.drain = function() {
+ self._drain();
+ };
+ }
+
+ /**
+ * Enqueue a task
+ * @param {{ run:function }} task
+ */
+ Scheduler.prototype.enqueue = function(task) {
+ this._queue[this._queueLen++] = task;
+ this.run();
+ };
+
+ /**
+ * Enqueue a task to run after the main task queue
+ * @param {{ run:function }} task
+ */
+ Scheduler.prototype.afterQueue = function(task) {
+ this._afterQueue[this._afterQueueLen++] = task;
+ this.run();
+ };
+
+ Scheduler.prototype.run = function() {
+ if (!this._running) {
+ this._running = true;
+ this._async(this.drain);
+ }
+ };
+
+ /**
+ * Drain the handler queue entirely, and then the after queue
+ */
+ Scheduler.prototype._drain = function() {
+ var i = 0;
+ for (; i < this._queueLen; ++i) {
+ this._queue[i].run();
+ this._queue[i] = void 0;
+ }
+
+ this._queueLen = 0;
+ this._running = false;
+
+ for (i = 0; i < this._afterQueueLen; ++i) {
+ this._afterQueue[i].run();
+ this._afterQueue[i] = void 0;
+ }
+
+ this._afterQueueLen = 0;
+ };
+
+ return Scheduler;
+
+});
+}(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
+
+},{}],4:[function(require,module,exports){
+/** @license MIT License (c) copyright 2010-2014 original author or authors */
+/** @author Brian Cavalier */
+/** @author John Hann */
+
+(function(define) { 'use strict';
+define(function(require) {
+
+ var setTimer = require('../env').setTimer;
+ var format = require('../format');
+
+ return function unhandledRejection(Promise) {
+
+ var logError = noop;
+ var logInfo = noop;
+ var localConsole;
+
+ if(typeof console !== 'undefined') {
+ // Alias console to prevent things like uglify's drop_console option from
+ // removing console.log/error. Unhandled rejections fall into the same
+ // category as uncaught exceptions, and build tools shouldn't silence them.
+ localConsole = console;
+ logError = typeof localConsole.error !== 'undefined'
+ ? function (e) { localConsole.error(e); }
+ : function (e) { localConsole.log(e); };
+
+ logInfo = typeof localConsole.info !== 'undefined'
+ ? function (e) { localConsole.info(e); }
+ : function (e) { localConsole.log(e); };
+ }
+
+ Promise.onPotentiallyUnhandledRejection = function(rejection) {
+ enqueue(report, rejection);
+ };
+
+ Promise.onPotentiallyUnhandledRejectionHandled = function(rejection) {
+ enqueue(unreport, rejection);
+ };
+
+ Promise.onFatalRejection = function(rejection) {
+ enqueue(throwit, rejection.value);
+ };
+
+ var tasks = [];
+ var reported = [];
+ var running = null;
+
+ function report(r) {
+ if(!r.handled) {
+ reported.push(r);
+ logError('Potentially unhandled rejection [' + r.id + '] ' + format.formatError(r.value));
+ }
+ }
+
+ function unreport(r) {
+ var i = reported.indexOf(r);
+ if(i >= 0) {
+ reported.splice(i, 1);
+ logInfo('Handled previous rejection [' + r.id + '] ' + format.formatObject(r.value));
+ }
+ }
+
+ function enqueue(f, x) {
+ tasks.push(f, x);
+ if(running === null) {
+ running = setTimer(flush, 0);
+ }
+ }
+
+ function flush() {
+ running = null;
+ while(tasks.length > 0) {
+ tasks.shift()(tasks.shift());
+ }
+ }
+
+ return Promise;
+ };
+
+ function throwit(e) {
+ throw e;
+ }
+
+ function noop() {}
+
+});
+}(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); }));
+
+},{"../env":5,"../format":6}],5:[function(require,module,exports){
+/** @license MIT License (c) copyright 2010-2014 original author or authors */
+/** @author Brian Cavalier */
+/** @author John Hann */
+
+/*global process,document,setTimeout,clearTimeout,MutationObserver,WebKitMutationObserver*/
+(function(define) { 'use strict';
+define(function(require) {
+ /*jshint maxcomplexity:6*/
+
+ // Sniff "best" async scheduling option
+ // Prefer process.nextTick or MutationObserver, then check for
+ // setTimeout, and finally vertx, since its the only env that doesn't
+ // have setTimeout
+
+ var MutationObs;
+ var capturedSetTimeout = typeof setTimeout !== 'undefined' && setTimeout;
+
+ // Default env
+ var setTimer = function(f, ms) { return setTimeout(f, ms); };
+ var clearTimer = function(t) { return clearTimeout(t); };
+ var asap = function (f) { return capturedSetTimeout(f, 0); };
+
+ // Detect specific env
+ if (isNode()) { // Node
+ asap = function (f) { return process.nextTick(f); };
+
+ } else if (MutationObs = hasMutationObserver()) { // Modern browser
+ asap = initMutationObserver(MutationObs);
+
+ } else if (!capturedSetTimeout) { // vert.x
+ var vertxRequire = require;
+ var vertx = vertxRequire('vertx');
+ setTimer = function (f, ms) { return vertx.setTimer(ms, f); };
+ clearTimer = vertx.cancelTimer;
+ asap = vertx.runOnLoop || vertx.runOnContext;
+ }
+
+ return {
+ setTimer: setTimer,
+ clearTimer: clearTimer,
+ asap: asap
+ };
+
+ function isNode () {
+ return typeof process !== 'undefined' &&
+ Object.prototype.toString.call(process) === '[object process]';
+ }
+
+ function hasMutationObserver () {
+ return (typeof MutationObserver === 'function' && MutationObserver) ||
+ (typeof WebKitMutationObserver === 'function' && WebKitMutationObserver);
+ }
+
+ function initMutationObserver(MutationObserver) {
+ var scheduled;
+ var node = document.createTextNode('');
+ var o = new MutationObserver(run);
+ o.observe(node, { characterData: true });
+
+ function run() {
+ var f = scheduled;
+ scheduled = void 0;
+ f();
+ }
+
+ var i = 0;
+ return function (f) {
+ scheduled = f;
+ node.data = (i ^= 1);
+ };
+ }
+});
+}(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(require); }));
+
+},{}],6:[function(require,module,exports){
+/** @license MIT License (c) copyright 2010-2014 original author or authors */
+/** @author Brian Cavalier */
+/** @author John Hann */
+
+(function(define) { 'use strict';
+define(function() {
+
+ return {
+ formatError: formatError,
+ formatObject: formatObject,
+ tryStringify: tryStringify
+ };
+
+ /**
+ * Format an error into a string. If e is an Error and has a stack property,
+ * it's returned. Otherwise, e is formatted using formatObject, with a
+ * warning added about e not being a proper Error.
+ * @param {*} e
+ * @returns {String} formatted string, suitable for output to developers
+ */
+ function formatError(e) {
+ var s = typeof e === 'object' && e !== null && (e.stack || e.message) ? e.stack || e.message : formatObject(e);
+ return e instanceof Error ? s : s + ' (WARNING: non-Error used)';
+ }
+
+ /**
+ * Format an object, detecting "plain" objects and running them through
+ * JSON.stringify if possible.
+ * @param {Object} o
+ * @returns {string}
+ */
+ function formatObject(o) {
+ var s = String(o);
+ if(s === '[object Object]' && typeof JSON !== 'undefined') {
+ s = tryStringify(o, s);
+ }
+ return s;
+ }
+
+ /**
+ * Try to return the result of JSON.stringify(x). If that fails, return
+ * defaultValue
+ * @param {*} x
+ * @param {*} defaultValue
+ * @returns {String|*} JSON.stringify(x) or defaultValue
+ */
+ function tryStringify(x, defaultValue) {
+ try {
+ return JSON.stringify(x);
+ } catch(e) {
+ return defaultValue;
+ }
+ }
+
+});
+}(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
+
+},{}],7:[function(require,module,exports){
+/** @license MIT License (c) copyright 2010-2014 original author or authors */
+/** @author Brian Cavalier */
+/** @author John Hann */
+
+(function(define) { 'use strict';
+define(function() {
+
+ return function makePromise(environment) {
+
+ var tasks = environment.scheduler;
+ var emitRejection = initEmitRejection();
+
+ var objectCreate = Object.create ||
+ function(proto) {
+ function Child() {}
+ Child.prototype = proto;
+ return new Child();
+ };
+
+ /**
+ * Create a promise whose fate is determined by resolver
+ * @constructor
+ * @returns {Promise} promise
+ * @name Promise
+ */
+ function Promise(resolver, handler) {
+ this._handler = resolver === Handler ? handler : init(resolver);
+ }
+
+ /**
+ * Run the supplied resolver
+ * @param resolver
+ * @returns {Pending}
+ */
+ function init(resolver) {
+ var handler = new Pending();
+
+ try {
+ resolver(promiseResolve, promiseReject, promiseNotify);
+ } catch (e) {
+ promiseReject(e);
+ }
+
+ return handler;
+
+ /**
+ * Transition from pre-resolution state to post-resolution state, notifying
+ * all listeners of the ultimate fulfillment or rejection
+ * @param {*} x resolution value
+ */
+ function promiseResolve (x) {
+ handler.resolve(x);
+ }
+ /**
+ * Reject this promise with reason, which will be used verbatim
+ * @param {Error|*} reason rejection reason, strongly suggested
+ * to be an Error type
+ */
+ function promiseReject (reason) {
+ handler.reject(reason);
+ }
+
+ /**
+ * @deprecated
+ * Issue a progress event, notifying all progress listeners
+ * @param {*} x progress event payload to pass to all listeners
+ */
+ function promiseNotify (x) {
+ handler.notify(x);
+ }
+ }
+
+ // Creation
+
+ Promise.resolve = resolve;
+ Promise.reject = reject;
+ Promise.never = never;
+
+ Promise._defer = defer;
+ Promise._handler = getHandler;
+
+ /**
+ * Returns a trusted promise. If x is already a trusted promise, it is
+ * returned, otherwise returns a new trusted Promise which follows x.
+ * @param {*} x
+ * @return {Promise} promise
+ */
+ function resolve(x) {
+ return isPromise(x) ? x
+ : new Promise(Handler, new Async(getHandler(x)));
+ }
+
+ /**
+ * Return a reject promise with x as its reason (x is used verbatim)
+ * @param {*} x
+ * @returns {Promise} rejected promise
+ */
+ function reject(x) {
+ return new Promise(Handler, new Async(new Rejected(x)));
+ }
+
+ /**
+ * Return a promise that remains pending forever
+ * @returns {Promise} forever-pending promise.
+ */
+ function never() {
+ return foreverPendingPromise; // Should be frozen
+ }
+
+ /**
+ * Creates an internal {promise, resolver} pair
+ * @private
+ * @returns {Promise}
+ */
+ function defer() {
+ return new Promise(Handler, new Pending());
+ }
+
+ // Transformation and flow control
+
+ /**
+ * Transform this promise's fulfillment value, returning a new Promise
+ * for the transformed result. If the promise cannot be fulfilled, onRejected
+ * is called with the reason. onProgress *may* be called with updates toward
+ * this promise's fulfillment.
+ * @param {function=} onFulfilled fulfillment handler
+ * @param {function=} onRejected rejection handler
+ * @param {function=} onProgress @deprecated progress handler
+ * @return {Promise} new promise
+ */
+ Promise.prototype.then = function(onFulfilled, onRejected, onProgress) {
+ var parent = this._handler;
+ var state = parent.join().state();
+
+ if ((typeof onFulfilled !== 'function' && state > 0) ||
+ (typeof onRejected !== 'function' && state < 0)) {
+ // Short circuit: value will not change, simply share handler
+ return new this.constructor(Handler, parent);
+ }
+
+ var p = this._beget();
+ var child = p._handler;
+
+ parent.chain(child, parent.receiver, onFulfilled, onRejected, onProgress);
+
+ return p;
+ };
+
+ /**
+ * If this promise cannot be fulfilled due to an error, call onRejected to
+ * handle the error. Shortcut for .then(undefined, onRejected)
+ * @param {function?} onRejected
+ * @return {Promise}
+ */
+ Promise.prototype['catch'] = function(onRejected) {
+ return this.then(void 0, onRejected);
+ };
+
+ /**
+ * Creates a new, pending promise of the same type as this promise
+ * @private
+ * @returns {Promise}
+ */
+ Promise.prototype._beget = function() {
+ return begetFrom(this._handler, this.constructor);
+ };
+
+ function begetFrom(parent, Promise) {
+ var child = new Pending(parent.receiver, parent.join().context);
+ return new Promise(Handler, child);
+ }
+
+ // Array combinators
+
+ Promise.all = all;
+ Promise.race = race;
+ Promise._traverse = traverse;
+
+ /**
+ * Return a promise that will fulfill when all promises in the
+ * input array have fulfilled, or will reject when one of the
+ * promises rejects.
+ * @param {array} promises array of promises
+ * @returns {Promise} promise for array of fulfillment values
+ */
+ function all(promises) {
+ return traverseWith(snd, null, promises);
+ }
+
+ /**
+ * Array<Promise<X>> -> Promise<Array<f(X)>>
+ * @private
+ * @param {function} f function to apply to each promise's value
+ * @param {Array} promises array of promises
+ * @returns {Promise} promise for transformed values
+ */
+ function traverse(f, promises) {
+ return traverseWith(tryCatch2, f, promises);
+ }
+
+ function traverseWith(tryMap, f, promises) {
+ var handler = typeof f === 'function' ? mapAt : settleAt;
+
+ var resolver = new Pending();
+ var pending = promises.length >>> 0;
+ var results = new Array(pending);
+
+ for (var i = 0, x; i < promises.length && !resolver.resolved; ++i) {
+ x = promises[i];
+
+ if (x === void 0 && !(i in promises)) {
+ --pending;
+ continue;
+ }
+
+ traverseAt(promises, handler, i, x, resolver);
+ }
+
+ if(pending === 0) {
+ resolver.become(new Fulfilled(results));
+ }
+
+ return new Promise(Handler, resolver);
+
+ function mapAt(i, x, resolver) {
+ if(!resolver.resolved) {
+ traverseAt(promises, settleAt, i, tryMap(f, x, i), resolver);
+ }
+ }
+
+ function settleAt(i, x, resolver) {
+ results[i] = x;
+ if(--pending === 0) {
+ resolver.become(new Fulfilled(results));
+ }
+ }
+ }
+
+ function traverseAt(promises, handler, i, x, resolver) {
+ if (maybeThenable(x)) {
+ var h = getHandlerMaybeThenable(x);
+ var s = h.state();
+
+ if (s === 0) {
+ h.fold(handler, i, void 0, resolver);
+ } else if (s > 0) {
+ handler(i, h.value, resolver);
+ } else {
+ resolver.become(h);
+ visitRemaining(promises, i+1, h);
+ }
+ } else {
+ handler(i, x, resolver);
+ }
+ }
+
+ Promise._visitRemaining = visitRemaining;
+ function visitRemaining(promises, start, handler) {
+ for(var i=start; i<promises.length; ++i) {
+ markAsHandled(getHandler(promises[i]), handler);
+ }
+ }
+
+ function markAsHandled(h, handler) {
+ if(h === handler) {
+ return;
+ }
+
+ var s = h.state();
+ if(s === 0) {
+ h.visit(h, void 0, h._unreport);
+ } else if(s < 0) {
+ h._unreport();
+ }
+ }
+
+ /**
+ * Fulfill-reject competitive race. Return a promise that will settle
+ * to the same state as the earliest input promise to settle.
+ *
+ * WARNING: The ES6 Promise spec requires that race()ing an empty array
+ * must return a promise that is pending forever. This implementation
+ * returns a singleton forever-pending promise, the same singleton that is
+ * returned by Promise.never(), thus can be checked with ===
+ *
+ * @param {array} promises array of promises to race
+ * @returns {Promise} if input is non-empty, a promise that will settle
+ * to the same outcome as the earliest input promise to settle. if empty
+ * is empty, returns a promise that will never settle.
+ */
+ function race(promises) {
+ if(typeof promises !== 'object' || promises === null) {
+ return reject(new TypeError('non-iterable passed to race()'));
+ }
+
+ // Sigh, race([]) is untestable unless we return *something*
+ // that is recognizable without calling .then() on it.
+ return promises.length === 0 ? never()
+ : promises.length === 1 ? resolve(promises[0])
+ : runRace(promises);
+ }
+
+ function runRace(promises) {
+ var resolver = new Pending();
+ var i, x, h;
+ for(i=0; i<promises.length; ++i) {
+ x = promises[i];
+ if (x === void 0 && !(i in promises)) {
+ continue;
+ }
+
+ h = getHandler(x);
+ if(h.state() !== 0) {
+ resolver.become(h);
+ visitRemaining(promises, i+1, h);
+ break;
+ } else {
+ h.visit(resolver, resolver.resolve, resolver.reject);
+ }
+ }
+ return new Promise(Handler, resolver);
+ }
+
+ // Promise internals
+ // Below this, everything is @private
+
+ /**
+ * Get an appropriate handler for x, without checking for cycles
+ * @param {*} x
+ * @returns {object} handler
+ */
+ function getHandler(x) {
+ if(isPromise(x)) {
+ return x._handler.join();
+ }
+ return maybeThenable(x) ? getHandlerUntrusted(x) : new Fulfilled(x);
+ }
+
+ /**
+ * Get a handler for thenable x.
+ * NOTE: You must only call this if maybeThenable(x) == true
+ * @param {object|function|Promise} x
+ * @returns {object} handler
+ */
+ function getHandlerMaybeThenable(x) {
+ return isPromise(x) ? x._handler.join() : getHandlerUntrusted(x);
+ }
+
+ /**
+ * Get a handler for potentially untrusted thenable x
+ * @param {*} x
+ * @returns {object} handler
+ */
+ function getHandlerUntrusted(x) {
+ try {
+ var untrustedThen = x.then;
+ return typeof untrustedThen === 'function'
+ ? new Thenable(untrustedThen, x)
+ : new Fulfilled(x);
+ } catch(e) {
+ return new Rejected(e);
+ }
+ }
+
+ /**
+ * Handler for a promise that is pending forever
+ * @constructor
+ */
+ function Handler() {}
+
+ Handler.prototype.when
+ = Handler.prototype.become
+ = Handler.prototype.notify // deprecated
+ = Handler.prototype.fail
+ = Handler.prototype._unreport
+ = Handler.prototype._report
+ = noop;
+
+ Handler.prototype._state = 0;
+
+ Handler.prototype.state = function() {
+ return this._state;
+ };
+
+ /**
+ * Recursively collapse handler chain to find the handler
+ * nearest to the fully resolved value.
+ * @returns {object} handler nearest the fully resolved value
+ */
+ Handler.prototype.join = function() {
+ var h = this;
+ while(h.handler !== void 0) {
+ h = h.handler;
+ }
+ return h;
+ };
+
+ Handler.prototype.chain = function(to, receiver, fulfilled, rejected, progress) {
+ this.when({
+ resolver: to,
+ receiver: receiver,
+ fulfilled: fulfilled,
+ rejected: rejected,
+ progress: progress
+ });
+ };
+
+ Handler.prototype.visit = function(receiver, fulfilled, rejected, progress) {
+ this.chain(failIfRejected, receiver, fulfilled, rejected, progress);
+ };
+
+ Handler.prototype.fold = function(f, z, c, to) {
+ this.when(new Fold(f, z, c, to));
+ };
+
+ /**
+ * Handler that invokes fail() on any handler it becomes
+ * @constructor
+ */
+ function FailIfRejected() {}
+
+ inherit(Handler, FailIfRejected);
+
+ FailIfRejected.prototype.become = function(h) {
+ h.fail();
+ };
+
+ var failIfRejected = new FailIfRejected();
+
+ /**
+ * Handler that manages a queue of consumers waiting on a pending promise
+ * @constructor
+ */
+ function Pending(receiver, inheritedContext) {
+ Promise.createContext(this, inheritedContext);
+
+ this.consumers = void 0;
+ this.receiver = receiver;
+ this.handler = void 0;
+ this.resolved = false;
+ }
+
+ inherit(Handler, Pending);
+
+ Pending.prototype._state = 0;
+
+ Pending.prototype.resolve = function(x) {
+ this.become(getHandler(x));
+ };
+
+ Pending.prototype.reject = function(x) {
+ if(this.resolved) {
+ return;
+ }
+
+ this.become(new Rejected(x));
+ };
+
+ Pending.prototype.join = function() {
+ if (!this.resolved) {
+ return this;
+ }
+
+ var h = this;
+
+ while (h.handler !== void 0) {
+ h = h.handler;
+ if (h === this) {
+ return this.handler = cycle();
+ }
+ }
+
+ return h;
+ };
+
+ Pending.prototype.run = function() {
+ var q = this.consumers;
+ var handler = this.handler;
+ this.handler = this.handler.join();
+ this.consumers = void 0;
+
+ for (var i = 0; i < q.length; ++i) {
+ handler.when(q[i]);
+ }
+ };
+
+ Pending.prototype.become = function(handler) {
+ if(this.resolved) {
+ return;
+ }
+
+ this.resolved = true;
+ this.handler = handler;
+ if(this.consumers !== void 0) {
+ tasks.enqueue(this);
+ }
+
+ if(this.context !== void 0) {
+ handler._report(this.context);
+ }
+ };
+
+ Pending.prototype.when = function(continuation) {
+ if(this.resolved) {
+ tasks.enqueue(new ContinuationTask(continuation, this.handler));
+ } else {
+ if(this.consumers === void 0) {
+ this.consumers = [continuation];
+ } else {
+ this.consumers.push(continuation);
+ }
+ }
+ };
+
+ /**
+ * @deprecated
+ */
+ Pending.prototype.notify = function(x) {
+ if(!this.resolved) {
+ tasks.enqueue(new ProgressTask(x, this));
+ }
+ };
+
+ Pending.prototype.fail = function(context) {
+ var c = typeof context === 'undefined' ? this.context : context;
+ this.resolved && this.handler.join().fail(c);
+ };
+
+ Pending.prototype._report = function(context) {
+ this.resolved && this.handler.join()._report(context);
+ };
+
+ Pending.prototype._unreport = function() {
+ this.resolved && this.handler.join()._unreport();
+ };
+
+ /**
+ * Wrap another handler and force it into a future stack
+ * @param {object} handler
+ * @constructor
+ */
+ function Async(handler) {
+ this.handler = handler;
+ }
+
+ inherit(Handler, Async);
+
+ Async.prototype.when = function(continuation) {
+ tasks.enqueue(new ContinuationTask(continuation, this));
+ };
+
+ Async.prototype._report = function(context) {
+ this.join()._report(context);
+ };
+
+ Async.prototype._unreport = function() {
+ this.join()._unreport();
+ };
+
+ /**
+ * Handler that wraps an untrusted thenable and assimilates it in a future stack
+ * @param {function} then
+ * @param {{then: function}} thenable
+ * @constructor
+ */
+ function Thenable(then, thenable) {
+ Pending.call(this);
+ tasks.enqueue(new AssimilateTask(then, thenable, this));
+ }
+
+ inherit(Pending, Thenable);
+
+ /**
+ * Handler for a fulfilled promise
+ * @param {*} x fulfillment value
+ * @constructor
+ */
+ function Fulfilled(x) {
+ Promise.createContext(this);
+ this.value = x;
+ }
+
+ inherit(Handler, Fulfilled);
+
+ Fulfilled.prototype._state = 1;
+
+ Fulfilled.prototype.fold = function(f, z, c, to) {
+ runContinuation3(f, z, this, c, to);
+ };
+
+ Fulfilled.prototype.when = function(cont) {
+ runContinuation1(cont.fulfilled, this, cont.receiver, cont.resolver);
+ };
+
+ var errorId = 0;
+
+ /**
+ * Handler for a rejected promise
+ * @param {*} x rejection reason
+ * @constructor
+ */
+ function Rejected(x) {
+ Promise.createContext(this);
+
+ this.id = ++errorId;
+ this.value = x;
+ this.handled = false;
+ this.reported = false;
+
+ this._report();
+ }
+
+ inherit(Handler, Rejected);
+
+ Rejected.prototype._state = -1;
+
+ Rejected.prototype.fold = function(f, z, c, to) {
+ to.become(this);
+ };
+
+ Rejected.prototype.when = function(cont) {
+ if(typeof cont.rejected === 'function') {
+ this._unreport();
+ }
+ runContinuation1(cont.rejected, this, cont.receiver, cont.resolver);
+ };
+
+ Rejected.prototype._report = function(context) {
+ tasks.afterQueue(new ReportTask(this, context));
+ };
+
+ Rejected.prototype._unreport = function() {
+ if(this.handled) {
+ return;
+ }
+ this.handled = true;
+ tasks.afterQueue(new UnreportTask(this));
+ };
+
+ Rejected.prototype.fail = function(context) {
+ this.reported = true;
+ emitRejection('unhandledRejection', this);
+ Promise.onFatalRejection(this, context === void 0 ? this.context : context);
+ };
+
+ function ReportTask(rejection, context) {
+ this.rejection = rejection;
+ this.context = context;
+ }
+
+ ReportTask.prototype.run = function() {
+ if(!this.rejection.handled && !this.rejection.reported) {
+ this.rejection.reported = true;
+ emitRejection('unhandledRejection', this.rejection) ||
+ Promise.onPotentiallyUnhandledRejection(this.rejection, this.context);
+ }
+ };
+
+ function UnreportTask(rejection) {
+ this.rejection = rejection;
+ }
+
+ UnreportTask.prototype.run = function() {
+ if(this.rejection.reported) {
+ emitRejection('rejectionHandled', this.rejection) ||
+ Promise.onPotentiallyUnhandledRejectionHandled(this.rejection);
+ }
+ };
+
+ // Unhandled rejection hooks
+ // By default, everything is a noop
+
+ Promise.createContext
+ = Promise.enterContext
+ = Promise.exitContext
+ = Promise.onPotentiallyUnhandledRejection
+ = Promise.onPotentiallyUnhandledRejectionHandled
+ = Promise.onFatalRejection
+ = noop;
+
+ // Errors and singletons
+
+ var foreverPendingHandler = new Handler();
+ var foreverPendingPromise = new Promise(Handler, foreverPendingHandler);
+
+ function cycle() {
+ return new Rejected(new TypeError('Promise cycle'));
+ }
+
+ // Task runners
+
+ /**
+ * Run a single consumer
+ * @constructor
+ */
+ function ContinuationTask(continuation, handler) {
+ this.continuation = continuation;
+ this.handler = handler;
+ }
+
+ ContinuationTask.prototype.run = function() {
+ this.handler.join().when(this.continuation);
+ };
+
+ /**
+ * Run a queue of progress handlers
+ * @constructor
+ */
+ function ProgressTask(value, handler) {
+ this.handler = handler;
+ this.value = value;
+ }
+
+ ProgressTask.prototype.run = function() {
+ var q = this.handler.consumers;
+ if(q === void 0) {
+ return;
+ }
+
+ for (var c, i = 0; i < q.length; ++i) {
+ c = q[i];
+ runNotify(c.progress, this.value, this.handler, c.receiver, c.resolver);
+ }
+ };
+
+ /**
+ * Assimilate a thenable, sending it's value to resolver
+ * @param {function} then
+ * @param {object|function} thenable
+ * @param {object} resolver
+ * @constructor
+ */
+ function AssimilateTask(then, thenable, resolver) {
+ this._then = then;
+ this.thenable = thenable;
+ this.resolver = resolver;
+ }
+
+ AssimilateTask.prototype.run = function() {
+ var h = this.resolver;
+ tryAssimilate(this._then, this.thenable, _resolve, _reject, _notify);
+
+ function _resolve(x) { h.resolve(x); }
+ function _reject(x) { h.reject(x); }
+ function _notify(x) { h.notify(x); }
+ };
+
+ function tryAssimilate(then, thenable, resolve, reject, notify) {
+ try {
+ then.call(thenable, resolve, reject, notify);
+ } catch (e) {
+ reject(e);
+ }
+ }
+
+ /**
+ * Fold a handler value with z
+ * @constructor
+ */
+ function Fold(f, z, c, to) {
+ this.f = f; this.z = z; this.c = c; this.to = to;
+ this.resolver = failIfRejected;
+ this.receiver = this;
+ }
+
+ Fold.prototype.fulfilled = function(x) {
+ this.f.call(this.c, this.z, x, this.to);
+ };
+
+ Fold.prototype.rejected = function(x) {
+ this.to.reject(x);
+ };
+
+ Fold.prototype.progress = function(x) {
+ this.to.notify(x);
+ };
+
+ // Other helpers
+
+ /**
+ * @param {*} x
+ * @returns {boolean} true iff x is a trusted Promise
+ */
+ function isPromise(x) {
+ return x instanceof Promise;
+ }
+
+ /**
+ * Test just enough to rule out primitives, in order to take faster
+ * paths in some code
+ * @param {*} x
+ * @returns {boolean} false iff x is guaranteed *not* to be a thenable
+ */
+ function maybeThenable(x) {
+ return (typeof x === 'object' || typeof x === 'function') && x !== null;
+ }
+
+ function runContinuation1(f, h, receiver, next) {
+ if(typeof f !== 'function') {
+ return next.become(h);
+ }
+
+ Promise.enterContext(h);
+ tryCatchReject(f, h.value, receiver, next);
+ Promise.exitContext();
+ }
+
+ function runContinuation3(f, x, h, receiver, next) {
+ if(typeof f !== 'function') {
+ return next.become(h);
+ }
+
+ Promise.enterContext(h);
+ tryCatchReject3(f, x, h.value, receiver, next);
+ Promise.exitContext();
+ }
+
+ /**
+ * @deprecated
+ */
+ function runNotify(f, x, h, receiver, next) {
+ if(typeof f !== 'function') {
+ return next.notify(x);
+ }
+
+ Promise.enterContext(h);
+ tryCatchReturn(f, x, receiver, next);
+ Promise.exitContext();
+ }
+
+ function tryCatch2(f, a, b) {
+ try {
+ return f(a, b);
+ } catch(e) {
+ return reject(e);
+ }
+ }
+
+ /**
+ * Return f.call(thisArg, x), or if it throws return a rejected promise for
+ * the thrown exception
+ */
+ function tryCatchReject(f, x, thisArg, next) {
+ try {
+ next.become(getHandler(f.call(thisArg, x)));
+ } catch(e) {
+ next.become(new Rejected(e));
+ }
+ }
+
+ /**
+ * Same as above, but includes the extra argument parameter.
+ */
+ function tryCatchReject3(f, x, y, thisArg, next) {
+ try {
+ f.call(thisArg, x, y, next);
+ } catch(e) {
+ next.become(new Rejected(e));
+ }
+ }
+
+ /**
+ * @deprecated
+ * Return f.call(thisArg, x), or if it throws, *return* the exception
+ */
+ function tryCatchReturn(f, x, thisArg, next) {
+ try {
+ next.notify(f.call(thisArg, x));
+ } catch(e) {
+ next.notify(e);
+ }
+ }
+
+ function inherit(Parent, Child) {
+ Child.prototype = objectCreate(Parent.prototype);
+ Child.prototype.constructor = Child;
+ }
+
+ function snd(x, y) {
+ return y;
+ }
+
+ function noop() {}
+
+ function initEmitRejection() {
+ /*global process, self, CustomEvent*/
+ if(typeof process !== 'undefined' && process !== null
+ && typeof process.emit === 'function') {
+ // Returning falsy here means to call the default
+ // onPotentiallyUnhandledRejection API. This is safe even in
+ // browserify since process.emit always returns falsy in browserify:
+ // https://github.com/defunctzombie/node-process/blob/master/browser.js#L40-L46
+ return function(type, rejection) {
+ return type === 'unhandledRejection'
+ ? process.emit(type, rejection.value, rejection)
+ : process.emit(type, rejection);
+ };
+ } else if(typeof self !== 'undefined' && typeof CustomEvent === 'function') {
+ return (function(noop, self, CustomEvent) {
+ var hasCustomEvent = false;
+ try {
+ var ev = new CustomEvent('unhandledRejection');
+ hasCustomEvent = ev instanceof CustomEvent;
+ } catch (e) {}
+
+ return !hasCustomEvent ? noop : function(type, rejection) {
+ var ev = new CustomEvent(type, {
+ detail: {
+ reason: rejection.value,
+ key: rejection
+ },
+ bubbles: false,
+ cancelable: true
+ });
+
+ return !self.dispatchEvent(ev);
+ };
+ }(noop, self, CustomEvent));
+ }
+
+ return noop;
+ }
+
+ return Promise;
+ };
+});
+}(typeof define === 'function' && define.amd ? define : function(factory) { module.exports = factory(); }));
+
+},{}]},{},[1])
+//# sourceMappingURL=Promise.js.map
+(1)
+});
+;if (typeof systemJSBootstrap !== 'undefined')
+ systemJSBootstrap();})();
diff --git a/dist/system-register-only.js b/dist/system-register-only.js
new file mode 100644
index 000000000..a29a90333
--- /dev/null
+++ b/dist/system-register-only.js
@@ -0,0 +1,5 @@
+/*
+ * SystemJS v0.19.39
+ */
+!function(e){function t(e,n){if("string"!=typeof e)throw new TypeError("URL must be a string");var r=String(e).replace(/^\s+|\s+$/g,"").match(/^([^:\/?#]+:)?(?:\/\/(?:([^:@\/?#]*)(?::([^:@\/?#]*))?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/);if(!r)throw new RangeError("Invalid URL format");var a=r[1]||"",o=r[2]||"",i=r[3]||"",s=r[4]||"",d=r[5]||"",l=r[6]||"",u=r[7]||"",c=r[8]||"",f=r[9]||"";if(void 0!==n){var m=n instanceof t?n:new t(n),p=!a&&!s&&!o;!p||u||c||(c=m.search),p&&"/"!==u[0]&&(u=u?(!m.host&&!m.username||m.pathname?"":"/")+m.pathname.slice(0,m.pathname.lastIndexOf("/")+1)+u:m.pathname);var h=[];u.replace(/^(\.\.?(\/|$))+/,"").replace(/\/(\.(\/|$))+/g,"/").replace(/\/\.\.$/,"/../").replace(/\/?[^\/]*/g,function(e){"/.."===e?h.pop():h.push(e)}),u=h.join("").replace(/^\//,"/"===u[0]?"/":""),p&&(l=m.port,d=m.hostname,s=m.host,i=m.password,o=m.username),a||(a=m.protocol)}u=u.replace(/\\/g,"/"),this.origin=s?a+(""!==a||""!==s?"//":"")+s:"",this.href=a+(a&&s||"file:"==a?"//":"")+(""!==o?o+(""!==i?":"+i:"")+"@":"")+s+u+c+f,this.protocol=a,this.username=o,this.password=i,this.host=s,this.hostname=d,this.port=l,this.pathname=u,this.search=c,this.hash=f}e.URLPolyfill=t}("undefined"!=typeof self?self:global),function(e){function t(e,t){if(!e.originalErr)for(var n=((e.message||e)+(e.stack?"\n"+e.stack:"")).toString().split("\n"),r=[],a=0;a<n.length;a++)"undefined"!=typeof $__curScript&&n[a].indexOf($__curScript.src)!=-1||r.push(n[a]);var o="(SystemJS) "+(r?r.join("\n\t"):e.message.substr(11))+"\n\t"+t;y||(o=o.replace(b?/file:\/\/\//g:/file:\/\//g,""));var i=E?new Error(o,e.fileName,e.lineNumber):new Error(o);return i.stack=o,i.originalErr=e.originalErr||e,i}function n(){}function r(t){this._loader={loaderObj:this,loads:[],modules:{},importPromises:{},moduleRecords:{}},w(this,"global",{get:function(){return e}})}function a(){r.call(this),this.paths={},this._loader.paths={},k.call(this)}function o(){}function i(e,t){a.prototype[e]=t(a.prototype[e]||function(){})}function s(e){k=e(k||function(){})}function d(e){return"."==e[0]&&(!e[1]||"/"==e[1]||"."==e[1])||"/"==e[0]}function l(e,t){if("."==e[0]){if("/"==e[1]&&"."!=e[2])return(t&&t.substr(0,t.lastIndexOf("/")+1)||S)+e.substr(2)}else if("/"!=e[0]&&e.indexOf(":")==-1)return(t&&t.substr(0,t.lastIndexOf("/")+1)||S)+e;return new P(e,t&&t.replace(/#/g,"%05")||I).href.replace(/%05/g,"#")}function u(e,t){var n,r="",a=0,o=e.paths,i=e._loader.paths;for(var s in o)if(!o.hasOwnProperty||o.hasOwnProperty(s)){var u=o[s];if(u!==i[s]&&(u=o[s]=i[s]=l(o[s],d(o[s])?S:e.baseURL)),s.indexOf("*")===-1){if(t==s)return o[s];if(t.substr(0,s.length-1)==s.substr(0,s.length-1)&&(t.length<s.length||t[s.length-1]==s[s.length-1])&&("/"==o[s][o[s].length-1]||""==o[s]))return o[s].substr(0,o[s].length-1)+(t.length>s.length?(o[s]&&"/"||"")+t.substr(s.length):"")}else{var c=s.split("*");if(c.length>2)throw new TypeError("Only one wildcard in a path is permitted");var f=c[0].length;f>=a&&t.substr(0,c[0].length)==c[0]&&t.substr(t.length-c[1].length)==c[1]&&(a=f,r=s,n=t.substr(c[0].length,t.length-c[1].length-c[0].length))}}var m=o[r];return"string"==typeof n&&(m=m.replace("*",n)),m}function c(e){for(var t=[],n=[],r=0,a=e.length;r<a;r++){var o=x.call(t,e[r]);o===-1?(t.push(e[r]),n.push([r])):n[o].push(r)}return{names:t,indices:n}}function f(t){var n={};if(("object"==typeof t||"function"==typeof t)&&t!==e)if(R)for(var r in t)"default"!==r&&m(n,t,r);else p(n,t);return n.default=t,w(n,"__useDefault",{value:!0}),n}function m(e,t,n){try{var r;(r=Object.getOwnPropertyDescriptor(t,n))&&w(e,n,r)}catch(r){return e[n]=t[n],!1}}function p(e,t,n){var r=t&&t.hasOwnProperty;for(var a in t)r&&!t.hasOwnProperty(a)||n&&a in e||(e[a]=t[a]);return e}function h(e){var t=e.match(z);return t&&"System.register"==e.substr(t[0].length,15)}function g(){return{name:null,deps:null,originalIndices:null,declare:null,execute:null,executingRequire:!1,declarative:!1,normalizedDeps:null,groupIndex:null,evaluated:!1,module:null,esModule:null,esmExports:!1}}var v="undefined"==typeof window&&"undefined"!=typeof self&&"undefined"!=typeof importScripts,y="undefined"!=typeof window&&"undefined"!=typeof document,b="undefined"!=typeof process&&"undefined"!=typeof process.platform&&!!process.platform.match(/^win/);e.console||(e.console={assert:function(){}});var w,x=Array.prototype.indexOf||function(e){for(var t=0,n=this.length;t<n;t++)if(this[t]===e)return t;return-1};!function(){try{Object.defineProperty({},"a",{})&&(w=Object.defineProperty)}catch(e){w=function(e,t,n){try{e[t]=n.value||n.get.call(e)}catch(e){}}}}();var S,E="_"==new Error(0,"_").fileName;if("undefined"!=typeof document&&document.getElementsByTagName){if(S=document.baseURI,!S){var O=document.getElementsByTagName("base");S=O[0]&&O[0].href||window.location.href}}else"undefined"!=typeof location&&(S=e.location.href);if(S)S=S.split("#")[0].split("?")[0],S=S.substr(0,S.lastIndexOf("/")+1);else{if("undefined"==typeof process||!process.cwd)throw new TypeError("No environment baseURI");S="file://"+(b?"/":"")+process.cwd()+"/",b&&(S=S.replace(/\\/g,"/"))}try{var _="test:"==new e.URL("test:///").protocol}catch(e){}var P=_?e.URL:e.URLPolyfill;w(n.prototype,"toString",{value:function(){return"Module"}}),function(){function e(e){return{status:"loading",name:e||"<Anonymous"+ ++b+">",linkSets:[],dependencies:[],metadata:{}}}function a(e,t,n){return new Promise(l({step:n.address?"fetch":"locate",loader:e,moduleName:t,moduleMetadata:n&&n.metadata||{},moduleSource:n.source,moduleAddress:n.address}))}function o(t,n,r,a){return new Promise(function(e,o){e(t.loaderObj.normalize(n,r,a))}).then(function(n){var r;if(t.modules[n])return r=e(n),r.status="linked",r.module=t.modules[n],r;for(var a=0,o=t.loads.length;a<o;a++)if(r=t.loads[a],r.name==n)return r;return r=e(n),t.loads.push(r),i(t,r),r})}function i(e,t){s(e,t,Promise.resolve().then(function(){return e.loaderObj.locate({name:t.name,metadata:t.metadata})}))}function s(e,t,n){d(e,t,n.then(function(n){if("loading"==t.status)return t.address=n,e.loaderObj.fetch({name:t.name,metadata:t.metadata,address:n})}))}function d(e,t,n){n.then(function(n){if("loading"==t.status)return t.address=t.address||t.name,Promise.resolve(e.loaderObj.translate({name:t.name,metadata:t.metadata,address:t.address,source:n})).then(function(n){return t.source=n,e.loaderObj.instantiate({name:t.name,metadata:t.metadata,address:t.address,source:n})}).then(function(e){if(void 0===e)throw new TypeError("Declarative modules unsupported in the polyfill.");if("object"!=typeof e)throw new TypeError("Invalid instantiate return value");t.depsList=e.deps||[],t.execute=e.execute}).then(function(){t.dependencies=[];for(var n=t.depsList,r=[],a=0,i=n.length;a<i;a++)(function(n,a){r.push(o(e,n,t.name,t.address).then(function(e){if(t.dependencies[a]={key:n,value:e.name},"linked"!=e.status)for(var r=t.linkSets.concat([]),o=0,i=r.length;o<i;o++)c(r[o],e)}))})(n[a],a);return Promise.all(r)}).then(function(){t.status="loaded";for(var e=t.linkSets.concat([]),n=0,r=e.length;n<r;n++)m(e[n],t)})}).catch(function(e){t.status="failed",t.exception=e;for(var n=t.linkSets.concat([]),r=0,a=n.length;r<a;r++)p(n[r],t,e)})}function l(t){return function(n,r){var a=t.loader,o=t.moduleName,l=t.step;if(a.modules[o])throw new TypeError('"'+o+'" already exists in the module table');for(var c,f=0,m=a.loads.length;f<m;f++)if(a.loads[f].name==o&&(c=a.loads[f],"translate"!=l||c.source||(c.address=t.moduleAddress,d(a,c,Promise.resolve(t.moduleSource))),c.linkSets.length&&c.linkSets[0].loads[0].name==c.name))return c.linkSets[0].done.then(function(){n(c)});var p=c||e(o);p.metadata=t.moduleMetadata;var h=u(a,p);a.loads.push(p),n(h.done),"locate"==l?i(a,p):"fetch"==l?s(a,p,Promise.resolve(t.moduleAddress)):(p.address=t.moduleAddress,d(a,p,Promise.resolve(t.moduleSource)))}}function u(e,t){var n={loader:e,loads:[],startingLoad:t,loadingCount:0};return n.done=new Promise(function(e,t){n.resolve=e,n.reject=t}),c(n,t),n}function c(e,t){if("failed"!=t.status){for(var n=0,r=e.loads.length;n<r;n++)if(e.loads[n]==t)return;e.loads.push(t),t.linkSets.push(e),"loaded"!=t.status&&e.loadingCount++;for(var a=e.loader,n=0,r=t.dependencies.length;n<r;n++)if(t.dependencies[n]){var o=t.dependencies[n].value;if(!a.modules[o])for(var i=0,s=a.loads.length;i<s;i++)if(a.loads[i].name==o){c(e,a.loads[i]);break}}}}function f(e){var t=!1;try{y(e,function(n,r){p(e,n,r),t=!0})}catch(n){p(e,null,n),t=!0}return t}function m(e,t){if(e.loadingCount--,!(e.loadingCount>0)){var n=e.startingLoad;if(e.loader.loaderObj.execute===!1){for(var r=[].concat(e.loads),a=0,o=r.length;a<o;a++){var t=r[a];t.module={name:t.name,module:S({}),evaluated:!0},t.status="linked",h(e.loader,t)}return e.resolve(n)}var i=f(e);i||e.resolve(n)}}function p(e,n,r){var a=e.loader;e:if(n)if(e.loads[0].name==n.name)r=t(r,"Error loading "+n.name);else{for(var o=0;o<e.loads.length;o++)for(var i=e.loads[o],s=0;s<i.dependencies.length;s++){var d=i.dependencies[s];if(d.value==n.name){r=t(r,"Error loading "+n.name+' as "'+d.key+'" from '+i.name);break e}}r=t(r,"Error loading "+n.name+" from "+e.loads[0].name)}else r=t(r,"Error linking "+e.loads[0].name);for(var l=e.loads.concat([]),o=0,u=l.length;o<u;o++){var n=l[o];a.loaderObj.failed=a.loaderObj.failed||[],x.call(a.loaderObj.failed,n)==-1&&a.loaderObj.failed.push(n);var c=x.call(n.linkSets,e);if(n.linkSets.splice(c,1),0==n.linkSets.length){var f=x.call(e.loader.loads,n);f!=-1&&e.loader.loads.splice(f,1)}}e.reject(r)}function h(e,t){if(e.loaderObj.trace){e.loaderObj.loads||(e.loaderObj.loads={});var n={};t.dependencies.forEach(function(e){n[e.key]=e.value}),e.loaderObj.loads[t.name]={name:t.name,deps:t.dependencies.map(function(e){return e.key}),depMap:n,address:t.address,metadata:t.metadata,source:t.source}}t.name&&(e.modules[t.name]=t.module);var r=x.call(e.loads,t);r!=-1&&e.loads.splice(r,1);for(var a=0,o=t.linkSets.length;a<o;a++)r=x.call(t.linkSets[a].loads,t),r!=-1&&t.linkSets[a].loads.splice(r,1);t.linkSets.splice(0,t.linkSets.length)}function g(e,t,r){try{var a=t.execute()}catch(e){return void r(t,e)}return a&&a instanceof n?a:void r(t,new TypeError("Execution must define a Module instance"))}function v(e,t,n){var r=e._loader.importPromises;return r[t]=n.then(function(e){return r[t]=void 0,e},function(e){throw r[t]=void 0,e})}function y(e,t){var n=e.loader;if(e.loads.length)for(var r=e.loads.concat([]),a=0;a<r.length;a++){var o=r[a],i=g(e,o,t);if(!i)return;o.module={name:o.name,module:i},o.status="linked",h(n,o)}}var b=0;r.prototype={constructor:r,define:function(e,t,n){if(this._loader.importPromises[e])throw new TypeError("Module is already loading.");return v(this,e,new Promise(l({step:"translate",loader:this._loader,moduleName:e,moduleMetadata:n&&n.metadata||{},moduleSource:t,moduleAddress:n&&n.address})))},delete:function(e){var t=this._loader;return delete t.importPromises[e],delete t.moduleRecords[e],!!t.modules[e]&&delete t.modules[e]},get:function(e){if(this._loader.modules[e])return this._loader.modules[e].module},has:function(e){return!!this._loader.modules[e]},import:function(e,t,n){"object"==typeof t&&(t=t.name);var r=this;return Promise.resolve(r.normalize(e,t)).then(function(e){var t=r._loader;return t.modules[e]?t.modules[e].module:t.importPromises[e]||v(r,e,a(t,e,{}).then(function(n){return delete t.importPromises[e],n.module.module}))})},load:function(e){var t=this._loader;return t.modules[e]?Promise.resolve():t.importPromises[e]||v(this,e,new Promise(l({step:"locate",loader:t,moduleName:e,moduleMetadata:{},moduleSource:void 0,moduleAddress:void 0})).then(function(){delete t.importPromises[e]}))},module:function(t,n){var r=e();r.address=n&&n.address;var a=u(this._loader,r),o=Promise.resolve(t),i=this._loader,s=a.done.then(function(){return r.module.module});return d(i,r,o),s},newModule:function(e){if("object"!=typeof e)throw new TypeError("Expected object");var t=new n,r=[];if(Object.getOwnPropertyNames&&null!=e)r=Object.getOwnPropertyNames(e);else for(var a in e)r.push(a);for(var o=0;o<r.length;o++)(function(n){w(t,n,{configurable:!1,enumerable:!0,get:function(){return e[n]},set:function(){throw new Error("Module exports cannot be changed externally.")}})})(r[o]);return Object.freeze&&Object.freeze(t),t},set:function(e,t){if(!(t instanceof n))throw new TypeError("Loader.set("+e+", module) must be a module");this._loader.modules[e]={module:t}},normalize:function(e,t,n){},locate:function(e){return e.name},fetch:function(e){},translate:function(e){return e.source},instantiate:function(e){}};var S=r.prototype.newModule}();var j;o.prototype=r.prototype,a.prototype=new o,a.prototype.constructor=a;var k,M=/^[^\/]+:\/\//,I=new P(S),R=!0;try{Object.getOwnPropertyDescriptor({a:0},"a")}catch(e){R=!1}var M=/^([^\/]+:\/\/|\/)/;a.prototype.normalize=function(e,t,n){return e=e.match(M)||"."==e[0]?new P(e,t||S).href:new P(u(this,e)||e,S).href},function(){function t(){if(s&&"interactive"===s.script.readyState)return s.load;for(var e=0;e<u.length;e++)if("interactive"==u[e].script.readyState)return s=u[e],s.load}function n(e,t){return new Promise(function(e,n){t.metadata.integrity&&n(new Error("Subresource integrity checking is not supported in web workers.")),d=t;try{importScripts(t.address)}catch(e){d=null,n(e)}d=null,t.metadata.entry||n(new Error(t.address+" did not call System.register or AMD define. If loading a global, ensure the meta format is set to global.")),e("")})}if("undefined"!=typeof document)var r=document.getElementsByTagName("head")[0];var a,o,s,d=null,l=r&&function(){var e=document.createElement("script"),t="undefined"!=typeof opera&&"[object Opera]"===opera.toString();return e.attachEvent&&!(e.attachEvent.toString&&e.attachEvent.toString().indexOf("[native code")<0)&&!t}(),u=[],c=0,f=[];i("pushRegister_",function(e){return function(n){return!e.call(this,n)&&(d?this.reduceRegister_(d,n):l?this.reduceRegister_(t(),n):c?f.push(n):this.reduceRegister_(null,n),!0)}}),i("fetch",function(t){return function(i){var d=this;return"json"!=i.metadata.format&&i.metadata.scriptLoad&&(y||v)?v?n(d,i):new Promise(function(t,n){function m(e){if(!g.readyState||"loaded"==g.readyState||"complete"==g.readyState){if(c--,i.metadata.entry||f.length){if(!l){for(var r=0;r<f.length;r++)d.reduceRegister_(i,f[r]);f=[]}}else d.reduceRegister_(i);h(),i.metadata.entry||i.metadata.bundle||n(new Error(i.name+" did not call System.register or AMD define. If loading a global module configure the global name via the meta exports property for script injection support.")),t("")}}function p(e){h(),n(new Error("Unable to load script "+i.address))}function h(){if(e.System=a,e.require=o,g.detachEvent){g.detachEvent("onreadystatechange",m);for(var t=0;t<u.length;t++)u[t].script==g&&(s&&s.script==g&&(s=null),u.splice(t,1))}else g.removeEventListener("load",m,!1),g.removeEventListener("error",p,!1);r.removeChild(g)}var g=document.createElement("script");g.async=!0,i.metadata.crossOrigin&&(g.crossOrigin=i.metadata.crossOrigin),i.metadata.integrity&&g.setAttribute("integrity",i.metadata.integrity),l?(g.attachEvent("onreadystatechange",m),u.push({script:g,load:i})):(g.addEventListener("load",m,!1),g.addEventListener("error",p,!1)),c++,a=e.System,o=e.require,g.src=i.address,r.appendChild(g)}):t.call(this,i)}})}();var z=/^(\s*\/\*[^\*]*(\*(?!\/)[^\*]*)*\*\/|\s*\/\/[^\n]*|\s*"[^"]+"\s*;?|\s*'[^']+'\s*;?)*\s*/;!function(){function t(e,n,r){if(r[e.groupIndex]=r[e.groupIndex]||[],x.call(r[e.groupIndex],e)==-1){r[e.groupIndex].push(e);for(var a=0,o=e.normalizedDeps.length;a<o;a++){var i=e.normalizedDeps[a],s=n.defined[i];if(s&&!s.evaluated){var d=e.groupIndex+(s.declarative!=e.declarative);if(null===s.groupIndex||s.groupIndex<d){if(null!==s.groupIndex&&(r[s.groupIndex].splice(x.call(r[s.groupIndex],s),1),0==r[s.groupIndex].length))throw new Error("Mixed dependency cycle detected");s.groupIndex=d}t(s,n,r)}}}}function r(e,n,r){if(!n.module){n.groupIndex=0;var a=[];t(n,r,a);for(var o=!!n.declarative==a.length%2,i=a.length-1;i>=0;i--){for(var s=a[i],d=0;d<s.length;d++){var u=s[d];o?l(u,r):m(u,r)}o=!o}}}function o(){}function d(e,t){return t[e]||(t[e]={name:e,dependencies:[],exports:new o,importers:[]})}function l(t,n){if(!t.module){var r=n._loader.moduleRecords,a=t.module=d(t.name,r),o=t.module.exports,i=t.declare.call(e,function(e,t){if(a.locked=!0,"object"==typeof e)for(var n in e)o[n]=e[n];else o[e]=t;for(var r=0,i=a.importers.length;r<i;r++){var s=a.importers[r];if(!s.locked){var d=x.call(s.dependencies,a),l=s.setters[d];l&&l(o)}}return a.locked=!1,t},{id:t.name});if("function"==typeof i&&(i={setters:[],execute:i}),i=i||{setters:[],execute:function(){}},a.setters=i.setters,a.execute=i.execute,!a.setters||!a.execute)throw new TypeError("Invalid System.register form for "+t.name);for(var s=0,u=t.normalizedDeps.length;s<u;s++){var c,f=t.normalizedDeps[s],m=n.defined[f],p=r[f];p?c=p.exports:m&&!m.declarative?c=m.esModule:m?(l(m,n),p=m.module,c=p.exports):c=n.get(f),p&&p.importers?(p.importers.push(a),a.dependencies.push(p)):a.dependencies.push(null);for(var h=t.originalIndices[s],g=0,v=h.length;g<v;++g){var y=h[g];a.setters[y]&&a.setters[y](c)}}}}function u(e,t){var n,r=t.defined[e];if(r)r.declarative?p(e,r,[],t):r.evaluated||m(r,t),n=r.module.exports;else if(n=t.get(e),!n)throw new Error("Unable to load dependency "+e+".");return(!r||r.declarative)&&n&&n.__useDefault?n.default:n}function m(t,r){if(!t.module){var a={},o=t.module={exports:a,id:t.name};if(!t.executingRequire)for(var i=0,s=t.normalizedDeps.length;i<s;i++){var d=t.normalizedDeps[i],l=r.defined[d];l&&m(l,r)}t.evaluated=!0;var c=t.execute.call(e,function(e){for(var n=0,a=t.deps.length;n<a;n++)if(t.deps[n]==e)return u(t.normalizedDeps[n],r);var o=r.normalizeSync(e,t.name);if(x.call(t.normalizedDeps,o)!=-1)return u(o,r);throw new Error("Module "+e+" not declared as a dependency of "+t.name)},a,o);void 0!==c&&(o.exports=c),a=o.exports,a&&(a.__esModule||a instanceof n)?t.esModule=r.newModule(a):t.esmExports&&a!==e?t.esModule=r.newModule(f(a)):t.esModule=r.newModule({default:a,__useDefault:!0})}}function p(t,n,r,a){if(n&&!n.evaluated&&n.declarative){r.push(t);for(var o=0,i=n.normalizedDeps.length;o<i;o++){var s=n.normalizedDeps[o];x.call(r,s)==-1&&(a.defined[s]?p(s,a.defined[s],r,a):a.get(s))}n.evaluated||(n.evaluated=!0,n.module.execute.call(e))}}a.prototype.register=function(e,t,n){if("string"!=typeof e&&(n=t,t=e,e=null),"boolean"==typeof n)return this.registerDynamic.apply(this,arguments);var r=g();r.name=e&&(this.decanonicalize||this.normalize).call(this,e),r.declarative=!0,r.deps=t,r.declare=n,this.pushRegister_({amd:!1,entry:r})},a.prototype.registerDynamic=function(e,t,n,r){"string"!=typeof e&&(r=n,n=t,t=e,e=null);var a=g();a.name=e&&(this.decanonicalize||this.normalize).call(this,e),a.deps=t,a.execute=r,a.executingRequire=n,this.pushRegister_({amd:!1,entry:a})},i("reduceRegister_",function(){return function(e,t){if(t){var n=t.entry,r=e&&e.metadata;if(n.name&&(n.name in this.defined||(this.defined[n.name]=n),r&&(r.bundle=!0)),!n.name||e&&!r.entry&&n.name==e.name){if(!r)throw new TypeError("Invalid System.register call. Anonymous System.register calls can only be made by modules loaded by SystemJS.import and not via script tags.");if(r.entry)throw"register"==r.format?new Error("Multiple anonymous System.register calls in module "+e.name+". If loading a bundle, ensure all the System.register calls are named."):new Error("Module "+e.name+" interpreted as "+r.format+" module format, but called System.register.");r.format||(r.format="register"),r.entry=n}}}}),s(function(e){return function(){e.call(this),this.defined={},this._loader.moduleRecords={}}}),w(o,"toString",{value:function(){return"Module"}}),i("delete",function(e){return function(t){return delete this._loader.moduleRecords[t],delete this.defined[t],e.call(this,t)}}),i("fetch",function(e){return function(t){return this.defined[t.name]?(t.metadata.format="defined",""):(t.metadata.deps=t.metadata.deps||[],e.call(this,t))}}),i("translate",function(e){return function(t){return t.metadata.deps=t.metadata.deps||[],Promise.resolve(e.apply(this,arguments)).then(function(e){return("register"==t.metadata.format||!t.metadata.format&&h(t.source))&&(t.metadata.format="register"),e})}}),i("load",function(e){return function(t){var n=this,a=n.defined[t];return!a||a.deps.length?e.apply(this,arguments):(a.originalIndices=a.normalizedDeps=[],r(t,a,n),p(t,a,[],n),a.esModule||(a.esModule=n.newModule(a.module.exports)),n.trace||(n.defined[t]=void 0),n.set(t,a.esModule),Promise.resolve())}}),i("instantiate",function(e){return function(t){"detect"==t.metadata.format&&(t.metadata.format=void 0),e.call(this,t);var n,a=this;if(a.defined[t.name])n=a.defined[t.name],n.declarative||(n.deps=n.deps.concat(t.metadata.deps)),n.deps=n.deps.concat(t.metadata.deps);else if(t.metadata.entry)n=t.metadata.entry,n.deps=n.deps.concat(t.metadata.deps);else if(!(a.builder&&t.metadata.bundle||"register"!=t.metadata.format&&"esm"!=t.metadata.format&&"es6"!=t.metadata.format)){if("undefined"!=typeof __exec&&__exec.call(a,t),!t.metadata.entry&&!t.metadata.bundle)throw new Error(t.name+" detected as "+t.metadata.format+" but didn't execute.");n=t.metadata.entry,n&&t.metadata.deps&&(n.deps=n.deps.concat(t.metadata.deps))}n||(n=g(),n.deps=t.metadata.deps,n.execute=function(){}),a.defined[t.name]=n;var o=c(n.deps);n.deps=o.names,n.originalIndices=o.indices,n.name=t.name,n.esmExports=t.metadata.esmExports!==!1;for(var i=[],s=0,d=n.deps.length;s<d;s++)i.push(Promise.resolve(a.normalize(n.deps[s],t.name)));return Promise.all(i).then(function(e){return n.normalizedDeps=e,{deps:n.deps,execute:function(){return r(t.name,n,a),p(t.name,n,[],a),n.esModule||(n.esModule=a.newModule(n.module.exports)),a.trace||(a.defined[t.name]=void 0),n.esModule}}})}})}(),function(){s(function(e){return function(){e.call(this),this.bundles={},this._loader.loadedBundles={}}}),i("locate",function(e){return function(t){var n=this,r=!1;if(!(t.name in n.defined))for(var a in n.bundles){for(var o=0;o<n.bundles[a].length;o++){var i=n.bundles[a][o];if(i==t.name){r=!0;break}if(i.indexOf("*")!=-1){var s=i.split("*");if(2!=s.length){n.bundles[a].splice(o--,1);continue}if(t.name.substring(0,s[0].length)==s[0]&&t.name.substr(t.name.length-s[1].length,s[1].length)==s[1]&&t.name.substr(s[0].length,t.name.length-s[1].length-s[0].length).indexOf("/")==-1){r=!0;break}}}if(r)return n.import(a).then(function(){return e.call(n,t)})}return e.call(n,t)}})}(),s(function(t){return function(){t.apply(this,arguments),e.define=this.amdDefine}}),i("fetch",function(e){return function(t){return t.metadata.scriptLoad=!0,e.call(this,t)}}),j=new a,e.SystemJS=j,j.version="0.19.39 Register Only","object"==typeof module&&module.exports&&"object"==typeof exports&&(module.exports=j),e.System=j}("undefined"!=typeof self?self:global);
+//# sourceMappingURL=system-register-only.js.map
diff --git a/dist/system-register-only.js.map b/dist/system-register-only.js.map
new file mode 100644
index 000000000..c3f8fbee0
--- /dev/null
+++ b/dist/system-register-only.js.map
@@ -0,0 +1 @@
+{"version":3,"sources":["system-register-only.src.js"],"names":["global","URLPolyfill","url","baseURL","TypeError","m","String","replace","match","RangeError","protocol","username","password","host","hostname","port","pathname","search","hash","undefined","base","flag","slice","lastIndexOf","output","p","pop","push","join","this","origin","href","self","__global","addToError","err","msg","originalErr","stack","message","toString","split","newStack","i","length","$__curScript","indexOf","src","newMsg","substr","isBrowser","isWindows","newErr","errArgs","Error","fileName","lineNumber","Module","Loader","options","_loader","loaderObj","loads","modules","importPromises","moduleRecords","defineProperty","get","SystemJSLoader","call","paths","systemJSConstructor","SystemProto","hook","name","prototype","hookConstructor","isRel","urlResolve","parent","baseURI","URL","baseURIObj","applyPaths","loader","wildcard","pathMatch","maxWildcardPrefixLen","pathsCache","hasOwnProperty","path","pathParts","wildcardPrefixLen","outPath","group","deps","names","indices","l","index","getESModule","exports","esModule","getOwnPropertyDescriptor","defineOrCopyProperty","extend","value","targetObj","sourceObj","propName","d","Object","ex","a","b","prepend","detectRegisterFormat","source","leadingCommentAndMeta","leadingCommentAndMetaRegEx","createEntry","originalIndices","declare","execute","executingRequire","declarative","normalizedDeps","groupIndex","evaluated","module","esmExports","isWorker","window","importScripts","document","process","platform","console","assert","Array","item","thisLen","e","obj","prop","opt","getElementsByTagName","bases","location","cwd","nativeURL","createLoad","status","anonCnt","linkSets","dependencies","metadata","loadModule","Promise","asyncStartLoadPartwayThrough","step","address","moduleName","moduleMetadata","moduleSource","moduleAddress","requestLoad","request","refererName","refererAddress","resolve","reject","normalize","then","load","proceedToLocate","proceedToFetch","locate","proceedToTranslate","fetch","translate","instantiate","instantiateResult","depsList","loadPromises","depLoad","key","concat","addLoadToLinkSet","all","updateLinkSetOnLoad","exc","exception","linkSetFailed","stepState","existingLoad","done","linkSet","createLinkSet","startingLoad","loadingCount","j","doLink","error","link","_newModule","finishLoad","abrupt","checkError","pLoad","dep","failed","linkIndex","splice","globalLoadsIndex","trace","depMap","forEach","map","loadIndex","doDynamicExecute","linkError","createImportPromise","promise","constructor","define","delete","has","import","parentName","parentAddress","sourcePromise","newModule","pNames","getOwnPropertyNames","configurable","enumerable","set","freeze","referrerName","referrerAddress","System","absURLRegEx","getInteractiveScriptLoad","interactiveScript","script","readyState","interactiveLoadingScripts","webWorkerImport","integrity","workerLoad","entry","head","curSystem","curRequire","ieEvents","s","createElement","isOpera","opera","attachEvent","loadingCnt","registerQueue","pushRegister","register","reduceRegister_","format","scriptLoad","complete","evt","cleanup","bundle","require","detachEvent","removeEventListener","removeChild","async","crossOrigin","setAttribute","addEventListener","appendChild","buildGroups","groups","depName","depEntry","defined","depGroupIndex","startEntry","curGroupDeclarative","linkDeclarativeModule","linkDynamicModule","ModuleRecord","getOrCreateModuleRecord","importers","declaration","locked","importerModule","importerIndex","setter","setters","id","depExports","depModule","len","getModule","ensureEvaluated","__useDefault","nameNormalized","normalizeSync","__esModule","default","seen","registerDynamic","apply","arguments","decanonicalize","pushRegister_","amd","curMeta","del","doLoad","normalized","builder","__exec","grouped","normalizePromises","bundles","loadedBundles","matched","curModule","parts","substring","amdDefine","SystemJS","version"],"mappings":";;;CAIA,SAAUA,GACV,QAASC,GAAYC,EAAKC,GACxB,GAAkB,gBAAPD,GACT,KAAM,IAAIE,WAAU,uBACtB,IAAIC,GAAIC,OAAOJ,GAAKK,QAAQ,aAAc,IAAIC,MAAM,mHACpD,KAAKH,EACH,KAAM,IAAII,YAAW,qBACvB,IAAIC,GAAWL,EAAE,IAAM,GACnBM,EAAWN,EAAE,IAAM,GACnBO,EAAWP,EAAE,IAAM,GACnBQ,EAAOR,EAAE,IAAM,GACfS,EAAWT,EAAE,IAAM,GACnBU,EAAOV,EAAE,IAAM,GACfW,EAAWX,EAAE,IAAM,GACnBY,EAASZ,EAAE,IAAM,GACjBa,EAAOb,EAAE,IAAM,EACnB,IAAgBc,SAAZhB,EAAuB,CACzB,GAAIiB,GAAOjB,YAAmBF,GAAcE,EAAU,GAAIF,GAAYE,GAClEkB,GAAQX,IAAaG,IAASF,GAC9BU,GAASL,GAAaC,IACxBA,EAASG,EAAKH,QACZI,GAAwB,MAAhBL,EAAS,KACnBA,EAAYA,IAAcI,EAAKP,OAAQO,EAAKT,UAAcS,EAAKJ,SAAiB,GAAN,KAAYI,EAAKJ,SAASM,MAAM,EAAGF,EAAKJ,SAASO,YAAY,KAAO,GAAKP,EAAYI,EAAKJ,SAEtK,IAAIQ,KACJR,GAAST,QAAQ,kBAAmB,IACjCA,QAAQ,iBAAkB,KAC1BA,QAAQ,UAAW,QACnBA,QAAQ,aAAc,SAAUkB,GACrB,QAANA,EACFD,EAAOE,MAEPF,EAAOG,KAAKF,KAElBT,EAAWQ,EAAOI,KAAK,IAAIrB,QAAQ,MAAuB,MAAhBS,EAAS,GAAa,IAAM,IAClEK,IACFN,EAAOK,EAAKL,KACZD,EAAWM,EAAKN,SAChBD,EAAOO,EAAKP,KACZD,EAAWQ,EAAKR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/system-register-only.src.js
new file mode 100644
index 000000000..7ff22628f
--- /dev/null
+++ b/dist/system-register-only.src.js
@@ -0,0 +1,2198 @@
+/*
+ * SystemJS v0.19.39
+ */
+// from https://gist.github.com/Yaffle/1088850
+(function(global) {
+function URLPolyfill(url, baseURL) {
+ if (typeof url != 'string')
+ throw new TypeError('URL must be a string');
+ var m = String(url).replace(/^\s+|\s+$/g, "").match(/^([^:\/?#]+:)?(?:\/\/(?:([^:@\/?#]*)(?::([^:@\/?#]*))?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/);
+ if (!m)
+ throw new RangeError('Invalid URL format');
+ var protocol = m[1] || "";
+ var username = m[2] || "";
+ var password = m[3] || "";
+ var host = m[4] || "";
+ var hostname = m[5] || "";
+ var port = m[6] || "";
+ var pathname = m[7] || "";
+ var search = m[8] || "";
+ var hash = m[9] || "";
+ if (baseURL !== undefined) {
+ var base = baseURL instanceof URLPolyfill ? baseURL : new URLPolyfill(baseURL);
+ var flag = !protocol && !host && !username;
+ if (flag && !pathname && !search)
+ search = base.search;
+ if (flag && pathname[0] !== "/")
+ pathname = (pathname ? (((base.host || base.username) && !base.pathname ? "/" : "") + base.pathname.slice(0, base.pathname.lastIndexOf("/") + 1) + pathname) : base.pathname);
+ // dot segments removal
+ var output = [];
+ pathname.replace(/^(\.\.?(\/|$))+/, "")
+ .replace(/\/(\.(\/|$))+/g, "/")
+ .replace(/\/\.\.$/, "/../")
+ .replace(/\/?[^\/]*/g, function (p) {
+ if (p === "/..")
+ output.pop();
+ else
+ output.push(p);
+ });
+ pathname = output.join("").replace(/^\//, pathname[0] === "/" ? "/" : "");
+ if (flag) {
+ port = base.port;
+ hostname = base.hostname;
+ host = base.host;
+ password = base.password;
+ username = base.username;
+ }
+ if (!protocol)
+ protocol = base.protocol;
+ }
+
+ // convert URLs to use / always
+ pathname = pathname.replace(/\\/g, '/');
+
+ this.origin = host ? protocol + (protocol !== "" || host !== "" ? "//" : "") + host : "";
+ this.href = protocol + (protocol && host || protocol == "file:" ? "//" : "") + (username !== "" ? username + (password !== "" ? ":" + password : "") + "@" : "") + host + pathname + search + hash;
+ this.protocol = protocol;
+ this.username = username;
+ this.password = password;
+ this.host = host;
+ this.hostname = hostname;
+ this.port = port;
+ this.pathname = pathname;
+ this.search = search;
+ this.hash = hash;
+}
+global.URLPolyfill = URLPolyfill;
+})(typeof self != 'undefined' ? self : global);(function(__global) {
+
+ var isWorker = typeof window == 'undefined' && typeof self != 'undefined' && typeof importScripts != 'undefined';
+ var isBrowser = typeof window != 'undefined' && typeof document != 'undefined';
+ var isWindows = typeof process != 'undefined' && typeof process.platform != 'undefined' && !!process.platform.match(/^win/);
+
+ if (!__global.console)
+ __global.console = { assert: function() {} };
+
+ // IE8 support
+ var indexOf = Array.prototype.indexOf || function(item) {
+ for (var i = 0, thisLen = this.length; i < thisLen; i++) {
+ if (this[i] === item) {
+ return i;
+ }
+ }
+ return -1;
+ };
+
+ var defineProperty;
+ (function () {
+ try {
+ if (!!Object.defineProperty({}, 'a', {}))
+ defineProperty = Object.defineProperty;
+ }
+ catch (e) {
+ defineProperty = function(obj, prop, opt) {
+ try {
+ obj[prop] = opt.value || opt.get.call(obj);
+ }
+ catch(e) {}
+ }
+ }
+ })();
+
+ var errArgs = new Error(0, '_').fileName == '_';
+
+ function addToError(err, msg) {
+ // parse the stack removing loader code lines for simplification
+ if (!err.originalErr) {
+ var stack = ((err.message || err) + (err.stack ? '\n' + err.stack : '')).toString().split('\n');
+ var newStack = [];
+ for (var i = 0; i < stack.length; i++) {
+ if (typeof $__curScript == 'undefined' || stack[i].indexOf($__curScript.src) == -1)
+ newStack.push(stack[i]);
+ }
+ }
+
+ var newMsg = '(SystemJS) ' + (newStack ? newStack.join('\n\t') : err.message.substr(11)) + '\n\t' + msg;
+
+ // Convert file:/// URLs to paths in Node
+ if (!isBrowser)
+ newMsg = newMsg.replace(isWindows ? /file:\/\/\//g : /file:\/\//g, '');
+
+ var newErr = errArgs ? new Error(newMsg, err.fileName, err.lineNumber) : new Error(newMsg);
+
+ newErr.stack = newMsg;
+
+ // track the original error
+ newErr.originalErr = err.originalErr || err;
+
+ return newErr;
+ }
+
+ function __eval(source, debugName, context) {
+ try {
+ new Function(source).call(context);
+ }
+ catch(e) {
+ throw addToError(e, 'Evaluating ' + debugName);
+ }
+ }
+
+ var baseURI;
+
+ // environent baseURI detection
+ if (typeof document != 'undefined' && document.getElementsByTagName) {
+ baseURI = document.baseURI;
+
+ if (!baseURI) {
+ var bases = document.getElementsByTagName('base');
+ baseURI = bases[0] && bases[0].href || window.location.href;
+ }
+ }
+ else if (typeof location != 'undefined') {
+ baseURI = __global.location.href;
+ }
+
+ // sanitize out the hash and querystring
+ if (baseURI) {
+ baseURI = baseURI.split('#')[0].split('?')[0];
+ baseURI = baseURI.substr(0, baseURI.lastIndexOf('/') + 1);
+ }
+ else if (typeof process != 'undefined' && process.cwd) {
+ baseURI = 'file://' + (isWindows ? '/' : '') + process.cwd() + '/';
+ if (isWindows)
+ baseURI = baseURI.replace(/\\/g, '/');
+ }
+ else {
+ throw new TypeError('No environment baseURI');
+ }
+
+ try {
+ var nativeURL = new __global.URL('test:///').protocol == 'test:';
+ }
+ catch(e) {}
+
+ var URL = nativeURL ? __global.URL : __global.URLPolyfill;
+
+/*
+*********************************************************************************************
+
+ Dynamic Module Loader Polyfill
+
+ - Implemented exactly to the former 2014-08-24 ES6 Specification Draft Rev 27, Section 15
+ http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts#august_24_2014_draft_rev_27
+
+ - Functions are commented with their spec numbers, with spec differences commented.
+
+ - Spec bugs are commented in this code with links.
+
+ - Abstract functions have been combined where possible, and their associated functions
+ commented.
+
+ - Realm implementation is entirely omitted.
+
+*********************************************************************************************
+*/
+
+function Module() {}
+// http://www.ecma-international.org/ecma-262/6.0/#sec-@@tostringtag
+defineProperty(Module.prototype, 'toString', {
+ value: function() {
+ return 'Module';
+ }
+});
+function Loader(options) {
+ this._loader = {
+ loaderObj: this,
+ loads: [],
+ modules: {},
+ importPromises: {},
+ moduleRecords: {}
+ };
+
+ // 26.3.3.6
+ defineProperty(this, 'global', {
+ get: function() {
+ return __global;
+ }
+ });
+
+ // 26.3.3.13 realm not implemented
+}
+
+(function() {
+
+// Some Helpers
+
+// logs a linkset snapshot for debugging
+/* function snapshot(loader) {
+ console.log('---Snapshot---');
+ for (var i = 0; i < loader.loads.length; i++) {
+ var load = loader.loads[i];
+ var linkSetLog = ' ' + load.name + ' (' + load.status + '): ';
+
+ for (var j = 0; j < load.linkSets.length; j++) {
+ linkSetLog += '{' + logloads(load.linkSets[j].loads) + '} ';
+ }
+ console.log(linkSetLog);
+ }
+ console.log('');
+}
+function logloads(loads) {
+ var log = '';
+ for (var k = 0; k < loads.length; k++)
+ log += loads[k].name + (k != loads.length - 1 ? ' ' : '');
+ return log;
+} */
+
+
+/* function checkInvariants() {
+ // see https://bugs.ecmascript.org/show_bug.cgi?id=2603#c1
+
+ var loads = System._loader.loads;
+ var linkSets = [];
+
+ for (var i = 0; i < loads.length; i++) {
+ var load = loads[i];
+ console.assert(load.status == 'loading' || load.status == 'loaded', 'Each load is loading or loaded');
+
+ for (var j = 0; j < load.linkSets.length; j++) {
+ var linkSet = load.linkSets[j];
+
+ for (var k = 0; k < linkSet.loads.length; k++)
+ console.assert(loads.indexOf(linkSet.loads[k]) != -1, 'linkSet loads are a subset of loader loads');
+
+ if (linkSets.indexOf(linkSet) == -1)
+ linkSets.push(linkSet);
+ }
+ }
+
+ for (var i = 0; i < loads.length; i++) {
+ var load = loads[i];
+ for (var j = 0; j < linkSets.length; j++) {
+ var linkSet = linkSets[j];
+
+ if (linkSet.loads.indexOf(load) != -1)
+ console.assert(load.linkSets.indexOf(linkSet) != -1, 'linkSet contains load -> load contains linkSet');
+
+ if (load.linkSets.indexOf(linkSet) != -1)
+ console.assert(linkSet.loads.indexOf(load) != -1, 'load contains linkSet -> linkSet contains load');
+ }
+ }
+
+ for (var i = 0; i < linkSets.length; i++) {
+ var linkSet = linkSets[i];
+ for (var j = 0; j < linkSet.loads.length; j++) {
+ var load = linkSet.loads[j];
+
+ for (var k = 0; k < load.dependencies.length; k++) {
+ var depName = load.dependencies[k].value;
+ var depLoad;
+ for (var l = 0; l < loads.length; l++) {
+ if (loads[l].name != depName)
+ continue;
+ depLoad = loads[l];
+ break;
+ }
+
+ // loading records are allowed not to have their dependencies yet
+ // if (load.status != 'loading')
+ // console.assert(depLoad, 'depLoad found');
+
+ // console.assert(linkSet.loads.indexOf(depLoad) != -1, 'linkset contains all dependencies');
+ }
+ }
+ }
+} */
+
+ // 15.2.3 - Runtime Semantics: Loader State
+
+ // 15.2.3.11
+ function createLoaderLoad(object) {
+ return {
+ // modules is an object for ES5 implementation
+ modules: {},
+ loads: [],
+ loaderObj: object
+ };
+ }
+
+ // 15.2.3.2 Load Records and LoadRequest Objects
+
+ var anonCnt = 0;
+
+ // 15.2.3.2.1
+ function createLoad(name) {
+ return {
+ status: 'loading',
+ name: name || '<Anonymous' + ++anonCnt + '>',
+ linkSets: [],
+ dependencies: [],
+ metadata: {}
+ };
+ }
+
+ // 15.2.3.2.2 createLoadRequestObject, absorbed into calling functions
+
+ // 15.2.4
+
+ // 15.2.4.1
+ function loadModule(loader, name, options) {
+ return new Promise(asyncStartLoadPartwayThrough({
+ step: options.address ? 'fetch' : 'locate',
+ loader: loader,
+ moduleName: name,
+ // allow metadata for import https://bugs.ecmascript.org/show_bug.cgi?id=3091
+ moduleMetadata: options && options.metadata || {},
+ moduleSource: options.source,
+ moduleAddress: options.address
+ }));
+ }
+
+ // 15.2.4.2
+ function requestLoad(loader, request, refererName, refererAddress) {
+ // 15.2.4.2.1 CallNormalize
+ return new Promise(function(resolve, reject) {
+ resolve(loader.loaderObj.normalize(request, refererName, refererAddress));
+ })
+ // 15.2.4.2.2 GetOrCreateLoad
+ .then(function(name) {
+ var load;
+ if (loader.modules[name]) {
+ load = createLoad(name);
+ load.status = 'linked';
+ // https://bugs.ecmascript.org/show_bug.cgi?id=2795
+ load.module = loader.modules[name];
+ return load;
+ }
+
+ for (var i = 0, l = loader.loads.length; i < l; i++) {
+ load = loader.loads[i];
+ if (load.name != name)
+ continue;
+ return load;
+ }
+
+ load = createLoad(name);
+ loader.loads.push(load);
+
+ proceedToLocate(loader, load);
+
+ return load;
+ });
+ }
+
+ // 15.2.4.3
+ function proceedToLocate(loader, load) {
+ proceedToFetch(loader, load,
+ Promise.resolve()
+ // 15.2.4.3.1 CallLocate
+ .then(function() {
+ return loader.loaderObj.locate({ name: load.name, metadata: load.metadata });
+ })
+ );
+ }
+
+ // 15.2.4.4
+ function proceedToFetch(loader, load, p) {
+ proceedToTranslate(loader, load,
+ p
+ // 15.2.4.4.1 CallFetch
+ .then(function(address) {
+ // adjusted, see https://bugs.ecmascript.org/show_bug.cgi?id=2602
+ if (load.status != 'loading')
+ return;
+ load.address = address;
+
+ return loader.loaderObj.fetch({ name: load.name, metadata: load.metadata, address: address });
+ })
+ );
+ }
+
+ // 15.2.4.5
+ function proceedToTranslate(loader, load, p) {
+ p
+ // 15.2.4.5.1 CallTranslate
+ .then(function(source) {
+ if (load.status != 'loading')
+ return;
+
+ load.address = load.address || load.name;
+
+ return Promise.resolve(loader.loaderObj.translate({ name: load.name, metadata: load.metadata, address: load.address, source: source }))
+
+ // 15.2.4.5.2 CallInstantiate
+ .then(function(source) {
+ load.source = source;
+ return loader.loaderObj.instantiate({ name: load.name, metadata: load.metadata, address: load.address, source: source });
+ })
+
+ // 15.2.4.5.3 InstantiateSucceeded
+ .then(function(instantiateResult) {
+ if (instantiateResult === undefined)
+ throw new TypeError('Declarative modules unsupported in the polyfill.');
+
+ if (typeof instantiateResult != 'object')
+ throw new TypeError('Invalid instantiate return value');
+
+ load.depsList = instantiateResult.deps || [];
+ load.execute = instantiateResult.execute;
+ })
+ // 15.2.4.6 ProcessLoadDependencies
+ .then(function() {
+ load.dependencies = [];
+ var depsList = load.depsList;
+
+ var loadPromises = [];
+ for (var i = 0, l = depsList.length; i < l; i++) (function(request, index) {
+ loadPromises.push(
+ requestLoad(loader, request, load.name, load.address)
+
+ // 15.2.4.6.1 AddDependencyLoad (load is parentLoad)
+ .then(function(depLoad) {
+
+ // adjusted from spec to maintain dependency order
+ // this is due to the System.register internal implementation needs
+ load.dependencies[index] = {
+ key: request,
+ value: depLoad.name
+ };
+
+ if (depLoad.status != 'linked') {
+ var linkSets = load.linkSets.concat([]);
+ for (var i = 0, l = linkSets.length; i < l; i++)
+ addLoadToLinkSet(linkSets[i], depLoad);
+ }
+
+ // console.log('AddDependencyLoad ' + depLoad.name + ' for ' + load.name);
+ // snapshot(loader);
+ })
+ );
+ })(depsList[i], i);
+
+ return Promise.all(loadPromises);
+ })
+
+ // 15.2.4.6.2 LoadSucceeded
+ .then(function() {
+ // console.log('LoadSucceeded ' + load.name);
+ // snapshot(loader);
+
+ load.status = 'loaded';
+
+ var linkSets = load.linkSets.concat([]);
+ for (var i = 0, l = linkSets.length; i < l; i++)
+ updateLinkSetOnLoad(linkSets[i], load);
+ });
+ })
+ // 15.2.4.5.4 LoadFailed
+ ['catch'](function(exc) {
+ load.status = 'failed';
+ load.exception = exc;
+
+ var linkSets = load.linkSets.concat([]);
+ for (var i = 0, l = linkSets.length; i < l; i++) {
+ linkSetFailed(linkSets[i], load, exc);
+ }
+
+ console.assert(load.linkSets.length == 0, 'linkSets not removed');
+ });
+ }
+
+ // 15.2.4.7 PromiseOfStartLoadPartwayThrough absorbed into calling functions
+
+ // 15.2.4.7.1
+ function asyncStartLoadPartwayThrough(stepState) {
+ return function(resolve, reject) {
+ var loader = stepState.loader;
+ var name = stepState.moduleName;
+ var step = stepState.step;
+
+ if (loader.modules[name])
+ throw new TypeError('"' + name + '" already exists in the module table');
+
+ // adjusted to pick up existing loads
+ var existingLoad;
+ for (var i = 0, l = loader.loads.length; i < l; i++) {
+ if (loader.loads[i].name == name) {
+ existingLoad = loader.loads[i];
+
+ if (step == 'translate' && !existingLoad.source) {
+ existingLoad.address = stepState.moduleAddress;
+ proceedToTranslate(loader, existingLoad, Promise.resolve(stepState.moduleSource));
+ }
+
+ // a primary load -> use that existing linkset if it is for the direct load here
+ // otherwise create a new linkset unit
+ if (existingLoad.linkSets.length && existingLoad.linkSets[0].loads[0].name == existingLoad.name)
+ return existingLoad.linkSets[0].done.then(function() {
+ resolve(existingLoad);
+ });
+ }
+ }
+
+ var load = existingLoad || createLoad(name);
+
+ load.metadata = stepState.moduleMetadata;
+
+ var linkSet = createLinkSet(loader, load);
+
+ loader.loads.push(load);
+
+ resolve(linkSet.done);
+
+ if (step == 'locate')
+ proceedToLocate(loader, load);
+
+ else if (step == 'fetch')
+ proceedToFetch(loader, load, Promise.resolve(stepState.moduleAddress));
+
+ else {
+ console.assert(step == 'translate', 'translate step');
+ load.address = stepState.moduleAddress;
+ proceedToTranslate(loader, load, Promise.resolve(stepState.moduleSource));
+ }
+ }
+ }
+
+ // Declarative linking functions run through alternative implementation:
+ // 15.2.5.1.1 CreateModuleLinkageRecord not implemented
+ // 15.2.5.1.2 LookupExport not implemented
+ // 15.2.5.1.3 LookupModuleDependency not implemented
+
+ // 15.2.5.2.1
+ function createLinkSet(loader, startingLoad) {
+ var linkSet = {
+ loader: loader,
+ loads: [],
+ startingLoad: startingLoad, // added see spec bug https://bugs.ecmascript.org/show_bug.cgi?id=2995
+ loadingCount: 0
+ };
+ linkSet.done = new Promise(function(resolve, reject) {
+ linkSet.resolve = resolve;
+ linkSet.reject = reject;
+ });
+ addLoadToLinkSet(linkSet, startingLoad);
+ return linkSet;
+ }
+ // 15.2.5.2.2
+ function addLoadToLinkSet(linkSet, load) {
+ if (load.status == 'failed')
+ return;
+
+ for (var i = 0, l = linkSet.loads.length; i < l; i++)
+ if (linkSet.loads[i] == load)
+ return;
+
+ linkSet.loads.push(load);
+ load.linkSets.push(linkSet);
+
+ // adjustment, see https://bugs.ecmascript.org/show_bug.cgi?id=2603
+ if (load.status != 'loaded') {
+ linkSet.loadingCount++;
+ }
+
+ var loader = linkSet.loader;
+
+ for (var i = 0, l = load.dependencies.length; i < l; i++) {
+ if (!load.dependencies[i])
+ continue;
+
+ var name = load.dependencies[i].value;
+
+ if (loader.modules[name])
+ continue;
+
+ for (var j = 0, d = loader.loads.length; j < d; j++) {
+ if (loader.loads[j].name != name)
+ continue;
+
+ addLoadToLinkSet(linkSet, loader.loads[j]);
+ break;
+ }
+ }
+ // console.log('add to linkset ' + load.name);
+ // snapshot(linkSet.loader);
+ }
+
+ // linking errors can be generic or load-specific
+ // this is necessary for debugging info
+ function doLink(linkSet) {
+ var error = false;
+ try {
+ link(linkSet, function(load, exc) {
+ linkSetFailed(linkSet, load, exc);
+ error = true;
+ });
+ }
+ catch(e) {
+ linkSetFailed(linkSet, null, e);
+ error = true;
+ }
+ return error;
+ }
+
+ // 15.2.5.2.3
+ function updateLinkSetOnLoad(linkSet, load) {
+ // console.log('update linkset on load ' + load.name);
+ // snapshot(linkSet.loader);
+
+ console.assert(load.status == 'loaded' || load.status == 'linked', 'loaded or linked');
+
+ linkSet.loadingCount--;
+
+ if (linkSet.loadingCount > 0)
+ return;
+
+ // adjusted for spec bug https://bugs.ecmascript.org/show_bug.cgi?id=2995
+ var startingLoad = linkSet.startingLoad;
+
+ // non-executing link variation for loader tracing
+ // on the server. Not in spec.
+ /***/
+ if (linkSet.loader.loaderObj.execute === false) {
+ var loads = [].concat(linkSet.loads);
+ for (var i = 0, l = loads.length; i < l; i++) {
+ var load = loads[i];
+ load.module = {
+ name: load.name,
+ module: _newModule({}),
+ evaluated: true
+ };
+ load.status = 'linked';
+ finishLoad(linkSet.loader, load);
+ }
+ return linkSet.resolve(startingLoad);
+ }
+ /***/
+
+ var abrupt = doLink(linkSet);
+
+ if (abrupt)
+ return;
+
+ console.assert(linkSet.loads.length == 0, 'loads cleared');
+
+ linkSet.resolve(startingLoad);
+ }
+
+ // 15.2.5.2.4
+ function linkSetFailed(linkSet, load, exc) {
+ var loader = linkSet.loader;
+ var requests;
+
+ checkError:
+ if (load) {
+ if (linkSet.loads[0].name == load.name) {
+ exc = addToError(exc, 'Error loading ' + load.name);
+ }
+ else {
+ for (var i = 0; i < linkSet.loads.length; i++) {
+ var pLoad = linkSet.loads[i];
+ for (var j = 0; j < pLoad.dependencies.length; j++) {
+ var dep = pLoad.dependencies[j];
+ if (dep.value == load.name) {
+ exc = addToError(exc, 'Error loading ' + load.name + ' as "' + dep.key + '" from ' + pLoad.name);
+ break checkError;
+ }
+ }
+ }
+ exc = addToError(exc, 'Error loading ' + load.name + ' from ' + linkSet.loads[0].name);
+ }
+ }
+ else {
+ exc = addToError(exc, 'Error linking ' + linkSet.loads[0].name);
+ }
+
+
+ var loads = linkSet.loads.concat([]);
+ for (var i = 0, l = loads.length; i < l; i++) {
+ var load = loads[i];
+
+ // store all failed load records
+ loader.loaderObj.failed = loader.loaderObj.failed || [];
+ if (indexOf.call(loader.loaderObj.failed, load) == -1)
+ loader.loaderObj.failed.push(load);
+
+ var linkIndex = indexOf.call(load.linkSets, linkSet);
+ console.assert(linkIndex != -1, 'link not present');
+ load.linkSets.splice(linkIndex, 1);
+ if (load.linkSets.length == 0) {
+ var globalLoadsIndex = indexOf.call(linkSet.loader.loads, load);
+ if (globalLoadsIndex != -1)
+ linkSet.loader.loads.splice(globalLoadsIndex, 1);
+ }
+ }
+ linkSet.reject(exc);
+ }
+
+ // 15.2.5.2.5
+ function finishLoad(loader, load) {
+ // add to global trace if tracing
+ if (loader.loaderObj.trace) {
+ if (!loader.loaderObj.loads)
+ loader.loaderObj.loads = {};
+ var depMap = {};
+ load.dependencies.forEach(function(dep) {
+ depMap[dep.key] = dep.value;
+ });
+ loader.loaderObj.loads[load.name] = {
+ name: load.name,
+ deps: load.dependencies.map(function(dep){ return dep.key }),
+ depMap: depMap,
+ address: load.address,
+ metadata: load.metadata,
+ source: load.source
+ };
+ }
+ // if not anonymous, add to the module table
+ if (load.name) {
+ console.assert(!loader.modules[load.name] || loader.modules[load.name].module === load.module.module, 'load not in module table');
+ loader.modules[load.name] = load.module;
+ }
+ var loadIndex = indexOf.call(loader.loads, load);
+ if (loadIndex != -1)
+ loader.loads.splice(loadIndex, 1);
+ for (var i = 0, l = load.linkSets.length; i < l; i++) {
+ loadIndex = indexOf.call(load.linkSets[i].loads, load);
+ if (loadIndex != -1)
+ load.linkSets[i].loads.splice(loadIndex, 1);
+ }
+ load.linkSets.splice(0, load.linkSets.length);
+ }
+
+ function doDynamicExecute(linkSet, load, linkError) {
+ try {
+ var module = load.execute();
+ }
+ catch(e) {
+ linkError(load, e);
+ return;
+ }
+ if (!module || !(module instanceof Module))
+ linkError(load, new TypeError('Execution must define a Module instance'));
+ else
+ return module;
+ }
+
+ // 26.3 Loader
+
+ // 26.3.1.1
+ // defined at top
+
+ // importPromises adds ability to import a module twice without error - https://bugs.ecmascript.org/show_bug.cgi?id=2601
+ function createImportPromise(loader, name, promise) {
+ var importPromises = loader._loader.importPromises;
+ return importPromises[name] = promise.then(function(m) {
+ importPromises[name] = undefined;
+ return m;
+ }, function(e) {
+ importPromises[name] = undefined;
+ throw e;
+ });
+ }
+
+ Loader.prototype = {
+ // 26.3.3.1
+ constructor: Loader,
+ // 26.3.3.2
+ define: function(name, source, options) {
+ // check if already defined
+ if (this._loader.importPromises[name])
+ throw new TypeError('Module is already loading.');
+ return createImportPromise(this, name, new Promise(asyncStartLoadPartwayThrough({
+ step: 'translate',
+ loader: this._loader,
+ moduleName: name,
+ moduleMetadata: options && options.metadata || {},
+ moduleSource: source,
+ moduleAddress: options && options.address
+ })));
+ },
+ // 26.3.3.3
+ 'delete': function(name) {
+ var loader = this._loader;
+ delete loader.importPromises[name];
+ delete loader.moduleRecords[name];
+ return loader.modules[name] ? delete loader.modules[name] : false;
+ },
+ // 26.3.3.4 entries not implemented
+ // 26.3.3.5
+ get: function(key) {
+ if (!this._loader.modules[key])
+ return;
+ return this._loader.modules[key].module;
+ },
+ // 26.3.3.7
+ has: function(name) {
+ return !!this._loader.modules[name];
+ },
+ // 26.3.3.8
+ 'import': function(name, parentName, parentAddress) {
+ if (typeof parentName == 'object')
+ parentName = parentName.name;
+
+ // run normalize first
+ var loaderObj = this;
+
+ // added, see https://bugs.ecmascript.org/show_bug.cgi?id=2659
+ return Promise.resolve(loaderObj.normalize(name, parentName))
+ .then(function(name) {
+ var loader = loaderObj._loader;
+
+ if (loader.modules[name])
+ return loader.modules[name].module;
+
+ return loader.importPromises[name] || createImportPromise(loaderObj, name,
+ loadModule(loader, name, {})
+ .then(function(load) {
+ delete loader.importPromises[name];
+ return load.module.module;
+ }));
+ });
+ },
+ // 26.3.3.9 keys not implemented
+ // 26.3.3.10
+ load: function(name) {
+ var loader = this._loader;
+ if (loader.modules[name])
+ return Promise.resolve();
+ return loader.importPromises[name] || createImportPromise(this, name, new Promise(asyncStartLoadPartwayThrough({
+ step: 'locate',
+ loader: loader,
+ moduleName: name,
+ moduleMetadata: {},
+ moduleSource: undefined,
+ moduleAddress: undefined
+ }))
+ .then(function() {
+ delete loader.importPromises[name];
+ }));
+ },
+ // 26.3.3.11
+ module: function(source, options) {
+ var load = createLoad();
+ load.address = options && options.address;
+ var linkSet = createLinkSet(this._loader, load);
+ var sourcePromise = Promise.resolve(source);
+ var loader = this._loader;
+ var p = linkSet.done.then(function() {
+ return load.module.module;
+ });
+ proceedToTranslate(loader, load, sourcePromise);
+ return p;
+ },
+ // 26.3.3.12
+ newModule: function (obj) {
+ if (typeof obj != 'object')
+ throw new TypeError('Expected object');
+
+ var m = new Module();
+
+ var pNames = [];
+ if (Object.getOwnPropertyNames && obj != null)
+ pNames = Object.getOwnPropertyNames(obj);
+ else
+ for (var key in obj)
+ pNames.push(key);
+
+ for (var i = 0; i < pNames.length; i++) (function(key) {
+ defineProperty(m, key, {
+ configurable: false,
+ enumerable: true,
+ get: function () {
+ return obj[key];
+ },
+ set: function() {
+ throw new Error('Module exports cannot be changed externally.');
+ }
+ });
+ })(pNames[i]);
+
+ if (Object.freeze)
+ Object.freeze(m);
+
+ return m;
+ },
+ // 26.3.3.14
+ set: function(name, module) {
+ if (!(module instanceof Module))
+ throw new TypeError('Loader.set(' + name + ', module) must be a module');
+ this._loader.modules[name] = {
+ module: module
+ };
+ },
+ // 26.3.3.15 values not implemented
+ // 26.3.3.16 @@iterator not implemented
+ // 26.3.3.17 @@toStringTag not implemented
+
+ // 26.3.3.18.1
+ normalize: function(name, referrerName, referrerAddress) {},
+ // 26.3.3.18.2
+ locate: function(load) {
+ return load.name;
+ },
+ // 26.3.3.18.3
+ fetch: function(load) {
+ },
+ // 26.3.3.18.4
+ translate: function(load) {
+ return load.source;
+ },
+ // 26.3.3.18.5
+ instantiate: function(load) {
+ }
+ };
+
+ var _newModule = Loader.prototype.newModule;
+
+/*
+ * ES6 Module Declarative Linking Code
+ */
+ function link(linkSet, linkError) {
+
+ var loader = linkSet.loader;
+
+ if (!linkSet.loads.length)
+ return;
+
+ var loads = linkSet.loads.concat([]);
+
+ for (var i = 0; i < loads.length; i++) {
+ var load = loads[i];
+
+ var module = doDynamicExecute(linkSet, load, linkError);
+ if (!module)
+ return;
+ load.module = {
+ name: load.name,
+ module: module
+ };
+ load.status = 'linked';
+
+ finishLoad(loader, load);
+ }
+ }
+
+})();
+
+var System;
+
+// SystemJS Loader Class and Extension helpers
+function SystemJSLoader() {
+ Loader.call(this);
+
+ this.paths = {};
+ this._loader.paths = {};
+
+ systemJSConstructor.call(this);
+}
+
+// inline Object.create-style class extension
+function SystemProto() {};
+SystemProto.prototype = Loader.prototype;
+SystemJSLoader.prototype = new SystemProto();
+SystemJSLoader.prototype.constructor = SystemJSLoader;
+
+var systemJSConstructor;
+
+function hook(name, hook) {
+ SystemJSLoader.prototype[name] = hook(SystemJSLoader.prototype[name] || function() {});
+}
+function hookConstructor(hook) {
+ systemJSConstructor = hook(systemJSConstructor || function() {});
+}
+
+
+var absURLRegEx = /^[^\/]+:\/\//;
+function isAbsolute(name) {
+ return name.match(absURLRegEx);
+}
+function isRel(name) {
+ return (name[0] == '.' && (!name[1] || name[1] == '/' || name[1] == '.')) || name[0] == '/';
+}
+function isPlain(name) {
+ return !isRel(name) && !isAbsolute(name);
+}
+
+var baseURIObj = new URL(baseURI);
+
+function urlResolve(name, parent) {
+ // url resolution shortpaths
+ if (name[0] == '.') {
+ // dot-relative url normalization
+ if (name[1] == '/' && name[2] != '.')
+ return (parent && parent.substr(0, parent.lastIndexOf('/') + 1) || baseURI) + name.substr(2);
+ }
+ else if (name[0] != '/' && name.indexOf(':') == -1) {
+ // plain parent normalization
+ return (parent && parent.substr(0, parent.lastIndexOf('/') + 1) || baseURI) + name;
+ }
+
+ return new URL(name, parent && parent.replace(/#/g, '%05') || baseURIObj).href.replace(/%05/g, '#');
+}
+
+// NB no specification provided for System.paths, used ideas discussed in https://github.com/jorendorff/js-loaders/issues/25
+function applyPaths(loader, name) {
+ // most specific (most number of slashes in path) match wins
+ var pathMatch = '', wildcard, maxWildcardPrefixLen = 0;
+
+ var paths = loader.paths;
+ var pathsCache = loader._loader.paths;
+
+ // check to see if we have a paths entry
+ for (var p in paths) {
+ if (paths.hasOwnProperty && !paths.hasOwnProperty(p))
+ continue;
+
+ // paths sanitization
+ var path = paths[p];
+ if (path !== pathsCache[p])
+ path = paths[p] = pathsCache[p] = urlResolve(paths[p], isRel(paths[p]) ? baseURI : loader.baseURL);
+
+ // exact path match
+ if (p.indexOf('*') === -1) {
+ if (name == p)
+ return paths[p];
+
+ // support trailing / in paths rules
+ else if (name.substr(0, p.length - 1) == p.substr(0, p.length - 1) && (name.length < p.length || name[p.length - 1] == p[p.length - 1]) && (paths[p][paths[p].length - 1] == '/' || paths[p] == '')) {
+ return paths[p].substr(0, paths[p].length - 1) + (name.length > p.length ? (paths[p] && '/' || '') + name.substr(p.length) : '');
+ }
+ }
+ // wildcard path match
+ else {
+ var pathParts = p.split('*');
+ if (pathParts.length > 2)
+ throw new TypeError('Only one wildcard in a path is permitted');
+
+ var wildcardPrefixLen = pathParts[0].length;
+ if (wildcardPrefixLen >= maxWildcardPrefixLen &&
+ name.substr(0, pathParts[0].length) == pathParts[0] &&
+ name.substr(name.length - pathParts[1].length) == pathParts[1]) {
+ maxWildcardPrefixLen = wildcardPrefixLen;
+ pathMatch = p;
+ wildcard = name.substr(pathParts[0].length, name.length - pathParts[1].length - pathParts[0].length);
+ }
+ }
+ }
+
+ var outPath = paths[pathMatch];
+ if (typeof wildcard == 'string')
+ outPath = outPath.replace('*', wildcard);
+
+ return outPath;
+}
+
+function dedupe(deps) {
+ var newDeps = [];
+ for (var i = 0, l = deps.length; i < l; i++)
+ if (indexOf.call(newDeps, deps[i]) == -1)
+ newDeps.push(deps[i])
+ return newDeps;
+}
+
+function group(deps) {
+ var names = [];
+ var indices = [];
+ for (var i = 0, l = deps.length; i < l; i++) {
+ var index = indexOf.call(names, deps[i]);
+ if (index === -1) {
+ names.push(deps[i]);
+ indices.push([i]);
+ }
+ else {
+ indices[index].push(i);
+ }
+ }
+ return { names: names, indices: indices };
+}
+
+var getOwnPropertyDescriptor = true;
+try {
+ Object.getOwnPropertyDescriptor({ a: 0 }, 'a');
+}
+catch(e) {
+ getOwnPropertyDescriptor = false;
+}
+
+// converts any module.exports object into an object ready for SystemJS.newModule
+function getESModule(exports) {
+ var esModule = {};
+ // don't trigger getters/setters in environments that support them
+ if ((typeof exports == 'object' || typeof exports == 'function') && exports !== __global) {
+ if (getOwnPropertyDescriptor) {
+ for (var p in exports) {
+ // The default property is copied to esModule later on
+ if (p === 'default')
+ continue;
+ defineOrCopyProperty(esModule, exports, p);
+ }
+ }
+ else {
+ extend(esModule, exports);
+ }
+ }
+ esModule['default'] = exports;
+ defineProperty(esModule, '__useDefault', {
+ value: true
+ });
+ return esModule;
+}
+
+function defineOrCopyProperty(targetObj, sourceObj, propName) {
+ try {
+ var d;
+ if (d = Object.getOwnPropertyDescriptor(sourceObj, propName))
+ defineProperty(targetObj, propName, d);
+ }
+ catch (ex) {
+ // Object.getOwnPropertyDescriptor threw an exception, fall back to normal set property
+ // we dont need hasOwnProperty here because getOwnPropertyDescriptor would have returned undefined above
+ targetObj[propName] = sourceObj[propName];
+ return false;
+ }
+}
+
+function extend(a, b, prepend) {
+ var hasOwnProperty = b && b.hasOwnProperty;
+ for (var p in b) {
+ if (hasOwnProperty && !b.hasOwnProperty(p))
+ continue;
+ if (!prepend || !(p in a))
+ a[p] = b[p];
+ }
+ return a;
+}
+
+// meta first-level extends where:
+// array + array appends
+// object + object extends
+// other properties replace
+function extendMeta(a, b, prepend) {
+ var hasOwnProperty = b && b.hasOwnProperty;
+ for (var p in b) {
+ if (hasOwnProperty && !b.hasOwnProperty(p))
+ continue;
+ var val = b[p];
+ if (!(p in a))
+ a[p] = val;
+ else if (val instanceof Array && a[p] instanceof Array)
+ a[p] = [].concat(prepend ? val : a[p]).concat(prepend ? a[p] : val);
+ else if (typeof val == 'object' && val !== null && typeof a[p] == 'object')
+ a[p] = extend(extend({}, a[p]), val, prepend);
+ else if (!prepend)
+ a[p] = val;
+ }
+}
+
+function extendPkgConfig(pkgCfgA, pkgCfgB, pkgName, loader, warnInvalidProperties) {
+ for (var prop in pkgCfgB) {
+ if (indexOf.call(['main', 'format', 'defaultExtension', 'basePath'], prop) != -1) {
+ pkgCfgA[prop] = pkgCfgB[prop];
+ }
+ else if (prop == 'map') {
+ extend(pkgCfgA.map = pkgCfgA.map || {}, pkgCfgB.map);
+ }
+ else if (prop == 'meta') {
+ extend(pkgCfgA.meta = pkgCfgA.meta || {}, pkgCfgB.meta);
+ }
+ else if (prop == 'depCache') {
+ for (var d in pkgCfgB.depCache) {
+ var dNormalized;
+
+ if (d.substr(0, 2) == './')
+ dNormalized = pkgName + '/' + d.substr(2);
+ else
+ dNormalized = coreResolve.call(loader, d);
+ loader.depCache[dNormalized] = (loader.depCache[dNormalized] || []).concat(pkgCfgB.depCache[d]);
+ }
+ }
+ else if (warnInvalidProperties && indexOf.call(['browserConfig', 'nodeConfig', 'devConfig', 'productionConfig'], prop) == -1 &&
+ (!pkgCfgB.hasOwnProperty || pkgCfgB.hasOwnProperty(prop))) {
+ warn.call(loader, '"' + prop + '" is not a valid package configuration option in package ' + pkgName);
+ }
+ }
+}
+
+// deeply-merge (to first level) config with any existing package config
+function setPkgConfig(loader, pkgName, cfg, prependConfig) {
+ var pkg;
+
+ // first package is config by reference for fast path, cloned after that
+ if (!loader.packages[pkgName]) {
+ pkg = loader.packages[pkgName] = cfg;
+ }
+ else {
+ var basePkg = loader.packages[pkgName];
+ pkg = loader.packages[pkgName] = {};
+
+ extendPkgConfig(pkg, prependConfig ? cfg : basePkg, pkgName, loader, prependConfig);
+ extendPkgConfig(pkg, prependConfig ? basePkg : cfg, pkgName, loader, !prependConfig);
+ }
+
+ // main object becomes main map
+ if (typeof pkg.main == 'object') {
+ pkg.map = pkg.map || {};
+ pkg.map['./@main'] = pkg.main;
+ pkg.main['default'] = pkg.main['default'] || './';
+ pkg.main = '@main';
+ }
+
+ return pkg;
+}
+
+function warn(msg) {
+ if (this.warnings && typeof console != 'undefined' && console.warn)
+ console.warn(msg);
+}
+var absURLRegEx = /^([^\/]+:\/\/|\/)/;
+
+// Normalization with module names as absolute URLs
+SystemJSLoader.prototype.normalize = function(name, parentName, parentAddress) {
+ // NB does `import 'file.js'` import relative to the parent name or baseURL?
+ // have assumed that it is baseURL-relative here, but spec may well align with URLs to be the latter
+ // safe option for users is to always use "./file.js" for relative
+
+ // not absolute or relative -> apply paths (what will be sites)
+ if (!name.match(absURLRegEx) && name[0] != '.')
+ name = new URL(applyPaths(this, name) || name, baseURI).href;
+ // apply parent-relative normalization, parentAddress is already normalized
+ else
+ name = new URL(name, parentName || baseURI).href;
+
+ return name;
+};
+
+// default locate is this
+/*
+SystemJSLoader.prototype.locate = function(load) {
+ return load.name;
+};
+*//*
+ * Script tag fetch
+ *
+ * When load.metadata.scriptLoad is true, we load via script tag injection.
+ */
+(function() {
+
+ if (typeof document != 'undefined')
+ var head = document.getElementsByTagName('head')[0];
+
+ var curSystem;
+ var curRequire;
+
+ // if doing worker executing, this is set to the load record being executed
+ var workerLoad = null;
+
+ // interactive mode handling method courtesy RequireJS
+ var ieEvents = head && (function() {
+ var s = document.createElement('script');
+ var isOpera = typeof opera !== 'undefined' && opera.toString() === '[object Opera]';
+ return s.attachEvent && !(s.attachEvent.toString && s.attachEvent.toString().indexOf('[native code') < 0) && !isOpera;
+ })();
+
+ // IE interactive-only part
+ // we store loading scripts array as { script: <script>, load: {...} }
+ var interactiveLoadingScripts = [];
+ var interactiveScript;
+ function getInteractiveScriptLoad() {
+ if (interactiveScript && interactiveScript.script.readyState === 'interactive')
+ return interactiveScript.load;
+
+ for (var i = 0; i < interactiveLoadingScripts.length; i++)
+ if (interactiveLoadingScripts[i].script.readyState == 'interactive') {
+ interactiveScript = interactiveLoadingScripts[i];
+ return interactiveScript.load;
+ }
+ }
+
+ // System.register, System.registerDynamic, AMD define pipeline
+ // this is called by the above methods when they execute
+ // we then run the reduceRegister_ collection function either immediately
+ // if we are in IE and know the currently executing script (interactive)
+ // or later if we need to wait for the synchronous load callback to know the script
+ var loadingCnt = 0;
+ var registerQueue = [];
+ hook('pushRegister_', function(pushRegister) {
+ return function(register) {
+ // if using eval-execution then skip
+ if (pushRegister.call(this, register))
+ return false;
+
+ // if using worker execution, then we're done
+ if (workerLoad)
+ this.reduceRegister_(workerLoad, register);
+
+ // detect if we know the currently executing load (IE)
+ // if so, immediately call reduceRegister
+ else if (ieEvents)
+ this.reduceRegister_(getInteractiveScriptLoad(), register);
+
+ // otherwise, add to our execution queue
+ // to call reduceRegister on sync script load event
+ else if (loadingCnt)
+ registerQueue.push(register);
+
+ // if we're not currently loading anything though
+ // then do the reduction against a null load
+ // (out of band named define or named register)
+ // note even in non-script environments, this catch is used
+ else
+ this.reduceRegister_(null, register);
+
+ return true;
+ };
+ });
+
+ function webWorkerImport(loader, load) {
+ return new Promise(function(resolve, reject) {
+ if (load.metadata.integrity)
+ reject(new Error('Subresource integrity checking is not supported in web workers.'));
+
+ workerLoad = load;
+ try {
+ importScripts(load.address);
+ }
+ catch(e) {
+ workerLoad = null;
+ reject(e);
+ }
+ workerLoad = null;
+
+ // if nothing registered, then something went wrong
+ if (!load.metadata.entry)
+ reject(new Error(load.address + ' did not call System.register or AMD define. If loading a global, ensure the meta format is set to global.'));
+
+ resolve('');
+ });
+ }
+
+ // override fetch to use script injection
+ hook('fetch', function(fetch) {
+ return function(load) {
+ var loader = this;
+
+ if (load.metadata.format == 'json' || !load.metadata.scriptLoad || (!isBrowser && !isWorker))
+ return fetch.call(this, load);
+
+ if (isWorker)
+ return webWorkerImport(loader, load);
+
+ return new Promise(function(resolve, reject) {
+ var s = document.createElement('script');
+
+ s.async = true;
+
+ if (load.metadata.crossOrigin)
+ s.crossOrigin = load.metadata.crossOrigin;
+
+ if (load.metadata.integrity)
+ s.setAttribute('integrity', load.metadata.integrity);
+
+ if (ieEvents) {
+ s.attachEvent('onreadystatechange', complete);
+ interactiveLoadingScripts.push({
+ script: s,
+ load: load
+ });
+ }
+ else {
+ s.addEventListener('load', complete, false);
+ s.addEventListener('error', error, false);
+ }
+
+ loadingCnt++;
+
+ curSystem = __global.System;
+ curRequire = __global.require;
+
+ s.src = load.address;
+ head.appendChild(s);
+
+ function complete(evt) {
+ if (s.readyState && s.readyState != 'loaded' && s.readyState != 'complete')
+ return;
+
+ loadingCnt--;
+
+ // complete call is sync on execution finish
+ // (in ie already done reductions)
+ if (!load.metadata.entry && !registerQueue.length) {
+ loader.reduceRegister_(load);
+ }
+ else if (!ieEvents) {
+ for (var i = 0; i < registerQueue.length; i++)
+ loader.reduceRegister_(load, registerQueue[i]);
+ registerQueue = [];
+ }
+
+ cleanup();
+
+ // if nothing registered, then something went wrong
+ if (!load.metadata.entry && !load.metadata.bundle)
+ reject(new Error(load.name + ' did not call System.register or AMD define. If loading a global module configure the global name via the meta exports property for script injection support.'));
+
+ resolve('');
+ }
+
+ function error(evt) {
+ cleanup();
+ reject(new Error('Unable to load script ' + load.address));
+ }
+
+ function cleanup() {
+ __global.System = curSystem;
+ __global.require = curRequire;
+
+ if (s.detachEvent) {
+ s.detachEvent('onreadystatechange', complete);
+ for (var i = 0; i < interactiveLoadingScripts.length; i++)
+ if (interactiveLoadingScripts[i].script == s) {
+ if (interactiveScript && interactiveScript.script == s)
+ interactiveScript = null;
+ interactiveLoadingScripts.splice(i, 1);
+ }
+ }
+ else {
+ s.removeEventListener('load', complete, false);
+ s.removeEventListener('error', error, false);
+ }
+
+ head.removeChild(s);
+ }
+ });
+ };
+ });
+})();
+/*
+ * Instantiate registry extension
+ *
+ * Supports Traceur System.register 'instantiate' output for loading ES6 as ES5.
+ *
+ * - Creates the loader.register function
+ * - Also supports metadata.format = 'register' in instantiate for anonymous register modules
+ * - Also supports metadata.deps, metadata.execute and metadata.executingRequire
+ * for handling dynamic modules alongside register-transformed ES6 modules
+ *
+ *
+ * The code here replicates the ES6 linking groups algorithm to ensure that
+ * circular ES6 compiled into System.register can work alongside circular AMD
+ * and CommonJS, identically to the actual ES6 loader.
+ *
+ */
+
+
+/*
+ * Registry side table entries in loader.defined
+ * Registry Entry Contains:
+ * - name
+ * - deps
+ * - declare for declarative modules
+ * - execute for dynamic modules, different to declarative execute on module
+ * - executingRequire indicates require drives execution for circularity of dynamic modules
+ * - declarative optional boolean indicating which of the above
+ *
+ * Can preload modules directly on SystemJS.defined['my/module'] = { deps, execute, executingRequire }
+ *
+ * Then the entry gets populated with derived information during processing:
+ * - normalizedDeps derived from deps, created in instantiate
+ * - groupIndex used by group linking algorithm
+ * - evaluated indicating whether evaluation has happend
+ * - module the module record object, containing:
+ * - exports actual module exports
+ *
+ * For dynamic we track the es module with:
+ * - esModule actual es module value
+ * - esmExports whether to extend the esModule with named exports
+ *
+ * Then for declarative only we track dynamic bindings with the 'module' records:
+ * - name
+ * - exports
+ * - setters declarative setter functions
+ * - dependencies, module records of dependencies
+ * - importers, module records of dependents
+ *
+ * After linked and evaluated, entries are removed, declarative module records remain in separate
+ * module binding table
+ *
+ */
+
+var leadingCommentAndMetaRegEx = /^(\s*\/\*[^\*]*(\*(?!\/)[^\*]*)*\*\/|\s*\/\/[^\n]*|\s*"[^"]+"\s*;?|\s*'[^']+'\s*;?)*\s*/;
+function detectRegisterFormat(source) {
+ var leadingCommentAndMeta = source.match(leadingCommentAndMetaRegEx);
+ return leadingCommentAndMeta && source.substr(leadingCommentAndMeta[0].length, 15) == 'System.register';
+}
+
+function createEntry() {
+ return {
+ name: null,
+ deps: null,
+ originalIndices: null,
+ declare: null,
+ execute: null,
+ executingRequire: false,
+ declarative: false,
+ normalizedDeps: null,
+ groupIndex: null,
+ evaluated: false,
+ module: null,
+ esModule: null,
+ esmExports: false
+ };
+}
+
+(function() {
+
+ /*
+ * There are two variations of System.register:
+ * 1. System.register for ES6 conversion (2-3 params) - System.register([name, ]deps, declare)
+ * see https://github.com/ModuleLoader/es6-module-loader/wiki/System.register-Explained
+ *
+ * 2. System.registerDynamic for dynamic modules (3-4 params) - System.registerDynamic([name, ]deps, executingRequire, execute)
+ * the true or false statement
+ *
+ * this extension implements the linking algorithm for the two variations identical to the spec
+ * allowing compiled ES6 circular references to work alongside AMD and CJS circular references.
+ *
+ */
+ SystemJSLoader.prototype.register = function(name, deps, declare) {
+ if (typeof name != 'string') {
+ declare = deps;
+ deps = name;
+ name = null;
+ }
+
+ // dynamic backwards-compatibility
+ // can be deprecated eventually
+ if (typeof declare == 'boolean')
+ return this.registerDynamic.apply(this, arguments);
+
+ var entry = createEntry();
+ // ideally wouldn't apply map config to bundle names but
+ // dependencies go through map regardless so we can't restrict
+ // could reconsider in shift to new spec
+ entry.name = name && (this.decanonicalize || this.normalize).call(this, name);
+ entry.declarative = true;
+ entry.deps = deps;
+ entry.declare = declare;
+
+ this.pushRegister_({
+ amd: false,
+ entry: entry
+ });
+ };
+ SystemJSLoader.prototype.registerDynamic = function(name, deps, declare, execute) {
+ if (typeof name != 'string') {
+ execute = declare;
+ declare = deps;
+ deps = name;
+ name = null;
+ }
+
+ // dynamic
+ var entry = createEntry();
+ entry.name = name && (this.decanonicalize || this.normalize).call(this, name);
+ entry.deps = deps;
+ entry.execute = execute;
+ entry.executingRequire = declare;
+
+ this.pushRegister_({
+ amd: false,
+ entry: entry
+ });
+ };
+ hook('reduceRegister_', function() {
+ return function(load, register) {
+ if (!register)
+ return;
+
+ var entry = register.entry;
+ var curMeta = load && load.metadata;
+
+ // named register
+ if (entry.name) {
+ if (!(entry.name in this.defined))
+ this.defined[entry.name] = entry;
+
+ if (curMeta)
+ curMeta.bundle = true;
+ }
+ // anonymous register
+ if (!entry.name || load && !curMeta.entry && entry.name == load.name) {
+ if (!curMeta)
+ throw new TypeError('Invalid System.register call. Anonymous System.register calls can only be made by modules loaded by SystemJS.import and not via script tags.');
+ if (curMeta.entry) {
+ if (curMeta.format == 'register')
+ throw new Error('Multiple anonymous System.register calls in module ' + load.name + '. If loading a bundle, ensure all the System.register calls are named.');
+ else
+ throw new Error('Module ' + load.name + ' interpreted as ' + curMeta.format + ' module format, but called System.register.');
+ }
+ if (!curMeta.format)
+ curMeta.format = 'register';
+ curMeta.entry = entry;
+ }
+ };
+ });
+
+ hookConstructor(function(constructor) {
+ return function() {
+ constructor.call(this);
+
+ this.defined = {};
+ this._loader.moduleRecords = {};
+ };
+ });
+
+ function buildGroups(entry, loader, groups) {
+ groups[entry.groupIndex] = groups[entry.groupIndex] || [];
+
+ if (indexOf.call(groups[entry.groupIndex], entry) != -1)
+ return;
+
+ groups[entry.groupIndex].push(entry);
+
+ for (var i = 0, l = entry.normalizedDeps.length; i < l; i++) {
+ var depName = entry.normalizedDeps[i];
+ var depEntry = loader.defined[depName];
+
+ // not in the registry means already linked / ES6
+ if (!depEntry || depEntry.evaluated)
+ continue;
+
+ // now we know the entry is in our unlinked linkage group
+ var depGroupIndex = entry.groupIndex + (depEntry.declarative != entry.declarative);
+
+ // the group index of an entry is always the maximum
+ if (depEntry.groupIndex === null || depEntry.groupIndex < depGroupIndex) {
+
+ // if already in a group, remove from the old group
+ if (depEntry.groupIndex !== null) {
+ groups[depEntry.groupIndex].splice(indexOf.call(groups[depEntry.groupIndex], depEntry), 1);
+
+ // if the old group is empty, then we have a mixed depndency cycle
+ if (groups[depEntry.groupIndex].length == 0)
+ throw new Error("Mixed dependency cycle detected");
+ }
+
+ depEntry.groupIndex = depGroupIndex;
+ }
+
+ buildGroups(depEntry, loader, groups);
+ }
+ }
+
+ function link(name, startEntry, loader) {
+ // skip if already linked
+ if (startEntry.module)
+ return;
+
+ startEntry.groupIndex = 0;
+
+ var groups = [];
+
+ buildGroups(startEntry, loader, groups);
+
+ var curGroupDeclarative = !!startEntry.declarative == groups.length % 2;
+ for (var i = groups.length - 1; i >= 0; i--) {
+ var group = groups[i];
+ for (var j = 0; j < group.length; j++) {
+ var entry = group[j];
+
+ // link each group
+ if (curGroupDeclarative)
+ linkDeclarativeModule(entry, loader);
+ else
+ linkDynamicModule(entry, loader);
+ }
+ curGroupDeclarative = !curGroupDeclarative;
+ }
+ }
+
+ // module binding records
+ function ModuleRecord() {}
+ defineProperty(ModuleRecord, 'toString', {
+ value: function() {
+ return 'Module';
+ }
+ });
+
+ function getOrCreateModuleRecord(name, moduleRecords) {
+ return moduleRecords[name] || (moduleRecords[name] = {
+ name: name,
+ dependencies: [],
+ exports: new ModuleRecord(), // start from an empty module and extend
+ importers: []
+ });
+ }
+
+ function linkDeclarativeModule(entry, loader) {
+ // only link if already not already started linking (stops at circular)
+ if (entry.module)
+ return;
+
+ var moduleRecords = loader._loader.moduleRecords;
+ var module = entry.module = getOrCreateModuleRecord(entry.name, moduleRecords);
+ var exports = entry.module.exports;
+
+ var declaration = entry.declare.call(__global, function(name, value) {
+ module.locked = true;
+
+ if (typeof name == 'object') {
+ for (var p in name)
+ exports[p] = name[p];
+ }
+ else {
+ exports[name] = value;
+ }
+
+ for (var i = 0, l = module.importers.length; i < l; i++) {
+ var importerModule = module.importers[i];
+ if (!importerModule.locked) {
+ var importerIndex = indexOf.call(importerModule.dependencies, module);
+ var setter = importerModule.setters[importerIndex];
+ if (setter)
+ setter(exports);
+ }
+ }
+
+ module.locked = false;
+ return value;
+ }, { id: entry.name });
+
+ if (typeof declaration == 'function')
+ declaration = { setters: [], execute: declaration };
+
+ // allowing undefined declaration was a mistake! To be deprecated.
+ declaration = declaration || { setters: [], execute: function() {} };
+
+ module.setters = declaration.setters;
+ module.execute = declaration.execute;
+
+ if (!module.setters || !module.execute) {
+ throw new TypeError('Invalid System.register form for ' + entry.name);
+ }
+
+ // now link all the module dependencies
+ for (var i = 0, l = entry.normalizedDeps.length; i < l; i++) {
+ var depName = entry.normalizedDeps[i];
+ var depEntry = loader.defined[depName];
+ var depModule = moduleRecords[depName];
+
+ // work out how to set depExports based on scenarios...
+ var depExports;
+
+ if (depModule) {
+ depExports = depModule.exports;
+ }
+ // dynamic, already linked in our registry
+ else if (depEntry && !depEntry.declarative) {
+ depExports = depEntry.esModule;
+ }
+ // in the loader registry
+ else if (!depEntry) {
+ depExports = loader.get(depName);
+ }
+ // we have an entry -> link
+ else {
+ linkDeclarativeModule(depEntry, loader);
+ depModule = depEntry.module;
+ depExports = depModule.exports;
+ }
+
+ // only declarative modules have dynamic bindings
+ if (depModule && depModule.importers) {
+ depModule.importers.push(module);
+ module.dependencies.push(depModule);
+ }
+ else {
+ module.dependencies.push(null);
+ }
+
+ // run setters for all entries with the matching dependency name
+ var originalIndices = entry.originalIndices[i];
+ for (var j = 0, len = originalIndices.length; j < len; ++j) {
+ var index = originalIndices[j];
+ if (module.setters[index]) {
+ module.setters[index](depExports);
+ }
+ }
+ }
+ }
+
+ // An analog to loader.get covering execution of all three layers (real declarative, simulated declarative, simulated dynamic)
+ function getModule(name, loader) {
+ var exports;
+ var entry = loader.defined[name];
+
+ if (!entry) {
+ exports = loader.get(name);
+ if (!exports)
+ throw new Error('Unable to load dependency ' + name + '.');
+ }
+
+ else {
+ if (entry.declarative)
+ ensureEvaluated(name, entry, [], loader);
+
+ else if (!entry.evaluated)
+ linkDynamicModule(entry, loader);
+
+ exports = entry.module.exports;
+ }
+
+ if ((!entry || entry.declarative) && exports && exports.__useDefault)
+ return exports['default'];
+
+ return exports;
+ }
+
+ function linkDynamicModule(entry, loader) {
+ if (entry.module)
+ return;
+
+ var exports = {};
+
+ var module = entry.module = { exports: exports, id: entry.name };
+
+ // AMD requires execute the tree first
+ if (!entry.executingRequire) {
+ for (var i = 0, l = entry.normalizedDeps.length; i < l; i++) {
+ var depName = entry.normalizedDeps[i];
+ // we know we only need to link dynamic due to linking algorithm
+ var depEntry = loader.defined[depName];
+ if (depEntry)
+ linkDynamicModule(depEntry, loader);
+ }
+ }
+
+ // now execute
+ entry.evaluated = true;
+ var output = entry.execute.call(__global, function(name) {
+ for (var i = 0, l = entry.deps.length; i < l; i++) {
+ if (entry.deps[i] != name)
+ continue;
+ return getModule(entry.normalizedDeps[i], loader);
+ }
+ // try and normalize the dependency to see if we have another form
+ var nameNormalized = loader.normalizeSync(name, entry.name);
+ if (indexOf.call(entry.normalizedDeps, nameNormalized) != -1)
+ return getModule(nameNormalized, loader);
+
+ throw new Error('Module ' + name + ' not declared as a dependency of ' + entry.name);
+ }, exports, module);
+
+ if (output !== undefined)
+ module.exports = output;
+
+ // create the esModule object, which allows ES6 named imports of dynamics
+ exports = module.exports;
+
+ // __esModule flag treats as already-named
+ if (exports && (exports.__esModule || exports instanceof Module))
+ entry.esModule = loader.newModule(exports);
+ // set module as 'default' export, then fake named exports by iterating properties
+ else if (entry.esmExports && exports !== __global)
+ entry.esModule = loader.newModule(getESModule(exports));
+ // just use the 'default' export
+ else
+ entry.esModule = loader.newModule({ 'default': exports, __useDefault: true });
+ }
+
+ /*
+ * Given a module, and the list of modules for this current branch,
+ * ensure that each of the dependencies of this module is evaluated
+ * (unless one is a circular dependency already in the list of seen
+ * modules, in which case we execute it)
+ *
+ * Then we evaluate the module itself depth-first left to right
+ * execution to match ES6 modules
+ */
+ function ensureEvaluated(moduleName, entry, seen, loader) {
+ // if already seen, that means it's an already-evaluated non circular dependency
+ if (!entry || entry.evaluated || !entry.declarative)
+ return;
+
+ // this only applies to declarative modules which late-execute
+
+ seen.push(moduleName);
+
+ for (var i = 0, l = entry.normalizedDeps.length; i < l; i++) {
+ var depName = entry.normalizedDeps[i];
+ if (indexOf.call(seen, depName) == -1) {
+ if (!loader.defined[depName])
+ loader.get(depName);
+ else
+ ensureEvaluated(depName, loader.defined[depName], seen, loader);
+ }
+ }
+
+ if (entry.evaluated)
+ return;
+
+ entry.evaluated = true;
+ entry.module.execute.call(__global);
+ }
+
+ // override the delete method to also clear the register caches
+ hook('delete', function(del) {
+ return function(name) {
+ delete this._loader.moduleRecords[name];
+ delete this.defined[name];
+ return del.call(this, name);
+ };
+ });
+
+ hook('fetch', function(fetch) {
+ return function(load) {
+ if (this.defined[load.name]) {
+ load.metadata.format = 'defined';
+ return '';
+ }
+
+ load.metadata.deps = load.metadata.deps || [];
+
+ return fetch.call(this, load);
+ };
+ });
+
+ hook('translate', function(translate) {
+ // we run the meta detection here (register is after meta)
+ return function(load) {
+ load.metadata.deps = load.metadata.deps || [];
+ return Promise.resolve(translate.apply(this, arguments)).then(function(source) {
+ // run detection for register format
+ if (load.metadata.format == 'register' || !load.metadata.format && detectRegisterFormat(load.source))
+ load.metadata.format = 'register';
+ return source;
+ });
+ };
+ });
+
+ // implement a perforance shortpath for System.load with no deps
+ hook('load', function(doLoad) {
+ return function(normalized) {
+ var loader = this;
+ var entry = loader.defined[normalized];
+
+ if (!entry || entry.deps.length)
+ return doLoad.apply(this, arguments);
+
+ entry.originalIndices = entry.normalizedDeps = [];
+
+ // recursively ensure that the module and all its
+ // dependencies are linked (with dependency group handling)
+ link(normalized, entry, loader);
+
+ // now handle dependency execution in correct order
+ ensureEvaluated(normalized, entry, [], loader);
+ if (!entry.esModule)
+ entry.esModule = loader.newModule(entry.module.exports);
+
+ // remove from the registry
+ if (!loader.trace)
+ loader.defined[normalized] = undefined;
+
+ // return the defined module object
+ loader.set(normalized, entry.esModule);
+
+ return Promise.resolve();
+ };
+ });
+
+ hook('instantiate', function(instantiate) {
+ return function(load) {
+ if (load.metadata.format == 'detect')
+ load.metadata.format = undefined;
+
+ // assumes previous instantiate is sync
+ // (core json support)
+ instantiate.call(this, load);
+
+ var loader = this;
+
+ var entry;
+
+ // first we check if this module has already been defined in the registry
+ if (loader.defined[load.name]) {
+ entry = loader.defined[load.name];
+ // don't support deps for ES modules
+ if (!entry.declarative)
+ entry.deps = entry.deps.concat(load.metadata.deps);
+ entry.deps = entry.deps.concat(load.metadata.deps);
+ }
+
+ // picked up already by an anonymous System.register script injection
+ // or via the dynamic formats
+ else if (load.metadata.entry) {
+ entry = load.metadata.entry;
+ entry.deps = entry.deps.concat(load.metadata.deps);
+ }
+
+ // Contains System.register calls
+ // (dont run bundles in the builder)
+ else if (!(loader.builder && load.metadata.bundle)
+ && (load.metadata.format == 'register' || load.metadata.format == 'esm' || load.metadata.format == 'es6')) {
+
+ if (typeof __exec != 'undefined')
+ __exec.call(loader, load);
+
+ if (!load.metadata.entry && !load.metadata.bundle)
+ throw new Error(load.name + ' detected as ' + load.metadata.format + ' but didn\'t execute.');
+
+ entry = load.metadata.entry;
+
+ // support metadata deps for System.register
+ if (entry && load.metadata.deps)
+ entry.deps = entry.deps.concat(load.metadata.deps);
+ }
+
+ // named bundles are just an empty module
+ if (!entry) {
+ entry = createEntry();
+ entry.deps = load.metadata.deps;
+ entry.execute = function() {};
+ }
+
+ // place this module onto defined for circular references
+ loader.defined[load.name] = entry;
+
+ var grouped = group(entry.deps);
+
+ entry.deps = grouped.names;
+ entry.originalIndices = grouped.indices;
+ entry.name = load.name;
+ entry.esmExports = load.metadata.esmExports !== false;
+
+ // first, normalize all dependencies
+ var normalizePromises = [];
+ for (var i = 0, l = entry.deps.length; i < l; i++)
+ normalizePromises.push(Promise.resolve(loader.normalize(entry.deps[i], load.name)));
+
+ return Promise.all(normalizePromises).then(function(normalizedDeps) {
+
+ entry.normalizedDeps = normalizedDeps;
+
+ return {
+ deps: entry.deps,
+ execute: function() {
+ // recursively ensure that the module and all its
+ // dependencies are linked (with dependency group handling)
+ link(load.name, entry, loader);
+
+ // now handle dependency execution in correct order
+ ensureEvaluated(load.name, entry, [], loader);
+
+ if (!entry.esModule)
+ entry.esModule = loader.newModule(entry.module.exports);
+
+ // remove from the registry
+ if (!loader.trace)
+ loader.defined[load.name] = undefined;
+
+ // return the defined module object
+ return entry.esModule;
+ }
+ };
+ });
+ };
+ });
+})();
+/*
+ System bundles
+
+ Allows a bundle module to be specified which will be dynamically
+ loaded before trying to load a given module.
+
+ For example:
+ SystemJS.bundles['mybundle'] = ['jquery', 'bootstrap/js/bootstrap']
+
+ Will result in a load to "mybundle" whenever a load to "jquery"
+ or "bootstrap/js/bootstrap" is made.
+
+ In this way, the bundle becomes the request that provides the module
+*/
+
+(function() {
+ // bundles support (just like RequireJS)
+ // bundle name is module name of bundle itself
+ // bundle is array of modules defined by the bundle
+ // when a module in the bundle is requested, the bundle is loaded instead
+ // of the form SystemJS.bundles['mybundle'] = ['jquery', 'bootstrap/js/bootstrap']
+ hookConstructor(function(constructor) {
+ return function() {
+ constructor.call(this);
+ this.bundles = {};
+ this._loader.loadedBundles = {};
+ };
+ });
+
+ // assign bundle metadata for bundle loads
+ hook('locate', function(locate) {
+ return function(load) {
+ var loader = this;
+ var matched = false;
+
+ if (!(load.name in loader.defined))
+ for (var b in loader.bundles) {
+ for (var i = 0; i < loader.bundles[b].length; i++) {
+ var curModule = loader.bundles[b][i];
+
+ if (curModule == load.name) {
+ matched = true;
+ break;
+ }
+
+ // wildcard in bundles does not include / boundaries
+ if (curModule.indexOf('*') != -1) {
+ var parts = curModule.split('*');
+ if (parts.length != 2) {
+ loader.bundles[b].splice(i--, 1);
+ continue;
+ }
+
+ if (load.name.substring(0, parts[0].length) == parts[0] &&
+ load.name.substr(load.name.length - parts[1].length, parts[1].length) == parts[1] &&
+ load.name.substr(parts[0].length, load.name.length - parts[1].length - parts[0].length).indexOf('/') == -1) {
+ matched = true;
+ break;
+ }
+ }
+ }
+
+ if (matched)
+ return loader['import'](b)
+ .then(function() {
+ return locate.call(loader, load);
+ });
+ }
+
+ return locate.call(loader, load);
+ };
+ });
+})();
+/*
+ * Script-only addition used for production loader
+ *
+ */
+hookConstructor(function(constructor) {
+ return function() {
+ constructor.apply(this, arguments);
+ __global.define = this.amdDefine;
+ };
+});
+
+hook('fetch', function(fetch) {
+ return function(load) {
+ load.metadata.scriptLoad = true;
+ return fetch.call(this, load);
+ };
+});System = new SystemJSLoader();
+
+__global.SystemJS = System;
+System.version = '0.19.39 Register Only';
+ if (typeof module == 'object' && module.exports && typeof exports == 'object')
+ module.exports = System;
+
+ __global.System = System;
+
+})(typeof self != 'undefined' ? self : global); \ No newline at end of file
diff --git a/dist/system.js b/dist/system.js
new file mode 100644
index 000000000..f6f69052e
--- /dev/null
+++ b/dist/system.js
@@ -0,0 +1,6 @@
+/*
+ * SystemJS v0.19.39
+ */
+!function(){function e(){!function(e){function t(e,r){if("string"!=typeof e)throw new TypeError("URL must be a string");var n=String(e).replace(/^\s+|\s+$/g,"").match(/^([^:\/?#]+:)?(?:\/\/(?:([^:@\/?#]*)(?::([^:@\/?#]*))?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/);if(!n)throw new RangeError("Invalid URL format");var a=n[1]||"",o=n[2]||"",i=n[3]||"",s=n[4]||"",l=n[5]||"",u=n[6]||"",d=n[7]||"",c=n[8]||"",f=n[9]||"";if(void 0!==r){var m=r instanceof t?r:new t(r),p=!a&&!s&&!o;!p||d||c||(c=m.search),p&&"/"!==d[0]&&(d=d?(!m.host&&!m.username||m.pathname?"":"/")+m.pathname.slice(0,m.pathname.lastIndexOf("/")+1)+d:m.pathname);var h=[];d.replace(/^(\.\.?(\/|$))+/,"").replace(/\/(\.(\/|$))+/g,"/").replace(/\/\.\.$/,"/../").replace(/\/?[^\/]*/g,function(e){"/.."===e?h.pop():h.push(e)}),d=h.join("").replace(/^\//,"/"===d[0]?"/":""),p&&(u=m.port,l=m.hostname,s=m.host,i=m.password,o=m.username),a||(a=m.protocol)}d=d.replace(/\\/g,"/"),this.origin=s?a+(""!==a||""!==s?"//":"")+s:"",this.href=a+(a&&s||"file:"==a?"//":"")+(""!==o?o+(""!==i?":"+i:"")+"@":"")+s+d+c+f,this.protocol=a,this.username=o,this.password=i,this.host=s,this.hostname=l,this.port=u,this.pathname=d,this.search=c,this.hash=f}e.URLPolyfill=t}("undefined"!=typeof self?self:global),function(e){function t(e,t){if(!e.originalErr)for(var r=((e.message||e)+(e.stack?"\n"+e.stack:"")).toString().split("\n"),n=[],a=0;a<r.length;a++)"undefined"!=typeof $__curScript&&r[a].indexOf($__curScript.src)!=-1||n.push(r[a]);var o="(SystemJS) "+(n?n.join("\n\t"):e.message.substr(11))+"\n\t"+t;F||(o=o.replace(D?/file:\/\/\//g:/file:\/\//g,""));var i=$?new Error(o,e.fileName,e.lineNumber):new Error(o);return i.stack=o,i.originalErr=e.originalErr||e,i}function r(){}function n(t){this._loader={loaderObj:this,loads:[],modules:{},importPromises:{},moduleRecords:{}},q(this,"global",{get:function(){return e}})}function a(){n.call(this),this.paths={},this._loader.paths={},V.call(this)}function o(){}function i(e,t){a.prototype[e]=t(a.prototype[e]||function(){})}function s(e){V=e(V||function(){})}function l(e){return e.match(Y)}function u(e){return"."==e[0]&&(!e[1]||"/"==e[1]||"."==e[1])||"/"==e[0]}function d(e){return!u(e)&&!l(e)}function c(e,t){if("."==e[0]){if("/"==e[1]&&"."!=e[2])return(t&&t.substr(0,t.lastIndexOf("/")+1)||J)+e.substr(2)}else if("/"!=e[0]&&e.indexOf(":")==-1)return(t&&t.substr(0,t.lastIndexOf("/")+1)||J)+e;return new H(e,t&&t.replace(/#/g,"%05")||K).href.replace(/%05/g,"#")}function f(e,t){var r,n="",a=0,o=e.paths,i=e._loader.paths;for(var s in o)if(!o.hasOwnProperty||o.hasOwnProperty(s)){var l=o[s];if(l!==i[s]&&(l=o[s]=i[s]=c(o[s],u(o[s])?J:e.baseURL)),s.indexOf("*")===-1){if(t==s)return o[s];if(t.substr(0,s.length-1)==s.substr(0,s.length-1)&&(t.length<s.length||t[s.length-1]==s[s.length-1])&&("/"==o[s][o[s].length-1]||""==o[s]))return o[s].substr(0,o[s].length-1)+(t.length>s.length?(o[s]&&"/"||"")+t.substr(s.length):"")}else{var d=s.split("*");if(d.length>2)throw new TypeError("Only one wildcard in a path is permitted");var f=d[0].length;f>=a&&t.substr(0,d[0].length)==d[0]&&t.substr(t.length-d[1].length)==d[1]&&(a=f,n=s,r=t.substr(d[0].length,t.length-d[1].length-d[0].length))}}var m=o[n];return"string"==typeof r&&(m=m.replace("*",r)),m}function m(e){for(var t=[],r=[],n=0,a=e.length;n<a;n++){var o=U.call(t,e[n]);o===-1?(t.push(e[n]),r.push([n])):r[o].push(n)}return{names:t,indices:r}}function p(t){var r={};if(("object"==typeof t||"function"==typeof t)&&t!==e)if(Q)for(var n in t)"default"!==n&&h(r,t,n);else g(r,t);return r.default=t,q(r,"__useDefault",{value:!0}),r}function h(e,t,r){try{var n;(n=Object.getOwnPropertyDescriptor(t,r))&&q(e,r,n)}catch(n){return e[r]=t[r],!1}}function g(e,t,r){var n=t&&t.hasOwnProperty;for(var a in t)n&&!t.hasOwnProperty(a)||r&&a in e||(e[a]=t[a]);return e}function v(e,t,r){var n=t&&t.hasOwnProperty;for(var a in t)if(!n||t.hasOwnProperty(a)){var o=t[a];a in e?o instanceof Array&&e[a]instanceof Array?e[a]=[].concat(r?o:e[a]).concat(r?e[a]:o):"object"==typeof o&&null!==o&&"object"==typeof e[a]?e[a]=g(g({},e[a]),o,r):r||(e[a]=o):e[a]=o}}function b(e,t,r,n,a){for(var o in t)if(U.call(["main","format","defaultExtension","basePath"],o)!=-1)e[o]=t[o];else if("map"==o)g(e.map=e.map||{},t.map);else if("meta"==o)g(e.meta=e.meta||{},t.meta);else if("depCache"==o)for(var i in t.depCache){var s;s="./"==i.substr(0,2)?r+"/"+i.substr(2):P.call(n,i),n.depCache[s]=(n.depCache[s]||[]).concat(t.depCache[i])}else!a||U.call(["browserConfig","nodeConfig","devConfig","productionConfig"],o)!=-1||t.hasOwnProperty&&!t.hasOwnProperty(o)||w.call(n,'"'+o+'" is not a valid package configuration option in package '+r)}function y(e,t,r,n){var a;if(e.packages[t]){var o=e.packages[t];a=e.packages[t]={},b(a,n?r:o,t,e,n),b(a,n?o:r,t,e,!n)}else a=e.packages[t]=r;return"object"==typeof a.main&&(a.map=a.map||{},a.map["./@main"]=a.main,a.main.default=a.main.default||"./",a.main="@main"),a}function w(e){this.warnings&&"undefined"!=typeof console&&console.warn}function x(e,t){for(var r=e.split(".");r.length;)t=t[r.shift()];return t}function S(e,t){var r,n=0;for(var a in e)if(t.substr(0,a.length)==a&&(t.length==a.length||"/"==t[a.length])){var o=a.split("/").length;if(o<=n)continue;r=a,n=o}return r}function _(e){this._loader.baseURL!==this.baseURL&&("/"!=this.baseURL[this.baseURL.length-1]&&(this.baseURL+="/"),this._loader.baseURL=this.baseURL=new H(this.baseURL,K).href)}function E(e,t){this.set("@system-env",te=this.newModule({browser:F,node:!!this._nodeRequire,production:!t&&e,dev:t||!e,build:t,default:!0}))}function j(e,t){if(!d(e))throw new Error("Node module "+e+" can't be loaded as it is not a package require.");if(!re){var r=this._nodeRequire("module"),n=t.substr(D?8:7);re=new r(n),re.paths=r._nodeModulePaths(n)}return re.require(e)}function P(e,t){if(u(e))return c(e,t);if(l(e))return e;var r=S(this.map,e);if(r){if(e=this.map[r]+e.substr(r.length),u(e))return c(e);if(l(e))return e}if(this.has(e))return e;if("@node/"==e.substr(0,6)){if(!this._nodeRequire)throw new TypeError("Error loading "+e+". Can only load node core modules in Node.");return this.builder?this.set(e,this.newModule({})):this.set(e,this.newModule(p(j.call(this,e.substr(6),this.baseURL)))),e}return _.call(this),f(this,e)||this.baseURL+e}function O(e,t,r){te.browser&&t.browserConfig&&r(t.browserConfig),te.node&&t.nodeConfig&&r(t.nodeConfig),te.dev&&t.devConfig&&r(t.devConfig),te.build&&t.buildConfig&&r(t.buildConfig),te.production&&t.productionConfig&&r(t.productionConfig)}function k(e){var t=e.match(oe);return t&&"System.register"==e.substr(t[0].length,15)}function M(){return{name:null,deps:null,originalIndices:null,declare:null,execute:null,executingRequire:!1,declarative:!1,normalizedDeps:null,groupIndex:null,evaluated:!1,module:null,esModule:null,esmExports:!1}}function R(t){if("string"==typeof t)return x(t,e);if(!(t instanceof Array))throw new Error("Global exports must be a string or array.");for(var r={},n=!0,a=0;a<t.length;a++){var o=x(t[a],e);n&&(r.default=o,n=!1),r[t[a].split(".").pop()]=o}return r}function z(e){var t,r,n,n="~"==e[0],a=e.lastIndexOf("|");return a!=-1?(t=e.substr(a+1),r=e.substr(n,a-n),n&&w.call(this,'Condition negation form "'+e+'" is deprecated for "'+r+"|~"+t+'"'),"~"==t[0]&&(n=!0,t=t.substr(1))):(t="default",r=e.substr(n),se.indexOf(r)!=-1&&(t=r,r=null)),{module:r||"@system-env",prop:t,negate:n}}function I(e){return e.module+"|"+(e.negate?"~":"")+e.prop}function T(e,t,r){var n=this;return this.normalize(e.module,t).then(function(t){return n.load(t).then(function(a){var o=x(e.prop,n.get(t));if(r&&"boolean"!=typeof o)throw new TypeError("Condition "+I(e)+" did not resolve to a boolean.");return e.negate?!o:o})})}function C(e,t){var r=e.match(le);if(!r)return Promise.resolve(e);var n=z.call(this,r[0].substr(2,r[0].length-3));return this.builder?this.normalize(n.module,t).then(function(t){return n.module=t,e.replace(le,"#{"+I(n)+"}")}):T.call(this,n,t,!1).then(function(r){if("string"!=typeof r)throw new TypeError("The condition value for "+e+" doesn't resolve to a string.");if(r.indexOf("/")!=-1)throw new TypeError("Unabled to interpolate conditional "+e+(t?" in "+t:"")+"\n\tThe condition value "+r+' cannot contain a "/" separator.');return e.replace(le,r)})}function L(e,t){var r=e.lastIndexOf("#?");if(r==-1)return Promise.resolve(e);var n=z.call(this,e.substr(r+2));return this.builder?this.normalize(n.module,t).then(function(t){return n.module=t,e.substr(0,r)+"#?"+I(n)}):T.call(this,n,t,!0).then(function(t){return t?e.substr(0,r):"@empty"})}var A="undefined"==typeof window&&"undefined"!=typeof self&&"undefined"!=typeof importScripts,F="undefined"!=typeof window&&"undefined"!=typeof document,D="undefined"!=typeof process&&"undefined"!=typeof process.platform&&!!process.platform.match(/^win/);e.console||(e.console={assert:function(){}});var q,U=Array.prototype.indexOf||function(e){for(var t=0,r=this.length;t<r;t++)if(this[t]===e)return t;return-1};!function(){try{Object.defineProperty({},"a",{})&&(q=Object.defineProperty)}catch(e){q=function(e,t,r){try{e[t]=r.value||r.get.call(e)}catch(e){}}}}();var J,$="_"==new Error(0,"_").fileName;if("undefined"!=typeof document&&document.getElementsByTagName){if(J=document.baseURI,!J){var N=document.getElementsByTagName("base");J=N[0]&&N[0].href||window.location.href}}else"undefined"!=typeof location&&(J=e.location.href);if(J)J=J.split("#")[0].split("?")[0],J=J.substr(0,J.lastIndexOf("/")+1);else{if("undefined"==typeof process||!process.cwd)throw new TypeError("No environment baseURI");J="file://"+(D?"/":"")+process.cwd()+"/",D&&(J=J.replace(/\\/g,"/"))}try{var B="test:"==new e.URL("test:///").protocol}catch(e){}var H=B?e.URL:e.URLPolyfill;q(r.prototype,"toString",{value:function(){return"Module"}}),function(){function e(e){return{status:"loading",name:e||"<Anonymous"+ ++y+">",linkSets:[],dependencies:[],metadata:{}}}function a(e,t,r){return new Promise(u({step:r.address?"fetch":"locate",loader:e,moduleName:t,moduleMetadata:r&&r.metadata||{},moduleSource:r.source,moduleAddress:r.address}))}function o(t,r,n,a){return new Promise(function(e,o){e(t.loaderObj.normalize(r,n,a))}).then(function(r){var n;if(t.modules[r])return n=e(r),n.status="linked",n.module=t.modules[r],n;for(var a=0,o=t.loads.length;a<o;a++)if(n=t.loads[a],n.name==r)return n;return n=e(r),t.loads.push(n),i(t,n),n})}function i(e,t){s(e,t,Promise.resolve().then(function(){return e.loaderObj.locate({name:t.name,metadata:t.metadata})}))}function s(e,t,r){l(e,t,r.then(function(r){if("loading"==t.status)return t.address=r,e.loaderObj.fetch({name:t.name,metadata:t.metadata,address:r})}))}function l(e,t,r){r.then(function(r){if("loading"==t.status)return t.address=t.address||t.name,Promise.resolve(e.loaderObj.translate({name:t.name,metadata:t.metadata,address:t.address,source:r})).then(function(r){return t.source=r,e.loaderObj.instantiate({name:t.name,metadata:t.metadata,address:t.address,source:r})}).then(function(e){if(void 0===e)throw new TypeError("Declarative modules unsupported in the polyfill.");if("object"!=typeof e)throw new TypeError("Invalid instantiate return value");t.depsList=e.deps||[],t.execute=e.execute}).then(function(){t.dependencies=[];for(var r=t.depsList,n=[],a=0,i=r.length;a<i;a++)(function(r,a){n.push(o(e,r,t.name,t.address).then(function(e){if(t.dependencies[a]={key:r,value:e.name},"linked"!=e.status)for(var n=t.linkSets.concat([]),o=0,i=n.length;o<i;o++)c(n[o],e)}))})(r[a],a);return Promise.all(n)}).then(function(){t.status="loaded";for(var e=t.linkSets.concat([]),r=0,n=e.length;r<n;r++)m(e[r],t)})}).catch(function(e){t.status="failed",t.exception=e;for(var r=t.linkSets.concat([]),n=0,a=r.length;n<a;n++)p(r[n],t,e)})}function u(t){return function(r,n){var a=t.loader,o=t.moduleName,u=t.step;if(a.modules[o])throw new TypeError('"'+o+'" already exists in the module table');for(var c,f=0,m=a.loads.length;f<m;f++)if(a.loads[f].name==o&&(c=a.loads[f],"translate"!=u||c.source||(c.address=t.moduleAddress,l(a,c,Promise.resolve(t.moduleSource))),c.linkSets.length&&c.linkSets[0].loads[0].name==c.name))return c.linkSets[0].done.then(function(){r(c)});var p=c||e(o);p.metadata=t.moduleMetadata;var h=d(a,p);a.loads.push(p),r(h.done),"locate"==u?i(a,p):"fetch"==u?s(a,p,Promise.resolve(t.moduleAddress)):(p.address=t.moduleAddress,l(a,p,Promise.resolve(t.moduleSource)))}}function d(e,t){var r={loader:e,loads:[],startingLoad:t,loadingCount:0};return r.done=new Promise(function(e,t){r.resolve=e,r.reject=t}),c(r,t),r}function c(e,t){if("failed"!=t.status){for(var r=0,n=e.loads.length;r<n;r++)if(e.loads[r]==t)return;e.loads.push(t),t.linkSets.push(e),"loaded"!=t.status&&e.loadingCount++;for(var a=e.loader,r=0,n=t.dependencies.length;r<n;r++)if(t.dependencies[r]){var o=t.dependencies[r].value;if(!a.modules[o])for(var i=0,s=a.loads.length;i<s;i++)if(a.loads[i].name==o){c(e,a.loads[i]);break}}}}function f(e){var t=!1;try{b(e,function(r,n){p(e,r,n),t=!0})}catch(r){p(e,null,r),t=!0}return t}function m(e,t){if(e.loadingCount--,!(e.loadingCount>0)){var r=e.startingLoad;if(e.loader.loaderObj.execute===!1){for(var n=[].concat(e.loads),a=0,o=n.length;a<o;a++){var t=n[a];t.module={name:t.name,module:w({}),evaluated:!0},t.status="linked",h(e.loader,t)}return e.resolve(r)}var i=f(e);i||e.resolve(r)}}function p(e,r,n){var a=e.loader;e:if(r)if(e.loads[0].name==r.name)n=t(n,"Error loading "+r.name);else{for(var o=0;o<e.loads.length;o++)for(var i=e.loads[o],s=0;s<i.dependencies.length;s++){var l=i.dependencies[s];if(l.value==r.name){n=t(n,"Error loading "+r.name+' as "'+l.key+'" from '+i.name);break e}}n=t(n,"Error loading "+r.name+" from "+e.loads[0].name)}else n=t(n,"Error linking "+e.loads[0].name);for(var u=e.loads.concat([]),o=0,d=u.length;o<d;o++){var r=u[o];a.loaderObj.failed=a.loaderObj.failed||[],U.call(a.loaderObj.failed,r)==-1&&a.loaderObj.failed.push(r);var c=U.call(r.linkSets,e);if(r.linkSets.splice(c,1),0==r.linkSets.length){var f=U.call(e.loader.loads,r);f!=-1&&e.loader.loads.splice(f,1)}}e.reject(n)}function h(e,t){if(e.loaderObj.trace){e.loaderObj.loads||(e.loaderObj.loads={});var r={};t.dependencies.forEach(function(e){r[e.key]=e.value}),e.loaderObj.loads[t.name]={name:t.name,deps:t.dependencies.map(function(e){return e.key}),depMap:r,address:t.address,metadata:t.metadata,source:t.source}}t.name&&(e.modules[t.name]=t.module);var n=U.call(e.loads,t);n!=-1&&e.loads.splice(n,1);for(var a=0,o=t.linkSets.length;a<o;a++)n=U.call(t.linkSets[a].loads,t),n!=-1&&t.linkSets[a].loads.splice(n,1);t.linkSets.splice(0,t.linkSets.length)}function g(e,t,n){try{var a=t.execute()}catch(e){return void n(t,e)}return a&&a instanceof r?a:void n(t,new TypeError("Execution must define a Module instance"))}function v(e,t,r){var n=e._loader.importPromises;return n[t]=r.then(function(e){return n[t]=void 0,e},function(e){throw n[t]=void 0,e})}function b(e,t){var r=e.loader;if(e.loads.length)for(var n=e.loads.concat([]),a=0;a<n.length;a++){var o=n[a],i=g(e,o,t);if(!i)return;o.module={name:o.name,module:i},o.status="linked",h(r,o)}}var y=0;n.prototype={constructor:n,define:function(e,t,r){if(this._loader.importPromises[e])throw new TypeError("Module is already loading.");return v(this,e,new Promise(u({step:"translate",loader:this._loader,moduleName:e,moduleMetadata:r&&r.metadata||{},moduleSource:t,moduleAddress:r&&r.address})))},delete:function(e){var t=this._loader;return delete t.importPromises[e],delete t.moduleRecords[e],!!t.modules[e]&&delete t.modules[e]},get:function(e){if(this._loader.modules[e])return this._loader.modules[e].module},has:function(e){return!!this._loader.modules[e]},import:function(e,t,r){"object"==typeof t&&(t=t.name);var n=this;return Promise.resolve(n.normalize(e,t)).then(function(e){var t=n._loader;return t.modules[e]?t.modules[e].module:t.importPromises[e]||v(n,e,a(t,e,{}).then(function(r){return delete t.importPromises[e],r.module.module}))})},load:function(e){var t=this._loader;return t.modules[e]?Promise.resolve():t.importPromises[e]||v(this,e,new Promise(u({step:"locate",loader:t,moduleName:e,moduleMetadata:{},moduleSource:void 0,moduleAddress:void 0})).then(function(){delete t.importPromises[e]}))},module:function(t,r){var n=e();n.address=r&&r.address;var a=d(this._loader,n),o=Promise.resolve(t),i=this._loader,s=a.done.then(function(){return n.module.module});return l(i,n,o),s},newModule:function(e){if("object"!=typeof e)throw new TypeError("Expected object");var t=new r,n=[];if(Object.getOwnPropertyNames&&null!=e)n=Object.getOwnPropertyNames(e);else for(var a in e)n.push(a);for(var o=0;o<n.length;o++)(function(r){q(t,r,{configurable:!1,enumerable:!0,get:function(){return e[r]},set:function(){throw new Error("Module exports cannot be changed externally.")}})})(n[o]);return Object.freeze&&Object.freeze(t),t},set:function(e,t){if(!(t instanceof r))throw new TypeError("Loader.set("+e+", module) must be a module");this._loader.modules[e]={module:t}},normalize:function(e,t,r){},locate:function(e){return e.name},fetch:function(e){},translate:function(e){return e.source},instantiate:function(e){}};var w=n.prototype.newModule}();var X,G;if("undefined"!=typeof XMLHttpRequest)G=function(e,t,r,n){function a(){r(i.responseText)}function o(){n(new Error("XHR error"+(i.status?" ("+i.status+(i.statusText?" "+i.statusText:"")+")":"")+" loading "+e))}var i=new XMLHttpRequest,s=!0,l=!1;if(!("withCredentials"in i)){var u=/^(\w+:)?\/\/([^\/]+)/.exec(e);u&&(s=u[2]===window.location.host,u[1]&&(s&=u[1]===window.location.protocol))}s||"undefined"==typeof XDomainRequest||(i=new XDomainRequest,i.onload=a,i.onerror=o,i.ontimeout=o,i.onprogress=function(){},i.timeout=0,l=!0),i.onreadystatechange=function(){4===i.readyState&&(0==i.status?i.responseText?a():(i.addEventListener("error",o),i.addEventListener("load",a)):200===i.status?a():o())},i.open("GET",e,!0),i.setRequestHeader&&(i.setRequestHeader("Accept","application/x-es-module, */*"),t&&("string"==typeof t&&i.setRequestHeader("Authorization",t),i.withCredentials=!0)),l?setTimeout(function(){i.send()},0):i.send(null)};else if("undefined"!=typeof require&&"undefined"!=typeof process){var Z;G=function(e,t,r,n){if("file:///"!=e.substr(0,8))throw new Error('Unable to fetch "'+e+'". Only file URLs of the form file:/// allowed running in Node.');return Z=Z||require("fs"),e=D?e.replace(/\//g,"\\").substr(8):e.substr(7),Z.readFile(e,function(e,t){if(e)return n(e);var a=t+"";"\ufeff"===a[0]&&(a=a.substr(1)),r(a)})}}else{if("undefined"==typeof self||"undefined"==typeof self.fetch)throw new TypeError("No environment fetch API available.");G=function(e,t,r,n){var a={headers:{Accept:"application/x-es-module, */*"}};t&&("string"==typeof t&&(a.headers.Authorization=t),a.credentials="include"),fetch(e,a).then(function(e){if(e.ok)return e.text();throw new Error("Fetch error: "+e.status+" "+e.statusText)}).then(r,n)}}var W=function(){function t(t){var n=this;return Promise.resolve(e["typescript"==n.transpiler?"ts":n.transpiler]||(n.pluginLoader||n).import(n.transpiler)).then(function(e){e.__useDefault&&(e=e.default);var a;return a=e.Compiler?r:e.createLanguageService?i:o,"(function(__moduleName){"+a.call(n,t,e)+'\n})("'+t.name+'");\n//# sourceURL='+t.address+"!transpiled"})}function r(e,t){var r=this.traceurOptions||{};r.modules="instantiate",r.script=!1,void 0===r.sourceMaps&&(r.sourceMaps="inline"),r.filename=e.address,r.inputSourceMap=e.metadata.sourceMap,r.moduleName=!1;var n=new t.Compiler(r);return a(e.source,n,r.filename)}function a(e,t,r){try{return t.compile(e,r)}catch(e){if(e.length)throw e[0];throw e}}function o(e,t){var r=this.babelOptions||{};return r.modules="system",void 0===r.sourceMap&&(r.sourceMap="inline"),r.inputSourceMap=e.metadata.sourceMap,r.filename=e.address,r.code=!0,r.ast=!1,t.transform(e.source,r).code}function i(e,t){var r=this.typescriptOptions||{};return r.target=r.target||t.ScriptTarget.ES5,void 0===r.sourceMap&&(r.sourceMap=!0),r.sourceMap&&r.inlineSourceMap!==!1&&(r.inlineSourceMap=!0),r.module=t.ModuleKind.System,t.transpile(e.source,r,e.address)}return n.prototype.transpiler="traceur",t}();o.prototype=n.prototype,a.prototype=new o,a.prototype.constructor=a;var V,Y=/^[^\/]+:\/\//,K=new H(J),Q=!0;try{Object.getOwnPropertyDescriptor({a:0},"a")}catch(e){Q=!1}var ee;!function(){function r(e){return l?d+new Buffer(e).toString("base64"):"undefined"!=typeof btoa?d+btoa(unescape(encodeURIComponent(e))):""}function n(e,t){var n=e.source.lastIndexOf("\n");"global"==e.metadata.format&&(t=!1);var a=e.metadata.sourceMap;if(a){if("object"!=typeof a)throw new TypeError("load.metadata.sourceMap must be set to an object.");a=JSON.stringify(a)}return(t?"(function(System, SystemJS) {":"")+e.source+(t?"\n})(System, System);":"")+("\n//# sourceURL="!=e.source.substr(n,15)?"\n//# sourceURL="+e.address+(a?"!transpiled":""):"")+(a&&r(a)||"")}function a(t,r){u=r,0==p++&&(c=e.System),e.System=e.SystemJS=t}function o(){0==--p&&(e.System=e.SystemJS=c),u=void 0}function s(e){v||(v=document.head||document.body||document.documentElement);var r=document.createElement("script");r.text=n(e,!1);var i,s=window.onerror;if(window.onerror=function(r){i=t(r,"Evaluating "+e.address),s&&s.apply(this,arguments)},a(this,e),e.metadata.integrity&&r.setAttribute("integrity",e.metadata.integrity),e.metadata.nonce&&r.setAttribute("nonce",e.metadata.nonce),v.appendChild(r),v.removeChild(r),o(),window.onerror=s,i)throw i}var l="undefined"!=typeof Buffer;try{l&&"YQ=="!=new Buffer("a").toString("base64")&&(l=!1)}catch(e){l=!1}var u,d="\n//# sourceMappingURL=data:application/json;base64,";i("pushRegister_",function(){return function(e){return!!u&&(this.reduceRegister_(u,e),!0)}});var c,f,m,p=0;ee=function(e){if(e.source){if((e.metadata.integrity||e.metadata.nonce)&&h)return s.call(this,e);try{a(this,e),u=e,!m&&this._nodeRequire&&(m=this._nodeRequire("vm"),f=m.runInThisContext("typeof System !== 'undefined' && System")===this),f?m.runInThisContext(n(e,!0),{filename:e.address+(e.metadata.sourceMap?"!transpiled":"")}):(0,eval)(n(e,!0)),o()}catch(r){throw o(),t(r,"Evaluating "+e.address)}}};var h=!1;if(F&&"undefined"!=typeof document&&document.getElementsByTagName){var g=document.getElementsByTagName("script");$__curScript=g[g.length-1],window.chrome&&window.chrome.extension||navigator.userAgent.match(/^Node\.js/)||(h=!0)}var v}();var te;s(function(e){return function(){e.call(this),this.baseURL=J,this.map={},"undefined"!=typeof $__curScript&&(this.scriptSrc=$__curScript.src),this.warnings=!1,this.defaultJSExtensions=!1,this.pluginFirst=!1,this.loaderErrorStack=!1,this.set("@empty",this.newModule({})),E.call(this,!1,!1)}}),"undefined"==typeof require||"undefined"==typeof process||process.browser||(a.prototype._nodeRequire=require);var re;i("normalize",function(e){return function(e,t,r){var n=P.call(this,e,t);return!this.defaultJSExtensions||r||".js"==n.substr(n.length-3,3)||d(n)||(n+=".js"),n}});var ne="undefined"!=typeof XMLHttpRequest;i("locate",function(e){return function(t){return Promise.resolve(e.call(this,t)).then(function(e){return ne?e.replace(/#/g,"%23"):e})}}),i("fetch",function(){return function(e){return new Promise(function(t,r){G(e.address,e.metadata.authorization,t,r)})}}),i("import",function(e){return function(t,r,n){return r&&r.name&&w.call(this,"SystemJS.import(name, { name: parentName }) is deprecated for SystemJS.import(name, parentName), while importing "+t+" from "+r.name),e.call(this,t,r,n).then(function(e){return e.__useDefault?e.default:e})}}),i("translate",function(e){return function(t){return"detect"==t.metadata.format&&(t.metadata.format=void 0),e.apply(this,arguments)}}),i("instantiate",function(e){return function(e){if("json"==e.metadata.format&&!this.builder){var t=e.metadata.entry=M();t.deps=[],t.execute=function(){try{return JSON.parse(e.source)}catch(t){throw new Error("Invalid JSON file "+e.name)}}}}}),a.prototype.getConfig=function(e){var t={},r=this;for(var n in r)r.hasOwnProperty&&!r.hasOwnProperty(n)||n in a.prototype&&"transpiler"!=n||U.call(["_loader","amdDefine","amdRequire","defined","failed","version","loads"],n)==-1&&(t[n]=r[n]);return t.production=te.production,t};var ae;a.prototype.config=function(e,t){function r(e){for(var t in e)if(e.hasOwnProperty(t))return!0}var n=this;if("loaderErrorStack"in e&&(ae=$__curScript,e.loaderErrorStack?$__curScript=void 0:$__curScript=ae),"warnings"in e&&(n.warnings=e.warnings),e.transpilerRuntime===!1&&(n._loader.loadedTranspilerRuntime=!0),("production"in e||"build"in e)&&E.call(n,!!e.production,!!(e.build||te&&te.build)),!t){var a;if(O(n,e,function(e){a=a||e.baseURL}),a=a||e.baseURL){if(r(n.packages)||r(n.meta)||r(n.depCache)||r(n.bundles)||r(n.packageConfigPaths))throw new TypeError("Incorrect configuration order. The baseURL must be configured with the first SystemJS.config call.");this.baseURL=a,_.call(this)}if(e.paths&&g(n.paths,e.paths),O(n,e,function(e){e.paths&&g(n.paths,e.paths)}),this.warnings)for(var o in n.paths)o.indexOf("*")!=-1&&w.call(n,'Paths configuration "'+o+'" -> "'+n.paths[o]+'" uses wildcards which are being deprecated for simpler trailing "/" folder paths.')}if(e.defaultJSExtensions&&(n.defaultJSExtensions=e.defaultJSExtensions,w.call(n,"The defaultJSExtensions configuration option is deprecated, use packages configuration instead.")),e.pluginFirst&&(n.pluginFirst=e.pluginFirst),e.map){var i="";for(var o in e.map){var s=e.map[o];if("string"!=typeof s){i+=(i.length?", ":"")+'"'+o+'"';var l=n.defaultJSExtensions&&".js"!=o.substr(o.length-3,3),u=n.decanonicalize(o);l&&".js"==u.substr(u.length-3,3)&&(u=u.substr(0,u.length-3));var c="";for(var f in n.packages)u.substr(0,f.length)==f&&(!u[f.length]||"/"==u[f.length])&&c.split("/").length<f.split("/").length&&(c=f);c&&n.packages[c].main&&(u=u.substr(0,u.length-n.packages[c].main.length-1));var f=n.packages[u]=n.packages[u]||{};f.map=s}else n.map[o]=s}i&&w.call(n,"The map configuration for "+i+' uses object submaps, which is deprecated in global map.\nUpdate this to use package contextual map with configs like SystemJS.config({ packages: { "'+o+'": { map: {...} } } }).')}if(e.packageConfigPaths){for(var m=[],p=0;p<e.packageConfigPaths.length;p++){var h=e.packageConfigPaths[p],v=Math.max(h.lastIndexOf("*")+1,h.lastIndexOf("/")),b=P.call(n,h.substr(0,v));m[p]=b+h.substr(v)}n.packageConfigPaths=m}if(e.bundles)for(var o in e.bundles){for(var x=[],p=0;p<e.bundles[o].length;p++){var l=n.defaultJSExtensions&&".js"!=e.bundles[o][p].substr(e.bundles[o][p].length-3,3),S=n.decanonicalize(e.bundles[o][p]);l&&".js"==S.substr(S.length-3,3)&&(S=S.substr(0,S.length-3)),x.push(S)}n.bundles[o]=x}if(e.packages)for(var o in e.packages){if(o.match(/^([^\/]+:)?\/\/$/))throw new TypeError('"'+o+'" is not a valid package name.');var u=P.call(n,o);"/"==u[u.length-1]&&(u=u.substr(0,u.length-1)),y(n,u,e.packages[o],!1)}for(var j in e){var s=e[j];if(U.call(["baseURL","map","packages","bundles","paths","warnings","packageConfigPaths","loaderErrorStack","browserConfig","nodeConfig","devConfig","buildConfig","productionConfig"],j)==-1)if("object"!=typeof s||s instanceof Array)n[j]=s;else{n[j]=n[j]||{};for(var o in s)if("meta"==j&&"*"==o[0])g(n[j][o]=n[j][o]||{},s[o]);else if("meta"==j){var k=P.call(n,o);n.defaultJSExtensions&&".js"!=k.substr(k.length-3,3)&&!d(k)&&(k+=".js"),g(n[j][k]=n[j][k]||{},s[o])}else if("depCache"==j){var l=n.defaultJSExtensions&&".js"!=o.substr(o.length-3,3),u=n.decanonicalize(o);l&&".js"==u.substr(u.length-3,3)&&(u=u.substr(0,u.length-3)),n[j][u]=[].concat(s[o])}else n[j][o]=s[o]}}O(n,e,function(e){n.config(e,!0)})},function(){function e(e,t){var r,n,a=0;for(var o in e.packages)t.substr(0,o.length)!==o||t.length!==o.length&&"/"!==t[o.length]||(n=o.split("/").length,n>a&&(r=o,a=n));return r}function t(e,t,r,n,a){if(!n||"/"==n[n.length-1]||a||t.defaultExtension===!1)return n;var o=!1;if(t.meta&&p(t.meta,n,function(e,t,r){if(0==r||e.lastIndexOf("*")!=e.length-1)return o=!0}),!o&&e.meta&&p(e.meta,r+"/"+n,function(e,t,r){if(0==r||e.lastIndexOf("*")!=e.length-1)return o=!0}),o)return n;var i="."+(t.defaultExtension||"js");return n.substr(n.length-i.length)!=i?n+i:n}function r(e,r,n,a,i){if(!a){if(!r.main)return n+(e.defaultJSExtensions?".js":"");a="./"==r.main.substr(0,2)?r.main.substr(2):r.main}if(r.map){var s="./"+a,l=S(r.map,s);if(l||(s="./"+t(e,r,n,a,i),s!="./"+a&&(l=S(r.map,s))),l){var u=o(e,r,n,l,s,i);if(u)return u}}return n+"/"+t(e,r,n,a,i)}function n(e,t,r,n){if("."==e)throw new Error("Package "+r+' has a map entry for "." which is not permitted.');return!(t.substr(0,e.length)==e&&n.length>e.length)}function o(e,r,a,o,i,s){"/"==i[i.length-1]&&(i=i.substr(0,i.length-1));var l=r.map[o];if("object"==typeof l)throw new Error("Synchronous conditional normalization not supported sync normalizing "+o+" in "+a);if(n(o,l,a,i)&&"string"==typeof l){if("."==l)l=a;else if("./"==l.substr(0,2))return a+"/"+t(e,r,a,l.substr(2)+i.substr(o.length),s);return e.normalizeSync(l+i.substr(o.length),a+"/")}}function l(e,r,n,a,o){if(!a){if(!r.main)return Promise.resolve(n+(e.defaultJSExtensions?".js":""));a="./"==r.main.substr(0,2)?r.main.substr(2):r.main}var i,s;return r.map&&(i="./"+a,s=S(r.map,i),s||(i="./"+t(e,r,n,a,o),i!="./"+a&&(s=S(r.map,i)))),(s?d(e,r,n,s,i,o):Promise.resolve()).then(function(i){return i?Promise.resolve(i):Promise.resolve(n+"/"+t(e,r,n,a,o))})}function u(e,r,n,a,o,i,s){if("."==o)o=n;else if("./"==o.substr(0,2))return Promise.resolve(n+"/"+t(e,r,n,o.substr(2)+i.substr(a.length),s)).then(function(t){return C.call(e,t,n+"/")});return e.normalize(o+i.substr(a.length),n+"/")}function d(e,t,r,a,o,i){"/"==o[o.length-1]&&(o=o.substr(0,o.length-1));var s=t.map[a];if("string"==typeof s)return n(a,s,r,o)?u(e,t,r,a,s,o,i):Promise.resolve();if(e.builder)return Promise.resolve(r+"/#:"+o);var l=[],d=[];for(var c in s){var f=z(c);d.push({condition:f,map:s[c]}),l.push(e.import(f.module,r))}return Promise.all(l).then(function(e){for(var t=0;t<d.length;t++){var r=d[t].condition,n=x(r.prop,e[t]);if(!r.negate&&n||r.negate&&!n)return d[t].map}}).then(function(s){if(s){if(!n(a,s,r,o))return;return u(e,t,r,a,s,o,i)}})}function c(e){var t=e.lastIndexOf("*"),r=Math.max(t+1,e.lastIndexOf("/"));return{length:r,regEx:new RegExp("^("+e.substr(0,r).replace(/[.+?^${}()|[\]\\]/g,"\\$&").replace(/\*/g,"[^\\/]+")+")(\\/|$)"),wildcard:t!=-1}}function f(e,t){for(var r,n,a=!1,o=0;o<e.packageConfigPaths.length;o++){var i=e.packageConfigPaths[o],s=h[i]||(h[i]=c(i));if(!(t.length<s.length)){var l=t.match(s.regEx);!l||r&&(a&&s.wildcard||!(r.length<l[1].length))||(r=l[1],a=!s.wildcard,n=r+i.substr(s.length))}}if(r)return{packageName:r,configPath:n}}function m(e,t,r){var n=e.pluginLoader||e;return(n.meta[r]=n.meta[r]||{}).format="json",n.meta[r].loader=null,n.load(r).then(function(){var a=n.get(r).default;return a.systemjs&&(a=a.systemjs),a.modules&&(a.meta=a.modules,w.call(e,"Package config file "+r+' is configured with "modules", which is deprecated as it has been renamed to "meta".')),y(e,t,a,!0)})}function p(e,t,r){var n;for(var a in e){var o="./"==a.substr(0,2)?"./":"";if(o&&(a=a.substr(2)),n=a.indexOf("*"),n!==-1&&a.substr(0,n)==t.substr(0,n)&&a.substr(n+1)==t.substr(t.length-a.length+n+1)&&r(a,e[o+a],a.split("/").length))return}var i=e[t]&&e.hasOwnProperty&&e.hasOwnProperty(t)?e[t]:e["./"+t];i&&r(i,i,0)}s(function(e){return function(){e.call(this),this.packages={},this.packageConfigPaths=[]}}),a.prototype.normalizeSync=a.prototype.decanonicalize=a.prototype.normalize,i("decanonicalize",function(t){return function(r,n){if(this.builder)return t.call(this,r,n,!0);var a=t.call(this,r,n,!1);if(!this.defaultJSExtensions)return a;var o=e(this,a),i=this.packages[o],s=i&&i.defaultExtension;return void 0==s&&i&&i.meta&&p(i.meta,a.substr(o),function(e,t,r){if(0==r||e.lastIndexOf("*")!=e.length-1)return s=!1,!0}),(s===!1||s&&".js"!=s)&&".js"!=r.substr(r.length-3,3)&&".js"==a.substr(a.length-3,3)&&(a=a.substr(0,a.length-3)),a}}),i("normalizeSync",function(t){return function(n,a,i){var s=this;if(i=i===!0,a)var l=e(s,a)||s.defaultJSExtensions&&".js"==a.substr(a.length-3,3)&&e(s,a.substr(0,a.length-3));
+var u=l&&s.packages[l];if(u&&"."!=n[0]){var d=u.map,c=d&&S(d,n);if(c&&"string"==typeof d[c]){var m=o(s,u,l,c,n,i);if(m)return m}}var p=s.defaultJSExtensions&&".js"!=n.substr(n.length-3,3),h=t.call(s,n,a,!1);p&&".js"!=h.substr(h.length-3,3)&&(p=!1),p&&(h=h.substr(0,h.length-3));var g=f(s,h),v=g&&g.packageName||e(s,h);if(!v)return h+(p?".js":"");var b=h.substr(v.length+1);return r(s,s.packages[v]||{},v,b,i)}}),i("normalize",function(t){return function(r,n,a){var o=this;return a=a===!0,Promise.resolve().then(function(){if(n)var t=e(o,n)||o.defaultJSExtensions&&".js"==n.substr(n.length-3,3)&&e(o,n.substr(0,n.length-3));var i=t&&o.packages[t];if(i&&"./"!=r.substr(0,2)){var s=i.map,l=s&&S(s,r);if(l)return d(o,i,t,l,r,a)}return Promise.resolve()}).then(function(i){if(i)return i;var s=o.defaultJSExtensions&&".js"!=r.substr(r.length-3,3),u=t.call(o,r,n,!1);s&&".js"!=u.substr(u.length-3,3)&&(s=!1),s&&(u=u.substr(0,u.length-3));var d=f(o,u),c=d&&d.packageName||e(o,u);if(!c)return Promise.resolve(u+(s?".js":""));var p=o.packages[c],h=p&&(p.configured||!d);return(h?Promise.resolve(p):m(o,c,d.configPath)).then(function(e){var t=u.substr(c.length+1);return l(o,e,c,t,a)})})}});var h={};i("locate",function(t){return function(r){var n=this;return Promise.resolve(t.call(this,r)).then(function(t){var a=e(n,r.name);if(a){var o=n.packages[a],i=r.name.substr(a.length+1),s={};if(o.meta){var l=0;p(o.meta,i,function(e,t,r){r>l&&(l=r),v(s,t,r&&l>r)}),v(r.metadata,s)}o.format&&!r.metadata.loader&&(r.metadata.format=r.metadata.format||o.format)}return t})}})}(),function(){function t(){if(s&&"interactive"===s.script.readyState)return s.load;for(var e=0;e<d.length;e++)if("interactive"==d[e].script.readyState)return s=d[e],s.load}function r(e,t){return new Promise(function(e,r){t.metadata.integrity&&r(new Error("Subresource integrity checking is not supported in web workers.")),l=t;try{importScripts(t.address)}catch(e){l=null,r(e)}l=null,t.metadata.entry||r(new Error(t.address+" did not call System.register or AMD define. If loading a global, ensure the meta format is set to global.")),e("")})}if("undefined"!=typeof document)var n=document.getElementsByTagName("head")[0];var a,o,s,l=null,u=n&&function(){var e=document.createElement("script"),t="undefined"!=typeof opera&&"[object Opera]"===opera.toString();return e.attachEvent&&!(e.attachEvent.toString&&e.attachEvent.toString().indexOf("[native code")<0)&&!t}(),d=[],c=0,f=[];i("pushRegister_",function(e){return function(r){return!e.call(this,r)&&(l?this.reduceRegister_(l,r):u?this.reduceRegister_(t(),r):c?f.push(r):this.reduceRegister_(null,r),!0)}}),i("fetch",function(t){return function(i){var l=this;return"json"!=i.metadata.format&&i.metadata.scriptLoad&&(F||A)?A?r(l,i):new Promise(function(t,r){function m(e){if(!g.readyState||"loaded"==g.readyState||"complete"==g.readyState){if(c--,i.metadata.entry||f.length){if(!u){for(var n=0;n<f.length;n++)l.reduceRegister_(i,f[n]);f=[]}}else l.reduceRegister_(i);h(),i.metadata.entry||i.metadata.bundle||r(new Error(i.name+" did not call System.register or AMD define. If loading a global module configure the global name via the meta exports property for script injection support.")),t("")}}function p(e){h(),r(new Error("Unable to load script "+i.address))}function h(){if(e.System=a,e.require=o,g.detachEvent){g.detachEvent("onreadystatechange",m);for(var t=0;t<d.length;t++)d[t].script==g&&(s&&s.script==g&&(s=null),d.splice(t,1))}else g.removeEventListener("load",m,!1),g.removeEventListener("error",p,!1);n.removeChild(g)}var g=document.createElement("script");g.async=!0,i.metadata.crossOrigin&&(g.crossOrigin=i.metadata.crossOrigin),i.metadata.integrity&&g.setAttribute("integrity",i.metadata.integrity),u?(g.attachEvent("onreadystatechange",m),d.push({script:g,load:i})):(g.addEventListener("load",m,!1),g.addEventListener("error",p,!1)),c++,a=e.System,o=e.require,g.src=i.address,n.appendChild(g)}):t.call(this,i)}})}();var oe=/^(\s*\/\*[^\*]*(\*(?!\/)[^\*]*)*\*\/|\s*\/\/[^\n]*|\s*"[^"]+"\s*;?|\s*'[^']+'\s*;?)*\s*/;!function(){function t(e,r,n){if(n[e.groupIndex]=n[e.groupIndex]||[],U.call(n[e.groupIndex],e)==-1){n[e.groupIndex].push(e);for(var a=0,o=e.normalizedDeps.length;a<o;a++){var i=e.normalizedDeps[a],s=r.defined[i];if(s&&!s.evaluated){var l=e.groupIndex+(s.declarative!=e.declarative);if(null===s.groupIndex||s.groupIndex<l){if(null!==s.groupIndex&&(n[s.groupIndex].splice(U.call(n[s.groupIndex],s),1),0==n[s.groupIndex].length))throw new Error("Mixed dependency cycle detected");s.groupIndex=l}t(s,r,n)}}}}function n(e,r,n){if(!r.module){r.groupIndex=0;var a=[];t(r,n,a);for(var o=!!r.declarative==a.length%2,i=a.length-1;i>=0;i--){for(var s=a[i],l=0;l<s.length;l++){var d=s[l];o?u(d,n):c(d,n)}o=!o}}}function o(){}function l(e,t){return t[e]||(t[e]={name:e,dependencies:[],exports:new o,importers:[]})}function u(t,r){if(!t.module){var n=r._loader.moduleRecords,a=t.module=l(t.name,n),o=t.module.exports,i=t.declare.call(e,function(e,t){if(a.locked=!0,"object"==typeof e)for(var r in e)o[r]=e[r];else o[e]=t;for(var n=0,i=a.importers.length;n<i;n++){var s=a.importers[n];if(!s.locked){var l=U.call(s.dependencies,a),u=s.setters[l];u&&u(o)}}return a.locked=!1,t},{id:t.name});if("function"==typeof i&&(i={setters:[],execute:i}),i=i||{setters:[],execute:function(){}},a.setters=i.setters,a.execute=i.execute,!a.setters||!a.execute)throw new TypeError("Invalid System.register form for "+t.name);for(var s=0,d=t.normalizedDeps.length;s<d;s++){var c,f=t.normalizedDeps[s],m=r.defined[f],p=n[f];p?c=p.exports:m&&!m.declarative?c=m.esModule:m?(u(m,r),p=m.module,c=p.exports):c=r.get(f),p&&p.importers?(p.importers.push(a),a.dependencies.push(p)):a.dependencies.push(null);for(var h=t.originalIndices[s],g=0,v=h.length;g<v;++g){var b=h[g];a.setters[b]&&a.setters[b](c)}}}}function d(e,t){var r,n=t.defined[e];if(n)n.declarative?f(e,n,[],t):n.evaluated||c(n,t),r=n.module.exports;else if(r=t.get(e),!r)throw new Error("Unable to load dependency "+e+".");return(!n||n.declarative)&&r&&r.__useDefault?r.default:r}function c(t,n){if(!t.module){var a={},o=t.module={exports:a,id:t.name};if(!t.executingRequire)for(var i=0,s=t.normalizedDeps.length;i<s;i++){var l=t.normalizedDeps[i],u=n.defined[l];u&&c(u,n)}t.evaluated=!0;var f=t.execute.call(e,function(e){for(var r=0,a=t.deps.length;r<a;r++)if(t.deps[r]==e)return d(t.normalizedDeps[r],n);var o=n.normalizeSync(e,t.name);if(U.call(t.normalizedDeps,o)!=-1)return d(o,n);throw new Error("Module "+e+" not declared as a dependency of "+t.name)},a,o);void 0!==f&&(o.exports=f),a=o.exports,a&&(a.__esModule||a instanceof r)?t.esModule=n.newModule(a):t.esmExports&&a!==e?t.esModule=n.newModule(p(a)):t.esModule=n.newModule({default:a,__useDefault:!0})}}function f(t,r,n,a){if(r&&!r.evaluated&&r.declarative){n.push(t);for(var o=0,i=r.normalizedDeps.length;o<i;o++){var s=r.normalizedDeps[o];U.call(n,s)==-1&&(a.defined[s]?f(s,a.defined[s],n,a):a.get(s))}r.evaluated||(r.evaluated=!0,r.module.execute.call(e))}}a.prototype.register=function(e,t,r){if("string"!=typeof e&&(r=t,t=e,e=null),"boolean"==typeof r)return this.registerDynamic.apply(this,arguments);var n=M();n.name=e&&(this.decanonicalize||this.normalize).call(this,e),n.declarative=!0,n.deps=t,n.declare=r,this.pushRegister_({amd:!1,entry:n})},a.prototype.registerDynamic=function(e,t,r,n){"string"!=typeof e&&(n=r,r=t,t=e,e=null);var a=M();a.name=e&&(this.decanonicalize||this.normalize).call(this,e),a.deps=t,a.execute=n,a.executingRequire=r,this.pushRegister_({amd:!1,entry:a})},i("reduceRegister_",function(){return function(e,t){if(t){var r=t.entry,n=e&&e.metadata;if(r.name&&(r.name in this.defined||(this.defined[r.name]=r),n&&(n.bundle=!0)),!r.name||e&&!n.entry&&r.name==e.name){if(!n)throw new TypeError("Invalid System.register call. Anonymous System.register calls can only be made by modules loaded by SystemJS.import and not via script tags.");if(n.entry)throw"register"==n.format?new Error("Multiple anonymous System.register calls in module "+e.name+". If loading a bundle, ensure all the System.register calls are named."):new Error("Module "+e.name+" interpreted as "+n.format+" module format, but called System.register.");n.format||(n.format="register"),n.entry=r}}}}),s(function(e){return function(){e.call(this),this.defined={},this._loader.moduleRecords={}}}),q(o,"toString",{value:function(){return"Module"}}),i("delete",function(e){return function(t){return delete this._loader.moduleRecords[t],delete this.defined[t],e.call(this,t)}}),i("fetch",function(e){return function(t){return this.defined[t.name]?(t.metadata.format="defined",""):(t.metadata.deps=t.metadata.deps||[],e.call(this,t))}}),i("translate",function(e){return function(t){return t.metadata.deps=t.metadata.deps||[],Promise.resolve(e.apply(this,arguments)).then(function(e){return("register"==t.metadata.format||!t.metadata.format&&k(t.source))&&(t.metadata.format="register"),e})}}),i("load",function(e){return function(t){var r=this,a=r.defined[t];return!a||a.deps.length?e.apply(this,arguments):(a.originalIndices=a.normalizedDeps=[],n(t,a,r),f(t,a,[],r),a.esModule||(a.esModule=r.newModule(a.module.exports)),r.trace||(r.defined[t]=void 0),r.set(t,a.esModule),Promise.resolve())}}),i("instantiate",function(e){return function(t){"detect"==t.metadata.format&&(t.metadata.format=void 0),e.call(this,t);var r,a=this;if(a.defined[t.name])r=a.defined[t.name],r.declarative||(r.deps=r.deps.concat(t.metadata.deps)),r.deps=r.deps.concat(t.metadata.deps);else if(t.metadata.entry)r=t.metadata.entry,r.deps=r.deps.concat(t.metadata.deps);else if(!(a.builder&&t.metadata.bundle||"register"!=t.metadata.format&&"esm"!=t.metadata.format&&"es6"!=t.metadata.format)){if("undefined"!=typeof ee&&ee.call(a,t),!t.metadata.entry&&!t.metadata.bundle)throw new Error(t.name+" detected as "+t.metadata.format+" but didn't execute.");r=t.metadata.entry,r&&t.metadata.deps&&(r.deps=r.deps.concat(t.metadata.deps))}r||(r=M(),r.deps=t.metadata.deps,r.execute=function(){}),a.defined[t.name]=r;var o=m(r.deps);r.deps=o.names,r.originalIndices=o.indices,r.name=t.name,r.esmExports=t.metadata.esmExports!==!1;for(var i=[],s=0,l=r.deps.length;s<l;s++)i.push(Promise.resolve(a.normalize(r.deps[s],t.name)));return Promise.all(i).then(function(e){return r.normalizedDeps=e,{deps:r.deps,execute:function(){return n(t.name,r,a),f(t.name,r,[],a),r.esModule||(r.esModule=a.newModule(r.module.exports)),a.trace||(a.defined[t.name]=void 0),r.esModule}}})}})}(),function(){var r=/(^\s*|[}\);\n]\s*)(import\s*(['"]|(\*\s+as\s+)?[^"'\(\)\n;]+\s*from\s*['"]|\{)|export\s+\*\s+from\s+["']|export\s*(\{|default|function|class|var|const|let|async\s+function))/,n=/\$traceurRuntime\s*\./,a=/babelHelpers\s*\./;i("translate",function(o){return function(i){var s=this,l=arguments;return o.apply(s,l).then(function(o){if("esm"==i.metadata.format||"es6"==i.metadata.format||!i.metadata.format&&o.match(r)){if("es6"==i.metadata.format&&w.call(s,"Module "+i.name+' has metadata setting its format to "es6", which is deprecated.\nThis should be updated to "esm".'),i.metadata.format="esm",i.metadata.deps){for(var u="",d=0;d<i.metadata.deps.length;d++)u+='import "'+i.metadata.deps[d]+'"; ';i.source=u+o}if(s.transpiler===!1){if(s.builder)return o;throw new TypeError("Unable to dynamically transpile ES module as SystemJS.transpiler set to false.")}return s._loader.loadedTranspiler=s._loader.loadedTranspiler||!1,s.pluginLoader&&(s.pluginLoader._loader.loadedTranspiler=s._loader.loadedTranspiler||!1),(s._loader.transpilerPromise||(s._loader.transpilerPromise=Promise.resolve(e["typescript"==s.transpiler?"ts":s.transpiler]||(s.pluginLoader||s).import(s.transpiler)))).then(function(e){return s._loader.loadedTranspilerRuntime=!0,e.translate?e==i.metadata.loaderModule?i.source:("string"==typeof i.metadata.sourceMap&&(i.metadata.sourceMap=JSON.parse(i.metadata.sourceMap)),Promise.resolve(e.translate.apply(s,l)).then(function(e){var t=i.metadata.sourceMap;if(t&&"object"==typeof t){var r=i.address.split("!")[0];t.file&&t.file!=i.address||(t.file=r+"!transpiled"),(!t.sources||t.sources.length<=1&&(!t.sources[0]||t.sources[0]==i.address))&&(t.sources=[r])}return"esm"==i.metadata.format&&!s.builder&&k(e)&&(i.metadata.format="register"),e})):(s.builder&&(i.metadata.originalSource=i.source),W.call(s,i).then(function(e){return i.metadata.sourceMap=void 0,e}))},function(e){throw t(e,"Unable to load transpiler to transpile "+i.name)})}if(s.transpiler===!1)return o;if(s._loader.loadedTranspiler!==!1||"traceur"!=s.transpiler&&"typescript"!=s.transpiler&&"babel"!=s.transpiler||i.name!=s.normalizeSync(s.transpiler)||(o.length>100&&!i.metadata.format&&(i.metadata.format="global","traceur"===s.transpiler&&(i.metadata.exports="traceur"),"typescript"===s.transpiler&&(i.metadata.exports="ts")),s._loader.loadedTranspiler=!0),s._loader.loadedTranspilerRuntime===!1&&(i.name!=s.normalizeSync("traceur-runtime")&&i.name!=s.normalizeSync("babel/external-helpers*")||(o.length>100&&(i.metadata.format=i.metadata.format||"global"),s._loader.loadedTranspilerRuntime=!0)),("register"==i.metadata.format||i.metadata.bundle)&&s._loader.loadedTranspilerRuntime!==!0){if("traceur"==s.transpiler&&!e.$traceurRuntime&&i.source.match(n))return s._loader.loadedTranspilerRuntime=s._loader.loadedTranspilerRuntime||!1,s.import("traceur-runtime").then(function(){return o});if("babel"==s.transpiler&&!e.babelHelpers&&i.source.match(a))return s._loader.loadedTranspilerRuntime=s._loader.loadedTranspilerRuntime||!1,s.import("babel/external-helpers").then(function(){return o})}return o})}})}();var ie="undefined"!=typeof self?"self":"global";i("fetch",function(e){return function(t){return t.metadata.exports&&!t.metadata.format&&(t.metadata.format="global"),e.call(this,t)}}),i("instantiate",function(e){return function(t){var r=this;if(t.metadata.format||(t.metadata.format="global"),"global"==t.metadata.format&&!t.metadata.entry){var n=M();t.metadata.entry=n,n.deps=[];for(var a in t.metadata.globals){var o=t.metadata.globals[a];o&&n.deps.push(o)}n.execute=function(e,n,a){var o;if(t.metadata.globals){o={};for(var i in t.metadata.globals)t.metadata.globals[i]&&(o[i]=e(t.metadata.globals[i]))}var s=t.metadata.exports;s&&(t.source+="\n"+ie+'["'+s+'"] = '+s+";");var l=r.get("@@global-helpers").prepareGlobal(a.id,s,o,!!t.metadata.encapsulateGlobal);return ee.call(r,t),l()}}return e.call(this,t)}}),i("reduceRegister_",function(e){return function(t,r){if(r||!t.metadata.exports&&(!A||"global"!=t.metadata.format))return e.call(this,t,r);t.metadata.format="global";var n=t.metadata.entry=M();n.deps=t.metadata.deps;var a=R(t.metadata.exports);n.execute=function(){return a}}}),s(function(t){return function(){function r(t){if(Object.keys)Object.keys(e).forEach(t);else for(var r in e)i.call(e,r)&&t(r)}function n(t){r(function(r){if(U.call(s,r)==-1){try{var n=e[r]}catch(e){s.push(r)}t(r,n)}})}var a=this;t.call(a);var o,i=Object.prototype.hasOwnProperty,s=["_g","sessionStorage","localStorage","clipboardData","frames","frameElement","external","mozAnimationStartTime","webkitStorageInfo","webkitIndexedDB","mozInnerScreenY","mozInnerScreenX"];a.set("@@global-helpers",a.newModule({prepareGlobal:function(t,r,a,i){var s=e.define;e.define=void 0;var l;if(a){l={};for(var u in a)l[u]=e[u],e[u]=a[u]}return r||(o={},n(function(e,t){o[e]=t})),function(){var t,a=r?R(r):{},u=!!r;if(r&&!i||n(function(n,s){o[n]!==s&&"undefined"!=typeof s&&(i&&(e[n]=void 0),r||(a[n]=s,"undefined"!=typeof t?u||t===s||(u=!0):t=s))}),a=u?a:t,l)for(var d in l)e[d]=l[d];return e.define=s,a}}}))}}),function(){function t(e){function t(e,t){for(var r=0;r<e.length;r++)if(e[r][0]<t.index&&e[r][1]>t.index)return!0;return!1}n.lastIndex=a.lastIndex=o.lastIndex=0;var r,i=[],s=[],l=[];if(e.length/e.split("\n").length<200){for(;r=o.exec(e);)s.push([r.index,r.index+r[0].length]);for(;r=a.exec(e);)t(s,r)||l.push([r.index+r[1].length,r.index+r[0].length-1])}for(;r=n.exec(e);)if(!t(s,r)&&!t(l,r)){var u=r[1].substr(1,r[1].length-2);if(u.match(/"|'/))continue;"/"==u[u.length-1]&&(u=u.substr(0,u.length-1)),i.push(u)}return i}var r=/(?:^\uFEFF?|[^$_a-zA-Z\xA0-\uFFFF.])(exports\s*(\[['"]|\.)|module(\.exports|\['exports'\]|\["exports"\])\s*(\[['"]|[=,\.]))/,n=/(?:^\uFEFF?|[^$_a-zA-Z\xA0-\uFFFF."'])require\s*\(\s*("[^"\\]*(?:\\.[^"\\]*)*"|'[^'\\]*(?:\\.[^'\\]*)*')\s*\)/g,a=/(^|[^\\])(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/gm,o=/("[^"\\\n\r]*(\\.[^"\\\n\r]*)*"|'[^'\\\n\r]*(\\.[^'\\\n\r]*)*')/g,s=/^\#\!.*/;i("instantiate",function(a){return function(o){var i=this;if(o.metadata.format||(r.lastIndex=0,n.lastIndex=0,(n.exec(o.source)||r.exec(o.source))&&(o.metadata.format="cjs")),"cjs"==o.metadata.format){var l=o.metadata.deps,u=o.metadata.cjsRequireDetection===!1?[]:t(o.source);for(var d in o.metadata.globals)o.metadata.globals[d]&&u.push(o.metadata.globals[d]);var c=M();o.metadata.entry=c,c.deps=u,c.executingRequire=!0,c.execute=function(t,r,n){function a(e){return"/"==e[e.length-1]&&(e=e.substr(0,e.length-1)),t.apply(this,arguments)}if(a.resolve=function(e){return i.get("@@cjs-helpers").requireResolve(e,n.id)},n.paths=[],n.require=t,!o.metadata.cjsDeferDepsExecute)for(var u=0;u<l.length;u++)a(l[u]);var d=i.get("@@cjs-helpers").getPathVars(n.id),c={exports:r,args:[a,r,n,d.filename,d.dirname,e,e]},f="(function(require, exports, module, __filename, __dirname, global, GLOBAL";if(o.metadata.globals)for(var m in o.metadata.globals)c.args.push(a(o.metadata.globals[m])),f+=", "+m;var p=e.define;e.define=void 0,e.__cjsWrapper=c,o.source=f+") {"+o.source.replace(s,"")+"\n}).apply(__cjsWrapper.exports, __cjsWrapper.args);",ee.call(i,o),e.__cjsWrapper=void 0,e.define=p}}return a.call(i,o)}})}(),s(function(e){return function(){function t(e){return"file:///"==e.substr(0,8)?e.substr(7+!!D):n&&e.substr(0,n.length)==n?e.substr(n.length):e}var r=this;if(e.call(r),"undefined"!=typeof window&&"undefined"!=typeof document&&window.location)var n=location.protocol+"//"+location.hostname+(location.port?":"+location.port:"");r.set("@@cjs-helpers",r.newModule({requireResolve:function(e,n){return t(r.normalizeSync(e,n))},getPathVars:function(e){var r,n=e.lastIndexOf("!");r=n!=-1?e.substr(0,n):e;var a=r.split("/");return a.pop(),a=a.join("/"),{filename:t(r),dirname:t(a)}}}))}}),i("fetch",function(t){return function(r){return r.metadata.scriptLoad&&F&&(e.define=this.amdDefine),t.call(this,r)}}),s(function(t){return function(){function r(e,t){e=e.replace(s,"");var r=e.match(d),n=(r[1].split(",")[t]||"require").replace(c,""),a=f[n]||(f[n]=new RegExp(l+n+u,"g"));a.lastIndex=0;for(var o,i=[];o=a.exec(e);)i.push(o[2]||o[3]);return i}function n(e,t,r,a){if("object"==typeof e&&!(e instanceof Array))return n.apply(null,Array.prototype.splice.call(arguments,1,arguments.length-1));if("string"==typeof e&&"function"==typeof t&&(e=[e]),!(e instanceof Array)){if("string"==typeof e){var i=o.defaultJSExtensions&&".js"!=e.substr(e.length-3,3),s=o.decanonicalize(e,a);i&&".js"==s.substr(s.length-3,3)&&(s=s.substr(0,s.length-3));var l=o.get(s);if(!l)throw new Error('Module not already loaded loading "'+e+'" as '+s+(a?' from "'+a+'".':"."));return l.__useDefault?l.default:l}throw new TypeError("Invalid require")}for(var u=[],d=0;d<e.length;d++)u.push(o.import(e[d],a));Promise.all(u).then(function(e){t&&t.apply(null,e)},r)}function a(t,a,i){function s(t,r,s){function c(e,r,a){return"string"==typeof e&&"function"!=typeof r?t(e):n.call(o,e,r,a,s.id)}for(var f=[],m=0;m<a.length;m++)f.push(t(a[m]));s.uri=s.id,s.config=function(){},d!=-1&&f.splice(d,0,s),u!=-1&&f.splice(u,0,r),l!=-1&&(c.toUrl=function(e){var t=o.defaultJSExtensions&&".js"!=e.substr(e.length-3,3),r=o.decanonicalize(e,s.id);return t&&".js"==r.substr(r.length-3,3)&&(r=r.substr(0,r.length-3)),r},f.splice(l,0,c));var p=e.require;e.require=n;var h=i.apply(u==-1?e:r,f);if(e.require=p,"undefined"==typeof h&&s&&(h=s.exports),"undefined"!=typeof h)return h}"string"!=typeof t&&(i=a,a=t,t=null),a instanceof Array||(i=a,a=["require","exports","module"].splice(0,i.length)),"function"!=typeof i&&(i=function(e){return function(){return e}}(i)),void 0===a[a.length-1]&&a.pop();var l,u,d;(l=U.call(a,"require"))!=-1&&(a.splice(l,1),t||(a=a.concat(r(i.toString(),l)))),(u=U.call(a,"exports"))!=-1&&a.splice(u,1),(d=U.call(a,"module"))!=-1&&a.splice(d,1);var c=M();c.name=t&&(o.decanonicalize||o.normalize).call(o,t),c.deps=a,c.execute=s,o.pushRegister_({amd:!0,entry:c})}var o=this;t.call(this);var s=/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/gm,l="(?:^|[^$_a-zA-Z\\xA0-\\uFFFF.])",u="\\s*\\(\\s*(\"([^\"]+)\"|'([^']+)')\\s*\\)",d=/\(([^\)]*)\)/,c=/^\s+|\s+$/g,f={};a.amd={},i("reduceRegister_",function(e){return function(t,r){if(!r||!r.amd)return e.call(this,t,r);var n=t&&t.metadata,a=r.entry;if(n)if(n.format&&"detect"!=n.format){if(!a.name&&"amd"!=n.format)throw new Error("AMD define called while executing "+n.format+" module "+t.name)}else n.format="amd";if(a.name)n&&(n.entry||n.bundle?n.entry&&n.entry.name&&n.entry.name!=t.name&&(n.entry=void 0):n.entry=a,n.bundle=!0),a.name in this.defined||(this.defined[a.name]=a);else{if(!n)throw new TypeError("Unexpected anonymous AMD define.");if(n.entry&&!n.entry.name)throw new Error("Multiple anonymous defines in module "+t.name);n.entry=a}}}),o.amdDefine=a,o.amdRequire=n}}),function(){var t=/(?:^\uFEFF?|[^$_a-zA-Z\xA0-\uFFFF.])define\s*\(\s*("[^"]+"\s*,\s*|'[^']+'\s*,\s*)?\s*(\[(\s*(("[^"]+"|'[^']+')\s*,|\/\/.*\r?\n|\/\*(.|\s)*?\*\/))*(\s*("[^"]+"|'[^']+')\s*,?)?(\s*(\/\/.*\r?\n|\/\*(.|\s)*?\*\/))*\s*\]|function\s*|{|[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*\))/;i("instantiate",function(r){return function(n){var a=this;if("amd"==n.metadata.format||!n.metadata.format&&n.source.match(t))if(n.metadata.format="amd",a.builder||a.execute===!1)n.metadata.execute=function(){return n.metadata.builderExecute.apply(this,arguments)};else{var o=e.define;e.define=this.amdDefine;try{ee.call(a,n)}finally{e.define=o}if(!n.metadata.entry&&!n.metadata.bundle)throw new TypeError("AMD module "+n.name+" did not define")}return r.call(a,n)}})}(),function(){function e(e,t){if(t){var r;if(e.pluginFirst){if((r=t.lastIndexOf("!"))!=-1)return t.substr(r+1)}else if((r=t.indexOf("!"))!=-1)return t.substr(0,r);return t}}function t(e,t){var r,n,a=t.lastIndexOf("!");if(a!=-1)return e.pluginFirst?(r=t.substr(a+1),n=t.substr(0,a)):(r=t.substr(0,a),n=t.substr(a+1)||r.substr(r.lastIndexOf(".")+1)),{argument:r,plugin:n}}function r(e,t,r,n){return n&&".js"==t.substr(t.length-3,3)&&(t=t.substr(0,t.length-3)),e.pluginFirst?r+"!"+t:t+"!"+r}function n(e,t){return e.defaultJSExtensions&&".js"!=t.substr(t.length-3,3)}function a(a){return function(o,i,s){var l=this,u=t(l,o);if(i=e(this,i),!u)return a.call(this,o,i,s);var d=l.normalizeSync(u.argument,i,!0),c=l.normalizeSync(u.plugin,i,!0);return r(l,d,c,n(l,u.argument))}}i("decanonicalize",a),i("normalizeSync",a),i("normalize",function(a){return function(o,i,s){var l=this;i=e(this,i);var u=t(l,o);return u?Promise.all([l.normalize(u.argument,i,!0),l.normalize(u.plugin,i,!1)]).then(function(e){return r(l,e[0],e[1],n(l,u.argument))}):a.call(l,o,i,s)}}),i("locate",function(e){return function(t){var r,n=this,a=t.name;return n.pluginFirst?(r=a.indexOf("!"))!=-1&&(t.metadata.loader=a.substr(0,r),t.name=a.substr(r+1)):(r=a.lastIndexOf("!"))!=-1&&(t.metadata.loader=a.substr(r+1),t.name=a.substr(0,r)),e.call(n,t).then(function(e){return r==-1&&t.metadata.loader?(n.pluginLoader||n).normalize(t.metadata.loader,t.name).then(function(r){return t.metadata.loader=r,e}):e}).then(function(e){var r=t.metadata.loader;if(!r)return e;if(t.name==r)throw new Error("Plugin "+r+" cannot load itself, make sure it is excluded from any wildcard meta configuration via a custom loader: false rule.");if(n.defined&&n.defined[a])return e;var o=n.pluginLoader||n;return o.import(r).then(function(r){return t.metadata.loaderModule=r,t.address=e,r.locate?r.locate.call(n,t):e})})}}),i("fetch",function(e){return function(t){var r=this;return t.metadata.loaderModule&&t.metadata.loaderModule.fetch&&"defined"!=t.metadata.format?(t.metadata.scriptLoad=!1,t.metadata.loaderModule.fetch.call(r,t,function(t){return e.call(r,t)})):e.call(r,t)}}),i("translate",function(e){return function(t){var r=this,n=arguments;return t.metadata.loaderModule&&t.metadata.loaderModule.translate&&"defined"!=t.metadata.format?Promise.resolve(t.metadata.loaderModule.translate.apply(r,n)).then(function(a){var o=t.metadata.sourceMap;if(o){if("object"!=typeof o)throw new Error("load.metadata.sourceMap must be set to an object.");var i=t.address.split("!")[0];o.file&&o.file!=t.address||(o.file=i+"!transpiled"),(!o.sources||o.sources.length<=1&&(!o.sources[0]||o.sources[0]==t.address))&&(o.sources=[i])}return"string"==typeof a?t.source=a:w.call(this,"Plugin "+t.metadata.loader+" should return the source in translate, instead of setting load.source directly. This support will be deprecated."),e.apply(r,n)}):e.apply(r,n)}}),i("instantiate",function(e){return function(t){var r=this,n=!1;return t.metadata.loaderModule&&t.metadata.loaderModule.instantiate&&!r.builder&&"defined"!=t.metadata.format?Promise.resolve(t.metadata.loaderModule.instantiate.call(r,t,function(t){if(n)throw new Error("Instantiate must only be called once.");return n=!0,e.call(r,t)})).then(function(a){return n?a:(t.metadata.entry=M(),t.metadata.entry.execute=function(){return a},t.metadata.entry.deps=t.metadata.deps,t.metadata.format="defined",e.call(r,t))}):e.call(r,t)}})}();var se=["browser","node","dev","build","production","default"],le=/#\{[^\}]+\}/;i("normalize",function(e){return function(t,r,n){var a=this;return L.call(a,t,r).then(function(t){return e.call(a,t,r,n)}).then(function(e){return C.call(a,e,r)})}}),function(){i("fetch",function(e){return function(t){var r=t.metadata.alias,n=t.metadata.deps||[];if(r){t.metadata.format="defined";var a=M();return this.defined[t.name]=a,a.declarative=!0,a.deps=n.concat([r]),a.declare=function(e){return{setters:[function(t){for(var r in t)e(r,t[r]);t.__useDefault&&(a.module.exports.__useDefault=!0)}],execute:function(){}}},""}return e.call(this,t)}})}(),function(){function e(e,t,r){for(var n,a=t.split(".");a.length>1;)n=a.shift(),e=e[n]=e[n]||{};n=a.shift(),n in e||(e[n]=r)}s(function(e){return function(){this.meta={},e.call(this)}}),i("locate",function(e){return function(t){var r,n=this.meta,a=t.name,o=0;for(var i in n)if(r=i.indexOf("*"),r!==-1&&i.substr(0,r)===a.substr(0,r)&&i.substr(r+1)===a.substr(a.length-i.length+r+1)){var s=i.split("/").length;s>o&&(o=s),v(t.metadata,n[i],o!=s)}return n[a]&&v(t.metadata,n[a]),e.call(this,t)}});var t=/^(\s*\/\*[^\*]*(\*(?!\/)[^\*]*)*\*\/|\s*\/\/[^\n]*|\s*"[^"]+"\s*;?|\s*'[^']+'\s*;?)+/,r=/\/\*[^\*]*(\*(?!\/)[^\*]*)*\*\/|\/\/[^\n]*|"[^"]+"\s*;?|'[^']+'\s*;?/g;i("translate",function(n){return function(a){if("defined"==a.metadata.format)return a.metadata.deps=a.metadata.deps||[],Promise.resolve(a.source);var o=a.source.match(t);if(o)for(var i=o[0].match(r),s=0;s<i.length;s++){var l=i[s],u=l.length,d=l.substr(0,1);if(";"==l.substr(u-1,1)&&u--,'"'==d||"'"==d){var c=l.substr(1,l.length-3),f=c.substr(0,c.indexOf(" "));if(f){var m=c.substr(f.length+1,c.length-f.length-1);"[]"==f.substr(f.length-2,2)?(f=f.substr(0,f.length-2),a.metadata[f]=a.metadata[f]||[],a.metadata[f].push(m)):a.metadata[f]instanceof Array?(w.call(this,"Module "+a.name+' contains deprecated "deps '+m+'" meta syntax.\nThis should be updated to "deps[] '+m+'" for pushing to array meta.'),a.metadata[f].push(m)):e(a.metadata,f,m)}else a.metadata[c]=!0}}return n.apply(this,arguments)}})}(),function(){s(function(e){return function(){e.call(this),this.bundles={},this._loader.loadedBundles={}}}),i("locate",function(e){return function(t){var r=this,n=!1;if(!(t.name in r.defined))for(var a in r.bundles){for(var o=0;o<r.bundles[a].length;o++){var i=r.bundles[a][o];if(i==t.name){n=!0;break}if(i.indexOf("*")!=-1){var s=i.split("*");if(2!=s.length){r.bundles[a].splice(o--,1);continue}if(t.name.substring(0,s[0].length)==s[0]&&t.name.substr(t.name.length-s[1].length,s[1].length)==s[1]&&t.name.substr(s[0].length,t.name.length-s[1].length-s[0].length).indexOf("/")==-1){n=!0;break}}}if(n)return r.import(a).then(function(){return e.call(r,t)})}return e.call(r,t)}})}(),function(){s(function(e){return function(){e.call(this),this.depCache={}}}),i("locate",function(e){return function(t){var r=this,n=r.depCache[t.name];if(n)for(var a=0;a<n.length;a++)r.import(n[a],t.name);return e.call(r,t)}})}(),X=new a,e.SystemJS=X,X.version="0.19.39 Standard","object"==typeof module&&module.exports&&"object"==typeof exports&&(module.exports=X),e.System=X}("undefined"!=typeof self?self:global)}var t="undefined"==typeof Promise;if("undefined"!=typeof document){var r=document.getElementsByTagName("script");if($__curScript=r[r.length-1],document.currentScript&&($__curScript.defer||$__curScript.async)&&($__curScript=document.currentScript),t){var n=$__curScript.src,a=n.substr(0,n.lastIndexOf("/")+1);window.systemJSBootstrap=e,document.write('<script type="text/javascript" src="'+a+'system-polyfills.js"></script>')}else e()}else if("undefined"!=typeof importScripts){var a="";try{throw new Error("_")}catch(e){e.stack.replace(/(?:at|@).*(http.+):[\d]+:[\d]+/,function(e,t){$__curScript={src:t},a=t.replace(/\/[^\/]*$/,"/")})}t&&importScripts(a+"system-polyfills.js"),e()}else $__curScript="undefined"!=typeof __filename?{src:__filename}:null,e()}();
+//# sourceMappingURL=system.js.map
diff --git a/dist/system.js.map b/dist/system.js.map
new file mode 100644
index 000000000..95326bbe5
--- /dev/null
+++ b/dist/system.js.map
@@ -0,0 +1 @@
+{"version":3,"sources":["system.src.js"],"names":["bootstrap","global","URLPolyfill","url","baseURL","TypeError","m","String","replace","match","RangeError","protocol","username","password","host","hostname","port","pathname","search","hash","undefined","base","flag","slice","lastIndexOf","output","p","pop","push","join","this","origin","href","self","__global","addToError","err","msg","originalErr","stack","message","toString","split","newStack","i","length","$__curScript","indexOf","src","newMsg","substr","isBrowser","isWindows","newErr","errArgs","Error","fileName","lineNumber","Module","Loader","options","_loader","loaderObj","loads","modules","importPromises","moduleRecords","defineProperty","get","SystemJSLoader","call","paths","systemJSConstructor","SystemProto","hook","name","prototype","hookConstructor","isAbsolute","absURLRegEx","isRel","isPlain","urlResolve","parent","baseURI","URL","baseURIObj","applyPaths","loader","wildcard","pathMatch","maxWildcardPrefixLen","pathsCache","hasOwnProperty","path","pathParts","wildcardPrefixLen","outPath","group","deps","names","indices","l","index","getESModule","exports","esModule","getOwnPropertyDescriptor","defineOrCopyProperty","extend","value","targetObj","sourceObj","propName","d","Object","ex","a","b","prepend","extendMeta","val","Array","concat","extendPkgConfig","pkgCfgA","pkgCfgB","pkgName","warnInvalidProperties","prop","map","meta","depCache","dNormalized","coreResolve","warn","setPkgConfig","cfg","prependConfig","pkg","packages","basePkg","main","warnings","console","readMemberExpression","pParts","shift","getMapMatch","bestMatch","bestMatchLength","curMatchLength","prepareBaseURL","setProduction","isProduction","isBuilder","set","envModule","newModule","browser","node","_nodeRequire","production","dev","build","default","getNodeModule","parentModuleContext","_nodeModulePaths","require","parentName","mapMatch","has","builder","envSet","envCallback","browserConfig","nodeConfig","devConfig","buildConfig","productionConfig","detectRegisterFormat","source","leadingCommentAndMeta","leadingCommentAndMetaRegEx","createEntry","originalIndices","declare","execute","executingRequire","declarative","normalizedDeps","groupIndex","evaluated","module","esmExports","getGlobalValue","globalValue","first","parseCondition","condition","conditionExport","conditionModule","negation","conditionExportIndex","sysConditions","negate","serializeCondition","conditionObj","resolveCondition","bool","normalize","then","normalizedCondition","load","q","interpolateConditional","conditionalMatch","interpolationRegEx","Promise","resolve","conditionValue","booleanConditional","booleanIndex","isWorker","window","importScripts","document","process","platform","assert","item","thisLen","e","obj","opt","getElementsByTagName","bases","location","cwd","nativeURL","createLoad","status","anonCnt","linkSets","dependencies","metadata","loadModule","asyncStartLoadPartwayThrough","step","address","moduleName","moduleMetadata","moduleSource","moduleAddress","requestLoad","request","refererName","refererAddress","reject","proceedToLocate","proceedToFetch","locate","proceedToTranslate","fetch","translate","instantiate","instantiateResult","depsList","loadPromises","depLoad","key","addLoadToLinkSet","all","updateLinkSetOnLoad","exc","exception","linkSetFailed","stepState","existingLoad","done","linkSet","createLinkSet","startingLoad","loadingCount","j","doLink","error","link","_newModule","finishLoad","abrupt","checkError","pLoad","dep","failed","linkIndex","splice","globalLoadsIndex","trace","depMap","forEach","loadIndex","doDynamicExecute","linkError","createImportPromise","promise","constructor","define","delete","import","parentAddress","sourcePromise","pNames","getOwnPropertyNames","configurable","enumerable","freeze","referrerName","referrerAddress","System","fetchTextFromURL","XMLHttpRequest","authorization","fulfill","xhr","responseText","statusText","sameDomain","doTimeout","domainCheck","exec","XDomainRequest","onload","onerror","ontimeout","onprogress","timeout","onreadystatechange","readyState","addEventListener","open","setRequestHeader","withCredentials","setTimeout","send","fs","readFile","data","dataString","opts","headers","Accept","credentials","r","ok","text","transpile","transpiler","pluginLoader","__useDefault","transpileFunction","Compiler","traceurTranspile","createLanguageService","typescriptTranspile","babelTranspile","traceur","traceurOptions","script","sourceMaps","filename","inputSourceMap","sourceMap","compiler","doTraceurCompile","compile","babel","babelOptions","code","ast","transform","ts","typescriptOptions","target","ScriptTarget","ES5","inlineSourceMap","ModuleKind","__exec","sourceMapString","hasBuffer","sourceMapPrefix","Buffer","btoa","unescape","encodeURIComponent","getSource","wrap","lastLineIndex","format","JSON","stringify","preExec","curLoad","callCounter","curSystem","SystemJS","postExec","scriptExec","head","body","documentElement","createElement","_e","apply","arguments","integrity","setAttribute","nonce","appendChild","removeChild","register","reduceRegister_","useVm","vm","supportsScriptExec","runInThisContext","eval","scripts","chrome","extension","navigator","userAgent","scriptSrc","defaultJSExtensions","pluginFirst","loaderErrorStack","skipExt","resolved","httpRequest","systemImport","systemTranslate","entry","parse","getConfig","curCurScript","config","isEnvConfig","checkHasConfig","transpilerRuntime","loadedTranspilerRuntime","bundles","packageConfigPaths","objMaps","v","defaultJSExtension","decanonicalize","pkgMatch","packageLength","Math","max","normalized","bundle","normalizedBundleDep","c","getPackage","curPkg","pkgLen","curPkgLen","addDefaultExtension","subPath","skipExtensions","defaultExtension","metaMatch","getMetaMatches","metaPattern","matchMeta","matchDepth","applyPackageConfigSync","mapPath","mapped","doMapSync","validMapping","normalizeSync","applyPackageConfig","doMap","doStringMap","conditionPromises","conditions","conditionValues","createPkgConfigPathObj","lastWildcard","regEx","RegExp","getPackageConfigMatch","configPath","exactMatch","packageConfigPath","packageName","loadPackageConfigPath","pkgConfigPath","configLoader","systemjs","pkgMeta","matchFn","wildcardIndex","dotRel","exactMeta","decanonicalized","isPlugin","parentPackageName","parentPackage","parentMap","parentMapMatch","pkgConfigMatch","isConfigured","configured","bestDepth","getInteractiveScriptLoad","interactiveScript","interactiveLoadingScripts","webWorkerImport","workerLoad","curRequire","ieEvents","s","isOpera","opera","attachEvent","loadingCnt","registerQueue","pushRegister","scriptLoad","complete","evt","cleanup","detachEvent","removeEventListener","async","crossOrigin","buildGroups","groups","depName","depEntry","defined","depGroupIndex","startEntry","curGroupDeclarative","linkDeclarativeModule","linkDynamicModule","ModuleRecord","getOrCreateModuleRecord","importers","declaration","locked","importerModule","importerIndex","setter","setters","id","depExports","depModule","len","getModule","ensureEvaluated","nameNormalized","__esModule","seen","registerDynamic","pushRegister_","amd","curMeta","del","doLoad","grouped","normalizePromises","esmRegEx","traceurRuntimeRegEx","babelHelpersRegEx","args","depInject","loadedTranspiler","transpilerPromise","loaderModule","originalName","file","sources","originalSource","$traceurRuntime","babelHelpers","__globalName","g","globals","gl","exportName","retrieveGlobal","prepareGlobal","encapsulateGlobal","reduceRegister","forEachGlobal","callback","keys","forEachGlobalValue","globalName","ignoredGlobalProps","globalSnapshot","encapsulate","curDefine","oldGlobals","singleGlobal","multipleExports","getCJSDeps","inLocation","locations","cjsRequireRegEx","lastIndex","commentRegEx","stringRegEx","stringLocations","commentLocations","cjsExportsRegEx","hashBangRegEx","metaDeps","cjsRequireDetection","_require","requireResolve","cjsDeferDepsExecute","pathVars","getPathVars","__cjsWrapper","dirname","cjsWrapper","stripOrigin","windowOrigin","parentId","moduleId","pluginIndex","amdDefine","requireIndex","params","fnBracketRegEx","requireAlias","wsRegEx","requireRegEx","requireRegExs","cjsRequirePre","cjsRequirePost","errback","referer","dynamicRequires","factory","req","contextualRequire","depValues","uri","moduleIndex","exportsIndex","toUrl","amdRequire","amdRegEx","builderExecute","getParentName","parentPluginIndex","parsePlugin","argumentName","pluginName","argument","plugin","combinePluginParts","checkDefaultExtension","arg","createNormalizeSync","parsed","pluginSyntaxIndex","loaderNormalized","result","calledInstantiate","alias","aliasDeps","_export","setMetaProperty","curPart","depth","metaRegEx","metaPartRegEx","metaParts","firstChar","metaString","metaName","metaValue","loadedBundles","matched","curModule","parts","substring","version","doPolyfill","currentScript","defer","curPath","basePath","systemJSBootstrap","write","__filename"],"mappings":";;;CAGA,WACA,QAASA,MACT,SAAUC,GACV,QAASC,GAAYC,EAAKC,GACxB,GAAkB,gBAAPD,GACT,KAAM,IAAIE,WAAU,uBACtB,IA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AAlBkO,eAA+B,CAC7C,GAAI2d,GAAW,EACf,KACE,KAAM,IAAItoB,OAAM,KAChB,MAAOkL,GACPA,EAAElM,MAAM/B,QAAQ,iCAAkC,SAASF,EAAGH,GAC5D2C,cAAiBE,IAAK7C,GACtB0rB,EAAW1rB,EAAIK,QAAQ,YAAa,OAGpCirB,GACFvd,cAAc2d,EAAW,uBAC3B7rB,QAGA8C,cAAoC,mBAAdkpB,aAA8BhpB,IAAKgpB,YAAe,KACxEhsB"} \ No newline at end of file
diff --git a/dist/system.src.js b/dist/system.src.js
new file mode 100644
index 000000000..3734388df
--- /dev/null
+++ b/dist/system.src.js
@@ -0,0 +1,5153 @@
+/*
+ * SystemJS v0.19.39
+ */
+(function() {
+function bootstrap() {// from https://gist.github.com/Yaffle/1088850
+(function(global) {
+function URLPolyfill(url, baseURL) {
+ if (typeof url != 'string')
+ throw new TypeError('URL must be a string');
+ var m = String(url).replace(/^\s+|\s+$/g, "").match(/^([^:\/?#]+:)?(?:\/\/(?:([^:@\/?#]*)(?::([^:@\/?#]*))?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/);
+ if (!m)
+ throw new RangeError('Invalid URL format');
+ var protocol = m[1] || "";
+ var username = m[2] || "";
+ var password = m[3] || "";
+ var host = m[4] || "";
+ var hostname = m[5] || "";
+ var port = m[6] || "";
+ var pathname = m[7] || "";
+ var search = m[8] || "";
+ var hash = m[9] || "";
+ if (baseURL !== undefined) {
+ var base = baseURL instanceof URLPolyfill ? baseURL : new URLPolyfill(baseURL);
+ var flag = !protocol && !host && !username;
+ if (flag && !pathname && !search)
+ search = base.search;
+ if (flag && pathname[0] !== "/")
+ pathname = (pathname ? (((base.host || base.username) && !base.pathname ? "/" : "") + base.pathname.slice(0, base.pathname.lastIndexOf("/") + 1) + pathname) : base.pathname);
+ // dot segments removal
+ var output = [];
+ pathname.replace(/^(\.\.?(\/|$))+/, "")
+ .replace(/\/(\.(\/|$))+/g, "/")
+ .replace(/\/\.\.$/, "/../")
+ .replace(/\/?[^\/]*/g, function (p) {
+ if (p === "/..")
+ output.pop();
+ else
+ output.push(p);
+ });
+ pathname = output.join("").replace(/^\//, pathname[0] === "/" ? "/" : "");
+ if (flag) {
+ port = base.port;
+ hostname = base.hostname;
+ host = base.host;
+ password = base.password;
+ username = base.username;
+ }
+ if (!protocol)
+ protocol = base.protocol;
+ }
+
+ // convert URLs to use / always
+ pathname = pathname.replace(/\\/g, '/');
+
+ this.origin = host ? protocol + (protocol !== "" || host !== "" ? "//" : "") + host : "";
+ this.href = protocol + (protocol && host || protocol == "file:" ? "//" : "") + (username !== "" ? username + (password !== "" ? ":" + password : "") + "@" : "") + host + pathname + search + hash;
+ this.protocol = protocol;
+ this.username = username;
+ this.password = password;
+ this.host = host;
+ this.hostname = hostname;
+ this.port = port;
+ this.pathname = pathname;
+ this.search = search;
+ this.hash = hash;
+}
+global.URLPolyfill = URLPolyfill;
+})(typeof self != 'undefined' ? self : global);(function(__global) {
+
+ var isWorker = typeof window == 'undefined' && typeof self != 'undefined' && typeof importScripts != 'undefined';
+ var isBrowser = typeof window != 'undefined' && typeof document != 'undefined';
+ var isWindows = typeof process != 'undefined' && typeof process.platform != 'undefined' && !!process.platform.match(/^win/);
+
+ if (!__global.console)
+ __global.console = { assert: function() {} };
+
+ // IE8 support
+ var indexOf = Array.prototype.indexOf || function(item) {
+ for (var i = 0, thisLen = this.length; i < thisLen; i++) {
+ if (this[i] === item) {
+ return i;
+ }
+ }
+ return -1;
+ };
+
+ var defineProperty;
+ (function () {
+ try {
+ if (!!Object.defineProperty({}, 'a', {}))
+ defineProperty = Object.defineProperty;
+ }
+ catch (e) {
+ defineProperty = function(obj, prop, opt) {
+ try {
+ obj[prop] = opt.value || opt.get.call(obj);
+ }
+ catch(e) {}
+ }
+ }
+ })();
+
+ var errArgs = new Error(0, '_').fileName == '_';
+
+ function addToError(err, msg) {
+ // parse the stack removing loader code lines for simplification
+ if (!err.originalErr) {
+ var stack = ((err.message || err) + (err.stack ? '\n' + err.stack : '')).toString().split('\n');
+ var newStack = [];
+ for (var i = 0; i < stack.length; i++) {
+ if (typeof $__curScript == 'undefined' || stack[i].indexOf($__curScript.src) == -1)
+ newStack.push(stack[i]);
+ }
+ }
+
+ var newMsg = '(SystemJS) ' + (newStack ? newStack.join('\n\t') : err.message.substr(11)) + '\n\t' + msg;
+
+ // Convert file:/// URLs to paths in Node
+ if (!isBrowser)
+ newMsg = newMsg.replace(isWindows ? /file:\/\/\//g : /file:\/\//g, '');
+
+ var newErr = errArgs ? new Error(newMsg, err.fileName, err.lineNumber) : new Error(newMsg);
+
+ newErr.stack = newMsg;
+
+ // track the original error
+ newErr.originalErr = err.originalErr || err;
+
+ return newErr;
+ }
+
+ function __eval(source, debugName, context) {
+ try {
+ new Function(source).call(context);
+ }
+ catch(e) {
+ throw addToError(e, 'Evaluating ' + debugName);
+ }
+ }
+
+ var baseURI;
+
+ // environent baseURI detection
+ if (typeof document != 'undefined' && document.getElementsByTagName) {
+ baseURI = document.baseURI;
+
+ if (!baseURI) {
+ var bases = document.getElementsByTagName('base');
+ baseURI = bases[0] && bases[0].href || window.location.href;
+ }
+ }
+ else if (typeof location != 'undefined') {
+ baseURI = __global.location.href;
+ }
+
+ // sanitize out the hash and querystring
+ if (baseURI) {
+ baseURI = baseURI.split('#')[0].split('?')[0];
+ baseURI = baseURI.substr(0, baseURI.lastIndexOf('/') + 1);
+ }
+ else if (typeof process != 'undefined' && process.cwd) {
+ baseURI = 'file://' + (isWindows ? '/' : '') + process.cwd() + '/';
+ if (isWindows)
+ baseURI = baseURI.replace(/\\/g, '/');
+ }
+ else {
+ throw new TypeError('No environment baseURI');
+ }
+
+ try {
+ var nativeURL = new __global.URL('test:///').protocol == 'test:';
+ }
+ catch(e) {}
+
+ var URL = nativeURL ? __global.URL : __global.URLPolyfill;
+
+/*
+*********************************************************************************************
+
+ Dynamic Module Loader Polyfill
+
+ - Implemented exactly to the former 2014-08-24 ES6 Specification Draft Rev 27, Section 15
+ http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts#august_24_2014_draft_rev_27
+
+ - Functions are commented with their spec numbers, with spec differences commented.
+
+ - Spec bugs are commented in this code with links.
+
+ - Abstract functions have been combined where possible, and their associated functions
+ commented.
+
+ - Realm implementation is entirely omitted.
+
+*********************************************************************************************
+*/
+
+function Module() {}
+// http://www.ecma-international.org/ecma-262/6.0/#sec-@@tostringtag
+defineProperty(Module.prototype, 'toString', {
+ value: function() {
+ return 'Module';
+ }
+});
+function Loader(options) {
+ this._loader = {
+ loaderObj: this,
+ loads: [],
+ modules: {},
+ importPromises: {},
+ moduleRecords: {}
+ };
+
+ // 26.3.3.6
+ defineProperty(this, 'global', {
+ get: function() {
+ return __global;
+ }
+ });
+
+ // 26.3.3.13 realm not implemented
+}
+
+(function() {
+
+// Some Helpers
+
+// logs a linkset snapshot for debugging
+/* function snapshot(loader) {
+ console.log('---Snapshot---');
+ for (var i = 0; i < loader.loads.length; i++) {
+ var load = loader.loads[i];
+ var linkSetLog = ' ' + load.name + ' (' + load.status + '): ';
+
+ for (var j = 0; j < load.linkSets.length; j++) {
+ linkSetLog += '{' + logloads(load.linkSets[j].loads) + '} ';
+ }
+ console.log(linkSetLog);
+ }
+ console.log('');
+}
+function logloads(loads) {
+ var log = '';
+ for (var k = 0; k < loads.length; k++)
+ log += loads[k].name + (k != loads.length - 1 ? ' ' : '');
+ return log;
+} */
+
+
+/* function checkInvariants() {
+ // see https://bugs.ecmascript.org/show_bug.cgi?id=2603#c1
+
+ var loads = System._loader.loads;
+ var linkSets = [];
+
+ for (var i = 0; i < loads.length; i++) {
+ var load = loads[i];
+ console.assert(load.status == 'loading' || load.status == 'loaded', 'Each load is loading or loaded');
+
+ for (var j = 0; j < load.linkSets.length; j++) {
+ var linkSet = load.linkSets[j];
+
+ for (var k = 0; k < linkSet.loads.length; k++)
+ console.assert(loads.indexOf(linkSet.loads[k]) != -1, 'linkSet loads are a subset of loader loads');
+
+ if (linkSets.indexOf(linkSet) == -1)
+ linkSets.push(linkSet);
+ }
+ }
+
+ for (var i = 0; i < loads.length; i++) {
+ var load = loads[i];
+ for (var j = 0; j < linkSets.length; j++) {
+ var linkSet = linkSets[j];
+
+ if (linkSet.loads.indexOf(load) != -1)
+ console.assert(load.linkSets.indexOf(linkSet) != -1, 'linkSet contains load -> load contains linkSet');
+
+ if (load.linkSets.indexOf(linkSet) != -1)
+ console.assert(linkSet.loads.indexOf(load) != -1, 'load contains linkSet -> linkSet contains load');
+ }
+ }
+
+ for (var i = 0; i < linkSets.length; i++) {
+ var linkSet = linkSets[i];
+ for (var j = 0; j < linkSet.loads.length; j++) {
+ var load = linkSet.loads[j];
+
+ for (var k = 0; k < load.dependencies.length; k++) {
+ var depName = load.dependencies[k].value;
+ var depLoad;
+ for (var l = 0; l < loads.length; l++) {
+ if (loads[l].name != depName)
+ continue;
+ depLoad = loads[l];
+ break;
+ }
+
+ // loading records are allowed not to have their dependencies yet
+ // if (load.status != 'loading')
+ // console.assert(depLoad, 'depLoad found');
+
+ // console.assert(linkSet.loads.indexOf(depLoad) != -1, 'linkset contains all dependencies');
+ }
+ }
+ }
+} */
+
+ // 15.2.3 - Runtime Semantics: Loader State
+
+ // 15.2.3.11
+ function createLoaderLoad(object) {
+ return {
+ // modules is an object for ES5 implementation
+ modules: {},
+ loads: [],
+ loaderObj: object
+ };
+ }
+
+ // 15.2.3.2 Load Records and LoadRequest Objects
+
+ var anonCnt = 0;
+
+ // 15.2.3.2.1
+ function createLoad(name) {
+ return {
+ status: 'loading',
+ name: name || '<Anonymous' + ++anonCnt + '>',
+ linkSets: [],
+ dependencies: [],
+ metadata: {}
+ };
+ }
+
+ // 15.2.3.2.2 createLoadRequestObject, absorbed into calling functions
+
+ // 15.2.4
+
+ // 15.2.4.1
+ function loadModule(loader, name, options) {
+ return new Promise(asyncStartLoadPartwayThrough({
+ step: options.address ? 'fetch' : 'locate',
+ loader: loader,
+ moduleName: name,
+ // allow metadata for import https://bugs.ecmascript.org/show_bug.cgi?id=3091
+ moduleMetadata: options && options.metadata || {},
+ moduleSource: options.source,
+ moduleAddress: options.address
+ }));
+ }
+
+ // 15.2.4.2
+ function requestLoad(loader, request, refererName, refererAddress) {
+ // 15.2.4.2.1 CallNormalize
+ return new Promise(function(resolve, reject) {
+ resolve(loader.loaderObj.normalize(request, refererName, refererAddress));
+ })
+ // 15.2.4.2.2 GetOrCreateLoad
+ .then(function(name) {
+ var load;
+ if (loader.modules[name]) {
+ load = createLoad(name);
+ load.status = 'linked';
+ // https://bugs.ecmascript.org/show_bug.cgi?id=2795
+ load.module = loader.modules[name];
+ return load;
+ }
+
+ for (var i = 0, l = loader.loads.length; i < l; i++) {
+ load = loader.loads[i];
+ if (load.name != name)
+ continue;
+ return load;
+ }
+
+ load = createLoad(name);
+ loader.loads.push(load);
+
+ proceedToLocate(loader, load);
+
+ return load;
+ });
+ }
+
+ // 15.2.4.3
+ function proceedToLocate(loader, load) {
+ proceedToFetch(loader, load,
+ Promise.resolve()
+ // 15.2.4.3.1 CallLocate
+ .then(function() {
+ return loader.loaderObj.locate({ name: load.name, metadata: load.metadata });
+ })
+ );
+ }
+
+ // 15.2.4.4
+ function proceedToFetch(loader, load, p) {
+ proceedToTranslate(loader, load,
+ p
+ // 15.2.4.4.1 CallFetch
+ .then(function(address) {
+ // adjusted, see https://bugs.ecmascript.org/show_bug.cgi?id=2602
+ if (load.status != 'loading')
+ return;
+ load.address = address;
+
+ return loader.loaderObj.fetch({ name: load.name, metadata: load.metadata, address: address });
+ })
+ );
+ }
+
+ // 15.2.4.5
+ function proceedToTranslate(loader, load, p) {
+ p
+ // 15.2.4.5.1 CallTranslate
+ .then(function(source) {
+ if (load.status != 'loading')
+ return;
+
+ load.address = load.address || load.name;
+
+ return Promise.resolve(loader.loaderObj.translate({ name: load.name, metadata: load.metadata, address: load.address, source: source }))
+
+ // 15.2.4.5.2 CallInstantiate
+ .then(function(source) {
+ load.source = source;
+ return loader.loaderObj.instantiate({ name: load.name, metadata: load.metadata, address: load.address, source: source });
+ })
+
+ // 15.2.4.5.3 InstantiateSucceeded
+ .then(function(instantiateResult) {
+ if (instantiateResult === undefined)
+ throw new TypeError('Declarative modules unsupported in the polyfill.');
+
+ if (typeof instantiateResult != 'object')
+ throw new TypeError('Invalid instantiate return value');
+
+ load.depsList = instantiateResult.deps || [];
+ load.execute = instantiateResult.execute;
+ })
+ // 15.2.4.6 ProcessLoadDependencies
+ .then(function() {
+ load.dependencies = [];
+ var depsList = load.depsList;
+
+ var loadPromises = [];
+ for (var i = 0, l = depsList.length; i < l; i++) (function(request, index) {
+ loadPromises.push(
+ requestLoad(loader, request, load.name, load.address)
+
+ // 15.2.4.6.1 AddDependencyLoad (load is parentLoad)
+ .then(function(depLoad) {
+
+ // adjusted from spec to maintain dependency order
+ // this is due to the System.register internal implementation needs
+ load.dependencies[index] = {
+ key: request,
+ value: depLoad.name
+ };
+
+ if (depLoad.status != 'linked') {
+ var linkSets = load.linkSets.concat([]);
+ for (var i = 0, l = linkSets.length; i < l; i++)
+ addLoadToLinkSet(linkSets[i], depLoad);
+ }
+
+ // console.log('AddDependencyLoad ' + depLoad.name + ' for ' + load.name);
+ // snapshot(loader);
+ })
+ );
+ })(depsList[i], i);
+
+ return Promise.all(loadPromises);
+ })
+
+ // 15.2.4.6.2 LoadSucceeded
+ .then(function() {
+ // console.log('LoadSucceeded ' + load.name);
+ // snapshot(loader);
+
+ load.status = 'loaded';
+
+ var linkSets = load.linkSets.concat([]);
+ for (var i = 0, l = linkSets.length; i < l; i++)
+ updateLinkSetOnLoad(linkSets[i], load);
+ });
+ })
+ // 15.2.4.5.4 LoadFailed
+ ['catch'](function(exc) {
+ load.status = 'failed';
+ load.exception = exc;
+
+ var linkSets = load.linkSets.concat([]);
+ for (var i = 0, l = linkSets.length; i < l; i++) {
+ linkSetFailed(linkSets[i], load, exc);
+ }
+
+ console.assert(load.linkSets.length == 0, 'linkSets not removed');
+ });
+ }
+
+ // 15.2.4.7 PromiseOfStartLoadPartwayThrough absorbed into calling functions
+
+ // 15.2.4.7.1
+ function asyncStartLoadPartwayThrough(stepState) {
+ return function(resolve, reject) {
+ var loader = stepState.loader;
+ var name = stepState.moduleName;
+ var step = stepState.step;
+
+ if (loader.modules[name])
+ throw new TypeError('"' + name + '" already exists in the module table');
+
+ // adjusted to pick up existing loads
+ var existingLoad;
+ for (var i = 0, l = loader.loads.length; i < l; i++) {
+ if (loader.loads[i].name == name) {
+ existingLoad = loader.loads[i];
+
+ if (step == 'translate' && !existingLoad.source) {
+ existingLoad.address = stepState.moduleAddress;
+ proceedToTranslate(loader, existingLoad, Promise.resolve(stepState.moduleSource));
+ }
+
+ // a primary load -> use that existing linkset if it is for the direct load here
+ // otherwise create a new linkset unit
+ if (existingLoad.linkSets.length && existingLoad.linkSets[0].loads[0].name == existingLoad.name)
+ return existingLoad.linkSets[0].done.then(function() {
+ resolve(existingLoad);
+ });
+ }
+ }
+
+ var load = existingLoad || createLoad(name);
+
+ load.metadata = stepState.moduleMetadata;
+
+ var linkSet = createLinkSet(loader, load);
+
+ loader.loads.push(load);
+
+ resolve(linkSet.done);
+
+ if (step == 'locate')
+ proceedToLocate(loader, load);
+
+ else if (step == 'fetch')
+ proceedToFetch(loader, load, Promise.resolve(stepState.moduleAddress));
+
+ else {
+ console.assert(step == 'translate', 'translate step');
+ load.address = stepState.moduleAddress;
+ proceedToTranslate(loader, load, Promise.resolve(stepState.moduleSource));
+ }
+ }
+ }
+
+ // Declarative linking functions run through alternative implementation:
+ // 15.2.5.1.1 CreateModuleLinkageRecord not implemented
+ // 15.2.5.1.2 LookupExport not implemented
+ // 15.2.5.1.3 LookupModuleDependency not implemented
+
+ // 15.2.5.2.1
+ function createLinkSet(loader, startingLoad) {
+ var linkSet = {
+ loader: loader,
+ loads: [],
+ startingLoad: startingLoad, // added see spec bug https://bugs.ecmascript.org/show_bug.cgi?id=2995
+ loadingCount: 0
+ };
+ linkSet.done = new Promise(function(resolve, reject) {
+ linkSet.resolve = resolve;
+ linkSet.reject = reject;
+ });
+ addLoadToLinkSet(linkSet, startingLoad);
+ return linkSet;
+ }
+ // 15.2.5.2.2
+ function addLoadToLinkSet(linkSet, load) {
+ if (load.status == 'failed')
+ return;
+
+ for (var i = 0, l = linkSet.loads.length; i < l; i++)
+ if (linkSet.loads[i] == load)
+ return;
+
+ linkSet.loads.push(load);
+ load.linkSets.push(linkSet);
+
+ // adjustment, see https://bugs.ecmascript.org/show_bug.cgi?id=2603
+ if (load.status != 'loaded') {
+ linkSet.loadingCount++;
+ }
+
+ var loader = linkSet.loader;
+
+ for (var i = 0, l = load.dependencies.length; i < l; i++) {
+ if (!load.dependencies[i])
+ continue;
+
+ var name = load.dependencies[i].value;
+
+ if (loader.modules[name])
+ continue;
+
+ for (var j = 0, d = loader.loads.length; j < d; j++) {
+ if (loader.loads[j].name != name)
+ continue;
+
+ addLoadToLinkSet(linkSet, loader.loads[j]);
+ break;
+ }
+ }
+ // console.log('add to linkset ' + load.name);
+ // snapshot(linkSet.loader);
+ }
+
+ // linking errors can be generic or load-specific
+ // this is necessary for debugging info
+ function doLink(linkSet) {
+ var error = false;
+ try {
+ link(linkSet, function(load, exc) {
+ linkSetFailed(linkSet, load, exc);
+ error = true;
+ });
+ }
+ catch(e) {
+ linkSetFailed(linkSet, null, e);
+ error = true;
+ }
+ return error;
+ }
+
+ // 15.2.5.2.3
+ function updateLinkSetOnLoad(linkSet, load) {
+ // console.log('update linkset on load ' + load.name);
+ // snapshot(linkSet.loader);
+
+ console.assert(load.status == 'loaded' || load.status == 'linked', 'loaded or linked');
+
+ linkSet.loadingCount--;
+
+ if (linkSet.loadingCount > 0)
+ return;
+
+ // adjusted for spec bug https://bugs.ecmascript.org/show_bug.cgi?id=2995
+ var startingLoad = linkSet.startingLoad;
+
+ // non-executing link variation for loader tracing
+ // on the server. Not in spec.
+ /***/
+ if (linkSet.loader.loaderObj.execute === false) {
+ var loads = [].concat(linkSet.loads);
+ for (var i = 0, l = loads.length; i < l; i++) {
+ var load = loads[i];
+ load.module = {
+ name: load.name,
+ module: _newModule({}),
+ evaluated: true
+ };
+ load.status = 'linked';
+ finishLoad(linkSet.loader, load);
+ }
+ return linkSet.resolve(startingLoad);
+ }
+ /***/
+
+ var abrupt = doLink(linkSet);
+
+ if (abrupt)
+ return;
+
+ console.assert(linkSet.loads.length == 0, 'loads cleared');
+
+ linkSet.resolve(startingLoad);
+ }
+
+ // 15.2.5.2.4
+ function linkSetFailed(linkSet, load, exc) {
+ var loader = linkSet.loader;
+ var requests;
+
+ checkError:
+ if (load) {
+ if (linkSet.loads[0].name == load.name) {
+ exc = addToError(exc, 'Error loading ' + load.name);
+ }
+ else {
+ for (var i = 0; i < linkSet.loads.length; i++) {
+ var pLoad = linkSet.loads[i];
+ for (var j = 0; j < pLoad.dependencies.length; j++) {
+ var dep = pLoad.dependencies[j];
+ if (dep.value == load.name) {
+ exc = addToError(exc, 'Error loading ' + load.name + ' as "' + dep.key + '" from ' + pLoad.name);
+ break checkError;
+ }
+ }
+ }
+ exc = addToError(exc, 'Error loading ' + load.name + ' from ' + linkSet.loads[0].name);
+ }
+ }
+ else {
+ exc = addToError(exc, 'Error linking ' + linkSet.loads[0].name);
+ }
+
+
+ var loads = linkSet.loads.concat([]);
+ for (var i = 0, l = loads.length; i < l; i++) {
+ var load = loads[i];
+
+ // store all failed load records
+ loader.loaderObj.failed = loader.loaderObj.failed || [];
+ if (indexOf.call(loader.loaderObj.failed, load) == -1)
+ loader.loaderObj.failed.push(load);
+
+ var linkIndex = indexOf.call(load.linkSets, linkSet);
+ console.assert(linkIndex != -1, 'link not present');
+ load.linkSets.splice(linkIndex, 1);
+ if (load.linkSets.length == 0) {
+ var globalLoadsIndex = indexOf.call(linkSet.loader.loads, load);
+ if (globalLoadsIndex != -1)
+ linkSet.loader.loads.splice(globalLoadsIndex, 1);
+ }
+ }
+ linkSet.reject(exc);
+ }
+
+ // 15.2.5.2.5
+ function finishLoad(loader, load) {
+ // add to global trace if tracing
+ if (loader.loaderObj.trace) {
+ if (!loader.loaderObj.loads)
+ loader.loaderObj.loads = {};
+ var depMap = {};
+ load.dependencies.forEach(function(dep) {
+ depMap[dep.key] = dep.value;
+ });
+ loader.loaderObj.loads[load.name] = {
+ name: load.name,
+ deps: load.dependencies.map(function(dep){ return dep.key }),
+ depMap: depMap,
+ address: load.address,
+ metadata: load.metadata,
+ source: load.source
+ };
+ }
+ // if not anonymous, add to the module table
+ if (load.name) {
+ console.assert(!loader.modules[load.name] || loader.modules[load.name].module === load.module.module, 'load not in module table');
+ loader.modules[load.name] = load.module;
+ }
+ var loadIndex = indexOf.call(loader.loads, load);
+ if (loadIndex != -1)
+ loader.loads.splice(loadIndex, 1);
+ for (var i = 0, l = load.linkSets.length; i < l; i++) {
+ loadIndex = indexOf.call(load.linkSets[i].loads, load);
+ if (loadIndex != -1)
+ load.linkSets[i].loads.splice(loadIndex, 1);
+ }
+ load.linkSets.splice(0, load.linkSets.length);
+ }
+
+ function doDynamicExecute(linkSet, load, linkError) {
+ try {
+ var module = load.execute();
+ }
+ catch(e) {
+ linkError(load, e);
+ return;
+ }
+ if (!module || !(module instanceof Module))
+ linkError(load, new TypeError('Execution must define a Module instance'));
+ else
+ return module;
+ }
+
+ // 26.3 Loader
+
+ // 26.3.1.1
+ // defined at top
+
+ // importPromises adds ability to import a module twice without error - https://bugs.ecmascript.org/show_bug.cgi?id=2601
+ function createImportPromise(loader, name, promise) {
+ var importPromises = loader._loader.importPromises;
+ return importPromises[name] = promise.then(function(m) {
+ importPromises[name] = undefined;
+ return m;
+ }, function(e) {
+ importPromises[name] = undefined;
+ throw e;
+ });
+ }
+
+ Loader.prototype = {
+ // 26.3.3.1
+ constructor: Loader,
+ // 26.3.3.2
+ define: function(name, source, options) {
+ // check if already defined
+ if (this._loader.importPromises[name])
+ throw new TypeError('Module is already loading.');
+ return createImportPromise(this, name, new Promise(asyncStartLoadPartwayThrough({
+ step: 'translate',
+ loader: this._loader,
+ moduleName: name,
+ moduleMetadata: options && options.metadata || {},
+ moduleSource: source,
+ moduleAddress: options && options.address
+ })));
+ },
+ // 26.3.3.3
+ 'delete': function(name) {
+ var loader = this._loader;
+ delete loader.importPromises[name];
+ delete loader.moduleRecords[name];
+ return loader.modules[name] ? delete loader.modules[name] : false;
+ },
+ // 26.3.3.4 entries not implemented
+ // 26.3.3.5
+ get: function(key) {
+ if (!this._loader.modules[key])
+ return;
+ return this._loader.modules[key].module;
+ },
+ // 26.3.3.7
+ has: function(name) {
+ return !!this._loader.modules[name];
+ },
+ // 26.3.3.8
+ 'import': function(name, parentName, parentAddress) {
+ if (typeof parentName == 'object')
+ parentName = parentName.name;
+
+ // run normalize first
+ var loaderObj = this;
+
+ // added, see https://bugs.ecmascript.org/show_bug.cgi?id=2659
+ return Promise.resolve(loaderObj.normalize(name, parentName))
+ .then(function(name) {
+ var loader = loaderObj._loader;
+
+ if (loader.modules[name])
+ return loader.modules[name].module;
+
+ return loader.importPromises[name] || createImportPromise(loaderObj, name,
+ loadModule(loader, name, {})
+ .then(function(load) {
+ delete loader.importPromises[name];
+ return load.module.module;
+ }));
+ });
+ },
+ // 26.3.3.9 keys not implemented
+ // 26.3.3.10
+ load: function(name) {
+ var loader = this._loader;
+ if (loader.modules[name])
+ return Promise.resolve();
+ return loader.importPromises[name] || createImportPromise(this, name, new Promise(asyncStartLoadPartwayThrough({
+ step: 'locate',
+ loader: loader,
+ moduleName: name,
+ moduleMetadata: {},
+ moduleSource: undefined,
+ moduleAddress: undefined
+ }))
+ .then(function() {
+ delete loader.importPromises[name];
+ }));
+ },
+ // 26.3.3.11
+ module: function(source, options) {
+ var load = createLoad();
+ load.address = options && options.address;
+ var linkSet = createLinkSet(this._loader, load);
+ var sourcePromise = Promise.resolve(source);
+ var loader = this._loader;
+ var p = linkSet.done.then(function() {
+ return load.module.module;
+ });
+ proceedToTranslate(loader, load, sourcePromise);
+ return p;
+ },
+ // 26.3.3.12
+ newModule: function (obj) {
+ if (typeof obj != 'object')
+ throw new TypeError('Expected object');
+
+ var m = new Module();
+
+ var pNames = [];
+ if (Object.getOwnPropertyNames && obj != null)
+ pNames = Object.getOwnPropertyNames(obj);
+ else
+ for (var key in obj)
+ pNames.push(key);
+
+ for (var i = 0; i < pNames.length; i++) (function(key) {
+ defineProperty(m, key, {
+ configurable: false,
+ enumerable: true,
+ get: function () {
+ return obj[key];
+ },
+ set: function() {
+ throw new Error('Module exports cannot be changed externally.');
+ }
+ });
+ })(pNames[i]);
+
+ if (Object.freeze)
+ Object.freeze(m);
+
+ return m;
+ },
+ // 26.3.3.14
+ set: function(name, module) {
+ if (!(module instanceof Module))
+ throw new TypeError('Loader.set(' + name + ', module) must be a module');
+ this._loader.modules[name] = {
+ module: module
+ };
+ },
+ // 26.3.3.15 values not implemented
+ // 26.3.3.16 @@iterator not implemented
+ // 26.3.3.17 @@toStringTag not implemented
+
+ // 26.3.3.18.1
+ normalize: function(name, referrerName, referrerAddress) {},
+ // 26.3.3.18.2
+ locate: function(load) {
+ return load.name;
+ },
+ // 26.3.3.18.3
+ fetch: function(load) {
+ },
+ // 26.3.3.18.4
+ translate: function(load) {
+ return load.source;
+ },
+ // 26.3.3.18.5
+ instantiate: function(load) {
+ }
+ };
+
+ var _newModule = Loader.prototype.newModule;
+
+/*
+ * ES6 Module Declarative Linking Code
+ */
+ function link(linkSet, linkError) {
+
+ var loader = linkSet.loader;
+
+ if (!linkSet.loads.length)
+ return;
+
+ var loads = linkSet.loads.concat([]);
+
+ for (var i = 0; i < loads.length; i++) {
+ var load = loads[i];
+
+ var module = doDynamicExecute(linkSet, load, linkError);
+ if (!module)
+ return;
+ load.module = {
+ name: load.name,
+ module: module
+ };
+ load.status = 'linked';
+
+ finishLoad(loader, load);
+ }
+ }
+
+})();
+
+var System;
+
+ var fetchTextFromURL;
+ if (typeof XMLHttpRequest != 'undefined') {
+ fetchTextFromURL = function(url, authorization, fulfill, reject) {
+ var xhr = new XMLHttpRequest();
+ var sameDomain = true;
+ var doTimeout = false;
+ if (!('withCredentials' in xhr)) {
+ // check if same domain
+ var domainCheck = /^(\w+:)?\/\/([^\/]+)/.exec(url);
+ if (domainCheck) {
+ sameDomain = domainCheck[2] === window.location.host;
+ if (domainCheck[1])
+ sameDomain &= domainCheck[1] === window.location.protocol;
+ }
+ }
+ if (!sameDomain && typeof XDomainRequest != 'undefined') {
+ xhr = new XDomainRequest();
+ xhr.onload = load;
+ xhr.onerror = error;
+ xhr.ontimeout = error;
+ xhr.onprogress = function() {};
+ xhr.timeout = 0;
+ doTimeout = true;
+ }
+ function load() {
+ fulfill(xhr.responseText);
+ }
+ function error() {
+ reject(new Error('XHR error' + (xhr.status ? ' (' + xhr.status + (xhr.statusText ? ' ' + xhr.statusText : '') + ')' : '') + ' loading ' + url));
+ }
+
+ xhr.onreadystatechange = function () {
+ if (xhr.readyState === 4) {
+ // in Chrome on file:/// URLs, status is 0
+ if (xhr.status == 0) {
+ if (xhr.responseText) {
+ load();
+ }
+ else {
+ // when responseText is empty, wait for load or error event
+ // to inform if it is a 404 or empty file
+ xhr.addEventListener('error', error);
+ xhr.addEventListener('load', load);
+ }
+ }
+ else if (xhr.status === 200) {
+ load();
+ }
+ else {
+ error();
+ }
+ }
+ };
+ xhr.open("GET", url, true);
+
+ if (xhr.setRequestHeader) {
+ xhr.setRequestHeader('Accept', 'application/x-es-module, */*');
+ // can set "authorization: true" to enable withCredentials only
+ if (authorization) {
+ if (typeof authorization == 'string')
+ xhr.setRequestHeader('Authorization', authorization);
+ xhr.withCredentials = true;
+ }
+ }
+
+ if (doTimeout) {
+ setTimeout(function() {
+ xhr.send();
+ }, 0);
+ } else {
+ xhr.send(null);
+ }
+ };
+ }
+ else if (typeof require != 'undefined' && typeof process != 'undefined') {
+ var fs;
+ fetchTextFromURL = function(url, authorization, fulfill, reject) {
+ if (url.substr(0, 8) != 'file:///')
+ throw new Error('Unable to fetch "' + url + '". Only file URLs of the form file:/// allowed running in Node.');
+ fs = fs || require('fs');
+ if (isWindows)
+ url = url.replace(/\//g, '\\').substr(8);
+ else
+ url = url.substr(7);
+ return fs.readFile(url, function(err, data) {
+ if (err) {
+ return reject(err);
+ }
+ else {
+ // Strip Byte Order Mark out if it's the leading char
+ var dataString = data + '';
+ if (dataString[0] === '\ufeff')
+ dataString = dataString.substr(1);
+
+ fulfill(dataString);
+ }
+ });
+ };
+ }
+ else if (typeof self != 'undefined' && typeof self.fetch != 'undefined') {
+ fetchTextFromURL = function(url, authorization, fulfill, reject) {
+ var opts = {
+ headers: {'Accept': 'application/x-es-module, */*'}
+ };
+
+ if (authorization) {
+ if (typeof authorization == 'string')
+ opts.headers['Authorization'] = authorization;
+ opts.credentials = 'include';
+ }
+
+ fetch(url, opts)
+ .then(function (r) {
+ if (r.ok) {
+ return r.text();
+ } else {
+ throw new Error('Fetch error: ' + r.status + ' ' + r.statusText);
+ }
+ })
+ .then(fulfill, reject);
+ }
+ }
+ else {
+ throw new TypeError('No environment fetch API available.');
+ }
+/*
+ * Traceur, Babel and TypeScript transpile hook for Loader
+ */
+var transpile = (function() {
+
+ // use Traceur by default
+ Loader.prototype.transpiler = 'traceur';
+
+ function transpile(load) {
+ var self = this;
+
+ return Promise.resolve(__global[self.transpiler == 'typescript' ? 'ts' : self.transpiler]
+ || (self.pluginLoader || self)['import'](self.transpiler))
+ .then(function(transpiler) {
+ if (transpiler.__useDefault)
+ transpiler = transpiler['default'];
+
+ var transpileFunction;
+ if (transpiler.Compiler)
+ transpileFunction = traceurTranspile;
+ else if (transpiler.createLanguageService)
+ transpileFunction = typescriptTranspile;
+ else
+ transpileFunction = babelTranspile;
+
+ // note __moduleName will be part of the transformer meta in future when we have the spec for this
+ return '(function(__moduleName){' + transpileFunction.call(self, load, transpiler) + '\n})("' + load.name + '");\n//# sourceURL=' + load.address + '!transpiled';
+ });
+ };
+
+ function traceurTranspile(load, traceur) {
+ var options = this.traceurOptions || {};
+ options.modules = 'instantiate';
+ options.script = false;
+ if (options.sourceMaps === undefined)
+ options.sourceMaps = 'inline';
+ options.filename = load.address;
+ options.inputSourceMap = load.metadata.sourceMap;
+ options.moduleName = false;
+
+ var compiler = new traceur.Compiler(options);
+
+ return doTraceurCompile(load.source, compiler, options.filename);
+ }
+ function doTraceurCompile(source, compiler, filename) {
+ try {
+ return compiler.compile(source, filename);
+ }
+ catch(e) {
+ // on older versions of traceur (<0.9.3), an array of errors is thrown
+ // rather than a single error.
+ if (e.length) {
+ throw e[0];
+ }
+ throw e;
+ }
+ }
+
+ function babelTranspile(load, babel) {
+ var options = this.babelOptions || {};
+ options.modules = 'system';
+ if (options.sourceMap === undefined)
+ options.sourceMap = 'inline';
+ options.inputSourceMap = load.metadata.sourceMap;
+ options.filename = load.address;
+ options.code = true;
+ options.ast = false;
+
+ return babel.transform(load.source, options).code;
+ }
+
+ function typescriptTranspile(load, ts) {
+ var options = this.typescriptOptions || {};
+ options.target = options.target || ts.ScriptTarget.ES5;
+ if (options.sourceMap === undefined)
+ options.sourceMap = true;
+ if (options.sourceMap && options.inlineSourceMap !== false)
+ options.inlineSourceMap = true;
+
+ options.module = ts.ModuleKind.System;
+
+ return ts.transpile(load.source, options, load.address);
+ }
+
+ return transpile;
+})();
+// SystemJS Loader Class and Extension helpers
+function SystemJSLoader() {
+ Loader.call(this);
+
+ this.paths = {};
+ this._loader.paths = {};
+
+ systemJSConstructor.call(this);
+}
+
+// inline Object.create-style class extension
+function SystemProto() {};
+SystemProto.prototype = Loader.prototype;
+SystemJSLoader.prototype = new SystemProto();
+SystemJSLoader.prototype.constructor = SystemJSLoader;
+
+var systemJSConstructor;
+
+function hook(name, hook) {
+ SystemJSLoader.prototype[name] = hook(SystemJSLoader.prototype[name] || function() {});
+}
+function hookConstructor(hook) {
+ systemJSConstructor = hook(systemJSConstructor || function() {});
+}
+
+
+var absURLRegEx = /^[^\/]+:\/\//;
+function isAbsolute(name) {
+ return name.match(absURLRegEx);
+}
+function isRel(name) {
+ return (name[0] == '.' && (!name[1] || name[1] == '/' || name[1] == '.')) || name[0] == '/';
+}
+function isPlain(name) {
+ return !isRel(name) && !isAbsolute(name);
+}
+
+var baseURIObj = new URL(baseURI);
+
+function urlResolve(name, parent) {
+ // url resolution shortpaths
+ if (name[0] == '.') {
+ // dot-relative url normalization
+ if (name[1] == '/' && name[2] != '.')
+ return (parent && parent.substr(0, parent.lastIndexOf('/') + 1) || baseURI) + name.substr(2);
+ }
+ else if (name[0] != '/' && name.indexOf(':') == -1) {
+ // plain parent normalization
+ return (parent && parent.substr(0, parent.lastIndexOf('/') + 1) || baseURI) + name;
+ }
+
+ return new URL(name, parent && parent.replace(/#/g, '%05') || baseURIObj).href.replace(/%05/g, '#');
+}
+
+// NB no specification provided for System.paths, used ideas discussed in https://github.com/jorendorff/js-loaders/issues/25
+function applyPaths(loader, name) {
+ // most specific (most number of slashes in path) match wins
+ var pathMatch = '', wildcard, maxWildcardPrefixLen = 0;
+
+ var paths = loader.paths;
+ var pathsCache = loader._loader.paths;
+
+ // check to see if we have a paths entry
+ for (var p in paths) {
+ if (paths.hasOwnProperty && !paths.hasOwnProperty(p))
+ continue;
+
+ // paths sanitization
+ var path = paths[p];
+ if (path !== pathsCache[p])
+ path = paths[p] = pathsCache[p] = urlResolve(paths[p], isRel(paths[p]) ? baseURI : loader.baseURL);
+
+ // exact path match
+ if (p.indexOf('*') === -1) {
+ if (name == p)
+ return paths[p];
+
+ // support trailing / in paths rules
+ else if (name.substr(0, p.length - 1) == p.substr(0, p.length - 1) && (name.length < p.length || name[p.length - 1] == p[p.length - 1]) && (paths[p][paths[p].length - 1] == '/' || paths[p] == '')) {
+ return paths[p].substr(0, paths[p].length - 1) + (name.length > p.length ? (paths[p] && '/' || '') + name.substr(p.length) : '');
+ }
+ }
+ // wildcard path match
+ else {
+ var pathParts = p.split('*');
+ if (pathParts.length > 2)
+ throw new TypeError('Only one wildcard in a path is permitted');
+
+ var wildcardPrefixLen = pathParts[0].length;
+ if (wildcardPrefixLen >= maxWildcardPrefixLen &&
+ name.substr(0, pathParts[0].length) == pathParts[0] &&
+ name.substr(name.length - pathParts[1].length) == pathParts[1]) {
+ maxWildcardPrefixLen = wildcardPrefixLen;
+ pathMatch = p;
+ wildcard = name.substr(pathParts[0].length, name.length - pathParts[1].length - pathParts[0].length);
+ }
+ }
+ }
+
+ var outPath = paths[pathMatch];
+ if (typeof wildcard == 'string')
+ outPath = outPath.replace('*', wildcard);
+
+ return outPath;
+}
+
+function dedupe(deps) {
+ var newDeps = [];
+ for (var i = 0, l = deps.length; i < l; i++)
+ if (indexOf.call(newDeps, deps[i]) == -1)
+ newDeps.push(deps[i])
+ return newDeps;
+}
+
+function group(deps) {
+ var names = [];
+ var indices = [];
+ for (var i = 0, l = deps.length; i < l; i++) {
+ var index = indexOf.call(names, deps[i]);
+ if (index === -1) {
+ names.push(deps[i]);
+ indices.push([i]);
+ }
+ else {
+ indices[index].push(i);
+ }
+ }
+ return { names: names, indices: indices };
+}
+
+var getOwnPropertyDescriptor = true;
+try {
+ Object.getOwnPropertyDescriptor({ a: 0 }, 'a');
+}
+catch(e) {
+ getOwnPropertyDescriptor = false;
+}
+
+// converts any module.exports object into an object ready for SystemJS.newModule
+function getESModule(exports) {
+ var esModule = {};
+ // don't trigger getters/setters in environments that support them
+ if ((typeof exports == 'object' || typeof exports == 'function') && exports !== __global) {
+ if (getOwnPropertyDescriptor) {
+ for (var p in exports) {
+ // The default property is copied to esModule later on
+ if (p === 'default')
+ continue;
+ defineOrCopyProperty(esModule, exports, p);
+ }
+ }
+ else {
+ extend(esModule, exports);
+ }
+ }
+ esModule['default'] = exports;
+ defineProperty(esModule, '__useDefault', {
+ value: true
+ });
+ return esModule;
+}
+
+function defineOrCopyProperty(targetObj, sourceObj, propName) {
+ try {
+ var d;
+ if (d = Object.getOwnPropertyDescriptor(sourceObj, propName))
+ defineProperty(targetObj, propName, d);
+ }
+ catch (ex) {
+ // Object.getOwnPropertyDescriptor threw an exception, fall back to normal set property
+ // we dont need hasOwnProperty here because getOwnPropertyDescriptor would have returned undefined above
+ targetObj[propName] = sourceObj[propName];
+ return false;
+ }
+}
+
+function extend(a, b, prepend) {
+ var hasOwnProperty = b && b.hasOwnProperty;
+ for (var p in b) {
+ if (hasOwnProperty && !b.hasOwnProperty(p))
+ continue;
+ if (!prepend || !(p in a))
+ a[p] = b[p];
+ }
+ return a;
+}
+
+// meta first-level extends where:
+// array + array appends
+// object + object extends
+// other properties replace
+function extendMeta(a, b, prepend) {
+ var hasOwnProperty = b && b.hasOwnProperty;
+ for (var p in b) {
+ if (hasOwnProperty && !b.hasOwnProperty(p))
+ continue;
+ var val = b[p];
+ if (!(p in a))
+ a[p] = val;
+ else if (val instanceof Array && a[p] instanceof Array)
+ a[p] = [].concat(prepend ? val : a[p]).concat(prepend ? a[p] : val);
+ else if (typeof val == 'object' && val !== null && typeof a[p] == 'object')
+ a[p] = extend(extend({}, a[p]), val, prepend);
+ else if (!prepend)
+ a[p] = val;
+ }
+}
+
+function extendPkgConfig(pkgCfgA, pkgCfgB, pkgName, loader, warnInvalidProperties) {
+ for (var prop in pkgCfgB) {
+ if (indexOf.call(['main', 'format', 'defaultExtension', 'basePath'], prop) != -1) {
+ pkgCfgA[prop] = pkgCfgB[prop];
+ }
+ else if (prop == 'map') {
+ extend(pkgCfgA.map = pkgCfgA.map || {}, pkgCfgB.map);
+ }
+ else if (prop == 'meta') {
+ extend(pkgCfgA.meta = pkgCfgA.meta || {}, pkgCfgB.meta);
+ }
+ else if (prop == 'depCache') {
+ for (var d in pkgCfgB.depCache) {
+ var dNormalized;
+
+ if (d.substr(0, 2) == './')
+ dNormalized = pkgName + '/' + d.substr(2);
+ else
+ dNormalized = coreResolve.call(loader, d);
+ loader.depCache[dNormalized] = (loader.depCache[dNormalized] || []).concat(pkgCfgB.depCache[d]);
+ }
+ }
+ else if (warnInvalidProperties && indexOf.call(['browserConfig', 'nodeConfig', 'devConfig', 'productionConfig'], prop) == -1 &&
+ (!pkgCfgB.hasOwnProperty || pkgCfgB.hasOwnProperty(prop))) {
+ warn.call(loader, '"' + prop + '" is not a valid package configuration option in package ' + pkgName);
+ }
+ }
+}
+
+// deeply-merge (to first level) config with any existing package config
+function setPkgConfig(loader, pkgName, cfg, prependConfig) {
+ var pkg;
+
+ // first package is config by reference for fast path, cloned after that
+ if (!loader.packages[pkgName]) {
+ pkg = loader.packages[pkgName] = cfg;
+ }
+ else {
+ var basePkg = loader.packages[pkgName];
+ pkg = loader.packages[pkgName] = {};
+
+ extendPkgConfig(pkg, prependConfig ? cfg : basePkg, pkgName, loader, prependConfig);
+ extendPkgConfig(pkg, prependConfig ? basePkg : cfg, pkgName, loader, !prependConfig);
+ }
+
+ // main object becomes main map
+ if (typeof pkg.main == 'object') {
+ pkg.map = pkg.map || {};
+ pkg.map['./@main'] = pkg.main;
+ pkg.main['default'] = pkg.main['default'] || './';
+ pkg.main = '@main';
+ }
+
+ return pkg;
+}
+
+function warn(msg) {
+ if (this.warnings && typeof console != 'undefined' && console.warn)
+ console.warn(msg);
+}
+// we define a __exec for globally-scoped execution
+// used by module format implementations
+var __exec;
+
+(function() {
+
+ var hasBuffer = typeof Buffer != 'undefined';
+ try {
+ if (hasBuffer && new Buffer('a').toString('base64') != 'YQ==')
+ hasBuffer = false;
+ }
+ catch(e) {
+ hasBuffer = false;
+ }
+
+ var sourceMapPrefix = '\n//# sourceMappingURL=data:application/json;base64,';
+ function inlineSourceMap(sourceMapString) {
+ if (hasBuffer)
+ return sourceMapPrefix + new Buffer(sourceMapString).toString('base64');
+ else if (typeof btoa != 'undefined')
+ return sourceMapPrefix + btoa(unescape(encodeURIComponent(sourceMapString)));
+ else
+ return '';
+ }
+
+ function getSource(load, wrap) {
+ var lastLineIndex = load.source.lastIndexOf('\n');
+
+ // wrap ES formats with a System closure for System global encapsulation
+ if (load.metadata.format == 'global')
+ wrap = false;
+
+ var sourceMap = load.metadata.sourceMap;
+ if (sourceMap) {
+ if (typeof sourceMap != 'object')
+ throw new TypeError('load.metadata.sourceMap must be set to an object.');
+
+ sourceMap = JSON.stringify(sourceMap);
+ }
+
+ return (wrap ? '(function(System, SystemJS) {' : '') + load.source + (wrap ? '\n})(System, System);' : '')
+ // adds the sourceURL comment if not already present
+ + (load.source.substr(lastLineIndex, 15) != '\n//# sourceURL='
+ ? '\n//# sourceURL=' + load.address + (sourceMap ? '!transpiled' : '') : '')
+ // add sourceMappingURL if load.metadata.sourceMap is set
+ + (sourceMap && inlineSourceMap(sourceMap) || '');
+ }
+
+ var curLoad;
+
+ // System.register, System.registerDynamic, AMD define pipeline
+ // if currently evalling code here, immediately reduce the registered entry against the load record
+ hook('pushRegister_', function() {
+ return function(register) {
+ if (!curLoad)
+ return false;
+
+ this.reduceRegister_(curLoad, register);
+ return true;
+ };
+ });
+
+ // System clobbering protection (mostly for Traceur)
+ var curSystem;
+ var callCounter = 0;
+ function preExec(loader, load) {
+ curLoad = load;
+ if (callCounter++ == 0)
+ curSystem = __global.System;
+ __global.System = __global.SystemJS = loader;
+ }
+ function postExec() {
+ if (--callCounter == 0)
+ __global.System = __global.SystemJS = curSystem;
+ curLoad = undefined;
+ }
+
+ var useVm;
+ var vm;
+ __exec = function(load) {
+ if (!load.source)
+ return;
+ if ((load.metadata.integrity || load.metadata.nonce) && supportsScriptExec)
+ return scriptExec.call(this, load);
+ try {
+ preExec(this, load);
+ curLoad = load;
+ // global scoped eval for node (avoids require scope leak)
+ if (!vm && this._nodeRequire) {
+ vm = this._nodeRequire('vm');
+ useVm = vm.runInThisContext("typeof System !== 'undefined' && System") === this;
+ }
+ if (useVm)
+ vm.runInThisContext(getSource(load, true), { filename: load.address + (load.metadata.sourceMap ? '!transpiled' : '') });
+ else
+ (0, eval)(getSource(load, true));
+ postExec();
+ }
+ catch(e) {
+ postExec();
+ throw addToError(e, 'Evaluating ' + load.address);
+ }
+ };
+
+ var supportsScriptExec = false;
+ if (isBrowser && typeof document != 'undefined' && document.getElementsByTagName) {
+ var scripts = document.getElementsByTagName('script');
+ $__curScript = scripts[scripts.length - 1];
+
+ if (!(window.chrome && window.chrome.extension || navigator.userAgent.match(/^Node\.js/)))
+ supportsScriptExec = true;
+ }
+
+ // script execution via injecting a script tag into the page
+ // this allows CSP integrity and nonce to be set for CSP environments
+ var head;
+ function scriptExec(load) {
+ if (!head)
+ head = document.head || document.body || document.documentElement;
+
+ var script = document.createElement('script');
+ script.text = getSource(load, false);
+ var onerror = window.onerror;
+ var e;
+ window.onerror = function(_e) {
+ e = addToError(_e, 'Evaluating ' + load.address);
+ if (onerror)
+ onerror.apply(this, arguments);
+ }
+ preExec(this, load);
+
+ if (load.metadata.integrity)
+ script.setAttribute('integrity', load.metadata.integrity);
+ if (load.metadata.nonce)
+ script.setAttribute('nonce', load.metadata.nonce);
+
+ head.appendChild(script);
+ head.removeChild(script);
+ postExec();
+ window.onerror = onerror;
+ if (e)
+ throw e;
+ }
+
+})();
+function readMemberExpression(p, value) {
+ var pParts = p.split('.');
+ while (pParts.length)
+ value = value[pParts.shift()];
+ return value;
+}
+
+function getMapMatch(map, name) {
+ var bestMatch, bestMatchLength = 0;
+
+ for (var p in map) {
+ if (name.substr(0, p.length) == p && (name.length == p.length || name[p.length] == '/')) {
+ var curMatchLength = p.split('/').length;
+ if (curMatchLength <= bestMatchLength)
+ continue;
+ bestMatch = p;
+ bestMatchLength = curMatchLength;
+ }
+ }
+
+ return bestMatch;
+}
+
+function prepareBaseURL(loader) {
+ // ensure baseURl is fully normalized
+ if (this._loader.baseURL !== this.baseURL) {
+ if (this.baseURL[this.baseURL.length - 1] != '/')
+ this.baseURL += '/';
+
+ this._loader.baseURL = this.baseURL = new URL(this.baseURL, baseURIObj).href;
+ }
+}
+
+var envModule;
+function setProduction(isProduction, isBuilder) {
+ this.set('@system-env', envModule = this.newModule({
+ browser: isBrowser,
+ node: !!this._nodeRequire,
+ production: !isBuilder && isProduction,
+ dev: isBuilder || !isProduction,
+ build: isBuilder,
+ 'default': true
+ }));
+}
+
+hookConstructor(function(constructor) {
+ return function() {
+ constructor.call(this);
+
+ // support baseURL
+ this.baseURL = baseURI;
+
+ // support map and paths
+ this.map = {};
+
+ // make the location of the system.js script accessible
+ if (typeof $__curScript != 'undefined')
+ this.scriptSrc = $__curScript.src;
+
+ // global behaviour flags
+ this.warnings = false;
+ this.defaultJSExtensions = false;
+ this.pluginFirst = false;
+ this.loaderErrorStack = false;
+
+ // by default load ".json" files as json
+ // leading * meta doesn't need normalization
+ // NB add this in next breaking release
+ // this.meta['*.json'] = { format: 'json' };
+
+ // support the empty module, as a concept
+ this.set('@empty', this.newModule({}));
+
+ setProduction.call(this, false, false);
+ };
+});
+
+// include the node require since we're overriding it
+if (typeof require != 'undefined' && typeof process != 'undefined' && !process.browser)
+ SystemJSLoader.prototype._nodeRequire = require;
+
+/*
+ Core SystemJS Normalization
+
+ If a name is relative, we apply URL normalization to the page
+ If a name is an absolute URL, we leave it as-is
+
+ Plain names (neither of the above) run through the map and paths
+ normalization phases.
+
+ The paths normalization phase applies last (paths extension), which
+ defines the `decanonicalize` function and normalizes everything into
+ a URL.
+ */
+
+var parentModuleContext;
+function getNodeModule(name, baseURL) {
+ if (!isPlain(name))
+ throw new Error('Node module ' + name + ' can\'t be loaded as it is not a package require.');
+
+ if (!parentModuleContext) {
+ var Module = this._nodeRequire('module');
+ var base = baseURL.substr(isWindows ? 8 : 7);
+ parentModuleContext = new Module(base);
+ parentModuleContext.paths = Module._nodeModulePaths(base);
+ }
+ return parentModuleContext.require(name);
+}
+
+function coreResolve(name, parentName) {
+ // standard URL resolution
+ if (isRel(name))
+ return urlResolve(name, parentName);
+ else if (isAbsolute(name))
+ return name;
+
+ // plain names not starting with './', '://' and '/' go through custom resolution
+ var mapMatch = getMapMatch(this.map, name);
+
+ if (mapMatch) {
+ name = this.map[mapMatch] + name.substr(mapMatch.length);
+
+ if (isRel(name))
+ return urlResolve(name);
+ else if (isAbsolute(name))
+ return name;
+ }
+
+ if (this.has(name))
+ return name;
+
+ // dynamically load node-core modules when requiring `@node/fs` for example
+ if (name.substr(0, 6) == '@node/') {
+ if (!this._nodeRequire)
+ throw new TypeError('Error loading ' + name + '. Can only load node core modules in Node.');
+ if (this.builder)
+ this.set(name, this.newModule({}));
+ else
+ this.set(name, this.newModule(getESModule(getNodeModule.call(this, name.substr(6), this.baseURL))));
+ return name;
+ }
+
+ // prepare the baseURL to ensure it is normalized
+ prepareBaseURL.call(this);
+
+ return applyPaths(this, name) || this.baseURL + name;
+}
+
+hook('normalize', function(normalize) {
+ return function(name, parentName, skipExt) {
+ var resolved = coreResolve.call(this, name, parentName);
+ if (this.defaultJSExtensions && !skipExt && resolved.substr(resolved.length - 3, 3) != '.js' && !isPlain(resolved))
+ resolved += '.js';
+ return resolved;
+ };
+});
+
+// percent encode just '#' in urls if using HTTP requests
+var httpRequest = typeof XMLHttpRequest != 'undefined';
+hook('locate', function(locate) {
+ return function(load) {
+ return Promise.resolve(locate.call(this, load))
+ .then(function(address) {
+ if (httpRequest)
+ return address.replace(/#/g, '%23');
+ return address;
+ });
+ };
+});
+
+/*
+ * Fetch with authorization
+ */
+hook('fetch', function() {
+ return function(load) {
+ return new Promise(function(resolve, reject) {
+ fetchTextFromURL(load.address, load.metadata.authorization, resolve, reject);
+ });
+ };
+});
+
+/*
+ __useDefault
+
+ When a module object looks like:
+ newModule(
+ __useDefault: true,
+ default: 'some-module'
+ })
+
+ Then importing that module provides the 'some-module'
+ result directly instead of the full module.
+
+ Useful for eg module.exports = function() {}
+*/
+hook('import', function(systemImport) {
+ return function(name, parentName, parentAddress) {
+ if (parentName && parentName.name)
+ warn.call(this, 'SystemJS.import(name, { name: parentName }) is deprecated for SystemJS.import(name, parentName), while importing ' + name + ' from ' + parentName.name);
+ return systemImport.call(this, name, parentName, parentAddress).then(function(module) {
+ return module.__useDefault ? module['default'] : module;
+ });
+ };
+});
+
+/*
+ * Allow format: 'detect' meta to enable format detection
+ */
+hook('translate', function(systemTranslate) {
+ return function(load) {
+ if (load.metadata.format == 'detect')
+ load.metadata.format = undefined;
+ return systemTranslate.apply(this, arguments);
+ };
+});
+
+
+/*
+ * JSON format support
+ *
+ * Supports loading JSON files as a module format itself
+ *
+ * Usage:
+ *
+ * SystemJS.config({
+ * meta: {
+ * '*.json': { format: 'json' }
+ * }
+ * });
+ *
+ * Module is returned as if written:
+ *
+ * export default {JSON}
+ *
+ * No named exports are provided
+ *
+ * Files ending in ".json" are treated as json automatically by SystemJS
+ */
+hook('instantiate', function(instantiate) {
+ return function(load) {
+ if (load.metadata.format == 'json' && !this.builder) {
+ var entry = load.metadata.entry = createEntry();
+ entry.deps = [];
+ entry.execute = function() {
+ try {
+ return JSON.parse(load.source);
+ }
+ catch(e) {
+ throw new Error("Invalid JSON file " + load.name);
+ }
+ };
+ }
+ };
+})
+
+/*
+ Extend config merging one deep only
+
+ loader.config({
+ some: 'random',
+ config: 'here',
+ deep: {
+ config: { too: 'too' }
+ }
+ });
+
+ <=>
+
+ loader.some = 'random';
+ loader.config = 'here'
+ loader.deep = loader.deep || {};
+ loader.deep.config = { too: 'too' };
+
+
+ Normalizes meta and package configs allowing for:
+
+ SystemJS.config({
+ meta: {
+ './index.js': {}
+ }
+ });
+
+ To become
+
+ SystemJS.meta['https://thissite.com/index.js'] = {};
+
+ For easy normalization canonicalization with latest URL support.
+
+*/
+function envSet(loader, cfg, envCallback) {
+ if (envModule.browser && cfg.browserConfig)
+ envCallback(cfg.browserConfig);
+ if (envModule.node && cfg.nodeConfig)
+ envCallback(cfg.nodeConfig);
+ if (envModule.dev && cfg.devConfig)
+ envCallback(cfg.devConfig);
+ if (envModule.build && cfg.buildConfig)
+ envCallback(cfg.buildConfig);
+ if (envModule.production && cfg.productionConfig)
+ envCallback(cfg.productionConfig);
+}
+
+SystemJSLoader.prototype.getConfig = function(name) {
+ var cfg = {};
+ var loader = this;
+ for (var p in loader) {
+ if (loader.hasOwnProperty && !loader.hasOwnProperty(p) || p in SystemJSLoader.prototype && p != 'transpiler')
+ continue;
+ if (indexOf.call(['_loader', 'amdDefine', 'amdRequire', 'defined', 'failed', 'version', 'loads'], p) == -1)
+ cfg[p] = loader[p];
+ }
+ cfg.production = envModule.production;
+ return cfg;
+};
+
+var curCurScript;
+SystemJSLoader.prototype.config = function(cfg, isEnvConfig) {
+ var loader = this;
+
+ if ('loaderErrorStack' in cfg) {
+ curCurScript = $__curScript;
+ if (cfg.loaderErrorStack)
+ $__curScript = undefined;
+ else
+ $__curScript = curCurScript;
+ }
+
+ if ('warnings' in cfg)
+ loader.warnings = cfg.warnings;
+
+ // transpiler deprecation path
+ if (cfg.transpilerRuntime === false)
+ loader._loader.loadedTranspilerRuntime = true;
+
+ if ('production' in cfg || 'build' in cfg)
+ setProduction.call(loader, !!cfg.production, !!(cfg.build || envModule && envModule.build));
+
+ if (!isEnvConfig) {
+ // if using nodeConfig / browserConfig / productionConfig, take baseURL from there
+ // these exceptions will be unnecessary when we can properly implement config queuings
+ var baseURL;
+ envSet(loader, cfg, function(cfg) {
+ baseURL = baseURL || cfg.baseURL;
+ });
+ baseURL = baseURL || cfg.baseURL;
+
+ // always configure baseURL first
+ if (baseURL) {
+ var hasConfig = false;
+ function checkHasConfig(obj) {
+ for (var p in obj)
+ if (obj.hasOwnProperty(p))
+ return true;
+ }
+ if (checkHasConfig(loader.packages) || checkHasConfig(loader.meta) || checkHasConfig(loader.depCache) || checkHasConfig(loader.bundles) || checkHasConfig(loader.packageConfigPaths))
+ throw new TypeError('Incorrect configuration order. The baseURL must be configured with the first SystemJS.config call.');
+
+ this.baseURL = baseURL;
+ prepareBaseURL.call(this);
+ }
+
+ if (cfg.paths)
+ extend(loader.paths, cfg.paths);
+
+ envSet(loader, cfg, function(cfg) {
+ if (cfg.paths)
+ extend(loader.paths, cfg.paths);
+ });
+
+ // warn on wildcard path deprecations
+ if (this.warnings) {
+ for (var p in loader.paths)
+ if (p.indexOf('*') != -1)
+ warn.call(loader, 'Paths configuration "' + p + '" -> "' + loader.paths[p] + '" uses wildcards which are being deprecated for simpler trailing "/" folder paths.');
+ }
+ }
+
+ if (cfg.defaultJSExtensions) {
+ loader.defaultJSExtensions = cfg.defaultJSExtensions;
+ warn.call(loader, 'The defaultJSExtensions configuration option is deprecated, use packages configuration instead.');
+ }
+
+ if (cfg.pluginFirst)
+ loader.pluginFirst = cfg.pluginFirst;
+
+ if (cfg.map) {
+ var objMaps = '';
+ for (var p in cfg.map) {
+ var v = cfg.map[p];
+
+ // object map backwards-compat into packages configuration
+ if (typeof v !== 'string') {
+ objMaps += (objMaps.length ? ', ' : '') + '"' + p + '"';
+
+ var defaultJSExtension = loader.defaultJSExtensions && p.substr(p.length - 3, 3) != '.js';
+ var prop = loader.decanonicalize(p);
+ if (defaultJSExtension && prop.substr(prop.length - 3, 3) == '.js')
+ prop = prop.substr(0, prop.length - 3);
+
+ // if a package main, revert it
+ var pkgMatch = '';
+ for (var pkg in loader.packages) {
+ if (prop.substr(0, pkg.length) == pkg
+ && (!prop[pkg.length] || prop[pkg.length] == '/')
+ && pkgMatch.split('/').length < pkg.split('/').length)
+ pkgMatch = pkg;
+ }
+ if (pkgMatch && loader.packages[pkgMatch].main)
+ prop = prop.substr(0, prop.length - loader.packages[pkgMatch].main.length - 1);
+
+ var pkg = loader.packages[prop] = loader.packages[prop] || {};
+ pkg.map = v;
+ }
+ else {
+ loader.map[p] = v;
+ }
+ }
+ if (objMaps)
+ warn.call(loader, 'The map configuration for ' + objMaps + ' uses object submaps, which is deprecated in global map.\nUpdate this to use package contextual map with configs like SystemJS.config({ packages: { "' + p + '": { map: {...} } } }).');
+ }
+
+ if (cfg.packageConfigPaths) {
+ var packageConfigPaths = [];
+ for (var i = 0; i < cfg.packageConfigPaths.length; i++) {
+ var path = cfg.packageConfigPaths[i];
+ var packageLength = Math.max(path.lastIndexOf('*') + 1, path.lastIndexOf('/'));
+ var normalized = coreResolve.call(loader, path.substr(0, packageLength));
+ packageConfigPaths[i] = normalized + path.substr(packageLength);
+ }
+ loader.packageConfigPaths = packageConfigPaths;
+ }
+
+ if (cfg.bundles) {
+ for (var p in cfg.bundles) {
+ var bundle = [];
+ for (var i = 0; i < cfg.bundles[p].length; i++) {
+ var defaultJSExtension = loader.defaultJSExtensions && cfg.bundles[p][i].substr(cfg.bundles[p][i].length - 3, 3) != '.js';
+ var normalizedBundleDep = loader.decanonicalize(cfg.bundles[p][i]);
+ if (defaultJSExtension && normalizedBundleDep.substr(normalizedBundleDep.length - 3, 3) == '.js')
+ normalizedBundleDep = normalizedBundleDep.substr(0, normalizedBundleDep.length - 3);
+ bundle.push(normalizedBundleDep);
+ }
+ loader.bundles[p] = bundle;
+ }
+ }
+
+ if (cfg.packages) {
+ for (var p in cfg.packages) {
+ if (p.match(/^([^\/]+:)?\/\/$/))
+ throw new TypeError('"' + p + '" is not a valid package name.');
+
+ var prop = coreResolve.call(loader, p);
+
+ // allow trailing slash in packages
+ if (prop[prop.length - 1] == '/')
+ prop = prop.substr(0, prop.length - 1);
+
+ setPkgConfig(loader, prop, cfg.packages[p], false);
+ }
+ }
+
+ for (var c in cfg) {
+ var v = cfg[c];
+
+ if (indexOf.call(['baseURL', 'map', 'packages', 'bundles', 'paths', 'warnings', 'packageConfigPaths',
+ 'loaderErrorStack', 'browserConfig', 'nodeConfig', 'devConfig', 'buildConfig', 'productionConfig'], c) != -1)
+ continue;
+
+ if (typeof v != 'object' || v instanceof Array) {
+ loader[c] = v;
+ }
+ else {
+ loader[c] = loader[c] || {};
+
+ for (var p in v) {
+ // base-level wildcard meta does not normalize to retain catch-all quality
+ if (c == 'meta' && p[0] == '*') {
+ extend(loader[c][p] = loader[c][p] || {}, v[p]);
+ }
+ else if (c == 'meta') {
+ // meta can go through global map, with defaultJSExtensions adding
+ var resolved = coreResolve.call(loader, p);
+ if (loader.defaultJSExtensions && resolved.substr(resolved.length - 3, 3) != '.js' && !isPlain(resolved))
+ resolved += '.js';
+ extend(loader[c][resolved] = loader[c][resolved] || {}, v[p]);
+ }
+ else if (c == 'depCache') {
+ var defaultJSExtension = loader.defaultJSExtensions && p.substr(p.length - 3, 3) != '.js';
+ var prop = loader.decanonicalize(p);
+ if (defaultJSExtension && prop.substr(prop.length - 3, 3) == '.js')
+ prop = prop.substr(0, prop.length - 3);
+ loader[c][prop] = [].concat(v[p]);
+ }
+ else {
+ loader[c][p] = v[p];
+ }
+ }
+ }
+ }
+
+ envSet(loader, cfg, function(cfg) {
+ loader.config(cfg, true);
+ });
+};/*
+ * Package Configuration Extension
+ *
+ * Example:
+ *
+ * SystemJS.packages = {
+ * jquery: {
+ * main: 'index.js', // when not set, package name is requested directly
+ * format: 'amd',
+ * defaultExtension: 'ts', // defaults to 'js', can be set to false
+ * modules: {
+ * '*.ts': {
+ * loader: 'typescript'
+ * },
+ * 'vendor/sizzle.js': {
+ * format: 'global'
+ * }
+ * },
+ * map: {
+ * // map internal require('sizzle') to local require('./vendor/sizzle')
+ * sizzle: './vendor/sizzle.js',
+ * // map any internal or external require of 'jquery/vendor/another' to 'another/index.js'
+ * './vendor/another.js': './another/index.js',
+ * // test.js / test -> lib/test.js
+ * './test.js': './lib/test.js',
+ *
+ * // environment-specific map configurations
+ * './index.js': {
+ * '~browser': './index-node.js',
+ * './custom-condition.js|~export': './index-custom.js'
+ * }
+ * },
+ * // allows for setting package-prefixed depCache
+ * // keys are normalized module names relative to the package itself
+ * depCache: {
+ * // import 'package/index.js' loads in parallel package/lib/test.js,package/vendor/sizzle.js
+ * './index.js': ['./test'],
+ * './test.js': ['external-dep'],
+ * 'external-dep/path.js': ['./another.js']
+ * }
+ * }
+ * };
+ *
+ * Then:
+ * import 'jquery' -> jquery/index.js
+ * import 'jquery/submodule' -> jquery/submodule.js
+ * import 'jquery/submodule.ts' -> jquery/submodule.ts loaded as typescript
+ * import 'jquery/vendor/another' -> another/index.js
+ *
+ * Detailed Behaviours
+ * - main can have a leading "./" can be added optionally
+ * - map and defaultExtension are applied to the main
+ * - defaultExtension adds the extension only if the exact extension is not present
+ * - defaultJSExtensions applies after map when defaultExtension is not set
+ * - if a meta value is available for a module, map and defaultExtension are skipped
+ * - like global map, package map also applies to subpaths (sizzle/x, ./vendor/another/sub)
+ * - condition module map is '@env' module in package or '@system-env' globally
+ * - map targets support conditional interpolation ('./x': './x.#{|env}.js')
+ * - internal package map targets cannot use boolean conditionals
+ *
+ * Package Configuration Loading
+ *
+ * Not all packages may already have their configuration present in the System config
+ * For these cases, a list of packageConfigPaths can be provided, which when matched against
+ * a request, will first request a ".json" file by the package name to derive the package
+ * configuration from. This allows dynamic loading of non-predetermined code, a key use
+ * case in SystemJS.
+ *
+ * Example:
+ *
+ * SystemJS.packageConfigPaths = ['packages/test/package.json', 'packages/*.json'];
+ *
+ * // will first request 'packages/new-package/package.json' for the package config
+ * // before completing the package request to 'packages/new-package/path'
+ * SystemJS.import('packages/new-package/path');
+ *
+ * // will first request 'packages/test/package.json' before the main
+ * SystemJS.import('packages/test');
+ *
+ * When a package matches packageConfigPaths, it will always send a config request for
+ * the package configuration.
+ * The package name itself is taken to be the match up to and including the last wildcard
+ * or trailing slash.
+ * The most specific package config path will be used.
+ * Any existing package configurations for the package will deeply merge with the
+ * package config, with the existing package configurations taking preference.
+ * To opt-out of the package configuration request for a package that matches
+ * packageConfigPaths, use the { configured: true } package config option.
+ *
+ */
+(function() {
+
+ hookConstructor(function(constructor) {
+ return function() {
+ constructor.call(this);
+ this.packages = {};
+ this.packageConfigPaths = [];
+ };
+ });
+
+ function getPackage(loader, normalized) {
+ // use most specific package
+ var curPkg, curPkgLen = 0, pkgLen;
+ for (var p in loader.packages) {
+ if (normalized.substr(0, p.length) === p && (normalized.length === p.length || normalized[p.length] === '/')) {
+ pkgLen = p.split('/').length;
+ if (pkgLen > curPkgLen) {
+ curPkg = p;
+ curPkgLen = pkgLen;
+ }
+ }
+ }
+ return curPkg;
+ }
+
+ function addDefaultExtension(loader, pkg, pkgName, subPath, skipExtensions) {
+ // don't apply extensions to folders or if defaultExtension = false
+ if (!subPath || subPath[subPath.length - 1] == '/' || skipExtensions || pkg.defaultExtension === false)
+ return subPath;
+
+ var metaMatch = false;
+
+ // exact meta or meta with any content after the last wildcard skips extension
+ if (pkg.meta)
+ getMetaMatches(pkg.meta, subPath, function(metaPattern, matchMeta, matchDepth) {
+ if (matchDepth == 0 || metaPattern.lastIndexOf('*') != metaPattern.length - 1)
+ return metaMatch = true;
+ });
+
+ // exact global meta or meta with any content after the last wildcard skips extension
+ if (!metaMatch && loader.meta)
+ getMetaMatches(loader.meta, pkgName + '/' + subPath, function(metaPattern, matchMeta, matchDepth) {
+ if (matchDepth == 0 || metaPattern.lastIndexOf('*') != metaPattern.length - 1)
+ return metaMatch = true;
+ });
+
+ if (metaMatch)
+ return subPath;
+
+ // work out what the defaultExtension is and add if not there already
+ // NB reconsider if default should really be ".js"?
+ var defaultExtension = '.' + (pkg.defaultExtension || 'js');
+ if (subPath.substr(subPath.length - defaultExtension.length) != defaultExtension)
+ return subPath + defaultExtension;
+ else
+ return subPath;
+ }
+
+ function applyPackageConfigSync(loader, pkg, pkgName, subPath, skipExtensions) {
+ // main
+ if (!subPath) {
+ if (pkg.main)
+ subPath = pkg.main.substr(0, 2) == './' ? pkg.main.substr(2) : pkg.main;
+ // also no submap if name is package itself (import 'pkg' -> 'path/to/pkg.js')
+ else
+ // NB can add a default package main convention here when defaultJSExtensions is deprecated
+ // if it becomes internal to the package then it would no longer be an exit path
+ return pkgName + (loader.defaultJSExtensions ? '.js' : '');
+ }
+
+ // map config checking without then with extensions
+ if (pkg.map) {
+ var mapPath = './' + subPath;
+
+ var mapMatch = getMapMatch(pkg.map, mapPath);
+
+ // we then check map with the default extension adding
+ if (!mapMatch) {
+ mapPath = './' + addDefaultExtension(loader, pkg, pkgName, subPath, skipExtensions);
+ if (mapPath != './' + subPath)
+ mapMatch = getMapMatch(pkg.map, mapPath);
+ }
+ if (mapMatch) {
+ var mapped = doMapSync(loader, pkg, pkgName, mapMatch, mapPath, skipExtensions);
+ if (mapped)
+ return mapped;
+ }
+ }
+
+ // normal package resolution
+ return pkgName + '/' + addDefaultExtension(loader, pkg, pkgName, subPath, skipExtensions);
+ }
+
+ function validMapping(mapMatch, mapped, pkgName, path) {
+ // disallow internal to subpath maps
+ if (mapMatch == '.')
+ throw new Error('Package ' + pkgName + ' has a map entry for "." which is not permitted.');
+
+ // allow internal ./x -> ./x/y or ./x/ -> ./x/y recursive maps
+ // but only if the path is exactly ./x and not ./x/z
+ if (mapped.substr(0, mapMatch.length) == mapMatch && path.length > mapMatch.length)
+ return false;
+
+ return true;
+ }
+
+ function doMapSync(loader, pkg, pkgName, mapMatch, path, skipExtensions) {
+ if (path[path.length - 1] == '/')
+ path = path.substr(0, path.length - 1);
+ var mapped = pkg.map[mapMatch];
+
+ if (typeof mapped == 'object')
+ throw new Error('Synchronous conditional normalization not supported sync normalizing ' + mapMatch + ' in ' + pkgName);
+
+ if (!validMapping(mapMatch, mapped, pkgName, path) || typeof mapped != 'string')
+ return;
+
+ // package map to main / base-level
+ if (mapped == '.')
+ mapped = pkgName;
+
+ // internal package map
+ else if (mapped.substr(0, 2) == './')
+ return pkgName + '/' + addDefaultExtension(loader, pkg, pkgName, mapped.substr(2) + path.substr(mapMatch.length), skipExtensions);
+
+ // external map reference
+ return loader.normalizeSync(mapped + path.substr(mapMatch.length), pkgName + '/');
+ }
+
+ function applyPackageConfig(loader, pkg, pkgName, subPath, skipExtensions) {
+ // main
+ if (!subPath) {
+ if (pkg.main)
+ subPath = pkg.main.substr(0, 2) == './' ? pkg.main.substr(2) : pkg.main;
+ // also no submap if name is package itself (import 'pkg' -> 'path/to/pkg.js')
+ else
+ // NB can add a default package main convention here when defaultJSExtensions is deprecated
+ // if it becomes internal to the package then it would no longer be an exit path
+ return Promise.resolve(pkgName + (loader.defaultJSExtensions ? '.js' : ''));
+ }
+
+ // map config checking without then with extensions
+ var mapPath, mapMatch;
+
+ if (pkg.map) {
+ mapPath = './' + subPath;
+ mapMatch = getMapMatch(pkg.map, mapPath);
+
+ // we then check map with the default extension adding
+ if (!mapMatch) {
+ mapPath = './' + addDefaultExtension(loader, pkg, pkgName, subPath, skipExtensions);
+ if (mapPath != './' + subPath)
+ mapMatch = getMapMatch(pkg.map, mapPath);
+ }
+ }
+
+ return (mapMatch ? doMap(loader, pkg, pkgName, mapMatch, mapPath, skipExtensions) : Promise.resolve())
+ .then(function(mapped) {
+ if (mapped)
+ return Promise.resolve(mapped);
+
+ // normal package resolution / fallback resolution for no conditional match
+ return Promise.resolve(pkgName + '/' + addDefaultExtension(loader, pkg, pkgName, subPath, skipExtensions));
+ });
+ }
+
+ function doStringMap(loader, pkg, pkgName, mapMatch, mapped, path, skipExtensions) {
+ // NB the interpolation cases should strictly skip subsequent interpolation
+ // package map to main / base-level
+ if (mapped == '.')
+ mapped = pkgName;
+
+ // internal package map
+ else if (mapped.substr(0, 2) == './')
+ return Promise.resolve(pkgName + '/' + addDefaultExtension(loader, pkg, pkgName, mapped.substr(2) + path.substr(mapMatch.length), skipExtensions))
+ .then(function(name) {
+ return interpolateConditional.call(loader, name, pkgName + '/');
+ });
+
+ // external map reference
+ return loader.normalize(mapped + path.substr(mapMatch.length), pkgName + '/');
+ }
+
+ function doMap(loader, pkg, pkgName, mapMatch, path, skipExtensions) {
+ if (path[path.length - 1] == '/')
+ path = path.substr(0, path.length - 1);
+
+ var mapped = pkg.map[mapMatch];
+
+ if (typeof mapped == 'string') {
+ if (!validMapping(mapMatch, mapped, pkgName, path))
+ return Promise.resolve();
+ return doStringMap(loader, pkg, pkgName, mapMatch, mapped, path, skipExtensions);
+ }
+
+ // we use a special conditional syntax to allow the builder to handle conditional branch points further
+ if (loader.builder)
+ return Promise.resolve(pkgName + '/#:' + path);
+
+ // we load all conditions upfront
+ var conditionPromises = [];
+ var conditions = [];
+ for (var e in mapped) {
+ var c = parseCondition(e);
+ conditions.push({
+ condition: c,
+ map: mapped[e]
+ });
+ conditionPromises.push(loader['import'](c.module, pkgName));
+ }
+
+ // map object -> conditional map
+ return Promise.all(conditionPromises)
+ .then(function(conditionValues) {
+ // first map condition to match is used
+ for (var i = 0; i < conditions.length; i++) {
+ var c = conditions[i].condition;
+ var value = readMemberExpression(c.prop, conditionValues[i]);
+ if (!c.negate && value || c.negate && !value)
+ return conditions[i].map;
+ }
+ })
+ .then(function(mapped) {
+ if (mapped) {
+ if (!validMapping(mapMatch, mapped, pkgName, path))
+ return;
+ return doStringMap(loader, pkg, pkgName, mapMatch, mapped, path, skipExtensions);
+ }
+
+ // no environment match -> fallback to original subPath by returning undefined
+ });
+ }
+
+ // normalizeSync = decanonicalize + package resolution
+ SystemJSLoader.prototype.normalizeSync = SystemJSLoader.prototype.decanonicalize = SystemJSLoader.prototype.normalize;
+
+ // decanonicalize must JUST handle package defaultExtension: false case when defaultJSExtensions is set
+ // to be deprecated!
+ hook('decanonicalize', function(decanonicalize) {
+ return function(name, parentName) {
+ if (this.builder)
+ return decanonicalize.call(this, name, parentName, true);
+
+ var decanonicalized = decanonicalize.call(this, name, parentName, false);
+
+ if (!this.defaultJSExtensions)
+ return decanonicalized;
+
+ var pkgName = getPackage(this, decanonicalized);
+
+ var pkg = this.packages[pkgName];
+ var defaultExtension = pkg && pkg.defaultExtension;
+
+ if (defaultExtension == undefined && pkg && pkg.meta)
+ getMetaMatches(pkg.meta, decanonicalized.substr(pkgName), function(metaPattern, matchMeta, matchDepth) {
+ if (matchDepth == 0 || metaPattern.lastIndexOf('*') != metaPattern.length - 1) {
+ defaultExtension = false;
+ return true;
+ }
+ });
+
+ if ((defaultExtension === false || defaultExtension && defaultExtension != '.js') && name.substr(name.length - 3, 3) != '.js' && decanonicalized.substr(decanonicalized.length - 3, 3) == '.js')
+ decanonicalized = decanonicalized.substr(0, decanonicalized.length - 3);
+
+ return decanonicalized;
+ };
+ });
+
+ hook('normalizeSync', function(normalizeSync) {
+ return function(name, parentName, isPlugin) {
+ var loader = this;
+ isPlugin = isPlugin === true;
+
+ // apply contextual package map first
+ // (we assume the parent package config has already been loaded)
+ if (parentName)
+ var parentPackageName = getPackage(loader, parentName) ||
+ loader.defaultJSExtensions && parentName.substr(parentName.length - 3, 3) == '.js' &&
+ getPackage(loader, parentName.substr(0, parentName.length - 3));
+
+ var parentPackage = parentPackageName && loader.packages[parentPackageName];
+
+ // ignore . since internal maps handled by standard package resolution
+ if (parentPackage && name[0] != '.') {
+ var parentMap = parentPackage.map;
+ var parentMapMatch = parentMap && getMapMatch(parentMap, name);
+
+ if (parentMapMatch && typeof parentMap[parentMapMatch] == 'string') {
+ var mapped = doMapSync(loader, parentPackage, parentPackageName, parentMapMatch, name, isPlugin);
+ if (mapped)
+ return mapped;
+ }
+ }
+
+ var defaultJSExtension = loader.defaultJSExtensions && name.substr(name.length - 3, 3) != '.js';
+
+ // apply map, core, paths, contextual package map
+ var normalized = normalizeSync.call(loader, name, parentName, false);
+
+ // undo defaultJSExtension
+ if (defaultJSExtension && normalized.substr(normalized.length - 3, 3) != '.js')
+ defaultJSExtension = false;
+ if (defaultJSExtension)
+ normalized = normalized.substr(0, normalized.length - 3);
+
+ var pkgConfigMatch = getPackageConfigMatch(loader, normalized);
+ var pkgName = pkgConfigMatch && pkgConfigMatch.packageName || getPackage(loader, normalized);
+
+ if (!pkgName)
+ return normalized + (defaultJSExtension ? '.js' : '');
+
+ var subPath = normalized.substr(pkgName.length + 1);
+
+ return applyPackageConfigSync(loader, loader.packages[pkgName] || {}, pkgName, subPath, isPlugin);
+ };
+ });
+
+ hook('normalize', function(normalize) {
+ return function(name, parentName, isPlugin) {
+ var loader = this;
+ isPlugin = isPlugin === true;
+
+ return Promise.resolve()
+ .then(function() {
+ // apply contextual package map first
+ // (we assume the parent package config has already been loaded)
+ if (parentName)
+ var parentPackageName = getPackage(loader, parentName) ||
+ loader.defaultJSExtensions && parentName.substr(parentName.length - 3, 3) == '.js' &&
+ getPackage(loader, parentName.substr(0, parentName.length - 3));
+
+ var parentPackage = parentPackageName && loader.packages[parentPackageName];
+
+ // ignore . since internal maps handled by standard package resolution
+ if (parentPackage && name.substr(0, 2) != './') {
+ var parentMap = parentPackage.map;
+ var parentMapMatch = parentMap && getMapMatch(parentMap, name);
+
+ if (parentMapMatch)
+ return doMap(loader, parentPackage, parentPackageName, parentMapMatch, name, isPlugin);
+ }
+
+ return Promise.resolve();
+ })
+ .then(function(mapped) {
+ if (mapped)
+ return mapped;
+
+ var defaultJSExtension = loader.defaultJSExtensions && name.substr(name.length - 3, 3) != '.js';
+
+ // apply map, core, paths, contextual package map
+ var normalized = normalize.call(loader, name, parentName, false);
+
+ // undo defaultJSExtension
+ if (defaultJSExtension && normalized.substr(normalized.length - 3, 3) != '.js')
+ defaultJSExtension = false;
+ if (defaultJSExtension)
+ normalized = normalized.substr(0, normalized.length - 3);
+
+ var pkgConfigMatch = getPackageConfigMatch(loader, normalized);
+ var pkgName = pkgConfigMatch && pkgConfigMatch.packageName || getPackage(loader, normalized);
+
+ if (!pkgName)
+ return Promise.resolve(normalized + (defaultJSExtension ? '.js' : ''));
+
+ var pkg = loader.packages[pkgName];
+
+ // if package is already configured or not a dynamic config package, use existing package config
+ var isConfigured = pkg && (pkg.configured || !pkgConfigMatch);
+ return (isConfigured ? Promise.resolve(pkg) : loadPackageConfigPath(loader, pkgName, pkgConfigMatch.configPath))
+ .then(function(pkg) {
+ var subPath = normalized.substr(pkgName.length + 1);
+
+ return applyPackageConfig(loader, pkg, pkgName, subPath, isPlugin);
+ });
+ });
+ };
+ });
+
+ // check if the given normalized name matches a packageConfigPath
+ // if so, loads the config
+ var packageConfigPaths = {};
+
+ // data object for quick checks against package paths
+ function createPkgConfigPathObj(path) {
+ var lastWildcard = path.lastIndexOf('*');
+ var length = Math.max(lastWildcard + 1, path.lastIndexOf('/'));
+ return {
+ length: length,
+ regEx: new RegExp('^(' + path.substr(0, length).replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '[^\\/]+') + ')(\\/|$)'),
+ wildcard: lastWildcard != -1
+ };
+ }
+
+ // most specific match wins
+ function getPackageConfigMatch(loader, normalized) {
+ var pkgName, exactMatch = false, configPath;
+ for (var i = 0; i < loader.packageConfigPaths.length; i++) {
+ var packageConfigPath = loader.packageConfigPaths[i];
+ var p = packageConfigPaths[packageConfigPath] || (packageConfigPaths[packageConfigPath] = createPkgConfigPathObj(packageConfigPath));
+ if (normalized.length < p.length)
+ continue;
+ var match = normalized.match(p.regEx);
+ if (match && (!pkgName || (!(exactMatch && p.wildcard) && pkgName.length < match[1].length))) {
+ pkgName = match[1];
+ exactMatch = !p.wildcard;
+ configPath = pkgName + packageConfigPath.substr(p.length);
+ }
+ }
+
+ if (!pkgName)
+ return;
+
+ return {
+ packageName: pkgName,
+ configPath: configPath
+ };
+ }
+
+ function loadPackageConfigPath(loader, pkgName, pkgConfigPath) {
+ var configLoader = loader.pluginLoader || loader;
+
+ // NB remove this when json is default
+ (configLoader.meta[pkgConfigPath] = configLoader.meta[pkgConfigPath] || {}).format = 'json';
+ configLoader.meta[pkgConfigPath].loader = null;
+
+ return configLoader.load(pkgConfigPath)
+ .then(function() {
+ var cfg = configLoader.get(pkgConfigPath)['default'];
+
+ // support "systemjs" prefixing
+ if (cfg.systemjs)
+ cfg = cfg.systemjs;
+
+ // modules backwards compatibility
+ if (cfg.modules) {
+ cfg.meta = cfg.modules;
+ warn.call(loader, 'Package config file ' + pkgConfigPath + ' is configured with "modules", which is deprecated as it has been renamed to "meta".');
+ }
+
+ return setPkgConfig(loader, pkgName, cfg, true);
+ });
+ }
+
+ function getMetaMatches(pkgMeta, subPath, matchFn) {
+ // wildcard meta
+ var meta = {};
+ var wildcardIndex;
+ for (var module in pkgMeta) {
+ // allow meta to start with ./ for flexibility
+ var dotRel = module.substr(0, 2) == './' ? './' : '';
+ if (dotRel)
+ module = module.substr(2);
+
+ wildcardIndex = module.indexOf('*');
+ if (wildcardIndex === -1)
+ continue;
+
+ if (module.substr(0, wildcardIndex) == subPath.substr(0, wildcardIndex)
+ && module.substr(wildcardIndex + 1) == subPath.substr(subPath.length - module.length + wildcardIndex + 1)) {
+ // alow match function to return true for an exit path
+ if (matchFn(module, pkgMeta[dotRel + module], module.split('/').length))
+ return;
+ }
+ }
+ // exact meta
+ var exactMeta = pkgMeta[subPath] && pkgMeta.hasOwnProperty && pkgMeta.hasOwnProperty(subPath) ? pkgMeta[subPath] : pkgMeta['./' + subPath];
+ if (exactMeta)
+ matchFn(exactMeta, exactMeta, 0);
+ }
+
+ hook('locate', function(locate) {
+ return function(load) {
+ var loader = this;
+ return Promise.resolve(locate.call(this, load))
+ .then(function(address) {
+ var pkgName = getPackage(loader, load.name);
+ if (pkgName) {
+ var pkg = loader.packages[pkgName];
+ var subPath = load.name.substr(pkgName.length + 1);
+
+ var meta = {};
+ if (pkg.meta) {
+ var bestDepth = 0;
+
+ // NB support a main shorthand in meta here?
+ getMetaMatches(pkg.meta, subPath, function(metaPattern, matchMeta, matchDepth) {
+ if (matchDepth > bestDepth)
+ bestDepth = matchDepth;
+ extendMeta(meta, matchMeta, matchDepth && bestDepth > matchDepth);
+ });
+
+ extendMeta(load.metadata, meta);
+ }
+
+ // format
+ if (pkg.format && !load.metadata.loader)
+ load.metadata.format = load.metadata.format || pkg.format;
+ }
+
+ return address;
+ });
+ };
+ });
+
+})();
+/*
+ * Script tag fetch
+ *
+ * When load.metadata.scriptLoad is true, we load via script tag injection.
+ */
+(function() {
+
+ if (typeof document != 'undefined')
+ var head = document.getElementsByTagName('head')[0];
+
+ var curSystem;
+ var curRequire;
+
+ // if doing worker executing, this is set to the load record being executed
+ var workerLoad = null;
+
+ // interactive mode handling method courtesy RequireJS
+ var ieEvents = head && (function() {
+ var s = document.createElement('script');
+ var isOpera = typeof opera !== 'undefined' && opera.toString() === '[object Opera]';
+ return s.attachEvent && !(s.attachEvent.toString && s.attachEvent.toString().indexOf('[native code') < 0) && !isOpera;
+ })();
+
+ // IE interactive-only part
+ // we store loading scripts array as { script: <script>, load: {...} }
+ var interactiveLoadingScripts = [];
+ var interactiveScript;
+ function getInteractiveScriptLoad() {
+ if (interactiveScript && interactiveScript.script.readyState === 'interactive')
+ return interactiveScript.load;
+
+ for (var i = 0; i < interactiveLoadingScripts.length; i++)
+ if (interactiveLoadingScripts[i].script.readyState == 'interactive') {
+ interactiveScript = interactiveLoadingScripts[i];
+ return interactiveScript.load;
+ }
+ }
+
+ // System.register, System.registerDynamic, AMD define pipeline
+ // this is called by the above methods when they execute
+ // we then run the reduceRegister_ collection function either immediately
+ // if we are in IE and know the currently executing script (interactive)
+ // or later if we need to wait for the synchronous load callback to know the script
+ var loadingCnt = 0;
+ var registerQueue = [];
+ hook('pushRegister_', function(pushRegister) {
+ return function(register) {
+ // if using eval-execution then skip
+ if (pushRegister.call(this, register))
+ return false;
+
+ // if using worker execution, then we're done
+ if (workerLoad)
+ this.reduceRegister_(workerLoad, register);
+
+ // detect if we know the currently executing load (IE)
+ // if so, immediately call reduceRegister
+ else if (ieEvents)
+ this.reduceRegister_(getInteractiveScriptLoad(), register);
+
+ // otherwise, add to our execution queue
+ // to call reduceRegister on sync script load event
+ else if (loadingCnt)
+ registerQueue.push(register);
+
+ // if we're not currently loading anything though
+ // then do the reduction against a null load
+ // (out of band named define or named register)
+ // note even in non-script environments, this catch is used
+ else
+ this.reduceRegister_(null, register);
+
+ return true;
+ };
+ });
+
+ function webWorkerImport(loader, load) {
+ return new Promise(function(resolve, reject) {
+ if (load.metadata.integrity)
+ reject(new Error('Subresource integrity checking is not supported in web workers.'));
+
+ workerLoad = load;
+ try {
+ importScripts(load.address);
+ }
+ catch(e) {
+ workerLoad = null;
+ reject(e);
+ }
+ workerLoad = null;
+
+ // if nothing registered, then something went wrong
+ if (!load.metadata.entry)
+ reject(new Error(load.address + ' did not call System.register or AMD define. If loading a global, ensure the meta format is set to global.'));
+
+ resolve('');
+ });
+ }
+
+ // override fetch to use script injection
+ hook('fetch', function(fetch) {
+ return function(load) {
+ var loader = this;
+
+ if (load.metadata.format == 'json' || !load.metadata.scriptLoad || (!isBrowser && !isWorker))
+ return fetch.call(this, load);
+
+ if (isWorker)
+ return webWorkerImport(loader, load);
+
+ return new Promise(function(resolve, reject) {
+ var s = document.createElement('script');
+
+ s.async = true;
+
+ if (load.metadata.crossOrigin)
+ s.crossOrigin = load.metadata.crossOrigin;
+
+ if (load.metadata.integrity)
+ s.setAttribute('integrity', load.metadata.integrity);
+
+ if (ieEvents) {
+ s.attachEvent('onreadystatechange', complete);
+ interactiveLoadingScripts.push({
+ script: s,
+ load: load
+ });
+ }
+ else {
+ s.addEventListener('load', complete, false);
+ s.addEventListener('error', error, false);
+ }
+
+ loadingCnt++;
+
+ curSystem = __global.System;
+ curRequire = __global.require;
+
+ s.src = load.address;
+ head.appendChild(s);
+
+ function complete(evt) {
+ if (s.readyState && s.readyState != 'loaded' && s.readyState != 'complete')
+ return;
+
+ loadingCnt--;
+
+ // complete call is sync on execution finish
+ // (in ie already done reductions)
+ if (!load.metadata.entry && !registerQueue.length) {
+ loader.reduceRegister_(load);
+ }
+ else if (!ieEvents) {
+ for (var i = 0; i < registerQueue.length; i++)
+ loader.reduceRegister_(load, registerQueue[i]);
+ registerQueue = [];
+ }
+
+ cleanup();
+
+ // if nothing registered, then something went wrong
+ if (!load.metadata.entry && !load.metadata.bundle)
+ reject(new Error(load.name + ' did not call System.register or AMD define. If loading a global module configure the global name via the meta exports property for script injection support.'));
+
+ resolve('');
+ }
+
+ function error(evt) {
+ cleanup();
+ reject(new Error('Unable to load script ' + load.address));
+ }
+
+ function cleanup() {
+ __global.System = curSystem;
+ __global.require = curRequire;
+
+ if (s.detachEvent) {
+ s.detachEvent('onreadystatechange', complete);
+ for (var i = 0; i < interactiveLoadingScripts.length; i++)
+ if (interactiveLoadingScripts[i].script == s) {
+ if (interactiveScript && interactiveScript.script == s)
+ interactiveScript = null;
+ interactiveLoadingScripts.splice(i, 1);
+ }
+ }
+ else {
+ s.removeEventListener('load', complete, false);
+ s.removeEventListener('error', error, false);
+ }
+
+ head.removeChild(s);
+ }
+ });
+ };
+ });
+})();
+/*
+ * Instantiate registry extension
+ *
+ * Supports Traceur System.register 'instantiate' output for loading ES6 as ES5.
+ *
+ * - Creates the loader.register function
+ * - Also supports metadata.format = 'register' in instantiate for anonymous register modules
+ * - Also supports metadata.deps, metadata.execute and metadata.executingRequire
+ * for handling dynamic modules alongside register-transformed ES6 modules
+ *
+ *
+ * The code here replicates the ES6 linking groups algorithm to ensure that
+ * circular ES6 compiled into System.register can work alongside circular AMD
+ * and CommonJS, identically to the actual ES6 loader.
+ *
+ */
+
+
+/*
+ * Registry side table entries in loader.defined
+ * Registry Entry Contains:
+ * - name
+ * - deps
+ * - declare for declarative modules
+ * - execute for dynamic modules, different to declarative execute on module
+ * - executingRequire indicates require drives execution for circularity of dynamic modules
+ * - declarative optional boolean indicating which of the above
+ *
+ * Can preload modules directly on SystemJS.defined['my/module'] = { deps, execute, executingRequire }
+ *
+ * Then the entry gets populated with derived information during processing:
+ * - normalizedDeps derived from deps, created in instantiate
+ * - groupIndex used by group linking algorithm
+ * - evaluated indicating whether evaluation has happend
+ * - module the module record object, containing:
+ * - exports actual module exports
+ *
+ * For dynamic we track the es module with:
+ * - esModule actual es module value
+ * - esmExports whether to extend the esModule with named exports
+ *
+ * Then for declarative only we track dynamic bindings with the 'module' records:
+ * - name
+ * - exports
+ * - setters declarative setter functions
+ * - dependencies, module records of dependencies
+ * - importers, module records of dependents
+ *
+ * After linked and evaluated, entries are removed, declarative module records remain in separate
+ * module binding table
+ *
+ */
+
+var leadingCommentAndMetaRegEx = /^(\s*\/\*[^\*]*(\*(?!\/)[^\*]*)*\*\/|\s*\/\/[^\n]*|\s*"[^"]+"\s*;?|\s*'[^']+'\s*;?)*\s*/;
+function detectRegisterFormat(source) {
+ var leadingCommentAndMeta = source.match(leadingCommentAndMetaRegEx);
+ return leadingCommentAndMeta && source.substr(leadingCommentAndMeta[0].length, 15) == 'System.register';
+}
+
+function createEntry() {
+ return {
+ name: null,
+ deps: null,
+ originalIndices: null,
+ declare: null,
+ execute: null,
+ executingRequire: false,
+ declarative: false,
+ normalizedDeps: null,
+ groupIndex: null,
+ evaluated: false,
+ module: null,
+ esModule: null,
+ esmExports: false
+ };
+}
+
+(function() {
+
+ /*
+ * There are two variations of System.register:
+ * 1. System.register for ES6 conversion (2-3 params) - System.register([name, ]deps, declare)
+ * see https://github.com/ModuleLoader/es6-module-loader/wiki/System.register-Explained
+ *
+ * 2. System.registerDynamic for dynamic modules (3-4 params) - System.registerDynamic([name, ]deps, executingRequire, execute)
+ * the true or false statement
+ *
+ * this extension implements the linking algorithm for the two variations identical to the spec
+ * allowing compiled ES6 circular references to work alongside AMD and CJS circular references.
+ *
+ */
+ SystemJSLoader.prototype.register = function(name, deps, declare) {
+ if (typeof name != 'string') {
+ declare = deps;
+ deps = name;
+ name = null;
+ }
+
+ // dynamic backwards-compatibility
+ // can be deprecated eventually
+ if (typeof declare == 'boolean')
+ return this.registerDynamic.apply(this, arguments);
+
+ var entry = createEntry();
+ // ideally wouldn't apply map config to bundle names but
+ // dependencies go through map regardless so we can't restrict
+ // could reconsider in shift to new spec
+ entry.name = name && (this.decanonicalize || this.normalize).call(this, name);
+ entry.declarative = true;
+ entry.deps = deps;
+ entry.declare = declare;
+
+ this.pushRegister_({
+ amd: false,
+ entry: entry
+ });
+ };
+ SystemJSLoader.prototype.registerDynamic = function(name, deps, declare, execute) {
+ if (typeof name != 'string') {
+ execute = declare;
+ declare = deps;
+ deps = name;
+ name = null;
+ }
+
+ // dynamic
+ var entry = createEntry();
+ entry.name = name && (this.decanonicalize || this.normalize).call(this, name);
+ entry.deps = deps;
+ entry.execute = execute;
+ entry.executingRequire = declare;
+
+ this.pushRegister_({
+ amd: false,
+ entry: entry
+ });
+ };
+ hook('reduceRegister_', function() {
+ return function(load, register) {
+ if (!register)
+ return;
+
+ var entry = register.entry;
+ var curMeta = load && load.metadata;
+
+ // named register
+ if (entry.name) {
+ if (!(entry.name in this.defined))
+ this.defined[entry.name] = entry;
+
+ if (curMeta)
+ curMeta.bundle = true;
+ }
+ // anonymous register
+ if (!entry.name || load && !curMeta.entry && entry.name == load.name) {
+ if (!curMeta)
+ throw new TypeError('Invalid System.register call. Anonymous System.register calls can only be made by modules loaded by SystemJS.import and not via script tags.');
+ if (curMeta.entry) {
+ if (curMeta.format == 'register')
+ throw new Error('Multiple anonymous System.register calls in module ' + load.name + '. If loading a bundle, ensure all the System.register calls are named.');
+ else
+ throw new Error('Module ' + load.name + ' interpreted as ' + curMeta.format + ' module format, but called System.register.');
+ }
+ if (!curMeta.format)
+ curMeta.format = 'register';
+ curMeta.entry = entry;
+ }
+ };
+ });
+
+ hookConstructor(function(constructor) {
+ return function() {
+ constructor.call(this);
+
+ this.defined = {};
+ this._loader.moduleRecords = {};
+ };
+ });
+
+ function buildGroups(entry, loader, groups) {
+ groups[entry.groupIndex] = groups[entry.groupIndex] || [];
+
+ if (indexOf.call(groups[entry.groupIndex], entry) != -1)
+ return;
+
+ groups[entry.groupIndex].push(entry);
+
+ for (var i = 0, l = entry.normalizedDeps.length; i < l; i++) {
+ var depName = entry.normalizedDeps[i];
+ var depEntry = loader.defined[depName];
+
+ // not in the registry means already linked / ES6
+ if (!depEntry || depEntry.evaluated)
+ continue;
+
+ // now we know the entry is in our unlinked linkage group
+ var depGroupIndex = entry.groupIndex + (depEntry.declarative != entry.declarative);
+
+ // the group index of an entry is always the maximum
+ if (depEntry.groupIndex === null || depEntry.groupIndex < depGroupIndex) {
+
+ // if already in a group, remove from the old group
+ if (depEntry.groupIndex !== null) {
+ groups[depEntry.groupIndex].splice(indexOf.call(groups[depEntry.groupIndex], depEntry), 1);
+
+ // if the old group is empty, then we have a mixed depndency cycle
+ if (groups[depEntry.groupIndex].length == 0)
+ throw new Error("Mixed dependency cycle detected");
+ }
+
+ depEntry.groupIndex = depGroupIndex;
+ }
+
+ buildGroups(depEntry, loader, groups);
+ }
+ }
+
+ function link(name, startEntry, loader) {
+ // skip if already linked
+ if (startEntry.module)
+ return;
+
+ startEntry.groupIndex = 0;
+
+ var groups = [];
+
+ buildGroups(startEntry, loader, groups);
+
+ var curGroupDeclarative = !!startEntry.declarative == groups.length % 2;
+ for (var i = groups.length - 1; i >= 0; i--) {
+ var group = groups[i];
+ for (var j = 0; j < group.length; j++) {
+ var entry = group[j];
+
+ // link each group
+ if (curGroupDeclarative)
+ linkDeclarativeModule(entry, loader);
+ else
+ linkDynamicModule(entry, loader);
+ }
+ curGroupDeclarative = !curGroupDeclarative;
+ }
+ }
+
+ // module binding records
+ function ModuleRecord() {}
+ defineProperty(ModuleRecord, 'toString', {
+ value: function() {
+ return 'Module';
+ }
+ });
+
+ function getOrCreateModuleRecord(name, moduleRecords) {
+ return moduleRecords[name] || (moduleRecords[name] = {
+ name: name,
+ dependencies: [],
+ exports: new ModuleRecord(), // start from an empty module and extend
+ importers: []
+ });
+ }
+
+ function linkDeclarativeModule(entry, loader) {
+ // only link if already not already started linking (stops at circular)
+ if (entry.module)
+ return;
+
+ var moduleRecords = loader._loader.moduleRecords;
+ var module = entry.module = getOrCreateModuleRecord(entry.name, moduleRecords);
+ var exports = entry.module.exports;
+
+ var declaration = entry.declare.call(__global, function(name, value) {
+ module.locked = true;
+
+ if (typeof name == 'object') {
+ for (var p in name)
+ exports[p] = name[p];
+ }
+ else {
+ exports[name] = value;
+ }
+
+ for (var i = 0, l = module.importers.length; i < l; i++) {
+ var importerModule = module.importers[i];
+ if (!importerModule.locked) {
+ var importerIndex = indexOf.call(importerModule.dependencies, module);
+ var setter = importerModule.setters[importerIndex];
+ if (setter)
+ setter(exports);
+ }
+ }
+
+ module.locked = false;
+ return value;
+ }, { id: entry.name });
+
+ if (typeof declaration == 'function')
+ declaration = { setters: [], execute: declaration };
+
+ // allowing undefined declaration was a mistake! To be deprecated.
+ declaration = declaration || { setters: [], execute: function() {} };
+
+ module.setters = declaration.setters;
+ module.execute = declaration.execute;
+
+ if (!module.setters || !module.execute) {
+ throw new TypeError('Invalid System.register form for ' + entry.name);
+ }
+
+ // now link all the module dependencies
+ for (var i = 0, l = entry.normalizedDeps.length; i < l; i++) {
+ var depName = entry.normalizedDeps[i];
+ var depEntry = loader.defined[depName];
+ var depModule = moduleRecords[depName];
+
+ // work out how to set depExports based on scenarios...
+ var depExports;
+
+ if (depModule) {
+ depExports = depModule.exports;
+ }
+ // dynamic, already linked in our registry
+ else if (depEntry && !depEntry.declarative) {
+ depExports = depEntry.esModule;
+ }
+ // in the loader registry
+ else if (!depEntry) {
+ depExports = loader.get(depName);
+ }
+ // we have an entry -> link
+ else {
+ linkDeclarativeModule(depEntry, loader);
+ depModule = depEntry.module;
+ depExports = depModule.exports;
+ }
+
+ // only declarative modules have dynamic bindings
+ if (depModule && depModule.importers) {
+ depModule.importers.push(module);
+ module.dependencies.push(depModule);
+ }
+ else {
+ module.dependencies.push(null);
+ }
+
+ // run setters for all entries with the matching dependency name
+ var originalIndices = entry.originalIndices[i];
+ for (var j = 0, len = originalIndices.length; j < len; ++j) {
+ var index = originalIndices[j];
+ if (module.setters[index]) {
+ module.setters[index](depExports);
+ }
+ }
+ }
+ }
+
+ // An analog to loader.get covering execution of all three layers (real declarative, simulated declarative, simulated dynamic)
+ function getModule(name, loader) {
+ var exports;
+ var entry = loader.defined[name];
+
+ if (!entry) {
+ exports = loader.get(name);
+ if (!exports)
+ throw new Error('Unable to load dependency ' + name + '.');
+ }
+
+ else {
+ if (entry.declarative)
+ ensureEvaluated(name, entry, [], loader);
+
+ else if (!entry.evaluated)
+ linkDynamicModule(entry, loader);
+
+ exports = entry.module.exports;
+ }
+
+ if ((!entry || entry.declarative) && exports && exports.__useDefault)
+ return exports['default'];
+
+ return exports;
+ }
+
+ function linkDynamicModule(entry, loader) {
+ if (entry.module)
+ return;
+
+ var exports = {};
+
+ var module = entry.module = { exports: exports, id: entry.name };
+
+ // AMD requires execute the tree first
+ if (!entry.executingRequire) {
+ for (var i = 0, l = entry.normalizedDeps.length; i < l; i++) {
+ var depName = entry.normalizedDeps[i];
+ // we know we only need to link dynamic due to linking algorithm
+ var depEntry = loader.defined[depName];
+ if (depEntry)
+ linkDynamicModule(depEntry, loader);
+ }
+ }
+
+ // now execute
+ entry.evaluated = true;
+ var output = entry.execute.call(__global, function(name) {
+ for (var i = 0, l = entry.deps.length; i < l; i++) {
+ if (entry.deps[i] != name)
+ continue;
+ return getModule(entry.normalizedDeps[i], loader);
+ }
+ // try and normalize the dependency to see if we have another form
+ var nameNormalized = loader.normalizeSync(name, entry.name);
+ if (indexOf.call(entry.normalizedDeps, nameNormalized) != -1)
+ return getModule(nameNormalized, loader);
+
+ throw new Error('Module ' + name + ' not declared as a dependency of ' + entry.name);
+ }, exports, module);
+
+ if (output !== undefined)
+ module.exports = output;
+
+ // create the esModule object, which allows ES6 named imports of dynamics
+ exports = module.exports;
+
+ // __esModule flag treats as already-named
+ if (exports && (exports.__esModule || exports instanceof Module))
+ entry.esModule = loader.newModule(exports);
+ // set module as 'default' export, then fake named exports by iterating properties
+ else if (entry.esmExports && exports !== __global)
+ entry.esModule = loader.newModule(getESModule(exports));
+ // just use the 'default' export
+ else
+ entry.esModule = loader.newModule({ 'default': exports, __useDefault: true });
+ }
+
+ /*
+ * Given a module, and the list of modules for this current branch,
+ * ensure that each of the dependencies of this module is evaluated
+ * (unless one is a circular dependency already in the list of seen
+ * modules, in which case we execute it)
+ *
+ * Then we evaluate the module itself depth-first left to right
+ * execution to match ES6 modules
+ */
+ function ensureEvaluated(moduleName, entry, seen, loader) {
+ // if already seen, that means it's an already-evaluated non circular dependency
+ if (!entry || entry.evaluated || !entry.declarative)
+ return;
+
+ // this only applies to declarative modules which late-execute
+
+ seen.push(moduleName);
+
+ for (var i = 0, l = entry.normalizedDeps.length; i < l; i++) {
+ var depName = entry.normalizedDeps[i];
+ if (indexOf.call(seen, depName) == -1) {
+ if (!loader.defined[depName])
+ loader.get(depName);
+ else
+ ensureEvaluated(depName, loader.defined[depName], seen, loader);
+ }
+ }
+
+ if (entry.evaluated)
+ return;
+
+ entry.evaluated = true;
+ entry.module.execute.call(__global);
+ }
+
+ // override the delete method to also clear the register caches
+ hook('delete', function(del) {
+ return function(name) {
+ delete this._loader.moduleRecords[name];
+ delete this.defined[name];
+ return del.call(this, name);
+ };
+ });
+
+ hook('fetch', function(fetch) {
+ return function(load) {
+ if (this.defined[load.name]) {
+ load.metadata.format = 'defined';
+ return '';
+ }
+
+ load.metadata.deps = load.metadata.deps || [];
+
+ return fetch.call(this, load);
+ };
+ });
+
+ hook('translate', function(translate) {
+ // we run the meta detection here (register is after meta)
+ return function(load) {
+ load.metadata.deps = load.metadata.deps || [];
+ return Promise.resolve(translate.apply(this, arguments)).then(function(source) {
+ // run detection for register format
+ if (load.metadata.format == 'register' || !load.metadata.format && detectRegisterFormat(load.source))
+ load.metadata.format = 'register';
+ return source;
+ });
+ };
+ });
+
+ // implement a perforance shortpath for System.load with no deps
+ hook('load', function(doLoad) {
+ return function(normalized) {
+ var loader = this;
+ var entry = loader.defined[normalized];
+
+ if (!entry || entry.deps.length)
+ return doLoad.apply(this, arguments);
+
+ entry.originalIndices = entry.normalizedDeps = [];
+
+ // recursively ensure that the module and all its
+ // dependencies are linked (with dependency group handling)
+ link(normalized, entry, loader);
+
+ // now handle dependency execution in correct order
+ ensureEvaluated(normalized, entry, [], loader);
+ if (!entry.esModule)
+ entry.esModule = loader.newModule(entry.module.exports);
+
+ // remove from the registry
+ if (!loader.trace)
+ loader.defined[normalized] = undefined;
+
+ // return the defined module object
+ loader.set(normalized, entry.esModule);
+
+ return Promise.resolve();
+ };
+ });
+
+ hook('instantiate', function(instantiate) {
+ return function(load) {
+ if (load.metadata.format == 'detect')
+ load.metadata.format = undefined;
+
+ // assumes previous instantiate is sync
+ // (core json support)
+ instantiate.call(this, load);
+
+ var loader = this;
+
+ var entry;
+
+ // first we check if this module has already been defined in the registry
+ if (loader.defined[load.name]) {
+ entry = loader.defined[load.name];
+ // don't support deps for ES modules
+ if (!entry.declarative)
+ entry.deps = entry.deps.concat(load.metadata.deps);
+ entry.deps = entry.deps.concat(load.metadata.deps);
+ }
+
+ // picked up already by an anonymous System.register script injection
+ // or via the dynamic formats
+ else if (load.metadata.entry) {
+ entry = load.metadata.entry;
+ entry.deps = entry.deps.concat(load.metadata.deps);
+ }
+
+ // Contains System.register calls
+ // (dont run bundles in the builder)
+ else if (!(loader.builder && load.metadata.bundle)
+ && (load.metadata.format == 'register' || load.metadata.format == 'esm' || load.metadata.format == 'es6')) {
+
+ if (typeof __exec != 'undefined')
+ __exec.call(loader, load);
+
+ if (!load.metadata.entry && !load.metadata.bundle)
+ throw new Error(load.name + ' detected as ' + load.metadata.format + ' but didn\'t execute.');
+
+ entry = load.metadata.entry;
+
+ // support metadata deps for System.register
+ if (entry && load.metadata.deps)
+ entry.deps = entry.deps.concat(load.metadata.deps);
+ }
+
+ // named bundles are just an empty module
+ if (!entry) {
+ entry = createEntry();
+ entry.deps = load.metadata.deps;
+ entry.execute = function() {};
+ }
+
+ // place this module onto defined for circular references
+ loader.defined[load.name] = entry;
+
+ var grouped = group(entry.deps);
+
+ entry.deps = grouped.names;
+ entry.originalIndices = grouped.indices;
+ entry.name = load.name;
+ entry.esmExports = load.metadata.esmExports !== false;
+
+ // first, normalize all dependencies
+ var normalizePromises = [];
+ for (var i = 0, l = entry.deps.length; i < l; i++)
+ normalizePromises.push(Promise.resolve(loader.normalize(entry.deps[i], load.name)));
+
+ return Promise.all(normalizePromises).then(function(normalizedDeps) {
+
+ entry.normalizedDeps = normalizedDeps;
+
+ return {
+ deps: entry.deps,
+ execute: function() {
+ // recursively ensure that the module and all its
+ // dependencies are linked (with dependency group handling)
+ link(load.name, entry, loader);
+
+ // now handle dependency execution in correct order
+ ensureEvaluated(load.name, entry, [], loader);
+
+ if (!entry.esModule)
+ entry.esModule = loader.newModule(entry.module.exports);
+
+ // remove from the registry
+ if (!loader.trace)
+ loader.defined[load.name] = undefined;
+
+ // return the defined module object
+ return entry.esModule;
+ }
+ };
+ });
+ };
+ });
+})();
+/*
+ * Extension to detect ES6 and auto-load Traceur or Babel for processing
+ */
+(function() {
+ // good enough ES6 module detection regex - format detections not designed to be accurate, but to handle the 99% use case
+ var esmRegEx = /(^\s*|[}\);\n]\s*)(import\s*(['"]|(\*\s+as\s+)?[^"'\(\)\n;]+\s*from\s*['"]|\{)|export\s+\*\s+from\s+["']|export\s*(\{|default|function|class|var|const|let|async\s+function))/;
+
+ var traceurRuntimeRegEx = /\$traceurRuntime\s*\./;
+ var babelHelpersRegEx = /babelHelpers\s*\./;
+
+ hook('translate', function(translate) {
+ return function(load) {
+ var loader = this;
+ var args = arguments;
+ return translate.apply(loader, args)
+ .then(function(source) {
+ // detect & transpile ES6
+ if (load.metadata.format == 'esm' || load.metadata.format == 'es6' || !load.metadata.format && source.match(esmRegEx)) {
+ if (load.metadata.format == 'es6')
+ warn.call(loader, 'Module ' + load.name + ' has metadata setting its format to "es6", which is deprecated.\nThis should be updated to "esm".');
+
+ load.metadata.format = 'esm';
+
+ if (load.metadata.deps) {
+ var depInject = '';
+ for (var i = 0; i < load.metadata.deps.length; i++)
+ depInject += 'import "' + load.metadata.deps[i] + '"; ';
+ load.source = depInject + source;
+ }
+
+ if (loader.transpiler === false) {
+ // we accept translation to esm for builds though to enable eg rollup optimizations
+ if (loader.builder)
+ return source;
+ throw new TypeError('Unable to dynamically transpile ES module as SystemJS.transpiler set to false.');
+ }
+
+ // setting _loader.loadedTranspiler = false tells the next block to
+ // do checks for setting transpiler metadata
+ loader._loader.loadedTranspiler = loader._loader.loadedTranspiler || false;
+ if (loader.pluginLoader)
+ loader.pluginLoader._loader.loadedTranspiler = loader._loader.loadedTranspiler || false;
+
+ // do transpilation
+ return (loader._loader.transpilerPromise || (
+ loader._loader.transpilerPromise = Promise.resolve(
+ __global[loader.transpiler == 'typescript' ? 'ts' : loader.transpiler] || (loader.pluginLoader || loader)['import'](loader.transpiler)
+ ))).then(function(transpiler) {
+ loader._loader.loadedTranspilerRuntime = true;
+
+ // translate hooks means this is a transpiler plugin instead of a raw implementation
+ if (transpiler.translate) {
+ // if transpiler is the same as the plugin loader, then don't run twice
+ if (transpiler == load.metadata.loaderModule)
+ return load.source;
+
+ // convert the source map into an object for transpilation chaining
+ if (typeof load.metadata.sourceMap == 'string')
+ load.metadata.sourceMap = JSON.parse(load.metadata.sourceMap);
+
+ return Promise.resolve(transpiler.translate.apply(loader, args))
+ .then(function(source) {
+ // sanitize sourceMap if an object not a JSON string
+ var sourceMap = load.metadata.sourceMap;
+ if (sourceMap && typeof sourceMap == 'object') {
+ var originalName = load.address.split('!')[0];
+
+ // force set the filename of the original file
+ if (!sourceMap.file || sourceMap.file == load.address)
+ sourceMap.file = originalName + '!transpiled';
+
+ // force set the sources list if only one source
+ if (!sourceMap.sources || sourceMap.sources.length <= 1 && (!sourceMap.sources[0] || sourceMap.sources[0] == load.address))
+ sourceMap.sources = [originalName];
+ }
+
+ if (load.metadata.format == 'esm' && !loader.builder && detectRegisterFormat(source))
+ load.metadata.format = 'register';
+ return source;
+ });
+ }
+
+ // legacy builder support
+ if (loader.builder)
+ load.metadata.originalSource = load.source;
+
+ // defined in es6-module-loader/src/transpile.js
+ return transpile.call(loader, load)
+ .then(function(source) {
+ // clear sourceMap as transpiler embeds it
+ load.metadata.sourceMap = undefined;
+ return source;
+ });
+ }, function(err) {
+ throw addToError(err, 'Unable to load transpiler to transpile ' + load.name);
+ });
+ }
+
+ // skip transpiler and transpiler runtime loading when transpiler is disabled
+ if (loader.transpiler === false)
+ return source;
+
+ // load the transpiler correctly
+ if (loader._loader.loadedTranspiler === false && (loader.transpiler == 'traceur' || loader.transpiler == 'typescript' || loader.transpiler == 'babel')
+ && load.name == loader.normalizeSync(loader.transpiler)) {
+
+ // always load transpiler as a global
+ if (source.length > 100 && !load.metadata.format) {
+ load.metadata.format = 'global';
+
+ if (loader.transpiler === 'traceur')
+ load.metadata.exports = 'traceur';
+ if (loader.transpiler === 'typescript')
+ load.metadata.exports = 'ts';
+ }
+
+ loader._loader.loadedTranspiler = true;
+ }
+
+ // load the transpiler runtime correctly
+ if (loader._loader.loadedTranspilerRuntime === false) {
+ if (load.name == loader.normalizeSync('traceur-runtime')
+ || load.name == loader.normalizeSync('babel/external-helpers*')) {
+ if (source.length > 100)
+ load.metadata.format = load.metadata.format || 'global';
+
+ loader._loader.loadedTranspilerRuntime = true;
+ }
+ }
+
+ // detect transpiler runtime usage to load runtimes
+ if ((load.metadata.format == 'register' || load.metadata.bundle) && loader._loader.loadedTranspilerRuntime !== true) {
+ if (loader.transpiler == 'traceur' && !__global.$traceurRuntime && load.source.match(traceurRuntimeRegEx)) {
+ loader._loader.loadedTranspilerRuntime = loader._loader.loadedTranspilerRuntime || false;
+ return loader['import']('traceur-runtime').then(function() {
+ return source;
+ });
+ }
+ if (loader.transpiler == 'babel' && !__global.babelHelpers && load.source.match(babelHelpersRegEx)) {
+ loader._loader.loadedTranspilerRuntime = loader._loader.loadedTranspilerRuntime || false;
+ return loader['import']('babel/external-helpers').then(function() {
+ return source;
+ });
+ }
+ }
+
+ return source;
+ });
+ };
+ });
+
+})();
+/*
+ SystemJS Global Format
+
+ Supports
+ metadata.deps
+ metadata.globals
+ metadata.exports
+
+ Without metadata.exports, detects writes to the global object.
+*/
+var __globalName = typeof self != 'undefined' ? 'self' : 'global';
+
+hook('fetch', function(fetch) {
+ return function(load) {
+ if (load.metadata.exports && !load.metadata.format)
+ load.metadata.format = 'global';
+ return fetch.call(this, load);
+ };
+});
+
+// ideally we could support script loading for globals, but the issue with that is that
+// we can't do it with AMD support side-by-side since AMD support means defining the
+// global define, and global support means not definining it, yet we don't have any hook
+// into the "pre-execution" phase of a script tag being loaded to handle both cases
+hook('instantiate', function(instantiate) {
+ return function(load) {
+ var loader = this;
+
+ if (!load.metadata.format)
+ load.metadata.format = 'global';
+
+ // global is a fallback module format
+ if (load.metadata.format == 'global' && !load.metadata.entry) {
+
+ var entry = createEntry();
+
+ load.metadata.entry = entry;
+
+ entry.deps = [];
+
+ for (var g in load.metadata.globals) {
+ var gl = load.metadata.globals[g];
+ if (gl)
+ entry.deps.push(gl);
+ }
+
+ entry.execute = function(require, exports, module) {
+
+ var globals;
+ if (load.metadata.globals) {
+ globals = {};
+ for (var g in load.metadata.globals)
+ if (load.metadata.globals[g])
+ globals[g] = require(load.metadata.globals[g]);
+ }
+
+ var exportName = load.metadata.exports;
+
+ if (exportName)
+ load.source += '\n' + __globalName + '["' + exportName + '"] = ' + exportName + ';';
+
+ var retrieveGlobal = loader.get('@@global-helpers').prepareGlobal(module.id, exportName, globals, !!load.metadata.encapsulateGlobal);
+ __exec.call(loader, load);
+
+ return retrieveGlobal();
+ }
+ }
+ return instantiate.call(this, load);
+ };
+});
+
+
+function getGlobalValue(exports) {
+ if (typeof exports == 'string')
+ return readMemberExpression(exports, __global);
+
+ if (!(exports instanceof Array))
+ throw new Error('Global exports must be a string or array.');
+
+ var globalValue = {};
+ var first = true;
+ for (var i = 0; i < exports.length; i++) {
+ var val = readMemberExpression(exports[i], __global);
+ if (first) {
+ globalValue['default'] = val;
+ first = false;
+ }
+ globalValue[exports[i].split('.').pop()] = val;
+ }
+ return globalValue;
+}
+
+hook('reduceRegister_', function(reduceRegister) {
+ return function(load, register) {
+ if (register || (!load.metadata.exports && !(isWorker && load.metadata.format == 'global')))
+ return reduceRegister.call(this, load, register);
+
+ load.metadata.format = 'global';
+ var entry = load.metadata.entry = createEntry();
+ entry.deps = load.metadata.deps;
+ var globalValue = getGlobalValue(load.metadata.exports);
+ entry.execute = function() {
+ return globalValue;
+ };
+ };
+});
+
+hookConstructor(function(constructor) {
+ return function() {
+ var loader = this;
+ constructor.call(loader);
+
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+
+ // bare minimum ignores
+ var ignoredGlobalProps = ['_g', 'sessionStorage', 'localStorage', 'clipboardData', 'frames', 'frameElement', 'external',
+ 'mozAnimationStartTime', 'webkitStorageInfo', 'webkitIndexedDB', 'mozInnerScreenY', 'mozInnerScreenX'];
+
+ var globalSnapshot;
+
+ function forEachGlobal(callback) {
+ if (Object.keys)
+ Object.keys(__global).forEach(callback);
+ else
+ for (var g in __global) {
+ if (!hasOwnProperty.call(__global, g))
+ continue;
+ callback(g);
+ }
+ }
+
+ function forEachGlobalValue(callback) {
+ forEachGlobal(function(globalName) {
+ if (indexOf.call(ignoredGlobalProps, globalName) != -1)
+ return;
+ try {
+ var value = __global[globalName];
+ }
+ catch (e) {
+ ignoredGlobalProps.push(globalName);
+ }
+ callback(globalName, value);
+ });
+ }
+
+ loader.set('@@global-helpers', loader.newModule({
+ prepareGlobal: function(moduleName, exports, globals, encapsulate) {
+ // disable module detection
+ var curDefine = __global.define;
+
+ __global.define = undefined;
+
+ // set globals
+ var oldGlobals;
+ if (globals) {
+ oldGlobals = {};
+ for (var g in globals) {
+ oldGlobals[g] = __global[g];
+ __global[g] = globals[g];
+ }
+ }
+
+ // store a complete copy of the global object in order to detect changes
+ if (!exports) {
+ globalSnapshot = {};
+
+ forEachGlobalValue(function(name, value) {
+ globalSnapshot[name] = value;
+ });
+ }
+
+ // return function to retrieve global
+ return function() {
+ var globalValue = exports ? getGlobalValue(exports) : {};
+
+ var singleGlobal;
+ var multipleExports = !!exports;
+
+ if (!exports || encapsulate)
+ forEachGlobalValue(function(name, value) {
+ if (globalSnapshot[name] === value)
+ return;
+ if (typeof value == 'undefined')
+ return;
+
+ // allow global encapsulation where globals are removed
+ if (encapsulate)
+ __global[name] = undefined;
+
+ if (!exports) {
+ globalValue[name] = value;
+
+ if (typeof singleGlobal != 'undefined') {
+ if (!multipleExports && singleGlobal !== value)
+ multipleExports = true;
+ }
+ else {
+ singleGlobal = value;
+ }
+ }
+ });
+
+ globalValue = multipleExports ? globalValue : singleGlobal;
+
+ // revert globals
+ if (oldGlobals) {
+ for (var g in oldGlobals)
+ __global[g] = oldGlobals[g];
+ }
+ __global.define = curDefine;
+
+ return globalValue;
+ };
+ }
+ }));
+ };
+});
+/*
+ SystemJS CommonJS Format
+*/
+(function() {
+ // CJS Module Format
+ // require('...') || exports[''] = ... || exports.asd = ... || module.exports = ...
+ var cjsExportsRegEx = /(?:^\uFEFF?|[^$_a-zA-Z\xA0-\uFFFF.])(exports\s*(\[['"]|\.)|module(\.exports|\['exports'\]|\["exports"\])\s*(\[['"]|[=,\.]))/;
+ // RegEx adjusted from https://github.com/jbrantly/yabble/blob/master/lib/yabble.js#L339
+ var cjsRequireRegEx = /(?:^\uFEFF?|[^$_a-zA-Z\xA0-\uFFFF."'])require\s*\(\s*("[^"\\]*(?:\\.[^"\\]*)*"|'[^'\\]*(?:\\.[^'\\]*)*')\s*\)/g;
+ var commentRegEx = /(^|[^\\])(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg;
+
+ var stringRegEx = /("[^"\\\n\r]*(\\.[^"\\\n\r]*)*"|'[^'\\\n\r]*(\\.[^'\\\n\r]*)*')/g;
+
+ // used to support leading #!/usr/bin/env in scripts as supported in Node
+ var hashBangRegEx = /^\#\!.*/;
+
+ function getCJSDeps(source) {
+ cjsRequireRegEx.lastIndex = commentRegEx.lastIndex = stringRegEx.lastIndex = 0;
+
+ var deps = [];
+
+ var match;
+
+ // track string and comment locations for unminified source
+ var stringLocations = [], commentLocations = [];
+
+ function inLocation(locations, match) {
+ for (var i = 0; i < locations.length; i++)
+ if (locations[i][0] < match.index && locations[i][1] > match.index)
+ return true;
+ return false;
+ }
+
+ if (source.length / source.split('\n').length < 200) {
+ while (match = stringRegEx.exec(source))
+ stringLocations.push([match.index, match.index + match[0].length]);
+
+ // TODO: track template literals here before comments
+
+ while (match = commentRegEx.exec(source)) {
+ // only track comments not starting in strings
+ if (!inLocation(stringLocations, match))
+ commentLocations.push([match.index + match[1].length, match.index + match[0].length - 1]);
+ }
+ }
+
+ while (match = cjsRequireRegEx.exec(source)) {
+ // ensure we're not within a string or comment location
+ if (!inLocation(stringLocations, match) && !inLocation(commentLocations, match)) {
+ var dep = match[1].substr(1, match[1].length - 2);
+ // skip cases like require('" + file + "')
+ if (dep.match(/"|'/))
+ continue;
+ // trailing slash requires are removed as they don't map mains in SystemJS
+ if (dep[dep.length - 1] == '/')
+ dep = dep.substr(0, dep.length - 1);
+ deps.push(dep);
+ }
+ }
+
+ return deps;
+ }
+
+ hook('instantiate', function(instantiate) {
+ return function(load) {
+ var loader = this;
+ if (!load.metadata.format) {
+ cjsExportsRegEx.lastIndex = 0;
+ cjsRequireRegEx.lastIndex = 0;
+ if (cjsRequireRegEx.exec(load.source) || cjsExportsRegEx.exec(load.source))
+ load.metadata.format = 'cjs';
+ }
+
+ if (load.metadata.format == 'cjs') {
+ var metaDeps = load.metadata.deps;
+ var deps = load.metadata.cjsRequireDetection === false ? [] : getCJSDeps(load.source);
+
+ for (var g in load.metadata.globals)
+ if (load.metadata.globals[g])
+ deps.push(load.metadata.globals[g]);
+
+ var entry = createEntry();
+
+ load.metadata.entry = entry;
+
+ entry.deps = deps;
+ entry.executingRequire = true;
+ entry.execute = function(_require, exports, module) {
+ function require(name) {
+ if (name[name.length - 1] == '/')
+ name = name.substr(0, name.length - 1);
+ return _require.apply(this, arguments);
+ }
+ require.resolve = function(name) {
+ return loader.get('@@cjs-helpers').requireResolve(name, module.id);
+ };
+ // support module.paths ish
+ module.paths = [];
+ module.require = _require;
+
+ // ensure meta deps execute first
+ if (!load.metadata.cjsDeferDepsExecute)
+ for (var i = 0; i < metaDeps.length; i++)
+ require(metaDeps[i]);
+
+ var pathVars = loader.get('@@cjs-helpers').getPathVars(module.id);
+ var __cjsWrapper = {
+ exports: exports,
+ args: [require, exports, module, pathVars.filename, pathVars.dirname, __global, __global]
+ };
+
+ var cjsWrapper = "(function(require, exports, module, __filename, __dirname, global, GLOBAL";
+
+ // add metadata.globals to the wrapper arguments
+ if (load.metadata.globals)
+ for (var g in load.metadata.globals) {
+ __cjsWrapper.args.push(require(load.metadata.globals[g]));
+ cjsWrapper += ", " + g;
+ }
+
+ // disable AMD detection
+ var define = __global.define;
+ __global.define = undefined;
+ __global.__cjsWrapper = __cjsWrapper;
+
+ load.source = cjsWrapper + ") {" + load.source.replace(hashBangRegEx, '') + "\n}).apply(__cjsWrapper.exports, __cjsWrapper.args);";
+
+ __exec.call(loader, load);
+
+ __global.__cjsWrapper = undefined;
+ __global.define = define;
+ };
+ }
+
+ return instantiate.call(loader, load);
+ };
+ });
+})();
+hookConstructor(function(constructor) {
+ return function() {
+ var loader = this;
+ constructor.call(loader);
+
+ if (typeof window != 'undefined' && typeof document != 'undefined' && window.location)
+ var windowOrigin = location.protocol + '//' + location.hostname + (location.port ? ':' + location.port : '');
+
+ function stripOrigin(path) {
+ if (path.substr(0, 8) == 'file:///')
+ return path.substr(7 + !!isWindows);
+
+ if (windowOrigin && path.substr(0, windowOrigin.length) == windowOrigin)
+ return path.substr(windowOrigin.length);
+
+ return path;
+ }
+
+ loader.set('@@cjs-helpers', loader.newModule({
+ requireResolve: function(request, parentId) {
+ return stripOrigin(loader.normalizeSync(request, parentId));
+ },
+ getPathVars: function(moduleId) {
+ // remove any plugin syntax
+ var pluginIndex = moduleId.lastIndexOf('!');
+ var filename;
+ if (pluginIndex != -1)
+ filename = moduleId.substr(0, pluginIndex);
+ else
+ filename = moduleId;
+
+ var dirname = filename.split('/');
+ dirname.pop();
+ dirname = dirname.join('/');
+
+ return {
+ filename: stripOrigin(filename),
+ dirname: stripOrigin(dirname)
+ };
+ }
+ }))
+ };
+});/*
+ * AMD Helper function module
+ * Separated into its own file as this is the part needed for full AMD support in SFX builds
+ * NB since implementations have now diverged this can be merged back with amd.js
+ */
+
+hook('fetch', function(fetch) {
+ return function(load) {
+ // script load implies define global leak
+ if (load.metadata.scriptLoad && isBrowser)
+ __global.define = this.amdDefine;
+ return fetch.call(this, load);
+ };
+});
+
+hookConstructor(function(constructor) {
+ return function() {
+ var loader = this;
+ constructor.call(this);
+
+ var commentRegEx = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg;
+ var cjsRequirePre = "(?:^|[^$_a-zA-Z\\xA0-\\uFFFF.])";
+ var cjsRequirePost = "\\s*\\(\\s*(\"([^\"]+)\"|'([^']+)')\\s*\\)";
+ var fnBracketRegEx = /\(([^\)]*)\)/;
+ var wsRegEx = /^\s+|\s+$/g;
+
+ var requireRegExs = {};
+
+ function getCJSDeps(source, requireIndex) {
+
+ // remove comments
+ source = source.replace(commentRegEx, '');
+
+ // determine the require alias
+ var params = source.match(fnBracketRegEx);
+ var requireAlias = (params[1].split(',')[requireIndex] || 'require').replace(wsRegEx, '');
+
+ // find or generate the regex for this requireAlias
+ var requireRegEx = requireRegExs[requireAlias] || (requireRegExs[requireAlias] = new RegExp(cjsRequirePre + requireAlias + cjsRequirePost, 'g'));
+
+ requireRegEx.lastIndex = 0;
+
+ var deps = [];
+
+ var match;
+ while (match = requireRegEx.exec(source))
+ deps.push(match[2] || match[3]);
+
+ return deps;
+ }
+
+ /*
+ AMD-compatible require
+ To copy RequireJS, set window.require = window.requirejs = loader.amdRequire
+ */
+ function require(names, callback, errback, referer) {
+ // in amd, first arg can be a config object... we just ignore
+ if (typeof names == 'object' && !(names instanceof Array))
+ return require.apply(null, Array.prototype.splice.call(arguments, 1, arguments.length - 1));
+
+ // amd require
+ if (typeof names == 'string' && typeof callback == 'function')
+ names = [names];
+ if (names instanceof Array) {
+ var dynamicRequires = [];
+ for (var i = 0; i < names.length; i++)
+ dynamicRequires.push(loader['import'](names[i], referer));
+ Promise.all(dynamicRequires).then(function(modules) {
+ if (callback)
+ callback.apply(null, modules);
+ }, errback);
+ }
+
+ // commonjs require
+ else if (typeof names == 'string') {
+ var defaultJSExtension = loader.defaultJSExtensions && names.substr(names.length - 3, 3) != '.js';
+ var normalized = loader.decanonicalize(names, referer);
+ if (defaultJSExtension && normalized.substr(normalized.length - 3, 3) == '.js')
+ normalized = normalized.substr(0, normalized.length - 3);
+ var module = loader.get(normalized);
+ if (!module)
+ throw new Error('Module not already loaded loading "' + names + '" as ' + normalized + (referer ? ' from "' + referer + '".' : '.'));
+ return module.__useDefault ? module['default'] : module;
+ }
+
+ else
+ throw new TypeError('Invalid require');
+ }
+
+ function define(name, deps, factory) {
+ if (typeof name != 'string') {
+ factory = deps;
+ deps = name;
+ name = null;
+ }
+ if (!(deps instanceof Array)) {
+ factory = deps;
+ deps = ['require', 'exports', 'module'].splice(0, factory.length);
+ }
+
+ if (typeof factory != 'function')
+ factory = (function(factory) {
+ return function() { return factory; }
+ })(factory);
+
+ // in IE8, a trailing comma becomes a trailing undefined entry
+ if (deps[deps.length - 1] === undefined)
+ deps.pop();
+
+ // remove system dependencies
+ var requireIndex, exportsIndex, moduleIndex;
+
+ if ((requireIndex = indexOf.call(deps, 'require')) != -1) {
+
+ deps.splice(requireIndex, 1);
+
+ // only trace cjs requires for non-named
+ // named defines assume the trace has already been done
+ if (!name)
+ deps = deps.concat(getCJSDeps(factory.toString(), requireIndex));
+ }
+
+ if ((exportsIndex = indexOf.call(deps, 'exports')) != -1)
+ deps.splice(exportsIndex, 1);
+
+ if ((moduleIndex = indexOf.call(deps, 'module')) != -1)
+ deps.splice(moduleIndex, 1);
+
+ function execute(req, exports, module) {
+ var depValues = [];
+ for (var i = 0; i < deps.length; i++)
+ depValues.push(req(deps[i]));
+
+ module.uri = module.id;
+
+ module.config = function() {};
+
+ // add back in system dependencies
+ if (moduleIndex != -1)
+ depValues.splice(moduleIndex, 0, module);
+
+ if (exportsIndex != -1)
+ depValues.splice(exportsIndex, 0, exports);
+
+ if (requireIndex != -1) {
+ function contextualRequire(names, callback, errback) {
+ if (typeof names == 'string' && typeof callback != 'function')
+ return req(names);
+ return require.call(loader, names, callback, errback, module.id);
+ }
+ contextualRequire.toUrl = function(name) {
+ // normalize without defaultJSExtensions
+ var defaultJSExtension = loader.defaultJSExtensions && name.substr(name.length - 3, 3) != '.js';
+ var url = loader.decanonicalize(name, module.id);
+ if (defaultJSExtension && url.substr(url.length - 3, 3) == '.js')
+ url = url.substr(0, url.length - 3);
+ return url;
+ };
+ depValues.splice(requireIndex, 0, contextualRequire);
+ }
+
+ // set global require to AMD require
+ var curRequire = __global.require;
+ __global.require = require;
+
+ var output = factory.apply(exportsIndex == -1 ? __global : exports, depValues);
+
+ __global.require = curRequire;
+
+ if (typeof output == 'undefined' && module)
+ output = module.exports;
+
+ if (typeof output != 'undefined')
+ return output;
+ }
+
+ var entry = createEntry();
+ entry.name = name && (loader.decanonicalize || loader.normalize).call(loader, name);
+ entry.deps = deps;
+ entry.execute = execute;
+
+ loader.pushRegister_({
+ amd: true,
+ entry: entry
+ });
+ }
+ define.amd = {};
+
+ // reduction function to attach defines to a load record
+ hook('reduceRegister_', function(reduceRegister) {
+ return function(load, register) {
+ // only handle AMD registers here
+ if (!register || !register.amd)
+ return reduceRegister.call(this, load, register);
+
+ var curMeta = load && load.metadata;
+ var entry = register.entry;
+
+ if (curMeta) {
+ if (!curMeta.format || curMeta.format == 'detect')
+ curMeta.format = 'amd';
+ else if (!entry.name && curMeta.format != 'amd')
+ throw new Error('AMD define called while executing ' + curMeta.format + ' module ' + load.name);
+ }
+
+ // anonymous define
+ if (!entry.name) {
+ if (!curMeta)
+ throw new TypeError('Unexpected anonymous AMD define.');
+
+ if (curMeta.entry && !curMeta.entry.name)
+ throw new Error('Multiple anonymous defines in module ' + load.name);
+
+ curMeta.entry = entry;
+ }
+ // named define
+ else {
+ // if we don't have any other defines,
+ // then let this be an anonymous define
+ // this is just to support single modules of the form:
+ // define('jquery')
+ // still loading anonymously
+ // because it is done widely enough to be useful
+ // as soon as there is more than one define, this gets removed though
+ if (curMeta) {
+ if (!curMeta.entry && !curMeta.bundle)
+ curMeta.entry = entry;
+ else if (curMeta.entry && curMeta.entry.name && curMeta.entry.name != load.name)
+ curMeta.entry = undefined;
+
+ // note this is now a bundle
+ curMeta.bundle = true;
+ }
+
+ // define the module through the register registry
+ if (!(entry.name in this.defined))
+ this.defined[entry.name] = entry;
+ }
+ };
+ });
+
+ loader.amdDefine = define;
+ loader.amdRequire = require;
+ };
+});/*
+ SystemJS AMD Format
+*/
+(function() {
+ // AMD Module Format Detection RegEx
+ // define([.., .., ..], ...)
+ // define(varName); || define(function(require, exports) {}); || define({})
+ var amdRegEx = /(?:^\uFEFF?|[^$_a-zA-Z\xA0-\uFFFF.])define\s*\(\s*("[^"]+"\s*,\s*|'[^']+'\s*,\s*)?\s*(\[(\s*(("[^"]+"|'[^']+')\s*,|\/\/.*\r?\n|\/\*(.|\s)*?\*\/))*(\s*("[^"]+"|'[^']+')\s*,?)?(\s*(\/\/.*\r?\n|\/\*(.|\s)*?\*\/))*\s*\]|function\s*|{|[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*\))/;
+
+ hook('instantiate', function(instantiate) {
+ return function(load) {
+ var loader = this;
+
+ if (load.metadata.format == 'amd' || !load.metadata.format && load.source.match(amdRegEx)) {
+ load.metadata.format = 'amd';
+
+ if (!loader.builder && loader.execute !== false) {
+ var curDefine = __global.define;
+ __global.define = this.amdDefine;
+
+ try {
+ __exec.call(loader, load);
+ }
+ finally {
+ __global.define = curDefine;
+ }
+
+ if (!load.metadata.entry && !load.metadata.bundle)
+ throw new TypeError('AMD module ' + load.name + ' did not define');
+ }
+ else {
+ load.metadata.execute = function() {
+ return load.metadata.builderExecute.apply(this, arguments);
+ };
+ }
+ }
+
+ return instantiate.call(loader, load);
+ };
+ });
+
+})();
+/*
+ SystemJS Loader Plugin Support
+
+ Supports plugin loader syntax with "!", or via metadata.loader
+
+ The plugin name is loaded as a module itself, and can override standard loader hooks
+ for the plugin resource. See the plugin section of the systemjs readme.
+*/
+
+(function() {
+ function getParentName(loader, parentName) {
+ // if parent is a plugin, normalize against the parent plugin argument only
+ if (parentName) {
+ var parentPluginIndex;
+ if (loader.pluginFirst) {
+ if ((parentPluginIndex = parentName.lastIndexOf('!')) != -1)
+ return parentName.substr(parentPluginIndex + 1);
+ }
+ else {
+ if ((parentPluginIndex = parentName.indexOf('!')) != -1)
+ return parentName.substr(0, parentPluginIndex);
+ }
+
+ return parentName;
+ }
+ }
+
+ function parsePlugin(loader, name) {
+ var argumentName;
+ var pluginName;
+
+ var pluginIndex = name.lastIndexOf('!');
+
+ if (pluginIndex == -1)
+ return;
+
+ if (loader.pluginFirst) {
+ argumentName = name.substr(pluginIndex + 1);
+ pluginName = name.substr(0, pluginIndex);
+ }
+ else {
+ argumentName = name.substr(0, pluginIndex);
+ pluginName = name.substr(pluginIndex + 1) || argumentName.substr(argumentName.lastIndexOf('.') + 1);
+ }
+
+ return {
+ argument: argumentName,
+ plugin: pluginName
+ };
+ }
+
+ // put name back together after parts have been normalized
+ function combinePluginParts(loader, argumentName, pluginName, defaultExtension) {
+ if (defaultExtension && argumentName.substr(argumentName.length - 3, 3) == '.js')
+ argumentName = argumentName.substr(0, argumentName.length - 3);
+
+ if (loader.pluginFirst) {
+ return pluginName + '!' + argumentName;
+ }
+ else {
+ return argumentName + '!' + pluginName;
+ }
+ }
+
+ // note if normalize will add a default js extension
+ // if so, remove for backwards compat
+ // this is strange and sucks, but will be deprecated
+ function checkDefaultExtension(loader, arg) {
+ return loader.defaultJSExtensions && arg.substr(arg.length - 3, 3) != '.js';
+ }
+
+ function createNormalizeSync(normalizeSync) {
+ return function(name, parentName, isPlugin) {
+ var loader = this;
+
+ var parsed = parsePlugin(loader, name);
+ parentName = getParentName(this, parentName);
+
+ if (!parsed)
+ return normalizeSync.call(this, name, parentName, isPlugin);
+
+ // if this is a plugin, normalize the plugin name and the argument
+ var argumentName = loader.normalizeSync(parsed.argument, parentName, true);
+ var pluginName = loader.normalizeSync(parsed.plugin, parentName, true);
+ return combinePluginParts(loader, argumentName, pluginName, checkDefaultExtension(loader, parsed.argument));
+ };
+ }
+
+ hook('decanonicalize', createNormalizeSync);
+ hook('normalizeSync', createNormalizeSync);
+
+ hook('normalize', function(normalize) {
+ return function(name, parentName, isPlugin) {
+ var loader = this;
+
+ parentName = getParentName(this, parentName);
+
+ var parsed = parsePlugin(loader, name);
+
+ if (!parsed)
+ return normalize.call(loader, name, parentName, isPlugin);
+
+ return Promise.all([
+ loader.normalize(parsed.argument, parentName, true),
+ loader.normalize(parsed.plugin, parentName, false)
+ ])
+ .then(function(normalized) {
+ return combinePluginParts(loader, normalized[0], normalized[1], checkDefaultExtension(loader, parsed.argument));
+ });
+ }
+ });
+
+ hook('locate', function(locate) {
+ return function(load) {
+ var loader = this;
+
+ var name = load.name;
+
+ // plugin syntax
+ var pluginSyntaxIndex;
+ if (loader.pluginFirst) {
+ if ((pluginSyntaxIndex = name.indexOf('!')) != -1) {
+ load.metadata.loader = name.substr(0, pluginSyntaxIndex);
+ load.name = name.substr(pluginSyntaxIndex + 1);
+ }
+ }
+ else {
+ if ((pluginSyntaxIndex = name.lastIndexOf('!')) != -1) {
+ load.metadata.loader = name.substr(pluginSyntaxIndex + 1);
+ load.name = name.substr(0, pluginSyntaxIndex);
+ }
+ }
+
+ return locate.call(loader, load)
+ .then(function(address) {
+ if (pluginSyntaxIndex != -1 || !load.metadata.loader)
+ return address;
+
+ // normalize plugin relative to parent in locate here when
+ // using plugin via loader metadata
+ return (loader.pluginLoader || loader).normalize(load.metadata.loader, load.name)
+ .then(function(loaderNormalized) {
+ load.metadata.loader = loaderNormalized;
+ return address;
+ });
+ })
+ .then(function(address) {
+ var plugin = load.metadata.loader;
+
+ if (!plugin)
+ return address;
+
+ // don't allow a plugin to load itself
+ if (load.name == plugin)
+ throw new Error('Plugin ' + plugin + ' cannot load itself, make sure it is excluded from any wildcard meta configuration via a custom loader: false rule.');
+
+ // only fetch the plugin itself if this name isn't defined
+ if (loader.defined && loader.defined[name])
+ return address;
+
+ var pluginLoader = loader.pluginLoader || loader;
+
+ // load the plugin module and run standard locate
+ return pluginLoader['import'](plugin)
+ .then(function(loaderModule) {
+ // store the plugin module itself on the metadata
+ load.metadata.loaderModule = loaderModule;
+
+ load.address = address;
+ if (loaderModule.locate)
+ return loaderModule.locate.call(loader, load);
+
+ return address;
+ });
+ });
+ };
+ });
+
+ hook('fetch', function(fetch) {
+ return function(load) {
+ var loader = this;
+ if (load.metadata.loaderModule && load.metadata.loaderModule.fetch && load.metadata.format != 'defined') {
+ load.metadata.scriptLoad = false;
+ return load.metadata.loaderModule.fetch.call(loader, load, function(load) {
+ return fetch.call(loader, load);
+ });
+ }
+ else {
+ return fetch.call(loader, load);
+ }
+ };
+ });
+
+ hook('translate', function(translate) {
+ return function(load) {
+ var loader = this;
+ var args = arguments;
+ if (load.metadata.loaderModule && load.metadata.loaderModule.translate && load.metadata.format != 'defined') {
+ return Promise.resolve(load.metadata.loaderModule.translate.apply(loader, args)).then(function(result) {
+ var sourceMap = load.metadata.sourceMap;
+
+ // sanitize sourceMap if an object not a JSON string
+ if (sourceMap) {
+ if (typeof sourceMap != 'object')
+ throw new Error('load.metadata.sourceMap must be set to an object.');
+
+ var originalName = load.address.split('!')[0];
+
+ // force set the filename of the original file
+ if (!sourceMap.file || sourceMap.file == load.address)
+ sourceMap.file = originalName + '!transpiled';
+
+ // force set the sources list if only one source
+ if (!sourceMap.sources || sourceMap.sources.length <= 1 && (!sourceMap.sources[0] || sourceMap.sources[0] == load.address))
+ sourceMap.sources = [originalName];
+ }
+
+ // if running on file:/// URLs, sourcesContent is necessary
+ // load.metadata.sourceMap.sourcesContent = [load.source];
+
+ if (typeof result == 'string')
+ load.source = result;
+ else
+ warn.call(this, 'Plugin ' + load.metadata.loader + ' should return the source in translate, instead of setting load.source directly. This support will be deprecated.');
+
+ return translate.apply(loader, args);
+ });
+ }
+ else {
+ return translate.apply(loader, args);
+ }
+ };
+ });
+
+ hook('instantiate', function(instantiate) {
+ return function(load) {
+ var loader = this;
+ var calledInstantiate = false;
+
+ if (load.metadata.loaderModule && load.metadata.loaderModule.instantiate && !loader.builder && load.metadata.format != 'defined')
+ return Promise.resolve(load.metadata.loaderModule.instantiate.call(loader, load, function(load) {
+ if (calledInstantiate)
+ throw new Error('Instantiate must only be called once.');
+ calledInstantiate = true;
+ return instantiate.call(loader, load);
+ })).then(function(result) {
+ if (calledInstantiate)
+ return result;
+
+ load.metadata.entry = createEntry();
+ load.metadata.entry.execute = function() {
+ return result;
+ }
+ load.metadata.entry.deps = load.metadata.deps;
+ load.metadata.format = 'defined';
+ return instantiate.call(loader, load);
+ });
+ else
+ return instantiate.call(loader, load);
+ };
+ });
+
+})();/*
+ * Conditions Extension
+ *
+ * Allows a condition module to alter the resolution of an import via syntax:
+ *
+ * import $ from 'jquery/#{browser}';
+ *
+ * Will first load the module 'browser' via `SystemJS.import('browser')` and
+ * take the default export of that module.
+ * If the default export is not a string, an error is thrown.
+ *
+ * We then substitute the string into the require to get the conditional resolution
+ * enabling environment-specific variations like:
+ *
+ * import $ from 'jquery/ie'
+ * import $ from 'jquery/firefox'
+ * import $ from 'jquery/chrome'
+ * import $ from 'jquery/safari'
+ *
+ * It can be useful for a condition module to define multiple conditions.
+ * This can be done via the `|` modifier to specify an export member expression:
+ *
+ * import 'jquery/#{./browser.js|grade.version}'
+ *
+ * Where the `grade` export `version` member in the `browser.js` module is substituted.
+ *
+ *
+ * Boolean Conditionals
+ *
+ * For polyfill modules, that are used as imports but have no module value,
+ * a binary conditional allows a module not to be loaded at all if not needed:
+ *
+ * import 'es5-shim#?./conditions.js|needs-es5shim'
+ *
+ * These conditions can also be negated via:
+ *
+ * import 'es5-shim#?./conditions.js|~es6'
+ *
+ */
+
+ var sysConditions = ['browser', 'node', 'dev', 'build', 'production', 'default'];
+
+ function parseCondition(condition) {
+ var conditionExport, conditionModule, negation;
+
+ var negation = condition[0] == '~';
+ var conditionExportIndex = condition.lastIndexOf('|');
+ if (conditionExportIndex != -1) {
+ conditionExport = condition.substr(conditionExportIndex + 1);
+ conditionModule = condition.substr(negation, conditionExportIndex - negation);
+
+ if (negation)
+ warn.call(this, 'Condition negation form "' + condition + '" is deprecated for "' + conditionModule + '|~' + conditionExport + '"');
+
+ if (conditionExport[0] == '~') {
+ negation = true;
+ conditionExport = conditionExport.substr(1);
+ }
+ }
+ else {
+ conditionExport = 'default';
+ conditionModule = condition.substr(negation);
+ if (sysConditions.indexOf(conditionModule) != -1) {
+ conditionExport = conditionModule;
+ conditionModule = null;
+ }
+ }
+
+ return {
+ module: conditionModule || '@system-env',
+ prop: conditionExport,
+ negate: negation
+ };
+ }
+
+ function serializeCondition(conditionObj) {
+ return conditionObj.module + '|' + (conditionObj.negate ? '~' : '') + conditionObj.prop;
+ }
+
+ function resolveCondition(conditionObj, parentName, bool) {
+ var self = this;
+ return this.normalize(conditionObj.module, parentName)
+ .then(function(normalizedCondition) {
+ return self.load(normalizedCondition)
+ .then(function(q) {
+ var m = readMemberExpression(conditionObj.prop, self.get(normalizedCondition));
+
+ if (bool && typeof m != 'boolean')
+ throw new TypeError('Condition ' + serializeCondition(conditionObj) + ' did not resolve to a boolean.');
+
+ return conditionObj.negate ? !m : m;
+ });
+ });
+ }
+
+ var interpolationRegEx = /#\{[^\}]+\}/;
+ function interpolateConditional(name, parentName) {
+ // first we normalize the conditional
+ var conditionalMatch = name.match(interpolationRegEx);
+
+ if (!conditionalMatch)
+ return Promise.resolve(name);
+
+ var conditionObj = parseCondition.call(this, conditionalMatch[0].substr(2, conditionalMatch[0].length - 3));
+
+ // in builds, return normalized conditional
+ if (this.builder)
+ return this['normalize'](conditionObj.module, parentName)
+ .then(function(conditionModule) {
+ conditionObj.module = conditionModule;
+ return name.replace(interpolationRegEx, '#{' + serializeCondition(conditionObj) + '}');
+ });
+
+ return resolveCondition.call(this, conditionObj, parentName, false)
+ .then(function(conditionValue) {
+ if (typeof conditionValue !== 'string')
+ throw new TypeError('The condition value for ' + name + ' doesn\'t resolve to a string.');
+
+ if (conditionValue.indexOf('/') != -1)
+ throw new TypeError('Unabled to interpolate conditional ' + name + (parentName ? ' in ' + parentName : '') + '\n\tThe condition value ' + conditionValue + ' cannot contain a "/" separator.');
+
+ return name.replace(interpolationRegEx, conditionValue);
+ });
+ }
+
+ function booleanConditional(name, parentName) {
+ // first we normalize the conditional
+ var booleanIndex = name.lastIndexOf('#?');
+
+ if (booleanIndex == -1)
+ return Promise.resolve(name);
+
+ var conditionObj = parseCondition.call(this, name.substr(booleanIndex + 2));
+
+ // in builds, return normalized conditional
+ if (this.builder)
+ return this['normalize'](conditionObj.module, parentName)
+ .then(function(conditionModule) {
+ conditionObj.module = conditionModule;
+ return name.substr(0, booleanIndex) + '#?' + serializeCondition(conditionObj);
+ });
+
+ return resolveCondition.call(this, conditionObj, parentName, true)
+ .then(function(conditionValue) {
+ return conditionValue ? name.substr(0, booleanIndex) : '@empty';
+ });
+ }
+
+ // normalizeSync does not parse conditionals at all although it could
+ hook('normalize', function(normalize) {
+ return function(name, parentName, skipExt) {
+ var loader = this;
+ return booleanConditional.call(loader, name, parentName)
+ .then(function(name) {
+ return normalize.call(loader, name, parentName, skipExt);
+ })
+ .then(function(normalized) {
+ return interpolateConditional.call(loader, normalized, parentName);
+ });
+ };
+ });
+/*
+ * Alias Extension
+ *
+ * Allows a module to be a plain copy of another module by module name
+ *
+ * SystemJS.meta['mybootstrapalias'] = { alias: 'bootstrap' };
+ *
+ */
+(function() {
+ // aliases
+ hook('fetch', function(fetch) {
+ return function(load) {
+ var alias = load.metadata.alias;
+ var aliasDeps = load.metadata.deps || [];
+ if (alias) {
+ load.metadata.format = 'defined';
+ var entry = createEntry();
+ this.defined[load.name] = entry;
+ entry.declarative = true;
+ entry.deps = aliasDeps.concat([alias]);
+ entry.declare = function(_export) {
+ return {
+ setters: [function(module) {
+ for (var p in module)
+ _export(p, module[p]);
+ if (module.__useDefault)
+ entry.module.exports.__useDefault = true;
+ }],
+ execute: function() {}
+ };
+ };
+ return '';
+ }
+
+ return fetch.call(this, load);
+ };
+ });
+})();/*
+ * Meta Extension
+ *
+ * Sets default metadata on a load record (load.metadata) from
+ * loader.metadata via SystemJS.meta function.
+ *
+ *
+ * Also provides an inline meta syntax for module meta in source.
+ *
+ * Eg:
+ *
+ * loader.meta({
+ * 'my/module': { deps: ['jquery'] }
+ * 'my/*': { format: 'amd' }
+ * });
+ *
+ * Which in turn populates loader.metadata.
+ *
+ * load.metadata.deps and load.metadata.format will then be set
+ * for 'my/module'
+ *
+ * The same meta could be set with a my/module.js file containing:
+ *
+ * my/module.js
+ * "format amd";
+ * "deps[] jquery";
+ * "globals.some value"
+ * console.log('this is my/module');
+ *
+ * Configuration meta always takes preference to inline meta.
+ *
+ * Multiple matches in wildcards are supported and ammend the meta.
+ *
+ *
+ * The benefits of the function form is that paths are URL-normalized
+ * supporting say
+ *
+ * loader.meta({ './app': { format: 'cjs' } });
+ *
+ * Instead of needing to set against the absolute URL (https://site.com/app.js)
+ *
+ */
+
+(function() {
+
+ hookConstructor(function(constructor) {
+ return function() {
+ this.meta = {};
+ constructor.call(this);
+ };
+ });
+
+ hook('locate', function(locate) {
+ return function(load) {
+ var meta = this.meta;
+ var name = load.name;
+
+ // NB for perf, maybe introduce a fast-path wildcard lookup cache here
+ // which is checked first
+
+ // apply wildcard metas
+ var bestDepth = 0;
+ var wildcardIndex;
+ for (var module in meta) {
+ wildcardIndex = module.indexOf('*');
+ if (wildcardIndex === -1)
+ continue;
+ if (module.substr(0, wildcardIndex) === name.substr(0, wildcardIndex)
+ && module.substr(wildcardIndex + 1) === name.substr(name.length - module.length + wildcardIndex + 1)) {
+ var depth = module.split('/').length;
+ if (depth > bestDepth)
+ bestDepth = depth;
+ extendMeta(load.metadata, meta[module], bestDepth != depth);
+ }
+ }
+
+ // apply exact meta
+ if (meta[name])
+ extendMeta(load.metadata, meta[name]);
+
+ return locate.call(this, load);
+ };
+ });
+
+ // detect any meta header syntax
+ // only set if not already set
+ var metaRegEx = /^(\s*\/\*[^\*]*(\*(?!\/)[^\*]*)*\*\/|\s*\/\/[^\n]*|\s*"[^"]+"\s*;?|\s*'[^']+'\s*;?)+/;
+ var metaPartRegEx = /\/\*[^\*]*(\*(?!\/)[^\*]*)*\*\/|\/\/[^\n]*|"[^"]+"\s*;?|'[^']+'\s*;?/g;
+
+ function setMetaProperty(target, p, value) {
+ var pParts = p.split('.');
+ var curPart;
+ while (pParts.length > 1) {
+ curPart = pParts.shift();
+ target = target[curPart] = target[curPart] || {};
+ }
+ curPart = pParts.shift();
+ if (!(curPart in target))
+ target[curPart] = value;
+ }
+
+ hook('translate', function(translate) {
+ return function(load) {
+ // shortpath for bundled
+ if (load.metadata.format == 'defined') {
+ load.metadata.deps = load.metadata.deps || [];
+ return Promise.resolve(load.source);
+ }
+
+ // NB meta will be post-translate pending transpiler conversion to plugins
+ var meta = load.source.match(metaRegEx);
+ if (meta) {
+ var metaParts = meta[0].match(metaPartRegEx);
+
+ for (var i = 0; i < metaParts.length; i++) {
+ var curPart = metaParts[i];
+ var len = curPart.length;
+
+ var firstChar = curPart.substr(0, 1);
+ if (curPart.substr(len - 1, 1) == ';')
+ len--;
+
+ if (firstChar != '"' && firstChar != "'")
+ continue;
+
+ var metaString = curPart.substr(1, curPart.length - 3);
+ var metaName = metaString.substr(0, metaString.indexOf(' '));
+
+ if (metaName) {
+ var metaValue = metaString.substr(metaName.length + 1, metaString.length - metaName.length - 1);
+
+ if (metaName.substr(metaName.length - 2, 2) == '[]') {
+ metaName = metaName.substr(0, metaName.length - 2);
+ load.metadata[metaName] = load.metadata[metaName] || [];
+ load.metadata[metaName].push(metaValue);
+ }
+ else if (load.metadata[metaName] instanceof Array) {
+ // temporary backwards compat for previous "deps" syntax
+ warn.call(this, 'Module ' + load.name + ' contains deprecated "deps ' + metaValue + '" meta syntax.\nThis should be updated to "deps[] ' + metaValue + '" for pushing to array meta.');
+ load.metadata[metaName].push(metaValue);
+ }
+ else {
+ setMetaProperty(load.metadata, metaName, metaValue);
+ }
+ }
+ else {
+ load.metadata[metaString] = true;
+ }
+ }
+ }
+
+ return translate.apply(this, arguments);
+ };
+ });
+})();
+/*
+ System bundles
+
+ Allows a bundle module to be specified which will be dynamically
+ loaded before trying to load a given module.
+
+ For example:
+ SystemJS.bundles['mybundle'] = ['jquery', 'bootstrap/js/bootstrap']
+
+ Will result in a load to "mybundle" whenever a load to "jquery"
+ or "bootstrap/js/bootstrap" is made.
+
+ In this way, the bundle becomes the request that provides the module
+*/
+
+(function() {
+ // bundles support (just like RequireJS)
+ // bundle name is module name of bundle itself
+ // bundle is array of modules defined by the bundle
+ // when a module in the bundle is requested, the bundle is loaded instead
+ // of the form SystemJS.bundles['mybundle'] = ['jquery', 'bootstrap/js/bootstrap']
+ hookConstructor(function(constructor) {
+ return function() {
+ constructor.call(this);
+ this.bundles = {};
+ this._loader.loadedBundles = {};
+ };
+ });
+
+ // assign bundle metadata for bundle loads
+ hook('locate', function(locate) {
+ return function(load) {
+ var loader = this;
+ var matched = false;
+
+ if (!(load.name in loader.defined))
+ for (var b in loader.bundles) {
+ for (var i = 0; i < loader.bundles[b].length; i++) {
+ var curModule = loader.bundles[b][i];
+
+ if (curModule == load.name) {
+ matched = true;
+ break;
+ }
+
+ // wildcard in bundles does not include / boundaries
+ if (curModule.indexOf('*') != -1) {
+ var parts = curModule.split('*');
+ if (parts.length != 2) {
+ loader.bundles[b].splice(i--, 1);
+ continue;
+ }
+
+ if (load.name.substring(0, parts[0].length) == parts[0] &&
+ load.name.substr(load.name.length - parts[1].length, parts[1].length) == parts[1] &&
+ load.name.substr(parts[0].length, load.name.length - parts[1].length - parts[0].length).indexOf('/') == -1) {
+ matched = true;
+ break;
+ }
+ }
+ }
+
+ if (matched)
+ return loader['import'](b)
+ .then(function() {
+ return locate.call(loader, load);
+ });
+ }
+
+ return locate.call(loader, load);
+ };
+ });
+})();
+/*
+ * Dependency Tree Cache
+ *
+ * Allows a build to pre-populate a dependency trace tree on the loader of
+ * the expected dependency tree, to be loaded upfront when requesting the
+ * module, avoinding the n round trips latency of module loading, where
+ * n is the dependency tree depth.
+ *
+ * eg:
+ * SystemJS.depCache = {
+ * 'app': ['normalized', 'deps'],
+ * 'normalized': ['another'],
+ * 'deps': ['tree']
+ * };
+ *
+ * SystemJS.import('app')
+ * // simultaneously starts loading all of:
+ * // 'normalized', 'deps', 'another', 'tree'
+ * // before "app" source is even loaded
+ *
+ */
+
+(function() {
+ hookConstructor(function(constructor) {
+ return function() {
+ constructor.call(this);
+ this.depCache = {};
+ }
+ });
+
+ hook('locate', function(locate) {
+ return function(load) {
+ var loader = this;
+ // load direct deps, in turn will pick up their trace trees
+ var deps = loader.depCache[load.name];
+ if (deps)
+ for (var i = 0; i < deps.length; i++)
+ loader['import'](deps[i], load.name);
+
+ return locate.call(loader, load);
+ };
+ });
+})();
+
+System = new SystemJSLoader();
+
+__global.SystemJS = System;
+System.version = '0.19.39 Standard';
+ if (typeof module == 'object' && module.exports && typeof exports == 'object')
+ module.exports = System;
+
+ __global.System = System;
+
+})(typeof self != 'undefined' ? self : global);}
+
+// auto-load Promise polyfill if needed in the browser
+var doPolyfill = typeof Promise === 'undefined';
+
+// document.write
+if (typeof document !== 'undefined') {
+ var scripts = document.getElementsByTagName('script');
+ $__curScript = scripts[scripts.length - 1];
+ if (document.currentScript && ($__curScript.defer || $__curScript.async))
+ $__curScript = document.currentScript;
+ if (doPolyfill) {
+ var curPath = $__curScript.src;
+ var basePath = curPath.substr(0, curPath.lastIndexOf('/') + 1);
+ window.systemJSBootstrap = bootstrap;
+ document.write(
+ '<' + 'script type="text/javascript" src="' + basePath + 'system-polyfills.js">' + '<' + '/script>'
+ );
+ }
+ else {
+ bootstrap();
+ }
+}
+// importScripts
+else if (typeof importScripts !== 'undefined') {
+ var basePath = '';
+ try {
+ throw new Error('_');
+ } catch (e) {
+ e.stack.replace(/(?:at|@).*(http.+):[\d]+:[\d]+/, function(m, url) {
+ $__curScript = { src: url };
+ basePath = url.replace(/\/[^\/]*$/, '/');
+ });
+ }
+ if (doPolyfill)
+ importScripts(basePath + 'system-polyfills.js');
+ bootstrap();
+}
+else {
+ $__curScript = typeof __filename != 'undefined' ? { src: __filename } : null;
+ bootstrap();
+}
+
+
+})(); \ No newline at end of file
diff --git a/docs/config-api.md b/docs/config-api.md
new file mode 100644
index 000000000..6ef4c6b92
--- /dev/null
+++ b/docs/config-api.md
@@ -0,0 +1,292 @@
+## Configuration API
+
+### Setting Configuration
+
+Once SystemJS has loaded, configuration can be set on SystemJS by using the configuration function `System.config`:
+
+```javascript
+System.config({
+ configA: {},
+ configB: 'value'
+});
+```
+
+This is a helper function which normalizes configuration and sets configuration properties on the SystemJS instance.
+
+`System.config({ prop: 'value' })` is mostly equivalent to `System.prop = value` except that it will extend configuration objects,
+and certain properties will be normalized to be stored correctly.
+
+For this reason it is usually advisable to use `System.config` instead of setting instance properties directly.
+
+### Configuration Options
+
+* [babelOptions](#babeloptions)
+* [bundle](#bundle)
+* [defaultJSExtensions](#defaultjsextensions)
+* [depCache](#depcache)
+* [map](#map)
+* [meta](#meta)
+* [packages](#packages)
+* [paths](#paths)
+* [traceurOptions](#traceuroptions)
+* [transpiler](#transpiler)
+* [typescriptOptions](#typescriptoptions)
+
+#### babelOptions
+Type: `Object`
+Default: `{}`
+
+Set the Babel transpiler options when [System.transpiler](#transpiler) is set to `babel`:
+
+```javascript
+System.config({
+ babelOptions: {
+ stage: 1
+ }
+});
+```
+
+A list of options is available in the [Babel project documentation](https://babeljs.io/docs/usage/options/).
+
+#### bundle
+Type: `Object`
+
+Bundles allow a collection of modules to be downloaded together as a package whenever any module from that collection is requested.
+Useful for splitting an application into sub-modules for production. Use with the [SystemJS Builder](https://github.com/systemjs/builder).
+
+```javascript
+System.config({
+ bundles: {
+ bundleA: ['dependencyA', 'dependencyB']
+ }
+});
+```
+
+In the above any require to `dependencyA` or `dependencyB` will first trigger a `System.import('bundleA')` before proceeding with the load of `dependencyA` or `dependencyB`.
+
+It is an alternative to including a script tag for a bundle in the page, useful for bundles that load dynamically where we want to trigger the bundle load automatically only when needed.
+
+The bundle itself is a module which contains named System.register and define calls as an output of the builder. The dependency names the bundles config lists should be the same names that are explicitly defined in the bundle.
+
+#### defaultJSExtensions
+
+Backwards-compatibility mode for the loader to automatically add '.js' extensions when not present to module requests.
+
+This allows code written for SystemJS 0.16 or less to work easily in the latest version:
+
+```javascript
+System.defaultJSExtensions = true;
+
+// requests ./some/module.js instead
+System.import('./some/module');
+```
+
+Note that this is a compatibility property for transitioning to using explicit extensions and will be deprecated in future.
+
+#### depCache
+Type: `Object`
+
+An alternative to bundling providing a solution to the latency issue of progressively loading dependencies.
+When a module specified in depCache is loaded, asynchronous loading of its pre-cached dependency list begins in parallel.
+
+```javascript
+System.config({
+ depCache: {
+ moduleA: ['moduleB'], // moduleA depends on moduleB
+ moduleB: ['moduleC'] // moduleB depends on moduleC
+ }
+});
+
+// when we do this import, depCache knows we also need moduleB and moduleC,
+// it then directly requests those modules as well as soon as we request moduleA
+System.import('moduleA')
+```
+
+Over HTTP/2 this approach may be preferable as it allows files to be individually cached in the browser meaning bundle optimizations are no longer a concern.
+
+#### map
+Type: `Object`
+
+The map option is similar to paths, but acts very early in the normalization process. It allows you to map a module alias to a
+location or package:
+
+```javascript
+System.config({
+ map: {
+ jquery: '//code.jquery.com/jquery-2.1.4.min.js'
+ }
+});
+```
+
+```javascript
+import $ from 'jquery';
+
+```
+
+In addition, a map also applies to any subpaths, making it suitable for package folders as well:
+
+```javascript
+System.config({
+ map: {
+ package: 'local/package'
+ }
+});
+```
+
+```javascript
+// loads /local/package/path.js
+System.import('package/path.js');
+```
+
+> Note map configuration used to support contextual submaps but this has been deprecated for package configuration.
+
+#### meta
+Type: `Object`
+Default: `{}`
+
+Module meta provides an API for SystemJS to understand how to load modules correctly.
+
+Meta is how we set the module format of a module, or know how to shim dependencies of a global script.
+
+```javascript
+System.config({
+ meta: {
+ // meaning [baseURL]/vendor/angular.js when no other rules are present
+ // path is normalized using map and paths configuration
+ 'vendor/angular.js': {
+ format: 'global', // load this module as a global
+ exports: 'angular', // the global property to take as the module value
+ deps: [
+ // dependencies to load before this module
+ 'jquery'
+ ]
+ }
+ }
+});
+```
+
+Wildcard meta is also supported and is additive from least to most specific match:
+
+```javascript
+System.config({
+ meta: {
+ '/vendor/*': { format: 'global' }
+ }
+});
+```
+
+* [`format`](module-formats.md):
+ Sets in what format the module is loaded.
+* [`exports`](module-formats.md#exports):
+ For the `global` format, when automatic detection of exports is not enough, a custom exports meta value can be set.
+ This tells the loader what global name to use as the module's export value.
+* [`deps`](module-formats.md#shim-dependencies):
+ Dependencies to load before this module. Goes through regular paths and map normalization. Only supported for the `cjs`, `amd` and `global` formats.
+* [`globals`](module-formats.md#custom-globals):
+ A map of global names to module names that should be defined only for the execution of this module.
+ Enables use of legacy code that expects certain globals to be present.
+ Referenced modules automatically becomes dependencies. Only supported for the `cjs` and `global` formats.
+* [`loader`](overview.md#plugin-loaders):
+ Set a loader for this meta path.
+* [`sourceMap`](creating-plugins.md):
+ For plugin transpilers to set the source map of their transpilation.
+* `scriptLoad`: Set to `true` to load the module using `<script>` tag injection (`importScript()` in a worker context) instead of using `fetch` and `eval`. This enables [CSP](https://www.w3.org/TR/CSP2/) support but disables the native loading of CommonJS modules and global modules where the export name is not declared via metadata.
+* `nonce`: The [nonce](https://www.w3.org/TR/CSP2/#script-src-the-nonce-attribute) attribute to use when loading the script as a way to enable CSP.
+ This should correspond to the "nonce-" attribute set in the Content-Security-Policy header.
+* `integrity`: The [subresource integrity](http://www.w3.org/TR/SRI/#the-integrity-attribute) attribute corresponding to the script integrity, describing the expected hash of the final code to be executed.
+ For example, `System.config({ meta: { 'src/example.js': { integrity: 'sha256-e3b0c44...' }});` would throw an error if the translated source of `src/example.js` doesn't match the expected hash.
+* `crossOrigin`: When scripts are loaded from a different domain (e.g. CDN) the global error handler (`window.onerror`)
+ has very limited information about errors to [prevent unintended leaking]
+ (https://developer.mozilla.org/en/docs/Web/API/GlobalEventHandlers/onerror#Notes).
+ In order to mitigate this, the `<script>` tags need to set [`crossorigin` attribute]
+ (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script#attr-crossorigin) and the server needs to
+ [enable CORS](http://enable-cors.org/).
+ The [valid values](https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes) are
+ `"anonymous"` and `"use-credentials"`.
+* `esmExports`: When loading a module that is not an ECMAScript Module, we set the module as the `default` export, but then also
+ iterate the module object and copy named exports for it a well. Use this option to disable this iteration and copying of the exports.
+
+#### packages
+Type: `Object`
+Default: `{}`
+
+Packages provide a convenience for setting meta and map configuration that is specific to a common path.
+
+In addition packages allow for setting contextual map configuration which only applies within the package itself.
+This allows for full dependency encapsulation without always needing to have all dependencies in a global namespace.
+
+```javascript
+System.config({
+ packages: {
+ // meaning [baseURL]/local/package when no other rules are present
+ // path is normalized using map and paths configuration
+ 'local/package': {
+ main: 'index.js',
+ format: 'cjs',
+ defaultExtension: 'js',
+ map: {
+ // use local jquery for all jquery requires in this package
+ 'jquery': './vendor/local-jquery.js',
+
+ // import '/local/package/custom-import' should route to '/local/package/local/import/file.js'
+ './custom-import': './local/import/file.js'
+ },
+ meta: {
+ // sets meta for modules within the package
+ 'vendor/*': {
+ 'format': 'global'
+ }
+ }
+ }
+ }
+});
+```
+
+* `main`: The main entry point of the package (so `import 'local/package'` is equivalent to `import 'local/package/index.js'`)
+* `format`: The module format of the package. See [Module Formats](https://github.com/systemjs/systemjs/blob/master/docs/module-formats.md).
+* `defaultExtension`: The default extension to add to modules requested within the package.
+ Takes preference over defaultJSExtensions.
+ Can be set to `defaultExtension: false` to optionally opt-out of extension-adding when `defaultJSExtensions` is enabled.
+* `map`: Local and relative map configurations scoped to the package. Apply for subpaths as well.
+* `meta`: Package-scoped meta configuration with wildcard support. Modules are subpaths within the package path.
+ This also provides an opt-out mechanism for `defaultExtension`, by adding modules here that should skip extension adding.
+
+#### paths
+Type: `Object`
+
+The [ES6 Module Loader](https://github.com/systemjs/systemjs/blob/master/docs/es6-modules-overview.md) paths implementation, applied after normalization and supporting subpaths via wildcards.
+
+_It is usually advisable to use map configuration over paths unless you need strict control over normalized module names._
+
+#### traceurOptions
+Type: `Object`
+Default: `{}`
+
+Set the Traceur compilation options.
+
+```javascript
+System.config({
+ traceurOptions: {
+ }
+});
+```
+
+A list of options is available in the [Traceur project documentation](https://github.com/google/traceur-compiler/wiki/Options-for-Compiling).
+
+#### transpiler
+Type: `String`
+Default: `traceur`
+
+Sets the module name of the transpiler to be used for loading ES6 modules.
+
+Represents a module name for `System.import` that must resolve to either Traceur, Babel or TypeScript.
+
+When set to `traceur`, `babel` or `typescript`, loading will be automatically configured as far as possible.
+
+#### typescriptOptions
+Type: `Object`
+Default: `{}`
+
+Sets the TypeScript transpiler options.
+
+A list of options is available in the [TypeScript project documentation](https://www.typescriptlang.org/docs/handbook/compiler-options.html).
diff --git a/docs/creating-plugins.md b/docs/creating-plugins.md
new file mode 100644
index 000000000..531ece163
--- /dev/null
+++ b/docs/creating-plugins.md
@@ -0,0 +1,84 @@
+### Creating a Plugin
+
+A plugin is just a set of overrides for the loader hooks of the ES6 module specification.
+
+The hooks plugins can override are `locate`, `fetch`, `translate` and `instantiate`.
+
+Read more about loader extensions and hooks at the [ES6 Module Loader polyfill wiki](https://github.com/ModuleLoader/es6-module-loader/blob/v0.17.0/docs/loader-extensions.md).
+
+The behaviors of the hooks are:
+
+* Locate: Overrides the location of the plugin resource
+* Fetch: Called with third argument representing default fetch function, has full control of fetch output.
+* Translate: Returns the translated source from `load.source`, can also set `load.metadata.sourceMap` for full source maps support.
+* Instantiate: Providing this hook as a promise or function allows the plugin to hook instantiate. Any return value becomes the defined custom module object for the plugin call.
+
+### Building Plugins
+
+When building via [SystemJS Builder](https://github.com/systemjs/builder), plugins that use the translate hook will be inlined into the bundle automatically.
+
+In this way, the bundle file becomes independent of the plugin loader and resource.
+
+If it is desired for the plugin itself not to be inlined into the bundle in this way, setting `exports.build = false` on the plugin will disable this,
+causing the plugin loader itself to be bundled in production instead to continue to dynamically load the resource.
+
+#### Sample CoffeeScript Plugin
+
+For example, we can write a CoffeeScript plugin with the following (CommonJS as an example, any module format works fine):
+
+js/coffee.js:
+```javascript
+ var CoffeeScript = require('coffeescript');
+
+ exports.translate = function(load) {
+ // optionally also set the sourceMap to support both builds and in-browser transpilation
+ // load.metadata.sourceMap = generatedSourceMap;
+ return CoffeeScript.compile(load.source);
+ }
+```
+
+By overriding the `translate` hook, we now support CoffeeScript loading with:
+
+```
+ - js/
+ - coffee.js our plugin above
+ - coffeescript.js the CoffeeScript compiler
+ - app/
+ - main.coffee
+```
+
+```javascript
+ System.import('app/main.coffee!').then(function(main) {
+ // main is now loaded from CoffeeScript
+ });
+```
+
+Source maps can also be passed by setting `load.metadata.sourceMap`.
+
+#### Sample CSS Plugin
+
+A CSS plugin, on the other hand, could override the fetch hook:
+
+js/css.js:
+```javascript
+ exports.fetch = function(load, fetch) {
+ return new Promise(function(resolve, reject) {
+ var cssFile = load.address;
+
+ var link = document.createElement('link');
+ link.rel = 'stylesheet';
+ link.href = cssFile;
+ link.onload = resolve;
+
+ document.head.appendChild(link);
+ })
+ .then(function() {
+ // return an empty module in the module pipeline itself
+ return '';
+ });
+ }
+```
+
+Each loader hook can either return directly or return a promise for the value.
+
+The other loader hooks are also treated otherwise identically to the specification.
diff --git a/docs/es6-modules-overview.md b/docs/es6-modules-overview.md
new file mode 100644
index 000000000..82f127548
--- /dev/null
+++ b/docs/es6-modules-overview.md
@@ -0,0 +1,108 @@
+## Background
+
+### Modules and Module Loaders
+
+A module is simply a JavaScript file written with module syntax. Modules _export_ values, which can then be _imported_ by other modules.
+
+[CommonJS](http://wiki.commonjs.org/wiki/CommonJS) and [AMD](https://github.com/amdjs/amdjs-api/wiki/AMD) JavaScript files are modules.
+
+A module loader provides the ability to dynamically load modules, and also keeps track of all loaded modules in a module registry.
+
+Typically, in production, the module registry would be populated by an initial compiled bundle of modules. Later in the page state, it may become necessary to dynamically
+load a new module. This module can then share dependencies with the initial page bundle without having to reload any dependencies.
+
+Module code is treated differently to scripts due to the nature of exports and imports.
+This is why the `<script type="module">` tag is introduced to distinguish script code from module code.
+
+### Module Naming
+
+Normalization rules allow module names to be converted into URLs.
+
+This allows module aliases like `import $ from 'jquery'` to be equivalent to writing `import $ from 'https://code.jquery.com/jquery.js'`
+
+Normalization rules are specific to the module loader implementation, with some certain standard conventions set down by the browser loader specification.
+
+## ES6 Module Syntax
+
+### Exporting
+
+ES6 module syntax is most similar to the `exports.method = function() {}` pattern in NodeJS of creating multiple named exports.
+
+In CommonJS one might write:
+
+```javascript
+ exports.someMethod = function() {
+
+ };
+
+ exports.another = {};
+```
+
+In ES6, this same code would be written:
+
+exporter.js:
+```javascript
+ export function someMethod() {
+
+ }
+
+ export var another = {};
+```
+
+Notice that the name of the function, class or variable gets used as the export name.
+
+### Importing
+
+When importing, we import any exports we need by name, and can also choose to rename them:
+
+importer.js:
+```javascript
+ import { someMethod, another as newName } from './exporter';
+
+ someMethod();
+ typeof newName == 'object';
+```
+
+### Default Import and Export
+
+Sometimes one doesn't want to write an import name at all. For this we can use the default export:
+
+export-default.js:
+```javascript
+ export default function foo() {
+ console.log('foo');
+ }
+```
+
+import-default.js:
+```javascript
+ import customName from './export-default';
+
+ customName(); // -> 'foo'
+```
+
+### All Supported Syntax
+
+There are a few other variations of module syntax, the full list of supported statements is listed below.
+
+```javascript
+import 'jquery'; // import a module without any import bindings
+import $ from 'jquery'; // import the default export of a module
+import { $ } from 'jquery'; // import a named export of a module
+import { $ as jQuery } from 'jquery'; // import a named export to a different name
+
+export var x = 42; // export a named variable
+export function foo() {}; // export a named function
+
+export default 42; // export the default export
+export default function foo() {}; // export the default export as a function
+
+export { encrypt }; // export an existing variable
+export { decrypt as dec }; // export a variable as a new name
+export { encrypt as en } from 'crypto'; // export an export from another module
+export * from 'crypto'; // export all exports from another module
+ // (except the default export)
+import * as crypto from 'crypto'; // import an entire module instance object
+```
+
+Note that any valid declaration can be exported. In ES6, this includes `class` (as in the example above), `const`, and `let`. \ No newline at end of file
diff --git a/docs/module-formats.md b/docs/module-formats.md
new file mode 100644
index 000000000..3bafda590
--- /dev/null
+++ b/docs/module-formats.md
@@ -0,0 +1,228 @@
+### Module Formats
+
+The following module formats are supported:
+
+* `esm`: ECMAScript Module (previously referred to as `es6`)
+* `cjs`: [CommonJS](#commonjs)
+* `amd`: [Asynchronous Module Definition](#amd)
+* `global`: [Global shim module format](#globals)
+* `register`: [System.register](system-api.md#systemregister-name-deps-declare) or [System.registerDynamic](system-api.md#systemregisterdynamic-name-deps-executingrequire-declare) compatibility module format
+
+The module format can be set via meta configuration:
+
+```javascript
+System.config({
+ meta: {
+ './module/path.js': {
+ format: 'esm'
+ }
+ }
+});
+```
+
+#### Module format detection
+
+When the module format is not set, automatic regular-expression-based detection is used.
+This module format detection is never completely accurate, but caters well for the majority use cases.
+
+The module format detection happens in the following order:
+* _System.register / System.registerDynamic_
+ If the source code starts with a number of comments, followed by `System.register` or `System.registerDynamic` as the first line of code.
+* _ES modules_
+ The source is only detected as an ES module if it contains explicit module syntax - valid `import` or `export` statements.
+* _AMD modules_
+ The presence of a valid AMD `define` statement in the code.
+* _CommonJS modules_
+ The presence of `require(...)` or `exports` / `module.exports` assigments
+* _Global_
+ This is the fallback module format after all the above fail.
+
+> Note that ES6 modules are detected via the presence of `import` and `export` module syntax and no other features at all. This is because the transpilation applies to the module format specifically, not the language.
+
+#### Inter-Format Dependencies
+
+Any module type can be loaded from any other type with full support thanks to [zebra-striping](https://github.com/ModuleLoader/es6-module-loader/blob/v0.17.0/docs/circular-references-bindings.md#zebra-striping).
+
+When loading CommonJS, AMD or Global modules from within ES6, the full module is available at the `default` export which can be loaded with the default import syntax.
+
+For convenience, named exports are also auto-populated but may not be correctly bound as expected, so use these carefully.
+
+./app/es6-loading-commonjs:
+```javascript
+// entire underscore instance
+import _ from './underscore.js';
+
+// unbound named export
+import {map} from './underscore.js';
+```
+
+### ES6
+
+ES6 modules are automatically transpiled as they are loaded, using the loader [transpiler option](config-api.md#transpiler) set.
+
+Circular references and bindings are implemented to the ES6 specification.
+
+The `__moduleName` local variable is also available, pending clarification of the module meta in the WhatWG loader spec.
+
+This provides the fully normalized name of the current module which can be useful for dynamically loading modules relative to the current module via:
+
+```javascript
+System.import('./local-module', __moduleName);
+```
+
+In due course this will be entirely replaced by the contextual loader once this has been specified.
+
+_ES6 is loaded via XHR making it non-[CSP](http://www.html5rocks.com/en/tutorials/security/content-security-policy/) compatible. ES6 should always be built for production to avoid transpiler costs, making this a development-only feature._
+
+### CommonJS
+
+* The `module`, `exports`, `require`, `global`, `__dirname` and `__filename` variables are all provided.
+* `module.id` is set.
+
+When executing CommonJS any global `define` is temporarily removed.
+
+For comprehensive handling of NodeJS modules, a conversion process is needed to make them SystemJS-compatible, such as the one used by jspm.
+
+_CommonJS is loaded via XHR making it non-[CSP](http://www.html5rocks.com/en/tutorials/security/content-security-policy/) compatible._
+
+Note that CommonJS modules on npm, loaded as CommonJS may well not load correctly through SystemJS. This is because SystemJS
+does not implement the NodeJS loading algorithm.
+
+If you want to load NodeJS modules through SystemJS you can use `import nodeModule from '@node/node-module-name'`, but this should only
+be used when absolutely necessary as it stops code from being universal, and makes it only compatible with NodeJS.
+
+### AMD
+
+* AMD support includes all AMD structural variations including the [CommonJS wrapper form](http://requirejs.org/docs/api.html#cjsmodule).
+* The special `module`, `exports`, and `require` module names are handled at the AMD format level and are not defined in the primary loader registry. `module.uri` and `module.id` are provided with `module.config` as a no-op.
+* Named defines are supported and will write directly into the loader registry.
+* A single named define will write into the loader registry but also be treated as the value of the module loaded if the names do not match. This enables loading a module containing `define('jquery', ...`.
+* Contextual dynamic requires are fully supported (`define(function(require) { require(['./dynamic/require'], callback) })`)
+
+When executing AMD, the global `module`, `exports` are temporarily removed, and the global `define` and `require` are set to the SystemJS AMD functions.
+
+_By default AMD modules are loaded via `<script>` tag injection making them [CSP](http://www.html5rocks.com/en/tutorials/security/content-security-policy/)-compatible, provided that modules that are AMD are indicated [via meta](#module-formats) so that SystemJS knows to skip format detection and load them with script tags._
+
+#### RequireJS Support
+
+To use SystemJS side-by-side in a RequireJS project, make sure to include RequireJS after ES6 Module Loader but before SystemJS.
+
+Conversely, to have SystemJS provide a RequireJS-like API in an application set:
+
+```javascript
+window.define = System.amdDefine;
+window.require = window.requirejs = System.amdRequire;
+```
+
+### Globals
+
+The `global` format loads globals identically to if they were included via `<script>` tags
+but with some extra features including the ability to [shim dependencies](#shim-dependencies),
+set [custom globals](#custom-globals), and [define the exports](#exports) of the global module.
+
+By default, the exports of a global are calculated as the diff of the environment global from before to after execution.
+
+This provides a convenient mechanism for auto-conversion of globals into modules.
+
+For example:
+
+```javascript
+var MyGlobal = 42;
+```
+
+Will get converted into the module `Module({ default: 42 })`.
+
+While the script:
+
+```javascript
+(function(global) {
+ global.globalA = 'global A';
+ global.globalB = 'global B';
+})(typeof self != 'undefined' ? self : global);
+```
+
+Will get converted into the module `Module({ globalA: 'global A', globalB: 'global B' })`
+
+Globals are picked up by variable assignment and undeclared assignment:
+
+```javascript
+var x = 'global'; // detected as a global
+y = 'global'; // detected as a global
+```
+
+These two cases fail in IE8 and WebWorkers, so do need to have their [exports explicitly declared](#exports) if compatibility is desired.
+
+> Globals are not removed from the global object for shim compatibility, but this could become possible in future if all globals
+use the [globals](#globals) meta for shims instead of [deps](#shim-dependencies).
+
+#### Shim Dependencies
+
+When loading plugins of globals like Angular or jQuery plugins, we always need to shim the dependencies of the plugin
+to be dependent on the global it expects to find.
+
+We do this via deps metadata on the module:
+
+```javascript
+System.config({
+ meta: {
+ 'vendor/angular-ui-router.js': {
+ deps: ['/vendor/angular.js']
+ }
+ }
+});
+System.import('vendor/angular-ui-router.js');
+```
+
+Note that deps is only supported for global modules.
+
+> It is always advisable to explicitly shim global modules as above for any globals they expect to be present.
+ For example, the above module may work fine without the shim if Angular always happens to load first in the page,
+ but this isn't always guaranteed, and problems will likely be hit later on when the load order happens to change.
+
+#### Custom Globals
+
+When shimming dependencies, the issue with this is that every dependency needs to be a global in order to be loadable by a global.
+
+This holds the entire ecosystem back as globals become the lowest common denominator.
+
+If we want to upgrade Angular to an ES6 version of Angular, while still supporting old Angular global modules, we can do this via custom globals:
+
+```javascript
+System.config({
+ meta: {
+ 'vendor/angular-ui-router.js': {
+ globals: {
+ angular: 'vendor/angular.js'
+ }
+ }
+ }
+});
+System.import('vendor/angular-ui-router.js');
+```
+
+In the above scenario, a globally scoped `angular` will be set to the module value for the Angular ES6 module only for the duration of execution of the global plugin. They will be reverted to whatever they where before after execution, if they didn't exist they're removed. This doesn't influence the globals that might already be generated by the referenced package.
+
+> **The globals meta-configuration option is only available for the `global` and `cjs` module formats.** as these are the only formats that are source-code-transformation based.
+
+Referenced packages automatically becomes dependencies.
+
+#### Exports
+
+When automatic detection of exports is not enough, a custom exports meta value can be set.
+
+This is a member expression on the global object to be taken as the exports of the module.
+
+For example, `angular` or `jQuery.fn.pluginName`.
+
+> Globals can be loaded in a way that is CSP-compatible by setting their `format` and `exports` metadata when not setting any `globals` metadata. SystemJS then knows it can use script tag injection for this case. For example, Google Analytics can be loaded without requiring CORS or CSP via setting:
+ ```javascript
+ System.config({
+ meta: {
+ 'https://www.google-analytics.com/analytics.js': {
+ exports: 'ga',
+ format: 'global'
+ }
+ }
+ });
+ ```
+
diff --git a/docs/overview.md b/docs/overview.md
new file mode 100644
index 000000000..a3899f297
--- /dev/null
+++ b/docs/overview.md
@@ -0,0 +1,166 @@
+### Loading Modules
+
+Any URL can be loaded as a module with standard URL syntax:
+
+```html
+<script src="system.js"></script>
+<script>
+ // loads relative to the current page URL
+ System.import('./local-module.js');
+
+ // load from an absolute URL directly
+ System.import('https://code.jquery.com/jquery.js');
+</script>
+```
+
+Any type of module format can be loaded and it will be detected automatically by SystemJS.
+
+##### File access from files
+
+> _Note that when running locally, ensure you are running from a local server or a browser with local XHR requests enabled. If not you will get an error message._
+
+> _For Chrome on Mac, you can run it with: `/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --allow-file-access-from-files &> /dev/null &`_
+
+> _In Firefox this requires navigating to `about:config`, entering `security.fileuri.strict_origin_policy` in the filter box and toggling the option to false._
+
+### Loading ES6
+
+app/es6-file.js:
+```javascript
+ export class q {
+ constructor() {
+ this.es6 = 'yay';
+ }
+ }
+```
+
+```html
+ <script>
+ System.import('./app/es6-file.js').then(function(m) {
+ console.log(new m.q().es6); // yay
+ });
+ </script>
+```
+
+ES6 modules define named exports, provided as getters on a special immutable `Module` object.
+
+* [Read more about ES6 modules and syntax](es6-modules-overview.md).
+* To build for production, see the [production workflows](production-workflows.md).
+* [Read more about SystemJS module format support](module-formats.md).
+
+### Loader Configuration
+
+Some of the standard configuration options and their use cases are described below.
+
+For a reference see the [Config API](config-api.md) page.
+
+#### baseURL
+
+The *baseURL* provides a special mechanism for loading modules relative to a standard reference URL.
+
+This can be useful for being able to refer to the same module from many different page URLs or environments:
+
+```javascript
+System.config({
+ baseURL: '/modules'
+});
+
+
+// loads /modules/jquery.js
+System.import('jquery.js');
+```
+
+Module names of the above form are referred to as _plain names_ and are always loaded baseURL-relative instead of
+parentURL relative like one would expect with ordinary URLs.
+
+> Note we always run the `System.config` function instead of setting instance properties directly as this will set the correct normalized baseURL in the process.
+
+#### Map Config
+
+The baseURL is very useful for providing an absolute reference URL for loading all modules, but we don't necessarily want to
+have to locate every single shared dependency from within one folder.
+
+Sometimes we want to load things from different places.
+
+Map configuration is useful here to be able to specific exactly where to locate a given package:
+
+```javascript
+System.config({
+ map: {
+ jquery: 'https://code.jquery.com/jquery.js'
+ }
+});
+```
+
+Map configuration can also be used to map subpaths:
+
+```javascript
+System.config({
+ map: {
+ app: '/app/'
+ }
+});
+
+// will load /app/main.js
+System.import('app/main.js');
+```
+
+Map configuration is always applied before the baseURL rule in the loader.
+
+### Plugin Loaders
+
+Plugins handle alternative loading scenarios, including loading assets such as CSS or images, and providing custom transpilation scenarios.
+
+Plugins can also inline into bundles or remain separate requests when using [SystemJS Builder](https://github.com/systemjs/builder).
+
+To create a custom plugin, see the documentation on [creating plugins](creating-plugins.md).
+
+#### Basic Use
+
+> Note that if using the `defaultJSExtensions` compatibility feature, plugins for resources with custom extensions will only work by using the [package configuration](config-api.md#packages) `defaultExtension: false` option to override this for specific packages.
+
+To use a plugin, set up the plugin itself as a standard module, either locating it in the baseURL or providing map configuration for it.
+
+In this case, we're using the [text plugin](https://github.com/systemjs/plugin-text) as an example.
+
+Then configure a custom resource to be loaded via the plugin, we then use meta configuration:
+
+```javascript
+System.config({
+ // locate the plugin via map configuration
+ // (alternatively have it in the baseURL)
+ map: {
+ text: '/path/to/text-plugin.js'
+ },
+ // use meta configuration to reference which modules
+ // should use the plugin loader
+ meta: {
+ 'templates/*.html': {
+ loader: 'text'
+ }
+ }
+});
+```
+
+Now any code that loads from `[baseURL]/templates/*.html` will use the text loader plugin and return the loaded content:
+
+app.js
+```javascript
+import htmlSource from 'templates/tpl.html';
+
+document.querySelector('.container').innerHTML = htmlSource;
+```
+
+When we build app.js, the text plugin will then automatically inline the templates into the bundle during the build.
+
+#### Plugin Syntax
+
+It is also possible to use syntax to load via plugins instead of configuration:
+
+```javascript
+System.import('some/file.txt!text')
+```
+
+When no plugin is explicitly specified the extension is used as the plugin name itself.
+
+> Note it is usually advisable to use plugin loader configuration over plugin syntax.
diff --git a/docs/production-workflows.md b/docs/production-workflows.md
new file mode 100644
index 000000000..6af698915
--- /dev/null
+++ b/docs/production-workflows.md
@@ -0,0 +1,83 @@
+### Compiling Modules into a Bundle
+
+[SystemJS builder](https://github.com/systemjs/builder) provides comprehensive support for compiling all
+module formats into a single bundle in a way that supports
+[circular references and zebra-striping](https://github.com/ModuleLoader/es6-module-loader/blob/v0.17.0/docs/circular-references-bindings.md).
+
+It also offers the ability to [create self-executing bundles](https://github.com/systemjs/builder#self-executing-sfx-bundles)
+that can run without needing SystemJS present at all by embedding a micro-loader implementation.
+
+### DepCache
+
+An alternative to bundling into a single bundle is to leave files as separate for loading in production.
+
+The depcache extension allows specifying the dependencies of all modules upfront through configuration so that loads can
+happen in parallel.
+
+```javascript
+System.config({
+ depCache: {
+ 'moduleA': ['moduleB'], // moduleA depends on moduleB
+ 'moduleB': ['moduleC'] // moduleB depends on moduleC
+ }
+});
+
+// when we do this import, depCache knows we also need moduleB and moduleC,
+// it then directly requests those modules as well as soon as we request moduleA
+System.import('moduleA')
+```
+
+Over HTTP/2 this approach may be preferable as it allows files to be individually cached in the browser meaning bundle
+optimizations are no longer a concern.
+
+### Bundle Extension
+
+It can be useful to load bundles of code on-demand instead of having them all included in the HTML page blocking the
+initial load.
+
+The bundle extension will automatically download a bundle as soon as an attempt to import any module in that bundle is made.
+
+```javascript
+ // the bundle at build/core.js contains these modules
+ System.config({
+ bundles: {
+ 'build/core': ['jquery', 'app/app', 'app/dep', 'lib/third-party']
+ }
+ });
+
+ // when we load 'app/app' the bundle extension interrupts the loading process
+ // and ensures that build/core.js is loaded first
+ System.import('app/app');
+
+ // this way a request to any one of 'jquery', 'app/app', 'app/dep', 'lib/third-party'
+ // will delegate to the bundle and only a single request is made
+```
+
+A built file must contain the exact named defines or named `System.register` statements for the modules
+it contains. Mismatched names will result in separate requests still being made.
+
+### CSP-Compatible Production
+
+SystemJS comes with a separate build for production only. This is fully [CSP](http://www.html5rocks.com/en/tutorials/security/content-security-policy/)-compatible using script tag injection to load scripts,
+while still remaining an extension of the ES6 Module Loader.
+
+Replace the `system.js` file with `dist/system-csp-production.js`.
+
+If we have compiled all our modules into a bundle we can then write:
+
+```html
+ <script src="system-csp-production.js"></script>
+ <script>
+ System.config({
+ bundles: {
+ 'bundle': ['app/main']
+ }
+ });
+ System.import('app/main').then(function(m) {
+ // loads app/main from the app-built bundle
+ });
+ </script>
+```
+
+> Note the main build of SystemJS will also use script tag injection for AMD, register and global modules when it can for maximum CSP compatibility.
+ It is typically just plugin loaders, CommonJS and custom global metadata options that cause XHR source-loading to be needed.
diff --git a/docs/system-api.md b/docs/system-api.md
new file mode 100644
index 000000000..803d688fc
--- /dev/null
+++ b/docs/system-api.md
@@ -0,0 +1,141 @@
+## SystemJS API
+
+For setting SystemJS configuration see the [Configuration API](config-api.md) page.
+
+#### System.amdDefine
+Type: `Function`
+
+For backwards-compatibility with AMD environments, set `window.define = System.amdDefine`.
+
+#### System.amdRequire
+Type: `Function`
+
+For backwards-compatibility with AMD environments, set `window.require = System.amdRequire`.
+
+#### System.config
+Type: `Function`
+
+SystemJS configuration helper function. See the [Configuration API](config-api.md).
+
+#### System.constructor
+Type: `Function`
+
+This represents the System base class, which can be extended or reinstantiated to create a custom System instance.
+
+Example:
+
+```javascript
+ var clonedSystem = new System.constructor();
+ clonedSystem.baseURL = System.baseURL;
+ clonedSystem.import('x'); // imports in a custom context
+```
+
+#### System.delete(moduleName)
+Type: `Function`
+
+Deletes a module from the registry by normalized name.
+
+```javascript
+System.delete('http://site.com/normalized/module/name.js');
+```
+
+#### System.get(moduleName) -> Module
+Type: `Function`
+
+Returns a module from the registry by normalized name.
+
+```javascript
+System.get('http://site.com/normalized/module/name.js').exportedFunction();
+```
+
+#### System.has(moduleName) -> Boolean
+Type: `Function`
+
+Returns whether a given module exists in the registry by normalized module name.
+
+```javascript
+if (System.has('http://site.com/normalized/module/name.js')) {
+ // ...
+}
+```
+
+#### System.import(moduleName [, normalizedParentName]) -> Promise(Module)
+Type: `Function`
+
+Loads a module by name taking an optional normalized parent name argument.
+
+Promise resolves to the module value.
+
+For loading relative to the current module, ES Modules define a `__moduleName` binding, so that:
+
+```javascript
+System.import('./local', __moduleName);
+```
+
+In CommonJS modules the above would be `module.id` instead.
+
+This is non-standard, but coverse a use case that will be provided by the spec.
+
+#### System.newModule(Object) -> Module
+Type: `Function`
+
+Given a plain JavaScript object, return an equivalent `Module` object.
+
+Useful when writing a custom `instantiate` hook or using `System.set`.
+
+#### System.register([name ,] deps, declare)
+Type: `Function`
+
+Declaration function for defining modules of the `System.register` polyfill module format.
+
+[Read more on the format at the loader polyfill page](https://github.com/ModuleLoader/es6-module-loader/blob/v0.17.0/docs/system-register.md)
+
+#### System.registerDynamic([name ,] deps, executingRequire, declare)
+Type: `Function`
+
+Companion module format to `System.register` for non-ES6 modules.
+
+Provides a `<script>`-injection-compatible module format that any CommonJS or Global module can be converted into for CSP compatibility.
+
+Output created by [SystemJS Builder](https://github.com/systemjs/builder) when creating bundles or self-executing bundles.
+
+For example, the following CommonJS module:
+
+```javascript
+module.exports = require('pkg/module');
+```
+
+Can be written:
+
+```javascript
+System.registerDynamic(['pkg/module'], true, function(require, exports, module) {
+ module.exports = require('pkg/module');
+});
+```
+
+`executingRequire` indicates that the dependencies are executed synchronously only when using the `require` function, and not before execution.
+
+* `require` is a standard CommonJS-style require
+* `exports` the CommonJS exports object, which is assigned to the `default` export of the module, with its own properties available as named exports.
+* `module` represents the CommonJS module object, with `export`, `id` and `url` properties set.
+
+#### System.set(moduleName, Module)
+Type: `Function`
+
+Sets a module into the registry directly and synchronously.
+
+Typically used along with `System.newModule` to create a valid `Module` object:
+
+```javascript
+System.set('custom-module', System.newModule({ prop: 'value' }));
+```
+
+> Note SystemJS stores all module names in the registry as normalized URLs. To be able to properly use the registry with `System.set` it is usually necessary to run `System.set(System.normalizeSync('custom-module'), System.newModule({ prop: 'value' }));` to ensure that `System.import` behaves correctly.
+
+#### System._nodeRequire
+Type: `Function`
+
+In CommonJS environments, SystemJS will substitute the global `require` as needed by the module format being loaded to ensure
+the correct detection paths in loaded code.
+
+The CommonJS require can be recovered within these modules from `System._nodeRequire`.
diff --git a/index.js b/index.js
new file mode 100644
index 000000000..6a958ecff
--- /dev/null
+++ b/index.js
@@ -0,0 +1,48 @@
+if (typeof Promise === 'undefined')
+ require('when/es6-shim/Promise');
+
+var version = require('./package.json').version;
+
+var isWindows = typeof process.platform != 'undefined' && process.platform.match(/^win/);
+
+// set transpiler paths in Node
+var nodeResolver = typeof process != 'undefined' && typeof require != 'undefined' && require.resolve;
+function configNodePath(loader, module, nodeModule, wildcard) {
+ if (loader.paths[module])
+ return;
+
+ var ext = wildcard ? '/package.json' : '';
+ try {
+ var match = nodeResolver(nodeModule + ext).replace(/\\/g, '/');
+ }
+ catch(e) {}
+
+ if (match)
+ loader.paths[module] = 'file://' + (isWindows ? '/' : '') + match.substr(0, match.length - ext.length) + (wildcard ? '/*.js' : '');
+}
+
+var SystemJSLoader = require('./dist/system.src').constructor;
+
+// standard class extend SystemJSLoader to SystemJSNodeLoader
+function SystemJSNodeLoader() {
+ SystemJSLoader.call(this);
+
+ if (nodeResolver) {
+ configNodePath(this, 'traceur', 'traceur/bin/traceur.js');
+ configNodePath(this, 'traceur-runtime', 'traceur/bin/traceur-runtime.js');
+ configNodePath(this, 'babel', 'babel-core/browser.js');
+ configNodePath(this, 'babel/external-helpers', 'babel-core/external-helpers.js');
+ configNodePath(this, 'babel-runtime/*', 'babel-runtime', true);
+ }
+}
+SystemJSNodeLoader.prototype = Object.create(SystemJSLoader.prototype);
+SystemJSNodeLoader.prototype.constructor = SystemJSNodeLoader;
+
+var System = new SystemJSNodeLoader();
+
+System.version = version + ' Node';
+
+if (typeof global != 'undefined')
+ global.System = global.SystemJS = System;
+
+module.exports = System;
diff --git a/lib/alias.js b/lib/alias.js
new file mode 100644
index 000000000..1d37220b5
--- /dev/null
+++ b/lib/alias.js
@@ -0,0 +1,38 @@
+/*
+ * Alias Extension
+ *
+ * Allows a module to be a plain copy of another module by module name
+ *
+ * SystemJS.meta['mybootstrapalias'] = { alias: 'bootstrap' };
+ *
+ */
+(function() {
+ // aliases
+ hook('fetch', function(fetch) {
+ return function(load) {
+ var alias = load.metadata.alias;
+ var aliasDeps = load.metadata.deps || [];
+ if (alias) {
+ load.metadata.format = 'defined';
+ var entry = createEntry();
+ this.defined[load.name] = entry;
+ entry.declarative = true;
+ entry.deps = aliasDeps.concat([alias]);
+ entry.declare = function(_export) {
+ return {
+ setters: [function(module) {
+ for (var p in module)
+ _export(p, module[p]);
+ if (module.__useDefault)
+ entry.module.exports.__useDefault = true;
+ }],
+ execute: function() {}
+ };
+ };
+ return '';
+ }
+
+ return fetch.call(this, load);
+ };
+ });
+})(); \ No newline at end of file
diff --git a/lib/amd-helpers.js b/lib/amd-helpers.js
new file mode 100644
index 000000000..8a5b410c1
--- /dev/null
+++ b/lib/amd-helpers.js
@@ -0,0 +1,245 @@
+/*
+ * AMD Helper function module
+ * Separated into its own file as this is the part needed for full AMD support in SFX builds
+ * NB since implementations have now diverged this can be merged back with amd.js
+ */
+
+hook('fetch', function(fetch) {
+ return function(load) {
+ // script load implies define global leak
+ if (load.metadata.scriptLoad && isBrowser)
+ __global.define = this.amdDefine;
+ return fetch.call(this, load);
+ };
+});
+
+hookConstructor(function(constructor) {
+ return function() {
+ var loader = this;
+ constructor.call(this);
+
+ var commentRegEx = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg;
+ var cjsRequirePre = "(?:^|[^$_a-zA-Z\\xA0-\\uFFFF.])";
+ var cjsRequirePost = "\\s*\\(\\s*(\"([^\"]+)\"|'([^']+)')\\s*\\)";
+ var fnBracketRegEx = /\(([^\)]*)\)/;
+ var wsRegEx = /^\s+|\s+$/g;
+
+ var requireRegExs = {};
+
+ function getCJSDeps(source, requireIndex) {
+
+ // remove comments
+ source = source.replace(commentRegEx, '');
+
+ // determine the require alias
+ var params = source.match(fnBracketRegEx);
+ var requireAlias = (params[1].split(',')[requireIndex] || 'require').replace(wsRegEx, '');
+
+ // find or generate the regex for this requireAlias
+ var requireRegEx = requireRegExs[requireAlias] || (requireRegExs[requireAlias] = new RegExp(cjsRequirePre + requireAlias + cjsRequirePost, 'g'));
+
+ requireRegEx.lastIndex = 0;
+
+ var deps = [];
+
+ var match;
+ while (match = requireRegEx.exec(source))
+ deps.push(match[2] || match[3]);
+
+ return deps;
+ }
+
+ /*
+ AMD-compatible require
+ To copy RequireJS, set window.require = window.requirejs = loader.amdRequire
+ */
+ function require(names, callback, errback, referer) {
+ // in amd, first arg can be a config object... we just ignore
+ if (typeof names == 'object' && !(names instanceof Array))
+ return require.apply(null, Array.prototype.splice.call(arguments, 1, arguments.length - 1));
+
+ // amd require
+ if (typeof names == 'string' && typeof callback == 'function')
+ names = [names];
+ if (names instanceof Array) {
+ var dynamicRequires = [];
+ for (var i = 0; i < names.length; i++)
+ dynamicRequires.push(loader['import'](names[i], referer));
+ Promise.all(dynamicRequires).then(function(modules) {
+ if (callback)
+ callback.apply(null, modules);
+ }, errback);
+ }
+
+ // commonjs require
+ else if (typeof names == 'string') {
+ var defaultJSExtension = loader.defaultJSExtensions && names.substr(names.length - 3, 3) != '.js';
+ var normalized = loader.decanonicalize(names, referer);
+ if (defaultJSExtension && normalized.substr(normalized.length - 3, 3) == '.js')
+ normalized = normalized.substr(0, normalized.length - 3);
+ var module = loader.get(normalized);
+ if (!module)
+ throw new Error('Module not already loaded loading "' + names + '" as ' + normalized + (referer ? ' from "' + referer + '".' : '.'));
+ return module.__useDefault ? module['default'] : module;
+ }
+
+ else
+ throw new TypeError('Invalid require');
+ }
+
+ function define(name, deps, factory) {
+ if (typeof name != 'string') {
+ factory = deps;
+ deps = name;
+ name = null;
+ }
+ if (!(deps instanceof Array)) {
+ factory = deps;
+ deps = ['require', 'exports', 'module'].splice(0, factory.length);
+ }
+
+ if (typeof factory != 'function')
+ factory = (function(factory) {
+ return function() { return factory; }
+ })(factory);
+
+ // in IE8, a trailing comma becomes a trailing undefined entry
+ if (deps[deps.length - 1] === undefined)
+ deps.pop();
+
+ // remove system dependencies
+ var requireIndex, exportsIndex, moduleIndex;
+
+ if ((requireIndex = indexOf.call(deps, 'require')) != -1) {
+
+ deps.splice(requireIndex, 1);
+
+ // only trace cjs requires for non-named
+ // named defines assume the trace has already been done
+ if (!name)
+ deps = deps.concat(getCJSDeps(factory.toString(), requireIndex));
+ }
+
+ if ((exportsIndex = indexOf.call(deps, 'exports')) != -1)
+ deps.splice(exportsIndex, 1);
+
+ if ((moduleIndex = indexOf.call(deps, 'module')) != -1)
+ deps.splice(moduleIndex, 1);
+
+ function execute(req, exports, module) {
+ var depValues = [];
+ for (var i = 0; i < deps.length; i++)
+ depValues.push(req(deps[i]));
+
+ module.uri = module.id;
+
+ module.config = function() {};
+
+ // add back in system dependencies
+ if (moduleIndex != -1)
+ depValues.splice(moduleIndex, 0, module);
+
+ if (exportsIndex != -1)
+ depValues.splice(exportsIndex, 0, exports);
+
+ if (requireIndex != -1) {
+ function contextualRequire(names, callback, errback) {
+ if (typeof names == 'string' && typeof callback != 'function')
+ return req(names);
+ return require.call(loader, names, callback, errback, module.id);
+ }
+ contextualRequire.toUrl = function(name) {
+ // normalize without defaultJSExtensions
+ var defaultJSExtension = loader.defaultJSExtensions && name.substr(name.length - 3, 3) != '.js';
+ var url = loader.decanonicalize(name, module.id);
+ if (defaultJSExtension && url.substr(url.length - 3, 3) == '.js')
+ url = url.substr(0, url.length - 3);
+ return url;
+ };
+ depValues.splice(requireIndex, 0, contextualRequire);
+ }
+
+ // set global require to AMD require
+ var curRequire = __global.require;
+ __global.require = require;
+
+ var output = factory.apply(exportsIndex == -1 ? __global : exports, depValues);
+
+ __global.require = curRequire;
+
+ if (typeof output == 'undefined' && module)
+ output = module.exports;
+
+ if (typeof output != 'undefined')
+ return output;
+ }
+
+ var entry = createEntry();
+ entry.name = name && (loader.decanonicalize || loader.normalize).call(loader, name);
+ entry.deps = deps;
+ entry.execute = execute;
+
+ loader.pushRegister_({
+ amd: true,
+ entry: entry
+ });
+ }
+ define.amd = {};
+
+ // reduction function to attach defines to a load record
+ hook('reduceRegister_', function(reduceRegister) {
+ return function(load, register) {
+ // only handle AMD registers here
+ if (!register || !register.amd)
+ return reduceRegister.call(this, load, register);
+
+ var curMeta = load && load.metadata;
+ var entry = register.entry;
+
+ if (curMeta) {
+ if (!curMeta.format || curMeta.format == 'detect')
+ curMeta.format = 'amd';
+ else if (!entry.name && curMeta.format != 'amd')
+ throw new Error('AMD define called while executing ' + curMeta.format + ' module ' + load.name);
+ }
+
+ // anonymous define
+ if (!entry.name) {
+ if (!curMeta)
+ throw new TypeError('Unexpected anonymous AMD define.');
+
+ if (curMeta.entry && !curMeta.entry.name)
+ throw new Error('Multiple anonymous defines in module ' + load.name);
+
+ curMeta.entry = entry;
+ }
+ // named define
+ else {
+ // if we don't have any other defines,
+ // then let this be an anonymous define
+ // this is just to support single modules of the form:
+ // define('jquery')
+ // still loading anonymously
+ // because it is done widely enough to be useful
+ // as soon as there is more than one define, this gets removed though
+ if (curMeta) {
+ if (!curMeta.entry && !curMeta.bundle)
+ curMeta.entry = entry;
+ else if (curMeta.entry && curMeta.entry.name && curMeta.entry.name != load.name)
+ curMeta.entry = undefined;
+
+ // note this is now a bundle
+ curMeta.bundle = true;
+ }
+
+ // define the module through the register registry
+ if (!(entry.name in this.defined))
+ this.defined[entry.name] = entry;
+ }
+ };
+ });
+
+ loader.amdDefine = define;
+ loader.amdRequire = require;
+ };
+}); \ No newline at end of file
diff --git a/lib/amd.js b/lib/amd.js
new file mode 100644
index 000000000..2e2d37948
--- /dev/null
+++ b/lib/amd.js
@@ -0,0 +1,42 @@
+/*
+ SystemJS AMD Format
+*/
+(function() {
+ // AMD Module Format Detection RegEx
+ // define([.., .., ..], ...)
+ // define(varName); || define(function(require, exports) {}); || define({})
+ var amdRegEx = /(?:^\uFEFF?|[^$_a-zA-Z\xA0-\uFFFF.])define\s*\(\s*("[^"]+"\s*,\s*|'[^']+'\s*,\s*)?\s*(\[(\s*(("[^"]+"|'[^']+')\s*,|\/\/.*\r?\n|\/\*(.|\s)*?\*\/))*(\s*("[^"]+"|'[^']+')\s*,?)?(\s*(\/\/.*\r?\n|\/\*(.|\s)*?\*\/))*\s*\]|function\s*|{|[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*\))/;
+
+ hook('instantiate', function(instantiate) {
+ return function(load) {
+ var loader = this;
+
+ if (load.metadata.format == 'amd' || !load.metadata.format && load.source.match(amdRegEx)) {
+ load.metadata.format = 'amd';
+
+ if (!loader.builder && loader.execute !== false) {
+ var curDefine = __global.define;
+ __global.define = this.amdDefine;
+
+ try {
+ __exec.call(loader, load);
+ }
+ finally {
+ __global.define = curDefine;
+ }
+
+ if (!load.metadata.entry && !load.metadata.bundle)
+ throw new TypeError('AMD module ' + load.name + ' did not define');
+ }
+ else {
+ load.metadata.execute = function() {
+ return load.metadata.builderExecute.apply(this, arguments);
+ };
+ }
+ }
+
+ return instantiate.call(loader, load);
+ };
+ });
+
+})();
diff --git a/lib/bundles.js b/lib/bundles.js
new file mode 100644
index 000000000..c22a44986
--- /dev/null
+++ b/lib/bundles.js
@@ -0,0 +1,73 @@
+/*
+ System bundles
+
+ Allows a bundle module to be specified which will be dynamically
+ loaded before trying to load a given module.
+
+ For example:
+ SystemJS.bundles['mybundle'] = ['jquery', 'bootstrap/js/bootstrap']
+
+ Will result in a load to "mybundle" whenever a load to "jquery"
+ or "bootstrap/js/bootstrap" is made.
+
+ In this way, the bundle becomes the request that provides the module
+*/
+
+(function() {
+ // bundles support (just like RequireJS)
+ // bundle name is module name of bundle itself
+ // bundle is array of modules defined by the bundle
+ // when a module in the bundle is requested, the bundle is loaded instead
+ // of the form SystemJS.bundles['mybundle'] = ['jquery', 'bootstrap/js/bootstrap']
+ hookConstructor(function(constructor) {
+ return function() {
+ constructor.call(this);
+ this.bundles = {};
+ this._loader.loadedBundles = {};
+ };
+ });
+
+ // assign bundle metadata for bundle loads
+ hook('locate', function(locate) {
+ return function(load) {
+ var loader = this;
+ var matched = false;
+
+ if (!(load.name in loader.defined))
+ for (var b in loader.bundles) {
+ for (var i = 0; i < loader.bundles[b].length; i++) {
+ var curModule = loader.bundles[b][i];
+
+ if (curModule == load.name) {
+ matched = true;
+ break;
+ }
+
+ // wildcard in bundles does not include / boundaries
+ if (curModule.indexOf('*') != -1) {
+ var parts = curModule.split('*');
+ if (parts.length != 2) {
+ loader.bundles[b].splice(i--, 1);
+ continue;
+ }
+
+ if (load.name.substring(0, parts[0].length) == parts[0] &&
+ load.name.substr(load.name.length - parts[1].length, parts[1].length) == parts[1] &&
+ load.name.substr(parts[0].length, load.name.length - parts[1].length - parts[0].length).indexOf('/') == -1) {
+ matched = true;
+ break;
+ }
+ }
+ }
+
+ if (matched)
+ return loader['import'](b)
+ .then(function() {
+ return locate.call(loader, load);
+ });
+ }
+
+ return locate.call(loader, load);
+ };
+ });
+})();
diff --git a/lib/cjs-helpers.js b/lib/cjs-helpers.js
new file mode 100644
index 000000000..0ae08d612
--- /dev/null
+++ b/lib/cjs-helpers.js
@@ -0,0 +1,43 @@
+hookConstructor(function(constructor) {
+ return function() {
+ var loader = this;
+ constructor.call(loader);
+
+ if (typeof window != 'undefined' && typeof document != 'undefined' && window.location)
+ var windowOrigin = location.protocol + '//' + location.hostname + (location.port ? ':' + location.port : '');
+
+ function stripOrigin(path) {
+ if (path.substr(0, 8) == 'file:///')
+ return path.substr(7 + !!isWindows);
+
+ if (windowOrigin && path.substr(0, windowOrigin.length) == windowOrigin)
+ return path.substr(windowOrigin.length);
+
+ return path;
+ }
+
+ loader.set('@@cjs-helpers', loader.newModule({
+ requireResolve: function(request, parentId) {
+ return stripOrigin(loader.normalizeSync(request, parentId));
+ },
+ getPathVars: function(moduleId) {
+ // remove any plugin syntax
+ var pluginIndex = moduleId.lastIndexOf('!');
+ var filename;
+ if (pluginIndex != -1)
+ filename = moduleId.substr(0, pluginIndex);
+ else
+ filename = moduleId;
+
+ var dirname = filename.split('/');
+ dirname.pop();
+ dirname = dirname.join('/');
+
+ return {
+ filename: stripOrigin(filename),
+ dirname: stripOrigin(dirname)
+ };
+ }
+ }))
+ };
+}); \ No newline at end of file
diff --git a/lib/cjs.js b/lib/cjs.js
new file mode 100644
index 000000000..c7327f181
--- /dev/null
+++ b/lib/cjs.js
@@ -0,0 +1,138 @@
+/*
+ SystemJS CommonJS Format
+*/
+(function() {
+ // CJS Module Format
+ // require('...') || exports[''] = ... || exports.asd = ... || module.exports = ...
+ var cjsExportsRegEx = /(?:^\uFEFF?|[^$_a-zA-Z\xA0-\uFFFF.])(exports\s*(\[['"]|\.)|module(\.exports|\['exports'\]|\["exports"\])\s*(\[['"]|[=,\.]))/;
+ // RegEx adjusted from https://github.com/jbrantly/yabble/blob/master/lib/yabble.js#L339
+ var cjsRequireRegEx = /(?:^\uFEFF?|[^$_a-zA-Z\xA0-\uFFFF."'])require\s*\(\s*("[^"\\]*(?:\\.[^"\\]*)*"|'[^'\\]*(?:\\.[^'\\]*)*')\s*\)/g;
+ var commentRegEx = /(^|[^\\])(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg;
+
+ var stringRegEx = /("[^"\\\n\r]*(\\.[^"\\\n\r]*)*"|'[^'\\\n\r]*(\\.[^'\\\n\r]*)*')/g;
+
+ // used to support leading #!/usr/bin/env in scripts as supported in Node
+ var hashBangRegEx = /^\#\!.*/;
+
+ function getCJSDeps(source) {
+ cjsRequireRegEx.lastIndex = commentRegEx.lastIndex = stringRegEx.lastIndex = 0;
+
+ var deps = [];
+
+ var match;
+
+ // track string and comment locations for unminified source
+ var stringLocations = [], commentLocations = [];
+
+ function inLocation(locations, match) {
+ for (var i = 0; i < locations.length; i++)
+ if (locations[i][0] < match.index && locations[i][1] > match.index)
+ return true;
+ return false;
+ }
+
+ if (source.length / source.split('\n').length < 200) {
+ while (match = stringRegEx.exec(source))
+ stringLocations.push([match.index, match.index + match[0].length]);
+
+ // TODO: track template literals here before comments
+
+ while (match = commentRegEx.exec(source)) {
+ // only track comments not starting in strings
+ if (!inLocation(stringLocations, match))
+ commentLocations.push([match.index + match[1].length, match.index + match[0].length - 1]);
+ }
+ }
+
+ while (match = cjsRequireRegEx.exec(source)) {
+ // ensure we're not within a string or comment location
+ if (!inLocation(stringLocations, match) && !inLocation(commentLocations, match)) {
+ var dep = match[1].substr(1, match[1].length - 2);
+ // skip cases like require('" + file + "')
+ if (dep.match(/"|'/))
+ continue;
+ // trailing slash requires are removed as they don't map mains in SystemJS
+ if (dep[dep.length - 1] == '/')
+ dep = dep.substr(0, dep.length - 1);
+ deps.push(dep);
+ }
+ }
+
+ return deps;
+ }
+
+ hook('instantiate', function(instantiate) {
+ return function(load) {
+ var loader = this;
+ if (!load.metadata.format) {
+ cjsExportsRegEx.lastIndex = 0;
+ cjsRequireRegEx.lastIndex = 0;
+ if (cjsRequireRegEx.exec(load.source) || cjsExportsRegEx.exec(load.source))
+ load.metadata.format = 'cjs';
+ }
+
+ if (load.metadata.format == 'cjs') {
+ var metaDeps = load.metadata.deps;
+ var deps = load.metadata.cjsRequireDetection === false ? [] : getCJSDeps(load.source);
+
+ for (var g in load.metadata.globals)
+ if (load.metadata.globals[g])
+ deps.push(load.metadata.globals[g]);
+
+ var entry = createEntry();
+
+ load.metadata.entry = entry;
+
+ entry.deps = deps;
+ entry.executingRequire = true;
+ entry.execute = function(_require, exports, module) {
+ function require(name) {
+ if (name[name.length - 1] == '/')
+ name = name.substr(0, name.length - 1);
+ return _require.apply(this, arguments);
+ }
+ require.resolve = function(name) {
+ return loader.get('@@cjs-helpers').requireResolve(name, module.id);
+ };
+ // support module.paths ish
+ module.paths = [];
+ module.require = _require;
+
+ // ensure meta deps execute first
+ if (!load.metadata.cjsDeferDepsExecute)
+ for (var i = 0; i < metaDeps.length; i++)
+ require(metaDeps[i]);
+
+ var pathVars = loader.get('@@cjs-helpers').getPathVars(module.id);
+ var __cjsWrapper = {
+ exports: exports,
+ args: [require, exports, module, pathVars.filename, pathVars.dirname, __global, __global]
+ };
+
+ var cjsWrapper = "(function(require, exports, module, __filename, __dirname, global, GLOBAL";
+
+ // add metadata.globals to the wrapper arguments
+ if (load.metadata.globals)
+ for (var g in load.metadata.globals) {
+ __cjsWrapper.args.push(require(load.metadata.globals[g]));
+ cjsWrapper += ", " + g;
+ }
+
+ // disable AMD detection
+ var define = __global.define;
+ __global.define = undefined;
+ __global.__cjsWrapper = __cjsWrapper;
+
+ load.source = cjsWrapper + ") {" + load.source.replace(hashBangRegEx, '') + "\n}).apply(__cjsWrapper.exports, __cjsWrapper.args);";
+
+ __exec.call(loader, load);
+
+ __global.__cjsWrapper = undefined;
+ __global.define = define;
+ };
+ }
+
+ return instantiate.call(loader, load);
+ };
+ });
+})();
diff --git a/lib/conditionals.js b/lib/conditionals.js
new file mode 100644
index 000000000..d30a6f9ac
--- /dev/null
+++ b/lib/conditionals.js
@@ -0,0 +1,161 @@
+/*
+ * Conditions Extension
+ *
+ * Allows a condition module to alter the resolution of an import via syntax:
+ *
+ * import $ from 'jquery/#{browser}';
+ *
+ * Will first load the module 'browser' via `SystemJS.import('browser')` and
+ * take the default export of that module.
+ * If the default export is not a string, an error is thrown.
+ *
+ * We then substitute the string into the require to get the conditional resolution
+ * enabling environment-specific variations like:
+ *
+ * import $ from 'jquery/ie'
+ * import $ from 'jquery/firefox'
+ * import $ from 'jquery/chrome'
+ * import $ from 'jquery/safari'
+ *
+ * It can be useful for a condition module to define multiple conditions.
+ * This can be done via the `|` modifier to specify an export member expression:
+ *
+ * import 'jquery/#{./browser.js|grade.version}'
+ *
+ * Where the `grade` export `version` member in the `browser.js` module is substituted.
+ *
+ *
+ * Boolean Conditionals
+ *
+ * For polyfill modules, that are used as imports but have no module value,
+ * a binary conditional allows a module not to be loaded at all if not needed:
+ *
+ * import 'es5-shim#?./conditions.js|needs-es5shim'
+ *
+ * These conditions can also be negated via:
+ *
+ * import 'es5-shim#?./conditions.js|~es6'
+ *
+ */
+
+ var sysConditions = ['browser', 'node', 'dev', 'build', 'production', 'default'];
+
+ function parseCondition(condition) {
+ var conditionExport, conditionModule, negation;
+
+ var negation = condition[0] == '~';
+ var conditionExportIndex = condition.lastIndexOf('|');
+ if (conditionExportIndex != -1) {
+ conditionExport = condition.substr(conditionExportIndex + 1);
+ conditionModule = condition.substr(negation, conditionExportIndex - negation);
+
+ if (negation)
+ warn.call(this, 'Condition negation form "' + condition + '" is deprecated for "' + conditionModule + '|~' + conditionExport + '"');
+
+ if (conditionExport[0] == '~') {
+ negation = true;
+ conditionExport = conditionExport.substr(1);
+ }
+ }
+ else {
+ conditionExport = 'default';
+ conditionModule = condition.substr(negation);
+ if (sysConditions.indexOf(conditionModule) != -1) {
+ conditionExport = conditionModule;
+ conditionModule = null;
+ }
+ }
+
+ return {
+ module: conditionModule || '@system-env',
+ prop: conditionExport,
+ negate: negation
+ };
+ }
+
+ function serializeCondition(conditionObj) {
+ return conditionObj.module + '|' + (conditionObj.negate ? '~' : '') + conditionObj.prop;
+ }
+
+ function resolveCondition(conditionObj, parentName, bool) {
+ var self = this;
+ return this.normalize(conditionObj.module, parentName)
+ .then(function(normalizedCondition) {
+ return self.load(normalizedCondition)
+ .then(function(q) {
+ var m = readMemberExpression(conditionObj.prop, self.get(normalizedCondition));
+
+ if (bool && typeof m != 'boolean')
+ throw new TypeError('Condition ' + serializeCondition(conditionObj) + ' did not resolve to a boolean.');
+
+ return conditionObj.negate ? !m : m;
+ });
+ });
+ }
+
+ var interpolationRegEx = /#\{[^\}]+\}/;
+ function interpolateConditional(name, parentName) {
+ // first we normalize the conditional
+ var conditionalMatch = name.match(interpolationRegEx);
+
+ if (!conditionalMatch)
+ return Promise.resolve(name);
+
+ var conditionObj = parseCondition.call(this, conditionalMatch[0].substr(2, conditionalMatch[0].length - 3));
+
+ // in builds, return normalized conditional
+ if (this.builder)
+ return this['normalize'](conditionObj.module, parentName)
+ .then(function(conditionModule) {
+ conditionObj.module = conditionModule;
+ return name.replace(interpolationRegEx, '#{' + serializeCondition(conditionObj) + '}');
+ });
+
+ return resolveCondition.call(this, conditionObj, parentName, false)
+ .then(function(conditionValue) {
+ if (typeof conditionValue !== 'string')
+ throw new TypeError('The condition value for ' + name + ' doesn\'t resolve to a string.');
+
+ if (conditionValue.indexOf('/') != -1)
+ throw new TypeError('Unabled to interpolate conditional ' + name + (parentName ? ' in ' + parentName : '') + '\n\tThe condition value ' + conditionValue + ' cannot contain a "/" separator.');
+
+ return name.replace(interpolationRegEx, conditionValue);
+ });
+ }
+
+ function booleanConditional(name, parentName) {
+ // first we normalize the conditional
+ var booleanIndex = name.lastIndexOf('#?');
+
+ if (booleanIndex == -1)
+ return Promise.resolve(name);
+
+ var conditionObj = parseCondition.call(this, name.substr(booleanIndex + 2));
+
+ // in builds, return normalized conditional
+ if (this.builder)
+ return this['normalize'](conditionObj.module, parentName)
+ .then(function(conditionModule) {
+ conditionObj.module = conditionModule;
+ return name.substr(0, booleanIndex) + '#?' + serializeCondition(conditionObj);
+ });
+
+ return resolveCondition.call(this, conditionObj, parentName, true)
+ .then(function(conditionValue) {
+ return conditionValue ? name.substr(0, booleanIndex) : '@empty';
+ });
+ }
+
+ // normalizeSync does not parse conditionals at all although it could
+ hook('normalize', function(normalize) {
+ return function(name, parentName, skipExt) {
+ var loader = this;
+ return booleanConditional.call(loader, name, parentName)
+ .then(function(name) {
+ return normalize.call(loader, name, parentName, skipExt);
+ })
+ .then(function(normalized) {
+ return interpolateConditional.call(loader, normalized, parentName);
+ });
+ };
+ });
diff --git a/lib/core.js b/lib/core.js
new file mode 100644
index 000000000..aef4315e8
--- /dev/null
+++ b/lib/core.js
@@ -0,0 +1,504 @@
+function readMemberExpression(p, value) {
+ var pParts = p.split('.');
+ while (pParts.length)
+ value = value[pParts.shift()];
+ return value;
+}
+
+function getMapMatch(map, name) {
+ var bestMatch, bestMatchLength = 0;
+
+ for (var p in map) {
+ if (name.substr(0, p.length) == p && (name.length == p.length || name[p.length] == '/')) {
+ var curMatchLength = p.split('/').length;
+ if (curMatchLength <= bestMatchLength)
+ continue;
+ bestMatch = p;
+ bestMatchLength = curMatchLength;
+ }
+ }
+
+ return bestMatch;
+}
+
+function prepareBaseURL(loader) {
+ // ensure baseURl is fully normalized
+ if (this._loader.baseURL !== this.baseURL) {
+ if (this.baseURL[this.baseURL.length - 1] != '/')
+ this.baseURL += '/';
+
+ this._loader.baseURL = this.baseURL = new URL(this.baseURL, baseURIObj).href;
+ }
+}
+
+var envModule;
+function setProduction(isProduction, isBuilder) {
+ this.set('@system-env', envModule = this.newModule({
+ browser: isBrowser,
+ node: !!this._nodeRequire,
+ production: !isBuilder && isProduction,
+ dev: isBuilder || !isProduction,
+ build: isBuilder,
+ 'default': true
+ }));
+}
+
+hookConstructor(function(constructor) {
+ return function() {
+ constructor.call(this);
+
+ // support baseURL
+ this.baseURL = baseURI;
+
+ // support map and paths
+ this.map = {};
+
+ // make the location of the system.js script accessible
+ if (typeof $__curScript != 'undefined')
+ this.scriptSrc = $__curScript.src;
+
+ // global behaviour flags
+ this.warnings = false;
+ this.defaultJSExtensions = false;
+ this.pluginFirst = false;
+ this.loaderErrorStack = false;
+
+ // by default load ".json" files as json
+ // leading * meta doesn't need normalization
+ // NB add this in next breaking release
+ // this.meta['*.json'] = { format: 'json' };
+
+ // support the empty module, as a concept
+ this.set('@empty', this.newModule({}));
+
+ setProduction.call(this, false, false);
+ };
+});
+
+// include the node require since we're overriding it
+if (typeof require != 'undefined' && typeof process != 'undefined' && !process.browser)
+ SystemJSLoader.prototype._nodeRequire = require;
+
+/*
+ Core SystemJS Normalization
+
+ If a name is relative, we apply URL normalization to the page
+ If a name is an absolute URL, we leave it as-is
+
+ Plain names (neither of the above) run through the map and paths
+ normalization phases.
+
+ The paths normalization phase applies last (paths extension), which
+ defines the `decanonicalize` function and normalizes everything into
+ a URL.
+ */
+
+var parentModuleContext;
+function getNodeModule(name, baseURL) {
+ if (!isPlain(name))
+ throw new Error('Node module ' + name + ' can\'t be loaded as it is not a package require.');
+
+ if (!parentModuleContext) {
+ var Module = this._nodeRequire('module');
+ var base = baseURL.substr(isWindows ? 8 : 7);
+ parentModuleContext = new Module(base);
+ parentModuleContext.paths = Module._nodeModulePaths(base);
+ }
+ return parentModuleContext.require(name);
+}
+
+function coreResolve(name, parentName) {
+ // standard URL resolution
+ if (isRel(name))
+ return urlResolve(name, parentName);
+ else if (isAbsolute(name))
+ return name;
+
+ // plain names not starting with './', '://' and '/' go through custom resolution
+ var mapMatch = getMapMatch(this.map, name);
+
+ if (mapMatch) {
+ name = this.map[mapMatch] + name.substr(mapMatch.length);
+
+ if (isRel(name))
+ return urlResolve(name);
+ else if (isAbsolute(name))
+ return name;
+ }
+
+ if (this.has(name))
+ return name;
+
+ // dynamically load node-core modules when requiring `@node/fs` for example
+ if (name.substr(0, 6) == '@node/') {
+ if (!this._nodeRequire)
+ throw new TypeError('Error loading ' + name + '. Can only load node core modules in Node.');
+ if (this.builder)
+ this.set(name, this.newModule({}));
+ else
+ this.set(name, this.newModule(getESModule(getNodeModule.call(this, name.substr(6), this.baseURL))));
+ return name;
+ }
+
+ // prepare the baseURL to ensure it is normalized
+ prepareBaseURL.call(this);
+
+ return applyPaths(this, name) || this.baseURL + name;
+}
+
+hook('normalize', function(normalize) {
+ return function(name, parentName, skipExt) {
+ var resolved = coreResolve.call(this, name, parentName);
+ if (this.defaultJSExtensions && !skipExt && resolved.substr(resolved.length - 3, 3) != '.js' && !isPlain(resolved))
+ resolved += '.js';
+ return resolved;
+ };
+});
+
+// percent encode just '#' in urls if using HTTP requests
+var httpRequest = typeof XMLHttpRequest != 'undefined';
+hook('locate', function(locate) {
+ return function(load) {
+ return Promise.resolve(locate.call(this, load))
+ .then(function(address) {
+ if (httpRequest)
+ return address.replace(/#/g, '%23');
+ return address;
+ });
+ };
+});
+
+/*
+ * Fetch with authorization
+ */
+hook('fetch', function() {
+ return function(load) {
+ return new Promise(function(resolve, reject) {
+ fetchTextFromURL(load.address, load.metadata.authorization, resolve, reject);
+ });
+ };
+});
+
+/*
+ __useDefault
+
+ When a module object looks like:
+ newModule(
+ __useDefault: true,
+ default: 'some-module'
+ })
+
+ Then importing that module provides the 'some-module'
+ result directly instead of the full module.
+
+ Useful for eg module.exports = function() {}
+*/
+hook('import', function(systemImport) {
+ return function(name, parentName, parentAddress) {
+ if (parentName && parentName.name)
+ warn.call(this, 'SystemJS.import(name, { name: parentName }) is deprecated for SystemJS.import(name, parentName), while importing ' + name + ' from ' + parentName.name);
+ return systemImport.call(this, name, parentName, parentAddress).then(function(module) {
+ return module.__useDefault ? module['default'] : module;
+ });
+ };
+});
+
+/*
+ * Allow format: 'detect' meta to enable format detection
+ */
+hook('translate', function(systemTranslate) {
+ return function(load) {
+ if (load.metadata.format == 'detect')
+ load.metadata.format = undefined;
+ return systemTranslate.apply(this, arguments);
+ };
+});
+
+
+/*
+ * JSON format support
+ *
+ * Supports loading JSON files as a module format itself
+ *
+ * Usage:
+ *
+ * SystemJS.config({
+ * meta: {
+ * '*.json': { format: 'json' }
+ * }
+ * });
+ *
+ * Module is returned as if written:
+ *
+ * export default {JSON}
+ *
+ * No named exports are provided
+ *
+ * Files ending in ".json" are treated as json automatically by SystemJS
+ */
+hook('instantiate', function(instantiate) {
+ return function(load) {
+ if (load.metadata.format == 'json' && !this.builder) {
+ var entry = load.metadata.entry = createEntry();
+ entry.deps = [];
+ entry.execute = function() {
+ try {
+ return JSON.parse(load.source);
+ }
+ catch(e) {
+ throw new Error("Invalid JSON file " + load.name);
+ }
+ };
+ }
+ };
+})
+
+/*
+ Extend config merging one deep only
+
+ loader.config({
+ some: 'random',
+ config: 'here',
+ deep: {
+ config: { too: 'too' }
+ }
+ });
+
+ <=>
+
+ loader.some = 'random';
+ loader.config = 'here'
+ loader.deep = loader.deep || {};
+ loader.deep.config = { too: 'too' };
+
+
+ Normalizes meta and package configs allowing for:
+
+ SystemJS.config({
+ meta: {
+ './index.js': {}
+ }
+ });
+
+ To become
+
+ SystemJS.meta['https://thissite.com/index.js'] = {};
+
+ For easy normalization canonicalization with latest URL support.
+
+*/
+function envSet(loader, cfg, envCallback) {
+ if (envModule.browser && cfg.browserConfig)
+ envCallback(cfg.browserConfig);
+ if (envModule.node && cfg.nodeConfig)
+ envCallback(cfg.nodeConfig);
+ if (envModule.dev && cfg.devConfig)
+ envCallback(cfg.devConfig);
+ if (envModule.build && cfg.buildConfig)
+ envCallback(cfg.buildConfig);
+ if (envModule.production && cfg.productionConfig)
+ envCallback(cfg.productionConfig);
+}
+
+SystemJSLoader.prototype.getConfig = function(name) {
+ var cfg = {};
+ var loader = this;
+ for (var p in loader) {
+ if (loader.hasOwnProperty && !loader.hasOwnProperty(p) || p in SystemJSLoader.prototype && p != 'transpiler')
+ continue;
+ if (indexOf.call(['_loader', 'amdDefine', 'amdRequire', 'defined', 'failed', 'version', 'loads'], p) == -1)
+ cfg[p] = loader[p];
+ }
+ cfg.production = envModule.production;
+ return cfg;
+};
+
+var curCurScript;
+SystemJSLoader.prototype.config = function(cfg, isEnvConfig) {
+ var loader = this;
+
+ if ('loaderErrorStack' in cfg) {
+ curCurScript = $__curScript;
+ if (cfg.loaderErrorStack)
+ $__curScript = undefined;
+ else
+ $__curScript = curCurScript;
+ }
+
+ if ('warnings' in cfg)
+ loader.warnings = cfg.warnings;
+
+ // transpiler deprecation path
+ if (cfg.transpilerRuntime === false)
+ loader._loader.loadedTranspilerRuntime = true;
+
+ if ('production' in cfg || 'build' in cfg)
+ setProduction.call(loader, !!cfg.production, !!(cfg.build || envModule && envModule.build));
+
+ if (!isEnvConfig) {
+ // if using nodeConfig / browserConfig / productionConfig, take baseURL from there
+ // these exceptions will be unnecessary when we can properly implement config queuings
+ var baseURL;
+ envSet(loader, cfg, function(cfg) {
+ baseURL = baseURL || cfg.baseURL;
+ });
+ baseURL = baseURL || cfg.baseURL;
+
+ // always configure baseURL first
+ if (baseURL) {
+ var hasConfig = false;
+ function checkHasConfig(obj) {
+ for (var p in obj)
+ if (obj.hasOwnProperty(p))
+ return true;
+ }
+ if (checkHasConfig(loader.packages) || checkHasConfig(loader.meta) || checkHasConfig(loader.depCache) || checkHasConfig(loader.bundles) || checkHasConfig(loader.packageConfigPaths))
+ throw new TypeError('Incorrect configuration order. The baseURL must be configured with the first SystemJS.config call.');
+
+ this.baseURL = baseURL;
+ prepareBaseURL.call(this);
+ }
+
+ if (cfg.paths)
+ extend(loader.paths, cfg.paths);
+
+ envSet(loader, cfg, function(cfg) {
+ if (cfg.paths)
+ extend(loader.paths, cfg.paths);
+ });
+
+ // warn on wildcard path deprecations
+ if (this.warnings) {
+ for (var p in loader.paths)
+ if (p.indexOf('*') != -1)
+ warn.call(loader, 'Paths configuration "' + p + '" -> "' + loader.paths[p] + '" uses wildcards which are being deprecated for simpler trailing "/" folder paths.');
+ }
+ }
+
+ if (cfg.defaultJSExtensions) {
+ loader.defaultJSExtensions = cfg.defaultJSExtensions;
+ warn.call(loader, 'The defaultJSExtensions configuration option is deprecated, use packages configuration instead.');
+ }
+
+ if (cfg.pluginFirst)
+ loader.pluginFirst = cfg.pluginFirst;
+
+ if (cfg.map) {
+ var objMaps = '';
+ for (var p in cfg.map) {
+ var v = cfg.map[p];
+
+ // object map backwards-compat into packages configuration
+ if (typeof v !== 'string') {
+ objMaps += (objMaps.length ? ', ' : '') + '"' + p + '"';
+
+ var defaultJSExtension = loader.defaultJSExtensions && p.substr(p.length - 3, 3) != '.js';
+ var prop = loader.decanonicalize(p);
+ if (defaultJSExtension && prop.substr(prop.length - 3, 3) == '.js')
+ prop = prop.substr(0, prop.length - 3);
+
+ // if a package main, revert it
+ var pkgMatch = '';
+ for (var pkg in loader.packages) {
+ if (prop.substr(0, pkg.length) == pkg
+ && (!prop[pkg.length] || prop[pkg.length] == '/')
+ && pkgMatch.split('/').length < pkg.split('/').length)
+ pkgMatch = pkg;
+ }
+ if (pkgMatch && loader.packages[pkgMatch].main)
+ prop = prop.substr(0, prop.length - loader.packages[pkgMatch].main.length - 1);
+
+ var pkg = loader.packages[prop] = loader.packages[prop] || {};
+ pkg.map = v;
+ }
+ else {
+ loader.map[p] = v;
+ }
+ }
+ if (objMaps)
+ warn.call(loader, 'The map configuration for ' + objMaps + ' uses object submaps, which is deprecated in global map.\nUpdate this to use package contextual map with configs like SystemJS.config({ packages: { "' + p + '": { map: {...} } } }).');
+ }
+
+ if (cfg.packageConfigPaths) {
+ var packageConfigPaths = [];
+ for (var i = 0; i < cfg.packageConfigPaths.length; i++) {
+ var path = cfg.packageConfigPaths[i];
+ var packageLength = Math.max(path.lastIndexOf('*') + 1, path.lastIndexOf('/'));
+ var normalized = coreResolve.call(loader, path.substr(0, packageLength));
+ packageConfigPaths[i] = normalized + path.substr(packageLength);
+ }
+ loader.packageConfigPaths = packageConfigPaths;
+ }
+
+ if (cfg.bundles) {
+ for (var p in cfg.bundles) {
+ var bundle = [];
+ for (var i = 0; i < cfg.bundles[p].length; i++) {
+ var defaultJSExtension = loader.defaultJSExtensions && cfg.bundles[p][i].substr(cfg.bundles[p][i].length - 3, 3) != '.js';
+ var normalizedBundleDep = loader.decanonicalize(cfg.bundles[p][i]);
+ if (defaultJSExtension && normalizedBundleDep.substr(normalizedBundleDep.length - 3, 3) == '.js')
+ normalizedBundleDep = normalizedBundleDep.substr(0, normalizedBundleDep.length - 3);
+ bundle.push(normalizedBundleDep);
+ }
+ loader.bundles[p] = bundle;
+ }
+ }
+
+ if (cfg.packages) {
+ for (var p in cfg.packages) {
+ if (p.match(/^([^\/]+:)?\/\/$/))
+ throw new TypeError('"' + p + '" is not a valid package name.');
+
+ var prop = coreResolve.call(loader, p);
+
+ // allow trailing slash in packages
+ if (prop[prop.length - 1] == '/')
+ prop = prop.substr(0, prop.length - 1);
+
+ setPkgConfig(loader, prop, cfg.packages[p], false);
+ }
+ }
+
+ for (var c in cfg) {
+ var v = cfg[c];
+
+ if (indexOf.call(['baseURL', 'map', 'packages', 'bundles', 'paths', 'warnings', 'packageConfigPaths',
+ 'loaderErrorStack', 'browserConfig', 'nodeConfig', 'devConfig', 'buildConfig', 'productionConfig'], c) != -1)
+ continue;
+
+ if (typeof v != 'object' || v instanceof Array) {
+ loader[c] = v;
+ }
+ else {
+ loader[c] = loader[c] || {};
+
+ for (var p in v) {
+ // base-level wildcard meta does not normalize to retain catch-all quality
+ if (c == 'meta' && p[0] == '*') {
+ extend(loader[c][p] = loader[c][p] || {}, v[p]);
+ }
+ else if (c == 'meta') {
+ // meta can go through global map, with defaultJSExtensions adding
+ var resolved = coreResolve.call(loader, p);
+ if (loader.defaultJSExtensions && resolved.substr(resolved.length - 3, 3) != '.js' && !isPlain(resolved))
+ resolved += '.js';
+ extend(loader[c][resolved] = loader[c][resolved] || {}, v[p]);
+ }
+ else if (c == 'depCache') {
+ var defaultJSExtension = loader.defaultJSExtensions && p.substr(p.length - 3, 3) != '.js';
+ var prop = loader.decanonicalize(p);
+ if (defaultJSExtension && prop.substr(prop.length - 3, 3) == '.js')
+ prop = prop.substr(0, prop.length - 3);
+ loader[c][prop] = [].concat(v[p]);
+ }
+ else {
+ loader[c][p] = v[p];
+ }
+ }
+ }
+ }
+
+ envSet(loader, cfg, function(cfg) {
+ loader.config(cfg, true);
+ });
+}; \ No newline at end of file
diff --git a/lib/createSystem.js b/lib/createSystem.js
new file mode 100644
index 000000000..96fbf418c
--- /dev/null
+++ b/lib/createSystem.js
@@ -0,0 +1,3 @@
+System = new SystemJSLoader();
+
+__global.SystemJS = System; \ No newline at end of file
diff --git a/lib/depCache.js b/lib/depCache.js
new file mode 100644
index 000000000..ced47a0e3
--- /dev/null
+++ b/lib/depCache.js
@@ -0,0 +1,44 @@
+/*
+ * Dependency Tree Cache
+ *
+ * Allows a build to pre-populate a dependency trace tree on the loader of
+ * the expected dependency tree, to be loaded upfront when requesting the
+ * module, avoinding the n round trips latency of module loading, where
+ * n is the dependency tree depth.
+ *
+ * eg:
+ * SystemJS.depCache = {
+ * 'app': ['normalized', 'deps'],
+ * 'normalized': ['another'],
+ * 'deps': ['tree']
+ * };
+ *
+ * SystemJS.import('app')
+ * // simultaneously starts loading all of:
+ * // 'normalized', 'deps', 'another', 'tree'
+ * // before "app" source is even loaded
+ *
+ */
+
+(function() {
+ hookConstructor(function(constructor) {
+ return function() {
+ constructor.call(this);
+ this.depCache = {};
+ }
+ });
+
+ hook('locate', function(locate) {
+ return function(load) {
+ var loader = this;
+ // load direct deps, in turn will pick up their trace trees
+ var deps = loader.depCache[load.name];
+ if (deps)
+ for (var i = 0; i < deps.length; i++)
+ loader['import'](deps[i], load.name);
+
+ return locate.call(loader, load);
+ };
+ });
+})();
+
diff --git a/lib/esm.js b/lib/esm.js
new file mode 100644
index 000000000..84ac0f353
--- /dev/null
+++ b/lib/esm.js
@@ -0,0 +1,161 @@
+/*
+ * Extension to detect ES6 and auto-load Traceur or Babel for processing
+ */
+(function() {
+ // good enough ES6 module detection regex - format detections not designed to be accurate, but to handle the 99% use case
+ var esmRegEx = /(^\s*|[}\);\n]\s*)(import\s*(['"]|(\*\s+as\s+)?[^"'\(\)\n;]+\s*from\s*['"]|\{)|export\s+\*\s+from\s+["']|export\s*(\{|default|function|class|var|const|let|async\s+function))/;
+
+ var traceurRuntimeRegEx = /\$traceurRuntime\s*\./;
+ var babelHelpersRegEx = /babelHelpers\s*\./;
+
+ hook('translate', function(translate) {
+ return function(load) {
+ var loader = this;
+ var args = arguments;
+ return translate.apply(loader, args)
+ .then(function(source) {
+ // detect & transpile ES6
+ if (load.metadata.format == 'esm' || load.metadata.format == 'es6' || !load.metadata.format && source.match(esmRegEx)) {
+ if (load.metadata.format == 'es6')
+ warn.call(loader, 'Module ' + load.name + ' has metadata setting its format to "es6", which is deprecated.\nThis should be updated to "esm".');
+
+ load.metadata.format = 'esm';
+
+ if (load.metadata.deps) {
+ var depInject = '';
+ for (var i = 0; i < load.metadata.deps.length; i++)
+ depInject += 'import "' + load.metadata.deps[i] + '"; ';
+ load.source = depInject + source;
+ }
+
+ if (loader.transpiler === false) {
+ // we accept translation to esm for builds though to enable eg rollup optimizations
+ if (loader.builder)
+ return source;
+ throw new TypeError('Unable to dynamically transpile ES module as SystemJS.transpiler set to false.');
+ }
+
+ // setting _loader.loadedTranspiler = false tells the next block to
+ // do checks for setting transpiler metadata
+ loader._loader.loadedTranspiler = loader._loader.loadedTranspiler || false;
+ if (loader.pluginLoader)
+ loader.pluginLoader._loader.loadedTranspiler = loader._loader.loadedTranspiler || false;
+
+ // do transpilation
+ return (loader._loader.transpilerPromise || (
+ loader._loader.transpilerPromise = Promise.resolve(
+ __global[loader.transpiler == 'typescript' ? 'ts' : loader.transpiler] || (loader.pluginLoader || loader).normalize(loader.transpiler)
+ .then(function(normalized) {
+ loader._loader.transpilerNormalized = normalized;
+ return (loader.pluginLoader || loader).load(normalized)
+ .then(function() {
+ return (loader.pluginLoader || loader).get(normalized);
+ });
+ })
+ ))).then(function(transpiler) {
+ loader._loader.loadedTranspilerRuntime = true;
+
+ // translate hooks means this is a transpiler plugin instead of a raw implementation
+ if (transpiler.translate) {
+ // if transpiler is the same as the plugin loader, then don't run twice
+ if (transpiler == load.metadata.loaderModule)
+ return load.source;
+ load.metadata.loaderModule = transpiler;
+ load.metadata.loader = loader._loader.transpilerNormalized;
+
+ // convert the source map into an object for transpilation chaining
+ if (typeof load.metadata.sourceMap == 'string')
+ load.metadata.sourceMap = JSON.parse(load.metadata.sourceMap);
+
+ return Promise.resolve(transpiler.translate.apply(loader, args))
+ .then(function(source) {
+ // sanitize sourceMap if an object not a JSON string
+ var sourceMap = load.metadata.sourceMap;
+ if (sourceMap && typeof sourceMap == 'object') {
+ var originalName = load.address.split('!')[0];
+
+ // force set the filename of the original file
+ if (!sourceMap.file || sourceMap.file == load.address)
+ sourceMap.file = originalName + '!transpiled';
+
+ // force set the sources list if only one source
+ if (!sourceMap.sources || sourceMap.sources.length <= 1 && (!sourceMap.sources[0] || sourceMap.sources[0] == load.address))
+ sourceMap.sources = [originalName];
+ }
+
+ if (load.metadata.format == 'esm' && !loader.builder && detectRegisterFormat(source))
+ load.metadata.format = 'register';
+ return source;
+ });
+ }
+
+ // legacy builder support
+ if (loader.builder)
+ load.metadata.originalSource = load.source;
+
+ // defined in es6-module-loader/src/transpile.js
+ return transpile.call(loader, load)
+ .then(function(source) {
+ // clear sourceMap as transpiler embeds it
+ load.metadata.sourceMap = undefined;
+ return source;
+ });
+ }, function(err) {
+ throw addToError(err, 'Unable to load transpiler to transpile ' + load.name);
+ });
+ }
+
+ // skip transpiler and transpiler runtime loading when transpiler is disabled
+ if (loader.transpiler === false)
+ return source;
+
+ // load the transpiler correctly
+ if (loader._loader.loadedTranspiler === false && (loader.transpiler == 'traceur' || loader.transpiler == 'typescript' || loader.transpiler == 'babel')
+ && load.name == loader.normalizeSync(loader.transpiler)) {
+
+ // always load transpiler as a global
+ if (source.length > 100 && !load.metadata.format) {
+ load.metadata.format = 'global';
+
+ if (loader.transpiler === 'traceur')
+ load.metadata.exports = 'traceur';
+ if (loader.transpiler === 'typescript')
+ load.metadata.exports = 'ts';
+ }
+
+ loader._loader.loadedTranspiler = true;
+ }
+
+ // load the transpiler runtime correctly
+ if (loader._loader.loadedTranspilerRuntime === false) {
+ if (load.name == loader.normalizeSync('traceur-runtime')
+ || load.name == loader.normalizeSync('babel/external-helpers*')) {
+ if (source.length > 100)
+ load.metadata.format = load.metadata.format || 'global';
+
+ loader._loader.loadedTranspilerRuntime = true;
+ }
+ }
+
+ // detect transpiler runtime usage to load runtimes
+ if ((load.metadata.format == 'register' || load.metadata.bundle) && loader._loader.loadedTranspilerRuntime !== true) {
+ if (loader.transpiler == 'traceur' && !__global.$traceurRuntime && load.source.match(traceurRuntimeRegEx)) {
+ loader._loader.loadedTranspilerRuntime = loader._loader.loadedTranspilerRuntime || false;
+ return loader['import']('traceur-runtime').then(function() {
+ return source;
+ });
+ }
+ if (loader.transpiler == 'babel' && !__global.babelHelpers && load.source.match(babelHelpersRegEx)) {
+ loader._loader.loadedTranspilerRuntime = loader._loader.loadedTranspilerRuntime || false;
+ return loader['import']('babel/external-helpers').then(function() {
+ return source;
+ });
+ }
+ }
+
+ return source;
+ });
+ };
+ });
+
+})();
diff --git a/lib/global-eval.js b/lib/global-eval.js
new file mode 100644
index 000000000..f27efc222
--- /dev/null
+++ b/lib/global-eval.js
@@ -0,0 +1,142 @@
+// we define a __exec for globally-scoped execution
+// used by module format implementations
+var __exec;
+
+(function() {
+
+ var hasBuffer = typeof Buffer != 'undefined';
+ try {
+ if (hasBuffer && new Buffer('a').toString('base64') != 'YQ==')
+ hasBuffer = false;
+ }
+ catch(e) {
+ hasBuffer = false;
+ }
+
+ var sourceMapPrefix = '\n//# sourceMappingURL=data:application/json;base64,';
+ function inlineSourceMap(sourceMapString) {
+ if (hasBuffer)
+ return sourceMapPrefix + new Buffer(sourceMapString).toString('base64');
+ else if (typeof btoa != 'undefined')
+ return sourceMapPrefix + btoa(unescape(encodeURIComponent(sourceMapString)));
+ else
+ return '';
+ }
+
+ function getSource(load, wrap) {
+ var lastLineIndex = load.source.lastIndexOf('\n');
+
+ // wrap ES formats with a System closure for System global encapsulation
+ if (load.metadata.format == 'global')
+ wrap = false;
+
+ var sourceMap = load.metadata.sourceMap;
+ if (sourceMap) {
+ if (typeof sourceMap != 'object')
+ throw new TypeError('load.metadata.sourceMap must be set to an object.');
+
+ sourceMap = JSON.stringify(sourceMap);
+ }
+
+ return (wrap ? '(function(System, SystemJS) {' : '') + load.source + (wrap ? '\n})(System, System);' : '')
+ // adds the sourceURL comment if not already present
+ + (load.source.substr(lastLineIndex, 15) != '\n//# sourceURL='
+ ? '\n//# sourceURL=' + load.address + (sourceMap ? '!transpiled' : '') : '')
+ // add sourceMappingURL if load.metadata.sourceMap is set
+ + (sourceMap && inlineSourceMap(sourceMap) || '');
+ }
+
+ var curLoad;
+
+ // System.register, System.registerDynamic, AMD define pipeline
+ // if currently evalling code here, immediately reduce the registered entry against the load record
+ hook('pushRegister_', function() {
+ return function(register) {
+ if (!curLoad)
+ return false;
+
+ this.reduceRegister_(curLoad, register);
+ return true;
+ };
+ });
+
+ // System clobbering protection (mostly for Traceur)
+ var curSystem;
+ var callCounter = 0;
+ function preExec(loader, load) {
+ curLoad = load;
+ if (callCounter++ == 0)
+ curSystem = __global.System;
+ __global.System = __global.SystemJS = loader;
+ }
+ function postExec() {
+ if (--callCounter == 0)
+ __global.System = __global.SystemJS = curSystem;
+ curLoad = undefined;
+ }
+
+ var useVm;
+ var vm;
+ __exec = function(load) {
+ if (!load.source)
+ return;
+ if ((load.metadata.integrity || load.metadata.nonce) && supportsScriptExec)
+ return scriptExec.call(this, load);
+ try {
+ preExec(this, load);
+ curLoad = load;
+ // global scoped eval for node (avoids require scope leak)
+ if (!vm && this._nodeRequire) {
+ vm = this._nodeRequire('vm');
+ useVm = vm.runInThisContext("typeof System !== 'undefined' && System") === this;
+ }
+ if (useVm)
+ vm.runInThisContext(getSource(load, true), { filename: load.address + (load.metadata.sourceMap ? '!transpiled' : '') });
+ else
+ (0, eval)(getSource(load, true));
+ postExec();
+ }
+ catch(e) {
+ postExec();
+ throw addToError(e, 'Evaluating ' + load.address);
+ }
+ };
+
+ var supportsScriptExec = false;
+ if (isBrowser && typeof document != 'undefined' && document.getElementsByTagName) {
+ if (!(window.chrome && window.chrome.extension || navigator.userAgent.match(/^Node\.js/)))
+ supportsScriptExec = true;
+ }
+
+ // script execution via injecting a script tag into the page
+ // this allows CSP integrity and nonce to be set for CSP environments
+ var head;
+ function scriptExec(load) {
+ if (!head)
+ head = document.head || document.body || document.documentElement;
+
+ var script = document.createElement('script');
+ script.text = getSource(load, false);
+ var onerror = window.onerror;
+ var e;
+ window.onerror = function(_e) {
+ e = addToError(_e, 'Evaluating ' + load.address);
+ if (onerror)
+ onerror.apply(this, arguments);
+ }
+ preExec(this, load);
+
+ if (load.metadata.integrity)
+ script.setAttribute('integrity', load.metadata.integrity);
+ if (load.metadata.nonce)
+ script.setAttribute('nonce', load.metadata.nonce);
+
+ head.appendChild(script);
+ head.removeChild(script);
+ postExec();
+ window.onerror = onerror;
+ if (e)
+ throw e;
+ }
+
+})();
diff --git a/lib/global-helpers.js b/lib/global-helpers.js
new file mode 100644
index 000000000..2e87f0882
--- /dev/null
+++ b/lib/global-helpers.js
@@ -0,0 +1,147 @@
+
+
+function getGlobalValue(exports) {
+ if (typeof exports == 'string')
+ return readMemberExpression(exports, __global);
+
+ if (!(exports instanceof Array))
+ throw new Error('Global exports must be a string or array.');
+
+ var globalValue = {};
+ var first = true;
+ for (var i = 0; i < exports.length; i++) {
+ var val = readMemberExpression(exports[i], __global);
+ if (first) {
+ globalValue['default'] = val;
+ first = false;
+ }
+ globalValue[exports[i].split('.').pop()] = val;
+ }
+ return globalValue;
+}
+
+hook('reduceRegister_', function(reduceRegister) {
+ return function(load, register) {
+ if (register || (!load.metadata.exports && !(isWorker && load.metadata.format == 'global')))
+ return reduceRegister.call(this, load, register);
+
+ load.metadata.format = 'global';
+ var entry = load.metadata.entry = createEntry();
+ entry.deps = load.metadata.deps;
+ var globalValue = getGlobalValue(load.metadata.exports);
+ entry.execute = function() {
+ return globalValue;
+ };
+ };
+});
+
+hookConstructor(function(constructor) {
+ return function() {
+ var loader = this;
+ constructor.call(loader);
+
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
+
+ // bare minimum ignores
+ var ignoredGlobalProps = ['_g', 'sessionStorage', 'localStorage', 'clipboardData', 'frames', 'frameElement', 'external',
+ 'mozAnimationStartTime', 'webkitStorageInfo', 'webkitIndexedDB', 'mozInnerScreenY', 'mozInnerScreenX'];
+
+ var globalSnapshot;
+
+ function forEachGlobal(callback) {
+ if (Object.keys)
+ Object.keys(__global).forEach(callback);
+ else
+ for (var g in __global) {
+ if (!hasOwnProperty.call(__global, g))
+ continue;
+ callback(g);
+ }
+ }
+
+ function forEachGlobalValue(callback) {
+ forEachGlobal(function(globalName) {
+ if (indexOf.call(ignoredGlobalProps, globalName) != -1)
+ return;
+ try {
+ var value = __global[globalName];
+ }
+ catch (e) {
+ ignoredGlobalProps.push(globalName);
+ }
+ callback(globalName, value);
+ });
+ }
+
+ loader.set('@@global-helpers', loader.newModule({
+ prepareGlobal: function(moduleName, exports, globals, encapsulate) {
+ // disable module detection
+ var curDefine = __global.define;
+
+ __global.define = undefined;
+
+ // set globals
+ var oldGlobals;
+ if (globals) {
+ oldGlobals = {};
+ for (var g in globals) {
+ oldGlobals[g] = __global[g];
+ __global[g] = globals[g];
+ }
+ }
+
+ // store a complete copy of the global object in order to detect changes
+ if (!exports) {
+ globalSnapshot = {};
+
+ forEachGlobalValue(function(name, value) {
+ globalSnapshot[name] = value;
+ });
+ }
+
+ // return function to retrieve global
+ return function() {
+ var globalValue = exports ? getGlobalValue(exports) : {};
+
+ var singleGlobal;
+ var multipleExports = !!exports;
+
+ if (!exports || encapsulate)
+ forEachGlobalValue(function(name, value) {
+ if (globalSnapshot[name] === value)
+ return;
+ if (typeof value == 'undefined')
+ return;
+
+ // allow global encapsulation where globals are removed
+ if (encapsulate)
+ __global[name] = undefined;
+
+ if (!exports) {
+ globalValue[name] = value;
+
+ if (typeof singleGlobal != 'undefined') {
+ if (!multipleExports && singleGlobal !== value)
+ multipleExports = true;
+ }
+ else {
+ singleGlobal = value;
+ }
+ }
+ });
+
+ globalValue = multipleExports ? globalValue : singleGlobal;
+
+ // revert globals
+ if (oldGlobals) {
+ for (var g in oldGlobals)
+ __global[g] = oldGlobals[g];
+ }
+ __global.define = curDefine;
+
+ return globalValue;
+ };
+ }
+ }));
+ };
+});
diff --git a/lib/global.js b/lib/global.js
new file mode 100644
index 000000000..b86a4d045
--- /dev/null
+++ b/lib/global.js
@@ -0,0 +1,70 @@
+/*
+ SystemJS Global Format
+
+ Supports
+ metadata.deps
+ metadata.globals
+ metadata.exports
+
+ Without metadata.exports, detects writes to the global object.
+*/
+var __globalName = typeof self != 'undefined' ? 'self' : 'global';
+
+hook('fetch', function(fetch) {
+ return function(load) {
+ if (load.metadata.exports && !load.metadata.format)
+ load.metadata.format = 'global';
+ return fetch.call(this, load);
+ };
+});
+
+// ideally we could support script loading for globals, but the issue with that is that
+// we can't do it with AMD support side-by-side since AMD support means defining the
+// global define, and global support means not definining it, yet we don't have any hook
+// into the "pre-execution" phase of a script tag being loaded to handle both cases
+hook('instantiate', function(instantiate) {
+ return function(load) {
+ var loader = this;
+
+ if (!load.metadata.format)
+ load.metadata.format = 'global';
+
+ // global is a fallback module format
+ if (load.metadata.format == 'global' && !load.metadata.entry) {
+
+ var entry = createEntry();
+
+ load.metadata.entry = entry;
+
+ entry.deps = [];
+
+ for (var g in load.metadata.globals) {
+ var gl = load.metadata.globals[g];
+ if (gl)
+ entry.deps.push(gl);
+ }
+
+ entry.execute = function(require, exports, module) {
+
+ var globals;
+ if (load.metadata.globals) {
+ globals = {};
+ for (var g in load.metadata.globals)
+ if (load.metadata.globals[g])
+ globals[g] = require(load.metadata.globals[g]);
+ }
+
+ var exportName = load.metadata.exports;
+
+ if (exportName)
+ load.source += '\n' + __globalName + '["' + exportName + '"] = ' + exportName + ';';
+
+ var retrieveGlobal = loader.get('@@global-helpers').prepareGlobal(module.id, exportName, globals, !!load.metadata.encapsulateGlobal);
+ __exec.call(loader, load);
+
+ return retrieveGlobal();
+ }
+ }
+ return instantiate.call(this, load);
+ };
+});
diff --git a/lib/legacy-transpiler.js b/lib/legacy-transpiler.js
new file mode 100644
index 000000000..79c3d9697
--- /dev/null
+++ b/lib/legacy-transpiler.js
@@ -0,0 +1,86 @@
+/*
+ * Traceur, Babel and TypeScript transpile hook for Loader
+ */
+var transpile = (function() {
+
+ // use Traceur by default
+ Loader.prototype.transpiler = 'traceur';
+
+ function transpile(load) {
+ var self = this;
+
+ return Promise.resolve(__global[self.transpiler == 'typescript' ? 'ts' : self.transpiler]
+ || (self.pluginLoader || self)['import'](self.transpiler))
+ .then(function(transpiler) {
+ if (transpiler.__useDefault)
+ transpiler = transpiler['default'];
+
+ var transpileFunction;
+ if (transpiler.Compiler)
+ transpileFunction = traceurTranspile;
+ else if (transpiler.createLanguageService)
+ transpileFunction = typescriptTranspile;
+ else
+ transpileFunction = babelTranspile;
+
+ // note __moduleName will be part of the transformer meta in future when we have the spec for this
+ return '(function(__moduleName){' + transpileFunction.call(self, load, transpiler) + '\n})("' + load.name + '");\n//# sourceURL=' + load.address + '!transpiled';
+ });
+ };
+
+ function traceurTranspile(load, traceur) {
+ var options = this.traceurOptions || {};
+ options.modules = 'instantiate';
+ options.script = false;
+ if (options.sourceMaps === undefined)
+ options.sourceMaps = 'inline';
+ options.filename = load.address;
+ options.inputSourceMap = load.metadata.sourceMap;
+ options.moduleName = false;
+
+ var compiler = new traceur.Compiler(options);
+
+ return doTraceurCompile(load.source, compiler, options.filename);
+ }
+ function doTraceurCompile(source, compiler, filename) {
+ try {
+ return compiler.compile(source, filename);
+ }
+ catch(e) {
+ // on older versions of traceur (<0.9.3), an array of errors is thrown
+ // rather than a single error.
+ if (e.length) {
+ throw e[0];
+ }
+ throw e;
+ }
+ }
+
+ function babelTranspile(load, babel) {
+ var options = this.babelOptions || {};
+ options.modules = 'system';
+ if (options.sourceMap === undefined)
+ options.sourceMap = 'inline';
+ options.inputSourceMap = load.metadata.sourceMap;
+ options.filename = load.address;
+ options.code = true;
+ options.ast = false;
+
+ return babel.transform(load.source, options).code;
+ }
+
+ function typescriptTranspile(load, ts) {
+ var options = this.typescriptOptions || {};
+ options.target = options.target || ts.ScriptTarget.ES5;
+ if (options.sourceMap === undefined)
+ options.sourceMap = true;
+ if (options.sourceMap && options.inlineSourceMap !== false)
+ options.inlineSourceMap = true;
+
+ options.module = ts.ModuleKind.System;
+
+ return ts.transpile(load.source, options, load.address);
+ }
+
+ return transpile;
+})();
diff --git a/lib/loader-wrapper-end.js b/lib/loader-wrapper-end.js
new file mode 100644
index 000000000..d10bbad1f
--- /dev/null
+++ b/lib/loader-wrapper-end.js
@@ -0,0 +1,6 @@
+ if (typeof module == 'object' && module.exports && typeof exports == 'object')
+ module.exports = System;
+
+ __global.System = System;
+
+})(typeof self != 'undefined' ? self : global); \ No newline at end of file
diff --git a/lib/loader-wrapper-start.js b/lib/loader-wrapper-start.js
new file mode 100644
index 000000000..147820c09
--- /dev/null
+++ b/lib/loader-wrapper-start.js
@@ -0,0 +1,913 @@
+(function(__global) {
+
+ var isWorker = typeof window == 'undefined' && typeof self != 'undefined' && typeof importScripts != 'undefined';
+ var isBrowser = typeof window != 'undefined' && typeof document != 'undefined';
+ var isWindows = typeof process != 'undefined' && typeof process.platform != 'undefined' && !!process.platform.match(/^win/);
+
+ if (!__global.console)
+ __global.console = { assert: function() {} };
+
+ // IE8 support
+ var indexOf = Array.prototype.indexOf || function(item) {
+ for (var i = 0, thisLen = this.length; i < thisLen; i++) {
+ if (this[i] === item) {
+ return i;
+ }
+ }
+ return -1;
+ };
+
+ var defineProperty;
+ (function () {
+ try {
+ if (!!Object.defineProperty({}, 'a', {}))
+ defineProperty = Object.defineProperty;
+ }
+ catch (e) {
+ defineProperty = function(obj, prop, opt) {
+ try {
+ obj[prop] = opt.value || opt.get.call(obj);
+ }
+ catch(e) {}
+ }
+ }
+ })();
+
+ var errArgs = new Error(0, '_').fileName == '_';
+
+ function addToError(err, msg) {
+ // parse the stack removing loader code lines for simplification
+ if (!err.originalErr) {
+ var stack = ((err.message || err) + (err.stack ? '\n' + err.stack : '')).toString().split('\n');
+ var newStack = [];
+ for (var i = 0; i < stack.length; i++) {
+ if (typeof $__curScript == 'undefined' || stack[i].indexOf($__curScript.src) == -1)
+ newStack.push(stack[i]);
+ }
+ }
+
+ var newMsg = '(SystemJS) ' + (newStack ? newStack.join('\n\t') : err.message.substr(11)) + '\n\t' + msg;
+
+ // Convert file:/// URLs to paths in Node
+ if (!isBrowser)
+ newMsg = newMsg.replace(isWindows ? /file:\/\/\//g : /file:\/\//g, '');
+
+ var newErr = errArgs ? new Error(newMsg, err.fileName, err.lineNumber) : new Error(newMsg);
+
+ newErr.stack = newMsg;
+
+ // track the original error
+ newErr.originalErr = err.originalErr || err;
+
+ return newErr;
+ }
+
+ function __eval(source, debugName, context) {
+ try {
+ new Function(source).call(context);
+ }
+ catch(e) {
+ throw addToError(e, 'Evaluating ' + debugName);
+ }
+ }
+
+ var baseURI;
+
+ // environent baseURI detection
+ if (typeof document != 'undefined' && document.getElementsByTagName) {
+ baseURI = document.baseURI;
+
+ if (!baseURI) {
+ var bases = document.getElementsByTagName('base');
+ baseURI = bases[0] && bases[0].href || window.location.href;
+ }
+ }
+ else if (typeof location != 'undefined') {
+ baseURI = __global.location.href;
+ }
+
+ // sanitize out the hash and querystring
+ if (baseURI) {
+ baseURI = baseURI.split('#')[0].split('?')[0];
+ baseURI = baseURI.substr(0, baseURI.lastIndexOf('/') + 1);
+ }
+ else if (typeof process != 'undefined' && process.cwd) {
+ baseURI = 'file://' + (isWindows ? '/' : '') + process.cwd() + '/';
+ if (isWindows)
+ baseURI = baseURI.replace(/\\/g, '/');
+ }
+ else {
+ throw new TypeError('No environment baseURI');
+ }
+
+ try {
+ var nativeURL = new __global.URL('test:///').protocol == 'test:';
+ }
+ catch(e) {}
+
+ var URL = nativeURL ? __global.URL : __global.URLPolyfill;
+
+/*
+*********************************************************************************************
+
+ Dynamic Module Loader Polyfill
+
+ - Implemented exactly to the former 2014-08-24 ES6 Specification Draft Rev 27, Section 15
+ http://wiki.ecmascript.org/doku.php?id=harmony:specification_drafts#august_24_2014_draft_rev_27
+
+ - Functions are commented with their spec numbers, with spec differences commented.
+
+ - Spec bugs are commented in this code with links.
+
+ - Abstract functions have been combined where possible, and their associated functions
+ commented.
+
+ - Realm implementation is entirely omitted.
+
+*********************************************************************************************
+*/
+
+function Module() {}
+// http://www.ecma-international.org/ecma-262/6.0/#sec-@@tostringtag
+defineProperty(Module.prototype, 'toString', {
+ value: function() {
+ return 'Module';
+ }
+});
+function Loader(options) {
+ this._loader = {
+ loaderObj: this,
+ loads: [],
+ modules: {},
+ importPromises: {},
+ moduleRecords: {}
+ };
+
+ // 26.3.3.6
+ defineProperty(this, 'global', {
+ get: function() {
+ return __global;
+ }
+ });
+
+ // 26.3.3.13 realm not implemented
+}
+
+(function() {
+
+// Some Helpers
+
+// logs a linkset snapshot for debugging
+/* function snapshot(loader) {
+ console.log('---Snapshot---');
+ for (var i = 0; i < loader.loads.length; i++) {
+ var load = loader.loads[i];
+ var linkSetLog = ' ' + load.name + ' (' + load.status + '): ';
+
+ for (var j = 0; j < load.linkSets.length; j++) {
+ linkSetLog += '{' + logloads(load.linkSets[j].loads) + '} ';
+ }
+ console.log(linkSetLog);
+ }
+ console.log('');
+}
+function logloads(loads) {
+ var log = '';
+ for (var k = 0; k < loads.length; k++)
+ log += loads[k].name + (k != loads.length - 1 ? ' ' : '');
+ return log;
+} */
+
+
+/* function checkInvariants() {
+ // see https://bugs.ecmascript.org/show_bug.cgi?id=2603#c1
+
+ var loads = System._loader.loads;
+ var linkSets = [];
+
+ for (var i = 0; i < loads.length; i++) {
+ var load = loads[i];
+ console.assert(load.status == 'loading' || load.status == 'loaded', 'Each load is loading or loaded');
+
+ for (var j = 0; j < load.linkSets.length; j++) {
+ var linkSet = load.linkSets[j];
+
+ for (var k = 0; k < linkSet.loads.length; k++)
+ console.assert(loads.indexOf(linkSet.loads[k]) != -1, 'linkSet loads are a subset of loader loads');
+
+ if (linkSets.indexOf(linkSet) == -1)
+ linkSets.push(linkSet);
+ }
+ }
+
+ for (var i = 0; i < loads.length; i++) {
+ var load = loads[i];
+ for (var j = 0; j < linkSets.length; j++) {
+ var linkSet = linkSets[j];
+
+ if (linkSet.loads.indexOf(load) != -1)
+ console.assert(load.linkSets.indexOf(linkSet) != -1, 'linkSet contains load -> load contains linkSet');
+
+ if (load.linkSets.indexOf(linkSet) != -1)
+ console.assert(linkSet.loads.indexOf(load) != -1, 'load contains linkSet -> linkSet contains load');
+ }
+ }
+
+ for (var i = 0; i < linkSets.length; i++) {
+ var linkSet = linkSets[i];
+ for (var j = 0; j < linkSet.loads.length; j++) {
+ var load = linkSet.loads[j];
+
+ for (var k = 0; k < load.dependencies.length; k++) {
+ var depName = load.dependencies[k].value;
+ var depLoad;
+ for (var l = 0; l < loads.length; l++) {
+ if (loads[l].name != depName)
+ continue;
+ depLoad = loads[l];
+ break;
+ }
+
+ // loading records are allowed not to have their dependencies yet
+ // if (load.status != 'loading')
+ // console.assert(depLoad, 'depLoad found');
+
+ // console.assert(linkSet.loads.indexOf(depLoad) != -1, 'linkset contains all dependencies');
+ }
+ }
+ }
+} */
+
+ // 15.2.3 - Runtime Semantics: Loader State
+
+ // 15.2.3.11
+ function createLoaderLoad(object) {
+ return {
+ // modules is an object for ES5 implementation
+ modules: {},
+ loads: [],
+ loaderObj: object
+ };
+ }
+
+ // 15.2.3.2 Load Records and LoadRequest Objects
+
+ var anonCnt = 0;
+
+ // 15.2.3.2.1
+ function createLoad(name) {
+ return {
+ status: 'loading',
+ name: name || '<Anonymous' + ++anonCnt + '>',
+ linkSets: [],
+ dependencies: [],
+ metadata: {}
+ };
+ }
+
+ // 15.2.3.2.2 createLoadRequestObject, absorbed into calling functions
+
+ // 15.2.4
+
+ // 15.2.4.1
+ function loadModule(loader, name, options) {
+ return new Promise(asyncStartLoadPartwayThrough({
+ step: options.address ? 'fetch' : 'locate',
+ loader: loader,
+ moduleName: name,
+ // allow metadata for import https://bugs.ecmascript.org/show_bug.cgi?id=3091
+ moduleMetadata: options && options.metadata || {},
+ moduleSource: options.source,
+ moduleAddress: options.address
+ }));
+ }
+
+ // 15.2.4.2
+ function requestLoad(loader, request, refererName, refererAddress) {
+ // 15.2.4.2.1 CallNormalize
+ return new Promise(function(resolve, reject) {
+ resolve(loader.loaderObj.normalize(request, refererName, refererAddress));
+ })
+ // 15.2.4.2.2 GetOrCreateLoad
+ .then(function(name) {
+ var load;
+ if (loader.modules[name]) {
+ load = createLoad(name);
+ load.status = 'linked';
+ // https://bugs.ecmascript.org/show_bug.cgi?id=2795
+ load.module = loader.modules[name];
+ return load;
+ }
+
+ for (var i = 0, l = loader.loads.length; i < l; i++) {
+ load = loader.loads[i];
+ if (load.name != name)
+ continue;
+ return load;
+ }
+
+ load = createLoad(name);
+ loader.loads.push(load);
+
+ proceedToLocate(loader, load);
+
+ return load;
+ });
+ }
+
+ // 15.2.4.3
+ function proceedToLocate(loader, load) {
+ proceedToFetch(loader, load,
+ Promise.resolve()
+ // 15.2.4.3.1 CallLocate
+ .then(function() {
+ return loader.loaderObj.locate({ name: load.name, metadata: load.metadata });
+ })
+ );
+ }
+
+ // 15.2.4.4
+ function proceedToFetch(loader, load, p) {
+ proceedToTranslate(loader, load,
+ p
+ // 15.2.4.4.1 CallFetch
+ .then(function(address) {
+ // adjusted, see https://bugs.ecmascript.org/show_bug.cgi?id=2602
+ if (load.status != 'loading')
+ return;
+ load.address = address;
+
+ return loader.loaderObj.fetch({ name: load.name, metadata: load.metadata, address: address });
+ })
+ );
+ }
+
+ // 15.2.4.5
+ function proceedToTranslate(loader, load, p) {
+ p
+ // 15.2.4.5.1 CallTranslate
+ .then(function(source) {
+ if (load.status != 'loading')
+ return;
+
+ load.address = load.address || load.name;
+
+ return Promise.resolve(loader.loaderObj.translate({ name: load.name, metadata: load.metadata, address: load.address, source: source }))
+
+ // 15.2.4.5.2 CallInstantiate
+ .then(function(source) {
+ load.source = source;
+ return loader.loaderObj.instantiate({ name: load.name, metadata: load.metadata, address: load.address, source: source });
+ })
+
+ // 15.2.4.5.3 InstantiateSucceeded
+ .then(function(instantiateResult) {
+ if (instantiateResult === undefined)
+ throw new TypeError('Declarative modules unsupported in the polyfill.');
+
+ if (typeof instantiateResult != 'object')
+ throw new TypeError('Invalid instantiate return value');
+
+ load.depsList = instantiateResult.deps || [];
+ load.execute = instantiateResult.execute;
+ })
+ // 15.2.4.6 ProcessLoadDependencies
+ .then(function() {
+ load.dependencies = [];
+ var depsList = load.depsList;
+
+ var loadPromises = [];
+ for (var i = 0, l = depsList.length; i < l; i++) (function(request, index) {
+ loadPromises.push(
+ requestLoad(loader, request, load.name, load.address)
+
+ // 15.2.4.6.1 AddDependencyLoad (load is parentLoad)
+ .then(function(depLoad) {
+
+ // adjusted from spec to maintain dependency order
+ // this is due to the System.register internal implementation needs
+ load.dependencies[index] = {
+ key: request,
+ value: depLoad.name
+ };
+
+ if (depLoad.status != 'linked') {
+ var linkSets = load.linkSets.concat([]);
+ for (var i = 0, l = linkSets.length; i < l; i++)
+ addLoadToLinkSet(linkSets[i], depLoad);
+ }
+
+ // console.log('AddDependencyLoad ' + depLoad.name + ' for ' + load.name);
+ // snapshot(loader);
+ })
+ );
+ })(depsList[i], i);
+
+ return Promise.all(loadPromises);
+ })
+
+ // 15.2.4.6.2 LoadSucceeded
+ .then(function() {
+ // console.log('LoadSucceeded ' + load.name);
+ // snapshot(loader);
+
+ load.status = 'loaded';
+
+ var linkSets = load.linkSets.concat([]);
+ for (var i = 0, l = linkSets.length; i < l; i++)
+ updateLinkSetOnLoad(linkSets[i], load);
+ });
+ })
+ // 15.2.4.5.4 LoadFailed
+ ['catch'](function(exc) {
+ load.status = 'failed';
+ load.exception = exc;
+
+ var linkSets = load.linkSets.concat([]);
+ for (var i = 0, l = linkSets.length; i < l; i++) {
+ linkSetFailed(linkSets[i], load, exc);
+ }
+
+ console.assert(load.linkSets.length == 0, 'linkSets not removed');
+ });
+ }
+
+ // 15.2.4.7 PromiseOfStartLoadPartwayThrough absorbed into calling functions
+
+ // 15.2.4.7.1
+ function asyncStartLoadPartwayThrough(stepState) {
+ return function(resolve, reject) {
+ var loader = stepState.loader;
+ var name = stepState.moduleName;
+ var step = stepState.step;
+
+ if (loader.modules[name])
+ throw new TypeError('"' + name + '" already exists in the module table');
+
+ // adjusted to pick up existing loads
+ var existingLoad;
+ for (var i = 0, l = loader.loads.length; i < l; i++) {
+ if (loader.loads[i].name == name) {
+ existingLoad = loader.loads[i];
+
+ if (step == 'translate' && !existingLoad.source) {
+ existingLoad.address = stepState.moduleAddress;
+ proceedToTranslate(loader, existingLoad, Promise.resolve(stepState.moduleSource));
+ }
+
+ // a primary load -> use that existing linkset if it is for the direct load here
+ // otherwise create a new linkset unit
+ if (existingLoad.linkSets.length && existingLoad.linkSets[0].loads[0].name == existingLoad.name)
+ return existingLoad.linkSets[0].done.then(function() {
+ resolve(existingLoad);
+ });
+ }
+ }
+
+ var load = existingLoad || createLoad(name);
+
+ load.metadata = stepState.moduleMetadata;
+
+ var linkSet = createLinkSet(loader, load);
+
+ loader.loads.push(load);
+
+ resolve(linkSet.done);
+
+ if (step == 'locate')
+ proceedToLocate(loader, load);
+
+ else if (step == 'fetch')
+ proceedToFetch(loader, load, Promise.resolve(stepState.moduleAddress));
+
+ else {
+ console.assert(step == 'translate', 'translate step');
+ load.address = stepState.moduleAddress;
+ proceedToTranslate(loader, load, Promise.resolve(stepState.moduleSource));
+ }
+ }
+ }
+
+ // Declarative linking functions run through alternative implementation:
+ // 15.2.5.1.1 CreateModuleLinkageRecord not implemented
+ // 15.2.5.1.2 LookupExport not implemented
+ // 15.2.5.1.3 LookupModuleDependency not implemented
+
+ // 15.2.5.2.1
+ function createLinkSet(loader, startingLoad) {
+ var linkSet = {
+ loader: loader,
+ loads: [],
+ startingLoad: startingLoad, // added see spec bug https://bugs.ecmascript.org/show_bug.cgi?id=2995
+ loadingCount: 0
+ };
+ linkSet.done = new Promise(function(resolve, reject) {
+ linkSet.resolve = resolve;
+ linkSet.reject = reject;
+ });
+ addLoadToLinkSet(linkSet, startingLoad);
+ return linkSet;
+ }
+ // 15.2.5.2.2
+ function addLoadToLinkSet(linkSet, load) {
+ if (load.status == 'failed')
+ return;
+
+ for (var i = 0, l = linkSet.loads.length; i < l; i++)
+ if (linkSet.loads[i] == load)
+ return;
+
+ linkSet.loads.push(load);
+ load.linkSets.push(linkSet);
+
+ // adjustment, see https://bugs.ecmascript.org/show_bug.cgi?id=2603
+ if (load.status != 'loaded') {
+ linkSet.loadingCount++;
+ }
+
+ var loader = linkSet.loader;
+
+ for (var i = 0, l = load.dependencies.length; i < l; i++) {
+ if (!load.dependencies[i])
+ continue;
+
+ var name = load.dependencies[i].value;
+
+ if (loader.modules[name])
+ continue;
+
+ for (var j = 0, d = loader.loads.length; j < d; j++) {
+ if (loader.loads[j].name != name)
+ continue;
+
+ addLoadToLinkSet(linkSet, loader.loads[j]);
+ break;
+ }
+ }
+ // console.log('add to linkset ' + load.name);
+ // snapshot(linkSet.loader);
+ }
+
+ // linking errors can be generic or load-specific
+ // this is necessary for debugging info
+ function doLink(linkSet) {
+ var error = false;
+ try {
+ link(linkSet, function(load, exc) {
+ linkSetFailed(linkSet, load, exc);
+ error = true;
+ });
+ }
+ catch(e) {
+ linkSetFailed(linkSet, null, e);
+ error = true;
+ }
+ return error;
+ }
+
+ // 15.2.5.2.3
+ function updateLinkSetOnLoad(linkSet, load) {
+ // console.log('update linkset on load ' + load.name);
+ // snapshot(linkSet.loader);
+
+ console.assert(load.status == 'loaded' || load.status == 'linked', 'loaded or linked');
+
+ linkSet.loadingCount--;
+
+ if (linkSet.loadingCount > 0)
+ return;
+
+ // adjusted for spec bug https://bugs.ecmascript.org/show_bug.cgi?id=2995
+ var startingLoad = linkSet.startingLoad;
+
+ // non-executing link variation for loader tracing
+ // on the server. Not in spec.
+ /***/
+ if (linkSet.loader.loaderObj.execute === false) {
+ var loads = [].concat(linkSet.loads);
+ for (var i = 0, l = loads.length; i < l; i++) {
+ var load = loads[i];
+ load.module = {
+ name: load.name,
+ module: _newModule({}),
+ evaluated: true
+ };
+ load.status = 'linked';
+ finishLoad(linkSet.loader, load);
+ }
+ return linkSet.resolve(startingLoad);
+ }
+ /***/
+
+ var abrupt = doLink(linkSet);
+
+ if (abrupt)
+ return;
+
+ console.assert(linkSet.loads.length == 0, 'loads cleared');
+
+ linkSet.resolve(startingLoad);
+ }
+
+ // 15.2.5.2.4
+ function linkSetFailed(linkSet, load, exc) {
+ var loader = linkSet.loader;
+ var requests;
+
+ checkError:
+ if (load) {
+ if (linkSet.loads[0].name == load.name) {
+ exc = addToError(exc, 'Error loading ' + load.name);
+ }
+ else {
+ for (var i = 0; i < linkSet.loads.length; i++) {
+ var pLoad = linkSet.loads[i];
+ for (var j = 0; j < pLoad.dependencies.length; j++) {
+ var dep = pLoad.dependencies[j];
+ if (dep.value == load.name) {
+ exc = addToError(exc, 'Error loading ' + load.name + ' as "' + dep.key + '" from ' + pLoad.name);
+ break checkError;
+ }
+ }
+ }
+ exc = addToError(exc, 'Error loading ' + load.name + ' from ' + linkSet.loads[0].name);
+ }
+ }
+ else {
+ exc = addToError(exc, 'Error linking ' + linkSet.loads[0].name);
+ }
+
+
+ var loads = linkSet.loads.concat([]);
+ for (var i = 0, l = loads.length; i < l; i++) {
+ var load = loads[i];
+
+ // store all failed load records
+ loader.loaderObj.failed = loader.loaderObj.failed || [];
+ if (indexOf.call(loader.loaderObj.failed, load) == -1)
+ loader.loaderObj.failed.push(load);
+
+ var linkIndex = indexOf.call(load.linkSets, linkSet);
+ console.assert(linkIndex != -1, 'link not present');
+ load.linkSets.splice(linkIndex, 1);
+ if (load.linkSets.length == 0) {
+ var globalLoadsIndex = indexOf.call(linkSet.loader.loads, load);
+ if (globalLoadsIndex != -1)
+ linkSet.loader.loads.splice(globalLoadsIndex, 1);
+ }
+ }
+ linkSet.reject(exc);
+ }
+
+ // 15.2.5.2.5
+ function finishLoad(loader, load) {
+ // add to global trace if tracing
+ if (loader.loaderObj.trace) {
+ if (!loader.loaderObj.loads)
+ loader.loaderObj.loads = {};
+ var depMap = {};
+ load.dependencies.forEach(function(dep) {
+ depMap[dep.key] = dep.value;
+ });
+ loader.loaderObj.loads[load.name] = {
+ name: load.name,
+ deps: load.dependencies.map(function(dep){ return dep.key }),
+ depMap: depMap,
+ address: load.address,
+ metadata: load.metadata,
+ source: load.source
+ };
+ }
+ // if not anonymous, add to the module table
+ if (load.name) {
+ console.assert(!loader.modules[load.name] || loader.modules[load.name].module === load.module.module, 'load not in module table');
+ loader.modules[load.name] = load.module;
+ }
+ var loadIndex = indexOf.call(loader.loads, load);
+ if (loadIndex != -1)
+ loader.loads.splice(loadIndex, 1);
+ for (var i = 0, l = load.linkSets.length; i < l; i++) {
+ loadIndex = indexOf.call(load.linkSets[i].loads, load);
+ if (loadIndex != -1)
+ load.linkSets[i].loads.splice(loadIndex, 1);
+ }
+ load.linkSets.splice(0, load.linkSets.length);
+ }
+
+ function doDynamicExecute(linkSet, load, linkError) {
+ try {
+ var module = load.execute();
+ }
+ catch(e) {
+ linkError(load, e);
+ return;
+ }
+ if (!module || !(module instanceof Module))
+ linkError(load, new TypeError('Execution must define a Module instance'));
+ else
+ return module;
+ }
+
+ // 26.3 Loader
+
+ // 26.3.1.1
+ // defined at top
+
+ // importPromises adds ability to import a module twice without error - https://bugs.ecmascript.org/show_bug.cgi?id=2601
+ function createImportPromise(loader, name, promise) {
+ var importPromises = loader._loader.importPromises;
+ return importPromises[name] = promise.then(function(m) {
+ importPromises[name] = undefined;
+ return m;
+ }, function(e) {
+ importPromises[name] = undefined;
+ throw e;
+ });
+ }
+
+ Loader.prototype = {
+ // 26.3.3.1
+ constructor: Loader,
+ // 26.3.3.2
+ define: function(name, source, options) {
+ // check if already defined
+ if (this._loader.importPromises[name])
+ throw new TypeError('Module is already loading.');
+ return createImportPromise(this, name, new Promise(asyncStartLoadPartwayThrough({
+ step: 'translate',
+ loader: this._loader,
+ moduleName: name,
+ moduleMetadata: options && options.metadata || {},
+ moduleSource: source,
+ moduleAddress: options && options.address
+ })));
+ },
+ // 26.3.3.3
+ 'delete': function(name) {
+ var loader = this._loader;
+ delete loader.importPromises[name];
+ delete loader.moduleRecords[name];
+ return loader.modules[name] ? delete loader.modules[name] : false;
+ },
+ // 26.3.3.4 entries not implemented
+ // 26.3.3.5
+ get: function(key) {
+ if (!this._loader.modules[key])
+ return;
+ return this._loader.modules[key].module;
+ },
+ // 26.3.3.7
+ has: function(name) {
+ return !!this._loader.modules[name];
+ },
+ // 26.3.3.8
+ 'import': function(name, parentName, parentAddress) {
+ if (typeof parentName == 'object')
+ parentName = parentName.name;
+
+ // run normalize first
+ var loaderObj = this;
+
+ // added, see https://bugs.ecmascript.org/show_bug.cgi?id=2659
+ return Promise.resolve(loaderObj.normalize(name, parentName))
+ .then(function(name) {
+ var loader = loaderObj._loader;
+
+ if (loader.modules[name])
+ return loader.modules[name].module;
+
+ return loader.importPromises[name] || createImportPromise(loaderObj, name,
+ loadModule(loader, name, {})
+ .then(function(load) {
+ delete loader.importPromises[name];
+ return load.module.module;
+ }));
+ });
+ },
+ // 26.3.3.9 keys not implemented
+ // 26.3.3.10
+ load: function(name) {
+ var loader = this._loader;
+ if (loader.modules[name])
+ return Promise.resolve();
+ return loader.importPromises[name] || createImportPromise(this, name, new Promise(asyncStartLoadPartwayThrough({
+ step: 'locate',
+ loader: loader,
+ moduleName: name,
+ moduleMetadata: {},
+ moduleSource: undefined,
+ moduleAddress: undefined
+ }))
+ .then(function() {
+ delete loader.importPromises[name];
+ }));
+ },
+ // 26.3.3.11
+ module: function(source, options) {
+ var load = createLoad();
+ load.address = options && options.address;
+ var linkSet = createLinkSet(this._loader, load);
+ var sourcePromise = Promise.resolve(source);
+ var loader = this._loader;
+ var p = linkSet.done.then(function() {
+ return load.module.module;
+ });
+ proceedToTranslate(loader, load, sourcePromise);
+ return p;
+ },
+ // 26.3.3.12
+ newModule: function (obj) {
+ if (typeof obj != 'object')
+ throw new TypeError('Expected object');
+
+ var m = new Module();
+
+ var pNames = [];
+ if (Object.getOwnPropertyNames && obj != null)
+ pNames = Object.getOwnPropertyNames(obj);
+ else
+ for (var key in obj)
+ pNames.push(key);
+
+ for (var i = 0; i < pNames.length; i++) (function(key) {
+ defineProperty(m, key, {
+ configurable: false,
+ enumerable: true,
+ get: function () {
+ return obj[key];
+ },
+ set: function() {
+ throw new Error('Module exports cannot be changed externally.');
+ }
+ });
+ })(pNames[i]);
+
+ if (Object.freeze)
+ Object.freeze(m);
+
+ return m;
+ },
+ // 26.3.3.14
+ set: function(name, module) {
+ if (!(module instanceof Module))
+ throw new TypeError('Loader.set(' + name + ', module) must be a module');
+ this._loader.modules[name] = {
+ module: module
+ };
+ },
+ // 26.3.3.15 values not implemented
+ // 26.3.3.16 @@iterator not implemented
+ // 26.3.3.17 @@toStringTag not implemented
+
+ // 26.3.3.18.1
+ normalize: function(name, referrerName, referrerAddress) {},
+ // 26.3.3.18.2
+ locate: function(load) {
+ return load.name;
+ },
+ // 26.3.3.18.3
+ fetch: function(load) {
+ },
+ // 26.3.3.18.4
+ translate: function(load) {
+ return load.source;
+ },
+ // 26.3.3.18.5
+ instantiate: function(load) {
+ }
+ };
+
+ var _newModule = Loader.prototype.newModule;
+
+/*
+ * ES6 Module Declarative Linking Code
+ */
+ function link(linkSet, linkError) {
+
+ var loader = linkSet.loader;
+
+ if (!linkSet.loads.length)
+ return;
+
+ var loads = linkSet.loads.concat([]);
+
+ for (var i = 0; i < loads.length; i++) {
+ var load = loads[i];
+
+ var module = doDynamicExecute(linkSet, load, linkError);
+ if (!module)
+ return;
+ load.module = {
+ name: load.name,
+ module: module
+ };
+ load.status = 'linked';
+
+ finishLoad(loader, load);
+ }
+ }
+
+})();
+
+var System;
+
diff --git a/lib/meta.js b/lib/meta.js
new file mode 100644
index 000000000..24e8b38ce
--- /dev/null
+++ b/lib/meta.js
@@ -0,0 +1,155 @@
+/*
+ * Meta Extension
+ *
+ * Sets default metadata on a load record (load.metadata) from
+ * loader.metadata via SystemJS.meta function.
+ *
+ *
+ * Also provides an inline meta syntax for module meta in source.
+ *
+ * Eg:
+ *
+ * loader.meta({
+ * 'my/module': { deps: ['jquery'] }
+ * 'my/*': { format: 'amd' }
+ * });
+ *
+ * Which in turn populates loader.metadata.
+ *
+ * load.metadata.deps and load.metadata.format will then be set
+ * for 'my/module'
+ *
+ * The same meta could be set with a my/module.js file containing:
+ *
+ * my/module.js
+ * "format amd";
+ * "deps[] jquery";
+ * "globals.some value"
+ * console.log('this is my/module');
+ *
+ * Configuration meta always takes preference to inline meta.
+ *
+ * Multiple matches in wildcards are supported and ammend the meta.
+ *
+ *
+ * The benefits of the function form is that paths are URL-normalized
+ * supporting say
+ *
+ * loader.meta({ './app': { format: 'cjs' } });
+ *
+ * Instead of needing to set against the absolute URL (https://site.com/app.js)
+ *
+ */
+
+(function() {
+
+ hookConstructor(function(constructor) {
+ return function() {
+ this.meta = {};
+ constructor.call(this);
+ };
+ });
+
+ hook('locate', function(locate) {
+ return function(load) {
+ var meta = this.meta;
+ var name = load.name;
+
+ // NB for perf, maybe introduce a fast-path wildcard lookup cache here
+ // which is checked first
+
+ // apply wildcard metas
+ var bestDepth = 0;
+ var wildcardIndex;
+ for (var module in meta) {
+ wildcardIndex = module.indexOf('*');
+ if (wildcardIndex === -1)
+ continue;
+ if (module.substr(0, wildcardIndex) === name.substr(0, wildcardIndex)
+ && module.substr(wildcardIndex + 1) === name.substr(name.length - module.length + wildcardIndex + 1)) {
+ var depth = module.split('/').length;
+ if (depth > bestDepth)
+ bestDepth = depth;
+ extendMeta(load.metadata, meta[module], bestDepth != depth);
+ }
+ }
+
+ // apply exact meta
+ if (meta[name])
+ extendMeta(load.metadata, meta[name]);
+
+ return locate.call(this, load);
+ };
+ });
+
+ // detect any meta header syntax
+ // only set if not already set
+ var metaRegEx = /^(\s*\/\*[^\*]*(\*(?!\/)[^\*]*)*\*\/|\s*\/\/[^\n]*|\s*"[^"]+"\s*;?|\s*'[^']+'\s*;?)+/;
+ var metaPartRegEx = /\/\*[^\*]*(\*(?!\/)[^\*]*)*\*\/|\/\/[^\n]*|"[^"]+"\s*;?|'[^']+'\s*;?/g;
+
+ function setMetaProperty(target, p, value) {
+ var pParts = p.split('.');
+ var curPart;
+ while (pParts.length > 1) {
+ curPart = pParts.shift();
+ target = target[curPart] = target[curPart] || {};
+ }
+ curPart = pParts.shift();
+ if (!(curPart in target))
+ target[curPart] = value;
+ }
+
+ hook('translate', function(translate) {
+ return function(load) {
+ // shortpath for bundled
+ if (load.metadata.format == 'defined') {
+ load.metadata.deps = load.metadata.deps || [];
+ return Promise.resolve(load.source);
+ }
+
+ // NB meta will be post-translate pending transpiler conversion to plugins
+ var meta = load.source.match(metaRegEx);
+ if (meta) {
+ var metaParts = meta[0].match(metaPartRegEx);
+
+ for (var i = 0; i < metaParts.length; i++) {
+ var curPart = metaParts[i];
+ var len = curPart.length;
+
+ var firstChar = curPart.substr(0, 1);
+ if (curPart.substr(len - 1, 1) == ';')
+ len--;
+
+ if (firstChar != '"' && firstChar != "'")
+ continue;
+
+ var metaString = curPart.substr(1, curPart.length - 3);
+ var metaName = metaString.substr(0, metaString.indexOf(' '));
+
+ if (metaName) {
+ var metaValue = metaString.substr(metaName.length + 1, metaString.length - metaName.length - 1);
+
+ if (metaName.substr(metaName.length - 2, 2) == '[]') {
+ metaName = metaName.substr(0, metaName.length - 2);
+ load.metadata[metaName] = load.metadata[metaName] || [];
+ load.metadata[metaName].push(metaValue);
+ }
+ else if (load.metadata[metaName] instanceof Array) {
+ // temporary backwards compat for previous "deps" syntax
+ warn.call(this, 'Module ' + load.name + ' contains deprecated "deps ' + metaValue + '" meta syntax.\nThis should be updated to "deps[] ' + metaValue + '" for pushing to array meta.');
+ load.metadata[metaName].push(metaValue);
+ }
+ else {
+ setMetaProperty(load.metadata, metaName, metaValue);
+ }
+ }
+ else {
+ load.metadata[metaString] = true;
+ }
+ }
+ }
+
+ return translate.apply(this, arguments);
+ };
+ });
+})();
diff --git a/lib/package.js b/lib/package.js
new file mode 100644
index 000000000..cdd3815e9
--- /dev/null
+++ b/lib/package.js
@@ -0,0 +1,596 @@
+/*
+ * Package Configuration Extension
+ *
+ * Example:
+ *
+ * SystemJS.packages = {
+ * jquery: {
+ * main: 'index.js', // when not set, package name is requested directly
+ * format: 'amd',
+ * defaultExtension: 'ts', // defaults to 'js', can be set to false
+ * modules: {
+ * '*.ts': {
+ * loader: 'typescript'
+ * },
+ * 'vendor/sizzle.js': {
+ * format: 'global'
+ * }
+ * },
+ * map: {
+ * // map internal require('sizzle') to local require('./vendor/sizzle')
+ * sizzle: './vendor/sizzle.js',
+ * // map any internal or external require of 'jquery/vendor/another' to 'another/index.js'
+ * './vendor/another.js': './another/index.js',
+ * // test.js / test -> lib/test.js
+ * './test.js': './lib/test.js',
+ *
+ * // environment-specific map configurations
+ * './index.js': {
+ * '~browser': './index-node.js',
+ * './custom-condition.js|~export': './index-custom.js'
+ * }
+ * },
+ * // allows for setting package-prefixed depCache
+ * // keys are normalized module names relative to the package itself
+ * depCache: {
+ * // import 'package/index.js' loads in parallel package/lib/test.js,package/vendor/sizzle.js
+ * './index.js': ['./test'],
+ * './test.js': ['external-dep'],
+ * 'external-dep/path.js': ['./another.js']
+ * }
+ * }
+ * };
+ *
+ * Then:
+ * import 'jquery' -> jquery/index.js
+ * import 'jquery/submodule' -> jquery/submodule.js
+ * import 'jquery/submodule.ts' -> jquery/submodule.ts loaded as typescript
+ * import 'jquery/vendor/another' -> another/index.js
+ *
+ * Detailed Behaviours
+ * - main can have a leading "./" can be added optionally
+ * - map and defaultExtension are applied to the main
+ * - defaultExtension adds the extension only if the exact extension is not present
+ * - defaultJSExtensions applies after map when defaultExtension is not set
+ * - if a meta value is available for a module, map and defaultExtension are skipped
+ * - like global map, package map also applies to subpaths (sizzle/x, ./vendor/another/sub)
+ * - condition module map is '@env' module in package or '@system-env' globally
+ * - map targets support conditional interpolation ('./x': './x.#{|env}.js')
+ * - internal package map targets cannot use boolean conditionals
+ *
+ * Package Configuration Loading
+ *
+ * Not all packages may already have their configuration present in the System config
+ * For these cases, a list of packageConfigPaths can be provided, which when matched against
+ * a request, will first request a ".json" file by the package name to derive the package
+ * configuration from. This allows dynamic loading of non-predetermined code, a key use
+ * case in SystemJS.
+ *
+ * Example:
+ *
+ * SystemJS.packageConfigPaths = ['packages/test/package.json', 'packages/*.json'];
+ *
+ * // will first request 'packages/new-package/package.json' for the package config
+ * // before completing the package request to 'packages/new-package/path'
+ * SystemJS.import('packages/new-package/path');
+ *
+ * // will first request 'packages/test/package.json' before the main
+ * SystemJS.import('packages/test');
+ *
+ * When a package matches packageConfigPaths, it will always send a config request for
+ * the package configuration.
+ * The package name itself is taken to be the match up to and including the last wildcard
+ * or trailing slash.
+ * The most specific package config path will be used.
+ * Any existing package configurations for the package will deeply merge with the
+ * package config, with the existing package configurations taking preference.
+ * To opt-out of the package configuration request for a package that matches
+ * packageConfigPaths, use the { configured: true } package config option.
+ *
+ */
+(function() {
+
+ hookConstructor(function(constructor) {
+ return function() {
+ constructor.call(this);
+ this.packages = {};
+ this.packageConfigPaths = [];
+ };
+ });
+
+ function getPackage(loader, normalized) {
+ // use most specific package
+ var curPkg, curPkgLen = 0, pkgLen;
+ for (var p in loader.packages) {
+ if (normalized.substr(0, p.length) === p && (normalized.length === p.length || normalized[p.length] === '/')) {
+ pkgLen = p.split('/').length;
+ if (pkgLen > curPkgLen) {
+ curPkg = p;
+ curPkgLen = pkgLen;
+ }
+ }
+ }
+ return curPkg;
+ }
+
+ function addDefaultExtension(loader, pkg, pkgName, subPath, skipExtensions) {
+ // don't apply extensions to folders or if defaultExtension = false
+ if (!subPath || subPath[subPath.length - 1] == '/' || skipExtensions || pkg.defaultExtension === false)
+ return subPath;
+
+ var metaMatch = false;
+
+ // exact meta or meta with any content after the last wildcard skips extension
+ if (pkg.meta)
+ getMetaMatches(pkg.meta, subPath, function(metaPattern, matchMeta, matchDepth) {
+ if (matchDepth == 0 || metaPattern.lastIndexOf('*') != metaPattern.length - 1)
+ return metaMatch = true;
+ });
+
+ // exact global meta or meta with any content after the last wildcard skips extension
+ if (!metaMatch && loader.meta)
+ getMetaMatches(loader.meta, pkgName + '/' + subPath, function(metaPattern, matchMeta, matchDepth) {
+ if (matchDepth == 0 || metaPattern.lastIndexOf('*') != metaPattern.length - 1)
+ return metaMatch = true;
+ });
+
+ if (metaMatch)
+ return subPath;
+
+ // work out what the defaultExtension is and add if not there already
+ // NB reconsider if default should really be ".js"?
+ var defaultExtension = '.' + (pkg.defaultExtension || 'js');
+ if (subPath.substr(subPath.length - defaultExtension.length) != defaultExtension)
+ return subPath + defaultExtension;
+ else
+ return subPath;
+ }
+
+ function applyPackageConfigSync(loader, pkg, pkgName, subPath, skipExtensions) {
+ // main
+ if (!subPath) {
+ if (pkg.main)
+ subPath = pkg.main.substr(0, 2) == './' ? pkg.main.substr(2) : pkg.main;
+ // also no submap if name is package itself (import 'pkg' -> 'path/to/pkg.js')
+ else
+ // NB can add a default package main convention here when defaultJSExtensions is deprecated
+ // if it becomes internal to the package then it would no longer be an exit path
+ return pkgName + (loader.defaultJSExtensions ? '.js' : '');
+ }
+
+ // map config checking without then with extensions
+ if (pkg.map) {
+ var mapPath = './' + subPath;
+
+ var mapMatch = getMapMatch(pkg.map, mapPath);
+
+ // we then check map with the default extension adding
+ if (!mapMatch) {
+ mapPath = './' + addDefaultExtension(loader, pkg, pkgName, subPath, skipExtensions);
+ if (mapPath != './' + subPath)
+ mapMatch = getMapMatch(pkg.map, mapPath);
+ }
+ if (mapMatch) {
+ var mapped = doMapSync(loader, pkg, pkgName, mapMatch, mapPath, skipExtensions);
+ if (mapped)
+ return mapped;
+ }
+ }
+
+ // normal package resolution
+ return pkgName + '/' + addDefaultExtension(loader, pkg, pkgName, subPath, skipExtensions);
+ }
+
+ function validMapping(mapMatch, mapped, pkgName, path) {
+ // disallow internal to subpath maps
+ if (mapMatch == '.')
+ throw new Error('Package ' + pkgName + ' has a map entry for "." which is not permitted.');
+
+ // allow internal ./x -> ./x/y or ./x/ -> ./x/y recursive maps
+ // but only if the path is exactly ./x and not ./x/z
+ if (mapped.substr(0, mapMatch.length) == mapMatch && path.length > mapMatch.length)
+ return false;
+
+ return true;
+ }
+
+ function doMapSync(loader, pkg, pkgName, mapMatch, path, skipExtensions) {
+ if (path[path.length - 1] == '/')
+ path = path.substr(0, path.length - 1);
+ var mapped = pkg.map[mapMatch];
+
+ if (typeof mapped == 'object')
+ throw new Error('Synchronous conditional normalization not supported sync normalizing ' + mapMatch + ' in ' + pkgName);
+
+ if (!validMapping(mapMatch, mapped, pkgName, path) || typeof mapped != 'string')
+ return;
+
+ // package map to main / base-level
+ if (mapped == '.')
+ mapped = pkgName;
+
+ // internal package map
+ else if (mapped.substr(0, 2) == './')
+ return pkgName + '/' + addDefaultExtension(loader, pkg, pkgName, mapped.substr(2) + path.substr(mapMatch.length), skipExtensions);
+
+ // external map reference
+ return loader.normalizeSync(mapped + path.substr(mapMatch.length), pkgName + '/');
+ }
+
+ function applyPackageConfig(loader, pkg, pkgName, subPath, skipExtensions) {
+ // main
+ if (!subPath) {
+ if (pkg.main)
+ subPath = pkg.main.substr(0, 2) == './' ? pkg.main.substr(2) : pkg.main;
+ // also no submap if name is package itself (import 'pkg' -> 'path/to/pkg.js')
+ else
+ // NB can add a default package main convention here when defaultJSExtensions is deprecated
+ // if it becomes internal to the package then it would no longer be an exit path
+ return Promise.resolve(pkgName + (loader.defaultJSExtensions ? '.js' : ''));
+ }
+
+ // map config checking without then with extensions
+ var mapPath, mapMatch;
+
+ if (pkg.map) {
+ mapPath = './' + subPath;
+ mapMatch = getMapMatch(pkg.map, mapPath);
+
+ // we then check map with the default extension adding
+ if (!mapMatch) {
+ mapPath = './' + addDefaultExtension(loader, pkg, pkgName, subPath, skipExtensions);
+ if (mapPath != './' + subPath)
+ mapMatch = getMapMatch(pkg.map, mapPath);
+ }
+ }
+
+ return (mapMatch ? doMap(loader, pkg, pkgName, mapMatch, mapPath, skipExtensions) : Promise.resolve())
+ .then(function(mapped) {
+ if (mapped)
+ return Promise.resolve(mapped);
+
+ // normal package resolution / fallback resolution for no conditional match
+ return Promise.resolve(pkgName + '/' + addDefaultExtension(loader, pkg, pkgName, subPath, skipExtensions));
+ });
+ }
+
+ function doStringMap(loader, pkg, pkgName, mapMatch, mapped, path, skipExtensions) {
+ // NB the interpolation cases should strictly skip subsequent interpolation
+ // package map to main / base-level
+ if (mapped == '.')
+ mapped = pkgName;
+
+ // internal package map
+ else if (mapped.substr(0, 2) == './')
+ return Promise.resolve(pkgName + '/' + addDefaultExtension(loader, pkg, pkgName, mapped.substr(2) + path.substr(mapMatch.length), skipExtensions))
+ .then(function(name) {
+ return interpolateConditional.call(loader, name, pkgName + '/');
+ });
+
+ // external map reference
+ return loader.normalize(mapped + path.substr(mapMatch.length), pkgName + '/');
+ }
+
+ function doMap(loader, pkg, pkgName, mapMatch, path, skipExtensions) {
+ if (path[path.length - 1] == '/')
+ path = path.substr(0, path.length - 1);
+
+ var mapped = pkg.map[mapMatch];
+
+ if (typeof mapped == 'string') {
+ if (!validMapping(mapMatch, mapped, pkgName, path))
+ return Promise.resolve();
+ return doStringMap(loader, pkg, pkgName, mapMatch, mapped, path, skipExtensions);
+ }
+
+ // we use a special conditional syntax to allow the builder to handle conditional branch points further
+ if (loader.builder)
+ return Promise.resolve(pkgName + '/#:' + path);
+
+ // we load all conditions upfront
+ var conditionPromises = [];
+ var conditions = [];
+ for (var e in mapped) {
+ var c = parseCondition(e);
+ conditions.push({
+ condition: c,
+ map: mapped[e]
+ });
+ conditionPromises.push(loader['import'](c.module, pkgName));
+ }
+
+ // map object -> conditional map
+ return Promise.all(conditionPromises)
+ .then(function(conditionValues) {
+ // first map condition to match is used
+ for (var i = 0; i < conditions.length; i++) {
+ var c = conditions[i].condition;
+ var value = readMemberExpression(c.prop, conditionValues[i]);
+ if (!c.negate && value || c.negate && !value)
+ return conditions[i].map;
+ }
+ })
+ .then(function(mapped) {
+ if (mapped) {
+ if (!validMapping(mapMatch, mapped, pkgName, path))
+ return;
+ return doStringMap(loader, pkg, pkgName, mapMatch, mapped, path, skipExtensions);
+ }
+
+ // no environment match -> fallback to original subPath by returning undefined
+ });
+ }
+
+ // normalizeSync = decanonicalize + package resolution
+ SystemJSLoader.prototype.normalizeSync = SystemJSLoader.prototype.decanonicalize = SystemJSLoader.prototype.normalize;
+
+ // decanonicalize must JUST handle package defaultExtension: false case when defaultJSExtensions is set
+ // to be deprecated!
+ hook('decanonicalize', function(decanonicalize) {
+ return function(name, parentName) {
+ if (this.builder)
+ return decanonicalize.call(this, name, parentName, true);
+
+ var decanonicalized = decanonicalize.call(this, name, parentName, false);
+
+ if (!this.defaultJSExtensions)
+ return decanonicalized;
+
+ var pkgName = getPackage(this, decanonicalized);
+
+ var pkg = this.packages[pkgName];
+ var defaultExtension = pkg && pkg.defaultExtension;
+
+ if (defaultExtension == undefined && pkg && pkg.meta)
+ getMetaMatches(pkg.meta, decanonicalized.substr(pkgName), function(metaPattern, matchMeta, matchDepth) {
+ if (matchDepth == 0 || metaPattern.lastIndexOf('*') != metaPattern.length - 1) {
+ defaultExtension = false;
+ return true;
+ }
+ });
+
+ if ((defaultExtension === false || defaultExtension && defaultExtension != '.js') && name.substr(name.length - 3, 3) != '.js' && decanonicalized.substr(decanonicalized.length - 3, 3) == '.js')
+ decanonicalized = decanonicalized.substr(0, decanonicalized.length - 3);
+
+ return decanonicalized;
+ };
+ });
+
+ hook('normalizeSync', function(normalizeSync) {
+ return function(name, parentName, isPlugin) {
+ var loader = this;
+ isPlugin = isPlugin === true;
+
+ // apply contextual package map first
+ // (we assume the parent package config has already been loaded)
+ if (parentName)
+ var parentPackageName = getPackage(loader, parentName) ||
+ loader.defaultJSExtensions && parentName.substr(parentName.length - 3, 3) == '.js' &&
+ getPackage(loader, parentName.substr(0, parentName.length - 3));
+
+ var parentPackage = parentPackageName && loader.packages[parentPackageName];
+
+ // ignore . since internal maps handled by standard package resolution
+ if (parentPackage && name[0] != '.') {
+ var parentMap = parentPackage.map;
+ var parentMapMatch = parentMap && getMapMatch(parentMap, name);
+
+ if (parentMapMatch && typeof parentMap[parentMapMatch] == 'string') {
+ var mapped = doMapSync(loader, parentPackage, parentPackageName, parentMapMatch, name, isPlugin);
+ if (mapped)
+ return mapped;
+ }
+ }
+
+ var defaultJSExtension = loader.defaultJSExtensions && name.substr(name.length - 3, 3) != '.js';
+
+ // apply map, core, paths, contextual package map
+ var normalized = normalizeSync.call(loader, name, parentName, false);
+
+ // undo defaultJSExtension
+ if (defaultJSExtension && normalized.substr(normalized.length - 3, 3) != '.js')
+ defaultJSExtension = false;
+ if (defaultJSExtension)
+ normalized = normalized.substr(0, normalized.length - 3);
+
+ var pkgConfigMatch = getPackageConfigMatch(loader, normalized);
+ var pkgName = pkgConfigMatch && pkgConfigMatch.packageName || getPackage(loader, normalized);
+
+ if (!pkgName)
+ return normalized + (defaultJSExtension ? '.js' : '');
+
+ var subPath = normalized.substr(pkgName.length + 1);
+
+ return applyPackageConfigSync(loader, loader.packages[pkgName] || {}, pkgName, subPath, isPlugin);
+ };
+ });
+
+ hook('normalize', function(normalize) {
+ return function(name, parentName, isPlugin) {
+ var loader = this;
+ isPlugin = isPlugin === true;
+
+ return Promise.resolve()
+ .then(function() {
+ // apply contextual package map first
+ // (we assume the parent package config has already been loaded)
+ if (parentName)
+ var parentPackageName = getPackage(loader, parentName) ||
+ loader.defaultJSExtensions && parentName.substr(parentName.length - 3, 3) == '.js' &&
+ getPackage(loader, parentName.substr(0, parentName.length - 3));
+
+ var parentPackage = parentPackageName && loader.packages[parentPackageName];
+
+ // ignore . since internal maps handled by standard package resolution
+ if (parentPackage && name.substr(0, 2) != './') {
+ var parentMap = parentPackage.map;
+ var parentMapMatch = parentMap && getMapMatch(parentMap, name);
+
+ if (parentMapMatch)
+ return doMap(loader, parentPackage, parentPackageName, parentMapMatch, name, isPlugin);
+ }
+
+ return Promise.resolve();
+ })
+ .then(function(mapped) {
+ if (mapped)
+ return mapped;
+
+ var defaultJSExtension = loader.defaultJSExtensions && name.substr(name.length - 3, 3) != '.js';
+
+ // apply map, core, paths, contextual package map
+ var normalized = normalize.call(loader, name, parentName, false);
+
+ // undo defaultJSExtension
+ if (defaultJSExtension && normalized.substr(normalized.length - 3, 3) != '.js')
+ defaultJSExtension = false;
+ if (defaultJSExtension)
+ normalized = normalized.substr(0, normalized.length - 3);
+
+ var pkgConfigMatch = getPackageConfigMatch(loader, normalized);
+ var pkgName = pkgConfigMatch && pkgConfigMatch.packageName || getPackage(loader, normalized);
+
+ if (!pkgName)
+ return Promise.resolve(normalized + (defaultJSExtension ? '.js' : ''));
+
+ var pkg = loader.packages[pkgName];
+
+ // if package is already configured or not a dynamic config package, use existing package config
+ var isConfigured = pkg && (pkg.configured || !pkgConfigMatch);
+ return (isConfigured ? Promise.resolve(pkg) : loadPackageConfigPath(loader, pkgName, pkgConfigMatch.configPath))
+ .then(function(pkg) {
+ var subPath = normalized.substr(pkgName.length + 1);
+
+ return applyPackageConfig(loader, pkg, pkgName, subPath, isPlugin);
+ });
+ });
+ };
+ });
+
+ // check if the given normalized name matches a packageConfigPath
+ // if so, loads the config
+ var packageConfigPaths = {};
+
+ // data object for quick checks against package paths
+ function createPkgConfigPathObj(path) {
+ var lastWildcard = path.lastIndexOf('*');
+ var length = Math.max(lastWildcard + 1, path.lastIndexOf('/'));
+ return {
+ length: length,
+ regEx: new RegExp('^(' + path.substr(0, length).replace(/[.+?^${}()|[\]\\]/g, '\\$&').replace(/\*/g, '[^\\/]+') + ')(\\/|$)'),
+ wildcard: lastWildcard != -1
+ };
+ }
+
+ // most specific match wins
+ function getPackageConfigMatch(loader, normalized) {
+ var pkgName, exactMatch = false, configPath;
+ for (var i = 0; i < loader.packageConfigPaths.length; i++) {
+ var packageConfigPath = loader.packageConfigPaths[i];
+ var p = packageConfigPaths[packageConfigPath] || (packageConfigPaths[packageConfigPath] = createPkgConfigPathObj(packageConfigPath));
+ if (normalized.length < p.length)
+ continue;
+ var match = normalized.match(p.regEx);
+ if (match && (!pkgName || (!(exactMatch && p.wildcard) && pkgName.length < match[1].length))) {
+ pkgName = match[1];
+ exactMatch = !p.wildcard;
+ configPath = pkgName + packageConfigPath.substr(p.length);
+ }
+ }
+
+ if (!pkgName)
+ return;
+
+ return {
+ packageName: pkgName,
+ configPath: configPath
+ };
+ }
+
+ function loadPackageConfigPath(loader, pkgName, pkgConfigPath) {
+ var configLoader = loader.pluginLoader || loader;
+
+ // NB remove this when json is default
+ (configLoader.meta[pkgConfigPath] = configLoader.meta[pkgConfigPath] || {}).format = 'json';
+ configLoader.meta[pkgConfigPath].loader = null;
+
+ return configLoader.load(pkgConfigPath)
+ .then(function() {
+ var cfg = configLoader.get(pkgConfigPath)['default'];
+
+ // support "systemjs" prefixing
+ if (cfg.systemjs)
+ cfg = cfg.systemjs;
+
+ // modules backwards compatibility
+ if (cfg.modules) {
+ cfg.meta = cfg.modules;
+ warn.call(loader, 'Package config file ' + pkgConfigPath + ' is configured with "modules", which is deprecated as it has been renamed to "meta".');
+ }
+
+ return setPkgConfig(loader, pkgName, cfg, true);
+ });
+ }
+
+ function getMetaMatches(pkgMeta, subPath, matchFn) {
+ // wildcard meta
+ var meta = {};
+ var wildcardIndex;
+ for (var module in pkgMeta) {
+ // allow meta to start with ./ for flexibility
+ var dotRel = module.substr(0, 2) == './' ? './' : '';
+ if (dotRel)
+ module = module.substr(2);
+
+ wildcardIndex = module.indexOf('*');
+ if (wildcardIndex === -1)
+ continue;
+
+ if (module.substr(0, wildcardIndex) == subPath.substr(0, wildcardIndex)
+ && module.substr(wildcardIndex + 1) == subPath.substr(subPath.length - module.length + wildcardIndex + 1)) {
+ // alow match function to return true for an exit path
+ if (matchFn(module, pkgMeta[dotRel + module], module.split('/').length))
+ return;
+ }
+ }
+ // exact meta
+ var exactMeta = pkgMeta[subPath] && pkgMeta.hasOwnProperty && pkgMeta.hasOwnProperty(subPath) ? pkgMeta[subPath] : pkgMeta['./' + subPath];
+ if (exactMeta)
+ matchFn(exactMeta, exactMeta, 0);
+ }
+
+ hook('locate', function(locate) {
+ return function(load) {
+ var loader = this;
+ return Promise.resolve(locate.call(this, load))
+ .then(function(address) {
+ var pkgName = getPackage(loader, load.name);
+ if (pkgName) {
+ var pkg = loader.packages[pkgName];
+ var subPath = load.name.substr(pkgName.length + 1);
+
+ var meta = {};
+ if (pkg.meta) {
+ var bestDepth = 0;
+
+ // NB support a main shorthand in meta here?
+ getMetaMatches(pkg.meta, subPath, function(metaPattern, matchMeta, matchDepth) {
+ if (matchDepth > bestDepth)
+ bestDepth = matchDepth;
+ extendMeta(meta, matchMeta, matchDepth && bestDepth > matchDepth);
+ });
+
+ extendMeta(load.metadata, meta);
+ }
+
+ // format
+ if (pkg.format && !load.metadata.loader)
+ load.metadata.format = load.metadata.format || pkg.format;
+ }
+
+ return address;
+ });
+ };
+ });
+
+})();
diff --git a/lib/paths.js b/lib/paths.js
new file mode 100644
index 000000000..5208fe457
--- /dev/null
+++ b/lib/paths.js
@@ -0,0 +1,42 @@
+function applyPaths(paths, name) {
+ // most specific (most number of slashes in path) match wins
+ var pathMatch = '', wildcard, maxWildcardPrefixLen = 0;
+
+ // check to see if we have a paths entry
+ for (var p in paths) {
+ if (paths.hasOwnProperty && !paths.hasOwnProperty(p))
+ continue;
+
+ // exact path match
+ if (p.indexOf('*') === -1) {
+ if (name == p)
+ return paths[p];
+
+ // support trailing / in paths rules
+ else if (name.substr(0, p.length - 1) == p.substr(0, p.length - 1) && (name.length < p.length || name[p.length - 1] == p[p.length - 1]) && (paths[p][paths[p].length - 1] == '/' || paths[p] == '')) {
+ return paths[p].substr(0, paths[p].length - 1) + (name.length > p.length ? (paths[p] && '/' || '') + name.substr(p.length) : '');
+ }
+ }
+ // wildcard path match
+ else {
+ var pathParts = p.split('*');
+ if (pathParts.length > 2)
+ throw new TypeError('Only one wildcard in a path is permitted');
+
+ var wildcardPrefixLen = pathParts[0].length;
+ if (wildcardPrefixLen >= maxWildcardPrefixLen &&
+ name.substr(0, pathParts[0].length) == pathParts[0] &&
+ name.substr(name.length - pathParts[1].length) == pathParts[1]) {
+ maxWildcardPrefixLen = wildcardPrefixLen;
+ pathMatch = p;
+ wildcard = name.substr(pathParts[0].length, name.length - pathParts[1].length - pathParts[0].length);
+ }
+ }
+ }
+
+ var outPath = paths[pathMatch];
+ if (typeof wildcard == 'string')
+ outPath = outPath.replace('*', wildcard);
+
+ return outPath;
+} \ No newline at end of file
diff --git a/lib/perf.js b/lib/perf.js
new file mode 100644
index 000000000..9f0a02fbc
--- /dev/null
+++ b/lib/perf.js
@@ -0,0 +1,227 @@
+/*
+ * SystemJS performance measurement addon
+ *
+ */
+(function() {
+function perfEvent(eventName, eventItem) {
+ var evt = new ProfileEvent(eventName, eventItem);
+ events.push(evt);
+ return evt;
+};
+
+// we extend the hook function itself to create performance instrumentation per extension
+var curHook = hook;
+
+var resolverHooks = ['import', 'normalizeSync', 'decanonicalize', 'normalize'];
+var pipelineHooks = ['locate', 'fetch', 'translate', 'instantiate'];
+hook = function(name, newHook) {
+ // hook information
+ var resolver = resolverHooks.indexOf(name) != -1;
+ var pipeline = pipelineHooks.indexOf(name) != -1;
+ var hookEvtName = name + ':' + newHook.toString().substr(0, 200);
+
+ curHook(name, function(prevHook) {
+ return function() {
+ // this is called when the hook runs
+ var hookItem = resolver ? arguments[0] + ' : ' + arguments[1] + ' : ' + !!arguments[2] : arguments[0] && arguments[0].name;
+ var evt = perfEvent(hookEvtName, hookItem);
+
+ // ignore time spent in the old hook
+ var fn = newHook(function() {
+ evt.pause();
+ var output = prevHook.apply(this, arguments);
+
+ if (output && output.toString && output.toString() == '[object Promise]') {
+ return Promise.resolve(output)
+ .then(function(output) {
+ evt.resume();
+ return output;
+ })
+ .catch(function(err) {
+ evt.resume()
+ throw err;
+ });
+ }
+ else {
+ evt.resume();
+ return output;
+ }
+ });
+
+ var output;
+ try {
+ output = fn.apply(this, arguments);
+ }
+ catch(e) {
+ evt.cancel();
+ throw e;
+ }
+
+ if (output && output.toString && output.toString() == '[object Promise]') {
+ return Promise.resolve(output)
+ .then(function(output) {
+ evt.done();
+ return output;
+ })
+ .catch(function(err) {
+ evt.cancel();
+ throw err;
+ });
+ }
+ else {
+ evt.done();
+ return output;
+ }
+ };
+ });
+};
+
+// profiling events
+var events = [];
+
+var perf = typeof performance != 'undefined' : performance : Date;
+
+// Performance Event class
+function ProfileEvent(name, item) {
+ this.name = name;
+ this.item = (typeof item == 'function' ? item() : item) || 'default';
+ this.start = perf.now();
+ this.stop = null;
+ this.pauseTime = null;
+ this.cancelled = false;
+}
+ProfileEvent.prototype.rename = function(name, item) {
+ this.name = name;
+ if (arguments.length > 1)
+ this.item = item;
+};
+ProfileEvent.prototype.done = function() {
+ if (this.stop)
+ throw new TypeError('Event ' + this.name + ' (' + this.item + ') has already completed.');
+ this.stop = perf.now();
+};
+ProfileEvent.prototype.cancel = function() {
+ this.cancelled = true;
+};
+ProfileEvent.prototype.cancelIfNotDone = function() {
+ if (!this.stop)
+ this.cancelled = true;
+};
+ProfileEvent.prototype.pause = function() {
+ if (this.stop)
+ throw new TypeError('Event ' + this.name + ' (' + this.item + ') cannot be paused as it has finished.');
+ if (!this.pauseTime)
+ this.pauseTime = perf.now();
+};
+ProfileEvent.prototype.resume = function() {
+ if (!this.pauseTime)
+ throw new TypeError('Event ' + this.name + ' (' + this.item + ') is not already paused.');
+ this.start += perf.now() - this.pauseTime;
+ this.pauseTime = null;
+};
+
+var logged = false;
+SystemJSLoader.prototype.perfSummary = function(includeEvts) {
+ logged = true;
+ // create groupings of events by event name to time data
+ // filtering out cancelled events
+ var groupedEvents = {};
+ events.forEach(function(evt) {
+ if (includeEvts && !includeEvts(evt))
+ return;
+ if (evt.cancelled)
+ return;
+ if (!evt.stop) {
+ console.warn('Event ' + evt.name + ' (' + evt.item + ') never completed.');
+ return;
+ }
+
+ var evtTimes = groupedEvents[evt.name] = groupedEvents[evt.name] || [];
+ evtTimes.push({
+ time: evt.stop - evt.start,
+ item: evt.item
+ });
+ });
+
+ Object.keys(groupedEvents).forEach(function(evt) {
+ var evtTimes = groupedEvents[evt];
+
+ // only one event -> log as a single event
+ if (evtTimes.length == 1) {
+ console.log(toTitleCase(evt) + (evtTimes[0].item != 'default' ? ' (' + evtTimes[0].item + ')' : ''));
+ logStat('Total Time', evtTimes[0].time);
+ console.log('');
+ return;
+ }
+
+ // multiple events, give some stats!
+ var evtCount = evtTimes.length;
+
+ console.log(toTitleCase(evt) + ' (' + evtCount + ' events)');
+
+ var totalTime = evtTimes.reduce(function(curSum, evt) {
+ return curSum + evt.time;
+ }, 0);
+ logStat('Cumulative Time', totalTime);
+
+ var mean = totalTime / evtCount;
+ logStat('Mean', mean);
+
+ var stdDev = Math.sqrt(evtTimes.reduce(function(curSum, evt) {
+ return curSum + Math.pow(evt.time - mean, 2);
+ }, 0) / evtCount);
+
+ logStat('Std Deviation', stdDev);
+
+ var withoutOutliers = evtTimes.filter(function(evt) {
+ return evt.time > mean - stdDev && evt.time < mean + stdDev;
+ });
+
+ logStat('Avg within 2σ', withoutOutliers.reduce(function(curSum, evt) {
+ return curSum + evt.time;
+ }, 0) / withoutOutliers.length);
+
+ var sorted = evtTimes.sort(function(a, b) {
+ return a.time > b.time ? 1 : -1;
+ });
+
+ var medianIndex = Math.round(evtCount / 2);
+ logStat('Median', sorted[medianIndex].time, sorted[medianIndex].evt);
+
+ logStat('Max', sorted[evtCount - 1].time, sorted[evtCount - 1].item);
+
+ logStat('Min', sorted[0].time, sorted[0].item);
+
+ var duplicates = evtTimes.filter(function(evt) {
+ return evtTimes.some(function(dup) {
+ return dup !== evt && dup.name == evt.name && dup.item == evt.item;
+ });
+ });
+
+ logStat('Duplicate Events', duplicates.length, true);
+
+ logStat('Total Duplicated Time', duplicates.reduce(function(duplicateTime, evt) {
+ return duplicateTime + evt.time;
+ }, 0));
+
+ console.log('');
+ });
+};
+
+function toTitleCase(title) {
+ return title.split('-').map(function(part) {
+ return part[0].toUpperCase() + part.substr(1);
+ }).join(' ');
+}
+
+var titleLen = 25;
+function logStat(title, value, item, isNum) {
+ if (item === true) {
+ item = undefined;
+ isNum = true;
+ }
+ var spaces = Array(titleLen - title.length + 1).join(' ');
+ var value = isNum ? value : Math.round(value * 100) / 100 + 'ms';
+ console.log(' ' + title + spaces + ': ' + value + (item ? ' (' + item + ')' : ''));
+}
+})(); \ No newline at end of file
diff --git a/lib/plugins.js b/lib/plugins.js
new file mode 100644
index 000000000..33e81824e
--- /dev/null
+++ b/lib/plugins.js
@@ -0,0 +1,263 @@
+/*
+ SystemJS Loader Plugin Support
+
+ Supports plugin loader syntax with "!", or via metadata.loader
+
+ The plugin name is loaded as a module itself, and can override standard loader hooks
+ for the plugin resource. See the plugin section of the systemjs readme.
+*/
+
+(function() {
+ function getParentName(loader, parentName) {
+ // if parent is a plugin, normalize against the parent plugin argument only
+ if (parentName) {
+ var parentPluginIndex;
+ if (loader.pluginFirst) {
+ if ((parentPluginIndex = parentName.lastIndexOf('!')) != -1)
+ return parentName.substr(parentPluginIndex + 1);
+ }
+ else {
+ if ((parentPluginIndex = parentName.indexOf('!')) != -1)
+ return parentName.substr(0, parentPluginIndex);
+ }
+
+ return parentName;
+ }
+ }
+
+ function parsePlugin(loader, name) {
+ var argumentName;
+ var pluginName;
+
+ var pluginIndex = name.lastIndexOf('!');
+
+ if (pluginIndex == -1)
+ return;
+
+ if (loader.pluginFirst) {
+ argumentName = name.substr(pluginIndex + 1);
+ pluginName = name.substr(0, pluginIndex);
+ }
+ else {
+ argumentName = name.substr(0, pluginIndex);
+ pluginName = name.substr(pluginIndex + 1) || argumentName.substr(argumentName.lastIndexOf('.') + 1);
+ }
+
+ return {
+ argument: argumentName,
+ plugin: pluginName
+ };
+ }
+
+ // put name back together after parts have been normalized
+ function combinePluginParts(loader, argumentName, pluginName, defaultExtension) {
+ if (defaultExtension && argumentName.substr(argumentName.length - 3, 3) == '.js')
+ argumentName = argumentName.substr(0, argumentName.length - 3);
+
+ if (loader.pluginFirst) {
+ return pluginName + '!' + argumentName;
+ }
+ else {
+ return argumentName + '!' + pluginName;
+ }
+ }
+
+ // note if normalize will add a default js extension
+ // if so, remove for backwards compat
+ // this is strange and sucks, but will be deprecated
+ function checkDefaultExtension(loader, arg) {
+ return loader.defaultJSExtensions && arg.substr(arg.length - 3, 3) != '.js';
+ }
+
+ function createNormalizeSync(normalizeSync) {
+ return function(name, parentName, isPlugin) {
+ var loader = this;
+
+ var parsed = parsePlugin(loader, name);
+ parentName = getParentName(this, parentName);
+
+ if (!parsed)
+ return normalizeSync.call(this, name, parentName, isPlugin);
+
+ // if this is a plugin, normalize the plugin name and the argument
+ var argumentName = loader.normalizeSync(parsed.argument, parentName, true);
+ var pluginName = loader.normalizeSync(parsed.plugin, parentName, true);
+ return combinePluginParts(loader, argumentName, pluginName, checkDefaultExtension(loader, parsed.argument));
+ };
+ }
+
+ hook('decanonicalize', createNormalizeSync);
+ hook('normalizeSync', createNormalizeSync);
+
+ hook('normalize', function(normalize) {
+ return function(name, parentName, isPlugin) {
+ var loader = this;
+
+ parentName = getParentName(this, parentName);
+
+ var parsed = parsePlugin(loader, name);
+
+ if (!parsed)
+ return normalize.call(loader, name, parentName, isPlugin);
+
+ return Promise.all([
+ loader.normalize(parsed.argument, parentName, true),
+ loader.normalize(parsed.plugin, parentName, false)
+ ])
+ .then(function(normalized) {
+ return combinePluginParts(loader, normalized[0], normalized[1], checkDefaultExtension(loader, parsed.argument));
+ });
+ }
+ });
+
+ hook('locate', function(locate) {
+ return function(load) {
+ var loader = this;
+
+ var name = load.name;
+
+ // plugin syntax
+ var pluginSyntaxIndex;
+ if (loader.pluginFirst) {
+ if ((pluginSyntaxIndex = name.indexOf('!')) != -1) {
+ load.metadata.loader = name.substr(0, pluginSyntaxIndex);
+ load.name = name.substr(pluginSyntaxIndex + 1);
+ }
+ }
+ else {
+ if ((pluginSyntaxIndex = name.lastIndexOf('!')) != -1) {
+ load.metadata.loader = name.substr(pluginSyntaxIndex + 1);
+ load.name = name.substr(0, pluginSyntaxIndex);
+ }
+ }
+
+ return locate.call(loader, load)
+ .then(function(address) {
+ if (pluginSyntaxIndex != -1 || !load.metadata.loader)
+ return address;
+
+ // normalize plugin relative to parent in locate here when
+ // using plugin via loader metadata
+ return (loader.pluginLoader || loader).normalize(load.metadata.loader, load.name)
+ .then(function(loaderNormalized) {
+ load.metadata.loader = loaderNormalized;
+ return address;
+ });
+ })
+ .then(function(address) {
+ var plugin = load.metadata.loader;
+
+ if (!plugin)
+ return address;
+
+ // don't allow a plugin to load itself
+ if (load.name == plugin)
+ throw new Error('Plugin ' + plugin + ' cannot load itself, make sure it is excluded from any wildcard meta configuration via a custom loader: false rule.');
+
+ // only fetch the plugin itself if this name isn't defined
+ if (loader.defined && loader.defined[name])
+ return address;
+
+ var pluginLoader = loader.pluginLoader || loader;
+
+ // load the plugin module and run standard locate
+ return pluginLoader['import'](plugin)
+ .then(function(loaderModule) {
+ // store the plugin module itself on the metadata
+ load.metadata.loaderModule = loaderModule;
+
+ load.address = address;
+ if (loaderModule.locate)
+ return loaderModule.locate.call(loader, load);
+
+ return address;
+ });
+ });
+ };
+ });
+
+ hook('fetch', function(fetch) {
+ return function(load) {
+ var loader = this;
+ if (load.metadata.loaderModule && load.metadata.loaderModule.fetch && load.metadata.format != 'defined') {
+ load.metadata.scriptLoad = false;
+ return load.metadata.loaderModule.fetch.call(loader, load, function(load) {
+ return fetch.call(loader, load);
+ });
+ }
+ else {
+ return fetch.call(loader, load);
+ }
+ };
+ });
+
+ hook('translate', function(translate) {
+ return function(load) {
+ var loader = this;
+ var args = arguments;
+ if (load.metadata.loaderModule && load.metadata.loaderModule.translate && load.metadata.format != 'defined') {
+ return Promise.resolve(load.metadata.loaderModule.translate.apply(loader, args)).then(function(result) {
+ var sourceMap = load.metadata.sourceMap;
+
+ // sanitize sourceMap if an object not a JSON string
+ if (sourceMap) {
+ if (typeof sourceMap != 'object')
+ throw new Error('load.metadata.sourceMap must be set to an object.');
+
+ var originalName = load.address.split('!')[0];
+
+ // force set the filename of the original file
+ if (!sourceMap.file || sourceMap.file == load.address)
+ sourceMap.file = originalName + '!transpiled';
+
+ // force set the sources list if only one source
+ if (!sourceMap.sources || sourceMap.sources.length <= 1 && (!sourceMap.sources[0] || sourceMap.sources[0] == load.address))
+ sourceMap.sources = [originalName];
+ }
+
+ // if running on file:/// URLs, sourcesContent is necessary
+ // load.metadata.sourceMap.sourcesContent = [load.source];
+
+ if (typeof result == 'string')
+ load.source = result;
+ else
+ warn.call(this, 'Plugin ' + load.metadata.loader + ' should return the source in translate, instead of setting load.source directly. This support will be deprecated.');
+
+ return translate.apply(loader, args);
+ });
+ }
+ else {
+ return translate.apply(loader, args);
+ }
+ };
+ });
+
+ hook('instantiate', function(instantiate) {
+ return function(load) {
+ var loader = this;
+ var calledInstantiate = false;
+
+ if (load.metadata.loaderModule && load.metadata.loaderModule.instantiate && !loader.builder && load.metadata.format != 'defined')
+ return Promise.resolve(load.metadata.loaderModule.instantiate.call(loader, load, function(load) {
+ if (calledInstantiate)
+ throw new Error('Instantiate must only be called once.');
+ calledInstantiate = true;
+ return instantiate.call(loader, load);
+ })).then(function(result) {
+ if (calledInstantiate)
+ return result;
+
+ load.metadata.entry = createEntry();
+ load.metadata.entry.execute = function() {
+ return result;
+ }
+ load.metadata.entry.deps = load.metadata.deps;
+ load.metadata.format = 'defined';
+ return instantiate.call(loader, load);
+ });
+ else
+ return instantiate.call(loader, load);
+ };
+ });
+
+})(); \ No newline at end of file
diff --git a/lib/polyfills-bootstrap.js b/lib/polyfills-bootstrap.js
new file mode 100644
index 000000000..27c806b6c
--- /dev/null
+++ b/lib/polyfills-bootstrap.js
@@ -0,0 +1,2 @@
+if (typeof systemJSBootstrap !== 'undefined')
+ systemJSBootstrap(); \ No newline at end of file
diff --git a/lib/proto.js b/lib/proto.js
new file mode 100644
index 000000000..08203cc49
--- /dev/null
+++ b/lib/proto.js
@@ -0,0 +1,268 @@
+// SystemJS Loader Class and Extension helpers
+function SystemJSLoader() {
+ Loader.call(this);
+
+ this.paths = {};
+ this._loader.paths = {};
+
+ systemJSConstructor.call(this);
+}
+
+// inline Object.create-style class extension
+function SystemProto() {};
+SystemProto.prototype = Loader.prototype;
+SystemJSLoader.prototype = new SystemProto();
+SystemJSLoader.prototype.constructor = SystemJSLoader;
+
+var systemJSConstructor;
+
+function hook(name, hook) {
+ SystemJSLoader.prototype[name] = hook(SystemJSLoader.prototype[name] || function() {});
+}
+function hookConstructor(hook) {
+ systemJSConstructor = hook(systemJSConstructor || function() {});
+}
+
+
+var absURLRegEx = /^[^\/]+:\/\//;
+function isAbsolute(name) {
+ return name.match(absURLRegEx);
+}
+function isRel(name) {
+ return (name[0] == '.' && (!name[1] || name[1] == '/' || name[1] == '.')) || name[0] == '/';
+}
+function isPlain(name) {
+ return !isRel(name) && !isAbsolute(name);
+}
+
+var baseURIObj = new URL(baseURI);
+
+function urlResolve(name, parent) {
+ // url resolution shortpaths
+ if (name[0] == '.') {
+ // dot-relative url normalization
+ if (name[1] == '/' && name[2] != '.')
+ return (parent && parent.substr(0, parent.lastIndexOf('/') + 1) || baseURI) + name.substr(2);
+ }
+ else if (name[0] != '/' && name.indexOf(':') == -1) {
+ // plain parent normalization
+ return (parent && parent.substr(0, parent.lastIndexOf('/') + 1) || baseURI) + name;
+ }
+
+ return new URL(name, parent && parent.replace(/#/g, '%05') || baseURIObj).href.replace(/%05/g, '#');
+}
+
+// NB no specification provided for System.paths, used ideas discussed in https://github.com/jorendorff/js-loaders/issues/25
+function applyPaths(loader, name) {
+ // most specific (most number of slashes in path) match wins
+ var pathMatch = '', wildcard, maxWildcardPrefixLen = 0;
+
+ var paths = loader.paths;
+ var pathsCache = loader._loader.paths;
+
+ // check to see if we have a paths entry
+ for (var p in paths) {
+ if (paths.hasOwnProperty && !paths.hasOwnProperty(p))
+ continue;
+
+ // paths sanitization
+ var path = paths[p];
+ if (path !== pathsCache[p])
+ path = paths[p] = pathsCache[p] = urlResolve(paths[p], isRel(paths[p]) ? baseURI : loader.baseURL);
+
+ // exact path match
+ if (p.indexOf('*') === -1) {
+ if (name == p)
+ return paths[p];
+
+ // support trailing / in paths rules
+ else if (name.substr(0, p.length - 1) == p.substr(0, p.length - 1) && (name.length < p.length || name[p.length - 1] == p[p.length - 1]) && (paths[p][paths[p].length - 1] == '/' || paths[p] == '')) {
+ return paths[p].substr(0, paths[p].length - 1) + (name.length > p.length ? (paths[p] && '/' || '') + name.substr(p.length) : '');
+ }
+ }
+ // wildcard path match
+ else {
+ var pathParts = p.split('*');
+ if (pathParts.length > 2)
+ throw new TypeError('Only one wildcard in a path is permitted');
+
+ var wildcardPrefixLen = pathParts[0].length;
+ if (wildcardPrefixLen >= maxWildcardPrefixLen &&
+ name.substr(0, pathParts[0].length) == pathParts[0] &&
+ name.substr(name.length - pathParts[1].length) == pathParts[1]) {
+ maxWildcardPrefixLen = wildcardPrefixLen;
+ pathMatch = p;
+ wildcard = name.substr(pathParts[0].length, name.length - pathParts[1].length - pathParts[0].length);
+ }
+ }
+ }
+
+ var outPath = paths[pathMatch];
+ if (typeof wildcard == 'string')
+ outPath = outPath.replace('*', wildcard);
+
+ return outPath;
+}
+
+function dedupe(deps) {
+ var newDeps = [];
+ for (var i = 0, l = deps.length; i < l; i++)
+ if (indexOf.call(newDeps, deps[i]) == -1)
+ newDeps.push(deps[i])
+ return newDeps;
+}
+
+function group(deps) {
+ var names = [];
+ var indices = [];
+ for (var i = 0, l = deps.length; i < l; i++) {
+ var index = indexOf.call(names, deps[i]);
+ if (index === -1) {
+ names.push(deps[i]);
+ indices.push([i]);
+ }
+ else {
+ indices[index].push(i);
+ }
+ }
+ return { names: names, indices: indices };
+}
+
+var getOwnPropertyDescriptor = true;
+try {
+ Object.getOwnPropertyDescriptor({ a: 0 }, 'a');
+}
+catch(e) {
+ getOwnPropertyDescriptor = false;
+}
+
+// converts any module.exports object into an object ready for SystemJS.newModule
+function getESModule(exports) {
+ var esModule = {};
+ // don't trigger getters/setters in environments that support them
+ if ((typeof exports == 'object' || typeof exports == 'function') && exports !== __global) {
+ if (getOwnPropertyDescriptor) {
+ for (var p in exports) {
+ // The default property is copied to esModule later on
+ if (p === 'default')
+ continue;
+ defineOrCopyProperty(esModule, exports, p);
+ }
+ }
+ else {
+ extend(esModule, exports);
+ }
+ }
+ esModule['default'] = exports;
+ defineProperty(esModule, '__useDefault', {
+ value: true
+ });
+ return esModule;
+}
+
+function defineOrCopyProperty(targetObj, sourceObj, propName) {
+ try {
+ var d;
+ if (d = Object.getOwnPropertyDescriptor(sourceObj, propName))
+ defineProperty(targetObj, propName, d);
+ }
+ catch (ex) {
+ // Object.getOwnPropertyDescriptor threw an exception, fall back to normal set property
+ // we dont need hasOwnProperty here because getOwnPropertyDescriptor would have returned undefined above
+ targetObj[propName] = sourceObj[propName];
+ return false;
+ }
+}
+
+function extend(a, b, prepend) {
+ var hasOwnProperty = b && b.hasOwnProperty;
+ for (var p in b) {
+ if (hasOwnProperty && !b.hasOwnProperty(p))
+ continue;
+ if (!prepend || !(p in a))
+ a[p] = b[p];
+ }
+ return a;
+}
+
+// meta first-level extends where:
+// array + array appends
+// object + object extends
+// other properties replace
+function extendMeta(a, b, prepend) {
+ var hasOwnProperty = b && b.hasOwnProperty;
+ for (var p in b) {
+ if (hasOwnProperty && !b.hasOwnProperty(p))
+ continue;
+ var val = b[p];
+ if (!(p in a))
+ a[p] = val;
+ else if (val instanceof Array && a[p] instanceof Array)
+ a[p] = [].concat(prepend ? val : a[p]).concat(prepend ? a[p] : val);
+ else if (typeof val == 'object' && val !== null && typeof a[p] == 'object')
+ a[p] = extend(extend({}, a[p]), val, prepend);
+ else if (!prepend)
+ a[p] = val;
+ }
+}
+
+function extendPkgConfig(pkgCfgA, pkgCfgB, pkgName, loader, warnInvalidProperties) {
+ for (var prop in pkgCfgB) {
+ if (indexOf.call(['main', 'format', 'defaultExtension', 'basePath'], prop) != -1) {
+ pkgCfgA[prop] = pkgCfgB[prop];
+ }
+ else if (prop == 'map') {
+ extend(pkgCfgA.map = pkgCfgA.map || {}, pkgCfgB.map);
+ }
+ else if (prop == 'meta') {
+ extend(pkgCfgA.meta = pkgCfgA.meta || {}, pkgCfgB.meta);
+ }
+ else if (prop == 'depCache') {
+ for (var d in pkgCfgB.depCache) {
+ var dNormalized;
+
+ if (d.substr(0, 2) == './')
+ dNormalized = pkgName + '/' + d.substr(2);
+ else
+ dNormalized = coreResolve.call(loader, d);
+ loader.depCache[dNormalized] = (loader.depCache[dNormalized] || []).concat(pkgCfgB.depCache[d]);
+ }
+ }
+ else if (warnInvalidProperties && indexOf.call(['browserConfig', 'nodeConfig', 'devConfig', 'productionConfig'], prop) == -1 &&
+ (!pkgCfgB.hasOwnProperty || pkgCfgB.hasOwnProperty(prop))) {
+ warn.call(loader, '"' + prop + '" is not a valid package configuration option in package ' + pkgName);
+ }
+ }
+}
+
+// deeply-merge (to first level) config with any existing package config
+function setPkgConfig(loader, pkgName, cfg, prependConfig) {
+ var pkg;
+
+ // first package is config by reference for fast path, cloned after that
+ if (!loader.packages[pkgName]) {
+ pkg = loader.packages[pkgName] = cfg;
+ }
+ else {
+ var basePkg = loader.packages[pkgName];
+ pkg = loader.packages[pkgName] = {};
+
+ extendPkgConfig(pkg, prependConfig ? cfg : basePkg, pkgName, loader, prependConfig);
+ extendPkgConfig(pkg, prependConfig ? basePkg : cfg, pkgName, loader, !prependConfig);
+ }
+
+ // main object becomes main map
+ if (typeof pkg.main == 'object') {
+ pkg.map = pkg.map || {};
+ pkg.map['./@main'] = pkg.main;
+ pkg.main['default'] = pkg.main['default'] || './';
+ pkg.main = '@main';
+ }
+
+ return pkg;
+}
+
+function warn(msg) {
+ if (this.warnings && typeof console != 'undefined' && console.warn)
+ console.warn(msg);
+}
diff --git a/lib/register.js b/lib/register.js
new file mode 100644
index 000000000..69568c9b9
--- /dev/null
+++ b/lib/register.js
@@ -0,0 +1,633 @@
+/*
+ * Instantiate registry extension
+ *
+ * Supports Traceur System.register 'instantiate' output for loading ES6 as ES5.
+ *
+ * - Creates the loader.register function
+ * - Also supports metadata.format = 'register' in instantiate for anonymous register modules
+ * - Also supports metadata.deps, metadata.execute and metadata.executingRequire
+ * for handling dynamic modules alongside register-transformed ES6 modules
+ *
+ *
+ * The code here replicates the ES6 linking groups algorithm to ensure that
+ * circular ES6 compiled into System.register can work alongside circular AMD
+ * and CommonJS, identically to the actual ES6 loader.
+ *
+ */
+
+
+/*
+ * Registry side table entries in loader.defined
+ * Registry Entry Contains:
+ * - name
+ * - deps
+ * - declare for declarative modules
+ * - execute for dynamic modules, different to declarative execute on module
+ * - executingRequire indicates require drives execution for circularity of dynamic modules
+ * - declarative optional boolean indicating which of the above
+ *
+ * Can preload modules directly on SystemJS.defined['my/module'] = { deps, execute, executingRequire }
+ *
+ * Then the entry gets populated with derived information during processing:
+ * - normalizedDeps derived from deps, created in instantiate
+ * - groupIndex used by group linking algorithm
+ * - evaluated indicating whether evaluation has happend
+ * - module the module record object, containing:
+ * - exports actual module exports
+ *
+ * For dynamic we track the es module with:
+ * - esModule actual es module value
+ * - esmExports whether to extend the esModule with named exports
+ *
+ * Then for declarative only we track dynamic bindings with the 'module' records:
+ * - name
+ * - exports
+ * - setters declarative setter functions
+ * - dependencies, module records of dependencies
+ * - importers, module records of dependents
+ *
+ * After linked and evaluated, entries are removed, declarative module records remain in separate
+ * module binding table
+ *
+ */
+
+var leadingCommentAndMetaRegEx = /^(\s*\/\*[^\*]*(\*(?!\/)[^\*]*)*\*\/|\s*\/\/[^\n]*|\s*"[^"]+"\s*;?|\s*'[^']+'\s*;?)*\s*/;
+function detectRegisterFormat(source) {
+ var leadingCommentAndMeta = source.match(leadingCommentAndMetaRegEx);
+ return leadingCommentAndMeta && source.substr(leadingCommentAndMeta[0].length, 15) == 'System.register';
+}
+
+function createEntry() {
+ return {
+ name: null,
+ deps: null,
+ originalIndices: null,
+ declare: null,
+ execute: null,
+ executingRequire: false,
+ declarative: false,
+ normalizedDeps: null,
+ groupIndex: null,
+ evaluated: false,
+ module: null,
+ esModule: null,
+ esmExports: false
+ };
+}
+
+(function() {
+
+ /*
+ * There are two variations of System.register:
+ * 1. System.register for ES6 conversion (2-3 params) - System.register([name, ]deps, declare)
+ * see https://github.com/ModuleLoader/es6-module-loader/wiki/System.register-Explained
+ *
+ * 2. System.registerDynamic for dynamic modules (3-4 params) - System.registerDynamic([name, ]deps, executingRequire, execute)
+ * the true or false statement
+ *
+ * this extension implements the linking algorithm for the two variations identical to the spec
+ * allowing compiled ES6 circular references to work alongside AMD and CJS circular references.
+ *
+ */
+ SystemJSLoader.prototype.register = function(name, deps, declare) {
+ if (typeof name != 'string') {
+ declare = deps;
+ deps = name;
+ name = null;
+ }
+
+ // dynamic backwards-compatibility
+ // can be deprecated eventually
+ if (typeof declare == 'boolean')
+ return this.registerDynamic.apply(this, arguments);
+
+ var entry = createEntry();
+ // ideally wouldn't apply map config to bundle names but
+ // dependencies go through map regardless so we can't restrict
+ // could reconsider in shift to new spec
+ entry.name = name && (this.decanonicalize || this.normalize).call(this, name);
+ entry.declarative = true;
+ entry.deps = deps;
+ entry.declare = declare;
+
+ this.pushRegister_({
+ amd: false,
+ entry: entry
+ });
+ };
+ SystemJSLoader.prototype.registerDynamic = function(name, deps, declare, execute) {
+ if (typeof name != 'string') {
+ execute = declare;
+ declare = deps;
+ deps = name;
+ name = null;
+ }
+
+ // dynamic
+ var entry = createEntry();
+ entry.name = name && (this.decanonicalize || this.normalize).call(this, name);
+ entry.deps = deps;
+ entry.execute = execute;
+ entry.executingRequire = declare;
+
+ this.pushRegister_({
+ amd: false,
+ entry: entry
+ });
+ };
+ hook('reduceRegister_', function() {
+ return function(load, register) {
+ if (!register)
+ return;
+
+ var entry = register.entry;
+ var curMeta = load && load.metadata;
+
+ // named register
+ if (entry.name) {
+ if (!(entry.name in this.defined))
+ this.defined[entry.name] = entry;
+
+ if (curMeta)
+ curMeta.bundle = true;
+ }
+ // anonymous register
+ if (!entry.name || load && !curMeta.entry && entry.name == load.name) {
+ if (!curMeta)
+ throw new TypeError('Invalid System.register call. Anonymous System.register calls can only be made by modules loaded by SystemJS.import and not via script tags.');
+ if (curMeta.entry) {
+ if (curMeta.format == 'register')
+ throw new Error('Multiple anonymous System.register calls in module ' + load.name + '. If loading a bundle, ensure all the System.register calls are named.');
+ else
+ throw new Error('Module ' + load.name + ' interpreted as ' + curMeta.format + ' module format, but called System.register.');
+ }
+ if (!curMeta.format)
+ curMeta.format = 'register';
+ curMeta.entry = entry;
+ }
+ };
+ });
+
+ hookConstructor(function(constructor) {
+ return function() {
+ constructor.call(this);
+
+ this.defined = {};
+ this._loader.moduleRecords = {};
+ };
+ });
+
+ function buildGroups(entry, loader, groups) {
+ groups[entry.groupIndex] = groups[entry.groupIndex] || [];
+
+ if (indexOf.call(groups[entry.groupIndex], entry) != -1)
+ return;
+
+ groups[entry.groupIndex].push(entry);
+
+ for (var i = 0, l = entry.normalizedDeps.length; i < l; i++) {
+ var depName = entry.normalizedDeps[i];
+ var depEntry = loader.defined[depName];
+
+ // not in the registry means already linked / ES6
+ if (!depEntry || depEntry.evaluated)
+ continue;
+
+ // now we know the entry is in our unlinked linkage group
+ var depGroupIndex = entry.groupIndex + (depEntry.declarative != entry.declarative);
+
+ // the group index of an entry is always the maximum
+ if (depEntry.groupIndex === null || depEntry.groupIndex < depGroupIndex) {
+
+ // if already in a group, remove from the old group
+ if (depEntry.groupIndex !== null) {
+ groups[depEntry.groupIndex].splice(indexOf.call(groups[depEntry.groupIndex], depEntry), 1);
+
+ // if the old group is empty, then we have a mixed depndency cycle
+ if (groups[depEntry.groupIndex].length == 0)
+ throw new Error("Mixed dependency cycle detected");
+ }
+
+ depEntry.groupIndex = depGroupIndex;
+ }
+
+ buildGroups(depEntry, loader, groups);
+ }
+ }
+
+ function link(name, startEntry, loader) {
+ // skip if already linked
+ if (startEntry.module)
+ return;
+
+ startEntry.groupIndex = 0;
+
+ var groups = [];
+
+ buildGroups(startEntry, loader, groups);
+
+ var curGroupDeclarative = !!startEntry.declarative == groups.length % 2;
+ for (var i = groups.length - 1; i >= 0; i--) {
+ var group = groups[i];
+ for (var j = 0; j < group.length; j++) {
+ var entry = group[j];
+
+ // link each group
+ if (curGroupDeclarative)
+ linkDeclarativeModule(entry, loader);
+ else
+ linkDynamicModule(entry, loader);
+ }
+ curGroupDeclarative = !curGroupDeclarative;
+ }
+ }
+
+ // module binding records
+ function ModuleRecord() {}
+ defineProperty(ModuleRecord, 'toString', {
+ value: function() {
+ return 'Module';
+ }
+ });
+
+ function getOrCreateModuleRecord(name, moduleRecords) {
+ return moduleRecords[name] || (moduleRecords[name] = {
+ name: name,
+ dependencies: [],
+ exports: new ModuleRecord(), // start from an empty module and extend
+ importers: []
+ });
+ }
+
+ function linkDeclarativeModule(entry, loader) {
+ // only link if already not already started linking (stops at circular)
+ if (entry.module)
+ return;
+
+ var moduleRecords = loader._loader.moduleRecords;
+ var module = entry.module = getOrCreateModuleRecord(entry.name, moduleRecords);
+ var exports = entry.module.exports;
+
+ var declaration = entry.declare.call(__global, function(name, value) {
+ module.locked = true;
+
+ if (typeof name == 'object') {
+ for (var p in name)
+ exports[p] = name[p];
+ }
+ else {
+ exports[name] = value;
+ }
+
+ for (var i = 0, l = module.importers.length; i < l; i++) {
+ var importerModule = module.importers[i];
+ if (!importerModule.locked) {
+ var importerIndex = indexOf.call(importerModule.dependencies, module);
+ var setter = importerModule.setters[importerIndex];
+ if (setter)
+ setter(exports);
+ }
+ }
+
+ module.locked = false;
+ return value;
+ }, { id: entry.name });
+
+ if (typeof declaration == 'function')
+ declaration = { setters: [], execute: declaration };
+
+ // allowing undefined declaration was a mistake! To be deprecated.
+ declaration = declaration || { setters: [], execute: function() {} };
+
+ module.setters = declaration.setters;
+ module.execute = declaration.execute;
+
+ if (!module.setters || !module.execute) {
+ throw new TypeError('Invalid System.register form for ' + entry.name);
+ }
+
+ // now link all the module dependencies
+ for (var i = 0, l = entry.normalizedDeps.length; i < l; i++) {
+ var depName = entry.normalizedDeps[i];
+ var depEntry = loader.defined[depName];
+ var depModule = moduleRecords[depName];
+
+ // work out how to set depExports based on scenarios...
+ var depExports;
+
+ if (depModule) {
+ depExports = depModule.exports;
+ }
+ // dynamic, already linked in our registry
+ else if (depEntry && !depEntry.declarative) {
+ depExports = depEntry.esModule;
+ }
+ // in the loader registry
+ else if (!depEntry) {
+ depExports = loader.get(depName);
+ }
+ // we have an entry -> link
+ else {
+ linkDeclarativeModule(depEntry, loader);
+ depModule = depEntry.module;
+ depExports = depModule.exports;
+ }
+
+ // only declarative modules have dynamic bindings
+ if (depModule && depModule.importers) {
+ depModule.importers.push(module);
+ module.dependencies.push(depModule);
+ }
+ else {
+ module.dependencies.push(null);
+ }
+
+ // run setters for all entries with the matching dependency name
+ var originalIndices = entry.originalIndices[i];
+ for (var j = 0, len = originalIndices.length; j < len; ++j) {
+ var index = originalIndices[j];
+ if (module.setters[index]) {
+ module.setters[index](depExports);
+ }
+ }
+ }
+ }
+
+ // An analog to loader.get covering execution of all three layers (real declarative, simulated declarative, simulated dynamic)
+ function getModule(name, loader) {
+ var exports;
+ var entry = loader.defined[name];
+
+ if (!entry) {
+ exports = loader.get(name);
+ if (!exports)
+ throw new Error('Unable to load dependency ' + name + '.');
+ }
+
+ else {
+ if (entry.declarative)
+ ensureEvaluated(name, entry, [], loader);
+
+ else if (!entry.evaluated)
+ linkDynamicModule(entry, loader);
+
+ exports = entry.module.exports;
+ }
+
+ if ((!entry || entry.declarative) && exports && exports.__useDefault)
+ return exports['default'];
+
+ return exports;
+ }
+
+ function linkDynamicModule(entry, loader) {
+ if (entry.module)
+ return;
+
+ var exports = {};
+
+ var module = entry.module = { exports: exports, id: entry.name };
+
+ // AMD requires execute the tree first
+ if (!entry.executingRequire) {
+ for (var i = 0, l = entry.normalizedDeps.length; i < l; i++) {
+ var depName = entry.normalizedDeps[i];
+ // we know we only need to link dynamic due to linking algorithm
+ var depEntry = loader.defined[depName];
+ if (depEntry)
+ linkDynamicModule(depEntry, loader);
+ }
+ }
+
+ // now execute
+ entry.evaluated = true;
+ var output = entry.execute.call(__global, function(name) {
+ for (var i = 0, l = entry.deps.length; i < l; i++) {
+ if (entry.deps[i] != name)
+ continue;
+ return getModule(entry.normalizedDeps[i], loader);
+ }
+ // try and normalize the dependency to see if we have another form
+ var nameNormalized = loader.normalizeSync(name, entry.name);
+ if (indexOf.call(entry.normalizedDeps, nameNormalized) != -1)
+ return getModule(nameNormalized, loader);
+
+ throw new Error('Module ' + name + ' not declared as a dependency of ' + entry.name);
+ }, exports, module);
+
+ if (output !== undefined)
+ module.exports = output;
+
+ // create the esModule object, which allows ES6 named imports of dynamics
+ exports = module.exports;
+
+ // __esModule flag treats as already-named
+ if (exports && (exports.__esModule || exports instanceof Module))
+ entry.esModule = loader.newModule(exports);
+ // set module as 'default' export, then fake named exports by iterating properties
+ else if (entry.esmExports && exports !== __global)
+ entry.esModule = loader.newModule(getESModule(exports));
+ // just use the 'default' export
+ else
+ entry.esModule = loader.newModule({ 'default': exports, __useDefault: true });
+ }
+
+ /*
+ * Given a module, and the list of modules for this current branch,
+ * ensure that each of the dependencies of this module is evaluated
+ * (unless one is a circular dependency already in the list of seen
+ * modules, in which case we execute it)
+ *
+ * Then we evaluate the module itself depth-first left to right
+ * execution to match ES6 modules
+ */
+ function ensureEvaluated(moduleName, entry, seen, loader) {
+ // if already seen, that means it's an already-evaluated non circular dependency
+ if (!entry || entry.evaluated || !entry.declarative)
+ return;
+
+ // this only applies to declarative modules which late-execute
+
+ seen.push(moduleName);
+
+ for (var i = 0, l = entry.normalizedDeps.length; i < l; i++) {
+ var depName = entry.normalizedDeps[i];
+ if (indexOf.call(seen, depName) == -1) {
+ if (!loader.defined[depName])
+ loader.get(depName);
+ else
+ ensureEvaluated(depName, loader.defined[depName], seen, loader);
+ }
+ }
+
+ if (entry.evaluated)
+ return;
+
+ entry.evaluated = true;
+ entry.module.execute.call(__global);
+ }
+
+ // override the delete method to also clear the register caches
+ hook('delete', function(del) {
+ return function(name) {
+ delete this._loader.moduleRecords[name];
+ delete this.defined[name];
+ return del.call(this, name);
+ };
+ });
+
+ hook('fetch', function(fetch) {
+ return function(load) {
+ if (this.defined[load.name]) {
+ load.metadata.format = 'defined';
+ return '';
+ }
+
+ load.metadata.deps = load.metadata.deps || [];
+
+ return fetch.call(this, load);
+ };
+ });
+
+ hook('translate', function(translate) {
+ // we run the meta detection here (register is after meta)
+ return function(load) {
+ load.metadata.deps = load.metadata.deps || [];
+ return Promise.resolve(translate.apply(this, arguments)).then(function(source) {
+ // run detection for register format
+ if (load.metadata.format == 'register' || !load.metadata.format && detectRegisterFormat(load.source))
+ load.metadata.format = 'register';
+ return source;
+ });
+ };
+ });
+
+ // implement a perforance shortpath for System.load with no deps
+ hook('load', function(doLoad) {
+ return function(normalized) {
+ var loader = this;
+ var entry = loader.defined[normalized];
+
+ if (!entry || entry.deps.length)
+ return doLoad.apply(this, arguments);
+
+ entry.originalIndices = entry.normalizedDeps = [];
+
+ // recursively ensure that the module and all its
+ // dependencies are linked (with dependency group handling)
+ link(normalized, entry, loader);
+
+ // now handle dependency execution in correct order
+ ensureEvaluated(normalized, entry, [], loader);
+ if (!entry.esModule)
+ entry.esModule = loader.newModule(entry.module.exports);
+
+ // remove from the registry
+ if (!loader.trace)
+ loader.defined[normalized] = undefined;
+
+ // return the defined module object
+ loader.set(normalized, entry.esModule);
+
+ return Promise.resolve();
+ };
+ });
+
+ hook('instantiate', function(instantiate) {
+ return function(load) {
+ if (load.metadata.format == 'detect')
+ load.metadata.format = undefined;
+
+ // assumes previous instantiate is sync
+ // (core json support)
+ instantiate.call(this, load);
+
+ var loader = this;
+
+ var entry;
+
+ // first we check if this module has already been defined in the registry
+ if (loader.defined[load.name]) {
+ entry = loader.defined[load.name];
+ // don't support deps for ES modules
+ if (!entry.declarative)
+ entry.deps = entry.deps.concat(load.metadata.deps);
+ entry.deps = entry.deps.concat(load.metadata.deps);
+ }
+
+ // picked up already by an anonymous System.register script injection
+ // or via the dynamic formats
+ else if (load.metadata.entry) {
+ entry = load.metadata.entry;
+ entry.deps = entry.deps.concat(load.metadata.deps);
+ }
+
+ // Contains System.register calls
+ // (dont run bundles in the builder)
+ else if (!(loader.builder && load.metadata.bundle)
+ && (load.metadata.format == 'register' || load.metadata.format == 'esm' || load.metadata.format == 'es6')) {
+
+ if (typeof __exec != 'undefined')
+ __exec.call(loader, load);
+
+ if (!load.metadata.entry && !load.metadata.bundle)
+ throw new Error(load.name + ' detected as ' + load.metadata.format + ' but didn\'t execute.');
+
+ entry = load.metadata.entry;
+
+ // support metadata deps for System.register
+ if (entry && load.metadata.deps)
+ entry.deps = entry.deps.concat(load.metadata.deps);
+ }
+
+ // named bundles are just an empty module
+ if (!entry) {
+ entry = createEntry();
+ entry.deps = load.metadata.deps;
+ entry.execute = function() {};
+ }
+
+ // place this module onto defined for circular references
+ loader.defined[load.name] = entry;
+
+ var grouped = group(entry.deps);
+
+ entry.deps = grouped.names;
+ entry.originalIndices = grouped.indices;
+ entry.name = load.name;
+ entry.esmExports = load.metadata.esmExports !== false;
+
+ // first, normalize all dependencies
+ var normalizePromises = [];
+ for (var i = 0, l = entry.deps.length; i < l; i++)
+ normalizePromises.push(Promise.resolve(loader.normalize(entry.deps[i], load.name)));
+
+ return Promise.all(normalizePromises).then(function(normalizedDeps) {
+
+ entry.normalizedDeps = normalizedDeps;
+
+ return {
+ deps: entry.deps,
+ execute: function() {
+ // recursively ensure that the module and all its
+ // dependencies are linked (with dependency group handling)
+ link(load.name, entry, loader);
+
+ // now handle dependency execution in correct order
+ ensureEvaluated(load.name, entry, [], loader);
+
+ if (!entry.esModule)
+ entry.esModule = loader.newModule(entry.module.exports);
+
+ // remove from the registry
+ if (!loader.trace)
+ loader.defined[load.name] = undefined;
+
+ // return the defined module object
+ return entry.esModule;
+ }
+ };
+ });
+ };
+ });
+})();
diff --git a/lib/scriptLoader.js b/lib/scriptLoader.js
new file mode 100644
index 000000000..8bd1d4b3e
--- /dev/null
+++ b/lib/scriptLoader.js
@@ -0,0 +1,196 @@
+/*
+ * Script tag fetch
+ *
+ * When load.metadata.scriptLoad is true, we load via script tag injection.
+ */
+(function() {
+
+ if (typeof document != 'undefined')
+ var head = document.getElementsByTagName('head')[0];
+
+ var curSystem;
+ var curRequire;
+
+ // if doing worker executing, this is set to the load record being executed
+ var workerLoad = null;
+
+ // interactive mode handling method courtesy RequireJS
+ var ieEvents = head && (function() {
+ var s = document.createElement('script');
+ var isOpera = typeof opera !== 'undefined' && opera.toString() === '[object Opera]';
+ return s.attachEvent && !(s.attachEvent.toString && s.attachEvent.toString().indexOf('[native code') < 0) && !isOpera;
+ })();
+
+ // IE interactive-only part
+ // we store loading scripts array as { script: <script>, load: {...} }
+ var interactiveLoadingScripts = [];
+ var interactiveScript;
+ function getInteractiveScriptLoad() {
+ if (interactiveScript && interactiveScript.script.readyState === 'interactive')
+ return interactiveScript.load;
+
+ for (var i = 0; i < interactiveLoadingScripts.length; i++)
+ if (interactiveLoadingScripts[i].script.readyState == 'interactive') {
+ interactiveScript = interactiveLoadingScripts[i];
+ return interactiveScript.load;
+ }
+ }
+
+ // System.register, System.registerDynamic, AMD define pipeline
+ // this is called by the above methods when they execute
+ // we then run the reduceRegister_ collection function either immediately
+ // if we are in IE and know the currently executing script (interactive)
+ // or later if we need to wait for the synchronous load callback to know the script
+ var loadingCnt = 0;
+ var registerQueue = [];
+ hook('pushRegister_', function(pushRegister) {
+ return function(register) {
+ // if using eval-execution then skip
+ if (pushRegister.call(this, register))
+ return false;
+
+ // if using worker execution, then we're done
+ if (workerLoad)
+ this.reduceRegister_(workerLoad, register);
+
+ // detect if we know the currently executing load (IE)
+ // if so, immediately call reduceRegister
+ else if (ieEvents)
+ this.reduceRegister_(getInteractiveScriptLoad(), register);
+
+ // otherwise, add to our execution queue
+ // to call reduceRegister on sync script load event
+ else if (loadingCnt)
+ registerQueue.push(register);
+
+ // if we're not currently loading anything though
+ // then do the reduction against a null load
+ // (out of band named define or named register)
+ // note even in non-script environments, this catch is used
+ else
+ this.reduceRegister_(null, register);
+
+ return true;
+ };
+ });
+
+ function webWorkerImport(loader, load) {
+ return new Promise(function(resolve, reject) {
+ if (load.metadata.integrity)
+ reject(new Error('Subresource integrity checking is not supported in web workers.'));
+
+ workerLoad = load;
+ try {
+ importScripts(load.address);
+ }
+ catch(e) {
+ workerLoad = null;
+ reject(e);
+ }
+ workerLoad = null;
+
+ // if nothing registered, then something went wrong
+ if (!load.metadata.entry)
+ reject(new Error(load.address + ' did not call System.register or AMD define. If loading a global, ensure the meta format is set to global.'));
+
+ resolve('');
+ });
+ }
+
+ // override fetch to use script injection
+ hook('fetch', function(fetch) {
+ return function(load) {
+ var loader = this;
+
+ if (load.metadata.format == 'json' || !load.metadata.scriptLoad || (!isBrowser && !isWorker))
+ return fetch.call(this, load);
+
+ if (isWorker)
+ return webWorkerImport(loader, load);
+
+ return new Promise(function(resolve, reject) {
+ var s = document.createElement('script');
+
+ s.async = true;
+
+ if (load.metadata.crossOrigin)
+ s.crossOrigin = load.metadata.crossOrigin;
+
+ if (load.metadata.integrity)
+ s.setAttribute('integrity', load.metadata.integrity);
+
+ if (ieEvents) {
+ s.attachEvent('onreadystatechange', complete);
+ interactiveLoadingScripts.push({
+ script: s,
+ load: load
+ });
+ }
+ else {
+ s.addEventListener('load', complete, false);
+ s.addEventListener('error', error, false);
+ }
+
+ loadingCnt++;
+
+ curSystem = __global.System;
+ curRequire = __global.require;
+
+ s.src = load.address;
+ head.appendChild(s);
+
+ function complete(evt) {
+ if (s.readyState && s.readyState != 'loaded' && s.readyState != 'complete')
+ return;
+
+ loadingCnt--;
+
+ // complete call is sync on execution finish
+ // (in ie already done reductions)
+ if (!load.metadata.entry && !registerQueue.length) {
+ loader.reduceRegister_(load);
+ }
+ else if (!ieEvents) {
+ for (var i = 0; i < registerQueue.length; i++)
+ loader.reduceRegister_(load, registerQueue[i]);
+ registerQueue = [];
+ }
+
+ cleanup();
+
+ // if nothing registered, then something went wrong
+ if (!load.metadata.entry && !load.metadata.bundle)
+ reject(new Error(load.name + ' did not call System.register or AMD define. If loading a global module configure the global name via the meta exports property for script injection support.'));
+
+ resolve('');
+ }
+
+ function error(evt) {
+ cleanup();
+ reject(new Error('Unable to load script ' + load.address));
+ }
+
+ function cleanup() {
+ __global.System = curSystem;
+ __global.require = curRequire;
+
+ if (s.detachEvent) {
+ s.detachEvent('onreadystatechange', complete);
+ for (var i = 0; i < interactiveLoadingScripts.length; i++)
+ if (interactiveLoadingScripts[i].script == s) {
+ if (interactiveScript && interactiveScript.script == s)
+ interactiveScript = null;
+ interactiveLoadingScripts.splice(i, 1);
+ }
+ }
+ else {
+ s.removeEventListener('load', complete, false);
+ s.removeEventListener('error', error, false);
+ }
+
+ head.removeChild(s);
+ }
+ });
+ };
+ });
+})();
diff --git a/lib/scriptOnly.js b/lib/scriptOnly.js
new file mode 100644
index 000000000..f5654958b
--- /dev/null
+++ b/lib/scriptOnly.js
@@ -0,0 +1,17 @@
+/*
+ * Script-only addition used for production loader
+ *
+ */
+hookConstructor(function(constructor) {
+ return function() {
+ constructor.apply(this, arguments);
+ __global.define = this.amdDefine;
+ };
+});
+
+hook('fetch', function(fetch) {
+ return function(load) {
+ load.metadata.scriptLoad = true;
+ return fetch.call(this, load);
+ };
+}); \ No newline at end of file
diff --git a/lib/system-fetch.js b/lib/system-fetch.js
new file mode 100644
index 000000000..fb642caac
--- /dev/null
+++ b/lib/system-fetch.js
@@ -0,0 +1,125 @@
+ var fetchTextFromURL;
+ if (typeof XMLHttpRequest != 'undefined') {
+ fetchTextFromURL = function(url, authorization, fulfill, reject) {
+ var xhr = new XMLHttpRequest();
+ var sameDomain = true;
+ var doTimeout = false;
+ if (!('withCredentials' in xhr)) {
+ // check if same domain
+ var domainCheck = /^(\w+:)?\/\/([^\/]+)/.exec(url);
+ if (domainCheck) {
+ sameDomain = domainCheck[2] === window.location.host;
+ if (domainCheck[1])
+ sameDomain &= domainCheck[1] === window.location.protocol;
+ }
+ }
+ if (!sameDomain && typeof XDomainRequest != 'undefined') {
+ xhr = new XDomainRequest();
+ xhr.onload = load;
+ xhr.onerror = error;
+ xhr.ontimeout = error;
+ xhr.onprogress = function() {};
+ xhr.timeout = 0;
+ doTimeout = true;
+ }
+ function load() {
+ fulfill(xhr.responseText);
+ }
+ function error() {
+ reject(new Error('XHR error' + (xhr.status ? ' (' + xhr.status + (xhr.statusText ? ' ' + xhr.statusText : '') + ')' : '') + ' loading ' + url));
+ }
+
+ xhr.onreadystatechange = function () {
+ if (xhr.readyState === 4) {
+ // in Chrome on file:/// URLs, status is 0
+ if (xhr.status == 0) {
+ if (xhr.responseText) {
+ load();
+ }
+ else {
+ // when responseText is empty, wait for load or error event
+ // to inform if it is a 404 or empty file
+ xhr.addEventListener('error', error);
+ xhr.addEventListener('load', load);
+ }
+ }
+ else if (xhr.status === 200) {
+ load();
+ }
+ else {
+ error();
+ }
+ }
+ };
+ xhr.open("GET", url, true);
+
+ if (xhr.setRequestHeader) {
+ xhr.setRequestHeader('Accept', 'application/x-es-module, */*');
+ // can set "authorization: true" to enable withCredentials only
+ if (authorization) {
+ if (typeof authorization == 'string')
+ xhr.setRequestHeader('Authorization', authorization);
+ xhr.withCredentials = true;
+ }
+ }
+
+ if (doTimeout) {
+ setTimeout(function() {
+ xhr.send();
+ }, 0);
+ } else {
+ xhr.send(null);
+ }
+ };
+ }
+ else if (typeof require != 'undefined' && typeof process != 'undefined') {
+ var fs;
+ fetchTextFromURL = function(url, authorization, fulfill, reject) {
+ if (url.substr(0, 8) != 'file:///')
+ throw new Error('Unable to fetch "' + url + '". Only file URLs of the form file:/// allowed running in Node.');
+ fs = fs || require('fs');
+ if (isWindows)
+ url = url.replace(/\//g, '\\').substr(8);
+ else
+ url = url.substr(7);
+ return fs.readFile(url, function(err, data) {
+ if (err) {
+ return reject(err);
+ }
+ else {
+ // Strip Byte Order Mark out if it's the leading char
+ var dataString = data + '';
+ if (dataString[0] === '\ufeff')
+ dataString = dataString.substr(1);
+
+ fulfill(dataString);
+ }
+ });
+ };
+ }
+ else if (typeof self != 'undefined' && typeof self.fetch != 'undefined') {
+ fetchTextFromURL = function(url, authorization, fulfill, reject) {
+ var opts = {
+ headers: {'Accept': 'application/x-es-module, */*'}
+ };
+
+ if (authorization) {
+ if (typeof authorization == 'string')
+ opts.headers['Authorization'] = authorization;
+ opts.credentials = 'include';
+ }
+
+ fetch(url, opts)
+ .then(function (r) {
+ if (r.ok) {
+ return r.text();
+ } else {
+ throw new Error('Fetch error: ' + r.status + ' ' + r.statusText);
+ }
+ })
+ .then(fulfill, reject);
+ }
+ }
+ else {
+ throw new TypeError('No environment fetch API available.');
+ }
diff --git a/lib/system-only-resolve.js b/lib/system-only-resolve.js
new file mode 100644
index 000000000..e8618c844
--- /dev/null
+++ b/lib/system-only-resolve.js
@@ -0,0 +1,24 @@
+var absURLRegEx = /^([^\/]+:\/\/|\/)/;
+
+// Normalization with module names as absolute URLs
+SystemJSLoader.prototype.normalize = function(name, parentName, parentAddress) {
+ // NB does `import 'file.js'` import relative to the parent name or baseURL?
+ // have assumed that it is baseURL-relative here, but spec may well align with URLs to be the latter
+ // safe option for users is to always use "./file.js" for relative
+
+ // not absolute or relative -> apply paths (what will be sites)
+ if (!name.match(absURLRegEx) && name[0] != '.')
+ name = new URL(applyPaths(this, name) || name, baseURI).href;
+ // apply parent-relative normalization, parentAddress is already normalized
+ else
+ name = new URL(name, parentName || baseURI).href;
+
+ return name;
+};
+
+// default locate is this
+/*
+SystemJSLoader.prototype.locate = function(load) {
+ return load.name;
+};
+*/ \ No newline at end of file
diff --git a/lib/url-polyfill.js b/lib/url-polyfill.js
new file mode 100644
index 000000000..b2a40198a
--- /dev/null
+++ b/lib/url-polyfill.js
@@ -0,0 +1,64 @@
+// from https://gist.github.com/Yaffle/1088850
+(function(global) {
+function URLPolyfill(url, baseURL) {
+ if (typeof url != 'string')
+ throw new TypeError('URL must be a string');
+ var m = String(url).replace(/^\s+|\s+$/g, "").match(/^([^:\/?#]+:)?(?:\/\/(?:([^:@\/?#]*)(?::([^:@\/?#]*))?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/);
+ if (!m)
+ throw new RangeError('Invalid URL format');
+ var protocol = m[1] || "";
+ var username = m[2] || "";
+ var password = m[3] || "";
+ var host = m[4] || "";
+ var hostname = m[5] || "";
+ var port = m[6] || "";
+ var pathname = m[7] || "";
+ var search = m[8] || "";
+ var hash = m[9] || "";
+ if (baseURL !== undefined) {
+ var base = baseURL instanceof URLPolyfill ? baseURL : new URLPolyfill(baseURL);
+ var flag = !protocol && !host && !username;
+ if (flag && !pathname && !search)
+ search = base.search;
+ if (flag && pathname[0] !== "/")
+ pathname = (pathname ? (((base.host || base.username) && !base.pathname ? "/" : "") + base.pathname.slice(0, base.pathname.lastIndexOf("/") + 1) + pathname) : base.pathname);
+ // dot segments removal
+ var output = [];
+ pathname.replace(/^(\.\.?(\/|$))+/, "")
+ .replace(/\/(\.(\/|$))+/g, "/")
+ .replace(/\/\.\.$/, "/../")
+ .replace(/\/?[^\/]*/g, function (p) {
+ if (p === "/..")
+ output.pop();
+ else
+ output.push(p);
+ });
+ pathname = output.join("").replace(/^\//, pathname[0] === "/" ? "/" : "");
+ if (flag) {
+ port = base.port;
+ hostname = base.hostname;
+ host = base.host;
+ password = base.password;
+ username = base.username;
+ }
+ if (!protocol)
+ protocol = base.protocol;
+ }
+
+ // convert URLs to use / always
+ pathname = pathname.replace(/\\/g, '/');
+
+ this.origin = host ? protocol + (protocol !== "" || host !== "" ? "//" : "") + host : "";
+ this.href = protocol + (protocol && host || protocol == "file:" ? "//" : "") + (username !== "" ? username + (password !== "" ? ":" + password : "") + "@" : "") + host + pathname + search + hash;
+ this.protocol = protocol;
+ this.username = username;
+ this.password = password;
+ this.host = host;
+ this.hostname = hostname;
+ this.port = port;
+ this.pathname = pathname;
+ this.search = search;
+ this.hash = hash;
+}
+global.URLPolyfill = URLPolyfill;
+})(typeof self != 'undefined' ? self : global); \ No newline at end of file
diff --git a/lib/wrapper-end.js b/lib/wrapper-end.js
new file mode 100644
index 000000000..e668fd1b6
--- /dev/null
+++ b/lib/wrapper-end.js
@@ -0,0 +1,47 @@
+}
+
+// auto-load Promise polyfill if needed in the browser
+var doPolyfill = typeof Promise === 'undefined';
+
+// document.write
+if (typeof document !== 'undefined') {
+ var scripts = document.getElementsByTagName('script');
+ $__curScript = scripts[scripts.length - 1];
+ if (document.currentScript && ($__curScript.defer || $__curScript.async))
+ $__curScript = document.currentScript;
+ if (!$__curScript.src)
+ $__curScript = undefined;
+ if (doPolyfill) {
+ var curPath = $__curScript.src;
+ var basePath = curPath.substr(0, curPath.lastIndexOf('/') + 1);
+ window.systemJSBootstrap = bootstrap;
+ document.write(
+ '<' + 'script type="text/javascript" src="' + basePath + 'system-polyfills.js">' + '<' + '/script>'
+ );
+ }
+ else {
+ bootstrap();
+ }
+}
+// importScripts
+else if (typeof importScripts !== 'undefined') {
+ var basePath = '';
+ try {
+ throw new Error('_');
+ } catch (e) {
+ e.stack.replace(/(?:at|@).*(http.+):[\d]+:[\d]+/, function(m, url) {
+ $__curScript = { src: url };
+ basePath = url.replace(/\/[^\/]*$/, '/');
+ });
+ }
+ if (doPolyfill)
+ importScripts(basePath + 'system-polyfills.js');
+ bootstrap();
+}
+else {
+ $__curScript = typeof __filename != 'undefined' ? { src: __filename } : null;
+ bootstrap();
+}
+
+
+})();
diff --git a/lib/wrapper-start.js b/lib/wrapper-start.js
new file mode 100644
index 000000000..dda23f0f8
--- /dev/null
+++ b/lib/wrapper-start.js
@@ -0,0 +1,2 @@
+(function() {
+function bootstrap() { \ No newline at end of file
diff --git a/package.json b/package.json
new file mode 100644
index 000000000..a8caf0f3f
--- /dev/null
+++ b/package.json
@@ -0,0 +1,34 @@
+{
+ "name": "systemjs",
+ "version": "0.19.39",
+ "description": "Universal dynamic module loader",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/systemjs/systemjs"
+ },
+ "author": "Guy Bedford",
+ "license": "MIT",
+ "files": [
+ "index.js",
+ "dist"
+ ],
+ "dependencies": {
+ "when": "^3.7.5"
+ },
+ "devDependencies": {
+ "babel-core": "^5.8.22",
+ "qunit": "^0.6.2",
+ "traceur": "0.0.105",
+ "typescript": "^1.6.2",
+ "uglify-js": "~2.4.23"
+ },
+ "scripts": {
+ "test:browser": "make test",
+ "perf": "node bench/normalize-perf.js",
+ "build": "make",
+ "test": "npm run test:babel && npm run test:traceur && npm run test:typescript",
+ "test:babel": "qunit -c s:./index.js -t ./test/test-babel.js",
+ "test:traceur": "qunit -c s:./index.js -t ./test/test-traceur.js",
+ "test:typescript": "qunit -c s:./index.js -t ./test/test-typescript.js"
+ }
+}
diff --git a/test/test-babel-runtime.html b/test/test-babel-runtime.html
new file mode 100644
index 000000000..bb62e1e42
--- /dev/null
+++ b/test/test-babel-runtime.html
@@ -0,0 +1,44 @@
+<!doctype html>
+<html>
+ <head>
+ <link rel="stylesheet" type="text/css" href="../bower_components/qunit/qunit/qunit.css"/>
+ </head>
+ <body>
+
+ <h1 id="qunit-header">SystemJS Test Suite</h1>
+
+ <h2 id="qunit-banner"></h2>
+ <div id="qunit-testrunner-toolbar"></div>
+ <h2 id="qunit-userAgent"></h2>
+ <ol id="qunit-tests"></ol>
+ <div id="qunit-test-area"></div>
+
+ <script src="../dist/system.src.js" type="text/javascript"></script>
+
+ <script src="../bower_components/qunit/qunit/qunit.js"></script>
+
+ <script>
+ QUnit.config.testTimeout = 2000;
+
+ QUnit.module("SystemJS Runtime");
+
+ function err(e) {
+ setTimeout(function() {
+ throw e.stack || e;
+ start();
+ });
+ }
+
+ System.transpiler = 'babel';
+ System.paths['babel/external-helpers'] = '../node_modules/babel-core/external-helpers.js';
+
+ asyncTest('Dynamicall loading modules with Traceur runtime', function() {
+ System['import']('tests/with-runtime-babel.js').then(function(m) {
+ ok(m.c);
+ start();
+ }, err);
+ });
+
+ </script>
+ </body>
+</html> \ No newline at end of file
diff --git a/test/test-babel.html b/test/test-babel.html
new file mode 100644
index 000000000..2cf3d1ea7
--- /dev/null
+++ b/test/test-babel.html
@@ -0,0 +1,29 @@
+<!doctype html>
+<html>
+ <head>
+ <link rel="stylesheet" type="text/css" href="../bower_components/qunit/qunit/qunit.css"/>
+ </head>
+ <body>
+
+ <h1 id="qunit-header">SystemJS Test Suite</h1>
+
+ <h2 id="qunit-banner"></h2>
+ <div id="qunit-testrunner-toolbar"></div>
+ <h2 id="qunit-userAgent"></h2>
+ <ol id="qunit-tests"></ol>
+ <div id="qunit-test-area"></div>
+
+ <script src="../dist/system.src.js" type="text/javascript"></script>
+ <script>
+ System.paths.babel = '../node_modules/babel-core/browser.js';
+ System.transpiler = 'babel';
+ System['import']('test.js')['catch'](function(e) {
+ setTimeout(function() {
+ throw e.stack || e;
+ })
+ });
+ </script>
+
+ <script src="../bower_components/qunit/qunit/qunit.js"></script>
+ </body>
+</html> \ No newline at end of file
diff --git a/test/test-babel.js b/test/test-babel.js
new file mode 100644
index 000000000..062b6158e
--- /dev/null
+++ b/test/test-babel.js
@@ -0,0 +1,3 @@
+System.transpiler = 'babel';
+System.baseURL = 'test/';
+require('./test'); \ No newline at end of file
diff --git a/test/test-csp-inline.html b/test/test-csp-inline.html
new file mode 100644
index 000000000..4f6dce16e
--- /dev/null
+++ b/test/test-csp-inline.html
@@ -0,0 +1,61 @@
+<!doctype html>
+<html>
+ <head>
+ <link rel="stylesheet" type="text/css" href="../bower_components/qunit/qunit/qunit.css"/>
+ <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'nonce-abc';">
+ </head>
+ <body>
+
+ <h1 id="qunit-header">SystemJS Test Suite</h1>
+
+ <h2 id="qunit-banner"></h2>
+ <div id="qunit-testrunner-toolbar"></div>
+ <h2 id="qunit-userAgent"></h2>
+ <ol id="qunit-tests"></ol>
+ <div id="qunit-test-area"></div>
+
+ <script src="../dist/system.src.js" type="text/javascript"></script>
+ <script src="../bower_components/qunit/qunit/qunit.js"></script>
+
+ <script nonce='abc'>
+ QUnit.config.testTimeout = 2000;
+
+ QUnit.module("SystemJS nonce");
+
+ function err(e) {
+ setTimeout(function() {
+ throw e.stack || e;
+ start();
+ });
+ }
+
+ asyncTest('Importing a script with a good nonce', function() {
+ System.config({
+ meta: {
+ 'tests/csp/nonce.js': {
+ nonce: 'abc'
+ }
+ }
+ });
+ System['import']('tests/csp/nonce.js').then(function(m) {
+ ok(m.nonce === 'abc');
+ start();
+ });
+ });
+
+ asyncTest('Importing a script with a bad nonce', function() {
+ System.config({
+ meta: {
+ 'tests/csp/nonce2.js': {
+ nonce: 'asdf'
+ }
+ }
+ });
+ System['import']('tests/csp/nonce2.js').then(function(m) {
+ ok(m.nonce !== 'ab');
+ start();
+ });
+ });
+ </script>
+ </body>
+</html>
diff --git a/test/test-csp.html b/test/test-csp.html
new file mode 100644
index 000000000..f488974f6
--- /dev/null
+++ b/test/test-csp.html
@@ -0,0 +1,280 @@
+<!doctype html>
+<html>
+ <head>
+ <link rel="stylesheet" type="text/css" href="../bower_components/qunit/qunit/qunit.css"/>
+ </head>
+ <body>
+
+ <h1 id="qunit-header">SystemJS Test Suite</h1>
+
+ <h2 id="qunit-banner"></h2>
+ <div id="qunit-testrunner-toolbar"></div>
+ <h2 id="qunit-userAgent"></h2>
+ <ol id="qunit-tests"></ol>
+ <div id="qunit-test-area"></div>
+
+ <script src="../dist/system-csp-production.src.js" type="text/javascript"></script>
+ <script src="../bower_components/qunit/qunit/qunit.js"></script>
+
+ <script>
+ QUnit.config.testTimeout = 2000;
+
+ QUnit.module("SystemJS CSP");
+
+ function err(e) {
+ setTimeout(function() {
+ throw e.stack || e;
+ start();
+ });
+ }
+
+ asyncTest('System version', function() {
+ ok(System.version.match(/^\d+\.\d+\.\d+(-\w+)? CSP$/));
+ start();
+ });
+
+ asyncTest('Loading an AMD module', function() {
+ System['import']('tests/amd-module.js').then(function(m) {
+ ok(m.amd == true);
+ ok(m.dep.amd == 'dep');
+ start();
+ }, err);
+ });
+
+ System.config({
+ bundles: {
+ 'tests/amd-bundle.js': ['bundle-1', 'bundle-2']
+ }
+ });
+ asyncTest('Loading an AMD bundle', function() {
+ System['import']('bundle-1').then(function(m) {
+ ok(m.defined == true);
+ start();
+ }, err);
+
+ stop();
+ System['import']('bundle-2').then(function(m) {
+ ok(m.defined == true);
+ start();
+ }, err);
+ });
+
+ asyncTest('Loading an AMD named define', function() {
+ System['import']('tests/nameddefine.js').then(function() {
+ System['import']('another-define').then(function(m) {
+ ok(m.named == 'define');
+ start();
+ }, err);
+ }, err);
+ });
+
+ asyncTest('Global script with exports as an array', function() {
+ System.config({
+ meta: {
+ 'tests/global-exports-array.js': {
+ exports: ['A', 'B']
+ }
+ }
+ });
+
+ System['import']('tests/global-exports-array.js').then(function(m) {
+ ok(m.A == 'A');
+ ok(m.B == 'B');
+ ok(!m.C);
+ ok(m['default'] == 'A');
+ start();
+ }, err);
+ });
+
+ asyncTest('Loading a badly named AMD define', function() {
+ System['import']('tests/jquery-named.js').then(function(jquery) {
+ ok(jquery.is == 'jquery');
+ start();
+ }, err);
+ });
+
+
+ asyncTest('System.register Circular', function() {
+ System['import']('tests/register-circular1.js').then(function(m) {
+ ok(m.q == 3, 'Binding not allocated');
+ ok(m.r == 5, 'Binding not updated');
+ start();
+ }, err);
+ });
+
+
+ asyncTest('Loading a UMD module', function() {
+ System['import']('tests/umd.js').then(function(m) {
+ ok(m.d == 'hi');
+ start();
+ }, err);
+ });
+
+ asyncTest('Loading a bundle', function() {
+ System['import']('tests/bundle.js').then(function(m) {
+ return System['import']('bundle-define1');
+ })
+ .then(function(m) {
+ ok(m.name == 'bundle1');
+
+ return System['import']('bundle-define2');
+ })
+ .then(function(m) {
+ ok(m.name == 'bundle2');
+
+ start();
+ })
+ ['catch'](err);
+ });
+
+ asyncTest('Loading a bundle on demand', function() {
+
+ System.config({
+ bundles: {
+ 'tests/main-bundle.js': ['jquery']
+ }
+ });
+ System['import']('jquery').then(function(m) {
+ ok(m.name == 'jquery-bundled');
+ start();
+ }, err);
+ });
+
+ System.config({
+ bundles: {
+ 'tests/mixed-bundle.js': ['tree/third', 'tree/cjs', 'tree/jquery', 'tree/second', 'tree/global', 'tree/amd', 'tree/first']
+ }
+ });
+ asyncTest('Loading AMD from a bundle', function() {
+ System['import']('tree/amd').then(function(m) {
+ ok(m.is == 'amd');
+ start();
+ }, err);
+ });
+
+ asyncTest('Loading CommonJS from a bundle', function() {
+ System['import']('tree/cjs').then(function(m) {
+ ok(m.cjs === true);
+ start();
+ }, err);
+ });
+
+ asyncTest('Loading a Global from a bundle', function() {
+ System['import']('tree/global').then(function(m) {
+ ok(m === 'output');
+ start();
+ }, err);
+ });
+
+ asyncTest('Loading named System.register', function() {
+ System['import']('tree/third').then(function(m) {
+ ok(m.some == 'exports');
+ start();
+ }, err);
+ });
+
+ asyncTest('Loading System.register from ES6', function() {
+ System['import']('tree/first').then(function(m) {
+ ok(m.p == 5);
+ start();
+ });
+ });
+
+ asyncTest('Running a simple non-fetch plugin', function() {
+ System.set('tests/es6-plugin', System.newModule({
+ fetch: function() {
+ return '';
+ },
+ instantiate: function() {
+ return "plugin";
+ }
+ }));
+ System['import']('test/file!tests/es6-plugin').then(function(m) {
+ ok(m == 'plugin');
+ start();
+ });
+ });
+
+ asyncTest('Loading a non-registering module', function() {
+ System['import']('tests/global-dep.js')['catch'](function(e) {
+ ok(e.toString().indexOf('did not call System.register or AMD define') != -1);
+ start();
+ });
+ });
+
+ asyncTest('Loading a global with exports defined', function() {
+ System.config({
+ meta: {
+ 'tests/global-single.js': {
+ exports: 'foo'
+ }
+ }
+ });
+ System['import']('tests/global-single.js').then(function(m) {
+ ok(m == 'bar');
+ start();
+ });
+ });
+
+ asyncTest('Loading a precompiled global with exports still defined', function() {
+ System.config({
+ meta: {
+ 'tests/global-single-compiled.js': {
+ exports: 'foobar'
+ }
+ }
+ });
+ System['import']('tests/global-single-compiled.js').then(function(m) {
+ ok(m == 'foo');
+ start();
+ });
+ });
+
+ asyncTest('Importing a script with wrong integrity fails', function() {
+ System.config({
+ meta: {
+ 'tests/csp/integrity.js': {
+ integrity: 'sha256-abc'
+ }
+ }
+ });
+ System['import']('tests/csp/integrity.js').then(err, function(e) {
+ ok(typeof e !== 'undefined');
+ start();
+ });
+ });
+
+ asyncTest('Importing a script with correct integrity', function() {
+ System.config({
+ meta: {
+ 'tests/csp/integrity.js': {
+ integrity: 'sha256-_AfZ2eZSJyVU4HFktUpbsTEoSJF1hL5eGKjgdXZnNTw='
+ }
+ }
+ });
+ System['import']('tests/csp/integrity.js').then(function(m) {
+ ok(m.integrity === 'integrity');
+ start();
+ }, err);
+ });
+
+ asyncTest('Importing jQuery from CDN', function() {
+ System['import']('https://code.jquery.com/jquery-1.11.3.min.js').then(function($) {
+ ok($.fn);
+ start();
+ });
+ });
+
+ asyncTest('Loading package configuration json', function() {
+ System.config({
+ packageConfigPaths: ['tests/testpkg*.json']
+ });
+ System.import('tests/testpkg2')
+ .then(function(m) {
+ ok(m.asdf == 'asdf');
+ start();
+ }, err);
+ })
+ </script>
+ </body>
+</html> \ No newline at end of file
diff --git a/test/test-jsextensions.html b/test/test-jsextensions.html
new file mode 100644
index 000000000..bb64a8f73
--- /dev/null
+++ b/test/test-jsextensions.html
@@ -0,0 +1,112 @@
+<!doctype html>
+<html>
+ <head>
+ <link rel="stylesheet" type="text/css" href="../bower_components/qunit/qunit/qunit.css"/>
+ <script src="../bower_components/qunit/qunit/qunit.js"></script>
+ </head>
+ <body>
+
+ <h1 id="qunit-header">SystemJS Test Suite</h1>
+
+ <h2 id="qunit-banner"></h2>
+ <div id="qunit-testrunner-toolbar"></div>
+ <h2 id="qunit-userAgent"></h2>
+ <ol id="qunit-tests"></ol>
+ <div id="qunit-test-area"></div>
+
+ <script>
+ // test polyfill loading
+ // window.URL = undefined;
+ </script>
+
+ <script src="../dist/system.src.js" type="text/javascript"></script>
+ <script>
+ System.traceurOptions = { asyncFunctions: true };
+ System.paths.traceur = '../node_modules/traceur/bin/traceur.js';
+
+ QUnit.config.testTimeout = 2000;
+
+ QUnit.module("SystemJS JS Extensions");
+
+ System.config({
+ defaultJSExtensions: true
+ });
+
+ asyncTest('Error handling', function() {
+ System['import']('tests/main').then(function(m) {
+ ok(m.dep == 'value');
+ start();
+ });
+ });
+
+ asyncTest('Pathing extension handling', function() {
+ System.config({
+ paths: {
+ 'path': 'tests/main'
+ },
+ packages: {
+ 'tests/testpkg': {
+ basePath: 'lib',
+ defaultExtension: 'ts',
+ map: {
+ './asdf': './test.ts'
+ }
+ },
+ 'tests/subcontextual-map': {
+ main: 'submodule',
+ map: {
+ dep: 'path'
+ }
+ }
+ }
+ });
+
+ Promise.all([
+ System['import']('path'),
+ System['import']('tests/testpkg/asdf'),
+ System['import']('tests/subcontextual-map'),
+ System['import']('tests/main-dep'),
+ System['import']('tests/main-dep.js')
+ ])
+ .then(function(mods) {
+ ok(mods[0].dep == 'value');
+ ok(mods[1] == 'ts');
+ ok(mods[2].dep == 'value');
+ ok(mods[3] == mods[2]);
+ ok(mods[3] == mods[4]);
+ start();
+ })
+ });
+
+ System.config({
+ packages: {
+ 'custom': {
+ defaultExtension: 'ext'
+ }
+ }
+ });
+ asyncTest('Register extensions', function(err) {
+ System['import']('tests/register-default-extension.js').then(function() {
+ System['import']('custom/file.ext').then(function(m) {
+ ok(m.custom == 'ext');
+ start();
+ }, err);
+ }, err);
+ });
+
+ System.config({
+ packages: {
+ 'tests/no-default-ext': {
+ defaultExtension: false
+ }
+ }
+ });
+ asyncTest('No default extension', function(err) {
+ System['import']('tests/no-default-ext/file.ext').then(function(m) {
+ ok(m.ext == 'ext');
+ start();
+ }, err);
+ });
+ </script>
+ </body>
+</html> \ No newline at end of file
diff --git a/test/test-register-only.html b/test/test-register-only.html
new file mode 100644
index 000000000..65ff64100
--- /dev/null
+++ b/test/test-register-only.html
@@ -0,0 +1,45 @@
+<!doctype html>
+<html>
+ <head>
+ <link rel="stylesheet" type="text/css" href="../bower_components/qunit/qunit/qunit.css"/>
+ </head>
+ <body>
+
+ <h1 id="qunit-header">SystemJS Test Suite</h1>
+
+ <h2 id="qunit-banner"></h2>
+ <div id="qunit-testrunner-toolbar"></div>
+ <h2 id="qunit-userAgent"></h2>
+ <ol id="qunit-tests"></ol>
+ <div id="qunit-test-area"></div>
+
+ <script src="../dist/system-register-only.src.js" type="text/javascript"></script>
+ <script src="../bower_components/qunit/qunit/qunit.js"></script>
+
+ <script>
+ QUnit.config.testTimeout = 2000;
+
+ QUnit.module("SystemJS CSP");
+
+ function err(e) {
+ setTimeout(function() {
+ throw e.stack || e;
+ start();
+ });
+ }
+
+ asyncTest('System version', function() {
+ ok(System.version.match(/^\d+\.\d+\.\d+(-\w+)? Register Only$/));
+ start();
+ });
+
+ asyncTest('System.register Circular', function() {
+ System['import']('tests/register-circular1.js').then(function(m) {
+ ok(m.q == 3, 'Binding not allocated');
+ ok(m.r == 5, 'Binding not updated');
+ start();
+ }, err);
+ });
+ </script>
+ </body>
+</html> \ No newline at end of file
diff --git a/test/test-tracer.html b/test/test-tracer.html
new file mode 100644
index 000000000..52075004f
--- /dev/null
+++ b/test/test-tracer.html
@@ -0,0 +1,71 @@
+<!doctype html>
+<html>
+ <head>
+ <link rel="stylesheet" type="text/css" href="../bower_components/qunit/qunit/qunit.css"/>
+ </head>
+ <body>
+
+ <h1 id="qunit-header">SystemJS Test Suite</h1>
+
+ <h2 id="qunit-banner"></h2>
+ <div id="qunit-testrunner-toolbar"></div>
+ <h2 id="qunit-userAgent"></h2>
+ <ol id="qunit-tests"></ol>
+ <div id="qunit-test-area"></div>
+
+ <script src="../dist/system.src.js" type="text/javascript"></script>
+
+ <script src="../bower_components/qunit/qunit/qunit.js"></script>
+
+ <script>
+ System.paths.traceur = '../node_modules/traceur/bin/traceur.js';
+
+ QUnit.config.testTimeout = 2000;
+
+ QUnit.module("SystemJS Tracer");
+
+ function err(e) {
+ setTimeout(function() {
+ throw e.stack || e;
+ start();
+ });
+ }
+
+ // enable tracing
+ System.pluginLoader = new System.constructor();
+ System.pluginLoader.paths = System.paths;
+ System.pluginLoader.baseURL = System.baseURL;
+ System.trace = true;
+ // System.execute = false;
+
+ asyncTest('ES6 Circular', function() {
+ System['import']('tests/es6-circular1.js').then(function(m) {
+ ok(System.loads[System.normalizeSync('tests/es6-circular1.js')].deps[0] == './es6-circular2.js');
+ start();
+ }, err);
+ });
+
+ asyncTest('AMD & CJS circular, ES6 Circular', function() {
+ System['import']('tests/all-circular1.js').then(function(m) {
+ ok(System.loads[System.normalizeSync('tests/all-circular1.js')].deps[0] == './all-circular2.js');
+ start();
+ }, err);
+ });
+
+ asyncTest('AMD -> System.register circular -> ES6', function() {
+ System['import']('tests/all-layers1.js').then(function(m) {
+ ok(System.loads[System.normalizeSync('tests/all-layers1.js')].deps[0] == './all-layers2.js');
+ start();
+ }, err);
+ });
+
+ asyncTest('Advanced compiler plugin', function() {
+ System['import']('tests/compiler-test.coffee!tests/advanced-plugin.js').then(function(m) {
+ ok(true);
+ start();
+ }, err);
+ });
+
+ </script>
+ </body>
+</html> \ No newline at end of file
diff --git a/test/test-traceur.html b/test/test-traceur.html
new file mode 100644
index 000000000..87f4cd23d
--- /dev/null
+++ b/test/test-traceur.html
@@ -0,0 +1,34 @@
+<!doctype html>
+<html>
+ <head>
+ <link rel="stylesheet" type="text/css" href="../bower_components/qunit/qunit/qunit.css"/>
+ </head>
+ <body>
+
+ <h1 id="qunit-header">SystemJS Test Suite</h1>
+
+ <h2 id="qunit-banner"></h2>
+ <div id="qunit-testrunner-toolbar"></div>
+ <h2 id="qunit-userAgent"></h2>
+ <ol id="qunit-tests"></ol>
+ <div id="qunit-test-area"></div>
+
+ <script>
+ // test polyfill loading
+ // window.URL = undefined;
+ </script>
+
+ <script src="../dist/system.src.js" type="text/javascript"></script>
+ <script>
+ System.traceurOptions = { asyncFunctions: true };
+ System.paths.traceur = '../node_modules/traceur/bin/traceur.js';
+ System['import']('test.js')['catch'](function(e) {
+ setTimeout(function() {
+ throw e.stack || e;
+ });
+ });
+ </script>
+
+ <script src="../bower_components/qunit/qunit/qunit.js"></script>
+ </body>
+</html> \ No newline at end of file
diff --git a/test/test-traceur.js b/test/test-traceur.js
new file mode 100644
index 000000000..983f51b36
--- /dev/null
+++ b/test/test-traceur.js
@@ -0,0 +1,3 @@
+System.transpiler = 'traceur';
+System.baseURL = 'test/';
+require('./test'); \ No newline at end of file
diff --git a/test/test-typescript.html b/test/test-typescript.html
new file mode 100644
index 000000000..4258164c9
--- /dev/null
+++ b/test/test-typescript.html
@@ -0,0 +1,31 @@
+<!doctype html>
+<html>
+ <head>
+ <link rel="stylesheet" type="text/css" href="../bower_components/qunit/qunit/qunit.css"/>
+ </head>
+ <body>
+
+ <h1 id="qunit-header">SystemJS Test Suite</h1>
+
+ <h2 id="qunit-banner"></h2>
+ <div id="qunit-testrunner-toolbar"></div>
+ <h2 id="qunit-userAgent"></h2>
+ <ol id="qunit-tests"></ol>
+ <div id="qunit-test-area"></div>
+
+ <!-- <script src="../bower_components/traceur/traceur.js"></script> -->
+ <script src="../node_modules/es6-module-loader/dist/es6-module-loader.src.js"></script>
+ <script src="../dist/system.src.js" type="text/javascript"></script>
+ <script>
+ System.paths['typescript'] = '../node_modules/typescript/lib/typescript.js';
+ System.transpiler = 'typescript';
+ System['import']('test.js')['catch'](function(e) {
+ setTimeout(function() {
+ throw e;
+ })
+ });
+ </script>
+
+ <script src="../bower_components/qunit/qunit/qunit.js"></script>
+ </body>
+</html> \ No newline at end of file
diff --git a/test/test-typescript.js b/test/test-typescript.js
new file mode 100644
index 000000000..e7a858309
--- /dev/null
+++ b/test/test-typescript.js
@@ -0,0 +1,4 @@
+global.ts = require('typescript');
+System.transpiler = 'typescript';
+System.baseURL = 'test/';
+require('./test'); \ No newline at end of file
diff --git a/test/test.js b/test/test.js
new file mode 100644
index 000000000..6d981d761
--- /dev/null
+++ b/test/test.js
@@ -0,0 +1,1462 @@
+"format global";
+
+(function(global) {
+
+QUnit.config.testTimeout = 30000;
+
+QUnit.module("SystemJS");
+
+if (typeof window == 'undefined')
+ System.baseURL = 'test';
+
+function err(e) {
+ setTimeout(function() {
+ if (typeof window == 'undefined')
+ console.log(e && e.stack || e);
+ else
+ throw e;
+ start();
+ });
+}
+
+var ie8 = typeof navigator != 'undefined' && navigator.appVersion && navigator.appVersion.indexOf('MSIE 8') != -1;
+
+asyncTest('System version', function() {
+ ok(System.version.match(/^\d+\.\d+\.\d+(-\w+)? (Standard|Node)$/));
+ start();
+});
+
+asyncTest('new Module().toString() == "Module"', function() {
+ System['import']('tests/global.js').then(function() {
+ var m = System.get(System.normalizeSync('tests/global.js'));
+ ok(m == 'Module');
+ start();
+ });
+});
+
+asyncTest('Error handling', function() {
+ System['import']('tests/error-loader.js').then(err, function(e) {
+ ok(true);
+ start();
+ });
+});
+
+asyncTest('Error handling2', function() {
+ System['import']('tests/error-loader2.js').then(err, function(e) {
+ if (typeof console != 'undefined' && console.error)
+ console.error(e);
+ ok(true);
+ start();
+ });
+});
+
+if (!ie8)
+asyncTest('Global script loading', function() {
+ System['import']('tests/global.js').then(function(m) {
+ ok(m.jjQuery && m.another, 'Global objects not defined');
+ start();
+ }, err);
+});
+
+if (!ie8)
+asyncTest('Global script with var syntax', function() {
+ System['import']('tests/global-single.js').then(function(m) {
+ ok(m == 'bar', 'Wrong global value');
+ start();
+ }, err);
+});
+
+asyncTest('Global script with multiple objects the same', function() {
+ System['import']('tests/global-multi.js').then(function(m) {
+ ok(m.jquery == 'here', 'Multi globals not detected');
+ start();
+ }, err);
+});
+
+if (!ie8)
+asyncTest('Global script multiple objects different', function() {
+ System['import']('tests/global-multi-diff.js').then(function(m) {
+ ok(m.foo == 'barz');
+ ok(m.baz == 'chaz');
+ ok(m.zed == 'ted');
+ start();
+ }, err);
+});
+
+asyncTest('Global script loading with inline shim', function() {
+ System['import']('tests/global-inline-dep.js').then(function(m) {
+ ok(m == '1.8.3', 'Global dependency not defined');
+ start();
+ }, err);
+});
+
+asyncTest('Global script with inline exports', function() {
+ System['import']('tests/global-inline-export.js').then(function(m) {
+ ok(m == 'r', 'Inline export not applied');
+ start();
+ }, err);
+});
+
+asyncTest('Global script with shim config', function() {
+ System.config({
+ meta: {
+ 'tests/global-shim-config.js': {
+ deps: ['./global-shim-config-dep.js']
+ }
+ }
+ });
+ // System. = { deps: ['./global-shim-config-dep.js'] };
+ System['import']('tests/global-shim-config.js').then(function(m) {
+ ok(m == 'shimmed', 'Not shimmed');
+ start();
+ }, err);
+});
+
+if (!ie8)
+asyncTest('Global script with inaccessible properties', function() {
+ Object.defineProperty(System.global, 'errorOnAccess', {
+ configurable: true,
+ enumerable: true,
+ get: function() { throw Error('This property is inaccessible'); },
+ });
+
+ System['import']('tests/global-inaccessible-props.js').then(function(m) {
+ ok(m == 'result of global-inaccessible-props', 'Failed due to a inaccessible property');
+
+ delete System.global.errorOnAccess;
+ start();
+ }, err);
+});
+
+asyncTest('Global script loading that detects as AMD with shim config', function() {
+ System.config({
+ meta: {
+ 'tests/global-shim-amd.js': { format: 'global' }
+ }
+ });
+
+ System['import']('tests/global-shim-amd.js').then(function(m) {
+ ok(m == 'global', 'Not shimmed');
+ start();
+ }, err);
+});
+
+asyncTest('Global script with exports as an array', function() {
+ System.config({
+ meta: {
+ 'tests/global-exports-array.js': {
+ exports: ['A', 'B']
+ }
+ }
+ });
+
+ System['import']('tests/global-exports-array.js').then(function(m) {
+ ok(m.A == 'A');
+ ok(m.B == 'B');
+ ok(!m.C);
+ ok(m['default'] == 'A');
+ start();
+ }, err);
+});
+
+asyncTest('Global with encapsulated execution', function() {
+ System.config({
+ meta: {
+ 'tests/global-encapsulation.js': {
+ encapsulateGlobal: true
+ }
+ }
+ });
+
+ System['import']('tests/global-encapsulation.js').then(function(m) {
+ ok(m == 'encapsulated global');
+ ok(global.globalName === undefined);
+ start();
+ }, err);
+});
+
+if (!ie8)
+asyncTest('Meta should override meta syntax', function() {
+ System.meta[System.normalizeSync('tests/meta-override.js')] = { format: 'esm' };
+ System['import']('tests/meta-override.js').then(function(m) {
+ ok(m.p == 'value', 'Not ES6');
+ start();
+ }, err);
+});
+
+asyncTest('Support the empty module', function() {
+ System['import']('@empty').then(function(m) {
+ ok(m, 'No empty module');
+ start();
+ }, err);
+});
+
+asyncTest('Global script with shim config exports', function() {
+ System.meta[System.normalizeSync('tests/global-shim-config-exports.js')] = { exports: 'p' };
+ System['import']('tests/global-shim-config-exports.js').then(function(m) {
+ ok(m == 'export', 'Exports not shimmed');
+ start();
+ }, err);
+});
+
+asyncTest('Map configuration', function() {
+ System.map['maptest'] = 'tests/map-test.js';
+ System['import']('maptest').then(function(m) {
+ ok(m.maptest == 'maptest', 'Mapped module not loaded');
+ start();
+ }, err);
+});
+
+asyncTest('Map configuration subpath', function() {
+ System.map['maptest'] = 'tests/map-test';
+ System['import']('maptest/sub.js').then(function(m) {
+ ok(m.maptest == 'maptestsub', 'Mapped folder not loaded');
+ start();
+ }, err);
+});
+
+asyncTest('Contextual map configuration', function() {
+ System.config({
+ packages: {
+ 'tests/contextual-test': {
+ main: 'contextual-map.js'
+ }
+ },
+ map: {
+ 'tests/contextual-test': {
+ maptest: '../contextual-map-dep.js'
+ }
+ }
+ });
+ System['import']('tests/contextual-test').then(function(m) {
+ ok(m.mapdep == 'mapdep', 'Contextual map dep not loaded');
+ start();
+ }, err);
+});
+
+asyncTest('Contextual map configuration for a package that is a file', function() {
+ System.config({
+ packages: {
+ 'tests/jquery.js': {
+ meta: {
+ '*': {
+ deps: ['a']
+ }
+ },
+ map: {
+ 'a': 'tests/amd-dep-A.js'
+ }
+ }
+ },
+ map: {
+ jquery: 'tests/jquery.js'
+ }
+ });
+ System['import']('tests/jquery.js').then(function(m) {
+ ok(m == 10);
+ start();
+ }, err);
+})
+
+asyncTest('Package map with shim', function() {
+ System.config({
+ packages: {
+ 'tests/shim-package': {
+ meta: {
+ '*': {
+ deps: ['shim-map-dep']
+ }
+ },
+ map: {
+ 'shim-map-dep': '../shim-map-test-dep.js'
+ }
+ }
+ }
+ });
+ System['import']('tests/shim-package/shim-map-test.js').then(function(m) {
+ ok(m == 'depvalue', 'shim dep not loaded');
+ start();
+ }, err);
+});
+
+asyncTest('Loading an AMD module', function() {
+ System.config({
+ meta: {
+ 'tests/amd-module.js': {
+ format: 'amd'
+ }
+ }
+ });
+ System['import']('tests/amd-module.js').then(function(m) {
+ ok(m.amd == true, 'Incorrect module');
+ ok(m.dep.amd == 'dep', 'Dependency not defined');
+ start();
+ }, err);
+});
+
+asyncTest('AMD detection test', function() {
+ System['import']('tests/amd-module-2.js').then(function(m) {
+ ok(m.amd);
+ start();
+ }, err);
+});
+
+asyncTest('AMD detection test with comments', function() {
+ System['import']('tests/amd-module-3.js').then(function(m) {
+ ok(m.amd);
+ start();
+ }, err);
+});
+
+asyncTest('AMD detection test with byte order mark (BOM)', function() {
+ System['import']('tests/amd-module-bom.js').then(function(m) {
+ ok(m.amd);
+ start();
+ }, err);
+});
+
+asyncTest('AMD with dynamic require callback', function() {
+ System['import']('tests/amd-dynamic-require.js').then(function(m) {
+ m.onCallback(function(m) {
+ ok(m === 'dynamic');
+ start();
+ });
+ });
+});
+
+asyncTest('Loading an AMD bundle', function() {
+ System.config({
+ bundles: {
+ 'tests/amd-bundle.js': ['bundle-*']
+ }
+ });
+ System['import']('bundle-1').then(function(m) {
+ ok(m.defined == true);
+ start();
+ }, err);
+
+ stop();
+ System['import']('bundle-2').then(function(m) {
+ ok(m.defined == true);
+ start();
+ }, err);
+});
+
+asyncTest('Loading an AMD named define', function() {
+ System['import']('tests/nameddefine.js').then(function(m1) {
+ ok(m1.converter, 'Showdown not loaded');
+ System['import']('another-define').then(function(m2) {
+ ok(m2.named === 'define', 'Another module is not defined');
+ start();
+ }, err);
+ }, err);
+});
+
+asyncTest('Loading an AMD bundle with an anonymous define', function() {
+ System['import']('tests/anon-named.js').then(function(m) {
+ ok(m.anon == true);
+ start();
+ }, err);
+});
+
+asyncTest('Loading an AMD bundle with multiple anonymous defines', function() {
+ System['import']('tests/multiple-anonymous.js').then(function(m) {
+ ok(false);
+ start();
+ }, function(e) {
+ ok(e.toString().indexOf('Multiple anonymous') != -1)
+ start();
+ });
+})
+
+asyncTest('Loading AMD CommonJS form', function() {
+ System['import']('tests/amd-cjs-module.js').then(function(m) {
+ ok(m.test == 'hi', 'Not defined');
+ start();
+ }, err);
+});
+
+asyncTest('AMD contextual require toUrl', function() {
+ System['import']('tests/amd-contextual.js').then(function(m) {
+ ok(m.name == System.baseURL + 'tests/amd-contextual.js');
+ ok(m.rel == System.baseURL + 'rel-path.js');
+ start();
+ }, err);
+});
+
+// TODO: fix!
+/* asyncTest('AMD race condition test', function() {
+ System.config({
+ bundles: {
+ "tests/out.js": ["tests/lib/modB.js"]
+ }
+ });
+
+ var completed = 0;
+ function completeImport() {
+ if (++completed == 3) {
+ ok(true);
+ start();
+ }
+ }
+
+ System.import('tests/modA.js').then(completeImport, err);
+ setTimeout(function () {
+ System.import('tests/modC.js').then(completeImport, err);
+ System.import('tests/lib/modB.js').then(completeImport, err);
+ }, 10);
+}); */
+
+asyncTest('Loading a CommonJS module', function() {
+ System['import']('tests/common-js-module.js').then(function(m) {
+ ok(m.hello == 'world', 'module value not defined');
+ ok(m.first == 'this is a dep', 'dep value not defined');
+ start();
+ }, err);
+});
+
+asyncTest('Loading a CommonJS module with this', function() {
+ System['import']('tests/cjs-this.js').then(function(m) {
+ ok(m.asdf == 'module value');
+ start();
+ }, err);
+});
+
+asyncTest('CommonJS setting module.exports', function() {
+ System['import']('tests/cjs-exports.js').then(function(m) {
+ ok(m.e == 'export');
+ start();
+ }, err);
+});
+
+asyncTest('CommonJS detection variation 1', function() {
+ System['import']('tests/commonjs-variation.js').then(function(m) {
+ ok(m.e === System.get('@empty'));
+ start();
+ }, err);
+});
+
+if (!ie8)
+asyncTest('CommonJS detection variation 2', function() {
+ System['import']('tests/commonjs-variation2.js').then(function(m) {
+ ok(typeof m.OpaqueToken === 'function');
+ start();
+ }, err);
+});
+
+asyncTest('CommonJS detection test with byte order mark (BOM)', function() {
+ System['import']('tests/cjs-exports-bom.js').then(function(m) {
+ ok(m.foo == 'bar');
+ start();
+ }, err);
+});
+
+asyncTest('CommonJS module detection test with byte order mark (BOM)', function() {
+ System['import']('tests/cjs-module-bom.js').then(function(m) {
+ ok(m.foo == 'bar');
+ start();
+ }, err);
+});
+
+asyncTest('CommonJS require variations', function() {
+ System['import']('tests/commonjs-requires.js').then(function(m) {
+ ok(m.d1 == 'd');
+ ok(m.d2 == 'd');
+ ok(m.d3 == "require('not a dep')");
+ ok(m.d4 == "text/* require('still not a dep') text");
+ ok(m.d5 == 'text \'quote\' require("yet still not a dep")');
+ ok(m.d6 == 'd6');
+ ok(m.d7 == 'export');
+ start();
+ }, err);
+});
+
+asyncTest('CommonJS globals', function() {
+ System.config({
+ meta: {
+ 'tests/commonjs-globals.js': {
+ globals: {
+ process: './cjs-process.js'
+ }
+ }
+ }
+ });
+ System['import']('tests/commonjs-globals.js').then(function(m) {
+ ok(m.process.env.NODE_ENV)
+ start();
+ }, err);
+});
+
+asyncTest('CommonJS require.resolve', function() {
+ System['import']('tests/cjs-resolve.js').then(function(m) {
+ ok(m.substr(m.length - 12, 12) == 'test/tests/a');
+ start();
+ }, err);
+})
+
+asyncTest('Loading a UMD module', function() {
+ System['import']('tests/umd.js').then(function(m) {
+ ok(m.d == 'hi', 'module value not defined');
+ start();
+ }, err);
+});
+
+asyncTest('Loading AMD with format hint', function() {
+ System['import']('tests/amd-format.js').then(function(m) {
+ ok(m.amd == 'amd', 'AMD not loaded');
+ start();
+ }, err);
+});
+
+asyncTest('Loading CJS with format hint', function() {
+ System['import']('tests/cjs-format.js').then(function(m) {
+ ok(m.cjs == 'cjs', 'CJS not loaded');
+ start();
+ }, err);
+});
+
+asyncTest('CommonJS globals', function() {
+ System['import']('tests/cjs-globals.js').then(function(m) {
+ ok(m.filename.match(/tests\/cjs-globals\.js$/));
+ ok(m.dirname.match(/\/tests$/));
+ ok(m.global == global);
+ start();
+ }, err);
+});
+
+asyncTest('Versions', function() {
+ System['import']('tests/zero@0.js').then(function(m) {
+ ok(m == '0');
+ start()
+ }, err);
+});
+
+asyncTest('Loading a module with # in the name', function() {
+ System['import']('tests/#.js').then(function(m) {
+ ok(m == '#');
+ start();
+ }, err);
+});
+
+asyncTest('Simple compiler Plugin', function() {
+ System.map['coffee'] = 'tests/compiler-plugin.js';
+ System['import']('tests/compiler-test.coffee!').then(function(m) {
+ ok(m.output == 'plugin output', 'Plugin not working.');
+ ok(m.extra == 'yay!', 'Compiler not working.');
+ start();
+ }, err);
+});
+
+asyncTest('Mapping a plugin argument', function() {
+ System.map['bootstrap'] = 'tests/bootstrap@3.1.1';
+ System.map['coffee'] = 'tests/compiler-plugin.js';
+ System['import']('bootstrap/test.coffee!coffee').then(function(m) {
+ ok(m.extra == 'yay!', 'not working');
+ start();
+ }, err);
+});
+
+asyncTest('Using pluginFirst config', function() {
+ System.pluginFirst = true;
+ System.map['bootstrap'] = 'tests/bootstrap@3.1.1';
+ System.map['coffee'] = 'tests/compiler-plugin.js';
+ System['import']('coffee!bootstrap/test.coffee').then(function(m) {
+ ok(m.extra == 'yay!', 'not working');
+ System.pluginFirst = false;
+ start();
+ }, err);
+});
+
+asyncTest('Advanced compiler plugin', function() {
+ System['import']('tests/compiler-test.js!tests/advanced-plugin.js').then(function(m) {
+ ok(m == 'custom fetch:' + System.baseURL + 'tests/compiler-test.js!' + System.baseURL + 'tests/advanced-plugin.js', m);
+ start();
+ }, err);
+});
+
+asyncTest('Plugin as a dependency', function() {
+ System.map['css'] = 'tests/css.js';
+ System['import']('tests/cjs-loading-plugin.js').then(function(m) {
+ ok(m.pluginSource == 'this is css');
+ start();
+ }, err);
+});
+
+asyncTest('AMD Circular', function() {
+ System['import']('tests/amd-circular1.js').then(function(m) {
+ ok(m.outFunc() == 5, 'Expected execution');
+ start();
+ })['catch'](err);
+});
+
+asyncTest('CJS Circular', function() {
+ System['import']('tests/cjs-circular1.js').then(function(m) {
+ ok(m.first == 'second value');
+ ok(m.firstWas == 'first value', 'Original value');
+ start();
+ }, err);
+});
+
+asyncTest('System.register Circular', function() {
+ System.config({
+ meta: {
+ 'tests/register-circular1.js': {
+ scriptLoad: true
+ }
+ }
+ });
+ System['import']('tests/register-circular1.js').then(function(m) {
+ ok(m.q == 3, 'Binding not allocated');
+ ok(m.r == 5, 'Binding not updated');
+ start();
+ }, err);
+});
+
+asyncTest('System.register regex test', function() {
+ System['import']('tests/register-regex.js').then(function(m) {
+ ok(m);
+ start();
+ }, err);
+});
+
+asyncTest('System.register regex test 2', function() {
+ System['import']('tests/register-regex-2.js').then(function(m) {
+ ok(m);
+ start();
+ }, err);
+});
+
+asyncTest('System.register module name arg', function() {
+ System['import']('tests/module-name.js').then(function(m) {
+ ok(m.name == System.baseURL + 'tests/module-name.js');
+ start();
+ }, err);
+});
+
+asyncTest('System.register group linking test', function() {
+ System.config({
+ bundles: {
+ 'tests/group-test.js': ['group-a']
+ }
+ });
+ System['import']('group-a').then(function(m) {
+ ok(m);
+ start();
+ }, err);
+});
+
+System.config({
+ bundles: {
+ 'tests/mixed-bundle.js': ['tree/third', 'tree/cjs', 'tree/jquery', 'tree/second', 'tree/global', 'tree/amd', 'tree/first']
+ }
+});
+
+asyncTest('Loading AMD from a bundle', function() {
+ System['import']('tree/amd').then(function(m) {
+ ok(m.is == 'amd');
+ start();
+ }, err);
+});
+
+asyncTest('Loading CommonJS from a bundle', function() {
+ System['import']('tree/cjs').then(function(m) {
+ ok(m.cjs === true);
+ start();
+ }, err);
+});
+
+asyncTest('Loading a Global from a bundle', function() {
+ System['import']('tree/global').then(function(m) {
+ ok(m === 'output');
+ start();
+ }, err);
+});
+
+asyncTest('Loading named System.register', function() {
+ System['import']('tree/third').then(function(m) {
+ ok(m.some == 'exports');
+ start();
+ }, err);
+});
+asyncTest('Loading System.register from ES6', function() {
+ System.config({
+ meta: {
+ 'tree/first': {
+ format: 'esm'
+ }
+ }
+ });
+ System['import']('tree/first').then(function(m) {
+ ok(m.p == 5);
+ start();
+ }, err);
+});
+
+asyncTest('AMD simplified CommonJS wrapping with an aliased require', function() {
+ System['import']('tests/amd-simplified-cjs-aliased-require1.js').then(function(m) {
+ ok(m.require2,"got dependency from aliased require");
+ ok(m.require2.amdCJS,"got dependency from aliased require listed as a dependency");
+ start();
+ }, err);
+});
+
+asyncTest('Loading dynamic modules with __esModule flag set', function() {
+ System['import']('tests/es-module-flag.js').then(function() {
+ m = System.get(System.normalizeSync('tests/es-module-flag.js'));
+ ok(m.exportName == 'export');
+ ok(m['default'] == 'default export');
+ ok(m.__esModule === true);
+ start();
+ }, err);
+});
+
+if (!ie8) {
+asyncTest('ES6 named export loading of CJS', function() {
+ System['import']('tests/es-named-import-cjs.js').then(function(m) {
+ ok(m.cjsFuncValue === 'named export');
+ start();
+ });
+});
+
+// TypeScript does not support async functions yet
+if (System.transpiler !== 'typescript')
+asyncTest('Async functions', function() {
+ System.babelOptions = { stage: 0 };
+ System.traceurOptions = { asyncFunctions: true };
+ System['import']('tests/async.js').then(function(m) {
+ ok(true);
+ start();
+ });
+});
+
+if (System.transpiler !== 'typescript')
+asyncTest('Wrapper module support', function() {
+ System['import']('tests/wrapper.js').then(function(m) {
+ ok(m.d == 'default1', 'Wrapper module not defined.');
+ start();
+ }, err);
+});
+
+asyncTest('ES6 plugin', function() {
+ System['import']('tests/blah.js!tests/es6-plugin.js').then(function(m) {
+ ok(m == 'plugin');
+ start();
+ }, err);
+});
+
+asyncTest('ES6 detection', function() {
+ System['import']('tests/es6-detection1.js').then(function(m) {
+ ok(true);
+ start();
+ }, err);
+});
+
+asyncTest('Basic exporting & importing', function() {
+ var m1, m2, m3, m4, err;
+ var checkComplete = function() {
+ if (m1 && m2 && m3 && m4 && err) {
+ ok(m1['default'] == 'default1', 'Error defining default 1');
+ ok(m2['default'] == 'default2', 'Error defining default 2');
+ ok(m3['default'] == 'default3', 'Error defining default 3');
+ ok(m4.test == 'default3', 'Error defining module');
+ start();
+ }
+ };
+ System['import']('tests/default1.js').then(function(_m1) {
+ if (m1 === undefined)
+ m1 = null;
+ else
+ m1 = _m1;
+ checkComplete();
+ })['catch'](err);
+ System['import']('tests/default1.js').then(function(_m1) {
+ if (m1 === undefined)
+ m1 = null;
+ else
+ m1 = _m1;
+ checkComplete();
+ })['catch'](err);
+ System['import']('tests/default2.js').then(function(_m2) {
+ m2 = _m2;
+ checkComplete();
+ })['catch'](err);
+ System['import']('tests/asdf.js').then(function() {
+ }, function(_err) {
+ err = _err;
+ checkComplete();
+ })['catch'](err);
+ System['import']('tests/default3.js').then(function(_m3) {
+ m3 = _m3;
+ checkComplete();
+ })['catch'](err);
+ System['import']('tests/module.js').then(function(_m4) {
+ m4 = _m4;
+ checkComplete();
+ })['catch'](err);
+});
+
+asyncTest('Export Star', function(assert) {
+ System['import']('tests/export-star.js').then(function(m) {
+ ok(m.foo == 'foo');
+ ok(m.bar == 'bar');
+ start();
+ }, err);
+});
+
+asyncTest('Importing a mapped loaded module', function() {
+ System.map['default1'] = 'tests/default1.js';
+ System['import']('default1').then(function(m) {
+ System['import']('default1').then(function(m) {
+ ok(m, 'no module');
+ start();
+ }, err);
+ }, err);
+});
+
+asyncTest('Loading empty ES6', function() {
+ System['import']('tests/empty-es6.js').then(function(m) {
+ ok(m && emptyES6);
+ start();
+ }, err);
+})
+
+asyncTest('Loading ES6 with format hint', function() {
+ System['import']('tests/es6-format.js').then(function(m) {
+ expect(0);
+ start();
+ }, err);
+});
+
+asyncTest('Loading ES6 loading AMD', function() {
+ System['import']('tests/es6-loading-amd.js').then(function(m) {
+ ok(m.amd == true);
+ start();
+ })
+});
+
+asyncTest('Loading AMD with import *', function() {
+ System['import']('tests/es6-import-star-amd.js').then(function(m) {
+ ok(m.g == true);
+ start();
+ }, err);
+});
+
+asyncTest('Loading ES6 and AMD', function() {
+ System['import']('tests/es6-and-amd.js').then(function(m) {
+ ok(m.amd_module == 'AMD Module');
+ ok(m.es6_module == 'ES6 Module');
+ start();
+ }, err);
+});
+
+asyncTest('ES module deps support', function() {
+ System.config({
+ meta: {
+ 'tests/esm-with-deps.js': {
+ deps: ['tests/esm-dep.js']
+ }
+ }
+ });
+ System['import']('tests/esm-with-deps.js').then(function(m) {
+ ok(m.p == 5);
+ ok(global.esmDep == 'esm-dep');
+ start();
+ });
+});
+
+asyncTest('Module Name meta', function() {
+ System['import']('tests/reflection.js').then(function(m) {
+ ok(m.myname == System.normalizeSync('tests/reflection.js'), 'Module name not returned');
+ start();
+ }, err);
+});
+
+asyncTest('Relative dyanamic loading', function() {
+ System['import']('tests/reldynamic.js').then(function(m) {
+ return m.dynamicLoad();
+ })
+ .then(function(m) {
+ ok(m.dynamic == 'module', 'Dynamic load failed');
+ start();
+ })
+ ['catch'](err);
+});
+
+asyncTest('ES6 Circular', function() {
+ System['import']('tests/es6-circular1.js').then(function(m) {
+ ok(m.q == 3, 'Binding not allocated');
+ if (System.transpiler != '6to5') ok(m.r == 3, 'Binding not updated');
+ start();
+ }, err);
+});
+
+asyncTest('AMD & CJS circular, ES6 Circular', function() {
+ System['import']('tests/all-circular1.js').then(function(m) {
+ if (System.transpiler != '6to5') ok(m.q == 4);
+ ok(m.o.checkObj() == 'changed');
+ start();
+ }, err);
+});
+
+asyncTest('AMD -> System.register circular -> ES6', function() {
+ System['import']('tests/all-layers1.js').then(function(m) {
+ ok(m == true)
+ start();
+ }, err);
+});
+
+asyncTest('Metadata dependencies work for named defines', function() {
+ System['import']('tests/meta-deps.js').then(function(m) {
+ return System['import']('b');
+ }).then(function(m) {
+ ok(m.a === 'a');
+ start();
+ });
+});
+
+asyncTest('Loading an AMD module that requires another works', function() {
+ expect(0);
+ System['import']('tests/amd-require.js').then(function(){
+ // Just getting this far means it is working.
+ start();
+ });
+});
+
+asyncTest('Loading a connected tree that connects ES and CJS modules', function(){
+ System['import']('tests/connected-tree/a.js').then(function(a){
+ ok(a.name === "a");
+ start();
+ });
+});
+
+asyncTest('Loading two bundles that have a shared dependency', function() {
+ System.config({
+ bundles: {
+ "tests/shared-dep-bundles/a.js": ["lib/shared-dep", "lib/a"],
+ "tests/shared-dep-bundles/b.js": ["lib/shared-dep", "lib/b"]
+ }
+ });
+ expect(0);
+ System['import']('lib/a').then(function() {
+ System['import']('lib/b').then(function() {
+ //If it gets here it's fine
+ start();
+ }, err);
+ }, err);
+});
+}
+
+asyncTest("System clone", function() {
+ var clonedSystem = new System.constructor();
+
+ clonedSystem.baseURL = System.baseURL;
+
+ System.map['maptest'] = 'tests/map-test.js';
+ clonedSystem.map['maptest'] = 'tests/map-test-dep.js';
+
+ Promise.all([System['import']('maptest'), clonedSystem['import']('maptest')]).then(function(modules) {
+ var m = modules[0];
+ var mClone = modules[1];
+
+ ok(m.maptest == 'maptest', 'Mapped module not loaded');
+ ok(mClone.dep == 'maptest', 'Mapped module not loaded');
+ ok(mClone !== m, "different modules");
+
+ start();
+ }, err);
+});
+
+asyncTest('Custom loader instance System scoped', function() {
+ var customSystem = new System.constructor();
+
+ customSystem.baseURL = System.baseURL;
+ customSystem.paths = System.paths;
+ customSystem.transpiler = System.transpiler;
+ customSystem['import']('tests/loader-scoping.js')
+ .then(function(m) {
+ ok(m.loader == customSystem);
+ start();
+ }, err);;
+});
+
+if(typeof window !== 'undefined' && window.Worker) {
+ asyncTest('Using SystemJS in a Web Worker', function() {
+ var worker = new Worker('./tests/worker-' + System.transpiler + '.js');
+ worker.onmessage = function(e) {
+ ok(e.data.amd === 'AMD Module');
+ ok(e.data.es6 === 'ES6 Module');
+ start();
+ };
+ });
+}
+
+asyncTest("Duplicate entries", function() {
+ System["import"]('tests/duplicateDeps/m1.js').then(function(m) {
+ var r = m.foo() + ":" + m.f3();
+ ok(r === "3:3", "duplicate entries in dependency list not handled correctly");
+ start();
+ })
+});
+
+// new features!!
+if (!ie8)
+asyncTest('Named imports for non-es6', function() {
+ System['import']('tests/es6-cjs-named-export.js').then(function(m) {
+ ok(m.someExport == 'asdf');
+ start();
+ }, err);
+});
+
+asyncTest('Globals', function() {
+ System.config({
+ meta: {
+ 'tests/with-global-deps.js': {
+ globals: {
+ '$$$': 'tests/dep.js'
+ }
+ }
+ }
+ });
+ System['import']('tests/with-global-deps.js').then(function(m) {
+ for (var p in m)
+ ok(false);
+ ok(!global.$$$);
+ start();
+ }, err);
+});
+
+asyncTest('Scriptload precompiled global with exports still defined', function() {
+ System.config({
+ meta: {
+ 'tests/global-single-compiled.js': {
+ scriptLoad: true,
+ exports: 'foobar',
+ format: typeof global != 'undefined' ? 'register' : 'global'
+ }
+ }
+ });
+ System['import']('tests/global-single-compiled.js').then(function(m) {
+ ok(m == 'foo');
+ start();
+ }, err);
+});
+
+asyncTest('Multi-format deps meta', function() {
+ System['import']('tests/amd-extra-deps.js').then(function(m) {
+ ok(m.join(',') == '10,5');
+ start();
+ }, err);
+});
+
+
+asyncTest('Wildcard meta', function() {
+ System.config({
+ meta: {
+ 'tests/cs/main.js': {
+ deps: ['./dep.js']
+ },
+ 'tests/cs/*': {
+ loader: 'tests/cs-loader.js'
+ }
+ }
+ });
+ System['import']('tests/cs/main.js').then(function(m) {
+ ok(m == 'cs');
+ start();
+ });
+});
+
+asyncTest('Package configuration CommonJS config example', function() {
+ System.config({
+ map: {
+ 'global-test': 'tests/testpkg/test.ts'
+ },
+ //packageConfigPaths: ['tests/testpk*.json'],
+ packageConfigPaths: ['tests/testpkg/system.json'],
+ packages: {
+ 'tests/testpkg': {
+ main: './noext',
+ map: {
+ "testpkg": "."
+ },
+ asdf: 'asdf'
+ }
+ }
+ });
+
+ Promise.all([
+ System['import']('tests/testpkg'),
+ System['import']('tests/testpkg/json'),
+ System['import']('tests/testpkg/dir/test'),
+ System['import']('tests/testpkg/dir2'),
+ System['import']('tests/testpkg/dir/'),
+ System['import']('tests/testpkg/env-module'),
+ System['import']('tests/testpkg/self'),
+ System['import']('tests/testpkg/conditional1'),
+ System['import']('tests/testpkg/conditional2'),
+ System['import']('tests/testpkg/self-load.js'),
+ System['import']('tests/testpkg/dir/self-load.js')
+ ]).then(function(m) {
+ ok(m[0].prop == 'value');
+ ok(m[1].prop == 'value');
+ ok(m[2] == 'ts');
+ ok(m[3].json == 'index');
+ ok(m[4] == 'dirindex');
+ ok(m[5] == (typeof window != 'undefined' ? 'browser' : 'not browser'));
+ ok(m[6].prop == 'value');
+ ok(m[7] == 'interpolated!');
+ ok(m[8] == 'interpolated!');
+ ok(m[9].a.prop == 'value' && m[9].b.prop == 'value');
+ ok(m[10].a.prop == 'value' && m[10].b.prop == 'value');
+ ok(global.depCacheTest == 'passed');
+ start();
+ }, err);
+});
+
+asyncTest('Package edge cases', function() {
+
+ var clonedSystem = new System.constructor();
+
+ var pkgCfg = { defaultExtension: 'asdf' };
+
+ try {
+ clonedSystem.config({
+ packages: {
+ '//': pkgCfg
+ }
+ });
+ ok(false);
+ }
+ catch(e) {
+ ok(e.toString().indexOf('not a valid package name') != -1);
+ }
+
+ try {
+ clonedSystem.config({
+ packages: {
+ 'https://': pkgCfg
+ }
+ });
+ ok(false);
+ }
+ catch(e) {
+ ok(e.toString().indexOf('not a valid package name') != -1);
+ }
+
+ clonedSystem.config({
+ packages: {
+ 'https://cdn.jquery.com': pkgCfg,
+ '//cdn.jquery.com': pkgCfg
+ }
+ });
+
+ clonedSystem.config({
+ packages: {
+ // both equivalent:
+ '.': pkgCfg,
+ './': pkgCfg,
+
+ '/': pkgCfg,
+
+ // this is now a nested package
+ // but our trailling / should avoid extension rules
+ // both equivalent:
+ '../': pkgCfg,
+ '..': pkgCfg
+ }
+ });
+
+ // ensure trailing "/" is equivalent to "tests/testpkg"
+ clonedSystem.config({
+ packageConfigPaths: ['tests/*.json'],
+ packages: {
+ 'tests/testpkg2/': {
+ defaultExtension: 'js'
+ }
+ }
+ });
+
+ // we now have nested packages:
+ // testpkg/ within test/ within / root://
+ // we're testing that we always select the rules of the inner package
+ clonedSystem['import']('tests/testpkg2/').then(function(m) {
+ ok(m.asdf == 'asdf');
+ start();
+ }, err);
+});
+
+asyncTest('Package map circular cases', function() {
+ System.config({
+ map: {
+ tp3: 'tests/testpkg3'
+ },
+ packages: {
+ 'tests/testpkg3': {
+ map: {
+ './lib': './lib/asdf.js',
+ './lib/': './lib/index.js',
+ './lib/p': './lib/q.js',
+ './src/': './src/index.js',
+ './bin': './bin/index.js'
+ }
+ }
+ }
+ });
+
+ Promise.all([
+ System.normalize('tp3/lib'),
+ System.normalize('tp3/lib/'),
+ System.normalize('tp3/lib/q'),
+ System.normalize('tp3/lib/p'),
+
+ System.normalize('../lib', System.baseURL + 'tests/testpkg3/asdf/x.js'),
+ System.normalize('../lib/', System.baseURL + 'tests/testpkg3/asdf/x.js'),
+ System.normalize('../lib/x', System.baseURL + 'tests/testpkg3/asdf/x.js'),
+
+ System.normalize('.', System.baseURL + 'tests/testpkg3/lib/a'),
+ System.normalize('./', System.baseURL + 'tests/testpkg3/lib/x'),
+ System.normalize('./p', System.baseURL + 'tests/testpkg3/lib/x'),
+ System.normalize('./q', System.baseURL + 'tests/testpkg3/lib/x'),
+
+ System.normalize('./lib', System.baseURL + 'tests/testpkg3/x.js'),
+ System.normalize('./lib/', System.baseURL + 'tests/testpkg3/x.js'),
+ System.normalize('./lib/p', System.baseURL + 'tests/testpkg3/x.js'),
+ System.normalize('./lib/q', System.baseURL + 'tests/testpkg3/x.js'),
+
+ System.normalize('../lib/', System.baseURL + 'tests/testpkg3/lib/x.js'),
+ System.normalize('../lib/x', System.baseURL + 'tests/testpkg3/lib/x.js'),
+ System.normalize('tp3/lib/q', System.baseURL + 'tests/testpkg3/lib/x.js'),
+
+ System.normalize('./src', System.baseURL + 'tests/testpkg3/'),
+ System.normalize('./src/', System.baseURL + 'tests/testpkg3/'),
+ System.normalize('./src/x', System.baseURL + 'tests/testpkg3/'),
+
+ System.normalize('tp3/src'),
+ System.normalize('tp3/src/'),
+ System.normalize('tp3/src/x'),
+
+ System.normalize('./bin', System.baseURL + 'tests/testpkg3/'),
+ System.normalize('./bin/', System.baseURL + 'tests/testpkg3/'),
+ System.normalize('./bin/x', System.baseURL + 'tests/testpkg3/'),
+
+ System.normalize('tp3/bin'),
+ System.normalize('tp3/bin/'),
+ System.normalize('tp3/bin/x'),
+
+ System.normalize('.', System.baseURL + 'tests/testpkg3/bin/x')
+ ])
+ .then(function(n) {
+ ok(n[0] == System.baseURL + 'tests/testpkg3/lib/asdf.js');
+ ok(n[1] == System.baseURL + 'tests/testpkg3/lib/index.js');
+ ok(n[2] == System.baseURL + 'tests/testpkg3/lib/q.js');
+ ok(n[3] == System.baseURL + 'tests/testpkg3/lib/q.js');
+
+ ok(n[4] == System.baseURL + 'tests/testpkg3/lib/asdf.js');
+ ok(n[5] == System.baseURL + 'tests/testpkg3/lib/index.js');
+ ok(n[6] == System.baseURL + 'tests/testpkg3/lib/x.js');
+
+ ok(n[7] == System.baseURL + 'tests/testpkg3/lib/index.js');
+ ok(n[8] == System.baseURL + 'tests/testpkg3/lib/index.js');
+ ok(n[9] == System.baseURL + 'tests/testpkg3/lib/q.js');
+ ok(n[10] == System.baseURL + 'tests/testpkg3/lib/q.js');
+
+ ok(n[11] == System.baseURL + 'tests/testpkg3/lib/asdf.js');
+ ok(n[12] == System.baseURL + 'tests/testpkg3/lib/index.js');
+ ok(n[13] == System.baseURL + 'tests/testpkg3/lib/q.js');
+ ok(n[14] == System.baseURL + 'tests/testpkg3/lib/q.js');
+
+ ok(n[15] == System.baseURL + 'tests/testpkg3/lib/index.js');
+ ok(n[16] == System.baseURL + 'tests/testpkg3/lib/x.js');
+ ok(n[17] == System.baseURL + 'tests/testpkg3/lib/q.js');
+
+ ok(n[18] == System.baseURL + 'tests/testpkg3/src.js');
+ ok(n[19] == System.baseURL + 'tests/testpkg3/src/index.js');
+ ok(n[20] == System.baseURL + 'tests/testpkg3/src/x.js');
+
+ ok(n[21] == System.baseURL + 'tests/testpkg3/src.js');
+ ok(n[22] == System.baseURL + 'tests/testpkg3/src/index.js');
+ ok(n[23] == System.baseURL + 'tests/testpkg3/src/x.js');
+
+ ok(n[24] == System.baseURL + 'tests/testpkg3/bin/index.js');
+ ok(n[25] == System.baseURL + 'tests/testpkg3/bin/index.js');
+ ok(n[26] == System.baseURL + 'tests/testpkg3/bin/x.js');
+
+ ok(n[27] == System.baseURL + 'tests/testpkg3/bin/index.js');
+ ok(n[28] == System.baseURL + 'tests/testpkg3/bin/index.js');
+ ok(n[29] == System.baseURL + 'tests/testpkg3/bin/x.js');
+
+ ok(n[30] == System.baseURL + 'tests/testpkg3/bin/index.js');
+ start();
+ }, err);
+
+});
+
+if (!ie8)
+asyncTest('Conditional loading', function() {
+ System.set('env', System.newModule({ 'browser': 'ie' }));
+
+ System['import']('tests/branch-#{env|browser}.js').then(function(m) {
+ ok(m.branch == 'ie');
+ start();
+ }, err);
+});
+
+asyncTest('Boolean conditional false', function() {
+ System.set('env', System.newModule({ 'js': { 'es5': true } }));
+
+ System['import']('tests/branch-boolean.js#?~env|js.es5').then(function(m) {
+ ok(m === System.get('@empty'));
+ start();
+ }, err);
+});
+
+if (!ie8)
+asyncTest('Boolean conditional true', function() {
+ System.set('env', System.newModule({ 'js': { 'es5': true } }));
+
+ System.config({
+ paths: {
+ 'branch-boolean.js': 'tests/branch-boolean.js'
+ }
+ });
+
+ System['import']('branch-boolean.js#?env|js.es5').then(function(m) {
+ ok(m['default'] === true);
+ start();
+ }, err);
+});
+
+asyncTest('Loading a System.registerdynamic module (not bundled)', function() {
+ System['import']('tests/registerdynamic-main.js').then(function(m) {
+ ok(typeof m.dependency === 'function');
+ ok(m.dependency() === 'ok');
+ start();
+ }).then(null, err);
+});
+
+asyncTest('Importing a script with wrong integrity fails', function() {
+ System.config({
+ meta: {
+ 'tests/csp/integrity.js': {
+ format: 'amd',
+ integrity: 'sha256-abc'
+ }
+ }
+ });
+ System['import']('tests/csp/integrity.js').then(function(m) {
+ ok(m.integrity == 'integrity');
+ start();
+ }, function(e) {
+ ok(typeof e !== 'undefined');
+ console.log('SRI not supported in this browser');
+ start();
+ });
+});
+
+if (typeof process != 'undefined') {
+ asyncTest('Loading Node core modules', function() {
+ System['import']('@node/fs').then(function(m) {
+ ok(m.writeFile);
+ start();
+ });
+ });
+
+
+ asyncTest('No global define leak in Node', function() {
+ ok(typeof define == 'undefined');
+ start();
+ });
+}
+
+asyncTest('Package-local alias esm', function() {
+ System.config({
+ map: {
+ 'package-local-alias-esm': 'tests/package-local-alias'
+ },
+ packages: {
+ 'package-local-alias-esm': {
+ main: 'index-esm.js',
+ format: 'esm',
+ meta: {
+ './local-esm': {alias: './local/index-esm.js'}
+ }
+ }
+ }
+ });
+ System['import']('package-local-alias-esm').then(function(m) {
+ ok(m.q == 'q');
+ ok(m.fromLocal == 'x');
+ start();
+ });
+});
+
+asyncTest('Package-local alias cjs', function() {
+ System.config({
+ map: {
+ 'package-local-alias-cjs': 'tests/package-local-alias'
+ },
+ packages: {
+ 'package-local-alias-cjs': {
+ main: 'index-cjs.js',
+ format: 'cjs',
+ meta: {
+ './local-cjs': {alias: './local/index-cjs.js'}
+ }
+ }
+ }
+ });
+ System['import']('package-local-alias-cjs').then(function(m) {
+ ok(m.q == 'q');
+ ok(m.fromLocal == 'x');
+ start();
+ });
+});
+
+asyncTest('Package-local alias esm default export', function() {
+ System.config({
+ map: {
+ 'package-local-alias-default-esm': 'tests/package-local-alias'
+ },
+ packages: {
+ 'package-local-alias-default-esm': { // can't reuse package names from previous test
+ main: 'index-default-esm.js', // because System.config() results persist across tests
+ format: 'esm',
+ meta: {
+ './local-default-esm': {alias: './local/index-default-esm.js'}
+ }
+ }
+ }
+ });
+ System['import']('package-local-alias-default-esm').then(function(m) {
+ ok(m.q == 'q');
+ ok(m.fromLocal == 'x');
+ ok(m.fromLocalDirect == 'x');
+ start();
+ });
+});
+
+asyncTest('Package-local alias cjs default export', function() {
+ System.config({
+ map: {
+ 'package-local-alias-default-cjs': 'tests/package-local-alias'
+ },
+ packages: {
+ 'package-local-alias-default-cjs': {
+ main: 'index-default-cjs.js',
+ format: 'cjs',
+ meta: {
+ './local-default-cjs': {alias: './local/index-default-cjs.js'}
+ }
+ }
+ }
+ });
+ System['import']('package-local-alias-default-cjs').then(function(m) {
+ ok(m.q == 'q');
+ ok(m.fromLocal == 'x');
+ ok(m.fromLocalDirect == 'x');
+ start();
+ });
+});
+
+
+})(typeof window == 'undefined' ? global : window);
diff --git a/test/tests/#.js b/test/tests/#.js
new file mode 100644
index 000000000..0cf86a864
--- /dev/null
+++ b/test/tests/#.js
@@ -0,0 +1 @@
+module.exports = '#'; \ No newline at end of file
diff --git a/test/tests/advanced-plugin.js b/test/tests/advanced-plugin.js
new file mode 100644
index 000000000..26c6a450c
--- /dev/null
+++ b/test/tests/advanced-plugin.js
@@ -0,0 +1,20 @@
+
+exports.locate = function(load) {
+ return new Promise(function(resolve, reject) {
+ setTimeout(function() {
+ resolve('custom fetch');
+ }, 20);
+ });
+}
+
+exports.fetch = function(load) {
+ return new Promise(function(resolve, reject) {
+ setTimeout(function() {
+ resolve(load.address);
+ }, 20);
+ });
+}
+
+exports.translate = function(load) {
+ load.source = '"deps ./plugin-dep.js"; (typeof window != "undefined" ? window : global).q = "' + load.source + ':' + load.name + '";';
+} \ No newline at end of file
diff --git a/test/tests/all-circular1.js b/test/tests/all-circular1.js
new file mode 100644
index 000000000..131dfecce
--- /dev/null
+++ b/test/tests/all-circular1.js
@@ -0,0 +1,9 @@
+import { a } from './all-circular2.js';
+export var q;
+export function p() {
+ q = a;
+}
+
+import o from './all-circular3.js';
+
+export { o }; \ No newline at end of file
diff --git a/test/tests/all-circular2.js b/test/tests/all-circular2.js
new file mode 100644
index 000000000..c88eceb9c
--- /dev/null
+++ b/test/tests/all-circular2.js
@@ -0,0 +1,3 @@
+import { p } from './all-circular1.js';
+export var a = 4;
+p(); \ No newline at end of file
diff --git a/test/tests/all-circular3.js b/test/tests/all-circular3.js
new file mode 100644
index 000000000..fea5e3f22
--- /dev/null
+++ b/test/tests/all-circular3.js
@@ -0,0 +1,10 @@
+define(function(require, exports) {
+ var obj = require('./all-circular4.js').obj;
+ exports.checkObj = function() {
+ return obj.circular;
+ }
+ exports.setObj = function() {
+ obj.circular = 'changed';
+ }
+ require('./all-circular4.js').set();
+}); \ No newline at end of file
diff --git a/test/tests/all-circular4.js b/test/tests/all-circular4.js
new file mode 100644
index 000000000..692445730
--- /dev/null
+++ b/test/tests/all-circular4.js
@@ -0,0 +1,5 @@
+exports.obj = { circular: 'mess' };
+var setter = require('./all-circular3.js');
+exports.set = function() {
+ setter.setObj();
+}
diff --git a/test/tests/all-layers1.js b/test/tests/all-layers1.js
new file mode 100644
index 000000000..2dea20d17
--- /dev/null
+++ b/test/tests/all-layers1.js
@@ -0,0 +1,3 @@
+define(['./all-layers2.js'], function(al2) {
+ return al2.q == 10 && al2.r == 5;
+}); \ No newline at end of file
diff --git a/test/tests/all-layers2.js b/test/tests/all-layers2.js
new file mode 100644
index 000000000..a4a72e128
--- /dev/null
+++ b/test/tests/all-layers2.js
@@ -0,0 +1,20 @@
+System.register(["./all-layers3.js"], function($__export) {
+ "use strict";
+ var q, r, c;
+ function p() {
+ if (q)
+ r = $__export('r', c);
+ else
+ q = $__export('q', c);
+ }
+ $__export('p', p);
+ return {
+ setters: [function(m) {
+ c = m.c;
+ }],
+ execute: function() {
+ c = 5;
+ p();
+ }
+ };
+});
diff --git a/test/tests/all-layers3.js b/test/tests/all-layers3.js
new file mode 100644
index 000000000..ac519f19a
--- /dev/null
+++ b/test/tests/all-layers3.js
@@ -0,0 +1,17 @@
+System.register(["./all-layers2.js", "./all-layers4.js"], function($__export) {
+ "use strict";
+ var c, p;
+ return {
+ setters: [
+ function(m) {
+ p = m.p;
+ },
+ function(m) {
+ $__export('c', c = m.c);
+ }
+ ],
+ execute: function() {
+ p();
+ }
+ };
+});
diff --git a/test/tests/all-layers4.js b/test/tests/all-layers4.js
new file mode 100644
index 000000000..4a2d7bf8a
--- /dev/null
+++ b/test/tests/all-layers4.js
@@ -0,0 +1 @@
+export var c = 10; \ No newline at end of file
diff --git a/test/tests/amd-bundle.js b/test/tests/amd-bundle.js
new file mode 100644
index 000000000..8856e2db9
--- /dev/null
+++ b/test/tests/amd-bundle.js
@@ -0,0 +1,6 @@
+define('bundle-1', function() {
+ return { defined: true };
+});
+define('bundle-2', function() {
+ return { defined: true };
+}); \ No newline at end of file
diff --git a/test/tests/amd-circular1.js b/test/tests/amd-circular1.js
new file mode 100644
index 000000000..2533e9bfd
--- /dev/null
+++ b/test/tests/amd-circular1.js
@@ -0,0 +1,7 @@
+define(function(require, exports) {
+ var depFunc = require('./amd-circular2.js').fn;
+ exports.val = 5;
+ exports.outFunc = function() {
+ return depFunc();
+ }
+}); \ No newline at end of file
diff --git a/test/tests/amd-circular2.js b/test/tests/amd-circular2.js
new file mode 100644
index 000000000..df9254d24
--- /dev/null
+++ b/test/tests/amd-circular2.js
@@ -0,0 +1,6 @@
+define(function(require, exports) {
+ var circular1 = require('./amd-circular1.js');
+ exports.fn = function() {
+ return circular1.val;
+ }
+}); \ No newline at end of file
diff --git a/test/tests/amd-cjs-module.js b/test/tests/amd-cjs-module.js
new file mode 100644
index 000000000..1ac2c3e1a
--- /dev/null
+++ b/test/tests/amd-cjs-module.js
@@ -0,0 +1,4 @@
+define(function(require, exports) {
+ var p = require('./amd-dep.js');
+ exports.test = 'hi';
+}); \ No newline at end of file
diff --git a/test/tests/amd-contextual.js b/test/tests/amd-contextual.js
new file mode 100644
index 000000000..b5e886297
--- /dev/null
+++ b/test/tests/amd-contextual.js
@@ -0,0 +1,6 @@
+define(['require', 'module'], function(require, module) {
+ return {
+ name: module.uri,
+ rel: require.toUrl('../rel-path.js')
+ };
+}); \ No newline at end of file
diff --git a/test/tests/amd-dep-A.js b/test/tests/amd-dep-A.js
new file mode 100644
index 000000000..c047cc49f
--- /dev/null
+++ b/test/tests/amd-dep-A.js
@@ -0,0 +1 @@
+A = 10; \ No newline at end of file
diff --git a/test/tests/amd-dep-B.js b/test/tests/amd-dep-B.js
new file mode 100644
index 000000000..6f5b4c6b0
--- /dev/null
+++ b/test/tests/amd-dep-B.js
@@ -0,0 +1 @@
+B = 5; \ No newline at end of file
diff --git a/test/tests/amd-dep.js b/test/tests/amd-dep.js
new file mode 100644
index 000000000..4ad8f7e5c
--- /dev/null
+++ b/test/tests/amd-dep.js
@@ -0,0 +1,3 @@
+define({
+ amd: 'dep'
+}); \ No newline at end of file
diff --git a/test/tests/amd-dynamic-require.js b/test/tests/amd-dynamic-require.js
new file mode 100644
index 000000000..6b7315dc3
--- /dev/null
+++ b/test/tests/amd-dynamic-require.js
@@ -0,0 +1,19 @@
+define(['require'], function(require) {
+ var cb, module;
+
+ require('./amd-dynamic.js', function(_module) {
+ module = _module;
+
+ if (cb)
+ cb(module);
+ });
+
+ return {
+ onCallback: function(_cb) {
+ if (module)
+ _cb(module);
+ else
+ cb = _cb;
+ }
+ };
+}); \ No newline at end of file
diff --git a/test/tests/amd-dynamic.js b/test/tests/amd-dynamic.js
new file mode 100644
index 000000000..88692ae46
--- /dev/null
+++ b/test/tests/amd-dynamic.js
@@ -0,0 +1,3 @@
+define(function() {
+ return 'dynamic';
+}); \ No newline at end of file
diff --git a/test/tests/amd-extra-deps.js b/test/tests/amd-extra-deps.js
new file mode 100644
index 000000000..86b8777ff
--- /dev/null
+++ b/test/tests/amd-extra-deps.js
@@ -0,0 +1,7 @@
+// NB update to "deps[]" when deps is deprecated
+"deps ./amd-dep-A.js";
+"deps ./amd-dep-B.js";
+
+define([], function() {
+ return [A, B];
+}); \ No newline at end of file
diff --git a/test/tests/amd-format.js b/test/tests/amd-format.js
new file mode 100644
index 000000000..3bc01fe38
--- /dev/null
+++ b/test/tests/amd-format.js
@@ -0,0 +1,18 @@
+/*
+ this is AMD
+*/
+// works with comments!!!
+/*
+ At least I hope so
+*/
+"amd";
+
+var m = {
+ amd: 'amd'
+};
+define(m);
+
+// attempt to fool amd detection
+if (typeof module != 'undefined')
+ module.exports = 'hello';
+
diff --git a/test/tests/amd-module-2.js b/test/tests/amd-module-2.js
new file mode 100644
index 000000000..5fdcb3e58
--- /dev/null
+++ b/test/tests/amd-module-2.js
@@ -0,0 +1,6 @@
+define([
+ './amd-module.js',
+ '@empty',
+], function () {
+ return { amd: true };
+}); \ No newline at end of file
diff --git a/test/tests/amd-module-3.js b/test/tests/amd-module-3.js
new file mode 100644
index 000000000..6c9128051
--- /dev/null
+++ b/test/tests/amd-module-3.js
@@ -0,0 +1,13 @@
+define([
+ // with a single-line comment
+ './amd-module.js',
+ /* with a multi-line
+ comment
+ */
+ './amd-module.js'
+ // trailing single-line comment
+ /* trailing multi-line
+ comment */
+], function () {
+ return { amd: true };
+});
diff --git a/test/tests/amd-module-bom.js b/test/tests/amd-module-bom.js
new file mode 100644
index 000000000..0f3de0b7f
--- /dev/null
+++ b/test/tests/amd-module-bom.js
@@ -0,0 +1,4 @@
+define([], function () {
+ // file starts with a byte order mark (BOM)
+ return { amd: true };
+});
diff --git a/test/tests/amd-module.js b/test/tests/amd-module.js
new file mode 100644
index 000000000..3cb3d58cf
--- /dev/null
+++ b/test/tests/amd-module.js
@@ -0,0 +1,6 @@
+define(['./amd-dep.js'], function(d) {
+ return {
+ dep: d,
+ amd: true
+ };
+}); \ No newline at end of file
diff --git a/test/tests/amd-require.js b/test/tests/amd-require.js
new file mode 100644
index 000000000..1db1c8a16
--- /dev/null
+++ b/test/tests/amd-require.js
@@ -0,0 +1,3 @@
+define(function(require) {
+ require(["tests/amd-dep.js"]);
+});
diff --git a/test/tests/amd-simplified-cjs-aliased-require1.js b/test/tests/amd-simplified-cjs-aliased-require1.js
new file mode 100644
index 000000000..819ca44c1
--- /dev/null
+++ b/test/tests/amd-simplified-cjs-aliased-require1.js
@@ -0,0 +1,7 @@
+define(function(req){
+ var r2 = req("./amd-simplified-cjs-aliased-require2.js");
+ return {
+ name: "require1",
+ require2: r2
+ };
+});
diff --git a/test/tests/amd-simplified-cjs-aliased-require2.js b/test/tests/amd-simplified-cjs-aliased-require2.js
new file mode 100644
index 000000000..be391226a
--- /dev/null
+++ b/test/tests/amd-simplified-cjs-aliased-require2.js
@@ -0,0 +1,8 @@
+define(["./amd-dep.js","require"],function(amdDep, req){
+ var amdCJS = req("./amd-cjs-module.js");
+ return {
+ name: "require2",
+ amdCJS: amdCJS,
+ amdDep: amdDep
+ };
+});
diff --git a/test/tests/anon-named.js b/test/tests/anon-named.js
new file mode 100644
index 000000000..6d0a61315
--- /dev/null
+++ b/test/tests/anon-named.js
@@ -0,0 +1,10 @@
+define('named-in-anon', function() {
+ return 'named';
+});
+
+define(['named-in-anon'], function(named) {
+ return {
+ anon: true,
+ named: named
+ };
+}); \ No newline at end of file
diff --git a/test/tests/async.js b/test/tests/async.js
new file mode 100644
index 000000000..f25bf5a81
--- /dev/null
+++ b/test/tests/async.js
@@ -0,0 +1,5 @@
+// will detect as CommonJS
+if (false) require('asdf');
+
+// should detect as ES6 first
+export async function p() {} \ No newline at end of file
diff --git a/test/tests/bootstrap@3.1.1/test.coffee b/test/tests/bootstrap@3.1.1/test.coffee
new file mode 100644
index 000000000..fc0891795
--- /dev/null
+++ b/test/tests/bootstrap@3.1.1/test.coffee
@@ -0,0 +1 @@
+exports.p = 4;
diff --git a/test/tests/branch-boolean.js b/test/tests/branch-boolean.js
new file mode 100644
index 000000000..bc5b6ccdb
--- /dev/null
+++ b/test/tests/branch-boolean.js
@@ -0,0 +1 @@
+export default true; \ No newline at end of file
diff --git a/test/tests/branch-ie.js b/test/tests/branch-ie.js
new file mode 100644
index 000000000..ea184442e
--- /dev/null
+++ b/test/tests/branch-ie.js
@@ -0,0 +1 @@
+export var branch = 'ie'; \ No newline at end of file
diff --git a/test/tests/bundle.js b/test/tests/bundle.js
new file mode 100644
index 000000000..d69e7ca69
--- /dev/null
+++ b/test/tests/bundle.js
@@ -0,0 +1,7 @@
+define('bundle-define1', function() {
+ return { name: 'bundle1' };
+});
+
+define('bundle-define2', function() {
+ return { name: 'bundle2' };
+}); \ No newline at end of file
diff --git a/test/tests/cjs-circular1.js b/test/tests/cjs-circular1.js
new file mode 100644
index 000000000..f2946cf87
--- /dev/null
+++ b/test/tests/cjs-circular1.js
@@ -0,0 +1,4 @@
+exports.first = 'first value';
+var p = require('./cjs-circular2.js').p;
+exports.first = 'second value';
+exports.firstWas = p(); \ No newline at end of file
diff --git a/test/tests/cjs-circular2.js b/test/tests/cjs-circular2.js
new file mode 100644
index 000000000..b6c8d87e4
--- /dev/null
+++ b/test/tests/cjs-circular2.js
@@ -0,0 +1,4 @@
+var first = require('./cjs-circular1.js').first;
+exports.p = function() {
+ return first;
+} \ No newline at end of file
diff --git a/test/tests/cjs-exports-bom.js b/test/tests/cjs-exports-bom.js
new file mode 100644
index 000000000..a3174cc3c
--- /dev/null
+++ b/test/tests/cjs-exports-bom.js
@@ -0,0 +1 @@
+exports.foo = "bar"; \ No newline at end of file
diff --git a/test/tests/cjs-exports-dep.js b/test/tests/cjs-exports-dep.js
new file mode 100644
index 000000000..326bed6cf
--- /dev/null
+++ b/test/tests/cjs-exports-dep.js
@@ -0,0 +1 @@
+exports.e = require('./cjs-exports.js')(); \ No newline at end of file
diff --git a/test/tests/cjs-exports.js b/test/tests/cjs-exports.js
new file mode 100644
index 000000000..fdd99ca92
--- /dev/null
+++ b/test/tests/cjs-exports.js
@@ -0,0 +1,6 @@
+module.exports = F;
+require('./cjs-exports-dep.js');
+function F() {
+ return 'export';
+}
+module.exports = require('./cjs-exports-dep.js'); \ No newline at end of file
diff --git a/test/tests/cjs-format.js b/test/tests/cjs-format.js
new file mode 100644
index 000000000..7ac68dc97
--- /dev/null
+++ b/test/tests/cjs-format.js
@@ -0,0 +1,4 @@
+"format cjs";
+if (typeof define != 'undefined')
+ define(function() {});
+exports.cjs = 'cjs';
diff --git a/test/tests/cjs-globals.js b/test/tests/cjs-globals.js
new file mode 100644
index 000000000..d71e2ed57
--- /dev/null
+++ b/test/tests/cjs-globals.js
@@ -0,0 +1,3 @@
+exports.dirname = __dirname;
+exports.filename = __filename;
+exports.global = global; \ No newline at end of file
diff --git a/test/tests/cjs-loading-plugin.js b/test/tests/cjs-loading-plugin.js
new file mode 100644
index 000000000..11dc2a5a4
--- /dev/null
+++ b/test/tests/cjs-loading-plugin.js
@@ -0,0 +1 @@
+module.exports = require('./test.css!'); \ No newline at end of file
diff --git a/test/tests/cjs-module-bom.js b/test/tests/cjs-module-bom.js
new file mode 100644
index 000000000..2176395e8
--- /dev/null
+++ b/test/tests/cjs-module-bom.js
@@ -0,0 +1 @@
+module.exports.foo = "bar"; \ No newline at end of file
diff --git a/test/tests/cjs-named-export.js b/test/tests/cjs-named-export.js
new file mode 100644
index 000000000..6609eeafc
--- /dev/null
+++ b/test/tests/cjs-named-export.js
@@ -0,0 +1,5 @@
+var p = module.exports = function() {
+
+}
+
+p.someExport = 'asdf'; \ No newline at end of file
diff --git a/test/tests/cjs-process.js b/test/tests/cjs-process.js
new file mode 100644
index 000000000..7f750c112
--- /dev/null
+++ b/test/tests/cjs-process.js
@@ -0,0 +1,3 @@
+exports.env = {
+ NODE_ENV: 'dev'
+}; \ No newline at end of file
diff --git a/test/tests/cjs-resolve.js b/test/tests/cjs-resolve.js
new file mode 100644
index 000000000..8461373e9
--- /dev/null
+++ b/test/tests/cjs-resolve.js
@@ -0,0 +1 @@
+module.exports = require.resolve('./a'); \ No newline at end of file
diff --git a/test/tests/cjs-this.js b/test/tests/cjs-this.js
new file mode 100644
index 000000000..79a4bb5db
--- /dev/null
+++ b/test/tests/cjs-this.js
@@ -0,0 +1,2 @@
+"format cjs";
+this.asdf = 'module value'; \ No newline at end of file
diff --git a/test/tests/common-js-dep.js b/test/tests/common-js-dep.js
new file mode 100644
index 000000000..3543bf0bf
--- /dev/null
+++ b/test/tests/common-js-dep.js
@@ -0,0 +1 @@
+exports.output = 'this is a dep'; \ No newline at end of file
diff --git a/test/tests/common-js-module.js b/test/tests/common-js-module.js
new file mode 100644
index 000000000..c7b6c12ee
--- /dev/null
+++ b/test/tests/common-js-module.js
@@ -0,0 +1,2 @@
+exports.first = require('./common-js-dep.js').output;
+exports.hello = 'world';
diff --git a/test/tests/commonjs-d.js b/test/tests/commonjs-d.js
new file mode 100644
index 000000000..b23a181b8
--- /dev/null
+++ b/test/tests/commonjs-d.js
@@ -0,0 +1 @@
+module.exports = 'd'; \ No newline at end of file
diff --git a/test/tests/commonjs-d2.js b/test/tests/commonjs-d2.js
new file mode 100644
index 000000000..3b340b2e0
--- /dev/null
+++ b/test/tests/commonjs-d2.js
@@ -0,0 +1 @@
+module.exports = 'd6'; \ No newline at end of file
diff --git a/test/tests/commonjs-globals.js b/test/tests/commonjs-globals.js
new file mode 100644
index 000000000..44194a0db
--- /dev/null
+++ b/test/tests/commonjs-globals.js
@@ -0,0 +1 @@
+exports.process = process; \ No newline at end of file
diff --git a/test/tests/commonjs-requires.js b/test/tests/commonjs-requires.js
new file mode 100644
index 000000000..af80d8058
--- /dev/null
+++ b/test/tests/commonjs-requires.js
@@ -0,0 +1,40 @@
+exports.d6 =
+/**/require('./commonjs-d2.js');
+
+exports.d1 = require(
+ './commonjs-d.js'
+);
+
+exports.d2 = (require
+("./commonjs-d.js"));
+
+var regex = / \/* /;
+
+exports.d3 = "require('not a dep')";
+
+exports.d4 = "text/* require('still not a dep') text";
+
+exports.d5 = 'text \'quote\' require("yet still not a dep")';
+
+var regexWithString = /asdfasdf " /;
+
+var regexClose = /asdf " */;
+
+// This comment triggered SystemJS to do a require because of this -> require('')
+exports.d7 = 'export';
+
+var p = false && require('" + "test" + "');
+
+// this line shouldn't be detected
+" = require(", "),\n ";
+
+
+/*
+
+Unsolved breaking cases:
+
+var regex = / " /; var string = " /* " // one line;
+require('asdf') // <- this will now be skipped as it will be in the '/*' comment
+*//*
+
+*/ \ No newline at end of file
diff --git a/test/tests/commonjs-variation.js b/test/tests/commonjs-variation.js
new file mode 100644
index 000000000..bf8b8c27e
--- /dev/null
+++ b/test/tests/commonjs-variation.js
@@ -0,0 +1,5 @@
+module.exports = {
+ e: (function p() {
+ return require('@empty');
+ })()
+} \ No newline at end of file
diff --git a/test/tests/commonjs-variation2.js b/test/tests/commonjs-variation2.js
new file mode 100644
index 000000000..f7a25047b
--- /dev/null
+++ b/test/tests/commonjs-variation2.js
@@ -0,0 +1,8 @@
+Object.defineProperties(module.exports, {
+ OpaqueToken: {get: function() {
+ return OpaqueToken;
+ }},
+ __esModule: {value: true}
+});
+
+function OpaqueToken() {} \ No newline at end of file
diff --git a/test/tests/compiled.coffee b/test/tests/compiled.coffee
new file mode 100644
index 000000000..dd46ac6f7
--- /dev/null
+++ b/test/tests/compiled.coffee
@@ -0,0 +1 @@
+var p = 4; \ No newline at end of file
diff --git a/test/tests/compiler-plugin.js b/test/tests/compiler-plugin.js
new file mode 100644
index 000000000..e7068fae3
--- /dev/null
+++ b/test/tests/compiler-plugin.js
@@ -0,0 +1,4 @@
+"format cjs";
+exports.translate = function(load) {
+ return 'require("tests/global.js"); exports.extra = "yay!"; \n' + load.source;
+}
diff --git a/test/tests/compiler-test.coffee b/test/tests/compiler-test.coffee
new file mode 100644
index 000000000..a79cb03b2
--- /dev/null
+++ b/test/tests/compiler-test.coffee
@@ -0,0 +1 @@
+exports.output = "plugin output";
diff --git a/test/tests/connected-tree/a.js b/test/tests/connected-tree/a.js
new file mode 100644
index 000000000..2ffbcaa58
--- /dev/null
+++ b/test/tests/connected-tree/a.js
@@ -0,0 +1,9 @@
+// a.js
+var c = require("./c.js");
+var b = require('./b.js');
+
+module.exports = {
+ name: "a",
+ b: b,
+ c: c
+};
diff --git a/test/tests/connected-tree/b.js b/test/tests/connected-tree/b.js
new file mode 100644
index 000000000..0e658df66
--- /dev/null
+++ b/test/tests/connected-tree/b.js
@@ -0,0 +1,6 @@
+import c from "./c.js";
+
+export default {
+ name: "b",
+ c: c
+};
diff --git a/test/tests/connected-tree/c.js b/test/tests/connected-tree/c.js
new file mode 100644
index 000000000..e885e1138
--- /dev/null
+++ b/test/tests/connected-tree/c.js
@@ -0,0 +1,3 @@
+module.exports = {
+ name: "c"
+}; \ No newline at end of file
diff --git a/test/tests/contextual-map-dep.js b/test/tests/contextual-map-dep.js
new file mode 100644
index 000000000..c2898baa8
--- /dev/null
+++ b/test/tests/contextual-map-dep.js
@@ -0,0 +1 @@
+exports.mapdep = 'mapdep';
diff --git a/test/tests/contextual-test/contextual-map.js b/test/tests/contextual-test/contextual-map.js
new file mode 100644
index 000000000..c3192b867
--- /dev/null
+++ b/test/tests/contextual-test/contextual-map.js
@@ -0,0 +1 @@
+module.exports = require('maptest');
diff --git a/test/tests/cs-loader.js b/test/tests/cs-loader.js
new file mode 100644
index 000000000..cc24b3fe9
--- /dev/null
+++ b/test/tests/cs-loader.js
@@ -0,0 +1,3 @@
+exports.translate = function translate(load) {
+ return load.source.replace(/#/g, '');
+} \ No newline at end of file
diff --git a/test/tests/cs/dep.js b/test/tests/cs/dep.js
new file mode 100644
index 000000000..168695856
--- /dev/null
+++ b/test/tests/cs/dep.js
@@ -0,0 +1 @@
+# language_global = 'cs'; \ No newline at end of file
diff --git a/test/tests/cs/main.js b/test/tests/cs/main.js
new file mode 100644
index 000000000..e4960c7c9
--- /dev/null
+++ b/test/tests/cs/main.js
@@ -0,0 +1 @@
+# module.exports = language_global; \ No newline at end of file
diff --git a/test/tests/csp/integrity.js b/test/tests/csp/integrity.js
new file mode 100644
index 000000000..0cd357c7a
--- /dev/null
+++ b/test/tests/csp/integrity.js
@@ -0,0 +1,5 @@
+define(function () {
+ return {
+ integrity: 'integrity'
+ }
+});
diff --git a/test/tests/csp/nonce.js b/test/tests/csp/nonce.js
new file mode 100644
index 000000000..35dee5ee5
--- /dev/null
+++ b/test/tests/csp/nonce.js
@@ -0,0 +1,3 @@
+module.exports = {
+ nonce: 'abc'
+};
diff --git a/test/tests/csp/nonce2.js b/test/tests/csp/nonce2.js
new file mode 100644
index 000000000..1c6556170
--- /dev/null
+++ b/test/tests/csp/nonce2.js
@@ -0,0 +1,3 @@
+module.exports = {
+ nonce: 'ab'
+};
diff --git a/test/tests/css.css b/test/tests/css.css
new file mode 100644
index 000000000..287755162
--- /dev/null
+++ b/test/tests/css.css
@@ -0,0 +1,3 @@
+body {
+ background-color: #eee;
+}
diff --git a/test/tests/css.js b/test/tests/css.js
new file mode 100644
index 000000000..c0a3875e2
--- /dev/null
+++ b/test/tests/css.js
@@ -0,0 +1,3 @@
+exports.instantiate = function(load) {
+ return { pluginSource: load.source };
+} \ No newline at end of file
diff --git a/test/tests/deep/deep-dep.js b/test/tests/deep/deep-dep.js
new file mode 100644
index 000000000..f053ebf79
--- /dev/null
+++ b/test/tests/deep/deep-dep.js
@@ -0,0 +1 @@
+module.exports = {};
diff --git a/test/tests/deep/deep.js b/test/tests/deep/deep.js
new file mode 100644
index 000000000..cb3befa5f
--- /dev/null
+++ b/test/tests/deep/deep.js
@@ -0,0 +1 @@
+require('./deep-dep');
diff --git a/test/tests/default1-dep.js b/test/tests/default1-dep.js
new file mode 100644
index 000000000..8771ac87f
--- /dev/null
+++ b/test/tests/default1-dep.js
@@ -0,0 +1 @@
+export var q = 4;
diff --git a/test/tests/default1.js b/test/tests/default1.js
new file mode 100644
index 000000000..1ff5f0108
--- /dev/null
+++ b/test/tests/default1.js
@@ -0,0 +1,3 @@
+import q from './default1-dep.js';
+export default 'default1';
+export var d = 'default1'; \ No newline at end of file
diff --git a/test/tests/default2.js b/test/tests/default2.js
new file mode 100644
index 000000000..db40d327f
--- /dev/null
+++ b/test/tests/default2.js
@@ -0,0 +1 @@
+export default 'default2'; \ No newline at end of file
diff --git a/test/tests/default3.js b/test/tests/default3.js
new file mode 100644
index 000000000..fd3505e99
--- /dev/null
+++ b/test/tests/default3.js
@@ -0,0 +1 @@
+export default 'default3'; \ No newline at end of file
diff --git a/test/tests/dep.js b/test/tests/dep.js
new file mode 100644
index 000000000..20e4f186b
--- /dev/null
+++ b/test/tests/dep.js
@@ -0,0 +1 @@
+define({});
diff --git a/test/tests/duplicateDeps/m1.js b/test/tests/duplicateDeps/m1.js
new file mode 100644
index 000000000..77b7efb3b
--- /dev/null
+++ b/test/tests/duplicateDeps/m1.js
@@ -0,0 +1,23 @@
+System.register(["tests/duplicateDeps/m2.js", "tests/duplicateDeps/m2.js", "tests/duplicateDeps/m2.js"], function(exports_1) {
+ var m2_1, m2_2;
+ function foo() {
+ return m2_1.f1() + m2_2.f2();
+ }
+ exports_1("foo", foo);
+ return {
+ setters:[
+ function (_m2_1) {
+ m2_1 = _m2_1;
+ },
+ function (_m2_2) {
+ m2_2 = _m2_2;
+ },
+ function (_m2_3) {
+ var reexports_1 = {};
+ reexports_1["f3"] = _m2_3["f3"];
+ exports_1(reexports_1);
+ }],
+ execute: function() {
+ }
+ }
+});
diff --git a/test/tests/duplicateDeps/m2.js b/test/tests/duplicateDeps/m2.js
new file mode 100644
index 000000000..03f71ea8e
--- /dev/null
+++ b/test/tests/duplicateDeps/m2.js
@@ -0,0 +1,13 @@
+System.register([], function(exports_1) {
+ function f1() { return 1; }
+ exports_1("f1", f1);
+ function f2() { return 2; }
+ exports_1("f2", f2);
+ function f3() { return 3; }
+ exports_1("f3", f3);
+ return {
+ setters:[],
+ execute: function() {
+ }
+ }
+});
diff --git a/test/tests/eaa-amd.js b/test/tests/eaa-amd.js
new file mode 100644
index 000000000..65843b0f4
--- /dev/null
+++ b/test/tests/eaa-amd.js
@@ -0,0 +1,3 @@
+define([], function() {
+ return 'AMD Module';
+}); \ No newline at end of file
diff --git a/test/tests/eaa-es6.js b/test/tests/eaa-es6.js
new file mode 100644
index 000000000..1a2fd7edc
--- /dev/null
+++ b/test/tests/eaa-es6.js
@@ -0,0 +1 @@
+export default 'ES6 Module'; \ No newline at end of file
diff --git a/test/tests/empty-es6.js b/test/tests/empty-es6.js
new file mode 100644
index 000000000..c6fa496fa
--- /dev/null
+++ b/test/tests/empty-es6.js
@@ -0,0 +1,3 @@
+(function(global) {
+ global.emptyES6 = true;
+})(typeof window == 'undefined' ? global : window); \ No newline at end of file
diff --git a/test/tests/ep/some-repo/main.js b/test/tests/ep/some-repo/main.js
new file mode 100644
index 000000000..a6d27d510
--- /dev/null
+++ b/test/tests/ep/some-repo/main.js
@@ -0,0 +1 @@
+export var main = 'here';
diff --git a/test/tests/error-loader.js b/test/tests/error-loader.js
new file mode 100644
index 000000000..b6b07cd0c
--- /dev/null
+++ b/test/tests/error-loader.js
@@ -0,0 +1 @@
+require('./error.js'); \ No newline at end of file
diff --git a/test/tests/error-loader2.js b/test/tests/error-loader2.js
new file mode 100644
index 000000000..69b15e06a
--- /dev/null
+++ b/test/tests/error-loader2.js
@@ -0,0 +1 @@
+require('non-existent'); \ No newline at end of file
diff --git a/test/tests/error.js b/test/tests/error.js
new file mode 100644
index 000000000..ca248d227
--- /dev/null
+++ b/test/tests/error.js
@@ -0,0 +1 @@
+foo / bar \ No newline at end of file
diff --git a/test/tests/es-module-flag.js b/test/tests/es-module-flag.js
new file mode 100644
index 000000000..0ed2e3149
--- /dev/null
+++ b/test/tests/es-module-flag.js
@@ -0,0 +1,3 @@
+exports.exportName = 'export';
+exports['default'] = 'default export';
+exports.__esModule = true; \ No newline at end of file
diff --git a/test/tests/es-named-import-cjs-cjs.js b/test/tests/es-named-import-cjs-cjs.js
new file mode 100644
index 000000000..a7cc4cd32
--- /dev/null
+++ b/test/tests/es-named-import-cjs-cjs.js
@@ -0,0 +1,3 @@
+exports.cjsFunc = function() {
+ return 'named export';
+}; \ No newline at end of file
diff --git a/test/tests/es-named-import-cjs.js b/test/tests/es-named-import-cjs.js
new file mode 100644
index 000000000..f484570c9
--- /dev/null
+++ b/test/tests/es-named-import-cjs.js
@@ -0,0 +1,2 @@
+import {cjsFunc} from './es-named-import-cjs-cjs.js';
+export var cjsFuncValue = cjsFunc(); \ No newline at end of file
diff --git a/test/tests/es6-and-amd.js b/test/tests/es6-and-amd.js
new file mode 100644
index 000000000..4c0a87465
--- /dev/null
+++ b/test/tests/es6-and-amd.js
@@ -0,0 +1,2 @@
+export {default as amd_module} from './eaa-amd.js';
+export {default as es6_module} from './eaa-es6.js'; \ No newline at end of file
diff --git a/test/tests/es6-circular1.js b/test/tests/es6-circular1.js
new file mode 100644
index 000000000..2cbd289ad
--- /dev/null
+++ b/test/tests/es6-circular1.js
@@ -0,0 +1,10 @@
+import {c} from './es6-circular2.js';
+export var q;
+export var r;
+export function p() {
+ if (q)
+ r = c;
+ else
+ q = c;
+}
+p();
diff --git a/test/tests/es6-circular2.js b/test/tests/es6-circular2.js
new file mode 100644
index 000000000..2a6f5c391
--- /dev/null
+++ b/test/tests/es6-circular2.js
@@ -0,0 +1,3 @@
+export var c = 3;
+import { p } from './es6-circular1.js';
+p();
diff --git a/test/tests/es6-cjs-named-export.js b/test/tests/es6-cjs-named-export.js
new file mode 100644
index 000000000..378335ccf
--- /dev/null
+++ b/test/tests/es6-cjs-named-export.js
@@ -0,0 +1 @@
+export {someExport} from './cjs-named-export.js'; \ No newline at end of file
diff --git a/test/tests/es6-detection1.js b/test/tests/es6-detection1.js
new file mode 100644
index 000000000..3fc252f50
--- /dev/null
+++ b/test/tests/es6-detection1.js
@@ -0,0 +1 @@
+import {q} from './es6-format.js'; \ No newline at end of file
diff --git a/test/tests/es6-format.js b/test/tests/es6-format.js
new file mode 100644
index 000000000..47b28ed47
--- /dev/null
+++ b/test/tests/es6-format.js
@@ -0,0 +1,6 @@
+"format es6";
+
+class q {
+}
+
+
diff --git a/test/tests/es6-import-star-amd.js b/test/tests/es6-import-star-amd.js
new file mode 100644
index 000000000..9cf2ff2c0
--- /dev/null
+++ b/test/tests/es6-import-star-amd.js
@@ -0,0 +1,3 @@
+import * as mod from './es6-loading-amd-dep.js';
+
+export var g = mod.default; \ No newline at end of file
diff --git a/test/tests/es6-loading-amd-dep.js b/test/tests/es6-loading-amd-dep.js
new file mode 100644
index 000000000..78ecb1bf4
--- /dev/null
+++ b/test/tests/es6-loading-amd-dep.js
@@ -0,0 +1,3 @@
+define(function() {
+ return true;
+}) \ No newline at end of file
diff --git a/test/tests/es6-loading-amd.js b/test/tests/es6-loading-amd.js
new file mode 100644
index 000000000..565fdd416
--- /dev/null
+++ b/test/tests/es6-loading-amd.js
@@ -0,0 +1,9 @@
+System.register(["./es6-loading-amd-dep.js"], function($__export) {
+ "use strict";
+ return {
+ setters: [function(m) {
+ $__export("amd", m.default);
+ }],
+ execute: function() {}
+ };
+});
diff --git a/test/tests/es6-plugin.js b/test/tests/es6-plugin.js
new file mode 100644
index 000000000..e37de9fce
--- /dev/null
+++ b/test/tests/es6-plugin.js
@@ -0,0 +1,3 @@
+export function fetch() {
+ return 'module.exports = "plugin";';
+} \ No newline at end of file
diff --git a/test/tests/esm-dep.js b/test/tests/esm-dep.js
new file mode 100644
index 000000000..f700e4920
--- /dev/null
+++ b/test/tests/esm-dep.js
@@ -0,0 +1,5 @@
+export var esmDep = true;
+
+(function(g) {
+ g.esmDep = 'esm-dep';
+})(typeof window != 'undefined' ? window : global); \ No newline at end of file
diff --git a/test/tests/esm-with-deps.js b/test/tests/esm-with-deps.js
new file mode 100644
index 000000000..55c925513
--- /dev/null
+++ b/test/tests/esm-with-deps.js
@@ -0,0 +1 @@
+export var p = 5; \ No newline at end of file
diff --git a/test/tests/export-star.js b/test/tests/export-star.js
new file mode 100644
index 000000000..31cd2ebac
--- /dev/null
+++ b/test/tests/export-star.js
@@ -0,0 +1,2 @@
+export * from './star-dep.js';
+export var bar = 'bar'; \ No newline at end of file
diff --git a/test/tests/foo.js b/test/tests/foo.js
new file mode 100644
index 000000000..343cf430b
--- /dev/null
+++ b/test/tests/foo.js
@@ -0,0 +1,10 @@
+System.register("tests/foo.js", [], function($__export) {
+ "use strict";
+ var __moduleName = "foo";
+ return {
+ setters: [],
+ execute: function() {
+ $__export('f', 'f');
+ }
+ };
+});
diff --git a/test/tests/global-dep.js b/test/tests/global-dep.js
new file mode 100644
index 000000000..3f6511023
--- /dev/null
+++ b/test/tests/global-dep.js
@@ -0,0 +1,5 @@
+(function(window) {
+ window.jjQuery = {
+ v: '1.8.3'
+ };
+})(typeof window != 'undefined' ? window : global); \ No newline at end of file
diff --git a/test/tests/global-encapsulation.js b/test/tests/global-encapsulation.js
new file mode 100644
index 000000000..b480da8ae
--- /dev/null
+++ b/test/tests/global-encapsulation.js
@@ -0,0 +1,3 @@
+(function(g) {
+ g.globalName = 'encapsulated global';
+})(typeof window != 'undefined' ? window : global); \ No newline at end of file
diff --git a/test/tests/global-exports-array.js b/test/tests/global-exports-array.js
new file mode 100644
index 000000000..ddfb91a37
--- /dev/null
+++ b/test/tests/global-exports-array.js
@@ -0,0 +1,5 @@
+A = 'A';
+
+B = 'B';
+
+C = 'C'; \ No newline at end of file
diff --git a/test/tests/global-inaccessible-props.js b/test/tests/global-inaccessible-props.js
new file mode 100644
index 000000000..aee7ce02b
--- /dev/null
+++ b/test/tests/global-inaccessible-props.js
@@ -0,0 +1,8 @@
+
+(function(window) {
+ if (!('errorOnAccess' in window))
+ throw Error();
+
+ window.test = 'result of global-inaccessible-props';
+
+})(typeof window != 'undefined' ? window : global);
diff --git a/test/tests/global-inline-dep.js b/test/tests/global-inline-dep.js
new file mode 100644
index 000000000..6873a63b9
--- /dev/null
+++ b/test/tests/global-inline-dep.js
@@ -0,0 +1,7 @@
+'format global';
+'deps ./global-dep.js';
+
+
+(function(window) {
+ window.newDep = jjQuery.v;
+})(typeof window != 'undefined' ? window : global); \ No newline at end of file
diff --git a/test/tests/global-inline-export.js b/test/tests/global-inline-export.js
new file mode 100644
index 000000000..0fc07aea5
--- /dev/null
+++ b/test/tests/global-inline-export.js
@@ -0,0 +1,9 @@
+"format global";
+"exports p.r";
+
+(function(window) {
+
+ window.p = {
+ r: 'r'
+ };
+})(typeof window != 'undefined' ? window : global); \ No newline at end of file
diff --git a/test/tests/global-multi-diff.js b/test/tests/global-multi-diff.js
new file mode 100644
index 000000000..2b58ae2b1
--- /dev/null
+++ b/test/tests/global-multi-diff.js
@@ -0,0 +1,3 @@
+foo = "barz";
+baz = "chaz";
+this.zed = "ted"; \ No newline at end of file
diff --git a/test/tests/global-multi.js b/test/tests/global-multi.js
new file mode 100644
index 000000000..e7f0b5cfc
--- /dev/null
+++ b/test/tests/global-multi.js
@@ -0,0 +1,6 @@
+(function(window) {
+ window.j$ = window.jjQuery = {
+ jquery: 'here'
+ };
+})(typeof window != 'undefined' ? window : global);
+
diff --git a/test/tests/global-shim-amd.js b/test/tests/global-shim-amd.js
new file mode 100644
index 000000000..9754587be
--- /dev/null
+++ b/test/tests/global-shim-amd.js
@@ -0,0 +1,6 @@
+(function(window) {
+ if (false)
+ define(function() {
+ });
+ window.test = 'global';
+})(typeof window != 'undefined' ? window : global); \ No newline at end of file
diff --git a/test/tests/global-shim-config-dep.js b/test/tests/global-shim-config-dep.js
new file mode 100644
index 000000000..a7ec1756b
--- /dev/null
+++ b/test/tests/global-shim-config-dep.js
@@ -0,0 +1 @@
+dep = 'shimmed'
diff --git a/test/tests/global-shim-config-exports.js b/test/tests/global-shim-config-exports.js
new file mode 100644
index 000000000..39553bca8
--- /dev/null
+++ b/test/tests/global-shim-config-exports.js
@@ -0,0 +1 @@
+var p = 'export'
diff --git a/test/tests/global-shim-config.js b/test/tests/global-shim-config.js
new file mode 100644
index 000000000..62139f6e3
--- /dev/null
+++ b/test/tests/global-shim-config.js
@@ -0,0 +1,3 @@
+(function(window) {
+ window.ME = dep;
+})(typeof window != 'undefined' ? window : global); \ No newline at end of file
diff --git a/test/tests/global-single-compiled.js b/test/tests/global-single-compiled.js
new file mode 100644
index 000000000..1c55c7506
--- /dev/null
+++ b/test/tests/global-single-compiled.js
@@ -0,0 +1,9 @@
+System.registerDynamic([], false, function($__require, $__exports, $__module) {
+ var _retrieveGlobal = System.get("@@global-helpers").prepareGlobal($__module.id, null, null);
+ (function() {
+ var foo = this["foobar"];
+ var foo = 'foo';
+ this["foobar"] = foo;
+ })();
+ return _retrieveGlobal();
+}) \ No newline at end of file
diff --git a/test/tests/global-single.js b/test/tests/global-single.js
new file mode 100644
index 000000000..9f6197b5f
--- /dev/null
+++ b/test/tests/global-single.js
@@ -0,0 +1 @@
+var foo = 'bar'; \ No newline at end of file
diff --git a/test/tests/global-with-export.js b/test/tests/global-with-export.js
new file mode 100644
index 000000000..656ea6a19
--- /dev/null
+++ b/test/tests/global-with-export.js
@@ -0,0 +1,5 @@
+(function(window) {
+ window.q = {
+ r: 'r'
+ };
+})(typeof window != 'undefined' ? window : global); \ No newline at end of file
diff --git a/test/tests/global.js b/test/tests/global.js
new file mode 100644
index 000000000..ae948f58c
--- /dev/null
+++ b/test/tests/global.js
@@ -0,0 +1,6 @@
+jjQuery = {
+ v: '2.0..0'
+};
+another = {
+ some: 'thing'
+}; \ No newline at end of file
diff --git a/test/tests/group-test.js b/test/tests/group-test.js
new file mode 100644
index 000000000..61e4eea78
--- /dev/null
+++ b/test/tests/group-test.js
@@ -0,0 +1,34 @@
+"format register";
+
+System.register("group-c", [], function($__export) {
+ "use strict";
+ var __moduleName = "group-c";
+ return {
+ setters: [],
+ execute: function() {
+ $__export('default', 'bar');
+ }
+ };
+});
+
+
+
+System.registerDynamic("group-b", ["group-c"], false, function(__require, __exports, __module) {
+ var _retrieveGlobal = System.get("@@global-helpers").prepareGlobal(__module.id);
+ (function() {
+ this.foo = 'foo';
+ }).call(System.global);
+ return _retrieveGlobal();
+});
+
+System.register("group-a", ["./group-b"], function($__export) {
+ "use strict";
+ var __moduleName = "group-a";
+ return {
+ setters: [function(m) {}],
+ execute: function() {}
+ };
+});
+
+
+
diff --git a/test/tests/hbs.hbs b/test/tests/hbs.hbs
new file mode 100644
index 000000000..6213adcb4
--- /dev/null
+++ b/test/tests/hbs.hbs
@@ -0,0 +1 @@
+<h1>{{title}}</h1>
diff --git a/test/tests/inline-depends-dep.js b/test/tests/inline-depends-dep.js
new file mode 100644
index 000000000..9310d31aa
--- /dev/null
+++ b/test/tests/inline-depends-dep.js
@@ -0,0 +1 @@
+window.depValue = 'dep'; \ No newline at end of file
diff --git a/test/tests/inline-depends.js b/test/tests/inline-depends.js
new file mode 100644
index 000000000..61b318777
--- /dev/null
+++ b/test/tests/inline-depends.js
@@ -0,0 +1 @@
+window.dep = window.depValue; \ No newline at end of file
diff --git a/test/tests/jquery-named.js b/test/tests/jquery-named.js
new file mode 100644
index 000000000..e53799d35
--- /dev/null
+++ b/test/tests/jquery-named.js
@@ -0,0 +1,3 @@
+define('jquery-named', function() {
+ return { is: 'jquery' };
+}); \ No newline at end of file
diff --git a/test/tests/jquery.js b/test/tests/jquery.js
new file mode 100644
index 000000000..e0ec49a53
--- /dev/null
+++ b/test/tests/jquery.js
@@ -0,0 +1,2 @@
+var a = 'a';
+module.exports = require(a); \ No newline at end of file
diff --git a/test/tests/legacy-plugin.js b/test/tests/legacy-plugin.js
new file mode 100644
index 000000000..89fd23f8e
--- /dev/null
+++ b/test/tests/legacy-plugin.js
@@ -0,0 +1,5 @@
+module.exports = function(name, address, fetch, callback, errback) {
+ fetch(address, function(source) {
+ callback('exports.plugin = true; ' + source);
+ });
+}
diff --git a/test/tests/loader-scoping.js b/test/tests/loader-scoping.js
new file mode 100644
index 000000000..656184c5f
--- /dev/null
+++ b/test/tests/loader-scoping.js
@@ -0,0 +1 @@
+export let loader = System; \ No newline at end of file
diff --git a/test/tests/main-bundle.js b/test/tests/main-bundle.js
new file mode 100644
index 000000000..9bf9a306d
--- /dev/null
+++ b/test/tests/main-bundle.js
@@ -0,0 +1,3 @@
+define('jquery', function() {
+ return { name: 'jquery-bundled' };
+}); \ No newline at end of file
diff --git a/test/tests/main-dep.js b/test/tests/main-dep.js
new file mode 100644
index 000000000..83e0e77d4
--- /dev/null
+++ b/test/tests/main-dep.js
@@ -0,0 +1 @@
+exports.dep = 'value'; \ No newline at end of file
diff --git a/test/tests/main.js b/test/tests/main.js
new file mode 100644
index 000000000..7e6f820a0
--- /dev/null
+++ b/test/tests/main.js
@@ -0,0 +1 @@
+module.exports = require('./main-dep'); \ No newline at end of file
diff --git a/test/tests/map-test-dep.js b/test/tests/map-test-dep.js
new file mode 100644
index 000000000..8085c9632
--- /dev/null
+++ b/test/tests/map-test-dep.js
@@ -0,0 +1 @@
+exports.dep = 'maptest';
diff --git a/test/tests/map-test.js b/test/tests/map-test.js
new file mode 100644
index 000000000..e87087e78
--- /dev/null
+++ b/test/tests/map-test.js
@@ -0,0 +1 @@
+exports.maptest = require('./map-test-dep.js').dep;
diff --git a/test/tests/map-test/sub.js b/test/tests/map-test/sub.js
new file mode 100644
index 000000000..64dcc8a01
--- /dev/null
+++ b/test/tests/map-test/sub.js
@@ -0,0 +1 @@
+exports.maptest = 'maptestsub';
diff --git a/test/tests/map-version.js b/test/tests/map-version.js
new file mode 100644
index 000000000..56ad56a96
--- /dev/null
+++ b/test/tests/map-version.js
@@ -0,0 +1 @@
+module.exports = require('./mvd@1.js'); \ No newline at end of file
diff --git a/test/tests/meta-deps.js b/test/tests/meta-deps.js
new file mode 100644
index 000000000..6bf3b4520
--- /dev/null
+++ b/test/tests/meta-deps.js
@@ -0,0 +1,21 @@
+(function(global) {
+
+System.config({
+ meta: {
+ b: {
+ deps: ['a']
+ }
+ }
+});
+
+define('a', [], function() {
+ global.MODULEA = 'a';
+});
+
+define('b', [], function() {
+ return {
+ a: global.MODULEA
+ };
+});
+
+})(typeof window == 'undefined' ? global : window); \ No newline at end of file
diff --git a/test/tests/meta-override.js b/test/tests/meta-override.js
new file mode 100644
index 000000000..b820ec262
--- /dev/null
+++ b/test/tests/meta-override.js
@@ -0,0 +1,2 @@
+"format global";
+export var p = 'value'; \ No newline at end of file
diff --git a/test/tests/mixed-bundle.js b/test/tests/mixed-bundle.js
new file mode 100644
index 000000000..58a25c355
--- /dev/null
+++ b/test/tests/mixed-bundle.js
@@ -0,0 +1,68 @@
+System.register("tree/third", [], function($__export) {
+ var some;
+ return {
+ setters: [],
+ execute: function() {
+ some = $__export('some', 'exports');
+ }
+ };
+});
+
+System.registerDynamic("tree/cjs", [], true, function(require, exports, __moduleName) {
+ var global = System.global;
+ var __define = global.define;
+ global.define = undefined;
+ var module = { exports: exports };
+ var process = System.get("@@nodeProcess");
+ exports.cjs = true;
+ global.define = __define;
+ return module.exports;
+});
+
+System.registerDynamic("tree/jquery", [], false, function(require, exports, __moduleName) {
+ var _retrieveGlobal = System.get("@@global-helpers").prepareGlobal(__moduleName);
+ this.jquery = {};
+
+
+ return _retrieveGlobal();
+});
+
+System.register("tree/second", ["./third", "./cjs"], function($__export) {
+ "use strict";
+ var __moduleName = "tree/second";
+ var q;
+ return {
+ setters: [function() {}, function() {}],
+ execute: function() {
+ q = $__export('q', 4);
+ }
+ };
+});
+
+System.registerDynamic("tree/global", ['./jquery'], false, function(__require, __exports, __moduleName) {
+ var _retrieveGlobal = System.get("@@global-helpers").prepareGlobal(__moduleName, "jquery.test");
+ "deps ./jquery";
+ "exports jquery.test";
+ this.jquery = this.jquery || {};
+ this.jquery.test = 'output';
+
+ this["jquery.test"] = jquery.test;
+ return _retrieveGlobal();
+});
+
+System.registerDynamic("tree/amd", ['./global'], false, function() {
+ return { is: 'amd' };
+});
+
+
+System.register("tree/first", ["./second", "./amd"], function($__export) {
+ "use strict";
+ var __moduleName = "tree/first";
+ var p;
+ return {
+ setters: [function() {}, function() {}],
+ execute: function() {
+ p = $__export('p', 5);
+ }
+ };
+});
diff --git a/test/tests/modA.js b/test/tests/modA.js
new file mode 100644
index 000000000..5e9b95304
--- /dev/null
+++ b/test/tests/modA.js
@@ -0,0 +1,7 @@
+define(function (require, exports, module) {
+'use strict';
+
+ var B = require("tests/lib/modB.js");
+ var C = require("./modC.js");
+ exports.A = "A";
+});
diff --git a/test/tests/modC.js b/test/tests/modC.js
new file mode 100644
index 000000000..00f89c525
--- /dev/null
+++ b/test/tests/modC.js
@@ -0,0 +1,5 @@
+define(function (require, exports, module) {
+'use strict';
+
+
+});
diff --git a/test/tests/module-name.js b/test/tests/module-name.js
new file mode 100644
index 000000000..4076c2b6e
--- /dev/null
+++ b/test/tests/module-name.js
@@ -0,0 +1,8 @@
+System.register([], function(_export, _context) {
+ return {
+ setters: [],
+ execute: function() {
+ _export('name', _context.id);
+ }
+ };
+}) \ No newline at end of file
diff --git a/test/tests/module.js b/test/tests/module.js
new file mode 100644
index 000000000..45cd96970
--- /dev/null
+++ b/test/tests/module.js
@@ -0,0 +1,3 @@
+import * as default3 from "./default3.js";
+
+export var test = default3.default; \ No newline at end of file
diff --git a/test/tests/multiple-anonymous.js b/test/tests/multiple-anonymous.js
new file mode 100644
index 000000000..5e4b93f98
--- /dev/null
+++ b/test/tests/multiple-anonymous.js
@@ -0,0 +1,14 @@
+define('named-in-anon', function() {
+ return 'named';
+});
+
+define(['named-in-anon'], function(named) {
+ return {
+ anon: true,
+ named: named
+ };
+});
+
+define([], function() {
+
+}); \ No newline at end of file
diff --git a/test/tests/mypackage/index.js b/test/tests/mypackage/index.js
new file mode 100644
index 000000000..78b94fe65
--- /dev/null
+++ b/test/tests/mypackage/index.js
@@ -0,0 +1 @@
+this.mapDep = 'bar';
diff --git a/test/tests/mypackage/lib/bar.js b/test/tests/mypackage/lib/bar.js
new file mode 100644
index 000000000..e198b88a4
--- /dev/null
+++ b/test/tests/mypackage/lib/bar.js
@@ -0,0 +1,2 @@
+bar = 'bar';
+exports = {};
diff --git a/test/tests/mypackage/src/foo.js b/test/tests/mypackage/src/foo.js
new file mode 100644
index 000000000..31e546b5a
--- /dev/null
+++ b/test/tests/mypackage/src/foo.js
@@ -0,0 +1,3 @@
+file = 'foo'
+if (typeof define != 'undefined')
+ define({});
diff --git a/test/tests/nameddefine.js b/test/tests/nameddefine.js
new file mode 100644
index 000000000..f0a302971
--- /dev/null
+++ b/test/tests/nameddefine.js
@@ -0,0 +1,14 @@
+var Showdown = { converter: true };
+
+// export
+if (typeof module !== 'undefined') module.exports = Showdown;
+
+// stolen from AMD branch of underscore
+// AMD define happens at the end for compatibility with AMD loaders
+// that don't enforce next-turn semantics on modules.
+if (typeof define === 'function' && define.amd) {
+ define('tests/nameddefine.js', function() {
+ return Showdown;
+ });
+}
+define('another-define', { named: 'define' });
diff --git a/test/tests/no-default-ext/file.ext b/test/tests/no-default-ext/file.ext
new file mode 100644
index 000000000..0194738d0
--- /dev/null
+++ b/test/tests/no-default-ext/file.ext
@@ -0,0 +1 @@
+exports.ext = 'ext';
diff --git a/test/tests/normalize-hook-test.js b/test/tests/normalize-hook-test.js
new file mode 100644
index 000000000..f4d3fb627
--- /dev/null
+++ b/test/tests/normalize-hook-test.js
@@ -0,0 +1 @@
+"hello world"; \ No newline at end of file
diff --git a/test/tests/out.js b/test/tests/out.js
new file mode 100644
index 000000000..9eb31e4c1
--- /dev/null
+++ b/test/tests/out.js
@@ -0,0 +1,19 @@
+"bundle";
+(function() {
+var define = System.amdDefine;
+define("tests/lib/modD.js", ["require", "exports", "module"], function(require, exports, module) {
+ 'use strict';
+ exports.D = "D";
+});
+
+})();
+(function() {
+var define = System.amdDefine;
+define("tests/lib/modB.js", ["require", "exports", "module", "../modC.js", "./modD.js"], function(require, exports, module) {
+ 'use strict';
+ require('../modC.js');
+ require('./modD.js');
+ exports.B = "B";
+});
+
+})(); \ No newline at end of file
diff --git a/test/tests/package-local-alias/index-cjs.js b/test/tests/package-local-alias/index-cjs.js
new file mode 100644
index 000000000..0cd8dedcc
--- /dev/null
+++ b/test/tests/package-local-alias/index-cjs.js
@@ -0,0 +1,6 @@
+
+var local = require('./local-cjs');
+
+exports.q = 'q';
+
+exports.fromLocal = local.x;
diff --git a/test/tests/package-local-alias/index-default-cjs.js b/test/tests/package-local-alias/index-default-cjs.js
new file mode 100644
index 000000000..d0a59da14
--- /dev/null
+++ b/test/tests/package-local-alias/index-default-cjs.js
@@ -0,0 +1,10 @@
+
+var local = require('./local-default-cjs');
+
+exports.q = 'q';
+
+exports.fromLocal = local;
+
+var localDirect = require('./local/index-default-cjs.js');
+
+exports.fromLocalDirect = localDirect;
diff --git a/test/tests/package-local-alias/index-default-esm.js b/test/tests/package-local-alias/index-default-esm.js
new file mode 100644
index 000000000..aead1e036
--- /dev/null
+++ b/test/tests/package-local-alias/index-default-esm.js
@@ -0,0 +1,10 @@
+
+import local from './local-default-esm';
+
+export var q = 'q';
+export var fromLocal = local;
+
+import localDirect from './local/index-default-esm.js';
+
+export var fromLocalDirect = localDirect;
+
diff --git a/test/tests/package-local-alias/index-esm.js b/test/tests/package-local-alias/index-esm.js
new file mode 100644
index 000000000..809c99695
--- /dev/null
+++ b/test/tests/package-local-alias/index-esm.js
@@ -0,0 +1,5 @@
+
+import {x} from './local-esm';
+
+export var q = 'q';
+export var fromLocal = x; \ No newline at end of file
diff --git a/test/tests/package-local-alias/local/index-cjs.js b/test/tests/package-local-alias/local/index-cjs.js
new file mode 100644
index 000000000..af02af190
--- /dev/null
+++ b/test/tests/package-local-alias/local/index-cjs.js
@@ -0,0 +1 @@
+exports.x = 'x';
diff --git a/test/tests/package-local-alias/local/index-default-cjs.js b/test/tests/package-local-alias/local/index-default-cjs.js
new file mode 100644
index 000000000..ee03c3617
--- /dev/null
+++ b/test/tests/package-local-alias/local/index-default-cjs.js
@@ -0,0 +1 @@
+module.exports = 'x';
diff --git a/test/tests/package-local-alias/local/index-default-esm.js b/test/tests/package-local-alias/local/index-default-esm.js
new file mode 100644
index 000000000..d35f42cc0
--- /dev/null
+++ b/test/tests/package-local-alias/local/index-default-esm.js
@@ -0,0 +1,2 @@
+
+export default 'x';
diff --git a/test/tests/package-local-alias/local/index-esm.js b/test/tests/package-local-alias/local/index-esm.js
new file mode 100644
index 000000000..5039a381e
--- /dev/null
+++ b/test/tests/package-local-alias/local/index-esm.js
@@ -0,0 +1 @@
+export var x = 'x';
diff --git a/test/tests/path/deep.js b/test/tests/path/deep.js
new file mode 100644
index 000000000..e254c491a
--- /dev/null
+++ b/test/tests/path/deep.js
@@ -0,0 +1 @@
+module.exports = 'path';
diff --git a/test/tests/plugin-dep.js b/test/tests/plugin-dep.js
new file mode 100644
index 000000000..4485e45e4
--- /dev/null
+++ b/test/tests/plugin-dep.js
@@ -0,0 +1,8 @@
+System.register([], function($__export) {
+ return {
+ setters: [],
+ execute: function() {
+ $__export('p', 5);
+ }
+ };
+}); \ No newline at end of file
diff --git a/test/tests/plugin@1.2.3/plugin.js b/test/tests/plugin@1.2.3/plugin.js
new file mode 100644
index 000000000..741d6e0f6
--- /dev/null
+++ b/test/tests/plugin@1.2.3/plugin.js
@@ -0,0 +1,3 @@
+exports.translate = function(load) {
+ load.source += '\nexports.versionedPlugin = true;';
+} \ No newline at end of file
diff --git a/test/tests/reflection.js b/test/tests/reflection.js
new file mode 100644
index 000000000..765dfe816
--- /dev/null
+++ b/test/tests/reflection.js
@@ -0,0 +1 @@
+export var myname = __moduleName;
diff --git a/test/tests/register-circular1.js b/test/tests/register-circular1.js
new file mode 100644
index 000000000..178980f73
--- /dev/null
+++ b/test/tests/register-circular1.js
@@ -0,0 +1,24 @@
+System.register(["./register-circular2.js"], function($__export) {
+ "use strict";
+ var c,
+ q,
+ r;
+ function p() {
+ if (q)
+ $__export("r", r = c);
+ else
+ $__export("q", q = c);
+ }
+ $__export("p", p);
+ return {
+ setters: [function(m) {
+ c = m.c;
+ }],
+ execute: function() {
+ c = 5;
+ q = $__export("q", q);
+ r = $__export("r", r);
+ p();
+ }
+ };
+}); \ No newline at end of file
diff --git a/test/tests/register-circular2.js b/test/tests/register-circular2.js
new file mode 100644
index 000000000..5b661b81d
--- /dev/null
+++ b/test/tests/register-circular2.js
@@ -0,0 +1,14 @@
+System.register(["./register-circular1.js"], function($__export) {
+ "use strict";
+ var c,
+ p;
+ return {
+ setters: [function(m) {
+ p = m.p;
+ }],
+ execute: function() {
+ c = $__export("c", 3);
+ p();
+ }
+ };
+}); \ No newline at end of file
diff --git a/test/tests/register-default-extension.js b/test/tests/register-default-extension.js
new file mode 100644
index 000000000..0ab2b012a
--- /dev/null
+++ b/test/tests/register-default-extension.js
@@ -0,0 +1,8 @@
+System.register('custom/file.ext', [], function(_export) {
+ return {
+ setters: [],
+ execute: function() {
+ _export('custom', 'ext');
+ }
+ };
+}); \ No newline at end of file
diff --git a/test/tests/register-regex-2.js b/test/tests/register-regex-2.js
new file mode 100644
index 000000000..3715b11e6
--- /dev/null
+++ b/test/tests/register-regex-2.js
@@ -0,0 +1,15 @@
+/**
+ * @file file comment
+ * ...
+ */
+
+/**
+ * module comment
+ * ...
+ */
+System.register([], function() {
+ return {
+ setters: [],
+ execute: function() {}
+ };
+}); \ No newline at end of file
diff --git a/test/tests/register-regex.js b/test/tests/register-regex.js
new file mode 100644
index 000000000..847e818fd
--- /dev/null
+++ b/test/tests/register-regex.js
@@ -0,0 +1,18 @@
+//// /collection/
+//import 'test/background/collection/clientErrors.spec';
+//import 'test/background/collection/playlistItems.spec';
+//import 'test/background/collection/playlists.spec';
+//import 'test/background/collection/searchResults.spec';
+//import 'test/background/collection/videos.spec';
+//import 'test/background/collection/streamItems.spec';
+
+//// /model/
+//import 'test/background/model/activePlaylistManager.spec';
+//import 'test/background/model/clientErrorManager.spec';
+//import 'test/background/model/dataSource.spec';
+//import 'test/background/model/playlistItem.spec';
+//import 'test/background/model/playlistItems.spec';
+//import 'test/background/model/relatedVideosManager.spec';
+//import 'test/background/model/signInManager.spec';
+//import 'test/background/model/user.spec';
+//import 'test/background/model/youTubeV3API.spec'; \ No newline at end of file
diff --git a/test/tests/registerdynamic-main.js b/test/tests/registerdynamic-main.js
new file mode 100644
index 000000000..dbd630a1d
--- /dev/null
+++ b/test/tests/registerdynamic-main.js
@@ -0,0 +1,11 @@
+System.register(["./registerdynamic-notbundled.js"], function(_export) {
+ var dependency;
+ return {
+ setters: [function(_dependency) {
+ dependency = _dependency['default'];
+ }],
+ execute: function() {
+ _export("dependency", dependency);
+ }
+ }
+});
diff --git a/test/tests/registerdynamic-notbundled.js b/test/tests/registerdynamic-notbundled.js
new file mode 100644
index 000000000..3406df504
--- /dev/null
+++ b/test/tests/registerdynamic-notbundled.js
@@ -0,0 +1,5 @@
+System.registerDynamic([], true, function(require, exports, module) {
+ module.exports = function() {
+ return 'ok';
+ };
+});
diff --git a/test/tests/reldynamic.js b/test/tests/reldynamic.js
new file mode 100644
index 000000000..99b5202a8
--- /dev/null
+++ b/test/tests/reldynamic.js
@@ -0,0 +1,5 @@
+
+
+export function dynamicLoad() {
+ return System.import('./reldynamicdep.js', __moduleName);
+}
diff --git a/test/tests/reldynamicdep.js b/test/tests/reldynamicdep.js
new file mode 100644
index 000000000..96da4b8e9
--- /dev/null
+++ b/test/tests/reldynamicdep.js
@@ -0,0 +1 @@
+export var dynamic = 'module';
diff --git a/test/tests/shared-dep-bundles/a.js b/test/tests/shared-dep-bundles/a.js
new file mode 100644
index 000000000..76aef0ec9
--- /dev/null
+++ b/test/tests/shared-dep-bundles/a.js
@@ -0,0 +1,33 @@
+"format register";
+
+System.register("lib/shared-dep", [], function($__export) {
+ "use strict";
+ var __moduleName = "lib/shared-dep";
+ function shared() {}
+ $__export("default", shared);
+ return {
+ setters: [],
+ execute: function() {
+ ;
+ }
+ };
+});
+
+
+
+System.register("lib/a", ["./shared-dep"], function($__export) {
+ "use strict";
+ var __moduleName = "lib/a";
+ var shared;
+ return {
+ setters: [function(m) {
+ shared = m.default;
+ }],
+ execute: function() {
+ }
+ };
+});
+
+
+
+//# sourceMappingURL=a.js.map \ No newline at end of file
diff --git a/test/tests/shared-dep-bundles/b.js b/test/tests/shared-dep-bundles/b.js
new file mode 100644
index 000000000..eec0f0bf4
--- /dev/null
+++ b/test/tests/shared-dep-bundles/b.js
@@ -0,0 +1,33 @@
+"format register";
+
+System.register("lib/shared-dep", [], function($__export) {
+ "use strict";
+ var __moduleName = "lib/shared-dep";
+ function shared() {}
+ $__export("default", shared);
+ return {
+ setters: [],
+ execute: function() {
+ ;
+ }
+ };
+});
+
+
+
+System.register("lib/b", ["./shared-dep"], function($__export) {
+ "use strict";
+ var __moduleName = "lib/b";
+ var shared;
+ return {
+ setters: [function(m) {
+ shared = m.default;
+ }],
+ execute: function() {
+ }
+ };
+});
+
+
+
+//# sourceMappingURL=b.js.map \ No newline at end of file
diff --git a/test/tests/shim-map-test-dep.js b/test/tests/shim-map-test-dep.js
new file mode 100644
index 000000000..409cf392a
--- /dev/null
+++ b/test/tests/shim-map-test-dep.js
@@ -0,0 +1 @@
+shimmapdep = 'depvalue' \ No newline at end of file
diff --git a/test/tests/shim-package/shim-map-test.js b/test/tests/shim-package/shim-map-test.js
new file mode 100644
index 000000000..3dc9d9e8a
--- /dev/null
+++ b/test/tests/shim-package/shim-map-test.js
@@ -0,0 +1 @@
+(typeof window != 'undefined' ? window : global).shimdep = shimmapdep; \ No newline at end of file
diff --git a/test/tests/some-json.json b/test/tests/some-json.json
new file mode 100644
index 000000000..ee68c7e15
--- /dev/null
+++ b/test/tests/some-json.json
@@ -0,0 +1,3 @@
+{
+ "some": "json"
+}
diff --git a/test/tests/some-text.txt b/test/tests/some-text.txt
new file mode 100644
index 000000000..9ce617009
--- /dev/null
+++ b/test/tests/some-text.txt
@@ -0,0 +1 @@
+this is some text
diff --git a/test/tests/star-dep.js b/test/tests/star-dep.js
new file mode 100644
index 000000000..0b7981c28
--- /dev/null
+++ b/test/tests/star-dep.js
@@ -0,0 +1 @@
+export var foo = 'foo'; \ No newline at end of file
diff --git a/test/tests/subcontextual-map/submodule.js b/test/tests/subcontextual-map/submodule.js
new file mode 100644
index 000000000..ffc2d7fe5
--- /dev/null
+++ b/test/tests/subcontextual-map/submodule.js
@@ -0,0 +1,3 @@
+define(['dep'], function(dep) {
+ return dep;
+}); \ No newline at end of file
diff --git a/test/tests/subcontextual-mapdep.js b/test/tests/subcontextual-mapdep.js
new file mode 100644
index 000000000..ad8c9d6d6
--- /dev/null
+++ b/test/tests/subcontextual-mapdep.js
@@ -0,0 +1 @@
+module.exports = 'submapdep'; \ No newline at end of file
diff --git a/test/tests/test.css b/test/tests/test.css
new file mode 100644
index 000000000..e56b63dfe
--- /dev/null
+++ b/test/tests/test.css
@@ -0,0 +1 @@
+this is css \ No newline at end of file
diff --git a/test/tests/testpkg/depcache-test.js b/test/tests/testpkg/depcache-test.js
new file mode 100644
index 000000000..d88fb1bde
--- /dev/null
+++ b/test/tests/testpkg/depcache-test.js
@@ -0,0 +1 @@
+(typeof window != 'undefined' ? window : global).depCacheTest = 'passed';
diff --git a/test/tests/testpkg/dir/index.js b/test/tests/testpkg/dir/index.js
new file mode 100644
index 000000000..cef6cd572
--- /dev/null
+++ b/test/tests/testpkg/dir/index.js
@@ -0,0 +1,2 @@
+require('./self-load.js');
+module.exports = 'dirindex'; \ No newline at end of file
diff --git a/test/tests/testpkg/dir/self-load.js b/test/tests/testpkg/dir/self-load.js
new file mode 100644
index 000000000..c6a24bda6
--- /dev/null
+++ b/test/tests/testpkg/dir/self-load.js
@@ -0,0 +1,2 @@
+exports.a = require('..');
+exports.b = require('../'); \ No newline at end of file
diff --git a/test/tests/testpkg/dir2/index.json b/test/tests/testpkg/dir2/index.json
new file mode 100644
index 000000000..07bd1b14d
--- /dev/null
+++ b/test/tests/testpkg/dir2/index.json
@@ -0,0 +1,3 @@
+{
+ "json": "index"
+} \ No newline at end of file
diff --git a/test/tests/testpkg/env-module-browser.js b/test/tests/testpkg/env-module-browser.js
new file mode 100644
index 000000000..e36fe2f1b
--- /dev/null
+++ b/test/tests/testpkg/env-module-browser.js
@@ -0,0 +1 @@
+module.exports = 'browser'; \ No newline at end of file
diff --git a/test/tests/testpkg/env-module.js b/test/tests/testpkg/env-module.js
new file mode 100644
index 000000000..3b25aeee1
--- /dev/null
+++ b/test/tests/testpkg/env-module.js
@@ -0,0 +1 @@
+module.exports = 'not browser'; \ No newline at end of file
diff --git a/test/tests/testpkg/index.js b/test/tests/testpkg/index.js
new file mode 100644
index 000000000..2fc521784
--- /dev/null
+++ b/test/tests/testpkg/index.js
@@ -0,0 +1 @@
+exports.prop = 'value'; \ No newline at end of file
diff --git a/test/tests/testpkg/interpolate.js b/test/tests/testpkg/interpolate.js
new file mode 100644
index 000000000..d93d44f21
--- /dev/null
+++ b/test/tests/testpkg/interpolate.js
@@ -0,0 +1 @@
+module.exports = 'interpolated!'; \ No newline at end of file
diff --git a/test/tests/testpkg/json.js b/test/tests/testpkg/json.js
new file mode 100644
index 000000000..278833a81
--- /dev/null
+++ b/test/tests/testpkg/json.js
@@ -0,0 +1,4 @@
+exports.translate = function(load) {
+ load.metadata.format = 'cjs';
+ return 'module.exports = ' + load.source;
+}; \ No newline at end of file
diff --git a/test/tests/testpkg/json.json b/test/tests/testpkg/json.json
new file mode 100644
index 000000000..0acdfb14b
--- /dev/null
+++ b/test/tests/testpkg/json.json
@@ -0,0 +1,3 @@
+{
+ "prop": "value"
+} \ No newline at end of file
diff --git a/test/tests/testpkg/polate.js b/test/tests/testpkg/polate.js
new file mode 100644
index 000000000..af567b6bf
--- /dev/null
+++ b/test/tests/testpkg/polate.js
@@ -0,0 +1 @@
+module.exports = 'polate'; \ No newline at end of file
diff --git a/test/tests/testpkg/self-load.js b/test/tests/testpkg/self-load.js
new file mode 100644
index 000000000..1c5617d42
--- /dev/null
+++ b/test/tests/testpkg/self-load.js
@@ -0,0 +1,2 @@
+exports.a = require('.');
+exports.b = require('./'); \ No newline at end of file
diff --git a/test/tests/testpkg/self.js b/test/tests/testpkg/self.js
new file mode 100644
index 000000000..c543a0725
--- /dev/null
+++ b/test/tests/testpkg/self.js
@@ -0,0 +1 @@
+module.exports = require('testpkg/json'); \ No newline at end of file
diff --git a/test/tests/testpkg/system.json b/test/tests/testpkg/system.json
new file mode 100644
index 000000000..b2092752c
--- /dev/null
+++ b/test/tests/testpkg/system.json
@@ -0,0 +1,28 @@
+{
+ "README": "This is not encouraging a system.json, which is a bad idea.",
+
+ "main": ["wrong-main"],
+ "format": "cjs",
+ "defaultExtension": "js",
+ "meta": {
+ "*.json": { "loader": "json" },
+ "noext": { "alias": "./json.json" },
+ "test.ts": true
+ },
+ "map": {
+ "json": "./json.js",
+ "./json": "./json.json",
+ "./dir/": "./dir/index",
+ "./dir2.js": "./dir2/index.json",
+ "./dir/test": "global-test",
+ "./env-module": {
+ "browser": "./env-module-browser.js"
+ },
+ "p": "./polate.js",
+ "./conditional1": "./interpolate.js",
+ "./conditional2": "./inter#{p}.js"
+ },
+ "depCache": {
+ "./dir2/index.json": ["../depcache-test"]
+ }
+} \ No newline at end of file
diff --git a/test/tests/testpkg/test.ts b/test/tests/testpkg/test.ts
new file mode 100644
index 000000000..4edba8a31
--- /dev/null
+++ b/test/tests/testpkg/test.ts
@@ -0,0 +1 @@
+module.exports = 'ts'; \ No newline at end of file
diff --git a/test/tests/testpkg2.json b/test/tests/testpkg2.json
new file mode 100644
index 000000000..1aae9f17b
--- /dev/null
+++ b/test/tests/testpkg2.json
@@ -0,0 +1,6 @@
+{
+ "main": {
+ "browser": "./asdf.asdf",
+ "~browser": "./asdf.asdf"
+ }
+} \ No newline at end of file
diff --git a/test/tests/testpkg2/asdf.asdf.js b/test/tests/testpkg2/asdf.asdf.js
new file mode 100644
index 000000000..93c2cdd62
--- /dev/null
+++ b/test/tests/testpkg2/asdf.asdf.js
@@ -0,0 +1,3 @@
+define({
+ asdf: 'asdf'
+}); \ No newline at end of file
diff --git a/test/tests/typescript.ts b/test/tests/typescript.ts
new file mode 100644
index 000000000..1cd9b2985
--- /dev/null
+++ b/test/tests/typescript.ts
@@ -0,0 +1 @@
+module.exports = 'typescript'; \ No newline at end of file
diff --git a/test/tests/umd-dep.js b/test/tests/umd-dep.js
new file mode 100644
index 000000000..9a690b9c5
--- /dev/null
+++ b/test/tests/umd-dep.js
@@ -0,0 +1,3 @@
+define({
+ dep: 'hi'
+}) \ No newline at end of file
diff --git a/test/tests/umd.js b/test/tests/umd.js
new file mode 100644
index 000000000..7faad2ba9
--- /dev/null
+++ b/test/tests/umd.js
@@ -0,0 +1,10 @@
+(function (root, factory) {
+ if (typeof define === 'function' && define.amd)
+ define(['./umd-dep.js'], function(dep) {
+ return (root.amdWebGlobal = factory(dep));
+ });
+ else
+ root.amdWebGlobal = factory(root.dep);
+}(this, function(dep) {
+ return { d: dep.dep };
+}));
diff --git a/test/tests/versioned@2.0.3.js b/test/tests/versioned@2.0.3.js
new file mode 100644
index 000000000..c5f522445
--- /dev/null
+++ b/test/tests/versioned@2.0.3.js
@@ -0,0 +1 @@
+exports.version = '2.3.4';
diff --git a/test/tests/wildcard-test/2.js b/test/tests/wildcard-test/2.js
new file mode 100644
index 000000000..4d3891f0c
--- /dev/null
+++ b/test/tests/wildcard-test/2.js
@@ -0,0 +1 @@
+export var q = {};
diff --git a/test/tests/wildcard-test/2/sub.js b/test/tests/wildcard-test/2/sub.js
new file mode 100644
index 000000000..05cded75a
--- /dev/null
+++ b/test/tests/wildcard-test/2/sub.js
@@ -0,0 +1 @@
+export var sub = {};
diff --git a/test/tests/wildcard-test/first.js b/test/tests/wildcard-test/first.js
new file mode 100644
index 000000000..f2ddf5c35
--- /dev/null
+++ b/test/tests/wildcard-test/first.js
@@ -0,0 +1 @@
+export var p = {};
diff --git a/test/tests/with-global-deps.js b/test/tests/with-global-deps.js
new file mode 100644
index 000000000..4c5addac0
--- /dev/null
+++ b/test/tests/with-global-deps.js
@@ -0,0 +1 @@
+var newGlobal = $$$; \ No newline at end of file
diff --git a/test/tests/with-runtime-babel.js b/test/tests/with-runtime-babel.js
new file mode 100644
index 000000000..4dca494cb
--- /dev/null
+++ b/test/tests/with-runtime-babel.js
@@ -0,0 +1,16 @@
+System.register([], function (_export) {
+ "use strict";
+
+ var c;
+ return {
+ setters: [],
+ execute: function () {
+ c = _export("c", function c() {
+ babelHelpers.classCallCheck(this, c);
+
+ babelHelpers.get(Object.getPrototypeOf(c.prototype), "constructor", this).call(this);
+ });
+ new c();
+ }
+ };
+}); \ No newline at end of file
diff --git a/test/tests/with-runtime-traceur.js b/test/tests/with-runtime-traceur.js
new file mode 100644
index 000000000..d86a1dea7
--- /dev/null
+++ b/test/tests/with-runtime-traceur.js
@@ -0,0 +1,14 @@
+System.register([], function($__export) {
+ "use strict";
+ var __moduleName = "test";
+ var c;
+ return {
+ setters: [],
+ execute: function() {
+ c = $__export("c", (function() {
+ var c = function c() {};
+ return ($traceurRuntime.createClass)(c, {}, {});
+ }()));
+ }
+ };
+});
diff --git a/test/tests/worker-babel.js b/test/tests/worker-babel.js
new file mode 100644
index 000000000..74c741309
--- /dev/null
+++ b/test/tests/worker-babel.js
@@ -0,0 +1,14 @@
+importScripts('../../dist/system.src.js');
+
+System.paths['babel'] = '../../node_modules/babel-core/browser.js';
+
+System.transpiler = 'babel';
+
+System.import('es6-and-amd.js').then(function(m) {
+ postMessage({
+ amd: m.amd_module,
+ es6: m.es6_module
+ });
+}, function(err) {
+ console.error(err);
+});
diff --git a/test/tests/worker-traceur.js b/test/tests/worker-traceur.js
new file mode 100644
index 000000000..30902cf40
--- /dev/null
+++ b/test/tests/worker-traceur.js
@@ -0,0 +1,12 @@
+importScripts('../../dist/system.src.js');
+
+System.paths['traceur'] = '../../node_modules/traceur/bin/traceur.js';
+
+System.import('es6-and-amd.js').then(function(m) {
+ postMessage({
+ amd: m.amd_module,
+ es6: m.es6_module
+ });
+}, function(err) {
+ console.error(err);
+});
diff --git a/test/tests/worker-typescript.js b/test/tests/worker-typescript.js
new file mode 100644
index 000000000..7bbf0c231
--- /dev/null
+++ b/test/tests/worker-typescript.js
@@ -0,0 +1,16 @@
+importScripts('../../dist/system.src.js');
+
+System.paths['typescript'] = '../../node_modules/typescript/lib/typescript.js';
+System.meta['typescript'] = { format: 'global', exports: 'ts' };
+System.transpiler = 'typescript';
+
+System.normalizeSync('test');
+
+System.import('es6-and-amd.js').then(function(m) {
+ postMessage({
+ amd: m.amd_module,
+ es6: m.es6_module
+ });
+}, function(err) {
+ console.error(err);
+});
diff --git a/test/tests/wrapper.js b/test/tests/wrapper.js
new file mode 100644
index 000000000..9a8eb0328
--- /dev/null
+++ b/test/tests/wrapper.js
@@ -0,0 +1 @@
+export * from './default1.js'; \ No newline at end of file
diff --git a/test/tests/zero@0.js b/test/tests/zero@0.js
new file mode 100644
index 000000000..0050f500b
--- /dev/null
+++ b/test/tests/zero@0.js
@@ -0,0 +1 @@
+module.exports = '0'; \ No newline at end of file