UNPKG

tav-media

Version:

Cross platform media editing framework

38 lines (37 loc) 1.11 kB
/* eslint-disable @typescript-eslint/no-require-imports */ // use require to import tav media node native module let tavModule; let platform = 'browser'; // Fix for Code static analysis tool throw error function requireFile(path) { return require(path); } // For nodejs environment, import node napi module if (typeof (process) !== 'undefined' && process.version) { tavModule = requireFile('../../bin/node/TAVMediaTemplateNode.node'); platform = 'nodejs'; // For Browser, use WASM module as tav namespace } else if (typeof (window) !== 'undefined' && window.Module) { tavModule = window.Module; platform = 'browser'; } else if (globalThis.tav) { // For built-in javascript engine, use tav namespace tavModule = globalThis.tav; platform = 'engine'; } else if (typeof (wx) !== 'undefined') { platform = 'wx'; } if (tavModule) { tavModule.PLATFORM = platform; } // eslint-disable-next-line import/no-mutable-exports export let tav = tavModule; export function setTAVModule(module) { tav = module; if (!tav.PLATFORM) { tav.PLATFORM = platform; } }