diff --git a/.yarn/install-state.gz b/.yarn/install-state.gz index a69c659..c667523 100644 Binary files a/.yarn/install-state.gz and b/.yarn/install-state.gz differ diff --git a/apps/expo-multi-tv/app.json b/apps/expo-multi-tv/app.json index ed3fff0..3200b08 100644 --- a/apps/expo-multi-tv/app.json +++ b/apps/expo-multi-tv/app.json @@ -2,7 +2,8 @@ "expo": { "plugins": [ "./plugins/withKotlinJvmTarget", - "@bam.tech/react-native-keyevent-expo-config-plugin", + "./plugins/withKeyEvent", + "./plugins/withTvosDeploymentTarget", [ "@react-native-tvos/config-tv", { @@ -22,14 +23,13 @@ "expo-build-properties", { "ios": { - "newArchEnabled": false + "deploymentTarget": "15.1" }, "android": { - "newArchEnabled": false, - "kotlinVersion": "1.9.24", - "compileSdkVersion": 34, + "kotlinVersion": "2.0.21", + "compileSdkVersion": 36, "targetSdkVersion": 34, - "minSdkVersion": 23 + "minSdkVersion": 24 } } ], @@ -57,6 +57,7 @@ }, "ios": { "bundleIdentifier": "com.anonymous.MultiTVSample" - } + }, + "newArchEnabled": false } } diff --git a/apps/expo-multi-tv/package.json b/apps/expo-multi-tv/package.json index 8ee913c..afe432e 100644 --- a/apps/expo-multi-tv/package.json +++ b/apps/expo-multi-tv/package.json @@ -19,7 +19,6 @@ "preset": "jest-expo" }, "dependencies": { - "@bam.tech/react-native-keyevent-expo-config-plugin": "^1.0.50", "@expo/metro-runtime": "~4.0.0", "@expo/vector-icons": "^14.0.0", "@multi-tv/shared-ui": "workspace:*", diff --git a/apps/expo-multi-tv/plugins/withKeyEvent.js b/apps/expo-multi-tv/plugins/withKeyEvent.js new file mode 100644 index 0000000..4a140df --- /dev/null +++ b/apps/expo-multi-tv/plugins/withKeyEvent.js @@ -0,0 +1,68 @@ +const { withMainActivity } = require("expo/config-plugins"); +const { + mergeContents, +} = require("@expo/config-plugins/build/utils/generateCode"); + +const withAndroidMainActivityImport = (config) => { + return withMainActivity(config, (config) => { + const newSrc = [ + "import android.view.KeyEvent", + "import com.github.kevinejohn.keyevent.KeyEventModule", + ]; + const newConfig = mergeContents({ + tag: "react-native-keyevent-import", + src: config.modResults.contents, + newSrc: newSrc.join("\n"), + anchor: `import`, + offset: 1, + comment: "//", + }); + return { + ...config, + modResults: newConfig, + }; + }); +}; + +const withAndroidMainActivityBody = (config) => { + return withMainActivity(config, (config) => { + const newSrc = [ + "override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {", + " KeyEventModule.getInstance().onKeyDownEvent(keyCode, event)", + " super.onKeyDown(keyCode, event)", + " return true", + "}", + "", + "override fun onKeyUp(keyCode: Int, event: KeyEvent): Boolean {", + " KeyEventModule.getInstance().onKeyUpEvent(keyCode, event)", + " super.onKeyUp(keyCode, event)", + " return true", + "}", + "", + "override fun onKeyMultiple(keyCode: Int, repeatCount: Int, event: KeyEvent): Boolean {", + " KeyEventModule.getInstance().onKeyMultipleEvent(keyCode, repeatCount, event)", + " return super.onKeyMultiple(keyCode, repeatCount, event)", + "}", + ]; + const newConfig = mergeContents({ + tag: "react-native-keyevent-body", + src: config.modResults.contents, + newSrc: newSrc.join("\n"), + anchor: `class MainActivity`, + offset: 1, + comment: "//", + }); + return { + ...config, + modResults: newConfig, + }; + }); +}; + +function withKeyEvent(config) { + config = withAndroidMainActivityImport(config); + config = withAndroidMainActivityBody(config); + return config; +} + +module.exports = withKeyEvent; diff --git a/apps/expo-multi-tv/plugins/withKotlinJvmTarget.js b/apps/expo-multi-tv/plugins/withKotlinJvmTarget.js index f80ffb2..c0fe669 100644 --- a/apps/expo-multi-tv/plugins/withKotlinJvmTarget.js +++ b/apps/expo-multi-tv/plugins/withKotlinJvmTarget.js @@ -6,33 +6,20 @@ function withKotlinJvmTarget(config) { return withDangerousMod(config, [ "android", async (config) => { - const buildGradlePath = path.join( + const rootBuildGradle = path.join( config.modRequest.platformProjectRoot, - "react-settings-plugin", - "build.gradle.kts" + "build.gradle" ); - if (fs.existsSync(buildGradlePath)) { - let contents = fs.readFileSync(buildGradlePath, "utf-8"); + if (fs.existsSync(rootBuildGradle)) { + let contents = fs.readFileSync(rootBuildGradle, "utf-8"); - if (!contents.includes("sourceCompatibility")) { - const jvmConfig = ` -java { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 -} - -tasks.withType { - kotlinOptions { - jvmTarget = "17" - } -} -`; + if (!contents.includes("ext.kotlinVersion")) { contents = contents.replace( - /repositories\s*\{\s*mavenCentral\(\)\s*\}/, - (match) => match + "\n" + jvmConfig + "buildscript {", + 'buildscript {\n ext.kotlinVersion = findProperty("android.kotlinVersion") ?: "2.0.21"' ); - fs.writeFileSync(buildGradlePath, contents); + fs.writeFileSync(rootBuildGradle, contents); } } diff --git a/apps/expo-multi-tv/plugins/withTvosDeploymentTarget.js b/apps/expo-multi-tv/plugins/withTvosDeploymentTarget.js new file mode 100644 index 0000000..775d16c --- /dev/null +++ b/apps/expo-multi-tv/plugins/withTvosDeploymentTarget.js @@ -0,0 +1,19 @@ +const { withXcodeProject } = require("expo/config-plugins"); + +function withTvosDeploymentTarget(config) { + return withXcodeProject(config, (config) => { + const project = config.modResults; + const configurations = project.pbxXCBuildConfigurationSection(); + + for (const key in configurations) { + const buildSettings = configurations[key].buildSettings; + if (buildSettings && buildSettings.TVOS_DEPLOYMENT_TARGET) { + buildSettings.TVOS_DEPLOYMENT_TARGET = "15.1"; + } + } + + return config; + }); +} + +module.exports = withTvosDeploymentTarget; diff --git a/yarn.lock b/yarn.lock index 0da28e3..2b4f5a4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2094,17 +2094,6 @@ __metadata: languageName: node linkType: hard -"@bam.tech/react-native-keyevent-expo-config-plugin@npm:^1.0.50": - version: 1.0.52 - resolution: "@bam.tech/react-native-keyevent-expo-config-plugin@npm:1.0.52" - dependencies: - "@expo/config-plugins": "npm:~8.0.0" - peerDependencies: - expo: ^51.0.9 - checksum: 10c0/860ef6908ae57e65fc9c6c01ce606b39c2e96ea69d59436f5dcb0742af64dbec4f4e7011b8f03e104617f804d81e123d19d9d2ed868d7d29c5b85f589fc3373a - languageName: node - linkType: hard - "@bcoe/v8-coverage@npm:^0.2.3": version: 0.2.3 resolution: "@bcoe/v8-coverage@npm:0.2.3" @@ -2549,29 +2538,6 @@ __metadata: languageName: node linkType: hard -"@expo/config-plugins@npm:~8.0.0": - version: 8.0.11 - resolution: "@expo/config-plugins@npm:8.0.11" - dependencies: - "@expo/config-types": "npm:^51.0.3" - "@expo/json-file": "npm:~8.3.0" - "@expo/plist": "npm:^0.1.0" - "@expo/sdk-runtime-versions": "npm:^1.0.0" - chalk: "npm:^4.1.2" - debug: "npm:^4.3.1" - find-up: "npm:~5.0.0" - getenv: "npm:^1.0.0" - glob: "npm:7.1.6" - resolve-from: "npm:^5.0.0" - semver: "npm:^7.5.4" - slash: "npm:^3.0.0" - slugify: "npm:^1.6.6" - xcode: "npm:^3.0.1" - xml2js: "npm:0.6.0" - checksum: 10c0/0dac5afd845c050334afb816fca447df96e27fc004bd99873e2f8ffed0ad8e7fc2e9bbb2877589b5ea6fc73c35144dc7bf174ca46cacfa14b1baf93a094e350d - languageName: node - linkType: hard - "@expo/config-plugins@npm:~9.0.17": version: 9.0.17 resolution: "@expo/config-plugins@npm:9.0.17" @@ -2594,13 +2560,6 @@ __metadata: languageName: node linkType: hard -"@expo/config-types@npm:^51.0.3": - version: 51.0.3 - resolution: "@expo/config-types@npm:51.0.3" - checksum: 10c0/bd87a729da985b0097ab29367c0473a2bced5ff211d416f342729e1b2631a7c00d62878e05cdee49ece7e3b65d3296957917f24380d57e2faef2cf220194fdec - languageName: node - linkType: hard - "@expo/config-types@npm:^52.0.5": version: 52.0.5 resolution: "@expo/config-types@npm:52.0.5" @@ -2784,17 +2743,6 @@ __metadata: languageName: node linkType: hard -"@expo/json-file@npm:~8.3.0": - version: 8.3.3 - resolution: "@expo/json-file@npm:8.3.3" - dependencies: - "@babel/code-frame": "npm:~7.10.4" - json5: "npm:^2.2.2" - write-file-atomic: "npm:^2.3.0" - checksum: 10c0/3b1b593a2fe6cb297713fbe2d1002bbc8d469fc55219343bffcce1b1abe941aace1b239d0afc1a3cf15b7ceed91e8da4ca36cb83b586f3bf9f05856e1ad560d3 - languageName: node - linkType: hard - "@expo/json-file@npm:~9.0.2": version: 9.0.2 resolution: "@expo/json-file@npm:9.0.2" @@ -2894,17 +2842,6 @@ __metadata: languageName: node linkType: hard -"@expo/plist@npm:^0.1.0": - version: 0.1.3 - resolution: "@expo/plist@npm:0.1.3" - dependencies: - "@xmldom/xmldom": "npm:~0.7.7" - base64-js: "npm:^1.2.3" - xmlbuilder: "npm:^14.0.0" - checksum: 10c0/134315260a7828bc1ce4563e2af67499b498feae46c39c5c2cab9d72082402a42d3b7575f13e269022bcf3c28668948ea960dd4943bd38f52f9c01154317aac5 - languageName: node - linkType: hard - "@expo/plist@npm:^0.2.2": version: 0.2.2 resolution: "@expo/plist@npm:0.2.2" @@ -3828,7 +3765,6 @@ __metadata: resolution: "@multi-tv/expo-multi-tv@workspace:apps/expo-multi-tv" dependencies: "@babel/core": "npm:^7.20.0" - "@bam.tech/react-native-keyevent-expo-config-plugin": "npm:^1.0.50" "@commitlint/cli": "npm:^19.5.0" "@commitlint/config-conventional": "npm:^19.5.0" "@expo/metro-runtime": "npm:~4.0.0" @@ -9742,7 +9678,7 @@ __metadata: languageName: node linkType: hard -"find-up@npm:^5.0.0, find-up@npm:~5.0.0": +"find-up@npm:^5.0.0": version: 5.0.0 resolution: "find-up@npm:5.0.0" dependencies: @@ -10226,20 +10162,6 @@ __metadata: languageName: node linkType: hard -"glob@npm:7.1.6": - version: 7.1.6 - resolution: "glob@npm:7.1.6" - dependencies: - fs.realpath: "npm:^1.0.0" - inflight: "npm:^1.0.4" - inherits: "npm:2" - minimatch: "npm:^3.0.4" - once: "npm:^1.3.0" - path-is-absolute: "npm:^1.0.0" - checksum: 10c0/2575cce9306ac534388db751f0aa3e78afedb6af8f3b529ac6b2354f66765545145dba8530abf7bff49fb399a047d3f9b6901c38ee4c9503f592960d9af67763 - languageName: node - linkType: hard - "glob@npm:^10.3.10, glob@npm:^10.4.2": version: 10.5.0 resolution: "glob@npm:10.5.0" @@ -12901,7 +12823,7 @@ __metadata: languageName: node linkType: hard -"json5@npm:^2.2.1, json5@npm:^2.2.2, json5@npm:^2.2.3": +"json5@npm:^2.2.1, json5@npm:^2.2.3": version: 2.2.3 resolution: "json5@npm:2.2.3" bin: @@ -19639,11 +19561,11 @@ __metadata: "typescript@patch:typescript@npm%3A~5.7.0#optional!builtin": version: 5.7.3 - resolution: "typescript@patch:typescript@npm%3A5.7.3#optional!builtin::version=5.7.3&hash=8c6c40" + resolution: "typescript@patch:typescript@npm%3A5.7.3#optional!builtin::version=5.7.3&hash=5786d5" bin: tsc: bin/tsc tsserver: bin/tsserver - checksum: 10c0/3b56d6afa03d9f6172d0b9cdb10e6b1efc9abc1608efd7a3d2f38773d5d8cfb9bbc68dfb72f0a7de5e8db04fc847f4e4baeddcd5ad9c9feda072234f0d788896 + checksum: 10c0/6fd7e0ed3bf23a81246878c613423730c40e8bdbfec4c6e4d7bf1b847cbb39076e56ad5f50aa9d7ebd89877999abaee216002d3f2818885e41c907caaa192cc4 languageName: node linkType: hard