mirror of
https://github.com/imputnet/cobalt.git
synced 2026-08-27 04:05:22 +00:00
packages/cobalt-rs-hls: add cross-platform loading logic
This commit is contained in:
parent
3f0105d8cf
commit
c9f5570b20
1 changed files with 21 additions and 3 deletions
|
|
@ -1,7 +1,25 @@
|
|||
import { createRequire } from 'module';
|
||||
const require = createRequire(import.meta.url);
|
||||
|
||||
// we load the compiled native binary directly for now
|
||||
const { HlsParser } = require('./cobalt-rs-hls.darwin-arm64.node');
|
||||
let nativeBinding = null;
|
||||
const { platform, arch } = process;
|
||||
|
||||
export { HlsParser };
|
||||
try {
|
||||
if (platform === 'darwin' && arch === 'arm64') {
|
||||
nativeBinding = require('./cobalt-rs-hls.darwin-arm64.node');
|
||||
} else if (platform === 'darwin' && arch === 'x64') {
|
||||
nativeBinding = require('./cobalt-rs-hls.darwin-x64.node');
|
||||
} else if (platform === 'linux' && arch === 'x64') {
|
||||
nativeBinding = require('./cobalt-rs-hls.linux-x64-gnu.node');
|
||||
} else if (platform === 'linux' && arch === 'arm64') {
|
||||
nativeBinding = require('./cobalt-rs-hls.linux-arm64-gnu.node');
|
||||
} else if (platform === 'win32' && arch === 'x64') {
|
||||
nativeBinding = require('./cobalt-rs-hls.win32-x64-msvc.node');
|
||||
} else {
|
||||
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`);
|
||||
}
|
||||
} catch (e) {
|
||||
throw new Error(`Failed to load native binding for ${platform}-${arch}: ${e.message}`);
|
||||
}
|
||||
|
||||
export const HlsParser = nativeBinding.HlsParser;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue