diff --git a/.vscode/settings.json b/.vscode/settings.json index 25117cc..4a841f7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,3 @@ { - "github-enterprise.uri": "https://git.creations.works" + "github-enterprise.uri": "https://git.creations.works" } diff --git a/biome.json b/biome.json new file mode 100644 index 0000000..3c4d4f1 --- /dev/null +++ b/biome.json @@ -0,0 +1,35 @@ +{ + "$schema": "https://biomejs.dev/schemas/1.9.4/schema.json", + "vcs": { + "enabled": true, + "clientKind": "git", + "useIgnoreFile": false + }, + "files": { + "ignoreUnknown": false, + "ignore": [] + }, + "formatter": { + "enabled": true, + "indentStyle": "tab", + "lineEnding": "lf" + }, + "organizeImports": { + "enabled": true + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true + } + }, + "javascript": { + "formatter": { + "quoteStyle": "double", + "indentStyle": "tab", + "lineEnding": "lf", + "jsxQuoteStyle": "double", + "semicolons": "always" + } + } +} diff --git a/config/environment.ts b/config/environment.ts index c584b45..239d2c3 100644 --- a/config/environment.ts +++ b/config/environment.ts @@ -1,9 +1,8 @@ export const environment: Environment = { - port: parseInt(process.env.PORT || "8080", 10), + port: Number.parseInt(process.env.PORT || "8080", 10), host: process.env.HOST || "0.0.0.0", development: - process.env.NODE_ENV === "development" || - process.argv.includes("--dev"), + process.env.NODE_ENV === "development" || process.argv.includes("--dev"), }; export const lanyardConfig: LanyardConfig = { diff --git a/eslint.config.js b/eslint.config.js deleted file mode 100644 index d43df76..0000000 --- a/eslint.config.js +++ /dev/null @@ -1,132 +0,0 @@ -import pluginJs from "@eslint/js"; -import tseslintPlugin from "@typescript-eslint/eslint-plugin"; -import tsParser from "@typescript-eslint/parser"; -import prettier from "eslint-plugin-prettier"; -import promisePlugin from "eslint-plugin-promise"; -import simpleImportSort from "eslint-plugin-simple-import-sort"; -import unicorn from "eslint-plugin-unicorn"; -import unusedImports from "eslint-plugin-unused-imports"; -import globals from "globals"; - -/** @type {import('eslint').Linter.FlatConfig[]} */ -export default [ - { - files: ["**/*.{js,mjs,cjs}"], - languageOptions: { - globals: globals.node, - }, - ...pluginJs.configs.recommended, - plugins: { - "simple-import-sort": simpleImportSort, - "unused-imports": unusedImports, - promise: promisePlugin, - prettier: prettier, - unicorn: unicorn, - }, - rules: { - "eol-last": ["error", "always"], - "no-multiple-empty-lines": ["error", { max: 1, maxEOF: 1 }], - "no-mixed-spaces-and-tabs": ["error", "smart-tabs"], - "simple-import-sort/imports": "error", - "simple-import-sort/exports": "error", - "unused-imports/no-unused-imports": "error", - "unused-imports/no-unused-vars": [ - "warn", - { - vars: "all", - varsIgnorePattern: "^_", - args: "after-used", - argsIgnorePattern: "^_", - }, - ], - "promise/always-return": "error", - "promise/no-return-wrap": "error", - "promise/param-names": "error", - "promise/catch-or-return": "error", - "promise/no-nesting": "warn", - "promise/no-promise-in-callback": "warn", - "promise/no-callback-in-promise": "warn", - "prettier/prettier": [ - "error", - { - useTabs: true, - tabWidth: 4, - }, - ], - indent: ["error", "tab", { SwitchCase: 1 }], - "unicorn/filename-case": [ - "error", - { - case: "camelCase", - }, - ], - }, - }, - { - files: ["**/*.{ts,tsx}"], - languageOptions: { - parser: tsParser, - globals: globals.node, - }, - plugins: { - "@typescript-eslint": tseslintPlugin, - "simple-import-sort": simpleImportSort, - "unused-imports": unusedImports, - promise: promisePlugin, - prettier: prettier, - unicorn: unicorn, - }, - rules: { - ...tseslintPlugin.configs.recommended.rules, - quotes: ["error", "double"], - "eol-last": ["error", "always"], - "no-multiple-empty-lines": ["error", { max: 1, maxEOF: 1 }], - "no-mixed-spaces-and-tabs": ["error", "smart-tabs"], - "simple-import-sort/imports": "error", - "simple-import-sort/exports": "error", - "unused-imports/no-unused-imports": "error", - "unused-imports/no-unused-vars": [ - "warn", - { - vars: "all", - varsIgnorePattern: "^_", - args: "after-used", - argsIgnorePattern: "^_", - }, - ], - "promise/always-return": "error", - "promise/no-return-wrap": "error", - "promise/param-names": "error", - "promise/catch-or-return": "error", - "promise/no-nesting": "warn", - "promise/no-promise-in-callback": "warn", - "promise/no-callback-in-promise": "warn", - "prettier/prettier": [ - "error", - { - useTabs: true, - tabWidth: 4, - }, - ], - indent: ["error", "tab", { SwitchCase: 1 }], - "unicorn/filename-case": [ - "error", - { - case: "camelCase", - }, - ], - "@typescript-eslint/explicit-function-return-type": ["error"], - "@typescript-eslint/explicit-module-boundary-types": ["error"], - "@typescript-eslint/typedef": [ - "error", - { - arrowParameter: true, - variableDeclaration: true, - propertyDeclaration: true, - memberVariableDeclaration: true, - parameter: true, - }, - ], - }, - }, -]; diff --git a/package.json b/package.json index 8d6e543..793fe71 100644 --- a/package.json +++ b/package.json @@ -5,24 +5,15 @@ "scripts": { "start": "bun run src/index.ts", "dev": "bun run --hot src/index.ts --dev", - "lint": "eslint", - "lint:fix": "bun lint --fix", + "lint": "bunx biome check", + "lint:fix": "bunx biome check --fix", "cleanup": "rm -rf logs node_modules bun.lockdb" }, "devDependencies": { - "@eslint/js": "^9.24.0", + "@biomejs/biome": "^1.9.4", "@types/bun": "^1.2.8", "@types/ejs": "^3.1.5", - "@typescript-eslint/eslint-plugin": "^8.29.0", - "@typescript-eslint/parser": "^8.29.0", - "eslint": "^9.24.0", - "eslint-plugin-prettier": "^5.2.6", - "eslint-plugin-promise": "^7.2.1", - "eslint-plugin-simple-import-sort": "^12.1.1", - "eslint-plugin-unicorn": "^58.0.0", - "eslint-plugin-unused-imports": "^4.1.4", - "globals": "^16.0.0", - "prettier": "^3.5.3" + "globals": "^16.0.0" }, "peerDependencies": { "typescript": "^5.8.3" diff --git a/public/css/error.css b/public/css/error.css index a8e591d..65dce6b 100644 --- a/public/css/error.css +++ b/public/css/error.css @@ -12,7 +12,7 @@ body { padding: 2rem; background: #1a1a1d; border-radius: 12px; - box-shadow: 0 0 20px rgba(0,0,0,0.3); + box-shadow: 0 0 20px rgba(0, 0, 0, 0.3); } .error-title { font-size: 2rem; diff --git a/public/css/index.css b/public/css/index.css index e4acc03..7a1a288 100644 --- a/public/css/index.css +++ b/public/css/index.css @@ -1,7 +1,38 @@ +:root { + --background: #0e0e10; + --card-bg: #1e1f22; + --card-hover-bg: #2a2a2d; + --border-color: #2e2e30; + + --text-color: #ffffff; + --text-subtle: #bbb; + --text-secondary: #b5bac1; + --text-muted: #888; + --link-color: #00b0f4; + + --status-online: #23a55a; + --status-idle: #f0b232; + --status-dnd: #e03e3e; + --status-offline: #747f8d; + --status-streaming: #b700ff; + + --progress-bg: #f23f43; + --progress-fill: #5865f2; + + --button-bg: #5865f2; + --button-hover-bg: #4752c4; + --button-disabled-bg: #2d2e31; + + --blockquote-color: #aaa; + --code-bg: #2e2e30; + + --readme-bg: #1a1a1d; +} + body { font-family: system-ui, sans-serif; - background-color: #0e0e10; - color: #ffffff; + background-color: var(--background); + color: var(--text-color); margin: 0; padding: 2rem; display: flex; @@ -52,26 +83,30 @@ body { width: 24px; height: 24px; border-radius: 50%; - border: 4px solid #0e0e10; + border: 4px solid var(--background); display: flex; align-items: center; justify-content: center; } .status-indicator.online { - background-color: #23a55a; + background-color: var(--status-online); } .status-indicator.idle { - background-color: #f0b232; + background-color: var(--status-idle); } .status-indicator.dnd { - background-color: #f23f43; + background-color: var(--status-dnd); } .status-indicator.offline { - background-color: #747f8d; + background-color: var(--status-offline); +} + +.status-indicator.streaming { + background-color: var(--status-streaming); } .platform-icon.mobile-only { @@ -91,12 +126,12 @@ body { h1 { font-size: 2.5rem; margin: 0; - color: #00b0f4; + color: var(--link-color); } .custom-status { font-size: 1.2rem; - color: #bbb; + color: var(--text-subtle); margin-top: 0.25rem; word-break: break-word; overflow-wrap: anywhere; @@ -107,7 +142,6 @@ h1 { flex-wrap: wrap; } - .custom-status .custom-emoji { width: 20px; height: 20px; @@ -142,14 +176,14 @@ ul { display: flex; flex-direction: row; gap: 1rem; - background-color: #1e1f22; + background-color: var(--card-bg); padding: 0.75rem 1rem; border-radius: 10px; - box-shadow: 0 1px 0 0 #2e2e30; + border: 1px solid var(--border-color); } .activity:hover { - background: #2a2a2d; + background: var(--card-hover-bg); } .activity-wrapper { @@ -164,7 +198,28 @@ ul { gap: 1rem; } -.activity-art { +.activity-image-wrapper { + position: relative; + width: 80px; + height: 80px; +} + +.activity-image-small { + width: 25px; + height: 25px; + border-radius: 50%; + object-fit: cover; + flex-shrink: 0; + border-color: var(--card-bg); + border-width: 2px; + border-style: solid; + + position: absolute; + bottom: -6px; + right: -10px; +} + +.activity-image { width: 80px; height: 80px; border-radius: 6px; @@ -202,17 +257,17 @@ ul { .activity-name { font-weight: 600; font-size: 1rem; - color: #fff; + color: var(--text-color); } .activity-detail { font-size: 0.875rem; - color: #b5bac1; + color: var(--text-secondary); } .activity-timestamp { font-size: 0.75rem; - color: #b5bac1; + color: var(--text-secondary); text-align: right; margin-left: auto; white-space: nowrap; @@ -220,14 +275,14 @@ ul { .progress-bar { height: 4px; - background-color: #2e2e30; + background-color: var(--border-color); border-radius: 2px; - margin-top: 0.5rem; + margin-top: 1rem; overflow: hidden; } .progress-fill { - background-color: #5865f2; + background-color: var(--progress-fill); transition: width 0.4s ease; height: 100%; } @@ -235,14 +290,13 @@ ul { .progress-bar, .progress-time-labels { width: 100%; - margin-top: 0.5rem; } .progress-time-labels { display: flex; justify-content: space-between; font-size: 0.75rem; - color: #888; + color: var(--text-muted); margin-top: 0.25rem; } @@ -256,7 +310,7 @@ ul { font-size: 0.75rem; text-transform: uppercase; font-weight: 600; - color: #aaa; + color: var(--blockquote-color); margin-bottom: 0.50rem; display: block; } @@ -267,7 +321,7 @@ ul { .progress-time-labels.paused .progress-current::after { content: " ⏸"; - color: #f0b232; + color: var(--status-idle); } .activity-buttons { @@ -278,7 +332,7 @@ ul { } .activity-button { - background-color: #5865f2; + background-color: var(--progress-fill); color: white; border: none; border-radius: 3px; @@ -291,12 +345,12 @@ ul { } .activity-button:hover { - background-color: #4752c4; + background-color: var(--button-hover-bg); text-decoration: none; } .activity-button:disabled { - background-color: #2d2e31; + background-color: var(--button-disabled-bg); cursor: not-allowed; opacity: 0.8; } @@ -325,6 +379,13 @@ ul { width: 100%; } + .activity-image-wrapper { + max-width: 100%; + max-height: 100%; + width: 100%; + height: 100%; + } + .avatar-wrapper { width: 96px; height: 96px; @@ -379,21 +440,31 @@ ul { align-items: center; text-align: center; padding: 1rem; - border-radius:0; + border-radius: 0; } - .activity-art { + .activity-image { width: 100%; - max-width: 300px; + max-width: 100%; height: auto; border-radius: 8px; } + .activity-image-small { + width: 40px; + height: 40px; + } + .activity-content { width: 100%; align-items: center; } + .activity-wrapper-inner { + flex-direction: column; + align-items: center; + } + .activity-header { flex-direction: column; align-items: center; @@ -430,12 +501,12 @@ ul { /* readme :p */ .readme { - max-width: 600px; + max-width: 700px; width: 100%; - background: #1a1a1d; + background: var(--readme-bg); padding: 1.5rem; border-radius: 8px; - box-shadow: 0 0 0 1px #2e2e30; + border: 1px solid var(--border-color); margin-top: 2rem; @@ -446,13 +517,13 @@ ul { .readme h2 { margin-top: 0; - color: #00b0f4; + color: var(--link-color); } .markdown-body { font-size: 1rem; line-height: 1.6; - color: #ddd; + color: var(--text-color); } .markdown-body h1, @@ -461,7 +532,7 @@ ul { .markdown-body h4, .markdown-body h5, .markdown-body h6 { - color: #ffffff; + color: var(--text-color); margin-top: 1.25rem; margin-bottom: 0.5rem; } @@ -471,7 +542,7 @@ ul { } .markdown-body a { - color: #00b0f4; + color: var(--link-color); text-decoration: none; } @@ -480,7 +551,7 @@ ul { } .markdown-body code { - background: #2e2e30; + background: var(--border-color); padding: 0.2em 0.4em; border-radius: 4px; font-family: monospace; @@ -488,7 +559,7 @@ ul { } .markdown-body pre { - background: #2e2e30; + background: var(--border-color); padding: 1rem; border-radius: 6px; overflow-x: auto; @@ -503,9 +574,9 @@ ul { } .markdown-body blockquote { - border-left: 4px solid #00b0f4; + border-left: 4px solid var(--link-color); padding-left: 1rem; - color: #aaa; + color: var(--blockquote-color); margin: 1rem 0; } diff --git a/public/js/index.js b/public/js/index.js index 35dbe32..e6a9afe 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -1,5 +1,3 @@ -/* eslint-disable indent */ - const activityProgressMap = new Map(); function formatTime(ms) { @@ -23,19 +21,19 @@ function formatVerbose(ms) { function updateElapsedAndProgress() { const now = Date.now(); - document.querySelectorAll(".activity-timestamp").forEach((el) => { + for (const el of document.querySelectorAll(".activity-timestamp")) { const start = Number(el.dataset.start); - if (!start) return; + if (!start) continue; const elapsed = now - start; const display = el.querySelector(".elapsed"); if (display) display.textContent = `(${formatVerbose(elapsed)} ago)`; - }); + } - document.querySelectorAll(".progress-bar").forEach((bar) => { + for (const bar of document.querySelectorAll(".progress-bar")) { const start = Number(bar.dataset.start); const end = Number(bar.dataset.end); - if (!start || !end || end <= start) return; + if (!start || !end || end <= start) continue; const duration = end - start; const elapsed = Math.min(now - start, duration); @@ -46,12 +44,12 @@ function updateElapsedAndProgress() { const fill = bar.querySelector(".progress-fill"); if (fill) fill.style.width = `${progress}%`; - }); + } - document.querySelectorAll(".progress-time-labels").forEach((label) => { + for (const label of document.querySelectorAll(".progress-time-labels")) { const start = Number(label.dataset.start); const end = Number(label.dataset.end); - if (!start || !end || end <= start) return; + if (!start || !end || end <= start) continue; const isPaused = now > end; const current = isPaused ? end - start : Math.max(0, now - start); @@ -77,14 +75,14 @@ function updateElapsedAndProgress() { : formatTime(current); } if (totalEl) totalEl.textContent = formatTime(total); - }); + } } updateElapsedAndProgress(); setInterval(updateElapsedAndProgress, 1000); const head = document.querySelector("head"); -let userId = head?.dataset.userId; +const userId = head?.dataset.userId; let instanceUri = head?.dataset.instanceUri; if (userId && instanceUri) { @@ -132,6 +130,25 @@ if (userId && instanceUri) { }); } +function resolveActivityImage(img, applicationId) { + if (!img) return null; + + if (img.startsWith("mp:external/")) { + return `https://media.discordapp.net/external/${img.slice("mp:external/".length)}`; + } + + if (img.includes("/https/")) { + const clean = img.split("/https/")[1]; + return clean ? `https://${clean}` : null; + } + + if (img.startsWith("spotify:")) { + return `https://i.scdn.co/image/${img.split(":")[1]}`; + } + + return `https://cdn.discordapp.com/app-assets/${applicationId}/${img}.png`; +} + function buildActivityHTML(activity) { const start = activity.timestamps?.start; const end = activity.timestamps?.end; @@ -143,18 +160,18 @@ function buildActivityHTML(activity) { ? Math.min(100, Math.floor((elapsed / total) * 100)) : null; - const img = activity.assets?.large_image; let art = null; + let smallArt = null; - if (img?.startsWith("mp:external/")) { - art = `https://media.discordapp.net/external/${img.slice("mp:external/".length)}`; - } else if (img?.includes("/https/")) { - const clean = img.split("/https/")[1]; - if (clean) art = `https://${clean}`; - } else if (img?.startsWith("spotify:")) { - art = `https://i.scdn.co/image/${img.split(":")[1]}`; - } else if (img) { - art = `https://cdn.discordapp.com/app-assets/${activity.application_id}/${img}.png`; + if (activity.assets) { + art = resolveActivityImage( + activity.assets.large_image, + activity.application_id, + ); + smallArt = resolveActivityImage( + activity.assets.small_image, + activity.application_id, + ); } const activityTypeMap = { @@ -189,10 +206,7 @@ function buildActivityHTML(activity) { ? `