Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should raise an error when lead to an incompatible type', () => {
// $ExpectError
(Constants.debugMode: 'ups...');
// $ExpectError
(Constants.deviceName: 'ups...');
// $ExpectError
(Constants.deviceYearClass: 'ups...');
// $ExpectError
(Constants.experienceUrl: 'ups...');
// $ExpectError
(Constants.expoRuntimeVersion: 'ups...');
// $ExpectError
(Constants.expoVersion: 'ups...');
// $ExpectError
(Constants.isDetached: 'ups...');
// $ExpectError
(Constants.intentUri: 'ups...');
// $ExpectError
(Constants.installationId: 'ups...');
// $ExpectError
(Constants.isDevice: 'ups...');
// $ExpectError
(Constants.isHeadless: 'ups...');
// $ExpectError
(Constants.linkingUri: 'ups...');
import Constants from 'expo-constants';
import { Platform } from '@unimodules/core';
import path from 'path-browserify';
import { PixelRatio } from 'react-native';
import URL from 'url-parse';
import AssetSourceResolver from './AssetSourceResolver';
import { getManifestBaseUrl } from './AssetUris';
// Fast lookup check if asset map has any overrides in the manifest
const assetMapOverride = Constants.manifest && Constants.manifest.assetMapOverride;
// Compute manifest base URL if available
const manifestBaseUrl = Constants.experienceUrl
? getManifestBaseUrl(Constants.experienceUrl)
: null;
/**
* Selects the best file for the given asset (ex: choosing the best scale for images) and returns
* a { uri, hash } pair for the specific asset file.
*
* If the asset isn't an image with multiple scales, the first file is selected.
*/
export function selectAssetSource(meta) {
// Override with the asset map in manifest if available
if (assetMapOverride && assetMapOverride.hasOwnProperty(meta.hash)) {
meta = { ...meta, ...assetMapOverride[meta.hash] };
}
// This logic is based on that of AssetSourceResolver, with additional support for file hashes and
// explicitly provided URIs
const scale = AssetSourceResolver.pickScale(meta.scales, PixelRatio.get());
const index = meta.scales.findIndex(s => s === scale);
httpServerLocation: string;
uri?: string;
fileHashes?: string[];
fileUris?: string[];
};
export type AssetSource = {
uri: string;
hash: string;
};
// Fast lookup check if asset map has any overrides in the manifest
const assetMapOverride = Constants.manifest && Constants.manifest.assetMapOverride;
// Compute manifest base URL if available
const manifestBaseUrl = Constants.experienceUrl
? getManifestBaseUrl(Constants.experienceUrl)
: null;
/**
* Selects the best file for the given asset (ex: choosing the best scale for images) and returns
* a { uri, hash } pair for the specific asset file.
*
* If the asset isn't an image with multiple scales, the first file is selected.
*/
export function selectAssetSource(meta: AssetMetadata): AssetSource {
// Override with the asset map in manifest if available
if (assetMapOverride && assetMapOverride.hasOwnProperty(meta.hash)) {
meta = { ...meta, ...assetMapOverride[meta.hash] };
}
// This logic is based on that of AssetSourceResolver, with additional support for file hashes and
uri?: string;
fileHashes?: string[];
fileUris?: string[];
};
export type AssetSource = {
uri: string;
hash: string;
};
// Fast lookup check if asset map has any overrides in the manifest
const assetMapOverride = Constants.manifest && Constants.manifest.assetMapOverride;
// Compute manifest base URL if available
const manifestBaseUrl = Constants.experienceUrl
? getManifestBaseUrl(Constants.experienceUrl)
: null;
/**
* Selects the best file for the given asset (ex: choosing the best scale for images) and returns
* a { uri, hash } pair for the specific asset file.
*
* If the asset isn't an image with multiple scales, the first file is selected.
*/
export function selectAssetSource(meta: AssetMetadata): AssetSource {
// Override with the asset map in manifest if available
if (assetMapOverride && assetMapOverride.hasOwnProperty(meta.hash)) {
meta = { ...meta, ...assetMapOverride[meta.hash] };
}
// This logic is based on that of AssetSourceResolver, with additional support for file hashes and
// explicitly provided URIs
import Constants from 'expo-constants';
import { Platform } from '@unimodules/core';
import path from 'path-browserify';
import { PixelRatio } from 'react-native';
import URL from 'url-parse';
import AssetSourceResolver from './AssetSourceResolver';
import { getManifestBaseUrl } from './AssetUris';
// Fast lookup check if asset map has any overrides in the manifest
const assetMapOverride = Constants.manifest && Constants.manifest.assetMapOverride;
// Compute manifest base URL if available
const manifestBaseUrl = Constants.experienceUrl
? getManifestBaseUrl(Constants.experienceUrl)
: null;
/**
* Selects the best file for the given asset (ex: choosing the best scale for images) and returns
* a { uri, hash } pair for the specific asset file.
*
* If the asset isn't an image with multiple scales, the first file is selected.
*/
export function selectAssetSource(meta) {
// Override with the asset map in manifest if available
if (assetMapOverride && assetMapOverride.hasOwnProperty(meta.hash)) {
meta = { ...meta, ...assetMapOverride[meta.hash] };
}
// This logic is based on that of AssetSourceResolver, with additional support for file hashes and
// explicitly provided URIs
const scale = AssetSourceResolver.pickScale(meta.scales, PixelRatio.get());