From 172e947d180f93447fff6a92e766e1c45b10bee8 Mon Sep 17 00:00:00 2001 From: Erisu Date: Wed, 15 May 2024 19:45:51 +0900 Subject: [PATCH 01/66] chore: bump version 13.0.1-dev --- framework/src/org/apache/cordova/CordovaWebView.java | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/framework/src/org/apache/cordova/CordovaWebView.java b/framework/src/org/apache/cordova/CordovaWebView.java index ed2778825..47247f79e 100644 --- a/framework/src/org/apache/cordova/CordovaWebView.java +++ b/framework/src/org/apache/cordova/CordovaWebView.java @@ -31,7 +31,7 @@ Licensed to the Apache Software Foundation (ASF) under one * are not expected to implement it. */ public interface CordovaWebView { - public static final String CORDOVA_VERSION = "13.0.0"; + public static final String CORDOVA_VERSION = "13.0.1-dev"; void init(CordovaInterface cordova, List pluginEntries, CordovaPreferences preferences); diff --git a/package-lock.json b/package-lock.json index 3372dd1aa..86ae519aa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "cordova-android", - "version": "13.0.0", + "version": "13.0.1-dev", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "cordova-android", - "version": "13.0.0", + "version": "13.0.1-dev", "license": "Apache-2.0", "dependencies": { "android-versions": "^2.0.0", diff --git a/package.json b/package.json index e2896e5c5..c9e7ad7c9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-android", - "version": "13.0.0", + "version": "13.0.1-dev", "description": "cordova-android release", "types": "./types/index.d.ts", "main": "lib/Api.js", From d28172711365ec2ec1a6c17480beb16a6554b5a6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jun 2024 09:38:52 -0700 Subject: [PATCH 02/66] chore(deps): bump braces from 3.0.2 to 3.0.3 (#1716) Bumps [braces](https://github.com/micromatch/braces) from 3.0.2 to 3.0.3. - [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md) - [Commits](https://github.com/micromatch/braces/compare/3.0.2...3.0.3) --- updated-dependencies: - dependency-name: braces dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 86ae519aa..58283ea36 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1198,11 +1198,11 @@ } }, "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -2363,9 +2363,9 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dependencies": { "to-regex-range": "^5.0.1" }, From 3503bfa31b10cc7d6948356d4c101c7b76109688 Mon Sep 17 00:00:00 2001 From: 5r1m <47805716+5r1m@users.noreply.github.com> Date: Mon, 24 Jun 2024 17:13:22 +0530 Subject: [PATCH 03/66] Update AndroidManifest.xml by extending android:configChanges with "navigation" as application is restarted when BT keyboard is connected in some devices (#1718) In some devices (especially pixel) connecting with BT keyboard is resulting in application being restarted. The existing "keyboard" seems to be not sufficient as in this case it was triggering "navigation" change. https://stackoverflow.com/questions/25735227/bluetooth-keyboard-will-cause-activity-destroy-and-recreate/27238892#27238892 --- templates/project/AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/project/AndroidManifest.xml b/templates/project/AndroidManifest.xml index e7bc7a451..b522b1406 100644 --- a/templates/project/AndroidManifest.xml +++ b/templates/project/AndroidManifest.xml @@ -39,7 +39,7 @@ android:launchMode="singleTop" android:theme="@style/Theme.App.SplashScreen" android:windowSoftInputMode="adjustResize" - android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" + android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode|navigation" android:exported="true"> From 5eddc460e49a5b8ce2bcc43d0a22fe4511842085 Mon Sep 17 00:00:00 2001 From: Norman Breau Date: Tue, 17 Sep 2024 09:33:52 -0300 Subject: [PATCH 04/66] fix(docs): Incorrect JDK requirement stated in README (#1739) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 982d72db4..cf657e884 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Cordova Android is an Android application library that allows for Cordova-based ## Requirements -* Java Development Kit (JDK) 11 +* Java Development Kit (JDK) 17 * [Android SDK](https://developer.android.com/) * [Node.js](https://nodejs.org) From 5a2c50d1ed67c1cdad0d12f1b6fbbd04ab55dff6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 22 Oct 2024 23:16:21 -0700 Subject: [PATCH 05/66] chore(deps): bump micromatch from 4.0.5 to 4.0.8 (#1736) Bumps [micromatch](https://github.com/micromatch/micromatch) from 4.0.5 to 4.0.8. - [Release notes](https://github.com/micromatch/micromatch/releases) - [Changelog](https://github.com/micromatch/micromatch/blob/master/CHANGELOG.md) - [Commits](https://github.com/micromatch/micromatch/compare/4.0.5...4.0.8) --- updated-dependencies: - dependency-name: micromatch dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 58283ea36..a51e4bb0d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3619,11 +3619,11 @@ } }, "node_modules/micromatch": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", - "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "dependencies": { - "braces": "^3.0.2", + "braces": "^3.0.3", "picomatch": "^2.3.1" }, "engines": { From 1347e48d14e40626703ddfa37b65c665c734a34c Mon Sep 17 00:00:00 2001 From: Darryl Pogue Date: Tue, 19 Nov 2024 20:55:50 -0800 Subject: [PATCH 06/66] chore(ci): Fix dependabot PR failures (#1750) --- .github/workflows/ci.yml | 8 +++++++- .github/workflows/release-audit.yml | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2f0bf006e..337922388 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,13 @@ name: Node CI -on: [push, pull_request] +on: + push: + branches-ignore: + - 'dependabot/**' + pull_request: + branches: + - '*' jobs: test: diff --git a/.github/workflows/release-audit.yml b/.github/workflows/release-audit.yml index 830909440..afc296ff0 100644 --- a/.github/workflows/release-audit.yml +++ b/.github/workflows/release-audit.yml @@ -17,7 +17,13 @@ name: Release Auditing -on: [push, pull_request] +on: + push: + branches-ignore: + - 'dependabot/**' + pull_request: + branches: + - '*' jobs: test: From dff2fc633121f995b6827a9d1a211c3c54d60c7d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Nov 2024 21:25:05 -0800 Subject: [PATCH 07/66] chore(deps): bump cross-spawn from 7.0.3 to 7.0.6 (#1748) Bumps [cross-spawn](https://github.com/moxystudio/node-cross-spawn) from 7.0.3 to 7.0.6. - [Changelog](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md) - [Commits](https://github.com/moxystudio/node-cross-spawn/compare/v7.0.3...v7.0.6) --- updated-dependencies: - dependency-name: cross-spawn dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index a51e4bb0d..640d59a1b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1461,9 +1461,9 @@ } }, "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", From 6f0efd3a0da9c4d74a83a76fcff24c4922b93691 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=A8=E3=83=AA=E3=82=B9?= Date: Tue, 28 Jan 2025 10:32:04 +0900 Subject: [PATCH 08/66] chore: bump 14.0.0-dev (#1762) --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 640d59a1b..31b57bf68 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "cordova-android", - "version": "13.0.1-dev", + "version": "14.0.0-dev", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "cordova-android", - "version": "13.0.1-dev", + "version": "14.0.0-dev", "license": "Apache-2.0", "dependencies": { "android-versions": "^2.0.0", diff --git a/package.json b/package.json index c9e7ad7c9..4d0fb3f54 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cordova-android", - "version": "13.0.1-dev", + "version": "14.0.0-dev", "description": "cordova-android release", "types": "./types/index.d.ts", "main": "lib/Api.js", From cee7b0b8acd4efd3a1a1ba5bfc38ea1d49d7d35e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=A8=E3=83=AA=E3=82=B9?= Date: Tue, 28 Jan 2025 10:32:49 +0900 Subject: [PATCH 09/66] feat!: SDK 35 Support (#1763) * feat(gradle)!: bump to 8.9 w/ AGP@8.7.3 * feat!: bump android sdk@35 & minimum-build-tool@35.0.0 --- framework/cdv-gradle-config-defaults.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/framework/cdv-gradle-config-defaults.json b/framework/cdv-gradle-config-defaults.json index 46e6513dd..20d2c01f3 100644 --- a/framework/cdv-gradle-config-defaults.json +++ b/framework/cdv-gradle-config-defaults.json @@ -1,10 +1,10 @@ { "MIN_SDK_VERSION": 24, - "SDK_VERSION": 34, + "SDK_VERSION": 35, "COMPILE_SDK_VERSION": null, - "GRADLE_VERSION": "8.7", - "MIN_BUILD_TOOLS_VERSION": "34.0.0", - "AGP_VERSION": "8.3.0", + "GRADLE_VERSION": "8.9", + "MIN_BUILD_TOOLS_VERSION": "35.0.0", + "AGP_VERSION": "8.7.3", "KOTLIN_VERSION": "1.9.24", "ANDROIDX_APP_COMPAT_VERSION": "1.6.1", "ANDROIDX_WEBKIT_VERSION": "1.6.0", From ea045dee63cdb35eb84affec114983bab12b91dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=A8=E3=83=AA=E3=82=B9?= Date: Tue, 28 Jan 2025 10:33:25 +0900 Subject: [PATCH 10/66] feat: androidx.appcompat:appcompat@1.7.0 (#1764) --- framework/cdv-gradle-config-defaults.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/cdv-gradle-config-defaults.json b/framework/cdv-gradle-config-defaults.json index 20d2c01f3..5cd99ea5d 100644 --- a/framework/cdv-gradle-config-defaults.json +++ b/framework/cdv-gradle-config-defaults.json @@ -6,7 +6,7 @@ "MIN_BUILD_TOOLS_VERSION": "35.0.0", "AGP_VERSION": "8.7.3", "KOTLIN_VERSION": "1.9.24", - "ANDROIDX_APP_COMPAT_VERSION": "1.6.1", + "ANDROIDX_APP_COMPAT_VERSION": "1.7.0", "ANDROIDX_WEBKIT_VERSION": "1.6.0", "ANDROIDX_CORE_SPLASHSCREEN_VERSION": "1.0.0", "GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION": "4.3.15", From 58c2e3ae158a4918067dbf993fef38ebce0cec1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=A8=E3=83=AA=E3=82=B9?= Date: Tue, 28 Jan 2025 10:54:19 +0900 Subject: [PATCH 11/66] feat: androidx.webkit:webkit@1.12.1 (#1765) --- framework/cdv-gradle-config-defaults.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/cdv-gradle-config-defaults.json b/framework/cdv-gradle-config-defaults.json index 5cd99ea5d..2a5719648 100644 --- a/framework/cdv-gradle-config-defaults.json +++ b/framework/cdv-gradle-config-defaults.json @@ -7,7 +7,7 @@ "AGP_VERSION": "8.7.3", "KOTLIN_VERSION": "1.9.24", "ANDROIDX_APP_COMPAT_VERSION": "1.7.0", - "ANDROIDX_WEBKIT_VERSION": "1.6.0", + "ANDROIDX_WEBKIT_VERSION": "1.12.1", "ANDROIDX_CORE_SPLASHSCREEN_VERSION": "1.0.0", "GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION": "4.3.15", "IS_GRADLE_PLUGIN_GOOGLE_SERVICES_ENABLED": false, From 1fe44d71c5e96842f1f567cda1e8a4b1eddcda0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=A8=E3=83=AA=E3=82=B9?= Date: Tue, 28 Jan 2025 11:14:07 +0900 Subject: [PATCH 12/66] feat: com.google.gms:google-services@4.4.2 (#1766) --- framework/cdv-gradle-config-defaults.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/cdv-gradle-config-defaults.json b/framework/cdv-gradle-config-defaults.json index 2a5719648..2716a1591 100644 --- a/framework/cdv-gradle-config-defaults.json +++ b/framework/cdv-gradle-config-defaults.json @@ -9,7 +9,7 @@ "ANDROIDX_APP_COMPAT_VERSION": "1.7.0", "ANDROIDX_WEBKIT_VERSION": "1.12.1", "ANDROIDX_CORE_SPLASHSCREEN_VERSION": "1.0.0", - "GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION": "4.3.15", + "GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION": "4.4.2", "IS_GRADLE_PLUGIN_GOOGLE_SERVICES_ENABLED": false, "IS_GRADLE_PLUGIN_KOTLIN_ENABLED": false, "PACKAGE_NAMESPACE": "io.cordova.helloCordova", From 34220ae0e3bc1c06b9c999bcb42fb58cf2591c09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=A8=E3=83=AA=E3=82=B9?= Date: Tue, 28 Jan 2025 11:57:42 +0900 Subject: [PATCH 13/66] feat: androidx.core:core-splashscreen@1.0.1 (#1768) --- framework/cdv-gradle-config-defaults.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/cdv-gradle-config-defaults.json b/framework/cdv-gradle-config-defaults.json index 2716a1591..5340cdc0e 100644 --- a/framework/cdv-gradle-config-defaults.json +++ b/framework/cdv-gradle-config-defaults.json @@ -8,7 +8,7 @@ "KOTLIN_VERSION": "1.9.24", "ANDROIDX_APP_COMPAT_VERSION": "1.7.0", "ANDROIDX_WEBKIT_VERSION": "1.12.1", - "ANDROIDX_CORE_SPLASHSCREEN_VERSION": "1.0.0", + "ANDROIDX_CORE_SPLASHSCREEN_VERSION": "1.0.1", "GRADLE_PLUGIN_GOOGLE_SERVICES_VERSION": "4.4.2", "IS_GRADLE_PLUGIN_GOOGLE_SERVICES_ENABLED": false, "IS_GRADLE_PLUGIN_KOTLIN_ENABLED": false, From 92116dee486dfa60f5ab47889c037cc5da4cab69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=A8=E3=83=AA=E3=82=B9?= Date: Tue, 28 Jan 2025 11:58:23 +0900 Subject: [PATCH 14/66] feat!: use kotlin-stdlib instead of kotlin-stdlib-jdk* (#1767) --- templates/project/app/build.gradle | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/templates/project/app/build.gradle b/templates/project/app/build.gradle index 19f97c21f..5ff337f1c 100644 --- a/templates/project/app/build.gradle +++ b/templates/project/app/build.gradle @@ -331,7 +331,16 @@ dependencies { implementation "androidx.core:core-splashscreen:${cordovaConfig.ANDROIDX_CORE_SPLASHSCREEN_VERSION}" if (cordovaConfig.IS_GRADLE_PLUGIN_KOTLIN_ENABLED) { - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${cordovaConfig.KOTLIN_VERSION}" + implementation "org.jetbrains.kotlin:kotlin-stdlib:${cordovaConfig.KOTLIN_VERSION}" + } + + constraints { + implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:${cordovaConfig.KOTLIN_VERSION}") { + because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib") + } + implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${cordovaConfig.KOTLIN_VERSION}") { + because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib") + } } // SUB-PROJECT DEPENDENCIES START From 9f5518000fbdbffe87003f8a3f69fd95102e5f07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=A8=E3=83=AA=E3=82=B9?= Date: Tue, 28 Jan 2025 12:13:36 +0900 Subject: [PATCH 15/66] refactor: prefix node:* (#1769) * refactor: prefix node:* to path * refactor: prefix node:* to os * refactor: prefix node:* to fs * refactor: prefix node:* to util --- lib/Adb.js | 2 +- lib/AndroidManifest.js | 2 +- lib/AndroidProject.js | 4 ++-- lib/Api.js | 2 +- lib/build.js | 4 ++-- lib/builders/ProjectBuilder.js | 2 +- lib/check_reqs.js | 2 +- lib/config/CordovaGradleConfigParser.js | 2 +- lib/config/GradlePropertiesParser.js | 4 ++-- lib/create.js | 2 +- lib/emulator.js | 2 +- lib/env/java.js | 2 +- lib/pluginHandlers.js | 2 +- lib/prepare.js | 2 +- lib/target.js | 2 +- lib/utils.js | 2 +- spec/e2e/e2e.spec.js | 4 ++-- spec/unit/AndroidManifest.spec.js | 6 +++--- spec/unit/AndroidProject.spec.js | 2 +- spec/unit/Api.spec.js | 4 ++-- spec/unit/android_sdk.spec.js | 4 ++-- spec/unit/builders/ProjectBuilder.spec.js | 2 +- spec/unit/check_reqs.spec.js | 2 +- spec/unit/create.spec.js | 2 +- spec/unit/emulator.spec.js | 2 +- spec/unit/java.spec.js | 2 +- spec/unit/pluginHandlers/common.spec.js | 4 ++-- spec/unit/pluginHandlers/handlers.spec.js | 4 ++-- spec/unit/prepare.spec.js | 2 +- test/run_java_unit_tests.js | 2 +- 30 files changed, 40 insertions(+), 40 deletions(-) diff --git a/lib/Adb.js b/lib/Adb.js index 2d0b2837a..897ef5cb7 100644 --- a/lib/Adb.js +++ b/lib/Adb.js @@ -17,7 +17,7 @@ under the License. */ -const os = require('os'); +const os = require('node:os'); const execa = require('execa'); const events = require('cordova-common').events; const CordovaError = require('cordova-common').CordovaError; diff --git a/lib/AndroidManifest.js b/lib/AndroidManifest.js index f8ab241cb..2006d6ee4 100644 --- a/lib/AndroidManifest.js +++ b/lib/AndroidManifest.js @@ -17,7 +17,7 @@ under the License. */ -const fs = require('fs'); +const fs = require('node:fs'); const xml = require('cordova-common').xmlHelpers; const DEFAULT_ORIENTATION = 'default'; diff --git a/lib/AndroidProject.js b/lib/AndroidProject.js index d0b0ad091..85f8ee535 100644 --- a/lib/AndroidProject.js +++ b/lib/AndroidProject.js @@ -17,8 +17,8 @@ under the License. */ -const fs = require('fs'); -const path = require('path'); +const fs = require('node:fs'); +const path = require('node:path'); const properties_parser = require('properties-parser'); const pluginHandlers = require('./pluginHandlers'); const CordovaGradleConfigParserFactory = require('./config/CordovaGradleConfigParserFactory'); diff --git a/lib/Api.js b/lib/Api.js index 4a99fe8f0..03527268c 100644 --- a/lib/Api.js +++ b/lib/Api.js @@ -17,7 +17,7 @@ under the License. */ -const path = require('path'); +const path = require('node:path'); const AndroidProject = require('./AndroidProject'); const PluginManager = require('cordova-common').PluginManager; diff --git a/lib/build.js b/lib/build.js index 7e42f280e..a0674f5b7 100644 --- a/lib/build.js +++ b/lib/build.js @@ -17,8 +17,8 @@ under the License. */ -const path = require('path'); -const fs = require('fs'); +const path = require('node:path'); +const fs = require('node:fs'); const nopt = require('nopt'); const untildify = require('untildify'); const { parseArgsStringToArgv } = require('string-argv'); diff --git a/lib/builders/ProjectBuilder.js b/lib/builders/ProjectBuilder.js index 024a02219..8cdc97e28 100644 --- a/lib/builders/ProjectBuilder.js +++ b/lib/builders/ProjectBuilder.js @@ -18,7 +18,7 @@ */ const fs = require('fs-extra'); -const path = require('path'); +const path = require('node:path'); const execa = require('execa'); const glob = require('fast-glob'); const events = require('cordova-common').events; diff --git a/lib/check_reqs.js b/lib/check_reqs.js index 29159a852..63ebe881d 100644 --- a/lib/check_reqs.js +++ b/lib/check_reqs.js @@ -18,7 +18,7 @@ */ const execa = require('execa'); -const path = require('path'); +const path = require('node:path'); const fs = require('fs-extra'); const { forgivingWhichSync, isWindows, isDarwin } = require('./utils'); const java = require('./env/java'); diff --git a/lib/config/CordovaGradleConfigParser.js b/lib/config/CordovaGradleConfigParser.js index f6f5d18ec..15b5e7550 100644 --- a/lib/config/CordovaGradleConfigParser.js +++ b/lib/config/CordovaGradleConfigParser.js @@ -18,7 +18,7 @@ */ const fs = require('fs-extra'); -const path = require('path'); +const path = require('node:path'); const events = require('cordova-common').events; class CordovaGradleConfigParser { diff --git a/lib/config/GradlePropertiesParser.js b/lib/config/GradlePropertiesParser.js index 9189a91b4..d4447b015 100644 --- a/lib/config/GradlePropertiesParser.js +++ b/lib/config/GradlePropertiesParser.js @@ -17,8 +17,8 @@ under the License. */ -const fs = require('fs'); -const path = require('path'); +const fs = require('node:fs'); +const path = require('node:path'); const propertiesParser = require('properties-parser'); const events = require('cordova-common').events; diff --git a/lib/create.js b/lib/create.js index 303ced12d..9c6155f75 100755 --- a/lib/create.js +++ b/lib/create.js @@ -17,7 +17,7 @@ under the License. */ -const path = require('path'); +const path = require('node:path'); const fs = require('fs-extra'); const utils = require('./utils'); const check_reqs = require('./check_reqs'); diff --git a/lib/emulator.js b/lib/emulator.js index c67e325d3..774601281 100644 --- a/lib/emulator.js +++ b/lib/emulator.js @@ -20,7 +20,7 @@ const execa = require('execa'); const fs = require('fs-extra'); const android_versions = require('android-versions'); -const path = require('path'); +const path = require('node:path'); const Adb = require('./Adb'); const events = require('cordova-common').events; const CordovaError = require('cordova-common').CordovaError; diff --git a/lib/env/java.js b/lib/env/java.js index 4c0f86ec9..f5f3c4347 100644 --- a/lib/env/java.js +++ b/lib/env/java.js @@ -19,7 +19,7 @@ const execa = require('execa'); const fs = require('fs-extra'); -const path = require('path'); +const path = require('node:path'); const glob = require('fast-glob'); const { CordovaError, events } = require('cordova-common'); const utils = require('../utils'); diff --git a/lib/pluginHandlers.js b/lib/pluginHandlers.js index 694088d1c..2a031d6e8 100644 --- a/lib/pluginHandlers.js +++ b/lib/pluginHandlers.js @@ -15,7 +15,7 @@ */ const fs = require('fs-extra'); -const path = require('path'); +const path = require('node:path'); const isPathInside = require('is-path-inside'); const events = require('cordova-common').events; const CordovaError = require('cordova-common').CordovaError; diff --git a/lib/prepare.js b/lib/prepare.js index 284904c42..22920b0c3 100644 --- a/lib/prepare.js +++ b/lib/prepare.js @@ -18,7 +18,7 @@ */ const fs = require('fs-extra'); -const path = require('path'); +const path = require('node:path'); const nopt = require('nopt'); const glob = require('fast-glob'); const dedent = require('dedent'); diff --git a/lib/target.js b/lib/target.js index 69066db90..fcdc79fc0 100644 --- a/lib/target.js +++ b/lib/target.js @@ -17,7 +17,7 @@ under the License. */ -const { inspect } = require('util'); +const { inspect } = require('node:util'); const execa = require('execa'); const Adb = require('./Adb'); const build = require('./build'); diff --git a/lib/utils.js b/lib/utils.js index 28f17d923..30398a2f5 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -25,7 +25,7 @@ const fs = require('fs-extra'); const which = require('which'); -const os = require('os'); +const os = require('node:os'); /** * Reads, searches, and replaces the found occurences with replacementString and then writes the file back out. diff --git a/spec/e2e/e2e.spec.js b/spec/e2e/e2e.spec.js index 8136c943d..df0ffa8b9 100644 --- a/spec/e2e/e2e.spec.js +++ b/spec/e2e/e2e.spec.js @@ -17,9 +17,9 @@ under the License. */ -const os = require('os'); +const os = require('node:os'); const fs = require('fs-extra'); -const path = require('path'); +const path = require('node:path'); const { EventEmitter } = require('events'); const { ConfigParser, PluginInfoProvider } = require('cordova-common'); const Api = require('../../lib/Api'); diff --git a/spec/unit/AndroidManifest.spec.js b/spec/unit/AndroidManifest.spec.js index e156efdc8..8c511b8f6 100644 --- a/spec/unit/AndroidManifest.spec.js +++ b/spec/unit/AndroidManifest.spec.js @@ -17,9 +17,9 @@ under the License. */ -const fs = require('fs'); -const os = require('os'); -const path = require('path'); +const fs = require('node:fs'); +const os = require('node:os'); +const path = require('node:path'); const rewire = require('rewire'); describe('AndroidManifest', () => { diff --git a/spec/unit/AndroidProject.spec.js b/spec/unit/AndroidProject.spec.js index 79d57f2fa..c865630db 100644 --- a/spec/unit/AndroidProject.spec.js +++ b/spec/unit/AndroidProject.spec.js @@ -17,7 +17,7 @@ under the License. */ -const path = require('path'); +const path = require('node:path'); const rewire = require('rewire'); const MockCordovaGradleConfigParser = require('./mocks/config/MockCordovaGradleConfigParser'); const CordovaGradleConfigParserFactory = require('../../lib/config/CordovaGradleConfigParserFactory'); diff --git a/spec/unit/Api.spec.js b/spec/unit/Api.spec.js index ca3754f5d..ca8b5be44 100644 --- a/spec/unit/Api.spec.js +++ b/spec/unit/Api.spec.js @@ -17,8 +17,8 @@ under the License. */ -const os = require('os'); -const path = require('path'); +const os = require('node:os'); +const path = require('node:path'); const common = require('cordova-common'); const EventEmitter = require('events'); diff --git a/spec/unit/android_sdk.spec.js b/spec/unit/android_sdk.spec.js index 67c0cbf89..4e12be15c 100644 --- a/spec/unit/android_sdk.spec.js +++ b/spec/unit/android_sdk.spec.js @@ -17,8 +17,8 @@ under the License. */ -const fs = require('fs'); -const path = require('path'); +const fs = require('node:fs'); +const path = require('node:path'); const rewire = require('rewire'); describe('android_sdk', () => { diff --git a/spec/unit/builders/ProjectBuilder.spec.js b/spec/unit/builders/ProjectBuilder.spec.js index 388beab5d..a96df2319 100644 --- a/spec/unit/builders/ProjectBuilder.spec.js +++ b/spec/unit/builders/ProjectBuilder.spec.js @@ -18,7 +18,7 @@ */ const fs = require('fs-extra'); -const path = require('path'); +const path = require('node:path'); const rewire = require('rewire'); const { isWindows } = require('../../../lib/utils'); diff --git a/spec/unit/check_reqs.spec.js b/spec/unit/check_reqs.spec.js index d5c1d4090..12cb6903b 100644 --- a/spec/unit/check_reqs.spec.js +++ b/spec/unit/check_reqs.spec.js @@ -20,7 +20,7 @@ const rewire = require('rewire'); const android_sdk = require('../../lib/android_sdk'); const fs = require('fs-extra'); -const path = require('path'); +const path = require('node:path'); const events = require('cordova-common').events; const which = require('which'); diff --git a/spec/unit/create.spec.js b/spec/unit/create.spec.js index 8c9c4304b..15e32b657 100644 --- a/spec/unit/create.spec.js +++ b/spec/unit/create.spec.js @@ -22,7 +22,7 @@ const utils = require('../../lib/utils'); const create = rewire('../../lib/create'); const check_reqs = require('../../lib/check_reqs'); const fs = require('fs-extra'); -const path = require('path'); +const path = require('node:path'); const MockCordovaGradleConfigParser = require('./mocks/config/MockCordovaGradleConfigParser'); const CordovaGradleConfigParserFactory = require('../../lib/config/CordovaGradleConfigParserFactory'); diff --git a/spec/unit/emulator.spec.js b/spec/unit/emulator.spec.js index 43815040e..426e559c5 100644 --- a/spec/unit/emulator.spec.js +++ b/spec/unit/emulator.spec.js @@ -18,7 +18,7 @@ */ const fs = require('fs-extra'); -const path = require('path'); +const path = require('node:path'); const rewire = require('rewire'); const which = require('which'); diff --git a/spec/unit/java.spec.js b/spec/unit/java.spec.js index 74680090a..04c57cd0a 100644 --- a/spec/unit/java.spec.js +++ b/spec/unit/java.spec.js @@ -17,7 +17,7 @@ under the License. */ -const path = require('path'); +const path = require('node:path'); const rewire = require('rewire'); const { CordovaError } = require('cordova-common'); const utils = require('../../lib/utils'); diff --git a/spec/unit/pluginHandlers/common.spec.js b/spec/unit/pluginHandlers/common.spec.js index d9938a172..90001fdcd 100644 --- a/spec/unit/pluginHandlers/common.spec.js +++ b/spec/unit/pluginHandlers/common.spec.js @@ -18,9 +18,9 @@ const rewire = require('rewire'); const common = rewire('../../../lib/pluginHandlers'); -const path = require('path'); +const path = require('node:path'); const fs = require('fs-extra'); -const osenv = require('os'); +const osenv = require('node:os'); const test_dir = path.join(osenv.tmpdir(), 'test_plugman'); const project_dir = path.join(test_dir, 'project'); diff --git a/spec/unit/pluginHandlers/handlers.spec.js b/spec/unit/pluginHandlers/handlers.spec.js index 33e8b2667..cefb269a8 100644 --- a/spec/unit/pluginHandlers/handlers.spec.js +++ b/spec/unit/pluginHandlers/handlers.spec.js @@ -20,9 +20,9 @@ const rewire = require('rewire'); const common = rewire('../../../lib/pluginHandlers'); const android = common.__get__('handlers'); -const path = require('path'); +const path = require('node:path'); const fs = require('fs-extra'); -const os = require('os'); +const os = require('node:os'); const temp = path.join(os.tmpdir(), 'plugman'); const plugins_dir = path.join(temp, 'cordova/plugins'); const dummyplugin = path.join(__dirname, '../../fixtures/org.test.plugins.dummyplugin'); diff --git a/spec/unit/prepare.spec.js b/spec/unit/prepare.spec.js index bdc65b4f7..eb9005738 100644 --- a/spec/unit/prepare.spec.js +++ b/spec/unit/prepare.spec.js @@ -18,7 +18,7 @@ */ const rewire = require('rewire'); -const path = require('path'); +const path = require('node:path'); const CordovaError = require('cordova-common').CordovaError; const GradlePropertiesParser = require('../../lib/config/GradlePropertiesParser'); const utils = require('../../lib/utils'); diff --git a/test/run_java_unit_tests.js b/test/run_java_unit_tests.js index 816ab6b02..5d48ea928 100644 --- a/test/run_java_unit_tests.js +++ b/test/run_java_unit_tests.js @@ -19,7 +19,7 @@ under the License. */ -const path = require('path'); +const path = require('node:path'); const execa = require('execa'); const fs = require('fs-extra'); const ProjectBuilder = require('../lib/builders/ProjectBuilder'); From 1f349f2984084e84c1f8bb475fd5da3e1d757dbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=A8=E3=83=AA=E3=82=B9?= Date: Tue, 28 Jan 2025 12:15:19 +0900 Subject: [PATCH 16/66] fix: creation of cdv-gradle-config.json w/ --link flag (#1770) --- lib/create.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/create.js b/lib/create.js index 9c6155f75..bf77b047d 100755 --- a/lib/create.js +++ b/lib/create.js @@ -55,6 +55,7 @@ function copyJsAndLibrary (projectPath, shared, projectName, targetAPI) { // The www dir is nuked on each prepare so we keep cordova.js in platform_www fs.ensureDirSync(platform_www); fs.copySync(srcCordovaJsPath, path.join(platform_www, 'cordova.js')); + fs.copySync(path.join(ROOT, 'framework', 'cdv-gradle-config-defaults.json'), path.join(projectPath, 'cdv-gradle-config.json')); if (shared) { const relativeFrameworkPath = path.relative(projectPath, getFrameworkDir(projectPath, true)); @@ -69,7 +70,6 @@ function copyJsAndLibrary (projectPath, shared, projectName, targetAPI) { fs.copySync(path.join(ROOT, 'framework', 'cordova.gradle'), path.join(nestedCordovaLibPath, 'cordova.gradle')); fs.copySync(path.join(ROOT, 'framework', 'repositories.gradle'), path.join(nestedCordovaLibPath, 'repositories.gradle')); fs.copySync(path.join(ROOT, 'framework', 'src'), path.join(nestedCordovaLibPath, 'src')); - fs.copySync(path.join(ROOT, 'framework', 'cdv-gradle-config-defaults.json'), path.join(projectPath, 'cdv-gradle-config.json')); } } From b623311efa2a809bff9dbf96897fcef097dc2d71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=A8=E3=83=AA=E3=82=B9?= Date: Tue, 28 Jan 2025 12:28:32 +0900 Subject: [PATCH 17/66] feat!: deprecate CordovaPlugin's method initialize (#1771) --- framework/src/org/apache/cordova/CordovaPlugin.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/framework/src/org/apache/cordova/CordovaPlugin.java b/framework/src/org/apache/cordova/CordovaPlugin.java index 1140c4aff..8adeb7a14 100644 --- a/framework/src/org/apache/cordova/CordovaPlugin.java +++ b/framework/src/org/apache/cordova/CordovaPlugin.java @@ -64,7 +64,11 @@ public final void privateInitialize(String serviceName, CordovaInterface cordova * Called after plugin construction and fields have been initialized. * Prefer to use pluginInitialize instead since there is no value in * having parameters on the initialize() function. + * + * @deprecated Use {@link #pluginInitialize()} instead. This method is no longer recommended + * and will be removed in future versions. */ + @Deprecated public void initialize(CordovaInterface cordova, CordovaWebView webView) { } @@ -416,7 +420,7 @@ public boolean hasPermisssion() { * @param requestCode * @param permissions * @param grantResults - * + * * @deprecated Use {@link #onRequestPermissionsResult} instead. */ @Deprecated From e0124785376cdc6c7ad4fc25f61b249aefaf8459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=A8=E3=83=AA=E3=82=B9?= Date: Wed, 29 Jan 2025 10:39:11 +0900 Subject: [PATCH 18/66] refactor: replace fs-extra with node:fs (#1772) * spec: add devDependencies "tmp" --- lib/builders/ProjectBuilder.js | 14 ++--- lib/check_reqs.js | 2 +- lib/config/CordovaGradleConfigParser.js | 6 +- lib/create.js | 56 +++++++++--------- lib/emulator.js | 2 +- lib/env/java.js | 2 +- lib/pluginHandlers.js | 16 +++--- lib/prepare.js | 18 +++--- lib/utils.js | 2 +- package-lock.json | 14 ++++- package.json | 4 +- spec/e2e/e2e.spec.js | 11 ++-- spec/unit/builders/ProjectBuilder.spec.js | 14 ++--- spec/unit/check_reqs.spec.js | 2 +- spec/unit/create.spec.js | 22 +++---- spec/unit/emulator.spec.js | 2 +- spec/unit/pluginHandlers/common.spec.js | 60 +++++++++++-------- spec/unit/pluginHandlers/handlers.spec.js | 70 +++++++++++------------ spec/unit/prepare.spec.js | 31 +++++----- test/run_java_unit_tests.js | 4 +- 20 files changed, 188 insertions(+), 164 deletions(-) diff --git a/lib/builders/ProjectBuilder.js b/lib/builders/ProjectBuilder.js index 8cdc97e28..2cd5d323a 100644 --- a/lib/builders/ProjectBuilder.js +++ b/lib/builders/ProjectBuilder.js @@ -17,7 +17,7 @@ under the License. */ -const fs = require('fs-extra'); +const fs = require('node:fs'); const path = require('node:path'); const execa = require('execa'); const glob = require('fast-glob'); @@ -174,7 +174,7 @@ class ProjectBuilder { try { fs.accessSync(subProjectGradle, fs.F_OK); } catch (e) { - fs.copySync(pluginBuildGradle, subProjectGradle); + fs.cpSync(pluginBuildGradle, subProjectGradle); } }; @@ -207,7 +207,7 @@ class ProjectBuilder { settingsGradlePaths.join('')); // Touch empty cdv-gradle-name.gradle file if missing. - if (!fs.pathExistsSync(path.join(this.root, 'cdv-gradle-name.gradle'))) { + if (!fs.existsSync(path.join(this.root, 'cdv-gradle-name.gradle'))) { fs.writeFileSync(path.join(this.root, 'cdv-gradle-name.gradle'), ''); } @@ -294,7 +294,7 @@ class ProjectBuilder { }).then(() => { const signingPropertiesPath = path.join(self.root, `${opts.buildType}${SIGNING_PROPERTIES}`); - if (fs.existsSync(signingPropertiesPath)) fs.removeSync(signingPropertiesPath); + if (fs.existsSync(signingPropertiesPath)) fs.rmSync(signingPropertiesPath); if (opts.packageInfo) { fs.ensureFileSync(signingPropertiesPath); const signingProperties = createEditor(signingPropertiesPath); @@ -309,7 +309,7 @@ class ProjectBuilder { * @returns The user defined configs */ _getCordovaConfig () { - return fs.readJSONSync(path.join(this.root, 'cdv-gradle-config.json')); + return JSON.parse(fs.readFileSync(path.join(this.root, 'cdv-gradle-config.json'), 'utf-8') || '{}'); } /* @@ -342,7 +342,7 @@ class ProjectBuilder { const args = this.getArgs('clean', opts); return execa(wrapper, args, { stdio: 'inherit', cwd: path.resolve(this.root) }) .then(() => { - fs.removeSync(path.join(this.root, 'out')); + fs.rmSync(path.join(this.root, 'out'), { recursive: true, force: true }); ['debug', 'release'].map(config => path.join(this.root, `${config}${SIGNING_PROPERTIES}`)) .forEach(file => { @@ -350,7 +350,7 @@ class ProjectBuilder { const hasMarker = hasFile && fs.readFileSync(file, 'utf8') .includes(MARKER); - if (hasFile && hasMarker) fs.removeSync(file); + if (hasFile && hasMarker) fs.rmSync(file); }); }); } diff --git a/lib/check_reqs.js b/lib/check_reqs.js index 63ebe881d..903f3e4c0 100644 --- a/lib/check_reqs.js +++ b/lib/check_reqs.js @@ -19,7 +19,7 @@ const execa = require('execa'); const path = require('node:path'); -const fs = require('fs-extra'); +const fs = require('node:fs'); const { forgivingWhichSync, isWindows, isDarwin } = require('./utils'); const java = require('./env/java'); const { CordovaError, ConfigParser, events } = require('cordova-common'); diff --git a/lib/config/CordovaGradleConfigParser.js b/lib/config/CordovaGradleConfigParser.js index 15b5e7550..2334629bc 100644 --- a/lib/config/CordovaGradleConfigParser.js +++ b/lib/config/CordovaGradleConfigParser.js @@ -17,7 +17,7 @@ under the License. */ -const fs = require('fs-extra'); +const fs = require('node:fs'); const path = require('node:path'); const events = require('cordova-common').events; @@ -41,7 +41,7 @@ class CordovaGradleConfigParser { * @returns {Record} The parsed JSON object representing the gradle config. */ _readConfig (configPath) { - return fs.readJSONSync(configPath, 'utf-8'); + return JSON.parse(fs.readFileSync(configPath, 'utf-8') || '{}'); } setPackageName (packageName) { @@ -64,7 +64,7 @@ class CordovaGradleConfigParser { */ write () { events.emit('verbose', '[Cordova Gradle Config] Saving File'); - fs.writeJSONSync(this._cdvGradleConfigFilePath, this._cdvGradleConfig, 'utf-8'); + fs.writeFileSync(this._cdvGradleConfigFilePath, JSON.stringify(this._cdvGradleConfig, null, 2), 'utf-8'); } } diff --git a/lib/create.js b/lib/create.js index bf77b047d..5bb5314ec 100755 --- a/lib/create.js +++ b/lib/create.js @@ -18,7 +18,7 @@ */ const path = require('node:path'); -const fs = require('fs-extra'); +const fs = require('node:fs'); const utils = require('./utils'); const check_reqs = require('./check_reqs'); const ROOT = path.join(__dirname, '..'); @@ -49,27 +49,27 @@ function copyJsAndLibrary (projectPath, shared, projectName, targetAPI) { const app_path = path.join(projectPath, 'app', 'src', 'main'); const platform_www = path.join(projectPath, 'platform_www'); - fs.copySync(srcCordovaJsPath, path.join(app_path, 'assets', 'www', 'cordova.js')); + fs.cpSync(srcCordovaJsPath, path.join(app_path, 'assets', 'www', 'cordova.js')); // Copy the cordova.js file to platforms//platform_www/ // The www dir is nuked on each prepare so we keep cordova.js in platform_www - fs.ensureDirSync(platform_www); - fs.copySync(srcCordovaJsPath, path.join(platform_www, 'cordova.js')); - fs.copySync(path.join(ROOT, 'framework', 'cdv-gradle-config-defaults.json'), path.join(projectPath, 'cdv-gradle-config.json')); + fs.mkdirSync(platform_www, { recursive: true }); + fs.cpSync(srcCordovaJsPath, path.join(platform_www, 'cordova.js')); + fs.cpSync(path.join(ROOT, 'framework', 'cdv-gradle-config-defaults.json'), path.join(projectPath, 'cdv-gradle-config.json')); if (shared) { const relativeFrameworkPath = path.relative(projectPath, getFrameworkDir(projectPath, true)); fs.symlinkSync(relativeFrameworkPath, nestedCordovaLibPath, 'dir'); } else { - fs.ensureDirSync(nestedCordovaLibPath); - fs.copySync(path.join(ROOT, 'framework', 'AndroidManifest.xml'), path.join(nestedCordovaLibPath, 'AndroidManifest.xml')); + fs.mkdirSync(nestedCordovaLibPath, { recursive: true }); + fs.cpSync(path.join(ROOT, 'framework', 'AndroidManifest.xml'), path.join(nestedCordovaLibPath, 'AndroidManifest.xml')); const propertiesEditor = createEditor(path.join(ROOT, 'framework', 'project.properties')); propertiesEditor.set('target', targetAPI); propertiesEditor.save(path.join(nestedCordovaLibPath, 'project.properties')); - fs.copySync(path.join(ROOT, 'framework', 'build.gradle'), path.join(nestedCordovaLibPath, 'build.gradle')); - fs.copySync(path.join(ROOT, 'framework', 'cordova.gradle'), path.join(nestedCordovaLibPath, 'cordova.gradle')); - fs.copySync(path.join(ROOT, 'framework', 'repositories.gradle'), path.join(nestedCordovaLibPath, 'repositories.gradle')); - fs.copySync(path.join(ROOT, 'framework', 'src'), path.join(nestedCordovaLibPath, 'src')); + fs.cpSync(path.join(ROOT, 'framework', 'build.gradle'), path.join(nestedCordovaLibPath, 'build.gradle')); + fs.cpSync(path.join(ROOT, 'framework', 'cordova.gradle'), path.join(nestedCordovaLibPath, 'cordova.gradle')); + fs.cpSync(path.join(ROOT, 'framework', 'repositories.gradle'), path.join(nestedCordovaLibPath, 'repositories.gradle')); + fs.cpSync(path.join(ROOT, 'framework', 'src'), path.join(nestedCordovaLibPath, 'src'), { recursive: true }); } } @@ -116,10 +116,10 @@ function prepBuildFiles (projectPath) { function copyBuildRules (projectPath) { const srcDir = path.join(ROOT, 'templates', 'project'); - fs.copySync(path.join(srcDir, 'build.gradle'), path.join(projectPath, 'build.gradle')); - fs.copySync(path.join(srcDir, 'app', 'build.gradle'), path.join(projectPath, 'app', 'build.gradle')); - fs.copySync(path.join(srcDir, 'app', 'repositories.gradle'), path.join(projectPath, 'app', 'repositories.gradle')); - fs.copySync(path.join(srcDir, 'repositories.gradle'), path.join(projectPath, 'repositories.gradle')); + fs.cpSync(path.join(srcDir, 'build.gradle'), path.join(projectPath, 'build.gradle')); + fs.cpSync(path.join(srcDir, 'app', 'build.gradle'), path.join(projectPath, 'app', 'build.gradle')); + fs.cpSync(path.join(srcDir, 'app', 'repositories.gradle'), path.join(projectPath, 'app', 'repositories.gradle')); + fs.cpSync(path.join(srcDir, 'repositories.gradle'), path.join(projectPath, 'repositories.gradle')); copyGradleTools(projectPath); } @@ -128,9 +128,9 @@ function copyScripts (projectPath) { const srcScriptsDir = path.join(ROOT, 'templates', 'cordova'); const destScriptsDir = path.join(projectPath, 'cordova'); // Delete old scripts directory if this is an update. - fs.removeSync(destScriptsDir); + fs.rmSync(destScriptsDir, { recursive: true, force: true }); // Copy in the new ones. - fs.copySync(srcScriptsDir, destScriptsDir); + fs.cpSync(srcScriptsDir, destScriptsDir, { recursive: true }); } /** @@ -174,7 +174,7 @@ function validateProjectName (project_name) { function copyGradleTools (projectPath) { const srcDir = path.join(ROOT, 'templates', 'project'); - fs.copySync(path.resolve(srcDir, 'tools'), path.resolve(projectPath, 'tools')); + fs.cpSync(path.resolve(srcDir, 'tools'), path.resolve(projectPath, 'tools'), { recursive: true }); } /** @@ -232,13 +232,13 @@ exports.create = function (project_path, config, options, events) { const app_path = path.join(project_path, 'app', 'src', 'main'); // copy project template - fs.ensureDirSync(app_path); - fs.copySync(path.join(project_template_dir, 'assets'), path.join(app_path, 'assets')); - fs.copySync(path.join(project_template_dir, 'res'), path.join(app_path, 'res')); - fs.copySync(path.join(project_template_dir, 'gitignore'), path.join(project_path, '.gitignore')); + fs.mkdirSync(app_path, { recursive: true }); + fs.cpSync(path.join(project_template_dir, 'assets'), path.join(app_path, 'assets'), { recursive: true }); + fs.cpSync(path.join(project_template_dir, 'res'), path.join(app_path, 'res'), { recursive: true }); + fs.cpSync(path.join(project_template_dir, 'gitignore'), path.join(project_path, '.gitignore')); // Manually create directories that would be empty within the template (since git doesn't track directories). - fs.ensureDirSync(path.join(app_path, 'libs')); + fs.mkdirSync(path.join(app_path, 'libs'), { recursive: true }); // copy cordova.js, cordova.jar exports.copyJsAndLibrary(project_path, options.link, safe_activity_name, target_api); @@ -247,9 +247,9 @@ exports.create = function (project_path, config, options, events) { const java_path = path.join(app_path, 'java'); const assets_path = path.join(app_path, 'assets'); const resource_path = path.join(app_path, 'res'); - fs.ensureDirSync(java_path); - fs.ensureDirSync(assets_path); - fs.ensureDirSync(resource_path); + fs.mkdirSync(java_path, { recursive: true }); + fs.mkdirSync(assets_path, { recursive: true }); + fs.mkdirSync(resource_path, { recursive: true }); // store package name in cdv-gradle-config const cdvGradleConfig = CordovaGradleConfigParserFactory.create(project_path); @@ -261,8 +261,8 @@ exports.create = function (project_path, config, options, events) { const activity_dir = path.join(java_path, packagePath); const activity_path = path.join(activity_dir, safe_activity_name + '.java'); - fs.ensureDirSync(activity_dir); - fs.copySync(path.join(project_template_dir, 'Activity.java'), activity_path); + fs.mkdirSync(activity_dir, { recursive: true }); + fs.cpSync(path.join(project_template_dir, 'Activity.java'), activity_path); utils.replaceFileContents(activity_path, /__ACTIVITY__/, safe_activity_name); utils.replaceFileContents(path.join(app_path, 'res', 'values', 'strings.xml'), /__NAME__/, utils.escape(project_name)); utils.replaceFileContents(activity_path, /__ID__/, package_name); diff --git a/lib/emulator.js b/lib/emulator.js index 774601281..6bab17a7c 100644 --- a/lib/emulator.js +++ b/lib/emulator.js @@ -18,7 +18,7 @@ */ const execa = require('execa'); -const fs = require('fs-extra'); +const fs = require('node:fs'); const android_versions = require('android-versions'); const path = require('node:path'); const Adb = require('./Adb'); diff --git a/lib/env/java.js b/lib/env/java.js index f5f3c4347..a65030e20 100644 --- a/lib/env/java.js +++ b/lib/env/java.js @@ -18,7 +18,7 @@ */ const execa = require('execa'); -const fs = require('fs-extra'); +const fs = require('node:fs'); const path = require('node:path'); const glob = require('fast-glob'); const { CordovaError, events } = require('cordova-common'); diff --git a/lib/pluginHandlers.js b/lib/pluginHandlers.js index 2a031d6e8..385d99324 100644 --- a/lib/pluginHandlers.js +++ b/lib/pluginHandlers.js @@ -14,7 +14,7 @@ * */ -const fs = require('fs-extra'); +const fs = require('node:fs'); const path = require('node:path'); const isPathInside = require('is-path-inside'); const events = require('cordova-common').events; @@ -166,13 +166,13 @@ const handlers = { scriptContent = 'cordova.define("' + moduleName + '", function(require, exports, module) {\n' + scriptContent + '\n});\n'; const wwwDest = path.resolve(project.www, 'plugins', plugin.id, obj.src); - fs.ensureDirSync(path.dirname(wwwDest)); + fs.mkdirSync(path.dirname(wwwDest), { recursive: true }); fs.writeFileSync(wwwDest, scriptContent, 'utf-8'); if (options && options.usePlatformWww) { // CB-11022 copy file to both directories if usePlatformWww is specified const platformWwwDest = path.resolve(project.platformWww, 'plugins', plugin.id, obj.src); - fs.ensureDirSync(path.dirname(platformWwwDest)); + fs.mkdirSync(path.dirname(platformWwwDest), { recursive: true }); fs.writeFileSync(platformWwwDest, scriptContent, 'utf-8'); } }, @@ -217,11 +217,11 @@ function copyFile (plugin_dir, src, project_dir, dest, link) { // check that dest path is located in project directory if (!isPathInside(dest, project_dir)) { throw new CordovaError('Destination "' + dest + '" for source file "' + src + '" is located outside the project'); } - fs.ensureDirSync(path.dirname(dest)); + fs.mkdirSync(path.dirname(dest), { recursive: true }); if (link) { symlinkFileOrDirTree(src, dest); } else { - fs.copySync(src, dest); + fs.cpSync(src, dest, { recursive: true }); } } @@ -235,11 +235,11 @@ function copyNewFile (plugin_dir, src, project_dir, dest, link) { function symlinkFileOrDirTree (src, dest) { if (fs.existsSync(dest)) { - fs.removeSync(dest); + fs.rmSync(dest, { recursive: true, force: true }); } if (fs.statSync(src).isDirectory()) { - fs.ensureDirSync(path.dirname(dest)); + fs.mkdirSync(path.dirname(dest), { recursive: true }); fs.readdirSync(src).forEach(function (entry) { symlinkFileOrDirTree(path.join(src, entry), path.join(dest, entry)); }); @@ -249,7 +249,7 @@ function symlinkFileOrDirTree (src, dest) { } function removeFile (file) { - fs.removeSync(file); + fs.rmSync(file); } // Sometimes we want to remove some java, and prune any unnecessary empty directories diff --git a/lib/prepare.js b/lib/prepare.js index 22920b0c3..5206e5089 100644 --- a/lib/prepare.js +++ b/lib/prepare.js @@ -17,7 +17,7 @@ under the License. */ -const fs = require('fs-extra'); +const fs = require('node:fs'); const path = require('node:path'); const nopt = require('nopt'); const glob = require('fast-glob'); @@ -93,7 +93,7 @@ function updateUserProjectGradleConfig (project) { // Write out changes const projectGradleConfigPath = path.join(project.root, 'cdv-gradle-config.json'); - fs.writeJSONSync(projectGradleConfigPath, projectGradleConfig, { spaces: 2 }); + fs.writeFileSync(projectGradleConfigPath, JSON.stringify(projectGradleConfig, null, 2), 'utf-8'); } function getUserGradleConfig (configXml) { @@ -198,7 +198,7 @@ function updateConfigFilesFrom (sourceConfig, configMunger, locations) { // First cleanup current config and merge project's one into own // Overwrite platform config.xml with defaults.xml. - fs.copySync(locations.defaultConfigXml, locations.configXml); + fs.cpSync(locations.defaultConfigXml, locations.configXml); // Then apply config changes from global munge to all config files // in project (including project's config) @@ -316,14 +316,14 @@ function updateProjectAccordingTo (platformConfig, locations) { const newDestFile = path.join(locations.root, 'app', 'src', 'main', 'java', androidPkgName.replace(/\./g, '/'), path.basename(destFile)); if (newDestFile.toLowerCase() !== destFile.toLowerCase()) { // If package was name changed we need to create new java with main activity in path matching new package name - fs.ensureDirSync(path.dirname(newDestFile)); + fs.mkdirSync(path.dirname(newDestFile), { recursive: true }); events.emit('verbose', `copy ${destFile} to ${newDestFile}`); - fs.copySync(destFile, newDestFile); + fs.cpSync(destFile, newDestFile); utils.replaceFileContents(newDestFile, /package [\w.]*;/, 'package ' + androidPkgName + ';'); events.emit('verbose', 'Wrote out Android package name "' + androidPkgName + '" to ' + newDestFile); // If package was name changed we need to remove old java with main activity events.emit('verbose', `remove ${destFile}`); - fs.removeSync(destFile); + fs.rmSync(destFile); // remove any empty directories let currentDir = path.dirname(destFile); const sourcesRoot = path.resolve(locations.root, 'src'); @@ -536,16 +536,16 @@ function updateProjectSplashScreenIconBackgroundColor (splashIconBackgroundColor function cleanupAndSetProjectSplashScreenImage (srcFile, destFilePath, possiblePreviousDestFilePath, cleanupOnly = false) { if (fs.existsSync(possiblePreviousDestFilePath)) { - fs.removeSync(possiblePreviousDestFilePath); + fs.rmSync(possiblePreviousDestFilePath); } if (cleanupOnly && fs.existsSync(destFilePath)) { // Also remove dest file path for cleanup even if previous was not use. - fs.removeSync(destFilePath); + fs.rmSync(destFilePath); } if (!cleanupOnly && srcFile && fs.existsSync(srcFile)) { - fs.copySync(srcFile, destFilePath); + fs.cpSync(srcFile, destFilePath); } } diff --git a/lib/utils.js b/lib/utils.js index 30398a2f5..d538e1b7d 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -23,7 +23,7 @@ // TODO: Perhaps this should live in cordova-common? -const fs = require('fs-extra'); +const fs = require('node:fs'); const which = require('which'); const os = require('node:os'); diff --git a/package-lock.json b/package-lock.json index 31b57bf68..54e57fff9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,6 @@ "dedent": "^1.5.3", "execa": "^5.1.1", "fast-glob": "^3.3.2", - "fs-extra": "^11.2.0", "is-path-inside": "^3.0.3", "nopt": "^7.2.1", "properties-parser": "^0.6.0", @@ -30,7 +29,8 @@ "jasmine": "^5.1.0", "jasmine-spec-reporter": "^7.0.0", "nyc": "^15.1.0", - "rewire": "^7.0.0" + "rewire": "^7.0.0", + "tmp": "^0.2.3" }, "engines": { "node": ">=16.13.0" @@ -4806,6 +4806,16 @@ "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", "dev": true }, + "node_modules/tmp": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.3.tgz", + "integrity": "sha512-nZD7m9iCPC5g0pYmcaxogYKggSfLsdxl8of3Q/oIbqCqLLIO9IAF0GWjX1z9NZRHPiXv8Wex4yDCaZsgEw0Y8w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.14" + } + }, "node_modules/to-fast-properties": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", diff --git a/package.json b/package.json index 4d0fb3f54..8c7b2bf55 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,6 @@ "dedent": "^1.5.3", "execa": "^5.1.1", "fast-glob": "^3.3.2", - "fs-extra": "^11.2.0", "is-path-inside": "^3.0.3", "nopt": "^7.2.1", "properties-parser": "^0.6.0", @@ -45,7 +44,8 @@ "jasmine": "^5.1.0", "jasmine-spec-reporter": "^7.0.0", "nyc": "^15.1.0", - "rewire": "^7.0.0" + "rewire": "^7.0.0", + "tmp": "^0.2.3" }, "engines": { "node": ">=16.13.0" diff --git a/spec/e2e/e2e.spec.js b/spec/e2e/e2e.spec.js index df0ffa8b9..5856f0e34 100644 --- a/spec/e2e/e2e.spec.js +++ b/spec/e2e/e2e.spec.js @@ -18,7 +18,7 @@ */ const os = require('node:os'); -const fs = require('fs-extra'); +const fs = require('node:fs'); const path = require('node:path'); const { EventEmitter } = require('events'); const { ConfigParser, PluginInfoProvider } = require('cordova-common'); @@ -49,14 +49,15 @@ describe('E2E', function () { api = await makeProject(projectPath); }); afterEach(() => { - fs.removeSync(tmpDir); + fs.rmSync(tmpDir, { recursive: true, force: true }); }); it('loads the API from a project directory', async () => { // Allow test project to find the `cordova-android` module - fs.ensureSymlinkSync( - path.join(__dirname, '../..'), - path.join(tmpDir, 'node_modules/cordova-android'), + fs.mkdirSync(path.join(tmpDir, 'node_modules'), { recursive: true }); + fs.symlinkSync( + path.join(__dirname, '..', '..'), + path.join(tmpDir, 'node_modules', 'cordova-android'), 'junction' ); diff --git a/spec/unit/builders/ProjectBuilder.spec.js b/spec/unit/builders/ProjectBuilder.spec.js index a96df2319..5ba213529 100644 --- a/spec/unit/builders/ProjectBuilder.spec.js +++ b/spec/unit/builders/ProjectBuilder.spec.js @@ -17,7 +17,7 @@ under the License. */ -const fs = require('fs-extra'); +const fs = require('node:fs'); const path = require('node:path'); const rewire = require('rewire'); const { isWindows } = require('../../../lib/utils'); @@ -220,7 +220,7 @@ describe('ProjectBuilder', () => { beforeEach(() => { const marker = ProjectBuilder.__get__('MARKER'); spyOn(fs, 'readFileSync').and.returnValue(`Some Header Here: ${marker}`); - spyOn(fs, 'removeSync'); + spyOn(fs, 'rmSync'); spyOn(builder, 'getArgs'); execaSpy.and.returnValue(Promise.resolve()); }); @@ -250,7 +250,7 @@ describe('ProjectBuilder', () => { it('should remove "out" folder', () => { return builder.clean({}).then(() => { - expect(fs.removeSync).toHaveBeenCalledWith(path.join(rootDir, 'out')); + expect(fs.rmSync).toHaveBeenCalledWith(path.join(rootDir, 'out'), { recursive: true, force: true }); }); }); @@ -261,8 +261,8 @@ describe('ProjectBuilder', () => { spyOn(fs, 'existsSync').and.returnValue(true); return builder.clean({}).then(() => { - expect(fs.removeSync).toHaveBeenCalledWith(debugSigningFile); - expect(fs.removeSync).toHaveBeenCalledWith(releaseSigningFile); + expect(fs.rmSync).toHaveBeenCalledWith(debugSigningFile); + expect(fs.rmSync).toHaveBeenCalledWith(releaseSigningFile); }); }); @@ -273,8 +273,8 @@ describe('ProjectBuilder', () => { spyOn(fs, 'existsSync').and.returnValue(false); return builder.clean({}).then(() => { - expect(fs.removeSync).not.toHaveBeenCalledWith(debugSigningFile); - expect(fs.removeSync).not.toHaveBeenCalledWith(releaseSigningFile); + expect(fs.rmSync).not.toHaveBeenCalledWith(debugSigningFile); + expect(fs.rmSync).not.toHaveBeenCalledWith(releaseSigningFile); }); }); }); diff --git a/spec/unit/check_reqs.spec.js b/spec/unit/check_reqs.spec.js index 12cb6903b..54df1cf70 100644 --- a/spec/unit/check_reqs.spec.js +++ b/spec/unit/check_reqs.spec.js @@ -19,7 +19,7 @@ const rewire = require('rewire'); const android_sdk = require('../../lib/android_sdk'); -const fs = require('fs-extra'); +const fs = require('node:fs'); const path = require('node:path'); const events = require('cordova-common').events; const which = require('which'); diff --git a/spec/unit/create.spec.js b/spec/unit/create.spec.js index 15e32b657..f6be97569 100644 --- a/spec/unit/create.spec.js +++ b/spec/unit/create.spec.js @@ -21,7 +21,7 @@ const rewire = require('rewire'); const utils = require('../../lib/utils'); const create = rewire('../../lib/create'); const check_reqs = require('../../lib/check_reqs'); -const fs = require('fs-extra'); +const fs = require('node:fs'); const path = require('node:path'); const MockCordovaGradleConfigParser = require('./mocks/config/MockCordovaGradleConfigParser'); const CordovaGradleConfigParserFactory = require('../../lib/config/CordovaGradleConfigParserFactory'); @@ -142,8 +142,8 @@ describe('create', function () { spyOn(create, 'prepBuildFiles'); revert_manifest_mock = create.__set__('AndroidManifest', Manifest_mock); spyOn(fs, 'existsSync').and.returnValue(false); - spyOn(fs, 'copySync'); - spyOn(fs, 'ensureDirSync'); + spyOn(fs, 'cpSync'); + spyOn(fs, 'mkdirSync'); spyOn(utils, 'replaceFileContents'); config_mock = jasmine.createSpyObj('ConfigParser mock instance', ['packageName', 'android_packageName', 'name', 'android_activityName']); events_mock = jasmine.createSpyObj('EventEmitter mock instance', ['emit']); @@ -238,17 +238,17 @@ describe('create', function () { describe('happy path', function () { it('should copy project templates from a specified custom template', () => { return create.create(project_path, config_mock, { customTemplate: '/template/path' }, events_mock).then(() => { - expect(fs.copySync).toHaveBeenCalledWith(path.join('/template/path', 'assets'), path.join(app_path, 'assets')); - expect(fs.copySync).toHaveBeenCalledWith(path.join('/template/path', 'res'), path.join(app_path, 'res')); - expect(fs.copySync).toHaveBeenCalledWith(path.join('/template/path', 'gitignore'), path.join(project_path, '.gitignore')); + expect(fs.cpSync).toHaveBeenCalledWith(path.join('/template/path', 'assets'), path.join(app_path, 'assets'), { recursive: true }); + expect(fs.cpSync).toHaveBeenCalledWith(path.join('/template/path', 'res'), path.join(app_path, 'res'), { recursive: true }); + expect(fs.cpSync).toHaveBeenCalledWith(path.join('/template/path', 'gitignore'), path.join(project_path, '.gitignore')); }); }); it('should copy project templates from the default templates location if no custom template is provided', () => { return create.create(project_path, config_mock, {}, events_mock).then(() => { - expect(fs.copySync).toHaveBeenCalledWith(path.join(default_templates, 'assets'), path.join(app_path, 'assets')); - expect(fs.copySync).toHaveBeenCalledWith(path.join(default_templates, 'res'), path.join(app_path, 'res')); - expect(fs.copySync).toHaveBeenCalledWith(path.join(default_templates, 'gitignore'), path.join(project_path, '.gitignore')); + expect(fs.cpSync).toHaveBeenCalledWith(path.join(default_templates, 'assets'), path.join(app_path, 'assets'), { recursive: true }); + expect(fs.cpSync).toHaveBeenCalledWith(path.join(default_templates, 'res'), path.join(app_path, 'res'), { recursive: true }); + expect(fs.cpSync).toHaveBeenCalledWith(path.join(default_templates, 'gitignore'), path.join(project_path, '.gitignore')); }); }); @@ -261,7 +261,7 @@ describe('create', function () { it('should create a java src directory based on the provided project package name', () => { config_mock.packageName.and.returnValue('org.apache.cordova'); return create.create(project_path, config_mock, {}, events_mock).then(() => { - expect(fs.ensureDirSync).toHaveBeenCalledWith(path.join(app_path, 'java', 'org', 'apache', 'cordova')); + expect(fs.mkdirSync).toHaveBeenCalledWith(path.join(app_path, 'java', 'org', 'apache', 'cordova'), { recursive: true }); }); }); @@ -270,7 +270,7 @@ describe('create', function () { config_mock.android_activityName.and.returnValue('CEEDEEVEE'); const activity_path = path.join(app_path, 'java', 'org', 'apache', 'cordova', 'CEEDEEVEE.java'); return create.create(project_path, config_mock, {}, events_mock).then(() => { - expect(fs.copySync).toHaveBeenCalledWith(path.join(default_templates, 'Activity.java'), activity_path); + expect(fs.cpSync).toHaveBeenCalledWith(path.join(default_templates, 'Activity.java'), activity_path); expect(utils.replaceFileContents).toHaveBeenCalledWith(activity_path, /__ACTIVITY__/, 'CEEDEEVEE'); expect(utils.replaceFileContents).toHaveBeenCalledWith(activity_path, /__ID__/, 'org.apache.cordova'); }); diff --git a/spec/unit/emulator.spec.js b/spec/unit/emulator.spec.js index 426e559c5..053ec2eaa 100644 --- a/spec/unit/emulator.spec.js +++ b/spec/unit/emulator.spec.js @@ -17,7 +17,7 @@ under the License. */ -const fs = require('fs-extra'); +const fs = require('node:fs'); const path = require('node:path'); const rewire = require('rewire'); const which = require('which'); diff --git a/spec/unit/pluginHandlers/common.spec.js b/spec/unit/pluginHandlers/common.spec.js index 90001fdcd..b7a9ceb4c 100644 --- a/spec/unit/pluginHandlers/common.spec.js +++ b/spec/unit/pluginHandlers/common.spec.js @@ -19,26 +19,40 @@ const rewire = require('rewire'); const common = rewire('../../../lib/pluginHandlers'); const path = require('node:path'); -const fs = require('fs-extra'); -const osenv = require('node:os'); +const fs = require('node:fs'); +const tmp = require('tmp'); -const test_dir = path.join(osenv.tmpdir(), 'test_plugman'); +tmp.setGracefulCleanup(); + +const tempdir = tmp.dirSync({ unsafeCleanup: true }); +const test_dir = path.join(tempdir.name, 'test_plugman'); const project_dir = path.join(test_dir, 'project'); const src = path.join(project_dir, 'src'); const dest = path.join(project_dir, 'dest'); const java_dir = path.join(src, 'one', 'two', 'three'); const java_file = path.join(java_dir, 'test.java'); const symlink_file = path.join(java_dir, 'symlink'); -const non_plugin_file = path.join(osenv.tmpdir(), 'non_plugin_file'); +const non_plugin_file = path.join(tempdir.name, 'non_plugin_file'); const copyFile = common.__get__('copyFile'); const deleteJava = common.__get__('deleteJava'); const copyNewFile = common.__get__('copyNewFile'); +function outputFileSync (file, content) { + const dir = path.dirname(file); + fs.mkdirSync(dir, { recursive: true }); + fs.writeFileSync(file, content, 'utf-8'); +} + describe('common platform handler', function () { + afterAll(() => { + // Remove tempdir after all specs complete + fs.rmSync(tempdir.name, { recursive: true, force: true }); + }); + afterEach(() => { - fs.removeSync(test_dir); - fs.removeSync(non_plugin_file); + fs.rmSync(test_dir, { recursive: true, force: true }); + fs.rmSync(non_plugin_file, { recursive: true, force: true }); }); describe('copyFile', function () { @@ -48,15 +62,15 @@ describe('common platform handler', function () { }); it('Test#002 : should throw if src not in plugin directory', function () { - fs.ensureDirSync(project_dir); - fs.outputFileSync(non_plugin_file, 'contents'); + fs.mkdirSync(project_dir, { recursive: true }); + outputFileSync(non_plugin_file, 'contents'); const outside_file = '../non_plugin_file'; expect(function () { copyFile(test_dir, outside_file, project_dir, dest); }) .toThrow(new Error('File "' + path.resolve(test_dir, outside_file) + '" is located outside the plugin directory "' + test_dir + '"')); }); it('Test#003 : should allow symlink src, if inside plugin', function () { - fs.outputFileSync(java_file, 'contents'); + outputFileSync(java_file, 'contents'); // This will fail on windows if not admin - ignore the error in that case. if (ignoreEPERMonWin32(java_file, symlink_file)) { @@ -67,8 +81,8 @@ describe('common platform handler', function () { }); it('Test#004 : should throw if symlink is linked to a file outside the plugin', function () { - fs.ensureDirSync(java_dir); - fs.outputFileSync(non_plugin_file, 'contents'); + fs.mkdirSync(java_dir, { recursive: true }); + outputFileSync(non_plugin_file, 'contents'); // This will fail on windows if not admin - ignore the error in that case. if (ignoreEPERMonWin32(non_plugin_file, symlink_file)) { @@ -80,37 +94,37 @@ describe('common platform handler', function () { }); it('Test#005 : should throw if dest is outside the project directory', function () { - fs.outputFileSync(java_file, 'contents'); + outputFileSync(java_file, 'contents'); expect(function () { copyFile(test_dir, java_file, project_dir, non_plugin_file); }) .toThrow(new Error('Destination "' + path.resolve(project_dir, non_plugin_file) + '" for source file "' + path.resolve(test_dir, java_file) + '" is located outside the project')); }); - it('Test#006 : should call mkdir -p on target path', function () { - fs.outputFileSync(java_file, 'contents'); + it('Test#006 : should call mkdirSync target path', function () { + outputFileSync(java_file, 'contents'); - const s = spyOn(fs, 'ensureDirSync').and.callThrough(); + const s = spyOn(fs, 'mkdirSync').and.callThrough(); const resolvedDest = path.resolve(project_dir, dest); copyFile(test_dir, java_file, project_dir, dest); expect(s).toHaveBeenCalled(); - expect(s).toHaveBeenCalledWith(path.dirname(resolvedDest)); + expect(s).toHaveBeenCalledWith(path.dirname(resolvedDest), { recursive: true }); }); it('Test#007 : should call cp source/dest paths', function () { - fs.outputFileSync(java_file, 'contents'); + outputFileSync(java_file, 'contents'); - const s = spyOn(fs, 'copySync').and.callThrough(); + const s = spyOn(fs, 'cpSync').and.callThrough(); const resolvedDest = path.resolve(project_dir, dest); copyFile(test_dir, java_file, project_dir, dest); expect(s).toHaveBeenCalled(); - expect(s).toHaveBeenCalledWith(java_file, resolvedDest); + expect(s).toHaveBeenCalledWith(java_file, resolvedDest, { recursive: true }); }); it('should handle relative paths when checking for sub paths', () => { - fs.outputFileSync(java_file, 'contents'); + outputFileSync(java_file, 'contents'); const relativeProjectPath = path.relative(process.cwd(), project_dir); expect(() => { @@ -121,7 +135,7 @@ describe('common platform handler', function () { describe('copyNewFile', function () { it('Test#008 : should throw if target path exists', function () { - fs.ensureDirSync(dest); + fs.mkdirSync(dest, { recursive: true }); expect(function () { copyNewFile(test_dir, src, project_dir, dest); }) .toThrow(new Error('"' + dest + '" already exists!')); }); @@ -129,11 +143,11 @@ describe('common platform handler', function () { describe('deleteJava', function () { beforeEach(function () { - fs.outputFileSync(java_file, 'contents'); + outputFileSync(java_file, 'contents'); }); it('Test#009 : should call fs.unlinkSync on the provided paths', function () { - const s = spyOn(fs, 'removeSync').and.callThrough(); + const s = spyOn(fs, 'rmSync').and.callThrough(); deleteJava(project_dir, java_file); expect(s).toHaveBeenCalled(); expect(s).toHaveBeenCalledWith(path.resolve(project_dir, java_file)); diff --git a/spec/unit/pluginHandlers/handlers.spec.js b/spec/unit/pluginHandlers/handlers.spec.js index cefb269a8..37d25aee5 100644 --- a/spec/unit/pluginHandlers/handlers.spec.js +++ b/spec/unit/pluginHandlers/handlers.spec.js @@ -21,7 +21,7 @@ const rewire = require('rewire'); const common = rewire('../../../lib/pluginHandlers'); const android = common.__get__('handlers'); const path = require('node:path'); -const fs = require('fs-extra'); +const fs = require('node:fs'); const os = require('node:os'); const temp = path.join(os.tmpdir(), 'plugman'); const plugins_dir = path.join(temp, 'cordova/plugins'); @@ -56,14 +56,14 @@ describe('android project handler', function () { let dummyProject; beforeEach(function () { - fs.ensureDirSync(temp); + fs.mkdirSync(temp, { recursive: true }); dummyProject = AndroidProject.getProjectFile(temp); copyFileSpy.calls.reset(); common.__set__('copyFile', copyFileSpy); }); afterEach(function () { - fs.removeSync(temp); + fs.rmSync(temp, { recursive: true, force: true }); common.__set__('copyFile', copyFileOrig); }); @@ -83,7 +83,7 @@ describe('android project handler', function () { describe('of elements', function () { beforeEach(function () { - fs.copySync(android_studio_project, temp); + fs.cpSync(android_studio_project, temp, { recursive: true }); }); it('Test#003 : should copy stuff from one location to another by calling common.copyFile', function () { @@ -102,7 +102,7 @@ describe('android project handler', function () { it('Test#006 : should throw if target file already exists', function () { // write out a file let target = path.resolve(temp, 'app', 'src', 'main', 'java', 'com', 'phonegap', 'plugins', 'dummyplugin'); - fs.ensureDirSync(target); + fs.mkdirSync(target, { recursive: true }); target = path.join(target, 'DummyPlugin.java'); fs.writeFileSync(target, 'some bs', 'utf-8'); @@ -192,7 +192,7 @@ describe('android project handler', function () { const copyNewFileSpy = jasmine.createSpy('copyNewFile'); beforeEach(function () { - fs.copySync(android_studio_project, temp); + fs.cpSync(android_studio_project, temp, { recursive: true }); spyOn(dummyProject, 'addSystemLibrary'); spyOn(dummyProject, 'addSubProject'); @@ -222,7 +222,7 @@ describe('android project handler', function () { it('Test#010 : should not copy anything if "custom" attribute is not set', function () { const framework = { src: 'plugin-lib' }; - const cpSpy = spyOn(fs, 'copySync'); + const cpSpy = spyOn(fs, 'cpSync'); android.framework.install(framework, dummyPluginInfo, dummyProject); expect(dummyProject.addSystemLibrary).toHaveBeenCalledWith(someString, framework.src); expect(cpSpy).not.toHaveBeenCalled(); @@ -289,23 +289,23 @@ describe('android project handler', function () { describe('uninstallation', function () { const deleteJavaOrig = common.__get__('deleteJava'); - const originalRemoveSync = fs.removeSync; + const originalRmSync = fs.rmSync; const deleteJavaSpy = jasmine.createSpy('deleteJava'); let dummyProject; - let removeSyncSpy; + let rmSyncSpy; beforeEach(function () { - fs.ensureDirSync(temp); - fs.ensureDirSync(plugins_dir); - fs.copySync(android_studio_project, temp); + fs.mkdirSync(temp, { recursive: true }); + fs.mkdirSync(plugins_dir, { recursive: true }); + fs.cpSync(android_studio_project, temp, { recursive: true }); AndroidProject.purgeCache(); dummyProject = AndroidProject.getProjectFile(temp); - removeSyncSpy = spyOn(fs, 'removeSync'); + rmSyncSpy = spyOn(fs, 'rmSync'); common.__set__('deleteJava', deleteJavaSpy); }); afterEach(function () { - originalRemoveSync.call(fs, temp); + originalRmSync.call(fs, temp, { recursive: true }); common.__set__('deleteJava', deleteJavaOrig); }); @@ -313,7 +313,7 @@ describe('android project handler', function () { it('Test#017 : should remove jar files for Android Studio projects', function () { android['lib-file'].install(valid_libs[0], dummyPluginInfo, dummyProject); android['lib-file'].uninstall(valid_libs[0], dummyPluginInfo, dummyProject); - expect(removeSyncSpy).toHaveBeenCalledWith(path.join(dummyProject.projectDir, 'app/libs/TestLib.jar')); + expect(rmSyncSpy).toHaveBeenCalledWith(path.join(dummyProject.projectDir, 'app/libs/TestLib.jar')); }); }); @@ -321,7 +321,7 @@ describe('android project handler', function () { it('Test#018 : should remove files for Android Studio projects', function () { android['resource-file'].install(valid_resources[0], dummyPluginInfo, dummyProject); android['resource-file'].uninstall(valid_resources[0], dummyPluginInfo, dummyProject); - expect(removeSyncSpy).toHaveBeenCalledWith(path.join(dummyProject.projectDir, 'app', 'src', 'main', 'res', 'xml', 'dummy.xml')); + expect(rmSyncSpy).toHaveBeenCalledWith(path.join(dummyProject.projectDir, 'app', 'src', 'main', 'res', 'xml', 'dummy.xml')); }); }); @@ -341,49 +341,49 @@ describe('android project handler', function () { it('Test#019b : should remove stuff by calling common.removeFile for Android Studio projects, of jar with new app target-dir scheme', function () { android['source-file'].install(valid_source[2], dummyPluginInfo, dummyProject, { android_studio: true }); android['source-file'].uninstall(valid_source[2], dummyPluginInfo, dummyProject, { android_studio: true }); - expect(removeSyncSpy).toHaveBeenCalledWith(path.join(dummyProject.projectDir, 'app/libs/TestLib.jar')); + expect(rmSyncSpy).toHaveBeenCalledWith(path.join(dummyProject.projectDir, 'app/libs/TestLib.jar')); }); it('Test#019c : should remove stuff by calling common.removeFile for Android Studio projects, of aar with new app target-dir scheme', function () { android['source-file'].install(valid_source[3], dummyPluginInfo, dummyProject, { android_studio: true }); android['source-file'].uninstall(valid_source[3], dummyPluginInfo, dummyProject, { android_studio: true }); - expect(removeSyncSpy).toHaveBeenCalledWith(path.join(dummyProject.projectDir, 'app/libs/TestAar.aar')); + expect(rmSyncSpy).toHaveBeenCalledWith(path.join(dummyProject.projectDir, 'app/libs/TestAar.aar')); }); it('Test#019d : should remove stuff by calling common.removeFile for Android Studio projects, of xml with old target-dir scheme', function () { android['source-file'].install(valid_source[4], dummyPluginInfo, dummyProject, { android_studio: true }); android['source-file'].uninstall(valid_source[4], dummyPluginInfo, dummyProject, { android_studio: true }); - expect(removeSyncSpy).toHaveBeenCalledWith(path.join(dummyProject.projectDir, 'app/src/main/res/xml/mysettings.xml')); + expect(rmSyncSpy).toHaveBeenCalledWith(path.join(dummyProject.projectDir, 'app/src/main/res/xml/mysettings.xml')); }); it('Test#019e : should remove stuff by calling common.removeFile for Android Studio projects, of file with other extension with old target-dir scheme', function () { android['source-file'].install(valid_source[5], dummyPluginInfo, dummyProject, { android_studio: true }); android['source-file'].uninstall(valid_source[5], dummyPluginInfo, dummyProject, { android_studio: true }); - expect(removeSyncSpy).toHaveBeenCalledWith(path.join(dummyProject.projectDir, 'app/src/main/res/values/other.extension')); + expect(rmSyncSpy).toHaveBeenCalledWith(path.join(dummyProject.projectDir, 'app/src/main/res/values/other.extension')); }); it('Test#019f : should remove stuff by calling common.removeFile for Android Studio projects, of aidl with old target-dir scheme (GH-547)', function () { android['source-file'].install(valid_source[6], dummyPluginInfo, dummyProject, { android_studio: true }); android['source-file'].uninstall(valid_source[6], dummyPluginInfo, dummyProject, { android_studio: true }); - expect(removeSyncSpy).toHaveBeenCalledWith(path.join(dummyProject.projectDir, 'app/src/main/aidl/com/mytest/myapi.aidl')); + expect(rmSyncSpy).toHaveBeenCalledWith(path.join(dummyProject.projectDir, 'app/src/main/aidl/com/mytest/myapi.aidl')); }); it('Test#019g : should remove stuff by calling common.removeFile for Android Studio projects, of aar with old target-dir scheme (GH-547)', function () { android['source-file'].install(valid_source[7], dummyPluginInfo, dummyProject, { android_studio: true }); android['source-file'].uninstall(valid_source[7], dummyPluginInfo, dummyProject, { android_studio: true }); - expect(removeSyncSpy).toHaveBeenCalledWith(path.join(dummyProject.projectDir, 'app/libs/testaar2.aar')); + expect(rmSyncSpy).toHaveBeenCalledWith(path.join(dummyProject.projectDir, 'app/libs/testaar2.aar')); }); it('Test#019h : should remove stuff by calling common.removeFile for Android Studio projects, of jar with old target-dir scheme (GH-547)', function () { android['source-file'].install(valid_source[8], dummyPluginInfo, dummyProject, { android_studio: true }); android['source-file'].uninstall(valid_source[8], dummyPluginInfo, dummyProject, { android_studio: true }); - expect(removeSyncSpy).toHaveBeenCalledWith(path.join(dummyProject.projectDir, 'app/libs/testjar2.jar')); + expect(rmSyncSpy).toHaveBeenCalledWith(path.join(dummyProject.projectDir, 'app/libs/testjar2.jar')); }); it('Test#019i : should remove stuff by calling common.removeFile for Android Studio projects, of .so lib file with old target-dir scheme (GH-547)', function () { android['source-file'].install(valid_source[9], dummyPluginInfo, dummyProject, { android_studio: true }); android['source-file'].uninstall(valid_source[9], dummyPluginInfo, dummyProject, { android_studio: true }); - expect(removeSyncSpy).toHaveBeenCalledWith(path.join(dummyProject.projectDir, 'app/src/main/jniLibs/x86/libnative.so')); + expect(rmSyncSpy).toHaveBeenCalledWith(path.join(dummyProject.projectDir, 'app/src/main/jniLibs/x86/libnative.so')); }); it('Test#019j : should remove stuff by calling common.deleteJava for Android Studio projects, with target-dir that includes "app"', function () { @@ -397,7 +397,7 @@ describe('android project handler', function () { const someString = jasmine.any(String); beforeEach(function () { - fs.ensureDirSync(path.join(dummyProject.projectDir, dummyPluginInfo.id)); + fs.mkdirSync(path.join(dummyProject.projectDir, dummyPluginInfo.id), { recursive: true }); spyOn(dummyProject, 'removeSystemLibrary'); spyOn(dummyProject, 'removeSubProject'); @@ -424,13 +424,13 @@ describe('android project handler', function () { const framework = { src: 'plugin-lib', custom: true }; android.framework.uninstall(framework, dummyPluginInfo, dummyProject); expect(dummyProject.removeSubProject).toHaveBeenCalledWith(dummyProject.projectDir, someString); - expect(removeSyncSpy).toHaveBeenCalledWith(someString); + expect(rmSyncSpy).toHaveBeenCalledWith(someString); }); it('Test#24 : should install gradleReference using project.removeGradleReference', function () { const framework = { src: 'plugin-lib', custom: true, type: 'gradleReference' }; android.framework.uninstall(framework, dummyPluginInfo, dummyProject); - expect(removeSyncSpy).toHaveBeenCalledWith(someString); + expect(rmSyncSpy).toHaveBeenCalledWith(someString); expect(dummyProject.removeGradleReference).toHaveBeenCalledWith(dummyProject.projectDir, someString); }); }); @@ -453,14 +453,14 @@ describe('android project handler', function () { it('Test#025 : should put module to both www and platform_www when options.usePlatformWww flag is specified', function () { android['js-module'].uninstall(jsModule, dummyPluginInfo, dummyProject, { usePlatformWww: true }); - expect(removeSyncSpy).toHaveBeenCalledWith(wwwDest); - expect(removeSyncSpy).toHaveBeenCalledWith(platformWwwDest); + expect(rmSyncSpy).toHaveBeenCalledWith(wwwDest); + expect(rmSyncSpy).toHaveBeenCalledWith(platformWwwDest); }); it('Test#026 : should put module to www only when options.usePlatformWww flag is not specified', function () { android['js-module'].uninstall(jsModule, dummyPluginInfo, dummyProject); - expect(removeSyncSpy).toHaveBeenCalledWith(wwwDest); - expect(removeSyncSpy).not.toHaveBeenCalledWith(platformWwwDest); + expect(rmSyncSpy).toHaveBeenCalledWith(wwwDest); + expect(rmSyncSpy).not.toHaveBeenCalledWith(platformWwwDest); }); }); @@ -481,14 +481,14 @@ describe('android project handler', function () { it('Test#027 : should put module to both www and platform_www when options.usePlatformWww flag is specified', function () { android.asset.uninstall(asset, dummyPluginInfo, dummyProject, { usePlatformWww: true }); - expect(removeSyncSpy).toHaveBeenCalledWith(wwwDest); - expect(removeSyncSpy).toHaveBeenCalledWith(platformWwwDest); + expect(rmSyncSpy).toHaveBeenCalledWith(wwwDest); + expect(rmSyncSpy).toHaveBeenCalledWith(platformWwwDest); }); it('Test#028 : should put module to www only when options.usePlatformWww flag is not specified', function () { android.asset.uninstall(asset, dummyPluginInfo, dummyProject); - expect(removeSyncSpy).toHaveBeenCalledWith(wwwDest); - expect(removeSyncSpy).not.toHaveBeenCalledWith(platformWwwDest); + expect(rmSyncSpy).toHaveBeenCalledWith(wwwDest); + expect(rmSyncSpy).not.toHaveBeenCalledWith(platformWwwDest); }); }); }); diff --git a/spec/unit/prepare.spec.js b/spec/unit/prepare.spec.js index eb9005738..374eb26ab 100644 --- a/spec/unit/prepare.spec.js +++ b/spec/unit/prepare.spec.js @@ -899,9 +899,9 @@ describe('prepare', () => { // Spies let replaceFileContents; - let ensureDirSyncSpy; - let copySyncSpy; - let removeSyncSpy; + let mkdirSyncSpy; + let cpSyncSpy; + let rmSyncSpy; // Mock Data let cordovaProject; @@ -1001,16 +1001,15 @@ describe('prepare', () => { `)) }); - ensureDirSyncSpy = jasmine.createSpy('ensureDirSync'); - copySyncSpy = jasmine.createSpy('copySync'); - removeSyncSpy = jasmine.createSpy('removeSync'); + mkdirSyncSpy = jasmine.createSpy('mkdirSync'); + cpSyncSpy = jasmine.createSpy('cpSync'); + rmSyncSpy = jasmine.createSpy('rmSync'); prepare.__set__('fs', { writeFileSync: jasmine.createSpy('writeFileSync'), - writeJSONSync: jasmine.createSpy('writeJSONSync'), - ensureDirSync: ensureDirSyncSpy, - copySync: copySyncSpy, - removeSync: removeSyncSpy, + mkdirSync: mkdirSyncSpy, + cpSync: cpSyncSpy, + rmSync: rmSyncSpy, existsSync: jasmine.createSpy('existsSync') }); }); @@ -1022,9 +1021,9 @@ describe('prepare', () => { await api.prepare(cordovaProject, options).then(() => { expect(replaceFileContents).toHaveBeenCalledWith(renamedJavaActivityPath, /package [\w.]*;/, 'package ' + packageName + ';'); - expect(ensureDirSyncSpy).toHaveBeenCalledWith(renamedPath); - expect(copySyncSpy).toHaveBeenCalledWith(initialJavaActivityPath, renamedJavaActivityPath); - expect(removeSyncSpy).toHaveBeenCalledWith(initialJavaActivityPath); + expect(mkdirSyncSpy).toHaveBeenCalledWith(renamedPath, { recursive: true }); + expect(cpSyncSpy).toHaveBeenCalledWith(initialJavaActivityPath, renamedJavaActivityPath); + expect(rmSyncSpy).toHaveBeenCalledWith(initialJavaActivityPath); }); }); @@ -1033,9 +1032,9 @@ describe('prepare', () => { await api.prepare(cordovaProject, options).then(() => { expect(replaceFileContents).toHaveBeenCalledTimes(0); - expect(ensureDirSyncSpy).toHaveBeenCalledTimes(0); - expect(copySyncSpy).toHaveBeenCalledTimes(0); - expect(removeSyncSpy).toHaveBeenCalledTimes(0); + expect(mkdirSyncSpy).toHaveBeenCalledTimes(0); + expect(cpSyncSpy).toHaveBeenCalledTimes(0); + expect(rmSyncSpy).toHaveBeenCalledTimes(0); }); }); }); diff --git a/test/run_java_unit_tests.js b/test/run_java_unit_tests.js index 5d48ea928..23e3c5c4e 100644 --- a/test/run_java_unit_tests.js +++ b/test/run_java_unit_tests.js @@ -21,7 +21,7 @@ const path = require('node:path'); const execa = require('execa'); -const fs = require('fs-extra'); +const fs = require('node:fs'); const ProjectBuilder = require('../lib/builders/ProjectBuilder'); class AndroidTestRunner { @@ -62,7 +62,7 @@ class AndroidTestRunner { .then(_ => { // TODO we should probably not only copy these files, but instead create a new project from scratch fs.copyFileSync(path.resolve(this.projectDir, '../../framework/cdv-gradle-config-defaults.json'), path.resolve(this.projectDir, 'cdv-gradle-config.json')); - fs.copySync(path.resolve(this.projectDir, '../../templates/project/tools'), path.resolve(this.projectDir, 'tools')); + fs.cpSync(path.resolve(this.projectDir, '../../templates/project/tools'), path.resolve(this.projectDir, 'tools'), { recursive: true }); fs.copyFileSync( path.join(__dirname, '../templates/project/assets/www/cordova.js'), path.join(this.projectDir, 'app/src/main/assets/www/cordova.js') From eb0f002112538895c2c8fa2f5042eaea4b8cb26b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=A8=E3=83=AA=E3=82=B9?= Date: Thu, 30 Jan 2025 18:17:22 +0900 Subject: [PATCH 19/66] style: update & resolve doc block warnings (#1774) * style: resolve throw symbols (except InvalidArgumentException) * style: resolve unknown symbol & reduce indention for PluginEntry * fix: define IllegalArgumentException not InvalidArgumentException --- cordova-js-src/plugin/android/app.js | 4 +- framework/cordova.gradle | 2 +- .../org/apache/cordova/AllowListPlugin.java | 2 +- .../apache/cordova/AuthenticationToken.java | 6 +- .../src/org/apache/cordova/CallbackMap.java | 2 +- framework/src/org/apache/cordova/Config.java | 2 +- .../org/apache/cordova/CordovaActivity.java | 19 ++-- .../cordova/CordovaClientCertRequest.java | 20 ++--- .../apache/cordova/CordovaDialogsHelper.java | 4 +- .../org/apache/cordova/CordovaInterface.java | 9 +- .../apache/cordova/CordovaInterfaceImpl.java | 4 +- .../src/org/apache/cordova/CordovaPlugin.java | 89 ++++++++++--------- .../apache/cordova/CordovaResourceApi.java | 69 ++++++++------ .../org/apache/cordova/CordovaWebView.java | 37 +++++--- .../apache/cordova/CordovaWebViewEngine.java | 2 +- .../apache/cordova/CordovaWebViewImpl.java | 12 +-- .../src/org/apache/cordova/CoreAndroid.java | 12 +-- .../cordova/ICordovaClientCertRequest.java | 20 ++--- framework/src/org/apache/cordova/LOG.java | 4 +- .../cordova/NativeToJsMessageQueue.java | 4 +- .../org/apache/cordova/PermissionHelper.java | 1 - .../src/org/apache/cordova/PluginEntry.java | 24 ++--- .../src/org/apache/cordova/PluginManager.java | 64 +++++++------ .../src/org/apache/cordova/PluginResult.java | 3 +- .../apache/cordova/SplashScreenPlugin.java | 10 +-- .../cordova/engine/SystemWebChromeClient.java | 13 +-- .../cordova/engine/SystemWebViewClient.java | 20 ++--- .../cordova/engine/SystemWebViewEngine.java | 12 +-- .../unittests/StandardActivityTest.java | 2 +- .../unittests/EmbeddedWebViewActivity.java | 2 +- 30 files changed, 252 insertions(+), 222 deletions(-) diff --git a/cordova-js-src/plugin/android/app.js b/cordova-js-src/plugin/android/app.js index 027ce31b1..c783ab1e3 100644 --- a/cordova-js-src/plugin/android/app.js +++ b/cordova-js-src/plugin/android/app.js @@ -31,14 +31,14 @@ module.exports = { }, /** - * Load the url into the webview or into new browser instance. + * Load the url into the WebView or into new browser instance. * * @param url The URL to load * @param props Properties that can be passed in to the activity: * wait: int => wait msec before loading URL * loadingDialog: "Title,Message" => display a native loading dialog * loadUrlTimeoutValue: int => time in msec to wait before triggering a timeout error - * clearHistory: boolean => clear webview history (default=false) + * clearHistory: boolean => clear WebView history (default=false) * openExternal: boolean => open in a new browser (default=false) * * Example: diff --git a/framework/cordova.gradle b/framework/cordova.gradle index 9b9783989..abb5b411b 100644 --- a/framework/cordova.gradle +++ b/framework/cordova.gradle @@ -150,7 +150,7 @@ def doGetConfigPreference(name, defaultValue) { } def doApplyCordovaConfigCustomization() { - // Apply user overide properties that comes from the "--gradleArg=-P" parameters + // Apply user override properties that comes from the "--gradleArg=-P" parameters if (project.hasProperty('cdvMinSdkVersion')) { cordovaConfig.MIN_SDK_VERSION = Integer.parseInt('' + cdvMinSdkVersion) } diff --git a/framework/src/org/apache/cordova/AllowListPlugin.java b/framework/src/org/apache/cordova/AllowListPlugin.java index 63dd5a199..e85f8ecde 100644 --- a/framework/src/org/apache/cordova/AllowListPlugin.java +++ b/framework/src/org/apache/cordova/AllowListPlugin.java @@ -39,7 +39,7 @@ public class AllowListPlugin extends CordovaPlugin { // Used when instantiated via reflection by PluginManager public AllowListPlugin() { } - // These can be used by embedders to allow Java-configuration of an allow list. + // These can be used by plugin developers to allow Java-configuration of an allow list. public AllowListPlugin(Context context) { this(new AllowList(), new AllowList(), null); new CustomConfigXmlParser().parse(context); diff --git a/framework/src/org/apache/cordova/AuthenticationToken.java b/framework/src/org/apache/cordova/AuthenticationToken.java index d3a231a0b..38451c567 100644 --- a/framework/src/org/apache/cordova/AuthenticationToken.java +++ b/framework/src/org/apache/cordova/AuthenticationToken.java @@ -37,8 +37,7 @@ public String getUserName() { /** * Sets the user name. * - * @param userName - * the new user name + * @param userName the new user name */ public void setUserName(String userName) { this.userName = userName; @@ -56,8 +55,7 @@ public String getPassword() { /** * Sets the password. * - * @param password - * the new password + * @param password the new password */ public void setPassword(String password) { this.password = password; diff --git a/framework/src/org/apache/cordova/CallbackMap.java b/framework/src/org/apache/cordova/CallbackMap.java index 050daa01f..b825610c5 100644 --- a/framework/src/org/apache/cordova/CallbackMap.java +++ b/framework/src/org/apache/cordova/CallbackMap.java @@ -54,7 +54,7 @@ public synchronized int registerCallback(CordovaPlugin receiver, int requestCode * obtained from registerCallback() * * @param mappedId The request code obtained from registerCallback() - * @return The CordovaPlugin and orignal request code that correspond to the + * @return The CordovaPlugin and original request code that correspond to the * given mappedCode */ public synchronized Pair getAndRemoveCallback(int mappedId) { diff --git a/framework/src/org/apache/cordova/Config.java b/framework/src/org/apache/cordova/Config.java index 238cd5e33..2082f251a 100644 --- a/framework/src/org/apache/cordova/Config.java +++ b/framework/src/org/apache/cordova/Config.java @@ -23,7 +23,7 @@ Licensed to the Apache Software Foundation (ASF) under one import android.app.Activity; -@Deprecated // Use AllowList, CordovaPrefences, etc. directly. +@Deprecated // Use AllowList, CordovaPreferences, etc. directly. public class Config { private static final String TAG = "Config"; diff --git a/framework/src/org/apache/cordova/CordovaActivity.java b/framework/src/org/apache/cordova/CordovaActivity.java index 325e9e9dd..50d6b3232 100755 --- a/framework/src/org/apache/cordova/CordovaActivity.java +++ b/framework/src/org/apache/cordova/CordovaActivity.java @@ -49,7 +49,7 @@ Licensed to the Apache Software Foundation (ASF) under one * application. It should be extended by the user to load the specific * html file that contains the application. * - * As an example: + *

As an example:

* *
  *     package org.apache.cordova.examples;
@@ -68,17 +68,16 @@ Licensed to the Apache Software Foundation (ASF) under one
  *     }
  * 
* - * Cordova xml configuration: Cordova uses a configuration file at - * res/xml/config.xml to specify its settings. See "The config.xml File" - * guide in cordova-docs at http://cordova.apache.org/docs for the documentation - * for the configuration. The use of the set*Property() methods is - * deprecated in favor of the config.xml file. + *

Cordova xml configuration: Cordova uses a configuration file at + * res/xml/config.xml to specify its settings. See the "Config.xml API" documentation for + * configuration details at Apache Cordova Docs.

* + *

The use of the set*Property() methods is deprecated in favor of the config.xml file.

*/ public class CordovaActivity extends AppCompatActivity { public static String TAG = "CordovaActivity"; - // The webview for our app + // The WebView for our app protected CordovaWebView appView; private static int ACTIVITY_STARTING = 0; @@ -206,7 +205,7 @@ protected void createViews() { /** * Construct the default web view object. *

- * Override this to customize the webview that is used. + * Override this to customize the WebView that is used. */ protected CordovaWebView makeWebView() { return new CordovaWebViewImpl(makeWebViewEngine()); @@ -227,7 +226,7 @@ public Object onMessage(String id, Object data) { } /** - * Load the url into the webview. + * Load the url into the WebView. */ public void loadUrl(String url) { if (appView == null) { @@ -250,7 +249,7 @@ protected void onPause() { if (this.appView != null) { // CB-9382 If there is an activity that started for result and main activity is waiting for callback - // result, we shoudn't stop WebView Javascript timers, as activity for result might be using them + // result, we shouldn't stop WebView Javascript timers, as activity for result might be using them boolean keepRunning = this.keepRunning || this.cordovaInterface.activityResultCallback != null; this.appView.handlePause(keepRunning); } diff --git a/framework/src/org/apache/cordova/CordovaClientCertRequest.java b/framework/src/org/apache/cordova/CordovaClientCertRequest.java index a78893414..af88392fb 100644 --- a/framework/src/org/apache/cordova/CordovaClientCertRequest.java +++ b/framework/src/org/apache/cordova/CordovaClientCertRequest.java @@ -47,8 +47,8 @@ public void cancel() request.cancel(); } - /* - * Returns the host name of the server requesting the certificate. + /** + * @return the host name of the server requesting the certificate. */ @SuppressLint("NewApi") @Override @@ -57,8 +57,8 @@ public String getHost() return request.getHost(); } - /* - * Returns the acceptable types of asymmetric keys (can be null). + /** + * @return the acceptable types of asymmetric keys (can be null). */ @SuppressLint("NewApi") @Override @@ -67,8 +67,8 @@ public String[] getKeyTypes() return request.getKeyTypes(); } - /* - * Returns the port number of the server requesting the certificate. + /** + * @return the port number of the server requesting the certificate. */ @SuppressLint("NewApi") @Override @@ -77,8 +77,8 @@ public int getPort() return request.getPort(); } - /* - * Returns the acceptable certificate issuers for the certificate matching the private key (can be null). + /** + * @return the acceptable certificate issuers for the certificate matching the private key (can be null). */ @SuppressLint("NewApi") @Override @@ -87,7 +87,7 @@ public Principal[] getPrincipals() return request.getPrincipals(); } - /* + /** * Ignore the request for now. Do not remember user's choice. */ @SuppressLint("NewApi") @@ -97,7 +97,7 @@ public void ignore() request.ignore(); } - /* + /** * Proceed with the specified private key and client certificate chain. Remember the user's positive choice and use it for future requests. * * @param privateKey The privateKey diff --git a/framework/src/org/apache/cordova/CordovaDialogsHelper.java b/framework/src/org/apache/cordova/CordovaDialogsHelper.java index a4c7ceb7b..f74ad8e74 100644 --- a/framework/src/org/apache/cordova/CordovaDialogsHelper.java +++ b/framework/src/org/apache/cordova/CordovaDialogsHelper.java @@ -118,8 +118,8 @@ public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { * If the client returns true, WebView will assume that the client will * handle the prompt dialog and call the appropriate JsPromptResult method. * - * Since we are hacking prompts for our own purposes, we should not be using them for - * this purpose, perhaps we should hack console.log to do this instead! + *

Since we are hacking prompts for our own purposes, we should not be using them for + * this purpose, perhaps we should hack console.log to do this instead!

*/ public void showPrompt(String message, String defaultValue, final Result result) { // Returning false would also show a dialog, but the default one shows the origin (ugly). diff --git a/framework/src/org/apache/cordova/CordovaInterface.java b/framework/src/org/apache/cordova/CordovaInterface.java index 53d03a5c0..867797227 100755 --- a/framework/src/org/apache/cordova/CordovaInterface.java +++ b/framework/src/org/apache/cordova/CordovaInterface.java @@ -51,7 +51,8 @@ public interface CordovaInterface { /** * Get the Android activity. * - * If a custom engine lives outside of the Activity's lifecycle the return value may be null. + *

If a custom engine lives outside of the Activity's lifecycle the return value + * may be null.

* * @return the Activity */ @@ -74,7 +75,7 @@ public interface CordovaInterface { public Object onMessage(String id, Object data); /** - * Returns a shared thread pool that can be used for background tasks. + * @return a shared thread pool that can be used for background tasks. */ public ExecutorService getThreadPool(); @@ -89,7 +90,9 @@ public interface CordovaInterface { public void requestPermissions(CordovaPlugin plugin, int requestCode, String [] permissions); /** - * Check for a permission. Returns true if the permission is granted, false otherwise. + * Check for a permission. + * + * @return true if the permission is granted, false otherwise. */ public boolean hasPermission(String permission); diff --git a/framework/src/org/apache/cordova/CordovaInterfaceImpl.java b/framework/src/org/apache/cordova/CordovaInterfaceImpl.java index 649dd5738..068c43697 100644 --- a/framework/src/org/apache/cordova/CordovaInterfaceImpl.java +++ b/framework/src/org/apache/cordova/CordovaInterfaceImpl.java @@ -135,7 +135,9 @@ public void onCordovaInit(PluginManager pluginManager) { } /** - * Routes the result to the awaiting plugin. Returns false if no plugin was waiting. + * Routes the result to the awaiting plugin. + * + * @return false if no plugin was waiting. */ public boolean onActivityResult(int requestCode, int resultCode, Intent intent) { CordovaPlugin callback = activityResultCallback; diff --git a/framework/src/org/apache/cordova/CordovaPlugin.java b/framework/src/org/apache/cordova/CordovaPlugin.java index 8adeb7a14..90a12c1aa 100644 --- a/framework/src/org/apache/cordova/CordovaPlugin.java +++ b/framework/src/org/apache/cordova/CordovaPlugin.java @@ -79,7 +79,7 @@ protected void pluginInitialize() { } /** - * Returns the plugin's service name (what you'd use when calling pluginManger.getPlugin()) + * @return the plugin's service name (what you'd use when calling pluginManger.getPlugin()) */ public String getServiceName() { return serviceName; @@ -88,11 +88,14 @@ public String getServiceName() { /** * Executes the request. * - * This method is called from the WebView thread. To do a non-trivial amount of work, use: - * cordova.getThreadPool().execute(runnable); + *

This method is called from the WebView thread. To do a non-trivial + * amount of work, use:

* - * To run on the UI thread, use: - * cordova.getActivity().runOnUiThread(runnable); + *
cordova.getThreadPool().execute(runnable);
+ * + *

To run on the UI thread, use:

+ * + *
cordova.getActivity().runOnUiThread(runnable);
* * @param action The action to execute. * @param rawArgs The exec() arguments in JSON form. @@ -107,11 +110,13 @@ public boolean execute(String action, String rawArgs, CallbackContext callbackCo /** * Executes the request. * - * This method is called from the WebView thread. To do a non-trivial amount of work, use: - * cordova.getThreadPool().execute(runnable); + *

This method is called from the WebView thread. To do a non-trivial amount of work, use:

* - * To run on the UI thread, use: - * cordova.getActivity().runOnUiThread(runnable); + *
cordova.getThreadPool().execute(runnable);
+ * + *

To run on the UI thread, use:

+ * + *
cordova.getActivity().runOnUiThread(runnable);
* * @param action The action to execute. * @param args The exec() arguments. @@ -126,10 +131,10 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo /** * Executes the request. * - * This method is called from the WebView thread. To do a non-trivial amount of work, use: + *

This method is called from the WebView thread. To do a non-trivial amount of work, use:

* cordova.getThreadPool().execute(runnable); * - * To run on the UI thread, use: + *

To run on the UI thread, use:

* cordova.getActivity().runOnUiThread(runnable); * * @param action The action to execute. @@ -231,18 +236,18 @@ public void onActivityResult(int requestCode, int resultCode, Intent intent) { /** * Hook for blocking the loading of external resources. * - * This will be called when the WebView's shouldInterceptRequest wants to + *

This will be called when the WebView's shouldInterceptRequest wants to * know whether to open a connection to an external resource. Return false * to block the request: if any plugin returns false, Cordova will block * the request. If all plugins return null, the default policy will be * enforced. If at least one plugin returns true, and no plugins return - * false, then the request will proceed. + * false, then the request will proceed.

* - * Note that this only affects resource requests which are routed through + *

Note that this only affects resource requests which are routed through * WebViewClient.shouldInterceptRequest, such as XMLHttpRequest requests and * img tag loads. WebSockets and media requests (such as

*/ public Boolean shouldAllowRequest(String url) { return null; @@ -250,13 +255,13 @@ public Boolean shouldAllowRequest(String url) { /** * Hook for blocking navigation by the Cordova WebView. This applies both to top-level and - * iframe navigations. + * iframe navigation. * - * This will be called when the WebView's needs to know whether to navigate + *

This will be called when the WebView's needs to know whether to navigate * to a new page. Return false to block the navigation: if any plugin * returns false, Cordova will block the navigation. If all plugins return * null, the default policy will be enforced. It at least one plugin returns - * true, and no plugins return false, then the navigation will proceed. + * true, and no plugins return false, then the navigation will proceed.

*/ public Boolean shouldAllowNavigation(String url) { return null; @@ -274,12 +279,12 @@ public Boolean shouldAllowBridgeAccess(String url) { /** * Hook for blocking the launching of Intents by the Cordova application. * - * This will be called when the WebView will not navigate to a page, but + *

This will be called when the WebView will not navigate to a page, but * could launch an intent to handle the URL. Return false to block this: if * any plugin returns false, Cordova will block the navigation. If all * plugins return null, the default policy will be enforced. If at least one * plugin returns true, and no plugins return false, then the URL will be - * opened. + * opened.

*/ public Boolean shouldOpenExternalUrl(String url) { return null; @@ -288,8 +293,8 @@ public Boolean shouldOpenExternalUrl(String url) { /** * Allows plugins to handle a link being clicked. Return true here to cancel the navigation. * - * @param url The URL that is trying to be loaded in the Cordova webview. - * @return Return true to prevent the URL from loading. Default is false. + * @param url The URL that is trying to be loaded in the Cordova WebView. + * @return true to prevent the URL from loading. Default is false. */ public boolean onOverrideUrlLoading(String url) { return false; @@ -299,17 +304,20 @@ public boolean onOverrideUrlLoading(String url) { * Hook for redirecting requests. Applies to WebView requests as well as requests made by plugins. * To handle the request directly, return a URI in the form: * - * cdvplugin://pluginId/... + *
cdvplugin://pluginId/...
* - * And implement handleOpenForRead(). - * To make this easier, use the toPluginUri() and fromPluginUri() helpers: + *

And implement handleOpenForRead().

* + *

To make this easier, use the toPluginUri() and fromPluginUri() helpers:

+ * + *
      *     public Uri remapUri(Uri uri) { return toPluginUri(uri); }
      *
      *     public CordovaResourceApi.OpenForReadResult handleOpenForRead(Uri uri) throws IOException {
      *         Uri origUri = fromPluginUri(uri);
      *         ...
      *     }
+     * 
*/ public Uri remapUri(Uri uri) { return null; @@ -347,9 +355,9 @@ protected Uri fromPluginUri(Uri pluginUri) { /** * Called when the WebView does a top-level navigation or refreshes. * - * Plugins should stop any long-running processes and clean up internal state. + *

Plugins should stop any long-running processes and clean up internal state.

* - * Does nothing by default. + *

Does nothing by default.

*/ public void onReset() { } @@ -362,9 +370,7 @@ public void onReset() { * @param handler The HttpAuthHandler used to set the WebView's response * @param host The host requiring authentication * @param realm The realm for which authentication is required - * - * @return Returns True if plugin will resolve this auth challenge, otherwise False - * + * @return true if the plugin will resolve this auth challenge, else false */ public boolean onReceivedHttpAuthRequest(CordovaWebView view, ICordovaHttpAuthHandler handler, String host, String realm) { return false; @@ -376,9 +382,7 @@ public boolean onReceivedHttpAuthRequest(CordovaWebView view, ICordovaHttpAuthHa * * @param view The WebView that is initiating the callback * @param request The client certificate request - * - * @return Returns True if plugin will resolve this auth challenge, otherwise False - * + * @return True if plugin will resolve this auth challenge, otherwise False */ public boolean onReceivedClientCertRequest(CordovaWebView view, ICordovaClientCertRequest request) { return false; @@ -396,20 +400,17 @@ public void onConfigurationChanged(Configuration newConfig) { * Called by the Plugin Manager when we need to actually request permissions * * @param requestCode Passed to the activity to track the request - * - * @return Returns the permission that was stored in the plugin + * @return The permission that was stored in the plugin */ - public void requestPermissions(int requestCode) { } - /* + /** * Called by the WebView implementation to check for geolocation permissions, can be used * by other Java methods in the event that a plugin is using this as a dependency. * - * @return Returns true if the plugin has all the permissions it needs to operate. + * @return True if the plugin has all the permissions it needs to operate. */ - public boolean hasPermisssion() { return true; } @@ -420,7 +421,6 @@ public boolean hasPermisssion() { * @param requestCode * @param permissions * @param grantResults - * * @deprecated Use {@link #onRequestPermissionsResult} instead. */ @Deprecated @@ -443,6 +443,7 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, /** * Allow plugins to supply a PathHandler for the WebViewAssetHandler + * * @return a CordovaPluginPathHandler which listen for paths and returns a response */ public CordovaPluginPathHandler getPathHandler() { @@ -450,11 +451,13 @@ public CordovaPluginPathHandler getPathHandler() { } /** - * Called when the WebView's render process has exited. Can be used to collect information regarding the crash for crashlytics or optionally attempt to gracefully handle/recover the crashed webview by recreating it. + * Called when the WebView's render process has exited. Can be used to collect information + * regarding the crash for crashlytics or optionally attempt to gracefully handle/recover the + * crashed WebView by recreating it. * - * See WebViewClient#onRenderProcessGone + *

See WebViewClient#onRenderProcessGone

* - * Note: A plugin must not attempt to recover a webview that it does not own/manage. + *

Note: A plugin must not attempt to recover a WebView that it does not own/manage.

* * @return true if the host application handled the situation that process has exited, * otherwise, application will crash if render process crashed, or be killed diff --git a/framework/src/org/apache/cordova/CordovaResourceApi.java b/framework/src/org/apache/cordova/CordovaResourceApi.java index a9f3453c0..1d6fd6f22 100644 --- a/framework/src/org/apache/cordova/CordovaResourceApi.java +++ b/framework/src/org/apache/cordova/CordovaResourceApi.java @@ -45,21 +45,36 @@ Licensed to the Apache Software Foundation (ASF) under one /** * What this class provides: - * 1. Helpers for reading & writing to URLs. - * - E.g. handles assets, resources, content providers, files, data URIs, http[s] - * - E.g. Can be used to query for mime-type & content length. * - * 2. To allow plugins to redirect URLs (via remapUrl). - * - All plugins should call remapUrl() on URLs they receive from JS *before* - * passing the URL onto other utility functions in this class. - * - For an example usage of this, refer to the org.apache.cordova.file plugin. + *
    + *
  1. + * Helpers for reading & writing to URLs. + *
      + *
    • E.g. handles assets, resources, content providers, files, data URIs, http[s]
    • + *
    • E.g. Can be used to query for mime-type & content length.

    • + *
    + *
  2. + *
  3. + * To allow plugins to redirect URLs (via remapUrl). + *
      + *
    • + * All plugins should call remapUrl() on URLs they receive from JS *before* passing the URL onto other utility functions in this class. + *
    • + *
    • For an example usage of this, refer to the org.apache.cordova.file plugin.
    • + *
    + *
  4. + *
* - * Future Work: - * - Consider using a Cursor to query content URLs for their size (like the file plugin does). - * - Allow plugins to remapUri to "cdv-plugin://plugin-name/foo", which CordovaResourceApi - * would then delegate to pluginManager.getPlugin(plugin-name).openForRead(url) - * - Currently, plugins *can* do this by remapping to a data: URL, but it's inefficient - * for large payloads. + *

Future Work:

+ *
    + *
  • Consider using a Cursor to query content URLs for their size (like the file plugin does).
  • + *
  • + * Allow plugins to remapUri to "cdv-plugin://plugin-name/foo", which CordovaResourceApi would then delegate to pluginManager.getPlugin(plugin-name).openForRead(url) + *
      + *
    • Currently, plugins *can* do this by remapping to a data: URL, but it's inefficient for large payloads.
    • + *
    + *
  • + *
*/ public class CordovaResourceApi { @SuppressWarnings("unused") @@ -143,8 +158,7 @@ public String remapPath(String path) { } /** - * Returns a File that points to the resource, or null if the resource - * is not on the local filesystem. + * @return A file that points to the resource, or null if the resource is not on the local filesystem. */ public File mapUriToFile(Uri uri) { assertBackgroundThread(); @@ -223,11 +237,12 @@ private String getMimeTypeFromPath(String path) { /** * Opens a stream to the given URI, also providing the MIME type & length. + * * @return Never returns null. - * @throws Throws an InvalidArgumentException for relative URIs. Relative URIs should be - * resolved before being passed into this function. - * @throws Throws an IOException if the URI cannot be opened. - * @throws Throws an IllegalStateException if called on a foreground thread. + * @throws IllegalArgumentException For relative URIs. Relative URIs should be resolved before + * being passed into this function. + * @throws IOException If the URI cannot be opened. + * @throws IllegalStateException If called on a foreground thread. */ public OpenForReadResult openForRead(Uri uri) throws IOException { return openForRead(uri, false); @@ -235,11 +250,12 @@ public OpenForReadResult openForRead(Uri uri) throws IOException { /** * Opens a stream to the given URI, also providing the MIME type & length. + * * @return Never returns null. - * @throws Throws an InvalidArgumentException for relative URIs. Relative URIs should be - * resolved before being passed into this function. - * @throws Throws an IOException if the URI cannot be opened. - * @throws Throws an IllegalStateException if called on a foreground thread and skipThreadCheck is false. + * @throws IllegalArgumentException For relative URIs. Relative URIs should be resolved before + * being passed into this function. + * @throws IOException If the URI cannot be opened. + * @throws IllegalStateException If called on a foreground thread and skipThreadCheck is false. */ public OpenForReadResult openForRead(Uri uri, boolean skipThreadCheck) throws IOException { if (!skipThreadCheck) { @@ -320,10 +336,11 @@ public OutputStream openOutputStream(Uri uri) throws IOException { /** * Opens a stream to the given URI. + * * @return Never returns null. - * @throws Throws an InvalidArgumentException for relative URIs. Relative URIs should be - * resolved before being passed into this function. - * @throws Throws an IOException if the URI cannot be opened. + * @throws IllegalArgumentException For relative URIs. Relative URIs should be resolved before + * being passed into this function. + * @throws IOException If the URI cannot be opened. */ public OutputStream openOutputStream(Uri uri, boolean append) throws IOException { assertBackgroundThread(); diff --git a/framework/src/org/apache/cordova/CordovaWebView.java b/framework/src/org/apache/cordova/CordovaWebView.java index 47247f79e..e4c7bd04f 100644 --- a/framework/src/org/apache/cordova/CordovaWebView.java +++ b/framework/src/org/apache/cordova/CordovaWebView.java @@ -25,9 +25,9 @@ Licensed to the Apache Software Foundation (ASF) under one import android.webkit.WebChromeClient.CustomViewCallback; /** - * Main interface for interacting with a Cordova webview - implemented by CordovaWebViewImpl. + * Main interface for interacting with a Cordova WebView - implemented by CordovaWebViewImpl. * This is an interface so that it can be easily mocked in tests. - * Methods may be added to this interface without a major version bump, as plugins & embedders + * Methods may be added to this interface without a major version bump, as plugins/developer * are not expected to implement it. */ public interface CordovaWebView { @@ -70,34 +70,47 @@ public interface CordovaWebView { /** * Send JavaScript statement back to JavaScript. * - * Deprecated (https://issues.apache.org/jira/browse/CB-6851) + *

Deprecated (CB-6851) * Instead of executing snippets of JS, you should use the exec bridge - * to create a Java->JS communication channel. - * To do this: - * 1. Within plugin.xml (to have your JS run before deviceready): - * - * 2. Within your .js (call exec on start-up): + * to create a Java->JS communication channel.

+ * + *

To do this:

+ * + *

1. Within plugin.xml (to have your JS run before deviceready):

+ * + *
+     * 
+     * 
+ * + *

2. Within your .js (call exec on start-up):

+ * + *
      *    require('cordova/channel').onCordovaReady.subscribe(function() {
      *      require('cordova/exec')(win, null, 'Plugin', 'method', []);
      *      function win(message) {
      *        ... process message from java here ...
      *      }
      *    });
-     * 3. Within your .java:
+     * 
+ * + *

3. Within your .java:

+ * + *
      *    PluginResult dataResult = new PluginResult(PluginResult.Status.OK, CODE);
      *    dataResult.setKeepCallback(true);
      *    savedCallbackContext.sendPluginResult(dataResult);
+     * 
*/ @Deprecated void sendJavascript(String statememt); /** - * Load the specified URL in the Cordova webview or a new browser instance. + * Load the specified URL in the Cordova WebView or a new browser instance. * - * NOTE: If openExternal is false, only allow listed URLs can be loaded. + *

NOTE: If openExternal is false, only allow listed URLs can be loaded.

* * @param url The url to load. - * @param openExternal Load url in browser instead of Cordova webview. + * @param openExternal Load url in browser instead of Cordova WebView. * @param clearHistory Clear the history stack, so new page becomes top of history * @param params Parameters for new app */ diff --git a/framework/src/org/apache/cordova/CordovaWebViewEngine.java b/framework/src/org/apache/cordova/CordovaWebViewEngine.java index c8e5a55d2..e2a45374c 100644 --- a/framework/src/org/apache/cordova/CordovaWebViewEngine.java +++ b/framework/src/org/apache/cordova/CordovaWebViewEngine.java @@ -59,7 +59,7 @@ void init(CordovaWebView parentWebView, CordovaInterface cordova, Client client, /** Clean up all resources associated with the WebView. */ void destroy(); - /** Add the evaulate Javascript method **/ + /** Add the evaluate Javascript method **/ void evaluateJavascript(String js, ValueCallback callback); /** diff --git a/framework/src/org/apache/cordova/CordovaWebViewImpl.java b/framework/src/org/apache/cordova/CordovaWebViewImpl.java index 4d5221e27..087ed3748 100644 --- a/framework/src/org/apache/cordova/CordovaWebViewImpl.java +++ b/framework/src/org/apache/cordova/CordovaWebViewImpl.java @@ -43,7 +43,7 @@ Licensed to the Apache Software Foundation (ASF) under one import java.util.Set; /** - * Main class for interacting with a Cordova webview. Manages plugins, events, and a CordovaWebViewEngine. + * Main class for interacting with a Cordova WebView. Manages plugins, events, and a CordovaWebViewEngine. * Class uses two-phase initialization. You must call init() before calling any other methods. */ public class CordovaWebViewImpl implements CordovaWebView { @@ -154,7 +154,7 @@ public void run() { stopLoading(); LOG.e(TAG, "CordovaWebView: TIMEOUT ERROR!"); - // Handle other errors by passing them to the webview in JS + // Handle other errors by passing them to the WebView in JS JSONObject data = new JSONObject(); try { data.put("errorCode", -6); @@ -219,7 +219,7 @@ public void showWebPage(String url, boolean openExternal, boolean clearHistory, engine.clearHistory(); } - // If loading into our webview + // If loading into our WebView if (!openExternal) { // Make sure url is in allow list if (pluginManager.shouldAllowNavigation(url)) { @@ -487,7 +487,7 @@ public void handlePause(boolean keepRunning) { // If app doesn't want to run in background if (!keepRunning) { - // Pause JavaScript timers. This affects all webviews within the app! + // Pause JavaScript timers. This affects all WebViews within the app! engine.setPaused(true); } } @@ -497,7 +497,7 @@ public void handleResume(boolean keepRunning) { return; } - // Resume JavaScript timers. This affects all webviews within the app! + // Resume JavaScript timers. This affects all WebViews within the app! engine.setPaused(false); this.pluginManager.onResume(keepRunning); @@ -537,7 +537,7 @@ public void handleDestroy() { // We should use a blank data: url instead so it's more obvious this.loadUrl("about:blank"); - // TODO: Should not destroy webview until after about:blank is done loading. + // TODO: Should not destroy WebView until after about:blank is done loading. engine.destroy(); hideCustomView(); } diff --git a/framework/src/org/apache/cordova/CoreAndroid.java b/framework/src/org/apache/cordova/CoreAndroid.java index 36b28b2da..158e46dbb 100755 --- a/framework/src/org/apache/cordova/CoreAndroid.java +++ b/framework/src/org/apache/cordova/CoreAndroid.java @@ -69,8 +69,9 @@ public void pluginInitialize() { * Executes the request and returns PluginResult. * * @param action The action to execute. - * @param args JSONArry of arguments for the plugin. + * @param args JSONArray of arguments for the plugin. * @param callbackContext The callback context from which we were invoked. + * * @return A PluginResult object with a status and message. */ @Override @@ -83,9 +84,9 @@ public boolean execute(String action, JSONArray args, CallbackContext callbackCo this.clearCache(); } else if (action.equals("show")) { - // This gets called from JavaScript onCordovaReady to show the webview. + // This gets called from JavaScript onCordovaReady to show the WebView. // I recommend we change the name of the Message as spinner/stop is not - // indicative of what this actually does (shows the webview). + // indicative of what this actually does (shows the WebView). cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { @@ -154,7 +155,7 @@ public void run() { } /** - * Load the url into the webview. + * Load the url into the WebView. * * @param url * @param props Properties that can be passed in to the Cordova activity (i.e. loadingDialog, wait, ...) @@ -354,9 +355,8 @@ private void sendEventMessage(PluginResult payload) { } } - /* + /** * Unregister the receiver - * */ @Override public void onDestroy() diff --git a/framework/src/org/apache/cordova/ICordovaClientCertRequest.java b/framework/src/org/apache/cordova/ICordovaClientCertRequest.java index 1417a156c..601be9b9f 100644 --- a/framework/src/org/apache/cordova/ICordovaClientCertRequest.java +++ b/framework/src/org/apache/cordova/ICordovaClientCertRequest.java @@ -31,32 +31,32 @@ public interface ICordovaClientCertRequest { */ public void cancel(); - /* - * Returns the host name of the server requesting the certificate. + /** + * @return the host name of the server requesting the certificate. */ public String getHost(); - /* - * Returns the acceptable types of asymmetric keys (can be null). + /** + * @return the acceptable types of asymmetric keys (can be null). */ public String[] getKeyTypes(); - /* - * Returns the port number of the server requesting the certificate. + /** + * @return the port number of the server requesting the certificate. */ public int getPort(); - /* - * Returns the acceptable certificate issuers for the certificate matching the private key (can be null). + /** + * @return the acceptable certificate issuers for the certificate matching the private key (can be null). */ public Principal[] getPrincipals(); - /* + /** * Ignore the request for now. Do not remember user's choice. */ public void ignore(); - /* + /** * Proceed with the specified private key and client certificate chain. Remember the user's positive choice and use it for future requests. * * @param privateKey The privateKey diff --git a/framework/src/org/apache/cordova/LOG.java b/framework/src/org/apache/cordova/LOG.java index 9fe7a7dfc..758eaba02 100755 --- a/framework/src/org/apache/cordova/LOG.java +++ b/framework/src/org/apache/cordova/LOG.java @@ -23,8 +23,8 @@ Licensed to the Apache Software Foundation (ASF) under one /** * Log to Android logging system. * - * Log message can be a string or a printf formatted string with arguments. - * See http://developer.android.com/reference/java/util/Formatter.html + *

Log message can be a string or a printf formatted string with arguments. + * See Formatter

*/ public class LOG { diff --git a/framework/src/org/apache/cordova/NativeToJsMessageQueue.java b/framework/src/org/apache/cordova/NativeToJsMessageQueue.java index 6e6f2a734..60a1acb4f 100755 --- a/framework/src/org/apache/cordova/NativeToJsMessageQueue.java +++ b/framework/src/org/apache/cordova/NativeToJsMessageQueue.java @@ -124,12 +124,10 @@ private void packMessage(JsMessage message, StringBuilder sb) { } /** - * Combines and returns queued messages combined into a single string. - * * Combines as many messages as possible, without exceeding * COMBINED_RESPONSE_CUTOFF in case of multiple response messages. * - * Returns null if the queue is empty. + * @return a string of queued messages combined or null if the queue is empty. */ public String popAndEncode(boolean fromOnlineEvent) { synchronized (this) { diff --git a/framework/src/org/apache/cordova/PermissionHelper.java b/framework/src/org/apache/cordova/PermissionHelper.java index b2e4023c1..bac8b8fe5 100644 --- a/framework/src/org/apache/cordova/PermissionHelper.java +++ b/framework/src/org/apache/cordova/PermissionHelper.java @@ -66,7 +66,6 @@ public static void requestPermissions(CordovaPlugin plugin, int requestCode, Str * * @param plugin The plugin the permission is being checked against * @param permission The permission to be checked - * * @return True if the permission has already been granted and false otherwise */ public static boolean hasPermission(CordovaPlugin plugin, String permission) { diff --git a/framework/src/org/apache/cordova/PluginEntry.java b/framework/src/org/apache/cordova/PluginEntry.java index 389cc2493..1b5199596 100755 --- a/framework/src/org/apache/cordova/PluginEntry.java +++ b/framework/src/org/apache/cordova/PluginEntry.java @@ -48,36 +48,36 @@ public final class PluginEntry { /** * Constructs with a CordovaPlugin already instantiated. * - * @param service The name of the service - * @param pluginClass The plugin class name + * @param service The name of the service + * @param plugin The plugin class name */ public PluginEntry(String service, CordovaPlugin plugin) { this(service, plugin.getClass().getName(), true, plugin); } /** - * @param service The name of the service - * @param plugin The CordovaPlugin already instantiated - * @param onload Create plugin object when HTML page is loaded + * @param service The name of the service + * @param plugin The CordovaPlugin already instantiated + * @param onload Create plugin object when HTML page is loaded */ public PluginEntry(String service, CordovaPlugin plugin, boolean onload) { this(service, plugin.getClass().getName(), onload, plugin); } /** - * @param service The name of the service - * @param pluginClass The plugin class name - * @param onload Create plugin object when HTML page is loaded + * @param service The name of the service + * @param pluginClass The plugin class name + * @param onload Create plugin object when HTML page is loaded */ public PluginEntry(String service, String pluginClass, boolean onload) { this(service, pluginClass, onload, null); } /** - * @param service The name of the service - * @param pluginClass The plugin class name - * @param onload Create plugin object when HTML page is loaded - * @param plugin The CordovaPlugin already instantiated + * @param service The name of the service + * @param pluginClass The plugin class name + * @param onload Create plugin object when HTML page is loaded + * @param plugin The CordovaPlugin already instantiated */ private PluginEntry(String service, String pluginClass, boolean onload, CordovaPlugin plugin) { this.service = service; diff --git a/framework/src/org/apache/cordova/PluginManager.java b/framework/src/org/apache/cordova/PluginManager.java index 255eacd0a..24560c2f3 100755 --- a/framework/src/org/apache/cordova/PluginManager.java +++ b/framework/src/org/apache/cordova/PluginManager.java @@ -38,8 +38,8 @@ Licensed to the Apache Software Foundation (ASF) under one /** * PluginManager is exposed to JavaScript in the Cordova WebView. * - * Calling native plugin code can be done by calling PluginManager.exec(...) - * from JavaScript. + *

Calling native plugin code can be done by calling PluginManager.exec(...) + * from JavaScript.

*/ public class PluginManager { private static String TAG = "PluginManager"; @@ -87,7 +87,7 @@ public void setPluginEntries(Collection pluginEntries) { } /** - * Init when loading a new HTML page into webview. + * Init when loading a new HTML page into WebView. */ public void init() { LOG.d(TAG, "init()"); @@ -121,9 +121,9 @@ private void startupPlugins() { * Receives a request for execution and fulfills it by finding the appropriate * Java class and calling it's execute method. * - * PluginManager.exec can be used either synchronously or async. In either case, a JSON encoded + *

PluginManager.exec can be used either synchronously or async. In either case, a JSON encoded * string is returned that will indicate if any errors have occurred when trying to find - * or execute the class denoted by the clazz argument. + * or execute the class denoted by the clazz argument.

* * @param service String containing the service to run * @param action String containing the action that the class is supposed to perform. This is @@ -252,9 +252,7 @@ public void onPause(boolean multitasking) { * @param handler The HttpAuthHandler used to set the WebView's response * @param host The host requiring authentication * @param realm The realm for which authentication is required - * - * @return Returns True if there is a plugin which will resolve this auth challenge, otherwise False - * + * @return True if there is a plugin which will resolve this auth challenge, otherwise False */ public boolean onReceivedHttpAuthRequest(CordovaWebView view, ICordovaHttpAuthHandler handler, String host, String realm) { synchronized (this.pluginMap) { @@ -273,9 +271,7 @@ public boolean onReceivedHttpAuthRequest(CordovaWebView view, ICordovaHttpAuthHa * * @param view The WebView that is initiating the callback * @param request The client certificate request - * - * @return Returns True if plugin will resolve this auth challenge, otherwise False - * + * @return True if plugin will resolve this auth challenge, otherwise False */ public boolean onReceivedClientCertRequest(CordovaWebView view, ICordovaClientCertRequest request) { synchronized (this.pluginMap) { @@ -375,12 +371,14 @@ public void onNewIntent(Intent intent) { } /** - * @todo should we move this somewhere public and accessible by all plugins? - * For now, it is placed where it is used and kept private so we can decide later and move without causing a breaking change. - * An ideal location might be in the "ConfigXmlParser" at the time it generates the "launchUrl". + * TODO: should we move this somewhere public and accessible by all plugins? + * + *

For now, it is placed where it is used and kept private so we can decide later and move without causing a breaking change. + * An ideal location might be in the "ConfigXmlParser" at the time it generates the "launchUrl".

+ * + * TODO: should we be restrictive on the "file://" return? e.g. "file:///android_asset/www/" * - * @todo should we be restrictive on the "file://" return? e.g. "file:///android_asset/www/" - * Would be considered as a breaking change if we apply a more granular check. + *

Would be considered as a breaking change if we apply a more granular check.

*/ private String getLaunchUrlPrefix() { if (!app.getPreferences().getBoolean("AndroidInsecureFileModeEnabled", false)) { @@ -393,14 +391,14 @@ private String getLaunchUrlPrefix() { } /** - * Called when the webview is going to request an external resource. + * Called when the WebView is going to request an external resource. * - * This delegates to the installed plugins, and returns true/false for the + *

This delegates to the installed plugins, and returns true/false for the * first plugin to provide a non-null result. If no plugins respond, then - * the default policy is applied. + * the default policy is applied.

* * @param url The URL that is being requested. - * @return Returns true to allow the resource to load, + * @return true to allow the resource to load, * false to block the resource. */ public boolean shouldAllowRequest(String url) { @@ -425,7 +423,7 @@ public boolean shouldAllowRequest(String url) { return true; } if (url.startsWith("file://")) { - //This directory on WebKit/Blink based webviews contains SQLite databases! + //This directory on WebKit/Blink based WebViews contains SQLite databases! //DON'T CHANGE THIS UNLESS YOU KNOW WHAT YOU'RE DOING! return !url.contains("/app_webview/"); } @@ -433,14 +431,14 @@ public boolean shouldAllowRequest(String url) { } /** - * Called when the webview is going to change the URL of the loaded content. + * Called when the WebView is going to change the URL of the loaded content. * - * This delegates to the installed plugins, and returns true/false for the + *

This delegates to the installed plugins, and returns true/false for the * first plugin to provide a non-null result. If no plugins respond, then - * the default policy is applied. + * the default policy is applied.

* * @param url The URL that is being requested. - * @return Returns true to allow the navigation, + * @return true to allow the navigation, * false to block the navigation. */ public boolean shouldAllowNavigation(String url) { @@ -462,7 +460,7 @@ public boolean shouldAllowNavigation(String url) { /** - * Called when the webview is requesting the exec() bridge be enabled. + * Called when the WebView is requesting the exec() bridge be enabled. */ public boolean shouldAllowBridgeAccess(String url) { synchronized (this.entryMap) { @@ -482,15 +480,15 @@ public boolean shouldAllowBridgeAccess(String url) { } /** - * Called when the webview is going not going to navigate, but may launch + * Called when the WebView is going not going to navigate, but may launch * an Intent for an URL. * - * This delegates to the installed plugins, and returns true/false for the + *

This delegates to the installed plugins, and returns true/false for the * first plugin to provide a non-null result. If no plugins respond, then - * the default policy is applied. + * the default policy is applied.

* * @param url The URL that is being requested. - * @return Returns true to allow the URL to launch an intent, + * @return true to allow the URL to launch an intent, * false to block the intent. */ public Boolean shouldOpenExternalUrl(String url) { @@ -511,7 +509,7 @@ public Boolean shouldOpenExternalUrl(String url) { } /** - * Called when the URL of the webview changes. + * Called when the URL of the WebView changes. * * @param url The URL that is being changed to. * @return Return false to allow the URL to load, return true to prevent the URL from loading. @@ -623,9 +621,9 @@ public ArrayList getPluginPathHandlers() { /** * Called when the WebView's render process has exited. * - * See https://developer.android.com/reference/android/webkit/WebViewClient#onRenderProcessGone(android.webkit.WebView,%20android.webkit.RenderProcessGoneDetail) + *

See WebViewClient#onRenderProcessGone

* - * @return true if the host application handled the situation that process has exited, + * @return true if the host application handled the situation that process has exited, * otherwise, application will crash if render process crashed, or be killed * if render process was killed by the system. */ diff --git a/framework/src/org/apache/cordova/PluginResult.java b/framework/src/org/apache/cordova/PluginResult.java index 5db60b3b7..a9696fb4b 100644 --- a/framework/src/org/apache/cordova/PluginResult.java +++ b/framework/src/org/apache/cordova/PluginResult.java @@ -118,8 +118,7 @@ public PluginResult getMultipartMessage(int index) { } /** - * If messageType == MESSAGE_TYPE_STRING, then returns the message string. - * Otherwise, returns null. + * @return message string when messageType is MESSAGE_TYPE_STRING otherwise null. */ public String getStrMessage() { return strMessage; diff --git a/framework/src/org/apache/cordova/SplashScreenPlugin.java b/framework/src/org/apache/cordova/SplashScreenPlugin.java index 425b13f9b..8f02d5219 100644 --- a/framework/src/org/apache/cordova/SplashScreenPlugin.java +++ b/framework/src/org/apache/cordova/SplashScreenPlugin.java @@ -45,25 +45,25 @@ public class SplashScreenPlugin extends CordovaPlugin { // Config preference values /** - * @param boolean autoHide to auto splash screen (default=true) + * Boolean flag to auto hide splash screen (default=true) */ private boolean autoHide; /** - * @param int delayTime in milliseconds (default=-1) + * Integer value of how long to delay in milliseconds (default=-1) */ private int delayTime; /** - * @param int fade to fade out splash screen (default=true) + * Boolean flag if to fade to fade out splash screen (default=true) */ private boolean isFadeEnabled; /** - * @param int fadeDuration fade out duration in milliseconds (default=500) + * Integer value of the fade duration in milliseconds (default=500) */ private int fadeDuration; // Internal variables /** - * @param boolean keepOnScreen flag to determine if the splash screen remains visible. + * Boolean flag to determine if the splash screen remains visible. */ private boolean keepOnScreen = true; diff --git a/framework/src/org/apache/cordova/engine/SystemWebChromeClient.java b/framework/src/org/apache/cordova/engine/SystemWebChromeClient.java index 8a48e3510..6ed2bdaa9 100755 --- a/framework/src/org/apache/cordova/engine/SystemWebChromeClient.java +++ b/framework/src/org/apache/cordova/engine/SystemWebChromeClient.java @@ -119,8 +119,8 @@ public void gotResult(boolean success, String value) { * If the client returns true, WebView will assume that the client will * handle the prompt dialog and call the appropriate JsPromptResult method. * - * Since we are hacking prompts for our own purposes, we should not be using them for - * this purpose, perhaps we should hack console.log to do this instead! + *

Since we are hacking prompts for our own purposes, we should not be using them for + * this purpose, perhaps we should hack console.log to do this instead!

*/ @Override public boolean onJsPrompt(WebView view, String origin, String message, String defaultValue, final JsPromptResult result) { @@ -155,15 +155,15 @@ public void onExceededDatabaseQuota(String url, String databaseIdentifier, long quotaUpdater.updateQuota(MAX_QUOTA); } - @Override /** * Instructs the client to show a prompt to ask the user to set the Geolocation permission state for the specified origin. * - * This also checks for the Geolocation Plugin and requests permission from the application to use Geolocation. + *

This also checks for the Geolocation Plugin and requests permission from the application to use Geolocation.

* * @param origin * @param callback */ + @Override public void onGeolocationPermissionsShowPrompt(String origin, Callback callback) { super.onGeolocationPermissionsShowPrompt(origin, callback); callback.invoke(origin, true, false); @@ -188,12 +188,13 @@ public void onHideCustomView() { parentEngine.getCordovaWebView().hideCustomView(); } - @Override /** * Ask the host application for a custom progress view to show while * a