expo-modules-core 58.0.13 → 58.0.15

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 (26) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/android/build.gradle +2 -2
  3. package/android/prebuilt/metadata.json +2 -2
  4. package/android/prebuilt/native-libs.tar.xz +0 -0
  5. package/android/proguard-rules.pro +34 -0
  6. package/android/src/main/cpp/fabric/ExpoComponentDescriptorFactory.cpp +2 -0
  7. package/android/src/main/cpp/fabric/ExpoComponentDescriptorFactory.h +6 -0
  8. package/android/src/main/cpp/fabric/FabricComponentsRegistry.cpp +8 -4
  9. package/android/src/main/java/expo/modules/kotlin/ExpoBridgeModule.kt +20 -4
  10. package/android/src/main/java/expo/modules/kotlin/defaultmodules/NativeModulesProxyModule.kt +7 -3
  11. package/android/src/main/java/expo/modules/kotlin/views/ShadowNodeProxy.kt +21 -3
  12. package/build/NativeViewManagerAdapter.native.d.ts +1 -1
  13. package/build/NativeViewManagerAdapter.native.js +2 -4
  14. package/build/NativeViewManagerAdapter.native.js.map +1 -1
  15. package/ios/Core/Classes/ClassDefinition.swift +5 -0
  16. package/ios/Core/Exceptions/CommonExceptions.swift +9 -0
  17. package/ios/Core/Exceptions/Exception.swift +13 -0
  18. package/ios/JS/ExpoRuntimeInstaller.swift +3 -4
  19. package/package.json +3 -3
  20. package/prebuilds/output/debug/xcframeworks/ExpoModulesCore.tar.gz +0 -0
  21. package/prebuilds/output/debug/xcframeworks/ExpoModulesWorklets.tar.gz +0 -0
  22. package/prebuilds/output/release/xcframeworks/ExpoModulesCore.tar.gz +0 -0
  23. package/prebuilds/output/release/xcframeworks/ExpoModulesWorklets.tar.gz +0 -0
  24. package/src/NativeViewManagerAdapter.native.tsx +10 -8
  25. package/build/ts-declarations/NativeComponentRegistry.d.ts +0 -12
  26. package/src/ts-declarations/NativeComponentRegistry.d.ts +0 -12
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## 58.0.15
4
+
5
+ ### Patch Changes
6
+
7
+ - [Android] Fix record arguments without `@OptimizedRecord` (such as `ImagePickerOptions` in older `expo-image-picker` versions) failing to convert in minified release builds with `The 1st argument cannot be cast to type ...` caused by a `NullPointerException`. Keep the `@Field` annotation class from being renamed by R8. ([#51206](https://github.com/expo/expo/pull/51206) by [@SoSerious194](https://github.com/SoSerious194))
8
+ - [Android] Fix release builds crashing at launch when the app uses an Expo Modules API 2.0 module, such as `expo-crypto`. R8 removed classes and members that the v2 runtime reaches through reflection and JNI. ([#51204](https://github.com/expo/expo/pull/51204) by [@Kudo](https://github.com/Kudo))
9
+ - [Android] Fixed Expo modules not receiving `OnCreate` when JavaScript reaches the JSI `NativeModulesProxy` before the legacy one, for example with lazy imports, which made modules like `expo-web-browser` fail on first use. Its constants are read lazily again, as before #46964. ([#51310](https://github.com/expo/expo/pull/51310) by [@alanjhughes](https://github.com/alanjhughes))
10
+ - [iOS] Fixed JavaScript errors created from native `Exception`s using the exception's debug description as their `message`, which prefixed it with the Swift type name and appended the native `file:line` (e.g. `MyException: reason (at MyModule.swift:42)`). The message is the exception's `description` again, as before the JSI rewrite and as on Android. `Exception.message` can now be overridden by subclasses; subclasses that already declare a `message` property need to mark it as `override`. ([#51210](https://github.com/expo/expo/pull/51210) by [@gabrieldonadel](https://github.com/gabrieldonadel))
11
+ - [Android] Fix views sized by Jetpack Compose, such as `RNHostView` in a `ModalBottomSheet`, that kept their old size until the keyboard animation ended when the keyboard was dismissed with the predictive back gesture. ([#51083](https://github.com/expo/expo/pull/51083) by [@intergalacticspacehighway](https://github.com/intergalacticspacehighway))
12
+ - [iOS] Throw when JavaScript constructs a shared object class that has no way to build its native instance, instead of returning an object that fails at its first member access. ([#51171](https://github.com/expo/expo/pull/51171) by [@tsapeta](https://github.com/tsapeta))
13
+ - [Android] Warn instead of failing silently when `installModules()` gives up waiting for an active `ReactInstance`. Previously JSI interop was installed into a context with no active instance and the method still returned `true`, so the first visible symptom was `globalThis.expo` being undefined in JS. ([#49801](https://github.com/expo/expo/pull/49801) by [@JeffreyKlug](https://github.com/JeffreyKlug))
14
+ - Updated dependencies. ([#51129](https://github.com/expo/expo/pull/51129), [#51234](https://github.com/expo/expo/pull/51234))
15
+ - expo-modules-jsi@58.0.10
16
+
17
+ ## 58.0.14
18
+
19
+ ### Patch Changes
20
+
21
+ - [Android] Fixed a data race on the Fabric view state-prop map when Expo registers its view components while React Native builds a component descriptor registry on another thread. ([#51044](https://github.com/expo/expo/pull/51044) by [@hirvesh](https://github.com/hirvesh))
22
+ - [Internal] Import `LogBox`, `DevSettings`, and `NativeComponentRegistry` from the `react-native` public API. ([#50862](https://github.com/expo/expo/pull/50862) by [@huntie](https://github.com/huntie))
23
+
3
24
  ## 58.0.13
4
25
 
5
26
  ### Patch Changes
@@ -46,7 +46,7 @@ if (shouldIncludeCompose) {
46
46
  }
47
47
 
48
48
  group = 'host.exp.exponent'
49
- version = '58.0.13'
49
+ version = '58.0.15'
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.13"
178
+ versionName "58.0.15"
179
179
  buildConfigField "String", "EXPO_MODULES_CORE_VERSION", "\"${versionName}\""
180
180
  buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", "true"
181
181
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "reactNativeVersion": "0.88.0",
3
- "sourceHash": "6f9421c9afcc3239b0995cea1757806a",
3
+ "sourceHash": "cfbedf19c9c9a434a2d9cd5dc4c91880",
4
4
  "variants": [
5
5
  "debug",
6
6
  "release"
@@ -16,5 +16,5 @@
16
16
  "libexpo-modules-jsi.so"
17
17
  ],
18
18
  "stripped": true,
19
- "createdAt": "2026-10-05T21:13:27.466871505Z"
19
+ "createdAt": "2026-10-09T16:09:16.803360891Z"
20
20
  }
Binary file
@@ -9,6 +9,11 @@
9
9
  *;
10
10
  }
11
11
 
12
+ # RecordTypeConverter reads `Field.key` through reflection to map JS keys to record
13
+ # properties. When R8 renames the annotation class, records without
14
+ # `@OptimizedRecord` can fail to convert with a NullPointerException at that read.
15
+ -keep @interface expo.modules.kotlin.records.Field { *; }
16
+
12
17
  -keep class * extends expo.modules.kotlin.sharedobjects.SharedObject
13
18
 
14
19
  -keep enum * implements expo.modules.kotlin.types.Enumerable {
@@ -48,3 +53,32 @@
48
53
  -keep class * implements expo.modules.kotlin.services.Service {
49
54
  <init>(...);
50
55
  }
56
+
57
+ # Expo Modules v2: ExpoModulesV2Host loads the generated list and the modules by reflection.
58
+ -keep class expo.modules.ExpoModulesV2ModuleList { public <init>(); }
59
+ -keep class * extends io.github.expo.modules.v2.Module {
60
+ <init>();
61
+ static ** INSTANCE;
62
+ }
63
+ # The v2 C++ runtime reaches these through JNI, and the artifacts ship no consumer rules.
64
+ -keep class io.github.expo.kolibri.** { *; }
65
+ -keep class io.github.expo.modules.v2.** { *; }
66
+ # JNI calls exported members and generated trampolines by name.
67
+ # A record registers its codec from the static `recordCodec$ExpoModulesV2` field initializer.
68
+ -keepclassmembers class * {
69
+ @io.github.expo.modules.v2.JS *;
70
+ @io.github.expo.modules.v2.Constant *;
71
+ @io.github.expo.modules.v2.Event *;
72
+ *** *$ExpoModulesV2(...);
73
+ static ** *$ExpoModulesV2;
74
+ }
75
+ -keep class **$ExpoModulesV2 { <init>(); }
76
+ # Kotlin puts property annotations on a synthetic method, so the getters need a rule of their own.
77
+ -keepclassmembers class * extends io.github.expo.modules.v2.Module { public *; }
78
+ -keepclassmembers class * extends io.github.expo.modules.v2.SharedObject { public *; }
79
+ # EnumConverter reads an enum's only property field by reflection, and v2 enums have no marker type.
80
+ # Scope it to enums in the package (and subpackages) of a v2 module or shared object.
81
+ -if class **.* extends io.github.expo.modules.v2.Module
82
+ -keepclassmembers,allowobfuscation enum <1>.** { !static <fields>; }
83
+ -if class **.* extends io.github.expo.modules.v2.SharedObject
84
+ -keepclassmembers,allowobfuscation enum <1>.** { !static <fields>; }
@@ -8,6 +8,7 @@ namespace react = facebook::react;
8
8
  namespace expo {
9
9
 
10
10
  StatePropMapType statePropMap = {};
11
+ std::shared_mutex statePropMapMutex;
11
12
 
12
13
  react::ComponentDescriptor::Unique concreteExpoComponentDescriptorConstructor(
13
14
  const react::ComponentDescriptorParameters &parameters
@@ -17,6 +18,7 @@ react::ComponentDescriptor::Unique concreteExpoComponentDescriptorConstructor(
17
18
  react::RawPropsParser(/*useRawPropsJsiValue=*/true)
18
19
  );
19
20
 
21
+ std::shared_lock lock(statePropMapMutex);
20
22
  if (statePropMap.contains(std::static_pointer_cast<std::string const>(parameters.flavor))) {
21
23
  descriptor->setStateProps(
22
24
  statePropMap.at(
@@ -5,6 +5,8 @@
5
5
  #include <react/renderer/core/ComponentDescriptor.h>
6
6
  #include "../types/FrontendConverter.h"
7
7
 
8
+ #include <shared_mutex>
9
+
8
10
  namespace react = facebook::react;
9
11
 
10
12
  namespace expo {
@@ -16,6 +18,10 @@ using StatePropMapType = std::unordered_map<
16
18
 
17
19
  extern StatePropMapType statePropMap;
18
20
 
21
+ // Guards `statePropMap`. It is written when Expo registers its view components and read
22
+ // when React Native builds a component descriptor registry, and these can run on different threads.
23
+ extern std::shared_mutex statePropMapMutex;
24
+
19
25
  react::ComponentDescriptor::Unique concreteExpoComponentDescriptorConstructor(
20
26
  const react::ComponentDescriptorParameters &parameters
21
27
  );
@@ -58,10 +58,14 @@ void FabricComponentsRegistry::registerComponentsRegistry(
58
58
  propMap.emplace(propName, converter);
59
59
  }
60
60
 
61
- statePropMap.insert_or_assign(
62
- flavor,
63
- propMap
64
- );
61
+ {
62
+ // Released before `add` below, which constructs descriptors that take the shared lock.
63
+ std::unique_lock lock(statePropMapMutex);
64
+ statePropMap.insert_or_assign(
65
+ flavor,
66
+ propMap
67
+ );
68
+ }
65
69
 
66
70
  providerRegistry->add(react::ComponentDescriptorProvider{
67
71
  reinterpret_cast<react::ComponentHandle>(componentName),
@@ -20,9 +20,21 @@ class ExpoBridgeModule(
20
20
  fun installModules(): Boolean {
21
21
  // Bridgeless ReactHostImpl may have BridgelessReactContext ready but not ReactInstance.
22
22
  // Try to busy wait until ReactInstance is available so we could get the javaScriptContextHolder.
23
- tryWaitSync(waitMs = 100, retries = 10) {
23
+ val ready = tryWaitSync(waitMs = 100, retries = 10) {
24
24
  reactApplicationContext.hasActiveReactInstance()
25
25
  }
26
+
27
+ if (!ready) {
28
+ // Don't fall through silently: without an active ReactInstance, installJSIInterop()
29
+ // below installs nothing into the runtime and this method still returns true, so the
30
+ // first visible symptom is JS reading `globalThis.expo` as undefined ("Cannot read
31
+ // property 'EventEmitter' of undefined") - far from the cause.
32
+ logger.warn(
33
+ "hasActiveReactInstance() is still false after waiting; installing JSI interop anyway. " +
34
+ "globalThis.expo will most likely be missing in the JS runtime."
35
+ )
36
+ }
37
+
26
38
  val kotlinInterop = nativeModulesProxy.get()?.kotlinInteropModuleRegistry
27
39
  ?: throw IllegalStateException("Couldn't find KotlinInteropModuleRegistry")
28
40
 
@@ -30,12 +42,16 @@ class ExpoBridgeModule(
30
42
  return true
31
43
  }
32
44
 
33
- private fun tryWaitSync(waitMs: Long, retries: Int, predicate: () -> Boolean) {
34
- repeat(retries) inner@{
45
+ /**
46
+ * Returns whether the predicate became true within the given budget.
47
+ */
48
+ private fun tryWaitSync(waitMs: Long, retries: Int, predicate: () -> Boolean): Boolean {
49
+ repeat(retries) {
35
50
  if (predicate()) {
36
- return
51
+ return true
37
52
  }
38
53
  Thread.sleep(waitMs)
39
54
  }
55
+ return predicate()
40
56
  }
41
57
  }
@@ -9,13 +9,17 @@ import expo.modules.kotlin.toBridgePromise
9
9
 
10
10
  internal const val NativeModulesProxyModuleName = "NativeModulesProxy"
11
11
 
12
+ private val legacyConstantKeys = listOf("modulesConstants", "exportedMethods", "viewManagersMetadata")
13
+
12
14
  class NativeModulesProxyModule : Module() {
13
15
  override fun definition() = ModuleDefinition {
14
16
  Name(NativeModulesProxyModuleName)
15
17
 
16
- appContext.legacyModulesProxyHolder?.get()?.constants?.forEach {
17
- Constant(it.key) {
18
- it.value
18
+ // The legacy proxy isn't attached yet when this definition is built, so read it lazily.
19
+ // Reading its constants is also what emits `OnCreate` to all modules.
20
+ legacyConstantKeys.forEach { key ->
21
+ Constant(key) {
22
+ appContext.legacyModulesProxyHolder?.get()?.constants?.get(key)
19
23
  }
20
24
  }
21
25
 
@@ -1,7 +1,9 @@
1
1
  package expo.modules.kotlin.views
2
2
 
3
3
  import android.view.ViewTreeObserver
4
+ import androidx.annotation.UiThread
4
5
  import expo.modules.kotlin.jni.fabric.NativeStatePropsGetter
6
+ import kotlinx.coroutines.launch
5
7
  import java.lang.ref.WeakReference
6
8
 
7
9
  class ShadowNodeProxy(expoView: ExpoView) {
@@ -10,18 +12,24 @@ class ShadowNodeProxy(expoView: ExpoView) {
10
12
 
11
13
  private var pendingFlush: ((stateWrapper: Any) -> Unit)? = null
12
14
  private var preDrawListener: ViewTreeObserver.OnPreDrawListener? = null
13
- private val flushRunnable = Runnable { drainPendingFlush() }
15
+ private var flushPosted = false
16
+ private val flushRunnable = Runnable {
17
+ flushPosted = false
18
+ drainPendingFlush()
19
+ }
14
20
 
15
21
  // Schedule in predraw listener to avoid early return in re-entrancy
16
22
  // We have a proper fix [here](https://github.com/facebook/react-native/pull/56311)
17
23
  // but it needs to be merged in RN
18
24
  // TODO: Remove the workaround when RN PR gets merged.
25
+ @UiThread
19
26
  fun setViewSize(width: Double, height: Double) {
20
27
  scheduleFlush { stateWrapper ->
21
28
  stateUpdater.updateViewSizeImmediate(stateWrapper, width, height)
22
29
  }
23
30
  }
24
31
 
32
+ @UiThread
25
33
  fun setStyleSize(width: Double?, height: Double?) {
26
34
  scheduleFlush { stateWrapper ->
27
35
  stateUpdater.updateStyleSizeImmediate(stateWrapper, width ?: Double.NaN, height ?: Double.NaN)
@@ -68,8 +76,18 @@ class ShadowNodeProxy(expoView: ExpoView) {
68
76
 
69
77
  // Predraw listener do not get called for each keyboard transition event so we add a fallback flush to be called here
70
78
  // https://github.com/expo/expo/issues/47778
71
- view.removeCallbacks(flushRunnable)
72
- view.post(flushRunnable)
79
+ // Async and posted once, so it still runs during animations.
80
+ // `Dispatchers.Main` posts async messages, which skip the traversal sync barriers.
81
+ // https://github.com/expo/expo/issues/51034
82
+ if (!flushPosted) {
83
+ flushPosted = true
84
+ if (view.isAttachedToWindow) {
85
+ view.appContext.mainQueue.launch { flushRunnable.run() }
86
+ } else {
87
+ // `view.post` keeps the runnable until the view attaches.
88
+ view.post(flushRunnable)
89
+ }
90
+ }
73
91
  }
74
92
 
75
93
  private fun drainPendingFlush() {
@@ -2,4 +2,4 @@ import { type ComponentType } from 'react';
2
2
  /**
3
3
  * A drop-in replacement for `requireNativeComponent`.
4
4
  */
5
- export declare function requireNativeViewManager<P>(moduleName: string, viewName?: string): ComponentType<P>;
5
+ export declare function requireNativeViewManager<P extends object>(moduleName: string, viewName?: string): ComponentType<P>;
@@ -1,10 +1,8 @@
1
1
  // Copyright © 2024 650 Industries.
2
- /// <reference path="ts-declarations/NativeComponentRegistry.d.ts" />
3
2
  'use client';
4
3
  import { jsx as _jsx } from "react/jsx-runtime";
5
4
  import { createRef, PureComponent } from 'react';
6
- import { findNodeHandle } from 'react-native';
7
- import { get as componentRegistryGet } from 'react-native/Libraries/NativeComponent/NativeComponentRegistry';
5
+ import { findNodeHandle, NativeComponentRegistry } from 'react-native';
8
6
  import { SharedObject } from './SharedObject';
9
7
  import { requireNativeModule } from './requireNativeModule';
10
8
  // To make the transition from React Native's `requireNativeComponent` to Expo's
@@ -24,7 +22,7 @@ import { requireNativeModule } from './requireNativeModule';
24
22
  const appIdentifier = globalThis.expo?.['__expo_app_identifier__'] ?? '';
25
23
  const viewNameSuffix = appIdentifier ? `_${appIdentifier}` : '';
26
24
  const nativeViewName = viewName ? `ViewManagerAdapter_${moduleName}_${viewName}${viewNameSuffix}` : `ViewManagerAdapter_${moduleName}${viewNameSuffix}`;
27
- return componentRegistryGet(nativeViewName, ()=>{
25
+ return NativeComponentRegistry.get(nativeViewName, ()=>{
28
26
  const expoViewConfig = globalThis.expo?.getViewConfig(moduleName, viewName);
29
27
  if (!expoViewConfig) {
30
28
  console.warn('Unable to get the view config for %s from module %s', viewName ?? 'default view', moduleName);
@@ -1 +1 @@
1
- {"version":3,"sources":["NativeViewManagerAdapter.native.tsx"],"sourcesContent":[null],"names":["createRef","PureComponent","findNodeHandle","get","componentRegistryGet","SharedObject","requireNativeModule","nativeComponentsCache","Map","requireNativeComponent","moduleName","viewName","appIdentifier","globalThis","expo","viewNameSuffix","nativeViewName","expoViewConfig","getViewConfig","console","warn","uiViewClassName","directEventTypes","validAttributes","addAttributeProcessing","processPropValue","value","sharedObjectId","__expo_shared_object_id__","descriptor","process","attributes","key","Object","keys","requireCachedNativeComponent","cacheKey","cachedNativeComponent","nativeComponent","set","mapAriaProps","props","accessibilityState","accessibilityValue","ariaBusy","ariaChecked","ariaDisabled","ariaExpanded","ariaHidden","ariaLabel","ariaLabelledBy","ariaLive","ariaSelected","ariaValueMax","ariaValueMin","ariaValueNow","ariaValueText","id","tabIndex","resolvedProps","undefined","accessibilityLabelledBy","split","accessibilityLabel","accessibilityLiveRegion","accessibilityElementsHidden","importantForAccessibility","nativeID","focusable","busy","checked","disabled","expanded","selected","max","min","now","text","requireNativeViewManager","ReactNativeComponent","NativeComponent","displayName","nativeRef","nativeTag","componentDidMount","current","getNativeRef","render","ref","nativeModule","nativeViewPrototype","ViewPrototypes","assign","prototype"],"mappings":"AAAA,mCAAmC;AAEnC,qEAAqE;AAErE;;AAEA,SAA6CA,SAAS,EAAEC,aAAa,QAAQ,QAAQ;AACrF,SAAkCC,cAAc,QAA4B,eAAe;AAC3F,SAASC,OAAOC,oBAAoB,QAAQ,iEAAiE;AAE7G,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,mBAAmB,Q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O,eAAenF,oBAAoBI;QACzC,MAAMgF,sBACJD,aAAaE,cAAc,CAAChF,WAAW,GAAGD,WAAW,CAAC,EAAEC,UAAU,GAAGD,WAAW;QAClF,IAAIgF,qBAAqB;YACvB,iGAAiG;YACjGzD,OAAO2D,MAAM,CAACZ,gBAAgBa,SAAS,EAAEH;QAC3C;IACF,EAAE,OAAM;IACN,mFAAmF;IACnF,gGAAgG;IAChG,8FAA8F;IAC9F,gEAAgE;IAChE,gIAAgI;IAClI;IAEA,OAAOV;AACT"}
1
+ {"version":3,"sources":["NativeViewManagerAdapter.native.tsx"],"sourcesContent":[null],"names":["createRef","PureComponent","findNodeHandle","NativeComponentRegistry","SharedObject","requireNativeModule","nativeComponentsCache","Map","requireNativeComponent","moduleName","viewName","appIdentifier","globalThis","expo","viewNameSuffix","nativeViewName","get","expoViewConfig","getViewConfig","console","warn","uiViewClassName","directEventTypes","validAttributes","addAttributeProcessing","processPropValue","value","sharedObjectId","__expo_shared_object_id__","descriptor","process","attributes","key","Object","keys","requireCachedNativeComponent","cacheKey","cachedNativeComponent","nativeComponent","set","mapAriaProps","props","accessibilityState","accessibilityValue","ariaBusy","ariaChecked","ariaDisabled","ariaExpanded","ariaHidden","ariaLabel","ariaLabelledBy","ariaLive","ariaSelected","ariaValueMax","ariaValueMin","ariaValueNow","ariaValueText","id","tabIndex","resolvedProps","undefined","accessibilityLabelledBy","split","accessibilityLabel","accessibilityLiveRegion","accessibilityElementsHidden","importantForAccessibility","nativeID","focusable","busy","checked","disabled","expanded","selected","max","min","now","text","requireNativeViewManager","ReactNativeComponent","NativeComponent","displayName","nativeRef","nativeTag","componentDidMount","current","getNativeRef","render","ref","nativeModule","nativeViewPrototype","ViewPrototypes","assign","prototype"],"mappings":"AAAA,mCAAmC;AAEnC;;AAEA,SAA6CA,SAAS,EAAEC,aAAa,QAAQ,QAAQ;AACrF,SAEEC,cAAc,EAEdC,uBAAuB,QAClB,eAAe;AAEtB,SAASC,YAAY,QAAQ,iBAAiB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S;;QAChF;IACF;IAEA,IAAI;QACF,MAAMO,eAAepF,oBAAoBI;QACzC,MAAMiF,sBACJD,aAAaE,cAAc,CAACjF,WAAW,GAAGD,WAAW,CAAC,EAAEC,UAAU,GAAGD,WAAW;QAClF,IAAIiF,qBAAqB;YACvB,iGAAiG;YACjGzD,OAAO2D,MAAM,CAACZ,gBAAgBa,SAAS,EAAEH;QAC3C;IACF,EAAE,OAAM;IACN,mFAAmF;IACnF,gGAAgG;IAChG,8FAA8F;IAC9F,gEAAgE;IAChE,gIAAgI;IAClI;IAEA,OAAOV;AACT"}
@@ -70,6 +70,11 @@ public final class ClassDefinition: ObjectDefinition {
70
70
  if let sharedObject = result as? SharedObject {
71
71
  appContext.sharedObjectRegistry.add(native: sharedObject, javaScript: this.getObject())
72
72
  }
73
+ } else if sharedObjectType != nil {
74
+ // Nothing built a native instance, so the object would reach JavaScript with no backing
75
+ // state and fail at its first member access. Classes whose inputs only the native side can
76
+ // supply land here: they need a `@JS init` or a DSL `Constructor` to be constructible.
77
+ throw Exceptions.ConstructorUnavailable(name)
73
78
  }
74
79
  return this
75
80
  }
@@ -99,6 +99,15 @@ public struct Exceptions {
99
99
  }
100
100
  }
101
101
 
102
+ /// An exception thrown when JavaScript calls `new` on a class whose native instance only the
103
+ /// native side can build. The class exposes no `@JS init` and no DSL `Constructor`, so there is
104
+ /// nothing to construct it with.
105
+ public final class ConstructorUnavailable: GenericException<String> {
106
+ override public var reason: String {
107
+ "'\(param)' cannot be constructed from JavaScript because its native instance is created by the module that owns it. Get an instance from that module's API instead of calling `new \(param)()`."
108
+ }
109
+ }
110
+
102
111
  /**
103
112
  An exception to throw when there is no module implementing the `EXPermissionsInterface` interface.
104
113
  - Note: This should never happen since the module is a part of `expo-modules-core`, but for compatibility reasons
@@ -63,6 +63,19 @@ open class Exception: CodedError, ChainableException, CustomStringConvertible, C
63
63
  let debugDescription = "\(name): \(reason) (at \(origin.file):\(origin.line))"
64
64
  return concatDescription(debugDescription, withCause: cause, debug: true)
65
65
  }
66
+
67
+ // MARK: - JavaScriptThrowable
68
+
69
+ /**
70
+ The message of the JavaScript error this exception is converted to. Defaults to `description`
71
+ (the reason and its cause chain), matching Android and what JavaScript received before the
72
+ JSI rewrite, instead of the protocol's default `debugDescription`, which also leaks the type
73
+ name and the native `file:line`. It is declared on the class, rather than inherited from the
74
+ protocol extension, so that subclasses can override it.
75
+ */
76
+ open var message: String {
77
+ description
78
+ }
66
79
  }
67
80
 
68
81
  /**
@@ -83,8 +83,7 @@ internal final class ReadOnlyExpoModulesPropertyException: GenericException<Stri
83
83
  + "Define or override behavior inside the native module instead."
84
84
  }
85
85
 
86
- // The default `JavaScriptThrowable.message` is `String(reflecting: self)`, which on
87
- // `Exception` resolves to `debugDescription` (name + reason + Swift file:line). For a
88
- // JS-facing error we want just `reason`, without leaking native source coordinates.
89
- var message: String { reason }
86
+ // `Exception.message` is the `description`, which is just `reason` here (no cause chain).
87
+ // Override it explicitly so the JS-facing error stays the bare `reason`.
88
+ override var message: String { reason }
90
89
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-modules-core",
3
- "version": "58.0.13",
3
+ "version": "58.0.15",
4
4
  "description": "The core of Expo Modules architecture",
5
5
  "keywords": [
6
6
  "expo",
@@ -64,16 +64,16 @@
64
64
  "./package.json": "./package.json"
65
65
  },
66
66
  "dependencies": {
67
- "expo-modules-jsi": "~58.0.9",
67
+ "expo-modules-jsi": "~58.0.10",
68
68
  "expo-modules-macros": "0.15.0",
69
69
  "invariant": "^2.2.4"
70
70
  },
71
71
  "devDependencies": {
72
+ "@expo/internal-scripts": "58.0.1",
72
73
  "@testing-library/react-native": "^14.0.1",
73
74
  "@types/invariant": "^2.2.33",
74
75
  "@types/react": "~19.3.0",
75
76
  "@types/react-dom": "^19.1.7",
76
- "expo-module-scripts": "56.0.7",
77
77
  "react-dom": "19.3.0"
78
78
  },
79
79
  "peerDependencies": {
@@ -1,12 +1,14 @@
1
1
  // Copyright © 2024 650 Industries.
2
2
 
3
- /// <reference path="ts-declarations/NativeComponentRegistry.d.ts" />
4
-
5
3
  'use client';
6
4
 
7
5
  import { type Component, type ComponentType, createRef, PureComponent } from 'react';
8
- import { type ReactNativeElement, findNodeHandle, type HostComponent } from 'react-native';
9
- import { get as componentRegistryGet } from 'react-native/Libraries/NativeComponent/NativeComponentRegistry';
6
+ import {
7
+ type ReactNativeElement,
8
+ findNodeHandle,
9
+ type HostComponent,
10
+ NativeComponentRegistry,
11
+ } from 'react-native';
10
12
 
11
13
  import { SharedObject } from './SharedObject';
12
14
  import { requireNativeModule } from './requireNativeModule';
@@ -44,7 +46,7 @@ declare namespace globalThis {
44
46
  /**
45
47
  * Requires a React Native component using the static view config from an Expo module.
46
48
  */
47
- function requireNativeComponent<Props>(
49
+ function requireNativeComponent<Props extends object>(
48
50
  moduleName: string,
49
51
  viewName?: string
50
52
  ): HostComponent<Props> {
@@ -55,7 +57,7 @@ function requireNativeComponent<Props>(
55
57
  ? `ViewManagerAdapter_${moduleName}_${viewName}${viewNameSuffix}`
56
58
  : `ViewManagerAdapter_${moduleName}${viewNameSuffix}`;
57
59
 
58
- return componentRegistryGet<Props>(nativeViewName, () => {
60
+ return NativeComponentRegistry.get<Props>(nativeViewName, () => {
59
61
  const expoViewConfig = globalThis.expo?.getViewConfig(moduleName, viewName);
60
62
 
61
63
  if (!expoViewConfig) {
@@ -113,7 +115,7 @@ function addAttributeProcessing(validAttributes: Record<string, any>): Record<st
113
115
  * "Tried to register two views with the same name" errors on fast refresh, but
114
116
  * also when there are multiple versions of the same package with native component.
115
117
  */
116
- function requireCachedNativeComponent<Props>(
118
+ function requireCachedNativeComponent<Props extends object>(
117
119
  moduleName: string,
118
120
  viewName?: string
119
121
  ): HostComponent<Props> {
@@ -211,7 +213,7 @@ function mapAriaProps(props: Record<string, any>): Record<string, any> {
211
213
  /**
212
214
  * A drop-in replacement for `requireNativeComponent`.
213
215
  */
214
- export function requireNativeViewManager<P>(
216
+ export function requireNativeViewManager<P extends object>(
215
217
  moduleName: string,
216
218
  viewName?: string
217
219
  ): ComponentType<P> {
@@ -1,12 +0,0 @@
1
- declare module 'react-native/Libraries/NativeComponent/NativeComponentRegistry' {
2
- import type { HostComponent } from 'react-native';
3
-
4
- export function get<Props>(
5
- name: string,
6
- register: () => {
7
- uiViewClassName: string;
8
- validAttributes?: Record<string, any>;
9
- directEventTypes?: Record<string, { registrationName: string }>;
10
- }
11
- ): HostComponent<Props>;
12
- }
@@ -1,12 +0,0 @@
1
- declare module 'react-native/Libraries/NativeComponent/NativeComponentRegistry' {
2
- import type { HostComponent } from 'react-native';
3
-
4
- export function get<Props>(
5
- name: string,
6
- register: () => {
7
- uiViewClassName: string;
8
- validAttributes?: Record<string, any>;
9
- directEventTypes?: Record<string, { registrationName: string }>;
10
- }
11
- ): HostComponent<Props>;
12
- }