expo-dev-launcher 3.6.9 → 3.6.10

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
+ ## 3.6.10 — 2024-05-25
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - Fixed loading error from a https dev-server on Android. ([#28691](https://github.com/expo/expo/pull/28691) by [@kudo](https://github.com/kudo))
18
+
13
19
  ## 3.6.9 — 2024-03-20
14
20
 
15
21
  ### 📚 3rd party library updates
@@ -53,7 +53,7 @@ android {
53
53
  minSdkVersion safeExtGet('minSdkVersion', 21)
54
54
  targetSdkVersion safeExtGet("targetSdkVersion", 34)
55
55
  versionCode 9
56
- versionName "3.6.9"
56
+ versionName "3.6.10"
57
57
  }
58
58
 
59
59
 
@@ -26,6 +26,7 @@ import com.facebook.react.devsupport.WebsocketJavaScriptExecutor
26
26
  import com.facebook.react.devsupport.WebsocketJavaScriptExecutor.JSExecutorConnectCallback
27
27
  import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener
28
28
  import com.facebook.react.devsupport.interfaces.DevSplitBundleCallback
29
+ import com.facebook.react.devsupport.interfaces.PackagerStatusCallback
29
30
  import com.facebook.react.devsupport.interfaces.RedBoxHandler
30
31
  import com.facebook.react.packagerconnection.RequestHandler
31
32
  import expo.modules.devlauncher.DevLauncherController
@@ -40,9 +41,19 @@ import java.io.IOException
40
41
  import java.util.concurrent.ExecutionException
41
42
  import java.util.concurrent.TimeUnit
42
43
  import java.util.concurrent.TimeoutException
44
+ import okhttp3.Call
45
+ import okhttp3.Callback
46
+ import okhttp3.OkHttpClient
47
+ import okhttp3.Request
48
+ import okhttp3.Response
49
+
50
+ private const val PACKAGER_OK_STATUS = "packager-status:running"
51
+ private const val HTTP_CONNECT_TIMEOUT_MS = 5000L
52
+ private const val PACKAGER_STATUS_ENDPOINT = "status"
53
+
43
54
 
44
55
  class DevLauncherDevSupportManager(
45
- applicationContext: Context?,
56
+ applicationContext: Context,
46
57
  val reactInstanceManagerHelper: ReactInstanceDevHelper?,
47
58
  packagerPathForJSBundleName: String?,
48
59
  enableOnCreate: Boolean,
@@ -70,6 +81,14 @@ class DevLauncherDevSupportManager(
70
81
  private val devSettings: DevLauncherInternalSettingsWrapper =
71
82
  DevLauncherInternalSettingsWrapper(getDevSettings())
72
83
 
84
+ private val httpClient: OkHttpClient by lazy {
85
+ OkHttpClient.Builder()
86
+ .connectTimeout(HTTP_CONNECT_TIMEOUT_MS, TimeUnit.MILLISECONDS)
87
+ .readTimeout(0, TimeUnit.MILLISECONDS)
88
+ .writeTimeout(0, TimeUnit.MILLISECONDS)
89
+ .build()
90
+ }
91
+
73
92
  // copied from https://github.com/facebook/react-native/blob/aa4da248c12e3ba41ecc9f1c547b21c208d9a15f/ReactAndroid/src/main/java/com/facebook/react/devsupport/BridgeDevSupportManager.java#L88-L128
74
93
  init {
75
94
  if (devSettings.isStartSamplingProfilerOnInit) {
@@ -258,6 +277,37 @@ class DevLauncherDevSupportManager(
258
277
  return "$defaultValue&$customOptionsString"
259
278
  }
260
279
 
280
+ /**
281
+ * Re-implement [PackagerStatusCheck](https://github.com/facebook/react-native/blob/958f8e2bb55ba3a2ac/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/PackagerStatusCheck.java)
282
+ * to support https.
283
+ */
284
+ override fun isPackagerRunning(callback: PackagerStatusCallback) {
285
+ val bundleURL = controller?.manifest?.getBundleURL() ?: return super.isPackagerRunning(callback)
286
+ val bundleUri = Uri.parse(bundleURL)
287
+ val statusUrl = bundleUri.buildUpon()
288
+ .path(PACKAGER_STATUS_ENDPOINT)
289
+ .clearQuery()
290
+ .build()
291
+ .toString()
292
+ val request = Request.Builder().url(statusUrl).build()
293
+ httpClient
294
+ .newCall(request)
295
+ .enqueue(object : Callback {
296
+ override fun onFailure(call: Call, e: IOException) {
297
+ callback.onPackagerStatusFetched(false)
298
+ }
299
+
300
+ override fun onResponse(call: Call, response: Response) {
301
+ if (!response.isSuccessful) {
302
+ callback.onPackagerStatusFetched(false)
303
+ return
304
+ }
305
+ val body = response.body?.string() ?: ""
306
+ callback.onPackagerStatusFetched(body == PACKAGER_OK_STATUS)
307
+ }
308
+ })
309
+ }
310
+
261
311
  // copied from https://github.com/facebook/react-native/blob/aa4da248c12e3ba41ecc9f1c547b21c208d9a15f/ReactAndroid/src/main/java/com/facebook/react/devsupport/BridgeDevSupportManager.java#L233-L277
262
312
  /** Starts of stops the sampling profiler */
263
313
  private fun toggleJSSamplingProfiler() {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "expo-dev-launcher",
3
3
  "title": "Expo Development Launcher",
4
- "version": "3.6.9",
4
+ "version": "3.6.10",
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",
@@ -66,5 +66,5 @@
66
66
  "./setupTests.ts"
67
67
  ]
68
68
  },
69
- "gitHead": "74264a222fcc02d5885b451597113df852d272fb"
69
+ "gitHead": "58a91cebca537b685603ca67bc51b6617b3dca80"
70
70
  }