UNPKG

ember-source

Version:

A JavaScript framework for creating ambitious web applications

1,193 lines (1,117 loc) 1.78 MB
/*! * @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-beta.1 */ /* 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); } } var result = callback.apply(this, reified); if (!deps.includes('exports') || result !== undefined) { exports = seen[name] = result; } 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; })(); (function () { 'use strict'; function d(name, mod) { Object.defineProperty(mod, '__esModule', { value: true }); define(name, [], () => mod); } // check if window exists and actually is the global const 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$1 = hasDOM ? self : null; const location$1 = hasDOM ? self.location : null; const history$1 = hasDOM ? self.history : null; const userAgent = hasDOM ? self.navigator.userAgent : 'Lynx (textmode)'; const isChrome = hasDOM ? typeof chrome === 'object' && !(typeof opera === 'object') : false; const isFirefox = hasDOM ? /Firefox|FxiOS/.test(userAgent) : false; const environment = /*#__PURE__*/Object.defineProperty({ __proto__: null, hasDOM, history: history$1, isChrome, isFirefox, location: location$1, userAgent, window: window$1 }, Symbol.toStringTag, { value: 'Module' }); /* globals window, self */ // 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 const global$1 = 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$1 = 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); /** 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 = { 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; } } { ENV._DEBUG_RENDER_TREE = true; } })(global$1.EmberENV); let HANDLERS = {}; let registerHandler$2 = function registerHandler(_type, _callback) {}; let invoke = () => {}; { registerHandler$2 = function registerHandler(type, callback) { let nextHandler = HANDLERS[type] || (() => {}); HANDLERS[type] = (message, options) => { callback(message, options, nextHandler); }; }; invoke = function invoke(type, message, test, options) { if (test) { return; } let handlerForType = HANDLERS[type]; if (handlerForType) { handlerForType(message, options); } }; } // This is a "global", but instead of declaring it as `declare global`, which // will expose it to all other modules, declare it *locally* (and don't export // it) so that it has the desired "private global" semantics -- however odd that // particular notion is. /** @module @ember/debug @public */ /** Allows for runtime registration of handler functions that override the default deprecation behavior. Deprecations are invoked by calls to [@ember/debug/deprecate](/ember/release/classes/@ember%2Fdebug/methods/deprecate?anchor=deprecate). The following example demonstrates its usage by registering a handler that throws an error if the message contains the word "should", otherwise defers to the default handler. ```javascript import { registerDeprecationHandler } from '@ember/debug'; registerDeprecationHandler((message, options, next) => { if (message.indexOf('should') !== -1) { throw new Error(`Deprecation message with should: ${message}`); } else { // defer to whatever handler was registered before this one next(message, options); } }); ``` The handler function takes the following arguments: <ul> <li> <code>message</code> - The message received from the deprecation call.</li> <li> <code>options</code> - An object passed in with the deprecation call containing additional information including:</li> <ul> <li> <code>id</code> - An id of the deprecation in the form of <code>package-name.specific-deprecation</code>.</li> <li> <code>until</code> - The Ember version number the feature and deprecation will be removed in.</li> </ul> <li> <code>next</code> - A function that calls into the previously registered handler.</li> </ul> @public @static @method registerDeprecationHandler @for @ember/debug @param handler {Function} A function to handle deprecation calls. @since 2.1.0 */ let registerHandler$1 = () => {}; let missingOptionsDeprecation$1; let missingOptionsIdDeprecation$1; let missingOptionDeprecation = () => ''; let deprecate$1 = () => {}; { registerHandler$1 = function registerHandler(handler) { registerHandler$2('deprecate', handler); }; let formatMessage = function formatMessage(_message, options) { let message = _message; if (options?.id) { message = message + ` [deprecation id: ${options.id}]`; } if (options?.until) { message = message + ` This will be removed in ${options.for} ${options.until}.`; } if (options?.url) { message += ` See ${options.url} for more details.`; } return message; }; registerHandler$1(function logDeprecationToConsole(message, options) { let updatedMessage = formatMessage(message, options); console.warn(`DEPRECATION: ${updatedMessage}`); // eslint-disable-line no-console }); let captureErrorForStack; if (new Error().stack) { captureErrorForStack = () => new Error(); } else { captureErrorForStack = () => { try { __fail__.fail(); return; } catch (e) { return e; } }; } registerHandler$1(function logDeprecationStackTrace(message, options, next) { if (ENV.LOG_STACKTRACE_ON_DEPRECATION) { let stackStr = ''; let error = captureErrorForStack(); let stack; if (error instanceof Error) { if (error.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 updatedMessage = formatMessage(message, options); console.warn(`DEPRECATION: ${updatedMessage}${stackStr}`); // eslint-disable-line no-console } else { next(message, options); } }); registerHandler$1(function raiseOnDeprecation(message, options, next) { if (ENV.RAISE_ON_DEPRECATION) { let updatedMessage = formatMessage(message); throw new Error(updatedMessage); } else { next(message, options); } }); missingOptionsDeprecation$1 = 'When calling `deprecate` you ' + 'must provide an `options` hash as the third parameter. ' + '`options` should include `id` and `until` properties.'; missingOptionsIdDeprecation$1 = 'When calling `deprecate` you must provide `id` in options.'; missingOptionDeprecation = (id, missingOption) => { return `When calling \`deprecate\` you must provide \`${missingOption}\` in options. Missing options.${missingOption} in "${id}" deprecation`; }; /** @module @ember/debug @public */ /** Display a deprecation warning with the provided message and a stack trace (Chrome and Firefox only). Ember itself leverages [Semantic Versioning](https://semver.org) to aid projects in keeping up with changes to the framework. Before any functionality or API is removed, it first flows linearly through a deprecation staging process. The staging process currently contains two stages: available and enabled. Deprecations are initially released into the 'available' stage. Deprecations will stay in this stage until the replacement API has been marked as a recommended practice via the RFC process and the addon ecosystem has generally adopted the change. Once a deprecation meets the above criteria, it will move into the 'enabled' stage where it will remain until the functionality or API is eventually removed. For application and addon developers, "available" deprecations are not urgent and "enabled" deprecations require action. * In a production build, this method is defined as an empty function (NOP). Uses of this method in Ember itself are stripped from the ember.prod.js build. ```javascript import { deprecate } from '@ember/debug'; deprecate( 'Use of `assign` has been deprecated. Please use `Object.assign` or the spread operator instead.', false, { id: 'ember-polyfills.deprecate-assign', until: '5.0.0', url: 'https://deprecations.emberjs.com/v4.x/#toc_ember-polyfills-deprecate-assign', for: 'ember-source', since: { available: '4.0.0', enabled: '4.0.0', }, } ); ``` @method deprecate @for @ember/debug @param {String} message A description of the deprecation. @param {Boolean} test A boolean. If falsy, the deprecation will be displayed. @param {Object} options @param {String} options.id A unique id for this deprecation. The id can be used by Ember debugging tools to change the behavior (raise, log or silence) for that specific deprecation. The id should be namespaced by dots, e.g. "view.helper.select". @param {string} options.until The version of Ember when this deprecation warning will be removed. @param {String} options.for A namespace for the deprecation, usually the package name @param {Object} options.since Describes when the deprecation became available and enabled. @param {String} [options.url] An optional url to the transition guide on the emberjs.com website. @static @public @since 1.0.0 */ deprecate$1 = function deprecate(message, test, options) { assert$1(missingOptionsDeprecation$1, Boolean(options && (options.id || options.until))); assert$1(missingOptionsIdDeprecation$1, Boolean(options.id)); assert$1(missingOptionDeprecation(options.id, 'until'), Boolean(options.until)); assert$1(missingOptionDeprecation(options.id, 'for'), Boolean(options.for)); assert$1(missingOptionDeprecation(options.id, 'since'), Boolean(options.since)); invoke('deprecate', message, test, options); }; } const _deprecate = deprecate$1; let testing = false; function isTesting() { return testing; } function setTesting(value) { testing = Boolean(value); } let registerHandler = () => {}; let warn$1 = () => {}; let missingOptionsDeprecation; let missingOptionsIdDeprecation; /** @module @ember/debug */ { /** Allows for runtime registration of handler functions that override the default warning behavior. Warnings are invoked by calls made to [@ember/debug/warn](/ember/release/classes/@ember%2Fdebug/methods/warn?anchor=warn). The following example demonstrates its usage by registering a handler that does nothing overriding Ember's default warning behavior. ```javascript import { registerWarnHandler } from '@ember/debug'; // next is not called, so no warnings get the default behavior registerWarnHandler(() => {}); ``` The handler function takes the following arguments: <ul> <li> <code>message</code> - The message received from the warn call. </li> <li> <code>options</code> - An object passed in with the warn call containing additional information including:</li> <ul> <li> <code>id</code> - An id of the warning in the form of <code>package-name.specific-warning</code>.</li> </ul> <li> <code>next</code> - A function that calls into the previously registered handler.</li> </ul> @public @static @method registerWarnHandler @for @ember/debug @param handler {Function} A function to handle warnings. @since 2.1.0 */ registerHandler = function registerHandler(handler) { registerHandler$2('warn', handler); }; registerHandler(function logWarning(message) { /* eslint-disable no-console */ console.warn(`WARNING: ${message}`); /* eslint-enable no-console */ }); missingOptionsDeprecation = 'When calling `warn` you ' + 'must provide an `options` hash as the third parameter. ' + '`options` should include an `id` property.'; missingOptionsIdDeprecation = 'When calling `warn` you must provide `id` in options.'; /** Display a warning with the provided message. * In a production build, this method is defined as an empty function (NOP). Uses of this method in Ember itself are stripped from the ember.prod.js build. ```javascript import { warn } from '@ember/debug'; import tomsterCount from './tomster-counter'; // a module in my project // Log a warning if we have more than 3 tomsters warn('Too many tomsters!', tomsterCount <= 3, { id: 'ember-debug.too-many-tomsters' }); ``` @method warn @for @ember/debug @static @param {String} message A warning to display. @param {Boolean|Object} test An optional boolean. If falsy, the warning will be displayed. If `test` is an object, the `test` parameter can be used as the `options` parameter and the warning is displayed. @param {Object} options @param {String} options.id The `id` can be used by Ember debugging tools to change the behavior (raise, log, or silence) for that specific warning. The `id` should be namespaced by dots, e.g. "ember-debug.feature-flag-with-features-stripped" @public @since 1.0.0 */ warn$1 = function warn(message, test, options) { if (arguments.length === 2 && typeof test === 'object') { options = test; test = false; } assert$1(missingOptionsDeprecation, Boolean(options)); assert$1(missingOptionsIdDeprecation, Boolean(options && options.id)); // SAFETY: we have explicitly assigned `false` if the user invoked the // arity-2 version of the overload, so we know `test` is always either // `undefined` or a `boolean` for type-safe callers. invoke('warn', message, test, options); }; } const _warn = warn$1; const { toString: objectToString$1 } = Object.prototype; const { toString: functionToString } = Function.prototype; const { isArray: isArray$5 } = Array; const { keys: objectKeys } = Object; const { stringify } = JSON; const LIST_LIMIT = 100; const DEPTH_LIMIT = 4; const SAFE_KEY = /^[\w$]+$/; /** @module @ember/debug */ /** Convenience method to inspect an object. This method will attempt to convert the object into a useful string description. It is a pretty simple implementation. If you want something more robust, use something like JSDump: https://github.com/NV/jsDump @method inspect @static @param {Object} obj The object you want to inspect. @return {String} A description of the object @since 1.4.0 @private */ function inspect(obj) { // detect Node util.inspect call inspect(depth: number, opts: object) if (typeof obj === 'number' && arguments.length === 2) { return this; } return inspectValue(obj, 0); } function inspectValue(value, depth, seen) { let valueIsArray = false; switch (typeof value) { case 'undefined': return 'undefined'; case 'object': if (value === null) return 'null'; if (isArray$5(value)) { valueIsArray = true; break; } // is toString Object.prototype.toString or undefined then traverse if (value.toString === objectToString$1 || value.toString === undefined) { break; } // custom toString return value.toString(); case 'function': return value.toString === functionToString ? value.name ? `[Function:${value.name}]` : `[Function]` : value.toString(); case 'string': return stringify(value); case 'symbol': case 'boolean': case 'number': default: return value.toString(); } if (seen === undefined) { seen = new WeakSet(); } else { if (seen.has(value)) return `[Circular]`; } seen.add(value); return valueIsArray ? inspectArray(value, depth + 1, seen) : inspectObject(value, depth + 1, seen); } function inspectKey(key) { return SAFE_KEY.test(key) ? key : stringify(key); } function inspectObject(obj, depth, seen) { if (depth > DEPTH_LIMIT) { return '[Object]'; } let s = '{'; let keys = objectKeys(obj); for (let i = 0; i < keys.length; i++) { s += i === 0 ? ' ' : ', '; if (i >= LIST_LIMIT) { s += `... ${keys.length - LIST_LIMIT} more keys`; break; } let key = keys[i]; (!(key) && assert$1('has key', key)); // Looping over array s += `${inspectKey(String(key))}: ${inspectValue(obj[key], depth, seen)}`; } s += ' }'; return s; } function inspectArray(arr, depth, seen) { if (depth > DEPTH_LIMIT) { return '[Array]'; } let s = '['; for (let i = 0; i < arr.length; i++) { s += i === 0 ? ' ' : ', '; if (i >= LIST_LIMIT) { s += `... ${arr.length - LIST_LIMIT} more items`; break; } s += inspectValue(arr[i], depth, seen); } s += ' ]'; return s; } const EMPTY_ARRAY$4 = Object.freeze([]); function emptyArray() { return EMPTY_ARRAY$4; } const EMPTY_STRING_ARRAY = emptyArray(); function* reverse(input) { for (let i = input.length - 1; i >= 0; i--) { yield input[i]; } } function* enumerate(input) { let i = 0; for (const item of input) { yield [i++, item]; } } // import Logger from './logger'; // let alreadyWarned = false; function debugAssert(test, msg) { // if (!alreadyWarned) { // alreadyWarned = true; // Logger.warn("Don't leave debug assertions on in public builds"); // } if (!test) { throw new Error(msg || 'assertion failure'); } } function unwrap$1(val) { if (val === null || val === undefined) throw new Error(`Expected value to be present`); return val; } function expect(val, message) { if (val === null || val === undefined) throw new Error(message); return val; } function unreachable(message = 'unreachable') { return new Error(message); } function isPresentArray(list) { return list.length > 0; } function assertPresentArray(list, message = `unexpected empty list`) { if (!isPresentArray(list)) { throw new Error(message); } } function asPresentArray(list, message = `unexpected empty list`) { assertPresentArray(list, message); return list; } function getLast(list) { return list.length === 0 ? undefined : list[list.length - 1]; } function dict() { return Object.create(null); } function isDict(u) { return u !== null && u !== undefined; } function isObject$1(u) { return typeof u === 'function' || typeof u === 'object' && u !== null; } class StackImpl { stack; current = null; constructor(values = []) { this.stack = values; } get size() { return this.stack.length; } push(item) { this.current = item; this.stack.push(item); } pop() { let item = this.stack.pop(); this.current = getLast(this.stack) ?? null; return item === undefined ? null : item; } nth(from) { let len = this.stack.length; return len < from ? null : unwrap$1(this.stack[len - from]); } isEmpty() { return this.stack.length === 0; } toArray() { return this.stack; } } let debugToString; { let getFunctionName = fn => { let functionName = fn.name; if (functionName === undefined) { let match = /function (\w+)\s*\(/u.exec(String(fn)); functionName = match && match[1] || ''; } return functionName.replace(/^bound /u, ''); }; let getObjectName = obj => { let name; let className; if (obj.constructor && typeof obj.constructor === 'function') { className = getFunctionName(obj.constructor); } if ('toString' in obj && obj.toString !== Object.prototype.toString && obj.toString !== Function.prototype.toString) { name = obj.toString(); } // If the class has a decent looking name, and the `toString` is one of the // default Ember toStrings, replace the constructor portion of the toString // with the class name. We check the length of the class name to prevent doing // this when the value is minified. if (name && /<.*:ember\d+>/u.test(name) && className && className[0] !== '_' && className.length > 2 && className !== 'Class') { return name.replace(/<.*:/u, `<${className}:`); } return name || className; }; let getPrimitiveName = value => { return String(value); }; debugToString = value => { if (typeof value === 'function') { return getFunctionName(value) || `(unknown function)`; } else if (typeof value === 'object' && value !== null) { return getObjectName(value) || `(unknown object)`; } else { return getPrimitiveName(value); } }; } var debugToString$1 = debugToString; function clearElement(parent) { let current = parent.firstChild; while (current) { let next = current.nextSibling; parent.removeChild(current); current = next; } } const ELEMENT_NODE = 1; const COMMENT_NODE = 8; const DOCUMENT_NODE = 9; const NS_SVG = 'http://www.w3.org/2000/svg'; const INSERT_BEFORE_BEGIN = 'beforebegin'; const INSERT_AFTER_BEGIN = 'afterbegin'; const INSERT_BEFORE_END = 'beforeend'; /* Encoding notes We use 30 bit integers for encoding, so that we don't ever encode a non-SMI integer to push on the stack. Handles are >= 0 Immediates are < 0 True, False, Undefined and Null are pushed as handles into the symbol table, with well known handles (0, 1, 2, 3) The negative space is divided into positives and negatives. Positives are higher numbers (-1, -2, -3, etc), negatives are lower. We only encode immediates for two reasons: 1. To transfer over the wire, so they're smaller in general 2. When pushing values onto the stack from the low level/inner VM, which may be converted into WASM one day. This allows the low-level VM to always use SMIs, and to minimize using JS values via handles for things like the stack pointer and frame pointer. Externally, most code pushes values as JS values, except when being pulled from the append byte code where it was already encoded. Logically, this is because the low level VM doesn't really care about these higher level values. For instance, the result of a userland helper may be a number, or a boolean, or undefined/null, but it's extra work to figure that out and push it correctly, vs. just pushing the value as a JS value with a handle. Note: The details could change here in the future, this is just the current strategy. */ let ImmediateConstants = /*#__PURE__*/function (ImmediateConstants) { ImmediateConstants[ImmediateConstants["MAX_SMI"] = 1073741823] = "MAX_SMI"; ImmediateConstants[ImmediateConstants["MIN_SMI"] = -1073741824] = "MIN_SMI"; ImmediateConstants[ImmediateConstants["SIGN_BIT"] = -536870913] = "SIGN_BIT"; ImmediateConstants[ImmediateConstants["MAX_INT"] = 536870911] = "MAX_INT"; ImmediateConstants[ImmediateConstants["MIN_INT"] = -536870912] = "MIN_INT"; ImmediateConstants[ImmediateConstants["FALSE_HANDLE"] = 0] = "FALSE_HANDLE"; ImmediateConstants[ImmediateConstants["TRUE_HANDLE"] = 1] = "TRUE_HANDLE"; ImmediateConstants[ImmediateConstants["NULL_HANDLE"] = 2] = "NULL_HANDLE"; ImmediateConstants[ImmediateConstants["UNDEFINED_HANDLE"] = 3] = "UNDEFINED_HANDLE"; ImmediateConstants[ImmediateConstants["ENCODED_FALSE_HANDLE"] = 0] = "ENCODED_FALSE_HANDLE"; ImmediateConstants[ImmediateConstants["ENCODED_TRUE_HANDLE"] = 1] = "ENCODED_TRUE_HANDLE"; ImmediateConstants[ImmediateConstants["ENCODED_NULL_HANDLE"] = 2] = "ENCODED_NULL_HANDLE"; ImmediateConstants[ImmediateConstants["ENCODED_UNDEFINED_HANDLE"] = 3] = "ENCODED_UNDEFINED_HANDLE"; return ImmediateConstants; }({}); function isHandle(value) { return value >= 0; } function constants(...values) { return [false, true, null, undefined, ...values]; } function isSmallInt(value) { return value % 1 === 0 && value <= ImmediateConstants.MAX_INT && value >= ImmediateConstants.MIN_INT; } function encodeNegative(num) { return num & ImmediateConstants.SIGN_BIT; } function decodeNegative(num) { return num | ~ImmediateConstants.SIGN_BIT; } function encodePositive(num) { return ~num; } function decodePositive(num) { return ~num; } function encodeHandle(num) { return num; } function decodeHandle(num) { return num; } function encodeImmediate(num) { num |= 0; return num < 0 ? encodeNegative(num) : encodePositive(num); } function decodeImmediate(num) { num |= 0; return num > ImmediateConstants.SIGN_BIT ? decodePositive(num) : decodeNegative(num); } [1, -1].forEach(x => decodeImmediate(encodeImmediate(x))); let assign = Object.assign; function castToSimple(node) { if (isDocument(node)) { return node; } else if (isSimpleElement(node)) { return node; } else { return node; } } // If passed a document, verify we're in the browser and return it as a Document // If we don't know what this is, but the check requires it to be an element, // the cast will mandate that it's a browser element // Finally, if it's a more generic check, the cast will mandate that it's a // browser node and return a BrowserNodeUtils corresponding to the check function castToBrowser(node, sugaryCheck) { if (node === null || node === undefined) { return null; } if (typeof document === undefined) { throw new Error('Attempted to cast to a browser node in a non-browser context'); } if (isDocument(node)) { return node; } if (node.ownerDocument !== document) { throw new Error('Attempted to cast to a browser node with a node that was not created from this document'); } return checkBrowserNode(node, sugaryCheck); } function checkError(from, check) { return new Error(`cannot cast a ${from} into ${String(check)}`); } function isDocument(node) { return node.nodeType === DOCUMENT_NODE; } function isSimpleElement(node) { return node?.nodeType === ELEMENT_NODE; } function checkBrowserNode(node, check) { let isMatch = false; if (node !== null) { if (typeof check === 'string') { isMatch = stringCheckNode(node, check); } else if (Array.isArray(check)) { isMatch = check.some(c => stringCheckNode(node, c)); } else { throw unreachable(); } } if (isMatch && node instanceof Node) { return node; } else { throw checkError(`SimpleElement(${node?.constructor?.name ?? 'null'})`, check); } } function stringCheckNode(node, check) { switch (check) { case 'NODE': return true; case 'HTML': return node instanceof HTMLElement; case 'SVG': return node instanceof SVGElement; case 'ELEMENT': return node instanceof Element; default: if (check.toUpperCase() === check) { throw new Error(`BUG: this code is missing handling for a generic node type`); } return node instanceof Element && node.tagName.toLowerCase() === check; } } function unwrapHandle(handle) { if (typeof handle === 'number') { return handle; } else { let error = handle.errors[0]; throw new Error(`Compile Error: ${error.problem} @ ${error.span.start}..${error.span.end}`); } } function unwrapTemplate(template) { if (template.result === 'error') { throw new Error(`Compile Error: ${template.problem} @ ${template.span.start}..${template.span.end}`); } return template; } function buildUntouchableThis(source) { let context = null; { let assertOnProperty = property => { let access = typeof property === 'symbol' || typeof property === 'number' ? `[${String(property)}]` : `.${property}`; throw new Error(`You accessed \`this${access}\` from a function passed to the ${source}, but the function itself was not bound to a valid \`this\` context. Consider updating to use a bound function (for instance, use an arrow function, \`() => {}\`).`); }; context = new Proxy({}, { get(_target, property) { assertOnProperty(property); }, set(_target, property) { assertOnProperty(property); return false; }, has(_target, property) { assertOnProperty(property); return false; } }); } return context; } // These are the default production build versions: const noop$3 = () => {}; // SAFETY: these casts are just straight-up lies, but the point is that they do // not do anything in production builds. let assert$1 = noop$3; let info = noop$3; let warn = noop$3; let debug$1 = noop$3; let deprecate = noop$3; let debugFreeze = noop$3; let setDebugFunction = noop$3; { setDebugFunction = function (type, callback) { switch (type) { case 'assert': return assert$1 = callback; case 'info': return info = callback; case 'warn': return warn = callback; case 'debug': return debug$1 = callback; case 'deprecate': return deprecate = callback; case 'debugSeal': return callback; case 'debugFreeze': return debugFreeze = callback; case 'runInDebug': return callback; case 'deprecateFunc': return callback; } }; } /** @module @ember/debug */ { /** Verify that a certain expectation is met, or throw a exception otherwise. This is useful for communicating assumptions in the code to other human readers as well as catching bugs that accidentally violates these expectations. Assertions are removed from production builds, so they can be freely added