diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 72845e2f3..000000000 --- a/.eslintrc +++ /dev/null @@ -1,42 +0,0 @@ -{ - "root": true, - "parser": "@typescript-eslint/parser", - "parserOptions": { - "ecmaVersion": 2018, - "sourceType": "module", - "project": "./tsconfig.json" - }, - "ignorePatterns": ["**/*"], - "plugins": ["@typescript-eslint", "@nrwl/nx"], - "extends": [ - "eslint:recommended", - "plugin:@typescript-eslint/eslint-recommended", - "plugin:@typescript-eslint/recommended", - "prettier", - "prettier/@typescript-eslint" - ], - "rules": { - "@typescript-eslint/explicit-member-accessibility": "off", - "@typescript-eslint/explicit-function-return-type": "off", - "@typescript-eslint/no-parameter-properties": "off", - "@nrwl/nx/enforce-module-boundaries": [ - "error", - { - "enforceBuildableLibDependency": true, - "allow": [], - "depConstraints": [ - { "sourceTag": "*", "onlyDependOnLibsWithTags": ["*"] } - ] - } - ] - }, - "overrides": [ - { - "files": ["*.tsx"], - "rules": { - "@typescript-eslint/no-unused-vars": "off", - "@typescript-eslint/no-any": "off" - } - } - ] -} diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 000000000..74d9d35a6 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,40 @@ +{ + "root": true, + "parser": "@typescript-eslint/parser", + "parserOptions": { + "ecmaVersion": 2018, + "sourceType": "module", + "project": "./tsconfig.json" + }, + "ignorePatterns": ["**/*"], + "plugins": ["@typescript-eslint", "@nrwl/nx"], + "extends": ["eslint:recommended", "plugin:@typescript-eslint/eslint-recommended", "plugin:@typescript-eslint/recommended", "prettier", "prettier/@typescript-eslint"], + "rules": { + "@typescript-eslint/explicit-member-accessibility": "off", + "@typescript-eslint/explicit-function-return-type": "off", + "@typescript-eslint/no-parameter-properties": "off", + "@nrwl/nx/enforce-module-boundaries": [ + "error", + { + "enforceBuildableLibDependency": true, + "allow": [], + "depConstraints": [ + { + "sourceTag": "*", + "onlyDependOnLibsWithTags": ["*"] + } + ] + } + ], + "@typescript-eslint/explicit-module-boundary-types": "off" + }, + "overrides": [ + { + "files": ["*.tsx"], + "rules": { + "@typescript-eslint/no-unused-vars": "off", + "@typescript-eslint/no-any": "off" + } + } + ] +} diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 5ef9b1bb0..810b02be0 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -12,6 +12,7 @@ Provide version numbers for the following components (information can be retriev - Cross-platform modules: - Android Runtime: - iOS Runtime: + - XCode Version: - Plugin(s): **Describe the bug** diff --git a/.github/workflows/npm_release.yml b/.github/workflows/npm_release.yml index 76e43ca4d..e21f08f52 100644 --- a/.github/workflows/npm_release.yml +++ b/.github/workflows/npm_release.yml @@ -23,7 +23,7 @@ jobs: run: npm version $NPM_VERSION - name: Build @nativescript/core - run: npx nx run core:build.npm + run: npx nx run core:build - name: Publish @nativescript/core working-directory: dist/packages diff --git a/.travis.yml b/.travis.yml index c0037f3ef..e4e7b12db 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: node_js node_js: - - "node" + - 14 script: - npm run setup - npm start @nativescript.core.test diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 000000000..98c163683 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,8 @@ +{ + "recommendations": [ + "nrwl.angular-console", + "ms-vscode.vscode-typescript-tslint-plugin", + "esbenp.prettier-vscode", + "firsttris.vscode-jest-runner" + ] +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 493fe2aea..ed19603c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,34 @@ +## [7.0.12](https://github.com/NativeScript/NativeScript/compare/7.0.11-core...7.0.12) (2020-10-21) + + +### Bug Fixes + +* **android:** BottomNavigation error on back press (application exit) ([#8970](https://github.com/NativeScript/NativeScript/issues/8970)) ([99bb067](https://github.com/NativeScript/NativeScript/commit/99bb067420871078c40454eec842fad6cbede0f7)) +* **core:** ObservableArray tests and a typo ([#8968](https://github.com/NativeScript/NativeScript/issues/8968)) ([5c1b7f6](https://github.com/NativeScript/NativeScript/commit/5c1b7f6d76c19877da1f47a0696dfbbd89b5fd00)) + + +### Features + +* **core:** TypeScript 4 + cleanup ([#8967](https://github.com/NativeScript/NativeScript/issues/8967)) ([2243660](https://github.com/NativeScript/NativeScript/commit/2243660080ce6877d68a3f32fd64625f86023f77)) +* **webpack:** add svelte support ([#8963](https://github.com/NativeScript/NativeScript/issues/8963)) ([0afea86](https://github.com/NativeScript/NativeScript/commit/0afea8681c62071823804f392ab8d595e61190ff)) + + + +## [7.0.10](https://github.com/NativeScript/NativeScript/compare/7.0.10-core...7.0.10) (2020-10-10) + + +### Bug Fixes + +* **ios:** iOS 10 support with adjustment to UILayoutGuide ([#8954](https://github.com/NativeScript/NativeScript/issues/8954)) ([ad25759](https://github.com/NativeScript/NativeScript/commit/ad2575991aa53c1a1806dfd5dc5e368e1674d73c)) + + +### Features + +* **webpack:** angular configuration schema validation compliance ([ee05b44](https://github.com/NativeScript/NativeScript/commit/ee05b4466336858bd7e2dcb651deb15ba74fc8c2)) +* **webpack:** angular configuration support for environment handling ([#8938](https://github.com/NativeScript/NativeScript/issues/8938)) ([3f7bf67](https://github.com/NativeScript/NativeScript/commit/3f7bf676ff4321d7c490099e3c72687ad68d46a2)) + + + ## [7.0.10](https://github.com/NativeScript/NativeScript/compare/7.0.9-core...7.0.10) (2020-10-03) diff --git a/LICENSE b/LICENSE index 061c44028..451412229 100755 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright (c) 2015-2019 Progress Software Corporation + Copyright (c) 2020, nStudio, LLC Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -198,4 +198,4 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and - limitations under the License. \ No newline at end of file + limitations under the License. diff --git a/apps/automated/package.json b/apps/automated/package.json index dac032e77..4ac3b0d15 100644 --- a/apps/automated/package.json +++ b/apps/automated/package.json @@ -2,10 +2,10 @@ "main": "main.js", "description": "NativeScript Application", "license": "MIT", - "repository": { - "type": "git", - "url": "https://github.com/NativeScript/NativeScript.git" - }, + "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/automated/src/data/observable-array-tests.ts b/apps/automated/src/data/observable-array-tests.ts index 3c4d0e8b9..1d41cb036 100644 --- a/apps/automated/src/data/observable-array-tests.ts +++ b/apps/automated/src/data/observable-array-tests.ts @@ -360,6 +360,85 @@ export const test_ObservableArray_spliceShouldRemoveSpecifiedNumberOfElementsSta export const test_ObservableArray_spliceShouldRemoveSpecifiedNumberOfElementsStartingFromSpecifiedIndexAndRaiseChangeEventWithCorrectArgs = function () { let result: ChangedData; + // >> observable-array-splice-change + const array = new ObservableArray([1, 2, 3, 4]); + + array.on(ObservableArray.changeEvent, (args: ChangedData) => { + // Argument (args) is ChangedData. + // args.eventName is "change". + // args.action is "splice". + // args.index is the start index. + // args.removed.length is equal to the number of deleted items. + // args.addedCount is 0. + + // >> (hide) + result = args; + // << (hide) + }); + + array.splice(1, 2); + // << observable-array-splice-change + + TKUnit.assert(result.eventName === ObservableArray.changeEvent && result.action === ChangeType.Splice && result.removed.length === 2 && result.index === 1 && result.addedCount === 0, "ObservableArray splice() should raise 'change' event with correct args!"); +}; + +export const test_ObservableArray_spliceShouldAddSpecifiedNumberOfElementsStartingFromSpecifiedIndexAndRaiseChangeEventWithCorrectArgs = function () { + let result: ChangedData; + + // >> observable-array-splice-change + const array = new ObservableArray([0]); + + array.on(ObservableArray.changeEvent, (args: ChangedData) => { + // Argument (args) is ChangedData. + // args.eventName is "change". + // args.action is "splice". + // args.index is the start index. + // args.removed.length is equal to the number of deleted items. + // args.addedCount is 0. + + // >> (hide) + result = args; + // << (hide) + }); + + // Because their is only one item in the above array the item index should be + // normalized to Index 1. + array.splice(2, 0, 1); + // << observable-array-splice-change + + TKUnit.assert(result.eventName === ObservableArray.changeEvent && result.action === ChangeType.Splice && result.removed.length === 0 && result.index === 1 && result.addedCount === 1, "ObservableArray splice() should raise 'change' event with correct args!"); +}; + +export const test_ObservableArray_spliceShouldAddDeleteSpecifiedNumberOfElementsStartingFromSpecifiedIndexAndRaiseChangeEventWithCorrectArgs = function () { + let result: ChangedData; + + // >> observable-array-splice-change + const array = new ObservableArray([0]); + + array.on(ObservableArray.changeEvent, (args: ChangedData) => { + // Argument (args) is ChangedData. + // args.eventName is "change". + // args.action is "splice". + // args.index is the start index. + // args.removed.length is equal to the number of deleted items. + // args.addedCount is 1. + + // >> (hide) + result = args; + // << (hide) + }); + + // Because we are starting at index 2, their is NOTHING to delete + // So the Starting index should actually be normalized to Index 1 + array.splice(2, 2, 1); + // << observable-array-splice-change + + TKUnit.assert(result.eventName === ObservableArray.changeEvent && result.action === ChangeType.Splice && result.removed.length === 0 && result.index === 1 && result.addedCount === 1, "ObservableArray splice() should raise 'change' event with correct args!"); +}; + +export const test_ObservableArray_spliceShouldRemoveSpecifiedNumberOfElementsStartingFromSpecifiedIndexAndRaiseChangeEventWithCorrectedArgs = function () { + let result: ChangedData; + // >> observable-array-splice-change const array = new ObservableArray([1, 2, 3]); @@ -526,6 +605,28 @@ export const test_ObservableArray_settingLengthToSomethingPerformsSplice = funct TKUnit.assertTrue(changeRaised); }; +export const test_ObservableArray_settingLengthToSomethingPerformsSpliceAdded = function () { + const array = new ObservableArray([1, 2, 3]); + let changeRaised = false; + + array.on('change', (args: ChangedData) => { + changeRaised = true; + TKUnit.assertEqual(args.object, array); + TKUnit.assertEqual(args.eventName, 'change'); + TKUnit.assertEqual(args.action, ChangeType.Splice); + + // Because the array only has 3 elements, the index it starts the change at is #2 + TKUnit.assertEqual(args.index, 3); + TKUnit.assertEqual(args.addedCount, 2); + TKUnit.arrayAssert(args.removed, []); + }); + + array.length = 5; + + TKUnit.assertEqual(array.length, 5); + TKUnit.assertTrue(changeRaised); +}; + const array = new ObservableArray(); // We do not have indexer! diff --git a/apps/automated/src/ui/repeater/repeater-tests.ts b/apps/automated/src/ui/repeater/repeater-tests.ts index ae6a8a1da..33b47c00e 100644 --- a/apps/automated/src/ui/repeater/repeater-tests.ts +++ b/apps/automated/src/ui/repeater/repeater-tests.ts @@ -1,6 +1,6 @@ import * as TKUnit from '../../tk-unit'; import * as helper from '../../ui-helper'; -import { Application, Label, Page, StackLayout, WrapLayout, LayoutBase, View, GestureTypes, Repeater, ObservableArray } from '@nativescript/core'; +import { Application, Label, Page, StackLayout, WrapLayout, LayoutBase, View, KeyedTemplate, GestureTypes, Repeater, ObservableArray } from '@nativescript/core'; var FEW_ITEMS = [0, 1, 2]; var MANY_ITEMS = []; @@ -8,6 +8,18 @@ for (var i = 0; i < 100; i++) { MANY_ITEMS[i] = i; } +const ITEM_TEMPLATES_STRING = ` + + + + `; + export function test_recycling() { const setters = new Map(); setters.set('itemsLayout', new StackLayout()); @@ -309,6 +321,117 @@ export function test_ItemTemplateFactoryFunction() { helper.buildUIAndRunTest(repeater, testAction); } +// Multiple item templates tests +export function test_ItemTemplateSelector_WhenWrongTemplateKeyIsSpecified_TheDefaultTemplateIsUsed() { + var repeater = new Repeater(); + + function testAction(views: Array) { + repeater.itemTemplate = "