ember-source
Version:
A JavaScript framework for creating ambitious web applications
1,349 lines (1,321 loc) • 1.7 MB
JavaScript
(function() {
/*!
* @overview Ember - JavaScript Application Framework
* @copyright Copyright 2011 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 5.10.0-alpha.4
*/
/* eslint-disable no-var */
/* globals global globalThis self */
/* eslint-disable-next-line no-unused-vars */
var define, require;
(function () {
var globalObj = typeof globalThis !== 'undefined' ? globalThis : typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : null;
if (globalObj === null) {
throw new Error('unable to locate global object');
}
if (typeof globalObj.define === 'function' && typeof globalObj.require === 'function') {
define = globalObj.define;
require = globalObj.require;
return;
}
var registry = Object.create(null);
var seen = Object.create(null);
function missingModule(name, referrerName) {
if (referrerName) {
throw new Error('Could not find module ' + name + ' required by: ' + referrerName);
} else {
throw new Error('Could not find module ' + name);
}
}
function internalRequire(_name, referrerName) {
var name = _name;
var mod = registry[name];
if (!mod) {
name = name + '/index';
mod = registry[name];
}
var exports = seen[name];
if (exports !== undefined) {
return exports;
}
exports = seen[name] = {};
if (!mod) {
missingModule(_name, referrerName);
}
var deps = mod.deps;
var callback = mod.callback;
var reified = new Array(deps.length);
for (var i = 0; i < deps.length; i++) {
if (deps[i] === 'exports') {
reified[i] = exports;
} else if (deps[i] === 'require') {
reified[i] = require;
} else {
reified[i] = require(deps[i], name);
}
}
callback.apply(this, reified);
return exports;
}
require = function (name) {
return internalRequire(name, null);
};
define = function (name, deps, callback) {
registry[name] = {
deps: deps,
callback: callback
};
};
// setup `require` module
require['default'] = require;
require.has = function registryHas(moduleName) {
return Boolean(registry[moduleName]) || Boolean(registry[moduleName + '/index']);
};
require._eak_seen = require.entries = registry;
})();
define("@ember/-internals/browser-environment/index", ["exports"], function (_exports) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.window = _exports.userAgent = _exports.location = _exports.isFirefox = _exports.isChrome = _exports.history = _exports.hasDOM = void 0;
// check if window exists and actually is the global
var hasDom = _exports.hasDOM = typeof self === 'object' && self !== null && self.Object === Object && typeof Window !== 'undefined' && self.constructor === Window && typeof document === 'object' && document !== null && self.document === document && typeof location === 'object' && location !== null && self.location === location && typeof history === 'object' && history !== null && self.history === history && typeof navigator === 'object' && navigator !== null && self.navigator === navigator && typeof navigator.userAgent === 'string';
const window = _exports.window = hasDom ? self : null;
const location$1 = _exports.location = hasDom ? self.location : null;
const history$1 = _exports.history = hasDom ? self.history : null;
const userAgent = _exports.userAgent = hasDom ? self.navigator.userAgent : 'Lynx (textmode)';
const isChrome = _exports.isChrome = hasDom ? typeof chrome === 'object' && !(typeof opera === 'object') : false;
const isFirefox = _exports.isFirefox = hasDom ? /Firefox|FxiOS/.test(userAgent) : false;
});
define("@ember/-internals/container/index", ["exports", "@ember/-internals/utils", "@ember/debug", "@ember/-internals/owner"], function (_exports, _utils, _debug, _owner) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.Registry = _exports.INIT_FACTORY = _exports.Container = void 0;
_exports.getFactoryFor = getFactoryFor;
_exports.privatize = privatize;
_exports.setFactoryFor = setFactoryFor;
let leakTracking;
let containers;
if (true /* DEBUG */) {
// requires v8
// chrome --js-flags="--allow-natives-syntax --expose-gc"
// node --allow-natives-syntax --expose-gc
try {
if (typeof gc === 'function') {
leakTracking = (() => {
// avoid syntax errors when --allow-natives-syntax not present
let GetWeakSetValues = new Function('weakSet', 'return %GetWeakSetValues(weakSet, 0)');
containers = new WeakSet();
return {
hasContainers() {
gc();
return GetWeakSetValues(containers).length > 0;
},
reset() {
let values = GetWeakSetValues(containers);
for (let i = 0; i < values.length; i++) {
containers.delete(values[i]);
}
}
};
})();
}
} catch (_e) {
// ignore
}
}
/**
A container used to instantiate and cache objects.
Every `Container` must be associated with a `Registry`, which is referenced
to determine the factory and options that should be used to instantiate
objects.
The public API for `Container` is still in flux and should not be considered
stable.
@private
@class Container
*/
class Container {
constructor(registry, options = {}) {
this.registry = registry;
this.owner = options.owner || null;
this.cache = (0, _utils.dictionary)(options.cache || null);
this.factoryManagerCache = (0, _utils.dictionary)(options.factoryManagerCache || null);
this.isDestroyed = false;
this.isDestroying = false;
if (true /* DEBUG */) {
this.validationCache = (0, _utils.dictionary)(options.validationCache || null);
if (containers !== undefined) {
containers.add(this);
}
}
}
/**
@private
@property registry
@type Registry
@since 1.11.0
*/
/**
@private
@property cache
@type InheritingDict
*/
/**
@private
@property validationCache
@type InheritingDict
*/
/**
Given a fullName return a corresponding instance.
The default behavior is for lookup to return a singleton instance.
The singleton is scoped to the container, allowing multiple containers
to all have their own locally scoped singletons.
```javascript
let registry = new Registry();
let container = registry.container();
registry.register('api:twitter', Twitter);
let twitter = container.lookup('api:twitter');
twitter instanceof Twitter; // => true
// by default the container will return singletons
let twitter2 = container.lookup('api:twitter');
twitter2 instanceof Twitter; // => true
twitter === twitter2; //=> true
```
If singletons are not wanted, an optional flag can be provided at lookup.
```javascript
let registry = new Registry();
let container = registry.container();
registry.register('api:twitter', Twitter);
let twitter = container.lookup('api:twitter', { singleton: false });
let twitter2 = container.lookup('api:twitter', { singleton: false });
twitter === twitter2; //=> false
```
@private
@method lookup
@param {String} fullName
@param {RegisterOptions} [options]
@return {any}
*/
lookup(fullName, options) {
if (this.isDestroyed) {
throw new Error(`Cannot call \`.lookup('${fullName}')\` after the owner has been destroyed`);
}
(true && !(this.registry.isValidFullName(fullName)) && (0, _debug.assert)('fullName must be a proper full name', this.registry.isValidFullName(fullName)));
return lookup(this, this.registry.normalize(fullName), options);
}
/**
A depth first traversal, destroying the container, its descendant containers and all
their managed objects.
@private
@method destroy
*/
destroy() {
this.isDestroying = true;
destroyDestroyables(this);
}
finalizeDestroy() {
resetCache(this);
this.isDestroyed = true;
}
/**
Clear either the entire cache or just the cache for a particular key.
@private
@method reset
@param {String} fullName optional key to reset; if missing, resets everything
*/
reset(fullName) {
if (this.isDestroyed) return;
if (fullName === undefined) {
destroyDestroyables(this);
resetCache(this);
} else {
resetMember(this, this.registry.normalize(fullName));
}
}
/**
Returns an object that can be used to provide an owner to a
manually created instance.
@private
@method ownerInjection
@returns { Object }
*/
ownerInjection() {
let injection = {};
(0, _owner.setOwner)(injection, this.owner);
return injection;
}
/**
Given a fullName, return the corresponding factory. The consumer of the factory
is responsible for the destruction of any factory instances, as there is no
way for the container to ensure instances are destroyed when it itself is
destroyed.
@public
@method factoryFor
@param {String} fullName
@return {any}
*/
factoryFor(fullName) {
if (this.isDestroyed) {
throw new Error(`Cannot call \`.factoryFor('${fullName}')\` after the owner has been destroyed`);
}
let normalizedName = this.registry.normalize(fullName);
(true && !(this.registry.isValidFullName(normalizedName)) && (0, _debug.assert)('fullName must be a proper full name', this.registry.isValidFullName(normalizedName)));
return factoryFor(this, normalizedName, fullName);
}
}
_exports.Container = Container;
if (true /* DEBUG */) {
Container._leakTracking = leakTracking;
}
/*
* Wrap a factory manager in a proxy which will not permit properties to be
* set on the manager.
*/
function wrapManagerInDeprecationProxy(manager) {
let validator = {
set(_obj, prop) {
throw new Error(`You attempted to set "${String(prop)}" on a factory manager created by container#factoryFor. A factory manager is a read-only construct.`);
}
};
// Note:
// We have to proxy access to the manager here so that private property
// access doesn't cause the above errors to occur.
let m = manager;
let proxiedManager = {
class: m.class,
create(props) {
return m.create(props);
}
};
return new Proxy(proxiedManager, validator);
}
function isSingleton(container, fullName) {
return container.registry.getOption(fullName, 'singleton') !== false;
}
function isInstantiatable(container, fullName) {
return container.registry.getOption(fullName, 'instantiate') !== false;
}
function lookup(container, fullName, options = {}) {
let normalizedName = fullName;
if (options.singleton === true || options.singleton === undefined && isSingleton(container, fullName)) {
let cached = container.cache[normalizedName];
if (cached !== undefined) {
return cached;
}
}
return instantiateFactory(container, normalizedName, fullName, options);
}
function factoryFor(container, normalizedName, fullName) {
let cached = container.factoryManagerCache[normalizedName];
if (cached !== undefined) {
return cached;
}
let factory = container.registry.resolve(normalizedName);
if (factory === undefined) {
return;
}
if (true /* DEBUG */ && factory && typeof factory._onLookup === 'function') {
factory._onLookup(fullName);
}
let manager = new InternalFactoryManager(container, factory, fullName, normalizedName);
if (true /* DEBUG */) {
manager = wrapManagerInDeprecationProxy(manager);
}
container.factoryManagerCache[normalizedName] = manager;
return manager;
}
function isSingletonClass(container, fullName, {
instantiate,
singleton
}) {
return singleton !== false && !instantiate && isSingleton(container, fullName) && !isInstantiatable(container, fullName);
}
function isSingletonInstance(container, fullName, {
instantiate,
singleton
}) {
return singleton !== false && instantiate !== false && (singleton === true || isSingleton(container, fullName)) && isInstantiatable(container, fullName);
}
function isFactoryClass(container, fullname, {
instantiate,
singleton
}) {
return instantiate === false && (singleton === false || !isSingleton(container, fullname)) && !isInstantiatable(container, fullname);
}
function isFactoryInstance(container, fullName, {
instantiate,
singleton
}) {
return instantiate !== false && (singleton === false || !isSingleton(container, fullName)) && isInstantiatable(container, fullName);
}
function instantiateFactory(container, normalizedName, fullName, options) {
let factoryManager = factoryFor(container, normalizedName, fullName);
if (factoryManager === undefined) {
return;
}
// SomeClass { singleton: true, instantiate: true } | { singleton: true } | { instantiate: true } | {}
// By default majority of objects fall into this case
if (isSingletonInstance(container, fullName, options)) {
let instance = container.cache[normalizedName] = factoryManager.create();
// if this lookup happened _during_ destruction (emits a deprecation, but
// is still possible) ensure that it gets destroyed
if (container.isDestroying) {
if (typeof instance.destroy === 'function') {
instance.destroy();
}
}
return instance;
}
// SomeClass { singleton: false, instantiate: true }
if (isFactoryInstance(container, fullName, options)) {
return factoryManager.create();
}
// SomeClass { singleton: true, instantiate: false } | { instantiate: false } | { singleton: false, instantiation: false }
if (isSingletonClass(container, fullName, options) || isFactoryClass(container, fullName, options)) {
return factoryManager.class;
}
throw new Error('Could not create factory');
}
function destroyDestroyables(container) {
let cache = container.cache;
let keys = Object.keys(cache);
for (let key of keys) {
let value = cache[key];
(true && !(value) && (0, _debug.assert)('has cached value', value));
if (value.destroy) {
value.destroy();
}
}
}
function resetCache(container) {
container.cache = (0, _utils.dictionary)(null);
container.factoryManagerCache = (0, _utils.dictionary)(null);
}
function resetMember(container, fullName) {
let member = container.cache[fullName];
delete container.factoryManagerCache[fullName];
if (member) {
delete container.cache[fullName];
if (member.destroy) {
member.destroy();
}
}
}
const INIT_FACTORY = _exports.INIT_FACTORY = Symbol('INIT_FACTORY');
function getFactoryFor(obj) {
// SAFETY: since we know `obj` is an `object`, we also know we can safely ask
// whether a key is set on it.
return obj[INIT_FACTORY];
}
function setFactoryFor(obj, factory) {
// SAFETY: since we know `obj` is an `object`, we also know we can safely set
// a key it safely at this location. (The only way this could be blocked is if
// someone has gone out of their way to use `Object.defineProperty()` with our
// internal-only symbol and made it `writable: false`.)
obj[INIT_FACTORY] = factory;
}
class InternalFactoryManager {
constructor(container, factory, fullName, normalizedName) {
this.container = container;
this.owner = container.owner;
this.class = factory;
this.fullName = fullName;
this.normalizedName = normalizedName;
this.madeToString = undefined;
this.injections = undefined;
}
toString() {
if (this.madeToString === undefined) {
this.madeToString = this.container.registry.makeToString(this.class, this.fullName);
}
return this.madeToString;
}
create(options) {
let {
container
} = this;
if (container.isDestroyed) {
throw new Error(`Cannot create new instances after the owner has been destroyed (you attempted to create ${this.fullName})`);
}
let props = options ? {
...options
} : {};
(0, _owner.setOwner)(props, container.owner);
setFactoryFor(props, this);
if (true /* DEBUG */) {
let lazyInjections;
let validationCache = this.container.validationCache;
// Ensure that all lazy injections are valid at instantiation time
if (!validationCache[this.fullName] && this.class && typeof this.class._lazyInjections === 'function') {
lazyInjections = this.class._lazyInjections();
lazyInjections = this.container.registry.normalizeInjectionsHash(lazyInjections);
this.container.registry.validateInjections(lazyInjections);
}
validationCache[this.fullName] = true;
(true && !(typeof this.class.create === 'function') && (0, _debug.assert)(`Failed to create an instance of '${this.normalizedName}'. Most likely an improperly defined class or an invalid module export.`, typeof this.class.create === 'function'));
}
return this.class.create(props);
}
}
const VALID_FULL_NAME_REGEXP = /^[^:]+:[^:]+$/;
/**
A registry used to store factory and option information keyed
by type.
A `Registry` stores the factory and option information needed by a
`Container` to instantiate and cache objects.
The API for `Registry` is still in flux and should not be considered stable.
@private
@class Registry
@since 1.11.0
*/
class Registry {
constructor(options = {}) {
this.fallback = options.fallback || null;
this.resolver = options.resolver || null;
this.registrations = (0, _utils.dictionary)(options.registrations || null);
this._normalizeCache = (0, _utils.dictionary)(null);
this._resolveCache = (0, _utils.dictionary)(null);
this._failSet = new Set();
this._options = (0, _utils.dictionary)(null);
this._typeOptions = (0, _utils.dictionary)(null);
}
/**
A backup registry for resolving registrations when no matches can be found.
@private
@property fallback
@type Registry
*/
/**
An object that has a `resolve` method that resolves a name.
@private
@property resolver
@type Resolver
*/
/**
@private
@property registrations
@type InheritingDict
*/
/**
@private
@property _normalizeCache
@type InheritingDict
*/
/**
@private
@property _resolveCache
@type InheritingDict
*/
/**
@private
@property _options
@type InheritingDict
*/
/**
@private
@property _typeOptions
@type InheritingDict
*/
/**
Creates a container based on this registry.
@private
@method container
@param {Object} options
@return {Container} created container
*/
container(options) {
return new Container(this, options);
}
register(fullName, factory, options = {}) {
(true && !(this.isValidFullName(fullName)) && (0, _debug.assert)('fullName must be a proper full name', this.isValidFullName(fullName)));
(true && !(factory !== undefined) && (0, _debug.assert)(`Attempting to register an unknown factory: '${fullName}'`, factory !== undefined));
let normalizedName = this.normalize(fullName);
(true && !(!this._resolveCache[normalizedName]) && (0, _debug.assert)(`Cannot re-register: '${fullName}', as it has already been resolved.`, !this._resolveCache[normalizedName]));
this._failSet.delete(normalizedName);
this.registrations[normalizedName] = factory;
this._options[normalizedName] = options;
}
/**
Unregister a fullName
```javascript
let registry = new Registry();
registry.register('model:user', User);
registry.resolve('model:user').create() instanceof User //=> true
registry.unregister('model:user')
registry.resolve('model:user') === undefined //=> true
```
@private
@method unregister
@param {String} fullName
*/
unregister(fullName) {
(true && !(this.isValidFullName(fullName)) && (0, _debug.assert)('fullName must be a proper full name', this.isValidFullName(fullName)));
let normalizedName = this.normalize(fullName);
delete this.registrations[normalizedName];
delete this._resolveCache[normalizedName];
delete this._options[normalizedName];
this._failSet.delete(normalizedName);
}
/**
Given a fullName return the corresponding factory.
By default `resolve` will retrieve the factory from
the registry.
```javascript
let registry = new Registry();
registry.register('api:twitter', Twitter);
registry.resolve('api:twitter') // => Twitter
```
Optionally the registry can be provided with a custom resolver.
If provided, `resolve` will first provide the custom resolver
the opportunity to resolve the fullName, otherwise it will fallback
to the registry.
```javascript
let registry = new Registry();
registry.resolver = function(fullName) {
// lookup via the module system of choice
};
// the twitter factory is added to the module system
registry.resolve('api:twitter') // => Twitter
```
@private
@method resolve
@param {String} fullName
@return {Function} fullName's factory
*/
resolve(fullName) {
let factory = resolve(this, this.normalize(fullName));
if (factory === undefined && this.fallback !== null) {
factory = this.fallback.resolve(fullName);
}
return factory;
}
/**
A hook that can be used to describe how the resolver will
attempt to find the factory.
For example, the default Ember `.describe` returns the full
class name (including namespace) where Ember's resolver expects
to find the `fullName`.
@private
@method describe
@param {String} fullName
@return {string} described fullName
*/
describe(fullName) {
if (this.resolver !== null && this.resolver.lookupDescription) {
return this.resolver.lookupDescription(fullName);
} else if (this.fallback !== null) {
return this.fallback.describe(fullName);
} else {
return fullName;
}
}
/**
A hook to enable custom fullName normalization behavior
@private
@method normalizeFullName
@param {String} fullName
@return {string} normalized fullName
*/
normalizeFullName(fullName) {
if (this.resolver !== null && this.resolver.normalize) {
return this.resolver.normalize(fullName);
} else if (this.fallback !== null) {
return this.fallback.normalizeFullName(fullName);
} else {
return fullName;
}
}
/**
Normalize a fullName based on the application's conventions
@private
@method normalize
@param {String} fullName
@return {string} normalized fullName
*/
normalize(fullName) {
return this._normalizeCache[fullName] || (this._normalizeCache[fullName] = this.normalizeFullName(fullName));
}
/**
@method makeToString
@private
@param {any} factory
@param {string} fullName
@return {function} toString function
*/
makeToString(factory, fullName) {
if (this.resolver !== null && this.resolver.makeToString) {
return this.resolver.makeToString(factory, fullName);
} else if (this.fallback !== null) {
return this.fallback.makeToString(factory, fullName);
} else {
return typeof factory === 'string' ? factory : factory.name ?? '(unknown class)';
}
}
/**
Given a fullName check if the container is aware of its factory
or singleton instance.
@private
@method has
@param {String} fullName
@param {Object} [options]
@param {String} [options.source] the fullname of the request source (used for local lookups)
@return {Boolean}
*/
has(fullName) {
if (!this.isValidFullName(fullName)) {
return false;
}
return has(this, this.normalize(fullName));
}
/**
Allow registering options for all factories of a type.
```javascript
let registry = new Registry();
let container = registry.container();
// if all of type `connection` must not be singletons
registry.optionsForType('connection', { singleton: false });
registry.register('connection:twitter', TwitterConnection);
registry.register('connection:facebook', FacebookConnection);
let twitter = container.lookup('connection:twitter');
let twitter2 = container.lookup('connection:twitter');
twitter === twitter2; // => false
let facebook = container.lookup('connection:facebook');
let facebook2 = container.lookup('connection:facebook');
facebook === facebook2; // => false
```
@private
@method optionsForType
@param {String} type
@param {Object} options
*/
optionsForType(type, options) {
this._typeOptions[type] = options;
}
getOptionsForType(type) {
let optionsForType = this._typeOptions[type];
if (optionsForType === undefined && this.fallback !== null) {
optionsForType = this.fallback.getOptionsForType(type);
}
return optionsForType;
}
/**
@private
@method options
@param {String} fullName
@param {Object} options
*/
options(fullName, options) {
let normalizedName = this.normalize(fullName);
this._options[normalizedName] = options;
}
getOptions(fullName) {
let normalizedName = this.normalize(fullName);
let options = this._options[normalizedName];
if (options === undefined && this.fallback !== null) {
options = this.fallback.getOptions(fullName);
}
return options;
}
getOption(fullName, optionName) {
let options = this._options[fullName];
if (options !== undefined && options[optionName] !== undefined) {
return options[optionName];
}
let type = fullName.split(':')[0];
(true && !(type) && (0, _debug.assert)('has type', type)); // split always will have at least one value
options = this._typeOptions[type];
if (options && options[optionName] !== undefined) {
return options[optionName];
} else if (this.fallback !== null) {
return this.fallback.getOption(fullName, optionName);
}
return undefined;
}
/**
@private
@method knownForType
@param {String} type the type to iterate over
*/
knownForType(type) {
let localKnown = (0, _utils.dictionary)(null);
let registeredNames = Object.keys(this.registrations);
for (let fullName of registeredNames) {
let itemType = fullName.split(':')[0];
if (itemType === type) {
localKnown[fullName] = true;
}
}
let fallbackKnown, resolverKnown;
if (this.fallback !== null) {
fallbackKnown = this.fallback.knownForType(type);
}
if (this.resolver !== null && this.resolver.knownForType) {
resolverKnown = this.resolver.knownForType(type);
}
return Object.assign({}, fallbackKnown, localKnown, resolverKnown);
}
isValidFullName(fullName) {
return VALID_FULL_NAME_REGEXP.test(fullName);
}
}
_exports.Registry = Registry;
if (true /* DEBUG */) {
const proto = Registry.prototype;
proto.normalizeInjectionsHash = function (hash) {
let injections = [];
for (let key in hash) {
if (Object.prototype.hasOwnProperty.call(hash, key)) {
let value = hash[key];
(true && !(value) && (0, _debug.assert)('has value', value));
let {
specifier
} = value;
(true && !(this.isValidFullName(specifier)) && (0, _debug.assert)(`Expected a proper full name, given '${specifier}'`, this.isValidFullName(specifier)));
injections.push({
property: key,
specifier
});
}
}
return injections;
};
proto.validateInjections = function (injections) {
if (!injections) {
return;
}
for (let injection of injections) {
let {
specifier
} = injection;
(true && !(this.has(specifier)) && (0, _debug.assert)(`Attempting to inject an unknown injection: '${specifier}'`, this.has(specifier)));
}
};
}
function resolve(registry, _normalizedName) {
let normalizedName = _normalizedName;
let cached = registry._resolveCache[normalizedName];
if (cached !== undefined) {
return cached;
}
if (registry._failSet.has(normalizedName)) {
return;
}
let resolved;
if (registry.resolver) {
resolved = registry.resolver.resolve(normalizedName);
}
if (resolved === undefined) {
resolved = registry.registrations[normalizedName];
}
if (resolved === undefined) {
registry._failSet.add(normalizedName);
} else {
registry._resolveCache[normalizedName] = resolved;
}
return resolved;
}
function has(registry, fullName) {
return registry.resolve(fullName) !== undefined;
}
const privateNames = (0, _utils.dictionary)(null);
const privateSuffix = `${Math.random()}${Date.now()}`.replace('.', '');
function privatize([fullName]) {
(true && !(arguments.length === 1 && fullName) && (0, _debug.assert)('has a single string argument', arguments.length === 1 && fullName));
let name = privateNames[fullName];
if (name) {
return name;
}
let [type, rawName] = fullName.split(':');
return privateNames[fullName] = (0, _utils.intern)(`${type}:${rawName}-${privateSuffix}`);
}
});
define("@ember/-internals/deprecations/index", ["exports", "@ember/-internals/environment", "@ember/version", "@ember/debug"], function (_exports, _environment, _version, _debug) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.DEPRECATIONS = void 0;
_exports.deprecateUntil = deprecateUntil;
_exports.emberVersionGte = emberVersionGte;
_exports.isRemoved = isRemoved;
function isEnabled(options) {
return Object.hasOwnProperty.call(options.since, 'enabled') || _environment.ENV._ALL_DEPRECATIONS_ENABLED;
}
let numEmberVersion = parseFloat(_environment.ENV._OVERRIDE_DEPRECATION_VERSION ?? _version.VERSION);
/* until must only be a minor version or major version */
function emberVersionGte(until, emberVersion = numEmberVersion) {
let significantUntil = until.replace(/(\.0+)/g, '');
return emberVersion >= parseFloat(significantUntil);
}
function isRemoved(options) {
return emberVersionGte(options.until);
}
function deprecation(options) {
return {
options,
test: !isEnabled(options),
isEnabled: isEnabled(options) || isRemoved(options),
isRemoved: isRemoved(options)
};
}
/*
To add a deprecation, you must add a new entry to the `DEPRECATIONS` object.
The entry should be an object with the following properties:
* `id` (required): A string that uniquely identifies the deprecation. This
should be a short, descriptive name, typically dasherized.
* `for` (required): The string `ember-source` -- every deprecation from this
package is for `ember-source`.
* `since` (required): An object with `available` and `enabled`. `available` is
the first version of Ember that the deprecation is available in. `enabled` is
the version of Ember that the deprecation was first enabled. This is used as
a feature flag deprecations. For public APIs, the `enabled` value is added
only once the deprecation RFC is [Ready for Release](https://github.com/emberjs/rfcs#ready-for-release).
* `until` (required): The version of Ember that the deprecation will be removed
* `url` (required): A URL to the deprecation guide for the deprecation. This
URL can be constructed in advance of the deprecation being added to the
[deprecation app](https://github.com/ember-learn/deprecation-app) by
following this format: `https://deprecations.emberjs.com/deprecations/{{id}}`.
For example:
`deprecate` should then be called using the entry from the `DEPRECATIONS` object.
```ts
import { DEPRECATIONS } from '@ember/-internals/deprecations';
//...
deprecateUntil(message, DEPRECATIONS.MY_DEPRECATION);
```
`expectDeprecation` should also use the DEPRECATIONS object, but it should be noted
that it uses `isEnabled` instead of `test` because the expectations of `expectDeprecation`
are the opposite of `test`.
```ts
expectDeprecation(
() => {
assert.equal(foo, bar(), 'foo is equal to bar'); // something that triggers the deprecation
},
/matchesMessage/,
DEPRECATIONS.MY_DEPRECATION.isEnabled
);
```
Tests can be conditionally run based on whether a deprecation is enabled or not:
```ts
[`${testUnless(DEPRECATIONS.MY_DEPRECATION.isRemoved)} specific deprecated feature tested only in this test`]
```
This test will be skipped when the MY_DEPRECATION is removed.
When adding a deprecation, we need to guard all the code that will eventually be removed, including tests.
For tests that are not specifically testing the deprecated feature, we need to figure out how to
test the behavior without encountering the deprecated feature, just as users would.
*/
const DEPRECATIONS = _exports.DEPRECATIONS = {
DEPRECATE_IMPLICIT_ROUTE_MODEL: deprecation({
id: 'deprecate-implicit-route-model',
for: 'ember-source',
since: {
available: '5.3.0',
enabled: '5.3.0'
},
until: '6.0.0',
url: 'https://deprecations.emberjs.com/v5.x/#toc_deprecate-implicit-route-model'
}),
DEPRECATE_TEMPLATE_ACTION: deprecation({
id: 'template-action',
url: 'https://deprecations.emberjs.com/id/template-action',
until: '6.0.0',
for: 'ember-source',
since: {
available: '5.9.0'
}
}),
DEPRECATE_COMPONENT_TEMPLATE_RESOLVING: deprecation({
id: 'component-template-resolving',
url: 'https://deprecations.emberjs.com/id/component-template-resolving',
until: '6.0.0',
for: 'ember-source',
since: {
available: '5.9.0'
}
})
};
function deprecateUntil(message, deprecation) {
const {
options
} = deprecation;
(true && !(Boolean(options.for === 'ember-source')) && (0, _debug.assert)('deprecateUntil must only be called for ember-source', Boolean(options.for === 'ember-source')));
if (deprecation.isRemoved) {
throw new Error(`The API deprecated by ${options.id} was removed in ember-source ${options.until}. The message was: ${message}. Please see ${options.url} for more details.`);
}
(true && !(deprecation.test) && (0, _debug.deprecate)(message, deprecation.test, options));
}
});
define("@ember/-internals/environment/index", ["exports"], function (_exports) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.context = _exports.ENV = void 0;
_exports.getENV = getENV;
_exports.getLookup = getLookup;
_exports.global = void 0;
_exports.setLookup = setLookup;
// from lodash to catch fake globals
function checkGlobal(value) {
return value && value.Object === Object ? value : undefined;
}
// element ids can ruin global miss checks
function checkElementIdShadowing(value) {
return value && value.nodeType === undefined ? value : undefined;
}
// export real global
var global$1 = _exports.global = checkGlobal(checkElementIdShadowing(typeof global === 'object' && global)) || checkGlobal(typeof self === 'object' && self) || checkGlobal(typeof window === 'object' && window) || typeof mainContext !== 'undefined' && mainContext ||
// set before strict mode in Ember loader/wrapper
new Function('return this')(); // eval outside of strict mode
// legacy imports/exports/lookup stuff (should we keep this??)
const context = _exports.context = function (global, Ember) {
return Ember === undefined ? {
imports: global,
exports: global,
lookup: global
} : {
// import jQuery
imports: Ember.imports || global,
// export Ember
exports: Ember.exports || global,
// search for Namespaces
lookup: Ember.lookup || global
};
}(global$1, global$1.Ember);
function getLookup() {
return context.lookup;
}
function setLookup(value) {
context.lookup = value;
}
/**
The hash of environment variables used to control various configuration
settings. To specify your own or override default settings, add the
desired properties to a global hash named `EmberENV` (or `ENV` for
backwards compatibility with earlier versions of Ember). The `EmberENV`
hash must be created before loading Ember.
@class EmberENV
@type Object
@public
*/
const ENV = _exports.ENV = {
ENABLE_OPTIONAL_FEATURES: false,
/**
Determines whether Ember should add to `Array`
native object prototypes, a few extra methods in order to provide a more
friendly API.
We generally recommend leaving this option set to true however, if you need
to turn it off, you can add the configuration property
`EXTEND_PROTOTYPES` to `EmberENV` and set it to `false`.
Note, when disabled (the default configuration for Ember Addons), you will
instead have to access all methods and functions from the Ember
namespace.
@property EXTEND_PROTOTYPES
@type Boolean
@default true
@for EmberENV
@public
*/
EXTEND_PROTOTYPES: {
Array: true
},
/**
The `LOG_STACKTRACE_ON_DEPRECATION` property, when true, tells Ember to log
a full stack trace during deprecation warnings.
@property LOG_STACKTRACE_ON_DEPRECATION
@type Boolean
@default true
@for EmberENV
@public
*/
LOG_STACKTRACE_ON_DEPRECATION: true,
/**
The `LOG_VERSION` property, when true, tells Ember to log versions of all
dependent libraries in use.
@property LOG_VERSION
@type Boolean
@default true
@for EmberENV
@public
*/
LOG_VERSION: true,
RAISE_ON_DEPRECATION: false,
STRUCTURED_PROFILE: false,
/**
Whether to perform extra bookkeeping needed to make the `captureRenderTree`
API work.
This has to be set before the ember JavaScript code is evaluated. This is
usually done by setting `window.EmberENV = { _DEBUG_RENDER_TREE: true };`
before the "vendor" `<script>` tag in `index.html`.
Setting the flag after Ember is already loaded will not work correctly. It
may appear to work somewhat, but fundamentally broken.
This is not intended to be set directly. Ember Inspector will enable the
flag on behalf of the user as needed.
This flag is always on in development mode.
The flag is off by default in production mode, due to the cost associated
with the the bookkeeping work.
The expected flow is that Ember Inspector will ask the user to refresh the
page after enabling the feature. It could also offer a feature where the
user add some domains to the "always on" list. In either case, Ember
Inspector will inject the code on the page to set the flag if needed.
@property _DEBUG_RENDER_TREE
@for EmberENV
@type Boolean
@default false
@private
*/
_DEBUG_RENDER_TREE: true /* DEBUG */,
/**
Whether to force all deprecations to be enabled. This is used internally by
Ember to enable deprecations in tests. It is not intended to be set in
projects.
@property _ALL_DEPRECATIONS_ENABLED
@for EmberENV
@type Boolean
@default false
@private
*/
_ALL_DEPRECATIONS_ENABLED: false,
/**
Override the version of ember-source used to determine when deprecations "break".
This is used internally by Ember to test with deprecated features "removed".
This is never intended to be set by projects.
@property _OVERRIDE_DEPRECATION_VERSION
@for EmberENV
@type string | null
@default null
@private
*/
_OVERRIDE_DEPRECATION_VERSION: null,
/**
Whether the app defaults to using async observers.
This is not intended to be set directly, as the implementation may change in
the future. Use `@ember/optional-features` instead.
@property _DEFAULT_ASYNC_OBSERVERS
@for EmberENV
@type Boolean
@default false
@private
*/
_DEFAULT_ASYNC_OBSERVERS: false,
/**
Whether the app still has default record-loading behavior in the model
hook from RFC https://rfcs.emberjs.com/id/0774-implicit-record-route-loading
This will also remove the default store property from the route.
This is not intended to be set directly, as the implementation may change in
the future. Use `@ember/optional-features` instead.
@property _NO_IMPLICIT_ROUTE_MODEL
@for EmberENV
@type Boolean
@default false
@private
*/
_NO_IMPLICIT_ROUTE_MODEL: false,
/**
Controls the maximum number of scheduled rerenders without "settling". In general,
applications should not need to modify this environment variable, but please
open an issue so that we can determine if a better default value is needed.
@property _RERENDER_LOOP_LIMIT
@for EmberENV
@type number
@default 1000
@private
*/
_RERENDER_LOOP_LIMIT: 1000,
EMBER_LOAD_HOOKS: {},
FEATURES: {}
};
(EmberENV => {
if (typeof EmberENV !== 'object' || EmberENV === null) return;
for (let flag in EmberENV) {
if (!Object.prototype.hasOwnProperty.call(EmberENV, flag) || flag === 'EXTEND_PROTOTYPES' || flag === 'EMBER_LOAD_HOOKS') continue;
let defaultValue = ENV[flag];
if (defaultValue === true) {
ENV[flag] = EmberENV[flag] !== false;
} else if (defaultValue === false) {
ENV[flag] = EmberENV[flag] === true;
} else {
ENV[flag] = EmberENV[flag];
}
}
let {
EXTEND_PROTOTYPES
} = EmberENV;
if (EXTEND_PROTOTYPES !== undefined) {
if (typeof EXTEND_PROTOTYPES === 'object' && EXTEND_PROTOTYPES !== null) {
ENV.EXTEND_PROTOTYPES.Array = EXTEND_PROTOTYPES.Array !== false;
} else {
ENV.EXTEND_PROTOTYPES.Array = EXTEND_PROTOTYPES !== false;
}
}
// TODO this does not seem to be used by anything,
// can we remove it? do we need to deprecate it?
let {
EMBER_LOAD_HOOKS
} = EmberENV;
if (typeof EMBER_LOAD_HOOKS === 'object' && EMBER_LOAD_HOOKS !== null) {
for (let hookName in EMBER_LOAD_HOOKS) {
if (!Object.prototype.hasOwnProperty.call(EMBER_LOAD_HOOKS, hookName)) continue;
let hooks = EMBER_LOAD_HOOKS[hookName];
if (Array.isArray(hooks)) {
ENV.EMBER_LOAD_HOOKS[hookName] = hooks.filter(hook => typeof hook === 'function');
}
}
}
let {
FEATURES
} = EmberENV;
if (typeof FEATURES === 'object' && FEATURES !== null) {
for (let feature in FEATURES) {
if (!Object.prototype.hasOwnProperty.call(FEATURES, feature)) continue;
ENV.FEATURES[feature] = FEATURES[feature] === true;
}
}
if (true /* DEBUG */) {
ENV._DEBUG_RENDER_TREE = true;
}
})(global$1.EmberENV);
function getENV() {
return ENV;
}
});
define("@ember/-internals/error-handling/index", ["exports"], function (_exports) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.getDispatchOverride = getDispatchOverride;
_exports.getOnerror = getOnerror;
_exports.onErrorTarget = void 0;
_exports.setDispatchOverride = setDispatchOverride;
_exports.setOnerror = setOnerror;
let onerror;
const onErrorTarget = _exports.onErrorTarget = {
get onerror() {
return onerror;
}
};
// Ember.onerror getter
function getOnerror() {
return onerror;
}
// Ember.onerror setter
function setOnerror(handler) {
onerror = handler;
}
let dispatchOverride = null;
// allows testing adapter to override dispatch
function getDispatchOverride() {
return dispatchOverride;
}
function setDispatchOverride(handler) {
dispatchOverride = handler;
}
});
define("@ember/-internals/glimmer/index", ["exports", "@glimmer/opcode-compiler", "@ember/-internals/browser-environment", "@ember/debug", "@ember/object", "@glimmer/reference", "@glimmer/validator", "@ember/modifier", "@ember/-internals/metal", "@ember/-internals/owner", "@ember/-internals/utils", "@glimmer/manager", "@ember/-internals/views", "@ember/engine", "@ember/engine/instance", "@ember/instrumentation", "@ember/service", "@ember/-internals/runtime", "@glimmer/runtime", "@glimmer/util", "@ember/-internals/string", "@glimmer/destroyable", "@ember/-internals/deprecations", "@ember/runloop", "@ember/object/-internals", "@ember/-internals/container", "@ember/-internals/environment", "@glimmer/vm", "@glimmer/program", "rsvp", "@glimmer/node", "@glimmer/global-context", "@ember/array/-internals", "@ember/-internals/glimmer", "@ember/array", "@ember/routing/-internals", "@ember/template-factory"], function (_exports, _opcodeCompiler, _browserEnvironment, _debug, _object, _reference, _validator, _modifier, _metal, _owner2, _utils, _manager, _views, _engine, _instance, _instrumentation, _service, _runtime, _runtime2, _util, _string, _destroyable, _deprecations, _runloop, _internals, _container, _environment2, _vm, _program, _rsvp, _node, _globalContext, _internals2, _glimmer, _array, _internals3, _templateFactory) {
"use strict";
Object.defineProperty(_exports, "__esModule", {
value: true
});
_exports.Component = void 0;
Object.defineProperty(_exports, "DOMChanges", {
enumerable: true,
get: function () {
return _runtime2.DOMChanges;
}
});
Object.defineProperty(_exports, "DOMTreeConstruction", {
enumerable: true,
get: function () {
return _runtime2.DOMTreeConstruction;
}
});
_exports.LinkTo = _exports.Input = _exports.Helper = void 0;
Object.defineProperty(_exports, "NodeDOMTreeConstruction", {
enumerable: true,
get: function () {
return _node.NodeDOMTreeConstruction;
}
});
_exports.Textarea = _exports.SafeString = _exports.RootTemplate = _exports.Renderer = _exports.OutletView = void 0;
_exports._resetRenderers = _resetRenderers;
Object.defineProperty(_exports, "componentCapabilities", {
enumerable: true,
get: function () {
return _manager.componentCapabilities;
}
});
_exports.escapeExpression = escapeExpression;
_exports.getTemplate = getTemplate;
_exports.getTemplates = getTemplates;
_exports.hasTemplate = hasTemplate;
_exports.helper = helper$1;
_exports.htmlSafe = htmlSafe;
_exports.isHTMLSafe = isHTMLSafe;
Object.defineProperty(_exports, "isSerializationFirstNode", {
enumerable: true,
get: function () {
return _runtime2.isSerializationFirstNode;
}
});
Object.defineProperty(_exports, "modifierCapabilities", {
enumerable: true,
get: function () {
return _manager.modifierCapabilities;
}
});
_exports.renderSettled = renderSettled;
_exports.setComponentManager = setComponentManager;
_exports.setTemplate = setTemplate;
_exports.setTemplates = setTemplates;
_exports.setupApplicationRegistry = setupApplicationRegistry;
_exports.setupEngineRegistry = setupEngineRegistry;
Object.defineProperty(_exports, "template", {
enumerable: true,
get: function () {
return _opcodeCompiler.templateFactory;
}
});
Object.defineProperty(_exports, "templateCacheCounters", {
enumerable: true,
get: function () {
return _opcodeCompiler.templateCacheCounters;
}
});
_exports.uniqueId = uniqueId$1;
var RootTemplate = _exports.RootTemplate = (0, _templateFactory.createTemplateFactory)(
/*
{{component this}}
*/
{
"id": "tjANIXCV",
"block": "[[[46,[30,0],null,null,null]],[],false,[\"component\"]]",
"moduleName": "packages/@ember/-internals/glimmer/lib/templates/root.hbs",
"isStrictMode": true
});
var InputTemplate = (0, _templateFactory.createTemplateFactory)(
/*
<input
{{!-- for compatibility --}}
id={{this.id}}
class={{this.class}}
...attributes
type={{this.type}}
checked={{this.checked}}
value={{this.value}}
{{on "change" this.change}}
{{on "input" this.input}}
{{on "keyup" this.keyUp}}
{{on "paste" this.valueDidChange}}
{{on "cut" this.valueDidChange}}
/>
*/
{
"id": "4z3DuGQ3",
"block": "[[[11,\"input\"],[16,1,[30,0,[\"id\"]]],[16,0,[30,0,[\"class\"]]],[17,1],[16,4,[30,0,[\"type\"]]]