Files
NativeScript/tns-core-modules/application/application-common.ts
Hristo Deshev b45cbe929b No more ambient modules for tns-core-modules/* subpackages.
- Use path mappings in tsconfig.json to resolve module typings
- Only use ambient mobules for global API's
- Move single-file modules to a subdir with the same name so that
we can provide a hand-written typing next to it (via package.json)
- Delete all mentions of tns-core-modules.d.ts
- Delete reference d.ts assembly build steps. Not needed anymore.
- HACK! Use a <reference> for global typings in application.d.ts
to avoid publishing a separate @types/tns-core-modules package.
- Rename declarations.d.ts to tns-core-modules.d.ts to preserve
JS project mappings in references.d.ts (the only place we use those)
2017-03-07 17:59:02 +02:00

62 lines
1.9 KiB
TypeScript

// Require globals first so that snapshot takes __extends function.
require("globals");
import { Observable, EventData } from "data/observable";
const events = new Observable();
// First merge all functions from events into application-common so that later appModule.on will be defined.
global.moduleMerge(events, exports);
export { Observable };
import { UnhandledErrorEventData, iOSApplication, AndroidApplication, CssChangedEventData } from "application";
import { NavigationEntry } from "ui/frame";
export const launchEvent = "launch";
export const suspendEvent = "suspend";
export const resumeEvent = "resume";
export const exitEvent = "exit";
export const lowMemoryEvent = "lowMemory";
export const uncaughtErrorEvent = "uncaughtError";
export const orientationChangedEvent = "orientationChanged";
export let cssFile: string = "app.css";
export let mainModule: string;
export let mainEntry: NavigationEntry;
export let resources: any = {};
export function setResources(res: any) {
resources = res;
}
export let android = undefined;
export let ios = undefined;
export function notify(args: EventData): void {
events.notify(args);
}
let app: iOSApplication | AndroidApplication;
export function setApplication(instance: iOSApplication | AndroidApplication): void {
app = instance;
}
export function livesync() {
events.notify(<EventData>{ eventName: "livesync", object: app });
}
export function setCssFileName(cssFileName: string) {
exports.cssFile = cssFileName;
events.notify(<CssChangedEventData>{ eventName: "cssChanged", object: app, cssFile: cssFileName });
}
export function addCss(cssText: string): void {
events.notify(<CssChangedEventData>{ eventName: "cssChanged", object: app, cssText: cssText });
}
global.__onUncaughtError = function (error: NativeScriptError) {
events.notify(<UnhandledErrorEventData>{ eventName: uncaughtErrorEvent, object: app, android: error, ios: error, error: error });
}