Unpack files required by optimized bundle format

Reviewed By: tadeuzagallo

Differential Revision: D3522855

fbshipit-source-id: 2d14db33ce9b98ea1aeea5a12e292e5926e43796
This commit is contained in:
Michał Gregorczyk
2016-07-12 08:03:08 -07:00
committed by Facebook Github Bot 2
parent e632025917
commit a665914d18
7 changed files with 838 additions and 0 deletions

View File

@@ -14,6 +14,8 @@ import android.content.Context;
import com.facebook.react.devsupport.DebugServerException;
import com.facebook.react.devsupport.DevServerHelper;
import java.io.File;
/**
* A class that stores JS bundle information and allows {@link CatalystInstance} to load a correct
* bundle through {@link ReactBridge}.
@@ -99,6 +101,19 @@ public abstract class JSBundleLoader {
};
}
public static JSBundleLoader createUnpackingBundleLoader(
final Context context,
final String sourceURL,
final String bundleName) {
return UnpackingJSBundleLoader.newBuilder()
.setContext(context)
.setSourceURL(sourceURL)
.setDestinationPath(new File(context.getFilesDir(), "optimized-bundle"))
.checkAndUnpackFile(bundleName + ".meta", "bundle.meta")
.unpackFile(bundleName, "bundle.js")
.build();
}
public abstract void loadScript(CatalystInstanceImpl instance);
public abstract String getSourceUrl();
}