-
Notifications
You must be signed in to change notification settings - Fork 31
feat(android): allow bundle file path #200
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @gronxb ! Thank you for contributing, this is a useful feature. Left two minor comments - I'll be happy to merge when they're addressed!
| .filterIsInstance<ReactPackage>(), | ||
| jsMainModulePath = options["mainModuleName"] as? String ?: "index", | ||
| jsBundleAssetPath = options["bundleAssetPath"] as? String ?: "index.android.bundle", | ||
| jsBundleAssetPath = if (isFilePath) "index.android.bundle" else bundlePath, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For clarity, how about always passing bundlePath to jsBundleAssetPath? In RN source indeed jsBundleAssetPath is not effective if jsBundleFilePath is provided, but if the behaviour was to somehow change in the future, we would've had a 'silent' potential cause of problems here. If we set it to bundlePath, we will be more resilient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually like it even more! I was worried that changing the name might be considered an API change, but this is exactly what I wanted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I change options["bundleAssetPath"] to options["bundlePath"]?
Since this is a breaking change, it will affect existing code, but it would result in a clearer name.
What would you prefer to do?
| ) { | ||
| val reactHost: ReactHost by lazy { | ||
| val bundlePath = options["bundleAssetPath"] as? String ?: "index.android.bundle" | ||
| val isFilePath = bundlePath.startsWith("/") || bundlePath.startsWith("file://") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[minor] Would you mind adding || bundlePath.startsWith("assets://") to isFilePath? RN's DefaultReactHost has logic for this non-standard protocol (even though the docstring mentions only the file:// protocol).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Summary
https://discord.com/channels/426714625279524876/1460917572894457968/1461699896594792677
I’m integrating HotUpdater. After an OTA update, HotUpdater uses the bundle from the file system.
Return values of
HotUpdater.getJSBundleFile():Without an OTA bundle (initial state):
"assets://index.android.bundle"
With an OTA bundle:
"/storage/emulated/0/Android/data/com.callstack.brownfield.android.example/files/bundle-store/019bc77b-d454-7ccd-9d39-721800a3026d/index.android.bundle"
Therefore, when the app is closed and reopened, file path access also needs to be allowed.
Test plan
2026-01-17.12.54.13.mov