@react-native-tvos/config-tv 0.0.9 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -39,6 +39,7 @@ or
39
39
  "tvosDeploymentTarget": "13.4",
40
40
  "removeFlipperOnAndroid": true,
41
41
  "androidTVBanner": "assets/images/tv_banner.png",
42
+ "androidTVIcon": "assets/images/tv_icon.png",
42
43
  "appleTVImages": {
43
44
  "icon": "./assets/images/myimage-tvos-1280x768.png",
44
45
  "iconSmall": "./assets/images/myimage-tvos-400x240.png",
@@ -68,6 +69,7 @@ _Plugin parameters_:
68
69
  - `removeFlipperOnAndroid`: (optional boolean, default true) Used to remove the Flipper dependency from `MainApplication.kt` (or `MainApplication.java`) and `android/app/build.gradle`. This is necessary for React Native TV 0.73 and higher, since Flipper integration is removed from these versions. If this causes issues, set the value to false, run `npx expo prebuild --clean` again, and then remove Flipper from your Android source manually. This change will be made regardless of the setting of the `EXPO_TV` environment variable or the value of the `isTV` plugin parameter, as it is needed for both Android mobile and Android TV.
69
70
  - `androidTVRequired`: (optional boolean, default false) If set, the Android manifest will be configured for Android TV only (no Android mobile support). Specifically, the "uses-feature" tag for "android.software.leanback" will be set to "required=true".
70
71
  - `androidTVBanner`: (optional string) If set, this should be a path to an existing PNG file appropriate for an Android TV banner image. See https://developer.android.com/design/ui/tv/guides/system/tv-app-icon-guidelines#banner . The Android manifest will be modified to reference this image, and the image will be copied into Android resource drawable directories.
72
+ - `androidTVIcon`: (optional string) If set, this should be a path to an existing PNG file appropriate for an Android TV icon image. See https://developer.android.com/design/ui/tv/guides/system/tv-app-icon-guidelines#launcher-icon . The Android manifest will be modified to reference this image, and the image will be copied into Android resource drawable and mipmap directories.
71
73
  - `appleTVImages`: (optional object) If set, this is an object with the paths to images needed to construct the Apple TV icon and top shelf brand assets. The images will be used to construct a brand asset catalog in the Xcode project Image catalog, and the project updated to use the brand assets as the source for the app icons. If this property is set, all image paths must be defined and the files must exist, or an error will be thrown. The images need to be the exact sizes shown here, in order to avoid errors during Xcode compilation and on submission to the App Store or TestFlight.
72
74
  - `icon`: (string) Path to a 1280x760 image
73
75
  - `iconSmall`: (string) Path to a 400x240 image
package/build/types.d.ts CHANGED
@@ -69,6 +69,14 @@ export type ConfigData = {
69
69
  * Android resource drawable directories.
70
70
  */
71
71
  androidTVBanner?: string;
72
+ /**
73
+ * If set, this should be a path to an existing PNG file appropriate for an Android TV icon image.
74
+ * See https://developer.android.com/design/ui/tv/guides/system/tv-app-icon-guidelines#launcher-icon
75
+ * The icon image will not be resized.
76
+ * The Android manifest will be modified to reference this image and the image will be copied into
77
+ * Android resource drawable directories.
78
+ */
79
+ androidTVIcon?: string;
72
80
  /**
73
81
  * If set, this is an object with the paths to images needed to construct the Apple TV icon and
74
82
  * top shelf brand assets. The images will be used to construct a brand asset catalog in the Xcode
@@ -5,5 +5,6 @@ export declare function tvosDeploymentTarget(params: ConfigData): string;
5
5
  export declare function shouldRemoveFlipperOnAndroid(params: ConfigData): boolean;
6
6
  export declare function isAndroidTVRequired(params: ConfigData): boolean;
7
7
  export declare function androidTVBanner(params: ConfigData): string | undefined;
8
+ export declare function androidTVIcon(params: ConfigData): string | undefined;
8
9
  export declare const appleTVImageTypes: string[];
9
10
  export declare function appleTVImagePathForType(params: ConfigData, imageType: string): string | undefined;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.appleTVImagePathForType = exports.appleTVImageTypes = exports.androidTVBanner = exports.isAndroidTVRequired = exports.shouldRemoveFlipperOnAndroid = exports.tvosDeploymentTarget = exports.isTVEnabled = exports.packageNameAndVersion = void 0;
3
+ exports.appleTVImagePathForType = exports.appleTVImageTypes = exports.androidTVIcon = exports.androidTVBanner = exports.isAndroidTVRequired = exports.shouldRemoveFlipperOnAndroid = exports.tvosDeploymentTarget = exports.isTVEnabled = exports.packageNameAndVersion = void 0;
4
4
  const getenv_1 = require("getenv");
5
5
  class Env {
6
6
  /** Enable prebuild for TV */
@@ -32,6 +32,10 @@ function androidTVBanner(params) {
32
32
  return params?.androidTVBanner;
33
33
  }
34
34
  exports.androidTVBanner = androidTVBanner;
35
+ function androidTVIcon(params) {
36
+ return params?.androidTVIcon;
37
+ }
38
+ exports.androidTVIcon = androidTVIcon;
35
39
  exports.appleTVImageTypes = [
36
40
  'icon',
37
41
  'iconSmall',
package/build/withTV.js CHANGED
@@ -9,6 +9,7 @@ const withTVSplashScreen_1 = require("./withTVSplashScreen");
9
9
  const withTVXcodeProject_1 = require("./withTVXcodeProject");
10
10
  const withTVAndroidRemoveFlipper_1 = require("./withTVAndroidRemoveFlipper");
11
11
  const withTVAndroidBannerImage_1 = require("./withTVAndroidBannerImage");
12
+ const withTVAndroidIconImage_1 = require("./withTVAndroidIconImage");
12
13
  const utils_1 = require("./utils");
13
14
  const withTVNoEffect = (config, params = {}) => {
14
15
  (0, utils_1.verboseLog)(`${utils_1.packageNameAndVersion}: isTV == false, TV-specific modifications will not be made.`, {});
@@ -29,6 +30,7 @@ const withTVPlugin = (config, params = {}) => {
29
30
  config = (0, withTVInfoPlist_1.withTVInfoPlist)(config, params);
30
31
  config = (0, withTVSplashScreen_1.withTVSplashScreen)(config, params);
31
32
  config = (0, withTVAndroidBannerImage_1.withTVAndroidBannerImage)(config, params); // This should be done before Android manifest config
33
+ config = (0, withTVAndroidIconImage_1.withTVAndroidIconImage)(config, params);
32
34
  config = (0, withTVAndroidManifest_1.withTVAndroidManifest)(config, params);
33
35
  return config;
34
36
  };
@@ -0,0 +1,4 @@
1
+ import { ConfigPlugin } from 'expo/config-plugins';
2
+ import { ConfigData } from './types';
3
+ /** Copies TV Icon image to the Android resources drawable folders. If image does not exist, throw an exception. */
4
+ export declare const withTVAndroidIconImage: ConfigPlugin<ConfigData>;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.withTVAndroidIconImage = void 0;
7
+ const config_plugins_1 = require("expo/config-plugins");
8
+ const fs_1 = require("fs");
9
+ const path_1 = __importDefault(require("path"));
10
+ const utils_1 = require("./utils");
11
+ const drawableDirectoryNames = [
12
+ 'drawable',
13
+ 'mipmap',
14
+ 'mipmap-hdpi',
15
+ 'mipmap-mdpi',
16
+ 'mipmap-xhdpi',
17
+ 'mipmap-xxhdpi',
18
+ 'mipmap-xxxhdpi',
19
+ ];
20
+ /** Copies TV Icon image to the Android resources drawable folders. If image does not exist, throw an exception. */
21
+ const withTVAndroidIconImage = (c, params = {}) => {
22
+ const androidTVIconPath = (0, utils_1.androidTVIcon)(params);
23
+ return (0, config_plugins_1.withDangerousMod)(c, [
24
+ 'android',
25
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
26
+ async (config) => {
27
+ if (!androidTVIconPath) {
28
+ return config;
29
+ }
30
+ (0, utils_1.verboseLog)(`adding TV Icon image ${androidTVIconPath} to Android resources`, {
31
+ params,
32
+ platform: 'android',
33
+ property: 'manifest',
34
+ });
35
+ for (const drawableDirectoryName of drawableDirectoryNames) {
36
+ const drawableDirectoryPath = path_1.default.join(config.modRequest.platformProjectRoot, 'app', 'src', 'main', 'res', drawableDirectoryName);
37
+ if (!(0, fs_1.existsSync)(drawableDirectoryPath)) {
38
+ await fs_1.promises.mkdir(drawableDirectoryPath);
39
+ }
40
+ if (drawableDirectoryName === "drawable") {
41
+ await fs_1.promises.copyFile(androidTVIconPath, path_1.default.join(drawableDirectoryPath, 'tv_icon.png'));
42
+ }
43
+ else {
44
+ await fs_1.promises.copyFile(androidTVIconPath, path_1.default.join(drawableDirectoryPath, 'ic_launcher.png'));
45
+ await fs_1.promises.copyFile(androidTVIconPath, path_1.default.join(drawableDirectoryPath, 'ic_launcher_round.png'));
46
+ }
47
+ }
48
+ return config;
49
+ },
50
+ ]);
51
+ };
52
+ exports.withTVAndroidIconImage = withTVAndroidIconImage;
@@ -5,4 +5,5 @@ export declare const withTVAndroidManifest: ConfigPlugin<ConfigData>;
5
5
  export declare function setLeanBackLauncherIntent(_config: Pick<ExpoConfig, 'android'>, androidManifest: AndroidConfig.Manifest.AndroidManifest, params: ConfigData): AndroidConfig.Manifest.AndroidManifest;
6
6
  export declare function removePortraitOrientation(_config: Pick<ExpoConfig, 'android'>, androidManifest: AndroidConfig.Manifest.AndroidManifest, params: ConfigData): AndroidConfig.Manifest.AndroidManifest;
7
7
  export declare function setTVBanner(_config: Pick<ExpoConfig, 'android'>, androidManifest: AndroidConfig.Manifest.AndroidManifest, params: ConfigData, androidTVBannerPath: string | undefined): AndroidConfig.Manifest.AndroidManifest;
8
+ export declare function setTVIcon(_config: Pick<ExpoConfig, 'android'>, androidManifest: AndroidConfig.Manifest.AndroidManifest, params: ConfigData, androidTVIconPath: string | undefined): AndroidConfig.Manifest.AndroidManifest;
8
9
  export declare function addTouchscreenHardwareFeatureToManifest(_config: Pick<ExpoConfig, 'android'>, androidManifest: AndroidConfig.Manifest.AndroidManifest, params: ConfigData): AndroidConfig.Manifest.AndroidManifest;
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addTouchscreenHardwareFeatureToManifest = exports.setTVBanner = exports.removePortraitOrientation = exports.setLeanBackLauncherIntent = exports.withTVAndroidManifest = void 0;
3
+ exports.addTouchscreenHardwareFeatureToManifest = exports.setTVIcon = exports.setTVBanner = exports.removePortraitOrientation = exports.setLeanBackLauncherIntent = exports.withTVAndroidManifest = void 0;
4
4
  const config_plugins_1 = require("expo/config-plugins");
5
5
  const utils_1 = require("./utils");
6
6
  const { getMainActivity, getMainApplication } = config_plugins_1.AndroidConfig.Manifest;
7
7
  const withTVAndroidManifest = (config, params = {}) => {
8
8
  const androidTVBannerPath = (0, utils_1.androidTVBanner)(params);
9
+ const androidTVIconPath = (0, utils_1.androidTVIcon)(params);
9
10
  return (0, config_plugins_1.withAndroidManifest)(config, (config) => {
10
11
  config.modResults = setLeanBackLauncherIntent(config, config.modResults, params);
11
12
  config.modResults = removePortraitOrientation(config, config.modResults, params);
@@ -13,6 +14,9 @@ const withTVAndroidManifest = (config, params = {}) => {
13
14
  if (androidTVBannerPath) {
14
15
  config.modResults = setTVBanner(config, config.modResults, params, androidTVBannerPath);
15
16
  }
17
+ if (androidTVIconPath) {
18
+ config.modResults = setTVIcon(config, config.modResults, params, androidTVIconPath);
19
+ }
16
20
  return config;
17
21
  });
18
22
  };
@@ -91,6 +95,23 @@ function setTVBanner(_config, androidManifest, params, androidTVBannerPath) {
91
95
  return androidManifest;
92
96
  }
93
97
  exports.setTVBanner = setTVBanner;
98
+ function setTVIcon(_config, androidManifest, params, androidTVIconPath) {
99
+ if (!androidTVIconPath) {
100
+ return androidManifest;
101
+ }
102
+ const mainApplication = getMainApplication(androidManifest);
103
+ if (mainApplication?.$) {
104
+ const metadata = mainApplication?.$ ?? {};
105
+ (0, utils_1.verboseLog)('adding TV icon to AndroidManifest.xml', {
106
+ params,
107
+ platform: 'android',
108
+ property: 'manifest',
109
+ });
110
+ metadata['android:icon'] = '@drawable/tv_icon';
111
+ }
112
+ return androidManifest;
113
+ }
114
+ exports.setTVIcon = setTVIcon;
94
115
  function addTouchscreenHardwareFeatureToManifest(_config, androidManifest, params) {
95
116
  // Add `<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>` to the AndroidManifest.xml
96
117
  if (!Array.isArray(androidManifest.manifest['uses-feature'])) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-tvos/config-tv",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "description": "Config plugin to reconfigure native directories for Apple TV and Android TV development if needed",
5
5
  "main": "build/withTV.js",
6
6
  "types": "build/withTV.d.ts",
@@ -34,7 +34,7 @@
34
34
  "react-native-tvos"
35
35
  ],
36
36
  "peerDependencies": {
37
- "expo": "^50.0.6"
37
+ "expo": "^51"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@types/getenv": "^1.0.1",