No public description

PiperOrigin-RevId: 554673463
This commit is contained in:
MediaPipe Team 2023-08-07 20:13:00 -07:00 committed by Copybara-Service
parent 032ed973b6
commit 39b31e51a9

View File

@ -1253,23 +1253,24 @@ export async function createMediaPipeLib<LibType>(
assetLoaderScript?: string|null, assetLoaderScript?: string|null,
glCanvas?: HTMLCanvasElement|OffscreenCanvas|null, glCanvas?: HTMLCanvasElement|OffscreenCanvas|null,
fileLocator?: FileLocator): Promise<LibType> { fileLocator?: FileLocator): Promise<LibType> {
const scripts = [];
// Run wasm-loader script here // Run wasm-loader script here
if (wasmLoaderScript) { if (wasmLoaderScript) {
scripts.push(wasmLoaderScript); await runScript(wasmLoaderScript);
}
// Run asset-loader script here
if (assetLoaderScript) {
scripts.push(assetLoaderScript);
}
// Load scripts in parallel, browser will execute them in sequence.
if (scripts.length) {
await Promise.all(scripts.map(runScript));
} }
if (!self.ModuleFactory) { if (!self.ModuleFactory) {
throw new Error('ModuleFactory not set.'); throw new Error('ModuleFactory not set.');
} }
// Run asset-loader script here; must be run after wasm-loader script if we
// are re-wrapping the existing MODULARIZE export.
if (assetLoaderScript) {
await runScript(assetLoaderScript);
if (!self.ModuleFactory) {
throw new Error('ModuleFactory not set.');
}
}
// Until asset scripts work nicely with MODULARIZE, when we are given both // Until asset scripts work nicely with MODULARIZE, when we are given both
// self.Module and a fileLocator, we manually merge them into self.Module and // self.Module and a fileLocator, we manually merge them into self.Module and
// use that. TODO: Remove this when asset scripts are fixed. // use that. TODO: Remove this when asset scripts are fixed.