expo-modules-core 3.0.7 → 3.0.8

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
@@ -10,6 +10,10 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 3.0.8 — 2025-08-27
14
+
15
+ _This version does not introduce any user-facing changes._
16
+
13
17
  ## 3.0.7 — 2025-08-26
14
18
 
15
19
  ### 🐛 Bug fixes
@@ -25,7 +25,7 @@ if (shouldIncludeCompose) {
25
25
  }
26
26
 
27
27
  group = 'host.exp.exponent'
28
- version = '3.0.7'
28
+ version = '3.0.8'
29
29
 
30
30
  def isExpoModulesCoreTests = {
31
31
  Gradle gradle = getGradle()
@@ -75,7 +75,7 @@ android {
75
75
  defaultConfig {
76
76
  consumerProguardFiles 'proguard-rules.pro'
77
77
  versionCode 1
78
- versionName "3.0.7"
78
+ versionName "3.0.8"
79
79
  buildConfigField "String", "EXPO_MODULES_CORE_VERSION", "\"${versionName}\""
80
80
  buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled.toString()
81
81
 
@@ -26,7 +26,9 @@ import expo.modules.interfaces.permissions.Permissions
26
26
  import expo.modules.interfaces.taskManager.TaskManagerInterface
27
27
  import expo.modules.kotlin.activityresult.ActivityResultsManager
28
28
  import expo.modules.kotlin.activityresult.DefaultAppContextActivityResultCaller
29
+ import expo.modules.kotlin.defaultmodules.AppDirectoriesModule
29
30
  import expo.modules.kotlin.defaultmodules.ErrorManagerModule
31
+ import expo.modules.kotlin.defaultmodules.FilePermissionModule
30
32
  import expo.modules.kotlin.defaultmodules.NativeModulesProxyModule
31
33
  import expo.modules.kotlin.events.EventEmitter
32
34
  import expo.modules.kotlin.events.EventName
@@ -107,9 +109,14 @@ class AppContext(
107
109
  // Registering modules has to happen at the very end of `AppContext` creation. Some modules need to access
108
110
  // `AppContext` during their initialisation, so we need to ensure all `AppContext`'s
109
111
  // properties are initialized first. Not having that would trigger NPE.
110
- hostingRuntimeContext.registry.register(ErrorManagerModule())
111
- hostingRuntimeContext.registry.register(NativeModulesProxyModule())
112
- hostingRuntimeContext.registry.register(modulesProvider)
112
+ registry.register(ErrorManagerModule())
113
+ registry.register(NativeModulesProxyModule())
114
+
115
+ // Registering modules that were previously provided by legacy FileSystem module.
116
+ legacyModuleRegistry.registerInternalModule(FilePermissionModule())
117
+ legacyModuleRegistry.registerInternalModule(AppDirectoriesModule(this))
118
+
119
+ registry.register(modulesProvider)
113
120
 
114
121
  logger.info("✅ AppContext was initialized")
115
122
  }
@@ -132,7 +139,8 @@ class AppContext(
132
139
  */
133
140
  inline fun <reified Module> legacyModule(): Module? {
134
141
  return try {
135
- legacyModuleRegistry.getModule(Module::class.java)
142
+ val module = legacyModuleRegistry.getModule(Module::class.java)
143
+ return module
136
144
  } catch (_: Exception) {
137
145
  null
138
146
  }
@@ -0,0 +1,26 @@
1
+ package expo.modules.kotlin.defaultmodules
2
+
3
+ import android.content.Context
4
+ import expo.modules.core.interfaces.InternalModule
5
+ import expo.modules.interfaces.filesystem.AppDirectoriesModuleInterface
6
+ import java.io.File
7
+
8
+ /*
9
+ New Sweet API modules don't have an easy way to access scoped context. We can't initialize them with scoped context as they need a ReactApplicationContext instead.
10
+ We can't make ScopedContext inherit from ReactApplicationContext as that would require moving ScopedContext to versioned and a large refactor.
11
+
12
+ This module is a stopgap solution to provide modules with a way to access ScopedContext directories using the filesystem module, only for our internal modules.
13
+ */
14
+
15
+ // The class needs to be 'open', because it's inherited in expoview
16
+ open class AppDirectoriesModule(private val context: Context) : AppDirectoriesModuleInterface, InternalModule {
17
+
18
+ override fun getExportedInterfaces(): List<Class<*>> =
19
+ listOf(AppDirectoriesModuleInterface::class.java)
20
+
21
+ override val cacheDirectory: File
22
+ get() = context.cacheDir
23
+
24
+ override val persistentFilesDirectory: File
25
+ get() = context.filesDir
26
+ }
@@ -0,0 +1,48 @@
1
+ package expo.modules.kotlin.defaultmodules
2
+
3
+ import android.content.Context
4
+ import expo.modules.interfaces.filesystem.FilePermissionModuleInterface
5
+ import expo.modules.core.interfaces.InternalModule
6
+ import expo.modules.interfaces.filesystem.Permission
7
+ import java.io.File
8
+ import java.io.IOException
9
+ import java.util.*
10
+
11
+ // The class needs to be 'open', because it's inherited in expoview
12
+ open class FilePermissionModule : FilePermissionModuleInterface, InternalModule {
13
+ override fun getExportedInterfaces(): List<Class<*>> =
14
+ listOf(FilePermissionModuleInterface::class.java)
15
+
16
+ override fun getPathPermissions(context: Context, path: String): EnumSet<Permission> =
17
+ getInternalPathPermissions(path, context) ?: getExternalPathPermissions(path)
18
+
19
+ private fun getInternalPathPermissions(path: String, context: Context): EnumSet<Permission>? {
20
+ return try {
21
+ val canonicalPath = File(path).canonicalPath
22
+ getInternalPaths(context)
23
+ .firstOrNull { dir -> canonicalPath.startsWith("$dir/") || dir == canonicalPath }
24
+ ?.let { EnumSet.of(Permission.READ, Permission.WRITE) }
25
+ } catch (e: IOException) {
26
+ EnumSet.noneOf(Permission::class.java)
27
+ }
28
+ }
29
+
30
+ protected open fun getExternalPathPermissions(path: String): EnumSet<Permission> {
31
+ val file = File(path)
32
+ return EnumSet.noneOf(Permission::class.java).apply {
33
+ if (file.canRead()) {
34
+ add(Permission.READ)
35
+ }
36
+ if (file.canWrite()) {
37
+ add(Permission.WRITE)
38
+ }
39
+ }
40
+ }
41
+
42
+ @Throws(IOException::class)
43
+ private fun getInternalPaths(context: Context): List<String> =
44
+ listOf(
45
+ context.filesDir.canonicalPath,
46
+ context.cacheDir.canonicalPath
47
+ )
48
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-modules-core",
3
- "version": "3.0.7",
3
+ "version": "3.0.8",
4
4
  "description": "The core of Expo Modules architecture",
5
5
  "main": "src/index.ts",
6
6
  "types": "build/index.d.ts",
@@ -65,5 +65,5 @@
65
65
  "@testing-library/react-native": "^13.2.0",
66
66
  "expo-module-scripts": "^5.0.4"
67
67
  },
68
- "gitHead": "d44e41c9c0714a838b1652556d27bcb506fabbdf"
68
+ "gitHead": "48faa7b9a9f93a7660cb80aa118c7f6bf0aeff38"
69
69
  }