From 36c786a26d4c928547bcca9407bac46df61c0bbd Mon Sep 17 00:00:00 2001 From: jamesread Date: Tue, 11 Nov 2025 10:20:54 +0000 Subject: [PATCH] chore: Cleanup websocket/marshaller code --- frontend/js/marshaller.js | 13 ------------- frontend/js/websocket.js | 16 ++++++++++++++++ frontend/main.js | 17 +++-------------- 3 files changed, 19 insertions(+), 27 deletions(-) delete mode 100644 frontend/js/marshaller.js diff --git a/frontend/js/marshaller.js b/frontend/js/marshaller.js deleted file mode 100644 index 011d736..0000000 --- a/frontend/js/marshaller.js +++ /dev/null @@ -1,13 +0,0 @@ -export function initMarshaller () { - window.addEventListener('EventOutputChunk', onOutputChunk) -} - -function onOutputChunk (evt) { - const chunk = evt.payload - - if (window.terminal) { - if (chunk.executionTrackingId === window.terminal.executionTrackingId) { - window.terminal.write(chunk.output) - } - } -} diff --git a/frontend/js/websocket.js b/frontend/js/websocket.js index e8b5a30..013c614 100644 --- a/frontend/js/websocket.js +++ b/frontend/js/websocket.js @@ -1,5 +1,11 @@ import { buttonResults } from '../resources/vue/stores/buttonResults.js' +export function initWebsocket () { + window.addEventListener('EventOutputChunk', onOutputChunk) + + window.checkWebsocketConnection = checkWebsocketConnection +} + export function checkWebsocketConnection () { reconnectWebsocket() } @@ -47,3 +53,13 @@ function handleEvent (msg) { window.showBigError('ws-unhandled-message', 'handling websocket message', 'Unhandled websocket message type from server: ' + typeName, true) } } + +function onOutputChunk (evt) { + const chunk = evt.payload + + if (window.terminal) { + if (chunk.executionTrackingId === window.terminal.executionTrackingId) { + window.terminal.write(chunk.output) + } + } +} diff --git a/frontend/main.js b/frontend/main.js index 66cbd78..4409f03 100644 --- a/frontend/main.js +++ b/frontend/main.js @@ -15,16 +15,11 @@ import { createApp } from 'vue' import router from './resources/vue/router.js' import App from './resources/vue/App.vue' -import { - initMarshaller -} from './js/marshaller.js' - -import { checkWebsocketConnection } from './js/websocket.js' +import { initWebsocket } from './js/websocket.js' function initClient () { const transport = createConnectTransport({ baseUrl: window.location.protocol + '//' + window.location.host + '/api/' - }) window.client = createClient(OliveTinApiService, transport) @@ -40,15 +35,9 @@ function setupVue () { function main () { initClient() - // Expose websocket connection function globally so App.vue can call it after successful init - window.checkWebsocketConnection = checkWebsocketConnection + initWebsocket() setupVue() - - initMarshaller() - -// window.addEventListener('EventConfigChanged', fetchGetDashboardComponents) -// window.addEventListener('EventEntityChanged', fetchGetDashboardComponents) } -main() // call self +main()