react-native-tvos 0.88.1-0 → 0.88.101-tv.0
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/Libraries/Core/ReactNativeVersion.js +2 -2
- package/React/Base/RCTConstants.m +1 -1
- package/React/Base/RCTVersion.m +2 -2
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.kt +2 -2
- package/ReactCommon/cxxreact/ReactNativeVersion.h +3 -3
- package/package.json +4 -2
- package/react-native.config.js +1 -21
- package/scripts/cocoapods/autolinking.rb +3 -2
- package/scripts/cocoapods/codegen.rb +1 -1
- package/scripts/cocoapods/codegen_utils.rb +1 -1
- package/scripts/cocoapods/fabric.rb +1 -1
- package/scripts/cocoapods/jsengine.rb +1 -1
- package/scripts/cocoapods/local_podspec_patch.rb +1 -1
- package/scripts/cocoapods/runtime.rb +1 -1
- package/scripts/cocoapods/utils.rb +9 -1
- package/scripts/codegen/generate-artifacts-executor/utils.js +1 -1
- package/scripts/react-native-xcode.sh +3 -0
- package/scripts/react_native_pods.rb +3 -3
- package/sdks/hermes-engine/hermes-engine.podspec +1 -1
- package/third-party-podspecs/ReactNativeDependencies.podspec +1 -1
- package/tvos-metro-config/index.js +139 -0
- package/tvos-metro-config/transform-worker.js +63 -0
- package/tvosCommands.js +1 -10
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
export default class ReactNativeVersion {
|
|
29
29
|
static major: number = 0;
|
|
30
30
|
static minor: number = 88;
|
|
31
|
-
static patch: number =
|
|
32
|
-
static prerelease: string | null = '0';
|
|
31
|
+
static patch: number = 101;
|
|
32
|
+
static prerelease: string | null = 'tv.0';
|
|
33
33
|
|
|
34
34
|
static getVersionString(): string {
|
|
35
35
|
return `${this.major}.${this.minor}.${this.patch}${this.prerelease != null ? `-${this.prerelease}` : ''}`;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
#import "RCTConstants.h"
|
|
9
9
|
|
|
10
|
-
NSString *const RCTPlatformName = @"
|
|
10
|
+
NSString *const RCTPlatformName = @"tvos";
|
|
11
11
|
|
|
12
12
|
NSString *const RCTUserInterfaceStyleDidChangeNotification = @"RCTUserInterfaceStyleDidChangeNotification";
|
|
13
13
|
NSString *const RCTUserInterfaceStyleDidChangeNotificationTraitCollectionKey = @"traitCollection";
|
package/React/Base/RCTVersion.m
CHANGED
|
@@ -23,8 +23,8 @@ NSDictionary* RCTGetReactNativeVersion(void)
|
|
|
23
23
|
__rnVersion = @{
|
|
24
24
|
RCTVersionMajor: @(0),
|
|
25
25
|
RCTVersionMinor: @(88),
|
|
26
|
-
RCTVersionPatch: @(
|
|
27
|
-
RCTVersionPrerelease: @"0",
|
|
26
|
+
RCTVersionPatch: @(101),
|
|
27
|
+
RCTVersionPrerelease: @"tv.0",
|
|
28
28
|
};
|
|
29
29
|
});
|
|
30
30
|
return __rnVersion;
|
|
@@ -14,15 +14,15 @@
|
|
|
14
14
|
|
|
15
15
|
#define REACT_NATIVE_VERSION_MAJOR 0
|
|
16
16
|
#define REACT_NATIVE_VERSION_MINOR 88
|
|
17
|
-
#define REACT_NATIVE_VERSION_PATCH
|
|
17
|
+
#define REACT_NATIVE_VERSION_PATCH 101
|
|
18
18
|
|
|
19
19
|
namespace facebook::react {
|
|
20
20
|
|
|
21
21
|
struct ReactNativeVersionType {
|
|
22
22
|
int32_t Major = 0;
|
|
23
23
|
int32_t Minor = 88;
|
|
24
|
-
int32_t Patch =
|
|
25
|
-
std::string_view Prerelease = "0";
|
|
24
|
+
int32_t Patch = 101;
|
|
25
|
+
std::string_view Prerelease = "tv.0";
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
constexpr ReactNativeVersionType ReactNativeVersion;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-tvos",
|
|
3
|
-
"version": "0.88.
|
|
3
|
+
"version": "0.88.101-tv.0",
|
|
4
4
|
"description": "A framework for building native apps using React",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
"default": "./src/react-private-interface.js"
|
|
61
61
|
},
|
|
62
62
|
"./setup-env": "./src/setup-env.js",
|
|
63
|
+
"./tvos-metro-config": "./tvos-metro-config/index.js",
|
|
63
64
|
"./unstable-internals-do-not-use": {
|
|
64
65
|
"react-native-unstable-internals": "./src/unstable-internals-do-not-use.d.ts",
|
|
65
66
|
"types": null,
|
|
@@ -86,6 +87,7 @@
|
|
|
86
87
|
"React-Core-prebuilt.podspec",
|
|
87
88
|
"react-native.config.js",
|
|
88
89
|
"tvosCommands.js",
|
|
90
|
+
"tvos-metro-config",
|
|
89
91
|
"React.podspec",
|
|
90
92
|
"React",
|
|
91
93
|
"!React/Fabric/RCTThirdPartyFabricComponentsProvider.*",
|
|
@@ -187,7 +189,7 @@
|
|
|
187
189
|
"whatwg-fetch": "^3.0.0",
|
|
188
190
|
"ws": "^7.5.10",
|
|
189
191
|
"yargs": "^17.6.2",
|
|
190
|
-
"@react-native-tvos/virtualized-lists": "0.88.
|
|
192
|
+
"@react-native-tvos/virtualized-lists": "0.88.101-tv.0"
|
|
191
193
|
},
|
|
192
194
|
"codegenConfig": {
|
|
193
195
|
"libraries": [
|
package/react-native.config.js
CHANGED
|
@@ -57,19 +57,6 @@ try {
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
let ios;
|
|
61
|
-
try {
|
|
62
|
-
ios = findCommunityPlatformPackage(
|
|
63
|
-
'@react-native-community/cli-platform-ios',
|
|
64
|
-
);
|
|
65
|
-
} catch {
|
|
66
|
-
if (verbose) {
|
|
67
|
-
console.warn(
|
|
68
|
-
'@react-native-community/cli-platform-ios not found, the react-native.config.js may be unusable.',
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
60
|
const commands /*: Array<Command> */ = [];
|
|
74
61
|
|
|
75
62
|
const {
|
|
@@ -89,14 +76,6 @@ const config = {
|
|
|
89
76
|
}>} */,
|
|
90
77
|
};
|
|
91
78
|
|
|
92
|
-
if (ios != null) {
|
|
93
|
-
config.commands.push(...ios.commands);
|
|
94
|
-
config.platforms.ios = {
|
|
95
|
-
projectConfig: ios.projectConfig,
|
|
96
|
-
dependencyConfig: ios.dependencyConfig,
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
79
|
if (android != null) {
|
|
101
80
|
config.commands.push(...android.commands);
|
|
102
81
|
config.platforms.android = {
|
|
@@ -113,6 +92,7 @@ try {
|
|
|
113
92
|
config.platforms.tvos = {
|
|
114
93
|
projectConfig: apple.getProjectConfig({platformName: 'tvos'}),
|
|
115
94
|
dependencyConfig: apple.getDependencyConfig({platformName: 'tvos'}),
|
|
95
|
+
npmPackageName: 'react-native-tvos',
|
|
116
96
|
};
|
|
117
97
|
} catch {
|
|
118
98
|
if (verbose) {
|
|
@@ -38,7 +38,8 @@ def list_native_modules!(config_command)
|
|
|
38
38
|
config = JSON.parse(json)
|
|
39
39
|
|
|
40
40
|
packages = config["dependencies"]
|
|
41
|
-
|
|
41
|
+
project_config = config["project"]["tvos"] || config["project"]["ios"]
|
|
42
|
+
ios_project_root = Pathname.new(project_config["sourceDir"])
|
|
42
43
|
react_native_path = Pathname.new(config["reactNativePath"])
|
|
43
44
|
codegen_output_path = ios_project_root.join("build/generated/autolinking/autolinking.json")
|
|
44
45
|
|
|
@@ -49,7 +50,7 @@ def list_native_modules!(config_command)
|
|
|
49
50
|
found_pods = []
|
|
50
51
|
|
|
51
52
|
packages.each do |package_name, package|
|
|
52
|
-
next unless package_config = package["platforms"]["ios"]
|
|
53
|
+
next unless package_config = package["platforms"]["tvos"] || package["platforms"]["ios"]
|
|
53
54
|
|
|
54
55
|
name = package["name"]
|
|
55
56
|
podspec_path = package_config["podspecPath"]
|
|
@@ -11,7 +11,7 @@ def run_codegen!(
|
|
|
11
11
|
config_file_dir,
|
|
12
12
|
new_arch_enabled: true,
|
|
13
13
|
disable_codegen: false,
|
|
14
|
-
react_native_path: "../node_modules/react-native",
|
|
14
|
+
react_native_path: "../node_modules/react-native-tvos",
|
|
15
15
|
fabric_enabled: false,
|
|
16
16
|
hermes_enabled: true,
|
|
17
17
|
codegen_output_dir: 'build/generated/ios',
|
|
@@ -26,7 +26,7 @@ class CodegenUtils
|
|
|
26
26
|
def use_react_native_codegen_discovery!(
|
|
27
27
|
codegen_disabled,
|
|
28
28
|
app_path,
|
|
29
|
-
react_native_path: "../node_modules/react-native",
|
|
29
|
+
react_native_path: "../node_modules/react-native-tvos",
|
|
30
30
|
fabric_enabled: false,
|
|
31
31
|
hermes_enabled: true,
|
|
32
32
|
config_file_dir: '',
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
# It sets up the Fabric dependencies.
|
|
8
8
|
#
|
|
9
9
|
# @parameter react_native_path: relative path to react-native
|
|
10
|
-
def setup_fabric!(react_native_path: "../node_modules/react-native")
|
|
10
|
+
def setup_fabric!(react_native_path: "../node_modules/react-native-tvos")
|
|
11
11
|
pod 'React-Fabric', :path => "#{react_native_path}/ReactCommon"
|
|
12
12
|
pod 'React-FabricComponents', :path => "#{react_native_path}/ReactCommon"
|
|
13
13
|
pod 'React-graphics', :path => "#{react_native_path}/ReactCommon/react/renderer/graphics"
|
|
@@ -9,7 +9,7 @@ require_relative './utils.rb'
|
|
|
9
9
|
#
|
|
10
10
|
# @parameter react_native_path: relative path to react-native
|
|
11
11
|
# @parameter fabric_enabled: whether Fabirc is enabled
|
|
12
|
-
def setup_hermes!(react_native_path: "../node_modules/react-native")
|
|
12
|
+
def setup_hermes!(react_native_path: "../node_modules/react-native-tvos")
|
|
13
13
|
react_native_dir = Pod::Config.instance.installation_root.join(react_native_path)
|
|
14
14
|
# This `:tag => hermestag` below is only to tell CocoaPods to update hermes-engine when React Native version changes.
|
|
15
15
|
# We have custom logic to compute the source for hermes-engine. See sdks/hermes-engine/*
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
# This is necessary because local podspec dependencies must be otherwise manually updated.
|
|
8
8
|
module LocalPodspecPatch
|
|
9
9
|
# Returns local podspecs whose versions differ from the one in the `react-native` package.
|
|
10
|
-
def self.pods_to_update(react_native_path: "../node_modules/react-native", dir_manager: Dir, file_manager: File)
|
|
10
|
+
def self.pods_to_update(react_native_path: "../node_modules/react-native-tvos", dir_manager: Dir, file_manager: File)
|
|
11
11
|
@@local_podspecs = dir_manager.glob("#{react_native_path}/third-party-podspecs/*").map { |file| file_manager.basename(file, ".podspec") }
|
|
12
12
|
@@local_podspecs = @@local_podspecs.select do |podspec_name|
|
|
13
13
|
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
# Set up Bridgeless dependencies
|
|
8
8
|
#
|
|
9
9
|
# @parameter react_native_path: relative path to react-native
|
|
10
|
-
def setup_bridgeless!(react_native_path: "../node_modules/react-native", use_hermes: true)
|
|
10
|
+
def setup_bridgeless!(react_native_path: "../node_modules/react-native-tvos", use_hermes: true)
|
|
11
11
|
pod "React-jsitracing", :path => "#{react_native_path}/ReactCommon/hermes/executor/"
|
|
12
12
|
pod "React-runtimescheduler", :path => "#{react_native_path}/ReactCommon/react/renderer/runtimescheduler"
|
|
13
13
|
pod 'React-RuntimeCore', :path => "#{react_native_path}/ReactCommon/react/runtime"
|
|
@@ -865,6 +865,14 @@ class ReactNativePodsUtils
|
|
|
865
865
|
end
|
|
866
866
|
end
|
|
867
867
|
|
|
868
|
+
# Removes the 100 that out-of-tree preview releases add to the patch number of
|
|
869
|
+
# the core release they are built on: "0.88.101" gives "0.88.1".
|
|
870
|
+
def self.core_base_version_for_tv_base_version(base_version)
|
|
871
|
+
match = base_version.match(/^(\d+)\.(\d+)\.(\d+)$/)
|
|
872
|
+
return base_version if match.nil? || match[3].to_i < 100
|
|
873
|
+
return "#{match[1]}.#{match[2]}.#{match[3].to_i - 100}"
|
|
874
|
+
end
|
|
875
|
+
|
|
868
876
|
# Computes the core release version on which a TV release version is based
|
|
869
877
|
def self.core_version_for_tv_version(version)
|
|
870
878
|
# See if the release version string has a dash (true for all TV releases)
|
|
@@ -881,7 +889,7 @@ class ReactNativePodsUtils
|
|
|
881
889
|
return version
|
|
882
890
|
end
|
|
883
891
|
|
|
884
|
-
core_base_version = match[1]
|
|
892
|
+
core_base_version = core_base_version_for_tv_base_version(match[1])
|
|
885
893
|
prerelease = match[2]
|
|
886
894
|
# Check to see if this matches the convention for TV prereleases ("0.79.0-0rc1", etc.)
|
|
887
895
|
prerelease_match = prerelease.match(/0rc(\d+)/)
|
|
@@ -479,7 +479,7 @@ function findReactNativeRootPath(projectRoot /* : string */) /* : string */ {
|
|
|
479
479
|
let reactNativePackageJsonPath;
|
|
480
480
|
try {
|
|
481
481
|
reactNativePackageJsonPath = require.resolve(
|
|
482
|
-
path.join('react-native', 'package.json'),
|
|
482
|
+
path.join('react-native-tvos', 'package.json'),
|
|
483
483
|
{
|
|
484
484
|
paths: [projectRoot],
|
|
485
485
|
},
|
|
@@ -41,7 +41,7 @@ end
|
|
|
41
41
|
# By using this function, you won't have to manually change your Podfile
|
|
42
42
|
# when we change the minimum version supported by the framework.
|
|
43
43
|
def min_supported_versions
|
|
44
|
-
return { :
|
|
44
|
+
return { :tvos => min_ios_version_supported }
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
# This function prepares the project for React Native, before processing
|
|
@@ -87,7 +87,7 @@ end
|
|
|
87
87
|
# - app_path: path to the React Native app. Required by the New Architecture.
|
|
88
88
|
# - config_file_dir: directory of the `package.json` file, required by the New Architecture.
|
|
89
89
|
def use_react_native! (
|
|
90
|
-
path: "../node_modules/react-native",
|
|
90
|
+
path: "../node_modules/react-native-tvos",
|
|
91
91
|
fabric_enabled: false,
|
|
92
92
|
new_arch_enabled: NewArchitectureHelper.new_arch_enabled,
|
|
93
93
|
production: false, # deprecated
|
|
@@ -575,7 +575,7 @@ end
|
|
|
575
575
|
# - enable_hermes_profiler: whether the hermes profiler should be turned on in Release mode
|
|
576
576
|
def react_native_post_install(
|
|
577
577
|
installer,
|
|
578
|
-
react_native_path = "../node_modules/react-native",
|
|
578
|
+
react_native_path = "../node_modules/react-native-tvos",
|
|
579
579
|
mac_catalyst_enabled: false,
|
|
580
580
|
ccache_enabled: ENV['USE_CCACHE'] == '1'
|
|
581
581
|
)
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @noflow
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Metro config for apps that bundle with the `tvos` platform, which is the
|
|
15
|
+
* platform that tvOS builds of react-native-tvos request from Metro.
|
|
16
|
+
*
|
|
17
|
+
* Usage, in an app's `metro.config.js`:
|
|
18
|
+
*
|
|
19
|
+
* const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
|
|
20
|
+
* const {withTVOSPlatform} = require('react-native/tvos-metro-config');
|
|
21
|
+
*
|
|
22
|
+
* module.exports = withTVOSPlatform(mergeConfig(getDefaultConfig(__dirname), config));
|
|
23
|
+
*
|
|
24
|
+
* An app that installs `react-native-tvos` next to `react-native` requires
|
|
25
|
+
* `react-native-tvos/tvos-metro-config` instead.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
const fs = require('node:fs');
|
|
29
|
+
const path = require('node:path');
|
|
30
|
+
|
|
31
|
+
const TVOS_PLATFORM_EXTENSIONS = ['tvos', 'ios', 'native'];
|
|
32
|
+
|
|
33
|
+
const TVOS_HOST_PACKAGE = 'react-native-tvos';
|
|
34
|
+
|
|
35
|
+
const REACT_NATIVE_REQUEST = /^react-native(\/.*)?$/;
|
|
36
|
+
|
|
37
|
+
const DEFAULT_TRANSFORMER_PATH = 'metro-transform-worker';
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Returns `config` with two changes for `tvos` bundles:
|
|
41
|
+
*
|
|
42
|
+
* - Modules resolve with the `.tvos`, `.ios`, `.native` file extensions in that
|
|
43
|
+
* order, because most React Native sources have an `.ios.js` file and no
|
|
44
|
+
* `.tvos.js` file. A `resolveRequest` in `config` still runs, with the
|
|
45
|
+
* expanded extensions and no platform.
|
|
46
|
+
* - Modules transform as `ios`, so that `Platform.OS` and `Platform.select`,
|
|
47
|
+
* which Metro inlines with the bundle platform, match iOS. React Native
|
|
48
|
+
* checks `Platform.OS === 'ios'` for behavior that tvOS shares with iOS.
|
|
49
|
+
* - When the app installs `react-native-tvos` next to `react-native`,
|
|
50
|
+
* `react-native` and `react-native/...` requests resolve to
|
|
51
|
+
* `react-native-tvos`. An app that aliases `react-native` to
|
|
52
|
+
* `react-native-tvos` needs no redirect and gets none.
|
|
53
|
+
*
|
|
54
|
+
* Other platforms do not change.
|
|
55
|
+
*
|
|
56
|
+
* @template {import('metro-config').ConfigT} T
|
|
57
|
+
* @param {T} config
|
|
58
|
+
* @returns {T}
|
|
59
|
+
*/
|
|
60
|
+
function withTVOSPlatform(config) {
|
|
61
|
+
if (
|
|
62
|
+
config.transformerPath != null &&
|
|
63
|
+
config.transformerPath !== DEFAULT_TRANSFORMER_PATH
|
|
64
|
+
) {
|
|
65
|
+
throw new Error(
|
|
66
|
+
`withTVOSPlatform replaces Metro's transformerPath, but this config sets it to "${config.transformerPath}". Remove that setting, or transform tvos bundles as ios in your own transformer.`,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const nextResolveRequest = config.resolver?.resolveRequest;
|
|
71
|
+
const redirectReactNative = hasSeparateTVOSHostPackage(config.projectRoot);
|
|
72
|
+
|
|
73
|
+
/** @type {NonNullable<import('metro-config').ConfigT['resolver']['resolveRequest']>} */
|
|
74
|
+
function resolveRequest(context, moduleName, platform) {
|
|
75
|
+
const resolve = nextResolveRequest ?? context.resolveRequest;
|
|
76
|
+
if (platform !== 'tvos') {
|
|
77
|
+
return resolve(context, moduleName, platform);
|
|
78
|
+
}
|
|
79
|
+
const sourceExts = TVOS_PLATFORM_EXTENSIONS.flatMap(platformExtension =>
|
|
80
|
+
context.sourceExts.map(sourceExt => `${platformExtension}.${sourceExt}`),
|
|
81
|
+
).concat(context.sourceExts);
|
|
82
|
+
const match = redirectReactNative
|
|
83
|
+
? REACT_NATIVE_REQUEST.exec(moduleName)
|
|
84
|
+
: null;
|
|
85
|
+
return resolve(
|
|
86
|
+
{...context, preferNativePlatform: false, sourceExts},
|
|
87
|
+
match ? `${TVOS_HOST_PACKAGE}${match[1] ?? ''}` : moduleName,
|
|
88
|
+
null,
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
...config,
|
|
94
|
+
resolver: {...config.resolver, resolveRequest},
|
|
95
|
+
transformerPath: require.resolve('./transform-worker'),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Whether `react-native-tvos` resolves from `projectRoot` to a different
|
|
101
|
+
* package than `react-native` does.
|
|
102
|
+
*
|
|
103
|
+
* @param {string | void} projectRoot
|
|
104
|
+
* @returns {boolean}
|
|
105
|
+
*/
|
|
106
|
+
function hasSeparateTVOSHostPackage(projectRoot) {
|
|
107
|
+
if (projectRoot == null) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
const tvosRoot = resolvePackageRoot(TVOS_HOST_PACKAGE, projectRoot);
|
|
111
|
+
return (
|
|
112
|
+
tvosRoot != null &&
|
|
113
|
+
tvosRoot !== resolvePackageRoot('react-native', projectRoot)
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* @param {string} packageName
|
|
119
|
+
* @param {string} projectRoot
|
|
120
|
+
* @returns {string | null}
|
|
121
|
+
*/
|
|
122
|
+
function resolvePackageRoot(packageName, projectRoot) {
|
|
123
|
+
try {
|
|
124
|
+
const packageJson = require.resolve(`${packageName}/package.json`, {
|
|
125
|
+
paths: [projectRoot],
|
|
126
|
+
});
|
|
127
|
+
return fs.realpathSync(path.dirname(packageJson));
|
|
128
|
+
} catch (error) {
|
|
129
|
+
if (
|
|
130
|
+
error.code === 'MODULE_NOT_FOUND' ||
|
|
131
|
+
error.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED'
|
|
132
|
+
) {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
throw error;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
module.exports = {withTVOSPlatform};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
* @noflow
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Metro transform worker that transforms `tvos` bundles as `ios`, and every
|
|
15
|
+
* other bundle as Metro's default worker does. See `withTVOSPlatform`.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const crypto = require('node:crypto');
|
|
19
|
+
const fs = require('node:fs');
|
|
20
|
+
const path = require('node:path');
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Metro's default worker, found through the `metro` package the way Metro
|
|
24
|
+
* finds it. Metro runs from the app, which is the working directory of Metro
|
|
25
|
+
* and its workers.
|
|
26
|
+
*/
|
|
27
|
+
function requireDefaultWorker() {
|
|
28
|
+
const metroPackageJson = require.resolve('metro/package.json', {
|
|
29
|
+
paths: [process.cwd(), __dirname],
|
|
30
|
+
});
|
|
31
|
+
return require(
|
|
32
|
+
require.resolve('metro-transform-worker', {
|
|
33
|
+
paths: [path.dirname(metroPackageJson)],
|
|
34
|
+
}),
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const worker = requireDefaultWorker();
|
|
39
|
+
|
|
40
|
+
const ownCacheKey = crypto
|
|
41
|
+
.createHash('sha1')
|
|
42
|
+
.update(fs.readFileSync(__filename))
|
|
43
|
+
.digest('hex');
|
|
44
|
+
|
|
45
|
+
/** @type {typeof worker.transform} */
|
|
46
|
+
function transform(config, projectRoot, filename, data, options) {
|
|
47
|
+
const transformOptions =
|
|
48
|
+
options.platform === 'tvos' ? {...options, platform: 'ios'} : options;
|
|
49
|
+
return worker.transform(
|
|
50
|
+
config,
|
|
51
|
+
projectRoot,
|
|
52
|
+
filename,
|
|
53
|
+
data,
|
|
54
|
+
transformOptions,
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** @type {typeof worker.getCacheKey} */
|
|
59
|
+
function getCacheKey(config, opts) {
|
|
60
|
+
return `${worker.getCacheKey(config, opts)}$${ownCacheKey}`;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
module.exports = {transform, getCacheKey};
|
package/tvosCommands.js
CHANGED
|
@@ -2,16 +2,7 @@
|
|
|
2
2
|
* @flow
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
try {
|
|
7
|
-
apple = require('@react-native-community/cli-platform-apple');
|
|
8
|
-
} catch {
|
|
9
|
-
if (verbose) {
|
|
10
|
-
console.warn(
|
|
11
|
-
'@react-native-community/cli-platform-apple not found, the react-native.config.js may be unusable.'
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
5
|
+
const apple = require('@react-native-community/cli-platform-apple');
|
|
15
6
|
|
|
16
7
|
const platformName = 'tvos';
|
|
17
8
|
|