diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-05-21 23:43:28 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-05-21 23:43:28 +0200 |
commit | 0fa67552247b2d29a6ca438c2605b8db2bbdbab7 (patch) | |
tree | 8109135e2fc141a324e8f21c66243ee4277b3b7c /js/vendor | |
parent | d3a774b2bd79654360a3ef12618102abf85a2ce3 (diff) |
es6 all the things
Diffstat (limited to 'js/vendor')
-rw-r--r-- | js/vendor/traceur-runtime/.bower.json | 22 | ||||
-rw-r--r-- | js/vendor/traceur-runtime/README.md | 35 | ||||
-rw-r--r-- | js/vendor/traceur-runtime/traceur-runtime.js | 1712 | ||||
-rw-r--r-- | js/vendor/traceur-runtime/traceur-runtime.min.js | 2 | ||||
-rw-r--r-- | js/vendor/traceur-runtime/traceur-runtime.min.map | 1 |
5 files changed, 1772 insertions, 0 deletions
diff --git a/js/vendor/traceur-runtime/.bower.json b/js/vendor/traceur-runtime/.bower.json new file mode 100644 index 000000000..952c74fff --- /dev/null +++ b/js/vendor/traceur-runtime/.bower.json @@ -0,0 +1,22 @@ +{ + "name": "traceur-runtime", + "version": "0.0.41", + "main": "./traceur-runtime.js", + "ignore": [ + "node_modules", + "Gruntfile.js", + "*.json", + ".*" + ], + "homepage": "https://github.com/jmcriffey/bower-traceur-runtime", + "_release": "0.0.41", + "_resolution": { + "type": "version", + "tag": "0.0.41", + "commit": "1327dd26531cc4c5371bbab30f72c908e1abab2e" + }, + "_source": "git://github.com/jmcriffey/bower-traceur-runtime.git", + "_target": "~0.0.41", + "_originalSource": "traceur-runtime", + "_direct": true +}
\ No newline at end of file diff --git a/js/vendor/traceur-runtime/README.md b/js/vendor/traceur-runtime/README.md new file mode 100644 index 000000000..a1150103b --- /dev/null +++ b/js/vendor/traceur-runtime/README.md @@ -0,0 +1,35 @@ +# bower-traceur-runtime + +This repo is for distribution on `bower`. The source for this module is in the +[main traceur repo](https://github.com/google/traceur-compiler/). +Please file issues and pull requests against that repo. + +## Install + +Install with `bower`: + +```shell +bower install traceur-runtime +``` + +Add a `<script>` to your `index.html`: + +```html +<script src="/bower_components/traceur-runtime/traceur-runtime.js"></script> +``` + +## License + +Copyright 2012 Traceur Authors. + +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. diff --git a/js/vendor/traceur-runtime/traceur-runtime.js b/js/vendor/traceur-runtime/traceur-runtime.js new file mode 100644 index 000000000..b3f9f54d5 --- /dev/null +++ b/js/vendor/traceur-runtime/traceur-runtime.js @@ -0,0 +1,1712 @@ +(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 $getPrototypeOf = $Object.getPrototypeOf; + 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; + function nonEnum(value) { + return { + configurable: true, + enumerable: false, + value: value, + writable: true + }; + } + var types = { + void: function voidType() {}, + any: function any() {}, + string: function string() {}, + number: function number() {}, + boolean: function boolean() {} + }; + var method = nonEnum; + var counter = 0; + function newUniqueString() { + return '__$' + Math.floor(Math.random() * 1e9) + '$' + ++counter + '$__'; + } + var symbolInternalProperty = newUniqueString(); + var symbolDescriptionProperty = newUniqueString(); + var symbolDataProperty = newUniqueString(); + var symbolValues = $create(null); + var privateNames = $create(null); + function createPrivateName() { + var s = newUniqueString(); + privateNames[s] = true; + return s; + } + function isSymbol(symbol) { + return typeof symbol === 'object' && symbol instanceof SymbolValue; + } + function typeOf(v) { + if (isSymbol(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]; + if (!getOption('symbols')) + return symbolValue[symbolInternalProperty]; + if (!symbolValue) + throw TypeError('Conversion from symbol to string'); + var desc = symbolValue[symbolDescriptionProperty]; + if (desc === undefined) + desc = ''; + return 'Symbol(' + desc + ')'; + })); + $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); + } + Symbol.iterator = Symbol(); + freeze(SymbolValue.prototype); + function toProperty(name) { + if (isSymbol(name)) + return name[symbolInternalProperty]; + return name; + } + function getOwnPropertyNames(object) { + var rv = []; + var names = $getOwnPropertyNames(object); + for (var i = 0; i < names.length; i++) { + var name = names[i]; + if (!symbolValues[name] && !privateNames[name]) + rv.push(name); + } + return rv; + } + function getOwnPropertyDescriptor(object, name) { + return $getOwnPropertyDescriptor(object, toProperty(name)); + } + 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 hasOwnProperty(name) { + return $hasOwnProperty.call(this, toProperty(name)); + } + function getOption(name) { + return global.traceur && global.traceur.options[name]; + } + function setProperty(object, name, value) { + var sym, + desc; + if (isSymbol(name)) { + sym = name; + name = name[symbolInternalProperty]; + } + object[name] = value; + if (sym && (desc = $getOwnPropertyDescriptor(object, name))) + $defineProperty(object, name, {enumerable: false}); + return value; + } + function defineProperty(object, name, descriptor) { + if (isSymbol(name)) { + if (descriptor.enumerable) { + descriptor = $create(descriptor, {enumerable: {value: false}}); + } + 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}); + Object.getOwnPropertySymbols = getOwnPropertySymbols; + function is(left, right) { + if (left === right) + return left !== 0 || 1 / left === 1 / right; + return left !== left && right !== right; + } + $defineProperty(Object, 'is', method(is)); + function assign(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i]; + var props = $keys(source); + var p, + length = props.length; + for (p = 0; p < length; p++) { + var name = props[p]; + if (privateNames[name]) + continue; + target[name] = source[name]; + } + } + return target; + } + $defineProperty(Object, 'assign', method(assign)); + 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 (privateNames[name]) + continue; + descriptor = $getOwnPropertyDescriptor(source, props[p]); + $defineProperty(target, props[p], descriptor); + } + return target; + } + $defineProperty(Object, 'mixin', method(mixin)); + } + 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 (privateNames[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 assertObject(x) { + if (!isObject(x)) + throw $TypeError(x + ' is not an Object'); + return x; + } + function spread() { + var rv = [], + k = 0; + for (var i = 0; i < arguments.length; i++) { + var valueToSpread = toObject(arguments[i]); + for (var j = 0; j < valueToSpread.length; j++) { + rv[k++] = valueToSpread[j]; + } + } + return rv; + } + 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 superCall(self, homeObject, name, args) { + return superGet(self, homeObject, name).apply(self, args); + } + 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 = {}, + name, + names = $getOwnPropertyNames(object); + for (var i = 0; i < names.length; i++) { + var name = names[i]; + descriptors[name] = $getOwnPropertyDescriptor(object, name); + } + 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; + } + if (superClass === null) + return null; + throw new TypeError(); + } + function defaultSuperCall(self, homeObject, args) { + if ($getPrototypeOf(homeObject) !== null) + superCall(self, homeObject, 'constructor', args); + } + 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); + } + function GeneratorContext() { + this.state = 0; + this.GState = ST_NEWBORN; + this.storedException = undefined; + this.finallyFallThrough = undefined; + this.sent_ = undefined; + this.returnValue = 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(); + }, + 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; + } + }; + function nextOrThrow(ctx, moveNext, action, x) { + switch (ctx.GState) { + case ST_EXECUTING: + throw new Error(("\"" + action + "\" on executing generator")); + case ST_CLOSED: + throw new Error(("\"" + action + "\" on closed generator")); + case ST_NEWBORN: + if (action === 'throw') { + ctx.GState = ST_CLOSED; + 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 = moveNext(ctx); + 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); + } + }; + $defineProperties(GeneratorFunctionPrototype.prototype, { + constructor: {enumerable: false}, + next: {enumerable: false}, + throw: {enumerable: false} + }); + 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 = Object.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; + } + function setupGlobals(global) { + global.Symbol = Symbol; + polyfillObject(global.Object); + } + setupGlobals(global); + global.$traceurRuntime = { + assertObject: assertObject, + asyncWrap: asyncWrap, + createClass: createClass, + defaultSuperCall: defaultSuperCall, + exportStar: exportStar, + initGeneratorFunction: initGeneratorFunction, + createGeneratorInstance: createGeneratorInstance, + getOwnHashObject: getOwnHashObject, + setProperty: setProperty, + setupGlobals: setupGlobals, + spread: spread, + superCall: superCall, + superGet: superGet, + superSet: superSet, + toObject: toObject, + toProperty: toProperty, + type: types, + typeof: typeOf + }; +})(typeof global !== 'undefined' ? global : 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 $__2 = $traceurRuntime.assertObject($traceurRuntime), + canonicalizeUrl = $__2.canonicalizeUrl, + resolveUrl = $__2.resolveUrl, + isAbsolute = $__2.isAbsolute; + var moduleInstantiators = Object.create(null); + var baseURL; + if (global.location && global.location.href) + baseURL = resolveUrl(global.location.href, './'); + else + baseURL = ''; + var UncoatedModuleEntry = function UncoatedModuleEntry(url, uncoatedModule) { + this.url = url; + this.value_ = uncoatedModule; + }; + ($traceurRuntime.createClass)(UncoatedModuleEntry, {}, {}); + var UncoatedModuleInstantiator = function UncoatedModuleInstantiator(url, func) { + $traceurRuntime.superCall(this, $UncoatedModuleInstantiator.prototype, "constructor", [url, null]); + this.func = func; + }; + var $UncoatedModuleInstantiator = UncoatedModuleInstantiator; + ($traceurRuntime.createClass)(UncoatedModuleInstantiator, {getUncoatedModule: function() { + if (this.value_) + return this.value_; + return this.value_ = this.func.call(global); + }}, {}, UncoatedModuleEntry); + 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, 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, 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; + } + })); |