adjusted build process and made freedata imports working

This commit is contained in:
DJ2LS 2023-10-08 09:57:03 +02:00
parent 3a4de02569
commit 1f8d0800ba
6 changed files with 99 additions and 37 deletions

View file

@ -11,8 +11,28 @@
}, },
"files": [ "files": [
"dist", "dist",
"dist-electron" "dist-electron",
"src/**/*",
"node_modules/**/*",
{
from: 'src',
to: 'dist'
}
], ],
"extraResources": [
{
"from": "src",
"to": "testfolder",
"filter": [
"**/*",
"!**/.git"
]
}
],
"mac": { "mac": {
"target": [ "target": [
"dmg" "dmg"
@ -41,18 +61,5 @@
"AppImage" "AppImage"
], ],
"artifactName": "${productName}-${version}.${ext}" "artifactName": "${productName}-${version}.${ext}"
}, }
"files": [
"**/*",
"!**/*.ts",
"!*.map",
"!package.json",
"!package-lock.json",
{
"from": "../dist",
"filter": [
"**/*"
]
},
]
} }

View file

@ -35,17 +35,35 @@ function useLoading() {
const className = `loaders-css__square-spin` const className = `loaders-css__square-spin`
const styleContent = ` const styleContent = `
@keyframes square-spin { @keyframes square-spin {
25% { transform: perspective(100px) rotateX(180deg) rotateY(0); } 0% {
50% { transform: perspective(100px) rotateX(180deg) rotateY(180deg); } transform: rotate(0deg);
75% { transform: perspective(100px) rotateX(0) rotateY(180deg); } background-image: url('/icon_cube_border.png'); /* Replace with the URL of your image */
100% { transform: perspective(100px) rotateX(0) rotateY(0); } background-size: cover; /* Scale the image to cover the entire container */
}
25% { transform: perspective(100px) rotateX(180deg) rotateY(0);
background-image: url('/icon_cube_border.png'); /* Replace with the URL of your image */
background-size: cover; /* Scale the image to cover the entire container */
}
50% { transform: perspective(100px) rotateX(180deg) rotateY(180deg);
background-image: url('/icon_cube_border.png'); /* Replace with the URL of your image */
background-size: cover; /* Scale the image to cover the entire container */
}
75% { transform: perspective(100px) rotateX(0) rotateY(180deg);
background-image: url('/icon_cube_border.png'); /* Replace with the URL of your image */
background-size: cover; /* Scale the image to cover the entire container */
}
100% { transform: perspective(100px) rotateX(0) rotateY(0);
background-image: url('/icon_cube_border.png'); /* Replace with the URL of your image */
background-size: cover; /* Scale the image to cover the entire container */
}
} }
.${className} > div { .${className} > div {
animation-fill-mode: both; animation-fill-mode: both;
width: 50px; width: 50px;
height: 50px; height: 50px;
background: #fff; background: #fff;
animation: square-spin 3s 0s cubic-bezier(0.09, 0.57, 0.49, 0.9) infinite; animation: square-spin 6s 0s cubic-bezier(0.09, 0.57, 0.49, 0.9) infinite;
} }
.app-loading-wrap { .app-loading-wrap {
position: fixed; position: fixed;
@ -57,7 +75,7 @@ function useLoading() {
align-items: center; align-items: center;
justify-content: center; justify-content: center;
background: #282c34; background: #282c34;
z-index: 9; z-index: 99999;
} }
` `
const oStyle = document.createElement('style') const oStyle = document.createElement('style')

View file

@ -12,3 +12,31 @@
<script type="module" src="/src/main.ts"></script> <script type="module" src="/src/main.ts"></script>
</body> </body>
</html> </html>
<script type="module">
// debugging code for figuring out correct folder structure in build environment
console.log(process.env)
import { readdir } from 'node:fs/promises';
import { readdirSync } from 'fs'
import { join } from 'path'
function walk(dir) {
return readdirSync(dir, { withFileTypes: true }).flatMap((file) => file.isDirectory() ? walk(join(dir, file.name)) : join(dir, file.name))
}
if (process.env["NODE_ENV"] == "production"){
console.log(walk(process.env["APPDIR"]))
console.log(walk(process.env["DIST"]))
console.log(walk(process.env["DIST_ELECTRON"]))
} else {
console.log("running in " + process.env["NODE_ENV"])
}
</script>

View file

@ -13,7 +13,10 @@ const chat = useChatStore(pinia);
import { sendMessage } from "./sock.js"; import { sendMessage } from "./sock.js";
const FD = require("./src/js/freedata.js");
//const FD = require("./src/js/freedata.js");
import {btoa_FD} from "./freedata.js"
// split character // split character
const split_char = "0;1;"; const split_char = "0;1;";
@ -118,7 +121,7 @@ export function newBroadcast(broadcastChannel, chatmessage) {
newChatObj._attachments = { newChatObj._attachments = {
[filename]: { [filename]: {
content_type: filetype, content_type: filetype,
data: FD.btoa_FD(file), data: btoa_FD(file),
}, },
}; };
@ -197,7 +200,7 @@ export function newMessage(
newChatObj._attachments = { newChatObj._attachments = {
[filename]: { [filename]: {
content_type: filetype, content_type: filetype,
data: FD.btoa_FD(file), data: btoa_FD(file),
}, },
}; };
@ -592,7 +595,7 @@ export function newMessageReceived(message, protocol) {
newChatObj._attachments = { newChatObj._attachments = {
[message[6]]: { [message[6]]: {
content_type: message[7], content_type: message[7],
data: FD.btoa_FD(message[8]), data: btoa_FD(message[8]),
}, },
}; };

View file

@ -5,7 +5,8 @@ const fs = require("fs");
* @param {string} data in normal/usual utf-8 format * @param {string} data in normal/usual utf-8 format
* @returns base64 encoded string * @returns base64 encoded string
*/ */
exports.btoa_FD = function (data) { export function btoa_FD(data) {
//exports.btoa_FD = function (data) {
return Buffer.from(data, "utf-8").toString("base64"); return Buffer.from(data, "utf-8").toString("base64");
}; };
/** /**
@ -13,7 +14,8 @@ exports.btoa_FD = function (data) {
* @param {string} data in base64 encoding * @param {string} data in base64 encoding
* @returns utf-8 normal/usual string * @returns utf-8 normal/usual string
*/ */
exports.atob_FD = function (data) { export function atob_FD(data) {
//exports.atob_FD = function (data) {
return Buffer.from(data, "base64").toString("utf-8"); return Buffer.from(data, "base64").toString("utf-8");
}; };
/** /**
@ -21,6 +23,7 @@ exports.atob_FD = function (data) {
* @param {string} data in base64 encoding * @param {string} data in base64 encoding
* @returns base64 bota compatible data for use in browser * @returns base64 bota compatible data for use in browser
*/ */
exports.atob = function (data) { export function atob(data) {
//exports.atob = function (data) {
return window.btoa(Buffer.from(data, "base64").toString("utf8")); return window.btoa(Buffer.from(data, "base64").toString("utf8"));
}; };

View file

@ -1,7 +1,10 @@
var net = require("net"); var net = require("net");
const path = require("path"); const path = require("path");
const FD = require("./src/js/freedata.js"); //const FD = require("./src/js/freedata.js");
import {atob_FD, btoa_FD} from "./freedata.js"
//import FD from './freedata.js'; //import FD from './freedata.js';
import { import {
newMessageReceived, newMessageReceived,
newBeaconReceived, newBeaconReceived,
@ -276,7 +279,7 @@ client.on("data", function (socketdata) {
case "broadcast": case "broadcast":
// RX'd FEC BROADCAST // RX'd FEC BROADCAST
var encoded_data = FD.atob_FD(data["data"]); var encoded_data = atob_FD(data["data"]);
var splitted_data = encoded_data.split(split_char); var splitted_data = encoded_data.split(split_char);
var messageArray = []; var messageArray = [];
if (splitted_data[0] == "m") { if (splitted_data[0] == "m") {
@ -449,7 +452,7 @@ client.on("data", function (socketdata) {
console.log(data); console.log(data);
// we need to encode here to do a deep check for checking if file or message // we need to encode here to do a deep check for checking if file or message
//var encoded_data = atob(data['data']) //var encoded_data = atob(data['data'])
var encoded_data = FD.atob_FD(data["data"]); var encoded_data = atob_FD(data["data"]);
var splitted_data = encoded_data.split(split_char); var splitted_data = encoded_data.split(split_char);
// new message received // new message received
@ -490,7 +493,7 @@ client.on("data", function (socketdata) {
try { try {
// we need to encode here to do a deep check for checking if file or message // we need to encode here to do a deep check for checking if file or message
//var encoded_data = atob(data['data-array'][i]['data']) //var encoded_data = atob(data['data-array'][i]['data'])
var encoded_data = FD.atob_FD(data["data-array"][i]["data"]); var encoded_data = atob_FD(data["data-array"][i]["data"]);
var splitted_data = encoded_data.split(split_char); var splitted_data = encoded_data.split(split_char);
if (splitted_data[0] == "m") { if (splitted_data[0] == "m") {
@ -600,7 +603,7 @@ function sendFile(
//Btoa / atob will not work with charsets > 8 bits (i.e. the emojis); should probably move away from using it //Btoa / atob will not work with charsets > 8 bits (i.e. the emojis); should probably move away from using it
//TODO: Will need to update anyother occurences and throughly test //TODO: Will need to update anyother occurences and throughly test
//data = btoa(data) //data = btoa(data)
data = FD.btoa_FD(data); data = btoa_FD(data);
command = command =
'{"type" : "arq", "command" : "send_raw", "parameter" : [{"dxcallsign" : "' + '{"type" : "arq", "command" : "send_raw", "parameter" : [{"dxcallsign" : "' +
@ -617,7 +620,7 @@ function sendFile(
// Send Message // Send Message
export function sendMessage(dxcallsign, data, checksum, uuid, command) { export function sendMessage(dxcallsign, data, checksum, uuid, command) {
data = FD.btoa_FD( data = btoa_FD(
"m" + "m" +
split_char + split_char +
command + command +
@ -652,7 +655,7 @@ export function sendMessage(dxcallsign, data, checksum, uuid, command) {
// Send Request message // Send Request message
//It would be then „m + split + request + split + request-type“ //It would be then „m + split + request + split + request-type“
function sendRequest(dxcallsign, mode, frames, data, command) { function sendRequest(dxcallsign, mode, frames, data, command) {
data = FD.btoa_FD("m" + split_char + command + split_char + data); data = btoa_FD("m" + split_char + command + split_char + data);
command = command =
'{"type" : "arq", "command" : "send_raw", "parameter" : [{"dxcallsign" : "' + '{"type" : "arq", "command" : "send_raw", "parameter" : [{"dxcallsign" : "' +
dxcallsign + dxcallsign +
@ -671,7 +674,7 @@ function sendRequest(dxcallsign, mode, frames, data, command) {
// Send Response message // Send Response message
//It would be then „m + split + request + split + request-type“ //It would be then „m + split + request + split + request-type“
function sendResponse(dxcallsign, mode, frames, data, command) { function sendResponse(dxcallsign, mode, frames, data, command) {
data = FD.btoa_FD("m" + split_char + command + split_char + data); data = btoa_FD("m" + split_char + command + split_char + data);
command = command =
'{"type" : "arq", "command" : "send_raw", "parameter" : [{"dxcallsign" : "' + '{"type" : "arq", "command" : "send_raw", "parameter" : [{"dxcallsign" : "' +
dxcallsign + dxcallsign +
@ -823,7 +826,7 @@ export function sendFecIsWriting(mycallsign) {
export function sendBroadcastChannel(channel, data_out, uuid) { export function sendBroadcastChannel(channel, data_out, uuid) {
let checksum = ""; let checksum = "";
let command = ""; let command = "";
let data = FD.btoa_FD( let data = btoa_FD(
"m" + "m" +
split_char + split_char +
channel + channel +