Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function render(rootComponent, stdio) {
var mount = new TuiRootMount(rootComponent, stdio);
exitHook(mount.componentWillUnmount.bind(mount));
mount.componentDidMount();
var events = new TuiEvents(stdio);
exitHook(events.componentWillUnmount.bind(events));
events.componentDidMount();
// Pipe events to mount
events.on('event', mount.handleEvent.bind(mount));
}
return new Promise((resolve) => {
var webpackDevServer = require.resolve('.bin/webpack-dev-server');
var args = '--config webpack.config.dev.js --hot --no-info --colors --port 2992 --inline';
var hotReload = spawn(webpackDevServer, args.split(' '), {
cwd: path.join(__dirname, '..'),
env: this.process.env,
stdio: [
'pipe',
'pipe',
this.process.stderr
]
});
exitHook(hotReload.kill.bind(hotReload));
hotReload.stdout.once('data', resolve);
});
}
.then(() => {
const screen = tui();
const main = new MainController(screen);
const player = cli.flags.player === 'mpd' ? new MpdPlayer() : new NodePlayer();
player.setOnNextSongCallback(() => store.dispatch(moveNext()));
exitHook(player.killPlayer.bind(player));
storage.on(PAUSE, () => player.pause());
storage.on(PLAY, url => player.play(url));
screen.key(['C-f'], () => storage.emit(SEARCH_VK));
screen.key(['f'], () => storage.emit(LOCAL_SEARCH));
screen.key(['space'], () => storage.emit(PAUSE));
screen.key(['x'], () => storage.emit(ADD_TO_PROFILE));
screen.key(['m', 'ь'], () => storage.emit(SWITCH_PANE));
screen.key(['d', 'в'], () => storage.emit(MOVE_TO_PLAYING));
screen.key(['left'], () => storage.emit(FOCUS_LEFT_PANE));
screen.key(['right'], () => storage.emit(FOCUS_RIGHT_PANE));
screen.key(['/', '?', '.', ','], () => storage.emit(SHOW_HELP));
};
const doCleanup = () => {
const tasks = cleanupTasks.slice(0);
cleanupTasks.length = 0;
for (const task of tasks) {
try {
task();
} catch (error) {
handleErrorWithoutExit(error);
}
}
};
const unhookExit: CleanupTask = exitHook(doCleanup);
const cleanupTasks: CleanupTask[] = [unhookExit];
try {
if (!allowUnexpected && flags.unexpected.length) {
throw createFlagError(`Unknown flag(s) "${flags.unexpected.join('", "')}"`);
}
try {
await fn({
log,
flags,
addCleanupTask: (task: CleanupTask) => cleanupTasks.push(task),
});
} finally {
doCleanup();
}
constructor(private log: ToolingLog) {
this.signalUnsubscribe = exitHook(() => {
this.teardown().catch(error => {
log.error(`ProcRunner teardown error: ${error.stack}`);
});
});
}
function Player(trakt) {
this.status = STOPPED;
this.trakt = trakt;
exitHook(() => this.stop());
}