From 1627e07964a84723aaa8ddf646ebe1e24f1d42a8 Mon Sep 17 00:00:00 2001 From: Enrique Hernandez Date: Thu, 17 Dec 2020 11:50:03 -0600 Subject: [PATCH] stream path animation v4 update input items styling add ipc event handler for message add send-message ipc handler add audio to send-message ipc remove extra JSON stringify statement for audio message add render bug fix for add contacts --- src/background.ts | 68 +++----- .../UI/UIDetails/messageRenderer.vue | 15 +- src/components/UI/UIDetails/messages.ts | 22 +-- src/components/UI/index.vue | 5 + .../input/inputDetails/audioInput.vue | 93 ++++++----- .../input/inputDetails/textInput.vue | 16 +- src/components/input/inputItem.vue | 44 +++--- .../input/audio/audioDetails/useAnimations.ts | 28 ++++ src/core/UI/input/audio/useStreamRecord.ts | 27 ++++ src/core/UI/input/audio/useStreamRender.ts | 81 ---------- .../UI/input/audio/useStreamVisualizer.ts | 148 ++++++++++++++++++ .../input/text/textDetails/useAnimations.ts | 1 + src/core/UI/input/text/useTextRender.ts | 46 +++--- src/core/UI/input/useInputController.ts | 82 +++++----- .../message/messageDetails/useComputed.ts | 1 + .../useMessageView.ts} | 23 ++- .../viewDetails}/useAnimations.ts | 2 +- .../viewDetails}/useOffsetCalculator.ts | 0 src/preload.ts | 14 +- src/types/animejs/index.ts | 4 + src/utils/keyDownHandler/useKeyDownHandler.ts | 13 +- src/utils/mediaStream/useMediaStream.ts | 2 + testServer.js | 10 +- 23 files changed, 450 insertions(+), 295 deletions(-) create mode 100644 src/core/UI/input/audio/audioDetails/useAnimations.ts delete mode 100644 src/core/UI/input/audio/useStreamRender.ts create mode 100644 src/core/UI/input/audio/useStreamVisualizer.ts rename src/core/messenger/{renderView/useRenderView.ts => messageView/useMessageView.ts} (73%) rename src/core/messenger/{renderView/renderDetails => messageView/viewDetails}/useAnimations.ts (98%) rename src/core/messenger/{renderView/renderDetails => messageView/viewDetails}/useOffsetCalculator.ts (100%) diff --git a/src/background.ts b/src/background.ts index 6b1284a..2892aa3 100644 --- a/src/background.ts +++ b/src/background.ts @@ -8,22 +8,15 @@ import * as path from "path"; import { SpeechRecorder } from "speech-recorder"; // TODO: connect To Crimata-BE -// import WebSocket from "ws"; +import WebSocket from "ws"; -// const ws = new WebSocket("ws://localhost:8080"); -// ws.on("open", function open() { -// ws.send("hello fro client"); -// }); -// ws.on("message", (message: any) => { -// console.log("received message", message); -// }); -// // const recorder = new SpeechRecorder({ sampleRate: 16000, framesPerBuffer: 320 }); // Keep a global reference of the window object, if you don't, the window will // be closed automatically when the JavaScript object is garbage collected. let win: BrowserWindow | null; +let ws: any; // Scheme must be registered before the app is ready protocol.registerSchemesAsPrivileged([ @@ -56,44 +49,35 @@ function createWindow() { win.loadURL("app://./index.html"); } - win.webContents.on('did-finish-load', () => { - // ipcMain.on('audio-stream', (Event: any, Payload: any) => { - // if (Payload.stream) { - // console.log('begin streaming'); - // recorder.start({ - // onAudio: (audio: object, speech: boolean) => { - // console.log(audio) - // } - // }); - // } else { - // recorder.stop(); - // console.log('stop streaming') - // } - // }) - - // if (win) { - // recorder.start({ - // onAudio: (audio: object, speech: boolean) => { - // if (win) { - // win.setTitle("Listening..."); - // // win.webContents.send('render-audio', { - // // audio: audio, - // // speech: speech - // // }) - // if (speech) { - // win.setTitle("Recording..."); - // // TODO: send audio to crimata BE - // // ws.send(audio); - // } - // } - // } - // }); - // } + + ws = new WebSocket("ws://localhost:8080"); + ws.on("open", function open() { + ws.send("hernandeze2@xavier.edu"); + }); + ws.on("message", (message: any) => { + const parsed = JSON.parse(message); + console.log('new message', message) + if (win) { + win.webContents.send('render-message', { + message: parsed + }) + } + }); + + ipcMain.on('send-message', (Event: any, payload: any) => { + const stringMessage = JSON.stringify(payload.message) + ws.send(stringMessage); + }) + + ipcMain.on('update-menu-bar', (Event: any, payload: any) => { + // win.setTitle("Listening..."); + }) }) win.on("closed", () => { win = null; + ws = null; }); } diff --git a/src/components/UI/UIDetails/messageRenderer.vue b/src/components/UI/UIDetails/messageRenderer.vue index 02a14e8..6084c17 100644 --- a/src/components/UI/UIDetails/messageRenderer.vue +++ b/src/components/UI/UIDetails/messageRenderer.vue @@ -12,7 +12,6 @@ class="messageList" transform="translate(0, 25)" preserverAspectRatio="none" - > \ No newline at end of file + }); + return { center }; + }, +}); + diff --git a/src/components/input/inputDetails/textInput.vue b/src/components/input/inputDetails/textInput.vue index 06419e9..c4e1f16 100644 --- a/src/components/input/inputDetails/textInput.vue +++ b/src/components/input/inputDetails/textInput.vue @@ -1,5 +1,11 @@