electron-devtools-vendor
Version:
<div align="center"> <h2>electron-devtools-vendor</h2> <img alt="MIT" src="https://img.shields.io/github/license/BlackHole1/electron-devtools-vendor?color=9cf&style=flat-square"> <img alt="GitHub repo size" src="https://img.shields.io/github/r
1,797 lines (1,504 loc) • 246 kB
JavaScript
(function(adapter, env) {
var define = window.define, requireModule = window.requireModule;
if (typeof define !== 'function' || typeof requireModule !== 'function') {
(function() {
var registry = {}, seen = {};
define = function(name, deps, callback) {
if (arguments.length < 3) {
callback = deps;
deps = [];
}
registry[name] = { deps: deps, callback: callback };
};
requireModule = function(name) {
if (seen[name]) { return seen[name]; }
seen[name] = {};
var mod = registry[name];
if (!mod) {
throw new Error("Module: '" + name + "' not found.");
}
var deps = mod.deps;
var callback = mod.callback;
var reified = [];
var exports;
for (var i = 0, l = deps.length; i < l; i++) {
if (deps[i] === 'exports') {
reified.push(exports = {});
} else {
reified.push(requireModule(deps[i]));
}
}
var value = callback.apply(this, reified);
seen[name] = exports || value;
return seen[name];
};
define.registry = registry;
define.seen = seen;
})();
}
'use strict';
define('ember-debug/adapters/basic', ['exports'], function (exports) {
'use strict';
/* globals requireModule */
/* eslint no-console: 0 */
var Ember = window.Ember;
var $ = Ember.$;
var A = Ember.A;
var computed = Ember.computed;
var RSVP = Ember.RSVP;
var EmberObject = Ember.Object;
var Promise = RSVP.Promise;
var resolve = RSVP.resolve;
exports['default'] = EmberObject.extend({
init: function init() {
var _this = this;
resolve(this.connect(), 'ember-inspector').then(function () {
_this.onConnectionReady();
}, null, 'ember-inspector');
},
/**
* Uses the current build's config module to determine
* the environment.
*
* @property environment
* @type {String}
*/
environment: computed(function () {
return requireModule('ember-debug/config')['default'].environment;
}),
debug: function debug() {
return console.debug.apply(console, arguments);
},
log: function log() {
return console.log.apply(console, arguments);
},
/**
* A wrapper for `console.warn`.
*
* @method warn
*/
warn: function warn() {
return console.warn.apply(console, arguments);
},
/**
Used to send messages to EmberExtension
@param {Object} type the message to the send
*/
sendMessage: function sendMessage() /* options */{},
/**
Register functions to be called
when a message from EmberExtension is received
@param {Function} callback
*/
onMessageReceived: function onMessageReceived(callback) {
this.get('_messageCallbacks').pushObject(callback);
},
/**
Inspect a specific element. This usually
means using the current environment's tools
to inspect the element in the DOM.
For example, in chrome, `inspect(elem)`
will open the Elements tab in dev tools
and highlight the element.
@param {DOM Element} elem
*/
inspectElement: function inspectElement() /* elem */{},
_messageCallbacks: computed(function () {
return A();
}),
_messageReceived: function _messageReceived(message) {
this.get('_messageCallbacks').forEach(function (callback) {
callback(message);
});
},
/**
* Handle an error caused by EmberDebug.
*
* This function rethrows in development and test envs,
* but warns instead in production.
*
* The idea is to control errors triggered by the inspector
* and make sure that users don't get mislead by inspector-caused
* bugs.
*
* @method handleError
* @param {Error} error
*/
handleError: function handleError(error) {
if (this.get('environment') === 'production') {
if (error && error instanceof Error) {
error = 'Error message: ' + error.message + '\nStack trace: ' + error.stack;
}
this.warn('Ember Inspector has errored.\n' + 'This is likely a bug in the inspector itself.\n' + 'You can report bugs at https://github.com/emberjs/ember-inspector.\n' + error);
} else {
this.warn('EmberDebug has errored:');
throw error;
}
},
/**
A promise that resolves when the connection
with the inspector is set up and ready.
@return {Promise}
*/
connect: function connect() {
var _this2 = this;
return new Promise(function (resolve, reject) {
$(function () {
if (_this2.isDestroyed) {
reject();
}
_this2.interval = setInterval(function () {
if (document.documentElement.dataset.emberExtension) {
clearInterval(_this2.interval);
resolve();
}
}, 10);
});
}, 'ember-inspector');
},
willDestroy: function willDestroy() {
this._super();
clearInterval(this.interval);
},
_isReady: false,
_pendingMessages: computed(function () {
return A();
}),
send: function send(options) {
if (this._isReady) {
this.sendMessage.apply(this, arguments);
} else {
this.get('_pendingMessages').push(options);
}
},
/**
Called when the connection is set up.
Flushes the pending messages.
*/
onConnectionReady: function onConnectionReady() {
var _this3 = this;
// Flush pending messages
var messages = this.get('_pendingMessages');
messages.forEach(function (options) {
return _this3.sendMessage(options);
});
messages.clear();
this._isReady = true;
}
});
});
'use strict';
define('ember-debug/adapters/bookmarklet', ['exports', 'ember-debug/adapters/basic'], function (exports, BasicAdapter) {
'use strict';
var Ember = window.Ember;
var $ = Ember.$;
exports['default'] = BasicAdapter['default'].extend({
init: function init() {
this._super();
this._listen();
},
sendMessage: function sendMessage(options) {
options = options || {};
window.emberInspector.w.postMessage(options, window.emberInspector.url);
},
_listen: function _listen() {
var _this = this;
window.addEventListener('message', function (e) {
if (e.origin !== window.emberInspector.url) {
return;
}
var message = e.data;
if (message.from === 'devtools') {
_this._messageReceived(message);
}
});
$(window).on('unload', function () {
_this.sendMessage({
unloading: true
});
});
}
});
});
'use strict';
define('ember-debug/adapters/chrome', ['exports', 'ember-debug/adapters/web-extension'], function (exports, WebExtension) {
'use strict';
exports['default'] = WebExtension['default'].extend();
});
'use strict';
define('ember-debug/adapters/firefox', ['exports', 'ember-debug/adapters/web-extension'], function (exports, WebExtension) {
'use strict';
/* eslint no-empty:0 */
var Ember = window.Ember;
var run = Ember.run;
exports['default'] = WebExtension['default'].extend({
debug: function debug() {
// WORKAROUND: temporarily workaround issues with firebug console object:
// - https://github.com/tildeio/ember-extension/issues/94
// - https://github.com/firebug/firebug/pull/109
// - https://code.google.com/p/fbug/issues/detail?id=7045
try {
this._super.apply(this, arguments);
} catch (e) {}
},
log: function log() {
// WORKAROUND: temporarily workaround issues with firebug console object:
// - https://github.com/tildeio/ember-extension/issues/94
// - https://github.com/firebug/firebug/pull/109
// - https://code.google.com/p/fbug/issues/detail?id=7045
try {
this._super.apply(this, arguments);
} catch (e) {}
}
});
});
'use strict';
define('ember-debug/adapters/web-extension', ['exports', 'ember-debug/adapters/basic'], function (exports, BasicAdapter) {
'use strict';
var Ember = window.Ember;
var computed = Ember.computed;
var run = Ember.run;
var extend = Ember.$.extend;
var isArray = Array.isArray;
var keys = Object.keys;
exports['default'] = BasicAdapter['default'].extend({
connect: function connect() {
var _this = this;
var channel = this.get('_channel');
return this._super.apply(this, arguments).then(function () {
window.postMessage('debugger-client', '*', [channel.port2]);
_this._listen();
}, null, 'ember-inspector');
},
sendMessage: function sendMessage(options) {
options = options || {};
// If prototype extensions are disabled, `Ember.A()` arrays
// would not be considered native arrays, so it's not possible to
// "clone" them through postMessage unless they are converted to a
// native array.
if (!Ember.EXTEND_PROTOTYPES || Ember.EXTEND_PROTOTYPES.Array === false) {
options = deepCloneArrays(extend(true, {}, options));
}
this.get('_chromePort').postMessage(options);
},
inspectElement: function inspectElement(elem) {
/* globals inspect */
inspect(elem);
},
_channel: computed(function () {
return new MessageChannel();
}).readOnly(),
_chromePort: computed(function () {
return this.get('_channel.port1');
}).readOnly(),
_listen: function _listen() {
var _this2 = this;
var chromePort = this.get('_chromePort');
chromePort.addEventListener('message', function (event) {
var message = event.data;
run(function () {
_this2._messageReceived(message);
});
});
chromePort.start();
}
});
/**
* Recursively clones all arrays. Needed because Chrome
* refuses to clone Ember Arrays when extend prototypes is disabled.
*
* If the item passed is an array, a clone of the array is returned.
* If the item is an object or an array, or array properties/items are cloned.
*
* @param {Mixed} item The item to clone
* @return {Mixed}
*/
function deepCloneArrays(item) {
if (isArray(item)) {
item = item.slice();
item.forEach(function (child, key) {
item[key] = deepCloneArrays(child);
});
} else if (item && typeof item === 'object') {
keys(item).forEach(function (key) {
item[key] = deepCloneArrays(item[key]);
});
}
return item;
}
});
'use strict';
define('ember-debug/adapters/websocket', ['exports', 'ember-debug/adapters/basic'], function (exports, BasicAdapter) {
'use strict';
var Ember = window.Ember;
var $ = Ember.$;
var computed = Ember.computed;
var run = Ember.run;
var Promise = Ember.RSVP.Promise;
exports['default'] = BasicAdapter['default'].extend({
sendMessage: function sendMessage(options) {
options = options || {};
this.get('socket').emit('emberInspectorMessage', options);
},
socket: computed(function () {
return window.EMBER_INSPECTOR_CONFIG.remoteDebugSocket;
}),
_listen: function _listen() {
var _this = this;
this.get('socket').on('emberInspectorMessage', function (message) {
run(function () {
_this._messageReceived(message);
});
});
},
_disconnect: function _disconnect() {
this.get('socket').removeAllListeners("emberInspectorMessage");
},
connect: function connect() {
var _this2 = this;
return new Promise(function (resolve, reject) {
$(function () {
if (_this2.isDestroyed) {
reject();
}
var EMBER_INSPECTOR_CONFIG = window.EMBER_INSPECTOR_CONFIG;
if (typeof EMBER_INSPECTOR_CONFIG === 'object' && EMBER_INSPECTOR_CONFIG.remoteDebugSocket) {
resolve();
}
});
}).then(function () {
_this2._listen();
});
},
willDestroy: function willDestroy() {
this._disconnect();
}
});
});
'use strict';
define('ember-debug/addons/ember-new-computed/index', ['exports', 'ember-debug/addons/ember-new-computed/utils/can-use-new-syntax'], function (exports, canUseNewSyntax) {
'use strict';
var Ember = window.Ember;
var computed = Ember.computed;
exports['default'] = function () {
var polyfillArguments = [];
var config = arguments[arguments.length - 1];
if (typeof config === 'function' || canUseNewSyntax['default']) {
return computed.apply(this, arguments);
}
for (var i = 0, l = arguments.length - 1; i < l; i++) {
polyfillArguments.push(arguments[i]);
}
var func = undefined;
if (config.set) {
func = function (key, value) {
if (arguments.length > 1) {
return config.set.call(this, key, value);
} else {
return config.get.call(this, key);
}
};
} else {
func = function (key) {
return config.get.call(this, key);
};
}
polyfillArguments.push(func);
return computed.apply(this, polyfillArguments);
};
});
'use strict';
define('ember-debug/addons/ember-new-computed/utils/can-use-new-syntax', ['exports'], function (exports) {
'use strict';
var Ember = window.Ember;
var computed = Ember.computed;
var supportsSetterGetter = undefined;
try {
computed({
set: function set() {},
get: function get() {}
});
supportsSetterGetter = true;
} catch (e) {
supportsSetterGetter = false;
}
exports['default'] = supportsSetterGetter;
});
'use strict';
define('ember-debug/container-debug', ['exports', 'ember-debug/mixins/port-mixin'], function (exports, PortMixin) {
'use strict';
var Ember = window.Ember;
var EmberObject = Ember.Object;
var computed = Ember.computed;
var oneWay = computed.oneWay;
exports['default'] = EmberObject.extend(PortMixin['default'], {
namespace: null,
port: oneWay('namespace.port').readOnly(),
application: oneWay('namespace.application').readOnly(),
objectInspector: oneWay('namespace.objectInspector').readOnly(),
container: computed('application', function () {
return this.get('application.__container__');
}),
portNamespace: 'container',
TYPES_TO_SKIP: computed(function () {
return ['component-lookup', 'container-debug-adapter', 'resolver-for-debugging', 'event_dispatcher'];
}),
typeFromKey: function typeFromKey(key) {
return key.split(':').shift();
},
nameFromKey: function nameFromKey(key) {
return key.split(':').pop();
},
shouldHide: function shouldHide(type) {
return type[0] === '-' || this.get('TYPES_TO_SKIP').indexOf(type) !== -1;
},
instancesByType: function instancesByType() {
var key = undefined;
var instancesByType = {};
var cache = this.get('container').cache;
// Detect if InheritingDict (from Ember < 1.8)
if (typeof cache.dict !== 'undefined' && typeof cache.eachLocal !== 'undefined') {
cache = cache.dict;
}
for (key in cache) {
var type = this.typeFromKey(key);
if (this.shouldHide(type)) {
continue;
}
if (instancesByType[type] === undefined) {
instancesByType[type] = [];
}
instancesByType[type].push({
fullName: key,
instance: cache[key]
});
}
return instancesByType;
},
getTypes: function getTypes() {
var key = undefined;
var types = [];
var instancesByType = this.instancesByType();
for (key in instancesByType) {
types.push({ name: key, count: instancesByType[key].length });
}
return types;
},
getInstances: function getInstances(type) {
var _this = this;
var instances = this.instancesByType()[type];
if (!instances) {
return null;
}
return instances.map(function (item) {
return {
name: _this.nameFromKey(item.fullName),
fullName: item.fullName,
inspectable: _this.get('objectInspector').canSend(item.instance)
};
});
},
messages: {
getTypes: function getTypes() {
this.sendMessage('types', {
types: this.getTypes()
});
},
getInstances: function getInstances(message) {
var instances = this.getInstances(message.containerType);
if (instances) {
this.sendMessage('instances', {
instances: instances,
status: 200
});
} else {
this.sendMessage('instances', {
status: 404
});
}
},
sendInstanceToConsole: function sendInstanceToConsole(message) {
var instance = this.get('container').lookup(message.name);
this.get('objectToConsole').sendValueToConsole(instance);
}
}
});
});
'use strict';
define('ember-debug/data-debug', ['exports', 'ember-debug/mixins/port-mixin'], function (exports, PortMixin) {
'use strict';
var Ember = window.Ember;
var EmberObject = Ember.Object;
var computed = Ember.computed;
var guidFor = Ember.guidFor;
var A = Ember.A;
var alias = computed.alias;
exports['default'] = EmberObject.extend(PortMixin['default'], {
init: function init() {
this._super();
this.sentTypes = {};
this.sentRecords = {};
},
sentTypes: {},
sentRecords: {},
releaseTypesMethod: null,
releaseRecordsMethod: null,
adapter: computed('application', function () {
var container = this.get('application').__container__;
// dataAdapter:main is deprecated
return this._resolve('data-adapter:main') && container.lookup('data-adapter:main') || this._resolve('dataAdapter:main') && container.lookup('dataAdapter:main');
}),
_resolve: function _resolve(name) {
// Ember >= 2.1
if (this.get('application').resolveRegistration) {
return this.get('application').resolveRegistration(name);
}
var container = this.get('application').__container__;
var registry = this.get('application.registry');
if (registry) {
// Ember >= 1.11
return registry.resolve(name);
} else if (container.resolve) {
// Ember < 1.11
return container.resolve(name);
} else {
// Ember >= 2.0 < 2.1
return container.registry.resolve(name);
}
},
namespace: null,
port: alias('namespace.port'),
application: alias('namespace.application'),
objectInspector: alias('namespace.objectInspector'),
portNamespace: 'data',
modelTypesAdded: function modelTypesAdded(types) {
var _this = this;
var typesToSend = undefined;
typesToSend = types.map(function (type) {
return _this.wrapType(type);
});
this.sendMessage('modelTypesAdded', {
modelTypes: typesToSend
});
},
modelTypesUpdated: function modelTypesUpdated(types) {
var _this2 = this;
var typesToSend = types.map(function (type) {
return _this2.wrapType(type);
});
this.sendMessage('modelTypesUpdated', {
modelTypes: typesToSend
});
},
wrapType: function wrapType(type) {
var objectId = guidFor(type.object);
this.sentTypes[objectId] = type;
return {
columns: type.columns,
count: type.count,
name: type.name,
objectId: objectId
};
},
recordsAdded: function recordsAdded(recordsReceived) {
var _this3 = this;
var records = undefined;
records = recordsReceived.map(function (record) {
return _this3.wrapRecord(record);
});
this.sendMessage('recordsAdded', {
records: records
});
},
recordsUpdated: function recordsUpdated(recordsReceived) {
var _this4 = this;
var records = recordsReceived.map(function (record) {
return _this4.wrapRecord(record);
});
this.sendMessage('recordsUpdated', {
records: records
});
},
recordsRemoved: function recordsRemoved(idx, count) {
this.sendMessage('recordsRemoved', {
index: idx,
count: count
});
},
wrapRecord: function wrapRecord(record) {
var objectId = guidFor(record.object);
var columnValues = {};
var searchKeywords = [];
this.sentRecords[objectId] = record;
// make objects clonable
for (var i in record.columnValues) {
columnValues[i] = this.get('objectInspector').inspect(record.columnValues[i]);
}
// make sure keywords can be searched and clonable
searchKeywords = A(record.searchKeywords).filter(function (keyword) {
return typeof keyword === 'string' || typeof keyword === 'number';
});
return {
columnValues: columnValues,
searchKeywords: searchKeywords,
filterValues: record.filterValues,
color: record.color,
objectId: objectId
};
},
releaseTypes: function releaseTypes() {
if (this.releaseTypesMethod) {
this.releaseTypesMethod();
this.releaseTypesMethod = null;
this.sentTypes = {};
}
},
releaseRecords: function releaseRecords() {
if (this.releaseRecordsMethod) {
this.releaseRecordsMethod();
this.releaseRecordsMethod = null;
this.sentRecords = {};
}
},
willDestroy: function willDestroy() {
this._super();
this.releaseRecords();
this.releaseTypes();
},
messages: {
checkAdapter: function checkAdapter() {
this.sendMessage('hasAdapter', { hasAdapter: !!this.get('adapter') });
},
getModelTypes: function getModelTypes() {
var _this5 = this;
this.releaseTypes();
this.releaseTypesMethod = this.get('adapter').watchModelTypes(function (types) {
_this5.modelTypesAdded(types);
}, function (types) {
_this5.modelTypesUpdated(types);
});
},
releaseModelTypes: function releaseModelTypes() {
this.releaseTypes();
},
getRecords: function getRecords(message) {
var _this6 = this,
_arguments = arguments;
var type = this.sentTypes[message.objectId];
this.releaseRecords();
var typeOrName = undefined;
if (this.get('adapter.acceptsModelName')) {
// Ember >= 1.3
typeOrName = type.name;
} else {
// support for legacy Ember < 1.3
typeOrName = type.object;
}
var releaseMethod = this.get('adapter').watchRecords(typeOrName, function (recordsReceived) {
_this6.recordsAdded(recordsReceived);
}, function (recordsUpdated) {
_this6.recordsUpdated(recordsUpdated);
}, function () {
_this6.recordsRemoved.apply(_this6, _arguments);
});
this.releaseRecordsMethod = releaseMethod;
},
releaseRecords: function releaseRecords() {
this.releaseRecords();
},
inspectModel: function inspectModel(message) {
this.get('objectInspector').sendObject(this.sentRecords[message.objectId].object);
},
getFilters: function getFilters() {
this.sendMessage('filters', {
filters: this.get('adapter').getFilters()
});
}
}
});
});
'use strict';
define('ember-debug/deprecation-debug', ['exports', 'ember-debug/mixins/port-mixin', 'ember-debug/libs/source-map'], function (exports, PortMixin, SourceMap) {
'use strict';
var Ember = window.Ember;
var EmberObject = Ember.Object;
var computed = Ember.computed;
var guidFor = Ember.guidFor;
var run = Ember.run;
var RSVP = Ember.RSVP;
var A = Ember.A;
var resolve = RSVP.resolve;
var all = RSVP.all;
var oneWay = computed.oneWay;
exports['default'] = EmberObject.extend(PortMixin['default'], {
portNamespace: 'deprecation',
port: oneWay('namespace.port').readOnly(),
adapter: oneWay('port.adapter').readOnly(),
deprecations: computed(function () {
return A();
}),
groupedDeprecations: computed(function () {
return {};
}),
deprecationsToSend: computed(function () {
return A();
}),
sourceMap: computed(function () {
return SourceMap['default'].create();
}),
emberCliConfig: oneWay('namespace.generalDebug.emberCliConfig').readOnly(),
init: function init() {
this._super();
this.replaceDeprecate();
},
/**
* Checks if ember-cli and looks for source maps.
*/
fetchSourceMap: function fetchSourceMap(stackStr) {
var _this = this;
if (this.get('emberCliConfig') && this.get('emberCliConfig.environment') === 'development') {
return this.get('sourceMap').map(stackStr).then(function (mapped) {
if (mapped && mapped.length > 0) {
var source = mapped.find(function (item) {
return item.source && !!item.source.match(new RegExp(_this.get('emberCliConfig.modulePrefix')));
});
if (source) {
source.found = true;
} else {
source = mapped.get('firstObject');
source.found = false;
}
return source;
}
});
} else {
return resolve(null, 'ember-inspector');
}
},
sendPending: function sendPending() {
var _this2 = this;
var deprecations = A();
var promises = all(this.get('deprecationsToSend').map(function (deprecation) {
var obj = undefined;
var promise = resolve(undefined, 'ember-inspector');
var grouped = _this2.get('groupedDeprecations');
_this2.get('deprecations').pushObject(deprecation);
var id = guidFor(deprecation.message);
obj = grouped[id];
if (obj) {
obj.count++;
obj.url = obj.url || deprecation.url;
} else {
obj = deprecation;
obj.count = 1;
obj.id = id;
obj.sources = A();
grouped[id] = obj;
}
var found = obj.sources.findBy('stackStr', deprecation.stackStr);
if (!found) {
(function () {
var stackStr = deprecation.stackStr;
promise = _this2.fetchSourceMap(stackStr).then(function (map) {
obj.sources.pushObject({
map: map,
stackStr: stackStr
});
if (map) {
obj.hasSourceMap = true;
}
}, null, 'ember-inspector');
})();
}
return promise.then(function () {
delete obj.stackStr;
deprecations.addObject(obj);
});
}));
promises.then(function () {
_this2.sendMessage('deprecationsAdded', { deprecations: deprecations });
_this2.get('deprecationsToSend').clear();
_this2.sendCount();
}, null, 'ember-inspector');
},
sendCount: function sendCount() {
this.sendMessage('count', {
count: this.get('deprecations.length') + this.get('deprecationsToSend.length')
});
},
messages: {
watch: function watch() {
this._watching = true;
var grouped = this.get('groupedDeprecations');
var deprecations = [];
for (var i in grouped) {
if (!grouped.hasOwnProperty(i)) {
continue;
}
deprecations.push(grouped[i]);
}
this.sendMessage('deprecationsAdded', {
deprecations: deprecations
});
this.sendPending();
},
sendStackTraces: function sendStackTraces(message) {
var _this3 = this;
var deprecation = message.deprecation;
deprecation.sources.forEach(function (source) {
var stack = source.stackStr;
stack = stack.split('\n');
stack.unshift('Ember Inspector (Deprecation Trace): ' + (deprecation.message || ''));
_this3.get('adapter').log(stack.join('\n'));
});
},
getCount: function getCount() {
this.sendCount();
},
clear: function clear() {
run.cancel(this.debounce);
this.get('deprecations').clear();
this.set('groupedDeprecations', {});
this.sendCount();
},
release: function release() {
this._watching = false;
}
},
willDestroy: function willDestroy() {
Ember.deprecate = this.originalDeprecate;
this.originalDeprecate = null;
run.cancel(this.debounce);
this._super();
},
replaceDeprecate: function replaceDeprecate() {
var self = this;
this.originalDeprecate = Ember.deprecate;
Ember.deprecate = function (message, test, options) {
/* global __fail__*/
// Code taken from https://github.com/emberjs/ember.js/blob/master/packages/ember-debug/lib/main.js
var noDeprecation = undefined;
if (typeof test === 'function' && !EmberObject.detect(test)) {
// try/catch to support old Ember versions
try {
noDeprecation = test();
} catch (e) {
noDeprecation = true;
}
} else {
noDeprecation = test;
}
if (noDeprecation) {
return;
}
var error = undefined;
// When using new Error, we can't do the arguments check for Chrome. Alternatives are welcome
try {
__fail__.fail();
} catch (e) {
error = e;
}
var stack = undefined;
var stackStr = '';
if (error.stack) {
// var stack;
if (error['arguments']) {
// Chrome
stack = error.stack.replace(/^\s+at\s+/gm, '').replace(/^([^\(]+?)([\n$])/gm, '{anonymous}($1)$2').replace(/^Object.<anonymous>\s*\(([^\)]+)\)/gm, '{anonymous}($1)').split('\n');
stack.shift();
} else {
// Firefox
stack = error.stack.replace(/(?:\n@:0)?\s+$/m, '').replace(/^\(/gm, '{anonymous}(').split('\n');
}
stackStr = "\n " + stack.slice(2).join("\n ");
}
var url = undefined;
if (arguments.length === 3 && options && typeof options === 'object') {
url = options.url;
}
var deprecation = {
message: message,
stackStr: stackStr,
url: url
};
self.get('deprecationsToSend').pushObject(deprecation);
run.cancel(self.debounce);
if (self._watching) {
self.debounce = run.debounce(self, 'sendPending', 100);
} else {
self.debounce = run.debounce(self, 'sendCount', 100);
}
if (!self._warned) {
self.get("adapter").warn("Deprecations were detected, see the Ember Inspector deprecations tab for more details.");
self._warned = true;
}
};
}
});
});
'use strict';
define('ember-debug/general-debug', ['exports', 'ember-debug/mixins/port-mixin'], function (exports, PortMixin) {
'use strict';
/* eslint no-empty:0 */
var Ember = window.Ember;
var $ = Ember.$;
var computed = Ember.computed;
var EmberObject = Ember.Object;
var A = Ember.A;
var libraries = Ember.libraries;
var oneWay = computed.oneWay;
var GeneralDebug = EmberObject.extend(PortMixin['default'], {
namespace: null,
port: oneWay('namespace.port').readOnly(),
application: oneWay('namespace.application').readOnly(),
promiseDebug: oneWay('namespace.promiseDebug').readOnly(),
portNamespace: 'general',
// Keep an eye on https://github.com/ember-cli/ember-cli/issues/3045
emberCliConfig: computed(function () {
var config = undefined;
$('meta[name]').each(function () {
var meta = $(this);
var match = meta.attr('name').match(/environment$/);
if (match) {
try {
/* global unescape */
config = JSON.parse(unescape(meta.attr('content')));
return false;
} catch (e) {}
}
});
return config;
}),
sendBooted: function sendBooted() {
this.sendMessage('applicationBooted', {
booted: this.get('application.__inspector__booted')
});
},
sendReset: function sendReset() {
this.sendMessage('reset', {
reset: true
});
},
messages: {
applicationBooted: function applicationBooted() {
this.sendBooted();
},
getLibraries: function getLibraries() {
// Ember has changed where the array of libraries is located.
// In older versions, `Ember.libraries` was the array itself,
// but now it's found under _registry.
if (libraries._registry) {
libraries = libraries._registry;
}
this.sendMessage('libraries', { libraries: arrayize(libraries) });
},
refresh: function refresh() {
window.location.reload();
}
}
});
function arrayize(enumerable) {
return A(enumerable).map(function (item) {
return item;
});
}
exports['default'] = GeneralDebug;
});
'use strict';
define('ember-debug/libs/promise-assembler', ['exports', 'ember-debug/models/promise'], function (exports, Promise) {
'use strict';
/**
Original implementation and the idea behind the `PromiseAssembler`,
`Promise` model, and other work related to promise inspection was done
by Stefan Penner (@stefanpenner) thanks to McGraw Hill Education (@mhelabs)
and Yapp Labs (@yapplabs).
*/
var Ember = window.Ember;
var EmberObject = Ember.Object;
var Evented = Ember.Evented;
var A = Ember.A;
var computed = Ember.computed;
var RSVP = Ember.RSVP;
var copy = Ember.copy;
var isNone = Ember.isNone;
var PromiseAssembler = EmberObject.extend(Evented, {
// RSVP lib to debug
RSVP: RSVP,
all: computed(function () {
return A();
}),
promiseIndex: computed(function () {
return {};
}),
// injected on creation
promiseDebug: null,
start: function start() {
var _this = this;
this.RSVP.configure('instrument', true);
this.promiseChained = function (e) {
chain.call(_this, e);
};
this.promiseRejected = function (e) {
reject.call(_this, e);
};
this.promiseFulfilled = function (e) {
fulfill.call(_this, e);
};
this.promiseCreated = function (e) {
create.bind(_this)(e);
};
this.RSVP.on('chained', this.promiseChained);
this.RSVP.on('rejected', this.promiseRejected);
this.RSVP.on('fulfilled', this.promiseFulfilled);
this.RSVP.on('created', this.promiseCreated);
},
stop: function stop() {
this.RSVP.configure('instrument', false);
this.RSVP.off('chained', this.promiseChained);
this.RSVP.off('rejected', this.promiseRejected);
this.RSVP.off('fulfilled', this.promiseFulfilled);
this.RSVP.off('created', this.promiseCreated);
this.get('all').forEach(function (item) {
item.destroy();
});
this.set('all', A());
this.set('promiseIndex', {});
this.promiseChained = null;
this.promiseRejected = null;
this.promiseFulfilled = null;
this.promiseCreated = null;
},
willDestroy: function willDestroy() {
this.stop();
this._super();
},
createPromise: function createPromise(props) {
var promise = Promise['default'].create(props);
var index = this.get('all.length');
this.get('all').pushObject(promise);
this.get('promiseIndex')[promise.get('guid')] = index;
return promise;
},
find: function find(guid) {
if (guid) {
var index = this.get('promiseIndex')[guid];
if (index !== undefined) {
return this.get('all').objectAt(index);
}
} else {
return this.get('all');
}
},
findOrCreate: function findOrCreate(guid) {
return this.find(guid) || this.createPromise({
guid: guid
});
},
updateOrCreate: function updateOrCreate(guid, properties) {
var entry = this.find(guid);
if (entry) {
entry.setProperties(properties);
} else {
properties = copy(properties);
properties.guid = guid;
entry = this.createPromise(properties);
}
return entry;
}
});
exports['default'] = PromiseAssembler;
PromiseAssembler.reopenClass({
supported: function supported() {
return !!RSVP.on;
}
});
var fulfill = function fulfill(event) {
var guid = event.guid;
var promise = this.updateOrCreate(guid, {
label: event.label,
settledAt: event.timeStamp,
state: 'fulfilled',
value: event.detail
});
this.trigger('fulfilled', {
promise: promise
});
};
var reject = function reject(event) {
var guid = event.guid;
var promise = this.updateOrCreate(guid, {
label: event.label,
settledAt: event.timeStamp,
state: 'rejected',
reason: event.detail
});
this.trigger('rejected', {
promise: promise
});
};
function chain(event) {
/*jshint validthis:true */
var guid = event.guid;
var promise = this.updateOrCreate(guid, {
label: event.label,
chainedAt: event.timeStamp
});
var children = promise.get('children');
var child = this.findOrCreate(event.childGuid);
child.set('parent', promise);
children.pushObject(child);
this.trigger('chained', {
promise: promise,
child: child
});
}
function create(event) {
/*jshint validthis:true */
var guid = event.guid;
var promise = this.updateOrCreate(guid, {
label: event.label,
createdAt: event.timeStamp,
stack: event.stack
});
// todo fix ordering
if (isNone(promise.get('state'))) {
promise.set('state', 'created');
}
this.trigger('created', {
promise: promise
});
}
});
'use strict';
define('ember-debug/libs/source-map', ['exports'], function (exports) {
'use strict';
/**
* Used to map a stack trace to its original sources.
* A lot of the code is inspired by/taken from
* https://github.com/evanw/node-source-map-support
*/
var Ember = window.Ember;
var EmberObject = Ember.Object;
var A = Ember.A;
var computed = Ember.computed;
var _Ember$RSVP = Ember.RSVP;
var resolve = _Ember$RSVP.resolve;
var Promise = _Ember$RSVP.Promise;
var notFoundError = new Error('Source map url not found');
exports['default'] = EmberObject.extend({
_lastPromise: computed(function () {
return resolve(undefined, 'ember-inspector');
}),
/**
* Returns a promise that resolves to an array
* of mapped sourcew.
*
* @param {String} stack The stack trace
* @return {RSVP.Promise}
*/
map: function map(stack) {
var _this = this;
var parsed = A(fromStackProperty(stack));
var array = A();
var lastPromise = null;
parsed.forEach(function (item) {
lastPromise = _this.get('_lastPromise').then(function () {
return _this.getSourceMap(item.url);
}, null, 'ember-inspector').then(function (smc) {
if (smc) {
var source = smc.originalPositionFor({
line: item.line,
column: item.column
});
source.fullSource = relativeToAbsolute(item.url, source.source);
array.push(source);
return array;
}
}, null, 'ember-inspector');
_this.set('_lastPromise', lastPromise);
});
return resolve(lastPromise, 'ember-inspector')['catch'](function (e) {
if (e === notFoundError) {
return null;
}
throw e;
}, 'ember-inspector');
},
sourceMapCache: computed(function () {
return {};
}),
getSourceMap: function getSourceMap(url) {
var sourceMaps = this.get('sourceMapCache');
if (sourceMaps[url] !== undefined) {
return resolve(sourceMaps[url], 'ember-inspector');
}
return retrieveSourceMap(url).then(function (response) {
if (response) {
var map = JSON.parse(response.map);
var sm = new window.sourceMap.SourceMapConsumer(map);
sourceMaps[url] = sm;
return sm;
}
}, function () {
sourceMaps[url] = null;
});
}
});
function retrieveSourceMap(source) {
var mapURL = undefined;
return retrieveSourceMapURL(source).then(function (sourceMappingURL) {
if (!sourceMappingURL) {
throw notFoundError;
}
// Support source map URLs relative to the source URL
mapURL = relativeToAbsolute(source, sourceMappingURL);
return mapURL;
}).then(retrieveFile).then(function (sourceMapData) {
if (!sourceMapData) {
return null;
}
return {
url: mapURL,
map: sourceMapData
};
});
}
function relativeToAbsolute(file, url) {
if (!file) {
return url;
}
var dir = file.split('/');
dir.pop();
dir.push(url);
return dir.join('/');
}
function retrieveFile(source) {
return new Promise(function (resolve) {
var xhr = new XMLHttpRequest();
xhr.onload = function () {
resolve(this.responseText, 'ember-inspector');
};
xhr.open('GET', source, true);
xhr.send();
}, 'ember-inspector');
}
function retrieveSourceMapURL(source) {
return retrieveFile(source).then(function (fileData) {
var match = /\/\/[#@]\s*sourceMappingURL=(.*)\s*$/m.exec(fileData);
if (!match) {
return null;
}
return match[1];
});
}
var UNKNOWN_FUNCTION = "<unknown>";
// Taken from https://github.com/errorception/browser-stack-parser/
function fromStackProperty(stackString) {
var chrome = /^\s*at (?:((?:\[object object\])?\S+(?: \[as \S+\])?) )?\(?((?:file|http|https):.*?):(\d+)(?::(\d+))?\)?\s*$/i;
var gecko = /^\s*(\S*)(?:\((.*?)\))?@((?:file|http|https).*?):(\d+)(?::(\d+))?\s*$/i;
var lines = stackString.split('\n');
var stack = [];
var parts = undefined;
for (var i = 0, j = lines.length; i < j; ++i) {
if (parts = gecko.exec(lines[i])) {
stack.push({
url: parts[3],
func: parts[1] || UNKNOWN_FUNCTION,
args: parts[2] ? parts[2].split(',') : '',
line: +parts[4],
column: parts[5] ? +parts[5] : null
});
} else if (parts = chrome.exec(lines[i])) {
stack.push({
url: parts[2],
func: parts[1] || UNKNOWN_FUNCTION,
line: +parts[3],
column: parts[4] ? +parts[4] : null
});
}
}
return stack.length ? stack : null;
}
});
'use strict';
define('ember-debug/main', ['exports', 'ember-debug/adapters/basic', 'ember-debug/port', 'ember-debug/object-inspector', 'ember-debug/general-debug', 'ember-debug/render-debug', 'ember-debug/view-debug', 'ember-debug/route-debug', 'ember-debug/data-debug', 'ember-debug/promise-debug', 'ember-debug/container-debug', 'ember-debug/deprecation-debug', 'ember-debug/services/session'], function (exports, BasicAdapter, Port, ObjectInspector, GeneralDebug, RenderDebug, ViewDebug, RouteDebug, DataDebug, PromiseDebug, ContainerDebug, DeprecationDebug, Session) {
'use strict';
var Ember = window.Ember;
var EmberObject = Ember.Object;
var run = Ember.run;
var Application = Ember.Application;
var namespaces = Ember.namespaces;
var EmberDebug = EmberObject.extend({
application: null,
started: false,
Port: Port['default'],
Adapter: BasicAdapter['default'],
start: function start($keepAdapter) {
if (this.get('started')) {
this.reset($keepAdapter);
return;
}
this.set('started', true);
if (!this.get('application')) {
this.set('application', getApplication());
}
this.reset();
this.get("adapter").debug("Ember Inspector Active");
},
destroyContainer: function destroyContainer() {
var _this = this;
if (this.get('generalDebug')) {
this.get('generalDebug').sendReset();
}
['dataDebug', 'viewDebug', 'routeDebug', 'generalDebug', 'renderDebug', 'promiseDebug', 'containerDebug', 'deprecationDebug', 'objectInspector', 'session'].forEach(function (prop) {
var handler = _this.get(prop);
if (handler) {
run(handler, 'destroy');
_this.set(prop, null);
}
});
},
startModule: function startModule(prop, Module) {
this.set(prop, Module.create({ namespace: this }));
},
willDestroy: function willDestroy() {
this.destroyContainer();
this._super.apply(this, arguments);
},
reset: function reset($keepAdapter) {
var _this2 = this;
this.destroyContainer();
run(function () {
// Adapters don't have state depending on the application itself.
// They also maintain connections with the inspector which we will
// lose if we destroy.
if (!_this2.get('adapter') || !$keepAdapter) {
_this2.startModule('adapter', _this2.Adapter);
}
if (!_this2.get('port') || !$keepAdapter) {
_this2.startModule('port', _this2.Port);
}
_this2.startModule('session', Session['default']);
_this2.startModule('generalDebug', GeneralDebug['default']);
_this2.startModule('renderDebug', RenderDebug['default']);
_this2.startModule('objectInspector', ObjectInspector['default']);
_this2.startModule('routeDebug', RouteDebug['default']);
_this2.startModule('viewDebug', ViewDebug['default']);
_this2.startModule('dataDebug', DataDebug['default']);
_this2.startModule('promiseDebug', PromiseDebug['default']);
_this2.startModule('containerDebug', ContainerDebug['default']);
_this2.startModule('deprecationDebug', DeprecationDebug['default']);
_this2.generalDebug.sendBooted();
_this2.viewDebug.sendTree();
});
},
inspect: function inspect(obj) {
this.get('objectInspector').sendObject(obj);
this.get('adapter').log('Sent to the Object Inspector');
return obj;
}
}).create();
function getApplication() {
var namespaces = Namespace.NAMESPACES;
var application = undefined;
namespaces.forEach(function (namespace) {
if (namespace instanceof Application) {
application = namespace;
return false;
}
});
return application;
}
exports['default'] = EmberDebug;
});
'use strict';
define('ember-debug/mixins/port-mixin', ['exports'], function (exports) {
'use strict';
var Ember = window.Ember;
var Mixin = Ember.Mixin;
exports['default'] = Mixin.create({
port: null,
messages: {},
portNamespace: null,
init: function init() {
this.setupPortListeners();
},
willDestroy: function willDestroy() {
this.removePortListeners();
},
sendMessage: function sendMessage(name, message) {
this.get('port').send(this.messageName(name), message);
},
setupPortListeners: function setupPortListeners() {
var port = this.get('port');
var messages = this.get('messages');
for (var _name in messages) {
if (messages.hasOwnProperty(_name)) {
port.on(this.messageName(_name), this, messages[_name]);
}
}
},
removePortListeners: function removePortListeners() {
var port = this.get('port');
var messages = this.get('messages');
for (var _name2 in messages) {
if (messages.hasOwnProperty(_name2)) {
port.off(this.messageName(_name2), this, messages[_name2]);
}
}
},
messageName: function messageName(name) {
var messageName = name;
if (this.get('portNamespace')) {
messageName = this.get('portNamespace') + ':' + messageName;
}
return messageName;
}
});
});
'use strict';
define('ember-debug/models/profile-manager', ['exports', 'ember-debug/models/profile-node'], function (exports, ProfileNode) {
'use strict';
var Ember = window.Ember;
var scheduleOnce = Ember.run.scheduleOnce;
/**
* A class for keeping track of active rendering profiles as a list.
*/
var ProfileManager = function ProfileManager() {
this.profiles = [];
this.current = null;
this.currentSet = [];
this._profilesAddedCallbacks = [];
};
ProfileManager.prototype = {
began: function began(timestamp, payload, now) {
return this.wrapForErrors(this, function () {
this.current = new ProfileNode['default'](timestamp, payload, this.current, now);
return this.current;
});
},
ended: function ended(timestamp, payload, profileNode) {
if (payload.exception) {
throw payload.exception;
}
return this.wrapForErrors(this, function () {
this.current = profileNode.parent;
profileNode.finish(timestamp);
// Are we done profiling an entire tree?
if (!this.current) {
this.currentSet.push(profileNode);
// If so, schedule an update of the profile list
scheduleOnce('afterRender', this, this._profilesFinished);
}
});
},
wrapForErrors: function wrapForErrors(context, callback) {
return callback.call(context);
},
clearProfiles: function clearProfiles() {
this.profiles.length = 0;
},
_profilesFinished: function _profilesFinished() {
return this.wrapForErrors(this, function () {
var firstNode = this.currentSet[0];
var parent