diff --git a/.changeset/cool-parts-guess.md b/.changeset/cool-parts-guess.md new file mode 100644 index 00000000..f54e298b --- /dev/null +++ b/.changeset/cool-parts-guess.md @@ -0,0 +1,5 @@ +--- +'@callstack/react-native-brownfield': minor +--- + +feat(android): allow bundle file path diff --git a/docs/docs/docs/api-reference/java.mdx b/docs/docs/docs/api-reference/java.mdx index 6ae9bd15..0bc8720f 100644 --- a/docs/docs/docs/api-reference/java.mdx +++ b/docs/docs/docs/api-reference/java.mdx @@ -69,7 +69,8 @@ A function used to initialize a React Native Brownfield singleton. Keep in mind - `useDeveloperSupport`: `Boolean` - Flag to use dev support. - `packages`: `List` - List of your React Native Native modules. - `mainModuleName`: `String` - Path to react native entry file (when loading from Metro). -- `bundleAssetPath`: `String` - Path to react native bundle asset file (when loading from app assets), appended to `asset://`. +- `bundleAssetPath`: `String` - Path to react native bundle asset file (when loading from app assets), appended to `asset://` +- `bundleFilePath`: `String` - Optional, should start with `file://`, in which case the JS bundle will be loaded from a local file; alternatively, can start with `asset://`, in which case it is equivalent to `bundleAssetPath` passed the value without the `asset://` prefix. This value has precedence over `bundleAssetPath`, if passed. **Examples:** diff --git a/docs/docs/docs/api-reference/kotlin.mdx b/docs/docs/docs/api-reference/kotlin.mdx index 931d72bb..86cec8aa 100644 --- a/docs/docs/docs/api-reference/kotlin.mdx +++ b/docs/docs/docs/api-reference/kotlin.mdx @@ -52,7 +52,8 @@ A function used to initialize a React Native Brownfield singleton. Keep in mind - `useDeveloperSupport`: `Boolean` - Flag to use dev support. - `packages`: `List` - List of your React Native Native modules. - `mainModuleName`: `String` - Path to react native entry file (when loading from Metro). -- `bundleAssetPath`: `String` - Path to react native bundle asset file (when loading from app assets), appended to `asset://`. +- `bundleAssetPath`: `String` - Path to react native bundle asset file (when loading from app assets), appended to `asset://` +- `bundleFilePath`: `String` - Optional, should start with `file://`, in which case the JS bundle will be loaded from a local file; alternatively, can start with `asset://`, in which case it is equivalent to `bundleAssetPath` passed the value without the `asset://` prefix. This value has precedence over `bundleAssetPath`, if passed. **Examples:** diff --git a/packages/react-native-brownfield/android/src/main/java/com/callstack/reactnativebrownfield/ReactNativeBrownfield.kt b/packages/react-native-brownfield/android/src/main/java/com/callstack/reactnativebrownfield/ReactNativeBrownfield.kt index 2045209a..8bc44c4a 100644 --- a/packages/react-native-brownfield/android/src/main/java/com/callstack/reactnativebrownfield/ReactNativeBrownfield.kt +++ b/packages/react-native-brownfield/android/src/main/java/com/callstack/reactnativebrownfield/ReactNativeBrownfield.kt @@ -72,16 +72,13 @@ class ReactNativeBrownfield private constructor(val reactHost: ReactHost) { onJSBundleLoaded: OnJSBundleLoaded? = null ) { val reactHost: ReactHost by lazy { - val bundlePath = options["bundleAssetPath"] as? String ?: "index.android.bundle" - val isFilePath = bundlePath.startsWith("/") || bundlePath.startsWith("file://") || bundlePath.startsWith("assets://") - getDefaultReactHost( context = application, packageList = (options["packages"] as? List<*> ?: emptyList()) .filterIsInstance(), jsMainModulePath = options["mainModuleName"] as? String ?: "index", - jsBundleAssetPath = bundlePath, - jsBundleFilePath = if (isFilePath) bundlePath else null, + jsBundleAssetPath = options["bundleAssetPath"] as? String ?: "index.android.bundle", + jsBundleFilePath = options["bundleFilePath"] as? String, useDevSupport = options["useDeveloperSupport"] as? Boolean ?: ReactBuildConfig.DEBUG, jsRuntimeFactory = null