From 43f1a1dd1b44065663a797603012394c52a9baea Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 13 May 2023 13:31:58 -0300 Subject: use ESM module syntax & update tui-lib Exciting update! This doesn't make any substantial changes exactly but does update the most quickly-archaic parts of older Node code. --- client.js | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) (limited to 'client.js') diff --git a/client.js b/client.js index ec1ab60..0af45f6 100644 --- a/client.js +++ b/client.js @@ -1,22 +1,18 @@ // Generic code for setting up mtui and the UI for any command line client. -'use strict' - -const AppElement = require('./ui') -const processSmartPlaylist = require('./smart-playlist') - -const { - ui: { - Root - }, - util: { - ansi, - Flushable, - TelnetInterfacer - } -} = require('tui-lib') +import AppElement from './ui.js' + +import {Root} from 'tui-lib/ui/primitives' -const setupClient = async ({backend, writable, interfacer, appConfig}) => { +import {Flushable} from 'tui-lib/util/interfaces' +import * as ansi from 'tui-lib/util/ansi' + +export default async function setupClient({ + backend, + writable, + screenInterface, + appConfig, +}) { const cleanTerminal = () => { writable.write(ansi.cleanCursor()) writable.write(ansi.disableAlternateScreen()) @@ -30,10 +26,10 @@ const setupClient = async ({backend, writable, interfacer, appConfig}) => { dirtyTerminal() const flushable = new Flushable(writable, true) - const root = new Root(interfacer, flushable) + const root = new Root(screenInterface, flushable) root.on('rendered', () => flushable.flush()) - const size = await interfacer.getScreenSize() + const size = await screenInterface.getScreenSize() root.w = size.width root.h = size.height root.fixAllLayout() @@ -42,7 +38,7 @@ const setupClient = async ({backend, writable, interfacer, appConfig}) => { flushable.write(ansi.clearScreen()) flushable.flush() - interfacer.on('resize', newSize => { + screenInterface.on('resize', newSize => { root.w = newSize.width root.h = newSize.height flushable.resizeScreen(newSize) @@ -69,5 +65,3 @@ const setupClient = async ({backend, writable, interfacer, appConfig}) => { return {appElement, cleanTerminal, dirtyTerminal, flushable, root} } - -module.exports = setupClient -- cgit 1.3.0-6-gf8a5