react-native-macos 0.76.9 → 0.76.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.
Files changed (74) hide show
  1. package/Libraries/Blob/RCTBlobManager.h +0 -0
  2. package/Libraries/Blob/RCTBlobManager.mm +0 -0
  3. package/Libraries/Components/TextInput/TextInputState.js +5 -1
  4. package/Libraries/Components/Touchable/TouchableWithoutFeedback.js +0 -0
  5. package/Libraries/Core/ReactNativeVersion.js +1 -1
  6. package/Libraries/Inspector/NetworkOverlay.js +1 -1
  7. package/Libraries/Lists/FillRateHelper.js +3 -3
  8. package/Libraries/Lists/FlatList.d.ts +1 -1
  9. package/Libraries/Lists/FlatList.js +2 -2
  10. package/Libraries/Lists/SectionList.d.ts +1 -1
  11. package/Libraries/Lists/SectionList.js +2 -2
  12. package/Libraries/Lists/SectionListModern.js +2 -2
  13. package/Libraries/Lists/ViewabilityHelper.js +3 -3
  14. package/Libraries/Lists/VirtualizeUtils.js +2 -2
  15. package/Libraries/Lists/VirtualizedList.js +3 -3
  16. package/Libraries/Lists/VirtualizedListContext.js +2 -2
  17. package/Libraries/Lists/VirtualizedSectionList.js +3 -3
  18. package/Libraries/Modal/Modal.js +1 -1
  19. package/Libraries/StyleSheet/normalizeColor.js +0 -0
  20. package/Libraries/Text/Text.d.ts +1 -0
  21. package/Libraries/Text/TextInput/Singleline/RCTUITextField.mm +1 -1
  22. package/Libraries/Utilities/ReactNativeTestTools.js +1 -1
  23. package/React/Base/RCTJavaScriptLoader.h +0 -0
  24. package/React/Base/RCTJavaScriptLoader.mm +0 -0
  25. package/React/Base/RCTVersion.m +1 -1
  26. package/React/CoreModules/RCTLogBoxView.mm +4 -1
  27. package/React/DevSupport/RCTPausedInDebuggerOverlayController.mm +82 -14
  28. package/React/Views/RCTViewKeyboardEvent.m +24 -0
  29. package/ReactAndroid/gradle.properties +1 -1
  30. package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +1 -1
  31. package/ReactCommon/cxxreact/ReactNativeVersion.h +1 -1
  32. package/local-cli/cli.js +0 -0
  33. package/package.json +5 -4
  34. package/scripts/compose-source-maps.js +0 -0
  35. package/scripts/featureflags/README.md +156 -0
  36. package/scripts/featureflags/index.js +14 -0
  37. package/scripts/ios-configure-glog.sh +0 -0
  38. package/scripts/node-binary.sh +0 -0
  39. package/scripts/packager.sh +0 -0
  40. package/scripts/react-native-xcode.sh +0 -0
  41. package/scripts/react_native_pods_utils/script_phases.sh +0 -0
  42. package/scripts/xcode/ccache-clang++.sh +0 -0
  43. package/scripts/xcode/ccache-clang.sh +0 -0
  44. package/scripts/xcode/with-environment.sh +0 -0
  45. package/types/index.d.ts +1 -1
  46. package/scripts/cocoapods/autolinking.rb +0 -206
  47. package/scripts/cocoapods/autolinking_utils.rb +0 -25
  48. package/scripts/cocoapods/codegen.rb +0 -59
  49. package/scripts/cocoapods/codegen_script_phase_extractor.rb +0 -13
  50. package/scripts/cocoapods/codegen_utils.rb +0 -363
  51. package/scripts/cocoapods/fabric.rb +0 -18
  52. package/scripts/cocoapods/helpers.rb +0 -148
  53. package/scripts/cocoapods/jsengine.rb +0 -33
  54. package/scripts/cocoapods/local_podspec_patch.rb +0 -51
  55. package/scripts/cocoapods/new_architecture.rb +0 -193
  56. package/scripts/cocoapods/privacy_manifest_utils.rb +0 -194
  57. package/scripts/cocoapods/runtime.rb +0 -18
  58. package/scripts/cocoapods/spm.rb +0 -94
  59. package/scripts/cocoapods/utils.rb +0 -723
  60. package/scripts/codegen/codegen-utils.js +0 -51
  61. package/scripts/codegen/generate-artifacts-executor.js +0 -815
  62. package/scripts/codegen/generate-specs-cli-executor.js +0 -128
  63. package/scripts/codegen/templates/RCTModulesConformingToProtocolsProviderH.template +0 -18
  64. package/scripts/codegen/templates/RCTModulesConformingToProtocolsProviderMM.template +0 -33
  65. package/sdks/hermes-engine/hermes-engine.podspec +0 -161
  66. package/sdks/hermes-engine/hermes-utils.rb +0 -285
  67. package/sdks/hermes-engine/utils/build-apple-framework.sh +0 -225
  68. package/sdks/hermes-engine/utils/build-hermes-xcode.sh +0 -100
  69. package/sdks/hermes-engine/utils/build-hermesc-xcode.sh +0 -18
  70. package/sdks/hermes-engine/utils/build-ios-framework.sh +0 -85
  71. package/sdks/hermes-engine/utils/build-mac-framework.sh +0 -22
  72. package/sdks/hermes-engine/utils/copy-hermes-xcode.sh +0 -7
  73. package/sdks/hermes-engine/utils/create-dummy-hermes-xcframework.sh +0 -32
  74. package/sdks/hermes-engine/utils/replace_hermes_version.js +0 -106
