From dfc604f50009c04f2eb2344945d64287c63daa77 Mon Sep 17 00:00:00 2001 From: MediaPipe Team Date: Fri, 14 Apr 2023 10:08:52 -0700 Subject: [PATCH] Patch for FileLocator and asset scripts not working together PiperOrigin-RevId: 524320143 --- mediapipe/web/graph_runner/graph_runner.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mediapipe/web/graph_runner/graph_runner.ts b/mediapipe/web/graph_runner/graph_runner.ts index 88c9d939..578577cf 100644 --- a/mediapipe/web/graph_runner/graph_runner.ts +++ b/mediapipe/web/graph_runner/graph_runner.ts @@ -1217,10 +1217,17 @@ export async function createMediaPipeLib( if (!self.ModuleFactory) { throw new Error('ModuleFactory not set.'); } + + // 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 + // use that. TODO: Remove this when asset scripts are fixed. + if (self.Module && fileLocator) { + (self.Module as FileLocator).locateFile = fileLocator.locateFile; + } // TODO: Ensure that fileLocator is passed in by all users // and make it required const module = - await self.ModuleFactory(fileLocator || self.Module as FileLocator); + await self.ModuleFactory(self.Module as FileLocator || fileLocator); // Don't reuse factory or module seed self.ModuleFactory = self.Module = undefined; return new constructorFcn(module, glCanvas);