From 44bdad2e509c30962c79155a16e6d499bbaf3791 Mon Sep 17 00:00:00 2001 From: Iris Lightshard Date: Sun, 7 Jul 2024 11:07:18 -0600 Subject: [PATCH] clean up frontend build config --- .gitignore | 4 ++-- README.md | 16 ++++++++++++++-- build.sh | 17 +++++++++-------- {dist => frontend/dist}/index.html | 0 {dist => frontend/dist}/main.js.LICENSE.txt | 0 {dist => frontend/dist}/style.css | 0 {ts => frontend/ts}/adapter-element.ts | 0 {ts => frontend/ts}/adapter.ts | 0 {ts => frontend/ts}/index.ts | 0 {ts => frontend/ts}/message-element.ts | 0 {ts => frontend/ts}/message.ts | 0 {ts => frontend/ts}/serviceWorker.ts | 0 {ts => frontend/ts}/settings-element.ts | 0 {ts => frontend/ts}/tabbar-element.ts | 0 {ts => frontend/ts}/thread-summary-element.ts | 0 {ts => frontend/ts}/thread.ts | 0 {ts => frontend/ts}/util.ts | 0 {ts => frontend/ts}/websocket.ts | 0 server/server.go | 2 +- tsconfig.json | 4 ++-- webpack.config.js | 11 ++++++++--- 21 files changed, 36 insertions(+), 18 deletions(-) rename {dist => frontend/dist}/index.html (100%) rename {dist => frontend/dist}/main.js.LICENSE.txt (100%) rename {dist => frontend/dist}/style.css (100%) rename {ts => frontend/ts}/adapter-element.ts (100%) rename {ts => frontend/ts}/adapter.ts (100%) rename {ts => frontend/ts}/index.ts (100%) rename {ts => frontend/ts}/message-element.ts (100%) rename {ts => frontend/ts}/message.ts (100%) rename {ts => frontend/ts}/serviceWorker.ts (100%) rename {ts => frontend/ts}/settings-element.ts (100%) rename {ts => frontend/ts}/tabbar-element.ts (100%) rename {ts => frontend/ts}/thread-summary-element.ts (100%) rename {ts => frontend/ts}/thread.ts (100%) rename {ts => frontend/ts}/util.ts (100%) rename {ts => frontend/ts}/websocket.ts (100%) diff --git a/.gitignore b/.gitignore index 8376d56..74fd6a4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ node_modules/ -dist/*.js -src/ +frontend/dist/*.js +frontend/.js underbbs \ No newline at end of file diff --git a/README.md b/README.md index 5c02a36..106cac7 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,19 @@ underBBS is a platform-agnostic messaging and social media client +## design + +`underbbs` supports multiple simultaneous account logins, mediating them for each user through a gateway server that handles all protocol-specific logic via `adapter`s and streaming content to the user through a single websocket connection with a singular data interface. + +each distinct `adapter` connection/configuration is represented in the frontend as a tab, and using the websocket's event-driven javascript interface with web components we can simply either store the data or tell the currently visible adapter that it might need to respond to the new data + +adapters receive commands via a quartzgun web API and send data back on their shared websocket connection + ## building -1. `npm install` -2. `npx tsc && npx webpack` (or run `./build.sh`, it does this for you) +requirements are + +- go 1.22 +- any recent nodejs that can do `typescript` and `webpack` 5 + +run `./build.sh` from the project root. you can supply 'front' or 'server' as an argument to build only one or the other; by default it builds both \ No newline at end of file diff --git a/build.sh b/build.sh index 66b69eb..76c3fe1 100755 --- a/build.sh +++ b/build.sh @@ -2,11 +2,15 @@ case "$1" in client) - if [ ! -e ./src ]; then - mkdir ./src + if [ ! -e ./frontend/.js ]; then + mkdir ./frontend/.js fi buildlog=$(mktemp) - npx tsc 2>&1 | nobs | sed -e 's/\.ts\(/\.ts:/g' -e 's/,[0-9]+\)://g' > ${buildlog} + if [ ! -z $"{PLAN9}" ]; then + npx tsc 2>&1 | nobs | sed -e 's/\.ts\(/\.ts:/g' -e 's/,[0-9]+\)://g' > ${buildlog} + else + npx tsc 2>&1 > ${buildlog} + fi if [ -s ${buildlog} ]; then cat ${buildlog} | head rm ${buildlog} @@ -18,11 +22,8 @@ case "$1" in go mod tidy go build ;; - both) + *) $0 client $0 server ;; - *) - echo "USAGE: ${0} " - ;; -esac \ No newline at end of file +esac diff --git a/dist/index.html b/frontend/dist/index.html similarity index 100% rename from dist/index.html rename to frontend/dist/index.html diff --git a/dist/main.js.LICENSE.txt b/frontend/dist/main.js.LICENSE.txt similarity index 100% rename from dist/main.js.LICENSE.txt rename to frontend/dist/main.js.LICENSE.txt diff --git a/dist/style.css b/frontend/dist/style.css similarity index 100% rename from dist/style.css rename to frontend/dist/style.css diff --git a/ts/adapter-element.ts b/frontend/ts/adapter-element.ts similarity index 100% rename from ts/adapter-element.ts rename to frontend/ts/adapter-element.ts diff --git a/ts/adapter.ts b/frontend/ts/adapter.ts similarity index 100% rename from ts/adapter.ts rename to frontend/ts/adapter.ts diff --git a/ts/index.ts b/frontend/ts/index.ts similarity index 100% rename from ts/index.ts rename to frontend/ts/index.ts diff --git a/ts/message-element.ts b/frontend/ts/message-element.ts similarity index 100% rename from ts/message-element.ts rename to frontend/ts/message-element.ts diff --git a/ts/message.ts b/frontend/ts/message.ts similarity index 100% rename from ts/message.ts rename to frontend/ts/message.ts diff --git a/ts/serviceWorker.ts b/frontend/ts/serviceWorker.ts similarity index 100% rename from ts/serviceWorker.ts rename to frontend/ts/serviceWorker.ts diff --git a/ts/settings-element.ts b/frontend/ts/settings-element.ts similarity index 100% rename from ts/settings-element.ts rename to frontend/ts/settings-element.ts diff --git a/ts/tabbar-element.ts b/frontend/ts/tabbar-element.ts similarity index 100% rename from ts/tabbar-element.ts rename to frontend/ts/tabbar-element.ts diff --git a/ts/thread-summary-element.ts b/frontend/ts/thread-summary-element.ts similarity index 100% rename from ts/thread-summary-element.ts rename to frontend/ts/thread-summary-element.ts diff --git a/ts/thread.ts b/frontend/ts/thread.ts similarity index 100% rename from ts/thread.ts rename to frontend/ts/thread.ts diff --git a/ts/util.ts b/frontend/ts/util.ts similarity index 100% rename from ts/util.ts rename to frontend/ts/util.ts diff --git a/ts/websocket.ts b/frontend/ts/websocket.ts similarity index 100% rename from ts/websocket.ts rename to frontend/ts/websocket.ts diff --git a/server/server.go b/server/server.go index e3721bf..556e42c 100644 --- a/server/server.go +++ b/server/server.go @@ -41,7 +41,7 @@ func New() *BBSServer { } // frontend is here - srvr.serveMux.Handle("/app/", http.StripPrefix("/app/", renderer.Subtree("./dist"))) + srvr.serveMux.Handle("/app/", http.StripPrefix("/app/", renderer.Subtree("./frontend/dist"))) // api srvr.serveMux.Handle("/api/", http.StripPrefix("/api", srvr.apiMux())) diff --git a/tsconfig.json b/tsconfig.json index 743face..9e3f100 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,7 +10,7 @@ "removeComments": false, "preserveConstEnums": true, "sourceMap": false, - "outDir": "./src" + "outDir": "./frontend/.js" }, - "include": [ "./ts/*.ts"] + "include": [ "./frontend/ts/*.ts"] } diff --git a/webpack.config.js b/webpack.config.js index 0e13b0f..5695b1e 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,9 +1,14 @@ const path = require('path'); module.exports = { - context: path.resolve(__dirname, 'src'), + mode: 'production', + context: path.resolve(__dirname, 'frontend', '.js'), entry: { main: './index.js', - serviceWorker: './serviceWorker.js' + serviceWorker: './serviceWorker.js', + }, + output: { + filename: '[name].js', + path: path.resolve(__dirname, 'frontend', 'dist'), } -} \ No newline at end of file +}