@@ -1,128 +0,0 @@
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
- */
9
-
10
- 'use strict';
11
-
12
- const utils = require('./codegen-utils');
13
- const fs = require('fs');
14
- const mkdirp = require('mkdirp');
15
- const path = require('path');
16
-
17
- const GENERATORS = {
18
- all: {
19
- android: ['componentsAndroid', 'modulesAndroid', 'modulesCxx'],
20
- ios: ['componentsIOS', 'modulesIOS', 'modulesCxx'],
21
- },
22
- components: {
23
- android: ['componentsAndroid'],
24
- ios: ['componentsIOS'],
25
- },
26
- modules: {
27
- android: ['modulesAndroid', 'modulesCxx'],
28
- ios: ['modulesIOS', 'modulesCxx'],
29
- },
30
- };
31
-
32
- function createOutputDirectoryIfNeeded(outputDirectory, libraryName) {
33
- if (!outputDirectory) {
34
- outputDirectory = path.resolve(__dirname, '..', 'Libraries', libraryName);
35
- }
36
- mkdirp.sync(outputDirectory);
37
- }
38
-
39
- /**
40
- * This function read a JSON schema from a path and parses it.
41
- * It throws if the schema don't exists or it can't be parsed.
42
- *
43
- * @parameter schemaPath: the path to the schema
44
- * @return a valid schema
45
- * @throw an Error if the schema doesn't exists in a given path or if it can't be parsed.
46
- */
47
- function readAndParseSchema(schemaPath) {
48
- const schemaText = fs.readFileSync(schemaPath, 'utf-8');
49
-
50
- if (schemaText == null) {
51
- throw new Error(`Can't find schema at ${schemaPath}`);
52
- }
53
-
54
- try {
55
- return JSON.parse(schemaText);
56
- } catch (err) {
57
- throw new Error(`Can't parse schema to JSON. ${schemaPath}`);
58
- }
59
- }
60
-
61
- function validateLibraryType(libraryType) {
62
- if (GENERATORS[libraryType] == null) {
63
- throw new Error(`Invalid library type. ${libraryType}`);
64
- }
65
- }
66
-
67
- function generateSpecFromInMemorySchema(
68
- platform,
69
- schema,
70
- outputDirectory,
71
- libraryName,
72
- packageName,
73
- libraryType,
74
- useLocalIncludePaths,
75
- ) {
76
- validateLibraryType(libraryType);
77
- createOutputDirectoryIfNeeded(outputDirectory, libraryName);
78
- utils.getCodegen().generate(
79
- {
80
- libraryName,
81
- schema,
82
- outputDirectory,
83
- packageName,
84
- useLocalIncludePaths,
85
- },
86
- {
87
- generators: GENERATORS[libraryType][platform],
88
- },
89
- );
90
-
91
- if (platform === 'android') {
92
- // Move all components C++ files to a structured jni folder for now.
93
- // Note: this should've been done by RNCodegen's generators, but:
94
- // * the generators don't support platform option yet
95
- // * this subdir structure is Android-only, not applicable to iOS
96
- const files = fs.readdirSync(outputDirectory);
97
- const jniOutputDirectory = `${outputDirectory}/jni/react/renderer/components/${libraryName}`;
98
- mkdirp.sync(jniOutputDirectory);
99
- files
100
- .filter(f => f.endsWith('.h') || f.endsWith('.cpp'))
101
- .forEach(f => {
102
- fs.renameSync(`${outputDirectory}/${f}`, `${jniOutputDirectory}/${f}`);
103
- });
104
- }
105
- }
106
-
107
- function generateSpec(
108
- platform,
109
- schemaPath,
110
- outputDirectory,
111
- libraryName,
112
- packageName,
113
- libraryType,
114
- ) {
115
- generateSpecFromInMemorySchema(
116
- platform,
117
- readAndParseSchema(schemaPath),
118
- outputDirectory,
119
- libraryName,
120
- packageName,
121
- libraryType,
122
- );
123
- }
124
-
125
- module.exports = {
126
- execute: generateSpec,
127
- generateSpecFromInMemorySchema: generateSpecFromInMemorySchema,
128
- };
@@ -1,18 +0,0 @@
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
-
8
- #import <Foundation/Foundation.h>
9
-
10
- @interface RCTModulesConformingToProtocolsProvider: NSObject
11
-
12
- +(NSArray<NSString *> *)imageURLLoaderClassNames;
13
-
14
- +(NSArray<NSString *> *)imageDataDecoderClassNames;
15
-
16
- +(NSArray<NSString *> *)URLRequestHandlerClassNames;
17
-
18
- @end
@@ -1,33 +0,0 @@
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
-
8
- #import "RCTModulesConformingToProtocolsProvider.h"
9
-
10
- @implementation RCTModulesConformingToProtocolsProvider
11
-
12
- +(NSArray<NSString *> *)imageURLLoaderClassNames
13
- {
14
- return @[
15
- {imageURLLoaderClassNames}
16
- ];
17
- }
18
-
19
- +(NSArray<NSString *> *)imageDataDecoderClassNames
20
- {
21
- return @[
22
- {imageDataDecoderClassNames}
23
- ];
24
- }
25
-
26
- +(NSArray<NSString *> *)URLRequestHandlerClassNames
27
- {
28
- return @[
29
- {requestHandlersClassNames}
30
- ];
31
- }
32
-
33
- @end
@@ -1,161 +0,0 @@
1
- # Copyright (c) Meta Platforms, Inc. and affiliates.
2
- #
3
- # This source code is licensed under the MIT license found in the
4
- # LICENSE file in the root directory of this source tree.
5
-
6
- require "json"
7
- require_relative "./hermes-utils.rb"
8
-
9
- # [macOS]
10
- react_native_path = File.dirname(Pod::Executable.execute_command('node', ['-p',
11
- 'require.resolve(
12
- "react-native-macos",
13
- {paths: [process.argv[1]]},
14
- )', __dir__]).strip
15
- )
16
-
17
- # package.json
18
- package = JSON.parse(File.read(File.join(react_native_path, "package.json")))
19
- # [macOS
20
- rn_version = package['version']
21
- version = findLastestVersionWithArtifact(rn_version) || rn_version
22
- # macOS]
23
-
24
- source_type = hermes_source_type(version, react_native_path)
25
- source = podspec_source(source_type, version, react_native_path)
26
-
27
- Pod::Spec.new do |spec|
28
- spec.name = "hermes-engine"
29
- spec.version = version
30
- spec.summary = "Hermes is a small and lightweight JavaScript engine optimized for running React Native."
31
- spec.description = "Hermes is a JavaScript engine optimized for fast start-up of React Native apps. It features ahead-of-time static optimization and compact bytecode."
32
- spec.homepage = "https://hermesengine.dev"
33
- spec.license = package['license']
34
- spec.author = "Facebook"
35
- spec.source = source
36
- spec.platforms = { :osx => "10.13", :ios => "15.1", :visionos => "1.0" }
37
-
38
- spec.preserve_paths = '**/*.*'
39
- spec.source_files = ''
40
-
41
- spec.pod_target_xcconfig = {
42
- "CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
43
- "CLANG_CXX_LIBRARY" => "compiler-default"
44
- }
45
-
46
- spec.ios.vendored_frameworks = "destroot/Library/Frameworks/ios/hermes.framework"
47
- spec.osx.vendored_frameworks = "destroot/Library/Frameworks/macosx/hermes.framework"
48
- spec.visionos.vendored_frameworks = "destroot/Library/Frameworks/xros/hermes.framework"
49
-
50
- if HermesEngineSourceType::isPrebuilt(source_type) then
51
-
52
- spec.subspec 'Pre-built' do |ss|
53
- ss.preserve_paths = ["destroot/bin/*"].concat(["**/*.{h,c,cpp}"])
54
- ss.source_files = "destroot/include/hermes/**/*.h"
55
- ss.header_mappings_dir = "destroot/include"
56
- ss.ios.vendored_frameworks = "destroot/Library/Frameworks/universal/hermes.xcframework"
57
- ss.visionos.vendored_frameworks = "destroot/Library/Frameworks/universal/hermes.xcframework"
58
- ss.osx.vendored_frameworks = "destroot/Library/Frameworks/macosx/hermes.framework"
59
- end
60
-
61
-
62
- # Right now, even reinstalling pods with the PRODUCTION flag turned on, does not change the version of hermes that is downloaded
63
- # To remove the PRODUCTION flag, we want to download the right version of hermes on the flight
64
- # we do so in a pre-build script we invoke from the Xcode build pipeline
65
- # We use this only for Apps created using the template. RNTester and Nightlies should not be used to build for Release.
66
- # We ignore this if we provide a specific tarball: the assumption here is that if you are providing a tarball, is because you want to
67
- # test something specific for that tarball.
68
- if source_type == HermesEngineSourceType::DOWNLOAD_PREBUILD_RELEASE_TARBALL
69
- spec.script_phase = {
70
- :name => "[Hermes] Replace Hermes for the right configuration, if needed",
71
- :execution_position => :before_compile,
72
- :script => <<-EOS
73
- . "$REACT_NATIVE_PATH/scripts/xcode/with-environment.sh"
74
-
75
- CONFIG="Release"
76
- if echo $GCC_PREPROCESSOR_DEFINITIONS | grep -q "DEBUG=1"; then
77
- CONFIG="Debug"
78
- fi
79
-
80
- "$NODE_BINARY" "$REACT_NATIVE_PATH/sdks/hermes-engine/utils/replace_hermes_version.js" -c "$CONFIG" -r "#{version}" -p "$PODS_ROOT"
81
- EOS
82
- }
83
- end
84
-
85
- elsif HermesEngineSourceType::isFromSource(source_type) then
86
-
87
- spec.subspec 'Hermes' do |ss|
88
- ss.source_files = ''
89
- ss.public_header_files = 'API/hermes/*.h'
90
- ss.header_dir = 'hermes'
91
- end
92
-
93
- spec.subspec 'cdp' do |ss|
94
- ss.source_files = ''
95
- ss.public_header_files = 'API/hermes/cdp/*.h'
96
- ss.header_dir = 'hermes/cdp'
97
- end
98
-
99
- spec.subspec 'inspector' do |ss|
100
- ss.source_files = ''
101
- ss.public_header_files = 'API/hermes/inspector/*.h'
102
- ss.header_dir = 'hermes/inspector'
103
- end
104
-
105
- spec.subspec 'inspector_chrome' do |ss|
106
- ss.source_files = ''
107
- ss.public_header_files = 'API/hermes/inspector/chrome/*.h'
108
- ss.header_dir = 'hermes/inspector/chrome'
109
- end
110
-
111
- spec.subspec 'Public' do |ss|
112
- ss.source_files = ''
113
- ss.public_header_files = 'public/hermes/Public/*.h'
114
- ss.header_dir = 'hermes/Public'
115
- end
116
-
117
- hermesc_path = "${PODS_ROOT}/hermes-engine/build_host_hermesc"
118
-
119
- if ENV.has_key?('HERMES_OVERRIDE_HERMESC_PATH') && File.exist?(ENV['HERMES_OVERRIDE_HERMESC_PATH']) then
120
- hermesc_path = ENV['HERMES_OVERRIDE_HERMESC_PATH']
121
- end
122
-
123
- spec.user_target_xcconfig = {
124
- 'HERMES_CLI_PATH' => "#{hermesc_path}/bin/hermesc"
125
- }
126
-
127
- spec.prepare_command = ". '#{react_native_path}/sdks/hermes-engine/utils/create-dummy-hermes-xcframework.sh'"
128
-
129
- # This podspec is also run in CI to build Hermes without using Pod install
130
- # and sometimes CI fails because `Pod::Executable` does not exist if it is not run with Pod Install.
131
- if defined?(Pod::Executable.to_s)
132
- CMAKE_BINARY = Pod::Executable::which!('cmake')
133
- # NOTE: Script phases are sorted alphabetically inside Xcode project
134
- spec.script_phases = [
135
- {
136
- :name => '[RN] [1] Build Hermesc',
137
- :output_files => [
138
- "#{hermesc_path}/ImportHermesc.cmake"
139
- ],
140
- :script => <<-EOS
141
- . "${REACT_NATIVE_PATH}/scripts/xcode/with-environment.sh"
142
- export CMAKE_BINARY=${CMAKE_BINARY:-#{CMAKE_BINARY}}
143
- . ${REACT_NATIVE_PATH}/sdks/hermes-engine/utils/build-hermesc-xcode.sh #{hermesc_path} ${REACT_NATIVE_PATH}/ReactCommon/jsi
144
- EOS
145
- },
146
- {
147
- :name => '[RN] [2] Build Hermes',
148
- :input_files => ["#{hermesc_path}/ImportHermesc.cmake"],
149
- :output_files => [
150
- "${PODS_ROOT}/hermes-engine/build/iphonesimulator/API/hermes/hermes.framework/hermes"
151
- ],
152
- :script => <<-EOS
153
- . "${REACT_NATIVE_PATH}/scripts/xcode/with-environment.sh"
154
- export CMAKE_BINARY=${CMAKE_BINARY:-#{CMAKE_BINARY}}
155
- . ${REACT_NATIVE_PATH}/sdks/hermes-engine/utils/build-hermes-xcode.sh #{version} #{hermesc_path}/ImportHermesc.cmake ${REACT_NATIVE_PATH}/ReactCommon/jsi
156
- EOS
157
- }
158
- ]
159
- end
160
- end
161
- end
@@ -1,285 +0,0 @@
1
- # Copyright (c) Meta Platforms, Inc. and affiliates.
2
- #
3
- # This source code is licensed under the MIT license found in the
4
- # LICENSE file in the root directory of this source tree.
5
-
6
- require 'net/http'
7
- require 'rexml/document'
8
- require 'open3' # [macOS]
9
-
10
- HERMES_GITHUB_URL = "https://github.com/facebook/hermes.git"
11
- ENV_BUILD_FROM_SOURCE = "RCT_BUILD_HERMES_FROM_SOURCE"
12
-
13
- module HermesEngineSourceType
14
- LOCAL_PREBUILT_TARBALL = :local_prebuilt_tarball
15
- DOWNLOAD_PREBUILD_RELEASE_TARBALL = :download_prebuild_release_tarball
16
- DOWNLOAD_PREBUILT_NIGHTLY_TARBALL = :download_prebuilt_nightly_tarball
17
- BUILD_FROM_GITHUB_COMMIT = :build_from_github_commit
18
- BUILD_FROM_GITHUB_TAG = :build_from_github_tag
19
- BUILD_FROM_GITHUB_MAIN = :build_from_github_main
20
- BUILD_FROM_LOCAL_SOURCE_DIR = :build_from_local_source_dir
21
-
22
- def HermesEngineSourceType.isPrebuilt(source_type)
23
- return source_type == LOCAL_PREBUILT_TARBALL || source_type == DOWNLOAD_PREBUILD_RELEASE_TARBALL || source_type == DOWNLOAD_PREBUILT_NIGHTLY_TARBALL
24
- end
25
-
26
- def HermesEngineSourceType.isFromSource(source_type)
27
- return source_type == BUILD_FROM_GITHUB_COMMIT || source_type == BUILD_FROM_GITHUB_TAG || source_type == BUILD_FROM_GITHUB_MAIN || source_type == BUILD_FROM_LOCAL_SOURCE_DIR
28
- end
29
- end
30
-
31
- # Computes the hermes-engine.podspec's source type.
32
- # - To use a specific tarball, install the dependencies with:
33
- # `HERMES_ENGINE_TARBALL_PATH=<path_to_tarball> bundle exec pod install`
34
- # - To force a build from source, install the dependencies with:
35
- # `RCT_BUILD_HERMES_FROM_SOURCE=true bundle exec pod install`
36
- # If none of the two are provided, Cocoapods will check whether there is a tarball for the current version
37
- # (either release or nightly). If not, it will fall back to building from source (the latest commit on main).
38
- #
39
- # Parameters:
40
- # - version: current version of the pod
41
- # - react_native_path: path to react native
42
- #
43
-
44
- # Returns: hermes-engine source type
45
- def hermes_source_type(version, react_native_path)
46
- if override_hermes_dir_envvar_defined()
47
- return HermesEngineSourceType::BUILD_FROM_LOCAL_SOURCE_DIR
48
- end
49
-
50
- if hermes_engine_tarball_envvar_defined()
51
- return HermesEngineSourceType::LOCAL_PREBUILT_TARBALL
52
- end
53
-
54
- if hermes_commit_envvar_defined()
55
- return HermesEngineSourceType::BUILD_FROM_GITHUB_COMMIT
56
- end
57
-
58
- if force_build_from_tag(react_native_path)
59
- return HermesEngineSourceType::BUILD_FROM_GITHUB_TAG
60
- end
61
-
62
- if force_build_from_main(react_native_path)
63
- return HermesEngineSourceType::BUILD_FROM_GITHUB_MAIN
64
- end
65
-
66
- if release_artifact_exists(version)
67
- return HermesEngineSourceType::DOWNLOAD_PREBUILD_RELEASE_TARBALL
68
- end
69
-
70
- if nightly_artifact_exists(version)
71
- return HermesEngineSourceType::DOWNLOAD_PREBUILT_NIGHTLY_TARBALL
72
- end
73
-
74
- return HermesEngineSourceType::BUILD_FROM_GITHUB_MAIN
75
- end
76
-
77
- def override_hermes_dir_envvar_defined()
78
- return ENV.has_key?('REACT_NATIVE_OVERRIDE_HERMES_DIR')
79
- end
80
-
81
- def hermes_engine_tarball_envvar_defined()
82
- return ENV.has_key?('HERMES_ENGINE_TARBALL_PATH')
83
- end
84
-
85
- def hermes_commit_envvar_defined()
86
- return ENV.has_key?('HERMES_COMMIT')
87
- end
88
-
89
- def force_build_from_tag(react_native_path)
90
- return ENV[ENV_BUILD_FROM_SOURCE] === 'true' && File.exist?(hermestag_file(react_native_path))
91
- end
92
-
93
- def force_build_from_main(react_native_path)
94
- return ENV[ENV_BUILD_FROM_SOURCE] === 'true' && !File.exist?(hermestag_file(react_native_path))
95
- end
96
-
97
- def release_artifact_exists(version)
98
- return hermes_artifact_exists(release_tarball_url(version, :debug))
99
- end
100
-
101
- def nightly_artifact_exists(version)
102
- return hermes_artifact_exists(nightly_tarball_url(version).gsub("\\", ""))
103
- end
104
-
105
- def podspec_source(source_type, version, react_native_path)
106
- case source_type
107
- when HermesEngineSourceType::BUILD_FROM_LOCAL_SOURCE_DIR
108
- return podspec_source_build_from_local_source_dir(react_native_path)
109
- when HermesEngineSourceType::LOCAL_PREBUILT_TARBALL
110
- return podspec_source_local_prebuilt_tarball()
111
- when HermesEngineSourceType::BUILD_FROM_GITHUB_COMMIT
112
- return podspec_source_build_from_github_commit()
113
- when HermesEngineSourceType::BUILD_FROM_GITHUB_TAG
114
- return podspec_source_build_from_github_tag(react_native_path)
115
- when HermesEngineSourceType::BUILD_FROM_GITHUB_MAIN
116
- return podspec_source_build_from_github_main()
117
- when HermesEngineSourceType::DOWNLOAD_PREBUILD_RELEASE_TARBALL
118
- return podspec_source_download_prebuild_release_tarball(react_native_path, version)
119
- when HermesEngineSourceType::DOWNLOAD_PREBUILT_NIGHTLY_TARBALL
120
- return podspec_source_download_prebuilt_nightly_tarball(version)
121
- else
122
- abort "[Hermes] Unsupported or invalid source type provided: #{source_type}"
123
- end
124
- end
125
-
126
- def podspec_source_build_from_local_source_dir(react_native_path)
127
- source_dir_path = ENV['REACT_NATIVE_OVERRIDE_HERMES_DIR']
128
- if Dir.exist?(source_dir_path)
129
- hermes_log("Using source code from local path: #{source_dir_path}")
130
- tarball_path = File.join(artifacts_dir(), "hermes-engine-from-local-source-dir.tar.gz")
131
- exclude_paths = [
132
- "__tests__",
133
- "./external/flowtest",
134
- "./external/esprima/test_fixtures"
135
- ]
136
- .map {|path| "--exclude=#{path}"}
137
- .join(' ')
138
- tar_command = "tar #{exclude_paths} -czvf #{tarball_path} -C #{source_dir_path} . 2> /dev/null"
139
- success = system(tar_command)
140
- if !success
141
- abort "Failed to create a tarball with the contents of \"#{source_dir_path}\""
142
- end
143
- return {:http => "file://#{tarball_path}"}
144
- else
145
- abort <<-EOS
146
- [Hermes] REACT_NATIVE_OVERRIDE_HERMES_DIR is set, but points to a non-existing directory: \"#{source_dir_path}\"
147
- If you don't want to use local source, run `unset REACT_NATIVE_OVERRIDE_HERMES_DIR`
148
- EOS
149
- end
150
- end
151
-
152
- def podspec_source_local_prebuilt_tarball()
153
- tarball_path = ENV['HERMES_ENGINE_TARBALL_PATH']
154
- if File.exist?(tarball_path)
155
- hermes_log("Using pre-built binary from local path defined by HERMES_ENGINE_TARBALL_PATH envvar: #{tarball_path}")
156
- return {:http => "file://#{tarball_path}"}
157
- end
158
- abort <<-EOS
159
- [Hermes] HERMES_ENGINE_TARBALL_PATH is set, but points to a non-existing file: \"#{tarball_path}\"
160
- If you don't want to use tarball, run `unset HERMES_ENGINE_TARBALL_PATH`
161
- EOS
162
- end
163
-
164
- def podspec_source_build_from_github_commit()
165
- commit = ENV['HERMES_COMMIT']
166
- hermes_log("Using commit defined by HERMES_COMMIT envvar: #{commit}")
167
- return {:git => HERMES_GITHUB_URL, :commit => commit}
168
- end
169
-
170
- def podspec_source_build_from_github_tag(react_native_path)
171
- tag = File.read(hermestag_file(react_native_path)).strip
172
- hermes_log("Using tag difined in sdks/.hermesversion: #{tag}")
173
- return {:git => HERMES_GITHUB_URL, :tag => tag}
174
- end
175
-
176
- def podspec_source_build_from_github_main()
177
- hermes_log("Using the latest commit from main.")
178
- return {:git => HERMES_GITHUB_URL, :commit => `git ls-remote #{HERMES_GITHUB_URL} main | cut -f 1`.strip}
179
- end
180
-
181
- def podspec_source_download_prebuild_release_tarball(react_native_path, version)
182
- url = release_tarball_url(version, :debug)
183
- hermes_log("Using release tarball from URL: #{url}")
184
- download_stable_hermes(react_native_path, version, :debug)
185
- download_stable_hermes(react_native_path, version, :release)
186
- return {:http => url}
187
- end
188
-
189
- def podspec_source_download_prebuilt_nightly_tarball(version)
190
- url = nightly_tarball_url(version)
191
- hermes_log("Using nightly tarball from URL: #{url}")
192
- return {:http => url}
193
- end
194
-
195
- # HELPERS
196
-
197
- def artifacts_dir()
198
- return File.join(Pod::Config.instance.project_pods_root, "hermes-engine-artifacts")
199
- end
200
-
201
- def hermestag_file(react_native_path)
202
- return File.join(react_native_path, "sdks", ".hermesversion")
203
- end
204
-
205
- def release_tarball_url(version, build_type)
206
- # Sample url from Maven:
207
- # https://repo1.maven.org/maven2/com/facebook/react/react-native-artifacts/0.71.0/react-native-artifacts-0.71.0-hermes-ios-debug.tar.gz
208
- return "https://repo1.maven.org/maven2/com/facebook/react/react-native-artifacts/#{version}/react-native-artifacts-#{version}-hermes-ios-#{build_type.to_s}.tar.gz"
209
- end
210
-
211
- def download_stable_hermes(react_native_path, version, configuration)
212
- tarball_url = release_tarball_url(version, configuration)
213
- download_hermes_tarball(react_native_path, tarball_url, version, configuration)
214
- end
215
-
216
- def download_hermes_tarball(react_native_path, tarball_url, version, configuration)
217
- destination_path = configuration == nil ?
218
- "#{artifacts_dir()}/hermes-ios-#{version}.tar.gz" :
219
- "#{artifacts_dir()}/hermes-ios-#{version}-#{configuration}.tar.gz"
220
-
221
- unless File.exist?(destination_path)
222
- # Download to a temporary file first so we don't cache incomplete downloads.
223
- tmp_file = "#{artifacts_dir()}/hermes-ios.download"
224
- `mkdir -p "#{artifacts_dir()}" && curl "#{tarball_url}" -Lo "#{tmp_file}" && mv "#{tmp_file}" "#{destination_path}"`
225
- end
226
- return destination_path
227
- end
228
-
229
- def nightly_tarball_url(version)
230
- params = "r=snapshots\&g=com.facebook.react\&a=react-native-artifacts\&c=hermes-ios-debug\&e=tar.gz\&v=#{version}-SNAPSHOT"
231
- return resolve_url_redirects("http://oss.sonatype.org/service/local/artifact/maven/redirect\?#{params}")
232
- end
233
-
234
- def resolve_url_redirects(url)
235
- return (`curl -Ls -o /dev/null -w %{url_effective} \"#{url}\"`)
236
- end
237
-
238
- # [macOS react-native-macos does not publish macos specific hermes artifacts
239
- # so we attempt to find the latest patch version of the iOS artifacts and use that
240
- def findLastestVersionWithArtifact(version)
241
- versionWithoutPatch = version.match(/^(\d+\.\d+)/)
242
- xml_data, = Open3.capture3("curl -s https://repo1.maven.org/maven2/com/facebook/react/react-native-artifacts/maven-metadata.xml")
243
-
244
- metadata = REXML::Document.new(xml_data)
245
- versions = metadata.elements.to_a('//metadata/versioning/versions/version')
246
-
247
- # Extract version numbers and sort them
248
- filtered_versions = versions.select { |version| version.text.match?(/^#{versionWithoutPatch}\.\d+$/) }
249
- if filtered_versions.empty?
250
- return
251
- end
252
-
253
- version_numbers = filtered_versions.map { |version| version.text }
254
- sorted_versions = version_numbers.sort_by { |v| Gem::Version.new(v) }
255
-
256
- return sorted_versions.last
257
- end
258
- # macOS]
259
-
260
- # This function checks that Hermes artifact exists.
261
- # As of now it should check it on the Maven repo.
262
- #
263
- # Parameters
264
- # - version: the version of React Native
265
- # - build_type: debug or release
266
- def hermes_artifact_exists(tarball_url)
267
- # -L is used to follow redirects, useful for the nightlies
268
- # I also needed to wrap the url in quotes to avoid escaping & and ?.
269
- return (`curl -o /dev/null --silent -Iw '%{http_code}' -L "#{tarball_url}"` == "200")
270
- end
271
-
272
- def hermes_log(message, level = :warning)
273
- if !Object.const_defined?("Pod::UI")
274
- return
275
- end
276
- hermes_log_messgae = '[Hermes] ' + message
277
- case level
278
- when :info
279
- Pod::UI.puts hermes_log_messgae.green
280
- when :error
281
- Pod::UI.puts hermes_log_messgae.red
282
- else
283
- Pod::UI.puts hermes_log_messgae.yellow
284
- end
285
- end