From 08b3cafb543a2eae3bb078b5fc6b077fb9b1561c Mon Sep 17 00:00:00 2001 From: Martin Guillon Date: Wed, 9 Sep 2020 22:47:26 +0200 Subject: [PATCH 01/14] fix(core): autoSystemAppearanceChanged typings in ambient context fix closes https://github.com/NativeScript/NativeScript/issues/8840 --- packages/core/application/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/application/index.d.ts b/packages/core/application/index.d.ts index 9d0106c3a..909627aa3 100644 --- a/packages/core/application/index.d.ts +++ b/packages/core/application/index.d.ts @@ -57,7 +57,7 @@ export const systemAppearanceChangedEvent: string; /** * Boolean to enable/disable systemAppearanceChanged */ -export let autoSystemAppearanceChanged = true; +export let autoSystemAppearanceChanged: boolean; /** * enable/disable systemAppearanceChanged From fda4c48851a4d88062f88abcbd32a22a0d132816 Mon Sep 17 00:00:00 2001 From: tarunama Date: Thu, 10 Sep 2020 10:28:13 +0900 Subject: [PATCH 02/14] chore: add repository --- apps/automated/package.json | 7 +++++-- apps/toolbox/package.json | 7 +++++-- apps/ui/package.json | 7 +++++-- package.json | 6 +++++- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/apps/automated/package.json b/apps/automated/package.json index dd43297b8..dac032e77 100644 --- a/apps/automated/package.json +++ b/apps/automated/package.json @@ -1,8 +1,11 @@ { "main": "main.js", "description": "NativeScript Application", - "license": "SEE LICENSE IN ", - "repository": "", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/NativeScript/NativeScript.git" + }, "scripts": { "clean": "npx rimraf hooks node_modules platforms package-lock.json && npm i" }, diff --git a/apps/toolbox/package.json b/apps/toolbox/package.json index 6e9b5ae7e..16167ec77 100644 --- a/apps/toolbox/package.json +++ b/apps/toolbox/package.json @@ -1,8 +1,11 @@ { "main": "main.js", "description": "NativeScript Application", - "license": "SEE LICENSE IN ", - "repository": "", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/NativeScript/NativeScript.git" + }, "dependencies": { "nativescript-theme-core": "file:../../node_modules/nativescript-theme-core", "@nativescript/core": "file:../../packages/core" diff --git a/apps/ui/package.json b/apps/ui/package.json index a47721bdf..100413761 100644 --- a/apps/ui/package.json +++ b/apps/ui/package.json @@ -1,8 +1,11 @@ { "main": "main.js", "description": "NativeScript Application", - "license": "SEE LICENSE IN ", - "repository": "", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/NativeScript/NativeScript.git" + }, "dependencies": { "nativescript-theme-core": "file:../../node_modules/nativescript-theme-core", "@nativescript/core": "file:../../packages/core" diff --git a/package.json b/package.json index 8758ffa40..201033255 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,11 @@ "start": "nps", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s" }, - "private": true, + "private": true, + "repository": { + "type": "git", + "url": "https://github.com/NativeScript/NativeScript.git" + }, "dependencies": { "nativescript-theme-core": "^1.0.4" }, From 81fd0a177d19de678286b5d26b9aa5310d2716a0 Mon Sep 17 00:00:00 2001 From: Ken Southerland Date: Wed, 9 Sep 2020 15:01:39 -0700 Subject: [PATCH 03/14] fix(webpack): verify now works properly --- packages/webpack/verify/update.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/webpack/verify/update.js b/packages/webpack/verify/update.js index fe0e43c76..cceb756f8 100644 --- a/packages/webpack/verify/update.js +++ b/packages/webpack/verify/update.js @@ -5,7 +5,7 @@ const { getPackageJson, getProjectDir, writePackageJson, -} = require("../projectHelpers"); +} = require("../helpers/projectHelpers"); const { forceUpdateProjectFiles } = require("../helpers/projectFilesManager"); const { forceUpdateProjectDeps } = require("../helpers/dependencyManager"); From 8b4ba737411b221ac7733f29700a88206da84396 Mon Sep 17 00:00:00 2001 From: tarunama Date: Thu, 10 Sep 2020 12:27:07 +0900 Subject: [PATCH 04/14] chore: cleanup navigation-helper.ts (#8834) --- apps/ui/e2e/helpers/navigation-helper.ts | 64 +++++++++++++++--------- 1 file changed, 41 insertions(+), 23 deletions(-) diff --git a/apps/ui/e2e/helpers/navigation-helper.ts b/apps/ui/e2e/helpers/navigation-helper.ts index d93ce7322..a0d1c36b1 100644 --- a/apps/ui/e2e/helpers/navigation-helper.ts +++ b/apps/ui/e2e/helpers/navigation-helper.ts @@ -1,4 +1,10 @@ -import { AppiumDriver, IRectangle, logInfo, logWarn, Point } from "nativescript-dev-appium"; +import { + AppiumDriver, + IRectangle, + logInfo, + logWarn, + Point +} from "nativescript-dev-appium"; export enum ElementCacheStrategy { allAtOnce, @@ -18,12 +24,15 @@ export class NavigationHelper { private _cachedElements: ICachedElement; private _currentSuite: ICachedElement; - constructor(protected _driver: AppiumDriver, protected _suitMainPageNavigationLinks: Array, private _elemtsCacheStrategy: ElementCacheStrategy = ElementCacheStrategy.onload) { - } + constructor( + protected _driver: AppiumDriver, + protected _suitMainPageNavigationLinks: Array, + private _elementsCacheStrategy: ElementCacheStrategy = ElementCacheStrategy.onload + ) {} - async initSuite() { - if (this._elemtsCacheStrategy === ElementCacheStrategy.allAtOnce - || this._elemtsCacheStrategy === ElementCacheStrategy.onload) { + async initSuite(): Promise { + if (this._elementsCacheStrategy === ElementCacheStrategy.allAtOnce + || this._elementsCacheStrategy === ElementCacheStrategy.onload) { if (this._currentSuite) { while (this._currentSuite.parent) { this._currentSuite = this._currentSuite.parent; @@ -31,7 +40,7 @@ export class NavigationHelper { } else { if (!this._cachedElements || this._cachedElements.children.size === 0) { this._cachedElements = { name: "initSuite", children: new Map() }; - if (this._elemtsCacheStrategy === ElementCacheStrategy.allAtOnce) { + if (this._elementsCacheStrategy === ElementCacheStrategy.allAtOnce) { await this.cacheAllElements(this._cachedElements); } } @@ -43,12 +52,12 @@ export class NavigationHelper { await this.navigateToSuitMainPage(); } - async endSuite() { - logInfo("End of suit 'button' tests!"); + async endSuite(): Promise { + logInfo(`End of suit 'button' tests!`); await this._driver.takeScreenshot("end_button_suit"); } - async navigateToSuitMainPage() { + async navigateToSuitMainPage(): Promise { for (let index = 0; index < this._suitMainPageNavigationLinks.length; index++) { const mainPage = this._suitMainPageNavigationLinks[index]; await this.navigateToSample(mainPage); @@ -59,7 +68,7 @@ export class NavigationHelper { logInfo(`Navigate to ${sample}`); const sampleName = sample.toLowerCase(); - if (this._elemtsCacheStrategy === ElementCacheStrategy.allAtOnce) { + if (this._elementsCacheStrategy === ElementCacheStrategy.allAtOnce) { if (!this._currentSuite.children.has(sampleName)) { await this.cacheAllElements(this._currentSuite); } @@ -69,7 +78,7 @@ export class NavigationHelper { const sampleElement = this._currentSuite.children.get(sampleName).rect; await this._driver.clickPoint(sampleElement.x + (sampleElement.width / 2), sampleElement.y + (sampleElement.height / 2)); this._currentSuite = this._currentSuite.children.get(sampleName); - } else if (this._elemtsCacheStrategy === ElementCacheStrategy.onload) { + } else if (this._elementsCacheStrategy === ElementCacheStrategy.onload) { if (this._currentSuite.children.has(sampleName)) { const sampleElement = this._currentSuite.children.get(sampleName).rect; await this._driver.clickPoint(sampleElement.x + (sampleElement.width / 2), sampleElement.y + (sampleElement.height / 2)); @@ -94,14 +103,14 @@ export class NavigationHelper { async navigateBackToSuitMainPage() { logInfo(`Navigate to back`); - if (this._elemtsCacheStrategy === ElementCacheStrategy.allAtOnce - || this._elemtsCacheStrategy === ElementCacheStrategy.onload) { + if (this._elementsCacheStrategy === ElementCacheStrategy.allAtOnce + || this._elementsCacheStrategy === ElementCacheStrategy.onload) { this._currentSuite = this._currentSuite && this._currentSuite.parent; } await this._driver.navBack(); } - async swipeBackToSuitMainPage() { + async swipeBackToSuitMainPage(): Promise { logInfo(`Swipe to back`); const startPoint = {}; const endPoint = {}; @@ -115,20 +124,29 @@ export class NavigationHelper { await this._driver.swipe(startPoint, endPoint); } else { - logWarn("Swipe back is not supported from android!"); + logWarn(`Swipe back is not supported from android!`); } } - private async cacheAllElements(cachedElements: ICachedElement) { - const allSamples = await this._driver.findElementsByClassName(this._driver.locators.button); + private async cacheAllElements(cachedElements: ICachedElement): Promise { + const allSamples = await this._driver.findElementsByClassName(this._driver.locators.button); for (let index = 0; index < allSamples.length; index++) { const element = allSamples[index]; const rect = await element.getRectangle(); - const text = (await element.text()).toLowerCase(); - if (!cachedElements.children.has(text)) { - console.log(text); - cachedElements.children.set(text, { parent: cachedElements, name: text, rect: rect, children: new Map() }); - } + const text = (await element.text()).toLowerCase(); + + if (cachedElements.children.has(text)) continue + + logInfo(text); + cachedElements.children.set( + text, + { + parent: cachedElements, + name: text, + rect: rect, + children: new Map() + } + ); } } } From bd00e1fa87093889b10e63302a40e1ecdbdaaa5c Mon Sep 17 00:00:00 2001 From: Martin Guillon Date: Thu, 10 Sep 2020 05:46:50 +0200 Subject: [PATCH 05/14] fix(core): bundle-config-loader global handling (#8838) --- packages/core/globals/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/core/globals/index.ts b/packages/core/globals/index.ts index 9ccbf5fba..d47733635 100644 --- a/packages/core/globals/index.ts +++ b/packages/core/globals/index.ts @@ -358,3 +358,6 @@ export function initGlobal() { }; } } +if (!global.NativeScriptHasInitGlobal) { + initGlobal(); +} From 86395da5f75bbed0604d27aa9cef833cd8d2c192 Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Wed, 9 Sep 2020 20:57:49 -0700 Subject: [PATCH 06/14] chore(release): @nativescript/core 7.0.2, @nativescript/webpack 3.0.4 (#8842) --- CHANGELOG.md | 11 +++++++++++ package.json | 2 +- packages/core/package.json | 2 +- packages/webpack/package.json | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ee4e97446..7b68251ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +## [7.0.2](https://github.com/NativeScript/NativeScript/compare/7.0.0...7.0.2) (2020-09-10) + + +### Bug Fixes + +* **core:** autoSystemAppearanceChanged typings in ambient context fix ([c30a9c3](https://github.com/NativeScript/NativeScript/commit/c30a9c3e3569e0367056bfd80fa730ae79e29066)) +* **core:** bundle-config-loader global handling ([#8838](https://github.com/NativeScript/NativeScript/issues/8838)) ([1623a56](https://github.com/NativeScript/NativeScript/commit/1623a567b6eaa195d075936103d2f7d829e1fa07)) +* **webpack:** verify now works properly ([f7713c4](https://github.com/NativeScript/NativeScript/commit/f7713c40a63959c2b5934a25bd3577f07d0401c0)) + + + ## [7.0.1](https://github.com/NativeScript/NativeScript/compare/7.0.0...7.0.1) (2020-09-09) diff --git a/package.json b/package.json index 201033255..445162952 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nativescript", - "version": "7.0.1", + "version": "7.0.2", "license": "MIT", "scripts": { "setup": "npx rimraf hooks node_modules package-lock.json && npm i && ts-patch install && nx run core:setup", diff --git a/packages/core/package.json b/packages/core/package.json index b41577142..d2a2b886a 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.1", + "version": "7.0.2", "homepage": "https://nativescript.org", "repository": { "type": "git", diff --git a/packages/webpack/package.json b/packages/webpack/package.json index 4a0e2d8c7..af66a5281 100644 --- a/packages/webpack/package.json +++ b/packages/webpack/package.json @@ -1,6 +1,6 @@ { "name": "@nativescript/webpack", - "version": "3.0.3", + "version": "3.0.4", "main": "index", "description": "Webpack plugin for NativeScript", "homepage": "https://nativescript.org", From f73dfb4e55415a71b39253c3076f45a9888e0ea5 Mon Sep 17 00:00:00 2001 From: Martin Guillon Date: Sat, 12 Sep 2020 18:31:13 +0200 Subject: [PATCH 07/14] types: add setAnimationEnabled to TabViewPager (#8846) --- .../src/lib/android/org.nativescript.widgets.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/types-android/src/lib/android/org.nativescript.widgets.d.ts b/packages/types-android/src/lib/android/org.nativescript.widgets.d.ts index 35da58adb..d2ea0f51b 100644 --- a/packages/types-android/src/lib/android/org.nativescript.widgets.d.ts +++ b/packages/types-android/src/lib/android/org.nativescript.widgets.d.ts @@ -460,6 +460,7 @@ constructor(context: android.content.Context, attrs: android.util.AttributeSet); setSwipePageEnabled(enabled: boolean): void; + setAnimationEnabled(enabled: boolean): void; } export class TabItemSpec { @@ -619,4 +620,4 @@ } } } -} \ No newline at end of file +} From d69e568a4b6505e1ceef33a56100996199bf2d4b Mon Sep 17 00:00:00 2001 From: Igor Randjelovic Date: Sat, 12 Sep 2020 18:33:47 +0200 Subject: [PATCH 08/14] fix: add missing configuration keys and move profiling out of android key (#8847) --- package.json | 10 +++---- packages/core/config/config.interface.ts | 35 ++++++++++++++++-------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 445162952..a83039951 100644 --- a/package.json +++ b/package.json @@ -7,11 +7,11 @@ "start": "nps", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s" }, - "private": true, - "repository": { - "type": "git", - "url": "https://github.com/NativeScript/NativeScript.git" - }, + "private": true, + "repository": { + "type": "git", + "url": "https://github.com/NativeScript/NativeScript.git" + }, "dependencies": { "nativescript-theme-core": "^1.0.4" }, diff --git a/packages/core/config/config.interface.ts b/packages/core/config/config.interface.ts index ff1528f7b..57ccf5cc2 100644 --- a/packages/core/config/config.interface.ts +++ b/packages/core/config/config.interface.ts @@ -1,4 +1,6 @@ -interface IConfigPlaform { +import type {InstrumentationMode} from '../profiling' + +interface IConfigPlatform { /** * App's bundle id */ @@ -10,9 +12,10 @@ interface IConfigPlaform { discardUncaughtJsExceptions?: boolean; } -interface IConfigIOS extends IConfigPlaform {} +// eslint-disable-next-line @typescript-eslint/no-empty-interface +interface IConfigIOS extends IConfigPlatform {} -interface IConfigAndroid extends IConfigPlaform { +interface IConfigAndroid extends IConfigPlatform { /** * These are the v8 runtime flags you can pass in, you must have "--expose_gc" as this is used in the runtime */ @@ -46,11 +49,6 @@ interface IConfigAndroid extends IConfigPlaform { */ gcThrottleTime?: number; - /** - * Enabled "timeline" profiling by setting this key to "timeline", default: "" - */ - profiling?: string; - /** * "none" & "full" is supported, "full" is depreciated * Default: none @@ -91,8 +89,8 @@ interface IConfigAndroid extends IConfigPlaform { enableLineBreakpoints?: boolean; /** - * Enabled the multithreaded JavaScript engine, this will probably break plugins... - * Disabled/Default: false + * Enable the multithreaded JavaScript engine, this will probably break plugins... + * Default: false - disabled. */ enableMultithreadedJavascript?: boolean; } @@ -104,9 +102,13 @@ export interface NativeScriptConfig { */ id?: string; /** - * App's main entry file + * App's main entry file (currently ignored - set it in package.json main field) */ main?: string; + /** + * Path to the app source directory + * This is often the `src` or `app` directory however can be changed. + */ appPath?: string; /** * App_Resources path @@ -131,4 +133,15 @@ export interface NativeScriptConfig { * Various Android specific configurations including Android runtime flags. */ android?: IConfigAndroid; + /** + * Enable profiling for the application. Default: no profiling + * In most cases when profiling, you will want to use "timeline" + */ + profiling?: InstrumentationMode; + /** + * Set the default CSS parser that NativeScript will use. + * Default: css-tree + */ + cssParser?: 'rework' | 'nativescript' | 'css-tree'; } + From b3e9339fc3a83572e5cefb999e327ca98d4c6147 Mon Sep 17 00:00:00 2001 From: Igor Randjelovic Date: Sat, 12 Sep 2020 18:48:45 +0200 Subject: [PATCH 09/14] chore(release): @nativescript/core@7.0.3, @nativescript/types@7.0.3, @nativescript/types-android@7.0.3, @nativescript/types-ios@7.0.3 --- CHANGELOG.md | 9 +++++++++ package.json | 2 +- packages/core/package.json | 2 +- packages/types-android/package.json | 2 +- packages/types-ios/package.json | 2 +- packages/types/package.json | 8 ++++---- 6 files changed, 17 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b68251ee..8d9bc288f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +## [7.0.3](https://github.com/NativeScript/NativeScript/compare/7.0.0...7.0.3) (2020-09-12) + + +### Bug Fixes + +* add missing configuration keys and move profiling out of android key ([#8847](https://github.com/NativeScript/NativeScript/issues/8847)) ([d69e568](https://github.com/NativeScript/NativeScript/commit/d69e568a4b6505e1ceef33a56100996199bf2d4b)) + + + ## [7.0.2](https://github.com/NativeScript/NativeScript/compare/7.0.0...7.0.2) (2020-09-10) diff --git a/package.json b/package.json index a83039951..41c969780 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nativescript", - "version": "7.0.2", + "version": "7.0.3", "license": "MIT", "scripts": { "setup": "npx rimraf hooks node_modules package-lock.json && npm i && ts-patch install && nx run core:setup", diff --git a/packages/core/package.json b/packages/core/package.json index d2a2b886a..d5ba90036 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.2", + "version": "7.0.3", "homepage": "https://nativescript.org", "repository": { "type": "git", diff --git a/packages/types-android/package.json b/packages/types-android/package.json index 15d0cce8c..7be7e7ad1 100644 --- a/packages/types-android/package.json +++ b/packages/types-android/package.json @@ -1,6 +1,6 @@ { "name": "@nativescript/types-android", - "version": "7.0.2", + "version": "7.0.3", "description": "NativeScript Types for Android.", "homepage": "https://nativescript.org", "repository": { diff --git a/packages/types-ios/package.json b/packages/types-ios/package.json index 3499d68bc..cf5455028 100644 --- a/packages/types-ios/package.json +++ b/packages/types-ios/package.json @@ -1,6 +1,6 @@ { "name": "@nativescript/types-ios", - "version": "7.0.1", + "version": "7.0.3", "description": "NativeScript Types for iOS.", "homepage": "https://nativescript.org", "repository": { diff --git a/packages/types/package.json b/packages/types/package.json index ea0430331..d49c9650a 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@nativescript/types", - "version": "7.0.1", + "version": "7.0.3", "description": "NativeScript Types for all supported platforms.", "homepage": "https://nativescript.org", "repository": { @@ -12,7 +12,7 @@ ], "license": "Apache-2.0", "dependencies": { - "@nativescript/types-ios": "~7.0.0", - "@nativescript/types-android": "~7.0.0" + "@nativescript/types-ios": "7.0.3", + "@nativescript/types-android": "7.0.3" } -} \ No newline at end of file +} From eb676fdedf9e3db750bb1c0e7b48194faed2c772 Mon Sep 17 00:00:00 2001 From: Nathanael Anderson Date: Tue, 15 Sep 2020 12:43:40 -0500 Subject: [PATCH 10/14] feat(core): global event handling (#8830) --- packages/core/data/observable/index.ts | 62 +++++++++++++++----------- 1 file changed, 36 insertions(+), 26 deletions(-) diff --git a/packages/core/data/observable/index.ts b/packages/core/data/observable/index.ts index fcd38e9f3..4b198d7df 100644 --- a/packages/core/data/observable/index.ts +++ b/packages/core/data/observable/index.ts @@ -36,10 +36,8 @@ export class WrappedValue implements WrappedValueDefinition { const _wrappedValues = [new WrappedValue(null), new WrappedValue(null), new WrappedValue(null), new WrappedValue(null), new WrappedValue(null)]; - const _globalEventHandlers = {}; - export class Observable implements ObservableDefinition { public static propertyChangeEvent = 'propertyChange'; public _isViewBase: boolean; @@ -163,14 +161,14 @@ export class Observable implements ObservableDefinition { throw new TypeError('callback must be function.'); } - const eventClass = this.name; + const eventClass = this.name === 'Observable' ? '*' : this.name; if (!_globalEventHandlers[eventClass]) { _globalEventHandlers[eventClass] = {}; } if (!Array.isArray(_globalEventHandlers[eventClass][eventName])) { _globalEventHandlers[eventClass][eventName] = []; } - _globalEventHandlers[eventClass][eventName].push({callback, thisArg, once: true}); + _globalEventHandlers[eventClass][eventName].push({ callback, thisArg, once: true }); } public static off(eventName: string, callback?: any, thisArg?: any): void { @@ -186,10 +184,12 @@ export class Observable implements ObservableDefinition { throw new TypeError('callback must be function.'); } - const eventClass = this.name; + const eventClass = this.name === 'Observable' ? '*' : this.name; // Short Circuit if no handlers exist.. - if (!_globalEventHandlers[eventClass] || !Array.isArray(_globalEventHandlers[eventClass][eventName])) { return; } + if (!_globalEventHandlers[eventClass] || !Array.isArray(_globalEventHandlers[eventClass][eventName])) { + return; + } const events = _globalEventHandlers[eventClass][eventName]; if (thisArg) { @@ -221,7 +221,6 @@ export class Observable implements ObservableDefinition { if (keys.length === 0) { delete _globalEventHandlers[eventClass]; } - } public static addEventListener(eventName: string, callback: any, thisArg?: any): void { @@ -233,41 +232,52 @@ export class Observable implements ObservableDefinition { throw new TypeError('callback must be function.'); } - const eventClass = this.name; - if (!_globalEventHandlers[eventClass]) { - _globalEventHandlers[eventClass] = {}; - } - if (!Array.isArray(_globalEventHandlers[eventClass][eventName])) { - _globalEventHandlers[eventClass][eventName] = []; - } - _globalEventHandlers[eventClass][eventName].push({callback, thisArg}); + const eventClass = this.name === 'Observable' ? '*' : this.name; + if (!_globalEventHandlers[eventClass]) { + _globalEventHandlers[eventClass] = {}; + } + if (!Array.isArray(_globalEventHandlers[eventClass][eventName])) { + _globalEventHandlers[eventClass][eventName] = []; + } + _globalEventHandlers[eventClass][eventName].push({ callback, thisArg }); } - public notify(data: T): void { - const eventClass = this.constructor.name; + private _globalNotify(eventClass: string, eventType: string, data: T): void { + // Check for the Global handlers for JUST this class if (_globalEventHandlers[eventClass]) { - const event = data.eventName + "First"; + const event = data.eventName + eventType; const events = _globalEventHandlers[eventClass][event]; if (events) { Observable._handleEvent(events, data); } } - const observers = >this._observers[data.eventName]; - if (observers) { - Observable._handleEvent(observers, data); - } - - if (_globalEventHandlers[eventClass]) { - const events = _globalEventHandlers[eventClass][data.eventName]; + // Check for he Global handlers for ALL classes + if (_globalEventHandlers['*']) { + const event = data.eventName + eventType; + const events = _globalEventHandlers['*'][event]; if (events) { Observable._handleEvent(events, data); } } } + public notify(data: T): void { + const eventClass = this.constructor.name; + this._globalNotify(eventClass, 'First', data); + + const observers = >this._observers[data.eventName]; + if (observers) { + Observable._handleEvent(observers, data); + } + + this._globalNotify(eventClass, '', data); + } + private static _handleEvent(observers: Array, data: T): void { - if (!observers) { return; } + if (!observers) { + return; + } for (let i = observers.length - 1; i >= 0; i--) { const entry = observers[i]; if (entry.once) { From 5f8d3d03f7eac1bdcb1cf4c338734298d2ba86ab Mon Sep 17 00:00:00 2001 From: Lochlan Date: Wed, 16 Sep 2020 16:22:12 +1000 Subject: [PATCH 11/14] fix(android-transitions): remove hard-coded flip transition duration/curve (#8851) --- packages/core/ui/frame/fragment.transitions.android.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/core/ui/frame/fragment.transitions.android.ts b/packages/core/ui/frame/fragment.transitions.android.ts index 83fe2dd1a..c58142993 100644 --- a/packages/core/ui/frame/fragment.transitions.android.ts +++ b/packages/core/ui/frame/fragment.transitions.android.ts @@ -149,7 +149,6 @@ export function _setAndroidFragmentTransitions(animated: boolean, navigationTran setupCurrentFragmentExplodeTransition(navigationTransition, currentEntry); } } else if (name.indexOf('flip') === 0) { - navigationTransition = { duration: 3000, curve: null }; const direction = name.substr('flip'.length) || 'right'; //Extract the direction from the string const flipTransition = new FlipTransition(direction, navigationTransition.duration, navigationTransition.curve); From 313f47637e2fd3d95acb56499cf72e8d6cde7aec Mon Sep 17 00:00:00 2001 From: felixkrautschuk Date: Sun, 20 Sep 2020 18:42:16 +0200 Subject: [PATCH 12/14] fix(ios): text-view color refreshes properly after setting the text to keep the styles (#8863) closes https://github.com/NativeScript/NativeScript/issues/8764 --- packages/core/ui/text-view/index.ios.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/ui/text-view/index.ios.ts b/packages/core/ui/text-view/index.ios.ts index 51db53e30..349770359 100644 --- a/packages/core/ui/text-view/index.ios.ts +++ b/packages/core/ui/text-view/index.ios.ts @@ -234,8 +234,8 @@ export class TextView extends TextViewBaseCommon { public showText() { this._isShowingHint = false; - this._refreshColor(); this._setNativeText(); + this._refreshColor(); this.requestLayout(); } From 45fb6c481b3ae7b3df2cd9f666e1813bdbaff0c7 Mon Sep 17 00:00:00 2001 From: asharghi Date: Wed, 23 Sep 2020 17:00:34 +0200 Subject: [PATCH 13/14] fix(ios): time-picker and date-picker for iOS 14 (#8877) --- packages/core/ui/date-picker/index.ios.ts | 17 +++++++++++++---- packages/core/ui/time-picker/index.ios.ts | 17 +++++++++++++---- .../src/lib/ios/objc-x86_64/objc!UIKit.d.ts | 2 ++ 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/packages/core/ui/date-picker/index.ios.ts b/packages/core/ui/date-picker/index.ios.ts index 5cf0d575e..f7e1618bb 100644 --- a/packages/core/ui/date-picker/index.ios.ts +++ b/packages/core/ui/date-picker/index.ios.ts @@ -1,9 +1,14 @@ import { DatePickerBase, yearProperty, monthProperty, dayProperty, dateProperty, maxDateProperty, minDateProperty } from './date-picker-common'; import { colorProperty } from '../styling/style-properties'; import { Color } from '../../color'; +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; + export class DatePicker extends DatePickerBase { private _changeHandler: NSObject; public nativeViewProtected: UIDatePicker; @@ -11,7 +16,9 @@ export class DatePicker extends DatePickerBase { public createNativeView() { const picker = UIDatePicker.new(); picker.datePickerMode = UIDatePickerMode.Date; - + if (SUPPORT_DATE_PICKER_STYLE) { + picker.preferredDatePickerStyle = DEFAULT_DATE_PICKER_STYLE; + } return picker; } @@ -74,11 +81,13 @@ export class DatePicker extends DatePickerBase { } [colorProperty.getDefault](): UIColor { - return this.nativeViewProtected.valueForKey('textColor'); + return SUPPORT_TEXT_COLOR ? this.nativeViewProtected.valueForKey('textColor') : UIColor.new(); } [colorProperty.setNative](value: Color | UIColor) { - const picker = this.nativeViewProtected; - picker.setValueForKey(value instanceof Color ? value.ios : value, 'textColor'); + if (SUPPORT_TEXT_COLOR) { + const picker = this.nativeViewProtected; + picker.setValueForKey(value instanceof Color ? value.ios : value, 'textColor'); + } } } diff --git a/packages/core/ui/time-picker/index.ios.ts b/packages/core/ui/time-picker/index.ios.ts index 940e5bda5..f0624e512 100644 --- a/packages/core/ui/time-picker/index.ios.ts +++ b/packages/core/ui/time-picker/index.ios.ts @@ -1,9 +1,14 @@ import { TimePickerBase, timeProperty, minuteIntervalProperty, minuteProperty, minMinuteProperty, maxMinuteProperty, hourProperty, minHourProperty, maxHourProperty } from './time-picker-common'; import { Color } from '../../color'; import { colorProperty } from '../styling/style-properties'; +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; + function getDate(hour: number, minute: number): Date { let components = NSDateComponents.alloc().init(); components.hour = hour; @@ -30,7 +35,9 @@ export class TimePicker extends TimePickerBase { createNativeView() { const picker = UIDatePicker.new(); picker.datePickerMode = UIDatePickerMode.Time; - + if (SUPPORT_DATE_PICKER_STYLE) { + picker.preferredDatePickerStyle = DEFAULT_DATE_PICKER_STYLE; + } return picker; } @@ -106,11 +113,13 @@ export class TimePicker extends TimePickerBase { } [colorProperty.getDefault](): UIColor { - return this.nativeViewProtected.valueForKey('textColor'); + return SUPPORT_TEXT_COLOR ? this.nativeViewProtected.valueForKey('textColor') : UIColor.new(); } [colorProperty.setNative](value: Color | UIColor) { - const color = value instanceof Color ? value.ios : value; - this.nativeViewProtected.setValueForKey(color, 'textColor'); + if (SUPPORT_TEXT_COLOR) { + const color = value instanceof Color ? value.ios : value; + this.nativeViewProtected.setValueForKey(color, 'textColor'); + } } } diff --git a/packages/types-ios/src/lib/ios/objc-x86_64/objc!UIKit.d.ts b/packages/types-ios/src/lib/ios/objc-x86_64/objc!UIKit.d.ts index c3c842480..a375a00dd 100644 --- a/packages/types-ios/src/lib/ios/objc-x86_64/objc!UIKit.d.ts +++ b/packages/types-ios/src/lib/ios/objc-x86_64/objc!UIKit.d.ts @@ -6101,6 +6101,8 @@ declare class UIDatePicker extends UIControl implements NSCoding { minuteInterval: number; + preferredDatePickerStyle: number; + timeZone: NSTimeZone; constructor(o: { coder: NSCoder; }); // inherited from NSCoding From 9ec1939233ea486d316a8e4d53b4edf37b18ce9b Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Wed, 23 Sep 2020 11:49:53 -0700 Subject: [PATCH 14/14] chore(release): @nativescript/core@7.0.4, @nativescript/types@7.0.4, @nativescript/types-android@7.0.4, @nativescript/types-ios@7.0.4 --- CHANGELOG.md | 16 ++++++++++++++++ package.json | 2 +- packages/core/package.json | 2 +- packages/types-android/package.json | 2 +- packages/types-ios/package.json | 2 +- packages/types/package.json | 6 +++--- 6 files changed, 23 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d9bc288f..5c722d7c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ +## [7.0.4](https://github.com/NativeScript/NativeScript/compare/7.0.3-types-ios...7.0.4) (2020-09-23) + + +### Bug Fixes + +* **android-transitions:** remove hard-coded flip transition duration/curve ([#8851](https://github.com/NativeScript/NativeScript/issues/8851)) ([5f8d3d0](https://github.com/NativeScript/NativeScript/commit/5f8d3d03f7eac1bdcb1cf4c338734298d2ba86ab)) +* **ios:** text-view color refreshes properly after setting the text to keep the styles ([#8863](https://github.com/NativeScript/NativeScript/issues/8863)) ([313f476](https://github.com/NativeScript/NativeScript/commit/313f47637e2fd3d95acb56499cf72e8d6cde7aec)) +* **ios:** time-picker and date-picker for iOS 14 ([#8877](https://github.com/NativeScript/NativeScript/issues/8877)) ([45fb6c4](https://github.com/NativeScript/NativeScript/commit/45fb6c481b3ae7b3df2cd9f666e1813bdbaff0c7)) + + +### Features + +* **core:** global event handling ([#8830](https://github.com/NativeScript/NativeScript/issues/8830)) ([eb676fd](https://github.com/NativeScript/NativeScript/commit/eb676fdedf9e3db750bb1c0e7b48194faed2c772)) + + + ## [7.0.3](https://github.com/NativeScript/NativeScript/compare/7.0.0...7.0.3) (2020-09-12) diff --git a/package.json b/package.json index 41c969780..e8460e884 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nativescript", - "version": "7.0.3", + "version": "7.0.4", "license": "MIT", "scripts": { "setup": "npx rimraf hooks node_modules package-lock.json && npm i && ts-patch install && nx run core:setup", diff --git a/packages/core/package.json b/packages/core/package.json index d5ba90036..fa4d816f4 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.3", + "version": "7.0.4", "homepage": "https://nativescript.org", "repository": { "type": "git", diff --git a/packages/types-android/package.json b/packages/types-android/package.json index 7be7e7ad1..b8431f405 100644 --- a/packages/types-android/package.json +++ b/packages/types-android/package.json @@ -1,6 +1,6 @@ { "name": "@nativescript/types-android", - "version": "7.0.3", + "version": "7.0.4", "description": "NativeScript Types for Android.", "homepage": "https://nativescript.org", "repository": { diff --git a/packages/types-ios/package.json b/packages/types-ios/package.json index cf5455028..32ba9c4de 100644 --- a/packages/types-ios/package.json +++ b/packages/types-ios/package.json @@ -1,6 +1,6 @@ { "name": "@nativescript/types-ios", - "version": "7.0.3", + "version": "7.0.4", "description": "NativeScript Types for iOS.", "homepage": "https://nativescript.org", "repository": { diff --git a/packages/types/package.json b/packages/types/package.json index d49c9650a..3e110f126 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -1,6 +1,6 @@ { "name": "@nativescript/types", - "version": "7.0.3", + "version": "7.0.4", "description": "NativeScript Types for all supported platforms.", "homepage": "https://nativescript.org", "repository": { @@ -12,7 +12,7 @@ ], "license": "Apache-2.0", "dependencies": { - "@nativescript/types-ios": "7.0.3", - "@nativescript/types-android": "7.0.3" + "@nativescript/types-ios": "7.0.4", + "@nativescript/types-android": "7.0.4" } }