diff --git a/dist/Aurelia Inspector 1.4.0.zip b/dist/Aurelia Inspector 1.4.0.zip new file mode 100644 index 0000000..e22a56f Binary files /dev/null and b/dist/Aurelia Inspector 1.4.0.zip differ diff --git a/manifest.json b/manifest.json index 86d284a..9a2b91c 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Aurelia Inspector", - "version": "1.3.0", + "version": "1.4.0", "description": "A Chrome plugin adding a new inspector pane to the Elements panel, providing Aurelia-specific information about selected elements.", "devtools_page": "devtools.html", "icons": { diff --git a/package.json b/package.json index 211f068..e81e7ec 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aurelia-inspector", - "version": "1.3.0", + "version": "1.4.0", "description": "A Chrome plugin that adds a new inspector pane to the Elements panel, providing Aurelia-specific information about selected elements.", "keywords": [ "aurelia", diff --git a/scripts/app-bundle.js b/scripts/app-bundle.js index cfec982..11c8978 100644 --- a/scripts/app-bundle.js +++ b/scripts/app-bundle.js @@ -1,24114 +1,12 @@ -/* @preserve - * The MIT License (MIT) - * - * Copyright (c) 2013-2015 Petka Antonov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - */ -/** - * bluebird build version 3.4.7 - * Features enabled: core - * Features disabled: race, call_get, generators, map, nodeify, promisify, props, reduce, settle, some, using, timers, filter, any, each -*/ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.Promise=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof _dereq_=="function"&&_dereq_;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 _dereq_=="function"&&_dereq_;for(var o=0;o 0) { - var fn = queue.shift(); - if (typeof fn !== "function") { - fn._settlePromises(); - continue; - } - var receiver = queue.shift(); - var arg = queue.shift(); - fn.call(receiver, arg); - } -}; - -Async.prototype._drainQueues = function () { - this._drainQueue(this._normalQueue); - this._reset(); - this._haveDrainedQueues = true; - this._drainQueue(this._lateQueue); -}; - -Async.prototype._queueTick = function () { - if (!this._isTickUsed) { - this._isTickUsed = true; - this._schedule(this.drainQueues); - } -}; - -Async.prototype._reset = function () { - this._isTickUsed = false; -}; - -module.exports = Async; -module.exports.firstLineError = firstLineError; - -},{"./queue":17,"./schedule":18,"./util":21}],2:[function(_dereq_,module,exports){ -"use strict"; -module.exports = function(Promise, INTERNAL, tryConvertToPromise, debug) { -var calledBind = false; -var rejectThis = function(_, e) { - this._reject(e); -}; - -var targetRejected = function(e, context) { - context.promiseRejectionQueued = true; - context.bindingPromise._then(rejectThis, rejectThis, null, this, e); -}; - -var bindingResolved = function(thisArg, context) { - if (((this._bitField & 50397184) === 0)) { - this._resolveCallback(context.target); - } -}; - -var bindingRejected = function(e, context) { - if (!context.promiseRejectionQueued) this._reject(e); -}; - -Promise.prototype.bind = function (thisArg) { - if (!calledBind) { - calledBind = true; - Promise.prototype._propagateFrom = debug.propagateFromFunction(); - Promise.prototype._boundValue = debug.boundValueFunction(); - } - var maybePromise = tryConvertToPromise(thisArg); - var ret = new Promise(INTERNAL); - ret._propagateFrom(this, 1); - var target = this._target(); - ret._setBoundTo(maybePromise); - if (maybePromise instanceof Promise) { - var context = { - promiseRejectionQueued: false, - promise: ret, - target: target, - bindingPromise: maybePromise - }; - target._then(INTERNAL, targetRejected, undefined, ret, context); - maybePromise._then( - bindingResolved, bindingRejected, undefined, ret, context); - ret._setOnCancel(maybePromise); - } else { - ret._resolveCallback(target); - } - return ret; -}; - -Promise.prototype._setBoundTo = function (obj) { - if (obj !== undefined) { - this._bitField = this._bitField | 2097152; - this._boundTo = obj; - } else { - this._bitField = this._bitField & (~2097152); - } -}; - -Promise.prototype._isBound = function () { - return (this._bitField & 2097152) === 2097152; -}; - -Promise.bind = function (thisArg, value) { - return Promise.resolve(value).bind(thisArg); -}; -}; - -},{}],3:[function(_dereq_,module,exports){ -"use strict"; -var old; -if (typeof Promise !== "undefined") old = Promise; -function noConflict() { - try { if (Promise === bluebird) Promise = old; } - catch (e) {} - return bluebird; -} -var bluebird = _dereq_("./promise")(); -bluebird.noConflict = noConflict; -module.exports = bluebird; - -},{"./promise":15}],4:[function(_dereq_,module,exports){ -"use strict"; -module.exports = function(Promise, PromiseArray, apiRejection, debug) { -var util = _dereq_("./util"); -var tryCatch = util.tryCatch; -var errorObj = util.errorObj; -var async = Promise._async; - -Promise.prototype["break"] = Promise.prototype.cancel = function() { - if (!debug.cancellation()) return this._warn("cancellation is disabled"); - - var promise = this; - var child = promise; - while (promise._isCancellable()) { - if (!promise._cancelBy(child)) { - if (child._isFollowing()) { - child._followee().cancel(); - } else { - child._cancelBranched(); - } - break; - } - - var parent = promise._cancellationParent; - if (parent == null || !parent._isCancellable()) { - if (promise._isFollowing()) { - promise._followee().cancel(); - } else { - promise._cancelBranched(); - } - break; - } else { - if (promise._isFollowing()) promise._followee().cancel(); - promise._setWillBeCancelled(); - child = promise; - promise = parent; - } - } -}; - -Promise.prototype._branchHasCancelled = function() { - this._branchesRemainingToCancel--; -}; - -Promise.prototype._enoughBranchesHaveCancelled = function() { - return this._branchesRemainingToCancel === undefined || - this._branchesRemainingToCancel <= 0; -}; - -Promise.prototype._cancelBy = function(canceller) { - if (canceller === this) { - this._branchesRemainingToCancel = 0; - this._invokeOnCancel(); - return true; - } else { - this._branchHasCancelled(); - if (this._enoughBranchesHaveCancelled()) { - this._invokeOnCancel(); - return true; - } - } - return false; -}; - -Promise.prototype._cancelBranched = function() { - if (this._enoughBranchesHaveCancelled()) { - this._cancel(); - } -}; - -Promise.prototype._cancel = function() { - if (!this._isCancellable()) return; - this._setCancelled(); - async.invoke(this._cancelPromises, this, undefined); -}; - -Promise.prototype._cancelPromises = function() { - if (this._length() > 0) this._settlePromises(); -}; - -Promise.prototype._unsetOnCancel = function() { - this._onCancelField = undefined; -}; - -Promise.prototype._isCancellable = function() { - return this.isPending() && !this._isCancelled(); -}; - -Promise.prototype.isCancellable = function() { - return this.isPending() && !this.isCancelled(); -}; - -Promise.prototype._doInvokeOnCancel = function(onCancelCallback, internalOnly) { - if (util.isArray(onCancelCallback)) { - for (var i = 0; i < onCancelCallback.length; ++i) { - this._doInvokeOnCancel(onCancelCallback[i], internalOnly); - } - } else if (onCancelCallback !== undefined) { - if (typeof onCancelCallback === "function") { - if (!internalOnly) { - var e = tryCatch(onCancelCallback).call(this._boundValue()); - if (e === errorObj) { - this._attachExtraTrace(e.e); - async.throwLater(e.e); - } - } - } else { - onCancelCallback._resultCancelled(this); - } - } -}; - -Promise.prototype._invokeOnCancel = function() { - var onCancelCallback = this._onCancel(); - this._unsetOnCancel(); - async.invoke(this._doInvokeOnCancel, this, onCancelCallback); -}; - -Promise.prototype._invokeInternalOnCancel = function() { - if (this._isCancellable()) { - this._doInvokeOnCancel(this._onCancel(), true); - this._unsetOnCancel(); - } -}; - -Promise.prototype._resultCancelled = function() { - this.cancel(); -}; - -}; - -},{"./util":21}],5:[function(_dereq_,module,exports){ -"use strict"; -module.exports = function(NEXT_FILTER) { -var util = _dereq_("./util"); -var getKeys = _dereq_("./es5").keys; -var tryCatch = util.tryCatch; -var errorObj = util.errorObj; - -function catchFilter(instances, cb, promise) { - return function(e) { - var boundTo = promise._boundValue(); - predicateLoop: for (var i = 0; i < instances.length; ++i) { - var item = instances[i]; - - if (item === Error || - (item != null && item.prototype instanceof Error)) { - if (e instanceof item) { - return tryCatch(cb).call(boundTo, e); - } - } else if (typeof item === "function") { - var matchesPredicate = tryCatch(item).call(boundTo, e); - if (matchesPredicate === errorObj) { - return matchesPredicate; - } else if (matchesPredicate) { - return tryCatch(cb).call(boundTo, e); - } - } else if (util.isObject(e)) { - var keys = getKeys(item); - for (var j = 0; j < keys.length; ++j) { - var key = keys[j]; - if (item[key] != e[key]) { - continue predicateLoop; - } - } - return tryCatch(cb).call(boundTo, e); - } - } - return NEXT_FILTER; - }; -} - -return catchFilter; -}; - -},{"./es5":10,"./util":21}],6:[function(_dereq_,module,exports){ -"use strict"; -module.exports = function(Promise) { -var longStackTraces = false; -var contextStack = []; - -Promise.prototype._promiseCreated = function() {}; -Promise.prototype._pushContext = function() {}; -Promise.prototype._popContext = function() {return null;}; -Promise._peekContext = Promise.prototype._peekContext = function() {}; - -function Context() { - this._trace = new Context.CapturedTrace(peekContext()); -} -Context.prototype._pushContext = function () { - if (this._trace !== undefined) { - this._trace._promiseCreated = null; - contextStack.push(this._trace); - } -}; - -Context.prototype._popContext = function () { - if (this._trace !== undefined) { - var trace = contextStack.pop(); - var ret = trace._promiseCreated; - trace._promiseCreated = null; - return ret; - } - return null; -}; - -function createContext() { - if (longStackTraces) return new Context(); -} - -function peekContext() { - var lastIndex = contextStack.length - 1; - if (lastIndex >= 0) { - return contextStack[lastIndex]; - } - return undefined; -} -Context.CapturedTrace = null; -Context.create = createContext; -Context.deactivateLongStackTraces = function() {}; -Context.activateLongStackTraces = function() { - var Promise_pushContext = Promise.prototype._pushContext; - var Promise_popContext = Promise.prototype._popContext; - var Promise_PeekContext = Promise._peekContext; - var Promise_peekContext = Promise.prototype._peekContext; - var Promise_promiseCreated = Promise.prototype._promiseCreated; - Context.deactivateLongStackTraces = function() { - Promise.prototype._pushContext = Promise_pushContext; - Promise.prototype._popContext = Promise_popContext; - Promise._peekContext = Promise_PeekContext; - Promise.prototype._peekContext = Promise_peekContext; - Promise.prototype._promiseCreated = Promise_promiseCreated; - longStackTraces = false; - }; - longStackTraces = true; - Promise.prototype._pushContext = Context.prototype._pushContext; - Promise.prototype._popContext = Context.prototype._popContext; - Promise._peekContext = Promise.prototype._peekContext = peekContext; - Promise.prototype._promiseCreated = function() { - var ctx = this._peekContext(); - if (ctx && ctx._promiseCreated == null) ctx._promiseCreated = this; - }; -}; -return Context; -}; - -},{}],7:[function(_dereq_,module,exports){ -"use strict"; -module.exports = function(Promise, Context) { -var getDomain = Promise._getDomain; -var async = Promise._async; -var Warning = _dereq_("./errors").Warning; -var util = _dereq_("./util"); -var canAttachTrace = util.canAttachTrace; -var unhandledRejectionHandled; -var possiblyUnhandledRejection; -var bluebirdFramePattern = - /[\\\/]bluebird[\\\/]js[\\\/](release|debug|instrumented)/; -var nodeFramePattern = /\((?:timers\.js):\d+:\d+\)/; -var parseLinePattern = /[\/<\(](.+?):(\d+):(\d+)\)?\s*$/; -var stackFramePattern = null; -var formatStack = null; -var indentStackFrames = false; -var printWarning; -var debugging = !!(util.env("BLUEBIRD_DEBUG") != 0 && - (true || - util.env("BLUEBIRD_DEBUG") || - util.env("NODE_ENV") === "development")); - -var warnings = !!(util.env("BLUEBIRD_WARNINGS") != 0 && - (debugging || util.env("BLUEBIRD_WARNINGS"))); - -var longStackTraces = !!(util.env("BLUEBIRD_LONG_STACK_TRACES") != 0 && - (debugging || util.env("BLUEBIRD_LONG_STACK_TRACES"))); - -var wForgottenReturn = util.env("BLUEBIRD_W_FORGOTTEN_RETURN") != 0 && - (warnings || !!util.env("BLUEBIRD_W_FORGOTTEN_RETURN")); - -Promise.prototype.suppressUnhandledRejections = function() { - var target = this._target(); - target._bitField = ((target._bitField & (~1048576)) | - 524288); -}; - -Promise.prototype._ensurePossibleRejectionHandled = function () { - if ((this._bitField & 524288) !== 0) return; - this._setRejectionIsUnhandled(); - async.invokeLater(this._notifyUnhandledRejection, this, undefined); -}; - -Promise.prototype._notifyUnhandledRejectionIsHandled = function () { - fireRejectionEvent("rejectionHandled", - unhandledRejectionHandled, undefined, this); -}; - -Promise.prototype._setReturnedNonUndefined = function() { - this._bitField = this._bitField | 268435456; -}; - -Promise.prototype._returnedNonUndefined = function() { - return (this._bitField & 268435456) !== 0; -}; - -Promise.prototype._notifyUnhandledRejection = function () { - if (this._isRejectionUnhandled()) { - var reason = this._settledValue(); - this._setUnhandledRejectionIsNotified(); - fireRejectionEvent("unhandledRejection", - possiblyUnhandledRejection, reason, this); - } -}; - -Promise.prototype._setUnhandledRejectionIsNotified = function () { - this._bitField = this._bitField | 262144; -}; - -Promise.prototype._unsetUnhandledRejectionIsNotified = function () { - this._bitField = this._bitField & (~262144); -}; - -Promise.prototype._isUnhandledRejectionNotified = function () { - return (this._bitField & 262144) > 0; -}; - -Promise.prototype._setRejectionIsUnhandled = function () { - this._bitField = this._bitField | 1048576; -}; - -Promise.prototype._unsetRejectionIsUnhandled = function () { - this._bitField = this._bitField & (~1048576); - if (this._isUnhandledRejectionNotified()) { - this._unsetUnhandledRejectionIsNotified(); - this._notifyUnhandledRejectionIsHandled(); - } -}; - -Promise.prototype._isRejectionUnhandled = function () { - return (this._bitField & 1048576) > 0; -}; - -Promise.prototype._warn = function(message, shouldUseOwnTrace, promise) { - return warn(message, shouldUseOwnTrace, promise || this); -}; - -Promise.onPossiblyUnhandledRejection = function (fn) { - var domain = getDomain(); - possiblyUnhandledRejection = - typeof fn === "function" ? (domain === null ? - fn : util.domainBind(domain, fn)) - : undefined; -}; - -Promise.onUnhandledRejectionHandled = function (fn) { - var domain = getDomain(); - unhandledRejectionHandled = - typeof fn === "function" ? (domain === null ? - fn : util.domainBind(domain, fn)) - : undefined; -}; - -var disableLongStackTraces = function() {}; -Promise.longStackTraces = function () { - if (async.haveItemsQueued() && !config.longStackTraces) { - throw new Error("cannot enable long stack traces after promises have been created\u000a\u000a See http://goo.gl/MqrFmX\u000a"); - } - if (!config.longStackTraces && longStackTracesIsSupported()) { - var Promise_captureStackTrace = Promise.prototype._captureStackTrace; - var Promise_attachExtraTrace = Promise.prototype._attachExtraTrace; - config.longStackTraces = true; - disableLongStackTraces = function() { - if (async.haveItemsQueued() && !config.longStackTraces) { - throw new Error("cannot enable long stack traces after promises have been created\u000a\u000a See http://goo.gl/MqrFmX\u000a"); - } - Promise.prototype._captureStackTrace = Promise_captureStackTrace; - Promise.prototype._attachExtraTrace = Promise_attachExtraTrace; - Context.deactivateLongStackTraces(); - async.enableTrampoline(); - config.longStackTraces = false; - }; - Promise.prototype._captureStackTrace = longStackTracesCaptureStackTrace; - Promise.prototype._attachExtraTrace = longStackTracesAttachExtraTrace; - Context.activateLongStackTraces(); - async.disableTrampolineIfNecessary(); - } -}; - -Promise.hasLongStackTraces = function () { - return config.longStackTraces && longStackTracesIsSupported(); -}; - -var fireDomEvent = (function() { - try { - if (typeof CustomEvent === "function") { - var event = new CustomEvent("CustomEvent"); - util.global.dispatchEvent(event); - return function(name, event) { - var domEvent = new CustomEvent(name.toLowerCase(), { - detail: event, - cancelable: true - }); - return !util.global.dispatchEvent(domEvent); - }; - } else if (typeof Event === "function") { - var event = new Event("CustomEvent"); - util.global.dispatchEvent(event); - return function(name, event) { - var domEvent = new Event(name.toLowerCase(), { - cancelable: true - }); - domEvent.detail = event; - return !util.global.dispatchEvent(domEvent); - }; - } else { - var event = document.createEvent("CustomEvent"); - event.initCustomEvent("testingtheevent", false, true, {}); - util.global.dispatchEvent(event); - return function(name, event) { - var domEvent = document.createEvent("CustomEvent"); - domEvent.initCustomEvent(name.toLowerCase(), false, true, - event); - return !util.global.dispatchEvent(domEvent); - }; - } - } catch (e) {} - return function() { - return false; - }; -})(); - -var fireGlobalEvent = (function() { - if (util.isNode) { - return function() { - return process.emit.apply(process, arguments); - }; - } else { - if (!util.global) { - return function() { - return false; - }; - } - return function(name) { - var methodName = "on" + name.toLowerCase(); - var method = util.global[methodName]; - if (!method) return false; - method.apply(util.global, [].slice.call(arguments, 1)); - return true; - }; - } -})(); - -function generatePromiseLifecycleEventObject(name, promise) { - return {promise: promise}; -} - -var eventToObjectGenerator = { - promiseCreated: generatePromiseLifecycleEventObject, - promiseFulfilled: generatePromiseLifecycleEventObject, - promiseRejected: generatePromiseLifecycleEventObject, - promiseResolved: generatePromiseLifecycleEventObject, - promiseCancelled: generatePromiseLifecycleEventObject, - promiseChained: function(name, promise, child) { - return {promise: promise, child: child}; - }, - warning: function(name, warning) { - return {warning: warning}; - }, - unhandledRejection: function (name, reason, promise) { - return {reason: reason, promise: promise}; - }, - rejectionHandled: generatePromiseLifecycleEventObject -}; - -var activeFireEvent = function (name) { - var globalEventFired = false; - try { - globalEventFired = fireGlobalEvent.apply(null, arguments); - } catch (e) { - async.throwLater(e); - globalEventFired = true; - } - - var domEventFired = false; - try { - domEventFired = fireDomEvent(name, - eventToObjectGenerator[name].apply(null, arguments)); - } catch (e) { - async.throwLater(e); - domEventFired = true; - } - - return domEventFired || globalEventFired; -}; - -Promise.config = function(opts) { - opts = Object(opts); - if ("longStackTraces" in opts) { - if (opts.longStackTraces) { - Promise.longStackTraces(); - } else if (!opts.longStackTraces && Promise.hasLongStackTraces()) { - disableLongStackTraces(); - } - } - if ("warnings" in opts) { - var warningsOption = opts.warnings; - config.warnings = !!warningsOption; - wForgottenReturn = config.warnings; - - if (util.isObject(warningsOption)) { - if ("wForgottenReturn" in warningsOption) { - wForgottenReturn = !!warningsOption.wForgottenReturn; - } - } - } - if ("cancellation" in opts && opts.cancellation && !config.cancellation) { - if (async.haveItemsQueued()) { - throw new Error( - "cannot enable cancellation after promises are in use"); - } - Promise.prototype._clearCancellationData = - cancellationClearCancellationData; - Promise.prototype._propagateFrom = cancellationPropagateFrom; - Promise.prototype._onCancel = cancellationOnCancel; - Promise.prototype._setOnCancel = cancellationSetOnCancel; - Promise.prototype._attachCancellationCallback = - cancellationAttachCancellationCallback; - Promise.prototype._execute = cancellationExecute; - propagateFromFunction = cancellationPropagateFrom; - config.cancellation = true; - } - if ("monitoring" in opts) { - if (opts.monitoring && !config.monitoring) { - config.monitoring = true; - Promise.prototype._fireEvent = activeFireEvent; - } else if (!opts.monitoring && config.monitoring) { - config.monitoring = false; - Promise.prototype._fireEvent = defaultFireEvent; - } - } - return Promise; -}; - -function defaultFireEvent() { return false; } - -Promise.prototype._fireEvent = defaultFireEvent; -Promise.prototype._execute = function(executor, resolve, reject) { - try { - executor(resolve, reject); - } catch (e) { - return e; - } -}; -Promise.prototype._onCancel = function () {}; -Promise.prototype._setOnCancel = function (handler) { ; }; -Promise.prototype._attachCancellationCallback = function(onCancel) { - ; -}; -Promise.prototype._captureStackTrace = function () {}; -Promise.prototype._attachExtraTrace = function () {}; -Promise.prototype._clearCancellationData = function() {}; -Promise.prototype._propagateFrom = function (parent, flags) { - ; - ; -}; - -function cancellationExecute(executor, resolve, reject) { - var promise = this; - try { - executor(resolve, reject, function(onCancel) { - if (typeof onCancel !== "function") { - throw new TypeError("onCancel must be a function, got: " + - util.toString(onCancel)); - } - promise._attachCancellationCallback(onCancel); - }); - } catch (e) { - return e; - } -} - -function cancellationAttachCancellationCallback(onCancel) { - if (!this._isCancellable()) return this; - - var previousOnCancel = this._onCancel(); - if (previousOnCancel !== undefined) { - if (util.isArray(previousOnCancel)) { - previousOnCancel.push(onCancel); - } else { - this._setOnCancel([previousOnCancel, onCancel]); - } - } else { - this._setOnCancel(onCancel); - } -} - -function cancellationOnCancel() { - return this._onCancelField; -} - -function cancellationSetOnCancel(onCancel) { - this._onCancelField = onCancel; -} - -function cancellationClearCancellationData() { - this._cancellationParent = undefined; - this._onCancelField = undefined; -} - -function cancellationPropagateFrom(parent, flags) { - if ((flags & 1) !== 0) { - this._cancellationParent = parent; - var branchesRemainingToCancel = parent._branchesRemainingToCancel; - if (branchesRemainingToCancel === undefined) { - branchesRemainingToCancel = 0; - } - parent._branchesRemainingToCancel = branchesRemainingToCancel + 1; - } - if ((flags & 2) !== 0 && parent._isBound()) { - this._setBoundTo(parent._boundTo); - } -} - -function bindingPropagateFrom(parent, flags) { - if ((flags & 2) !== 0 && parent._isBound()) { - this._setBoundTo(parent._boundTo); - } -} -var propagateFromFunction = bindingPropagateFrom; - -function boundValueFunction() { - var ret = this._boundTo; - if (ret !== undefined) { - if (ret instanceof Promise) { - if (ret.isFulfilled()) { - return ret.value(); - } else { - return undefined; - } - } - } - return ret; -} - -function longStackTracesCaptureStackTrace() { - this._trace = new CapturedTrace(this._peekContext()); -} - -function longStackTracesAttachExtraTrace(error, ignoreSelf) { - if (canAttachTrace(error)) { - var trace = this._trace; - if (trace !== undefined) { - if (ignoreSelf) trace = trace._parent; - } - if (trace !== undefined) { - trace.attachExtraTrace(error); - } else if (!error.__stackCleaned__) { - var parsed = parseStackAndMessage(error); - util.notEnumerableProp(error, "stack", - parsed.message + "\n" + parsed.stack.join("\n")); - util.notEnumerableProp(error, "__stackCleaned__", true); - } - } -} - -function checkForgottenReturns(returnValue, promiseCreated, name, promise, - parent) { - if (returnValue === undefined && promiseCreated !== null && - wForgottenReturn) { - if (parent !== undefined && parent._returnedNonUndefined()) return; - if ((promise._bitField & 65535) === 0) return; - - if (name) name = name + " "; - var handlerLine = ""; - var creatorLine = ""; - if (promiseCreated._trace) { - var traceLines = promiseCreated._trace.stack.split("\n"); - var stack = cleanStack(traceLines); - for (var i = stack.length - 1; i >= 0; --i) { - var line = stack[i]; - if (!nodeFramePattern.test(line)) { - var lineMatches = line.match(parseLinePattern); - if (lineMatches) { - handlerLine = "at " + lineMatches[1] + - ":" + lineMatches[2] + ":" + lineMatches[3] + " "; - } - break; - } - } - - if (stack.length > 0) { - var firstUserLine = stack[0]; - for (var i = 0; i < traceLines.length; ++i) { - - if (traceLines[i] === firstUserLine) { - if (i > 0) { - creatorLine = "\n" + traceLines[i - 1]; - } - break; - } - } - - } - } - var msg = "a promise was created in a " + name + - "handler " + handlerLine + "but was not returned from it, " + - "see http://goo.gl/rRqMUw" + - creatorLine; - promise._warn(msg, true, promiseCreated); - } -} - -function deprecated(name, replacement) { - var message = name + - " is deprecated and will be removed in a future version."; - if (replacement) message += " Use " + replacement + " instead."; - return warn(message); -} - -function warn(message, shouldUseOwnTrace, promise) { - if (!config.warnings) return; - var warning = new Warning(message); - var ctx; - if (shouldUseOwnTrace) { - promise._attachExtraTrace(warning); - } else if (config.longStackTraces && (ctx = Promise._peekContext())) { - ctx.attachExtraTrace(warning); - } else { - var parsed = parseStackAndMessage(warning); - warning.stack = parsed.message + "\n" + parsed.stack.join("\n"); - } - - if (!activeFireEvent("warning", warning)) { - formatAndLogError(warning, "", true); - } -} - -function reconstructStack(message, stacks) { - for (var i = 0; i < stacks.length - 1; ++i) { - stacks[i].push("From previous event:"); - stacks[i] = stacks[i].join("\n"); - } - if (i < stacks.length) { - stacks[i] = stacks[i].join("\n"); - } - return message + "\n" + stacks.join("\n"); -} - -function removeDuplicateOrEmptyJumps(stacks) { - for (var i = 0; i < stacks.length; ++i) { - if (stacks[i].length === 0 || - ((i + 1 < stacks.length) && stacks[i][0] === stacks[i+1][0])) { - stacks.splice(i, 1); - i--; - } - } -} - -function removeCommonRoots(stacks) { - var current = stacks[0]; - for (var i = 1; i < stacks.length; ++i) { - var prev = stacks[i]; - var currentLastIndex = current.length - 1; - var currentLastLine = current[currentLastIndex]; - var commonRootMeetPoint = -1; - - for (var j = prev.length - 1; j >= 0; --j) { - if (prev[j] === currentLastLine) { - commonRootMeetPoint = j; - break; - } - } - - for (var j = commonRootMeetPoint; j >= 0; --j) { - var line = prev[j]; - if (current[currentLastIndex] === line) { - current.pop(); - currentLastIndex--; - } else { - break; - } - } - current = prev; - } -} - -function cleanStack(stack) { - var ret = []; - for (var i = 0; i < stack.length; ++i) { - var line = stack[i]; - var isTraceLine = " (No stack trace)" === line || - stackFramePattern.test(line); - var isInternalFrame = isTraceLine && shouldIgnore(line); - if (isTraceLine && !isInternalFrame) { - if (indentStackFrames && line.charAt(0) !== " ") { - line = " " + line; - } - ret.push(line); - } - } - return ret; -} - -function stackFramesAsArray(error) { - var stack = error.stack.replace(/\s+$/g, "").split("\n"); - for (var i = 0; i < stack.length; ++i) { - var line = stack[i]; - if (" (No stack trace)" === line || stackFramePattern.test(line)) { - break; - } - } - if (i > 0 && error.name != "SyntaxError") { - stack = stack.slice(i); - } - return stack; -} - -function parseStackAndMessage(error) { - var stack = error.stack; - var message = error.toString(); - stack = typeof stack === "string" && stack.length > 0 - ? stackFramesAsArray(error) : [" (No stack trace)"]; - return { - message: message, - stack: error.name == "SyntaxError" ? stack : cleanStack(stack) - }; -} - -function formatAndLogError(error, title, isSoft) { - if (typeof console !== "undefined") { - var message; - if (util.isObject(error)) { - var stack = error.stack; - message = title + formatStack(stack, error); - } else { - message = title + String(error); - } - if (typeof printWarning === "function") { - printWarning(message, isSoft); - } else if (typeof console.log === "function" || - typeof console.log === "object") { - console.log(message); - } - } -} - -function fireRejectionEvent(name, localHandler, reason, promise) { - var localEventFired = false; - try { - if (typeof localHandler === "function") { - localEventFired = true; - if (name === "rejectionHandled") { - localHandler(promise); - } else { - localHandler(reason, promise); - } - } - } catch (e) { - async.throwLater(e); - } - - if (name === "unhandledRejection") { - if (!activeFireEvent(name, reason, promise) && !localEventFired) { - formatAndLogError(reason, "Unhandled rejection "); - } - } else { - activeFireEvent(name, promise); - } -} - -function formatNonError(obj) { - var str; - if (typeof obj === "function") { - str = "[function " + - (obj.name || "anonymous") + - "]"; - } else { - str = obj && typeof obj.toString === "function" - ? obj.toString() : util.toString(obj); - var ruselessToString = /\[object [a-zA-Z0-9$_]+\]/; - if (ruselessToString.test(str)) { - try { - var newStr = JSON.stringify(obj); - str = newStr; - } - catch(e) { - - } - } - if (str.length === 0) { - str = "(empty array)"; - } - } - return ("(<" + snip(str) + ">, no stack trace)"); -} - -function snip(str) { - var maxChars = 41; - if (str.length < maxChars) { - return str; - } - return str.substr(0, maxChars - 3) + "..."; -} - -function longStackTracesIsSupported() { - return typeof captureStackTrace === "function"; -} - -var shouldIgnore = function() { return false; }; -var parseLineInfoRegex = /[\/<\(]([^:\/]+):(\d+):(?:\d+)\)?\s*$/; -function parseLineInfo(line) { - var matches = line.match(parseLineInfoRegex); - if (matches) { - return { - fileName: matches[1], - line: parseInt(matches[2], 10) - }; - } -} - -function setBounds(firstLineError, lastLineError) { - if (!longStackTracesIsSupported()) return; - var firstStackLines = firstLineError.stack.split("\n"); - var lastStackLines = lastLineError.stack.split("\n"); - var firstIndex = -1; - var lastIndex = -1; - var firstFileName; - var lastFileName; - for (var i = 0; i < firstStackLines.length; ++i) { - var result = parseLineInfo(firstStackLines[i]); - if (result) { - firstFileName = result.fileName; - firstIndex = result.line; - break; - } - } - for (var i = 0; i < lastStackLines.length; ++i) { - var result = parseLineInfo(lastStackLines[i]); - if (result) { - lastFileName = result.fileName; - lastIndex = result.line; - break; - } - } - if (firstIndex < 0 || lastIndex < 0 || !firstFileName || !lastFileName || - firstFileName !== lastFileName || firstIndex >= lastIndex) { - return; - } - - shouldIgnore = function(line) { - if (bluebirdFramePattern.test(line)) return true; - var info = parseLineInfo(line); - if (info) { - if (info.fileName === firstFileName && - (firstIndex <= info.line && info.line <= lastIndex)) { - return true; - } - } - return false; - }; -} - -function CapturedTrace(parent) { - this._parent = parent; - this._promisesCreated = 0; - var length = this._length = 1 + (parent === undefined ? 0 : parent._length); - captureStackTrace(this, CapturedTrace); - if (length > 32) this.uncycle(); -} -util.inherits(CapturedTrace, Error); -Context.CapturedTrace = CapturedTrace; - -CapturedTrace.prototype.uncycle = function() { - var length = this._length; - if (length < 2) return; - var nodes = []; - var stackToIndex = {}; - - for (var i = 0, node = this; node !== undefined; ++i) { - nodes.push(node); - node = node._parent; - } - length = this._length = i; - for (var i = length - 1; i >= 0; --i) { - var stack = nodes[i].stack; - if (stackToIndex[stack] === undefined) { - stackToIndex[stack] = i; - } - } - for (var i = 0; i < length; ++i) { - var currentStack = nodes[i].stack; - var index = stackToIndex[currentStack]; - if (index !== undefined && index !== i) { - if (index > 0) { - nodes[index - 1]._parent = undefined; - nodes[index - 1]._length = 1; - } - nodes[i]._parent = undefined; - nodes[i]._length = 1; - var cycleEdgeNode = i > 0 ? nodes[i - 1] : this; - - if (index < length - 1) { - cycleEdgeNode._parent = nodes[index + 1]; - cycleEdgeNode._parent.uncycle(); - cycleEdgeNode._length = - cycleEdgeNode._parent._length + 1; - } else { - cycleEdgeNode._parent = undefined; - cycleEdgeNode._length = 1; - } - var currentChildLength = cycleEdgeNode._length + 1; - for (var j = i - 2; j >= 0; --j) { - nodes[j]._length = currentChildLength; - currentChildLength++; - } - return; - } - } -}; - -CapturedTrace.prototype.attachExtraTrace = function(error) { - if (error.__stackCleaned__) return; - this.uncycle(); - var parsed = parseStackAndMessage(error); - var message = parsed.message; - var stacks = [parsed.stack]; - - var trace = this; - while (trace !== undefined) { - stacks.push(cleanStack(trace.stack.split("\n"))); - trace = trace._parent; - } - removeCommonRoots(stacks); - removeDuplicateOrEmptyJumps(stacks); - util.notEnumerableProp(error, "stack", reconstructStack(message, stacks)); - util.notEnumerableProp(error, "__stackCleaned__", true); -}; - -var captureStackTrace = (function stackDetection() { - var v8stackFramePattern = /^\s*at\s*/; - var v8stackFormatter = function(stack, error) { - if (typeof stack === "string") return stack; - - if (error.name !== undefined && - error.message !== undefined) { - return error.toString(); - } - return formatNonError(error); - }; - - if (typeof Error.stackTraceLimit === "number" && - typeof Error.captureStackTrace === "function") { - Error.stackTraceLimit += 6; - stackFramePattern = v8stackFramePattern; - formatStack = v8stackFormatter; - var captureStackTrace = Error.captureStackTrace; - - shouldIgnore = function(line) { - return bluebirdFramePattern.test(line); - }; - return function(receiver, ignoreUntil) { - Error.stackTraceLimit += 6; - captureStackTrace(receiver, ignoreUntil); - Error.stackTraceLimit -= 6; - }; - } - var err = new Error(); - - if (typeof err.stack === "string" && - err.stack.split("\n")[0].indexOf("stackDetection@") >= 0) { - stackFramePattern = /@/; - formatStack = v8stackFormatter; - indentStackFrames = true; - return function captureStackTrace(o) { - o.stack = new Error().stack; - }; - } - - var hasStackAfterThrow; - try { throw new Error(); } - catch(e) { - hasStackAfterThrow = ("stack" in e); - } - if (!("stack" in err) && hasStackAfterThrow && - typeof Error.stackTraceLimit === "number") { - stackFramePattern = v8stackFramePattern; - formatStack = v8stackFormatter; - return function captureStackTrace(o) { - Error.stackTraceLimit += 6; - try { throw new Error(); } - catch(e) { o.stack = e.stack; } - Error.stackTraceLimit -= 6; - }; - } - - formatStack = function(stack, error) { - if (typeof stack === "string") return stack; - - if ((typeof error === "object" || - typeof error === "function") && - error.name !== undefined && - error.message !== undefined) { - return error.toString(); - } - return formatNonError(error); - }; - - return null; - -})([]); - -if (typeof console !== "undefined" && typeof console.warn !== "undefined") { - printWarning = function (message) { - console.warn(message); - }; - if (util.isNode && process.stderr.isTTY) { - printWarning = function(message, isSoft) { - var color = isSoft ? "\u001b[33m" : "\u001b[31m"; - console.warn(color + message + "\u001b[0m\n"); - }; - } else if (!util.isNode && typeof (new Error().stack) === "string") { - printWarning = function(message, isSoft) { - console.warn("%c" + message, - isSoft ? "color: darkorange" : "color: red"); - }; - } -} - -var config = { - warnings: warnings, - longStackTraces: false, - cancellation: false, - monitoring: false -}; - -if (longStackTraces) Promise.longStackTraces(); - -return { - longStackTraces: function() { - return config.longStackTraces; - }, - warnings: function() { - return config.warnings; - }, - cancellation: function() { - return config.cancellation; - }, - monitoring: function() { - return config.monitoring; - }, - propagateFromFunction: function() { - return propagateFromFunction; - }, - boundValueFunction: function() { - return boundValueFunction; - }, - checkForgottenReturns: checkForgottenReturns, - setBounds: setBounds, - warn: warn, - deprecated: deprecated, - CapturedTrace: CapturedTrace, - fireDomEvent: fireDomEvent, - fireGlobalEvent: fireGlobalEvent -}; -}; - -},{"./errors":9,"./util":21}],8:[function(_dereq_,module,exports){ -"use strict"; -module.exports = function(Promise) { -function returner() { - return this.value; -} -function thrower() { - throw this.reason; -} - -Promise.prototype["return"] = -Promise.prototype.thenReturn = function (value) { - if (value instanceof Promise) value.suppressUnhandledRejections(); - return this._then( - returner, undefined, undefined, {value: value}, undefined); -}; - -Promise.prototype["throw"] = -Promise.prototype.thenThrow = function (reason) { - return this._then( - thrower, undefined, undefined, {reason: reason}, undefined); -}; - -Promise.prototype.catchThrow = function (reason) { - if (arguments.length <= 1) { - return this._then( - undefined, thrower, undefined, {reason: reason}, undefined); - } else { - var _reason = arguments[1]; - var handler = function() {throw _reason;}; - return this.caught(reason, handler); - } -}; - -Promise.prototype.catchReturn = function (value) { - if (arguments.length <= 1) { - if (value instanceof Promise) value.suppressUnhandledRejections(); - return this._then( - undefined, returner, undefined, {value: value}, undefined); - } else { - var _value = arguments[1]; - if (_value instanceof Promise) _value.suppressUnhandledRejections(); - var handler = function() {return _value;}; - return this.caught(value, handler); - } -}; -}; - -},{}],9:[function(_dereq_,module,exports){ -"use strict"; -var es5 = _dereq_("./es5"); -var Objectfreeze = es5.freeze; -var util = _dereq_("./util"); -var inherits = util.inherits; -var notEnumerableProp = util.notEnumerableProp; - -function subError(nameProperty, defaultMessage) { - function SubError(message) { - if (!(this instanceof SubError)) return new SubError(message); - notEnumerableProp(this, "message", - typeof message === "string" ? message : defaultMessage); - notEnumerableProp(this, "name", nameProperty); - if (Error.captureStackTrace) { - Error.captureStackTrace(this, this.constructor); - } else { - Error.call(this); - } - } - inherits(SubError, Error); - return SubError; -} - -var _TypeError, _RangeError; -var Warning = subError("Warning", "warning"); -var CancellationError = subError("CancellationError", "cancellation error"); -var TimeoutError = subError("TimeoutError", "timeout error"); -var AggregateError = subError("AggregateError", "aggregate error"); -try { - _TypeError = TypeError; - _RangeError = RangeError; -} catch(e) { - _TypeError = subError("TypeError", "type error"); - _RangeError = subError("RangeError", "range error"); -} - -var methods = ("join pop push shift unshift slice filter forEach some " + - "every map indexOf lastIndexOf reduce reduceRight sort reverse").split(" "); - -for (var i = 0; i < methods.length; ++i) { - if (typeof Array.prototype[methods[i]] === "function") { - AggregateError.prototype[methods[i]] = Array.prototype[methods[i]]; - } -} - -es5.defineProperty(AggregateError.prototype, "length", { - value: 0, - configurable: false, - writable: true, - enumerable: true -}); -AggregateError.prototype["isOperational"] = true; -var level = 0; -AggregateError.prototype.toString = function() { - var indent = Array(level * 4 + 1).join(" "); - var ret = "\n" + indent + "AggregateError of:" + "\n"; - level++; - indent = Array(level * 4 + 1).join(" "); - for (var i = 0; i < this.length; ++i) { - var str = this[i] === this ? "[Circular AggregateError]" : this[i] + ""; - var lines = str.split("\n"); - for (var j = 0; j < lines.length; ++j) { - lines[j] = indent + lines[j]; - } - str = lines.join("\n"); - ret += str + "\n"; - } - level--; - return ret; -}; - -function OperationalError(message) { - if (!(this instanceof OperationalError)) - return new OperationalError(message); - notEnumerableProp(this, "name", "OperationalError"); - notEnumerableProp(this, "message", message); - this.cause = message; - this["isOperational"] = true; - - if (message instanceof Error) { - notEnumerableProp(this, "message", message.message); - notEnumerableProp(this, "stack", message.stack); - } else if (Error.captureStackTrace) { - Error.captureStackTrace(this, this.constructor); - } - -} -inherits(OperationalError, Error); - -var errorTypes = Error["__BluebirdErrorTypes__"]; -if (!errorTypes) { - errorTypes = Objectfreeze({ - CancellationError: CancellationError, - TimeoutError: TimeoutError, - OperationalError: OperationalError, - RejectionError: OperationalError, - AggregateError: AggregateError - }); - es5.defineProperty(Error, "__BluebirdErrorTypes__", { - value: errorTypes, - writable: false, - enumerable: false, - configurable: false - }); -} - -module.exports = { - Error: Error, - TypeError: _TypeError, - RangeError: _RangeError, - CancellationError: errorTypes.CancellationError, - OperationalError: errorTypes.OperationalError, - TimeoutError: errorTypes.TimeoutError, - AggregateError: errorTypes.AggregateError, - Warning: Warning -}; - -},{"./es5":10,"./util":21}],10:[function(_dereq_,module,exports){ -var isES5 = (function(){ - "use strict"; - return this === undefined; -})(); - -if (isES5) { - module.exports = { - freeze: Object.freeze, - defineProperty: Object.defineProperty, - getDescriptor: Object.getOwnPropertyDescriptor, - keys: Object.keys, - names: Object.getOwnPropertyNames, - getPrototypeOf: Object.getPrototypeOf, - isArray: Array.isArray, - isES5: isES5, - propertyIsWritable: function(obj, prop) { - var descriptor = Object.getOwnPropertyDescriptor(obj, prop); - return !!(!descriptor || descriptor.writable || descriptor.set); - } - }; -} else { - var has = {}.hasOwnProperty; - var str = {}.toString; - var proto = {}.constructor.prototype; - - var ObjectKeys = function (o) { - var ret = []; - for (var key in o) { - if (has.call(o, key)) { - ret.push(key); - } - } - return ret; - }; - - var ObjectGetDescriptor = function(o, key) { - return {value: o[key]}; - }; - - var ObjectDefineProperty = function (o, key, desc) { - o[key] = desc.value; - return o; - }; - - var ObjectFreeze = function (obj) { - return obj; - }; - - var ObjectGetPrototypeOf = function (obj) { - try { - return Object(obj).constructor.prototype; - } - catch (e) { - return proto; - } - }; - - var ArrayIsArray = function (obj) { - try { - return str.call(obj) === "[object Array]"; - } - catch(e) { - return false; - } - }; - - module.exports = { - isArray: ArrayIsArray, - keys: ObjectKeys, - names: ObjectKeys, - defineProperty: ObjectDefineProperty, - getDescriptor: ObjectGetDescriptor, - freeze: ObjectFreeze, - getPrototypeOf: ObjectGetPrototypeOf, - isES5: isES5, - propertyIsWritable: function() { - return true; - } - }; -} - -},{}],11:[function(_dereq_,module,exports){ -"use strict"; -module.exports = function(Promise, tryConvertToPromise) { -var util = _dereq_("./util"); -var CancellationError = Promise.CancellationError; -var errorObj = util.errorObj; - -function PassThroughHandlerContext(promise, type, handler) { - this.promise = promise; - this.type = type; - this.handler = handler; - this.called = false; - this.cancelPromise = null; -} - -PassThroughHandlerContext.prototype.isFinallyHandler = function() { - return this.type === 0; -}; - -function FinallyHandlerCancelReaction(finallyHandler) { - this.finallyHandler = finallyHandler; -} - -FinallyHandlerCancelReaction.prototype._resultCancelled = function() { - checkCancel(this.finallyHandler); -}; - -function checkCancel(ctx, reason) { - if (ctx.cancelPromise != null) { - if (arguments.length > 1) { - ctx.cancelPromise._reject(reason); - } else { - ctx.cancelPromise._cancel(); - } - ctx.cancelPromise = null; - return true; - } - return false; -} - -function succeed() { - return finallyHandler.call(this, this.promise._target()._settledValue()); -} -function fail(reason) { - if (checkCancel(this, reason)) return; - errorObj.e = reason; - return errorObj; -} -function finallyHandler(reasonOrValue) { - var promise = this.promise; - var handler = this.handler; - - if (!this.called) { - this.called = true; - var ret = this.isFinallyHandler() - ? handler.call(promise._boundValue()) - : handler.call(promise._boundValue(), reasonOrValue); - if (ret !== undefined) { - promise._setReturnedNonUndefined(); - var maybePromise = tryConvertToPromise(ret, promise); - if (maybePromise instanceof Promise) { - if (this.cancelPromise != null) { - if (maybePromise._isCancelled()) { - var reason = - new CancellationError("late cancellation observer"); - promise._attachExtraTrace(reason); - errorObj.e = reason; - return errorObj; - } else if (maybePromise.isPending()) { - maybePromise._attachCancellationCallback( - new FinallyHandlerCancelReaction(this)); - } - } - return maybePromise._then( - succeed, fail, undefined, this, undefined); - } - } - } - - if (promise.isRejected()) { - checkCancel(this); - errorObj.e = reasonOrValue; - return errorObj; - } else { - checkCancel(this); - return reasonOrValue; - } -} - -Promise.prototype._passThrough = function(handler, type, success, fail) { - if (typeof handler !== "function") return this.then(); - return this._then(success, - fail, - undefined, - new PassThroughHandlerContext(this, type, handler), - undefined); -}; - -Promise.prototype.lastly = -Promise.prototype["finally"] = function (handler) { - return this._passThrough(handler, - 0, - finallyHandler, - finallyHandler); -}; - -Promise.prototype.tap = function (handler) { - return this._passThrough(handler, 1, finallyHandler); -}; - -return PassThroughHandlerContext; -}; - -},{"./util":21}],12:[function(_dereq_,module,exports){ -"use strict"; -module.exports = -function(Promise, PromiseArray, tryConvertToPromise, INTERNAL, async, - getDomain) { -var util = _dereq_("./util"); -var canEvaluate = util.canEvaluate; -var tryCatch = util.tryCatch; -var errorObj = util.errorObj; -var reject; - -if (!true) { -if (canEvaluate) { - var thenCallback = function(i) { - return new Function("value", "holder", " \n\ - 'use strict'; \n\ - holder.pIndex = value; \n\ - holder.checkFulfillment(this); \n\ - ".replace(/Index/g, i)); - }; - - var promiseSetter = function(i) { - return new Function("promise", "holder", " \n\ - 'use strict'; \n\ - holder.pIndex = promise; \n\ - ".replace(/Index/g, i)); - }; - - var generateHolderClass = function(total) { - var props = new Array(total); - for (var i = 0; i < props.length; ++i) { - props[i] = "this.p" + (i+1); - } - var assignment = props.join(" = ") + " = null;"; - var cancellationCode= "var promise;\n" + props.map(function(prop) { - return " \n\ - promise = " + prop + "; \n\ - if (promise instanceof Promise) { \n\ - promise.cancel(); \n\ - } \n\ - "; - }).join("\n"); - var passedArguments = props.join(", "); - var name = "Holder$" + total; - - - var code = "return function(tryCatch, errorObj, Promise, async) { \n\ - 'use strict'; \n\ - function [TheName](fn) { \n\ - [TheProperties] \n\ - this.fn = fn; \n\ - this.asyncNeeded = true; \n\ - this.now = 0; \n\ - } \n\ - \n\ - [TheName].prototype._callFunction = function(promise) { \n\ - promise._pushContext(); \n\ - var ret = tryCatch(this.fn)([ThePassedArguments]); \n\ - promise._popContext(); \n\ - if (ret === errorObj) { \n\ - promise._rejectCallback(ret.e, false); \n\ - } else { \n\ - promise._resolveCallback(ret); \n\ - } \n\ - }; \n\ - \n\ - [TheName].prototype.checkFulfillment = function(promise) { \n\ - var now = ++this.now; \n\ - if (now === [TheTotal]) { \n\ - if (this.asyncNeeded) { \n\ - async.invoke(this._callFunction, this, promise); \n\ - } else { \n\ - this._callFunction(promise); \n\ - } \n\ - \n\ - } \n\ - }; \n\ - \n\ - [TheName].prototype._resultCancelled = function() { \n\ - [CancellationCode] \n\ - }; \n\ - \n\ - return [TheName]; \n\ - }(tryCatch, errorObj, Promise, async); \n\ - "; - - code = code.replace(/\[TheName\]/g, name) - .replace(/\[TheTotal\]/g, total) - .replace(/\[ThePassedArguments\]/g, passedArguments) - .replace(/\[TheProperties\]/g, assignment) - .replace(/\[CancellationCode\]/g, cancellationCode); - - return new Function("tryCatch", "errorObj", "Promise", "async", code) - (tryCatch, errorObj, Promise, async); - }; - - var holderClasses = []; - var thenCallbacks = []; - var promiseSetters = []; - - for (var i = 0; i < 8; ++i) { - holderClasses.push(generateHolderClass(i + 1)); - thenCallbacks.push(thenCallback(i + 1)); - promiseSetters.push(promiseSetter(i + 1)); - } - - reject = function (reason) { - this._reject(reason); - }; -}} - -Promise.join = function () { - var last = arguments.length - 1; - var fn; - if (last > 0 && typeof arguments[last] === "function") { - fn = arguments[last]; - if (!true) { - if (last <= 8 && canEvaluate) { - var ret = new Promise(INTERNAL); - ret._captureStackTrace(); - var HolderClass = holderClasses[last - 1]; - var holder = new HolderClass(fn); - var callbacks = thenCallbacks; - - for (var i = 0; i < last; ++i) { - var maybePromise = tryConvertToPromise(arguments[i], ret); - if (maybePromise instanceof Promise) { - maybePromise = maybePromise._target(); - var bitField = maybePromise._bitField; - ; - if (((bitField & 50397184) === 0)) { - maybePromise._then(callbacks[i], reject, - undefined, ret, holder); - promiseSetters[i](maybePromise, holder); - holder.asyncNeeded = false; - } else if (((bitField & 33554432) !== 0)) { - callbacks[i].call(ret, - maybePromise._value(), holder); - } else if (((bitField & 16777216) !== 0)) { - ret._reject(maybePromise._reason()); - } else { - ret._cancel(); - } - } else { - callbacks[i].call(ret, maybePromise, holder); - } - } - - if (!ret._isFateSealed()) { - if (holder.asyncNeeded) { - var domain = getDomain(); - if (domain !== null) { - holder.fn = util.domainBind(domain, holder.fn); - } - } - ret._setAsyncGuaranteed(); - ret._setOnCancel(holder); - } - return ret; - } - } - } - var args = [].slice.call(arguments);; - if (fn) args.pop(); - var ret = new PromiseArray(args).promise(); - return fn !== undefined ? ret.spread(fn) : ret; -}; - -}; - -},{"./util":21}],13:[function(_dereq_,module,exports){ -"use strict"; -module.exports = -function(Promise, INTERNAL, tryConvertToPromise, apiRejection, debug) { -var util = _dereq_("./util"); -var tryCatch = util.tryCatch; - -Promise.method = function (fn) { - if (typeof fn !== "function") { - throw new Promise.TypeError("expecting a function but got " + util.classString(fn)); - } - return function () { - var ret = new Promise(INTERNAL); - ret._captureStackTrace(); - ret._pushContext(); - var value = tryCatch(fn).apply(this, arguments); - var promiseCreated = ret._popContext(); - debug.checkForgottenReturns( - value, promiseCreated, "Promise.method", ret); - ret._resolveFromSyncValue(value); - return ret; - }; -}; - -Promise.attempt = Promise["try"] = function (fn) { - if (typeof fn !== "function") { - return apiRejection("expecting a function but got " + util.classString(fn)); - } - var ret = new Promise(INTERNAL); - ret._captureStackTrace(); - ret._pushContext(); - var value; - if (arguments.length > 1) { - debug.deprecated("calling Promise.try with more than 1 argument"); - var arg = arguments[1]; - var ctx = arguments[2]; - value = util.isArray(arg) ? tryCatch(fn).apply(ctx, arg) - : tryCatch(fn).call(ctx, arg); - } else { - value = tryCatch(fn)(); - } - var promiseCreated = ret._popContext(); - debug.checkForgottenReturns( - value, promiseCreated, "Promise.try", ret); - ret._resolveFromSyncValue(value); - return ret; -}; - -Promise.prototype._resolveFromSyncValue = function (value) { - if (value === util.errorObj) { - this._rejectCallback(value.e, false); - } else { - this._resolveCallback(value, true); - } -}; -}; - -},{"./util":21}],14:[function(_dereq_,module,exports){ -"use strict"; -var util = _dereq_("./util"); -var maybeWrapAsError = util.maybeWrapAsError; -var errors = _dereq_("./errors"); -var OperationalError = errors.OperationalError; -var es5 = _dereq_("./es5"); - -function isUntypedError(obj) { - return obj instanceof Error && - es5.getPrototypeOf(obj) === Error.prototype; -} - -var rErrorKey = /^(?:name|message|stack|cause)$/; -function wrapAsOperationalError(obj) { - var ret; - if (isUntypedError(obj)) { - ret = new OperationalError(obj); - ret.name = obj.name; - ret.message = obj.message; - ret.stack = obj.stack; - var keys = es5.keys(obj); - for (var i = 0; i < keys.length; ++i) { - var key = keys[i]; - if (!rErrorKey.test(key)) { - ret[key] = obj[key]; - } - } - return ret; - } - util.markAsOriginatingFromRejection(obj); - return obj; -} - -function nodebackForPromise(promise, multiArgs) { - return function(err, value) { - if (promise === null) return; - if (err) { - var wrapped = wrapAsOperationalError(maybeWrapAsError(err)); - promise._attachExtraTrace(wrapped); - promise._reject(wrapped); - } else if (!multiArgs) { - promise._fulfill(value); - } else { - var args = [].slice.call(arguments, 1);; - promise._fulfill(args); - } - promise = null; - }; -} - -module.exports = nodebackForPromise; - -},{"./errors":9,"./es5":10,"./util":21}],15:[function(_dereq_,module,exports){ -"use strict"; -module.exports = function() { -var makeSelfResolutionError = function () { - return new TypeError("circular promise resolution chain\u000a\u000a See http://goo.gl/MqrFmX\u000a"); -}; -var reflectHandler = function() { - return new Promise.PromiseInspection(this._target()); -}; -var apiRejection = function(msg) { - return Promise.reject(new TypeError(msg)); -}; -function Proxyable() {} -var UNDEFINED_BINDING = {}; -var util = _dereq_("./util"); - -var getDomain; -if (util.isNode) { - getDomain = function() { - var ret = process.domain; - if (ret === undefined) ret = null; - return ret; - }; -} else { - getDomain = function() { - return null; - }; -} -util.notEnumerableProp(Promise, "_getDomain", getDomain); - -var es5 = _dereq_("./es5"); -var Async = _dereq_("./async"); -var async = new Async(); -es5.defineProperty(Promise, "_async", {value: async}); -var errors = _dereq_("./errors"); -var TypeError = Promise.TypeError = errors.TypeError; -Promise.RangeError = errors.RangeError; -var CancellationError = Promise.CancellationError = errors.CancellationError; -Promise.TimeoutError = errors.TimeoutError; -Promise.OperationalError = errors.OperationalError; -Promise.RejectionError = errors.OperationalError; -Promise.AggregateError = errors.AggregateError; -var INTERNAL = function(){}; -var APPLY = {}; -var NEXT_FILTER = {}; -var tryConvertToPromise = _dereq_("./thenables")(Promise, INTERNAL); -var PromiseArray = - _dereq_("./promise_array")(Promise, INTERNAL, - tryConvertToPromise, apiRejection, Proxyable); -var Context = _dereq_("./context")(Promise); - /*jshint unused:false*/ -var createContext = Context.create; -var debug = _dereq_("./debuggability")(Promise, Context); -var CapturedTrace = debug.CapturedTrace; -var PassThroughHandlerContext = - _dereq_("./finally")(Promise, tryConvertToPromise); -var catchFilter = _dereq_("./catch_filter")(NEXT_FILTER); -var nodebackForPromise = _dereq_("./nodeback"); -var errorObj = util.errorObj; -var tryCatch = util.tryCatch; -function check(self, executor) { - if (typeof executor !== "function") { - throw new TypeError("expecting a function but got " + util.classString(executor)); - } - if (self.constructor !== Promise) { - throw new TypeError("the promise constructor cannot be invoked directly\u000a\u000a See http://goo.gl/MqrFmX\u000a"); - } -} - -function Promise(executor) { - this._bitField = 0; - this._fulfillmentHandler0 = undefined; - this._rejectionHandler0 = undefined; - this._promise0 = undefined; - this._receiver0 = undefined; - if (executor !== INTERNAL) { - check(this, executor); - this._resolveFromExecutor(executor); - } - this._promiseCreated(); - this._fireEvent("promiseCreated", this); -} - -Promise.prototype.toString = function () { - return "[object Promise]"; -}; - -Promise.prototype.caught = Promise.prototype["catch"] = function (fn) { - var len = arguments.length; - if (len > 1) { - var catchInstances = new Array(len - 1), - j = 0, i; - for (i = 0; i < len - 1; ++i) { - var item = arguments[i]; - if (util.isObject(item)) { - catchInstances[j++] = item; - } else { - return apiRejection("expecting an object but got " + - "A catch statement predicate " + util.classString(item)); - } - } - catchInstances.length = j; - fn = arguments[i]; - return this.then(undefined, catchFilter(catchInstances, fn, this)); - } - return this.then(undefined, fn); -}; - -Promise.prototype.reflect = function () { - return this._then(reflectHandler, - reflectHandler, undefined, this, undefined); -}; - -Promise.prototype.then = function (didFulfill, didReject) { - if (debug.warnings() && arguments.length > 0 && - typeof didFulfill !== "function" && - typeof didReject !== "function") { - var msg = ".then() only accepts functions but was passed: " + - util.classString(didFulfill); - if (arguments.length > 1) { - msg += ", " + util.classString(didReject); - } - this._warn(msg); - } - return this._then(didFulfill, didReject, undefined, undefined, undefined); -}; - -Promise.prototype.done = function (didFulfill, didReject) { - var promise = - this._then(didFulfill, didReject, undefined, undefined, undefined); - promise._setIsFinal(); -}; - -Promise.prototype.spread = function (fn) { - if (typeof fn !== "function") { - return apiRejection("expecting a function but got " + util.classString(fn)); - } - return this.all()._then(fn, undefined, undefined, APPLY, undefined); -}; - -Promise.prototype.toJSON = function () { - var ret = { - isFulfilled: false, - isRejected: false, - fulfillmentValue: undefined, - rejectionReason: undefined - }; - if (this.isFulfilled()) { - ret.fulfillmentValue = this.value(); - ret.isFulfilled = true; - } else if (this.isRejected()) { - ret.rejectionReason = this.reason(); - ret.isRejected = true; - } - return ret; -}; - -Promise.prototype.all = function () { - if (arguments.length > 0) { - this._warn(".all() was passed arguments but it does not take any"); - } - return new PromiseArray(this).promise(); -}; - -Promise.prototype.error = function (fn) { - return this.caught(util.originatesFromRejection, fn); -}; - -Promise.getNewLibraryCopy = module.exports; - -Promise.is = function (val) { - return val instanceof Promise; -}; - -Promise.fromNode = Promise.fromCallback = function(fn) { - var ret = new Promise(INTERNAL); - ret._captureStackTrace(); - var multiArgs = arguments.length > 1 ? !!Object(arguments[1]).multiArgs - : false; - var result = tryCatch(fn)(nodebackForPromise(ret, multiArgs)); - if (result === errorObj) { - ret._rejectCallback(result.e, true); - } - if (!ret._isFateSealed()) ret._setAsyncGuaranteed(); - return ret; -}; - -Promise.all = function (promises) { - return new PromiseArray(promises).promise(); -}; - -Promise.cast = function (obj) { - var ret = tryConvertToPromise(obj); - if (!(ret instanceof Promise)) { - ret = new Promise(INTERNAL); - ret._captureStackTrace(); - ret._setFulfilled(); - ret._rejectionHandler0 = obj; - } - return ret; -}; - -Promise.resolve = Promise.fulfilled = Promise.cast; - -Promise.reject = Promise.rejected = function (reason) { - var ret = new Promise(INTERNAL); - ret._captureStackTrace(); - ret._rejectCallback(reason, true); - return ret; -}; - -Promise.setScheduler = function(fn) { - if (typeof fn !== "function") { - throw new TypeError("expecting a function but got " + util.classString(fn)); - } - return async.setScheduler(fn); -}; - -Promise.prototype._then = function ( - didFulfill, - didReject, - _, receiver, - internalData -) { - var haveInternalData = internalData !== undefined; - var promise = haveInternalData ? internalData : new Promise(INTERNAL); - var target = this._target(); - var bitField = target._bitField; - - if (!haveInternalData) { - promise._propagateFrom(this, 3); - promise._captureStackTrace(); - if (receiver === undefined && - ((this._bitField & 2097152) !== 0)) { - if (!((bitField & 50397184) === 0)) { - receiver = this._boundValue(); - } else { - receiver = target === this ? undefined : this._boundTo; - } - } - this._fireEvent("promiseChained", this, promise); - } - - var domain = getDomain(); - if (!((bitField & 50397184) === 0)) { - var handler, value, settler = target._settlePromiseCtx; - if (((bitField & 33554432) !== 0)) { - value = target._rejectionHandler0; - handler = didFulfill; - } else if (((bitField & 16777216) !== 0)) { - value = target._fulfillmentHandler0; - handler = didReject; - target._unsetRejectionIsUnhandled(); - } else { - settler = target._settlePromiseLateCancellationObserver; - value = new CancellationError("late cancellation observer"); - target._attachExtraTrace(value); - handler = didReject; - } - - async.invoke(settler, target, { - handler: domain === null ? handler - : (typeof handler === "function" && - util.domainBind(domain, handler)), - promise: promise, - receiver: receiver, - value: value - }); - } else { - target._addCallbacks(didFulfill, didReject, promise, receiver, domain); - } - - return promise; -}; - -Promise.prototype._length = function () { - return this._bitField & 65535; -}; - -Promise.prototype._isFateSealed = function () { - return (this._bitField & 117506048) !== 0; -}; - -Promise.prototype._isFollowing = function () { - return (this._bitField & 67108864) === 67108864; -}; - -Promise.prototype._setLength = function (len) { - this._bitField = (this._bitField & -65536) | - (len & 65535); -}; - -Promise.prototype._setFulfilled = function () { - this._bitField = this._bitField | 33554432; - this._fireEvent("promiseFulfilled", this); -}; - -Promise.prototype._setRejected = function () { - this._bitField = this._bitField | 16777216; - this._fireEvent("promiseRejected", this); -}; - -Promise.prototype._setFollowing = function () { - this._bitField = this._bitField | 67108864; - this._fireEvent("promiseResolved", this); -}; - -Promise.prototype._setIsFinal = function () { - this._bitField = this._bitField | 4194304; -}; - -Promise.prototype._isFinal = function () { - return (this._bitField & 4194304) > 0; -}; - -Promise.prototype._unsetCancelled = function() { - this._bitField = this._bitField & (~65536); -}; - -Promise.prototype._setCancelled = function() { - this._bitField = this._bitField | 65536; - this._fireEvent("promiseCancelled", this); -}; - -Promise.prototype._setWillBeCancelled = function() { - this._bitField = this._bitField | 8388608; -}; - -Promise.prototype._setAsyncGuaranteed = function() { - if (async.hasCustomScheduler()) return; - this._bitField = this._bitField | 134217728; -}; - -Promise.prototype._receiverAt = function (index) { - var ret = index === 0 ? this._receiver0 : this[ - index * 4 - 4 + 3]; - if (ret === UNDEFINED_BINDING) { - return undefined; - } else if (ret === undefined && this._isBound()) { - return this._boundValue(); - } - return ret; -}; - -Promise.prototype._promiseAt = function (index) { - return this[ - index * 4 - 4 + 2]; -}; - -Promise.prototype._fulfillmentHandlerAt = function (index) { - return this[ - index * 4 - 4 + 0]; -}; - -Promise.prototype._rejectionHandlerAt = function (index) { - return this[ - index * 4 - 4 + 1]; -}; - -Promise.prototype._boundValue = function() {}; - -Promise.prototype._migrateCallback0 = function (follower) { - var bitField = follower._bitField; - var fulfill = follower._fulfillmentHandler0; - var reject = follower._rejectionHandler0; - var promise = follower._promise0; - var receiver = follower._receiverAt(0); - if (receiver === undefined) receiver = UNDEFINED_BINDING; - this._addCallbacks(fulfill, reject, promise, receiver, null); -}; - -Promise.prototype._migrateCallbackAt = function (follower, index) { - var fulfill = follower._fulfillmentHandlerAt(index); - var reject = follower._rejectionHandlerAt(index); - var promise = follower._promiseAt(index); - var receiver = follower._receiverAt(index); - if (receiver === undefined) receiver = UNDEFINED_BINDING; - this._addCallbacks(fulfill, reject, promise, receiver, null); -}; - -Promise.prototype._addCallbacks = function ( - fulfill, - reject, - promise, - receiver, - domain -) { - var index = this._length(); - - if (index >= 65535 - 4) { - index = 0; - this._setLength(0); - } - - if (index === 0) { - this._promise0 = promise; - this._receiver0 = receiver; - if (typeof fulfill === "function") { - this._fulfillmentHandler0 = - domain === null ? fulfill : util.domainBind(domain, fulfill); - } - if (typeof reject === "function") { - this._rejectionHandler0 = - domain === null ? reject : util.domainBind(domain, reject); - } - } else { - var base = index * 4 - 4; - this[base + 2] = promise; - this[base + 3] = receiver; - if (typeof fulfill === "function") { - this[base + 0] = - domain === null ? fulfill : util.domainBind(domain, fulfill); - } - if (typeof reject === "function") { - this[base + 1] = - domain === null ? reject : util.domainBind(domain, reject); - } - } - this._setLength(index + 1); - return index; -}; - -Promise.prototype._proxy = function (proxyable, arg) { - this._addCallbacks(undefined, undefined, arg, proxyable, null); -}; - -Promise.prototype._resolveCallback = function(value, shouldBind) { - if (((this._bitField & 117506048) !== 0)) return; - if (value === this) - return this._rejectCallback(makeSelfResolutionError(), false); - var maybePromise = tryConvertToPromise(value, this); - if (!(maybePromise instanceof Promise)) return this._fulfill(value); - - if (shouldBind) this._propagateFrom(maybePromise, 2); - - var promise = maybePromise._target(); - - if (promise === this) { - this._reject(makeSelfResolutionError()); - return; - } - - var bitField = promise._bitField; - if (((bitField & 50397184) === 0)) { - var len = this._length(); - if (len > 0) promise._migrateCallback0(this); - for (var i = 1; i < len; ++i) { - promise._migrateCallbackAt(this, i); - } - this._setFollowing(); - this._setLength(0); - this._setFollowee(promise); - } else if (((bitField & 33554432) !== 0)) { - this._fulfill(promise._value()); - } else if (((bitField & 16777216) !== 0)) { - this._reject(promise._reason()); - } else { - var reason = new CancellationError("late cancellation observer"); - promise._attachExtraTrace(reason); - this._reject(reason); - } -}; - -Promise.prototype._rejectCallback = -function(reason, synchronous, ignoreNonErrorWarnings) { - var trace = util.ensureErrorObject(reason); - var hasStack = trace === reason; - if (!hasStack && !ignoreNonErrorWarnings && debug.warnings()) { - var message = "a promise was rejected with a non-error: " + - util.classString(reason); - this._warn(message, true); - } - this._attachExtraTrace(trace, synchronous ? hasStack : false); - this._reject(reason); -}; - -Promise.prototype._resolveFromExecutor = function (executor) { - var promise = this; - this._captureStackTrace(); - this._pushContext(); - var synchronous = true; - var r = this._execute(executor, function(value) { - promise._resolveCallback(value); - }, function (reason) { - promise._rejectCallback(reason, synchronous); - }); - synchronous = false; - this._popContext(); - - if (r !== undefined) { - promise._rejectCallback(r, true); - } -}; - -Promise.prototype._settlePromiseFromHandler = function ( - handler, receiver, value, promise -) { - var bitField = promise._bitField; - if (((bitField & 65536) !== 0)) return; - promise._pushContext(); - var x; - if (receiver === APPLY) { - if (!value || typeof value.length !== "number") { - x = errorObj; - x.e = new TypeError("cannot .spread() a non-array: " + - util.classString(value)); - } else { - x = tryCatch(handler).apply(this._boundValue(), value); - } - } else { - x = tryCatch(handler).call(receiver, value); - } - var promiseCreated = promise._popContext(); - bitField = promise._bitField; - if (((bitField & 65536) !== 0)) return; - - if (x === NEXT_FILTER) { - promise._reject(value); - } else if (x === errorObj) { - promise._rejectCallback(x.e, false); - } else { - debug.checkForgottenReturns(x, promiseCreated, "", promise, this); - promise._resolveCallback(x); - } -}; - -Promise.prototype._target = function() { - var ret = this; - while (ret._isFollowing()) ret = ret._followee(); - return ret; -}; - -Promise.prototype._followee = function() { - return this._rejectionHandler0; -}; - -Promise.prototype._setFollowee = function(promise) { - this._rejectionHandler0 = promise; -}; - -Promise.prototype._settlePromise = function(promise, handler, receiver, value) { - var isPromise = promise instanceof Promise; - var bitField = this._bitField; - var asyncGuaranteed = ((bitField & 134217728) !== 0); - if (((bitField & 65536) !== 0)) { - if (isPromise) promise._invokeInternalOnCancel(); - - if (receiver instanceof PassThroughHandlerContext && - receiver.isFinallyHandler()) { - receiver.cancelPromise = promise; - if (tryCatch(handler).call(receiver, value) === errorObj) { - promise._reject(errorObj.e); - } - } else if (handler === reflectHandler) { - promise._fulfill(reflectHandler.call(receiver)); - } else if (receiver instanceof Proxyable) { - receiver._promiseCancelled(promise); - } else if (isPromise || promise instanceof PromiseArray) { - promise._cancel(); - } else { - receiver.cancel(); - } - } else if (typeof handler === "function") { - if (!isPromise) { - handler.call(receiver, value, promise); - } else { - if (asyncGuaranteed) promise._setAsyncGuaranteed(); - this._settlePromiseFromHandler(handler, receiver, value, promise); - } - } else if (receiver instanceof Proxyable) { - if (!receiver._isResolved()) { - if (((bitField & 33554432) !== 0)) { - receiver._promiseFulfilled(value, promise); - } else { - receiver._promiseRejected(value, promise); - } - } - } else if (isPromise) { - if (asyncGuaranteed) promise._setAsyncGuaranteed(); - if (((bitField & 33554432) !== 0)) { - promise._fulfill(value); - } else { - promise._reject(value); - } - } -}; - -Promise.prototype._settlePromiseLateCancellationObserver = function(ctx) { - var handler = ctx.handler; - var promise = ctx.promise; - var receiver = ctx.receiver; - var value = ctx.value; - if (typeof handler === "function") { - if (!(promise instanceof Promise)) { - handler.call(receiver, value, promise); - } else { - this._settlePromiseFromHandler(handler, receiver, value, promise); - } - } else if (promise instanceof Promise) { - promise._reject(value); - } -}; - -Promise.prototype._settlePromiseCtx = function(ctx) { - this._settlePromise(ctx.promise, ctx.handler, ctx.receiver, ctx.value); -}; - -Promise.prototype._settlePromise0 = function(handler, value, bitField) { - var promise = this._promise0; - var receiver = this._receiverAt(0); - this._promise0 = undefined; - this._receiver0 = undefined; - this._settlePromise(promise, handler, receiver, value); -}; - -Promise.prototype._clearCallbackDataAtIndex = function(index) { - var base = index * 4 - 4; - this[base + 2] = - this[base + 3] = - this[base + 0] = - this[base + 1] = undefined; -}; - -Promise.prototype._fulfill = function (value) { - var bitField = this._bitField; - if (((bitField & 117506048) >>> 16)) return; - if (value === this) { - var err = makeSelfResolutionError(); - this._attachExtraTrace(err); - return this._reject(err); - } - this._setFulfilled(); - this._rejectionHandler0 = value; - - if ((bitField & 65535) > 0) { - if (((bitField & 134217728) !== 0)) { - this._settlePromises(); - } else { - async.settlePromises(this); - } - } -}; - -Promise.prototype._reject = function (reason) { - var bitField = this._bitField; - if (((bitField & 117506048) >>> 16)) return; - this._setRejected(); - this._fulfillmentHandler0 = reason; - - if (this._isFinal()) { - return async.fatalError(reason, util.isNode); - } - - if ((bitField & 65535) > 0) { - async.settlePromises(this); - } else { - this._ensurePossibleRejectionHandled(); - } -}; - -Promise.prototype._fulfillPromises = function (len, value) { - for (var i = 1; i < len; i++) { - var handler = this._fulfillmentHandlerAt(i); - var promise = this._promiseAt(i); - var receiver = this._receiverAt(i); - this._clearCallbackDataAtIndex(i); - this._settlePromise(promise, handler, receiver, value); - } -}; - -Promise.prototype._rejectPromises = function (len, reason) { - for (var i = 1; i < len; i++) { - var handler = this._rejectionHandlerAt(i); - var promise = this._promiseAt(i); - var receiver = this._receiverAt(i); - this._clearCallbackDataAtIndex(i); - this._settlePromise(promise, handler, receiver, reason); - } -}; - -Promise.prototype._settlePromises = function () { - var bitField = this._bitField; - var len = (bitField & 65535); - - if (len > 0) { - if (((bitField & 16842752) !== 0)) { - var reason = this._fulfillmentHandler0; - this._settlePromise0(this._rejectionHandler0, reason, bitField); - this._rejectPromises(len, reason); - } else { - var value = this._rejectionHandler0; - this._settlePromise0(this._fulfillmentHandler0, value, bitField); - this._fulfillPromises(len, value); - } - this._setLength(0); - } - this._clearCancellationData(); -}; - -Promise.prototype._settledValue = function() { - var bitField = this._bitField; - if (((bitField & 33554432) !== 0)) { - return this._rejectionHandler0; - } else if (((bitField & 16777216) !== 0)) { - return this._fulfillmentHandler0; - } -}; - -function deferResolve(v) {this.promise._resolveCallback(v);} -function deferReject(v) {this.promise._rejectCallback(v, false);} - -Promise.defer = Promise.pending = function() { - debug.deprecated("Promise.defer", "new Promise"); - var promise = new Promise(INTERNAL); - return { - promise: promise, - resolve: deferResolve, - reject: deferReject - }; -}; - -util.notEnumerableProp(Promise, - "_makeSelfResolutionError", - makeSelfResolutionError); - -_dereq_("./method")(Promise, INTERNAL, tryConvertToPromise, apiRejection, - debug); -_dereq_("./bind")(Promise, INTERNAL, tryConvertToPromise, debug); -_dereq_("./cancel")(Promise, PromiseArray, apiRejection, debug); -_dereq_("./direct_resolve")(Promise); -_dereq_("./synchronous_inspection")(Promise); -_dereq_("./join")( - Promise, PromiseArray, tryConvertToPromise, INTERNAL, async, getDomain); -Promise.Promise = Promise; -Promise.version = "3.4.7"; - - util.toFastProperties(Promise); - util.toFastProperties(Promise.prototype); - function fillTypes(value) { - var p = new Promise(INTERNAL); - p._fulfillmentHandler0 = value; - p._rejectionHandler0 = value; - p._promise0 = value; - p._receiver0 = value; - } - // Complete slack tracking, opt out of field-type tracking and - // stabilize map - fillTypes({a: 1}); - fillTypes({b: 2}); - fillTypes({c: 3}); - fillTypes(1); - fillTypes(function(){}); - fillTypes(undefined); - fillTypes(false); - fillTypes(new Promise(INTERNAL)); - debug.setBounds(Async.firstLineError, util.lastLineError); - return Promise; - -}; - -},{"./async":1,"./bind":2,"./cancel":4,"./catch_filter":5,"./context":6,"./debuggability":7,"./direct_resolve":8,"./errors":9,"./es5":10,"./finally":11,"./join":12,"./method":13,"./nodeback":14,"./promise_array":16,"./synchronous_inspection":19,"./thenables":20,"./util":21}],16:[function(_dereq_,module,exports){ -"use strict"; -module.exports = function(Promise, INTERNAL, tryConvertToPromise, - apiRejection, Proxyable) { -var util = _dereq_("./util"); -var isArray = util.isArray; - -function toResolutionValue(val) { - switch(val) { - case -2: return []; - case -3: return {}; - } -} - -function PromiseArray(values) { - var promise = this._promise = new Promise(INTERNAL); - if (values instanceof Promise) { - promise._propagateFrom(values, 3); - } - promise._setOnCancel(this); - this._values = values; - this._length = 0; - this._totalResolved = 0; - this._init(undefined, -2); -} -util.inherits(PromiseArray, Proxyable); - -PromiseArray.prototype.length = function () { - return this._length; -}; - -PromiseArray.prototype.promise = function () { - return this._promise; -}; - -PromiseArray.prototype._init = function init(_, resolveValueIfEmpty) { - var values = tryConvertToPromise(this._values, this._promise); - if (values instanceof Promise) { - values = values._target(); - var bitField = values._bitField; - ; - this._values = values; - - if (((bitField & 50397184) === 0)) { - this._promise._setAsyncGuaranteed(); - return values._then( - init, - this._reject, - undefined, - this, - resolveValueIfEmpty - ); - } else if (((bitField & 33554432) !== 0)) { - values = values._value(); - } else if (((bitField & 16777216) !== 0)) { - return this._reject(values._reason()); - } else { - return this._cancel(); - } - } - values = util.asArray(values); - if (values === null) { - var err = apiRejection( - "expecting an array or an iterable object but got " + util.classString(values)).reason(); - this._promise._rejectCallback(err, false); - return; - } - - if (values.length === 0) { - if (resolveValueIfEmpty === -5) { - this._resolveEmptyArray(); - } - else { - this._resolve(toResolutionValue(resolveValueIfEmpty)); - } - return; - } - this._iterate(values); -}; - -PromiseArray.prototype._iterate = function(values) { - var len = this.getActualLength(values.length); - this._length = len; - this._values = this.shouldCopyValues() ? new Array(len) : this._values; - var result = this._promise; - var isResolved = false; - var bitField = null; - for (var i = 0; i < len; ++i) { - var maybePromise = tryConvertToPromise(values[i], result); - - if (maybePromise instanceof Promise) { - maybePromise = maybePromise._target(); - bitField = maybePromise._bitField; - } else { - bitField = null; - } - - if (isResolved) { - if (bitField !== null) { - maybePromise.suppressUnhandledRejections(); - } - } else if (bitField !== null) { - if (((bitField & 50397184) === 0)) { - maybePromise._proxy(this, i); - this._values[i] = maybePromise; - } else if (((bitField & 33554432) !== 0)) { - isResolved = this._promiseFulfilled(maybePromise._value(), i); - } else if (((bitField & 16777216) !== 0)) { - isResolved = this._promiseRejected(maybePromise._reason(), i); - } else { - isResolved = this._promiseCancelled(i); - } - } else { - isResolved = this._promiseFulfilled(maybePromise, i); - } - } - if (!isResolved) result._setAsyncGuaranteed(); -}; - -PromiseArray.prototype._isResolved = function () { - return this._values === null; -}; - -PromiseArray.prototype._resolve = function (value) { - this._values = null; - this._promise._fulfill(value); -}; - -PromiseArray.prototype._cancel = function() { - if (this._isResolved() || !this._promise._isCancellable()) return; - this._values = null; - this._promise._cancel(); -}; - -PromiseArray.prototype._reject = function (reason) { - this._values = null; - this._promise._rejectCallback(reason, false); -}; - -PromiseArray.prototype._promiseFulfilled = function (value, index) { - this._values[index] = value; - var totalResolved = ++this._totalResolved; - if (totalResolved >= this._length) { - this._resolve(this._values); - return true; - } - return false; -}; - -PromiseArray.prototype._promiseCancelled = function() { - this._cancel(); - return true; -}; - -PromiseArray.prototype._promiseRejected = function (reason) { - this._totalResolved++; - this._reject(reason); - return true; -}; - -PromiseArray.prototype._resultCancelled = function() { - if (this._isResolved()) return; - var values = this._values; - this._cancel(); - if (values instanceof Promise) { - values.cancel(); - } else { - for (var i = 0; i < values.length; ++i) { - if (values[i] instanceof Promise) { - values[i].cancel(); - } - } - } -}; - -PromiseArray.prototype.shouldCopyValues = function () { - return true; -}; - -PromiseArray.prototype.getActualLength = function (len) { - return len; -}; - -return PromiseArray; -}; - -},{"./util":21}],17:[function(_dereq_,module,exports){ -"use strict"; -function arrayMove(src, srcIndex, dst, dstIndex, len) { - for (var j = 0; j < len; ++j) { - dst[j + dstIndex] = src[j + srcIndex]; - src[j + srcIndex] = void 0; - } -} - -function Queue(capacity) { - this._capacity = capacity; - this._length = 0; - this._front = 0; -} - -Queue.prototype._willBeOverCapacity = function (size) { - return this._capacity < size; -}; - -Queue.prototype._pushOne = function (arg) { - var length = this.length(); - this._checkCapacity(length + 1); - var i = (this._front + length) & (this._capacity - 1); - this[i] = arg; - this._length = length + 1; -}; - -Queue.prototype.push = function (fn, receiver, arg) { - var length = this.length() + 3; - if (this._willBeOverCapacity(length)) { - this._pushOne(fn); - this._pushOne(receiver); - this._pushOne(arg); - return; - } - var j = this._front + length - 3; - this._checkCapacity(length); - var wrapMask = this._capacity - 1; - this[(j + 0) & wrapMask] = fn; - this[(j + 1) & wrapMask] = receiver; - this[(j + 2) & wrapMask] = arg; - this._length = length; -}; - -Queue.prototype.shift = function () { - var front = this._front, - ret = this[front]; - - this[front] = undefined; - this._front = (front + 1) & (this._capacity - 1); - this._length--; - return ret; -}; - -Queue.prototype.length = function () { - return this._length; -}; - -Queue.prototype._checkCapacity = function (size) { - if (this._capacity < size) { - this._resizeTo(this._capacity << 1); - } -}; - -Queue.prototype._resizeTo = function (capacity) { - var oldCapacity = this._capacity; - this._capacity = capacity; - var front = this._front; - var length = this._length; - var moveItemsCount = (front + length) & (oldCapacity - 1); - arrayMove(this, 0, this, oldCapacity, moveItemsCount); -}; - -module.exports = Queue; - -},{}],18:[function(_dereq_,module,exports){ -"use strict"; -var util = _dereq_("./util"); -var schedule; -var noAsyncScheduler = function() { - throw new Error("No async scheduler available\u000a\u000a See http://goo.gl/MqrFmX\u000a"); -}; -var NativePromise = util.getNativePromise(); -if (util.isNode && typeof MutationObserver === "undefined") { - var GlobalSetImmediate = global.setImmediate; - var ProcessNextTick = process.nextTick; - schedule = util.isRecentNode - ? function(fn) { GlobalSetImmediate.call(global, fn); } - : function(fn) { ProcessNextTick.call(process, fn); }; -} else if (typeof NativePromise === "function" && - typeof NativePromise.resolve === "function") { - var nativePromise = NativePromise.resolve(); - schedule = function(fn) { - nativePromise.then(fn); - }; -} else if ((typeof MutationObserver !== "undefined") && - !(typeof window !== "undefined" && - window.navigator && - (window.navigator.standalone || window.cordova))) { - schedule = (function() { - var div = document.createElement("div"); - var opts = {attributes: true}; - var toggleScheduled = false; - var div2 = document.createElement("div"); - var o2 = new MutationObserver(function() { - div.classList.toggle("foo"); - toggleScheduled = false; - }); - o2.observe(div2, opts); - - var scheduleToggle = function() { - if (toggleScheduled) return; - toggleScheduled = true; - div2.classList.toggle("foo"); - }; - - return function schedule(fn) { - var o = new MutationObserver(function() { - o.disconnect(); - fn(); - }); - o.observe(div, opts); - scheduleToggle(); - }; - })(); -} else if (typeof setImmediate !== "undefined") { - schedule = function (fn) { - setImmediate(fn); - }; -} else if (typeof setTimeout !== "undefined") { - schedule = function (fn) { - setTimeout(fn, 0); - }; -} else { - schedule = noAsyncScheduler; -} -module.exports = schedule; - -},{"./util":21}],19:[function(_dereq_,module,exports){ -"use strict"; -module.exports = function(Promise) { -function PromiseInspection(promise) { - if (promise !== undefined) { - promise = promise._target(); - this._bitField = promise._bitField; - this._settledValueField = promise._isFateSealed() - ? promise._settledValue() : undefined; - } - else { - this._bitField = 0; - this._settledValueField = undefined; - } -} - -PromiseInspection.prototype._settledValue = function() { - return this._settledValueField; -}; - -var value = PromiseInspection.prototype.value = function () { - if (!this.isFulfilled()) { - throw new TypeError("cannot get fulfillment value of a non-fulfilled promise\u000a\u000a See http://goo.gl/MqrFmX\u000a"); - } - return this._settledValue(); -}; - -var reason = PromiseInspection.prototype.error = -PromiseInspection.prototype.reason = function () { - if (!this.isRejected()) { - throw new TypeError("cannot get rejection reason of a non-rejected promise\u000a\u000a See http://goo.gl/MqrFmX\u000a"); - } - return this._settledValue(); -}; - -var isFulfilled = PromiseInspection.prototype.isFulfilled = function() { - return (this._bitField & 33554432) !== 0; -}; - -var isRejected = PromiseInspection.prototype.isRejected = function () { - return (this._bitField & 16777216) !== 0; -}; - -var isPending = PromiseInspection.prototype.isPending = function () { - return (this._bitField & 50397184) === 0; -}; - -var isResolved = PromiseInspection.prototype.isResolved = function () { - return (this._bitField & 50331648) !== 0; -}; - -PromiseInspection.prototype.isCancelled = function() { - return (this._bitField & 8454144) !== 0; -}; - -Promise.prototype.__isCancelled = function() { - return (this._bitField & 65536) === 65536; -}; - -Promise.prototype._isCancelled = function() { - return this._target().__isCancelled(); -}; - -Promise.prototype.isCancelled = function() { - return (this._target()._bitField & 8454144) !== 0; -}; - -Promise.prototype.isPending = function() { - return isPending.call(this._target()); -}; - -Promise.prototype.isRejected = function() { - return isRejected.call(this._target()); -}; - -Promise.prototype.isFulfilled = function() { - return isFulfilled.call(this._target()); -}; - -Promise.prototype.isResolved = function() { - return isResolved.call(this._target()); -}; - -Promise.prototype.value = function() { - return value.call(this._target()); -}; - -Promise.prototype.reason = function() { - var target = this._target(); - target._unsetRejectionIsUnhandled(); - return reason.call(target); -}; - -Promise.prototype._value = function() { - return this._settledValue(); -}; - -Promise.prototype._reason = function() { - this._unsetRejectionIsUnhandled(); - return this._settledValue(); -}; - -Promise.PromiseInspection = PromiseInspection; -}; - -},{}],20:[function(_dereq_,module,exports){ -"use strict"; -module.exports = function(Promise, INTERNAL) { -var util = _dereq_("./util"); -var errorObj = util.errorObj; -var isObject = util.isObject; - -function tryConvertToPromise(obj, context) { - if (isObject(obj)) { - if (obj instanceof Promise) return obj; - var then = getThen(obj); - if (then === errorObj) { - if (context) context._pushContext(); - var ret = Promise.reject(then.e); - if (context) context._popContext(); - return ret; - } else if (typeof then === "function") { - if (isAnyBluebirdPromise(obj)) { - var ret = new Promise(INTERNAL); - obj._then( - ret._fulfill, - ret._reject, - undefined, - ret, - null - ); - return ret; - } - return doThenable(obj, then, context); - } - } - return obj; -} - -function doGetThen(obj) { - return obj.then; -} - -function getThen(obj) { - try { - return doGetThen(obj); - } catch (e) { - errorObj.e = e; - return errorObj; - } -} - -var hasProp = {}.hasOwnProperty; -function isAnyBluebirdPromise(obj) { - try { - return hasProp.call(obj, "_promise0"); - } catch (e) { - return false; - } -} - -function doThenable(x, then, context) { - var promise = new Promise(INTERNAL); - var ret = promise; - if (context) context._pushContext(); - promise._captureStackTrace(); - if (context) context._popContext(); - var synchronous = true; - var result = util.tryCatch(then).call(x, resolve, reject); - synchronous = false; - - if (promise && result === errorObj) { - promise._rejectCallback(result.e, true, true); - promise = null; - } - - function resolve(value) { - if (!promise) return; - promise._resolveCallback(value); - promise = null; - } - - function reject(reason) { - if (!promise) return; - promise._rejectCallback(reason, synchronous, true); - promise = null; - } - return ret; -} - -return tryConvertToPromise; -}; - -},{"./util":21}],21:[function(_dereq_,module,exports){ -"use strict"; -var es5 = _dereq_("./es5"); -var canEvaluate = typeof navigator == "undefined"; - -var errorObj = {e: {}}; -var tryCatchTarget; -var globalObject = typeof self !== "undefined" ? self : - typeof window !== "undefined" ? window : - typeof global !== "undefined" ? global : - this !== undefined ? this : null; - -function tryCatcher() { - try { - var target = tryCatchTarget; - tryCatchTarget = null; - return target.apply(this, arguments); - } catch (e) { - errorObj.e = e; - return errorObj; - } -} -function tryCatch(fn) { - tryCatchTarget = fn; - return tryCatcher; -} - -var inherits = function(Child, Parent) { - var hasProp = {}.hasOwnProperty; - - function T() { - this.constructor = Child; - this.constructor$ = Parent; - for (var propertyName in Parent.prototype) { - if (hasProp.call(Parent.prototype, propertyName) && - propertyName.charAt(propertyName.length-1) !== "$" - ) { - this[propertyName + "$"] = Parent.prototype[propertyName]; - } - } - } - T.prototype = Parent.prototype; - Child.prototype = new T(); - return Child.prototype; -}; - - -function isPrimitive(val) { - return val == null || val === true || val === false || - typeof val === "string" || typeof val === "number"; - -} - -function isObject(value) { - return typeof value === "function" || - typeof value === "object" && value !== null; -} - -function maybeWrapAsError(maybeError) { - if (!isPrimitive(maybeError)) return maybeError; - - return new Error(safeToString(maybeError)); -} - -function withAppended(target, appendee) { - var len = target.length; - var ret = new Array(len + 1); - var i; - for (i = 0; i < len; ++i) { - ret[i] = target[i]; - } - ret[i] = appendee; - return ret; -} - -function getDataPropertyOrDefault(obj, key, defaultValue) { - if (es5.isES5) { - var desc = Object.getOwnPropertyDescriptor(obj, key); - - if (desc != null) { - return desc.get == null && desc.set == null - ? desc.value - : defaultValue; - } - } else { - return {}.hasOwnProperty.call(obj, key) ? obj[key] : undefined; - } -} - -function notEnumerableProp(obj, name, value) { - if (isPrimitive(obj)) return obj; - var descriptor = { - value: value, - configurable: true, - enumerable: false, - writable: true - }; - es5.defineProperty(obj, name, descriptor); - return obj; -} - -function thrower(r) { - throw r; -} - -var inheritedDataKeys = (function() { - var excludedPrototypes = [ - Array.prototype, - Object.prototype, - Function.prototype - ]; - - var isExcludedProto = function(val) { - for (var i = 0; i < excludedPrototypes.length; ++i) { - if (excludedPrototypes[i] === val) { - return true; - } - } - return false; - }; - - if (es5.isES5) { - var getKeys = Object.getOwnPropertyNames; - return function(obj) { - var ret = []; - var visitedKeys = Object.create(null); - while (obj != null && !isExcludedProto(obj)) { - var keys; - try { - keys = getKeys(obj); - } catch (e) { - return ret; - } - for (var i = 0; i < keys.length; ++i) { - var key = keys[i]; - if (visitedKeys[key]) continue; - visitedKeys[key] = true; - var desc = Object.getOwnPropertyDescriptor(obj, key); - if (desc != null && desc.get == null && desc.set == null) { - ret.push(key); - } - } - obj = es5.getPrototypeOf(obj); - } - return ret; - }; - } else { - var hasProp = {}.hasOwnProperty; - return function(obj) { - if (isExcludedProto(obj)) return []; - var ret = []; - - /*jshint forin:false */ - enumeration: for (var key in obj) { - if (hasProp.call(obj, key)) { - ret.push(key); - } else { - for (var i = 0; i < excludedPrototypes.length; ++i) { - if (hasProp.call(excludedPrototypes[i], key)) { - continue enumeration; - } - } - ret.push(key); - } - } - return ret; - }; - } - -})(); - -var thisAssignmentPattern = /this\s*\.\s*\S+\s*=/; -function isClass(fn) { - try { - if (typeof fn === "function") { - var keys = es5.names(fn.prototype); - - var hasMethods = es5.isES5 && keys.length > 1; - var hasMethodsOtherThanConstructor = keys.length > 0 && - !(keys.length === 1 && keys[0] === "constructor"); - var hasThisAssignmentAndStaticMethods = - thisAssignmentPattern.test(fn + "") && es5.names(fn).length > 0; - - if (hasMethods || hasMethodsOtherThanConstructor || - hasThisAssignmentAndStaticMethods) { - return true; - } - } - return false; - } catch (e) { - return false; - } -} - -function toFastProperties(obj) { - /*jshint -W027,-W055,-W031*/ - function FakeConstructor() {} - FakeConstructor.prototype = obj; - var l = 8; - while (l--) new FakeConstructor(); - return obj; - eval(obj); -} - -var rident = /^[a-z$_][a-z$_0-9]*$/i; -function isIdentifier(str) { - return rident.test(str); -} - -function filledRange(count, prefix, suffix) { - var ret = new Array(count); - for(var i = 0; i < count; ++i) { - ret[i] = prefix + i + suffix; - } - return ret; -} - -function safeToString(obj) { - try { - return obj + ""; - } catch (e) { - return "[no string representation]"; - } -} - -function isError(obj) { - return obj !== null && - typeof obj === "object" && - typeof obj.message === "string" && - typeof obj.name === "string"; -} - -function markAsOriginatingFromRejection(e) { - try { - notEnumerableProp(e, "isOperational", true); - } - catch(ignore) {} -} - -function originatesFromRejection(e) { - if (e == null) return false; - return ((e instanceof Error["__BluebirdErrorTypes__"].OperationalError) || - e["isOperational"] === true); -} - -function canAttachTrace(obj) { - return isError(obj) && es5.propertyIsWritable(obj, "stack"); -} - -var ensureErrorObject = (function() { - if (!("stack" in new Error())) { - return function(value) { - if (canAttachTrace(value)) return value; - try {throw new Error(safeToString(value));} - catch(err) {return err;} - }; - } else { - return function(value) { - if (canAttachTrace(value)) return value; - return new Error(safeToString(value)); - }; - } -})(); - -function classString(obj) { - return {}.toString.call(obj); -} - -function copyDescriptors(from, to, filter) { - var keys = es5.names(from); - for (var i = 0; i < keys.length; ++i) { - var key = keys[i]; - if (filter(key)) { - try { - es5.defineProperty(to, key, es5.getDescriptor(from, key)); - } catch (ignore) {} - } - } -} - -var asArray = function(v) { - if (es5.isArray(v)) { - return v; - } - return null; -}; - -if (typeof Symbol !== "undefined" && Symbol.iterator) { - var ArrayFrom = typeof Array.from === "function" ? function(v) { - return Array.from(v); - } : function(v) { - var ret = []; - var it = v[Symbol.iterator](); - var itResult; - while (!((itResult = it.next()).done)) { - ret.push(itResult.value); - } - return ret; - }; - - asArray = function(v) { - if (es5.isArray(v)) { - return v; - } else if (v != null && typeof v[Symbol.iterator] === "function") { - return ArrayFrom(v); - } - return null; - }; -} - -var isNode = typeof process !== "undefined" && - classString(process).toLowerCase() === "[object process]"; - -var hasEnvVariables = typeof process !== "undefined" && - typeof process.env !== "undefined"; - -function env(key) { - return hasEnvVariables ? process.env[key] : undefined; -} - -function getNativePromise() { - if (typeof Promise === "function") { - try { - var promise = new Promise(function(){}); - if ({}.toString.call(promise) === "[object Promise]") { - return Promise; - } - } catch (e) {} - } -} - -function domainBind(self, cb) { - return self.bind(cb); -} - -var ret = { - isClass: isClass, - isIdentifier: isIdentifier, - inheritedDataKeys: inheritedDataKeys, - getDataPropertyOrDefault: getDataPropertyOrDefault, - thrower: thrower, - isArray: es5.isArray, - asArray: asArray, - notEnumerableProp: notEnumerableProp, - isPrimitive: isPrimitive, - isObject: isObject, - isError: isError, - canEvaluate: canEvaluate, - errorObj: errorObj, - tryCatch: tryCatch, - inherits: inherits, - withAppended: withAppended, - maybeWrapAsError: maybeWrapAsError, - toFastProperties: toFastProperties, - filledRange: filledRange, - toString: safeToString, - canAttachTrace: canAttachTrace, - ensureErrorObject: ensureErrorObject, - originatesFromRejection: originatesFromRejection, - markAsOriginatingFromRejection: markAsOriginatingFromRejection, - classString: classString, - copyDescriptors: copyDescriptors, - hasDevTools: typeof chrome !== "undefined" && chrome && - typeof chrome.loadTimes === "function", - isNode: isNode, - hasEnvVariables: hasEnvVariables, - env: env, - global: globalObject, - getNativePromise: getNativePromise, - domainBind: domainBind -}; -ret.isRecentNode = ret.isNode && (function() { - var version = process.versions.node.split(".").map(Number); - return (version[0] === 0 && version[1] > 10) || (version[0] > 0); -})(); - -if (ret.isNode) ret.toFastProperties(process); - -try {throw new Error(); } catch (e) {ret.lastLineError = e;} -module.exports = ret; - -},{"./es5":10}]},{},[3])(3) -}); ;if (typeof window !== 'undefined' && window !== null) { window.P = window.Promise; } else if (typeof self !== 'undefined' && self !== null) { self.P = self.Promise; } -/** vim: et:ts=4:sw=4:sts=4 - * @license RequireJS 2.3.2 Copyright jQuery Foundation and other contributors. - * Released under MIT license, https://github.com/requirejs/requirejs/blob/master/LICENSE - */ -//Not using strict: uneven strict support in browsers, #392, and causes -//problems with requirejs.exec()/transpiler plugins that may not be strict. -/*jslint regexp: true, nomen: true, sloppy: true */ -/*global window, navigator, document, importScripts, setTimeout, opera */ - -var requirejs, require, define; -(function (global, setTimeout) { - var req, s, head, baseElement, dataMain, src, - interactiveScript, currentlyAddingScript, mainScript, subPath, - version = '2.3.2', - commentRegExp = /\/\*[\s\S]*?\*\/|([^:"'=]|^)\/\/.*$/mg, - cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g, - jsSuffixRegExp = /\.js$/, - currDirRegExp = /^\.\//, - op = Object.prototype, - ostring = op.toString, - hasOwn = op.hasOwnProperty, - isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document), - isWebWorker = !isBrowser && typeof importScripts !== 'undefined', - //PS3 indicates loaded and complete, but need to wait for complete - //specifically. Sequence is 'loading', 'loaded', execution, - // then 'complete'. The UA check is unfortunate, but not sure how - //to feature test w/o causing perf issues. - readyRegExp = isBrowser && navigator.platform === 'PLAYSTATION 3' ? - /^complete$/ : /^(complete|loaded)$/, - defContextName = '_', - //Oh the tragedy, detecting opera. See the usage of isOpera for reason. - isOpera = typeof opera !== 'undefined' && opera.toString() === '[object Opera]', - contexts = {}, - cfg = {}, - globalDefQueue = [], - useInteractive = false; - - //Could match something like ')//comment', do not lose the prefix to comment. - function commentReplace(match, singlePrefix) { - return singlePrefix || ''; - } - - function isFunction(it) { - return ostring.call(it) === '[object Function]'; - } - - function isArray(it) { - return ostring.call(it) === '[object Array]'; - } - - /** - * Helper function for iterating over an array. If the func returns - * a true value, it will break out of the loop. - */ - function each(ary, func) { - if (ary) { - var i; - for (i = 0; i < ary.length; i += 1) { - if (ary[i] && func(ary[i], i, ary)) { - break; - } - } - } - } - - /** - * Helper function for iterating over an array backwards. If the func - * returns a true value, it will break out of the loop. - */ - function eachReverse(ary, func) { - if (ary) { - var i; - for (i = ary.length - 1; i > -1; i -= 1) { - if (ary[i] && func(ary[i], i, ary)) { - break; - } - } - } - } - - function hasProp(obj, prop) { - return hasOwn.call(obj, prop); - } - - function getOwn(obj, prop) { - return hasProp(obj, prop) && obj[prop]; - } - - /** - * Cycles over properties in an object and calls a function for each - * property value. If the function returns a truthy value, then the - * iteration is stopped. - */ - function eachProp(obj, func) { - var prop; - for (prop in obj) { - if (hasProp(obj, prop)) { - if (func(obj[prop], prop)) { - break; - } - } - } - } - - /** - * Simple function to mix in properties from source into target, - * but only if target does not already have a property of the same name. - */ - function mixin(target, source, force, deepStringMixin) { - if (source) { - eachProp(source, function (value, prop) { - if (force || !hasProp(target, prop)) { - if (deepStringMixin && typeof value === 'object' && value && - !isArray(value) && !isFunction(value) && - !(value instanceof RegExp)) { - - if (!target[prop]) { - target[prop] = {}; - } - mixin(target[prop], value, force, deepStringMixin); - } else { - target[prop] = value; - } - } - }); - } - return target; - } - - //Similar to Function.prototype.bind, but the 'this' object is specified - //first, since it is easier to read/figure out what 'this' will be. - function bind(obj, fn) { - return function () { - return fn.apply(obj, arguments); - }; - } - - function scripts() { - return document.getElementsByTagName('script'); - } - - function defaultOnError(err) { - throw err; - } - - //Allow getting a global that is expressed in - //dot notation, like 'a.b.c'. - function getGlobal(value) { - if (!value) { - return value; - } - var g = global; - each(value.split('.'), function (part) { - g = g[part]; - }); - return g; - } - - /** - * Constructs an error with a pointer to an URL with more information. - * @param {String} id the error ID that maps to an ID on a web page. - * @param {String} message human readable error. - * @param {Error} [err] the original error, if there is one. - * - * @returns {Error} - */ - function makeError(id, msg, err, requireModules) { - var e = new Error(msg + '\nhttp://requirejs.org/docs/errors.html#' + id); - e.requireType = id; - e.requireModules = requireModules; - if (err) { - e.originalError = err; - } - return e; - } - - if (typeof define !== 'undefined') { - //If a define is already in play via another AMD loader, - //do not overwrite. - return; - } - - if (typeof requirejs !== 'undefined') { - if (isFunction(requirejs)) { - //Do not overwrite an existing requirejs instance. - return; - } - cfg = requirejs; - requirejs = undefined; - } - - //Allow for a require config object - if (typeof require !== 'undefined' && !isFunction(require)) { - //assume it is a config object. - cfg = require; - require = undefined; - } - - function newContext(contextName) { - var inCheckLoaded, Module, context, handlers, - checkLoadedTimeoutId, - config = { - //Defaults. Do not set a default for map - //config to speed up normalize(), which - //will run faster if there is no default. - waitSeconds: 7, - baseUrl: './', - paths: {}, - bundles: {}, - pkgs: {}, - shim: {}, - config: {} - }, - registry = {}, - //registry of just enabled modules, to speed - //cycle breaking code when lots of modules - //are registered, but not activated. - enabledRegistry = {}, - undefEvents = {}, - defQueue = [], - defined = {}, - urlFetched = {}, - bundlesMap = {}, - requireCounter = 1, - unnormalizedCounter = 1; - - /** - * Trims the . and .. from an array of path segments. - * It will keep a leading path segment if a .. will become - * the first path segment, to help with module name lookups, - * which act like paths, but can be remapped. But the end result, - * all paths that use this function should look normalized. - * NOTE: this method MODIFIES the input array. - * @param {Array} ary the array of path segments. - */ - function trimDots(ary) { - var i, part; - for (i = 0; i < ary.length; i++) { - part = ary[i]; - if (part === '.') { - ary.splice(i, 1); - i -= 1; - } else if (part === '..') { - // If at the start, or previous value is still .., - // keep them so that when converted to a path it may - // still work when converted to a path, even though - // as an ID it is less than ideal. In larger point - // releases, may be better to just kick out an error. - if (i === 0 || (i === 1 && ary[2] === '..') || ary[i - 1] === '..') { - continue; - } else if (i > 0) { - ary.splice(i - 1, 2); - i -= 2; - } - } - } - } - - /** - * Given a relative module name, like ./something, normalize it to - * a real name that can be mapped to a path. - * @param {String} name the relative name - * @param {String} baseName a real name that the name arg is relative - * to. - * @param {Boolean} applyMap apply the map config to the value. Should - * only be done if this normalization is for a dependency ID. - * @returns {String} normalized name - */ - function normalize(name, baseName, applyMap) { - var pkgMain, mapValue, nameParts, i, j, nameSegment, lastIndex, - foundMap, foundI, foundStarMap, starI, normalizedBaseParts, - baseParts = (baseName && baseName.split('/')), - map = config.map, - starMap = map && map['*']; - - //Adjust any relative paths. - if (name) { - name = name.split('/'); - lastIndex = name.length - 1; - - // If wanting node ID compatibility, strip .js from end - // of IDs. Have to do this here, and not in nameToUrl - // because node allows either .js or non .js to map - // to same file. - if (config.nodeIdCompat && jsSuffixRegExp.test(name[lastIndex])) { - name[lastIndex] = name[lastIndex].replace(jsSuffixRegExp, ''); - } - - // Starts with a '.' so need the baseName - if (name[0].charAt(0) === '.' && baseParts) { - //Convert baseName to array, and lop off the last part, - //so that . matches that 'directory' and not name of the baseName's - //module. For instance, baseName of 'one/two/three', maps to - //'one/two/three.js', but we want the directory, 'one/two' for - //this normalization. - normalizedBaseParts = baseParts.slice(0, baseParts.length - 1); - name = normalizedBaseParts.concat(name); - } - - trimDots(name); - name = name.join('/'); - } - - //Apply map config if available. - if (applyMap && map && (baseParts || starMap)) { - nameParts = name.split('/'); - - outerLoop: for (i = nameParts.length; i > 0; i -= 1) { - nameSegment = nameParts.slice(0, i).join('/'); - - if (baseParts) { - //Find the longest baseName segment match in the config. - //So, do joins on the biggest to smallest lengths of baseParts. - for (j = baseParts.length; j > 0; j -= 1) { - mapValue = getOwn(map, baseParts.slice(0, j).join('/')); - - //baseName segment has config, find if it has one for - //this name. - if (mapValue) { - mapValue = getOwn(mapValue, nameSegment); - if (mapValue) { - //Match, update name to the new value. - foundMap = mapValue; - foundI = i; - break outerLoop; - } - } - } - } - - //Check for a star map match, but just hold on to it, - //if there is a shorter segment match later in a matching - //config, then favor over this star map. - if (!foundStarMap && starMap && getOwn(starMap, nameSegment)) { - foundStarMap = getOwn(starMap, nameSegment); - starI = i; - } - } - - if (!foundMap && foundStarMap) { - foundMap = foundStarMap; - foundI = starI; - } - - if (foundMap) { - nameParts.splice(0, foundI, foundMap); - name = nameParts.join('/'); - } - } - - // If the name points to a package's name, use - // the package main instead. - pkgMain = getOwn(config.pkgs, name); - - return pkgMain ? pkgMain : name; - } - - function removeScript(name) { - if (isBrowser) { - each(scripts(), function (scriptNode) { - if (scriptNode.getAttribute('data-requiremodule') === name && - scriptNode.getAttribute('data-requirecontext') === context.contextName) { - scriptNode.parentNode.removeChild(scriptNode); - return true; - } - }); - } - } - - function hasPathFallback(id) { - var pathConfig = getOwn(config.paths, id); - if (pathConfig && isArray(pathConfig) && pathConfig.length > 1) { - //Pop off the first array value, since it failed, and - //retry - pathConfig.shift(); - context.require.undef(id); - - //Custom require that does not do map translation, since - //ID is "absolute", already mapped/resolved. - context.makeRequire(null, { - skipMap: true - })([id]); - - return true; - } - } - - //Turns a plugin!resource to [plugin, resource] - //with the plugin being undefined if the name - //did not have a plugin prefix. - function splitPrefix(name) { - var prefix, - index = name ? name.indexOf('!') : -1; - if (index > -1) { - prefix = name.substring(0, index); - name = name.substring(index + 1, name.length); - } - return [prefix, name]; - } - - /** - * Creates a module mapping that includes plugin prefix, module - * name, and path. If parentModuleMap is provided it will - * also normalize the name via require.normalize() - * - * @param {String} name the module name - * @param {String} [parentModuleMap] parent module map - * for the module name, used to resolve relative names. - * @param {Boolean} isNormalized: is the ID already normalized. - * This is true if this call is done for a define() module ID. - * @param {Boolean} applyMap: apply the map config to the ID. - * Should only be true if this map is for a dependency. - * - * @returns {Object} - */ - function makeModuleMap(name, parentModuleMap, isNormalized, applyMap) { - var url, pluginModule, suffix, nameParts, - prefix = null, - parentName = parentModuleMap ? parentModuleMap.name : null, - originalName = name, - isDefine = true, - normalizedName = ''; - - //If no name, then it means it is a require call, generate an - //internal name. - if (!name) { - isDefine = false; - name = '_@r' + (requireCounter += 1); - } - - nameParts = splitPrefix(name); - prefix = nameParts[0]; - name = nameParts[1]; - - if (prefix) { - prefix = normalize(prefix, parentName, applyMap); - pluginModule = getOwn(defined, prefix); - } - - //Account for relative paths if there is a base name. - if (name) { - if (prefix) { - if (pluginModule && pluginModule.normalize) { - //Plugin is loaded, use its normalize method. - normalizedName = pluginModule.normalize(name, function (name) { - return normalize(name, parentName, applyMap); - }); - } else { - // If nested plugin references, then do not try to - // normalize, as it will not normalize correctly. This - // places a restriction on resourceIds, and the longer - // term solution is not to normalize until plugins are - // loaded and all normalizations to allow for async - // loading of a loader plugin. But for now, fixes the - // common uses. Details in #1131 - normalizedName = name.indexOf('!') === -1 ? - normalize(name, parentName, applyMap) : - name; - } - } else { - //A regular module. - normalizedName = normalize(name, parentName, applyMap); - - //Normalized name may be a plugin ID due to map config - //application in normalize. The map config values must - //already be normalized, so do not need to redo that part. - nameParts = splitPrefix(normalizedName); - prefix = nameParts[0]; - normalizedName = nameParts[1]; - isNormalized = true; - - url = context.nameToUrl(normalizedName); - } - } - - //If the id is a plugin id that cannot be determined if it needs - //normalization, stamp it with a unique ID so two matching relative - //ids that may conflict can be separate. - suffix = prefix && !pluginModule && !isNormalized ? - '_unnormalized' + (unnormalizedCounter += 1) : - ''; - - return { - prefix: prefix, - name: normalizedName, - parentMap: parentModuleMap, - unnormalized: !!suffix, - url: url, - originalName: originalName, - isDefine: isDefine, - id: (prefix ? - prefix + '!' + normalizedName : - normalizedName) + suffix - }; - } - - function getModule(depMap) { - var id = depMap.id, - mod = getOwn(registry, id); - - if (!mod) { - mod = registry[id] = new context.Module(depMap); - } - - return mod; - } - - function on(depMap, name, fn) { - var id = depMap.id, - mod = getOwn(registry, id); - - if (hasProp(defined, id) && - (!mod || mod.defineEmitComplete)) { - if (name === 'defined') { - fn(defined[id]); - } - } else { - mod = getModule(depMap); - if (mod.error && name === 'error') { - fn(mod.error); - } else { - mod.on(name, fn); - } - } - } - - function onError(err, errback) { - var ids = err.requireModules, - notified = false; - - if (errback) { - errback(err); - } else { - each(ids, function (id) { - var mod = getOwn(registry, id); - if (mod) { - //Set error on module, so it skips timeout checks. - mod.error = err; - if (mod.events.error) { - notified = true; - mod.emit('error', err); - } - } - }); - - if (!notified) { - req.onError(err); - } - } - } - - /** - * Internal method to transfer globalQueue items to this context's - * defQueue. - */ - function takeGlobalQueue() { - //Push all the globalDefQueue items into the context's defQueue - if (globalDefQueue.length) { - each(globalDefQueue, function(queueItem) { - var id = queueItem[0]; - if (typeof id === 'string') { - context.defQueueMap[id] = true; - } - defQueue.push(queueItem); - }); - globalDefQueue = []; - } - } - - handlers = { - 'require': function (mod) { - if (mod.require) { - return mod.require; - } else { - return (mod.require = context.makeRequire(mod.map)); - } - }, - 'exports': function (mod) { - mod.usingExports = true; - if (mod.map.isDefine) { - if (mod.exports) { - return (defined[mod.map.id] = mod.exports); - } else { - return (mod.exports = defined[mod.map.id] = {}); - } - } - }, - 'module': function (mod) { - if (mod.module) { - return mod.module; - } else { - return (mod.module = { - id: mod.map.id, - uri: mod.map.url, - config: function () { - return getOwn(config.config, mod.map.id) || {}; - }, - exports: mod.exports || (mod.exports = {}) - }); - } - } - }; - - function cleanRegistry(id) { - //Clean up machinery used for waiting modules. - delete registry[id]; - delete enabledRegistry[id]; - } - - function breakCycle(mod, traced, processed) { - var id = mod.map.id; - - if (mod.error) { - mod.emit('error', mod.error); - } else { - traced[id] = true; - each(mod.depMaps, function (depMap, i) { - var depId = depMap.id, - dep = getOwn(registry, depId); - - //Only force things that have not completed - //being defined, so still in the registry, - //and only if it has not been matched up - //in the module already. - if (dep && !mod.depMatched[i] && !processed[depId]) { - if (getOwn(traced, depId)) { - mod.defineDep(i, defined[depId]); - mod.check(); //pass false? - } else { - breakCycle(dep, traced, processed); - } - } - }); - processed[id] = true; - } - } - - function checkLoaded() { - var err, usingPathFallback, - waitInterval = config.waitSeconds * 1000, - //It is possible to disable the wait interval by using waitSeconds of 0. - expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(), - noLoads = [], - reqCalls = [], - stillLoading = false, - needCycleCheck = true; - - //Do not bother if this call was a result of a cycle break. - if (inCheckLoaded) { - return; - } - - inCheckLoaded = true; - - //Figure out the state of all the modules. - eachProp(enabledRegistry, function (mod) { - var map = mod.map, - modId = map.id; - - //Skip things that are not enabled or in error state. - if (!mod.enabled) { - return; - } - - if (!map.isDefine) { - reqCalls.push(mod); - } - - if (!mod.error) { - //If the module should be executed, and it has not - //been inited and time is up, remember it. - if (!mod.inited && expired) { - if (hasPathFallback(modId)) { - usingPathFallback = true; - stillLoading = true; - } else { - noLoads.push(modId); - removeScript(modId); - } - } else if (!mod.inited && mod.fetched && map.isDefine) { - stillLoading = true; - if (!map.prefix) { - //No reason to keep looking for unfinished - //loading. If the only stillLoading is a - //plugin resource though, keep going, - //because it may be that a plugin resource - //is waiting on a non-plugin cycle. - return (needCycleCheck = false); - } - } - } - }); - - if (expired && noLoads.length) { - //If wait time expired, throw error of unloaded modules. - err = makeError('timeout', 'Load timeout for modules: ' + noLoads, null, noLoads); - err.contextName = context.contextName; - return onError(err); - } - - //Not expired, check for a cycle. - if (needCycleCheck) { - each(reqCalls, function (mod) { - breakCycle(mod, {}, {}); - }); - } - - //If still waiting on loads, and the waiting load is something - //other than a plugin resource, or there are still outstanding - //scripts, then just try back later. - if ((!expired || usingPathFallback) && stillLoading) { - //Something is still waiting to load. Wait for it, but only - //if a timeout is not already in effect. - if ((isBrowser || isWebWorker) && !checkLoadedTimeoutId) { - checkLoadedTimeoutId = setTimeout(function () { - checkLoadedTimeoutId = 0; - checkLoaded(); - }, 50); - } - } - - inCheckLoaded = false; - } - - Module = function (map) { - this.events = getOwn(undefEvents, map.id) || {}; - this.map = map; - this.shim = getOwn(config.shim, map.id); - this.depExports = []; - this.depMaps = []; - this.depMatched = []; - this.pluginMaps = {}; - this.depCount = 0; - - /* this.exports this.factory - this.depMaps = [], - this.enabled, this.fetched - */ - }; - - Module.prototype = { - init: function (depMaps, factory, errback, options) { - options = options || {}; - - //Do not do more inits if already done. Can happen if there - //are multiple define calls for the same module. That is not - //a normal, common case, but it is also not unexpected. - if (this.inited) { - return; - } - - this.factory = factory; - - if (errback) { - //Register for errors on this module. - this.on('error', errback); - } else if (this.events.error) { - //If no errback already, but there are error listeners - //on this module, set up an errback to pass to the deps. - errback = bind(this, function (err) { - this.emit('error', err); - }); - } - - //Do a copy of the dependency array, so that - //source inputs are not modified. For example - //"shim" deps are passed in here directly, and - //doing a direct modification of the depMaps array - //would affect that config. - this.depMaps = depMaps && depMaps.slice(0); - - this.errback = errback; - - //Indicate this module has be initialized - this.inited = true; - - this.ignore = options.ignore; - - //Could have option to init this module in enabled mode, - //or could have been previously marked as enabled. However, - //the dependencies are not known until init is called. So - //if enabled previously, now trigger dependencies as enabled. - if (options.enabled || this.enabled) { - //Enable this module and dependencies. - //Will call this.check() - this.enable(); - } else { - this.check(); - } - }, - - defineDep: function (i, depExports) { - //Because of cycles, defined callback for a given - //export can be called more than once. - if (!this.depMatched[i]) { - this.depMatched[i] = true; - this.depCount -= 1; - this.depExports[i] = depExports; - } - }, - - fetch: function () { - if (this.fetched) { - return; - } - this.fetched = true; - - context.startTime = (new Date()).getTime(); - - var map = this.map; - - //If the manager is for a plugin managed resource, - //ask the plugin to load it now. - if (this.shim) { - context.makeRequire(this.map, { - enableBuildCallback: true - })(this.shim.deps || [], bind(this, function () { - return map.prefix ? this.callPlugin() : this.load(); - })); - } else { - //Regular dependency. - return map.prefix ? this.callPlugin() : this.load(); - } - }, - - load: function () { - var url = this.map.url; - - //Regular dependency. - if (!urlFetched[url]) { - urlFetched[url] = true; - context.load(this.map.id, url); - } - }, - - /** - * Checks if the module is ready to define itself, and if so, - * define it. - */ - check: function () { - if (!this.enabled || this.enabling) { - return; - } - - var err, cjsModule, - id = this.map.id, - depExports = this.depExports, - exports = this.exports, - factory = this.factory; - - if (!this.inited) { - // Only fetch if not already in the defQueue. - if (!hasProp(context.defQueueMap, id)) { - this.fetch(); - } - } else if (this.error) { - this.emit('error', this.error); - } else if (!this.defining) { - //The factory could trigger another require call - //that would result in checking this module to - //define itself again. If already in the process - //of doing that, skip this work. - this.defining = true; - - if (this.depCount < 1 && !this.defined) { - if (isFunction(factory)) { - //If there is an error listener, favor passing - //to that instead of throwing an error. However, - //only do it for define()'d modules. require - //errbacks should not be called for failures in - //their callbacks (#699). However if a global - //onError is set, use that. - if ((this.events.error && this.map.isDefine) || - req.onError !== defaultOnError) { - try { - exports = context.execCb(id, factory, depExports, exports); - } catch (e) { - err = e; - } - } else { - exports = context.execCb(id, factory, depExports, exports); - } - - // Favor return value over exports. If node/cjs in play, - // then will not have a return value anyway. Favor - // module.exports assignment over exports object. - if (this.map.isDefine && exports === undefined) { - cjsModule = this.module; - if (cjsModule) { - exports = cjsModule.exports; - } else if (this.usingExports) { - //exports already set the defined value. - exports = this.exports; - } - } - - if (err) { - err.requireMap = this.map; - err.requireModules = this.map.isDefine ? [this.map.id] : null; - err.requireType = this.map.isDefine ? 'define' : 'require'; - return onError((this.error = err)); - } - - } else { - //Just a literal value - exports = factory; - } - - this.exports = exports; - - if (this.map.isDefine && !this.ignore) { - defined[id] = exports; - - if (req.onResourceLoad) { - var resLoadMaps = []; - each(this.depMaps, function (depMap) { - resLoadMaps.push(depMap.normalizedMap || depMap); - }); - req.onResourceLoad(context, this.map, resLoadMaps); - } - } - - //Clean up - cleanRegistry(id); - - this.defined = true; - } - - //Finished the define stage. Allow calling check again - //to allow define notifications below in the case of a - //cycle. - this.defining = false; - - if (this.defined && !this.defineEmitted) { - this.defineEmitted = true; - this.emit('defined', this.exports); - this.defineEmitComplete = true; - } - - } - }, - - callPlugin: function () { - var map = this.map, - id = map.id, - //Map already normalized the prefix. - pluginMap = makeModuleMap(map.prefix); - - //Mark this as a dependency for this plugin, so it - //can be traced for cycles. - this.depMaps.push(pluginMap); - - on(pluginMap, 'defined', bind(this, function (plugin) { - var load, normalizedMap, normalizedMod, - bundleId = getOwn(bundlesMap, this.map.id), - name = this.map.name, - parentName = this.map.parentMap ? this.map.parentMap.name : null, - localRequire = context.makeRequire(map.parentMap, { - enableBuildCallback: true - }); - - //If current map is not normalized, wait for that - //normalized name to load instead of continuing. - if (this.map.unnormalized) { - //Normalize the ID if the plugin allows it. - if (plugin.normalize) { - name = plugin.normalize(name, function (name) { - return normalize(name, parentName, true); - }) || ''; - } - - //prefix and name should already be normalized, no need - //for applying map config again either. - normalizedMap = makeModuleMap(map.prefix + '!' + name, - this.map.parentMap); - on(normalizedMap, - 'defined', bind(this, function (value) { - this.map.normalizedMap = normalizedMap; - this.init([], function () { return value; }, null, { - enabled: true, - ignore: true - }); - })); - - normalizedMod = getOwn(registry, normalizedMap.id); - if (normalizedMod) { - //Mark this as a dependency for this plugin, so it - //can be traced for cycles. - this.depMaps.push(normalizedMap); - - if (this.events.error) { - normalizedMod.on('error', bind(this, function (err) { - this.emit('error', err); - })); - } - normalizedMod.enable(); - } - - return; - } - - //If a paths config, then just load that file instead to - //resolve the plugin, as it is built into that paths layer. - if (bundleId) { - this.map.url = context.nameToUrl(bundleId); - this.load(); - return; - } - - load = bind(this, function (value) { - this.init([], function () { return value; }, null, { - enabled: true - }); - }); - - load.error = bind(this, function (err) { - this.inited = true; - this.error = err; - err.requireModules = [id]; - - //Remove temp unnormalized modules for this module, - //since they will never be resolved otherwise now. - eachProp(registry, function (mod) { - if (mod.map.id.indexOf(id + '_unnormalized') === 0) { - cleanRegistry(mod.map.id); - } - }); - - onError(err); - }); - - //Allow plugins to load other code without having to know the - //context or how to 'complete' the load. - load.fromText = bind(this, function (text, textAlt) { - /*jslint evil: true */ - var moduleName = map.name, - moduleMap = makeModuleMap(moduleName), - hasInteractive = useInteractive; - - //As of 2.1.0, support just passing the text, to reinforce - //fromText only being called once per resource. Still - //support old style of passing moduleName but discard - //that moduleName in favor of the internal ref. - if (textAlt) { - text = textAlt; - } - - //Turn off interactive script matching for IE for any define - //calls in the text, then turn it back on at the end. - if (hasInteractive) { - useInteractive = false; - } - - //Prime the system by creating a module instance for - //it. - getModule(moduleMap); - - //Transfer any config to this other module. - if (hasProp(config.config, id)) { - config.config[moduleName] = config.config[id]; - } - - try { - req.exec(text); - } catch (e) { - return onError(makeError('fromtexteval', - 'fromText eval for ' + id + - ' failed: ' + e, - e, - [id])); - } - - if (hasInteractive) { - useInteractive = true; - } - - //Mark this as a dependency for the plugin - //resource - this.depMaps.push(moduleMap); - - //Support anonymous modules. - context.completeLoad(moduleName); - - //Bind the value of that module to the value for this - //resource ID. - localRequire([moduleName], load); - }); - - //Use parentName here since the plugin's name is not reliable, - //could be some weird string with no path that actually wants to - //reference the parentName's path. - plugin.load(map.name, localRequire, load, config); - })); - - context.enable(pluginMap, this); - this.pluginMaps[pluginMap.id] = pluginMap; - }, - - enable: function () { - enabledRegistry[this.map.id] = this; - this.enabled = true; - - //Set flag mentioning that the module is enabling, - //so that immediate calls to the defined callbacks - //for dependencies do not trigger inadvertent load - //with the depCount still being zero. - this.enabling = true; - - //Enable each dependency - each(this.depMaps, bind(this, function (depMap, i) { - var id, mod, handler; - - if (typeof depMap === 'string') { - //Dependency needs to be converted to a depMap - //and wired up to this module. - depMap = makeModuleMap(depMap, - (this.map.isDefine ? this.map : this.map.parentMap), - false, - !this.skipMap); - this.depMaps[i] = depMap; - - handler = getOwn(handlers, depMap.id); - - if (handler) { - this.depExports[i] = handler(this); - return; - } - - this.depCount += 1; - - on(depMap, 'defined', bind(this, function (depExports) { - if (this.undefed) { - return; - } - this.defineDep(i, depExports); - this.check(); - })); - - if (this.errback) { - on(depMap, 'error', bind(this, this.errback)); - } else if (this.events.error) { - // No direct errback on this module, but something - // else is listening for errors, so be sure to - // propagate the error correctly. - on(depMap, 'error', bind(this, function(err) { - this.emit('error', err); - })); - } - } - - id = depMap.id; - mod = registry[id]; - - //Skip special modules like 'require', 'exports', 'module' - //Also, don't call enable if it is already enabled, - //important in circular dependency cases. - if (!hasProp(handlers, id) && mod && !mod.enabled) { - context.enable(depMap, this); - } - })); - - //Enable each plugin that is used in - //a dependency - eachProp(this.pluginMaps, bind(this, function (pluginMap) { - var mod = getOwn(registry, pluginMap.id); - if (mod && !mod.enabled) { - context.enable(pluginMap, this); - } - })); - - this.enabling = false; - - this.check(); - }, - - on: function (name, cb) { - var cbs = this.events[name]; - if (!cbs) { - cbs = this.events[name] = []; - } - cbs.push(cb); - }, - - emit: function (name, evt) { - each(this.events[name], function (cb) { - cb(evt); - }); - if (name === 'error') { - //Now that the error handler was triggered, remove - //the listeners, since this broken Module instance - //can stay around for a while in the registry. - delete this.events[name]; - } - } - }; - - function callGetModule(args) { - //Skip modules already defined. - if (!hasProp(defined, args[0])) { - getModule(makeModuleMap(args[0], null, true)).init(args[1], args[2]); - } - } - - function removeListener(node, func, name, ieName) { - //Favor detachEvent because of IE9 - //issue, see attachEvent/addEventListener comment elsewhere - //in this file. - if (node.detachEvent && !isOpera) { - //Probably IE. If not it will throw an error, which will be - //useful to know. - if (ieName) { - node.detachEvent(ieName, func); - } - } else { - node.removeEventListener(name, func, false); - } - } - - /** - * Given an event from a script node, get the requirejs info from it, - * and then removes the event listeners on the node. - * @param {Event} evt - * @returns {Object} - */ - function getScriptData(evt) { - //Using currentTarget instead of target for Firefox 2.0's sake. Not - //all old browsers will be supported, but this one was easy enough - //to support and still makes sense. - var node = evt.currentTarget || evt.srcElement; - - //Remove the listeners once here. - removeListener(node, context.onScriptLoad, 'load', 'onreadystatechange'); - removeListener(node, context.onScriptError, 'error'); - - return { - node: node, - id: node && node.getAttribute('data-requiremodule') - }; - } - - function intakeDefines() { - var args; - - //Any defined modules in the global queue, intake them now. - takeGlobalQueue(); - - //Make sure any remaining defQueue items get properly processed. - while (defQueue.length) { - args = defQueue.shift(); - if (args[0] === null) { - return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' + - args[args.length - 1])); - } else { - //args are id, deps, factory. Should be normalized by the - //define() function. - callGetModule(args); - } - } - context.defQueueMap = {}; - } - - context = { - config: config, - contextName: contextName, - registry: registry, - defined: defined, - urlFetched: urlFetched, - defQueue: defQueue, - defQueueMap: {}, - Module: Module, - makeModuleMap: makeModuleMap, - nextTick: req.nextTick, - onError: onError, - - /** - * Set a configuration for the context. - * @param {Object} cfg config object to integrate. - */ - configure: function (cfg) { - //Make sure the baseUrl ends in a slash. - if (cfg.baseUrl) { - if (cfg.baseUrl.charAt(cfg.baseUrl.length - 1) !== '/') { - cfg.baseUrl += '/'; - } - } - - // Convert old style urlArgs string to a function. - if (typeof cfg.urlArgs === 'string') { - var urlArgs = cfg.urlArgs; - cfg.urlArgs = function(id, url) { - return (url.indexOf('?') === -1 ? '?' : '&') + urlArgs; - }; - } - - //Save off the paths since they require special processing, - //they are additive. - var shim = config.shim, - objs = { - paths: true, - bundles: true, - config: true, - map: true - }; - - eachProp(cfg, function (value, prop) { - if (objs[prop]) { - if (!config[prop]) { - config[prop] = {}; - } - mixin(config[prop], value, true, true); - } else { - config[prop] = value; - } - }); - - //Reverse map the bundles - if (cfg.bundles) { - eachProp(cfg.bundles, function (value, prop) { - each(value, function (v) { - if (v !== prop) { - bundlesMap[v] = prop; - } - }); - }); - } - - //Merge shim - if (cfg.shim) { - eachProp(cfg.shim, function (value, id) { - //Normalize the structure - if (isArray(value)) { - value = { - deps: value - }; - } - if ((value.exports || value.init) && !value.exportsFn) { - value.exportsFn = context.makeShimExports(value); - } - shim[id] = value; - }); - config.shim = shim; - } - - //Adjust packages if necessary. - if (cfg.packages) { - each(cfg.packages, function (pkgObj) { - var location, name; - - pkgObj = typeof pkgObj === 'string' ? {name: pkgObj} : pkgObj; - - name = pkgObj.name; - location = pkgObj.location; - if (location) { - config.paths[name] = pkgObj.location; - } - - //Save pointer to main module ID for pkg name. - //Remove leading dot in main, so main paths are normalized, - //and remove any trailing .js, since different package - //envs have different conventions: some use a module name, - //some use a file name. - config.pkgs[name] = pkgObj.name + '/' + (pkgObj.main || 'main') - .replace(currDirRegExp, '') - .replace(jsSuffixRegExp, ''); - }); - } - - //If there are any "waiting to execute" modules in the registry, - //update the maps for them, since their info, like URLs to load, - //may have changed. - eachProp(registry, function (mod, id) { - //If module already has init called, since it is too - //late to modify them, and ignore unnormalized ones - //since they are transient. - if (!mod.inited && !mod.map.unnormalized) { - mod.map = makeModuleMap(id, null, true); - } - }); - - //If a deps array or a config callback is specified, then call - //require with those args. This is useful when require is defined as a - //config object before require.js is loaded. - if (cfg.deps || cfg.callback) { - context.require(cfg.deps || [], cfg.callback); - } - }, - - makeShimExports: function (value) { - function fn() { - var ret; - if (value.init) { - ret = value.init.apply(global, arguments); - } - return ret || (value.exports && getGlobal(value.exports)); - } - return fn; - }, - - makeRequire: function (relMap, options) { - options = options || {}; - - function localRequire(deps, callback, errback) { - var id, map, requireMod; - - if (options.enableBuildCallback && callback && isFunction(callback)) { - callback.__requireJsBuild = true; - } - - if (typeof deps === 'string') { - if (isFunction(callback)) { - //Invalid call - return onError(makeError('requireargs', 'Invalid require call'), errback); - } - - //If require|exports|module are requested, get the - //value for them from the special handlers. Caveat: - //this only works while module is being defined. - if (relMap && hasProp(handlers, deps)) { - return handlers[deps](registry[relMap.id]); - } - - //Synchronous access to one module. If require.get is - //available (as in the Node adapter), prefer that. - if (req.get) { - return req.get(context, deps, relMap, localRequire); - } - - //Normalize module name, if it contains . or .. - map = makeModuleMap(deps, relMap, false, true); - id = map.id; - - if (!hasProp(defined, id)) { - return onError(makeError('notloaded', 'Module name "' + - id + - '" has not been loaded yet for context: ' + - contextName + - (relMap ? '' : '. Use require([])'))); - } - return defined[id]; - } - - //Grab defines waiting in the global queue. - intakeDefines(); - - //Mark all the dependencies as needing to be loaded. - context.nextTick(function () { - //Some defines could have been added since the - //require call, collect them. - intakeDefines(); - - requireMod = getModule(makeModuleMap(null, relMap)); - - //Store if map config should be applied to this require - //call for dependencies. - requireMod.skipMap = options.skipMap; - - requireMod.init(deps, callback, errback, { - enabled: true - }); - - checkLoaded(); - }); - - return localRequire; - } - - mixin(localRequire, { - isBrowser: isBrowser, - - /** - * Converts a module name + .extension into an URL path. - * *Requires* the use of a module name. It does not support using - * plain URLs like nameToUrl. - */ - toUrl: function (moduleNamePlusExt) { - var ext, - index = moduleNamePlusExt.lastIndexOf('.'), - segment = moduleNamePlusExt.split('/')[0], - isRelative = segment === '.' || segment === '..'; - - //Have a file extension alias, and it is not the - //dots from a relative path. - if (index !== -1 && (!isRelative || index > 1)) { - ext = moduleNamePlusExt.substring(index, moduleNamePlusExt.length); - moduleNamePlusExt = moduleNamePlusExt.substring(0, index); - } - - return context.nameToUrl(normalize(moduleNamePlusExt, - relMap && relMap.id, true), ext, true); - }, - - defined: function (id) { - return hasProp(defined, makeModuleMap(id, relMap, false, true).id); - }, - - specified: function (id) { - id = makeModuleMap(id, relMap, false, true).id; - return hasProp(defined, id) || hasProp(registry, id); - } - }); - - //Only allow undef on top level require calls - if (!relMap) { - localRequire.undef = function (id) { - //Bind any waiting define() calls to this context, - //fix for #408 - takeGlobalQueue(); - - var map = makeModuleMap(id, relMap, true), - mod = getOwn(registry, id); - - mod.undefed = true; - removeScript(id); - - delete defined[id]; - delete urlFetched[map.url]; - delete undefEvents[id]; - - //Clean queued defines too. Go backwards - //in array so that the splices do not - //mess up the iteration. - eachReverse(defQueue, function(args, i) { - if (args[0] === id) { - defQueue.splice(i, 1); - } - }); - delete context.defQueueMap[id]; - - if (mod) { - //Hold on to listeners in case the - //module will be attempted to be reloaded - //using a different config. - if (mod.events.defined) { - undefEvents[id] = mod.events; - } - - cleanRegistry(id); - } - }; - } - - return localRequire; - }, - - /** - * Called to enable a module if it is still in the registry - * awaiting enablement. A second arg, parent, the parent module, - * is passed in for context, when this method is overridden by - * the optimizer. Not shown here to keep code compact. - */ - enable: function (depMap) { - var mod = getOwn(registry, depMap.id); - if (mod) { - getModule(depMap).enable(); - } - }, - - /** - * Internal method used by environment adapters to complete a load event. - * A load event could be a script load or just a load pass from a synchronous - * load call. - * @param {String} moduleName the name of the module to potentially complete. - */ - completeLoad: function (moduleName) { - var found, args, mod, - shim = getOwn(config.shim, moduleName) || {}, - shExports = shim.exports; - - takeGlobalQueue(); - - while (defQueue.length) { - args = defQueue.shift(); - if (args[0] === null) { - args[0] = moduleName; - //If already found an anonymous module and bound it - //to this name, then this is some other anon module - //waiting for its completeLoad to fire. - if (found) { - break; - } - found = true; - } else if (args[0] === moduleName) { - //Found matching define call for this script! - found = true; - } - - callGetModule(args); - } - context.defQueueMap = {}; - - //Do this after the cycle of callGetModule in case the result - //of those calls/init calls changes the registry. - mod = getOwn(registry, moduleName); - - if (!found && !hasProp(defined, moduleName) && mod && !mod.inited) { - if (config.enforceDefine && (!shExports || !getGlobal(shExports))) { - if (hasPathFallback(moduleName)) { - return; - } else { - return onError(makeError('nodefine', - 'No define call for ' + moduleName, - null, - [moduleName])); - } - } else { - //A script that does not call define(), so just simulate - //the call for it. - callGetModule([moduleName, (shim.deps || []), shim.exportsFn]); - } - } - - checkLoaded(); - }, - - /** - * Converts a module name to a file path. Supports cases where - * moduleName may actually be just an URL. - * Note that it **does not** call normalize on the moduleName, - * it is assumed to have already been normalized. This is an - * internal API, not a public one. Use toUrl for the public API. - */ - nameToUrl: function (moduleName, ext, skipExt) { - var paths, syms, i, parentModule, url, - parentPath, bundleId, - pkgMain = getOwn(config.pkgs, moduleName); - - if (pkgMain) { - moduleName = pkgMain; - } - - bundleId = getOwn(bundlesMap, moduleName); - - if (bundleId) { - return context.nameToUrl(bundleId, ext, skipExt); - } - - //If a colon is in the URL, it indicates a protocol is used and it is just - //an URL to a file, or if it starts with a slash, contains a query arg (i.e. ?) - //or ends with .js, then assume the user meant to use an url and not a module id. - //The slash is important for protocol-less URLs as well as full paths. - if (req.jsExtRegExp.test(moduleName)) { - //Just a plain path, not module name lookup, so just return it. - //Add extension if it is included. This is a bit wonky, only non-.js things pass - //an extension, this method probably needs to be reworked. - url = moduleName + (ext || ''); - } else { - //A module that needs to be converted to a path. - paths = config.paths; - - syms = moduleName.split('/'); - //For each module name segment, see if there is a path - //registered for it. Start with most specific name - //and work up from it. - for (i = syms.length; i > 0; i -= 1) { - parentModule = syms.slice(0, i).join('/'); - - parentPath = getOwn(paths, parentModule); - if (parentPath) { - //If an array, it means there are a few choices, - //Choose the one that is desired - if (isArray(parentPath)) { - parentPath = parentPath[0]; - } - syms.splice(0, i, parentPath); - break; - } - } - - //Join the path parts together, then figure out if baseUrl is needed. - url = syms.join('/'); - url += (ext || (/^data\:|^blob\:|\?/.test(url) || skipExt ? '' : '.js')); - url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url; - } - - return config.urlArgs && !/^blob\:/.test(url) ? - url + config.urlArgs(moduleName, url) : url; - }, - - //Delegates to req.load. Broken out as a separate function to - //allow overriding in the optimizer. - load: function (id, url) { - req.load(context, id, url); - }, - - /** - * Executes a module callback function. Broken out as a separate function - * solely to allow the build system to sequence the files in the built - * layer in the right sequence. - * - * @private - */ - execCb: function (name, callback, args, exports) { - return callback.apply(exports, args); - }, - - /** - * callback for script loads, used to check status of loading. - * - * @param {Event} evt the event from the browser for the script - * that was loaded. - */ - onScriptLoad: function (evt) { - //Using currentTarget instead of target for Firefox 2.0's sake. Not - //all old browsers will be supported, but this one was easy enough - //to support and still makes sense. - if (evt.type === 'load' || - (readyRegExp.test((evt.currentTarget || evt.srcElement).readyState))) { - //Reset interactive script so a script node is not held onto for - //to long. - interactiveScript = null; - - //Pull out the name of the module and the context. - var data = getScriptData(evt); - context.completeLoad(data.id); - } - }, - - /** - * Callback for script errors. - */ - onScriptError: function (evt) { - var data = getScriptData(evt); - if (!hasPathFallback(data.id)) { - var parents = []; - eachProp(registry, function(value, key) { - if (key.indexOf('_@r') !== 0) { - each(value.depMaps, function(depMap) { - if (depMap.id === data.id) { - parents.push(key); - return true; - } - }); - } - }); - return onError(makeError('scripterror', 'Script error for "' + data.id + - (parents.length ? - '", needed by: ' + parents.join(', ') : - '"'), evt, [data.id])); - } - } - }; - - context.require = context.makeRequire(); - return context; - } - - /** - * Main entry point. - * - * If the only argument to require is a string, then the module that - * is represented by that string is fetched for the appropriate context. - * - * If the first argument is an array, then it will be treated as an array - * of dependency string names to fetch. An optional function callback can - * be specified to execute when all of those dependencies are available. - * - * Make a local req variable to help Caja compliance (it assumes things - * on a require that are not standardized), and to give a short - * name for minification/local scope use. - */ - req = requirejs = function (deps, callback, errback, optional) { - - //Find the right context, use default - var context, config, - contextName = defContextName; - - // Determine if have config object in the call. - if (!isArray(deps) && typeof deps !== 'string') { - // deps is a config object - config = deps; - if (isArray(callback)) { - // Adjust args if there are dependencies - deps = callback; - callback = errback; - errback = optional; - } else { - deps = []; - } - } - - if (config && config.context) { - contextName = config.context; - } - - context = getOwn(contexts, contextName); - if (!context) { - context = contexts[contextName] = req.s.newContext(contextName); - } - - if (config) { - context.configure(config); - } - - return context.require(deps, callback, errback); - }; - - /** - * Support require.config() to make it easier to cooperate with other - * AMD loaders on globally agreed names. - */ - req.config = function (config) { - return req(config); - }; - - /** - * Execute something after the current tick - * of the event loop. Override for other envs - * that have a better solution than setTimeout. - * @param {Function} fn function to execute later. - */ - req.nextTick = typeof setTimeout !== 'undefined' ? function (fn) { - setTimeout(fn, 4); - } : function (fn) { fn(); }; - - /** - * Export require as a global, but only if it does not already exist. - */ - if (!require) { - require = req; - } - - req.version = version; - - //Used to filter out dependencies that are already paths. - req.jsExtRegExp = /^\/|:|\?|\.js$/; - req.isBrowser = isBrowser; - s = req.s = { - contexts: contexts, - newContext: newContext - }; - - //Create default context. - req({}); - - //Exports some context-sensitive methods on global require. - each([ - 'toUrl', - 'undef', - 'defined', - 'specified' - ], function (prop) { - //Reference from contexts instead of early binding to default context, - //so that during builds, the latest instance of the default context - //with its config gets used. - req[prop] = function () { - var ctx = contexts[defContextName]; - return ctx.require[prop].apply(ctx, arguments); - }; - }); - - if (isBrowser) { - head = s.head = document.getElementsByTagName('head')[0]; - //If BASE tag is in play, using appendChild is a problem for IE6. - //When that browser dies, this can be removed. Details in this jQuery bug: - //http://dev.jquery.com/ticket/2709 - baseElement = document.getElementsByTagName('base')[0]; - if (baseElement) { - head = s.head = baseElement.parentNode; - } - } - - /** - * Any errors that require explicitly generates will be passed to this - * function. Intercept/override it if you want custom error handling. - * @param {Error} err the error object. - */ - req.onError = defaultOnError; - - /** - * Creates the node for the load command. Only used in browser envs. - */ - req.createNode = function (config, moduleName, url) { - var node = config.xhtml ? - document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') : - document.createElement('script'); - node.type = config.scriptType || 'text/javascript'; - node.charset = 'utf-8'; - node.async = true; - return node; - }; - - /** - * Does the request to load a module for the browser case. - * Make this a separate function to allow other environments - * to override it. - * - * @param {Object} context the require context to find state. - * @param {String} moduleName the name of the module. - * @param {Object} url the URL to the module. - */ - req.load = function (context, moduleName, url) { - var config = (context && context.config) || {}, - node; - if (isBrowser) { - //In the browser so use a script tag - node = req.createNode(config, moduleName, url); - - node.setAttribute('data-requirecontext', context.contextName); - node.setAttribute('data-requiremodule', moduleName); - - //Set up load listener. Test attachEvent first because IE9 has - //a subtle issue in its addEventListener and script onload firings - //that do not match the behavior of all other browsers with - //addEventListener support, which fire the onload event for a - //script right after the script execution. See: - //https://connect.microsoft.com/IE/feedback/details/648057/script-onload-event-is-not-fired-immediately-after-script-execution - //UNFORTUNATELY Opera implements attachEvent but does not follow the script - //script execution mode. - if (node.attachEvent && - //Check if node.attachEvent is artificially added by custom script or - //natively supported by browser - //read https://github.com/requirejs/requirejs/issues/187 - //if we can NOT find [native code] then it must NOT natively supported. - //in IE8, node.attachEvent does not have toString() - //Note the test for "[native code" with no closing brace, see: - //https://github.com/requirejs/requirejs/issues/273 - !(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) && - !isOpera) { - //Probably IE. IE (at least 6-8) do not fire - //script onload right after executing the script, so - //we cannot tie the anonymous define call to a name. - //However, IE reports the script as being in 'interactive' - //readyState at the time of the define call. - useInteractive = true; - - node.attachEvent('onreadystatechange', context.onScriptLoad); - //It would be great to add an error handler here to catch - //404s in IE9+. However, onreadystatechange will fire before - //the error handler, so that does not help. If addEventListener - //is used, then IE will fire error before load, but we cannot - //use that pathway given the connect.microsoft.com issue - //mentioned above about not doing the 'script execute, - //then fire the script load event listener before execute - //next script' that other browsers do. - //Best hope: IE10 fixes the issues, - //and then destroys all installs of IE 6-9. - //node.attachEvent('onerror', context.onScriptError); - } else { - node.addEventListener('load', context.onScriptLoad, false); - node.addEventListener('error', context.onScriptError, false); - } - node.src = url; - - //Calling onNodeCreated after all properties on the node have been - //set, but before it is placed in the DOM. - if (config.onNodeCreated) { - config.onNodeCreated(node, config, moduleName, url); - } - - //For some cache cases in IE 6-8, the script executes before the end - //of the appendChild execution, so to tie an anonymous define - //call to the module name (which is stored on the node), hold on - //to a reference to this node, but clear after the DOM insertion. - currentlyAddingScript = node; - if (baseElement) { - head.insertBefore(node, baseElement); - } else { - head.appendChild(node); - } - currentlyAddingScript = null; - - return node; - } else if (isWebWorker) { - try { - //In a web worker, use importScripts. This is not a very - //efficient use of importScripts, importScripts will block until - //its script is downloaded and evaluated. However, if web workers - //are in play, the expectation is that a build has been done so - //that only one script needs to be loaded anyway. This may need - //to be reevaluated if other use cases become common. - - // Post a task to the event loop to work around a bug in WebKit - // where the worker gets garbage-collected after calling - // importScripts(): https://webkit.org/b/153317 - setTimeout(function() {}, 0); - importScripts(url); - - //Account for anonymous modules - context.completeLoad(moduleName); - } catch (e) { - context.onError(makeError('importscripts', - 'importScripts failed for ' + - moduleName + ' at ' + url, - e, - [moduleName])); - } - } - }; - - function getInteractiveScript() { - if (interactiveScript && interactiveScript.readyState === 'interactive') { - return interactiveScript; - } - - eachReverse(scripts(), function (script) { - if (script.readyState === 'interactive') { - return (interactiveScript = script); - } - }); - return interactiveScript; - } - - //Look for a data-main script attribute, which could also adjust the baseUrl. - if (isBrowser && !cfg.skipDataMain) { - //Figure out baseUrl. Get it from the script tag with require.js in it. - eachReverse(scripts(), function (script) { - //Set the 'head' where we can append children by - //using the script's parent. - if (!head) { - head = script.parentNode; - } - - //Look for a data-main attribute to set main script for the page - //to load. If it is there, the path to data main becomes the - //baseUrl, if it is not already set. - dataMain = script.getAttribute('data-main'); - if (dataMain) { - //Preserve dataMain in case it is a path (i.e. contains '?') - mainScript = dataMain; - - //Set final baseUrl if there is not already an explicit one, - //but only do so if the data-main value is not a loader plugin - //module ID. - if (!cfg.baseUrl && mainScript.indexOf('!') === -1) { - //Pull off the directory of data-main for use as the - //baseUrl. - src = mainScript.split('/'); - mainScript = src.pop(); - subPath = src.length ? src.join('/') + '/' : './'; - - cfg.baseUrl = subPath; - } - - //Strip off any trailing .js since mainScript is now - //like a module name. - mainScript = mainScript.replace(jsSuffixRegExp, ''); - - //If mainScript is still a path, fall back to dataMain - if (req.jsExtRegExp.test(mainScript)) { - mainScript = dataMain; - } - - //Put the data-main script in the files to load. - cfg.deps = cfg.deps ? cfg.deps.concat(mainScript) : [mainScript]; - - return true; - } - }); - } - - /** - * The function that handles definitions of modules. Differs from - * require() in that a string for the module should be the first argument, - * and the function to execute after dependencies are loaded should - * return a value to define the module corresponding to the first argument's - * name. - */ - define = function (name, deps, callback) { - var node, context; - - //Allow for anonymous modules - if (typeof name !== 'string') { - //Adjust args appropriately - callback = deps; - deps = name; - name = null; - } - - //This module may not have dependencies - if (!isArray(deps)) { - callback = deps; - deps = null; - } - - //If no name, and callback is a function, then figure out if it a - //CommonJS thing with dependencies. - if (!deps && isFunction(callback)) { - deps = []; - //Remove comments from the callback string, - //look for require calls, and pull them into the dependencies, - //but only if there are function args. - if (callback.length) { - callback - .toString() - .replace(commentRegExp, commentReplace) - .replace(cjsRequireRegExp, function (match, dep) { - deps.push(dep); - }); - - //May be a CommonJS thing even without require calls, but still - //could use exports, and module. Avoid doing exports and module - //work though if it just needs require. - //REQUIRES the function to expect the CommonJS variables in the - //order listed below. - deps = (callback.length === 1 ? ['require'] : ['require', 'exports', 'module']).concat(deps); - } - } - - //If in IE 6-8 and hit an anonymous define() call, do the interactive - //work. - if (useInteractive) { - node = currentlyAddingScript || getInteractiveScript(); - if (node) { - if (!name) { - name = node.getAttribute('data-requiremodule'); - } - context = contexts[node.getAttribute('data-requirecontext')]; - } - } - - //Always save off evaluating the def call until the script onload handler. - //This allows multiple modules to be in a file without prematurely - //tracing dependencies, and allows for anonymous module support, - //where the module name is not known until the script onload event - //occurs. If no context, use the global queue, and get it processed - //in the onscript load callback. - if (context) { - context.defQueue.push([name, deps, callback]); - context.defQueueMap[name] = true; - } else { - globalDefQueue.push([name, deps, callback]); - } - }; - - define.amd = { - jQuery: true - }; - - /** - * Executes the text. Normally just uses eval, but can be modified - * to use a better, environment-specific call. Only used for transpiling - * loader plugins, not for plain JS modules. - * @param {String} text the text to execute/evaluate. - */ - req.exec = function (text) { - /*jslint evil: true */ - return eval(text); - }; - - //Set up with config info. - req(cfg); -}(this, (typeof setTimeout === 'undefined' ? undefined : setTimeout))); - -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -define('backend/debug-host',["require", "exports", "aurelia-dependency-injection"], function (require, exports, aurelia_dependency_injection_1) { - "use strict"; - var createAureliaDebugger = function () { - if (window['aureliaDebugger']) { - return; - } - (function () { - var nextDebugId = 0; - function getNextDebugId() { - return ++nextDebugId; - } - function createErrorObject(e) { - return { - bindingContext: { - properties: [ - { - name: 'Debugger Error', - value: e.message, - type: 'string', - canEdit: false - } - ] - } - }; - } - function attachedOwner(node) { - var ownerView = node.auOwnerView; - if (ownerView && ownerView.viewFactory) { - return ownerView; - } - return null; - } - function nodeIsImmediateChildOfView(view, node) { - var currentChild = view.firstChild; - var lastChild = view.lastChild; - var nextChild; - while (currentChild) { - nextChild = currentChild.nextSibling; - if (currentChild === node) { - return true; - } - if (currentChild === lastChild) { - break; - } - currentChild = nextChild; - } - return false; - } - function findSiblingRepeaterView(node) { - if (!node) { - return null; - } - var current = node.nextSibling; - while (current) { - if (current.nodeType === 8 && current.viewSlot && current.data === 'anchor') { - var children = current.viewSlot.children; - for (var i = 0, ii = children.length; i < ii; ++i) { - var view = children[i]; - if (nodeIsImmediateChildOfView(view, node)) { - return view; - } - } - } - current = current.nextSibling; - } - return null; - } - function findImmediateControllerOwningView(node) { - var parent = node.parentNode; - if (parent && parent.au && parent.au.controller - && parent.au.controller.view && nodeIsImmediateChildOfView(parent.au.controller.view, node)) { - return parent.au.controller.view; - } - return null; - } - function findComposingView(node) { - if (!node) { - return null; - } - if (node.aurelia) { - return node.aurelia.root.view; - } - else if (attachedOwner(node)) { - return attachedOwner(node); - } - else if (node.au) { - var au = node.au; - if (au.controller) { - var controller = au.controller; - var tagName = node.tagName ? node.tagName.toLowerCase() : null; - if (tagName === 'router-view') { - return controller.viewModel.view; - } - else if (tagName === 'compose') { - return controller.viewModel.currentController.view; - } - else if (controller['with']) { - return controller['with'].viewModel.view; - } - } - } - return null; - } - function getDebugPropertyKeys(obj) { - var props = []; - for (var key in obj) { - if (key && !key.startsWith('_') && typeof obj[key] !== 'function') { - props.push(key); - } - } - return props; - } - window['aureliaDebugger'] = { - setValueOnDebugInfo: function (debugInfo, value, instance) { - try { - var expandableValue = void 0; - if (value instanceof Node) { - debugInfo.canExpand = true; - debugInfo.type = 'node'; - debugInfo.value = value.constructor.name; - expandableValue = value; - } - else if (Array.isArray(value)) { - debugInfo.canExpand = true; - debugInfo.type = 'array'; - debugInfo.value = "Array[" + value.length + "]"; - expandableValue = value; - } - else { - debugInfo.type = typeof value; - debugInfo.value = value; - } - if (value === null) { - debugInfo.type = 'null'; - debugInfo.value = 'null'; - } - else if (value === undefined) { - debugInfo.type = 'undefined'; - debugInfo.value = 'undefined'; - } - else if (debugInfo.type === 'object') { - debugInfo.canExpand = true; - expandableValue = value; - if (value.constructor) { - debugInfo.value = value.constructor.name; - } - else { - debugInfo.value = 'Object'; - } - } - if (debugInfo.type === 'string' || debugInfo.type === 'number' || debugInfo.type === 'boolean') { - debugInfo.canEdit = true; - } - debugInfo.debugId = debugInfo.debugId || getNextDebugId(); - this.debugValueLookup[debugInfo.debugId] = Object.assign({ - instance: instance, - expandableValue: expandableValue - }, debugInfo); - return debugInfo; - } - catch (e) { - return createErrorObject(e); - } - }, - createControllerDebugInfo: function (controller) { - var _this = this; - try { - var controllerDebugInfo = { - name: controller.behavior.elementName || controller.behavior.attributeName - }; - var viewModel_1 = controller.viewModel; - var bindableKeys_1 = {}; - controllerDebugInfo.bindables = controller.behavior.properties.map(function (x) { - bindableKeys_1[x.name] = true; - return _this.setValueOnDebugInfo({ - name: x.name, - attribute: x.attribute, - }, viewModel_1[x.name], viewModel_1); - }); - controllerDebugInfo.properties = getDebugPropertyKeys(viewModel_1) - .filter(function (x) { return !(x in bindableKeys_1); }) - .map(function (x) { - return _this.setValueOnDebugInfo({ - name: x - }, viewModel_1[x], viewModel_1); - }); - return controllerDebugInfo; - } - catch (e) { - return createErrorObject(e); - } - }, - convertObjectToDebugInfo: function (obj, blackList) { - var _this = this; - blackList = blackList || {}; - return { - properties: getDebugPropertyKeys(obj) - .filter(function (x) { return !(x in blackList); }) - .map(function (x) { - return _this.setValueOnDebugInfo({ - name: x - }, obj[x], obj); - }) - }; - }, - getDebugInfoForNode: function (selectedNode) { - var _this = this; - try { - var debugInfo = {}; - this.debugValueLookup = {}; - this.nextDebugId = 0; - if (selectedNode.au) { - var au = selectedNode.au; - if (au.controller) { - debugInfo.customElement = this.createControllerDebugInfo(au.controller); - } - var tagName = selectedNode.tagName ? selectedNode.tagName.toLowerCase() : null; - var customAttributeNames = getDebugPropertyKeys(au) - .filter(function (key) { - return key !== 'controller' && key !== tagName; - }); - if (customAttributeNames.length) { - debugInfo.customAttributes = customAttributeNames.map(function (x) { return _this.createControllerDebugInfo(au[x]); }); - } - } - var owningView = this.findOwningViewOfNode(selectedNode); - if (owningView) { - if (owningView.bindingContext) { - debugInfo.bindingContext = this.convertObjectToDebugInfo(owningView.bindingContext); - } - if (owningView.overrideContext) { - debugInfo.overrideContext = this.convertObjectToDebugInfo(owningView.overrideContext, { bindingContext: true, parentOverrideContext: true }); - } - } - return debugInfo; - } - catch (e) { - return createErrorObject(e); - } - }, - getExpandedDebugValueForId: function (id) { - var value = this.debugValueLookup[id].expandableValue; - if (Array.isArray(value)) { - var newValue_1 = {}; - value.forEach(function (value, index) { - newValue_1[index] = value; - }); - value = newValue_1; - } - return this.convertObjectToDebugInfo(value); - }, - findOwningViewOfNode: function (node) { - function moveUp(n) { - var current = n.parentNode; - if (current) { - return findComposingView(current) || findSiblingRepeaterView(current) || findImmediateControllerOwningView(current) || moveUp(current); - } - return null; - } - return attachedOwner(node) || findSiblingRepeaterView(node) || findImmediateControllerOwningView(node) || moveUp(node); - }, - updateValueForId: function (id, value) { - var debugInfo = this.debugValueLookup[id]; - debugInfo.instance[debugInfo.name] = value; - this.setValueOnDebugInfo(debugInfo, value, debugInfo.instance); - } - }; - })(); - }; - var SelectionChanged = (function () { - function SelectionChanged(debugInfo) { - this.debugInfo = debugInfo; - } - return SelectionChanged; - }()); - exports.SelectionChanged = SelectionChanged; - var DebugHost = (function () { - function DebugHost() { - } - DebugHost.prototype.attach = function (consumer) { - if (chrome && chrome.devtools) { - var code = "(" + createAureliaDebugger.toString() + ")(); aureliaDebugger.getDebugInfoForNode($0)"; - chrome.devtools.panels.elements.onSelectionChanged.addListener(function () { - chrome.devtools.inspectedWindow.eval(code, function (debugObject) { - consumer.onSelectionChanged(new SelectionChanged(debugObject)); - }); - }); - chrome.devtools.inspectedWindow.eval(code, function (debugObject) { - consumer.onSelectionChanged(new SelectionChanged(debugObject)); - }); - } - }; - DebugHost.prototype.updateDebugValue = function (debugInfo) { - var value = debugInfo.value; - if (debugInfo.type === 'string') { - value = "'" + value + "'"; - } - var code = "aureliaDebugger.updateValueForId(" + debugInfo.debugId + ", " + value + ")"; - chrome.devtools.inspectedWindow.eval(code); - }; - DebugHost.prototype.toggleDebugValueExpansion = function (debugInfo) { - if (debugInfo.canExpand) { - debugInfo.isExpanded = !debugInfo.isExpanded; - if (debugInfo.isExpanded && !debugInfo.expandedValue) { - var code = "aureliaDebugger.getExpandedDebugValueForId(" + debugInfo.debugId + ");"; - chrome.devtools.inspectedWindow.eval(code, function (expandedValue) { - debugInfo.expandedValue = expandedValue; - debugInfo.isExpanded = true; - }); - } - } - }; - return DebugHost; - }()); - DebugHost = __decorate([ - aurelia_dependency_injection_1.autoinject, - __metadata("design:paramtypes", []) - ], DebugHost); - exports.DebugHost = DebugHost; -}); - -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -define('app',["require", "exports", "./backend/debug-host", "aurelia-dependency-injection"], function (require, exports, debug_host_1, aurelia_dependency_injection_1) { - "use strict"; - var App = (function () { - function App(debugHost) { - this.debugHost = debugHost; - this.isDarkTheme = false; - } - App.prototype.attached = function () { - this.debugHost.attach(this); - this.isDarkTheme = chrome && chrome.devtools && chrome.devtools.panels && chrome.devtools.panels.themeName === 'dark'; - }; - App.prototype.onSelectionChanged = function (event) { - this.debugInfo = event.debugInfo; - }; - return App; - }()); - App = __decorate([ - aurelia_dependency_injection_1.autoinject, - __metadata("design:paramtypes", [debug_host_1.DebugHost]) - ], App); - exports.App = App; - var StringifyValueConverter = (function () { - function StringifyValueConverter() { - } - StringifyValueConverter.prototype.toView = function (value) { - return JSON.stringify(value); - }; - return StringifyValueConverter; - }()); - exports.StringifyValueConverter = StringifyValueConverter; -}); - -define('environment',["require", "exports"], function (require, exports) { - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.default = { - debug: true, - testing: true - }; -}); - -define('main',["require", "exports", "./environment"], function (require, exports, environment_1) { - "use strict"; - Promise.config({ - longStackTraces: environment_1.default.debug, - warnings: { - wForgottenReturn: false - } - }); - function configure(aurelia) { - aurelia.use - .defaultBindingLanguage() - .defaultResources() - .feature('resources'); - if (environment_1.default.debug) { - aurelia.use.developmentLogging(); - } - if (environment_1.default.testing) { - aurelia.use.plugin('aurelia-testing'); - } - aurelia.start().then(function () { return aurelia.setRoot(); }); - } - exports.configure = configure; -}); - -define('resources/index',["require", "exports"], function (require, exports) { - "use strict"; - function configure(config) { - config.globalResources([ - './elements/aurelia-logo.html', - './elements/debug-group', - './elements/controller-view.html', - './elements/property-view' - ]); - } - exports.configure = configure; -}); - -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -define('resources/elements/debug-group',["require", "exports", "aurelia-templating"], function (require, exports, aurelia_templating_1) { - "use strict"; - var DebugGroup = (function () { - function DebugGroup() { - } - return DebugGroup; - }()); - __decorate([ - aurelia_templating_1.bindable, - __metadata("design:type", String) - ], DebugGroup.prototype, "heading", void 0); - exports.DebugGroup = DebugGroup; -}); - -var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -}; -var __metadata = (this && this.__metadata) || function (k, v) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); -}; -define('resources/elements/property-view',["require", "exports", "aurelia-dependency-injection", "aurelia-templating", "aurelia-task-queue", "../../backend/debug-host"], function (require, exports, aurelia_dependency_injection_1, aurelia_templating_1, aurelia_task_queue_1, debug_host_1) { - "use strict"; - var PropertyView = (function () { - function PropertyView(debugHost, taskQueue) { - this.debugHost = debugHost; - this.taskQueue = taskQueue; - } - PropertyView.prototype.beginEditing = function () { - var _this = this; - if (this.property.canEdit) { - this.property.isEditing = true; - this.taskQueue.queueMicroTask(function () { - _this.editor.focus(); - _this.editor.select(); - }); - } - }; - PropertyView.prototype.onKeyDown = function (e) { - if (e.keyCode === 13) { - this.endEditing(); - } - return true; - }; - PropertyView.prototype.endEditing = function () { - this.property.value = this.editor.value; - this.property.isEditing = false; - this.debugHost.updateDebugValue(this.property); - }; - return PropertyView; - }()); - __decorate([ - aurelia_templating_1.bindable, - __metadata("design:type", Object) - ], PropertyView.prototype, "property", void 0); - PropertyView = __decorate([ - aurelia_dependency_injection_1.autoinject, - __metadata("design:paramtypes", [debug_host_1.DebugHost, aurelia_task_queue_1.TaskQueue]) - ], PropertyView); - exports.PropertyView = PropertyView; -}); - -define('text!app.html', ['module'], function(module) { module.exports = ""; }); -define('text!app.css', ['module'], function(module) { module.exports = ".app-header {\n background: #f4f4f4;\n padding: 0;\n padding: 5px 0 0 0;\n text-align: center;\n}\n\n.dark .app-header {\n background: #2a2a2a;\n}\n\n.logo-badge {\n position: relative;\n top: -7px;\n font-weight: 100;\n font-size: 16px;\n color: #BB79A8;\n}\n\n.not-found {\n font-style: italic;\n font-size: 10px;\n}\n\n.dark .not-found {\n color: #989898;\n}\n\n.custom-attribute {\n margin-bottom: 4px;\n}\n\n.custom-attribute .attribute-name {\n color: saddlebrown;\n}\n.dark .custom-attribute .attribute-name {\n color: #ef9565;\n}\n\n.custom-attribute .block-token {\n color: gray;\n}\n\n.custom-attribute .attribute-name, .custom-attribute .block-token {\n font-size: 12px;\n display: inline;\n font-family: monospace;\n}\n\n.custom-attribute controller-view {\n margin-left: 8px;\n display: block;\n}\n"; }); -define('text!resources/elements/aurelia-logo.html', ['module'], function(module) { module.exports = ""; }); -define('text!reset.css', ['module'], function(module) { module.exports = "/* http://meyerweb.com/eric/tools/css/reset/\n v2.0 | 20110126\n License: none (public domain)\n*/\n\nhtml, body, div, span, applet, object, iframe,\nh1, h2, h3, h4, h5, h6, p, blockquote, pre,\na, abbr, acronym, address, big, cite, code,\ndel, dfn, em, img, ins, kbd, q, s, samp,\nsmall, strike, strong, sub, sup, tt, var,\nb, u, i, center,\ndl, dt, dd, ol, ul, li,\nfieldset, form, label, legend,\ntable, caption, tbody, tfoot, thead, tr, th, td,\narticle, aside, canvas, details, embed,\nfigure, figcaption, footer, header, hgroup,\nmenu, nav, output, ruby, section, summary,\ntime, mark, audio, video {\n\tmargin: 0;\n\tpadding: 0;\n\tborder: 0;\n\tfont-size: 100%;\n\tfont: inherit;\n\tvertical-align: baseline;\n}\n/* HTML5 display-role reset for older browsers */\narticle, aside, details, figcaption, figure,\nfooter, header, hgroup, menu, nav, section {\n\tdisplay: block;\n}\nbody {\n\tline-height: 1;\n}\nol, ul {\n\tlist-style: none;\n}\nblockquote, q {\n\tquotes: none;\n}\nblockquote:before, blockquote:after,\nq:before, q:after {\n\tcontent: '';\n\tcontent: none;\n}\ntable {\n\tborder-collapse: collapse;\n\tborder-spacing: 0;\n}\n\n/*! normalize.css v5.0.0 | MIT License | github.com/necolas/normalize.css */\n\n/* Document\n ========================================================================== */\n\n/**\n * 1. Change the default font family in all browsers (opinionated).\n * 2. Correct the line height in all browsers.\n * 3. Prevent adjustments of font size after orientation changes in\n * IE on Windows Phone and in iOS.\n */\n\nhtml {\n font-family: sans-serif; /* 1 */\n line-height: 1.15; /* 2 */\n -ms-text-size-adjust: 100%; /* 3 */\n -webkit-text-size-adjust: 100%; /* 3 */\n}\n\n/* Forms\n ========================================================================== */\n\n/**\n * 1. Change the font styles in all browsers (opinionated).\n * 2. Remove the margin in Firefox and Safari.\n */\n\nbutton,\ninput,\noptgroup,\nselect,\ntextarea {\n font-family: sans-serif; /* 1 */\n font-size: 100%; /* 1 */\n line-height: 1.15; /* 1 */\n margin: 0; /* 2 */\n}\n\n/**\n * Show the overflow in IE.\n * 1. Show the overflow in Edge.\n */\n\nbutton,\ninput { /* 1 */\n overflow: visible;\n}\n\n/**\n * Remove the inheritance of text transform in Edge, Firefox, and IE.\n * 1. Remove the inheritance of text transform in Firefox.\n */\n\nbutton,\nselect { /* 1 */\n text-transform: none;\n}\n\n/**\n * 1. Prevent a WebKit bug where (2) destroys native `audio` and `video`\n * controls in Android 4.\n * 2. Correct the inability to style clickable types in iOS and Safari.\n */\n\nbutton,\nhtml [type=\"button\"], /* 1 */\n[type=\"reset\"],\n[type=\"submit\"] {\n -webkit-appearance: button; /* 2 */\n}\n\n/**\n * Remove the inner border and padding in Firefox.\n */\n\nbutton::-moz-focus-inner,\n[type=\"button\"]::-moz-focus-inner,\n[type=\"reset\"]::-moz-focus-inner,\n[type=\"submit\"]::-moz-focus-inner {\n border-style: none;\n padding: 0;\n}\n\n/**\n * Restore the focus styles unset by the previous rule.\n */\n\nbutton:-moz-focusring,\n[type=\"button\"]:-moz-focusring,\n[type=\"reset\"]:-moz-focusring,\n[type=\"submit\"]:-moz-focusring {\n outline: 1px dotted ButtonText;\n}\n\n/**\n * Change the border, margin, and padding in all browsers (opinionated).\n */\n\nfieldset {\n border: 1px solid #c0c0c0;\n margin: 0 2px;\n padding: 0.35em 0.625em 0.75em;\n}\n\n/**\n * 1. Correct the text wrapping in Edge and IE.\n * 2. Correct the color inheritance from `fieldset` elements in IE.\n * 3. Remove the padding so developers are not caught out when they zero out\n * `fieldset` elements in all browsers.\n */\n\nlegend {\n box-sizing: border-box; /* 1 */\n color: inherit; /* 2 */\n display: table; /* 1 */\n max-width: 100%; /* 1 */\n padding: 0; /* 3 */\n white-space: normal; /* 1 */\n}\n\n/**\n * 1. Add the correct display in IE 9-.\n * 2. Add the correct vertical alignment in Chrome, Firefox, and Opera.\n */\n\nprogress {\n display: inline-block; /* 1 */\n vertical-align: baseline; /* 2 */\n}\n\n/**\n * Remove the default vertical scrollbar in IE.\n */\n\ntextarea {\n overflow: auto;\n}\n\n/**\n * 1. Add the correct box sizing in IE 10-.\n * 2. Remove the padding in IE 10-.\n */\n\n[type=\"checkbox\"],\n[type=\"radio\"] {\n box-sizing: border-box; /* 1 */\n padding: 0; /* 2 */\n}\n\n/**\n * Correct the cursor style of increment and decrement buttons in Chrome.\n */\n\n[type=\"number\"]::-webkit-inner-spin-button,\n[type=\"number\"]::-webkit-outer-spin-button {\n height: auto;\n}\n\n/**\n * 1. Correct the odd appearance in Chrome and Safari.\n * 2. Correct the outline style in Safari.\n */\n\n[type=\"search\"] {\n -webkit-appearance: textfield; /* 1 */\n outline-offset: -2px; /* 2 */\n}\n\n/**\n * Remove the inner padding and cancel buttons in Chrome and Safari on macOS.\n */\n\n[type=\"search\"]::-webkit-search-cancel-button,\n[type=\"search\"]::-webkit-search-decoration {\n -webkit-appearance: none;\n}\n\n/**\n * 1. Correct the inability to style clickable types in iOS and Safari.\n * 2. Change font properties to `inherit` in Safari.\n */\n\n::-webkit-file-upload-button {\n -webkit-appearance: button; /* 1 */\n font: inherit; /* 2 */\n}\n"; }); -define('text!resources/elements/controller-view.html', ['module'], function(module) { module.exports = ""; }); -define('text!resources/elements/controller-view.css', ['module'], function(module) { module.exports = "controller-view .category-name {\n font-size: 10px;\n margin-bottom: 2px;\n margin-top: 2px;\n}\n"; }); -define('text!resources/elements/debug-group.html', ['module'], function(module) { module.exports = ""; }); -define('text!resources/elements/debug-group.css', ['module'], function(module) { module.exports = "debug-group .header {\n font-weight: normal;\n font-size: 12px;\n margin: 0;\n padding: 4px;\n background: #f4f4f4;\n border-bottom: 1px solid rgba(0, 0, 0, .25);\n border-top: 1px solid rgba(0, 0, 0, .25);\n}\n\n.dark debug-group .header {\n color: #989898;\n background: #2a2a2a;\n border-bottom: 1px solid #5c5c5c;\n border-top: 1px solid #3d3d3d;\n}\n\ndebug-group .content { \n margin: 4px;\n}\n"; }); -define('text!resources/elements/property-view.html', ['module'], function(module) { module.exports = ""; }); -define('text!resources/elements/property-view.css', ['module'], function(module) { module.exports = "property-view {\n margin-top: 2px;\n display: block;\n}\n\nproperty-view .arrow {\n font-size: 10px;\n color: dimgray;\n cursor: default;\n}\n\nproperty-view .arrow .right {\n margin-right: 1px;\n}\n\nproperty-view .property-line {\n white-space: nowrap;\n}\n\nproperty-view .property-name {\n font-size: 12px;\n color: purple;\n font-family: monospace;\n margin-left: 1px;\n}\n\n.dark property-view .property-name {\n color: #34c7bb;\n}\nproperty-view .value-container {\n position: relative;\n}\n\nproperty-view .property-editor {\n font-family: monospace;\n font-size: 12px;\n margin: 0;\n height: 12px;\n outline: none;\n border: 1px solid darkgray;\n box-shadow: 0 0 5px rgba(0,0,0,.5);\n position: absolute;\n top: 4px;\n left: 2px;\n padding: 0 0 0 2px;\n}\n\nproperty-view .property-value, property-view .token-colon {\n font-size: 12px;\n color: dimgray;\n font-family: monospace;\n}\n\nproperty-view .property-value.null, property-view .property-value.undefined {\n color: dimgray;\n}\n\nproperty-view .property-value.boolean {\n color: deeppink;\n}\n\nproperty-view .property-value.string {\n color: red;\n white-space: nowrap;\n}\n.dark property-view .property-value.string {\n color:#cbcbcb;\n}\n\nproperty-view .property-value.number {\n color: blue;\n}\n\n.dark property-view .property-value.number {\n color: #59a6ca;\n}\n\nproperty-view .property-value.array {\n color: black;\n}\n\n.dark property-view .property-value.array {\n color: #cbcbcb;\n}\n\nproperty-view .property-value.object, property-view .property-value.node {\n color: black;\n}\n\n.dark property-view .property-value.object, property-view .property-value.node {\n color: #cbcbcb;\n}\n\nproperty-view ul.properties {\n margin-left: 16px;\n}\n\nproperty-view .no-properties {\n margin-top: 4px;\n font-size: 10px;\n}\n\n.dark property-view .no-properties {\n color: #989898;\n}\n"; }); -define('aurelia-binding',['exports', 'aurelia-logging', 'aurelia-pal', 'aurelia-task-queue', 'aurelia-metadata'], function (exports, _aureliaLogging, _aureliaPal, _aureliaTaskQueue, _aureliaMetadata) { - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.getSetObserver = exports.BindingEngine = exports.NameExpression = exports.Listener = exports.ListenerExpression = exports.BindingBehaviorResource = exports.ValueConverterResource = exports.Call = exports.CallExpression = exports.Binding = exports.BindingExpression = exports.ObjectObservationAdapter = exports.ObserverLocator = exports.SVGAnalyzer = exports.presentationAttributes = exports.presentationElements = exports.elements = exports.ComputedExpression = exports.ClassObserver = exports.SelectValueObserver = exports.CheckedObserver = exports.ValueAttributeObserver = exports.StyleObserver = exports.DataAttributeObserver = exports.dataAttributeAccessor = exports.XLinkAttributeObserver = exports.SetterObserver = exports.PrimitiveObserver = exports.propertyAccessor = exports.DirtyCheckProperty = exports.DirtyChecker = exports.EventManager = exports.delegationStrategy = exports.getMapObserver = exports.ParserImplementation = exports.Parser = exports.Scanner = exports.Lexer = exports.Token = exports.bindingMode = exports.ExpressionCloner = exports.Unparser = exports.LiteralObject = exports.LiteralArray = exports.LiteralString = exports.LiteralPrimitive = exports.PrefixNot = exports.Binary = exports.CallFunction = exports.CallMember = exports.CallScope = exports.AccessKeyed = exports.AccessMember = exports.AccessScope = exports.AccessThis = exports.Conditional = exports.Assign = exports.ValueConverter = exports.BindingBehavior = exports.Chain = exports.Expression = exports.getArrayObserver = exports.CollectionLengthObserver = exports.ModifyCollectionObserver = exports.ExpressionObserver = exports.sourceContext = undefined; - exports.camelCase = camelCase; - exports.createOverrideContext = createOverrideContext; - exports.getContextFor = getContextFor; - exports.createScopeForTest = createScopeForTest; - exports.connectable = connectable; - exports.enqueueBindingConnect = enqueueBindingConnect; - exports.subscriberCollection = subscriberCollection; - exports.calcSplices = calcSplices; - exports.mergeSplice = mergeSplice; - exports.projectArraySplices = projectArraySplices; - exports.getChangeRecords = getChangeRecords; - exports.cloneExpression = cloneExpression; - exports.hasDeclaredDependencies = hasDeclaredDependencies; - exports.declarePropertyDependencies = declarePropertyDependencies; - exports.computedFrom = computedFrom; - exports.createComputedObserver = createComputedObserver; - exports.valueConverter = valueConverter; - exports.bindingBehavior = bindingBehavior; - exports.observable = observable; - - var LogManager = _interopRequireWildcard(_aureliaLogging); - - function _interopRequireWildcard(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; - } - } - - var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { - return typeof obj; - } : function (obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; - }; - - var _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; - }; - }(); - - function _possibleConstructorReturn(self, call) { - if (!self) { - throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - } - - return call && (typeof call === "object" || typeof call === "function") ? call : self; - } - - function _inherits(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) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; - } - - - - var _dec, _dec2, _class, _dec3, _class2, _dec4, _class3, _dec5, _class5, _dec6, _class7, _dec7, _class8, _dec8, _class9, _dec9, _class10, _class11, _temp, _dec10, _class12, _class13, _temp2; - - var map = Object.create(null); - - function camelCase(name) { - if (name in map) { - return map[name]; - } - var result = name.charAt(0).toLowerCase() + name.slice(1).replace(/[_.-](\w|$)/g, function (_, x) { - return x.toUpperCase(); - }); - map[name] = result; - return result; - } - - function createOverrideContext(bindingContext, parentOverrideContext) { - return { - bindingContext: bindingContext, - parentOverrideContext: parentOverrideContext || null - }; - } - - function getContextFor(name, scope, ancestor) { - var oc = scope.overrideContext; - - if (ancestor) { - while (ancestor && oc) { - ancestor--; - oc = oc.parentOverrideContext; - } - if (ancestor || !oc) { - return undefined; - } - return name in oc ? oc : oc.bindingContext; - } - - while (oc && !(name in oc) && !(oc.bindingContext && name in oc.bindingContext)) { - oc = oc.parentOverrideContext; - } - if (oc) { - return name in oc ? oc : oc.bindingContext; - } - - return scope.bindingContext || scope.overrideContext; - } - - function createScopeForTest(bindingContext, parentBindingContext) { - if (parentBindingContext) { - return { - bindingContext: bindingContext, - overrideContext: createOverrideContext(bindingContext, createOverrideContext(parentBindingContext)) - }; - } - return { - bindingContext: bindingContext, - overrideContext: createOverrideContext(bindingContext) - }; - } - - var sourceContext = exports.sourceContext = 'Binding:source'; - var slotNames = []; - var versionSlotNames = []; - - for (var i = 0; i < 100; i++) { - slotNames.push('_observer' + i); - versionSlotNames.push('_observerVersion' + i); - } - - function addObserver(observer) { - var observerSlots = this._observerSlots === undefined ? 0 : this._observerSlots; - var i = observerSlots; - while (i-- && this[slotNames[i]] !== observer) {} - - if (i === -1) { - i = 0; - while (this[slotNames[i]]) { - i++; - } - this[slotNames[i]] = observer; - observer.subscribe(sourceContext, this); - - if (i === observerSlots) { - this._observerSlots = i + 1; - } - } - - if (this._version === undefined) { - this._version = 0; - } - this[versionSlotNames[i]] = this._version; - } - - function observeProperty(obj, propertyName) { - var observer = this.observerLocator.getObserver(obj, propertyName); - addObserver.call(this, observer); - } - - function observeArray(array) { - var observer = this.observerLocator.getArrayObserver(array); - addObserver.call(this, observer); - } - - function unobserve(all) { - var i = this._observerSlots; - while (i--) { - if (all || this[versionSlotNames[i]] !== this._version) { - var observer = this[slotNames[i]]; - this[slotNames[i]] = null; - if (observer) { - observer.unsubscribe(sourceContext, this); - } - } - } - } - - function connectable() { - return function (target) { - target.prototype.observeProperty = observeProperty; - target.prototype.observeArray = observeArray; - target.prototype.unobserve = unobserve; - target.prototype.addObserver = addObserver; - }; - } - - var queue = []; - var queued = {}; - var nextId = 0; - var minimumImmediate = 100; - var frameBudget = 15; - - var isFlushRequested = false; - var immediate = 0; - - function flush(animationFrameStart) { - var length = queue.length; - var i = 0; - while (i < length) { - var binding = queue[i]; - queued[binding.__connectQueueId] = false; - binding.connect(true); - i++; - - if (i % 100 === 0 && _aureliaPal.PLATFORM.performance.now() - animationFrameStart > frameBudget) { - break; - } - } - queue.splice(0, i); - - if (queue.length) { - _aureliaPal.PLATFORM.requestAnimationFrame(flush); - } else { - isFlushRequested = false; - immediate = 0; - } - } - - function enqueueBindingConnect(binding) { - if (immediate < minimumImmediate) { - immediate++; - binding.connect(false); - } else { - var id = binding.__connectQueueId; - if (id === undefined) { - id = nextId; - nextId++; - binding.__connectQueueId = id; - } - - if (!queued[id]) { - queue.push(binding); - queued[id] = true; - } - } - if (!isFlushRequested) { - isFlushRequested = true; - _aureliaPal.PLATFORM.requestAnimationFrame(flush); - } - } - - function addSubscriber(context, callable) { - if (this.hasSubscriber(context, callable)) { - return false; - } - if (!this._context0) { - this._context0 = context; - this._callable0 = callable; - return true; - } - if (!this._context1) { - this._context1 = context; - this._callable1 = callable; - return true; - } - if (!this._context2) { - this._context2 = context; - this._callable2 = callable; - return true; - } - if (!this._contextsRest) { - this._contextsRest = [context]; - this._callablesRest = [callable]; - return true; - } - this._contextsRest.push(context); - this._callablesRest.push(callable); - return true; - } - - function removeSubscriber(context, callable) { - if (this._context0 === context && this._callable0 === callable) { - this._context0 = null; - this._callable0 = null; - return true; - } - if (this._context1 === context && this._callable1 === callable) { - this._context1 = null; - this._callable1 = null; - return true; - } - if (this._context2 === context && this._callable2 === callable) { - this._context2 = null; - this._callable2 = null; - return true; - } - var rest = this._contextsRest; - var index = void 0; - if (!rest || !rest.length || (index = rest.indexOf(context)) === -1 || this._callablesRest[index] !== callable) { - return false; - } - rest.splice(index, 1); - this._callablesRest.splice(index, 1); - return true; - } - - var arrayPool1 = []; - var arrayPool2 = []; - var poolUtilization = []; - - function callSubscribers(newValue, oldValue) { - var context0 = this._context0; - var callable0 = this._callable0; - var context1 = this._context1; - var callable1 = this._callable1; - var context2 = this._context2; - var callable2 = this._callable2; - var length = this._contextsRest ? this._contextsRest.length : 0; - var contextsRest = void 0; - var callablesRest = void 0; - var poolIndex = void 0; - var i = void 0; - if (length) { - poolIndex = poolUtilization.length; - while (poolIndex-- && poolUtilization[poolIndex]) {} - if (poolIndex < 0) { - poolIndex = poolUtilization.length; - contextsRest = []; - callablesRest = []; - poolUtilization.push(true); - arrayPool1.push(contextsRest); - arrayPool2.push(callablesRest); - } else { - poolUtilization[poolIndex] = true; - contextsRest = arrayPool1[poolIndex]; - callablesRest = arrayPool2[poolIndex]; - } - - i = length; - while (i--) { - contextsRest[i] = this._contextsRest[i]; - callablesRest[i] = this._callablesRest[i]; - } - } - - if (context0) { - if (callable0) { - callable0.call(context0, newValue, oldValue); - } else { - context0(newValue, oldValue); - } - } - if (context1) { - if (callable1) { - callable1.call(context1, newValue, oldValue); - } else { - context1(newValue, oldValue); - } - } - if (context2) { - if (callable2) { - callable2.call(context2, newValue, oldValue); - } else { - context2(newValue, oldValue); - } - } - if (length) { - for (i = 0; i < length; i++) { - var callable = callablesRest[i]; - var context = contextsRest[i]; - if (callable) { - callable.call(context, newValue, oldValue); - } else { - context(newValue, oldValue); - } - contextsRest[i] = null; - callablesRest[i] = null; - } - poolUtilization[poolIndex] = false; - } - } - - function hasSubscribers() { - return !!(this._context0 || this._context1 || this._context2 || this._contextsRest && this._contextsRest.length); - } - - function hasSubscriber(context, callable) { - var has = this._context0 === context && this._callable0 === callable || this._context1 === context && this._callable1 === callable || this._context2 === context && this._callable2 === callable; - if (has) { - return true; - } - var index = void 0; - var contexts = this._contextsRest; - if (!contexts || (index = contexts.length) === 0) { - return false; - } - var callables = this._callablesRest; - while (index--) { - if (contexts[index] === context && callables[index] === callable) { - return true; - } - } - return false; - } - - function subscriberCollection() { - return function (target) { - target.prototype.addSubscriber = addSubscriber; - target.prototype.removeSubscriber = removeSubscriber; - target.prototype.callSubscribers = callSubscribers; - target.prototype.hasSubscribers = hasSubscribers; - target.prototype.hasSubscriber = hasSubscriber; - }; - } - - var ExpressionObserver = exports.ExpressionObserver = (_dec = connectable(), _dec2 = subscriberCollection(), _dec(_class = _dec2(_class = function () { - function ExpressionObserver(scope, expression, observerLocator, lookupFunctions) { - - - this.scope = scope; - this.expression = expression; - this.observerLocator = observerLocator; - this.lookupFunctions = lookupFunctions; - } - - ExpressionObserver.prototype.getValue = function getValue() { - return this.expression.evaluate(this.scope, this.lookupFunctions); - }; - - ExpressionObserver.prototype.setValue = function setValue(newValue) { - this.expression.assign(this.scope, newValue); - }; - - ExpressionObserver.prototype.subscribe = function subscribe(context, callable) { - var _this = this; - - if (!this.hasSubscribers()) { - this.oldValue = this.expression.evaluate(this.scope, this.lookupFunctions); - this.expression.connect(this, this.scope); - } - this.addSubscriber(context, callable); - if (arguments.length === 1 && context instanceof Function) { - return { - dispose: function dispose() { - _this.unsubscribe(context, callable); - } - }; - } - }; - - ExpressionObserver.prototype.unsubscribe = function unsubscribe(context, callable) { - if (this.removeSubscriber(context, callable) && !this.hasSubscribers()) { - this.unobserve(true); - this.oldValue = undefined; - } - }; - - ExpressionObserver.prototype.call = function call() { - var newValue = this.expression.evaluate(this.scope, this.lookupFunctions); - var oldValue = this.oldValue; - if (newValue !== oldValue) { - this.oldValue = newValue; - this.callSubscribers(newValue, oldValue); - } - this._version++; - this.expression.connect(this, this.scope); - this.unobserve(false); - }; - - return ExpressionObserver; - }()) || _class) || _class); - - - function isIndex(s) { - return +s === s >>> 0; - } - - function toNumber(s) { - return +s; - } - - function newSplice(index, removed, addedCount) { - return { - index: index, - removed: removed, - addedCount: addedCount - }; - } - - var EDIT_LEAVE = 0; - var EDIT_UPDATE = 1; - var EDIT_ADD = 2; - var EDIT_DELETE = 3; - - function ArraySplice() {} - - ArraySplice.prototype = { - calcEditDistances: function calcEditDistances(current, currentStart, currentEnd, old, oldStart, oldEnd) { - var rowCount = oldEnd - oldStart + 1; - var columnCount = currentEnd - currentStart + 1; - var distances = new Array(rowCount); - var north = void 0; - var west = void 0; - - for (var _i = 0; _i < rowCount; ++_i) { - distances[_i] = new Array(columnCount); - distances[_i][0] = _i; - } - - for (var j = 0; j < columnCount; ++j) { - distances[0][j] = j; - } - - for (var _i2 = 1; _i2 < rowCount; ++_i2) { - for (var _j = 1; _j < columnCount; ++_j) { - if (this.equals(current[currentStart + _j - 1], old[oldStart + _i2 - 1])) { - distances[_i2][_j] = distances[_i2 - 1][_j - 1]; - } else { - north = distances[_i2 - 1][_j] + 1; - west = distances[_i2][_j - 1] + 1; - distances[_i2][_j] = north < west ? north : west; - } - } - } - - return distances; - }, - - spliceOperationsFromEditDistances: function spliceOperationsFromEditDistances(distances) { - var i = distances.length - 1; - var j = distances[0].length - 1; - var current = distances[i][j]; - var edits = []; - while (i > 0 || j > 0) { - if (i === 0) { - edits.push(EDIT_ADD); - j--; - continue; - } - if (j === 0) { - edits.push(EDIT_DELETE); - i--; - continue; - } - var northWest = distances[i - 1][j - 1]; - var west = distances[i - 1][j]; - var north = distances[i][j - 1]; - - var min = void 0; - if (west < north) { - min = west < northWest ? west : northWest; - } else { - min = north < northWest ? north : northWest; - } - - if (min === northWest) { - if (northWest === current) { - edits.push(EDIT_LEAVE); - } else { - edits.push(EDIT_UPDATE); - current = northWest; - } - i--; - j--; - } else if (min === west) { - edits.push(EDIT_DELETE); - i--; - current = west; - } else { - edits.push(EDIT_ADD); - j--; - current = north; - } - } - - edits.reverse(); - return edits; - }, - - calcSplices: function calcSplices(current, currentStart, currentEnd, old, oldStart, oldEnd) { - var prefixCount = 0; - var suffixCount = 0; - - var minLength = Math.min(currentEnd - currentStart, oldEnd - oldStart); - if (currentStart === 0 && oldStart === 0) { - prefixCount = this.sharedPrefix(current, old, minLength); - } - - if (currentEnd === current.length && oldEnd === old.length) { - suffixCount = this.sharedSuffix(current, old, minLength - prefixCount); - } - - currentStart += prefixCount; - oldStart += prefixCount; - currentEnd -= suffixCount; - oldEnd -= suffixCount; - - if (currentEnd - currentStart === 0 && oldEnd - oldStart === 0) { - return []; - } - - if (currentStart === currentEnd) { - var _splice = newSplice(currentStart, [], 0); - while (oldStart < oldEnd) { - _splice.removed.push(old[oldStart++]); - } - - return [_splice]; - } else if (oldStart === oldEnd) { - return [newSplice(currentStart, [], currentEnd - currentStart)]; - } - - var ops = this.spliceOperationsFromEditDistances(this.calcEditDistances(current, currentStart, currentEnd, old, oldStart, oldEnd)); - - var splice = undefined; - var splices = []; - var index = currentStart; - var oldIndex = oldStart; - for (var _i3 = 0; _i3 < ops.length; ++_i3) { - switch (ops[_i3]) { - case EDIT_LEAVE: - if (splice) { - splices.push(splice); - splice = undefined; - } - - index++; - oldIndex++; - break; - case EDIT_UPDATE: - if (!splice) { - splice = newSplice(index, [], 0); - } - - splice.addedCount++; - index++; - - splice.removed.push(old[oldIndex]); - oldIndex++; - break; - case EDIT_ADD: - if (!splice) { - splice = newSplice(index, [], 0); - } - - splice.addedCount++; - index++; - break; - case EDIT_DELETE: - if (!splice) { - splice = newSplice(index, [], 0); - } - - splice.removed.push(old[oldIndex]); - oldIndex++; - break; - } - } - - if (splice) { - splices.push(splice); - } - return splices; - }, - - sharedPrefix: function sharedPrefix(current, old, searchLength) { - for (var _i4 = 0; _i4 < searchLength; ++_i4) { - if (!this.equals(current[_i4], old[_i4])) { - return _i4; - } - } - - return searchLength; - }, - - sharedSuffix: function sharedSuffix(current, old, searchLength) { - var index1 = current.length; - var index2 = old.length; - var count = 0; - while (count < searchLength && this.equals(current[--index1], old[--index2])) { - count++; - } - - return count; - }, - - calculateSplices: function calculateSplices(current, previous) { - return this.calcSplices(current, 0, current.length, previous, 0, previous.length); - }, - - equals: function equals(currentValue, previousValue) { - return currentValue === previousValue; - } - }; - - var arraySplice = new ArraySplice(); - - function calcSplices(current, currentStart, currentEnd, old, oldStart, oldEnd) { - return arraySplice.calcSplices(current, currentStart, currentEnd, old, oldStart, oldEnd); - } - - function intersect(start1, end1, start2, end2) { - if (end1 < start2 || end2 < start1) { - return -1; - } - - if (end1 === start2 || end2 === start1) { - return 0; - } - - if (start1 < start2) { - if (end1 < end2) { - return end1 - start2; - } - - return end2 - start2; - } - - if (end2 < end1) { - return end2 - start1; - } - - return end1 - start1; - } - - function mergeSplice(splices, index, removed, addedCount) { - var splice = newSplice(index, removed, addedCount); - - var inserted = false; - var insertionOffset = 0; - - for (var _i5 = 0; _i5 < splices.length; _i5++) { - var current = splices[_i5]; - current.index += insertionOffset; - - if (inserted) { - continue; - } - - var intersectCount = intersect(splice.index, splice.index + splice.removed.length, current.index, current.index + current.addedCount); - - if (intersectCount >= 0) { - - splices.splice(_i5, 1); - _i5--; - - insertionOffset -= current.addedCount - current.removed.length; - - splice.addedCount += current.addedCount - intersectCount; - var deleteCount = splice.removed.length + current.removed.length - intersectCount; - - if (!splice.addedCount && !deleteCount) { - inserted = true; - } else { - var currentRemoved = current.removed; - - if (splice.index < current.index) { - var prepend = splice.removed.slice(0, current.index - splice.index); - Array.prototype.push.apply(prepend, currentRemoved); - currentRemoved = prepend; - } - - if (splice.index + splice.removed.length > current.index + current.addedCount) { - var append = splice.removed.slice(current.index + current.addedCount - splice.index); - Array.prototype.push.apply(currentRemoved, append); - } - - splice.removed = currentRemoved; - if (current.index < splice.index) { - splice.index = current.index; - } - } - } else if (splice.index < current.index) { - - inserted = true; - - splices.splice(_i5, 0, splice); - _i5++; - - var offset = splice.addedCount - splice.removed.length; - current.index += offset; - insertionOffset += offset; - } - } - - if (!inserted) { - splices.push(splice); - } - } - - function createInitialSplices(array, changeRecords) { - var splices = []; - - for (var _i6 = 0; _i6 < changeRecords.length; _i6++) { - var record = changeRecords[_i6]; - switch (record.type) { - case 'splice': - mergeSplice(splices, record.index, record.removed.slice(), record.addedCount); - break; - case 'add': - case 'update': - case 'delete': - if (!isIndex(record.name)) { - continue; - } - - var index = toNumber(record.name); - if (index < 0) { - continue; - } - - mergeSplice(splices, index, [record.oldValue], record.type === 'delete' ? 0 : 1); - break; - default: - console.error('Unexpected record type: ' + JSON.stringify(record)); - break; - } - } - - return splices; - } - - function projectArraySplices(array, changeRecords) { - var splices = []; - - createInitialSplices(array, changeRecords).forEach(function (splice) { - if (splice.addedCount === 1 && splice.removed.length === 1) { - if (splice.removed[0] !== array[splice.index]) { - splices.push(splice); - } - - return; - } - - splices = splices.concat(calcSplices(array, splice.index, splice.index + splice.addedCount, splice.removed, 0, splice.removed.length)); - }); - - return splices; - } - - function newRecord(type, object, key, oldValue) { - return { - type: type, - object: object, - key: key, - oldValue: oldValue - }; - } - - function getChangeRecords(map) { - var entries = new Array(map.size); - var keys = map.keys(); - var i = 0; - var item = void 0; - - while (item = keys.next()) { - if (item.done) { - break; - } - - entries[i] = newRecord('added', map, item.value); - i++; - } - - return entries; - } - - var ModifyCollectionObserver = exports.ModifyCollectionObserver = (_dec3 = subscriberCollection(), _dec3(_class2 = function () { - function ModifyCollectionObserver(taskQueue, collection) { - - - this.taskQueue = taskQueue; - this.queued = false; - this.changeRecords = null; - this.oldCollection = null; - this.collection = collection; - this.lengthPropertyName = collection instanceof Map || collection instanceof Set ? 'size' : 'length'; - } - - ModifyCollectionObserver.prototype.subscribe = function subscribe(context, callable) { - this.addSubscriber(context, callable); - }; - - ModifyCollectionObserver.prototype.unsubscribe = function unsubscribe(context, callable) { - this.removeSubscriber(context, callable); - }; - - ModifyCollectionObserver.prototype.addChangeRecord = function addChangeRecord(changeRecord) { - if (!this.hasSubscribers() && !this.lengthObserver) { - return; - } - - if (changeRecord.type === 'splice') { - var index = changeRecord.index; - var arrayLength = changeRecord.object.length; - if (index > arrayLength) { - index = arrayLength - changeRecord.addedCount; - } else if (index < 0) { - index = arrayLength + changeRecord.removed.length + index - changeRecord.addedCount; - } - if (index < 0) { - index = 0; - } - changeRecord.index = index; - } - - if (this.changeRecords === null) { - this.changeRecords = [changeRecord]; - } else { - this.changeRecords.push(changeRecord); - } - - if (!this.queued) { - this.queued = true; - this.taskQueue.queueMicroTask(this); - } - }; - - ModifyCollectionObserver.prototype.flushChangeRecords = function flushChangeRecords() { - if (this.changeRecords && this.changeRecords.length || this.oldCollection) { - this.call(); - } - }; - - ModifyCollectionObserver.prototype.reset = function reset(oldCollection) { - this.oldCollection = oldCollection; - - if (this.hasSubscribers() && !this.queued) { - this.queued = true; - this.taskQueue.queueMicroTask(this); - } - }; - - ModifyCollectionObserver.prototype.getLengthObserver = function getLengthObserver() { - return this.lengthObserver || (this.lengthObserver = new CollectionLengthObserver(this.collection)); - }; - - ModifyCollectionObserver.prototype.call = function call() { - var changeRecords = this.changeRecords; - var oldCollection = this.oldCollection; - var records = void 0; - - this.queued = false; - this.changeRecords = []; - this.oldCollection = null; - - if (this.hasSubscribers()) { - if (oldCollection) { - if (this.collection instanceof Map || this.collection instanceof Set) { - records = getChangeRecords(oldCollection); - } else { - records = calcSplices(this.collection, 0, this.collection.length, oldCollection, 0, oldCollection.length); - } - } else { - if (this.collection instanceof Map || this.collection instanceof Set) { - records = changeRecords; - } else { - records = projectArraySplices(this.collection, changeRecords); - } - } - - this.callSubscribers(records); - } - - if (this.lengthObserver) { - this.lengthObserver.call(this.collection[this.lengthPropertyName]); - } - }; - - return ModifyCollectionObserver; - }()) || _class2); - var CollectionLengthObserver = exports.CollectionLengthObserver = (_dec4 = subscriberCollection(), _dec4(_class3 = function () { - function CollectionLengthObserver(collection) { - - - this.collection = collection; - this.lengthPropertyName = collection instanceof Map || collection instanceof Set ? 'size' : 'length'; - this.currentValue = collection[this.lengthPropertyName]; - } - - CollectionLengthObserver.prototype.getValue = function getValue() { - return this.collection[this.lengthPropertyName]; - }; - - CollectionLengthObserver.prototype.setValue = function setValue(newValue) { - this.collection[this.lengthPropertyName] = newValue; - }; - - CollectionLengthObserver.prototype.subscribe = function subscribe(context, callable) { - this.addSubscriber(context, callable); - }; - - CollectionLengthObserver.prototype.unsubscribe = function unsubscribe(context, callable) { - this.removeSubscriber(context, callable); - }; - - CollectionLengthObserver.prototype.call = function call(newValue) { - var oldValue = this.currentValue; - this.callSubscribers(newValue, oldValue); - this.currentValue = newValue; - }; - - return CollectionLengthObserver; - }()) || _class3); - - var pop = Array.prototype.pop; - var push = Array.prototype.push; - var reverse = Array.prototype.reverse; - var shift = Array.prototype.shift; - var sort = Array.prototype.sort; - var splice = Array.prototype.splice; - var unshift = Array.prototype.unshift; - - Array.prototype.pop = function () { - var notEmpty = this.length > 0; - var methodCallResult = pop.apply(this, arguments); - if (notEmpty && this.__array_observer__ !== undefined) { - this.__array_observer__.addChangeRecord({ - type: 'delete', - object: this, - name: this.length, - oldValue: methodCallResult - }); - } - return methodCallResult; - }; - - Array.prototype.push = function () { - var methodCallResult = push.apply(this, arguments); - if (this.__array_observer__ !== undefined) { - this.__array_observer__.addChangeRecord({ - type: 'splice', - object: this, - index: this.length - arguments.length, - removed: [], - addedCount: arguments.length - }); - } - return methodCallResult; - }; - - Array.prototype.reverse = function () { - var oldArray = void 0; - if (this.__array_observer__ !== undefined) { - this.__array_observer__.flushChangeRecords(); - oldArray = this.slice(); - } - var methodCallResult = reverse.apply(this, arguments); - if (this.__array_observer__ !== undefined) { - this.__array_observer__.reset(oldArray); - } - return methodCallResult; - }; - - Array.prototype.shift = function () { - var notEmpty = this.length > 0; - var methodCallResult = shift.apply(this, arguments); - if (notEmpty && this.__array_observer__ !== undefined) { - this.__array_observer__.addChangeRecord({ - type: 'delete', - object: this, - name: 0, - oldValue: methodCallResult - }); - } - return methodCallResult; - }; - - Array.prototype.sort = function () { - var oldArray = void 0; - if (this.__array_observer__ !== undefined) { - this.__array_observer__.flushChangeRecords(); - oldArray = this.slice(); - } - var methodCallResult = sort.apply(this, arguments); - if (this.__array_observer__ !== undefined) { - this.__array_observer__.reset(oldArray); - } - return methodCallResult; - }; - - Array.prototype.splice = function () { - var methodCallResult = splice.apply(this, arguments); - if (this.__array_observer__ !== undefined) { - this.__array_observer__.addChangeRecord({ - type: 'splice', - object: this, - index: arguments[0], - removed: methodCallResult, - addedCount: arguments.length > 2 ? arguments.length - 2 : 0 - }); - } - return methodCallResult; - }; - - Array.prototype.unshift = function () { - var methodCallResult = unshift.apply(this, arguments); - if (this.__array_observer__ !== undefined) { - this.__array_observer__.addChangeRecord({ - type: 'splice', - object: this, - index: 0, - removed: [], - addedCount: arguments.length - }); - } - return methodCallResult; - }; - - function _getArrayObserver(taskQueue, array) { - return ModifyArrayObserver.for(taskQueue, array); - } - - exports.getArrayObserver = _getArrayObserver; - - var ModifyArrayObserver = function (_ModifyCollectionObse) { - _inherits(ModifyArrayObserver, _ModifyCollectionObse); - - function ModifyArrayObserver(taskQueue, array) { - - - return _possibleConstructorReturn(this, _ModifyCollectionObse.call(this, taskQueue, array)); - } - - ModifyArrayObserver.for = function _for(taskQueue, array) { - if (!('__array_observer__' in array)) { - Reflect.defineProperty(array, '__array_observer__', { - value: ModifyArrayObserver.create(taskQueue, array), - enumerable: false, configurable: false - }); - } - return array.__array_observer__; - }; - - ModifyArrayObserver.create = function create(taskQueue, array) { - return new ModifyArrayObserver(taskQueue, array); - }; - - return ModifyArrayObserver; - }(ModifyCollectionObserver); - - var Expression = exports.Expression = function () { - function Expression() { - - - this.isChain = false; - this.isAssignable = false; - } - - Expression.prototype.evaluate = function evaluate(scope, lookupFunctions, args) { - throw new Error('Binding expression "' + this + '" cannot be evaluated.'); - }; - - Expression.prototype.assign = function assign(scope, value, lookupFunctions) { - throw new Error('Binding expression "' + this + '" cannot be assigned to.'); - }; - - Expression.prototype.toString = function toString() { - return Unparser.unparse(this); - }; - - return Expression; - }(); - - var Chain = exports.Chain = function (_Expression) { - _inherits(Chain, _Expression); - - function Chain(expressions) { - - - var _this3 = _possibleConstructorReturn(this, _Expression.call(this)); - - _this3.expressions = expressions; - _this3.isChain = true; - return _this3; - } - - Chain.prototype.evaluate = function evaluate(scope, lookupFunctions) { - var result = void 0; - var expressions = this.expressions; - var last = void 0; - - for (var _i7 = 0, length = expressions.length; _i7 < length; ++_i7) { - last = expressions[_i7].evaluate(scope, lookupFunctions); - - if (last !== null) { - result = last; - } - } - - return result; - }; - - Chain.prototype.accept = function accept(visitor) { - return visitor.visitChain(this); - }; - - return Chain; - }(Expression); - - var BindingBehavior = exports.BindingBehavior = function (_Expression2) { - _inherits(BindingBehavior, _Expression2); - - function BindingBehavior(expression, name, args) { - - - var _this4 = _possibleConstructorReturn(this, _Expression2.call(this)); - - _this4.expression = expression; - _this4.name = name; - _this4.args = args; - return _this4; - } - - BindingBehavior.prototype.evaluate = function evaluate(scope, lookupFunctions) { - return this.expression.evaluate(scope, lookupFunctions); - }; - - BindingBehavior.prototype.assign = function assign(scope, value, lookupFunctions) { - return this.expression.assign(scope, value, lookupFunctions); - }; - - BindingBehavior.prototype.accept = function accept(visitor) { - return visitor.visitBindingBehavior(this); - }; - - BindingBehavior.prototype.connect = function connect(binding, scope) { - this.expression.connect(binding, scope); - }; - - BindingBehavior.prototype.bind = function bind(binding, scope, lookupFunctions) { - if (this.expression.expression && this.expression.bind) { - this.expression.bind(binding, scope, lookupFunctions); - } - var behavior = lookupFunctions.bindingBehaviors(this.name); - if (!behavior) { - throw new Error('No BindingBehavior named "' + this.name + '" was found!'); - } - var behaviorKey = 'behavior-' + this.name; - if (binding[behaviorKey]) { - throw new Error('A binding behavior named "' + this.name + '" has already been applied to "' + this.expression + '"'); - } - binding[behaviorKey] = behavior; - behavior.bind.apply(behavior, [binding, scope].concat(evalList(scope, this.args, binding.lookupFunctions))); - }; - - BindingBehavior.prototype.unbind = function unbind(binding, scope) { - var behaviorKey = 'behavior-' + this.name; - binding[behaviorKey].unbind(binding, scope); - binding[behaviorKey] = null; - if (this.expression.expression && this.expression.unbind) { - this.expression.unbind(binding, scope); - } - }; - - return BindingBehavior; - }(Expression); - - var ValueConverter = exports.ValueConverter = function (_Expression3) { - _inherits(ValueConverter, _Expression3); - - function ValueConverter(expression, name, args, allArgs) { - - - var _this5 = _possibleConstructorReturn(this, _Expression3.call(this)); - - _this5.expression = expression; - _this5.name = name; - _this5.args = args; - _this5.allArgs = allArgs; - return _this5; - } - - ValueConverter.prototype.evaluate = function evaluate(scope, lookupFunctions) { - var converter = lookupFunctions.valueConverters(this.name); - if (!converter) { - throw new Error('No ValueConverter named "' + this.name + '" was found!'); - } - - if ('toView' in converter) { - return converter.toView.apply(converter, evalList(scope, this.allArgs, lookupFunctions)); - } - - return this.allArgs[0].evaluate(scope, lookupFunctions); - }; - - ValueConverter.prototype.assign = function assign(scope, value, lookupFunctions) { - var converter = lookupFunctions.valueConverters(this.name); - if (!converter) { - throw new Error('No ValueConverter named "' + this.name + '" was found!'); - } - - if ('fromView' in converter) { - value = converter.fromView.apply(converter, [value].concat(evalList(scope, this.args, lookupFunctions))); - } - - return this.allArgs[0].assign(scope, value, lookupFunctions); - }; - - ValueConverter.prototype.accept = function accept(visitor) { - return visitor.visitValueConverter(this); - }; - - ValueConverter.prototype.connect = function connect(binding, scope) { - var expressions = this.allArgs; - var i = expressions.length; - while (i--) { - expressions[i].connect(binding, scope); - } - }; - - return ValueConverter; - }(Expression); - - var Assign = exports.Assign = function (_Expression4) { - _inherits(Assign, _Expression4); - - function Assign(target, value) { - - - var _this6 = _possibleConstructorReturn(this, _Expression4.call(this)); - - _this6.target = target; - _this6.value = value; - return _this6; - } - - Assign.prototype.evaluate = function evaluate(scope, lookupFunctions) { - return this.target.assign(scope, this.value.evaluate(scope, lookupFunctions)); - }; - - Assign.prototype.accept = function accept(vistor) { - vistor.visitAssign(this); - }; - - Assign.prototype.connect = function connect(binding, scope) {}; - - return Assign; - }(Expression); - - var Conditional = exports.Conditional = function (_Expression5) { - _inherits(Conditional, _Expression5); - - function Conditional(condition, yes, no) { - - - var _this7 = _possibleConstructorReturn(this, _Expression5.call(this)); - - _this7.condition = condition; - _this7.yes = yes; - _this7.no = no; - return _this7; - } - - Conditional.prototype.evaluate = function evaluate(scope, lookupFunctions) { - return !!this.condition.evaluate(scope) ? this.yes.evaluate(scope) : this.no.evaluate(scope); - }; - - Conditional.prototype.accept = function accept(visitor) { - return visitor.visitConditional(this); - }; - - Conditional.prototype.connect = function connect(binding, scope) { - this.condition.connect(binding, scope); - if (this.condition.evaluate(scope)) { - this.yes.connect(binding, scope); - } else { - this.no.connect(binding, scope); - } - }; - - return Conditional; - }(Expression); - - var AccessThis = exports.AccessThis = function (_Expression6) { - _inherits(AccessThis, _Expression6); - - function AccessThis(ancestor) { - - - var _this8 = _possibleConstructorReturn(this, _Expression6.call(this)); - - _this8.ancestor = ancestor; - return _this8; - } - - AccessThis.prototype.evaluate = function evaluate(scope, lookupFunctions) { - var oc = scope.overrideContext; - var i = this.ancestor; - while (i-- && oc) { - oc = oc.parentOverrideContext; - } - return i < 1 && oc ? oc.bindingContext : undefined; - }; - - AccessThis.prototype.accept = function accept(visitor) { - return visitor.visitAccessThis(this); - }; - - AccessThis.prototype.connect = function connect(binding, scope) {}; - - return AccessThis; - }(Expression); - - var AccessScope = exports.AccessScope = function (_Expression7) { - _inherits(AccessScope, _Expression7); - - function AccessScope(name, ancestor) { - - - var _this9 = _possibleConstructorReturn(this, _Expression7.call(this)); - - _this9.name = name; - _this9.ancestor = ancestor; - _this9.isAssignable = true; - return _this9; - } - - AccessScope.prototype.evaluate = function evaluate(scope, lookupFunctions) { - var context = getContextFor(this.name, scope, this.ancestor); - return context[this.name]; - }; - - AccessScope.prototype.assign = function assign(scope, value) { - var context = getContextFor(this.name, scope, this.ancestor); - return context ? context[this.name] = value : undefined; - }; - - AccessScope.prototype.accept = function accept(visitor) { - return visitor.visitAccessScope(this); - }; - - AccessScope.prototype.connect = function connect(binding, scope) { - var context = getContextFor(this.name, scope, this.ancestor); - binding.observeProperty(context, this.name); - }; - - return AccessScope; - }(Expression); - - var AccessMember = exports.AccessMember = function (_Expression8) { - _inherits(AccessMember, _Expression8); - - function AccessMember(object, name) { - - - var _this10 = _possibleConstructorReturn(this, _Expression8.call(this)); - - _this10.object = object; - _this10.name = name; - _this10.isAssignable = true; - return _this10; - } - - AccessMember.prototype.evaluate = function evaluate(scope, lookupFunctions) { - var instance = this.object.evaluate(scope, lookupFunctions); - return instance === null || instance === undefined ? instance : instance[this.name]; - }; - - AccessMember.prototype.assign = function assign(scope, value) { - var instance = this.object.evaluate(scope); - - if (instance === null || instance === undefined) { - instance = {}; - this.object.assign(scope, instance); - } - - instance[this.name] = value; - return value; - }; - - AccessMember.prototype.accept = function accept(visitor) { - return visitor.visitAccessMember(this); - }; - - AccessMember.prototype.connect = function connect(binding, scope) { - this.object.connect(binding, scope); - var obj = this.object.evaluate(scope); - if (obj) { - binding.observeProperty(obj, this.name); - } - }; - - return AccessMember; - }(Expression); - - var AccessKeyed = exports.AccessKeyed = function (_Expression9) { - _inherits(AccessKeyed, _Expression9); - - function AccessKeyed(object, key) { - - - var _this11 = _possibleConstructorReturn(this, _Expression9.call(this)); - - _this11.object = object; - _this11.key = key; - _this11.isAssignable = true; - return _this11; - } - - AccessKeyed.prototype.evaluate = function evaluate(scope, lookupFunctions) { - var instance = this.object.evaluate(scope, lookupFunctions); - var lookup = this.key.evaluate(scope, lookupFunctions); - return getKeyed(instance, lookup); - }; - - AccessKeyed.prototype.assign = function assign(scope, value) { - var instance = this.object.evaluate(scope); - var lookup = this.key.evaluate(scope); - return setKeyed(instance, lookup, value); - }; - - AccessKeyed.prototype.accept = function accept(visitor) { - return visitor.visitAccessKeyed(this); - }; - - AccessKeyed.prototype.connect = function connect(binding, scope) { - this.object.connect(binding, scope); - var obj = this.object.evaluate(scope); - if (obj instanceof Object) { - this.key.connect(binding, scope); - var key = this.key.evaluate(scope); - - if (key !== null && key !== undefined && !(Array.isArray(obj) && typeof key === 'number')) { - binding.observeProperty(obj, key); - } - } - }; - - return AccessKeyed; - }(Expression); - - var CallScope = exports.CallScope = function (_Expression10) { - _inherits(CallScope, _Expression10); - - function CallScope(name, args, ancestor) { - - - var _this12 = _possibleConstructorReturn(this, _Expression10.call(this)); - - _this12.name = name; - _this12.args = args; - _this12.ancestor = ancestor; - return _this12; - } - - CallScope.prototype.evaluate = function evaluate(scope, lookupFunctions, mustEvaluate) { - var args = evalList(scope, this.args, lookupFunctions); - var context = getContextFor(this.name, scope, this.ancestor); - var func = getFunction(context, this.name, mustEvaluate); - if (func) { - return func.apply(context, args); - } - return undefined; - }; - - CallScope.prototype.accept = function accept(visitor) { - return visitor.visitCallScope(this); - }; - - CallScope.prototype.connect = function connect(binding, scope) { - var args = this.args; - var i = args.length; - while (i--) { - args[i].connect(binding, scope); - } - }; - - return CallScope; - }(Expression); - - var CallMember = exports.CallMember = function (_Expression11) { - _inherits(CallMember, _Expression11); - - function CallMember(object, name, args) { - - - var _this13 = _possibleConstructorReturn(this, _Expression11.call(this)); - - _this13.object = object; - _this13.name = name; - _this13.args = args; - return _this13; - } - - CallMember.prototype.evaluate = function evaluate(scope, lookupFunctions, mustEvaluate) { - var instance = this.object.evaluate(scope, lookupFunctions); - var args = evalList(scope, this.args, lookupFunctions); - var func = getFunction(instance, this.name, mustEvaluate); - if (func) { - return func.apply(instance, args); - } - return undefined; - }; - - CallMember.prototype.accept = function accept(visitor) { - return visitor.visitCallMember(this); - }; - - CallMember.prototype.connect = function connect(binding, scope) { - this.object.connect(binding, scope); - var obj = this.object.evaluate(scope); - if (getFunction(obj, this.name, false)) { - var args = this.args; - var _i8 = args.length; - while (_i8--) { - args[_i8].connect(binding, scope); - } - } - }; - - return CallMember; - }(Expression); - - var CallFunction = exports.CallFunction = function (_Expression12) { - _inherits(CallFunction, _Expression12); - - function CallFunction(func, args) { - - - var _this14 = _possibleConstructorReturn(this, _Expression12.call(this)); - - _this14.func = func; - _this14.args = args; - return _this14; - } - - CallFunction.prototype.evaluate = function evaluate(scope, lookupFunctions, mustEvaluate) { - var func = this.func.evaluate(scope, lookupFunctions); - if (typeof func === 'function') { - return func.apply(null, evalList(scope, this.args, lookupFunctions)); - } - if (!mustEvaluate && (func === null || func === undefined)) { - return undefined; - } - throw new Error(this.func + ' is not a function'); - }; - - CallFunction.prototype.accept = function accept(visitor) { - return visitor.visitCallFunction(this); - }; - - CallFunction.prototype.connect = function connect(binding, scope) { - this.func.connect(binding, scope); - var func = this.func.evaluate(scope); - if (typeof func === 'function') { - var args = this.args; - var _i9 = args.length; - while (_i9--) { - args[_i9].connect(binding, scope); - } - } - }; - - return CallFunction; - }(Expression); - - var Binary = exports.Binary = function (_Expression13) { - _inherits(Binary, _Expression13); - - function Binary(operation, left, right) { - - - var _this15 = _possibleConstructorReturn(this, _Expression13.call(this)); - - _this15.operation = operation; - _this15.left = left; - _this15.right = right; - return _this15; - } - - Binary.prototype.evaluate = function evaluate(scope, lookupFunctions) { - var left = this.left.evaluate(scope); - - switch (this.operation) { - case '&&': - return left && this.right.evaluate(scope); - case '||': - return left || this.right.evaluate(scope); - } - - var right = this.right.evaluate(scope); - - switch (this.operation) { - case '==': - return left == right; - case '===': - return left === right; - case '!=': - return left != right; - case '!==': - return left !== right; - } - - if (left === null || right === null || left === undefined || right === undefined) { - switch (this.operation) { - case '+': - if (left !== null && left !== undefined) return left; - if (right !== null && right !== undefined) return right; - return 0; - case '-': - if (left !== null && left !== undefined) return left; - if (right !== null && right !== undefined) return 0 - right; - return 0; - } - - return null; - } - - switch (this.operation) { - case '+': - return autoConvertAdd(left, right); - case '-': - return left - right; - case '*': - return left * right; - case '/': - return left / right; - case '%': - return left % right; - case '<': - return left < right; - case '>': - return left > right; - case '<=': - return left <= right; - case '>=': - return left >= right; - case '^': - return left ^ right; - } - - throw new Error('Internal error [' + this.operation + '] not handled'); - }; - - Binary.prototype.accept = function accept(visitor) { - return visitor.visitBinary(this); - }; - - Binary.prototype.connect = function connect(binding, scope) { - this.left.connect(binding, scope); - var left = this.left.evaluate(scope); - if (this.operation === '&&' && !left || this.operation === '||' && left) { - return; - } - this.right.connect(binding, scope); - }; - - return Binary; - }(Expression); - - var PrefixNot = exports.PrefixNot = function (_Expression14) { - _inherits(PrefixNot, _Expression14); - - function PrefixNot(operation, expression) { - - - var _this16 = _possibleConstructorReturn(this, _Expression14.call(this)); - - _this16.operation = operation; - _this16.expression = expression; - return _this16; - } - - PrefixNot.prototype.evaluate = function evaluate(scope, lookupFunctions) { - return !this.expression.evaluate(scope); - }; - - PrefixNot.prototype.accept = function accept(visitor) { - return visitor.visitPrefix(this); - }; - - PrefixNot.prototype.connect = function connect(binding, scope) { - this.expression.connect(binding, scope); - }; - - return PrefixNot; - }(Expression); - - var LiteralPrimitive = exports.LiteralPrimitive = function (_Expression15) { - _inherits(LiteralPrimitive, _Expression15); - - function LiteralPrimitive(value) { - - - var _this17 = _possibleConstructorReturn(this, _Expression15.call(this)); - - _this17.value = value; - return _this17; - } - - LiteralPrimitive.prototype.evaluate = function evaluate(scope, lookupFunctions) { - return this.value; - }; - - LiteralPrimitive.prototype.accept = function accept(visitor) { - return visitor.visitLiteralPrimitive(this); - }; - - LiteralPrimitive.prototype.connect = function connect(binding, scope) {}; - - return LiteralPrimitive; - }(Expression); - - var LiteralString = exports.LiteralString = function (_Expression16) { - _inherits(LiteralString, _Expression16); - - function LiteralString(value) { - - - var _this18 = _possibleConstructorReturn(this, _Expression16.call(this)); - - _this18.value = value; - return _this18; - } - - LiteralString.prototype.evaluate = function evaluate(scope, lookupFunctions) { - return this.value; - }; - - LiteralString.prototype.accept = function accept(visitor) { - return visitor.visitLiteralString(this); - }; - - LiteralString.prototype.connect = function connect(binding, scope) {}; - - return LiteralString; - }(Expression); - - var LiteralArray = exports.LiteralArray = function (_Expression17) { - _inherits(LiteralArray, _Expression17); - - function LiteralArray(elements) { - - - var _this19 = _possibleConstructorReturn(this, _Expression17.call(this)); - - _this19.elements = elements; - return _this19; - } - - LiteralArray.prototype.evaluate = function evaluate(scope, lookupFunctions) { - var elements = this.elements; - var result = []; - - for (var _i10 = 0, length = elements.length; _i10 < length; ++_i10) { - result[_i10] = elements[_i10].evaluate(scope, lookupFunctions); - } - - return result; - }; - - LiteralArray.prototype.accept = function accept(visitor) { - return visitor.visitLiteralArray(this); - }; - - LiteralArray.prototype.connect = function connect(binding, scope) { - var length = this.elements.length; - for (var _i11 = 0; _i11 < length; _i11++) { - this.elements[_i11].connect(binding, scope); - } - }; - - return LiteralArray; - }(Expression); - - var LiteralObject = exports.LiteralObject = function (_Expression18) { - _inherits(LiteralObject, _Expression18); - - function LiteralObject(keys, values) { - - - var _this20 = _possibleConstructorReturn(this, _Expression18.call(this)); - - _this20.keys = keys; - _this20.values = values; - return _this20; - } - - LiteralObject.prototype.evaluate = function evaluate(scope, lookupFunctions) { - var instance = {}; - var keys = this.keys; - var values = this.values; - - for (var _i12 = 0, length = keys.length; _i12 < length; ++_i12) { - instance[keys[_i12]] = values[_i12].evaluate(scope, lookupFunctions); - } - - return instance; - }; - - LiteralObject.prototype.accept = function accept(visitor) { - return visitor.visitLiteralObject(this); - }; - - LiteralObject.prototype.connect = function connect(binding, scope) { - var length = this.keys.length; - for (var _i13 = 0; _i13 < length; _i13++) { - this.values[_i13].connect(binding, scope); - } - }; - - return LiteralObject; - }(Expression); - - function evalList(scope, list, lookupFunctions) { - var length = list.length; - var result = []; - for (var _i14 = 0; _i14 < length; _i14++) { - result[_i14] = list[_i14].evaluate(scope, lookupFunctions); - } - return result; - } - - function autoConvertAdd(a, b) { - if (a !== null && b !== null) { - if (typeof a === 'string' && typeof b !== 'string') { - return a + b.toString(); - } - - if (typeof a !== 'string' && typeof b === 'string') { - return a.toString() + b; - } - - return a + b; - } - - if (a !== null) { - return a; - } - - if (b !== null) { - return b; - } - - return 0; - } - - function getFunction(obj, name, mustExist) { - var func = obj === null || obj === undefined ? null : obj[name]; - if (typeof func === 'function') { - return func; - } - if (!mustExist && (func === null || func === undefined)) { - return null; - } - throw new Error(name + ' is not a function'); - } - - function getKeyed(obj, key) { - if (Array.isArray(obj)) { - return obj[parseInt(key, 10)]; - } else if (obj) { - return obj[key]; - } else if (obj === null || obj === undefined) { - return undefined; - } - - return obj[key]; - } - - function setKeyed(obj, key, value) { - if (Array.isArray(obj)) { - var index = parseInt(key, 10); - - if (obj.length <= index) { - obj.length = index + 1; - } - - obj[index] = value; - } else { - obj[key] = value; - } - - return value; - } - - var Unparser = exports.Unparser = function () { - function Unparser(buffer) { - - - this.buffer = buffer; - } - - Unparser.unparse = function unparse(expression) { - var buffer = []; - var visitor = new Unparser(buffer); - - expression.accept(visitor); - - return buffer.join(''); - }; - - Unparser.prototype.write = function write(text) { - this.buffer.push(text); - }; - - Unparser.prototype.writeArgs = function writeArgs(args) { - this.write('('); - - for (var _i15 = 0, length = args.length; _i15 < length; ++_i15) { - if (_i15 !== 0) { - this.write(','); - } - - args[_i15].accept(this); - } - - this.write(')'); - }; - - Unparser.prototype.visitChain = function visitChain(chain) { - var expressions = chain.expressions; - - for (var _i16 = 0, length = expression.length; _i16 < length; ++_i16) { - if (_i16 !== 0) { - this.write(';'); - } - - expressions[_i16].accept(this); - } - }; - - Unparser.prototype.visitBindingBehavior = function visitBindingBehavior(behavior) { - var args = behavior.args; - - behavior.expression.accept(this); - this.write('&' + behavior.name); - - for (var _i17 = 0, length = args.length; _i17 < length; ++_i17) { - this.write(':'); - args[_i17].accept(this); - } - }; - - Unparser.prototype.visitValueConverter = function visitValueConverter(converter) { - var args = converter.args; - - converter.expression.accept(this); - this.write('|' + converter.name); - - for (var _i18 = 0, length = args.length; _i18 < length; ++_i18) { - this.write(':'); - args[_i18].accept(this); - } - }; - - Unparser.prototype.visitAssign = function visitAssign(assign) { - assign.target.accept(this); - this.write('='); - assign.value.accept(this); - }; - - Unparser.prototype.visitConditional = function visitConditional(conditional) { - conditional.condition.accept(this); - this.write('?'); - conditional.yes.accept(this); - this.write(':'); - conditional.no.accept(this); - }; - - Unparser.prototype.visitAccessThis = function visitAccessThis(access) { - if (access.ancestor === 0) { - this.write('$this'); - return; - } - this.write('$parent'); - var i = access.ancestor - 1; - while (i--) { - this.write('.$parent'); - } - }; - - Unparser.prototype.visitAccessScope = function visitAccessScope(access) { - var i = access.ancestor; - while (i--) { - this.write('$parent.'); - } - this.write(access.name); - }; - - Unparser.prototype.visitAccessMember = function visitAccessMember(access) { - access.object.accept(this); - this.write('.' + access.name); - }; - - Unparser.prototype.visitAccessKeyed = function visitAccessKeyed(access) { - access.object.accept(this); - this.write('['); - access.key.accept(this); - this.write(']'); - }; - - Unparser.prototype.visitCallScope = function visitCallScope(call) { - var i = call.ancestor; - while (i--) { - this.write('$parent.'); - } - this.write(call.name); - this.writeArgs(call.args); - }; - - Unparser.prototype.visitCallFunction = function visitCallFunction(call) { - call.func.accept(this); - this.writeArgs(call.args); - }; - - Unparser.prototype.visitCallMember = function visitCallMember(call) { - call.object.accept(this); - this.write('.' + call.name); - this.writeArgs(call.args); - }; - - Unparser.prototype.visitPrefix = function visitPrefix(prefix) { - this.write('(' + prefix.operation); - prefix.expression.accept(this); - this.write(')'); - }; - - Unparser.prototype.visitBinary = function visitBinary(binary) { - binary.left.accept(this); - this.write(binary.operation); - binary.right.accept(this); - }; - - Unparser.prototype.visitLiteralPrimitive = function visitLiteralPrimitive(literal) { - this.write('' + literal.value); - }; - - Unparser.prototype.visitLiteralArray = function visitLiteralArray(literal) { - var elements = literal.elements; - - this.write('['); - - for (var _i19 = 0, length = elements.length; _i19 < length; ++_i19) { - if (_i19 !== 0) { - this.write(','); - } - - elements[_i19].accept(this); - } - - this.write(']'); - }; - - Unparser.prototype.visitLiteralObject = function visitLiteralObject(literal) { - var keys = literal.keys; - var values = literal.values; - - this.write('{'); - - for (var _i20 = 0, length = keys.length; _i20 < length; ++_i20) { - if (_i20 !== 0) { - this.write(','); - } - - this.write('\'' + keys[_i20] + '\':'); - values[_i20].accept(this); - } - - this.write('}'); - }; - - Unparser.prototype.visitLiteralString = function visitLiteralString(literal) { - var escaped = literal.value.replace(/'/g, "\'"); - this.write('\'' + escaped + '\''); - }; - - return Unparser; - }(); - - var ExpressionCloner = exports.ExpressionCloner = function () { - function ExpressionCloner() { - - } - - ExpressionCloner.prototype.cloneExpressionArray = function cloneExpressionArray(array) { - var clonedArray = []; - var i = array.length; - while (i--) { - clonedArray[i] = array[i].accept(this); - } - return clonedArray; - }; - - ExpressionCloner.prototype.visitChain = function visitChain(chain) { - return new Chain(this.cloneExpressionArray(chain.expressions)); - }; - - ExpressionCloner.prototype.visitBindingBehavior = function visitBindingBehavior(behavior) { - return new BindingBehavior(behavior.expression.accept(this), behavior.name, this.cloneExpressionArray(behavior.args)); - }; - - ExpressionCloner.prototype.visitValueConverter = function visitValueConverter(converter) { - return new ValueConverter(converter.expression.accept(this), converter.name, this.cloneExpressionArray(converter.args)); - }; - - ExpressionCloner.prototype.visitAssign = function visitAssign(assign) { - return new Assign(assign.target.accept(this), assign.value.accept(this)); - }; - - ExpressionCloner.prototype.visitConditional = function visitConditional(conditional) { - return new Conditional(conditional.condition.accept(this), conditional.yes.accept(this), conditional.no.accept(this)); - }; - - ExpressionCloner.prototype.visitAccessThis = function visitAccessThis(access) { - return new AccessThis(access.ancestor); - }; - - ExpressionCloner.prototype.visitAccessScope = function visitAccessScope(access) { - return new AccessScope(access.name, access.ancestor); - }; - - ExpressionCloner.prototype.visitAccessMember = function visitAccessMember(access) { - return new AccessMember(access.object.accept(this), access.name); - }; - - ExpressionCloner.prototype.visitAccessKeyed = function visitAccessKeyed(access) { - return new AccessKeyed(access.object.accept(this), access.key.accept(this)); - }; - - ExpressionCloner.prototype.visitCallScope = function visitCallScope(call) { - return new CallScope(call.name, this.cloneExpressionArray(call.args), call.ancestor); - }; - - ExpressionCloner.prototype.visitCallFunction = function visitCallFunction(call) { - return new CallFunction(call.func.accept(this), this.cloneExpressionArray(call.args)); - }; - - ExpressionCloner.prototype.visitCallMember = function visitCallMember(call) { - return new CallMember(call.object.accept(this), call.name, this.cloneExpressionArray(call.args)); - }; - - ExpressionCloner.prototype.visitPrefix = function visitPrefix(prefix) { - return new PrefixNot(prefix.operation, prefix.expression.accept(this)); - }; - - ExpressionCloner.prototype.visitBinary = function visitBinary(binary) { - return new Binary(binary.operation, binary.left.accept(this), binary.right.accept(this)); - }; - - ExpressionCloner.prototype.visitLiteralPrimitive = function visitLiteralPrimitive(literal) { - return new LiteralPrimitive(literal); - }; - - ExpressionCloner.prototype.visitLiteralArray = function visitLiteralArray(literal) { - return new LiteralArray(this.cloneExpressionArray(literal.elements)); - }; - - ExpressionCloner.prototype.visitLiteralObject = function visitLiteralObject(literal) { - return new LiteralObject(literal.keys, this.cloneExpressionArray(literal.values)); - }; - - ExpressionCloner.prototype.visitLiteralString = function visitLiteralString(literal) { - return new LiteralString(literal.value); - }; - - return ExpressionCloner; - }(); - - function cloneExpression(expression) { - var visitor = new ExpressionCloner(); - return expression.accept(visitor); - } - - var bindingMode = exports.bindingMode = { - oneTime: 0, - oneWay: 1, - twoWay: 2 - }; - - var Token = exports.Token = function () { - function Token(index, text) { - - - this.index = index; - this.text = text; - } - - Token.prototype.withOp = function withOp(op) { - this.opKey = op; - return this; - }; - - Token.prototype.withGetterSetter = function withGetterSetter(key) { - this.key = key; - return this; - }; - - Token.prototype.withValue = function withValue(value) { - this.value = value; - return this; - }; - - Token.prototype.toString = function toString() { - return 'Token(' + this.text + ')'; - }; - - return Token; - }(); - - var Lexer = exports.Lexer = function () { - function Lexer() { - - } - - Lexer.prototype.lex = function lex(text) { - var scanner = new Scanner(text); - var tokens = []; - var token = scanner.scanToken(); - - while (token) { - tokens.push(token); - token = scanner.scanToken(); - } - - return tokens; - }; - - return Lexer; - }(); - - var Scanner = exports.Scanner = function () { - function Scanner(input) { - - - this.input = input; - this.length = input.length; - this.peek = 0; - this.index = -1; - - this.advance(); - } - - Scanner.prototype.scanToken = function scanToken() { - while (this.peek <= $SPACE) { - if (++this.index >= this.length) { - this.peek = $EOF; - return null; - } - - this.peek = this.input.charCodeAt(this.index); - } - - if (isIdentifierStart(this.peek)) { - return this.scanIdentifier(); - } - - if (isDigit(this.peek)) { - return this.scanNumber(this.index); - } - - var start = this.index; - - switch (this.peek) { - case $PERIOD: - this.advance(); - return isDigit(this.peek) ? this.scanNumber(start) : new Token(start, '.'); - case $LPAREN: - case $RPAREN: - case $LBRACE: - case $RBRACE: - case $LBRACKET: - case $RBRACKET: - case $COMMA: - case $COLON: - case $SEMICOLON: - return this.scanCharacter(start, String.fromCharCode(this.peek)); - case $SQ: - case $DQ: - return this.scanString(); - case $PLUS: - case $MINUS: - case $STAR: - case $SLASH: - case $PERCENT: - case $CARET: - case $QUESTION: - return this.scanOperator(start, String.fromCharCode(this.peek)); - case $LT: - case $GT: - case $BANG: - case $EQ: - return this.scanComplexOperator(start, $EQ, String.fromCharCode(this.peek), '='); - case $AMPERSAND: - return this.scanComplexOperator(start, $AMPERSAND, '&', '&'); - case $BAR: - return this.scanComplexOperator(start, $BAR, '|', '|'); - case $NBSP: - while (isWhitespace(this.peek)) { - this.advance(); - } - - return this.scanToken(); - } - - var character = String.fromCharCode(this.peek); - this.error('Unexpected character [' + character + ']'); - return null; - }; - - Scanner.prototype.scanCharacter = function scanCharacter(start, text) { - assert(this.peek === text.charCodeAt(0)); - this.advance(); - return new Token(start, text); - }; - - Scanner.prototype.scanOperator = function scanOperator(start, text) { - assert(this.peek === text.charCodeAt(0)); - assert(OPERATORS.indexOf(text) !== -1); - this.advance(); - return new Token(start, text).withOp(text); - }; - - Scanner.prototype.scanComplexOperator = function scanComplexOperator(start, code, one, two) { - assert(this.peek === one.charCodeAt(0)); - this.advance(); - - var text = one; - - if (this.peek === code) { - this.advance(); - text += two; - } - - if (this.peek === code) { - this.advance(); - text += two; - } - - assert(OPERATORS.indexOf(text) !== -1); - - return new Token(start, text).withOp(text); - }; - - Scanner.prototype.scanIdentifier = function scanIdentifier() { - assert(isIdentifierStart(this.peek)); - var start = this.index; - - this.advance(); - - while (isIdentifierPart(this.peek)) { - this.advance(); - } - - var text = this.input.substring(start, this.index); - var result = new Token(start, text); - - if (OPERATORS.indexOf(text) !== -1) { - result.withOp(text); - } else { - result.withGetterSetter(text); - } - - return result; - }; - - Scanner.prototype.scanNumber = function scanNumber(start) { - assert(isDigit(this.peek)); - var simple = this.index === start; - this.advance(); - - while (true) { - if (!isDigit(this.peek)) { - if (this.peek === $PERIOD) { - simple = false; - } else if (isExponentStart(this.peek)) { - this.advance(); - - if (isExponentSign(this.peek)) { - this.advance(); - } - - if (!isDigit(this.peek)) { - this.error('Invalid exponent', -1); - } - - simple = false; - } else { - break; - } - } - - this.advance(); - } - - var text = this.input.substring(start, this.index); - var value = simple ? parseInt(text, 10) : parseFloat(text); - return new Token(start, text).withValue(value); - }; - - Scanner.prototype.scanString = function scanString() { - assert(this.peek === $SQ || this.peek === $DQ); - - var start = this.index; - var quote = this.peek; - - this.advance(); - - var buffer = void 0; - var marker = this.index; - - while (this.peek !== quote) { - if (this.peek === $BACKSLASH) { - if (!buffer) { - buffer = []; - } - - buffer.push(this.input.substring(marker, this.index)); - this.advance(); - - var _unescaped = void 0; - - if (this.peek === $u) { - var hex = this.input.substring(this.index + 1, this.index + 5); - - if (!/[A-Z0-9]{4}/.test(hex)) { - this.error('Invalid unicode escape [\\u' + hex + ']'); - } - - _unescaped = parseInt(hex, 16); - - for (var _i21 = 0; _i21 < 5; ++_i21) { - this.advance(); - } - } else { - _unescaped = unescape(this.peek); - this.advance(); - } - - buffer.push(String.fromCharCode(_unescaped)); - marker = this.index; - } else if (this.peek === $EOF) { - this.error('Unterminated quote'); - } else { - this.advance(); - } - } - - var last = this.input.substring(marker, this.index); - this.advance(); - var text = this.input.substring(start, this.index); - - var unescaped = last; - - if (buffer !== null && buffer !== undefined) { - buffer.push(last); - unescaped = buffer.join(''); - } - - return new Token(start, text).withValue(unescaped); - }; - - Scanner.prototype.advance = function advance() { - if (++this.index >= this.length) { - this.peek = $EOF; - } else { - this.peek = this.input.charCodeAt(this.index); - } - }; - - Scanner.prototype.error = function error(message) { - var offset = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1]; - - var position = this.index + offset; - throw new Error('Lexer Error: ' + message + ' at column ' + position + ' in expression [' + this.input + ']'); - }; - - return Scanner; - }(); - - var OPERATORS = ['undefined', 'null', 'true', 'false', '+', '-', '*', '/', '%', '^', '=', '==', '===', '!=', '!==', '<', '>', '<=', '>=', '&&', '||', '&', '|', '!', '?']; - - var $EOF = 0; - var $TAB = 9; - var $LF = 10; - var $VTAB = 11; - var $FF = 12; - var $CR = 13; - var $SPACE = 32; - var $BANG = 33; - var $DQ = 34; - var $$ = 36; - var $PERCENT = 37; - var $AMPERSAND = 38; - var $SQ = 39; - var $LPAREN = 40; - var $RPAREN = 41; - var $STAR = 42; - var $PLUS = 43; - var $COMMA = 44; - var $MINUS = 45; - var $PERIOD = 46; - var $SLASH = 47; - var $COLON = 58; - var $SEMICOLON = 59; - var $LT = 60; - var $EQ = 61; - var $GT = 62; - var $QUESTION = 63; - - var $0 = 48; - var $9 = 57; - - var $A = 65; - var $E = 69; - var $Z = 90; - - var $LBRACKET = 91; - var $BACKSLASH = 92; - var $RBRACKET = 93; - var $CARET = 94; - var $_ = 95; - - var $a = 97; - var $e = 101; - var $f = 102; - var $n = 110; - var $r = 114; - var $t = 116; - var $u = 117; - var $v = 118; - var $z = 122; - - var $LBRACE = 123; - var $BAR = 124; - var $RBRACE = 125; - var $NBSP = 160; - - function isWhitespace(code) { - return code >= $TAB && code <= $SPACE || code === $NBSP; - } - - function isIdentifierStart(code) { - return $a <= code && code <= $z || $A <= code && code <= $Z || code === $_ || code === $$; - } - - function isIdentifierPart(code) { - return $a <= code && code <= $z || $A <= code && code <= $Z || $0 <= code && code <= $9 || code === $_ || code === $$; - } - - function isDigit(code) { - return $0 <= code && code <= $9; - } - - function isExponentStart(code) { - return code === $e || code === $E; - } - - function isExponentSign(code) { - return code === $MINUS || code === $PLUS; - } - - function unescape(code) { - switch (code) { - case $n: - return $LF; - case $f: - return $FF; - case $r: - return $CR; - case $t: - return $TAB; - case $v: - return $VTAB; - default: - return code; - } - } - - function assert(condition, message) { - if (!condition) { - throw message || 'Assertion failed'; - } - } - - var EOF = new Token(-1, null); - - var Parser = exports.Parser = function () { - function Parser() { - - - this.cache = {}; - this.lexer = new Lexer(); - } - - Parser.prototype.parse = function parse(input) { - input = input || ''; - - return this.cache[input] || (this.cache[input] = new ParserImplementation(this.lexer, input).parseChain()); - }; - - return Parser; - }(); - - var ParserImplementation = exports.ParserImplementation = function () { - function ParserImplementation(lexer, input) { - - - this.index = 0; - this.input = input; - this.tokens = lexer.lex(input); - } - - ParserImplementation.prototype.parseChain = function parseChain() { - var isChain = false; - var expressions = []; - - while (this.optional(';')) { - isChain = true; - } - - while (this.index < this.tokens.length) { - if (this.peek.text === ')' || this.peek.text === '}' || this.peek.text === ']') { - this.error('Unconsumed token ' + this.peek.text); - } - - var expr = this.parseBindingBehavior(); - expressions.push(expr); - - while (this.optional(';')) { - isChain = true; - } - - if (isChain) { - this.error('Multiple expressions are not allowed.'); - } - } - - return expressions.length === 1 ? expressions[0] : new Chain(expressions); - }; - - ParserImplementation.prototype.parseBindingBehavior = function parseBindingBehavior() { - var result = this.parseValueConverter(); - - while (this.optional('&')) { - var name = this.peek.text; - var args = []; - - this.advance(); - - while (this.optional(':')) { - args.push(this.parseExpression()); - } - - result = new BindingBehavior(result, name, args); - } - - return result; - }; - - ParserImplementation.prototype.parseValueConverter = function parseValueConverter() { - var result = this.parseExpression(); - - while (this.optional('|')) { - var name = this.peek.text; - var args = []; - - this.advance(); - - while (this.optional(':')) { - args.push(this.parseExpression()); - } - - result = new ValueConverter(result, name, args, [result].concat(args)); - } - - return result; - }; - - ParserImplementation.prototype.parseExpression = function parseExpression() { - var start = this.peek.index; - var result = this.parseConditional(); - - while (this.peek.text === '=') { - if (!result.isAssignable) { - var end = this.index < this.tokens.length ? this.peek.index : this.input.length; - var _expression = this.input.substring(start, end); - - this.error('Expression ' + _expression + ' is not assignable'); - } - - this.expect('='); - result = new Assign(result, this.parseConditional()); - } - - return result; - }; - - ParserImplementation.prototype.parseConditional = function parseConditional() { - var start = this.peek.index; - var result = this.parseLogicalOr(); - - if (this.optional('?')) { - var yes = this.parseExpression(); - - if (!this.optional(':')) { - var end = this.index < this.tokens.length ? this.peek.index : this.input.length; - var _expression2 = this.input.substring(start, end); - - this.error('Conditional expression ' + _expression2 + ' requires all 3 expressions'); - } - - var no = this.parseExpression(); - result = new Conditional(result, yes, no); - } - - return result; - }; - - ParserImplementation.prototype.parseLogicalOr = function parseLogicalOr() { - var result = this.parseLogicalAnd(); - - while (this.optional('||')) { - result = new Binary('||', result, this.parseLogicalAnd()); - } - - return result; - }; - - ParserImplementation.prototype.parseLogicalAnd = function parseLogicalAnd() { - var result = this.parseEquality(); - - while (this.optional('&&')) { - result = new Binary('&&', result, this.parseEquality()); - } - - return result; - }; - - ParserImplementation.prototype.parseEquality = function parseEquality() { - var result = this.parseRelational(); - - while (true) { - if (this.optional('==')) { - result = new Binary('==', result, this.parseRelational()); - } else if (this.optional('!=')) { - result = new Binary('!=', result, this.parseRelational()); - } else if (this.optional('===')) { - result = new Binary('===', result, this.parseRelational()); - } else if (this.optional('!==')) { - result = new Binary('!==', result, this.parseRelational()); - } else { - return result; - } - } - }; - - ParserImplementation.prototype.parseRelational = function parseRelational() { - var result = this.parseAdditive(); - - while (true) { - if (this.optional('<')) { - result = new Binary('<', result, this.parseAdditive()); - } else if (this.optional('>')) { - result = new Binary('>', result, this.parseAdditive()); - } else if (this.optional('<=')) { - result = new Binary('<=', result, this.parseAdditive()); - } else if (this.optional('>=')) { - result = new Binary('>=', result, this.parseAdditive()); - } else { - return result; - } - } - }; - - ParserImplementation.prototype.parseAdditive = function parseAdditive() { - var result = this.parseMultiplicative(); - - while (true) { - if (this.optional('+')) { - result = new Binary('+', result, this.parseMultiplicative()); - } else if (this.optional('-')) { - result = new Binary('-', result, this.parseMultiplicative()); - } else { - return result; - } - } - }; - - ParserImplementation.prototype.parseMultiplicative = function parseMultiplicative() { - var result = this.parsePrefix(); - - while (true) { - if (this.optional('*')) { - result = new Binary('*', result, this.parsePrefix()); - } else if (this.optional('%')) { - result = new Binary('%', result, this.parsePrefix()); - } else if (this.optional('/')) { - result = new Binary('/', result, this.parsePrefix()); - } else { - return result; - } - } - }; - - ParserImplementation.prototype.parsePrefix = function parsePrefix() { - if (this.optional('+')) { - return this.parsePrefix(); - } else if (this.optional('-')) { - return new Binary('-', new LiteralPrimitive(0), this.parsePrefix()); - } else if (this.optional('!')) { - return new PrefixNot('!', this.parsePrefix()); - } - - return this.parseAccessOrCallMember(); - }; - - ParserImplementation.prototype.parseAccessOrCallMember = function parseAccessOrCallMember() { - var result = this.parsePrimary(); - - while (true) { - if (this.optional('.')) { - var name = this.peek.text; - - this.advance(); - - if (this.optional('(')) { - var args = this.parseExpressionList(')'); - this.expect(')'); - if (result instanceof AccessThis) { - result = new CallScope(name, args, result.ancestor); - } else { - result = new CallMember(result, name, args); - } - } else { - if (result instanceof AccessThis) { - result = new AccessScope(name, result.ancestor); - } else { - result = new AccessMember(result, name); - } - } - } else if (this.optional('[')) { - var key = this.parseExpression(); - this.expect(']'); - result = new AccessKeyed(result, key); - } else if (this.optional('(')) { - var _args = this.parseExpressionList(')'); - this.expect(')'); - result = new CallFunction(result, _args); - } else { - return result; - } - } - }; - - ParserImplementation.prototype.parsePrimary = function parsePrimary() { - if (this.optional('(')) { - var result = this.parseExpression(); - this.expect(')'); - return result; - } else if (this.optional('null')) { - return new LiteralPrimitive(null); - } else if (this.optional('undefined')) { - return new LiteralPrimitive(undefined); - } else if (this.optional('true')) { - return new LiteralPrimitive(true); - } else if (this.optional('false')) { - return new LiteralPrimitive(false); - } else if (this.optional('[')) { - var elements = this.parseExpressionList(']'); - this.expect(']'); - return new LiteralArray(elements); - } else if (this.peek.text === '{') { - return this.parseObject(); - } else if (this.peek.key !== null && this.peek.key !== undefined) { - return this.parseAccessOrCallScope(); - } else if (this.peek.value !== null && this.peek.value !== undefined) { - var value = this.peek.value; - this.advance(); - return value instanceof String || typeof value === 'string' ? new LiteralString(value) : new LiteralPrimitive(value); - } else if (this.index >= this.tokens.length) { - throw new Error('Unexpected end of expression: ' + this.input); - } else { - this.error('Unexpected token ' + this.peek.text); - } - }; - - ParserImplementation.prototype.parseAccessOrCallScope = function parseAccessOrCallScope() { - var name = this.peek.key; - - this.advance(); - - if (name === '$this') { - return new AccessThis(0); - } - - var ancestor = 0; - while (name === '$parent') { - ancestor++; - if (this.optional('.')) { - name = this.peek.key; - this.advance(); - } else if (this.peek === EOF || this.peek.text === '(' || this.peek.text === ')' || this.peek.text === '[' || this.peek.text === '}' || this.peek.text === ',') { - return new AccessThis(ancestor); - } else { - this.error('Unexpected token ' + this.peek.text); - } - } - - if (this.optional('(')) { - var args = this.parseExpressionList(')'); - this.expect(')'); - return new CallScope(name, args, ancestor); - } - - return new AccessScope(name, ancestor); - }; - - ParserImplementation.prototype.parseObject = function parseObject() { - var keys = []; - var values = []; - - this.expect('{'); - - if (this.peek.text !== '}') { - do { - var peek = this.peek; - var value = peek.value; - keys.push(typeof value === 'string' ? value : peek.text); - - this.advance(); - if (peek.key && (this.peek.text === ',' || this.peek.text === '}')) { - --this.index; - values.push(this.parseAccessOrCallScope()); - } else { - this.expect(':'); - values.push(this.parseExpression()); - } - } while (this.optional(',')); - } - - this.expect('}'); - - return new LiteralObject(keys, values); - }; - - ParserImplementation.prototype.parseExpressionList = function parseExpressionList(terminator) { - var result = []; - - if (this.peek.text !== terminator) { - do { - result.push(this.parseExpression()); - } while (this.optional(',')); - } - - return result; - }; - - ParserImplementation.prototype.optional = function optional(text) { - if (this.peek.text === text) { - this.advance(); - return true; - } - - return false; - }; - - ParserImplementation.prototype.expect = function expect(text) { - if (this.peek.text === text) { - this.advance(); - } else { - this.error('Missing expected ' + text); - } - }; - - ParserImplementation.prototype.advance = function advance() { - this.index++; - }; - - ParserImplementation.prototype.error = function error(message) { - var location = this.index < this.tokens.length ? 'at column ' + (this.tokens[this.index].index + 1) + ' in' : 'at the end of the expression'; - - throw new Error('Parser Error: ' + message + ' ' + location + ' [' + this.input + ']'); - }; - - _createClass(ParserImplementation, [{ - key: 'peek', - get: function get() { - return this.index < this.tokens.length ? this.tokens[this.index] : EOF; - } - }]); - - return ParserImplementation; - }(); - - var mapProto = Map.prototype; - - function _getMapObserver(taskQueue, map) { - return ModifyMapObserver.for(taskQueue, map); - } - - exports.getMapObserver = _getMapObserver; - - var ModifyMapObserver = function (_ModifyCollectionObse2) { - _inherits(ModifyMapObserver, _ModifyCollectionObse2); - - function ModifyMapObserver(taskQueue, map) { - - - return _possibleConstructorReturn(this, _ModifyCollectionObse2.call(this, taskQueue, map)); - } - - ModifyMapObserver.for = function _for(taskQueue, map) { - if (!('__map_observer__' in map)) { - Reflect.defineProperty(map, '__map_observer__', { - value: ModifyMapObserver.create(taskQueue, map), - enumerable: false, configurable: false - }); - } - return map.__map_observer__; - }; - - ModifyMapObserver.create = function create(taskQueue, map) { - var observer = new ModifyMapObserver(taskQueue, map); - - var proto = mapProto; - if (proto.add !== map.add || proto.delete !== map.delete || proto.clear !== map.clear) { - proto = { - add: map.add, - delete: map.delete, - clear: map.clear - }; - } - - map.set = function () { - var hasValue = map.has(arguments[0]); - var type = hasValue ? 'update' : 'add'; - var oldValue = map.get(arguments[0]); - var methodCallResult = proto.set.apply(map, arguments); - if (!hasValue || oldValue !== map.get(arguments[0])) { - observer.addChangeRecord({ - type: type, - object: map, - key: arguments[0], - oldValue: oldValue - }); - } - return methodCallResult; - }; - - map.delete = function () { - var hasValue = map.has(arguments[0]); - var oldValue = map.get(arguments[0]); - var methodCallResult = proto.delete.apply(map, arguments); - if (hasValue) { - observer.addChangeRecord({ - type: 'delete', - object: map, - key: arguments[0], - oldValue: oldValue - }); - } - return methodCallResult; - }; - - map.clear = function () { - var methodCallResult = proto.clear.apply(map, arguments); - observer.addChangeRecord({ - type: 'clear', - object: map - }); - return methodCallResult; - }; - - return observer; - }; - - return ModifyMapObserver; - }(ModifyCollectionObserver); - - function findOriginalEventTarget(event) { - return event.path && event.path[0] || event.deepPath && event.deepPath[0] || event.target; - } - - function stopPropagation() { - this.standardStopPropagation(); - this.propagationStopped = true; - } - - function interceptStopPropagation(event) { - event.standardStopPropagation = event.stopPropagation; - event.stopPropagation = stopPropagation; - } - - function handleCapturedEvent(event) { - var interceptInstalled = false; - event.propagationStopped = false; - var target = findOriginalEventTarget(event); - - var orderedCallbacks = []; - - while (target) { - if (target.capturedCallbacks) { - var callback = target.capturedCallbacks[event.type]; - if (callback) { - if (!interceptInstalled) { - interceptStopPropagation(event); - interceptInstalled = true; - } - orderedCallbacks.push(callback); - } - } - target = target.parentNode; - } - for (var _i22 = orderedCallbacks.length - 1; _i22 >= 0; _i22--) { - var orderedCallback = orderedCallbacks[_i22]; - orderedCallback(event); - if (event.propagationStopped) { - break; - } - } - } - - var CapturedHandlerEntry = function () { - function CapturedHandlerEntry(eventName) { - - - this.eventName = eventName; - this.count = 0; - } - - CapturedHandlerEntry.prototype.increment = function increment() { - this.count++; - - if (this.count === 1) { - _aureliaPal.DOM.addEventListener(this.eventName, handleCapturedEvent, true); - } - }; - - CapturedHandlerEntry.prototype.decrement = function decrement() { - this.count--; - - if (this.count === 0) { - _aureliaPal.DOM.removeEventListener(this.eventName, handleCapturedEvent, true); - } - }; - - return CapturedHandlerEntry; - }(); - - function handleDelegatedEvent(event) { - var interceptInstalled = false; - event.propagationStopped = false; - var target = findOriginalEventTarget(event); - - while (target && !event.propagationStopped) { - if (target.delegatedCallbacks) { - var callback = target.delegatedCallbacks[event.type]; - if (callback) { - if (!interceptInstalled) { - interceptStopPropagation(event); - interceptInstalled = true; - } - callback(event); - } - } - - target = target.parentNode; - } - } - - var DelegateHandlerEntry = function () { - function DelegateHandlerEntry(eventName) { - - - this.eventName = eventName; - this.count = 0; - } - - DelegateHandlerEntry.prototype.increment = function increment() { - this.count++; - - if (this.count === 1) { - _aureliaPal.DOM.addEventListener(this.eventName, handleDelegatedEvent, false); - } - }; - - DelegateHandlerEntry.prototype.decrement = function decrement() { - this.count--; - - if (this.count === 0) { - _aureliaPal.DOM.removeEventListener(this.eventName, handleDelegatedEvent); - } - }; - - return DelegateHandlerEntry; - }(); - - var DefaultEventStrategy = function () { - function DefaultEventStrategy() { - - - this.delegatedHandlers = {}; - this.capturedHandlers = {}; - } - - DefaultEventStrategy.prototype.subscribe = function subscribe(target, targetEvent, callback, strategy) { - var _this22 = this; - - var delegatedHandlers = void 0; - var capturedHandlers = void 0; - var handlerEntry = void 0; - - if (strategy === delegationStrategy.bubbling) { - var _ret = function () { - delegatedHandlers = _this22.delegatedHandlers; - handlerEntry = delegatedHandlers[targetEvent] || (delegatedHandlers[targetEvent] = new DelegateHandlerEntry(targetEvent)); - var delegatedCallbacks = target.delegatedCallbacks || (target.delegatedCallbacks = {}); - - handlerEntry.increment(); - delegatedCallbacks[targetEvent] = callback; - - return { - v: function v() { - handlerEntry.decrement(); - delegatedCallbacks[targetEvent] = null; - } - }; - }(); - - if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v; - } - if (strategy === delegationStrategy.capturing) { - var _ret2 = function () { - capturedHandlers = _this22.capturedHandlers; - handlerEntry = capturedHandlers[targetEvent] || (capturedHandlers[targetEvent] = new CapturedHandlerEntry(targetEvent)); - var capturedCallbacks = target.capturedCallbacks || (target.capturedCallbacks = {}); - - handlerEntry.increment(); - capturedCallbacks[targetEvent] = callback; - - return { - v: function v() { - handlerEntry.decrement(); - capturedCallbacks[targetEvent] = null; - } - }; - }(); - - if ((typeof _ret2 === 'undefined' ? 'undefined' : _typeof(_ret2)) === "object") return _ret2.v; - } - - target.addEventListener(targetEvent, callback, false); - - return function () { - target.removeEventListener(targetEvent, callback); - }; - }; - - return DefaultEventStrategy; - }(); - - var delegationStrategy = exports.delegationStrategy = { - none: 0, - capturing: 1, - bubbling: 2 - }; - - var EventManager = exports.EventManager = function () { - function EventManager() { - - - this.elementHandlerLookup = {}; - this.eventStrategyLookup = {}; - - this.registerElementConfig({ - tagName: 'input', - properties: { - value: ['change', 'input'], - checked: ['change', 'input'], - files: ['change', 'input'] - } - }); - - this.registerElementConfig({ - tagName: 'textarea', - properties: { - value: ['change', 'input'] - } - }); - - this.registerElementConfig({ - tagName: 'select', - properties: { - value: ['change'] - } - }); - - this.registerElementConfig({ - tagName: 'content editable', - properties: { - value: ['change', 'input', 'blur', 'keyup', 'paste'] - } - }); - - this.registerElementConfig({ - tagName: 'scrollable element', - properties: { - scrollTop: ['scroll'], - scrollLeft: ['scroll'] - } - }); - - this.defaultEventStrategy = new DefaultEventStrategy(); - } - - EventManager.prototype.registerElementConfig = function registerElementConfig(config) { - var tagName = config.tagName.toLowerCase(); - var properties = config.properties; - var propertyName = void 0; - - this.elementHandlerLookup[tagName] = {}; - - for (propertyName in properties) { - if (properties.hasOwnProperty(propertyName)) { - this.registerElementPropertyConfig(tagName, propertyName, properties[propertyName]); - } - } - }; - - EventManager.prototype.registerElementPropertyConfig = function registerElementPropertyConfig(tagName, propertyName, events) { - this.elementHandlerLookup[tagName][propertyName] = this.createElementHandler(events); - }; - - EventManager.prototype.createElementHandler = function createElementHandler(events) { - return { - subscribe: function subscribe(target, callback) { - events.forEach(function (changeEvent) { - target.addEventListener(changeEvent, callback, false); - }); - - return function () { - events.forEach(function (changeEvent) { - target.removeEventListener(changeEvent, callback); - }); - }; - } - }; - }; - - EventManager.prototype.registerElementHandler = function registerElementHandler(tagName, handler) { - this.elementHandlerLookup[tagName.toLowerCase()] = handler; - }; - - EventManager.prototype.registerEventStrategy = function registerEventStrategy(eventName, strategy) { - this.eventStrategyLookup[eventName] = strategy; - }; - - EventManager.prototype.getElementHandler = function getElementHandler(target, propertyName) { - var tagName = void 0; - var lookup = this.elementHandlerLookup; - - if (target.tagName) { - tagName = target.tagName.toLowerCase(); - - if (lookup[tagName] && lookup[tagName][propertyName]) { - return lookup[tagName][propertyName]; - } - - if (propertyName === 'textContent' || propertyName === 'innerHTML') { - return lookup['content editable'].value; - } - - if (propertyName === 'scrollTop' || propertyName === 'scrollLeft') { - return lookup['scrollable element'][propertyName]; - } - } - - return null; - }; - - EventManager.prototype.addEventListener = function addEventListener(target, targetEvent, callback, delegate) { - return (this.eventStrategyLookup[targetEvent] || this.defaultEventStrategy).subscribe(target, targetEvent, callback, delegate); - }; - - return EventManager; - }(); - - var DirtyChecker = exports.DirtyChecker = function () { - function DirtyChecker() { - - - this.tracked = []; - this.checkDelay = 120; - } - - DirtyChecker.prototype.addProperty = function addProperty(property) { - var tracked = this.tracked; - - tracked.push(property); - - if (tracked.length === 1) { - this.scheduleDirtyCheck(); - } - }; - - DirtyChecker.prototype.removeProperty = function removeProperty(property) { - var tracked = this.tracked; - tracked.splice(tracked.indexOf(property), 1); - }; - - DirtyChecker.prototype.scheduleDirtyCheck = function scheduleDirtyCheck() { - var _this23 = this; - - setTimeout(function () { - return _this23.check(); - }, this.checkDelay); - }; - - DirtyChecker.prototype.check = function check() { - var tracked = this.tracked; - var i = tracked.length; - - while (i--) { - var current = tracked[i]; - - if (current.isDirty()) { - current.call(); - } - } - - if (tracked.length) { - this.scheduleDirtyCheck(); - } - }; - - return DirtyChecker; - }(); - - var DirtyCheckProperty = exports.DirtyCheckProperty = (_dec5 = subscriberCollection(), _dec5(_class5 = function () { - function DirtyCheckProperty(dirtyChecker, obj, propertyName) { - - - this.dirtyChecker = dirtyChecker; - this.obj = obj; - this.propertyName = propertyName; - } - - DirtyCheckProperty.prototype.getValue = function getValue() { - return this.obj[this.propertyName]; - }; - - DirtyCheckProperty.prototype.setValue = function setValue(newValue) { - this.obj[this.propertyName] = newValue; - }; - - DirtyCheckProperty.prototype.call = function call() { - var oldValue = this.oldValue; - var newValue = this.getValue(); - - this.callSubscribers(newValue, oldValue); - - this.oldValue = newValue; - }; - - DirtyCheckProperty.prototype.isDirty = function isDirty() { - return this.oldValue !== this.obj[this.propertyName]; - }; - - DirtyCheckProperty.prototype.subscribe = function subscribe(context, callable) { - if (!this.hasSubscribers()) { - this.oldValue = this.getValue(); - this.dirtyChecker.addProperty(this); - } - this.addSubscriber(context, callable); - }; - - DirtyCheckProperty.prototype.unsubscribe = function unsubscribe(context, callable) { - if (this.removeSubscriber(context, callable) && !this.hasSubscribers()) { - this.dirtyChecker.removeProperty(this); - } - }; - - return DirtyCheckProperty; - }()) || _class5); - - - var logger = LogManager.getLogger('property-observation'); - - var propertyAccessor = exports.propertyAccessor = { - getValue: function getValue(obj, propertyName) { - return obj[propertyName]; - }, - setValue: function setValue(value, obj, propertyName) { - obj[propertyName] = value; - } - }; - - var PrimitiveObserver = exports.PrimitiveObserver = function () { - function PrimitiveObserver(primitive, propertyName) { - - - this.doNotCache = true; - - this.primitive = primitive; - this.propertyName = propertyName; - } - - PrimitiveObserver.prototype.getValue = function getValue() { - return this.primitive[this.propertyName]; - }; - - PrimitiveObserver.prototype.setValue = function setValue() { - var type = _typeof(this.primitive); - throw new Error('The ' + this.propertyName + ' property of a ' + type + ' (' + this.primitive + ') cannot be assigned.'); - }; - - PrimitiveObserver.prototype.subscribe = function subscribe() {}; - - PrimitiveObserver.prototype.unsubscribe = function unsubscribe() {}; - - return PrimitiveObserver; - }(); - - var SetterObserver = exports.SetterObserver = (_dec6 = subscriberCollection(), _dec6(_class7 = function () { - function SetterObserver(taskQueue, obj, propertyName) { - - - this.taskQueue = taskQueue; - this.obj = obj; - this.propertyName = propertyName; - this.queued = false; - this.observing = false; - } - - SetterObserver.prototype.getValue = function getValue() { - return this.obj[this.propertyName]; - }; - - SetterObserver.prototype.setValue = function setValue(newValue) { - this.obj[this.propertyName] = newValue; - }; - - SetterObserver.prototype.getterValue = function getterValue() { - return this.currentValue; - }; - - SetterObserver.prototype.setterValue = function setterValue(newValue) { - var oldValue = this.currentValue; - - if (oldValue !== newValue) { - if (!this.queued) { - this.oldValue = oldValue; - this.queued = true; - this.taskQueue.queueMicroTask(this); - } - - this.currentValue = newValue; - } - }; - - SetterObserver.prototype.call = function call() { - var oldValue = this.oldValue; - var newValue = this.currentValue; - - this.queued = false; - - this.callSubscribers(newValue, oldValue); - }; - - SetterObserver.prototype.subscribe = function subscribe(context, callable) { - if (!this.observing) { - this.convertProperty(); - } - this.addSubscriber(context, callable); - }; - - SetterObserver.prototype.unsubscribe = function unsubscribe(context, callable) { - this.removeSubscriber(context, callable); - }; - - SetterObserver.prototype.convertProperty = function convertProperty() { - this.observing = true; - this.currentValue = this.obj[this.propertyName]; - this.setValue = this.setterValue; - this.getValue = this.getterValue; - - if (!Reflect.defineProperty(this.obj, this.propertyName, { - configurable: true, - enumerable: this.propertyName in this.obj ? this.obj.propertyIsEnumerable(this.propertyName) : true, - get: this.getValue.bind(this), - set: this.setValue.bind(this) - })) { - logger.warn('Cannot observe property \'' + this.propertyName + '\' of object', this.obj); - } - }; - - return SetterObserver; - }()) || _class7); - - var XLinkAttributeObserver = exports.XLinkAttributeObserver = function () { - function XLinkAttributeObserver(element, propertyName, attributeName) { - - - this.element = element; - this.propertyName = propertyName; - this.attributeName = attributeName; - } - - XLinkAttributeObserver.prototype.getValue = function getValue() { - return this.element.getAttributeNS('http://www.w3.org/1999/xlink', this.attributeName); - }; - - XLinkAttributeObserver.prototype.setValue = function setValue(newValue) { - return this.element.setAttributeNS('http://www.w3.org/1999/xlink', this.attributeName, newValue); - }; - - XLinkAttributeObserver.prototype.subscribe = function subscribe() { - throw new Error('Observation of a "' + this.element.nodeName + '" element\'s "' + this.propertyName + '" property is not supported.'); - }; - - return XLinkAttributeObserver; - }(); - - var dataAttributeAccessor = exports.dataAttributeAccessor = { - getValue: function getValue(obj, propertyName) { - return obj.getAttribute(propertyName); - }, - setValue: function setValue(value, obj, propertyName) { - return obj.setAttribute(propertyName, value); - } - }; - - var DataAttributeObserver = exports.DataAttributeObserver = function () { - function DataAttributeObserver(element, propertyName) { - - - this.element = element; - this.propertyName = propertyName; - } - - DataAttributeObserver.prototype.getValue = function getValue() { - return this.element.getAttribute(this.propertyName); - }; - - DataAttributeObserver.prototype.setValue = function setValue(newValue) { - return this.element.setAttribute(this.propertyName, newValue); - }; - - DataAttributeObserver.prototype.subscribe = function subscribe() { - throw new Error('Observation of a "' + this.element.nodeName + '" element\'s "' + this.propertyName + '" property is not supported.'); - }; - - return DataAttributeObserver; - }(); - - var StyleObserver = exports.StyleObserver = function () { - function StyleObserver(element, propertyName) { - - - this.element = element; - this.propertyName = propertyName; - - this.styles = null; - this.version = 0; - } - - StyleObserver.prototype.getValue = function getValue() { - return this.element.style.cssText; - }; - - StyleObserver.prototype._setProperty = function _setProperty(style, value) { - var priority = ''; - - if (value !== null && value !== undefined && typeof value.indexOf === 'function' && value.indexOf('!important') !== -1) { - priority = 'important'; - value = value.replace('!important', ''); - } - this.element.style.setProperty(style, value, priority); - }; - - StyleObserver.prototype.setValue = function setValue(newValue) { - var styles = this.styles || {}; - var style = void 0; - var version = this.version; - - if (newValue !== null && newValue !== undefined) { - if (newValue instanceof Object) { - var value = void 0; - for (style in newValue) { - if (newValue.hasOwnProperty(style)) { - value = newValue[style]; - style = style.replace(/([A-Z])/g, function (m) { - return '-' + m.toLowerCase(); - }); - styles[style] = version; - this._setProperty(style, value); - } - } - } else if (newValue.length) { - var rx = /\s*([\w\-]+)\s*:\s*((?:(?:[\w\-]+\(\s*(?:"(?:\\"|[^"])*"|'(?:\\'|[^'])*'|[\w\-]+\(\s*(?:^"(?:\\"|[^"])*"|'(?:\\'|[^'])*'|[^\)]*)\),?|[^\)]*)\),?|"(?:\\"|[^"])*"|'(?:\\'|[^'])*'|[^;]*),?\s*)+);?/g; - var pair = void 0; - while ((pair = rx.exec(newValue)) !== null) { - style = pair[1]; - if (!style) { - continue; - } - - styles[style] = version; - this._setProperty(style, pair[2]); - } - } - } - - this.styles = styles; - this.version += 1; - - if (version === 0) { - return; - } - - version -= 1; - for (style in styles) { - if (!styles.hasOwnProperty(style) || styles[style] !== version) { - continue; - } - - this.element.style.removeProperty(style); - } - }; - - StyleObserver.prototype.subscribe = function subscribe() { - throw new Error('Observation of a "' + this.element.nodeName + '" element\'s "' + this.propertyName + '" property is not supported.'); - }; - - return StyleObserver; - }(); - - var ValueAttributeObserver = exports.ValueAttributeObserver = (_dec7 = subscriberCollection(), _dec7(_class8 = function () { - function ValueAttributeObserver(element, propertyName, handler) { - - - this.element = element; - this.propertyName = propertyName; - this.handler = handler; - if (propertyName === 'files') { - this.setValue = function () {}; - } - } - - ValueAttributeObserver.prototype.getValue = function getValue() { - return this.element[this.propertyName]; - }; - - ValueAttributeObserver.prototype.setValue = function setValue(newValue) { - newValue = newValue === undefined || newValue === null ? '' : newValue; - if (this.element[this.propertyName] !== newValue) { - this.element[this.propertyName] = newValue; - this.notify(); - } - }; - - ValueAttributeObserver.prototype.notify = function notify() { - var oldValue = this.oldValue; - var newValue = this.getValue(); - - this.callSubscribers(newValue, oldValue); - - this.oldValue = newValue; - }; - - ValueAttributeObserver.prototype.subscribe = function subscribe(context, callable) { - if (!this.hasSubscribers()) { - this.oldValue = this.getValue(); - this.disposeHandler = this.handler.subscribe(this.element, this.notify.bind(this)); - } - - this.addSubscriber(context, callable); - }; - - ValueAttributeObserver.prototype.unsubscribe = function unsubscribe(context, callable) { - if (this.removeSubscriber(context, callable) && !this.hasSubscribers()) { - this.disposeHandler(); - this.disposeHandler = null; - } - }; - - return ValueAttributeObserver; - }()) || _class8); - - - var checkedArrayContext = 'CheckedObserver:array'; - var checkedValueContext = 'CheckedObserver:value'; - - var CheckedObserver = exports.CheckedObserver = (_dec8 = subscriberCollection(), _dec8(_class9 = function () { - function CheckedObserver(element, handler, observerLocator) { - - - this.element = element; - this.handler = handler; - this.observerLocator = observerLocator; - } - - CheckedObserver.prototype.getValue = function getValue() { - return this.value; - }; - - CheckedObserver.prototype.setValue = function setValue(newValue) { - if (this.value === newValue) { - return; - } - - if (this.arrayObserver) { - this.arrayObserver.unsubscribe(checkedArrayContext, this); - this.arrayObserver = null; - } - - if (this.element.type === 'checkbox' && Array.isArray(newValue)) { - this.arrayObserver = this.observerLocator.getArrayObserver(newValue); - this.arrayObserver.subscribe(checkedArrayContext, this); - } - - this.oldValue = this.value; - this.value = newValue; - this.synchronizeElement(); - this.notify(); - - if (!this.initialSync) { - this.initialSync = true; - this.observerLocator.taskQueue.queueMicroTask(this); - } - }; - - CheckedObserver.prototype.call = function call(context, splices) { - this.synchronizeElement(); - - if (!this.valueObserver) { - this.valueObserver = this.element.__observers__.model || this.element.__observers__.value; - if (this.valueObserver) { - this.valueObserver.subscribe(checkedValueContext, this); - } - } - }; - - CheckedObserver.prototype.synchronizeElement = function synchronizeElement() { - var value = this.value; - var element = this.element; - var elementValue = element.hasOwnProperty('model') ? element.model : element.value; - var isRadio = element.type === 'radio'; - var matcher = element.matcher || function (a, b) { - return a === b; - }; - - element.checked = isRadio && !!matcher(value, elementValue) || !isRadio && value === true || !isRadio && Array.isArray(value) && value.findIndex(function (item) { - return !!matcher(item, elementValue); - }) !== -1; - }; - - CheckedObserver.prototype.synchronizeValue = function synchronizeValue() { - var value = this.value; - var element = this.element; - var elementValue = element.hasOwnProperty('model') ? element.model : element.value; - var index = void 0; - var matcher = element.matcher || function (a, b) { - return a === b; - }; - - if (element.type === 'checkbox') { - if (Array.isArray(value)) { - index = value.findIndex(function (item) { - return !!matcher(item, elementValue); - }); - if (element.checked && index === -1) { - value.push(elementValue); - } else if (!element.checked && index !== -1) { - value.splice(index, 1); - } - - return; - } - - value = element.checked; - } else if (element.checked) { - value = elementValue; - } else { - return; - } - - this.oldValue = this.value; - this.value = value; - this.notify(); - }; - - CheckedObserver.prototype.notify = function notify() { - var oldValue = this.oldValue; - var newValue = this.value; - - this.callSubscribers(newValue, oldValue); - }; - - CheckedObserver.prototype.subscribe = function subscribe(context, callable) { - if (!this.hasSubscribers()) { - this.disposeHandler = this.handler.subscribe(this.element, this.synchronizeValue.bind(this, false)); - } - this.addSubscriber(context, callable); - }; - - CheckedObserver.prototype.unsubscribe = function unsubscribe(context, callable) { - if (this.removeSubscriber(context, callable) && !this.hasSubscribers()) { - this.disposeHandler(); - this.disposeHandler = null; - } - }; - - CheckedObserver.prototype.unbind = function unbind() { - if (this.arrayObserver) { - this.arrayObserver.unsubscribe(checkedArrayContext, this); - this.arrayObserver = null; - } - if (this.valueObserver) { - this.valueObserver.unsubscribe(checkedValueContext, this); - } - }; - - return CheckedObserver; - }()) || _class9); - - - var selectArrayContext = 'SelectValueObserver:array'; - - var SelectValueObserver = exports.SelectValueObserver = (_dec9 = subscriberCollection(), _dec9(_class10 = function () { - function SelectValueObserver(element, handler, observerLocator) { - - - this.element = element; - this.handler = handler; - this.observerLocator = observerLocator; - } - - SelectValueObserver.prototype.getValue = function getValue() { - return this.value; - }; - - SelectValueObserver.prototype.setValue = function setValue(newValue) { - if (newValue !== null && newValue !== undefined && this.element.multiple && !Array.isArray(newValue)) { - throw new Error('Only null or Array instances can be bound to a multi-select.'); - } - if (this.value === newValue) { - return; - } - - if (this.arrayObserver) { - this.arrayObserver.unsubscribe(selectArrayContext, this); - this.arrayObserver = null; - } - - if (Array.isArray(newValue)) { - this.arrayObserver = this.observerLocator.getArrayObserver(newValue); - this.arrayObserver.subscribe(selectArrayContext, this); - } - - this.oldValue = this.value; - this.value = newValue; - this.synchronizeOptions(); - this.notify(); - - if (!this.initialSync) { - this.initialSync = true; - this.observerLocator.taskQueue.queueMicroTask(this); - } - }; - - SelectValueObserver.prototype.call = function call(context, splices) { - this.synchronizeOptions(); - }; - - SelectValueObserver.prototype.synchronizeOptions = function synchronizeOptions() { - var value = this.value; - var clear = void 0; - var isArray = void 0; - - if (value === null || value === undefined) { - clear = true; - } else if (Array.isArray(value)) { - isArray = true; - } - - var options = this.element.options; - var i = options.length; - var matcher = this.element.matcher || function (a, b) { - return a === b; - }; - - var _loop = function _loop() { - var option = options.item(i); - if (clear) { - option.selected = false; - return 'continue'; - } - var optionValue = option.hasOwnProperty('model') ? option.model : option.value; - if (isArray) { - option.selected = value.findIndex(function (item) { - return !!matcher(optionValue, item); - }) !== -1; - return 'continue'; - } - option.selected = !!matcher(optionValue, value); - }; - - while (i--) { - var _ret3 = _loop(); - - if (_ret3 === 'continue') continue; - } - }; - - SelectValueObserver.prototype.synchronizeValue = function synchronizeValue() { - var _this24 = this; - - var options = this.element.options; - var count = 0; - var value = []; - - for (var _i23 = 0, ii = options.length; _i23 < ii; _i23++) { - var _option = options.item(_i23); - if (!_option.selected) { - continue; - } - value.push(_option.hasOwnProperty('model') ? _option.model : _option.value); - count++; - } - - if (this.element.multiple) { - if (Array.isArray(this.value)) { - var _ret4 = function () { - var matcher = _this24.element.matcher || function (a, b) { - return a === b; - }; - - var i = 0; - - var _loop2 = function _loop2() { - var a = _this24.value[i]; - if (value.findIndex(function (b) { - return matcher(a, b); - }) === -1) { - _this24.value.splice(i, 1); - } else { - i++; - } - }; - - while (i < _this24.value.length) { - _loop2(); - } - - i = 0; - - var _loop3 = function _loop3() { - var a = value[i]; - if (_this24.value.findIndex(function (b) { - return matcher(a, b); - }) === -1) { - _this24.value.push(a); - } - i++; - }; - - while (i < value.length) { - _loop3(); - } - return { - v: void 0 - }; - }(); - - if ((typeof _ret4 === 'undefined' ? 'undefined' : _typeof(_ret4)) === "object") return _ret4.v; - } - } else { - if (count === 0) { - value = null; - } else { - value = value[0]; - } - } - - if (value !== this.value) { - this.oldValue = this.value; - this.value = value; - this.notify(); - } - }; - - SelectValueObserver.prototype.notify = function notify() { - var oldValue = this.oldValue; - var newValue = this.value; - - this.callSubscribers(newValue, oldValue); - }; - - SelectValueObserver.prototype.subscribe = function subscribe(context, callable) { - if (!this.hasSubscribers()) { - this.disposeHandler = this.handler.subscribe(this.element, this.synchronizeValue.bind(this, false)); - } - this.addSubscriber(context, callable); - }; - - SelectValueObserver.prototype.unsubscribe = function unsubscribe(context, callable) { - if (this.removeSubscriber(context, callable) && !this.hasSubscribers()) { - this.disposeHandler(); - this.disposeHandler = null; - } - }; - - SelectValueObserver.prototype.bind = function bind() { - var _this25 = this; - - this.domObserver = _aureliaPal.DOM.createMutationObserver(function () { - _this25.synchronizeOptions(); - _this25.synchronizeValue(); - }); - this.domObserver.observe(this.element, { childList: true, subtree: true }); - }; - - SelectValueObserver.prototype.unbind = function unbind() { - this.domObserver.disconnect(); - this.domObserver = null; - - if (this.arrayObserver) { - this.arrayObserver.unsubscribe(selectArrayContext, this); - this.arrayObserver = null; - } - }; - - return SelectValueObserver; - }()) || _class10); - - var ClassObserver = exports.ClassObserver = function () { - function ClassObserver(element) { - - - this.element = element; - this.doNotCache = true; - this.value = ''; - this.version = 0; - } - - ClassObserver.prototype.getValue = function getValue() { - return this.value; - }; - - ClassObserver.prototype.setValue = function setValue(newValue) { - var nameIndex = this.nameIndex || {}; - var version = this.version; - var names = void 0; - var name = void 0; - - if (newValue !== null && newValue !== undefined && newValue.length) { - names = newValue.split(/\s+/); - for (var _i24 = 0, length = names.length; _i24 < length; _i24++) { - name = names[_i24]; - if (name === '') { - continue; - } - nameIndex[name] = version; - this.element.classList.add(name); - } - } - - this.value = newValue; - this.nameIndex = nameIndex; - this.version += 1; - - if (version === 0) { - return; - } - - version -= 1; - for (name in nameIndex) { - if (!nameIndex.hasOwnProperty(name) || nameIndex[name] !== version) { - continue; - } - this.element.classList.remove(name); - } - }; - - ClassObserver.prototype.subscribe = function subscribe() { - throw new Error('Observation of a "' + this.element.nodeName + '" element\'s "class" property is not supported.'); - }; - - return ClassObserver; - }(); - - function hasDeclaredDependencies(descriptor) { - return !!(descriptor && descriptor.get && descriptor.get.dependencies); - } - - function declarePropertyDependencies(ctor, propertyName, dependencies) { - var descriptor = Object.getOwnPropertyDescriptor(ctor.prototype, propertyName); - descriptor.get.dependencies = dependencies; - } - - function computedFrom() { - for (var _len = arguments.length, rest = Array(_len), _key = 0; _key < _len; _key++) { - rest[_key] = arguments[_key]; - } - - return function (target, key, descriptor) { - descriptor.get.dependencies = rest; - return descriptor; - }; - } - - var ComputedExpression = exports.ComputedExpression = function (_Expression19) { - _inherits(ComputedExpression, _Expression19); - - function ComputedExpression(name, dependencies) { - - - var _this26 = _possibleConstructorReturn(this, _Expression19.call(this)); - - _this26.name = name; - _this26.dependencies = dependencies; - _this26.isAssignable = true; - return _this26; - } - - ComputedExpression.prototype.evaluate = function evaluate(scope, lookupFunctions) { - return scope.bindingContext[this.name]; - }; - - ComputedExpression.prototype.assign = function assign(scope, value) { - scope.bindingContext[this.name] = value; - }; - - ComputedExpression.prototype.accept = function accept(visitor) { - throw new Error('not implemented'); - }; - - ComputedExpression.prototype.connect = function connect(binding, scope) { - var dependencies = this.dependencies; - var i = dependencies.length; - while (i--) { - dependencies[i].connect(binding, scope); - } - }; - - return ComputedExpression; - }(Expression); - - function createComputedObserver(obj, propertyName, descriptor, observerLocator) { - var dependencies = descriptor.get.dependencies; - if (!(dependencies instanceof ComputedExpression)) { - var _i25 = dependencies.length; - while (_i25--) { - dependencies[_i25] = observerLocator.parser.parse(dependencies[_i25]); - } - dependencies = descriptor.get.dependencies = new ComputedExpression(propertyName, dependencies); - } - - var scope = { bindingContext: obj, overrideContext: createOverrideContext(obj) }; - return new ExpressionObserver(scope, dependencies, observerLocator); - } - - var elements = exports.elements = { - a: ['class', 'externalResourcesRequired', 'id', 'onactivate', 'onclick', 'onfocusin', 'onfocusout', 'onload', 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'requiredExtensions', 'requiredFeatures', 'style', 'systemLanguage', 'target', 'transform', 'xlink:actuate', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type', 'xml:base', 'xml:lang', 'xml:space'], - altGlyph: ['class', 'dx', 'dy', 'externalResourcesRequired', 'format', 'glyphRef', 'id', 'onactivate', 'onclick', 'onfocusin', 'onfocusout', 'onload', 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'requiredExtensions', 'requiredFeatures', 'rotate', 'style', 'systemLanguage', 'x', 'xlink:actuate', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type', 'xml:base', 'xml:lang', 'xml:space', 'y'], - altGlyphDef: ['id', 'xml:base', 'xml:lang', 'xml:space'], - altGlyphItem: ['id', 'xml:base', 'xml:lang', 'xml:space'], - animate: ['accumulate', 'additive', 'attributeName', 'attributeType', 'begin', 'by', 'calcMode', 'dur', 'end', 'externalResourcesRequired', 'fill', 'from', 'id', 'keySplines', 'keyTimes', 'max', 'min', 'onbegin', 'onend', 'onload', 'onrepeat', 'repeatCount', 'repeatDur', 'requiredExtensions', 'requiredFeatures', 'restart', 'systemLanguage', 'to', 'values', 'xlink:actuate', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type', 'xml:base', 'xml:lang', 'xml:space'], - animateColor: ['accumulate', 'additive', 'attributeName', 'attributeType', 'begin', 'by', 'calcMode', 'dur', 'end', 'externalResourcesRequired', 'fill', 'from', 'id', 'keySplines', 'keyTimes', 'max', 'min', 'onbegin', 'onend', 'onload', 'onrepeat', 'repeatCount', 'repeatDur', 'requiredExtensions', 'requiredFeatures', 'restart', 'systemLanguage', 'to', 'values', 'xlink:actuate', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type', 'xml:base', 'xml:lang', 'xml:space'], - animateMotion: ['accumulate', 'additive', 'begin', 'by', 'calcMode', 'dur', 'end', 'externalResourcesRequired', 'fill', 'from', 'id', 'keyPoints', 'keySplines', 'keyTimes', 'max', 'min', 'onbegin', 'onend', 'onload', 'onrepeat', 'origin', 'path', 'repeatCount', 'repeatDur', 'requiredExtensions', 'requiredFeatures', 'restart', 'rotate', 'systemLanguage', 'to', 'values', 'xlink:actuate', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type', 'xml:base', 'xml:lang', 'xml:space'], - animateTransform: ['accumulate', 'additive', 'attributeName', 'attributeType', 'begin', 'by', 'calcMode', 'dur', 'end', 'externalResourcesRequired', 'fill', 'from', 'id', 'keySplines', 'keyTimes', 'max', 'min', 'onbegin', 'onend', 'onload', 'onrepeat', 'repeatCount', 'repeatDur', 'requiredExtensions', 'requiredFeatures', 'restart', 'systemLanguage', 'to', 'type', 'values', 'xlink:actuate', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type', 'xml:base', 'xml:lang', 'xml:space'], - circle: ['class', 'cx', 'cy', 'externalResourcesRequired', 'id', 'onactivate', 'onclick', 'onfocusin', 'onfocusout', 'onload', 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'r', 'requiredExtensions', 'requiredFeatures', 'style', 'systemLanguage', 'transform', 'xml:base', 'xml:lang', 'xml:space'], - clipPath: ['class', 'clipPathUnits', 'externalResourcesRequired', 'id', 'requiredExtensions', 'requiredFeatures', 'style', 'systemLanguage', 'transform', 'xml:base', 'xml:lang', 'xml:space'], - 'color-profile': ['id', 'local', 'name', 'rendering-intent', 'xlink:actuate', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type', 'xml:base', 'xml:lang', 'xml:space'], - cursor: ['externalResourcesRequired', 'id', 'requiredExtensions', 'requiredFeatures', 'systemLanguage', 'x', 'xlink:actuate', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type', 'xml:base', 'xml:lang', 'xml:space', 'y'], - defs: ['class', 'externalResourcesRequired', 'id', 'onactivate', 'onclick', 'onfocusin', 'onfocusout', 'onload', 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'requiredExtensions', 'requiredFeatures', 'style', 'systemLanguage', 'transform', 'xml:base', 'xml:lang', 'xml:space'], - desc: ['class', 'id', 'style', 'xml:base', 'xml:lang', 'xml:space'], - ellipse: ['class', 'cx', 'cy', 'externalResourcesRequired', 'id', 'onactivate', 'onclick', 'onfocusin', 'onfocusout', 'onload', 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'requiredExtensions', 'requiredFeatures', 'rx', 'ry', 'style', 'systemLanguage', 'transform', 'xml:base', 'xml:lang', 'xml:space'], - feBlend: ['class', 'height', 'id', 'in', 'in2', 'mode', 'result', 'style', 'width', 'x', 'xml:base', 'xml:lang', 'xml:space', 'y'], - feColorMatrix: ['class', 'height', 'id', 'in', 'result', 'style', 'type', 'values', 'width', 'x', 'xml:base', 'xml:lang', 'xml:space', 'y'], - feComponentTransfer: ['class', 'height', 'id', 'in', 'result', 'style', 'width', 'x', 'xml:base', 'xml:lang', 'xml:space', 'y'], - feComposite: ['class', 'height', 'id', 'in', 'in2', 'k1', 'k2', 'k3', 'k4', 'operator', 'result', 'style', 'width', 'x', 'xml:base', 'xml:lang', 'xml:space', 'y'], - feConvolveMatrix: ['bias', 'class', 'divisor', 'edgeMode', 'height', 'id', 'in', 'kernelMatrix', 'kernelUnitLength', 'order', 'preserveAlpha', 'result', 'style', 'targetX', 'targetY', 'width', 'x', 'xml:base', 'xml:lang', 'xml:space', 'y'], - feDiffuseLighting: ['class', 'diffuseConstant', 'height', 'id', 'in', 'kernelUnitLength', 'result', 'style', 'surfaceScale', 'width', 'x', 'xml:base', 'xml:lang', 'xml:space', 'y'], - feDisplacementMap: ['class', 'height', 'id', 'in', 'in2', 'result', 'scale', 'style', 'width', 'x', 'xChannelSelector', 'xml:base', 'xml:lang', 'xml:space', 'y', 'yChannelSelector'], - feDistantLight: ['azimuth', 'elevation', 'id', 'xml:base', 'xml:lang', 'xml:space'], - feFlood: ['class', 'height', 'id', 'result', 'style', 'width', 'x', 'xml:base', 'xml:lang', 'xml:space', 'y'], - feFuncA: ['amplitude', 'exponent', 'id', 'intercept', 'offset', 'slope', 'tableValues', 'type', 'xml:base', 'xml:lang', 'xml:space'], - feFuncB: ['amplitude', 'exponent', 'id', 'intercept', 'offset', 'slope', 'tableValues', 'type', 'xml:base', 'xml:lang', 'xml:space'], - feFuncG: ['amplitude', 'exponent', 'id', 'intercept', 'offset', 'slope', 'tableValues', 'type', 'xml:base', 'xml:lang', 'xml:space'], - feFuncR: ['amplitude', 'exponent', 'id', 'intercept', 'offset', 'slope', 'tableValues', 'type', 'xml:base', 'xml:lang', 'xml:space'], - feGaussianBlur: ['class', 'height', 'id', 'in', 'result', 'stdDeviation', 'style', 'width', 'x', 'xml:base', 'xml:lang', 'xml:space', 'y'], - feImage: ['class', 'externalResourcesRequired', 'height', 'id', 'preserveAspectRatio', 'result', 'style', 'width', 'x', 'xlink:actuate', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type', 'xml:base', 'xml:lang', 'xml:space', 'y'], - feMerge: ['class', 'height', 'id', 'result', 'style', 'width', 'x', 'xml:base', 'xml:lang', 'xml:space', 'y'], - feMergeNode: ['id', 'xml:base', 'xml:lang', 'xml:space'], - feMorphology: ['class', 'height', 'id', 'in', 'operator', 'radius', 'result', 'style', 'width', 'x', 'xml:base', 'xml:lang', 'xml:space', 'y'], - feOffset: ['class', 'dx', 'dy', 'height', 'id', 'in', 'result', 'style', 'width', 'x', 'xml:base', 'xml:lang', 'xml:space', 'y'], - fePointLight: ['id', 'x', 'xml:base', 'xml:lang', 'xml:space', 'y', 'z'], - feSpecularLighting: ['class', 'height', 'id', 'in', 'kernelUnitLength', 'result', 'specularConstant', 'specularExponent', 'style', 'surfaceScale', 'width', 'x', 'xml:base', 'xml:lang', 'xml:space', 'y'], - feSpotLight: ['id', 'limitingConeAngle', 'pointsAtX', 'pointsAtY', 'pointsAtZ', 'specularExponent', 'x', 'xml:base', 'xml:lang', 'xml:space', 'y', 'z'], - feTile: ['class', 'height', 'id', 'in', 'result', 'style', 'width', 'x', 'xml:base', 'xml:lang', 'xml:space', 'y'], - feTurbulence: ['baseFrequency', 'class', 'height', 'id', 'numOctaves', 'result', 'seed', 'stitchTiles', 'style', 'type', 'width', 'x', 'xml:base', 'xml:lang', 'xml:space', 'y'], - filter: ['class', 'externalResourcesRequired', 'filterRes', 'filterUnits', 'height', 'id', 'primitiveUnits', 'style', 'width', 'x', 'xlink:actuate', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type', 'xml:base', 'xml:lang', 'xml:space', 'y'], - font: ['class', 'externalResourcesRequired', 'horiz-adv-x', 'horiz-origin-x', 'horiz-origin-y', 'id', 'style', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'xml:base', 'xml:lang', 'xml:space'], - 'font-face': ['accent-height', 'alphabetic', 'ascent', 'bbox', 'cap-height', 'descent', 'font-family', 'font-size', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'hanging', 'id', 'ideographic', 'mathematical', 'overline-position', 'overline-thickness', 'panose-1', 'slope', 'stemh', 'stemv', 'strikethrough-position', 'strikethrough-thickness', 'underline-position', 'underline-thickness', 'unicode-range', 'units-per-em', 'v-alphabetic', 'v-hanging', 'v-ideographic', 'v-mathematical', 'widths', 'x-height', 'xml:base', 'xml:lang', 'xml:space'], - 'font-face-format': ['id', 'string', 'xml:base', 'xml:lang', 'xml:space'], - 'font-face-name': ['id', 'name', 'xml:base', 'xml:lang', 'xml:space'], - 'font-face-src': ['id', 'xml:base', 'xml:lang', 'xml:space'], - 'font-face-uri': ['id', 'xlink:actuate', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type', 'xml:base', 'xml:lang', 'xml:space'], - foreignObject: ['class', 'externalResourcesRequired', 'height', 'id', 'onactivate', 'onclick', 'onfocusin', 'onfocusout', 'onload', 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'requiredExtensions', 'requiredFeatures', 'style', 'systemLanguage', 'transform', 'width', 'x', 'xml:base', 'xml:lang', 'xml:space', 'y'], - g: ['class', 'externalResourcesRequired', 'id', 'onactivate', 'onclick', 'onfocusin', 'onfocusout', 'onload', 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'requiredExtensions', 'requiredFeatures', 'style', 'systemLanguage', 'transform', 'xml:base', 'xml:lang', 'xml:space'], - glyph: ['arabic-form', 'class', 'd', 'glyph-name', 'horiz-adv-x', 'id', 'lang', 'orientation', 'style', 'unicode', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'xml:base', 'xml:lang', 'xml:space'], - glyphRef: ['class', 'dx', 'dy', 'format', 'glyphRef', 'id', 'style', 'x', 'xlink:actuate', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type', 'xml:base', 'xml:lang', 'xml:space', 'y'], - hkern: ['g1', 'g2', 'id', 'k', 'u1', 'u2', 'xml:base', 'xml:lang', 'xml:space'], - image: ['class', 'externalResourcesRequired', 'height', 'id', 'onactivate', 'onclick', 'onfocusin', 'onfocusout', 'onload', 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'preserveAspectRatio', 'requiredExtensions', 'requiredFeatures', 'style', 'systemLanguage', 'transform', 'width', 'x', 'xlink:actuate', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type', 'xml:base', 'xml:lang', 'xml:space', 'y'], - line: ['class', 'externalResourcesRequired', 'id', 'onactivate', 'onclick', 'onfocusin', 'onfocusout', 'onload', 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'requiredExtensions', 'requiredFeatures', 'style', 'systemLanguage', 'transform', 'x1', 'x2', 'xml:base', 'xml:lang', 'xml:space', 'y1', 'y2'], - linearGradient: ['class', 'externalResourcesRequired', 'gradientTransform', 'gradientUnits', 'id', 'spreadMethod', 'style', 'x1', 'x2', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:title', 'xlink:type', 'xml:base', 'xml:lang', 'xml:space', 'y1', 'y2'], - marker: ['class', 'externalResourcesRequired', 'id', 'markerHeight', 'markerUnits', 'markerWidth', 'orient', 'preserveAspectRatio', 'refX', 'refY', 'style', 'viewBox', 'xml:base', 'xml:lang', 'xml:space'], - mask: ['class', 'externalResourcesRequired', 'height', 'id', 'maskContentUnits', 'maskUnits', 'requiredExtensions', 'requiredFeatures', 'style', 'systemLanguage', 'width', 'x', 'xml:base', 'xml:lang', 'xml:space', 'y'], - metadata: ['id', 'xml:base', 'xml:lang', 'xml:space'], - 'missing-glyph': ['class', 'd', 'horiz-adv-x', 'id', 'style', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'xml:base', 'xml:lang', 'xml:space'], - mpath: ['externalResourcesRequired', 'id', 'xlink:actuate', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type', 'xml:base', 'xml:lang', 'xml:space'], - path: ['class', 'd', 'externalResourcesRequired', 'id', 'onactivate', 'onclick', 'onfocusin', 'onfocusout', 'onload', 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'pathLength', 'requiredExtensions', 'requiredFeatures', 'style', 'systemLanguage', 'transform', 'xml:base', 'xml:lang', 'xml:space'], - pattern: ['class', 'externalResourcesRequired', 'height', 'id', 'patternContentUnits', 'patternTransform', 'patternUnits', 'preserveAspectRatio', 'requiredExtensions', 'requiredFeatures', 'style', 'systemLanguage', 'viewBox', 'width', 'x', 'xlink:actuate', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type', 'xml:base', 'xml:lang', 'xml:space', 'y'], - polygon: ['class', 'externalResourcesRequired', 'id', 'onactivate', 'onclick', 'onfocusin', 'onfocusout', 'onload', 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'points', 'requiredExtensions', 'requiredFeatures', 'style', 'systemLanguage', 'transform', 'xml:base', 'xml:lang', 'xml:space'], - polyline: ['class', 'externalResourcesRequired', 'id', 'onactivate', 'onclick', 'onfocusin', 'onfocusout', 'onload', 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'points', 'requiredExtensions', 'requiredFeatures', 'style', 'systemLanguage', 'transform', 'xml:base', 'xml:lang', 'xml:space'], - radialGradient: ['class', 'cx', 'cy', 'externalResourcesRequired', 'fx', 'fy', 'gradientTransform', 'gradientUnits', 'id', 'r', 'spreadMethod', 'style', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:title', 'xlink:type', 'xml:base', 'xml:lang', 'xml:space'], - rect: ['class', 'externalResourcesRequired', 'height', 'id', 'onactivate', 'onclick', 'onfocusin', 'onfocusout', 'onload', 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'requiredExtensions', 'requiredFeatures', 'rx', 'ry', 'style', 'systemLanguage', 'transform', 'width', 'x', 'xml:base', 'xml:lang', 'xml:space', 'y'], - script: ['externalResourcesRequired', 'id', 'type', 'xlink:actuate', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type', 'xml:base', 'xml:lang', 'xml:space'], - set: ['attributeName', 'attributeType', 'begin', 'dur', 'end', 'externalResourcesRequired', 'fill', 'id', 'max', 'min', 'onbegin', 'onend', 'onload', 'onrepeat', 'repeatCount', 'repeatDur', 'requiredExtensions', 'requiredFeatures', 'restart', 'systemLanguage', 'to', 'xlink:actuate', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type', 'xml:base', 'xml:lang', 'xml:space'], - stop: ['class', 'id', 'offset', 'style', 'xml:base', 'xml:lang', 'xml:space'], - style: ['id', 'media', 'title', 'type', 'xml:base', 'xml:lang', 'xml:space'], - svg: ['baseProfile', 'class', 'contentScriptType', 'contentStyleType', 'externalResourcesRequired', 'height', 'id', 'onabort', 'onactivate', 'onclick', 'onerror', 'onfocusin', 'onfocusout', 'onload', 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'onresize', 'onscroll', 'onunload', 'onzoom', 'preserveAspectRatio', 'requiredExtensions', 'requiredFeatures', 'style', 'systemLanguage', 'version', 'viewBox', 'width', 'x', 'xml:base', 'xml:lang', 'xml:space', 'y', 'zoomAndPan'], - switch: ['class', 'externalResourcesRequired', 'id', 'onactivate', 'onclick', 'onfocusin', 'onfocusout', 'onload', 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'requiredExtensions', 'requiredFeatures', 'style', 'systemLanguage', 'transform', 'xml:base', 'xml:lang', 'xml:space'], - symbol: ['class', 'externalResourcesRequired', 'id', 'onactivate', 'onclick', 'onfocusin', 'onfocusout', 'onload', 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'preserveAspectRatio', 'style', 'viewBox', 'xml:base', 'xml:lang', 'xml:space'], - text: ['class', 'dx', 'dy', 'externalResourcesRequired', 'id', 'lengthAdjust', 'onactivate', 'onclick', 'onfocusin', 'onfocusout', 'onload', 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'requiredExtensions', 'requiredFeatures', 'rotate', 'style', 'systemLanguage', 'textLength', 'transform', 'x', 'xml:base', 'xml:lang', 'xml:space', 'y'], - textPath: ['class', 'externalResourcesRequired', 'id', 'lengthAdjust', 'method', 'onactivate', 'onclick', 'onfocusin', 'onfocusout', 'onload', 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'requiredExtensions', 'requiredFeatures', 'spacing', 'startOffset', 'style', 'systemLanguage', 'textLength', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:title', 'xlink:type', 'xml:base', 'xml:lang', 'xml:space'], - title: ['class', 'id', 'style', 'xml:base', 'xml:lang', 'xml:space'], - tref: ['class', 'dx', 'dy', 'externalResourcesRequired', 'id', 'lengthAdjust', 'onactivate', 'onclick', 'onfocusin', 'onfocusout', 'onload', 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'requiredExtensions', 'requiredFeatures', 'rotate', 'style', 'systemLanguage', 'textLength', 'x', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:title', 'xlink:type', 'xml:base', 'xml:lang', 'xml:space', 'y'], - tspan: ['class', 'dx', 'dy', 'externalResourcesRequired', 'id', 'lengthAdjust', 'onactivate', 'onclick', 'onfocusin', 'onfocusout', 'onload', 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'requiredExtensions', 'requiredFeatures', 'rotate', 'style', 'systemLanguage', 'textLength', 'x', 'xml:base', 'xml:lang', 'xml:space', 'y'], - use: ['class', 'externalResourcesRequired', 'height', 'id', 'onactivate', 'onclick', 'onfocusin', 'onfocusout', 'onload', 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'requiredExtensions', 'requiredFeatures', 'style', 'systemLanguage', 'transform', 'width', 'x', 'xlink:actuate', 'xlink:arcrole', 'xlink:href', 'xlink:role', 'xlink:show', 'xlink:title', 'xlink:type', 'xml:base', 'xml:lang', 'xml:space', 'y'], - view: ['externalResourcesRequired', 'id', 'preserveAspectRatio', 'viewBox', 'viewTarget', 'xml:base', 'xml:lang', 'xml:space', 'zoomAndPan'], - vkern: ['g1', 'g2', 'id', 'k', 'u1', 'u2', 'xml:base', 'xml:lang', 'xml:space'] - }; - var presentationElements = exports.presentationElements = { - 'a': true, - 'altGlyph': true, - 'animate': true, - 'animateColor': true, - 'circle': true, - 'clipPath': true, - 'defs': true, - 'ellipse': true, - 'feBlend': true, - 'feColorMatrix': true, - 'feComponentTransfer': true, - 'feComposite': true, - 'feConvolveMatrix': true, - 'feDiffuseLighting': true, - 'feDisplacementMap': true, - 'feFlood': true, - 'feGaussianBlur': true, - 'feImage': true, - 'feMerge': true, - 'feMorphology': true, - 'feOffset': true, - 'feSpecularLighting': true, - 'feTile': true, - 'feTurbulence': true, - 'filter': true, - 'font': true, - 'foreignObject': true, - 'g': true, - 'glyph': true, - 'glyphRef': true, - 'image': true, - 'line': true, - 'linearGradient': true, - 'marker': true, - 'mask': true, - 'missing-glyph': true, - 'path': true, - 'pattern': true, - 'polygon': true, - 'polyline': true, - 'radialGradient': true, - 'rect': true, - 'stop': true, - 'svg': true, - 'switch': true, - 'symbol': true, - 'text': true, - 'textPath': true, - 'tref': true, - 'tspan': true, - 'use': true - }; - - var presentationAttributes = exports.presentationAttributes = { - 'alignment-baseline': true, - 'baseline-shift': true, - 'clip-path': true, - 'clip-rule': true, - 'clip': true, - 'color-interpolation-filters': true, - 'color-interpolation': true, - 'color-profile': true, - 'color-rendering': true, - 'color': true, - 'cursor': true, - 'direction': true, - 'display': true, - 'dominant-baseline': true, - 'enable-background': true, - 'fill-opacity': true, - 'fill-rule': true, - 'fill': true, - 'filter': true, - 'flood-color': true, - 'flood-opacity': true, - 'font-family': true, - 'font-size-adjust': true, - 'font-size': true, - 'font-stretch': true, - 'font-style': true, - 'font-variant': true, - 'font-weight': true, - 'glyph-orientation-horizontal': true, - 'glyph-orientation-vertical': true, - 'image-rendering': true, - 'kerning': true, - 'letter-spacing': true, - 'lighting-color': true, - 'marker-end': true, - 'marker-mid': true, - 'marker-start': true, - 'mask': true, - 'opacity': true, - 'overflow': true, - 'pointer-events': true, - 'shape-rendering': true, - 'stop-color': true, - 'stop-opacity': true, - 'stroke-dasharray': true, - 'stroke-dashoffset': true, - 'stroke-linecap': true, - 'stroke-linejoin': true, - 'stroke-miterlimit': true, - 'stroke-opacity': true, - 'stroke-width': true, - 'stroke': true, - 'text-anchor': true, - 'text-decoration': true, - 'text-rendering': true, - 'unicode-bidi': true, - 'visibility': true, - 'word-spacing': true, - 'writing-mode': true - }; - - function createElement(html) { - var div = _aureliaPal.DOM.createElement('div'); - div.innerHTML = html; - return div.firstChild; - } - - var SVGAnalyzer = exports.SVGAnalyzer = function () { - function SVGAnalyzer() { - - - if (createElement('').firstElementChild.nodeName === 'altglyph' && elements.altGlyph) { - elements.altglyph = elements.altGlyph; - delete elements.altGlyph; - elements.altglyphdef = elements.altGlyphDef; - delete elements.altGlyphDef; - elements.altglyphitem = elements.altGlyphItem; - delete elements.altGlyphItem; - elements.glyphref = elements.glyphRef; - delete elements.glyphRef; - } - } - - SVGAnalyzer.prototype.isStandardSvgAttribute = function isStandardSvgAttribute(nodeName, attributeName) { - return presentationElements[nodeName] && presentationAttributes[attributeName] || elements[nodeName] && elements[nodeName].indexOf(attributeName) !== -1; - }; - - return SVGAnalyzer; - }(); - - var ObserverLocator = exports.ObserverLocator = (_temp = _class11 = function () { - function ObserverLocator(taskQueue, eventManager, dirtyChecker, svgAnalyzer, parser) { - - - this.taskQueue = taskQueue; - this.eventManager = eventManager; - this.dirtyChecker = dirtyChecker; - this.svgAnalyzer = svgAnalyzer; - this.parser = parser; - this.adapters = []; - this.logger = LogManager.getLogger('observer-locator'); - } - - ObserverLocator.prototype.getObserver = function getObserver(obj, propertyName) { - var observersLookup = obj.__observers__; - var observer = void 0; - - if (observersLookup && propertyName in observersLookup) { - return observersLookup[propertyName]; - } - - observer = this.createPropertyObserver(obj, propertyName); - - if (!observer.doNotCache) { - if (observersLookup === undefined) { - observersLookup = this.getOrCreateObserversLookup(obj); - } - - observersLookup[propertyName] = observer; - } - - return observer; - }; - - ObserverLocator.prototype.getOrCreateObserversLookup = function getOrCreateObserversLookup(obj) { - return obj.__observers__ || this.createObserversLookup(obj); - }; - - ObserverLocator.prototype.createObserversLookup = function createObserversLookup(obj) { - var value = {}; - - if (!Reflect.defineProperty(obj, '__observers__', { - enumerable: false, - configurable: false, - writable: false, - value: value - })) { - this.logger.warn('Cannot add observers to object', obj); - } - - return value; - }; - - ObserverLocator.prototype.addAdapter = function addAdapter(adapter) { - this.adapters.push(adapter); - }; - - ObserverLocator.prototype.getAdapterObserver = function getAdapterObserver(obj, propertyName, descriptor) { - for (var _i26 = 0, ii = this.adapters.length; _i26 < ii; _i26++) { - var adapter = this.adapters[_i26]; - var observer = adapter.getObserver(obj, propertyName, descriptor); - if (observer) { - return observer; - } - } - return null; - }; - - ObserverLocator.prototype.createPropertyObserver = function createPropertyObserver(obj, propertyName) { - var descriptor = void 0; - var handler = void 0; - var xlinkResult = void 0; - - if (!(obj instanceof Object)) { - return new PrimitiveObserver(obj, propertyName); - } - - if (obj instanceof _aureliaPal.DOM.Element) { - if (propertyName === 'class') { - return new ClassObserver(obj); - } - if (propertyName === 'style' || propertyName === 'css') { - return new StyleObserver(obj, propertyName); - } - handler = this.eventManager.getElementHandler(obj, propertyName); - if (propertyName === 'value' && obj.tagName.toLowerCase() === 'select') { - return new SelectValueObserver(obj, handler, this); - } - if (propertyName === 'checked' && obj.tagName.toLowerCase() === 'input') { - return new CheckedObserver(obj, handler, this); - } - if (handler) { - return new ValueAttributeObserver(obj, propertyName, handler); - } - xlinkResult = /^xlink:(.+)$/.exec(propertyName); - if (xlinkResult) { - return new XLinkAttributeObserver(obj, propertyName, xlinkResult[1]); - } - if (propertyName === 'role' && (obj instanceof _aureliaPal.DOM.Element || obj instanceof _aureliaPal.DOM.SVGElement) || /^\w+:|^data-|^aria-/.test(propertyName) || obj instanceof _aureliaPal.DOM.SVGElement && this.svgAnalyzer.isStandardSvgAttribute(obj.nodeName, propertyName)) { - return new DataAttributeObserver(obj, propertyName); - } - } - - descriptor = Object.getPropertyDescriptor(obj, propertyName); - - if (hasDeclaredDependencies(descriptor)) { - return createComputedObserver(obj, propertyName, descriptor, this); - } - - if (descriptor) { - var existingGetterOrSetter = descriptor.get || descriptor.set; - if (existingGetterOrSetter) { - if (existingGetterOrSetter.getObserver) { - return existingGetterOrSetter.getObserver(obj); - } - - var adapterObserver = this.getAdapterObserver(obj, propertyName, descriptor); - if (adapterObserver) { - return adapterObserver; - } - return new DirtyCheckProperty(this.dirtyChecker, obj, propertyName); - } - } - - if (obj instanceof Array) { - if (propertyName === 'length') { - return this.getArrayObserver(obj).getLengthObserver(); - } - - return new DirtyCheckProperty(this.dirtyChecker, obj, propertyName); - } else if (obj instanceof Map) { - if (propertyName === 'size') { - return this.getMapObserver(obj).getLengthObserver(); - } - - return new DirtyCheckProperty(this.dirtyChecker, obj, propertyName); - } else if (obj instanceof Set) { - if (propertyName === 'size') { - return this.getSetObserver(obj).getLengthObserver(); - } - - return new DirtyCheckProperty(this.dirtyChecker, obj, propertyName); - } - - return new SetterObserver(this.taskQueue, obj, propertyName); - }; - - ObserverLocator.prototype.getAccessor = function getAccessor(obj, propertyName) { - if (obj instanceof _aureliaPal.DOM.Element) { - if (propertyName === 'class' || propertyName === 'style' || propertyName === 'css' || propertyName === 'value' && (obj.tagName.toLowerCase() === 'input' || obj.tagName.toLowerCase() === 'select') || propertyName === 'checked' && obj.tagName.toLowerCase() === 'input' || propertyName === 'model' && obj.tagName.toLowerCase() === 'input' || /^xlink:.+$/.exec(propertyName)) { - return this.getObserver(obj, propertyName); - } - if (/^\w+:|^data-|^aria-/.test(propertyName) || obj instanceof _aureliaPal.DOM.SVGElement && this.svgAnalyzer.isStandardSvgAttribute(obj.nodeName, propertyName)) { - return dataAttributeAccessor; - } - } - return propertyAccessor; - }; - - ObserverLocator.prototype.getArrayObserver = function getArrayObserver(array) { - return _getArrayObserver(this.taskQueue, array); - }; - - ObserverLocator.prototype.getMapObserver = function getMapObserver(map) { - return _getMapObserver(this.taskQueue, map); - }; - - ObserverLocator.prototype.getSetObserver = function getSetObserver(set) { - return _getSetObserver(this.taskQueue, set); - }; - - return ObserverLocator; - }(), _class11.inject = [_aureliaTaskQueue.TaskQueue, EventManager, DirtyChecker, SVGAnalyzer, Parser], _temp); - - var ObjectObservationAdapter = exports.ObjectObservationAdapter = function () { - function ObjectObservationAdapter() { - - } - - ObjectObservationAdapter.prototype.getObserver = function getObserver(object, propertyName, descriptor) { - throw new Error('BindingAdapters must implement getObserver(object, propertyName).'); - }; - - return ObjectObservationAdapter; - }(); - - var BindingExpression = exports.BindingExpression = function () { - function BindingExpression(observerLocator, targetProperty, sourceExpression, mode, lookupFunctions, attribute) { - - - this.observerLocator = observerLocator; - this.targetProperty = targetProperty; - this.sourceExpression = sourceExpression; - this.mode = mode; - this.lookupFunctions = lookupFunctions; - this.attribute = attribute; - this.discrete = false; - } - - BindingExpression.prototype.createBinding = function createBinding(target) { - return new Binding(this.observerLocator, this.sourceExpression, target, this.targetProperty, this.mode, this.lookupFunctions); - }; - - return BindingExpression; - }(); - - var targetContext = 'Binding:target'; - - var Binding = exports.Binding = (_dec10 = connectable(), _dec10(_class12 = function () { - function Binding(observerLocator, sourceExpression, target, targetProperty, mode, lookupFunctions) { - - - this.observerLocator = observerLocator; - this.sourceExpression = sourceExpression; - this.target = target; - this.targetProperty = targetProperty; - this.mode = mode; - this.lookupFunctions = lookupFunctions; - } - - Binding.prototype.updateTarget = function updateTarget(value) { - this.targetObserver.setValue(value, this.target, this.targetProperty); - }; - - Binding.prototype.updateSource = function updateSource(value) { - this.sourceExpression.assign(this.source, value, this.lookupFunctions); - }; - - Binding.prototype.call = function call(context, newValue, oldValue) { - if (!this.isBound) { - return; - } - if (context === sourceContext) { - oldValue = this.targetObserver.getValue(this.target, this.targetProperty); - newValue = this.sourceExpression.evaluate(this.source, this.lookupFunctions); - if (newValue !== oldValue) { - this.updateTarget(newValue); - } - if (this.mode !== bindingMode.oneTime) { - this._version++; - this.sourceExpression.connect(this, this.source); - this.unobserve(false); - } - return; - } - if (context === targetContext) { - if (newValue !== this.sourceExpression.evaluate(this.source, this.lookupFunctions)) { - this.updateSource(newValue); - } - return; - } - throw new Error('Unexpected call context ' + context); - }; - - Binding.prototype.bind = function bind(source) { - if (this.isBound) { - if (this.source === source) { - return; - } - this.unbind(); - } - this.isBound = true; - this.source = source; - - if (this.sourceExpression.bind) { - this.sourceExpression.bind(this, source, this.lookupFunctions); - } - - var mode = this.mode; - if (!this.targetObserver) { - var method = mode === bindingMode.twoWay ? 'getObserver' : 'getAccessor'; - this.targetObserver = this.observerLocator[method](this.target, this.targetProperty); - } - - if ('bind' in this.targetObserver) { - this.targetObserver.bind(); - } - var value = this.sourceExpression.evaluate(source, this.lookupFunctions); - this.updateTarget(value); - - if (mode === bindingMode.oneWay) { - enqueueBindingConnect(this); - } else if (mode === bindingMode.twoWay) { - this.sourceExpression.connect(this, source); - this.targetObserver.subscribe(targetContext, this); - } - }; - - Binding.prototype.unbind = function unbind() { - if (!this.isBound) { - return; - } - this.isBound = false; - if (this.sourceExpression.unbind) { - this.sourceExpression.unbind(this, this.source); - } - this.source = null; - if ('unbind' in this.targetObserver) { - this.targetObserver.unbind(); - } - if (this.targetObserver.unsubscribe) { - this.targetObserver.unsubscribe(targetContext, this); - } - this.unobserve(true); - }; - - Binding.prototype.connect = function connect(evaluate) { - if (!this.isBound) { - return; - } - if (evaluate) { - var value = this.sourceExpression.evaluate(this.source, this.lookupFunctions); - this.updateTarget(value); - } - this.sourceExpression.connect(this, this.source); - }; - - return Binding; - }()) || _class12); - - var CallExpression = exports.CallExpression = function () { - function CallExpression(observerLocator, targetProperty, sourceExpression, lookupFunctions) { - - - this.observerLocator = observerLocator; - this.targetProperty = targetProperty; - this.sourceExpression = sourceExpression; - this.lookupFunctions = lookupFunctions; - } - - CallExpression.prototype.createBinding = function createBinding(target) { - return new Call(this.observerLocator, this.sourceExpression, target, this.targetProperty, this.lookupFunctions); - }; - - return CallExpression; - }(); - - var Call = exports.Call = function () { - function Call(observerLocator, sourceExpression, target, targetProperty, lookupFunctions) { - - - this.sourceExpression = sourceExpression; - this.target = target; - this.targetProperty = observerLocator.getObserver(target, targetProperty); - this.lookupFunctions = lookupFunctions; - } - - Call.prototype.callSource = function callSource($event) { - var overrideContext = this.source.overrideContext; - Object.assign(overrideContext, $event); - overrideContext.$event = $event; - var mustEvaluate = true; - var result = this.sourceExpression.evaluate(this.source, this.lookupFunctions, mustEvaluate); - delete overrideContext.$event; - for (var prop in $event) { - delete overrideContext[prop]; - } - return result; - }; - - Call.prototype.bind = function bind(source) { - var _this27 = this; - - if (this.isBound) { - if (this.source === source) { - return; - } - this.unbind(); - } - this.isBound = true; - this.source = source; - - if (this.sourceExpression.bind) { - this.sourceExpression.bind(this, source, this.lookupFunctions); - } - this.targetProperty.setValue(function ($event) { - return _this27.callSource($event); - }); - }; - - Call.prototype.unbind = function unbind() { - if (!this.isBound) { - return; - } - this.isBound = false; - if (this.sourceExpression.unbind) { - this.sourceExpression.unbind(this, this.source); - } - this.source = null; - this.targetProperty.setValue(null); - }; - - return Call; - }(); - - var ValueConverterResource = exports.ValueConverterResource = function () { - function ValueConverterResource(name) { - - - this.name = name; - } - - ValueConverterResource.convention = function convention(name) { - if (name.endsWith('ValueConverter')) { - return new ValueConverterResource(camelCase(name.substring(0, name.length - 14))); - } - }; - - ValueConverterResource.prototype.initialize = function initialize(container, target) { - this.instance = container.get(target); - }; - - ValueConverterResource.prototype.register = function register(registry, name) { - registry.registerValueConverter(name || this.name, this.instance); - }; - - ValueConverterResource.prototype.load = function load(container, target) {}; - - return ValueConverterResource; - }(); - - function valueConverter(nameOrTarget) { - if (nameOrTarget === undefined || typeof nameOrTarget === 'string') { - return function (target) { - _aureliaMetadata.metadata.define(_aureliaMetadata.metadata.resource, new ValueConverterResource(nameOrTarget), target); - }; - } - - _aureliaMetadata.metadata.define(_aureliaMetadata.metadata.resource, new ValueConverterResource(), nameOrTarget); - } - - var BindingBehaviorResource = exports.BindingBehaviorResource = function () { - function BindingBehaviorResource(name) { - - - this.name = name; - } - - BindingBehaviorResource.convention = function convention(name) { - if (name.endsWith('BindingBehavior')) { - return new BindingBehaviorResource(camelCase(name.substring(0, name.length - 15))); - } - }; - - BindingBehaviorResource.prototype.initialize = function initialize(container, target) { - this.instance = container.get(target); - }; - - BindingBehaviorResource.prototype.register = function register(registry, name) { - registry.registerBindingBehavior(name || this.name, this.instance); - }; - - BindingBehaviorResource.prototype.load = function load(container, target) {}; - - return BindingBehaviorResource; - }(); - - function bindingBehavior(nameOrTarget) { - if (nameOrTarget === undefined || typeof nameOrTarget === 'string') { - return function (target) { - _aureliaMetadata.metadata.define(_aureliaMetadata.metadata.resource, new BindingBehaviorResource(nameOrTarget), target); - }; - } - - _aureliaMetadata.metadata.define(_aureliaMetadata.metadata.resource, new BindingBehaviorResource(), nameOrTarget); - } - - var ListenerExpression = exports.ListenerExpression = function () { - function ListenerExpression(eventManager, targetEvent, sourceExpression, delegationStrategy, preventDefault, lookupFunctions) { - - - this.eventManager = eventManager; - this.targetEvent = targetEvent; - this.sourceExpression = sourceExpression; - this.delegationStrategy = delegationStrategy; - this.discrete = true; - this.preventDefault = preventDefault; - this.lookupFunctions = lookupFunctions; - } - - ListenerExpression.prototype.createBinding = function createBinding(target) { - return new Listener(this.eventManager, this.targetEvent, this.delegationStrategy, this.sourceExpression, target, this.preventDefault, this.lookupFunctions); - }; - - return ListenerExpression; - }(); - - var Listener = exports.Listener = function () { - function Listener(eventManager, targetEvent, delegationStrategy, sourceExpression, target, preventDefault, lookupFunctions) { - - - this.eventManager = eventManager; - this.targetEvent = targetEvent; - this.delegationStrategy = delegationStrategy; - this.sourceExpression = sourceExpression; - this.target = target; - this.preventDefault = preventDefault; - this.lookupFunctions = lookupFunctions; - } - - Listener.prototype.callSource = function callSource(event) { - var overrideContext = this.source.overrideContext; - overrideContext.$event = event; - var mustEvaluate = true; - var result = this.sourceExpression.evaluate(this.source, this.lookupFunctions, mustEvaluate); - delete overrideContext.$event; - if (result !== true && this.preventDefault) { - event.preventDefault(); - } - return result; - }; - - Listener.prototype.bind = function bind(source) { - var _this28 = this; - - if (this.isBound) { - if (this.source === source) { - return; - } - this.unbind(); - } - this.isBound = true; - this.source = source; - - if (this.sourceExpression.bind) { - this.sourceExpression.bind(this, source, this.lookupFunctions); - } - this._disposeListener = this.eventManager.addEventListener(this.target, this.targetEvent, function (event) { - return _this28.callSource(event); - }, this.delegationStrategy); - }; - - Listener.prototype.unbind = function unbind() { - if (!this.isBound) { - return; - } - this.isBound = false; - if (this.sourceExpression.unbind) { - this.sourceExpression.unbind(this, this.source); - } - this.source = null; - this._disposeListener(); - this._disposeListener = null; - }; - - return Listener; - }(); - - function getAU(element) { - var au = element.au; - - if (au === undefined) { - throw new Error('No Aurelia APIs are defined for the element: "' + element.tagName + '".'); - } - - return au; - } - - var NameExpression = exports.NameExpression = function () { - function NameExpression(sourceExpression, apiName, lookupFunctions) { - - - this.sourceExpression = sourceExpression; - this.apiName = apiName; - this.lookupFunctions = lookupFunctions; - this.discrete = true; - } - - NameExpression.prototype.createBinding = function createBinding(target) { - return new NameBinder(this.sourceExpression, NameExpression.locateAPI(target, this.apiName), this.lookupFunctions); - }; - - NameExpression.locateAPI = function locateAPI(element, apiName) { - switch (apiName) { - case 'element': - return element; - case 'controller': - return getAU(element).controller; - case 'view-model': - return getAU(element).controller.viewModel; - case 'view': - return getAU(element).controller.view; - default: - var target = getAU(element)[apiName]; - - if (target === undefined) { - throw new Error('Attempted to reference "' + apiName + '", but it was not found amongst the target\'s API.'); - } - - return target.viewModel; - } - }; - - return NameExpression; - }(); - - var NameBinder = function () { - function NameBinder(sourceExpression, target, lookupFunctions) { - - - this.sourceExpression = sourceExpression; - this.target = target; - this.lookupFunctions = lookupFunctions; - } - - NameBinder.prototype.bind = function bind(source) { - if (this.isBound) { - if (this.source === source) { - return; - } - this.unbind(); - } - this.isBound = true; - this.source = source; - if (this.sourceExpression.bind) { - this.sourceExpression.bind(this, source, this.lookupFunctions); - } - this.sourceExpression.assign(this.source, this.target, this.lookupFunctions); - }; - - NameBinder.prototype.unbind = function unbind() { - if (!this.isBound) { - return; - } - this.isBound = false; - if (this.sourceExpression.evaluate(this.source, this.lookupFunctions) === this.target) { - this.sourceExpression.assign(this.source, null, this.lookupFunctions); - } - if (this.sourceExpression.unbind) { - this.sourceExpression.unbind(this, this.source); - } - this.source = null; - }; - - return NameBinder; - }(); - - var LookupFunctions = { - bindingBehaviors: function bindingBehaviors(name) { - return null; - }, - valueConverters: function valueConverters(name) { - return null; - } - }; - - var BindingEngine = exports.BindingEngine = (_temp2 = _class13 = function () { - function BindingEngine(observerLocator, parser) { - - - this.observerLocator = observerLocator; - this.parser = parser; - } - - BindingEngine.prototype.createBindingExpression = function createBindingExpression(targetProperty, sourceExpression) { - var mode = arguments.length <= 2 || arguments[2] === undefined ? bindingMode.oneWay : arguments[2]; - var lookupFunctions = arguments.length <= 3 || arguments[3] === undefined ? LookupFunctions : arguments[3]; - - return new BindingExpression(this.observerLocator, targetProperty, this.parser.parse(sourceExpression), mode, lookupFunctions); - }; - - BindingEngine.prototype.propertyObserver = function propertyObserver(obj, propertyName) { - var _this29 = this; - - return { - subscribe: function subscribe(callback) { - var observer = _this29.observerLocator.getObserver(obj, propertyName); - observer.subscribe(callback); - return { - dispose: function dispose() { - return observer.unsubscribe(callback); - } - }; - } - }; - }; - - BindingEngine.prototype.collectionObserver = function collectionObserver(collection) { - var _this30 = this; - - return { - subscribe: function subscribe(callback) { - var observer = void 0; - if (collection instanceof Array) { - observer = _this30.observerLocator.getArrayObserver(collection); - } else if (collection instanceof Map) { - observer = _this30.observerLocator.getMapObserver(collection); - } else if (collection instanceof Set) { - observer = _this30.observerLocator.getSetObserver(collection); - } else { - throw new Error('collection must be an instance of Array, Map or Set.'); - } - observer.subscribe(callback); - return { - dispose: function dispose() { - return observer.unsubscribe(callback); - } - }; - } - }; - }; - - BindingEngine.prototype.expressionObserver = function expressionObserver(bindingContext, expression) { - var scope = { bindingContext: bindingContext, overrideContext: createOverrideContext(bindingContext) }; - return new ExpressionObserver(scope, this.parser.parse(expression), this.observerLocator, LookupFunctions); - }; - - BindingEngine.prototype.parseExpression = function parseExpression(expression) { - return this.parser.parse(expression); - }; - - BindingEngine.prototype.registerAdapter = function registerAdapter(adapter) { - this.observerLocator.addAdapter(adapter); - }; - - return BindingEngine; - }(), _class13.inject = [ObserverLocator, Parser], _temp2); - - - var setProto = Set.prototype; - - function _getSetObserver(taskQueue, set) { - return ModifySetObserver.for(taskQueue, set); - } - - exports.getSetObserver = _getSetObserver; - - var ModifySetObserver = function (_ModifyCollectionObse3) { - _inherits(ModifySetObserver, _ModifyCollectionObse3); - - function ModifySetObserver(taskQueue, set) { - - - return _possibleConstructorReturn(this, _ModifyCollectionObse3.call(this, taskQueue, set)); - } - - ModifySetObserver.for = function _for(taskQueue, set) { - if (!('__set_observer__' in set)) { - Reflect.defineProperty(set, '__set_observer__', { - value: ModifySetObserver.create(taskQueue, set), - enumerable: false, configurable: false - }); - } - return set.__set_observer__; - }; - - ModifySetObserver.create = function create(taskQueue, set) { - var observer = new ModifySetObserver(taskQueue, set); - - var proto = setProto; - if (proto.add !== set.add || proto.delete !== set.delete || proto.clear !== set.clear) { - proto = { - add: set.add, - delete: set.delete, - clear: set.clear - }; - } - - set.add = function () { - var type = 'add'; - var oldSize = set.size; - var methodCallResult = proto.add.apply(set, arguments); - var hasValue = set.size === oldSize; - if (!hasValue) { - observer.addChangeRecord({ - type: type, - object: set, - value: Array.from(set).pop() - }); - } - return methodCallResult; - }; - - set.delete = function () { - var hasValue = set.has(arguments[0]); - var methodCallResult = proto.delete.apply(set, arguments); - if (hasValue) { - observer.addChangeRecord({ - type: 'delete', - object: set, - value: arguments[0] - }); - } - return methodCallResult; - }; - - set.clear = function () { - var methodCallResult = proto.clear.apply(set, arguments); - observer.addChangeRecord({ - type: 'clear', - object: set - }); - return methodCallResult; - }; - - return observer; - }; - - return ModifySetObserver; - }(ModifyCollectionObserver); - - function observable(targetOrConfig, key, descriptor) { - function deco(target, key, descriptor, config) { - var isClassDecorator = key === undefined; - if (isClassDecorator) { - target = target.prototype; - key = typeof config === 'string' ? config : config.name; - } - - var innerPropertyName = '_' + key; - var innerPropertyDescriptor = { - configurable: true, - enumerable: false, - writable: true - }; - - var callbackName = config && config.changeHandler || key + 'Changed'; - - if (descriptor) { - if (typeof descriptor.initializer === 'function') { - innerPropertyDescriptor.value = descriptor.initializer(); - } - } else { - descriptor = {}; - } - - if (!('enumerable' in descriptor)) { - descriptor.enumerable = true; - } - - delete descriptor.value; - delete descriptor.writable; - delete descriptor.initializer; - - Reflect.defineProperty(target, innerPropertyName, innerPropertyDescriptor); - - descriptor.get = function () { - return this[innerPropertyName]; - }; - descriptor.set = function (newValue) { - var oldValue = this[innerPropertyName]; - if (newValue === oldValue) { - return; - } - - this[innerPropertyName] = newValue; - Reflect.defineProperty(this, innerPropertyName, { enumerable: false }); - - if (this[callbackName]) { - this[callbackName](newValue, oldValue, key); - } - }; - - descriptor.get.dependencies = [innerPropertyName]; - - if (isClassDecorator) { - Reflect.defineProperty(target, key, descriptor); - } else { - return descriptor; - } - } - - if (key === undefined) { - return function (t, k, d) { - return deco(t, k, d, targetOrConfig); - }; - } - return deco(targetOrConfig, key, descriptor); - } -}); -define('aurelia-dependency-injection',['exports', 'aurelia-metadata', 'aurelia-pal'], function (exports, _aureliaMetadata, _aureliaPal) { - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.Container = exports.InvocationHandler = exports._emptyParameters = exports.SingletonRegistration = exports.TransientRegistration = exports.FactoryInvoker = exports.NewInstance = exports.Factory = exports.StrategyResolver = exports.Parent = exports.Optional = exports.All = exports.Lazy = exports.resolver = undefined; - exports.getDecoratorDependencies = getDecoratorDependencies; - exports.lazy = lazy; - exports.all = all; - exports.optional = optional; - exports.parent = parent; - exports.factory = factory; - exports.newInstance = newInstance; - exports.invoker = invoker; - exports.invokeAsFactory = invokeAsFactory; - exports.registration = registration; - exports.transient = transient; - exports.singleton = singleton; - exports.autoinject = autoinject; - exports.inject = inject; - - - - var _dec, _class, _dec2, _class3, _dec3, _class5, _dec4, _class7, _dec5, _class9, _dec6, _class11, _dec7, _class13, _classInvokers; - - var resolver = exports.resolver = _aureliaMetadata.protocol.create('aurelia:resolver', function (target) { - if (!(typeof target.get === 'function')) { - return 'Resolvers must implement: get(container: Container, key: any): any'; - } - - return true; - }); - - var Lazy = exports.Lazy = (_dec = resolver(), _dec(_class = function () { - function Lazy(key) { - - - this._key = key; - } - - Lazy.prototype.get = function get(container) { - var _this = this; - - return function () { - return container.get(_this._key); - }; - }; - - Lazy.of = function of(key) { - return new Lazy(key); - }; - - return Lazy; - }()) || _class); - var All = exports.All = (_dec2 = resolver(), _dec2(_class3 = function () { - function All(key) { - - - this._key = key; - } - - All.prototype.get = function get(container) { - return container.getAll(this._key); - }; - - All.of = function of(key) { - return new All(key); - }; - - return All; - }()) || _class3); - var Optional = exports.Optional = (_dec3 = resolver(), _dec3(_class5 = function () { - function Optional(key) { - var checkParent = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1]; - - - - this._key = key; - this._checkParent = checkParent; - } - - Optional.prototype.get = function get(container) { - if (container.hasResolver(this._key, this._checkParent)) { - return container.get(this._key); - } - - return null; - }; - - Optional.of = function of(key) { - var checkParent = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1]; - - return new Optional(key, checkParent); - }; - - return Optional; - }()) || _class5); - var Parent = exports.Parent = (_dec4 = resolver(), _dec4(_class7 = function () { - function Parent(key) { - - - this._key = key; - } - - Parent.prototype.get = function get(container) { - return container.parent ? container.parent.get(this._key) : null; - }; - - Parent.of = function of(key) { - return new Parent(key); - }; - - return Parent; - }()) || _class7); - var StrategyResolver = exports.StrategyResolver = (_dec5 = resolver(), _dec5(_class9 = function () { - function StrategyResolver(strategy, state) { - - - this.strategy = strategy; - this.state = state; - } - - StrategyResolver.prototype.get = function get(container, key) { - switch (this.strategy) { - case 0: - return this.state; - case 1: - var singleton = container.invoke(this.state); - this.state = singleton; - this.strategy = 0; - return singleton; - case 2: - return container.invoke(this.state); - case 3: - return this.state(container, key, this); - case 4: - return this.state[0].get(container, key); - case 5: - return container.get(this.state); - default: - throw new Error('Invalid strategy: ' + this.strategy); - } - }; - - return StrategyResolver; - }()) || _class9); - var Factory = exports.Factory = (_dec6 = resolver(), _dec6(_class11 = function () { - function Factory(key) { - - - this._key = key; - } - - Factory.prototype.get = function get(container) { - var _this2 = this; - - return function () { - for (var _len = arguments.length, rest = Array(_len), _key = 0; _key < _len; _key++) { - rest[_key] = arguments[_key]; - } - - return container.invoke(_this2._key, rest); - }; - }; - - Factory.of = function of(key) { - return new Factory(key); - }; - - return Factory; - }()) || _class11); - var NewInstance = exports.NewInstance = (_dec7 = resolver(), _dec7(_class13 = function () { - function NewInstance(key) { - - - this.key = key; - this.asKey = key; - - for (var _len2 = arguments.length, dynamicDependencies = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { - dynamicDependencies[_key2 - 1] = arguments[_key2]; - } - - this.dynamicDependencies = dynamicDependencies; - } - - NewInstance.prototype.get = function get(container) { - var dynamicDependencies = this.dynamicDependencies.length > 0 ? this.dynamicDependencies.map(function (dependency) { - return dependency['protocol:aurelia:resolver'] ? dependency.get(container) : container.get(dependency); - }) : undefined; - var instance = container.invoke(this.key, dynamicDependencies); - container.registerInstance(this.asKey, instance); - return instance; - }; - - NewInstance.prototype.as = function as(key) { - this.asKey = key; - return this; - }; - - NewInstance.of = function of(key) { - for (var _len3 = arguments.length, dynamicDependencies = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { - dynamicDependencies[_key3 - 1] = arguments[_key3]; - } - - return new (Function.prototype.bind.apply(NewInstance, [null].concat([key], dynamicDependencies)))(); - }; - - return NewInstance; - }()) || _class13); - function getDecoratorDependencies(target, name) { - var dependencies = target.inject; - if (typeof dependencies === 'function') { - throw new Error('Decorator ' + name + ' cannot be used with "inject()". Please use an array instead.'); - } - if (!dependencies) { - dependencies = _aureliaMetadata.metadata.getOwn(_aureliaMetadata.metadata.paramTypes, target).slice(); - target.inject = dependencies; - } - - return dependencies; - } - - function lazy(keyValue) { - return function (target, key, index) { - var params = getDecoratorDependencies(target, 'lazy'); - params[index] = Lazy.of(keyValue); - }; - } - - function all(keyValue) { - return function (target, key, index) { - var params = getDecoratorDependencies(target, 'all'); - params[index] = All.of(keyValue); - }; - } - - function optional() { - var checkParentOrTarget = arguments.length <= 0 || arguments[0] === undefined ? true : arguments[0]; - - var deco = function deco(checkParent) { - return function (target, key, index) { - var params = getDecoratorDependencies(target, 'optional'); - params[index] = Optional.of(params[index], checkParent); - }; - }; - if (typeof checkParentOrTarget === 'boolean') { - return deco(checkParentOrTarget); - } - return deco(true); - } - - function parent(target, key, index) { - var params = getDecoratorDependencies(target, 'parent'); - params[index] = Parent.of(params[index]); - } - - function factory(keyValue, asValue) { - return function (target, key, index) { - var params = getDecoratorDependencies(target, 'factory'); - var factory = Factory.of(keyValue); - params[index] = asValue ? factory.as(asValue) : factory; - }; - } - - function newInstance(asKeyOrTarget) { - for (var _len4 = arguments.length, dynamicDependencies = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) { - dynamicDependencies[_key4 - 1] = arguments[_key4]; - } - - var deco = function deco(asKey) { - return function (target, key, index) { - var params = getDecoratorDependencies(target, 'newInstance'); - params[index] = NewInstance.of.apply(NewInstance, [params[index]].concat(dynamicDependencies)); - if (!!asKey) { - params[index].as(asKey); - } - }; - }; - if (arguments.length >= 1) { - return deco(asKeyOrTarget); - } - return deco(); - } - - function invoker(value) { - return function (target) { - _aureliaMetadata.metadata.define(_aureliaMetadata.metadata.invoker, value, target); - }; - } - - function invokeAsFactory(potentialTarget) { - var deco = function deco(target) { - _aureliaMetadata.metadata.define(_aureliaMetadata.metadata.invoker, FactoryInvoker.instance, target); - }; - - return potentialTarget ? deco(potentialTarget) : deco; - } - - var FactoryInvoker = exports.FactoryInvoker = function () { - function FactoryInvoker() { - - } - - FactoryInvoker.prototype.invoke = function invoke(container, fn, dependencies) { - var i = dependencies.length; - var args = new Array(i); - - while (i--) { - args[i] = container.get(dependencies[i]); - } - - return fn.apply(undefined, args); - }; - - FactoryInvoker.prototype.invokeWithDynamicDependencies = function invokeWithDynamicDependencies(container, fn, staticDependencies, dynamicDependencies) { - var i = staticDependencies.length; - var args = new Array(i); - - while (i--) { - args[i] = container.get(staticDependencies[i]); - } - - if (dynamicDependencies !== undefined) { - args = args.concat(dynamicDependencies); - } - - return fn.apply(undefined, args); - }; - - return FactoryInvoker; - }(); - - FactoryInvoker.instance = new FactoryInvoker(); - - function registration(value) { - return function (target) { - _aureliaMetadata.metadata.define(_aureliaMetadata.metadata.registration, value, target); - }; - } - - function transient(key) { - return registration(new TransientRegistration(key)); - } - - function singleton(keyOrRegisterInChild) { - var registerInChild = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; - - return registration(new SingletonRegistration(keyOrRegisterInChild, registerInChild)); - } - - var TransientRegistration = exports.TransientRegistration = function () { - function TransientRegistration(key) { - - - this._key = key; - } - - TransientRegistration.prototype.registerResolver = function registerResolver(container, key, fn) { - return container.registerTransient(this._key || key, fn); - }; - - return TransientRegistration; - }(); - - var SingletonRegistration = exports.SingletonRegistration = function () { - function SingletonRegistration(keyOrRegisterInChild) { - var registerInChild = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; - - - - if (typeof keyOrRegisterInChild === 'boolean') { - this._registerInChild = keyOrRegisterInChild; - } else { - this._key = keyOrRegisterInChild; - this._registerInChild = registerInChild; - } - } - - SingletonRegistration.prototype.registerResolver = function registerResolver(container, key, fn) { - return this._registerInChild ? container.registerSingleton(this._key || key, fn) : container.root.registerSingleton(this._key || key, fn); - }; - - return SingletonRegistration; - }(); - - function validateKey(key) { - if (key === null || key === undefined) { - throw new Error('key/value cannot be null or undefined. Are you trying to inject/register something that doesn\'t exist with DI?'); - } - } - var _emptyParameters = exports._emptyParameters = Object.freeze([]); - - _aureliaMetadata.metadata.registration = 'aurelia:registration'; - _aureliaMetadata.metadata.invoker = 'aurelia:invoker'; - - var resolverDecorates = resolver.decorates; - - var InvocationHandler = exports.InvocationHandler = function () { - function InvocationHandler(fn, invoker, dependencies) { - - - this.fn = fn; - this.invoker = invoker; - this.dependencies = dependencies; - } - - InvocationHandler.prototype.invoke = function invoke(container, dynamicDependencies) { - return dynamicDependencies !== undefined ? this.invoker.invokeWithDynamicDependencies(container, this.fn, this.dependencies, dynamicDependencies) : this.invoker.invoke(container, this.fn, this.dependencies); - }; - - return InvocationHandler; - }(); - - function invokeWithDynamicDependencies(container, fn, staticDependencies, dynamicDependencies) { - var i = staticDependencies.length; - var args = new Array(i); - - while (i--) { - args[i] = container.get(staticDependencies[i]); - } - - if (dynamicDependencies !== undefined) { - args = args.concat(dynamicDependencies); - } - - return Reflect.construct(fn, args); - } - - var classInvokers = (_classInvokers = {}, _classInvokers[0] = { - invoke: function invoke(container, Type) { - return new Type(); - }, - - invokeWithDynamicDependencies: invokeWithDynamicDependencies - }, _classInvokers[1] = { - invoke: function invoke(container, Type, deps) { - return new Type(container.get(deps[0])); - }, - - invokeWithDynamicDependencies: invokeWithDynamicDependencies - }, _classInvokers[2] = { - invoke: function invoke(container, Type, deps) { - return new Type(container.get(deps[0]), container.get(deps[1])); - }, - - invokeWithDynamicDependencies: invokeWithDynamicDependencies - }, _classInvokers[3] = { - invoke: function invoke(container, Type, deps) { - return new Type(container.get(deps[0]), container.get(deps[1]), container.get(deps[2])); - }, - - invokeWithDynamicDependencies: invokeWithDynamicDependencies - }, _classInvokers[4] = { - invoke: function invoke(container, Type, deps) { - return new Type(container.get(deps[0]), container.get(deps[1]), container.get(deps[2]), container.get(deps[3])); - }, - - invokeWithDynamicDependencies: invokeWithDynamicDependencies - }, _classInvokers[5] = { - invoke: function invoke(container, Type, deps) { - return new Type(container.get(deps[0]), container.get(deps[1]), container.get(deps[2]), container.get(deps[3]), container.get(deps[4])); - }, - - invokeWithDynamicDependencies: invokeWithDynamicDependencies - }, _classInvokers.fallback = { - invoke: invokeWithDynamicDependencies, - invokeWithDynamicDependencies: invokeWithDynamicDependencies - }, _classInvokers); - - function getDependencies(f) { - if (!f.hasOwnProperty('inject')) { - return []; - } - - if (typeof f.inject === 'function') { - return f.inject(); - } - - return f.inject; - } - - var Container = exports.Container = function () { - function Container(configuration) { - - - if (configuration === undefined) { - configuration = {}; - } - - this._configuration = configuration; - this._onHandlerCreated = configuration.onHandlerCreated; - this._handlers = configuration.handlers || (configuration.handlers = new Map()); - this._resolvers = new Map(); - this.root = this; - this.parent = null; - } - - Container.prototype.makeGlobal = function makeGlobal() { - Container.instance = this; - return this; - }; - - Container.prototype.setHandlerCreatedCallback = function setHandlerCreatedCallback(onHandlerCreated) { - this._onHandlerCreated = onHandlerCreated; - this._configuration.onHandlerCreated = onHandlerCreated; - }; - - Container.prototype.registerInstance = function registerInstance(key, instance) { - return this.registerResolver(key, new StrategyResolver(0, instance === undefined ? key : instance)); - }; - - Container.prototype.registerSingleton = function registerSingleton(key, fn) { - return this.registerResolver(key, new StrategyResolver(1, fn === undefined ? key : fn)); - }; - - Container.prototype.registerTransient = function registerTransient(key, fn) { - return this.registerResolver(key, new StrategyResolver(2, fn === undefined ? key : fn)); - }; - - Container.prototype.registerHandler = function registerHandler(key, handler) { - return this.registerResolver(key, new StrategyResolver(3, handler)); - }; - - Container.prototype.registerAlias = function registerAlias(originalKey, aliasKey) { - return this.registerResolver(aliasKey, new StrategyResolver(5, originalKey)); - }; - - Container.prototype.registerResolver = function registerResolver(key, resolver) { - validateKey(key); - - var allResolvers = this._resolvers; - var result = allResolvers.get(key); - - if (result === undefined) { - allResolvers.set(key, resolver); - } else if (result.strategy === 4) { - result.state.push(resolver); - } else { - allResolvers.set(key, new StrategyResolver(4, [result, resolver])); - } - - return resolver; - }; - - Container.prototype.autoRegister = function autoRegister(key, fn) { - fn = fn === undefined ? key : fn; - - if (typeof fn === 'function') { - var _registration = _aureliaMetadata.metadata.get(_aureliaMetadata.metadata.registration, fn); - - if (_registration === undefined) { - return this.registerResolver(key, new StrategyResolver(1, fn)); - } - - return _registration.registerResolver(this, key, fn); - } - - return this.registerResolver(key, new StrategyResolver(0, fn)); - }; - - Container.prototype.autoRegisterAll = function autoRegisterAll(fns) { - var i = fns.length; - while (i--) { - this.autoRegister(fns[i]); - } - }; - - Container.prototype.unregister = function unregister(key) { - this._resolvers.delete(key); - }; - - Container.prototype.hasResolver = function hasResolver(key) { - var checkParent = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; - - validateKey(key); - - return this._resolvers.has(key) || checkParent && this.parent !== null && this.parent.hasResolver(key, checkParent); - }; - - Container.prototype.get = function get(key) { - validateKey(key); - - if (key === Container) { - return this; - } - - if (resolverDecorates(key)) { - return key.get(this, key); - } - - var resolver = this._resolvers.get(key); - - if (resolver === undefined) { - if (this.parent === null) { - return this.autoRegister(key).get(this, key); - } - - var _registration2 = _aureliaMetadata.metadata.get(_aureliaMetadata.metadata.registration, key); - - if (_registration2 === undefined) { - return this.parent._get(key); - } - - return _registration2.registerResolver(this, key, key).get(this, key); - } - - return resolver.get(this, key); - }; - - Container.prototype._get = function _get(key) { - var resolver = this._resolvers.get(key); - - if (resolver === undefined) { - if (this.parent === null) { - return this.autoRegister(key).get(this, key); - } - - return this.parent._get(key); - } - - return resolver.get(this, key); - }; - - Container.prototype.getAll = function getAll(key) { - validateKey(key); - - var resolver = this._resolvers.get(key); - - if (resolver === undefined) { - if (this.parent === null) { - return _emptyParameters; - } - - return this.parent.getAll(key); - } - - if (resolver.strategy === 4) { - var state = resolver.state; - var i = state.length; - var results = new Array(i); - - while (i--) { - results[i] = state[i].get(this, key); - } - - return results; - } - - return [resolver.get(this, key)]; - }; - - Container.prototype.createChild = function createChild() { - var child = new Container(this._configuration); - child.root = this.root; - child.parent = this; - return child; - }; - - Container.prototype.invoke = function invoke(fn, dynamicDependencies) { - try { - var _handler = this._handlers.get(fn); - - if (_handler === undefined) { - _handler = this._createInvocationHandler(fn); - this._handlers.set(fn, _handler); - } - - return _handler.invoke(this, dynamicDependencies); - } catch (e) { - throw new _aureliaPal.AggregateError('Error invoking ' + fn.name + '. Check the inner error for details.', e, true); - } - }; - - Container.prototype._createInvocationHandler = function _createInvocationHandler(fn) { - var dependencies = void 0; - - if (fn.inject === undefined) { - dependencies = _aureliaMetadata.metadata.getOwn(_aureliaMetadata.metadata.paramTypes, fn) || _emptyParameters; - } else { - dependencies = []; - var ctor = fn; - while (typeof ctor === 'function') { - var _dependencies; - - (_dependencies = dependencies).push.apply(_dependencies, getDependencies(ctor)); - ctor = Object.getPrototypeOf(ctor); - } - } - - var invoker = _aureliaMetadata.metadata.getOwn(_aureliaMetadata.metadata.invoker, fn) || classInvokers[dependencies.length] || classInvokers.fallback; - - var handler = new InvocationHandler(fn, invoker, dependencies); - return this._onHandlerCreated !== undefined ? this._onHandlerCreated(handler) : handler; - }; - - return Container; - }(); - - function autoinject(potentialTarget) { - var deco = function deco(target) { - var previousInject = target.inject ? target.inject.slice() : null; - var autoInject = _aureliaMetadata.metadata.getOwn(_aureliaMetadata.metadata.paramTypes, target) || _emptyParameters; - if (!previousInject) { - target.inject = autoInject; - } else { - for (var i = 0; i < autoInject.length; i++) { - if (previousInject[i] && previousInject[i] !== autoInject[i]) { - var prevIndex = previousInject.indexOf(autoInject[i]); - if (prevIndex > -1) { - previousInject.splice(prevIndex, 1); - } - previousInject.splice(prevIndex > -1 && prevIndex < i ? i - 1 : i, 0, autoInject[i]); - } else if (!previousInject[i]) { - previousInject[i] = autoInject[i]; - } - } - target.inject = previousInject; - } - }; - - return potentialTarget ? deco(potentialTarget) : deco; - } - - function inject() { - for (var _len5 = arguments.length, rest = Array(_len5), _key5 = 0; _key5 < _len5; _key5++) { - rest[_key5] = arguments[_key5]; - } - - return function (target, key, descriptor) { - if (typeof descriptor === 'number' && rest.length === 1) { - var params = target.inject; - if (typeof params === 'function') { - throw new Error('Decorator inject cannot be used with "inject()". Please use an array instead.'); - } - if (!params) { - params = _aureliaMetadata.metadata.getOwn(_aureliaMetadata.metadata.paramTypes, target).slice(); - target.inject = params; - } - params[descriptor] = rest[0]; - return; - } - - if (descriptor) { - var _fn = descriptor.value; - _fn.inject = rest; - } else { - target.inject = rest; - } - }; - } -}); -define('aurelia-framework',['exports', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-metadata', 'aurelia-templating', 'aurelia-loader', 'aurelia-task-queue', 'aurelia-path', 'aurelia-pal', 'aurelia-logging'], function (exports, _aureliaDependencyInjection, _aureliaBinding, _aureliaMetadata, _aureliaTemplating, _aureliaLoader, _aureliaTaskQueue, _aureliaPath, _aureliaPal, _aureliaLogging) { - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.LogManager = exports.FrameworkConfiguration = exports.Aurelia = undefined; - Object.keys(_aureliaDependencyInjection).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function () { - return _aureliaDependencyInjection[key]; - } - }); - }); - Object.keys(_aureliaBinding).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function () { - return _aureliaBinding[key]; - } - }); - }); - Object.keys(_aureliaMetadata).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function () { - return _aureliaMetadata[key]; - } - }); - }); - Object.keys(_aureliaTemplating).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function () { - return _aureliaTemplating[key]; - } - }); - }); - Object.keys(_aureliaLoader).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function () { - return _aureliaLoader[key]; - } - }); - }); - Object.keys(_aureliaTaskQueue).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function () { - return _aureliaTaskQueue[key]; - } - }); - }); - Object.keys(_aureliaPath).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function () { - return _aureliaPath[key]; - } - }); - }); - Object.keys(_aureliaPal).forEach(function (key) { - if (key === "default" || key === "__esModule") return; - Object.defineProperty(exports, key, { - enumerable: true, - get: function () { - return _aureliaPal[key]; - } - }); - }); - - var TheLogManager = _interopRequireWildcard(_aureliaLogging); - - function _interopRequireWildcard(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; - } - } - - - - function preventActionlessFormSubmit() { - _aureliaPal.DOM.addEventListener('submit', function (evt) { - var target = evt.target; - var action = target.action; - - if (target.tagName.toLowerCase() === 'form' && !action) { - evt.preventDefault(); - } - }); - } - - var Aurelia = exports.Aurelia = function () { - function Aurelia(loader, container, resources) { - - - this.loader = loader || new _aureliaPal.PLATFORM.Loader(); - this.container = container || new _aureliaDependencyInjection.Container().makeGlobal(); - this.resources = resources || new _aureliaTemplating.ViewResources(); - this.use = new FrameworkConfiguration(this); - this.logger = TheLogManager.getLogger('aurelia'); - this.hostConfigured = false; - this.host = null; - - this.use.instance(Aurelia, this); - this.use.instance(_aureliaLoader.Loader, this.loader); - this.use.instance(_aureliaTemplating.ViewResources, this.resources); - } - - Aurelia.prototype.start = function start() { - var _this = this; - - if (this.started) { - return Promise.resolve(this); - } - - this.started = true; - this.logger.info('Aurelia Starting'); - - return this.use.apply().then(function () { - preventActionlessFormSubmit(); - - if (!_this.container.hasResolver(_aureliaTemplating.BindingLanguage)) { - var message = 'You must configure Aurelia with a BindingLanguage implementation.'; - _this.logger.error(message); - throw new Error(message); - } - - _this.logger.info('Aurelia Started'); - var evt = _aureliaPal.DOM.createCustomEvent('aurelia-started', { bubbles: true, cancelable: true }); - _aureliaPal.DOM.dispatchEvent(evt); - return _this; - }); - }; - - Aurelia.prototype.enhance = function enhance() { - var _this2 = this; - - var bindingContext = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; - var applicationHost = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; - - this._configureHost(applicationHost || _aureliaPal.DOM.querySelectorAll('body')[0]); - - return new Promise(function (resolve) { - var engine = _this2.container.get(_aureliaTemplating.TemplatingEngine); - _this2.root = engine.enhance({ container: _this2.container, element: _this2.host, resources: _this2.resources, bindingContext: bindingContext }); - _this2.root.attached(); - _this2._onAureliaComposed(); - resolve(_this2); - }); - }; - - Aurelia.prototype.setRoot = function setRoot() { - var _this3 = this; - - var root = arguments.length <= 0 || arguments[0] === undefined ? null : arguments[0]; - var applicationHost = arguments.length <= 1 || arguments[1] === undefined ? null : arguments[1]; - - var instruction = {}; - - if (this.root && this.root.viewModel && this.root.viewModel.router) { - this.root.viewModel.router.deactivate(); - this.root.viewModel.router.reset(); - } - - this._configureHost(applicationHost); - - var engine = this.container.get(_aureliaTemplating.TemplatingEngine); - var transaction = this.container.get(_aureliaTemplating.CompositionTransaction); - delete transaction.initialComposition; - - if (!root) { - if (this.configModuleId) { - root = (0, _aureliaPath.relativeToFile)('./app', this.configModuleId); - } else { - root = 'app'; - } - } - - instruction.viewModel = root; - instruction.container = instruction.childContainer = this.container; - instruction.viewSlot = this.hostSlot; - instruction.host = this.host; - - return engine.compose(instruction).then(function (r) { - _this3.root = r; - instruction.viewSlot.attached(); - _this3._onAureliaComposed(); - return _this3; - }); - }; - - Aurelia.prototype._configureHost = function _configureHost(applicationHost) { - if (this.hostConfigured) { - return; - } - applicationHost = applicationHost || this.host; - - if (!applicationHost || typeof applicationHost === 'string') { - this.host = _aureliaPal.DOM.getElementById(applicationHost || 'applicationHost'); - } else { - this.host = applicationHost; - } - - if (!this.host) { - throw new Error('No applicationHost was specified.'); - } - - this.hostConfigured = true; - this.host.aurelia = this; - this.hostSlot = new _aureliaTemplating.ViewSlot(this.host, true); - this.hostSlot.transformChildNodesIntoView(); - this.container.registerInstance(_aureliaPal.DOM.boundary, this.host); - }; - - Aurelia.prototype._onAureliaComposed = function _onAureliaComposed() { - var evt = _aureliaPal.DOM.createCustomEvent('aurelia-composed', { bubbles: true, cancelable: true }); - setTimeout(function () { - return _aureliaPal.DOM.dispatchEvent(evt); - }, 1); - }; - - return Aurelia; - }(); - - var logger = TheLogManager.getLogger('aurelia'); - var extPattern = /\.[^/.]+$/; - - function runTasks(config, tasks) { - var current = void 0; - var next = function next() { - current = tasks.shift(); - if (current) { - return Promise.resolve(current(config)).then(next); - } - - return Promise.resolve(); - }; - - return next(); - } - - function loadPlugin(config, loader, info) { - logger.debug('Loading plugin ' + info.moduleId + '.'); - config.resourcesRelativeTo = info.resourcesRelativeTo; - - var id = info.moduleId; - - if (info.resourcesRelativeTo.length > 1) { - return loader.normalize(info.moduleId, info.resourcesRelativeTo[1]).then(function (normalizedId) { - return _loadPlugin(normalizedId); - }); - } - - return _loadPlugin(id); - - function _loadPlugin(moduleId) { - return loader.loadModule(moduleId).then(function (m) { - if ('configure' in m) { - return Promise.resolve(m.configure(config, info.config || {})).then(function () { - config.resourcesRelativeTo = null; - logger.debug('Configured plugin ' + info.moduleId + '.'); - }); - } - - config.resourcesRelativeTo = null; - logger.debug('Loaded plugin ' + info.moduleId + '.'); - }); - } - } - - function loadResources(aurelia, resourcesToLoad, appResources) { - var viewEngine = aurelia.container.get(_aureliaTemplating.ViewEngine); - - return Promise.all(Object.keys(resourcesToLoad).map(function (n) { - return _normalize(resourcesToLoad[n]); - })).then(function (loads) { - var names = []; - var importIds = []; - - loads.forEach(function (l) { - names.push(undefined); - importIds.push(l.importId); - }); - - return viewEngine.importViewResources(importIds, names, appResources); - }); - - function _normalize(load) { - var moduleId = load.moduleId; - var ext = getExt(moduleId); - - if (isOtherResource(moduleId)) { - moduleId = removeExt(moduleId); - } - - return aurelia.loader.normalize(moduleId, load.relativeTo).then(function (normalized) { - return { - name: load.moduleId, - importId: isOtherResource(load.moduleId) ? addOriginalExt(normalized, ext) : normalized - }; - }); - } - - function isOtherResource(name) { - var ext = getExt(name); - if (!ext) return false; - if (ext === '') return false; - if (ext === '.js' || ext === '.ts') return false; - return true; - } - - function removeExt(name) { - return name.replace(extPattern, ''); - } - - function addOriginalExt(normalized, ext) { - return removeExt(normalized) + '.' + ext; - } - } - - function getExt(name) { - var match = name.match(extPattern); - if (match && match.length > 0) { - return match[0].split('.')[1]; - } - } - - function assertProcessed(plugins) { - if (plugins.processed) { - throw new Error('This config instance has already been applied. To load more plugins or global resources, create a new FrameworkConfiguration instance.'); - } - } - - var FrameworkConfiguration = function () { - function FrameworkConfiguration(aurelia) { - var _this4 = this; - - - - this.aurelia = aurelia; - this.container = aurelia.container; - this.info = []; - this.processed = false; - this.preTasks = []; - this.postTasks = []; - this.resourcesToLoad = {}; - this.preTask(function () { - return aurelia.loader.normalize('aurelia-bootstrapper').then(function (name) { - return _this4.bootstrapperName = name; - }); - }); - this.postTask(function () { - return loadResources(aurelia, _this4.resourcesToLoad, aurelia.resources); - }); - } - - FrameworkConfiguration.prototype.instance = function instance(type, _instance) { - this.container.registerInstance(type, _instance); - return this; - }; - - FrameworkConfiguration.prototype.singleton = function singleton(type, implementation) { - this.container.registerSingleton(type, implementation); - return this; - }; - - FrameworkConfiguration.prototype.transient = function transient(type, implementation) { - this.container.registerTransient(type, implementation); - return this; - }; - - FrameworkConfiguration.prototype.preTask = function preTask(task) { - assertProcessed(this); - this.preTasks.push(task); - return this; - }; - - FrameworkConfiguration.prototype.postTask = function postTask(task) { - assertProcessed(this); - this.postTasks.push(task); - return this; - }; - - FrameworkConfiguration.prototype.feature = function feature(plugin, config) { - if (getExt(plugin)) { - return this.plugin({ moduleId: plugin, resourcesRelativeTo: [plugin, ''], config: config || {} }); - } - - return this.plugin({ moduleId: plugin + '/index', resourcesRelativeTo: [plugin, ''], config: config || {} }); - }; - - FrameworkConfiguration.prototype.globalResources = function globalResources(resources) { - assertProcessed(this); - - var toAdd = Array.isArray(resources) ? resources : arguments; - var resource = void 0; - var resourcesRelativeTo = this.resourcesRelativeTo || ['', '']; - - for (var i = 0, ii = toAdd.length; i < ii; ++i) { - resource = toAdd[i]; - if (typeof resource !== 'string') { - throw new Error('Invalid resource path [' + resource + ']. Resources must be specified as relative module IDs.'); - } - - var parent = resourcesRelativeTo[0]; - var grandParent = resourcesRelativeTo[1]; - var name = resource; - - if ((resource.startsWith('./') || resource.startsWith('../')) && parent !== '') { - name = (0, _aureliaPath.join)(parent, resource); - } - - this.resourcesToLoad[name] = { moduleId: name, relativeTo: grandParent }; - } - - return this; - }; - - FrameworkConfiguration.prototype.globalName = function globalName(resourcePath, newName) { - assertProcessed(this); - this.resourcesToLoad[resourcePath] = { moduleId: newName, relativeTo: '' }; - return this; - }; - - FrameworkConfiguration.prototype.plugin = function plugin(_plugin, config) { - assertProcessed(this); - - if (typeof _plugin === 'string') { - return this.plugin({ moduleId: _plugin, resourcesRelativeTo: [_plugin, ''], config: config || {} }); - } - - this.info.push(_plugin); - return this; - }; - - FrameworkConfiguration.prototype._addNormalizedPlugin = function _addNormalizedPlugin(name, config) { - var _this5 = this; - - var plugin = { moduleId: name, resourcesRelativeTo: [name, ''], config: config || {} }; - this.plugin(plugin); - - this.preTask(function () { - var relativeTo = [name, _this5.bootstrapperName]; - plugin.moduleId = name; - plugin.resourcesRelativeTo = relativeTo; - return Promise.resolve(); - }); - - return this; - }; - - FrameworkConfiguration.prototype.defaultBindingLanguage = function defaultBindingLanguage() { - return this._addNormalizedPlugin('aurelia-templating-binding'); - }; - - FrameworkConfiguration.prototype.router = function router() { - return this._addNormalizedPlugin('aurelia-templating-router'); - }; - - FrameworkConfiguration.prototype.history = function history() { - return this._addNormalizedPlugin('aurelia-history-browser'); - }; - - FrameworkConfiguration.prototype.defaultResources = function defaultResources() { - return this._addNormalizedPlugin('aurelia-templating-resources'); - }; - - FrameworkConfiguration.prototype.eventAggregator = function eventAggregator() { - return this._addNormalizedPlugin('aurelia-event-aggregator'); - }; - - FrameworkConfiguration.prototype.basicConfiguration = function basicConfiguration() { - return this.defaultBindingLanguage().defaultResources().eventAggregator(); - }; - - FrameworkConfiguration.prototype.standardConfiguration = function standardConfiguration() { - return this.basicConfiguration().history().router(); - }; - - FrameworkConfiguration.prototype.developmentLogging = function developmentLogging() { - var _this6 = this; - - this.preTask(function () { - return _this6.aurelia.loader.normalize('aurelia-logging-console', _this6.bootstrapperName).then(function (name) { - return _this6.aurelia.loader.loadModule(name).then(function (m) { - TheLogManager.addAppender(new m.ConsoleAppender()); - TheLogManager.setLevel(TheLogManager.logLevel.debug); - }); - }); - }); - - return this; - }; - - FrameworkConfiguration.prototype.apply = function apply() { - var _this7 = this; - - if (this.processed) { - return Promise.resolve(); - } - - return runTasks(this, this.preTasks).then(function () { - var loader = _this7.aurelia.loader; - var info = _this7.info; - var current = void 0; - - var next = function next() { - current = info.shift(); - if (current) { - return loadPlugin(_this7, loader, current).then(next); - } - - _this7.processed = true; - return Promise.resolve(); - }; - - return next().then(function () { - return runTasks(_this7, _this7.postTasks); - }); - }); - }; - - return FrameworkConfiguration; - }(); - - exports.FrameworkConfiguration = FrameworkConfiguration; - var LogManager = exports.LogManager = TheLogManager; -}); -define('aurelia-loader',['exports', 'aurelia-path', 'aurelia-metadata'], function (exports, _aureliaPath, _aureliaMetadata) { - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.Loader = exports.TemplateRegistryEntry = exports.TemplateDependency = undefined; - - var _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; - }; - }(); - - - - var TemplateDependency = exports.TemplateDependency = function TemplateDependency(src, name) { - - - this.src = src; - this.name = name; - }; - - var TemplateRegistryEntry = exports.TemplateRegistryEntry = function () { - function TemplateRegistryEntry(address) { - - - this.templateIsLoaded = false; - this.factoryIsReady = false; - this.resources = null; - this.dependencies = null; - - this.address = address; - this.onReady = null; - this._template = null; - this._factory = null; - } - - TemplateRegistryEntry.prototype.addDependency = function addDependency(src, name) { - var finalSrc = typeof src === 'string' ? (0, _aureliaPath.relativeToFile)(src, this.address) : _aureliaMetadata.Origin.get(src).moduleId; - - this.dependencies.push(new TemplateDependency(finalSrc, name)); - }; - - _createClass(TemplateRegistryEntry, [{ - key: 'template', - get: function get() { - return this._template; - }, - set: function set(value) { - var address = this.address; - var requires = void 0; - var current = void 0; - var src = void 0; - var dependencies = void 0; - - this._template = value; - this.templateIsLoaded = true; - - requires = value.content.querySelectorAll('require'); - dependencies = this.dependencies = new Array(requires.length); - - for (var i = 0, ii = requires.length; i < ii; ++i) { - current = requires[i]; - src = current.getAttribute('from'); - - if (!src) { - throw new Error(' element in ' + address + ' has no "from" attribute.'); - } - - dependencies[i] = new TemplateDependency((0, _aureliaPath.relativeToFile)(src, address), current.getAttribute('as')); - - if (current.parentNode) { - current.parentNode.removeChild(current); - } - } - } - }, { - key: 'factory', - get: function get() { - return this._factory; - }, - set: function set(value) { - this._factory = value; - this.factoryIsReady = true; - } - }]); - - return TemplateRegistryEntry; - }(); - - var Loader = exports.Loader = function () { - function Loader() { - - - this.templateRegistry = {}; - } - - Loader.prototype.map = function map(id, source) { - throw new Error('Loaders must implement map(id, source).'); - }; - - Loader.prototype.normalizeSync = function normalizeSync(moduleId, relativeTo) { - throw new Error('Loaders must implement normalizeSync(moduleId, relativeTo).'); - }; - - Loader.prototype.normalize = function normalize(moduleId, relativeTo) { - throw new Error('Loaders must implement normalize(moduleId: string, relativeTo: string): Promise.'); - }; - - Loader.prototype.loadModule = function loadModule(id) { - throw new Error('Loaders must implement loadModule(id).'); - }; - - Loader.prototype.loadAllModules = function loadAllModules(ids) { - throw new Error('Loader must implement loadAllModules(ids).'); - }; - - Loader.prototype.loadTemplate = function loadTemplate(url) { - throw new Error('Loader must implement loadTemplate(url).'); - }; - - Loader.prototype.loadText = function loadText(url) { - throw new Error('Loader must implement loadText(url).'); - }; - - Loader.prototype.applyPluginToUrl = function applyPluginToUrl(url, pluginName) { - throw new Error('Loader must implement applyPluginToUrl(url, pluginName).'); - }; - - Loader.prototype.addPlugin = function addPlugin(pluginName, implementation) { - throw new Error('Loader must implement addPlugin(pluginName, implementation).'); - }; - - Loader.prototype.getOrCreateTemplateRegistryEntry = function getOrCreateTemplateRegistryEntry(address) { - return this.templateRegistry[address] || (this.templateRegistry[address] = new TemplateRegistryEntry(address)); - }; - - return Loader; - }(); -}); -define('aurelia-logging',['exports'], function (exports) { - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.getLogger = getLogger; - exports.addAppender = addAppender; - exports.setLevel = setLevel; - exports.getLevel = getLevel; - - - - var logLevel = exports.logLevel = { - none: 0, - error: 1, - warn: 2, - info: 3, - debug: 4 - }; - - var loggers = {}; - var appenders = []; - var slice = Array.prototype.slice; - var loggerConstructionKey = {}; - var globalDefaultLevel = logLevel.none; - - function log(logger, level, args) { - var i = appenders.length; - var current = void 0; - - args = slice.call(args); - args.unshift(logger); - - while (i--) { - current = appenders[i]; - current[level].apply(current, args); - } - } - - function debug() { - if (this.level < 4) { - return; - } - - log(this, 'debug', arguments); - } - - function info() { - if (this.level < 3) { - return; - } - - log(this, 'info', arguments); - } - - function warn() { - if (this.level < 2) { - return; - } - - log(this, 'warn', arguments); - } - - function error() { - if (this.level < 1) { - return; - } - - log(this, 'error', arguments); - } - - function connectLogger(logger) { - logger.debug = debug; - logger.info = info; - logger.warn = warn; - logger.error = error; - } - - function createLogger(id) { - var logger = new Logger(id, loggerConstructionKey); - logger.setLevel(globalDefaultLevel); - - if (appenders.length) { - connectLogger(logger); - } - - return logger; - } - - function getLogger(id) { - return loggers[id] || (loggers[id] = createLogger(id)); - } - - function addAppender(appender) { - appenders.push(appender); - - if (appenders.length === 1) { - for (var key in loggers) { - connectLogger(loggers[key]); - } - } - } - - function setLevel(level) { - globalDefaultLevel = level; - for (var key in loggers) { - loggers[key].setLevel(level); - } - } - - function getLevel() { - return globalDefaultLevel; - } - - var Logger = exports.Logger = function () { - function Logger(id, key) { - - - this.level = logLevel.none; - - if (key !== loggerConstructionKey) { - throw new Error('Cannot instantiate "Logger". Use "getLogger" instead.'); - } - - this.id = id; - } - - Logger.prototype.debug = function debug(message) {}; - - Logger.prototype.info = function info(message) {}; - - Logger.prototype.warn = function warn(message) {}; - - Logger.prototype.error = function error(message) {}; - - Logger.prototype.setLevel = function setLevel(level) { - this.level = level; - }; - - return Logger; - }(); -}); -define('aurelia-metadata',['exports', 'aurelia-pal'], function (exports, _aureliaPal) { - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.Origin = exports.metadata = undefined; - exports.decorators = decorators; - exports.deprecated = deprecated; - exports.mixin = mixin; - exports.protocol = protocol; - - var _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; - }; - - - - var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { - return typeof obj; - } : function (obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; - }; - - function isObject(val) { - return val && (typeof val === 'function' || (typeof val === 'undefined' ? 'undefined' : _typeof(val)) === 'object'); - } - - var metadata = exports.metadata = { - resource: 'aurelia:resource', - paramTypes: 'design:paramtypes', - propertyType: 'design:type', - properties: 'design:properties', - get: function get(metadataKey, target, targetKey) { - if (!isObject(target)) { - return undefined; - } - var result = metadata.getOwn(metadataKey, target, targetKey); - return result === undefined ? metadata.get(metadataKey, Object.getPrototypeOf(target), targetKey) : result; - }, - getOwn: function getOwn(metadataKey, target, targetKey) { - if (!isObject(target)) { - return undefined; - } - return Reflect.getOwnMetadata(metadataKey, target, targetKey); - }, - define: function define(metadataKey, metadataValue, target, targetKey) { - Reflect.defineMetadata(metadataKey, metadataValue, target, targetKey); - }, - getOrCreateOwn: function getOrCreateOwn(metadataKey, Type, target, targetKey) { - var result = metadata.getOwn(metadataKey, target, targetKey); - - if (result === undefined) { - result = new Type(); - Reflect.defineMetadata(metadataKey, result, target, targetKey); - } - - return result; - } - }; - - var originStorage = new Map(); - var unknownOrigin = Object.freeze({ moduleId: undefined, moduleMember: undefined }); - - var Origin = exports.Origin = function () { - function Origin(moduleId, moduleMember) { - - - this.moduleId = moduleId; - this.moduleMember = moduleMember; - } - - Origin.get = function get(fn) { - var origin = originStorage.get(fn); - - if (origin === undefined) { - _aureliaPal.PLATFORM.eachModule(function (key, value) { - if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') { - for (var name in value) { - var exp = value[name]; - if (exp === fn) { - originStorage.set(fn, origin = new Origin(key, name)); - return true; - } - } - } - - if (value === fn) { - originStorage.set(fn, origin = new Origin(key, 'default')); - return true; - } - - return false; - }); - } - - return origin || unknownOrigin; - }; - - Origin.set = function set(fn, origin) { - originStorage.set(fn, origin); - }; - - return Origin; - }(); - - function decorators() { - for (var _len = arguments.length, rest = Array(_len), _key = 0; _key < _len; _key++) { - rest[_key] = arguments[_key]; - } - - var applicator = function applicator(target, key, descriptor) { - var i = rest.length; - - if (key) { - descriptor = descriptor || { - value: target[key], - writable: true, - configurable: true, - enumerable: true - }; - - while (i--) { - descriptor = rest[i](target, key, descriptor) || descriptor; - } - - Object.defineProperty(target, key, descriptor); - } else { - while (i--) { - target = rest[i](target) || target; - } - } - - return target; - }; - - applicator.on = applicator; - return applicator; - } - - function deprecated(optionsOrTarget, maybeKey, maybeDescriptor) { - function decorator(target, key, descriptor) { - var methodSignature = target.constructor.name + '#' + key; - var options = maybeKey ? {} : optionsOrTarget || {}; - var message = 'DEPRECATION - ' + methodSignature; - - if (typeof descriptor.value !== 'function') { - throw new SyntaxError('Only methods can be marked as deprecated.'); - } - - if (options.message) { - message += ' - ' + options.message; - } - - return _extends({}, descriptor, { - value: function deprecationWrapper() { - if (options.error) { - throw new Error(message); - } else { - console.warn(message); - } - - return descriptor.value.apply(this, arguments); - } - }); - } - - return maybeKey ? decorator(optionsOrTarget, maybeKey, maybeDescriptor) : decorator; - } - - function mixin(behavior) { - var instanceKeys = Object.keys(behavior); - - function _mixin(possible) { - var decorator = function decorator(target) { - var resolvedTarget = typeof target === 'function' ? target.prototype : target; - - var i = instanceKeys.length; - while (i--) { - var property = instanceKeys[i]; - Object.defineProperty(resolvedTarget, property, { - value: behavior[property], - writable: true - }); - } - }; - - return possible ? decorator(possible) : decorator; - } - - return _mixin; - } - - function alwaysValid() { - return true; - } - function noCompose() {} - - function ensureProtocolOptions(options) { - if (options === undefined) { - options = {}; - } else if (typeof options === 'function') { - options = { - validate: options - }; - } - - if (!options.validate) { - options.validate = alwaysValid; - } - - if (!options.compose) { - options.compose = noCompose; - } - - return options; - } - - function createProtocolValidator(validate) { - return function (target) { - var result = validate(target); - return result === true; - }; - } - - function createProtocolAsserter(name, validate) { - return function (target) { - var result = validate(target); - if (result !== true) { - throw new Error(result || name + ' was not correctly implemented.'); - } - }; - } - - function protocol(name, options) { - options = ensureProtocolOptions(options); - - var result = function result(target) { - var resolvedTarget = typeof target === 'function' ? target.prototype : target; - - options.compose(resolvedTarget); - result.assert(resolvedTarget); - - Object.defineProperty(resolvedTarget, 'protocol:' + name, { - enumerable: false, - configurable: false, - writable: false, - value: true - }); - }; - - result.validate = createProtocolValidator(options.validate); - result.assert = createProtocolAsserter(name, options.validate); - - return result; - } - - protocol.create = function (name, options) { - options = ensureProtocolOptions(options); - var hidden = 'protocol:' + name; - var result = function result(target) { - var decorator = protocol(name, options); - return target ? decorator(target) : decorator; - }; - - result.decorates = function (obj) { - return obj[hidden] === true; - }; - result.validate = createProtocolValidator(options.validate); - result.assert = createProtocolAsserter(name, options.validate); - - return result; - }; -}); -define('aurelia-pal',['exports'], function (exports) { - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.AggregateError = AggregateError; - exports.initializePAL = initializePAL; - exports.reset = reset; - function AggregateError(message, innerError, skipIfAlreadyAggregate) { - if (innerError) { - if (innerError.innerError && skipIfAlreadyAggregate) { - return innerError; - } - - var separator = '\n------------------------------------------------\n'; - - message += separator + 'Inner Error:\n'; - - if (typeof innerError === 'string') { - message += 'Message: ' + innerError; - } else { - if (innerError.message) { - message += 'Message: ' + innerError.message; - } else { - message += 'Unknown Inner Error Type. Displaying Inner Error as JSON:\n ' + JSON.stringify(innerError, null, ' '); - } - - if (innerError.stack) { - message += '\nInner Error Stack:\n' + innerError.stack; - message += '\nEnd Inner Error Stack'; - } - } - - message += separator; - } - - var e = new Error(message); - if (innerError) { - e.innerError = innerError; - } - - return e; - } - - var FEATURE = exports.FEATURE = {}; - - var PLATFORM = exports.PLATFORM = { - noop: function noop() {}, - eachModule: function eachModule() {}, - moduleName: function (_moduleName) { - function moduleName(_x) { - return _moduleName.apply(this, arguments); - } - - moduleName.toString = function () { - return _moduleName.toString(); - }; - - return moduleName; - }(function (moduleName) { - return moduleName; - }) - }; - - PLATFORM.global = function () { - if (typeof self !== 'undefined') { - return self; - } - - if (typeof global !== 'undefined') { - return global; - } - - return new Function('return this')(); - }(); - - var DOM = exports.DOM = {}; - var isInitialized = exports.isInitialized = false; - function initializePAL(callback) { - if (isInitialized) { - return; - } - exports.isInitialized = isInitialized = true; - if (typeof Object.getPropertyDescriptor !== 'function') { - Object.getPropertyDescriptor = function (subject, name) { - var pd = Object.getOwnPropertyDescriptor(subject, name); - var proto = Object.getPrototypeOf(subject); - while (typeof pd === 'undefined' && proto !== null) { - pd = Object.getOwnPropertyDescriptor(proto, name); - proto = Object.getPrototypeOf(proto); - } - return pd; - }; - } - - callback(PLATFORM, FEATURE, DOM); - } - function reset() { - exports.isInitialized = isInitialized = false; - } -}); -define('aurelia-bootstrapper',['exports', 'aurelia-pal', 'aurelia-pal-browser', 'aurelia-polyfills'], function (exports, _aureliaPal, _aureliaPalBrowser) { - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.bootstrap = bootstrap; - - - var bootstrapQueue = []; - var sharedLoader = null; - var Aurelia = null; - - function onBootstrap(callback) { - return new Promise(function (resolve, reject) { - if (sharedLoader) { - resolve(callback(sharedLoader)); - } else { - bootstrapQueue.push(function () { - try { - resolve(callback(sharedLoader)); - } catch (e) { - reject(e); - } - }); - } - }); - } - - function ready(global) { - return new Promise(function (resolve, reject) { - if (global.document.readyState === 'complete') { - resolve(global.document); - } else { - global.document.addEventListener('DOMContentLoaded', completed); - global.addEventListener('load', completed); - } - - function completed() { - global.document.removeEventListener('DOMContentLoaded', completed); - global.removeEventListener('load', completed); - resolve(global.document); - } - }); - } - - function createLoader() { - if (_aureliaPal.PLATFORM.Loader) { - return Promise.resolve(new _aureliaPal.PLATFORM.Loader()); - } - - if (window.System && typeof window.System.import === 'function') { - return System.normalize('aurelia-bootstrapper').then(function (bootstrapperName) { - return System.normalize('aurelia-loader-default', bootstrapperName); - }).then(function (loaderName) { - return System.import(loaderName).then(function (m) { - return new m.DefaultLoader(); - }); - }); - } - - if (typeof window.require === 'function') { - return new Promise(function (resolve, reject) { - return require(['aurelia-loader-default'], function (m) { - return resolve(new m.DefaultLoader()); - }, reject); - }); - } - - return Promise.reject('No PLATFORM.Loader is defined and there is neither a System API (ES6) or a Require API (AMD) globally available to load your app.'); - } - - function preparePlatform(loader) { - return loader.normalize('aurelia-bootstrapper').then(function (bootstrapperName) { - return loader.normalize('aurelia-framework', bootstrapperName).then(function (frameworkName) { - loader.map('aurelia-framework', frameworkName); - - return Promise.all([loader.normalize('aurelia-dependency-injection', frameworkName).then(function (diName) { - return loader.map('aurelia-dependency-injection', diName); - }), loader.normalize('aurelia-router', bootstrapperName).then(function (routerName) { - return loader.map('aurelia-router', routerName); - }), loader.normalize('aurelia-logging-console', bootstrapperName).then(function (loggingConsoleName) { - return loader.map('aurelia-logging-console', loggingConsoleName); - })]).then(function () { - return loader.loadModule(frameworkName).then(function (m) { - return Aurelia = m.Aurelia; - }); - }); - }); - }); - } - - function handleApp(loader, appHost) { - var moduleId = appHost.getAttribute('aurelia-app') || appHost.getAttribute('data-aurelia-app'); - return config(loader, appHost, moduleId); - } - - function config(loader, appHost, configModuleId) { - var aurelia = new Aurelia(loader); - aurelia.host = appHost; - aurelia.configModuleId = configModuleId || null; - - if (configModuleId) { - return loader.loadModule(configModuleId).then(function (customConfig) { - if (!customConfig.configure) { - throw new Error("Cannot initialize module '" + configModuleId + "' without a configure function."); - } - - customConfig.configure(aurelia); - }); - } - - aurelia.use.standardConfiguration().developmentLogging(); - - return aurelia.start().then(function () { - return aurelia.setRoot(); - }); - } - - function run() { - return ready(window).then(function (doc) { - (0, _aureliaPalBrowser.initialize)(); - - var appHost = doc.querySelectorAll('[aurelia-app],[data-aurelia-app]'); - return createLoader().then(function (loader) { - return preparePlatform(loader).then(function () { - for (var i = 0, ii = appHost.length; i < ii; ++i) { - handleApp(loader, appHost[i]).catch(console.error.bind(console)); - } - - sharedLoader = loader; - for (var _i = 0, _ii = bootstrapQueue.length; _i < _ii; ++_i) { - bootstrapQueue[_i](); - } - bootstrapQueue = null; - }); - }); - }); - } - - function bootstrap(configure) { - return onBootstrap(function (loader) { - var aurelia = new Aurelia(loader); - return configure(aurelia); - }); - } - - run(); -}); -define('aurelia-loader-default',['exports', 'aurelia-loader', 'aurelia-pal', 'aurelia-metadata'], function (exports, _aureliaLoader, _aureliaPal, _aureliaMetadata) { - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.DefaultLoader = exports.TextTemplateLoader = undefined; - - function _possibleConstructorReturn(self, call) { - if (!self) { - throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - } - - return call && (typeof call === "object" || typeof call === "function") ? call : self; - } - - function _inherits(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) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; - } - - - - var TextTemplateLoader = exports.TextTemplateLoader = function () { - function TextTemplateLoader() { - - } - - TextTemplateLoader.prototype.loadTemplate = function loadTemplate(loader, entry) { - return loader.loadText(entry.address).then(function (text) { - entry.template = _aureliaPal.DOM.createTemplateFromMarkup(text); - }); - }; - - return TextTemplateLoader; - }(); - - function ensureOriginOnExports(executed, name) { - var target = executed; - var key = void 0; - var exportedValue = void 0; - - if (target.__useDefault) { - target = target['default']; - } - - _aureliaMetadata.Origin.set(target, new _aureliaMetadata.Origin(name, 'default')); - - for (key in target) { - exportedValue = target[key]; - - if (typeof exportedValue === 'function') { - _aureliaMetadata.Origin.set(exportedValue, new _aureliaMetadata.Origin(name, key)); - } - } - - return executed; - } - - var DefaultLoader = exports.DefaultLoader = function (_Loader) { - _inherits(DefaultLoader, _Loader); - - function DefaultLoader() { - - - var _this = _possibleConstructorReturn(this, _Loader.call(this)); - - _this.textPluginName = 'text'; - - - _this.moduleRegistry = Object.create(null); - _this.useTemplateLoader(new TextTemplateLoader()); - - var that = _this; - - _this.addPlugin('template-registry-entry', { - 'fetch': function fetch(address) { - var entry = that.getOrCreateTemplateRegistryEntry(address); - return entry.templateIsLoaded ? entry : that.templateLoader.loadTemplate(that, entry).then(function (x) { - return entry; - }); - } - }); - return _this; - } - - DefaultLoader.prototype.useTemplateLoader = function useTemplateLoader(templateLoader) { - this.templateLoader = templateLoader; - }; - - DefaultLoader.prototype.loadAllModules = function loadAllModules(ids) { - var loads = []; - - for (var i = 0, ii = ids.length; i < ii; ++i) { - loads.push(this.loadModule(ids[i])); - } - - return Promise.all(loads); - }; - - DefaultLoader.prototype.loadTemplate = function loadTemplate(url) { - return this._import(this.applyPluginToUrl(url, 'template-registry-entry')); - }; - - DefaultLoader.prototype.loadText = function loadText(url) { - return this._import(this.applyPluginToUrl(url, this.textPluginName)).then(function (textOrModule) { - if (typeof textOrModule === 'string') { - return textOrModule; - } - - return textOrModule['default']; - }); - }; - - return DefaultLoader; - }(_aureliaLoader.Loader); - - _aureliaPal.PLATFORM.Loader = DefaultLoader; - - if (!_aureliaPal.PLATFORM.global.System || !_aureliaPal.PLATFORM.global.System.import) { - if (_aureliaPal.PLATFORM.global.requirejs && requirejs.s && requirejs.s.contexts && requirejs.s.contexts._ && requirejs.s.contexts._.defined) { - _aureliaPal.PLATFORM.eachModule = function (callback) { - var defined = requirejs.s.contexts._.defined; - for (var key in defined) { - try { - if (callback(key, defined[key])) return; - } catch (e) {} - } - }; - } else { - _aureliaPal.PLATFORM.eachModule = function (callback) {}; - } - - DefaultLoader.prototype._import = function (moduleId) { - return new Promise(function (resolve, reject) { - require([moduleId], resolve, reject); - }); - }; - - DefaultLoader.prototype.loadModule = function (id) { - var _this2 = this; - - var existing = this.moduleRegistry[id]; - if (existing !== undefined) { - return Promise.resolve(existing); - } - - return new Promise(function (resolve, reject) { - require([id], function (m) { - _this2.moduleRegistry[id] = m; - resolve(ensureOriginOnExports(m, id)); - }, reject); - }); - }; - - DefaultLoader.prototype.map = function (id, source) {}; - - DefaultLoader.prototype.normalize = function (moduleId, relativeTo) { - return Promise.resolve(moduleId); - }; - - DefaultLoader.prototype.normalizeSync = function (moduleId, relativeTo) { - return moduleId; - }; - - DefaultLoader.prototype.applyPluginToUrl = function (url, pluginName) { - return pluginName + '!' + url; - }; - - DefaultLoader.prototype.addPlugin = function (pluginName, implementation) { - var nonAnonDefine = define; - nonAnonDefine(pluginName, [], { - 'load': function load(name, req, onload) { - var result = implementation.fetch(name); - Promise.resolve(result).then(onload); - } - }); - }; - } else { - _aureliaPal.PLATFORM.eachModule = function (callback) { - var modules = System._loader.modules; - - for (var key in modules) { - try { - if (callback(key, modules[key].module)) return; - } catch (e) {} - } - }; - - System.set('text', System.newModule({ - 'translate': function translate(load) { - return 'module.exports = "' + load.source.replace(/(["\\])/g, '\\$1').replace(/[\f]/g, '\\f').replace(/[\b]/g, '\\b').replace(/[\n]/g, '\\n').replace(/[\t]/g, '\\t').replace(/[\r]/g, '\\r').replace(/[\u2028]/g, '\\u2028').replace(/[\u2029]/g, '\\u2029') + '";'; - } - })); - - DefaultLoader.prototype._import = function (moduleId) { - return System.import(moduleId); - }; - - DefaultLoader.prototype.loadModule = function (id) { - var _this3 = this; - - return System.normalize(id).then(function (newId) { - var existing = _this3.moduleRegistry[newId]; - if (existing !== undefined) { - return Promise.resolve(existing); - } - - return System.import(newId).then(function (m) { - _this3.moduleRegistry[newId] = m; - return ensureOriginOnExports(m, newId); - }); - }); - }; - - DefaultLoader.prototype.map = function (id, source) { - System.map[id] = source; - }; - - DefaultLoader.prototype.normalizeSync = function (moduleId, relativeTo) { - return System.normalizeSync(moduleId, relativeTo); - }; - - DefaultLoader.prototype.normalize = function (moduleId, relativeTo) { - return System.normalize(moduleId, relativeTo); - }; - - DefaultLoader.prototype.applyPluginToUrl = function (url, pluginName) { - return url + '!' + pluginName; - }; - - DefaultLoader.prototype.addPlugin = function (pluginName, implementation) { - System.set(pluginName, System.newModule({ - 'fetch': function fetch(load, _fetch) { - var result = implementation.fetch(load.address); - return Promise.resolve(result).then(function (x) { - load.metadata.result = x; - return ''; - }); - }, - 'instantiate': function instantiate(load) { - return load.metadata.result; - } - })); - }; - } -}); -define('aurelia-path',['exports'], function (exports) { - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.relativeToFile = relativeToFile; - exports.join = join; - exports.buildQueryString = buildQueryString; - exports.parseQueryString = parseQueryString; - - var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { - return typeof obj; - } : function (obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; - }; - - function trimDots(ary) { - for (var i = 0; i < ary.length; ++i) { - var part = ary[i]; - if (part === '.') { - ary.splice(i, 1); - i -= 1; - } else if (part === '..') { - if (i === 0 || i === 1 && ary[2] === '..' || ary[i - 1] === '..') { - continue; - } else if (i > 0) { - ary.splice(i - 1, 2); - i -= 2; - } - } - } - } - - function relativeToFile(name, file) { - var fileParts = file && file.split('/'); - var nameParts = name.trim().split('/'); - - if (nameParts[0].charAt(0) === '.' && fileParts) { - var normalizedBaseParts = fileParts.slice(0, fileParts.length - 1); - nameParts.unshift.apply(nameParts, normalizedBaseParts); - } - - trimDots(nameParts); - - return nameParts.join('/'); - } - - function join(path1, path2) { - if (!path1) { - return path2; - } - - if (!path2) { - return path1; - } - - var schemeMatch = path1.match(/^([^/]*?:)\//); - var scheme = schemeMatch && schemeMatch.length > 0 ? schemeMatch[1] : ''; - path1 = path1.substr(scheme.length); - - var urlPrefix = void 0; - if (path1.indexOf('///') === 0 && scheme === 'file:') { - urlPrefix = '///'; - } else if (path1.indexOf('//') === 0) { - urlPrefix = '//'; - } else if (path1.indexOf('/') === 0) { - urlPrefix = '/'; - } else { - urlPrefix = ''; - } - - var trailingSlash = path2.slice(-1) === '/' ? '/' : ''; - - var url1 = path1.split('/'); - var url2 = path2.split('/'); - var url3 = []; - - for (var i = 0, ii = url1.length; i < ii; ++i) { - if (url1[i] === '..') { - url3.pop(); - } else if (url1[i] === '.' || url1[i] === '') { - continue; - } else { - url3.push(url1[i]); - } - } - - for (var _i = 0, _ii = url2.length; _i < _ii; ++_i) { - if (url2[_i] === '..') { - url3.pop(); - } else if (url2[_i] === '.' || url2[_i] === '') { - continue; - } else { - url3.push(url2[_i]); - } - } - - return scheme + urlPrefix + url3.join('/') + trailingSlash; - } - - var encode = encodeURIComponent; - var encodeKey = function encodeKey(k) { - return encode(k).replace('%24', '$'); - }; - - function buildParam(key, value, traditional) { - var result = []; - if (value === null || value === undefined) { - return result; - } - if (Array.isArray(value)) { - for (var i = 0, l = value.length; i < l; i++) { - if (traditional) { - result.push(encodeKey(key) + '=' + encode(value[i])); - } else { - var arrayKey = key + '[' + (_typeof(value[i]) === 'object' && value[i] !== null ? i : '') + ']'; - result = result.concat(buildParam(arrayKey, value[i])); - } - } - } else if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && !traditional) { - for (var propertyName in value) { - result = result.concat(buildParam(key + '[' + propertyName + ']', value[propertyName])); - } - } else { - result.push(encodeKey(key) + '=' + encode(value)); - } - return result; - } - - function buildQueryString(params, traditional) { - var pairs = []; - var keys = Object.keys(params || {}).sort(); - for (var i = 0, len = keys.length; i < len; i++) { - var key = keys[i]; - pairs = pairs.concat(buildParam(key, params[key], traditional)); - } - - if (pairs.length === 0) { - return ''; - } - - return pairs.join('&'); - } - - function processScalarParam(existedParam, value) { - if (Array.isArray(existedParam)) { - existedParam.push(value); - return existedParam; - } - if (existedParam !== undefined) { - return [existedParam, value]; - } - - return value; - } - - function parseComplexParam(queryParams, keys, value) { - var currentParams = queryParams; - var keysLastIndex = keys.length - 1; - for (var j = 0; j <= keysLastIndex; j++) { - var key = keys[j] === '' ? currentParams.length : keys[j]; - if (j < keysLastIndex) { - var prevValue = !currentParams[key] || _typeof(currentParams[key]) === 'object' ? currentParams[key] : [currentParams[key]]; - currentParams = currentParams[key] = prevValue || (isNaN(keys[j + 1]) ? {} : []); - } else { - currentParams = currentParams[key] = value; - } - } - } - - function parseQueryString(queryString) { - var queryParams = {}; - if (!queryString || typeof queryString !== 'string') { - return queryParams; - } - - var query = queryString; - if (query.charAt(0) === '?') { - query = query.substr(1); - } - - var pairs = query.replace(/\+/g, ' ').split('&'); - for (var i = 0; i < pairs.length; i++) { - var pair = pairs[i].split('='); - var key = decodeURIComponent(pair[0]); - if (!key) { - continue; - } - - var keys = key.split(']['); - var keysLastIndex = keys.length - 1; - - if (/\[/.test(keys[0]) && /\]$/.test(keys[keysLastIndex])) { - keys[keysLastIndex] = keys[keysLastIndex].replace(/\]$/, ''); - keys = keys.shift().split('[').concat(keys); - keysLastIndex = keys.length - 1; - } else { - keysLastIndex = 0; - } - - if (pair.length >= 2) { - var value = pair[1] ? decodeURIComponent(pair[1]) : ''; - if (keysLastIndex) { - parseComplexParam(queryParams, keys, value); - } else { - queryParams[key] = processScalarParam(queryParams[key], value); - } - } else { - queryParams[key] = true; - } - } - return queryParams; - } -}); -define('aurelia-polyfills',['aurelia-pal'], function (_aureliaPal) { - 'use strict'; - - var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { - return typeof obj; - } : function (obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; - }; - - (function (Object, GOPS) { - 'use strict'; - - if (GOPS in Object) return; - - var setDescriptor, - G = _aureliaPal.PLATFORM.global, - id = 0, - random = '' + Math.random(), - prefix = '__\x01symbol:', - prefixLength = prefix.length, - internalSymbol = '__\x01symbol@@' + random, - DP = 'defineProperty', - DPies = 'defineProperties', - GOPN = 'getOwnPropertyNames', - GOPD = 'getOwnPropertyDescriptor', - PIE = 'propertyIsEnumerable', - gOPN = Object[GOPN], - gOPD = Object[GOPD], - create = Object.create, - keys = Object.keys, - defineProperty = Object[DP], - $defineProperties = Object[DPies], - descriptor = gOPD(Object, GOPN), - ObjectProto = Object.prototype, - hOP = ObjectProto.hasOwnProperty, - pIE = ObjectProto[PIE], - toString = ObjectProto.toString, - indexOf = Array.prototype.indexOf || function (v) { - for (var i = this.length; i-- && this[i] !== v;) {} - return i; - }, - addInternalIfNeeded = function addInternalIfNeeded(o, uid, enumerable) { - if (!hOP.call(o, internalSymbol)) { - defineProperty(o, internalSymbol, { - enumerable: false, - configurable: false, - writable: false, - value: {} - }); - } - o[internalSymbol]['@@' + uid] = enumerable; - }, - createWithSymbols = function createWithSymbols(proto, descriptors) { - var self = create(proto); - gOPN(descriptors).forEach(function (key) { - if (propertyIsEnumerable.call(descriptors, key)) { - $defineProperty(self, key, descriptors[key]); - } - }); - return self; - }, - copyAsNonEnumerable = function copyAsNonEnumerable(descriptor) { - var newDescriptor = create(descriptor); - newDescriptor.enumerable = false; - return newDescriptor; - }, - get = function get() {}, - onlyNonSymbols = function onlyNonSymbols(name) { - return name != internalSymbol && !hOP.call(source, name); - }, - onlySymbols = function onlySymbols(name) { - return name != internalSymbol && hOP.call(source, name); - }, - propertyIsEnumerable = function propertyIsEnumerable(key) { - var uid = '' + key; - return onlySymbols(uid) ? hOP.call(this, uid) && this[internalSymbol]['@@' + uid] : pIE.call(this, key); - }, - setAndGetSymbol = function setAndGetSymbol(uid) { - var descriptor = { - enumerable: false, - configurable: true, - get: get, - set: function set(value) { - setDescriptor(this, uid, { - enumerable: false, - configurable: true, - writable: true, - value: value - }); - addInternalIfNeeded(this, uid, true); - } - }; - defineProperty(ObjectProto, uid, descriptor); - return source[uid] = defineProperty(Object(uid), 'constructor', sourceConstructor); - }, - _Symbol = function _Symbol2(description) { - if (this && this !== G) { - throw new TypeError('Symbol is not a constructor'); - } - return setAndGetSymbol(prefix.concat(description || '', random, ++id)); - }, - source = create(null), - sourceConstructor = { value: _Symbol }, - sourceMap = function sourceMap(uid) { - return source[uid]; - }, - $defineProperty = function defineProp(o, key, descriptor) { - var uid = '' + key; - if (onlySymbols(uid)) { - setDescriptor(o, uid, descriptor.enumerable ? copyAsNonEnumerable(descriptor) : descriptor); - addInternalIfNeeded(o, uid, !!descriptor.enumerable); - } else { - defineProperty(o, key, descriptor); - } - return o; - }, - $getOwnPropertySymbols = function getOwnPropertySymbols(o) { - var cof = toString.call(o); - o = cof === '[object String]' ? o.split('') : Object(o); - return gOPN(o).filter(onlySymbols).map(sourceMap); - }; - - descriptor.value = $defineProperty; - defineProperty(Object, DP, descriptor); - - descriptor.value = $getOwnPropertySymbols; - defineProperty(Object, GOPS, descriptor); - - descriptor.value = function getOwnPropertyNames(o) { - return gOPN(o).filter(onlyNonSymbols); - }; - defineProperty(Object, GOPN, descriptor); - - descriptor.value = function defineProperties(o, descriptors) { - var symbols = $getOwnPropertySymbols(descriptors); - if (symbols.length) { - keys(descriptors).concat(symbols).forEach(function (uid) { - if (propertyIsEnumerable.call(descriptors, uid)) { - $defineProperty(o, uid, descriptors[uid]); - } - }); - } else { - $defineProperties(o, descriptors); - } - return o; - }; - defineProperty(Object, DPies, descriptor); - - descriptor.value = propertyIsEnumerable; - defineProperty(ObjectProto, PIE, descriptor); - - descriptor.value = _Symbol; - defineProperty(G, 'Symbol', descriptor); - - descriptor.value = function (key) { - var uid = prefix.concat(prefix, key, random); - return uid in ObjectProto ? source[uid] : setAndGetSymbol(uid); - }; - defineProperty(_Symbol, 'for', descriptor); - - descriptor.value = function (symbol) { - return hOP.call(source, symbol) ? symbol.slice(prefixLength * 2, -random.length) : void 0; - }; - defineProperty(_Symbol, 'keyFor', descriptor); - - descriptor.value = function getOwnPropertyDescriptor(o, key) { - var descriptor = gOPD(o, key); - if (descriptor && onlySymbols(key)) { - descriptor.enumerable = propertyIsEnumerable.call(o, key); - } - return descriptor; - }; - defineProperty(Object, GOPD, descriptor); - - descriptor.value = function (proto, descriptors) { - return arguments.length === 1 ? create(proto) : createWithSymbols(proto, descriptors); - }; - defineProperty(Object, 'create', descriptor); - - descriptor.value = function () { - var str = toString.call(this); - return str === '[object String]' && onlySymbols(this) ? '[object Symbol]' : str; - }; - defineProperty(ObjectProto, 'toString', descriptor); - - try { - setDescriptor = create(defineProperty({}, prefix, { - get: function get() { - return defineProperty(this, prefix, { value: false })[prefix]; - } - }))[prefix] || defineProperty; - } catch (o_O) { - setDescriptor = function setDescriptor(o, key, descriptor) { - var protoDescriptor = gOPD(ObjectProto, key); - delete ObjectProto[key]; - defineProperty(o, key, descriptor); - defineProperty(ObjectProto, key, protoDescriptor); - }; - } - })(Object, 'getOwnPropertySymbols'); - - (function (O, S) { - var dP = O.defineProperty, - ObjectProto = O.prototype, - toString = ObjectProto.toString, - toStringTag = 'toStringTag', - descriptor; - ['iterator', 'match', 'replace', 'search', 'split', 'hasInstance', 'isConcatSpreadable', 'unscopables', 'species', 'toPrimitive', toStringTag].forEach(function (name) { - if (!(name in Symbol)) { - dP(Symbol, name, { value: Symbol(name) }); - switch (name) { - case toStringTag: - descriptor = O.getOwnPropertyDescriptor(ObjectProto, 'toString'); - descriptor.value = function () { - var str = toString.call(this), - tst = typeof this === 'undefined' || this === null ? undefined : this[Symbol.toStringTag]; - return typeof tst === 'undefined' ? str : '[object ' + tst + ']'; - }; - dP(ObjectProto, 'toString', descriptor); - break; - } - } - }); - })(Object, Symbol); - - (function (Si, AP, SP) { - - function returnThis() { - return this; - } - - if (!AP[Si]) AP[Si] = function () { - var i = 0, - self = this, - iterator = { - next: function next() { - var done = self.length <= i; - return done ? { done: done } : { done: done, value: self[i++] }; - } - }; - iterator[Si] = returnThis; - return iterator; - }; - - if (!SP[Si]) SP[Si] = function () { - var fromCodePoint = String.fromCodePoint, - self = this, - i = 0, - length = self.length, - iterator = { - next: function next() { - var done = length <= i, - c = done ? '' : fromCodePoint(self.codePointAt(i)); - i += c.length; - return done ? { done: done } : { done: done, value: c }; - } - }; - iterator[Si] = returnThis; - return iterator; - }; - })(Symbol.iterator, Array.prototype, String.prototype); - - Number.isNaN = Number.isNaN || function (value) { - return value !== value; - }; - - Number.isFinite = Number.isFinite || function (value) { - return typeof value === "number" && isFinite(value); - }; - if (!String.prototype.endsWith || function () { - try { - return !"ab".endsWith("a", 1); - } catch (e) { - return true; - } - }()) { - String.prototype.endsWith = function (searchString, position) { - var subjectString = this.toString(); - if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) { - position = subjectString.length; - } - position -= searchString.length; - var lastIndex = subjectString.indexOf(searchString, position); - return lastIndex !== -1 && lastIndex === position; - }; - } - - if (!String.prototype.startsWith || function () { - try { - return !"ab".startsWith("b", 1); - } catch (e) { - return true; - } - }()) { - String.prototype.startsWith = function (searchString, position) { - position = position || 0; - return this.substr(position, searchString.length) === searchString; - }; - } - - if (!Array.from) { - Array.from = function () { - var toInteger = function toInteger(it) { - return isNaN(it = +it) ? 0 : (it > 0 ? Math.floor : Math.ceil)(it); - }; - var toLength = function toLength(it) { - return it > 0 ? Math.min(toInteger(it), 0x1fffffffffffff) : 0; - }; - var iterCall = function iterCall(iter, fn, val, index) { - try { - return fn(val, index); - } catch (E) { - if (typeof iter.return == 'function') iter.return(); - throw E; - } - }; - - return function from(arrayLike) { - var O = Object(arrayLike), - C = typeof this == 'function' ? this : Array, - aLen = arguments.length, - mapfn = aLen > 1 ? arguments[1] : undefined, - mapping = mapfn !== undefined, - index = 0, - iterFn = O[Symbol.iterator], - length, - result, - step, - iterator; - if (mapping) mapfn = mapfn.bind(aLen > 2 ? arguments[2] : undefined); - if (iterFn != undefined && !Array.isArray(arrayLike)) { - for (iterator = iterFn.call(O), result = new C(); !(step = iterator.next()).done; index++) { - result[index] = mapping ? iterCall(iterator, mapfn, step.value, index) : step.value; - } - } else { - length = toLength(O.length); - for (result = new C(length); length > index; index++) { - result[index] = mapping ? mapfn(O[index], index) : O[index]; - } - } - result.length = index; - return result; - }; - }(); - } - - if (!Array.prototype.find) { - Object.defineProperty(Array.prototype, 'find', { - configurable: true, - writable: true, - enumerable: false, - value: function value(predicate) { - if (this === null) { - throw new TypeError('Array.prototype.find called on null or undefined'); - } - if (typeof predicate !== 'function') { - throw new TypeError('predicate must be a function'); - } - var list = Object(this); - var length = list.length >>> 0; - var thisArg = arguments[1]; - var value; - - for (var i = 0; i < length; i++) { - value = list[i]; - if (predicate.call(thisArg, value, i, list)) { - return value; - } - } - return undefined; - } - }); - } - - if (!Array.prototype.findIndex) { - Object.defineProperty(Array.prototype, 'findIndex', { - configurable: true, - writable: true, - enumerable: false, - value: function value(predicate) { - if (this === null) { - throw new TypeError('Array.prototype.findIndex called on null or undefined'); - } - if (typeof predicate !== 'function') { - throw new TypeError('predicate must be a function'); - } - var list = Object(this); - var length = list.length >>> 0; - var thisArg = arguments[1]; - var value; - - for (var i = 0; i < length; i++) { - value = list[i]; - if (predicate.call(thisArg, value, i, list)) { - return i; - } - } - return -1; - } - }); - } - - if (!Array.prototype.includes) { - Object.defineProperty(Array.prototype, 'includes', { - configurable: true, - writable: true, - enumerable: false, - value: function value(searchElement) { - var O = Object(this); - var len = parseInt(O.length) || 0; - if (len === 0) { - return false; - } - var n = parseInt(arguments[1]) || 0; - var k; - if (n >= 0) { - k = n; - } else { - k = len + n; - if (k < 0) { - k = 0; - } - } - var currentElement; - while (k < len) { - currentElement = O[k]; - if (searchElement === currentElement || searchElement !== searchElement && currentElement !== currentElement) { - return true; - } - k++; - } - return false; - } - }); - } - - (function () { - var needsFix = false; - - try { - var s = Object.keys('a'); - needsFix = s.length !== 1 || s[0] !== '0'; - } catch (e) { - needsFix = true; - } - - if (needsFix) { - Object.keys = function () { - var hasOwnProperty = Object.prototype.hasOwnProperty, - hasDontEnumBug = !{ toString: null }.propertyIsEnumerable('toString'), - dontEnums = ['toString', 'toLocaleString', 'valueOf', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'constructor'], - dontEnumsLength = dontEnums.length; - - return function (obj) { - if (obj === undefined || obj === null) { - throw TypeError('Cannot convert undefined or null to object'); - } - - obj = Object(obj); - - var result = [], - prop, - i; - - for (prop in obj) { - if (hasOwnProperty.call(obj, prop)) { - result.push(prop); - } - } - - if (hasDontEnumBug) { - for (i = 0; i < dontEnumsLength; i++) { - if (hasOwnProperty.call(obj, dontEnums[i])) { - result.push(dontEnums[i]); - } - } - } - - return result; - }; - }(); - } - })(); - - (function (O) { - if ('assign' in O) { - return; - } - - O.defineProperty(O, 'assign', { - configurable: true, - writable: true, - value: function () { - var gOPS = O.getOwnPropertySymbols, - pIE = O.propertyIsEnumerable, - filterOS = gOPS ? function (self) { - return gOPS(self).filter(pIE, self); - } : function () { - return Array.prototype; - }; - - return function assign(where) { - if (gOPS && !(where instanceof O)) { - console.warn('problematic Symbols', where); - } - - function set(keyOrSymbol) { - where[keyOrSymbol] = arg[keyOrSymbol]; - } - - for (var i = 1, ii = arguments.length; i < ii; ++i) { - var arg = arguments[i]; - - if (arg === null || arg === undefined) { - continue; - } - - O.keys(arg).concat(filterOS(arg)).forEach(set); - } - - return where; - }; - }() - }); - })(Object); - - (function (global) { - var i; - - var defineProperty = Object.defineProperty, - is = function is(a, b) { - return a === b || a !== a && b !== b; - }; - - if (typeof WeakMap == 'undefined') { - global.WeakMap = createCollection({ - 'delete': sharedDelete, - - clear: sharedClear, - - get: sharedGet, - - has: mapHas, - - set: sharedSet - }, true); - } - - if (typeof Map == 'undefined' || typeof new Map().values !== 'function' || !new Map().values().next) { - var _createCollection; - - global.Map = createCollection((_createCollection = { - 'delete': sharedDelete, - - has: mapHas, - - get: sharedGet, - - set: sharedSet, - - keys: sharedKeys, - - values: sharedValues, - - entries: mapEntries, - - forEach: sharedForEach, - - clear: sharedClear - }, _createCollection[Symbol.iterator] = mapEntries, _createCollection)); - } - - if (typeof Set == 'undefined' || typeof new Set().values !== 'function' || !new Set().values().next) { - var _createCollection2; - - global.Set = createCollection((_createCollection2 = { - has: setHas, - - add: sharedAdd, - - 'delete': sharedDelete, - - clear: sharedClear, - - keys: sharedValues, - values: sharedValues, - - entries: setEntries, - - forEach: sharedForEach - }, _createCollection2[Symbol.iterator] = sharedValues, _createCollection2)); - } - - if (typeof WeakSet == 'undefined') { - global.WeakSet = createCollection({ - 'delete': sharedDelete, - - add: sharedAdd, - - clear: sharedClear, - - has: setHas - }, true); - } - - function createCollection(proto, objectOnly) { - function Collection(a) { - if (!this || this.constructor !== Collection) return new Collection(a); - this._keys = []; - this._values = []; - this._itp = []; - this.objectOnly = objectOnly; - - if (a) init.call(this, a); - } - - if (!objectOnly) { - defineProperty(proto, 'size', { - get: sharedSize - }); - } - - proto.constructor = Collection; - Collection.prototype = proto; - - return Collection; - } - - function init(a) { - var i; - - if (this.add) a.forEach(this.add, this);else a.forEach(function (a) { - this.set(a[0], a[1]); - }, this); - } - - function sharedDelete(key) { - if (this.has(key)) { - this._keys.splice(i, 1); - this._values.splice(i, 1); - - this._itp.forEach(function (p) { - if (i < p[0]) p[0]--; - }); - } - - return -1 < i; - }; - - function sharedGet(key) { - return this.has(key) ? this._values[i] : undefined; - } - - function has(list, key) { - if (this.objectOnly && key !== Object(key)) throw new TypeError("Invalid value used as weak collection key"); - - if (key != key || key === 0) for (i = list.length; i-- && !is(list[i], key);) {} else i = list.indexOf(key); - return -1 < i; - } - - function setHas(value) { - return has.call(this, this._values, value); - } - - function mapHas(value) { - return has.call(this, this._keys, value); - } - - function sharedSet(key, value) { - this.has(key) ? this._values[i] = value : this._values[this._keys.push(key) - 1] = value; - return this; - } - - function sharedAdd(value) { - if (!this.has(value)) this._values.push(value); - return this; - } - - function sharedClear() { - (this._keys || 0).length = this._values.length = 0; - } - - function sharedKeys() { - return sharedIterator(this._itp, this._keys); - } - - function sharedValues() { - return sharedIterator(this._itp, this._values); - } - - function mapEntries() { - return sharedIterator(this._itp, this._keys, this._values); - } - - function setEntries() { - return sharedIterator(this._itp, this._values, this._values); - } - - function sharedIterator(itp, array, array2) { - var _ref; - - var p = [0], - done = false; - itp.push(p); - return _ref = {}, _ref[Symbol.iterator] = function () { - return this; - }, _ref.next = function next() { - var v, - k = p[0]; - if (!done && k < array.length) { - v = array2 ? [array[k], array2[k]] : array[k]; - p[0]++; - } else { - done = true; - itp.splice(itp.indexOf(p), 1); - } - return { done: done, value: v }; - }, _ref; - } - - function sharedSize() { - return this._values.length; - } - - function sharedForEach(callback, context) { - var it = this.entries(); - for (;;) { - var r = it.next(); - if (r.done) break; - callback.call(context, r.value[1], r.value[0], this); - } - } - })(_aureliaPal.PLATFORM.global); - - var emptyMetadata = Object.freeze({}); - var metadataContainerKey = '__metadata__'; - var bind = Function.prototype.bind; - - if (typeof _aureliaPal.PLATFORM.global.Reflect === 'undefined') { - _aureliaPal.PLATFORM.global.Reflect = {}; - } - - if (typeof Reflect.getOwnMetadata !== 'function') { - Reflect.getOwnMetadata = function (metadataKey, target, targetKey) { - if (target.hasOwnProperty(metadataContainerKey)) { - return (target[metadataContainerKey][targetKey] || emptyMetadata)[metadataKey]; - } - }; - } - - if (typeof Reflect.defineMetadata !== 'function') { - Reflect.defineMetadata = function (metadataKey, metadataValue, target, targetKey) { - var metadataContainer = target.hasOwnProperty(metadataContainerKey) ? target[metadataContainerKey] : target[metadataContainerKey] = {}; - var targetContainer = metadataContainer[targetKey] || (metadataContainer[targetKey] = {}); - targetContainer[metadataKey] = metadataValue; - }; - } - - if (typeof Reflect.metadata !== 'function') { - Reflect.metadata = function (metadataKey, metadataValue) { - return function (target, targetKey) { - Reflect.defineMetadata(metadataKey, metadataValue, target, targetKey); - }; - }; - } - - if (typeof Reflect.defineProperty !== 'function') { - Reflect.defineProperty = function (target, propertyKey, descriptor) { - if ((typeof target === 'undefined' ? 'undefined' : _typeof(target)) === 'object' ? target === null : typeof target !== 'function') { - throw new TypeError('Reflect.defineProperty called on non-object'); - } - try { - Object.defineProperty(target, propertyKey, descriptor); - return true; - } catch (e) { - return false; - } - }; - } - - if (typeof Reflect.construct !== 'function') { - Reflect.construct = function (Target, args) { - if (args) { - switch (args.length) { - case 0: - return new Target(); - case 1: - return new Target(args[0]); - case 2: - return new Target(args[0], args[1]); - case 3: - return new Target(args[0], args[1], args[2]); - case 4: - return new Target(args[0], args[1], args[2], args[3]); - } - } - - var a = [null]; - a.push.apply(a, args); - return new (bind.apply(Target, a))(); - }; - } - - if (typeof Reflect.ownKeys !== 'function') { - Reflect.ownKeys = function (o) { - return Object.getOwnPropertyNames(o).concat(Object.getOwnPropertySymbols(o)); - }; - } -}); -define('aurelia-task-queue',['exports', 'aurelia-pal'], function (exports, _aureliaPal) { - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.TaskQueue = undefined; - - - - var hasSetImmediate = typeof setImmediate === 'function'; - - function makeRequestFlushFromMutationObserver(flush) { - var toggle = 1; - var observer = _aureliaPal.DOM.createMutationObserver(flush); - var node = _aureliaPal.DOM.createTextNode(''); - observer.observe(node, { characterData: true }); - return function requestFlush() { - toggle = -toggle; - node.data = toggle; - }; - } - - function makeRequestFlushFromTimer(flush) { - return function requestFlush() { - var timeoutHandle = setTimeout(handleFlushTimer, 0); - - var intervalHandle = setInterval(handleFlushTimer, 50); - function handleFlushTimer() { - clearTimeout(timeoutHandle); - clearInterval(intervalHandle); - flush(); - } - }; - } - - function onError(error, task) { - if ('onError' in task) { - task.onError(error); - } else if (hasSetImmediate) { - setImmediate(function () { - throw error; - }); - } else { - setTimeout(function () { - throw error; - }, 0); - } - } - - var TaskQueue = exports.TaskQueue = function () { - function TaskQueue() { - var _this = this; - - - - this.flushing = false; - - this.microTaskQueue = []; - this.microTaskQueueCapacity = 1024; - this.taskQueue = []; - - if (_aureliaPal.FEATURE.mutationObserver) { - this.requestFlushMicroTaskQueue = makeRequestFlushFromMutationObserver(function () { - return _this.flushMicroTaskQueue(); - }); - } else { - this.requestFlushMicroTaskQueue = makeRequestFlushFromTimer(function () { - return _this.flushMicroTaskQueue(); - }); - } - - this.requestFlushTaskQueue = makeRequestFlushFromTimer(function () { - return _this.flushTaskQueue(); - }); - } - - TaskQueue.prototype.queueMicroTask = function queueMicroTask(task) { - if (this.microTaskQueue.length < 1) { - this.requestFlushMicroTaskQueue(); - } - - this.microTaskQueue.push(task); - }; - - TaskQueue.prototype.queueTask = function queueTask(task) { - if (this.taskQueue.length < 1) { - this.requestFlushTaskQueue(); - } - - this.taskQueue.push(task); - }; - - TaskQueue.prototype.flushTaskQueue = function flushTaskQueue() { - var queue = this.taskQueue; - var index = 0; - var task = void 0; - - this.taskQueue = []; - - try { - this.flushing = true; - while (index < queue.length) { - task = queue[index]; - task.call(); - index++; - } - } catch (error) { - onError(error, task); - } finally { - this.flushing = false; - } - }; - - TaskQueue.prototype.flushMicroTaskQueue = function flushMicroTaskQueue() { - var queue = this.microTaskQueue; - var capacity = this.microTaskQueueCapacity; - var index = 0; - var task = void 0; - - try { - this.flushing = true; - while (index < queue.length) { - task = queue[index]; - task.call(); - index++; - - if (index > capacity) { - for (var scan = 0, newLength = queue.length - index; scan < newLength; scan++) { - queue[scan] = queue[scan + index]; - } - - queue.length -= index; - index = 0; - } - } - } catch (error) { - onError(error, task); - } finally { - this.flushing = false; - } - - queue.length = 0; - }; - - return TaskQueue; - }(); -}); -define('aurelia-logging-console',['exports', 'aurelia-logging'], function (exports, _aureliaLogging) { - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.ConsoleAppender = undefined; - - - - var ConsoleAppender = exports.ConsoleAppender = function () { - function ConsoleAppender() { - - } - - ConsoleAppender.prototype.debug = function debug(logger) { - var _console; - - for (var _len = arguments.length, rest = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - rest[_key - 1] = arguments[_key]; - } - - (_console = console).debug.apply(_console, ['DEBUG [' + logger.id + ']'].concat(rest)); - }; - - ConsoleAppender.prototype.info = function info(logger) { - var _console2; - - for (var _len2 = arguments.length, rest = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { - rest[_key2 - 1] = arguments[_key2]; - } - - (_console2 = console).info.apply(_console2, ['INFO [' + logger.id + ']'].concat(rest)); - }; - - ConsoleAppender.prototype.warn = function warn(logger) { - var _console3; - - for (var _len3 = arguments.length, rest = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { - rest[_key3 - 1] = arguments[_key3]; - } - - (_console3 = console).warn.apply(_console3, ['WARN [' + logger.id + ']'].concat(rest)); - }; - - ConsoleAppender.prototype.error = function error(logger) { - var _console4; - - for (var _len4 = arguments.length, rest = Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) { - rest[_key4 - 1] = arguments[_key4]; - } - - (_console4 = console).error.apply(_console4, ['ERROR [' + logger.id + ']'].concat(rest)); - }; - - return ConsoleAppender; - }(); -}); -define('aurelia-templating',['exports', 'aurelia-logging', 'aurelia-metadata', 'aurelia-pal', 'aurelia-path', 'aurelia-loader', 'aurelia-dependency-injection', 'aurelia-binding', 'aurelia-task-queue'], function (exports, _aureliaLogging, _aureliaMetadata, _aureliaPal, _aureliaPath, _aureliaLoader, _aureliaDependencyInjection, _aureliaBinding, _aureliaTaskQueue) { - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.TemplatingEngine = exports.ElementConfigResource = exports.CompositionEngine = exports.HtmlBehaviorResource = exports.BindableProperty = exports.BehaviorPropertyObserver = exports.Controller = exports.ViewEngine = exports.ModuleAnalyzer = exports.ResourceDescription = exports.ResourceModule = exports.ViewCompiler = exports.ViewFactory = exports.BoundViewFactory = exports.ViewSlot = exports.View = exports.ViewResources = exports.ShadowDOM = exports.ShadowSlot = exports.PassThroughSlot = exports.SlotCustomAttribute = exports.BindingLanguage = exports.ViewLocator = exports.InlineViewStrategy = exports.TemplateRegistryViewStrategy = exports.NoViewStrategy = exports.ConventionalViewStrategy = exports.RelativeViewStrategy = exports.viewStrategy = exports.TargetInstruction = exports.BehaviorInstruction = exports.ViewCompileInstruction = exports.ResourceLoadContext = exports.ElementEvents = exports.ViewEngineHooksResource = exports.CompositionTransaction = exports.CompositionTransactionOwnershipToken = exports.CompositionTransactionNotifier = exports.Animator = exports.animationEvent = undefined; - exports._hyphenate = _hyphenate; - exports._isAllWhitespace = _isAllWhitespace; - exports.viewEngineHooks = viewEngineHooks; - exports.children = children; - exports.child = child; - exports.resource = resource; - exports.behavior = behavior; - exports.customElement = customElement; - exports.customAttribute = customAttribute; - exports.templateController = templateController; - exports.bindable = bindable; - exports.dynamicOptions = dynamicOptions; - exports.useShadowDOM = useShadowDOM; - exports.processAttributes = processAttributes; - exports.processContent = processContent; - exports.containerless = containerless; - exports.useViewStrategy = useViewStrategy; - exports.useView = useView; - exports.inlineView = inlineView; - exports.noView = noView; - exports.elementConfig = elementConfig; - exports.viewResources = viewResources; - - var LogManager = _interopRequireWildcard(_aureliaLogging); - - function _interopRequireWildcard(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; - } - } - - var _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; - }; - }(); - - var _class4, _temp, _dec, _class5, _dec2, _class6, _dec3, _class7, _dec4, _class8, _dec5, _class9, _class10, _temp2, _dec6, _class11, _class12, _temp3, _class15, _dec7, _class17, _dec8, _class18, _class19, _temp4, _dec9, _class21, _dec10, _class22, _dec11, _class23; - - var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { - return typeof obj; - } : function (obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; - }; - - - - var animationEvent = exports.animationEvent = { - enterBegin: 'animation:enter:begin', - enterActive: 'animation:enter:active', - enterDone: 'animation:enter:done', - enterTimeout: 'animation:enter:timeout', - - leaveBegin: 'animation:leave:begin', - leaveActive: 'animation:leave:active', - leaveDone: 'animation:leave:done', - leaveTimeout: 'animation:leave:timeout', - - staggerNext: 'animation:stagger:next', - - removeClassBegin: 'animation:remove-class:begin', - removeClassActive: 'animation:remove-class:active', - removeClassDone: 'animation:remove-class:done', - removeClassTimeout: 'animation:remove-class:timeout', - - addClassBegin: 'animation:add-class:begin', - addClassActive: 'animation:add-class:active', - addClassDone: 'animation:add-class:done', - addClassTimeout: 'animation:add-class:timeout', - - animateBegin: 'animation:animate:begin', - animateActive: 'animation:animate:active', - animateDone: 'animation:animate:done', - animateTimeout: 'animation:animate:timeout', - - sequenceBegin: 'animation:sequence:begin', - sequenceDone: 'animation:sequence:done' - }; - - var Animator = exports.Animator = function () { - function Animator() { - - } - - Animator.prototype.enter = function enter(element) { - return Promise.resolve(false); - }; - - Animator.prototype.leave = function leave(element) { - return Promise.resolve(false); - }; - - Animator.prototype.removeClass = function removeClass(element, className) { - element.classList.remove(className); - return Promise.resolve(false); - }; - - Animator.prototype.addClass = function addClass(element, className) { - element.classList.add(className); - return Promise.resolve(false); - }; - - Animator.prototype.animate = function animate(element, className) { - return Promise.resolve(false); - }; - - Animator.prototype.runSequence = function runSequence(animations) {}; - - Animator.prototype.registerEffect = function registerEffect(effectName, properties) {}; - - Animator.prototype.unregisterEffect = function unregisterEffect(effectName) {}; - - return Animator; - }(); - - var CompositionTransactionNotifier = exports.CompositionTransactionNotifier = function () { - function CompositionTransactionNotifier(owner) { - - - this.owner = owner; - this.owner._compositionCount++; - } - - CompositionTransactionNotifier.prototype.done = function done() { - this.owner._compositionCount--; - this.owner._tryCompleteTransaction(); - }; - - return CompositionTransactionNotifier; - }(); - - var CompositionTransactionOwnershipToken = exports.CompositionTransactionOwnershipToken = function () { - function CompositionTransactionOwnershipToken(owner) { - - - this.owner = owner; - this.owner._ownershipToken = this; - this.thenable = this._createThenable(); - } - - CompositionTransactionOwnershipToken.prototype.waitForCompositionComplete = function waitForCompositionComplete() { - this.owner._tryCompleteTransaction(); - return this.thenable; - }; - - CompositionTransactionOwnershipToken.prototype.resolve = function resolve() { - this._resolveCallback(); - }; - - CompositionTransactionOwnershipToken.prototype._createThenable = function _createThenable() { - var _this = this; - - return new Promise(function (resolve, reject) { - _this._resolveCallback = resolve; - }); - }; - - return CompositionTransactionOwnershipToken; - }(); - - var CompositionTransaction = exports.CompositionTransaction = function () { - function CompositionTransaction() { - - - this._ownershipToken = null; - this._compositionCount = 0; - } - - CompositionTransaction.prototype.tryCapture = function tryCapture() { - return this._ownershipToken === null ? new CompositionTransactionOwnershipToken(this) : null; - }; - - CompositionTransaction.prototype.enlist = function enlist() { - return new CompositionTransactionNotifier(this); - }; - - CompositionTransaction.prototype._tryCompleteTransaction = function _tryCompleteTransaction() { - if (this._compositionCount <= 0) { - this._compositionCount = 0; - - if (this._ownershipToken !== null) { - var token = this._ownershipToken; - this._ownershipToken = null; - token.resolve(); - } - } - }; - - return CompositionTransaction; - }(); - - var capitalMatcher = /([A-Z])/g; - - function addHyphenAndLower(char) { - return '-' + char.toLowerCase(); - } - - function _hyphenate(name) { - return (name.charAt(0).toLowerCase() + name.slice(1)).replace(capitalMatcher, addHyphenAndLower); - } - - function _isAllWhitespace(node) { - return !(node.auInterpolationTarget || /[^\t\n\r ]/.test(node.textContent)); - } - - var ViewEngineHooksResource = exports.ViewEngineHooksResource = function () { - function ViewEngineHooksResource() { - - } - - ViewEngineHooksResource.prototype.initialize = function initialize(container, target) { - this.instance = container.get(target); - }; - - ViewEngineHooksResource.prototype.register = function register(registry, name) { - registry.registerViewEngineHooks(this.instance); - }; - - ViewEngineHooksResource.prototype.load = function load(container, target) {}; - - ViewEngineHooksResource.convention = function convention(name) { - if (name.endsWith('ViewEngineHooks')) { - return new ViewEngineHooksResource(); - } - }; - - return ViewEngineHooksResource; - }(); - - function viewEngineHooks(target) { - var deco = function deco(t) { - _aureliaMetadata.metadata.define(_aureliaMetadata.metadata.resource, new ViewEngineHooksResource(), t); - }; - - return target ? deco(target) : deco; - } - - var ElementEvents = exports.ElementEvents = function () { - function ElementEvents(element) { - - - this.element = element; - this.subscriptions = {}; - } - - ElementEvents.prototype._enqueueHandler = function _enqueueHandler(handler) { - this.subscriptions[handler.eventName] = this.subscriptions[handler.eventName] || []; - this.subscriptions[handler.eventName].push(handler); - }; - - ElementEvents.prototype._dequeueHandler = function _dequeueHandler(handler) { - var index = void 0; - var subscriptions = this.subscriptions[handler.eventName]; - if (subscriptions) { - index = subscriptions.indexOf(handler); - if (index > -1) { - subscriptions.splice(index, 1); - } - } - return handler; - }; - - ElementEvents.prototype.publish = function publish(eventName) { - var detail = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - var bubbles = arguments.length <= 2 || arguments[2] === undefined ? true : arguments[2]; - var cancelable = arguments.length <= 3 || arguments[3] === undefined ? true : arguments[3]; - - var event = _aureliaPal.DOM.createCustomEvent(eventName, { cancelable: cancelable, bubbles: bubbles, detail: detail }); - this.element.dispatchEvent(event); - }; - - ElementEvents.prototype.subscribe = function subscribe(eventName, handler) { - var _this2 = this; - - var bubbles = arguments.length <= 2 || arguments[2] === undefined ? true : arguments[2]; - - if (handler && typeof handler === 'function') { - handler.eventName = eventName; - handler.handler = handler; - handler.bubbles = bubbles; - handler.dispose = function () { - _this2.element.removeEventListener(eventName, handler, bubbles); - _this2._dequeueHandler(handler); - }; - this.element.addEventListener(eventName, handler, bubbles); - this._enqueueHandler(handler); - return handler; - } - - return undefined; - }; - - ElementEvents.prototype.subscribeOnce = function subscribeOnce(eventName, handler) { - var _this3 = this; - - var bubbles = arguments.length <= 2 || arguments[2] === undefined ? true : arguments[2]; - - if (handler && typeof handler === 'function') { - var _ret = function () { - var _handler = function _handler(event) { - handler(event); - _handler.dispose(); - }; - return { - v: _this3.subscribe(eventName, _handler, bubbles) - }; - }(); - - if ((typeof _ret === 'undefined' ? 'undefined' : _typeof(_ret)) === "object") return _ret.v; - } - - return undefined; - }; - - ElementEvents.prototype.dispose = function dispose(eventName) { - if (eventName && typeof eventName === 'string') { - var subscriptions = this.subscriptions[eventName]; - if (subscriptions) { - while (subscriptions.length) { - var subscription = subscriptions.pop(); - if (subscription) { - subscription.dispose(); - } - } - } - } else { - this.disposeAll(); - } - }; - - ElementEvents.prototype.disposeAll = function disposeAll() { - for (var key in this.subscriptions) { - this.dispose(key); - } - }; - - return ElementEvents; - }(); - - var ResourceLoadContext = exports.ResourceLoadContext = function () { - function ResourceLoadContext() { - - - this.dependencies = {}; - } - - ResourceLoadContext.prototype.addDependency = function addDependency(url) { - this.dependencies[url] = true; - }; - - ResourceLoadContext.prototype.hasDependency = function hasDependency(url) { - return url in this.dependencies; - }; - - return ResourceLoadContext; - }(); - - var ViewCompileInstruction = exports.ViewCompileInstruction = function ViewCompileInstruction() { - var targetShadowDOM = arguments.length <= 0 || arguments[0] === undefined ? false : arguments[0]; - var compileSurrogate = arguments.length <= 1 || arguments[1] === undefined ? false : arguments[1]; - - - - this.targetShadowDOM = targetShadowDOM; - this.compileSurrogate = compileSurrogate; - this.associatedModuleId = null; - }; - - ViewCompileInstruction.normal = new ViewCompileInstruction(); - - var BehaviorInstruction = exports.BehaviorInstruction = function () { - BehaviorInstruction.enhance = function enhance() { - var instruction = new BehaviorInstruction(); - instruction.enhance = true; - return instruction; - }; - - BehaviorInstruction.unitTest = function unitTest(type, attributes) { - var instruction = new BehaviorInstruction(); - instruction.type = type; - instruction.attributes = attributes || {}; - return instruction; - }; - - BehaviorInstruction.element = function element(node, type) { - var instruction = new BehaviorInstruction(); - instruction.type = type; - instruction.attributes = {}; - instruction.anchorIsContainer = !(node.hasAttribute('containerless') || type.containerless); - instruction.initiatedByBehavior = true; - return instruction; - }; - - BehaviorInstruction.attribute = function attribute(attrName, type) { - var instruction = new BehaviorInstruction(); - instruction.attrName = attrName; - instruction.type = type || null; - instruction.attributes = {}; - return instruction; - }; - - BehaviorInstruction.dynamic = function dynamic(host, viewModel, viewFactory) { - var instruction = new BehaviorInstruction(); - instruction.host = host; - instruction.viewModel = viewModel; - instruction.viewFactory = viewFactory; - instruction.inheritBindingContext = true; - return instruction; - }; - - function BehaviorInstruction() { - - - this.initiatedByBehavior = false; - this.enhance = false; - this.partReplacements = null; - this.viewFactory = null; - this.originalAttrName = null; - this.skipContentProcessing = false; - this.contentFactory = null; - this.viewModel = null; - this.anchorIsContainer = false; - this.host = null; - this.attributes = null; - this.type = null; - this.attrName = null; - this.inheritBindingContext = false; - } - - return BehaviorInstruction; - }(); - - BehaviorInstruction.normal = new BehaviorInstruction(); - - var TargetInstruction = exports.TargetInstruction = (_temp = _class4 = function () { - TargetInstruction.shadowSlot = function shadowSlot(parentInjectorId) { - var instruction = new TargetInstruction(); - instruction.parentInjectorId = parentInjectorId; - instruction.shadowSlot = true; - return instruction; - }; - - TargetInstruction.contentExpression = function contentExpression(expression) { - var instruction = new TargetInstruction(); - instruction.contentExpression = expression; - return instruction; - }; - - TargetInstruction.lifting = function lifting(parentInjectorId, liftingInstruction) { - var instruction = new TargetInstruction(); - instruction.parentInjectorId = parentInjectorId; - instruction.expressions = TargetInstruction.noExpressions; - instruction.behaviorInstructions = [liftingInstruction]; - instruction.viewFactory = liftingInstruction.viewFactory; - instruction.providers = [liftingInstruction.type.target]; - instruction.lifting = true; - return instruction; - }; - - TargetInstruction.normal = function normal(injectorId, parentInjectorId, providers, behaviorInstructions, expressions, elementInstruction) { - var instruction = new TargetInstruction(); - instruction.injectorId = injectorId; - instruction.parentInjectorId = parentInjectorId; - instruction.providers = providers; - instruction.behaviorInstructions = behaviorInstructions; - instruction.expressions = expressions; - instruction.anchorIsContainer = elementInstruction ? elementInstruction.anchorIsContainer : true; - instruction.elementInstruction = elementInstruction; - return instruction; - }; - - TargetInstruction.surrogate = function surrogate(providers, behaviorInstructions, expressions, values) { - var instruction = new TargetInstruction(); - instruction.expressions = expressions; - instruction.behaviorInstructions = behaviorInstructions; - instruction.providers = providers; - instruction.values = values; - return instruction; - }; - - function TargetInstruction() { - - - this.injectorId = null; - this.parentInjectorId = null; - - this.shadowSlot = false; - this.slotName = null; - this.slotFallbackFactory = null; - - this.contentExpression = null; - - this.expressions = null; - this.behaviorInstructions = null; - this.providers = null; - - this.viewFactory = null; - - this.anchorIsContainer = false; - this.elementInstruction = null; - this.lifting = false; - - this.values = null; - } - - return TargetInstruction; - }(), _class4.noExpressions = Object.freeze([]), _temp); - var viewStrategy = exports.viewStrategy = _aureliaMetadata.protocol.create('aurelia:view-strategy', { - validate: function validate(target) { - if (!(typeof target.loadViewFactory === 'function')) { - return 'View strategies must implement: loadViewFactory(viewEngine: ViewEngine, compileInstruction: ViewCompileInstruction, loadContext?: ResourceLoadContext): Promise'; - } - - return true; - }, - compose: function compose(target) { - if (!(typeof target.makeRelativeTo === 'function')) { - target.makeRelativeTo = _aureliaPal.PLATFORM.noop; - } - } - }); - - var RelativeViewStrategy = exports.RelativeViewStrategy = (_dec = viewStrategy(), _dec(_class5 = function () { - function RelativeViewStrategy(path) { - - - this.path = path; - this.absolutePath = null; - } - - RelativeViewStrategy.prototype.loadViewFactory = function loadViewFactory(viewEngine, compileInstruction, loadContext, target) { - if (this.absolutePath === null && this.moduleId) { - this.absolutePath = (0, _aureliaPath.relativeToFile)(this.path, this.moduleId); - } - - compileInstruction.associatedModuleId = this.moduleId; - return viewEngine.loadViewFactory(this.absolutePath || this.path, compileInstruction, loadContext, target); - }; - - RelativeViewStrategy.prototype.makeRelativeTo = function makeRelativeTo(file) { - if (this.absolutePath === null) { - this.absolutePath = (0, _aureliaPath.relativeToFile)(this.path, file); - } - }; - - return RelativeViewStrategy; - }()) || _class5); - var ConventionalViewStrategy = exports.ConventionalViewStrategy = (_dec2 = viewStrategy(), _dec2(_class6 = function () { - function ConventionalViewStrategy(viewLocator, origin) { - - - this.moduleId = origin.moduleId; - this.viewUrl = viewLocator.convertOriginToViewUrl(origin); - } - - ConventionalViewStrategy.prototype.loadViewFactory = function loadViewFactory(viewEngine, compileInstruction, loadContext, target) { - compileInstruction.associatedModuleId = this.moduleId; - return viewEngine.loadViewFactory(this.viewUrl, compileInstruction, loadContext, target); - }; - - return ConventionalViewStrategy; - }()) || _class6); - var NoViewStrategy = exports.NoViewStrategy = (_dec3 = viewStrategy(), _dec3(_class7 = function () { - function NoViewStrategy(dependencies, dependencyBaseUrl) { - - - this.dependencies = dependencies || null; - this.dependencyBaseUrl = dependencyBaseUrl || ''; - } - - NoViewStrategy.prototype.loadViewFactory = function loadViewFactory(viewEngine, compileInstruction, loadContext, target) { - var entry = this.entry; - var dependencies = this.dependencies; - - if (entry && entry.factoryIsReady) { - return Promise.resolve(null); - } - - this.entry = entry = new _aureliaLoader.TemplateRegistryEntry(this.moduleId || this.dependencyBaseUrl); - - entry.dependencies = []; - entry.templateIsLoaded = true; - - if (dependencies !== null) { - for (var i = 0, ii = dependencies.length; i < ii; ++i) { - var current = dependencies[i]; - - if (typeof current === 'string' || typeof current === 'function') { - entry.addDependency(current); - } else { - entry.addDependency(current.from, current.as); - } - } - } - - compileInstruction.associatedModuleId = this.moduleId; - - return viewEngine.loadViewFactory(entry, compileInstruction, loadContext, target); - }; - - return NoViewStrategy; - }()) || _class7); - var TemplateRegistryViewStrategy = exports.TemplateRegistryViewStrategy = (_dec4 = viewStrategy(), _dec4(_class8 = function () { - function TemplateRegistryViewStrategy(moduleId, entry) { - - - this.moduleId = moduleId; - this.entry = entry; - } - - TemplateRegistryViewStrategy.prototype.loadViewFactory = function loadViewFactory(viewEngine, compileInstruction, loadContext, target) { - var entry = this.entry; - - if (entry.factoryIsReady) { - return Promise.resolve(entry.factory); - } - - compileInstruction.associatedModuleId = this.moduleId; - return viewEngine.loadViewFactory(entry, compileInstruction, loadContext, target); - }; - - return TemplateRegistryViewStrategy; - }()) || _class8); - var InlineViewStrategy = exports.InlineViewStrategy = (_dec5 = viewStrategy(), _dec5(_class9 = function () { - function InlineViewStrategy(markup, dependencies, dependencyBaseUrl) { - - - this.markup = markup; - this.dependencies = dependencies || null; - this.dependencyBaseUrl = dependencyBaseUrl || ''; - } - - InlineViewStrategy.prototype.loadViewFactory = function loadViewFactory(viewEngine, compileInstruction, loadContext, target) { - var entry = this.entry; - var dependencies = this.dependencies; - - if (entry && entry.factoryIsReady) { - return Promise.resolve(entry.factory); - } - - this.entry = entry = new _aureliaLoader.TemplateRegistryEntry(this.moduleId || this.dependencyBaseUrl); - entry.template = _aureliaPal.DOM.createTemplateFromMarkup(this.markup); - - if (dependencies !== null) { - for (var i = 0, ii = dependencies.length; i < ii; ++i) { - var current = dependencies[i]; - - if (typeof current === 'string' || typeof current === 'function') { - entry.addDependency(current); - } else { - entry.addDependency(current.from, current.as); - } - } - } - - compileInstruction.associatedModuleId = this.moduleId; - return viewEngine.loadViewFactory(entry, compileInstruction, loadContext, target); - }; - - return InlineViewStrategy; - }()) || _class9); - var ViewLocator = exports.ViewLocator = (_temp2 = _class10 = function () { - function ViewLocator() { - - } - - ViewLocator.prototype.getViewStrategy = function getViewStrategy(value) { - if (!value) { - return null; - } - - if ((typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && 'getViewStrategy' in value) { - var _origin = _aureliaMetadata.Origin.get(value.constructor); - - value = value.getViewStrategy(); - - if (typeof value === 'string') { - value = new RelativeViewStrategy(value); - } - - viewStrategy.assert(value); - - if (_origin.moduleId) { - value.makeRelativeTo(_origin.moduleId); - } - - return value; - } - - if (typeof value === 'string') { - value = new RelativeViewStrategy(value); - } - - if (viewStrategy.validate(value)) { - return value; - } - - if (typeof value !== 'function') { - value = value.constructor; - } - - var origin = _aureliaMetadata.Origin.get(value); - var strategy = _aureliaMetadata.metadata.get(ViewLocator.viewStrategyMetadataKey, value); - - if (!strategy) { - if (!origin.moduleId) { - throw new Error('Cannot determine default view strategy for object.', value); - } - - strategy = this.createFallbackViewStrategy(origin); - } else if (origin.moduleId) { - strategy.moduleId = origin.moduleId; - } - - return strategy; - }; - - ViewLocator.prototype.createFallbackViewStrategy = function createFallbackViewStrategy(origin) { - return new ConventionalViewStrategy(this, origin); - }; - - ViewLocator.prototype.convertOriginToViewUrl = function convertOriginToViewUrl(origin) { - var moduleId = origin.moduleId; - var id = moduleId.endsWith('.js') || moduleId.endsWith('.ts') ? moduleId.substring(0, moduleId.length - 3) : moduleId; - return id + '.html'; - }; - - return ViewLocator; - }(), _class10.viewStrategyMetadataKey = 'aurelia:view-strategy', _temp2); - - - function mi(name) { - throw new Error('BindingLanguage must implement ' + name + '().'); - } - - var BindingLanguage = exports.BindingLanguage = function () { - function BindingLanguage() { - - } - - BindingLanguage.prototype.inspectAttribute = function inspectAttribute(resources, elementName, attrName, attrValue) { - mi('inspectAttribute'); - }; - - BindingLanguage.prototype.createAttributeInstruction = function createAttributeInstruction(resources, element, info, existingInstruction) { - mi('createAttributeInstruction'); - }; - - BindingLanguage.prototype.inspectTextContent = function inspectTextContent(resources, value) { - mi('inspectTextContent'); - }; - - return BindingLanguage; - }(); - - var noNodes = Object.freeze([]); - - var SlotCustomAttribute = exports.SlotCustomAttribute = (_dec6 = (0, _aureliaDependencyInjection.inject)(_aureliaPal.DOM.Element), _dec6(_class11 = function () { - function SlotCustomAttribute(element) { - - - this.element = element; - this.element.auSlotAttribute = this; - } - - SlotCustomAttribute.prototype.valueChanged = function valueChanged(newValue, oldValue) {}; - - return SlotCustomAttribute; - }()) || _class11); - - var PassThroughSlot = exports.PassThroughSlot = function () { - function PassThroughSlot(anchor, name, destinationName, fallbackFactory) { - - - this.anchor = anchor; - this.anchor.viewSlot = this; - this.name = name; - this.destinationName = destinationName; - this.fallbackFactory = fallbackFactory; - this.destinationSlot = null; - this.projections = 0; - this.contentView = null; - - var attr = new SlotCustomAttribute(this.anchor); - attr.value = this.destinationName; - } - - PassThroughSlot.prototype.renderFallbackContent = function renderFallbackContent(view, nodes, projectionSource, index) { - if (this.contentView === null) { - this.contentView = this.fallbackFactory.create(this.ownerView.container); - this.contentView.bind(this.ownerView.bindingContext, this.ownerView.overrideContext); - - var slots = Object.create(null); - slots[this.destinationSlot.name] = this.destinationSlot; - - ShadowDOM.distributeView(this.contentView, slots, projectionSource, index, this.destinationSlot.name); - } - }; - - PassThroughSlot.prototype.passThroughTo = function passThroughTo(destinationSlot) { - this.destinationSlot = destinationSlot; - }; - - PassThroughSlot.prototype.addNode = function addNode(view, node, projectionSource, index) { - if (this.contentView !== null) { - this.contentView.removeNodes(); - this.contentView.detached(); - this.contentView.unbind(); - this.contentView = null; - } - - if (node.viewSlot instanceof PassThroughSlot) { - node.viewSlot.passThroughTo(this); - return; - } - - this.projections++; - this.destinationSlot.addNode(view, node, projectionSource, index); - }; - - PassThroughSlot.prototype.removeView = function removeView(view, projectionSource) { - this.projections--; - this.destinationSlot.removeView(view, projectionSource); - - if (this.needsFallbackRendering) { - this.renderFallbackContent(null, noNodes, projectionSource); - } - }; - - PassThroughSlot.prototype.removeAll = function removeAll(projectionSource) { - this.projections = 0; - this.destinationSlot.removeAll(projectionSource); - - if (this.needsFallbackRendering) { - this.renderFallbackContent(null, noNodes, projectionSource); - } - }; - - PassThroughSlot.prototype.projectFrom = function projectFrom(view, projectionSource) { - this.destinationSlot.projectFrom(view, projectionSource); - }; - - PassThroughSlot.prototype.created = function created(ownerView) { - this.ownerView = ownerView; - }; - - PassThroughSlot.prototype.bind = function bind(view) { - if (this.contentView) { - this.contentView.bind(view.bindingContext, view.overrideContext); - } - }; - - PassThroughSlot.prototype.attached = function attached() { - if (this.contentView) { - this.contentView.attached(); - } - }; - - PassThroughSlot.prototype.detached = function detached() { - if (this.contentView) { - this.contentView.detached(); - } - }; - - PassThroughSlot.prototype.unbind = function unbind() { - if (this.contentView) { - this.contentView.unbind(); - } - }; - - _createClass(PassThroughSlot, [{ - key: 'needsFallbackRendering', - get: function get() { - return this.fallbackFactory && this.projections === 0; - } - }]); - - return PassThroughSlot; - }(); - - var ShadowSlot = exports.ShadowSlot = function () { - function ShadowSlot(anchor, name, fallbackFactory) { - - - this.anchor = anchor; - this.anchor.isContentProjectionSource = true; - this.anchor.viewSlot = this; - this.name = name; - this.fallbackFactory = fallbackFactory; - this.contentView = null; - this.projections = 0; - this.children = []; - this.projectFromAnchors = null; - this.destinationSlots = null; - } - - ShadowSlot.prototype.addNode = function addNode(view, node, projectionSource, index, destination) { - if (this.contentView !== null) { - this.contentView.removeNodes(); - this.contentView.detached(); - this.contentView.unbind(); - this.contentView = null; - } - - if (node.viewSlot instanceof PassThroughSlot) { - node.viewSlot.passThroughTo(this); - return; - } - - if (this.destinationSlots !== null) { - ShadowDOM.distributeNodes(view, [node], this.destinationSlots, this, index); - } else { - node.auOwnerView = view; - node.auProjectionSource = projectionSource; - node.auAssignedSlot = this; - - var anchor = this._findAnchor(view, node, projectionSource, index); - var parent = anchor.parentNode; - - parent.insertBefore(node, anchor); - this.children.push(node); - this.projections++; - } - }; - - ShadowSlot.prototype.removeView = function removeView(view, projectionSource) { - if (this.destinationSlots !== null) { - ShadowDOM.undistributeView(view, this.destinationSlots, this); - } else if (this.contentView && this.contentView.hasSlots) { - ShadowDOM.undistributeView(view, this.contentView.slots, projectionSource); - } else { - var found = this.children.find(function (x) { - return x.auSlotProjectFrom === projectionSource; - }); - if (found) { - var _children = found.auProjectionChildren; - - for (var i = 0, ii = _children.length; i < ii; ++i) { - var _child = _children[i]; - - if (_child.auOwnerView === view) { - _children.splice(i, 1); - view.fragment.appendChild(_child); - i--;ii--; - this.projections--; - } - } - - if (this.needsFallbackRendering) { - this.renderFallbackContent(view, noNodes, projectionSource); - } - } - } - }; - - ShadowSlot.prototype.removeAll = function removeAll(projectionSource) { - if (this.destinationSlots !== null) { - ShadowDOM.undistributeAll(this.destinationSlots, this); - } else if (this.contentView && this.contentView.hasSlots) { - ShadowDOM.undistributeAll(this.contentView.slots, projectionSource); - } else { - var found = this.children.find(function (x) { - return x.auSlotProjectFrom === projectionSource; - }); - - if (found) { - var _children2 = found.auProjectionChildren; - for (var i = 0, ii = _children2.length; i < ii; ++i) { - var _child2 = _children2[i]; - _child2.auOwnerView.fragment.appendChild(_child2); - this.projections--; - } - - found.auProjectionChildren = []; - - if (this.needsFallbackRendering) { - this.renderFallbackContent(null, noNodes, projectionSource); - } - } - } - }; - - ShadowSlot.prototype._findAnchor = function _findAnchor(view, node, projectionSource, index) { - if (projectionSource) { - var found = this.children.find(function (x) { - return x.auSlotProjectFrom === projectionSource; - }); - if (found) { - if (index !== undefined) { - var _children3 = found.auProjectionChildren; - var viewIndex = -1; - var lastView = void 0; - - for (var i = 0, ii = _children3.length; i < ii; ++i) { - var current = _children3[i]; - - if (current.auOwnerView !== lastView) { - viewIndex++; - lastView = current.auOwnerView; - - if (viewIndex >= index && lastView !== view) { - _children3.splice(i, 0, node); - return current; - } - } - } - } - - found.auProjectionChildren.push(node); - return found; - } - } - - return this.anchor; - }; - - ShadowSlot.prototype.projectTo = function projectTo(slots) { - this.destinationSlots = slots; - }; - - ShadowSlot.prototype.projectFrom = function projectFrom(view, projectionSource) { - var anchor = _aureliaPal.DOM.createComment('anchor'); - var parent = this.anchor.parentNode; - anchor.auSlotProjectFrom = projectionSource; - anchor.auOwnerView = view; - anchor.auProjectionChildren = []; - parent.insertBefore(anchor, this.anchor); - this.children.push(anchor); - - if (this.projectFromAnchors === null) { - this.projectFromAnchors = []; - } - - this.projectFromAnchors.push(anchor); - }; - - ShadowSlot.prototype.renderFallbackContent = function renderFallbackContent(view, nodes, projectionSource, index) { - if (this.contentView === null) { - this.contentView = this.fallbackFactory.create(this.ownerView.container); - this.contentView.bind(this.ownerView.bindingContext, this.ownerView.overrideContext); - this.contentView.insertNodesBefore(this.anchor); - } - - if (this.contentView.hasSlots) { - var slots = this.contentView.slots; - var projectFromAnchors = this.projectFromAnchors; - - if (projectFromAnchors !== null) { - for (var slotName in slots) { - var slot = slots[slotName]; - - for (var i = 0, ii = projectFromAnchors.length; i < ii; ++i) { - var anchor = projectFromAnchors[i]; - slot.projectFrom(anchor.auOwnerView, anchor.auSlotProjectFrom); - } - } - } - - this.fallbackSlots = slots; - ShadowDOM.distributeNodes(view, nodes, slots, projectionSource, index); - } - }; - - ShadowSlot.prototype.created = function created(ownerView) { - this.ownerView = ownerView; - }; - - ShadowSlot.prototype.bind = function bind(view) { - if (this.contentView) { - this.contentView.bind(view.bindingContext, view.overrideContext); - } - }; - - ShadowSlot.prototype.attached = function attached() { - if (this.contentView) { - this.contentView.attached(); - } - }; - - ShadowSlot.prototype.detached = function detached() { - if (this.contentView) { - this.contentView.detached(); - } - }; - - ShadowSlot.prototype.unbind = function unbind() { - if (this.contentView) { - this.contentView.unbind(); - } - }; - - _createClass(ShadowSlot, [{ - key: 'needsFallbackRendering', - get: function get() { - return this.fallbackFactory && this.projections === 0; - } - }]); - - return ShadowSlot; - }(); - - var ShadowDOM = exports.ShadowDOM = (_temp3 = _class12 = function () { - function ShadowDOM() { - - } - - ShadowDOM.getSlotName = function getSlotName(node) { - if (node.auSlotAttribute === undefined) { - return ShadowDOM.defaultSlotKey; - } - - return node.auSlotAttribute.value; - }; - - ShadowDOM.distributeView = function distributeView(view, slots, projectionSource, index, destinationOverride) { - var nodes = void 0; - - if (view === null) { - nodes = noNodes; - } else { - var childNodes = view.fragment.childNodes; - var ii = childNodes.length; - nodes = new Array(ii); - - for (var i = 0; i < ii; ++i) { - nodes[i] = childNodes[i]; - } - } - - ShadowDOM.distributeNodes(view, nodes, slots, projectionSource, index, destinationOverride); - }; - - ShadowDOM.undistributeView = function undistributeView(view, slots, projectionSource) { - for (var slotName in slots) { - slots[slotName].removeView(view, projectionSource); - } - }; - - ShadowDOM.undistributeAll = function undistributeAll(slots, projectionSource) { - for (var slotName in slots) { - slots[slotName].removeAll(projectionSource); - } - }; - - ShadowDOM.distributeNodes = function distributeNodes(view, nodes, slots, projectionSource, index, destinationOverride) { - for (var i = 0, ii = nodes.length; i < ii; ++i) { - var currentNode = nodes[i]; - var nodeType = currentNode.nodeType; - - if (currentNode.isContentProjectionSource) { - currentNode.viewSlot.projectTo(slots); - - for (var slotName in slots) { - slots[slotName].projectFrom(view, currentNode.viewSlot); - } - - nodes.splice(i, 1); - ii--;i--; - } else if (nodeType === 1 || nodeType === 3 || currentNode.viewSlot instanceof PassThroughSlot) { - if (nodeType === 3 && _isAllWhitespace(currentNode)) { - nodes.splice(i, 1); - ii--;i--; - } else { - var found = slots[destinationOverride || ShadowDOM.getSlotName(currentNode)]; - - if (found) { - found.addNode(view, currentNode, projectionSource, index); - nodes.splice(i, 1); - ii--;i--; - } - } - } else { - nodes.splice(i, 1); - ii--;i--; - } - } - - for (var _slotName in slots) { - var slot = slots[_slotName]; - - if (slot.needsFallbackRendering) { - slot.renderFallbackContent(view, nodes, projectionSource, index); - } - } - }; - - return ShadowDOM; - }(), _class12.defaultSlotKey = '__au-default-slot-key__', _temp3); - - - function register(lookup, name, resource, type) { - if (!name) { - return; - } - - var existing = lookup[name]; - if (existing) { - if (existing !== resource) { - throw new Error('Attempted to register ' + type + ' when one with the same name already exists. Name: ' + name + '.'); - } - - return; - } - - lookup[name] = resource; - } - - var ViewResources = exports.ViewResources = function () { - function ViewResources(parent, viewUrl) { - - - this.bindingLanguage = null; - - this.parent = parent || null; - this.hasParent = this.parent !== null; - this.viewUrl = viewUrl || ''; - this.lookupFunctions = { - valueConverters: this.getValueConverter.bind(this), - bindingBehaviors: this.getBindingBehavior.bind(this) - }; - this.attributes = Object.create(null); - this.elements = Object.create(null); - this.valueConverters = Object.create(null); - this.bindingBehaviors = Object.create(null); - this.attributeMap = Object.create(null); - this.values = Object.create(null); - this.beforeCompile = this.afterCompile = this.beforeCreate = this.afterCreate = this.beforeBind = this.beforeUnbind = false; - } - - ViewResources.prototype._tryAddHook = function _tryAddHook(obj, name) { - if (typeof obj[name] === 'function') { - var func = obj[name].bind(obj); - var counter = 1; - var callbackName = void 0; - - while (this[callbackName = name + counter.toString()] !== undefined) { - counter++; - } - - this[name] = true; - this[callbackName] = func; - } - }; - - ViewResources.prototype._invokeHook = function _invokeHook(name, one, two, three, four) { - if (this.hasParent) { - this.parent._invokeHook(name, one, two, three, four); - } - - if (this[name]) { - this[name + '1'](one, two, three, four); - - var callbackName = name + '2'; - if (this[callbackName]) { - this[callbackName](one, two, three, four); - - callbackName = name + '3'; - if (this[callbackName]) { - this[callbackName](one, two, three, four); - - var counter = 4; - - while (this[callbackName = name + counter.toString()] !== undefined) { - this[callbackName](one, two, three, four); - counter++; - } - } - } - } - }; - - ViewResources.prototype.registerViewEngineHooks = function registerViewEngineHooks(hooks) { - this._tryAddHook(hooks, 'beforeCompile'); - this._tryAddHook(hooks, 'afterCompile'); - this._tryAddHook(hooks, 'beforeCreate'); - this._tryAddHook(hooks, 'afterCreate'); - this._tryAddHook(hooks, 'beforeBind'); - this._tryAddHook(hooks, 'beforeUnbind'); - }; - - ViewResources.prototype.getBindingLanguage = function getBindingLanguage(bindingLanguageFallback) { - return this.bindingLanguage || (this.bindingLanguage = bindingLanguageFallback); - }; - - ViewResources.prototype.patchInParent = function patchInParent(newParent) { - var originalParent = this.parent; - - this.parent = newParent || null; - this.hasParent = this.parent !== null; - - if (newParent.parent === null) { - newParent.parent = originalParent; - newParent.hasParent = originalParent !== null; - } - }; - - ViewResources.prototype.relativeToView = function relativeToView(path) { - return (0, _aureliaPath.relativeToFile)(path, this.viewUrl); - }; - - ViewResources.prototype.registerElement = function registerElement(tagName, behavior) { - register(this.elements, tagName, behavior, 'an Element'); - }; - - ViewResources.prototype.getElement = function getElement(tagName) { - return this.elements[tagName] || (this.hasParent ? this.parent.getElement(tagName) : null); - }; - - ViewResources.prototype.mapAttribute = function mapAttribute(attribute) { - return this.attributeMap[attribute] || (this.hasParent ? this.parent.mapAttribute(attribute) : null); - }; - - ViewResources.prototype.registerAttribute = function registerAttribute(attribute, behavior, knownAttribute) { - this.attributeMap[attribute] = knownAttribute; - register(this.attributes, attribute, behavior, 'an Attribute'); - }; - - ViewResources.prototype.getAttribute = function getAttribute(attribute) { - return this.attributes[attribute] || (this.hasParent ? this.parent.getAttribute(attribute) : null); - }; - - ViewResources.prototype.registerValueConverter = function registerValueConverter(name, valueConverter) { - register(this.valueConverters, name, valueConverter, 'a ValueConverter'); - }; - - ViewResources.prototype.getValueConverter = function getValueConverter(name) { - return this.valueConverters[name] || (this.hasParent ? this.parent.getValueConverter(name) : null); - }; - - ViewResources.prototype.registerBindingBehavior = function registerBindingBehavior(name, bindingBehavior) { - register(this.bindingBehaviors, name, bindingBehavior, 'a BindingBehavior'); - }; - - ViewResources.prototype.getBindingBehavior = function getBindingBehavior(name) { - return this.bindingBehaviors[name] || (this.hasParent ? this.parent.getBindingBehavior(name) : null); - }; - - ViewResources.prototype.registerValue = function registerValue(name, value) { - register(this.values, name, value, 'a value'); - }; - - ViewResources.prototype.getValue = function getValue(name) { - return this.values[name] || (this.hasParent ? this.parent.getValue(name) : null); - }; - - return ViewResources; - }(); - - var View = exports.View = function () { - function View(container, viewFactory, fragment, controllers, bindings, children, slots) { - - - this.container = container; - this.viewFactory = viewFactory; - this.resources = viewFactory.resources; - this.fragment = fragment; - this.firstChild = fragment.firstChild; - this.lastChild = fragment.lastChild; - this.controllers = controllers; - this.bindings = bindings; - this.children = children; - this.slots = slots; - this.hasSlots = false; - this.fromCache = false; - this.isBound = false; - this.isAttached = false; - this.bindingContext = null; - this.overrideContext = null; - this.controller = null; - this.viewModelScope = null; - this.animatableElement = undefined; - this._isUserControlled = false; - this.contentView = null; - - for (var key in slots) { - this.hasSlots = true; - break; - } - } - - View.prototype.returnToCache = function returnToCache() { - this.viewFactory.returnViewToCache(this); - }; - - View.prototype.created = function created() { - var i = void 0; - var ii = void 0; - var controllers = this.controllers; - - for (i = 0, ii = controllers.length; i < ii; ++i) { - controllers[i].created(this); - } - }; - - View.prototype.bind = function bind(bindingContext, overrideContext, _systemUpdate) { - var controllers = void 0; - var bindings = void 0; - var children = void 0; - var i = void 0; - var ii = void 0; - - if (_systemUpdate && this._isUserControlled) { - return; - } - - if (this.isBound) { - if (this.bindingContext === bindingContext) { - return; - } - - this.unbind(); - } - - this.isBound = true; - this.bindingContext = bindingContext; - this.overrideContext = overrideContext || (0, _aureliaBinding.createOverrideContext)(bindingContext); - - this.resources._invokeHook('beforeBind', this); - - bindings = this.bindings; - for (i = 0, ii = bindings.length; i < ii; ++i) { - bindings[i].bind(this); - } - - if (this.viewModelScope !== null) { - bindingContext.bind(this.viewModelScope.bindingContext, this.viewModelScope.overrideContext); - this.viewModelScope = null; - } - - controllers = this.controllers; - for (i = 0, ii = controllers.length; i < ii; ++i) { - controllers[i].bind(this); - } - - children = this.children; - for (i = 0, ii = children.length; i < ii; ++i) { - children[i].bind(bindingContext, overrideContext, true); - } - - if (this.hasSlots) { - ShadowDOM.distributeView(this.contentView, this.slots); - } - }; - - View.prototype.addBinding = function addBinding(binding) { - this.bindings.push(binding); - - if (this.isBound) { - binding.bind(this); - } - }; - - View.prototype.unbind = function unbind() { - var controllers = void 0; - var bindings = void 0; - var children = void 0; - var i = void 0; - var ii = void 0; - - if (this.isBound) { - this.isBound = false; - this.resources._invokeHook('beforeUnbind', this); - - if (this.controller !== null) { - this.controller.unbind(); - } - - bindings = this.bindings; - for (i = 0, ii = bindings.length; i < ii; ++i) { - bindings[i].unbind(); - } - - controllers = this.controllers; - for (i = 0, ii = controllers.length; i < ii; ++i) { - controllers[i].unbind(); - } - - children = this.children; - for (i = 0, ii = children.length; i < ii; ++i) { - children[i].unbind(); - } - - this.bindingContext = null; - this.overrideContext = null; - } - }; - - View.prototype.insertNodesBefore = function insertNodesBefore(refNode) { - refNode.parentNode.insertBefore(this.fragment, refNode); - }; - - View.prototype.appendNodesTo = function appendNodesTo(parent) { - parent.appendChild(this.fragment); - }; - - View.prototype.removeNodes = function removeNodes() { - var fragment = this.fragment; - var current = this.firstChild; - var end = this.lastChild; - var next = void 0; - - while (current) { - next = current.nextSibling; - fragment.appendChild(current); - - if (current === end) { - break; - } - - current = next; - } - }; - - View.prototype.attached = function attached() { - var controllers = void 0; - var children = void 0; - var i = void 0; - var ii = void 0; - - if (this.isAttached) { - return; - } - - this.isAttached = true; - - if (this.controller !== null) { - this.controller.attached(); - } - - controllers = this.controllers; - for (i = 0, ii = controllers.length; i < ii; ++i) { - controllers[i].attached(); - } - - children = this.children; - for (i = 0, ii = children.length; i < ii; ++i) { - children[i].attached(); - } - }; - - View.prototype.detached = function detached() { - var controllers = void 0; - var children = void 0; - var i = void 0; - var ii = void 0; - - if (this.isAttached) { - this.isAttached = false; - - if (this.controller !== null) { - this.controller.detached(); - } - - controllers = this.controllers; - for (i = 0, ii = controllers.length; i < ii; ++i) { - controllers[i].detached(); - } - - children = this.children; - for (i = 0, ii = children.length; i < ii; ++i) { - children[i].detached(); - } - } - }; - - return View; - }(); - - function getAnimatableElement(view) { - if (view.animatableElement !== undefined) { - return view.animatableElement; - } - - var current = view.firstChild; - - while (current && current.nodeType !== 1) { - current = current.nextSibling; - } - - if (current && current.nodeType === 1) { - return view.animatableElement = current.classList.contains('au-animate') ? current : null; - } - - return view.animatableElement = null; - } - - var ViewSlot = exports.ViewSlot = function () { - function ViewSlot(anchor, anchorIsContainer) { - var animator = arguments.length <= 2 || arguments[2] === undefined ? Animator.instance : arguments[2]; - - - - this.anchor = anchor; - this.anchorIsContainer = anchorIsContainer; - this.bindingContext = null; - this.overrideContext = null; - this.animator = animator; - this.children = []; - this.isBound = false; - this.isAttached = false; - this.contentSelectors = null; - anchor.viewSlot = this; - anchor.isContentProjectionSource = false; - } - - ViewSlot.prototype.animateView = function animateView(view) { - var direction = arguments.length <= 1 || arguments[1] === undefined ? 'enter' : arguments[1]; - - var animatableElement = getAnimatableElement(view); - - if (animatableElement !== null) { - switch (direction) { - case 'enter': - return this.animator.enter(animatableElement); - case 'leave': - return this.animator.leave(animatableElement); - default: - throw new Error('Invalid animation direction: ' + direction); - } - } - }; - - ViewSlot.prototype.transformChildNodesIntoView = function transformChildNodesIntoView() { - var parent = this.anchor; - - this.children.push({ - fragment: parent, - firstChild: parent.firstChild, - lastChild: parent.lastChild, - returnToCache: function returnToCache() {}, - removeNodes: function removeNodes() { - var last = void 0; - - while (last = parent.lastChild) { - parent.removeChild(last); - } - }, - created: function created() {}, - bind: function bind() {}, - unbind: function unbind() {}, - attached: function attached() {}, - detached: function detached() {} - }); - }; - - ViewSlot.prototype.bind = function bind(bindingContext, overrideContext) { - var i = void 0; - var ii = void 0; - var children = void 0; - - if (this.isBound) { - if (this.bindingContext === bindingContext) { - return; - } - - this.unbind(); - } - - this.isBound = true; - this.bindingContext = bindingContext = bindingContext || this.bindingContext; - this.overrideContext = overrideContext = overrideContext || this.overrideContext; - - children = this.children; - for (i = 0, ii = children.length; i < ii; ++i) { - children[i].bind(bindingContext, overrideContext, true); - } - }; - - ViewSlot.prototype.unbind = function unbind() { - if (this.isBound) { - var i = void 0; - var ii = void 0; - var _children4 = this.children; - - this.isBound = false; - this.bindingContext = null; - this.overrideContext = null; - - for (i = 0, ii = _children4.length; i < ii; ++i) { - _children4[i].unbind(); - } - } - }; - - ViewSlot.prototype.add = function add(view) { - if (this.anchorIsContainer) { - view.appendNodesTo(this.anchor); - } else { - view.insertNodesBefore(this.anchor); - } - - this.children.push(view); - - if (this.isAttached) { - view.attached(); - return this.animateView(view, 'enter'); - } - }; - - ViewSlot.prototype.insert = function insert(index, view) { - var children = this.children; - var length = children.length; - - if (index === 0 && length === 0 || index >= length) { - return this.add(view); - } - - view.insertNodesBefore(children[index].firstChild); - children.splice(index, 0, view); - - if (this.isAttached) { - view.attached(); - return this.animateView(view, 'enter'); - } - }; - - ViewSlot.prototype.move = function move(sourceIndex, targetIndex) { - if (sourceIndex === targetIndex) { - return; - } - - var children = this.children; - var view = children[sourceIndex]; - - view.removeNodes(); - view.insertNodesBefore(children[targetIndex].firstChild); - children.splice(sourceIndex, 1); - children.splice(targetIndex, 0, view); - }; - - ViewSlot.prototype.remove = function remove(view, returnToCache, skipAnimation) { - return this.removeAt(this.children.indexOf(view), returnToCache, skipAnimation); - }; - - ViewSlot.prototype.removeMany = function removeMany(viewsToRemove, returnToCache, skipAnimation) { - var _this4 = this; - - var children = this.children; - var ii = viewsToRemove.length; - var i = void 0; - var rmPromises = []; - - viewsToRemove.forEach(function (child) { - if (skipAnimation) { - child.removeNodes(); - return; - } - - var animation = _this4.animateView(child, 'leave'); - if (animation) { - rmPromises.push(animation.then(function () { - return child.removeNodes(); - })); - } else { - child.removeNodes(); - } - }); - - var removeAction = function removeAction() { - if (_this4.isAttached) { - for (i = 0; i < ii; ++i) { - viewsToRemove[i].detached(); - } - } - - if (returnToCache) { - for (i = 0; i < ii; ++i) { - viewsToRemove[i].returnToCache(); - } - } - - for (i = 0; i < ii; ++i) { - var index = children.indexOf(viewsToRemove[i]); - if (index >= 0) { - children.splice(index, 1); - } - } - }; - - if (rmPromises.length > 0) { - return Promise.all(rmPromises).then(function () { - return removeAction(); - }); - } - - return removeAction(); - }; - - ViewSlot.prototype.removeAt = function removeAt(index, returnToCache, skipAnimation) { - var _this5 = this; - - var view = this.children[index]; - - var removeAction = function removeAction() { - index = _this5.children.indexOf(view); - view.removeNodes(); - _this5.children.splice(index, 1); - - if (_this5.isAttached) { - view.detached(); - } - - if (returnToCache) { - view.returnToCache(); - } - - return view; - }; - - if (!skipAnimation) { - var animation = this.animateView(view, 'leave'); - if (animation) { - return animation.then(function () { - return removeAction(); - }); - } - } - - return removeAction(); - }; - - ViewSlot.prototype.removeAll = function removeAll(returnToCache, skipAnimation) { - var _this6 = this; - - var children = this.children; - var ii = children.length; - var i = void 0; - var rmPromises = []; - - children.forEach(function (child) { - if (skipAnimation) { - child.removeNodes(); - return; - } - - var animation = _this6.animateView(child, 'leave'); - if (animation) { - rmPromises.push(animation.then(function () { - return child.removeNodes(); - })); - } else { - child.removeNodes(); - } - }); - - var removeAction = function removeAction() { - if (_this6.isAttached) { - for (i = 0; i < ii; ++i) { - children[i].detached(); - } - } - - if (returnToCache) { - for (i = 0; i < ii; ++i) { - children[i].returnToCache(); - } - } - - _this6.children = []; - }; - - if (rmPromises.length > 0) { - return Promise.all(rmPromises).then(function () { - return removeAction(); - }); - } - - return removeAction(); - }; - - ViewSlot.prototype.attached = function attached() { - var i = void 0; - var ii = void 0; - var children = void 0; - var child = void 0; - - if (this.isAttached) { - return; - } - - this.isAttached = true; - - children = this.children; - for (i = 0, ii = children.length; i < ii; ++i) { - child = children[i]; - child.attached(); - this.animateView(child, 'enter'); - } - }; - - ViewSlot.prototype.detached = function detached() { - var i = void 0; - var ii = void 0; - var children = void 0; - - if (this.isAttached) { - this.isAttached = false; - children = this.children; - for (i = 0, ii = children.length; i < ii; ++i) { - children[i].detached(); - } - } - }; - - ViewSlot.prototype.projectTo = function projectTo(slots) { - var _this7 = this; - - this.projectToSlots = slots; - this.add = this._projectionAdd; - this.insert = this._projectionInsert; - this.move = this._projectionMove; - this.remove = this._projectionRemove; - this.removeAt = this._projectionRemoveAt; - this.removeMany = this._projectionRemoveMany; - this.removeAll = this._projectionRemoveAll; - this.children.forEach(function (view) { - return ShadowDOM.distributeView(view, slots, _this7); - }); - }; - - ViewSlot.prototype._projectionAdd = function _projectionAdd(view) { - ShadowDOM.distributeView(view, this.projectToSlots, this); - - this.children.push(view); - - if (this.isAttached) { - view.attached(); - } - }; - - ViewSlot.prototype._projectionInsert = function _projectionInsert(index, view) { - if (index === 0 && !this.children.length || index >= this.children.length) { - this.add(view); - } else { - ShadowDOM.distributeView(view, this.projectToSlots, this, index); - - this.children.splice(index, 0, view); - - if (this.isAttached) { - view.attached(); - } - } - }; - - ViewSlot.prototype._projectionMove = function _projectionMove(sourceIndex, targetIndex) { - if (sourceIndex === targetIndex) { - return; - } - - var children = this.children; - var view = children[sourceIndex]; - - ShadowDOM.undistributeView(view, this.projectToSlots, this); - ShadowDOM.distributeView(view, this.projectToSlots, this, targetIndex); - - children.splice(sourceIndex, 1); - children.splice(targetIndex, 0, view); - }; - - ViewSlot.prototype._projectionRemove = function _projectionRemove(view, returnToCache) { - ShadowDOM.undistributeView(view, this.projectToSlots, this); - this.children.splice(this.children.indexOf(view), 1); - - if (this.isAttached) { - view.detached(); - } - }; - - ViewSlot.prototype._projectionRemoveAt = function _projectionRemoveAt(index, returnToCache) { - var view = this.children[index]; - - ShadowDOM.undistributeView(view, this.projectToSlots, this); - this.children.splice(index, 1); - - if (this.isAttached) { - view.detached(); - } - }; - - ViewSlot.prototype._projectionRemoveMany = function _projectionRemoveMany(viewsToRemove, returnToCache) { - var _this8 = this; - - viewsToRemove.forEach(function (view) { - return _this8.remove(view, returnToCache); - }); - }; - - ViewSlot.prototype._projectionRemoveAll = function _projectionRemoveAll(returnToCache) { - ShadowDOM.undistributeAll(this.projectToSlots, this); - - var children = this.children; - - if (this.isAttached) { - for (var i = 0, ii = children.length; i < ii; ++i) { - children[i].detached(); - } - } - - this.children = []; - }; - - return ViewSlot; - }(); - - var ProviderResolver = (0, _aureliaDependencyInjection.resolver)(_class15 = function () { - function ProviderResolver() { - - } - - ProviderResolver.prototype.get = function get(container, key) { - var id = key.__providerId__; - return id in container ? container[id] : container[id] = container.invoke(key); - }; - - return ProviderResolver; - }()) || _class15; - - var providerResolverInstance = new ProviderResolver(); - - function elementContainerGet(key) { - if (key === _aureliaPal.DOM.Element) { - return this.element; - } - - if (key === BoundViewFactory) { - if (this.boundViewFactory) { - return this.boundViewFactory; - } - - var factory = this.instruction.viewFactory; - var _partReplacements = this.partReplacements; - - if (_partReplacements) { - factory = _partReplacements[factory.part] || factory; - } - - this.boundViewFactory = new BoundViewFactory(this, factory, _partReplacements); - return this.boundViewFactory; - } - - if (key === ViewSlot) { - if (this.viewSlot === undefined) { - this.viewSlot = new ViewSlot(this.element, this.instruction.anchorIsContainer); - this.element.isContentProjectionSource = this.instruction.lifting; - this.children.push(this.viewSlot); - } - - return this.viewSlot; - } - - if (key === ElementEvents) { - return this.elementEvents || (this.elementEvents = new ElementEvents(this.element)); - } - - if (key === CompositionTransaction) { - return this.compositionTransaction || (this.compositionTransaction = this.parent.get(key)); - } - - if (key === ViewResources) { - return this.viewResources; - } - - if (key === TargetInstruction) { - return this.instruction; - } - - return this.superGet(key); - } - - function createElementContainer(parent, element, instruction, children, partReplacements, resources) { - var container = parent.createChild(); - var providers = void 0; - var i = void 0; - - container.element = element; - container.instruction = instruction; - container.children = children; - container.viewResources = resources; - container.partReplacements = partReplacements; - - providers = instruction.providers; - i = providers.length; - - while (i--) { - container._resolvers.set(providers[i], providerResolverInstance); - } - - container.superGet = container.get; - container.get = elementContainerGet; - - return container; - } - - function makeElementIntoAnchor(element, elementInstruction) { - var anchor = _aureliaPal.DOM.createComment('anchor'); - - if (elementInstruction) { - var firstChild = element.firstChild; - - if (firstChild && firstChild.tagName === 'AU-CONTENT') { - anchor.contentElement = firstChild; - } - - anchor.hasAttribute = function (name) { - return element.hasAttribute(name); - }; - anchor.getAttribute = function (name) { - return element.getAttribute(name); - }; - anchor.setAttribute = function (name, value) { - element.setAttribute(name, value); - }; - } - - _aureliaPal.DOM.replaceNode(anchor, element); - - return anchor; - } - - function applyInstructions(containers, element, instruction, controllers, bindings, children, shadowSlots, partReplacements, resources) { - var behaviorInstructions = instruction.behaviorInstructions; - var expressions = instruction.expressions; - var elementContainer = void 0; - var i = void 0; - var ii = void 0; - var current = void 0; - var instance = void 0; - - if (instruction.contentExpression) { - bindings.push(instruction.contentExpression.createBinding(element.nextSibling)); - element.nextSibling.auInterpolationTarget = true; - element.parentNode.removeChild(element); - return; - } - - if (instruction.shadowSlot) { - var commentAnchor = _aureliaPal.DOM.createComment('slot'); - var slot = void 0; - - if (instruction.slotDestination) { - slot = new PassThroughSlot(commentAnchor, instruction.slotName, instruction.slotDestination, instruction.slotFallbackFactory); - } else { - slot = new ShadowSlot(commentAnchor, instruction.slotName, instruction.slotFallbackFactory); - } - - _aureliaPal.DOM.replaceNode(commentAnchor, element); - shadowSlots[instruction.slotName] = slot; - controllers.push(slot); - return; - } - - if (behaviorInstructions.length) { - if (!instruction.anchorIsContainer) { - element = makeElementIntoAnchor(element, instruction.elementInstruction); - } - - containers[instruction.injectorId] = elementContainer = createElementContainer(containers[instruction.parentInjectorId], element, instruction, children, partReplacements, resources); - - for (i = 0, ii = behaviorInstructions.length; i < ii; ++i) { - current = behaviorInstructions[i]; - instance = current.type.create(elementContainer, current, element, bindings); - controllers.push(instance); - } - } - - for (i = 0, ii = expressions.length; i < ii; ++i) { - bindings.push(expressions[i].createBinding(element)); - } - } - - function styleStringToObject(style, target) { - var attributes = style.split(';'); - var firstIndexOfColon = void 0; - var i = void 0; - var current = void 0; - var key = void 0; - var value = void 0; - - target = target || {}; - - for (i = 0; i < attributes.length; i++) { - current = attributes[i]; - firstIndexOfColon = current.indexOf(':'); - key = current.substring(0, firstIndexOfColon).trim(); - value = current.substring(firstIndexOfColon + 1).trim(); - target[key] = value; - } - - return target; - } - - function styleObjectToString(obj) { - var result = ''; - - for (var key in obj) { - result += key + ':' + obj[key] + ';'; - } - - return result; - } - - function applySurrogateInstruction(container, element, instruction, controllers, bindings, children) { - var behaviorInstructions = instruction.behaviorInstructions; - var expressions = instruction.expressions; - var providers = instruction.providers; - var values = instruction.values; - var i = void 0; - var ii = void 0; - var current = void 0; - var instance = void 0; - var currentAttributeValue = void 0; - - i = providers.length; - while (i--) { - container._resolvers.set(providers[i], providerResolverInstance); - } - - for (var key in values) { - currentAttributeValue = element.getAttribute(key); - - if (currentAttributeValue) { - if (key === 'class') { - element.setAttribute('class', currentAttributeValue + ' ' + values[key]); - } else if (key === 'style') { - var styleObject = styleStringToObject(values[key]); - styleStringToObject(currentAttributeValue, styleObject); - element.setAttribute('style', styleObjectToString(styleObject)); - } - } else { - element.setAttribute(key, values[key]); - } - } - - if (behaviorInstructions.length) { - for (i = 0, ii = behaviorInstructions.length; i < ii; ++i) { - current = behaviorInstructions[i]; - instance = current.type.create(container, current, element, bindings); - - if (instance.contentView) { - children.push(instance.contentView); - } - - controllers.push(instance); - } - } - - for (i = 0, ii = expressions.length; i < ii; ++i) { - bindings.push(expressions[i].createBinding(element)); - } - } - - var BoundViewFactory = exports.BoundViewFactory = function () { - function BoundViewFactory(parentContainer, viewFactory, partReplacements) { - - - this.parentContainer = parentContainer; - this.viewFactory = viewFactory; - this.factoryCreateInstruction = { partReplacements: partReplacements }; - } - - BoundViewFactory.prototype.create = function create() { - var view = this.viewFactory.create(this.parentContainer.createChild(), this.factoryCreateInstruction); - view._isUserControlled = true; - return view; - }; - - BoundViewFactory.prototype.setCacheSize = function setCacheSize(size, doNotOverrideIfAlreadySet) { - this.viewFactory.setCacheSize(size, doNotOverrideIfAlreadySet); - }; - - BoundViewFactory.prototype.getCachedView = function getCachedView() { - return this.viewFactory.getCachedView(); - }; - - BoundViewFactory.prototype.returnViewToCache = function returnViewToCache(view) { - this.viewFactory.returnViewToCache(view); - }; - - _createClass(BoundViewFactory, [{ - key: 'isCaching', - get: function get() { - return this.viewFactory.isCaching; - } - }]); - - return BoundViewFactory; - }(); - - var ViewFactory = exports.ViewFactory = function () { - function ViewFactory(template, instructions, resources) { - - - this.isCaching = false; - - this.template = template; - this.instructions = instructions; - this.resources = resources; - this.cacheSize = -1; - this.cache = null; - } - - ViewFactory.prototype.setCacheSize = function setCacheSize(size, doNotOverrideIfAlreadySet) { - if (size) { - if (size === '*') { - size = Number.MAX_VALUE; - } else if (typeof size === 'string') { - size = parseInt(size, 10); - } - } - - if (this.cacheSize === -1 || !doNotOverrideIfAlreadySet) { - this.cacheSize = size; - } - - if (this.cacheSize > 0) { - this.cache = []; - } else { - this.cache = null; - } - - this.isCaching = this.cacheSize > 0; - }; - - ViewFactory.prototype.getCachedView = function getCachedView() { - return this.cache !== null ? this.cache.pop() || null : null; - }; - - ViewFactory.prototype.returnViewToCache = function returnViewToCache(view) { - if (view.isAttached) { - view.detached(); - } - - if (view.isBound) { - view.unbind(); - } - - if (this.cache !== null && this.cache.length < this.cacheSize) { - view.fromCache = true; - this.cache.push(view); - } - }; - - ViewFactory.prototype.create = function create(container, createInstruction, element) { - createInstruction = createInstruction || BehaviorInstruction.normal; - - var cachedView = this.getCachedView(); - if (cachedView !== null) { - return cachedView; - } - - var fragment = createInstruction.enhance ? this.template : this.template.cloneNode(true); - var instructables = fragment.querySelectorAll('.au-target'); - var instructions = this.instructions; - var resources = this.resources; - var controllers = []; - var bindings = []; - var children = []; - var shadowSlots = Object.create(null); - var containers = { root: container }; - var partReplacements = createInstruction.partReplacements; - var i = void 0; - var ii = void 0; - var view = void 0; - var instructable = void 0; - var instruction = void 0; - - this.resources._invokeHook('beforeCreate', this, container, fragment, createInstruction); - - if (element && this.surrogateInstruction !== null) { - applySurrogateInstruction(container, element, this.surrogateInstruction, controllers, bindings, children); - } - - if (createInstruction.enhance && fragment.hasAttribute('au-target-id')) { - instructable = fragment; - instruction = instructions[instructable.getAttribute('au-target-id')]; - applyInstructions(containers, instructable, instruction, controllers, bindings, children, shadowSlots, partReplacements, resources); - } - - for (i = 0, ii = instructables.length; i < ii; ++i) { - instructable = instructables[i]; - instruction = instructions[instructable.getAttribute('au-target-id')]; - applyInstructions(containers, instructable, instruction, controllers, bindings, children, shadowSlots, partReplacements, resources); - } - - view = new View(container, this, fragment, controllers, bindings, children, shadowSlots); - - if (!createInstruction.initiatedByBehavior) { - view.created(); - } - - this.resources._invokeHook('afterCreate', view); - - return view; - }; - - return ViewFactory; - }(); - - var nextInjectorId = 0; - function getNextInjectorId() { - return ++nextInjectorId; - } - - function configureProperties(instruction, resources) { - var type = instruction.type; - var attrName = instruction.attrName; - var attributes = instruction.attributes; - var property = void 0; - var key = void 0; - var value = void 0; - - var knownAttribute = resources.mapAttribute(attrName); - if (knownAttribute && attrName in attributes && knownAttribute !== attrName) { - attributes[knownAttribute] = attributes[attrName]; - delete attributes[attrName]; - } - - for (key in attributes) { - value = attributes[key]; - - if (value !== null && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') { - property = type.attributes[key]; - - if (property !== undefined) { - value.targetProperty = property.name; - } else { - value.targetProperty = key; - } - } - } - } - - var lastAUTargetID = 0; - function getNextAUTargetID() { - return (++lastAUTargetID).toString(); - } - - function makeIntoInstructionTarget(element) { - var value = element.getAttribute('class'); - var auTargetID = getNextAUTargetID(); - - element.setAttribute('class', value ? value + ' au-target' : 'au-target'); - element.setAttribute('au-target-id', auTargetID); - - return auTargetID; - } - - function makeShadowSlot(compiler, resources, node, instructions, parentInjectorId) { - var auShadowSlot = _aureliaPal.DOM.createElement('au-shadow-slot'); - _aureliaPal.DOM.replaceNode(auShadowSlot, node); - - var auTargetID = makeIntoInstructionTarget(auShadowSlot); - var instruction = TargetInstruction.shadowSlot(parentInjectorId); - - instruction.slotName = node.getAttribute('name') || ShadowDOM.defaultSlotKey; - instruction.slotDestination = node.getAttribute('slot'); - - if (node.innerHTML.trim()) { - var fragment = _aureliaPal.DOM.createDocumentFragment(); - var _child3 = void 0; - - while (_child3 = node.firstChild) { - fragment.appendChild(_child3); - } - - instruction.slotFallbackFactory = compiler.compile(fragment, resources); - } - - instructions[auTargetID] = instruction; - - return auShadowSlot; - } - - var ViewCompiler = exports.ViewCompiler = (_dec7 = (0, _aureliaDependencyInjection.inject)(BindingLanguage, ViewResources), _dec7(_class17 = function () { - function ViewCompiler(bindingLanguage, resources) { - - - this.bindingLanguage = bindingLanguage; - this.resources = resources; - } - - ViewCompiler.prototype.compile = function compile(source, resources, compileInstruction) { - resources = resources || this.resources; - compileInstruction = compileInstruction || ViewCompileInstruction.normal; - source = typeof source === 'string' ? _aureliaPal.DOM.createTemplateFromMarkup(source) : source; - - var content = void 0; - var part = void 0; - var cacheSize = void 0; - - if (source.content) { - part = source.getAttribute('part'); - cacheSize = source.getAttribute('view-cache'); - content = _aureliaPal.DOM.adoptNode(source.content); - } else { - content = source; - } - - compileInstruction.targetShadowDOM = compileInstruction.targetShadowDOM && _aureliaPal.FEATURE.shadowDOM; - resources._invokeHook('beforeCompile', content, resources, compileInstruction); - - var instructions = {}; - this._compileNode(content, resources, instructions, source, 'root', !compileInstruction.targetShadowDOM); - - var firstChild = content.firstChild; - if (firstChild && firstChild.nodeType === 1) { - var targetId = firstChild.getAttribute('au-target-id'); - if (targetId) { - var ins = instructions[targetId]; - - if (ins.shadowSlot || ins.lifting || ins.elementInstruction && !ins.elementInstruction.anchorIsContainer) { - content.insertBefore(_aureliaPal.DOM.createComment('view'), firstChild); - } - } - } - - var factory = new ViewFactory(content, instructions, resources); - - factory.surrogateInstruction = compileInstruction.compileSurrogate ? this._compileSurrogate(source, resources) : null; - factory.part = part; - - if (cacheSize) { - factory.setCacheSize(cacheSize); - } - - resources._invokeHook('afterCompile', factory); - - return factory; - }; - - ViewCompiler.prototype._compileNode = function _compileNode(node, resources, instructions, parentNode, parentInjectorId, targetLightDOM) { - switch (node.nodeType) { - case 1: - return this._compileElement(node, resources, instructions, parentNode, parentInjectorId, targetLightDOM); - case 3: - var expression = resources.getBindingLanguage(this.bindingLanguage).inspectTextContent(resources, node.wholeText); - if (expression) { - var marker = _aureliaPal.DOM.createElement('au-marker'); - var auTargetID = makeIntoInstructionTarget(marker); - (node.parentNode || parentNode).insertBefore(marker, node); - node.textContent = ' '; - instructions[auTargetID] = TargetInstruction.contentExpression(expression); - - while (node.nextSibling && node.nextSibling.nodeType === 3) { - (node.parentNode || parentNode).removeChild(node.nextSibling); - } - } else { - while (node.nextSibling && node.nextSibling.nodeType === 3) { - node = node.nextSibling; - } - } - return node.nextSibling; - case 11: - var currentChild = node.firstChild; - while (currentChild) { - currentChild = this._compileNode(currentChild, resources, instructions, node, parentInjectorId, targetLightDOM); - } - break; - default: - break; - } - - return node.nextSibling; - }; - - ViewCompiler.prototype._compileSurrogate = function _compileSurrogate(node, resources) { - var tagName = node.tagName.toLowerCase(); - var attributes = node.attributes; - var bindingLanguage = resources.getBindingLanguage(this.bindingLanguage); - var knownAttribute = void 0; - var property = void 0; - var instruction = void 0; - var i = void 0; - var ii = void 0; - var attr = void 0; - var attrName = void 0; - var attrValue = void 0; - var info = void 0; - var type = void 0; - var expressions = []; - var expression = void 0; - var behaviorInstructions = []; - var values = {}; - var hasValues = false; - var providers = []; - - for (i = 0, ii = attributes.length; i < ii; ++i) { - attr = attributes[i]; - attrName = attr.name; - attrValue = attr.value; - - info = bindingLanguage.inspectAttribute(resources, tagName, attrName, attrValue); - type = resources.getAttribute(info.attrName); - - if (type) { - knownAttribute = resources.mapAttribute(info.attrName); - if (knownAttribute) { - property = type.attributes[knownAttribute]; - - if (property) { - info.defaultBindingMode = property.defaultBindingMode; - - if (!info.command && !info.expression) { - info.command = property.hasOptions ? 'options' : null; - } - } - } - } - - instruction = bindingLanguage.createAttributeInstruction(resources, node, info, undefined, type); - - if (instruction) { - if (instruction.alteredAttr) { - type = resources.getAttribute(instruction.attrName); - } - - if (instruction.discrete) { - expressions.push(instruction); - } else { - if (type) { - instruction.type = type; - configureProperties(instruction, resources); - - if (type.liftsContent) { - throw new Error('You cannot place a template controller on a surrogate element.'); - } else { - behaviorInstructions.push(instruction); - } - } else { - expressions.push(instruction.attributes[instruction.attrName]); - } - } - } else { - if (type) { - instruction = BehaviorInstruction.attribute(attrName, type); - instruction.attributes[resources.mapAttribute(attrName)] = attrValue; - - if (type.liftsContent) { - throw new Error('You cannot place a template controller on a surrogate element.'); - } else { - behaviorInstructions.push(instruction); - } - } else if (attrName !== 'id' && attrName !== 'part' && attrName !== 'replace-part') { - hasValues = true; - values[attrName] = attrValue; - } - } - } - - if (expressions.length || behaviorInstructions.length || hasValues) { - for (i = 0, ii = behaviorInstructions.length; i < ii; ++i) { - instruction = behaviorInstructions[i]; - instruction.type.compile(this, resources, node, instruction); - providers.push(instruction.type.target); - } - - for (i = 0, ii = expressions.length; i < ii; ++i) { - expression = expressions[i]; - if (expression.attrToRemove !== undefined) { - node.removeAttribute(expression.attrToRemove); - } - } - - return TargetInstruction.surrogate(providers, behaviorInstructions, expressions, values); - } - - return null; - }; - - ViewCompiler.prototype._compileElement = function _compileElement(node, resources, instructions, parentNode, parentInjectorId, targetLightDOM) { - var tagName = node.tagName.toLowerCase(); - var attributes = node.attributes; - var expressions = []; - var expression = void 0; - var behaviorInstructions = []; - var providers = []; - var bindingLanguage = resources.getBindingLanguage(this.bindingLanguage); - var liftingInstruction = void 0; - var viewFactory = void 0; - var type = void 0; - var elementInstruction = void 0; - var elementProperty = void 0; - var i = void 0; - var ii = void 0; - var attr = void 0; - var attrName = void 0; - var attrValue = void 0; - var instruction = void 0; - var info = void 0; - var property = void 0; - var knownAttribute = void 0; - var auTargetID = void 0; - var injectorId = void 0; - - if (tagName === 'slot') { - if (targetLightDOM) { - node = makeShadowSlot(this, resources, node, instructions, parentInjectorId); - } - return node.nextSibling; - } else if (tagName === 'template') { - viewFactory = this.compile(node, resources); - viewFactory.part = node.getAttribute('part'); - } else { - type = resources.getElement(node.getAttribute('as-element') || tagName); - if (type) { - elementInstruction = BehaviorInstruction.element(node, type); - type.processAttributes(this, resources, node, attributes, elementInstruction); - behaviorInstructions.push(elementInstruction); - } - } - - for (i = 0, ii = attributes.length; i < ii; ++i) { - attr = attributes[i]; - attrName = attr.name; - attrValue = attr.value; - info = bindingLanguage.inspectAttribute(resources, tagName, attrName, attrValue); - - if (targetLightDOM && info.attrName === 'slot') { - info.attrName = attrName = 'au-slot'; - } - - type = resources.getAttribute(info.attrName); - elementProperty = null; - - if (type) { - knownAttribute = resources.mapAttribute(info.attrName); - if (knownAttribute) { - property = type.attributes[knownAttribute]; - - if (property) { - info.defaultBindingMode = property.defaultBindingMode; - - if (!info.command && !info.expression) { - info.command = property.hasOptions ? 'options' : null; - } - } - } - } else if (elementInstruction) { - elementProperty = elementInstruction.type.attributes[info.attrName]; - if (elementProperty) { - info.defaultBindingMode = elementProperty.defaultBindingMode; - } - } - - if (elementProperty) { - instruction = bindingLanguage.createAttributeInstruction(resources, node, info, elementInstruction); - } else { - instruction = bindingLanguage.createAttributeInstruction(resources, node, info, undefined, type); - } - - if (instruction) { - if (instruction.alteredAttr) { - type = resources.getAttribute(instruction.attrName); - } - - if (instruction.discrete) { - expressions.push(instruction); - } else { - if (type) { - instruction.type = type; - configureProperties(instruction, resources); - - if (type.liftsContent) { - instruction.originalAttrName = attrName; - liftingInstruction = instruction; - break; - } else { - behaviorInstructions.push(instruction); - } - } else if (elementProperty) { - elementInstruction.attributes[info.attrName].targetProperty = elementProperty.name; - } else { - expressions.push(instruction.attributes[instruction.attrName]); - } - } - } else { - if (type) { - instruction = BehaviorInstruction.attribute(attrName, type); - instruction.attributes[resources.mapAttribute(attrName)] = attrValue; - - if (type.liftsContent) { - instruction.originalAttrName = attrName; - liftingInstruction = instruction; - break; - } else { - behaviorInstructions.push(instruction); - } - } else if (elementProperty) { - elementInstruction.attributes[attrName] = attrValue; - } - } - } - - if (liftingInstruction) { - liftingInstruction.viewFactory = viewFactory; - node = liftingInstruction.type.compile(this, resources, node, liftingInstruction, parentNode); - auTargetID = makeIntoInstructionTarget(node); - instructions[auTargetID] = TargetInstruction.lifting(parentInjectorId, liftingInstruction); - } else { - if (expressions.length || behaviorInstructions.length) { - injectorId = behaviorInstructions.length ? getNextInjectorId() : false; - - for (i = 0, ii = behaviorInstructions.length; i < ii; ++i) { - instruction = behaviorInstructions[i]; - instruction.type.compile(this, resources, node, instruction, parentNode); - providers.push(instruction.type.target); - } - - for (i = 0, ii = expressions.length; i < ii; ++i) { - expression = expressions[i]; - if (expression.attrToRemove !== undefined) { - node.removeAttribute(expression.attrToRemove); - } - } - - auTargetID = makeIntoInstructionTarget(node); - instructions[auTargetID] = TargetInstruction.normal(injectorId, parentInjectorId, providers, behaviorInstructions, expressions, elementInstruction); - } - - if (elementInstruction && elementInstruction.skipContentProcessing) { - return node.nextSibling; - } - - var currentChild = node.firstChild; - while (currentChild) { - currentChild = this._compileNode(currentChild, resources, instructions, node, injectorId || parentInjectorId, targetLightDOM); - } - } - - return node.nextSibling; - }; - - return ViewCompiler; - }()) || _class17); - - var ResourceModule = exports.ResourceModule = function () { - function ResourceModule(moduleId) { - - - this.id = moduleId; - this.moduleInstance = null; - this.mainResource = null; - this.resources = null; - this.viewStrategy = null; - this.isInitialized = false; - this.onLoaded = null; - this.loadContext = null; - } - - ResourceModule.prototype.initialize = function initialize(container) { - var current = this.mainResource; - var resources = this.resources; - var vs = this.viewStrategy; - - if (this.isInitialized) { - return; - } - - this.isInitialized = true; - - if (current !== undefined) { - current.metadata.viewStrategy = vs; - current.initialize(container); - } - - for (var i = 0, ii = resources.length; i < ii; ++i) { - current = resources[i]; - current.metadata.viewStrategy = vs; - current.initialize(container); - } - }; - - ResourceModule.prototype.register = function register(registry, name) { - var main = this.mainResource; - var resources = this.resources; - - if (main !== undefined) { - main.register(registry, name); - name = null; - } - - for (var i = 0, ii = resources.length; i < ii; ++i) { - resources[i].register(registry, name); - name = null; - } - }; - - ResourceModule.prototype.load = function load(container, loadContext) { - if (this.onLoaded !== null) { - return this.loadContext === loadContext ? Promise.resolve() : this.onLoaded; - } - - var main = this.mainResource; - var resources = this.resources; - var loads = void 0; - - if (main !== undefined) { - loads = new Array(resources.length + 1); - loads[0] = main.load(container, loadContext); - for (var i = 0, ii = resources.length; i < ii; ++i) { - loads[i + 1] = resources[i].load(container, loadContext); - } - } else { - loads = new Array(resources.length); - for (var _i = 0, _ii = resources.length; _i < _ii; ++_i) { - loads[_i] = resources[_i].load(container, loadContext); - } - } - - this.loadContext = loadContext; - this.onLoaded = Promise.all(loads); - return this.onLoaded; - }; - - return ResourceModule; - }(); - - var ResourceDescription = exports.ResourceDescription = function () { - function ResourceDescription(key, exportedValue, resourceTypeMeta) { - - - if (!resourceTypeMeta) { - resourceTypeMeta = _aureliaMetadata.metadata.get(_aureliaMetadata.metadata.resource, exportedValue); - - if (!resourceTypeMeta) { - resourceTypeMeta = new HtmlBehaviorResource(); - resourceTypeMeta.elementName = _hyphenate(key); - _aureliaMetadata.metadata.define(_aureliaMetadata.metadata.resource, resourceTypeMeta, exportedValue); - } - } - - if (resourceTypeMeta instanceof HtmlBehaviorResource) { - if (resourceTypeMeta.elementName === undefined) { - resourceTypeMeta.elementName = _hyphenate(key); - } else if (resourceTypeMeta.attributeName === undefined) { - resourceTypeMeta.attributeName = _hyphenate(key); - } else if (resourceTypeMeta.attributeName === null && resourceTypeMeta.elementName === null) { - HtmlBehaviorResource.convention(key, resourceTypeMeta); - } - } else if (!resourceTypeMeta.name) { - resourceTypeMeta.name = _hyphenate(key); - } - - this.metadata = resourceTypeMeta; - this.value = exportedValue; - } - - ResourceDescription.prototype.initialize = function initialize(container) { - this.metadata.initialize(container, this.value); - }; - - ResourceDescription.prototype.register = function register(registry, name) { - this.metadata.register(registry, name); - }; - - ResourceDescription.prototype.load = function load(container, loadContext) { - return this.metadata.load(container, this.value, loadContext); - }; - - return ResourceDescription; - }(); - - var ModuleAnalyzer = exports.ModuleAnalyzer = function () { - function ModuleAnalyzer() { - - - this.cache = Object.create(null); - } - - ModuleAnalyzer.prototype.getAnalysis = function getAnalysis(moduleId) { - return this.cache[moduleId]; - }; - - ModuleAnalyzer.prototype.analyze = function analyze(moduleId, moduleInstance, mainResourceKey) { - var mainResource = void 0; - var fallbackValue = void 0; - var fallbackKey = void 0; - var resourceTypeMeta = void 0; - var key = void 0; - var exportedValue = void 0; - var resources = []; - var conventional = void 0; - var vs = void 0; - var resourceModule = void 0; - - resourceModule = this.cache[moduleId]; - if (resourceModule) { - return resourceModule; - } - - resourceModule = new ResourceModule(moduleId); - this.cache[moduleId] = resourceModule; - - if (typeof moduleInstance === 'function') { - moduleInstance = { 'default': moduleInstance }; - } - - if (mainResourceKey) { - mainResource = new ResourceDescription(mainResourceKey, moduleInstance[mainResourceKey]); - } - - for (key in moduleInstance) { - exportedValue = moduleInstance[key]; - - if (key === mainResourceKey || typeof exportedValue !== 'function') { - continue; - } - - resourceTypeMeta = _aureliaMetadata.metadata.get(_aureliaMetadata.metadata.resource, exportedValue); - - if (resourceTypeMeta) { - if (resourceTypeMeta.attributeName === null && resourceTypeMeta.elementName === null) { - HtmlBehaviorResource.convention(key, resourceTypeMeta); - } - - if (resourceTypeMeta.attributeName === null && resourceTypeMeta.elementName === null) { - resourceTypeMeta.elementName = _hyphenate(key); - } - - if (!mainResource && resourceTypeMeta instanceof HtmlBehaviorResource && resourceTypeMeta.elementName !== null) { - mainResource = new ResourceDescription(key, exportedValue, resourceTypeMeta); - } else { - resources.push(new ResourceDescription(key, exportedValue, resourceTypeMeta)); - } - } else if (viewStrategy.decorates(exportedValue)) { - vs = exportedValue; - } else if (exportedValue instanceof _aureliaLoader.TemplateRegistryEntry) { - vs = new TemplateRegistryViewStrategy(moduleId, exportedValue); - } else { - if (conventional = HtmlBehaviorResource.convention(key)) { - if (conventional.elementName !== null && !mainResource) { - mainResource = new ResourceDescription(key, exportedValue, conventional); - } else { - resources.push(new ResourceDescription(key, exportedValue, conventional)); - } - - _aureliaMetadata.metadata.define(_aureliaMetadata.metadata.resource, conventional, exportedValue); - } else if (conventional = _aureliaBinding.ValueConverterResource.convention(key) || _aureliaBinding.BindingBehaviorResource.convention(key) || ViewEngineHooksResource.convention(key)) { - resources.push(new ResourceDescription(key, exportedValue, conventional)); - _aureliaMetadata.metadata.define(_aureliaMetadata.metadata.resource, conventional, exportedValue); - } else if (!fallbackValue) { - fallbackValue = exportedValue; - fallbackKey = key; - } - } - } - - if (!mainResource && fallbackValue) { - mainResource = new ResourceDescription(fallbackKey, fallbackValue); - } - - resourceModule.moduleInstance = moduleInstance; - resourceModule.mainResource = mainResource; - resourceModule.resources = resources; - resourceModule.viewStrategy = vs; - - return resourceModule; - }; - - return ModuleAnalyzer; - }(); - - var logger = LogManager.getLogger('templating'); - - function ensureRegistryEntry(loader, urlOrRegistryEntry) { - if (urlOrRegistryEntry instanceof _aureliaLoader.TemplateRegistryEntry) { - return Promise.resolve(urlOrRegistryEntry); - } - - return loader.loadTemplate(urlOrRegistryEntry); - } - - var ProxyViewFactory = function () { - function ProxyViewFactory(promise) { - var _this9 = this; - - - - promise.then(function (x) { - return _this9.viewFactory = x; - }); - } - - ProxyViewFactory.prototype.create = function create(container, bindingContext, createInstruction, element) { - return this.viewFactory.create(container, bindingContext, createInstruction, element); - }; - - ProxyViewFactory.prototype.setCacheSize = function setCacheSize(size, doNotOverrideIfAlreadySet) { - this.viewFactory.setCacheSize(size, doNotOverrideIfAlreadySet); - }; - - ProxyViewFactory.prototype.getCachedView = function getCachedView() { - return this.viewFactory.getCachedView(); - }; - - ProxyViewFactory.prototype.returnViewToCache = function returnViewToCache(view) { - this.viewFactory.returnViewToCache(view); - }; - - _createClass(ProxyViewFactory, [{ - key: 'isCaching', - get: function get() { - return this.viewFactory.isCaching; - } - }]); - - return ProxyViewFactory; - }(); - - var ViewEngine = exports.ViewEngine = (_dec8 = (0, _aureliaDependencyInjection.inject)(_aureliaLoader.Loader, _aureliaDependencyInjection.Container, ViewCompiler, ModuleAnalyzer, ViewResources), _dec8(_class18 = (_temp4 = _class19 = function () { - function ViewEngine(loader, container, viewCompiler, moduleAnalyzer, appResources) { - - - this.loader = loader; - this.container = container; - this.viewCompiler = viewCompiler; - this.moduleAnalyzer = moduleAnalyzer; - this.appResources = appResources; - this._pluginMap = {}; - - var auSlotBehavior = new HtmlBehaviorResource(); - auSlotBehavior.attributeName = 'au-slot'; - auSlotBehavior.initialize(container, SlotCustomAttribute); - auSlotBehavior.register(appResources); - } - - ViewEngine.prototype.addResourcePlugin = function addResourcePlugin(extension, implementation) { - var name = extension.replace('.', '') + '-resource-plugin'; - this._pluginMap[extension] = name; - this.loader.addPlugin(name, implementation); - }; - - ViewEngine.prototype.loadViewFactory = function loadViewFactory(urlOrRegistryEntry, compileInstruction, loadContext, target) { - var _this10 = this; - - loadContext = loadContext || new ResourceLoadContext(); - - return ensureRegistryEntry(this.loader, urlOrRegistryEntry).then(function (registryEntry) { - if (registryEntry.onReady) { - if (!loadContext.hasDependency(urlOrRegistryEntry)) { - loadContext.addDependency(urlOrRegistryEntry); - return registryEntry.onReady; - } - - if (registryEntry.template === null) { - return registryEntry.onReady; - } - - return Promise.resolve(new ProxyViewFactory(registryEntry.onReady)); - } - - loadContext.addDependency(urlOrRegistryEntry); - - registryEntry.onReady = _this10.loadTemplateResources(registryEntry, compileInstruction, loadContext, target).then(function (resources) { - registryEntry.resources = resources; - - if (registryEntry.template === null) { - return registryEntry.factory = null; - } - - var viewFactory = _this10.viewCompiler.compile(registryEntry.template, resources, compileInstruction); - return registryEntry.factory = viewFactory; - }); - - return registryEntry.onReady; - }); - }; - - ViewEngine.prototype.loadTemplateResources = function loadTemplateResources(registryEntry, compileInstruction, loadContext, target) { - var resources = new ViewResources(this.appResources, registryEntry.address); - var dependencies = registryEntry.dependencies; - var importIds = void 0; - var names = void 0; - - compileInstruction = compileInstruction || ViewCompileInstruction.normal; - - if (dependencies.length === 0 && !compileInstruction.associatedModuleId) { - return Promise.resolve(resources); - } - - importIds = dependencies.map(function (x) { - return x.src; - }); - names = dependencies.map(function (x) { - return x.name; - }); - logger.debug('importing resources for ' + registryEntry.address, importIds); - - if (target) { - var viewModelRequires = _aureliaMetadata.metadata.get(ViewEngine.viewModelRequireMetadataKey, target); - if (viewModelRequires) { - var templateImportCount = importIds.length; - for (var i = 0, ii = viewModelRequires.length; i < ii; ++i) { - var req = viewModelRequires[i]; - var importId = typeof req === 'function' ? _aureliaMetadata.Origin.get(req).moduleId : (0, _aureliaPath.relativeToFile)(req.src || req, registryEntry.address); - - if (importIds.indexOf(importId) === -1) { - importIds.push(importId); - names.push(req.as); - } - } - logger.debug('importing ViewModel resources for ' + compileInstruction.associatedModuleId, importIds.slice(templateImportCount)); - } - } - - return this.importViewResources(importIds, names, resources, compileInstruction, loadContext); - }; - - ViewEngine.prototype.importViewModelResource = function importViewModelResource(moduleImport, moduleMember) { - var _this11 = this; - - return this.loader.loadModule(moduleImport).then(function (viewModelModule) { - var normalizedId = _aureliaMetadata.Origin.get(viewModelModule).moduleId; - var resourceModule = _this11.moduleAnalyzer.analyze(normalizedId, viewModelModule, moduleMember); - - if (!resourceModule.mainResource) { - throw new Error('No view model found in module "' + moduleImport + '".'); - } - - resourceModule.initialize(_this11.container); - - return resourceModule.mainResource; - }); - }; - - ViewEngine.prototype.importViewResources = function importViewResources(moduleIds, names, resources, compileInstruction, loadContext) { - var _this12 = this; - - loadContext = loadContext || new ResourceLoadContext(); - compileInstruction = compileInstruction || ViewCompileInstruction.normal; - - moduleIds = moduleIds.map(function (x) { - return _this12._applyLoaderPlugin(x); - }); - - return this.loader.loadAllModules(moduleIds).then(function (imports) { - var i = void 0; - var ii = void 0; - var analysis = void 0; - var normalizedId = void 0; - var current = void 0; - var associatedModule = void 0; - var container = _this12.container; - var moduleAnalyzer = _this12.moduleAnalyzer; - var allAnalysis = new Array(imports.length); - - for (i = 0, ii = imports.length; i < ii; ++i) { - current = imports[i]; - normalizedId = _aureliaMetadata.Origin.get(current).moduleId; - - analysis = moduleAnalyzer.analyze(normalizedId, current); - analysis.initialize(container); - analysis.register(resources, names[i]); - - allAnalysis[i] = analysis; - } - - if (compileInstruction.associatedModuleId) { - associatedModule = moduleAnalyzer.getAnalysis(compileInstruction.associatedModuleId); - - if (associatedModule) { - associatedModule.register(resources); - } - } - - for (i = 0, ii = allAnalysis.length; i < ii; ++i) { - allAnalysis[i] = allAnalysis[i].load(container, loadContext); - } - - return Promise.all(allAnalysis).then(function () { - return resources; - }); - }); - }; - - ViewEngine.prototype._applyLoaderPlugin = function _applyLoaderPlugin(id) { - var index = id.lastIndexOf('.'); - if (index !== -1) { - var ext = id.substring(index); - var pluginName = this._pluginMap[ext]; - - if (pluginName === undefined) { - return id; - } - - return this.loader.applyPluginToUrl(id, pluginName); - } - - return id; - }; - - return ViewEngine; - }(), _class19.viewModelRequireMetadataKey = 'aurelia:view-model-require', _temp4)) || _class18); - - var Controller = exports.Controller = function () { - function Controller(behavior, instruction, viewModel, container) { - - - this.behavior = behavior; - this.instruction = instruction; - this.viewModel = viewModel; - this.isAttached = false; - this.view = null; - this.isBound = false; - this.scope = null; - this.container = container; - this.elementEvents = container.elementEvents || null; - - var observerLookup = behavior.observerLocator.getOrCreateObserversLookup(viewModel); - var handlesBind = behavior.handlesBind; - var attributes = instruction.attributes; - var boundProperties = this.boundProperties = []; - var properties = behavior.properties; - var i = void 0; - var ii = void 0; - - behavior._ensurePropertiesDefined(viewModel, observerLookup); - - for (i = 0, ii = properties.length; i < ii; ++i) { - properties[i]._initialize(viewModel, observerLookup, attributes, handlesBind, boundProperties); - } - } - - Controller.prototype.created = function created(owningView) { - if (this.behavior.handlesCreated) { - this.viewModel.created(owningView, this.view); - } - }; - - Controller.prototype.automate = function automate(overrideContext, owningView) { - this.view.bindingContext = this.viewModel; - this.view.overrideContext = overrideContext || (0, _aureliaBinding.createOverrideContext)(this.viewModel); - this.view._isUserControlled = true; - - if (this.behavior.handlesCreated) { - this.viewModel.created(owningView || null, this.view); - } - - this.bind(this.view); - }; - - Controller.prototype.bind = function bind(scope) { - var skipSelfSubscriber = this.behavior.handlesBind; - var boundProperties = this.boundProperties; - var i = void 0; - var ii = void 0; - var x = void 0; - var observer = void 0; - var selfSubscriber = void 0; - - if (this.isBound) { - if (this.scope === scope) { - return; - } - - this.unbind(); - } - - this.isBound = true; - this.scope = scope; - - for (i = 0, ii = boundProperties.length; i < ii; ++i) { - x = boundProperties[i]; - observer = x.observer; - selfSubscriber = observer.selfSubscriber; - observer.publishing = false; - - if (skipSelfSubscriber) { - observer.selfSubscriber = null; - } - - x.binding.bind(scope); - observer.call(); - - observer.publishing = true; - observer.selfSubscriber = selfSubscriber; - } - - var overrideContext = void 0; - if (this.view !== null) { - if (skipSelfSubscriber) { - this.view.viewModelScope = scope; - } - - if (this.viewModel === scope.overrideContext.bindingContext) { - overrideContext = scope.overrideContext; - } else if (this.instruction.inheritBindingContext) { - overrideContext = (0, _aureliaBinding.createOverrideContext)(this.viewModel, scope.overrideContext); - } else { - overrideContext = (0, _aureliaBinding.createOverrideContext)(this.viewModel); - overrideContext.__parentOverrideContext = scope.overrideContext; - } - - this.view.bind(this.viewModel, overrideContext); - } else if (skipSelfSubscriber) { - overrideContext = scope.overrideContext; - - if (scope.overrideContext.__parentOverrideContext !== undefined && this.viewModel.viewFactory && this.viewModel.viewFactory.factoryCreateInstruction.partReplacements) { - overrideContext = Object.assign({}, scope.overrideContext); - overrideContext.parentOverrideContext = scope.overrideContext.__parentOverrideContext; - } - this.viewModel.bind(scope.bindingContext, overrideContext); - } - }; - - Controller.prototype.unbind = function unbind() { - if (this.isBound) { - var boundProperties = this.boundProperties; - var i = void 0; - var ii = void 0; - - this.isBound = false; - this.scope = null; - - if (this.view !== null) { - this.view.unbind(); - } - - if (this.behavior.handlesUnbind) { - this.viewModel.unbind(); - } - - if (this.elementEvents !== null) { - this.elementEvents.disposeAll(); - } - - for (i = 0, ii = boundProperties.length; i < ii; ++i) { - boundProperties[i].binding.unbind(); - } - } - }; - - Controller.prototype.attached = function attached() { - if (this.isAttached) { - return; - } - - this.isAttached = true; - - if (this.behavior.handlesAttached) { - this.viewModel.attached(); - } - - if (this.view !== null) { - this.view.attached(); - } - }; - - Controller.prototype.detached = function detached() { - if (this.isAttached) { - this.isAttached = false; - - if (this.view !== null) { - this.view.detached(); - } - - if (this.behavior.handlesDetached) { - this.viewModel.detached(); - } - } - }; - - return Controller; - }(); - - var BehaviorPropertyObserver = exports.BehaviorPropertyObserver = (_dec9 = (0, _aureliaBinding.subscriberCollection)(), _dec9(_class21 = function () { - function BehaviorPropertyObserver(taskQueue, obj, propertyName, selfSubscriber, initialValue) { - - - this.taskQueue = taskQueue; - this.obj = obj; - this.propertyName = propertyName; - this.notqueued = true; - this.publishing = false; - this.selfSubscriber = selfSubscriber; - this.currentValue = this.oldValue = initialValue; - } - - BehaviorPropertyObserver.prototype.getValue = function getValue() { - return this.currentValue; - }; - - BehaviorPropertyObserver.prototype.setValue = function setValue(newValue) { - var oldValue = this.currentValue; - - if (oldValue !== newValue) { - this.oldValue = oldValue; - this.currentValue = newValue; - - if (this.publishing && this.notqueued) { - if (this.taskQueue.flushing) { - this.call(); - } else { - this.notqueued = false; - this.taskQueue.queueMicroTask(this); - } - } - } - }; - - BehaviorPropertyObserver.prototype.call = function call() { - var oldValue = this.oldValue; - var newValue = this.currentValue; - - this.notqueued = true; - - if (newValue === oldValue) { - return; - } - - if (this.selfSubscriber) { - this.selfSubscriber(newValue, oldValue); - } - - this.callSubscribers(newValue, oldValue); - this.oldValue = newValue; - }; - - BehaviorPropertyObserver.prototype.subscribe = function subscribe(context, callable) { - this.addSubscriber(context, callable); - }; - - BehaviorPropertyObserver.prototype.unsubscribe = function unsubscribe(context, callable) { - this.removeSubscriber(context, callable); - }; - - return BehaviorPropertyObserver; - }()) || _class21); - - - function getObserver(behavior, instance, name) { - var lookup = instance.__observers__; - - if (lookup === undefined) { - if (!behavior.isInitialized) { - behavior.initialize(_aureliaDependencyInjection.Container.instance || new _aureliaDependencyInjection.Container(), instance.constructor); - } - - lookup = behavior.observerLocator.getOrCreateObserversLookup(instance); - behavior._ensurePropertiesDefined(instance, lookup); - } - - return lookup[name]; - } - - var BindableProperty = exports.BindableProperty = function () { - function BindableProperty(nameOrConfig) { - - - if (typeof nameOrConfig === 'string') { - this.name = nameOrConfig; - } else { - Object.assign(this, nameOrConfig); - } - - this.attribute = this.attribute || _hyphenate(this.name); - if (this.defaultBindingMode === null || this.defaultBindingMode === undefined) { - this.defaultBindingMode = _aureliaBinding.bindingMode.oneWay; - } - this.changeHandler = this.changeHandler || null; - this.owner = null; - this.descriptor = null; - } - - BindableProperty.prototype.registerWith = function registerWith(target, behavior, descriptor) { - behavior.properties.push(this); - behavior.attributes[this.attribute] = this; - this.owner = behavior; - - if (descriptor) { - this.descriptor = descriptor; - return this._configureDescriptor(behavior, descriptor); - } - - return undefined; - }; - - BindableProperty.prototype._configureDescriptor = function _configureDescriptor(behavior, descriptor) { - var name = this.name; - - descriptor.configurable = true; - descriptor.enumerable = true; - - if ('initializer' in descriptor) { - this.defaultValue = descriptor.initializer; - delete descriptor.initializer; - delete descriptor.writable; - } - - if ('value' in descriptor) { - this.defaultValue = descriptor.value; - delete descriptor.value; - delete descriptor.writable; - } - - descriptor.get = function () { - return getObserver(behavior, this, name).getValue(); - }; - - descriptor.set = function (value) { - getObserver(behavior, this, name).setValue(value); - }; - - descriptor.get.getObserver = function (obj) { - return getObserver(behavior, obj, name); - }; - - return descriptor; - }; - - BindableProperty.prototype.defineOn = function defineOn(target, behavior) { - var name = this.name; - var handlerName = void 0; - - if (this.changeHandler === null) { - handlerName = name + 'Changed'; - if (handlerName in target.prototype) { - this.changeHandler = handlerName; - } - } - - if (this.descriptor === null) { - Object.defineProperty(target.prototype, name, this._configureDescriptor(behavior, {})); - } - }; - - BindableProperty.prototype.createObserver = function createObserver(viewModel) { - var selfSubscriber = null; - var defaultValue = this.defaultValue; - var changeHandlerName = this.changeHandler; - var name = this.name; - var initialValue = void 0; - - if (this.hasOptions) { - return undefined; - } - - if (changeHandlerName in viewModel) { - if ('propertyChanged' in viewModel) { - selfSubscriber = function selfSubscriber(newValue, oldValue) { - viewModel[changeHandlerName](newValue, oldValue); - viewModel.propertyChanged(name, newValue, oldValue); - }; - } else { - selfSubscriber = function selfSubscriber(newValue, oldValue) { - return viewModel[changeHandlerName](newValue, oldValue); - }; - } - } else if ('propertyChanged' in viewModel) { - selfSubscriber = function selfSubscriber(newValue, oldValue) { - return viewModel.propertyChanged(name, newValue, oldValue); - }; - } else if (changeHandlerName !== null) { - throw new Error('Change handler ' + changeHandlerName + ' was specified but not declared on the class.'); - } - - if (defaultValue !== undefined) { - initialValue = typeof defaultValue === 'function' ? defaultValue.call(viewModel) : defaultValue; - } - - return new BehaviorPropertyObserver(this.owner.taskQueue, viewModel, this.name, selfSubscriber, initialValue); - }; - - BindableProperty.prototype._initialize = function _initialize(viewModel, observerLookup, attributes, behaviorHandlesBind, boundProperties) { - var selfSubscriber = void 0; - var observer = void 0; - var attribute = void 0; - var defaultValue = this.defaultValue; - - if (this.isDynamic) { - for (var key in attributes) { - this._createDynamicProperty(viewModel, observerLookup, behaviorHandlesBind, key, attributes[key], boundProperties); - } - } else if (!this.hasOptions) { - observer = observerLookup[this.name]; - - if (attributes !== null) { - selfSubscriber = observer.selfSubscriber; - attribute = attributes[this.attribute]; - - if (behaviorHandlesBind) { - observer.selfSubscriber = null; - } - - if (typeof attribute === 'string') { - viewModel[this.name] = attribute; - observer.call(); - } else if (attribute) { - boundProperties.push({ observer: observer, binding: attribute.createBinding(viewModel) }); - } else if (defaultValue !== undefined) { - observer.call(); - } - - observer.selfSubscriber = selfSubscriber; - } - - observer.publishing = true; - } - }; - - BindableProperty.prototype._createDynamicProperty = function _createDynamicProperty(viewModel, observerLookup, behaviorHandlesBind, name, attribute, boundProperties) { - var changeHandlerName = name + 'Changed'; - var selfSubscriber = null; - var observer = void 0; - var info = void 0; - - if (changeHandlerName in viewModel) { - if ('propertyChanged' in viewModel) { - selfSubscriber = function selfSubscriber(newValue, oldValue) { - viewModel[changeHandlerName](newValue, oldValue); - viewModel.propertyChanged(name, newValue, oldValue); - }; - } else { - selfSubscriber = function selfSubscriber(newValue, oldValue) { - return viewModel[changeHandlerName](newValue, oldValue); - }; - } - } else if ('propertyChanged' in viewModel) { - selfSubscriber = function selfSubscriber(newValue, oldValue) { - return viewModel.propertyChanged(name, newValue, oldValue); - }; - } - - observer = observerLookup[name] = new BehaviorPropertyObserver(this.owner.taskQueue, viewModel, name, selfSubscriber); - - Object.defineProperty(viewModel, name, { - configurable: true, - enumerable: true, - get: observer.getValue.bind(observer), - set: observer.setValue.bind(observer) - }); - - if (behaviorHandlesBind) { - observer.selfSubscriber = null; - } - - if (typeof attribute === 'string') { - viewModel[name] = attribute; - observer.call(); - } else if (attribute) { - info = { observer: observer, binding: attribute.createBinding(viewModel) }; - boundProperties.push(info); - } - - observer.publishing = true; - observer.selfSubscriber = selfSubscriber; - }; - - return BindableProperty; - }(); - - var lastProviderId = 0; - - function nextProviderId() { - return ++lastProviderId; - } - - function doProcessContent() { - return true; - } - function doProcessAttributes() {} - - var HtmlBehaviorResource = exports.HtmlBehaviorResource = function () { - function HtmlBehaviorResource() { - - - this.elementName = null; - this.attributeName = null; - this.attributeDefaultBindingMode = undefined; - this.liftsContent = false; - this.targetShadowDOM = false; - this.shadowDOMOptions = null; - this.processAttributes = doProcessAttributes; - this.processContent = doProcessContent; - this.usesShadowDOM = false; - this.childBindings = null; - this.hasDynamicOptions = false; - this.containerless = false; - this.properties = []; - this.attributes = {}; - this.isInitialized = false; - } - - HtmlBehaviorResource.convention = function convention(name, existing) { - var behavior = void 0; - - if (name.endsWith('CustomAttribute')) { - behavior = existing || new HtmlBehaviorResource(); - behavior.attributeName = _hyphenate(name.substring(0, name.length - 15)); - } - - if (name.endsWith('CustomElement')) { - behavior = existing || new HtmlBehaviorResource(); - behavior.elementName = _hyphenate(name.substring(0, name.length - 13)); - } - - return behavior; - }; - - HtmlBehaviorResource.prototype.addChildBinding = function addChildBinding(behavior) { - if (this.childBindings === null) { - this.childBindings = []; - } - - this.childBindings.push(behavior); - }; - - HtmlBehaviorResource.prototype.initialize = function initialize(container, target) { - var proto = target.prototype; - var properties = this.properties; - var attributeName = this.attributeName; - var attributeDefaultBindingMode = this.attributeDefaultBindingMode; - var i = void 0; - var ii = void 0; - var current = void 0; - - if (this.isInitialized) { - return; - } - - this.isInitialized = true; - target.__providerId__ = nextProviderId(); - - this.observerLocator = container.get(_aureliaBinding.ObserverLocator); - this.taskQueue = container.get(_aureliaTaskQueue.TaskQueue); - - this.target = target; - this.usesShadowDOM = this.targetShadowDOM && _aureliaPal.FEATURE.shadowDOM; - this.handlesCreated = 'created' in proto; - this.handlesBind = 'bind' in proto; - this.handlesUnbind = 'unbind' in proto; - this.handlesAttached = 'attached' in proto; - this.handlesDetached = 'detached' in proto; - this.htmlName = this.elementName || this.attributeName; - - if (attributeName !== null) { - if (properties.length === 0) { - new BindableProperty({ - name: 'value', - changeHandler: 'valueChanged' in proto ? 'valueChanged' : null, - attribute: attributeName, - defaultBindingMode: attributeDefaultBindingMode - }).registerWith(target, this); - } - - current = properties[0]; - - if (properties.length === 1 && current.name === 'value') { - current.isDynamic = current.hasOptions = this.hasDynamicOptions; - current.defineOn(target, this); - } else { - for (i = 0, ii = properties.length; i < ii; ++i) { - properties[i].defineOn(target, this); - } - - current = new BindableProperty({ - name: 'value', - changeHandler: 'valueChanged' in proto ? 'valueChanged' : null, - attribute: attributeName, - defaultBindingMode: attributeDefaultBindingMode - }); - - current.hasOptions = true; - current.registerWith(target, this); - } - } else { - for (i = 0, ii = properties.length; i < ii; ++i) { - properties[i].defineOn(target, this); - } - } - }; - - HtmlBehaviorResource.prototype.register = function register(registry, name) { - if (this.attributeName !== null) { - registry.registerAttribute(name || this.attributeName, this, this.attributeName); - } - - if (this.elementName !== null) { - registry.registerElement(name || this.elementName, this); - } - }; - - HtmlBehaviorResource.prototype.load = function load(container, target, loadContext, viewStrategy, transientView) { - var _this13 = this; - - var options = void 0; - - if (this.elementName !== null) { - viewStrategy = container.get(ViewLocator).getViewStrategy(viewStrategy || this.viewStrategy || target); - options = new ViewCompileInstruction(this.targetShadowDOM, true); - - if (!viewStrategy.moduleId) { - viewStrategy.moduleId = _aureliaMetadata.Origin.get(target).moduleId; - } - - return viewStrategy.loadViewFactory(container.get(ViewEngine), options, loadContext, target).then(function (viewFactory) { - if (!transientView || !_this13.viewFactory) { - _this13.viewFactory = viewFactory; - } - - return viewFactory; - }); - } - - return Promise.resolve(this); - }; - - HtmlBehaviorResource.prototype.compile = function compile(compiler, resources, node, instruction, parentNode) { - if (this.liftsContent) { - if (!instruction.viewFactory) { - var template = _aureliaPal.DOM.createElement('template'); - var fragment = _aureliaPal.DOM.createDocumentFragment(); - var cacheSize = node.getAttribute('view-cache'); - var part = node.getAttribute('part'); - - node.removeAttribute(instruction.originalAttrName); - _aureliaPal.DOM.replaceNode(template, node, parentNode); - fragment.appendChild(node); - instruction.viewFactory = compiler.compile(fragment, resources); - - if (part) { - instruction.viewFactory.part = part; - node.removeAttribute('part'); - } - - if (cacheSize) { - instruction.viewFactory.setCacheSize(cacheSize); - node.removeAttribute('view-cache'); - } - - node = template; - } - } else if (this.elementName !== null) { - var _partReplacements2 = {}; - - if (this.processContent(compiler, resources, node, instruction) && node.hasChildNodes()) { - var currentChild = node.firstChild; - var contentElement = this.usesShadowDOM ? null : _aureliaPal.DOM.createElement('au-content'); - var nextSibling = void 0; - var toReplace = void 0; - - while (currentChild) { - nextSibling = currentChild.nextSibling; - - if (currentChild.tagName === 'TEMPLATE' && (toReplace = currentChild.getAttribute('replace-part'))) { - _partReplacements2[toReplace] = compiler.compile(currentChild, resources); - _aureliaPal.DOM.removeNode(currentChild, parentNode); - instruction.partReplacements = _partReplacements2; - } else if (contentElement !== null) { - if (currentChild.nodeType === 3 && _isAllWhitespace(currentChild)) { - _aureliaPal.DOM.removeNode(currentChild, parentNode); - } else { - contentElement.appendChild(currentChild); - } - } - - currentChild = nextSibling; - } - - if (contentElement !== null && contentElement.hasChildNodes()) { - node.appendChild(contentElement); - } - - instruction.skipContentProcessing = false; - } else { - instruction.skipContentProcessing = true; - } - } - - return node; - }; - - HtmlBehaviorResource.prototype.create = function create(container, instruction, element, bindings) { - var viewHost = void 0; - var au = null; - - instruction = instruction || BehaviorInstruction.normal; - element = element || null; - bindings = bindings || null; - - if (this.elementName !== null && element) { - if (this.usesShadowDOM) { - viewHost = element.attachShadow(this.shadowDOMOptions); - container.registerInstance(_aureliaPal.DOM.boundary, viewHost); - } else { - viewHost = element; - if (this.targetShadowDOM) { - container.registerInstance(_aureliaPal.DOM.boundary, viewHost); - } - } - } - - if (element !== null) { - element.au = au = element.au || {}; - } - - var viewModel = instruction.viewModel || container.get(this.target); - var controller = new Controller(this, instruction, viewModel, container); - var childBindings = this.childBindings; - var viewFactory = void 0; - - if (this.liftsContent) { - au.controller = controller; - } else if (this.elementName !== null) { - viewFactory = instruction.viewFactory || this.viewFactory; - container.viewModel = viewModel; - - if (viewFactory) { - controller.view = viewFactory.create(container, instruction, element); - } - - if (element !== null) { - au.controller = controller; - - if (controller.view) { - if (!this.usesShadowDOM && (element.childNodes.length === 1 || element.contentElement)) { - var contentElement = element.childNodes[0] || element.contentElement; - controller.view.contentView = { fragment: contentElement }; - contentElement.parentNode && _aureliaPal.DOM.removeNode(contentElement); - } - - if (instruction.anchorIsContainer) { - if (childBindings !== null) { - for (var i = 0, ii = childBindings.length; i < ii; ++i) { - controller.view.addBinding(childBindings[i].create(element, viewModel, controller)); - } - } - - controller.view.appendNodesTo(viewHost); - } else { - controller.view.insertNodesBefore(viewHost); - } - } else if (childBindings !== null) { - for (var _i2 = 0, _ii2 = childBindings.length; _i2 < _ii2; ++_i2) { - bindings.push(childBindings[_i2].create(element, viewModel, controller)); - } - } - } else if (controller.view) { - controller.view.controller = controller; - - if (childBindings !== null) { - for (var _i3 = 0, _ii3 = childBindings.length; _i3 < _ii3; ++_i3) { - controller.view.addBinding(childBindings[_i3].create(instruction.host, viewModel, controller)); - } - } - } else if (childBindings !== null) { - for (var _i4 = 0, _ii4 = childBindings.length; _i4 < _ii4; ++_i4) { - bindings.push(childBindings[_i4].create(instruction.host, viewModel, controller)); - } - } - } else if (childBindings !== null) { - for (var _i5 = 0, _ii5 = childBindings.length; _i5 < _ii5; ++_i5) { - bindings.push(childBindings[_i5].create(element, viewModel, controller)); - } - } - - if (au !== null) { - au[this.htmlName] = controller; - } - - if (instruction.initiatedByBehavior && viewFactory) { - controller.view.created(); - } - - return controller; - }; - - HtmlBehaviorResource.prototype._ensurePropertiesDefined = function _ensurePropertiesDefined(instance, lookup) { - var properties = void 0; - var i = void 0; - var ii = void 0; - var observer = void 0; - - if ('__propertiesDefined__' in lookup) { - return; - } - - lookup.__propertiesDefined__ = true; - properties = this.properties; - - for (i = 0, ii = properties.length; i < ii; ++i) { - observer = properties[i].createObserver(instance); - - if (observer !== undefined) { - lookup[observer.propertyName] = observer; - } - } - }; - - return HtmlBehaviorResource; - }(); - - function createChildObserverDecorator(selectorOrConfig, all) { - return function (target, key, descriptor) { - var actualTarget = typeof key === 'string' ? target.constructor : target; - var r = _aureliaMetadata.metadata.getOrCreateOwn(_aureliaMetadata.metadata.resource, HtmlBehaviorResource, actualTarget); - - if (typeof selectorOrConfig === 'string') { - selectorOrConfig = { - selector: selectorOrConfig, - name: key - }; - } - - if (descriptor) { - descriptor.writable = true; - } - - selectorOrConfig.all = all; - r.addChildBinding(new ChildObserver(selectorOrConfig)); - }; - } - - function children(selectorOrConfig) { - return createChildObserverDecorator(selectorOrConfig, true); - } - - function child(selectorOrConfig) { - return createChildObserverDecorator(selectorOrConfig, false); - } - - var ChildObserver = function () { - function ChildObserver(config) { - - - this.name = config.name; - this.changeHandler = config.changeHandler || this.name + 'Changed'; - this.selector = config.selector; - this.all = config.all; - } - - ChildObserver.prototype.create = function create(viewHost, viewModel, controller) { - return new ChildObserverBinder(this.selector, viewHost, this.name, viewModel, controller, this.changeHandler, this.all); - }; - - return ChildObserver; - }(); - - var noMutations = []; - - function trackMutation(groupedMutations, binder, record) { - var mutations = groupedMutations.get(binder); - - if (!mutations) { - mutations = []; - groupedMutations.set(binder, mutations); - } - - mutations.push(record); - } - - function onChildChange(mutations, observer) { - var binders = observer.binders; - var bindersLength = binders.length; - var groupedMutations = new Map(); - - for (var i = 0, ii = mutations.length; i < ii; ++i) { - var record = mutations[i]; - var added = record.addedNodes; - var removed = record.removedNodes; - - for (var j = 0, jj = removed.length; j < jj; ++j) { - var node = removed[j]; - if (node.nodeType === 1) { - for (var k = 0; k < bindersLength; ++k) { - var binder = binders[k]; - if (binder.onRemove(node)) { - trackMutation(groupedMutations, binder, record); - } - } - } - } - - for (var _j = 0, _jj = added.length; _j < _jj; ++_j) { - var _node = added[_j]; - if (_node.nodeType === 1) { - for (var _k = 0; _k < bindersLength; ++_k) { - var _binder = binders[_k]; - if (_binder.onAdd(_node)) { - trackMutation(groupedMutations, _binder, record); - } - } - } - } - } - - groupedMutations.forEach(function (value, key) { - if (key.changeHandler !== null) { - key.viewModel[key.changeHandler](value); - } - }); - } - - var ChildObserverBinder = function () { - function ChildObserverBinder(selector, viewHost, property, viewModel, controller, changeHandler, all) { - - - this.selector = selector; - this.viewHost = viewHost; - this.property = property; - this.viewModel = viewModel; - this.controller = controller; - this.changeHandler = changeHandler in viewModel ? changeHandler : null; - this.usesShadowDOM = controller.behavior.usesShadowDOM; - this.all = all; - - if (!this.usesShadowDOM && controller.view && controller.view.contentView) { - this.contentView = controller.view.contentView; - } else { - this.contentView = null; - } - } - - ChildObserverBinder.prototype.matches = function matches(element) { - if (element.matches(this.selector)) { - if (this.contentView === null) { - return true; - } - - var contentView = this.contentView; - var assignedSlot = element.auAssignedSlot; - - if (assignedSlot && assignedSlot.projectFromAnchors) { - var anchors = assignedSlot.projectFromAnchors; - - for (var i = 0, ii = anchors.length; i < ii; ++i) { - if (anchors[i].auOwnerView === contentView) { - return true; - } - } - - return false; - } - - return element.auOwnerView === contentView; - } - - return false; - }; - - ChildObserverBinder.prototype.bind = function bind(source) { - var viewHost = this.viewHost; - var viewModel = this.viewModel; - var observer = viewHost.__childObserver__; - - if (!observer) { - observer = viewHost.__childObserver__ = _aureliaPal.DOM.createMutationObserver(onChildChange); - - var options = { - childList: true, - subtree: !this.usesShadowDOM - }; - - observer.observe(viewHost, options); - observer.binders = []; - } - - observer.binders.push(this); - - if (this.usesShadowDOM) { - var current = viewHost.firstElementChild; - - if (this.all) { - var items = viewModel[this.property]; - if (!items) { - items = viewModel[this.property] = []; - } else { - items.length = 0; - } - - while (current) { - if (this.matches(current)) { - items.push(current.au && current.au.controller ? current.au.controller.viewModel : current); - } - - current = current.nextElementSibling; - } - - if (this.changeHandler !== null) { - this.viewModel[this.changeHandler](noMutations); - } - } else { - while (current) { - if (this.matches(current)) { - var value = current.au && current.au.controller ? current.au.controller.viewModel : current; - this.viewModel[this.property] = value; - - if (this.changeHandler !== null) { - this.viewModel[this.changeHandler](value); - } - - break; - } - - current = current.nextElementSibling; - } - } - } - }; - - ChildObserverBinder.prototype.onRemove = function onRemove(element) { - if (this.matches(element)) { - var value = element.au && element.au.controller ? element.au.controller.viewModel : element; - - if (this.all) { - var items = this.viewModel[this.property] || (this.viewModel[this.property] = []); - var index = items.indexOf(value); - - if (index !== -1) { - items.splice(index, 1); - } - - return true; - } - - return false; - } - - return false; - }; - - ChildObserverBinder.prototype.onAdd = function onAdd(element) { - if (this.matches(element)) { - var value = element.au && element.au.controller ? element.au.controller.viewModel : element; - - if (this.all) { - var items = this.viewModel[this.property] || (this.viewModel[this.property] = []); - var index = 0; - var prev = element.previousElementSibling; - - while (prev) { - if (this.matches(prev)) { - index++; - } - - prev = prev.previousElementSibling; - } - - items.splice(index, 0, value); - return true; - } - - this.viewModel[this.property] = value; - - if (this.changeHandler !== null) { - this.viewModel[this.changeHandler](value); - } - } - - return false; - }; - - ChildObserverBinder.prototype.unbind = function unbind() { - if (this.viewHost.__childObserver__) { - this.viewHost.__childObserver__.disconnect(); - this.viewHost.__childObserver__ = null; - } - }; - - return ChildObserverBinder; - }(); - - function tryActivateViewModel(context) { - if (context.skipActivation || typeof context.viewModel.activate !== 'function') { - return Promise.resolve(); - } - - return context.viewModel.activate(context.model) || Promise.resolve(); - } - - var CompositionEngine = exports.CompositionEngine = (_dec10 = (0, _aureliaDependencyInjection.inject)(ViewEngine, ViewLocator), _dec10(_class22 = function () { - function CompositionEngine(viewEngine, viewLocator) { - - - this.viewEngine = viewEngine; - this.viewLocator = viewLocator; - } - - CompositionEngine.prototype._createControllerAndSwap = function _createControllerAndSwap(context) { - function swap(controller) { - return Promise.resolve(context.viewSlot.removeAll(true)).then(function () { - if (context.currentController) { - context.currentController.unbind(); - } - - context.viewSlot.add(controller.view); - - if (context.compositionTransactionNotifier) { - context.compositionTransactionNotifier.done(); - } - - return controller; - }); - } - - return this.createController(context).then(function (controller) { - controller.automate(context.overrideContext, context.owningView); - - if (context.compositionTransactionOwnershipToken) { - return context.compositionTransactionOwnershipToken.waitForCompositionComplete().then(function () { - return swap(controller); - }); - } - - return swap(controller); - }); - }; - - CompositionEngine.prototype.createController = function createController(context) { - var _this14 = this; - - var childContainer = void 0; - var viewModel = void 0; - var viewModelResource = void 0; - var m = void 0; - - return this.ensureViewModel(context).then(tryActivateViewModel).then(function () { - childContainer = context.childContainer; - viewModel = context.viewModel; - viewModelResource = context.viewModelResource; - m = viewModelResource.metadata; - - var viewStrategy = _this14.viewLocator.getViewStrategy(context.view || viewModel); - - if (context.viewResources) { - viewStrategy.makeRelativeTo(context.viewResources.viewUrl); - } - - return m.load(childContainer, viewModelResource.value, null, viewStrategy, true); - }).then(function (viewFactory) { - return m.create(childContainer, BehaviorInstruction.dynamic(context.host, viewModel, viewFactory)); - }); - }; - - CompositionEngine.prototype.ensureViewModel = function ensureViewModel(context) { - var childContainer = context.childContainer = context.childContainer || context.container.createChild(); - - if (typeof context.viewModel === 'string') { - context.viewModel = context.viewResources ? context.viewResources.relativeToView(context.viewModel) : context.viewModel; - - return this.viewEngine.importViewModelResource(context.viewModel).then(function (viewModelResource) { - childContainer.autoRegister(viewModelResource.value); - - if (context.host) { - childContainer.registerInstance(_aureliaPal.DOM.Element, context.host); - } - - context.viewModel = childContainer.viewModel = childContainer.get(viewModelResource.value); - context.viewModelResource = viewModelResource; - return context; - }); - } - - var m = _aureliaMetadata.metadata.getOrCreateOwn(_aureliaMetadata.metadata.resource, HtmlBehaviorResource, context.viewModel.constructor); - m.elementName = m.elementName || 'dynamic-element'; - m.initialize(context.container || childContainer, context.viewModel.constructor); - context.viewModelResource = { metadata: m, value: context.viewModel.constructor }; - childContainer.viewModel = context.viewModel; - return Promise.resolve(context); - }; - - CompositionEngine.prototype.compose = function compose(context) { - context.childContainer = context.childContainer || context.container.createChild(); - context.view = this.viewLocator.getViewStrategy(context.view); - - var transaction = context.childContainer.get(CompositionTransaction); - var compositionTransactionOwnershipToken = transaction.tryCapture(); - - if (compositionTransactionOwnershipToken) { - context.compositionTransactionOwnershipToken = compositionTransactionOwnershipToken; - } else { - context.compositionTransactionNotifier = transaction.enlist(); - } - - if (context.viewModel) { - return this._createControllerAndSwap(context); - } else if (context.view) { - if (context.viewResources) { - context.view.makeRelativeTo(context.viewResources.viewUrl); - } - - return context.view.loadViewFactory(this.viewEngine, new ViewCompileInstruction()).then(function (viewFactory) { - var result = viewFactory.create(context.childContainer); - result.bind(context.bindingContext, context.overrideContext); - - var work = function work() { - return Promise.resolve(context.viewSlot.removeAll(true)).then(function () { - context.viewSlot.add(result); - - if (context.compositionTransactionNotifier) { - context.compositionTransactionNotifier.done(); - } - - return result; - }); - }; - - if (context.compositionTransactionOwnershipToken) { - return context.compositionTransactionOwnershipToken.waitForCompositionComplete().then(work); - } - - return work(); - }); - } else if (context.viewSlot) { - context.viewSlot.removeAll(); - - if (context.compositionTransactionNotifier) { - context.compositionTransactionNotifier.done(); - } - - return Promise.resolve(null); - } - - return Promise.resolve(null); - }; - - return CompositionEngine; - }()) || _class22); - - var ElementConfigResource = exports.ElementConfigResource = function () { - function ElementConfigResource() { - - } - - ElementConfigResource.prototype.initialize = function initialize(container, target) {}; - - ElementConfigResource.prototype.register = function register(registry, name) {}; - - ElementConfigResource.prototype.load = function load(container, target) { - var config = new target(); - var eventManager = container.get(_aureliaBinding.EventManager); - eventManager.registerElementConfig(config); - }; - - return ElementConfigResource; - }(); - - function validateBehaviorName(name, type) { - if (/[A-Z]/.test(name)) { - var newName = _hyphenate(name); - LogManager.getLogger('templating').warn('\'' + name + '\' is not a valid ' + type + ' name and has been converted to \'' + newName + '\'. Upper-case letters are not allowed because the DOM is not case-sensitive.'); - return newName; - } - return name; - } - - function resource(instance) { - return function (target) { - _aureliaMetadata.metadata.define(_aureliaMetadata.metadata.resource, instance, target); - }; - } - - function behavior(override) { - return function (target) { - if (override instanceof HtmlBehaviorResource) { - _aureliaMetadata.metadata.define(_aureliaMetadata.metadata.resource, override, target); - } else { - var r = _aureliaMetadata.metadata.getOrCreateOwn(_aureliaMetadata.metadata.resource, HtmlBehaviorResource, target); - Object.assign(r, override); - } - }; - } - - function customElement(name) { - return function (target) { - var r = _aureliaMetadata.metadata.getOrCreateOwn(_aureliaMetadata.metadata.resource, HtmlBehaviorResource, target); - r.elementName = validateBehaviorName(name, 'custom element'); - }; - } - - function customAttribute(name, defaultBindingMode) { - return function (target) { - var r = _aureliaMetadata.metadata.getOrCreateOwn(_aureliaMetadata.metadata.resource, HtmlBehaviorResource, target); - r.attributeName = validateBehaviorName(name, 'custom attribute'); - r.attributeDefaultBindingMode = defaultBindingMode; - }; - } - - function templateController(target) { - var deco = function deco(t) { - var r = _aureliaMetadata.metadata.getOrCreateOwn(_aureliaMetadata.metadata.resource, HtmlBehaviorResource, t); - r.liftsContent = true; - }; - - return target ? deco(target) : deco; - } - - function bindable(nameOrConfigOrTarget, key, descriptor) { - var deco = function deco(target, key2, descriptor2) { - var actualTarget = key2 ? target.constructor : target; - var r = _aureliaMetadata.metadata.getOrCreateOwn(_aureliaMetadata.metadata.resource, HtmlBehaviorResource, actualTarget); - var prop = void 0; - - if (key2) { - nameOrConfigOrTarget = nameOrConfigOrTarget || {}; - nameOrConfigOrTarget.name = key2; - } - - prop = new BindableProperty(nameOrConfigOrTarget); - return prop.registerWith(actualTarget, r, descriptor2); - }; - - if (!nameOrConfigOrTarget) { - return deco; - } - - if (key) { - var _target = nameOrConfigOrTarget; - nameOrConfigOrTarget = null; - return deco(_target, key, descriptor); - } - - return deco; - } - - function dynamicOptions(target) { - var deco = function deco(t) { - var r = _aureliaMetadata.metadata.getOrCreateOwn(_aureliaMetadata.metadata.resource, HtmlBehaviorResource, t); - r.hasDynamicOptions = true; - }; - - return target ? deco(target) : deco; - } - - var defaultShadowDOMOptions = { mode: 'open' }; - function useShadowDOM(targetOrOptions) { - var options = typeof targetOrOptions === 'function' || !targetOrOptions ? defaultShadowDOMOptions : targetOrOptions; - - var deco = function deco(t) { - var r = _aureliaMetadata.metadata.getOrCreateOwn(_aureliaMetadata.metadata.resource, HtmlBehaviorResource, t); - r.targetShadowDOM = true; - r.shadowDOMOptions = options; - }; - - return typeof targetOrOptions === 'function' ? deco(targetOrOptions) : deco; - } - - function processAttributes(processor) { - return function (t) { - var r = _aureliaMetadata.metadata.getOrCreateOwn(_aureliaMetadata.metadata.resource, HtmlBehaviorResource, t); - r.processAttributes = function (compiler, resources, node, attributes, elementInstruction) { - try { - processor(compiler, resources, node, attributes, elementInstruction); - } catch (error) { - LogManager.getLogger('templating').error(error); - } - }; - }; - } - - function doNotProcessContent() { - return false; - } - - function processContent(processor) { - return function (t) { - var r = _aureliaMetadata.metadata.getOrCreateOwn(_aureliaMetadata.metadata.resource, HtmlBehaviorResource, t); - r.processContent = processor ? function (compiler, resources, node, instruction) { - try { - return processor(compiler, resources, node, instruction); - } catch (error) { - LogManager.getLogger('templating').error(error); - return false; - } - } : doNotProcessContent; - }; - } - - function containerless(target) { - var deco = function deco(t) { - var r = _aureliaMetadata.metadata.getOrCreateOwn(_aureliaMetadata.metadata.resource, HtmlBehaviorResource, t); - r.containerless = true; - }; - - return target ? deco(target) : deco; - } - - function useViewStrategy(strategy) { - return function (target) { - _aureliaMetadata.metadata.define(ViewLocator.viewStrategyMetadataKey, strategy, target); - }; - } - - function useView(path) { - return useViewStrategy(new RelativeViewStrategy(path)); - } - - function inlineView(markup, dependencies, dependencyBaseUrl) { - return useViewStrategy(new InlineViewStrategy(markup, dependencies, dependencyBaseUrl)); - } - - function noView(targetOrDependencies, dependencyBaseUrl) { - var target = void 0; - var dependencies = void 0; - if (typeof targetOrDependencies === 'function') { - target = targetOrDependencies; - } else { - dependencies = targetOrDependencies; - target = undefined; - } - - var deco = function deco(t) { - _aureliaMetadata.metadata.define(ViewLocator.viewStrategyMetadataKey, new NoViewStrategy(dependencies, dependencyBaseUrl), t); - }; - - return target ? deco(target) : deco; - } - - function elementConfig(target) { - var deco = function deco(t) { - _aureliaMetadata.metadata.define(_aureliaMetadata.metadata.resource, new ElementConfigResource(), t); - }; - - return target ? deco(target) : deco; - } - - function viewResources() { - for (var _len = arguments.length, resources = Array(_len), _key = 0; _key < _len; _key++) { - resources[_key] = arguments[_key]; - } - - return function (target) { - _aureliaMetadata.metadata.define(ViewEngine.viewModelRequireMetadataKey, resources, target); - }; - } - - var TemplatingEngine = exports.TemplatingEngine = (_dec11 = (0, _aureliaDependencyInjection.inject)(_aureliaDependencyInjection.Container, ModuleAnalyzer, ViewCompiler, CompositionEngine), _dec11(_class23 = function () { - function TemplatingEngine(container, moduleAnalyzer, viewCompiler, compositionEngine) { - - - this._container = container; - this._moduleAnalyzer = moduleAnalyzer; - this._viewCompiler = viewCompiler; - this._compositionEngine = compositionEngine; - container.registerInstance(Animator, Animator.instance = new Animator()); - } - - TemplatingEngine.prototype.configureAnimator = function configureAnimator(animator) { - this._container.unregister(Animator); - this._container.registerInstance(Animator, Animator.instance = animator); - }; - - TemplatingEngine.prototype.compose = function compose(context) { - return this._compositionEngine.compose(context); - }; - - TemplatingEngine.prototype.enhance = function enhance(instruction) { - if (instruction instanceof _aureliaPal.DOM.Element) { - instruction = { element: instruction }; - } - - var compilerInstructions = {}; - var resources = instruction.resources || this._container.get(ViewResources); - - this._viewCompiler._compileNode(instruction.element, resources, compilerInstructions, instruction.element.parentNode, 'root', true); - - var factory = new ViewFactory(instruction.element, compilerInstructions, resources); - var container = instruction.container || this._container.createChild(); - var view = factory.create(container, BehaviorInstruction.enhance()); - - view.bind(instruction.bindingContext || {}, instruction.overrideContext); - - return view; - }; - - return TemplatingEngine; - }()) || _class23); -}); -define('aurelia-pal-browser',['exports', 'aurelia-pal'], function (exports, _aureliaPal) { - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports._DOM = exports._FEATURE = exports._PLATFORM = undefined; - exports._ensureFunctionName = _ensureFunctionName; - exports._ensureClassList = _ensureClassList; - exports._ensurePerformance = _ensurePerformance; - exports._ensureCustomEvent = _ensureCustomEvent; - exports._ensureElementMatches = _ensureElementMatches; - exports._ensureHTMLTemplateElement = _ensureHTMLTemplateElement; - exports.initialize = initialize; - - var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { - return typeof obj; - } : function (obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; - }; - - var _PLATFORM = exports._PLATFORM = { - location: window.location, - history: window.history, - addEventListener: function addEventListener(eventName, callback, capture) { - this.global.addEventListener(eventName, callback, capture); - }, - removeEventListener: function removeEventListener(eventName, callback, capture) { - this.global.removeEventListener(eventName, callback, capture); - }, - - performance: window.performance, - requestAnimationFrame: function requestAnimationFrame(callback) { - return this.global.requestAnimationFrame(callback); - } - }; - - function _ensureFunctionName() { - function test() {} - - if (!test.name) { - Object.defineProperty(Function.prototype, 'name', { - get: function get() { - var name = this.toString().match(/^\s*function\s*(\S*)\s*\(/)[1]; - - Object.defineProperty(this, 'name', { value: name }); - return name; - } - }); - } - } - - function _ensureClassList() { - if (!('classList' in document.createElement('_')) || document.createElementNS && !('classList' in document.createElementNS('http://www.w3.org/2000/svg', 'g'))) { - (function () { - var protoProp = 'prototype'; - var strTrim = String.prototype.trim; - var arrIndexOf = Array.prototype.indexOf; - var emptyArray = []; - - var DOMEx = function DOMEx(type, message) { - this.name = type; - this.code = DOMException[type]; - this.message = message; - }; - - var checkTokenAndGetIndex = function checkTokenAndGetIndex(classList, token) { - if (token === '') { - throw new DOMEx('SYNTAX_ERR', 'An invalid or illegal string was specified'); - } - - if (/\s/.test(token)) { - throw new DOMEx('INVALID_CHARACTER_ERR', 'String contains an invalid character'); - } - - return arrIndexOf.call(classList, token); - }; - - var ClassList = function ClassList(elem) { - var trimmedClasses = strTrim.call(elem.getAttribute('class') || ''); - var classes = trimmedClasses ? trimmedClasses.split(/\s+/) : emptyArray; - - for (var i = 0, ii = classes.length; i < ii; ++i) { - this.push(classes[i]); - } - - this._updateClassName = function () { - elem.setAttribute('class', this.toString()); - }; - }; - - var classListProto = ClassList[protoProp] = []; - - DOMEx[protoProp] = Error[protoProp]; - - classListProto.item = function (i) { - return this[i] || null; - }; - - classListProto.contains = function (token) { - token += ''; - return checkTokenAndGetIndex(this, token) !== -1; - }; - - classListProto.add = function () { - var tokens = arguments; - var i = 0; - var ii = tokens.length; - var token = void 0; - var updated = false; - - do { - token = tokens[i] + ''; - if (checkTokenAndGetIndex(this, token) === -1) { - this.push(token); - updated = true; - } - } while (++i < ii); - - if (updated) { - this._updateClassName(); - } - }; - - classListProto.remove = function () { - var tokens = arguments; - var i = 0; - var ii = tokens.length; - var token = void 0; - var updated = false; - var index = void 0; - - do { - token = tokens[i] + ''; - index = checkTokenAndGetIndex(this, token); - while (index !== -1) { - this.splice(index, 1); - updated = true; - index = checkTokenAndGetIndex(this, token); - } - } while (++i < ii); - - if (updated) { - this._updateClassName(); - } - }; - - classListProto.toggle = function (token, force) { - token += ''; - - var result = this.contains(token); - var method = result ? force !== true && 'remove' : force !== false && 'add'; - - if (method) { - this[method](token); - } - - if (force === true || force === false) { - return force; - } - - return !result; - }; - - classListProto.toString = function () { - return this.join(' '); - }; - - Object.defineProperty(Element.prototype, 'classList', { - get: function get() { - return new ClassList(this); - }, - enumerable: true, - configurable: true - }); - })(); - } else { - var testElement = document.createElement('_'); - testElement.classList.add('c1', 'c2'); - - if (!testElement.classList.contains('c2')) { - var createMethod = function createMethod(method) { - var original = DOMTokenList.prototype[method]; - - DOMTokenList.prototype[method] = function (token) { - for (var i = 0, ii = arguments.length; i < ii; ++i) { - token = arguments[i]; - original.call(this, token); - } - }; - }; - - createMethod('add'); - createMethod('remove'); - } - - testElement.classList.toggle('c3', false); - - if (testElement.classList.contains('c3')) { - (function () { - var _toggle = DOMTokenList.prototype.toggle; - - DOMTokenList.prototype.toggle = function (token, force) { - if (1 in arguments && !this.contains(token) === !force) { - return force; - } - - return _toggle.call(this, token); - }; - })(); - } - - testElement = null; - } - } - - function _ensurePerformance() { - // @license http://opensource.org/licenses/MIT - if ('performance' in window === false) { - window.performance = {}; - } - - if ('now' in window.performance === false) { - (function () { - var nowOffset = Date.now(); - - if (performance.timing && performance.timing.navigationStart) { - nowOffset = performance.timing.navigationStart; - } - - window.performance.now = function now() { - return Date.now() - nowOffset; - }; - })(); - } - - _PLATFORM.performance = window.performance; - } - - function _ensureCustomEvent() { - if (!window.CustomEvent || typeof window.CustomEvent !== 'function') { - var _CustomEvent = function _CustomEvent(event, params) { - params = params || { - bubbles: false, - cancelable: false, - detail: undefined - }; - - var evt = document.createEvent('CustomEvent'); - evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); - return evt; - }; - - _CustomEvent.prototype = window.Event.prototype; - window.CustomEvent = _CustomEvent; - } - } - - function _ensureElementMatches() { - if (Element && !Element.prototype.matches) { - var proto = Element.prototype; - proto.matches = proto.matchesSelector || proto.mozMatchesSelector || proto.msMatchesSelector || proto.oMatchesSelector || proto.webkitMatchesSelector; - } - } - - var _FEATURE = exports._FEATURE = {}; - - _FEATURE.shadowDOM = function () { - return !!HTMLElement.prototype.attachShadow; - }(); - - _FEATURE.scopedCSS = function () { - return 'scoped' in document.createElement('style'); - }(); - - _FEATURE.htmlTemplateElement = function () { - return 'content' in document.createElement('template'); - }(); - - _FEATURE.mutationObserver = function () { - return !!(window.MutationObserver || window.WebKitMutationObserver); - }(); - - function _ensureHTMLTemplateElement() { - function isSVGTemplate(el) { - return el.tagName === 'template' && el.namespaceURI === 'http://www.w3.org/2000/svg'; - } - - function fixSVGTemplateElement(el) { - var template = el.ownerDocument.createElement('template'); - var attrs = el.attributes; - var length = attrs.length; - var attr = void 0; - - el.parentNode.insertBefore(template, el); - - while (length-- > 0) { - attr = attrs[length]; - template.setAttribute(attr.name, attr.value); - el.removeAttribute(attr.name); - } - - el.parentNode.removeChild(el); - - return fixHTMLTemplateElement(template); - } - - function fixHTMLTemplateElement(template) { - var content = template.content = document.createDocumentFragment(); - var child = void 0; - - while (child = template.firstChild) { - content.appendChild(child); - } - - return template; - } - - function fixHTMLTemplateElementRoot(template) { - var content = fixHTMLTemplateElement(template).content; - var childTemplates = content.querySelectorAll('template'); - - for (var i = 0, ii = childTemplates.length; i < ii; ++i) { - var child = childTemplates[i]; - - if (isSVGTemplate(child)) { - fixSVGTemplateElement(child); - } else { - fixHTMLTemplateElement(child); - } - } - - return template; - } - - if (_FEATURE.htmlTemplateElement) { - _FEATURE.ensureHTMLTemplateElement = function (template) { - return template; - }; - } else { - _FEATURE.ensureHTMLTemplateElement = fixHTMLTemplateElementRoot; - } - } - - var shadowPoly = window.ShadowDOMPolyfill || null; - - var _DOM = exports._DOM = { - Element: Element, - SVGElement: SVGElement, - boundary: 'aurelia-dom-boundary', - addEventListener: function addEventListener(eventName, callback, capture) { - document.addEventListener(eventName, callback, capture); - }, - removeEventListener: function removeEventListener(eventName, callback, capture) { - document.removeEventListener(eventName, callback, capture); - }, - adoptNode: function adoptNode(node) { - return document.adoptNode(node, true); - }, - createElement: function createElement(tagName) { - return document.createElement(tagName); - }, - createTextNode: function createTextNode(text) { - return document.createTextNode(text); - }, - createComment: function createComment(text) { - return document.createComment(text); - }, - createDocumentFragment: function createDocumentFragment() { - return document.createDocumentFragment(); - }, - createMutationObserver: function createMutationObserver(callback) { - return new (window.MutationObserver || window.WebKitMutationObserver)(callback); - }, - createCustomEvent: function createCustomEvent(eventType, options) { - return new window.CustomEvent(eventType, options); - }, - dispatchEvent: function dispatchEvent(evt) { - document.dispatchEvent(evt); - }, - getComputedStyle: function getComputedStyle(element) { - return window.getComputedStyle(element); - }, - getElementById: function getElementById(id) { - return document.getElementById(id); - }, - querySelectorAll: function querySelectorAll(query) { - return document.querySelectorAll(query); - }, - nextElementSibling: function nextElementSibling(element) { - if (element.nextElementSibling) { - return element.nextElementSibling; - } - do { - element = element.nextSibling; - } while (element && element.nodeType !== 1); - return element; - }, - createTemplateFromMarkup: function createTemplateFromMarkup(markup) { - var parser = document.createElement('div'); - parser.innerHTML = markup; - - var temp = parser.firstElementChild; - if (!temp || temp.nodeName !== 'TEMPLATE') { - throw new Error('Template markup must be wrapped in a