expo-modules-core 58.0.30 → 58.1.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.
Files changed (27) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/ExpoModulesCore.podspec +6 -8
  3. package/android/build.gradle +2 -2
  4. package/android/prebuilt/metadata.json +1 -1
  5. package/android/prebuilt/native-libs.tar.xz +0 -0
  6. package/android/src/main/java/expo/modules/adapters/react/apploader/RNHeadlessAppLoader.kt +2 -3
  7. package/ios/Core/AppContext.swift +29 -2
  8. package/ios/Core/Arguments/Convertibles.swift +1 -24
  9. package/ios/Core/Coding/JavaScriptCodable+Color.swift +887 -0
  10. package/ios/Core/Coding/JavaScriptCodable+URL.swift +55 -0
  11. package/ios/Core/Convertibles/Convertibles+Color.swift +10 -686
  12. package/ios/Core/Events/EventEmitter.swift +194 -1
  13. package/ios/Core/ExpoModulesMacros.swift +32 -1
  14. package/ios/Core/ExpoPackage.swift +29 -0
  15. package/ios/Core/ModulesProvider.swift +19 -0
  16. package/ios/Core/SharedObjects/SharedObjectRegistry.swift +28 -16
  17. package/ios/Core/Views/SwiftUI/Convertibles+SwiftUI.swift +2 -67
  18. package/ios/Core/Views/SwiftUI/SwiftUIHostingView.swift +1 -0
  19. package/ios/Core/Views/SwiftUI/SwiftUIViewHost.swift +100 -39
  20. package/ios/Core/Views/SwiftUI/SwiftUIVirtualView.swift +1 -0
  21. package/package.json +3 -3
  22. package/prebuilds/output/debug/xcframeworks/ExpoModulesCore.tar.gz +0 -0
  23. package/prebuilds/output/debug/xcframeworks/ExpoModulesWorklets.tar.gz +0 -0
  24. package/prebuilds/output/headers/xcframeworks/ExpoModulesCoreHeaders.tar.gz +0 -0
  25. package/prebuilds/output/release/xcframeworks/ExpoModulesCore.tar.gz +0 -0
  26. package/prebuilds/output/release/xcframeworks/ExpoModulesWorklets.tar.gz +0 -0
  27. package/spm.config.json +4 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## 58.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [iOS] Add `JavaScriptDecodable` and `JavaScriptEncodable` conformances to `URL`, `UIColor`, `CGColor` and SwiftUI `Color`, so the Expo Modules API 2.0 macros accept them as arguments, return values, record fields and event payloads. ([#53085](https://github.com/expo/expo/pull/53085) by [@tsapeta](https://github.com/tsapeta))
