mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-25 23:00:58 +08:00
resolve iOS assets from embedded bundle path for iOS platform
Reviewed By: zahanm Differential Revision: D6193907 fbshipit-source-id: 09c76a5c3d6a7777a9a823c21bfcc0fe344bc83e
This commit is contained in:
committed by
Facebook Github Bot
parent
45185947ee
commit
a329e968fc
@@ -52,12 +52,19 @@ class AssetSourceResolver {
|
||||
serverUrl: ?string;
|
||||
// where the jsbundle is being run from
|
||||
jsbundleUrl: ?string;
|
||||
// where the embedded bundle in the app is stored
|
||||
embeddedBundleUrl: ?string;
|
||||
// the asset to resolve
|
||||
asset: PackagerAsset;
|
||||
|
||||
constructor(serverUrl: ?string, jsbundleUrl: ?string, asset: PackagerAsset) {
|
||||
constructor(serverUrl: ?string,
|
||||
jsbundleUrl: ?string,
|
||||
embeddedBundleUrl: ?string,
|
||||
asset: PackagerAsset
|
||||
) {
|
||||
this.serverUrl = serverUrl;
|
||||
this.jsbundleUrl = jsbundleUrl;
|
||||
this.embeddedBundleUrl = embeddedBundleUrl;
|
||||
this.asset = asset;
|
||||
}
|
||||
|
||||
@@ -69,6 +76,10 @@ class AssetSourceResolver {
|
||||
return !!this.jsbundleUrl;
|
||||
}
|
||||
|
||||
canLoadFromEmbeddedBundledLocation(): boolean {
|
||||
return !!this.embeddedBundleUrl;
|
||||
}
|
||||
|
||||
defaultAsset(): ResolvedAssetSource {
|
||||
if (this.isLoadedFromServer()) {
|
||||
return this.assetServerURL();
|
||||
@@ -112,6 +123,15 @@ class AssetSourceResolver {
|
||||
return this.fromSource(path + getScaledAssetPath(this.asset));
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves to the asset that was bundled with the app, with a scaled asset filename
|
||||
* E.g. 'file:///sdcard/bundle/assets/AwesomeModule/icon@2x.png'
|
||||
*/
|
||||
scaledAssetURLInEmbeddedBundleUrl(): ResolvedAssetSource {
|
||||
const path = this.embeddedBundleUrl || 'file://';
|
||||
return this.fromSource(path + getScaledAssetPath(this.asset));
|
||||
}
|
||||
|
||||
/**
|
||||
* The default location of assets bundled with the app, located by
|
||||
* resource identifier
|
||||
|
||||
Reference in New Issue
Block a user