mirror of
https://github.com/status-im/react-native.git
synced 2025-01-26 09:19:10 +00:00
Load Indexed RAM format on android
Reviewed By: javache Differential Revision: D4268243 fbshipit-source-id: fc969cfc69810d0477c926ffc79c23584fcbd7eb
This commit is contained in:
parent
fb3906994e
commit
f9f32eb426
@ -14,6 +14,8 @@
|
||||
#include <jni/LocalReference.h>
|
||||
|
||||
#include <cxxreact/Instance.h>
|
||||
#include <cxxreact/JSBundleType.h>
|
||||
#include <cxxreact/JSIndexedRAMBundle.h>
|
||||
#include <cxxreact/MethodCall.h>
|
||||
#include <cxxreact/ModuleRegistry.h>
|
||||
|
||||
@ -174,10 +176,32 @@ void CatalystInstanceImpl::loadScriptFromAssets(jobject assetManager,
|
||||
}
|
||||
}
|
||||
|
||||
bool CatalystInstanceImpl::isIndexedRAMBundle(const char *sourcePath) {
|
||||
std::ifstream bundle_stream(sourcePath, std::ios_base::in);
|
||||
if (!bundle_stream) {
|
||||
return false;
|
||||
}
|
||||
BundleHeader header;
|
||||
bundle_stream.read(reinterpret_cast<char *>(&header), sizeof(header));
|
||||
bundle_stream.close();
|
||||
return parseTypeFromHeader(header) == ScriptTag::RAMBundle;
|
||||
}
|
||||
|
||||
void CatalystInstanceImpl::loadScriptFromFile(jni::alias_ref<jstring> fileName,
|
||||
const std::string& sourceURL) {
|
||||
return instance_->loadScriptFromFile(fileName ? fileName->toStdString() : "",
|
||||
sourceURL);
|
||||
|
||||
std::string file = fileName ? fileName->toStdString() : "";
|
||||
|
||||
if (isIndexedRAMBundle(file.c_str())) {
|
||||
auto bundle = folly::make_unique<JSIndexedRAMBundle>(file.c_str());
|
||||
auto startupScript = bundle->getStartupCode();
|
||||
instance_->loadUnbundle(
|
||||
std::move(bundle),
|
||||
std::move(startupScript),
|
||||
sourceURL);
|
||||
} else {
|
||||
instance_->loadScriptFromFile(file, sourceURL);
|
||||
}
|
||||
}
|
||||
|
||||
void CatalystInstanceImpl::loadScriptFromOptimizedBundle(const std::string& bundlePath,
|
||||
|
@ -40,6 +40,8 @@ class CatalystInstanceImpl : public jni::HybridClass<CatalystInstanceImpl> {
|
||||
|
||||
CatalystInstanceImpl();
|
||||
|
||||
static bool isIndexedRAMBundle(const char *sourcePath);
|
||||
|
||||
void initializeBridge(
|
||||
jni::alias_ref<ReactCallback::javaobject> callback,
|
||||
// This executor is actually a factory holder.
|
||||
|
@ -9,6 +9,7 @@ LOCAL_SRC_FILES := \
|
||||
Executor.cpp \
|
||||
Instance.cpp \
|
||||
JSCExecutor.cpp \
|
||||
JSBundleType.cpp \
|
||||
JSCLegacyProfiler.cpp \
|
||||
JSCLegacyTracing.cpp \
|
||||
JSCMemory.cpp \
|
||||
@ -16,6 +17,7 @@ LOCAL_SRC_FILES := \
|
||||
JSCPerfStats.cpp \
|
||||
JSCTracing.cpp \
|
||||
JSCWebWorker.cpp \
|
||||
JSIndexedRAMBundle.cpp \
|
||||
MethodCall.cpp \
|
||||
ModuleRegistry.cpp \
|
||||
NativeToJsBridge.cpp \
|
||||
|
Loading…
x
Reference in New Issue
Block a user