Allow relative URLs for WASM loading

PiperOrigin-RevId: 523572715
This commit is contained in:
Sebastian Schmidt 2023-04-11 19:20:53 -07:00 committed by Copybara-Service
parent e2b13523f1
commit 1b947df0c2

View File

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
// Placeholder for internal dependency on trusted resource URL builder // Placeholder for internal dependency on resourceUrlSafeByReview
import {WasmFileset} from './wasm_fileset'; import {WasmFileset} from './wasm_fileset';
@ -30,6 +30,9 @@ const WASM_SIMD_CHECK = new Uint8Array([
2, 1, 0, 10, 10, 1, 8, 0, 65, 0, 253, 15, 253, 98, 11 2, 1, 0, 10, 10, 1, 8, 0, 65, 0, 253, 15, 253, 98, 11
]); ]);
/** The categories of tasks supported by MediaPipe. */
type MediapipeTaskCategory = 'audio'|'text'|'vision';
async function isSimdSupported(): Promise<boolean> { async function isSimdSupported(): Promise<boolean> {
if (supportsSimd === undefined) { if (supportsSimd === undefined) {
try { try {
@ -44,7 +47,7 @@ async function isSimdSupported(): Promise<boolean> {
} }
async function createFileset( async function createFileset(
taskName: string, basePath = ''): Promise<WasmFileset> { taskName: MediapipeTaskCategory, basePath = ''): Promise<WasmFileset> {
const suffix = const suffix =
await isSimdSupported() ? 'wasm_internal' : 'wasm_nosimd_internal'; await isSimdSupported() ? 'wasm_internal' : 'wasm_nosimd_internal';