From 25046c7f94ec76bac8f34b040547782e6150ab8f Mon Sep 17 00:00:00 2001 From: Svetoslav Date: Wed, 18 Sep 2019 01:05:39 +0300 Subject: [PATCH 01/10] chore: remove grunt and update build scripts (#7838) * chore: prepare and pack scripts * chore: update @types/node dep * chore: remove prepare-dist command from pack-dist --- build/clear-private-definitions.js | 51 +++ build/create-release-changelog-pr.js | 18 - build/pack-dist.sh | 19 + build/prepare-dist.sh | 69 ++++ build/run-testsapp.grunt.js | 354 ------------------ package.json | 20 +- tns-core-modules-widgets/LICENSE | 201 ---------- tns-core-modules-widgets/build.sh | 4 +- tns-core-modules/LICENSE | 201 ---------- tns-core-modules/package.json | 2 +- tns-core-modules/tsconfig.json | 33 ++ .../frame/transition-definitions.android.d.ts | 1 + tns-platform-declarations/tsconfig.json | 21 +- 13 files changed, 206 insertions(+), 788 deletions(-) create mode 100644 build/clear-private-definitions.js delete mode 100644 build/create-release-changelog-pr.js create mode 100755 build/pack-dist.sh create mode 100755 build/prepare-dist.sh delete mode 100644 build/run-testsapp.grunt.js delete mode 100755 tns-core-modules-widgets/LICENSE delete mode 100755 tns-core-modules/LICENSE create mode 100644 tns-core-modules/tsconfig.json diff --git a/build/clear-private-definitions.js b/build/clear-private-definitions.js new file mode 100644 index 0000000000..a8a5cabbd6 --- /dev/null +++ b/build/clear-private-definitions.js @@ -0,0 +1,51 @@ +const path = require("path"); +const fs = require("fs"); +const readdirp = require("readdirp"); + +const inputFolder = path.resolve(process.argv[2]); + +console.log(`Clearing private definitions in ${inputFolder}`); + +function filterTypeScriptFiles(content) { + var leadingPrivate = /^.*@private/ig; + if (leadingPrivate.test(content)) { + return { shouldDelete: true }; + } + + let blockCommentPrivate = /\/\*\*([^](?!\*\/))*@module([^](?!\*\/))*@private[^]*?\*\//g; + if (blockCommentPrivate.test(content)) { + return { shouldDelete: true }; + } + + let newContent = content; + newContent = newContent.replace(/\/\/[\/\s]*@private[^]*?\/\/[\/\s]*?@endprivate/gm, ""); + + if (newContent !== content) { + return { shouldReplace: true, newContent: newContent }; + } + + return { shouldReplace: false, shouldDelete: false }; +}; + +readdirp(inputFolder, { + fileFilter: ["*.d.ts"], + directoryFilter: function (di) { return !di.path.includes("node_modules"); } +}).on("data", (entry) => { + const { fullPath } = entry; + const content = fs.readFileSync(fullPath, "utf8"); + const { shouldDelete, shouldReplace, newContent } = filterTypeScriptFiles(content); + + if (shouldDelete) { + console.log("[Delete]", fullPath) + fs.unlinkSync(fullPath); + } else if (shouldReplace) { + console.log("[Cleared]", fullPath) + fs.writeFileSync(fullPath, newContent, "utf8", (err) => { + console.log("ERROR writing file: " + fullPath, error); + }) + } +}) + .on("warn", error => console.error("non-fatal error", error)) + .on("error", error => console.error("fatal error", error)) + .on("end", () => console.log("done")); + diff --git a/build/create-release-changelog-pr.js b/build/create-release-changelog-pr.js deleted file mode 100644 index 409f46ddaf..0000000000 --- a/build/create-release-changelog-pr.js +++ /dev/null @@ -1,18 +0,0 @@ -const { readFileSync } = require("fs"); -const { resolve } = require("path"); -const { createPR, argsParser, gitBranch } = require("./pr-helper"); - -const currentBranch = argsParser().currentBranch || gitBranch; -const modulesPackageVersion = argsParser().packageVersion || JSON.parse(readFileSync(resolve(process.cwd(), "tns-core-modules/package.json")).toString()).version; -const title = argsParser().title || `release: cut the ${modulesPackageVersion} release`; -const baseBranch = argsParser().base || "release"; -const body = argsParser().body || "docs: update changelog"; - -const postQuery = { - "body": body, - "head": currentBranch, - "base": baseBranch, - "title": title -} - -createPR(postQuery); \ No newline at end of file diff --git a/build/pack-dist.sh b/build/pack-dist.sh new file mode 100755 index 0000000000..cc6685a86e --- /dev/null +++ b/build/pack-dist.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -x +set -e + +DIST=dist; +ROOT_DIR=$(cd `dirname $0` && pwd)/..; +cd "$ROOT_DIR" + +( + cd "$DIST/tns-platform-declarations" + TGZ="$(npm pack)" + mv "$TGZ" "../$TGZ" +) + +( + cd "$DIST/tns-core-modules" + TGZ="$(npm pack)" + mv "$TGZ" "../$TGZ" +) \ No newline at end of file diff --git a/build/prepare-dist.sh b/build/prepare-dist.sh new file mode 100755 index 0000000000..7f7c08fcc2 --- /dev/null +++ b/build/prepare-dist.sh @@ -0,0 +1,69 @@ +#!/bin/bash +set -x +set -e + +DIST=dist; +ROOT_DIR=$(cd `dirname $0` && pwd)/..; +cd "$ROOT_DIR" + +mkdir -p "$DIST" + +## NPM INSTALL +( + echo "NPM install in root of the repo" + cd "$ROOT_DIR" + npm install +) + +## Prepare Platfrom Declarations +( + PACKAGE=tns-platform-declarations; + + echo "Clearing $DIST/$PACKAGE" + npx rimraf "$DIST/$PACKAGE" + npx rimraf "$DIST/$PACKAGE*.tgz" + + echo "Copying $PACKAGE $DIST/$PACKAGE..." + npx ncp "$PACKAGE" "$DIST/$PACKAGE" + + echo "Copying README and LICENSE to $DIST/$PACKAGE" + npx ncp LICENSE "$DIST/$PACKAGE"/LICENSE + + cd "$DIST/$PACKAGE" + + echo 'Running npm install...' + npm install + + echo 'Running npm test...' + npm test +) + +## Prepare Core Modules +( + PACKAGE=tns-core-modules; + + echo "Clearing $DIST/$PACKAGE" + npx rimraf "$DIST/$PACKAGE" + npx rimraf "$DIST/$PACKAGE*.tgz" + + echo "Copying $PACKAGE $DIST/$PACKAGE..." + npx ncp "$PACKAGE" "$DIST/$PACKAGE" + + echo "Cleaning inner readme.md-s ..." + npx rimraf "$DIST/$PACKAGE/**/README.md" + npx rimraf "$DIST/$PACKAGE/**/Readme.md" + + echo "Copying README and LICENSE to $DIST/$PACKAGE" + npx ncp LICENSE "$DIST"/"$PACKAGE"/LICENSE + npx ncp README.md "$DIST"/"$PACKAGE"/README.md + + ( + echo 'TypeScript transpile...' + cd "$DIST/$PACKAGE" + npm install + npx tsc + ) + + echo "Clearing typescript definitions from private APIs..." + node build/clear-private-definitions "$DIST/$PACKAGE" +) diff --git a/build/run-testsapp.grunt.js b/build/run-testsapp.grunt.js deleted file mode 100644 index 533a58462c..0000000000 --- a/build/run-testsapp.grunt.js +++ /dev/null @@ -1,354 +0,0 @@ -module.exports = { - - run: function(grunt) { - var pathModule = require("path"); - - var modulesPackageConfig = grunt.file.readJSON('package.json'); - - //Construct and validate the arguments - var args = { - platform: grunt.option("platform"), - modulesPath: grunt.option("modulesPath"), - tnsPath: grunt.option("tnsPath"), - emulatorProcessIdentifier: grunt.option("emuPId"), - emuAvdName: grunt.option("avd"), - outFile: grunt.option("logFilePath"), - runtimePath: grunt.option("runtimePath"), - runtimeVersion: grunt.option("runtimeVersion"), - showEmu: grunt.option("showEmu"), - runAppOnly: grunt.option("runAppOnly"), - pathToApp: grunt.option("pathToApp") - }; - - (function validateInput(){ - if (!(/^(Android|iOS)$/).test(args.platform)) { - throw new Error("Invalid target platform specified! Use --platform=Android|iOS"); - } - - if (args.platform === "Android") { - if (!args.emulatorProcessIdentifier) { - throw new Error("Please, specify an identifier of the emulator process so that it can be stopped (--emuPId=...). Too many emulators started might cause machine overload"); - } - if (!args.emuAvdName) { - throw new Error("Please, specify the name of the AVD to start (--avd=...)."); - } - } - - if (args.runAppOnly && !args.pathToApp) { - throw new Error("runAppOnly called, but no path to application specified. Please, add the path via the (--pathToApp=...) parameter."); - } - }()); - - var localCfg = { - tnsPath: args.tnsPath || "tns", - emulatorProcessIdentifier: args.emulatorProcessIdentifier, - modulesPath: args.modulesPath || "./bin/dist/tns-core-modules-" + modulesPackageConfig.version + ".tgz", - emuAvdName: args.emuAvdName, - outFile: args.outFile || "./TestRunResult.txt", - frameworkArgument: args.runtimePath ? " --frameworkPath=" + args.runtimePath : "", - runtimeVersionArgument: args.runtimeVersion ? "@" + args.runtimeVersion : "", - showEmu: args.showEmu || false, - runAppOnly: args.runAppOnly || false, - - workingDir:".testsapprun", - testsAppName:"TestsApp", - tnsCoreModulesSource: pathModule.resolve("./tns-core-modules"), - applicationDir: pathModule.join(".testsapprun", "TestsApp"), - appDir: pathModule.join(".testsapprun", "TestsApp", "app"), - pathToApk: "./platforms/android/build/outputs/apk/TestsApp-debug.apk", - pathToApp: "./platforms/ios/build/emulator/TestsApp.app", - deployedAppName:"org.nativescript.TestsApp", - mainActivityName:"com.tns.NativeScriptActivity", - pathToCompiledTests: "bin/dist/tests/app", - simulatorSysLog: pathModule.join(process.env.HOME, "Library/Logs/CoreSimulator", args.emuAvdName, "/system.log"), - platform: args.platform - } - - if (localCfg.runAppOnly) { - localCfg.pathToApp = localCfg.pathToApk = args.pathToApp; - localCfg.applicationDir = "./"; - } - - grunt.initConfig({ - clean: { - workingDir: { - src: localCfg.workingDir - }, - originalAppDir: { - src: [ - localCfg.appDir + "/*", - "!" + pathModule.join(localCfg.appDir, "App_Resources") + "" - ] - }, - modules: { - src: pathModule.join(localCfg.applicationDir, "node_modules", "tns-core-modules") - }, - tempExtractedModules: { - src: pathModule.join(localCfg.applicationDir, "node_modules", "package") - }, - simulatorLog: { - src: localCfg.simulatorSysLog, - options: { - force: true - } - } - }, - mkdir: { - workingDir: { - options: { - create: [localCfg.workingDir], - mode: 0700 - } - } - }, - copy: { - testsAppToRunDir: { - src: "**/*.*", - dest: localCfg.appDir, - cwd: localCfg.pathToCompiledTests, - expand: true - }, - modulesToDir: { - expand: true, - src: "**/*.*", - cwd: pathModule.join(localCfg.applicationDir, "node_modules", "package"), - dest: pathModule.join(localCfg.applicationDir, "node_modules", "tns-core-modules") - }, - addAndroidPermissions: { - src: "AndroidManifest.xml", - dest: localCfg.applicationDir + "/app/App_Resources/Android/", - cwd: localCfg.applicationDir + "/app/App_Resources/Android", - expand: true, - options: { - process: function(content, srcPath) { - var newContent = content; - - var internetPermissionFinder = /((\s*)]*android\.permission\.INTERNET[^>]*>)/; - - if (!/uses-permission[^>]*android\.permission\.ACCESS_NETWORK_STATE/.test(content)) { - newContent = newContent.replace(internetPermissionFinder, "$1$2"); - } - if (!/uses-permission[^>]*android\.permission\.ACCESS_FINE_LOCATION/.test(content)) { - newContent = newContent.replace(internetPermissionFinder, "$1$2"); - } - return newContent; - } - } - }, - addiOSPermissions: { - src: localCfg.testsAppName + "-Info.plist", - dest: pathModule.join(localCfg.applicationDir,"/platforms/ios/", localCfg.testsAppName) + "/", - cwd: pathModule.join(localCfg.applicationDir,"/platforms/ios/", localCfg.testsAppName), - expand: true, - options: { - process: function(content, srcPath) { - var newContent = content; - - var lastDictLocator = /(<\/dict>\s*<\/plist>)$/gm; - - if (!/NSAppTransportSecurity/.test(content)) { - newContent = newContent.replace(lastDictLocator, "NSAppTransportSecurity\n$1"); - } - if (!/NSAllowsArbitraryLoads/.test(content)) { - newContent = newContent.replace(lastDictLocator, "\nNSAllowsArbitraryLoads\n\n\n$1"); - } - return newContent; - } - } - }, - simulatorLog: { - src: localCfg.simulatorSysLog, - dest: localCfg.outFile - } - }, - exec: { - killAndroidEmulator: { - cmd: "pkill '" + localCfg.emulatorProcessIdentifier + "'", - exitCode: [0, 1] - }, - killiOSEmulator: { - cmd: "pkill Simulator", - exitCode: [0, 1] - }, - createApp: { - cmd: localCfg.tnsPath + " create " + localCfg.testsAppName, - cwd: localCfg.workingDir - }, - restartAdb: { - cmd: "adb kill-server && adb start-server" - }, - uninstallExistingAndroidApp: { - cmd: "adb uninstall " + localCfg.deployedAppName - }, - installNewAndroidApp: { - cmd: "adb install " + localCfg.pathToApk, - cwd: localCfg.applicationDir - }, - startAndroidEmulator: { - cmd: "emulator -avd " + localCfg.emuAvdName + " -no-audio " + (args.showEmu ? "" : "-no-window") + "&" - }, - startAndroidApp: { - cmd: "adb shell am start -n " + localCfg.deployedAppName + "/" + localCfg.mainActivityName - }, - uninstallExistingiOSApp: { - cmd: "xcrun simctl uninstall " + localCfg.emuAvdName + " org.nativescript." + localCfg.testsAppName, - cwd: localCfg.applicationDir - }, - installNewiOSApp: { - cmd: "xcrun simctl install " + localCfg.emuAvdName + " " + localCfg.pathToApp, - cwd: localCfg.applicationDir - }, - startiOSApp: { - cmd: "xcrun simctl launch " + localCfg.emuAvdName + " org.nativescript." + localCfg.testsAppName - }, - "npm-i-modules": { - cmd: "npm i " + pathModule.relative(localCfg.applicationDir, localCfg.modulesPath), - cwd: localCfg.applicationDir - }, - "npm-i-widgets": { - cmd: "npm i tns-core-modules-widgets@next", - cwd: localCfg.applicationDir - } - }, - shell: { - collectAndroidLog: { - command: "./expect.exp " + "'adb logcat *:D' " + localCfg.outFile, - options: { - execOptions: { - maxBuffer: Infinity - } - } - }, - waitiOSLogCompletion: { - command: "./expect.exp " + "'tail -f " + localCfg.simulatorSysLog + "' " + localCfg.outFile, - options: { - execOptions: { - maxBuffer: Infinity - } - } - }, - startiOSSimulator: { - command: "xcrun instruments -w " + localCfg.emuAvdName, - options: { - failOnError: false - }, - }, - buildApp: { - command: "tns build " + localCfg.platform.toLowerCase(), - options: { - execOptions: { - maxBuffer: Infinity, - cwd: localCfg.applicationDir - } - } - }, - addPlatform: { - command: "tns platform add " + localCfg.platform.toLowerCase() + localCfg.runtimeVersionArgument + " " + localCfg.frameworkArgument, - options: { - execOptions: { - maxBuffer: Infinity, - cwd: localCfg.applicationDir - } - } - }, - } - }); - - grunt.loadNpmTasks("grunt-shell"); - grunt.loadNpmTasks("grunt-exec"); - grunt.loadNpmTasks("grunt-mkdir"); - grunt.loadNpmTasks("grunt-contrib-clean"); - grunt.loadNpmTasks("grunt-contrib-copy"); - - var getPlatformSpecificTask = function(templatedTaskName) { - return templatedTaskName.replace(/\{platform\}/, localCfg.platform); - } - - grunt.registerTask("startEmulatorAndroid", [ - getPlatformSpecificTask("exec:startAndroidEmulator"), - ]); - - grunt.registerTask("startEmulatoriOS", [ - getPlatformSpecificTask("shell:startiOSSimulator"), - ]); - - grunt.registerTask("collectLogAndroid", [ - "shell:collectAndroidLog" - ]); - - grunt.registerTask("collectLogiOS", [ - "shell:waitiOSLogCompletion", - "copy:simulatorLog" - ]); - - grunt.registerTask("doPreUninstallAppAndroid", [ - "exec:restartAdb" - ]); - - grunt.registerTask("doPreUninstallAppiOS", [ - "clean:simulatorLog" - ]); - - grunt.registerTask("cleanup", [ -// getPlatformSpecificTask("exec:kill{platform}Emulator"), - "clean:workingDir" - ]); - - grunt.registerTask("buildOnly", [ - "exec:createApp", - "clean:originalAppDir", - "copy:testsAppToRunDir", - "clean:modules", - "exec:npm-i-modules", - "exec:npm-i-widgets", - "copy:modulesToDir", - "clean:tempExtractedModules", - - "shell:addPlatform", - getPlatformSpecificTask("copy:add{platform}Permissions"), - "shell:buildApp", - ]); - - grunt.registerTask("buildTestsApp", [ - "cleanup", - "mkdir:workingDir", - "buildOnly" - - ]); - grunt.registerTask("buildOnlyTestsApp", ["buildTestsApp"]); - - grunt.registerTask("runOnly", [ -// getPlatformSpecificTask("doPreUninstallApp{platform}"), - - getPlatformSpecificTask("exec:uninstallExisting{platform}App"), - getPlatformSpecificTask("exec:installNew{platform}App"), - getPlatformSpecificTask("exec:start{platform}App"), - getPlatformSpecificTask("collectLog{platform}"), - ]); - - grunt.registerTask("runApp", [ -// "cleanup", -// getPlatformSpecificTask("startEmulator{platform}"), - "runOnly", - "cleanup" - - ]); - - grunt.registerTask("runOnlyTestsApp", ["runApp"]); - - - var tasksToExecute = ["runApp"]; - if (!localCfg.runAppOnly) { - tasksToExecute = [ - "cleanup", - "mkdir:workingDir", - getPlatformSpecificTask("startEmulator{platform}"), - "buildOnly", - "runOnly", - "cleanup" - ]; - } - - grunt.registerTask("testsapp", tasksToExecute); - } -} diff --git a/package.json b/package.json index 3c57d4ab91..fad67c4edb 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "devDependencies": { "@types/chai": "^4.0.4", "@types/mocha": "^2.2.42", - "@types/node": "^7.0.5", + "@types/node": "~10.12.18", "chai": "^4.1.2", "concurrently": "^2.1.0", "css": "^2.2.1", @@ -32,9 +32,12 @@ "mocha-typescript": "^1.1.9", "module-alias": "^2.0.1", "nativescript-typedoc-theme": "git://github.com/NativeScript/nativescript-typedoc-theme.git#master", + "ncp": "^2.0.0", "parse-css": "git+https://github.com/tabatkins/parse-css.git", "parserlib": "^1.1.1", + "readdirp": "^3.1.2", "reduce-css-calc": "^2.1.6", + "rimraf": "^2.5.0", "shady-css-parser": "^0.1.0", "shelljs": "^0.7.0", "source-map-support": "^0.4.17", @@ -46,8 +49,7 @@ "typescript": "^3.1.6" }, "scripts": { - "setup": "", - "setup-widgets": "( cd tns-core-modules-widgets && sh build.sh ) && npm run dev-link-tns-core-modules-widgets", + "setup-widgets": "(cd tns-core-modules-widgets && sh build.sh) && npm run dev-link-tns-core-modules-widgets", "tsc": "node --max_old_space_size=4096 ./node_modules/typescript/bin/tsc", "ci": "tsc && npm run tslint && npm run ci-apps && npm run ci-e2e && npm run ci-tests", "ci-apps": "cd apps && npm i ../tns-core-modules ../tns-platform-declarations --save", @@ -56,7 +58,7 @@ "unit-test": "tsc -p tsconfig.unit-tests.json && mocha --opts unit-tests/mocha.opts", "unit-test-watch": "mocha-typescript-watch -p tsconfig.unit-tests.json --opts unit-tests/mocha.opts", "compile-all": "npm run tsc -- -p tsconfig.json --outDir bin/dist", - "compile-modules": "npm run tsc -- -p tsconfig.modules.json --outDir bin/dist", + "compile-modules": "npm run tsc -- -p tsconfig.modules.json", "compile-check-base-dts": "npm run tsc -- -p tsconfig.base-dts.json", "compile-unit-tests": "npm run tsc -- -p tsconfig.unit-tests.json --outDir bin/dist/unit-tests", "compile-check-combined-dts": "npm run tsc -- -p tsconfig.combined-dts.json", @@ -67,20 +69,16 @@ "dev-tsc-e2e": "npm run tsc -- -p e2e", "dev-tsc-all": "npm run dev-tsc-tns-platform-declarations && npm run tsc && npm run dev-tsc-tests && npm run dev-tsc-apps && && npm run dev-tsc-e2e", "dev-link-tns-core-modules-widgets": "(cd tns-core-modules-widgets/dist/package && npm link) && (cd tns-core-modules && npm i ../tns-core-modules-widgets/dist/package --save)", - "dev-declarations": "npm run setup && rm -rf tns-platform-declarations/ios/objc* && TNS_TYPESCRIPT_DECLARATIONS_PATH=$PWD/tns-platform-declarations/ios/objc tns build ios --path tests", + "dev-declarations": "rm -rf tns-platform-declarations/ios/objc* && TNS_TYPESCRIPT_DECLARATIONS_PATH=$PWD/tns-platform-declarations/ios/objc tns build ios --path tests", "test": "npm run test-android && npm run test-ios", - "pretest": "npm run setup && npm run tsc", "test-android": "tns run android --path tests --justlaunch --no-watch", "test-ios": "tns run ios --path tests --justlaunch --no-watch", "test-watch-android": "npm run pretest && concurrently --kill-others \"npm run tsc-w\" \"tns run android --path tests --watch\"", "test-watch-ios": "npm run pretest && concurrently --kill-others \"npm run tsc-w\" \"tns run ios --path tests --watch\"", "typedoc": "typedoc --tsconfig tsconfig.typedoc.json --out bin/dist/apiref --includeDeclarations --name NativeScript --theme ./node_modules/nativescript-typedoc-theme --excludeExternals --externalPattern \"**/+(tns-core-modules|module).d.ts\"", "dev-typedoc": "npm run typedoc && cd bin/dist/apiref && npx http-server", - "test-tsc-es2016": "npm run tsc -- -p tsconfig.public.es2016.json", "tslint": "tslint --project tsconfig.tslint.json --config build/tslint.json", - "madge-ios": "tsc --skipLibCheck && tns prepare ios --path tests && madge --circular tests/platforms/ios/tests/app/tns_modules/tns-core-modules", - "madge-ios-image": "tsc --skipLibCheck && tns prepare ios --path tests && madge --image graph-tests-ios.svg tests/platforms/ios/tests/app/tns_modules/tns-core-modules", - "madge-android": "tsc --skipLibCheck && tns prepare android --path tests && madge --circular tests/platforms/android/app/src/main/assets/app/tns_modules/tns-core-modules", - "madge-android-image": "tsc --skipLibCheck && tns prepare android --path tests && madge --image graph-tests-android.svg tests/platforms/android/app/src/main/assets/app/tns_modules/tns-core-modules" + "prepare-dist": "bash ./build/prepare-dist.sh", + "pack-dist": "bash ./build/pack-dist.sh" } } diff --git a/tns-core-modules-widgets/LICENSE b/tns-core-modules-widgets/LICENSE deleted file mode 100755 index 061c440288..0000000000 --- a/tns-core-modules-widgets/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright (c) 2015-2019 Progress Software Corporation - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - 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 diff --git a/tns-core-modules-widgets/build.sh b/tns-core-modules-widgets/build.sh index d1d2ec1a78..c4ede3f234 100755 --- a/tns-core-modules-widgets/build.sh +++ b/tns-core-modules-widgets/build.sh @@ -15,7 +15,9 @@ export SKIP_PACK=true ./build.ios.sh echo "Copy NPM artefacts" -cp .npmignore LICENSE README.md package.json dist/package +cp .npmignore README.md package.json dist/package +cp ../LICENSE dist/package + if [ "$1" ] then diff --git a/tns-core-modules/LICENSE b/tns-core-modules/LICENSE deleted file mode 100755 index ef8add3b41..0000000000 --- a/tns-core-modules/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright (c) 2015-2019 Progress Software Corporation - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - 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. diff --git a/tns-core-modules/package.json b/tns-core-modules/package.json index 9c763fb590..8ee9d95f39 100644 --- a/tns-core-modules/package.json +++ b/tns-core-modules/package.json @@ -31,7 +31,7 @@ "tslib": "1.10.0" }, "devDependencies": { - "@types/node": "~7.0.5", + "@types/node": "~10.12.18", "tns-platform-declarations": "next" }, "scripts": { diff --git a/tns-core-modules/tsconfig.json b/tns-core-modules/tsconfig.json new file mode 100644 index 0000000000..631dd8b0d6 --- /dev/null +++ b/tns-core-modules/tsconfig.json @@ -0,0 +1,33 @@ +{ + "compilerOptions": { + "noEmitOnError": false, + "noEmitHelpers": true, + "target": "es5", + "module": "commonjs", + "declaration": false, + "noImplicitAny": false, + "noImplicitUseStrict": true, + "removeComments": true, + "experimentalDecorators": true, + "diagnostics": true, + "sourceMap": true, + "lib": [ + "es6", "dom" + ], + "types": [ + "node", + "chai", + "mocha" + ], + "baseUrl": ".", + "paths": { + "tns-core-modules/*": ["*"] + } + }, + "include": [ + "**/*.ts" + ], + "exclude": [ + "tns-core-modules/node_modules/" + ] +} diff --git a/tns-core-modules/ui/frame/transition-definitions.android.d.ts b/tns-core-modules/ui/frame/transition-definitions.android.d.ts index 1a86939f20..5773d3a0a5 100644 --- a/tns-core-modules/ui/frame/transition-definitions.android.d.ts +++ b/tns-core-modules/ui/frame/transition-definitions.android.d.ts @@ -1,4 +1,5 @@ /** + * @module "ui/frame/transition-definitions.android * @private */ /** */ diff --git a/tns-platform-declarations/tsconfig.json b/tns-platform-declarations/tsconfig.json index ab70b0477c..ad84e06bf8 100644 --- a/tns-platform-declarations/tsconfig.json +++ b/tns-platform-declarations/tsconfig.json @@ -1,5 +1,24 @@ { - "extends": "../tsconfig.shared", + "compilerOptions": { + "noEmitOnError": false, + "noEmitHelpers": true, + "target": "es5", + "module": "commonjs", + "declaration": false, + "noImplicitAny": false, + "noImplicitUseStrict": true, + "removeComments": true, + "experimentalDecorators": true, + "diagnostics": true, + "sourceMap": true, + "lib": [ + "es6", "dom" + ], + "baseUrl": ".", + "paths": { + "tns-core-modules/*": ["tns-core-modules/*"] + } + }, "exclude": [ "android-*.d.ts", "android/android-*.d.ts", From 4166e2d966d9cbe10267b42e5726939988583864 Mon Sep 17 00:00:00 2001 From: Vasil Chimev Date: Thu, 19 Sep 2019 18:49:07 +0300 Subject: [PATCH 02/10] fix: expose orientation to application module (#7832) --- tests/app/application/application-tests-common.ts | 4 ++++ tns-core-modules/application/application.android.ts | 4 ++++ tns-core-modules/application/application.d.ts | 6 ++++++ tns-core-modules/application/application.ios.ts | 8 ++++++-- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/tests/app/application/application-tests-common.ts b/tests/app/application/application-tests-common.ts index 47dc01e944..6d0179eb01 100644 --- a/tests/app/application/application-tests-common.ts +++ b/tests/app/application/application-tests-common.ts @@ -21,3 +21,7 @@ export function testDisplayedEvent() { // global.isDisplayedEventFired flag is set in app.ts application.displayedEvent handler TKUnit.assert((global).isDisplayedEventFired, "application.displayedEvent not fired"); } + +export function testOrientation() { + TKUnit.assert(app.orientation, "Orientation not initialized."); +} diff --git a/tns-core-modules/application/application.android.ts b/tns-core-modules/application/application.android.ts index b1d633c620..25e04594bd 100644 --- a/tns-core-modules/application/application.android.ts +++ b/tns-core-modules/application/application.android.ts @@ -248,6 +248,10 @@ export function getNativeApplication(): android.app.Application { return nativeApp; } +export function orientation(): "portrait" | "landscape" | "unknown" { + return androidApp.orientation; +} + on(orientationChangedEvent, (args: OrientationChangedEventData) => { const rootView = getRootView(); if (rootView) { diff --git a/tns-core-modules/application/application.d.ts b/tns-core-modules/application/application.d.ts index 672e55cc57..48217c411b 100644 --- a/tns-core-modules/application/application.d.ts +++ b/tns-core-modules/application/application.d.ts @@ -285,6 +285,12 @@ export function on(event: "discardedError", callback: (args: DiscardedErrorEvent */ export function on(event: "orientationChanged", callback: (args: OrientationChangedEventData) => void, thisArg?: any); +/** + * Gets the orientation of the application. + * Available values: "portrait", "landscape", "unknown". + */ +export function orientation(): "portrait" | "landscape" | "unknown"; + /** * This is the Android-specific application object instance. * Encapsulates methods and properties specific to the Android platform. diff --git a/tns-core-modules/application/application.ios.ts b/tns-core-modules/application/application.ios.ts index 37a8340960..60fd1fda89 100644 --- a/tns-core-modules/application/application.ios.ts +++ b/tns-core-modules/application/application.ios.ts @@ -39,8 +39,8 @@ const Responder = (UIResponder).extend({ // NOOP } }, { - protocols: [UIApplicationDelegate] - } + protocols: [UIApplicationDelegate] +} ); class NotificationObserver extends NSObject { @@ -415,6 +415,10 @@ function setViewControllerView(view: View): void { } } +export function orientation(): "portrait" | "landscape" | "unknown" { + return iosApp.orientation; +} + on(orientationChangedEvent, (args: OrientationChangedEventData) => { const rootView = getRootView(); if (rootView) { From 167c0c9c2a5687414f78b172087233da5f69f4fa Mon Sep 17 00:00:00 2001 From: Martin Yankov Date: Tue, 24 Sep 2019 17:27:42 +0300 Subject: [PATCH 03/10] chore: add highlight color to api reference (#7858) --- .../ui/tab-navigation-base/tab-strip/tab-strip.d.ts | 5 +++++ .../ui/tab-navigation-base/tab-strip/tab-strip.ts | 1 + 2 files changed, 6 insertions(+) diff --git a/tns-core-modules/ui/tab-navigation-base/tab-strip/tab-strip.d.ts b/tns-core-modules/ui/tab-navigation-base/tab-strip/tab-strip.d.ts index 22b6298903..6df5c81cdb 100644 --- a/tns-core-modules/ui/tab-navigation-base/tab-strip/tab-strip.d.ts +++ b/tns-core-modules/ui/tab-navigation-base/tab-strip/tab-strip.d.ts @@ -27,6 +27,11 @@ export class TabStrip extends View { */ iosIconRenderingMode: "automatic" | "alwaysOriginal" | "alwaysTemplate"; + /** + * Gets or sets the color that marks the selected tab of the tab strip. Works for Tabs component only. + */ + highlightColor: Color; + /** * @private */ diff --git a/tns-core-modules/ui/tab-navigation-base/tab-strip/tab-strip.ts b/tns-core-modules/ui/tab-navigation-base/tab-strip/tab-strip.ts index f6654c4c5e..deead4fb87 100644 --- a/tns-core-modules/ui/tab-navigation-base/tab-strip/tab-strip.ts +++ b/tns-core-modules/ui/tab-navigation-base/tab-strip/tab-strip.ts @@ -24,6 +24,7 @@ export class TabStrip extends View implements TabStripDefinition, AddChildFromBu public items: TabStripItem[]; public isIconSizeFixed: boolean; public iosIconRenderingMode: "automatic" | "alwaysOriginal" | "alwaysTemplate"; + public highlightColor: Color; public _hasImage: boolean; public _hasTitle: boolean; From b7f6a2dec544093b11d63cf60a981cf286a5100b Mon Sep 17 00:00:00 2001 From: vakrilov Date: Fri, 27 Sep 2019 17:26:07 +0300 Subject: [PATCH 04/10] test: escape & in tests (invalid XML) --- ...bindingExpressions_logicalComparisonOperators_testPage.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/app/ui/test-pages/bindingExpressions_logicalComparisonOperators_testPage.xml b/tests/app/ui/test-pages/bindingExpressions_logicalComparisonOperators_testPage.xml index b22a68571f..02bd49a909 100644 --- a/tests/app/ui/test-pages/bindingExpressions_logicalComparisonOperators_testPage.xml +++ b/tests/app/ui/test-pages/bindingExpressions_logicalComparisonOperators_testPage.xml @@ -1,7 +1,7 @@  - + - + From 6246a72c39119f62d9c07969ffdc020cdece14e3 Mon Sep 17 00:00:00 2001 From: Svetoslav Date: Thu, 10 Oct 2019 00:29:55 +0300 Subject: [PATCH 05/10] svetoslavtsenov/extend gestures tests (#7870) --- e2e/ui-tests-app/.vscode/launch.json | 8 +- e2e/ui-tests-app/app/events/gestures-page.ts | 165 +++++++++++------- e2e/ui-tests-app/app/events/handlers-page.ts | 31 ++-- e2e/ui-tests-app/app/events/handlers-page.xml | 3 + .../e2e/suites/css/styles/styles-page.ts | 2 +- .../gestures-events/common/common-tests.ts | 68 ++++++++ .../events-gestures-base-page.ts | 10 ++ .../gestures-events/gestures/gestures-page.ts | 17 ++ .../gestures/gestures.e2e-spec.ts | 120 +++++++++++++ .../bottom-navigation.e2e-spec.ts | 2 +- .../tab-view-css-properties.e2e-spec.ts | 11 +- .../tabs/tabs-tests.e2e-spec.ts | 2 +- 12 files changed, 350 insertions(+), 89 deletions(-) create mode 100644 e2e/ui-tests-app/e2e/suites/gestures-events/common/common-tests.ts create mode 100644 e2e/ui-tests-app/e2e/suites/gestures-events/events-gestures-base-page.ts create mode 100644 e2e/ui-tests-app/e2e/suites/gestures-events/gestures/gestures-page.ts create mode 100644 e2e/ui-tests-app/e2e/suites/gestures-events/gestures/gestures.e2e-spec.ts diff --git a/e2e/ui-tests-app/.vscode/launch.json b/e2e/ui-tests-app/.vscode/launch.json index 1c798a1645..f50412d011 100644 --- a/e2e/ui-tests-app/.vscode/launch.json +++ b/e2e/ui-tests-app/.vscode/launch.json @@ -27,7 +27,8 @@ "--colors", "--opts", "../config/mocha.opts", - "--grep=bottom-navigation", + "--grep", + "gestures-events-gestures", "-a", ], "internalConsoleOptions": "openOnSessionStart", @@ -45,10 +46,7 @@ "--opts", "../config/mocha.opts", "--grep=bottom-navigation", - "android", - "--grep=bottom-navigation", - "--port", - "8889", + "android" ], "internalConsoleOptions": "openOnSessionStart" } diff --git a/e2e/ui-tests-app/app/events/gestures-page.ts b/e2e/ui-tests-app/app/events/gestures-page.ts index 03166a8e21..674a3f5964 100644 --- a/e2e/ui-tests-app/app/events/gestures-page.ts +++ b/e2e/ui-tests-app/app/events/gestures-page.ts @@ -1,55 +1,56 @@ -import * as labelModule from "tns-core-modules/ui/label"; -import * as gestures from "tns-core-modules/ui/gestures"; -import * as button from "tns-core-modules/ui/button"; -import * as pages from "tns-core-modules/ui/page"; -import * as deviceProperties from "tns-core-modules/platform"; -import * as stackLayoutModule from "tns-core-modules/ui/layouts/stack-layout"; +import { + GestureEventData, + RotationGestureEventData, + GestureTypes, + SwipeGestureEventData, + PanGestureEventData, + PinchGestureEventData, + GestureStateTypes +} from "tns-core-modules/ui/gestures"; +import { Button } from "tns-core-modules/ui/button"; +import { Label } from "tns-core-modules/ui/label"; +import { Page } from "tns-core-modules/ui/page"; +import { StackLayout } from "tns-core-modules/ui/layouts/stack-layout"; +import { screen, isAndroid } from "tns-core-modules/platform"; export function createPage() { - - var stack = new stackLayoutModule.StackLayout(); - var labelHeight = Math.round(deviceProperties.screen.mainScreen.heightPixels / (7 * deviceProperties.screen.mainScreen.scale)); - var stopButton = new button.Button(); + const stack = new StackLayout(); + var stopButton = new Button(); + if (isAndroid) { + stopButton.height = 30; + stopButton.fontSize = 8; + } stopButton.text = "Stop Detecting Gestures"; + stopButton.automationText = "stopGesturesDetecting"; stack.addChild(stopButton); - var tapLabel = new labelModule.Label(); - tapLabel.text = "Tap here"; + const labelHeight = Math.round(screen.mainScreen.heightPixels / (10 * screen.mainScreen.scale)); + + const tapLabel = createLabel("Tap here", labelHeight); stack.addChild(tapLabel); - var doubletapLabel = new labelModule.Label(); - doubletapLabel.text = "Double Tap here"; - stack.addChild(doubletapLabel); + const doubleTapLabel = createLabel("Double Tap here", labelHeight); + stack.addChild(doubleTapLabel); + + const longPressLabel = createLabel("Long Press here", labelHeight); + stack.addChild(longPressLabel); - var longpressLabel = new labelModule.Label(); - longpressLabel.text = "Long Press here"; - stack.addChild(longpressLabel); + const tapAndDoubleTapLabel = createLabel("Tap or Double Tap", labelHeight, true); + stack.addChild(tapAndDoubleTapLabel); - var swipeLabel = new labelModule.Label(); - swipeLabel.height = labelHeight; - swipeLabel.text = "Swipe here"; - swipeLabel.textWrap = true; + const swipeLabel = createLabel("Swipe here", labelHeight, true); stack.addChild(swipeLabel); - var panLabel = new labelModule.Label(); - panLabel.height = labelHeight; - panLabel.text = "Pan here"; - panLabel.textWrap = true; + const panLabel = createLabel("Pan here", labelHeight, true); stack.addChild(panLabel); - var pinchLabel = new labelModule.Label(); - pinchLabel.height = labelHeight; - pinchLabel.text = "Pinch here"; - pinchLabel.textWrap = true; + const pinchLabel = createLabel("Pinch here", labelHeight, true); stack.addChild(pinchLabel); - var rotaionLabel = new labelModule.Label(); - rotaionLabel.height = labelHeight; - rotaionLabel.text = "Rotate here"; - rotaionLabel.textWrap = true; - stack.addChild(rotaionLabel); + const rotationLabel = createLabel("Rotate here", labelHeight, true); + stack.addChild(rotationLabel); - stopButton.on(button.Button.tapEvent, function () { + stopButton.on("tap", function () { observer1.disconnect(); observer2.disconnect(); observer3.disconnect(); @@ -57,77 +58,111 @@ export function createPage() { observer5.disconnect(); observer6.disconnect(); observer7.disconnect(); + observer8.disconnect(); + observer9.disconnect(); tapLabel.text = "Gestures detection disabled"; - doubletapLabel.text = "Gestures detection disabled"; - longpressLabel.text = "Gestures detection disabled"; - swipeLabel.text = "Gesturesd detection disabled"; + tapLabel.automationText = "Gestures detection disabled"; + doubleTapLabel.text = "Gestures detection disabled"; + doubleTapLabel.automationText = "Gestures detection disabled"; + longPressLabel.text = "Gestures detection disabled"; + longPressLabel.automationText = "Gestures detection disabled"; + swipeLabel.text = "Gestures detection disabled"; + swipeLabel.automationText = "Gestures detection disabled"; panLabel.text = "Gestures detection disabled"; + panLabel.automationText = "Gestures detection disabled"; pinchLabel.text = "Gestures detection disabled"; - rotaionLabel.text = "Gestures detection disabled"; + pinchLabel.automationText = "Gestures detection disabled"; + rotationLabel.text = "Gestures detection disabled"; + rotationLabel.automationText = "Gestures detection disabled"; + tapAndDoubleTapLabel.text = "Gestures detection disabled"; + tapAndDoubleTapLabel.automationText = "Gestures detection disabled"; }); - tapLabel.on(gestures.GestureTypes.tap, function (args: gestures.GestureEventData) { + tapLabel.on(GestureTypes[GestureTypes.tap], function (args: GestureEventData) { tapLabel.text = "Tap gesture detected, " + (args.object === tapLabel); }); - var observer1 = tapLabel.getGestureObservers(gestures.GestureTypes.tap)[0]; + const observer1 = tapLabel.getGestureObservers(GestureTypes.tap)[0]; - doubletapLabel.on(gestures.GestureTypes.doubleTap, function (args: gestures.GestureEventData) { - doubletapLabel.text = "Double Tap gesture detected, " + (args.object === doubletapLabel); + doubleTapLabel.on(GestureTypes[GestureTypes.doubleTap], function (args: GestureEventData) { + doubleTapLabel.text = "Double Tap gesture detected, " + (args.object === doubleTapLabel); }); - var observer2 = doubletapLabel.getGestureObservers(gestures.GestureTypes.doubleTap)[0]; + const observer2 = doubleTapLabel.getGestureObservers(GestureTypes.doubleTap)[0]; - longpressLabel.on(gestures.GestureTypes.longPress, function (args: gestures.GestureEventData) { - longpressLabel.text = "Long Press gesture detected, " + (args.object === longpressLabel); + longPressLabel.on(GestureTypes[GestureTypes.longPress], function (args: GestureEventData) { + longPressLabel.text = "Long Press gesture detected, " + (args.object === longPressLabel); }); - var observer3 = longpressLabel.getGestureObservers(gestures.GestureTypes.longPress)[0]; + const observer3 = longPressLabel.getGestureObservers(GestureTypes.longPress)[0]; - swipeLabel.on(gestures.GestureTypes.swipe, function (args: gestures.SwipeGestureEventData) { + swipeLabel.on(GestureTypes[GestureTypes.swipe], function (args: SwipeGestureEventData) { swipeLabel.text = "Swipe Direction: " + args.direction + ", " + (args.object === swipeLabel); // + getStateAsString(args.state); }); - var observer4 = swipeLabel.getGestureObservers(gestures.GestureTypes.swipe)[0]; + const observer4 = swipeLabel.getGestureObservers(GestureTypes.swipe)[0]; - panLabel.on(gestures.GestureTypes.pan, function (args: gestures.PanGestureEventData) { + panLabel.on(GestureTypes[GestureTypes.pan], function (args: PanGestureEventData) { panLabel.text = "Pan deltaX:" + Math.round(args.deltaX) + "; deltaY:" + Math.round(args.deltaY) + ";" + ", " + (args.object === panLabel) + getStateAsString(args.state); }); - var observer5 = panLabel.getGestureObservers(gestures.GestureTypes.pan)[0]; + const observer5 = panLabel.getGestureObservers(GestureTypes.pan)[0]; - pinchLabel.on(gestures.GestureTypes.pinch, function (args: gestures.PinchGestureEventData) { + pinchLabel.on(GestureTypes[GestureTypes.pinch], function (args: PinchGestureEventData) { pinchLabel.text = "Pinch Scale: " + Math.round(args.scale) + ", " + (args.object === pinchLabel) + getStateAsString(args.state); }); - var observer6 = pinchLabel.getGestureObservers(gestures.GestureTypes.pinch)[0]; + const observer6 = pinchLabel.getGestureObservers(GestureTypes.pinch)[0]; - rotaionLabel.on(gestures.GestureTypes.rotation, function (args: gestures.RotationGestureEventData) { - rotaionLabel.text = "Rotation: " + Math.round(args.rotation) + ", " + (args.object === rotaionLabel) + getStateAsString(args.state); + rotationLabel.on(GestureTypes[GestureTypes.rotation], function (args: RotationGestureEventData) { + rotationLabel.text = "Rotation: " + Math.round(args.rotation) + ", " + (args.object === rotationLabel) + getStateAsString(args.state); }); - var observer7 = rotaionLabel.getGestureObservers(gestures.GestureTypes.rotation)[0]; + const observer7 = rotationLabel.getGestureObservers(GestureTypes.rotation)[0]; - var page = new pages.Page(); - page.content = stack; + tapAndDoubleTapLabel.on(GestureTypes[GestureTypes.doubleTap], function (args: GestureEventData) { + tapAndDoubleTapLabel.text = "Last action: Double tap gesture, " + (args.object === tapAndDoubleTapLabel); + }); + + const observer8 = tapAndDoubleTapLabel.getGestureObservers(GestureTypes.doubleTap)[0]; + tapAndDoubleTapLabel.on(GestureTypes[GestureTypes.tap], function (args: GestureEventData) { + tapAndDoubleTapLabel.text = "Last action: Tap gesture, " + (args.object === tapAndDoubleTapLabel); + }); + + const observer9 = tapAndDoubleTapLabel.getGestureObservers(GestureTypes.tap)[0]; + + const page = new Page(); + page.content = stack; + return page; } -var states = new Array(); -function getStateAsString(state: gestures.GestureStateTypes): string { - if (state === gestures.GestureStateTypes.began) { +function getStateAsString(state: GestureStateTypes): string { + const states = new Array(); + if (state === GestureStateTypes.began) { states.length = 0; states.push("began"); - } else if (state === gestures.GestureStateTypes.cancelled) { + } else if (state === GestureStateTypes.cancelled) { states.push("cancelled"); - } else if (state === gestures.GestureStateTypes.changed) { + } else if (state === GestureStateTypes.changed) { if (states.indexOf("changed") === -1) { states.push("changed"); } - } else if (state === gestures.GestureStateTypes.ended) { + } else if (state === GestureStateTypes.ended) { states.push("ended"); } return ", states: " + states.join(","); } + +function createLabel(text: string, labelHeight: number, shouldWrap = false) { + const label = new Label(); + label.height = labelHeight; + label.text = text; + label.textWrap = shouldWrap; + label.borderColor = "green"; + label.borderWidth = 1; + + return label; +} \ No newline at end of file diff --git a/e2e/ui-tests-app/app/events/handlers-page.ts b/e2e/ui-tests-app/app/events/handlers-page.ts index d3ffe29801..24308b61bf 100644 --- a/e2e/ui-tests-app/app/events/handlers-page.ts +++ b/e2e/ui-tests-app/app/events/handlers-page.ts @@ -1,16 +1,27 @@ -import * as observable from "tns-core-modules/data/observable"; -import * as gestures from "tns-core-modules/ui/gestures"; -import * as pages from "tns-core-modules/ui/page"; +import { EventData } from "tns-core-modules/data/observable"; +import { GestureEventData } from "tns-core-modules/ui/gestures"; +import { Page } from "tns-core-modules/ui/page"; +import { Label } from "tns-core-modules/ui/label/label"; -export function pageLoaded(args: observable.EventData) { - var page = args.object; - page.bindingContext = { tapAction: tapAction, doubleTapAction: doubleTapAction }; +export function pageLoaded(args: EventData) { + var page = args.object; + page.bindingContext = { tapAction: tapAction, doubleTapAction: doubleTapAction, cleanResult: cleanResult }; } -export function tapAction(args: gestures.GestureEventData) { - console.log("tapAction"); +export function tapAction(args: GestureEventData) { + setResult(args, "tapAction"); } -export function doubleTapAction(args: gestures.GestureEventData) { - console.log("doubleTapAction"); +export function doubleTapAction(args: GestureEventData) { + setResult(args, "doubleTapAction"); } + +export function cleanResult(args: GestureEventData) { + setResult(args, ""); +} + +const setResult = (args: GestureEventData, text: string) => { + console.log(text); + const resultPanel: Label = (((args.object).page)).getViewById("resultContainer"); + resultPanel.text = text; +}; diff --git a/e2e/ui-tests-app/app/events/handlers-page.xml b/e2e/ui-tests-app/app/events/handlers-page.xml index 275055a405..d3ea351780 100644 --- a/e2e/ui-tests-app/app/events/handlers-page.xml +++ b/e2e/ui-tests-app/app/events/handlers-page.xml @@ -2,5 +2,8 @@