From 70041bd9991d393441595326566ca45f6dcba2e8 Mon Sep 17 00:00:00 2001 From: Hristo Deshev Date: Fri, 30 Oct 2015 17:01:15 +0200 Subject: [PATCH 1/2] Don't expose platform types in public d.ts files. Use any. Add a comment with the real type. --- application/application.d.ts | 46 +++++++++---------- color/color.d.ts | 4 +- image-source/image-source.d.ts | 6 +-- location/location.d.ts | 10 ++-- ui/action-bar/action-bar.d.ts | 6 +-- ui/activity-indicator/activity-indicator.d.ts | 6 +-- ui/button/button.d.ts | 6 +-- ui/core/control-state-change.d.ts | 4 +- ui/core/view.android.ts | 12 ----- ui/core/view.d.ts | 11 +---- ui/date-picker/date-picker.d.ts | 6 +-- ui/frame/frame.d.ts | 16 +++---- ui/gestures/gestures.d.ts | 6 +-- ui/html-view/html-view.d.ts | 6 +-- ui/image/image.d.ts | 4 +- ui/label/label.d.ts | 6 +-- ui/layouts/layout.android.ts | 16 ++++++- ui/list-picker/list-picker.d.ts | 6 +-- ui/list-view/list-view.d.ts | 8 ++-- ui/progress/progress.d.ts | 6 +-- ui/search-bar/search-bar.d.ts | 6 +-- ui/slider/slider.d.ts | 6 +-- ui/styling/background.android.d.ts | 11 +++++ ui/styling/background.d.ts | 12 +---- ui/styling/font.d.ts | 6 +-- ui/switch/switch.d.ts | 6 +-- ui/tab-view/tab-view.d.ts | 8 ++-- ui/text-field/text-field.d.ts | 6 +-- ui/text-view/text-view.d.ts | 6 +-- ui/time-picker/time-picker.d.ts | 6 +-- ui/utils.d.ts | 4 +- ui/web-view/web-view.d.ts | 6 +-- utils/utils.d.ts | 14 +++--- 33 files changed, 141 insertions(+), 147 deletions(-) create mode 100644 ui/styling/background.android.d.ts diff --git a/application/application.d.ts b/application/application.d.ts index ec75aedcd..aba0b1ebb 100644 --- a/application/application.d.ts +++ b/application/application.d.ts @@ -243,7 +243,7 @@ declare module "application" { /** * The activity. */ - activity: android.app.Activity; + activity: any /* android.app.Activity */; /** * The name of the event. @@ -263,7 +263,7 @@ declare module "application" { /** * The bundle. */ - bundle: android.os.Bundle; + bundle: any /* android.os.Bundle */; } /** @@ -283,7 +283,7 @@ declare module "application" { /** * The intent. */ - intent: android.content.Intent; + intent: any /* android.content.Intent */; } /** @@ -303,27 +303,27 @@ declare module "application" { /** * The [android Application](http://developer.android.com/reference/android/app/Application.html) object instance provided to the init of the module. */ - nativeApp: android.app.Application; + nativeApp: any /* android.app.Application */; /** * The application's [android Context](http://developer.android.com/reference/android/content/Context.html) object instance. */ - context: android.content.Context; + context: any /* android.content.Context */; /** * The currently active (loaded) [android Activity](http://developer.android.com/reference/android/app/Activity.html). This property is automatically updated upon Activity events. */ - foregroundActivity: android.app.Activity; + foregroundActivity: any /* android.app.Activity */; /** * The currently active (loaded) Context. This is typically the top-level Activity that is just created. */ - currentContext: android.content.Context; + currentContext: any /* android.content.Context */; /** * The main (start) Activity for the application. */ - startActivity: android.app.Activity; + startActivity: any /* android.app.Activity */; /** * The name of the application package. @@ -335,47 +335,47 @@ declare module "application" { * @param intent - Native (android) intent used to create the activity. * Returns com.tns.NativeScriptActivity.extend implementation. */ - getActivity(intent: android.content.Intent): any; + getActivity(intent: any /* android.content.Intent */): any; /** * [Deprecated. Please use the respective event instead.] Direct handler of the [onActivityCreated method](http://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html). */ - onActivityCreated: (activity: android.app.Activity, bundle: android.os.Bundle) => void; + onActivityCreated: (activity: any /* android.app.Activity */, bundle: any /* android.os.Bundle */) => void; /** * [Deprecated. Please use the respective event instead.] Direct handler of the [onActivityDestroyed method](http://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html). */ - onActivityDestroyed: (activity: android.app.Activity) => void; + onActivityDestroyed: (activity: any /* android.app.Activity */) => void; /** * [Deprecated. Please use the respective event instead.] Direct handler of the [onActivityDestroyed method](http://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html). */ - onActivityStarted: (activity: android.app.Activity) => void; + onActivityStarted: (activity: any /* android.app.Activity */) => void; /** * [Deprecated. Please use the respective event instead.] Direct handler of the [onActivityPaused method](http://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html). */ - onActivityPaused: (activity: android.app.Activity) => void; + onActivityPaused: (activity: any /* android.app.Activity */) => void; /** * [Deprecated. Please use the respective event instead.] Direct handler of the [onActivityResumed method](http://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html). */ - onActivityResumed: (activity: android.app.Activity) => void; + onActivityResumed: (activity: any /* android.app.Activity */) => void; /** * [Deprecated. Please use the respective event instead.] Direct handler of the [onActivityStopped method](http://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html). */ - onActivityStopped: (activity: android.app.Activity) => void; + onActivityStopped: (activity: any /* android.app.Activity */) => void; /** * [Deprecated. Please use the respective event instead.] Direct handler of the [onActivitySaveInstanceState method](http://developer.android.com/reference/android/app/Application.ActivityLifecycleCallbacks.html). */ - onSaveActivityState: (activity: android.app.Activity, bundle: android.os.Bundle) => void; + onSaveActivityState: (activity: any /* android.app.Activity */, bundle: any /* android.os.Bundle */) => void; /** * [Deprecated. Please use the respective event instead.] Direct handler of the onActivityResult method. */ - onActivityResult: (requestCode: number, resultCode: number, data: android.content.Intent) => void; + onActivityResult: (requestCode: number, resultCode: number, data: any /* android.content.Intent */) => void; /** * A basic method signature to hook an event listener (shortcut alias to the addEventListener method). @@ -481,7 +481,7 @@ declare module "application" { * @param intentFilter A string containing the intent filter. * @param onReceiveCallback A callback function that will be called each time the receiver receives a broadcast. */ - registerBroadcastReceiver(intentFilter: string, onReceiveCallback: (context: android.content.Context, intent: android.content.Intent) => void): void; + registerBroadcastReceiver(intentFilter: string, onReceiveCallback: (context: any /* android.content.Context */, intent: any /* android.content.Intent */) => void): void; /** * Unregister a previously registered BroadcastReceiver. @@ -500,17 +500,17 @@ declare module "application" { /** * The root view controller for the application. */ - rootController: UIViewController; + rootController: any /* UIViewController */; /** * The [UIApplication](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplication_Class/index.html). */ - nativeApp: UIApplication; + nativeApp: any /* UIApplication */; /** * The [UIApplicationDelegate](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIApplicationDelegate_Protocol/index.html) class. */ - delegate: typeof UIApplicationDelegate; + delegate: any /* typeof UIApplicationDelegate */; /** * Adds an observer to the default notification center for the specified notification. @@ -518,7 +518,7 @@ declare module "application" { * @param notificationName A string containing the name of the notification. * @param onReceiveCallback A callback function that will be called each time the observer receives a notification. */ - addNotificationObserver(notificationName: string, onReceiveCallback: (notification: NSNotification) => void): any; + addNotificationObserver(notificationName: string, onReceiveCallback: (notification: any /* NSNotification */) => void): any; /** * Removes the observer for the specified notification from the default notification center. @@ -529,4 +529,4 @@ declare module "application" { */ removeNotificationObserver(observer: any, notificationName: string): void; } -} \ No newline at end of file +} diff --git a/color/color.d.ts b/color/color.d.ts index 5b97b5bfc..e227d87cb 100644 --- a/color/color.d.ts +++ b/color/color.d.ts @@ -54,7 +54,7 @@ declare module "color" { /** * Gets the iOS-specific UIColor value representation. This is a read-only property. */ - ios: UIColor; + ios: any /* UIColor */; /** * Specifies whether this Color is equal to the Color parameter. @@ -75,4 +75,4 @@ declare module "color" { */ public static isValid(value: any): boolean; } -} \ No newline at end of file +} diff --git a/image-source/image-source.d.ts b/image-source/image-source.d.ts index 956612c6e..aa71208e3 100644 --- a/image-source/image-source.d.ts +++ b/image-source/image-source.d.ts @@ -20,12 +20,12 @@ declare module "image-source" { /** * The iOS-specific [UIImage](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIImage_Class/) instance. Will be undefined when running on Android. */ - ios: UIImage; + ios: any /* UIImage */; /** * The Android-specific [image](http://developer.android.com/reference/android/graphics/Bitmap.html) instance. Will be undefined when running on iOS. */ - android: android.graphics.Bitmap; + android: any /* android.graphics.Bitmap */; /** * Loads this instance from the specified resource name. @@ -122,4 +122,4 @@ declare module "image-source" { * @param path The path. */ export function isFileOrResourcePath(path: string): boolean -} \ No newline at end of file +} diff --git a/location/location.d.ts b/location/location.d.ts index 72c521e8f..596711a20 100644 --- a/location/location.d.ts +++ b/location/location.d.ts @@ -57,12 +57,12 @@ declare module "location" { /** * The android-specific [location](http://developer.android.com/reference/android/location/Location.html) object. */ - android: android.location.Location; + android: any /* android.location.Location */; /** * The ios-specific [CLLocation](https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocation_Class/) object. */ - ios: CLLocation; + ios: any /* CLLocation */; } /** @@ -162,7 +162,7 @@ declare module "location" { /** * The android-specific location manager [LocationManager](http://developer.android.com/reference/android/location/LocationManager.html) */ - manager: android.location.LocationManager; + manager: any /* android.location.LocationManager */; /** * The minimum time interval between subsequent location updates, in milliseconds. @@ -186,6 +186,6 @@ declare module "location" { /** * The ios-specific location manager [CLLocationManager](https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/) */ - manager: CLLocationManager; + manager: any /* CLLocationManager */; } -} \ No newline at end of file +} diff --git a/ui/action-bar/action-bar.d.ts b/ui/action-bar/action-bar.d.ts index 1b85ccb80..7841dcc8a 100644 --- a/ui/action-bar/action-bar.d.ts +++ b/ui/action-bar/action-bar.d.ts @@ -205,7 +205,7 @@ declare module "ui/action-bar" { } //@private - export function _setNavBarColor(navBar: UINavigationBar, color: UIColor); - export function _setNavBarBackgroundColor(navBar: UINavigationBar, color: UIColor); + export function _setNavBarColor(navBar: any /* UINavigationBar */, color: any /* UIColor */); + export function _setNavBarBackgroundColor(navBar: any /* UINavigationBar */, color: any /* UIColor */); //@endprivate -} \ No newline at end of file +} diff --git a/ui/activity-indicator/activity-indicator.d.ts b/ui/activity-indicator/activity-indicator.d.ts index 708c670f4..9a584f446 100644 --- a/ui/activity-indicator/activity-indicator.d.ts +++ b/ui/activity-indicator/activity-indicator.d.ts @@ -17,16 +17,16 @@ declare module "ui/activity-indicator" { /** * Gets the native [android widget](http://developer.android.com/reference/android/widget/ProgressBar.html) that represents the user interface for this component. Valid only when running on Android OS. */ - android: android.widget.ProgressBar; + android: any /* android.widget.ProgressBar */; /** * Gets the native iOS [UIActivityIndicatorView](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIActivityIndicatorView_Class/index.html) that represents the user interface for this component. Valid only when running on iOS. */ - ios: UIActivityIndicatorView; + ios: any /* UIActivityIndicatorView */; /** * Gets or sets a value indicating whether the widget is currently displaying progress. */ busy: boolean; } -} \ No newline at end of file +} diff --git a/ui/button/button.d.ts b/ui/button/button.d.ts index 925c46bfd..ef020410f 100644 --- a/ui/button/button.d.ts +++ b/ui/button/button.d.ts @@ -24,12 +24,12 @@ declare module "ui/button" { /** * Gets the native [android widget](http://developer.android.com/reference/android/widget/Button.html) that represents the user interface for this component. Valid only when running on Android OS. */ - android: android.widget.Button; + android: any /* android.widget.Button */; /** * Gets the native [UIButton](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIButton_Class/) that represents the user interface for this component. Valid only when running on iOS. */ - ios: UIButton; + ios: any /* UIButton */; /** * Gets or sets the text (label) displayed by this instance. @@ -62,4 +62,4 @@ declare module "ui/button" { */ _addChildFromBuilder(name: string, value: any): void; } -} \ No newline at end of file +} diff --git a/ui/core/control-state-change.d.ts b/ui/core/control-state-change.d.ts index 4886f4a63..5ca2fcde9 100644 --- a/ui/core/control-state-change.d.ts +++ b/ui/core/control-state-change.d.ts @@ -9,6 +9,6 @@ * @param control An instance of the UIControl which state will be watched. * @param callback A callback called when a visual state of the UIControl is changed. */ - constructor(control: UIControl, callback: (state: string) => void); + constructor(control: any /* UIControl */, callback: (state: string) => void); } -} \ No newline at end of file +} diff --git a/ui/core/view.android.ts b/ui/core/view.android.ts index cd9843eeb..60753f31b 100644 --- a/ui/core/view.android.ts +++ b/ui/core/view.android.ts @@ -62,18 +62,6 @@ function onIsUserInteractionEnabledPropertyChanged(data: dependencyObservable.Pr } (viewCommon.View.isUserInteractionEnabledProperty.metadata).onSetNativeValue = onIsUserInteractionEnabledPropertyChanged; -export var NativeViewGroup = (android.view.ViewGroup).extend({ - onMeasure: function (widthMeasureSpec, heightMeasureSpec) { - var owner: viewDefinition.View = this[OWNER]; - owner.onMeasure(widthMeasureSpec, heightMeasureSpec); - this.setMeasuredDimension(owner.getMeasuredWidth(), owner.getMeasuredHeight()); - }, - onLayout: function (changed: boolean, left: number, top: number, right: number, bottom: number): void { - var owner: viewDefinition.View = this[OWNER]; - owner.onLayout(left, top, right, bottom); - } -}); - export class View extends viewCommon.View { private _disableUserInteractionListener: android.view.View.OnTouchListener = new android.view.View.OnTouchListener({ onTouch: function (view: android.view.View, event: android.view.MotionEvent) { diff --git a/ui/core/view.d.ts b/ui/core/view.d.ts index 36fdb0157..ee59508a3 100644 --- a/ui/core/view.d.ts +++ b/ui/core/view.d.ts @@ -452,7 +452,7 @@ declare module "ui/core/view" { _propagateInheritableProperties(view: View) _inheritProperties(parentView: View) _removeView(view: View); - _context: android.content.Context; + _context: any /* android.content.Context */; public _applyXmlAttribute(attribute: string, value: any): boolean; @@ -474,7 +474,7 @@ declare module "ui/core/view" { _eachChildView(callback: (child: View) => boolean); _childrenCount: number; - _onAttached(context: android.content.Context): void; + _onAttached(context: any /* android.content.Context */): void; _onContextChanged(): void; _onDetached(force?: boolean): void; _createUI(): void; @@ -511,13 +511,6 @@ declare module "ui/core/view" { export class CustomLayoutView extends View { } - //@private - export class NativeViewGroup extends android.view.ViewGroup { - constructor(context: android.content.Context); - public setOwner(view: View); - } - //@endprivate - /** * Defines an interface for adding arrays declared in xml. */ diff --git a/ui/date-picker/date-picker.d.ts b/ui/date-picker/date-picker.d.ts index 9e3978489..5d7e4c940 100644 --- a/ui/date-picker/date-picker.d.ts +++ b/ui/date-picker/date-picker.d.ts @@ -18,12 +18,12 @@ declare module "ui/date-picker" { /** * Gets the native [android.widget.DatePicker](http://developer.android.com/reference/android/widget/DatePicker.html) that represents the user interface for this component. Valid only when running on Android OS. */ - android: android.widget.DatePicker; + android: any /* android.widget.DatePicker */; /** * Gets the native iOS [UIDatePicker](http://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIDatePicker_Class/index.html) that represents the user interface for this component. Valid only when running on iOS. */ - ios: UIDatePicker; + ios: any /* UIDatePicker */; /** * Gets or sets the year. @@ -50,4 +50,4 @@ declare module "ui/date-picker" { */ minDate: Date; } -} \ No newline at end of file +} diff --git a/ui/frame/frame.d.ts b/ui/frame/frame.d.ts index 86cf6099e..d4c65d512 100644 --- a/ui/frame/frame.d.ts +++ b/ui/frame/frame.d.ts @@ -176,7 +176,7 @@ declare module "ui/frame" { /** * Gets the Android-specific menu item that has been selected. */ - item: android.view.IMenuItem; + item: any /* android.view.IMenuItem */; /** * True to mark the event as handled (that is to prevent the default processing). @@ -193,28 +193,28 @@ declare module "ui/frame" { /** * Gets the native [android ViewGroup](http://developer.android.com/reference/android/view/ViewGroup.html) instance that represents the root layout part of the Frame. */ - rootViewGroup: android.view.ViewGroup; + rootViewGroup: any /* android.view.ViewGroup */; /** * Gets the native [android Activity](http://developer.android.com/reference/android/app/Activity.html) instance associated with this Frame. In case of nested Frame objects, this property points to the activity of the root Frame. */ - activity: android.app.Activity; + activity: any /* android.app.Activity */; /** * Gets the current (foreground) activity for the application. This property will recursively traverse all existing Frame objects and check for own Activity property. */ - currentActivity: android.app.Activity; + currentActivity: any /* android.app.Activity */; /** * Gets the actionBar property of the currentActivity. */ - actionBar: android.app.ActionBar; + actionBar: any /* android.app.ActionBar */; /** * A function called by the Runtime whenever a new Activity is about to be opened. * @param intent The native [android Intent](http://developer.android.com/reference/android/content/Intent.html) object passed to the Activity's onCreate method. */ - onActivityRequested(intent: android.content.Intent): Object; + onActivityRequested(intent: any /* android.content.Intent */): Object; /** * Determines whether the Activity associated with this Frame will display an action bar or not. @@ -237,7 +237,7 @@ declare module "ui/frame" { /** * Gets the native [UINavigationController](https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UINavigationController_Class/index.html) instance associated with this Frame. */ - controller: UINavigationController; + controller: any /* UINavigationController */; /** * Gets or sets the visibility of navigationBar. @@ -245,4 +245,4 @@ declare module "ui/frame" { */ navBarVisibility: string; } -} \ No newline at end of file +} diff --git a/ui/gestures/gestures.d.ts b/ui/gestures/gestures.d.ts index 8075edeb2..3add21a14 100644 --- a/ui/gestures/gestures.d.ts +++ b/ui/gestures/gestures.d.ts @@ -76,7 +76,7 @@ declare module "ui/gestures" { /** * Gets the underlying native iOS specific [UIGestureRecognizer](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIGestureRecognizer_Class/). */ - ios: UIGestureRecognizer + ios: any /* UIGestureRecognizer */; /** * Gets the underlying native android specific [gesture detector](http://developer.android.com/reference/android/view/GestureDetector.html). */ @@ -151,7 +151,7 @@ declare module "ui/gestures" { /** * An internal Android specific method used to pass the motion event to the correct gesture observer. */ - androidOnTouchEvent: (motionEvent: android.view.MotionEvent) => void; + androidOnTouchEvent: (motionEvent: any /* android.view.MotionEvent */) => void; } /** @@ -174,4 +174,4 @@ declare module "ui/gestures" { * @param type - A string representation of a gesture type (e.g. Tap). */ export function fromString(type: string): GestureTypes; -} \ No newline at end of file +} diff --git a/ui/html-view/html-view.d.ts b/ui/html-view/html-view.d.ts index 522cf6940..a188724f7 100644 --- a/ui/html-view/html-view.d.ts +++ b/ui/html-view/html-view.d.ts @@ -22,12 +22,12 @@ declare module "ui/html-view" { /** * Gets the native [android widget](http://developer.android.com/reference/android/widget/TextView.html) that represents the user interface for this component. Valid only when running on Android OS. */ - android: android.widget.TextView; + android: any /* android.widget.TextView */; /** * Gets the native [UILabel](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UILabel_Class/) that represents the user interface for this component. Valid only when running on iOS. */ - ios: UILabel; + ios: any /* UILabel */; /** * Gets or sets html string for the HtmlView. @@ -44,4 +44,4 @@ declare module "ui/html-view" { */ html?: string; } -} \ No newline at end of file +} diff --git a/ui/image/image.d.ts b/ui/image/image.d.ts index 27b8b6ab5..7c699bdb6 100644 --- a/ui/image/image.d.ts +++ b/ui/image/image.d.ts @@ -18,12 +18,12 @@ declare module "ui/image" { /** * Gets the native [android widget](http://developer.android.com/reference/android/widget/ImageView.html) that represents the user interface for this component. Valid only when running on Android OS. */ - android: android.widget.ImageView; + android: any /* android.widget.ImageView */; /** * Gets the native iOS [UIImageView](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIImageView_Class/) that represents the user interface for this component. Valid only when running on iOS. */ - ios: UIImageView; + ios: any /* UIImageView */; /** * Gets or sets the image source of the image. diff --git a/ui/label/label.d.ts b/ui/label/label.d.ts index 0ee2ea45d..eab7dae1f 100644 --- a/ui/label/label.d.ts +++ b/ui/label/label.d.ts @@ -21,12 +21,12 @@ declare module "ui/label" { /** * Gets the native [android widget](http://developer.android.com/reference/android/widget/TextView.html) that represents the user interface for this component. Valid only when running on Android OS. */ - android: android.widget.TextView; + android: any /* android.widget.TextView */; /** * Gets the native [UILabel](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UILabel_Class/) that represents the user interface for this component. Valid only when running on iOS. */ - ios: UILabel; + ios: any /* UILabel */; /** * Gets or sets whether the Label wraps text or not. @@ -48,4 +48,4 @@ declare module "ui/label" { */ textWrap?: boolean; } -} \ No newline at end of file +} diff --git a/ui/layouts/layout.android.ts b/ui/layouts/layout.android.ts index 2d9a93123..934f1b510 100644 --- a/ui/layouts/layout.android.ts +++ b/ui/layouts/layout.android.ts @@ -6,6 +6,18 @@ import utils = require("utils/utils"); var OWNER = "_owner"; +var NativeViewGroup = (android.view.ViewGroup).extend({ + onMeasure: function (widthMeasureSpec, heightMeasureSpec) { + var owner: view.View = this[OWNER]; + owner.onMeasure(widthMeasureSpec, heightMeasureSpec); + this.setMeasuredDimension(owner.getMeasuredWidth(), owner.getMeasuredHeight()); + }, + onLayout: function (changed: boolean, left: number, top: number, right: number, bottom: number): void { + var owner: view.View = this[OWNER]; + owner.onLayout(left, top, right, bottom); + } +}); + export class Layout extends layoutBase.LayoutBase implements definition.Layout { private _viewGroup: android.view.ViewGroup; @@ -18,7 +30,7 @@ export class Layout extends layoutBase.LayoutBase implements definition.Layout { } public _createUI() { - this._viewGroup = new view.NativeViewGroup(this._context); + this._viewGroup = new NativeViewGroup(this._context); this._viewGroup[OWNER] = this; } @@ -60,4 +72,4 @@ export class Layout extends layoutBase.LayoutBase implements definition.Layout { public onLayout(left: number, top: number, right: number, bottom: number): void { // Don't call super because it will trigger layout again. } -} \ No newline at end of file +} diff --git a/ui/list-picker/list-picker.d.ts b/ui/list-picker/list-picker.d.ts index 7dab06705..ba8c69536 100644 --- a/ui/list-picker/list-picker.d.ts +++ b/ui/list-picker/list-picker.d.ts @@ -17,12 +17,12 @@ declare module "ui/list-picker" { /** * Gets the native [android.widget.NumberPicker](http://developer.android.com/reference/android/widget/NumberPicker.html) that represents the user interface for this component. Valid only when running on Android OS. */ - android: android.widget.NumberPicker; + android: any /* android.widget.NumberPicker */; /** * Gets the native iOS [UIPickerView](http://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIDatePicker_Class/index.html) that represents the user interface for this component. Valid only when running on iOS. */ - ios: UIPickerView; + ios: any /* UIPickerView */; /** * Gets or sets the selected index. @@ -35,4 +35,4 @@ declare module "ui/list-picker" { */ items: any; } -} \ No newline at end of file +} diff --git a/ui/list-view/list-view.d.ts b/ui/list-view/list-view.d.ts index abdc5236e..798fbae82 100644 --- a/ui/list-view/list-view.d.ts +++ b/ui/list-view/list-view.d.ts @@ -52,12 +52,12 @@ declare module "ui/list-view" { /** * Gets the native [android widget](http://developer.android.com/reference/android/widget/ListView.html) that represents the user interface for this component. Valid only when running on Android OS. */ - android: android.widget.ListView; + android: any /* android.widget.ListView */; /** * Gets the native [iOS view](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableView_Class/) that represents the user interface for this component. Valid only when running on iOS. */ - ios: UITableView; + ios: any /* UITableView */; /** * Gets a value indicating whether the ListView is currently scrolling. @@ -137,11 +137,11 @@ declare module "ui/list-view" { /** * Gets the native [iOS view](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableViewCell_Class/) that represents the user interface where the view is hosted. Valid only when running on iOS. */ - ios: UITableViewCell; + ios: any /* UITableViewCell */; /** * Gets the native [android widget](http://developer.android.com/reference/android/view/ViewGroup.html) that represents the user interface where the view is hosted. Valid only when running on Android OS. */ - android: android.view.ViewGroup; + android: any /* android.view.ViewGroup */; } } diff --git a/ui/progress/progress.d.ts b/ui/progress/progress.d.ts index 055520a0f..efd160897 100644 --- a/ui/progress/progress.d.ts +++ b/ui/progress/progress.d.ts @@ -22,12 +22,12 @@ declare module "ui/progress" { /** * Gets the native [android widget](http://developer.android.com/reference/android/widget/ProgressBar.html) that represents the user interface for this component. Valid only when running on Android OS. */ - android: android.widget.ProgressBar; + android: any /* android.widget.ProgressBar */; /** * Gets the native iOS [UIProgressView](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIProgressView_Class/) that represents the user interface for this component. Valid only when running on iOS. */ - ios: UIProgressView; + ios: any /* UIProgressView */; /** * Gets or sets a progress current value. @@ -39,4 +39,4 @@ declare module "ui/progress" { */ maxValue: number; } -} \ No newline at end of file +} diff --git a/ui/search-bar/search-bar.d.ts b/ui/search-bar/search-bar.d.ts index 73e272e39..7d99048f7 100644 --- a/ui/search-bar/search-bar.d.ts +++ b/ui/search-bar/search-bar.d.ts @@ -34,12 +34,12 @@ declare module "ui/search-bar" { /** * Gets the native [android widget](http://developer.android.com/reference/android/widget/SearchView.html) that represents the user interface for this component. Valid only when running on Android OS. */ - android: android.widget.SearchView; + android: any /* android.widget.SearchView */; /** * Gets the native iOS [UISearchBar](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UISearchBar_Class/) that represents the user interface for this component. Valid only when running on iOS. */ - ios: UISearchBar; + ios: any /* UISearchBar */; /** * Gets or sets a search bar text. @@ -84,4 +84,4 @@ declare module "ui/search-bar" { */ dismissSoftInput(): void; } -} \ No newline at end of file +} diff --git a/ui/slider/slider.d.ts b/ui/slider/slider.d.ts index 0107f9cb8..086ac25dc 100644 --- a/ui/slider/slider.d.ts +++ b/ui/slider/slider.d.ts @@ -27,12 +27,12 @@ declare module "ui/slider" { /** * Gets the native [android widget](http://developer.android.com/reference/android/widget/SeekBar.html) that represents the user interface for this component. Valid only when running on Android OS. */ - android: android.widget.SeekBar; + android: any /* android.widget.SeekBar */; /** * Gets the native iOS [UISlider](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UISlider_Class/) that represents the user interface for this component. Valid only when running on iOS. */ - ios: UISlider; + ios: any /* UISlider */; /** * Gets or sets a slider current value. The default value is 0. @@ -49,4 +49,4 @@ declare module "ui/slider" { */ maxValue: number; } -} \ No newline at end of file +} diff --git a/ui/styling/background.android.d.ts b/ui/styling/background.android.d.ts new file mode 100644 index 000000000..477a4faba --- /dev/null +++ b/ui/styling/background.android.d.ts @@ -0,0 +1,11 @@ +declare module "ui/styling/background" { + // We are using "ad" here to avoid namespace collision with the global android object + export module ad { + export class BorderDrawable extends android.graphics.drawable.ColorDrawable { + borderWidth: number; + cornerRadius: number; + borderColor: number; + background: Background; + } + } +} diff --git a/ui/styling/background.d.ts b/ui/styling/background.d.ts index c28ddb4f8..ce1ab4ba9 100644 --- a/ui/styling/background.d.ts +++ b/ui/styling/background.d.ts @@ -44,16 +44,6 @@ declare module "ui/styling/background" { } export module ios { - export function createBackgroundUIColor(view: viewModule.View): UIColor; - } - - // We are using "ad" here to avoid namespace collision with the global android object - export module ad { - export class BorderDrawable extends android.graphics.drawable.ColorDrawable { - borderWidth: number; - cornerRadius: number; - borderColor: number; - background: Background; - } + export function createBackgroundUIColor(view: viewModule.View): any /* UIColor */; } } diff --git a/ui/styling/font.d.ts b/ui/styling/font.d.ts index 879a4caf7..22132eb35 100644 --- a/ui/styling/font.d.ts +++ b/ui/styling/font.d.ts @@ -12,8 +12,8 @@ constructor(family: string, size: number, style: string, weight: string); - public getAndroidTypeface(): android.graphics.Typeface; - public getUIFont(defaultFont: UIFont): UIFont; + public getAndroidTypeface(): any /* android.graphics.Typeface */; + public getUIFont(defaultFont: any /* UIFont */): any /* UIFont */; public withFontFamily(family: string): Font; public withFontStyle(style: string): Font; @@ -27,4 +27,4 @@ export module ios { export function registerFont(fontFile: string); } -} \ No newline at end of file +} diff --git a/ui/switch/switch.d.ts b/ui/switch/switch.d.ts index e053d9eac..6ac697d84 100644 --- a/ui/switch/switch.d.ts +++ b/ui/switch/switch.d.ts @@ -18,16 +18,16 @@ declare module "ui/switch" { /** * Gets the native [android widget](http://developer.android.com/reference/android/widget/Switch.html) that represents the user interface for this component. Valid only when running on Android OS. */ - android: android.widget.Switch; + android: any /* android.widget.Switch */; /** * Gets the native iOS [UISwitch](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UISwitch_Class/) that represents the user interface for this component. Valid only when running on iOS. */ - ios: UISwitch; + ios: any /* UISwitch */; /** * Gets or sets if a switch is checked or not. */ checked: boolean; } -} \ No newline at end of file +} diff --git a/ui/tab-view/tab-view.d.ts b/ui/tab-view/tab-view.d.ts index f97073152..c19169fae 100644 --- a/ui/tab-view/tab-view.d.ts +++ b/ui/tab-view/tab-view.d.ts @@ -74,12 +74,12 @@ declare module "ui/tab-view" { /** * Gets the native [android widget](http://developer.android.com/reference/android/support/v4/view/ViewPager.html) that represents the user interface for this component. Valid only when running on Android OS. */ - android: android.view.View;//android.support.v4.view.ViewPager; + android: any /* android.view.View */;//android.support.v4.view.ViewPager; /** * Gets the native iOS [UITabBarController](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITabBarController_Class/) that represents the user interface for this component. Valid only when running on iOS. */ - ios: UITabBarController; + ios: any /* UITabBarController */; /** * String value used when hooking to the selectedIndexChanged event. @@ -100,8 +100,8 @@ declare module "ui/tab-view" { on(event: "selectedIndexChanged", callback: (args: SelectedIndexChangedEventData) => void, thisArg?: any); //@private - _getAndroidTabView(): org.nativescript.widgets.TabLayout; + _getAndroidTabView(): any /* org.nativescript.widgets.TabLayout */; _updateIOSTabBarColors(): void; //@endprivate } -} \ No newline at end of file +} diff --git a/ui/text-field/text-field.d.ts b/ui/text-field/text-field.d.ts index f61ff94af..707f12a61 100644 --- a/ui/text-field/text-field.d.ts +++ b/ui/text-field/text-field.d.ts @@ -15,12 +15,12 @@ declare module "ui/text-field" { /** * Gets the native [android widget](http://developer.android.com/reference/android/widget/EditText.html) that represents the user interface for this component. Valid only when running on Android OS. */ - android: android.widget.EditText; + android: any /* android.widget.EditText */; /** * Gets the native iOS [UITextField](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextField_Class/) that represents the user interface for this component. Valid only when running on iOS. */ - ios: UITextField; + ios: any /* UITextField */; /** * Gets or sets if a text field is for password entry. @@ -37,4 +37,4 @@ declare module "ui/text-field" { */ secure?: boolean; } -} \ No newline at end of file +} diff --git a/ui/text-view/text-view.d.ts b/ui/text-view/text-view.d.ts index a63bbc5d7..ab4e7f405 100644 --- a/ui/text-view/text-view.d.ts +++ b/ui/text-view/text-view.d.ts @@ -13,11 +13,11 @@ declare module "ui/text-view" { /** * Gets the native [android widget](http://developer.android.com/reference/android/widget/EditText.html) that represents the user interface for this component. Valid only when running on Android OS. */ - android: android.widget.EditText; + android: any /* android.widget.EditText */; /** * Gets the native iOS [UITextView](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITextView_Class/) that represents the user interface for this component. Valid only when running on iOS. */ - ios: UITextView; + ios: any /* UITextView */; } -} \ No newline at end of file +} diff --git a/ui/time-picker/time-picker.d.ts b/ui/time-picker/time-picker.d.ts index 11f4edeb6..722f2855d 100644 --- a/ui/time-picker/time-picker.d.ts +++ b/ui/time-picker/time-picker.d.ts @@ -17,12 +17,12 @@ declare module "ui/time-picker" { /** * Gets the native [android.widget.TimePicker](http://developer.android.com/reference/android/widget/TimePicker.html) that represents the user interface for this component. Valid only when running on Android OS. */ - android: android.widget.TimePicker; + android: any /* android.widget.TimePicker */; /** * Gets the native iOS [UIDatePicker](http://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIDatePicker_Class/index.html) that represents the user interface for this component. Valid only when running on iOS. */ - ios: UIDatePicker; + ios: any /* UIDatePicker */; /** * Gets or sets the time hour. @@ -34,4 +34,4 @@ declare module "ui/time-picker" { */ minute: number; } -} \ No newline at end of file +} diff --git a/ui/utils.d.ts b/ui/utils.d.ts index e52fdc1ae..65d949689 100644 --- a/ui/utils.d.ts +++ b/ui/utils.d.ts @@ -5,9 +5,9 @@ * Gets actual height of a [UIView](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/) widget. * @param uiView - An instance of UIView. */ - export function getActualHeight(uiView: UIView): number; + export function getActualHeight(uiView: any /* UIView */): number; - export function _layoutRootView(rootView: view.View, parentBounds: CGRect): void; + export function _layoutRootView(rootView: view.View, parentBounds: any /* CGRect */): void; export function getStatusBarHeight(): number; } diff --git a/ui/web-view/web-view.d.ts b/ui/web-view/web-view.d.ts index 038085ae5..9f5ff0689 100644 --- a/ui/web-view/web-view.d.ts +++ b/ui/web-view/web-view.d.ts @@ -28,12 +28,12 @@ declare module "ui/web-view" { /** * Gets the native [android widget](http://developer.android.com/reference/android/webkit/WebView.html) that represents the user interface for this component. Valid only when running on Android OS. */ - android: android.webkit.WebView; + android: any /* android.webkit.WebView */; /** * Gets the native [UIWebView](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIWebView_Class/) that represents the user interface for this component. Valid only when running on iOS. */ - ios: UIWebView; + ios: any /* UIWebView */; /** * [Obsolete. Please use src instead!] Gets or sets the url displayed by this instance. @@ -107,4 +107,4 @@ declare module "ui/web-view" { */ error: string; } -} \ No newline at end of file +} diff --git a/utils/utils.d.ts b/utils/utils.d.ts index 48b4e09d6..a6b93a2bd 100644 --- a/utils/utils.d.ts +++ b/utils/utils.d.ts @@ -59,27 +59,27 @@ /** * Gets the native Android application instance. */ - export function getApplication(): android.app.Application; + export function getApplication(): any /* android.app.Application */; /** * Gets the Android application context. */ - export function getApplicationContext(): android.content.Context; + export function getApplicationContext(): any /* android.content.Context */; /** * Gets the native Android input method manager. */ - export function getInputMethodManager(): android.view.inputmethod.InputMethodManager; + export function getInputMethodManager(): any /* android.view.inputmethod.InputMethodManager */; /** * Hides the soft input method, ususally a soft keyboard. */ - export function dismissSoftInput(nativeView: android.view.View): void; + export function dismissSoftInput(nativeView: any /* android.view.View */): void; /** * Shows the soft input method, ususally a soft keyboard. */ - export function showSoftInput(nativeView: android.view.View): void; + export function showSoftInput(nativeView: any /* android.view.View */): void; /** * Utility module dealing with some android collections. @@ -122,7 +122,7 @@ * Gets a color from the current theme. * @param name - Name of the color resource. */ - export function getPalleteColor(name: string, context: android.content.Context): number; + export function getPalleteColor(name: string, context: any /* android.content.Context */): number; } } /** @@ -149,7 +149,7 @@ * Gets NativeScript color from [UIColor](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIColor_Class/). * @param uiColor - UIColor instance used to create a NativeScript color. */ - export function getColor(uiColor: UIColor): colorModule.Color; + export function getColor(uiColor: any /* UIColor */): colorModule.Color; /** * Gets an information about if current mode is Landscape. */ From 10e802d10784f44d965905d67a27101021f88126 Mon Sep 17 00:00:00 2001 From: Hristo Deshev Date: Fri, 30 Oct 2015 17:02:04 +0200 Subject: [PATCH 2/2] Add a compile-dts step to verify that we don't expose platform types. Alas Grunt or grunt-ts doesn't fail the build if that fails. --- gruntfile.js | 67 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 28 deletions(-) diff --git a/gruntfile.js b/gruntfile.js index 42cd5e013..24e885c37 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -25,7 +25,7 @@ module.exports = function(grunt) { var contentAsObject = JSON.parse(content); update(contentAsObject); return JSON.stringify(contentAsObject, null, "\t"); - } + }; var updateModulesPackageDef = function(content, srcPath) { return updatePackageDef(content, function(contentAsObject) { @@ -42,7 +42,7 @@ module.exports = function(grunt) { contentAsObject.version = localCfg.packageVersion; contentAsObject.author = "Telerik "; var specificKeywords = ["telerik", "mobile", "nativescript", "{N}", "tns", "appbuilder"]; - if (currentAppName.indexOf("template-") == 0) { + if (currentAppName.indexOf("template-") === 0) { var templateName = currentAppName.substring("template-".length); contentAsObject.name = "tns-" + currentAppName; contentAsObject.description = "Nativescript " + templateName + " project template"; @@ -132,7 +132,7 @@ module.exports = function(grunt) { } } return allDirs; - } + }; var localCfg = { srcDir: ".", @@ -150,7 +150,7 @@ module.exports = function(grunt) { }; var nodeTestEnv = JSON.parse(JSON.stringify(process.env)); - nodeTestEnv['NODE_PATH'] = localCfg.outModulesDir; + nodeTestEnv.NODE_PATH = localCfg.outModulesDir; localCfg.nodeTestsDir = pathModule.join(localCfg.outModulesDir, 'node-tests'); @@ -177,6 +177,19 @@ module.exports = function(grunt) { "!./libjs.d.ts" ]); + var tsOptions = { + fast: 'never', + module: "commonjs", + target: "es5", + sourceMap: false, + declaration: false, + removeComments: !grunt.option('leavecomments') || '', + compiler: "node_modules/typescript/bin/tsc", + noEmitOnError: true, + experimentalDecorators: true, + noEmitHelpers: true + }; + grunt.initConfig({ localCfg : localCfg, pkg: grunt.file.readJSON('package.json'), @@ -314,36 +327,31 @@ module.exports = function(grunt) { build: { src: localCfg.typeScriptSrc, outDir: localCfg.outModulesDir, - options: { - fast: 'never', - module: "commonjs", - target: "es5", - sourceMap: false, - declaration: false, - removeComments: "<%= !grunt.option('leavecomments') || '' %>", - compiler: "node_modules/typescript/bin/tsc", - noEmitOnError: true, - experimentalDecorators: true, - noEmitHelpers: true - } + options: tsOptions }, buildNodeTests: { src: [ 'js-libs/easysax/**/*.ts', 'xml/**/*.ts', 'node-tests/**/*.ts', + 'es-collections.d.ts', ], outDir: localCfg.outModulesDir, - options: { - fast: 'never', - module: "commonjs", - target: "es5", - sourceMap: false, - declaration: false, - removeComments: "<%= !grunt.option('leavecomments') || '' %>", - compiler: "node_modules/typescript/bin/tsc", - noEmitOnError: true - } + options: tsOptions + }, + buildDts: { + src: [ + '**/*.d.ts', + '!org.nativescript.widgets.d.ts', + '!**/*.android.d.ts', + '!node_modules/**/*', + '!bin/**/*', + '!apps/**/*', + '!android17.d.ts', + '!ios.d.ts', + ], + outDir: localCfg.outModulesDir, + options: tsOptions } }, tslint: { @@ -431,7 +439,7 @@ module.exports = function(grunt) { clonedTasks.push({name: taskName, cfg: taskCfg}); } return clonedTasks; - } + }; var enqueueTasks = function(tasks) { for (var i=0; i