expo-modules-core 58.0.29 → 58.0.30

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 58.0.30
4
+
5
+ ### Patch Changes
6
+
7
+ - [iOS] Add `ExpoRootViewController`, which applies the status bar style and visibility set from JavaScript, and use it as the default root view controller. ([#52727](https://github.com/expo/expo/pull/52727) by [@alanjhughes](https://github.com/alanjhughes))
8
+ - [iOS] Update `expo-modules-macros` to 0.29.0. The code that `@Record` and `@Union` generate is `nonisolated`, so it also compiles with `-default-isolation MainActor`, a `@Union` can be a `@Record` property, and a `@SharedObject` subclass binds the `@JS` members it inherits. A `@Record` type can no longer be created from a native dictionary: its `from(dictionary:appContext:)` throws `RecordDictionaryConversionException`. ([#52443](https://github.com/expo/expo/pull/52443) by [@tsapeta](https://github.com/tsapeta))
9
+ - [iOS] Make `Logger.minLevel` public, so apps can keep less severe logs of the shared `log` instance, such as module registration in release builds, out of the device log. ([#52238](https://github.com/expo/expo/pull/52238) by [@tmak](https://github.com/tmak))
10
+ - [iOS] `@ExpoModule` and `@SharedObject` add an `@unchecked Sendable` conformance to their class, so `@JS(.withAsync)` functions compile without declaring it by hand. ([#52443](https://github.com/expo/expo/pull/52443) by [@tsapeta](https://github.com/tsapeta))
11
+ - [iOS] Add `RecordDictionaryConversionException`, which `@Record` types throw when they're created from a native dictionary. ([#52463](https://github.com/expo/expo/pull/52463) by [@tsapeta](https://github.com/tsapeta))
12
+ - Updated dependencies. ([#52476](https://github.com/expo/expo/pull/52476), [#52477](https://github.com/expo/expo/pull/52477), [#52696](https://github.com/expo/expo/pull/52696), [#52570](https://github.com/expo/expo/pull/52570), [#52648](https://github.com/expo/expo/pull/52648))
13
+ - expo-modules-jsi@58.0.22
14
+
3
15
  ## 58.0.29
4
16
 
5
17
  ### Patch Changes
@@ -46,7 +46,7 @@ if (shouldIncludeCompose) {
46
46
  }
47
47
 
48
48
  group = 'host.exp.exponent'
49
- version = '58.0.29'
49
+ version = '58.0.30'
50
50
 
51
51
  def isExpoModulesCoreTests = {
52
52
  Gradle gradle = getGradle()
@@ -175,7 +175,7 @@ android {
175
175
  defaultConfig {
176
176
  consumerProguardFiles 'proguard-rules.pro'
177
177
  versionCode 1
178
- versionName "58.0.29"
178
+ versionName "58.0.30"
179
179
  buildConfigField "String", "EXPO_MODULES_CORE_VERSION", "\"${versionName}\""
180
180
  buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", "true"
181
181
 
@@ -16,5 +16,5 @@
16
16
  "libexpo-modules-jsi.so"
17
17
  ],
18
18
  "stripped": true,
19
- "createdAt": "2026-10-31T09:58:28.402034468Z"
19
+ "createdAt": "2026-11-03T15:13:40.407447Z"
20
20
  }
Binary file
@@ -97,7 +97,8 @@ extension Benchmarks {
97
97
  extension Benchmarks {
98
98
  @Test(arguments: [10, 1000])
99
99
  func `encode an array of records`(count: Int) async throws {
100
- try await recordBenchmarkCase { runtime in
100
+ try await appContextBenchmarkCase { appContext in
101
+ let runtime = try appContext.runtime
101
102
  let points = (0..<count).map { BenchmarkPoint(x: Double($0), y: Double($0)) }
102
103
  try benchmark("[Record].encode: \(count) records", runtime: runtime) { iterations in
103
104
  for _ in 0..<iterations {
@@ -108,19 +109,6 @@ extension Benchmarks {
108
109
  }
109
110
  }
110
111
 
111
- /// Runs one case with the runtime of a new app context.
112
- private func recordBenchmarkCase(
113
- _ measure: @escaping @JavaScriptActor (JavaScriptRuntime) throws -> Void
114
- ) async throws {
115
- try await benchmarkCase {
116
- let appContext = AppContext.create()
117
- let runtime = try appContext.runtime
118
- try withExtendedLifetime(appContext) {
119
- try measure(runtime)
120
- }
121
- }
122
- }
123
-
124
112
  @Record
125
113
  private struct BenchmarkPoint {
126
114
  var x: Double = 0
@@ -115,6 +115,11 @@ public macro Event(_ name: String? = nil, sync: Bool = false) =
115
115
  /// is no `Name(…)` DSL entry. It defaults to the class name; pass `@ExpoModule("CustomName")` to
116
116
  /// override it.
117
117
  ///
118
+ /// The class gets an `@unchecked Sendable` conformance when it isn't `Sendable` yet, because native
119
+ /// code calls the module from more than one thread (for example a `.withAsync` variant runs on the
120
+ /// concurrent thread pool). Keep mutable state that more than one thread uses behind a lock or an
121
+ /// actor.
122
+ ///
118
123
  /// Usage:
119
124
  ///
120
125
  /// @ExpoModule
@@ -128,7 +133,7 @@ public macro Event(_ name: String? = nil, sync: Bool = false) =
128
133
  named(_jsName), named(_classTypes), named(appContext), named(init),
129
134
  named(_decorateModule), named(_assertTypesConformance))
130
135
  @attached(memberAttribute)
131
- @attached(extension, conformances: AnyModule)
136
+ @attached(extension, conformances: AnyModule, Sendable)
132
137
  public macro ExpoModule(_ name: String? = nil, classes: [Any.Type] = []) =
133
138
  #externalMacro(module: "ExpoModulesMacros", type: "ExpoModuleMacro")
134
139
 
@@ -145,6 +150,9 @@ public macro ExpoModule(_ name: String? = nil, classes: [Any.Type] = []) =
145
150
  /// JS arguments. Core calls them when building the class. The class must be a `SharedObject`
146
151
  /// subclass, direct or not, or the `_jsName` override doesn't compile.
147
152
  ///
153
+ /// Like `@ExpoModule`, the macro adds an `@unchecked Sendable` conformance when the class isn't
154
+ /// `Sendable` yet.
155
+ ///
148
156
  /// Usage:
149
157
  ///
150
158
  /// @SharedObject
@@ -164,18 +172,21 @@ public macro ExpoModule(_ name: String? = nil, classes: [Any.Type] = []) =
164
172
  named(_jsName), named(_decorateSharedObject), named(_constructSharedObject),
165
173
  named(_assertTypesConformance))
166
174
  @attached(memberAttribute)
175
+ @attached(extension, conformances: Sendable)
167
176
  public macro SharedObject(_ name: String? = nil) =
168
177
  #externalMacro(module: "ExpoModulesMacros", type: "SharedObjectMacro")
169
178
 
170
179
  /// Member + extension macro applied to a record `struct` or `class`. Every non-`static`,
171
180
  /// non-`private`/`fileprivate`, non-`lazy`, non-computed stored property is part of the record — no
172
181
  /// `@Field` wrapper needed — and the macro synthesizes the whole conversion surface from each
173
- /// property's static type: a memberwise `init`, the `from(object:appContext:)` /
174
- /// `from(dictionary:appContext:)` factories, the `toDictionary(appContext:)` /
175
- /// `toObject(appContext:)` write side, and the `JavaScriptDecodable` / `JavaScriptEncodable`
176
- /// conversions `decode(_:in:)` and `encode(_:in:)`. The type is auto-conformed to `Record`; the
177
- /// synthesized methods override `Record`'s reflection-based defaults, so it stays usable anywhere a
178
- /// `Record` argument is expected.
182
+ /// property's static type: a memberwise `init`, `from(object:appContext:)`,
183
+ /// `toDictionary(appContext:)` / `toObject(appContext:)`, and the `JavaScriptDecodable` /
184
+ /// `JavaScriptEncodable` conversions `decode(_:in:)` and `encode(_:in:)`. The type is auto-conformed to
185
+ /// `Record`; the synthesized methods override `Record`'s reflection-based defaults, so it stays usable
186
+ /// anywhere a `Record` argument is expected.
187
+ ///
188
+ /// A record converts only from and to JavaScript values. The synthesized `from(dictionary:appContext:)`
189
+ /// throws `RecordDictionaryConversionException`, so a record can't be created from a native dictionary.
179
190
  ///
180
191
  /// `decode(_:in:)` and `encode(_:in:)` use the runtime they receive and don't need an app context, so
181
192
  /// the record converts on any runtime. A class with an inheritance clause doesn't get them, so it
@@ -14,10 +14,16 @@ public class Logger: @unchecked Sendable {
14
14
  public static let EXPO_MODULES_LOG_SUBSYSTEM = "dev.expo.modules"
15
15
  public static let EXPO_LOG_CATEGORY = "expo"
16
16
 
17
+ /**
18
+ The least severe log type this logger passes to its handlers. Defaults to `.trace` in debug builds
19
+ and `.info` in release builds. Apps can raise it, for example with `log.minLevel = .error` before
20
+ the React Native host starts, to keep less severe logs of the shared `log` instance out of the
21
+ device log. Set it once at launch: changes are not synchronized with logging on other threads.
22
+ */
17
23
  #if DEBUG || EXPO_CONFIGURATION_DEBUG
18
- private var minLevel: LogType = .trace
24
+ public var minLevel: LogType = .trace
19
25
  #else
20
- private var minLevel: LogType = .info
26
+ public var minLevel: LogType = .info
21
27
  #endif
22
28
 
23
29
  private let logHandlers: [LogHandler]
@@ -30,8 +30,9 @@ public protocol Record: Convertible, JavaScriptDecodable, JavaScriptEncodable {
30
30
 
31
31
  /**
32
32
  Reads the record's members from a `[String: Any]` dictionary. The `@Field`-based default goes
33
- through reflection (`init()` + `update(withDict:)`); the `@Record` macro overrides it with a
34
- direct, statically-typed factory.
33
+ through reflection (`init()` + `update(withDict:)`). The `@Record` macro overrides it with a
34
+ factory that throws `RecordDictionaryConversionException`, since a macro record converts only from
35
+ JavaScript values.
35
36
  */
36
37
  static func from(dictionary: Dict, appContext: AppContext) throws -> Self
37
38
 
@@ -69,14 +70,25 @@ public final class RecordPropertyRequiredException: GenericException<String>, @u
69
70
  }
70
71
  }
71
72
 
73
+ /**
74
+ Thrown by a synthesized record's `from(dictionary:appContext:)`. A `@Record` type converts only from
75
+ and to JavaScript values, through its `decode` and `encode`, so it can't be created from a native
76
+ dictionary. The parameter is the name of the record type.
77
+ */
78
+ public final class RecordDictionaryConversionException: GenericException<String>, @unchecked Sendable {
79
+ override public var reason: String {
80
+ return "Cannot create '\(param)' from a native dictionary, because a @Record type converts only from JavaScript values. Receive the value as a JavaScript argument, or create it with its memberwise initializer"
81
+ }
82
+ }
83
+
72
84
  /**
73
85
  Provides the default implementation of `Record` protocol.
74
86
  */
75
87
  public extension Record {
76
88
  static func convert(from value: Any?, appContext: AppContext) throws -> Self {
77
89
  if let value = value as? Dict {
78
- // `from(dictionary:)` dispatches dynamically — reflection for `@Field` records, the
79
- // synthesized factory for `@Record` ones — so both read correctly off a dictionary.
90
+ // `from(dictionary:)` dispatches dynamically: reflection for `@Field` records, and for `@Record`
91
+ // ones the synthesized factory, which throws `RecordDictionaryConversionException`.
80
92
  return try Self.from(dictionary: value, appContext: appContext)
81
93
  }
82
94
  // It's possible that the current implementation tries to convert a value that is already of the desired type.
@@ -102,8 +114,8 @@ public extension Record {
102
114
  }
103
115
 
104
116
  static func from(dictionary: Dict, appContext: AppContext) throws -> Self {
105
- // Reflection-based default for `@Field` records. The `@Record` macro synthesizes a direct,
106
- // statically-typed override that takes precedence over this. Delegates to `init(from:appContext:)`
117
+ // Reflection-based default for `@Field` records. The `@Record` macro synthesizes an override that
118
+ // throws, which takes precedence over this. Delegates to `init(from:appContext:)`
107
119
  // so any custom dictionary initializer a record provides still runs.
108
120
  return try Self(from: dictionary, appContext: appContext)
109
121
  }
@@ -38,6 +38,6 @@ public class ExpoReactDelegate: NSObject {
38
38
  public func createRootViewController() -> UIViewController {
39
39
  return self.handlers.lazy
40
40
  .compactMap { $0.createRootViewController() }
41
- .first(where: { _ in true }) ?? UIViewController()
41
+ .first(where: { _ in true }) ?? ExpoRootViewController()
42
42
  }
43
43
  }
@@ -0,0 +1,22 @@
1
+ // Copyright 2018-present 650 Industries. All rights reserved.
2
+
3
+ internal import React
4
+
5
+ /**
6
+ Root view controller that applies the status bar state set from JavaScript.
7
+ */
8
+ open class ExpoRootViewController: UIViewController {
9
+ #if os(iOS)
10
+ open override var preferredStatusBarStyle: UIStatusBarStyle {
11
+ return RCTStatusBarAppearance.style
12
+ }
13
+
14
+ open override var prefersStatusBarHidden: Bool {
15
+ return RCTStatusBarAppearance.hidden
16
+ }
17
+
18
+ open override var preferredStatusBarUpdateAnimation: UIStatusBarAnimation {
19
+ return RCTStatusBarAppearance.updateAnimation
20
+ }
21
+ #endif
22
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-modules-core",
3
- "version": "58.0.29",
3
+ "version": "58.0.30",
4
4
  "description": "The core of Expo Modules architecture",
5
5
  "keywords": [
6
6
  "expo",
@@ -66,12 +66,12 @@
66
66
  "./package.json": "./package.json"
67
67
  },
68
68
  "dependencies": {
69
- "expo-modules-jsi": "~58.0.21",
70
- "expo-modules-macros": "0.27.1",
69
+ "expo-modules-jsi": "~58.0.22",
70
+ "expo-modules-macros": "0.29.0",
71
71
  "invariant": "^2.2.4"
72
72
  },
73
73
  "devDependencies": {
74
- "@expo/internal-scripts": "58.0.5",
74
+ "@expo/internal-scripts": "58.0.6",
75
75
  "@testing-library/react-native": "^14.0.1",
76
76
  "@types/invariant": "^2.2.33",
77
77
  "@types/react": "~19.3.0",