Merge commit '9af485a584e47fd503ed5c62b9f6482574715f1e' as 'thirdparty/systemjs'
This commit is contained in:
commit
de4628b3a7
1
thirdparty/systemjs/.agignore
vendored
Normal file
1
thirdparty/systemjs/.agignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
dist/*
|
3
thirdparty/systemjs/.gitignore
vendored
Normal file
3
thirdparty/systemjs/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
node_modules
|
||||||
|
bower_components
|
||||||
|
.DS_Store
|
14
thirdparty/systemjs/.travis.yml
vendored
Normal file
14
thirdparty/systemjs/.travis.yml
vendored
Normal file
@ -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
|
10
thirdparty/systemjs/LICENSE
vendored
Normal file
10
thirdparty/systemjs/LICENSE
vendored
Normal file
@ -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.
|
186
thirdparty/systemjs/Makefile
vendored
Executable file
186
thirdparty/systemjs/Makefile
vendored
Executable file
@ -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 "})();" \
|
||||||
|
) > $@;
|
149
thirdparty/systemjs/README.md
vendored
Normal file
149
thirdparty/systemjs/README.md
vendored
Normal file
@ -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
|
949
thirdparty/systemjs/bench/cjs-sample/cjs.js
vendored
Normal file
949
thirdparty/systemjs/bench/cjs-sample/cjs.js
vendored
Normal file
@ -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;
|
1474
thirdparty/systemjs/bench/config-example/config.js
vendored
Normal file
1474
thirdparty/systemjs/bench/config-example/config.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
69
thirdparty/systemjs/bench/config-example/normalize-data.js
vendored
Normal file
69
thirdparty/systemjs/bench/config-example/normalize-data.js
vendored
Normal file
@ -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"]]
|
||||||
|
];
|
972
thirdparty/systemjs/bench/config-example/pkg-configs.js
vendored
Normal file
972
thirdparty/systemjs/bench/config-example/pkg-configs.js
vendored
Normal file
@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
63
thirdparty/systemjs/bench/get-cjs-deps.js
vendored
Normal file
63
thirdparty/systemjs/bench/get-cjs-deps.js
vendored
Normal file
@ -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);
|
||||||
|
|
67
thirdparty/systemjs/bench/normalize-perf.js
vendored
Normal file
67
thirdparty/systemjs/bench/normalize-perf.js
vendored
Normal file
@ -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);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
17
thirdparty/systemjs/bower.json
vendored
Normal file
17
thirdparty/systemjs/bower.json
vendored
Normal file
@ -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"
|
||||||
|
}
|
||||||
|
}
|
6
thirdparty/systemjs/dist/system-csp-production.js
vendored
Normal file
6
thirdparty/systemjs/dist/system-csp-production.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
thirdparty/systemjs/dist/system-csp-production.js.map
vendored
Normal file
1
thirdparty/systemjs/dist/system-csp-production.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
4536
thirdparty/systemjs/dist/system-csp-production.src.js
vendored
Normal file
4536
thirdparty/systemjs/dist/system-csp-production.src.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
5
thirdparty/systemjs/dist/system-polyfills.js
vendored
Normal file
5
thirdparty/systemjs/dist/system-polyfills.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
thirdparty/systemjs/dist/system-polyfills.js.map
vendored
Normal file
1
thirdparty/systemjs/dist/system-polyfills.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
1277
thirdparty/systemjs/dist/system-polyfills.src.js
vendored
Normal file
1277
thirdparty/systemjs/dist/system-polyfills.src.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
5
thirdparty/systemjs/dist/system-register-only.js
vendored
Normal file
5
thirdparty/systemjs/dist/system-register-only.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
thirdparty/systemjs/dist/system-register-only.js.map
vendored
Normal file
1
thirdparty/systemjs/dist/system-register-only.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
2198
thirdparty/systemjs/dist/system-register-only.src.js
vendored
Normal file
2198
thirdparty/systemjs/dist/system-register-only.src.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
6
thirdparty/systemjs/dist/system.js
vendored
Normal file
6
thirdparty/systemjs/dist/system.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
thirdparty/systemjs/dist/system.js.map
vendored
Normal file
1
thirdparty/systemjs/dist/system.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
5153
thirdparty/systemjs/dist/system.src.js
vendored
Normal file
5153
thirdparty/systemjs/dist/system.src.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
292
thirdparty/systemjs/docs/config-api.md
vendored
Normal file
292
thirdparty/systemjs/docs/config-api.md
vendored
Normal file
@ -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).
|
84
thirdparty/systemjs/docs/creating-plugins.md
vendored
Normal file
84
thirdparty/systemjs/docs/creating-plugins.md
vendored
Normal file
@ -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.
|
108
thirdparty/systemjs/docs/es6-modules-overview.md
vendored
Normal file
108
thirdparty/systemjs/docs/es6-modules-overview.md
vendored
Normal file
@ -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`.
|
228
thirdparty/systemjs/docs/module-formats.md
vendored
Normal file
228
thirdparty/systemjs/docs/module-formats.md
vendored
Normal file
@ -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'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
166
thirdparty/systemjs/docs/overview.md
vendored
Normal file
166
thirdparty/systemjs/docs/overview.md
vendored
Normal file
@ -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.
|
83
thirdparty/systemjs/docs/production-workflows.md
vendored
Normal file
83
thirdparty/systemjs/docs/production-workflows.md
vendored
Normal file
@ -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.
|
141
thirdparty/systemjs/docs/system-api.md
vendored
Normal file
141
thirdparty/systemjs/docs/system-api.md
vendored
Normal file
@ -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`.
|
48
thirdparty/systemjs/index.js
vendored
Normal file
48
thirdparty/systemjs/index.js
vendored
Normal file
@ -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;
|
38
thirdparty/systemjs/lib/alias.js
vendored
Normal file
38
thirdparty/systemjs/lib/alias.js
vendored
Normal file
@ -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);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
})();
|
245
thirdparty/systemjs/lib/amd-helpers.js
vendored
Normal file
245
thirdparty/systemjs/lib/amd-helpers.js
vendored
Normal file
@ -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;
|
||||||
|
};
|
||||||
|
});
|
42
thirdparty/systemjs/lib/amd.js
vendored
Normal file
42
thirdparty/systemjs/lib/amd.js
vendored
Normal file
@ -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);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
})();
|
73
thirdparty/systemjs/lib/bundles.js
vendored
Normal file
73
thirdparty/systemjs/lib/bundles.js
vendored
Normal file
@ -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);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
})();
|
43
thirdparty/systemjs/lib/cjs-helpers.js
vendored
Normal file
43
thirdparty/systemjs/lib/cjs-helpers.js
vendored
Normal file
@ -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)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
};
|
||||||
|
});
|
138
thirdparty/systemjs/lib/cjs.js
vendored
Normal file
138
thirdparty/systemjs/lib/cjs.js
vendored
Normal file
@ -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);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
})();
|
161
thirdparty/systemjs/lib/conditionals.js
vendored
Normal file
161
thirdparty/systemjs/lib/conditionals.js
vendored
Normal file
@ -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);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
});
|
504
thirdparty/systemjs/lib/core.js
vendored
Normal file
504
thirdparty/systemjs/lib/core.js
vendored
Normal file
@ -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);
|
||||||
|
});
|
||||||
|
};
|
3
thirdparty/systemjs/lib/createSystem.js
vendored
Normal file
3
thirdparty/systemjs/lib/createSystem.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
System = new SystemJSLoader();
|
||||||
|
|
||||||
|
__global.SystemJS = System;
|
44
thirdparty/systemjs/lib/depCache.js
vendored
Normal file
44
thirdparty/systemjs/lib/depCache.js
vendored
Normal file
@ -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);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
|
161
thirdparty/systemjs/lib/esm.js
vendored
Normal file
161
thirdparty/systemjs/lib/esm.js
vendored
Normal file
@ -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;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
})();
|
142
thirdparty/systemjs/lib/global-eval.js
vendored
Normal file
142
thirdparty/systemjs/lib/global-eval.js
vendored
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
})();
|
147
thirdparty/systemjs/lib/global-helpers.js
vendored
Normal file
147
thirdparty/systemjs/lib/global-helpers.js
vendored
Normal file
@ -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;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
});
|
70
thirdparty/systemjs/lib/global.js
vendored
Normal file
70
thirdparty/systemjs/lib/global.js
vendored
Normal file
@ -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);
|
||||||
|
};
|
||||||
|
});
|
86
thirdparty/systemjs/lib/legacy-transpiler.js
vendored
Normal file
86
thirdparty/systemjs/lib/legacy-transpiler.js
vendored
Normal file
@ -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;
|
||||||
|
})();
|
6
thirdparty/systemjs/lib/loader-wrapper-end.js
vendored
Normal file
6
thirdparty/systemjs/lib/loader-wrapper-end.js
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
if (typeof module == 'object' && module.exports && typeof exports == 'object')
|
||||||
|
module.exports = System;
|
||||||
|
|
||||||
|
__global.System = System;
|
||||||
|
|
||||||
|
})(typeof self != 'undefined' ? self : global);
|
913
thirdparty/systemjs/lib/loader-wrapper-start.js
vendored
Normal file
913
thirdparty/systemjs/lib/loader-wrapper-start.js
vendored
Normal file
@ -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;
|
||||||
|
|
155
thirdparty/systemjs/lib/meta.js
vendored
Normal file
155
thirdparty/systemjs/lib/meta.js
vendored
Normal file
@ -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);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
})();
|
596
thirdparty/systemjs/lib/package.js
vendored
Normal file
596
thirdparty/systemjs/lib/package.js
vendored
Normal file
@ -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;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
})();
|
42
thirdparty/systemjs/lib/paths.js
vendored
Normal file
42
thirdparty/systemjs/lib/paths.js
vendored
Normal file
@ -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;
|
||||||
|
}
|
227
thirdparty/systemjs/lib/perf.js
vendored
Normal file
227
thirdparty/systemjs/lib/perf.js
vendored
Normal file
@ -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 + ')' : ''));
|
||||||
|
}
|
||||||
|
})();
|
263
thirdparty/systemjs/lib/plugins.js
vendored
Normal file
263
thirdparty/systemjs/lib/plugins.js
vendored
Normal file
@ -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);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
})();
|
2
thirdparty/systemjs/lib/polyfills-bootstrap.js
vendored
Normal file
2
thirdparty/systemjs/lib/polyfills-bootstrap.js
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
if (typeof systemJSBootstrap !== 'undefined')
|
||||||
|
systemJSBootstrap();
|
268
thirdparty/systemjs/lib/proto.js
vendored
Normal file
268
thirdparty/systemjs/lib/proto.js
vendored
Normal file
@ -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);
|
||||||
|
}
|
633
thirdparty/systemjs/lib/register.js
vendored
Normal file
633
thirdparty/systemjs/lib/register.js
vendored
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
});
|
||||||
|
})();
|
196
thirdparty/systemjs/lib/scriptLoader.js
vendored
Normal file
196
thirdparty/systemjs/lib/scriptLoader.js
vendored
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
});
|
||||||
|
})();
|
17
thirdparty/systemjs/lib/scriptOnly.js
vendored
Normal file
17
thirdparty/systemjs/lib/scriptOnly.js
vendored
Normal file
@ -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);
|
||||||
|
};
|
||||||
|
});
|
125
thirdparty/systemjs/lib/system-fetch.js
vendored
Normal file
125
thirdparty/systemjs/lib/system-fetch.js
vendored
Normal file
@ -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.');
|
||||||
|
}
|
24
thirdparty/systemjs/lib/system-only-resolve.js
vendored
Normal file
24
thirdparty/systemjs/lib/system-only-resolve.js
vendored
Normal file
@ -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;
|
||||||
|
};
|
||||||
|
*/
|
64
thirdparty/systemjs/lib/url-polyfill.js
vendored
Normal file
64
thirdparty/systemjs/lib/url-polyfill.js
vendored
Normal file
@ -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);
|
47
thirdparty/systemjs/lib/wrapper-end.js
vendored
Normal file
47
thirdparty/systemjs/lib/wrapper-end.js
vendored
Normal file
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
})();
|
2
thirdparty/systemjs/lib/wrapper-start.js
vendored
Normal file
2
thirdparty/systemjs/lib/wrapper-start.js
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
(function() {
|
||||||
|
function bootstrap() {
|
34
thirdparty/systemjs/package.json
vendored
Normal file
34
thirdparty/systemjs/package.json
vendored
Normal file
@ -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"
|
||||||
|
}
|
||||||
|
}
|
44
thirdparty/systemjs/test/test-babel-runtime.html
vendored
Normal file
44
thirdparty/systemjs/test/test-babel-runtime.html
vendored
Normal file
@ -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>
|
29
thirdparty/systemjs/test/test-babel.html
vendored
Normal file
29
thirdparty/systemjs/test/test-babel.html
vendored
Normal file
@ -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>
|
3
thirdparty/systemjs/test/test-babel.js
vendored
Normal file
3
thirdparty/systemjs/test/test-babel.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
System.transpiler = 'babel';
|
||||||
|
System.baseURL = 'test/';
|
||||||
|
require('./test');
|
61
thirdparty/systemjs/test/test-csp-inline.html
vendored
Normal file
61
thirdparty/systemjs/test/test-csp-inline.html
vendored
Normal file
@ -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>
|
280
thirdparty/systemjs/test/test-csp.html
vendored
Normal file
280
thirdparty/systemjs/test/test-csp.html
vendored
Normal file
@ -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>
|
112
thirdparty/systemjs/test/test-jsextensions.html
vendored
Normal file
112
thirdparty/systemjs/test/test-jsextensions.html
vendored
Normal file
@ -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>
|
45
thirdparty/systemjs/test/test-register-only.html
vendored
Normal file
45
thirdparty/systemjs/test/test-register-only.html
vendored
Normal file
@ -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>
|
71
thirdparty/systemjs/test/test-tracer.html
vendored
Normal file
71
thirdparty/systemjs/test/test-tracer.html
vendored
Normal file
@ -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>
|
34
thirdparty/systemjs/test/test-traceur.html
vendored
Normal file
34
thirdparty/systemjs/test/test-traceur.html
vendored
Normal file
@ -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>
|
3
thirdparty/systemjs/test/test-traceur.js
vendored
Normal file
3
thirdparty/systemjs/test/test-traceur.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
System.transpiler = 'traceur';
|
||||||
|
System.baseURL = 'test/';
|
||||||
|
require('./test');
|
31
thirdparty/systemjs/test/test-typescript.html
vendored
Normal file
31
thirdparty/systemjs/test/test-typescript.html
vendored
Normal file
@ -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>
|
4
thirdparty/systemjs/test/test-typescript.js
vendored
Normal file
4
thirdparty/systemjs/test/test-typescript.js
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
global.ts = require('typescript');
|
||||||
|
System.transpiler = 'typescript';
|
||||||
|
System.baseURL = 'test/';
|
||||||
|
require('./test');
|
1462
thirdparty/systemjs/test/test.js
vendored
Normal file
1462
thirdparty/systemjs/test/test.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
thirdparty/systemjs/test/tests/#.js
vendored
Normal file
1
thirdparty/systemjs/test/tests/#.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
module.exports = '#';
|
20
thirdparty/systemjs/test/tests/advanced-plugin.js
vendored
Normal file
20
thirdparty/systemjs/test/tests/advanced-plugin.js
vendored
Normal file
@ -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 + '";';
|
||||||
|
}
|
9
thirdparty/systemjs/test/tests/all-circular1.js
vendored
Normal file
9
thirdparty/systemjs/test/tests/all-circular1.js
vendored
Normal file
@ -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 };
|
3
thirdparty/systemjs/test/tests/all-circular2.js
vendored
Normal file
3
thirdparty/systemjs/test/tests/all-circular2.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
import { p } from './all-circular1.js';
|
||||||
|
export var a = 4;
|
||||||
|
p();
|
10
thirdparty/systemjs/test/tests/all-circular3.js
vendored
Normal file
10
thirdparty/systemjs/test/tests/all-circular3.js
vendored
Normal file
@ -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();
|
||||||
|
});
|
5
thirdparty/systemjs/test/tests/all-circular4.js
vendored
Normal file
5
thirdparty/systemjs/test/tests/all-circular4.js
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
exports.obj = { circular: 'mess' };
|
||||||
|
var setter = require('./all-circular3.js');
|
||||||
|
exports.set = function() {
|
||||||
|
setter.setObj();
|
||||||
|
}
|
3
thirdparty/systemjs/test/tests/all-layers1.js
vendored
Normal file
3
thirdparty/systemjs/test/tests/all-layers1.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
define(['./all-layers2.js'], function(al2) {
|
||||||
|
return al2.q == 10 && al2.r == 5;
|
||||||
|
});
|
20
thirdparty/systemjs/test/tests/all-layers2.js
vendored
Normal file
20
thirdparty/systemjs/test/tests/all-layers2.js
vendored
Normal file
@ -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();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
17
thirdparty/systemjs/test/tests/all-layers3.js
vendored
Normal file
17
thirdparty/systemjs/test/tests/all-layers3.js
vendored
Normal file
@ -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();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
1
thirdparty/systemjs/test/tests/all-layers4.js
vendored
Normal file
1
thirdparty/systemjs/test/tests/all-layers4.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
export var c = 10;
|
6
thirdparty/systemjs/test/tests/amd-bundle.js
vendored
Normal file
6
thirdparty/systemjs/test/tests/amd-bundle.js
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
define('bundle-1', function() {
|
||||||
|
return { defined: true };
|
||||||
|
});
|
||||||
|
define('bundle-2', function() {
|
||||||
|
return { defined: true };
|
||||||
|
});
|
7
thirdparty/systemjs/test/tests/amd-circular1.js
vendored
Normal file
7
thirdparty/systemjs/test/tests/amd-circular1.js
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
define(function(require, exports) {
|
||||||
|
var depFunc = require('./amd-circular2.js').fn;
|
||||||
|
exports.val = 5;
|
||||||
|
exports.outFunc = function() {
|
||||||
|
return depFunc();
|
||||||
|
}
|
||||||
|
});
|
6
thirdparty/systemjs/test/tests/amd-circular2.js
vendored
Normal file
6
thirdparty/systemjs/test/tests/amd-circular2.js
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
define(function(require, exports) {
|
||||||
|
var circular1 = require('./amd-circular1.js');
|
||||||
|
exports.fn = function() {
|
||||||
|
return circular1.val;
|
||||||
|
}
|
||||||
|
});
|
4
thirdparty/systemjs/test/tests/amd-cjs-module.js
vendored
Normal file
4
thirdparty/systemjs/test/tests/amd-cjs-module.js
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
define(function(require, exports) {
|
||||||
|
var p = require('./amd-dep.js');
|
||||||
|
exports.test = 'hi';
|
||||||
|
});
|
6
thirdparty/systemjs/test/tests/amd-contextual.js
vendored
Normal file
6
thirdparty/systemjs/test/tests/amd-contextual.js
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
define(['require', 'module'], function(require, module) {
|
||||||
|
return {
|
||||||
|
name: module.uri,
|
||||||
|
rel: require.toUrl('../rel-path.js')
|
||||||
|
};
|
||||||
|
});
|
1
thirdparty/systemjs/test/tests/amd-dep-A.js
vendored
Normal file
1
thirdparty/systemjs/test/tests/amd-dep-A.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
A = 10;
|
1
thirdparty/systemjs/test/tests/amd-dep-B.js
vendored
Normal file
1
thirdparty/systemjs/test/tests/amd-dep-B.js
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
B = 5;
|
3
thirdparty/systemjs/test/tests/amd-dep.js
vendored
Normal file
3
thirdparty/systemjs/test/tests/amd-dep.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
define({
|
||||||
|
amd: 'dep'
|
||||||
|
});
|
19
thirdparty/systemjs/test/tests/amd-dynamic-require.js
vendored
Normal file
19
thirdparty/systemjs/test/tests/amd-dynamic-require.js
vendored
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
3
thirdparty/systemjs/test/tests/amd-dynamic.js
vendored
Normal file
3
thirdparty/systemjs/test/tests/amd-dynamic.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
define(function() {
|
||||||
|
return 'dynamic';
|
||||||
|
});
|
7
thirdparty/systemjs/test/tests/amd-extra-deps.js
vendored
Normal file
7
thirdparty/systemjs/test/tests/amd-extra-deps.js
vendored
Normal file
@ -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];
|
||||||
|
});
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user