expo-modules-core 58.0.27 → 58.0.29

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,26 @@
1
1
  # Changelog
2
2
 
3
+ ## 58.0.29
4
+
5
+ ### Patch Changes
6
+
7
+ - [Android] Fix `Enum` to JS conversion failing in minified builds when constructor parameter names are not kept. ([#51677](https://github.com/expo/expo/pull/51677) by [@sergeich](https://github.com/sergeich))
8
+ - [iOS] Fix a Swift 6.4.2 compiler crash when building `ExpoModulesCore` from source. ([#52631](https://github.com/expo/expo/pull/52631) by [@ramonclaudio](https://github.com/ramonclaudio))
9
+
10
+ ## 58.0.28
11
+
12
+ ### Patch Changes
13
+
14
+ - [iOS] Add `EventEmitter.emit(event:payload:encode:)`, which emits a payload that a closure encodes into a slot. `expo-modules-macros` uses it for an `@Event` whose payload holds a tuple, which can't conform to `JavaScriptEncodable`. ([#52392](https://github.com/expo/expo/pull/52392) by [@tsapeta](https://github.com/tsapeta))
15
+ - [iOS] Send `Network.loadingFailed` to the network inspector when a request fails, so failed requests no longer show as pending. ([#52431](https://github.com/expo/expo/pull/52431) by [@alanjhughes](https://github.com/alanjhughes))
16
+ - [iOS] Fix missing upload progress for `URLSession` requests, such as `XMLHttpRequest` and foreground `File.upload`, when the network inspector is enabled. ([#52428](https://github.com/expo/expo/pull/52428) by [@alanjhughes](https://github.com/alanjhughes))
17
+ - [iOS] Update `expo-modules-macros` to 0.27.0, which converts Swift tuples in `@JS` members, `@Record` properties, `@Union` payloads, `@Event` payloads and closure arguments, and resolves the tuple type aliases declared in `@ExpoModule` and `@SharedObject` classes. ([#52390](https://github.com/expo/expo/pull/52390) by [@tsapeta](https://github.com/tsapeta))
18
+ - [iOS] Update `expo-modules-macros` to 0.27.1, which binds sync `@JS` functions that return nothing through the `Void` host function overload. This reduces the overhead of calling them. ([#52435](https://github.com/expo/expo/pull/52435) by [@tsapeta](https://github.com/tsapeta))
19
+ - [iOS] Reduce the overhead of passing an existing shared object to JavaScript, as a function result or an event payload, and of emitting events from shared objects. ([#52180](https://github.com/expo/expo/pull/52180) by [@tsapeta](https://github.com/tsapeta))
20
+ - Rebuild precompiled iOS binaries against React Native 0.88.1. ([#52404](https://github.com/expo/expo/pull/52404) by [@intergalacticspacehighway](https://github.com/intergalacticspacehighway))
21
+ - Updated dependencies. ([#52210](https://github.com/expo/expo/pull/52210), [#52208](https://github.com/expo/expo/pull/52208), [#52293](https://github.com/expo/expo/pull/52293), [#52350](https://github.com/expo/expo/pull/52350), [#52286](https://github.com/expo/expo/pull/52286), [#52328](https://github.com/expo/expo/pull/52328), [#51880](https://github.com/expo/expo/pull/51880), [#52346](https://github.com/expo/expo/pull/52346), [#52254](https://github.com/expo/expo/pull/52254), [#52392](https://github.com/expo/expo/pull/52392), [#52404](https://github.com/expo/expo/pull/52404))
22
+ - expo-modules-jsi@58.0.21
23
+
3
24
  ## 58.0.27
4
25
 
5
26
  ### Patch Changes
@@ -37,5 +37,10 @@ Pod::Spec.new do |s|
37
37
  test_spec.dependency 'ExpoModulesTestCore'
38
38
 
39
39
  test_spec.source_files = 'ios/WorkletsTests/**/*.{m,swift}'
40
+ # The test bundle links libExpoModulesCore.a (C++). ExpoModulesCore adds -lc++ in its
41
+ # `user_target_xcconfig`, which a test_spec target doesn't inherit, so link libc++ explicitly.
42
+ test_spec.pod_target_xcconfig = {
43
+ 'OTHER_LDFLAGS' => '$(inherited) -lc++'
44
+ }
40
45
  end
41
46
  end
@@ -46,7 +46,7 @@ if (shouldIncludeCompose) {
46
46
  }
47
47
 
48
48
  group = 'host.exp.exponent'
49
- version = '58.0.27'
49
+ version = '58.0.29'
50
50
 
51
51
  def isExpoModulesCoreTests = {
52
52
  Gradle gradle = getGradle()
@@ -97,7 +97,7 @@ if (workletsProject != null) {
97
97
 
98
98
  def reactNativeWorkletsRootDir = workletsProject?.projectDir?.parentFile
99
99
 
100
- def expoModulesV2Version = "0.2.6"
100
+ def expoModulesV2Version = "0.2.7"
101
101
 
102
102
  configurations {
103
103
  // Artifact-only: the C++ sources, not something to put on any classpath.
@@ -175,7 +175,7 @@ android {
175
175
  defaultConfig {
176
176
  consumerProguardFiles 'proguard-rules.pro'
177
177
  versionCode 1
178
- versionName "58.0.27"
178
+ versionName "58.0.29"
179
179
  buildConfigField "String", "EXPO_MODULES_CORE_VERSION", "\"${versionName}\""
180
180
  buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", "true"
181
181
 
@@ -1,5 +1,5 @@
1
1
  {
2
- "reactNativeVersion": "0.88.0",
2
+ "reactNativeVersion": "0.88.1",
3
3
  "sourceHash": "e93890c6e60394cdef56149d38614433",
4
4
  "variants": [
5
5
  "debug",
@@ -16,5 +16,5 @@
16
16
  "libexpo-modules-jsi.so"
17
17
  ],
18
18
  "stripped": true,
19
- "createdAt": "2026-10-27T11:46:34.803657897Z"
19
+ "createdAt": "2026-10-31T09:58:28.402034468Z"
20
20
  }
Binary file
@@ -14,6 +14,7 @@ import io.github.expo.pika.PIntrospectionData
14
14
  import io.github.expo.pika.PIntrospectionProvider
15
15
  import io.github.expo.pika.PProperty
16
16
  import java.io.File
17
+ import java.lang.reflect.Modifier
17
18
  import java.net.URI
18
19
  import java.net.URL
19
20
  import kotlin.reflect.KProperty1
@@ -274,7 +275,18 @@ fun Enum<*>.toJSValue(): Any? {
274
275
 
275
276
  @Suppress("UNCHECKED_CAST")
276
277
  val parameterProperty = this::class.declaredMemberProperties
277
- .find { it.name == parameterName } as KProperty1<Enum<*>, *>
278
+ .find { it.name == parameterName } as? KProperty1<Enum<*>, *>
279
+
280
+ // Minifiers can rename the parameter in the Kotlin metadata (for example, to `p0`) and keep the property name.
281
+ if (parameterProperty == null) {
282
+ val fields = declaringJavaClass.declaredFields
283
+ .filter { !Modifier.isStatic(it.modifiers) && !it.isSynthetic }
284
+ return when (fields.size) {
285
+ 0 -> name
286
+ 1 -> fields.first().apply { isAccessible = true }.get(this)
287
+ else -> throw IllegalStateException("Enum '$javaClass' cannot be used as return type (incompatible with JS)")
288
+ }
289
+ }
278
290
 
279
291
  return parameterProperty.get(this)
280
292
  }
@@ -33,7 +33,7 @@ dependencies {
33
33
  implementation("com.facebook.react:react-native-gradle-plugin")
34
34
  implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3")
35
35
  implementation("io.github.expo.pika:pika-gradle:1.1.0")
36
- implementation("io.github.expo:expo-modules-v2-gradle-plugin:0.2.6")
36
+ implementation("io.github.expo:expo-modules-v2-gradle-plugin:0.2.7")
37
37
 
38
38
  if (isExpoAutolinkingSettingsPluginAvailable) {
39
39
  implementation("expo.modules:expo-autolinking-plugin-shared")
@@ -35,9 +35,15 @@ extension SharedObject: JavaScriptDecodable, JavaScriptEncodable {
35
35
 
36
36
  @JavaScriptActor
37
37
  public static func encode(_ value: SharedObject, in runtime: borrowing JavaScriptRuntime) throws -> JavaScriptValue {
38
- // Delegates to `DynamicSharedObjectType.castToJS`, which returns the already-paired JS object or
39
- // creates and registers a new one. That needs the registry on the app context, recovered from the
40
- // runtime; an unprepared runtime throws `Exceptions.AppContextNotFound`.
38
+ // An object already paired in this runtime is read off its native state, which is how most objects
39
+ // are encoded (for example, when a module returns or emits an object it got from JavaScript).
40
+ if let jsObject = value.object(in: runtime) {
41
+ return jsObject.takeValue()
42
+ }
43
+ // Otherwise, delegates to `DynamicSharedObjectType.castToJS`, which mostly creates and registers a
44
+ // new JS object. It returns an already-paired one only when the object is paired in its app
45
+ // context's runtime and that isn't `runtime`. That needs the registry on the app context, recovered
46
+ // from the runtime; an unprepared runtime throws `Exceptions.AppContextNotFound`.
41
47
  //
42
48
  // TODO: creating the object isn't `encode`'s job. Once creation/pairing moves elsewhere, `encode`
43
49
  // would only read the native state, dropping the app-context lookup and becoming `@inlinable` too.
@@ -100,9 +100,44 @@ public extension EventEmitter {
100
100
  }
101
101
  }
102
102
 
103
+ /// Schedules an event with the given name and payload to be emitted to the associated JavaScript object,
104
+ /// converting the payload with `encode`, which writes it into a slot like
105
+ /// `JavaScriptEncodable.encode(_:into:in:)`. The `@Event` macro uses it for payload types that can't
106
+ /// conform to `JavaScriptEncodable`, such as tuples.
107
+ @inlinable
108
+ func emit<P>(
109
+ event: String,
110
+ payload: sending P,
111
+ encode: @escaping @JavaScriptActor @Sendable (P, borrowing JavaScriptValue.Slot, borrowing JavaScriptRuntime) throws
112
+ -> Void
113
+ ) {
114
+ guard let runtime = eventRuntime(forEvent: event) else {
115
+ return
116
+ }
117
+ // See the note in `emit(event:payload:)` above.
118
+ let emitter = WeakEventEmitterReference(value: self)
119
+
120
+ runtime.schedule {
121
+ guard let emitter = emitter.value else {
122
+ return
123
+ }
124
+ let jsPayload: JavaScriptValue
125
+ do {
126
+ jsPayload = try JavaScriptValue.encoding(in: runtime) { slot in
127
+ try encode(payload, slot, runtime)
128
+ }
129
+ } catch {
130
+ warnPayloadNotEncoded(event: event, payloadType: P.self, error: error)
131
+ return
132
+ }
133
+ dispatchEvent(event: event, payload: jsPayload, from: emitter, in: runtime)
134
+ }
135
+ }
136
+
103
137
  /**
104
138
  Schedules an event with the given name and payload to be emitted to the associated JavaScript object.
105
- Payloads that are `JavaScriptEncodable` use the overload above, which converts them statically.
139
+ Payloads that are `JavaScriptEncodable` use the `emit(event:payload:)` overload for them, which converts
140
+ them statically.
106
141
  */
107
142
  @_disfavoredOverload
108
143
  func emit<P: AnyArgument>(event: String, payload: sending P) {
@@ -126,7 +126,7 @@ public macro Event(_ name: String? = nil, sync: Bool = false) =
126
126
  member,
127
127
  names:
128
128
  named(_jsName), named(_classTypes), named(appContext), named(init),
129
- named(_decorateModule))
129
+ named(_decorateModule), named(_assertTypesConformance))
130
130
  @attached(memberAttribute)
131
131
  @attached(extension, conformances: AnyModule)
132
132
  public macro ExpoModule(_ name: String? = nil, classes: [Any.Type] = []) =
@@ -161,7 +161,8 @@ public macro ExpoModule(_ name: String? = nil, classes: [Any.Type] = []) =
161
161
  @attached(
162
162
  member,
163
163
  names:
164
- named(_jsName), named(_decorateSharedObject), named(_constructSharedObject))
164
+ named(_jsName), named(_decorateSharedObject), named(_constructSharedObject),
165
+ named(_assertTypesConformance))
165
166
  @attached(memberAttribute)
166
167
  public macro SharedObject(_ name: String? = nil) =
167
168
  #externalMacro(module: "ExpoModulesMacros", type: "SharedObjectMacro")
@@ -197,7 +197,7 @@ public class AsyncFunctionDefinition<Args, FirstArgType, ReturnType>: AnyAsyncFu
197
197
  switch consume result {
198
198
  case .success(let value):
199
199
  promise.resolve(value)
200
- case .failure(let error as any Error):
200
+ case .failure(let error):
201
201
  promise.reject(error)
202
202
  }
203
203
  }
@@ -99,6 +99,21 @@ open class SharedObject: AnySharedObject {
99
99
  return appContext?.sharedObjectRegistry.toJavaScriptObject(self)
100
100
  }
101
101
 
102
+ /// The native state, or `nil` if the object was released. A released native state can outlive the
103
+ /// release on a JS object that couldn't drop it (for example a frozen one).
104
+ internal var unreleasedNativeState: SharedObjectNativeState? {
105
+ guard let nativeState, !nativeState.isReleased else {
106
+ return nil
107
+ }
108
+ return nativeState
109
+ }
110
+
111
+ /// The JS object paired with this object in the given runtime, read off its native state. Returns
112
+ /// `nil` when the object isn't paired in that runtime or was released.
113
+ internal func object(in runtime: borrowing JavaScriptRuntime) -> JavaScriptObject? {
114
+ return unreleasedNativeState?.javaScriptObject(in: runtime)
115
+ }
116
+
102
117
  /**
103
118
  Backwards-compatible overload that forwards to `emit(event:payload:)`. Existing single-argument
104
119
  call sites keep working unchanged; the parameter has been renamed to `payload` to make the
@@ -138,7 +153,9 @@ open class SharedObject: AnySharedObject {
138
153
  extension SharedObject: EventEmitter {
139
154
  @JavaScriptActor
140
155
  public func withEventTarget<R>(_ body: (borrowing JavaScriptObject) throws -> R) rethrows -> R? {
141
- guard let target = getJavaScriptObject() else {
156
+ // The same lookup as `getJavaScriptObject()`, without going through the registry, since it runs
157
+ // for every emitted event.
158
+ guard let runtime = try? appContext?.runtime, let target = object(in: runtime) else {
142
159
  return nil
143
160
  }
144
161
  return try body(target)
@@ -59,7 +59,7 @@ internal final class SharedObjectNativeState: JavaScriptNativeState {
59
59
 
60
60
  /// Returns the JS object paired with the native object in `runtime`, or `nil` if there is no live
61
61
  /// pairing there (none was created, or the JS object has been garbage-collected).
62
- internal func javaScriptObject(in runtime: JavaScriptRuntime) -> JavaScriptObject? {
62
+ internal func javaScriptObject(in runtime: borrowing JavaScriptRuntime) -> JavaScriptObject? {
63
63
  let runtimeId = runtime.id
64
64
 
65
65
  // Unwrap the ref first so the optional doesn't nest with `withValue`'s, which would form a
@@ -248,23 +248,14 @@ public final class SharedObjectRegistry: Sendable {
248
248
  guard let runtime = try? appContext?.runtime else {
249
249
  return nil
250
250
  }
251
- return unreleasedNativeState(of: nativeObject)?.javaScriptObject(in: runtime)
252
- }
253
-
254
- /// Returns the native object's native state, or `nil` if it was released. A released native state can
255
- /// outlive the release on a JS object that couldn't drop it (for example a frozen one).
256
- private func unreleasedNativeState(of nativeObject: SharedObject) -> SharedObjectNativeState? {
257
- guard let nativeState = nativeObject.nativeState, !nativeState.isReleased else {
258
- return nil
259
- }
260
- return nativeState
251
+ return nativeObject.object(in: runtime)
261
252
  }
262
253
 
263
254
  /// Returns the JS object paired with the native object in this registry's runtime, if it is alive and
264
255
  /// still holds the native object's native state.
265
256
  private func pairedObjectHoldingNativeState(of nativeObject: SharedObject, in runtime: JavaScriptRuntime?) -> JavaScriptObject? {
266
257
  guard let runtime,
267
- let nativeState = unreleasedNativeState(of: nativeObject),
258
+ let nativeState = nativeObject.unreleasedNativeState,
268
259
  let pairedObject = nativeState.javaScriptObject(in: runtime),
269
260
  pairedObject.getNativeState(as: SharedObjectNativeState.self) === nativeState
270
261
  else {
@@ -163,6 +163,22 @@ struct CdpNetwork {
163
163
  }
164
164
  }
165
165
 
166
+ struct LoadingFailedParams: EventParams {
167
+ let requestId: RequestId
168
+ let timestamp: MonotonicTime
169
+ let type: ResourceType
170
+ let errorText: String
171
+ let canceled: Bool
172
+
173
+ init(now: TimeInterval, requestId: RequestId, error: Error) {
174
+ self.requestId = requestId
175
+ self.timestamp = now
176
+ self.type = ResourceType.other
177
+ self.errorText = error.localizedDescription
178
+ self.canceled = (error as? URLError)?.code == .cancelled
179
+ }
180
+ }
181
+
166
182
  struct ExpoReceivedResponseBodyParams: EventParams {
167
183
  let requestId: RequestId
168
184
  let body: String
@@ -71,6 +71,11 @@ public final class ExpoRequestCdpInterceptor: NSObject, ExpoRequestInterceptorPr
71
71
  let params3 = CdpNetwork.LoadingFinishedParams(now: now, requestId: requestId, encodedDataLength: task.countOfBytesReceived)
72
72
  dispatchEvent(CdpNetwork.Event(method: "Network.loadingFinished", params: params3))
73
73
  }
74
+
75
+ func didFailLoading(requestId: String, task: URLSessionTask, error: Error) {
76
+ let params = CdpNetwork.LoadingFailedParams(now: Date().timeIntervalSince1970, requestId: requestId, error: error)
77
+ dispatchEvent(CdpNetwork.Event(method: "Network.loadingFailed", params: params))
78
+ }
74
79
  }
75
80
 
76
81
  /**
@@ -17,6 +17,7 @@ public final class ExpoRequestInterceptorProtocol: URLProtocol, URLSessionDataDe
17
17
  )
18
18
  private var requestId: String?
19
19
  private var dataTask_: URLSessionDataTask?
20
+ private weak var originalTask: URLSessionTask?
20
21
  private let responseBody = NSMutableData()
21
22
  private var responseBodyExceedsLimit = false
22
23
 
@@ -69,6 +70,17 @@ public final class ExpoRequestInterceptorProtocol: URLProtocol, URLSessionDataDe
69
70
  dataTask_ = dataTask
70
71
  }
71
72
 
73
+ @objc
74
+ public convenience init(
75
+ task: URLSessionTask,
76
+ cachedResponse: CachedURLResponse?,
77
+ client: URLProtocolClient?
78
+ ) {
79
+ // swiftlint:disable:next force_unwrapping
80
+ self.init(request: task.currentRequest!, cachedResponse: cachedResponse, client: client)
81
+ originalTask = task
82
+ }
83
+
72
84
  public override class func canonicalRequest(for request: URLRequest) -> URLRequest {
73
85
  request
74
86
  }
@@ -97,6 +109,9 @@ public final class ExpoRequestInterceptorProtocol: URLProtocol, URLSessionDataDe
97
109
 
98
110
  public func urlSession(_: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) {
99
111
  if let error = error {
112
+ if let requestId {
113
+ Self.delegate.didFailLoading(requestId: requestId, task: task, error: error)
114
+ }
100
115
  client?.urlProtocol(self, didFailWithError: error)
101
116
  } else {
102
117
  if let response = task.response as? HTTPURLResponse,
@@ -179,28 +194,13 @@ public final class ExpoRequestInterceptorProtocol: URLProtocol, URLSessionDataDe
179
194
  // Workaround to get the original task's URLSessionDelegate through the internal property and send upload process
180
195
  // Fixes https://github.com/expo/expo/issues/28269
181
196
  // swiftlint:enable line_length
182
- guard let dataTask = dataTask_ else {
183
- return
184
- }
185
-
186
- // Prevent recursive delegate calls
187
- if task === dataTask {
188
- return
189
- }
190
-
191
- if #available(iOS 15.0, tvOS 15.0, macOS 12.0, *), let delegate = dataTask.delegate {
192
- // For the case if the task has a dedicated delegate than the default delegate from its URLSession
193
- delegate.urlSession?(
194
- session, task: dataTask, didSendBodyData: bytesSent, totalBytesSent: totalBytesSent, totalBytesExpectedToSend: totalBytesExpectedToSend
195
- )
196
- return
197
- }
198
- guard let session = task.value(forKey: "session") as? URLSession,
199
- let delegate = session.delegate as? URLSessionTaskDelegate else {
197
+ guard let originalTask,
198
+ let originalSession = originalTask.value(forKey: "session") as? URLSession,
199
+ let delegate = originalTask.delegate ?? originalSession.delegate as? URLSessionTaskDelegate else {
200
200
  return
201
201
  }
202
202
  delegate.urlSession?(
203
- session, task: dataTask, didSendBodyData: bytesSent, totalBytesSent: totalBytesSent, totalBytesExpectedToSend: totalBytesExpectedToSend
203
+ originalSession, task: originalTask, didSendBodyData: bytesSent, totalBytesSent: totalBytesSent, totalBytesExpectedToSend: totalBytesExpectedToSend
204
204
  )
205
205
  }
206
206
 
@@ -223,6 +223,9 @@ protocol ExpoRequestInterceptorProtocolDelegate: Sendable {
223
223
 
224
224
  @objc
225
225
  func didReceiveResponse(requestId: String, task: URLSessionTask, responseBody: Data, isText: Bool, responseBodyExceedsLimit: Bool)
226
+
227
+ @objc
228
+ func didFailLoading(requestId: String, task: URLSessionTask, error: Error)
226
229
  }
227
230
 
228
231
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-modules-core",
3
- "version": "58.0.27",
3
+ "version": "58.0.29",
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.20",
70
- "expo-modules-macros": "0.24.0",
69
+ "expo-modules-jsi": "~58.0.21",
70
+ "expo-modules-macros": "0.27.1",
71
71
  "invariant": "^2.2.4"
72
72
  },
73
73
  "devDependencies": {
74
- "@expo/internal-scripts": "58.0.4",
74
+ "@expo/internal-scripts": "58.0.5",
75
75
  "@testing-library/react-native": "^14.0.1",
76
76
  "@types/invariant": "^2.2.33",
77
77
  "@types/react": "~19.3.0",