]> Repos - mime-chat/commitdiff
rename composable files to composable notation
authorriqo <hernandeze2@xavier.edu>
Tue, 15 Jun 2021 13:48:14 +0000 (08:48 -0500)
committerriqo <hernandeze2@xavier.edu>
Tue, 15 Jun 2021 13:48:14 +0000 (08:48 -0500)
18 files changed:
src/audio.ts
src/composables/audio.ts [deleted file]
src/composables/useEmitter.ts [moved from src/composables/emitter.ts with 100% similarity]
src/composables/useHttp.ts [moved from src/composables/http.ts with 100% similarity]
src/composables/useIpcMain.ts [moved from src/composables/ipcHandler.ts with 100% similarity]
src/composables/useMessageCanvas.ts [moved from src/composables/canvas.ts with 100% similarity]
src/composables/useSaveToJSON.ts [moved from src/composables/json.ts with 100% similarity]
src/composables/useWebsockets.ts [moved from src/composables/websockets.ts with 100% similarity]
src/render/components/controllers/messenger.control.ts
src/render/components/messenger.vue
src/render/components/settings.vue
src/render/composables/useDraggify.ts [moved from src/render/composables/draggify.ts with 100% similarity]
src/render/composables/useIpcRend.ts [moved from src/render/composables/ipc.ts with 100% similarity]
src/render/composables/useMessages.ts [new file with mode: 0644]
src/render/composables/useProfile.ts [moved from src/render/composables/auth.ts with 100% similarity]
src/render/composables/useScroll.ts [moved from src/render/composables/scroll.ts with 100% similarity]
src/render/main.ts [new file with mode: 0644]
src/store.ts [moved from src/composables/store.ts with 100% similarity]

