expo-dev-launcher 4.0.3 → 4.0.4

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,12 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 4.0.4 — 2024-04-24
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - Fixed "Missing transform.routerRoot option in Metro bundling request" error when loading the bundle. ([#28428](https://github.com/expo/expo/pull/28428) by [@kudo](https://github.com/kudo))
18
+
13
19
  ## 4.0.3 — 2024-04-23
14
20
 
15
21
  _This version does not introduce any user-facing changes._
@@ -17,7 +17,7 @@ android {
17
17
  namespace "expo.modules.devlauncher"
18
18
  defaultConfig {
19
19
  versionCode 9
20
- versionName "4.0.3"
20
+ versionName "4.0.4"
21
21
  }
22
22
 
23
23
  buildTypes {
@@ -10,13 +10,17 @@ import com.facebook.react.ReactPackage
10
10
  import com.facebook.react.bridge.JSBundleLoader
11
11
  import com.facebook.react.common.annotations.UnstableReactNativeAPI
12
12
  import com.facebook.react.defaults.DefaultReactHostDelegate
13
+ import com.facebook.react.devsupport.DevLauncherDevServerHelper
13
14
  import com.facebook.react.devsupport.DevLauncherInternalSettings
15
+ import com.facebook.react.devsupport.DevServerHelper
14
16
  import com.facebook.react.devsupport.DevSupportManagerBase
15
17
  import com.facebook.react.devsupport.interfaces.DevSupportManager
18
+ import com.facebook.react.modules.systeminfo.AndroidInfoHelpers
16
19
  import com.facebook.react.runtime.ReactHostDelegate
17
20
  import com.facebook.react.runtime.ReactHostImpl
18
21
  import expo.interfaces.devmenu.ReactHostWrapper
19
22
  import expo.interfaces.devmenu.annotations.ContainsDevMenuExtension
23
+ import expo.modules.devlauncher.launcher.DevLauncherControllerInterface
20
24
  import expo.modules.devlauncher.react.DevLauncherDevSupportManagerSwapper
21
25
  import expo.modules.devlauncher.rncompatibility.DevLauncherBridgeDevSupportManager
22
26
  import expo.modules.devlauncher.rncompatibility.DevLauncherBridgelessDevSupportManager
@@ -123,11 +127,12 @@ private fun injectDebugServerHost(
123
127
  val mDevServerHelperField = devSupportManagerBaseClass.getDeclaredField("mDevServerHelper")
124
128
  mDevServerHelperField.isAccessible = true
125
129
  val devServerHelper = mDevServerHelperField[devSupportManager]
126
- val mSettingsField = devServerHelper.javaClass.getDeclaredField("mSettings")
130
+ check(devServerHelper is DevLauncherDevServerHelper)
131
+ val mSettingsField = DevServerHelper::class.java.getDeclaredField("mSettings")
127
132
  mSettingsField.isAccessible = true
128
133
  mSettingsField[devServerHelper] = settings
129
134
 
130
- val packagerConnectionSettingsField = devServerHelper.javaClass.getDeclaredField("mPackagerConnectionSettings")
135
+ val packagerConnectionSettingsField = DevServerHelper::class.java.getDeclaredField("mPackagerConnectionSettings")
131
136
  packagerConnectionSettingsField.isAccessible = true
132
137
  packagerConnectionSettingsField[devServerHelper] = settings.public_getPackagerConnectionSettings()
133
138
  }
@@ -210,6 +215,22 @@ private fun injectLocalBundleLoader(
210
215
  }
211
216
  }
212
217
 
218
+ fun injectDevServerHelper(context: Context, devSupportManager: DevSupportManager, controller: DevLauncherControllerInterface?) {
219
+ val defaultServerHost = AndroidInfoHelpers.getServerHost(context)
220
+ val devSettings = DevLauncherInternalSettings(context, defaultServerHost)
221
+ val devLauncherDevServerHelper = DevLauncherDevServerHelper(
222
+ context = context,
223
+ controller = controller,
224
+ devSettings = devSettings,
225
+ packagerConnection = devSettings.public_getPackagerConnectionSettings()
226
+ )
227
+ DevSupportManagerBase::class.java.setProtectedDeclaredField(
228
+ devSupportManager,
229
+ "mDevServerHelper",
230
+ devLauncherDevServerHelper
231
+ )
232
+ }
233
+
213
234
  fun findDevMenuPackage(): ReactPackage? {
214
235
  return try {
215
236
  val clazz = Class.forName("expo.modules.devmenu.DevMenuPackage")
@@ -0,0 +1,50 @@
1
+ package com.facebook.react.devsupport
2
+
3
+ import android.content.Context
4
+ import android.net.Uri
5
+ import com.facebook.react.modules.debug.interfaces.DeveloperSettings
6
+ import com.facebook.react.packagerconnection.PackagerConnectionSettings
7
+ import expo.modules.devlauncher.launcher.DevLauncherControllerInterface
8
+
9
+ class DevLauncherDevServerHelper(
10
+ context: Context,
11
+ private val controller: DevLauncherControllerInterface?,
12
+ devSettings: DeveloperSettings,
13
+ packagerConnection: PackagerConnectionSettings
14
+ ) :
15
+ DevServerHelper(devSettings, context.packageName, packagerConnection) {
16
+
17
+ override fun getDevServerBundleURL(jsModulePath: String?): String {
18
+ return controller?.manifest?.getBundleURL() ?: super.getDevServerBundleURL(jsModulePath)
19
+ }
20
+
21
+ override fun getDevServerSplitBundleURL(jsModulePath: String?): String {
22
+ return controller?.manifest?.getBundleURL() ?: super.getDevServerSplitBundleURL(jsModulePath)
23
+ }
24
+
25
+ override fun getSourceUrl(mainModuleName: String?): String {
26
+ return controller?.manifest?.getBundleURL() ?: super.getSourceUrl(mainModuleName)
27
+ }
28
+
29
+ override fun getSourceMapUrl(mainModuleName: String?): String {
30
+ val defaultValue = super.getSourceMapUrl(mainModuleName)
31
+ val bundleURL = controller?.manifest?.getBundleURL()
32
+ ?: return defaultValue
33
+
34
+ val parsedURL = Uri.parse(bundleURL)
35
+ val customOptions = parsedURL.queryParameterNames.mapNotNull { key ->
36
+ if (key.startsWith("transform")) {
37
+ key to requireNotNull(parsedURL.getQueryParameter(key))
38
+ } else {
39
+ null
40
+ }
41
+ }.ifEmpty {
42
+ return defaultValue
43
+ }
44
+
45
+ val customOptionsString = customOptions.joinToString("&") { (key, value) ->
46
+ "$key=$value"
47
+ }
48
+ return "$defaultValue&$customOptionsString"
49
+ }
50
+ }
@@ -1,7 +1,7 @@
1
1
  package com.facebook.react.devsupport
2
2
 
3
3
  import android.content.Context
4
- import com.facebook.react.packagerconnection.PackagerConnectionSettings
4
+ import com.facebook.react.devsupport.DevInternalSettings.Listener
5
5
  import expo.modules.devlauncher.react.DevLauncherPackagerConnectionSettings
6
6
 
7
7
  internal class DevLauncherInternalSettings(
@@ -15,16 +15,3 @@ internal class DevLauncherInternalSettings(
15
15
  @Suppress("FunctionName")
16
16
  fun public_getPackagerConnectionSettings() = getPackagerConnectionSettings()
17
17
  }
18
-
19
- /**
20
- * A wrapper of [DevInternalSettings] allows us to access the package-private [DevInternalSettings] properties
21
- */
22
- internal class DevLauncherInternalSettingsWrapper(private val devSettings: DevInternalSettings) {
23
- val isStartSamplingProfilerOnInit = devSettings.isStartSamplingProfilerOnInit
24
- var isRemoteJSDebugEnabled: Boolean
25
- get() = devSettings.isRemoteJSDebugEnabled
26
- set(value) {
27
- devSettings.isRemoteJSDebugEnabled = value
28
- }
29
- val packagerConnectionSettings: PackagerConnectionSettings = devSettings.packagerConnectionSettings
30
- }
@@ -8,6 +8,7 @@ import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener
8
8
  import com.facebook.react.devsupport.interfaces.RedBoxHandler
9
9
  import com.facebook.react.packagerconnection.RequestHandler
10
10
  import expo.modules.devlauncher.DevLauncherController
11
+ import expo.modules.devlauncher.helpers.injectDevServerHelper
11
12
  import expo.modules.devlauncher.koin.DevLauncherKoinComponent
12
13
  import expo.modules.devlauncher.koin.optInject
13
14
  import expo.modules.devlauncher.launcher.DevLauncherControllerInterface
@@ -15,7 +16,7 @@ import expo.modules.devlauncher.launcher.errors.DevLauncherAppError
15
16
  import expo.modules.devlauncher.launcher.errors.DevLauncherErrorActivity
16
17
 
17
18
  class DevLauncherBridgeDevSupportManager(
18
- applicationContext: Context?,
19
+ applicationContext: Context,
19
20
  reactInstanceDevHelper: ReactInstanceDevHelper?,
20
21
  packagerPathForJSBundleName: String?,
21
22
  enableOnCreate: Boolean,
@@ -38,10 +39,17 @@ class DevLauncherBridgeDevSupportManager(
38
39
  DevLauncherKoinComponent {
39
40
  private val controller: DevLauncherControllerInterface? by optInject()
40
41
 
42
+ init {
43
+ injectDevServerHelper(applicationContext, this, controller)
44
+ }
45
+
41
46
  override fun showNewJavaError(message: String?, e: Throwable) {
42
47
  Log.e("DevLauncher", "$message", e)
43
48
  if (!DevLauncherController.wasInitialized()) {
44
- Log.e("DevLauncher", "DevLauncher wasn't initialized. Couldn't intercept native error handling.")
49
+ Log.e(
50
+ "DevLauncher",
51
+ "DevLauncher wasn't initialized. Couldn't intercept native error handling."
52
+ )
45
53
  super.showNewJavaError(message, e)
46
54
  return
47
55
  }
@@ -55,7 +63,7 @@ class DevLauncherBridgeDevSupportManager(
55
63
  DevLauncherErrorActivity.showError(activity, DevLauncherAppError(message, e))
56
64
  }
57
65
 
58
- override fun getUniqueTag() = "DevLauncherApp - Bridge"
66
+ override fun getUniqueTag() = "DevLauncherApp-Bridge"
59
67
 
60
68
  override fun startInspector() {
61
69
  // no-op for the default `startInspector` which would be implicitly called
@@ -5,6 +5,7 @@ import android.util.Log
5
5
  import com.facebook.react.runtime.NonFinalBridgelessDevSupportManager
6
6
  import com.facebook.react.runtime.ReactHostImpl
7
7
  import expo.modules.devlauncher.DevLauncherController
8
+ import expo.modules.devlauncher.helpers.injectDevServerHelper
8
9
  import expo.modules.devlauncher.koin.DevLauncherKoinComponent
9
10
  import expo.modules.devlauncher.koin.optInject
10
11
  import expo.modules.devlauncher.launcher.DevLauncherControllerInterface
@@ -18,6 +19,10 @@ class DevLauncherBridgelessDevSupportManager(
18
19
  ) : NonFinalBridgelessDevSupportManager(host, context, packagerPathForJSBundleName), DevLauncherKoinComponent {
19
20
  private val controller: DevLauncherControllerInterface? by optInject()
20
21
 
22
+ init {
23
+ injectDevServerHelper(context, this, controller)
24
+ }
25
+
21
26
  override fun showNewJavaError(message: String?, e: Throwable) {
22
27
  Log.e("DevLauncher", "$message", e)
23
28
  if (!DevLauncherController.wasInitialized()) {
@@ -35,7 +40,7 @@ class DevLauncherBridgelessDevSupportManager(
35
40
  DevLauncherErrorActivity.showError(activity, DevLauncherAppError(message, e))
36
41
  }
37
42
 
38
- override fun getUniqueTag() = "DevLauncherApp - Bridgeless"
43
+ override fun getUniqueTag() = "DevLauncherApp-Bridgeless"
39
44
 
40
45
  override fun startInspector() {
41
46
  // no-op for the default `startInspector` which would be implicitly called
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "expo-dev-launcher",
3
3
  "title": "Expo Development Launcher",
4
- "version": "4.0.3",
4
+ "version": "4.0.4",
5
5
  "description": "Pre-release version of the Expo development launcher package for testing.",
6
6
  "main": "build/DevLauncher.js",
7
7
  "types": "build/DevLauncher.d.ts",
@@ -31,7 +31,7 @@
31
31
  "homepage": "https://docs.expo.dev",
32
32
  "dependencies": {
33
33
  "ajv": "8.11.0",
34
- "expo-dev-menu": "5.0.3",
34
+ "expo-dev-menu": "5.0.5",
35
35
  "expo-manifests": "~0.14.0",
36
36
  "resolve-from": "^5.0.0",
37
37
  "semver": "^7.6.0"
@@ -66,5 +66,5 @@
66
66
  "./setupTests.ts"
67
67
  ]
68
68
  },
69
- "gitHead": "ee4f30ef3b5fa567ad1bf94794197f7683fdd481"
69
+ "gitHead": "8b4cb45563b85c2ec91b1b249d136661bf6e8981"
70
70
  }