react-native-macos 0.75.29 → 0.75.31

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.
@@ -16,7 +16,7 @@ const version: $ReadOnly<{
16
16
  }> = {
17
17
  major: 0,
18
18
  minor: 75,
19
- patch: 29,
19
+ patch: 31,
20
20
  prerelease: null,
21
21
  };
22
22
 
@@ -153,7 +153,7 @@
153
153
 
154
154
  - (NSArray<NSAttributedStringKey> *)validAttributesForMarkedText
155
155
  {
156
- return ((NSTextView *)self.currentEditor).validAttributesForMarkedText;
156
+ return ((NSTextView *)self.currentEditor).validAttributesForMarkedText ?: @[];
157
157
  }
158
158
 
159
159
  #endif // macOS]
@@ -23,7 +23,7 @@ NSDictionary* RCTGetReactNativeVersion(void)
23
23
  __rnVersion = @{
24
24
  RCTVersionMajor: @(0),
25
25
  RCTVersionMinor: @(75),
26
- RCTVersionPatch: @(29),
26
+ RCTVersionPatch: @(31),
27
27
  RCTVersionPrerelease: [NSNull null],
28
28
  };
29
29
  });
@@ -44,7 +44,7 @@ void UIGraphicsBeginImageContextWithOptions(CGSize size, __unused BOOL opaque, C
44
44
  size_t height = ceilf(size.height * scale);
45
45
 
46
46
  CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
47
- CGContextRef ctx = CGBitmapContextCreate(NULL, width, height, 8/*bitsPerComponent*/, width * 4/*bytesPerRow*/, colorSpace, kCGImageAlphaPremultipliedFirst);
47
+ CGContextRef ctx = CGBitmapContextCreate(NULL, width, height, 8/*bitsPerComponent*/, width * 4/*bytesPerRow*/, colorSpace, (CGBitmapInfo)kCGImageAlphaPremultipliedFirst);
48
48
  CGColorSpaceRelease(colorSpace);
49
49
 
50
50
  if (ctx != NULL)
@@ -1,4 +1,4 @@
1
- VERSION_NAME=0.75.29
1
+ VERSION_NAME=0.75.31
2
2
  react.internal.publishingGroup=com.facebook.react
3
3
 
4
4
  android.useAndroidX=true
@@ -17,6 +17,6 @@ public class ReactNativeVersion {
17
17
  public static final Map<String, Object> VERSION = MapBuilder.<String, Object>of(
18
18
  "major", 0,
19
19
  "minor", 75,
20
- "patch", 29,
20
+ "patch", 31,
21
21
  "prerelease", null);
22
22
  }
@@ -17,7 +17,7 @@ namespace facebook::react {
17
17
  constexpr struct {
18
18
  int32_t Major = 0;
19
19
  int32_t Minor = 75;
20
- int32_t Patch = 29;
20
+ int32_t Patch = 31;
21
21
  std::string_view Prerelease = "";
22
22
  } ReactNativeVersion;
23
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-macos",
3
- "version": "0.75.29",
3
+ "version": "0.75.31",
4
4
  "description": "React Native for macOS",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -102,7 +102,8 @@
102
102
  },
103
103
  "peerDependencies": {
104
104
  "@types/react": "^18.2.6",
105
- "react": "^18.2.0"
105
+ "react": "^18.2.0",
106
+ "react-native": "0.75.5"
106
107
  },
107
108
  "peerDependenciesMeta": {
108
109
  "@types/react": {
@@ -191,16 +191,22 @@ class ReactNativePodsUtils
191
191
  private
192
192
 
193
193
  def self.add_build_settings_to_pod(installer, settings_name, settings_value, target_pod_name, configuration)
194
+ # [macOS
195
+ # Since some RN projects might combine multiple platforms into the same Xcode project,
196
+ # we'll be much more forgiving with the pod name matching in react-native-macos.
197
+ # Could be upstreamed as part of https://github.com/microsoft/react-native-macos/issues/2526.
198
+ valid_suffixes = ["", "-iOS", "-macOS", "-visionOS"]
199
+ # macOS]
194
200
  installer.target_installation_results.pod_target_installation_results.each do |pod_name, target_installation_result|
195
- if pod_name.to_s == target_pod_name
201
+ if valid_suffixes.any? { |suffix| pod_name.to_s == "#{target_pod_name}#{suffix}" } # [macOS]
196
202
  target_installation_result.native_target.build_configurations.each do |config|
197
- if configuration == nil || (configuration != nil && config.name.include?(configuration))
198
- config.build_settings[settings_name] ||= '$(inherited) '
199
- config.build_settings[settings_name] << settings_value
200
- end
203
+ if configuration == nil || (configuration != nil && config.type == configuration)
204
+ config.build_settings[settings_name] ||= '$(inherited) '
205
+ config.build_settings[settings_name] << settings_value
201
206
  end
202
207
  end
203
208
  end
209
+ end
204
210
  end
205
211
 
206
212
  def self.fix_library_search_path(config)
@@ -10,14 +10,13 @@ react_native_path = File.join(__dir__, "..", "..")
10
10
 
11
11
  # package.json
12
12
  package = JSON.parse(File.read(File.join(react_native_path, "package.json")))
13
- # [macOS
14
- rn_version = package['version']
15
- version = findLastestVersionWithArtifact(rn_version) || rn_version
16
- # macOS]
13
+ version = findMatchingHermesVersion(package) # [macOS] Use special logic instead of just package['version']
17
14
 
18
15
  source_type = hermes_source_type(version, react_native_path)
19
16
  source = podspec_source(source_type, version, react_native_path)
20
17
 
18
+ version = version || package['version'] # [macOS] If version is nil, fall back to package version so CocoaPods doesn't fail
19
+
21
20
  Pod::Spec.new do |spec|
22
21
  spec.name = "hermes-engine"
23
22
  spec.version = version
@@ -6,6 +6,8 @@
6
6
  require 'net/http'
7
7
  require 'rexml/document'
8
8
  require 'open3' # [macOS]
9
+ require 'json' # [macOS]
10
+ require 'tmpdir' # [macOS]
9
11
 
10
12
  HERMES_GITHUB_URL = "https://github.com/facebook/hermes.git"
11
13
  ENV_BUILD_FROM_SOURCE = "RCT_BUILD_HERMES_FROM_SOURCE"
@@ -174,8 +176,18 @@ def podspec_source_build_from_github_tag(react_native_path)
174
176
  end
175
177
 
176
178
  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
+ # hermes_log("Using the latest commit from main.")
180
+ # return {:git => HERMES_GITHUB_URL, :commit => `git ls-remote #{HERMES_GITHUB_URL} main | cut -f 1`.strip}
181
+
182
+ # [macOS
183
+ # The logic for this is a bit different on macOS.
184
+ # Since react-native-macos lags slightly behind facebook/react-native, we can't always use
185
+ # the latest Hermes commit because Hermes and JSI don't always guarantee backwards compatibility.
186
+ # Instead, we take the commit hash of Hermes at the time of the merge base with facebook/react-native.
187
+ commit = hermes_commit_at_merge_base()
188
+ hermes_log("Using Hermes commit from the merge base with facebook/react-native: #{commit}")
189
+ return {:git => HERMES_GITHUB_URL, :commit => commit}
190
+ # macOS]
179
191
  end
180
192
 
181
193
  def podspec_source_download_prebuild_release_tarball(react_native_path, version)
@@ -198,6 +210,51 @@ def artifacts_dir()
198
210
  return File.join(Pod::Config.instance.project_pods_root, "hermes-engine-artifacts")
199
211
  end
200
212
 
213
+ # [macOS
214
+ def hermes_commit_at_merge_base()
215
+ # We don't need ls-remote because react-native-macos is a fork of facebook/react-native
216
+ fetch_result = `git fetch -q https://github.com/facebook/react-native.git`
217
+ if $?.exitstatus != 0
218
+ abort <<-EOS
219
+ [Hermes] Failed to fetch facebook/react-native into the local repository.
220
+ EOS
221
+ end
222
+
223
+ merge_base = `git merge-base FETCH_HEAD HEAD`.strip
224
+ if merge_base.empty?
225
+ abort <<-EOS
226
+ [Hermes] Unable to find the merge base between our HEAD and upstream's HEAD.
227
+ EOS
228
+ end
229
+
230
+ timestamp = `git show -s --format=%ci #{merge_base}`.strip
231
+ if timestamp.empty?
232
+ abort <<-EOS
233
+ [Hermes] Unable to extract the timestamp for the merge base (#{merge_base}).
234
+ EOS
235
+ end
236
+
237
+ commit = nil
238
+ Dir.mktmpdir do |tmpdir|
239
+ hermes_git_dir = File.join(tmpdir, "hermes.git")
240
+ # Unfortunately we can't use git rev-list on HERMES_GITHUB_URL directly since we're not in that repo.
241
+ # Instead, we create a shallow clone to avoid downloading the entire history.
242
+ `git clone -q --bare --shallow-since="#{timestamp}" #{HERMES_GITHUB_URL} "#{hermes_git_dir}"`
243
+ `git --git-dir="#{hermes_git_dir}" fetch -q --deepen=1`
244
+
245
+ # If all goes well, this will be the commit hash of Hermes at the time of the merge base
246
+ commit = `git --git-dir="#{hermes_git_dir}" rev-list -1 --before="#{timestamp}" HEAD`.strip
247
+ if commit.empty?
248
+ abort <<-EOS
249
+ [Hermes] Unable to find the Hermes commit hash at time #{timestamp}.
250
+ EOS
251
+ end
252
+ end
253
+
254
+ return commit
255
+ end
256
+ # macOS]
257
+
201
258
  def hermestag_file(react_native_path)
202
259
  return File.join(react_native_path, "sdks", ".hermesversion")
203
260
  end
@@ -235,25 +292,20 @@ def resolve_url_redirects(url)
235
292
  return (`curl -Ls -o /dev/null -w %{url_effective} \"#{url}\"`)
236
293
  end
237
294
 
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
295
+ # [macOS
296
+ # Tries to find a suitable Hermes version for a given react-native-macos package.
297
+ # For stable branches, we prefer this to be specified as a peer dependency.
298
+ def findMatchingHermesVersion(package)
299
+ if package['version'] == "1000.0.0"
300
+ # The main branch builds from source, so skip this check
301
+ return nil
251
302
  end
252
303
 
253
- version_numbers = filtered_versions.map { |version| version.text }
254
- sorted_versions = version_numbers.sort_by { |v| Gem::Version.new(v) }
304
+ if package['peerDependencies']
305
+ return package['peerDependencies']['react-native']
306
+ end
255
307
 
256
- return sorted_versions.last
308
+ hermes_log("No matching Hermes version found. Defaulting to main branch, which may be unreliable.")
257
309
  end
258
310
  # macOS]
259
311