index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..844e79194ab41f6b10af1ef988136ffc0f6c24f2 100644 (file)
@@ -0,0 +1,187 @@
+/* eslint @typescript-eslint/no-var-requires: "off" */
+
+"use strict";
+
+// where the audio goes
+let buffer: ArrayBuffer[] = [];
+
+// place audio data in buffer
+export function collect (chunk: ArrayBuffer) {
+    buffer.push(chunk);
+}
+
+// return audio and clear buffer
+export function flush () {
+    const bufferCopy = buffer;
+    buffer = [];
+    return bufferCopy;
+}
+
+// import { backgroundMitt } from '@/modules/emitter';
+// const portAudio = require('naudiodon');
+
+// // Audio in and out stream objects.
+// let ai: typeof portAudio.AudioIO | boolean = false;
+// let ao: typeof portAudio.AudioIO | boolean = false;
+
+// // Whether activly recording.
+// let record = false;
+
+// const audioContainer = {
+//     input: '',
+// }
+
+// const audioOptions = {
+//     channelCount: 1,
+//     sampleFormat: 16,
+//     sampleRate: 16000,
+//     deviceId: -1,
+//     closeOnError: false,
+// }
+
+// export const toggleRecord = (): void => { record = !record };
+
+
+// export const fetchAudioInput = (): Promise<Error | string> => (
+
+//     new Promise((resolve, reject) => {
+
+//         try {
+//             resolve(audioContainer.input);
+//             toggleRecord();
+//         } catch (e) {
+//             reject(new Error('Failed to fetch the audio.'))
+//         }
+
+//     })
+// )
+
+
+// // Main audio function run by run.ts module.
+// export function initAudioIO(): void {
+//     console.log("AUDIO:Starting io streams.")
+
+//     if (!ai) {
+
+//         // Initialize and start input stream.
+//         ai = new portAudio.AudioIO({ inOptions: audioOptions });
+//         ai.setEncoding("hex");
+//         ai.start();
+
+//         // On each data chunk...
+//         ai.on('data', (chunk: string) => {
+
+//             // If recording, we capture the data.
+//             if (record) {
+//                 console.log('AUDIO:Recording...')
+//                 audioContainer.input += chunk;
+//             }
+
+//             // Else, we don't capture and also clear audioContainer.
+//             else {
+//                 if (audioContainer.input.length) {
+//                     audioContainer.input = "";
+//                 }
+//             }
+
+//         });
+//     }
+
+//     if (!ao) {
+
+//         // Initialize and start input stream.
+//         ao = new portAudio.AudioIO({ outOptions: audioOptions });
+//         ao.start();
+
+//     }
+// }
+
+
+// // ---Audio playback--------------------------------------------
+
+// // Split Buffer into an array of len-sized Buffers.
+// function bufSplit(buf: Buffer, len: number): Array<Buffer> {
+//     const chunks = [];
+//     let i = 0;
+//     let L = len;
+
+//     while(i < buf.byteLength) {
+//       chunks.push(buf.slice(i, L));
+//       i = L;
+//       L += len;
+//     }
+
+//     return chunks;
+// }
+
+// // Audio playback.
+// export function play(input: string): void {
+
+//     // Format the audio.
+//     const audio = bufSplit(
+//         Buffer.from(input as string, 'hex'),
+//         8192
+//     );
+
+//     // Called on end of write.
+//     const callback = () => {
+
+//         // We stop audio playback anim.
+//         backgroundMitt.emit('ipc-renderer', {
+//             endpoint: 'stop-playback-anim'
+//         });
+
+//     }
+
+//     write();
+
+//     // Iterate through audio array and write buffers to portAudio writable.
+//     function write() {
+//         let chunk: Buffer;
+//         let ok = true;
+//         let i = 0;
+
+//         do {
+//             chunk = audio[i];
+//             if (i === audio.length - 1) {
+//                 // write last chunk.
+//                 ao.write(chunk, null, callback);
+//             } else {
+//                 // check for backpreassure.
+//                 ok = ao.write(chunk, null);
+//             }
+//             i++;
+//         } while (i < audio.length && ok);
+
+//         if (i < audio.length) {
+//             // Had to stop early!
+//             // Write some more once it drains.
+//             ao.once('drain', write);
+//         }
+//     }
+// }
+
+// // -------------------------------------------------------------
+
+// // Get's called on window close.
+// export async function stopStream() {
+//     console.log("AUDIO:Stopping audio stream.")
+//     if (ai) {
+//         try {
+//             await ai.quit()
+//         } catch(e){
+//             console.log('AUDIO: Failed to shutdown audio input.');
+//             throw e;
+//         }
+//     }
+//     if (ao) {
+//         try {
+//             await ao.quit()
+//         } catch(e){
+//             console.log('AUDIO: Failed to shutdown audio output.');
+//             throw e;
+//         }
+//     }
+// }
+
+
diff --git a/src/composables/audio.ts b/src/composables/audio.ts
deleted file mode 100644 (file)
index 844e791..0000000
+++ /dev/null
@@ -1,187 +0,0 @@
-/* eslint @typescript-eslint/no-var-requires: "off" */
-
-"use strict";
-
-// where the audio goes
-let buffer: ArrayBuffer[] = [];
-
-// place audio data in buffer
-export function collect (chunk: ArrayBuffer) {
-    buffer.push(chunk);
-}
-
-// return audio and clear buffer
-export function flush () {
-    const bufferCopy = buffer;
-    buffer = [];
-    return bufferCopy;
-}
-
-// import { backgroundMitt } from '@/modules/emitter';
-// const portAudio = require('naudiodon');
-
-// // Audio in and out stream objects.
-// let ai: typeof portAudio.AudioIO | boolean = false;
-// let ao: typeof portAudio.AudioIO | boolean = false;
-
-// // Whether activly recording.
-// let record = false;
-
-// const audioContainer = {
-//     input: '',
-// }
-
-// const audioOptions = {
-//     channelCount: 1,
-//     sampleFormat: 16,
-//     sampleRate: 16000,
-//     deviceId: -1,
-//     closeOnError: false,
-// }
-
-// export const toggleRecord = (): void => { record = !record };
-
-
-// export const fetchAudioInput = (): Promise<Error | string> => (
-
-//     new Promise((resolve, reject) => {
-
-//         try {
-//             resolve(audioContainer.input);
-//             toggleRecord();
-//         } catch (e) {
-//             reject(new Error('Failed to fetch the audio.'))
-//         }
-
-//     })
-// )
-
-
-// // Main audio function run by run.ts module.
-// export function initAudioIO(): void {
-//     console.log("AUDIO:Starting io streams.")
-
-//     if (!ai) {
-
-//         // Initialize and start input stream.
-//         ai = new portAudio.AudioIO({ inOptions: audioOptions });
-//         ai.setEncoding("hex");
-//         ai.start();
-
-//         // On each data chunk...
-//         ai.on('data', (chunk: string) => {
-
-//             // If recording, we capture the data.
-//             if (record) {
-//                 console.log('AUDIO:Recording...')
-//                 audioContainer.input += chunk;
-//             }
-
-//             // Else, we don't capture and also clear audioContainer.
-//             else {
-//                 if (audioContainer.input.length) {
-//                     audioContainer.input = "";
-//                 }
-//             }
-
-//         });
-//     }
-
-//     if (!ao) {
-
-//         // Initialize and start input stream.
-//         ao = new portAudio.AudioIO({ outOptions: audioOptions });
-//         ao.start();
-
-//     }
-// }
-
-
-// // ---Audio playback--------------------------------------------
-
-// // Split Buffer into an array of len-sized Buffers.
-// function bufSplit(buf: Buffer, len: number): Array<Buffer> {
-//     const chunks = [];
-//     let i = 0;
-//     let L = len;
-
-//     while(i < buf.byteLength) {
-//       chunks.push(buf.slice(i, L));
-//       i = L;
-//       L += len;
-//     }
-
-//     return chunks;
-// }
-
-// // Audio playback.
-// export function play(input: string): void {
-
-//     // Format the audio.
-//     const audio = bufSplit(
-//         Buffer.from(input as string, 'hex'),
-//         8192
-//     );
-
-//     // Called on end of write.
-//     const callback = () => {
-
-//         // We stop audio playback anim.
-//         backgroundMitt.emit('ipc-renderer', {
-//             endpoint: 'stop-playback-anim'
-//         });
-
-//     }
-
-//     write();
-
-//     // Iterate through audio array and write buffers to portAudio writable.
-//     function write() {
-//         let chunk: Buffer;
-//         let ok = true;
-//         let i = 0;
-
-//         do {
-//             chunk = audio[i];
-//             if (i === audio.length - 1) {
-//                 // write last chunk.
-//                 ao.write(chunk, null, callback);
-//             } else {
-//                 // check for backpreassure.
-//                 ok = ao.write(chunk, null);
-//             }
-//             i++;
-//         } while (i < audio.length && ok);
-
-//         if (i < audio.length) {
-//             // Had to stop early!
-//             // Write some more once it drains.
-//             ao.once('drain', write);
-//         }
-//     }
-// }
-
-// // -------------------------------------------------------------
-
-// // Get's called on window close.
-// export async function stopStream() {
-//     console.log("AUDIO:Stopping audio stream.")
-//     if (ai) {
-//         try {
-//             await ai.quit()
-//         } catch(e){
-//             console.log('AUDIO: Failed to shutdown audio input.');
-//             throw e;
-//         }
-//     }
-//     if (ao) {
-//         try {
-//             await ao.quit()
-//         } catch(e){
-//             console.log('AUDIO: Failed to shutdown audio output.');
-//             throw e;
-//         }
-//     }
-// }
-
-
index 9ae7d47f18cfa9033cf0e5249b146de9bd3cb22a..a0f9b09c19647efa08463faf8704ca755a26f26f 100644 (file)
@@ -1,20 +1,20 @@
 import { ref } from 'vue';
 import useScroll from "@/render/composables/scroll";
 
