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,528 lines (1,483 loc) • 385 kB
JavaScript
(function loadEmberDebugInWebpage() {
const waitForEmberLoad = new Promise((resolve) => {
if (window.requireModule) {
const has =
window.requireModule.has ||
function has(id) {
return !!(
window.requireModule.entries[id] ||
window.requireModule.entries[id + '/index']
);
};
if (has('ember')) {
return resolve();
}
}
/**
* NOTE: if the above (for some reason) fails and the consuming app has
* deprecation-workflow's throwOnUnhandled: true
* or set `ember-global`'s handler to 'throw'
* and is using at least `ember-source@3.27`
*
* this will throw an exception in the consuming project
*/
if (window.Ember) return resolve();
window.addEventListener('Ember', resolve, { once: true });
});
waitForEmberLoad.then(() => (function(adapter, env) {
/* eslint-disable */
let define = window.define && ((...args) => window.define(...args)),
exports = undefined,
module = undefined,
require = window.requireModule,
requireModule = window.requireModule;
/* eslint-enable */
if (typeof define !== 'function' || typeof requireModule !== 'function') {
(function () {
let registry = {},
seen = {};
define = function (name, deps, callback) {
if (arguments.length < 3) {
callback = deps;
deps = [];
}
registry[name] = { deps, callback };
};
requireModule = function (name) {
if (seen[name]) {
return seen[name];
}
let mod = registry[name];
if (!mod) {
throw new Error(`Module: '${name}' not found.`);
}
seen[name] = {};
let deps = mod.deps;
let callback = mod.callback;
let reified = [];
let exports;
for (let i = 0, l = deps.length; i < l; i++) {
if (deps[i] === 'exports') {
reified.push((exports = {}));
} else {
reified.push(requireModule(deps[i]));
}
}
let value = callback.apply(this, reified);
seen[name] = exports || value;
return seen[name];
};
define.registry = registry;
define.seen = seen;
})();
}
define("ember-debug/adapters/basic", ["exports", "ember-debug/utils/on-ready", "ember-debug/utils/base-object"], function (_exports, _onReady, _baseObject) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.default = void 0;
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /* eslint no-console: 0 */
class BasicAdapter extends _baseObject.default {
constructor(...args) {
super(...args);
_defineProperty(this, "_isReady", false);
_defineProperty(this, "_pendingMessages", []);
}
init() {
Promise.resolve(this.connect()).then(() => {
this.onConnectionReady();
}, null);
this._messageCallbacks = [];
}
/**
* Uses the current build's config module to determine
* the environment.
*
* @property environment
* @type {String}
*/
get environment() {
if (!this.__environment) {
this.__environment = requireModule('ember-debug/config')['default'].environment;
}
return this.__environment;
}
debug() {
return console.debug(...arguments);
}
log() {
return console.log(...arguments);
}
/**
* A wrapper for `console.warn`.
*
* @method warn
*/
warn() {
return console.warn(...arguments);
}
/**
Used to send messages to EmberExtension
@param {Object} type the message to the send
*/
sendMessage( /* options */) {}
/**
Register functions to be called
when a message from EmberExtension is received
@param {Function} callback
*/
onMessageReceived(callback) {
this._messageCallbacks.push(callback);
}
/**
Inspect a specific DOM node. This usually
means using the current environment's tools
to inspect the node in the DOM.
For example, in chrome, `inspect(node)`
will open the Elements tab in dev tools
and highlight the DOM node.
@param {Node} node
*/
inspectNode( /* node */) {}
_messageReceived(message) {
this._messageCallbacks.forEach(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(error) {
if (this.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() {
return new Promise((resolve, reject) => {
(0, _onReady.onReady)(() => {
if (this.isDestroyed) {
reject();
}
this.interval = setInterval(() => {
if (document.documentElement.dataset.emberExtension) {
clearInterval(this.interval);
resolve();
}
}, 10);
});
});
}
willDestroy() {
super.willDestroy();
clearInterval(this.interval);
}
send(options) {
if (this._isReady) {
this.sendMessage(...arguments);
} else {
this._pendingMessages.push(options);
}
}
/**
Called when the connection is set up.
Flushes the pending messages.
*/
onConnectionReady() {
// Flush pending messages
const messages = this._pendingMessages;
messages.forEach(options => this.sendMessage(options));
messages.length = 0;
this._isReady = true;
}
}
_exports.default = BasicAdapter;
});
define("ember-debug/adapters/bookmarklet", ["exports", "ember-debug/adapters/basic"], function (_exports, _basic) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.default = void 0;
class _default extends _basic.default {
init() {
super.init();
this._listen();
}
sendMessage(options) {
options = options || {};
window.emberInspector.w.postMessage(options, window.emberInspector.url);
}
_listen() {
window.addEventListener('message', e => {
if (e.origin !== window.emberInspector.url) {
return;
}
const message = e.data;
if (message.from === 'devtools') {
this._messageReceived(message);
}
});
window.onunload = () => {
this.sendMessage({
unloading: true
});
};
}
}
_exports.default = _default;
});
define("ember-debug/adapters/chrome", ["exports", "ember-debug/adapters/web-extension"], function (_exports, _webExtension) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.default = void 0;
class _default extends _webExtension.default {}
_exports.default = _default;
});
define("ember-debug/adapters/firefox", ["exports", "ember-debug/adapters/web-extension"], function (_exports, _webExtension) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.default = void 0;
/* eslint no-empty:0 */
class _default extends _webExtension.default {
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 {
super.debug(...arguments);
} catch (e) {}
}
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 {
super.log(...arguments);
} catch (e) {}
}
}
_exports.default = _default;
});
define("ember-debug/adapters/web-extension", ["exports", "ember-debug/adapters/basic", "ember-debug/utils/type-check", "ember-debug/utils/ember", "ember-debug/utils/ember/runloop"], function (_exports, _basic, _typeCheck, _ember, _runloop) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.default = void 0;
const {
isArray
} = Array;
const {
keys
} = Object;
class _default extends _basic.default {
init() {
this._channel = new MessageChannel();
this._chromePort = this._channel?.port1;
super.init();
}
connect() {
const channel = this._channel;
return super.connect().then(() => {
window.postMessage('debugger-client', '*', [channel.port2]);
this._listen();
}, null);
}
sendMessage(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.
options = deepClone(options);
this._chromePort.postMessage(options);
}
/**
* Open the devtools "Elements" and select an DOM node.
*
* @param {Node} node The DOM node to select
*/
inspectNode(node) {
// NOTE:
//
// Basically, we are just trying to call `inspect(node)` here.
// However, `inspect` is a special function that is in the global
// scope but not on the global object (i.e. `window.inspect`) does
// not work. This sometimes causes problems, because, e.g. if the
// page has a div with the ID `inspect`, `window.inspect` will point
// to that div and shadow the "global" inspect function with no way
// to get it back. That causes "`inspect` is not a function" errors.
//
// As it turns out, however, when the extension page evals, the
// `inspect` function does not get shadowed. So, we can ask the
// inspector extension page to call that function for us, using
// `inspected.Window.eval('inspect(node)')`.
//
// However, since we cannot just send the DOM node directly to the
// extension, we will have to store it in a temporary global variable
// so that the extension can find it.
let name = `__EMBER_INSPECTOR_${(Math.random() * 100000000).toFixed(0)}`;
window[name] = node;
this.namespace.port.send('view:inspectDOMNode', {
name
});
}
_listen() {
let chromePort = this._chromePort;
chromePort.addEventListener('message', event => {
const message = event.data;
// We should generally not be run-wrapping here. Starting a runloop in
// ember-debug will cause the inspected app to revalidate/rerender. We
// are generally not intending to cause changes to the rendered output
// of the app, so this is generally unnecessary, and in big apps this
// could be quite slow. There is nothing special about the `view:*`
// messages – I (GC) just happened to have reviewed all of them recently
// and can be quite sure that they don't need the runloop. We should
// audit the rest of them and see if we can remove the else branch. I
// think we most likely can. In the limited cases (if any) where the
// runloop is needed, the callback code should just do the wrapping
// themselves.
if (message.type.startsWith('view:')) {
this._messageReceived(message);
} else {
(0, _runloop.run)(() => {
this._messageReceived(message);
});
}
});
chromePort.start();
}
}
// On some older Ember version `Ember.ENV.EXTEND_PROTOTYPES` is not
// guarenteed to be an object. While this code only support 3.4+ (all
// of which normalizes `EXTEND_PROTOTYPES` for us), startup-wrapper.js
// eagerly require/load ember-debug modules, which ultimately causes
// this top-level code to run, even we are going to pick a different
// adapter later. See GH #1114.
_exports.default = _default;
const HAS_ARRAY_PROTOTYPE_EXTENSIONS = (() => {
try {
return _ember.default.ENV.EXTEND_PROTOTYPES.Array === true;
} catch (e) {
return false;
}
})();
let deepClone;
if (HAS_ARRAY_PROTOTYPE_EXTENSIONS) {
deepClone = function deepClone(item) {
return item;
};
} else {
/**
* 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}
*/
deepClone = function deepClone(item) {
let clone = item;
if (isArray(item)) {
clone = new Array(item.length);
item.forEach((child, key) => {
clone[key] = deepClone(child);
});
} else if (item && (0, _typeCheck.typeOf)(item) === 'object') {
clone = {};
keys(item).forEach(key => {
clone[key] = deepClone(item[key]);
});
}
return clone;
};
}
});
define("ember-debug/adapters/websocket", ["exports", "ember-debug/adapters/basic", "ember-debug/utils/on-ready", "ember-debug/utils/ember/runloop"], function (_exports, _basic, _onReady, _runloop) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.default = void 0;
class _default extends _basic.default {
sendMessage(options = {}) {
this.socket.emit('emberInspectorMessage', options);
}
get socket() {
return window.EMBER_INSPECTOR_CONFIG.remoteDebugSocket;
}
_listen() {
this.socket.on('emberInspectorMessage', message => {
// We should generally not be run-wrapping here. Starting a runloop in
// ember-debug will cause the inspected app to revalidate/rerender. We
// are generally not intending to cause changes to the rendered output
// of the app, so this is generally unnecessary, and in big apps this
// could be quite slow. There is nothing special about the `view:*`
// messages – I (GC) just happened to have reviewed all of them recently
// and can be quite sure that they don't need the runloop. We should
// audit the rest of them and see if we can remove the else branch. I
// think we most likely can. In the limited cases (if any) where the
// runloop is needed, the callback code should just do the wrapping
// themselves.
if (message.type.startsWith('view:')) {
this._messageReceived(message);
} else {
(0, _runloop.run)(() => {
this._messageReceived(message);
});
}
});
}
_disconnect() {
this.socket.removeAllListeners('emberInspectorMessage');
}
connect() {
return new Promise((resolve, reject) => {
(0, _onReady.onReady)(() => {
if (this.isDestroyed) {
reject();
}
const EMBER_INSPECTOR_CONFIG = window.EMBER_INSPECTOR_CONFIG;
if (typeof EMBER_INSPECTOR_CONFIG === 'object' && EMBER_INSPECTOR_CONFIG.remoteDebugSocket) {
resolve();
}
});
}).then(() => {
this._listen();
});
}
willDestroy() {
this._disconnect();
}
}
_exports.default = _default;
});
define("ember-debug/container-debug", ["exports", "ember-debug/debug-port"], function (_exports, _debugPort) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.default = void 0;
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class _class extends _debugPort.default {
constructor(...args) {
super(...args);
_defineProperty(this, "TYPES_TO_SKIP", ['component-lookup', 'container-debug-adapter', 'resolver-for-debugging', 'event_dispatcher']);
}
get objectInspector() {
return this.namespace?.objectInspector;
}
get container() {
return this.namespace?.owner?.__container__;
}
typeFromKey(key) {
return key.split(':').shift();
}
nameFromKey(key) {
return key.split(':').pop();
}
shouldHide(type) {
return type[0] === '-' || this.TYPES_TO_SKIP.indexOf(type) !== -1;
}
instancesByType() {
let key;
let instancesByType = {};
let cache = this.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) {
const 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() {
let key;
let types = [];
const instancesByType = this.instancesByType();
for (key in instancesByType) {
types.push({
name: key,
count: instancesByType[key].length
});
}
return types;
}
getInstances(type) {
const instances = this.instancesByType()[type];
if (!instances) {
return null;
}
return instances.map(item => ({
name: this.nameFromKey(item.fullName),
fullName: item.fullName,
inspectable: this.objectInspector.canSend(item.instance)
}));
}
}
_exports.default = _class;
(() => {
_class.prototype.portNamespace = 'container';
_class.prototype.messages = {
getTypes() {
this.sendMessage('types', {
types: this.getTypes()
});
},
getInstances(message) {
let instances = this.getInstances(message.containerType);
if (instances) {
this.sendMessage('instances', {
instances,
status: 200
});
} else {
this.sendMessage('instances', {
status: 404
});
}
},
sendInstanceToConsole(message) {
const instance = this.container.lookup(message.name);
this.objectToConsole.sendValueToConsole(instance);
}
};
})();
});
define("ember-debug/data-debug", ["exports", "ember-debug/debug-port", "ember-debug/utils/ember/object/internals"], function (_exports, _debugPort, _internals) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.default = void 0;
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class _class extends _debugPort.default {
constructor(...args) {
super(...args);
_defineProperty(this, "releaseTypesMethod", null);
_defineProperty(this, "releaseRecordsMethod", null);
}
init() {
super.init();
this.sentTypes = {};
this.sentRecords = {};
}
/* eslint-disable ember/no-side-effects */
get adapter() {
const owner = this.namespace?.owner;
// dataAdapter:main is deprecated
let adapter = this._resolve('data-adapter:main') && owner.lookup('data-adapter:main');
// column limit is now supported at the inspector level
if (adapter) {
adapter.attributeLimit = 100;
return adapter;
}
return null;
}
/* eslint-enable ember/no-side-effects */
_resolve(name) {
const owner = this.namespace?.owner;
return owner.resolveRegistration(name);
}
get port() {
return this.namespace?.port;
}
get objectInspector() {
return this.namespace?.objectInspector;
}
modelTypesAdded(types) {
let typesToSend;
typesToSend = types.map(type => this.wrapType(type));
this.sendMessage('modelTypesAdded', {
modelTypes: typesToSend
});
}
modelTypesUpdated(types) {
let typesToSend = types.map(type => this.wrapType(type));
this.sendMessage('modelTypesUpdated', {
modelTypes: typesToSend
});
}
wrapType(type) {
const objectId = (0, _internals.guidFor)(type.object);
this.sentTypes[objectId] = type;
return {
columns: type.columns,
count: type.count,
name: type.name,
objectId
};
}
recordsAdded(recordsReceived) {
let records = recordsReceived.map(record => this.wrapRecord(record));
this.sendMessage('recordsAdded', {
records
});
}
recordsUpdated(recordsReceived) {
let records = recordsReceived.map(record => this.wrapRecord(record));
this.sendMessage('recordsUpdated', {
records
});
}
recordsRemoved(index, count) {
this.sendMessage('recordsRemoved', {
index,
count
});
}
wrapRecord(record) {
const objectId = (0, _internals.guidFor)(record.object);
let columnValues = {};
let searchKeywords = [];
this.sentRecords[objectId] = record;
// make objects clonable
for (let i in record.columnValues) {
columnValues[i] = this.objectInspector.inspect(record.columnValues[i]);
}
// make sure keywords can be searched and clonable
searchKeywords = record.searchKeywords.filter(keyword => typeof keyword === 'string' || typeof keyword === 'number');
return {
columnValues,
searchKeywords,
filterValues: record.filterValues,
color: record.color,
objectId
};
}
releaseTypes() {
if (this.releaseTypesMethod) {
this.releaseTypesMethod();
this.releaseTypesMethod = null;
this.sentTypes = {};
}
}
releaseRecords() {
if (this.releaseRecordsMethod) {
this.releaseRecordsMethod();
this.releaseRecordsMethod = null;
this.sentRecords = {};
}
}
willDestroy() {
super.willDestroy();
this.releaseRecords();
this.releaseTypes();
}
}
_exports.default = _class;
(() => {
_class.prototype.portNamespace = 'data';
_class.prototype.messages = {
checkAdapter() {
this.sendMessage('hasAdapter', {
hasAdapter: !!this.adapter
});
},
getModelTypes() {
this.modelTypesAdded([]);
this.releaseTypes();
this.releaseTypesMethod = this.adapter.watchModelTypes(types => {
this.modelTypesAdded(types);
}, types => {
this.modelTypesUpdated(types);
});
},
releaseModelTypes() {
this.releaseTypes();
},
getRecords(message) {
const type = this.sentTypes[message.objectId];
this.releaseRecords();
let typeOrName;
if (this.adapter.acceptsModelName) {
// Ember >= 1.3
typeOrName = type.name;
}
this.recordsAdded([]);
let releaseMethod = this.adapter.watchRecords(typeOrName, recordsReceived => {
this.recordsAdded(recordsReceived);
}, recordsUpdated => {
this.recordsUpdated(recordsUpdated);
}, (...args) => {
this.recordsRemoved(...args);
});
this.releaseRecordsMethod = releaseMethod;
},
releaseRecords() {
this.releaseRecords();
},
inspectModel(message) {
this.objectInspector.sendObject(this.sentRecords[message.objectId].object);
},
getFilters() {
this.sendMessage('filters', {
filters: this.adapter.getFilters()
});
}
};
})();
});
define("ember-debug/debug-port", ["exports", "ember-debug/utils/base-object"], function (_exports, _baseObject) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.default = void 0;
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
class _default extends _baseObject.default {
constructor(data) {
super(data);
_defineProperty(this, "port", null);
if (!data) {
throw new Error('need to pass data');
}
this.port = this.namespace?.port;
this.setupOrRemovePortListeners('on');
}
willDestroy() {
super.willDestroy();
this.setupOrRemovePortListeners('off');
}
sendMessage(name, message) {
if (this.isDestroyed) return;
this.port.send(this.messageName(name), message);
}
messageName(name) {
let messageName = name;
if (this.portNamespace) {
messageName = `${this.portNamespace}:${messageName}`;
}
return messageName;
}
/**
* Setup or tear down port listeners. Call on `init` and `willDestroy`
* @param {String} onOrOff 'on' or 'off' the functions to call i.e. port.on or port.off for adding or removing listeners
*/
setupOrRemovePortListeners(onOrOff) {
let port = this.port;
let messages = this.messages;
for (let name in messages) {
if (messages.hasOwnProperty(name)) {
port[onOrOff](this.messageName(name), this, messages[name]);
}
}
}
}
_exports.default = _default;
});
define("ember-debug/deprecation-debug", ["exports", "ember-debug/debug-port", "ember-debug/libs/source-map", "ember-debug/utils/ember/debug", "ember-debug/utils/ember/object/internals", "ember-debug/utils/ember/runloop"], function (_exports, _debugPort, _sourceMap, _debug, _internals, _runloop) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.default = void 0;
class _class extends _debugPort.default {
get adapter() {
return this.port?.adapter;
}
get emberCliConfig() {
return this.__emberCliConfig || this.namespace?.generalDebug.emberCliConfig;
}
set emberCliConfig(value) {
this.__emberCliConfig = value;
}
constructor(data) {
super(data);
this.deprecations = [];
this.deprecationsToSend = [];
this.groupedDeprecations = {};
this.options = {
toggleDeprecationWorkflow: false
};
this.handleDeprecations();
}
/**
* Checks if ember-cli and looks for source maps.
*/
fetchSourceMap(stackStr) {
if (this.emberCliConfig && this.emberCliConfig.environment === 'development') {
return this.sourceMap.map(stackStr).then(mapped => {
if (mapped && mapped.length > 0) {
let source = mapped.find(item => item.source && !!item.source.match(new RegExp(this.emberCliConfig.modulePrefix)));
if (source) {
source.found = true;
} else {
source = mapped.firstObject;
source.found = false;
}
return source;
}
}, null, 'ember-inspector');
} else {
return Promise.resolve(null);
}
}
sendPending() {
if (this.isDestroyed) {
return;
}
let deprecations = [];
let promises = Promise.all(this.deprecationsToSend.map(deprecation => {
let obj;
let promise = Promise.resolve(undefined);
let grouped = this.groupedDeprecations;
this.deprecations.push(deprecation);
const id = (0, _internals.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 = [];
grouped[id] = obj;
}
let found = obj.sources.find(s => s.stackStr === deprecation.stackStr);
if (!found) {
let stackStr = deprecation.stackStr;
promise = this.fetchSourceMap(stackStr).then(map => {
obj.sources.push({
map,
stackStr
});
if (map) {
obj.hasSourceMap = true;
}
}, null, 'ember-inspector');
}
return promise.then(() => {
delete obj.stackStr;
if (!deprecations.includes(obj)) {
deprecations.push(obj);
}
}, null);
}));
promises.then(() => {
this.sendMessage('deprecationsAdded', {
deprecations
});
this.deprecationsToSend.length = 0;
this.sendCount();
}, null);
}
sendCount() {
if (this.isDestroyed) {
return;
}
this.sendMessage('count', {
count: this.deprecations.length + this.deprecationsToSend.length
});
}
willDestroy() {
(0, _runloop.cancel)(this.debounce);
return super.willDestroy();
}
handleDeprecations() {
(0, _debug.registerDeprecationHandler)((message, options, next) => {
if (!this.adapter) {
next(message, options);
return;
}
/* global __fail__*/
let error;
// When using new Error, we can't do the arguments check for Chrome. Alternatives are welcome
try {
__fail__.fail();
} catch (e) {
error = e;
}
let stack;
let 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 ')}`;
}
let url;
if (options && typeof options === 'object') {
url = options.url;
}
const deprecation = {
message,
stackStr,
url
};
// For ember-debug testing we usually don't want
// to catch deprecations
if (!this.namespace?.IGNORE_DEPRECATIONS) {
this.deprecationsToSend.push(deprecation);
(0, _runloop.cancel)(this.debounce);
if (this._watching) {
this.debounce = (0, _runloop.debounce)(this, 'sendPending', 100);
} else {
this.debounce = (0, _runloop.debounce)(this, 'sendCount', 100);
}
if (!this._warned) {
this.adapter.warn('Deprecations were detected, see the Ember Inspector deprecations tab for more details.');
this._warned = true;
}
}
if (this.options.toggleDeprecationWorkflow) {
next(message, options);
}
});
}
}
_exports.default = _class;
(() => {
_class.prototype.portNamespace = 'deprecation';
_class.prototype.sourceMap = new _sourceMap.default();
_class.prototype.messages = {
watch() {
this._watching = true;
let grouped = this.groupedDeprecations;
let deprecations = [];
for (let i in grouped) {
if (!grouped.hasOwnProperty(i)) {
continue;
}
deprecations.push(grouped[i]);
}
this.sendMessage('deprecationsAdded', {
deprecations
});
this.sendPending();
},
sendStackTraces(message) {
let deprecation = message.deprecation;
deprecation.sources.forEach(source => {
let stack = source.stackStr;
stack = stack.split('\n');
stack.unshift(`Ember Inspector (Deprecation Trace): ${deprecation.message || ''}`);
this.adapter.log(stack.join('\n'));
});
},
getCount() {
this.sendCount();
},
clear() {
(0, _runloop.cancel)(this.debounce);
this.deprecations.length = 0;
this.groupedDeprecations = {};
this.sendCount();
},
release() {
this._watching = false;
},
setOptions({
options
}) {
this.options.toggleDeprecationWorkflow = options.toggleDeprecationWorkflow;
}
};
})();
});
define("ember-debug/deps/backburner", ["exports"], function (_exports) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.buildPlatform = buildPlatform;
_exports.default = void 0;
const SET_TIMEOUT = setTimeout;
const NOOP = () => {};
function buildNext(flush) {
// Using "promises first" here to:
//
// 1) Ensure more consistent experience on browsers that
// have differently queued microtasks (separate queues for
// MutationObserver vs Promises).
// 2) Ensure better debugging experiences (it shows up in Chrome
// call stack as "Promise.then (async)") which is more consistent
// with user expectations
//
// When Promise is unavailable use MutationObserver (mostly so that we
// still get microtasks on IE11), and when neither MutationObserver and
// Promise are present use a plain old setTimeout.
if (typeof Promise === 'function') {
const autorunPromise = Promise.resolve();
return () => autorunPromise.then(flush);
} else if (typeof MutationObserver === 'function') {
let iterations = 0;
let observer = new MutationObserver(flush);
let node = document.createTextNode('');
observer.observe(node, {
characterData: true
});
return () => {
iterations = ++iterations % 2;
node.data = '' + iterations;
return iterations;
};
} else {
return () => SET_TIMEOUT(flush, 0);
}
}
function buildPlatform(flush) {
let clearNext = NOOP;
return {
setTimeout(fn, ms) {
return setTimeout(fn, ms);
},
clearTimeout(timerId) {
return clearTimeout(timerId);
},
now() {
return Date.now();
},
next: buildNext(flush),
clearNext
};
}
const NUMBER = /\d+/;
const TIMERS_OFFSET = 6;
function isCoercableNumber(suspect) {
let type = typeof suspect;
return type === 'number' && suspect === suspect || type === 'string' && NUMBER.test(suspect);
}
function getOnError(options) {
return options.onError || options.onErrorTarget && options.onErrorTarget[options.onErrorMethod];
}
function findItem(target, method, collection) {
let index = -1;
for (let i = 0, l = collection.length; i < l; i += 4) {
if (collection[i] === target && collection[i + 1] === method) {
index = i;
break;
}
}
return index;
}
function findTimerItem(target, method, collection) {
let index = -1;
for (let i = 2, l = collection.length; i < l; i += 6) {
if (collection[i] === target && collection[i + 1] === method) {
index = i - 2;
break;
}
}
return index;
}
function getQueueItems(items, queueItemLength, queueItemPositionOffset = 0) {
let queueItems = [];
for (let i = 0; i < items.length; i += queueItemLength) {
let maybeError = items[i + 3 /* stack */ + queueItemPositionOffset];
let queueItem = {
target: items[i + 0 /* target */ + queueItemPositionOffset],
method: items[i + 1 /* method */ + queueItemPositionOffset],
args: items[i + 2 /* args */ + queueItemPositionOffset],
stack: maybeError !== undefined && 'stack' in maybeError ? maybeError.stack : ''
};
queueItems.push(queueItem);
}
return queueItems;
}
function binarySearch(time, timers) {
let start = 0;
let end = timers.length - TIMERS_OFFSET;
let middle;
let l;
while (start < end) {
// since timers is an array of pairs 'l' will always
// be an integer
l = (end - start) / TIMERS_OFFSET;
// compensate for the index in case even number
// of pairs inside timers
middle = start + l - l % TIMERS_OFFSET;
if (time >= timers[middle]) {
start = middle + TIMERS_OFFSET;
} else {
end = middle;
}
}
return time >= timers[start] ? start + TIMERS_OFFSET : start;
}
const QUEUE_ITEM_LENGTH = 4;
class Queue {
constructor(name, options = {}, globalOptions = {}) {
this._queueBeingFlushed = [];
this.targetQueues = new Map();
this.index = 0;
this._queue = [];
this.name = name;
this.options = options;
this.globalOptions = globalOptions;
}
stackFor(index) {
if (index < this._queue.length) {
let entry = this._queue[index * 3 + QUEUE_ITEM_LENGTH];
if (entry) {
return entry.stack;
} else {
return null;
}
}
}
flush(sync) {
let {
before,
after
} = this.options;
let target;
let method;
let args;
let errorRecordedForStack;
this.targetQueues.clear();
if (this._queueBeingFlushed.length === 0) {
this._queueBeingFlushed = this._queue;
this._queue = [];
}
if (before !== undefined) {
before();
}
let invoke;
let queueItems = this._queueBeingFlushed;
if (queueItems.length > 0) {
let onError = getOnError(this.globalOptions);
invoke = onError ? this.invokeWithOnError : this.invoke;
for (let i = this.index; i < queueItems.length; i += QUEUE_ITEM_LENGTH) {
this.index += QUEUE_ITEM_LENGTH;
method = queueItems[i + 1];
// method could have been nullified / canceled during flush
if (method !== null) {
//
// ** 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
//
target = queueItems[i];
args = queueItems[i + 2];
errorRecordedForStack = queueItems[i + 3]; // Debugging assistance
invoke(target, method, args, onError, errorRecordedForStack);
}
if (this.index !== this._queueBeingFlushed.length && this.globalOptions.mustYield && this.globalOptions.mustYield()) {
return 1 /* Pause */;
}
}
}
if (after !== undefined) {
after();
}
this._queueBeingFlushed.length = 0;
this.index = 0;
if (sync !== false && this._queue.length > 0) {
// check if new items have been added
this.flush(true);
}
}
hasWork() {
return this._queueBeingFlushed.length > 0 || this._queue.length > 0;
}
cancel({
target,
method
}) {
let queue = this._queue;
let targetQueueMap = this.targetQueues.get(target);
if (targetQueueMap !== undefined) {
targetQueueMap.delete(method);
}
let index = findItem(target, method, queue);
if (index > -1) {
queue.splice(index, QUEUE_ITEM_LENGTH);
return true;
}
// if not found in current queue
// could be in the queue that is being flushed
queue = this._queueBeingFlushed;
index = findItem(target, method, queue);
if (index > -1) {
queue[index + 1] = null;
return true;
}
return false;
}
push(target, method, args, stack) {
this._queue.push(target, method, args, stack);
return {
queue: this,
target,
method
};
}
pushUnique(target, method, args, stack) {
let localQueueMap = this.targetQueues.get(target);
if (localQueueMap === undefined) {
localQueueMap = new Map();
this.targetQueues.set(target, localQueueMap);
}
let index = localQueueMap.get(method);
if (index === undefined) {
let queueIndex = this._queue.push(target, method, args, stack) - QUEUE_ITEM_LENGTH;
localQueueMap.set(method, queueIndex);
} else {
let queue = this._queue;
queue[index + 2] = args; // replace args
queue[index + 3] = stack; // replace stack
}
return {
queue: this,
target,
method
};
}
_getDebugInfo(debugEnabled) {
if (debugEnabled) {
let debugInfo = getQueueItems(this._queue, QUEUE_ITEM_LENGTH);
return debugInfo;
}
return undefined;
}
invoke(target, method, args /*, onError, errorRecordedForStack */) {
if (args === undefined) {
method.call(target);
} else {
method.apply(target, args);
}
}
invokeWithOnError(target, method, args, onError, errorRecordedForStack) {
try {
if (args === undefined) {
method.call(target);
} else {
method.apply(target, args);
}
} catch (error) {
onError(error, errorRecordedForStack);
}
}
}
class DeferredActionQueues {
constructor(queueNames = [], options) {
this.queues = {};
this.queueNameIndex = 0;
this.queueNames = queueNames;
queueNames.reduce(function (queues, queueName) {
queues[queueName] = new Queue(queueName, options[queueName], options);
return queues;
}, this.queues);
}
/**
* @method schedule
* @param {String} queueName
* @param {Any} target
* @param {Any} method
* @param {Any} args
* @param {Boolean} onceFlag
* @param {Any} stack
* @return queue
*/
schedule(queueName, target, method, args, onceFlag, stack) {
let queues = this.queues;
let queue = queues[queueName];
if (queue === undefined) {
throw new Error(`You attempted to schedule an action in a queue (${queueName}) that doesn\'t exist`);
}
if (method === undefined || method === null) {
throw new Error(`You attempted to schedule an action in a queue (${queueName}) for a method that doesn\'t exist`);
}
this.queueNameIndex = 0;
if (onceFlag) {
return queue.pushUnique(target, method, args, stack);
} else {
return queue.push(target, method, args, stack);
}
}
/**
* DeferredActionQueues.flush() calls Queue.flush()
*
* @method flush
* @param {Boolean} fromAutorun
*/
flush(fromAutorun = false) {
let queue;
let queueName;
let numberOfQueues = this.queueNames.length;
while (this.queueNameIndex < numberOfQueues) {
queueName = this.queueNames[this.queueNameIndex];
queue = this.queues[queueName];
if (queue.hasWork() === false) {
this.queueNameIndex++;
if (fromAutorun && this.queueNameIndex < numberOfQueues) {
return 1 /* Pause */;
}
} else {
if (queue.flush(false /* async */) === 1 /* Pause */) {
return 1 /* Pause */;
}
}
}
}
/**
* Returns debug information for the current queues.
*
* @method _getDebugInfo
* @param {Boolean} debugEnabled
* @returns {IDebugInfo | undefined}
*/
_getDebugInfo(debugEnabled) {
if (debugEnabled) {
let debugInfo = {};
let queue;
let queueName;
let numberOfQueues = this.queueNames.length;
let i = 0;
while (i < numberOfQueues) {
queueName = this.queueNames[i];
queue = this.queues[queueName];
debugInfo[queueName] = queue._getDebugInfo(debugEnabled);
i++;
}
return debugInfo;
}
return;
}
}
function iteratorDrain(fn) {
let iterator = fn();
let result = iterator.next();
while (result.done === false) {
result.value();
result = iterator.next();
}
}
const noop = function () {};
const DISABLE_SCHEDULE = Object.freeze([]);
function parseArgs() {
let length = arguments.length;
let args;
let method;
let target;
if (length === 0) ;else if (length === 1) {
target = null;
method = arguments[0];
} else {
let argsIndex = 2;
let methodOrTarget = arguments[0];
let methodOrArgs = arguments[1];
let type = typeof methodOrArgs;
if (type === 'function') {
target = methodOrTarget;
method = methodOrArgs;
} else if (methodOrTarget !== null && type === 'string' && methodOrArgs in methodOrTarget) {
target = methodOrTarget;
method = target[methodOrArgs];
} else if (typeof methodOrTarget === 'function') {
argsIndex = 1;
target = null;
method = methodOrTarget;
}
if (length > argsIndex) {
let len = length - argsIndex;
args = new Array(len);
for (let i = 0; i < len; i++) {
args[i] = arguments[i + argsIndex];
}
}
}
return [target, method, args];
}
function parseTimerArgs() {
let [target, method, args] = parseArgs(...arguments);
let wait = 0;
let length = args !== undefined ? args.length : 0;
if (length > 0) {
let last = args[length - 1];
if (isCoercableNumber(last)) {
wait = parseInt(args.pop(), 10);
}
}
return [target, method, args, wait];
}
function parseDebounceArgs() {
let target;
let method;
let isImmediate;
let args;
let wait;
if (arguments.length === 2) {
method = arguments[0];
wait = arguments[1];
target = null;
} else {
[target, method, args] = parseArgs(...arguments);
if (args === undefined) {
wait = 0;
} else {
wait = args.pop();
if (!isCoercableNumber(wait)) {
isImmediate = wait === true;
wait = args.pop();
}
}
}
wait = parseInt(wait, 10);
return [target, method, a