ember-source
Version:
A JavaScript framework for creating ambitious web applications
50 lines (45 loc) • 2.54 kB
JavaScript
import '../-internals/meta/lib/meta.js';
export { g as guidFor } from '../../shared-chunks/mandatory-setter-DHZe7-kW.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 { E as addListener } from '../../shared-chunks/observers-Bj9qLVau.js';
export { g as cacheFor } from '../../shared-chunks/computed_cache-DmYKevAP.js';
import '../-internals/environment/index.js';
import EmberObject from './index.js';
import { assert } from '../debug/lib/assert.js';
// Here we have runtime shenanigans to add debug-only errors to the class in dev
// builds. Those runtime shenanigans produce the need for type-level shenanigans
// to match: if we just assign without an explicit type annotation on the `let`
// binding below for `FrameworkObject`, TS gets stuck because this creates
// `FrameworkObject` with a class expression (rather than the usual class
// declaration form). That in turn means TS needs to be able to fully name the
// type produced by the class expression, which includes the `OWNER` symbol from
// `@glimmer/owner`.
//
// By explicitly giving the declaration a type when assigning it the class
// expression, instead of relying on inference, TS no longer needs to name the
// `OWNER` property key from the super class, eliminating the private name
// shenanigans.
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
let FrameworkObject = class FrameworkObject extends EmberObject {};
{
const INIT_WAS_CALLED = Symbol('INIT_WAS_CALLED');
let ASSERT_INIT_WAS_CALLED = Symbol('ASSERT_INIT_WAS_CALLED');
FrameworkObject = class DebugFrameworkObject extends EmberObject {
[INIT_WAS_CALLED] = false;
init(properties) {
super.init(properties);
this[INIT_WAS_CALLED] = true;
}
[ASSERT_INIT_WAS_CALLED]() {
(!(this[INIT_WAS_CALLED]) && assert(`You must call \`super.init(...arguments);\` or \`this._super(...arguments)\` when overriding \`init\` on a framework object. Please update ${this} to call \`super.init(...arguments);\` from \`init\` when using native classes or \`this._super(...arguments)\` when using \`EmberObject.extend()\`.`, this[INIT_WAS_CALLED]));
}
};
addListener(FrameworkObject.prototype, 'init', null, ASSERT_INIT_WAS_CALLED);
}
export { FrameworkObject };