Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): handle DevServerHelper constructor signature change #1423

Merged
merged 2 commits into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 27 additions & 35 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -301,45 +301,37 @@ android {
}

sourceSets {
if (project.ext.react.enableCamera) {
main.java.srcDirs += "src/camera/java"
} else {
main.java.srcDirs += "src/no-camera/java"
}
main.java.srcDirs += [
project.ext.react.enableCamera ? "src/camera/java" : "src/no-camera/java",

// TODO: Remove this block when we drop support for 0.67
project.ext.react.enableFabric ? "src/fabric/java" : "src/no-fabric/java",

// TODO: Remove this block when we drop support for 0.65
enableNewArchitecture ? "src/turbomodule/java" : "src/no-turbomodule/java",

// TODO: Remove this block when we drop support for 0.67
// https://github.com/facebook/react-native/commit/ce74aa4ed335d4c36ce722d47937b582045e05c4
reactNativeVersion > 0 && reactNativeVersion < 6800
? "src/reactinstanceeventlistener-pre-0.68/java"
: "src/reactinstanceeventlistener-0.68/java",

// TODO: Remove this block when we drop support for 0.72
// https://github.com/facebook/react-native/commit/e5dd9cdc6688e63e75a7e0bebf380be1a9a5fe2b
reactNativeVersion > 0 && reactNativeVersion < 7200
? "src/reactactivitydelegate-pre-0.72/java"
: "src/reactactivitydelegate-0.72/java",

// TODO: Remove this block when we drop support for 0.73
// https://github.com/facebook/react-native/commit/da358d0ec7a492edb804b9cdce70e7516ee518ae
reactNativeVersion > 0 && reactNativeVersion < 7300
? "src/devserverhelper-pre-0.73/java"
: "src/devserverhelper-0.73/java",
]

if (project.ext.react.enableFlipper) {
debug.java.srcDirs += "src/flipper/java"
}

// TODO: Remove this block when we drop support for 0.67
if (project.ext.react.enableFabric) {
main.java.srcDirs += "src/fabric/java"
} else {
main.java.srcDirs += "src/no-fabric/java"
}

// TODO: Remove this block when we drop support for 0.65
if (enableNewArchitecture) {
main.java.srcDirs += "src/turbomodule/java"
} else {
main.java.srcDirs += "src/no-turbomodule/java"
}

// TODO: Remove this block when we drop support for 0.67
// https://github.com/facebook/react-native/commit/ce74aa4ed335d4c36ce722d47937b582045e05c4
if (reactNativeVersion > 0 && reactNativeVersion < 6800) {
main.java.srcDirs += "src/reactinstanceeventlistener-pre-0.68/java"
} else {
main.java.srcDirs += "src/reactinstanceeventlistener-0.68/java"
}

// TODO: Remove this block when we drop support for 0.72
// https://github.com/facebook/react-native/commit/e5dd9cdc6688e63e75a7e0bebf380be1a9a5fe2b
if (reactNativeVersion > 0 && reactNativeVersion < 7200) {
main.java.srcDirs += "src/reactactivitydelegate-pre-0.72/java"
} else {
main.java.srcDirs += "src/reactactivitydelegate-0.72/java"
}
}

splits {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.microsoft.reacttestapp.react

import android.content.Context
import com.facebook.react.devsupport.DevServerHelper
import com.facebook.react.devsupport.InspectorPackagerConnection.BundleStatus
import com.facebook.react.modules.debug.interfaces.DeveloperSettings
import com.facebook.react.packagerconnection.PackagerConnectionSettings

fun createDevServerHelper(context: Context, developerSettings: DeveloperSettings): DevServerHelper {
return DevServerHelper(
developerSettings,
context.packageName,
{ BundleStatus() },
PackagerConnectionSettings(context)
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.microsoft.reacttestapp.react

import android.content.Context
import com.facebook.react.devsupport.DevInternalSettings
import com.facebook.react.devsupport.DevServerHelper
import com.facebook.react.devsupport.InspectorPackagerConnection.BundleStatus
import com.facebook.react.modules.debug.interfaces.DeveloperSettings

fun createDevServerHelper(
context: Context,
@Suppress("UNUSED_PARAMETER") developerSettings: DeveloperSettings
): DevServerHelper {
return DevServerHelper(
DevInternalSettings(context) {},
context.packageName,
{ BundleStatus() }
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import com.facebook.react.ReactPackage
import com.facebook.react.bridge.JSIModulePackage
import com.facebook.react.bridge.JavaScriptExecutorFactory
import com.facebook.react.bridge.ReactContext
import com.facebook.react.devsupport.DevInternalSettings
import com.facebook.react.devsupport.DevServerHelper
import com.facebook.react.devsupport.InspectorPackagerConnection.BundleStatus
import com.facebook.react.devsupport.interfaces.DevSupportManager
import com.facebook.react.modules.systeminfo.ReactNativeVersion
import com.facebook.react.packagerconnection.PackagerConnectionSettings
Expand Down Expand Up @@ -212,13 +209,12 @@ class TestAppReactNativeHost(
val latch = CountDownLatch(1)
var packagerIsRunning = false

DevServerHelper(
DevInternalSettings(context) {},
context.packageName
) { BundleStatus() }.isPackagerRunning {
val devSettings = reactInstanceManager.devSupportManager.devSettings
createDevServerHelper(context, devSettings).isPackagerRunning {
packagerIsRunning = it
latch.countDown()
}

latch.await()
return packagerIsRunning
}
Expand Down
2 changes: 2 additions & 0 deletions test/pack.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ describe("npm pack", () => {
"android/app/lint.xml",
"android/app/src/camera/java/com/microsoft/reacttestapp/camera/MainActivityExtensions.kt",
"android/app/src/camera/java/com/microsoft/reacttestapp/camera/QRCodeScannerFragment.kt",
"android/app/src/devserverhelper-0.73/java/com/microsoft/reacttestapp/react/DevServerHelperCompat.kt",
"android/app/src/devserverhelper-pre-0.73/java/com/microsoft/reacttestapp/react/DevServerHelperCompat.kt",
"android/app/src/fabric/java/com/microsoft/reacttestapp/fabric/FabricJSIModulePackage.kt",
"android/app/src/flipper/java/com/microsoft/reacttestapp/ReactNativeFlipper.kt",
"android/app/src/main/AndroidManifest.xml",
Expand Down