dist/ember-runtime.js in ember-source-2.9.0.beta.5 vs dist/ember-runtime.js in ember-source-2.9.0
- old
+ new
@@ -4,11 +4,11 @@
* @copyright Copyright 2011-2016 Tilde Inc. and contributors
* Portions Copyright 2006-2011 Strobe Inc.
* Portions Copyright 2008-2011 Apple Inc. All rights reserved.
* @license Licensed under MIT license
* See https://raw.github.com/emberjs/ember.js/master/LICENSE
- * @version 2.9.0-beta.5
+ * @version 2.9.0
*/
var enifed, requireModule, require, Ember;
var mainContext = this;
@@ -110,1094 +110,1057 @@
enifed = Ember.__loader.define;
require = requireModule = Ember.__loader.require;
}
})();
-var babelHelpers;
+enifed('backburner', ['exports', 'backburner/utils', 'backburner/platform', 'backburner/binary-search', 'backburner/deferred-action-queues'], function (exports, _backburnerUtils, _backburnerPlatform, _backburnerBinarySearch, _backburnerDeferredActionQueues) {
+ 'use strict';
-function inherits(subClass, superClass) {
- subClass.prototype = Object.create(superClass && superClass.prototype, {
- constructor: {
- value: subClass,
- enumerable: false,
- writable: true,
- configurable: true
+ exports.default = Backburner;
+
+ function Backburner(queueNames, options) {
+ this.queueNames = queueNames;
+ this.options = options || {};
+ if (!this.options.defaultQueue) {
+ this.options.defaultQueue = queueNames[0];
}
- });
+ this.instanceStack = [];
+ this._debouncees = [];
+ this._throttlers = [];
+ this._eventCallbacks = {
+ end: [],
+ begin: []
+ };
- if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : defaults(subClass, superClass);
-}
+ var _this = this;
+ this._boundClearItems = function () {
+ clearItems();
+ };
-function taggedTemplateLiteralLoose(strings, raw) {
- strings.raw = raw;
- return strings;
-}
+ this._timerTimeoutId = undefined;
+ this._timers = [];
-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);
- }
-}
+ this._platform = this.options._platform || _backburnerPlatform.default;
-function createClass(Constructor, protoProps, staticProps) {
- if (protoProps) defineProperties(Constructor.prototype, protoProps);
- if (staticProps) defineProperties(Constructor, staticProps);
- return Constructor;
-}
-
-function interopExportWildcard(obj, defaults) {
- var newObj = defaults({}, obj);
- delete newObj['default'];
- return newObj;
-}
-
-function defaults(obj, defaults) {
- var keys = Object.getOwnPropertyNames(defaults);
- for (var i = 0; i < keys.length; i++) {
- var key = keys[i];
- var value = Object.getOwnPropertyDescriptor(defaults, key);
- if (value && value.configurable && obj[key] === undefined) {
- Object.defineProperty(obj, key, value);
- }
+ this._boundRunExpiredTimers = function () {
+ _this._runExpiredTimers();
+ };
}
- return obj;
-}
-babelHelpers = {
- inherits: inherits,
- taggedTemplateLiteralLoose: taggedTemplateLiteralLoose,
- slice: Array.prototype.slice,
- createClass: createClass,
- interopExportWildcard: interopExportWildcard,
- defaults: defaults
-};
+ Backburner.prototype = {
+ begin: function () {
+ var options = this.options;
+ var onBegin = options && options.onBegin;
+ var previousInstance = this.currentInstance;
-enifed('backburner', ['exports'], function (exports) { 'use strict';
+ if (previousInstance) {
+ this.instanceStack.push(previousInstance);
+ }
-var NUMBER = /\d+/;
+ this.currentInstance = new _backburnerDeferredActionQueues.default(this.queueNames, options);
+ this._trigger('begin', this.currentInstance, previousInstance);
+ if (onBegin) {
+ onBegin(this.currentInstance, previousInstance);
+ }
+ },
-function each(collection, callback) {
- for (var i = 0; i < collection.length; i++) {
- callback(collection[i]);
- }
-}
+ end: function () {
+ var options = this.options;
+ var onEnd = options && options.onEnd;
+ var currentInstance = this.currentInstance;
+ var nextInstance = null;
-function isString(suspect) {
- return typeof suspect === 'string';
-}
+ // Prevent double-finally bug in Safari 6.0.2 and iOS 6
+ // This bug appears to be resolved in Safari 6.0.5 and iOS 7
+ var finallyAlreadyCalled = false;
+ try {
+ currentInstance.flush();
+ } finally {
+ if (!finallyAlreadyCalled) {
+ finallyAlreadyCalled = true;
-function isFunction(suspect) {
- return typeof suspect === 'function';
-}
+ this.currentInstance = null;
-function isNumber(suspect) {
- return typeof suspect === 'number';
-}
+ if (this.instanceStack.length) {
+ nextInstance = this.instanceStack.pop();
+ this.currentInstance = nextInstance;
+ }
+ this._trigger('end', currentInstance, nextInstance);
+ if (onEnd) {
+ onEnd(currentInstance, nextInstance);
+ }
+ }
+ }
+ },
-function isCoercableNumber(number) {
- return isNumber(number) || NUMBER.test(number);
-}
+ /**
+ Trigger an event. Supports up to two arguments. Designed around
+ triggering transition events from one run loop instance to the
+ next, which requires an argument for the first instance and then
+ an argument for the next instance.
+ @private
+ @method _trigger
+ @param {String} eventName
+ @param {any} arg1
+ @param {any} arg2
+ */
+ _trigger: function (eventName, arg1, arg2) {
+ var callbacks = this._eventCallbacks[eventName];
+ if (callbacks) {
+ for (var i = 0; i < callbacks.length; i++) {
+ callbacks[i](arg1, arg2);
+ }
+ }
+ },
-function binarySearch(time, timers) {
- var start = 0;
- var end = timers.length - 2;
- var middle, l;
+ on: function (eventName, callback) {
+ if (typeof callback !== 'function') {
+ throw new TypeError('Callback must be a function');
+ }
+ var callbacks = this._eventCallbacks[eventName];
+ if (callbacks) {
+ callbacks.push(callback);
+ } else {
+ throw new TypeError('Cannot on() event "' + eventName + '" because it does not exist');
+ }
+ },
- while (start < end) {
- // since timers is an array of pairs 'l' will always
- // be an integer
- l = (end - start) / 2;
+ off: function (eventName, callback) {
+ if (eventName) {
+ var callbacks = this._eventCallbacks[eventName];
+ var callbackFound = false;
+ if (!callbacks) return;
+ if (callback) {
+ for (var i = 0; i < callbacks.length; i++) {
+ if (callbacks[i] === callback) {
+ callbackFound = true;
+ callbacks.splice(i, 1);
+ i--;
+ }
+ }
+ }
+ if (!callbackFound) {
+ throw new TypeError('Cannot off() callback that does not exist');
+ }
+ } else {
+ throw new TypeError('Cannot off() event "' + eventName + '" because it does not exist');
+ }
+ },
- // compensate for the index in case even number
- // of pairs inside timers
- middle = start + l - (l % 2);
+ run: function () /* target, method, args */{
+ var length = arguments.length;
+ var method, target, args;
- if (time >= timers[middle]) {
- start = middle + 2;
- } else {
- end = middle;
- }
- }
+ if (length === 1) {
+ method = arguments[0];
+ target = null;
+ } else {
+ target = arguments[0];
+ method = arguments[1];
+ }
- return (time >= timers[start]) ? start + 2 : start;
-}
+ if (_backburnerUtils.isString(method)) {
+ method = target[method];
+ }
-function Queue(name, options, globalOptions) {
- this.name = name;
- this.globalOptions = globalOptions || {};
- this.options = options;
- this._queue = [];
- this.targetQueues = {};
- this._queueBeingFlushed = undefined;
-}
+ if (length > 2) {
+ args = new Array(length - 2);
+ for (var i = 0, l = length - 2; i < l; i++) {
+ args[i] = arguments[i + 2];
+ }
+ } else {
+ args = [];
+ }
-Queue.prototype = {
- push: function(target, method, args, stack) {
- var queue = this._queue;
- queue.push(target, method, args, stack);
+ var onError = getOnError(this.options);
- return {
- queue: this,
- target: target,
- method: method
- };
- },
+ this.begin();
- pushUniqueWithoutGuid: function(target, method, args, stack) {
- var queue = this._queue;
+ // guard against Safari 6's double-finally bug
+ var didFinally = false;
- for (var i = 0, l = queue.length; i < l; i += 4) {
- var currentTarget = queue[i];
- var currentMethod = queue[i+1];
+ if (onError) {
+ try {
+ return method.apply(target, args);
+ } catch (error) {
+ onError(error);
+ } finally {
+ if (!didFinally) {
+ didFinally = true;
+ this.end();
+ }
+ }
+ } else {
+ try {
+ return method.apply(target, args);
+ } finally {
+ if (!didFinally) {
+ didFinally = true;
+ this.end();
+ }
+ }
+ }
+ },
- if (currentTarget === target && currentMethod === method) {
- queue[i+2] = args; // replace args
- queue[i+3] = stack; // replace stack
- return;
+ /*
+ Join the passed method with an existing queue and execute immediately,
+ if there isn't one use `Backburner#run`.
+ The join method is like the run method except that it will schedule into
+ an existing queue if one already exists. In either case, the join method will
+ immediately execute the passed in function and return its result.
+ @method join
+ @param {Object} target
+ @param {Function} method The method to be executed
+ @param {any} args The method arguments
+ @return method result
+ */
+ join: function () /* target, method, args */{
+ if (!this.currentInstance) {
+ return this.run.apply(this, arguments);
}
- }
- queue.push(target, method, args, stack);
- },
+ var length = arguments.length;
+ var method, target;
- targetQueue: function(targetQueue, target, method, args, stack) {
- var queue = this._queue;
+ if (length === 1) {
+ method = arguments[0];
+ target = null;
+ } else {
+ target = arguments[0];
+ method = arguments[1];
+ }
- for (var i = 0, l = targetQueue.length; i < l; i += 2) {
- var currentMethod = targetQueue[i];
- var currentIndex = targetQueue[i + 1];
+ if (_backburnerUtils.isString(method)) {
+ method = target[method];
+ }
- if (currentMethod === method) {
- queue[currentIndex + 2] = args; // replace args
- queue[currentIndex + 3] = stack; // replace stack
- return;
+ if (length === 1) {
+ return method();
+ } else if (length === 2) {
+ return method.call(target);
+ } else {
+ var args = new Array(length - 2);
+ for (var i = 0, l = length - 2; i < l; i++) {
+ args[i] = arguments[i + 2];
+ }
+ return method.apply(target, args);
}
- }
+ },
- targetQueue.push(
- method,
- queue.push(target, method, args, stack) - 4
- );
- },
+ /*
+ Defer the passed function to run inside the specified queue.
+ @method defer
+ @param {String} queueName
+ @param {Object} target
+ @param {Function|String} method The method or method name to be executed
+ @param {any} args The method arguments
+ @return method result
+ */
+ defer: function (queueName /* , target, method, args */) {
+ var length = arguments.length;
+ var method, target, args;
- pushUniqueWithGuid: function(guid, target, method, args, stack) {
- var hasLocalQueue = this.targetQueues[guid];
+ if (length === 2) {
+ method = arguments[1];
+ target = null;
+ } else {
+ target = arguments[1];
+ method = arguments[2];
+ }
- if (hasLocalQueue) {
- this.targetQueue(hasLocalQueue, target, method, args, stack);
- } else {
- this.targetQueues[guid] = [
- method,
- this._queue.push(target, method, args, stack) - 4
- ];
- }
+ if (_backburnerUtils.isString(method)) {
+ method = target[method];
+ }
- return {
- queue: this,
- target: target,
- method: method
- };
- },
+ var stack = this.DEBUG ? new Error() : undefined;
- pushUnique: function(target, method, args, stack) {
- var KEY = this.globalOptions.GUID_KEY;
+ if (length > 3) {
+ args = new Array(length - 3);
+ for (var i = 3; i < length; i++) {
+ args[i - 3] = arguments[i];
+ }
+ } else {
+ args = undefined;
+ }
- if (target && KEY) {
- var guid = target[KEY];
- if (guid) {
- return this.pushUniqueWithGuid(guid, target, method, args, stack);
+ if (!this.currentInstance) {
+ createAutorun(this);
}
- }
+ return this.currentInstance.schedule(queueName, target, method, args, false, stack);
+ },
- this.pushUniqueWithoutGuid(target, method, args, stack);
+ deferOnce: function (queueName /* , target, method, args */) {
+ var length = arguments.length;
+ var method, target, args;
- return {
- queue: this,
- target: target,
- method: method
- };
- },
+ if (length === 2) {
+ method = arguments[1];
+ target = null;
+ } else {
+ target = arguments[1];
+ method = arguments[2];
+ }
- invoke: function(target, method, args /*, onError, errorRecordedForStack */) {
- if (args && args.length > 0) {
- method.apply(target, args);
- } else {
- method.call(target);
- }
- },
+ if (_backburnerUtils.isString(method)) {
+ method = target[method];
+ }
- invokeWithOnError: function(target, method, args, onError, errorRecordedForStack) {
- try {
- if (args && args.length > 0) {
- method.apply(target, args);
+ var stack = this.DEBUG ? new Error() : undefined;
+
+ if (length > 3) {
+ args = new Array(length - 3);
+ for (var i = 3; i < length; i++) {
+ args[i - 3] = arguments[i];
+ }
} else {
- method.call(target);
+ args = undefined;
}
- } catch(error) {
- onError(error, errorRecordedForStack);
- }
- },
- flush: function(sync) {
- var queue = this._queue;
- var length = queue.length;
+ if (!this.currentInstance) {
+ createAutorun(this);
+ }
+ return this.currentInstance.schedule(queueName, target, method, args, true, stack);
+ },
- if (length === 0) {
- return;
- }
+ setTimeout: function () {
+ var l = arguments.length;
+ var args = new Array(l);
- var globalOptions = this.globalOptions;
- var options = this.options;
- var before = options && options.before;
- var after = options && options.after;
- var onError = globalOptions.onError || (globalOptions.onErrorTarget &&
- globalOptions.onErrorTarget[globalOptions.onErrorMethod]);
- var target, method, args, errorRecordedForStack;
- var invoke = onError ? this.invokeWithOnError : this.invoke;
+ for (var x = 0; x < l; x++) {
+ args[x] = arguments[x];
+ }
- this.targetQueues = Object.create(null);
- var queueItems = this._queueBeingFlushed = this._queue.slice();
- this._queue = [];
+ var length = args.length,
+ method,
+ wait,
+ target,
+ methodOrTarget,
+ methodOrWait,
+ methodOrArgs;
- if (before) {
- before();
- }
+ if (length === 0) {
+ return;
+ } else if (length === 1) {
+ method = args.shift();
+ wait = 0;
+ } else if (length === 2) {
+ methodOrTarget = args[0];
+ methodOrWait = args[1];
- for (var i = 0; i < length; i += 4) {
- target = queueItems[i];
- method = queueItems[i+1];
- args = queueItems[i+2];
- errorRecordedForStack = queueItems[i+3]; // Debugging assistance
+ if (_backburnerUtils.isFunction(methodOrWait) || _backburnerUtils.isFunction(methodOrTarget[methodOrWait])) {
+ target = args.shift();
+ method = args.shift();
+ wait = 0;
+ } else if (_backburnerUtils.isCoercableNumber(methodOrWait)) {
+ method = args.shift();
+ wait = args.shift();
+ } else {
+ method = args.shift();
+ wait = 0;
+ }
+ } else {
+ var last = args[args.length - 1];
- if (isString(method)) {
- method = target[method];
- }
+ if (_backburnerUtils.isCoercableNumber(last)) {
+ wait = args.pop();
+ } else {
+ wait = 0;
+ }
- // method could have been nullified / canceled during flush
- if (method) {
- //
- // ** Attention intrepid developer **
- //
- // To find out the stack of this task when it was scheduled onto
- // the run loop, add the following to your app.js:
- //
- // Ember.run.backburner.DEBUG = true; // NOTE: This slows your app, don't leave it on in production.
- //
- // Once that is in place, when you are at a breakpoint and navigate
- // here in the stack explorer, you can look at `errorRecordedForStack.stack`,
- // which will be the captured stack when this job was scheduled.
- //
- // One possible long-term solution is the following Chrome issue:
- // https://bugs.chromium.org/p/chromium/issues/detail?id=332624
- //
- invoke(target, method, args, onError, errorRecordedForStack);
+ methodOrTarget = args[0];
+ methodOrArgs = args[1];
+
+ if (_backburnerUtils.isFunction(methodOrArgs) || _backburnerUtils.isString(methodOrArgs) && methodOrTarget !== null && methodOrArgs in methodOrTarget) {
+ target = args.shift();
+ method = args.shift();
+ } else {
+ method = args.shift();
+ }
}
- }
- if (after) {
- after();
- }
+ var executeAt = Date.now() + parseInt(wait !== wait ? 0 : wait, 10);
- this._queueBeingFlushed = undefined;
+ if (_backburnerUtils.isString(method)) {
+ method = target[method];
+ }
- if (sync !== false &&
- this._queue.length > 0) {
- // check if new items have been added
- this.flush(true);
- }
- },
+ var onError = getOnError(this.options);
- cancel: function(actionToCancel) {
- var queue = this._queue, currentTarget, currentMethod, i, l;
- var target = actionToCancel.target;
- var method = actionToCancel.method;
- var GUID_KEY = this.globalOptions.GUID_KEY;
-
- if (GUID_KEY && this.targetQueues && target) {
- var targetQueue = this.targetQueues[target[GUID_KEY]];
-
- if (targetQueue) {
- for (i = 0, l = targetQueue.length; i < l; i++) {
- if (targetQueue[i] === method) {
- targetQueue.splice(i, 1);
+ function fn() {
+ if (onError) {
+ try {
+ method.apply(target, args);
+ } catch (e) {
+ onError(e);
}
+ } else {
+ method.apply(target, args);
}
}
- }
- for (i = 0, l = queue.length; i < l; i += 4) {
- currentTarget = queue[i];
- currentMethod = queue[i+1];
+ return this._setTimeout(fn, executeAt);
+ },
- if (currentTarget === target &&
- currentMethod === method) {
- queue.splice(i, 4);
- return true;
+ _setTimeout: function (fn, executeAt) {
+ if (this._timers.length === 0) {
+ this._timers.push(executeAt, fn);
+ this._installTimerTimeout();
+ return fn;
}
- }
- // if not found in current queue
- // could be in the queue that is being flushed
- queue = this._queueBeingFlushed;
+ // find position to insert
+ var i = _backburnerBinarySearch.default(executeAt, this._timers);
- if (!queue) {
- return;
- }
+ this._timers.splice(i, 0, executeAt, fn);
- for (i = 0, l = queue.length; i < l; i += 4) {
- currentTarget = queue[i];
- currentMethod = queue[i+1];
-
- if (currentTarget === target &&
- currentMethod === method) {
- // don't mess with array during flush
- // just nullify the method
- queue[i+1] = null;
- return true;
+ // we should be the new earliest timer if i == 0
+ if (i === 0) {
+ this._reinstallTimerTimeout();
}
- }
- }
-};
-function DeferredActionQueues(queueNames, options) {
- var queues = this.queues = {};
- this.queueNames = queueNames = queueNames || [];
+ return fn;
+ },
- this.options = options;
+ throttle: function (target, method /* , args, wait, [immediate] */) {
+ var backburner = this;
+ var args = new Array(arguments.length);
+ for (var i = 0; i < arguments.length; i++) {
+ args[i] = arguments[i];
+ }
+ var immediate = args.pop();
+ var wait, throttler, index, timer;
- each(queueNames, function(queueName) {
- queues[queueName] = new Queue(queueName, options[queueName], options);
- });
-}
+ if (_backburnerUtils.isNumber(immediate) || _backburnerUtils.isString(immediate)) {
+ wait = immediate;
+ immediate = true;
+ } else {
+ wait = args.pop();
+ }
-function noSuchQueue(name) {
- throw new Error('You attempted to schedule an action in a queue (' + name + ') that doesn\'t exist');
-}
+ wait = parseInt(wait, 10);
-function noSuchMethod(name) {
- throw new Error('You attempted to schedule an action in a queue (' + name + ') for a method that doesn\'t exist');
-}
+ index = findThrottler(target, method, this._throttlers);
+ if (index > -1) {
+ return this._throttlers[index];
+ } // throttled
-DeferredActionQueues.prototype = {
- schedule: function(name, target, method, args, onceFlag, stack) {
- var queues = this.queues;
- var queue = queues[name];
+ timer = this._platform.setTimeout(function () {
+ if (!immediate) {
+ backburner.run.apply(backburner, args);
+ }
+ var index = findThrottler(target, method, backburner._throttlers);
+ if (index > -1) {
+ backburner._throttlers.splice(index, 1);
+ }
+ }, wait);
- if (!queue) {
- noSuchQueue(name);
- }
+ if (immediate) {
+ this.run.apply(this, args);
+ }
- if (!method) {
- noSuchMethod(name);
- }
+ throttler = [target, method, timer];
- if (onceFlag) {
- return queue.pushUnique(target, method, args, stack);
- } else {
- return queue.push(target, method, args, stack);
- }
- },
+ this._throttlers.push(throttler);
- flush: function() {
- var queues = this.queues;
- var queueNames = this.queueNames;
- var queueName, queue;
- var queueNameIndex = 0;
- var numberOfQueues = queueNames.length;
+ return throttler;
+ },
- while (queueNameIndex < numberOfQueues) {
- queueName = queueNames[queueNameIndex];
- queue = queues[queueName];
+ debounce: function (target, method /* , args, wait, [immediate] */) {
+ var backburner = this;
+ var args = new Array(arguments.length);
+ for (var i = 0; i < arguments.length; i++) {
+ args[i] = arguments[i];
+ }
- var numberOfQueueItems = queue._queue.length;
+ var immediate = args.pop();
+ var wait, index, debouncee, timer;
- if (numberOfQueueItems === 0) {
- queueNameIndex++;
+ if (_backburnerUtils.isNumber(immediate) || _backburnerUtils.isString(immediate)) {
+ wait = immediate;
+ immediate = false;
} else {
- queue.flush(false /* async */);
- queueNameIndex = 0;
+ wait = args.pop();
}
- }
- }
-};
-function Backburner(queueNames, options) {
- this.queueNames = queueNames;
- this.options = options || {};
- if (!this.options.defaultQueue) {
- this.options.defaultQueue = queueNames[0];
- }
- this.instanceStack = [];
- this._debouncees = [];
- this._throttlers = [];
- this._eventCallbacks = {
- end: [],
- begin: []
- };
+ wait = parseInt(wait, 10);
+ // Remove debouncee
+ index = findDebouncee(target, method, this._debouncees);
- var _this = this;
- this._boundClearItems = function() {
- clearItems();
- };
+ if (index > -1) {
+ debouncee = this._debouncees[index];
+ this._debouncees.splice(index, 1);
+ this._platform.clearTimeout(debouncee[2]);
+ }
- this._timerTimeoutId = undefined;
- this._timers = [];
+ timer = this._platform.setTimeout(function () {
+ if (!immediate) {
+ backburner.run.apply(backburner, args);
+ }
+ var index = findDebouncee(target, method, backburner._debouncees);
+ if (index > -1) {
+ backburner._debouncees.splice(index, 1);
+ }
+ }, wait);
- this._platform = this.options._platform || {
- setTimeout: function (fn, ms) {
- return setTimeout(fn, ms);
- },
- clearTimeout: function (id) {
- clearTimeout(id);
- }
- };
+ if (immediate && index === -1) {
+ backburner.run.apply(backburner, args);
+ }
- this._boundRunExpiredTimers = function () {
- _this._runExpiredTimers();
- };
-}
+ debouncee = [target, method, timer];
-Backburner.prototype = {
- begin: function() {
- var options = this.options;
- var onBegin = options && options.onBegin;
- var previousInstance = this.currentInstance;
+ backburner._debouncees.push(debouncee);
- if (previousInstance) {
- this.instanceStack.push(previousInstance);
- }
+ return debouncee;
+ },
- this.currentInstance = new DeferredActionQueues(this.queueNames, options);
- this._trigger('begin', this.currentInstance, previousInstance);
- if (onBegin) {
- onBegin(this.currentInstance, previousInstance);
- }
- },
+ cancelTimers: function () {
+ _backburnerUtils.each(this._throttlers, this._boundClearItems);
+ this._throttlers = [];
- end: function() {
- var options = this.options;
- var onEnd = options && options.onEnd;
- var currentInstance = this.currentInstance;
- var nextInstance = null;
+ _backburnerUtils.each(this._debouncees, this._boundClearItems);
+ this._debouncees = [];
- // Prevent double-finally bug in Safari 6.0.2 and iOS 6
- // This bug appears to be resolved in Safari 6.0.5 and iOS 7
- var finallyAlreadyCalled = false;
- try {
- currentInstance.flush();
- } finally {
- if (!finallyAlreadyCalled) {
- finallyAlreadyCalled = true;
+ this._clearTimerTimeout();
+ this._timers = [];
- this.currentInstance = null;
-
- if (this.instanceStack.length) {
- nextInstance = this.instanceStack.pop();
- this.currentInstance = nextInstance;
- }
- this._trigger('end', currentInstance, nextInstance);
- if (onEnd) {
- onEnd(currentInstance, nextInstance);
- }
+ if (this._autorun) {
+ this._platform.clearTimeout(this._autorun);
+ this._autorun = null;
}
- }
- },
+ },
- /**
- Trigger an event. Supports up to two arguments. Designed around
- triggering transition events from one run loop instance to the
- next, which requires an argument for the first instance and then
- an argument for the next instance.
+ hasTimers: function () {
+ return !!this._timers.length || !!this._debouncees.length || !!this._throttlers.length || this._autorun;
+ },
- @private
- @method _trigger
- @param {String} eventName
- @param {any} arg1
- @param {any} arg2
- */
- _trigger: function(eventName, arg1, arg2) {
- var callbacks = this._eventCallbacks[eventName];
- if (callbacks) {
- for (var i = 0; i < callbacks.length; i++) {
- callbacks[i](arg1, arg2);
- }
- }
- },
+ cancel: function (timer) {
+ var timerType = typeof timer;
- on: function(eventName, callback) {
- if (typeof callback !== 'function') {
- throw new TypeError('Callback must be a function');
- }
- var callbacks = this._eventCallbacks[eventName];
- if (callbacks) {
- callbacks.push(callback);
- } else {
- throw new TypeError('Cannot on() event "' + eventName + '" because it does not exist');
- }
- },
-
- off: function(eventName, callback) {
- if (eventName) {
- var callbacks = this._eventCallbacks[eventName];
- var callbackFound = false;
- if (!callbacks) return;
- if (callback) {
- for (var i = 0; i < callbacks.length; i++) {
- if (callbacks[i] === callback) {
- callbackFound = true;
- callbacks.splice(i, 1);
- i--;
+ if (timer && timerType === 'object' && timer.queue && timer.method) {
+ // we're cancelling a deferOnce
+ return timer.queue.cancel(timer);
+ } else if (timerType === 'function') {
+ // we're cancelling a setTimeout
+ for (var i = 0, l = this._timers.length; i < l; i += 2) {
+ if (this._timers[i + 1] === timer) {
+ this._timers.splice(i, 2); // remove the two elements
+ if (i === 0) {
+ this._reinstallTimerTimeout();
+ }
+ return true;
}
}
+ } else if (Object.prototype.toString.call(timer) === '[object Array]') {
+ // we're cancelling a throttle or debounce
+ return this._cancelItem(findThrottler, this._throttlers, timer) || this._cancelItem(findDebouncee, this._debouncees, timer);
+ } else {
+ return; // timer was null or not a timer
}
- if (!callbackFound) {
- throw new TypeError('Cannot off() callback that does not exist');
+ },
+
+ _cancelItem: function (findMethod, array, timer) {
+ var item, index;
+
+ if (timer.length < 3) {
+ return false;
}
- } else {
- throw new TypeError('Cannot off() event "' + eventName + '" because it does not exist');
- }
- },
- run: function(/* target, method, args */) {
- var length = arguments.length;
- var method, target, args;
+ index = findMethod(timer[0], timer[1], array);
- if (length === 1) {
- method = arguments[0];
- target = null;
- } else {
- target = arguments[0];
- method = arguments[1];
- }
+ if (index > -1) {
- if (isString(method)) {
- method = target[method];
- }
+ item = array[index];
- if (length > 2) {
- args = new Array(length - 2);
- for (var i = 0, l = length - 2; i < l; i++) {
- args[i] = arguments[i + 2];
+ if (item[2] === timer[2]) {
+ array.splice(index, 1);
+ this._platform.clearTimeout(timer[2]);
+ return true;
+ }
}
- } else {
- args = [];
- }
- var onError = getOnError(this.options);
+ return false;
+ },
- this.begin();
+ _runExpiredTimers: function () {
+ this._timerTimeoutId = undefined;
+ this.run(this, this._scheduleExpiredTimers);
+ },
- // guard against Safari 6's double-finally bug
- var didFinally = false;
-
- if (onError) {
- try {
- return method.apply(target, args);
- } catch(error) {
- onError(error);
- } finally {
- if (!didFinally) {
- didFinally = true;
- this.end();
+ _scheduleExpiredTimers: function () {
+ var n = Date.now();
+ var timers = this._timers;
+ var i = 0;
+ var l = timers.length;
+ for (; i < l; i += 2) {
+ var executeAt = timers[i];
+ var fn = timers[i + 1];
+ if (executeAt <= n) {
+ this.schedule(this.options.defaultQueue, null, fn);
+ } else {
+ break;
}
}
- } else {
- try {
- return method.apply(target, args);
- } finally {
- if (!didFinally) {
- didFinally = true;
- this.end();
- }
+ timers.splice(0, i);
+ this._installTimerTimeout();
+ },
+
+ _reinstallTimerTimeout: function () {
+ this._clearTimerTimeout();
+ this._installTimerTimeout();
+ },
+
+ _clearTimerTimeout: function () {
+ if (!this._timerTimeoutId) {
+ return;
}
+ this._platform.clearTimeout(this._timerTimeoutId);
+ this._timerTimeoutId = undefined;
+ },
+
+ _installTimerTimeout: function () {
+ if (!this._timers.length) {
+ return;
+ }
+ var minExpiresAt = this._timers[0];
+ var n = Date.now();
+ var wait = Math.max(0, minExpiresAt - n);
+ this._timerTimeoutId = this._platform.setTimeout(this._boundRunExpiredTimers, wait);
}
- },
+ };
- /*
- Join the passed method with an existing queue and execute immediately,
- if there isn't one use `Backburner#run`.
+ Backburner.prototype.schedule = Backburner.prototype.defer;
+ Backburner.prototype.scheduleOnce = Backburner.prototype.deferOnce;
+ Backburner.prototype.later = Backburner.prototype.setTimeout;
- The join method is like the run method except that it will schedule into
- an existing queue if one already exists. In either case, the join method will
- immediately execute the passed in function and return its result.
+ function getOnError(options) {
+ return options.onError || options.onErrorTarget && options.onErrorTarget[options.onErrorMethod];
+ }
- @method join
- @param {Object} target
- @param {Function} method The method to be executed
- @param {any} args The method arguments
- @return method result
- */
- join: function(/* target, method, args */) {
- if (!this.currentInstance) {
- return this.run.apply(this, arguments);
- }
+ function createAutorun(backburner) {
+ backburner.begin();
+ backburner._autorun = backburner._platform.setTimeout(function () {
+ backburner._autorun = null;
+ backburner.end();
+ });
+ }
- var length = arguments.length;
- var method, target;
+ function findDebouncee(target, method, debouncees) {
+ return findItem(target, method, debouncees);
+ }
- if (length === 1) {
- method = arguments[0];
- target = null;
- } else {
- target = arguments[0];
- method = arguments[1];
- }
+ function findThrottler(target, method, throttlers) {
+ return findItem(target, method, throttlers);
+ }
- if (isString(method)) {
- method = target[method];
- }
+ function findItem(target, method, collection) {
+ var item;
+ var index = -1;
- if (length === 1) {
- return method();
- } else if (length === 2) {
- return method.call(target);
- } else {
- var args = new Array(length - 2);
- for (var i = 0, l = length - 2; i < l; i++) {
- args[i] = arguments[i + 2];
+ for (var i = 0, l = collection.length; i < l; i++) {
+ item = collection[i];
+ if (item[0] === target && item[1] === method) {
+ index = i;
+ break;
}
- return method.apply(target, args);
}
- },
+ return index;
+ }
- /*
- Defer the passed function to run inside the specified queue.
+ function clearItems(item) {
+ this._platform.clearTimeout(item[2]);
+ }
+});
+enifed("backburner/binary-search", ["exports"], function (exports) {
+ "use strict";
- @method defer
- @param {String} queueName
- @param {Object} target
- @param {Function|String} method The method or method name to be executed
- @param {any} args The method arguments
- @return method result
- */
- defer: function(queueName /* , target, method, args */) {
- var length = arguments.length;
- var method, target, args;
+ exports.default = binarySearch;
- if (length === 2) {
- method = arguments[1];
- target = null;
- } else {
- target = arguments[1];
- method = arguments[2];
- }
+ function binarySearch(time, timers) {
+ var start = 0;
+ var end = timers.length - 2;
+ var middle, l;
- if (isString(method)) {
- method = target[method];
- }
+ while (start < end) {
+ // since timers is an array of pairs 'l' will always
+ // be an integer
+ l = (end - start) / 2;
- var stack = this.DEBUG ? new Error() : undefined;
+ // compensate for the index in case even number
+ // of pairs inside timers
+ middle = start + l - l % 2;
- if (length > 3) {
- args = new Array(length - 3);
- for (var i = 3; i < length; i++) {
- args[i-3] = arguments[i];
+ if (time >= timers[middle]) {
+ start = middle + 2;
+ } else {
+ end = middle;
}
- } else {
- args = undefined;
}
- if (!this.currentInstance) { createAutorun(this); }
- return this.currentInstance.schedule(queueName, target, method, args, false, stack);
- },
+ return time >= timers[start] ? start + 2 : start;
+ }
+});
+enifed('backburner/deferred-action-queues', ['exports', 'backburner/utils', 'backburner/queue'], function (exports, _backburnerUtils, _backburnerQueue) {
+ 'use strict';
- deferOnce: function(queueName /* , target, method, args */) {
- var length = arguments.length;
- var method, target, args;
+ exports.default = DeferredActionQueues;
- if (length === 2) {
- method = arguments[1];
- target = null;
- } else {
- target = arguments[1];
- method = arguments[2];
- }
+ function DeferredActionQueues(queueNames, options) {
+ var queues = this.queues = {};
+ this.queueNames = queueNames = queueNames || [];
- if (isString(method)) {
- method = target[method];
- }
+ this.options = options;
- var stack = this.DEBUG ? new Error() : undefined;
+ _backburnerUtils.each(queueNames, function (queueName) {
+ queues[queueName] = new _backburnerQueue.default(queueName, options[queueName], options);
+ });
+ }
- if (length > 3) {
- args = new Array(length - 3);
- for (var i = 3; i < length; i++) {
- args[i-3] = arguments[i];
- }
- } else {
- args = undefined;
- }
+ function noSuchQueue(name) {
+ throw new Error('You attempted to schedule an action in a queue (' + name + ') that doesn\'t exist');
+ }
- if (!this.currentInstance) {
- createAutorun(this);
- }
- return this.currentInstance.schedule(queueName, target, method, args, true, stack);
- },
+ function noSuchMethod(name) {
+ throw new Error('You attempted to schedule an action in a queue (' + name + ') for a method that doesn\'t exist');
+ }
- setTimeout: function() {
- var l = arguments.length;
- var args = new Array(l);
+ DeferredActionQueues.prototype = {
+ schedule: function (name, target, method, args, onceFlag, stack) {
+ var queues = this.queues;
+ var queue = queues[name];
- for (var x = 0; x < l; x++) {
- args[x] = arguments[x];
- }
+ if (!queue) {
+ noSuchQueue(name);
+ }
- var length = args.length,
- method, wait, target,
- methodOrTarget, methodOrWait, methodOrArgs;
-
- if (length === 0) {
- return;
- } else if (length === 1) {
- method = args.shift();
- wait = 0;
- } else if (length === 2) {
- methodOrTarget = args[0];
- methodOrWait = args[1];
-
- if (isFunction(methodOrWait) || isFunction(methodOrTarget[methodOrWait])) {
- target = args.shift();
- method = args.shift();
- wait = 0;
- } else if (isCoercableNumber(methodOrWait)) {
- method = args.shift();
- wait = args.shift();
- } else {
- method = args.shift();
- wait = 0;
+ if (!method) {
+ noSuchMethod(name);
}
- } else {
- var last = args[args.length - 1];
- if (isCoercableNumber(last)) {
- wait = args.pop();
+ if (onceFlag) {
+ return queue.pushUnique(target, method, args, stack);
} else {
- wait = 0;
+ return queue.push(target, method, args, stack);
}
+ },
- methodOrTarget = args[0];
- methodOrArgs = args[1];
+ flush: function () {
+ var queues = this.queues;
+ var queueNames = this.queueNames;
+ var queueName, queue;
+ var queueNameIndex = 0;
+ var numberOfQueues = queueNames.length;
- if (isFunction(methodOrArgs) || (isString(methodOrArgs) &&
- methodOrTarget !== null &&
- methodOrArgs in methodOrTarget)) {
- target = args.shift();
- method = args.shift();
- } else {
- method = args.shift();
+ while (queueNameIndex < numberOfQueues) {
+ queueName = queueNames[queueNameIndex];
+ queue = queues[queueName];
+
+ var numberOfQueueItems = queue._queue.length;
+
+ if (numberOfQueueItems === 0) {
+ queueNameIndex++;
+ } else {
+ queue.flush(false /* async */);
+ queueNameIndex = 0;
+ }
}
}
+ };
+});
+enifed('backburner/platform', ['exports'], function (exports) {
+ 'use strict';
- var executeAt = Date.now() + parseInt(wait !== wait ? 0 : wait, 10);
+ var GlobalContext;
- if (isString(method)) {
- method = target[method];
- }
+ /* global self */
+ if (typeof self === 'object') {
+ GlobalContext = self;
- var onError = getOnError(this.options);
+ /* global global */
+ } else if (typeof global === 'object') {
+ GlobalContext = global;
- function fn() {
- if (onError) {
- try {
- method.apply(target, args);
- } catch (e) {
- onError(e);
- }
+ /* global window */
+ } else if (typeof window === 'object') {
+ GlobalContext = window;
} else {
- method.apply(target, args);
+ throw new Error('no global: `self`, `global` nor `window` was found');
}
- }
- return this._setTimeout(fn, executeAt);
- },
+ exports.default = GlobalContext;
+});
+enifed('backburner/queue', ['exports', 'backburner/utils'], function (exports, _backburnerUtils) {
+ 'use strict';
- _setTimeout: function (fn, executeAt) {
- if (this._timers.length === 0) {
- this._timers.push(executeAt, fn);
- this._installTimerTimeout();
- return fn;
- }
+ exports.default = Queue;
- // find position to insert
- var i = binarySearch(executeAt, this._timers);
+ function Queue(name, options, globalOptions) {
+ this.name = name;
+ this.globalOptions = globalOptions || {};
+ this.options = options;
+ this._queue = [];
+ this.targetQueues = {};
+ this._queueBeingFlushed = undefined;
+ }
- this._timers.splice(i, 0, executeAt, fn);
+ Queue.prototype = {
+ push: function (target, method, args, stack) {
+ var queue = this._queue;
+ queue.push(target, method, args, stack);
- // we should be the new earliest timer if i == 0
- if (i === 0) {
- this._reinstallTimerTimeout();
- }
+ return {
+ queue: this,
+ target: target,
+ method: method
+ };
+ },
- return fn;
- },
+ pushUniqueWithoutGuid: function (target, method, args, stack) {
+ var queue = this._queue;
- throttle: function(target, method /* , args, wait, [immediate] */) {
- var backburner = this;
- var args = new Array(arguments.length);
- for (var i = 0; i < arguments.length; i++) {
- args[i] = arguments[i];
- }
- var immediate = args.pop();
- var wait, throttler, index, timer;
+ for (var i = 0, l = queue.length; i < l; i += 4) {
+ var currentTarget = queue[i];
+ var currentMethod = queue[i + 1];
- if (isNumber(immediate) || isString(immediate)) {
- wait = immediate;
- immediate = true;
- } else {
- wait = args.pop();
- }
+ if (currentTarget === target && currentMethod === method) {
+ queue[i + 2] = args; // replace args
+ queue[i + 3] = stack; // replace stack
+ return;
+ }
+ }
- wait = parseInt(wait, 10);
+ queue.push(target, method, args, stack);
+ },
- index = findThrottler(target, method, this._throttlers);
- if (index > -1) { return this._throttlers[index]; } // throttled
+ targetQueue: function (targetQueue, target, method, args, stack) {
+ var queue = this._queue;
- timer = this._platform.setTimeout(function() {
- if (!immediate) {
- backburner.run.apply(backburner, args);
+ for (var i = 0, l = targetQueue.length; i < l; i += 2) {
+ var currentMethod = targetQueue[i];
+ var currentIndex = targetQueue[i + 1];
+
+ if (currentMethod === method) {
+ queue[currentIndex + 2] = args; // replace args
+ queue[currentIndex + 3] = stack; // replace stack
+ return;
+ }
}
- var index = findThrottler(target, method, backburner._throttlers);
- if (index > -1) {
- backburner._throttlers.splice(index, 1);
- }
- }, wait);
- if (immediate) {
- this.run.apply(this, args);
- }
+ targetQueue.push(method, queue.push(target, method, args, stack) - 4);
+ },
- throttler = [target, method, timer];
+ pushUniqueWithGuid: function (guid, target, method, args, stack) {
+ var hasLocalQueue = this.targetQueues[guid];
- this._throttlers.push(throttler);
+ if (hasLocalQueue) {
+ this.targetQueue(hasLocalQueue, target, method, args, stack);
+ } else {
+ this.targetQueues[guid] = [method, this._queue.push(target, method, args, stack) - 4];
+ }
- return throttler;
- },
+ return {
+ queue: this,
+ target: target,
+ method: method
+ };
+ },
- debounce: function(target, method /* , args, wait, [immediate] */) {
- var backburner = this;
- var args = new Array(arguments.length);
- for (var i = 0; i < arguments.length; i++) {
- args[i] = arguments[i];
- }
+ pushUnique: function (target, method, args, stack) {
+ var KEY = this.globalOptions.GUID_KEY;
- var immediate = args.pop();
- var wait, index, debouncee, timer;
+ if (target && KEY) {
+ var guid = target[KEY];
+ if (guid) {
+ return this.pushUniqueWithGuid(guid, target, method, args, stack);
+ }
+ }
- if (isNumber(immediate) || isString(immediate)) {
- wait = immediate;
- immediate = false;
- } else {
- wait = args.pop();
- }
+ this.pushUniqueWithoutGuid(target, method, args, stack);
- wait = parseInt(wait, 10);
- // Remove debouncee
- index = findDebouncee(target, method, this._debouncees);
+ return {
+ queue: this,
+ target: target,
+ method: method
+ };
+ },
- if (index > -1) {
- debouncee = this._debouncees[index];
- this._debouncees.splice(index, 1);
- this._platform.clearTimeout(debouncee[2]);
- }
+ invoke: function (target, method, args, _, _errorRecordedForStack) {
+ if (args && args.length > 0) {
+ method.apply(target, args);
+ } else {
+ method.call(target);
+ }
+ },
- timer = this._platform.setTimeout(function() {
- if (!immediate) {
- backburner.run.apply(backburner, args);
+ invokeWithOnError: function (target, method, args, onError, errorRecordedForStack) {
+ try {
+ if (args && args.length > 0) {
+ method.apply(target, args);
+ } else {
+ method.call(target);
+ }
+ } catch (error) {
+ onError(error, errorRecordedForStack);
}
- var index = findDebouncee(target, method, backburner._debouncees);
- if (index > -1) {
- backburner._debouncees.splice(index, 1);
+ },
+
+ flush: function (sync) {
+ var queue = this._queue;
+ var length = queue.length;
+
+ if (length === 0) {
+ return;
}
- }, wait);
- if (immediate && index === -1) {
- backburner.run.apply(backburner, args);
- }
+ var globalOptions = this.globalOptions;
+ var options = this.options;
+ var before = options && options.before;
+ var after = options && options.after;
+ var onError = globalOptions.onError || globalOptions.onErrorTarget && globalOptions.onErrorTarget[globalOptions.onErrorMethod];
+ var target, method, args, errorRecordedForStack;
+ var invoke = onError ? this.invokeWithOnError : this.invoke;
- debouncee = [
- target,
- method,
- timer
- ];
+ this.targetQueues = Object.create(null);
+ var queueItems = this._queueBeingFlushed = this._queue.slice();
+ this._queue = [];
- backburner._debouncees.push(debouncee);
+ if (before) {
+ before();
+ }
- return debouncee;
- },
+ for (var i = 0; i < length; i += 4) {
+ target = queueItems[i];
+ method = queueItems[i + 1];
+ args = queueItems[i + 2];
+ errorRecordedForStack = queueItems[i + 3]; // Debugging assistance
- cancelTimers: function() {
- each(this._throttlers, this._boundClearItems);
- this._throttlers = [];
+ if (_backburnerUtils.isString(method)) {
+ method = target[method];
+ }
- each(this._debouncees, this._boundClearItems);
- this._debouncees = [];
+ // method could have been nullified / canceled during flush
+ if (method) {
+ //
+ // ** Attention intrepid developer **
+ //
+ // To find out the stack of this task when it was scheduled onto
+ // the run loop, add the following to your app.js:
+ //
+ // Ember.run.backburner.DEBUG = true; // NOTE: This slows your app, don't leave it on in production.
+ //
+ // Once that is in place, when you are at a breakpoint and navigate
+ // here in the stack explorer, you can look at `errorRecordedForStack.stack`,
+ // which will be the captured stack when this job was scheduled.
+ //
+ invoke(target, method, args, onError, errorRecordedForStack);
+ }
+ }
- this._clearTimerTimeout();
- this._timers = [];
+ if (after) {
+ after();
+ }
- if (this._autorun) {
- this._platform.clearTimeout(this._autorun);
- this._autorun = null;
- }
- },
+ this._queueBeingFlushed = undefined;
- hasTimers: function() {
- return !!this._timers.length || !!this._debouncees.length || !!this._throttlers.length || this._autorun;
- },
+ if (sync !== false && this._queue.length > 0) {
+ // check if new items have been added
+ this.flush(true);
+ }
+ },
- cancel: function (timer) {
- var timerType = typeof timer;
+ cancel: function (actionToCancel) {
+ var queue = this._queue,
+ currentTarget,
+ currentMethod,
+ i,
+ l;
+ var target = actionToCancel.target;
+ var method = actionToCancel.method;
+ var GUID_KEY = this.globalOptions.GUID_KEY;
- if (timer && timerType === 'object' && timer.queue && timer.method) { // we're cancelling a deferOnce
- return timer.queue.cancel(timer);
- } else if (timerType === 'function') { // we're cancelling a setTimeout
- for (var i = 0, l = this._timers.length; i < l; i += 2) {
- if (this._timers[i + 1] === timer) {
- this._timers.splice(i, 2); // remove the two elements
- if (i === 0) {
- this._reinstallTimerTimeout();
+ if (GUID_KEY && this.targetQueues && target) {
+ var targetQueue = this.targetQueues[target[GUID_KEY]];
+
+ if (targetQueue) {
+ for (i = 0, l = targetQueue.length; i < l; i++) {
+ if (targetQueue[i] === method) {
+ targetQueue.splice(i, 1);
+ }
}
- return true;
}
}
- } else if (Object.prototype.toString.call(timer) === '[object Array]'){ // we're cancelling a throttle or debounce
- return this._cancelItem(findThrottler, this._throttlers, timer) ||
- this._cancelItem(findDebouncee, this._debouncees, timer);
- } else {
- return; // timer was null or not a timer
- }
- },
- _cancelItem: function(findMethod, array, timer){
- var item, index;
+ for (i = 0, l = queue.length; i < l; i += 4) {
+ currentTarget = queue[i];
+ currentMethod = queue[i + 1];
- if (timer.length < 3) { return false; }
+ if (currentTarget === target && currentMethod === method) {
+ queue.splice(i, 4);
+ return true;
+ }
+ }
- index = findMethod(timer[0], timer[1], array);
+ // if not found in current queue
+ // could be in the queue that is being flushed
+ queue = this._queueBeingFlushed;
- if (index > -1) {
-
- item = array[index];
-
- if (item[2] === timer[2]) {
- array.splice(index, 1);
- this._platform.clearTimeout(timer[2]);
- return true;
+ if (!queue) {
+ return;
}
- }
- return false;
- },
+ for (i = 0, l = queue.length; i < l; i += 4) {
+ currentTarget = queue[i];
+ currentMethod = queue[i + 1];
- _runExpiredTimers: function () {
- this._timerTimeoutId = undefined;
- this.run(this, this._scheduleExpiredTimers);
- },
-
- _scheduleExpiredTimers: function () {
- var n = Date.now();
- var timers = this._timers;
- var i = 0;
- var l = timers.length;
- for (; i < l; i += 2) {
- var executeAt = timers[i];
- var fn = timers[i+1];
- if (executeAt <= n) {
- this.schedule(this.options.defaultQueue, null, fn);
- } else {
- break;
+ if (currentTarget === target && currentMethod === method) {
+ // don't mess with array during flush
+ // just nullify the method
+ queue[i + 1] = null;
+ return true;
+ }
}
}
- timers.splice(0, i);
- this._installTimerTimeout();
- },
+ };
+});
+enifed('backburner/utils', ['exports'], function (exports) {
+ 'use strict';
- _reinstallTimerTimeout: function () {
- this._clearTimerTimeout();
- this._installTimerTimeout();
- },
+ exports.each = each;
+ exports.isString = isString;
+ exports.isFunction = isFunction;
+ exports.isNumber = isNumber;
+ exports.isCoercableNumber = isCoercableNumber;
+ var NUMBER = /\d+/;
- _clearTimerTimeout: function () {
- if (!this._timerTimeoutId) {
- return;
+ function each(collection, callback) {
+ for (var i = 0; i < collection.length; i++) {
+ callback(collection[i]);
}
- this._platform.clearTimeout(this._timerTimeoutId);
- this._timerTimeoutId = undefined;
- },
+ }
- _installTimerTimeout: function () {
- if (!this._timers.length) {
- return;
- }
- var minExpiresAt = this._timers[0];
- var n = Date.now();
- var wait = Math.max(0, minExpiresAt - n);
- this._timerTimeoutId = this._platform.setTimeout(this._boundRunExpiredTimers, wait);
+ function isString(suspect) {
+ return typeof suspect === 'string';
}
-};
-Backburner.prototype.schedule = Backburner.prototype.defer;
-Backburner.prototype.scheduleOnce = Backburner.prototype.deferOnce;
-Backburner.prototype.later = Backburner.prototype.setTimeout;
+ function isFunction(suspect) {
+ return typeof suspect === 'function';
+ }
-function getOnError(options) {
- return options.onError || (options.onErrorTarget && options.onErrorTarget[options.onErrorMethod]);
-}
-
-function createAutorun(backburner) {
- var setTimeout = backburner._platform.setTimeout;
- backburner.begin();
- backburner._autorun = setTimeout(function() {
- backburner._autorun = null;
- backburner.end();
- }, 0);
-}
-
-function findDebouncee(target, method, debouncees) {
- return findItem(target, method, debouncees);
-}
-
-function findThrottler(target, method, throttlers) {
- return findItem(target, method, throttlers);
-}
-
-function findItem(target, method, collection) {
- var item;
- var index = -1;
-
- for (var i = 0, l = collection.length; i < l; i++) {
- item = collection[i];
- if (item[0] === target && item[1] === method) {
- index = i;
- break;
- }
+ function isNumber(suspect) {
+ return typeof suspect === 'number';
}
- return index;
-}
-
-function clearItems(item) {
- this._platform.clearTimeout(item[2]);
-}
-
-exports['default'] = Backburner;
-
-Object.defineProperty(exports, '__esModule', { value: true });
-
+ function isCoercableNumber(number) {
+ return isNumber(number) || NUMBER.test(number);
+ }
});
-enifed('container/container', ['exports', 'ember-utils', 'ember-environment', 'ember-metal'], function (exports, _emberUtils, _emberEnvironment, _emberMetal) {
+enifed('container/container', ['exports', 'ember-environment', 'ember-metal/debug', 'ember-metal/dictionary', 'container/owner', 'ember-runtime/mixins/container_proxy', 'ember-metal/symbol'], function (exports, _emberEnvironment, _emberMetalDebug, _emberMetalDictionary, _containerOwner, _emberRuntimeMixinsContainer_proxy, _emberMetalSymbol) {
'use strict';
exports.default = Container;
- exports.buildFakeContainerWithDeprecations = buildFakeContainerWithDeprecations;
- var CONTAINER_OVERRIDE = _emberUtils.symbol('CONTAINER_OVERRIDE');
+ var CONTAINER_OVERRIDE = _emberMetalSymbol.default('CONTAINER_OVERRIDE');
/**
A container used to instantiate and cache objects.
Every `Container` must be associated with a `Registry`, which is referenced
@@ -1212,14 +1175,14 @@
*/
function Container(registry, options) {
this.registry = registry;
this.owner = options && options.owner ? options.owner : null;
- this.cache = _emberUtils.dictionary(options && options.cache ? options.cache : null);
- this.factoryCache = _emberUtils.dictionary(options && options.factoryCache ? options.factoryCache : null);
- this.validationCache = _emberUtils.dictionary(options && options.validationCache ? options.validationCache : null);
- this._fakeContainerToInject = buildFakeContainerWithDeprecations(this);
+ this.cache = _emberMetalDictionary.default(options && options.cache ? options.cache : null);
+ this.factoryCache = _emberMetalDictionary.default(options && options.factoryCache ? options.factoryCache : null);
+ this.validationCache = _emberMetalDictionary.default(options && options.validationCache ? options.validationCache : null);
+ this._fakeContainerToInject = _emberRuntimeMixinsContainer_proxy.buildFakeContainerWithDeprecations(this);
this[CONTAINER_OVERRIDE] = undefined;
this.isDestroyed = false;
}
Container.prototype = {
@@ -1290,11 +1253,11 @@
@param {Object} [options]
@param {String} [options.source] The fullname of the request source (used for local lookup)
@return {any}
*/
lookup: function (fullName, options) {
- _emberMetal.assert('fullName must be a proper full name', this.registry.validateFullName(fullName));
+ _emberMetalDebug.assert('fullName must be a proper full name', this.registry.validateFullName(fullName));
return lookup(this, this.registry.normalize(fullName), options);
},
/**
Given a fullName, return the corresponding factory.
@@ -1304,11 +1267,11 @@
@param {Object} [options]
@param {String} [options.source] The fullname of the request source (used for local lookup)
@return {any}
*/
lookupFactory: function (fullName, options) {
- _emberMetal.assert('fullName must be a proper full name', this.registry.validateFullName(fullName));
+ _emberMetalDebug.assert('fullName must be a proper full name', this.registry.validateFullName(fullName));
return factoryFor(this, this.registry.normalize(fullName), options);
},
/**
A depth first traversal, destroying the container, its descendant containers and all
@@ -1348,11 +1311,11 @@
@returns { Object }
*/
ownerInjection: function () {
var _ref;
- return _ref = {}, _ref[_emberUtils.OWNER] = this.owner, _ref;
+ return _ref = {}, _ref[_containerOwner.OWNER] = this.owner, _ref;
}
};
function isSingleton(container, fullName) {
return container.registry.getOption(fullName, 'singleton') !== false;
@@ -1487,11 +1450,11 @@
var type = splitName[0];
var injections = buildInjections(container, registry.getTypeInjections(type), registry.getInjections(fullName));
injections._debugContainerKey = fullName;
- _emberUtils.setOwner(injections, container.owner);
+ _containerOwner.setOwner(injections, container.owner);
return injections;
}
function factoryInjectionsFor(container, fullName) {
@@ -1519,11 +1482,11 @@
throw new Error('Failed to create an instance of \'' + fullName + '\'. Most likely an improperly defined class or' + ' an invalid module export.');
}
validationCache = container.validationCache;
- _emberMetal.runInDebug(function () {
+ _emberMetalDebug.runInDebug(function () {
// Ensure that all lazy injections are valid at instantiation time
if (!validationCache[fullName] && typeof factory._lazyInjections === 'function') {
lazyInjections = factory._lazyInjections();
lazyInjections = container.registry.normalizeInjectionsHash(lazyInjections);
@@ -1565,16 +1528,16 @@
function injectDeprecatedContainer(object, container) {
Object.defineProperty(object, 'container', {
configurable: true,
enumerable: false,
get: function () {
- _emberMetal.deprecate('Using the injected `container` is deprecated. Please use the `getOwner` helper instead to access the owner of this object.', false, { id: 'ember-application.injected-container', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_injected-container-access' });
+ _emberMetalDebug.deprecate('Using the injected `container` is deprecated. Please use the `getOwner` helper instead to access the owner of this object.', false, { id: 'ember-application.injected-container', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_injected-container-access' });
return this[CONTAINER_OVERRIDE] || container;
},
set: function (value) {
- _emberMetal.deprecate('Providing the `container` property to ' + this + ' is deprecated. Please use `Ember.setOwner` or `owner.ownerInjection()` instead to provide an owner to the instance being created.', false, { id: 'ember-application.injected-container', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_injected-container-access' });
+ _emberMetalDebug.deprecate('Providing the `container` property to ' + this + ' is deprecated. Please use `Ember.setOwner` or `owner.ownerInjection()` instead to provide an owner to the instance being created.', false, { id: 'ember-application.injected-container', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_injected-container-access' });
this[CONTAINER_OVERRIDE] = value;
return value;
}
@@ -1600,11 +1563,11 @@
if (value.destroy) {
value.destroy();
}
});
- container.cache.dict = _emberUtils.dictionary(null);
+ container.cache.dict = _emberMetalDictionary.default(null);
}
function resetMember(container, fullName) {
var member = container.cache[fullName];
@@ -1616,54 +1579,103 @@
if (member.destroy) {
member.destroy();
}
}
}
-
- function buildFakeContainerWithDeprecations(container) {
- var fakeContainer = {};
- var propertyMappings = {
- lookup: 'lookup',
- lookupFactory: '_lookupFactory'
- };
-
- for (var containerProperty in propertyMappings) {
- fakeContainer[containerProperty] = buildFakeContainerFunction(container, containerProperty, propertyMappings[containerProperty]);
- }
-
- return fakeContainer;
- }
-
- function buildFakeContainerFunction(container, containerProperty, ownerProperty) {
- return function () {
- _emberMetal.deprecate('Using the injected `container` is deprecated. Please use the `getOwner` helper to access the owner of this object and then call `' + ownerProperty + '` instead.', false, {
- id: 'ember-application.injected-container',
- until: '3.0.0',
- url: 'http://emberjs.com/deprecations/v2.x#toc_injected-container-access'
- });
- return container[containerProperty].apply(container, arguments);
- };
- }
});
-enifed('container/index', ['exports', 'container/registry', 'container/container'], function (exports, _containerRegistry, _containerContainer) {
+enifed('container/index', ['exports', 'container/registry', 'container/container', 'container/owner'], function (exports, _containerRegistry, _containerContainer, _containerOwner) {
/*
Public API for the container is still in flux.
The public API, specified on the application namespace should be considered the stable API.
// @module container
@private
*/
'use strict';
exports.Registry = _containerRegistry.default;
- exports.privatize = _containerRegistry.privatize;
exports.Container = _containerContainer.default;
- exports.buildFakeContainerWithDeprecations = _containerContainer.buildFakeContainerWithDeprecations;
+ exports.getOwner = _containerOwner.getOwner;
+ exports.setOwner = _containerOwner.setOwner;
});
-enifed('container/registry', ['exports', 'ember-utils', 'ember-metal', 'container/container'], function (exports, _emberUtils, _emberMetal, _containerContainer) {
+enifed('container/owner', ['exports', 'ember-metal/symbol'], function (exports, _emberMetalSymbol) {
+ /**
+ @module ember
+ @submodule ember-runtime
+ */
+
'use strict';
+ exports.getOwner = getOwner;
+ exports.setOwner = setOwner;
+ var OWNER = _emberMetalSymbol.default('OWNER');
+
+ exports.OWNER = OWNER;
+ /**
+ Framework objects in an Ember application (components, services, routes, etc.)
+ are created via a factory and dependency injection system. Each of these
+ objects is the responsibility of an "owner", which handled its
+ instantiation and manages its lifetime.
+
+ `getOwner` fetches the owner object responsible for an instance. This can
+ be used to lookup or resolve other class instances, or register new factories
+ into the owner.
+
+ For example, this component dynamically looks up a service based on the
+ `audioType` passed as an attribute:
+
+ ```
+ // app/components/play-audio.js
+ import Ember from 'ember';
+
+ // Usage:
+ //
+ // {{play-audio audioType=model.audioType audioFile=model.file}}
+ //
+ export default Ember.Component.extend({
+ audioService: Ember.computed('audioType', function() {
+ let owner = Ember.getOwner(this);
+ return owner.lookup(`service:${this.get('audioType')}`);
+ }),
+ click() {
+ let player = this.get('audioService');
+ player.play(this.get('audioFile'));
+ }
+ });
+ ```
+
+ @method getOwner
+ @for Ember
+ @param {Object} object An object with an owner.
+ @return {Object} An owner object.
+ @since 2.3.0
+ @public
+ */
+
+ function getOwner(object) {
+ return object[OWNER];
+ }
+
+ /**
+ `setOwner` forces a new owner on a given object instance. This is primarily
+ useful in some testing cases.
+
+ @method setOwner
+ @for Ember
+ @param {Object} object An object with an owner.
+ @return {Object} An owner object.
+ @since 2.3.0
+ @public
+ */
+
+ function setOwner(object, owner) {
+ object[OWNER] = owner;
+ }
+});
+enifed('container/registry', ['exports', 'ember-metal/debug', 'ember-metal/dictionary', 'ember-metal/empty_object', 'ember-metal/assign', 'container/container', 'ember-metal/utils'], function (exports, _emberMetalDebug, _emberMetalDictionary, _emberMetalEmpty_object, _emberMetalAssign, _containerContainer, _emberMetalUtils) {
+ 'use strict';
+
exports.default = Registry;
exports.privatize = privatize;
var VALID_FULL_NAME_REGEXP = /^[^:]+:[^:]+$/;
@@ -1690,24 +1702,24 @@
if (typeof this.resolver === 'function') {
deprecateResolverFunction(this);
}
}
- this.registrations = _emberUtils.dictionary(options && options.registrations ? options.registrations : null);
+ this.registrations = _emberMetalDictionary.default(options && options.registrations ? options.registrations : null);
- this._typeInjections = _emberUtils.dictionary(null);
- this._injections = _emberUtils.dictionary(null);
- this._factoryTypeInjections = _emberUtils.dictionary(null);
- this._factoryInjections = _emberUtils.dictionary(null);
+ this._typeInjections = _emberMetalDictionary.default(null);
+ this._injections = _emberMetalDictionary.default(null);
+ this._factoryTypeInjections = _emberMetalDictionary.default(null);
+ this._factoryInjections = _emberMetalDictionary.default(null);
- this._localLookupCache = new _emberUtils.EmptyObject();
- this._normalizeCache = _emberUtils.dictionary(null);
- this._resolveCache = _emberUtils.dictionary(null);
- this._failCache = _emberUtils.dictionary(null);
+ this._localLookupCache = new _emberMetalEmpty_object.default();
+ this._normalizeCache = _emberMetalDictionary.default(null);
+ this._resolveCache = _emberMetalDictionary.default(null);
+ this._failCache = _emberMetalDictionary.default(null);
- this._options = _emberUtils.dictionary(null);
- this._typeOptions = _emberUtils.dictionary(null);
+ this._options = _emberMetalDictionary.default(null);
+ this._typeOptions = _emberMetalDictionary.default(null);
}
Registry.prototype = {
/**
A backup registry for resolving registrations when no matches can be found.
@@ -1815,11 +1827,11 @@
@param {Object} options
*/
register: function (fullName, factory) {
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
- _emberMetal.assert('fullName must be a proper full name', this.validateFullName(fullName));
+ _emberMetalDebug.assert('fullName must be a proper full name', this.validateFullName(fullName));
if (factory === undefined) {
throw new TypeError('Attempting to register an unknown factory: \'' + fullName + '\'');
}
@@ -1846,15 +1858,15 @@
@private
@method unregister
@param {String} fullName
*/
unregister: function (fullName) {
- _emberMetal.assert('fullName must be a proper full name', this.validateFullName(fullName));
+ _emberMetalDebug.assert('fullName must be a proper full name', this.validateFullName(fullName));
var normalizedName = this.normalize(fullName);
- this._localLookupCache = new _emberUtils.EmptyObject();
+ this._localLookupCache = new _emberMetalEmpty_object.default();
delete this.registrations[normalizedName];
delete this._resolveCache[normalizedName];
delete this._failCache[normalizedName];
delete this._options[normalizedName];
@@ -1887,11 +1899,11 @@
@param {Object} [options]
@param {String} [options.source] the fullname of the request source (used for local lookups)
@return {Function} fullName's factory
*/
resolve: function (fullName, options) {
- _emberMetal.assert('fullName must be a proper full name', this.validateFullName(fullName));
+ _emberMetalDebug.assert('fullName must be a proper full name', this.validateFullName(fullName));
var factory = resolve(this, this.normalize(fullName), options);
if (factory === undefined && this.fallback) {
var _fallback;
factory = (_fallback = this.fallback).resolve.apply(_fallback, arguments);
@@ -2084,11 +2096,11 @@
@param {String} type
@param {String} property
@param {String} fullName
*/
typeInjection: function (type, property, fullName) {
- _emberMetal.assert('fullName must be a proper full name', this.validateFullName(fullName));
+ _emberMetalDebug.assert('fullName must be a proper full name', this.validateFullName(fullName));
var fullNameType = fullName.split(':')[0];
if (fullNameType === type) {
throw new Error('Cannot inject a \'' + fullName + '\' on other ' + type + '(s).');
}
@@ -2140,11 +2152,11 @@
if (fullName.indexOf(':') === -1) {
return this.typeInjection(fullName, property, normalizedInjectionName);
}
- _emberMetal.assert('fullName must be a proper full name', this.validateFullName(fullName));
+ _emberMetalDebug.assert('fullName must be a proper full name', this.validateFullName(fullName));
var normalizedName = this.normalize(fullName);
var injections = this._injections[normalizedName] || (this._injections[normalizedName] = []);
injections.push({
@@ -2245,11 +2257,11 @@
*/
knownForType: function (type) {
var fallbackKnown = undefined,
resolverKnown = undefined;
- var localKnown = _emberUtils.dictionary(null);
+ var localKnown = _emberMetalDictionary.default(null);
var registeredNames = Object.keys(this.registrations);
for (var index = 0; index < registeredNames.length; index++) {
var fullName = registeredNames[index];
var itemType = fullName.split(':')[0];
@@ -2264,11 +2276,11 @@
if (this.resolver && this.resolver.knownForType) {
resolverKnown = this.resolver.knownForType(type);
}
- return _emberUtils.assign({}, fallbackKnown, localKnown, resolverKnown);
+ return _emberMetalAssign.default({}, fallbackKnown, localKnown, resolverKnown);
},
validateFullName: function (fullName) {
if (!this.isValidFullName(fullName)) {
throw new TypeError('Invalid Fullname, expected: \'type:name\' got: ' + fullName);
@@ -2300,11 +2312,11 @@
normalizeInjectionsHash: function (hash) {
var injections = [];
for (var key in hash) {
if (hash.hasOwnProperty(key)) {
- _emberMetal.assert('Expected a proper full name, given \'' + hash[key] + '\'', this.validateFullName(hash[key]));
+ _emberMetalDebug.assert('Expected a proper full name, given \'' + hash[key] + '\'', this.validateFullName(hash[key]));
injections.push({
property: key,
fullName: hash[key]
});
@@ -2346,11 +2358,11 @@
return injections;
}
};
function deprecateResolverFunction(registry) {
- _emberMetal.deprecate('Passing a `resolver` function into a Registry is deprecated. Please pass in a Resolver object with a `resolve` method.', false, { id: 'ember-application.registry-resolver-as-function', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_registry-resolver-as-function' });
+ _emberMetalDebug.deprecate('Passing a `resolver` function into a Registry is deprecated. Please pass in a Resolver object with a `resolve` method.', false, { id: 'ember-application.registry-resolver-as-function', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_registry-resolver-as-function' });
registry.resolver = {
resolve: registry.resolver
};
}
@@ -2372,13 +2384,13 @@
@param {String} [options.source] the fullname of the request source (used for local lookups)
@return {String} fullName
*/
Registry.prototype.expandLocalLookup = function Registry_expandLocalLookup(fullName, options) {
if (this.resolver && this.resolver.expandLocalLookup) {
- _emberMetal.assert('fullName must be a proper full name', this.validateFullName(fullName));
- _emberMetal.assert('options.source must be provided to expandLocalLookup', options && options.source);
- _emberMetal.assert('options.source must be a proper full name', this.validateFullName(options.source));
+ _emberMetalDebug.assert('fullName must be a proper full name', this.validateFullName(fullName));
+ _emberMetalDebug.assert('options.source must be provided to expandLocalLookup', options && options.source);
+ _emberMetalDebug.assert('options.source must be a proper full name', this.validateFullName(options.source));
var normalizedFullName = this.normalize(fullName);
var normalizedSource = this.normalize(options.source);
return expandLocalLookup(this, normalizedFullName, normalizedSource);
@@ -2392,11 +2404,11 @@
function expandLocalLookup(registry, normalizedName, normalizedSource) {
var cache = registry._localLookupCache;
var normalizedNameCache = cache[normalizedName];
if (!normalizedNameCache) {
- normalizedNameCache = cache[normalizedName] = new _emberUtils.EmptyObject();
+ normalizedNameCache = cache[normalizedName] = new _emberMetalEmpty_object.default();
}
var cached = normalizedNameCache[normalizedSource];
if (cached !== undefined) {
@@ -2449,11 +2461,11 @@
function has(registry, fullName, source) {
return registry.resolve(fullName, { source: source }) !== undefined;
}
- var privateNames = _emberUtils.dictionary(null);
+ var privateNames = _emberMetalDictionary.default(null);
var privateSuffix = '' + Math.random() + Date.now();
function privatize(_ref) {
var fullName = _ref[0];
@@ -2465,11 +2477,11 @@
var _fullName$split = fullName.split(':');
var type = _fullName$split[0];
var rawName = _fullName$split[1];
- return privateNames[fullName] = _emberUtils.intern(type + ':' + rawName + '-' + privateSuffix);
+ return privateNames[fullName] = _emberMetalUtils.intern(type + ':' + rawName + '-' + privateSuffix);
}
});
enifed('ember-console/index', ['exports', 'ember-environment'], function (exports, _emberEnvironment) {
'use strict';
@@ -2780,11 +2792,11 @@
Function: defaultTrue(obj.Function)
};
}
}
});
-enifed('ember-metal/alias', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/error', 'ember-metal/properties', 'ember-metal/computed', 'ember-metal/meta', 'ember-metal/dependent_keys'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalError, _emberMetalProperties, _emberMetalComputed, _emberMetalMeta, _emberMetalDependent_keys) {
+enifed('ember-metal/alias', ['exports', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/error', 'ember-metal/properties', 'ember-metal/computed', 'ember-metal/utils', 'ember-metal/meta', 'ember-metal/dependent_keys'], function (exports, _emberMetalDebug, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalError, _emberMetalProperties, _emberMetalComputed, _emberMetalUtils, _emberMetalMeta, _emberMetalDependent_keys) {
'use strict';
exports.default = alias;
exports.AliasedProperty = AliasedProperty;
@@ -2798,53 +2810,48 @@
this._dependentKeys = [altKey];
}
AliasedProperty.prototype = Object.create(_emberMetalProperties.Descriptor.prototype);
- AliasedProperty.prototype.setup = function (obj, keyName) {
- _emberMetalDebug.assert('Setting alias \'' + keyName + '\' on self', this.altKey !== keyName);
- var meta = _emberMetalMeta.meta(obj);
- if (meta.peekWatching(keyName)) {
- _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta);
- }
+ AliasedProperty.prototype.get = function AliasedProperty_get(obj, keyName) {
+ return _emberMetalProperty_get.get(obj, this.altKey);
};
- AliasedProperty.prototype._addDependentKeyIfMissing = function (obj, keyName) {
- var meta = _emberMetalMeta.meta(obj);
- if (!meta.peekDeps(this.altKey, keyName)) {
- _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, meta);
- }
+ AliasedProperty.prototype.set = function AliasedProperty_set(obj, keyName, value) {
+ return _emberMetalProperty_set.set(obj, this.altKey, value);
};
- AliasedProperty.prototype._removeDependentKeyIfAdded = function (obj, keyName) {
- var meta = _emberMetalMeta.meta(obj);
- if (meta.peekDeps(this.altKey, keyName)) {
- _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, meta);
- }
+ AliasedProperty.prototype.willWatch = function (obj, keyName) {
+ _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, _emberMetalMeta.meta(obj));
};
- AliasedProperty.prototype.willWatch = AliasedProperty.prototype._addDependentKeyIfMissing;
- AliasedProperty.prototype.didUnwatch = AliasedProperty.prototype._removeDependentKeyIfAdded;
- AliasedProperty.prototype.teardown = AliasedProperty.prototype._removeDependentKeyIfAdded;
+ AliasedProperty.prototype.didUnwatch = function (obj, keyName) {
+ _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, _emberMetalMeta.meta(obj));
+ };
- AliasedProperty.prototype.get = function AliasedProperty_get(obj, keyName) {
- this._addDependentKeyIfMissing(obj, keyName);
-
- return _emberMetalProperty_get.get(obj, this.altKey);
+ AliasedProperty.prototype.setup = function (obj, keyName) {
+ _emberMetalDebug.assert('Setting alias \'' + keyName + '\' on self', this.altKey !== keyName);
+ var m = _emberMetalMeta.meta(obj);
+ if (m.peekWatching(keyName)) {
+ _emberMetalDependent_keys.addDependentKeys(this, obj, keyName, m);
+ }
};
- AliasedProperty.prototype.set = function AliasedProperty_set(obj, keyName, value) {
- return _emberMetalProperty_set.set(obj, this.altKey, value);
+ AliasedProperty.prototype.teardown = function (obj, keyName) {
+ var m = _emberMetalMeta.meta(obj);
+ if (m.peekWatching(keyName)) {
+ _emberMetalDependent_keys.removeDependentKeys(this, obj, keyName, m);
+ }
};
AliasedProperty.prototype.readOnly = function () {
this.set = AliasedProperty_readOnlySet;
return this;
};
function AliasedProperty_readOnlySet(obj, keyName, value) {
- throw new _emberMetalError.default('Cannot set read-only property \'' + keyName + '\' on object: ' + _emberUtils.inspect(obj));
+ throw new _emberMetalError.default('Cannot set read-only property \'' + keyName + '\' on object: ' + _emberMetalUtils.inspect(obj));
}
AliasedProperty.prototype.oneWay = function () {
this.set = AliasedProperty_oneWaySet;
return this;
@@ -2857,11 +2864,55 @@
// Backwards compatibility with Ember Data.
AliasedProperty.prototype._meta = undefined;
AliasedProperty.prototype.meta = _emberMetalComputed.ComputedProperty.prototype.meta;
});
-enifed('ember-metal/binding', ['exports', 'ember-utils', 'ember-console', 'ember-environment', 'ember-metal/run_loop', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/events', 'ember-metal/observer', 'ember-metal/path_cache'], function (exports, _emberUtils, _emberConsole, _emberEnvironment, _emberMetalRun_loop, _emberMetalDebug, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalEvents, _emberMetalObserver, _emberMetalPath_cache) {
+enifed("ember-metal/assign", ["exports"], function (exports) {
+ /**
+ Copy properties from a source object to a target object.
+
+ ```javascript
+ var a = { first: 'Yehuda' };
+ var b = { last: 'Katz' };
+ var c = { company: 'Tilde Inc.' };
+ Ember.assign(a, b, c); // a === { first: 'Yehuda', last: 'Katz', company: 'Tilde Inc.' }, b === { last: 'Katz' }, c === { company: 'Tilde Inc.' }
+ ```
+
+ @method assign
+ @for Ember
+ @param {Object} original The object to assign into
+ @param {Object} ...args The objects to copy properties from
+ @return {Object}
+ @public
+ */
+ "use strict";
+
+ exports.default = assign;
+
+ function assign(original) {
+ for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
+ args[_key - 1] = arguments[_key];
+ }
+
+ for (var i = 0; i < args.length; i++) {
+ var arg = args[i];
+ if (!arg) {
+ continue;
+ }
+
+ var updates = Object.keys(arg);
+
+ for (var _i = 0; _i < updates.length; _i++) {
+ var prop = updates[_i];
+ original[prop] = arg[prop];
+ }
+ }
+
+ return original;
+ }
+});
+enifed('ember-metal/binding', ['exports', 'ember-console', 'ember-environment', 'ember-metal/run_loop', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/utils', 'ember-metal/events', 'ember-metal/observer', 'ember-metal/path_cache'], function (exports, _emberConsole, _emberEnvironment, _emberMetalRun_loop, _emberMetalDebug, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalUtils, _emberMetalEvents, _emberMetalObserver, _emberMetalPath_cache) {
'use strict';
exports.bind = bind;
/**
@@ -2966,11 +3017,11 @@
@return {String} string representation of binding
@public
*/
toString: function () {
var oneWay = this._oneWay ? '[oneWay]' : '';
- return 'Ember.Binding<' + _emberUtils.guidFor(this) + '>(' + this._from + ' -> ' + this._to + ')' + oneWay;
+ return 'Ember.Binding<' + _emberMetalUtils.guidFor(this) + '>(' + this._from + ' -> ' + this._to + ')' + oneWay;
},
// ..........................................................
// CONNECT AND SYNC
//
@@ -3333,15 +3384,19 @@
return new Binding(to, from).connect(obj);
}
exports.Binding = Binding;
});
-enifed('ember-metal/cache', ['exports', 'ember-utils'], function (exports, _emberUtils) {
+enifed('ember-metal/cache', ['exports', 'ember-metal/empty_object'], function (exports, _emberMetalEmpty_object) {
'use strict';
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
+
var Cache = (function () {
function Cache(limit, func, key, store) {
+ _classCallCheck(this, Cache);
+
this.size = 0;
this.misses = 0;
this.hits = 0;
this.limit = limit;
this.func = func;
@@ -3398,11 +3453,13 @@
function UNDEFINED() {}
var DefaultStore = (function () {
function DefaultStore() {
- this.data = new _emberUtils.EmptyObject();
+ _classCallCheck(this, DefaultStore);
+
+ this.data = new _emberMetalEmpty_object.default();
}
DefaultStore.prototype.get = function get(key) {
return this.data[key];
};
@@ -3410,17 +3467,17 @@
DefaultStore.prototype.set = function set(key, value) {
this.data[key] = value;
};
DefaultStore.prototype.clear = function clear() {
- this.data = new _emberUtils.EmptyObject();
+ this.data = new _emberMetalEmpty_object.default();
};
return DefaultStore;
})();
});
-enifed('ember-metal/chains', ['exports', 'ember-utils', 'ember-metal/property_get', 'ember-metal/meta', 'ember-metal/watch_key', 'ember-metal/watch_path'], function (exports, _emberUtils, _emberMetalProperty_get, _emberMetalMeta, _emberMetalWatch_key, _emberMetalWatch_path) {
+enifed('ember-metal/chains', ['exports', 'ember-metal/property_get', 'ember-metal/meta', 'ember-metal/watch_key', 'ember-metal/empty_object', 'ember-metal/watch_path'], function (exports, _emberMetalProperty_get, _emberMetalMeta, _emberMetalWatch_key, _emberMetalEmpty_object, _emberMetalWatch_path) {
'use strict';
exports.finishChains = finishChains;
var FIRST_KEY = /^([^\.]+)/;
@@ -3428,22 +3485,22 @@
function firstKey(path) {
return path.match(FIRST_KEY)[0];
}
function isObject(obj) {
- return typeof obj === 'object' && obj;
+ return obj && typeof obj === 'object';
}
function isVolatile(obj) {
return !(isObject(obj) && obj.isDescriptor && obj._volatile === false);
}
function ChainWatchers() {
// chain nodes that reference a key in this obj by key
// we only create ChainWatchers when we are going to add them
// so create this upfront
- this.chains = new _emberUtils.EmptyObject();
+ this.chains = new _emberMetalEmpty_object.default();
}
ChainWatchers.prototype = {
add: function (key, node) {
var nodes = this.chains[key];
@@ -3671,11 +3728,11 @@
chain: function (key, path) {
var chains = this._chains;
var node = undefined;
if (chains === undefined) {
- chains = this._chains = new _emberUtils.EmptyObject();
+ chains = this._chains = new _emberMetalEmpty_object.default();
} else {
node = chains[key];
}
if (node === undefined) {
@@ -3774,11 +3831,11 @@
}
exports.removeChainWatcher = removeChainWatcher;
exports.ChainNode = ChainNode;
});
-enifed('ember-metal/computed', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/property_set', 'ember-metal/meta', 'ember-metal/expand_properties', 'ember-metal/error', 'ember-metal/properties', 'ember-metal/property_events', 'ember-metal/dependent_keys'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalProperty_set, _emberMetalMeta, _emberMetalExpand_properties, _emberMetalError, _emberMetalProperties, _emberMetalProperty_events, _emberMetalDependent_keys) {
+enifed('ember-metal/computed', ['exports', 'ember-metal/debug', 'ember-metal/property_set', 'ember-metal/utils', 'ember-metal/meta', 'ember-metal/expand_properties', 'ember-metal/error', 'ember-metal/properties', 'ember-metal/property_events', 'ember-metal/dependent_keys'], function (exports, _emberMetalDebug, _emberMetalProperty_set, _emberMetalUtils, _emberMetalMeta, _emberMetalExpand_properties, _emberMetalError, _emberMetalProperties, _emberMetalProperty_events, _emberMetalDependent_keys) {
'use strict';
exports.default = computed;
/**
@@ -4125,11 +4182,11 @@
return this.setWithSuspend(obj, keyName, value);
};
ComputedPropertyPrototype._throwReadOnlyError = function computedPropertyThrowReadOnlyError(obj, keyName) {
- throw new _emberMetalError.default('Cannot set read-only property "' + keyName + '" on object: ' + _emberUtils.inspect(obj));
+ throw new _emberMetalError.default('Cannot set read-only property "' + keyName + '" on object: ' + _emberMetalUtils.inspect(obj));
};
ComputedPropertyPrototype.clobberSet = function computedPropertyClobberSet(obj, keyName, value) {
var cachedValue = cacheFor(obj, keyName);
_emberMetalProperties.defineProperty(obj, keyName, null, cachedValue);
@@ -4383,10 +4440,11 @@
*/
var Ember = typeof _emberEnvironment.context.imports.Ember === 'object' && _emberEnvironment.context.imports.Ember || {};
// Make sure these are set whether Ember was already defined or not
Ember.isNamespace = true;
+
Ember.toString = function () {
return 'Ember';
};
// ..........................................................
@@ -4559,80 +4617,89 @@
return _emberMetalProperty_get.get(this, newKey);
}
});
}
});
-enifed('ember-metal/descriptor', ['exports', 'ember-metal/properties'], function (exports, _emberMetalProperties) {
+enifed('ember-metal/dictionary', ['exports', 'ember-metal/empty_object'], function (exports, _emberMetalEmpty_object) {
'use strict';
- exports.default = descriptor;
+ exports.default = makeDictionary;
- function descriptor(desc) {
- return new Descriptor(desc);
+ // the delete is meant to hint at runtimes that this object should remain in
+ // dictionary mode. This is clearly a runtime specific hack, but currently it
+ // appears worthwhile in some usecases. Please note, these deletes do increase
+ // the cost of creation dramatically over a plain Object.create. And as this
+ // only makes sense for long-lived dictionaries that aren't instantiated often.
+
+ function makeDictionary(parent) {
+ var dict = undefined;
+ if (parent === null) {
+ dict = new _emberMetalEmpty_object.default();
+ } else {
+ dict = Object.create(parent);
+ }
+ dict['_dict'] = null;
+ delete dict['_dict'];
+ return dict;
}
+});
+enifed("ember-metal/empty_object", ["exports"], function (exports) {
+ // This exists because `Object.create(null)` is absurdly slow compared
+ // to `new EmptyObject()`. In either case, you want a null prototype
+ // when you're treating the object instances as arbitrary dictionaries
+ // and don't want your keys colliding with build-in methods on the
+ // default object prototype.
- /**
- A wrapper for a native ES5 descriptor. In an ideal world, we wouldn't need
- this at all, however, the way we currently flatten/merge our mixins require
- a special value to denote a descriptor.
-
- @class Descriptor
- @private
- */
+ "use strict";
- var Descriptor = (function (_EmberDescriptor) {
- babelHelpers.inherits(Descriptor, _EmberDescriptor);
-
- function Descriptor(desc) {
- _EmberDescriptor.call(this);
- this.desc = desc;
+ var proto = Object.create(null, {
+ // without this, we will always still end up with (new
+ // EmptyObject()).constructor === Object
+ constructor: {
+ value: undefined,
+ enumerable: false,
+ writable: true
}
+ });
- Descriptor.prototype.setup = function setup(obj, key) {
- Object.defineProperty(obj, key, this.desc);
- };
-
- Descriptor.prototype.teardown = function teardown(obj, key) {};
-
- return Descriptor;
- })(_emberMetalProperties.Descriptor);
+ function EmptyObject() {}
+ EmptyObject.prototype = proto;
+ exports.default = EmptyObject;
});
-enifed("ember-metal/error", ["exports"], function (exports) {
+enifed('ember-metal/error', ['exports'], function (exports) {
+ 'use strict';
+ exports.default = EmberError;
+ var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack'];
+
/**
A subclass of the JavaScript Error object for use in Ember.
@class Error
@namespace Ember
@extends Error
@constructor
@public
*/
- "use strict";
- exports.default = EmberError;
+ function EmberError() {
+ var tmp = Error.apply(this, arguments);
- function EmberError(message) {
- if (!(this instanceof EmberError)) {
- return new EmberError(message);
- }
-
- var error = Error.call(this, message);
-
+ // Adds a `stack` property to the given error object that will yield the
+ // stack trace at the time captureStackTrace was called.
+ // When collecting the stack trace all frames above the topmost call
+ // to this function, including that call, will be left out of the
+ // stack trace.
+ // This is useful because we can hide Ember implementation details
+ // that are not very helpful for the user.
if (Error.captureStackTrace) {
Error.captureStackTrace(this, EmberError);
- } else {
- this.stack = error.stack;
}
-
- this.description = error.description;
- this.fileName = error.fileName;
- this.lineNumber = error.lineNumber;
- this.message = error.message;
- this.name = error.name;
- this.number = error.number;
- this.code = error.code;
+ // Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work.
+ for (var idx = 0; idx < errorProps.length; idx++) {
+ this[errorProps[idx]] = tmp[errorProps[idx]];
+ }
}
EmberError.prototype = Object.create(Error.prototype);
});
enifed('ember-metal/error_handler', ['exports', 'ember-console', 'ember-metal/testing'], function (exports, _emberConsole, _emberMetalTesting) {
@@ -4694,11 +4761,11 @@
} else {
_emberConsole.default.error(getStack(error));
}
}
});
-enifed('ember-metal/events', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/meta', 'ember-metal/meta_listeners'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalMeta, _emberMetalMeta_listeners) {
+enifed('ember-metal/events', ['exports', 'ember-metal/debug', 'ember-metal/utils', 'ember-metal/meta', 'ember-metal/meta_listeners'], function (exports, _emberMetalDebug, _emberMetalUtils, _emberMetalMeta, _emberMetalMeta_listeners) {
'no use strict';
// Remove "use strict"; from transpiled module until
// https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed
/**
@@ -4941,11 +5008,11 @@
if (!target) {
target = obj;
}
if ('string' === typeof method) {
if (params) {
- _emberUtils.applyStr(target, method, params);
+ _emberMetalUtils.applyStr(target, method, params);
} else {
target[method]();
}
} else {
if (params) {
@@ -5108,11 +5175,11 @@
});
return all;
}
});
-enifed('ember-metal/features', ['exports', 'ember-utils', 'ember-environment', 'ember/features'], function (exports, _emberUtils, _emberEnvironment, _emberFeatures) {
+enifed('ember-metal/features', ['exports', 'ember-environment', 'ember-metal/assign', 'ember/features'], function (exports, _emberEnvironment, _emberMetalAssign, _emberFeatures) {
'use strict';
exports.default = isEnabled;
/**
@@ -5126,11 +5193,11 @@
@namespace Ember
@static
@since 1.1.0
@public
*/
- var FEATURES = _emberUtils.assign(_emberFeatures.default, _emberEnvironment.ENV.FEATURES);
+ var FEATURES = _emberMetalAssign.default(_emberFeatures.default, _emberEnvironment.ENV.FEATURES);
exports.FEATURES = FEATURES;
/**
Determine whether the specified `feature` is enabled. Used by Ember's
build tools to exclude experimental features from beta/stable builds.
@@ -5204,146 +5271,331 @@
ret[propertyNames[i]] = _emberMetalProperty_get.get(obj, propertyNames[i]);
}
return ret;
}
});
-enifed('ember-metal/index', ['exports', 'require', 'ember-metal/core', 'ember-metal/computed', 'ember-metal/alias', 'ember-metal/merge', 'ember-metal/debug', 'ember-metal/instrumentation', 'ember-metal/testing', 'ember-metal/error_handler', 'ember-metal/meta', 'ember-metal/error', 'ember-metal/cache', 'ember-metal/features', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/weak_map', 'ember-metal/events', 'ember-metal/is_none', 'ember-metal/is_empty', 'ember-metal/is_blank', 'ember-metal/is_present', 'ember-metal/run_loop', 'ember-metal/observer_set', 'ember-metal/property_events', 'ember-metal/properties', 'ember-metal/watch_key', 'ember-metal/chains', 'ember-metal/watch_path', 'ember-metal/watching', 'ember-metal/libraries', 'ember-metal/map', 'ember-metal/get_properties', 'ember-metal/set_properties', 'ember-metal/expand_properties', 'ember-metal/observer', 'ember-metal/mixin', 'ember-metal/binding', 'ember-metal/path_cache', 'ember-metal/injected_property', 'ember-metal/tags', 'ember-metal/replace', 'ember-metal/transaction', 'ember-metal/descriptor'], function (exports, _require, _emberMetalCore, _emberMetalComputed, _emberMetalAlias, _emberMetalMerge, _emberMetalDebug, _emberMetalInstrumentation, _emberMetalTesting, _emberMetalError_handler, _emberMetalMeta, _emberMetalError, _emberMetalCache, _emberMetalFeatures, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalWeak_map, _emberMetalEvents, _emberMetalIs_none, _emberMetalIs_empty, _emberMetalIs_blank, _emberMetalIs_present, _emberMetalRun_loop, _emberMetalObserver_set, _emberMetalProperty_events, _emberMetalProperties, _emberMetalWatch_key, _emberMetalChains, _emberMetalWatch_path, _emberMetalWatching, _emberMetalLibraries, _emberMetalMap, _emberMetalGet_properties, _emberMetalSet_properties, _emberMetalExpand_properties, _emberMetalObserver, _emberMetalMixin, _emberMetalBinding, _emberMetalPath_cache, _emberMetalInjected_property, _emberMetalTags, _emberMetalReplace, _emberMetalTransaction, _emberMetalDescriptor) {
+enifed('ember-metal/index', ['exports', 'require', 'ember-environment', 'ember/version', 'ember-metal/core', 'ember-metal/debug', 'ember-metal/features', 'ember-metal/assign', 'ember-metal/merge', 'ember-metal/instrumentation', 'ember-metal/utils', 'ember-metal/meta', 'ember-metal/error', 'ember-metal/cache', 'ember-console', 'ember-metal/property_get', 'ember-metal/events', 'ember-metal/observer_set', 'ember-metal/property_events', 'ember-metal/properties', 'ember-metal/property_set', 'ember-metal/weak_map', 'ember-metal/map', 'ember-metal/get_properties', 'ember-metal/set_properties', 'ember-metal/watch_key', 'ember-metal/chains', 'ember-metal/watch_path', 'ember-metal/watching', 'ember-metal/expand_properties', 'ember-metal/computed', 'ember-metal/alias', 'ember-metal/observer', 'ember-metal/mixin', 'ember-metal/binding', 'ember-metal/path_cache', 'ember-metal/testing', 'ember-metal/error_handler', 'ember-metal/run_loop', 'ember-metal/libraries', 'ember-metal/is_none', 'ember-metal/is_empty', 'ember-metal/is_blank', 'ember-metal/is_present', 'backburner'], function (exports, _require, _emberEnvironment, _emberVersion, _emberMetalCore, _emberMetalDebug, _emberMetalFeatures, _emberMetalAssign, _emberMetalMerge, _emberMetalInstrumentation, _emberMetalUtils, _emberMetalMeta, _emberMetalError, _emberMetalCache, _emberConsole, _emberMetalProperty_get, _emberMetalEvents, _emberMetalObserver_set, _emberMetalProperty_events, _emberMetalProperties, _emberMetalProperty_set, _emberMetalWeak_map, _emberMetalMap, _emberMetalGet_properties, _emberMetalSet_properties, _emberMetalWatch_key, _emberMetalChains, _emberMetalWatch_path, _emberMetalWatching, _emberMetalExpand_properties, _emberMetalComputed, _emberMetalAlias, _emberMetalObserver, _emberMetalMixin, _emberMetalBinding, _emberMetalPath_cache, _emberMetalTesting, _emberMetalError_handler, _emberMetalRun_loop, _emberMetalLibraries, _emberMetalIs_none, _emberMetalIs_empty, _emberMetalIs_blank, _emberMetalIs_present, _backburner) {
/**
@module ember
@submodule ember-metal
*/
+ // BEGIN IMPORTS
'use strict';
- exports.default = _emberMetalCore.default;
- // reexports
- exports.computed = _emberMetalComputed.default;
- exports.cacheFor = _emberMetalComputed.cacheFor;
- exports.ComputedProperty = _emberMetalComputed.ComputedProperty;
- exports.alias = _emberMetalAlias.default;
- exports.merge = _emberMetalMerge.default;
- exports.assert = _emberMetalDebug.assert;
- exports.info = _emberMetalDebug.info;
- exports.warn = _emberMetalDebug.warn;
- exports.debug = _emberMetalDebug.debug;
- exports.deprecate = _emberMetalDebug.deprecate;
- exports.deprecateFunc = _emberMetalDebug.deprecateFunc;
- exports.runInDebug = _emberMetalDebug.runInDebug;
- exports.setDebugFunction = _emberMetalDebug.setDebugFunction;
- exports.getDebugFunction = _emberMetalDebug.getDebugFunction;
- exports.instrument = _emberMetalInstrumentation.instrument;
- exports.flaggedInstrument = _emberMetalInstrumentation.flaggedInstrument;
- exports._instrumentStart = _emberMetalInstrumentation._instrumentStart;
- exports.instrumentationReset = _emberMetalInstrumentation.reset;
- exports.instrumentationSubscribe = _emberMetalInstrumentation.subscribe;
- exports.instrumentationUnsubscribe = _emberMetalInstrumentation.unsubscribe;
- exports.isTesting = _emberMetalTesting.isTesting;
- exports.setTesting = _emberMetalTesting.setTesting;
- exports.getOnerror = _emberMetalError_handler.getOnerror;
- exports.setOnerror = _emberMetalError_handler.setOnerror;
- exports.dispatchError = _emberMetalError_handler.dispatchError;
- exports.setDispatchOverride = _emberMetalError_handler.setDispatchOverride;
- exports.META_DESC = _emberMetalMeta.META_DESC;
- exports.meta = _emberMetalMeta.meta;
- exports.peekMeta = _emberMetalMeta.peekMeta;
- exports.Error = _emberMetalError.default;
- exports.Cache = _emberMetalCache.default;
- exports.isFeatureEnabled = _emberMetalFeatures.default;
- exports.FEATURES = _emberMetalFeatures.FEATURES;
- exports.DEFAULT_FEATURES = _emberMetalFeatures.DEFAULT_FEATURES;
- exports._getPath = _emberMetalProperty_get._getPath;
- exports.get = _emberMetalProperty_get.get;
- exports.getWithDefault = _emberMetalProperty_get.getWithDefault;
- exports.set = _emberMetalProperty_set.set;
- exports.trySet = _emberMetalProperty_set.trySet;
- exports.WeakMap = _emberMetalWeak_map.default;
- exports.accumulateListeners = _emberMetalEvents.accumulateListeners;
- exports.addListener = _emberMetalEvents.addListener;
- exports.hasListeners = _emberMetalEvents.hasListeners;
- exports.listenersFor = _emberMetalEvents.listenersFor;
- exports.on = _emberMetalEvents.on;
- exports.removeListener = _emberMetalEvents.removeListener;
- exports.sendEvent = _emberMetalEvents.sendEvent;
- exports.suspendListener = _emberMetalEvents.suspendListener;
- exports.suspendListeners = _emberMetalEvents.suspendListeners;
- exports.watchedEvents = _emberMetalEvents.watchedEvents;
- exports.isNone = _emberMetalIs_none.default;
- exports.isEmpty = _emberMetalIs_empty.default;
- exports.isBlank = _emberMetalIs_blank.default;
- exports.isPresent = _emberMetalIs_present.default;
- exports.run = _emberMetalRun_loop.default;
- exports.ObserverSet = _emberMetalObserver_set.default;
- exports.beginPropertyChanges = _emberMetalProperty_events.beginPropertyChanges;
- exports.changeProperties = _emberMetalProperty_events.changeProperties;
- exports.endPropertyChanges = _emberMetalProperty_events.endPropertyChanges;
- exports.overrideChains = _emberMetalProperty_events.overrideChains;
- exports.propertyDidChange = _emberMetalProperty_events.propertyDidChange;
- exports.propertyWillChange = _emberMetalProperty_events.propertyWillChange;
- exports.PROPERTY_DID_CHANGE = _emberMetalProperty_events.PROPERTY_DID_CHANGE;
- exports.defineProperty = _emberMetalProperties.defineProperty;
- exports.Descriptor = _emberMetalProperties.Descriptor;
- exports.watchKey = _emberMetalWatch_key.watchKey;
- exports.unwatchKey = _emberMetalWatch_key.unwatchKey;
- exports.ChainNode = _emberMetalChains.ChainNode;
- exports.finishChains = _emberMetalChains.finishChains;
- exports.removeChainWatcher = _emberMetalChains.removeChainWatcher;
- exports.watchPath = _emberMetalWatch_path.watchPath;
- exports.unwatchPath = _emberMetalWatch_path.unwatchPath;
- exports.destroy = _emberMetalWatching.destroy;
- exports.isWatching = _emberMetalWatching.isWatching;
- exports.unwatch = _emberMetalWatching.unwatch;
- exports.watch = _emberMetalWatching.watch;
- exports.watcherCount = _emberMetalWatching.watcherCount;
- exports.libraries = _emberMetalLibraries.default;
- exports.Map = _emberMetalMap.Map;
- exports.MapWithDefault = _emberMetalMap.MapWithDefault;
- exports.OrderedSet = _emberMetalMap.OrderedSet;
- exports.getProperties = _emberMetalGet_properties.default;
- exports.setProperties = _emberMetalSet_properties.default;
- exports.expandProperties = _emberMetalExpand_properties.default;
- exports._suspendObserver = _emberMetalObserver._suspendObserver;
- exports._suspendObservers = _emberMetalObserver._suspendObservers;
- exports.addObserver = _emberMetalObserver.addObserver;
- exports.observersFor = _emberMetalObserver.observersFor;
- exports.removeObserver = _emberMetalObserver.removeObserver;
- exports._addBeforeObserver = _emberMetalObserver._addBeforeObserver;
- exports._removeBeforeObserver = _emberMetalObserver._removeBeforeObserver;
- exports.NAME_KEY = _emberMetalMixin.NAME_KEY;
- exports.Mixin = _emberMetalMixin.Mixin;
- exports.aliasMethod = _emberMetalMixin.aliasMethod;
- exports._immediateObserver = _emberMetalMixin._immediateObserver;
- exports._beforeObserver = _emberMetalMixin._beforeObserver;
- exports.mixin = _emberMetalMixin.mixin;
- exports.observer = _emberMetalMixin.observer;
- exports.required = _emberMetalMixin.required;
- exports.REQUIRED = _emberMetalMixin.REQUIRED;
- exports.hasUnprocessedMixins = _emberMetalMixin.hasUnprocessedMixins;
- exports.clearUnprocessedMixins = _emberMetalMixin.clearUnprocessedMixins;
- exports.detectBinding = _emberMetalMixin.detectBinding;
- exports.Binding = _emberMetalBinding.Binding;
- exports.bind = _emberMetalBinding.bind;
- exports.isGlobalPath = _emberMetalPath_cache.isGlobalPath;
- exports.InjectedProperty = _emberMetalInjected_property.default;
- exports.setHasViews = _emberMetalTags.setHasViews;
- exports.tagFor = _emberMetalTags.tagFor;
- exports.markObjectAsDirty = _emberMetalTags.markObjectAsDirty;
- exports.replace = _emberMetalReplace.default;
- exports.runInTransaction = _emberMetalTransaction.default;
- exports.didRender = _emberMetalTransaction.didRender;
- exports.assertNotRendered = _emberMetalTransaction.assertNotRendered;
- exports.descriptor = _emberMetalDescriptor.default;
+ _emberMetalComputed.computed.alias = _emberMetalAlias.default;
- // TODO: this needs to be deleted once we refactor the build tooling
+ // END IMPORTS
+
+ // BEGIN EXPORTS
+ var EmberInstrumentation = _emberMetalCore.default.Instrumentation = {};
+ EmberInstrumentation.instrument = _emberMetalInstrumentation.instrument;
+ EmberInstrumentation.subscribe = _emberMetalInstrumentation.subscribe;
+ EmberInstrumentation.unsubscribe = _emberMetalInstrumentation.unsubscribe;
+ EmberInstrumentation.reset = _emberMetalInstrumentation.reset;
+
+ _emberMetalCore.default.instrument = _emberMetalInstrumentation.instrument;
+ _emberMetalCore.default.subscribe = _emberMetalInstrumentation.subscribe;
+
+ _emberMetalCore.default._Cache = _emberMetalCache.default;
+
+ _emberMetalCore.default.generateGuid = _emberMetalUtils.generateGuid;
+ _emberMetalCore.default.GUID_KEY = _emberMetalUtils.GUID_KEY;
+ _emberMetalCore.default.NAME_KEY = _emberMetalMixin.NAME_KEY;
+ _emberMetalCore.default.platform = {
+ defineProperty: true,
+ hasPropertyAccessors: true
+ };
+
+ _emberMetalCore.default.Error = _emberMetalError.default;
+ _emberMetalCore.default.guidFor = _emberMetalUtils.guidFor;
+ _emberMetalCore.default.META_DESC = _emberMetalMeta.META_DESC;
+ _emberMetalCore.default.meta = _emberMetalMeta.meta;
+ _emberMetalCore.default.inspect = _emberMetalUtils.inspect;
+
+ _emberMetalCore.default.tryCatchFinally = _emberMetalUtils.deprecatedTryCatchFinally;
+ _emberMetalCore.default.makeArray = _emberMetalUtils.makeArray;
+ _emberMetalCore.default.canInvoke = _emberMetalUtils.canInvoke;
+ _emberMetalCore.default.tryInvoke = _emberMetalUtils.tryInvoke;
+ _emberMetalCore.default.wrap = _emberMetalUtils.wrap;
+ _emberMetalCore.default.apply = _emberMetalUtils.apply;
+ _emberMetalCore.default.applyStr = _emberMetalUtils.applyStr;
+ _emberMetalCore.default.uuid = _emberMetalUtils.uuid;
+
+ _emberMetalCore.default.Logger = _emberConsole.default;
+
+ _emberMetalCore.default.get = _emberMetalProperty_get.get;
+ _emberMetalCore.default.getWithDefault = _emberMetalProperty_get.getWithDefault;
+ _emberMetalCore.default._getPath = _emberMetalProperty_get._getPath;
+
+ _emberMetalCore.default.on = _emberMetalEvents.on;
+ _emberMetalCore.default.addListener = _emberMetalEvents.addListener;
+ _emberMetalCore.default.removeListener = _emberMetalEvents.removeListener;
+ _emberMetalCore.default._suspendListener = _emberMetalEvents.suspendListener;
+ _emberMetalCore.default._suspendListeners = _emberMetalEvents.suspendListeners;
+ _emberMetalCore.default.sendEvent = _emberMetalEvents.sendEvent;
+ _emberMetalCore.default.hasListeners = _emberMetalEvents.hasListeners;
+ _emberMetalCore.default.watchedEvents = _emberMetalEvents.watchedEvents;
+ _emberMetalCore.default.listenersFor = _emberMetalEvents.listenersFor;
+ _emberMetalCore.default.accumulateListeners = _emberMetalEvents.accumulateListeners;
+
+ _emberMetalCore.default._ObserverSet = _emberMetalObserver_set.default;
+
+ _emberMetalCore.default.propertyWillChange = _emberMetalProperty_events.propertyWillChange;
+ _emberMetalCore.default.propertyDidChange = _emberMetalProperty_events.propertyDidChange;
+ _emberMetalCore.default.overrideChains = _emberMetalProperty_events.overrideChains;
+ _emberMetalCore.default.beginPropertyChanges = _emberMetalProperty_events.beginPropertyChanges;
+ _emberMetalCore.default.endPropertyChanges = _emberMetalProperty_events.endPropertyChanges;
+ _emberMetalCore.default.changeProperties = _emberMetalProperty_events.changeProperties;
+
+ _emberMetalCore.default.defineProperty = _emberMetalProperties.defineProperty;
+
+ _emberMetalCore.default.set = _emberMetalProperty_set.set;
+ _emberMetalCore.default.trySet = _emberMetalProperty_set.trySet;
+
+ if (_emberMetalFeatures.default('ember-metal-weakmap')) {
+ _emberMetalCore.default.WeakMap = _emberMetalWeak_map.default;
+ }
+ _emberMetalCore.default.OrderedSet = _emberMetalMap.OrderedSet;
+ _emberMetalCore.default.Map = _emberMetalMap.Map;
+ _emberMetalCore.default.MapWithDefault = _emberMetalMap.MapWithDefault;
+
+ _emberMetalCore.default.getProperties = _emberMetalGet_properties.default;
+ _emberMetalCore.default.setProperties = _emberMetalSet_properties.default;
+
+ _emberMetalCore.default.watchKey = _emberMetalWatch_key.watchKey;
+ _emberMetalCore.default.unwatchKey = _emberMetalWatch_key.unwatchKey;
+
+ _emberMetalCore.default.removeChainWatcher = _emberMetalChains.removeChainWatcher;
+ _emberMetalCore.default._ChainNode = _emberMetalChains.ChainNode;
+ _emberMetalCore.default.finishChains = _emberMetalChains.finishChains;
+
+ _emberMetalCore.default.watchPath = _emberMetalWatch_path.watchPath;
+ _emberMetalCore.default.unwatchPath = _emberMetalWatch_path.unwatchPath;
+
+ _emberMetalCore.default.watch = _emberMetalWatching.watch;
+ _emberMetalCore.default.isWatching = _emberMetalWatching.isWatching;
+ _emberMetalCore.default.unwatch = _emberMetalWatching.unwatch;
+ _emberMetalCore.default.rewatch = _emberMetalWatching.rewatch;
+ _emberMetalCore.default.destroy = _emberMetalWatching.destroy;
+
+ _emberMetalCore.default.expandProperties = _emberMetalExpand_properties.default;
+
+ _emberMetalCore.default.ComputedProperty = _emberMetalComputed.ComputedProperty;
+ _emberMetalCore.default.computed = _emberMetalComputed.computed;
+ _emberMetalCore.default.cacheFor = _emberMetalComputed.cacheFor;
+
+ _emberMetalCore.default.addObserver = _emberMetalObserver.addObserver;
+ _emberMetalCore.default.observersFor = _emberMetalObserver.observersFor;
+ _emberMetalCore.default.removeObserver = _emberMetalObserver.removeObserver;
+ _emberMetalCore.default._suspendObserver = _emberMetalObserver._suspendObserver;
+ _emberMetalCore.default._suspendObservers = _emberMetalObserver._suspendObservers;
+
+ _emberMetalCore.default.required = _emberMetalMixin.required;
+ _emberMetalCore.default.aliasMethod = _emberMetalMixin.aliasMethod;
+ _emberMetalCore.default.observer = _emberMetalMixin.observer;
+ _emberMetalCore.default.immediateObserver = _emberMetalMixin._immediateObserver;
+ _emberMetalCore.default.mixin = _emberMetalMixin.mixin;
+ _emberMetalCore.default.Mixin = _emberMetalMixin.Mixin;
+
+ _emberMetalCore.default.bind = _emberMetalBinding.bind;
+ _emberMetalCore.default.Binding = _emberMetalBinding.Binding;
+ _emberMetalCore.default.isGlobalPath = _emberMetalPath_cache.isGlobalPath;
+
+ _emberMetalCore.default.run = _emberMetalRun_loop.default;
+
+ /**
+ @class Backburner
+ @for Ember
+ @private
+ */
+ _emberMetalCore.default.Backburner = function () {
+ _emberMetalDebug.deprecate('Usage of Ember.Backburner is deprecated.', false, {
+ id: 'ember-metal.ember-backburner',
+ until: '2.8.0',
+ url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-backburner'
+ });
+
+ function BackburnerAlias(args) {
+ return _backburner.default.apply(this, args);
+ }
+
+ BackburnerAlias.prototype = _backburner.default.prototype;
+
+ return new BackburnerAlias(arguments);
+ };
+
+ _emberMetalCore.default._Backburner = _backburner.default;
+
+ /**
+ The semantic version
+ @property VERSION
+ @type String
+ @public
+ */
+ _emberMetalCore.default.VERSION = _emberVersion.default;
+
+ _emberMetalCore.default.libraries = _emberMetalLibraries.default;
+
+ _emberMetalLibraries.default.registerCoreLibrary('Ember', _emberMetalCore.default.VERSION);
+
+ _emberMetalCore.default.isNone = _emberMetalIs_none.default;
+ _emberMetalCore.default.isEmpty = _emberMetalIs_empty.default;
+ _emberMetalCore.default.isBlank = _emberMetalIs_blank.default;
+ _emberMetalCore.default.isPresent = _emberMetalIs_present.default;
+
+ _emberMetalCore.default.assign = Object.assign || _emberMetalAssign.default;
+ _emberMetalCore.default.merge = _emberMetalMerge.default;
+
+ _emberMetalCore.default.FEATURES = _emberMetalFeatures.FEATURES;
+ _emberMetalCore.default.FEATURES.isEnabled = _emberMetalFeatures.default;
+
+ _emberMetalCore.default.EXTEND_PROTOTYPES = _emberEnvironment.ENV.EXTEND_PROTOTYPES;
+
+ // BACKWARDS COMPAT ACCESSORS FOR ENV FLAGS
+ Object.defineProperty(_emberMetalCore.default, 'LOG_STACKTRACE_ON_DEPRECATION', {
+ get: function () {
+ return _emberEnvironment.ENV.LOG_STACKTRACE_ON_DEPRECATION;
+ },
+ set: function (value) {
+ _emberEnvironment.ENV.LOG_STACKTRACE_ON_DEPRECATION = !!value;
+ },
+ enumerable: false
+ });
+
+ Object.defineProperty(_emberMetalCore.default, 'LOG_VERSION', {
+ get: function () {
+ return _emberEnvironment.ENV.LOG_VERSION;
+ },
+ set: function (value) {
+ _emberEnvironment.ENV.LOG_VERSION = !!value;
+ },
+ enumerable: false
+ });
+
+ Object.defineProperty(_emberMetalCore.default, 'MODEL_FACTORY_INJECTIONS', {
+ get: function () {
+ return _emberEnvironment.ENV.MODEL_FACTORY_INJECTIONS;
+ },
+ set: function (value) {
+ _emberEnvironment.ENV.MODEL_FACTORY_INJECTIONS = !!value;
+ },
+ enumerable: false
+ });
+
+ Object.defineProperty(_emberMetalCore.default, 'LOG_BINDINGS', {
+ get: function () {
+ return _emberEnvironment.ENV.LOG_BINDINGS;
+ },
+ set: function (value) {
+ _emberEnvironment.ENV.LOG_BINDINGS = !!value;
+ },
+ enumerable: false
+ });
+
+ Object.defineProperty(_emberMetalCore.default, 'ENV', {
+ get: function () {
+ return _emberEnvironment.ENV;
+ },
+ enumerable: false
+ });
+
+ /**
+ The context that Ember searches for namespace instances on.
+
+ @private
+ */
+ Object.defineProperty(_emberMetalCore.default, 'lookup', {
+ get: function () {
+ return _emberEnvironment.context.lookup;
+ },
+ set: function (value) {
+ _emberEnvironment.context.lookup = value;
+ },
+ enumerable: false
+ });
+
+ Object.defineProperty(_emberMetalCore.default, 'testing', {
+ get: _emberMetalTesting.isTesting,
+ set: _emberMetalTesting.setTesting,
+ enumerable: false
+ });
+
+ /**
+ A function may be assigned to `Ember.onerror` to be called when Ember
+ internals encounter an error. This is useful for specialized error handling
+ and reporting code.
+
+ ```javascript
+ Ember.onerror = function(error) {
+ Em.$.ajax('/report-error', 'POST', {
+ stack: error.stack,
+ otherInformation: 'whatever app state you want to provide'
+ });
+ };
+ ```
+
+ Internally, `Ember.onerror` is used as Backburner's error handler.
+
+ @event onerror
+ @for Ember
+ @param {Exception} error the error object
+ @public
+ */
+ Object.defineProperty(_emberMetalCore.default, 'onerror', {
+ get: _emberMetalError_handler.getOnerror,
+ set: _emberMetalError_handler.setOnerror,
+ enumerable: false
+ });
+
+ /**
+ An empty function useful for some operations. Always returns `this`.
+
+ @method K
+ @return {Object}
+ @public
+ */
+ _emberMetalCore.default.K = function K() {
+ return this;
+ };
+
+ // The debug functions are exported to globals with `require` to
+ // prevent babel-plugin-filter-imports from removing them.
+ var debugModule = _require.default('ember-metal/debug');
+ _emberMetalCore.default.assert = debugModule.assert;
+ _emberMetalCore.default.warn = debugModule.warn;
+ _emberMetalCore.default.debug = debugModule.debug;
+ _emberMetalCore.default.deprecate = debugModule.deprecate;
+ _emberMetalCore.default.deprecateFunc = debugModule.deprecateFunc;
+ _emberMetalCore.default.runInDebug = debugModule.runInDebug;
+ // END EXPORTS
+
// do this for side-effects of updating Ember.assert, warn, etc when
// ember-debug is present
// This needs to be called before any deprecateFunc
-
if (_require.has('ember-debug')) {
_require.default('ember-debug');
+ } else {
+ _emberMetalCore.default.Debug = {};
+ _emberMetalCore.default.Debug.registerDeprecationHandler = function () {};
+ _emberMetalCore.default.Debug.registerWarnHandler = function () {};
}
+
+ _emberMetalCore.default.create = _emberMetalDebug.deprecateFunc('Ember.create is deprecated in favor of Object.create', { id: 'ember-metal.ember-create', until: '3.0.0' }, Object.create);
+ _emberMetalCore.default.keys = _emberMetalDebug.deprecateFunc('Ember.keys is deprecated in favor of Object.keys', { id: 'ember-metal.ember.keys', until: '3.0.0' }, Object.keys);
+
+ /* globals module */
+ if (typeof module === 'object' && module.exports) {
+ module.exports = _emberMetalCore.default;
+ } else {
+ _emberEnvironment.context.exports.Ember = _emberEnvironment.context.exports.Em = _emberMetalCore.default;
+ }
+
+ exports.default = _emberMetalCore.default;
});
-enifed('ember-metal/injected_property', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/computed', 'ember-metal/alias', 'ember-metal/properties'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalComputed, _emberMetalAlias, _emberMetalProperties) {
+// reexports
+enifed('ember-metal/injected_property', ['exports', 'ember-metal/debug', 'ember-metal/computed', 'ember-metal/alias', 'ember-metal/properties', 'container/owner'], function (exports, _emberMetalDebug, _emberMetalComputed, _emberMetalAlias, _emberMetalProperties, _containerOwner) {
'use strict';
exports.default = InjectedProperty;
/**
@@ -5366,11 +5618,11 @@
AliasedPropertyPrototype.oneWay.call(this);
}
function injectedPropertyGet(keyName) {
var desc = this[keyName];
- var owner = _emberUtils.getOwner(this) || this.container; // fallback to `container` for backwards compat
+ var owner = _containerOwner.getOwner(this) || this.container; // fallback to `container` for backwards compat
_emberMetalDebug.assert('InjectedProperties should be defined with the Ember.inject computed property macros.', desc && desc.isDescriptor && desc.type);
_emberMetalDebug.assert('Attempting to lookup an injected property on an object without a container, ensure that the object was instantiated via a container.', owner);
return owner.lookup(desc.type + ':' + (desc.name || keyName));
@@ -5527,30 +5779,24 @@
finalizer();
return result;
}
}
- function NOOP() {}
-
// private for now
- function _instrumentStart(name, _payload, _payloadParam) {
- if (subscribers.length === 0) {
- return NOOP;
- }
-
+ function _instrumentStart(name, _payload) {
var listeners = cache[name];
if (!listeners) {
listeners = populateListeners(name);
}
if (listeners.length === 0) {
- return NOOP;
+ return;
}
- var payload = _payload(_payloadParam);
+ var payload = _payload();
var STRUCTURED_PROFILE = _emberEnvironment.ENV.STRUCTURED_PROFILE;
var timeName = undefined;
if (STRUCTURED_PROFILE) {
timeName = name + ': ' + payload.object;
@@ -5897,11 +6143,11 @@
};
}
exports.default = new Libraries();
});
-enifed('ember-metal/map', ['exports', 'ember-utils'], function (exports, _emberUtils) {
+enifed('ember-metal/map', ['exports', 'ember-metal/utils', 'ember-metal/empty_object'], function (exports, _emberMetalUtils, _emberMetalEmpty_object) {
/**
@module ember
@submodule ember-metal
*/
@@ -5931,11 +6177,11 @@
function missingNew(name) {
throw new TypeError('Constructor ' + name + ' requires \'new\'');
}
function copyNull(obj) {
- var output = new _emberUtils.EmptyObject();
+ var output = new _emberMetalEmpty_object.default();
for (var prop in obj) {
// hasOwnPropery is not needed because obj is new EmptyObject();
output[prop] = obj[prop];
}
@@ -5990,11 +6236,11 @@
/**
@method clear
@private
*/
clear: function () {
- this.presenceSet = new _emberUtils.EmptyObject();
+ this.presenceSet = new _emberMetalEmpty_object.default();
this.list = [];
this.size = 0;
},
/**
@@ -6003,11 +6249,11 @@
@param guid (optional, and for internal use)
@return {Ember.OrderedSet}
@private
*/
add: function (obj, _guid) {
- var guid = _guid || _emberUtils.guidFor(obj);
+ var guid = _guid || _emberMetalUtils.guidFor(obj);
var presenceSet = this.presenceSet;
var list = this.list;
if (presenceSet[guid] !== true) {
presenceSet[guid] = true;
@@ -6024,11 +6270,11 @@
@param _guid (optional and for internal use only)
@return {Boolean}
@private
*/
delete: function (obj, _guid) {
- var guid = _guid || _emberUtils.guidFor(obj);
+ var guid = _guid || _emberMetalUtils.guidFor(obj);
var presenceSet = this.presenceSet;
var list = this.list;
if (presenceSet[guid] === true) {
delete presenceSet[guid];
@@ -6061,11 +6307,11 @@
has: function (obj) {
if (this.size === 0) {
return false;
}
- var guid = _emberUtils.guidFor(obj);
+ var guid = _emberMetalUtils.guidFor(obj);
var presenceSet = this.presenceSet;
return presenceSet[guid] === true;
},
@@ -6146,11 +6392,11 @@
*/
function Map() {
if (this instanceof Map) {
this._keys = OrderedSet.create();
this._keys._silenceRemoveDeprecation = true;
- this._values = new _emberUtils.EmptyObject();
+ this._values = new _emberMetalEmpty_object.default();
this.size = 0;
} else {
missingNew('Map');
}
}
@@ -6189,11 +6435,11 @@
if (this.size === 0) {
return;
}
var values = this._values;
- var guid = _emberUtils.guidFor(key);
+ var guid = _emberMetalUtils.guidFor(key);
return values[guid];
},
/**
@@ -6206,11 +6452,11 @@
@private
*/
set: function (key, value) {
var keys = this._keys;
var values = this._values;
- var guid = _emberUtils.guidFor(key);
+ var guid = _emberMetalUtils.guidFor(key);
// ensure we don't store -0
var k = key === -0 ? 0 : key;
keys.add(k, guid);
@@ -6236,11 +6482,11 @@
}
// don't use ES6 "delete" because it will be annoying
// to use in browsers that are not ES6 friendly;
var keys = this._keys;
var values = this._values;
- var guid = _emberUtils.guidFor(key);
+ var guid = _emberMetalUtils.guidFor(key);
if (keys.delete(key, guid)) {
delete values[guid];
this.size = keys.size;
return true;
@@ -6302,11 +6548,11 @@
@method clear
@private
*/
clear: function () {
this._keys.clear();
- this._values = new _emberUtils.EmptyObject();
+ this._values = new _emberMetalEmpty_object.default();
this.size = 0;
},
/**
@method copy
@@ -6427,11 +6673,11 @@
}
return original;
}
});
-enifed('ember-metal/meta', ['exports', 'ember-utils', 'ember-metal/features', 'ember-metal/meta_listeners'], function (exports, _emberUtils, _emberMetalFeatures, _emberMetalMeta_listeners) {
+enifed('ember-metal/meta', ['exports', 'ember-metal/features', 'ember-metal/meta_listeners', 'ember-metal/empty_object', 'ember-metal/utils', 'ember-metal/symbol'], function (exports, _emberMetalFeatures, _emberMetalMeta_listeners, _emberMetalEmpty_object, _emberMetalUtils, _emberMetalSymbol) {
'no use strict';
// Remove "use strict"; from transpiled module until
// https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed
exports.meta = meta;
@@ -6474,15 +6720,10 @@
chainWatchers: ownCustomObject,
chains: inheritedCustomObject,
tag: ownCustomObject
};
- if (_emberMetalFeatures.default('ember-glimmer-detect-backtracking-rerender') || _emberMetalFeatures.default('ember-glimmer-allow-backtracking-rerender')) {
- members.lastRendered = ownMap;
- members.lastRenderedFrom = ownMap; // FIXME: not used in production, remove me from prod builds
- }
-
var memberNames = Object.keys(members);
var META_FIELD = '__ember_meta__';
function Meta(obj, parentMeta) {
this._cache = undefined;
@@ -6507,15 +6748,10 @@
// explicitly instead of using prototypical inheritance because we
// have detailed knowledge of how each property should really be
// inherited, and we can optimize it much better than JS runtimes.
this.parent = parentMeta;
- if (_emberMetalFeatures.default('ember-glimmer-detect-backtracking-rerender') || _emberMetalFeatures.default('ember-glimmer-allow-backtracking-rerender')) {
- this._lastRendered = undefined;
- this._lastRenderedFrom = undefined; // FIXME: not used in production, remove me from prod builds
- }
-
this._initializeListeners();
}
Meta.prototype.isInitialized = function (obj) {
return this.proto !== obj;
@@ -6542,11 +6778,11 @@
}
Meta.prototype._getOrCreateOwnMap = function (key) {
var ret = this[key];
if (!ret) {
- ret = this[key] = new _emberUtils.EmptyObject();
+ ret = this[key] = new _emberMetalEmpty_object.default();
}
return ret;
};
// Implements a member that is a lazily created POJO with inheritable
@@ -6564,11 +6800,11 @@
return this._findInherited(key, subkey);
};
Meta.prototype['forEach' + capitalized] = function (fn) {
var pointer = this;
- var seen = new _emberUtils.EmptyObject();
+ var seen = new _emberMetalEmpty_object.default();
while (pointer !== undefined) {
var map = pointer[key];
if (map) {
for (var _key in map) {
if (!seen[_key]) {
@@ -6616,11 +6852,11 @@
}
pointer = pointer.parent;
}
};
- var UNDEFINED = _emberUtils.symbol('undefined');
+ var UNDEFINED = _emberMetalSymbol.default('undefined');
exports.UNDEFINED = UNDEFINED;
// Implements a member that provides a lazily created map of maps,
// with inheritance at both levels.
function inheritedMapOfMaps(name, Meta) {
@@ -6629,11 +6865,11 @@
Meta.prototype['write' + capitalized] = function (subkey, itemkey, value) {
var outerMap = this._getOrCreateOwnMap(key);
var innerMap = outerMap[subkey];
if (!innerMap) {
- innerMap = outerMap[subkey] = new _emberUtils.EmptyObject();
+ innerMap = outerMap[subkey] = new _emberMetalEmpty_object.default();
}
innerMap[itemkey] = value;
};
Meta.prototype['peek' + capitalized] = function (subkey, itemkey) {
@@ -6668,11 +6904,11 @@
};
}
Meta.prototype._forEachIn = function (key, subkey, fn) {
var pointer = this;
- var seen = new _emberUtils.EmptyObject();
+ var seen = new _emberMetalEmpty_object.default();
var calls = [];
while (pointer !== undefined) {
var map = pointer[key];
if (map) {
var innerMap = map[subkey];
@@ -6779,11 +7015,11 @@
return UNDEFINED;
};
Meta.prototype.writeValue = function (obj, key, value) {
- var descriptor = _emberUtils.lookupDescriptor(obj, key);
+ var descriptor = _emberMetalUtils.lookupDescriptor(obj, key);
var isMandatorySetter = descriptor && descriptor.set && descriptor.set.isMandatorySetter;
if (isMandatorySetter) {
this.writeValues(key, value);
} else {
@@ -7025,11 +7261,11 @@
}
}
destination.push(target, method, source[index + 3]);
}
});
-enifed('ember-metal/mixin', ['exports', 'ember-utils', 'ember-metal/error', 'ember-metal/debug', 'ember-metal/meta', 'ember-metal/expand_properties', 'ember-metal/properties', 'ember-metal/computed', 'ember-metal/binding', 'ember-metal/observer', 'ember-metal/events'], function (exports, _emberUtils, _emberMetalError, _emberMetalDebug, _emberMetalMeta, _emberMetalExpand_properties, _emberMetalProperties, _emberMetalComputed, _emberMetalBinding, _emberMetalObserver, _emberMetalEvents) {
+enifed('ember-metal/mixin', ['exports', 'ember-metal/error', 'ember-metal/debug', 'ember-metal/assign', 'ember-metal/utils', 'ember-metal/meta', 'ember-metal/expand_properties', 'ember-metal/properties', 'ember-metal/computed', 'ember-metal/binding', 'ember-metal/observer', 'ember-metal/events'], function (exports, _emberMetalError, _emberMetalDebug, _emberMetalAssign, _emberMetalUtils, _emberMetalMeta, _emberMetalExpand_properties, _emberMetalProperties, _emberMetalComputed, _emberMetalBinding, _emberMetalObserver, _emberMetalEvents) {
'no use strict';
// Remove "use strict"; from transpiled module until
// https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed
/**
@@ -7060,11 +7296,11 @@
function mixinProperties(mixinsMeta, mixin) {
var guid = undefined;
if (mixin instanceof Mixin) {
- guid = _emberUtils.guidFor(mixin);
+ guid = _emberMetalUtils.guidFor(mixin);
if (mixinsMeta.peekMixins(guid)) {
return CONTINUE;
}
mixinsMeta.writeMixins(guid, mixin);
return mixin.properties;
@@ -7109,14 +7345,14 @@
// Since multiple mixins may inherit from the same parent, we need
// to clone the computed property so that other mixins do not receive
// the wrapped version.
property = Object.create(property);
- property._getter = _emberUtils.wrap(property._getter, superProperty._getter);
+ property._getter = _emberMetalUtils.wrap(property._getter, superProperty._getter);
if (superProperty._setter) {
if (property._setter) {
- property._setter = _emberUtils.wrap(property._setter, superProperty._setter);
+ property._setter = _emberMetalUtils.wrap(property._setter, superProperty._setter);
} else {
property._setter = superProperty._setter;
}
}
@@ -7139,11 +7375,11 @@
// Only wrap the new method if the original method was a function
if (superMethod === undefined || 'function' !== typeof superMethod) {
return method;
}
- return _emberUtils.wrap(method, superMethod);
+ return _emberMetalUtils.wrap(method, superMethod);
}
function applyConcatenatedProperties(obj, key, value, values) {
var baseValue = values[key] || obj[key];
@@ -7153,14 +7389,14 @@
return baseValue;
} else {
return baseValue.concat(value);
}
} else {
- return _emberUtils.makeArray(baseValue).concat(value);
+ return _emberMetalUtils.makeArray(baseValue).concat(value);
}
} else {
- return _emberUtils.makeArray(value);
+ return _emberMetalUtils.makeArray(value);
}
}
function applyMergedProperties(obj, key, value, values) {
var baseValue = values[key] || obj[key];
@@ -7174,11 +7410,11 @@
if (!baseValue) {
return value;
}
- var newBase = _emberUtils.assign({}, baseValue);
+ var newBase = _emberMetalAssign.default({}, baseValue);
var hasFunction = false;
for (var prop in value) {
if (!value.hasOwnProperty(prop)) {
continue;
@@ -7232,11 +7468,12 @@
function mergeMixins(mixins, m, descs, values, base, keys) {
var currentMixin = undefined,
props = undefined,
key = undefined,
concats = undefined,
- mergings = undefined;
+ mergings = undefined,
+ meta = undefined;
function removeKeys(keyName) {
delete descs[keyName];
delete values[keyName];
}
@@ -7249,10 +7486,11 @@
if (props === CONTINUE) {
continue;
}
if (props) {
+ meta = _emberMetalMeta.meta(base);
if (base.willMergeMixin) {
base.willMergeMixin(props);
}
concats = concatenatedMixinProperties('concatenatedProperties', props, values, base);
mergings = concatenatedMixinProperties('mergedProperties', props, values, base);
@@ -7260,11 +7498,11 @@
for (key in props) {
if (!props.hasOwnProperty(key)) {
continue;
}
keys.push(key);
- addNormalizedProperty(base, key, props[key], m, descs, values, concats, mergings);
+ addNormalizedProperty(base, key, props[key], meta, descs, values, concats, mergings);
}
// manually copy toString() because some JS engines do not enumerate it
if (props.hasOwnProperty('toString')) {
base.toString = props.toString;
@@ -7433,34 +7671,34 @@
applyMixin(obj, args, false);
return obj;
}
- var NAME_KEY = _emberUtils.GUID_KEY + '_name';
+ var NAME_KEY = _emberMetalUtils.GUID_KEY + '_name';
exports.NAME_KEY = NAME_KEY;
/**
The `Ember.Mixin` class allows you to create mixins, whose properties can be
added to other classes. For instance,
```javascript
- const EditableMixin = Ember.Mixin.create({
- edit() {
+ App.Editable = Ember.Mixin.create({
+ edit: function() {
console.log('starting to edit');
this.set('isEditing', true);
},
isEditing: false
});
// Mix mixins into classes by passing them as the first arguments to
- // `.extend.`
- const Comment = Ember.Object.extend(EditableMixin, {
- post: null
+ // .extend.
+ App.CommentView = Ember.View.extend(App.Editable, {
+ template: Ember.Handlebars.compile('{{#if view.isEditing}}...{{else}}...{{/if}}')
});
- let comment = Comment.create(post: somePost);
- comment.edit(); // outputs 'starting to edit'
+ commentView = App.CommentView.create();
+ commentView.edit(); // outputs 'starting to edit'
```
Note that Mixins are created with `Ember.Mixin.create`, not
`Ember.Mixin.extend`.
@@ -7468,25 +7706,23 @@
defined as properties will be shared amongst objects that implement the mixin.
If you want to define a property in a mixin that is not shared, you can define
it either as a computed property or have it be created on initialization of the object.
```javascript
- // filters array will be shared amongst any object implementing mixin
- const FilterableMixin = Ember.Mixin.create({
+ //filters array will be shared amongst any object implementing mixin
+ App.Filterable = Ember.Mixin.create({
filters: Ember.A()
});
- // filters will be a separate array for every object implementing the mixin
- const FilterableMixin = Ember.Mixin.create({
- filters: Ember.computed(function() {
- return Ember.A();
- })
+ //filters will be a separate array for every object implementing the mixin
+ App.Filterable = Ember.Mixin.create({
+ filters: Ember.computed(function() {return Ember.A();})
});
- // filters will be created as a separate array during the object's initialization
- const Filterable = Ember.Mixin.create({
- init() {
+ //filters will be created as a separate array during the object's initialization
+ App.Filterable = Ember.Mixin.create({
+ init: function() {
this._super(...arguments);
this.set("filters", Ember.A());
}
});
```
@@ -7517,11 +7753,11 @@
} else {
this.mixins = undefined;
}
this.ownerConstructor = undefined;
this._without = undefined;
- this[_emberUtils.GUID_KEY] = null;
+ this[_emberMetalUtils.GUID_KEY] = null;
this[NAME_KEY] = null;
_emberMetalDebug.debugSeal(this);
}
Mixin._apply = applyMixin;
@@ -7611,11 +7847,11 @@
};
MixinPrototype.toString = Object.toString;
function _detect(curMixin, targetMixin, seen) {
- var guid = _emberUtils.guidFor(curMixin);
+ var guid = _emberMetalUtils.guidFor(curMixin);
if (seen[guid]) {
return false;
}
seen[guid] = true;
@@ -7638,21 +7874,21 @@
@param obj
@return {Boolean}
@private
*/
MixinPrototype.detect = function (obj) {
- if (typeof obj !== 'object' || obj === null) {
+ if (!obj) {
return false;
}
if (obj instanceof Mixin) {
return _detect(obj, this, {});
}
var m = _emberMetalMeta.peekMeta(obj);
if (!m) {
return false;
}
- return !!m.peekMixins(_emberUtils.guidFor(this));
+ return !!m.peekMixins(_emberMetalUtils.guidFor(this));
};
MixinPrototype.without = function () {
var ret = new Mixin([this]);
@@ -7663,14 +7899,14 @@
ret._without = args;
return ret;
};
function _keys(ret, mixin, seen) {
- if (seen[_emberUtils.guidFor(mixin)]) {
+ if (seen[_emberMetalUtils.guidFor(mixin)]) {
return;
}
- seen[_emberUtils.guidFor(mixin)] = true;
+ seen[_emberMetalUtils.guidFor(mixin)] = true;
if (mixin.properties) {
var props = Object.keys(mixin.properties);
for (var i = 0; i < props.length; i++) {
var key = props[i];
@@ -7869,10 +8105,34 @@
Note, `@each.property` observer is called per each add or replace of an element
and it's not called with a specific enumeration item.
A `_beforeObserver` fires before a property changes.
+ A `_beforeObserver` is an alternative form of `.observesBefore()`.
+
+ ```javascript
+ App.PersonView = Ember.View.extend({
+ friends: [{ name: 'Tom' }, { name: 'Stefan' }, { name: 'Kris' }],
+
+ valueDidChange: Ember.observer('content.value', function(obj, keyName) {
+ // only run if updating a value already in the DOM
+ if (this.get('state') === 'inDOM') {
+ let color = obj.get(keyName) > this.changingFrom ? 'green' : 'red';
+ // logic
+ }
+ }),
+
+ friendsDidChange: Ember.observer('friends.@each.name', function(obj, keyName) {
+ // some logic
+ // obj.get(keyName) returns friends array
+ })
+ });
+ ```
+
+ Also available as `Function.prototype.observesBefore` if prototype extensions are
+ enabled.
+
@method beforeObserver
@for Ember
@param {String} propertyNames*
@param {Function} func
@return func
@@ -7906,11 +8166,11 @@
for (var i = 0; i < _paths.length; ++i) {
_emberMetalExpand_properties.default(_paths[i], addWatchedProperty);
}
if (typeof func !== 'function') {
- throw new _emberMetalError.default('_beforeObserver called without a function');
+ throw new _emberMetalError.default('Ember.beforeObserver called without a function');
}
func.__ember_observesBefore__ = paths;
return func;
}
@@ -8031,11 +8291,11 @@
_emberMetalEvents.removeListener(obj, beforeEvent(path), target, method);
return this;
}
});
-enifed('ember-metal/observer_set', ['exports', 'ember-utils', 'ember-metal/events'], function (exports, _emberUtils, _emberMetalEvents) {
+enifed('ember-metal/observer_set', ['exports', 'ember-metal/utils', 'ember-metal/events'], function (exports, _emberMetalUtils, _emberMetalEvents) {
'use strict';
exports.default = ObserverSet;
/*
@@ -8062,11 +8322,11 @@
}
ObserverSet.prototype.add = function (sender, keyName, eventName) {
var observerSet = this.observerSet;
var observers = this.observers;
- var senderGuid = _emberUtils.guidFor(sender);
+ var senderGuid = _emberMetalUtils.guidFor(sender);
var keySet = observerSet[senderGuid];
var index = undefined;
if (!keySet) {
observerSet[senderGuid] = keySet = {};
@@ -8407,14 +8667,14 @@
// https://github.com/ariya/phantomjs/issues/11856
Object.defineProperty(obj, keyName, { configurable: true, writable: true, value: 'iCry' });
Object.defineProperty(obj, keyName, desc);
}
});
-enifed('ember-metal/property_events', ['exports', 'ember-utils', 'ember-metal/meta', 'ember-metal/events', 'ember-metal/tags', 'ember-metal/observer_set', 'ember-metal/features', 'ember-metal/transaction'], function (exports, _emberUtils, _emberMetalMeta, _emberMetalEvents, _emberMetalTags, _emberMetalObserver_set, _emberMetalFeatures, _emberMetalTransaction) {
+enifed('ember-metal/property_events', ['exports', 'ember-metal/utils', 'ember-metal/meta', 'ember-metal/events', 'ember-metal/tags', 'ember-metal/observer_set', 'ember-metal/symbol'], function (exports, _emberMetalUtils, _emberMetalMeta, _emberMetalEvents, _emberMetalTags, _emberMetalObserver_set, _emberMetalSymbol) {
'use strict';
- var PROPERTY_DID_CHANGE = _emberUtils.symbol('PROPERTY_DID_CHANGE');
+ var PROPERTY_DID_CHANGE = _emberMetalSymbol.default('PROPERTY_DID_CHANGE');
exports.PROPERTY_DID_CHANGE = PROPERTY_DID_CHANGE;
var beforeObserverSet = new _emberMetalObserver_set.default();
var observerSet = new _emberMetalObserver_set.default();
var deferred = 0;
@@ -8504,18 +8764,11 @@
if (obj[PROPERTY_DID_CHANGE]) {
obj[PROPERTY_DID_CHANGE](keyName);
}
- if (obj.isDestroying) {
- return;
- }
_emberMetalTags.markObjectAsDirty(m);
-
- if (_emberMetalFeatures.default('ember-glimmer-detect-backtracking-rerender') || _emberMetalFeatures.default('ember-glimmer-allow-backtracking-rerender')) {
- _emberMetalTransaction.assertNotRendered(obj, keyName, m);
- }
}
var WILL_SEEN = undefined,
DID_SEEN = undefined;
// called whenever a property is about to change to clear the cache of any dependent keys (and notify those properties of changes, etc...)
@@ -8563,11 +8816,11 @@
}
function iterDeps(method, obj, depKey, seen, meta) {
var possibleDesc = undefined,
desc = undefined;
- var guid = _emberUtils.guidFor(obj);
+ var guid = _emberMetalUtils.guidFor(obj);
var current = seen[guid];
if (!current) {
current = seen[guid] = {};
}
@@ -8754,10 +9007,15 @@
_emberMetalDebug.assert('Get must be called with two arguments; an object and a property key', arguments.length === 2);
_emberMetalDebug.assert('Cannot call get with \'' + keyName + '\' on an undefined object.', obj !== undefined && obj !== null);
_emberMetalDebug.assert('The key provided to get must be a string, you passed ' + keyName, typeof keyName === 'string');
_emberMetalDebug.assert('\'this\' in paths is not supported', !_emberMetalPath_cache.hasThis(keyName));
+ // Helpers that operate with 'this' within an #each
+ if (keyName === '') {
+ return obj;
+ }
+
var value = obj[keyName];
var desc = value !== null && typeof value === 'object' && value.isDescriptor ? value : undefined;
var ret = undefined;
if (desc === undefined && _emberMetalPath_cache.isPath(keyName)) {
@@ -8830,11 +9088,11 @@
return value;
}
exports.default = get;
});
-enifed('ember-metal/property_set', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/features', 'ember-metal/property_get', 'ember-metal/property_events', 'ember-metal/error', 'ember-metal/path_cache', 'ember-metal/meta'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalFeatures, _emberMetalProperty_get, _emberMetalProperty_events, _emberMetalError, _emberMetalPath_cache, _emberMetalMeta) {
+enifed('ember-metal/property_set', ['exports', 'ember-metal/debug', 'ember-metal/features', 'ember-metal/property_get', 'ember-metal/property_events', 'ember-metal/error', 'ember-metal/path_cache', 'ember-metal/meta', 'ember-metal/utils'], function (exports, _emberMetalDebug, _emberMetalFeatures, _emberMetalProperty_get, _emberMetalProperty_events, _emberMetalError, _emberMetalPath_cache, _emberMetalMeta, _emberMetalUtils) {
'use strict';
exports.set = set;
exports.trySet = trySet;
@@ -8856,11 +9114,11 @@
function set(obj, keyName, value, tolerant) {
_emberMetalDebug.assert('Set must be called with three or four arguments; an object, a property key, a value and tolerant true/false', arguments.length === 3 || arguments.length === 4);
_emberMetalDebug.assert('Cannot call set with \'' + keyName + '\' on an undefined object.', obj && typeof obj === 'object' || typeof obj === 'function');
_emberMetalDebug.assert('The key provided to set must be a string, you passed ' + keyName, typeof keyName === 'string');
_emberMetalDebug.assert('\'this\' in paths is not supported', !_emberMetalPath_cache.hasThis(keyName));
- _emberMetalDebug.assert('calling set on destroyed object: ' + _emberUtils.toString(obj) + '.' + keyName + ' = ' + _emberUtils.toString(value), !obj.isDestroyed);
+ _emberMetalDebug.assert('calling set on destroyed object: ' + _emberMetalUtils.toString(obj) + '.' + keyName + ' = ' + _emberMetalUtils.toString(value), !obj.isDestroyed);
if (_emberMetalPath_cache.isPath(keyName)) {
return setPath(obj, keyName, value, tolerant);
}
@@ -8998,11 +9256,11 @@
ret = ret.concat(splice.apply(array, chunk));
}
return ret;
}
});
-enifed('ember-metal/run_loop', ['exports', 'ember-utils', 'ember-metal/debug', 'ember-metal/testing', 'ember-metal/error_handler', 'ember-metal/property_events', 'backburner'], function (exports, _emberUtils, _emberMetalDebug, _emberMetalTesting, _emberMetalError_handler, _emberMetalProperty_events, _backburner) {
+enifed('ember-metal/run_loop', ['exports', 'ember-metal/debug', 'ember-metal/testing', 'ember-metal/error_handler', 'ember-metal/utils', 'ember-metal/property_events', 'backburner'], function (exports, _emberMetalDebug, _emberMetalTesting, _emberMetalError_handler, _emberMetalUtils, _emberMetalProperty_events, _backburner) {
'use strict';
exports.default = run;
function onBegin(current) {
@@ -9021,11 +9279,11 @@
return _emberMetalError_handler.setOnerror(handler);
}
};
var backburner = new _backburner.default(['sync', 'actions', 'destroy'], {
- GUID_KEY: _emberUtils.GUID_KEY,
+ GUID_KEY: _emberMetalUtils.GUID_KEY,
sync: {
before: _emberMetalProperty_events.beginPropertyChanges,
after: _emberMetalProperty_events.endPropertyChanges
},
defaultQueue: 'actions',
@@ -9724,60 +9982,91 @@
}
});
return properties;
}
});
-enifed('ember-metal/tags', ['exports', 'glimmer-reference', 'ember-metal/meta', 'require'], function (exports, _glimmerReference, _emberMetalMeta, _require) {
+enifed('ember-metal/symbol', ['exports', 'ember-metal/utils'], function (exports, _emberMetalUtils) {
'use strict';
+ exports.default = symbol;
+
+ function symbol(debugName) {
+ // TODO: Investigate using platform symbols, but we do not
+ // want to require non-enumerability for this API, which
+ // would introduce a large cost.
+
+ return _emberMetalUtils.intern(debugName + ' [id=' + _emberMetalUtils.GUID_KEY + Math.floor(Math.random() * new Date()) + ']');
+ }
+});
+enifed('ember-metal/tags', ['exports', 'ember-metal/meta', 'require'], function (exports, _emberMetalMeta, _require2) {
+ 'use strict';
+
exports.setHasViews = setHasViews;
exports.tagFor = tagFor;
- exports.markObjectAsDirty = markObjectAsDirty;
+ var hasGlimmer = _require2.has('glimmer-reference');
+ var CONSTANT_TAG = undefined,
+ CURRENT_TAG = undefined,
+ DirtyableTag = undefined,
+ makeTag = undefined,
+ run = undefined;
+
var hasViews = function () {
return false;
};
function setHasViews(fn) {
hasViews = fn;
}
- function makeTag() {
- return new _glimmerReference.DirtyableTag();
- }
+ var markObjectAsDirty = undefined;
+ exports.markObjectAsDirty = markObjectAsDirty;
+
function tagFor(object, _meta) {
- if (typeof object === 'object' && object) {
+ if (!hasGlimmer) {
+ throw new Error('Cannot call tagFor without Glimmer');
+ }
+
+ if (object && typeof object === 'object') {
var meta = _meta || _emberMetalMeta.meta(object);
return meta.writableTag(makeTag);
} else {
- return _glimmerReference.CONSTANT_TAG;
+ return CONSTANT_TAG;
}
}
- function markObjectAsDirty(meta) {
- var tag = meta && meta.readableTag();
-
- if (tag) {
- ensureRunloop();
- tag.dirty();
- }
- }
-
- var run = undefined;
-
function K() {}
-
function ensureRunloop() {
if (!run) {
- run = _require.default('ember-metal/run_loop').default;
+ run = _require2.default('ember-metal/run_loop').default;
}
if (hasViews() && !run.backburner.currentInstance) {
run.schedule('actions', K);
}
}
+
+ if (hasGlimmer) {
+ var _require = _require2.default('glimmer-reference');
+
+ DirtyableTag = _require.DirtyableTag;
+ CONSTANT_TAG = _require.CONSTANT_TAG;
+ CURRENT_TAG = _require.CURRENT_TAG;
+
+ makeTag = function () {
+ return new DirtyableTag();
+ };
+
+ exports.markObjectAsDirty = markObjectAsDirty = function (meta) {
+ ensureRunloop();
+ var tag = meta && meta.readableTag() || CURRENT_TAG;
+ tag.dirty();
+ };
+ } else {
+ exports.markObjectAsDirty = markObjectAsDirty = function () {};
+ }
});
enifed("ember-metal/testing", ["exports"], function (exports) {
"use strict";
exports.isTesting = isTesting;
@@ -9790,109 +10079,548 @@
function setTesting(value) {
testing = !!value;
}
});
-enifed('ember-metal/transaction', ['exports', 'ember-metal/meta', 'ember-metal/debug', 'ember-metal/features'], function (exports, _emberMetalMeta, _emberMetalDebug, _emberMetalFeatures) {
- 'use strict';
+enifed('ember-metal/utils', ['exports'], function (exports) {
+ 'no use strict';
+ // Remove "use strict"; from transpiled module until
+ // https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed
- var runInTransaction = undefined,
- didRender = undefined,
- assertNotRendered = undefined;
+ /**
+ @module ember-metal
+ */
- var raise = _emberMetalDebug.assert;
- if (_emberMetalFeatures.default('ember-glimmer-allow-backtracking-rerender')) {
- raise = function (message, test) {
- _emberMetalDebug.deprecate(message, test, { id: 'ember-views.render-double-modify', until: '3.0.0' });
- };
+ /**
+ Previously we used `Ember.$.uuid`, however `$.uuid` has been removed from
+ jQuery master. We'll just bootstrap our own uuid now.
+
+ @private
+ @return {Number} the uuid
+ */
+ exports.uuid = uuid;
+ exports.intern = intern;
+ exports.generateGuid = generateGuid;
+ exports.guidFor = guidFor;
+ exports.wrap = wrap;
+ exports.tryInvoke = tryInvoke;
+ exports.makeArray = makeArray;
+ exports.inspect = inspect;
+ exports.applyStr = applyStr;
+ exports.lookupDescriptor = lookupDescriptor;
+ exports.toString = toString;
+ var _uuid = 0;
+
+ /**
+ Generates a universally unique identifier. This method
+ is used internally by Ember for assisting with
+ the generation of GUID's and other unique identifiers.
+
+ @public
+ @return {Number} [description]
+ */
+
+ function uuid() {
+ return ++_uuid;
}
- var implication = undefined;
- if (_emberMetalFeatures.default('ember-glimmer-allow-backtracking-rerender')) {
- implication = 'will be removed in Ember 3.0.';
- } else if (_emberMetalFeatures.default('ember-glimmer-detect-backtracking-rerender')) {
- implication = 'is no longer supported. See https://github.com/emberjs/ember.js/issues/13948 for more details.';
+ /**
+ Prefix used for guids through out Ember.
+ @private
+ @property GUID_PREFIX
+ @for Ember
+ @type String
+ @final
+ */
+ var GUID_PREFIX = 'ember';
+
+ // Used for guid generation...
+ var numberCache = [];
+ var stringCache = {};
+
+ /**
+ Strongly hint runtimes to intern the provided string.
+
+ When do I need to use this function?
+
+ For the most part, never. Pre-mature optimization is bad, and often the
+ runtime does exactly what you need it to, and more often the trade-off isn't
+ worth it.
+
+ Why?
+
+ Runtimes store strings in at least 2 different representations:
+ Ropes and Symbols (interned strings). The Rope provides a memory efficient
+ data-structure for strings created from concatenation or some other string
+ manipulation like splitting.
+
+ Unfortunately checking equality of different ropes can be quite costly as
+ runtimes must resort to clever string comparison algorithms. These
+ algorithms typically cost in proportion to the length of the string.
+ Luckily, this is where the Symbols (interned strings) shine. As Symbols are
+ unique by their string content, equality checks can be done by pointer
+ comparison.
+
+ How do I know if my string is a rope or symbol?
+
+ Typically (warning general sweeping statement, but truthy in runtimes at
+ present) static strings created as part of the JS source are interned.
+ Strings often used for comparisons can be interned at runtime if some
+ criteria are met. One of these criteria can be the size of the entire rope.
+ For example, in chrome 38 a rope longer then 12 characters will not
+ intern, nor will segments of that rope.
+
+ Some numbers: http://jsperf.com/eval-vs-keys/8
+
+ Known Trickâ„¢
+
+ @private
+ @return {String} interned version of the provided string
+ */
+
+ function intern(str) {
+ var obj = {};
+ obj[str] = 1;
+ for (var key in obj) {
+ if (key === str) {
+ return key;
+ }
+ }
+ return str;
}
- if (_emberMetalFeatures.default('ember-glimmer-detect-backtracking-rerender') || _emberMetalFeatures.default('ember-glimmer-allow-backtracking-rerender')) {
- (function () {
- var counter = 0;
- var inTransaction = false;
- var shouldReflush = undefined;
+ /**
+ A unique key used to assign guids and other private metadata to objects.
+ If you inspect an object in your browser debugger you will often see these.
+ They can be safely ignored.
+
+ On browsers that support it, these properties are added with enumeration
+ disabled so they won't show up when you iterate over your properties.
+
+ @private
+ @property GUID_KEY
+ @for Ember
+ @type String
+ @final
+ */
+ var GUID_KEY = intern('__ember' + +new Date());
- exports.default = runInTransaction = function (context, methodName) {
- shouldReflush = false;
- inTransaction = true;
- context[methodName]();
- inTransaction = false;
- counter++;
- return shouldReflush;
- };
+ var GUID_DESC = {
+ writable: true,
+ configurable: true,
+ enumerable: false,
+ value: null
+ };
- exports.didRender = didRender = function (object, key, reference) {
- if (!inTransaction) {
- return;
+ exports.GUID_DESC = GUID_DESC;
+ var nullDescriptor = {
+ configurable: true,
+ writable: true,
+ enumerable: false,
+ value: null
+ };
+
+ var GUID_KEY_PROPERTY = {
+ name: GUID_KEY,
+ descriptor: nullDescriptor
+ };
+
+ exports.GUID_KEY_PROPERTY = GUID_KEY_PROPERTY;
+ /**
+ Generates a new guid, optionally saving the guid to the object that you
+ pass in. You will rarely need to use this method. Instead you should
+ call `Ember.guidFor(obj)`, which return an existing guid if available.
+
+ @private
+ @method generateGuid
+ @for Ember
+ @param {Object} [obj] Object the guid will be used for. If passed in, the guid will
+ be saved on the object and reused whenever you pass the same object
+ again.
+
+ If no object is passed, just generate a new guid.
+ @param {String} [prefix] Prefix to place in front of the guid. Useful when you want to
+ separate the guid into separate namespaces.
+ @return {String} the guid
+ */
+
+ function generateGuid(obj, prefix) {
+ if (!prefix) {
+ prefix = GUID_PREFIX;
+ }
+
+ var ret = prefix + uuid();
+ if (obj) {
+ if (obj[GUID_KEY] === null) {
+ obj[GUID_KEY] = ret;
+ } else {
+ GUID_DESC.value = ret;
+ if (obj.__defineNonEnumerable) {
+ obj.__defineNonEnumerable(GUID_KEY_PROPERTY);
+ } else {
+ Object.defineProperty(obj, GUID_KEY, GUID_DESC);
}
- var meta = _emberMetalMeta.meta(object);
- var lastRendered = meta.writableLastRendered();
- lastRendered[key] = counter;
+ }
+ }
+ return ret;
+ }
- _emberMetalDebug.runInDebug(function () {
- var lastRenderedFrom = meta.writableLastRenderedFrom();
- lastRenderedFrom[key] = reference;
- });
- };
+ /**
+ Returns a unique id for the object. If the object does not yet have a guid,
+ one will be assigned to it. You can call this on any object,
+ `Ember.Object`-based or not, but be aware that it will add a `_guid`
+ property.
+
+ You can also use this method on DOM Element objects.
+
+ @public
+ @method guidFor
+ @for Ember
+ @param {Object} obj any object, string, number, Element, or primitive
+ @return {String} the unique guid for this instance.
+ */
- exports.assertNotRendered = assertNotRendered = function (object, key, _meta) {
- var meta = _meta || _emberMetalMeta.meta(object);
- var lastRendered = meta.readableLastRendered();
+ function guidFor(obj) {
+ if (obj && obj[GUID_KEY]) {
+ return obj[GUID_KEY];
+ }
- if (lastRendered && lastRendered[key] === counter) {
- raise((function () {
- var ref = meta.readableLastRenderedFrom();
- var parts = [];
- var lastRef = ref[key];
+ // special cases where we don't want to add a key to object
+ if (obj === undefined) {
+ return '(undefined)';
+ }
- var label = undefined;
+ if (obj === null) {
+ return '(null)';
+ }
- if (lastRef) {
- while (lastRef && lastRef._propertyKey) {
- parts.unshift(lastRef._propertyKey);
- lastRef = lastRef._parentReference;
- }
+ var ret = undefined;
+ var type = typeof obj;
- label = parts.join();
- } else {
- label = 'the same value';
- }
+ // Don't allow prototype changes to String etc. to change the guidFor
+ switch (type) {
+ case 'number':
+ ret = numberCache[obj];
- return 'You modified ' + parts.join('.') + ' twice on ' + object + ' in a single render. This was unreliable and slow in Ember 1.x and ' + implication;
- })(), false);
+ if (!ret) {
+ ret = numberCache[obj] = 'nu' + obj;
+ }
- shouldReflush = true;
+ return ret;
+
+ case 'string':
+ ret = stringCache[obj];
+
+ if (!ret) {
+ ret = stringCache[obj] = 'st' + uuid();
}
+
+ return ret;
+
+ case 'boolean':
+ return obj ? '(true)' : '(false)';
+
+ default:
+ if (obj === Object) {
+ return '(Object)';
+ }
+
+ if (obj === Array) {
+ return '(Array)';
+ }
+
+ ret = GUID_PREFIX + uuid();
+
+ if (obj[GUID_KEY] === null) {
+ obj[GUID_KEY] = ret;
+ } else {
+ GUID_DESC.value = ret;
+
+ if (obj.__defineNonEnumerable) {
+ obj.__defineNonEnumerable(GUID_KEY_PROPERTY);
+ } else {
+ Object.defineProperty(obj, GUID_KEY, GUID_DESC);
+ }
+ }
+ return ret;
+ }
+ }
+
+ var HAS_SUPER_PATTERN = /\.(_super|call\(this|apply\(this)/;
+ var fnToString = Function.prototype.toString;
+
+ var checkHasSuper = (function () {
+ var sourceAvailable = fnToString.call(function () {
+ return this;
+ }).indexOf('return this') > -1;
+
+ if (sourceAvailable) {
+ return function checkHasSuper(func) {
+ return HAS_SUPER_PATTERN.test(fnToString.call(func));
};
- })();
- } else {
- exports.default = runInTransaction = function () {
- throw new Error('Cannot call runInTransaction without Glimmer');
- };
+ }
- exports.didRender = didRender = function () {
- throw new Error('Cannot call didRender without Glimmer');
+ return function checkHasSuper() {
+ return true;
};
+ })();
- exports.assertNotRendered = assertNotRendered = function () {
- throw new Error('Cannot call assertNotRendered without Glimmer');
- };
+ exports.checkHasSuper = checkHasSuper;
+ function ROOT() {}
+ ROOT.__hasSuper = false;
+
+ function hasSuper(func) {
+ if (func.__hasSuper === undefined) {
+ func.__hasSuper = checkHasSuper(func);
+ }
+ return func.__hasSuper;
}
- exports.default = runInTransaction;
- exports.didRender = didRender;
- exports.assertNotRendered = assertNotRendered;
+ /**
+ Wraps the passed function so that `this._super` will point to the superFunc
+ when the function is invoked. This is the primitive we use to implement
+ calls to super.
+
+ @private
+ @method wrap
+ @for Ember
+ @param {Function} func The function to call
+ @param {Function} superFunc The super function.
+ @return {Function} wrapped function.
+ */
+
+ function wrap(func, superFunc) {
+ if (!hasSuper(func)) {
+ return func;
+ }
+ // ensure an unwrapped super that calls _super is wrapped with a terminal _super
+ if (!superFunc.wrappedFunction && hasSuper(superFunc)) {
+ return _wrap(func, _wrap(superFunc, ROOT));
+ }
+ return _wrap(func, superFunc);
+ }
+
+ function _wrap(func, superFunc) {
+ function superWrapper() {
+ var orig = this._super;
+ this._super = superFunc;
+ var ret = func.apply(this, arguments);
+ this._super = orig;
+ return ret;
+ }
+
+ superWrapper.wrappedFunction = func;
+ superWrapper.__ember_observes__ = func.__ember_observes__;
+ superWrapper.__ember_observesBefore__ = func.__ember_observesBefore__;
+ superWrapper.__ember_listens__ = func.__ember_listens__;
+
+ return superWrapper;
+ }
+
+ /**
+ Checks to see if the `methodName` exists on the `obj`.
+
+ ```javascript
+ let foo = { bar: function() { return 'bar'; }, baz: null };
+
+ Ember.canInvoke(foo, 'bar'); // true
+ Ember.canInvoke(foo, 'baz'); // false
+ Ember.canInvoke(foo, 'bat'); // false
+ ```
+
+ @method canInvoke
+ @for Ember
+ @param {Object} obj The object to check for the method
+ @param {String} methodName The method name to check for
+ @return {Boolean}
+ @private
+ */
+ function canInvoke(obj, methodName) {
+ return !!(obj && typeof obj[methodName] === 'function');
+ }
+
+ /**
+ Checks to see if the `methodName` exists on the `obj`,
+ and if it does, invokes it with the arguments passed.
+
+ ```javascript
+ let d = new Date('03/15/2013');
+
+ Ember.tryInvoke(d, 'getTime'); // 1363320000000
+ Ember.tryInvoke(d, 'setFullYear', [2014]); // 1394856000000
+ Ember.tryInvoke(d, 'noSuchMethod', [2014]); // undefined
+ ```
+
+ @method tryInvoke
+ @for Ember
+ @param {Object} obj The object to check for the method
+ @param {String} methodName The method name to check for
+ @param {Array} [args] The arguments to pass to the method
+ @return {*} the return value of the invoked method or undefined if it cannot be invoked
+ @public
+ */
+
+ function tryInvoke(obj, methodName, args) {
+ if (canInvoke(obj, methodName)) {
+ return args ? applyStr(obj, methodName, args) : applyStr(obj, methodName);
+ }
+ }
+
+ // ........................................
+ // TYPING & ARRAY MESSAGING
+ //
+
+ var objectToString = Object.prototype.toString;
+
+ /**
+ Forces the passed object to be part of an array. If the object is already
+ an array, it will return the object. Otherwise, it will add the object to
+ an array. If obj is `null` or `undefined`, it will return an empty array.
+
+ ```javascript
+ Ember.makeArray(); // []
+ Ember.makeArray(null); // []
+ Ember.makeArray(undefined); // []
+ Ember.makeArray('lindsay'); // ['lindsay']
+ Ember.makeArray([1, 2, 42]); // [1, 2, 42]
+
+ let controller = Ember.ArrayProxy.create({ content: [] });
+
+ Ember.makeArray(controller) === controller; // true
+ ```
+
+ @method makeArray
+ @for Ember
+ @param {Object} obj the object
+ @return {Array}
+ @private
+ */
+
+ function makeArray(obj) {
+ if (obj === null || obj === undefined) {
+ return [];
+ }
+ return Array.isArray(obj) ? obj : [obj];
+ }
+
+ /**
+ Convenience method to inspect an object. This method will attempt to
+ convert the object into a useful string description.
+
+ It is a pretty simple implementation. If you want something more robust,
+ use something like JSDump: https://github.com/NV/jsDump
+
+ @method inspect
+ @for Ember
+ @param {Object} obj The object you want to inspect.
+ @return {String} A description of the object
+ @since 1.4.0
+ @private
+ */
+
+ function inspect(obj) {
+ if (obj === null) {
+ return 'null';
+ }
+ if (obj === undefined) {
+ return 'undefined';
+ }
+ if (Array.isArray(obj)) {
+ return '[' + obj + ']';
+ }
+ // for non objects
+ var type = typeof obj;
+ if (type !== 'object' && type !== 'symbol') {
+ return '' + obj;
+ }
+ // overridden toString
+ if (typeof obj.toString === 'function' && obj.toString !== objectToString) {
+ return obj.toString();
+ }
+
+ // Object.prototype.toString === {}.toString
+ var v = undefined;
+ var ret = [];
+ for (var key in obj) {
+ if (obj.hasOwnProperty(key)) {
+ v = obj[key];
+ if (v === 'toString') {
+ continue;
+ } // ignore useless items
+ if (typeof v === 'function') {
+ v = 'function() { ... }';
+ }
+
+ if (v && typeof v.toString !== 'function') {
+ ret.push(key + ': ' + objectToString.call(v));
+ } else {
+ ret.push(key + ': ' + v);
+ }
+ }
+ }
+ return '{' + ret.join(', ') + '}';
+ }
+
+ /**
+ @param {Object} t target
+ @param {String} m method
+ @param {Array} a args
+ @private
+ */
+
+ function applyStr(t, m, a) {
+ var l = a && a.length;
+ if (!a || !l) {
+ return t[m]();
+ }
+ switch (l) {
+ case 1:
+ return t[m](a[0]);
+ case 2:
+ return t[m](a[0], a[1]);
+ case 3:
+ return t[m](a[0], a[1], a[2]);
+ case 4:
+ return t[m](a[0], a[1], a[2], a[3]);
+ case 5:
+ return t[m](a[0], a[1], a[2], a[3], a[4]);
+ default:
+ return t[m].apply(t, a);
+ }
+ }
+
+ function lookupDescriptor(obj, keyName) {
+ var current = obj;
+ while (current) {
+ var descriptor = Object.getOwnPropertyDescriptor(current, keyName);
+
+ if (descriptor) {
+ return descriptor;
+ }
+
+ current = Object.getPrototypeOf(current);
+ }
+
+ return null;
+ }
+
+ // A `toString` util function that supports objects without a `toString`
+ // method, e.g. an object created with `Object.create(null)`.
+
+ function toString(obj) {
+ if (obj && obj.toString) {
+ return obj.toString();
+ } else {
+ return objectToString.call(obj);
+ }
+ }
+
+ exports.GUID_KEY = GUID_KEY;
+ exports.makeArray = makeArray;
+ exports.canInvoke = canInvoke;
});
-enifed('ember-metal/watch_key', ['exports', 'ember-utils', 'ember-metal/features', 'ember-metal/meta', 'ember-metal/properties'], function (exports, _emberUtils, _emberMetalFeatures, _emberMetalMeta, _emberMetalProperties) {
+enifed('ember-metal/watch_key', ['exports', 'ember-metal/features', 'ember-metal/meta', 'ember-metal/properties', 'ember-metal/utils'], function (exports, _emberMetalFeatures, _emberMetalMeta, _emberMetalProperties, _emberMetalUtils) {
'use strict';
exports.watchKey = watchKey;
exports.unwatchKey = unwatchKey;
@@ -9936,11 +10664,11 @@
// Future traveler, although this code looks scary. It merely exists in
// development to aid in development asertions. Production builds of
// ember strip this entire block out
handleMandatorySetter = function handleMandatorySetter(m, obj, keyName) {
- var descriptor = _emberUtils.lookupDescriptor(obj, keyName);
+ var descriptor = _emberMetalUtils.lookupDescriptor(obj, keyName);
var configurable = descriptor ? descriptor.configurable : true;
var isWritable = descriptor ? descriptor.writable : true;
var hasValue = descriptor ? 'value' in descriptor : true;
var possibleDesc = descriptor && descriptor.value;
var isDescriptor = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor;
@@ -9996,11 +10724,11 @@
// Some further context: Once a property is watched by ember, bypassing `set`
// for mutation, will bypass observation. This code exists to assert when
// that occurs, and attempt to provide more helpful feedback. The alternative
// is tricky to debug partially observable properties.
if (!desc && keyName in obj) {
- var maybeMandatoryDescriptor = _emberUtils.lookupDescriptor(obj, keyName);
+ var maybeMandatoryDescriptor = _emberMetalUtils.lookupDescriptor(obj, keyName);
if (maybeMandatoryDescriptor.set && maybeMandatoryDescriptor.set.isMandatorySetter) {
if (maybeMandatoryDescriptor.get && maybeMandatoryDescriptor.get.isInheritingGetter) {
var possibleValue = m.readInheritedValue('values', keyName);
if (possibleValue === _emberMetalMeta.UNDEFINED) {
@@ -10167,11 +10895,11 @@
}
}
}
}
});
-enifed('ember-metal/weak_map', ['exports', 'ember-utils', 'ember-metal/meta'], function (exports, _emberUtils, _emberMetalMeta) {
+enifed('ember-metal/weak_map', ['exports', 'ember-metal/utils', 'ember-metal/meta'], function (exports, _emberMetalUtils, _emberMetalMeta) {
'use strict';
exports.default = WeakMap;
var id = 0;
@@ -10199,11 +10927,11 @@
function WeakMap(iterable) {
if (!(this instanceof WeakMap)) {
throw new TypeError('Constructor WeakMap requires \'new\'');
}
- this._id = _emberUtils.GUID_KEY + id++;
+ this._id = _emberMetalUtils.GUID_KEY + id++;
if (iterable === null || iterable === undefined) {
return;
} else if (Array.isArray(iterable)) {
for (var i = 0; i < iterable.length; i++) {
@@ -10448,11 +11176,11 @@
default:
return 0;
}
}
});
-enifed('ember-runtime/computed/computed_macros', ['exports', 'ember-metal'], function (exports, _emberMetal) {
+enifed('ember-runtime/computed/computed_macros', ['exports', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/computed', 'ember-metal/is_empty', 'ember-metal/is_none', 'ember-metal/alias', 'ember-metal/expand_properties'], function (exports, _emberMetalDebug, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalComputed, _emberMetalIs_empty, _emberMetalIs_none, _emberMetalAlias, _emberMetalExpand_properties) {
'use strict';
exports.empty = empty;
exports.notEmpty = notEmpty;
exports.none = none;
@@ -10480,13 +11208,13 @@
expandedProperties.push(entry);
}
for (var i = 0; i < properties.length; i++) {
var property = properties[i];
- _emberMetal.assert('Dependent keys passed to Ember.computed.' + predicateName + '() can\'t have spaces.', property.indexOf(' ') < 0);
+ _emberMetalDebug.assert('Dependent keys passed to Ember.computed.' + predicateName + '() can\'t have spaces.', property.indexOf(' ') < 0);
- _emberMetal.expandProperties(property, extractProperty);
+ _emberMetalExpand_properties.default(property, extractProperty);
}
return expandedProperties;
}
@@ -10496,21 +11224,21 @@
properties[_key] = arguments[_key];
}
var expandedProperties = expandPropertiesToArray(name, properties);
- var computedFunc = _emberMetal.computed(function () {
+ var computedFunc = _emberMetalComputed.computed(function () {
var lastIdx = expandedProperties.length - 1;
for (var i = 0; i < lastIdx; i++) {
- var value = _emberMetal.get(this, expandedProperties[i]);
+ var value = _emberMetalProperty_get.get(this, expandedProperties[i]);
if (!predicate(value)) {
return value;
}
}
- return _emberMetal.get(this, expandedProperties[lastIdx]);
+ return _emberMetalProperty_get.get(this, expandedProperties[lastIdx]);
});
return computedFunc.property.apply(computedFunc, expandedProperties);
};
}
@@ -10543,12 +11271,12 @@
the original value for property
@public
*/
function empty(dependentKey) {
- return _emberMetal.computed(dependentKey + '.length', function () {
- return _emberMetal.isEmpty(_emberMetal.get(this, dependentKey));
+ return _emberMetalComputed.computed(dependentKey + '.length', function () {
+ return _emberMetalIs_empty.default(_emberMetalProperty_get.get(this, dependentKey));
});
}
/**
A computed property that returns true if the value of the dependent
@@ -10575,12 +11303,12 @@
original value for property is not empty.
@public
*/
function notEmpty(dependentKey) {
- return _emberMetal.computed(dependentKey + '.length', function () {
- return !_emberMetal.isEmpty(_emberMetal.get(this, dependentKey));
+ return _emberMetalComputed.computed(dependentKey + '.length', function () {
+ return !_emberMetalIs_empty.default(_emberMetalProperty_get.get(this, dependentKey));
});
}
/**
A computed property that returns true if the value of the dependent
@@ -10610,12 +11338,12 @@
returns true if original value for property is null or undefined.
@public
*/
function none(dependentKey) {
- return _emberMetal.computed(dependentKey, function () {
- return _emberMetal.isNone(_emberMetal.get(this, dependentKey));
+ return _emberMetalComputed.computed(dependentKey, function () {
+ return _emberMetalIs_none.default(_emberMetalProperty_get.get(this, dependentKey));
});
}
/**
A computed property that returns the inverse boolean value
@@ -10642,12 +11370,12 @@
inverse of the original value for property
@public
*/
function not(dependentKey) {
- return _emberMetal.computed(dependentKey, function () {
- return !_emberMetal.get(this, dependentKey);
+ return _emberMetalComputed.computed(dependentKey, function () {
+ return !_emberMetalProperty_get.get(this, dependentKey);
});
}
/**
A computed property that converts the provided dependent property
@@ -10676,12 +11404,12 @@
to boolean the original value for property
@public
*/
function bool(dependentKey) {
- return _emberMetal.computed(dependentKey, function () {
- return !!_emberMetal.get(this, dependentKey);
+ return _emberMetalComputed.computed(dependentKey, function () {
+ return !!_emberMetalProperty_get.get(this, dependentKey);
});
}
/**
A computed property which matches the original value for the
@@ -10712,12 +11440,12 @@
the original value for property against a given RegExp
@public
*/
function match(dependentKey, regexp) {
- return _emberMetal.computed(dependentKey, function () {
- var value = _emberMetal.get(this, dependentKey);
+ return _emberMetalComputed.computed(dependentKey, function () {
+ var value = _emberMetalProperty_get.get(this, dependentKey);
return typeof value === 'string' ? regexp.test(value) : false;
});
}
@@ -10749,12 +11477,12 @@
the original value for property is equal to the given value.
@public
*/
function equal(dependentKey, value) {
- return _emberMetal.computed(dependentKey, function () {
- return _emberMetal.get(this, dependentKey) === value;
+ return _emberMetalComputed.computed(dependentKey, function () {
+ return _emberMetalProperty_get.get(this, dependentKey) === value;
});
}
/**
A computed property that returns true if the provided dependent property
@@ -10784,12 +11512,12 @@
the original value for property is greater than given value.
@public
*/
function gt(dependentKey, value) {
- return _emberMetal.computed(dependentKey, function () {
- return _emberMetal.get(this, dependentKey) > value;
+ return _emberMetalComputed.computed(dependentKey, function () {
+ return _emberMetalProperty_get.get(this, dependentKey) > value;
});
}
/**
A computed property that returns true if the provided dependent property
@@ -10819,12 +11547,12 @@
the original value for property is greater or equal then given value.
@public
*/
function gte(dependentKey, value) {
- return _emberMetal.computed(dependentKey, function () {
- return _emberMetal.get(this, dependentKey) >= value;
+ return _emberMetalComputed.computed(dependentKey, function () {
+ return _emberMetalProperty_get.get(this, dependentKey) >= value;
});
}
/**
A computed property that returns true if the provided dependent property
@@ -10854,12 +11582,12 @@
the original value for property is less then given value.
@public
*/
function lt(dependentKey, value) {
- return _emberMetal.computed(dependentKey, function () {
- return _emberMetal.get(this, dependentKey) < value;
+ return _emberMetalComputed.computed(dependentKey, function () {
+ return _emberMetalProperty_get.get(this, dependentKey) < value;
});
}
/**
A computed property that returns true if the provided dependent property
@@ -10889,12 +11617,12 @@
the original value for property is less or equal than given value.
@public
*/
function lte(dependentKey, value) {
- return _emberMetal.computed(dependentKey, function () {
- return _emberMetal.get(this, dependentKey) <= value;
+ return _emberMetalComputed.computed(dependentKey, function () {
+ return _emberMetalProperty_get.get(this, dependentKey) <= value;
});
}
/**
A computed property that performs a logical `and` on the
@@ -11039,11 +11767,11 @@
one way computed property to the original value for property.
@public
*/
function oneWay(dependentKey) {
- return _emberMetal.alias(dependentKey).oneWay();
+ return _emberMetalAlias.default(dependentKey).oneWay();
}
/**
This is a more semantically meaningful alias of `computed.oneWay`,
whose name is somewhat ambiguous as to which direction the data flows.
@@ -11091,11 +11819,11 @@
@since 1.5.0
@public
*/
function readOnly(dependentKey) {
- return _emberMetal.alias(dependentKey).readOnly();
+ return _emberMetalAlias.default(dependentKey).readOnly();
}
/**
Creates a new property that is an alias for another property
on an object. Calls to `get` or `set` this property behave as
@@ -11125,24 +11853,24 @@
@since 1.7.0
@public
*/
function deprecatingAlias(dependentKey, options) {
- return _emberMetal.computed(dependentKey, {
+ return _emberMetalComputed.computed(dependentKey, {
get: function (key) {
- _emberMetal.deprecate('Usage of `' + key + '` is deprecated, use `' + dependentKey + '` instead.', false, options);
- return _emberMetal.get(this, dependentKey);
+ _emberMetalDebug.deprecate('Usage of `' + key + '` is deprecated, use `' + dependentKey + '` instead.', false, options);
+ return _emberMetalProperty_get.get(this, dependentKey);
},
set: function (key, value) {
- _emberMetal.deprecate('Usage of `' + key + '` is deprecated, use `' + dependentKey + '` instead.', false, options);
- _emberMetal.set(this, dependentKey, value);
+ _emberMetalDebug.deprecate('Usage of `' + key + '` is deprecated, use `' + dependentKey + '` instead.', false, options);
+ _emberMetalProperty_set.set(this, dependentKey, value);
return value;
}
});
}
});
-enifed('ember-runtime/computed/reduce_computed_macros', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/compare', 'ember-runtime/utils', 'ember-runtime/system/native_array'], function (exports, _emberUtils, _emberMetal, _emberRuntimeCompare, _emberRuntimeUtils, _emberRuntimeSystemNative_array) {
+enifed('ember-runtime/computed/reduce_computed_macros', ['exports', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/error', 'ember-metal/computed', 'ember-metal/observer', 'ember-runtime/compare', 'ember-runtime/utils', 'ember-runtime/system/native_array', 'ember-metal/is_none', 'ember-metal/get_properties', 'ember-metal/empty_object', 'ember-metal/utils', 'ember-metal/weak_map'], function (exports, _emberMetalDebug, _emberMetalProperty_get, _emberMetalError, _emberMetalComputed, _emberMetalObserver, _emberRuntimeCompare, _emberRuntimeUtils, _emberRuntimeSystemNative_array, _emberMetalIs_none, _emberMetalGet_properties, _emberMetalEmpty_object, _emberMetalUtils, _emberMetalWeak_map) {
/**
@module ember
@submodule ember-runtime
*/
@@ -11161,14 +11889,14 @@
exports.setDiff = setDiff;
exports.collect = collect;
exports.sort = sort;
function reduceMacro(dependentKey, callback, initialValue) {
- return _emberMetal.computed(dependentKey + '.[]', function () {
+ return _emberMetalComputed.computed(dependentKey + '.[]', function () {
var _this = this;
- var arr = _emberMetal.get(this, dependentKey);
+ var arr = _emberMetalProperty_get.get(this, dependentKey);
if (arr === null || typeof arr !== 'object') {
return initialValue;
}
@@ -11186,12 +11914,12 @@
} else {
propertyName = dependentKey;
dependentKey += '.[]';
}
- return _emberMetal.computed(dependentKey, function () {
- var value = _emberMetal.get(this, propertyName);
+ return _emberMetalComputed.computed(dependentKey, function () {
+ var value = _emberMetalProperty_get.get(this, propertyName);
if (_emberRuntimeUtils.isArray(value)) {
return _emberRuntimeSystemNative_array.A(callback.call(this, value));
} else {
return _emberRuntimeSystemNative_array.A();
}
@@ -11205,11 +11933,11 @@
args.push(function () {
return _emberRuntimeSystemNative_array.A(callback.call(this, dependentKeys));
});
- return _emberMetal.computed.apply(this, args).readOnly();
+ return _emberMetalComputed.computed.apply(this, args).readOnly();
}
/**
A computed property that returns the sum of the values
in the dependent array.
@@ -11395,14 +12123,14 @@
@return {Ember.ComputedProperty} an array mapped to the specified key
@public
*/
function mapBy(dependentKey, propertyKey) {
- _emberMetal.assert('Ember.computed.mapBy expects a property string for its second argument, ' + 'perhaps you meant to use "map"', typeof propertyKey === 'string');
+ _emberMetalDebug.assert('Ember.computed.mapBy expects a property string for its second argument, ' + 'perhaps you meant to use "map"', typeof propertyKey === 'string');
return map(dependentKey + '.@each.' + propertyKey, function (item) {
- return _emberMetal.get(item, propertyKey);
+ return _emberMetalProperty_get.get(item, propertyKey);
});
}
/**
Filters the array by the callback.
@@ -11479,15 +12207,15 @@
function filterBy(dependentKey, propertyKey, value) {
var callback = undefined;
if (arguments.length === 2) {
callback = function (item) {
- return _emberMetal.get(item, propertyKey);
+ return _emberMetalProperty_get.get(item, propertyKey);
};
} else {
callback = function (item) {
- return _emberMetal.get(item, propertyKey) === value;
+ return _emberMetalProperty_get.get(item, propertyKey) === value;
};
}
return filter(dependentKey + '.@each.' + propertyKey, callback);
}
@@ -11532,11 +12260,11 @@
var _this2 = this;
var uniq = _emberRuntimeSystemNative_array.A();
dependentKeys.forEach(function (dependentKey) {
- var value = _emberMetal.get(_this2, dependentKey);
+ var value = _emberMetalProperty_get.get(_this2, dependentKey);
if (_emberRuntimeUtils.isArray(value)) {
value.forEach(function (item) {
if (uniq.indexOf(item) === -1) {
uniq.push(item);
}
@@ -11577,17 +12305,17 @@
unique elements from the dependent array
@public
*/
function uniqBy(dependentKey, propertyKey) {
- return _emberMetal.computed(dependentKey + '.[]', function () {
+ return _emberMetalComputed.computed(dependentKey + '.[]', function () {
var uniq = _emberRuntimeSystemNative_array.A();
- var seen = new _emberUtils.EmptyObject();
- var list = _emberMetal.get(this, dependentKey);
+ var seen = new _emberMetalEmpty_object.default();
+ var list = _emberMetalProperty_get.get(this, dependentKey);
if (_emberRuntimeUtils.isArray(list)) {
list.forEach(function (item) {
- var guid = _emberUtils.guidFor(_emberMetal.get(item, propertyKey));
+ var guid = _emberMetalUtils.guidFor(_emberMetalProperty_get.get(item, propertyKey));
if (!(guid in seen)) {
seen[guid] = true;
uniq.push(item);
}
});
@@ -11641,11 +12369,11 @@
return multiArrayMacro(args, function (dependentKeys) {
var _this3 = this;
var arrays = dependentKeys.map(function (dependentKey) {
- var array = _emberMetal.get(_this3, dependentKey);
+ var array = _emberMetalProperty_get.get(_this3, dependentKey);
return _emberRuntimeUtils.isArray(array) ? array : [];
});
var results = arrays.pop().filter(function (candidate) {
@@ -11704,14 +12432,14 @@
@public
*/
function setDiff(setAProperty, setBProperty) {
if (arguments.length !== 2) {
- throw new _emberMetal.Error('setDiff requires exactly two dependent arrays.');
+ throw new _emberMetalError.default('setDiff requires exactly two dependent arrays.');
}
- return _emberMetal.computed(setAProperty + '.[]', setBProperty + '.[]', function () {
+ return _emberMetalComputed.computed(setAProperty + '.[]', setBProperty + '.[]', function () {
var setA = this.get(setAProperty);
var setB = this.get(setBProperty);
if (!_emberRuntimeUtils.isArray(setA)) {
return _emberRuntimeSystemNative_array.A();
@@ -11757,15 +12485,15 @@
for (var _len3 = arguments.length, dependentKeys = Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
dependentKeys[_key3] = arguments[_key3];
}
return multiArrayMacro(dependentKeys, function () {
- var properties = _emberMetal.getProperties(this, dependentKeys);
+ var properties = _emberMetalGet_properties.default(this, dependentKeys);
var res = _emberRuntimeSystemNative_array.A();
for (var key in properties) {
if (properties.hasOwnProperty(key)) {
- if (_emberMetal.isNone(properties[key])) {
+ if (_emberMetalIs_none.default(properties[key])) {
res.push(null);
} else {
res.push(properties[key]);
}
}
@@ -11839,11 +12567,11 @@
on the sort property array or callback function
@public
*/
function sort(itemsKey, sortDefinition) {
- _emberMetal.assert('Ember.computed.sort requires two arguments: an array key to sort and ' + 'either a sort properties key or sort function', arguments.length === 2);
+ _emberMetalDebug.assert('Ember.computed.sort requires two arguments: an array key to sort and ' + 'either a sort properties key or sort function', arguments.length === 2);
if (typeof sortDefinition === 'function') {
return customSort(itemsKey, sortDefinition);
} else {
return propertySort(itemsKey, sortDefinition);
@@ -11861,29 +12589,29 @@
}
// This one needs to dynamically set up and tear down observers on the itemsKey
// depending on the sortProperties
function propertySort(itemsKey, sortPropertiesKey) {
- var cp = new _emberMetal.ComputedProperty(function (key) {
+ var cp = new _emberMetalComputed.ComputedProperty(function (key) {
var _this5 = this;
var itemsKeyIsAtThis = itemsKey === '@this';
- var sortProperties = _emberMetal.get(this, sortPropertiesKey);
+ var sortProperties = _emberMetalProperty_get.get(this, sortPropertiesKey);
- _emberMetal.assert('The sort definition for \'' + key + '\' on ' + this + ' must be a function or an array of strings', _emberRuntimeUtils.isArray(sortProperties) && sortProperties.every(function (s) {
+ _emberMetalDebug.assert('The sort definition for \'' + key + '\' on ' + this + ' must be a function or an array of strings', _emberRuntimeUtils.isArray(sortProperties) && sortProperties.every(function (s) {
return typeof s === 'string';
}));
var normalizedSortProperties = normalizeSortProperties(sortProperties);
// Add/remove property observers as required.
- var activeObserversMap = cp._activeObserverMap || (cp._activeObserverMap = new _emberMetal.WeakMap());
+ var activeObserversMap = cp._activeObserverMap || (cp._activeObserverMap = new _emberMetalWeak_map.default());
var activeObservers = activeObserversMap.get(this);
if (activeObservers) {
activeObservers.forEach(function (args) {
- return _emberMetal.removeObserver.apply(null, args);
+ return _emberMetalObserver.removeObserver.apply(null, args);
});
}
function sortPropertyDidChange() {
this.notifyPropertyChange(key);
@@ -11892,18 +12620,18 @@
activeObservers = normalizedSortProperties.map(function (_ref) {
var prop = _ref[0];
var path = itemsKeyIsAtThis ? '@each.' + prop : itemsKey + '.@each.' + prop;
var args = [_this5, path, sortPropertyDidChange];
- _emberMetal.addObserver.apply(null, args);
+ _emberMetalObserver.addObserver.apply(null, args);
return args;
});
activeObserversMap.set(this, activeObservers);
// Sort and return the array.
- var items = itemsKeyIsAtThis ? this : _emberMetal.get(this, itemsKey);
+ var items = itemsKeyIsAtThis ? this : _emberMetalProperty_get.get(this, itemsKey);
if (_emberRuntimeUtils.isArray(items)) {
return sortByNormalizedSortProperties(items, normalizedSortProperties);
} else {
return _emberRuntimeSystemNative_array.A();
@@ -11933,21 +12661,21 @@
for (var i = 0; i < normalizedSortProperties.length; i++) {
var _normalizedSortProperties$i = normalizedSortProperties[i];
var prop = _normalizedSortProperties$i[0];
var direction = _normalizedSortProperties$i[1];
- var result = _emberRuntimeCompare.default(_emberMetal.get(itemA, prop), _emberMetal.get(itemB, prop));
+ var result = _emberRuntimeCompare.default(_emberMetalProperty_get.get(itemA, prop), _emberMetalProperty_get.get(itemB, prop));
if (result !== 0) {
return direction === 'desc' ? -1 * result : result;
}
}
return 0;
}));
}
});
-enifed('ember-runtime/controllers/controller', ['exports', 'ember-metal', 'ember-runtime/system/object', 'ember-runtime/mixins/controller', 'ember-runtime/inject', 'ember-runtime/mixins/action_handler'], function (exports, _emberMetal, _emberRuntimeSystemObject, _emberRuntimeMixinsController, _emberRuntimeInject, _emberRuntimeMixinsAction_handler) {
+enifed('ember-runtime/controllers/controller', ['exports', 'ember-metal/debug', 'ember-runtime/system/object', 'ember-runtime/mixins/controller', 'ember-runtime/inject', 'ember-runtime/mixins/action_handler'], function (exports, _emberMetalDebug, _emberRuntimeSystemObject, _emberRuntimeMixinsController, _emberRuntimeInject, _emberRuntimeMixinsAction_handler) {
'use strict';
/**
@module ember
@submodule ember-runtime
@@ -11963,11 +12691,11 @@
var Controller = _emberRuntimeSystemObject.default.extend(_emberRuntimeMixinsController.default);
_emberRuntimeMixinsAction_handler.deprecateUnderscoreActions(Controller);
function controllerInjectionHelper(factory) {
- _emberMetal.assert('Defining an injected controller property on a ' + 'non-controller is not allowed.', _emberRuntimeMixinsController.default.detect(factory.PrototypeMixin));
+ _emberMetalDebug.assert('Defining an injected controller property on a ' + 'non-controller is not allowed.', _emberRuntimeMixinsController.default.detect(factory.PrototypeMixin));
}
/**
Creates a property that lazily looks up another controller in the container.
Can only be used when defining another controller.
@@ -12001,11 +12729,11 @@
*/
_emberRuntimeInject.createInjectionHelper('controller', controllerInjectionHelper);
exports.default = Controller;
});
-enifed('ember-runtime/copy', ['exports', 'ember-metal', 'ember-runtime/system/object', 'ember-runtime/mixins/copyable'], function (exports, _emberMetal, _emberRuntimeSystemObject, _emberRuntimeMixinsCopyable) {
+enifed('ember-runtime/copy', ['exports', 'ember-metal/debug', 'ember-runtime/system/object', 'ember-runtime/mixins/copyable'], function (exports, _emberMetalDebug, _emberRuntimeSystemObject, _emberRuntimeMixinsCopyable) {
'use strict';
exports.default = copy;
function _copy(obj, deep, seen, copies) {
@@ -12021,11 +12749,11 @@
// avoid cyclical loops
if (deep && (loc = seen.indexOf(obj)) >= 0) {
return copies[loc];
}
- _emberMetal.assert('Cannot clone an Ember.Object that does not implement Ember.Copyable', !(obj instanceof _emberRuntimeSystemObject.default) || _emberRuntimeMixinsCopyable.default && _emberRuntimeMixinsCopyable.default.detect(obj));
+ _emberMetalDebug.assert('Cannot clone an Ember.Object that does not implement Ember.Copyable', !(obj instanceof _emberRuntimeSystemObject.default) || _emberRuntimeMixinsCopyable.default && _emberRuntimeMixinsCopyable.default.detect(obj));
// IMPORTANT: this specific test will detect a native array only. Any other
// object will need to implement Copyable.
if (Array.isArray(obj)) {
ret = obj.slice();
@@ -12098,11 +12826,11 @@
}
return _copy(obj, deep, deep ? [] : null, deep ? [] : null);
}
});
-enifed('ember-runtime/ext/function', ['exports', 'ember-environment', 'ember-metal'], function (exports, _emberEnvironment, _emberMetal) {
+enifed('ember-runtime/ext/function', ['exports', 'ember-environment', 'ember-metal/debug', 'ember-metal/computed', 'ember-metal/mixin'], function (exports, _emberEnvironment, _emberMetalDebug, _emberMetalComputed, _emberMetalMixin) {
/**
@module ember
@submodule ember-runtime
*/
@@ -12157,11 +12885,11 @@
@method property
@for Function
@public
*/
FunctionPrototype.property = function () {
- var ret = _emberMetal.computed(this);
+ var ret = _emberMetalComputed.computed(this);
// ComputedProperty.prototype.property expands properties; no need for us to
// do so here.
return ret.property.apply(ret, arguments);
};
@@ -12189,15 +12917,15 @@
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
args.push(this);
- return _emberMetal.observer.apply(this, args);
+ return _emberMetalMixin.observer.apply(this, args);
};
FunctionPrototype._observesImmediately = function () {
- _emberMetal.assert('Immediate observers must observe internal properties only, ' + 'not properties on other objects.', function checkIsInternalProperty() {
+ _emberMetalDebug.assert('Immediate observers must observe internal properties only, ' + 'not properties on other objects.', function checkIsInternalProperty() {
for (var i = 0; i < arguments.length; i++) {
if (arguments[i].indexOf('.') !== -1) {
return false;
}
}
@@ -12227,11 +12955,11 @@
@method observesImmediately
@for Function
@deprecated
@private
*/
- FunctionPrototype.observesImmediately = _emberMetal.deprecateFunc('Function#observesImmediately is deprecated. Use Function#observes instead', { id: 'ember-runtime.ext-function', until: '3.0.0' }, FunctionPrototype._observesImmediately);
+ FunctionPrototype.observesImmediately = _emberMetalDebug.deprecateFunc('Function#observesImmediately is deprecated. Use Function#observes instead', { id: 'ember-runtime.ext-function', until: '3.0.0' }, FunctionPrototype._observesImmediately);
/**
The `on` extension of Javascript's Function prototype is available
when `EmberENV.EXTEND_PROTOTYPES` or `EmberENV.EXTEND_PROTOTYPES.Function` is
true, which is the default.
@@ -12255,17 +12983,17 @@
return this;
};
}
});
-enifed('ember-runtime/ext/rsvp', ['exports', 'rsvp', 'ember-metal'], function (exports, _rsvp, _emberMetal) {
+enifed('ember-runtime/ext/rsvp', ['exports', 'rsvp', 'ember-metal/run_loop', 'ember-metal/debug', 'ember-metal/error_handler'], function (exports, _rsvp, _emberMetalRun_loop, _emberMetalDebug, _emberMetalError_handler) {
'use strict';
exports.onerrorDefault = onerrorDefault;
- var backburner = _emberMetal.run.backburner;
- _emberMetal.run._addQueue('rsvpAfter', 'destroy');
+ var backburner = _emberMetalRun_loop.default.backburner;
+ _emberMetalRun_loop.default._addQueue('rsvpAfter', 'destroy');
_rsvp.configure('async', function (callback, promise) {
backburner.schedule('actions', null, callback, promise);
});
@@ -12276,11 +13004,11 @@
_rsvp.on('error', onerrorDefault);
function onerrorDefault(reason) {
var error = errorFor(reason);
if (error) {
- _emberMetal.dispatchError(error);
+ _emberMetalError_handler.dispatchError(error);
}
}
function errorFor(reason) {
if (!reason) return;
@@ -12288,11 +13016,11 @@
if (reason.errorThrown) {
return unwrapErrorThrown(reason);
}
if (reason.name === 'UnrecognizedURLError') {
- _emberMetal.assert('The URL \'' + reason.message + '\' did not match any routes in your application', false);
+ _emberMetalDebug.assert('The URL \'' + reason.message + '\' did not match any routes in your application', false);
return;
}
if (reason.name === 'TransitionAborted') {
return;
@@ -12424,104 +13152,168 @@
StringPrototype.capitalize = function () {
return _emberRuntimeSystemString.capitalize(this);
};
}
});
-enifed('ember-runtime/index', ['exports', 'ember-runtime/ext/string', 'ember-runtime/ext/function', 'ember-runtime/system/object', 'ember-runtime/system/string', 'ember-runtime/mixins/registry_proxy', 'ember-runtime/mixins/container_proxy', 'ember-runtime/copy', 'ember-runtime/inject', 'ember-runtime/compare', 'ember-runtime/is-equal', 'ember-runtime/mixins/array', 'ember-runtime/mixins/comparable', 'ember-runtime/system/namespace', 'ember-runtime/system/array_proxy', 'ember-runtime/system/object_proxy', 'ember-runtime/system/core_object', 'ember-runtime/system/native_array', 'ember-runtime/mixins/action_handler', 'ember-runtime/mixins/copyable', 'ember-runtime/mixins/enumerable', 'ember-runtime/mixins/freezable', 'ember-runtime/mixins/-proxy', 'ember-runtime/system/lazy_load', 'ember-runtime/mixins/observable', 'ember-runtime/mixins/mutable_enumerable', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/target_action_support', 'ember-runtime/mixins/evented', 'ember-runtime/mixins/promise_proxy', 'ember-runtime/computed/computed_macros', 'ember-runtime/computed/reduce_computed_macros', 'ember-runtime/controllers/controller', 'ember-runtime/mixins/controller', 'ember-runtime/system/service', 'ember-runtime/ext/rsvp', 'ember-runtime/utils', 'ember-runtime/string_registry'], function (exports, _emberRuntimeExtString, _emberRuntimeExtFunction, _emberRuntimeSystemObject, _emberRuntimeSystemString, _emberRuntimeMixinsRegistry_proxy, _emberRuntimeMixinsContainer_proxy, _emberRuntimeCopy, _emberRuntimeInject, _emberRuntimeCompare, _emberRuntimeIsEqual, _emberRuntimeMixinsArray, _emberRuntimeMixinsComparable, _emberRuntimeSystemNamespace, _emberRuntimeSystemArray_proxy, _emberRuntimeSystemObject_proxy, _emberRuntimeSystemCore_object, _emberRuntimeSystemNative_array, _emberRuntimeMixinsAction_handler, _emberRuntimeMixinsCopyable, _emberRuntimeMixinsEnumerable, _emberRuntimeMixinsFreezable, _emberRuntimeMixinsProxy, _emberRuntimeSystemLazy_load, _emberRuntimeMixinsObservable, _emberRuntimeMixinsMutable_enumerable, _emberRuntimeMixinsMutable_array, _emberRuntimeMixinsTarget_action_support, _emberRuntimeMixinsEvented, _emberRuntimeMixinsPromise_proxy, _emberRuntimeComputedComputed_macros, _emberRuntimeComputedReduce_computed_macros, _emberRuntimeControllersController, _emberRuntimeMixinsController, _emberRuntimeSystemService, _emberRuntimeExtRsvp, _emberRuntimeUtils, _emberRuntimeString_registry) {
+enifed('ember-runtime/index', ['exports', 'ember-metal', 'ember-runtime/is-equal', 'ember-runtime/compare', 'ember-runtime/copy', 'ember-runtime/inject', 'ember-runtime/system/namespace', 'ember-runtime/system/object', 'ember-runtime/system/container', 'ember-runtime/system/array_proxy', 'ember-runtime/system/object_proxy', 'ember-runtime/system/core_object', 'ember-runtime/system/native_array', 'ember-runtime/system/string', 'ember-runtime/system/lazy_load', 'ember-runtime/mixins/array', 'ember-runtime/mixins/comparable', 'ember-runtime/mixins/copyable', 'ember-runtime/mixins/enumerable', 'ember-runtime/mixins/freezable', 'ember-runtime/mixins/-proxy', 'ember-runtime/mixins/observable', 'ember-runtime/mixins/action_handler', 'ember-runtime/mixins/mutable_enumerable', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/target_action_support', 'ember-runtime/mixins/evented', 'ember-runtime/mixins/promise_proxy', 'ember-metal/features', 'ember-runtime/computed/computed_macros', 'ember-runtime/computed/reduce_computed_macros', 'ember-runtime/controllers/controller', 'ember-runtime/mixins/controller', 'ember-runtime/system/service', 'ember-runtime/ext/rsvp', 'ember-runtime/ext/string', 'ember-runtime/ext/function', 'ember-runtime/utils', 'ember-runtime/mixins/registry_proxy', 'ember-runtime/mixins/container_proxy', 'ember-runtime/string_registry'], function (exports, _emberMetal, _emberRuntimeIsEqual, _emberRuntimeCompare, _emberRuntimeCopy, _emberRuntimeInject, _emberRuntimeSystemNamespace, _emberRuntimeSystemObject, _emberRuntimeSystemContainer, _emberRuntimeSystemArray_proxy, _emberRuntimeSystemObject_proxy, _emberRuntimeSystemCore_object, _emberRuntimeSystemNative_array, _emberRuntimeSystemString, _emberRuntimeSystemLazy_load, _emberRuntimeMixinsArray, _emberRuntimeMixinsComparable, _emberRuntimeMixinsCopyable, _emberRuntimeMixinsEnumerable, _emberRuntimeMixinsFreezable, _emberRuntimeMixinsProxy, _emberRuntimeMixinsObservable, _emberRuntimeMixinsAction_handler, _emberRuntimeMixinsMutable_enumerable, _emberRuntimeMixinsMutable_array, _emberRuntimeMixinsTarget_action_support, _emberRuntimeMixinsEvented, _emberRuntimeMixinsPromise_proxy, _emberMetalFeatures, _emberRuntimeComputedComputed_macros, _emberRuntimeComputedReduce_computed_macros, _emberRuntimeControllersController, _emberRuntimeMixinsController, _emberRuntimeSystemService, _emberRuntimeExtRsvp, _emberRuntimeExtString, _emberRuntimeExtFunction, _emberRuntimeUtils, _emberRuntimeMixinsRegistry_proxy, _emberRuntimeMixinsContainer_proxy, _emberRuntimeString_registry) {
/**
@module ember
@submodule ember-runtime
*/
+ // BEGIN IMPORTS
'use strict';
- exports.Object = _emberRuntimeSystemObject.default;
- exports.FrameworkObject = _emberRuntimeSystemObject.FrameworkObject;
- exports.String = _emberRuntimeSystemString.default;
- exports.RegistryProxyMixin = _emberRuntimeMixinsRegistry_proxy.default;
- exports.buildFakeRegistryWithDeprecations = _emberRuntimeMixinsRegistry_proxy.buildFakeRegistryWithDeprecations;
- exports.ContainerProxyMixin = _emberRuntimeMixinsContainer_proxy.default;
- exports.copy = _emberRuntimeCopy.default;
- exports.inject = _emberRuntimeInject.default;
- exports.compare = _emberRuntimeCompare.default;
- exports.isEqual = _emberRuntimeIsEqual.default;
- exports.Array = _emberRuntimeMixinsArray.default;
- exports.objectAt = _emberRuntimeMixinsArray.objectAt;
- exports.isEmberArray = _emberRuntimeMixinsArray.isEmberArray;
- exports.addArrayObserver = _emberRuntimeMixinsArray.addArrayObserver;
- exports.removeArrayObserver = _emberRuntimeMixinsArray.removeArrayObserver;
- exports.Comparable = _emberRuntimeMixinsComparable.default;
- exports.Namespace = _emberRuntimeSystemNamespace.default;
- exports.isNamespaceSearchDisabled = _emberRuntimeSystemNamespace.isSearchDisabled;
- exports.setNamespaceSearchDisabled = _emberRuntimeSystemNamespace.setSearchDisabled;
- exports.ArrayProxy = _emberRuntimeSystemArray_proxy.default;
- exports.ObjectProxy = _emberRuntimeSystemObject_proxy.default;
- exports.CoreObject = _emberRuntimeSystemCore_object.default;
- exports.NativeArray = _emberRuntimeSystemNative_array.default;
- exports.A = _emberRuntimeSystemNative_array.A;
- exports.ActionHandler = _emberRuntimeMixinsAction_handler.default;
- exports.deprecateUnderscoreActions = _emberRuntimeMixinsAction_handler.deprecateUnderscoreActions;
- exports.Copyable = _emberRuntimeMixinsCopyable.default;
- exports.Enumerable = _emberRuntimeMixinsEnumerable.default;
- exports.Freezable = _emberRuntimeMixinsFreezable.Freezable;
- exports.FROZEN_ERROR = _emberRuntimeMixinsFreezable.FROZEN_ERROR;
- exports._ProxyMixin = _emberRuntimeMixinsProxy.default;
- exports.isProxy = _emberRuntimeMixinsProxy.isProxy;
- exports.onLoad = _emberRuntimeSystemLazy_load.onLoad;
- exports.runLoadHooks = _emberRuntimeSystemLazy_load.runLoadHooks;
- exports._loaded = _emberRuntimeSystemLazy_load._loaded;
- exports.Observable = _emberRuntimeMixinsObservable.default;
- exports.MutableEnumerable = _emberRuntimeMixinsMutable_enumerable.default;
- exports.MutableArray = _emberRuntimeMixinsMutable_array.default;
- exports.removeAt = _emberRuntimeMixinsMutable_array.removeAt;
- exports.TargetActionSupport = _emberRuntimeMixinsTarget_action_support.default;
- exports.Evented = _emberRuntimeMixinsEvented.default;
- exports.PromiseProxyMixin = _emberRuntimeMixinsPromise_proxy.default;
- exports.empty = _emberRuntimeComputedComputed_macros.empty;
- exports.notEmpty = _emberRuntimeComputedComputed_macros.notEmpty;
- exports.none = _emberRuntimeComputedComputed_macros.none;
- exports.not = _emberRuntimeComputedComputed_macros.not;
- exports.bool = _emberRuntimeComputedComputed_macros.bool;
- exports.match = _emberRuntimeComputedComputed_macros.match;
- exports.equal = _emberRuntimeComputedComputed_macros.equal;
- exports.gt = _emberRuntimeComputedComputed_macros.gt;
- exports.gte = _emberRuntimeComputedComputed_macros.gte;
- exports.lt = _emberRuntimeComputedComputed_macros.lt;
- exports.lte = _emberRuntimeComputedComputed_macros.lte;
- exports.oneWay = _emberRuntimeComputedComputed_macros.oneWay;
- exports.readOnly = _emberRuntimeComputedComputed_macros.readOnly;
- exports.deprecatingAlias = _emberRuntimeComputedComputed_macros.deprecatingAlias;
- exports.and = _emberRuntimeComputedComputed_macros.and;
- exports.or = _emberRuntimeComputedComputed_macros.or;
- exports.sum = _emberRuntimeComputedReduce_computed_macros.sum;
- exports.min = _emberRuntimeComputedReduce_computed_macros.min;
- exports.max = _emberRuntimeComputedReduce_computed_macros.max;
- exports.map = _emberRuntimeComputedReduce_computed_macros.map;
- exports.sort = _emberRuntimeComputedReduce_computed_macros.sort;
- exports.setDiff = _emberRuntimeComputedReduce_computed_macros.setDiff;
- exports.mapBy = _emberRuntimeComputedReduce_computed_macros.mapBy;
- exports.filter = _emberRuntimeComputedReduce_computed_macros.filter;
- exports.filterBy = _emberRuntimeComputedReduce_computed_macros.filterBy;
- exports.uniq = _emberRuntimeComputedReduce_computed_macros.uniq;
- exports.uniqBy = _emberRuntimeComputedReduce_computed_macros.uniqBy;
- exports.union = _emberRuntimeComputedReduce_computed_macros.union;
- exports.intersect = _emberRuntimeComputedReduce_computed_macros.intersect;
- exports.collect = _emberRuntimeComputedReduce_computed_macros.collect;
- exports.Controller = _emberRuntimeControllersController.default;
- exports.ControllerMixin = _emberRuntimeMixinsController.default;
- exports.Service = _emberRuntimeSystemService.default;
- exports.RSVP = _emberRuntimeExtRsvp.default;
- exports.onerrorDefault = _emberRuntimeExtRsvp.onerrorDefault;
- // just for side effect of extending Ember.RSVP
- exports.isArray = _emberRuntimeUtils.isArray;
- exports.typeOf = _emberRuntimeUtils.typeOf;
- exports.getStrings = _emberRuntimeString_registry.getStrings;
- exports.setStrings = _emberRuntimeString_registry.setStrings;
+ // END IMPORTS
+
+ // BEGIN EXPORTS
+ _emberMetal.default.compare = _emberRuntimeCompare.default;
+ _emberMetal.default.copy = _emberRuntimeCopy.default;
+ _emberMetal.default.isEqual = _emberRuntimeIsEqual.default;
+
+ _emberMetal.default.inject = _emberRuntimeInject.default;
+
+ _emberMetal.default.Array = _emberRuntimeMixinsArray.default;
+
+ _emberMetal.default.Comparable = _emberRuntimeMixinsComparable.default;
+ _emberMetal.default.Copyable = _emberRuntimeMixinsCopyable.default;
+
+ _emberMetal.default.Freezable = _emberRuntimeMixinsFreezable.Freezable;
+ _emberMetal.default.FROZEN_ERROR = _emberRuntimeMixinsFreezable.FROZEN_ERROR;
+
+ _emberMetal.default.MutableEnumerable = _emberRuntimeMixinsMutable_enumerable.default;
+ _emberMetal.default.MutableArray = _emberRuntimeMixinsMutable_array.default;
+
+ _emberMetal.default.TargetActionSupport = _emberRuntimeMixinsTarget_action_support.default;
+ _emberMetal.default.Evented = _emberRuntimeMixinsEvented.default;
+
+ _emberMetal.default.PromiseProxyMixin = _emberRuntimeMixinsPromise_proxy.default;
+
+ _emberMetal.default.Observable = _emberRuntimeMixinsObservable.default;
+
+ _emberMetal.default.typeOf = _emberRuntimeUtils.typeOf;
+ _emberMetal.default.isArray = _emberRuntimeUtils.isArray;
+
+ // ES6TODO: this seems a less than ideal way/place to add properties to Ember.computed
+ var EmComputed = _emberMetal.default.computed;
+
+ EmComputed.empty = _emberRuntimeComputedComputed_macros.empty;
+ EmComputed.notEmpty = _emberRuntimeComputedComputed_macros.notEmpty;
+ EmComputed.none = _emberRuntimeComputedComputed_macros.none;
+ EmComputed.not = _emberRuntimeComputedComputed_macros.not;
+ EmComputed.bool = _emberRuntimeComputedComputed_macros.bool;
+ EmComputed.match = _emberRuntimeComputedComputed_macros.match;
+ EmComputed.equal = _emberRuntimeComputedComputed_macros.equal;
+ EmComputed.gt = _emberRuntimeComputedComputed_macros.gt;
+ EmComputed.gte = _emberRuntimeComputedComputed_macros.gte;
+ EmComputed.lt = _emberRuntimeComputedComputed_macros.lt;
+ EmComputed.lte = _emberRuntimeComputedComputed_macros.lte;
+ EmComputed.oneWay = _emberRuntimeComputedComputed_macros.oneWay;
+ EmComputed.reads = _emberRuntimeComputedComputed_macros.oneWay;
+ EmComputed.readOnly = _emberRuntimeComputedComputed_macros.readOnly;
+ EmComputed.defaultTo = _emberRuntimeComputedComputed_macros.defaultTo;
+ EmComputed.deprecatingAlias = _emberRuntimeComputedComputed_macros.deprecatingAlias;
+ EmComputed.and = _emberRuntimeComputedComputed_macros.and;
+ EmComputed.or = _emberRuntimeComputedComputed_macros.or;
+ EmComputed.any = _emberRuntimeComputedComputed_macros.any;
+
+ EmComputed.sum = _emberRuntimeComputedReduce_computed_macros.sum;
+ EmComputed.min = _emberRuntimeComputedReduce_computed_macros.min;
+ EmComputed.max = _emberRuntimeComputedReduce_computed_macros.max;
+ EmComputed.map = _emberRuntimeComputedReduce_computed_macros.map;
+ EmComputed.sort = _emberRuntimeComputedReduce_computed_macros.sort;
+ EmComputed.setDiff = _emberRuntimeComputedReduce_computed_macros.setDiff;
+ EmComputed.mapBy = _emberRuntimeComputedReduce_computed_macros.mapBy;
+ EmComputed.filter = _emberRuntimeComputedReduce_computed_macros.filter;
+ EmComputed.filterBy = _emberRuntimeComputedReduce_computed_macros.filterBy;
+ EmComputed.uniq = _emberRuntimeComputedReduce_computed_macros.uniq;
+
+ if (_emberMetalFeatures.default('ember-runtime-computed-uniq-by')) {
+ EmComputed.uniqBy = _emberRuntimeComputedReduce_computed_macros.uniqBy;
+ }
+
+ EmComputed.union = _emberRuntimeComputedReduce_computed_macros.union;
+ EmComputed.intersect = _emberRuntimeComputedReduce_computed_macros.intersect;
+ EmComputed.collect = _emberRuntimeComputedReduce_computed_macros.collect;
+
+ _emberMetal.default.String = _emberRuntimeSystemString.default;
+ _emberMetal.default.Object = _emberRuntimeSystemObject.default;
+ _emberMetal.default.Container = _emberRuntimeSystemContainer.Container;
+ _emberMetal.default.Registry = _emberRuntimeSystemContainer.Registry;
+
+ _emberMetal.default.getOwner = _emberRuntimeSystemContainer.getOwner;
+ _emberMetal.default.setOwner = _emberRuntimeSystemContainer.setOwner;
+
+ _emberMetal.default._RegistryProxyMixin = _emberRuntimeMixinsRegistry_proxy.default;
+ _emberMetal.default._ContainerProxyMixin = _emberRuntimeMixinsContainer_proxy.default;
+
+ _emberMetal.default.Namespace = _emberRuntimeSystemNamespace.default;
+ _emberMetal.default.Enumerable = _emberRuntimeMixinsEnumerable.default;
+ _emberMetal.default.ArrayProxy = _emberRuntimeSystemArray_proxy.default;
+ _emberMetal.default.ObjectProxy = _emberRuntimeSystemObject_proxy.default;
+ _emberMetal.default.ActionHandler = _emberRuntimeMixinsAction_handler.default;
+ _emberMetal.default.CoreObject = _emberRuntimeSystemCore_object.default;
+ _emberMetal.default.NativeArray = _emberRuntimeSystemNative_array.default;
+ // ES6TODO: Currently we must rely on the global from ember-metal/core to avoid circular deps
+ // Ember.A = A;
+ _emberMetal.default.onLoad = _emberRuntimeSystemLazy_load.onLoad;
+ _emberMetal.default.runLoadHooks = _emberRuntimeSystemLazy_load.runLoadHooks;
+
+ _emberMetal.default.Controller = _emberRuntimeControllersController.default;
+ _emberMetal.default.ControllerMixin = _emberRuntimeMixinsController.default;
+
+ _emberMetal.default.Service = _emberRuntimeSystemService.default;
+
+ _emberMetal.default._ProxyMixin = _emberRuntimeMixinsProxy.default;
+
+ _emberMetal.default.RSVP = _emberRuntimeExtRsvp.default;
+ // END EXPORTS
+
+ /**
+ Defines the hash of localized strings for the current language. Used by
+ the `Ember.String.loc()` helper. To localize, add string values to this
+ hash.
+
+ @property STRINGS
+ @for Ember
+ @type Object
+ @private
+ */
+ Object.defineProperty(_emberMetal.default, 'STRINGS', {
+ configurable: false,
+ get: _emberRuntimeString_registry.getStrings,
+ set: _emberRuntimeString_registry.setStrings
+ });
+
+ /**
+ Whether searching on the global for new Namespace instances is enabled.
+
+ This is only exported here as to not break any addons. Given the new
+ visit API, you will have issues if you treat this as a indicator of
+ booted.
+
+ Internally this is only exposing a flag in Namespace.
+
+ @property BOOTED
+ @for Ember
+ @type Boolean
+ @private
+ */
+ Object.defineProperty(_emberMetal.default, 'BOOTED', {
+ configurable: false,
+ enumerable: false,
+ get: _emberRuntimeSystemNamespace.isSearchDisabled,
+ set: _emberRuntimeSystemNamespace.setSearchDisabled
+ });
+
+ exports.default = _emberMetal.default;
});
+// reexports
+// just for side effect of extending Ember.RSVP
// just for side effect of extending String.prototype
// just for side effect of extending Function.prototype
-enifed('ember-runtime/inject', ['exports', 'ember-metal'], function (exports, _emberMetal) {
+enifed('ember-runtime/inject', ['exports', 'ember-metal/debug', 'ember-metal/injected_property'], function (exports, _emberMetalDebug, _emberMetalInjected_property) {
'use strict';
exports.default = inject;
exports.createInjectionHelper = createInjectionHelper;
exports.validatePropertyInjections = validatePropertyInjections;
@@ -12534,11 +13326,11 @@
@static
@public
*/
function inject() {
- _emberMetal.assert('Injected properties must be created through helpers, see \'' + Object.keys(inject).join('"', '"') + '\'');
+ _emberMetalDebug.assert('Injected properties must be created through helpers, see \'' + Object.keys(inject).join('"', '"') + '\'');
}
// Dictionary of injection validations by type, added to by `createInjectionHelper`
var typeValidators = {};
@@ -12557,11 +13349,11 @@
function createInjectionHelper(type, validator) {
typeValidators[type] = validator;
inject[type] = function (name) {
- return new _emberMetal.InjectedProperty(type, name);
+ return new _emberMetalInjected_property.default(type, name);
};
}
/**
Validation function that runs per-type validation functions once for each
@@ -12578,11 +13370,11 @@
var proto = factory.proto();
var types = [];
for (var key in proto) {
var desc = proto[key];
- if (desc instanceof _emberMetal.InjectedProperty && types.indexOf(desc.type) === -1) {
+ if (desc instanceof _emberMetalInjected_property.default && types.indexOf(desc.type) === -1) {
types.push(desc.type);
}
}
if (types.length) {
@@ -12651,11 +13443,11 @@
}
return a === b;
}
});
-enifed('ember-runtime/mixins/-proxy', ['exports', 'glimmer-reference', 'ember-utils', 'ember-metal', 'ember-runtime/computed/computed_macros'], function (exports, _glimmerReference, _emberUtils, _emberMetal, _emberRuntimeComputedComputed_macros) {
+enifed('ember-runtime/mixins/-proxy', ['exports', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/meta', 'ember-metal/observer', 'ember-metal/property_events', 'ember-runtime/computed/computed_macros', 'ember-metal/properties', 'ember-metal/mixin', 'ember-metal/symbol'], function (exports, _emberMetalDebug, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalMeta, _emberMetalObserver, _emberMetalProperty_events, _emberRuntimeComputedComputed_macros, _emberMetalProperties, _emberMetalMixin, _emberMetalSymbol) {
/**
@module ember
@submodule ember-runtime
*/
@@ -12663,114 +13455,81 @@
var _Mixin$create;
exports.isProxy = isProxy;
- var IS_PROXY = _emberUtils.symbol('IS_PROXY');
+ var IS_PROXY = _emberMetalSymbol.default('IS_PROXY');
function isProxy(value) {
- return typeof value === 'object' && value && value[IS_PROXY];
+ return value && value[IS_PROXY];
}
function contentPropertyWillChange(content, contentKey) {
var key = contentKey.slice(8); // remove "content."
if (key in this) {
return;
} // if shadowed in proxy
- _emberMetal.propertyWillChange(this, key);
+ _emberMetalProperty_events.propertyWillChange(this, key);
}
function contentPropertyDidChange(content, contentKey) {
var key = contentKey.slice(8); // remove "content."
if (key in this) {
return;
} // if shadowed in proxy
- _emberMetal.propertyDidChange(this, key);
+ _emberMetalProperty_events.propertyDidChange(this, key);
}
- var ProxyTag = (function (_CachedTag) {
- babelHelpers.inherits(ProxyTag, _CachedTag);
-
- function ProxyTag(proxy) {
- _CachedTag.call(this);
-
- var content = _emberMetal.get(proxy, 'content');
-
- this.proxy = proxy;
- this.proxyWrapperTag = new _glimmerReference.DirtyableTag();
- this.proxyContentTag = new _glimmerReference.UpdatableTag(_emberMetal.tagFor(content));
- }
-
- /**
- `Ember.ProxyMixin` forwards all properties not defined by the proxy itself
- to a proxied `content` object. See Ember.ObjectProxy for more details.
-
- @class ProxyMixin
- @namespace Ember
- @private
- */
-
- ProxyTag.prototype.compute = function compute() {
- return Math.max(this.proxyWrapperTag.value(), this.proxyContentTag.value());
- };
-
- ProxyTag.prototype.dirty = function dirty() {
- this.proxyWrapperTag.dirty();
- };
-
- ProxyTag.prototype.contentDidChange = function contentDidChange() {
- var content = _emberMetal.get(this.proxy, 'content');
- this.proxyContentTag.update(_emberMetal.tagFor(content));
- };
-
- return ProxyTag;
- })(_glimmerReference.CachedTag);
-
- exports.default = _emberMetal.Mixin.create((_Mixin$create = {}, _Mixin$create[IS_PROXY] = true, _Mixin$create.content = null, _Mixin$create._initializeTag = _emberMetal.on('init', function () {
- _emberMetal.meta(this)._tag = new ProxyTag(this);
- }), _Mixin$create._contentDidChange = _emberMetal.observer('content', function () {
- _emberMetal.assert('Can\'t set Proxy\'s content to itself', _emberMetal.get(this, 'content') !== this);
- _emberMetal.tagFor(this).contentDidChange();
+ /**
+ `Ember.ProxyMixin` forwards all properties not defined by the proxy itself
+ to a proxied `content` object. See Ember.ObjectProxy for more details.
+
+ @class ProxyMixin
+ @namespace Ember
+ @private
+ */
+ exports.default = _emberMetalMixin.Mixin.create((_Mixin$create = {}, _Mixin$create[IS_PROXY] = true, _Mixin$create.content = null, _Mixin$create._contentDidChange = _emberMetalMixin.observer('content', function () {
+ _emberMetalDebug.assert('Can\'t set Proxy\'s content to itself', _emberMetalProperty_get.get(this, 'content') !== this);
}), _Mixin$create.isTruthy = _emberRuntimeComputedComputed_macros.bool('content'), _Mixin$create._debugContainerKey = null, _Mixin$create.willWatchProperty = function (key) {
var contentKey = 'content.' + key;
- _emberMetal._addBeforeObserver(this, contentKey, null, contentPropertyWillChange);
- _emberMetal.addObserver(this, contentKey, null, contentPropertyDidChange);
+ _emberMetalObserver._addBeforeObserver(this, contentKey, null, contentPropertyWillChange);
+ _emberMetalObserver.addObserver(this, contentKey, null, contentPropertyDidChange);
}, _Mixin$create.didUnwatchProperty = function (key) {
var contentKey = 'content.' + key;
- _emberMetal._removeBeforeObserver(this, contentKey, null, contentPropertyWillChange);
- _emberMetal.removeObserver(this, contentKey, null, contentPropertyDidChange);
+ _emberMetalObserver._removeBeforeObserver(this, contentKey, null, contentPropertyWillChange);
+ _emberMetalObserver.removeObserver(this, contentKey, null, contentPropertyDidChange);
}, _Mixin$create.unknownProperty = function (key) {
- var content = _emberMetal.get(this, 'content');
+ var content = _emberMetalProperty_get.get(this, 'content');
if (content) {
- _emberMetal.deprecate('You attempted to access `' + key + '` from `' + this + '`, but object proxying is deprecated. Please use `model.' + key + '` instead.', !this.isController, { id: 'ember-runtime.controller-proxy', until: '3.0.0' });
- return _emberMetal.get(content, key);
+ _emberMetalDebug.deprecate('You attempted to access `' + key + '` from `' + this + '`, but object proxying is deprecated. Please use `model.' + key + '` instead.', !this.isController, { id: 'ember-runtime.controller-proxy', until: '3.0.0' });
+ return _emberMetalProperty_get.get(content, key);
}
}, _Mixin$create.setUnknownProperty = function (key, value) {
- var m = _emberMetal.meta(this);
+ var m = _emberMetalMeta.meta(this);
if (m.proto === this) {
// if marked as prototype then just defineProperty
// rather than delegate
- _emberMetal.defineProperty(this, key, null, value);
+ _emberMetalProperties.defineProperty(this, key, null, value);
return value;
}
- var content = _emberMetal.get(this, 'content');
- _emberMetal.assert('Cannot delegate set(\'' + key + '\', ' + value + ') to the \'content\' property of object proxy ' + this + ': its \'content\' is undefined.', content);
+ var content = _emberMetalProperty_get.get(this, 'content');
+ _emberMetalDebug.assert('Cannot delegate set(\'' + key + '\', ' + value + ') to the \'content\' property of object proxy ' + this + ': its \'content\' is undefined.', content);
- _emberMetal.deprecate('You attempted to set `' + key + '` from `' + this + '`, but object proxying is deprecated. Please use `model.' + key + '` instead.', !this.isController, { id: 'ember-runtime.controller-proxy', until: '3.0.0' });
- return _emberMetal.set(content, key, value);
+ _emberMetalDebug.deprecate('You attempted to set `' + key + '` from `' + this + '`, but object proxying is deprecated. Please use `model.' + key + '` instead.', !this.isController, { id: 'ember-runtime.controller-proxy', until: '3.0.0' });
+ return _emberMetalProperty_set.set(content, key, value);
}, _Mixin$create));
});
/**
The object whose properties will be forwarded.
@property content
@type Ember.Object
@default null
@private
*/
-enifed('ember-runtime/mixins/action_handler', ['exports', 'ember-metal'], function (exports, _emberMetal) {
+enifed('ember-runtime/mixins/action_handler', ['exports', 'ember-metal/debug', 'ember-metal/mixin', 'ember-metal/property_get'], function (exports, _emberMetalDebug, _emberMetalMixin, _emberMetalProperty_get) {
/**
@module ember
@submodule ember-runtime
*/
@@ -12778,20 +13537,20 @@
exports.deprecateUnderscoreActions = deprecateUnderscoreActions;
/**
`Ember.ActionHandler` is available on some familiar classes including
- `Ember.Route`, `Ember.Component`, and `Ember.Controller`.
+ `Ember.Route`, `Ember.View`, `Ember.Component`, and `Ember.Controller`.
(Internally the mixin is used by `Ember.CoreView`, `Ember.ControllerMixin`,
and `Ember.Route` and available to the above classes through
inheritance.)
@class ActionHandler
@namespace Ember
@private
*/
- var ActionHandler = _emberMetal.Mixin.create({
+ var ActionHandler = _emberMetalMixin.Mixin.create({
mergedProperties: ['actions'],
/**
The collection of functions, keyed by name, available on this
`ActionHandler` as action targets.
@@ -12821,12 +13580,12 @@
// to both actions, since the actions hash is merged rather
// then replaced when extending mixins / parent classes.
this.send('displayBanner');
this.send('playMusic');
```
- Within a Controller, Route or Component's action handler,
- the value of the `this` context is the Controller, Route or
+ Within a Controller, Route, View or Component's action handler,
+ the value of the `this` context is the Controller, Route, View or
Component object:
```js
App.SongRoute = Ember.Route.extend({
actions: {
myAction() {
@@ -12931,23 +13690,23 @@
if (!shouldBubble) {
return;
}
}
- if (target = _emberMetal.get(this, 'target')) {
+ if (target = _emberMetalProperty_get.get(this, 'target')) {
var _target;
- _emberMetal.assert('The `target` for ' + this + ' (' + target + ') does not have a `send` method', typeof target.send === 'function');
+ _emberMetalDebug.assert('The `target` for ' + this + ' (' + target + ') does not have a `send` method', typeof target.send === 'function');
(_target = target).send.apply(_target, arguments);
}
},
willMergeMixin: function (props) {
- _emberMetal.assert('Specifying `_actions` and `actions` in the same mixin is not supported.', !props.actions || !props._actions);
+ _emberMetalDebug.assert('Specifying `_actions` and `actions` in the same mixin is not supported.', !props.actions || !props._actions);
if (props._actions) {
- _emberMetal.deprecate('Specifying actions in `_actions` is deprecated, please use `actions` instead.', false, { id: 'ember-runtime.action-handler-_actions', until: '3.0.0' });
+ _emberMetalDebug.deprecate('Specifying actions in `_actions` is deprecated, please use `actions` instead.', false, { id: 'ember-runtime.action-handler-_actions', until: '3.0.0' });
props.actions = props._actions;
delete props._actions;
}
}
@@ -12958,20 +13717,20 @@
function deprecateUnderscoreActions(factory) {
Object.defineProperty(factory.prototype, '_actions', {
configurable: true,
enumerable: false,
set: function (value) {
- _emberMetal.assert('You cannot set `_actions` on ' + this + ', please use `actions` instead.');
+ _emberMetalDebug.assert('You cannot set `_actions` on ' + this + ', please use `actions` instead.');
},
get: function () {
- _emberMetal.deprecate('Usage of `_actions` is deprecated, use `actions` instead.', false, { id: 'ember-runtime.action-handler-_actions', until: '3.0.0' });
- return _emberMetal.get(this, 'actions');
+ _emberMetalDebug.deprecate('Usage of `_actions` is deprecated, use `actions` instead.', false, { id: 'ember-runtime.action-handler-_actions', until: '3.0.0' });
+ return _emberMetalProperty_get.get(this, 'actions');
}
});
}
});
-enifed('ember-runtime/mixins/array', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/mixins/enumerable', 'ember-runtime/system/each_proxy'], function (exports, _emberUtils, _emberMetal, _emberRuntimeMixinsEnumerable, _emberRuntimeSystemEach_proxy) {
+enifed('ember-runtime/mixins/array', ['exports', 'ember-metal/core', 'ember-metal/symbol', 'ember-metal/property_get', 'ember-metal/computed', 'ember-metal/is_none', 'ember-runtime/mixins/enumerable', 'ember-metal/mixin', 'ember-metal/property_events', 'ember-metal/events', 'ember-metal/meta', 'ember-metal/tags', 'ember-runtime/system/each_proxy', 'ember-metal/debug', 'ember-metal/features'], function (exports, _emberMetalCore, _emberMetalSymbol, _emberMetalProperty_get, _emberMetalComputed, _emberMetalIs_none, _emberRuntimeMixinsEnumerable, _emberMetalMixin, _emberMetalProperty_events, _emberMetalEvents, _emberMetalMeta, _emberMetalTags, _emberRuntimeSystemEach_proxy, _emberMetalDebug, _emberMetalFeatures) {
/**
@module ember
@submodule ember-runtime
*/
@@ -12990,32 +13749,32 @@
exports.isEmberArray = isEmberArray;
function arrayObserversHelper(obj, target, opts, operation, notify) {
var willChange = opts && opts.willChange || 'arrayWillChange';
var didChange = opts && opts.didChange || 'arrayDidChange';
- var hasObservers = _emberMetal.get(obj, 'hasArrayObservers');
+ var hasObservers = _emberMetalProperty_get.get(obj, 'hasArrayObservers');
if (hasObservers === notify) {
- _emberMetal.propertyWillChange(obj, 'hasArrayObservers');
+ _emberMetalProperty_events.propertyWillChange(obj, 'hasArrayObservers');
}
operation(obj, '@array:before', target, willChange);
operation(obj, '@array:change', target, didChange);
if (hasObservers === notify) {
- _emberMetal.propertyDidChange(obj, 'hasArrayObservers');
+ _emberMetalProperty_events.propertyDidChange(obj, 'hasArrayObservers');
}
return obj;
}
function addArrayObserver(array, target, opts) {
- return arrayObserversHelper(array, target, opts, _emberMetal.addListener, false);
+ return arrayObserversHelper(array, target, opts, _emberMetalEvents.addListener, false);
}
function removeArrayObserver(array, target, opts) {
- return arrayObserversHelper(array, target, opts, _emberMetal.removeListener, true);
+ return arrayObserversHelper(array, target, opts, _emberMetalEvents.removeListener, true);
}
function objectAt(content, idx) {
if (content.objectAt) {
return content.objectAt(idx);
@@ -13044,13 +13803,13 @@
if (array.__each) {
array.__each.arrayWillChange(array, startIdx, removeAmt, addAmt);
}
- _emberMetal.sendEvent(array, '@array:before', [array, startIdx, removeAmt, addAmt]);
+ _emberMetalEvents.sendEvent(array, '@array:before', [array, startIdx, removeAmt, addAmt]);
- if (startIdx >= 0 && removeAmt >= 0 && _emberMetal.get(array, 'hasEnumerableObservers')) {
+ if (startIdx >= 0 && removeAmt >= 0 && _emberMetalProperty_get.get(array, 'hasEnumerableObservers')) {
removing = [];
lim = startIdx + removeAmt;
for (var idx = startIdx; idx < lim; idx++) {
removing.push(objectAt(array, idx));
@@ -13063,11 +13822,11 @@
return array;
}
function arrayContentDidChange(array, startIdx, removeAmt, addAmt) {
- _emberMetal.markObjectAsDirty(_emberMetal.meta(array));
+ _emberMetalTags.markObjectAsDirty(_emberMetalMeta.meta(array));
// if no args are passed assume everything changes
if (startIdx === undefined) {
startIdx = 0;
removeAmt = addAmt = -1;
@@ -13080,11 +13839,11 @@
addAmt = -1;
}
}
var adding = undefined;
- if (startIdx >= 0 && addAmt >= 0 && _emberMetal.get(array, 'hasEnumerableObservers')) {
+ if (startIdx >= 0 && addAmt >= 0 && _emberMetalProperty_get.get(array, 'hasEnumerableObservers')) {
adding = [];
var lim = startIdx + addAmt;
for (var idx = startIdx; idx < lim; idx++) {
adding.push(objectAt(array, idx));
@@ -13097,30 +13856,30 @@
if (array.__each) {
array.__each.arrayDidChange(array, startIdx, removeAmt, addAmt);
}
- _emberMetal.sendEvent(array, '@array:change', [array, startIdx, removeAmt, addAmt]);
+ _emberMetalEvents.sendEvent(array, '@array:change', [array, startIdx, removeAmt, addAmt]);
- var length = _emberMetal.get(array, 'length');
- var cachedFirst = _emberMetal.cacheFor(array, 'firstObject');
- var cachedLast = _emberMetal.cacheFor(array, 'lastObject');
+ var length = _emberMetalProperty_get.get(array, 'length');
+ var cachedFirst = _emberMetalComputed.cacheFor(array, 'firstObject');
+ var cachedLast = _emberMetalComputed.cacheFor(array, 'lastObject');
if (objectAt(array, 0) !== cachedFirst) {
- _emberMetal.propertyWillChange(array, 'firstObject');
- _emberMetal.propertyDidChange(array, 'firstObject');
+ _emberMetalProperty_events.propertyWillChange(array, 'firstObject');
+ _emberMetalProperty_events.propertyDidChange(array, 'firstObject');
}
if (objectAt(array, length - 1) !== cachedLast) {
- _emberMetal.propertyWillChange(array, 'lastObject');
- _emberMetal.propertyDidChange(array, 'lastObject');
+ _emberMetalProperty_events.propertyWillChange(array, 'lastObject');
+ _emberMetalProperty_events.propertyDidChange(array, 'lastObject');
}
return array;
}
- var EMBER_ARRAY = _emberUtils.symbol('EMBER_ARRAY');
+ var EMBER_ARRAY = _emberMetalSymbol.default('EMBER_ARRAY');
function isEmberArray(obj) {
return obj && !!obj[EMBER_ARRAY];
}
@@ -13162,51 +13921,51 @@
@namespace Ember
@uses Ember.Enumerable
@since Ember 0.9.0
@public
*/
- var ArrayMixin = _emberMetal.Mixin.create(_emberRuntimeMixinsEnumerable.default, (_Mixin$create = {}, _Mixin$create[EMBER_ARRAY] = true, _Mixin$create.length = null, _Mixin$create.objectAt = function (idx) {
- if (idx < 0 || idx >= _emberMetal.get(this, 'length')) {
+ var ArrayMixin = _emberMetalMixin.Mixin.create(_emberRuntimeMixinsEnumerable.default, (_Mixin$create = {}, _Mixin$create[EMBER_ARRAY] = true, _Mixin$create.length = null, _Mixin$create.objectAt = function (idx) {
+ if (idx < 0 || idx >= _emberMetalProperty_get.get(this, 'length')) {
return undefined;
}
- return _emberMetal.get(this, idx);
+ return _emberMetalProperty_get.get(this, idx);
}, _Mixin$create.objectsAt = function (indexes) {
var _this = this;
return indexes.map(function (idx) {
return objectAt(_this, idx);
});
}, _Mixin$create.nextObject = function (idx) {
return objectAt(this, idx);
- }, _Mixin$create['[]'] = _emberMetal.computed({
+ }, _Mixin$create['[]'] = _emberMetalComputed.computed({
get: function (key) {
return this;
},
set: function (key, value) {
- this.replace(0, _emberMetal.get(this, 'length'), value);
+ this.replace(0, _emberMetalProperty_get.get(this, 'length'), value);
return this;
}
- }), _Mixin$create.firstObject = _emberMetal.computed(function () {
+ }), _Mixin$create.firstObject = _emberMetalComputed.computed(function () {
return objectAt(this, 0);
- }).readOnly(), _Mixin$create.lastObject = _emberMetal.computed(function () {
- return objectAt(this, _emberMetal.get(this, 'length') - 1);
+ }).readOnly(), _Mixin$create.lastObject = _emberMetalComputed.computed(function () {
+ return objectAt(this, _emberMetalProperty_get.get(this, 'length') - 1);
}).readOnly(), _Mixin$create.contains = function (obj) {
- if (_emberMetal.isFeatureEnabled('ember-runtime-enumerable-includes')) {
- _emberMetal.deprecate('`Enumerable#contains` is deprecated, use `Enumerable#includes` instead.', false, { id: 'ember-runtime.enumerable-contains', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_enumerable-contains' });
+ if (_emberMetalFeatures.default('ember-runtime-enumerable-includes')) {
+ _emberMetalDebug.deprecate('`Enumerable#contains` is deprecated, use `Enumerable#includes` instead.', false, { id: 'ember-runtime.enumerable-contains', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_enumerable-contains' });
}
return this.indexOf(obj) >= 0;
}, _Mixin$create.slice = function (beginIndex, endIndex) {
- var ret = _emberMetal.default.A();
- var length = _emberMetal.get(this, 'length');
+ var ret = _emberMetalCore.default.A();
+ var length = _emberMetalProperty_get.get(this, 'length');
- if (_emberMetal.isNone(beginIndex)) {
+ if (_emberMetalIs_none.default(beginIndex)) {
beginIndex = 0;
}
- if (_emberMetal.isNone(endIndex) || endIndex > length) {
+ if (_emberMetalIs_none.default(endIndex) || endIndex > length) {
endIndex = length;
}
if (beginIndex < 0) {
beginIndex = length + beginIndex;
@@ -13220,11 +13979,11 @@
ret[ret.length] = objectAt(this, beginIndex++);
}
return ret;
}, _Mixin$create.indexOf = function (object, startAt) {
- var len = _emberMetal.get(this, 'length');
+ var len = _emberMetalProperty_get.get(this, 'length');
if (startAt === undefined) {
startAt = 0;
}
@@ -13238,11 +13997,11 @@
}
}
return -1;
}, _Mixin$create.lastIndexOf = function (object, startAt) {
- var len = _emberMetal.get(this, 'length');
+ var len = _emberMetalProperty_get.get(this, 'length');
if (startAt === undefined || startAt >= len) {
startAt = len - 1;
}
@@ -13259,26 +14018,26 @@
return -1;
}, _Mixin$create.addArrayObserver = function (target, opts) {
return addArrayObserver(this, target, opts);
}, _Mixin$create.removeArrayObserver = function (target, opts) {
return removeArrayObserver(this, target, opts);
- }, _Mixin$create.hasArrayObservers = _emberMetal.computed(function () {
- return _emberMetal.hasListeners(this, '@array:change') || _emberMetal.hasListeners(this, '@array:before');
+ }, _Mixin$create.hasArrayObservers = _emberMetalComputed.computed(function () {
+ return _emberMetalEvents.hasListeners(this, '@array:change') || _emberMetalEvents.hasListeners(this, '@array:before');
}), _Mixin$create.arrayContentWillChange = function (startIdx, removeAmt, addAmt) {
return arrayContentWillChange(this, startIdx, removeAmt, addAmt);
}, _Mixin$create.arrayContentDidChange = function (startIdx, removeAmt, addAmt) {
return arrayContentDidChange(this, startIdx, removeAmt, addAmt);
- }, _Mixin$create['@each'] = _emberMetal.computed(function () {
+ }, _Mixin$create['@each'] = _emberMetalComputed.computed(function () {
// TODO use Symbol or add to meta
if (!this.__each) {
this.__each = new _emberRuntimeSystemEach_proxy.default(this);
}
return this.__each;
}).volatile(), _Mixin$create));
- if (_emberMetal.isFeatureEnabled('ember-runtime-enumerable-includes')) {
+ if (_emberMetalFeatures.default('ember-runtime-enumerable-includes')) {
ArrayMixin.reopen({
/**
Returns `true` if the passed object can be found in the array.
This method is a Polyfill for ES 2016 Array.includes.
If no `startAt` argument is given, the starting location to
@@ -13299,11 +14058,11 @@
@param {Number} startAt optional starting location to search, default 0
@return {Boolean} `true` if object is found in the array.
@public
*/
includes: function (obj, startAt) {
- var len = _emberMetal.get(this, 'length');
+ var len = _emberMetalProperty_get.get(this, 'length');
if (startAt === undefined) {
startAt = 0;
}
@@ -13539,11 +14298,11 @@
});
```
@property @each
@public
*/
-enifed('ember-runtime/mixins/comparable', ['exports', 'ember-metal'], function (exports, _emberMetal) {
+enifed('ember-runtime/mixins/comparable', ['exports', 'ember-metal/mixin'], function (exports, _emberMetalMixin) {
'use strict';
/**
@module ember
@submodule ember-runtime
@@ -13558,11 +14317,11 @@
@class Comparable
@namespace Ember
@since Ember 0.9
@private
*/
- exports.default = _emberMetal.Mixin.create({
+ exports.default = _emberMetalMixin.Mixin.create({
/**
__Required.__ You must implement this method to apply this mixin.
Override to return the result of the comparison of the two parameters. The
compare method should return:
@@ -13577,25 +14336,27 @@
@private
*/
compare: null
});
});
-enifed('ember-runtime/mixins/container_proxy', ['exports', 'ember-metal'], function (exports, _emberMetal) {
+enifed('ember-runtime/mixins/container_proxy', ['exports', 'ember-metal/run_loop', 'ember-metal/debug', 'ember-metal/mixin'], function (exports, _emberMetalRun_loop, _emberMetalDebug, _emberMetalMixin) {
/**
@module ember
@submodule ember-runtime
*/
'use strict';
+ exports.buildFakeContainerWithDeprecations = buildFakeContainerWithDeprecations;
+
/**
ContainerProxyMixin is used to provide public access to specific
container functionality.
@class ContainerProxyMixin
@private
*/
- exports.default = _emberMetal.Mixin.create({
+ exports.default = _emberMetalMixin.Mixin.create({
/**
The container stores state.
@private
@property {Ember.Container} __container__
*/
@@ -13685,25 +14446,50 @@
*/
willDestroy: function () {
this._super.apply(this, arguments);
if (this.__container__) {
- _emberMetal.run(this.__container__, 'destroy');
+ _emberMetalRun_loop.default(this.__container__, 'destroy');
}
}
});
+
+ function buildFakeContainerWithDeprecations(container) {
+ var fakeContainer = {};
+ var propertyMappings = {
+ lookup: 'lookup',
+ lookupFactory: '_lookupFactory'
+ };
+
+ for (var containerProperty in propertyMappings) {
+ fakeContainer[containerProperty] = buildFakeContainerFunction(container, containerProperty, propertyMappings[containerProperty]);
+ }
+
+ return fakeContainer;
+ }
+
+ function buildFakeContainerFunction(container, containerProperty, ownerProperty) {
+ return function () {
+ _emberMetalDebug.deprecate('Using the injected `container` is deprecated. Please use the `getOwner` helper to access the owner of this object and then call `' + ownerProperty + '` instead.', false, {
+ id: 'ember-application.injected-container',
+ until: '3.0.0',
+ url: 'http://emberjs.com/deprecations/v2.x#toc_injected-container-access'
+ });
+ return container[containerProperty].apply(container, arguments);
+ };
+ }
});
-enifed('ember-runtime/mixins/controller', ['exports', 'ember-metal', 'ember-runtime/mixins/action_handler', 'ember-runtime/mixins/controller_content_model_alias_deprecation'], function (exports, _emberMetal, _emberRuntimeMixinsAction_handler, _emberRuntimeMixinsController_content_model_alias_deprecation) {
+enifed('ember-runtime/mixins/controller', ['exports', 'ember-metal/mixin', 'ember-metal/alias', 'ember-runtime/mixins/action_handler', 'ember-runtime/mixins/controller_content_model_alias_deprecation'], function (exports, _emberMetalMixin, _emberMetalAlias, _emberRuntimeMixinsAction_handler, _emberRuntimeMixinsController_content_model_alias_deprecation) {
'use strict';
/**
@class ControllerMixin
@namespace Ember
@uses Ember.ActionHandler
@private
*/
- exports.default = _emberMetal.Mixin.create(_emberRuntimeMixinsAction_handler.default, _emberRuntimeMixinsController_content_model_alias_deprecation.default, {
+ exports.default = _emberMetalMixin.Mixin.create(_emberRuntimeMixinsAction_handler.default, _emberRuntimeMixinsController_content_model_alias_deprecation.default, {
/* ducktype as a controller */
isController: true,
/**
The object to which actions from the view should be sent.
@@ -13731,15 +14517,15 @@
model: null,
/**
@private
*/
- content: _emberMetal.alias('model')
+ content: _emberMetalAlias.default('model')
});
});
-enifed('ember-runtime/mixins/controller_content_model_alias_deprecation', ['exports', 'ember-metal'], function (exports, _emberMetal) {
+enifed('ember-runtime/mixins/controller_content_model_alias_deprecation', ['exports', 'ember-metal/debug', 'ember-metal/mixin'], function (exports, _emberMetalDebug, _emberMetalMixin) {
'use strict';
/*
The ControllerContentModelAliasDeprecation mixin is used to provide a useful
deprecation warning when specifying `content` directly on a `Ember.Controller`
@@ -13752,11 +14538,11 @@
simple ground rule: Never set a controllers content, rather always set
its model and ember will do the right thing.
Used internally by Ember in `Ember.Controller`.
*/
- exports.default = _emberMetal.Mixin.create({
+ exports.default = _emberMetalMixin.Mixin.create({
/**
@private
Moves `content` to `model` at extend time if a `model` is not also specified.
Note that this currently modifies the mixin themselves, which is technically
dubious but is practically of little consequence. This may change in the
@@ -13773,16 +14559,16 @@
if (props.content && !modelSpecified) {
props.model = props.content;
delete props['content'];
- _emberMetal.deprecate('Do not specify `content` on a Controller, use `model` instead.', false, { id: 'ember-runtime.will-merge-mixin', until: '3.0.0' });
+ _emberMetalDebug.deprecate('Do not specify `content` on a Controller, use `model` instead.', false, { id: 'ember-runtime.will-merge-mixin', until: '3.0.0' });
}
}
});
});
-enifed('ember-runtime/mixins/copyable', ['exports', 'ember-metal', 'ember-runtime/mixins/freezable'], function (exports, _emberMetal, _emberRuntimeMixinsFreezable) {
+enifed('ember-runtime/mixins/copyable', ['exports', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/mixin', 'ember-runtime/mixins/freezable', 'ember-metal/error'], function (exports, _emberMetalDebug, _emberMetalProperty_get, _emberMetalMixin, _emberRuntimeMixinsFreezable, _emberMetalError) {
/**
@module ember
@submodule ember-runtime
*/
@@ -13802,11 +14588,11 @@
@class Copyable
@namespace Ember
@since Ember 0.9
@private
*/
- exports.default = _emberMetal.Mixin.create({
+ exports.default = _emberMetalMixin.Mixin.create({
/**
__Required.__ You must implement this method to apply this mixin.
Override to return a copy of the receiver. Default implementation raises
an exception.
@method copy
@@ -13828,20 +14614,20 @@
@return {Object} copy of receiver or receiver
@deprecated Use `Object.freeze` instead.
@private
*/
frozenCopy: function () {
- _emberMetal.deprecate('`frozenCopy` is deprecated, use `Object.freeze` instead.', false, { id: 'ember-runtime.frozen-copy', until: '3.0.0' });
+ _emberMetalDebug.deprecate('`frozenCopy` is deprecated, use `Object.freeze` instead.', false, { id: 'ember-runtime.frozen-copy', until: '3.0.0' });
if (_emberRuntimeMixinsFreezable.Freezable && _emberRuntimeMixinsFreezable.Freezable.detect(this)) {
- return _emberMetal.get(this, 'isFrozen') ? this : this.copy().freeze();
+ return _emberMetalProperty_get.get(this, 'isFrozen') ? this : this.copy().freeze();
} else {
- throw new _emberMetal.Error(this + ' does not support freezing');
+ throw new _emberMetalError.default(this + ' does not support freezing');
}
}
});
});
-enifed('ember-runtime/mixins/enumerable', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/compare', 'require'], function (exports, _emberUtils, _emberMetal, _emberRuntimeCompare, _require) {
+enifed('ember-runtime/mixins/enumerable', ['exports', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/mixin', 'ember-metal/utils', 'ember-metal/computed', 'ember-metal/empty_object', 'ember-metal/features', 'ember-metal/property_events', 'ember-metal/events', 'ember-runtime/compare', 'require', 'ember-metal/debug'], function (exports, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalMixin, _emberMetalUtils, _emberMetalComputed, _emberMetalEmpty_object, _emberMetalFeatures, _emberMetalProperty_events, _emberMetalEvents, _emberRuntimeCompare, _require, _emberMetalDebug) {
/**
@module ember
@submodule ember-runtime
*/
@@ -13870,11 +14656,11 @@
function iter(key, value) {
var valueProvided = arguments.length === 2;
function i(item) {
- var cur = _emberMetal.get(item, key);
+ var cur = _emberMetalProperty_get.get(item, key);
return valueProvided ? value === cur : !!cur;
}
return i;
}
@@ -13915,11 +14701,11 @@
@class Enumerable
@namespace Ember
@since Ember 0.9
@private
*/
- var Enumerable = _emberMetal.Mixin.create({
+ var Enumerable = _emberMetalMixin.Mixin.create({
/**
__Required.__ You must implement this method to apply this mixin.
Implement this method to make your class enumerable.
This method will be called repeatedly during enumeration. The index value
@@ -13967,12 +14753,12 @@
@property firstObject
@return {Object} the object or undefined
@readOnly
@public
*/
- firstObject: _emberMetal.computed('[]', function () {
- if (_emberMetal.get(this, 'length') === 0) {
+ firstObject: _emberMetalComputed.computed('[]', function () {
+ if (_emberMetalProperty_get.get(this, 'length') === 0) {
return undefined;
}
// handle generic enumerables
var context = popCtx();
@@ -13996,12 +14782,12 @@
@property lastObject
@return {Object} the last object or undefined
@readOnly
@public
*/
- lastObject: _emberMetal.computed('[]', function () {
- var len = _emberMetal.get(this, 'length');
+ lastObject: _emberMetalComputed.computed('[]', function () {
+ var len = _emberMetalProperty_get.get(this, 'length');
if (len === 0) {
return undefined;
}
@@ -14034,12 +14820,12 @@
@param {Object} obj The object to search for.
@return {Boolean} `true` if object is found in enumerable.
@public
*/
contains: function (obj) {
- if (_emberMetal.isFeatureEnabled('ember-runtime-enumerable-includes')) {
- _emberMetal.deprecate('`Enumerable#contains` is deprecated, use `Enumerable#includes` instead.', false, { id: 'ember-runtime.enumerable-contains', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_enumerable-contains' });
+ if (_emberMetalFeatures.default('ember-runtime-enumerable-includes')) {
+ _emberMetalDebug.deprecate('`Enumerable#contains` is deprecated, use `Enumerable#includes` instead.', false, { id: 'ember-runtime.enumerable-contains', until: '3.0.0', url: 'http://emberjs.com/deprecations/v2.x#toc_enumerable-contains' });
}
var found = this.find(function (item) {
return item === obj;
});
@@ -14072,11 +14858,11 @@
if (typeof callback !== 'function') {
throw new TypeError();
}
var context = popCtx();
- var len = _emberMetal.get(this, 'length');
+ var len = _emberMetalProperty_get.get(this, 'length');
var last = null;
if (target === undefined) {
target = null;
}
@@ -14098,11 +14884,11 @@
@method getEach
@param {String} key name of the property
@return {Array} The mapped array.
@public
*/
- getEach: _emberMetal.aliasMethod('mapBy'),
+ getEach: _emberMetalMixin.aliasMethod('mapBy'),
/**
Sets the value on the named property for each member. This is more
ergonomic than using other methods defined on this helper. If the object
implements Ember.Observable, the value will be changed to `set(),` otherwise
@@ -14113,11 +14899,11 @@
@return {Object} receiver
@public
*/
setEach: function (key, value) {
return this.forEach(function (item) {
- return _emberMetal.set(item, key, value);
+ return _emberMetalProperty_set.set(item, key, value);
});
},
/**
Maps all of the items in the enumeration to another value, returning
@@ -14158,11 +14944,11 @@
@return {Array} The mapped array.
@public
*/
mapBy: function (key) {
return this.map(function (next) {
- return _emberMetal.get(next, key);
+ return _emberMetalProperty_get.get(next, key);
});
},
/**
Returns an array with all of the items in the enumeration that the passed
@@ -14250,14 +15036,14 @@
@return {Array} rejected array
@public
*/
rejectBy: function (key, value) {
var exactValue = function (item) {
- return _emberMetal.get(item, key) === value;
+ return _emberMetalProperty_get.get(item, key) === value;
};
var hasValue = function (item) {
- return !!_emberMetal.get(item, key);
+ return !!_emberMetalProperty_get.get(item, key);
};
var use = arguments.length === 2 ? exactValue : hasValue;
return this.reject(use);
},
@@ -14284,11 +15070,11 @@
@param {Object} [target] The target object to use
@return {Object} Found item or `undefined`.
@public
*/
find: function (callback, target) {
- var len = _emberMetal.get(this, 'length');
+ var len = _emberMetalProperty_get.get(this, 'length');
if (target === undefined) {
target = null;
}
@@ -14404,11 +15190,11 @@
@param {Object} [target] The target object to use
@return {Boolean} `true` if the passed function returns `true` for any item
@public
*/
any: function (callback, target) {
- var len = _emberMetal.get(this, 'length');
+ var len = _emberMetalProperty_get.get(this, 'length');
var context = popCtx();
var found = false;
var last = null;
var next = undefined;
@@ -14606,11 +15392,11 @@
@property []
@type Array
@return this
@private
*/
- '[]': _emberMetal.computed({
+ '[]': _emberMetalComputed.computed({
get: function (key) {
return this;
}
}),
@@ -14628,21 +15414,21 @@
@private
*/
addEnumerableObserver: function (target, opts) {
var willChange = opts && opts.willChange || 'enumerableWillChange';
var didChange = opts && opts.didChange || 'enumerableDidChange';
- var hasObservers = _emberMetal.get(this, 'hasEnumerableObservers');
+ var hasObservers = _emberMetalProperty_get.get(this, 'hasEnumerableObservers');
if (!hasObservers) {
- _emberMetal.propertyWillChange(this, 'hasEnumerableObservers');
+ _emberMetalProperty_events.propertyWillChange(this, 'hasEnumerableObservers');
}
- _emberMetal.addListener(this, '@enumerable:before', target, willChange);
- _emberMetal.addListener(this, '@enumerable:change', target, didChange);
+ _emberMetalEvents.addListener(this, '@enumerable:before', target, willChange);
+ _emberMetalEvents.addListener(this, '@enumerable:change', target, didChange);
if (!hasObservers) {
- _emberMetal.propertyDidChange(this, 'hasEnumerableObservers');
+ _emberMetalProperty_events.propertyDidChange(this, 'hasEnumerableObservers');
}
return this;
},
@@ -14655,21 +15441,21 @@
@private
*/
removeEnumerableObserver: function (target, opts) {
var willChange = opts && opts.willChange || 'enumerableWillChange';
var didChange = opts && opts.didChange || 'enumerableDidChange';
- var hasObservers = _emberMetal.get(this, 'hasEnumerableObservers');
+ var hasObservers = _emberMetalProperty_get.get(this, 'hasEnumerableObservers');
if (hasObservers) {
- _emberMetal.propertyWillChange(this, 'hasEnumerableObservers');
+ _emberMetalProperty_events.propertyWillChange(this, 'hasEnumerableObservers');
}
- _emberMetal.removeListener(this, '@enumerable:before', target, willChange);
- _emberMetal.removeListener(this, '@enumerable:change', target, didChange);
+ _emberMetalEvents.removeListener(this, '@enumerable:before', target, willChange);
+ _emberMetalEvents.removeListener(this, '@enumerable:change', target, didChange);
if (hasObservers) {
- _emberMetal.propertyDidChange(this, 'hasEnumerableObservers');
+ _emberMetalProperty_events.propertyDidChange(this, 'hasEnumerableObservers');
}
return this;
},
@@ -14678,12 +15464,12 @@
on the array.
@property hasEnumerableObservers
@type Boolean
@private
*/
- hasEnumerableObservers: _emberMetal.computed(function () {
- return _emberMetal.hasListeners(this, '@enumerable:change') || _emberMetal.hasListeners(this, '@enumerable:before');
+ hasEnumerableObservers: _emberMetalComputed.computed(function () {
+ return _emberMetalEvents.hasListeners(this, '@enumerable:change') || _emberMetalEvents.hasListeners(this, '@enumerable:before');
}),
/**
Invoke this method just before the contents of your enumerable will
change. You can either omit the parameters completely or pass the objects
@@ -14702,19 +15488,19 @@
hasDelta = undefined;
if ('number' === typeof removing) {
removeCnt = removing;
} else if (removing) {
- removeCnt = _emberMetal.get(removing, 'length');
+ removeCnt = _emberMetalProperty_get.get(removing, 'length');
} else {
removeCnt = removing = -1;
}
if ('number' === typeof adding) {
addCnt = adding;
} else if (adding) {
- addCnt = _emberMetal.get(adding, 'length');
+ addCnt = _emberMetalProperty_get.get(adding, 'length');
} else {
addCnt = adding = -1;
}
hasDelta = addCnt < 0 || removeCnt < 0 || addCnt - removeCnt !== 0;
@@ -14725,17 +15511,17 @@
if (adding === -1) {
adding = null;
}
- _emberMetal.propertyWillChange(this, '[]');
+ _emberMetalProperty_events.propertyWillChange(this, '[]');
if (hasDelta) {
- _emberMetal.propertyWillChange(this, 'length');
+ _emberMetalProperty_events.propertyWillChange(this, 'length');
}
- _emberMetal.sendEvent(this, '@enumerable:before', [this, removing, adding]);
+ _emberMetalEvents.sendEvent(this, '@enumerable:before', [this, removing, adding]);
return this;
},
/**
@@ -14758,19 +15544,19 @@
hasDelta = undefined;
if ('number' === typeof removing) {
removeCnt = removing;
} else if (removing) {
- removeCnt = _emberMetal.get(removing, 'length');
+ removeCnt = _emberMetalProperty_get.get(removing, 'length');
} else {
removeCnt = removing = -1;
}
if ('number' === typeof adding) {
addCnt = adding;
} else if (adding) {
- addCnt = _emberMetal.get(adding, 'length');
+ addCnt = _emberMetalProperty_get.get(adding, 'length');
} else {
addCnt = adding = -1;
}
hasDelta = addCnt < 0 || removeCnt < 0 || addCnt - removeCnt !== 0;
@@ -14781,17 +15567,17 @@
if (adding === -1) {
adding = null;
}
- _emberMetal.sendEvent(this, '@enumerable:change', [this, removing, adding]);
+ _emberMetalEvents.sendEvent(this, '@enumerable:change', [this, removing, adding]);
if (hasDelta) {
- _emberMetal.propertyDidChange(this, 'length');
+ _emberMetalProperty_events.propertyDidChange(this, 'length');
}
- _emberMetal.propertyDidChange(this, '[]');
+ _emberMetalProperty_events.propertyDidChange(this, '[]');
return this;
},
/**
@@ -14808,12 +15594,12 @@
var sortKeys = arguments;
return this.toArray().sort(function (a, b) {
for (var i = 0; i < sortKeys.length; i++) {
var key = sortKeys[i];
- var propA = _emberMetal.get(a, key);
- var propB = _emberMetal.get(b, key);
+ var propA = _emberMetalProperty_get.get(a, key);
+ var propB = _emberMetalProperty_get.get(b, key);
// return 1 or -1 else continue to the next sortKey
var compareValue = _emberRuntimeCompare.default(propA, propB);
if (compareValue) {
return compareValue;
@@ -14822,11 +15608,11 @@
return 0;
});
}
});
- if (_emberMetal.isFeatureEnabled('ember-runtime-computed-uniq-by')) {
+ if (_emberMetalFeatures.default('ember-runtime-computed-uniq-by')) {
Enumerable.reopen({
/**
Returns a new enumerable that contains only items containing a unique property value.
The default implementation returns an array regardless of the receiver type.
```javascript
@@ -14838,14 +15624,14 @@
@public
*/
uniqBy: function (key) {
var ret = emberA();
- var seen = new _emberUtils.EmptyObject();
+ var seen = new _emberMetalEmpty_object.default();
this.forEach(function (item) {
- var guid = _emberUtils.guidFor(_emberMetal.get(item, key));
+ var guid = _emberMetalUtils.guidFor(_emberMetalProperty_get.get(item, key));
if (!(guid in seen)) {
seen[guid] = true;
ret.push(item);
}
});
@@ -14853,11 +15639,11 @@
return ret;
}
});
}
- if (_emberMetal.isFeatureEnabled('ember-runtime-enumerable-includes')) {
+ if (_emberMetalFeatures.default('ember-runtime-enumerable-includes')) {
Enumerable.reopen({
/**
Returns `true` if the passed object can be found in the enumerable.
```javascript
[1, 2, 3].includes(2); // true
@@ -14870,13 +15656,13 @@
@param {Object} obj The object to search for.
@return {Boolean} `true` if object is found in the enumerable.
@public
*/
includes: function (obj) {
- _emberMetal.assert('Enumerable#includes cannot accept a second argument "startAt" as enumerable items are unordered.', arguments.length === 1);
+ _emberMetalDebug.assert('Enumerable#includes cannot accept a second argument "startAt" as enumerable items are unordered.', arguments.length === 1);
- var len = _emberMetal.get(this, 'length');
+ var len = _emberMetalProperty_get.get(this, 'length');
var idx = undefined,
next = undefined;
var last = null;
var found = false;
@@ -14915,11 +15701,11 @@
});
}
exports.default = Enumerable;
});
-enifed('ember-runtime/mixins/evented', ['exports', 'ember-metal'], function (exports, _emberMetal) {
+enifed('ember-runtime/mixins/evented', ['exports', 'ember-metal/mixin', 'ember-metal/events'], function (exports, _emberMetalMixin, _emberMetalEvents) {
'use strict';
/**
@module ember
@submodule ember-runtime
@@ -14959,11 +15745,11 @@
@class Evented
@namespace Ember
@public
*/
- exports.default = _emberMetal.Mixin.create({
+ exports.default = _emberMetalMixin.Mixin.create({
/**
Subscribes to a named event with given function.
```javascript
person.on('didLoad', function() {
@@ -14980,11 +15766,11 @@
@param {Function} method The callback to execute
@return this
@public
*/
on: function (name, target, method) {
- _emberMetal.addListener(this, name, target, method);
+ _emberMetalEvents.addListener(this, name, target, method);
return this;
},
/**
Subscribes a function to a named event and then cancels the subscription
@@ -15004,11 +15790,11 @@
if (!method) {
method = target;
target = null;
}
- _emberMetal.addListener(this, name, target, method, true);
+ _emberMetalEvents.addListener(this, name, target, method, true);
return this;
},
/**
Triggers a named event for the object. Any additional arguments
@@ -15029,11 +15815,11 @@
trigger: function (name) {
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
- _emberMetal.sendEvent(this, name, args);
+ _emberMetalEvents.sendEvent(this, name, args);
},
/**
Cancels subscription for given name, target, and method.
@method off
@@ -15042,11 +15828,11 @@
@param {Function} method The function of the subscription
@return this
@public
*/
off: function (name, target, method) {
- _emberMetal.removeListener(this, name, target, method);
+ _emberMetalEvents.removeListener(this, name, target, method);
return this;
},
/**
Checks to see if object has any subscriptions for named event.
@@ -15054,15 +15840,15 @@
@param {String} name The name of the event
@return {Boolean} does the object have a subscription for event
@public
*/
has: function (name) {
- return _emberMetal.hasListeners(this, name);
+ return _emberMetalEvents.hasListeners(this, name);
}
});
});
-enifed('ember-runtime/mixins/freezable', ['exports', 'ember-metal'], function (exports, _emberMetal) {
+enifed('ember-runtime/mixins/freezable', ['exports', 'ember-metal/debug', 'ember-metal/mixin', 'ember-metal/property_get', 'ember-metal/property_set'], function (exports, _emberMetalDebug, _emberMetalMixin, _emberMetalProperty_get, _emberMetalProperty_set) {
/**
@module ember
@submodule ember-runtime
*/
@@ -15124,14 +15910,14 @@
@namespace Ember
@since Ember 0.9
@deprecated Use `Object.freeze` instead.
@private
*/
- var Freezable = _emberMetal.Mixin.create({
+ var Freezable = _emberMetalMixin.Mixin.create({
init: function () {
- _emberMetal.deprecate('`Ember.Freezable` is deprecated, use `Object.freeze` instead.', false, { id: 'ember-runtime.freezable-init', until: '3.0.0' });
+ _emberMetalDebug.deprecate('`Ember.Freezable` is deprecated, use `Object.freeze` instead.', false, { id: 'ember-runtime.freezable-init', until: '3.0.0' });
this._super.apply(this, arguments);
},
/**
Set to `true` when the object is frozen. Use this property to detect
@@ -15148,30 +15934,37 @@
@method freeze
@return {Object} receiver
@private
*/
freeze: function () {
- if (_emberMetal.get(this, 'isFrozen')) {
+ if (_emberMetalProperty_get.get(this, 'isFrozen')) {
return this;
}
- _emberMetal.set(this, 'isFrozen', true);
+ _emberMetalProperty_set.set(this, 'isFrozen', true);
return this;
}
});
exports.Freezable = Freezable;
var FROZEN_ERROR = 'Frozen object cannot be modified.';
exports.FROZEN_ERROR = FROZEN_ERROR;
});
-enifed('ember-runtime/mixins/mutable_array', ['exports', 'ember-metal', 'ember-runtime/mixins/array', 'ember-runtime/mixins/mutable_enumerable', 'ember-runtime/mixins/enumerable'], function (exports, _emberMetal, _emberRuntimeMixinsArray, _emberRuntimeMixinsMutable_enumerable, _emberRuntimeMixinsEnumerable) {
+enifed('ember-runtime/mixins/mutable_array', ['exports', 'ember-metal/property_get', 'ember-metal/error', 'ember-metal/mixin', 'ember-runtime/mixins/array', 'ember-runtime/mixins/mutable_enumerable', 'ember-runtime/mixins/enumerable', 'ember-metal/features'], function (exports, _emberMetalProperty_get, _emberMetalError, _emberMetalMixin, _emberRuntimeMixinsArray, _emberRuntimeMixinsMutable_enumerable, _emberRuntimeMixinsEnumerable, _emberMetalFeatures) {
/**
@module ember
@submodule ember-runtime
*/
+ // require('ember-runtime/mixins/array');
+ // require('ember-runtime/mixins/mutable_enumerable');
+
+ // ..........................................................
+ // CONSTANTS
+ //
+
'use strict';
exports.removeAt = removeAt;
var OUT_OF_RANGE_EXCEPTION = 'Index out of range';
var EMPTY = [];
@@ -15180,12 +15973,12 @@
// HELPERS
//
function removeAt(array, start, len) {
if ('number' === typeof start) {
- if (start < 0 || start >= _emberMetal.get(array, 'length')) {
- throw new _emberMetal.Error(OUT_OF_RANGE_EXCEPTION);
+ if (start < 0 || start >= _emberMetalProperty_get.get(array, 'length')) {
+ throw new _emberMetalError.default(OUT_OF_RANGE_EXCEPTION);
}
// fast case
if (len === undefined) {
len = 1;
@@ -15216,11 +16009,11 @@
@namespace Ember
@uses Ember.Array
@uses Ember.MutableEnumerable
@public
*/
- exports.default = _emberMetal.Mixin.create(_emberRuntimeMixinsArray.default, _emberRuntimeMixinsMutable_enumerable.default, {
+ exports.default = _emberMetalMixin.Mixin.create(_emberRuntimeMixinsArray.default, _emberRuntimeMixinsMutable_enumerable.default, {
/**
__Required.__ You must implement this method to apply this mixin.
This is one of the primitives you must implement to support `Ember.Array`.
You should replace amt objects started at idx with the objects in the
@@ -15248,11 +16041,11 @@
@method clear
@return {Ember.Array} An empty Array.
@public
*/
clear: function () {
- var len = _emberMetal.get(this, 'length');
+ var len = _emberMetalProperty_get.get(this, 'length');
if (len === 0) {
return this;
}
this.replace(0, len, EMPTY);
@@ -15272,12 +16065,12 @@
@param {Object} object object to insert
@return {Ember.Array} receiver
@public
*/
insertAt: function (idx, object) {
- if (idx > _emberMetal.get(this, 'length')) {
- throw new _emberMetal.Error(OUT_OF_RANGE_EXCEPTION);
+ if (idx > _emberMetalProperty_get.get(this, 'length')) {
+ throw new _emberMetalError.default(OUT_OF_RANGE_EXCEPTION);
}
this.replace(idx, 0, [object]);
return this;
},
@@ -15315,11 +16108,11 @@
@param {*} obj object to push
@return object same object passed as a param
@public
*/
pushObject: function (obj) {
- this.insertAt(_emberMetal.get(this, 'length'), obj);
+ this.insertAt(_emberMetalProperty_get.get(this, 'length'), obj);
return obj;
},
/**
Add the objects in the passed numerable to the end of the array. Defers
@@ -15335,11 +16128,11 @@
*/
pushObjects: function (objects) {
if (!(_emberRuntimeMixinsEnumerable.default.detect(objects) || Array.isArray(objects))) {
throw new TypeError('Must pass Ember.Enumerable to Ember.MutableArray#pushObjects');
}
- this.replace(_emberMetal.get(this, 'length'), 0, objects);
+ this.replace(_emberMetalProperty_get.get(this, 'length'), 0, objects);
return this;
},
/**
Pop object from array or nil if none are left. Works just like `pop()` but
@@ -15352,11 +16145,11 @@
@method popObject
@return object
@public
*/
popObject: function () {
- var len = _emberMetal.get(this, 'length');
+ var len = _emberMetalProperty_get.get(this, 'length');
if (len === 0) {
return null;
}
var ret = _emberRuntimeMixinsArray.objectAt(this, len - 1);
@@ -15375,11 +16168,11 @@
@method shiftObject
@return object
@public
*/
shiftObject: function () {
- if (_emberMetal.get(this, 'length') === 0) {
+ if (_emberMetalProperty_get.get(this, 'length') === 0) {
return null;
}
var ret = _emberRuntimeMixinsArray.objectAt(this, 0);
this.removeAt(0);
@@ -15428,11 +16221,11 @@
@method reverseObjects
@return {Ember.Array} receiver
@public
*/
reverseObjects: function () {
- var len = _emberMetal.get(this, 'length');
+ var len = _emberMetalProperty_get.get(this, 'length');
if (len === 0) {
return this;
}
var objects = this.toArray().reverse();
@@ -15457,11 +16250,11 @@
setObjects: function (objects) {
if (objects.length === 0) {
return this.clear();
}
- var len = _emberMetal.get(this, 'length');
+ var len = _emberMetalProperty_get.get(this, 'length');
this.replace(0, len, objects);
return this;
},
// ..........................................................
@@ -15480,11 +16273,11 @@
@param {*} obj object to remove
@return {Ember.Array} receiver
@public
*/
removeObject: function (obj) {
- var loc = _emberMetal.get(this, 'length') || 0;
+ var loc = _emberMetalProperty_get.get(this, 'length') || 0;
while (--loc >= 0) {
var curObject = _emberRuntimeMixinsArray.objectAt(this, loc);
if (curObject === obj) {
this.removeAt(loc);
@@ -15507,11 +16300,11 @@
@public
*/
addObject: function (obj) {
var included = undefined;
- if (_emberMetal.isFeatureEnabled('ember-runtime-enumerable-includes')) {
+ if (_emberMetalFeatures.default('ember-runtime-enumerable-includes')) {
included = this.includes(obj);
} else {
included = this.contains(obj);
}
@@ -15521,11 +16314,11 @@
return this;
}
});
});
-enifed('ember-runtime/mixins/mutable_enumerable', ['exports', 'ember-runtime/mixins/enumerable', 'ember-metal'], function (exports, _emberRuntimeMixinsEnumerable, _emberMetal) {
+enifed('ember-runtime/mixins/mutable_enumerable', ['exports', 'ember-runtime/mixins/enumerable', 'ember-metal/mixin', 'ember-metal/property_events'], function (exports, _emberRuntimeMixinsEnumerable, _emberMetalMixin, _emberMetalProperty_events) {
'use strict';
/**
@module ember
@submodule ember-runtime
@@ -15569,11 +16362,11 @@
@class MutableEnumerable
@namespace Ember
@uses Ember.Enumerable
@public
*/
- exports.default = _emberMetal.Mixin.create(_emberRuntimeMixinsEnumerable.default, {
+ exports.default = _emberMetalMixin.Mixin.create(_emberRuntimeMixinsEnumerable.default, {
/**
__Required.__ You must implement this method to apply this mixin.
Attempts to add the passed object to the receiver if the object is not
already present in the collection. If the object is present, this method
@@ -15595,15 +16388,15 @@
@public
*/
addObjects: function (objects) {
var _this = this;
- _emberMetal.beginPropertyChanges(this);
+ _emberMetalProperty_events.beginPropertyChanges(this);
objects.forEach(function (obj) {
return _this.addObject(obj);
});
- _emberMetal.endPropertyChanges(this);
+ _emberMetalProperty_events.endPropertyChanges(this);
return this;
},
/**
__Required.__ You must implement this method to apply this mixin.
@@ -15625,20 +16418,20 @@
@param {Ember.Enumerable} objects the objects to remove
@return {Object} receiver
@public
*/
removeObjects: function (objects) {
- _emberMetal.beginPropertyChanges(this);
+ _emberMetalProperty_events.beginPropertyChanges(this);
for (var i = objects.length - 1; i >= 0; i--) {
this.removeObject(objects[i]);
}
- _emberMetal.endPropertyChanges(this);
+ _emberMetalProperty_events.endPropertyChanges(this);
return this;
}
});
});
-enifed('ember-runtime/mixins/observable', ['exports', 'ember-metal'], function (exports, _emberMetal) {
+enifed('ember-runtime/mixins/observable', ['exports', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/property_set', 'ember-metal/get_properties', 'ember-metal/set_properties', 'ember-metal/mixin', 'ember-metal/events', 'ember-metal/property_events', 'ember-metal/observer', 'ember-metal/computed', 'ember-metal/is_none'], function (exports, _emberMetalDebug, _emberMetalProperty_get, _emberMetalProperty_set, _emberMetalGet_properties, _emberMetalSet_properties, _emberMetalMixin, _emberMetalEvents, _emberMetalProperty_events, _emberMetalObserver, _emberMetalComputed, _emberMetalIs_none) {
/**
@module ember
@submodule ember-runtime
*/
@@ -15710,11 +16503,11 @@
@class Observable
@namespace Ember
@public
*/
- exports.default = _emberMetal.Mixin.create({
+ exports.default = _emberMetalMixin.Mixin.create({
/**
Retrieves the value of a property from the object.
This method is usually similar to using `object[keyName]` or `object.keyName`,
however it supports both computed properties and the unknownProperty
@@ -15743,11 +16536,11 @@
@param {String} keyName The property to retrieve
@return {Object} The property value or undefined.
@public
*/
get: function (keyName) {
- return _emberMetal.get(this, keyName);
+ return _emberMetalProperty_get.get(this, keyName);
},
/**
To get the values of multiple properties at once, call `getProperties`
with a list of strings or an array:
@@ -15768,11 +16561,11 @@
getProperties: function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
- return _emberMetal.getProperties.apply(null, [this].concat(args));
+ return _emberMetalGet_properties.default.apply(null, [this].concat(args));
},
/**
Sets the provided key or path to the value.
This method is generally very similar to calling `object[key] = value` or
@@ -15804,11 +16597,11 @@
@param {Object} value The value to set or `null`.
@return {Object} The passed value
@public
*/
set: function (keyName, value) {
- return _emberMetal.set(this, keyName, value);
+ return _emberMetalProperty_set.set(this, keyName, value);
},
/**
Sets a list of properties at once. These properties are set inside
a single `beginPropertyChanges` and `endPropertyChanges` batch, so
@@ -15820,11 +16613,11 @@
@param {Object} hash the hash of keys and values to set
@return {Object} The passed in hash
@public
*/
setProperties: function (hash) {
- return _emberMetal.setProperties(this, hash);
+ return _emberMetalSet_properties.default(this, hash);
},
/**
Begins a grouping of property changes.
You can use this method to group property changes so that notifications
@@ -15837,11 +16630,11 @@
@method beginPropertyChanges
@return {Ember.Observable}
@private
*/
beginPropertyChanges: function () {
- _emberMetal.beginPropertyChanges();
+ _emberMetalProperty_events.beginPropertyChanges();
return this;
},
/**
Ends a grouping of property changes.
@@ -15854,11 +16647,11 @@
@method endPropertyChanges
@return {Ember.Observable}
@private
*/
endPropertyChanges: function () {
- _emberMetal.endPropertyChanges();
+ _emberMetalProperty_events.endPropertyChanges();
return this;
},
/**
Notify the observer system that a property is about to change.
@@ -15875,11 +16668,11 @@
@param {String} keyName The property key that is about to change.
@return {Ember.Observable}
@private
*/
propertyWillChange: function (keyName) {
- _emberMetal.propertyWillChange(this, keyName);
+ _emberMetalProperty_events.propertyWillChange(this, keyName);
return this;
},
/**
Notify the observer system that a property has just changed.
@@ -15896,11 +16689,11 @@
@param {String} keyName The property key that has just changed.
@return {Ember.Observable}
@private
*/
propertyDidChange: function (keyName) {
- _emberMetal.propertyDidChange(this, keyName);
+ _emberMetalProperty_events.propertyDidChange(this, keyName);
return this;
},
/**
Convenience method to call `propertyWillChange` and `propertyDidChange` in
@@ -15952,11 +16745,11 @@
@param {Object} target The target object to invoke
@param {String|Function} method The method to invoke.
@public
*/
addObserver: function (key, target, method) {
- _emberMetal.addObserver(this, key, target, method);
+ _emberMetalObserver.addObserver(this, key, target, method);
},
/**
Remove an observer you have previously registered on this object. Pass
the same key, target, and method you passed to `addObserver()` and your
@@ -15966,11 +16759,11 @@
@param {Object} target The target object to invoke
@param {String|Function} method The method to invoke.
@public
*/
removeObserver: function (key, target, method) {
- _emberMetal.removeObserver(this, key, target, method);
+ _emberMetalObserver.removeObserver(this, key, target, method);
},
/**
Returns `true` if the object currently has observers registered for a
particular key. You can use this method to potentially defer performing
@@ -15980,11 +16773,11 @@
@param {String} key Key to check
@return {Boolean}
@private
*/
hasObserverFor: function (key) {
- return _emberMetal.hasListeners(this, key + ':change');
+ return _emberMetalEvents.hasListeners(this, key + ':change');
},
/**
Retrieves the value of a property, or a default value in the case that the
property returns `undefined`.
@@ -15996,11 +16789,11 @@
@param {Object} defaultValue The value to return if the property value is undefined
@return {Object} The property value or the defaultValue.
@public
*/
getWithDefault: function (keyName, defaultValue) {
- return _emberMetal.getWithDefault(this, keyName, defaultValue);
+ return _emberMetalProperty_get.getWithDefault(this, keyName, defaultValue);
},
/**
Set the value of a property to the current value plus some amount.
```javascript
@@ -16012,15 +16805,15 @@
@param {Number} increment The amount to increment by. Defaults to 1
@return {Number} The new property value
@public
*/
incrementProperty: function (keyName, increment) {
- if (_emberMetal.isNone(increment)) {
+ if (_emberMetalIs_none.default(increment)) {
increment = 1;
}
- _emberMetal.assert('Must pass a numeric value to incrementProperty', !isNaN(parseFloat(increment)) && isFinite(increment));
- return _emberMetal.set(this, keyName, (parseFloat(_emberMetal.get(this, keyName)) || 0) + increment);
+ _emberMetalDebug.assert('Must pass a numeric value to incrementProperty', !isNaN(parseFloat(increment)) && isFinite(increment));
+ return _emberMetalProperty_set.set(this, keyName, (parseFloat(_emberMetalProperty_get.get(this, keyName)) || 0) + increment);
},
/**
Set the value of a property to the current value minus some amount.
```javascript
@@ -16032,15 +16825,15 @@
@param {Number} decrement The amount to decrement by. Defaults to 1
@return {Number} The new property value
@public
*/
decrementProperty: function (keyName, decrement) {
- if (_emberMetal.isNone(decrement)) {
+ if (_emberMetalIs_none.default(decrement)) {
decrement = 1;
}
- _emberMetal.assert('Must pass a numeric value to decrementProperty', !isNaN(parseFloat(decrement)) && isFinite(decrement));
- return _emberMetal.set(this, keyName, (_emberMetal.get(this, keyName) || 0) - decrement);
+ _emberMetalDebug.assert('Must pass a numeric value to decrementProperty', !isNaN(parseFloat(decrement)) && isFinite(decrement));
+ return _emberMetalProperty_set.set(this, keyName, (_emberMetalProperty_get.get(this, keyName) || 0) - decrement);
},
/**
Set the value of a boolean property to the opposite of its
current value.
@@ -16051,11 +16844,11 @@
@param {String} keyName The name of the property to toggle
@return {Boolean} The new property value
@public
*/
toggleProperty: function (keyName) {
- return _emberMetal.set(this, keyName, !_emberMetal.get(this, keyName));
+ return _emberMetalProperty_set.set(this, keyName, !_emberMetalProperty_get.get(this, keyName));
},
/**
Returns the cached value of a computed property, if it exists.
This allows you to inspect the value of a computed property
@@ -16065,41 +16858,41 @@
@param {String} keyName
@return {Object} The cached value of the computed property, if any
@public
*/
cacheFor: function (keyName) {
- return _emberMetal.cacheFor(this, keyName);
+ return _emberMetalComputed.cacheFor(this, keyName);
},
// intended for debugging purposes
observersForKey: function (keyName) {
- return _emberMetal.observersFor(this, keyName);
+ return _emberMetalObserver.observersFor(this, keyName);
}
});
});
-enifed('ember-runtime/mixins/promise_proxy', ['exports', 'ember-metal', 'ember-runtime/computed/computed_macros'], function (exports, _emberMetal, _emberRuntimeComputedComputed_macros) {
+enifed('ember-runtime/mixins/promise_proxy', ['exports', 'ember-metal/property_get', 'ember-metal/set_properties', 'ember-metal/computed', 'ember-runtime/computed/computed_macros', 'ember-metal/mixin', 'ember-metal/error'], function (exports, _emberMetalProperty_get, _emberMetalSet_properties, _emberMetalComputed, _emberRuntimeComputedComputed_macros, _emberMetalMixin, _emberMetalError) {
'use strict';
/**
@module ember
@submodule ember-runtime
*/
function tap(proxy, promise) {
- _emberMetal.setProperties(proxy, {
+ _emberMetalSet_properties.default(proxy, {
isFulfilled: false,
isRejected: false
});
return promise.then(function (value) {
- _emberMetal.setProperties(proxy, {
+ _emberMetalSet_properties.default(proxy, {
content: value,
isFulfilled: true
});
return value;
}, function (reason) {
- _emberMetal.setProperties(proxy, {
+ _emberMetalSet_properties.default(proxy, {
reason: reason,
isRejected: true
});
throw reason;
}, 'Ember: PromiseProxy');
@@ -16161,11 +16954,11 @@
```
@class Ember.PromiseProxyMixin
@public
*/
- exports.default = _emberMetal.Mixin.create({
+ exports.default = _emberMetalMixin.Mixin.create({
/**
If the proxied promise is rejected this will contain the reason
provided.
@property reason
@default null
@@ -16216,13 +17009,13 @@
});
```
@property promise
@public
*/
- promise: _emberMetal.computed({
+ promise: _emberMetalComputed.computed({
get: function () {
- throw new _emberMetal.Error('PromiseProxy\'s promise must be set');
+ throw new _emberMetalError.default('PromiseProxy\'s promise must be set');
},
set: function (key, promise) {
return tap(this, promise);
}
}),
@@ -16261,16 +17054,16 @@
});
function promiseAlias(name) {
return function () {
- var promise = _emberMetal.get(this, 'promise');
+ var promise = _emberMetalProperty_get.get(this, 'promise');
return promise[name].apply(promise, arguments);
};
}
});
-enifed('ember-runtime/mixins/registry_proxy', ['exports', 'ember-metal'], function (exports, _emberMetal) {
+enifed('ember-runtime/mixins/registry_proxy', ['exports', 'ember-metal/debug', 'ember-metal/mixin'], function (exports, _emberMetalDebug, _emberMetalMixin) {
/**
@module ember
@submodule ember-runtime
*/
@@ -16283,11 +17076,11 @@
registry functionality.
@class RegistryProxyMixin
@private
*/
- exports.default = _emberMetal.Mixin.create({
+ exports.default = _emberMetalMixin.Mixin.create({
__registry__: null,
/**
Given a fullName return the corresponding factory.
@public
@@ -16511,20 +17304,20 @@
return fakeRegistry;
}
function buildFakeRegistryFunction(instance, typeForMessage, deprecatedProperty, nonDeprecatedProperty) {
return function () {
- _emberMetal.deprecate('Using `' + typeForMessage + '.registry.' + deprecatedProperty + '` is deprecated. Please use `' + typeForMessage + '.' + nonDeprecatedProperty + '` instead.', false, {
+ _emberMetalDebug.deprecate('Using `' + typeForMessage + '.registry.' + deprecatedProperty + '` is deprecated. Please use `' + typeForMessage + '.' + nonDeprecatedProperty + '` instead.', false, {
id: 'ember-application.app-instance-registry',
until: '3.0.0',
url: 'http://emberjs.com/deprecations/v2.x/#toc_ember-application-registry-ember-applicationinstance-registry'
});
return instance[nonDeprecatedProperty].apply(instance, arguments);
};
}
});
-enifed('ember-runtime/mixins/target_action_support', ['exports', 'ember-environment', 'ember-metal'], function (exports, _emberEnvironment, _emberMetal) {
+enifed('ember-runtime/mixins/target_action_support', ['exports', 'ember-environment', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/mixin', 'ember-metal/computed'], function (exports, _emberEnvironment, _emberMetalDebug, _emberMetalProperty_get, _emberMetalMixin, _emberMetalComputed) {
/**
@module ember
@submodule ember-runtime
*/
@@ -16533,29 +17326,32 @@
/**
`Ember.TargetActionSupport` is a mixin that can be included in a class
to add a `triggerAction` method with semantics similar to the Handlebars
`{{action}}` helper. In normal Ember usage, the `{{action}}` helper is
usually the best choice. This mixin is most often useful when you are
- doing more complex event handling in Components.
+ doing more complex event handling in View objects.
+ See also `Ember.ViewTargetActionSupport`, which has
+ view-aware defaults for target and actionContext.
+
@class TargetActionSupport
@namespace Ember
@extends Ember.Mixin
@private
*/
- exports.default = _emberMetal.Mixin.create({
+ exports.default = _emberMetalMixin.Mixin.create({
target: null,
action: null,
actionContext: null,
- actionContextObject: _emberMetal.computed('actionContext', function () {
- var actionContext = _emberMetal.get(this, 'actionContext');
+ actionContextObject: _emberMetalComputed.computed('actionContext', function () {
+ var actionContext = _emberMetalProperty_get.get(this, 'actionContext');
if (typeof actionContext === 'string') {
- var value = _emberMetal.get(this, actionContext);
+ var value = _emberMetalProperty_get.get(this, actionContext);
if (value === undefined) {
- value = _emberMetal.get(_emberEnvironment.context.lookup, actionContext);
+ value = _emberMetalProperty_get.get(_emberEnvironment.context.lookup, actionContext);
}
return value;
} else {
return actionContext;
}
@@ -16609,11 +17405,11 @@
@private
*/
triggerAction: function () {
var opts = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
- var action = opts.action || _emberMetal.get(this, 'action');
+ var action = opts.action || _emberMetalProperty_get.get(this, 'action');
var target = opts.target;
if (!target) {
target = getTarget(this);
}
@@ -16628,20 +17424,20 @@
return ret.concat(options);
}
if (typeof actionContext === 'undefined') {
- actionContext = _emberMetal.get(this, 'actionContextObject') || this;
+ actionContext = _emberMetalProperty_get.get(this, 'actionContextObject') || this;
}
if (target && action) {
var ret = undefined;
if (target.send) {
ret = target.send.apply(target, args(actionContext, action));
} else {
- _emberMetal.assert('The action \'' + action + '\' did not exist on ' + target, typeof target[action] === 'function');
+ _emberMetalDebug.assert('The action \'' + action + '\' did not exist on ' + target, typeof target[action] === 'function');
ret = target[action].apply(target, args(actionContext));
}
if (ret !== false) {
ret = true;
@@ -16654,11 +17450,11 @@
}
});
function getTarget(instance) {
// TODO: Deprecate specifying `targetObject`
- var target = _emberMetal.get(instance, 'targetObject');
+ var target = _emberMetalProperty_get.get(instance, 'targetObject');
// if a `targetObject` CP was provided, use it
if (target) {
return target;
}
@@ -16666,16 +17462,16 @@
// if _targetObject use it
if (instance._targetObject) {
return instance._targetObject;
}
- target = _emberMetal.get(instance, 'target');
+ target = _emberMetalProperty_get.get(instance, 'target');
if (target) {
if (typeof target === 'string') {
- var value = _emberMetal.get(instance, target);
+ var value = _emberMetalProperty_get.get(instance, target);
if (value === undefined) {
- value = _emberMetal.get(_emberEnvironment.context.lookup, target);
+ value = _emberMetalProperty_get.get(_emberEnvironment.context.lookup, target);
}
return value;
} else {
return target;
@@ -16711,11 +17507,11 @@
enifed('ember-runtime/system/application', ['exports', 'ember-runtime/system/namespace'], function (exports, _emberRuntimeSystemNamespace) {
'use strict';
exports.default = _emberRuntimeSystemNamespace.default.extend();
});
-enifed('ember-runtime/system/array_proxy', ['exports', 'ember-metal', 'ember-runtime/utils', 'ember-runtime/system/object', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/enumerable', 'ember-runtime/mixins/array'], function (exports, _emberMetal, _emberRuntimeUtils, _emberRuntimeSystemObject, _emberRuntimeMixinsMutable_array, _emberRuntimeMixinsEnumerable, _emberRuntimeMixinsArray) {
+enifed('ember-runtime/system/array_proxy', ['exports', 'ember-metal/debug', 'ember-metal/property_get', 'ember-runtime/utils', 'ember-metal/computed', 'ember-metal/mixin', 'ember-metal/property_events', 'ember-metal/error', 'ember-runtime/system/object', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/enumerable', 'ember-metal/alias', 'ember-runtime/mixins/array'], function (exports, _emberMetalDebug, _emberMetalProperty_get, _emberRuntimeUtils, _emberMetalComputed, _emberMetalMixin, _emberMetalProperty_events, _emberMetalError, _emberRuntimeSystemObject, _emberRuntimeMixinsMutable_array, _emberRuntimeMixinsEnumerable, _emberMetalAlias, _emberRuntimeMixinsArray) {
'use strict';
/**
@module ember
@submodule ember-runtime
@@ -16783,11 +17579,11 @@
implementation, this and `content` are the same. Subclasses of `ArrayProxy`
can override this property to provide things like sorting and filtering.
@property arrangedContent
@private
*/
- arrangedContent: _emberMetal.alias('content'),
+ arrangedContent: _emberMetalAlias.default('content'),
/**
Should actually retrieve the object at the specified index from the
content. You can override this method in subclasses to transform the
content item to something new.
@@ -16796,11 +17592,11 @@
@param {Number} idx The index to retrieve.
@return {Object} the value or undefined if none found
@private
*/
objectAtContent: function (idx) {
- return _emberRuntimeMixinsArray.objectAt(_emberMetal.get(this, 'arrangedContent'), idx);
+ return _emberRuntimeMixinsArray.objectAt(_emberMetalProperty_get.get(this, 'arrangedContent'), idx);
},
/**
Should actually replace the specified objects on the content array.
You can override this method in subclasses to transform the content item
@@ -16813,25 +17609,25 @@
objects.
@return {void}
@private
*/
replaceContent: function (idx, amt, objects) {
- _emberMetal.get(this, 'content').replace(idx, amt, objects);
+ _emberMetalProperty_get.get(this, 'content').replace(idx, amt, objects);
},
/**
Invoked when the content property is about to change. Notifies observers that the
entire array content will change.
@private
@method _contentWillChange
*/
- _contentWillChange: _emberMetal._beforeObserver('content', function () {
+ _contentWillChange: _emberMetalMixin._beforeObserver('content', function () {
this._teardownContent();
}),
_teardownContent: function () {
- var content = _emberMetal.get(this, 'content');
+ var content = _emberMetalProperty_get.get(this, 'content');
if (content) {
_emberRuntimeMixinsArray.removeArrayObserver(content, this, {
willChange: 'contentArrayWillChange',
didChange: 'contentArrayDidChange'
@@ -16864,68 +17660,68 @@
Invoked when the content property changes. Notifies observers that the
entire array content has changed.
@private
@method _contentDidChange
*/
- _contentDidChange: _emberMetal.observer('content', function () {
- var content = _emberMetal.get(this, 'content');
+ _contentDidChange: _emberMetalMixin.observer('content', function () {
+ var content = _emberMetalProperty_get.get(this, 'content');
- _emberMetal.assert('Can\'t set ArrayProxy\'s content to itself', content !== this);
+ _emberMetalDebug.assert('Can\'t set ArrayProxy\'s content to itself', content !== this);
this._setupContent();
}),
_setupContent: function () {
- var content = _emberMetal.get(this, 'content');
+ var content = _emberMetalProperty_get.get(this, 'content');
if (content) {
- _emberMetal.assert('ArrayProxy expects an Array or Ember.ArrayProxy, but you passed ' + typeof content, _emberRuntimeUtils.isArray(content) || content.isDestroyed);
+ _emberMetalDebug.assert('ArrayProxy expects an Array or Ember.ArrayProxy, but you passed ' + typeof content, _emberRuntimeUtils.isArray(content) || content.isDestroyed);
_emberRuntimeMixinsArray.addArrayObserver(content, this, {
willChange: 'contentArrayWillChange',
didChange: 'contentArrayDidChange'
});
}
},
- _arrangedContentWillChange: _emberMetal._beforeObserver('arrangedContent', function () {
- var arrangedContent = _emberMetal.get(this, 'arrangedContent');
- var len = arrangedContent ? _emberMetal.get(arrangedContent, 'length') : 0;
+ _arrangedContentWillChange: _emberMetalMixin._beforeObserver('arrangedContent', function () {
+ var arrangedContent = _emberMetalProperty_get.get(this, 'arrangedContent');
+ var len = arrangedContent ? _emberMetalProperty_get.get(arrangedContent, 'length') : 0;
this.arrangedContentArrayWillChange(this, 0, len, undefined);
this.arrangedContentWillChange(this);
this._teardownArrangedContent(arrangedContent);
}),
- _arrangedContentDidChange: _emberMetal.observer('arrangedContent', function () {
- var arrangedContent = _emberMetal.get(this, 'arrangedContent');
- var len = arrangedContent ? _emberMetal.get(arrangedContent, 'length') : 0;
+ _arrangedContentDidChange: _emberMetalMixin.observer('arrangedContent', function () {
+ var arrangedContent = _emberMetalProperty_get.get(this, 'arrangedContent');
+ var len = arrangedContent ? _emberMetalProperty_get.get(arrangedContent, 'length') : 0;
- _emberMetal.assert('Can\'t set ArrayProxy\'s content to itself', arrangedContent !== this);
+ _emberMetalDebug.assert('Can\'t set ArrayProxy\'s content to itself', arrangedContent !== this);
this._setupArrangedContent();
this.arrangedContentDidChange(this);
this.arrangedContentArrayDidChange(this, 0, undefined, len);
}),
_setupArrangedContent: function () {
- var arrangedContent = _emberMetal.get(this, 'arrangedContent');
+ var arrangedContent = _emberMetalProperty_get.get(this, 'arrangedContent');
if (arrangedContent) {
- _emberMetal.assert('ArrayProxy expects an Array or Ember.ArrayProxy, but you passed ' + typeof arrangedContent, _emberRuntimeUtils.isArray(arrangedContent) || arrangedContent.isDestroyed);
+ _emberMetalDebug.assert('ArrayProxy expects an Array or Ember.ArrayProxy, but you passed ' + typeof arrangedContent, _emberRuntimeUtils.isArray(arrangedContent) || arrangedContent.isDestroyed);
_emberRuntimeMixinsArray.addArrayObserver(arrangedContent, this, {
willChange: 'arrangedContentArrayWillChange',
didChange: 'arrangedContentArrayDidChange'
});
}
},
_teardownArrangedContent: function () {
- var arrangedContent = _emberMetal.get(this, 'arrangedContent');
+ var arrangedContent = _emberMetalProperty_get.get(this, 'arrangedContent');
if (arrangedContent) {
_emberRuntimeMixinsArray.removeArrayObserver(arrangedContent, this, {
willChange: 'arrangedContentArrayWillChange',
didChange: 'arrangedContentArrayDidChange'
@@ -16935,62 +17731,62 @@
arrangedContentWillChange: K,
arrangedContentDidChange: K,
objectAt: function (idx) {
- return _emberMetal.get(this, 'content') && this.objectAtContent(idx);
+ return _emberMetalProperty_get.get(this, 'content') && this.objectAtContent(idx);
},
- length: _emberMetal.computed(function () {
- var arrangedContent = _emberMetal.get(this, 'arrangedContent');
- return arrangedContent ? _emberMetal.get(arrangedContent, 'length') : 0;
+ length: _emberMetalComputed.computed(function () {
+ var arrangedContent = _emberMetalProperty_get.get(this, 'arrangedContent');
+ return arrangedContent ? _emberMetalProperty_get.get(arrangedContent, 'length') : 0;
// No dependencies since Enumerable notifies length of change
}),
_replace: function (idx, amt, objects) {
- var content = _emberMetal.get(this, 'content');
- _emberMetal.assert('The content property of ' + this.constructor + ' should be set before modifying it', content);
+ var content = _emberMetalProperty_get.get(this, 'content');
+ _emberMetalDebug.assert('The content property of ' + this.constructor + ' should be set before modifying it', content);
if (content) {
this.replaceContent(idx, amt, objects);
}
return this;
},
replace: function () {
- if (_emberMetal.get(this, 'arrangedContent') === _emberMetal.get(this, 'content')) {
+ if (_emberMetalProperty_get.get(this, 'arrangedContent') === _emberMetalProperty_get.get(this, 'content')) {
this._replace.apply(this, arguments);
} else {
- throw new _emberMetal.Error('Using replace on an arranged ArrayProxy is not allowed.');
+ throw new _emberMetalError.default('Using replace on an arranged ArrayProxy is not allowed.');
}
},
_insertAt: function (idx, object) {
- if (idx > _emberMetal.get(this, 'content.length')) {
- throw new _emberMetal.Error(OUT_OF_RANGE_EXCEPTION);
+ if (idx > _emberMetalProperty_get.get(this, 'content.length')) {
+ throw new _emberMetalError.default(OUT_OF_RANGE_EXCEPTION);
}
this._replace(idx, 0, [object]);
return this;
},
insertAt: function (idx, object) {
- if (_emberMetal.get(this, 'arrangedContent') === _emberMetal.get(this, 'content')) {
+ if (_emberMetalProperty_get.get(this, 'arrangedContent') === _emberMetalProperty_get.get(this, 'content')) {
return this._insertAt(idx, object);
} else {
- throw new _emberMetal.Error('Using insertAt on an arranged ArrayProxy is not allowed.');
+ throw new _emberMetalError.default('Using insertAt on an arranged ArrayProxy is not allowed.');
}
},
removeAt: function (start, len) {
if ('number' === typeof start) {
- var content = _emberMetal.get(this, 'content');
- var arrangedContent = _emberMetal.get(this, 'arrangedContent');
+ var content = _emberMetalProperty_get.get(this, 'content');
+ var arrangedContent = _emberMetalProperty_get.get(this, 'arrangedContent');
var indices = [];
- if (start < 0 || start >= _emberMetal.get(this, 'length')) {
- throw new _emberMetal.Error(OUT_OF_RANGE_EXCEPTION);
+ if (start < 0 || start >= _emberMetalProperty_get.get(this, 'length')) {
+ throw new _emberMetalError.default(OUT_OF_RANGE_EXCEPTION);
}
if (len === undefined) {
len = 1;
}
@@ -17004,39 +17800,39 @@
// Replace in reverse order since indices will change
indices.sort(function (a, b) {
return b - a;
});
- _emberMetal.beginPropertyChanges();
+ _emberMetalProperty_events.beginPropertyChanges();
for (var i = 0; i < indices.length; i++) {
this._replace(indices[i], 1, EMPTY);
}
- _emberMetal.endPropertyChanges();
+ _emberMetalProperty_events.endPropertyChanges();
}
return this;
},
pushObject: function (obj) {
- this._insertAt(_emberMetal.get(this, 'content.length'), obj);
+ this._insertAt(_emberMetalProperty_get.get(this, 'content.length'), obj);
return obj;
},
pushObjects: function (objects) {
if (!(_emberRuntimeMixinsEnumerable.default.detect(objects) || _emberRuntimeUtils.isArray(objects))) {
throw new TypeError('Must pass Ember.Enumerable to Ember.MutableArray#pushObjects');
}
- this._replace(_emberMetal.get(this, 'length'), 0, objects);
+ this._replace(_emberMetalProperty_get.get(this, 'length'), 0, objects);
return this;
},
setObjects: function (objects) {
if (objects.length === 0) {
return this.clear();
}
- var len = _emberMetal.get(this, 'length');
+ var len = _emberMetalProperty_get.get(this, 'length');
this._replace(0, len, objects);
return this;
},
unshiftObject: function (obj) {
@@ -17072,11 +17868,22 @@
this._teardownArrangedContent();
this._teardownContent();
}
});
});
-enifed('ember-runtime/system/core_object', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/mixins/action_handler', 'ember-runtime/inject'], function (exports, _emberUtils, _emberMetal, _emberRuntimeMixinsAction_handler, _emberRuntimeInject) {
+enifed('ember-runtime/system/container', ['exports', 'ember-metal/property_set', 'container/registry', 'container/container', 'container/owner'], function (exports, _emberMetalProperty_set, _containerRegistry, _containerContainer, _containerOwner) {
+ 'use strict';
+
+ _containerRegistry.default.set = _emberMetalProperty_set.set;
+ _containerContainer.default.set = _emberMetalProperty_set.set;
+
+ exports.Registry = _containerRegistry.default;
+ exports.Container = _containerContainer.default;
+ exports.getOwner = _containerOwner.getOwner;
+ exports.setOwner = _containerOwner.setOwner;
+});
+enifed('ember-runtime/system/core_object', ['exports', 'ember-metal/debug', 'ember-metal/features', 'ember-metal/assign', 'ember-metal/property_get', 'ember-metal/utils', 'ember-metal/meta', 'ember-metal/chains', 'ember-metal/events', 'ember-metal/mixin', 'ember-metal/error', 'ember-runtime/mixins/action_handler', 'ember-metal/properties', 'ember-metal/binding', 'ember-metal/computed', 'ember-metal/injected_property', 'ember-metal/run_loop', 'ember-metal/watching', 'ember-runtime/inject', 'ember-metal/symbol'], function (exports, _emberMetalDebug, _emberMetalFeatures, _emberMetalAssign, _emberMetalProperty_get, _emberMetalUtils, _emberMetalMeta, _emberMetalChains, _emberMetalEvents, _emberMetalMixin, _emberMetalError, _emberRuntimeMixinsAction_handler, _emberMetalProperties, _emberMetalBinding, _emberMetalComputed, _emberMetalInjected_property, _emberMetalRun_loop, _emberMetalWatching, _emberRuntimeInject, _emberMetalSymbol) {
'no use strict';
// Remove "use strict"; from transpiled module until
// https://bugs.webkit.org/show_bug.cgi?id=138038 is fixed
/**
@@ -17085,14 +17892,18 @@
*/
// using ember-metal/lib/main here to ensure that ember-debug is setup
// if present
- var schedule = _emberMetal.run.schedule;
- var applyMixin = _emberMetal.Mixin._apply;
- var finishPartial = _emberMetal.Mixin.finishPartial;
- var reopen = _emberMetal.Mixin.prototype.reopen;
+ var _Mixin$create;
+
+ var POST_INIT = _emberMetalSymbol.default('POST_INIT');
+ exports.POST_INIT = POST_INIT;
+ var schedule = _emberMetalRun_loop.default.schedule;
+ var applyMixin = _emberMetalMixin.Mixin._apply;
+ var finishPartial = _emberMetalMixin.Mixin.finishPartial;
+ var reopen = _emberMetalMixin.Mixin.prototype.reopen;
var hasCachedComputedProperties = false;
function makeCtor() {
// Note: avoid accessing any properties on the object since it makes the
// method a lot faster. This is glue code so we want it to be as fast as
@@ -17108,12 +17919,12 @@
if (arguments.length > 0) {
initProperties = [arguments[0]];
}
- this.__defineNonEnumerable(_emberUtils.GUID_KEY_PROPERTY);
- var m = _emberMetal.meta(this);
+ this.__defineNonEnumerable(_emberMetalUtils.GUID_KEY_PROPERTY);
+ var m = _emberMetalMeta.meta(this);
var proto = m.proto;
m.proto = this;
if (initProperties) {
// capture locally so we can clear the closed over variable
var props = initProperties;
@@ -17123,14 +17934,14 @@
var mergedProperties = this.mergedProperties;
for (var i = 0; i < props.length; i++) {
var properties = props[i];
- _emberMetal.assert('Ember.Object.create no longer supports mixing in other ' + 'definitions, use .extend & .create separately instead.', !(properties instanceof _emberMetal.Mixin));
+ _emberMetalDebug.assert('Ember.Object.create no longer supports mixing in other ' + 'definitions, use .extend & .create separately instead.', !(properties instanceof _emberMetalMixin.Mixin));
if (typeof properties !== 'object' && properties !== undefined) {
- throw new _emberMetal.Error('Ember.Object.create only accepts objects.');
+ throw new _emberMetalError.default('Ember.Object.create only accepts objects.');
}
if (!properties) {
continue;
}
@@ -17139,49 +17950,49 @@
for (var j = 0; j < keyNames.length; j++) {
var keyName = keyNames[j];
var value = properties[keyName];
- if (_emberMetal.detectBinding(keyName)) {
+ if (_emberMetalMixin.detectBinding(keyName)) {
m.writeBindings(keyName, value);
}
var possibleDesc = this[keyName];
var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined;
- _emberMetal.assert('Ember.Object.create no longer supports defining computed ' + 'properties. Define computed properties using extend() or reopen() ' + 'before calling create().', !(value instanceof _emberMetal.ComputedProperty));
- _emberMetal.assert('Ember.Object.create no longer supports defining methods that call _super.', !(typeof value === 'function' && value.toString().indexOf('._super') !== -1));
- _emberMetal.assert('`actions` must be provided at extend time, not at create time, ' + 'when Ember.ActionHandler is used (i.e. views, controllers & routes).', !(keyName === 'actions' && _emberRuntimeMixinsAction_handler.default.detect(this)));
+ _emberMetalDebug.assert('Ember.Object.create no longer supports defining computed ' + 'properties. Define computed properties using extend() or reopen() ' + 'before calling create().', !(value instanceof _emberMetalComputed.ComputedProperty));
+ _emberMetalDebug.assert('Ember.Object.create no longer supports defining methods that call _super.', !(typeof value === 'function' && value.toString().indexOf('._super') !== -1));
+ _emberMetalDebug.assert('`actions` must be provided at extend time, not at create time, ' + 'when Ember.ActionHandler is used (i.e. views, controllers & routes).', !(keyName === 'actions' && _emberRuntimeMixinsAction_handler.default.detect(this)));
if (concatenatedProperties && concatenatedProperties.length > 0 && concatenatedProperties.indexOf(keyName) >= 0) {
var baseValue = this[keyName];
if (baseValue) {
if ('function' === typeof baseValue.concat) {
value = baseValue.concat(value);
} else {
- value = _emberUtils.makeArray(baseValue).concat(value);
+ value = _emberMetalUtils.makeArray(baseValue).concat(value);
}
} else {
- value = _emberUtils.makeArray(value);
+ value = _emberMetalUtils.makeArray(value);
}
}
if (mergedProperties && mergedProperties.length && mergedProperties.indexOf(keyName) >= 0) {
var originalValue = this[keyName];
- value = _emberUtils.assign({}, originalValue, value);
+ value = _emberMetalAssign.default({}, originalValue, value);
}
if (desc) {
desc.set(this, keyName, value);
} else {
if (typeof this.setUnknownProperty === 'function' && !(keyName in this)) {
this.setUnknownProperty(keyName, value);
} else {
- if (_emberMetal.isFeatureEnabled('mandatory-setter')) {
- _emberMetal.defineProperty(this, keyName, null, value); // setup mandatory setter
+ if (_emberMetalFeatures.default('mandatory-setter')) {
+ _emberMetalProperties.defineProperty(this, keyName, null, value); // setup mandatory setter
} else {
this[keyName] = value;
}
}
}
@@ -17191,19 +18002,21 @@
finishPartial(this, m);
this.init.apply(this, arguments);
+ this[POST_INIT]();
+
m.proto = proto;
- _emberMetal.finishChains(this);
- _emberMetal.sendEvent(this, 'init');
+ _emberMetalChains.finishChains(this);
+ _emberMetalEvents.sendEvent(this, 'init');
};
- Class.toString = _emberMetal.Mixin.prototype.toString;
+ Class.toString = _emberMetalMixin.Mixin.prototype.toString;
Class.willReopen = function () {
if (wasApplied) {
- Class.PrototypeMixin = _emberMetal.Mixin.create(Class.PrototypeMixin);
+ Class.PrototypeMixin = _emberMetalMixin.Mixin.create(Class.PrototypeMixin);
}
wasApplied = false;
};
@@ -17235,11 +18048,11 @@
*/
var CoreObject = makeCtor();
CoreObject.toString = function () {
return 'Ember.CoreObject';
};
- CoreObject.PrototypeMixin = _emberMetal.Mixin.create({
+ CoreObject.PrototypeMixin = _emberMetalMixin.Mixin.create((_Mixin$create = {
reopen: function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
@@ -17250,16 +18063,16 @@
/**
An overridable method called when objects are instantiated. By default,
does nothing unless it is overridden during class definition.
Example:
```javascript
- const Person = Ember.Object.extend({
- init() {
- alert(`Name is ${this.get('name')}`);
+ App.Person = Ember.Object.extend({
+ init: function() {
+ alert('Name is ' + this.get('name'));
}
});
- let steve = Person.create({
+ var steve = App.Person.create({
name: "Steve"
});
// alerts 'Name is Steve'.
```
NOTE: If you do override `init` for a framework class like `Ember.View`,
@@ -17268,336 +18081,131 @@
do important setup work, and you'll see strange behavior in your
application.
@method init
@public
*/
- init: function () {},
+ init: function () {}
- __defineNonEnumerable: function (property) {
- Object.defineProperty(this, property.name, property.descriptor);
- //this[property.name] = property.descriptor.value;
- },
+ }, _Mixin$create[POST_INIT] = function () {}, _Mixin$create.__defineNonEnumerable = function (property) {
+ Object.defineProperty(this, property.name, property.descriptor);
+ //this[property.name] = property.descriptor.value;
+ }, _Mixin$create.concatenatedProperties = null, _Mixin$create.mergedProperties = null, _Mixin$create.isDestroyed = false, _Mixin$create.isDestroying = false, _Mixin$create.destroy = function () {
+ if (this.isDestroying) {
+ return;
+ }
+ this.isDestroying = true;
- /**
- Defines the properties that will be concatenated from the superclass
- (instead of overridden).
- By default, when you extend an Ember class a property defined in
- the subclass overrides a property with the same name that is defined
- in the superclass. However, there are some cases where it is preferable
- to build up a property's value by combining the superclass' property
- value with the subclass' value. An example of this in use within Ember
- is the `classNames` property of `Ember.View`.
- Here is some sample code showing the difference between a concatenated
- property and a normal one:
- ```javascript
- const Bar = Ember.Object.extend({
- // Configure which properties to concatenate
- concatenatedProperties: ['concatenatedProperty'],
- someNonConcatenatedProperty: ['bar'],
- concatenatedProperty: ['bar']
- });
- const FooBar = Bar.extend({
- someNonConcatenatedProperty: ['foo'],
- concatenatedProperty: ['foo']
- });
- let fooBar = FooBar.create();
- fooBar.get('someNonConcatenatedProperty'); // ['foo']
- fooBar.get('concatenatedProperty'); // ['bar', 'foo']
- ```
- This behavior extends to object creation as well. Continuing the
- above example:
- ```javascript
- let fooBar = FooBar.create({
- someNonConcatenatedProperty: ['baz'],
- concatenatedProperty: ['baz']
- })
- fooBar.get('someNonConcatenatedProperty'); // ['baz']
- fooBar.get('concatenatedProperty'); // ['bar', 'foo', 'baz']
- ```
- Adding a single property that is not an array will just add it in the array:
- ```javascript
- let fooBar = FooBar.create({
- concatenatedProperty: 'baz'
- })
- view.get('concatenatedProperty'); // ['bar', 'foo', 'baz']
- ```
- Using the `concatenatedProperties` property, we can tell Ember to mix the
- content of the properties.
- In `Ember.Component` the `classNames`, `classNameBindings` and
- `attributeBindings` properties are concatenated.
- This feature is available for you to use throughout the Ember object model,
- although typical app developers are likely to use it infrequently. Since
- it changes expectations about behavior of properties, you should properly
- document its usage in each individual concatenated property (to not
- mislead your users to think they can override the property in a subclass).
- @property concatenatedProperties
- @type Array
- @default null
- @public
- */
- concatenatedProperties: null,
-
- /**
- Defines the properties that will be merged from the superclass
- (instead of overridden).
- By default, when you extend an Ember class a property defined in
- the subclass overrides a property with the same name that is defined
- in the superclass. However, there are some cases where it is preferable
- to build up a property's value by merging the superclass property value
- with the subclass property's value. An example of this in use within Ember
- is the `queryParams` property of routes.
- Here is some sample code showing the difference between a merged
- property and a normal one:
- ```javascript
- const Bar = Ember.Object.extend({
- // Configure which properties are to be merged
- mergedProperties: ['mergedProperty'],
- someNonMergedProperty: {
- nonMerged: 'superclass value of nonMerged'
- },
- mergedProperty: {
- page: {replace: false},
- limit: {replace: true}
- }
- });
- const FooBar = Bar.extend({
- someNonMergedProperty: {
- completelyNonMerged: 'subclass value of nonMerged'
- },
- mergedProperty: {
- limit: {replace: false}
- }
- });
- let fooBar = FooBar.create();
- fooBar.get('someNonMergedProperty');
- // => { completelyNonMerged: 'subclass value of nonMerged' }
- //
- // Note the entire object, including the nonMerged property of
- // the superclass object, has been replaced
- fooBar.get('mergedProperty');
- // => {
- // page: {replace: false},
- // limit: {replace: false}
- // }
- //
- // Note the page remains from the superclass, and the
- // `limit` property's value of `false` has been merged from
- // the subclass.
- ```
- This behavior is not available during object `create` calls. It is only
- available at `extend` time.
- In `Ember.Route` the `queryParams` property is merged.
- This feature is available for you to use throughout the Ember object model,
- although typical app developers are likely to use it infrequently. Since
- it changes expectations about behavior of properties, you should properly
- document its usage in each individual merged property (to not
- mislead your users to think they can override the property in a subclass).
- @property mergedProperties
- @type Array
- @default null
- @public
- */
- mergedProperties: null,
-
- /**
- Destroyed object property flag.
- if this property is `true` the observers and bindings were already
- removed by the effect of calling the `destroy()` method.
- @property isDestroyed
- @default false
- @public
- */
- isDestroyed: false,
-
- /**
- Destruction scheduled flag. The `destroy()` method has been called.
- The object stays intact until the end of the run loop at which point
- the `isDestroyed` flag is set.
- @property isDestroying
- @default false
- @public
- */
- isDestroying: false,
-
- /**
- Destroys an object by setting the `isDestroyed` flag and removing its
- metadata, which effectively destroys observers and bindings.
- If you try to set a property on a destroyed object, an exception will be
- raised.
- Note that destruction is scheduled for the end of the run loop and does not
- happen immediately. It will set an isDestroying flag immediately.
- @method destroy
- @return {Ember.Object} receiver
- @public
- */
- destroy: function () {
- if (this.isDestroying) {
- return;
- }
- this.isDestroying = true;
-
- schedule('actions', this, this.willDestroy);
- schedule('destroy', this, this._scheduledDestroy);
- return this;
- },
-
- /**
- Override to implement teardown.
- @method willDestroy
- @public
- */
- willDestroy: function () {},
-
- /**
- Invoked by the run loop to actually destroy the object. This is
- scheduled for execution by the `destroy` method.
- @private
- @method _scheduledDestroy
- */
- _scheduledDestroy: function () {
- if (this.isDestroyed) {
- return;
- }
- _emberMetal.destroy(this);
- this.isDestroyed = true;
- },
-
- bind: function (to, from) {
- if (!(from instanceof _emberMetal.Binding)) {
- from = _emberMetal.Binding.from(from);
- }
- from.to(to).connect(this);
- return from;
- },
-
- /**
- Returns a string representation which attempts to provide more information
- than Javascript's `toString` typically does, in a generic way for all Ember
- objects.
- ```javascript
- const Person = Ember.Object.extend()
- person = Person.create()
- person.toString() //=> "<Person:ember1024>"
- ```
- If the object's class is not defined on an Ember namespace, it will
- indicate it is a subclass of the registered superclass:
- ```javascript
- const Student = Person.extend()
- let student = Student.create()
- student.toString() //=> "<(subclass of Person):ember1025>"
- ```
- If the method `toStringExtension` is defined, its return value will be
- included in the output.
- ```javascript
- const Teacher = Person.extend({
- toStringExtension() {
- return this.get('fullName');
- }
- });
- teacher = Teacher.create()
- teacher.toString(); //=> "<Teacher:ember1026:Tom Dale>"
- ```
- @method toString
- @return {String} string representation
- @public
- */
- toString: function () {
- var hasToStringExtension = typeof this.toStringExtension === 'function';
- var extension = hasToStringExtension ? ':' + this.toStringExtension() : '';
- var ret = '<' + this.constructor.toString() + ':' + _emberUtils.guidFor(this) + extension + '>';
-
- return ret;
+ schedule('actions', this, this.willDestroy);
+ schedule('destroy', this, this._scheduledDestroy);
+ return this;
+ }, _Mixin$create.willDestroy = function () {}, _Mixin$create._scheduledDestroy = function () {
+ if (this.isDestroyed) {
+ return;
}
- });
+ _emberMetalWatching.destroy(this);
+ this.isDestroyed = true;
+ }, _Mixin$create.bind = function (to, from) {
+ if (!(from instanceof _emberMetalBinding.Binding)) {
+ from = _emberMetalBinding.Binding.from(from);
+ }
+ from.to(to).connect(this);
+ return from;
+ }, _Mixin$create.toString = function () {
+ var hasToStringExtension = typeof this.toStringExtension === 'function';
+ var extension = hasToStringExtension ? ':' + this.toStringExtension() : '';
+ var ret = '<' + this.constructor.toString() + ':' + _emberMetalUtils.guidFor(this) + extension + '>';
+ return ret;
+ }, _Mixin$create));
+
CoreObject.PrototypeMixin.ownerConstructor = CoreObject;
CoreObject.__super__ = null;
var ClassMixinProps = {
- ClassMixin: _emberMetal.REQUIRED,
+ ClassMixin: _emberMetalMixin.REQUIRED,
- PrototypeMixin: _emberMetal.REQUIRED,
+ PrototypeMixin: _emberMetalMixin.REQUIRED,
isClass: true,
isMethod: false,
/**
Creates a new subclass.
```javascript
- const Person = Ember.Object.extend({
- say(thing) {
+ App.Person = Ember.Object.extend({
+ say: function(thing) {
alert(thing);
}
});
```
- This defines a new subclass of Ember.Object: `Person`. It contains one method: `say()`.
+ This defines a new subclass of Ember.Object: `App.Person`. It contains one method: `say()`.
You can also create a subclass from any existing class by calling its `extend()` method.
- For example, you might want to create a subclass of Ember's built-in `Ember.Component` class:
+ For example, you might want to create a subclass of Ember's built-in `Ember.View` class:
```javascript
- const PersonComponent = Ember.Component.extend({
+ App.PersonView = Ember.View.extend({
tagName: 'li',
classNameBindings: ['isAdministrator']
});
```
When defining a subclass, you can override methods but still access the
implementation of your parent class by calling the special `_super()` method:
```javascript
- const Person = Ember.Object.extend({
- say(thing) {
+ App.Person = Ember.Object.extend({
+ say: function(thing) {
var name = this.get('name');
- alert(`${name} says: ${thing}`);
+ alert(name + ' says: ' + thing);
}
});
- const Soldier = Person.extend({
- say(thing) {
- this._super(`${thing}, sir!`);
+ App.Soldier = App.Person.extend({
+ say: function(thing) {
+ this._super(thing + ", sir!");
},
- march(numberOfHours) {
- alert(`${this.get('name')} marches for ${numberOfHours} hours.`);
+ march: function(numberOfHours) {
+ alert(this.get('name') + ' marches for ' + numberOfHours + ' hours.');
}
});
- let yehuda = Soldier.create({
+ var yehuda = App.Soldier.create({
name: "Yehuda Katz"
});
yehuda.say("Yes"); // alerts "Yehuda Katz says: Yes, sir!"
```
- The `create()` on line #17 creates an *instance* of the `Soldier` class.
- The `extend()` on line #8 creates a *subclass* of `Person`. Any instance
- of the `Person` class will *not* have the `march()` method.
+ The `create()` on line #17 creates an *instance* of the `App.Soldier` class.
+ The `extend()` on line #8 creates a *subclass* of `App.Person`. Any instance
+ of the `App.Person` class will *not* have the `march()` method.
You can also pass `Mixin` classes to add additional properties to the subclass.
```javascript
- const Person = Ember.Object.extend({
- say(thing) {
- alert(`${this.get('name')} says: ${thing}`);
+ App.Person = Ember.Object.extend({
+ say: function(thing) {
+ alert(this.get('name') + ' says: ' + thing);
}
});
- const SingingMixin = Mixin.create({
- sing(thing){
- alert(`${this.get('name')} sings: la la la ${thing}`);
+ App.SingingMixin = Mixin.create({
+ sing: function(thing){
+ alert(this.get('name') + ' sings: la la la ' + thing);
}
});
- const BroadwayStar = Person.extend(SingingMixin, {
- dance() {
- alert(`${this.get('name')} dances: tap tap tap tap `);
+ App.BroadwayStar = App.Person.extend(App.SingingMixin, {
+ dance: function() {
+ alert(this.get('name') + ' dances: tap tap tap tap ');
}
});
```
- The `BroadwayStar` class contains three methods: `say()`, `sing()`, and `dance()`.
+ The `App.BroadwayStar` class contains three methods: `say()`, `sing()`, and `dance()`.
@method extend
@static
@param {Mixin} [mixins]* One or more Mixin classes
@param {Object} [arguments]* Object containing values to use within the new class
@public
*/
extend: function () {
var Class = makeCtor();
var proto;
- Class.ClassMixin = _emberMetal.Mixin.create(this.ClassMixin);
- Class.PrototypeMixin = _emberMetal.Mixin.create(this.PrototypeMixin);
+ Class.ClassMixin = _emberMetalMixin.Mixin.create(this.ClassMixin);
+ Class.PrototypeMixin = _emberMetalMixin.Mixin.create(this.PrototypeMixin);
Class.ClassMixin.ownerConstructor = Class;
Class.PrototypeMixin.ownerConstructor = Class;
reopen.apply(Class.PrototypeMixin, arguments);
@@ -17605,37 +18213,37 @@
Class.superclass = this;
Class.__super__ = this.prototype;
proto = Class.prototype = Object.create(this.prototype);
proto.constructor = Class;
- _emberUtils.generateGuid(proto);
- _emberMetal.meta(proto).proto = proto; // this will disable observers on prototype
+ _emberMetalUtils.generateGuid(proto);
+ _emberMetalMeta.meta(proto).proto = proto; // this will disable observers on prototype
Class.ClassMixin.apply(Class);
return Class;
},
/**
Creates an instance of a class. Accepts either no arguments, or an object
containing values to initialize the newly instantiated object with.
```javascript
- const Person = Ember.Object.extend({
- helloWorld() {
- alert(`Hi, my name is ${this.get('name')}`);
+ App.Person = Ember.Object.extend({
+ helloWorld: function() {
+ alert("Hi, my name is " + this.get('name'));
}
});
- let tom = Person.create({
+ var tom = App.Person.create({
name: 'Tom Dale'
});
tom.helloWorld(); // alerts "Hi, my name is Tom Dale".
```
`create` will call the `init` function if defined during
`Ember.AnyObject.extend`
If no arguments are passed to `create`, it will not set values to the new
instance during initialization:
```javascript
- let noName = Person.create();
+ var noName = App.Person.create();
noName.helloWorld(); // alerts undefined
```
NOTE: For performance reasons, you cannot declare methods or computed
properties during `create`. You should instead declare methods and computed
properties when using `extend`.
@@ -17659,17 +18267,17 @@
/**
Augments a constructor's prototype with additional
properties and functions:
```javascript
- const MyObject = Ember.Object.extend({
+ MyObject = Ember.Object.extend({
name: 'an object'
});
o = MyObject.create();
o.get('name'); // 'an object'
MyObject.reopen({
- say(msg){
+ say: function(msg){
console.log(msg);
}
})
o2 = MyObject.create();
o2.say("hello"); // logs "hello"
@@ -17687,11 +18295,11 @@
},
/**
Augments a constructor's own properties and functions:
```javascript
- const MyObject = Ember.Object.extend({
+ MyObject = Ember.Object.extend({
name: 'an object'
});
MyObject.reopenClass({
canBuild: false
});
@@ -17699,34 +18307,34 @@
o = MyObject.create();
```
In other words, this creates static properties and functions for the class.
These are only available on the class and not on any instance of that class.
```javascript
- const Person = Ember.Object.extend({
- name: "",
- sayHello() {
+ App.Person = Ember.Object.extend({
+ name : "",
+ sayHello : function() {
alert("Hello. My name is " + this.get('name'));
}
});
- Person.reopenClass({
- species: "Homo sapiens",
- createPerson(newPersonsName){
- return Person.create({
+ App.Person.reopenClass({
+ species : "Homo sapiens",
+ createPerson: function(newPersonsName){
+ return App.Person.create({
name:newPersonsName
});
}
});
- let tom = Person.create({
- name: "Tom Dale"
+ var tom = App.Person.create({
+ name : "Tom Dale"
});
- let yehuda = Person.createPerson("Yehuda Katz");
+ var yehuda = App.Person.createPerson("Yehuda Katz");
tom.sayHello(); // "Hello. My name is Tom Dale"
yehuda.sayHello(); // "Hello. My name is Yehuda Katz"
- alert(Person.species); // "Homo sapiens"
+ alert(App.Person.species); // "Homo sapiens"
```
Note that `species` and `createPerson` are *not* valid on the `tom` and `yehuda`
- variables. They are only valid on `Person`.
+ variables. They are only valid on `App.Person`.
To add functions and properties to instances of
a constructor by extending the constructor's prototype
see `reopen`
@method reopenClass
@public
@@ -17759,14 +18367,14 @@
metadata about how they function or what values they operate on. For
example, computed property functions may close over variables that are then
no longer available for introspection.
You can pass a hash of these values to a computed property like this:
```javascript
- person: Ember.computed(function() {
+ person: function() {
var personId = this.get('personId');
- return Person.create({ id: personId });
- }).meta({ type: Person })
+ return App.Person.create({ id: personId });
+ }.property().meta({ type: App.Person })
```
Once you've done this, you can retrieve the values saved to the computed
property from your class like this:
```javascript
MyClass.metaForProperty('person');
@@ -17780,15 +18388,15 @@
metaForProperty: function (key) {
var proto = this.proto();
var possibleDesc = proto[key];
var desc = possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor ? possibleDesc : undefined;
- _emberMetal.assert('metaForProperty() could not find a computed property ' + 'with key \'' + key + '\'.', !!desc && desc instanceof _emberMetal.ComputedProperty);
+ _emberMetalDebug.assert('metaForProperty() could not find a computed property ' + 'with key \'' + key + '\'.', !!desc && desc instanceof _emberMetalComputed.ComputedProperty);
return desc._meta || {};
},
- _computedProperties: _emberMetal.computed(function () {
+ _computedProperties: _emberMetalComputed.computed(function () {
hasCachedComputedProperties = true;
var proto = this.proto();
var property;
var properties = [];
@@ -17816,24 +18424,24 @@
*/
eachComputedProperty: function (callback, binding) {
var property;
var empty = {};
- var properties = _emberMetal.get(this, '_computedProperties');
+ var properties = _emberMetalProperty_get.get(this, '_computedProperties');
for (var i = 0; i < properties.length; i++) {
property = properties[i];
callback.call(binding || this, property.name, property.meta || empty);
}
}
};
function injectedPropertyAssertion() {
- _emberMetal.assert('Injected properties are invalid', _emberRuntimeInject.validatePropertyInjections(this));
+ _emberMetalDebug.assert('Injected properties are invalid', _emberRuntimeInject.validatePropertyInjections(this));
}
- _emberMetal.runInDebug(function () {
+ _emberMetalDebug.runInDebug(function () {
/**
Provides lookup-time type validation for injected properties.
@private
@method _onLookup
*/
@@ -17853,19 +18461,19 @@
var proto = this.proto();
var key, desc;
for (key in proto) {
desc = proto[key];
- if (desc instanceof _emberMetal.InjectedProperty) {
+ if (desc instanceof _emberMetalInjected_property.default) {
injections[key] = desc.type + ':' + (desc.name || key);
}
}
return injections;
};
- var ClassMixin = _emberMetal.Mixin.create(ClassMixinProps);
+ var ClassMixin = _emberMetalMixin.Mixin.create(ClassMixinProps);
ClassMixin.ownerConstructor = CoreObject;
CoreObject.ClassMixin = ClassMixin;
@@ -17874,23 +18482,215 @@
CoreObject.reopen({
didDefineProperty: function (proto, key, value) {
if (hasCachedComputedProperties === false) {
return;
}
- if (value instanceof _emberMetal.ComputedProperty) {
- var cache = _emberMetal.meta(this.constructor).readableCache();
+ if (value instanceof _emberMetalComputed.ComputedProperty) {
+ var cache = _emberMetalMeta.meta(this.constructor).readableCache();
if (cache && cache._computedProperties !== undefined) {
cache._computedProperties = undefined;
}
}
}
});
exports.default = CoreObject;
});
-enifed('ember-runtime/system/each_proxy', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/mixins/array'], function (exports, _emberUtils, _emberMetal, _emberRuntimeMixinsArray) {
+
+// NOTE: this object should never be included directly. Instead use `Ember.Object`.
+// We only define this separately so that `Ember.Set` can depend on it.
+
+/**
+ Defines the properties that will be concatenated from the superclass
+ (instead of overridden).
+ By default, when you extend an Ember class a property defined in
+ the subclass overrides a property with the same name that is defined
+ in the superclass. However, there are some cases where it is preferable
+ to build up a property's value by combining the superclass' property
+ value with the subclass' value. An example of this in use within Ember
+ is the `classNames` property of `Ember.View`.
+ Here is some sample code showing the difference between a concatenated
+ property and a normal one:
+ ```javascript
+ App.BarView = Ember.View.extend({
+ someNonConcatenatedProperty: ['bar'],
+ classNames: ['bar']
+ });
+ App.FooBarView = App.BarView.extend({
+ someNonConcatenatedProperty: ['foo'],
+ classNames: ['foo']
+ });
+ var fooBarView = App.FooBarView.create();
+ fooBarView.get('someNonConcatenatedProperty'); // ['foo']
+ fooBarView.get('classNames'); // ['ember-view', 'bar', 'foo']
+ ```
+ This behavior extends to object creation as well. Continuing the
+ above example:
+ ```javascript
+ var view = App.FooBarView.create({
+ someNonConcatenatedProperty: ['baz'],
+ classNames: ['baz']
+ })
+ view.get('someNonConcatenatedProperty'); // ['baz']
+ view.get('classNames'); // ['ember-view', 'bar', 'foo', 'baz']
+ ```
+ Adding a single property that is not an array will just add it in the array:
+ ```javascript
+ var view = App.FooBarView.create({
+ classNames: 'baz'
+ })
+ view.get('classNames'); // ['ember-view', 'bar', 'foo', 'baz']
+ ```
+ Using the `concatenatedProperties` property, we can tell Ember to mix the
+ content of the properties.
+ In `Ember.View` the `classNameBindings` and `attributeBindings` properties
+ are also concatenated, in addition to `classNames`.
+ This feature is available for you to use throughout the Ember object model,
+ although typical app developers are likely to use it infrequently. Since
+ it changes expectations about behavior of properties, you should properly
+ document its usage in each individual concatenated property (to not
+ mislead your users to think they can override the property in a subclass).
+ @property concatenatedProperties
+ @type Array
+ @default null
+ @public
+*/
+
+/**
+ Defines the properties that will be merged from the superclass
+ (instead of overridden).
+ By default, when you extend an Ember class a property defined in
+ the subclass overrides a property with the same name that is defined
+ in the superclass. However, there are some cases where it is preferable
+ to build up a property's value by merging the superclass property value
+ with the subclass property's value. An example of this in use within Ember
+ is the `queryParams` property of routes.
+ Here is some sample code showing the difference between a merged
+ property and a normal one:
+ ```javascript
+ App.BarRoute = Ember.Route.extend({
+ someNonMergedProperty: {
+ nonMerged: 'superclass value of nonMerged'
+ },
+ queryParams: {
+ page: {replace: false},
+ limit: {replace: true}
+ }
+ });
+ App.FooBarRoute = App.BarRoute.extend({
+ someNonMergedProperty: {
+ completelyNonMerged: 'subclass value of nonMerged'
+ },
+ queryParams: {
+ limit: {replace: false}
+ }
+ });
+ var fooBarRoute = App.FooBarRoute.create();
+ fooBarRoute.get('someNonMergedProperty');
+ // => { completelyNonMerged: 'subclass value of nonMerged' }
+ //
+ // Note the entire object, including the nonMerged property of
+ // the superclass object, has been replaced
+ fooBarRoute.get('queryParams');
+ // => {
+ // page: {replace: false},
+ // limit: {replace: false}
+ // }
+ //
+ // Note the page remains from the superclass, and the
+ // `limit` property's value of `false` has been merged from
+ // the subclass.
+ ```
+ This behavior is not available during object `create` calls. It is only
+ available at `extend` time.
+ This feature is available for you to use throughout the Ember object model,
+ although typical app developers are likely to use it infrequently. Since
+ it changes expectations about behavior of properties, you should properly
+ document its usage in each individual merged property (to not
+ mislead your users to think they can override the property in a subclass).
+ @property mergedProperties
+ @type Array
+ @default null
+ @public
+*/
+
+/**
+ Destroyed object property flag.
+ if this property is `true` the observers and bindings were already
+ removed by the effect of calling the `destroy()` method.
+ @property isDestroyed
+ @default false
+ @public
+*/
+
+/**
+ Destruction scheduled flag. The `destroy()` method has been called.
+ The object stays intact until the end of the run loop at which point
+ the `isDestroyed` flag is set.
+ @property isDestroying
+ @default false
+ @public
+*/
+
+/**
+ Destroys an object by setting the `isDestroyed` flag and removing its
+ metadata, which effectively destroys observers and bindings.
+ If you try to set a property on a destroyed object, an exception will be
+ raised.
+ Note that destruction is scheduled for the end of the run loop and does not
+ happen immediately. It will set an isDestroying flag immediately.
+ @method destroy
+ @return {Ember.Object} receiver
+ @public
+*/
+
+/**
+ Override to implement teardown.
+ @method willDestroy
+ @public
+*/
+
+/**
+ Invoked by the run loop to actually destroy the object. This is
+ scheduled for execution by the `destroy` method.
+ @private
+ @method _scheduledDestroy
+*/
+
+/**
+ Returns a string representation which attempts to provide more information
+ than Javascript's `toString` typically does, in a generic way for all Ember
+ objects.
+ ```javascript
+ App.Person = Em.Object.extend()
+ person = App.Person.create()
+ person.toString() //=> "<App.Person:ember1024>"
+ ```
+ If the object's class is not defined on an Ember namespace, it will
+ indicate it is a subclass of the registered superclass:
+ ```javascript
+ Student = App.Person.extend()
+ student = Student.create()
+ student.toString() //=> "<(subclass of App.Person):ember1025>"
+ ```
+ If the method `toStringExtension` is defined, its return value will be
+ included in the output.
+ ```javascript
+ App.Teacher = App.Person.extend({
+ toStringExtension: function() {
+ return this.get('fullName');
+ }
+ });
+ teacher = App.Teacher.create()
+ teacher.toString(); //=> "<App.Teacher:ember1026:Tom Dale>"
+ ```
+ @method toString
+ @return {String} string representation
+ @public
+*/
+enifed('ember-runtime/system/each_proxy', ['exports', 'ember-metal/debug', 'ember-metal/property_get', 'ember-metal/observer', 'ember-metal/property_events', 'ember-metal/empty_object', 'ember-runtime/mixins/array'], function (exports, _emberMetalDebug, _emberMetalProperty_get, _emberMetalObserver, _emberMetalProperty_events, _emberMetalEmpty_object, _emberRuntimeMixinsArray) {
'use strict';
exports.default = EachProxy;
/**
@@ -17921,22 +18721,22 @@
var lim = removedCnt > 0 ? idx + removedCnt : -1;
for (var key in keys) {
if (lim > 0) {
removeObserverForContentKey(content, key, this, idx, lim);
}
- _emberMetal.propertyWillChange(this, key);
+ _emberMetalProperty_events.propertyWillChange(this, key);
}
},
arrayDidChange: function (content, idx, removedCnt, addedCnt) {
var keys = this._keys;
var lim = addedCnt > 0 ? idx + addedCnt : -1;
for (var key in keys) {
if (lim > 0) {
addObserverForContentKey(content, key, this, idx, lim);
}
- _emberMetal.propertyDidChange(this, key);
+ _emberMetalProperty_events.propertyDidChange(this, key);
}
},
// ..........................................................
// LISTEN FOR NEW OBSERVERS AND OTHER EVENT LISTENERS
@@ -17955,17 +18755,17 @@
// Actual watch keys on the source content.
beginObservingContentKey: function (keyName) {
var keys = this._keys;
if (!keys) {
- keys = this._keys = new _emberUtils.EmptyObject();
+ keys = this._keys = new _emberMetalEmpty_object.default();
}
if (!keys[keyName]) {
keys[keyName] = 1;
var content = this._content;
- var len = _emberMetal.get(content, 'length');
+ var len = _emberMetalProperty_get.get(content, 'length');
addObserverForContentKey(content, keyName, this, 0, len);
} else {
keys[keyName]++;
}
@@ -17973,42 +18773,42 @@
stopObservingContentKey: function (keyName) {
var keys = this._keys;
if (keys && keys[keyName] > 0 && --keys[keyName] <= 0) {
var content = this._content;
- var len = _emberMetal.get(content, 'length');
+ var len = _emberMetalProperty_get.get(content, 'length');
removeObserverForContentKey(content, keyName, this, 0, len);
}
},
contentKeyWillChange: function (obj, keyName) {
- _emberMetal.propertyWillChange(this, keyName);
+ _emberMetalProperty_events.propertyWillChange(this, keyName);
},
contentKeyDidChange: function (obj, keyName) {
- _emberMetal.propertyDidChange(this, keyName);
+ _emberMetalProperty_events.propertyDidChange(this, keyName);
}
};
function addObserverForContentKey(content, keyName, proxy, idx, loc) {
while (--loc >= idx) {
var item = _emberRuntimeMixinsArray.objectAt(content, loc);
if (item) {
- _emberMetal.assert('When using @each to observe the array ' + content + ', the array must return an object', typeof item === 'object');
- _emberMetal._addBeforeObserver(item, keyName, proxy, 'contentKeyWillChange');
- _emberMetal.addObserver(item, keyName, proxy, 'contentKeyDidChange');
+ _emberMetalDebug.assert('When using @each to observe the array ' + content + ', the array must return an object', typeof item === 'object');
+ _emberMetalObserver._addBeforeObserver(item, keyName, proxy, 'contentKeyWillChange');
+ _emberMetalObserver.addObserver(item, keyName, proxy, 'contentKeyDidChange');
}
}
}
function removeObserverForContentKey(content, keyName, proxy, idx, loc) {
while (--loc >= idx) {
var item = _emberRuntimeMixinsArray.objectAt(content, loc);
if (item) {
- _emberMetal._removeBeforeObserver(item, keyName, proxy, 'contentKeyWillChange');
- _emberMetal.removeObserver(item, keyName, proxy, 'contentKeyDidChange');
+ _emberMetalObserver._removeBeforeObserver(item, keyName, proxy, 'contentKeyWillChange');
+ _emberMetalObserver.removeObserver(item, keyName, proxy, 'contentKeyDidChange');
}
}
}
});
enifed('ember-runtime/system/lazy_load', ['exports', 'ember-environment'], function (exports, _emberEnvironment) {
@@ -18085,11 +18885,11 @@
return callback(object);
});
}
}
});
-enifed('ember-runtime/system/namespace', ['exports', 'ember-utils', 'ember-metal', 'ember-environment', 'ember-runtime/system/object'], function (exports, _emberUtils, _emberMetal, _emberEnvironment, _emberRuntimeSystemObject) {
+enifed('ember-runtime/system/namespace', ['exports', 'ember-metal/core', 'ember-environment', 'ember-metal/property_get', 'ember-metal/utils', 'ember-metal/mixin', 'ember-runtime/system/object'], function (exports, _emberMetalCore, _emberEnvironment, _emberMetalProperty_get, _emberMetalUtils, _emberMetalMixin, _emberRuntimeSystemObject) {
/**
@module ember
@submodule ember-runtime
*/
'use strict';
@@ -18132,17 +18932,17 @@
Namespace.NAMESPACES.push(this);
Namespace.PROCESSED = false;
},
toString: function () {
- var name = _emberMetal.get(this, 'name') || _emberMetal.get(this, 'modulePrefix');
+ var name = _emberMetalProperty_get.get(this, 'name') || _emberMetalProperty_get.get(this, 'modulePrefix');
if (name) {
return name;
}
findNamespaces();
- return this[_emberMetal.NAME_KEY];
+ return this[_emberMetalMixin.NAME_KEY];
},
nameClasses: function () {
processNamespace([this.toString()], this, {});
},
@@ -18159,13 +18959,13 @@
this._super.apply(this, arguments);
}
});
Namespace.reopenClass({
- NAMESPACES: [_emberMetal.default],
+ NAMESPACES: [_emberMetalCore.default],
NAMESPACES_BY_ID: {
- Ember: _emberMetal.default
+ Ember: _emberMetalCore.default
},
PROCESSED: false,
processAll: processAllNamespaces,
byName: function (name) {
if (!searchDisabled) {
@@ -18198,22 +18998,22 @@
// the key, so processing `Ember.View` will make the Array
// `['Ember', 'View']`.
paths[idx] = key;
// If we have found an unprocessed class
- if (obj && obj.toString === classToString && !obj[_emberMetal.NAME_KEY]) {
+ if (obj && obj.toString === classToString && !obj[_emberMetalMixin.NAME_KEY]) {
// Replace the class' `toString` with the dot-separated path
// and set its `NAME_KEY`
- obj[_emberMetal.NAME_KEY] = paths.join('.');
+ obj[_emberMetalMixin.NAME_KEY] = paths.join('.');
// Support nested namespaces
} else if (obj && obj.isNamespace) {
// Skip aliased namespaces
- if (seen[_emberUtils.guidFor(obj)]) {
+ if (seen[_emberMetalUtils.guidFor(obj)]) {
continue;
}
- seen[_emberUtils.guidFor(obj)] = true;
+ seen[_emberMetalUtils.guidFor(obj)] = true;
// Process the child namespace
processNamespace(paths, obj, seen);
}
}
@@ -18247,34 +19047,34 @@
if (!isUppercase(key.charCodeAt(0))) {
continue;
}
var obj = tryIsNamespace(lookup, key);
if (obj) {
- obj[_emberMetal.NAME_KEY] = key;
+ obj[_emberMetalMixin.NAME_KEY] = key;
}
}
}
function superClassString(mixin) {
var superclass = mixin.superclass;
if (superclass) {
- if (superclass[_emberMetal.NAME_KEY]) {
- return superclass[_emberMetal.NAME_KEY];
+ if (superclass[_emberMetalMixin.NAME_KEY]) {
+ return superclass[_emberMetalMixin.NAME_KEY];
}
return superClassString(superclass);
}
}
function classToString() {
- if (!searchDisabled && !this[_emberMetal.NAME_KEY]) {
+ if (!searchDisabled && !this[_emberMetalMixin.NAME_KEY]) {
processAllNamespaces();
}
var ret = undefined;
- if (this[_emberMetal.NAME_KEY]) {
- ret = this[_emberMetal.NAME_KEY];
+ if (this[_emberMetalMixin.NAME_KEY]) {
+ ret = this[_emberMetalMixin.NAME_KEY];
} else if (this._toString) {
ret = this._toString;
} else {
var str = superClassString(this);
if (str) {
@@ -18288,11 +19088,11 @@
return ret;
}
function processAllNamespaces() {
var unprocessedNamespaces = !Namespace.PROCESSED;
- var unprocessedMixins = _emberMetal.hasUnprocessedMixins();
+ var unprocessedMixins = _emberMetalMixin.hasUnprocessedMixins();
if (unprocessedNamespaces) {
findNamespaces();
Namespace.PROCESSED = true;
}
@@ -18304,26 +19104,26 @@
for (var i = 0; i < namespaces.length; i++) {
namespace = namespaces[i];
processNamespace([namespace.toString()], namespace, {});
}
- _emberMetal.clearUnprocessedMixins();
+ _emberMetalMixin.clearUnprocessedMixins();
}
}
function makeToString(ret) {
return function () {
return ret;
};
}
- _emberMetal.Mixin.prototype.toString = classToString; // ES6TODO: altering imported objects. SBB.
+ _emberMetalMixin.Mixin.prototype.toString = classToString; // ES6TODO: altering imported objects. SBB.
exports.default = Namespace;
});
// Preloaded into namespaces
-enifed('ember-runtime/system/native_array', ['exports', 'ember-metal', 'ember-environment', 'ember-runtime/mixins/array', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/observable', 'ember-runtime/mixins/copyable', 'ember-runtime/mixins/freezable', 'ember-runtime/copy'], function (exports, _emberMetal, _emberEnvironment, _emberRuntimeMixinsArray, _emberRuntimeMixinsMutable_array, _emberRuntimeMixinsObservable, _emberRuntimeMixinsCopyable, _emberRuntimeMixinsFreezable, _emberRuntimeCopy) {
+enifed('ember-runtime/system/native_array', ['exports', 'ember-metal/core', 'ember-environment', 'ember-metal/replace', 'ember-metal/property_get', 'ember-metal/mixin', 'ember-runtime/mixins/array', 'ember-runtime/mixins/mutable_array', 'ember-runtime/mixins/observable', 'ember-runtime/mixins/copyable', 'ember-runtime/mixins/freezable', 'ember-runtime/copy'], function (exports, _emberMetalCore, _emberEnvironment, _emberMetalReplace, _emberMetalProperty_get, _emberMetalMixin, _emberRuntimeMixinsArray, _emberRuntimeMixinsMutable_array, _emberRuntimeMixinsObservable, _emberRuntimeMixinsCopyable, _emberRuntimeMixinsFreezable, _emberRuntimeCopy) {
/**
@module ember
@submodule ember-runtime
*/
'use strict';
@@ -18344,11 +19144,11 @@
@uses Ember.MutableArray
@uses Ember.Observable
@uses Ember.Copyable
@public
*/
- var NativeArray = _emberMetal.Mixin.create(_emberRuntimeMixinsMutable_array.default, _emberRuntimeMixinsObservable.default, _emberRuntimeMixinsCopyable.default, {
+ var NativeArray = _emberMetalMixin.Mixin.create(_emberRuntimeMixinsMutable_array.default, _emberRuntimeMixinsObservable.default, _emberRuntimeMixinsCopyable.default, {
// because length is a built-in property we need to know to just get the
// original property.
get: function (key) {
if ('number' === typeof key) {
@@ -18369,17 +19169,17 @@
}
// if we replaced exactly the same number of items, then pass only the
// replaced range. Otherwise, pass the full remaining array length
// since everything has shifted
- var len = objects ? _emberMetal.get(objects, 'length') : 0;
+ var len = objects ? _emberMetalProperty_get.get(objects, 'length') : 0;
_emberRuntimeMixinsArray.arrayContentWillChange(this, idx, amt, len);
if (len === 0) {
this.splice(idx, amt);
} else {
- _emberMetal.replace(this, idx, amt, objects);
+ _emberMetalReplace.default(this, idx, amt, objects);
}
_emberRuntimeMixinsArray.arrayContentDidChange(this, idx, amt, len);
return this;
},
@@ -18451,11 +19251,12 @@
*/
var A = undefined;
if (_emberEnvironment.ENV.EXTEND_PROTOTYPES.Array) {
NativeArray.apply(Array.prototype);
- exports.A = A = function (arr) {
+ exports. // ES6TODO: Setting A onto the object returned by ember-metal/core to avoid circles
+ A = A = function (arr) {
return arr || [];
};
} else {
exports.A = A = function (arr) {
if (!arr) {
@@ -18463,17 +19264,16 @@
}
return _emberRuntimeMixinsArray.default.detect(arr) ? arr : NativeArray.apply(arr);
};
}
- _emberMetal.default.A = A;
- exports.A = A;
+ _emberMetalCore.default.A = A;exports.A = A;
exports.NativeArray = NativeArray;
exports.default = NativeArray;
});
// Ember.A circular
-enifed('ember-runtime/system/object', ['exports', 'ember-utils', 'ember-metal', 'ember-runtime/system/core_object', 'ember-runtime/mixins/observable'], function (exports, _emberUtils, _emberMetal, _emberRuntimeSystemCore_object, _emberRuntimeMixinsObservable) {
+enifed('ember-runtime/system/object', ['exports', 'ember-runtime/system/core_object', 'ember-runtime/mixins/observable'], function (exports, _emberRuntimeSystemCore_object, _emberRuntimeMixinsObservable) {
/**
@module ember
@submodule ember-runtime
*/
@@ -18493,30 +19293,10 @@
var EmberObject = _emberRuntimeSystemCore_object.default.extend(_emberRuntimeMixinsObservable.default);
EmberObject.toString = function () {
return 'Ember.Object';
};
- var FrameworkObject = EmberObject;
-
- exports.FrameworkObject = FrameworkObject;
- _emberMetal.runInDebug(function () {
- var _EmberObject$extend;
-
- var INIT_WAS_CALLED = _emberUtils.symbol('INIT_WAS_CALLED');
- var ASSERT_INIT_WAS_CALLED = _emberUtils.symbol('ASSERT_INIT_WAS_CALLED');
-
- exports.FrameworkObject = FrameworkObject = EmberObject.extend((_EmberObject$extend = {
- init: function () {
- this._super.apply(this, arguments);
- this[INIT_WAS_CALLED] = true;
- }
-
- }, _EmberObject$extend[ASSERT_INIT_WAS_CALLED] = _emberMetal.on('init', function () {
- _emberMetal.assert('You must call `this._super(...arguments);` when overriding `init` on a framework object. Please update ' + this + ' to call `this._super(...arguments);` from `init`.', this[INIT_WAS_CALLED]);
- }), _EmberObject$extend));
- });
-
exports.default = EmberObject;
});
enifed('ember-runtime/system/object_proxy', ['exports', 'ember-runtime/system/object', 'ember-runtime/mixins/-proxy'], function (exports, _emberRuntimeSystemObject, _emberRuntimeMixinsProxy) {
'use strict';
@@ -18638,27 +19418,27 @@
isServiceFactory: true
});
exports.default = Service;
});
-enifed('ember-runtime/system/string', ['exports', 'ember-metal', 'ember-utils', 'ember-runtime/utils', 'ember-runtime/string_registry'], function (exports, _emberMetal, _emberUtils, _emberRuntimeUtils, _emberRuntimeString_registry) {
+enifed('ember-runtime/system/string', ['exports', 'ember-metal/debug', 'ember-metal/utils', 'ember-runtime/utils', 'ember-runtime/string_registry', 'ember-metal/cache'], function (exports, _emberMetalDebug, _emberMetalUtils, _emberRuntimeUtils, _emberRuntimeString_registry, _emberMetalCache) {
/**
@module ember
@submodule ember-runtime
*/
'use strict';
var STRING_DASHERIZE_REGEXP = /[ _]/g;
- var STRING_DASHERIZE_CACHE = new _emberMetal.Cache(1000, function (key) {
+ var STRING_DASHERIZE_CACHE = new _emberMetalCache.default(1000, function (key) {
return decamelize(key).replace(STRING_DASHERIZE_REGEXP, '-');
});
var STRING_CAMELIZE_REGEXP_1 = /(\-|\_|\.|\s)+(.)?/g;
var STRING_CAMELIZE_REGEXP_2 = /(^|\/)([A-Z])/g;
- var CAMELIZE_CACHE = new _emberMetal.Cache(1000, function (key) {
+ var CAMELIZE_CACHE = new _emberMetalCache.default(1000, function (key) {
return key.replace(STRING_CAMELIZE_REGEXP_1, function (match, separator, chr) {
return chr ? chr.toUpperCase() : '';
}).replace(STRING_CAMELIZE_REGEXP_2, function (match, separator, chr) {
return match.toLowerCase();
});
@@ -18666,11 +19446,11 @@
var STRING_CLASSIFY_REGEXP_1 = /^(\-|_)+(.)?/;
var STRING_CLASSIFY_REGEXP_2 = /(.)(\-|\_|\.|\s)+(.)?/g;
var STRING_CLASSIFY_REGEXP_3 = /(^|\/|\.)([a-z])/g;
- var CLASSIFY_CACHE = new _emberMetal.Cache(1000, function (str) {
+ var CLASSIFY_CACHE = new _emberMetalCache.default(1000, function (str) {
var replace1 = function (match, separator, chr) {
return chr ? '_' + chr.toUpperCase() : '';
};
var replace2 = function (match, initialChar, separator, chr) {
return initialChar + (chr ? chr.toUpperCase() : '');
@@ -18685,25 +19465,25 @@
});
var STRING_UNDERSCORE_REGEXP_1 = /([a-z\d])([A-Z]+)/g;
var STRING_UNDERSCORE_REGEXP_2 = /\-|\s+/g;
- var UNDERSCORE_CACHE = new _emberMetal.Cache(1000, function (str) {
+ var UNDERSCORE_CACHE = new _emberMetalCache.default(1000, function (str) {
return str.replace(STRING_UNDERSCORE_REGEXP_1, '$1_$2').replace(STRING_UNDERSCORE_REGEXP_2, '_').toLowerCase();
});
var STRING_CAPITALIZE_REGEXP = /(^|\/)([a-z])/g;
- var CAPITALIZE_CACHE = new _emberMetal.Cache(1000, function (str) {
+ var CAPITALIZE_CACHE = new _emberMetalCache.default(1000, function (str) {
return str.replace(STRING_CAPITALIZE_REGEXP, function (match, separator, chr) {
return match.toUpperCase();
});
});
var STRING_DECAMELIZE_REGEXP = /([a-z\d])([A-Z])/g;
- var DECAMELIZE_CACHE = new _emberMetal.Cache(1000, function (str) {
+ var DECAMELIZE_CACHE = new _emberMetalCache.default(1000, function (str) {
return str.replace(STRING_DECAMELIZE_REGEXP, '$1_$2').toLowerCase();
});
function _fmt(str, formats) {
var cachedFormats = formats;
@@ -18719,16 +19499,16 @@
// first, replace any ORDERED replacements.
var idx = 0; // the current index for non-numerical replacements
return str.replace(/%@([0-9]+)?/g, function (s, argIndex) {
argIndex = argIndex ? parseInt(argIndex, 10) - 1 : idx++;
s = cachedFormats[argIndex];
- return s === null ? '(null)' : s === undefined ? '' : _emberUtils.inspect(s);
+ return s === null ? '(null)' : s === undefined ? '' : _emberMetalUtils.inspect(s);
});
}
function fmt(str, formats) {
- _emberMetal.deprecate('Ember.String.fmt is deprecated, use ES6 template strings instead.', false, { id: 'ember-string-utils.fmt', until: '3.0.0', url: 'http://babeljs.io/docs/learn-es2015/#template-strings' });
+ _emberMetalDebug.deprecate('Ember.String.fmt is deprecated, use ES6 template strings instead.', false, { id: 'ember-string-utils.fmt', until: '3.0.0', url: 'http://babeljs.io/docs/learn-es2015/#template-strings' });
return _fmt.apply(undefined, arguments);
}
function loc(str, formats) {
if (!_emberRuntimeUtils.isArray(formats) || arguments.length > 2) {
@@ -19097,2516 +19877,2704 @@
}
});
enifed("ember/features", ["exports"], function (exports) {
"use strict";
- exports.default = { "features-stripped-test": false, "ember-routing-route-configured-query-params": false, "ember-libraries-isregistered": false, "ember-runtime-computed-uniq-by": true, "ember-improved-instrumentation": false, "ember-runtime-enumerable-includes": true, "ember-string-ishtmlsafe": true, "ember-testing-check-waiters": true, "ember-metal-weakmap": false, "ember-glimmer-allow-backtracking-rerender": false, "mandatory-setter": true, "ember-glimmer-detect-backtracking-rerender": true };
+ exports.default = {};
});
enifed("ember/version", ["exports"], function (exports) {
"use strict";
- exports.default = "2.9.0-beta.5";
+ exports.default = "2.9.0";
});
-/*!
- * @overview RSVP - a tiny implementation of Promises/A+.
- * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors
- * @license Licensed under MIT license
- * See https://raw.githubusercontent.com/tildeio/rsvp.js/master/LICENSE
- * @version 3.2.1
- */
+enifed('rsvp', ['exports', 'rsvp/promise', 'rsvp/events', 'rsvp/node', 'rsvp/all', 'rsvp/all-settled', 'rsvp/race', 'rsvp/hash', 'rsvp/hash-settled', 'rsvp/rethrow', 'rsvp/defer', 'rsvp/config', 'rsvp/map', 'rsvp/resolve', 'rsvp/reject', 'rsvp/filter', 'rsvp/asap'], function (exports, _rsvpPromise, _rsvpEvents, _rsvpNode, _rsvpAll, _rsvpAllSettled, _rsvpRace, _rsvpHash, _rsvpHashSettled, _rsvpRethrow, _rsvpDefer, _rsvpConfig, _rsvpMap, _rsvpResolve, _rsvpReject, _rsvpFilter, _rsvpAsap) {
+ 'use strict';
-enifed('rsvp', ['exports'], function (exports) { 'use strict';
+ // defaults
+ _rsvpConfig.config.async = _rsvpAsap.default;
+ _rsvpConfig.config.after = function (cb) {
+ setTimeout(cb, 0);
+ };
+ var cast = _rsvpResolve.default;
+ function async(callback, arg) {
+ _rsvpConfig.config.async(callback, arg);
+ }
-function indexOf(callbacks, callback) {
- for (var i=0, l=callbacks.length; i<l; i++) {
- if (callbacks[i] === callback) { return i; }
+ function on() {
+ _rsvpConfig.config['on'].apply(_rsvpConfig.config, arguments);
}
- return -1;
-}
+ function off() {
+ _rsvpConfig.config['off'].apply(_rsvpConfig.config, arguments);
+ }
-function callbacksFor(object) {
- var callbacks = object._promiseCallbacks;
-
- if (!callbacks) {
- callbacks = object._promiseCallbacks = {};
+ // Set up instrumentation through `window.__PROMISE_INTRUMENTATION__`
+ if (typeof window !== 'undefined' && typeof window['__PROMISE_INSTRUMENTATION__'] === 'object') {
+ var callbacks = window['__PROMISE_INSTRUMENTATION__'];
+ _rsvpConfig.configure('instrument', true);
+ for (var eventName in callbacks) {
+ if (callbacks.hasOwnProperty(eventName)) {
+ on(eventName, callbacks[eventName]);
+ }
+ }
}
- return callbacks;
-}
+ exports.cast = cast;
+ exports.Promise = _rsvpPromise.default;
+ exports.EventTarget = _rsvpEvents.default;
+ exports.all = _rsvpAll.default;
+ exports.allSettled = _rsvpAllSettled.default;
+ exports.race = _rsvpRace.default;
+ exports.hash = _rsvpHash.default;
+ exports.hashSettled = _rsvpHashSettled.default;
+ exports.rethrow = _rsvpRethrow.default;
+ exports.defer = _rsvpDefer.default;
+ exports.denodeify = _rsvpNode.default;
+ exports.configure = _rsvpConfig.configure;
+ exports.on = on;
+ exports.off = off;
+ exports.resolve = _rsvpResolve.default;
+ exports.reject = _rsvpReject.default;
+ exports.async = async;
+ exports.map = _rsvpMap.default;
+ exports.filter = _rsvpFilter.default;
+});
+enifed('rsvp.umd', ['exports', 'rsvp/platform', 'rsvp'], function (exports, _rsvpPlatform, _rsvp) {
+ 'use strict';
-/**
- @class RSVP.EventTarget
-*/
-var EventTarget = {
+ var RSVP = {
+ 'race': _rsvp.race,
+ 'Promise': _rsvp.Promise,
+ 'allSettled': _rsvp.allSettled,
+ 'hash': _rsvp.hash,
+ 'hashSettled': _rsvp.hashSettled,
+ 'denodeify': _rsvp.denodeify,
+ 'on': _rsvp.on,
+ 'off': _rsvp.off,
+ 'map': _rsvp.map,
+ 'filter': _rsvp.filter,
+ 'resolve': _rsvp.resolve,
+ 'reject': _rsvp.reject,
+ 'all': _rsvp.all,
+ 'rethrow': _rsvp.rethrow,
+ 'defer': _rsvp.defer,
+ 'EventTarget': _rsvp.EventTarget,
+ 'configure': _rsvp.configure,
+ 'async': _rsvp.async
+ };
- /**
- `RSVP.EventTarget.mixin` extends an object with EventTarget methods. For
- Example:
-
- ```javascript
- var object = {};
-
- RSVP.EventTarget.mixin(object);
-
- object.on('finished', function(event) {
- // handle event
+ /* global define:true module:true window: true */
+ if (typeof define === 'function' && define['amd']) {
+ define(function () {
+ return RSVP;
});
+ } else if (typeof module !== 'undefined' && module['exports']) {
+ module['exports'] = RSVP;
+ } else if (typeof _rsvpPlatform.default !== 'undefined') {
+ _rsvpPlatform.default['RSVP'] = RSVP;
+ }
+});
+enifed('rsvp/-internal', ['exports', 'rsvp/utils', 'rsvp/instrument', 'rsvp/config'], function (exports, _rsvpUtils, _rsvpInstrument, _rsvpConfig) {
+ 'use strict';
- object.trigger('finished', { detail: value });
- ```
+ function withOwnPromise() {
+ return new TypeError('A promises callback cannot return that same promise.');
+ }
- `EventTarget.mixin` also works with prototypes:
+ function noop() {}
- ```javascript
- var Person = function() {};
- RSVP.EventTarget.mixin(Person.prototype);
+ var PENDING = void 0;
+ var FULFILLED = 1;
+ var REJECTED = 2;
- var yehuda = new Person();
- var tom = new Person();
+ var GET_THEN_ERROR = new ErrorObject();
- yehuda.on('poke', function(event) {
- console.log('Yehuda says OW');
- });
+ function getThen(promise) {
+ try {
+ return promise.then;
+ } catch (error) {
+ GET_THEN_ERROR.error = error;
+ return GET_THEN_ERROR;
+ }
+ }
- tom.on('poke', function(event) {
- console.log('Tom says OW');
- });
+ function tryThen(then, value, fulfillmentHandler, rejectionHandler) {
+ try {
+ then.call(value, fulfillmentHandler, rejectionHandler);
+ } catch (e) {
+ return e;
+ }
+ }
- yehuda.trigger('poke');
- tom.trigger('poke');
- ```
+ function handleForeignThenable(promise, thenable, then) {
+ _rsvpConfig.config.async(function (promise) {
+ var sealed = false;
+ var error = tryThen(then, thenable, function (value) {
+ if (sealed) {
+ return;
+ }
+ sealed = true;
+ if (thenable !== value) {
+ resolve(promise, value);
+ } else {
+ fulfill(promise, value);
+ }
+ }, function (reason) {
+ if (sealed) {
+ return;
+ }
+ sealed = true;
- @method mixin
- @for RSVP.EventTarget
- @private
- @param {Object} object object to extend with EventTarget methods
- */
- 'mixin': function(object) {
- object['on'] = this['on'];
- object['off'] = this['off'];
- object['trigger'] = this['trigger'];
- object._promiseCallbacks = undefined;
- return object;
- },
+ reject(promise, reason);
+ }, 'Settle: ' + (promise._label || ' unknown promise'));
- /**
- Registers a callback to be executed when `eventName` is triggered
+ if (!sealed && error) {
+ sealed = true;
+ reject(promise, error);
+ }
+ }, promise);
+ }
- ```javascript
- object.on('event', function(eventInfo){
- // handle the event
- });
+ function handleOwnThenable(promise, thenable) {
+ if (thenable._state === FULFILLED) {
+ fulfill(promise, thenable._result);
+ } else if (thenable._state === REJECTED) {
+ thenable._onError = null;
+ reject(promise, thenable._result);
+ } else {
+ subscribe(thenable, undefined, function (value) {
+ if (thenable !== value) {
+ resolve(promise, value);
+ } else {
+ fulfill(promise, value);
+ }
+ }, function (reason) {
+ reject(promise, reason);
+ });
+ }
+ }
- object.trigger('event');
- ```
+ function handleMaybeThenable(promise, maybeThenable) {
+ if (maybeThenable.constructor === promise.constructor) {
+ handleOwnThenable(promise, maybeThenable);
+ } else {
+ var then = getThen(maybeThenable);
- @method on
- @for RSVP.EventTarget
- @private
- @param {String} eventName name of the event to listen for
- @param {Function} callback function to be called when the event is triggered.
- */
- 'on': function(eventName, callback) {
- if (typeof callback !== 'function') {
- throw new TypeError('Callback must be a function');
+ if (then === GET_THEN_ERROR) {
+ reject(promise, GET_THEN_ERROR.error);
+ } else if (then === undefined) {
+ fulfill(promise, maybeThenable);
+ } else if (_rsvpUtils.isFunction(then)) {
+ handleForeignThenable(promise, maybeThenable, then);
+ } else {
+ fulfill(promise, maybeThenable);
+ }
}
+ }
- var allCallbacks = callbacksFor(this), callbacks;
-
- callbacks = allCallbacks[eventName];
-
- if (!callbacks) {
- callbacks = allCallbacks[eventName] = [];
+ function resolve(promise, value) {
+ if (promise === value) {
+ fulfill(promise, value);
+ } else if (_rsvpUtils.objectOrFunction(value)) {
+ handleMaybeThenable(promise, value);
+ } else {
+ fulfill(promise, value);
}
+ }
- if (indexOf(callbacks, callback) === -1) {
- callbacks.push(callback);
+ function publishRejection(promise) {
+ if (promise._onError) {
+ promise._onError(promise._result);
}
- },
- /**
- You can use `off` to stop firing a particular callback for an event:
+ publish(promise);
+ }
- ```javascript
- function doStuff() { // do stuff! }
- object.on('stuff', doStuff);
-
- object.trigger('stuff'); // doStuff will be called
-
- // Unregister ONLY the doStuff callback
- object.off('stuff', doStuff);
- object.trigger('stuff'); // doStuff will NOT be called
- ```
-
- If you don't pass a `callback` argument to `off`, ALL callbacks for the
- event will not be executed when the event fires. For example:
-
- ```javascript
- var callback1 = function(){};
- var callback2 = function(){};
-
- object.on('stuff', callback1);
- object.on('stuff', callback2);
-
- object.trigger('stuff'); // callback1 and callback2 will be executed.
-
- object.off('stuff');
- object.trigger('stuff'); // callback1 and callback2 will not be executed!
- ```
-
- @method off
- @for RSVP.EventTarget
- @private
- @param {String} eventName event to stop listening to
- @param {Function} callback optional argument. If given, only the function
- given will be removed from the event's callback queue. If no `callback`
- argument is given, all callbacks will be removed from the event's callback
- queue.
- */
- 'off': function(eventName, callback) {
- var allCallbacks = callbacksFor(this), callbacks, index;
-
- if (!callback) {
- allCallbacks[eventName] = [];
+ function fulfill(promise, value) {
+ if (promise._state !== PENDING) {
return;
}
- callbacks = allCallbacks[eventName];
+ promise._result = value;
+ promise._state = FULFILLED;
- index = indexOf(callbacks, callback);
-
- if (index !== -1) { callbacks.splice(index, 1); }
- },
-
- /**
- Use `trigger` to fire custom events. For example:
-
- ```javascript
- object.on('foo', function(){
- console.log('foo event happened!');
- });
- object.trigger('foo');
- // 'foo event happened!' logged to the console
- ```
-
- You can also pass a value as a second argument to `trigger` that will be
- passed as an argument to all event listeners for the event:
-
- ```javascript
- object.on('foo', function(value){
- console.log(value.name);
- });
-
- object.trigger('foo', { name: 'bar' });
- // 'bar' logged to the console
- ```
-
- @method trigger
- @for RSVP.EventTarget
- @private
- @param {String} eventName name of the event to be triggered
- @param {*} options optional value to be passed to any event handlers for
- the given `eventName`
- */
- 'trigger': function(eventName, options, label) {
- var allCallbacks = callbacksFor(this), callbacks, callback;
-
- if (callbacks = allCallbacks[eventName]) {
- // Don't cache the callbacks.length since it may grow
- for (var i=0; i<callbacks.length; i++) {
- callback = callbacks[i];
-
- callback(options, label);
+ if (promise._subscribers.length === 0) {
+ if (_rsvpConfig.config.instrument) {
+ _rsvpInstrument.default('fulfilled', promise);
}
+ } else {
+ _rsvpConfig.config.async(publish, promise);
}
}
-};
-var config = {
- instrument: false
-};
-
-EventTarget['mixin'](config);
-
-function configure(name, value) {
- if (name === 'onerror') {
- // handle for legacy users that expect the actual
- // error to be passed to their function added via
- // `RSVP.configure('onerror', someFunctionHere);`
- config['on']('error', value);
- return;
+ function reject(promise, reason) {
+ if (promise._state !== PENDING) {
+ return;
+ }
+ promise._state = REJECTED;
+ promise._result = reason;
+ _rsvpConfig.config.async(publishRejection, promise);
}
- if (arguments.length === 2) {
- config[name] = value;
- } else {
- return config[name];
- }
-}
+ function subscribe(parent, child, onFulfillment, onRejection) {
+ var subscribers = parent._subscribers;
+ var length = subscribers.length;
-function objectOrFunction(x) {
- return typeof x === 'function' || (typeof x === 'object' && x !== null);
-}
+ parent._onError = null;
-function isFunction(x) {
- return typeof x === 'function';
-}
+ subscribers[length] = child;
+ subscribers[length + FULFILLED] = onFulfillment;
+ subscribers[length + REJECTED] = onRejection;
-function isMaybeThenable(x) {
- return typeof x === 'object' && x !== null;
-}
+ if (length === 0 && parent._state) {
+ _rsvpConfig.config.async(publish, parent);
+ }
+ }
-var _isArray;
-if (!Array.isArray) {
- _isArray = function (x) {
- return Object.prototype.toString.call(x) === '[object Array]';
- };
-} else {
- _isArray = Array.isArray;
-}
+ function publish(promise) {
+ var subscribers = promise._subscribers;
+ var settled = promise._state;
-var isArray = _isArray;
+ if (_rsvpConfig.config.instrument) {
+ _rsvpInstrument.default(settled === FULFILLED ? 'fulfilled' : 'rejected', promise);
+ }
-// Date.now is not available in browsers < IE9
-// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now#Compatibility
-var now = Date.now || function() { return new Date().getTime(); };
+ if (subscribers.length === 0) {
+ return;
+ }
-function F() { }
+ var child,
+ callback,
+ detail = promise._result;
-var o_create = (Object.create || function (o) {
- if (arguments.length > 1) {
- throw new Error('Second argument not supported');
- }
- if (typeof o !== 'object') {
- throw new TypeError('Argument must be an object');
- }
- F.prototype = o;
- return new F();
-});
+ for (var i = 0; i < subscribers.length; i += 3) {
+ child = subscribers[i];
+ callback = subscribers[i + settled];
-var queue = [];
-
-function scheduleFlush() {
- setTimeout(function() {
- var entry;
- for (var i = 0; i < queue.length; i++) {
- entry = queue[i];
-
- var payload = entry.payload;
-
- payload.guid = payload.key + payload.id;
- payload.childGuid = payload.key + payload.childId;
- if (payload.error) {
- payload.stack = payload.error.stack;
+ if (child) {
+ invokeCallback(settled, child, callback, detail);
+ } else {
+ callback(detail);
}
-
- config['trigger'](entry.name, entry.payload);
}
- queue.length = 0;
- }, 50);
-}
-function instrument(eventName, promise, child) {
- if (1 === queue.push({
- name: eventName,
- payload: {
- key: promise._guidKey,
- id: promise._id,
- eventName: eventName,
- detail: promise._result,
- childId: child && child._id,
- label: promise._label,
- timeStamp: now(),
- error: config["instrument-with-stack"] ? new Error(promise._label) : null
- }})) {
- scheduleFlush();
- }
+ promise._subscribers.length = 0;
}
-/**
- `RSVP.Promise.resolve` returns a promise that will become resolved with the
- passed `value`. It is shorthand for the following:
-
- ```javascript
- var promise = new RSVP.Promise(function(resolve, reject){
- resolve(1);
- });
-
- promise.then(function(value){
- // value === 1
- });
- ```
-
- Instead of writing the above, your code now simply becomes the following:
-
- ```javascript
- var promise = RSVP.Promise.resolve(1);
-
- promise.then(function(value){
- // value === 1
- });
- ```
-
- @method resolve
- @static
- @param {*} object value that the returned promise will be resolved with
- @param {String} label optional string for identifying the returned promise.
- Useful for tooling.
- @return {Promise} a promise that will become fulfilled with the given
- `value`
-*/
-function resolve$1(object, label) {
- /*jshint validthis:true */
- var Constructor = this;
-
- if (object && typeof object === 'object' && object.constructor === Constructor) {
- return object;
+ function ErrorObject() {
+ this.error = null;
}
- var promise = new Constructor(noop, label);
- resolve(promise, object);
- return promise;
-}
+ var TRY_CATCH_ERROR = new ErrorObject();
-function withOwnPromise() {
- return new TypeError('A promises callback cannot return that same promise.');
-}
-
-function noop() {}
-
-var PENDING = void 0;
-var FULFILLED = 1;
-var REJECTED = 2;
-
-var GET_THEN_ERROR = new ErrorObject();
-
-function getThen(promise) {
- try {
- return promise.then;
- } catch(error) {
- GET_THEN_ERROR.error = error;
- return GET_THEN_ERROR;
+ function tryCatch(callback, detail) {
+ try {
+ return callback(detail);
+ } catch (e) {
+ TRY_CATCH_ERROR.error = e;
+ return TRY_CATCH_ERROR;
+ }
}
-}
-function tryThen(then, value, fulfillmentHandler, rejectionHandler) {
- try {
- then.call(value, fulfillmentHandler, rejectionHandler);
- } catch(e) {
- return e;
- }
-}
+ function invokeCallback(settled, promise, callback, detail) {
+ var hasCallback = _rsvpUtils.isFunction(callback),
+ value,
+ error,
+ succeeded,
+ failed;
-function handleForeignThenable(promise, thenable, then) {
- config.async(function(promise) {
- var sealed = false;
- var error = tryThen(then, thenable, function(value) {
- if (sealed) { return; }
- sealed = true;
- if (thenable !== value) {
- resolve(promise, value, undefined);
+ if (hasCallback) {
+ value = tryCatch(callback, detail);
+
+ if (value === TRY_CATCH_ERROR) {
+ failed = true;
+ error = value.error;
+ value = null;
} else {
- fulfill(promise, value);
+ succeeded = true;
}
- }, function(reason) {
- if (sealed) { return; }
- sealed = true;
- reject(promise, reason);
- }, 'Settle: ' + (promise._label || ' unknown promise'));
-
- if (!sealed && error) {
- sealed = true;
- reject(promise, error);
+ if (promise === value) {
+ reject(promise, withOwnPromise());
+ return;
+ }
+ } else {
+ value = detail;
+ succeeded = true;
}
- }, promise);
-}
-function handleOwnThenable(promise, thenable) {
- if (thenable._state === FULFILLED) {
- fulfill(promise, thenable._result);
- } else if (thenable._state === REJECTED) {
- thenable._onError = null;
- reject(promise, thenable._result);
- } else {
- subscribe(thenable, undefined, function(value) {
- if (thenable !== value) {
- resolve(promise, value, undefined);
- } else {
+ if (promise._state !== PENDING) {
+ // noop
+ } else if (hasCallback && succeeded) {
+ resolve(promise, value);
+ } else if (failed) {
+ reject(promise, error);
+ } else if (settled === FULFILLED) {
fulfill(promise, value);
+ } else if (settled === REJECTED) {
+ reject(promise, value);
}
- }, function(reason) {
- reject(promise, reason);
- });
}
-}
-function handleMaybeThenable(promise, maybeThenable, then$$) {
- if (maybeThenable.constructor === promise.constructor &&
- then$$ === then &&
- constructor.resolve === resolve$1) {
- handleOwnThenable(promise, maybeThenable);
- } else {
- if (then$$ === GET_THEN_ERROR) {
- reject(promise, GET_THEN_ERROR.error);
- } else if (then$$ === undefined) {
- fulfill(promise, maybeThenable);
- } else if (isFunction(then$$)) {
- handleForeignThenable(promise, maybeThenable, then$$);
- } else {
- fulfill(promise, maybeThenable);
+ function initializePromise(promise, resolver) {
+ var resolved = false;
+ try {
+ resolver(function resolvePromise(value) {
+ if (resolved) {
+ return;
+ }
+ resolved = true;
+ resolve(promise, value);
+ }, function rejectPromise(reason) {
+ if (resolved) {
+ return;
+ }
+ resolved = true;
+ reject(promise, reason);
+ });
+ } catch (e) {
+ reject(promise, e);
}
}
-}
-function resolve(promise, value) {
- if (promise === value) {
- fulfill(promise, value);
- } else if (objectOrFunction(value)) {
- handleMaybeThenable(promise, value, getThen(value));
- } else {
- fulfill(promise, value);
- }
-}
+ exports.noop = noop;
+ exports.resolve = resolve;
+ exports.reject = reject;
+ exports.fulfill = fulfill;
+ exports.subscribe = subscribe;
+ exports.publish = publish;
+ exports.publishRejection = publishRejection;
+ exports.initializePromise = initializePromise;
+ exports.invokeCallback = invokeCallback;
+ exports.FULFILLED = FULFILLED;
+ exports.REJECTED = REJECTED;
+ exports.PENDING = PENDING;
+});
+enifed('rsvp/all-settled', ['exports', 'rsvp/enumerator', 'rsvp/promise', 'rsvp/utils'], function (exports, _rsvpEnumerator, _rsvpPromise, _rsvpUtils) {
+ 'use strict';
-function publishRejection(promise) {
- if (promise._onError) {
- promise._onError(promise._result);
+ exports.default = allSettled;
+
+ function AllSettled(Constructor, entries, label) {
+ this._superConstructor(Constructor, entries, false, /* don't abort on reject */label);
}
- publish(promise);
-}
+ AllSettled.prototype = _rsvpUtils.o_create(_rsvpEnumerator.default.prototype);
+ AllSettled.prototype._superConstructor = _rsvpEnumerator.default;
+ AllSettled.prototype._makeResult = _rsvpEnumerator.makeSettledResult;
+ AllSettled.prototype._validationError = function () {
+ return new Error('allSettled must be called with an array');
+ };
-function fulfill(promise, value) {
- if (promise._state !== PENDING) { return; }
+ /**
+ `RSVP.allSettled` is similar to `RSVP.all`, but instead of implementing
+ a fail-fast method, it waits until all the promises have returned and
+ shows you all the results. This is useful if you want to handle multiple
+ promises' failure states together as a set.
+
+ Returns a promise that is fulfilled when all the given promises have been
+ settled. The return promise is fulfilled with an array of the states of
+ the promises passed into the `promises` array argument.
+
+ Each state object will either indicate fulfillment or rejection, and
+ provide the corresponding value or reason. The states will take one of
+ the following formats:
+
+ ```javascript
+ { state: 'fulfilled', value: value }
+ or
+ { state: 'rejected', reason: reason }
+ ```
+
+ Example:
+
+ ```javascript
+ var promise1 = RSVP.Promise.resolve(1);
+ var promise2 = RSVP.Promise.reject(new Error('2'));
+ var promise3 = RSVP.Promise.reject(new Error('3'));
+ var promises = [ promise1, promise2, promise3 ];
+
+ RSVP.allSettled(promises).then(function(array){
+ // array == [
+ // { state: 'fulfilled', value: 1 },
+ // { state: 'rejected', reason: Error },
+ // { state: 'rejected', reason: Error }
+ // ]
+ // Note that for the second item, reason.message will be '2', and for the
+ // third item, reason.message will be '3'.
+ }, function(error) {
+ // Not run. (This block would only be called if allSettled had failed,
+ // for instance if passed an incorrect argument type.)
+ });
+ ```
+
+ @method allSettled
+ @static
+ @for RSVP
+ @param {Array} entries
+ @param {String} label - optional string that describes the promise.
+ Useful for tooling.
+ @return {Promise} promise that is fulfilled with an array of the settled
+ states of the constituent promises.
+ */
- promise._result = value;
- promise._state = FULFILLED;
-
- if (promise._subscribers.length === 0) {
- if (config.instrument) {
- instrument('fulfilled', promise);
- }
- } else {
- config.async(publish, promise);
+ function allSettled(entries, label) {
+ return new AllSettled(_rsvpPromise.default, entries, label).promise;
}
-}
+});
+enifed("rsvp/all", ["exports", "rsvp/promise"], function (exports, _rsvpPromise) {
+ "use strict";
-function reject(promise, reason) {
- if (promise._state !== PENDING) { return; }
- promise._state = REJECTED;
- promise._result = reason;
- config.async(publishRejection, promise);
-}
+ exports.default = all;
-function subscribe(parent, child, onFulfillment, onRejection) {
- var subscribers = parent._subscribers;
- var length = subscribers.length;
+ /**
+ This is a convenient alias for `RSVP.Promise.all`.
+
+ @method all
+ @static
+ @for RSVP
+ @param {Array} array Array of promises.
+ @param {String} label An optional label. This is useful
+ for tooling.
+ */
- parent._onError = null;
-
- subscribers[length] = child;
- subscribers[length + FULFILLED] = onFulfillment;
- subscribers[length + REJECTED] = onRejection;
-
- if (length === 0 && parent._state) {
- config.async(publish, parent);
+ function all(array, label) {
+ return _rsvpPromise.default.all(array, label);
}
-}
+});
+enifed('rsvp/asap', ['exports'], function (exports) {
+ 'use strict';
-function publish(promise) {
- var subscribers = promise._subscribers;
- var settled = promise._state;
+ exports.default = asap;
+ var len = 0;
+ var toString = ({}).toString;
+ var vertxNext;
- if (config.instrument) {
- instrument(settled === FULFILLED ? 'fulfilled' : 'rejected', promise);
+ function asap(callback, arg) {
+ queue[len] = callback;
+ queue[len + 1] = arg;
+ len += 2;
+ if (len === 2) {
+ // If len is 1, that means that we need to schedule an async flush.
+ // If additional callbacks are queued before the queue is flushed, they
+ // will be processed by this flush that we are scheduling.
+ scheduleFlush();
+ }
}
- if (subscribers.length === 0) { return; }
+ var browserWindow = typeof window !== 'undefined' ? window : undefined;
+ var browserGlobal = browserWindow || {};
+ var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver;
+ var isNode = typeof window === 'undefined' && typeof process !== 'undefined' && ({}).toString.call(process) === '[object process]';
- var child, callback, detail = promise._result;
+ // test for web worker but not in IE10
+ var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined';
- for (var i = 0; i < subscribers.length; i += 3) {
- child = subscribers[i];
- callback = subscribers[i + settled];
-
- if (child) {
- invokeCallback(settled, child, callback, detail);
- } else {
- callback(detail);
+ // node
+ function useNextTick() {
+ var nextTick = process.nextTick;
+ // node version 0.10.x displays a deprecation warning when nextTick is used recursively
+ // setImmediate should be used instead instead
+ var version = process.versions.node.match(/^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/);
+ if (Array.isArray(version) && version[1] === '0' && version[2] === '10') {
+ nextTick = setImmediate;
}
+ return function () {
+ nextTick(flush);
+ };
}
- promise._subscribers.length = 0;
-}
-
-function ErrorObject() {
- this.error = null;
-}
-
-var TRY_CATCH_ERROR = new ErrorObject();
-
-function tryCatch(callback, detail) {
- try {
- return callback(detail);
- } catch(e) {
- TRY_CATCH_ERROR.error = e;
- return TRY_CATCH_ERROR;
+ // vertx
+ function useVertxTimer() {
+ return function () {
+ vertxNext(flush);
+ };
}
-}
-function invokeCallback(settled, promise, callback, detail) {
- var hasCallback = isFunction(callback),
- value, error, succeeded, failed;
+ function useMutationObserver() {
+ var iterations = 0;
+ var observer = new BrowserMutationObserver(flush);
+ var node = document.createTextNode('');
+ observer.observe(node, { characterData: true });
- if (hasCallback) {
- value = tryCatch(callback, detail);
-
- if (value === TRY_CATCH_ERROR) {
- failed = true;
- error = value.error;
- value = null;
- } else {
- succeeded = true;
- }
-
- if (promise === value) {
- reject(promise, withOwnPromise());
- return;
- }
-
- } else {
- value = detail;
- succeeded = true;
+ return function () {
+ node.data = iterations = ++iterations % 2;
+ };
}
- if (promise._state !== PENDING) {
- // noop
- } else if (hasCallback && succeeded) {
- resolve(promise, value);
- } else if (failed) {
- reject(promise, error);
- } else if (settled === FULFILLED) {
- fulfill(promise, value);
- } else if (settled === REJECTED) {
- reject(promise, value);
+ // web worker
+ function useMessageChannel() {
+ var channel = new MessageChannel();
+ channel.port1.onmessage = flush;
+ return function () {
+ channel.port2.postMessage(0);
+ };
}
-}
-function initializePromise(promise, resolver) {
- var resolved = false;
- try {
- resolver(function resolvePromise(value){
- if (resolved) { return; }
- resolved = true;
- resolve(promise, value);
- }, function rejectPromise(reason) {
- if (resolved) { return; }
- resolved = true;
- reject(promise, reason);
- });
- } catch(e) {
- reject(promise, e);
+ function useSetTimeout() {
+ return function () {
+ setTimeout(flush, 1);
+ };
}
-}
-function then(onFulfillment, onRejection, label) {
- var parent = this;
- var state = parent._state;
+ var queue = new Array(1000);
+ function flush() {
+ for (var i = 0; i < len; i += 2) {
+ var callback = queue[i];
+ var arg = queue[i + 1];
- if (state === FULFILLED && !onFulfillment || state === REJECTED && !onRejection) {
- config.instrument && instrument('chained', parent, parent);
- return parent;
- }
+ callback(arg);
- parent._onError = null;
+ queue[i] = undefined;
+ queue[i + 1] = undefined;
+ }
- var child = new parent.constructor(noop, label);
- var result = parent._result;
+ len = 0;
+ }
- config.instrument && instrument('chained', parent, child);
-
- if (state) {
- var callback = arguments[state - 1];
- config.async(function(){
- invokeCallback(state, child, callback, result);
- });
- } else {
- subscribe(parent, child, onFulfillment, onRejection);
+ function attemptVertex() {
+ try {
+ var r = require;
+ var vertx = r('vertx');
+ vertxNext = vertx.runOnLoop || vertx.runOnContext;
+ return useVertxTimer();
+ } catch (e) {
+ return useSetTimeout();
+ }
}
- return child;
-}
-
-function makeSettledResult(state, position, value) {
- if (state === FULFILLED) {
- return {
- state: 'fulfilled',
- value: value
- };
+ var scheduleFlush;
+ // Decide what async method to use to triggering processing of queued callbacks:
+ if (isNode) {
+ scheduleFlush = useNextTick();
+ } else if (BrowserMutationObserver) {
+ scheduleFlush = useMutationObserver();
+ } else if (isWorker) {
+ scheduleFlush = useMessageChannel();
+ } else if (browserWindow === undefined && typeof require === 'function') {
+ scheduleFlush = attemptVertex();
} else {
- return {
- state: 'rejected',
- reason: value
- };
+ scheduleFlush = useSetTimeout();
}
-}
+});
+enifed('rsvp/config', ['exports', 'rsvp/events'], function (exports, _rsvpEvents) {
+ 'use strict';
-function Enumerator(Constructor, input, abortOnReject, label) {
- this._instanceConstructor = Constructor;
- this.promise = new Constructor(noop, label);
- this._abortOnReject = abortOnReject;
+ var config = {
+ instrument: false
+ };
- if (this._validateInput(input)) {
- this._input = input;
- this.length = input.length;
- this._remaining = input.length;
+ _rsvpEvents.default['mixin'](config);
- this._init();
+ function configure(name, value) {
+ if (name === 'onerror') {
+ // handle for legacy users that expect the actual
+ // error to be passed to their function added via
+ // `RSVP.configure('onerror', someFunctionHere);`
+ config['on']('error', value);
+ return;
+ }
- if (this.length === 0) {
- fulfill(this.promise, this._result);
+ if (arguments.length === 2) {
+ config[name] = value;
} else {
- this.length = this.length || 0;
- this._enumerate();
- if (this._remaining === 0) {
- fulfill(this.promise, this._result);
- }
+ return config[name];
}
- } else {
- reject(this.promise, this._validationError());
}
-}
-Enumerator.prototype._validateInput = function(input) {
- return isArray(input);
-};
+ exports.config = config;
+ exports.configure = configure;
+});
+enifed('rsvp/defer', ['exports', 'rsvp/promise'], function (exports, _rsvpPromise) {
+ 'use strict';
-Enumerator.prototype._validationError = function() {
- return new Error('Array Methods must be provided an Array');
-};
+ exports.default = defer;
-Enumerator.prototype._init = function() {
- this._result = new Array(this.length);
-};
+ /**
+ `RSVP.defer` returns an object similar to jQuery's `$.Deferred`.
+ `RSVP.defer` should be used when porting over code reliant on `$.Deferred`'s
+ interface. New code should use the `RSVP.Promise` constructor instead.
+
+ The object returned from `RSVP.defer` is a plain object with three properties:
+
+ * promise - an `RSVP.Promise`.
+ * reject - a function that causes the `promise` property on this object to
+ become rejected
+ * resolve - a function that causes the `promise` property on this object to
+ become fulfilled.
+
+ Example:
+
+ ```javascript
+ var deferred = RSVP.defer();
+
+ deferred.resolve("Success!");
+
+ deferred.promise.then(function(value){
+ // value here is "Success!"
+ });
+ ```
+
+ @method defer
+ @static
+ @for RSVP
+ @param {String} label optional string for labeling the promise.
+ Useful for tooling.
+ @return {Object}
+ */
-Enumerator.prototype._enumerate = function() {
- var length = this.length;
- var promise = this.promise;
- var input = this._input;
+ function defer(label) {
+ var deferred = {};
- for (var i = 0; promise._state === PENDING && i < length; i++) {
- this._eachEntry(input[i], i);
+ deferred['promise'] = new _rsvpPromise.default(function (resolve, reject) {
+ deferred['resolve'] = resolve;
+ deferred['reject'] = reject;
+ }, label);
+
+ return deferred;
}
-};
+});
+enifed('rsvp/enumerator', ['exports', 'rsvp/utils', 'rsvp/-internal'], function (exports, _rsvpUtils, _rsvpInternal) {
+ 'use strict';
-Enumerator.prototype._settleMaybeThenable = function(entry, i) {
- var c = this._instanceConstructor;
- var resolve = c.resolve;
+ exports.makeSettledResult = makeSettledResult;
- if (resolve === resolve$1) {
- var then$$ = getThen(entry);
-
- if (then$$ === then &&
- entry._state !== PENDING) {
- entry._onError = null;
- this._settledAt(entry._state, i, entry._result);
- } else if (typeof then$$ !== 'function') {
- this._remaining--;
- this._result[i] = this._makeResult(FULFILLED, i, entry);
- } else if (c === Promise) {
- var promise = new c(noop);
- handleMaybeThenable(promise, entry, then$$);
- this._willSettleAt(promise, i);
+ function makeSettledResult(state, position, value) {
+ if (state === _rsvpInternal.FULFILLED) {
+ return {
+ state: 'fulfilled',
+ value: value
+ };
} else {
- this._willSettleAt(new c(function(resolve) { resolve(entry); }), i);
+ return {
+ state: 'rejected',
+ reason: value
+ };
}
- } else {
- this._willSettleAt(resolve(entry), i);
}
-};
-Enumerator.prototype._eachEntry = function(entry, i) {
- if (isMaybeThenable(entry)) {
- this._settleMaybeThenable(entry, i);
- } else {
- this._remaining--;
- this._result[i] = this._makeResult(FULFILLED, i, entry);
- }
-};
+ function Enumerator(Constructor, input, abortOnReject, label) {
+ var enumerator = this;
-Enumerator.prototype._settledAt = function(state, i, value) {
- var promise = this.promise;
+ enumerator._instanceConstructor = Constructor;
+ enumerator.promise = new Constructor(_rsvpInternal.noop, label);
+ enumerator._abortOnReject = abortOnReject;
- if (promise._state === PENDING) {
- this._remaining--;
+ if (enumerator._validateInput(input)) {
+ enumerator._input = input;
+ enumerator.length = input.length;
+ enumerator._remaining = input.length;
- if (this._abortOnReject && state === REJECTED) {
- reject(promise, value);
+ enumerator._init();
+
+ if (enumerator.length === 0) {
+ _rsvpInternal.fulfill(enumerator.promise, enumerator._result);
+ } else {
+ enumerator.length = enumerator.length || 0;
+ enumerator._enumerate();
+ if (enumerator._remaining === 0) {
+ _rsvpInternal.fulfill(enumerator.promise, enumerator._result);
+ }
+ }
} else {
- this._result[i] = this._makeResult(state, i, value);
+ _rsvpInternal.reject(enumerator.promise, enumerator._validationError());
}
}
- if (this._remaining === 0) {
- fulfill(promise, this._result);
- }
-};
+ exports.default = Enumerator;
-Enumerator.prototype._makeResult = function(state, i, value) {
- return value;
-};
+ Enumerator.prototype._validateInput = function (input) {
+ return _rsvpUtils.isArray(input);
+ };
-Enumerator.prototype._willSettleAt = function(promise, i) {
- var enumerator = this;
+ Enumerator.prototype._validationError = function () {
+ return new Error('Array Methods must be provided an Array');
+ };
- subscribe(promise, undefined, function(value) {
- enumerator._settledAt(FULFILLED, i, value);
- }, function(reason) {
- enumerator._settledAt(REJECTED, i, reason);
- });
-};
+ Enumerator.prototype._init = function () {
+ this._result = new Array(this.length);
+ };
-/**
- `RSVP.Promise.all` accepts an array of promises, and returns a new promise which
- is fulfilled with an array of fulfillment values for the passed promises, or
- rejected with the reason of the first passed promise to be rejected. It casts all
- elements of the passed iterable to promises as it runs this algorithm.
+ Enumerator.prototype._enumerate = function () {
+ var enumerator = this;
+ var length = enumerator.length;
+ var promise = enumerator.promise;
+ var input = enumerator._input;
- Example:
+ for (var i = 0; promise._state === _rsvpInternal.PENDING && i < length; i++) {
+ enumerator._eachEntry(input[i], i);
+ }
+ };
- ```javascript
- var promise1 = RSVP.resolve(1);
- var promise2 = RSVP.resolve(2);
- var promise3 = RSVP.resolve(3);
- var promises = [ promise1, promise2, promise3 ];
+ Enumerator.prototype._eachEntry = function (entry, i) {
+ var enumerator = this;
+ var c = enumerator._instanceConstructor;
+ if (_rsvpUtils.isMaybeThenable(entry)) {
+ if (entry.constructor === c && entry._state !== _rsvpInternal.PENDING) {
+ entry._onError = null;
+ enumerator._settledAt(entry._state, i, entry._result);
+ } else {
+ enumerator._willSettleAt(c.resolve(entry), i);
+ }
+ } else {
+ enumerator._remaining--;
+ enumerator._result[i] = enumerator._makeResult(_rsvpInternal.FULFILLED, i, entry);
+ }
+ };
- RSVP.Promise.all(promises).then(function(array){
- // The array here would be [ 1, 2, 3 ];
- });
- ```
+ Enumerator.prototype._settledAt = function (state, i, value) {
+ var enumerator = this;
+ var promise = enumerator.promise;
- If any of the `promises` given to `RSVP.all` are rejected, the first promise
- that is rejected will be given as an argument to the returned promises's
- rejection handler. For example:
+ if (promise._state === _rsvpInternal.PENDING) {
+ enumerator._remaining--;
- Example:
+ if (enumerator._abortOnReject && state === _rsvpInternal.REJECTED) {
+ _rsvpInternal.reject(promise, value);
+ } else {
+ enumerator._result[i] = enumerator._makeResult(state, i, value);
+ }
+ }
- ```javascript
- var promise1 = RSVP.resolve(1);
- var promise2 = RSVP.reject(new Error("2"));
- var promise3 = RSVP.reject(new Error("3"));
- var promises = [ promise1, promise2, promise3 ];
+ if (enumerator._remaining === 0) {
+ _rsvpInternal.fulfill(promise, enumerator._result);
+ }
+ };
- RSVP.Promise.all(promises).then(function(array){
- // Code here never runs because there are rejected promises!
- }, function(error) {
- // error.message === "2"
- });
- ```
+ Enumerator.prototype._makeResult = function (state, i, value) {
+ return value;
+ };
- @method all
- @static
- @param {Array} entries array of promises
- @param {String} label optional string for labeling the promise.
- Useful for tooling.
- @return {Promise} promise that is fulfilled when all `promises` have been
- fulfilled, or rejected if any of them become rejected.
- @static
-*/
-function all(entries, label) {
- return new Enumerator(this, entries, true /* abort on reject */, label).promise;
-}
+ Enumerator.prototype._willSettleAt = function (promise, i) {
+ var enumerator = this;
-/**
- `RSVP.Promise.race` returns a new promise which is settled in the same way as the
- first passed promise to settle.
+ _rsvpInternal.subscribe(promise, undefined, function (value) {
+ enumerator._settledAt(_rsvpInternal.FULFILLED, i, value);
+ }, function (reason) {
+ enumerator._settledAt(_rsvpInternal.REJECTED, i, reason);
+ });
+ };
+});
+enifed('rsvp/events', ['exports'], function (exports) {
+ 'use strict';
- Example:
+ function indexOf(callbacks, callback) {
+ for (var i = 0, l = callbacks.length; i < l; i++) {
+ if (callbacks[i] === callback) {
+ return i;
+ }
+ }
- ```javascript
- var promise1 = new RSVP.Promise(function(resolve, reject){
- setTimeout(function(){
- resolve('promise 1');
- }, 200);
- });
-
- var promise2 = new RSVP.Promise(function(resolve, reject){
- setTimeout(function(){
- resolve('promise 2');
- }, 100);
- });
-
- RSVP.Promise.race([promise1, promise2]).then(function(result){
- // result === 'promise 2' because it was resolved before promise1
- // was resolved.
- });
- ```
-
- `RSVP.Promise.race` is deterministic in that only the state of the first
- settled promise matters. For example, even if other promises given to the
- `promises` array argument are resolved, but the first settled promise has
- become rejected before the other promises became fulfilled, the returned
- promise will become rejected:
-
- ```javascript
- var promise1 = new RSVP.Promise(function(resolve, reject){
- setTimeout(function(){
- resolve('promise 1');
- }, 200);
- });
-
- var promise2 = new RSVP.Promise(function(resolve, reject){
- setTimeout(function(){
- reject(new Error('promise 2'));
- }, 100);
- });
-
- RSVP.Promise.race([promise1, promise2]).then(function(result){
- // Code here never runs
- }, function(reason){
- // reason.message === 'promise 2' because promise 2 became rejected before
- // promise 1 became fulfilled
- });
- ```
-
- An example real-world use case is implementing timeouts:
-
- ```javascript
- RSVP.Promise.race([ajax('foo.json'), timeout(5000)])
- ```
-
- @method race
- @static
- @param {Array} entries array of promises to observe
- @param {String} label optional string for describing the promise returned.
- Useful for tooling.
- @return {Promise} a promise which settles in the same way as the first passed
- promise to settle.
-*/
-function race(entries, label) {
- /*jshint validthis:true */
- var Constructor = this;
-
- var promise = new Constructor(noop, label);
-
- if (!isArray(entries)) {
- reject(promise, new TypeError('You must pass an array to race.'));
- return promise;
+ return -1;
}
- var length = entries.length;
+ function callbacksFor(object) {
+ var callbacks = object._promiseCallbacks;
- function onFulfillment(value) {
- resolve(promise, value);
- }
+ if (!callbacks) {
+ callbacks = object._promiseCallbacks = {};
+ }
- function onRejection(reason) {
- reject(promise, reason);
+ return callbacks;
}
- for (var i = 0; promise._state === PENDING && i < length; i++) {
- subscribe(Constructor.resolve(entries[i]), undefined, onFulfillment, onRejection);
- }
+ /**
+ @class RSVP.EventTarget
+ */
+ exports.default = {
- return promise;
-}
+ /**
+ `RSVP.EventTarget.mixin` extends an object with EventTarget methods. For
+ Example:
+ ```javascript
+ var object = {};
+ RSVP.EventTarget.mixin(object);
+ object.on('finished', function(event) {
+ // handle event
+ });
+ object.trigger('finished', { detail: value });
+ ```
+ `EventTarget.mixin` also works with prototypes:
+ ```javascript
+ var Person = function() {};
+ RSVP.EventTarget.mixin(Person.prototype);
+ var yehuda = new Person();
+ var tom = new Person();
+ yehuda.on('poke', function(event) {
+ console.log('Yehuda says OW');
+ });
+ tom.on('poke', function(event) {
+ console.log('Tom says OW');
+ });
+ yehuda.trigger('poke');
+ tom.trigger('poke');
+ ```
+ @method mixin
+ @for RSVP.EventTarget
+ @private
+ @param {Object} object object to extend with EventTarget methods
+ */
+ 'mixin': function (object) {
+ object['on'] = this['on'];
+ object['off'] = this['off'];
+ object['trigger'] = this['trigger'];
+ object._promiseCallbacks = undefined;
+ return object;
+ },
-/**
- `RSVP.Promise.reject` returns a promise rejected with the passed `reason`.
- It is shorthand for the following:
+ /**
+ Registers a callback to be executed when `eventName` is triggered
+ ```javascript
+ object.on('event', function(eventInfo){
+ // handle the event
+ });
+ object.trigger('event');
+ ```
+ @method on
+ @for RSVP.EventTarget
+ @private
+ @param {String} eventName name of the event to listen for
+ @param {Function} callback function to be called when the event is triggered.
+ */
+ 'on': function (eventName, callback) {
+ if (typeof callback !== 'function') {
+ throw new TypeError('Callback must be a function');
+ }
- ```javascript
- var promise = new RSVP.Promise(function(resolve, reject){
- reject(new Error('WHOOPS'));
- });
+ var allCallbacks = callbacksFor(this),
+ callbacks;
- promise.then(function(value){
- // Code here doesn't run because the promise is rejected!
- }, function(reason){
- // reason.message === 'WHOOPS'
- });
- ```
+ callbacks = allCallbacks[eventName];
- Instead of writing the above, your code now simply becomes the following:
+ if (!callbacks) {
+ callbacks = allCallbacks[eventName] = [];
+ }
- ```javascript
- var promise = RSVP.Promise.reject(new Error('WHOOPS'));
+ if (indexOf(callbacks, callback) === -1) {
+ callbacks.push(callback);
+ }
+ },
- promise.then(function(value){
- // Code here doesn't run because the promise is rejected!
- }, function(reason){
- // reason.message === 'WHOOPS'
- });
- ```
+ /**
+ You can use `off` to stop firing a particular callback for an event:
+ ```javascript
+ function doStuff() { // do stuff! }
+ object.on('stuff', doStuff);
+ object.trigger('stuff'); // doStuff will be called
+ // Unregister ONLY the doStuff callback
+ object.off('stuff', doStuff);
+ object.trigger('stuff'); // doStuff will NOT be called
+ ```
+ If you don't pass a `callback` argument to `off`, ALL callbacks for the
+ event will not be executed when the event fires. For example:
+ ```javascript
+ var callback1 = function(){};
+ var callback2 = function(){};
+ object.on('stuff', callback1);
+ object.on('stuff', callback2);
+ object.trigger('stuff'); // callback1 and callback2 will be executed.
+ object.off('stuff');
+ object.trigger('stuff'); // callback1 and callback2 will not be executed!
+ ```
+ @method off
+ @for RSVP.EventTarget
+ @private
+ @param {String} eventName event to stop listening to
+ @param {Function} callback optional argument. If given, only the function
+ given will be removed from the event's callback queue. If no `callback`
+ argument is given, all callbacks will be removed from the event's callback
+ queue.
+ */
+ 'off': function (eventName, callback) {
+ var allCallbacks = callbacksFor(this),
+ callbacks,
+ index;
- @method reject
- @static
- @param {*} reason value that the returned promise will be rejected with.
- @param {String} label optional string for identifying the returned promise.
- Useful for tooling.
- @return {Promise} a promise rejected with the given `reason`.
-*/
-function reject$1(reason, label) {
- /*jshint validthis:true */
- var Constructor = this;
- var promise = new Constructor(noop, label);
- reject(promise, reason);
- return promise;
-}
+ if (!callback) {
+ allCallbacks[eventName] = [];
+ return;
+ }
-var guidKey = 'rsvp_' + now() + '-';
-var counter = 0;
+ callbacks = allCallbacks[eventName];
-function needsResolver() {
- throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
-}
+ index = indexOf(callbacks, callback);
-function needsNew() {
- throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
-}
+ if (index !== -1) {
+ callbacks.splice(index, 1);
+ }
+ },
-/**
- Promise objects represent the eventual result of an asynchronous operation. The
- primary way of interacting with a promise is through its `then` method, which
- registers callbacks to receive either a promise’s eventual value or the reason
- why the promise cannot be fulfilled.
+ /**
+ Use `trigger` to fire custom events. For example:
+ ```javascript
+ object.on('foo', function(){
+ console.log('foo event happened!');
+ });
+ object.trigger('foo');
+ // 'foo event happened!' logged to the console
+ ```
+ You can also pass a value as a second argument to `trigger` that will be
+ passed as an argument to all event listeners for the event:
+ ```javascript
+ object.on('foo', function(value){
+ console.log(value.name);
+ });
+ object.trigger('foo', { name: 'bar' });
+ // 'bar' logged to the console
+ ```
+ @method trigger
+ @for RSVP.EventTarget
+ @private
+ @param {String} eventName name of the event to be triggered
+ @param {*} options optional value to be passed to any event handlers for
+ the given `eventName`
+ */
+ 'trigger': function (eventName, options) {
+ var allCallbacks = callbacksFor(this),
+ callbacks,
+ callback;
- Terminology
- -----------
+ if (callbacks = allCallbacks[eventName]) {
+ // Don't cache the callbacks.length since it may grow
+ for (var i = 0; i < callbacks.length; i++) {
+ callback = callbacks[i];
- - `promise` is an object or function with a `then` method whose behavior conforms to this specification.
- - `thenable` is an object or function that defines a `then` method.
- - `value` is any legal JavaScript value (including undefined, a thenable, or a promise).
- - `exception` is a value that is thrown using the throw statement.
- - `reason` is a value that indicates why a promise was rejected.
- - `settled` the final resting state of a promise, fulfilled or rejected.
+ callback(options);
+ }
+ }
+ }
+ };
+});
+enifed('rsvp/filter', ['exports', 'rsvp/promise', 'rsvp/utils'], function (exports, _rsvpPromise, _rsvpUtils) {
+ 'use strict';
- A promise can be in one of three states: pending, fulfilled, or rejected.
+ exports.default = filter;
- Promises that are fulfilled have a fulfillment value and are in the fulfilled
- state. Promises that are rejected have a rejection reason and are in the
- rejected state. A fulfillment value is never a thenable.
+ /**
+ `RSVP.filter` is similar to JavaScript's native `filter` method, except that it
+ waits for all promises to become fulfilled before running the `filterFn` on
+ each item in given to `promises`. `RSVP.filter` returns a promise that will
+ become fulfilled with the result of running `filterFn` on the values the
+ promises become fulfilled with.
+
+ For example:
+
+ ```javascript
+
+ var promise1 = RSVP.resolve(1);
+ var promise2 = RSVP.resolve(2);
+ var promise3 = RSVP.resolve(3);
+
+ var promises = [promise1, promise2, promise3];
+
+ var filterFn = function(item){
+ return item > 1;
+ };
+
+ RSVP.filter(promises, filterFn).then(function(result){
+ // result is [ 2, 3 ]
+ });
+ ```
+
+ If any of the `promises` given to `RSVP.filter` are rejected, the first promise
+ that is rejected will be given as an argument to the returned promise's
+ rejection handler. For example:
+
+ ```javascript
+ var promise1 = RSVP.resolve(1);
+ var promise2 = RSVP.reject(new Error('2'));
+ var promise3 = RSVP.reject(new Error('3'));
+ var promises = [ promise1, promise2, promise3 ];
+
+ var filterFn = function(item){
+ return item > 1;
+ };
+
+ RSVP.filter(promises, filterFn).then(function(array){
+ // Code here never runs because there are rejected promises!
+ }, function(reason) {
+ // reason.message === '2'
+ });
+ ```
+
+ `RSVP.filter` will also wait for any promises returned from `filterFn`.
+ For instance, you may want to fetch a list of users then return a subset
+ of those users based on some asynchronous operation:
+
+ ```javascript
+
+ var alice = { name: 'alice' };
+ var bob = { name: 'bob' };
+ var users = [ alice, bob ];
+
+ var promises = users.map(function(user){
+ return RSVP.resolve(user);
+ });
+
+ var filterFn = function(user){
+ // Here, Alice has permissions to create a blog post, but Bob does not.
+ return getPrivilegesForUser(user).then(function(privs){
+ return privs.can_create_blog_post === true;
+ });
+ };
+ RSVP.filter(promises, filterFn).then(function(users){
+ // true, because the server told us only Alice can create a blog post.
+ users.length === 1;
+ // false, because Alice is the only user present in `users`
+ users[0] === bob;
+ });
+ ```
+
+ @method filter
+ @static
+ @for RSVP
+ @param {Array} promises
+ @param {Function} filterFn - function to be called on each resolved value to
+ filter the final results.
+ @param {String} label optional string describing the promise. Useful for
+ tooling.
+ @return {Promise}
+ */
- Promises can also be said to *resolve* a value. If this value is also a
- promise, then the original promise's settled state will match the value's
- settled state. So a promise that *resolves* a promise that rejects will
- itself reject, and a promise that *resolves* a promise that fulfills will
- itself fulfill.
+ function filter(promises, filterFn, label) {
+ return _rsvpPromise.default.all(promises, label).then(function (values) {
+ if (!_rsvpUtils.isFunction(filterFn)) {
+ throw new TypeError("You must pass a function as filter's second argument.");
+ }
+ var length = values.length;
+ var filtered = new Array(length);
- Basic Usage:
- ------------
+ for (var i = 0; i < length; i++) {
+ filtered[i] = filterFn(values[i]);
+ }
- ```js
- var promise = new Promise(function(resolve, reject) {
- // on success
- resolve(value);
+ return _rsvpPromise.default.all(filtered, label).then(function (filtered) {
+ var results = new Array(length);
+ var newLength = 0;
- // on failure
- reject(reason);
- });
-
- promise.then(function(value) {
- // on fulfillment
- }, function(reason) {
- // on rejection
- });
- ```
-
- Advanced Usage:
- ---------------
-
- Promises shine when abstracting away asynchronous interactions such as
- `XMLHttpRequest`s.
-
- ```js
- function getJSON(url) {
- return new Promise(function(resolve, reject){
- var xhr = new XMLHttpRequest();
-
- xhr.open('GET', url);
- xhr.onreadystatechange = handler;
- xhr.responseType = 'json';
- xhr.setRequestHeader('Accept', 'application/json');
- xhr.send();
-
- function handler() {
- if (this.readyState === this.DONE) {
- if (this.status === 200) {
- resolve(this.response);
- } else {
- reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']'));
+ for (var i = 0; i < length; i++) {
+ if (filtered[i]) {
+ results[newLength] = values[i];
+ newLength++;
}
}
- };
+
+ results.length = newLength;
+
+ return results;
+ });
});
}
+});
+enifed('rsvp/hash-settled', ['exports', 'rsvp/promise', 'rsvp/enumerator', 'rsvp/promise-hash', 'rsvp/utils'], function (exports, _rsvpPromise, _rsvpEnumerator, _rsvpPromiseHash, _rsvpUtils) {
+ 'use strict';
- getJSON('/posts.json').then(function(json) {
- // on fulfillment
- }, function(reason) {
- // on rejection
- });
- ```
+ exports.default = hashSettled;
- Unlike callbacks, promises are great composable primitives.
-
- ```js
- Promise.all([
- getJSON('/posts'),
- getJSON('/comments')
- ]).then(function(values){
- values[0] // => postsJSON
- values[1] // => commentsJSON
-
- return values;
- });
- ```
-
- @class RSVP.Promise
- @param {function} resolver
- @param {String} label optional string for labeling the promise.
- Useful for tooling.
- @constructor
-*/
-function Promise(resolver, label) {
- this._id = counter++;
- this._label = label;
- this._state = undefined;
- this._result = undefined;
- this._subscribers = [];
-
- config.instrument && instrument('created', this);
-
- if (noop !== resolver) {
- typeof resolver !== 'function' && needsResolver();
- this instanceof Promise ? initializePromise(this, resolver) : needsNew();
+ function HashSettled(Constructor, object, label) {
+ this._superConstructor(Constructor, object, false, label);
}
-}
-Promise.cast = resolve$1; // deprecated
-Promise.all = all;
-Promise.race = race;
-Promise.resolve = resolve$1;
-Promise.reject = reject$1;
+ HashSettled.prototype = _rsvpUtils.o_create(_rsvpPromiseHash.default.prototype);
+ HashSettled.prototype._superConstructor = _rsvpEnumerator.default;
+ HashSettled.prototype._makeResult = _rsvpEnumerator.makeSettledResult;
-Promise.prototype = {
- constructor: Promise,
+ HashSettled.prototype._validationError = function () {
+ return new Error('hashSettled must be called with an object');
+ };
- _guidKey: guidKey,
-
- _onError: function (reason) {
- var promise = this;
- config.after(function() {
- if (promise._onError) {
- config['trigger']('error', reason, promise._label);
- }
+ /**
+ `RSVP.hashSettled` is similar to `RSVP.allSettled`, but takes an object
+ instead of an array for its `promises` argument.
+
+ Unlike `RSVP.all` or `RSVP.hash`, which implement a fail-fast method,
+ but like `RSVP.allSettled`, `hashSettled` waits until all the
+ constituent promises have returned and then shows you all the results
+ with their states and values/reasons. This is useful if you want to
+ handle multiple promises' failure states together as a set.
+
+ Returns a promise that is fulfilled when all the given promises have been
+ settled, or rejected if the passed parameters are invalid.
+
+ The returned promise is fulfilled with a hash that has the same key names as
+ the `promises` object argument. If any of the values in the object are not
+ promises, they will be copied over to the fulfilled object and marked with state
+ 'fulfilled'.
+
+ Example:
+
+ ```javascript
+ var promises = {
+ myPromise: RSVP.Promise.resolve(1),
+ yourPromise: RSVP.Promise.resolve(2),
+ theirPromise: RSVP.Promise.resolve(3),
+ notAPromise: 4
+ };
+
+ RSVP.hashSettled(promises).then(function(hash){
+ // hash here is an object that looks like:
+ // {
+ // myPromise: { state: 'fulfilled', value: 1 },
+ // yourPromise: { state: 'fulfilled', value: 2 },
+ // theirPromise: { state: 'fulfilled', value: 3 },
+ // notAPromise: { state: 'fulfilled', value: 4 }
+ // }
});
- },
+ ```
+
+ If any of the `promises` given to `RSVP.hash` are rejected, the state will
+ be set to 'rejected' and the reason for rejection provided.
+
+ Example:
+
+ ```javascript
+ var promises = {
+ myPromise: RSVP.Promise.resolve(1),
+ rejectedPromise: RSVP.Promise.reject(new Error('rejection')),
+ anotherRejectedPromise: RSVP.Promise.reject(new Error('more rejection')),
+ };
+
+ RSVP.hashSettled(promises).then(function(hash){
+ // hash here is an object that looks like:
+ // {
+ // myPromise: { state: 'fulfilled', value: 1 },
+ // rejectedPromise: { state: 'rejected', reason: Error },
+ // anotherRejectedPromise: { state: 'rejected', reason: Error },
+ // }
+ // Note that for rejectedPromise, reason.message == 'rejection',
+ // and for anotherRejectedPromise, reason.message == 'more rejection'.
+ });
+ ```
+
+ An important note: `RSVP.hashSettled` is intended for plain JavaScript objects that
+ are just a set of keys and values. `RSVP.hashSettled` will NOT preserve prototype
+ chains.
+
+ Example:
+
+ ```javascript
+ function MyConstructor(){
+ this.example = RSVP.Promise.resolve('Example');
+ }
+
+ MyConstructor.prototype = {
+ protoProperty: RSVP.Promise.resolve('Proto Property')
+ };
+
+ var myObject = new MyConstructor();
+
+ RSVP.hashSettled(myObject).then(function(hash){
+ // protoProperty will not be present, instead you will just have an
+ // object that looks like:
+ // {
+ // example: { state: 'fulfilled', value: 'Example' }
+ // }
+ //
+ // hash.hasOwnProperty('protoProperty'); // false
+ // 'undefined' === typeof hash.protoProperty
+ });
+ ```
+
+ @method hashSettled
+ @for RSVP
+ @param {Object} object
+ @param {String} label optional string that describes the promise.
+ Useful for tooling.
+ @return {Promise} promise that is fulfilled when when all properties of `promises`
+ have been settled.
+ @static
+ */
-/**
- The primary way of interacting with a promise is through its `then` method,
- which registers callbacks to receive either a promise's eventual value or the
- reason why the promise cannot be fulfilled.
-
- ```js
- findUser().then(function(user){
- // user is available
- }, function(reason){
- // user is unavailable, and you are given the reason why
- });
- ```
-
- Chaining
- --------
-
- The return value of `then` is itself a promise. This second, 'downstream'
- promise is resolved with the return value of the first promise's fulfillment
- or rejection handler, or rejected if the handler throws an exception.
-
- ```js
- findUser().then(function (user) {
- return user.name;
- }, function (reason) {
- return 'default name';
- }).then(function (userName) {
- // If `findUser` fulfilled, `userName` will be the user's name, otherwise it
- // will be `'default name'`
- });
-
- findUser().then(function (user) {
- throw new Error('Found user, but still unhappy');
- }, function (reason) {
- throw new Error('`findUser` rejected and we're unhappy');
- }).then(function (value) {
- // never reached
- }, function (reason) {
- // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'.
- // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'.
- });
- ```
- If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.
-
- ```js
- findUser().then(function (user) {
- throw new PedagogicalException('Upstream error');
- }).then(function (value) {
- // never reached
- }).then(function (value) {
- // never reached
- }, function (reason) {
- // The `PedgagocialException` is propagated all the way down to here
- });
- ```
-
- Assimilation
- ------------
-
- Sometimes the value you want to propagate to a downstream promise can only be
- retrieved asynchronously. This can be achieved by returning a promise in the
- fulfillment or rejection handler. The downstream promise will then be pending
- until the returned promise is settled. This is called *assimilation*.
-
- ```js
- findUser().then(function (user) {
- return findCommentsByAuthor(user);
- }).then(function (comments) {
- // The user's comments are now available
- });
- ```
-
- If the assimliated promise rejects, then the downstream promise will also reject.
-
- ```js
- findUser().then(function (user) {
- return findCommentsByAuthor(user);
- }).then(function (comments) {
- // If `findCommentsByAuthor` fulfills, we'll have the value here
- }, function (reason) {
- // If `findCommentsByAuthor` rejects, we'll have the reason here
- });
- ```
-
- Simple Example
- --------------
-
- Synchronous Example
-
- ```javascript
- var result;
-
- try {
- result = findResult();
- // success
- } catch(reason) {
- // failure
+ function hashSettled(object, label) {
+ return new HashSettled(_rsvpPromise.default, object, label).promise;
}
- ```
+});
+enifed('rsvp/hash', ['exports', 'rsvp/promise', 'rsvp/promise-hash'], function (exports, _rsvpPromise, _rsvpPromiseHash) {
+ 'use strict';
- Errback Example
+ exports.default = hash;
- ```js
- findResult(function(result, err){
- if (err) {
- // failure
- } else {
- // success
+ /**
+ `RSVP.hash` is similar to `RSVP.all`, but takes an object instead of an array
+ for its `promises` argument.
+
+ Returns a promise that is fulfilled when all the given promises have been
+ fulfilled, or rejected if any of them become rejected. The returned promise
+ is fulfilled with a hash that has the same key names as the `promises` object
+ argument. If any of the values in the object are not promises, they will
+ simply be copied over to the fulfilled object.
+
+ Example:
+
+ ```javascript
+ var promises = {
+ myPromise: RSVP.resolve(1),
+ yourPromise: RSVP.resolve(2),
+ theirPromise: RSVP.resolve(3),
+ notAPromise: 4
+ };
+
+ RSVP.hash(promises).then(function(hash){
+ // hash here is an object that looks like:
+ // {
+ // myPromise: 1,
+ // yourPromise: 2,
+ // theirPromise: 3,
+ // notAPromise: 4
+ // }
+ });
+ ````
+
+ If any of the `promises` given to `RSVP.hash` are rejected, the first promise
+ that is rejected will be given as the reason to the rejection handler.
+
+ Example:
+
+ ```javascript
+ var promises = {
+ myPromise: RSVP.resolve(1),
+ rejectedPromise: RSVP.reject(new Error('rejectedPromise')),
+ anotherRejectedPromise: RSVP.reject(new Error('anotherRejectedPromise')),
+ };
+
+ RSVP.hash(promises).then(function(hash){
+ // Code here never runs because there are rejected promises!
+ }, function(reason) {
+ // reason.message === 'rejectedPromise'
+ });
+ ```
+
+ An important note: `RSVP.hash` is intended for plain JavaScript objects that
+ are just a set of keys and values. `RSVP.hash` will NOT preserve prototype
+ chains.
+
+ Example:
+
+ ```javascript
+ function MyConstructor(){
+ this.example = RSVP.resolve('Example');
}
- });
- ```
+
+ MyConstructor.prototype = {
+ protoProperty: RSVP.resolve('Proto Property')
+ };
+
+ var myObject = new MyConstructor();
+
+ RSVP.hash(myObject).then(function(hash){
+ // protoProperty will not be present, instead you will just have an
+ // object that looks like:
+ // {
+ // example: 'Example'
+ // }
+ //
+ // hash.hasOwnProperty('protoProperty'); // false
+ // 'undefined' === typeof hash.protoProperty
+ });
+ ```
+
+ @method hash
+ @static
+ @for RSVP
+ @param {Object} object
+ @param {String} label optional string that describes the promise.
+ Useful for tooling.
+ @return {Promise} promise that is fulfilled when all properties of `promises`
+ have been fulfilled, or rejected if any of them become rejected.
+ */
- Promise Example;
-
- ```javascript
- findResult().then(function(result){
- // success
- }, function(reason){
- // failure
- });
- ```
-
- Advanced Example
- --------------
-
- Synchronous Example
-
- ```javascript
- var author, books;
-
- try {
- author = findAuthor();
- books = findBooksByAuthor(author);
- // success
- } catch(reason) {
- // failure
+ function hash(object, label) {
+ return new _rsvpPromiseHash.default(_rsvpPromise.default, object, label).promise;
}
- ```
+});
+enifed('rsvp/instrument', ['exports', 'rsvp/config', 'rsvp/utils'], function (exports, _rsvpConfig, _rsvpUtils) {
+ 'use strict';
- Errback Example
+ exports.default = instrument;
- ```js
+ var queue = [];
- function foundBooks(books) {
+ function scheduleFlush() {
+ setTimeout(function () {
+ var entry;
+ for (var i = 0; i < queue.length; i++) {
+ entry = queue[i];
- }
+ var payload = entry.payload;
- function failure(reason) {
+ payload.guid = payload.key + payload.id;
+ payload.childGuid = payload.key + payload.childId;
+ if (payload.error) {
+ payload.stack = payload.error.stack;
+ }
+ _rsvpConfig.config['trigger'](entry.name, entry.payload);
+ }
+ queue.length = 0;
+ }, 50);
}
- findAuthor(function(author, err){
- if (err) {
- failure(err);
- // failure
- } else {
- try {
- findBoooksByAuthor(author, function(books, err) {
- if (err) {
- failure(err);
- } else {
- try {
- foundBooks(books);
- } catch(reason) {
- failure(reason);
- }
- }
- });
- } catch(error) {
- failure(err);
- }
- // success
+ function instrument(eventName, promise, child) {
+ if (1 === queue.push({
+ name: eventName,
+ payload: {
+ key: promise._guidKey,
+ id: promise._id,
+ eventName: eventName,
+ detail: promise._result,
+ childId: child && child._id,
+ label: promise._label,
+ timeStamp: _rsvpUtils.now(),
+ error: _rsvpConfig.config["instrument-with-stack"] ? new Error(promise._label) : null
+ } })) {
+ scheduleFlush();
}
- });
- ```
+ }
+});
+enifed('rsvp/map', ['exports', 'rsvp/promise', 'rsvp/utils'], function (exports, _rsvpPromise, _rsvpUtils) {
+ 'use strict';
- Promise Example;
+ exports.default = map;
- ```javascript
- findAuthor().
- then(findBooksByAuthor).
- then(function(books){
- // found books
- }).catch(function(reason){
- // something went wrong
- });
- ```
+ /**
+ `RSVP.map` is similar to JavaScript's native `map` method, except that it
+ waits for all promises to become fulfilled before running the `mapFn` on
+ each item in given to `promises`. `RSVP.map` returns a promise that will
+ become fulfilled with the result of running `mapFn` on the values the promises
+ become fulfilled with.
+
+ For example:
+
+ ```javascript
+
+ var promise1 = RSVP.resolve(1);
+ var promise2 = RSVP.resolve(2);
+ var promise3 = RSVP.resolve(3);
+ var promises = [ promise1, promise2, promise3 ];
+
+ var mapFn = function(item){
+ return item + 1;
+ };
+
+ RSVP.map(promises, mapFn).then(function(result){
+ // result is [ 2, 3, 4 ]
+ });
+ ```
+
+ If any of the `promises` given to `RSVP.map` are rejected, the first promise
+ that is rejected will be given as an argument to the returned promise's
+ rejection handler. For example:
+
+ ```javascript
+ var promise1 = RSVP.resolve(1);
+ var promise2 = RSVP.reject(new Error('2'));
+ var promise3 = RSVP.reject(new Error('3'));
+ var promises = [ promise1, promise2, promise3 ];
+
+ var mapFn = function(item){
+ return item + 1;
+ };
+
+ RSVP.map(promises, mapFn).then(function(array){
+ // Code here never runs because there are rejected promises!
+ }, function(reason) {
+ // reason.message === '2'
+ });
+ ```
+
+ `RSVP.map` will also wait if a promise is returned from `mapFn`. For example,
+ say you want to get all comments from a set of blog posts, but you need
+ the blog posts first because they contain a url to those comments.
+
+ ```javscript
+
+ var mapFn = function(blogPost){
+ // getComments does some ajax and returns an RSVP.Promise that is fulfilled
+ // with some comments data
+ return getComments(blogPost.comments_url);
+ };
+
+ // getBlogPosts does some ajax and returns an RSVP.Promise that is fulfilled
+ // with some blog post data
+ RSVP.map(getBlogPosts(), mapFn).then(function(comments){
+ // comments is the result of asking the server for the comments
+ // of all blog posts returned from getBlogPosts()
+ });
+ ```
+
+ @method map
+ @static
+ @for RSVP
+ @param {Array} promises
+ @param {Function} mapFn function to be called on each fulfilled promise.
+ @param {String} label optional string for labeling the promise.
+ Useful for tooling.
+ @return {Promise} promise that is fulfilled with the result of calling
+ `mapFn` on each fulfilled promise or value when they become fulfilled.
+ The promise will be rejected if any of the given `promises` become rejected.
+ @static
+ */
- @method then
- @param {Function} onFulfillment
- @param {Function} onRejection
- @param {String} label optional string for labeling the promise.
- Useful for tooling.
- @return {Promise}
-*/
- then: then,
+ function map(promises, mapFn, label) {
+ return _rsvpPromise.default.all(promises, label).then(function (values) {
+ if (!_rsvpUtils.isFunction(mapFn)) {
+ throw new TypeError("You must pass a function as map's second argument.");
+ }
-/**
- `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
- as the catch block of a try/catch statement.
+ var length = values.length;
+ var results = new Array(length);
- ```js
- function findAuthor(){
- throw new Error('couldn't find that author');
- }
+ for (var i = 0; i < length; i++) {
+ results[i] = mapFn(values[i]);
+ }
- // synchronous
- try {
- findAuthor();
- } catch(reason) {
- // something went wrong
+ return _rsvpPromise.default.all(results, label);
+ });
}
+});
+enifed('rsvp/node', ['exports', 'rsvp/promise', 'rsvp/-internal', 'rsvp/utils'], function (exports, _rsvpPromise, _rsvpInternal, _rsvpUtils) {
+ 'use strict';
- // async with promises
- findAuthor().catch(function(reason){
- // something went wrong
- });
- ```
+ exports.default = denodeify;
- @method catch
- @param {Function} onRejection
- @param {String} label optional string for labeling the promise.
- Useful for tooling.
- @return {Promise}
-*/
- 'catch': function(onRejection, label) {
- return this.then(undefined, onRejection, label);
- },
+ function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }
-/**
- `finally` will be invoked regardless of the promise's fate just as native
- try/catch/finally behaves
+ function Result() {
+ this.value = undefined;
+ }
- Synchronous example:
+ var ERROR = new Result();
+ var GET_THEN_ERROR = new Result();
- ```js
- findAuthor() {
- if (Math.random() > 0.5) {
- throw new Error();
+ function getThen(obj) {
+ try {
+ return obj.then;
+ } catch (error) {
+ ERROR.value = error;
+ return ERROR;
}
- return new Author();
}
- try {
- return findAuthor(); // succeed or fail
- } catch(error) {
- return findOtherAuther();
- } finally {
- // always runs
- // doesn't affect the return value
+ function tryApply(f, s, a) {
+ try {
+ f.apply(s, a);
+ } catch (error) {
+ ERROR.value = error;
+ return ERROR;
+ }
}
- ```
- Asynchronous example:
+ function makeObject(_, argumentNames) {
+ var obj = {};
+ var name;
+ var i;
+ var length = _.length;
+ var args = new Array(length);
- ```js
- findAuthor().catch(function(reason){
- return findOtherAuther();
- }).finally(function(){
- // author was either found, or not
- });
- ```
+ for (var x = 0; x < length; x++) {
+ args[x] = _[x];
+ }
- @method finally
- @param {Function} callback
- @param {String} label optional string for labeling the promise.
- Useful for tooling.
- @return {Promise}
-*/
- 'finally': function(callback, label) {
- var promise = this;
- var constructor = promise.constructor;
+ for (i = 0; i < argumentNames.length; i++) {
+ name = argumentNames[i];
+ obj[name] = args[i + 1];
+ }
- return promise.then(function(value) {
- return constructor.resolve(callback()).then(function() {
- return value;
- });
- }, function(reason) {
- return constructor.resolve(callback()).then(function() {
- return constructor.reject(reason);
- });
- }, label);
+ return obj;
}
-};
-function Result() {
- this.value = undefined;
-}
+ function arrayResult(_) {
+ var length = _.length;
+ var args = new Array(length - 1);
-var ERROR = new Result();
-var GET_THEN_ERROR$1 = new Result();
+ for (var i = 1; i < length; i++) {
+ args[i - 1] = _[i];
+ }
-function getThen$1(obj) {
- try {
- return obj.then;
- } catch(error) {
- ERROR.value= error;
- return ERROR;
+ return args;
}
-}
-
-function tryApply(f, s, a) {
- try {
- f.apply(s, a);
- } catch(error) {
- ERROR.value = error;
- return ERROR;
+ function wrapThenable(then, promise) {
+ return {
+ then: function (onFulFillment, onRejection) {
+ return then.call(promise, onFulFillment, onRejection);
+ }
+ };
}
-}
-function makeObject(_, argumentNames) {
- var obj = {};
- var name;
- var i;
- var length = _.length;
- var args = new Array(length);
-
- for (var x = 0; x < length; x++) {
- args[x] = _[x];
- }
-
- for (i = 0; i < argumentNames.length; i++) {
- name = argumentNames[i];
- obj[name] = args[i + 1];
- }
-
- return obj;
-}
-
-function arrayResult(_) {
- var length = _.length;
- var args = new Array(length - 1);
-
- for (var i = 1; i < length; i++) {
- args[i - 1] = _[i];
- }
-
- return args;
-}
-
-function wrapThenable(then, promise) {
- return {
- then: function(onFulFillment, onRejection) {
- return then.call(promise, onFulFillment, onRejection);
- }
- };
-}
-
-/**
- `RSVP.denodeify` takes a 'node-style' function and returns a function that
- will return an `RSVP.Promise`. You can use `denodeify` in Node.js or the
- browser when you'd prefer to use promises over using callbacks. For example,
- `denodeify` transforms the following:
-
- ```javascript
- var fs = require('fs');
-
- fs.readFile('myfile.txt', function(err, data){
- if (err) return handleError(err);
- handleData(data);
- });
- ```
-
- into:
-
- ```javascript
- var fs = require('fs');
- var readFile = RSVP.denodeify(fs.readFile);
-
- readFile('myfile.txt').then(handleData, handleError);
- ```
-
- If the node function has multiple success parameters, then `denodeify`
- just returns the first one:
-
- ```javascript
- var request = RSVP.denodeify(require('request'));
-
- request('http://example.com').then(function(res) {
- // ...
- });
- ```
-
- However, if you need all success parameters, setting `denodeify`'s
- second parameter to `true` causes it to return all success parameters
- as an array:
-
- ```javascript
- var request = RSVP.denodeify(require('request'), true);
-
- request('http://example.com').then(function(result) {
- // result[0] -> res
- // result[1] -> body
- });
- ```
-
- Or if you pass it an array with names it returns the parameters as a hash:
-
- ```javascript
- var request = RSVP.denodeify(require('request'), ['res', 'body']);
-
- request('http://example.com').then(function(result) {
- // result.res
- // result.body
- });
- ```
-
- Sometimes you need to retain the `this`:
-
- ```javascript
- var app = require('express')();
- var render = RSVP.denodeify(app.render.bind(app));
- ```
-
- The denodified function inherits from the original function. It works in all
- environments, except IE 10 and below. Consequently all properties of the original
- function are available to you. However, any properties you change on the
- denodeified function won't be changed on the original function. Example:
-
- ```javascript
- var request = RSVP.denodeify(require('request')),
- cookieJar = request.jar(); // <- Inheritance is used here
-
- request('http://example.com', {jar: cookieJar}).then(function(res) {
- // cookieJar.cookies holds now the cookies returned by example.com
- });
- ```
-
- Using `denodeify` makes it easier to compose asynchronous operations instead
- of using callbacks. For example, instead of:
-
- ```javascript
- var fs = require('fs');
-
- fs.readFile('myfile.txt', function(err, data){
- if (err) { ... } // Handle error
- fs.writeFile('myfile2.txt', data, function(err){
+ /**
+ `RSVP.denodeify` takes a 'node-style' function and returns a function that
+ will return an `RSVP.Promise`. You can use `denodeify` in Node.js or the
+ browser when you'd prefer to use promises over using callbacks. For example,
+ `denodeify` transforms the following:
+
+ ```javascript
+ var fs = require('fs');
+
+ fs.readFile('myfile.txt', function(err, data){
+ if (err) return handleError(err);
+ handleData(data);
+ });
+ ```
+
+ into:
+
+ ```javascript
+ var fs = require('fs');
+ var readFile = RSVP.denodeify(fs.readFile);
+
+ readFile('myfile.txt').then(handleData, handleError);
+ ```
+
+ If the node function has multiple success parameters, then `denodeify`
+ just returns the first one:
+
+ ```javascript
+ var request = RSVP.denodeify(require('request'));
+
+ request('http://example.com').then(function(res) {
+ // ...
+ });
+ ```
+
+ However, if you need all success parameters, setting `denodeify`'s
+ second parameter to `true` causes it to return all success parameters
+ as an array:
+
+ ```javascript
+ var request = RSVP.denodeify(require('request'), true);
+
+ request('http://example.com').then(function(result) {
+ // result[0] -> res
+ // result[1] -> body
+ });
+ ```
+
+ Or if you pass it an array with names it returns the parameters as a hash:
+
+ ```javascript
+ var request = RSVP.denodeify(require('request'), ['res', 'body']);
+
+ request('http://example.com').then(function(result) {
+ // result.res
+ // result.body
+ });
+ ```
+
+ Sometimes you need to retain the `this`:
+
+ ```javascript
+ var app = require('express')();
+ var render = RSVP.denodeify(app.render.bind(app));
+ ```
+
+ The denodified function inherits from the original function. It works in all
+ environments, except IE 10 and below. Consequently all properties of the original
+ function are available to you. However, any properties you change on the
+ denodeified function won't be changed on the original function. Example:
+
+ ```javascript
+ var request = RSVP.denodeify(require('request')),
+ cookieJar = request.jar(); // <- Inheritance is used here
+
+ request('http://example.com', {jar: cookieJar}).then(function(res) {
+ // cookieJar.cookies holds now the cookies returned by example.com
+ });
+ ```
+
+ Using `denodeify` makes it easier to compose asynchronous operations instead
+ of using callbacks. For example, instead of:
+
+ ```javascript
+ var fs = require('fs');
+
+ fs.readFile('myfile.txt', function(err, data){
if (err) { ... } // Handle error
+ fs.writeFile('myfile2.txt', data, function(err){
+ if (err) { ... } // Handle error
+ console.log('done')
+ });
+ });
+ ```
+
+ you can chain the operations together using `then` from the returned promise:
+
+ ```javascript
+ var fs = require('fs');
+ var readFile = RSVP.denodeify(fs.readFile);
+ var writeFile = RSVP.denodeify(fs.writeFile);
+
+ readFile('myfile.txt').then(function(data){
+ return writeFile('myfile2.txt', data);
+ }).then(function(){
console.log('done')
+ }).catch(function(error){
+ // Handle error
});
- });
- ```
+ ```
+
+ @method denodeify
+ @static
+ @for RSVP
+ @param {Function} nodeFunc a 'node-style' function that takes a callback as
+ its last argument. The callback expects an error to be passed as its first
+ argument (if an error occurred, otherwise null), and the value from the
+ operation as its second argument ('function(err, value){ }').
+ @param {Boolean|Array} [options] An optional paramter that if set
+ to `true` causes the promise to fulfill with the callback's success arguments
+ as an array. This is useful if the node function has multiple success
+ paramters. If you set this paramter to an array with names, the promise will
+ fulfill with a hash with these names as keys and the success parameters as
+ values.
+ @return {Function} a function that wraps `nodeFunc` to return an
+ `RSVP.Promise`
+ @static
+ */
- you can chain the operations together using `then` from the returned promise:
+ function denodeify(nodeFunc, options) {
+ var fn = function () {
+ var self = this;
+ var l = arguments.length;
+ var args = new Array(l + 1);
+ var arg;
+ var promiseInput = false;
- ```javascript
- var fs = require('fs');
- var readFile = RSVP.denodeify(fs.readFile);
- var writeFile = RSVP.denodeify(fs.writeFile);
+ for (var i = 0; i < l; ++i) {
+ arg = arguments[i];
- readFile('myfile.txt').then(function(data){
- return writeFile('myfile2.txt', data);
- }).then(function(){
- console.log('done')
- }).catch(function(error){
- // Handle error
- });
- ```
-
- @method denodeify
- @static
- @for RSVP
- @param {Function} nodeFunc a 'node-style' function that takes a callback as
- its last argument. The callback expects an error to be passed as its first
- argument (if an error occurred, otherwise null), and the value from the
- operation as its second argument ('function(err, value){ }').
- @param {Boolean|Array} [options] An optional paramter that if set
- to `true` causes the promise to fulfill with the callback's success arguments
- as an array. This is useful if the node function has multiple success
- paramters. If you set this paramter to an array with names, the promise will
- fulfill with a hash with these names as keys and the success parameters as
- values.
- @return {Function} a function that wraps `nodeFunc` to return an
- `RSVP.Promise`
- @static
-*/
-function denodeify(nodeFunc, options) {
- var fn = function() {
- var self = this;
- var l = arguments.length;
- var args = new Array(l + 1);
- var arg;
- var promiseInput = false;
-
- for (var i = 0; i < l; ++i) {
- arg = arguments[i];
-
- if (!promiseInput) {
- // TODO: clean this up
- promiseInput = needsPromiseInput(arg);
- if (promiseInput === GET_THEN_ERROR$1) {
- var p = new Promise(noop);
- reject(p, GET_THEN_ERROR$1.value);
- return p;
- } else if (promiseInput && promiseInput !== true) {
- arg = wrapThenable(promiseInput, arg);
+ if (!promiseInput) {
+ // TODO: clean this up
+ promiseInput = needsPromiseInput(arg);
+ if (promiseInput === GET_THEN_ERROR) {
+ var p = new _rsvpPromise.default(_rsvpInternal.noop);
+ _rsvpInternal.reject(p, GET_THEN_ERROR.value);
+ return p;
+ } else if (promiseInput && promiseInput !== true) {
+ arg = wrapThenable(promiseInput, arg);
+ }
}
+ args[i] = arg;
}
- args[i] = arg;
- }
- var promise = new Promise(noop);
+ var promise = new _rsvpPromise.default(_rsvpInternal.noop);
- args[l] = function(err, val) {
- if (err)
- reject(promise, err);
- else if (options === undefined)
- resolve(promise, val);
- else if (options === true)
- resolve(promise, arrayResult(arguments));
- else if (isArray(options))
- resolve(promise, makeObject(arguments, options));
- else
- resolve(promise, val);
+ args[l] = function (err, val) {
+ if (err) _rsvpInternal.reject(promise, err);else if (options === undefined) _rsvpInternal.resolve(promise, val);else if (options === true) _rsvpInternal.resolve(promise, arrayResult(arguments));else if (_rsvpUtils.isArray(options)) _rsvpInternal.resolve(promise, makeObject(arguments, options));else _rsvpInternal.resolve(promise, val);
+ };
+
+ if (promiseInput) {
+ return handlePromiseInput(promise, args, nodeFunc, self);
+ } else {
+ return handleValueInput(promise, args, nodeFunc, self);
+ }
};
- if (promiseInput) {
- return handlePromiseInput(promise, args, nodeFunc, self);
- } else {
- return handleValueInput(promise, args, nodeFunc, self);
- }
- };
+ _defaults(fn, nodeFunc);
- fn.__proto__ = nodeFunc;
-
- return fn;
-}
-
-function handleValueInput(promise, args, nodeFunc, self) {
- var result = tryApply(nodeFunc, self, args);
- if (result === ERROR) {
- reject(promise, result.value);
+ return fn;
}
- return promise;
-}
-function handlePromiseInput(promise, args, nodeFunc, self){
- return Promise.all(args).then(function(args){
+ function handleValueInput(promise, args, nodeFunc, self) {
var result = tryApply(nodeFunc, self, args);
if (result === ERROR) {
- reject(promise, result.value);
+ _rsvpInternal.reject(promise, result.value);
}
return promise;
- });
-}
+ }
-function needsPromiseInput(arg) {
- if (arg && typeof arg === 'object') {
- if (arg.constructor === Promise) {
- return true;
+ function handlePromiseInput(promise, args, nodeFunc, self) {
+ return _rsvpPromise.default.all(args).then(function (args) {
+ var result = tryApply(nodeFunc, self, args);
+ if (result === ERROR) {
+ _rsvpInternal.reject(promise, result.value);
+ }
+ return promise;
+ });
+ }
+
+ function needsPromiseInput(arg) {
+ if (arg && typeof arg === 'object') {
+ if (arg.constructor === _rsvpPromise.default) {
+ return true;
+ } else {
+ return getThen(arg);
+ }
} else {
- return getThen$1(arg);
+ return false;
}
- } else {
- return false;
}
-}
+});
+enifed('rsvp/platform', ['exports'], function (exports) {
+ 'use strict';
-/**
- This is a convenient alias for `RSVP.Promise.all`.
+ var platform;
- @method all
- @static
- @for RSVP
- @param {Array} array Array of promises.
- @param {String} label An optional label. This is useful
- for tooling.
-*/
-function all$1(array, label) {
- return Promise.all(array, label);
-}
+ /* global self */
+ if (typeof self === 'object') {
+ platform = self;
-function AllSettled(Constructor, entries, label) {
- this._superConstructor(Constructor, entries, false /* don't abort on reject */, label);
-}
-
-AllSettled.prototype = o_create(Enumerator.prototype);
-AllSettled.prototype._superConstructor = Enumerator;
-AllSettled.prototype._makeResult = makeSettledResult;
-AllSettled.prototype._validationError = function() {
- return new Error('allSettled must be called with an array');
-};
-
-/**
- `RSVP.allSettled` is similar to `RSVP.all`, but instead of implementing
- a fail-fast method, it waits until all the promises have returned and
- shows you all the results. This is useful if you want to handle multiple
- promises' failure states together as a set.
-
- Returns a promise that is fulfilled when all the given promises have been
- settled. The return promise is fulfilled with an array of the states of
- the promises passed into the `promises` array argument.
-
- Each state object will either indicate fulfillment or rejection, and
- provide the corresponding value or reason. The states will take one of
- the following formats:
-
- ```javascript
- { state: 'fulfilled', value: value }
- or
- { state: 'rejected', reason: reason }
- ```
-
- Example:
-
- ```javascript
- var promise1 = RSVP.Promise.resolve(1);
- var promise2 = RSVP.Promise.reject(new Error('2'));
- var promise3 = RSVP.Promise.reject(new Error('3'));
- var promises = [ promise1, promise2, promise3 ];
-
- RSVP.allSettled(promises).then(function(array){
- // array == [
- // { state: 'fulfilled', value: 1 },
- // { state: 'rejected', reason: Error },
- // { state: 'rejected', reason: Error }
- // ]
- // Note that for the second item, reason.message will be '2', and for the
- // third item, reason.message will be '3'.
- }, function(error) {
- // Not run. (This block would only be called if allSettled had failed,
- // for instance if passed an incorrect argument type.)
- });
- ```
-
- @method allSettled
- @static
- @for RSVP
- @param {Array} entries
- @param {String} label - optional string that describes the promise.
- Useful for tooling.
- @return {Promise} promise that is fulfilled with an array of the settled
- states of the constituent promises.
-*/
-
-function allSettled(entries, label) {
- return new AllSettled(Promise, entries, label).promise;
-}
-
-/**
- This is a convenient alias for `RSVP.Promise.race`.
-
- @method race
- @static
- @for RSVP
- @param {Array} array Array of promises.
- @param {String} label An optional label. This is useful
- for tooling.
- */
-function race$1(array, label) {
- return Promise.race(array, label);
-}
-
-function PromiseHash(Constructor, object, label) {
- this._superConstructor(Constructor, object, true, label);
-}
-
-PromiseHash.prototype = o_create(Enumerator.prototype);
-PromiseHash.prototype._superConstructor = Enumerator;
-PromiseHash.prototype._init = function() {
- this._result = {};
-};
-
-PromiseHash.prototype._validateInput = function(input) {
- return input && typeof input === 'object';
-};
-
-PromiseHash.prototype._validationError = function() {
- return new Error('Promise.hash must be called with an object');
-};
-
-PromiseHash.prototype._enumerate = function() {
- var enumerator = this;
- var promise = enumerator.promise;
- var input = enumerator._input;
- var results = [];
-
- for (var key in input) {
- if (promise._state === PENDING && Object.prototype.hasOwnProperty.call(input, key)) {
- results.push({
- position: key,
- entry: input[key]
- });
+ /* global global */
+ } else if (typeof global === 'object') {
+ platform = global;
+ } else {
+ throw new Error('no global: `self` or `global` found');
}
- }
- var length = results.length;
- enumerator._remaining = length;
- var result;
+ exports.default = platform;
+});
+enifed('rsvp/promise-hash', ['exports', 'rsvp/enumerator', 'rsvp/-internal', 'rsvp/utils'], function (exports, _rsvpEnumerator, _rsvpInternal, _rsvpUtils) {
+ 'use strict';
- for (var i = 0; promise._state === PENDING && i < length; i++) {
- result = results[i];
- enumerator._eachEntry(result.entry, result.position);
+ function PromiseHash(Constructor, object, label) {
+ this._superConstructor(Constructor, object, true, label);
}
-};
-/**
- `RSVP.hash` is similar to `RSVP.all`, but takes an object instead of an array
- for its `promises` argument.
+ exports.default = PromiseHash;
- Returns a promise that is fulfilled when all the given promises have been
- fulfilled, or rejected if any of them become rejected. The returned promise
- is fulfilled with a hash that has the same key names as the `promises` object
- argument. If any of the values in the object are not promises, they will
- simply be copied over to the fulfilled object.
-
- Example:
-
- ```javascript
- var promises = {
- myPromise: RSVP.resolve(1),
- yourPromise: RSVP.resolve(2),
- theirPromise: RSVP.resolve(3),
- notAPromise: 4
+ PromiseHash.prototype = _rsvpUtils.o_create(_rsvpEnumerator.default.prototype);
+ PromiseHash.prototype._superConstructor = _rsvpEnumerator.default;
+ PromiseHash.prototype._init = function () {
+ this._result = {};
};
- RSVP.hash(promises).then(function(hash){
- // hash here is an object that looks like:
- // {
- // myPromise: 1,
- // yourPromise: 2,
- // theirPromise: 3,
- // notAPromise: 4
- // }
- });
- ````
-
- If any of the `promises` given to `RSVP.hash` are rejected, the first promise
- that is rejected will be given as the reason to the rejection handler.
-
- Example:
-
- ```javascript
- var promises = {
- myPromise: RSVP.resolve(1),
- rejectedPromise: RSVP.reject(new Error('rejectedPromise')),
- anotherRejectedPromise: RSVP.reject(new Error('anotherRejectedPromise')),
+ PromiseHash.prototype._validateInput = function (input) {
+ return input && typeof input === 'object';
};
- RSVP.hash(promises).then(function(hash){
- // Code here never runs because there are rejected promises!
- }, function(reason) {
- // reason.message === 'rejectedPromise'
- });
- ```
-
- An important note: `RSVP.hash` is intended for plain JavaScript objects that
- are just a set of keys and values. `RSVP.hash` will NOT preserve prototype
- chains.
-
- Example:
-
- ```javascript
- function MyConstructor(){
- this.example = RSVP.resolve('Example');
- }
-
- MyConstructor.prototype = {
- protoProperty: RSVP.resolve('Proto Property')
+ PromiseHash.prototype._validationError = function () {
+ return new Error('Promise.hash must be called with an object');
};
- var myObject = new MyConstructor();
+ PromiseHash.prototype._enumerate = function () {
+ var enumerator = this;
+ var promise = enumerator.promise;
+ var input = enumerator._input;
+ var results = [];
- RSVP.hash(myObject).then(function(hash){
- // protoProperty will not be present, instead you will just have an
- // object that looks like:
- // {
- // example: 'Example'
- // }
- //
- // hash.hasOwnProperty('protoProperty'); // false
- // 'undefined' === typeof hash.protoProperty
- });
- ```
+ for (var key in input) {
+ if (promise._state === _rsvpInternal.PENDING && Object.prototype.hasOwnProperty.call(input, key)) {
+ results.push({
+ position: key,
+ entry: input[key]
+ });
+ }
+ }
- @method hash
- @static
- @for RSVP
- @param {Object} object
- @param {String} label optional string that describes the promise.
- Useful for tooling.
- @return {Promise} promise that is fulfilled when all properties of `promises`
- have been fulfilled, or rejected if any of them become rejected.
-*/
-function hash(object, label) {
- return new PromiseHash(Promise, object, label).promise;
-}
+ var length = results.length;
+ enumerator._remaining = length;
+ var result;
-function HashSettled(Constructor, object, label) {
- this._superConstructor(Constructor, object, false, label);
-}
-
-HashSettled.prototype = o_create(PromiseHash.prototype);
-HashSettled.prototype._superConstructor = Enumerator;
-HashSettled.prototype._makeResult = makeSettledResult;
-
-HashSettled.prototype._validationError = function() {
- return new Error('hashSettled must be called with an object');
-};
-
-/**
- `RSVP.hashSettled` is similar to `RSVP.allSettled`, but takes an object
- instead of an array for its `promises` argument.
-
- Unlike `RSVP.all` or `RSVP.hash`, which implement a fail-fast method,
- but like `RSVP.allSettled`, `hashSettled` waits until all the
- constituent promises have returned and then shows you all the results
- with their states and values/reasons. This is useful if you want to
- handle multiple promises' failure states together as a set.
-
- Returns a promise that is fulfilled when all the given promises have been
- settled, or rejected if the passed parameters are invalid.
-
- The returned promise is fulfilled with a hash that has the same key names as
- the `promises` object argument. If any of the values in the object are not
- promises, they will be copied over to the fulfilled object and marked with state
- 'fulfilled'.
-
- Example:
-
- ```javascript
- var promises = {
- myPromise: RSVP.Promise.resolve(1),
- yourPromise: RSVP.Promise.resolve(2),
- theirPromise: RSVP.Promise.resolve(3),
- notAPromise: 4
+ for (var i = 0; promise._state === _rsvpInternal.PENDING && i < length; i++) {
+ result = results[i];
+ enumerator._eachEntry(result.entry, result.position);
+ }
};
+});
+enifed('rsvp/promise', ['exports', 'rsvp/config', 'rsvp/instrument', 'rsvp/utils', 'rsvp/-internal', 'rsvp/promise/all', 'rsvp/promise/race', 'rsvp/promise/resolve', 'rsvp/promise/reject'], function (exports, _rsvpConfig, _rsvpInstrument, _rsvpUtils, _rsvpInternal, _rsvpPromiseAll, _rsvpPromiseRace, _rsvpPromiseResolve, _rsvpPromiseReject) {
+ 'use strict';
- RSVP.hashSettled(promises).then(function(hash){
- // hash here is an object that looks like:
- // {
- // myPromise: { state: 'fulfilled', value: 1 },
- // yourPromise: { state: 'fulfilled', value: 2 },
- // theirPromise: { state: 'fulfilled', value: 3 },
- // notAPromise: { state: 'fulfilled', value: 4 }
- // }
- });
- ```
+ exports.default = Promise;
- If any of the `promises` given to `RSVP.hash` are rejected, the state will
- be set to 'rejected' and the reason for rejection provided.
+ var guidKey = 'rsvp_' + _rsvpUtils.now() + '-';
+ var counter = 0;
- Example:
+ function needsResolver() {
+ throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
+ }
- ```javascript
- var promises = {
- myPromise: RSVP.Promise.resolve(1),
- rejectedPromise: RSVP.Promise.reject(new Error('rejection')),
- anotherRejectedPromise: RSVP.Promise.reject(new Error('more rejection')),
- };
-
- RSVP.hashSettled(promises).then(function(hash){
- // hash here is an object that looks like:
- // {
- // myPromise: { state: 'fulfilled', value: 1 },
- // rejectedPromise: { state: 'rejected', reason: Error },
- // anotherRejectedPromise: { state: 'rejected', reason: Error },
- // }
- // Note that for rejectedPromise, reason.message == 'rejection',
- // and for anotherRejectedPromise, reason.message == 'more rejection'.
- });
- ```
-
- An important note: `RSVP.hashSettled` is intended for plain JavaScript objects that
- are just a set of keys and values. `RSVP.hashSettled` will NOT preserve prototype
- chains.
-
- Example:
-
- ```javascript
- function MyConstructor(){
- this.example = RSVP.Promise.resolve('Example');
+ function needsNew() {
+ throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
}
- MyConstructor.prototype = {
- protoProperty: RSVP.Promise.resolve('Proto Property')
- };
+ /**
+ Promise objects represent the eventual result of an asynchronous operation. The
+ primary way of interacting with a promise is through its `then` method, which
+ registers callbacks to receive either a promise’s eventual value or the reason
+ why the promise cannot be fulfilled.
+
+ Terminology
+ -----------
+
+ - `promise` is an object or function with a `then` method whose behavior conforms to this specification.
+ - `thenable` is an object or function that defines a `then` method.
+ - `value` is any legal JavaScript value (including undefined, a thenable, or a promise).
+ - `exception` is a value that is thrown using the throw statement.
+ - `reason` is a value that indicates why a promise was rejected.
+ - `settled` the final resting state of a promise, fulfilled or rejected.
+
+ A promise can be in one of three states: pending, fulfilled, or rejected.
+
+ Promises that are fulfilled have a fulfillment value and are in the fulfilled
+ state. Promises that are rejected have a rejection reason and are in the
+ rejected state. A fulfillment value is never a thenable.
+
+ Promises can also be said to *resolve* a value. If this value is also a
+ promise, then the original promise's settled state will match the value's
+ settled state. So a promise that *resolves* a promise that rejects will
+ itself reject, and a promise that *resolves* a promise that fulfills will
+ itself fulfill.
+
+
+ Basic Usage:
+ ------------
+
+ ```js
+ var promise = new Promise(function(resolve, reject) {
+ // on success
+ resolve(value);
+
+ // on failure
+ reject(reason);
+ });
+
+ promise.then(function(value) {
+ // on fulfillment
+ }, function(reason) {
+ // on rejection
+ });
+ ```
+
+ Advanced Usage:
+ ---------------
+
+ Promises shine when abstracting away asynchronous interactions such as
+ `XMLHttpRequest`s.
+
+ ```js
+ function getJSON(url) {
+ return new Promise(function(resolve, reject){
+ var xhr = new XMLHttpRequest();
+
+ xhr.open('GET', url);
+ xhr.onreadystatechange = handler;
+ xhr.responseType = 'json';
+ xhr.setRequestHeader('Accept', 'application/json');
+ xhr.send();
+
+ function handler() {
+ if (this.readyState === this.DONE) {
+ if (this.status === 200) {
+ resolve(this.response);
+ } else {
+ reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']'));
+ }
+ }
+ };
+ });
+ }
+
+ getJSON('/posts.json').then(function(json) {
+ // on fulfillment
+ }, function(reason) {
+ // on rejection
+ });
+ ```
+
+ Unlike callbacks, promises are great composable primitives.
+
+ ```js
+ Promise.all([
+ getJSON('/posts'),
+ getJSON('/comments')
+ ]).then(function(values){
+ values[0] // => postsJSON
+ values[1] // => commentsJSON
+
+ return values;
+ });
+ ```
+
+ @class RSVP.Promise
+ @param {function} resolver
+ @param {String} label optional string for labeling the promise.
+ Useful for tooling.
+ @constructor
+ */
- var myObject = new MyConstructor();
+ function Promise(resolver, label) {
+ var promise = this;
- RSVP.hashSettled(myObject).then(function(hash){
- // protoProperty will not be present, instead you will just have an
- // object that looks like:
- // {
- // example: { state: 'fulfilled', value: 'Example' }
- // }
- //
- // hash.hasOwnProperty('protoProperty'); // false
- // 'undefined' === typeof hash.protoProperty
- });
- ```
+ promise._id = counter++;
+ promise._label = label;
+ promise._state = undefined;
+ promise._result = undefined;
+ promise._subscribers = [];
- @method hashSettled
- @for RSVP
- @param {Object} object
- @param {String} label optional string that describes the promise.
- Useful for tooling.
- @return {Promise} promise that is fulfilled when when all properties of `promises`
- have been settled.
- @static
-*/
-function hashSettled(object, label) {
- return new HashSettled(Promise, object, label).promise;
-}
+ if (_rsvpConfig.config.instrument) {
+ _rsvpInstrument.default('created', promise);
+ }
-/**
- `RSVP.rethrow` will rethrow an error on the next turn of the JavaScript event
- loop in order to aid debugging.
+ if (_rsvpInternal.noop !== resolver) {
+ if (!_rsvpUtils.isFunction(resolver)) {
+ needsResolver();
+ }
- Promises A+ specifies that any exceptions that occur with a promise must be
- caught by the promises implementation and bubbled to the last handler. For
- this reason, it is recommended that you always specify a second rejection
- handler function to `then`. However, `RSVP.rethrow` will throw the exception
- outside of the promise, so it bubbles up to your console if in the browser,
- or domain/cause uncaught exception in Node. `rethrow` will also throw the
- error again so the error can be handled by the promise per the spec.
+ if (!(promise instanceof Promise)) {
+ needsNew();
+ }
- ```javascript
- function throws(){
- throw new Error('Whoops!');
+ _rsvpInternal.initializePromise(promise, resolver);
+ }
}
- var promise = new RSVP.Promise(function(resolve, reject){
- throws();
- });
+ Promise.cast = _rsvpPromiseResolve.default; // deprecated
+ Promise.all = _rsvpPromiseAll.default;
+ Promise.race = _rsvpPromiseRace.default;
+ Promise.resolve = _rsvpPromiseResolve.default;
+ Promise.reject = _rsvpPromiseReject.default;
- promise.catch(RSVP.rethrow).then(function(){
- // Code here doesn't run because the promise became rejected due to an
- // error!
- }, function (err){
- // handle the error here
- });
- ```
+ Promise.prototype = {
+ constructor: Promise,
- The 'Whoops' error will be thrown on the next turn of the event loop
- and you can watch for it in your console. You can also handle it using a
- rejection handler given to `.then` or `.catch` on the returned promise.
+ _guidKey: guidKey,
- @method rethrow
- @static
- @for RSVP
- @param {Error} reason reason the promise became rejected.
- @throws Error
- @static
-*/
-function rethrow(reason) {
- setTimeout(function() {
- throw reason;
- });
- throw reason;
-}
+ _onError: function (reason) {
+ var promise = this;
+ _rsvpConfig.config.after(function () {
+ if (promise._onError) {
+ _rsvpConfig.config['trigger']('error', reason);
+ }
+ });
+ },
-/**
- `RSVP.defer` returns an object similar to jQuery's `$.Deferred`.
- `RSVP.defer` should be used when porting over code reliant on `$.Deferred`'s
- interface. New code should use the `RSVP.Promise` constructor instead.
+ /**
+ The primary way of interacting with a promise is through its `then` method,
+ which registers callbacks to receive either a promise's eventual value or the
+ reason why the promise cannot be fulfilled.
+
+ ```js
+ findUser().then(function(user){
+ // user is available
+ }, function(reason){
+ // user is unavailable, and you are given the reason why
+ });
+ ```
+
+ Chaining
+ --------
+
+ The return value of `then` is itself a promise. This second, 'downstream'
+ promise is resolved with the return value of the first promise's fulfillment
+ or rejection handler, or rejected if the handler throws an exception.
+
+ ```js
+ findUser().then(function (user) {
+ return user.name;
+ }, function (reason) {
+ return 'default name';
+ }).then(function (userName) {
+ // If `findUser` fulfilled, `userName` will be the user's name, otherwise it
+ // will be `'default name'`
+ });
+
+ findUser().then(function (user) {
+ throw new Error('Found user, but still unhappy');
+ }, function (reason) {
+ throw new Error('`findUser` rejected and we're unhappy');
+ }).then(function (value) {
+ // never reached
+ }, function (reason) {
+ // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'.
+ // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'.
+ });
+ ```
+ If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.
+
+ ```js
+ findUser().then(function (user) {
+ throw new PedagogicalException('Upstream error');
+ }).then(function (value) {
+ // never reached
+ }).then(function (value) {
+ // never reached
+ }, function (reason) {
+ // The `PedgagocialException` is propagated all the way down to here
+ });
+ ```
+
+ Assimilation
+ ------------
+
+ Sometimes the value you want to propagate to a downstream promise can only be
+ retrieved asynchronously. This can be achieved by returning a promise in the
+ fulfillment or rejection handler. The downstream promise will then be pending
+ until the returned promise is settled. This is called *assimilation*.
+
+ ```js
+ findUser().then(function (user) {
+ return findCommentsByAuthor(user);
+ }).then(function (comments) {
+ // The user's comments are now available
+ });
+ ```
+
+ If the assimliated promise rejects, then the downstream promise will also reject.
+
+ ```js
+ findUser().then(function (user) {
+ return findCommentsByAuthor(user);
+ }).then(function (comments) {
+ // If `findCommentsByAuthor` fulfills, we'll have the value here
+ }, function (reason) {
+ // If `findCommentsByAuthor` rejects, we'll have the reason here
+ });
+ ```
+
+ Simple Example
+ --------------
+
+ Synchronous Example
+
+ ```javascript
+ var result;
+
+ try {
+ result = findResult();
+ // success
+ } catch(reason) {
+ // failure
+ }
+ ```
+
+ Errback Example
+
+ ```js
+ findResult(function(result, err){
+ if (err) {
+ // failure
+ } else {
+ // success
+ }
+ });
+ ```
+
+ Promise Example;
+
+ ```javascript
+ findResult().then(function(result){
+ // success
+ }, function(reason){
+ // failure
+ });
+ ```
+
+ Advanced Example
+ --------------
+
+ Synchronous Example
+
+ ```javascript
+ var author, books;
+
+ try {
+ author = findAuthor();
+ books = findBooksByAuthor(author);
+ // success
+ } catch(reason) {
+ // failure
+ }
+ ```
+
+ Errback Example
+
+ ```js
+
+ function foundBooks(books) {
+
+ }
+
+ function failure(reason) {
+
+ }
+
+ findAuthor(function(author, err){
+ if (err) {
+ failure(err);
+ // failure
+ } else {
+ try {
+ findBoooksByAuthor(author, function(books, err) {
+ if (err) {
+ failure(err);
+ } else {
+ try {
+ foundBooks(books);
+ } catch(reason) {
+ failure(reason);
+ }
+ }
+ });
+ } catch(error) {
+ failure(err);
+ }
+ // success
+ }
+ });
+ ```
+
+ Promise Example;
+
+ ```javascript
+ findAuthor().
+ then(findBooksByAuthor).
+ then(function(books){
+ // found books
+ }).catch(function(reason){
+ // something went wrong
+ });
+ ```
+
+ @method then
+ @param {Function} onFulfillment
+ @param {Function} onRejection
+ @param {String} label optional string for labeling the promise.
+ Useful for tooling.
+ @return {Promise}
+ */
+ then: function (onFulfillment, onRejection, label) {
+ var parent = this;
+ var state = parent._state;
- The object returned from `RSVP.defer` is a plain object with three properties:
+ if (state === _rsvpInternal.FULFILLED && !onFulfillment || state === _rsvpInternal.REJECTED && !onRejection) {
+ if (_rsvpConfig.config.instrument) {
+ _rsvpInstrument.default('chained', parent, parent);
+ }
+ return parent;
+ }
- * promise - an `RSVP.Promise`.
- * reject - a function that causes the `promise` property on this object to
- become rejected
- * resolve - a function that causes the `promise` property on this object to
- become fulfilled.
+ parent._onError = null;
- Example:
+ var child = new parent.constructor(_rsvpInternal.noop, label);
+ var result = parent._result;
- ```javascript
- var deferred = RSVP.defer();
+ if (_rsvpConfig.config.instrument) {
+ _rsvpInstrument.default('chained', parent, child);
+ }
- deferred.resolve("Success!");
+ if (state) {
+ var callback = arguments[state - 1];
+ _rsvpConfig.config.async(function () {
+ _rsvpInternal.invokeCallback(state, child, callback, result);
+ });
+ } else {
+ _rsvpInternal.subscribe(parent, child, onFulfillment, onRejection);
+ }
- deferred.promise.then(function(value){
- // value here is "Success!"
- });
- ```
+ return child;
+ },
- @method defer
- @static
- @for RSVP
- @param {String} label optional string for labeling the promise.
- Useful for tooling.
- @return {Object}
- */
+ /**
+ `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
+ as the catch block of a try/catch statement.
+
+ ```js
+ function findAuthor(){
+ throw new Error('couldn't find that author');
+ }
+
+ // synchronous
+ try {
+ findAuthor();
+ } catch(reason) {
+ // something went wrong
+ }
+
+ // async with promises
+ findAuthor().catch(function(reason){
+ // something went wrong
+ });
+ ```
+
+ @method catch
+ @param {Function} onRejection
+ @param {String} label optional string for labeling the promise.
+ Useful for tooling.
+ @return {Promise}
+ */
+ 'catch': function (onRejection, label) {
+ return this.then(undefined, onRejection, label);
+ },
-function defer(label) {
- var deferred = {};
+ /**
+ `finally` will be invoked regardless of the promise's fate just as native
+ try/catch/finally behaves
+
+ Synchronous example:
+
+ ```js
+ findAuthor() {
+ if (Math.random() > 0.5) {
+ throw new Error();
+ }
+ return new Author();
+ }
+
+ try {
+ return findAuthor(); // succeed or fail
+ } catch(error) {
+ return findOtherAuther();
+ } finally {
+ // always runs
+ // doesn't affect the return value
+ }
+ ```
+
+ Asynchronous example:
+
+ ```js
+ findAuthor().catch(function(reason){
+ return findOtherAuther();
+ }).finally(function(){
+ // author was either found, or not
+ });
+ ```
+
+ @method finally
+ @param {Function} callback
+ @param {String} label optional string for labeling the promise.
+ Useful for tooling.
+ @return {Promise}
+ */
+ 'finally': function (callback, label) {
+ var promise = this;
+ var constructor = promise.constructor;
- deferred['promise'] = new Promise(function(resolve, reject) {
- deferred['resolve'] = resolve;
- deferred['reject'] = reject;
- }, label);
-
- return deferred;
-}
-
-/**
- `RSVP.map` is similar to JavaScript's native `map` method, except that it
- waits for all promises to become fulfilled before running the `mapFn` on
- each item in given to `promises`. `RSVP.map` returns a promise that will
- become fulfilled with the result of running `mapFn` on the values the promises
- become fulfilled with.
-
- For example:
-
- ```javascript
-
- var promise1 = RSVP.resolve(1);
- var promise2 = RSVP.resolve(2);
- var promise3 = RSVP.resolve(3);
- var promises = [ promise1, promise2, promise3 ];
-
- var mapFn = function(item){
- return item + 1;
+ return promise.then(function (value) {
+ return constructor.resolve(callback()).then(function () {
+ return value;
+ });
+ }, function (reason) {
+ return constructor.resolve(callback()).then(function () {
+ throw reason;
+ });
+ }, label);
+ }
};
+});
+enifed('rsvp/promise/all', ['exports', 'rsvp/enumerator'], function (exports, _rsvpEnumerator) {
+ 'use strict';
- RSVP.map(promises, mapFn).then(function(result){
- // result is [ 2, 3, 4 ]
- });
- ```
+ exports.default = all;
- If any of the `promises` given to `RSVP.map` are rejected, the first promise
- that is rejected will be given as an argument to the returned promise's
- rejection handler. For example:
+ /**
+ `RSVP.Promise.all` accepts an array of promises, and returns a new promise which
+ is fulfilled with an array of fulfillment values for the passed promises, or
+ rejected with the reason of the first passed promise to be rejected. It casts all
+ elements of the passed iterable to promises as it runs this algorithm.
+
+ Example:
+
+ ```javascript
+ var promise1 = RSVP.resolve(1);
+ var promise2 = RSVP.resolve(2);
+ var promise3 = RSVP.resolve(3);
+ var promises = [ promise1, promise2, promise3 ];
+
+ RSVP.Promise.all(promises).then(function(array){
+ // The array here would be [ 1, 2, 3 ];
+ });
+ ```
+
+ If any of the `promises` given to `RSVP.all` are rejected, the first promise
+ that is rejected will be given as an argument to the returned promises's
+ rejection handler. For example:
+
+ Example:
+
+ ```javascript
+ var promise1 = RSVP.resolve(1);
+ var promise2 = RSVP.reject(new Error("2"));
+ var promise3 = RSVP.reject(new Error("3"));
+ var promises = [ promise1, promise2, promise3 ];
+
+ RSVP.Promise.all(promises).then(function(array){
+ // Code here never runs because there are rejected promises!
+ }, function(error) {
+ // error.message === "2"
+ });
+ ```
+
+ @method all
+ @static
+ @param {Array} entries array of promises
+ @param {String} label optional string for labeling the promise.
+ Useful for tooling.
+ @return {Promise} promise that is fulfilled when all `promises` have been
+ fulfilled, or rejected if any of them become rejected.
+ @static
+ */
- ```javascript
- var promise1 = RSVP.resolve(1);
- var promise2 = RSVP.reject(new Error('2'));
- var promise3 = RSVP.reject(new Error('3'));
- var promises = [ promise1, promise2, promise3 ];
+ function all(entries, label) {
+ return new _rsvpEnumerator.default(this, entries, true, /* abort on reject */label).promise;
+ }
+});
+enifed('rsvp/promise/race', ['exports', 'rsvp/utils', 'rsvp/-internal'], function (exports, _rsvpUtils, _rsvpInternal) {
+ 'use strict';
- var mapFn = function(item){
- return item + 1;
- };
+ exports.default = race;
- RSVP.map(promises, mapFn).then(function(array){
- // Code here never runs because there are rejected promises!
- }, function(reason) {
- // reason.message === '2'
- });
- ```
+ /**
+ `RSVP.Promise.race` returns a new promise which is settled in the same way as the
+ first passed promise to settle.
+
+ Example:
+
+ ```javascript
+ var promise1 = new RSVP.Promise(function(resolve, reject){
+ setTimeout(function(){
+ resolve('promise 1');
+ }, 200);
+ });
+
+ var promise2 = new RSVP.Promise(function(resolve, reject){
+ setTimeout(function(){
+ resolve('promise 2');
+ }, 100);
+ });
+
+ RSVP.Promise.race([promise1, promise2]).then(function(result){
+ // result === 'promise 2' because it was resolved before promise1
+ // was resolved.
+ });
+ ```
+
+ `RSVP.Promise.race` is deterministic in that only the state of the first
+ settled promise matters. For example, even if other promises given to the
+ `promises` array argument are resolved, but the first settled promise has
+ become rejected before the other promises became fulfilled, the returned
+ promise will become rejected:
+
+ ```javascript
+ var promise1 = new RSVP.Promise(function(resolve, reject){
+ setTimeout(function(){
+ resolve('promise 1');
+ }, 200);
+ });
+
+ var promise2 = new RSVP.Promise(function(resolve, reject){
+ setTimeout(function(){
+ reject(new Error('promise 2'));
+ }, 100);
+ });
+
+ RSVP.Promise.race([promise1, promise2]).then(function(result){
+ // Code here never runs
+ }, function(reason){
+ // reason.message === 'promise 2' because promise 2 became rejected before
+ // promise 1 became fulfilled
+ });
+ ```
+
+ An example real-world use case is implementing timeouts:
+
+ ```javascript
+ RSVP.Promise.race([ajax('foo.json'), timeout(5000)])
+ ```
+
+ @method race
+ @static
+ @param {Array} entries array of promises to observe
+ @param {String} label optional string for describing the promise returned.
+ Useful for tooling.
+ @return {Promise} a promise which settles in the same way as the first passed
+ promise to settle.
+ */
- `RSVP.map` will also wait if a promise is returned from `mapFn`. For example,
- say you want to get all comments from a set of blog posts, but you need
- the blog posts first because they contain a url to those comments.
+ function race(entries, label) {
+ /*jshint validthis:true */
+ var Constructor = this;
- ```javscript
+ var promise = new Constructor(_rsvpInternal.noop, label);
- var mapFn = function(blogPost){
- // getComments does some ajax and returns an RSVP.Promise that is fulfilled
- // with some comments data
- return getComments(blogPost.comments_url);
- };
+ if (!_rsvpUtils.isArray(entries)) {
+ _rsvpInternal.reject(promise, new TypeError('You must pass an array to race.'));
+ return promise;
+ }
- // getBlogPosts does some ajax and returns an RSVP.Promise that is fulfilled
- // with some blog post data
- RSVP.map(getBlogPosts(), mapFn).then(function(comments){
- // comments is the result of asking the server for the comments
- // of all blog posts returned from getBlogPosts()
- });
- ```
+ var length = entries.length;
- @method map
- @static
- @for RSVP
- @param {Array} promises
- @param {Function} mapFn function to be called on each fulfilled promise.
- @param {String} label optional string for labeling the promise.
- Useful for tooling.
- @return {Promise} promise that is fulfilled with the result of calling
- `mapFn` on each fulfilled promise or value when they become fulfilled.
- The promise will be rejected if any of the given `promises` become rejected.
- @static
-*/
-function map(promises, mapFn, label) {
- return Promise.all(promises, label).then(function(values) {
- if (!isFunction(mapFn)) {
- throw new TypeError("You must pass a function as map's second argument.");
+ function onFulfillment(value) {
+ _rsvpInternal.resolve(promise, value);
}
- var length = values.length;
- var results = new Array(length);
+ function onRejection(reason) {
+ _rsvpInternal.reject(promise, reason);
+ }
- for (var i = 0; i < length; i++) {
- results[i] = mapFn(values[i]);
+ for (var i = 0; promise._state === _rsvpInternal.PENDING && i < length; i++) {
+ _rsvpInternal.subscribe(Constructor.resolve(entries[i]), undefined, onFulfillment, onRejection);
}
- return Promise.all(results, label);
- });
-}
+ return promise;
+ }
+});
+enifed('rsvp/promise/reject', ['exports', 'rsvp/-internal'], function (exports, _rsvpInternal) {
+ 'use strict';
-/**
- This is a convenient alias for `RSVP.Promise.resolve`.
+ exports.default = reject;
- @method resolve
- @static
- @for RSVP
- @param {*} value value that the returned promise will be resolved with
- @param {String} label optional string for identifying the returned promise.
- Useful for tooling.
- @return {Promise} a promise that will become fulfilled with the given
- `value`
-*/
-function resolve$2(value, label) {
- return Promise.resolve(value, label);
-}
+ /**
+ `RSVP.Promise.reject` returns a promise rejected with the passed `reason`.
+ It is shorthand for the following:
+
+ ```javascript
+ var promise = new RSVP.Promise(function(resolve, reject){
+ reject(new Error('WHOOPS'));
+ });
+
+ promise.then(function(value){
+ // Code here doesn't run because the promise is rejected!
+ }, function(reason){
+ // reason.message === 'WHOOPS'
+ });
+ ```
+
+ Instead of writing the above, your code now simply becomes the following:
+
+ ```javascript
+ var promise = RSVP.Promise.reject(new Error('WHOOPS'));
+
+ promise.then(function(value){
+ // Code here doesn't run because the promise is rejected!
+ }, function(reason){
+ // reason.message === 'WHOOPS'
+ });
+ ```
+
+ @method reject
+ @static
+ @param {*} reason value that the returned promise will be rejected with.
+ @param {String} label optional string for identifying the returned promise.
+ Useful for tooling.
+ @return {Promise} a promise rejected with the given `reason`.
+ */
-/**
- This is a convenient alias for `RSVP.Promise.reject`.
+ function reject(reason, label) {
+ /*jshint validthis:true */
+ var Constructor = this;
+ var promise = new Constructor(_rsvpInternal.noop, label);
+ _rsvpInternal.reject(promise, reason);
+ return promise;
+ }
+});
+enifed('rsvp/promise/resolve', ['exports', 'rsvp/-internal'], function (exports, _rsvpInternal) {
+ 'use strict';
- @method reject
- @static
- @for RSVP
- @param {*} reason value that the returned promise will be rejected with.
- @param {String} label optional string for identifying the returned promise.
- Useful for tooling.
- @return {Promise} a promise rejected with the given `reason`.
-*/
-function reject$2(reason, label) {
- return Promise.reject(reason, label);
-}
+ exports.default = resolve;
-/**
- `RSVP.filter` is similar to JavaScript's native `filter` method, except that it
- waits for all promises to become fulfilled before running the `filterFn` on
- each item in given to `promises`. `RSVP.filter` returns a promise that will
- become fulfilled with the result of running `filterFn` on the values the
- promises become fulfilled with.
+ /**
+ `RSVP.Promise.resolve` returns a promise that will become resolved with the
+ passed `value`. It is shorthand for the following:
+
+ ```javascript
+ var promise = new RSVP.Promise(function(resolve, reject){
+ resolve(1);
+ });
+
+ promise.then(function(value){
+ // value === 1
+ });
+ ```
+
+ Instead of writing the above, your code now simply becomes the following:
+
+ ```javascript
+ var promise = RSVP.Promise.resolve(1);
+
+ promise.then(function(value){
+ // value === 1
+ });
+ ```
+
+ @method resolve
+ @static
+ @param {*} object value that the returned promise will be resolved with
+ @param {String} label optional string for identifying the returned promise.
+ Useful for tooling.
+ @return {Promise} a promise that will become fulfilled with the given
+ `value`
+ */
- For example:
+ function resolve(object, label) {
+ /*jshint validthis:true */
+ var Constructor = this;
- ```javascript
+ if (object && typeof object === 'object' && object.constructor === Constructor) {
+ return object;
+ }
- var promise1 = RSVP.resolve(1);
- var promise2 = RSVP.resolve(2);
- var promise3 = RSVP.resolve(3);
+ var promise = new Constructor(_rsvpInternal.noop, label);
+ _rsvpInternal.resolve(promise, object);
+ return promise;
+ }
+});
+enifed('rsvp/race', ['exports', 'rsvp/promise'], function (exports, _rsvpPromise) {
+ 'use strict';
- var promises = [promise1, promise2, promise3];
+ exports.default = race;
- var filterFn = function(item){
- return item > 1;
- };
+ /**
+ This is a convenient alias for `RSVP.Promise.race`.
+
+ @method race
+ @static
+ @for RSVP
+ @param {Array} array Array of promises.
+ @param {String} label An optional label. This is useful
+ for tooling.
+ */
- RSVP.filter(promises, filterFn).then(function(result){
- // result is [ 2, 3 ]
- });
- ```
+ function race(array, label) {
+ return _rsvpPromise.default.race(array, label);
+ }
+});
+enifed('rsvp/reject', ['exports', 'rsvp/promise'], function (exports, _rsvpPromise) {
+ 'use strict';
- If any of the `promises` given to `RSVP.filter` are rejected, the first promise
- that is rejected will be given as an argument to the returned promise's
- rejection handler. For example:
+ exports.default = reject;
- ```javascript
- var promise1 = RSVP.resolve(1);
- var promise2 = RSVP.reject(new Error('2'));
- var promise3 = RSVP.reject(new Error('3'));
- var promises = [ promise1, promise2, promise3 ];
+ /**
+ This is a convenient alias for `RSVP.Promise.reject`.
+
+ @method reject
+ @static
+ @for RSVP
+ @param {*} reason value that the returned promise will be rejected with.
+ @param {String} label optional string for identifying the returned promise.
+ Useful for tooling.
+ @return {Promise} a promise rejected with the given `reason`.
+ */
- var filterFn = function(item){
- return item > 1;
- };
+ function reject(reason, label) {
+ return _rsvpPromise.default.reject(reason, label);
+ }
+});
+enifed('rsvp/resolve', ['exports', 'rsvp/promise'], function (exports, _rsvpPromise) {
+ 'use strict';
- RSVP.filter(promises, filterFn).then(function(array){
- // Code here never runs because there are rejected promises!
- }, function(reason) {
- // reason.message === '2'
- });
- ```
+ exports.default = resolve;
- `RSVP.filter` will also wait for any promises returned from `filterFn`.
- For instance, you may want to fetch a list of users then return a subset
- of those users based on some asynchronous operation:
+ /**
+ This is a convenient alias for `RSVP.Promise.resolve`.
+
+ @method resolve
+ @static
+ @for RSVP
+ @param {*} value value that the returned promise will be resolved with
+ @param {String} label optional string for identifying the returned promise.
+ Useful for tooling.
+ @return {Promise} a promise that will become fulfilled with the given
+ `value`
+ */
- ```javascript
-
- var alice = { name: 'alice' };
- var bob = { name: 'bob' };
- var users = [ alice, bob ];
-
- var promises = users.map(function(user){
- return RSVP.resolve(user);
- });
-
- var filterFn = function(user){
- // Here, Alice has permissions to create a blog post, but Bob does not.
- return getPrivilegesForUser(user).then(function(privs){
- return privs.can_create_blog_post === true;
+ function resolve(value, label) {
+ return _rsvpPromise.default.resolve(value, label);
+ }
+});
+enifed("rsvp/rethrow", ["exports"], function (exports) {
+ /**
+ `RSVP.rethrow` will rethrow an error on the next turn of the JavaScript event
+ loop in order to aid debugging.
+
+ Promises A+ specifies that any exceptions that occur with a promise must be
+ caught by the promises implementation and bubbled to the last handler. For
+ this reason, it is recommended that you always specify a second rejection
+ handler function to `then`. However, `RSVP.rethrow` will throw the exception
+ outside of the promise, so it bubbles up to your console if in the browser,
+ or domain/cause uncaught exception in Node. `rethrow` will also throw the
+ error again so the error can be handled by the promise per the spec.
+
+ ```javascript
+ function throws(){
+ throw new Error('Whoops!');
+ }
+
+ var promise = new RSVP.Promise(function(resolve, reject){
+ throws();
});
- };
- RSVP.filter(promises, filterFn).then(function(users){
- // true, because the server told us only Alice can create a blog post.
- users.length === 1;
- // false, because Alice is the only user present in `users`
- users[0] === bob;
- });
- ```
+
+ promise.catch(RSVP.rethrow).then(function(){
+ // Code here doesn't run because the promise became rejected due to an
+ // error!
+ }, function (err){
+ // handle the error here
+ });
+ ```
+
+ The 'Whoops' error will be thrown on the next turn of the event loop
+ and you can watch for it in your console. You can also handle it using a
+ rejection handler given to `.then` or `.catch` on the returned promise.
+
+ @method rethrow
+ @static
+ @for RSVP
+ @param {Error} reason reason the promise became rejected.
+ @throws Error
+ @static
+ */
+ "use strict";
- @method filter
- @static
- @for RSVP
- @param {Array} promises
- @param {Function} filterFn - function to be called on each resolved value to
- filter the final results.
- @param {String} label optional string describing the promise. Useful for
- tooling.
- @return {Promise}
-*/
-function filter(promises, filterFn, label) {
- return Promise.all(promises, label).then(function(values) {
- if (!isFunction(filterFn)) {
- throw new TypeError("You must pass a function as filter's second argument.");
- }
+ exports.default = rethrow;
- var length = values.length;
- var filtered = new Array(length);
-
- for (var i = 0; i < length; i++) {
- filtered[i] = filterFn(values[i]);
- }
-
- return Promise.all(filtered, label).then(function(filtered) {
- var results = new Array(length);
- var newLength = 0;
-
- for (var i = 0; i < length; i++) {
- if (filtered[i]) {
- results[newLength] = values[i];
- newLength++;
- }
- }
-
- results.length = newLength;
-
- return results;
+ function rethrow(reason) {
+ setTimeout(function () {
+ throw reason;
});
- });
-}
-
-var len = 0;
-var vertxNext;
-function asap(callback, arg) {
- queue$1[len] = callback;
- queue$1[len + 1] = arg;
- len += 2;
- if (len === 2) {
- // If len is 1, that means that we need to schedule an async flush.
- // If additional callbacks are queued before the queue is flushed, they
- // will be processed by this flush that we are scheduling.
- scheduleFlush$1();
+ throw reason;
}
-}
+});
+enifed('rsvp/utils', ['exports'], function (exports) {
+ 'use strict';
-var browserWindow = (typeof window !== 'undefined') ? window : undefined;
-var browserGlobal = browserWindow || {};
-var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver;
-var isNode = typeof self === 'undefined' &&
- typeof process !== 'undefined' && {}.toString.call(process) === '[object process]';
+ exports.objectOrFunction = objectOrFunction;
+ exports.isFunction = isFunction;
+ exports.isMaybeThenable = isMaybeThenable;
-// test for web worker but not in IE10
-var isWorker = typeof Uint8ClampedArray !== 'undefined' &&
- typeof importScripts !== 'undefined' &&
- typeof MessageChannel !== 'undefined';
+ function objectOrFunction(x) {
+ return typeof x === 'function' || typeof x === 'object' && x !== null;
+ }
-// node
-function useNextTick() {
- var nextTick = process.nextTick;
- // node version 0.10.x displays a deprecation warning when nextTick is used recursively
- // setImmediate should be used instead instead
- var version = process.versions.node.match(/^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/);
- if (Array.isArray(version) && version[1] === '0' && version[2] === '10') {
- nextTick = setImmediate;
+ function isFunction(x) {
+ return typeof x === 'function';
}
- return function() {
- nextTick(flush);
- };
-}
-// vertx
-function useVertxTimer() {
- return function() {
- vertxNext(flush);
- };
-}
-
-function useMutationObserver() {
- var iterations = 0;
- var observer = new BrowserMutationObserver(flush);
- var node = document.createTextNode('');
- observer.observe(node, { characterData: true });
-
- return function() {
- node.data = (iterations = ++iterations % 2);
- };
-}
-
-// web worker
-function useMessageChannel() {
- var channel = new MessageChannel();
- channel.port1.onmessage = flush;
- return function () {
- channel.port2.postMessage(0);
- };
-}
-
-function useSetTimeout() {
- return function() {
- setTimeout(flush, 1);
- };
-}
-
-var queue$1 = new Array(1000);
-function flush() {
- for (var i = 0; i < len; i+=2) {
- var callback = queue$1[i];
- var arg = queue$1[i+1];
-
- callback(arg);
-
- queue$1[i] = undefined;
- queue$1[i+1] = undefined;
+ function isMaybeThenable(x) {
+ return typeof x === 'object' && x !== null;
}
- len = 0;
-}
-
-function attemptVertex() {
- try {
- var r = require;
- var vertx = r('vertx');
- vertxNext = vertx.runOnLoop || vertx.runOnContext;
- return useVertxTimer();
- } catch(e) {
- return useSetTimeout();
+ var _isArray;
+ if (!Array.isArray) {
+ _isArray = function (x) {
+ return Object.prototype.toString.call(x) === '[object Array]';
+ };
+ } else {
+ _isArray = Array.isArray;
}
-}
-var scheduleFlush$1;
-// Decide what async method to use to triggering processing of queued callbacks:
-if (isNode) {
- scheduleFlush$1 = useNextTick();
-} else if (BrowserMutationObserver) {
- scheduleFlush$1 = useMutationObserver();
-} else if (isWorker) {
- scheduleFlush$1 = useMessageChannel();
-} else if (browserWindow === undefined && typeof require === 'function') {
- scheduleFlush$1 = attemptVertex();
-} else {
- scheduleFlush$1 = useSetTimeout();
-}
+ var isArray = _isArray;
-// defaults
-config.async = asap;
-config.after = function(cb) {
- setTimeout(cb, 0);
-};
-var cast = resolve$2;
-function async(callback, arg) {
- config.async(callback, arg);
-}
+ exports.isArray = isArray;
+ // Date.now is not available in browsers < IE9
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/now#Compatibility
+ var now = Date.now || function () {
+ return new Date().getTime();
+ };
-function on() {
- config['on'].apply(config, arguments);
-}
+ exports.now = now;
+ function F() {}
-function off() {
- config['off'].apply(config, arguments);
-}
-
-// Set up instrumentation through `window.__PROMISE_INTRUMENTATION__`
-if (typeof window !== 'undefined' && typeof window['__PROMISE_INSTRUMENTATION__'] === 'object') {
- var callbacks = window['__PROMISE_INSTRUMENTATION__'];
- configure('instrument', true);
- for (var eventName in callbacks) {
- if (callbacks.hasOwnProperty(eventName)) {
- on(eventName, callbacks[eventName]);
+ var o_create = Object.create || function (o) {
+ if (arguments.length > 1) {
+ throw new Error('Second argument not supported');
}
- }
-}
-
-exports.cast = cast;
-exports.Promise = Promise;
-exports.EventTarget = EventTarget;
-exports.all = all$1;
-exports.allSettled = allSettled;
-exports.race = race$1;
-exports.hash = hash;
-exports.hashSettled = hashSettled;
-exports.rethrow = rethrow;
-exports.defer = defer;
-exports.denodeify = denodeify;
-exports.configure = configure;
-exports.on = on;
-exports.off = off;
-exports.resolve = resolve$2;
-exports.reject = reject$2;
-exports.async = async;
-exports.map = map;
-exports.filter = filter;
-
-Object.defineProperty(exports, '__esModule', { value: true });
-
+ if (typeof o !== 'object') {
+ throw new TypeError('Argument must be an object');
+ }
+ F.prototype = o;
+ return new F();
+ };
+ exports.o_create = o_create;
});
(function (m) { if (typeof module === "object" && module.exports) { module.exports = m } }(requireModule("ember-runtime").default));
}());