8
+
9
+ ### Patch Changes
10
+
11
+ - [iOS] Add the `.inline` and `.blocking` options of `@Event` and the `emitInline` and `emitBlocking` methods of `EventEmitter` that they use. With `.inline`, the listeners run before the call returns when it is made on the JavaScript thread. With `.blocking`, they run before the call returns on any thread. ([#52712](https://github.com/expo/expo/pull/52712) by [@tsapeta](https://github.com/tsapeta))
12
+ - [iOS] Update `expo-modules-macros` to 0.31.0. `@ExpoModule` and `@SharedObject` warn when the class isn't `public`, and `@Event` takes the `.inline` and `.blocking` options. ([#52712](https://github.com/expo/expo/pull/52712) by [@tsapeta](https://github.com/tsapeta))
13
+ - [iOS] Update `expo-modules-macros` to 0.33.0. The `ExpoModulesMacrosPlugin` Swift package product no longer breaks iOS builds in Xcode. The macros report more mistakes as build errors: generic, `static` or misplaced `@JS` members, reserved JavaScript names, a `@SharedObject` class without a superclass, and invalid `@Record`, `@Event` and `@Union` declarations. A parenthesized optional type is treated as optional. ([#53026](https://github.com/expo/expo/pull/53026) by [@chrfalch](https://github.com/chrfalch))
14
+ - [iOS] Define `REACT_NATIVE_TARGET_VERSION` in the precompiled `ExpoModulesCore`, so it sends view size updates with `unstable_Immediate` and keeps the size-commit budget, like a source build. ([#52924](https://github.com/expo/expo/pull/52924) by [@intergalacticspacehighway](https://github.com/intergalacticspacehighway))
15
+ - On iOS, generated modules providers also list the modules declared with `@ExpoModule` (Expo Modules API 2.0) by npm package, as an `ExpoPackage` for each package, in the new `packages` property. Local modules and inline modules declared with `@ExpoModule` are in the `$local` package. The property is generated only when the installed `expo-modules-core` supports it. Module registration doesn't change: all modules stay in `getModuleClasses()`. ([#52647](https://github.com/expo/expo/pull/52647) by [@tsapeta](https://github.com/tsapeta))
16
+ - [Android] Fix `RNHeadlessAppLoader.isRunning` reporting an app as headless after an Activity took over its React host, for example when a background task event arrived during a cold start. `expo-task-manager` then skipped forwarding `onHostResume`, `onHostPause` and `onHostDestroy` to task consumers such as `expo-location`'s, which kept reporting locations as if the app were in the foreground or background. ([#51184](https://github.com/expo/expo/pull/51184) by [@retu2libc](https://github.com/retu2libc))
17
+ - [iOS] Fix app contexts that own their runtime, such as the ones in unit tests, never being deallocated. ([#53094](https://github.com/expo/expo/pull/53094) by [@tsapeta](https://github.com/tsapeta))
18
+ - [iOS] Declare the `ExpoModulesCore` source attributes unconditionally, so autolinking patches the prebuilt `ExpoModulesCore` like other precompiled modules. ([#50207](https://github.com/expo/expo/pull/50207) by [@cristunaranjo](https://github.com/cristunaranjo))
19
+ - [iOS] Fix React Native content in a SwiftUI `List` row going blank. When SwiftUI builds more than one instance of a row, the instance it displays now holds the hosted view. ([#52910](https://github.com/expo/expo/pull/52910) by [@intergalacticspacehighway](https://github.com/intergalacticspacehighway))
20
+ - Updated dependencies. ([#53050](https://github.com/expo/expo/pull/53050))
21
+ - expo-modules-jsi@58.0.23
22
+
3
23
  ## 58.0.30
4
24
 
5
25
  ### Patch Changes
@@ -115,14 +115,12 @@ Pod::Spec.new do |s|
115
115
 
116
116
  install_modules_dependencies(s)
117
117
 
118
- if (!Expo::PackagesConfig.instance.try_link_with_prebuilt_xcframework(s))
119
- s.static_framework = true
120
- s.header_dir = 'ExpoModulesCore'
121
- s.source_files = 'ios/**/*.{h,m,mm,swift,cpp}', 'common/cpp/**/*.{h,cpp}'
122
- s.exclude_files = ['ios/Tests', 'ios/Benchmarks', 'ios/Worklets', 'ios/WorkletsTests', 'ios/WorkletsAdapter']
123
- s.compiler_flags = compiler_flags
124
- s.private_header_files = ['ios/**/*+Private.h', 'ios/**/Swift.h']
125
- end
118
+ s.static_framework = true
119
+ s.header_dir = 'ExpoModulesCore'
120
+ s.source_files = 'ios/**/*.{h,m,mm,swift,cpp}', 'common/cpp/**/*.{h,cpp}'
121
+ s.exclude_files = ['ios/Tests', 'ios/Benchmarks', 'ios/Worklets', 'ios/WorkletsTests', 'ios/WorkletsAdapter']
122
+ s.compiler_flags = compiler_flags
123
+ s.private_header_files = ['ios/**/*+Private.h', 'ios/**/Swift.h']
126
124
 
127
125
  s.test_spec 'Tests' do |test_spec|
128
126
  test_spec.dependency 'ExpoModulesTestCore'
@@ -46,7 +46,7 @@ if (shouldIncludeCompose) {
46
46
  }
47
47
 
48
48
  group = 'host.exp.exponent'
49
- version = '58.0.30'
49
+ version = '58.1.0'
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.30"
178
+ versionName "58.1.0"
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-11-03T15:13:40.407447Z"
19
+ "createdAt": "2026-11-11T09:18:54.471475173Z"
20
20
  }
Binary file
@@ -74,9 +74,8 @@ class RNHeadlessAppLoader @DoNotStrip constructor() : HeadlessAppLoader {
74
74
  }
75
75
 
76
76
  override fun isRunning(appScopeKey: String?): Boolean {
77
- // New architecture - We can return true since the fact that we have a reactContext
78
- // means that we've already called start on the reactHost
79
- return appRecords[appScopeKey] != null
77
+ val reactContext = appRecords[appScopeKey] ?: return false
78
+ return !reactContext.hasCurrentActivity()
80
79
  }
81
80
  //endregion HeadlessAppLoader
82
81
  }
@@ -10,6 +10,7 @@ public class AppContext: NSObject, EXAppContextProtocol, @unchecked Sendable {
10
10
  internal static func create() -> AppContext {
11
11
  let appContext = AppContext()
12
12
 
13
+ appContext.ownsRuntime = true
13
14
  appContext._runtime = ExpoRuntime()
14
15
  return appContext
15
16
  }
@@ -60,6 +61,18 @@ public class AppContext: NSObject, EXAppContextProtocol, @unchecked Sendable {
60
61
  */
61
62
  private var hostWrapper: ExpoHostWrapper?
62
63
 
64
+ /**
65
+ Whether the app context owns its runtime, as the one from `create()` and `TestAppContext` do,
66
+ rather than React Native. The `global.expo` native state then doesn't pin the app context (see
67
+ ``NativeState``): nothing else tears that runtime down, so the pin would be a cycle that keeps
68
+ both alive forever. Set it before the runtime.
69
+ */
70
+ internal var ownsRuntime = false {
71
+ willSet {
72
+ assert(_runtime == nil, "Set ownsRuntime before the runtime: the global.expo native state reads it only once")
73
+ }
74
+ }
75
+
63
76
  /**
64
77
  Underlying JSI runtime of the running app.
65
78
  */
@@ -696,8 +709,15 @@ public class AppContext: NSObject, EXAppContextProtocol, @unchecked Sendable {
696
709
  /// intentional: the cycle is broken only when the runtime is torn down (which frees the
697
710
  /// native state and fires its deallocator), which is exactly what defers the app context's
698
711
  /// release until the runtime is gone. The app context never holds the native state directly.
712
+ ///
713
+ /// An app context that owns its runtime (see ``ownsRuntime``) isn't pinned, as the cycle would
714
+ /// never break. The native state references it weakly and the app context tears the runtime
715
+ /// down in its own `deinit`.
699
716
  internal final class NativeState: JavaScriptNativeState {
700
- internal let appContext: AppContext
717
+ internal weak let appContext: AppContext?
718
+
719
+ /// The strong reference that pins the app context, or `nil` when it isn't pinned.
720
+ private let pinnedAppContext: AppContext?
701
721
 
702
722
  /// Whether releasing this native state should tear the app context down. Set only for the
703
723
  /// main runtime; subordinate runtimes pin the app context and enable recovery without
@@ -706,6 +726,7 @@ public class AppContext: NSObject, EXAppContextProtocol, @unchecked Sendable {
706
726
 
707
727
  internal init(appContext: AppContext, ownsLifecycle: Bool) {
708
728
  self.appContext = appContext
729
+ self.pinnedAppContext = appContext.ownsRuntime ? nil : appContext
709
730
  self.ownsLifecycle = ownsLifecycle
710
731
  super.init()
711
732
  setDeallocator { nativeState in
@@ -718,7 +739,7 @@ public class AppContext: NSObject, EXAppContextProtocol, @unchecked Sendable {
718
739
  // values. A future cross-runtime sharing path that could drop this state's last JSI slot
719
740
  // while the runtime still runs JavaScript (see `JavaScriptNativeState.acquireShared`)
720
741
  // would need to hop to the JS thread here first.
721
- nativeState.appContext.destroy()
742
+ nativeState.appContext?.destroy()
722
743
  }
723
744
  }
724
745
  }
@@ -742,6 +763,12 @@ public class AppContext: NSObject, EXAppContextProtocol, @unchecked Sendable {
742
763
  deinit {
743
764
  NotificationCenter.default.removeObserver(self)
744
765
 
766
+ // Nothing pins an app context that owns its runtime, so the runtime outlives it only until its
767
+ // stored properties are released. Release the JavaScript objects before that.
768
+ if ownsRuntime && _runtime != nil {
769
+ destroy()
770
+ }
771
+
745
772
  // Post an event to the registry only if it was already created.
746
773
  // If we let it to lazy-load here, that would crash since the module registry
747
774
  // has a weak reference to the app context which is being deallocated.
@@ -18,24 +18,7 @@ extension URL: Convertible {
18
18
  }
19
19
  throw Conversions.ConvertingException<URL>(value)
20
20
  }
21
-
22
- // First we try to create a URL without extra encoding, as it came.
23
- if let url = convertToUrl(string: value) {
24
- return url
25
- }
26
-
27
- // File path doesn't need to be percent-encoded.
28
- if isFileUrlPath(value) {
29
- return URL(fileURLWithPath: value)
30
- }
31
-
32
- // If we get here, the string is not the file url and may require percent-encoding characters that are not URL-safe according to RFC 3986.
33
- if let encodedValue = percentEncodeUrlString(value), let url = convertToUrl(string: encodedValue) {
34
- return url
35
- }
36
-
37
- // If it still fails to create the URL object, the string possibly contains characters that must be explicitly percent-encoded beforehand.
38
- throw UrlContainsInvalidCharactersException()
21
+ return try urlFromString(value)
39
22
  }
40
23
 
41
24
  public static func convertResult(_ result: Any, appContext: AppContext) throws -> Any {
@@ -46,12 +29,6 @@ extension URL: Convertible {
46
29
  }
47
30
  }
48
31
 
49
- internal class UrlContainsInvalidCharactersException: Exception {
50
- override var reason: String {
51
- return "Unable to create a URL object from the given string, make sure to percent-encode these characters: \(urlAllowedCharacters)"
52
- }
53
- }
54
-
55
32
  // MARK: - CoreGraphics
56
33
 
57
34
  extension CGPoint: Convertible {