expo-modules-core 56.0.4 → 56.0.6

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 (84) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/android/build.gradle +39 -40
  3. package/android/src/main/cpp/Exceptions.cpp +0 -3
  4. package/android/src/main/cpp/Exceptions.h +1 -4
  5. package/android/src/main/cpp/ExpoHeader.pch +0 -2
  6. package/android/src/main/cpp/ExpoModulesHostObject.cpp +1 -2
  7. package/android/src/main/cpp/ExpoModulesHostObject.h +1 -3
  8. package/android/src/main/cpp/JNIDeallocator.h +1 -1
  9. package/android/src/main/cpp/JNIFunctionBody.cpp +0 -1
  10. package/android/src/main/cpp/JNIFunctionBody.h +1 -2
  11. package/android/src/main/cpp/JNIInjector.cpp +1 -1
  12. package/android/src/main/cpp/JNIUtils.cpp +1 -1
  13. package/android/src/main/cpp/JNIUtils.h +1 -6
  14. package/android/src/main/cpp/JSIContext.cpp +1 -5
  15. package/android/src/main/cpp/JSIContext.h +1 -6
  16. package/android/src/main/cpp/JSITypeConverter.h +1 -5
  17. package/android/src/main/cpp/JSharedObject.h +1 -1
  18. package/android/src/main/cpp/JavaCallback.cpp +8 -13
  19. package/android/src/main/cpp/JavaCallback.h +1 -7
  20. package/android/src/main/cpp/JavaReferencesCache.cpp +1 -2
  21. package/android/src/main/cpp/JavaReferencesCache.h +1 -4
  22. package/android/src/main/cpp/JavaScriptArrayBuffer.h +1 -4
  23. package/android/src/main/cpp/JavaScriptFunction.h +1 -4
  24. package/android/src/main/cpp/JavaScriptModuleObject.h +1 -5
  25. package/android/src/main/cpp/JavaScriptObject.h +1 -5
  26. package/android/src/main/cpp/JavaScriptRuntime.cpp +0 -1
  27. package/android/src/main/cpp/JavaScriptRuntime.h +1 -2
  28. package/android/src/main/cpp/JavaScriptTypedArray.h +1 -4
  29. package/android/src/main/cpp/JavaScriptValue.h +1 -5
  30. package/android/src/main/cpp/JavaScriptWeakObject.h +1 -5
  31. package/android/src/main/cpp/MethodMetadata.cpp +1 -6
  32. package/android/src/main/cpp/MethodMetadata.h +1 -9
  33. package/android/src/main/cpp/NativeArrayBuffer.h +1 -4
  34. package/android/src/main/cpp/RuntimeHolder.h +1 -2
  35. package/android/src/main/cpp/ThreadSafeJNIGlobalRef.h +1 -1
  36. package/android/src/main/cpp/concepts/jni.h +4 -4
  37. package/android/src/main/cpp/concepts/jni_deref.h +1 -1
  38. package/android/src/main/cpp/concepts/jsi.h +1 -1
  39. package/android/src/main/cpp/decorators/JSClassesDecorator.h +1 -3
  40. package/android/src/main/cpp/decorators/JSConstantsDecorator.cpp +1 -4
  41. package/android/src/main/cpp/decorators/JSConstantsDecorator.h +1 -3
  42. package/android/src/main/cpp/decorators/JSDecorator.h +1 -2
  43. package/android/src/main/cpp/decorators/JSDecoratorsBridgingObject.h +1 -4
  44. package/android/src/main/cpp/decorators/JSFunctionsDecorator.cpp +1 -2
  45. package/android/src/main/cpp/decorators/JSFunctionsDecorator.h +1 -5
  46. package/android/src/main/cpp/decorators/JSObjectDecorator.h +1 -1
  47. package/android/src/main/cpp/decorators/JSPropertiesDecorator.cpp +1 -2
  48. package/android/src/main/cpp/decorators/JSPropertiesDecorator.h +1 -3
  49. package/android/src/main/cpp/fabric/AndroidExpoViewProps.h +1 -1
  50. package/android/src/main/cpp/fabric/AndroidExpoViewState.h +1 -3
  51. package/android/src/main/cpp/fabric/FabricComponentsRegistry.h +1 -1
  52. package/android/src/main/cpp/fabric/NativeStatePropsGetter.h +1 -2
  53. package/android/src/main/cpp/installers/MainRuntimeInstaller.h +1 -2
  54. package/android/src/main/cpp/installers/WorkletRuntimeInstaller.h +1 -2
  55. package/android/src/main/cpp/javaclasses/Collections.h +1 -1
  56. package/android/src/main/cpp/javaclasses/JSRunnable.h +1 -1
  57. package/android/src/main/cpp/types/AnyType.cpp +0 -1
  58. package/android/src/main/cpp/types/AnyType.h +1 -2
  59. package/android/src/main/cpp/types/ExpectedType.h +1 -1
  60. package/android/src/main/cpp/types/FrontendConverter.cpp +1 -1
  61. package/android/src/main/cpp/types/FrontendConverter.h +1 -3
  62. package/android/src/main/cpp/types/FrontendConverterProvider.h +1 -5
  63. package/android/src/main/cpp/types/JNIToJSIConverter.h +13 -16
  64. package/android/src/main/cpp/worklets/Serializable.h +2 -2
  65. package/android/src/main/cpp/worklets/Worklet.h +2 -5
  66. package/android/src/main/cpp/worklets/WorkletJSCallInvoker.h +2 -4
  67. package/android/src/main/cpp/worklets/WorkletNativeRuntime.h +2 -2
  68. package/android/src/main/java/expo/modules/kotlin/views/decorators/CSSProps.kt +1 -1
  69. package/ios/Core/AppContext.swift +26 -4
  70. package/ios/Core/Conversions.swift +20 -7
  71. package/ios/Core/DynamicTypes/AnyDynamicType.swift +20 -0
  72. package/ios/Core/DynamicTypes/DynamicArrayType.swift +12 -6
  73. package/ios/Core/DynamicTypes/DynamicDictionaryType.swift +12 -6
  74. package/ios/Core/DynamicTypes/DynamicRawType.swift +6 -2
  75. package/ios/Core/DynamicTypes/DynamicStringType.swift +5 -1
  76. package/ios/Core/Functions/SyncFunctionDefinition.swift +1 -1
  77. package/ios/Core/MainValueConverter.swift +8 -0
  78. package/ios/JS/EXReactSchedulerDispatch.h +28 -0
  79. package/ios/JS/EXReactSchedulerDispatch.mm +19 -0
  80. package/package.json +3 -3
  81. package/prebuilds/output/debug/xcframeworks/ExpoModulesCore.tar.gz +0 -0
  82. package/prebuilds/output/debug/xcframeworks/ExpoModulesWorklets.tar.gz +0 -0
  83. package/prebuilds/output/release/xcframeworks/ExpoModulesCore.tar.gz +0 -0
  84. package/prebuilds/output/release/xcframeworks/ExpoModulesWorklets.tar.gz +0 -0
