import engineCheck from "engine-check" ; import { dirname , join , } from "node:path" ; import process from "node:process" ; import { fileURLToPath , } from "node:url" ; import UvcControl from "uvc-control" ; import CameraControlHelper from "./camera-control-helper.js" ; import CameraControlHelperFactory from "./camera-control-helper-factory.js" ; import CameraFactory from "./camera-factory.js" ; import CameraHelper from "./camera-helper.js" ; import CameraHelperFactory from "./camera-helper-factory.js" ; import CommandHandlers from "./command-handlers.js" ; import ControlsCommand from "./command-handlers/controls.js" ; import DevicesCommand from "./command-handlers/devices.js" ; import ExportCommand from "./command-handlers/export.js" ; import GetCommand from "./command-handlers/get.js" ; import ImportCommand from "./command-handlers/import.js" ; import RangeCommand from "./command-handlers/range.js" ; import RangesCommand from "./command-handlers/ranges.js" ; import SetCommand from "./command-handlers/set.js" ; import CommandManager from "./command-manager.js" ; import Output from "./output.js" ; import runtimeConfigurator from "./runtime-configurator.js" ; import { Commands , } from "./types/command.js" ; import UvcDeviceLister from "./uvc-device-lister.js" ; const __dirname = dirname ( fileURLToPath ( import . meta . url ) ) ; const mainAsync = async ( ) => { try { const runtimeConfig = await runtimeConfigurator ( ) ; const output = new Output ( runtimeConfig . verbose ) ; process . on ( "unhandledRejection" , ( ... args ) => { output . error ( ... args ) ; process . exitCode = 1 ; } ) ; process . on ( "uncaughtException" , ( ... args ) => { output . error ( ... args ) ; process . exitCode = 1 ; } ) ; const cameraFactory = new CameraFactory ( output , UvcControl ) ; const cameraControlHelperFactory = new CameraControlHelperFactory ( UvcControl , CameraControlHelper ) ; const cameraHelperFactory = new CameraHelperFactory ( output , cameraControlHelperFactory , CameraHelper ) ; const uvcDeviceLister = new UvcDeviceLister ( UvcControl ) ; const commands = { controls : new ControlsCommand ( ) , devices : new DevicesCommand ( uvcDeviceLister ) , "export" : new ExportCommand ( ) , get : new GetCommand ( ) , "import" : new ImportCommand ( ) , range : new RangeCommand ( ) , ranges : new RangesCommand ( ) , set : new SetCommand ( ) , } ; const commandHandlers = new CommandHandlers ( output , commands ) ; const commandManager = new CommandManager ( output , cameraFactory , cameraHelperFactory , commandHandlers ) ; await commandManager . execute ( runtimeConfig ) ; } catch ( error ) { console . error ( error ) ; process . exitCode = 1 ; } } ; const main = ( ) => { try { engineCheck ( { searchRoot : join ( __dirname , ".." ) , } ) ; void mainAsync ( ) ; } catch ( error ) { console . error ( error ) ; process . exitCode = 1 ; } } ; main ( ) ;