Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(async () => {
const nativeAsset = await AssetUtils.resolveAsync(asset);
function parseAsset(image) {
texture.image = image;
// JPEGs can't have an alpha channel, so memory can be saved by storing them as RGB.
texture.format = formatFromURI(nativeAsset.localUri);
texture.needsUpdate = true;
if (onLoad !== undefined) {
onLoad(texture);
}
}
if (Platform.OS === 'web') {
loader.load(
nativeAsset.localUri,
private loadHTMLFile = async () => {
try {
let asset: Asset = await AssetUtils.resolveAsync(INDEX_FILE_PATH);
let fileString: string = await FileSystem.readAsStringAsync(
asset.localUri
);
this.setState({ webviewContent: fileString });
} catch (error) {
console.warn(error);
console.warn("Unable to resolve index file");
}
};
componentDidMount = async () => {
try {
const asset = await AssetUtils.resolveAsync(requiredAsset)
console.log({asset})
this.setState({ asset })
} catch (error) {
console.log({ error })
}
};
async loadHtml() {
const { uri } = await AssetUtils.resolveAsync(editorCode)
const res = await fetch(uri)
const html = await res.text()
this.setState({ source: html })
}
async function textureAsync(resource) {
const asset = await AssetUtils.resolveAsync(resource);
return texture(asset);
}
export default textureAsync;
const textureFromExpoAsync = async resource => {
let asset = resource;
if (Platform.OS !== 'web') {
asset = await resolveAsync(resource);
}
return PIXI.Texture.from(asset);
};
export default async function resolveAsset(fileReference) {
let urls = [];
if (Array.isArray(fileReference)) {
for (let file of fileReference) {
const asset = await resolveAsync(file);
urls.push(asset);
}
}
else {
const asset = await resolveAsync(fileReference);
urls.push(asset);
}
return urls;
}
export async function stringFromAsset(asset) {
export default async function resolveAsset(fileReference: any): Promise {
let urls: Asset[] = [];
if (Array.isArray(fileReference)) {
for (let file of fileReference) {
const asset = await resolveAsync(file);
urls.push(asset);
}
} else {
const asset = await resolveAsync(fileReference);
urls.push(asset);
}
return urls;
}
set src(src) {
if (this._src === src) return;
delete this.localUri;
this._src = src;
if (src) {
resolveAsync(src).then(({ localUri }) => {
this.localUri = localUri;
if (this.onload) this.onload();
});
}
}
};