diff --git a/CHANGELOG.md b/CHANGELOG.md index 26375ca6c..02522c16e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,33 @@ +## [7.0.8](https://github.com/NativeScript/NativeScript/compare/7.0.7-core...7.0.8) (2020-09-29) + + +### Bug Fixes + +* **core:** global index typing fix for unit testing framework ([#8915](https://github.com/NativeScript/NativeScript/issues/8915)) ([806fc88](https://github.com/NativeScript/NativeScript/commit/806fc880dd944a8808a0f407ae5d0c0d4be55d5d)) +* **core:** Observable splice index > length ([#8900](https://github.com/NativeScript/NativeScript/issues/8900)) ([65b1cdb](https://github.com/NativeScript/NativeScript/commit/65b1cdbae0a9e873a3d2bc4636038423351b794e)) +* **ios:** Utils.openFile ([#8914](https://github.com/NativeScript/NativeScript/issues/8914)) ([647926e](https://github.com/NativeScript/NativeScript/commit/647926ee281712a82238d5153522d9a07be5870c)) + + + +## [7.0.7](https://github.com/NativeScript/NativeScript/compare/7.0.6-core...7.0.7) (2020-09-26) + + +### Bug Fixes + +* **ios:** preferredDatePickerStyle property ([#8899](https://github.com/NativeScript/NativeScript/issues/8899)) ([dbefc43](https://github.com/NativeScript/NativeScript/commit/dbefc43b9bb9b907883990f8d40c178fc7ecea9c)) + + + +## [7.0.6](https://github.com/NativeScript/NativeScript/compare/7.0.5-core...7.0.6) (2020-09-25) + + +### Bug Fixes + +* **core:** delegate should be set on nativeTextViewProtected ([#8881](https://github.com/NativeScript/NativeScript/issues/8881)) ([021c0bb](https://github.com/NativeScript/NativeScript/commit/021c0bb9a24f15a9adf9d5e25a981ea53901e600)) +* **core:** global handling with env.production flag ([#8903](https://github.com/NativeScript/NativeScript/issues/8903)) ([3437ed7](https://github.com/NativeScript/NativeScript/commit/3437ed7e1483cddf75aeca9bd8ff475e449f110f)) + + + ## [7.0.5](https://github.com/NativeScript/NativeScript/compare/7.0.4-core...7.0.5) (2020-09-23) diff --git a/README.md b/README.md index 2a42cd95e..c210ec5ce 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@

- NativeScript + NativeScript

