110 lines
4.3 KiB
JavaScript
110 lines
4.3 KiB
JavaScript
// Metro module 85 (f86).
|
|
import _classCallCheck from "./_classCallCheck";
|
|
import _createClass from "./_createClass";
|
|
import { pickScale } from "./Module86";
|
|
import * as _PixelRatio from "./PixelRatio";
|
|
import { getBasePath, getAndroidResourceIdentifier, getAndroidResourceFolderName } from "./Module102";
|
|
import * as _Module38 from "./Module38";
|
|
let env84 = {};
|
|
const AssetSourceResolver = function AssetSourceResolver(a0, a1, a2) {
|
|
_classCallCheck(this, AssetSourceResolver);
|
|
this.serverUrl = a0;
|
|
this.jsbundleUrl = a1;
|
|
this.asset = a2;
|
|
};
|
|
const r39 = _createClass(AssetSourceResolver, [{
|
|
key: "isLoadedFromServer",
|
|
value: function isLoadedFromServer() {
|
|
return this.serverUrl != null && this.serverUrl !== "" && !(this.asset.type === "xml");
|
|
}
|
|
}, {
|
|
key: "isLoadedFromFileSystem",
|
|
value: function isLoadedFromFileSystem() {
|
|
let r6 = this.jsbundleUrl != null;
|
|
if (r6) {
|
|
const jsbundleUrl = this.jsbundleUrl;
|
|
r6 = jsbundleUrl == null ? void 0 : jsbundleUrl.startsWith("file://");
|
|
}
|
|
return r6;
|
|
}
|
|
}, {
|
|
key: "defaultAsset",
|
|
value: function defaultAsset() {
|
|
return this.isLoadedFromServer() ? this.assetServerURL() : this.asset.resolver != null ? this.getAssetUsingResolver(this.asset.resolver) : this.isLoadedFromFileSystem() ? this.drawableFolderInBundle() : this.resourceIdentifierWithoutScale();
|
|
}
|
|
}, {
|
|
key: "getAssetUsingResolver",
|
|
value: function getAssetUsingResolver(a0) {
|
|
if (a0 === "android") {
|
|
return this.isLoadedFromFileSystem() ? this.drawableFolderInBundle() : this.resourceIdentifierWithoutScale();
|
|
}
|
|
if (a0 === "generic") {
|
|
return this.scaledAssetURLNearBundle();
|
|
}
|
|
throw new Error("Don't know how to get asset via provided resolver: " + a0 + "\nAsset: " + JSON.stringify(this.asset, null, "\t") + "\nPossible resolvers are:" + JSON.stringify(["android", "generic"], null, "\t"));
|
|
}
|
|
}, {
|
|
key: "assetServerURL",
|
|
value: function assetServerURL() {
|
|
_Module38(this.serverUrl != null, "need server to load from");
|
|
const fromSource2 = this.fromSource;
|
|
const serverUrl = this.serverUrl;
|
|
const asset = this.asset;
|
|
const r25 = pickScale(asset.scales, _PixelRatio.default.get());
|
|
const r26 = r25 !== 1 ? "@" + r25 + "x" : "";
|
|
return fromSource2.call(this, serverUrl + (HermesInternal.concat.call(getBasePath(asset) + "/" + asset.name, r26, ".") + asset.type) + "?platform=android&hash=" + this.asset.hash);
|
|
}
|
|
}, {
|
|
key: "scaledAssetPath",
|
|
value: function scaledAssetPath() {
|
|
const fromSource2 = this.fromSource;
|
|
const asset = this.asset;
|
|
const r17 = pickScale(asset.scales, _PixelRatio.default.get());
|
|
const r18 = r17 !== 1 ? "@" + r17 + "x" : "";
|
|
return fromSource2.call(this, HermesInternal.concat.call(getBasePath(asset) + "/" + asset.name, r18, ".") + asset.type);
|
|
}
|
|
}, {
|
|
key: "scaledAssetURLNearBundle",
|
|
value: function scaledAssetURLNearBundle() {
|
|
let jsbundleUrl = this.jsbundleUrl;
|
|
if (jsbundleUrl == null) {
|
|
jsbundleUrl = "file://";
|
|
}
|
|
const fromSource2 = this.fromSource;
|
|
const asset = this.asset;
|
|
const r19 = pickScale(asset.scales, _PixelRatio.default.get());
|
|
const r20 = r19 !== 1 ? "@" + r19 + "x" : "";
|
|
return fromSource2.call(this, jsbundleUrl + (HermesInternal.concat.call(getBasePath(asset) + "/" + asset.name, r20, ".") + asset.type).replace(/\.\.\//g, "_"));
|
|
}
|
|
}, {
|
|
key: "resourceIdentifierWithoutScale",
|
|
value: function resourceIdentifierWithoutScale() {
|
|
_Module38(true, "resource identifiers work on Android");
|
|
return this.fromSource(getAndroidResourceIdentifier(this.asset));
|
|
}
|
|
}, {
|
|
key: "drawableFolderInBundle",
|
|
value: function drawableFolderInBundle() {
|
|
let jsbundleUrl = this.jsbundleUrl;
|
|
if (jsbundleUrl == null) {
|
|
jsbundleUrl = "file://";
|
|
}
|
|
const fromSource2 = this.fromSource;
|
|
const asset = this.asset;
|
|
return fromSource2.call(this, jsbundleUrl + (getAndroidResourceFolderName(asset, pickScale(asset.scales, _PixelRatio.default.get())) + "/" + getAndroidResourceIdentifier(asset) + "." + asset.type));
|
|
}
|
|
}, {
|
|
key: "fromSource",
|
|
value: function fromSource(a0) {
|
|
return {
|
|
__packager_asset: true,
|
|
width: this.asset.width,
|
|
height: this.asset.height,
|
|
uri: a0,
|
|
scale: pickScale(this.asset.scales, _PixelRatio.default.get())
|
|
};
|
|
}
|
|
}]);
|
|
r39.pickScale = pickScale;
|
|
export default r39;
|