import { Buffer } from "node:buffer"; import { createRequire } from "node:module"; import { getEnv } from "./runtime.ts"; import type { MediaParams, MediaTypes } from "./types.ts"; export interface FuncObject { name: string; input: boolean; anim?: boolean; } export interface MediaLib { funcs: { image: FuncObject[]; }; process( type: MediaTypes, cmd: string, params: MediaParams["params"], input: { data?: ArrayBuffer; type?: string; }, ): Promise<{ data: Buffer; type: string }>; init(): { image?: string[]; }; shutdown(): void; trim(): number; } const nodeRequire = createRequire(import.meta.url); const debug = getEnv("DEBUG"); const relPath = `../../build/${debug && debug === "true" ? "Debug" : "Release"}/esmbmedia.node`; export const media = nodeRequire(relPath) as MediaLib;