various updates

This commit is contained in:
MathMan05 2024-11-26 15:28:28 -06:00
parent c9ce8c234a
commit e24afe2abe
9 changed files with 180 additions and 95 deletions

View file

@ -8,98 +8,110 @@ const plumber = require("gulp-plumber");
const sourcemaps = require('gulp-sourcemaps'); const sourcemaps = require('gulp-sourcemaps');
const fs=require("fs"); const fs=require("fs");
const swcOptions = { const swcOptions = {
jsc: { jsc: {
parser: { parser: {
syntax: "typescript", syntax: "typescript",
tsx: false, tsx: false,
decorators: true, decorators: true,
dynamicImport: true, dynamicImport: true,
},
transform: {
react: {
runtime: "automatic",
},
},
target: "es2022",
loose: false,
externalHelpers: false,
keepClassNames: true,
}, },
transform: { module: {
react: { type: "es6",
runtime: "automatic", strict: true,
}, strictMode: true,
lazy: false,
noInterop: false,
}, },
target: "es2022", sourceMaps: true,
loose: false, minify: false,
externalHelpers: false,
keepClassNames: true,
},
module: {
type: "es6",
strict: true,
strictMode: true,
lazy: false,
noInterop: false,
},
sourceMaps: true,
minify: false,
}; };
gulp.task('watch', function () {
gulp.watch('./src', gulp.series("default"));
}, {debounceDelay: 10});
// Clean task to delete the dist directory // Clean task to delete the dist directory
gulp.task("clean", (cb) => { gulp.task("clean", (cb) => {
return rimraf.rimraf("dist").then(cb()); return rimraf.rimraf("dist").then(cb());
}); });
const exec = require('child_process').exec;
// Task to compile TypeScript files using SWC // Task to compile TypeScript files using SWC
gulp.task("scripts", () => { gulp.task("scripts", async () => {
if (argv.swc) { if (argv.swc) {
return gulp return gulp
.src("src/**/*.ts") .src("src/**/*.ts")
.pipe(sourcemaps.init()) .pipe(sourcemaps.init())
.pipe(plumber()) // Prevent pipe breaking caused by errors .pipe(plumber()) // Prevent pipe breaking caused by errors
.pipe(swc(swcOptions)) .pipe(swc(swcOptions))
.pipe(sourcemaps.write('.')) .pipe(sourcemaps.write('.'))
.pipe(gulp.dest("dist")); .pipe(gulp.dest("dist"));
} else { } else if(argv.bunswc){
console.warn("[WARN] Using TSC compiler, will be slower than SWC"); return await new Promise(ret=>{
return gulp exec("bun swc ./src -s -d dist").on('exit', function (code) {
.src("src/**/*.ts") ret();
.pipe(sourcemaps.init()) });
.pipe(plumber()) // Prevent pipe breaking caused by errors })
.pipe(tsProject()) }else {
.pipe(sourcemaps.write('.')) console.warn("[WARN] Using TSC compiler, will be slower than SWC");
.pipe(gulp.dest("dist")); return gulp
} .src("src/**/*.ts")
.pipe(sourcemaps.init())
.pipe(plumber()) // Prevent pipe breaking caused by errors
.pipe(tsProject())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest("dist"));
}
}); });
// Task to copy HTML files // Task to copy HTML files
gulp.task("copy-html", () => { gulp.task("copy-html", () => {
return gulp return gulp
.src("src/**/*.html") .src("src/**/*.html")
.pipe(plumber()) // Prevent pipe breaking caused by errors .pipe(plumber()) // Prevent pipe breaking caused by errors
.pipe(gulp.dest("dist")); .pipe(gulp.dest("dist"));
}); });
gulp.task("copy-translations", () => { gulp.task("copy-translations", () => {
let langs=fs.readdirSync("translations"); let langs=fs.readdirSync("translations");
langs=langs.filter((e)=>e!=="qqq.json"); langs=langs.filter((e)=>e!=="qqq.json");
const langobj={}; const langobj={};
for(const lang of langs){ for(const lang of langs){
const json=JSON.parse(fs.readFileSync("translations/"+lang).toString()); const json=JSON.parse(fs.readFileSync("translations/"+lang).toString());
langobj[lang]=json.readableName; langobj[lang]=json.readableName;
} }
if(!fs.existsSync("dist/webpage/translations")) fs.mkdirSync("dist/webpage/translations") if(!fs.existsSync("dist/webpage/translations")) fs.mkdirSync("dist/webpage/translations")
fs.writeFileSync("dist/webpage/translations/langs.js",`const langs=${JSON.stringify(langobj)};export{langs}`); fs.writeFileSync("dist/webpage/translations/langs.js",`const langs=${JSON.stringify(langobj)};export{langs}`);
return gulp return gulp
.src("translations/*.json") .src("translations/*.json")
.pipe(plumber()) // Prevent pipe breaking caused by errors .pipe(plumber()) // Prevent pipe breaking caused by errors
.pipe(gulp.dest("dist/webpage/translations")); .pipe(gulp.dest("dist/webpage/translations"));
}); });
// Task to copy other static assets (e.g., CSS, images) // Task to copy other static assets (e.g., CSS, images)
gulp.task("copy-assets", () => { gulp.task("copy-assets", () => {
return gulp return gulp
.src([ .src([
"src/**/*.css", "src/**/*.css",
"src/**/*.bin", "src/**/*.bin",
"src/**/*.ico", "src/**/*.ico",
"src/**/*.json", "src/**/*.json",
"src/**/*.js", "src/**/*.js",
"src/**/*.png", "src/**/*.png",
"src/**/*.jpg", "src/**/*.jpg",
"src/**/*.jpeg", "src/**/*.jpeg",
"src/**/*.webp", "src/**/*.webp",
"src/**/*.gif", "src/**/*.gif",
"src/**/*.svg", "src/**/*.svg",
],{encoding:false}) ],{encoding:false})
.pipe(plumber()) // Prevent pipe breaking caused by errors .pipe(plumber()) // Prevent pipe breaking caused by errors
.pipe(gulp.dest("dist")); .pipe(gulp.dest("dist"));
@ -107,6 +119,6 @@ gulp.task("copy-assets", () => {
// Default task to run all tasks // Default task to run all tasks
gulp.task( gulp.task(
"default", "default",
gulp.series("clean", gulp.parallel("scripts", "copy-html", "copy-assets"), "copy-translations") gulp.series("clean", gulp.parallel("scripts", "copy-html", "copy-assets"), "copy-translations")
); );

View file

@ -853,6 +853,7 @@ class Channel extends SnowFlake{
//loading.classList.remove("loading"); //loading.classList.remove("loading");
(document.getElementById("typebox") as HTMLDivElement).contentEditable =""+this.canMessage; (document.getElementById("typebox") as HTMLDivElement).contentEditable =""+this.canMessage;
(document.getElementById("upload") as HTMLElement).style.visibility=this.canMessage?"visible":"hidden"; (document.getElementById("upload") as HTMLElement).style.visibility=this.canMessage?"visible":"hidden";
(document.getElementById("typediv") as HTMLElement).style.visibility="visible";
(document.getElementById("typebox") as HTMLDivElement).focus(); (document.getElementById("typebox") as HTMLDivElement).focus();
} }
typingmap: Map<Member, number> = new Map(); typingmap: Map<Member, number> = new Map();
@ -1086,10 +1087,8 @@ class Channel extends SnowFlake{
let id: string | undefined; let id: string | undefined;
if(this.lastreadmessageid && this.messages.has(this.lastreadmessageid)){ if(this.lastreadmessageid && this.messages.has(this.lastreadmessageid)){
id = this.lastreadmessageid; id = this.lastreadmessageid;
}else if( }else if(this.lastreadmessageid && (id = this.findClosest(this.lastreadmessageid))){
this.lastreadmessageid &&
(id = this.findClosest(this.lastreadmessageid))
){
}else if(this.lastmessageid && this.messages.has(this.lastmessageid)){ }else if(this.lastmessageid && this.messages.has(this.lastmessageid)){
id = this.goBackIds(this.lastmessageid, 50); id = this.goBackIds(this.lastmessageid, 50);
} }
@ -1098,7 +1097,7 @@ class Channel extends SnowFlake{
const title = document.createElement("h2"); const title = document.createElement("h2");
title.id = "removetitle"; title.id = "removetitle";
title.textContent = I18n.getTranslation("noMessages"); title.textContent = I18n.getTranslation("noMessages");
title.classList.add("titlespace"); title.classList.add("titlespace","messagecontainer");
messages.append(title); messages.append(title);
} }
this.infinitefocus = false; this.infinitefocus = false;

View file

@ -3,12 +3,7 @@ import{ Channel }from"./channel.js";
import{ Message }from"./message.js"; import{ Message }from"./message.js";
import{ Localuser }from"./localuser.js"; import{ Localuser }from"./localuser.js";
import{ User }from"./user.js"; import{ User }from"./user.js";
import{ import{channeljson,dirrectjson,memberjson,messagejson}from"./jsontypes.js";
channeljson,
dirrectjson,
memberjson,
messagejson,
}from"./jsontypes.js";
import{ Permissions }from"./permissions.js"; import{ Permissions }from"./permissions.js";
import{ SnowFlake }from"./snowflake.js"; import{ SnowFlake }from"./snowflake.js";
import{ Contextmenu }from"./contextmenu.js"; import{ Contextmenu }from"./contextmenu.js";
@ -23,9 +18,6 @@ class Direct extends Guild{
super(-1, owner, null); super(-1, owner, null);
this.message_notifications = 0; this.message_notifications = 0;
this.owner = owner; this.owner = owner;
if(!this.localuser){
console.error("Owner was not included, please fix");
}
this.headers = this.localuser.headers; this.headers = this.localuser.headers;
this.channels = []; this.channels = [];
this.channelids = {}; this.channelids = {};
@ -58,6 +50,25 @@ class Direct extends Guild{
channel.del(); channel.del();
} }
} }
getHTML(){
const ddiv=document.createElement("div");
const build=super.getHTML();
const freindDiv=document.createElement("div");
freindDiv.classList.add("liststyle","flexltr","friendsbutton");
const icon=document.createElement("span");
icon.classList.add("svgicon","svg-friends","space");
freindDiv.append(icon);
freindDiv.append("Friends");
ddiv.append(freindDiv);
freindDiv.onclick=()=>{
this.loadChannel(null);
}
ddiv.append(build);
return ddiv;
}
giveMember(_member: memberjson){ giveMember(_member: memberjson){
console.error("not a real guild, can't give member object"); console.error("not a real guild, can't give member object");
} }
@ -200,6 +211,7 @@ class Group extends Channel{
this.buildmessages(); this.buildmessages();
(document.getElementById("typebox") as HTMLDivElement).contentEditable ="" + true; (document.getElementById("typebox") as HTMLDivElement).contentEditable ="" + true;
(document.getElementById("upload") as HTMLElement).style.visibility="visible"; (document.getElementById("upload") as HTMLElement).style.visibility="visible";
(document.getElementById("typediv") as HTMLElement).style.visibility="visible";
(document.getElementById("typebox") as HTMLDivElement).focus(); (document.getElementById("typebox") as HTMLDivElement).focus();
} }
messageCreate(messagep: { d: messagejson }){ messageCreate(messagep: { d: messagejson }){

View file

@ -577,7 +577,7 @@ class Guild extends SnowFlake{
} }
return this.member.hasRole(r); return this.member.hasRole(r);
} }
loadChannel(ID?: string | undefined,addstate=true){ loadChannel(ID?: string | undefined| null,addstate=true){
if(ID){ if(ID){
const channel = this.localuser.channelids.get(ID); const channel = this.localuser.channelids.get(ID);
if(channel){ if(channel){
@ -585,17 +585,63 @@ class Guild extends SnowFlake{
return; return;
} }
} }
if(this.prevchannel){ if(this.prevchannel&&ID!==null){
console.log(this.prevchannel); console.log(this.prevchannel);
this.prevchannel.getHTML(addstate); this.prevchannel.getHTML(addstate);
return; return;
} }
for(const thing of this.channels){ if(this.id!=="@me"){
if(thing.children.length === 0){ for(const thing of this.channels){
thing.getHTML(addstate); if(thing.type!==4){
return; thing.getHTML(addstate);
return;
}
} }
} }
this.removePrevChannel();
this.noChannel(addstate);
}
removePrevChannel(){
if(this.localuser.channelfocus){
this.localuser.channelfocus.infinite.delete();
}
if(this !== this.localuser.lookingguild){
this.loadGuild();
}
if(this.localuser.channelfocus && this.localuser.channelfocus.myhtml){
this.localuser.channelfocus.myhtml.classList.remove("viewChannel");
}
this.prevchannel = undefined;
this.localuser.channelfocus = undefined;
const replybox = document.getElementById("replybox") as HTMLElement;
const typebox = document.getElementById("typebox") as HTMLElement;
replybox.classList.add("hideReplyBox");
typebox.classList.remove("typeboxreplying");
(document.getElementById("typebox") as HTMLDivElement).contentEditable ="false";
(document.getElementById("upload") as HTMLElement).style.visibility="hidden";
(document.getElementById("typediv") as HTMLElement).style.visibility="hidden";
(document.getElementById("sideDiv") as HTMLElement).innerHTML="";
}
noChannel(addstate:boolean){
if(addstate){
history.pushState([this.id,undefined], "", "/channels/" + this.id);
}
this.localuser.pageTitle("Weird spot");
const channelTopic = document.getElementById("channelTopic") as HTMLSpanElement;
channelTopic.setAttribute("hidden", "");
const loading = document.getElementById("loadingdiv") as HTMLDivElement;
loading.classList.remove("loading");
this.localuser.getSidePannel();
const messages = document.getElementById("channelw") as HTMLDivElement;
for(const thing of Array.from(messages.getElementsByClassName("messagecontainer"))){
thing.remove();
}
const h1=document.createElement("h1");
h1.classList.add("messagecontainer")
h1.textContent="You're in a weird spot, this guild has no channels";
messages.append(h1);
} }
loadGuild(){ loadGuild(){
this.localuser.loadGuild(this.id); this.localuser.loadGuild(this.id);
@ -703,7 +749,9 @@ class Guild extends SnowFlake{
if(indexy !== -1){ if(indexy !== -1){
this.headchannels.splice(indexy, 1); this.headchannels.splice(indexy, 1);
} }
if(channel===this.prevchannel){
this.prevchannel=undefined;
}
/* /*
const build=[]; const build=[];
for(const thing of this.channels){ for(const thing of this.channels){

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 180 180"><g fill="red"><circle cx="53.7" cy="52.5" r="16.8"/><path d="m94 179.7.5-57.4A40 40 0 0 0 54.8 82a40 40 0 0 0-40.3 39.6l-.5 58h40z"/><circle cx="116.3" cy="32.9" r="16.8"/><path d="M117.4 62.3A40 40 0 0 0 81.2 85a45 45 0 0 1 19.5 37.5l-.5 57.3h56a40 40 0 0 0 .2-2.4l.6-74.6a40 40 0 0 0-39.6-40.4Z"/></g></svg>

After

Width:  |  Height:  |  Size: 371 B

View file

@ -64,7 +64,7 @@
<span id="channelTopic" class="ellipsis" hidden>Channel topic</span> <span id="channelTopic" class="ellipsis" hidden>Channel topic</span>
</span> </span>
<label for="memberlisttoggle" id="memberlisttoggleicon"> <label for="memberlisttoggle" id="memberlisttoggleicon">
<span class="svgicon svg-channel"></span> <span class="svgicon svg-friends"></span>
</label> </label>
<input type="checkbox" id="memberlisttoggle" checked> <input type="checkbox" id="memberlisttoggle" checked>
</div> </div>

View file

@ -5,7 +5,6 @@ import{ MarkDown }from"./markdown.js";
import{ Message }from"./message.js"; import{ Message }from"./message.js";
import{File}from"./file.js"; import{File}from"./file.js";
import { I18n } from "./i18n.js"; import { I18n } from "./i18n.js";
(async ()=>{ (async ()=>{
await I18n.done await I18n.done
const users = getBulkUsers(); const users = getBulkUsers();

View file

@ -794,8 +794,7 @@ class Localuser{
guild.html.classList.add("serveropen"); guild.html.classList.add("serveropen");
} }
this.lookingguild = guild; this.lookingguild = guild;
(document.getElementById("serverName") as HTMLElement).textContent = (document.getElementById("serverName") as HTMLElement).textContent = guild.properties.name;
guild.properties.name;
//console.log(this.guildids,id) //console.log(this.guildids,id)
const channels = document.getElementById("channels") as HTMLDivElement; const channels = document.getElementById("channels") as HTMLDivElement;
channels.innerHTML = ""; channels.innerHTML = "";

View file

@ -248,12 +248,18 @@ textarea {
} }
.svg-upload { .svg-upload {
mask: url(/icons/upload.svg); mask: url(/icons/upload.svg);
width: .2in !important;!i;!; width: .2in !important;
cursor: pointer; cursor: pointer;
} }
.svg-x { .svg-x {
mask: url(/icons/x.svg); mask: url(/icons/x.svg);
} }
.svg-friends{
mask: url(/icons/friends.svg);
width: 24px !important;!i;!;
height: 24px !important;!i;!;
margin-right: 0 !important;!i;!;
}
.svgicon { .svgicon {
display: block; display: block;
height: 100%; height: 100%;
@ -328,6 +334,10 @@ textarea {
::-webkit-scrollbar-thumb:hover { ::-webkit-scrollbar-thumb:hover {
background: var(--primary-text-soft); background: var(--primary-text-soft);
} }
#sideDiv:empty{
width:0px;
padding:0;
}
#servers::-webkit-scrollbar, #channels::-webkit-scrollbar, #sideDiv::-webkit-scrollbar { #servers::-webkit-scrollbar, #channels::-webkit-scrollbar, #sideDiv::-webkit-scrollbar {
display: none; display: none;
} }
@ -2054,6 +2064,11 @@ fieldset input[type="radio"] {
} }
} }
.friendsbutton{
transition: background-color .2s;
background-color: #00000050;
padding: .08in;
}
.bigemoji{ .bigemoji{
width:.6in; width:.6in;
} }