From b2f4d724708fa7597f6c041c93a211fa8015c03b Mon Sep 17 00:00:00 2001 From: Mike North Date: Thu, 20 Sep 2018 18:13:12 -0700 Subject: [PATCH] [ember] @ember/application as source of types, ember as re-export --- types/ember-mocha/tsconfig.json | 2 + types/ember-qunit/tsconfig.json | 4 + types/ember-resolver/ember-resolver-tests.ts | 2 +- types/ember-resolver/tsconfig.json | 2 + types/ember-test-helpers/tsconfig.json | 2 + types/ember/index.d.ts | 288 ++---------------- types/ember/tsconfig.json | 2 + .../-private/default-resolver.d.ts | 21 ++ .../-private/event-dispatcher.d.ts | 16 + .../ember__application/-private/registry.d.ts | 13 + types/ember__application/deprecations.d.ts | 37 ++- .../ember__application/globals-resolver.d.ts | 4 +- types/ember__application/index.d.ts | 135 +++++++- types/ember__application/instance.d.ts | 8 +- types/ember__application/resolver.d.ts | 4 +- types/ember__application/tsconfig.json | 6 + types/ember__application/types.d.ts | 30 ++ types/ember__test-helpers/tsconfig.json | 2 + types/ember__test/tsconfig.json | 4 + 19 files changed, 299 insertions(+), 283 deletions(-) create mode 100644 types/ember__application/-private/default-resolver.d.ts create mode 100644 types/ember__application/-private/event-dispatcher.d.ts create mode 100644 types/ember__application/-private/registry.d.ts create mode 100644 types/ember__application/types.d.ts diff --git a/types/ember-mocha/tsconfig.json b/types/ember-mocha/tsconfig.json index 33768e7c41..2c00d52341 100644 --- a/types/ember-mocha/tsconfig.json +++ b/types/ember-mocha/tsconfig.json @@ -15,6 +15,8 @@ "paths": { "@ember/engine": ["ember__engine"], "@ember/engine/*": ["ember__engine/*"], + "@ember/application": ["ember__application"], + "@ember/application/*": ["ember__application/*"], "@ember/object": ["ember__object"], "@ember/object/*": ["ember__object/*"] }, diff --git a/types/ember-qunit/tsconfig.json b/types/ember-qunit/tsconfig.json index 86590138a0..3b9170403c 100644 --- a/types/ember-qunit/tsconfig.json +++ b/types/ember-qunit/tsconfig.json @@ -14,6 +14,10 @@ "../" ], "paths": { + "@ember/engine": ["ember__engine"], + "@ember/engine/*": ["ember__engine/*"], + "@ember/application": ["ember__application"], + "@ember/application/*": ["ember__application/*"], "@ember/object": ["ember__object"], "@ember/object/*": ["ember__object/*"] }, diff --git a/types/ember-resolver/ember-resolver-tests.ts b/types/ember-resolver/ember-resolver-tests.ts index 6973daeda0..ac348f1d79 100644 --- a/types/ember-resolver/ember-resolver-tests.ts +++ b/types/ember-resolver/ember-resolver-tests.ts @@ -1,5 +1,5 @@ import EmberResolver from 'ember-resolver'; -import { Ember } from 'ember'; +import Ember from 'ember'; const MyResolver = EmberResolver.extend({ pluralizedTypes: { diff --git a/types/ember-resolver/tsconfig.json b/types/ember-resolver/tsconfig.json index 60667c8a52..e8dfb6e8ce 100644 --- a/types/ember-resolver/tsconfig.json +++ b/types/ember-resolver/tsconfig.json @@ -15,6 +15,8 @@ "paths": { "@ember/engine": ["ember__engine"], "@ember/engine/*": ["ember__engine/*"], + "@ember/application": ["ember__application"], + "@ember/application/*": ["ember__application/*"], "@ember/object": ["ember__object"], "@ember/object/*": ["ember__object/*"] }, diff --git a/types/ember-test-helpers/tsconfig.json b/types/ember-test-helpers/tsconfig.json index a6e8d61ba8..2d9eb44d16 100644 --- a/types/ember-test-helpers/tsconfig.json +++ b/types/ember-test-helpers/tsconfig.json @@ -16,6 +16,8 @@ "paths": { "@ember/engine": ["ember__engine"], "@ember/engine/*": ["ember__engine/*"], + "@ember/application": ["ember__application"], + "@ember/application/*": ["ember__application/*"], "@ember/object": ["ember__object"], "@ember/object/*": ["ember__object/*"] }, diff --git a/types/ember/index.d.ts b/types/ember/index.d.ts index 6c74cde8ee..1a13bc5a68 100755 --- a/types/ember/index.d.ts +++ b/types/ember/index.d.ts @@ -24,6 +24,7 @@ /// /// /// +/// declare module 'ember' { import { @@ -65,6 +66,9 @@ declare module 'ember' { import _ContainerProxyMixin from '@ember/engine/-private/container-proxy-mixin'; import _RegistryProxyMixin from '@ember/engine/-private/registry-proxy-mixin'; import EmberCoreObject from '@ember/object/core'; + import * as EmberApplicationNs from '@ember/application'; + import * as EmberApplicationInstanceNs from '@ember/application/instance'; + import * as EmberApplicationDeprecateNs from '@ember/application/deprecations'; // tslint:disable-next-line:no-duplicate-imports import * as EmberControllerNs from '@ember/controller'; // tslint:disable-next-line:no-duplicate-imports @@ -96,6 +100,11 @@ declare module 'ember' { import EmberRoutingHistoryLocation from '@ember/routing/history-location'; import EmberRoutingNoneLocation from '@ember/routing/none-location'; import EmberRoutingLinkComponent from '@ember/routing/link-component'; + // @ember/application + import EmberDefaultResolver from '@ember/application/-private/default-resolver'; + import EmberEventDispatcher from '@ember/application/-private/event-dispatcher'; + import EmberRegistry from '@ember/application/-private/registry'; + import EmberResolver from '@ember/application/resolver'; type Mix = B & Pick>; type Mix3 = Mix, C>; @@ -132,37 +141,6 @@ declare module 'ember' { | 'afterRender' | 'destroy'; - interface EventDispatcherEvents { - touchstart?: string | null; - touchmove?: string | null; - touchend?: string | null; - touchcancel?: string | null; - keydown?: string | null; - keyup?: string | null; - keypress?: string | null; - mousedown?: string | null; - mouseup?: string | null; - contextmenu?: string | null; - click?: string | null; - dblclick?: string | null; - mousemove?: string | null; - focusin?: string | null; - focusout?: string | null; - mouseenter?: string | null; - mouseleave?: string | null; - submit?: string | null; - input?: string | null; - change?: string | null; - dragstart?: string | null; - drag?: string | null; - dragenter?: string | null; - dragleave?: string | null; - dragover?: string | null; - drop?: string | null; - dragend?: string | null; - [event: string]: string | null | undefined; - } - /** * Ember.CoreView is an abstract class that exists to give view-like behavior to both Ember's main * view class Ember.Component and other classes that don't need the full functionality of Ember.Component. @@ -198,6 +176,14 @@ declare module 'ember' { export class NoneLocation extends EmberRoutingNoneLocation {} export class HistoryLocation extends EmberRoutingHistoryLocation {} export class LinkComponent extends EmberRoutingLinkComponent {} + const deprecateFunc: typeof EmberApplicationDeprecateNs.deprecateFunc; + const deprecate: typeof EmberApplicationDeprecateNs.deprecate; + const getOwner: typeof EmberApplicationNs.getOwner; + const setOwner: typeof EmberApplicationNs.setOwner; + class DefaultResolver extends EmberDefaultResolver {} + class Resolver extends EmberResolver {} + class EventDispatcher extends EmberEventDispatcher {} + class Registry extends EmberRegistry {} interface FunctionPrototypeExtensions { /** * The `property` extension of Javascript's Function prototype is available @@ -232,109 +218,6 @@ declare module 'ember' { w(): string[]; } - /** - * An instance of Ember.Application is the starting point for every Ember application. It helps to - * instantiate, initialize and coordinate the many objects that make up your app. - */ - class Application extends EmberEngineNs.default { - /** - * Call advanceReadiness after any asynchronous setup logic has completed. - * Each call to deferReadiness must be matched by a call to advanceReadiness - * or the application will never become ready and routing will not begin. - */ - advanceReadiness(): void; - /** - * Use this to defer readiness until some condition is true. - * - * This allows you to perform asynchronous setup logic and defer - * booting your application until the setup has finished. - * - * However, if the setup requires a loading UI, it might be better - * to use the router for this purpose. - */ - deferReadiness(): void; - /** - * defines an injection or typeInjection - */ - inject(factoryNameOrType: string, property: string, injectionName: string): void; - /** - * This injects the test helpers into the window's scope. If a function of the - * same name has already been defined it will be cached (so that it can be reset - * if the helper is removed with `unregisterHelper` or `removeTestHelpers`). - * Any callbacks registered with `onInjectHelpers` will be called once the - * helpers have been injected. - */ - injectTestHelpers(): void; - /** - * registers a factory for later injection - * @param fullName type:name (e.g., 'model:user') - * @param factory (e.g., App.Person) - */ - register(fullName: string, factory: any): void; - /** - * This removes all helpers that have been registered, and resets and functions - * that were overridden by the helpers. - */ - removeTestHelpers(): void; - /** - * Reset the application. This is typically used only in tests. - */ - reset(): void; - /** - * This hook defers the readiness of the application, so that you can start - * the app when your tests are ready to run. It also sets the router's - * location to 'none', so that the window's location will not be modified - * (preventing both accidental leaking of state between tests and interference - * with your testing framework). - */ - setupForTesting(): void; - /** - * The DOM events for which the event dispatcher should listen. - */ - customEvents: EventDispatcherEvents; - /** - * The Ember.EventDispatcher responsible for delegating events to this application's views. - */ - eventDispatcher: EventDispatcher; - /** - * Set this to provide an alternate class to Ember.DefaultResolver - */ - resolver: DefaultResolver; - /** - * The root DOM element of the Application. This can be specified as an - * element or a jQuery-compatible selector string. - * - * This is the element that will be passed to the Application's, eventDispatcher, - * which sets up the listeners for event delegation. Every view in your application - * should be a child of the element you specify here. - */ - rootElement: HTMLElement | string; - /** - * Called when the Application has become ready. - * The call will be delayed until the DOM has become ready. - */ - ready: (...args: any[]) => any; - /** - * Application's router. - */ - Router: Router; - registry: Registry; - /** - * Initialize the application and return a promise that resolves with the `Application` - * object when the boot process is complete. - */ - boot(): Promise; - /** - * Create an ApplicationInstance for this Application. - */ - buildInstance(options?: object): ApplicationInstance; - } - /** - * The `ApplicationInstance` encapsulates all of the stateful aspects of a - * running `Application`. - */ - class ApplicationInstance extends EngineInstance {} - /** * Connects the properties of two objects so that whenever the value of one property changes, * the other property will be changed also. @@ -384,25 +267,6 @@ declare module 'ember' { registerDeprecationHandler: typeof EmberDebugNs.registerDeprecationHandler; registerWarnHandler: typeof EmberDebugNs.registerWarnHandler; }; - /** - * The DefaultResolver defines the default lookup rules to resolve - * container lookups before consulting the container for registered - * items: - */ - class DefaultResolver extends Resolver { - /** - * This method is called via the container's resolver method. - * It parses the provided `fullName` and then looks up and - * returns the appropriate template or class. - */ - resolve(fullName: string): {}; - /** - * This will be set to the Application instance when it is - * created. - */ - namespace: Application; - } - class EngineInstance extends EmberEngineInstanceNs.default {} class Engine extends EmberEngineNs.default {} @@ -410,20 +274,7 @@ declare module 'ember' { * A subclass of the JavaScript Error object for use in Ember. */ const Error: ErrorConstructor; - /** - * `Ember.EventDispatcher` handles delegating browser events to their - * corresponding `Ember.Views.` For example, when you click on a view, - * `Ember.EventDispatcher` ensures that that view's `mouseDown` method gets - * called. - */ - class EventDispatcher extends Object { - /** - * The set of events names (and associated handler function names) to be setup - * and dispatched by the `EventDispatcher`. Modifications to this list can be done - * at setup time, generally via the `Ember.Application.customEvents` hash. - */ - events: EventDispatcherEvents; - } + const Evented: typeof EmberObjectEventedNs.default; /** * The `Ember.Freezable` mixin implements some basic methods for marking an @@ -525,19 +376,6 @@ declare module 'ember' { toArray(): any[]; } - /** - * A registry used to store factory and option information keyed - * by type. - */ - class Registry { - register( - fullName: string, - factory: EmberClassConstructor, - options?: { singleton?: boolean } - ): void; - } - class Resolver extends Ember.Object {} - class Service extends Object {} interface Transition { /** @@ -566,7 +404,8 @@ declare module 'ember' { namespace RSVP { type Promise = Rsvp.Promise; } - + class Application extends EmberApplicationNs.default {} + class ApplicationInstance extends EmberApplicationInstanceNs.default {} /** * This is a container for an assortment of testing related functionality */ @@ -1049,41 +888,10 @@ declare module 'ember' { * `getEngineParent` retrieves an engine instance's parent instance. */ function getEngineParent(engine: EngineInstance): EngineInstance; - /** - * Display a deprecation warning with the provided message and a stack trace - * (Chrome and Firefox only). - */ - function deprecate( - message: string, - test: boolean, - options: { id: string; until: string } - ): any; - /** - * @deprecated Missing deprecation options: https://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options - */ - function deprecate( - message: string, - test: boolean, - options?: { id?: string; until?: string } - ): any; + const assert: typeof EmberDebugNs.assert; const debug: typeof EmberDebugNs.debug; const defineProperty: typeof EmberObjectNs.defineProperty; - /** - * Alias an old, deprecated method with its new counterpart. - */ - function deprecateFunc any)>( - message: string, - options: { id: string; until: string }, - func: Func - ): Func; - /** - * @deprecated Missing deprecation options: https://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options - */ - function deprecateFunc any)>( - message: string, - func: Func - ): Func; export const runInDebug: typeof EmberDebugNs.runInDebug; export const warn: typeof EmberDebugNs.warn; @@ -1115,17 +923,6 @@ declare module 'ember' { const setProperties: typeof EmberObjectNs.setProperties; const set: typeof EmberObjectNs.set; const trySet: typeof EmberObjectNs.trySet; - - /** - * Detects when a specific package of Ember (e.g. 'Ember.Application') - * has fully loaded and is available for extension. - */ - function onLoad(name: string, callback: (...args: any[]) => any): any; - /** - * Called when an Ember.js package (e.g Ember.Application) has finished - * loading. Triggers any callbacks registered for this event. - */ - function runLoadHooks(name: string, object?: {}): any; const compare: typeof EmberUtilsNs.compare; /** * Creates a shallow copy of the passed object. A deep copy of the object is @@ -1153,18 +950,7 @@ declare module 'ember' { const guidFor: typeof EmberObjectInternalsNs.guidFor; const inspect: typeof EmberDebugNs.inspect; const tryInvoke: typeof EmberUtilsNs.tryInvoke; - /** - * Framework objects in an Ember application (components, services, routes, etc.) - * are created via a factory and dependency injection system. Each of these - * objects is the responsibility of an "owner", which handled its - * instantiation and manages its lifetime. - */ - function getOwner(object: any): any; - /** - * `setOwner` forces a new owner on a given object instance. This is primarily - * useful in some testing cases. - */ - function setOwner(object: any, owner: any): void; + /** * A function may be assigned to `Ember.onerror` to be called when Ember * internals encounter an error. This is useful for specialized error handling @@ -1210,36 +996,6 @@ declare module 'ember' { export default Ember; } -declare module '@ember/application' { - import Ember from 'ember'; - export default class Application extends Ember.Application { } - export const getOwner: typeof Ember.getOwner; - export const onLoad: typeof Ember.onLoad; - export const runLoadHooks: typeof Ember.runLoadHooks; - export const setOwner: typeof Ember.setOwner; -} - -declare module '@ember/application/deprecations' { - import Ember from 'ember'; - export const deprecate: typeof Ember.deprecate; - export const deprecateFunc: typeof Ember.deprecateFunc; -} - -declare module '@ember/application/globals-resolver' { - import Ember from 'ember'; - export default class GlobalsResolver extends Ember.DefaultResolver { } -} - -declare module '@ember/application/instance' { - import Ember from 'ember'; - export default class ApplicationInstance extends Ember.ApplicationInstance { } -} - -declare module '@ember/application/resolver' { - import Ember from 'ember'; - export default class Resolver extends Ember.Resolver { } -} - declare module '@ember/error' { import Ember from 'ember'; const Error: typeof Ember.Error; diff --git a/types/ember/tsconfig.json b/types/ember/tsconfig.json index 8674555752..dc4e29326d 100755 --- a/types/ember/tsconfig.json +++ b/types/ember/tsconfig.json @@ -30,6 +30,8 @@ "@ember/object/*": ["ember__object/*"], "@ember/component": ["ember__component"], "@ember/component/*": ["ember__component/*"], + "@ember/application": ["ember__application"], + "@ember/application/*": ["ember__application/*"], "@ember/controller": ["ember__controller"], "@ember/polyfills": ["ember__polyfills"] }, diff --git a/types/ember__application/-private/default-resolver.d.ts b/types/ember__application/-private/default-resolver.d.ts new file mode 100644 index 0000000000..85cc676e24 --- /dev/null +++ b/types/ember__application/-private/default-resolver.d.ts @@ -0,0 +1,21 @@ +import Resolver from "@ember/engine/-private/resolver"; +import Application from "@ember/application"; + +/** + * The DefaultResolver defines the default lookup rules to resolve + * container lookups before consulting the container for registered + * items: + */ +export default class DefaultResolver extends Resolver { + /** + * This method is called via the container's resolver method. + * It parses the provided `fullName` and then looks up and + * returns the appropriate template or class. + */ + resolve(fullName: string): {}; + /** + * This will be set to the Application instance when it is + * created. + */ + namespace: Application; +} diff --git a/types/ember__application/-private/event-dispatcher.d.ts b/types/ember__application/-private/event-dispatcher.d.ts new file mode 100644 index 0000000000..d70217cc5f --- /dev/null +++ b/types/ember__application/-private/event-dispatcher.d.ts @@ -0,0 +1,16 @@ +import { EventDispatcherEvents } from "@ember/application/types"; + +/** + * `Ember.EventDispatcher` handles delegating browser events to their + * corresponding `Ember.Views.` For example, when you click on a view, + * `Ember.EventDispatcher` ensures that that view's `mouseDown` method gets + * called. + */ +export default class EventDispatcher extends Object { + /** + * The set of events names (and associated handler function names) to be setup + * and dispatched by the `EventDispatcher`. Modifications to this list can be done + * at setup time, generally via the `Ember.Application.customEvents` hash. + */ + events: EventDispatcherEvents; +} diff --git a/types/ember__application/-private/registry.d.ts b/types/ember__application/-private/registry.d.ts new file mode 100644 index 0000000000..94ed25ef9a --- /dev/null +++ b/types/ember__application/-private/registry.d.ts @@ -0,0 +1,13 @@ +import { EmberClassConstructor } from "@ember/object/-private/types"; + +/** + * A registry used to store factory and option information keyed + * by type. + */ +export default class Registry { + register( + fullName: string, + factory: EmberClassConstructor, + options?: { singleton?: boolean } + ): void; +} diff --git a/types/ember__application/deprecations.d.ts b/types/ember__application/deprecations.d.ts index 608ba5c7f7..a74babd084 100644 --- a/types/ember__application/deprecations.d.ts +++ b/types/ember__application/deprecations.d.ts @@ -1,4 +1,35 @@ -import Ember from 'ember'; +/** + * Display a deprecation warning with the provided message and a stack trace + * (Chrome and Firefox only). + */ +export function deprecate( + message: string, + test: boolean, + options: { id: string; until: string } +): any; -export const deprecate: typeof Ember.deprecate; -export const deprecateFunc: typeof Ember.deprecateFunc; +/** + * @deprecated Missing deprecation options: https://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options + */ +export function deprecate( + message: string, + test: boolean, + options?: { id?: string; until?: string } +): any; + +/** + * @deprecated Missing deprecation options: https://emberjs.com/deprecations/v2.x/#toc_ember-debug-function-options + */ +export function deprecateFunc any)>( + message: string, + func: Func +): Func; + +/** + * Alias an old, deprecated method with its new counterpart. + */ +export function deprecateFunc any)>( + message: string, + options: { id: string; until: string }, + func: Func +): Func; diff --git a/types/ember__application/globals-resolver.d.ts b/types/ember__application/globals-resolver.d.ts index e51f4681ed..5cb428ad5c 100644 --- a/types/ember__application/globals-resolver.d.ts +++ b/types/ember__application/globals-resolver.d.ts @@ -1,3 +1 @@ -import Ember from 'ember'; - -export default class GlobalsResolver extends Ember.DefaultResolver { } +export { default } from '@ember/application/-private/default-resolver'; diff --git a/types/ember__application/index.d.ts b/types/ember__application/index.d.ts index cdef372444..aa1a5a1889 100644 --- a/types/ember__application/index.d.ts +++ b/types/ember__application/index.d.ts @@ -4,10 +4,133 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 -import Ember from 'ember'; +import Engine from '@ember/engine'; +import ApplicationInstance from '@ember/application/instance'; +import EventDispatcher from '@ember/application/-private/event-dispatcher'; +import { EventDispatcherEvents } from '@ember/application/types'; +import DefaultResolver from '@ember/application/-private/default-resolver'; +import { Router } from '@ember/routing'; +import Registry from '@ember/application/-private/registry'; -export default class Application extends Ember.Application { } -export const getOwner: typeof Ember.getOwner; -export const onLoad: typeof Ember.onLoad; -export const runLoadHooks: typeof Ember.runLoadHooks; -export const setOwner: typeof Ember.setOwner; +/** + * An instance of Ember.Application is the starting point for every Ember application. It helps to + * instantiate, initialize and coordinate the many objects that make up your app. + */ +export default class Application extends Engine { + /** + * Call advanceReadiness after any asynchronous setup logic has completed. + * Each call to deferReadiness must be matched by a call to advanceReadiness + * or the application will never become ready and routing will not begin. + */ + advanceReadiness(): void; + /** + * Use this to defer readiness until some condition is true. + * + * This allows you to perform asynchronous setup logic and defer + * booting your application until the setup has finished. + * + * However, if the setup requires a loading UI, it might be better + * to use the router for this purpose. + */ + deferReadiness(): void; + /** + * defines an injection or typeInjection + */ + inject(factoryNameOrType: string, property: string, injectionName: string): void; + /** + * This injects the test helpers into the window's scope. If a function of the + * same name has already been defined it will be cached (so that it can be reset + * if the helper is removed with `unregisterHelper` or `removeTestHelpers`). + * Any callbacks registered with `onInjectHelpers` will be called once the + * helpers have been injected. + */ + injectTestHelpers(): void; + /** + * registers a factory for later injection + * @param fullName type:name (e.g., 'model:user') + * @param factory (e.g., App.Person) + */ + register(fullName: string, factory: any): void; + /** + * This removes all helpers that have been registered, and resets and functions + * that were overridden by the helpers. + */ + removeTestHelpers(): void; + /** + * Reset the application. This is typically used only in tests. + */ + reset(): void; + /** + * This hook defers the readiness of the application, so that you can start + * the app when your tests are ready to run. It also sets the router's + * location to 'none', so that the window's location will not be modified + * (preventing both accidental leaking of state between tests and interference + * with your testing framework). + */ + setupForTesting(): void; + /** + * The DOM events for which the event dispatcher should listen. + */ + customEvents: EventDispatcherEvents; + /** + * The Ember.EventDispatcher responsible for delegating events to this application's views. + */ + eventDispatcher: EventDispatcher; + /** + * Set this to provide an alternate class to Ember.DefaultResolver + */ + resolver: DefaultResolver; + /** + * The root DOM element of the Application. This can be specified as an + * element or a jQuery-compatible selector string. + * + * This is the element that will be passed to the Application's, eventDispatcher, + * which sets up the listeners for event delegation. Every view in your application + * should be a child of the element you specify here. + */ + rootElement: HTMLElement | string; + /** + * Called when the Application has become ready. + * The call will be delayed until the DOM has become ready. + */ + ready: (...args: any[]) => any; + /** + * Application's router. + */ + Router: Router; + registry: Registry; + /** + * Initialize the application and return a promise that resolves with the `Application` + * object when the boot process is complete. + */ + boot(): Promise; + /** + * Create an ApplicationInstance for this Application. + */ + buildInstance(options?: object): ApplicationInstance; +} + +/** + * Framework objects in an Ember application (components, services, routes, etc.) + * are created via a factory and dependency injection system. Each of these + * objects is the responsibility of an "owner", which handled its + * instantiation and manages its lifetime. + */ +export function getOwner(object: any): any; +/** + * `setOwner` forces a new owner on a given object instance. This is primarily + * useful in some testing cases. + */ +export function setOwner(object: any, owner: any): void; + +/** + * Detects when a specific package of Ember (e.g. 'Ember.Application') + * has fully loaded and is available for extension. + */ +export function onLoad(name: string, callback: (...args: any[]) => any): any; + +/** + * Called when an Ember.js package (e.g Ember.Application) has finished + * loading. Triggers any callbacks registered for this event. + */ +export function runLoadHooks(name: string, object?: {}): any; diff --git a/types/ember__application/instance.d.ts b/types/ember__application/instance.d.ts index 0d01298d52..db5f37fcd5 100644 --- a/types/ember__application/instance.d.ts +++ b/types/ember__application/instance.d.ts @@ -1,3 +1,7 @@ -import Ember from 'ember'; +import EngineInstance from "@ember/engine/instance"; -export default class ApplicationInstance extends Ember.ApplicationInstance { } +/** + * The `ApplicationInstance` encapsulates all of the stateful aspects of a + * running `Application`. + */ +export default class ApplicationInstance extends EngineInstance {} diff --git a/types/ember__application/resolver.d.ts b/types/ember__application/resolver.d.ts index a218fcd3e7..326352ac49 100644 --- a/types/ember__application/resolver.d.ts +++ b/types/ember__application/resolver.d.ts @@ -1,3 +1,3 @@ -import Ember from 'ember'; +import EmberObject from '@ember/object'; -export default class Resolver extends Ember.Resolver { } +export default class Resolver extends EmberObject {} diff --git a/types/ember__application/tsconfig.json b/types/ember__application/tsconfig.json index 7be641d164..c83da0b13d 100644 --- a/types/ember__application/tsconfig.json +++ b/types/ember__application/tsconfig.json @@ -19,6 +19,8 @@ "@ember/object/*": ["ember__object/*"], "@ember/engine": ["ember__engine"], "@ember/engine/*": ["ember__engine/*"], + "@ember/routing": ["ember__routing"], + "@ember/routing/*": ["ember__routing/*"], "@ember/application": ["ember__application"], "@ember/application/*": ["ember__application/*"] }, @@ -32,6 +34,10 @@ "index.d.ts", "instance.d.ts", "resolver.d.ts", + "types.d.ts", + "-private/default-resolver.d.ts", + "-private/event-dispatcher.d.ts", + "-private/registry.d.ts", "test/application.ts", "test/deprecations.ts", "test/resolver.ts", diff --git a/types/ember__application/types.d.ts b/types/ember__application/types.d.ts new file mode 100644 index 0000000000..aa5d41877c --- /dev/null +++ b/types/ember__application/types.d.ts @@ -0,0 +1,30 @@ +export interface EventDispatcherEvents { + touchstart?: string | null; + touchmove?: string | null; + touchend?: string | null; + touchcancel?: string | null; + keydown?: string | null; + keyup?: string | null; + keypress?: string | null; + mousedown?: string | null; + mouseup?: string | null; + contextmenu?: string | null; + click?: string | null; + dblclick?: string | null; + mousemove?: string | null; + focusin?: string | null; + focusout?: string | null; + mouseenter?: string | null; + mouseleave?: string | null; + submit?: string | null; + input?: string | null; + change?: string | null; + dragstart?: string | null; + drag?: string | null; + dragenter?: string | null; + dragleave?: string | null; + dragover?: string | null; + drop?: string | null; + dragend?: string | null; + [event: string]: string | null | undefined; +} diff --git a/types/ember__test-helpers/tsconfig.json b/types/ember__test-helpers/tsconfig.json index 31f47f69cb..fe65a675b2 100644 --- a/types/ember__test-helpers/tsconfig.json +++ b/types/ember__test-helpers/tsconfig.json @@ -19,6 +19,8 @@ "paths": { "@ember/engine": ["ember__engine"], "@ember/engine/*": ["ember__engine/*"], + "@ember/application": ["ember__application"], + "@ember/application/*": ["ember__application/*"], "@ember/object": ["ember__object"], "@ember/object/*": ["ember__object/*"], "@ember/test-helpers": ["ember__test-helpers"] diff --git a/types/ember__test/tsconfig.json b/types/ember__test/tsconfig.json index 89f8c76b60..e5405575cc 100644 --- a/types/ember__test/tsconfig.json +++ b/types/ember__test/tsconfig.json @@ -15,6 +15,10 @@ "../" ], "paths": { + "@ember/engine": ["ember__engine"], + "@ember/engine/*": ["ember__engine/*"], + "@ember/application": ["ember__application"], + "@ember/application/*": ["ember__application/*"], "@ember/test": ["ember__test"], "@ember/test/*": ["ember__test/*"] },