expo-modules-core 58.1.0 → 58.2.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.
- package/CHANGELOG.md +15 -0
- package/android/build.gradle +3 -3
- package/android/prebuilt/metadata.json +1 -1
- package/android/prebuilt/native-libs.tar.xz +0 -0
- package/android/src/main/java/expo/modules/kotlin/AppContext.kt +4 -2
- package/android/src/main/java/expo/modules/kotlin/sharedobjects/SharedObjectRegistry.kt +6 -2
- package/android/src/main/java/expo/modules/v2/AppExpoContext.kt +35 -0
- package/android/src/main/java/expo/modules/v2/ExpoModulesV2Host.kt +31 -14
- package/expo-module-gradle-plugin/build.gradle.kts +1 -1
- package/ios/Core/AppContext.swift +17 -2
- package/ios/Core/Views/SwiftUI/SwiftUIHostingView.swift +4 -1
- package/package.json +2 -2
- package/prebuilds/output/debug/xcframeworks/ExpoModulesCore.tar.gz +0 -0
- package/prebuilds/output/debug/xcframeworks/ExpoModulesWorklets.tar.gz +0 -0
- package/prebuilds/output/headers/xcframeworks/ExpoModulesCoreHeaders.tar.gz +0 -0
- package/prebuilds/output/headers/xcframeworks/ExpoModulesWorkletsHeaders.tar.gz +0 -0
- package/prebuilds/output/release/xcframeworks/ExpoModulesCore.tar.gz +0 -0
- package/prebuilds/output/release/xcframeworks/ExpoModulesWorklets.tar.gz +0 -0
- package/spm.config.json +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 58.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [iOS] Ship an `ExpoModulesWorkletsHeaders.xcframework` with the iOS prebuilds. A module built from its checked-in Package.swift can depend on the `ExpoModulesWorkletsHeaders` product to compile against `ExpoModulesWorklets`. ([#53322](https://github.com/expo/expo/pull/53322) by [@chrfalch](https://github.com/chrfalch))
|
|
8
|
+
- [Android] Add the `legacyAppContext` and `legacyAppContextOrNull` extensions, which give an Expo Modules API 2.0 module or shared object the `AppContext` of the app. ([#53860](https://github.com/expo/expo/pull/53860) by [@lukmccall](https://github.com/lukmccall))
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- [Android] Fixed a race in `SharedObjectRegistry` where a live shared object passed to an async function could be reported as already released (`UsingReleasedSharedObjectException`) while another thread added or released a shared object. ([#50939](https://github.com/expo/expo/pull/50939) by [@edwardsmatt](https://github.com/edwardsmatt))
|
|
13
|
+
- [iOS] Fix a crash when several concurrent functions read `appContext.fileSystem` or `appContext.permissions` for the first time at once, such as parallel `openDatabaseAsync` calls in `expo-sqlite`. ([#54321](https://github.com/expo/expo/pull/54321) by [@intergalacticspacehighway](https://github.com/intergalacticspacehighway))
|
|
14
|
+
- [iOS] Fixed SwiftUI views (such as `@expo/ui`'s `Host`) rendering nothing when mounted outside any view controller, for example inside react-native-screens' `FullWindowOverlay`. ([#50966](https://github.com/expo/expo/pull/50966) by [@finn-pleo](https://github.com/finn-pleo))
|
|
15
|
+
- Updated dependencies. ([#54091](https://github.com/expo/expo/pull/54091))
|
|
16
|
+
- expo-modules-jsi@58.0.24
|
|
17
|
+
|
|
3
18
|
## 58.1.0
|
|
4
19
|
|
|
5
20
|
### Minor Changes
|
package/android/build.gradle
CHANGED
|
@@ -46,7 +46,7 @@ if (shouldIncludeCompose) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
group = 'host.exp.exponent'
|
|
49
|
-
version = '58.
|
|
49
|
+
version = '58.2.0'
|
|
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.
|
|
100
|
+
def expoModulesV2Version = "0.3.0"
|
|
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.
|
|
178
|
+
versionName "58.2.0"
|
|
179
179
|
buildConfigField "String", "EXPO_MODULES_CORE_VERSION", "\"${versionName}\""
|
|
180
180
|
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", "true"
|
|
181
181
|
|
|
Binary file
|
|
@@ -100,6 +100,8 @@ class AppContext(
|
|
|
100
100
|
|
|
101
101
|
val services = ServicesRegistry(this.weak())
|
|
102
102
|
|
|
103
|
+
private val expoModulesV2Host = ExpoModulesV2Host()
|
|
104
|
+
|
|
103
105
|
internal var legacyModulesProxyHolder: WeakReference<NativeModulesProxy>? = null
|
|
104
106
|
|
|
105
107
|
private val activityResultsManager = ActivityResultsManager(this)
|
|
@@ -154,7 +156,7 @@ class AppContext(
|
|
|
154
156
|
*/
|
|
155
157
|
fun installJSIInterop() {
|
|
156
158
|
runtime.install()
|
|
157
|
-
runtime.reactContext?.let(
|
|
159
|
+
runtime.reactContext?.let { expoModulesV2Host.install(this, it) }
|
|
158
160
|
}
|
|
159
161
|
|
|
160
162
|
/**
|
|
@@ -286,7 +288,7 @@ class AppContext(
|
|
|
286
288
|
mainQueue.cancel(ContextDestroyedException())
|
|
287
289
|
backgroundCoroutineScope.cancel(ContextDestroyedException())
|
|
288
290
|
|
|
289
|
-
|
|
291
|
+
expoModulesV2Host.uninstall()
|
|
290
292
|
|
|
291
293
|
runtime.deallocate()
|
|
292
294
|
if (uiRuntimeHolder.isInitialized()) {
|
|
@@ -108,7 +108,9 @@ class SharedObjectRegistry(runtime: Runtime) {
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
internal fun toNativeObject(id: SharedObjectId): SharedObject {
|
|
111
|
-
val native =
|
|
111
|
+
val native = synchronized(this) {
|
|
112
|
+
pairs[id.ensureWasNotRelease()]?.first
|
|
113
|
+
}
|
|
112
114
|
return native ?: throw InvalidSharedObjectIdException()
|
|
113
115
|
}
|
|
114
116
|
|
|
@@ -124,7 +126,9 @@ class SharedObjectRegistry(runtime: Runtime) {
|
|
|
124
126
|
}
|
|
125
127
|
|
|
126
128
|
val id = SharedObjectId(js.getProperty(sharedObjectIdPropertyName).getInt())
|
|
127
|
-
return
|
|
129
|
+
return synchronized(this) {
|
|
130
|
+
pairs[id]?.first
|
|
131
|
+
}
|
|
128
132
|
}
|
|
129
133
|
|
|
130
134
|
internal fun toJavaScriptObjectOrNull(native: SharedObject): JavaScriptObject? {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
package expo.modules.v2
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
import expo.modules.kotlin.AppContext
|
|
5
|
+
import expo.modules.kotlin.exception.Exceptions
|
|
6
|
+
import io.github.expo.modules.v2.ExpoObject
|
|
7
|
+
import io.github.expo.modules.v2.react.ReactExpoContext
|
|
8
|
+
import java.lang.ref.WeakReference
|
|
9
|
+
|
|
10
|
+
internal class AppExpoContext(
|
|
11
|
+
appContext: AppContext,
|
|
12
|
+
reactContext: ReactApplicationContext
|
|
13
|
+
) : ReactExpoContext(reactContext) {
|
|
14
|
+
private val appContextHolder = WeakReference(appContext)
|
|
15
|
+
|
|
16
|
+
val appContext: AppContext?
|
|
17
|
+
get() = appContextHolder.get()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The [AppContext] of the app this module or shared object belongs to. Throws when the object has
|
|
22
|
+
* no context yet, when that context is closed, or when it was not created by `expo-modules-core`.
|
|
23
|
+
*/
|
|
24
|
+
val ExpoObject.legacyAppContext: AppContext
|
|
25
|
+
get() {
|
|
26
|
+
val context = context
|
|
27
|
+
check(context is AppExpoContext) {
|
|
28
|
+
"${javaClass.name} belongs to a ${context.javaClass.name}, which has no AppContext"
|
|
29
|
+
}
|
|
30
|
+
return context.appContext ?: throw Exceptions.AppContextLost()
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Like [legacyAppContext], but null instead of throwing. */
|
|
34
|
+
val ExpoObject.legacyAppContextOrNull: AppContext?
|
|
35
|
+
get() = (contextOrNull as? AppExpoContext)?.appContext
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
package expo.modules.v2
|
|
2
2
|
|
|
3
3
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
import expo.modules.kotlin.AppContext
|
|
4
5
|
import expo.modules.kotlin.logger
|
|
5
6
|
import io.github.expo.modules.v2.Module
|
|
6
7
|
import io.github.expo.modules.v2.react.ExpoModulesV2React
|
|
7
8
|
import io.github.expo.modules.v2.react.ReactRuntime
|
|
8
9
|
import java.lang.reflect.Modifier
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
private const val GENERATED_PROVIDER_CLASS = "expo.modules.ExpoModulesV2ModuleList"
|
|
12
|
-
|
|
11
|
+
class ExpoModulesV2Host {
|
|
13
12
|
private var runtime: ReactRuntime? = null
|
|
14
13
|
|
|
15
|
-
fun install(reactContext: ReactApplicationContext) =
|
|
14
|
+
fun install(appContext: AppContext, reactContext: ReactApplicationContext) =
|
|
16
15
|
synchronized(this) {
|
|
17
16
|
if (runtime != null) {
|
|
18
17
|
logger.warn("⚠️ Expo Modules v2 was already installed")
|
|
@@ -34,27 +33,41 @@ object ExpoModulesV2Host {
|
|
|
34
33
|
// Must run before `ReactRuntime` initializes. Its superclass, kolibri's `NativeObject`,
|
|
35
34
|
// otherwise loads the native library under kolibri's default name, which does not exist.
|
|
36
35
|
ExpoModulesV2React.ensureLoaded()
|
|
37
|
-
// The runtime
|
|
38
|
-
val
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
throw e
|
|
36
|
+
// The runtime does not own this context, so `close` below closes it too.
|
|
37
|
+
val context = AppExpoContext(appContext, reactContext)
|
|
38
|
+
val attached = ReactRuntime.attach(reactContext, context = context)
|
|
39
|
+
val registered = modules.count { module -> register(attached, module) }
|
|
40
|
+
if (registered == 0) {
|
|
41
|
+
close(attached)
|
|
42
|
+
return
|
|
45
43
|
}
|
|
46
44
|
runtime = attached
|
|
47
|
-
logger.info("✅ Expo Modules v2 installed $
|
|
45
|
+
logger.info("✅ Expo Modules v2 installed $registered module(s) on globalThis.expo.modules")
|
|
48
46
|
} catch (e: Throwable) {
|
|
49
47
|
logger.error("❌ Cannot install Expo Modules v2: $e", e)
|
|
50
48
|
}
|
|
51
49
|
}
|
|
52
50
|
|
|
53
51
|
fun uninstall() = synchronized(this) {
|
|
54
|
-
runtime?.close
|
|
52
|
+
runtime?.let(::close)
|
|
55
53
|
runtime = null
|
|
56
54
|
}
|
|
57
55
|
|
|
56
|
+
private fun register(runtime: ReactRuntime, module: Module): Boolean =
|
|
57
|
+
try {
|
|
58
|
+
runtime.moduleRegistry.register(module)
|
|
59
|
+
true
|
|
60
|
+
} catch (e: Throwable) {
|
|
61
|
+
logger.error("❌ Cannot register the Expo Modules v2 module ${module.javaClass.name}: $e", e)
|
|
62
|
+
false
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private fun close(runtime: ReactRuntime) {
|
|
66
|
+
// The same order as a runtime that owns its context: the context first, then the runtime.
|
|
67
|
+
runtime.context.close()
|
|
68
|
+
runtime.close()
|
|
69
|
+
}
|
|
70
|
+
|
|
58
71
|
private fun autolinkedModules(): List<Module> {
|
|
59
72
|
val provider = try {
|
|
60
73
|
Class.forName(GENERATED_PROVIDER_CLASS)
|
|
@@ -78,4 +91,8 @@ object ExpoModulesV2Host {
|
|
|
78
91
|
|
|
79
92
|
return moduleClass.getDeclaredConstructor().apply { isAccessible = true }.newInstance()
|
|
80
93
|
}
|
|
94
|
+
|
|
95
|
+
private companion object {
|
|
96
|
+
const val GENERATED_PROVIDER_CLASS = "expo.modules.ExpoModulesV2ModuleList"
|
|
97
|
+
}
|
|
81
98
|
}
|
|
@@ -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.
|
|
36
|
+
implementation("io.github.expo:expo-modules-v2-gradle-plugin:0.3.0")
|
|
37
37
|
|
|
38
38
|
if (isExpoAutolinkingSettingsPluginAvailable) {
|
|
39
39
|
implementation("expo.modules:expo-autolinking-plugin-shared")
|
|
@@ -272,17 +272,32 @@ public class AppContext: NSObject, EXAppContextProtocol, @unchecked Sendable {
|
|
|
272
272
|
*/
|
|
273
273
|
public lazy var constants: EXConstantsInterface? = ConstantsProvider.shared
|
|
274
274
|
|
|
275
|
+
// Created on first access, like a `lazy var`, but under a lock: concurrent functions can read it on several threads at once.
|
|
276
|
+
private let fileSystemStorage = Mutex<FileSystemManager?>(nil)
|
|
277
|
+
|
|
275
278
|
/**
|
|
276
279
|
Provides access to the file system utilities. Can be overridden if the app should use different directories or file permissions.
|
|
277
280
|
For instance, Expo Go uses sandboxed environment per project where the cache and document directories must be scoped.
|
|
278
281
|
It's an optional type for historical reasons, for now let's keep it like this for backwards compatibility.
|
|
279
282
|
*/
|
|
280
|
-
public
|
|
283
|
+
public var fileSystem: FileSystemManager? {
|
|
284
|
+
get {
|
|
285
|
+
fileSystemStorage.withLock { stored in
|
|
286
|
+
if let stored {
|
|
287
|
+
return stored
|
|
288
|
+
}
|
|
289
|
+
let fileSystem = FileSystemManager(appGroupSharedDirectories: config.appGroupSharedDirectories)
|
|
290
|
+
stored = fileSystem
|
|
291
|
+
return fileSystem
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
set { fileSystemStorage.withLock { $0 = newValue } }
|
|
295
|
+
}
|
|
281
296
|
|
|
282
297
|
/**
|
|
283
298
|
Provides access to the permissions manager.
|
|
284
299
|
*/
|
|
285
|
-
public
|
|
300
|
+
public var permissions: EXPermissionsService? = EXPermissionsService()
|
|
286
301
|
|
|
287
302
|
/**
|
|
288
303
|
Provides access to the image loader from legacy module registry.
|
|
@@ -241,8 +241,11 @@ extension ExpoSwiftUI {
|
|
|
241
241
|
parentController?.addChild(hostingController)
|
|
242
242
|
#else
|
|
243
243
|
guard let parentController else {
|
|
244
|
-
|
|
244
|
+
// Mounted on the window with no view controller, as `FullWindowOverlay` does.
|
|
245
|
+
// Render without containment.
|
|
245
246
|
hostingController.removeFromParent()
|
|
247
|
+
addSubview(hostingController.view)
|
|
248
|
+
setupHostingViewConstraints()
|
|
246
249
|
return
|
|
247
250
|
}
|
|
248
251
|
// `reactViewController()` walks the responder chain, which may not match the view hierarchy:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-modules-core",
|
|
3
|
-
"version": "58.
|
|
3
|
+
"version": "58.2.0",
|
|
4
4
|
"description": "The core of Expo Modules architecture",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"expo",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"./package.json": "./package.json"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"expo-modules-jsi": "~58.0.
|
|
69
|
+
"expo-modules-jsi": "~58.0.24",
|
|
70
70
|
"expo-modules-macros": "0.33.0",
|
|
71
71
|
"invariant": "^2.2.4"
|
|
72
72
|
},
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|