This repository has been archived on 2022-03-12. You can view files and clone it, but cannot push or open issues or pull requests.

22 lines
884 B
JavaScript
Raw Normal View History

2021-04-02 02:24:13 +03:00
import { Asset } from './Asset';
import { IS_ENV_WITH_UPDATES_ENABLED } from './PlatformUtils';
import { setCustomSourceTransformer } from './resolveAssetSource';
// Override React Native's asset resolution for `Image` components in contexts where it matters
if (IS_ENV_WITH_UPDATES_ENABLED) {
setCustomSourceTransformer(resolver => {
try {
// Bundler is using the hashAssetFiles plugin if and only if the fileHashes property exists
if (resolver.asset.fileHashes) {
const asset = Asset.fromMetadata(resolver.asset);
return resolver.fromSource(asset.downloaded ? asset.localUri : asset.uri);
}
else {
return resolver.defaultAsset();
}
}
catch (e) {
return resolver.defaultAsset();
}
});
}
//# sourceMappingURL=Asset.fx.js.map