diff --git a/nativescript-core/application/index.ios.ts b/nativescript-core/application/index.ios.ts index 9578e9a40..598fd58e7 100644 --- a/nativescript-core/application/index.ios.ts +++ b/nativescript-core/application/index.ios.ts @@ -13,7 +13,7 @@ export * from './application-common'; import { Builder } from '../ui/builder'; import { CLASS_PREFIX, getSystemCssClasses, pushToSystemCssClasses, ROOT_VIEW_CSS_CLASS } from '../css/system-classes'; import { IOSHelper } from '../ui/core/view/view-helper'; -import { device } from '../platform'; +import { Device } from '../platform'; import { profile } from '../profiling'; import { ios } from '../utils'; @@ -166,7 +166,7 @@ export class iOSApplication implements iOSApplicationDefinition { } } - @profile() + @profile private didFinishLaunchingWithOptions(notification: NSNotification) { if (!displayedOnce) { displayedLinkTarget = CADisplayLinkTarget.new(); @@ -204,7 +204,7 @@ export class iOSApplication implements iOSApplicationDefinition { } } - @profile() + @profile private didBecomeActive(notification: NSNotification) { const ios = UIApplication.sharedApplication; const object = this; @@ -484,7 +484,7 @@ function setViewControllerView(view: View): void { } function setRootViewsCssClasses(rootView: View): void { - const deviceType = device.deviceType.toLowerCase(); + const deviceType = Device.deviceType.toLowerCase(); pushToSystemCssClasses(`${CLASS_PREFIX}${IOS_PLATFORM}`); pushToSystemCssClasses(`${CLASS_PREFIX}${deviceType}`); diff --git a/nativescript-core/file-system/file-name-resolver/index.ts b/nativescript-core/file-system/file-name-resolver/index.ts index 0ed5d3049..891119050 100644 --- a/nativescript-core/file-system/file-name-resolver/index.ts +++ b/nativescript-core/file-system/file-name-resolver/index.ts @@ -1,6 +1,6 @@ import { FileNameResolver as FileNameResolverDefinition } from '.'; import { PlatformContext } from '../../module-name-resolver/qualifier-matcher'; -import { screen, device } from '../../platform'; +import { screen, Device } from '../../platform'; import { path as fsPath, Folder, File } from '..'; import { Trace } from '../../trace'; import * as appCommonModule from '../../application/application-common'; @@ -79,8 +79,8 @@ export function resolveFileName(path: string, ext: string): string { resolverInstance = new FileNameResolver({ width: screen.mainScreen.widthDIPs, height: screen.mainScreen.heightDIPs, - os: device.os, - deviceType: device.deviceType, + os: Device.os, + deviceType: Device.deviceType, }); } diff --git a/nativescript-core/file-system/index.ts b/nativescript-core/file-system/index.ts index 1996d7a17..11475a312 100644 --- a/nativescript-core/file-system/index.ts +++ b/nativescript-core/file-system/index.ts @@ -328,7 +328,7 @@ export class File extends FileSystemEntity { }); } - @profile() + @profile public readTextSync(onError?: (error: any) => any, encoding?: string): string { this.checkAccess(); diff --git a/nativescript-core/index.d.ts b/nativescript-core/index.d.ts index e28578a33..18f83f8e7 100644 --- a/nativescript-core/index.d.ts +++ b/nativescript-core/index.d.ts @@ -1,6 +1,6 @@ /// export { ApplicationEventData, LaunchEventData, OrientationChangedEventData, UnhandledErrorEventData, DiscardedErrorEventData, CssChangedEventData, LoadAppCSSEventData, iOSApplication, AndroidApplication, AndroidActivityEventData, AndroidActivityBundleEventData, AndroidActivityRequestPermissionsEventData, AndroidActivityResultEventData, AndroidActivityNewIntentEventData, AndroidActivityBackPressedEventData } from './application'; -import { getMainEntry, getRootView, setResources, setCssFileName, getCssFileName, loadAppCss, addCss, on, off, run, orientation, getNativeApplication, hasLaunched, AndroidApplication, iOSApplication } from './application'; +import { getMainEntry, getRootView, _resetRootView, setResources, setCssFileName, getCssFileName, loadAppCss, addCss, on, off, run, orientation, getNativeApplication, hasLaunched, AndroidApplication, iOSApplication } from './application'; export declare const Application: { launchEvent: string; displayedEvent: string; @@ -13,6 +13,7 @@ export declare const Application: { orientationChangedEvent: string; getMainEntry: typeof getMainEntry; getRootView: typeof getRootView; + resetRootView: typeof _resetRootView; setResources: typeof setResources; setCssFileName: typeof setCssFileName; getCssFileName: typeof getCssFileName; @@ -64,7 +65,7 @@ export declare const Http: { }; export { ImageAsset, ImageAssetOptions } from './image-asset'; export { ImageSource } from './image-source'; -export { isAndroid, isIOS, screen as Screen, device as Device, platformNames } from './platform'; +export { isAndroid, isIOS, screen as Screen, IDevice, Device, platformNames } from './platform'; export { InstrumentationMode, TimerInfo } from './profiling'; import { enable as profilingEnable, disable as profilingDisable, time, uptime, start, stop, isRunning, dumpProfiles, resetProfiles, profile, startCPUProfile, stopCPUProfile } from './profiling'; export declare const Profiling: { diff --git a/nativescript-core/index.ts b/nativescript-core/index.ts index 0be1151da..f3bc48d62 100644 --- a/nativescript-core/index.ts +++ b/nativescript-core/index.ts @@ -10,7 +10,7 @@ if (!hasInitGlobal) { export { ApplicationEventData, LaunchEventData, OrientationChangedEventData, UnhandledErrorEventData, DiscardedErrorEventData, CssChangedEventData, LoadAppCSSEventData, iOSApplication, AndroidApplication, AndroidActivityEventData, AndroidActivityBundleEventData, AndroidActivityRequestPermissionsEventData, AndroidActivityResultEventData, AndroidActivityNewIntentEventData, AndroidActivityBackPressedEventData } from './application'; // Export all methods and fields from "application" as Application -import { launchEvent, displayedEvent, uncaughtErrorEvent, discardedErrorEvent, suspendEvent, resumeEvent, exitEvent, lowMemoryEvent, orientationChangedEvent, getMainEntry, getRootView, setResources, setCssFileName, getCssFileName, loadAppCss, addCss, on, off, run, orientation, getNativeApplication, hasLaunched, android, ios } from './application'; +import { launchEvent, displayedEvent, uncaughtErrorEvent, discardedErrorEvent, suspendEvent, resumeEvent, exitEvent, lowMemoryEvent, orientationChangedEvent, getMainEntry, getRootView, _resetRootView, setResources, setCssFileName, getCssFileName, loadAppCss, addCss, on, off, run, orientation, getNativeApplication, hasLaunched, android, ios } from './application'; export const Application = { launchEvent, displayedEvent, @@ -24,6 +24,7 @@ export const Application = { getMainEntry, getRootView, + resetRootView: _resetRootView, setResources, setCssFileName, getCssFileName, @@ -86,7 +87,7 @@ export const Http = { export { ImageAsset, ImageAssetOptions } from './image-asset'; export { ImageSource } from './image-source'; -export { isAndroid, isIOS, screen as Screen, device as Device, platformNames } from './platform'; +export { isAndroid, isIOS, screen as Screen, IDevice, Device, platformNames } from './platform'; // Export interfaces from "profiling" module export { InstrumentationMode, TimerInfo } from './profiling'; diff --git a/nativescript-core/module-name-resolver/index.ts b/nativescript-core/module-name-resolver/index.ts index de288ba25..499cc125d 100644 --- a/nativescript-core/module-name-resolver/index.ts +++ b/nativescript-core/module-name-resolver/index.ts @@ -1,5 +1,5 @@ import { ModuleNameResolver as ModuleNameResolverDefinition } from './'; -import { screen, device } from '../platform'; +import { screen, Device } from '../platform'; import * as appCommonModule from '../application/application-common'; import { PlatformContext, findMatch, stripQualifiers } from './qualifier-matcher'; import { registerModulesFromFileSystem } from './non-bundle-workflow-compat'; @@ -70,8 +70,8 @@ export function resolveModuleName(path: string, ext: string): string { resolverInstance = new ModuleNameResolver({ width: screen.mainScreen.widthDIPs, height: screen.mainScreen.heightDIPs, - os: device.os, - deviceType: device.deviceType, + os: Device.os, + deviceType: Device.deviceType, }); } diff --git a/nativescript-core/package.json b/nativescript-core/package.json index 7466799f5..b64653fd3 100644 --- a/nativescript-core/package.json +++ b/nativescript-core/package.json @@ -3,7 +3,7 @@ "main": "index", "types": "index.d.ts", "description": "NativeScript Core Modules", - "version": "7.0.0-rc.0", + "version": "7.0.0-rc.2", "homepage": "https://www.nativescript.org", "repository": { "type": "git", @@ -19,11 +19,11 @@ ], "license": "Apache-2.0", "dependencies": { + "@nativescript/core-widgets": "~7.0.0-rc.0", "@nativescript/hook": "~1.0.0", "css-tree": "^1.0.0-alpha.39", "reduce-css-calc": "^2.1.6", "semver": "~7.3.2", - "@nativescript/core-widgets": "~7.0.0-rc.0", "tslib": "~2.0.0" }, "devDependencies": { diff --git a/nativescript-core/platform/index.android.ts b/nativescript-core/platform/index.android.ts index d75314748..cd14902fa 100644 --- a/nativescript-core/platform/index.android.ts +++ b/nativescript-core/platform/index.android.ts @@ -1,5 +1,4 @@ /* tslint:disable:class-name */ -import { Device as DeviceDefinition, ScreenMetrics as ScreenMetricsDefinition } from '.'; import * as appModule from '../application'; const MIN_TABLET_PIXELS = 600; @@ -9,7 +8,7 @@ export module platformNames { export const ios = 'iOS'; } -class Device implements DeviceDefinition { +class DeviceRef { private _manufacturer: string; private _model: string; private _osVersion: string; @@ -95,7 +94,7 @@ class Device implements DeviceDefinition { } } -class MainScreen implements ScreenMetricsDefinition { +class MainScreen { private _metrics: android.util.DisplayMetrics; private reinitMetrics(): void { @@ -140,7 +139,7 @@ class MainScreen implements ScreenMetricsDefinition { } } -export const device = new Device(); +export const Device = new DeviceRef(); export module screen { export const mainScreen = new MainScreen(); diff --git a/nativescript-core/platform/index.d.ts b/nativescript-core/platform/index.d.ts index 5ed559993..c6cb6201f 100644 --- a/nativescript-core/platform/index.d.ts +++ b/nativescript-core/platform/index.d.ts @@ -25,7 +25,7 @@ export module platformNames { /* * An object containing device specific information. */ -export interface Device { +export interface IDevice { /** * Gets the manufacturer of the device. * For example: "Apple" or "HTC" or "Samsung". @@ -124,4 +124,4 @@ export module screen { /** * Gets the current device information. */ -export const device: Device; +export const Device: IDevice; diff --git a/nativescript-core/platform/index.ios.ts b/nativescript-core/platform/index.ios.ts index 85c1f949d..bc7e26fcd 100644 --- a/nativescript-core/platform/index.ios.ts +++ b/nativescript-core/platform/index.ios.ts @@ -1,12 +1,11 @@ /* tslint:disable:class-name */ -import { Device as DeviceDefinition, ScreenMetrics as ScreenMetricsDefinition } from '.'; export module platformNames { export const android = 'Android'; export const ios = 'iOS'; } -class Device implements DeviceDefinition { +class DeviceRef { private _model: string; private _osVersion: string; private _sdkVersion: string; @@ -90,7 +89,7 @@ class Device implements DeviceDefinition { } } -class MainScreen implements ScreenMetricsDefinition { +class MainScreen { private _screen: UIScreen; private get screen(): UIScreen { @@ -118,7 +117,7 @@ class MainScreen implements ScreenMetricsDefinition { } } -export const device = new Device(); +export const Device = new DeviceRef(); export module screen { export const mainScreen = new MainScreen(); diff --git a/nativescript-core/profiling/index.ts b/nativescript-core/profiling/index.ts index de5b428db..29dbc4c55 100644 --- a/nativescript-core/profiling/index.ts +++ b/nativescript-core/profiling/index.ts @@ -243,7 +243,7 @@ const voidMethodDecorator = () => { // no op }; -export function profile(nameFnOrTarget?: string | Function | Object, fnOrKey?: Function | string | symbol, descriptor?: PropertyDescriptor, attrs?: any): Function | MethodDecorator { +export function profile(nameFnOrTarget?: string | Function | Object, fnOrKey?: Function | string | symbol, descriptor?: PropertyDescriptor, attrs?: any): any { if (typeof nameFnOrTarget === 'object' && (typeof fnOrKey === 'string' || typeof fnOrKey === 'symbol')) { if (!profileFunctionFactory) { return; diff --git a/nativescript-core/trace/index.d.ts b/nativescript-core/trace/index.d.ts new file mode 100644 index 000000000..d693067de --- /dev/null +++ b/nativescript-core/trace/index.d.ts @@ -0,0 +1,146 @@ +/** + * An interface used to define a writer used by trace to print (log). + */ +export interface TraceWriter { + write(message: any, category: string, type?: number): void; +} + +/** + * An interface used to trace information about specific event. + */ +export interface TraceEventListener { + filter: string; + on(object: Object, name: string, data?: any): void; +} + +/** + * An interface used to for handling trace error + */ +export interface TraceErrorHandler { + handlerError(error: Error): any; +} + +export namespace Trace { + /** + * Enables the trace module. + */ + export function enable(): void; + + /** + * Disables the trace module. + */ + export function disable(): void; + + /** + * A function that returns whether the tracer is enabled and there is a point in writing messages. + * Check this to avoid writing complex string templates. + * Send error messages even if tracing is disabled. + */ + export function isEnabled(): boolean; + + /** + * Adds a TraceWriter instance to the trace module. + * @param writer The TraceWriter instance to add. + */ + export function addWriter(writer: TraceWriter): void; + + /** + * Removes a TraceWriter instance from the trace module. + * @param writer The TraceWriter instance to remove. + */ + export function removeWriter(writer: TraceWriter): void; + + /** + * Clears all the writers from the trace module. + */ + export function clearWriters(): void; + + /** + * Sets the categories the module will trace. + * @param categories The comma-separated list of categories. If not specified all messages from all categories will be traced. + */ + export function setCategories(categories: string): void; + + /** + * Adds categories to existing categories the module will trace. + * @param categories The comma-separated list of categories. If not specified all messages from all categories will be traced. + */ + export function addCategories(categories: string): void; + + /** + * Check if category is already set in trace module. + * @param category The category to check. + */ + export function isCategorySet(category: string): boolean; + + /** + * Writes a message using the available writers. + * @param message The message to be written. + * @param category The category of the message. + * @param type Optional, the type of the message - info, warning, error. + */ + export function write(message: any, category: string, type?: number): void; + + /** + * Notifies all the attached listeners for an event that has occurred in the sender object. + * @param object The Object instance that raised the event. + * @param name The name of the raised event. + * @param data An optional parameter that passes the data associated with the event. + */ + export function notifyEvent(object: Object, name: string, data?: any): void; + + export function addEventListener(listener: TraceEventListener): void; + + export function removeEventListener(listener: TraceEventListener): void; + + export module messageType { + export const log = 0; + export const info = 1; + export const warn = 2; + export const error = 3; + } + + /** + * all predefined categories. + */ + export module categories { + export const VisualTreeEvents = 'VisualTreeEvents'; + export const Layout = 'Layout'; + export const Style = 'Style'; + export const ViewHierarchy = 'ViewHierarchy'; + export const NativeLifecycle = 'NativeLifecycle'; + export const Debug = 'Debug'; + export const Navigation = 'Navigation'; + export const Test = 'Test'; + export const Binding = 'Binding'; + export const BindingError = 'BindingError'; + export const Error = 'Error'; + export const Animation = 'Animation'; + export const Transition = 'Transition'; + export const Livesync = 'Livesync'; + export const ModuleNameResolver = 'ModuleNameResolver'; + + export const separator = ','; + export const All: Array; + + export function concat(): string; + + class ConsoleWriter implements TraceWriter { + public write(message: any, category: string, type?: number): void; + } + + export class DefaultErrorHandler implements TraceErrorHandler { + handlerError(error: any): void; + } + + export function getErrorHandler(): TraceErrorHandler; + + export function setErrorHandler(handler: TraceErrorHandler): void; + + /** + * Passes an error to the registered ErrorHandler + * @param error The error to be handled. + */ + export function error(error: string | Error): void; + } +} diff --git a/nativescript-core/ui/action-bar/action-bar-common.ts b/nativescript-core/ui/action-bar/action-bar-common.ts index e4aa6768f..2b4a83be2 100644 --- a/nativescript-core/ui/action-bar/action-bar-common.ts +++ b/nativescript-core/ui/action-bar/action-bar-common.ts @@ -305,7 +305,7 @@ export class ActionItemBase extends ViewBase implements ActionItemDefinition { } } - @profile() + @profile public onLoaded() { if (this._actionView) { this._actionView.style[horizontalAlignmentProperty.cssName] = 'center'; diff --git a/nativescript-core/ui/animation/index.android.ts b/nativescript-core/ui/animation/index.android.ts index 558bf0807..bc31283b5 100644 --- a/nativescript-core/ui/animation/index.android.ts +++ b/nativescript-core/ui/animation/index.android.ts @@ -8,7 +8,7 @@ import { Color } from '../../color'; import { Trace } from '../../trace'; import { opacityProperty, backgroundColorProperty, rotateProperty, rotateXProperty, rotateYProperty, translateXProperty, translateYProperty, scaleXProperty, scaleYProperty, heightProperty, widthProperty, PercentLength } from '../styling/style-properties'; import { layout } from '../../utils'; -import { device, screen } from '../../platform'; +import { Device, screen } from '../../platform'; import lazy from '../../utils/lazy'; export * from './animation-common'; @@ -219,7 +219,7 @@ export class Animation extends AnimationBase { private _play(): AnimationPromise { const animationFinishedPromise = super.play(); - if (device.sdkVersion <= '23') { + if (Device.sdkVersion <= '23') { this._animatorSet = new android.animation.AnimatorSet(); this._animatorSet.addListener(this._animatorListener); } diff --git a/nativescript-core/ui/bottom-navigation/index.ios.ts b/nativescript-core/ui/bottom-navigation/index.ios.ts index fe0a547ae..bea9550b8 100644 --- a/nativescript-core/ui/bottom-navigation/index.ios.ts +++ b/nativescript-core/ui/bottom-navigation/index.ios.ts @@ -7,7 +7,7 @@ import { TextTransform } from '../text-base'; // Requires import { Color } from '../../color'; import { ImageSource } from '../../image-source'; -import { device } from '../../platform'; +import { Device } from '../../platform'; import { ios as iosUtils, isFontIconURI, layout } from '../../utils'; import { CSSType, ios as iosView, View } from '../core/view'; import { Frame } from '../frame'; @@ -20,7 +20,7 @@ import { getTransformedText } from '../text-base'; const maxTabsCount = 5; const majorVersion = iosUtils.MajorVersion; -const isPhone = device.deviceType === 'Phone'; +const isPhone = Device.deviceType === 'Phone'; class UITabBarControllerImpl extends UITabBarController { private _owner: WeakRef; diff --git a/nativescript-core/ui/builder/component-builder/component-builder.ts b/nativescript-core/ui/builder/component-builder/component-builder.ts index e25bf9462..78d4d8dc3 100644 --- a/nativescript-core/ui/builder/component-builder/component-builder.ts +++ b/nativescript-core/ui/builder/component-builder/component-builder.ts @@ -7,7 +7,7 @@ import { isEventOrGesture } from '../../core/bindable'; import { getBindingOptions, bindingConstants } from '../binding-builder'; import { profile } from '../../../profiling'; import * as debugModule from '../../../utils/debug'; -import * as platform from '../../../platform'; +import { Device } from '../../../platform'; import { sanitizeModuleName } from '../module-name-sanitizer'; import { resolveModuleName } from '../../../module-name-resolver'; @@ -115,7 +115,7 @@ const applyComponentAttributes = profile('applyComponentAttributes', (instance: if (attr.indexOf(':') !== -1) { const platformName = attr.split(':')[0].trim(); - if (platformName.toLowerCase() === platform.device.os.toLowerCase()) { + if (platformName.toLowerCase() === Device.os.toLowerCase()) { attr = attr.split(':')[1].trim(); } else { continue; diff --git a/nativescript-core/ui/builder/index.ts b/nativescript-core/ui/builder/index.ts index 7c2b3256f..6f58833c7 100644 --- a/nativescript-core/ui/builder/index.ts +++ b/nativescript-core/ui/builder/index.ts @@ -9,7 +9,7 @@ import { debug, ScopeError, SourceError, Source } from '../../utils/debug'; import * as xml from '../../xml'; import { isString, isObject, isDefined } from '../../utils/types'; import { ComponentModule, setPropertyValue, getComponentModule } from './component-builder'; -import { platformNames, device } from '../../platform'; +import { platformNames, Device } from '../../platform'; import { profile } from '../../profiling'; import { sanitizeModuleName } from './module-name-sanitizer'; import { resolveModuleName } from '../../module-name-resolver'; @@ -368,7 +368,7 @@ namespace xml2ui { } private static isCurentPlatform(value: string): boolean { - return value && value.toLowerCase() === device.os.toLowerCase(); + return value && value.toLowerCase() === Device.os.toLowerCase(); } } @@ -579,7 +579,7 @@ namespace xml2ui { this.sourceTracker = sourceTracker; } - @profile() + @profile private buildComponent(args: xml.ParserEvent): ComponentModule { if (args.prefix && args.namespace) { // Custom components diff --git a/nativescript-core/ui/button/index.android.ts b/nativescript-core/ui/button/index.android.ts index 5d07edaee..944feaa3e 100644 --- a/nativescript-core/ui/button/index.android.ts +++ b/nativescript-core/ui/button/index.android.ts @@ -5,12 +5,12 @@ import { textAlignmentProperty } from '../text-base'; import { TextAlignment } from '../enums'; import { profile } from '../../profiling'; import { TouchGestureEventData, GestureTypes, TouchAction } from '../gestures'; -import { device } from '../../platform'; +import { Device } from '../../platform'; import lazy from '../../utils/lazy'; export * from './button-common'; -const sdkVersion = lazy(() => parseInt(device.sdkVersion)); +const sdkVersion = lazy(() => parseInt(Device.sdkVersion)); interface ClickListener { new (owner: Button): android.view.View.OnClickListener; @@ -57,7 +57,7 @@ export class Button extends ButtonBase { private _stateListAnimator: any; private _highlightedHandler: (args: TouchGestureEventData) => void; - @profile() + @profile public createNativeView() { if (!AndroidButton) { AndroidButton = android.widget.Button; diff --git a/nativescript-core/ui/button/index.ios.ts b/nativescript-core/ui/button/index.ios.ts index 2cc218426..ebb34a688 100644 --- a/nativescript-core/ui/button/index.ios.ts +++ b/nativescript-core/ui/button/index.ios.ts @@ -6,7 +6,7 @@ import { textAlignmentProperty, whiteSpaceProperty, WhiteSpace } from '../text-b import { TextAlignment } from '../enums'; import { profile } from '../../profiling'; import { TouchGestureEventData, GestureTypes, TouchAction } from '../gestures'; -import { device } from '../../platform'; +import { Device } from '../../platform'; import { layout } from '../../utils'; export * from './button-common'; diff --git a/nativescript-core/ui/core/view-base/index.ts b/nativescript-core/ui/core/view-base/index.ts index 29f3922f6..ca5558d79 100644 --- a/nativescript-core/ui/core/view-base/index.ts +++ b/nativescript-core/ui/core/view-base/index.ts @@ -385,7 +385,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition this[name] = WrappedValue.unwrap(value); } - @profile() + @profile public onLoaded() { this.setFlag(Flags.superOnLoadedCalled, true); if (this._isLoaded) { @@ -405,7 +405,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition this._emit('loaded'); } - @profile() + @profile public onUnloaded() { this.setFlag(Flags.superOnUnloadedCalled, true); if (!this._isLoaded) { @@ -524,7 +524,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition return allStates; } - @profile() + @profile public addPseudoClass(name: string): void { let allStates = this.getAllAliasedStates(name); for (let i = 0; i < allStates.length; i++) { @@ -535,7 +535,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition } } - @profile() + @profile public deletePseudoClass(name: string): void { let allStates = this.getAllAliasedStates(name); for (let i = 0; i < allStates.length; i++) { @@ -618,7 +618,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition } } - @profile() + @profile public requestLayout(): void { // Default implementation for non View instances (like TabViewItem). const parent = this.parent; @@ -631,7 +631,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition // } - @profile() + @profile public _addView(view: ViewBase, atIndex?: number) { if (Trace.isEnabled()) { Trace.write(`${this}._addView(${view}, ${atIndex})`, Trace.categories.ViewHierarchy); @@ -757,7 +757,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition this._setupUI(context); } - @profile() + @profile public _setupUI(context: android.content.Context, atIndex?: number, parentIsLoaded?: boolean): void { if (this._context === context) { return; @@ -851,7 +851,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition } } - @profile() + @profile public _tearDownUI(force?: boolean): void { // No context means we are already teared down. if (!this._context) { diff --git a/nativescript-core/ui/core/view/index.android.ts b/nativescript-core/ui/core/view/index.android.ts index 5ff86bed1..737be542b 100644 --- a/nativescript-core/ui/core/view/index.android.ts +++ b/nativescript-core/ui/core/view/index.android.ts @@ -46,7 +46,7 @@ import { profile } from '../../../profiling'; import { topmost } from '../../frame/frame-stack'; import { screen } from '../../../platform'; import { AndroidActivityBackPressedEventData, android as androidApp } from '../../../application'; -import { device } from '../../../platform'; +import { Device } from '../../../platform'; import lazy from '../../../utils/lazy'; export * from './view-common'; @@ -59,7 +59,7 @@ const statePressed = 16842919; // android.R.attr.state_pressed const stateEnabled = 16842910; // android.R.attr.state_enabled const styleAnimationDialog = 16973826; // android.R.style.Animation_Dialog -const sdkVersion = lazy(() => parseInt(device.sdkVersion)); +const sdkVersion = lazy(() => parseInt(Device.sdkVersion)); const modalMap = new Map(); @@ -389,7 +389,7 @@ export class View extends ViewCommon { return manager; } - @profile() + @profile public onLoaded() { this._manager = null; this._rootManager = null; @@ -397,7 +397,7 @@ export class View extends ViewCommon { this.setOnTouchListener(); } - @profile() + @profile public onUnloaded() { if (this.touchListenerIsSet) { this.touchListenerIsSet = false; @@ -516,7 +516,7 @@ export class View extends ViewCommon { } } - @profile() + @profile public requestLayout(): void { super.requestLayout(); if (this.nativeViewProtected) { diff --git a/nativescript-core/ui/core/view/index.ios.ts b/nativescript-core/ui/core/view/index.ios.ts index efab19a95..579f3b109 100644 --- a/nativescript-core/ui/core/view/index.ios.ts +++ b/nativescript-core/ui/core/view/index.ios.ts @@ -80,7 +80,7 @@ export class View extends ViewCommon implements ViewDefinition { } } - @profile() + @profile public layout(left: number, top: number, right: number, bottom: number, setFrame = true): void { const { boundsChanged, sizeChanged } = this._setCurrentLayoutBounds(left, top, right, bottom); if (setFrame) { @@ -118,7 +118,7 @@ export class View extends ViewCommon implements ViewDefinition { this._privateFlags |= PFLAG_MEASURED_DIMENSION_SET; } - @profile() + @profile public onMeasure(widthMeasureSpec: number, heightMeasureSpec: number): void { const view = this.nativeViewProtected; const width = layout.getMeasureSpecSize(widthMeasureSpec); diff --git a/nativescript-core/ui/frame/frame-common.ts b/nativescript-core/ui/frame/frame-common.ts index 008a3ce7b..54ef4065b 100644 --- a/nativescript-core/ui/frame/frame-common.ts +++ b/nativescript-core/ui/frame/frame-common.ts @@ -110,7 +110,7 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition { throw new Error(`Frame should not have a view. Use 'defaultPage' property instead.`); } - @profile() + @profile public onLoaded() { super.onLoaded(); @@ -378,7 +378,7 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition { } } - @profile() + @profile public performNavigation(navigationContext: NavigationContext) { this._executingContext = navigationContext; @@ -388,7 +388,7 @@ export class FrameBase extends CustomLayoutView implements FrameDefinition { this._navigateCore(backstackEntry); } - @profile() + @profile private performGoBack(navigationContext: NavigationContext) { let backstackEntry = navigationContext.entry; const backstack = this._backStack; diff --git a/nativescript-core/ui/frame/index.android.ts b/nativescript-core/ui/frame/index.android.ts index ebad5c00a..0fe765386 100644 --- a/nativescript-core/ui/frame/index.android.ts +++ b/nativescript-core/ui/frame/index.android.ts @@ -17,7 +17,7 @@ import { _setAndroidFragmentTransitions, _getAnimatedEntries, _updateTransitions // TODO: Remove this and get it from global to decouple builder for angular import { Builder } from '../builder'; import { CLASS_PREFIX, getSystemCssClasses, pushToSystemCssClasses, ROOT_VIEW_CSS_CLASS } from '../../css/system-classes'; -import { device } from '../../platform'; +import { Device } from '../../platform'; import { profile } from '../../profiling'; export * from './frame-common'; @@ -370,7 +370,7 @@ export class Frame extends FrameBase { // HACK: This @profile decorator creates a circular dependency // HACK: because the function parameter type is evaluated with 'typeof' - @profile() + @profile public _navigateCore(newEntry: any) { // should be (newEntry: BackstackEntry) super._navigateCore(newEntry); @@ -818,7 +818,7 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks { public entry: BackstackEntry; private backgroundBitmap: android.graphics.Bitmap = null; - @profile() + @profile public onHiddenChanged(fragment: androidx.fragment.app.Fragment, hidden: boolean, superFunc: Function): void { if (Trace.isEnabled()) { Trace.write(`${fragment}.onHiddenChanged(${hidden})`, Trace.categories.NativeLifecycle); @@ -826,7 +826,7 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks { superFunc.call(fragment, hidden); } - @profile() + @profile public onCreateAnimator(fragment: androidx.fragment.app.Fragment, transit: number, enter: boolean, nextAnim: number, superFunc: Function): android.animation.Animator { let animator = null; const entry = this.entry; @@ -840,7 +840,7 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks { return animator || superFunc.call(fragment, transit, enter, nextAnim); } - @profile() + @profile public onCreate(fragment: androidx.fragment.app.Fragment, savedInstanceState: android.os.Bundle, superFunc: Function): void { if (Trace.isEnabled()) { Trace.write(`${fragment}.onCreate(${savedInstanceState})`, Trace.categories.NativeLifecycle); @@ -861,7 +861,7 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks { } } - @profile() + @profile public onCreateView(fragment: androidx.fragment.app.Fragment, inflater: android.view.LayoutInflater, container: android.view.ViewGroup, savedInstanceState: android.os.Bundle, superFunc: Function): android.view.View { if (Trace.isEnabled()) { Trace.write(`${fragment}.onCreateView(inflater, container, ${savedInstanceState})`, Trace.categories.NativeLifecycle); @@ -935,7 +935,7 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks { return page.nativeViewProtected; } - @profile() + @profile public onSaveInstanceState(fragment: androidx.fragment.app.Fragment, outState: android.os.Bundle, superFunc: Function): void { if (Trace.isEnabled()) { Trace.write(`${fragment}.onSaveInstanceState(${outState})`, Trace.categories.NativeLifecycle); @@ -943,7 +943,7 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks { superFunc.call(fragment, outState); } - @profile() + @profile public onDestroyView(fragment: org.nativescript.widgets.FragmentBase, superFunc: Function): void { try { if (Trace.isEnabled()) { @@ -963,7 +963,7 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks { } } - @profile() + @profile public onDestroy(fragment: androidx.fragment.app.Fragment, superFunc: Function): void { if (Trace.isEnabled()) { Trace.write(`${fragment}.onDestroy()`, Trace.categories.NativeLifecycle); @@ -992,7 +992,7 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks { } } - @profile() + @profile public onPause(fragment: org.nativescript.widgets.FragmentBase, superFunc: Function): void { try { // Get view as bitmap and set it as background. This is workaround for the disapearing nested fragments. @@ -1007,12 +1007,12 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks { } } - @profile() + @profile public onStop(fragment: androidx.fragment.app.Fragment, superFunc: Function): void { superFunc.call(fragment); } - @profile() + @profile public toStringOverride(fragment: androidx.fragment.app.Fragment, superFunc: Function): string { const entry = this.entry; if (entry) { @@ -1053,7 +1053,7 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks { return this._rootView; } - @profile() + @profile public onCreate(activity: androidx.appcompat.app.AppCompatActivity, savedInstanceState: android.os.Bundle, intentOrSuperFunc: android.content.Intent | Function, superFunc?: Function): void { if (Trace.isEnabled()) { Trace.write(`Activity.onCreate(${savedInstanceState})`, Trace.categories.NativeLifecycle); @@ -1096,7 +1096,7 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks { moduleLoaded = true; } - @profile() + @profile public onSaveInstanceState(activity: androidx.appcompat.app.AppCompatActivity, outState: android.os.Bundle, superFunc: Function): void { superFunc.call(activity, outState); const rootView = this._rootView; @@ -1108,7 +1108,7 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks { outState.putInt(ROOT_VIEW_ID_EXTRA, rootView._domId); } - @profile() + @profile public onNewIntent(activity: androidx.appcompat.app.AppCompatActivity, intent: android.content.Intent, superSetIntentFunc: Function, superFunc: Function): void { superFunc.call(activity, intent); superSetIntentFunc.call(activity, intent); @@ -1121,7 +1121,7 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks { }); } - @profile() + @profile public onStart(activity: any, superFunc: Function): void { superFunc.call(activity); @@ -1135,7 +1135,7 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks { } } - @profile() + @profile public onStop(activity: any, superFunc: Function): void { superFunc.call(activity); @@ -1149,7 +1149,7 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks { } } - @profile() + @profile public onPostResume(activity: any, superFunc: Function): void { superFunc.call(activity); @@ -1173,7 +1173,7 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks { } } - @profile() + @profile public onDestroy(activity: any, superFunc: Function): void { try { if (Trace.isEnabled()) { @@ -1196,7 +1196,7 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks { } } - @profile() + @profile public onBackPressed(activity: any, superFunc: Function): void { if (Trace.isEnabled()) { Trace.write('NativeScriptActivity.onBackPressed;', Trace.categories.NativeLifecycle); @@ -1234,7 +1234,7 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks { } } - @profile() + @profile public onRequestPermissionsResult(activity: any, requestCode: number, permissions: Array, grantResults: Array, superFunc: Function): void { if (Trace.isEnabled()) { Trace.write('NativeScriptActivity.onRequestPermissionsResult;', Trace.categories.NativeLifecycle); @@ -1250,7 +1250,7 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks { }); } - @profile() + @profile public onActivityResult(activity: any, requestCode: number, resultCode: number, data: android.content.Intent, superFunc: Function): void { superFunc.call(activity, requestCode, resultCode, data); if (Trace.isEnabled()) { @@ -1314,7 +1314,7 @@ class ActivityCallbacksImplementation implements AndroidActivityCallbacks { this._rootView = rootView; activityRootViewsMap.set(rootView._domId, new WeakRef(rootView)); - const deviceType = device.deviceType.toLowerCase(); + const deviceType = Device.deviceType.toLowerCase(); pushToSystemCssClasses(`${CLASS_PREFIX}${ANDROID_PLATFORM}`); pushToSystemCssClasses(`${CLASS_PREFIX}${deviceType}`); diff --git a/nativescript-core/ui/frame/index.ios.ts b/nativescript-core/ui/frame/index.ios.ts index b61fc8bf7..d3bfa5c34 100644 --- a/nativescript-core/ui/frame/index.ios.ts +++ b/nativescript-core/ui/frame/index.ios.ts @@ -62,7 +62,7 @@ export class Frame extends FrameBase { // !!! THIS PROFILE DECORATOR CREATES A CIRCULAR DEPENDENCY // !!! BECAUSE THE PARAMETER TYPE IS EVALUATED WITH TYPEOF - @profile() + @profile public _navigateCore(backstackEntry: any) { super._navigateCore(backstackEntry); @@ -396,7 +396,7 @@ class UINavigationControllerImpl extends UINavigationController { return this._owner.get(); } - @profile() + @profile public viewWillAppear(animated: boolean): void { super.viewWillAppear(animated); const owner = this._owner.get(); @@ -405,7 +405,7 @@ class UINavigationControllerImpl extends UINavigationController { } } - @profile() + @profile public viewDidDisappear(animated: boolean): void { super.viewDidDisappear(animated); const owner = this._owner.get(); @@ -439,7 +439,7 @@ class UINavigationControllerImpl extends UINavigationController { }); } - @profile() + @profile public pushViewControllerAnimated(viewController: UIViewController, animated: boolean): void { let navigationTransition = viewController[TRANSITION]; if (Trace.isEnabled()) { @@ -458,7 +458,7 @@ class UINavigationControllerImpl extends UINavigationController { }); } - @profile() + @profile public setViewControllersAnimated(viewControllers: NSArray, animated: boolean): void { let viewController = viewControllers.lastObject; let navigationTransition = viewController[TRANSITION]; diff --git a/nativescript-core/ui/label/index.android.ts b/nativescript-core/ui/label/index.android.ts index bdb1b5295..a6b2a5cf0 100644 --- a/nativescript-core/ui/label/index.android.ts +++ b/nativescript-core/ui/label/index.android.ts @@ -24,7 +24,7 @@ export class Label extends TextBase implements LabelDefinition { this.style.whiteSpace = value ? 'normal' : 'nowrap'; } - @profile() + @profile public createNativeView() { if (!TextView) { TextView = android.widget.TextView; diff --git a/nativescript-core/ui/list-picker/index.android.ts b/nativescript-core/ui/list-picker/index.android.ts index b1c45c9c5..6af8567ff 100644 --- a/nativescript-core/ui/list-picker/index.android.ts +++ b/nativescript-core/ui/list-picker/index.android.ts @@ -1,12 +1,12 @@ import { ListPickerBase, selectedIndexProperty, itemsProperty, ItemsSource } from './list-picker-common'; import { colorProperty } from '../styling/style-properties'; import { Color } from '../../color'; -import { device } from '../../platform'; +import { Device } from '../../platform'; import lazy from '../../utils/lazy'; export * from './list-picker-common'; -const sdkVersion = lazy(() => parseInt(device.sdkVersion)); +const sdkVersion = lazy(() => parseInt(Device.sdkVersion)); interface Formatter { new (owner: ListPicker): android.widget.NumberPicker.Formatter; diff --git a/nativescript-core/ui/list-picker/index.ios.ts b/nativescript-core/ui/list-picker/index.ios.ts index 10cae1034..080e3faea 100644 --- a/nativescript-core/ui/list-picker/index.ios.ts +++ b/nativescript-core/ui/list-picker/index.ios.ts @@ -32,7 +32,7 @@ export class ListPicker extends ListPickerBase { return this.nativeViewProtected; } - @profile() + @profile public onLoaded() { super.onLoaded(); this.ios.delegate = this._delegate; diff --git a/nativescript-core/ui/list-view/index.android.ts b/nativescript-core/ui/list-view/index.android.ts index 1731949f9..3f44d948b 100644 --- a/nativescript-core/ui/list-view/index.android.ts +++ b/nativescript-core/ui/list-view/index.android.ts @@ -57,7 +57,7 @@ export class ListView extends ListViewBase { public _realizedItems = new Map(); public _realizedTemplates = new Map>(); - @profile() + @profile public createNativeView() { const listView = new android.widget.ListView(this._context); listView.setDescendantFocusability(android.view.ViewGroup.FOCUS_AFTER_DESCENDANTS); @@ -281,7 +281,7 @@ function ensureListViewAdapterClass() { return itemViewType; } - @profile() + @profile public getView(index: number, convertView: android.view.View, parent: android.view.ViewGroup): android.view.View { //this.owner._dumpRealizedTemplates(); diff --git a/nativescript-core/ui/list-view/index.ios.ts b/nativescript-core/ui/list-view/index.ios.ts index b0205699e..5169db837 100644 --- a/nativescript-core/ui/list-view/index.ios.ts +++ b/nativescript-core/ui/list-view/index.ios.ts @@ -273,7 +273,7 @@ export class ListView extends ListViewBase { this.ios.clipsToBounds = true; } - @profile() + @profile public onLoaded() { super.onLoaded(); if (this._isDataDirty) { diff --git a/nativescript-core/ui/page/index.android.ts b/nativescript-core/ui/page/index.android.ts index da68dc1c9..2623e1c44 100644 --- a/nativescript-core/ui/page/index.android.ts +++ b/nativescript-core/ui/page/index.android.ts @@ -3,7 +3,7 @@ import { View } from '../core/view'; import { Color } from '../../color'; import { ActionBar } from '../action-bar'; import { GridLayout } from '../layouts/grid-layout'; -import { device } from '../../platform'; +import { Device } from '../../platform'; import { profile } from '../../profiling'; export * from './page-common'; @@ -43,7 +43,7 @@ export class Page extends PageBase { return super._addViewToNativeVisualTree(child, atIndex); } - @profile() + @profile public onLoaded() { super.onLoaded(); if (!this.hasActionBar && this.actionBarHidden !== true) { @@ -76,7 +76,7 @@ export class Page extends PageBase { color: number; systemUiVisibility: number; } { - if (device.sdkVersion >= '21') { + if (Device.sdkVersion >= '21') { const window = (this._context).getWindow(); const decorView = window.getDecorView(); @@ -89,7 +89,7 @@ export class Page extends PageBase { return null; } [statusBarStyleProperty.setNative](value: 'dark' | 'light' | { color: number; systemUiVisibility: number }) { - if (device.sdkVersion >= '21') { + if (Device.sdkVersion >= '21') { const window = (this._context).getWindow(); const decorView = window.getDecorView(); @@ -107,7 +107,7 @@ export class Page extends PageBase { } [androidStatusBarBackgroundProperty.getDefault](): number { - if (device.sdkVersion >= '21') { + if (Device.sdkVersion >= '21') { const window = (this._context).getWindow(); return (window).getStatusBarColor(); @@ -116,7 +116,7 @@ export class Page extends PageBase { return null; } [androidStatusBarBackgroundProperty.setNative](value: number | Color) { - if (device.sdkVersion >= '21') { + if (Device.sdkVersion >= '21') { const window = (this._context).getWindow(); const color = value instanceof Color ? value.android : value; (window).setStatusBarColor(color); diff --git a/nativescript-core/ui/page/index.ios.ts b/nativescript-core/ui/page/index.ios.ts index 46ca375cc..692537260 100644 --- a/nativescript-core/ui/page/index.ios.ts +++ b/nativescript-core/ui/page/index.ios.ts @@ -133,7 +133,7 @@ class UIViewControllerImpl extends UIViewController { } } - @profile() + @profile public viewDidAppear(animated: boolean): void { super.viewDidAppear(animated); @@ -194,7 +194,7 @@ class UIViewControllerImpl extends UIViewController { } } - @profile() + @profile public viewWillDisappear(animated: boolean): void { super.viewWillDisappear(animated); @@ -223,7 +223,7 @@ class UIViewControllerImpl extends UIViewController { } } - @profile() + @profile public viewDidDisappear(animated: boolean): void { super.viewDidDisappear(animated); diff --git a/nativescript-core/ui/page/page-common.ts b/nativescript-core/ui/page/page-common.ts index c6dccdc30..dfdb50ea7 100644 --- a/nativescript-core/ui/page/page-common.ts +++ b/nativescript-core/ui/page/page-common.ts @@ -102,7 +102,7 @@ export class PageBase extends ContentView implements PageDefinition { }; } - @profile() + @profile public onNavigatingTo(context: any, isBackNavigation: boolean, bindingContext?: any) { this._navigationContext = context; @@ -120,17 +120,17 @@ export class PageBase extends ContentView implements PageDefinition { this.notify(this.createNavigatedData(PageBase.navigatingToEvent, isBackNavigation)); } - @profile() + @profile public onNavigatedTo(isBackNavigation: boolean) { this.notify(this.createNavigatedData(PageBase.navigatedToEvent, isBackNavigation)); } - @profile() + @profile public onNavigatingFrom(isBackNavigation: boolean) { this.notify(this.createNavigatedData(PageBase.navigatingFromEvent, isBackNavigation)); } - @profile() + @profile public onNavigatedFrom(isBackNavigation: boolean) { this.notify(this.createNavigatedData(PageBase.navigatedFromEvent, isBackNavigation)); diff --git a/nativescript-core/ui/repeater/index.ts b/nativescript-core/ui/repeater/index.ts index 526e8e62e..68ac5e799 100644 --- a/nativescript-core/ui/repeater/index.ts +++ b/nativescript-core/ui/repeater/index.ts @@ -47,7 +47,7 @@ export class Repeater extends CustomLayoutView { */ public itemsLayout: LayoutBase; - @profile() + @profile public onLoaded() { if (this._isDirty) { this.refresh(); diff --git a/nativescript-core/ui/scroll-view/scroll-view-common.ts b/nativescript-core/ui/scroll-view/scroll-view-common.ts index 5454f0563..4c995b8b3 100644 --- a/nativescript-core/ui/scroll-view/scroll-view-common.ts +++ b/nativescript-core/ui/scroll-view/scroll-view-common.ts @@ -33,7 +33,7 @@ export abstract class ScrollViewBase extends ContentView implements ScrollViewDe } } - @profile() + @profile public onLoaded() { super.onLoaded(); diff --git a/nativescript-core/ui/styling/font.ios.ts b/nativescript-core/ui/styling/font.ios.ts index 133853c10..3af9a0a77 100644 --- a/nativescript-core/ui/styling/font.ios.ts +++ b/nativescript-core/ui/styling/font.ios.ts @@ -1,6 +1,6 @@ import { Font as FontBase, parseFontFamily, genericFontFamilies, FontStyle, FontWeight } from './font-common'; import { Trace } from '../../trace'; -import { device } from '../../platform'; +import { Device } from '../../platform'; import * as fs from '../../file-system'; export * from './font-common'; @@ -8,7 +8,7 @@ const EMULATE_OBLIQUE = true; const OBLIQUE_TRANSFORM = CGAffineTransformMake(1, 0, 0.2, 1, 0, 0); const DEFAULT_SERIF = 'Times New Roman'; const DEFAULT_MONOSPACE = 'Courier New'; -const SUPPORT_FONT_WEIGHTS = parseFloat(device.osVersion) >= 10.0; +const SUPPORT_FONT_WEIGHTS = parseFloat(Device.osVersion) >= 10.0; export class Font extends FontBase { public static default = new Font(undefined, undefined, FontStyle.NORMAL, FontWeight.NORMAL); diff --git a/nativescript-core/ui/styling/style-scope.ts b/nativescript-core/ui/styling/style-scope.ts index 7686f7c9b..4605445a3 100644 --- a/nativescript-core/ui/styling/style-scope.ts +++ b/nativescript-core/ui/styling/style-scope.ts @@ -157,7 +157,7 @@ class CSSSource { return new CSSSource(undefined, url, file, keyframes, undefined); } - @profile() + @profile public static resolveCSSPathFromURL(url: string, importSource?: string): string { const app = knownFolders.currentApp().path; const file = resolveFileNameFromUrl(url, app, File.exists, importSource); @@ -180,13 +180,13 @@ class CSSSource { return this._source; } - @profile() + @profile private load(): void { const file = File.fromPath(this._file); this._source = file.readTextSync(); } - @profile() + @profile private parse(): void { try { if (!this._ast) { @@ -209,7 +209,7 @@ class CSSSource { } } - @profile() + @profile private parseCSSAst() { if (this._source) { switch (parser) { @@ -232,7 +232,7 @@ class CSSSource { } } - @profile() + @profile private createSelectors() { if (this._ast) { this._selectors = [...this.createSelectorsFromImports(), ...this.createSelectorsFromSyntaxTree()]; @@ -447,7 +447,7 @@ export class CssState { this.unsubscribeFromDynamicUpdates(); } - @profile() + @profile private updateMatch() { const view = this.viewRef.get(); if (view && view._styleScope) { @@ -460,7 +460,7 @@ export class CssState { this._matchInvalid = false; } - @profile() + @profile private updateDynamicState(): void { const view = this.viewRef.get(); if (!view) { @@ -716,7 +716,7 @@ export class StyleScope { this.ensureSelectors(); } - @profile() + @profile private setCss(cssString: string, cssFileName?): void { this._css = cssString; @@ -726,7 +726,7 @@ export class StyleScope { this.ensureSelectors(); } - @profile() + @profile private appendCss(cssString: string, cssFileName?): void { if (!cssString && !cssFileName) { return; @@ -773,7 +773,7 @@ export class StyleScope { return this._localCssSelectorsAppliedVersion === this._localCssSelectorVersion; } - @profile() + @profile private _createSelectors() { let toMerge: RuleSet[][] = []; toMerge.push(applicationCssSelectors); @@ -793,7 +793,7 @@ export class StyleScope { // HACK: This @profile decorator creates a circular dependency // HACK: because the function parameter type is evaluated with 'typeof' - @profile() + @profile public matchSelectors(view: any): SelectorsMatch { // should be (view: ViewBase): SelectorsMatch this.ensureSelectors(); diff --git a/nativescript-core/ui/tab-view/index.ios.ts b/nativescript-core/ui/tab-view/index.ios.ts index 65b5587b2..9aa7b437f 100644 --- a/nativescript-core/ui/tab-view/index.ios.ts +++ b/nativescript-core/ui/tab-view/index.ios.ts @@ -12,11 +12,11 @@ import { ImageSource } from '../../image-source'; import { profile } from '../../profiling'; import { Frame } from '../frame'; import { layout, ios as iosUtils } from '../../utils'; -import { device } from '../../platform'; +import { Device } from '../../platform'; export * from './tab-view-common'; const majorVersion = iosUtils.MajorVersion; -const isPhone = device.deviceType === 'Phone'; +const isPhone = Device.deviceType === 'Phone'; class UITabBarControllerImpl extends UITabBarController { private _owner: WeakRef; @@ -36,7 +36,7 @@ class UITabBarControllerImpl extends UITabBarController { this.extendedLayoutIncludesOpaqueBars = true; } - @profile() + @profile public viewWillAppear(animated: boolean): void { super.viewWillAppear(animated); const owner = this._owner.get(); @@ -51,7 +51,7 @@ class UITabBarControllerImpl extends UITabBarController { } } - @profile() + @profile public viewDidDisappear(animated: boolean): void { super.viewDidDisappear(animated); const owner = this._owner.get(); @@ -295,7 +295,7 @@ export class TabView extends TabViewBase { super.disposeNativeView(); } - @profile() + @profile public onLoaded() { super.onLoaded(); diff --git a/nativescript-core/ui/tabs/index.ios.ts b/nativescript-core/ui/tabs/index.ios.ts index 77e6f819f..39ef3f35a 100644 --- a/nativescript-core/ui/tabs/index.ios.ts +++ b/nativescript-core/ui/tabs/index.ios.ts @@ -7,7 +7,7 @@ import { TextTransform } from '../text-base'; // Requires import { Color } from '../../color'; import { ImageSource } from '../../image-source'; -import { device } from '../../platform'; +import { Device } from '../../platform'; import { ios as iosUtils, isFontIconURI, layout } from '../../utils'; import { ios as iosView, View } from '../core/view'; import { ViewBase } from '../core/view-base'; @@ -22,7 +22,7 @@ import { swipeEnabledProperty, TabsBase, IOSTabBarItemsAlignment, iOSTabBarItems export * from './tabs-common'; const majorVersion = iosUtils.MajorVersion; -const isPhone = device.deviceType === 'Phone'; +const isPhone = Device.deviceType === 'Phone'; // Equivalent to dispatch_async(dispatch_get_main_queue(...)) call const invokeOnRunLoop = (function () { diff --git a/nativescript-core/ui/text-field/index.ios.ts b/nativescript-core/ui/text-field/index.ios.ts index 7fb4b7472..706e3c146 100644 --- a/nativescript-core/ui/text-field/index.ios.ts +++ b/nativescript-core/ui/text-field/index.ios.ts @@ -132,7 +132,7 @@ export class TextField extends TextFieldBase { super.disposeNativeView(); } - @profile() + @profile public onLoaded() { super.onLoaded(); this.ios.delegate = this._delegate; diff --git a/nativescript-core/ui/text-view/index.ios.ts b/nativescript-core/ui/text-view/index.ios.ts index 1ae1c9637..a3647276e 100644 --- a/nativescript-core/ui/text-view/index.ios.ts +++ b/nativescript-core/ui/text-view/index.ios.ts @@ -108,7 +108,7 @@ export class TextView extends TextViewBaseCommon { super.disposeNativeView(); } - @profile() + @profile public onLoaded() { super.onLoaded(); this.ios.delegate = this._delegate; diff --git a/nativescript-core/ui/web-view/index.ios.ts b/nativescript-core/ui/web-view/index.ios.ts index 9de295b13..94923ab73 100644 --- a/nativescript-core/ui/web-view/index.ios.ts +++ b/nativescript-core/ui/web-view/index.ios.ts @@ -124,7 +124,7 @@ export class WebView extends WebViewBase { super.disposeNativeView(); } - @profile() + @profile public onLoaded() { super.onLoaded(); this.ios.navigationDelegate = this._delegate; diff --git a/nativescript-core/utils/index.android.ts b/nativescript-core/utils/index.android.ts index 6177de570..5859d1101 100644 --- a/nativescript-core/utils/index.android.ts +++ b/nativescript-core/utils/index.android.ts @@ -1,5 +1,5 @@ import { ad } from './native-helper'; -import { device } from '../platform'; +import { Device } from '../platform'; import { FileSystemAccess } from '../file-system/file-system-access'; import { Trace } from '../trace'; @@ -113,7 +113,7 @@ Applications cannot access internal storage of other application on Android (see chooserIntent.addFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK); // Android SDK <28 only requires starting the chooser Intent straight forwardly - const sdkVersion = parseInt(device.sdkVersion, 10); + const sdkVersion = parseInt(Device.sdkVersion, 10); if (sdkVersion && sdkVersion < MIN_URI_SHARE_RESTRICTED_APK_VERSION) { Trace.write(`detected sdk version ${sdkVersion} (< ${MIN_URI_SHARE_RESTRICTED_APK_VERSION}), using simple openFile`, Trace.categories.Debug); intent.setDataAndType(android.net.Uri.fromFile(new java.io.File(filePath)), mimeType); diff --git a/package.json b/package.json index 1fb503f8a..bcee4fa3f 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "NativeScript", "description": "NativeScript Core Modules", "homepage": "https://nativescript.org", - "version": "7.0.0-rc.0", + "version": "7.0.0-rc.2", "repository": { "type": "git", "url": "https://github.com/NativeScript/NativeScript" diff --git a/tests/app/application/application-tests-common.ts b/tests/app/application/application-tests-common.ts index bc1d9fe25..24178e370 100644 --- a/tests/app/application/application-tests-common.ts +++ b/tests/app/application/application-tests-common.ts @@ -1,18 +1,18 @@ import * as app from "@nativescript/core/application"; -import * as platform from "@nativescript/core/platform"; +import { isAndroid, isIOS, Device, Application, platformNames } from "@nativescript/core"; import * as TKUnit from "../tk-unit"; -if (app.android) { +if (isAndroid) { console.log("We are running on an Android device!"); -} else if (app.ios) { +} else if (isIOS) { console.log("We are running on an iOS device!"); } export function testInitialized() { - if (platform.device.os === platform.platformNames.android) { + if (Device.os === platformNames.android) { TKUnit.assert(app.android, "Application module not properly intialized"); - } else if (platform.device.os === platform.platformNames.ios) { + } else if (Device.os === platformNames.ios) { TKUnit.assert(app.ios, "Application module not properly intialized"); } } @@ -23,5 +23,5 @@ export function testDisplayedEvent() { } export function testOrientation() { - TKUnit.assert(app.orientation(), "Orientation not initialized."); + TKUnit.assert(Application.orientation(), "Orientation not initialized."); } diff --git a/tests/app/file-system/file-system-tests.ts b/tests/app/file-system/file-system-tests.ts index c9c1e19db..6c0d4e10d 100644 --- a/tests/app/file-system/file-system-tests.ts +++ b/tests/app/file-system/file-system-tests.ts @@ -5,7 +5,7 @@ import * as fs from "@nativescript/core/file-system"; import * as TKUnit from "../tk-unit"; import * as appModule from "@nativescript/core/application"; -import * as platform from "@nativescript/core/platform"; +import { isIOS, Device, platformNames } from "@nativescript/core"; export var testPathNormalize = function () { // >> file-system-normalize @@ -190,7 +190,7 @@ export var testFileReadWriteBinary = function () { // >> (hide) var destination = destinationFile.readSync(e => { error = e; }); TKUnit.assertNull(error); - if (platform.device.os === platform.platformNames.ios) { + if (Device.os === platformNames.ios) { TKUnit.assertTrue(source.isEqualToData(destination)); } else { TKUnit.assertEqual(new java.io.File(sourceFile.path).length(), new java.io.File(destinationFile.path).length()); @@ -217,7 +217,7 @@ export var testFileReadWriteBinaryAsync = function () { // Succeded in writing the file destinationFile.read() .then(function (destination) { - if (platform.device.os === platform.platformNames.ios) { + if (Device.os === platformNames.ios) { TKUnit.assertTrue(source.isEqualToData(destination)); } else { TKUnit.assertEqual(new java.io.File(sourceFile.path).length(), new java.io.File(destinationFile.path).length()); @@ -268,7 +268,7 @@ function _testIOSSpecificKnownFolder(knownFolderName: string) { createdFile.writeTextSync("some text"); } }; - if (platform.isIOS) { + if (isIOS) { testFunc(); if (knownFolder) { TKUnit.assertTrue(knownFolder.isKnown, `The ${knownFolderName} folder should have its "isKnown" property set to true.`); diff --git a/tests/app/navigation/transition-tests.ts b/tests/app/navigation/transition-tests.ts index a385f5d5c..1f453f9bb 100644 --- a/tests/app/navigation/transition-tests.ts +++ b/tests/app/navigation/transition-tests.ts @@ -37,10 +37,10 @@ export function test_Transitions() { }); var transitions; - if (platform.device.os === platform.platformNames.ios) { + if (platform.Device.os === platform.platformNames.ios) { transitions = ["curl"]; } else { - const _sdkVersion = parseInt(platform.device.sdkVersion); + const _sdkVersion = parseInt(platform.Device.sdkVersion); transitions = _sdkVersion >= 21 ? ["explode"] : []; } diff --git a/tests/app/pages/page5.ts b/tests/app/pages/page5.ts index e154c7a31..3c9f48daf 100644 --- a/tests/app/pages/page5.ts +++ b/tests/app/pages/page5.ts @@ -43,11 +43,11 @@ function printDeviceInfoIOS() { } function printTNSInfo() { - console.log("platform.device.model = " + platform.device.model); - console.log("platform.device.os = " + platform.device.os); - console.log("platform.device.osVersion = " + platform.device.osVersion); - console.log("platform.device.sdkVersion = " + platform.device.sdkVersion); - console.log("platform.device.deviceType = " + platform.device.deviceType); + console.log("platform.Device.model = " + platform.Device.model); + console.log("platform.Device.os = " + platform.Device.os); + console.log("platform.Device.osVersion = " + platform.Device.osVersion); + console.log("platform.Device.sdkVersion = " + platform.Device.sdkVersion); + console.log("platform.Device.deviceType = " + platform.Device.deviceType); console.log("platform.screen.mainScreen.widthDIPs = " + platform.screen.mainScreen.widthDIPs); console.log("platform.screen.mainScreen.heightDIPs = " + platform.screen.mainScreen.heightDIPs); diff --git a/tests/app/platform/platform-tests.ts b/tests/app/platform/platform-tests.ts index 11e0d3834..2cec65952 100644 --- a/tests/app/platform/platform-tests.ts +++ b/tests/app/platform/platform-tests.ts @@ -10,26 +10,26 @@ export function test_platform() { } else { expectedPlatform = "iOS"; } - TKUnit.assertEqual(platformModule.device.os, expectedPlatform); + TKUnit.assertEqual(platformModule.Device.os, expectedPlatform); } export function test_device_screen() { - TKUnit.assert(platformModule.device.model, "Device model not initialized."); - TKUnit.assert(platformModule.device.manufacturer, "Device manufacturer not initialized."); - TKUnit.assert(platformModule.device.deviceType, "Device type not initialized."); - TKUnit.assert(platformModule.device.uuid, "Device UUID not initialized."); + TKUnit.assert(platformModule.Device.model, "Device model not initialized."); + TKUnit.assert(platformModule.Device.manufacturer, "Device manufacturer not initialized."); + TKUnit.assert(platformModule.Device.deviceType, "Device type not initialized."); + TKUnit.assert(platformModule.Device.uuid, "Device UUID not initialized."); - TKUnit.assert(platformModule.device.language, "Preferred language not initialized."); + TKUnit.assert(platformModule.Device.language, "Preferred language not initialized."); // NSLocale.currentLocale.objectForKey(NSLocaleCountryCode) not initialized by default on iOS13 simulator; // can be set through Settings -> General -> Language & Region -> Region if (platformModule.isAndroid || ios.MajorVersion < 13) { - TKUnit.assert(platformModule.device.region, "Preferred region not initialized."); + TKUnit.assert(platformModule.Device.region, "Preferred region not initialized."); } - TKUnit.assert(platformModule.device.os, "OS not initialized."); - TKUnit.assert(platformModule.device.osVersion, "OS version not initialized."); - TKUnit.assert(platformModule.device.sdkVersion, "SDK version not initialized."); + TKUnit.assert(platformModule.Device.os, "OS not initialized."); + TKUnit.assert(platformModule.Device.osVersion, "OS version not initialized."); + TKUnit.assert(platformModule.Device.sdkVersion, "SDK version not initialized."); TKUnit.assert(platformModule.screen.mainScreen.widthPixels, "Screen width (px) not initialized."); TKUnit.assert(platformModule.screen.mainScreen.heightPixels, "Screen height (px) not initialized."); diff --git a/tests/app/test-runner.ts b/tests/app/test-runner.ts index ca1264a6c..6c3e23c55 100644 --- a/tests/app/test-runner.ts +++ b/tests/app/test-runner.ts @@ -17,14 +17,14 @@ Frame.defaultAnimatedNavigation = false; export function isRunningOnEmulator(): boolean { // These checks are not good enough to be added to modules but they keep unit tests green. - if (platform.device.os === platform.platformNames.android) { + if (platform.Device.os === platform.platformNames.android) { return android.os.Build.FINGERPRINT.indexOf("generic") > -1 || android.os.Build.HARDWARE.toLowerCase() === "goldfish" || android.os.Build.HARDWARE.toLowerCase() === "donatello" || // VS Emulator android.os.Build.PRODUCT.toLocaleLowerCase().indexOf("sdk") > -1 || android.os.Build.PRODUCT.toLocaleLowerCase().indexOf("emulator") > -1; // VS Emulator } - else if (platform.device.os === platform.platformNames.ios) { + else if (platform.Device.os === platform.platformNames.ios) { return (__dirname.search("Simulator") > -1); } } @@ -397,7 +397,7 @@ function generateTestFile(allTests: TestInfo[]) { let testName = testCase.testName; let duration = (testCase.duration / 1000).toFixed(2); - testCases.push(``) + testCases.push(``) if (!testCase.isPassed) { failedTestCount++; testCases.push(``) diff --git a/tests/app/tk-unit.ts b/tests/app/tk-unit.ts index fc16be512..82e072da3 100644 --- a/tests/app/tk-unit.ts +++ b/tests/app/tk-unit.ts @@ -17,7 +17,7 @@ import * as timer from "@nativescript/core/timer"; import { Trace } from "@nativescript/core"; import * as types from "@nativescript/core/utils/types"; -const sdkVersion = parseInt(platform.device.sdkVersion); +const sdkVersion = parseInt(platform.Device.sdkVersion); Trace.enable(); diff --git a/tests/app/ui/activity-indicator/activity-indicator-tests.ts b/tests/app/ui/activity-indicator/activity-indicator-tests.ts index 049eff954..035f526fe 100644 --- a/tests/app/ui/activity-indicator/activity-indicator-tests.ts +++ b/tests/app/ui/activity-indicator/activity-indicator-tests.ts @@ -49,7 +49,7 @@ export function test_set_TNS_value_updates_native_value() { } // Uncomment this when find way to check android Drawable color set by setColorFilter() method. -if (platform.device.os === platform.platformNames.ios) { +if (platform.Device.os === platform.platformNames.ios) { exports.test_set_color = function () { var ai = new activityIndicatorModule.ActivityIndicator(); ai.color = new color.Color("red"); diff --git a/tests/app/ui/date-picker/date-picker-tests.ts b/tests/app/ui/date-picker/date-picker-tests.ts index f4c4520e4..29565aa7e 100644 --- a/tests/app/ui/date-picker/date-picker-tests.ts +++ b/tests/app/ui/date-picker/date-picker-tests.ts @@ -76,7 +76,7 @@ export class DatePickerTest extends testModule.UITest parseInt(device.sdkVersion)); +const sdkVersion = lazy(() => parseInt(Device.sdkVersion)); export const test_ImageCache_ValidUrl = function (done: (err: Error, res?: string) => void) { // see https://github.com/NativeScript/NativeScript/issues/6643 diff --git a/tests/app/ui/page/page-tests-common.ts b/tests/app/ui/page/page-tests-common.ts index 501840dcf..2e95d296e 100644 --- a/tests/app/ui/page/page-tests-common.ts +++ b/tests/app/ui/page/page-tests-common.ts @@ -786,7 +786,7 @@ export function test_WhenRootTabViewShownModallyItCanCloseModal() { } export function test_WhenPageIsNavigatedToItCanShowAnotherPageAsModal() { - // if (platform.device.os === platform.platformNames.android + // if (platform.Device.os === platform.platformNames.android // && android.os.Build.VERSION.SDK_INT === android.os.Build.VERSION_CODES.JELLY_BEAN_MR1 // && android.os.Build.CPU_ABI.indexOf("x86") !== -1) { // // Skip this test on x68 Android with API Level 17 diff --git a/tests/app/ui/progress/progress-tests.ts b/tests/app/ui/progress/progress-tests.ts index 50cd3c755..3459ce226 100644 --- a/tests/app/ui/progress/progress-tests.ts +++ b/tests/app/ui/progress/progress-tests.ts @@ -57,7 +57,7 @@ export function test_set_value_greater_than_max_should_set_value_to_max() { } // Uncomment this when find way to check android Drawable color set by setColorFilter() method. -if (platform.device.os === platform.platformNames.ios) { +if (platform.Device.os === platform.platformNames.ios) { exports.test_set_color = function () { var progress = new progressModule.Progress(); progress.color = new color.Color("red"); diff --git a/tests/app/ui/styling/root-views-css-classes-tests.ts b/tests/app/ui/styling/root-views-css-classes-tests.ts index 679cb6d46..84397eb95 100644 --- a/tests/app/ui/styling/root-views-css-classes-tests.ts +++ b/tests/app/ui/styling/root-views-css-classes-tests.ts @@ -9,7 +9,7 @@ import { import { isAndroid, isIOS, - device + Device } from "@nativescript/core/platform"; import { Button } from "@nativescript/core"; import { Page } from "@nativescript/core/ui/page"; @@ -75,7 +75,7 @@ function _test_device_type_css_class(rootView: View, shouldSetClassName: boolean } const cssClasses = rootView.cssClasses; - const deviceType = device.deviceType; + const deviceType = Device.deviceType; if (deviceType === DeviceType.Phone) { TKUnit.assertTrue(cssClasses.has(PHONE_DEVICE_TYPE_CSS_CLASS), `${PHONE_DEVICE_TYPE_CSS_CLASS} CSS class is missing`); TKUnit.assertFalse(cssClasses.has(TABLET_DEVICE_TYPE_CSS_CLASS), `${TABLET_DEVICE_TYPE_CSS_CLASS} CSS class is present`); diff --git a/tests/app/ui/switch/switch-tests.ts b/tests/app/ui/switch/switch-tests.ts index ec86b6b1d..ce34d12c4 100644 --- a/tests/app/ui/switch/switch-tests.ts +++ b/tests/app/ui/switch/switch-tests.ts @@ -42,7 +42,7 @@ export function test_default_native_values() { } // Uncomment this when find way to check android Drawable color set by setColorFilter() method. -if (platform.device.os === platform.platformNames.ios) { +if (platform.Device.os === platform.platformNames.ios) { exports.test_set_color = function () { var mySwitch = new switchModule.Switch(); mySwitch.color = new Color("red"); diff --git a/tests/app/ui/text-view/text-view-tests.ts b/tests/app/ui/text-view/text-view-tests.ts index 935f224b0..1a83770f5 100644 --- a/tests/app/ui/text-view/text-view-tests.ts +++ b/tests/app/ui/text-view/text-view-tests.ts @@ -87,7 +87,7 @@ export var testSetTextUndefined = function () { }; // Supported for ios only. -if (platform.device.os === platform.platformNames.ios) { +if (platform.Device.os === platform.platformNames.ios) { exports.test_set_color = function () { helper.buildUIAndRunTest(_createTextViewFunc(), function (views: Array) { var textView = views[0]; diff --git a/tests/app/ui/time-picker/time-picker-tests.ts b/tests/app/ui/time-picker/time-picker-tests.ts index 020978806..415f425a8 100644 --- a/tests/app/ui/time-picker/time-picker-tests.ts +++ b/tests/app/ui/time-picker/time-picker-tests.ts @@ -49,7 +49,7 @@ export class TimePickerTest extends testModule.UITestBuilder.parse(""); var tf = p.content; - if (platform.device.os === platform.platformNames.ios) { + if (platform.Device.os === platform.platformNames.ios) { TKUnit.assertFalse(tf.editable, "Expected result: false; Actual result: " + tf.editable + "; type: " + typeof (tf.editable)); } else { TKUnit.assertTrue(tf.editable, "Expected result: true; Actual result: " + tf.editable + "; type: " + typeof (tf.editable)); @@ -350,7 +350,7 @@ export function test_parse_ShouldParsePlatformSpecificProperties() { export function test_parse_ShouldParsePlatformSpecificComponents() { var p = Builder.parse(""); - if (platform.device.os === platform.platformNames.ios) { + if (platform.Device.os === platform.platformNames.ios) { TKUnit.assert(p.content instanceof textFieldModule.TextField, "Expected result: TextField; Actual result: " + p.content); } else { diff --git a/tests/app/xml-parser-tests/xml-parser-tests.ts b/tests/app/xml-parser-tests/xml-parser-tests.ts index 650ecb00a..182a982e3 100644 --- a/tests/app/xml-parser-tests/xml-parser-tests.ts +++ b/tests/app/xml-parser-tests/xml-parser-tests.ts @@ -6,10 +6,10 @@ import * as TKUnit from "../tk-unit"; import * as xmlModule from "@nativescript/core/xml"; import * as fs from "@nativescript/core/file-system"; import { Builder } from "@nativescript/core/ui/builder"; -import { isIOS, device } from "@nativescript/core/platform"; +import { isIOS, Device } from "@nativescript/core/platform"; import lazy from "@nativescript/core/utils/lazy"; -const sdkVersion = lazy(() => parseInt(device.sdkVersion)); +const sdkVersion = lazy(() => parseInt(Device.sdkVersion)); export var test_XmlParser_IsDefined = function () { TKUnit.assertNotEqual(xmlModule.XmlParser, undefined, "Class XmlParser should be defined!");