Skip to content

Commit b0193b0

Browse files
Yujie Liufacebook-github-bot
Yujie Liu
authored andcommitted
Rename bundleUrl to jsbundleURL
Reviewed By: fkgozali Differential Revision: D6236921 fbshipit-source-id: f1018836465ba6cf21679fe9d21c18eec762199d
1 parent b983de9 commit b0193b0

File tree

2 files changed

+23
-23
lines changed

2 files changed

+23
-23
lines changed

Libraries/Image/AssetSourceResolver.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ function getAssetPathInDrawableFolder(asset): string {
5050
class AssetSourceResolver {
5151

5252
serverUrl: ?string;
53-
// where the bundle is being run from
54-
bundleUrl: ?string;
53+
// where the jsbundle is being run from
54+
jsbundleUrl: ?string;
5555
// the asset to resolve
5656
asset: PackagerAsset;
5757

58-
constructor(serverUrl: ?string, bundleUrl: ?string, asset: PackagerAsset) {
58+
constructor(serverUrl: ?string, jsbundleUrl: ?string, asset: PackagerAsset) {
5959
this.serverUrl = serverUrl;
60-
this.bundleUrl = bundleUrl;
60+
this.jsbundleUrl = jsbundleUrl;
6161
this.asset = asset;
6262
}
6363

@@ -66,7 +66,7 @@ class AssetSourceResolver {
6666
}
6767

6868
isLoadedFromFileSystem(): boolean {
69-
return !!this.bundleUrl;
69+
return !!this.jsbundleUrl;
7070
}
7171

7272
defaultAsset(): ResolvedAssetSource {
@@ -79,7 +79,7 @@ class AssetSourceResolver {
7979
this.drawableFolderInBundle() :
8080
this.resourceIdentifierWithoutScale();
8181
} else {
82-
return this.scaledAssetURLInBundle();
82+
return this.scaledAssetURLInScript();
8383
}
8484
}
8585

@@ -104,11 +104,11 @@ class AssetSourceResolver {
104104
}
105105

106106
/**
107-
* Resolves to where the bundle is running from, with a scaled asset filename
107+
* Resolves to where the script is running from, with a scaled asset filename
108108
* E.g. 'file:///sdcard/bundle/assets/AwesomeModule/[email protected]'
109109
*/
110-
scaledAssetURLInBundle(): ResolvedAssetSource {
111-
const path = this.bundleUrl || 'file://';
110+
scaledAssetURLInScript(): ResolvedAssetSource {
111+
const path = this.jsbundleUrl || 'file://';
112112
return this.fromSource(path + getScaledAssetPath(this.asset));
113113
}
114114

@@ -129,7 +129,7 @@ class AssetSourceResolver {
129129
* E.g. 'file:///sdcard/AwesomeModule/drawable-mdpi/icon.png'
130130
*/
131131
drawableFolderInBundle(): ResolvedAssetSource {
132-
const path = this.bundleUrl || 'file://';
132+
const path = this.jsbundleUrl || 'file://';
133133
return this.fromSource(
134134
path + getAssetPathInDrawableFolder(this.asset)
135135
);

Libraries/Image/resolveAssetSource.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -19,45 +19,45 @@ const NativeModules = require('NativeModules');
1919

2020
import type { ResolvedAssetSource } from 'AssetSourceResolver';
2121

22-
let _customSourceTransformer, _serverURL, _bundleSourceURL;
22+
let _customSourceTransformer, _serverURL, _scriptURL;
2323

2424
function getDevServerURL(): ?string {
2525
if (_serverURL === undefined) {
2626
var scriptURL = NativeModules.SourceCode.scriptURL;
2727
var match = scriptURL && scriptURL.match(/^https?:\/\/.*?\//);
2828
if (match) {
29-
// Bundle was loaded from network
29+
// jsBundle was loaded from network
3030
_serverURL = match[0];
3131
} else {
32-
// Bundle was loaded from file
32+
// jsBundle was loaded from file
3333
_serverURL = null;
3434
}
3535
}
3636
return _serverURL;
3737
}
3838

39-
function getBundleSourceURL(): ?string {
40-
if (_bundleSourceURL === undefined) {
39+
function getScriptURL(): ?string {
40+
if (_scriptURL === undefined) {
4141
const scriptURL = NativeModules.SourceCode.scriptURL;
4242
if (!scriptURL) {
4343
// scriptURL is falsy, we have nothing to go on here
44-
_bundleSourceURL = null;
45-
return _bundleSourceURL;
44+
_scriptURL = null;
45+
return _scriptURL;
4646
}
4747
if (scriptURL.startsWith('assets://')) {
4848
// android: running from within assets, no offline path to use
49-
_bundleSourceURL = null;
50-
return _bundleSourceURL;
49+
_scriptURL = null;
50+
return _scriptURL;
5151
}
52-
_bundleSourceURL = scriptURL.substring(0, scriptURL.lastIndexOf('/') + 1);
52+
_scriptURL = scriptURL.substring(0, scriptURL.lastIndexOf('/') + 1);
5353
if (!scriptURL.startsWith('file://')) {
5454
// Add file protocol in case we have an absolute file path and not a URL.
5555
// This shouldn't really be necessary. scriptURL should be a URL.
56-
_bundleSourceURL = 'file://' + _bundleSourceURL;
56+
_scriptURL = 'file://' + _scriptURL;
5757
}
5858
}
5959

60-
return _bundleSourceURL;
60+
return _scriptURL;
6161
}
6262

6363
function setCustomSourceTransformer(
@@ -80,7 +80,7 @@ function resolveAssetSource(source: any): ?ResolvedAssetSource {
8080
return null;
8181
}
8282

83-
const resolver = new AssetSourceResolver(getDevServerURL(), getBundleSourceURL(), asset);
83+
const resolver = new AssetSourceResolver(getDevServerURL(), getScriptURL(), asset);
8484
if (_customSourceTransformer) {
8585
return _customSourceTransformer(resolver);
8686
}

0 commit comments

Comments
 (0)