UNPKG

ember-source

Version:

A JavaScript framework for creating ambitious web applications

75 lines (66 loc) 2.36 kB
import '../-internals/meta/lib/meta.js'; import { g as guidFor } from '../../shared-chunks/mandatory-setter-DHZe7-kW.js'; import { g as getName, s as setName } from '../../shared-chunks/name-Z7dpqvzn.js'; import '../debug/index.js'; import '../../@glimmer/destroyable/index.js'; import '../../@glimmer/validator/index.js'; import '../../shared-chunks/debug-to-string-CFb7h0lY.js'; import '../../@glimmer/global-context/index.js'; import '../../shared-chunks/reference-C3TKDRnP.js'; import '../../shared-chunks/capabilities-O_xc7Yqk.js'; import { g as get } from '../../shared-chunks/observers-Bj9qLVau.js'; import { N as NAMESPACES, a as NAMESPACES_BY_ID, p as processAllNamespaces, f as findNamespace, b as addNamespace, c as findNamespaces, d as processNamespace, r as removeNamespace } from '../../shared-chunks/namespace_search-uT8odThF.js'; import EmberObject from '../object/index.js'; import { assert } from '../debug/lib/assert.js'; /** @module @ember/application/namespace */ /** A Namespace is an object usually used to contain other objects or methods such as an application or framework. Create a namespace anytime you want to define one of these new containers. ## Example Usage ```javascript import Namespace from '@ember/application/namespace'; MyFramework = Namespace.create({ VERSION: '1.0.0' }); ``` @class Namespace @extends EmberObject @public */ class Namespace extends EmberObject { static NAMESPACES = NAMESPACES; static NAMESPACES_BY_ID = NAMESPACES_BY_ID; static processAll = processAllNamespaces; static byName = findNamespace; init(properties) { super.init(properties); addNamespace(this); } toString() { let existing_name = get(this, 'name') || get(this, 'modulePrefix'); if (existing_name) { (!(typeof existing_name === 'string') && assert("name wasn't a string", typeof existing_name === 'string')); return existing_name; } findNamespaces(); let name = getName(this); if (name === undefined) { name = guidFor(this); setName(this, name); } return name; } nameClasses() { processNamespace(this); } destroy() { removeNamespace(this); return super.destroy(); } } // Declare on the prototype to have a single shared value. Namespace.prototype.isNamespace = true; export { Namespace as default };