@@ -11,7 +11,7 @@ NativeScript [![Build Status](https://travis-ci.org/NativeScript/NativeScript.svg?branch=master)](https://travis-ci.org/NativeScript/NativeScript) -[NativeScript](http://www.nativescript.org) empowers you to access native api's from JavaScript directly. The framework currently provides iOS and Android runtimes for rich mobile development and can be utilized in a number of diverse use cases. +[NativeScript](http://www.nativescript.org) empowers you to access native APIs from JavaScript directly. The framework currently provides iOS and Android runtimes for rich mobile development and can be utilized in a number of diverse use cases. ## Getting Started and Installation diff --git a/package.json b/package.json index 248a1b951..60eafd3ab 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nativescript", - "version": "7.0.5", + "version": "7.0.8", "license": "MIT", "config": { "npm_alias": "npm" diff --git a/packages/core/__tests__/tsconfig.json b/packages/core/__tests__/tsconfig.json index 97e52b876..48350c360 100644 --- a/packages/core/__tests__/tsconfig.json +++ b/packages/core/__tests__/tsconfig.json @@ -30,6 +30,7 @@ } }, "include": [ + "../global-types.d.ts", "./**/*.ts" ], "exclude": [ diff --git a/packages/core/application/index.android.ts b/packages/core/application/index.android.ts index 773108d6d..7587f17af 100644 --- a/packages/core/application/index.android.ts +++ b/packages/core/application/index.android.ts @@ -476,24 +476,23 @@ function ensureBroadCastReceiverClass() { return; } - @NativeClass - class BroadcastReceiver extends android.content.BroadcastReceiver { - private _onReceiveCallback: (context: android.content.Context, intent: android.content.Intent) => void; + @NativeClass + class BroadcastReceiver extends android.content.BroadcastReceiver { + private _onReceiveCallback: (context: android.content.Context, intent: android.content.Intent) => void; - constructor(onReceiveCallback: (context: android.content.Context, intent: android.content.Intent) => void) { - super(); - this._onReceiveCallback = onReceiveCallback; + constructor(onReceiveCallback: (context: android.content.Context, intent: android.content.Intent) => void) { + super(); + this._onReceiveCallback = onReceiveCallback; - return global.__native(this); - } - - public onReceive(context: android.content.Context, intent: android.content.Intent) { - if (this._onReceiveCallback) { - this._onReceiveCallback(context, intent); - } - } - } + return global.__native(this); + } + public onReceive(context: android.content.Context, intent: android.content.Intent) { + if (this._onReceiveCallback) { + this._onReceiveCallback(context, intent); + } + } + } BroadcastReceiverClass = BroadcastReceiver; } diff --git a/packages/core/application/index.d.ts b/packages/core/application/index.d.ts index ff7b1f7a5..a3e0910d8 100644 --- a/packages/core/application/index.d.ts +++ b/packages/core/application/index.d.ts @@ -62,7 +62,7 @@ export let autoSystemAppearanceChanged: boolean; /** * enable/disable systemAppearanceChanged */ -export function setAutoSystemAppearanceChanged (value: boolean); +export function setAutoSystemAppearanceChanged(value: boolean); /** * Updates root view classes including those of modals diff --git a/packages/core/config/config.interface.ts b/packages/core/config/config.interface.ts index 57ccf5cc2..e63c30b9a 100644 --- a/packages/core/config/config.interface.ts +++ b/packages/core/config/config.interface.ts @@ -1,4 +1,4 @@ -import type {InstrumentationMode} from '../profiling' +import type { InstrumentationMode } from '../profiling'; interface IConfigPlatform { /** @@ -144,4 +144,3 @@ export interface NativeScriptConfig { */ cssParser?: 'rework' | 'nativescript' | 'css-tree'; } - diff --git a/packages/core/config/index.ts b/packages/core/config/index.ts index 19955812e..e8c38695e 100644 --- a/packages/core/config/index.ts +++ b/packages/core/config/index.ts @@ -1 +1 @@ -export * from './config.interface'; \ No newline at end of file +export * from './config.interface'; diff --git a/packages/core/connectivity/index.android.ts b/packages/core/connectivity/index.android.ts index 13ffbcc9e..0c9b29c56 100644 --- a/packages/core/connectivity/index.android.ts +++ b/packages/core/connectivity/index.android.ts @@ -1,4 +1,4 @@ -import {android as androidApp, getNativeApplication} from '../application'; +import { android as androidApp, getNativeApplication } from '../application'; export enum connectionType { none = 0, diff --git a/packages/core/data/observable-array/index.ts b/packages/core/data/observable-array/index.ts index b7f390cc1..cc026e91e 100644 --- a/packages/core/data/observable-array/index.ts +++ b/packages/core/data/observable-array/index.ts @@ -246,7 +246,7 @@ export class ObservableArray extends Observable { eventName: CHANGE, object: this, action: ChangeType.Splice, - index: start, + index: Math.min(start, this._array.length-1), removed: result, addedCount: this._array.length + result.length - length, }); diff --git a/packages/core/globals/index.d.ts b/packages/core/globals/index.d.ts index 34b248a72..c934047b4 100644 --- a/packages/core/globals/index.d.ts +++ b/packages/core/globals/index.d.ts @@ -1,6 +1,6 @@ import { Observable } from '../data/observable'; export declare class NativeScriptGlobalState { - events: Observable; + events: Observable; launched: boolean; } export function installPolyfills(moduleName: string, exportNames: string[]): void; diff --git a/packages/core/globals/index.ts b/packages/core/globals/index.ts index a5771d05f..8e419af92 100644 --- a/packages/core/globals/index.ts +++ b/packages/core/globals/index.ts @@ -359,5 +359,5 @@ export function initGlobal() { } } if (!global.NativeScriptHasInitGlobal) { - initGlobal(); -} \ No newline at end of file + initGlobal(); +} diff --git a/packages/core/index.ts b/packages/core/index.ts index 6291561c7..77be3d80a 100644 --- a/packages/core/index.ts +++ b/packages/core/index.ts @@ -29,9 +29,9 @@ export const Application = { loadAppCss, addCss, on, - off, - notify, - hasListeners, + off, + notify, + hasListeners, run, orientation, getNativeApplication, @@ -135,11 +135,11 @@ export const Utils = { android: androidUtils, // legacy (a lot of plugins use the shorthand "ad" Utils.ad instead of Utils.android) ad: androidUtils, - ios: iosUtils, - setTimeout, - setInterval, - clearInterval, - clearTimeout, + ios: iosUtils, + setTimeout, + setInterval, + clearInterval, + clearTimeout, Source, ClassInfo, getClass, diff --git a/packages/core/inspector_modules.ios.ts b/packages/core/inspector_modules.ios.ts index 18deeeebf..b228c93d4 100644 --- a/packages/core/inspector_modules.ios.ts +++ b/packages/core/inspector_modules.ios.ts @@ -1,5 +1,5 @@ console.log('Loading inspector modules...'); -import './globals'; +import './globals'; require('./debugger/webinspector-network'); require('./debugger/webinspector-dom'); require('./debugger/webinspector-css'); diff --git a/packages/core/package.json b/packages/core/package.json index 88b99f049..f8fd29104 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -3,7 +3,7 @@ "main": "index", "types": "index.d.ts", "description": "NativeScript Core Modules", - "version": "7.0.6-alpha.2", + "version": "7.0.8", "homepage": "https://nativescript.org", "repository": { "type": "git", diff --git a/packages/core/ui/bottom-navigation/index.android.ts b/packages/core/ui/bottom-navigation/index.android.ts index 5a2fefd91..3334d36a2 100644 --- a/packages/core/ui/bottom-navigation/index.android.ts +++ b/packages/core/ui/bottom-navigation/index.android.ts @@ -456,7 +456,7 @@ export class BottomNavigation extends TabNavigationBase { const fragmentManager = this._getFragmentManager(); const transaction = fragmentManager.beginTransaction(); const fragments = fragmentManager.getFragments().toArray(); - for (let i=0;i({ valueConverter: (v) => new Date(v), }); dateProperty.register(DatePickerBase); + +export const iosPreferredDatePickerStyleProperty = new Property({ + name: 'iosPreferredDatePickerStyle', + defaultValue: 0, + valueConverter: (v) => parseInt(v), +}); +iosPreferredDatePickerStyleProperty.register(DatePickerBase); \ No newline at end of file diff --git a/packages/core/ui/date-picker/index.d.ts b/packages/core/ui/date-picker/index.d.ts index b735de5d8..e255230e4 100644 --- a/packages/core/ui/date-picker/index.d.ts +++ b/packages/core/ui/date-picker/index.d.ts @@ -7,6 +7,7 @@ export const dayProperty: Property; export const dateProperty: Property; export const maxDate: Property; export const minDate: Property; +export const iosPreferredDatePickerStyleProperty: Property; /** * Represents an date picker. @@ -51,4 +52,14 @@ export class DatePicker extends View { * Gets or sets the min date. */ minDate: Date; + + /** + * Gets or set the UIDatePickerStyle of the date picker in iOS 13.4+. Defaults to 0. + * Valid values are numbers: + * - 0: automatic (system picks the concrete style based on the current platform and date picker mode) + * - 1: wheels (the date picker displays as a wheel picker) + * - 2: compact (the date picker displays as a label that when tapped displays a calendar-style editor) + * - 3: inline (the date pickers displays as an inline, editable field) + */ + iosPreferredDatePickerStyle: number; } diff --git a/packages/core/ui/date-picker/index.ios.ts b/packages/core/ui/date-picker/index.ios.ts index f7e1618bb..118124bd0 100644 --- a/packages/core/ui/date-picker/index.ios.ts +++ b/packages/core/ui/date-picker/index.ios.ts @@ -5,9 +5,8 @@ import { Device } from '../../platform'; export * from './date-picker-common'; -const SUPPORT_DATE_PICKER_STYLE = parseFloat(Device.os) >= 14.0; -const SUPPORT_TEXT_COLOR = parseFloat(Device.os) < 14.0; -const DEFAULT_DATE_PICKER_STYLE = 1; +const SUPPORT_DATE_PICKER_STYLE = parseFloat(Device.osVersion) >= 13.4; +const SUPPORT_TEXT_COLOR = parseFloat(Device.osVersion) < 14.0; export class DatePicker extends DatePickerBase { private _changeHandler: NSObject; @@ -17,7 +16,7 @@ export class DatePicker extends DatePickerBase { const picker = UIDatePicker.new(); picker.datePickerMode = UIDatePickerMode.Date; if (SUPPORT_DATE_PICKER_STYLE) { - picker.preferredDatePickerStyle = DEFAULT_DATE_PICKER_STYLE; + picker.preferredDatePickerStyle = this.iosPreferredDatePickerStyle; } return picker; } diff --git a/packages/core/ui/frame/fragment.android.ts b/packages/core/ui/frame/fragment.android.ts index a1bea72e9..46477fc61 100644 --- a/packages/core/ui/frame/fragment.android.ts +++ b/packages/core/ui/frame/fragment.android.ts @@ -16,7 +16,7 @@ const FragmentClass = (org.nativescript.widgets.FragmentBase).extend('com.t }, onPause(): void { - this._callbacks.onPause(this, superProto.onStop); + this._callbacks.onPause(this, superProto.onPause); }, onCreate(savedInstanceState: android.os.Bundle) { diff --git a/packages/core/ui/styling/css-selector/index.ts b/packages/core/ui/styling/css-selector/index.ts index 1ac6846b3..168a1cac7 100644 --- a/packages/core/ui/styling/css-selector/index.ts +++ b/packages/core/ui/styling/css-selector/index.ts @@ -1,3 +1,4 @@ +import '../../../globals'; import { isNullOrUndefined } from '../../../utils/types'; import * as cssParser from '../../../css'; diff --git a/packages/core/ui/tab-navigation-base/tab-content-item/index.android.ts b/packages/core/ui/tab-navigation-base/tab-content-item/index.android.ts index 3889a182a..eadf6a585 100644 --- a/packages/core/ui/tab-navigation-base/tab-content-item/index.android.ts +++ b/packages/core/ui/tab-navigation-base/tab-content-item/index.android.ts @@ -54,7 +54,7 @@ export class TabContentItem extends TabContentItemBase { } const fragments = fragmentManager.getFragments().toArray(); - for (let i=0;i>fragmentManager.getFragments().toArray(); - for (let i=0;i; @@ -66,3 +76,5 @@ export const minMinuteProperty: Property; export const timeProperty: Property; export const minuteIntervalProperty: Property; + +export const iosPreferredDatePickerStyleProperty: Property; \ No newline at end of file diff --git a/packages/core/ui/time-picker/index.ios.ts b/packages/core/ui/time-picker/index.ios.ts index f0624e512..12c7ddd7f 100644 --- a/packages/core/ui/time-picker/index.ios.ts +++ b/packages/core/ui/time-picker/index.ios.ts @@ -5,9 +5,8 @@ import { Device } from '../../platform'; export * from './time-picker-common'; -const SUPPORT_DATE_PICKER_STYLE = parseFloat(Device.os) >= 14.0; -const SUPPORT_TEXT_COLOR = parseFloat(Device.os) < 14.0; -const DEFAULT_DATE_PICKER_STYLE = 1; +const SUPPORT_DATE_PICKER_STYLE = parseFloat(Device.osVersion) >= 13.4; +const SUPPORT_TEXT_COLOR = parseFloat(Device.osVersion) < 14.0; function getDate(hour: number, minute: number): Date { let components = NSDateComponents.alloc().init(); @@ -36,7 +35,7 @@ export class TimePicker extends TimePickerBase { const picker = UIDatePicker.new(); picker.datePickerMode = UIDatePickerMode.Time; if (SUPPORT_DATE_PICKER_STYLE) { - picker.preferredDatePickerStyle = DEFAULT_DATE_PICKER_STYLE; + picker.preferredDatePickerStyle = this.iosPreferredDatePickerStyle; } return picker; } diff --git a/packages/core/ui/time-picker/time-picker-common.ts b/packages/core/ui/time-picker/time-picker-common.ts index 077973ab3..39c02cbae 100644 --- a/packages/core/ui/time-picker/time-picker-common.ts +++ b/packages/core/ui/time-picker/time-picker-common.ts @@ -98,6 +98,7 @@ export abstract class TimePickerBase extends View implements TimePickerDefinitio public maxHour: number; public minMinute: number; public maxMinute: number; + public iosPreferredDatePickerStyle: number; } TimePickerBase.prototype.recycleNativeView = 'auto'; @@ -204,3 +205,10 @@ export const timeProperty = new Property({ }, }); timeProperty.register(TimePickerBase); + +export const iosPreferredDatePickerStyleProperty = new Property({ + name: 'iosPreferredDatePickerStyle', + defaultValue: 0, + valueConverter: (v) => parseInt(v), +}); +iosPreferredDatePickerStyleProperty.register(TimePickerBase); diff --git a/packages/core/utils/index.ios.ts b/packages/core/utils/index.ios.ts index 90bc24dc2..1cce1b2a6 100644 --- a/packages/core/utils/index.ios.ts +++ b/packages/core/utils/index.ios.ts @@ -11,7 +11,7 @@ export function openFile(filePath: string): boolean { let path = iOSNativeHelper.isRealDevice() ? filePath.replace('~', appPath) : filePath; const controller = UIDocumentInteractionController.interactionControllerWithURL(NSURL.fileURLWithPath(path)); - controller.delegate = new iOSNativeHelper.UIDocumentInteractionControllerDelegateImpl(); + controller.delegate = iOSNativeHelper.createUIDocumentInteractionControllerDelegate(); return controller.presentPreviewAnimated(true); } catch (e) { diff --git a/packages/core/utils/native-helper.d.ts b/packages/core/utils/native-helper.d.ts index 19986a7cf..d402c33a2 100644 --- a/packages/core/utils/native-helper.d.ts +++ b/packages/core/utils/native-helper.d.ts @@ -168,7 +168,10 @@ export namespace iOSNativeHelper { */ export function applyRotateTransform(transform: any /* CATransform3D*/, x: number, y: number, z: number): any; /* CATransform3D*/ - export class UIDocumentInteractionControllerDelegateImpl {} + /** + * Create a UIDocumentInteractionControllerDelegate implementation for use with UIDocumentInteractionController + */ + export function createUIDocumentInteractionControllerDelegate(): any; /** * Checks whether the application is running on real device and not on simulator. diff --git a/packages/core/utils/native-helper.ios.ts b/packages/core/utils/native-helper.ios.ts index 89d24b29b..b757a33b1 100644 --- a/packages/core/utils/native-helper.ios.ts +++ b/packages/core/utils/native-helper.ios.ts @@ -14,7 +14,7 @@ function openFileAtRootModule(filePath: string): boolean { let path = iOSNativeHelper.isRealDevice() ? filePath.replace('~', appPath) : filePath; const controller = UIDocumentInteractionController.interactionControllerWithURL(NSURL.fileURLWithPath(path)); - controller.delegate = new iOSNativeHelper.UIDocumentInteractionControllerDelegateImpl(); + controller.delegate = iOSNativeHelper.createUIDocumentInteractionControllerDelegate(); return controller.presentPreviewAnimated(true); } catch (e) { @@ -125,30 +125,33 @@ export namespace iOSNativeHelper { } return transform; - } - - @NativeClass - export class UIDocumentInteractionControllerDelegateImpl extends NSObject implements UIDocumentInteractionControllerDelegate { - public static ObjCProtocols = [UIDocumentInteractionControllerDelegate]; - - public getViewController(): UIViewController { - const app = UIApplication.sharedApplication; - - return app.keyWindow.rootViewController; - } - - public documentInteractionControllerViewControllerForPreview(controller: UIDocumentInteractionController) { - return this.getViewController(); - } - - public documentInteractionControllerViewForPreview(controller: UIDocumentInteractionController) { - return this.getViewController().view; - } - - public documentInteractionControllerRectForPreview(controller: UIDocumentInteractionController): CGRect { - return this.getViewController().view.frame; - } - } + } + + export function createUIDocumentInteractionControllerDelegate(): NSObject { + @NativeClass + class UIDocumentInteractionControllerDelegateImpl extends NSObject implements UIDocumentInteractionControllerDelegate { + public static ObjCProtocols = [UIDocumentInteractionControllerDelegate]; + + public getViewController(): UIViewController { + const app = UIApplication.sharedApplication; + + return app.keyWindow.rootViewController; + } + + public documentInteractionControllerViewControllerForPreview(controller: UIDocumentInteractionController) { + return this.getViewController(); + } + + public documentInteractionControllerViewForPreview(controller: UIDocumentInteractionController) { + return this.getViewController().view; + } + + public documentInteractionControllerRectForPreview(controller: UIDocumentInteractionController): CGRect { + return this.getViewController().view.frame; + } + } + return new UIDocumentInteractionControllerDelegateImpl(); + } export function isRealDevice() { try { diff --git a/packages/webpack/package.json b/packages/webpack/package.json index c776ce387..8b7784600 100644 --- a/packages/webpack/package.json +++ b/packages/webpack/package.json @@ -1,6 +1,6 @@ { "name": "@nativescript/webpack", - "version": "3.0.4", + "version": "3.0.5", "main": "index", "description": "Webpack plugin for NativeScript", "homepage": "https://nativescript.org",