+
Rigctld remote port
-
+
-
Radio model
diff --git a/gui_vue/src/js/chatHandler.ts b/gui_vue/src/js/chatHandler.ts
index 9cbc6d40..f9cc10fd 100644
--- a/gui_vue/src/js/chatHandler.ts
+++ b/gui_vue/src/js/chatHandler.ts
@@ -17,14 +17,11 @@ const state = useStateStore(pinia);
import { useSettingsStore } from "../store/settingsStore.js";
const settings = useSettingsStore(pinia);
-
import { sendMessage, sendBroadcastChannel } from "./sock.js";
import { displayToast } from "./popupHandler.js";
-
//const FD = require("./src/js/freedata.js");
-import {btoa_FD} from "./freedata.js"
-
+import { btoa_FD } from "./freedata.js";
// split character
const split_char = "0;1;";
@@ -61,8 +58,7 @@ interface messageDefaultObject {
};
}
-
-interface beaconDefaultObject{
+interface beaconDefaultObject {
command: string;
is_new: boolean;
_id: string;
@@ -94,37 +90,36 @@ PouchDB.plugin(require("pouchdb-find"));
PouchDB.plugin(require("pouchdb-upsert"));
// https://stackoverflow.com/a/26227660
-if(typeof process.env["APPDATA"] !== "undefined"){
- var appDataFolder = process.env["APPDATA"]
- console.log(appDataFolder)
-
+if (typeof process.env["APPDATA"] !== "undefined") {
+ var appDataFolder = process.env["APPDATA"];
+ console.log(appDataFolder);
} else {
- var appDataFolder: string;
+ var appDataFolder: string;
- switch (process.platform) {
- case "darwin":
- appDataFolder = process.env["HOME"] + "/Library/Application Support";
- console.log(appDataFolder);
- break;
- case "linux":
- appDataFolder = process.env["HOME"] + "/.config";
- console.log(appDataFolder);
- break;
- case "win32":
- appDataFolder = "undefined";
- break;
- default:
- appDataFolder = "undefined";
- break;
- }
+ switch (process.platform) {
+ case "darwin":
+ appDataFolder = process.env["HOME"] + "/Library/Application Support";
+ console.log(appDataFolder);
+ break;
+ case "linux":
+ appDataFolder = process.env["HOME"] + "/.config";
+ console.log(appDataFolder);
+ break;
+ case "win32":
+ appDataFolder = "undefined";
+ break;
+ default:
+ appDataFolder = "undefined";
+ break;
+ }
}
-console.log("loading chat database...")
-console.log("appdata folder:" + appDataFolder)
+console.log("loading chat database...");
+console.log("appdata folder:" + appDataFolder);
var configFolder = path.join(appDataFolder, "FreeDATA");
-console.log("config folder:" + configFolder)
+console.log("config folder:" + configFolder);
var chatDB = path.join(configFolder, "chatDB");
-console.log("database path:" + chatDB)
+console.log("database path:" + chatDB);
var db = new PouchDB(chatDB);
@@ -135,8 +130,7 @@ var db = new PouchDB(chatDB);
/* -------- RUN A DATABASE CLEANUP ON STARTUP */
//dbClean()
-updateAllChat(true)
-
+updateAllChat(true);
// create callsign set for storing unique callsigns
chat.callsign_list = new Set();
@@ -147,9 +141,9 @@ export function newBroadcast(broadcastChannel, chatmessage) {
var frames = "";
var data = "";
- var file = "";
- var filetype = "text";
- var filename = "";
+ var file = "";
+ var filetype = "text";
+ var filename = "";
var file_checksum = ""; //crc32(file).toString(16).toUpperCase();
var checksum = "";
@@ -167,37 +161,35 @@ export function newBroadcast(broadcastChannel, chatmessage) {
// slice uuid for reducing overhead
uuid = uuid.slice(-4);
+ let newChatObj: messageDefaultObject = {
+ command: "broadcast",
+ hmac_signed: false,
+ percent: 0,
+ bytesperminute: 0, // You need to assign a value here
+ is_new: false,
+ _id: uuid,
+ timestamp: timestamp,
+ dxcallsign: broadcastChannel,
+ dxgrid: "null",
+ msg: chatmessage,
+ checksum: file_checksum,
+ type: message_type,
+ status: "transmitting",
+ attempt: 1,
+ uuid: uuid,
+ duration: 0,
+ nacks: 0,
+ speed_list: "null",
+ _attachments: {
+ [filename]: {
+ content_type: filetype,
+ data: btoa_FD(file),
+ },
+ },
+ };
-let newChatObj: messageDefaultObject = {
- command: "broadcast",
- hmac_signed: false,
- percent: 0,
- bytesperminute: 0, // You need to assign a value here
- is_new: false,
- _id: uuid,
- timestamp: timestamp,
- dxcallsign: broadcastChannel,
- dxgrid: "null",
- msg: chatmessage,
- checksum: file_checksum,
- type: message_type,
- status: "transmitting",
- attempt: 1,
- uuid: uuid,
- duration: 0,
- nacks: 0,
- speed_list: "null",
- _attachments: {
- [filename]: {
- content_type: filetype,
- data: btoa_FD(file),
- }
- }
-};
-
-
- //sendMessage(newChatObj)
- sendBroadcastChannel(newChatObj)
+ //sendMessage(newChatObj)
+ sendBroadcastChannel(newChatObj);
addObjToDatabase(newChatObj);
}
@@ -216,7 +208,7 @@ export function newMessage(
var data = "";
var filename = "";
var filetype = "";
- var file=""
+ var file = "";
if (typeof chatFile !== "undefined") {
file = chatFile;
filetype = chatFileType;
@@ -242,33 +234,32 @@ export function newMessage(
// slice uuid for reducing overhead
uuid = uuid.slice(-8);
-
-let newChatObj: messageDefaultObject = {
- command: "msg",
- hmac_signed: false,
- percent: 0,
- bytesperminute: 0, // You need to assign a value here
- is_new: false,
- _id: uuid,
- timestamp: timestamp,
- dxcallsign: dxcallsign,
- dxgrid: "null",
- msg: chatmessage,
- checksum: file_checksum,
- type: message_type,
- status: "transmitting",
- attempt: 1,
- uuid: uuid,
- duration: 0,
- nacks: 0,
- speed_list: "null",
- _attachments: {
- [filename]: {
- content_type: filetype,
- data: btoa_FD(file)
- }
- }
-};
+ let newChatObj: messageDefaultObject = {
+ command: "msg",
+ hmac_signed: false,
+ percent: 0,
+ bytesperminute: 0, // You need to assign a value here
+ is_new: false,
+ _id: uuid,
+ timestamp: timestamp,
+ dxcallsign: dxcallsign,
+ dxgrid: "null",
+ msg: chatmessage,
+ checksum: file_checksum,
+ type: message_type,
+ status: "transmitting",
+ attempt: 1,
+ uuid: uuid,
+ duration: 0,
+ nacks: 0,
+ speed_list: "null",
+ _attachments: {
+ [filename]: {
+ content_type: filetype,
+ data: btoa_FD(file),
+ },
+ },
+ };
sendMessage(newChatObj);
addObjToDatabase(newChatObj);
@@ -288,7 +279,9 @@ function sortChatList() {
}
reorderedData[dxcallsign].push(obj);
- reorderedData[dxcallsign] = reorderedData[dxcallsign].sort(sortByProperty("timestamp"));
+ reorderedData[dxcallsign] = reorderedData[dxcallsign].sort(
+ sortByProperty("timestamp"),
+ );
}
});
//console.log(reorderedData["2LS-0"])
@@ -296,17 +289,14 @@ function sortChatList() {
}
//https://medium.com/@asadise/sorting-a-json-array-according-one-property-in-javascript-18b1d22cd9e9
-function sortByProperty(property){
- return function(a,b){
- if(a[property] > b[property])
- return 1;
- else if(a[property] < b[property])
- return -1;
-
- return 0;
- }
-}
+function sortByProperty(property) {
+ return function (a, b) {
+ if (a[property] > b[property]) return 1;
+ else if (a[property] < b[property]) return -1;
+ return 0;
+ };
+}
export function getMessageAttachment(id) {
return new Promise(async (resolve, reject) => {
@@ -333,28 +323,29 @@ export function getMessageAttachment(id) {
});
}
-
//repeat a message
export function repeatMessageTransmission(id) {
// 1. get message object by ID
// 2. Upsert Attempts
// 3. send message
-db.find({
+ db.find({
selector: {
_id: id,
},
- }).then(function (result){
- console.log(result)
- let obj = result.docs[0]
- console.log(obj)
- obj.attempt += 1
- databaseUpsert(obj.uuid, "attempt", obj.attempt);
- updateUnsortedChatListEntry(obj.uuid, "attempt", obj.attempt);
- sendMessage(obj)
- }).catch(function (err) {
- console.log(err);
- });
+ })
+ .then(function (result) {
+ console.log(result);
+ let obj = result.docs[0];
+ console.log(obj);
+ obj.attempt += 1;
+ databaseUpsert(obj.uuid, "attempt", obj.attempt);
+ updateUnsortedChatListEntry(obj.uuid, "attempt", obj.attempt);
+ sendMessage(obj);
+ })
+ .catch(function (err) {
+ console.log(err);
+ });
}
// delete a message from databse and gui
@@ -374,7 +365,6 @@ export function deleteMessageFromDB(id) {
chat.sorted_chat_list = sortChatList();
}
-
//Function to clean old beacons and optimize database
async function dbClean() {
//Only keep the most x latest days of beacons
@@ -384,7 +374,6 @@ async function dbClean() {
(Date.now() - beaconKeep * 24 * 60 * 60 * 1000) / 1000,
);
-
//Items to purge from database
var purgeFilter = [
{ type: "beacon" },
@@ -404,7 +393,7 @@ async function dbClean() {
//console.log("Purging " + result.docs.length + " beacons received before " + timestampPurge);
itemCount = result.docs.length;
result.docs.forEach(async function (item) {
- await deleteMessageFromDB(item._id)
+ await deleteMessageFromDB(item._id);
});
})
.catch(function (err) {
@@ -415,20 +404,13 @@ async function dbClean() {
//Too slow on older/slower machines
//await db.compact();
+ let message = "Database maintenance is complete";
+ displayToast("info", "bi bi-info-circle", message, 5000);
-
- let message = "Database maintenance is complete"
- displayToast("info", "bi bi-info-circle", message, 5000);
-
- message = "Removed "+itemCount+" items from database"
- displayToast("info", "bi bi-info-circle", message, 5000);
-
-
+ message = "Removed " + itemCount + " items from database";
+ displayToast("info", "bi bi-info-circle", message, 5000);
}
-
-
-
// function to update transmission status
export function updateTransmissionStatus(obj) {
// update database entries
@@ -436,23 +418,19 @@ export function updateTransmissionStatus(obj) {
databaseUpsert(obj.uuid, "bytesperminute", obj.bytesperminute);
databaseUpsert(obj.uuid, "status", obj.status);
-
// update screen rendering / messages
updateUnsortedChatListEntry(obj.uuid, "percent", obj.percent);
updateUnsortedChatListEntry(obj.uuid, "bytesperminute", obj.bytesperminute);
updateUnsortedChatListEntry(obj.uuid, "status", obj.status);
-
}
export function updateUnsortedChatListEntry(uuid, object, value) {
-
- var data = getFromUnsortedChatListByUUID(uuid)
- if(data){
+ var data = getFromUnsortedChatListByUUID(uuid);
+ if (data) {
data[object] = value;
console.log("Entry updated:", data[object]);
chat.sorted_chat_list = sortChatList();
return data;
-
}
/*
@@ -470,43 +448,39 @@ export function updateUnsortedChatListEntry(uuid, object, value) {
return null; // Return null if not found
}
-function getFromUnsortedChatListByUUID(uuid){
- for (const entry of chat.unsorted_chat_list) {
- if (entry.uuid === uuid) {
- return entry;
- }
+function getFromUnsortedChatListByUUID(uuid) {
+ for (const entry of chat.unsorted_chat_list) {
+ if (entry.uuid === uuid) {
+ return entry;
}
- return false;
+ }
+ return false;
}
-export function getNewMessagesByDXCallsign(dxcallsign): [number, number, any]{
-let new_counter = 0
-let total_counter = 0
-let item_array = []
-if (typeof dxcallsign !== 'undefined'){
- for (const key in chat.sorted_chat_list[dxcallsign]){
- //console.log(chat.sorted_chat_list[dxcallsign][key])
- //item_array.push(chat.sorted_chat_list[dxcallsign][key])
- if(chat.sorted_chat_list[dxcallsign][key].is_new){
- item_array.push(chat.sorted_chat_list[dxcallsign][key])
- new_counter += 1
-
+export function getNewMessagesByDXCallsign(dxcallsign): [number, number, any] {
+ let new_counter = 0;
+ let total_counter = 0;
+ let item_array = [];
+ if (typeof dxcallsign !== "undefined") {
+ for (const key in chat.sorted_chat_list[dxcallsign]) {
+ //console.log(chat.sorted_chat_list[dxcallsign][key])
+ //item_array.push(chat.sorted_chat_list[dxcallsign][key])
+ if (chat.sorted_chat_list[dxcallsign][key].is_new) {
+ item_array.push(chat.sorted_chat_list[dxcallsign][key]);
+ new_counter += 1;
}
- total_counter += 1
+ total_counter += 1;
}
+ }
+
+ return [total_counter, new_counter, item_array];
}
- return [total_counter, new_counter, item_array];
+export function resetIsNewMessage(uuid, value) {
+ databaseUpsert(uuid, "is_new", value);
+ updateUnsortedChatListEntry(uuid, "is_new", value);
}
-
-export function resetIsNewMessage(uuid, value){
- databaseUpsert(uuid, "is_new", value)
- updateUnsortedChatListEntry(uuid, "is_new", value);
-}
-
-
-
export function databaseUpsert(id, object, value) {
db.upsert(id, function (doc) {
if (!doc[object]) {
@@ -527,70 +501,61 @@ export function databaseUpsert(id, object, value) {
// function for fetching all messages from chat / updating chat
export async function updateAllChat(cleanup) {
-
- // run cleanup if requested
- if (cleanup) {
- await dbClean()
- }
- let indexFields = [
- {dxcallsign: "asc"},
- {timestamp: "asc"}
- ]
+ // run cleanup if requested
+ if (cleanup) {
+ await dbClean();
+ }
+ let indexFields = [{ dxcallsign: "asc" }, { timestamp: "asc" }];
let filter = {
- selector: {
- $and: [
- { dxcallsign: { $exists: true } },
- { timestamp: { $exists: true } },
- //{ $or: chat.chat_filter },
- ],
- },
- sort: [{ dxcallsign: "asc" }, { timestamp: "asc" }],
+ selector: {
+ $and: [
+ { dxcallsign: { $exists: true } },
+ { timestamp: { $exists: true } },
+ //{ $or: chat.chat_filter },
+ ],
+ },
+ sort: [{ dxcallsign: "asc" }, { timestamp: "asc" }],
+ };
+ //"{ dxcallsign: \"asc\" }, { timestamp: \"asc\" }"
+ await createIndex(indexFields);
+ getFromDBByFilter(filter)
+ .then(function (result) {
+ for (var item of (result as any).docs) {
+ const dxcallsign = item.dxcallsign;
+ // Check if dxcallsign already exists as a property in the result object
+ if (!chat.sorted_beacon_list[dxcallsign]) {
+ // If not, initialize it with an empty array for snr values
+ chat.sorted_beacon_list[dxcallsign] = {
+ dxcallsign,
+ snr: [],
+ timestamp: [],
+ };
+ chat.callsign_list.add(dxcallsign);
}
- //"{ dxcallsign: \"asc\" }, { timestamp: \"asc\" }"
- await createIndex(indexFields);
- getFromDBByFilter(filter)
- .then(function (result) {
- for (var item of (result as any).docs) {
- const dxcallsign = item.dxcallsign;
- // Check if dxcallsign already exists as a property in the result object
- if (!chat.sorted_beacon_list[dxcallsign]) {
- // If not, initialize it with an empty array for snr values
- chat.sorted_beacon_list[dxcallsign] = {
- dxcallsign,
- snr: [],
- timestamp: [],
- };
- chat.callsign_list.add(dxcallsign);
- }
- if (item.type === "beacon") {
- //console.log(item);
+ if (item.type === "beacon") {
+ //console.log(item);
- // TODO: sort beacon list .... maybe a part for a separate function
- const jsonData = [item];
-
- // Process each JSON item step by step
- jsonData.forEach((jsonitem) => {
- const { snr, timestamp } = item;
+ // TODO: sort beacon list .... maybe a part for a separate function
+ const jsonData = [item];
- // Push the snr value to the corresponding dxcallsign's snr array
- chat.sorted_beacon_list[dxcallsign].snr.push(snr);
- chat.sorted_beacon_list[dxcallsign].timestamp.push(timestamp);
- });
- } else {
-
- chat.unsorted_chat_list.push(item);
- chat.sorted_chat_list = sortChatList();
-
- }
-
- }
-
- })
- .catch(function (err) {
- console.log(err);
- });
+ // Process each JSON item step by step
+ jsonData.forEach((jsonitem) => {
+ const { snr, timestamp } = item;
+ // Push the snr value to the corresponding dxcallsign's snr array
+ chat.sorted_beacon_list[dxcallsign].snr.push(snr);
+ chat.sorted_beacon_list[dxcallsign].timestamp.push(timestamp);
+ });
+ } else {
+ chat.unsorted_chat_list.push(item);
+ chat.sorted_chat_list = sortChatList();
+ }
+ }
+ })
+ .catch(function (err) {
+ console.log(err);
+ });
}
function addObjToDatabase(newobj) {
@@ -610,12 +575,10 @@ function addObjToDatabase(newobj) {
console.log("new database entry");
console.log(response);
-
if (newobj.command === "msg") {
chat.unsorted_chat_list.push(newobj);
chat.sorted_chat_list = sortChatList();
}
-
})
.catch(function (err) {
console.log(err);
@@ -624,11 +587,8 @@ function addObjToDatabase(newobj) {
// try upserting status in case we tried sending a message to our selfes
databaseUpsert(newobj.uuid, "status", newobj.status);
updateUnsortedChatListEntry(newobj.uuid, "status", newobj.status);
-
-
});
-
/*
// upsert footer ...
@@ -659,7 +619,7 @@ function createChatIndex() {
"is_new",
"nacks",
"duration",
- "speed_list"
+ "speed_list",
],
},
})
@@ -681,8 +641,6 @@ export function deleteChatByCallsign(callsign) {
deleteFromDatabaseByCallsign(callsign);
}
-
-
function deleteFromDatabaseByCallsign(callsign) {
db.find({
selector: {
@@ -730,18 +688,18 @@ export function newBeaconReceived(obj) {
"mycallsign": "DJ2LS-0"
}
*/
-let newChatObj: beaconDefaultObject = {
- command: "beacon",
- is_new: false,
- _id: obj["uuid"],
- timestamp: obj["timestamp"],
- dxcallsign: obj["dxcallsign"],
- dxgrid: obj["dxgrid"],
- type: "beacon",
- status: obj["beacon"],
- uuid: obj["uuid"],
- snr: obj["snr"], // adding the new field
-};
+ let newChatObj: beaconDefaultObject = {
+ command: "beacon",
+ is_new: false,
+ _id: obj["uuid"],
+ timestamp: obj["timestamp"],
+ dxcallsign: obj["dxcallsign"],
+ dxgrid: obj["dxgrid"],
+ type: "beacon",
+ status: obj["beacon"],
+ uuid: obj["uuid"],
+ snr: obj["snr"], // adding the new field
+ };
addObjToDatabase(newChatObj);
@@ -769,13 +727,11 @@ let newChatObj: beaconDefaultObject = {
});
// check if auto retry enabled
- console.log("-----------------------------------------")
- console.log(settings.enable_auto_retry.toUpperCase())
- if (settings.enable_auto_retry.toUpperCase() == "TRUE") {
+ console.log("-----------------------------------------");
+ console.log(settings.enable_auto_retry.toUpperCase());
+ if (settings.enable_auto_retry.toUpperCase() == "TRUE") {
checkForWaitingMessages(dxcallsign);
}
-
-
}
// function for handling a received message
@@ -857,33 +813,32 @@ export function newMessageReceived(message, protocol) {
*/
console.log(protocol);
-let newChatObj: messageDefaultObject = {
- command: "msg",
- hmac_signed: protocol["hmac_signed"],
- percent: 100,
- bytesperminute: protocol["bytesperminute"],
- is_new: true,
- _id: message[3],
- timestamp: message[4],
- dxcallsign: protocol["dxcallsign"],
- dxgrid: protocol["dxgrid"],
- msg: message[5],
- checksum: message[2],
- type: protocol["status"],
- status: protocol["status"],
- attempt: 1,
- uuid: message[3],
- duration: protocol["duration"],
- nacks: protocol["nacks"],
- speed_list: protocol["speed_list"],
- _attachments: {
- [message[6]]: {
- content_type: message[7],
- data: btoa_FD(message[8])
- }
- }
-};
-
+ let newChatObj: messageDefaultObject = {
+ command: "msg",
+ hmac_signed: protocol["hmac_signed"],
+ percent: 100,
+ bytesperminute: protocol["bytesperminute"],
+ is_new: true,
+ _id: message[3],
+ timestamp: message[4],
+ dxcallsign: protocol["dxcallsign"],
+ dxgrid: protocol["dxgrid"],
+ msg: message[5],
+ checksum: message[2],
+ type: protocol["status"],
+ status: protocol["status"],
+ attempt: 1,
+ uuid: message[3],
+ duration: protocol["duration"],
+ nacks: protocol["nacks"],
+ speed_list: protocol["speed_list"],
+ _attachments: {
+ [message[6]]: {
+ content_type: message[7],
+ data: btoa_FD(message[8]),
+ },
+ },
+ };
// some tweaks for broadcasts
if (protocol.fec == "broadcast") {
@@ -906,31 +861,26 @@ export function setStateSuccess() {
state.arq_seconds_until_timeout_percent = 100;
}
-export function requestMessageInfo(id){
-
-console.log(id)
-// id and uuid are the same
-var data = getFromUnsortedChatListByUUID(id)
-console.log(data)
- chat.selectedMessageObject = data
-
-
+export function requestMessageInfo(id) {
+ console.log(id);
+ // id and uuid are the same
+ var data = getFromUnsortedChatListByUUID(id);
+ console.log(data);
+ chat.selectedMessageObject = data;
}
-async function createIndex(myIndexFields)
-{
- db.createIndex({
- index: {
- fields: myIndexFields,
- },
- })
- .catch(err => {
- console.log(err);
- });
+async function createIndex(myIndexFields) {
+ db.createIndex({
+ index: {
+ fields: myIndexFields,
+ },
+ }).catch((err) => {
+ console.log(err);
+ });
}
-async function getFromDBByFilter(filter) {
-/*
+async function getFromDBByFilter(filter) {
+ /*
USAGE:
let filter = {
@@ -951,54 +901,53 @@ getFromDBByFilter(filter)
});
*/
-return new Promise((resolve, reject) => {
-return db.find(filter)
-.then(result => {
- console.log(result);
- resolve(result);
-})
-.catch(err => {
- console.log(err);
- reject(err);
-})})
+ return new Promise((resolve, reject) => {
+ return db
+ .find(filter)
+ .then((result) => {
+ console.log(result);
+ resolve(result);
+ })
+ .catch((err) => {
+ console.log(err);
+ reject(err);
+ });
+ });
}
-
-
async function checkForWaitingMessages(dxcall) {
-
-let filter = {
+ let filter = {
selector: {
dxcallsign: dxcall,
type: "transmit",
status: "failed",
//attempt: { $lt: parseInt(config.max_retry_attempts) }
},
- }
+ };
-getFromDBByFilter(filter)
- .then(result => {
- // @ts-expect-error
- let message = "Found " + result.docs.length + " waiting messages for " + dxcall
+ getFromDBByFilter(filter)
+ .then((result) => {
+ // @ts-expect-error
+ let message =
+ "Found " + result.docs.length + " waiting messages for " + dxcall;
- console.log(message);
- displayToast("info", "bi bi-info-circle", message, 5000);
+ console.log(message);
+ displayToast("info", "bi bi-info-circle", message, 5000);
// handle result
// @ts-expect-error
if (result.docs.length > 0) {
// only want to process the first available item object, then return
// this ensures, we are only sending one message at once
-// @ts-expect-error
+ // @ts-expect-error
if (result.docs[0].attempt < settings.max_retry_attempts) {
- // @ts-expect-error
- repeatMessageTransmission(result.docs[0].uuid)
+ // @ts-expect-error
+ repeatMessageTransmission(result.docs[0].uuid);
}
return;
}
-
- })
- .catch(err => {
- console.log(err)
- });
-}
\ No newline at end of file
+ })
+ .catch((err) => {
+ console.log(err);
+ });
+}
diff --git a/gui_vue/src/js/daemon.ts b/gui_vue/src/js/daemon.ts
index 6b0d0d43..b36ee729 100644
--- a/gui_vue/src/js/daemon.ts
+++ b/gui_vue/src/js/daemon.ts
@@ -116,14 +116,13 @@ daemon.on("data", function (socketdata) {
stackoverflow.com questions 9070700 nodejs-net-createserver-large-amount-of-data-coming-in
*/
- socketdata = socketchunk.join("\n") + socketdata.toString("utf8"); //append incoming data to socketchunk
- //socketdata = socketdata.toString("utf8"); // convert data to string
+ socketdata = socketchunk.join("\n") + socketdata.toString("utf8"); //append incoming data to socketchunk
+ //socketdata = socketdata.toString("utf8"); // convert data to string
//socketchunk += socketdata; // append data to buffer so we can stick long data together
// check if we received begin and end of json data
if (socketdata.startsWith('{"') && socketdata.endsWith('"}\n')) {
-
var data = "";
// split data into chunks if we received multiple commands
@@ -151,25 +150,19 @@ daemon.on("data", function (socketdata) {
}
}
- console.log(data)
+ console.log(data);
if (data["command"] == "daemon_state") {
-
// update audio devices by putting them to audio store
audioStore.inputDevices = data["input_devices"];
audioStore.outputDevices = data["output_devices"];
settings.serial_devices = data["serial_devices"];
- state.python_version = data["python_version"]
- state.modem_version = data["version"]
+ state.python_version = data["python_version"];
+ state.modem_version = data["version"];
state.modem_running_state = data["daemon_state"][0]["status"];
state.rigctld_started = data["rigctld_state"][0]["status"];
//state.rigctld_process = data["daemon_state"][0]["rigctld_process"];
-
-
}
-
-
-
if (data["command"] == "test_hamlib") {
let Data = {
hamlib_result: data["result"],
@@ -246,7 +239,8 @@ export function startModem() {
// STOP Modem
//exports.stopModem = function () {
export function stopModem() {
- var command = '{"type" : "set", "command": "stop_modem" , "parameter": "---" }';
+ var command =
+ '{"type" : "set", "command": "stop_modem" , "parameter": "---" }';
writeDaemonCommand(command);
}
@@ -289,44 +283,38 @@ function testHamlib(
}
export function startRigctld() {
-
var json_command = JSON.stringify({
type: "set",
command: "start_rigctld",
parameter: [
{
- hamlib_deviceid: settings.hamlib_deviceid,
- hamlib_deviceport: settings.hamlib_deviceport,
- hamlib_stop_bits: settings.hamlib_stop_bits,
- hamlib_data_bits: settings.hamlib_data_bits,
- hamlib_handshake: settings.hamlib_handshake,
- hamlib_serialspeed: settings.hamlib_serialspeed,
- hamlib_dtrstate: settings.hamlib_dtrstate,
- hamlib_pttprotocol: settings.hamlib_pttprotocol,
- hamlib_ptt_port: settings.hamlib_ptt_port,
- hamlib_dcd: settings.hamlib_dcd,
- hamlbib_serialspeed_ptt: settings.hamlib_serialspeed,
- hamlib_rigctld_port: settings.hamlib_rigctld_port,
- hamlib_rigctld_ip: settings.hamlib_rigctld_ip,
- hamlib_rigctld_path: settings.hamlib_rigctld_path,
- hamlib_rigctld_server_port: settings.hamlib_rigctld_server_port,
- hamlib_rigctld_custom_args: settings.hamlib_rigctld_custom_args
-
+ hamlib_deviceid: settings.hamlib_deviceid,
+ hamlib_deviceport: settings.hamlib_deviceport,
+ hamlib_stop_bits: settings.hamlib_stop_bits,
+ hamlib_data_bits: settings.hamlib_data_bits,
+ hamlib_handshake: settings.hamlib_handshake,
+ hamlib_serialspeed: settings.hamlib_serialspeed,
+ hamlib_dtrstate: settings.hamlib_dtrstate,
+ hamlib_pttprotocol: settings.hamlib_pttprotocol,
+ hamlib_ptt_port: settings.hamlib_ptt_port,
+ hamlib_dcd: settings.hamlib_dcd,
+ hamlbib_serialspeed_ptt: settings.hamlib_serialspeed,
+ hamlib_rigctld_port: settings.hamlib_rigctld_port,
+ hamlib_rigctld_ip: settings.hamlib_rigctld_ip,
+ hamlib_rigctld_path: settings.hamlib_rigctld_path,
+ hamlib_rigctld_server_port: settings.hamlib_rigctld_server_port,
+ hamlib_rigctld_custom_args: settings.hamlib_rigctld_custom_args,
},
],
});
console.log(json_command);
writeDaemonCommand(json_command);
-
}
-export function stopRigctld(){
+export function stopRigctld() {
let command = '{"type" : "set", "command": "stop_rigctld"}';
writeDaemonCommand(command);
-
}
-
-
//Save myCall
function saveMyCall(callsign) {
//exports.saveMyCall = function (callsign) {
@@ -344,5 +332,3 @@ function saveMyGrid(grid) {
'{"type" : "set", "command": "mygrid" , "parameter": "' + grid + '"}';
writeDaemonCommand(command);
}
-
-
diff --git a/gui_vue/src/js/freedata.ts b/gui_vue/src/js/freedata.ts
index 93eebe91..5e954633 100644
--- a/gui_vue/src/js/freedata.ts
+++ b/gui_vue/src/js/freedata.ts
@@ -6,24 +6,24 @@ const fs = require("fs");
* @returns base64 encoded string
*/
export function btoa_FD(data) {
-//exports.btoa_FD = function (data) {
+ //exports.btoa_FD = function (data) {
return Buffer.from(data, "utf-8").toString("base64");
-};
+}
/**
* ASCII to Binary replacement
* @param {string} data in base64 encoding
* @returns utf-8 normal/usual string
*/
export function atob_FD(data) {
-//exports.atob_FD = function (data) {
+ //exports.atob_FD = function (data) {
return Buffer.from(data, "base64").toString("utf-8");
-};
+}
/**
* UTF8 to ASCII btoa
* @param {string} data in base64 encoding
* @returns base64 bota compatible data for use in browser
*/
export function atob(data) {
-//exports.atob = function (data) {
+ //exports.atob = function (data) {
return window.btoa(Buffer.from(data, "base64").toString("utf8"));
-};
+}
diff --git a/gui_vue/src/js/settingsHandler.ts b/gui_vue/src/js/settingsHandler.ts
index a7fc7fe8..dc52011c 100644
--- a/gui_vue/src/js/settingsHandler.ts
+++ b/gui_vue/src/js/settingsHandler.ts
@@ -15,43 +15,40 @@ import { useSettingsStore } from "../store/settingsStore.js";
const settings = useSettingsStore(pinia);
// ---------------------------------
-console.log(process.env)
-if(typeof process.env["APPDATA"] !== "undefined"){
- var appDataFolder = process.env["APPDATA"]
- console.log(appDataFolder)
-
+console.log(process.env);
+if (typeof process.env["APPDATA"] !== "undefined") {
+ var appDataFolder = process.env["APPDATA"];
+ console.log(appDataFolder);
} else {
- switch (process.platform) {
- case "darwin":
- var appDataFolder = process.env["HOME"] + "/Library/Application Support";
- console.log(appDataFolder)
+ switch (process.platform) {
+ case "darwin":
+ var appDataFolder = process.env["HOME"] + "/Library/Application Support";
+ console.log(appDataFolder);
- break;
- case "linux":
- var appDataFolder = process.env["HOME"] + "/.config";
- console.log(appDataFolder)
+ break;
+ case "linux":
+ var appDataFolder = process.env["HOME"] + "/.config";
+ console.log(appDataFolder);
- break;
- case "linux":
- var appDataFolder = "undefined";
- break;
- case "win32":
- var appDataFolder = "undefined";
- break;
- default:
- var appDataFolder = "undefined";
- break;
- }
+ break;
+ case "linux":
+ var appDataFolder = "undefined";
+ break;
+ case "win32":
+ var appDataFolder = "undefined";
+ break;
+ default:
+ var appDataFolder = "undefined";
+ break;
+ }
}
-
var configFolder = path.join(appDataFolder, "FreeDATA");
var configPath = path.join(configFolder, "config.json");
-console.log(appDataFolder)
-console.log(configFolder)
-console.log(configPath)
-
+console.log(appDataFolder);
+console.log(configFolder);
+console.log(configPath);
// create config folder if not exists
if (!fs.existsSync(configFolder)) {
diff --git a/gui_vue/src/js/sock.js b/gui_vue/src/js/sock.js
index 3a0a6ba2..643e0991 100644
--- a/gui_vue/src/js/sock.js
+++ b/gui_vue/src/js/sock.js
@@ -1,11 +1,10 @@
var net = require("net");
const path = require("path");
//const FD = require("./src/js/freedata.js");
-import {atob_FD, btoa_FD} from "./freedata"
+import { atob_FD, btoa_FD } from "./freedata";
//import FD from './freedata.js';
- import {addDataToWaterfall} from "../js/waterfallHandler.js"
-
+import { addDataToWaterfall } from "../js/waterfallHandler.js";
import {
newMessageReceived,
@@ -167,7 +166,7 @@ client.on("data", function (socketdata) {
continue;
}
}
- //console.log(data)
+ //console.log(data)
if (data["command"] == "modem_state") {
//console.log(data)
// set length of RX Buffer to global variable
@@ -186,9 +185,7 @@ client.on("data", function (socketdata) {
stateStore.channel_busy = data["channel_busy"];
stateStore.channel_busy_slot = data["channel_busy_slot"];
- addDataToWaterfall(JSON.parse(data["fft"]))
-
-
+ addDataToWaterfall(JSON.parse(data["fft"]));
if (data["scatter"].length > 0) {
stateStore.scatter = data["scatter"];
@@ -253,7 +250,7 @@ client.on("data", function (socketdata) {
arq_rx_frame_n_bursts: data["arq_rx_frame_n_bursts"],
arq_rx_n_current_arq_frame: data["arq_rx_n_current_arq_frame"],
arq_n_arq_frames_per_data_frame:
- data["arq_n_arq_frames_per_data_frame"],
+ data["arq_n_arq_frames_per_data_frame"],
arq_bytes_per_minute: data["arq_bytes_per_minute"],
arq_compression_factor: data["arq_compression_factor"],
routing_table: data["routing_table"],
@@ -272,7 +269,10 @@ client.on("data", function (socketdata) {
if (data["freedata"] == "modem-message") {
// break early if we received a dummy callsign
// thats a kind of hotfix, as long as the modem isnt handling this better
- if (data["dxcallsign"] == "AA0AA-0" || data["dxcallsign"] == "ZZ9YY-0") {
+ if (
+ data["dxcallsign"] == "AA0AA-0" ||
+ data["dxcallsign"] == "ZZ9YY-0"
+ ) {
break;
}
@@ -334,7 +334,12 @@ client.on("data", function (socketdata) {
switch (data["beacon"]) {
case "transmitting":
// BEACON TRANSMITTING
- displayToast("success", "bi-broadcast-pin", "Transmitting beacon", 5000);
+ displayToast(
+ "success",
+ "bi-broadcast-pin",
+ "Transmitting beacon",
+ 5000,
+ );
break;
case "received":
@@ -357,14 +362,20 @@ client.on("data", function (socketdata) {
case "received":
// PING RECEIVED
message =
- "Ping request from " + data["dxcallsign"] + " | " + data["dxgrid"];
+ "Ping request from " +
+ data["dxcallsign"] +
+ " | " +
+ data["dxgrid"];
displayToast("success", "bi-arrow-right-short", message, 5000);
break;
case "acknowledge":
// PING ACKNOWLEDGE
message =
- "Received ping-ack from " + data["dxcallsign"] + " | " + data["dxgrid"];
+ "Received ping-ack from " +
+ data["dxcallsign"] +
+ " | " +
+ data["dxgrid"];
displayToast("success", "bi-arrow-left-right", message, 5000);
break;
}
@@ -485,7 +496,6 @@ client.on("data", function (socketdata) {
}
}
}
-
}
//finally delete message buffer
@@ -596,24 +606,22 @@ function sendFile(
// Send Message
export function sendMessage(obj) {
+ let dxcallsign = obj.dxcallsign;
+ let checksum = obj.checksum;
+ let uuid = obj.uuid;
+ let command = obj.command;
-let dxcallsign = obj.dxcallsign
-let checksum = obj.checksum
-let uuid = obj.uuid
-let command = obj.command
+ let filename = Object.keys(obj._attachments)[0];
+ //let filetype = filename.split(".")[1]
+ let filetype = obj._attachments[filename].content_type;
+ let file = obj._attachments[filename].data;
-let filename = Object.keys(obj._attachments)[0]
-//let filetype = filename.split(".")[1]
-let filetype = obj._attachments[filename].content_type
-let file = obj._attachments[filename].data
+ //console.log(obj._attachments)
+ //console.log(filename)
+ //console.log(filetype)
+ //console.log(file)
-//console.log(obj._attachments)
-//console.log(filename)
-//console.log(filetype)
-//console.log(file)
-
-
-let data_with_attachment =
+ let data_with_attachment =
obj.timestamp +
split_char +
obj.msg +
@@ -764,8 +772,7 @@ export function stopTransmission() {
export function getRxBuffer() {
var command = '{"type" : "get", "command" : "rx_buffer"}';
- writeTncCommand(command);
-
+ writeTncCommand(command);
}
// START BEACON
@@ -827,12 +834,11 @@ export function sendFecIsWriting(mycallsign) {
// SEND FEC TO BROADCASTCHANNEL
//export function sendBroadcastChannel(channel, data_out, uuid) {
export function sendBroadcastChannel(obj) {
-
let checksum = obj.checksum;
let command = obj.command;
let uuid = obj.uuid;
- let channel = obj.dxcallsign
- let data_out = obj.msg
+ let channel = obj.dxcallsign;
+ let data_out = obj.msg;
let data = btoa_FD(
"m" +
diff --git a/gui_vue/src/js/waterfallHandler.js b/gui_vue/src/js/waterfallHandler.js
index f4d8bf92..7d4aa15c 100644
--- a/gui_vue/src/js/waterfallHandler.js
+++ b/gui_vue/src/js/waterfallHandler.js
@@ -1,5 +1,4 @@
-import {Spectrum} from "../assets/waterfall/spectrum.js"
-
+import { Spectrum } from "../assets/waterfall/spectrum.js";
import { setActivePinia } from "pinia";
import pinia from "../store/index";
@@ -8,27 +7,23 @@ setActivePinia(pinia);
import { useSettingsStore } from "../store/settingsStore.js";
const settings = useSettingsStore(pinia);
+var spectrum = new Object();
+export function initWaterfall() {
+ spectrum = new Spectrum("waterfall", {
+ spectrumPercent: 0,
+ wf_rows: 192, //Assuming 1 row = 1 pixe1, 192 is the height of the spectrum container
+ });
-var spectrum = new Object
-
-export function initWaterfall(){
- spectrum = new Spectrum("waterfall", {
- spectrumPercent: 0,
- wf_rows: 192, //Assuming 1 row = 1 pixe1, 192 is the height of the spectrum container
- });
-
- console.log(settings.wftheme)
- spectrum.setColorMap(settings.wftheme);
-
+ console.log(settings.wftheme);
+ spectrum.setColorMap(settings.wftheme);
}
-export function addDataToWaterfall(data){
- //console.log(spectrum)
- try {
- spectrum.addData(data);
- } catch (e) {
- //console.log(e);
- }
-
-}
\ No newline at end of file
+export function addDataToWaterfall(data) {
+ //console.log(spectrum)
+ try {
+ spectrum.addData(data);
+ } catch (e) {
+ //console.log(e);
+ }
+}
diff --git a/gui_vue/src/main.ts b/gui_vue/src/main.ts
index 4c4cdbbf..2dae75b8 100644
--- a/gui_vue/src/main.ts
+++ b/gui_vue/src/main.ts
@@ -1,33 +1,29 @@
-import { createApp } from 'vue'
-import { createPinia } from 'pinia'
-import {loadSettings} from './js/settingsHandler'
-
-import './styles.css'
+import { createApp } from "vue";
+import { createPinia } from "pinia";
+import { loadSettings } from "./js/settingsHandler";
+import "./styles.css";
// Import all of Bootstrap's JS
//import * as bootstrap from 'bootstrap'
-import 'bootstrap/dist/js/bootstrap.bundle.min.js'
-import 'bootstrap/dist/css/bootstrap.css'
-import 'bootstrap-icons/font/bootstrap-icons.css'
-
+import "bootstrap/dist/js/bootstrap.bundle.min.js";
+import "bootstrap/dist/css/bootstrap.css";
+import "bootstrap-icons/font/bootstrap-icons.css";
// Import our custom CSS
//import './scss/styles.scss'
-
-
-import App from './App.vue'
-const app = createApp(App)
+import App from "./App.vue";
+const app = createApp(App);
//.mount('#app').$nextTick(() => postMessage({ payload: 'removeLoading' }, '*'))
-const pinia = createPinia()
-app.mount('#app')
+const pinia = createPinia();
+app.mount("#app");
-app.use(pinia)
-loadSettings()
+app.use(pinia);
+loadSettings();
//import './js/settingsHandler.js'
-import './js/daemon'
-import './js/sock.js'
+import "./js/daemon";
+import "./js/sock.js";
//import './js/settingsHandler.js'
diff --git a/gui_vue/src/store/audioStore.js b/gui_vue/src/store/audioStore.js
index 72b09612..189425ab 100644
--- a/gui_vue/src/store/audioStore.js
+++ b/gui_vue/src/store/audioStore.js
@@ -12,19 +12,17 @@ export const useAudioStore = defineStore("audioStore", () => {
var inputDevices = ref([{ id: 0, name: "no input devices" }]);
var outputDevices = ref([{ id: 0, name: "no output devices" }]);
- var startupInputDevice = ref(0)
- var startupOutputDevice = ref(0)
-
+ var startupInputDevice = ref(0);
+ var startupOutputDevice = ref(0);
function getInputDevices() {
var html = "";
for (var key in inputDevices.value) {
-
- let selected = ''
- if (inputDevices.value[key]["name"] == settings.rx_audio){
- selected = "selected"
+ let selected = "";
+ if (inputDevices.value[key]["name"] == settings.rx_audio) {
+ selected = "selected";
} else {
- selected = ''
+ selected = "";
}
html += ``;
@@ -35,17 +33,23 @@ export const useAudioStore = defineStore("audioStore", () => {
function getOutputDevices() {
var html = "";
for (var key in outputDevices.value) {
-
- let selected = ''
- if (outputDevices.value[key]["name"] == settings.tx_audio){
- selected = "selected"
+ let selected = "";
+ if (outputDevices.value[key]["name"] == settings.tx_audio) {
+ selected = "selected";
} else {
- selected = ''
+ selected = "";
}
html += ``;
}
return html;
}
- return { inputDevices, outputDevices, getInputDevices, getOutputDevices, startupInputDevice, startupOutputDevice };
+ return {
+ inputDevices,
+ outputDevices,
+ getInputDevices,
+ getOutputDevices,
+ startupInputDevice,
+ startupOutputDevice,
+ };
});
diff --git a/gui_vue/src/store/chatStore.js b/gui_vue/src/store/chatStore.js
index 2c29c49d..9be177d4 100644
--- a/gui_vue/src/store/chatStore.js
+++ b/gui_vue/src/store/chatStore.js
@@ -16,31 +16,31 @@ export const useChatStore = defineStore("chatStore", () => {
var selectedCallsign = ref();
// we need a default value in our ref because of our message info modal
var selectedMessageObject = ref({
- "command": "msg",
- "hmac_signed": false,
- "percent": 0,
- "is_new": false,
- "_id": "2ead6698",
- "timestamp": 1697289795,
- "dxcallsign": "DJ2LS-0",
- "dxgrid": "null",
- "msg": "test",
- "checksum": "",
- "type": "transmit",
- "status": "transmitting",
- "attempt": 1,
- "uuid": "2ead6698",
- "duration": 0,
- "nacks": 0,
- "speed_list": "null",
- "_attachments": {
- "": {
- "content_type": "text",
- "data": ""
- }
- }
-});
- var inputText = ref('');
+ command: "msg",
+ hmac_signed: false,
+ percent: 0,
+ is_new: false,
+ _id: "2ead6698",
+ timestamp: 1697289795,
+ dxcallsign: "DJ2LS-0",
+ dxgrid: "null",
+ msg: "test",
+ checksum: "",
+ type: "transmit",
+ status: "transmitting",
+ attempt: 1,
+ uuid: "2ead6698",
+ duration: 0,
+ nacks: 0,
+ speed_list: "null",
+ _attachments: {
+ "": {
+ content_type: "text",
+ data: "",
+ },
+ },
+ });
+ var inputText = ref("");
var inputFile = ref();
var inputFileName = ref();
var inputFileType = ref();
@@ -62,8 +62,6 @@ export const useChatStore = defineStore("chatStore", () => {
var beaconDataArray = ref([]);
var beaconLabelArray = ref([]);
-
-
return {
selectedCallsign,
selectedMessageObject,
diff --git a/gui_vue/src/store/settingsStore.js b/gui_vue/src/store/settingsStore.js
index 4559c968..00787ff2 100644
--- a/gui_vue/src/store/settingsStore.js
+++ b/gui_vue/src/store/settingsStore.js
@@ -3,8 +3,8 @@ import { ref } from "vue";
export const useSettingsStore = defineStore("settingsStore", () => {
// audio
- var tx_audio = ref()
- var rx_audio = ref()
+ var tx_audio = ref();
+ var rx_audio = ref();
// network
var modem_host = ref("127.0.0.1");
@@ -77,19 +77,19 @@ export const useSettingsStore = defineStore("settingsStore", () => {
var enable_mesh_features = ref("False");
var serial_devices = ref();
-
function getSerialDevices() {
if (this.hamlib_deviceport == "ignore")
- var html = '';
+ var html =
+ '';
else
- var html = '';
+ var html =
+ '';
for (var key in serial_devices.value) {
-
- let selected = ''
- if (serial_devices.value[key]["port"] == this. hamlib_deviceport){
- selected = "selected"
+ let selected = "";
+ if (serial_devices.value[key]["port"] == this.hamlib_deviceport) {
+ selected = "selected";
} else {
- selected = ''
+ selected = "";
}
html += ``;
@@ -223,6 +223,6 @@ export const useSettingsStore = defineStore("settingsStore", () => {
tx_audio,
rx_audio,
getSerialDevices,
- serial_devices
+ serial_devices,
};
});
diff --git a/gui_vue/src/store/stateStore.js b/gui_vue/src/store/stateStore.js
index e8a035ba..2eed16b3 100644
--- a/gui_vue/src/store/stateStore.js
+++ b/gui_vue/src/store/stateStore.js
@@ -59,24 +59,24 @@ export const useStateStore = defineStore("stateStore", () => {
var python_version = ref();
var modem_version = ref();
-
-function getChannelBusySlotState(slot){
+ function getChannelBusySlotState(slot) {
const slot_state = channel_busy_slot.value;
- if (typeof slot_state !== 'undefined') {
+ if (typeof slot_state !== "undefined") {
// Replace 'False' with 'false' to match JavaScript's boolean representation
- const string = slot_state.replace(/False/g, 'false').replace(/True/g, 'true');
+ const string = slot_state
+ .replace(/False/g, "false")
+ .replace(/True/g, "true");
// Parse the string to get an array
const arr = JSON.parse(string);
- return arr[slot]
+ return arr[slot];
} else {
// Handle the undefined case
return false;
}
-}
-
+ }
function updateTncState(state) {
modem_connection.value = state;
@@ -175,6 +175,6 @@ function getChannelBusySlotState(slot){
rigctld_started,
rigctld_process,
python_version,
- modem_version
+ modem_version,
};
});
diff --git a/gui_vue/vite.config.ts b/gui_vue/vite.config.ts
index 885f0cb4..9933d2cd 100644
--- a/gui_vue/vite.config.ts
+++ b/gui_vue/vite.config.ts
@@ -1,18 +1,18 @@
-import { rmSync } from 'node:fs'
-import { defineConfig } from 'vite'
-import vue from '@vitejs/plugin-vue'
-import electron from 'vite-plugin-electron'
-import renderer from 'vite-plugin-electron-renderer'
-import { notBundle } from 'vite-plugin-electron/plugin'
-import pkg from './package.json'
+import { rmSync } from "node:fs";
+import { defineConfig } from "vite";
+import vue from "@vitejs/plugin-vue";
+import electron from "vite-plugin-electron";
+import renderer from "vite-plugin-electron-renderer";
+import { notBundle } from "vite-plugin-electron/plugin";
+import pkg from "./package.json";
// https://vitejs.dev/config/
export default defineConfig(({ command }) => {
- rmSync('dist-electron', { recursive: true, force: true })
+ rmSync("dist-electron", { recursive: true, force: true });
- const isServe = command === 'serve'
- const isBuild = command === 'build'
- const sourcemap = isServe || !!process.env.VSCODE_DEBUG
+ const isServe = command === "serve";
+ const isBuild = command === "build";
+ const sourcemap = isServe || !!process.env.VSCODE_DEBUG;
return {
plugins: [
@@ -20,25 +20,29 @@ export default defineConfig(({ command }) => {
electron([
{
// Main process entry file of the Electron App.
- entry: 'electron/main/index.ts',
+ entry: "electron/main/index.ts",
onstart({ startup }) {
if (process.env.VSCODE_DEBUG) {
- console.log(/* For `.vscode/.debug.script.mjs` */'[startup] Electron App')
+ console.log(
+ /* For `.vscode/.debug.script.mjs` */ "[startup] Electron App",
+ );
} else {
- startup()
+ startup();
}
},
vite: {
build: {
sourcemap,
minify: isBuild,
- outDir: 'dist-electron/main',
+ outDir: "dist-electron/main",
rollupOptions: {
// Some third-party Node.js libraries may not be built correctly by Vite, especially `C/C++` addons,
// we can use `external` to exclude them to ensure they work correctly.
// Others need to put them in `dependencies` to ensure they are collected into `app.asar` after the app is built.
// Of course, this is not absolute, just this way is relatively simple. :)
- external: Object.keys('dependencies' in pkg ? pkg.dependencies : {}),
+ external: Object.keys(
+ "dependencies" in pkg ? pkg.dependencies : {},
+ ),
},
},
plugins: [
@@ -49,40 +53,42 @@ export default defineConfig(({ command }) => {
},
},
{
- entry: 'electron/preload/index.ts',
+ entry: "electron/preload/index.ts",
onstart({ reload }) {
// Notify the Renderer process to reload the page when the Preload scripts build is complete,
// instead of restarting the entire Electron App.
- reload()
+ reload();
},
vite: {
build: {
- sourcemap: sourcemap ? 'inline' : undefined, // #332
+ sourcemap: sourcemap ? "inline" : undefined, // #332
minify: isBuild,
- outDir: 'dist-electron/preload',
+ outDir: "dist-electron/preload",
rollupOptions: {
- external: Object.keys('dependencies' in pkg ? pkg.dependencies : {}),
+ external: Object.keys(
+ "dependencies" in pkg ? pkg.dependencies : {},
+ ),
},
},
- plugins: [
- isServe && notBundle(),
- ],
+ plugins: [isServe && notBundle()],
},
- }
+ },
]),
// Use Node.js API in the Renderer process
renderer(),
],
- server: process.env.VSCODE_DEBUG && (() => {
- const url = new URL(pkg.debug.env.VITE_DEV_SERVER_URL)
- return {
- host: url.hostname,
- port: +url.port,
- }
- })(),
- define: {
- 'import.meta.env.PACKAGE_VERSION':JSON.stringify(pkg.version)
- },
+ server:
+ process.env.VSCODE_DEBUG &&
+ (() => {
+ const url = new URL(pkg.debug.env.VITE_DEV_SERVER_URL);
+ return {
+ host: url.hostname,
+ port: +url.port,
+ };
+ })(),
+ define: {
+ "import.meta.env.PACKAGE_VERSION": JSON.stringify(pkg.version),
+ },
clearScreen: false,
- }
-})
+ };
+});