Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ void CatalystInstanceImpl::jniLoadScriptFromAssets(
jni::alias_ref<JAssetManager::javaobject> assetManager,
const std::string& assetURL,
bool loadSynchronously) {

std::unique_ptr<BundleLoader> bundleLoader = std::make_unique<AssetBundleLoader>(assetManager);
instance_->runApplication(assetURL, std::move(bundleLoader), loadSynchronously);
}
Expand Down
9 changes: 6 additions & 3 deletions ReactAndroid/src/main/jni/react/jni/FileRAMBundle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,17 @@ BundleType FileRAMBundle::getBundleType() const {
return BundleType::FileRAMBundle;
}

FileRAMBundle::Module FileRAMBundle::getModule(uint32_t moduleId) const {
FileRAMBundle::Module FileRAMBundle::getModule(uint32_t moduleId, const char* bundlePrefix) const {
// can be nullptr for default constructor.
FBASSERTMSGF(
assetManager_ != nullptr,
"Unbundle has not been initialized with an asset manager");
auto sourceUrl = folly::to<std::string>(moduleId, ".js");

auto fileName = moduleDirectory_ + sourceUrl;
if (bundlePrefix) {
sourceUrl = folly::to<std::string>(bundlePrefix, "-", sourceUrl);
}

auto asset = openAsset(assetManager_, fileName.c_str(), AASSET_MODE_BUFFER);

const char* buffer = nullptr;
Expand All @@ -122,7 +125,7 @@ FileRAMBundle::Module FileRAMBundle::getModule(uint32_t moduleId) const {
if (buffer == nullptr) {
throw ModuleNotFound(moduleId);
}
return {sourceUrl, std::string(buffer, AAsset_getLength(asset.get()))};
return { sourceUrl, std::string(buffer, AAsset_getLength(asset.get())) };
}

} // namespace react
Expand Down
2 changes: 1 addition & 1 deletion ReactAndroid/src/main/jni/react/jni/FileRAMBundle.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class FileRAMBundle : public RAMBundle {
std::string getSourcePath() const override;
std::string getSourceURL() const override;
std::unique_ptr<const JSBigString> getStartupScript() const override;
Module getModule(uint32_t moduleId) const override;
Module getModule(uint32_t moduleId, const char* bundlePrefix) const override;
BundleType getBundleType() const override;

private:
Expand Down
3 changes: 2 additions & 1 deletion ReactCommon/cxxreact/BundleRegistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ BundleRegistry::GetModuleLambda BundleRegistry::makeGetModuleLambda(std::string
" is not a RAM bundle - GetModuleLambda cannot be used on it");
}

return ramBundle->getModule(moduleId);
auto bundlePrefix = bundleName == "seg-0" ? nullptr : bundleName.c_str();
return ramBundle->getModule(moduleId, bundlePrefix);
};
}

Expand Down
5 changes: 4 additions & 1 deletion ReactCommon/cxxreact/IndexedRAMBundle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,12 @@ std::string IndexedRAMBundle::getSourcePath() const {
return sourcePath_;
}

IndexedRAMBundle::Module IndexedRAMBundle::getModule(uint32_t moduleId) const {
IndexedRAMBundle::Module IndexedRAMBundle::getModule(uint32_t moduleId, const char* bundlePrefix) const {
Module ret;
ret.name = folly::to<std::string>(moduleId, ".js");
if (bundlePrefix) {
ret.name = folly::to<std::string>(bundlePrefix, "-", ret.name);
}
ret.code = getModuleCode(moduleId);
return ret;
}
Expand Down
2 changes: 1 addition & 1 deletion ReactCommon/cxxreact/IndexedRAMBundle.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class IndexedRAMBundle : public RAMBundle {
std::string getSourceURL() const override;
std::string getSourcePath() const override;
std::unique_ptr<const JSBigString> getStartupScript() const override;
Module getModule(uint32_t moduleId) const override;
Module getModule(uint32_t moduleId, const char* bundlePrefix) const override;
BundleType getBundleType() const override;

private:
Expand Down
2 changes: 1 addition & 1 deletion ReactCommon/cxxreact/RAMBundle.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class RAMBundle : public Bundle {
*/
virtual std::string getSourcePath() const = 0;
virtual std::unique_ptr<const JSBigString> getStartupScript() const = 0;
virtual Module getModule(uint32_t moduleId) const = 0;
virtual Module getModule(uint32_t moduleId, const char* bundlePrefix) const = 0;
};

} // react
Expand Down