From 19a6c4b527d8806a4eecffea27a3421ee6ea8c6a Mon Sep 17 00:00:00 2001 From: Tim Lancina Date: Tue, 2 Jun 2015 17:35:57 -0500 Subject: [PATCH] wip it good --- config.js | 214 ++ gulpfile.js | 112 +- package.json | 15 +- scripts/component/Reflect.js | 964 ++++++ scripts/component/babel-external-helpers.js | 401 +++ scripts/component/es6-module-loader.js | 8 + scripts/component/system.src.js | 2406 +++++++++++++ scripts/component/traceur-runtime.js | 3424 +++++++++++++++++++ scripts/component/zone-microtask.js | 1937 +++++++++++ scripts/e2e/ionic.template.html | 18 +- 10 files changed, 9428 insertions(+), 71 deletions(-) create mode 100644 config.js create mode 100644 scripts/component/Reflect.js create mode 100644 scripts/component/babel-external-helpers.js create mode 100644 scripts/component/es6-module-loader.js create mode 100644 scripts/component/system.src.js create mode 100644 scripts/component/traceur-runtime.js create mode 100644 scripts/component/zone-microtask.js diff --git a/config.js b/config.js new file mode 100644 index 0000000000..b2669e0f2c --- /dev/null +++ b/config.js @@ -0,0 +1,214 @@ +System.config({ + "baseURL": "/", + "transpiler": "babel", + "babelOptions": { + "optional": [ + "runtime" + ] + }, + "paths": { + "ionic/*": "dist/ionic/*.js", + "github:*": "jspm_packages/github/*.js", + "npm:*": "jspm_packages/npm/*.js", + "*": "*.js" + } +}); + +System.config({ + "map": { + "angular2": "npm:angular2@2.0.0-alpha.25", + "babel": "npm:babel-core@5.4.7", + "babel-runtime": "npm:babel-runtime@5.4.7", + "core-js": "npm:core-js@0.9.13", + "github:jspm/nodelibs-assert@0.1.0": { + "assert": "npm:assert@1.3.0" + }, + "github:jspm/nodelibs-buffer@0.1.0": { + "buffer": "npm:buffer@3.2.2" + }, + "github:jspm/nodelibs-events@0.1.1": { + "events": "npm:events@1.0.2" + }, + "github:jspm/nodelibs-http@1.7.1": { + "Base64": "npm:Base64@0.2.1", + "events": "github:jspm/nodelibs-events@0.1.1", + "inherits": "npm:inherits@2.0.1", + "stream": "github:jspm/nodelibs-stream@0.1.0", + "url": "github:jspm/nodelibs-url@0.1.0", + "util": "github:jspm/nodelibs-util@0.1.0" + }, + "github:jspm/nodelibs-path@0.1.0": { + "path-browserify": "npm:path-browserify@0.0.0" + }, + "github:jspm/nodelibs-process@0.1.1": { + "process": "npm:process@0.10.1" + }, + "github:jspm/nodelibs-querystring@0.1.0": { + "querystring": "npm:querystring@0.2.0" + }, + "github:jspm/nodelibs-stream@0.1.0": { + "stream-browserify": "npm:stream-browserify@1.0.0" + }, + "github:jspm/nodelibs-url@0.1.0": { + "url": "npm:url@0.10.3" + }, + "github:jspm/nodelibs-util@0.1.0": { + "util": "npm:util@0.10.3" + }, + "npm:amdefine@0.1.0": { + "fs": "github:jspm/nodelibs-fs@0.1.2", + "module": "github:jspm/nodelibs-module@0.1.0", + "path": "github:jspm/nodelibs-path@0.1.0", + "process": "github:jspm/nodelibs-process@0.1.1" + }, + "npm:angular2@2.0.0-alpha.25": { + "fs": "github:jspm/nodelibs-fs@0.1.2", + "path": "github:jspm/nodelibs-path@0.1.0", + "process": "github:jspm/nodelibs-process@0.1.1", + "rtts_assert": "npm:rtts_assert@2.0.0-alpha.25", + "rx": "npm:rx@2.5.1", + "traceur": "npm:traceur@0.0.87", + "url": "github:jspm/nodelibs-url@0.1.0", + "zone.js": "npm:zone.js@0.5.0" + }, + "npm:assert@1.3.0": { + "util": "npm:util@0.10.3" + }, + "npm:brace-expansion@1.1.0": { + "balanced-match": "npm:balanced-match@0.2.0", + "concat-map": "npm:concat-map@0.0.1" + }, + "npm:buffer@3.2.2": { + "base64-js": "npm:base64-js@0.0.8", + "ieee754": "npm:ieee754@1.1.5", + "is-array": "npm:is-array@1.0.1" + }, + "npm:commander@2.6.0": { + "child_process": "github:jspm/nodelibs-child_process@0.1.0", + "events": "github:jspm/nodelibs-events@0.1.1", + "path": "github:jspm/nodelibs-path@0.1.0", + "process": "github:jspm/nodelibs-process@0.1.1" + }, + "npm:core-js@0.9.13": { + "fs": "github:jspm/nodelibs-fs@0.1.2", + "process": "github:jspm/nodelibs-process@0.1.1", + "systemjs-json": "github:systemjs/plugin-json@0.1.0" + }, + "npm:core-util-is@1.0.1": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0" + }, + "npm:glob@4.3.5": { + "assert": "github:jspm/nodelibs-assert@0.1.0", + "events": "github:jspm/nodelibs-events@0.1.1", + "fs": "github:jspm/nodelibs-fs@0.1.2", + "inflight": "npm:inflight@1.0.4", + "inherits": "npm:inherits@2.0.1", + "minimatch": "npm:minimatch@2.0.8", + "once": "npm:once@1.3.2", + "path": "github:jspm/nodelibs-path@0.1.0", + "process": "github:jspm/nodelibs-process@0.1.1", + "util": "github:jspm/nodelibs-util@0.1.0" + }, + "npm:inflight@1.0.4": { + "once": "npm:once@1.3.2", + "process": "github:jspm/nodelibs-process@0.1.1", + "wrappy": "npm:wrappy@1.0.1" + }, + "npm:inherits@2.0.1": { + "util": "github:jspm/nodelibs-util@0.1.0" + }, + "npm:minimatch@2.0.8": { + "brace-expansion": "npm:brace-expansion@1.1.0", + "path": "github:jspm/nodelibs-path@0.1.0" + }, + "npm:once@1.3.2": { + "wrappy": "npm:wrappy@1.0.1" + }, + "npm:path-browserify@0.0.0": { + "process": "github:jspm/nodelibs-process@0.1.1" + }, + "npm:punycode@1.3.2": { + "process": "github:jspm/nodelibs-process@0.1.1" + }, + "npm:readable-stream@1.1.13": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "core-util-is": "npm:core-util-is@1.0.1", + "events": "github:jspm/nodelibs-events@0.1.1", + "inherits": "npm:inherits@2.0.1", + "isarray": "npm:isarray@0.0.1", + "process": "github:jspm/nodelibs-process@0.1.1", + "stream": "github:jspm/nodelibs-stream@0.1.0", + "stream-browserify": "npm:stream-browserify@1.0.0", + "string_decoder": "npm:string_decoder@0.10.31", + "util": "github:jspm/nodelibs-util@0.1.0" + }, + "npm:rsvp@3.0.18": { + "assert": "github:jspm/nodelibs-assert@0.1.0", + "process": "github:jspm/nodelibs-process@0.1.1", + "util": "github:jspm/nodelibs-util@0.1.0" + }, + "npm:rtts_assert@2.0.0-alpha.25": { + "fs": "github:jspm/nodelibs-fs@0.1.2", + "path": "github:jspm/nodelibs-path@0.1.0" + }, + "npm:rx@2.5.1": { + "process": "github:jspm/nodelibs-process@0.1.1" + }, + "npm:semver@2.3.2": { + "process": "github:jspm/nodelibs-process@0.1.1" + }, + "npm:source-map-support@0.2.10": { + "assert": "github:jspm/nodelibs-assert@0.1.0", + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "child_process": "github:jspm/nodelibs-child_process@0.1.0", + "fs": "github:jspm/nodelibs-fs@0.1.2", + "http": "github:jspm/nodelibs-http@1.7.1", + "path": "github:jspm/nodelibs-path@0.1.0", + "process": "github:jspm/nodelibs-process@0.1.1", + "querystring": "github:jspm/nodelibs-querystring@0.1.0", + "source-map": "npm:source-map@0.1.32" + }, + "npm:source-map@0.1.32": { + "amdefine": "npm:amdefine@0.1.0", + "fs": "github:jspm/nodelibs-fs@0.1.2", + "path": "github:jspm/nodelibs-path@0.1.0", + "process": "github:jspm/nodelibs-process@0.1.1" + }, + "npm:stream-browserify@1.0.0": { + "events": "github:jspm/nodelibs-events@0.1.1", + "inherits": "npm:inherits@2.0.1", + "readable-stream": "npm:readable-stream@1.1.13" + }, + "npm:string_decoder@0.10.31": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0" + }, + "npm:traceur@0.0.87": { + "buffer": "github:jspm/nodelibs-buffer@0.1.0", + "commander": "npm:commander@2.6.0", + "fs": "github:jspm/nodelibs-fs@0.1.2", + "glob": "npm:glob@4.3.5", + "module": "github:jspm/nodelibs-module@0.1.0", + "path": "github:jspm/nodelibs-path@0.1.0", + "process": "github:jspm/nodelibs-process@0.1.1", + "rsvp": "npm:rsvp@3.0.18", + "semver": "npm:semver@2.3.2", + "source-map-support": "npm:source-map-support@0.2.10", + "systemjs-json": "github:systemjs/plugin-json@0.1.0", + "util": "github:jspm/nodelibs-util@0.1.0" + }, + "npm:url@0.10.3": { + "assert": "github:jspm/nodelibs-assert@0.1.0", + "punycode": "npm:punycode@1.3.2", + "querystring": "npm:querystring@0.2.0", + "util": "github:jspm/nodelibs-util@0.1.0" + }, + "npm:util@0.10.3": { + "inherits": "npm:inherits@2.0.1", + "process": "github:jspm/nodelibs-process@0.1.1" + }, + "npm:zone.js@0.5.0": { + "process": "github:jspm/nodelibs-process@0.1.1" + } + } +}); + diff --git a/gulpfile.js b/gulpfile.js index c1f069b683..7f8b9add95 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -18,6 +18,7 @@ var runSequence = require('run-sequence'); var watch = require('gulp-watch'); var exec = require('child_process').exec; var babel = require('gulp-babel'); +var traceur = require('gulp-traceur'); var webpack = require('gulp-webpack'); var lazypipe = require('lazypipe'); @@ -82,86 +83,83 @@ gulp.task('clean', function(done) { del(['../angular-ionic/modules/ionic, ./angular-ionic/modules/examples/src/ionic, dist/'], done); }); -gulp.task('ionic.transpile.js', function(done) { - return gulp.src(['ionic/**/*.js', '!ionic/components/*/test/**/*']) - .pipe(babel(babelOptions)) - //.pipe(concat('ionic.bundle.js')) - .pipe(gulp.dest('dist/js/')); -}); - //gulp.task('ionic.copy.js', function(done) { // return gulp.src(['ionic/**/*.js', '!ionic/components/*/test/**/*']) // .pipe(gulp.dest('../angular-ionic/modules/ionic')); //}); +// + var traceurOptions = { + annotations: true, + types: true, + outputLanguage: 'es6' + } + var babelOptions = { optional: ['es7.decorators'], - plugins: [ + /*plugins: [ './transformers/disable-define', 'angular2-annotations', 'type-assertion:after' - ] + ],*/ + modules: "system" }; - var webpackOptions = { - module: { - loaders: [ - { - test: /\.es6$/, - loader: "babel-loader?" + JSON.stringify(babelOptions) - }, - { - test: /\.js$/, - exclude: /node_modules/, - loader: "babel-loader?" + JSON.stringify(babelOptions) - } - ] - }, - resolve: { - alias: { - 'angular2': 'angular2/es6/dev', - 'rtts_assert': 'rtts_assert/es6' - }, - modulesDirectories: [ - 'ionic2', - 'node_modules' - ], - extensions: ['', '.js', '.es6'] - }, - debug: true - } - +gulp.task('ionic.traceur.es6', function(done) { + return gulp.src(['ionic/**/*.js', '!ionic/components/*/test/**/*']) + .pipe(traceur(traceurOptions)) + //.pipe(concat('ionic.bundle.js')) + .pipe(gulp.dest('dist/ionic')); +}); gulp.task('ionic.examples', function() { var buildTest = lazypipe() - //.pipe(babel, babelOptions) - .pipe(webpack, webpackOptions) - .pipe(createIndexHTML); + .pipe(traceur, traceurOptions) + .pipe(babel, babelOptions) // Get each test folder with gulp.src return gulp.src('ionic/components/*/test/*/**/*') - .pipe(gulpif(/index.js$/, buildTest())) + .pipe(gulpif(/.js$/, buildTest())) + .pipe(gulpif(/index.js$/, createTest())) .pipe(rename(function(file) { file.dirname = file.dirname.replace(path.sep + 'test' + path.sep, path.sep) })) .pipe(gulp.dest('dist/examples/')) - function createIndexHTML() { - var indexContents = _.template( - fs.readFileSync('scripts/e2e/ionic.template.html') - )({ - buildConfig: buildConfig - }); + function createTest() { + var indexContents = _.template( + fs.readFileSync('scripts/e2e/ionic.template.html') + )({ + buildConfig: buildConfig + }); - return through2.obj(function(file, enc, next) { - var self = this; - self.push(new VinylFile({ - base: file.base, - contents: new Buffer(indexContents), - path: path.join(path.dirname(file.path), 'index.html'), - })); - next(null, file); - }) - } + return through2.obj(function(file, enc, next) { + // debugger; + //var Builder = require('systemjs-builder'); + //var builder = new Builder(); + //builder.loadConfig('config.js').then(function(){ + //builder.config(systemjsConfig); + // builder.build('index'/*, path.join(path.dirname(file.path), 'index.js')*/).then(function(){ + var self = this; + self.push(new VinylFile({ + base: file.base, + contents: new Buffer(indexContents), + path: path.join(path.dirname(file.path), 'index.html'), + })); + next(null, file); + //}); + //}) + }); + } +}); + + +gulp.task('build.system.js', function() { + var Builder = require('systemjs-builder'); + var builder = new Builder(); + builder.loadConfig('config.js').then(function(){ + //builder.config(systemjsConfig); + return builder.build('index', 'index.js'); + }) }); diff --git a/package.json b/package.json index 7188ab8aa2..5f595ddb2c 100644 --- a/package.json +++ b/package.json @@ -53,10 +53,15 @@ "traceur": "0.0.87", "zone.js": "0.4.1" }, - "registry": "jspm", - "directories": { - "baseURL": "n", - "lib": "n", - "packages": "n/jspm_packages" + "jspm": { + "directories": {}, + "dependencies": { + "angular2": "npm:angular2@^2.0.0-alpha.25" + }, + "devDependencies": { + "babel": "npm:babel-core@^5.1.13", + "babel-runtime": "npm:babel-runtime@^5.1.13", + "core-js": "npm:core-js@^0.9.4" + } } } diff --git a/scripts/component/Reflect.js b/scripts/component/Reflect.js new file mode 100644 index 0000000000..2d1a57a4e5 --- /dev/null +++ b/scripts/component/Reflect.js @@ -0,0 +1,964 @@ +/*! ***************************************************************************** +Copyright (C) Microsoft. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + +See the License for the specific language governing permissions and +limitations under the License. +***************************************************************************** */ +"use strict"; +var Reflect; +(function (Reflect) { + // Load global or shim versions of Map, Set, and WeakMap + var functionPrototype = Object.getPrototypeOf(Function); + var _Map = typeof Map === "function" ? Map : CreateMapPolyfill(); + var _Set = typeof Set === "function" ? Set : CreateSetPolyfill(); + var _WeakMap = typeof WeakMap === "function" ? WeakMap : CreateWeakMapPolyfill(); + // [[Metadata]] internal slot + var __Metadata__ = new _WeakMap(); + /** + * Applies a set of decorators to a property of a target object. + * @param decorators An array of decorators. + * @param target The target object. + * @param targetKey (Optional) The property key to decorate. + * @param targetDescriptor (Optional) The property descriptor for the target key + * @remarks Decorators are applied in reverse order. + * @example + * + * class C { + * // property declarations are not part of ES6, though they are valid in TypeScript: + * // static staticProperty; + * // property; + * + * constructor(p) { } + * static staticMethod(p) { } + * method(p) { } + * } + * + * // constructor + * C = Reflect.decorate(decoratorsArray, C); + * + * // property (on constructor) + * Reflect.decorate(decoratorsArray, C, "staticProperty"); + * + * // property (on prototype) + * Reflect.decorate(decoratorsArray, C.prototype, "property"); + * + * // method (on constructor) + * Object.defineProperty(C, "staticMethod", + * Reflect.decorate(decoratorsArray, C, "staticMethod", + * Object.getOwnPropertyDescriptor(C, "staticMethod"))); + * + * // method (on prototype) + * Object.defineProperty(C.prototype, "method", + * Reflect.decorate(decoratorsArray, C.prototype, "method", + * Object.getOwnPropertyDescriptor(C.prototype, "method"))); + * + */ + function decorate(decorators, target, targetKey, targetDescriptor) { + if (!IsUndefined(targetDescriptor)) { + if (!IsArray(decorators)) { + throw new TypeError(); + } + else if (!IsObject(target)) { + throw new TypeError(); + } + else if (IsUndefined(targetKey)) { + throw new TypeError(); + } + else if (!IsObject(targetDescriptor)) { + throw new TypeError(); + } + targetKey = ToPropertyKey(targetKey); + return DecoratePropertyWithDescriptor(decorators, target, targetKey, targetDescriptor); + } + else if (!IsUndefined(targetKey)) { + if (!IsArray(decorators)) { + throw new TypeError(); + } + else if (!IsObject(target)) { + throw new TypeError(); + } + targetKey = ToPropertyKey(targetKey); + return DecoratePropertyWithoutDescriptor(decorators, target, targetKey); + } + else { + if (!IsArray(decorators)) { + throw new TypeError(); + } + else if (!IsConstructor(target)) { + throw new TypeError(); + } + return DecorateConstructor(decorators, target); + } + } + Reflect.decorate = decorate; + /** + * A default metadata decorator factory that can be used on a class, class member, or parameter. + * @param metadataKey The key for the metadata entry. + * @param metadataValue The value for the metadata entry. + * @returns A decorator function. + * @remarks + * If `metadataKey` is already defined for the target and target key, the + * metadataValue for that key will be overwritten. + * @example + * + * // constructor + * @Reflect.metadata(key, value) + * class C { + * } + * + * // property (on constructor, TypeScript only) + * class C { + * @Reflect.metadata(key, value) + * static staticProperty; + * } + * + * // property (on prototype, TypeScript only) + * class C { + * @Reflect.metadata(key, value) + * property; + * } + * + * // method (on constructor) + * class C { + * @Reflect.metadata(key, value) + * static staticMethod() { } + * } + * + * // method (on prototype) + * class C { + * @Reflect.metadata(key, value) + * method() { } + * } + * + */ + function metadata(metadataKey, metadataValue) { + function decorator(target, targetKey) { + if (!IsUndefined(targetKey)) { + if (!IsObject(target)) { + throw new TypeError(); + } + targetKey = ToPropertyKey(targetKey); + OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, targetKey); + } + else { + if (!IsConstructor(target)) { + throw new TypeError(); + } + OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, undefined); + } + } + return decorator; + } + Reflect.metadata = metadata; + /** + * Define a unique metadata entry on the target. + * @param metadataKey A key used to store and retrieve metadata. + * @param metadataValue A value that contains attached metadata. + * @param target The target object on which to define metadata. + * @param targetKey (Optional) The property key for the target. + * @example + * + * class C { + * // property declarations are not part of ES6, though they are valid in TypeScript: + * // static staticProperty; + * // property; + * + * constructor(p) { } + * static staticMethod(p) { } + * method(p) { } + * } + * + * // constructor + * Reflect.defineMetadata("custom:annotation", options, C); + * + * // property (on constructor) + * Reflect.defineMetadata("custom:annotation", options, C, "staticProperty"); + * + * // property (on prototype) + * Reflect.defineMetadata("custom:annotation", options, C.prototype, "property"); + * + * // method (on constructor) + * Reflect.defineMetadata("custom:annotation", options, C, "staticMethod"); + * + * // method (on prototype) + * Reflect.defineMetadata("custom:annotation", options, C.prototype, "method"); + * + * // decorator factory as metadata-producing annotation. + * function MyAnnotation(options): Decorator { + * return (target, key?) => Reflect.defineMetadata("custom:annotation", options, target, key); + * } + * + */ + function defineMetadata(metadataKey, metadataValue, target, targetKey) { + if (!IsObject(target)) { + throw new TypeError(); + } + else if (!IsUndefined(targetKey)) { + targetKey = ToPropertyKey(targetKey); + } + return OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, targetKey); + } + Reflect.defineMetadata = defineMetadata; + /** + * Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined. + * @param metadataKey A key used to store and retrieve metadata. + * @param target The target object on which the metadata is defined. + * @param targetKey (Optional) The property key for the target. + * @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`. + * @example + * + * class C { + * // property declarations are not part of ES6, though they are valid in TypeScript: + * // static staticProperty; + * // property; + * + * constructor(p) { } + * static staticMethod(p) { } + * method(p) { } + * } + * + * // constructor + * result = Reflect.hasMetadata("custom:annotation", C); + * + * // property (on constructor) + * result = Reflect.hasMetadata("custom:annotation", C, "staticProperty"); + * + * // property (on prototype) + * result = Reflect.hasMetadata("custom:annotation", C.prototype, "property"); + * + * // method (on constructor) + * result = Reflect.hasMetadata("custom:annotation", C, "staticMethod"); + * + * // method (on prototype) + * result = Reflect.hasMetadata("custom:annotation", C.prototype, "method"); + * + */ + function hasMetadata(metadataKey, target, targetKey) { + if (!IsObject(target)) { + throw new TypeError(); + } + else if (!IsUndefined(targetKey)) { + targetKey = ToPropertyKey(targetKey); + } + return OrdinaryHasMetadata(metadataKey, target, targetKey); + } + Reflect.hasMetadata = hasMetadata; + /** + * Gets a value indicating whether the target object has the provided metadata key defined. + * @param metadataKey A key used to store and retrieve metadata. + * @param target The target object on which the metadata is defined. + * @param targetKey (Optional) The property key for the target. + * @returns `true` if the metadata key was defined on the target object; otherwise, `false`. + * @example + * + * class C { + * // property declarations are not part of ES6, though they are valid in TypeScript: + * // static staticProperty; + * // property; + * + * constructor(p) { } + * static staticMethod(p) { } + * method(p) { } + * } + * + * // constructor + * result = Reflect.hasOwnMetadata("custom:annotation", C); + * + * // property (on constructor) + * result = Reflect.hasOwnMetadata("custom:annotation", C, "staticProperty"); + * + * // property (on prototype) + * result = Reflect.hasOwnMetadata("custom:annotation", C.prototype, "property"); + * + * // method (on constructor) + * result = Reflect.hasOwnMetadata("custom:annotation", C, "staticMethod"); + * + * // method (on prototype) + * result = Reflect.hasOwnMetadata("custom:annotation", C.prototype, "method"); + * + */ + function hasOwnMetadata(metadataKey, target, targetKey) { + if (!IsObject(target)) { + throw new TypeError(); + } + else if (!IsUndefined(targetKey)) { + targetKey = ToPropertyKey(targetKey); + } + return OrdinaryHasOwnMetadata(metadataKey, target, targetKey); + } + Reflect.hasOwnMetadata = hasOwnMetadata; + /** + * Gets the metadata value for the provided metadata key on the target object or its prototype chain. + * @param metadataKey A key used to store and retrieve metadata. + * @param target The target object on which the metadata is defined. + * @param targetKey (Optional) The property key for the target. + * @returns The metadata value for the metadata key if found; otherwise, `undefined`. + * @example + * + * class C { + * // property declarations are not part of ES6, though they are valid in TypeScript: + * // static staticProperty; + * // property; + * + * constructor(p) { } + * static staticMethod(p) { } + * method(p) { } + * } + * + * // constructor + * result = Reflect.getMetadata("custom:annotation", C); + * + * // property (on constructor) + * result = Reflect.getMetadata("custom:annotation", C, "staticProperty"); + * + * // property (on prototype) + * result = Reflect.getMetadata("custom:annotation", C.prototype, "property"); + * + * // method (on constructor) + * result = Reflect.getMetadata("custom:annotation", C, "staticMethod"); + * + * // method (on prototype) + * result = Reflect.getMetadata("custom:annotation", C.prototype, "method"); + * + */ + function getMetadata(metadataKey, target, targetKey) { + if (!IsObject(target)) { + throw new TypeError(); + } + else if (!IsUndefined(targetKey)) { + targetKey = ToPropertyKey(targetKey); + } + return OrdinaryGetMetadata(metadataKey, target, targetKey); + } + Reflect.getMetadata = getMetadata; + /** + * Gets the metadata value for the provided metadata key on the target object. + * @param metadataKey A key used to store and retrieve metadata. + * @param target The target object on which the metadata is defined. + * @param targetKey (Optional) The property key for the target. + * @returns The metadata value for the metadata key if found; otherwise, `undefined`. + * @example + * + * class C { + * // property declarations are not part of ES6, though they are valid in TypeScript: + * // static staticProperty; + * // property; + * + * constructor(p) { } + * static staticMethod(p) { } + * method(p) { } + * } + * + * // constructor + * result = Reflect.getOwnMetadata("custom:annotation", C); + * + * // property (on constructor) + * result = Reflect.getOwnMetadata("custom:annotation", C, "staticProperty"); + * + * // property (on prototype) + * result = Reflect.getOwnMetadata("custom:annotation", C.prototype, "property"); + * + * // method (on constructor) + * result = Reflect.getOwnMetadata("custom:annotation", C, "staticMethod"); + * + * // method (on prototype) + * result = Reflect.getOwnMetadata("custom:annotation", C.prototype, "method"); + * + */ + function getOwnMetadata(metadataKey, target, targetKey) { + if (!IsObject(target)) { + throw new TypeError(); + } + else if (!IsUndefined(targetKey)) { + targetKey = ToPropertyKey(targetKey); + } + return OrdinaryGetOwnMetadata(metadataKey, target, targetKey); + } + Reflect.getOwnMetadata = getOwnMetadata; + /** + * Gets the metadata keys defined on the target object or its prototype chain. + * @param target The target object on which the metadata is defined. + * @param targetKey (Optional) The property key for the target. + * @returns An array of unique metadata keys. + * @example + * + * class C { + * // property declarations are not part of ES6, though they are valid in TypeScript: + * // static staticProperty; + * // property; + * + * constructor(p) { } + * static staticMethod(p) { } + * method(p) { } + * } + * + * // constructor + * result = Reflect.getMetadataKeys(C); + * + * // property (on constructor) + * result = Reflect.getMetadataKeys(C, "staticProperty"); + * + * // property (on prototype) + * result = Reflect.getMetadataKeys(C.prototype, "property"); + * + * // method (on constructor) + * result = Reflect.getMetadataKeys(C, "staticMethod"); + * + * // method (on prototype) + * result = Reflect.getMetadataKeys(C.prototype, "method"); + * + */ + function getMetadataKeys(target, targetKey) { + if (!IsObject(target)) { + throw new TypeError(); + } + else if (!IsUndefined(targetKey)) { + targetKey = ToPropertyKey(targetKey); + } + return OrdinaryMetadataKeys(target, targetKey); + } + Reflect.getMetadataKeys = getMetadataKeys; + /** + * Gets the unique metadata keys defined on the target object. + * @param target The target object on which the metadata is defined. + * @param targetKey (Optional) The property key for the target. + * @returns An array of unique metadata keys. + * @example + * + * class C { + * // property declarations are not part of ES6, though they are valid in TypeScript: + * // static staticProperty; + * // property; + * + * constructor(p) { } + * static staticMethod(p) { } + * method(p) { } + * } + * + * // constructor + * result = Reflect.getOwnMetadataKeys(C); + * + * // property (on constructor) + * result = Reflect.getOwnMetadataKeys(C, "staticProperty"); + * + * // property (on prototype) + * result = Reflect.getOwnMetadataKeys(C.prototype, "property"); + * + * // method (on constructor) + * result = Reflect.getOwnMetadataKeys(C, "staticMethod"); + * + * // method (on prototype) + * result = Reflect.getOwnMetadataKeys(C.prototype, "method"); + * + */ + function getOwnMetadataKeys(target, targetKey) { + if (!IsObject(target)) { + throw new TypeError(); + } + else if (!IsUndefined(targetKey)) { + targetKey = ToPropertyKey(targetKey); + } + return OrdinaryOwnMetadataKeys(target, targetKey); + } + Reflect.getOwnMetadataKeys = getOwnMetadataKeys; + /** + * Deletes the metadata entry from the target object with the provided key. + * @param metadataKey A key used to store and retrieve metadata. + * @param target The target object on which the metadata is defined. + * @param targetKey (Optional) The property key for the target. + * @returns `true` if the metadata entry was found and deleted; otherwise, false. + * @example + * + * class C { + * // property declarations are not part of ES6, though they are valid in TypeScript: + * // static staticProperty; + * // property; + * + * constructor(p) { } + * static staticMethod(p) { } + * method(p) { } + * } + * + * // constructor + * result = Reflect.deleteMetadata("custom:annotation", C); + * + * // property (on constructor) + * result = Reflect.deleteMetadata("custom:annotation", C, "staticProperty"); + * + * // property (on prototype) + * result = Reflect.deleteMetadata("custom:annotation", C.prototype, "property"); + * + * // method (on constructor) + * result = Reflect.deleteMetadata("custom:annotation", C, "staticMethod"); + * + * // method (on prototype) + * result = Reflect.deleteMetadata("custom:annotation", C.prototype, "method"); + * + */ + function deleteMetadata(metadataKey, target, targetKey) { + if (!IsObject(target)) { + throw new TypeError(); + } + else if (!IsUndefined(targetKey)) { + targetKey = ToPropertyKey(targetKey); + } + // https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#deletemetadata-metadatakey-p- + var metadataMap = GetOrCreateMetadataMap(target, targetKey, false); + if (IsUndefined(metadataMap)) { + return false; + } + if (!metadataMap.delete(metadataKey)) { + return false; + } + if (metadataMap.size > 0) { + return true; + } + var targetMetadata = __Metadata__.get(target); + targetMetadata.delete(targetKey); + if (targetMetadata.size > 0) { + return true; + } + __Metadata__.delete(target); + return true; + } + Reflect.deleteMetadata = deleteMetadata; + function DecorateConstructor(decorators, target) { + for (var i = decorators.length - 1; i >= 0; --i) { + var decorator = decorators[i]; + var decorated = decorator(target); + if (!IsUndefined(decorated)) { + if (!IsConstructor(decorated)) { + throw new TypeError(); + } + target = decorated; + } + } + return target; + } + function DecoratePropertyWithDescriptor(decorators, target, propertyKey, descriptor) { + for (var i = decorators.length - 1; i >= 0; --i) { + var decorator = decorators[i]; + var decorated = decorator(target, propertyKey, descriptor); + if (!IsUndefined(decorated)) { + if (!IsObject(decorated)) { + throw new TypeError(); + } + descriptor = decorated; + } + } + return descriptor; + } + function DecoratePropertyWithoutDescriptor(decorators, target, propertyKey) { + for (var i = decorators.length - 1; i >= 0; --i) { + var decorator = decorators[i]; + decorator(target, propertyKey); + } + } + // https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#getorcreatemetadatamap--o-p-create- + function GetOrCreateMetadataMap(target, targetKey, create) { + var targetMetadata = __Metadata__.get(target); + if (!targetMetadata) { + if (!create) { + return undefined; + } + targetMetadata = new _Map(); + __Metadata__.set(target, targetMetadata); + } + var keyMetadata = targetMetadata.get(targetKey); + if (!keyMetadata) { + if (!create) { + return undefined; + } + keyMetadata = new _Map(); + targetMetadata.set(targetKey, keyMetadata); + } + return keyMetadata; + } + // https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinaryhasmetadata--metadatakey-o-p- + function OrdinaryHasMetadata(MetadataKey, O, P) { + var hasOwn = OrdinaryHasOwnMetadata(MetadataKey, O, P); + if (hasOwn) { + return true; + } + var parent = GetPrototypeOf(O); + if (parent !== null) { + return OrdinaryHasMetadata(MetadataKey, parent, P); + } + return false; + } + // https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinaryhasownmetadata--metadatakey-o-p- + function OrdinaryHasOwnMetadata(MetadataKey, O, P) { + var metadataMap = GetOrCreateMetadataMap(O, P, false); + if (metadataMap === undefined) { + return false; + } + return Boolean(metadataMap.has(MetadataKey)); + } + // https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinarygetmetadata--metadatakey-o-p- + function OrdinaryGetMetadata(MetadataKey, O, P) { + var hasOwn = OrdinaryHasOwnMetadata(MetadataKey, O, P); + if (hasOwn) { + return OrdinaryGetOwnMetadata(MetadataKey, O, P); + } + var parent = GetPrototypeOf(O); + if (parent !== null) { + return OrdinaryGetMetadata(MetadataKey, parent, P); + } + return undefined; + } + // https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinarygetownmetadata--metadatakey-o-p- + function OrdinaryGetOwnMetadata(MetadataKey, O, P) { + var metadataMap = GetOrCreateMetadataMap(O, P, false); + if (metadataMap === undefined) { + return undefined; + } + return metadataMap.get(MetadataKey); + } + // https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinarydefineownmetadata--metadatakey-metadatavalue-o-p- + function OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P) { + var metadataMap = GetOrCreateMetadataMap(O, P, true); + metadataMap.set(MetadataKey, MetadataValue); + } + // https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinarymetadatakeys--o-p- + function OrdinaryMetadataKeys(O, P) { + var ownKeys = OrdinaryOwnMetadataKeys(O, P); + var parent = GetPrototypeOf(O); + if (parent === null) { + return ownKeys; + } + var parentKeys = OrdinaryMetadataKeys(parent, P); + if (parentKeys.length <= 0) { + return ownKeys; + } + if (ownKeys.length <= 0) { + return parentKeys; + } + var set = new _Set(); + var keys = []; + for (var _i = 0; _i < ownKeys.length; _i++) { + var key = ownKeys[_i]; + var hasKey = set.has(key); + if (!hasKey) { + set.add(key); + keys.push(key); + } + } + for (var _a = 0; _a < parentKeys.length; _a++) { + var key = parentKeys[_a]; + var hasKey = set.has(key); + if (!hasKey) { + set.add(key); + keys.push(key); + } + } + return keys; + } + // https://github.com/jonathandturner/decorators/blob/master/specs/metadata.md#ordinaryownmetadatakeys--o-p- + function OrdinaryOwnMetadataKeys(target, targetKey) { + var metadataMap = GetOrCreateMetadataMap(target, targetKey, false); + var keys = []; + if (metadataMap) { + metadataMap.forEach(function (_, key) { return keys.push(key); }); + } + return keys; + } + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ecmascript-language-types-undefined-type + function IsUndefined(x) { + return x === undefined; + } + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isarray + function IsArray(x) { + return Array.isArray(x); + } + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object-type + function IsObject(x) { + return typeof x === "object" ? x !== null : typeof x === "function"; + } + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-isconstructor + function IsConstructor(x) { + return typeof x === "function"; + } + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ecmascript-language-types-symbol-type + function IsSymbol(x) { + return typeof x === "symbol"; + } + // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-topropertykey + function ToPropertyKey(value) { + if (IsSymbol(value)) { + return value; + } + return String(value); + } + function GetPrototypeOf(O) { + var proto = Object.getPrototypeOf(O); + if (typeof O !== "function" || O === functionPrototype) { + return proto; + } + // TypeScript doesn't set __proto__ in ES5, as it's non-standard. + // Try to determine the superclass constructor. Compatible implementations + // must either set __proto__ on a subclass constructor to the superclass constructor, + // or ensure each class has a valid `constructor` property on its prototype that + // points back to the constructor. + // If this is not the same as Function.[[Prototype]], then this is definately inherited. + // This is the case when in ES6 or when using __proto__ in a compatible browser. + if (proto !== functionPrototype) { + return proto; + } + // If the super prototype is Object.prototype, null, or undefined, then we cannot determine the heritage. + var prototype = O.prototype; + var prototypeProto = Object.getPrototypeOf(prototype); + if (prototypeProto == null || prototypeProto === Object.prototype) { + return proto; + } + // if the constructor was not a function, then we cannot determine the heritage. + var constructor = prototypeProto.constructor; + if (typeof constructor !== "function") { + return proto; + } + // if we have some kind of self-reference, then we cannot determine the heritage. + if (constructor === O) { + return proto; + } + // we have a pretty good guess at the heritage. + return constructor; + } + // naive Map shim + function CreateMapPolyfill() { + var cacheSentinel = {}; + function Map() { + this._keys = []; + this._values = []; + this._cache = cacheSentinel; + } + Map.prototype = { + get size() { + return this._keys.length; + }, + has: function (key) { + if (key === this._cache) { + return true; + } + if (this._find(key) >= 0) { + this._cache = key; + return true; + } + return false; + }, + get: function (key) { + var index = this._find(key); + if (index >= 0) { + this._cache = key; + return this._values[index]; + } + return undefined; + }, + set: function (key, value) { + this.delete(key); + this._keys.push(key); + this._values.push(value); + this._cache = key; + return this; + }, + delete: function (key) { + var index = this._find(key); + if (index >= 0) { + this._keys.splice(index, 1); + this._values.splice(index, 1); + this._cache = cacheSentinel; + return true; + } + return false; + }, + clear: function () { + this._keys.length = 0; + this._values.length = 0; + this._cache = cacheSentinel; + }, + forEach: function (callback, thisArg) { + var size = this.size; + for (var i = 0; i < size; ++i) { + var key = this._keys[i]; + var value = this._values[i]; + this._cache = key; + callback.call(this, value, key, this); + } + }, + _find: function (key) { + var keys = this._keys; + var size = keys.length; + for (var i = 0; i < size; ++i) { + if (keys[i] === key) { + return i; + } + } + return -1; + } + }; + return Map; + } + // naive Set shim + function CreateSetPolyfill() { + var cacheSentinel = {}; + function Set() { + this._map = new _Map(); + } + Set.prototype = { + get size() { + return this._map.length; + }, + has: function (value) { + return this._map.has(value); + }, + add: function (value) { + this._map.set(value, value); + return this; + }, + delete: function (value) { + return this._map.delete(value); + }, + clear: function () { + this._map.clear(); + }, + forEach: function (callback, thisArg) { + this._map.forEach(callback, thisArg); + } + }; + return Set; + } + // naive WeakMap shim + function CreateWeakMapPolyfill() { + var UUID_SIZE = 16; + var isNode = typeof global !== "undefined" && + typeof module === "object" && + typeof module.exports === "object" && + typeof require === "function"; + var nodeCrypto = isNode && require("crypto"); + var hasOwn = Object.prototype.hasOwnProperty; + var keys = {}; + var rootKey = CreateUniqueKey(); + function WeakMap() { + this._key = CreateUniqueKey(); + } + WeakMap.prototype = { + has: function (target) { + var table = GetOrCreateWeakMapTable(target, false); + if (table) { + return this._key in table; + } + return false; + }, + get: function (target) { + var table = GetOrCreateWeakMapTable(target, false); + if (table) { + return table[this._key]; + } + return undefined; + }, + set: function (target, value) { + var table = GetOrCreateWeakMapTable(target, true); + table[this._key] = value; + return this; + }, + delete: function (target) { + var table = GetOrCreateWeakMapTable(target, false); + if (table && this._key in table) { + return delete table[this._key]; + } + return false; + }, + clear: function () { + // NOTE: not a real clear, just makes the previous data unreachable + this._key = CreateUniqueKey(); + } + }; + function FillRandomBytes(buffer, size) { + for (var i = 0; i < size; ++i) { + buffer[i] = Math.random() * 255 | 0; + } + } + function GenRandomBytes(size) { + if (nodeCrypto) { + var data = nodeCrypto.randomBytes(size); + return data; + } + else if (typeof Uint8Array === "function") { + var data = new Uint8Array(size); + if (typeof crypto !== "undefined") { + crypto.getRandomValues(data); + } + else if (typeof msCrypto !== "undefined") { + msCrypto.getRandomValues(data); + } + else { + FillRandomBytes(data, size); + } + return data; + } + else { + var data = new Array(size); + FillRandomBytes(data, size); + return data; + } + } + function CreateUUID() { + var data = GenRandomBytes(UUID_SIZE); + // mark as random - RFC 4122 § 4.4 + data[6] = data[6] & 0x4f | 0x40; + data[8] = data[8] & 0xbf | 0x80; + var result = ""; + for (var offset = 0; offset < UUID_SIZE; ++offset) { + var byte = data[offset]; + if (offset === 4 || offset === 6 || offset === 8) { + result += "-"; + } + if (byte < 16) { + result += "0"; + } + result += byte.toString(16).toLowerCase(); + } + return result; + } + function CreateUniqueKey() { + var key; + do { + key = "@@WeakMap@@" + CreateUUID(); + } while (hasOwn.call(keys, key)); + keys[key] = true; + return key; + } + function GetOrCreateWeakMapTable(target, create) { + if (!hasOwn.call(target, rootKey)) { + if (!create) { + return undefined; + } + Object.defineProperty(target, rootKey, { value: Object.create(null) }); + } + return target[rootKey]; + } + return WeakMap; + } + // hook global Reflect + (function (__global) { + if (typeof __global.Reflect !== "undefined") { + if (__global.Reflect !== Reflect) { + for (var p in Reflect) { + __global.Reflect[p] = Reflect[p]; + } + } + } + else { + __global.Reflect = Reflect; + } + })(typeof window !== "undefined" ? window : + typeof WorkerGlobalScope !== "undefined" ? self : + typeof global !== "undefined" ? global : + Function("return this;")()); +})(Reflect || (Reflect = {})); +//# sourceMappingURL=Reflect.js.map \ No newline at end of file diff --git a/scripts/component/babel-external-helpers.js b/scripts/component/babel-external-helpers.js new file mode 100644 index 0000000000..d0e59d3aeb --- /dev/null +++ b/scripts/component/babel-external-helpers.js @@ -0,0 +1,401 @@ +(function (global) { + var babelHelpers = global.babelHelpers = {}; + + babelHelpers.inherits = function (subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + enumerable: false, + writable: true, + configurable: true + } + }); + if (superClass) subClass.__proto__ = superClass; + }; + + babelHelpers.defaults = function (obj, defaults) { + var keys = Object.getOwnPropertyNames(defaults); + + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + var value = Object.getOwnPropertyDescriptor(defaults, key); + + if (value && value.configurable && obj[key] === undefined) { + Object.defineProperty(obj, key, value); + } + } + + return obj; + }; + + babelHelpers.createClass = (function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + })(); + + babelHelpers.createDecoratedClass = (function () { + function defineProperties(target, descriptors, initializers) { + for (var i = 0; i < descriptors.length; i++) { + var descriptor = descriptors[i]; + var decorators = descriptor.decorators; + var key = descriptor.key; + delete descriptor.key; + delete descriptor.decorators; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor || descriptor.initializer) descriptor.writable = true; + + if (decorators) { + for (var f = 0; f < decorators.length; f++) { + var decorator = decorators[f]; + + if (typeof decorator === "function") { + descriptor = decorator(target, key, descriptor) || descriptor; + } else { + throw new TypeError("The decorator for method " + descriptor.key + " is of the invalid type " + typeof decorator); + } + } + + if (descriptor.initializer !== undefined) { + initializers[key] = descriptor; + continue; + } + } + + Object.defineProperty(target, key, descriptor); + } + } + + return function (Constructor, protoProps, staticProps, protoInitializers, staticInitializers) { + if (protoProps) defineProperties(Constructor.prototype, protoProps, protoInitializers); + if (staticProps) defineProperties(Constructor, staticProps, staticInitializers); + return Constructor; + }; + })(); + + babelHelpers.createDecoratedObject = function (descriptors) { + var target = {}; + + for (var i = 0; i < descriptors.length; i++) { + var descriptor = descriptors[i]; + var decorators = descriptor.decorators; + var key = descriptor.key; + delete descriptor.key; + delete descriptor.decorators; + descriptor.enumerable = true; + descriptor.configurable = true; + descriptor.writable = true; + + if (decorators) { + for (var f = 0; f < decorators.length; f++) { + var decorator = decorators[f]; + + if (typeof decorator === "function") { + descriptor = decorator(target, key, descriptor) || descriptor; + } else { + throw new TypeError("The decorator for method " + descriptor.key + " is of the invalid type " + typeof decorator); + } + } + } + + if (descriptor.initializer) { + descriptor.value = descriptor.initializer.call(target); + } + + Object.defineProperty(target, key, descriptor); + } + + return target; + }; + + babelHelpers.defineDecoratedPropertyDescriptor = function (target, key, descriptors) { + var _descriptor = descriptors[key]; + if (!_descriptor) return; + var descriptor = {}; + + for (var _key in _descriptor) descriptor[_key] = _descriptor[_key]; + + descriptor.value = descriptor.initializer.call(target); + Object.defineProperty(target, key, descriptor); + }; + + babelHelpers.taggedTemplateLiteral = function (strings, raw) { + return Object.freeze(Object.defineProperties(strings, { + raw: { + value: Object.freeze(raw) + } + })); + }; + + babelHelpers.taggedTemplateLiteralLoose = function (strings, raw) { + strings.raw = raw; + return strings; + }; + + babelHelpers.toArray = function (arr) { + return Array.isArray(arr) ? arr : Array.from(arr); + }; + + babelHelpers.toConsumableArray = function (arr) { + if (Array.isArray(arr)) { + for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; + + return arr2; + } else { + return Array.from(arr); + } + }; + + babelHelpers.slicedToArray = function (arr, i) { + if (Array.isArray(arr)) { + return arr; + } else if (Symbol.iterator in Object(arr)) { + var _arr = []; + var _n = true; + var _d = false; + var _e = undefined; + + try { + for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { + _arr.push(_s.value); + + if (i && _arr.length === i) break; + } + } catch (err) { + _d = true; + _e = err; + } finally { + try { + if (!_n && _i["return"]) _i["return"](); + } finally { + if (_d) throw _e; + } + } + + return _arr; + } else { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); + } + }; + + babelHelpers.slicedToArrayLoose = function (arr, i) { + if (Array.isArray(arr)) { + return arr; + } else if (Symbol.iterator in Object(arr)) { + var _arr = []; + + for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) { + _arr.push(_step.value); + + if (i && _arr.length === i) break; + } + + return _arr; + } else { + throw new TypeError("Invalid attempt to destructure non-iterable instance"); + } + }; + + babelHelpers.objectWithoutProperties = function (obj, keys) { + var target = {}; + + for (var i in obj) { + if (keys.indexOf(i) >= 0) continue; + if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; + target[i] = obj[i]; + } + + return target; + }; + + babelHelpers.hasOwn = Object.prototype.hasOwnProperty; + babelHelpers.slice = Array.prototype.slice; + babelHelpers.bind = Function.prototype.bind; + + babelHelpers.defineProperty = function (obj, key, value) { + return Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + }; + + babelHelpers.asyncToGenerator = function (fn) { + return function () { + var gen = fn.apply(this, arguments); + return new Promise(function (resolve, reject) { + var callNext = step.bind(null, "next"); + var callThrow = step.bind(null, "throw"); + + function step(key, arg) { + try { + var info = gen[key](arg); + var value = info.value; + } catch (error) { + reject(error); + return; + } + + if (info.done) { + resolve(value); + } else { + Promise.resolve(value).then(callNext, callThrow); + } + } + + callNext(); + }); + }; + }; + + babelHelpers.interopRequireWildcard = function (obj) { + if (obj && obj.__esModule) { + return obj; + } else { + var newObj = {}; + + if (obj != null) { + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; + } + } + + newObj["default"] = obj; + return newObj; + } + }; + + babelHelpers.interopRequireDefault = function (obj) { + return obj && obj.__esModule ? obj : { + "default": obj + }; + }; + + babelHelpers._typeof = function (obj) { + return obj && obj.constructor === Symbol ? "symbol" : typeof obj; + }; + + babelHelpers._extends = Object.assign || function (target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + + for (var key in source) { + if (Object.prototype.hasOwnProperty.call(source, key)) { + target[key] = source[key]; + } + } + } + + return target; + }; + + babelHelpers.get = function get(object, property, receiver) { + var desc = Object.getOwnPropertyDescriptor(object, property); + + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + + if (parent === null) { + return undefined; + } else { + return get(parent, property, receiver); + } + } else if ("value" in desc) { + return desc.value; + } else { + var getter = desc.get; + + if (getter === undefined) { + return undefined; + } + + return getter.call(receiver); + } + }; + + babelHelpers.set = function set(object, property, value, receiver) { + var desc = Object.getOwnPropertyDescriptor(object, property); + + if (desc === undefined) { + var parent = Object.getPrototypeOf(object); + + if (parent !== null) { + set(parent, property, value, receiver); + } + } else if ("value" in desc && desc.writable) { + desc.value = value; + } else { + var setter = desc.set; + + if (setter !== undefined) { + setter.call(receiver, value); + } + } + + return value; + }; + + babelHelpers.classCallCheck = function (instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + }; + + babelHelpers.objectDestructuringEmpty = function (obj) { + if (obj == null) throw new TypeError("Cannot destructure undefined"); + }; + + babelHelpers.temporalUndefined = {}; + + babelHelpers.temporalAssertDefined = function (val, name, undef) { + if (val === undef) { + throw new ReferenceError(name + " is not defined - temporal dead zone"); + } + + return true; + }; + + babelHelpers.selfGlobal = typeof global === "undefined" ? self : global; + + babelHelpers.defaultProps = function (defaultProps, props) { + if (defaultProps) { + for (var propName in defaultProps) { + if (typeof props[propName] === "undefined") { + props[propName] = defaultProps[propName]; + } + } + } + + return props; + }; + + babelHelpers._instanceof = function (left, right) { + if (right != null && right[Symbol.hasInstance]) { + return right[Symbol.hasInstance](left); + } else { + return left instanceof right; + } + }; + + babelHelpers.interopRequire = function (obj) { + return obj && obj.__esModule ? obj["default"] : obj; + }; +})(typeof global === "undefined" ? self : global); diff --git a/scripts/component/es6-module-loader.js b/scripts/component/es6-module-loader.js new file mode 100644 index 0000000000..670808d249 --- /dev/null +++ b/scripts/component/es6-module-loader.js @@ -0,0 +1,8 @@ +/* + * es6-module-loader v0.16.0 + * https://github.com/ModuleLoader/es6-module-loader + * Copyright (c) 2015 Guy Bedford, Luke Hoban, Addy Osmani; Licensed MIT + */ + +!function(a){"object"==typeof exports?module.exports=a():"function"==typeof define&&define.amd?define(a):"undefined"!=typeof window?window.Promise=a():"undefined"!=typeof global?global.Promise=a():"undefined"!=typeof self&&(self.Promise=a())}(function(){var a;return function b(a,c,d){function e(g,h){if(!c[g]){if(!a[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};a[g][0].call(j.exports,function(b){var c=a[g][1][b];return e(c?c:b)},j,j.exports,b,a,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g=0&&(n.splice(b,1),l("Handled previous rejection ["+a.id+"] "+e.formatObject(a.value)))}function h(a,b){m.push(a,b),null===o&&(o=d(i,0))}function i(){for(o=null;m.length>0;)m.shift()(m.shift())}var j,k=c,l=c;"undefined"!=typeof console&&(j=console,k="undefined"!=typeof j.error?function(a){j.error(a)}:function(a){j.log(a)},l="undefined"!=typeof j.info?function(a){j.info(a)}:function(a){j.log(a)}),a.onPotentiallyUnhandledRejection=function(a){h(f,a)},a.onPotentiallyUnhandledRejectionHandled=function(a){h(g,a)},a.onFatalRejection=function(a){h(b,a.value)};var m=[],n=[],o=null;return a}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a(b)})},{"../env":5,"../format":6}],5:[function(b,c){!function(a){"use strict";a(function(a){function b(){return"undefined"!=typeof process&&null!==process&&"function"==typeof process.nextTick}function c(){return"function"==typeof MutationObserver&&MutationObserver||"function"==typeof WebKitMutationObserver&&WebKitMutationObserver}function d(a){function b(){var a=c;c=void 0,a()}var c,d=document.createTextNode(""),e=new a(b);e.observe(d,{characterData:!0});var f=0;return function(a){c=a,d.data=f^=1}}var e,f="undefined"!=typeof setTimeout&&setTimeout,g=function(a,b){return setTimeout(a,b)},h=function(a){return clearTimeout(a)},i=function(a){return f(a,0)};if(b())i=function(a){return process.nextTick(a)};else if(e=c())i=d(e);else if(!f){var j=a,k=j("vertx");g=function(a,b){return k.setTimer(b,a)},h=k.cancelTimer,i=k.runOnLoop||k.runOnContext}return{setTimer:g,clearTimer:h,asap:i}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a(b)})},{}],6:[function(b,c){!function(a){"use strict";a(function(){function a(a){var c="object"==typeof a&&null!==a&&a.stack?a.stack:b(a);return a instanceof Error?c:c+" (WARNING: non-Error used)"}function b(a){var b=String(a);return"[object Object]"===b&&"undefined"!=typeof JSON&&(b=c(a,b)),b}function c(a,b){try{return JSON.stringify(a)}catch(c){return b}}return{formatError:a,formatObject:b,tryStringify:c}})}("function"==typeof a&&a.amd?a:function(a){c.exports=a()})},{}],7:[function(b,c){!function(a){"use strict";a(function(){return function(a){function b(a,b){this._handler=a===t?b:c(a)}function c(a){function b(a){e.resolve(a)}function c(a){e.reject(a)}function d(a){e.notify(a)}var e=new v;try{a(b,c,d)}catch(f){c(f)}return e}function d(a){return I(a)?a:new b(t,new w(q(a)))}function e(a){return new b(t,new w(new z(a)))}function f(){return _}function g(){return new b(t,new v)}function h(a,b){var c=new v(a.receiver,a.join().context);return new b(t,c)}function i(a){return k(S,null,a)}function j(a,b){return k(N,a,b)}function k(a,c,d){function e(b,e,g){g.resolved||l(d,f,b,a(c,e,b),g)}function f(a,b,c){k[a]=b,0===--j&&c.become(new y(k))}for(var g,h="function"==typeof c?e:f,i=new v,j=d.length>>>0,k=new Array(j),m=0;m0?b(c,f.value,e):(e.become(f),m(a,c+1,f))}else b(c,d,e)}function m(a,b,c){for(var d=b;dc&&a._unreport()}}function o(a){return"object"!=typeof a||null===a?e(new TypeError("non-iterable passed to race()")):0===a.length?f():1===a.length?d(a[0]):p(a)}function p(a){var c,d,e,f=new v;for(c=0;c0||"function"!=typeof b&&0>e)return new this.constructor(t,d);var f=this._beget(),g=f._handler;return d.chain(g,d.receiver,a,b,c),f},b.prototype["catch"]=function(a){return this.then(void 0,a)},b.prototype._beget=function(){return h(this._handler,this.constructor)},b.all=i,b.race=o,b._traverse=j,b._visitRemaining=m,t.prototype.when=t.prototype.become=t.prototype.notify=t.prototype.fail=t.prototype._unreport=t.prototype._report=T,t.prototype._state=0,t.prototype.state=function(){return this._state},t.prototype.join=function(){for(var a=this;void 0!==a.handler;)a=a.handler;return a},t.prototype.chain=function(a,b,c,d,e){this.when({resolver:a,receiver:b,fulfilled:c,rejected:d,progress:e})},t.prototype.visit=function(a,b,c,d){this.chain(Y,a,b,c,d)},t.prototype.fold=function(a,b,c,d){this.when(new H(a,b,c,d))},R(t,u),u.prototype.become=function(a){a.fail()};var Y=new u;R(t,v),v.prototype._state=0,v.prototype.resolve=function(a){this.become(q(a))},v.prototype.reject=function(a){this.resolved||this.become(new z(a))},v.prototype.join=function(){if(!this.resolved)return this;for(var a=this;void 0!==a.handler;)if(a=a.handler,a===this)return this.handler=C();return a},v.prototype.run=function(){var a=this.consumers,b=this.handler;this.handler=this.handler.join(),this.consumers=void 0;for(var c=0;cf;f++)if(e=b.loads[f],e.name==c)return e;return e=a(c),b.loads.push(e),d(b,e),e})}function d(a,b){e(a,b,A.resolve().then(function(){return a.loaderObj.locate({name:b.name,metadata:b.metadata})}))}function e(a,b,c){f(a,b,c.then(function(c){return"loading"==b.status?(b.address=c,a.loaderObj.fetch({name:b.name,metadata:b.metadata,address:c})):void 0}))}function f(a,b,d){d.then(function(d){return"loading"==b.status?A.resolve(a.loaderObj.translate({name:b.name,metadata:b.metadata,address:b.address,source:d})).then(function(c){return b.source=c,a.loaderObj.instantiate({name:b.name,metadata:b.metadata,address:b.address,source:c})}).then(function(c){if(void 0===c)return b.address=b.address||"",b.isDeclarative=!0,a.loaderObj.transpile(b).then(function(a){var c=__global.System,d=c.register;c.register=function(a,c,d){"string"!=typeof a&&(d=c,c=a),b.declare=d,b.depsList=c},__eval(a,__global,b),c.register=d});if("object"!=typeof c)throw TypeError("Invalid instantiate return value");b.depsList=c.deps||[],b.execute=c.execute,b.isDeclarative=!1}).then(function(){b.dependencies=[];for(var d=b.depsList,e=[],f=0,g=d.length;g>f;f++)(function(d,f){e.push(c(a,d,b.name,b.address).then(function(a){if(b.dependencies[f]={key:d,value:a.name},"linked"!=a.status)for(var c=b.linkSets.concat([]),e=0,g=c.length;g>e;e++)i(c[e],a)}))})(d[f],f);return A.all(e)}).then(function(){b.status="loaded";for(var a=b.linkSets.concat([]),c=0,d=a.length;d>c;c++)k(a[c],b)}):void 0})["catch"](function(a){b.status="failed",b.exception=a;for(var c=b.linkSets.concat([]),d=0,e=c.length;e>d;d++)l(c[d],b,a)})}function g(b){return function(c){var g=b.loader,i=b.moduleName,j=b.step;if(g.modules[i])throw new TypeError('"'+i+'" already exists in the module table');for(var k,l=0,m=g.loads.length;m>l;l++)if(g.loads[l].name==i)return k=g.loads[l],"translate"!=j||k.source||(k.address=b.moduleAddress,f(g,k,A.resolve(b.moduleSource))),k.linkSets[0].done.then(function(){c(k)});var n=a(i);n.metadata=b.moduleMetadata;var o=h(g,n);g.loads.push(n),c(o.done),"locate"==j?d(g,n):"fetch"==j?e(g,n,A.resolve(b.moduleAddress)):(n.address=b.moduleAddress,f(g,n,A.resolve(b.moduleSource)))}}function h(a,b){var c={loader:a,loads:[],startingLoad:b,loadingCount:0};return c.done=new A(function(a,b){c.resolve=a,c.reject=b}),i(c,b),c}function i(a,b){for(var c=0,d=a.loads.length;d>c;c++)if(a.loads[c]==b)return;a.loads.push(b),b.linkSets.push(a),"loaded"!=b.status&&a.loadingCount++;for(var e=a.loader,c=0,d=b.dependencies.length;d>c;c++){var f=b.dependencies[c].value;if(!e.modules[f])for(var g=0,h=e.loads.length;h>g;g++)if(e.loads[g].name==f){i(a,e.loads[g]);break}}}function j(a){var b=!1;try{p(a,function(c,d){l(a,c,d),b=!0})}catch(c){l(a,null,c),b=!0}return b}function k(a,b){if(a.loadingCount--,!(a.loadingCount>0)){var c=a.startingLoad;if(a.loader.loaderObj.execute===!1){for(var d=[].concat(a.loads),e=0,f=d.length;f>e;e++){var b=d[e];b.module=b.isDeclarative?{name:b.name,module:E({}),evaluated:!0}:{module:E({})},b.status="linked",m(a.loader,b)}return a.resolve(c)}var g=j(a);g||a.resolve(c)}}function l(a,b,c){var d=a.loader;a.loads[0].name!=b.name&&(c=w(c,'Error loading "'+b.name+'" from "'+a.loads[0].name+'" at '+(a.loads[0].address||"")+"\n")),c=w(c,'Error loading "'+b.name+'" at '+(b.address||"")+"\n");for(var e=a.loads.concat([]),f=0,g=e.length;g>f;f++){var b=e[f];d.loaderObj.failed=d.loaderObj.failed||[],-1==B.call(d.loaderObj.failed,b)&&d.loaderObj.failed.push(b);var h=B.call(b.linkSets,a);if(b.linkSets.splice(h,1),0==b.linkSets.length){var i=B.call(a.loader.loads,b);-1!=i&&a.loader.loads.splice(i,1)}}a.reject(c)}function m(a,b){if(a.loaderObj.trace){a.loaderObj.loads||(a.loaderObj.loads={});var c={};b.dependencies.forEach(function(a){c[a.key]=a.value}),a.loaderObj.loads[b.name]={name:b.name,deps:b.dependencies.map(function(a){return a.key}),depMap:c,address:b.address,metadata:b.metadata,source:b.source,kind:b.isDeclarative?"declarative":"dynamic"}}b.name&&(a.modules[b.name]=b.module);var d=B.call(a.loads,b);-1!=d&&a.loads.splice(d,1);for(var e=0,f=b.linkSets.length;f>e;e++)d=B.call(b.linkSets[e].loads,b),-1!=d&&b.linkSets[e].loads.splice(d,1);b.linkSets.splice(0,b.linkSets.length)}function n(a,b,c){if(c[a.groupIndex]=c[a.groupIndex]||[],-1==B.call(c[a.groupIndex],a)){c[a.groupIndex].push(a);for(var d=0,e=b.length;e>d;d++)for(var f=b[d],g=0;g=0;g--){for(var h=d[g],i=0;ic;c++){var g=d.importers[c];if(!g.locked){var h=B.call(g.dependencies,d);g.setters[h](e)}}return d.locked=!1,b});d.setters=f.setters,d.execute=f.execute;for(var g=0,h=a.dependencies.length;h>g;g++){var i=a.dependencies[g].value,j=c.modules[i];if(!j)for(var k=0;kf;f++){var h=e[f];if(h&&-1==B.call(b,h)&&(d=v(h,b,c)))return d=w(d,"Error evaluating "+h.name+"\n")}if(a.failed)return new Error("Module failed execution.");if(!a.evaluated)return a.evaluated=!0,d=t(a),d?a.failed=!0:Object.preventExtensions&&Object.preventExtensions(a.module),a.execute=void 0,d}}function w(a,b){return a instanceof Error?a.message=b+a.message:a=b+a,a}function x(a){if("object"!=typeof a)throw new TypeError("Options must be an object");a.normalize&&(this.normalize=a.normalize),a.locate&&(this.locate=a.locate),a.fetch&&(this.fetch=a.fetch),a.translate&&(this.translate=a.translate),a.instantiate&&(this.instantiate=a.instantiate),this._loader={loaderObj:this,loads:[],modules:{},importPromises:{},moduleRecords:{}},C(this,"global",{get:function(){return __global}})}function y(){}function z(a,b,c){var d=a._loader.importPromises;return d[b]=c.then(function(a){return d[b]=void 0,a},function(a){throw d[b]=void 0,a})}var A=__global.Promise||require("when/es6-shim/Promise");__global.console&&(console.assert=console.assert||function(){});var B=Array.prototype.indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(this[b]===a)return b;return-1},C=$__Object$defineProperty,D=0;x.prototype={constructor:x,define:function(a,b,c){if(this._loader.importPromises[a])throw new TypeError("Module is already loading.");return z(this,a,new A(g({step:"translate",loader:this._loader,moduleName:a,moduleMetadata:c&&c.metadata||{},moduleSource:b,moduleAddress:c&&c.address})))},"delete":function(a){var b=this._loader;return delete b.importPromises[a],delete b.moduleRecords[a],b.modules[a]?delete b.modules[a]:!1},get:function(a){return this._loader.modules[a]?(u(this._loader.modules[a],[],this),this._loader.modules[a].module):void 0},has:function(a){return!!this._loader.modules[a]},"import":function(a,c){var d=this;return A.resolve(d.normalize(a,c&&c.name,c&&c.address)).then(function(a){var e=d._loader;return e.modules[a]?(u(e.modules[a],[],e._loader),e.modules[a].module):e.importPromises[a]||z(d,a,b(e,a,c||{}).then(function(b){return delete e.importPromises[a],s(e,b)}))})},load:function(a){return this._loader.modules[a]?(u(this._loader.modules[a],[],this._loader),A.resolve(this._loader.modules[a].module)):this._loader.importPromises[a]||z(this,a,b(this._loader,a,{}))},module:function(b,c){var d=a();d.address=c&&c.address;var e=h(this._loader,d),g=A.resolve(b),i=this._loader,j=e.done.then(function(){return s(i,d)});return f(i,d,g),j},newModule:function(a){if("object"!=typeof a)throw new TypeError("Expected object");var b=new y;for(var c in a)!function(c){C(b,c,{configurable:!1,enumerable:!0,get:function(){return a[c]}})}(c);return Object.preventExtensions&&Object.preventExtensions(b),b},set:function(a,b){if(!(b instanceof y))throw new TypeError("Loader.set("+a+", module) must be a module");this._loader.modules[a]={module:b}},normalize:function(a){return a},locate:function(a){return a.name},fetch:function(){throw new TypeError("Fetch not implemented")},translate:function(a){return a.source},instantiate:function(){}};var E=x.prototype.newModule;"object"==typeof exports&&(module.exports=x),__global.Reflect=__global.Reflect||{},__global.Reflect.Loader=__global.Reflect.Loader||x,__global.Reflect.global=__global.Reflect.global||__global,__global.LoaderPolyfill=x}(),function(a){function b(a,b){return a.newModule({"default":f[b],__useDefault:!0})}function c(a,b){var c=this.traceurOptions||{};c.modules="instantiate",c.script=!1,c.sourceMaps="inline",c.filename=a.address,c.inputSourceMap=a.metadata.sourceMap,c.moduleName=!1;var e=new b.Compiler(c),f=d(a.source,e,c.filename);return f+="!eval"}function d(a,b,c){try{return b.compile(a,c)}catch(d){throw d[0]}}function e(a,b){var c=this.babelOptions||{};c.modules="system",c.sourceMap="inline",c.filename=a.address,c.code=!0,c.ast=!1,c.blacklist||(c.blacklist=["react"]);var d=b.transform(a.source,c).code;return d+"\n//# sourceURL="+a.address+"!eval"}var f=__global,g=!0;a.prototype.transpiler="traceur",a.prototype.transpile=function(a){var d=this;return g&&(f.traceur&&!d.has("traceur")&&d.set("traceur",b(d,"traceur")),f.babel&&!d.has("babel")&&d.set("babel",b(d,"babel")),g=!1),d["import"](d.transpiler).then(function(b){return b.__useDefault&&(b=b["default"]),'var __moduleAddress = "'+a.address+'";'+(b.Compiler?c:e).call(d,a,b)})},a.prototype.instantiate=function(a){if(a.name===this.transpiler){var c=this;return{deps:[],execute:function(){var d=f.System,e=f.Reflect.Loader;return __eval("(function(require,exports,module){"+a.source+"})();",f,a),f.System=d,f.Reflect.Loader=e,b(c,a.name)}}}}}(__global.LoaderPolyfill),function(){function a(a){var b=String(a).replace(/^\s+|\s+$/g,"").match(/^([^:\/?#]+:)?(\/\/(?:[^:@\/?#]*(?::[^:@\/?#]*)?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/);return b?{href:b[0]||"",protocol:b[1]||"",authority:b[2]||"",host:b[3]||"",hostname:b[4]||"",port:b[5]||"",pathname:b[6]||"",search:b[7]||"",hash:b[8]||""}:null}function b(a){var b=[];return a.replace(/^(\.\.?(\/|$))+/,"").replace(/\/(\.(\/|$))+/g,"/").replace(/\/\.\.$/,"/../").replace(/\/?[^\/]*/g,function(a){"/.."===a?b.pop():b.push(a)}),b.join("").replace(/^\//,"/"===a.charAt(0)?"/":"")}function c(c,d){return i&&(d=d.replace(/\\/g,"/")),d=a(d||""),c=a(c||""),d&&c?(d.protocol||c.protocol)+(d.protocol||d.authority?d.authority:c.authority)+b(d.protocol||d.authority||"/"===d.pathname.charAt(0)?d.pathname:d.pathname?(c.authority&&!c.pathname?"/":"")+c.pathname.slice(0,c.pathname.lastIndexOf("/")+1)+d.pathname:c.pathname)+(d.protocol||d.authority||d.pathname?d.search:d.search||c.search)+d.hash:null}function d(){document.removeEventListener("DOMContentLoaded",d,!1),window.removeEventListener("load",d,!1),e()}function e(){for(var a=document.getElementsByTagName("script"),b=0;b2)throw new TypeError("Only one wildcard in a path is permitted");if(1==g.length){if(d==f&&f.length>e.length){e=f;break}}else d.substr(0,g[0].length)==g[0]&&d.substr(d.length-g[1].length)==g[1]&&(e=f,b=d.substr(g[0].length,d.length-g[1].length-g[0].length))}var i=this.paths[e];return b&&(i=i.replace("*",b)),h&&(i=i.replace(/#/g,"%23")),c(this.baseURL,i)},enumerable:!1,writable:!0}),$__Object$defineProperty(b.prototype,"fetch",{value:function(a){var b=this;return new j(function(d,e){f(c(b.baseURL,a.address),function(a){d(a)},e)})},enumerable:!1,writable:!0}),b}(__global.LoaderPolyfill),m=new l;if("object"==typeof exports&&(module.exports=m),__global.System=m,h&&"undefined"!=typeof document.getElementsByTagName){var n=document.getElementsByTagName("script");n=n[n.length-1],"complete"===document.readyState?setTimeout(e):document.addEventListener&&(document.addEventListener("DOMContentLoaded",d,!1),window.addEventListener("load",d,!1)),n.getAttribute("data-init")&&window[n.getAttribute("data-init")]()}}()}("undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope?self:global); +//# sourceMappingURL=es6-module-loader.js.map \ No newline at end of file diff --git a/scripts/component/system.src.js b/scripts/component/system.src.js new file mode 100644 index 0000000000..4362d78b1a --- /dev/null +++ b/scripts/component/system.src.js @@ -0,0 +1,2406 @@ +/* + * SystemJS v0.16.11 + */ + +(function($__global, $__globalName) { + +$__global.upgradeSystemLoader = function() { + $__global.upgradeSystemLoader = undefined; + + // indexOf polyfill for IE + var indexOf = Array.prototype.indexOf || function(item) { + for (var i = 0, l = this.length; i < l; i++) + if (this[i] === item) + return i; + return -1; + } + + var isWindows = typeof process != 'undefined' && !!process.platform.match(/^win/); + + // Absolute URL parsing, from https://gist.github.com/Yaffle/1088850 + function parseURI(url) { + var m = String(url).replace(/^\s+|\s+$/g, '').match(/^([^:\/?#]+:)?(\/\/(?:[^:@\/?#]*(?::[^:@\/?#]*)?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/); + // authority = '//' + user + ':' + pass '@' + hostname + ':' port + return (m ? { + href : m[0] || '', + protocol : m[1] || '', + authority: m[2] || '', + host : m[3] || '', + hostname : m[4] || '', + port : m[5] || '', + pathname : m[6] || '', + search : m[7] || '', + hash : m[8] || '' + } : null); + } + function toAbsoluteURL(base, href) { + function removeDotSegments(input) { + var output = []; + input.replace(/^(\.\.?(\/|$))+/, '') + .replace(/\/(\.(\/|$))+/g, '/') + .replace(/\/\.\.$/, '/../') + .replace(/\/?[^\/]*/g, function (p) { + if (p === '/..') + output.pop(); + else + output.push(p); + }); + return output.join('').replace(/^\//, input.charAt(0) === '/' ? '/' : ''); + } + + if (isWindows) + href = href.replace(/\\/g, '/'); + + href = parseURI(href || ''); + base = parseURI(base || ''); + + return !href || !base ? null : (href.protocol || base.protocol) + + (href.protocol || href.authority ? href.authority : base.authority) + + removeDotSegments(href.protocol || href.authority || href.pathname.charAt(0) === '/' ? href.pathname : (href.pathname ? ((base.authority && !base.pathname ? '/' : '') + base.pathname.slice(0, base.pathname.lastIndexOf('/') + 1) + href.pathname) : base.pathname)) + + (href.protocol || href.authority || href.pathname ? href.search : (href.search || base.search)) + + href.hash; + } + + // clone the original System loader + var System; + (function() { + var originalSystem = $__global.System; + System = $__global.System = new LoaderPolyfill(originalSystem); + System.baseURL = originalSystem.baseURL; + System.paths = { '*': '*.js' }; + System.originalSystem = originalSystem; + })(); + + System.noConflict = function() { + $__global.SystemJS = System; + $__global.System = System.originalSystem; + } + + +/* + * SystemJS Core + * Code should be vaguely readable + * + */ +var originalSystem = $__global.System.originalSystem; +function core(loader) { + /* + __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() {} + */ + var loaderImport = loader['import']; + loader['import'] = function(name, options) { + return loaderImport.call(this, name, options).then(function(module) { + return module.__useDefault ? module['default'] : module; + }); + } + + // support the empty module, as a concept + loader.set('@empty', loader.newModule({})); + + // include the node require since we're overriding it + if (typeof require != 'undefined') + loader._nodeRequire = require; + + /* + Config + Extends 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' }; + */ + loader.config = function(cfg) { + for (var c in cfg) { + var v = cfg[c]; + if (typeof v == 'object' && !(v instanceof Array)) { + this[c] = this[c] || {}; + for (var p in v) + this[c][p] = v[p]; + } + else + this[c] = v; + } + } + + // override locate to allow baseURL to be document-relative + var baseURI; + if (typeof window == 'undefined' && + typeof WorkerGlobalScope == 'undefined' && typeof process != 'undefined') { + baseURI = 'file:' + process.cwd() + '/'; + if (isWindows) + baseURI = baseURI.replace(/\\/g, '/'); + } + // Inside of a Web Worker + else if (typeof window == 'undefined') { + baseURI = location.href; + } + else { + baseURI = document.baseURI; + if (!baseURI) { + var bases = document.getElementsByTagName('base'); + baseURI = bases[0] && bases[0].href || window.location.href; + } + } + + var loaderLocate = loader.locate; + var normalizedBaseURL; + loader.locate = function(load) { + if (this.baseURL != normalizedBaseURL) { + normalizedBaseURL = toAbsoluteURL(baseURI, this.baseURL); + + if (normalizedBaseURL.substr(normalizedBaseURL.length - 1, 1) != '/') + normalizedBaseURL += '/'; + this.baseURL = normalizedBaseURL; + } + + return Promise.resolve(loaderLocate.call(this, load)); + } + + function applyExtensions(extensions, loader) { + loader._extensions = []; + for(var i = 0, len = extensions.length; i < len; i++) { + extensions[i](loader); + } + } + + loader._extensions = loader._extensions || []; + loader._extensions.push(core); + + loader.clone = function() { + var originalLoader = this; + var loader = new LoaderPolyfill(originalSystem); + loader.baseURL = originalLoader.baseURL; + loader.paths = { '*': '*.js' }; + applyExtensions(originalLoader._extensions, loader); + return loader; + }; +} +/* + * Meta Extension + * + * Sets default metadata on a load record (load.metadata) from + * loader.meta[moduleName]. + * Also provides an inline meta syntax for module meta in source. + * + * Eg: + * + * loader.meta['my/module'] = { some: 'meta' }; + * + * load.metadata.some = 'meta' will now be set on the load record. + * + * The same meta could be set with a my/module.js file containing: + * + * my/module.js + * "some meta"; + * "another meta"; + * console.log('this is my/module'); + * + * The benefit of inline meta is that coniguration doesn't need + * to be known in advance, which is useful for modularising + * configuration and avoiding the need for configuration injection. + * + * + * Example + * ------- + * + * The simplest meta example is setting the module format: + * + * System.meta['my/module'] = { format: 'amd' }; + * + * or inside 'my/module.js': + * + * "format amd"; + * define(...); + * + */ + +function meta(loader) { + var metaRegEx = /^(\s*\/\*.*\*\/|\s*\/\/[^\n]*|\s*"[^"]+"\s*;?|\s*'[^']+'\s*;?)+/; + var metaPartRegEx = /\/\*.*\*\/|\/\/[^\n]*|"[^"]+"\s*;?|'[^']+'\s*;?/g; + + loader.meta = {}; + loader._extensions = loader._extensions || []; + loader._extensions.push(meta); + + function setConfigMeta(loader, load) { + var meta = loader.meta && loader.meta[load.name]; + if (meta) { + for (var p in meta) + load.metadata[p] = load.metadata[p] || meta[p]; + } + } + + var loaderLocate = loader.locate; + loader.locate = function(load) { + setConfigMeta(this, load); + return loaderLocate.call(this, load); + } + + var loaderTranslate = loader.translate; + loader.translate = function(load) { + // detect any meta header syntax + var meta = load.source.match(metaRegEx); + if (meta) { + var metaParts = meta[0].match(metaPartRegEx); + for (var i = 0; i < metaParts.length; i++) { + var len = metaParts[i].length; + + var firstChar = metaParts[i].substr(0, 1); + if (metaParts[i].substr(len - 1, 1) == ';') + len--; + + if (firstChar != '"' && firstChar != "'") + continue; + + var metaString = metaParts[i].substr(1, metaParts[i].length - 3); + + var metaName = metaString.substr(0, metaString.indexOf(' ')); + if (metaName) { + var metaValue = metaString.substr(metaName.length + 1, metaString.length - metaName.length - 1); + + if (load.metadata[metaName] instanceof Array) + load.metadata[metaName].push(metaValue); + else if (!load.metadata[metaName]) + load.metadata[metaName] = metaValue; + } + } + } + // config meta overrides + setConfigMeta(this, load); + + return loaderTranslate.call(this, load); + } +} +/* + * 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 + * + * Works as a standalone extension, but benefits from having a more + * advanced __eval defined like in SystemJS polyfill-wrapper-end.js + * + * 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. + * + */ +function register(loader) { + if (typeof indexOf == 'undefined') + indexOf = Array.prototype.indexOf; + if (typeof __eval == 'undefined' || typeof document != 'undefined' && !document.addEventListener) + __eval = 0 || eval; // uglify breaks without the 0 || + + loader._extensions = loader._extensions || []; + loader._extensions.push(register); + + // define exec for easy evaluation of a load record (load.name, load.source, load.address) + // main feature is source maps support handling + var curSystem; + function exec(load) { + var loader = this; + // support sourceMappingURL (efficiently) + var sourceMappingURL; + var lastLineIndex = load.source.lastIndexOf('\n'); + if (lastLineIndex != -1) { + if (load.source.substr(lastLineIndex + 1, 21) == '//# sourceMappingURL=') { + sourceMappingURL = load.source.substr(lastLineIndex + 22, load.source.length - lastLineIndex - 22); + if (typeof toAbsoluteURL != 'undefined') + sourceMappingURL = toAbsoluteURL(load.address, sourceMappingURL); + } + } + + __eval(load.source, load.address, sourceMappingURL); + } + loader.__exec = exec; + + 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; + } + + /* + * 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.register for dynamic modules (3-4 params) - System.register([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. + * + */ + // loader.register sets loader.defined for declarative modules + var anonRegister; + var calledRegister; + function registerModule(name, deps, declare, execute) { + if (typeof name != 'string') { + execute = declare; + declare = deps; + deps = name; + name = null; + } + + calledRegister = true; + + var register; + + // dynamic + if (typeof declare == 'boolean') { + register = { + declarative: false, + deps: deps, + execute: execute, + executingRequire: declare + }; + } + else { + // ES6 declarative + register = { + declarative: true, + deps: deps, + declare: declare + }; + } + + // named register + if (name) { + register.name = name; + // we never overwrite an existing define + if (!(name in loader.defined)) + loader.defined[name] = register; + } + // anonymous register + else if (register.declarative) { + if (anonRegister) + throw new TypeError('Multiple anonymous System.register calls in the same module file.'); + anonRegister = register; + } + } + /* + * Registry side table - 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 System.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 + * + * Then for declarative only we track dynamic bindings with the records: + * - name + * - setters declarative setter functions + * - exports actual module values + * - 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 + * + */ + + function defineRegister(loader) { + if (loader.register) + return; + + loader.register = registerModule; + + if (!loader.defined) + loader.defined = {}; + + // script injection mode calls this function synchronously on load + var onScriptLoad = loader.onScriptLoad; + loader.onScriptLoad = function(load) { + onScriptLoad(load); + // anonymous define + if (anonRegister) + load.metadata.entry = anonRegister; + + if (calledRegister) { + load.metadata.format = load.metadata.format || 'register'; + load.metadata.registered = true; + } + } + } + + defineRegister(loader); + + 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 === undefined || depEntry.groupIndex < depGroupIndex) { + + // if already in a group, remove from the old group + if (depEntry.groupIndex !== undefined) { + 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 TypeError("Mixed dependency cycle detected"); + } + + depEntry.groupIndex = depGroupIndex; + } + + buildGroups(depEntry, loader, groups); + } + } + + function link(name, loader) { + var startEntry = loader.defined[name]; + + // 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 + var moduleRecords = {}; + function getOrCreateModuleRecord(name) { + return moduleRecords[name] || (moduleRecords[name] = { + name: name, + dependencies: [], + exports: {}, // 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 module = entry.module = getOrCreateModuleRecord(entry.name); + var exports = entry.module.exports; + + var declaration = entry.declare.call(loader.global, function(name, value) { + module.locked = true; + 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); + importerModule.setters[importerIndex](exports); + } + } + + module.locked = false; + return value; + }); + + 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) { + if (depEntry.module.exports && depEntry.module.exports.__esModule) + depExports = depEntry.module.exports; + else + depExports = { 'default': depEntry.module.exports, '__useDefault': true }; + } + // 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 the setter for this dependency + if (module.setters[i]) + module.setters[i](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, [], 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(loader.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); + } + throw new TypeError('Module ' + name + ' not declared as a dependency.'); + }, exports, module); + + if (output) + module.exports = output; + } + + /* + * 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, seen, loader) { + var entry = loader.defined[moduleName]; + + // 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, seen, loader); + } + } + + if (entry.evaluated) + return; + + entry.evaluated = true; + entry.module.execute.call(loader.global); + } + + // override the delete method to also clear the register caches + var loaderDelete = loader['delete']; + loader['delete'] = function(name) { + delete moduleRecords[name]; + return loaderDelete.call(this, name); + }; + + var registerRegEx = /System\.register/; + + var loaderFetch = loader.fetch; + loader.fetch = function(load) { + var loader = this; + defineRegister(loader); + if (loader.defined[load.name]) { + load.metadata.format = 'defined'; + return ''; + } + anonRegister = null; + calledRegister = false; + // the above get picked up by onScriptLoad + return loaderFetch.call(loader, load); + } + + var loaderTranslate = loader.translate; + loader.translate = function(load) { + this.register = registerModule; + + this.__exec = exec; + + load.metadata.deps = load.metadata.deps || []; + + // we run the meta detection here (register is after meta) + return Promise.resolve(loaderTranslate.call(this, load)).then(function(source) { + + // dont run format detection for globals shimmed + // ideally this should be in the global extension, but there is + // currently no neat way to separate it + if (load.metadata.init || load.metadata.exports) + load.metadata.format = load.metadata.format || 'global'; + + // run detection for register format + if (load.metadata.format == 'register' || !load.metadata.format && load.source.match(registerRegEx)) + load.metadata.format = 'register'; + return source; + }); + } + + + var loaderInstantiate = loader.instantiate; + loader.instantiate = function(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]; + entry.deps = entry.deps.concat(load.metadata.deps); + } + + // picked up already by a script injection + else if (load.metadata.entry) + entry = load.metadata.entry; + + // otherwise check if it is dynamic + else if (load.metadata.execute) { + entry = { + declarative: false, + deps: load.metadata.deps || [], + execute: load.metadata.execute, + executingRequire: load.metadata.executingRequire // NodeJS-style requires or not + }; + } + + // Contains System.register calls + else if (load.metadata.format == 'register') { + anonRegister = null; + calledRegister = false; + + var curSystem = loader.global.System; + + loader.global.System = loader; + + loader.__exec(load); + + loader.global.System = curSystem; + + if (anonRegister) + entry = anonRegister; + else + load.metadata.bundle = true; + + if (!entry && System.defined[load.name]) + entry = System.defined[load.name]; + + if (!calledRegister && !load.metadata.registered) + throw new TypeError(load.name + ' detected as System.register but didn\'t execute.'); + } + + // named bundles are just an empty module + if (!entry && load.metadata.format != 'es6') + return { + deps: load.metadata.deps, + execute: function() { + return loader.newModule({}); + } + }; + + // place this module onto defined for circular references + if (entry) + loader.defined[load.name] = entry; + + // no entry -> treat as ES6 + else + return loaderInstantiate.call(this, load); + + entry.deps = dedupe(entry.deps); + entry.name = load.name; + + // 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, loader); + + // now handle dependency execution in correct order + ensureEvaluated(load.name, [], loader); + + // remove from the registry + loader.defined[load.name] = undefined; + + var module = entry.module.exports; + + if (!module || !entry.declarative && module.__esModule !== true) + module = { 'default': module, __useDefault: true }; + + // return the defined module object + return loader.newModule(module); + } + }; + }); + } +} +/* + * Extension to detect ES6 and auto-load Traceur or Babel for processing + */ +function es6(loader) { + loader._extensions.push(es6); + + // good enough ES6 detection regex - format detections not designed to be accurate, but to handle the 99% use case + var es6RegEx = /(^\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*\./; + + var transpilerNormalized, transpilerRuntimeNormalized; + + var firstLoad = true; + + var nodeResolver = typeof process != 'undefined' && typeof require != 'undefined' && require.resolve; + + function configNodeGlobal(loader, module, nodeModule, wilcardDummy) { + loader.meta = loader.meta || {}; + var meta = loader.meta[module] = loader.meta[module] || {}; + meta.format = meta.format || 'global'; + if (!loader.paths[module]) { + var path = resolvePath(nodeModule, wilcardDummy); + if (path) { + loader.paths[module] = path; + } + } + } + + function resolvePath(nodeModule, wildcard) { + if (nodeResolver) { + var ext = wildcard ? '/package.json' : ''; + try { + var match = nodeResolver(nodeModule + ext); + return 'file:' + match.substr(0, match.length - ext.length) + (wildcard ? '/*.js' : ''); + } + catch(e) {} + } + } + + var loaderLocate = loader.locate; + loader.locate = function(load) { + var self = this; + if (firstLoad) { + if (self.transpiler == 'traceur') { + configNodeGlobal(self, 'traceur', 'traceur/bin/traceur.js'); + self.meta['traceur'].exports = 'traceur'; + configNodeGlobal(self, 'traceur-runtime', 'traceur/bin/traceur-runtime.js'); + } + else if (self.transpiler == 'babel') { + configNodeGlobal(self, 'babel', 'babel-core/browser.js'); + configNodeGlobal(self, 'babel/external-helpers', 'babel-core/external-helpers.js'); + configNodeGlobal(self, 'babel-runtime/*', 'babel-runtime', true); + } + firstLoad = false; + } + return loaderLocate.call(self, load); + }; + + var loaderTranslate = loader.translate; + loader.translate = function(load) { + var loader = this; + + return loaderTranslate.call(loader, load) + .then(function(source) { + + // detect ES6 + if (load.metadata.format == 'es6' || !load.metadata.format && source.match(es6RegEx)) { + load.metadata.format = 'es6'; + return source; + } + + if (load.metadata.format == 'register') { + if (!loader.global.$traceurRuntime && load.source.match(traceurRuntimeRegEx)) { + return loader['import']('traceur-runtime').then(function() { + return source; + }); + } + if (!loader.global.babelHelpers && load.source.match(babelHelpersRegEx)) { + return loader['import']('babel/external-helpers').then(function() { + return source; + }); + } + } + + // ensure Traceur doesn't clobber the System global + if (loader.transpiler == 'traceur') + return Promise.all([ + transpilerNormalized || (transpilerNormalized = loader.normalize(loader.transpiler)), + transpilerRuntimeNormalized || (transpilerRuntimeNormalized = loader.normalize(loader.transpiler + '-runtime')) + ]) + .then(function(normalized) { + if (load.name == normalized[0] || load.name == normalized[1]) + return '(function() { var curSystem = System; ' + source + '\nSystem = curSystem; })();'; + + return source; + }); + + return source; + }); + + }; + +} +/* + SystemJS Global Format + + Supports + metadata.deps + metadata.init + metadata.exports + + Also detects writes to the global object avoiding global collisions. + See the SystemJS readme global support section for further information. +*/ +function global(loader) { + + loader._extensions.push(global); + + function readGlobalProperty(p, value) { + var pParts = p.split('.'); + while (pParts.length) + value = value[pParts.shift()]; + return value; + } + + // bare minimum ignores for IE8 + var ignoredGlobalProps = ['sessionStorage', 'localStorage', 'clipboardData', 'frames', 'external']; + + var hasOwnProperty = Object.prototype.hasOwnProperty; + + function iterateGlobals(callback) { + if (Object.keys) + Object.keys(loader.global).forEach(callback); + else + for (var g in loader.global) { + if (!hasOwnProperty.call(loader.global, g)) + continue; + callback(g); + } + } + + function forEachGlobal(callback) { + iterateGlobals(function(globalName) { + if (indexOf.call(ignoredGlobalProps, globalName) != -1) + return; + try { + var value = loader.global[globalName]; + } + catch(e) { + ignoredGlobalProps.push(globalName); + } + callback(globalName, value); + }); + } + + function createHelpers(loader) { + if (loader.has('@@global-helpers')) + return; + + var moduleGlobals = {}; + + var globalSnapshot; + + loader.set('@@global-helpers', loader.newModule({ + prepareGlobal: function(moduleName, deps) { + // first, we add all the dependency modules to the global + for (var i = 0; i < deps.length; i++) { + var moduleGlobal = moduleGlobals[deps[i]]; + if (moduleGlobal) + for (var m in moduleGlobal) + loader.global[m] = moduleGlobal[m]; + } + + // now store a complete copy of the global object + // in order to detect changes + globalSnapshot = {}; + + forEachGlobal(function(name, value) { + globalSnapshot[name] = value; + }); + }, + retrieveGlobal: function(moduleName, exportName, init) { + var singleGlobal; + var multipleExports; + var exports = {}; + + // run init + if (init) + singleGlobal = init.call(loader.global); + + // check for global changes, creating the globalObject for the module + // if many globals, then a module object for those is created + // if one global, then that is the module directly + else if (exportName) { + var firstPart = exportName.split('.')[0]; + singleGlobal = readGlobalProperty(exportName, loader.global); + exports[firstPart] = loader.global[firstPart]; + } + + else { + forEachGlobal(function(name, value) { + if (globalSnapshot[name] === value) + return; + if (typeof value === 'undefined') + return; + exports[name] = value; + if (typeof singleGlobal !== 'undefined') { + if (!multipleExports && singleGlobal !== value) + multipleExports = true; + } + else { + singleGlobal = value; + } + }); + } + + moduleGlobals[moduleName] = exports; + + return multipleExports ? exports : singleGlobal; + } + })); + } + + createHelpers(loader); + + var loaderInstantiate = loader.instantiate; + loader.instantiate = function(load) { + var loader = this; + + createHelpers(loader); + + var exportName = load.metadata.exports; + + if (!load.metadata.format) + load.metadata.format = 'global'; + + // global is a fallback module format + if (load.metadata.format == 'global') { + load.metadata.execute = function(require, exports, module) { + + loader.get('@@global-helpers').prepareGlobal(module.id, load.metadata.deps); + + if (exportName) + load.source += $__globalName + '["' + exportName + '"] = ' + exportName + ';'; + + // disable module detection + var define = loader.global.define; + var require = loader.global.require; + + loader.global.define = undefined; + loader.global.module = undefined; + loader.global.exports = undefined; + + loader.__exec(load); + + loader.global.require = require; + loader.global.define = define; + + return loader.get('@@global-helpers').retrieveGlobal(module.id, exportName, load.metadata.init); + } + } + return loaderInstantiate.call(loader, load); + } +} +/* + SystemJS CommonJS Format +*/ +function cjs(loader) { + loader._extensions.push(cjs); + + // CJS Module Format + // require('...') || exports[''] = ... || exports.asd = ... || module.exports = ... + var cjsExportsRegEx = /(?:^\uFEFF?|[^$_a-zA-Z\xA0-\uFFFF.]|module\.)exports\s*(\[['"]|\.)|(?:^\uFEFF?|[^$_a-zA-Z\xA0-\uFFFF.])module\.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; + + function getCJSDeps(source) { + cjsRequireRegEx.lastIndex = 0; + + var deps = []; + + // remove comments from the source first, if not minified + if (source.length / source.split('\n').length < 200) + source = source.replace(commentRegEx, ''); + + var match; + + while (match = cjsRequireRegEx.exec(source)) + deps.push(match[1].substr(1, match[1].length - 2)); + + return deps; + } + + if (typeof location != 'undefined' && location.origin) + var curOrigin = location.protocol + '//' + location.hostname + (location.port ? ':' + location.port : ''); + + var loaderInstantiate = loader.instantiate; + loader.instantiate = function(load) { + + 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') { + load.metadata.deps = load.metadata.deps ? load.metadata.deps.concat(getCJSDeps(load.source)) : getCJSDeps(load.source); + + load.metadata.executingRequire = true; + + load.metadata.execute = function(require, exports, module) { + var dirname = (load.address || '').split('/'); + dirname.pop(); + dirname = dirname.join('/'); + + var address = load.address; + + if (curOrigin && address.substr(0, curOrigin.length) === curOrigin) { + address = address.substr(curOrigin.length); + dirname = dirname.substr(curOrigin.length); + } + else if (address.substr(0, 5) == 'file:') { + address = address.substr(5); + dirname = dirname.substr(5); + } + + // if on the server, remove the "file:" part from the dirname + if (System._nodeRequire) + dirname = dirname.substr(5); + + var globals = loader.global._g = { + global: loader.global, + exports: exports, + module: module, + require: require, + __filename: address, + __dirname: dirname + }; + + var source = '(function(global, exports, module, require, __filename, __dirname) { ' + load.source + + '\n}).call(_g.exports, _g.global, _g.exports, _g.module, _g.require, _g.__filename, _g.__dirname);'; + + // disable AMD detection + var define = loader.global.define; + loader.global.define = undefined; + + loader.__exec({ + name: load.name, + address: load.address, + source: source + }); + + loader.global.define = define; + + loader.global._g = undefined; + } + } + + return loaderInstantiate.call(this, load); + }; +} +/* + SystemJS AMD Format + Provides the AMD module format definition at System.format.amd + as well as a RequireJS-style require on System.require +*/ +function amd(loader) { + // by default we only enforce AMD noConflict mode in Node + var isNode = typeof module != 'undefined' && module.exports; + + loader._extensions.push(amd); + + // 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]*\))/; + 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) { + // 'this' is bound to the loader + var loader = this; + + // 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 (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 module = loader.get(names); + return module.__useDefault ? module['default'] : module; + } + + else + throw new TypeError('Invalid require'); + }; + loader.amdRequire = function() { + return require.apply(this, arguments); + }; + + function makeRequire(parentName, staticRequire, loader) { + return function(names, callback, errback) { + if (typeof names == 'string') { + if (typeof callback === 'function') + names = [names]; + else + return staticRequire(names); + } + return require.call(loader, names, callback, errback, { name: parentName }); + } + } + + // run once per loader + function generateDefine(loader) { + // script injection mode calls this function synchronously on load + var onScriptLoad = loader.onScriptLoad; + loader.onScriptLoad = function(load) { + onScriptLoad(load); + if (anonDefine || defineBundle) { + load.metadata.format = 'defined'; + load.metadata.registered = true; + } + + if (anonDefine) { + load.metadata.deps = load.metadata.deps ? load.metadata.deps.concat(anonDefine.deps) : anonDefine.deps; + load.metadata.execute = anonDefine.execute; + } + } + + 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']; + } + + 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); + + var factoryText = factory.toString(); + + deps = deps.concat(getCJSDeps(factoryText, requireIndex)); + } + + + if ((exportsIndex = indexOf.call(deps, 'exports')) != -1) + deps.splice(exportsIndex, 1); + + if ((moduleIndex = indexOf.call(deps, 'module')) != -1) + deps.splice(moduleIndex, 1); + + var define = { + deps: deps, + execute: function(require, exports, module) { + + var depValues = []; + for (var i = 0; i < deps.length; i++) + depValues.push(require(deps[i])); + + module.uri = loader.baseURL + 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) + depValues.splice(requireIndex, 0, makeRequire(module.id, require, loader)); + + // set global require to AMD require + var curRequire = global.require; + global.require = System.amdRequire; + + var output = factory.apply(global, depValues); + + global.require = curRequire; + + if (typeof output == 'undefined' && module) + output = module.exports; + + if (typeof output != 'undefined') + return output; + } + }; + + // anonymous define + if (!name) { + // already defined anonymously -> throw + if (anonDefine) + throw new TypeError('Multiple defines for anonymous module'); + anonDefine = define; + } + // named define + else { + // if it has no dependencies and we don't have any other + // defines, then let this be an anonymous define + if (deps.length == 0 && !anonDefine && !defineBundle) + anonDefine = define; + + // otherwise its a bundle only + else + anonDefine = null; + + // the above is just to support single modules of the form: + // define('jquery') + // still loading anonymously + // because it is done widely enough to be useful + + // note this is now a bundle + defineBundle = true; + + // define the module through the register registry + loader.register(name, define.deps, false, define.execute); + } + }; + define.amd = {}; + loader.amdDefine = define; + } + + var anonDefine; + // set to true if the current module turns out to be a named define bundle + var defineBundle; + + var oldModule, oldExports, oldDefine; + + // adds define as a global (potentially just temporarily) + function createDefine(loader) { + if (!loader.amdDefine) + generateDefine(loader); + + anonDefine = null; + defineBundle = null; + + // ensure no NodeJS environment detection + var global = loader.global; + + oldModule = global.module; + oldExports = global.exports; + oldDefine = global.define; + + global.module = undefined; + global.exports = undefined; + + if (global.define && global.define === loader.amdDefine) + return; + + global.define = loader.amdDefine; + } + + function removeDefine(loader) { + var global = loader.global; + global.define = oldDefine; + global.module = oldModule; + global.exports = oldExports; + } + + generateDefine(loader); + + if (loader.scriptLoader) { + var loaderFetch = loader.fetch; + loader.fetch = function(load) { + createDefine(this); + return loaderFetch.call(this, load); + } + } + + var loaderInstantiate = loader.instantiate; + loader.instantiate = function(load) { + var loader = this; + + if (load.metadata.format == 'amd' || !load.metadata.format && load.source.match(amdRegEx)) { + load.metadata.format = 'amd'; + + if (loader.execute !== false) { + createDefine(loader); + + loader.__exec(load); + + removeDefine(loader); + + if (!anonDefine && !defineBundle && !isNode) + throw new TypeError('AMD module ' + load.name + ' did not define'); + } + + if (anonDefine) { + load.metadata.deps = load.metadata.deps ? load.metadata.deps.concat(anonDefine.deps) : anonDefine.deps; + load.metadata.execute = anonDefine.execute; + } + } + + return loaderInstantiate.call(loader, load); + } +} +/* + SystemJS map support + + Provides map configuration through + System.map['jquery'] = 'some/module/map' + + As well as contextual map config through + System.map['bootstrap'] = { + jquery: 'some/module/map2' + } + + Note that this applies for subpaths, just like RequireJS + + jquery -> 'some/module/map' + jquery/path -> 'some/module/map/path' + bootstrap -> 'bootstrap' + + Inside any module name of the form 'bootstrap' or 'bootstrap/*' + jquery -> 'some/module/map2' + jquery/p -> 'some/module/map2/p' + + Maps are carefully applied from most specific contextual map, to least specific global map +*/ +function map(loader) { + loader.map = loader.map || {}; + + loader._extensions.push(map); + + // return if prefix parts (separated by '/') match the name + // eg prefixMatch('jquery/some/thing', 'jquery') -> true + // prefixMatch('jqueryhere/', 'jquery') -> false + function prefixMatch(name, prefix) { + if (name.length < prefix.length) + return false; + if (name.substr(0, prefix.length) != prefix) + return false; + if (name[prefix.length] && name[prefix.length] != '/') + return false; + return true; + } + + // get the depth of a given path + // eg pathLen('some/name') -> 2 + function pathLen(name) { + var len = 1; + for (var i = 0, l = name.length; i < l; i++) + if (name[i] === '/') + len++; + return len; + } + + function doMap(name, matchLen, map) { + return map + name.substr(matchLen); + } + + // given a relative-resolved module name and normalized parent name, + // apply the map configuration + function applyMap(name, parentName, loader) { + var curMatch, curMatchLength = 0; + var curParent, curParentMatchLength = 0; + var tmpParentLength, tmpPrefixLength; + var subPath; + var nameParts; + + // first find most specific contextual match + if (parentName) { + for (var p in loader.map) { + var curMap = loader.map[p]; + if (typeof curMap != 'object') + continue; + + // most specific parent match wins first + if (!prefixMatch(parentName, p)) + continue; + + tmpParentLength = pathLen(p); + if (tmpParentLength <= curParentMatchLength) + continue; + + for (var q in curMap) { + // most specific name match wins + if (!prefixMatch(name, q)) + continue; + tmpPrefixLength = pathLen(q); + if (tmpPrefixLength <= curMatchLength) + continue; + + curMatch = q; + curMatchLength = tmpPrefixLength; + curParent = p; + curParentMatchLength = tmpParentLength; + } + } + } + + // if we found a contextual match, apply it now + if (curMatch) + return doMap(name, curMatch.length, loader.map[curParent][curMatch]); + + // now do the global map + for (var p in loader.map) { + var curMap = loader.map[p]; + if (typeof curMap != 'string') + continue; + + if (!prefixMatch(name, p)) + continue; + + var tmpPrefixLength = pathLen(p); + + if (tmpPrefixLength <= curMatchLength) + continue; + + curMatch = p; + curMatchLength = tmpPrefixLength; + } + + if (curMatch) + return doMap(name, curMatch.length, loader.map[curMatch]); + + return name; + } + + var loaderNormalize = loader.normalize; + loader.normalize = function(name, parentName, parentAddress) { + var loader = this; + if (!loader.map) + loader.map = {}; + + var isPackage = false; + if (name.substr(name.length - 1, 1) == '/') { + isPackage = true; + name += '#'; + } + + return Promise.resolve(loaderNormalize.call(loader, name, parentName, parentAddress)) + .then(function(name) { + name = applyMap(name, parentName, loader); + + // Normalize "module/" into "module/module" + // Convenient for packages + if (isPackage) { + var nameParts = name.split('/'); + nameParts.pop(); + var pkgName = nameParts.pop(); + nameParts.push(pkgName); + nameParts.push(pkgName); + name = nameParts.join('/'); + } + + return name; + }); + } +} +/* + SystemJS Plugin Support + + Supports plugin syntax with "!" + + 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 plugins(loader) { + if (typeof indexOf == 'undefined') + indexOf = Array.prototype.indexOf; + + loader._extensions.push(plugins); + + var loaderNormalize = loader.normalize; + loader.normalize = function(name, parentName, parentAddress) { + var loader = this; + // if parent is a plugin, normalize against the parent plugin argument only + var parentPluginIndex; + if (parentName && (parentPluginIndex = parentName.indexOf('!')) != -1) + parentName = parentName.substr(0, parentPluginIndex); + + return Promise.resolve(loaderNormalize.call(loader, name, parentName, parentAddress)) + .then(function(name) { + // if this is a plugin, normalize the plugin name and the argument + var pluginIndex = name.lastIndexOf('!'); + if (pluginIndex != -1) { + var argumentName = name.substr(0, pluginIndex); + + // plugin name is part after "!" or the extension itself + var pluginName = name.substr(pluginIndex + 1) || argumentName.substr(argumentName.lastIndexOf('.') + 1); + + // normalize the plugin name relative to the same parent + return new Promise(function(resolve) { + resolve(loader.normalize(pluginName, parentName, parentAddress)); + }) + // normalize the plugin argument + .then(function(_pluginName) { + pluginName = _pluginName; + return loader.normalize(argumentName, parentName, parentAddress); + }) + .then(function(argumentName) { + return argumentName + '!' + pluginName; + }); + } + + // standard normalization + return name; + }); + }; + + var loaderLocate = loader.locate; + loader.locate = function(load) { + var loader = this; + + var name = load.name; + + // only fetch the plugin itself if this name isn't defined + if (this.defined && this.defined[name]) + return loaderLocate.call(this, load); + + // plugin + var pluginIndex = name.lastIndexOf('!'); + if (pluginIndex != -1) { + var pluginName = name.substr(pluginIndex + 1); + + // the name to locate is the plugin argument only + load.name = name.substr(0, pluginIndex); + + var pluginLoader = loader.pluginLoader || loader; + + // load the plugin module + // NB ideally should use pluginLoader.load for normalized, + // but not currently working for some reason + return pluginLoader['import'](pluginName) + .then(function() { + var plugin = pluginLoader.get(pluginName); + plugin = plugin['default'] || plugin; + + // allow plugins to opt-out of build + if (plugin.build === false && loader.pluginLoader) + load.metadata.build = false; + + // store the plugin module itself on the metadata + load.metadata.plugin = plugin; + load.metadata.pluginName = pluginName; + load.metadata.pluginArgument = load.name; + + // run plugin locate if given + if (plugin.locate) + return plugin.locate.call(loader, load); + + // otherwise use standard locate without '.js' extension adding + else + return Promise.resolve(loader.locate(load)) + .then(function(address) { + return address.replace(/\.js$/, ''); + }); + }); + } + + return loaderLocate.call(this, load); + }; + + var loaderFetch = loader.fetch; + loader.fetch = function(load) { + var loader = this; + // ignore fetching build = false unless in a plugin loader + if (load.metadata.build === false && loader.pluginLoader) + return ''; + else if (load.metadata.plugin && load.metadata.plugin.fetch && !load.metadata.pluginFetchCalled) { + load.metadata.pluginFetchCalled = true; + return load.metadata.plugin.fetch.call(loader, load, loaderFetch); + } + else + return loaderFetch.call(loader, load); + } + + var loaderTranslate = loader.translate; + loader.translate = function(load) { + var loader = this; + if (load.metadata.plugin && load.metadata.plugin.translate) + return Promise.resolve(load.metadata.plugin.translate.call(loader, load)).then(function(result) { + if (typeof result == 'string') + load.source = result; + return loaderTranslate.call(loader, load); + }); + else + return loaderTranslate.call(loader, load); + } + + var loaderInstantiate = loader.instantiate; + loader.instantiate = function(load) { + var loader = this; + if (load.metadata.plugin && load.metadata.plugin.instantiate) + return Promise.resolve(load.metadata.plugin.instantiate.call(loader, load)).then(function(result) { + load.metadata.format = 'defined'; + load.metadata.execute = function() { + return result; + }; + return loaderInstantiate.call(loader, load); + }); + else if (load.metadata.plugin && load.metadata.plugin.build === false) { + load.metadata.format = 'defined'; + load.metadata.deps.push(load.metadata.pluginName); + load.metadata.execute = function() { + return loader.newModule({}); + }; + return loaderInstantiate.call(loader, load); + } + else + return loaderInstantiate.call(loader, load); + } + +} +/* + System bundles + + Allows a bundle module to be specified which will be dynamically + loaded before trying to load a given module. + + For example: + System.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(loader) { + if (typeof indexOf == 'undefined') + indexOf = Array.prototype.indexOf; + + loader._extensions.push(bundles); + + // 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 System.bundles['mybundle'] = ['jquery', 'bootstrap/js/bootstrap'] + loader.bundles = loader.bundles || {}; + + var loadedBundles = []; + + function loadFromBundle(loader, bundle) { + // we do manual normalization in case the bundle is mapped + // this is so we can still know the normalized name is a bundle + return Promise.resolve(loader.normalize(bundle)) + .then(function(normalized) { + if (indexOf.call(loadedBundles, normalized) == -1) { + loadedBundles.push(normalized); + loader.bundles[normalized] = loader.bundles[normalized] || loader.bundles[bundle]; + + // note this module is a bundle in the meta + loader.meta = loader.meta || {}; + loader.meta[normalized] = loader.meta[normalized] || {}; + loader.meta[normalized].bundle = true; + } + return loader.load(normalized); + }) + .then(function() { + return ''; + }); + } + + var loaderFetch = loader.fetch; + loader.fetch = function(load) { + var loader = this; + if (loader.trace) + return loaderFetch.call(this, load); + if (!loader.bundles) + loader.bundles = {}; + + // check what bundles we've already loaded + for (var i = 0; i < loadedBundles.length; i++) { + if (indexOf.call(loader.bundles[loadedBundles[i]], load.name) == -1) + continue; + + return loadFromBundle(loader, loadedBundles[i]); + } + + // if this module is in a bundle, load the bundle first then + for (var b in loader.bundles) { + if (indexOf.call(loader.bundles[b], load.name) == -1) + continue; + + return loadFromBundle(loader, b); + } + + return loaderFetch.call(this, load); + } +} +/* + SystemJS Semver Version Addon + + 1. Uses Semver convention for major and minor forms + + Supports requesting a module from a package that contains a version suffix + with the following semver ranges: + module - any version + module@1 - major version 1, any minor (not prerelease) + module@1.2 - minor version 1.2, any patch (not prerelease) + module@1.2.3 - exact version + + It is assumed that these modules are provided by the server / file system. + + First checks the already-requested packages to see if there are any packages + that would match the same package and version range. + + This provides a greedy algorithm as a simple fix for sharing version-managed + dependencies as much as possible, which can later be optimized through version + hint configuration created out of deeper version tree analysis. + + 2. Semver-compatibility syntax (caret operator - ^) + + Compatible version request support is then also provided for: + + module@^1.2.3 - module@1, >=1.2.3 + module@^1.2 - module@1, >=1.2.0 + module@^1 - module@1 + module@^0.5.3 - module@0.5, >= 0.5.3 + module@^0.0.1 - module@0.0.1 + + The ^ symbol is always normalized out to a normal version request. + + This provides comprehensive semver compatibility. + + 3. System.versions version hints and version report + + Note this addon should be provided after all other normalize overrides. + + The full list of versions can be found at System.versions providing an insight + into any possible version forks. + + It is also possible to create version solution hints on the System global: + + System.versions = { + jquery: ['1.9.2', '2.0.3'], + bootstrap: '3.0.1' + }; + + Versions can be an array or string for a single version. + + When a matching semver request is made (jquery@1.9, jquery@1, bootstrap@3) + they will be converted to the latest version match contained here, if present. + + Prereleases in this versions list are also allowed to satisfy ranges when present. +*/ + +function versions(loader) { + if (typeof indexOf == 'undefined') + indexOf = Array.prototype.indexOf; + + loader._extensions.push(versions); + + var semverRegEx = /^(\d+)(?:\.(\d+)(?:\.(\d+)(?:-([\da-z-]+(?:\.[\da-z-]+)*)(?:\+([\da-z-]+(?:\.[\da-z-]+)*))?)?)?)?$/i; + var numRegEx = /^\d+$/; + + function toInt(num) { + return parseInt(num, 10); + } + + function parseSemver(v) { + var semver = v.match(semverRegEx); + if (!semver) + return { + tag: v + }; + else + return { + major: toInt(semver[1]), + minor: toInt(semver[2]), + patch: toInt(semver[3]), + pre: semver[4] && semver[4].split('.') + }; + } + + var parts = ['major', 'minor', 'patch']; + function semverCompareParsed(v1, v2) { + // not semvers - tags have equal precedence + if (v1.tag && v2.tag) + return 0; + + // semver beats non-semver + if (v1.tag) + return -1; + if (v2.tag) + return 1; + + // compare version numbers + for (var i = 0; i < parts.length; i++) { + var part = parts[i]; + var part1 = v1[part]; + var part2 = v2[part]; + if (part1 == part2) + continue; + if (isNaN(part1)) + return -1; + if (isNaN(part2)) + return 1; + return part1 > part2 ? 1 : -1; + } + + if (!v1.pre && !v2.pre) + return 0; + + if (!v1.pre) + return 1; + if (!v2.pre) + return -1; + + // prerelease comparison + for (var i = 0, l = Math.min(v1.pre.length, v2.pre.length); i < l; i++) { + if (v1.pre[i] == v2.pre[i]) + continue; + + var isNum1 = v1.pre[i].match(numRegEx); + var isNum2 = v2.pre[i].match(numRegEx); + + // numeric has lower precedence + if (isNum1 && !isNum2) + return -1; + if (isNum2 && !isNum1) + return 1; + + // compare parts + if (isNum1 && isNum2) + return toInt(v1.pre[i]) > toInt(v2.pre[i]) ? 1 : -1; + else + return v1.pre[i] > v2.pre[i] ? 1 : -1; + } + + if (v1.pre.length == v2.pre.length) + return 0; + + // more pre-release fields win if equal + return v1.pre.length > v2.pre.length ? 1 : -1; + } + + // match against a parsed range object + // saves operation repetition + // doesn't support tags + // if not semver or fuzzy, assume exact + function matchParsed(range, version) { + var rangeVersion = range.version; + + if (rangeVersion.tag) + return rangeVersion.tag == version.tag; + + // if the version is less than the range, it's not a match + if (semverCompareParsed(rangeVersion, version) == 1) + return false; + + // now we just have to check that the version isn't too high for the range + if (isNaN(version.minor) || isNaN(version.patch)) + return false; + + // if the version has a prerelease, ensure the range version has a prerelease in it + // and that we match the range version up to the prerelease exactly + if (version.pre) { + if (!(rangeVersion.major == version.major && rangeVersion.minor == version.minor && rangeVersion.patch == version.patch)) + return false; + return range.semver || range.fuzzy || rangeVersion.pre.join('.') == version.pre.join('.'); + } + + // check semver range + if (range.semver) { + // ^0 + if (rangeVersion.major == 0 && isNaN(rangeVersion.minor)) + return version.major < 1; + // ^1.. + else if (rangeVersion.major >= 1) + return rangeVersion.major == version.major; + // ^0.1, ^0.2 + else if (rangeVersion.minor >= 1) + return rangeVersion.minor == version.minor; + // ^0.0.0 + else + return (rangeVersion.patch || 0) == version.patch; + } + + // check fuzzy range + if (range.fuzzy) + return version.major == rangeVersion.major && version.minor < (rangeVersion.minor || 0) + 1; + + // exact match + // eg 001.002.003 matches 1.2.3 + return !rangeVersion.pre && rangeVersion.major == version.major && rangeVersion.minor == version.minor && rangeVersion.patch == version.patch; + } + + /* + * semver - is this a semver range + * fuzzy - is this a fuzzy range + * version - the parsed version object + */ + function parseRange(range) { + var rangeObj = {}; + + ((rangeObj.semver = range.substr(0, 1) == '^') + || (rangeObj.fuzzy = range.substr(0, 1) == '~') + ) && (range = range.substr(1)); + + var rangeVersion = rangeObj.version = parseSemver(range); + + if (rangeVersion.tag) + return rangeObj; + + // 0, 0.1 behave like ~0, ~0.1 + if (!rangeObj.fuzzy && !rangeObj.semver && (isNaN(rangeVersion.minor) || isNaN(rangeVersion.patch))) + rangeObj.fuzzy = true; + + // ~1, ~0 behave like ^1, ^0 + if (rangeObj.fuzzy && isNaN(rangeVersion.minor)) { + rangeObj.semver = true; + rangeObj.fuzzy = false; + } + + // ^0.0 behaves like ~0.0 + if (rangeObj.semver && !isNaN(rangeVersion.minor) && isNaN(rangeVersion.patch)) { + rangeObj.semver = false; + rangeObj.fuzzy = true; + } + + return rangeObj; + } + + function semverCompare(v1, v2) { + return semverCompareParsed(parseSemver(v1), parseSemver(v2)); + } + + loader.versions = loader.versions || {}; + + var loaderNormalize = loader.normalize; + // NOW use modified match algorithm if possible + loader.normalize = function(name, parentName, parentAddress) { + if (!this.versions) + this.versions = {}; + var packageVersions = this.versions; + + // strip the version before applying map config + var stripVersion, stripSubPathLength; + var versionIndex = name.indexOf('!') != -1 ? 0 : name.lastIndexOf('@'); + if (versionIndex > 0) { + var parts = name.substr(versionIndex + 1, name.length - versionIndex - 1).split('/'); + stripVersion = parts[0]; + stripSubPathLength = parts.length; + name = name.substr(0, versionIndex) + name.substr(versionIndex + stripVersion.length + 1, name.length - versionIndex - stripVersion.length - 1); + } + + // run all other normalizers first + return Promise.resolve(loaderNormalize.call(this, name, parentName, parentAddress)).then(function(normalized) { + + var index = normalized.indexOf('!') != -1 ? 0 : normalized.indexOf('@'); + + // if we stripped a version, and it still has no version, add it back + if (stripVersion && (index == -1 || index == 0)) { + var parts = normalized.split('/'); + parts[parts.length - stripSubPathLength] += '@' + stripVersion; + normalized = parts.join('/'); + index = normalized.indexOf('@'); + } + + // see if this module corresponds to a package already in our versioned packages list + + // no version specified - check against the list (given we don't know the package name) + var nextChar, versions; + if (index == -1 || index == 0) { + for (var p in packageVersions) { + versions = packageVersions[p]; + if (normalized.substr(0, p.length) != p) + continue; + + nextChar = normalized.substr(p.length, 1); + + if (nextChar && nextChar != '/') + continue; + + // match -> take latest version + return p + '@' + (typeof versions == 'string' ? versions : versions[versions.length - 1]) + normalized.substr(p.length); + } + return normalized; + } + + // get the version info + var packageName = normalized.substr(0, index); + var range = normalized.substr(index + 1).split('/')[0]; + var rangeLength = range.length; + var parsedRange = parseRange(normalized.substr(index + 1).split('/')[0]); + versions = packageVersions[normalized.substr(0, index)] || []; + if (typeof versions == 'string') + versions = [versions]; + + // find a match in our version list + for (var i = versions.length - 1; i >= 0; i--) { + if (matchParsed(parsedRange, parseSemver(versions[i]))) + return packageName + '@' + versions[i] + normalized.substr(index + rangeLength + 1); + } + + // no match found -> send a request to the server + var versionRequest; + if (parsedRange.semver) { + versionRequest = parsedRange.version.major == 0 && !isNaN(parsedRange.version.minor) ? '0.' + parsedRange.version.minor : parsedRange.version.major; + } + else if (parsedRange.fuzzy) { + versionRequest = parsedRange.version.major + '.' + parsedRange.version.minor; + } + else { + versionRequest = range; + versions.push(range); + versions.sort(semverCompare); + packageVersions[packageName] = versions.length == 1 ? versions[0] : versions; + } + + return packageName + '@' + versionRequest + normalized.substr(index + rangeLength + 1); + }); + } +} +/* + * 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: + * System.depCache = { + * 'app': ['normalized', 'deps'], + * 'normalized': ['another'], + * 'deps': ['tree'] + * }; + * + * System.import('app') + * // simultaneously starts loading all of: + * // 'normalized', 'deps', 'another', 'tree' + * // before "app" source is even loaded + */ + +function depCache(loader) { + loader.depCache = loader.depCache || {}; + + loader._extensions.push(depCache); + + var loaderLocate = loader.locate; + loader.locate = function(load) { + var loader = this; + + if (!loader.depCache) + loader.depCache = {}; + + // 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.load(deps[i]); + + return loaderLocate.call(loader, load); + } +} + +core(System); +meta(System); +register(System); +es6(System); +global(System); +cjs(System); +amd(System); +map(System); +plugins(System); +bundles(System); +versions(System); +depCache(System); + +}; + +var $__curScript, __eval; + +(function() { + + var doEval; + + __eval = function(source, address, sourceMap) { + source += '\n//# sourceURL=' + address + (sourceMap ? '\n//# sourceMappingURL=' + sourceMap : ''); + + try { + doEval(source); + } + catch(e) { + var msg = 'Error evaluating ' + address + '\n'; + if (e instanceof Error) + e.message = msg + e.message; + else + e = msg + e; + throw e; + } + }; + + if (typeof document != 'undefined') { + var head; + + var scripts = document.getElementsByTagName('script'); + $__curScript = scripts[scripts.length - 1]; + + // globally scoped eval for the browser + doEval = function(source) { + if (!head) + head = document.head || document.body || document.documentElement; + + var script = document.createElement('script'); + script.text = source; + var onerror = window.onerror; + var e; + window.onerror = function(_e) { + e = _e; + } + head.appendChild(script); + head.removeChild(script); + window.onerror = onerror; + if (e) + throw e; + } + + if (!$__global.System || !$__global.LoaderPolyfill) { + // determine the current script path as the base path + var curPath = $__curScript.src; + var basePath = curPath.substr(0, curPath.lastIndexOf('/') + 1); + document.write( + '<' + 'script type="text/javascript" src="' + basePath + 'es6-module-loader.js" data-init="upgradeSystemLoader">' + '<' + '/script>' + ); + } + else { + $__global.upgradeSystemLoader(); + } + } + else if (typeof importScripts != 'undefined') { + doEval = function(source) { + try { + eval(source); + } catch(e) { + throw e; + } + }; + + if (!$__global.System || !$__global.LoaderPolyfill) { + var basePath = ''; + try { + throw new Error('Get worker base path via error stack'); + } catch (e) { + e.stack.replace(/(?:at|@).*(http.+):[\d]+:[\d]+/, function (m, url) { + basePath = url.replace(/\/[^\/]*$/, '/'); + }); + } + importScripts(basePath + 'es6-module-loader.js'); + $__global.upgradeSystemLoader(); + } else { + $__global.upgradeSystemLoader(); + } + } + else { + var es6ModuleLoader = require('es6-module-loader'); + $__global.System = es6ModuleLoader.System; + $__global.Loader = es6ModuleLoader.Loader; + $__global.upgradeSystemLoader(); + module.exports = $__global.System; + + // global scoped eval for node + var vm = require('vm'); + doEval = function(source, address, sourceMap) { + vm.runInThisContext(source); + } + } +})(); + +})(typeof window != 'undefined' ? window : (typeof global != 'undefined' ? global : self), +typeof window != 'undefined' ? 'window' : (typeof global != 'undefined' ? 'global' : 'self')); diff --git a/scripts/component/traceur-runtime.js b/scripts/component/traceur-runtime.js new file mode 100644 index 0000000000..050892c11c --- /dev/null +++ b/scripts/component/traceur-runtime.js @@ -0,0 +1,3424 @@ +(function(global) { + 'use strict'; + if (global.$traceurRuntime) { + return ; + } + var $Object = Object; + var $TypeError = TypeError; + var $create = $Object.create; + var $defineProperties = $Object.defineProperties; + var $defineProperty = $Object.defineProperty; + var $freeze = $Object.freeze; + var $getOwnPropertyDescriptor = $Object.getOwnPropertyDescriptor; + var $getOwnPropertyNames = $Object.getOwnPropertyNames; + var $keys = $Object.keys; + var $hasOwnProperty = $Object.prototype.hasOwnProperty; + var $toString = $Object.prototype.toString; + var $preventExtensions = Object.preventExtensions; + var $seal = Object.seal; + var $isExtensible = Object.isExtensible; + var $apply = Function.prototype.call.bind(Function.prototype.apply); + function $bind(operand, thisArg, args) { + var argArray = [thisArg]; + for (var i = 0; i < args.length; i++) { + argArray[i + 1] = args[i]; + } + var func = $apply(Function.prototype.bind, operand, argArray); + return func; + } + function $construct(func, argArray) { + var object = new ($bind(func, null, argArray)); + return object; + } + var counter = 0; + function newUniqueString() { + return '__$' + Math.floor(Math.random() * 1e9) + '$' + ++counter + '$__'; + } + var privateNames = $create(null); + function isPrivateName(s) { + return privateNames[s]; + } + function createPrivateName() { + var s = newUniqueString(); + privateNames[s] = true; + return s; + } + var CONTINUATION_TYPE = Object.create(null); + function createContinuation(operand, thisArg, argsArray) { + return [CONTINUATION_TYPE, operand, thisArg, argsArray]; + } + function isContinuation(object) { + return object && object[0] === CONTINUATION_TYPE; + } + var isTailRecursiveName = null; + function setupProperTailCalls() { + isTailRecursiveName = createPrivateName(); + Function.prototype.call = initTailRecursiveFunction(function call(thisArg) { + var result = tailCall(function(thisArg) { + var argArray = []; + for (var i = 1; i < arguments.length; ++i) { + argArray[i - 1] = arguments[i]; + } + var continuation = createContinuation(this, thisArg, argArray); + return continuation; + }, this, arguments); + return result; + }); + Function.prototype.apply = initTailRecursiveFunction(function apply(thisArg, argArray) { + var result = tailCall(function(thisArg, argArray) { + var continuation = createContinuation(this, thisArg, argArray); + return continuation; + }, this, arguments); + return result; + }); + } + function initTailRecursiveFunction(func) { + if (isTailRecursiveName === null) { + setupProperTailCalls(); + } + func[isTailRecursiveName] = true; + return func; + } + function isTailRecursive(func) { + return !!func[isTailRecursiveName]; + } + function tailCall(func, thisArg, argArray) { + var continuation = argArray[0]; + if (isContinuation(continuation)) { + continuation = $apply(func, thisArg, continuation[3]); + return continuation; + } + continuation = createContinuation(func, thisArg, argArray); + while (true) { + if (isTailRecursive(func)) { + continuation = $apply(func, continuation[2], [continuation]); + } else { + continuation = $apply(func, continuation[2], continuation[3]); + } + if (!isContinuation(continuation)) { + return continuation; + } + func = continuation[1]; + } + } + function construct() { + var object; + if (isTailRecursive(this)) { + object = $construct(this, [createContinuation(null, null, arguments)]); + } else { + object = $construct(this, arguments); + } + return object; + } + var $traceurRuntime = { + initTailRecursiveFunction: initTailRecursiveFunction, + call: tailCall, + continuation: createContinuation, + construct: construct + }; + (function() { + function nonEnum(value) { + return { + configurable: true, + enumerable: false, + value: value, + writable: true + }; + } + var method = nonEnum; + var symbolInternalProperty = newUniqueString(); + var symbolDescriptionProperty = newUniqueString(); + var symbolDataProperty = newUniqueString(); + var symbolValues = $create(null); + function isShimSymbol(symbol) { + return typeof symbol === 'object' && symbol instanceof SymbolValue; + } + function typeOf(v) { + if (isShimSymbol(v)) + return 'symbol'; + return typeof v; + } + function Symbol(description) { + var value = new SymbolValue(description); + if (!(this instanceof Symbol)) + return value; + throw new TypeError('Symbol cannot be new\'ed'); + } + $defineProperty(Symbol.prototype, 'constructor', nonEnum(Symbol)); + $defineProperty(Symbol.prototype, 'toString', method(function() { + var symbolValue = this[symbolDataProperty]; + return symbolValue[symbolInternalProperty]; + })); + $defineProperty(Symbol.prototype, 'valueOf', method(function() { + var symbolValue = this[symbolDataProperty]; + if (!symbolValue) + throw TypeError('Conversion from symbol to string'); + if (!getOption('symbols')) + return symbolValue[symbolInternalProperty]; + return symbolValue; + })); + function SymbolValue(description) { + var key = newUniqueString(); + $defineProperty(this, symbolDataProperty, {value: this}); + $defineProperty(this, symbolInternalProperty, {value: key}); + $defineProperty(this, symbolDescriptionProperty, {value: description}); + freeze(this); + symbolValues[key] = this; + } + $defineProperty(SymbolValue.prototype, 'constructor', nonEnum(Symbol)); + $defineProperty(SymbolValue.prototype, 'toString', { + value: Symbol.prototype.toString, + enumerable: false + }); + $defineProperty(SymbolValue.prototype, 'valueOf', { + value: Symbol.prototype.valueOf, + enumerable: false + }); + var hashProperty = createPrivateName(); + var hashPropertyDescriptor = {value: undefined}; + var hashObjectProperties = { + hash: {value: undefined}, + self: {value: undefined} + }; + var hashCounter = 0; + function getOwnHashObject(object) { + var hashObject = object[hashProperty]; + if (hashObject && hashObject.self === object) + return hashObject; + if ($isExtensible(object)) { + hashObjectProperties.hash.value = hashCounter++; + hashObjectProperties.self.value = object; + hashPropertyDescriptor.value = $create(null, hashObjectProperties); + $defineProperty(object, hashProperty, hashPropertyDescriptor); + return hashPropertyDescriptor.value; + } + return undefined; + } + function freeze(object) { + getOwnHashObject(object); + return $freeze.apply(this, arguments); + } + function preventExtensions(object) { + getOwnHashObject(object); + return $preventExtensions.apply(this, arguments); + } + function seal(object) { + getOwnHashObject(object); + return $seal.apply(this, arguments); + } + freeze(SymbolValue.prototype); + function isSymbolString(s) { + return symbolValues[s] || privateNames[s]; + } + function toProperty(name) { + if (isShimSymbol(name)) + return name[symbolInternalProperty]; + return name; + } + function removeSymbolKeys(array) { + var rv = []; + for (var i = 0; i < array.length; i++) { + if (!isSymbolString(array[i])) { + rv.push(array[i]); + } + } + return rv; + } + function getOwnPropertyNames(object) { + return removeSymbolKeys($getOwnPropertyNames(object)); + } + function keys(object) { + return removeSymbolKeys($keys(object)); + } + function getOwnPropertySymbols(object) { + var rv = []; + var names = $getOwnPropertyNames(object); + for (var i = 0; i < names.length; i++) { + var symbol = symbolValues[names[i]]; + if (symbol) { + rv.push(symbol); + } + } + return rv; + } + function getOwnPropertyDescriptor(object, name) { + return $getOwnPropertyDescriptor(object, toProperty(name)); + } + function hasOwnProperty(name) { + return $hasOwnProperty.call(this, toProperty(name)); + } + function getOption(name) { + return global.$traceurRuntime.options[name]; + } + function defineProperty(object, name, descriptor) { + if (isShimSymbol(name)) { + name = name[symbolInternalProperty]; + } + $defineProperty(object, name, descriptor); + return object; + } + function polyfillObject(Object) { + $defineProperty(Object, 'defineProperty', {value: defineProperty}); + $defineProperty(Object, 'getOwnPropertyNames', {value: getOwnPropertyNames}); + $defineProperty(Object, 'getOwnPropertyDescriptor', {value: getOwnPropertyDescriptor}); + $defineProperty(Object.prototype, 'hasOwnProperty', {value: hasOwnProperty}); + $defineProperty(Object, 'freeze', {value: freeze}); + $defineProperty(Object, 'preventExtensions', {value: preventExtensions}); + $defineProperty(Object, 'seal', {value: seal}); + $defineProperty(Object, 'keys', {value: keys}); + } + function exportStar(object) { + for (var i = 1; i < arguments.length; i++) { + var names = $getOwnPropertyNames(arguments[i]); + for (var j = 0; j < names.length; j++) { + var name = names[j]; + if (isSymbolString(name)) + continue; + (function(mod, name) { + $defineProperty(object, name, { + get: function() { + return mod[name]; + }, + enumerable: true + }); + })(arguments[i], names[j]); + } + } + return object; + } + function isObject(x) { + return x != null && (typeof x === 'object' || typeof x === 'function'); + } + function toObject(x) { + if (x == null) + throw $TypeError(); + return $Object(x); + } + function checkObjectCoercible(argument) { + if (argument == null) { + throw new TypeError('Value cannot be converted to an Object'); + } + return argument; + } + function polyfillSymbol(global, Symbol) { + if (!global.Symbol) { + global.Symbol = Symbol; + Object.getOwnPropertySymbols = getOwnPropertySymbols; + } + if (!global.Symbol.iterator) { + global.Symbol.iterator = Symbol('Symbol.iterator'); + } + if (!global.Symbol.observer) { + global.Symbol.observer = Symbol('Symbol.observer'); + } + } + function setupGlobals(global) { + polyfillSymbol(global, Symbol); + global.Reflect = global.Reflect || {}; + global.Reflect.global = global.Reflect.global || global; + polyfillObject(global.Object); + } + setupGlobals(global); + global.$traceurRuntime = { + call: tailCall, + checkObjectCoercible: checkObjectCoercible, + construct: construct, + continuation: createContinuation, + createPrivateName: createPrivateName, + defineProperties: $defineProperties, + defineProperty: $defineProperty, + exportStar: exportStar, + getOwnHashObject: getOwnHashObject, + getOwnPropertyDescriptor: $getOwnPropertyDescriptor, + getOwnPropertyNames: $getOwnPropertyNames, + initTailRecursiveFunction: initTailRecursiveFunction, + isObject: isObject, + isPrivateName: isPrivateName, + isSymbolString: isSymbolString, + keys: $keys, + options: {}, + setupGlobals: setupGlobals, + toObject: toObject, + toProperty: toProperty, + typeof: typeOf + }; + })(); +})(typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this); +(function() { + function buildFromEncodedParts(opt_scheme, opt_userInfo, opt_domain, opt_port, opt_path, opt_queryData, opt_fragment) { + var out = []; + if (opt_scheme) { + out.push(opt_scheme, ':'); + } + if (opt_domain) { + out.push('//'); + if (opt_userInfo) { + out.push(opt_userInfo, '@'); + } + out.push(opt_domain); + if (opt_port) { + out.push(':', opt_port); + } + } + if (opt_path) { + out.push(opt_path); + } + if (opt_queryData) { + out.push('?', opt_queryData); + } + if (opt_fragment) { + out.push('#', opt_fragment); + } + return out.join(''); + } + ; + var splitRe = new RegExp('^' + '(?:' + '([^:/?#.]+)' + ':)?' + '(?://' + '(?:([^/?#]*)@)?' + '([\\w\\d\\-\\u0100-\\uffff.%]*)' + '(?::([0-9]+))?' + ')?' + '([^?#]+)?' + '(?:\\?([^#]*))?' + '(?:#(.*))?' + '$'); + var ComponentIndex = { + SCHEME: 1, + USER_INFO: 2, + DOMAIN: 3, + PORT: 4, + PATH: 5, + QUERY_DATA: 6, + FRAGMENT: 7 + }; + function split(uri) { + return (uri.match(splitRe)); + } + function removeDotSegments(path) { + if (path === '/') + return '/'; + var leadingSlash = path[0] === '/' ? '/' : ''; + var trailingSlash = path.slice(-1) === '/' ? '/' : ''; + var segments = path.split('/'); + var out = []; + var up = 0; + for (var pos = 0; pos < segments.length; pos++) { + var segment = segments[pos]; + switch (segment) { + case '': + case '.': + break; + case '..': + if (out.length) + out.pop(); + else + up++; + break; + default: + out.push(segment); + } + } + if (!leadingSlash) { + while (up-- > 0) { + out.unshift('..'); + } + if (out.length === 0) + out.push('.'); + } + return leadingSlash + out.join('/') + trailingSlash; + } + function joinAndCanonicalizePath(parts) { + var path = parts[ComponentIndex.PATH] || ''; + path = removeDotSegments(path); + parts[ComponentIndex.PATH] = path; + return buildFromEncodedParts(parts[ComponentIndex.SCHEME], parts[ComponentIndex.USER_INFO], parts[ComponentIndex.DOMAIN], parts[ComponentIndex.PORT], parts[ComponentIndex.PATH], parts[ComponentIndex.QUERY_DATA], parts[ComponentIndex.FRAGMENT]); + } + function canonicalizeUrl(url) { + var parts = split(url); + return joinAndCanonicalizePath(parts); + } + function resolveUrl(base, url) { + var parts = split(url); + var baseParts = split(base); + if (parts[ComponentIndex.SCHEME]) { + return joinAndCanonicalizePath(parts); + } else { + parts[ComponentIndex.SCHEME] = baseParts[ComponentIndex.SCHEME]; + } + for (var i = ComponentIndex.SCHEME; i <= ComponentIndex.PORT; i++) { + if (!parts[i]) { + parts[i] = baseParts[i]; + } + } + if (parts[ComponentIndex.PATH][0] == '/') { + return joinAndCanonicalizePath(parts); + } + var path = baseParts[ComponentIndex.PATH]; + var index = path.lastIndexOf('/'); + path = path.slice(0, index + 1) + parts[ComponentIndex.PATH]; + parts[ComponentIndex.PATH] = path; + return joinAndCanonicalizePath(parts); + } + function isAbsolute(name) { + if (!name) + return false; + if (name[0] === '/') + return true; + var parts = split(name); + if (parts[ComponentIndex.SCHEME]) + return true; + return false; + } + $traceurRuntime.canonicalizeUrl = canonicalizeUrl; + $traceurRuntime.isAbsolute = isAbsolute; + $traceurRuntime.removeDotSegments = removeDotSegments; + $traceurRuntime.resolveUrl = resolveUrl; +})(); +(function(global) { + 'use strict'; + var $__1 = $traceurRuntime, + canonicalizeUrl = $__1.canonicalizeUrl, + resolveUrl = $__1.resolveUrl, + isAbsolute = $__1.isAbsolute; + var moduleInstantiators = Object.create(null); + var baseURL; + if (global.location && global.location.href) + baseURL = resolveUrl(global.location.href, './'); + else + baseURL = ''; + function UncoatedModuleEntry(url, uncoatedModule) { + this.url = url; + this.value_ = uncoatedModule; + } + function ModuleEvaluationError(erroneousModuleName, cause) { + this.message = this.constructor.name + ': ' + this.stripCause(cause) + ' in ' + erroneousModuleName; + if (!(cause instanceof ModuleEvaluationError) && cause.stack) + this.stack = this.stripStack(cause.stack); + else + this.stack = ''; + } + ModuleEvaluationError.prototype = Object.create(Error.prototype); + ModuleEvaluationError.prototype.constructor = ModuleEvaluationError; + ModuleEvaluationError.prototype.stripError = function(message) { + return message.replace(/.*Error:/, this.constructor.name + ':'); + }; + ModuleEvaluationError.prototype.stripCause = function(cause) { + if (!cause) + return ''; + if (!cause.message) + return cause + ''; + return this.stripError(cause.message); + }; + ModuleEvaluationError.prototype.loadedBy = function(moduleName) { + this.stack += '\n loaded by ' + moduleName; + }; + ModuleEvaluationError.prototype.stripStack = function(causeStack) { + var stack = []; + causeStack.split('\n').some((function(frame) { + if (/UncoatedModuleInstantiator/.test(frame)) + return true; + stack.push(frame); + })); + stack[0] = this.stripError(stack[0]); + return stack.join('\n'); + }; + function beforeLines(lines, number) { + var result = []; + var first = number - 3; + if (first < 0) + first = 0; + for (var i = first; i < number; i++) { + result.push(lines[i]); + } + return result; + } + function afterLines(lines, number) { + var last = number + 1; + if (last > lines.length - 1) + last = lines.length - 1; + var result = []; + for (var i = number; i <= last; i++) { + result.push(lines[i]); + } + return result; + } + function columnSpacing(columns) { + var result = ''; + for (var i = 0; i < columns - 1; i++) { + result += '-'; + } + return result; + } + function UncoatedModuleInstantiator(url, func) { + UncoatedModuleEntry.call(this, url, null); + this.func = func; + } + UncoatedModuleInstantiator.prototype = Object.create(UncoatedModuleEntry.prototype); + UncoatedModuleInstantiator.prototype.getUncoatedModule = function() { + if (this.value_) + return this.value_; + try { + var relativeRequire; + if (typeof $traceurRuntime !== undefined && $traceurRuntime.require) { + relativeRequire = $traceurRuntime.require.bind(null, this.url); + } + return this.value_ = this.func.call(global, relativeRequire); + } catch (ex) { + if (ex instanceof ModuleEvaluationError) { + ex.loadedBy(this.url); + throw ex; + } + if (ex.stack) { + var lines = this.func.toString().split('\n'); + var evaled = []; + ex.stack.split('\n').some(function(frame) { + if (frame.indexOf('UncoatedModuleInstantiator.getUncoatedModule') > 0) + return true; + var m = /(at\s[^\s]*\s).*>:(\d*):(\d*)\)/.exec(frame); + if (m) { + var line = parseInt(m[2], 10); + evaled = evaled.concat(beforeLines(lines, line)); + evaled.push(columnSpacing(m[3]) + '^'); + evaled = evaled.concat(afterLines(lines, line)); + evaled.push('= = = = = = = = ='); + } else { + evaled.push(frame); + } + }); + ex.stack = evaled.join('\n'); + } + throw new ModuleEvaluationError(this.url, ex); + } + }; + function getUncoatedModuleInstantiator(name) { + if (!name) + return ; + var url = ModuleStore.normalize(name); + return moduleInstantiators[url]; + } + ; + var moduleInstances = Object.create(null); + var liveModuleSentinel = {}; + function Module(uncoatedModule) { + var isLive = arguments[1]; + var coatedModule = Object.create(null); + Object.getOwnPropertyNames(uncoatedModule).forEach((function(name) { + var getter, + value; + if (isLive === liveModuleSentinel) { + var descr = Object.getOwnPropertyDescriptor(uncoatedModule, name); + if (descr.get) + getter = descr.get; + } + if (!getter) { + value = uncoatedModule[name]; + getter = function() { + return value; + }; + } + Object.defineProperty(coatedModule, name, { + get: getter, + enumerable: true + }); + })); + Object.preventExtensions(coatedModule); + return coatedModule; + } + var ModuleStore = { + normalize: function(name, refererName, refererAddress) { + if (typeof name !== 'string') + throw new TypeError('module name must be a string, not ' + typeof name); + if (isAbsolute(name)) + return canonicalizeUrl(name); + if (/[^\.]\/\.\.\//.test(name)) { + throw new Error('module name embeds /../: ' + name); + } + if (name[0] === '.' && refererName) + return resolveUrl(refererName, name); + return canonicalizeUrl(name); + }, + get: function(normalizedName) { + var m = getUncoatedModuleInstantiator(normalizedName); + if (!m) + return undefined; + var moduleInstance = moduleInstances[m.url]; + if (moduleInstance) + return moduleInstance; + moduleInstance = Module(m.getUncoatedModule(), liveModuleSentinel); + return moduleInstances[m.url] = moduleInstance; + }, + set: function(normalizedName, module) { + normalizedName = String(normalizedName); + moduleInstantiators[normalizedName] = new UncoatedModuleInstantiator(normalizedName, (function() { + return module; + })); + moduleInstances[normalizedName] = module; + }, + get baseURL() { + return baseURL; + }, + set baseURL(v) { + baseURL = String(v); + }, + registerModule: function(name, deps, func) { + var normalizedName = ModuleStore.normalize(name); + if (moduleInstantiators[normalizedName]) + throw new Error('duplicate module named ' + normalizedName); + moduleInstantiators[normalizedName] = new UncoatedModuleInstantiator(normalizedName, func); + }, + bundleStore: Object.create(null), + register: function(name, deps, func) { + if (!deps || !deps.length && !func.length) { + this.registerModule(name, deps, func); + } else { + this.bundleStore[name] = { + deps: deps, + execute: function() { + var $__0 = arguments; + var depMap = {}; + deps.forEach((function(dep, index) { + return depMap[dep] = $__0[index]; + })); + var registryEntry = func.call(this, depMap); + registryEntry.execute.call(this); + return registryEntry.exports; + } + }; + } + }, + getAnonymousModule: function(func) { + return new Module(func.call(global), liveModuleSentinel); + }, + getForTesting: function(name) { + var $__0 = this; + if (!this.testingPrefix_) { + Object.keys(moduleInstances).some((function(key) { + var m = /(traceur@[^\/]*\/)/.exec(key); + if (m) { + $__0.testingPrefix_ = m[1]; + return true; + } + })); + } + return this.get(this.testingPrefix_ + name); + } + }; + var moduleStoreModule = new Module({ModuleStore: ModuleStore}); + ModuleStore.set('@traceur/src/runtime/ModuleStore', moduleStoreModule); + ModuleStore.set('@traceur/src/runtime/ModuleStore.js', moduleStoreModule); + var setupGlobals = $traceurRuntime.setupGlobals; + $traceurRuntime.setupGlobals = function(global) { + setupGlobals(global); + }; + $traceurRuntime.ModuleStore = ModuleStore; + global.System = { + register: ModuleStore.register.bind(ModuleStore), + registerModule: ModuleStore.registerModule.bind(ModuleStore), + get: ModuleStore.get, + set: ModuleStore.set, + normalize: ModuleStore.normalize + }; + $traceurRuntime.getModuleImpl = function(name) { + var instantiator = getUncoatedModuleInstantiator(name); + return instantiator && instantiator.getUncoatedModule(); + }; +})(typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this); +System.registerModule("traceur-runtime@0.0.87/src/runtime/async.js", [], function() { + "use strict"; + var __moduleName = "traceur-runtime@0.0.87/src/runtime/async.js"; + if (typeof $traceurRuntime !== 'object') { + throw new Error('traceur runtime not found.'); + } + var $createPrivateName = $traceurRuntime.createPrivateName; + var $defineProperty = $traceurRuntime.defineProperty; + var $defineProperties = $traceurRuntime.defineProperties; + var $create = Object.create; + var thisName = $createPrivateName(); + var argsName = $createPrivateName(); + var observeName = $createPrivateName(); + function AsyncGeneratorFunction() {} + function AsyncGeneratorFunctionPrototype() {} + AsyncGeneratorFunction.prototype = AsyncGeneratorFunctionPrototype; + AsyncGeneratorFunctionPrototype.constructor = AsyncGeneratorFunction; + $defineProperty(AsyncGeneratorFunctionPrototype, 'constructor', {enumerable: false}); + var AsyncGeneratorContext = function AsyncGeneratorContext(observer) { + var $__0 = this; + this.decoratedObserver = $traceurRuntime.createDecoratedGenerator(observer, (function() { + $__0.done = true; + })); + this.done = false; + this.inReturn = false; + }; + ($traceurRuntime.createClass)(AsyncGeneratorContext, { + throw: function(error) { + if (!this.inReturn) { + throw error; + } + }, + yield: function(value) { + if (this.done) { + this.inReturn = true; + throw undefined; + } + var result; + try { + result = this.decoratedObserver.next(value); + } catch (e) { + this.done = true; + throw e; + } + if (result === undefined) { + return ; + } + if (result.done) { + this.done = true; + this.inReturn = true; + throw undefined; + } + return result.value; + }, + yieldFor: function(observable) { + var ctx = this; + return $traceurRuntime.observeForEach(observable[$traceurRuntime.toProperty(Symbol.observer)].bind(observable), function(value) { + if (ctx.done) { + this.return(); + return ; + } + var result; + try { + result = ctx.decoratedObserver.next(value); + } catch (e) { + ctx.done = true; + throw e; + } + if (result === undefined) { + return ; + } + if (result.done) { + ctx.done = true; + } + return result; + }); + } + }, {}); + AsyncGeneratorFunctionPrototype.prototype[Symbol.observer] = function(observer) { + var observe = this[observeName]; + var ctx = new AsyncGeneratorContext(observer); + $traceurRuntime.schedule((function() { + return observe(ctx); + })).then((function(value) { + if (!ctx.done) { + ctx.decoratedObserver.return(value); + } + })).catch((function(error) { + if (!ctx.done) { + ctx.decoratedObserver.throw(error); + } + })); + return ctx.decoratedObserver; + }; + $defineProperty(AsyncGeneratorFunctionPrototype.prototype, Symbol.observer, {enumerable: false}); + function initAsyncGeneratorFunction(functionObject) { + functionObject.prototype = $create(AsyncGeneratorFunctionPrototype.prototype); + functionObject.__proto__ = AsyncGeneratorFunctionPrototype; + return functionObject; + } + function createAsyncGeneratorInstance(observe, functionObject) { + for (var args = [], + $__2 = 2; $__2 < arguments.length; $__2++) + args[$__2 - 2] = arguments[$__2]; + var object = $create(functionObject.prototype); + object[thisName] = this; + object[argsName] = args; + object[observeName] = observe; + return object; + } + function observeForEach(observe, next) { + return new Promise((function(resolve, reject) { + var generator = observe({ + next: function(value) { + return next.call(generator, value); + }, + throw: function(error) { + reject(error); + }, + return: function(value) { + resolve(value); + } + }); + })); + } + function schedule(asyncF) { + return Promise.resolve().then(asyncF); + } + var generator = Symbol(); + var onDone = Symbol(); + var DecoratedGenerator = function DecoratedGenerator(_generator, _onDone) { + this[generator] = _generator; + this[onDone] = _onDone; + }; + ($traceurRuntime.createClass)(DecoratedGenerator, { + next: function(value) { + var result = this[generator].next(value); + if (result !== undefined && result.done) { + this[onDone].call(this); + } + return result; + }, + throw: function(error) { + this[onDone].call(this); + return this[generator].throw(error); + }, + return: function(value) { + this[onDone].call(this); + return this[generator].return(value); + } + }, {}); + function createDecoratedGenerator(generator, onDone) { + return new DecoratedGenerator(generator, onDone); + } + $traceurRuntime.initAsyncGeneratorFunction = initAsyncGeneratorFunction; + $traceurRuntime.createAsyncGeneratorInstance = createAsyncGeneratorInstance; + $traceurRuntime.observeForEach = observeForEach; + $traceurRuntime.schedule = schedule; + $traceurRuntime.createDecoratedGenerator = createDecoratedGenerator; + return {}; +}); +System.registerModule("traceur-runtime@0.0.87/src/runtime/classes.js", [], function() { + "use strict"; + var __moduleName = "traceur-runtime@0.0.87/src/runtime/classes.js"; + var $Object = Object; + var $TypeError = TypeError; + var $create = $Object.create; + var $defineProperties = $traceurRuntime.defineProperties; + var $defineProperty = $traceurRuntime.defineProperty; + var $getOwnPropertyDescriptor = $traceurRuntime.getOwnPropertyDescriptor; + var $getOwnPropertyNames = $traceurRuntime.getOwnPropertyNames; + var $getPrototypeOf = Object.getPrototypeOf; + var $__0 = Object, + getOwnPropertyNames = $__0.getOwnPropertyNames, + getOwnPropertySymbols = $__0.getOwnPropertySymbols; + function superDescriptor(homeObject, name) { + var proto = $getPrototypeOf(homeObject); + do { + var result = $getOwnPropertyDescriptor(proto, name); + if (result) + return result; + proto = $getPrototypeOf(proto); + } while (proto); + return undefined; + } + function superConstructor(ctor) { + return ctor.__proto__; + } + function superGet(self, homeObject, name) { + var descriptor = superDescriptor(homeObject, name); + if (descriptor) { + if (!descriptor.get) + return descriptor.value; + return descriptor.get.call(self); + } + return undefined; + } + function superSet(self, homeObject, name, value) { + var descriptor = superDescriptor(homeObject, name); + if (descriptor && descriptor.set) { + descriptor.set.call(self, value); + return value; + } + throw $TypeError(("super has no setter '" + name + "'.")); + } + function getDescriptors(object) { + var descriptors = {}; + var names = getOwnPropertyNames(object); + for (var i = 0; i < names.length; i++) { + var name = names[i]; + descriptors[name] = $getOwnPropertyDescriptor(object, name); + } + var symbols = getOwnPropertySymbols(object); + for (var i = 0; i < symbols.length; i++) { + var symbol = symbols[i]; + descriptors[$traceurRuntime.toProperty(symbol)] = $getOwnPropertyDescriptor(object, $traceurRuntime.toProperty(symbol)); + } + return descriptors; + } + function createClass(ctor, object, staticObject, superClass) { + $defineProperty(object, 'constructor', { + value: ctor, + configurable: true, + enumerable: false, + writable: true + }); + if (arguments.length > 3) { + if (typeof superClass === 'function') + ctor.__proto__ = superClass; + ctor.prototype = $create(getProtoParent(superClass), getDescriptors(object)); + } else { + ctor.prototype = object; + } + $defineProperty(ctor, 'prototype', { + configurable: false, + writable: false + }); + return $defineProperties(ctor, getDescriptors(staticObject)); + } + function getProtoParent(superClass) { + if (typeof superClass === 'function') { + var prototype = superClass.prototype; + if ($Object(prototype) === prototype || prototype === null) + return superClass.prototype; + throw new $TypeError('super prototype must be an Object or null'); + } + if (superClass === null) + return null; + throw new $TypeError(("Super expression must either be null or a function, not " + typeof superClass + ".")); + } + $traceurRuntime.createClass = createClass; + $traceurRuntime.superConstructor = superConstructor; + $traceurRuntime.superGet = superGet; + $traceurRuntime.superSet = superSet; + return {}; +}); +System.registerModule("traceur-runtime@0.0.87/src/runtime/destructuring.js", [], function() { + "use strict"; + var __moduleName = "traceur-runtime@0.0.87/src/runtime/destructuring.js"; + function iteratorToArray(iter) { + var rv = []; + var i = 0; + var tmp; + while (!(tmp = iter.next()).done) { + rv[i++] = tmp.value; + } + return rv; + } + $traceurRuntime.iteratorToArray = iteratorToArray; + return {}; +}); +System.registerModule("traceur-runtime@0.0.87/src/runtime/generators.js", [], function() { + "use strict"; + var __moduleName = "traceur-runtime@0.0.87/src/runtime/generators.js"; + if (typeof $traceurRuntime !== 'object') { + throw new Error('traceur runtime not found.'); + } + var createPrivateName = $traceurRuntime.createPrivateName; + var $defineProperties = $traceurRuntime.defineProperties; + var $defineProperty = $traceurRuntime.defineProperty; + var $create = Object.create; + var $TypeError = TypeError; + function nonEnum(value) { + return { + configurable: true, + enumerable: false, + value: value, + writable: true + }; + } + var ST_NEWBORN = 0; + var ST_EXECUTING = 1; + var ST_SUSPENDED = 2; + var ST_CLOSED = 3; + var END_STATE = -2; + var RETHROW_STATE = -3; + function getInternalError(state) { + return new Error('Traceur compiler bug: invalid state in state machine: ' + state); + } + var RETURN_SENTINEL = {}; + function GeneratorContext() { + this.state = 0; + this.GState = ST_NEWBORN; + this.storedException = undefined; + this.finallyFallThrough = undefined; + this.sent_ = undefined; + this.returnValue = undefined; + this.oldReturnValue = undefined; + this.tryStack_ = []; + } + GeneratorContext.prototype = { + pushTry: function(catchState, finallyState) { + if (finallyState !== null) { + var finallyFallThrough = null; + for (var i = this.tryStack_.length - 1; i >= 0; i--) { + if (this.tryStack_[i].catch !== undefined) { + finallyFallThrough = this.tryStack_[i].catch; + break; + } + } + if (finallyFallThrough === null) + finallyFallThrough = RETHROW_STATE; + this.tryStack_.push({ + finally: finallyState, + finallyFallThrough: finallyFallThrough + }); + } + if (catchState !== null) { + this.tryStack_.push({catch: catchState}); + } + }, + popTry: function() { + this.tryStack_.pop(); + }, + maybeUncatchable: function() { + if (this.storedException === RETURN_SENTINEL) { + throw RETURN_SENTINEL; + } + }, + get sent() { + this.maybeThrow(); + return this.sent_; + }, + set sent(v) { + this.sent_ = v; + }, + get sentIgnoreThrow() { + return this.sent_; + }, + maybeThrow: function() { + if (this.action === 'throw') { + this.action = 'next'; + throw this.sent_; + } + }, + end: function() { + switch (this.state) { + case END_STATE: + return this; + case RETHROW_STATE: + throw this.storedException; + default: + throw getInternalError(this.state); + } + }, + handleException: function(ex) { + this.GState = ST_CLOSED; + this.state = END_STATE; + throw ex; + }, + wrapYieldStar: function(iterator) { + var ctx = this; + return { + next: function(v) { + return iterator.next(v); + }, + throw: function(e) { + var result; + if (e === RETURN_SENTINEL) { + if (iterator.return) { + result = iterator.return(ctx.returnValue); + if (!result.done) { + ctx.returnValue = ctx.oldReturnValue; + return result; + } + ctx.returnValue = result.value; + } + throw e; + } + if (iterator.throw) { + return iterator.throw(e); + } + iterator.return && iterator.return(); + throw $TypeError('Inner iterator does not have a throw method'); + } + }; + } + }; + function nextOrThrow(ctx, moveNext, action, x) { + switch (ctx.GState) { + case ST_EXECUTING: + throw new Error(("\"" + action + "\" on executing generator")); + case ST_CLOSED: + if (action == 'next') { + return { + value: undefined, + done: true + }; + } + if (x === RETURN_SENTINEL) { + return { + value: ctx.returnValue, + done: true + }; + } + throw x; + case ST_NEWBORN: + if (action === 'throw') { + ctx.GState = ST_CLOSED; + if (x === RETURN_SENTINEL) { + return { + value: ctx.returnValue, + done: true + }; + } + throw x; + } + if (x !== undefined) + throw $TypeError('Sent value to newborn generator'); + case ST_SUSPENDED: + ctx.GState = ST_EXECUTING; + ctx.action = action; + ctx.sent = x; + var value; + try { + value = moveNext(ctx); + } catch (ex) { + if (ex === RETURN_SENTINEL) { + value = ctx; + } else { + throw ex; + } + } + var done = value === ctx; + if (done) + value = ctx.returnValue; + ctx.GState = done ? ST_CLOSED : ST_SUSPENDED; + return { + value: value, + done: done + }; + } + } + var ctxName = createPrivateName(); + var moveNextName = createPrivateName(); + function GeneratorFunction() {} + function GeneratorFunctionPrototype() {} + GeneratorFunction.prototype = GeneratorFunctionPrototype; + $defineProperty(GeneratorFunctionPrototype, 'constructor', nonEnum(GeneratorFunction)); + GeneratorFunctionPrototype.prototype = { + constructor: GeneratorFunctionPrototype, + next: function(v) { + return nextOrThrow(this[ctxName], this[moveNextName], 'next', v); + }, + throw: function(v) { + return nextOrThrow(this[ctxName], this[moveNextName], 'throw', v); + }, + return: function(v) { + this[ctxName].oldReturnValue = this[ctxName].returnValue; + this[ctxName].returnValue = v; + return nextOrThrow(this[ctxName], this[moveNextName], 'throw', RETURN_SENTINEL); + } + }; + $defineProperties(GeneratorFunctionPrototype.prototype, { + constructor: {enumerable: false}, + next: {enumerable: false}, + throw: {enumerable: false}, + return: {enumerable: false} + }); + Object.defineProperty(GeneratorFunctionPrototype.prototype, Symbol.iterator, nonEnum(function() { + return this; + })); + function createGeneratorInstance(innerFunction, functionObject, self) { + var moveNext = getMoveNext(innerFunction, self); + var ctx = new GeneratorContext(); + var object = $create(functionObject.prototype); + object[ctxName] = ctx; + object[moveNextName] = moveNext; + return object; + } + function initGeneratorFunction(functionObject) { + functionObject.prototype = $create(GeneratorFunctionPrototype.prototype); + functionObject.__proto__ = GeneratorFunctionPrototype; + return functionObject; + } + function AsyncFunctionContext() { + GeneratorContext.call(this); + this.err = undefined; + var ctx = this; + ctx.result = new Promise(function(resolve, reject) { + ctx.resolve = resolve; + ctx.reject = reject; + }); + } + AsyncFunctionContext.prototype = $create(GeneratorContext.prototype); + AsyncFunctionContext.prototype.end = function() { + switch (this.state) { + case END_STATE: + this.resolve(this.returnValue); + break; + case RETHROW_STATE: + this.reject(this.storedException); + break; + default: + this.reject(getInternalError(this.state)); + } + }; + AsyncFunctionContext.prototype.handleException = function() { + this.state = RETHROW_STATE; + }; + function asyncWrap(innerFunction, self) { + var moveNext = getMoveNext(innerFunction, self); + var ctx = new AsyncFunctionContext(); + ctx.createCallback = function(newState) { + return function(value) { + ctx.state = newState; + ctx.value = value; + moveNext(ctx); + }; + }; + ctx.errback = function(err) { + handleCatch(ctx, err); + moveNext(ctx); + }; + moveNext(ctx); + return ctx.result; + } + function getMoveNext(innerFunction, self) { + return function(ctx) { + while (true) { + try { + return innerFunction.call(self, ctx); + } catch (ex) { + handleCatch(ctx, ex); + } + } + }; + } + function handleCatch(ctx, ex) { + ctx.storedException = ex; + var last = ctx.tryStack_[ctx.tryStack_.length - 1]; + if (!last) { + ctx.handleException(ex); + return ; + } + ctx.state = last.catch !== undefined ? last.catch : last.finally; + if (last.finallyFallThrough !== undefined) + ctx.finallyFallThrough = last.finallyFallThrough; + } + $traceurRuntime.asyncWrap = asyncWrap; + $traceurRuntime.initGeneratorFunction = initGeneratorFunction; + $traceurRuntime.createGeneratorInstance = createGeneratorInstance; + return {}; +}); +System.registerModule("traceur-runtime@0.0.87/src/runtime/relativeRequire.js", [], function() { + "use strict"; + var __moduleName = "traceur-runtime@0.0.87/src/runtime/relativeRequire.js"; + var path; + function relativeRequire(callerPath, requiredPath) { + path = path || typeof require !== 'undefined' && require('path'); + function isDirectory(path) { + return path.slice(-1) === '/'; + } + function isAbsolute(path) { + return path[0] === '/'; + } + function isRelative(path) { + return path[0] === '.'; + } + if (isDirectory(requiredPath) || isAbsolute(requiredPath)) + return ; + return isRelative(requiredPath) ? require(path.resolve(path.dirname(callerPath), requiredPath)) : require(requiredPath); + } + $traceurRuntime.require = relativeRequire; + return {}; +}); +System.registerModule("traceur-runtime@0.0.87/src/runtime/spread.js", [], function() { + "use strict"; + var __moduleName = "traceur-runtime@0.0.87/src/runtime/spread.js"; + function spread() { + var rv = [], + j = 0, + iterResult; + for (var i = 0; i < arguments.length; i++) { + var valueToSpread = $traceurRuntime.checkObjectCoercible(arguments[i]); + if (typeof valueToSpread[$traceurRuntime.toProperty(Symbol.iterator)] !== 'function') { + throw new TypeError('Cannot spread non-iterable object.'); + } + var iter = valueToSpread[$traceurRuntime.toProperty(Symbol.iterator)](); + while (!(iterResult = iter.next()).done) { + rv[j++] = iterResult.value; + } + } + return rv; + } + $traceurRuntime.spread = spread; + return {}; +}); +System.registerModule("traceur-runtime@0.0.87/src/runtime/type-assertions.js", [], function() { + "use strict"; + var __moduleName = "traceur-runtime@0.0.87/src/runtime/type-assertions.js"; + var types = { + any: {name: 'any'}, + boolean: {name: 'boolean'}, + number: {name: 'number'}, + string: {name: 'string'}, + symbol: {name: 'symbol'}, + void: {name: 'void'} + }; + var GenericType = function GenericType(type, argumentTypes) { + this.type = type; + this.argumentTypes = argumentTypes; + }; + ($traceurRuntime.createClass)(GenericType, {}, {}); + var typeRegister = Object.create(null); + function genericType(type) { + for (var argumentTypes = [], + $__1 = 1; $__1 < arguments.length; $__1++) + argumentTypes[$__1 - 1] = arguments[$__1]; + var typeMap = typeRegister; + var key = $traceurRuntime.getOwnHashObject(type).hash; + if (!typeMap[key]) { + typeMap[key] = Object.create(null); + } + typeMap = typeMap[key]; + for (var i = 0; i < argumentTypes.length - 1; i++) { + key = $traceurRuntime.getOwnHashObject(argumentTypes[i]).hash; + if (!typeMap[key]) { + typeMap[key] = Object.create(null); + } + typeMap = typeMap[key]; + } + var tail = argumentTypes[argumentTypes.length - 1]; + key = $traceurRuntime.getOwnHashObject(tail).hash; + if (!typeMap[key]) { + typeMap[key] = new GenericType(type, argumentTypes); + } + return typeMap[key]; + } + $traceurRuntime.GenericType = GenericType; + $traceurRuntime.genericType = genericType; + $traceurRuntime.type = types; + return {}; +}); +System.registerModule("traceur-runtime@0.0.87/src/runtime/runtime-modules.js", [], function() { + "use strict"; + var __moduleName = "traceur-runtime@0.0.87/src/runtime/runtime-modules.js"; + System.get("traceur-runtime@0.0.87/src/runtime/relativeRequire.js"); + System.get("traceur-runtime@0.0.87/src/runtime/spread.js"); + System.get("traceur-runtime@0.0.87/src/runtime/destructuring.js"); + System.get("traceur-runtime@0.0.87/src/runtime/classes.js"); + System.get("traceur-runtime@0.0.87/src/runtime/async.js"); + System.get("traceur-runtime@0.0.87/src/runtime/generators.js"); + System.get("traceur-runtime@0.0.87/src/runtime/type-assertions.js"); + return {}; +}); +System.get("traceur-runtime@0.0.87/src/runtime/runtime-modules.js" + ''); +System.registerModule("traceur-runtime@0.0.87/src/runtime/polyfills/utils.js", [], function() { + "use strict"; + var __moduleName = "traceur-runtime@0.0.87/src/runtime/polyfills/utils.js"; + var $ceil = Math.ceil; + var $floor = Math.floor; + var $isFinite = isFinite; + var $isNaN = isNaN; + var $pow = Math.pow; + var $min = Math.min; + var toObject = $traceurRuntime.toObject; + function toUint32(x) { + return x >>> 0; + } + function isObject(x) { + return x && (typeof x === 'object' || typeof x === 'function'); + } + function isCallable(x) { + return typeof x === 'function'; + } + function isNumber(x) { + return typeof x === 'number'; + } + function toInteger(x) { + x = +x; + if ($isNaN(x)) + return 0; + if (x === 0 || !$isFinite(x)) + return x; + return x > 0 ? $floor(x) : $ceil(x); + } + var MAX_SAFE_LENGTH = $pow(2, 53) - 1; + function toLength(x) { + var len = toInteger(x); + return len < 0 ? 0 : $min(len, MAX_SAFE_LENGTH); + } + function checkIterable(x) { + return !isObject(x) ? undefined : x[Symbol.iterator]; + } + function isConstructor(x) { + return isCallable(x); + } + function createIteratorResultObject(value, done) { + return { + value: value, + done: done + }; + } + function maybeDefine(object, name, descr) { + if (!(name in object)) { + Object.defineProperty(object, name, descr); + } + } + function maybeDefineMethod(object, name, value) { + maybeDefine(object, name, { + value: value, + configurable: true, + enumerable: false, + writable: true + }); + } + function maybeDefineConst(object, name, value) { + maybeDefine(object, name, { + value: value, + configurable: false, + enumerable: false, + writable: false + }); + } + function maybeAddFunctions(object, functions) { + for (var i = 0; i < functions.length; i += 2) { + var name = functions[i]; + var value = functions[i + 1]; + maybeDefineMethod(object, name, value); + } + } + function maybeAddConsts(object, consts) { + for (var i = 0; i < consts.length; i += 2) { + var name = consts[i]; + var value = consts[i + 1]; + maybeDefineConst(object, name, value); + } + } + function maybeAddIterator(object, func, Symbol) { + if (!Symbol || !Symbol.iterator || object[Symbol.iterator]) + return ; + if (object['@@iterator']) + func = object['@@iterator']; + Object.defineProperty(object, Symbol.iterator, { + value: func, + configurable: true, + enumerable: false, + writable: true + }); + } + var polyfills = []; + function registerPolyfill(func) { + polyfills.push(func); + } + function polyfillAll(global) { + polyfills.forEach((function(f) { + return f(global); + })); + } + return { + get toObject() { + return toObject; + }, + get toUint32() { + return toUint32; + }, + get isObject() { + return isObject; + }, + get isCallable() { + return isCallable; + }, + get isNumber() { + return isNumber; + }, + get toInteger() { + return toInteger; + }, + get toLength() { + return toLength; + }, + get checkIterable() { + return checkIterable; + }, + get isConstructor() { + return isConstructor; + }, + get createIteratorResultObject() { + return createIteratorResultObject; + }, + get maybeDefine() { + return maybeDefine; + }, + get maybeDefineMethod() { + return maybeDefineMethod; + }, + get maybeDefineConst() { + return maybeDefineConst; + }, + get maybeAddFunctions() { + return maybeAddFunctions; + }, + get maybeAddConsts() { + return maybeAddConsts; + }, + get maybeAddIterator() { + return maybeAddIterator; + }, + get registerPolyfill() { + return registerPolyfill; + }, + get polyfillAll() { + return polyfillAll; + } + }; +}); +System.registerModule("traceur-runtime@0.0.87/src/runtime/polyfills/Map.js", [], function() { + "use strict"; + var __moduleName = "traceur-runtime@0.0.87/src/runtime/polyfills/Map.js"; + var $__0 = System.get("traceur-runtime@0.0.87/src/runtime/polyfills/utils.js"), + isObject = $__0.isObject, + maybeAddIterator = $__0.maybeAddIterator, + registerPolyfill = $__0.registerPolyfill; + var getOwnHashObject = $traceurRuntime.getOwnHashObject; + var $hasOwnProperty = Object.prototype.hasOwnProperty; + var deletedSentinel = {}; + function lookupIndex(map, key) { + if (isObject(key)) { + var hashObject = getOwnHashObject(key); + return hashObject && map.objectIndex_[hashObject.hash]; + } + if (typeof key === 'string') + return map.stringIndex_[key]; + return map.primitiveIndex_[key]; + } + function initMap(map) { + map.entries_ = []; + map.objectIndex_ = Object.create(null); + map.stringIndex_ = Object.create(null); + map.primitiveIndex_ = Object.create(null); + map.deletedCount_ = 0; + } + var Map = function Map() { + var $__10, + $__11; + var iterable = arguments[0]; + if (!isObject(this)) + throw new TypeError('Map called on incompatible type'); + if ($hasOwnProperty.call(this, 'entries_')) { + throw new TypeError('Map can not be reentrantly initialised'); + } + initMap(this); + if (iterable !== null && iterable !== undefined) { + var $__5 = true; + var $__6 = false; + var $__7 = undefined; + try { + for (var $__3 = void 0, + $__2 = (iterable)[$traceurRuntime.toProperty(Symbol.iterator)](); !($__5 = ($__3 = $__2.next()).done); $__5 = true) { + var $__9 = $__3.value, + key = ($__10 = $__9[$traceurRuntime.toProperty(Symbol.iterator)](), ($__11 = $__10.next()).done ? void 0 : $__11.value), + value = ($__11 = $__10.next()).done ? void 0 : $__11.value; + { + this.set(key, value); + } + } + } catch ($__8) { + $__6 = true; + $__7 = $__8; + } finally { + try { + if (!$__5 && $__2.return != null) { + $__2.return(); + } + } finally { + if ($__6) { + throw $__7; + } + } + } + } + }; + ($traceurRuntime.createClass)(Map, { + get size() { + return this.entries_.length / 2 - this.deletedCount_; + }, + get: function(key) { + var index = lookupIndex(this, key); + if (index !== undefined) + return this.entries_[index + 1]; + }, + set: function(key, value) { + var objectMode = isObject(key); + var stringMode = typeof key === 'string'; + var index = lookupIndex(this, key); + if (index !== undefined) { + this.entries_[index + 1] = value; + } else { + index = this.entries_.length; + this.entries_[index] = key; + this.entries_[index + 1] = value; + if (objectMode) { + var hashObject = getOwnHashObject(key); + var hash = hashObject.hash; + this.objectIndex_[hash] = index; + } else if (stringMode) { + this.stringIndex_[key] = index; + } else { + this.primitiveIndex_[key] = index; + } + } + return this; + }, + has: function(key) { + return lookupIndex(this, key) !== undefined; + }, + delete: function(key) { + var objectMode = isObject(key); + var stringMode = typeof key === 'string'; + var index; + var hash; + if (objectMode) { + var hashObject = getOwnHashObject(key); + if (hashObject) { + index = this.objectIndex_[hash = hashObject.hash]; + delete this.objectIndex_[hash]; + } + } else if (stringMode) { + index = this.stringIndex_[key]; + delete this.stringIndex_[key]; + } else { + index = this.primitiveIndex_[key]; + delete this.primitiveIndex_[key]; + } + if (index !== undefined) { + this.entries_[index] = deletedSentinel; + this.entries_[index + 1] = undefined; + this.deletedCount_++; + return true; + } + return false; + }, + clear: function() { + initMap(this); + }, + forEach: function(callbackFn) { + var thisArg = arguments[1]; + for (var i = 0; i < this.entries_.length; i += 2) { + var key = this.entries_[i]; + var value = this.entries_[i + 1]; + if (key === deletedSentinel) + continue; + callbackFn.call(thisArg, value, key, this); + } + }, + entries: $traceurRuntime.initGeneratorFunction(function $__12() { + var i, + key, + value; + return $traceurRuntime.createGeneratorInstance(function($ctx) { + while (true) + switch ($ctx.state) { + case 0: + i = 0; + $ctx.state = 12; + break; + case 12: + $ctx.state = (i < this.entries_.length) ? 8 : -2; + break; + case 4: + i += 2; + $ctx.state = 12; + break; + case 8: + key = this.entries_[i]; + value = this.entries_[i + 1]; + $ctx.state = 9; + break; + case 9: + $ctx.state = (key === deletedSentinel) ? 4 : 6; + break; + case 6: + $ctx.state = 2; + return [key, value]; + case 2: + $ctx.maybeThrow(); + $ctx.state = 4; + break; + default: + return $ctx.end(); + } + }, $__12, this); + }), + keys: $traceurRuntime.initGeneratorFunction(function $__13() { + var i, + key, + value; + return $traceurRuntime.createGeneratorInstance(function($ctx) { + while (true) + switch ($ctx.state) { + case 0: + i = 0; + $ctx.state = 12; + break; + case 12: + $ctx.state = (i < this.entries_.length) ? 8 : -2; + break; + case 4: + i += 2; + $ctx.state = 12; + break; + case 8: + key = this.entries_[i]; + value = this.entries_[i + 1]; + $ctx.state = 9; + break; + case 9: + $ctx.state = (key === deletedSentinel) ? 4 : 6; + break; + case 6: + $ctx.state = 2; + return key; + case 2: + $ctx.maybeThrow(); + $ctx.state = 4; + break; + default: + return $ctx.end(); + } + }, $__13, this); + }), + values: $traceurRuntime.initGeneratorFunction(function $__14() { + var i, + key, + value; + return $traceurRuntime.createGeneratorInstance(function($ctx) { + while (true) + switch ($ctx.state) { + case 0: + i = 0; + $ctx.state = 12; + break; + case 12: + $ctx.state = (i < this.entries_.length) ? 8 : -2; + break; + case 4: + i += 2; + $ctx.state = 12; + break; + case 8: + key = this.entries_[i]; + value = this.entries_[i + 1]; + $ctx.state = 9; + break; + case 9: + $ctx.state = (key === deletedSentinel) ? 4 : 6; + break; + case 6: + $ctx.state = 2; + return value; + case 2: + $ctx.maybeThrow(); + $ctx.state = 4; + break; + default: + return $ctx.end(); + } + }, $__14, this); + }) + }, {}); + Object.defineProperty(Map.prototype, Symbol.iterator, { + configurable: true, + writable: true, + value: Map.prototype.entries + }); + function polyfillMap(global) { + var $__9 = global, + Object = $__9.Object, + Symbol = $__9.Symbol; + if (!global.Map) + global.Map = Map; + var mapPrototype = global.Map.prototype; + if (mapPrototype.entries === undefined) + global.Map = Map; + if (mapPrototype.entries) { + maybeAddIterator(mapPrototype, mapPrototype.entries, Symbol); + maybeAddIterator(Object.getPrototypeOf(new global.Map().entries()), function() { + return this; + }, Symbol); + } + } + registerPolyfill(polyfillMap); + return { + get Map() { + return Map; + }, + get polyfillMap() { + return polyfillMap; + } + }; +}); +System.get("traceur-runtime@0.0.87/src/runtime/polyfills/Map.js" + ''); +System.registerModule("traceur-runtime@0.0.87/src/runtime/polyfills/Set.js", [], function() { + "use strict"; + var __moduleName = "traceur-runtime@0.0.87/src/runtime/polyfills/Set.js"; + var $__0 = System.get("traceur-runtime@0.0.87/src/runtime/polyfills/utils.js"), + isObject = $__0.isObject, + maybeAddIterator = $__0.maybeAddIterator, + registerPolyfill = $__0.registerPolyfill; + var Map = System.get("traceur-runtime@0.0.87/src/runtime/polyfills/Map.js").Map; + var getOwnHashObject = $traceurRuntime.getOwnHashObject; + var $hasOwnProperty = Object.prototype.hasOwnProperty; + function initSet(set) { + set.map_ = new Map(); + } + var Set = function Set() { + var iterable = arguments[0]; + if (!isObject(this)) + throw new TypeError('Set called on incompatible type'); + if ($hasOwnProperty.call(this, 'map_')) { + throw new TypeError('Set can not be reentrantly initialised'); + } + initSet(this); + if (iterable !== null && iterable !== undefined) { + var $__7 = true; + var $__8 = false; + var $__9 = undefined; + try { + for (var $__5 = void 0, + $__4 = (iterable)[$traceurRuntime.toProperty(Symbol.iterator)](); !($__7 = ($__5 = $__4.next()).done); $__7 = true) { + var item = $__5.value; + { + this.add(item); + } + } + } catch ($__10) { + $__8 = true; + $__9 = $__10; + } finally { + try { + if (!$__7 && $__4.return != null) { + $__4.return(); + } + } finally { + if ($__8) { + throw $__9; + } + } + } + } + }; + ($traceurRuntime.createClass)(Set, { + get size() { + return this.map_.size; + }, + has: function(key) { + return this.map_.has(key); + }, + add: function(key) { + this.map_.set(key, key); + return this; + }, + delete: function(key) { + return this.map_.delete(key); + }, + clear: function() { + return this.map_.clear(); + }, + forEach: function(callbackFn) { + var thisArg = arguments[1]; + var $__2 = this; + return this.map_.forEach((function(value, key) { + callbackFn.call(thisArg, key, key, $__2); + })); + }, + values: $traceurRuntime.initGeneratorFunction(function $__12() { + var $__13, + $__14; + return $traceurRuntime.createGeneratorInstance(function($ctx) { + while (true) + switch ($ctx.state) { + case 0: + $__13 = $ctx.wrapYieldStar(this.map_.keys()[Symbol.iterator]()); + $ctx.sent = void 0; + $ctx.action = 'next'; + $ctx.state = 12; + break; + case 12: + $__14 = $__13[$ctx.action]($ctx.sentIgnoreThrow); + $ctx.state = 9; + break; + case 9: + $ctx.state = ($__14.done) ? 3 : 2; + break; + case 3: + $ctx.sent = $__14.value; + $ctx.state = -2; + break; + case 2: + $ctx.state = 12; + return $__14.value; + default: + return $ctx.end(); + } + }, $__12, this); + }), + entries: $traceurRuntime.initGeneratorFunction(function $__15() { + var $__16, + $__17; + return $traceurRuntime.createGeneratorInstance(function($ctx) { + while (true) + switch ($ctx.state) { + case 0: + $__16 = $ctx.wrapYieldStar(this.map_.entries()[Symbol.iterator]()); + $ctx.sent = void 0; + $ctx.action = 'next'; + $ctx.state = 12; + break; + case 12: + $__17 = $__16[$ctx.action]($ctx.sentIgnoreThrow); + $ctx.state = 9; + break; + case 9: + $ctx.state = ($__17.done) ? 3 : 2; + break; + case 3: + $ctx.sent = $__17.value; + $ctx.state = -2; + break; + case 2: + $ctx.state = 12; + return $__17.value; + default: + return $ctx.end(); + } + }, $__15, this); + }) + }, {}); + Object.defineProperty(Set.prototype, Symbol.iterator, { + configurable: true, + writable: true, + value: Set.prototype.values + }); + Object.defineProperty(Set.prototype, 'keys', { + configurable: true, + writable: true, + value: Set.prototype.values + }); + function polyfillSet(global) { + var $__11 = global, + Object = $__11.Object, + Symbol = $__11.Symbol; + if (!global.Set) + global.Set = Set; + var setPrototype = global.Set.prototype; + if (setPrototype.values) { + maybeAddIterator(setPrototype, setPrototype.values, Symbol); + maybeAddIterator(Object.getPrototypeOf(new global.Set().values()), function() { + return this; + }, Symbol); + } + } + registerPolyfill(polyfillSet); + return { + get Set() { + return Set; + }, + get polyfillSet() { + return polyfillSet; + } + }; +}); +System.get("traceur-runtime@0.0.87/src/runtime/polyfills/Set.js" + ''); +System.registerModule("traceur-runtime@0.0.87/node_modules/rsvp/lib/rsvp/asap.js", [], function() { + "use strict"; + var __moduleName = "traceur-runtime@0.0.87/node_modules/rsvp/lib/rsvp/asap.js"; + var len = 0; + function asap(callback, arg) { + queue[len] = callback; + queue[len + 1] = arg; + len += 2; + if (len === 2) { + scheduleFlush(); + } + } + var $__default = asap; + var browserGlobal = (typeof window !== 'undefined') ? window : {}; + var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver; + var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined'; + function useNextTick() { + return function() { + process.nextTick(flush); + }; + } + function useMutationObserver() { + var iterations = 0; + var observer = new BrowserMutationObserver(flush); + var node = document.createTextNode(''); + observer.observe(node, {characterData: true}); + return function() { + node.data = (iterations = ++iterations % 2); + }; + } + function useMessageChannel() { + var channel = new MessageChannel(); + channel.port1.onmessage = flush; + return function() { + channel.port2.postMessage(0); + }; + } + function useSetTimeout() { + return function() { + setTimeout(flush, 1); + }; + } + var queue = new Array(1000); + function flush() { + for (var i = 0; i < len; i += 2) { + var callback = queue[i]; + var arg = queue[i + 1]; + callback(arg); + queue[i] = undefined; + queue[i + 1] = undefined; + } + len = 0; + } + var scheduleFlush; + if (typeof process !== 'undefined' && {}.toString.call(process) === '[object process]') { + scheduleFlush = useNextTick(); + } else if (BrowserMutationObserver) { + scheduleFlush = useMutationObserver(); + } else if (isWorker) { + scheduleFlush = useMessageChannel(); + } else { + scheduleFlush = useSetTimeout(); + } + return {get default() { + return $__default; + }}; +}); +System.registerModule("traceur-runtime@0.0.87/src/runtime/polyfills/Promise.js", [], function() { + "use strict"; + var __moduleName = "traceur-runtime@0.0.87/src/runtime/polyfills/Promise.js"; + var async = System.get("traceur-runtime@0.0.87/node_modules/rsvp/lib/rsvp/asap.js").default; + var registerPolyfill = System.get("traceur-runtime@0.0.87/src/runtime/polyfills/utils.js").registerPolyfill; + var promiseRaw = {}; + function isPromise(x) { + return x && typeof x === 'object' && x.status_ !== undefined; + } + function idResolveHandler(x) { + return x; + } + function idRejectHandler(x) { + throw x; + } + function chain(promise) { + var onResolve = arguments[1] !== (void 0) ? arguments[1] : idResolveHandler; + var onReject = arguments[2] !== (void 0) ? arguments[2] : idRejectHandler; + var deferred = getDeferred(promise.constructor); + switch (promise.status_) { + case undefined: + throw TypeError; + case 0: + promise.onResolve_.push(onResolve, deferred); + promise.onReject_.push(onReject, deferred); + break; + case +1: + promiseEnqueue(promise.value_, [onResolve, deferred]); + break; + case -1: + promiseEnqueue(promise.value_, [onReject, deferred]); + break; + } + return deferred.promise; + } + function getDeferred(C) { + if (this === $Promise) { + var promise = promiseInit(new $Promise(promiseRaw)); + return { + promise: promise, + resolve: (function(x) { + promiseResolve(promise, x); + }), + reject: (function(r) { + promiseReject(promise, r); + }) + }; + } else { + var result = {}; + result.promise = new C((function(resolve, reject) { + result.resolve = resolve; + result.reject = reject; + })); + return result; + } + } + function promiseSet(promise, status, value, onResolve, onReject) { + promise.status_ = status; + promise.value_ = value; + promise.onResolve_ = onResolve; + promise.onReject_ = onReject; + return promise; + } + function promiseInit(promise) { + return promiseSet(promise, 0, undefined, [], []); + } + var Promise = function Promise(resolver) { + if (resolver === promiseRaw) + return ; + if (typeof resolver !== 'function') + throw new TypeError; + var promise = promiseInit(this); + try { + resolver((function(x) { + promiseResolve(promise, x); + }), (function(r) { + promiseReject(promise, r); + })); + } catch (e) { + promiseReject(promise, e); + } + }; + ($traceurRuntime.createClass)(Promise, { + catch: function(onReject) { + return this.then(undefined, onReject); + }, + then: function(onResolve, onReject) { + if (typeof onResolve !== 'function') + onResolve = idResolveHandler; + if (typeof onReject !== 'function') + onReject = idRejectHandler; + var that = this; + var constructor = this.constructor; + return chain(this, function(x) { + x = promiseCoerce(constructor, x); + return x === that ? onReject(new TypeError) : isPromise(x) ? x.then(onResolve, onReject) : onResolve(x); + }, onReject); + } + }, { + resolve: function(x) { + if (this === $Promise) { + if (isPromise(x)) { + return x; + } + return promiseSet(new $Promise(promiseRaw), +1, x); + } else { + return new this(function(resolve, reject) { + resolve(x); + }); + } + }, + reject: function(r) { + if (this === $Promise) { + return promiseSet(new $Promise(promiseRaw), -1, r); + } else { + return new this((function(resolve, reject) { + reject(r); + })); + } + }, + all: function(values) { + var deferred = getDeferred(this); + var resolutions = []; + try { + var makeCountdownFunction = function(i) { + return (function(x) { + resolutions[i] = x; + if (--count === 0) + deferred.resolve(resolutions); + }); + }; + var count = 0; + var i = 0; + var $__6 = true; + var $__7 = false; + var $__8 = undefined; + try { + for (var $__4 = void 0, + $__3 = (values)[$traceurRuntime.toProperty(Symbol.iterator)](); !($__6 = ($__4 = $__3.next()).done); $__6 = true) { + var value = $__4.value; + { + var countdownFunction = makeCountdownFunction(i); + this.resolve(value).then(countdownFunction, (function(r) { + deferred.reject(r); + })); + ++i; + ++count; + } + } + } catch ($__9) { + $__7 = true; + $__8 = $__9; + } finally { + try { + if (!$__6 && $__3.return != null) { + $__3.return(); + } + } finally { + if ($__7) { + throw $__8; + } + } + } + if (count === 0) { + deferred.resolve(resolutions); + } + } catch (e) { + deferred.reject(e); + } + return deferred.promise; + }, + race: function(values) { + var deferred = getDeferred(this); + try { + for (var i = 0; i < values.length; i++) { + this.resolve(values[i]).then((function(x) { + deferred.resolve(x); + }), (function(r) { + deferred.reject(r); + })); + } + } catch (e) { + deferred.reject(e); + } + return deferred.promise; + } + }); + var $Promise = Promise; + var $PromiseReject = $Promise.reject; + function promiseResolve(promise, x) { + promiseDone(promise, +1, x, promise.onResolve_); + } + function promiseReject(promise, r) { + promiseDone(promise, -1, r, promise.onReject_); + } + function promiseDone(promise, status, value, reactions) { + if (promise.status_ !== 0) + return ; + promiseEnqueue(value, reactions); + promiseSet(promise, status, value); + } + function promiseEnqueue(value, tasks) { + async((function() { + for (var i = 0; i < tasks.length; i += 2) { + promiseHandle(value, tasks[i], tasks[i + 1]); + } + })); + } + function promiseHandle(value, handler, deferred) { + try { + var result = handler(value); + if (result === deferred.promise) + throw new TypeError; + else if (isPromise(result)) + chain(result, deferred.resolve, deferred.reject); + else + deferred.resolve(result); + } catch (e) { + try { + deferred.reject(e); + } catch (e) {} + } + } + var thenableSymbol = '@@thenable'; + function isObject(x) { + return x && (typeof x === 'object' || typeof x === 'function'); + } + function promiseCoerce(constructor, x) { + if (!isPromise(x) && isObject(x)) { + var then; + try { + then = x.then; + } catch (r) { + var promise = $PromiseReject.call(constructor, r); + x[thenableSymbol] = promise; + return promise; + } + if (typeof then === 'function') { + var p = x[thenableSymbol]; + if (p) { + return p; + } else { + var deferred = getDeferred(constructor); + x[thenableSymbol] = deferred.promise; + try { + then.call(x, deferred.resolve, deferred.reject); + } catch (r) { + deferred.reject(r); + } + return deferred.promise; + } + } + } + return x; + } + function polyfillPromise(global) { + if (!global.Promise) + global.Promise = Promise; + } + registerPolyfill(polyfillPromise); + return { + get Promise() { + return Promise; + }, + get polyfillPromise() { + return polyfillPromise; + } + }; +}); +System.get("traceur-runtime@0.0.87/src/runtime/polyfills/Promise.js" + ''); +System.registerModule("traceur-runtime@0.0.87/src/runtime/polyfills/StringIterator.js", [], function() { + "use strict"; + var $__2; + var __moduleName = "traceur-runtime@0.0.87/src/runtime/polyfills/StringIterator.js"; + var $__0 = System.get("traceur-runtime@0.0.87/src/runtime/polyfills/utils.js"), + createIteratorResultObject = $__0.createIteratorResultObject, + isObject = $__0.isObject; + var toProperty = $traceurRuntime.toProperty; + var hasOwnProperty = Object.prototype.hasOwnProperty; + var iteratedString = Symbol('iteratedString'); + var stringIteratorNextIndex = Symbol('stringIteratorNextIndex'); + var StringIterator = function StringIterator() { + ; + }; + ($traceurRuntime.createClass)(StringIterator, ($__2 = {}, Object.defineProperty($__2, "next", { + value: function() { + var o = this; + if (!isObject(o) || !hasOwnProperty.call(o, iteratedString)) { + throw new TypeError('this must be a StringIterator object'); + } + var s = o[toProperty(iteratedString)]; + if (s === undefined) { + return createIteratorResultObject(undefined, true); + } + var position = o[toProperty(stringIteratorNextIndex)]; + var len = s.length; + if (position >= len) { + o[toProperty(iteratedString)] = undefined; + return createIteratorResultObject(undefined, true); + } + var first = s.charCodeAt(position); + var resultString; + if (first < 0xD800 || first > 0xDBFF || position + 1 === len) { + resultString = String.fromCharCode(first); + } else { + var second = s.charCodeAt(position + 1); + if (second < 0xDC00 || second > 0xDFFF) { + resultString = String.fromCharCode(first); + } else { + resultString = String.fromCharCode(first) + String.fromCharCode(second); + } + } + o[toProperty(stringIteratorNextIndex)] = position + resultString.length; + return createIteratorResultObject(resultString, false); + }, + configurable: true, + enumerable: true, + writable: true + }), Object.defineProperty($__2, Symbol.iterator, { + value: function() { + return this; + }, + configurable: true, + enumerable: true, + writable: true + }), $__2), {}); + function createStringIterator(string) { + var s = String(string); + var iterator = Object.create(StringIterator.prototype); + iterator[toProperty(iteratedString)] = s; + iterator[toProperty(stringIteratorNextIndex)] = 0; + return iterator; + } + return {get createStringIterator() { + return createStringIterator; + }}; +}); +System.registerModule("traceur-runtime@0.0.87/src/runtime/polyfills/String.js", [], function() { + "use strict"; + var __moduleName = "traceur-runtime@0.0.87/src/runtime/polyfills/String.js"; + var createStringIterator = System.get("traceur-runtime@0.0.87/src/runtime/polyfills/StringIterator.js").createStringIterator; + var $__1 = System.get("traceur-runtime@0.0.87/src/runtime/polyfills/utils.js"), + maybeAddFunctions = $__1.maybeAddFunctions, + maybeAddIterator = $__1.maybeAddIterator, + registerPolyfill = $__1.registerPolyfill; + var $toString = Object.prototype.toString; + var $indexOf = String.prototype.indexOf; + var $lastIndexOf = String.prototype.lastIndexOf; + function startsWith(search) { + var string = String(this); + if (this == null || $toString.call(search) == '[object RegExp]') { + throw TypeError(); + } + var stringLength = string.length; + var searchString = String(search); + var searchLength = searchString.length; + var position = arguments.length > 1 ? arguments[1] : undefined; + var pos = position ? Number(position) : 0; + if (isNaN(pos)) { + pos = 0; + } + var start = Math.min(Math.max(pos, 0), stringLength); + return $indexOf.call(string, searchString, pos) == start; + } + function endsWith(search) { + var string = String(this); + if (this == null || $toString.call(search) == '[object RegExp]') { + throw TypeError(); + } + var stringLength = string.length; + var searchString = String(search); + var searchLength = searchString.length; + var pos = stringLength; + if (arguments.length > 1) { + var position = arguments[1]; + if (position !== undefined) { + pos = position ? Number(position) : 0; + if (isNaN(pos)) { + pos = 0; + } + } + } + var end = Math.min(Math.max(pos, 0), stringLength); + var start = end - searchLength; + if (start < 0) { + return false; + } + return $lastIndexOf.call(string, searchString, start) == start; + } + function includes(search) { + if (this == null) { + throw TypeError(); + } + var string = String(this); + if (search && $toString.call(search) == '[object RegExp]') { + throw TypeError(); + } + var stringLength = string.length; + var searchString = String(search); + var searchLength = searchString.length; + var position = arguments.length > 1 ? arguments[1] : undefined; + var pos = position ? Number(position) : 0; + if (pos != pos) { + pos = 0; + } + var start = Math.min(Math.max(pos, 0), stringLength); + if (searchLength + start > stringLength) { + return false; + } + return $indexOf.call(string, searchString, pos) != -1; + } + function repeat(count) { + if (this == null) { + throw TypeError(); + } + var string = String(this); + var n = count ? Number(count) : 0; + if (isNaN(n)) { + n = 0; + } + if (n < 0 || n == Infinity) { + throw RangeError(); + } + if (n == 0) { + return ''; + } + var result = ''; + while (n--) { + result += string; + } + return result; + } + function codePointAt(position) { + if (this == null) { + throw TypeError(); + } + var string = String(this); + var size = string.length; + var index = position ? Number(position) : 0; + if (isNaN(index)) { + index = 0; + } + if (index < 0 || index >= size) { + return undefined; + } + var first = string.charCodeAt(index); + var second; + if (first >= 0xD800 && first <= 0xDBFF && size > index + 1) { + second = string.charCodeAt(index + 1); + if (second >= 0xDC00 && second <= 0xDFFF) { + return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; + } + } + return first; + } + function raw(callsite) { + var raw = callsite.raw; + var len = raw.length >>> 0; + if (len === 0) + return ''; + var s = ''; + var i = 0; + while (true) { + s += raw[i]; + if (i + 1 === len) + return s; + s += arguments[++i]; + } + } + function fromCodePoint(_) { + var codeUnits = []; + var floor = Math.floor; + var highSurrogate; + var lowSurrogate; + var index = -1; + var length = arguments.length; + if (!length) { + return ''; + } + while (++index < length) { + var codePoint = Number(arguments[index]); + if (!isFinite(codePoint) || codePoint < 0 || codePoint > 0x10FFFF || floor(codePoint) != codePoint) { + throw RangeError('Invalid code point: ' + codePoint); + } + if (codePoint <= 0xFFFF) { + codeUnits.push(codePoint); + } else { + codePoint -= 0x10000; + highSurrogate = (codePoint >> 10) + 0xD800; + lowSurrogate = (codePoint % 0x400) + 0xDC00; + codeUnits.push(highSurrogate, lowSurrogate); + } + } + return String.fromCharCode.apply(null, codeUnits); + } + function stringPrototypeIterator() { + var o = $traceurRuntime.checkObjectCoercible(this); + var s = String(o); + return createStringIterator(s); + } + function polyfillString(global) { + var String = global.String; + maybeAddFunctions(String.prototype, ['codePointAt', codePointAt, 'endsWith', endsWith, 'includes', includes, 'repeat', repeat, 'startsWith', startsWith]); + maybeAddFunctions(String, ['fromCodePoint', fromCodePoint, 'raw', raw]); + maybeAddIterator(String.prototype, stringPrototypeIterator, Symbol); + } + registerPolyfill(polyfillString); + return { + get startsWith() { + return startsWith; + }, + get endsWith() { + return endsWith; + }, + get includes() { + return includes; + }, + get repeat() { + return repeat; + }, + get codePointAt() { + return codePointAt; + }, + get raw() { + return raw; + }, + get fromCodePoint() { + return fromCodePoint; + }, + get stringPrototypeIterator() { + return stringPrototypeIterator; + }, + get polyfillString() { + return polyfillString; + } + }; +}); +System.get("traceur-runtime@0.0.87/src/runtime/polyfills/String.js" + ''); +System.registerModule("traceur-runtime@0.0.87/src/runtime/polyfills/ArrayIterator.js", [], function() { + "use strict"; + var $__2; + var __moduleName = "traceur-runtime@0.0.87/src/runtime/polyfills/ArrayIterator.js"; + var $__0 = System.get("traceur-runtime@0.0.87/src/runtime/polyfills/utils.js"), + toObject = $__0.toObject, + toUint32 = $__0.toUint32, + createIteratorResultObject = $__0.createIteratorResultObject; + var ARRAY_ITERATOR_KIND_KEYS = 1; + var ARRAY_ITERATOR_KIND_VALUES = 2; + var ARRAY_ITERATOR_KIND_ENTRIES = 3; + var ArrayIterator = function ArrayIterator() { + ; + }; + ($traceurRuntime.createClass)(ArrayIterator, ($__2 = {}, Object.defineProperty($__2, "next", { + value: function() { + var iterator = toObject(this); + var array = iterator.iteratorObject_; + if (!array) { + throw new TypeError('Object is not an ArrayIterator'); + } + var index = iterator.arrayIteratorNextIndex_; + var itemKind = iterator.arrayIterationKind_; + var length = toUint32(array.length); + if (index >= length) { + iterator.arrayIteratorNextIndex_ = Infinity; + return createIteratorResultObject(undefined, true); + } + iterator.arrayIteratorNextIndex_ = index + 1; + if (itemKind == ARRAY_ITERATOR_KIND_VALUES) + return createIteratorResultObject(array[index], false); + if (itemKind == ARRAY_ITERATOR_KIND_ENTRIES) + return createIteratorResultObject([index, array[index]], false); + return createIteratorResultObject(index, false); + }, + configurable: true, + enumerable: true, + writable: true + }), Object.defineProperty($__2, Symbol.iterator, { + value: function() { + return this; + }, + configurable: true, + enumerable: true, + writable: true + }), $__2), {}); + function createArrayIterator(array, kind) { + var object = toObject(array); + var iterator = new ArrayIterator; + iterator.iteratorObject_ = object; + iterator.arrayIteratorNextIndex_ = 0; + iterator.arrayIterationKind_ = kind; + return iterator; + } + function entries() { + return createArrayIterator(this, ARRAY_ITERATOR_KIND_ENTRIES); + } + function keys() { + return createArrayIterator(this, ARRAY_ITERATOR_KIND_KEYS); + } + function values() { + return createArrayIterator(this, ARRAY_ITERATOR_KIND_VALUES); + } + return { + get entries() { + return entries; + }, + get keys() { + return keys; + }, + get values() { + return values; + } + }; +}); +System.registerModule("traceur-runtime@0.0.87/src/runtime/polyfills/Array.js", [], function() { + "use strict"; + var __moduleName = "traceur-runtime@0.0.87/src/runtime/polyfills/Array.js"; + var $__0 = System.get("traceur-runtime@0.0.87/src/runtime/polyfills/ArrayIterator.js"), + entries = $__0.entries, + keys = $__0.keys, + jsValues = $__0.values; + var $__1 = System.get("traceur-runtime@0.0.87/src/runtime/polyfills/utils.js"), + checkIterable = $__1.checkIterable, + isCallable = $__1.isCallable, + isConstructor = $__1.isConstructor, + maybeAddFunctions = $__1.maybeAddFunctions, + maybeAddIterator = $__1.maybeAddIterator, + registerPolyfill = $__1.registerPolyfill, + toInteger = $__1.toInteger, + toLength = $__1.toLength, + toObject = $__1.toObject; + function from(arrLike) { + var mapFn = arguments[1]; + var thisArg = arguments[2]; + var C = this; + var items = toObject(arrLike); + var mapping = mapFn !== undefined; + var k = 0; + var arr, + len; + if (mapping && !isCallable(mapFn)) { + throw TypeError(); + } + if (checkIterable(items)) { + arr = isConstructor(C) ? new C() : []; + var $__5 = true; + var $__6 = false; + var $__7 = undefined; + try { + for (var $__3 = void 0, + $__2 = (items)[$traceurRuntime.toProperty(Symbol.iterator)](); !($__5 = ($__3 = $__2.next()).done); $__5 = true) { + var item = $__3.value; + { + if (mapping) { + arr[k] = mapFn.call(thisArg, item, k); + } else { + arr[k] = item; + } + k++; + } + } + } catch ($__8) { + $__6 = true; + $__7 = $__8; + } finally { + try { + if (!$__5 && $__2.return != null) { + $__2.return(); + } + } finally { + if ($__6) { + throw $__7; + } + } + } + arr.length = k; + return arr; + } + len = toLength(items.length); + arr = isConstructor(C) ? new C(len) : new Array(len); + for (; k < len; k++) { + if (mapping) { + arr[k] = typeof thisArg === 'undefined' ? mapFn(items[k], k) : mapFn.call(thisArg, items[k], k); + } else { + arr[k] = items[k]; + } + } + arr.length = len; + return arr; + } + function of() { + for (var items = [], + $__9 = 0; $__9 < arguments.length; $__9++) + items[$__9] = arguments[$__9]; + var C = this; + var len = items.length; + var arr = isConstructor(C) ? new C(len) : new Array(len); + for (var k = 0; k < len; k++) { + arr[k] = items[k]; + } + arr.length = len; + return arr; + } + function fill(value) { + var start = arguments[1] !== (void 0) ? arguments[1] : 0; + var end = arguments[2]; + var object = toObject(this); + var len = toLength(object.length); + var fillStart = toInteger(start); + var fillEnd = end !== undefined ? toInteger(end) : len; + fillStart = fillStart < 0 ? Math.max(len + fillStart, 0) : Math.min(fillStart, len); + fillEnd = fillEnd < 0 ? Math.max(len + fillEnd, 0) : Math.min(fillEnd, len); + while (fillStart < fillEnd) { + object[fillStart] = value; + fillStart++; + } + return object; + } + function find(predicate) { + var thisArg = arguments[1]; + return findHelper(this, predicate, thisArg); + } + function findIndex(predicate) { + var thisArg = arguments[1]; + return findHelper(this, predicate, thisArg, true); + } + function findHelper(self, predicate) { + var thisArg = arguments[2]; + var returnIndex = arguments[3] !== (void 0) ? arguments[3] : false; + var object = toObject(self); + var len = toLength(object.length); + if (!isCallable(predicate)) { + throw TypeError(); + } + for (var i = 0; i < len; i++) { + var value = object[i]; + if (predicate.call(thisArg, value, i, object)) { + return returnIndex ? i : value; + } + } + return returnIndex ? -1 : undefined; + } + function polyfillArray(global) { + var $__10 = global, + Array = $__10.Array, + Object = $__10.Object, + Symbol = $__10.Symbol; + var values = jsValues; + if (Symbol && Symbol.iterator && Array.prototype[Symbol.iterator]) { + values = Array.prototype[Symbol.iterator]; + } + maybeAddFunctions(Array.prototype, ['entries', entries, 'keys', keys, 'values', values, 'fill', fill, 'find', find, 'findIndex', findIndex]); + maybeAddFunctions(Array, ['from', from, 'of', of]); + maybeAddIterator(Array.prototype, values, Symbol); + maybeAddIterator(Object.getPrototypeOf([].values()), function() { + return this; + }, Symbol); + } + registerPolyfill(polyfillArray); + return { + get from() { + return from; + }, + get of() { + return of; + }, + get fill() { + return fill; + }, + get find() { + return find; + }, + get findIndex() { + return findIndex; + }, + get polyfillArray() { + return polyfillArray; + } + }; +}); +System.get("traceur-runtime@0.0.87/src/runtime/polyfills/Array.js" + ''); +System.registerModule("traceur-runtime@0.0.87/src/runtime/polyfills/Object.js", [], function() { + "use strict"; + var __moduleName = "traceur-runtime@0.0.87/src/runtime/polyfills/Object.js"; + var $__0 = System.get("traceur-runtime@0.0.87/src/runtime/polyfills/utils.js"), + maybeAddFunctions = $__0.maybeAddFunctions, + registerPolyfill = $__0.registerPolyfill; + var $__1 = $traceurRuntime, + defineProperty = $__1.defineProperty, + getOwnPropertyDescriptor = $__1.getOwnPropertyDescriptor, + getOwnPropertyNames = $__1.getOwnPropertyNames, + isPrivateName = $__1.isPrivateName, + keys = $__1.keys; + function is(left, right) { + if (left === right) + return left !== 0 || 1 / left === 1 / right; + return left !== left && right !== right; + } + function assign(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + var props = source == null ? [] : keys(source); + var p = void 0, + length = props.length; + for (p = 0; p < length; p++) { + var name = props[p]; + if (isPrivateName(name)) + continue; + target[name] = source[name]; + } + } + return target; + } + function mixin(target, source) { + var props = getOwnPropertyNames(source); + var p, + descriptor, + length = props.length; + for (p = 0; p < length; p++) { + var name = props[p]; + if (isPrivateName(name)) + continue; + descriptor = getOwnPropertyDescriptor(source, props[p]); + defineProperty(target, props[p], descriptor); + } + return target; + } + function polyfillObject(global) { + var Object = global.Object; + maybeAddFunctions(Object, ['assign', assign, 'is', is, 'mixin', mixin]); + } + registerPolyfill(polyfillObject); + return { + get is() { + return is; + }, + get assign() { + return assign; + }, + get mixin() { + return mixin; + }, + get polyfillObject() { + return polyfillObject; + } + }; +}); +System.get("traceur-runtime@0.0.87/src/runtime/polyfills/Object.js" + ''); +System.registerModule("traceur-runtime@0.0.87/src/runtime/polyfills/Number.js", [], function() { + "use strict"; + var __moduleName = "traceur-runtime@0.0.87/src/runtime/polyfills/Number.js"; + var $__0 = System.get("traceur-runtime@0.0.87/src/runtime/polyfills/utils.js"), + isNumber = $__0.isNumber, + maybeAddConsts = $__0.maybeAddConsts, + maybeAddFunctions = $__0.maybeAddFunctions, + registerPolyfill = $__0.registerPolyfill, + toInteger = $__0.toInteger; + var $abs = Math.abs; + var $isFinite = isFinite; + var $isNaN = isNaN; + var MAX_SAFE_INTEGER = Math.pow(2, 53) - 1; + var MIN_SAFE_INTEGER = -Math.pow(2, 53) + 1; + var EPSILON = Math.pow(2, -52); + function NumberIsFinite(number) { + return isNumber(number) && $isFinite(number); + } + ; + function isInteger(number) { + return NumberIsFinite(number) && toInteger(number) === number; + } + function NumberIsNaN(number) { + return isNumber(number) && $isNaN(number); + } + ; + function isSafeInteger(number) { + if (NumberIsFinite(number)) { + var integral = toInteger(number); + if (integral === number) + return $abs(integral) <= MAX_SAFE_INTEGER; + } + return false; + } + function polyfillNumber(global) { + var Number = global.Number; + maybeAddConsts(Number, ['MAX_SAFE_INTEGER', MAX_SAFE_INTEGER, 'MIN_SAFE_INTEGER', MIN_SAFE_INTEGER, 'EPSILON', EPSILON]); + maybeAddFunctions(Number, ['isFinite', NumberIsFinite, 'isInteger', isInteger, 'isNaN', NumberIsNaN, 'isSafeInteger', isSafeInteger]); + } + registerPolyfill(polyfillNumber); + return { + get MAX_SAFE_INTEGER() { + return MAX_SAFE_INTEGER; + }, + get MIN_SAFE_INTEGER() { + return MIN_SAFE_INTEGER; + }, + get EPSILON() { + return EPSILON; + }, + get isFinite() { + return NumberIsFinite; + }, + get isInteger() { + return isInteger; + }, + get isNaN() { + return NumberIsNaN; + }, + get isSafeInteger() { + return isSafeInteger; + }, + get polyfillNumber() { + return polyfillNumber; + } + }; +}); +System.get("traceur-runtime@0.0.87/src/runtime/polyfills/Number.js" + ''); +System.registerModule("traceur-runtime@0.0.87/src/runtime/polyfills/fround.js", [], function() { + "use strict"; + var __moduleName = "traceur-runtime@0.0.87/src/runtime/polyfills/fround.js"; + var $isFinite = isFinite; + var $isNaN = isNaN; + var $__0 = Math, + LN2 = $__0.LN2, + abs = $__0.abs, + floor = $__0.floor, + log = $__0.log, + min = $__0.min, + pow = $__0.pow; + function packIEEE754(v, ebits, fbits) { + var bias = (1 << (ebits - 1)) - 1, + s, + e, + f, + ln, + i, + bits, + str, + bytes; + function roundToEven(n) { + var w = floor(n), + f = n - w; + if (f < 0.5) + return w; + if (f > 0.5) + return w + 1; + return w % 2 ? w + 1 : w; + } + if (v !== v) { + e = (1 << ebits) - 1; + f = pow(2, fbits - 1); + s = 0; + } else if (v === Infinity || v === -Infinity) { + e = (1 << ebits) - 1; + f = 0; + s = (v < 0) ? 1 : 0; + } else if (v === 0) { + e = 0; + f = 0; + s = (1 / v === -Infinity) ? 1 : 0; + } else { + s = v < 0; + v = abs(v); + if (v >= pow(2, 1 - bias)) { + e = min(floor(log(v) / LN2), 1023); + f = roundToEven(v / pow(2, e) * pow(2, fbits)); + if (f / pow(2, fbits) >= 2) { + e = e + 1; + f = 1; + } + if (e > bias) { + e = (1 << ebits) - 1; + f = 0; + } else { + e = e + bias; + f = f - pow(2, fbits); + } + } else { + e = 0; + f = roundToEven(v / pow(2, 1 - bias - fbits)); + } + } + bits = []; + for (i = fbits; i; i -= 1) { + bits.push(f % 2 ? 1 : 0); + f = floor(f / 2); + } + for (i = ebits; i; i -= 1) { + bits.push(e % 2 ? 1 : 0); + e = floor(e / 2); + } + bits.push(s ? 1 : 0); + bits.reverse(); + str = bits.join(''); + bytes = []; + while (str.length) { + bytes.push(parseInt(str.substring(0, 8), 2)); + str = str.substring(8); + } + return bytes; + } + function unpackIEEE754(bytes, ebits, fbits) { + var bits = [], + i, + j, + b, + str, + bias, + s, + e, + f; + for (i = bytes.length; i; i -= 1) { + b = bytes[i - 1]; + for (j = 8; j; j -= 1) { + bits.push(b % 2 ? 1 : 0); + b = b >> 1; + } + } + bits.reverse(); + str = bits.join(''); + bias = (1 << (ebits - 1)) - 1; + s = parseInt(str.substring(0, 1), 2) ? -1 : 1; + e = parseInt(str.substring(1, 1 + ebits), 2); + f = parseInt(str.substring(1 + ebits), 2); + if (e === (1 << ebits) - 1) { + return f !== 0 ? NaN : s * Infinity; + } else if (e > 0) { + return s * pow(2, e - bias) * (1 + f / pow(2, fbits)); + } else if (f !== 0) { + return s * pow(2, -(bias - 1)) * (f / pow(2, fbits)); + } else { + return s < 0 ? -0 : 0; + } + } + function unpackF32(b) { + return unpackIEEE754(b, 8, 23); + } + function packF32(v) { + return packIEEE754(v, 8, 23); + } + function fround(x) { + if (x === 0 || !$isFinite(x) || $isNaN(x)) { + return x; + } + return unpackF32(packF32(Number(x))); + } + return {get fround() { + return fround; + }}; +}); +System.registerModule("traceur-runtime@0.0.87/src/runtime/polyfills/Math.js", [], function() { + "use strict"; + var __moduleName = "traceur-runtime@0.0.87/src/runtime/polyfills/Math.js"; + var jsFround = System.get("traceur-runtime@0.0.87/src/runtime/polyfills/fround.js").fround; + var $__1 = System.get("traceur-runtime@0.0.87/src/runtime/polyfills/utils.js"), + maybeAddFunctions = $__1.maybeAddFunctions, + registerPolyfill = $__1.registerPolyfill, + toUint32 = $__1.toUint32; + var $isFinite = isFinite; + var $isNaN = isNaN; + var $__2 = Math, + abs = $__2.abs, + ceil = $__2.ceil, + exp = $__2.exp, + floor = $__2.floor, + log = $__2.log, + pow = $__2.pow, + sqrt = $__2.sqrt; + function clz32(x) { + x = toUint32(+x); + if (x == 0) + return 32; + var result = 0; + if ((x & 0xFFFF0000) === 0) { + x <<= 16; + result += 16; + } + ; + if ((x & 0xFF000000) === 0) { + x <<= 8; + result += 8; + } + ; + if ((x & 0xF0000000) === 0) { + x <<= 4; + result += 4; + } + ; + if ((x & 0xC0000000) === 0) { + x <<= 2; + result += 2; + } + ; + if ((x & 0x80000000) === 0) { + x <<= 1; + result += 1; + } + ; + return result; + } + function imul(x, y) { + x = toUint32(+x); + y = toUint32(+y); + var xh = (x >>> 16) & 0xffff; + var xl = x & 0xffff; + var yh = (y >>> 16) & 0xffff; + var yl = y & 0xffff; + return xl * yl + (((xh * yl + xl * yh) << 16) >>> 0) | 0; + } + function sign(x) { + x = +x; + if (x > 0) + return 1; + if (x < 0) + return -1; + return x; + } + function log10(x) { + return log(x) * 0.434294481903251828; + } + function log2(x) { + return log(x) * 1.442695040888963407; + } + function log1p(x) { + x = +x; + if (x < -1 || $isNaN(x)) { + return NaN; + } + if (x === 0 || x === Infinity) { + return x; + } + if (x === -1) { + return -Infinity; + } + var result = 0; + var n = 50; + if (x < 0 || x > 1) { + return log(1 + x); + } + for (var i = 1; i < n; i++) { + if ((i % 2) === 0) { + result -= pow(x, i) / i; + } else { + result += pow(x, i) / i; + } + } + return result; + } + function expm1(x) { + x = +x; + if (x === -Infinity) { + return -1; + } + if (!$isFinite(x) || x === 0) { + return x; + } + return exp(x) - 1; + } + function cosh(x) { + x = +x; + if (x === 0) { + return 1; + } + if ($isNaN(x)) { + return NaN; + } + if (!$isFinite(x)) { + return Infinity; + } + if (x < 0) { + x = -x; + } + if (x > 21) { + return exp(x) / 2; + } + return (exp(x) + exp(-x)) / 2; + } + function sinh(x) { + x = +x; + if (!$isFinite(x) || x === 0) { + return x; + } + return (exp(x) - exp(-x)) / 2; + } + function tanh(x) { + x = +x; + if (x === 0) + return x; + if (!$isFinite(x)) + return sign(x); + var exp1 = exp(x); + var exp2 = exp(-x); + return (exp1 - exp2) / (exp1 + exp2); + } + function acosh(x) { + x = +x; + if (x < 1) + return NaN; + if (!$isFinite(x)) + return x; + return log(x + sqrt(x + 1) * sqrt(x - 1)); + } + function asinh(x) { + x = +x; + if (x === 0 || !$isFinite(x)) + return x; + if (x > 0) + return log(x + sqrt(x * x + 1)); + return -log(-x + sqrt(x * x + 1)); + } + function atanh(x) { + x = +x; + if (x === -1) { + return -Infinity; + } + if (x === 1) { + return Infinity; + } + if (x === 0) { + return x; + } + if ($isNaN(x) || x < -1 || x > 1) { + return NaN; + } + return 0.5 * log((1 + x) / (1 - x)); + } + function hypot(x, y) { + var length = arguments.length; + var args = new Array(length); + var max = 0; + for (var i = 0; i < length; i++) { + var n = arguments[i]; + n = +n; + if (n === Infinity || n === -Infinity) + return Infinity; + n = abs(n); + if (n > max) + max = n; + args[i] = n; + } + if (max === 0) + max = 1; + var sum = 0; + var compensation = 0; + for (var i = 0; i < length; i++) { + var n = args[i] / max; + var summand = n * n - compensation; + var preliminary = sum + summand; + compensation = (preliminary - sum) - summand; + sum = preliminary; + } + return sqrt(sum) * max; + } + function trunc(x) { + x = +x; + if (x > 0) + return floor(x); + if (x < 0) + return ceil(x); + return x; + } + var fround, + f32; + if (typeof Float32Array === 'function') { + f32 = new Float32Array(1); + fround = function(x) { + f32[0] = Number(x); + return f32[0]; + }; + } else { + fround = jsFround; + } + ; + function cbrt(x) { + x = +x; + if (x === 0) + return x; + var negate = x < 0; + if (negate) + x = -x; + var result = pow(x, 1 / 3); + return negate ? -result : result; + } + function polyfillMath(global) { + var Math = global.Math; + maybeAddFunctions(Math, ['acosh', acosh, 'asinh', asinh, 'atanh', atanh, 'cbrt', cbrt, 'clz32', clz32, 'cosh', cosh, 'expm1', expm1, 'fround', fround, 'hypot', hypot, 'imul', imul, 'log10', log10, 'log1p', log1p, 'log2', log2, 'sign', sign, 'sinh', sinh, 'tanh', tanh, 'trunc', trunc]); + } + registerPolyfill(polyfillMath); + return { + get clz32() { + return clz32; + }, + get imul() { + return imul; + }, + get sign() { + return sign; + }, + get log10() { + return log10; + }, + get log2() { + return log2; + }, + get log1p() { + return log1p; + }, + get expm1() { + return expm1; + }, + get cosh() { + return cosh; + }, + get sinh() { + return sinh; + }, + get tanh() { + return tanh; + }, + get acosh() { + return acosh; + }, + get asinh() { + return asinh; + }, + get atanh() { + return atanh; + }, + get hypot() { + return hypot; + }, + get trunc() { + return trunc; + }, + get fround() { + return fround; + }, + get cbrt() { + return cbrt; + }, + get polyfillMath() { + return polyfillMath; + } + }; +}); +System.get("traceur-runtime@0.0.87/src/runtime/polyfills/Math.js" + ''); +System.registerModule("traceur-runtime@0.0.87/src/runtime/polyfills/polyfills.js", [], function() { + "use strict"; + var __moduleName = "traceur-runtime@0.0.87/src/runtime/polyfills/polyfills.js"; + var polyfillAll = System.get("traceur-runtime@0.0.87/src/runtime/polyfills/utils.js").polyfillAll; + polyfillAll(Reflect.global); + var setupGlobals = $traceurRuntime.setupGlobals; + $traceurRuntime.setupGlobals = function(global) { + setupGlobals(global); + polyfillAll(global); + }; + return {}; +}); +System.get("traceur-runtime@0.0.87/src/runtime/polyfills/polyfills.js" + ''); diff --git a/scripts/component/zone-microtask.js b/scripts/component/zone-microtask.js new file mode 100644 index 0000000000..4e47de2358 --- /dev/null +++ b/scripts/component/zone-microtask.js @@ -0,0 +1,1937 @@ +(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o postsJSON + values[1] // => commentsJSON + + return values; + }); + ``` + + @class Promise + @param {function} resolver + Useful for tooling. + @constructor + */ + function lib$es6$promise$promise$$Promise(resolver) { + this._id = lib$es6$promise$promise$$counter++; + this._state = undefined; + this._result = undefined; + this._subscribers = []; + + if (lib$es6$promise$$internal$$noop !== resolver) { + if (!lib$es6$promise$utils$$isFunction(resolver)) { + lib$es6$promise$promise$$needsResolver(); + } + + if (!(this instanceof lib$es6$promise$promise$$Promise)) { + lib$es6$promise$promise$$needsNew(); + } + + lib$es6$promise$$internal$$initializePromise(this, resolver); + } + } + + lib$es6$promise$promise$$Promise.all = lib$es6$promise$promise$all$$default; + lib$es6$promise$promise$$Promise.race = lib$es6$promise$promise$race$$default; + lib$es6$promise$promise$$Promise.resolve = lib$es6$promise$promise$resolve$$default; + lib$es6$promise$promise$$Promise.reject = lib$es6$promise$promise$reject$$default; + + lib$es6$promise$promise$$Promise.prototype = { + constructor: lib$es6$promise$promise$$Promise, + + /** + The primary way of interacting with a promise is through its `then` method, + which registers callbacks to receive either a promise's eventual value or the + reason why the promise cannot be fulfilled. + + ```js + findUser().then(function(user){ + // user is available + }, function(reason){ + // user is unavailable, and you are given the reason why + }); + ``` + + Chaining + -------- + + The return value of `then` is itself a promise. This second, 'downstream' + promise is resolved with the return value of the first promise's fulfillment + or rejection handler, or rejected if the handler throws an exception. + + ```js + findUser().then(function (user) { + return user.name; + }, function (reason) { + return 'default name'; + }).then(function (userName) { + // If `findUser` fulfilled, `userName` will be the user's name, otherwise it + // will be `'default name'` + }); + + findUser().then(function (user) { + throw new Error('Found user, but still unhappy'); + }, function (reason) { + throw new Error('`findUser` rejected and we're unhappy'); + }).then(function (value) { + // never reached + }, function (reason) { + // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'. + // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'. + }); + ``` + If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream. + + ```js + findUser().then(function (user) { + throw new PedagogicalException('Upstream error'); + }).then(function (value) { + // never reached + }).then(function (value) { + // never reached + }, function (reason) { + // The `PedgagocialException` is propagated all the way down to here + }); + ``` + + Assimilation + ------------ + + Sometimes the value you want to propagate to a downstream promise can only be + retrieved asynchronously. This can be achieved by returning a promise in the + fulfillment or rejection handler. The downstream promise will then be pending + until the returned promise is settled. This is called *assimilation*. + + ```js + findUser().then(function (user) { + return findCommentsByAuthor(user); + }).then(function (comments) { + // The user's comments are now available + }); + ``` + + If the assimliated promise rejects, then the downstream promise will also reject. + + ```js + findUser().then(function (user) { + return findCommentsByAuthor(user); + }).then(function (comments) { + // If `findCommentsByAuthor` fulfills, we'll have the value here + }, function (reason) { + // If `findCommentsByAuthor` rejects, we'll have the reason here + }); + ``` + + Simple Example + -------------- + + Synchronous Example + + ```javascript + var result; + + try { + result = findResult(); + // success + } catch(reason) { + // failure + } + ``` + + Errback Example + + ```js + findResult(function(result, err){ + if (err) { + // failure + } else { + // success + } + }); + ``` + + Promise Example; + + ```javascript + findResult().then(function(result){ + // success + }, function(reason){ + // failure + }); + ``` + + Advanced Example + -------------- + + Synchronous Example + + ```javascript + var author, books; + + try { + author = findAuthor(); + books = findBooksByAuthor(author); + // success + } catch(reason) { + // failure + } + ``` + + Errback Example + + ```js + + function foundBooks(books) { + + } + + function failure(reason) { + + } + + findAuthor(function(author, err){ + if (err) { + failure(err); + // failure + } else { + try { + findBoooksByAuthor(author, function(books, err) { + if (err) { + failure(err); + } else { + try { + foundBooks(books); + } catch(reason) { + failure(reason); + } + } + }); + } catch(error) { + failure(err); + } + // success + } + }); + ``` + + Promise Example; + + ```javascript + findAuthor(). + then(findBooksByAuthor). + then(function(books){ + // found books + }).catch(function(reason){ + // something went wrong + }); + ``` + + @method then + @param {Function} onFulfilled + @param {Function} onRejected + Useful for tooling. + @return {Promise} + */ + then: function(onFulfillment, onRejection) { + var parent = this; + var state = parent._state; + + if (state === lib$es6$promise$$internal$$FULFILLED && !onFulfillment || state === lib$es6$promise$$internal$$REJECTED && !onRejection) { + return this; + } + + var child = new this.constructor(lib$es6$promise$$internal$$noop); + var result = parent._result; + + if (state) { + var callback = arguments[state - 1]; + lib$es6$promise$asap$$default(function(){ + lib$es6$promise$$internal$$invokeCallback(state, child, callback, result); + }); + } else { + lib$es6$promise$$internal$$subscribe(parent, child, onFulfillment, onRejection); + } + + return child; + }, + + /** + `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same + as the catch block of a try/catch statement. + + ```js + function findAuthor(){ + throw new Error('couldn't find that author'); + } + + // synchronous + try { + findAuthor(); + } catch(reason) { + // something went wrong + } + + // async with promises + findAuthor().catch(function(reason){ + // something went wrong + }); + ``` + + @method catch + @param {Function} onRejection + Useful for tooling. + @return {Promise} + */ + 'catch': function(onRejection) { + return this.then(null, onRejection); + } + }; + function lib$es6$promise$polyfill$$polyfill() { + var local; + + if (typeof global !== 'undefined') { + local = global; + } else if (typeof self !== 'undefined') { + local = self; + } else { + try { + local = Function('return this')(); + } catch (e) { + throw new Error('polyfill failed because global object is unavailable in this environment'); + } + } + + var P = local.Promise; + + if (P && Object.prototype.toString.call(P.resolve()) === '[object Promise]' && !P.cast) { + return; + } + + local.Promise = lib$es6$promise$promise$$default; + } + var lib$es6$promise$polyfill$$default = lib$es6$promise$polyfill$$polyfill; + + var lib$es6$promise$umd$$ES6Promise = { + 'Promise': lib$es6$promise$promise$$default, + 'polyfill': lib$es6$promise$polyfill$$default + }; + + /* global define:true module:true window: true */ + if (typeof define === 'function' && define['amd']) { + define(function() { return lib$es6$promise$umd$$ES6Promise; }); + } else if (typeof module !== 'undefined' && module['exports']) { + module['exports'] = lib$es6$promise$umd$$ES6Promise; + } else if (typeof this !== 'undefined') { + this['ES6Promise'] = lib$es6$promise$umd$$ES6Promise; + } + + lib$es6$promise$polyfill$$default(); +}).call(this); + + +}).call(this,{},typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],4:[function(require,module,exports){ +(function (global){ +'use strict'; + +function scheduleMicrotask(fn) { + asap(this.bind(fn)); +} + +function addMicrotaskSupport(zoneClass) { + zoneClass.prototype.scheduleMicrotask = scheduleMicrotask; + return zoneClass; +} + +module.exports = { + addMicrotaskSupport: addMicrotaskSupport +}; + +// TODO(vicb): There are plan to be able to use asap() from es6-promise +// see https://github.com/jakearchibald/es6-promise/pull/113 +// for now adapt code from asap.js in es6-promise +// Note: the node support has been dropped here + +// TODO(vicb): Create a benchmark for the different methods & the usage of the queue +// see https://github.com/angular/zone.js/issues/97 + +var len = 0; + +var hasNativePromise = typeof Promise ==! "undefined" && + Promise.toString().indexOf("[native code]") !== -1; + +var isFirefox = global.navigator && + global.navigator.userAgent.toLowerCase().indexOf('firefox') > -1; + +function asap(callback) { + queue[len] = callback; + len += 1; + if (len === 1) { + scheduleFlush(); + } +} + +var browserWindow = (typeof global.window !== 'undefined') ? global.window : undefined; +var browserGlobal = browserWindow || {}; +var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver; + +// test for web worker but not in IE10 +var isWorker = typeof Uint8ClampedArray !== 'undefined' && + typeof importScripts !== 'undefined' && + typeof MessageChannel !== 'undefined'; + +function useMutationObserver() { + var iterations = 0; + var observer = new BrowserMutationObserver(flush); + var node = document.createTextNode(''); + observer.observe(node, { characterData: true }); + + return function() { + node.data = (iterations = ++iterations % 2); + }; +} + +// web worker +function useMessageChannel() { + var channel = new MessageChannel(); + channel.port1.onmessage = flush; + return function () { + channel.port2.postMessage(0); + }; +} + +function useSetTimeout() { + return function() { + setTimeout(flush, 1); + }; +} + +function usePromise() { + var resolvedPromise = Promise.resolve(void 0); + return function() { + resolvedPromise.then(flush); + } +} + +var queue = new Array(1000); + +function flush() { + for (var i = 0; i < len; i++) { + var callback = queue[i]; + callback(); + queue[i] = undefined; + } + + len = 0; +} + +var scheduleFlush; +// Decide what async method to use to triggering processing of queued callbacks: +if (hasNativePromise && !isFirefox) { + // TODO(vicb): remove '!isFirefox' when the bug is fixed: + // https://bugzilla.mozilla.org/show_bug.cgi?id=1162013 + scheduleFlush = usePromise(); +} else if (BrowserMutationObserver) { + scheduleFlush = useMutationObserver(); +} else if (isWorker) { + scheduleFlush = useMessageChannel(); +} else { + scheduleFlush = useSetTimeout(); +} + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],5:[function(require,module,exports){ +(function (global){ +'use strict'; + +var fnPatch = require('./functions'); +var promisePatch = require('./promise'); +var mutationObserverPatch = require('./mutation-observer'); +var definePropertyPatch = require('./define-property'); +var registerElementPatch = require('./register-element'); +var webSocketPatch = require('./websocket'); +var eventTargetPatch = require('./event-target'); +var propertyDescriptorPatch = require('./property-descriptor'); + +function apply() { + fnPatch.patchSetClearFunction(global, [ + 'timeout', + 'interval', + 'immediate' + ]); + + fnPatch.patchSetFunction(global, [ + 'requestAnimationFrame', + 'mozRequestAnimationFrame', + 'webkitRequestAnimationFrame' + ]); + + fnPatch.patchFunction(global, [ + 'alert', + 'prompt' + ]); + + eventTargetPatch.apply(); + + propertyDescriptorPatch.apply(); + + promisePatch.apply(); + + mutationObserverPatch.patchClass('MutationObserver'); + mutationObserverPatch.patchClass('WebKitMutationObserver'); + + definePropertyPatch.apply(); + + registerElementPatch.apply(); +} + +module.exports = { + apply: apply +}; + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"./define-property":6,"./event-target":7,"./functions":8,"./mutation-observer":9,"./promise":10,"./property-descriptor":11,"./register-element":12,"./websocket":13}],6:[function(require,module,exports){ +'use strict'; + +// might need similar for object.freeze +// i regret nothing + +var _defineProperty = Object.defineProperty; +var _getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; +var _create = Object.create; + +function apply() { + Object.defineProperty = function (obj, prop, desc) { + if (isUnconfigurable(obj, prop)) { + throw new TypeError('Cannot assign to read only property \'' + prop + '\' of ' + obj); + } + if (prop !== 'prototype') { + desc = rewriteDescriptor(obj, prop, desc); + } + return _defineProperty(obj, prop, desc); + }; + + Object.defineProperties = function (obj, props) { + Object.keys(props).forEach(function (prop) { + Object.defineProperty(obj, prop, props[prop]); + }); + return obj; + }; + + Object.create = function (obj, proto) { + if (typeof proto === 'object') { + Object.keys(proto).forEach(function (prop) { + proto[prop] = rewriteDescriptor(obj, prop, proto[prop]); + }); + } + return _create(obj, proto); + }; + + Object.getOwnPropertyDescriptor = function (obj, prop) { + var desc = _getOwnPropertyDescriptor(obj, prop); + if (isUnconfigurable(obj, prop)) { + desc.configurable = false; + } + return desc; + }; +}; + +function _redefineProperty(obj, prop, desc) { + desc = rewriteDescriptor(obj, prop, desc); + return _defineProperty(obj, prop, desc); +}; + +function isUnconfigurable (obj, prop) { + return obj && obj.__unconfigurables && obj.__unconfigurables[prop]; +} + +function rewriteDescriptor (obj, prop, desc) { + desc.configurable = true; + if (!desc.configurable) { + if (!obj.__unconfigurables) { + _defineProperty(obj, '__unconfigurables', { writable: true, value: {} }); + } + obj.__unconfigurables[prop] = true; + } + return desc; +} + +module.exports = { + apply: apply, + _redefineProperty: _redefineProperty +}; + + + +},{}],7:[function(require,module,exports){ +(function (global){ +'use strict'; + +var utils = require('../utils'); + +function apply() { + // patched properties depend on addEventListener, so this needs to come first + if (global.EventTarget) { + utils.patchEventTargetMethods(global.EventTarget.prototype); + + // Note: EventTarget is not available in all browsers, + // if it's not available, we instead patch the APIs in the IDL that inherit from EventTarget + } else { + var apis = [ 'ApplicationCache', + 'EventSource', + 'FileReader', + 'InputMethodContext', + 'MediaController', + 'MessagePort', + 'Node', + 'Performance', + 'SVGElementInstance', + 'SharedWorker', + 'TextTrack', + 'TextTrackCue', + 'TextTrackList', + 'WebKitNamedFlow', + 'Window', + 'Worker', + 'WorkerGlobalScope', + 'XMLHttpRequestEventTarget', + 'XMLHttpRequestUpload' + ]; + + apis.forEach(function(thing) { + global[thing] && utils.patchEventTargetMethods(global[thing].prototype); + }); + } +} + +module.exports = { + apply: apply +}; + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"../utils":14}],8:[function(require,module,exports){ +(function (global){ +'use strict'; + +var utils = require('../utils'); + +function patchSetClearFunction(obj, fnNames) { + fnNames.map(function (name) { + return name[0].toUpperCase() + name.substr(1); + }).forEach(function (name) { + var setName = 'set' + name; + var delegate = obj[setName]; + + if (delegate) { + var clearName = 'clear' + name; + var ids = {}; + + var bindArgs = setName === 'setInterval' ? utils.bindArguments : utils.bindArgumentsOnce; + + global.zone[setName] = function (fn) { + var id, fnRef = fn; + arguments[0] = function () { + delete ids[id]; + return fnRef.apply(this, arguments); + }; + var args = bindArgs(arguments); + id = delegate.apply(obj, args); + ids[id] = true; + return id; + }; + + obj[setName] = function () { + return global.zone[setName].apply(this, arguments); + }; + + var clearDelegate = obj[clearName]; + + global.zone[clearName] = function (id) { + if (ids[id]) { + delete ids[id]; + global.zone.dequeueTask(); + } + return clearDelegate.apply(this, arguments); + }; + + obj[clearName] = function () { + return global.zone[clearName].apply(this, arguments); + }; + } + }); +}; + +function patchSetFunction(obj, fnNames) { + fnNames.forEach(function (name) { + var delegate = obj[name]; + + if (delegate) { + global.zone[name] = function (fn) { + var fnRef = fn; + arguments[0] = function () { + return fnRef.apply(this, arguments); + }; + var args = utils.bindArgumentsOnce(arguments); + return delegate.apply(obj, args); + }; + + obj[name] = function () { + return zone[name].apply(this, arguments); + }; + } + }); +}; + +function patchFunction(obj, fnNames) { + fnNames.forEach(function (name) { + var delegate = obj[name]; + global.zone[name] = function () { + return delegate.apply(obj, arguments); + }; + + obj[name] = function () { + return global.zone[name].apply(this, arguments); + }; + }); +}; + + +module.exports = { + patchSetClearFunction: patchSetClearFunction, + patchSetFunction: patchSetFunction, + patchFunction: patchFunction +}; + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"../utils":14}],9:[function(require,module,exports){ +(function (global){ +'use strict'; + +// wrap some native API on `window` +function patchClass(className) { + var OriginalClass = global[className]; + if (!OriginalClass) return; + + global[className] = function (fn) { + this._o = new OriginalClass(global.zone.bind(fn, true)); + // Remember where the class was instantiate to execute the enqueueTask and dequeueTask hooks + this._creationZone = global.zone; + }; + + var instance = new OriginalClass(function () {}); + + global[className].prototype.disconnect = function () { + var result = this._o.disconnect.apply(this._o, arguments); + if (this._active) { + this._creationZone.dequeueTask(); + this._active = false; + } + return result; + }; + + global[className].prototype.observe = function () { + if (!this._active) { + this._creationZone.enqueueTask(); + this._active = true; + } + return this._o.observe.apply(this._o, arguments); + }; + + var prop; + for (prop in instance) { + (function (prop) { + if (typeof global[className].prototype !== undefined) { + return; + } + if (typeof instance[prop] === 'function') { + global[className].prototype[prop] = function () { + return this._o[prop].apply(this._o, arguments); + }; + } else { + Object.defineProperty(global[className].prototype, prop, { + set: function (fn) { + if (typeof fn === 'function') { + this._o[prop] = global.zone.bind(fn); + } else { + this._o[prop] = fn; + } + }, + get: function () { + return this._o[prop]; + } + }); + } + }(prop)); + } +}; + +module.exports = { + patchClass: patchClass +}; + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],10:[function(require,module,exports){ +(function (global){ +'use strict'; + +var utils = require('../utils'); + +/* + * patch a fn that returns a promise + */ +var bindPromiseFn = (function() { + // if the browser natively supports Promises, we can just return a native promise + if (global.Promise) { + return function (delegate) { + return function() { + var delegatePromise = delegate.apply(this, arguments); + if (delegatePromise instanceof Promise) { + return delegatePromise; + } else { + return new Promise(function(resolve, reject) { + delegatePromise.then(resolve, reject); + }); + } + }; + }; + } else { + // if the browser does not have native promises, we have to patch each promise instance + return function (delegate) { + return function () { + return patchThenable(delegate.apply(this, arguments)); + }; + }; + } + + function patchThenable(thenable) { + var then = thenable.then; + thenable.then = function () { + var args = utils.bindArguments(arguments); + var nextThenable = then.apply(thenable, args); + return patchThenable(nextThenable); + }; + + var ocatch = thenable.catch; + thenable.catch = function () { + var args = utils.bindArguments(arguments); + var nextThenable = ocatch.apply(thenable, args); + return patchThenable(nextThenable); + }; + return thenable; + } +}()); + +function apply() { + if (global.Promise) { + utils.patchPrototype(Promise.prototype, [ + 'then', + 'catch' + ]); + } +} + +module.exports = { + apply: apply, + bindPromiseFn: bindPromiseFn +}; + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"../utils":14}],11:[function(require,module,exports){ +(function (global){ +'use strict'; + +var webSocketPatch = require('./websocket'); +var utils = require('../utils'); + +var eventNames = 'copy cut paste abort blur focus canplay canplaythrough change click contextmenu dblclick drag dragend dragenter dragleave dragover dragstart drop durationchange emptied ended input invalid keydown keypress keyup load loadeddata loadedmetadata loadstart message mousedown mouseenter mouseleave mousemove mouseout mouseover mouseup pause play playing progress ratechange reset scroll seeked seeking select show stalled submit suspend timeupdate volumechange waiting mozfullscreenchange mozfullscreenerror mozpointerlockchange mozpointerlockerror error webglcontextrestored webglcontextlost webglcontextcreationerror'.split(' '); + +function apply() { + if (canPatchViaPropertyDescriptor()) { + // for browsers that we can patch the descriptor: Chrome & Firefox + var onEventNames = eventNames.map(function (property) { + return 'on' + property; + }); + utils.patchProperties(HTMLElement.prototype, onEventNames); + utils.patchProperties(XMLHttpRequest.prototype); + utils.patchProperties(WebSocket.prototype); + } else { + // Safari + patchViaCapturingAllTheEvents(); + utils.patchClass('XMLHttpRequest'); + webSocketPatch.apply(); + } +} + +function canPatchViaPropertyDescriptor() { + if (!Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'onclick') && typeof Element !== 'undefined') { + // WebKit https://bugs.webkit.org/show_bug.cgi?id=134364 + // IDL interface attributes are not configurable + var desc = Object.getOwnPropertyDescriptor(Element.prototype, 'onclick'); + if (desc && !desc.configurable) return false; + } + + Object.defineProperty(HTMLElement.prototype, 'onclick', { + get: function () { + return true; + } + }); + var elt = document.createElement('div'); + var result = !!elt.onclick; + Object.defineProperty(HTMLElement.prototype, 'onclick', {}); + return result; +}; + +// Whenever any event fires, we check the event target and all parents +// for `onwhatever` properties and replace them with zone-bound functions +// - Chrome (for now) +function patchViaCapturingAllTheEvents() { + eventNames.forEach(function (property) { + var onproperty = 'on' + property; + document.addEventListener(property, function (event) { + var elt = event.target, bound; + while (elt) { + if (elt[onproperty] && !elt[onproperty]._unbound) { + bound = global.zone.bind(elt[onproperty]); + bound._unbound = elt[onproperty]; + elt[onproperty] = bound; + } + elt = elt.parentElement; + } + }, true); + }); +}; + +module.exports = { + apply: apply +}; + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"../utils":14,"./websocket":13}],12:[function(require,module,exports){ +(function (global){ +'use strict'; + +var _redefineProperty = require('./define-property')._redefineProperty; + +function apply() { + if (!('registerElement' in global.document)) { + return; + } + + var _registerElement = document.registerElement; + var callbacks = [ + 'createdCallback', + 'attachedCallback', + 'detachedCallback', + 'attributeChangedCallback' + ]; + + document.registerElement = function (name, opts) { + callbacks.forEach(function (callback) { + if (opts.prototype[callback]) { + var descriptor = Object.getOwnPropertyDescriptor(opts.prototype, callback); + if (descriptor.value) { + descriptor.value = global.zone.bind(descriptor.value || opts.prototype[callback]); + _redefineProperty(opts.prototype, callback, descriptor); + } + } + }); + return _registerElement.apply(document, [name, opts]); + }; +} + +module.exports = { + apply: apply +}; + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"./define-property":6}],13:[function(require,module,exports){ +(function (global){ +'use strict'; + +var utils = require('../utils.js'); + +// we have to patch the instance since the proto is non-configurable +function apply() { + var WS = global.WebSocket; + utils.patchEventTargetMethods(WS.prototype); + global.WebSocket = function(a, b) { + var socket = arguments.length > 1 ? new WS(a, b) : new WS(a); + var proxySocket; + + // Safari 7.0 has non-configurable own 'onmessage' and friends properties on the socket instance + var onmessageDesc = Object.getOwnPropertyDescriptor(socket, 'onmessage'); + if (onmessageDesc && onmessageDesc.configurable === false) { + proxySocket = Object.create(socket); + ['addEventListener', 'removeEventListener', 'send', 'close'].forEach(function(propName) { + proxySocket[propName] = function() { + return socket[propName].apply(socket, arguments); + }; + }); + } else { + // we can patch the real socket + proxySocket = socket; + } + + utils.patchProperties(proxySocket, ['onclose', 'onerror', 'onmessage', 'onopen']); + + return proxySocket; + }; +} + +module.exports = { + apply: apply +}; + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"../utils.js":14}],14:[function(require,module,exports){ +(function (global){ +'use strict'; + +function bindArguments(args) { + for (var i = args.length - 1; i >= 0; i--) { + if (typeof args[i] === 'function') { + args[i] = global.zone.bind(args[i]); + } + } + return args; +}; + +function bindArgumentsOnce(args) { + for (var i = args.length - 1; i >= 0; i--) { + if (typeof args[i] === 'function') { + args[i] = global.zone.bindOnce(args[i]); + } + } + return args; +}; + +function patchPrototype(obj, fnNames) { + fnNames.forEach(function (name) { + var delegate = obj[name]; + if (delegate) { + obj[name] = function () { + return delegate.apply(this, bindArguments(arguments)); + }; + } + }); +}; + +function patchProperty(obj, prop) { + var desc = Object.getOwnPropertyDescriptor(obj, prop) || { + enumerable: true, + configurable: true + }; + + // A property descriptor cannot have getter/setter and be writable + // deleting the writable and value properties avoids this error: + // + // TypeError: property descriptors must not specify a value or be writable when a + // getter or setter has been specified + delete desc.writable; + delete desc.value; + + // substr(2) cuz 'onclick' -> 'click', etc + var eventName = prop.substr(2); + var _prop = '_' + prop; + + desc.set = function (fn) { + if (this[_prop]) { + this.removeEventListener(eventName, this[_prop]); + } + + if (typeof fn === 'function') { + this[_prop] = fn; + this.addEventListener(eventName, fn, false); + } else { + this[_prop] = null; + } + }; + + desc.get = function () { + return this[_prop]; + }; + + Object.defineProperty(obj, prop, desc); +}; + +function patchProperties(obj, properties) { + + (properties || (function () { + var props = []; + for (var prop in obj) { + props.push(prop); + } + return props; + }()). + filter(function (propertyName) { + return propertyName.substr(0,2) === 'on'; + })). + forEach(function (eventName) { + patchProperty(obj, eventName); + }); +}; + +function patchEventTargetMethods(obj) { + var addDelegate = obj.addEventListener; + obj.addEventListener = function (eventName, fn) { + fn._bound = fn._bound || {}; + arguments[1] = fn._bound[eventName] = zone.bind(fn); + return addDelegate.apply(this, arguments); + }; + + var removeDelegate = obj.removeEventListener; + obj.removeEventListener = function (eventName, fn) { + if(arguments[1]._bound && arguments[1]._bound[eventName]) { + var _bound = arguments[1]._bound; + arguments[1] = _bound[eventName]; + delete _bound[eventName]; + } + var result = removeDelegate.apply(this, arguments); + global.zone.dequeueTask(fn); + return result; + }; +}; + +// wrap some native API on `window` +function patchClass(className) { + var OriginalClass = global[className]; + if (!OriginalClass) return; + + global[className] = function () { + var a = bindArguments(arguments); + switch (a.length) { + case 0: this._o = new OriginalClass(); break; + case 1: this._o = new OriginalClass(a[0]); break; + case 2: this._o = new OriginalClass(a[0], a[1]); break; + case 3: this._o = new OriginalClass(a[0], a[1], a[2]); break; + case 4: this._o = new OriginalClass(a[0], a[1], a[2], a[3]); break; + default: throw new Error('what are you even doing?'); + } + }; + + var instance = new OriginalClass(className.substr(-16) === 'MutationObserver' ? function () {} : undefined); + + var prop; + for (prop in instance) { + (function (prop) { + if (typeof instance[prop] === 'function') { + global[className].prototype[prop] = function () { + return this._o[prop].apply(this._o, arguments); + }; + } else { + Object.defineProperty(global[className].prototype, prop, { + set: function (fn) { + if (typeof fn === 'function') { + this._o[prop] = global.zone.bind(fn); + } else { + this._o[prop] = fn; + } + }, + get: function () { + return this._o[prop]; + } + }); + } + }(prop)); + }; +}; + +module.exports = { + bindArguments: bindArguments, + bindArgumentsOnce: bindArgumentsOnce, + patchPrototype: patchPrototype, + patchProperty: patchProperty, + patchProperties: patchProperties, + patchEventTargetMethods: patchEventTargetMethods, + patchClass: patchClass +}; + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}]},{},[1]); diff --git a/scripts/e2e/ionic.template.html b/scripts/e2e/ionic.template.html index cb25d904a6..610f9ef197 100644 --- a/scripts/e2e/ionic.template.html +++ b/scripts/e2e/ionic.template.html @@ -21,19 +21,19 @@ - - + + - - - - - - - + + + + + + +