chore: cleanup

This commit is contained in:
Igor Randjelovic
2023-05-12 19:10:17 +02:00
parent 3f2496d445
commit 7e9752b9a0
3 changed files with 16 additions and 13 deletions

View File

@ -19,13 +19,11 @@ import {
ApplicationEventData, ApplicationEventData,
CssChangedEventData, CssChangedEventData,
DiscardedErrorEventData, DiscardedErrorEventData,
FontScaleChangedEventData,
LaunchEventData, LaunchEventData,
LoadAppCSSEventData, LoadAppCSSEventData,
NativeScriptError, NativeScriptError,
OrientationChangedEventData, OrientationChangedEventData,
SystemAppearanceChangedEventData, SystemAppearanceChangedEventData,
UnhandledErrorEventData,
} from './application-interfaces'; } from './application-interfaces';
const ORIENTATION_CSS_CLASSES = [ const ORIENTATION_CSS_CLASSES = [
@ -68,6 +66,8 @@ export class ApplicationCommon {
readonly systemAppearanceChangedEvent = 'systemAppearanceChanged'; readonly systemAppearanceChangedEvent = 'systemAppearanceChanged';
readonly fontScaleChangedEvent = 'fontScaleChanged'; readonly fontScaleChangedEvent = 'fontScaleChanged';
readonly livesyncEvent = 'livesync'; readonly livesyncEvent = 'livesync';
readonly loadAppCssEvent = 'loadAppCss';
readonly cssChangedEvent = 'cssChanged';
// Application events go through the global events. // Application events go through the global events.
readonly on: ApplicationEvents['on'] = globalEvents.on.bind(globalEvents); readonly on: ApplicationEvents['on'] = globalEvents.on.bind(globalEvents);
@ -107,6 +107,9 @@ export class ApplicationCommon {
}; };
} }
/**
* @internal
*/
livesync(rootView: View, context?: ModuleContext) { livesync(rootView: View, context?: ModuleContext) {
this.notify({ eventName: this.livesyncEvent, object: this }); this.notify({ eventName: this.livesyncEvent, object: this });
const liveSyncCore = global.__onLiveSyncCore; const liveSyncCore = global.__onLiveSyncCore;
@ -228,7 +231,11 @@ export class ApplicationCommon {
// implement in platform specific files (iOS only for now) // implement in platform specific files (iOS only for now)
} }
mainEntry: NavigationEntry; protected mainEntry: NavigationEntry;
/**
* @returns The main entry of the application
*/
getMainEntry() { getMainEntry() {
return this.mainEntry; return this.mainEntry;
} }
@ -248,6 +255,7 @@ export class ApplicationCommon {
return launchArgs.root; return launchArgs.root;
} }
@profile
createRootView(view?: View, fireLaunchEvent = false, additionalLanchEventData?: any) { createRootView(view?: View, fireLaunchEvent = false, additionalLanchEventData?: any) {
let rootView = view; let rootView = view;
@ -305,14 +313,14 @@ export class ApplicationCommon {
bindableResources.set(res); bindableResources.set(res);
} }
cssFile = './app.css'; private cssFile = './app.css';
/** /**
* Sets css file name for the application. * Sets css file name for the application.
*/ */
setCssFileName(cssFileName: string) { setCssFileName(cssFileName: string) {
this.cssFile = cssFileName; this.cssFile = cssFileName;
this.notify(<CssChangedEventData>{ this.notify(<CssChangedEventData>{
eventName: 'cssChanged', eventName: this.cssChangedEvent,
object: this, object: this,
cssFile: cssFileName, cssFile: cssFileName,
}); });
@ -334,7 +342,7 @@ export class ApplicationCommon {
loadAppCss(): void { loadAppCss(): void {
try { try {
this.notify(<LoadAppCSSEventData>{ this.notify(<LoadAppCSSEventData>{
eventName: 'loadAppCss', eventName: this.loadAppCssEvent,
object: this, object: this,
ios: this.ios, ios: this.ios,
android: this.android, android: this.android,
@ -353,7 +361,7 @@ export class ApplicationCommon {
addCss(cssText: string, attributeScoped?: boolean): void { addCss(cssText: string, attributeScoped?: boolean): void {
this.notify(<CssChangedEventData>{ this.notify(<CssChangedEventData>{
eventName: 'cssChanged', eventName: this.cssChangedEvent,
object: this, object: this,
cssText: cssText, cssText: cssText,
}); });

View File

@ -1,4 +1,3 @@
// Types
import type { ApplicationCommon } from '.'; import type { ApplicationCommon } from '.';
import type { EventData, Observable } from '../data/observable'; import type { EventData, Observable } from '../data/observable';
import type { View } from '../ui/core/view'; import type { View } from '../ui/core/view';

View File

@ -5,11 +5,7 @@ import { NavigationEntry } from '../ui/frame/frame-interfaces';
import * as Utils from '../utils'; import * as Utils from '../utils';
import type { iOSApplication as IiOSApplication } from './application'; import type { iOSApplication as IiOSApplication } from './application';
import { ApplicationCommon } from './application-common'; import { ApplicationCommon } from './application-common';
import { import { ApplicationEventData } from './application-interfaces';
ApplicationEventData,
LaunchEventData,
LoadAppCSSEventData,
} from './application-interfaces';
@NativeClass @NativeClass
class CADisplayLinkTarget extends NSObject { class CADisplayLinkTarget extends NSObject {