mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-10 10:00:16 +08:00
add API to CatalystInstanceImpl for executing optimized bundle
Reviewed By: tadeuzagallo Differential Revision: D3545345 fbshipit-source-id: 538fec77b816c3fd767e8c2eda81c78971996b17
This commit is contained in:
committed by
Facebook Github Bot 2
parent
a665914d18
commit
1331e20db5
@@ -161,8 +161,9 @@ public class CatalystInstanceImpl implements CatalystInstance {
|
||||
MessageQueueThread moduleQueue,
|
||||
ModuleRegistryHolder registryHolder);
|
||||
|
||||
/* package */ native void loadScriptFromAssets(AssetManager assetManager, String assetURL, boolean useLazyBundle);
|
||||
/* package */ native void loadScriptFromAssets(AssetManager assetManager, String assetURL);
|
||||
/* package */ native void loadScriptFromFile(String fileName, String sourceURL);
|
||||
/* package */ native void loadScriptFromOptimizedBundle(String path, String sourceURL, int flags);
|
||||
|
||||
@Override
|
||||
public void runJSBundle() {
|
||||
|
||||
@@ -30,18 +30,11 @@ public abstract class JSBundleLoader {
|
||||
public static JSBundleLoader createFileLoader(
|
||||
final Context context,
|
||||
final String fileName) {
|
||||
return createFileLoader(context, fileName, false);
|
||||
}
|
||||
|
||||
public static JSBundleLoader createFileLoader(
|
||||
final Context context,
|
||||
final String fileName,
|
||||
final boolean useLazyBundle) {
|
||||
return new JSBundleLoader() {
|
||||
@Override
|
||||
public void loadScript(CatalystInstanceImpl instance) {
|
||||
if (fileName.startsWith("assets://")) {
|
||||
instance.loadScriptFromAssets(context.getAssets(), fileName, useLazyBundle);
|
||||
instance.loadScriptFromAssets(context.getAssets(), fileName);
|
||||
} else {
|
||||
instance.loadScriptFromFile(fileName, fileName);
|
||||
}
|
||||
|
||||
@@ -38,6 +38,12 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;
|
||||
*/
|
||||
public class UnpackingJSBundleLoader extends JSBundleLoader {
|
||||
|
||||
/**
|
||||
* Flag passed to loadScriptFromOptimizedBundle to let the bridge know that
|
||||
* the unpacked unpacked js source file.
|
||||
*/
|
||||
static final int UNPACKED_JS_SOURCE = (1 << 0);
|
||||
|
||||
/**
|
||||
* Name of the lock files. Multiple processes can be spawned off the same app
|
||||
* and we need to guarantee that at most one unpacks files at any time. To
|
||||
@@ -141,10 +147,10 @@ public class UnpackingJSBundleLoader extends JSBundleLoader {
|
||||
@Override
|
||||
public void loadScript(CatalystInstanceImpl instance) {
|
||||
prepare();
|
||||
// TODO(12128379): add instance method that would take bundle directory
|
||||
instance.loadScriptFromFile(
|
||||
new File(mDirectoryPath, "bundle.js").getPath(),
|
||||
mSourceURL);
|
||||
instance.loadScriptFromOptimizedBundle(
|
||||
mDirectoryPath.getPath(),
|
||||
mSourceURL,
|
||||
UNPACKED_JS_SOURCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user