@@ -36,6 +36,11 @@ public protocol AnyDynamicType: CustomStringConvertible, Sendable {
36
36
 
37
37
  func castToJS<ValueType>(_ value: ValueType, appContext: AppContext) throws -> JavaScriptValue
38
38
 
39
+ /**
40
+ Runtime-aware `castToJS`.
41
+ */
42
+ func castToJS<ValueType>(_ value: ValueType, appContext: AppContext, in runtime: JavaScriptRuntime) throws -> JavaScriptValue
43
+
39
44
  /**
40
45
  Converts the given native value directly to `JavaScriptValue`.
41
46
  The default implementation uses `convertResult` and then `castToJS`, but dynamic types
@@ -43,6 +48,11 @@ public protocol AnyDynamicType: CustomStringConvertible, Sendable {
43
48
  */
44
49
  func convertToJS<ValueType>(_ value: ValueType, appContext: AppContext) throws -> JavaScriptValue
45
50
 
51
+ /**
52
+ Runtime-aware `convertToJS`.
53
+ */
54
+ func convertToJS<ValueType>(_ value: ValueType, appContext: AppContext, in runtime: JavaScriptRuntime) throws -> JavaScriptValue
55
+
46
56
  /**
47
57
  Converts function's result to the type that can later be converted to a JS value.
48
58
  For instance, types such as records, enumerables and shared objects need special handling
@@ -60,11 +70,21 @@ extension AnyDynamicType {
60
70
  return try Conversions.unknownToJavaScriptValue(value, appContext: appContext)
61
71
  }
62
72
 
73
+ // Default forwards to the legacy `castToJS`, dropping `runtime`
74
+ public func castToJS<ValueType>(_ value: ValueType, appContext: AppContext, in runtime: JavaScriptRuntime) throws -> JavaScriptValue {
75
+ return try castToJS(value, appContext: appContext)
76
+ }
77
+
63
78
  public func convertToJS<ValueType>(_ value: ValueType, appContext: AppContext) throws -> JavaScriptValue {
64
79
  let result = Conversions.convertFunctionResult(value, appContext: appContext, dynamicType: self)
65
80
  return try castToJS(result, appContext: appContext)
66
81
  }
67
82
 
83
+ public func convertToJS<ValueType>(_ value: ValueType, appContext: AppContext, in runtime: JavaScriptRuntime) throws -> JavaScriptValue {
84
+ let result = Conversions.convertFunctionResult(value, appContext: appContext, dynamicType: self)
85
+ return try castToJS(result, appContext: appContext, in: runtime)
86
+ }
87
+
68
88
  func convertResult<ResultType>(_ result: ResultType, appContext: AppContext) throws -> Any {
69
89
  return result
70
90
  }
@@ -55,13 +55,16 @@ internal struct DynamicArrayType: AnyDynamicType {
55
55
  are already in their post-conversion shape, such as `JavaScriptValue.undefined`.
56
56
  */
57
57
  func castToJS<ValueType>(_ value: ValueType, appContext: AppContext) throws -> JavaScriptValue {
58
+ return try castToJS(value, appContext: appContext, in: try appContext.runtime)
59
+ }
60
+
61
+ func castToJS<ValueType>(_ value: ValueType, appContext: AppContext, in runtime: JavaScriptRuntime) throws -> JavaScriptValue {
58
62
  guard let array = value as? [Any] else {
59
- return try Conversions.anyToJavaScriptValue(value, appContext: appContext)
63
+ return try Conversions.anyToJavaScriptValue(value, appContext: appContext, in: runtime)
60
64
  }
61
- let runtime = try appContext.runtime
62
65
  let jsArray = runtime.createArray(length: array.count)
63
66
  for (index, element) in array.enumerated() {
64
- try jsArray.set(value: try elementType.castToJS(element, appContext: appContext), at: index)
67
+ try jsArray.set(value: try elementType.castToJS(element, appContext: appContext, in: runtime), at: index)
65
68
  }
66
69
  return jsArray.asValue()
67
70
  }
@@ -71,13 +74,16 @@ internal struct DynamicArrayType: AnyDynamicType {
71
74
  to use their own direct conversion paths before any array-level normalization.
72
75
  */
73
76
  func convertToJS<ValueType>(_ value: ValueType, appContext: AppContext) throws -> JavaScriptValue {
77
+ return try convertToJS(value, appContext: appContext, in: try appContext.runtime)
78
+ }
79
+
80
+ func convertToJS<ValueType>(_ value: ValueType, appContext: AppContext, in runtime: JavaScriptRuntime) throws -> JavaScriptValue {
74
81
  guard let array = value as? [Any] else {
75
- return try Conversions.anyToJavaScriptValue(value, appContext: appContext)
82
+ return try Conversions.anyToJavaScriptValue(value, appContext: appContext, in: runtime)
76
83
  }
77
- let runtime = try appContext.runtime
78
84
  let jsArray = runtime.createArray(length: array.count)
79
85
  for (index, element) in array.enumerated() {
80
- try jsArray.set(value: try elementType.convertToJS(element, appContext: appContext), at: index)
86
+ try jsArray.set(value: try elementType.convertToJS(element, appContext: appContext, in: runtime), at: index)
81
87
  }
82
88
  return jsArray.asValue()
83
89
  }
@@ -61,14 +61,17 @@ internal struct DynamicDictionaryType: AnyDynamicType {
61
61
  are already in their post-conversion shape, such as `JavaScriptValue.undefined`.
62
62
  */
63
63
  func castToJS<ValueType>(_ value: ValueType, appContext: AppContext) throws -> JavaScriptValue {
64
+ return try castToJS(value, appContext: appContext, in: try appContext.runtime)
65
+ }
66
+
67
+ func castToJS<ValueType>(_ value: ValueType, appContext: AppContext, in runtime: JavaScriptRuntime) throws -> JavaScriptValue {
64
68
  guard let dict = value as? [AnyHashable: Any] else {
65
- return try Conversions.anyToJavaScriptValue(value, appContext: appContext)
69
+ return try Conversions.anyToJavaScriptValue(value, appContext: appContext, in: runtime)
66
70
  }
67
- let runtime = try appContext.runtime
68
71
  let jsObject = runtime.createObject()
69
72
  for (key, element) in dict {
70
73
  guard let key = key as? String else { continue }
71
- jsObject.setProperty(key, value: try valueType.castToJS(element, appContext: appContext))
74
+ jsObject.setProperty(key, value: try valueType.castToJS(element, appContext: appContext, in: runtime))
72
75
  }
73
76
  return jsObject.asValue()
74
77
  }
@@ -78,14 +81,17 @@ internal struct DynamicDictionaryType: AnyDynamicType {
78
81
  to use their own direct conversion paths before any dictionary-level normalization.
79
82
  */
80
83
  func convertToJS<ValueType>(_ value: ValueType, appContext: AppContext) throws -> JavaScriptValue {
84
+ return try convertToJS(value, appContext: appContext, in: try appContext.runtime)
85
+ }
86
+
87
+ func convertToJS<ValueType>(_ value: ValueType, appContext: AppContext, in runtime: JavaScriptRuntime) throws -> JavaScriptValue {
81
88
  guard let dict = value as? [AnyHashable: Any] else {
82
- return try Conversions.anyToJavaScriptValue(value, appContext: appContext)
89
+ return try Conversions.anyToJavaScriptValue(value, appContext: appContext, in: runtime)
83
90
  }
84
- let runtime = try appContext.runtime
85
91
  let jsObject = runtime.createObject()
86
92
  for (key, element) in dict {
87
93
  guard let key = key as? String else { continue }
88
- jsObject.setProperty(key, value: try valueType.convertToJS(element, appContext: appContext))
94
+ jsObject.setProperty(key, value: try valueType.convertToJS(element, appContext: appContext, in: runtime))
89
95
  }
90
96
  return jsObject.asValue()
91
97
  }
@@ -38,6 +38,10 @@ internal struct DynamicRawType<InnerType>: AnyDynamicType {
38
38
  }
39
39
 
40
40
  func castToJS<ValueType>(_ value: ValueType, appContext: AppContext) throws -> JavaScriptValue {
41
+ return try castToJS(value, appContext: appContext, in: try appContext.runtime)
42
+ }
43
+
44
+ func castToJS<ValueType>(_ value: ValueType, appContext: AppContext, in runtime: JavaScriptRuntime) throws -> JavaScriptValue {
41
45
  if Optional.isNil(value) {
42
46
  return .null
43
47
  }
@@ -46,9 +50,9 @@ internal struct DynamicRawType<InnerType>: AnyDynamicType {
46
50
  // handlers like `DynamicEnumType.castToJS`. Guarded against infinite recursion: the
47
51
  // dispatch only kicks in when the value's runtime type differs from `innerType`.
48
52
  if InnerType.self != type(of: value as Any), let argument = value as? AnyArgument {
49
- return try type(of: argument).getDynamicType().castToJS(argument, appContext: appContext)
53
+ return try type(of: argument).getDynamicType().castToJS(argument, appContext: appContext, in: runtime)
50
54
  }
51
- return try Conversions.unknownToJavaScriptValue(value, appContext: appContext)
55
+ return try Conversions.unknownToJavaScriptValue(value, appContext: appContext, in: runtime)
52
56
  }
53
57
 
54
58
  func convertResult<ResultType>(_ result: ResultType, appContext: AppContext) throws -> Any {
@@ -28,8 +28,12 @@ internal struct DynamicStringType: AnyDynamicType {
28
28
  }
29
29
 
30
30
  func castToJS<ValueType>(_ value: ValueType, appContext: AppContext) throws -> JavaScriptValue {
31
+ return try castToJS(value, appContext: appContext, in: try appContext.runtime)
32
+ }
33
+
34
+ func castToJS<ValueType>(_ value: ValueType, appContext: AppContext, in runtime: JavaScriptRuntime) throws -> JavaScriptValue {
31
35
  if let string = value as? String {
32
- return JavaScriptValue(try appContext.runtime, string)
36
+ return JavaScriptValue(runtime, string)
33
37
  }
34
38
  throw Conversions.ConversionToJSFailedException((kind: .string, nativeType: ValueType.self))
35
39
  }
@@ -101,7 +101,7 @@ public class SyncFunctionDefinition<Args, FirstArgType, ReturnType>: AnySyncFunc
101
101
  func call(_ appContext: AppContext, in runtime: JavaScriptRuntime, this: JavaScriptValue, arguments: consuming JavaScriptValuesBuffer) throws(Exception) -> JavaScriptValue {
102
102
  let result = try runBody(appContext, in: runtime, this: this, arguments: arguments)
103
103
  do {
104
- return try appContext.converter.toJS(result, returnType)
104
+ return try appContext.converter.toJS(result, returnType, in: runtime)
105
105
  } catch let error as Exception {
106
106
  throw FunctionCallException(name).causedBy(error)
107
107
  } catch {
@@ -42,4 +42,12 @@ public struct MainValueConverter: ~Copyable {
42
42
  public func toJS(_ value: Any, _ type: AnyDynamicType) throws -> JavaScriptValue {
43
43
  return try type.convertToJS(value, appContext: appContext)
44
44
  }
45
+
46
+ /**
47
+ `toJS` variant that targets a specific runtime. Useful for Worklet runtime conversions.
48
+ */
49
+ @JavaScriptActor
50
+ public func toJS(_ value: Any, _ type: AnyDynamicType, in runtime: JavaScriptRuntime) throws -> JavaScriptValue {
51
+ return try type.convertToJS(value, appContext: appContext, in: runtime)
52
+ }
45
53
  }
@@ -0,0 +1,28 @@
1
+ // Copyright 2025-present 650 Industries. All rights reserved.
2
+
3
+ #pragma once
4
+
5
+ #ifdef __cplusplus
6
+
7
+ namespace expo {
8
+
9
+ /**
10
+ Trampoline that `ExpoModulesJSI` calls to dispatch work onto the JS thread.
11
+ Casts the `nativeScheduler` pointer back to a `react::RuntimeScheduler *` and
12
+ calls `scheduleTask` on it. The signature matches `expo::RuntimeScheduler::ScheduleFn`
13
+ declared in the xcframework's `RuntimeScheduler.h`.
14
+
15
+ Lives in ExpoModulesCore (rather than in the xcframework) so that
16
+ ExpoModulesJSI.framework's prebuilt binary doesn't need to link against
17
+ React-runtimescheduler — important for source-built RN, where those symbols
18
+ are hidden after link and unreachable via -undefined dynamic_lookup.
19
+
20
+ Hosts that initialize their own runtime (e.g. ExpoReactNativeFactory, Expo Go)
21
+ pass `&expo::dispatchOnReactScheduler` as the `dispatch` argument to
22
+ `AppContext.setRuntime`.
23
+ */
24
+ void dispatchOnReactScheduler(void *nativeScheduler, int priority, void (^callback)()) noexcept;
25
+
26
+ } // namespace expo
27
+
28
+ #endif // __cplusplus
@@ -0,0 +1,19 @@
1
+ // Copyright 2025-present 650 Industries. All rights reserved.
2
+
3
+ #import "EXReactSchedulerDispatch.h"
4
+
5
+ #import <react/renderer/runtimescheduler/RuntimeScheduler.h>
6
+
7
+ namespace expo {
8
+
9
+ void dispatchOnReactScheduler(void *nativeScheduler, int priority, void (^callback)()) noexcept
10
+ {
11
+ auto *scheduler = static_cast<facebook::react::RuntimeScheduler *>(nativeScheduler);
12
+ scheduler->scheduleTask(
13
+ static_cast<facebook::react::SchedulerPriority>(priority),
14
+ [callback](facebook::jsi::Runtime &) {
15
+ callback();
16
+ });
17
+ }
18
+
19
+ } // namespace expo
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-modules-core",
3
- "version": "56.0.4",
3
+ "version": "56.0.6",
4
4
  "description": "The core of Expo Modules architecture",
5
5
  "main": "src/index.ts",
6
6
  "types": "build/index.d.ts",
@@ -47,7 +47,7 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "@expo/expo-modules-macros-plugin": "~0.0.8",
50
- "expo-modules-jsi": "~56.0.1",
50
+ "expo-modules-jsi": "~56.0.3",
51
51
  "invariant": "^2.2.4"
52
52
  },
53
53
  "peerDependencies": {
@@ -66,7 +66,7 @@
66
66
  "@types/invariant": "^2.2.33",
67
67
  "expo-module-scripts": "56.0.2"
68
68
  },
69
- "gitHead": "d7b4e5edff4bf2e619d2c2f16d158798c6d592ef",
69
+ "gitHead": "42013232893cb2aa71ab218e9b422d4a8476b3f0",
70
70
  "scripts": {
71
71
  "build": "expo-module build",
72
72
  "clean": "expo-module clean",