-const canvas = ref();
+const messagesRef = ref();
 
 /* seed the canvas with messages */
 const seedCanvas = (messages: Message[]) => {
-  canvas.value = messages;
+  messagesRef.value = messages;
 }
 
 const addMessage = (message: Message) => {
-  canvas.value.push(message);
+  messagesRef.value.push(message);
 }
 
 const updateMessage = (message: Message) => {
 
-  let target_message = canvas.value.filter((m: Message) => {
+  let target_message = messagesRef.value.filter((m: Message) => {
       return m.uid = message.uid;
   })[0];
 
@@ -29,10 +29,10 @@ export default function useMessages() {
   const { updateScrollRef, adjustScroll } = useScroll("messenger");
 
   return {
-    canvas,
+    messagesRef,
     seedCanvas,
     addMessage,
     updateMessage
   };
 
-}
\ No newline at end of file
+}
index 4ea2d5b73c90c808023f6bdc7a30b1016bc6f593..9bc64483298c22e2028db60b3c50b25bc6870dc5 100644 (file)
@@ -8,10 +8,9 @@
   <!-- List of message bubbles. -->
   <div id="messenger">
     <Bubble
-      v-for="message in messages"
+      v-for="message in messagesRef"
       :text="message.text"
       :context="message.context"
-      :child
       :key="message[0]"
     />
   </div>
@@ -24,7 +23,7 @@ import { defineComponent, onMounted, onUnmounted } from "vue";
 import Message from "@/render/components/message.vue";
 import InputItem from "@/render/components/inputItem.vue";
 import Settings from "@/render/components/settings.vue";
-import useMessages from "@/render/composables/messages";
+import useMessages from "./controllers/messenger.control";
 
 export default defineComponent({
   name: "Messenger",
@@ -40,23 +39,23 @@ export default defineComponent({
   setup(props) {
 
     // Handle messages in view.
-    const { messages, updateMessageView } = useMessages();
+    const { messagesRef, updateMessageView } = useMessages();
 
     onMounted(() => {
 
       /* seed messages */
       window.ipcRenderer.on("init-messages", (e_: any, payload: any) => {
-        seedMessages(payload.messages);
+        // seedMessages(payload.messages);
       });
 
       /* add a new message */
       window.ipcRenderer.on("add-message", (_e: any, payload: any) => {
-        addMessage(payload.message);
+        // addMessage(payload.message);
       });
 
       /* update an existing message */
       window.ipcRenderer.on("update-message", (_e: any, payload: any) => {
-        updateMessage(payload.message);
+        // updateMessage(payload.message);
       });
 
     });
@@ -66,7 +65,7 @@ export default defineComponent({
     });
 
     return {
-      messages
+      messagesRef
     };
 
   },
index 7c4b9ceec27e3b4beb8c842ac30dca554d538c27..9b4f3e56575614775acec308128ea9ed4b20bb23 100644 (file)
@@ -31,7 +31,7 @@
   import  { useIpc } from "@/modules/ipc";
   import { logoutRequest } from '@/modules/message';
   import { useProfile } from "@/modules/auth"
-  import { invokeLogout } from "@/ipcRend/account";
+  import { invokeLogout } from "@/render/ipc";
 
   export default defineComponent({
     name: "Settings",
diff --git a/src/render/composables/useMessages.ts b/src/render/composables/useMessages.ts
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/render/main.ts b/src/render/main.ts
new file mode 100644 (file)
index 0000000..50a594a
--- /dev/null
@@ -0,0 +1,16 @@
+
+// src/main.ts
+
+import App from "./App.vue";
+
+import mitt from "mitt";
+import { createApp } from "vue";
+
+
+// Handle events.
+const emitter = mitt();
+
+const app = createApp(App)
+
+app.provide("mitt", emitter)
+app.mount("#app");
similarity index 100%
rename from src/composables/store.ts
rename to src/store.ts