Compare commits
1 commit
Author | SHA1 | Date | |
---|---|---|---|
02f3092fcb |
23 changed files with 497 additions and 855 deletions
|
@ -1,24 +0,0 @@
|
|||
name: Code quality checks
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
biome:
|
||||
runs-on: docker
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Bun
|
||||
run: |
|
||||
curl -fsSL https://bun.sh/install | bash
|
||||
export BUN_INSTALL="$HOME/.bun"
|
||||
echo "$BUN_INSTALL/bin" >> $GITHUB_PATH
|
||||
|
||||
- name: Install Dependencies
|
||||
run: bun install
|
||||
|
||||
- name: Run Biome with verbose output
|
||||
run: bunx biome ci . --verbose
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"github-enterprise.uri": "https://git.creations.works"
|
||||
"github-enterprise.uri": "https://git.creations.works"
|
||||
}
|
||||
|
|
35
biome.json
35
biome.json
|
@ -1,35 +0,0 @@
|
|||
{
|
||||
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
|
||||
"vcs": {
|
||||
"enabled": true,
|
||||
"clientKind": "git",
|
||||
"useIgnoreFile": false
|
||||
},
|
||||
"files": {
|
||||
"ignoreUnknown": true,
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,9 @@
|
|||
export const environment: Environment = {
|
||||
port: Number.parseInt(process.env.PORT || "8080", 10),
|
||||
port: 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 = {
|
||||
|
|
132
eslint.config.js
Normal file
132
eslint.config.js
Normal file
|
@ -0,0 +1,132 @@
|
|||
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,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
];
|
22
package.json
22
package.json
|
@ -5,23 +5,31 @@
|
|||
"scripts": {
|
||||
"start": "bun run src/index.ts",
|
||||
"dev": "bun run --hot src/index.ts --dev",
|
||||
"lint": "bunx biome check",
|
||||
"lint:fix": "bunx biome check --fix",
|
||||
"lint": "eslint",
|
||||
"lint:fix": "bun lint --fix",
|
||||
"cleanup": "rm -rf logs node_modules bun.lockdb"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "^1.9.4",
|
||||
"@eslint/js": "^9.24.0",
|
||||
"@types/bun": "^1.2.8",
|
||||
"@types/ejs": "^3.1.5",
|
||||
"globals": "^16.0.0"
|
||||
"@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": "^56.0.1",
|
||||
"eslint-plugin-unused-imports": "^4.1.4",
|
||||
"globals": "^15.15.0",
|
||||
"prettier": "^3.5.3"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "^5.8.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"ejs": "^3.1.10",
|
||||
"isomorphic-dompurify": "^2.23.0",
|
||||
"marked": "^15.0.7",
|
||||
"node-vibrant": "^4.0.3"
|
||||
"node-vibrant": "^4.0.3",
|
||||
"marked": "^15.0.7"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,38 +1,7 @@
|
|||
: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: var(--background);
|
||||
color: var(--text-color);
|
||||
background-color: #0e0e10;
|
||||
color: #ffffff;
|
||||
margin: 0;
|
||||
padding: 2rem;
|
||||
display: flex;
|
||||
|
@ -40,30 +9,6 @@ body {
|
|||
align-items: center;
|
||||
}
|
||||
|
||||
.snowflake {
|
||||
position: absolute;
|
||||
background-color: white;
|
||||
border-radius: 50%;
|
||||
pointer-events: none;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.raindrop {
|
||||
position: absolute;
|
||||
background-color: white;
|
||||
border-radius: 50%;
|
||||
pointer-events: none;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.activity-header.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.user-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
@ -107,30 +52,26 @@ body {
|
|||
width: 24px;
|
||||
height: 24px;
|
||||
border-radius: 50%;
|
||||
border: 4px solid var(--background);
|
||||
border: 4px solid #0e0e10;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.status-indicator.online {
|
||||
background-color: var(--status-online);
|
||||
background-color: #23a55a;
|
||||
}
|
||||
|
||||
.status-indicator.idle {
|
||||
background-color: var(--status-idle);
|
||||
background-color: #f0b232;
|
||||
}
|
||||
|
||||
.status-indicator.dnd {
|
||||
background-color: var(--status-dnd);
|
||||
background-color: #f23f43;
|
||||
}
|
||||
|
||||
.status-indicator.offline {
|
||||
background-color: var(--status-offline);
|
||||
}
|
||||
|
||||
.status-indicator.streaming {
|
||||
background-color: var(--status-streaming);
|
||||
background-color: #747f8d;
|
||||
}
|
||||
|
||||
.platform-icon.mobile-only {
|
||||
|
@ -150,12 +91,12 @@ body {
|
|||
h1 {
|
||||
font-size: 2.5rem;
|
||||
margin: 0;
|
||||
color: var(--link-color);
|
||||
color: #00b0f4;
|
||||
}
|
||||
|
||||
.custom-status {
|
||||
font-size: 1.2rem;
|
||||
color: var(--text-subtle);
|
||||
color: #bbb;
|
||||
margin-top: 0.25rem;
|
||||
word-break: break-word;
|
||||
overflow-wrap: anywhere;
|
||||
|
@ -166,6 +107,7 @@ h1 {
|
|||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
|
||||
.custom-status .custom-emoji {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
|
@ -200,50 +142,19 @@ ul {
|
|||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 1rem;
|
||||
background-color: var(--card-bg);
|
||||
padding: 0.75rem 1rem;
|
||||
border-radius: 10px;
|
||||
border: 1px solid var(--border-color);
|
||||
background: #1a1a1d;
|
||||
padding: 1rem;
|
||||
border-radius: 6px;
|
||||
box-shadow: 0 0 0 1px #2e2e30;
|
||||
transition: background 0.2s ease;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.activity:hover {
|
||||
background: var(--card-hover-bg);
|
||||
background: #2a2a2d;
|
||||
}
|
||||
|
||||
.activity-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.activity-wrapper-inner {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.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 {
|
||||
.activity-art {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
border-radius: 6px;
|
||||
|
@ -254,15 +165,7 @@ ul {
|
|||
.activity-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
flex: 1;
|
||||
gap: 0.5rem;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.activity-top {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
|
@ -272,91 +175,64 @@ ul {
|
|||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.activity-bottom {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.activity-name {
|
||||
font-weight: 600;
|
||||
font-size: 1rem;
|
||||
color: var(--text-color);
|
||||
font-weight: bold;
|
||||
font-size: 1.1rem;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.activity-detail {
|
||||
font-size: 0.875rem;
|
||||
color: var(--text-secondary);
|
||||
font-size: 0.95rem;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.activity-timestamp {
|
||||
font-size: 0.75rem;
|
||||
color: var(--text-secondary);
|
||||
font-size: 0.8rem;
|
||||
color: #777;
|
||||
text-align: right;
|
||||
margin-left: auto;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.progress-bar {
|
||||
height: 4px;
|
||||
background-color: var(--border-color);
|
||||
border-radius: 2px;
|
||||
margin-top: 1rem;
|
||||
height: 6px;
|
||||
background-color: #333;
|
||||
border-radius: 3px;
|
||||
overflow: hidden;
|
||||
width: 100%;
|
||||
margin-top: 0.5rem;
|
||||
}
|
||||
|
||||
.progress-fill {
|
||||
background-color: var(--progress-fill);
|
||||
transition: width 0.4s ease;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.progress-bar,
|
||||
.progress-time-labels {
|
||||
width: 100%;
|
||||
background-color: #00b0f4;
|
||||
transition: width 0.5s ease;
|
||||
}
|
||||
|
||||
.progress-time-labels {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
font-size: 0.75rem;
|
||||
color: var(--text-muted);
|
||||
color: #888;
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
|
||||
.activity-type-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.activity-type-label {
|
||||
font-size: 0.75rem;
|
||||
text-transform: uppercase;
|
||||
font-weight: 600;
|
||||
color: var(--blockquote-color);
|
||||
margin-bottom: 0.50rem;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.activity-header.no-timestamp {
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.progress-time-labels.paused .progress-current::after {
|
||||
content: " ⏸";
|
||||
color: var(--status-idle);
|
||||
color: #f0b232;
|
||||
}
|
||||
|
||||
.activity-buttons {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
margin-top: 0.75rem;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.activity-button {
|
||||
background-color: var(--progress-fill);
|
||||
background-color: #5865f2;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 3px;
|
||||
|
@ -369,13 +245,14 @@ ul {
|
|||
}
|
||||
|
||||
.activity-button:hover {
|
||||
background-color: var(--button-hover-bg);
|
||||
background-color: #4752c4;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.activity-button:disabled {
|
||||
background-color: var(--button-disabled-bg);
|
||||
cursor: not-allowed;
|
||||
.activity-button.disabled {
|
||||
background-color: #4e5058;
|
||||
cursor: default;
|
||||
pointer-events: none;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
|
@ -403,13 +280,6 @@ ul {
|
|||
width: 100%;
|
||||
}
|
||||
|
||||
.activity-image-wrapper {
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.avatar-wrapper {
|
||||
width: 96px;
|
||||
height: 96px;
|
||||
|
@ -464,31 +334,21 @@ ul {
|
|||
align-items: center;
|
||||
text-align: center;
|
||||
padding: 1rem;
|
||||
border-radius: 0;
|
||||
border-radius:0;
|
||||
}
|
||||
|
||||
.activity-image {
|
||||
.activity-art {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
max-width: 300px;
|
||||
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;
|
||||
|
@ -525,14 +385,12 @@ ul {
|
|||
|
||||
/* readme :p */
|
||||
.readme {
|
||||
max-width: 700px;
|
||||
max-width: 600px;
|
||||
width: 100%;
|
||||
background: var(--readme-bg);
|
||||
background: #1a1a1d;
|
||||
padding: 1.5rem;
|
||||
border-radius: 8px;
|
||||
border: 1px solid var(--border-color);
|
||||
|
||||
margin-top: 2rem;
|
||||
box-shadow: 0 0 0 1px #2e2e30;
|
||||
|
||||
box-sizing: border-box;
|
||||
overflow: hidden;
|
||||
|
@ -541,13 +399,13 @@ ul {
|
|||
|
||||
.readme h2 {
|
||||
margin-top: 0;
|
||||
color: var(--link-color);
|
||||
color: #00b0f4;
|
||||
}
|
||||
|
||||
.markdown-body {
|
||||
font-size: 1rem;
|
||||
line-height: 1.6;
|
||||
color: var(--text-color);
|
||||
color: #ddd;
|
||||
}
|
||||
|
||||
.markdown-body h1,
|
||||
|
@ -556,7 +414,7 @@ ul {
|
|||
.markdown-body h4,
|
||||
.markdown-body h5,
|
||||
.markdown-body h6 {
|
||||
color: var(--text-color);
|
||||
color: #ffffff;
|
||||
margin-top: 1.25rem;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
@ -566,7 +424,7 @@ ul {
|
|||
}
|
||||
|
||||
.markdown-body a {
|
||||
color: var(--link-color);
|
||||
color: #00b0f4;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
|
@ -575,7 +433,7 @@ ul {
|
|||
}
|
||||
|
||||
.markdown-body code {
|
||||
background: var(--border-color);
|
||||
background: #2e2e30;
|
||||
padding: 0.2em 0.4em;
|
||||
border-radius: 4px;
|
||||
font-family: monospace;
|
||||
|
@ -583,7 +441,7 @@ ul {
|
|||
}
|
||||
|
||||
.markdown-body pre {
|
||||
background: var(--border-color);
|
||||
background: #2e2e30;
|
||||
padding: 1rem;
|
||||
border-radius: 6px;
|
||||
overflow-x: auto;
|
||||
|
@ -598,9 +456,9 @@ ul {
|
|||
}
|
||||
|
||||
.markdown-body blockquote {
|
||||
border-left: 4px solid var(--link-color);
|
||||
border-left: 4px solid #00b0f4;
|
||||
padding-left: 1rem;
|
||||
color: var(--blockquote-color);
|
||||
color: #aaa;
|
||||
margin: 1rem 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,42 +1,36 @@
|
|||
/* eslint-disable indent */
|
||||
|
||||
const activityProgressMap = new Map();
|
||||
|
||||
function formatTime(ms) {
|
||||
const totalSecs = Math.floor(ms / 1000);
|
||||
const hours = Math.floor(totalSecs / 3600);
|
||||
const mins = Math.floor((totalSecs % 3600) / 60);
|
||||
const mins = Math.floor(totalSecs / 60);
|
||||
const secs = totalSecs % 60;
|
||||
|
||||
return `${String(hours).padStart(1, "0")}:${String(mins).padStart(2, "0")}:${String(secs).padStart(2, "0")}`;
|
||||
}
|
||||
|
||||
function formatVerbose(ms) {
|
||||
const totalSecs = Math.floor(ms / 1000);
|
||||
const hours = Math.floor(totalSecs / 3600);
|
||||
const mins = Math.floor((totalSecs % 3600) / 60);
|
||||
const secs = totalSecs % 60;
|
||||
|
||||
return `${hours}h ${mins}m ${secs}s`;
|
||||
return `${mins}:${secs.toString().padStart(2, "0")}`;
|
||||
}
|
||||
|
||||
function updateElapsedAndProgress() {
|
||||
const now = Date.now();
|
||||
|
||||
for (const el of document.querySelectorAll(".activity-timestamp")) {
|
||||
document.querySelectorAll(".activity-timestamp").forEach((el) => {
|
||||
const start = Number(el.dataset.start);
|
||||
if (!start) continue;
|
||||
if (!start) return;
|
||||
|
||||
const elapsed = now - start;
|
||||
const mins = Math.floor(elapsed / 60000);
|
||||
const secs = Math.floor((elapsed % 60000) / 1000);
|
||||
const display = el.querySelector(".elapsed");
|
||||
if (display) display.textContent = `(${formatVerbose(elapsed)} ago)`;
|
||||
}
|
||||
if (display)
|
||||
display.textContent = `(${mins}m ${secs.toString().padStart(2, "0")}s ago)`;
|
||||
});
|
||||
|
||||
for (const bar of document.querySelectorAll(".progress-bar")) {
|
||||
document.querySelectorAll(".progress-bar").forEach((bar) => {
|
||||
const start = Number(bar.dataset.start);
|
||||
const end = Number(bar.dataset.end);
|
||||
if (!start || !end || end <= start) continue;
|
||||
if (!start || !end || end <= start) return;
|
||||
|
||||
const duration = end - start;
|
||||
const elapsed = Math.min(now - start, duration);
|
||||
const elapsed = now - start;
|
||||
const progress = Math.min(
|
||||
100,
|
||||
Math.max(0, Math.floor((elapsed / duration) * 100)),
|
||||
|
@ -44,15 +38,14 @@ function updateElapsedAndProgress() {
|
|||
|
||||
const fill = bar.querySelector(".progress-fill");
|
||||
if (fill) fill.style.width = `${progress}%`;
|
||||
}
|
||||
});
|
||||
|
||||
for (const label of document.querySelectorAll(".progress-time-labels")) {
|
||||
document.querySelectorAll(".progress-time-labels").forEach((label) => {
|
||||
const start = Number(label.dataset.start);
|
||||
const end = Number(label.dataset.end);
|
||||
if (!start || !end || end <= start) continue;
|
||||
if (!start || !end || end <= start) return;
|
||||
|
||||
const isPaused = now > end;
|
||||
const current = isPaused ? end - start : Math.max(0, now - start);
|
||||
const current = Math.max(0, now - start);
|
||||
const total = end - start;
|
||||
|
||||
const currentEl = label.querySelector(".progress-current");
|
||||
|
@ -61,7 +54,7 @@ function updateElapsedAndProgress() {
|
|||
const id = `${start}-${end}`;
|
||||
const last = activityProgressMap.get(id);
|
||||
|
||||
if (isPaused || (last !== undefined && last === current)) {
|
||||
if (last !== undefined && last === current) {
|
||||
label.classList.add("paused");
|
||||
} else {
|
||||
label.classList.remove("paused");
|
||||
|
@ -69,20 +62,16 @@ function updateElapsedAndProgress() {
|
|||
|
||||
activityProgressMap.set(id, current);
|
||||
|
||||
if (currentEl) {
|
||||
currentEl.textContent = isPaused
|
||||
? `Paused at ${formatTime(current)}`
|
||||
: formatTime(current);
|
||||
}
|
||||
if (currentEl) currentEl.textContent = formatTime(current);
|
||||
if (totalEl) totalEl.textContent = formatTime(total);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
updateElapsedAndProgress();
|
||||
setInterval(updateElapsedAndProgress, 1000);
|
||||
|
||||
const head = document.querySelector("head");
|
||||
const userId = head?.dataset.userId;
|
||||
let userId = head?.dataset.userId;
|
||||
let instanceUri = head?.dataset.instanceUri;
|
||||
|
||||
if (userId && instanceUri) {
|
||||
|
@ -97,56 +86,25 @@ if (userId && instanceUri) {
|
|||
|
||||
const socket = new WebSocket(`${wsUri}/socket`);
|
||||
|
||||
let heartbeatInterval = null;
|
||||
|
||||
socket.addEventListener("open", () => {});
|
||||
socket.addEventListener("open", () => {
|
||||
socket.send(
|
||||
JSON.stringify({
|
||||
op: 2,
|
||||
d: {
|
||||
subscribe_to_id: userId,
|
||||
},
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
socket.addEventListener("message", (event) => {
|
||||
const payload = JSON.parse(event.data);
|
||||
|
||||
if (payload.op === 1 && payload.d?.heartbeat_interval) {
|
||||
heartbeatInterval = setInterval(() => {
|
||||
socket.send(JSON.stringify({ op: 3 }));
|
||||
}, payload.d.heartbeat_interval);
|
||||
|
||||
socket.send(
|
||||
JSON.stringify({
|
||||
op: 2,
|
||||
d: {
|
||||
subscribe_to_id: userId,
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
if (payload.t === "INIT_STATE" || payload.t === "PRESENCE_UPDATE") {
|
||||
updatePresence(payload.d);
|
||||
requestAnimationFrame(() => updateElapsedAndProgress());
|
||||
updateElapsedAndProgress();
|
||||
}
|
||||
});
|
||||
|
||||
socket.addEventListener("close", () => {
|
||||
if (heartbeatInterval) clearInterval(heartbeatInterval);
|
||||
});
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -160,116 +118,75 @@ 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 (activity.assets) {
|
||||
art = resolveActivityImage(
|
||||
activity.assets.large_image,
|
||||
activity.application_id,
|
||||
);
|
||||
smallArt = resolveActivityImage(
|
||||
activity.assets.small_image,
|
||||
activity.application_id,
|
||||
);
|
||||
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`;
|
||||
}
|
||||
|
||||
const activityTypeMap = {
|
||||
0: "Playing",
|
||||
1: "Streaming",
|
||||
2: "Listening",
|
||||
3: "Watching",
|
||||
4: "Custom Status",
|
||||
5: "Competing",
|
||||
};
|
||||
|
||||
const activityType =
|
||||
activity.name === "Spotify"
|
||||
? "Listening to Spotify"
|
||||
: activity.name === "TIDAL"
|
||||
? "Listening to TIDAL"
|
||||
: activityTypeMap[activity.type] || "Playing";
|
||||
|
||||
const activityTimestamp =
|
||||
start && progress === null
|
||||
? `<div class="activity-timestamp" data-start="${start}">
|
||||
<span>Since: ${new Date(start).toLocaleTimeString("en-GB", {
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
second: "2-digit",
|
||||
})} <span class="elapsed"></span></span>
|
||||
</div>`
|
||||
: "";
|
||||
|
||||
const activityButtons =
|
||||
activity.buttons && activity.buttons.length > 0
|
||||
? `<div class="activity-buttons">
|
||||
${activity.buttons
|
||||
.map((button, index) => {
|
||||
const label = typeof button === "string" ? button : button.label;
|
||||
let url = null;
|
||||
if (typeof button === "object" && button.url) {
|
||||
url = button.url;
|
||||
} else if (index === 0 && activity.url) {
|
||||
url = activity.url;
|
||||
}
|
||||
return url
|
||||
? `<a href="${url}" class="activity-button" target="_blank" rel="noopener noreferrer">${label}</a>`
|
||||
: null;
|
||||
})
|
||||
.filter(Boolean)
|
||||
.join("")}
|
||||
</div>`
|
||||
!total && start
|
||||
? `
|
||||
<div class="activity-timestamp" data-start="${start}">
|
||||
<span>
|
||||
Since: ${new Date(start).toLocaleTimeString("en-GB", {
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
second: "2-digit",
|
||||
})} <span class="elapsed"></span>
|
||||
</span>
|
||||
</div>`
|
||||
: "";
|
||||
|
||||
const progressBar =
|
||||
progress !== null
|
||||
? `<div class="progress-bar" data-start="${start}" data-end="${end}">
|
||||
? `
|
||||
<div class="progress-bar" data-start="${start}" data-end="${end}">
|
||||
<div class="progress-fill" style="width: ${progress}%"></div>
|
||||
</div>
|
||||
<div class="progress-time-labels" data-start="${start}" data-end="${end}">
|
||||
<span class="progress-current">${formatTime(elapsed)}</span>
|
||||
<span class="progress-total">${formatTime(total)}</span>
|
||||
</div>`
|
||||
</div>
|
||||
`
|
||||
: "";
|
||||
|
||||
const isMusic = activity.type === 2 || activity.type === 3;
|
||||
|
||||
const primaryLine = isMusic ? activity.details : activity.name;
|
||||
const secondaryLine = isMusic ? activity.state : activity.details;
|
||||
const tertiaryLine = isMusic ? activity.assets?.large_text : activity.state;
|
||||
|
||||
const activityArt = art
|
||||
? `<div class="activity-image-wrapper">
|
||||
<img class="activity-image" src="${art}" alt="Art" ${activity.assets?.large_text ? `title="${activity.assets.large_text}"` : ""}>
|
||||
${smallArt ? `<img class="activity-image-small" src="${smallArt}" alt="Small Art" ${activity.assets?.small_text ? `title="${activity.assets.small_text}"` : ""}>` : ""}
|
||||
</div>`
|
||||
: "";
|
||||
const activityButtons = activity.buttons && activity.buttons.length > 0
|
||||
? `<div class="activity-buttons">
|
||||
${activity.buttons.map((button, index) => {
|
||||
const buttonLabel = typeof button === 'string' ? button : button.label;
|
||||
let buttonUrl = null;
|
||||
if (typeof button === 'object' && button.url) {
|
||||
buttonUrl = button.url;
|
||||
}
|
||||
else if (index === 0 && activity.url) {
|
||||
buttonUrl = activity.url;
|
||||
}
|
||||
if (buttonUrl) {
|
||||
return `<a href="${buttonUrl}" class="activity-button" target="_blank" rel="noopener noreferrer">${buttonLabel}</a>`;
|
||||
} else {
|
||||
return `<span class="activity-button disabled">${buttonLabel}</span>`;
|
||||
}
|
||||
}).join('')}
|
||||
</div>`
|
||||
: '';
|
||||
|
||||
return `
|
||||
<li class="activity">
|
||||
<div class="activity-wrapper">
|
||||
<div class="activity-type-wrapper">
|
||||
<span class="activity-type-label" data-type="${activity.type}">${activityType}</span>
|
||||
${art ? `<img class="activity-art" src="${art}" alt="Art">` : ""}
|
||||
<div class="activity-content">
|
||||
<div class="activity-header ${progress !== null ? "no-timestamp" : ""}">
|
||||
<span class="activity-name">${activity.name}</span>
|
||||
${activityTimestamp}
|
||||
</div>
|
||||
<div class="activity-wrapper-inner">
|
||||
${activityArt}
|
||||
<div class="activity-content">
|
||||
<div class="inner-content">
|
||||
<div class="activity-top">
|
||||
<div class="activity-header ${progress !== null ? "no-timestamp" : ""}">
|
||||
<span class="activity-name">${primaryLine}</span>
|
||||
</div>
|
||||
${secondaryLine ? `<div class="activity-detail">${secondaryLine}</div>` : ""}
|
||||
${tertiaryLine ? `<div class="activity-detail">${tertiaryLine}</div>` : ""}
|
||||
</div>
|
||||
<div class="activity-bottom">
|
||||
${activityButtons}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
${activity.details ? `<div class="activity-detail">${activity.details}</div>` : ""}
|
||||
${activity.state ? `<div class="activity-detail">${activity.state}</div>` : ""}
|
||||
${activityButtons}
|
||||
${progressBar}
|
||||
</div>
|
||||
</li>
|
||||
|
@ -279,7 +196,9 @@ function buildActivityHTML(activity) {
|
|||
function updatePresence(data) {
|
||||
const avatarWrapper = document.querySelector(".avatar-wrapper");
|
||||
const statusIndicator = avatarWrapper?.querySelector(".status-indicator");
|
||||
const mobileIcon = avatarWrapper?.querySelector(".platform-icon.mobile-only");
|
||||
const mobileIcon = avatarWrapper?.querySelector(
|
||||
".platform-icon.mobile-only",
|
||||
);
|
||||
|
||||
const userInfo = document.querySelector(".user-info");
|
||||
const customStatus = userInfo?.querySelector(".custom-status");
|
||||
|
@ -290,15 +209,8 @@ function updatePresence(data) {
|
|||
desktop: data.active_on_discord_desktop,
|
||||
};
|
||||
|
||||
let status = "offline";
|
||||
if (data.activities.some((activity) => activity.type === 1)) {
|
||||
status = "streaming";
|
||||
} else {
|
||||
status = data.discord_status;
|
||||
}
|
||||
|
||||
if (statusIndicator) {
|
||||
statusIndicator.className = `status-indicator ${status}`;
|
||||
statusIndicator.className = `status-indicator ${data.discord_status}`;
|
||||
}
|
||||
|
||||
if (platform.mobile && !mobileIcon) {
|
||||
|
@ -309,7 +221,7 @@ function updatePresence(data) {
|
|||
`;
|
||||
} else if (!platform.mobile && mobileIcon) {
|
||||
mobileIcon.remove();
|
||||
avatarWrapper.innerHTML += `<div class="status-indicator ${status}"></div>`;
|
||||
avatarWrapper.innerHTML += `<div class="status-indicator ${data.discord_status}"></div>`;
|
||||
}
|
||||
|
||||
const custom = data.activities?.find((a) => a.type === 4);
|
||||
|
@ -322,31 +234,16 @@ function updatePresence(data) {
|
|||
} else if (emoji?.name) {
|
||||
emojiHTML = `${emoji.name} `;
|
||||
}
|
||||
customStatus.innerHTML = `
|
||||
${emojiHTML}
|
||||
${custom.state ? `<span class="custom-status-text">${custom.state}</span>` : ""}
|
||||
`;
|
||||
customStatus.innerHTML = `${emojiHTML}${custom.state}`;
|
||||
}
|
||||
|
||||
const filtered = data.activities
|
||||
?.filter((a) => a.type !== 4)
|
||||
?.sort((a, b) => {
|
||||
const priority = { 2: 0, 1: 1, 3: 2 }; // Listening, Streaming, Watching ? should i keep this
|
||||
const aPriority = priority[a.type] ?? 99;
|
||||
const bPriority = priority[b.type] ?? 99;
|
||||
return aPriority - bPriority;
|
||||
});
|
||||
|
||||
const filtered = data.activities?.filter((a) => a.type !== 4);
|
||||
const activityList = document.querySelector(".activities");
|
||||
const activitiesTitle = document.querySelector(".activity-header");
|
||||
|
||||
if (activityList && activitiesTitle) {
|
||||
if (activityList) {
|
||||
activityList.innerHTML = "";
|
||||
if (filtered?.length) {
|
||||
activityList.innerHTML = filtered.map(buildActivityHTML).join("");
|
||||
activitiesTitle.classList.remove("hidden");
|
||||
} else {
|
||||
activityList.innerHTML = "";
|
||||
activitiesTitle.classList.add("hidden");
|
||||
}
|
||||
updateElapsedAndProgress();
|
||||
}
|
||||
|
|
|
@ -1,77 +0,0 @@
|
|||
const rainContainer = document.createElement("div");
|
||||
rainContainer.style.position = "fixed";
|
||||
rainContainer.style.top = "0";
|
||||
rainContainer.style.left = "0";
|
||||
rainContainer.style.width = "100vw";
|
||||
rainContainer.style.height = "100vh";
|
||||
rainContainer.style.pointerEvents = "none";
|
||||
document.body.appendChild(rainContainer);
|
||||
|
||||
const maxRaindrops = 100;
|
||||
const raindrops = [];
|
||||
const mouse = { x: -100, y: -100 };
|
||||
|
||||
document.addEventListener("mousemove", (e) => {
|
||||
mouse.x = e.clientX;
|
||||
mouse.y = e.clientY;
|
||||
});
|
||||
|
||||
const getRaindropColor = () => {
|
||||
const htmlTag = document.documentElement;
|
||||
return htmlTag.getAttribute("data-theme") === "dark"
|
||||
? "rgba(173, 216, 230, 0.8)"
|
||||
: "rgba(70, 130, 180, 0.8)";
|
||||
};
|
||||
|
||||
const createRaindrop = () => {
|
||||
if (raindrops.length >= maxRaindrops) {
|
||||
const oldestRaindrop = raindrops.shift();
|
||||
rainContainer.removeChild(oldestRaindrop);
|
||||
}
|
||||
|
||||
const raindrop = document.createElement("div");
|
||||
raindrop.classList.add("raindrop");
|
||||
raindrop.style.position = "absolute";
|
||||
raindrop.style.width = "2px";
|
||||
raindrop.style.height = `${Math.random() * 10 + 10}px`;
|
||||
raindrop.style.background = getRaindropColor();
|
||||
raindrop.style.borderRadius = "1px";
|
||||
raindrop.style.left = `${Math.random() * window.innerWidth}px`;
|
||||
raindrop.style.top = `-${raindrop.style.height}`;
|
||||
raindrop.style.opacity = Math.random() * 0.5 + 0.3;
|
||||
raindrop.speed = Math.random() * 6 + 4;
|
||||
raindrop.directionX = (Math.random() - 0.5) * 0.2;
|
||||
raindrop.directionY = Math.random() * 0.5 + 0.8;
|
||||
|
||||
raindrops.push(raindrop);
|
||||
rainContainer.appendChild(raindrop);
|
||||
};
|
||||
|
||||
setInterval(createRaindrop, 50);
|
||||
|
||||
function updateRaindrops() {
|
||||
raindrops.forEach((raindrop, index) => {
|
||||
const rect = raindrop.getBoundingClientRect();
|
||||
|
||||
raindrop.style.left = `${rect.left + raindrop.directionX * raindrop.speed}px`;
|
||||
raindrop.style.top = `${rect.top + raindrop.directionY * raindrop.speed}px`;
|
||||
|
||||
if (rect.top + rect.height >= window.innerHeight) {
|
||||
rainContainer.removeChild(raindrop);
|
||||
raindrops.splice(index, 1);
|
||||
}
|
||||
|
||||
if (
|
||||
rect.left > window.innerWidth ||
|
||||
rect.top > window.innerHeight ||
|
||||
rect.left < 0
|
||||
) {
|
||||
raindrop.style.left = `${Math.random() * window.innerWidth}px`;
|
||||
raindrop.style.top = `-${raindrop.style.height}`;
|
||||
}
|
||||
});
|
||||
|
||||
requestAnimationFrame(updateRaindrops);
|
||||
}
|
||||
|
||||
updateRaindrops();
|
|
@ -1,84 +0,0 @@
|
|||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const snowContainer = document.createElement("div");
|
||||
snowContainer.style.position = "fixed";
|
||||
snowContainer.style.top = "0";
|
||||
snowContainer.style.left = "0";
|
||||
snowContainer.style.width = "100vw";
|
||||
snowContainer.style.height = "100vh";
|
||||
snowContainer.style.pointerEvents = "none";
|
||||
document.body.appendChild(snowContainer);
|
||||
|
||||
const maxSnowflakes = 60;
|
||||
const snowflakes = [];
|
||||
const mouse = { x: -100, y: -100 };
|
||||
|
||||
document.addEventListener("mousemove", (e) => {
|
||||
mouse.x = e.clientX;
|
||||
mouse.y = e.clientY;
|
||||
});
|
||||
|
||||
const createSnowflake = () => {
|
||||
if (snowflakes.length >= maxSnowflakes) {
|
||||
const oldestSnowflake = snowflakes.shift();
|
||||
snowContainer.removeChild(oldestSnowflake);
|
||||
}
|
||||
|
||||
const snowflake = document.createElement("div");
|
||||
snowflake.classList.add("snowflake");
|
||||
snowflake.style.position = "absolute";
|
||||
snowflake.style.width = `${Math.random() * 3 + 2}px`;
|
||||
snowflake.style.height = snowflake.style.width;
|
||||
snowflake.style.background = "white";
|
||||
snowflake.style.borderRadius = "50%";
|
||||
snowflake.style.opacity = Math.random();
|
||||
snowflake.style.left = `${Math.random() * window.innerWidth}px`;
|
||||
snowflake.style.top = `-${snowflake.style.height}`;
|
||||
snowflake.speed = Math.random() * 3 + 2;
|
||||
snowflake.directionX = (Math.random() - 0.5) * 0.5;
|
||||
snowflake.directionY = Math.random() * 0.5 + 0.5;
|
||||
|
||||
snowflakes.push(snowflake);
|
||||
snowContainer.appendChild(snowflake);
|
||||
};
|
||||
|
||||
setInterval(createSnowflake, 80);
|
||||
|
||||
function updateSnowflakes() {
|
||||
snowflakes.forEach((snowflake, index) => {
|
||||
const rect = snowflake.getBoundingClientRect();
|
||||
|
||||
const dx = rect.left + rect.width / 2 - mouse.x;
|
||||
const dy = rect.top + rect.height / 2 - mouse.y;
|
||||
const distance = Math.sqrt(dx * dx + dy * dy);
|
||||
|
||||
if (distance < 30) {
|
||||
snowflake.directionX += (dx / distance) * 0.02;
|
||||
snowflake.directionY += (dy / distance) * 0.02;
|
||||
} else {
|
||||
snowflake.directionX += (Math.random() - 0.5) * 0.01;
|
||||
snowflake.directionY += (Math.random() - 0.5) * 0.01;
|
||||
}
|
||||
|
||||
snowflake.style.left = `${rect.left + snowflake.directionX * snowflake.speed}px`;
|
||||
snowflake.style.top = `${rect.top + snowflake.directionY * snowflake.speed}px`;
|
||||
|
||||
if (rect.top + rect.height >= window.innerHeight) {
|
||||
snowContainer.removeChild(snowflake);
|
||||
snowflakes.splice(index, 1);
|
||||
}
|
||||
|
||||
if (
|
||||
rect.left > window.innerWidth ||
|
||||
rect.top > window.innerHeight ||
|
||||
rect.left < 0
|
||||
) {
|
||||
snowflake.style.left = `${Math.random() * window.innerWidth}px`;
|
||||
snowflake.style.top = `-${snowflake.style.height}`;
|
||||
}
|
||||
});
|
||||
|
||||
requestAnimationFrame(updateSnowflakes);
|
||||
}
|
||||
|
||||
updateSnowflakes();
|
||||
});
|
|
@ -1,6 +1,6 @@
|
|||
export function timestampToReadable(timestamp?: number): string {
|
||||
const date: Date =
|
||||
timestamp && !Number.isNaN(timestamp) ? new Date(timestamp) : new Date();
|
||||
if (Number.isNaN(date.getTime())) return "Invalid Date";
|
||||
timestamp && !isNaN(timestamp) ? new Date(timestamp) : new Date();
|
||||
if (isNaN(date.getTime())) return "Invalid Date";
|
||||
return date.toISOString().replace("T", " ").replace("Z", "");
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { resolve } from "node:path";
|
||||
import { renderFile } from "ejs";
|
||||
import { resolve } from "path";
|
||||
|
||||
export async function renderEjsTemplate(
|
||||
viewName: string | string[],
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { lanyardConfig } from "@config/environment";
|
||||
import { fetch } from "bun";
|
||||
import DOMPurify from "isomorphic-dompurify";
|
||||
import { marked } from "marked";
|
||||
|
||||
export async function getLanyardData(id?: string): Promise<LanyardResponse> {
|
||||
|
@ -76,7 +75,7 @@ export async function handleReadMe(data: LanyardData): Promise<string | null> {
|
|||
return null;
|
||||
|
||||
if (res.headers.has("content-length")) {
|
||||
const size: number = Number.parseInt(
|
||||
const size: number = parseInt(
|
||||
res.headers.get("content-length") || "0",
|
||||
10,
|
||||
);
|
||||
|
@ -86,10 +85,7 @@ export async function handleReadMe(data: LanyardData): Promise<string | null> {
|
|||
const text: string = await res.text();
|
||||
if (!text || text.length < 10) return null;
|
||||
|
||||
const html: string | null = await marked.parse(text);
|
||||
const safe: string | null = DOMPurify.sanitize(html);
|
||||
|
||||
return safe;
|
||||
return marked.parse(text);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
import type { Stats } from "node:fs";
|
||||
import { environment } from "@config/environment";
|
||||
import { timestampToReadable } from "@helpers/char";
|
||||
import type { Stats } from "fs";
|
||||
import {
|
||||
type WriteStream,
|
||||
createWriteStream,
|
||||
existsSync,
|
||||
mkdirSync,
|
||||
statSync,
|
||||
} from "node:fs";
|
||||
import { EOL } from "node:os";
|
||||
import { basename, join } from "node:path";
|
||||
import { environment } from "@config/environment";
|
||||
import { timestampToReadable } from "@helpers/char";
|
||||
WriteStream,
|
||||
} from "fs";
|
||||
import { EOL } from "os";
|
||||
import { basename, join } from "path";
|
||||
|
||||
class Logger {
|
||||
private static instance: Logger;
|
||||
|
@ -37,7 +37,7 @@ class Logger {
|
|||
mkdirSync(logDir, { recursive: true });
|
||||
}
|
||||
|
||||
let addSeparator = false;
|
||||
let addSeparator: boolean = false;
|
||||
|
||||
if (existsSync(logFile)) {
|
||||
const fileStats: Stats = statSync(logFile);
|
||||
|
@ -66,9 +66,9 @@ class Logger {
|
|||
|
||||
private extractFileName(stack: string): string {
|
||||
const stackLines: string[] = stack.split("\n");
|
||||
let callerFile = "";
|
||||
let callerFile: string = "";
|
||||
|
||||
for (let i = 2; i < stackLines.length; i++) {
|
||||
for (let i: number = 2; i < stackLines.length; i++) {
|
||||
const line: string = stackLines[i].trim();
|
||||
if (line && !line.includes("Logger.") && line.includes("(")) {
|
||||
callerFile = line.split("(")[1]?.split(")")[0] || "";
|
||||
|
@ -91,7 +91,7 @@ class Logger {
|
|||
return { filename, timestamp: readableTimestamp };
|
||||
}
|
||||
|
||||
public info(message: string | string[], breakLine = false): void {
|
||||
public info(message: string | string[], breakLine: boolean = false): void {
|
||||
const stack: string = new Error().stack || "";
|
||||
const { filename, timestamp } = this.getCallerInfo(stack);
|
||||
|
||||
|
@ -110,7 +110,7 @@ class Logger {
|
|||
this.writeConsoleMessageColored(logMessageParts, breakLine);
|
||||
}
|
||||
|
||||
public warn(message: string | string[], breakLine = false): void {
|
||||
public warn(message: string | string[], breakLine: boolean = false): void {
|
||||
const stack: string = new Error().stack || "";
|
||||
const { filename, timestamp } = this.getCallerInfo(stack);
|
||||
|
||||
|
@ -131,7 +131,7 @@ class Logger {
|
|||
|
||||
public error(
|
||||
message: string | Error | (string | Error)[],
|
||||
breakLine = false,
|
||||
breakLine: boolean = false,
|
||||
): void {
|
||||
const stack: string = new Error().stack || "";
|
||||
const { filename, timestamp } = this.getCallerInfo(stack);
|
||||
|
@ -161,7 +161,7 @@ class Logger {
|
|||
bracketMessage2: string,
|
||||
message: string | string[],
|
||||
color: string,
|
||||
breakLine = false,
|
||||
breakLine: boolean = false,
|
||||
): void {
|
||||
const stack: string = new Error().stack || "";
|
||||
const { timestamp } = this.getCallerInfo(stack);
|
||||
|
@ -189,7 +189,7 @@ class Logger {
|
|||
|
||||
private writeConsoleMessageColored(
|
||||
logMessageParts: ILogMessageParts,
|
||||
breakLine = false,
|
||||
breakLine: boolean = false,
|
||||
): void {
|
||||
const logMessage: string = Object.keys(logMessageParts)
|
||||
.map((key: string) => {
|
||||
|
|
|
@ -3,7 +3,11 @@ import { logger } from "@helpers/logger";
|
|||
import { serverHandler } from "@/server";
|
||||
|
||||
async function main(): Promise<void> {
|
||||
serverHandler.initialize();
|
||||
try {
|
||||
serverHandler.initialize();
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((error: Error) => {
|
||||
|
|
|
@ -29,20 +29,13 @@ async function handler(request: ExtendedRequest): Promise<Response> {
|
|||
}
|
||||
|
||||
const presence: LanyardData = data.data;
|
||||
const readme: string | Promise<string> | null = await handleReadMe(presence);
|
||||
|
||||
let status: string;
|
||||
if (presence.activities.some((activity) => activity.type === 1)) {
|
||||
status = "streaming";
|
||||
} else {
|
||||
status = presence.discord_status;
|
||||
}
|
||||
const readme: string | Promise<string> | null =
|
||||
await handleReadMe(presence);
|
||||
|
||||
const ejsTemplateData: EjsTemplateData = {
|
||||
title: presence.discord_user.global_name || presence.discord_user.username,
|
||||
username:
|
||||
presence.discord_user.global_name || presence.discord_user.username,
|
||||
status: status,
|
||||
title: `${presence.discord_user.username || "Unknown"}`,
|
||||
username: presence.discord_user.username,
|
||||
status: presence.discord_status,
|
||||
activities: presence.activities,
|
||||
user: presence.discord_user,
|
||||
platform: {
|
||||
|
@ -52,8 +45,6 @@ async function handler(request: ExtendedRequest): Promise<Response> {
|
|||
},
|
||||
instance,
|
||||
readme,
|
||||
allowSnow: presence.kv.snow || false,
|
||||
allowRain: presence.kv.rain || false,
|
||||
};
|
||||
|
||||
return await renderEjsTemplate("index", ejsTemplateData);
|
||||
|
|
|
@ -24,7 +24,10 @@ async function handler(request: ExtendedRequest): Promise<Response> {
|
|||
try {
|
||||
res = await fetch(url);
|
||||
} catch {
|
||||
return Response.json({ error: "Failed to fetch image" }, { status: 500 });
|
||||
return Response.json(
|
||||
{ error: "Failed to fetch image" },
|
||||
{ status: 500 },
|
||||
);
|
||||
}
|
||||
|
||||
if (!res.ok) {
|
||||
|
|
|
@ -28,20 +28,15 @@ async function handler(): Promise<Response> {
|
|||
}
|
||||
|
||||
const presence: LanyardData = data.data;
|
||||
const readme: string | Promise<string> | null = await handleReadMe(presence);
|
||||
|
||||
let status: string;
|
||||
if (presence.activities.some((activity) => activity.type === 1)) {
|
||||
status = "streaming";
|
||||
} else {
|
||||
status = presence.discord_status;
|
||||
}
|
||||
const readme: string | Promise<string> | null =
|
||||
await handleReadMe(presence);
|
||||
|
||||
const ejsTemplateData: EjsTemplateData = {
|
||||
title: presence.discord_user.global_name || presence.discord_user.username,
|
||||
title:
|
||||
presence.discord_user.global_name || presence.discord_user.username,
|
||||
username:
|
||||
presence.discord_user.global_name || presence.discord_user.username,
|
||||
status: status,
|
||||
status: presence.discord_status,
|
||||
activities: presence.activities,
|
||||
user: presence.discord_user,
|
||||
platform: {
|
||||
|
@ -51,8 +46,6 @@ async function handler(): Promise<Response> {
|
|||
},
|
||||
instance,
|
||||
readme,
|
||||
allowSnow: presence.kv.snow === "true",
|
||||
allowRain: presence.kv.rain === "true",
|
||||
};
|
||||
|
||||
return await renderEjsTemplate("index", ejsTemplateData);
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import { resolve } from "node:path";
|
||||
import { environment } from "@config/environment";
|
||||
import { logger } from "@helpers/logger";
|
||||
import {
|
||||
|
@ -7,6 +6,7 @@ import {
|
|||
type MatchedRoute,
|
||||
type Serve,
|
||||
} from "bun";
|
||||
import { resolve } from "path";
|
||||
|
||||
import { webSocketHandler } from "@/websocket";
|
||||
|
||||
|
@ -34,16 +34,22 @@ class ServerHandler {
|
|||
open: webSocketHandler.handleOpen.bind(webSocketHandler),
|
||||
message: webSocketHandler.handleMessage.bind(webSocketHandler),
|
||||
close: webSocketHandler.handleClose.bind(webSocketHandler),
|
||||
error(error) {
|
||||
logger.error(`Server error: ${error.message}`);
|
||||
return new Response(`Server Error: ${error.message}`, {
|
||||
status: 500,
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const accessUrls: string[] = [
|
||||
const accessUrls = [
|
||||
`http://${server.hostname}:${server.port}`,
|
||||
`http://localhost:${server.port}`,
|
||||
`http://127.0.0.1:${server.port}`,
|
||||
];
|
||||
|
||||
logger.info(`Server running at ${accessUrls[0]}`);
|
||||
logger.info(`Server running at ${accessUrls[0]}`, true);
|
||||
logger.info(`Access via: ${accessUrls[1]} or ${accessUrls[2]}`, true);
|
||||
|
||||
this.logRoutes();
|
||||
|
@ -77,16 +83,21 @@ class ServerHandler {
|
|||
|
||||
if (await file.exists()) {
|
||||
const fileContent: ArrayBuffer = await file.arrayBuffer();
|
||||
const contentType: string = file.type || "application/octet-stream";
|
||||
const contentType: string =
|
||||
file.type || "application/octet-stream";
|
||||
|
||||
return new Response(fileContent, {
|
||||
headers: { "Content-Type": contentType },
|
||||
});
|
||||
} else {
|
||||
logger.warn(`File not found: ${filePath}`);
|
||||
return new Response("Not Found", { status: 404 });
|
||||
}
|
||||
logger.warn(`File not found: ${filePath}`);
|
||||
return new Response("Not Found", { status: 404 });
|
||||
} catch (error) {
|
||||
logger.error([`Error serving static file: ${pathname}`, error as Error]);
|
||||
logger.error([
|
||||
`Error serving static file: ${pathname}`,
|
||||
error as Error,
|
||||
]);
|
||||
return new Response("Internal Server Error", { status: 500 });
|
||||
}
|
||||
}
|
||||
|
@ -112,7 +123,8 @@ class ServerHandler {
|
|||
|
||||
try {
|
||||
const routeModule: RouteModule = await import(filePath);
|
||||
const contentType: string | null = request.headers.get("Content-Type");
|
||||
const contentType: string | null =
|
||||
request.headers.get("Content-Type");
|
||||
const actualContentType: string | null = contentType
|
||||
? contentType.split(";")[0].trim()
|
||||
: null;
|
||||
|
@ -139,7 +151,9 @@ class ServerHandler {
|
|||
|
||||
if (
|
||||
(Array.isArray(routeModule.routeDef.method) &&
|
||||
!routeModule.routeDef.method.includes(request.method)) ||
|
||||
!routeModule.routeDef.method.includes(
|
||||
request.method,
|
||||
)) ||
|
||||
(!Array.isArray(routeModule.routeDef.method) &&
|
||||
routeModule.routeDef.method !== request.method)
|
||||
) {
|
||||
|
@ -164,7 +178,9 @@ class ServerHandler {
|
|||
if (Array.isArray(expectedContentType)) {
|
||||
matchesAccepts =
|
||||
expectedContentType.includes("*/*") ||
|
||||
expectedContentType.includes(actualContentType || "");
|
||||
expectedContentType.includes(
|
||||
actualContentType || "",
|
||||
);
|
||||
} else {
|
||||
matchesAccepts =
|
||||
expectedContentType === "*/*" ||
|
||||
|
@ -203,7 +219,10 @@ class ServerHandler {
|
|||
}
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
logger.error([`Error handling route ${request.url}:`, error as Error]);
|
||||
logger.error([
|
||||
`Error handling route ${request.url}:`,
|
||||
error as Error,
|
||||
]);
|
||||
|
||||
response = Response.json(
|
||||
{
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head data-user-id="<%= user.id %>" data-instance-uri="<%= instance %>">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
@ -14,30 +13,22 @@
|
|||
<link rel="stylesheet" href="/public/css/index.css">
|
||||
<script src="/public/js/index.js" defer></script>
|
||||
|
||||
<% if (allowSnow) { %>
|
||||
<script src="/public/js/snow.js" defer></script>
|
||||
<% } %>
|
||||
<% if(allowRain) { %>
|
||||
<script src="/public/js/rain.js" defer></script>
|
||||
<% } %>
|
||||
|
||||
<meta name="color-scheme" content="dark">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="user-card">
|
||||
<div class="avatar-status-wrapper">
|
||||
<div class="avatar-wrapper">
|
||||
<img class="avatar" src="https://cdn.discordapp.com/avatars/<%= user.id %>/<%= user.avatar %>" alt="Avatar">
|
||||
<% if (user.avatar_decoration_data) { %>
|
||||
<img class="decoration" src="https://cdn.discordapp.com/avatar-decoration-presets/<%= user.avatar_decoration_data.asset %>" alt="Decoration">
|
||||
<img class="decoration" src="https://cdn.discordapp.com/avatar-decoration-presets/<%= user.avatar_decoration_data.asset %>" alt="Decoration">
|
||||
<% } %>
|
||||
<% if (platform.mobile) { %>
|
||||
<svg class="platform-icon mobile-only" viewBox="0 0 1000 1500" fill="#43a25a" aria-label="Mobile" width="17" height="17">
|
||||
<path d="M 187 0 L 813 0 C 916.277 0 1000 83.723 1000 187 L 1000 1313 C 1000 1416.277 916.277 1500 813 1500 L 187 1500 C 83.723 1500 0 1416.277 0 1313 L 0 187 C 0 83.723 83.723 0 187 0 Z M 125 1000 L 875 1000 L 875 250 L 125 250 Z M 500 1125 C 430.964 1125 375 1180.964 375 1250 C 375 1319.036 430.964 1375 500 1375 C 569.036 1375 625 1319.036 625 1250 C 625 1180.964 569.036 1125 500 1125 Z" />
|
||||
</svg>
|
||||
<svg class="platform-icon mobile-only" viewBox="0 0 1000 1500" fill="#43a25a" aria-label="Mobile" width="17" height="17">
|
||||
<path d="M 187 0 L 813 0 C 916.277 0 1000 83.723 1000 187 L 1000 1313 C 1000 1416.277 916.277 1500 813 1500 L 187 1500 C 83.723 1500 0 1416.277 0 1313 L 0 187 C 0 83.723 83.723 0 187 0 Z M 125 1000 L 875 1000 L 875 250 L 125 250 Z M 500 1125 C 430.964 1125 375 1180.964 375 1250 C 375 1319.036 430.964 1375 500 1375 C 569.036 1375 625 1319.036 625 1250 C 625 1180.964 569.036 1125 500 1125 Z"/>
|
||||
</svg>
|
||||
<% } else { %>
|
||||
<div class="status-indicator <%= status %>"></div>
|
||||
<div class="status-indicator <%= status %>"></div>
|
||||
<% } %>
|
||||
</div>
|
||||
<div class="user-info">
|
||||
|
@ -49,164 +40,111 @@
|
|||
? `https://cdn.discordapp.com/emojis/${emoji.id}.${emoji.animated ? "gif" : "png"}`
|
||||
: null;
|
||||
%>
|
||||
<p class="custom-status">
|
||||
<% if (isCustom && emojiUrl) { %>
|
||||
<img src="<%= emojiUrl %>" alt="<%= emoji.name %>" class="custom-emoji">
|
||||
<% } else if (emoji?.name) { %>
|
||||
<%= emoji.name %>
|
||||
<% } %>
|
||||
<% if (activities[0].state) { %>
|
||||
<span class="custom-status-text"><%= activities[0].state %></span>
|
||||
<% } %>
|
||||
</p>
|
||||
<p class="custom-status">
|
||||
<% if (isCustom && emojiUrl) { %>
|
||||
<img src="<%= emojiUrl %>" alt="<%= emoji.name %>" class="custom-emoji">
|
||||
<% } else if (emoji?.name) { %>
|
||||
<%= emoji.name %>
|
||||
<% } %>
|
||||
<%= activities[0].state %>
|
||||
</p>
|
||||
<% } %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%
|
||||
let filtered = activities
|
||||
.filter(a => a.type !== 4)
|
||||
.sort((a, b) => {
|
||||
const priority = { 2: 0, 1: 1, 3: 2 };
|
||||
const aPriority = priority[a.type] ?? 99;
|
||||
const bPriority = priority[b.type] ?? 99;
|
||||
return aPriority - bPriority;
|
||||
});
|
||||
%>
|
||||
<% const filtered = activities.filter(a => a.type !== 4); %>
|
||||
<% if (filtered.length > 0) { %>
|
||||
<h2>Activities</h2>
|
||||
<ul class="activities">
|
||||
<% filtered.forEach(activity => {
|
||||
const start = activity.timestamps?.start;
|
||||
const end = activity.timestamps?.end;
|
||||
const now = Date.now();
|
||||
const elapsed = start ? now - start : 0;
|
||||
const total = (start && end) ? end - start : null;
|
||||
const progress = (total && elapsed > 0) ? Math.min(100, Math.floor((elapsed / total) * 100)) : null;
|
||||
|
||||
<h2 class="activity-header <%= filtered.length === 0 ? 'hidden' : '' %>">Activities</h2>
|
||||
<ul class="activities">
|
||||
<% filtered.forEach(activity => {
|
||||
const start = activity.timestamps?.start;
|
||||
const end = activity.timestamps?.end;
|
||||
const now = Date.now();
|
||||
const elapsed = start ? now - start : 0;
|
||||
const total = (start && end) ? end - start : null;
|
||||
const progress = (total && elapsed > 0) ? Math.min(100, Math.floor((elapsed / total) * 100)) : null;
|
||||
|
||||
let art = null;
|
||||
let smallArt = null;
|
||||
|
||||
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 img = activity.assets?.large_image;
|
||||
let art = null;
|
||||
if (img?.includes("https")) {
|
||||
const clean = img.split("/https/")[1];
|
||||
return clean ? `https://${clean}` : null;
|
||||
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 (img.startsWith("spotify:")) {
|
||||
return `https://i.scdn.co/image/${img.split(":")[1]}`;
|
||||
}
|
||||
return `https://cdn.discordapp.com/app-assets/${applicationId}/${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 = {
|
||||
0: "Playing",
|
||||
1: "Streaming",
|
||||
2: "Listening",
|
||||
3: "Watching",
|
||||
4: "Custom Status",
|
||||
5: "Competing",
|
||||
};
|
||||
|
||||
const activityType = activity.name === "Spotify"
|
||||
? "Listening to Spotify"
|
||||
: activity.name === "TIDAL"
|
||||
? "Listening to TIDAL"
|
||||
: activityTypeMap[activity.type] || "Playing";
|
||||
%>
|
||||
<li class="activity">
|
||||
<div class="activity-wrapper">
|
||||
<div class="activity-type-wrapper">
|
||||
<span class="activity-type-label" data-type="<%= activity.type %>"><%= activityType %></span>
|
||||
<% if (start && progress === null) { %>
|
||||
<div class="activity-timestamp" data-start="<%= start %>">
|
||||
<% const started = new Date(start); %>
|
||||
<span>
|
||||
Since: <%= started.toLocaleTimeString('en-GB', { hour: '2-digit', minute: '2-digit', second: '2-digit' }) %> <span class="elapsed"></span>
|
||||
</span>
|
||||
</div>
|
||||
<% } %>
|
||||
</div>
|
||||
<div class="activity-wrapper-inner">
|
||||
%>
|
||||
<li class="activity">
|
||||
<% if (art) { %>
|
||||
<div class="activity-image-wrapper">
|
||||
<img class="activity-image" src="<%= art %>" alt="Art" <%= activity.assets?.large_text ? `title="${activity.assets.large_text}"` : '' %>>
|
||||
<% if (smallArt) { %>
|
||||
<img class="activity-image-small" src="<%= smallArt %>" alt="Small Art" <%= activity.assets?.small_text ? `title="${activity.assets.small_text}"` : '' %>>
|
||||
<img class="activity-art" src="<%= art %>" alt="Art">
|
||||
<% } %>
|
||||
|
||||
<div class="activity-content">
|
||||
<div class="activity-header <%= progress !== null ? 'no-timestamp' : '' %>">
|
||||
<span class="activity-name"><%= activity.name %></span>
|
||||
|
||||
<% if (start && progress === null) { %>
|
||||
<div class="activity-timestamp" data-start="<%= start %>">
|
||||
<% const started = new Date(start); %>
|
||||
<span>
|
||||
Since: <%= started.toLocaleTimeString('en-GB', { hour: '2-digit', minute: '2-digit', second: '2-digit' }) %> <span class="elapsed"></span>
|
||||
</span>
|
||||
</div>
|
||||
<% } %>
|
||||
</div>
|
||||
|
||||
<% if (activity.details) { %>
|
||||
<div class="activity-detail"><%= activity.details %></div>
|
||||
<% } %>
|
||||
<% if (activity.state) { %>
|
||||
<div class="activity-detail"><%= activity.state %></div>
|
||||
<% } %>
|
||||
|
||||
<% if (activity.buttons && activity.buttons.length > 0) { %>
|
||||
<div class="activity-buttons">
|
||||
<% activity.buttons.forEach((button, index) => {
|
||||
const buttonLabel = typeof button === 'string' ? button : button.label;
|
||||
let buttonUrl = null;
|
||||
if (typeof button === 'object' && button.url) {
|
||||
buttonUrl = button.url;
|
||||
}
|
||||
else if (index === 0 && activity.url) {
|
||||
buttonUrl = activity.url;
|
||||
}
|
||||
%>
|
||||
<% if (buttonUrl) { %>
|
||||
<a href="<%= buttonUrl %>" class="activity-button" target="_blank" rel="noopener noreferrer"><%= buttonLabel %></a>
|
||||
<% } else { %>
|
||||
<span class="activity-button disabled"><%= buttonLabel %></span>
|
||||
<% } %>
|
||||
<% }); %>
|
||||
</div>
|
||||
<% } %>
|
||||
|
||||
<% if (progress !== null) { %>
|
||||
<div class="progress-bar" data-start="<%= start %>" data-end="<%= end %>">
|
||||
<div class="progress-fill" <%= progress !== null ? `style="width: ${progress}%"` : '' %>></div>
|
||||
</div>
|
||||
|
||||
<% if (start && end) { %>
|
||||
<div class="progress-time-labels" data-start="<%= start %>" data-end="<%= end %>">
|
||||
<span class="progress-current">--:--</span>
|
||||
<span class="progress-total"><%= Math.floor((end - start) / 60000) %>:<%= String(Math.floor(((end - start) % 60000) / 1000)).padStart(2, "0") %></span>
|
||||
</div>
|
||||
<% } %>
|
||||
<% } %>
|
||||
</div>
|
||||
<% } %>
|
||||
<div class="activity-content">
|
||||
<div class="inner-content">
|
||||
<%
|
||||
const isMusic = activity.type === 2 || activity.type === 3;
|
||||
const primaryLine = isMusic ? activity.details : activity.name;
|
||||
const secondaryLine = isMusic ? activity.state : activity.details;
|
||||
const tertiaryLine = isMusic ? activity.assets?.large_text : activity.state;
|
||||
%>
|
||||
<div class="activity-top">
|
||||
<div class="activity-header <%= progress !== null ? 'no-timestamp' : '' %>">
|
||||
<span class="activity-name"><%= primaryLine %></span>
|
||||
</div>
|
||||
<% if (secondaryLine) { %>
|
||||
<div class="activity-detail"><%= secondaryLine %></div>
|
||||
<% } %>
|
||||
<% if (tertiaryLine) { %>
|
||||
<div class="activity-detail"><%= tertiaryLine %></div>
|
||||
<% } %>
|
||||
</div>
|
||||
<div class="activity-bottom">
|
||||
<% if (activity.buttons && activity.buttons.length > 0) { %>
|
||||
<div class="activity-buttons">
|
||||
<% activity.buttons.forEach((button, index) => {
|
||||
const buttonLabel = typeof button === 'string' ? button : button.label;
|
||||
let buttonUrl = null;
|
||||
if (typeof button === 'object' && button.url) {
|
||||
buttonUrl = button.url;
|
||||
} else if (index === 0 && activity.url) {
|
||||
buttonUrl = activity.url;
|
||||
}
|
||||
%>
|
||||
<% if (buttonUrl) { %>
|
||||
<a href="<%= buttonUrl %>" class="activity-button" target="_blank" rel="noopener noreferrer"><%= buttonLabel %></a>
|
||||
<% } %>
|
||||
<% }) %>
|
||||
</div>
|
||||
<% } %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% if (progress !== null) { %>
|
||||
<div class="progress-bar" data-start="<%= start %>" data-end="<%= end %>">
|
||||
<div class="progress-fill" <%= progress !== null ? `style="width: ${progress}%"` : '' %>></div>
|
||||
</div>
|
||||
<% if (start && end) { %>
|
||||
<div class="progress-time-labels" data-start="<%= start %>" data-end="<%= end %>">
|
||||
<span class="progress-current"></span>
|
||||
<span class="progress-total"><%= Math.floor((end - start) / 60000) %>:<%= String(Math.floor(((end - start) % 60000) / 1000)).padStart(2, "0") %></span>
|
||||
</div>
|
||||
<% } %>
|
||||
<% } %>
|
||||
</div>
|
||||
</li>
|
||||
<% }); %>
|
||||
</ul>
|
||||
|
||||
</li>
|
||||
<% }) %>
|
||||
</ul>
|
||||
<% } %>
|
||||
<% if (readme) { %>
|
||||
<section class="readme">
|
||||
<div class="markdown-body"><%- readme %></div>
|
||||
</section>
|
||||
<h2>Readme</h2>
|
||||
<section class="readme">
|
||||
<div class="markdown-body"><%- readme %></div>
|
||||
</section>
|
||||
<% } %>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { logger } from "@helpers/logger";
|
||||
import type { ServerWebSocket } from "bun";
|
||||
import { type ServerWebSocket } from "bun";
|
||||
|
||||
class WebSocketHandler {
|
||||
public handleMessage(ws: ServerWebSocket, message: string): void {
|
||||
|
@ -20,7 +20,11 @@ class WebSocketHandler {
|
|||
}
|
||||
}
|
||||
|
||||
public handleClose(ws: ServerWebSocket, code: number, reason: string): void {
|
||||
public handleClose(
|
||||
ws: ServerWebSocket,
|
||||
code: number,
|
||||
reason: string,
|
||||
): void {
|
||||
logger.warn(`WebSocket closed with code ${code}, reason: ${reason}`);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,14 +2,28 @@
|
|||
"compilerOptions": {
|
||||
"baseUrl": "./",
|
||||
"paths": {
|
||||
"@/*": ["src/*"],
|
||||
"@config/*": ["config/*"],
|
||||
"@types/*": ["types/*"],
|
||||
"@helpers/*": ["src/helpers/*"]
|
||||
"@/*": [
|
||||
"src/*"
|
||||
],
|
||||
"@config/*": [
|
||||
"config/*"
|
||||
],
|
||||
"@types/*": [
|
||||
"types/*"
|
||||
],
|
||||
"@helpers/*": [
|
||||
"src/helpers/*"
|
||||
]
|
||||
},
|
||||
"typeRoots": ["./src/types", "./node_modules/@types"],
|
||||
"typeRoots": [
|
||||
"./src/types",
|
||||
"./node_modules/@types"
|
||||
],
|
||||
// Enable latest features
|
||||
"lib": ["ESNext", "DOM"],
|
||||
"lib": [
|
||||
"ESNext",
|
||||
"DOM"
|
||||
],
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"moduleDetection": "force",
|
||||
|
@ -27,7 +41,11 @@
|
|||
// Some stricter flags (disabled by default)
|
||||
"noUnusedLocals": false,
|
||||
"noUnusedParameters": false,
|
||||
"noPropertyAccessFromIndexSignature": false
|
||||
"noPropertyAccessFromIndexSignature": false,
|
||||
},
|
||||
"include": ["src", "types", "config"]
|
||||
"include": [
|
||||
"src",
|
||||
"types",
|
||||
"config"
|
||||
],
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue