Compare commits
1
Commits
main
...
feat-build-tools
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6c86a219e4 |
No files matched your search
@@ -0,0 +1,81 @@
|
||||
name: Build Binaries
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
|
||||
- name: Install pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
with:
|
||||
version: 9
|
||||
|
||||
- name: Get pnpm store directory
|
||||
shell: bash
|
||||
run: |
|
||||
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
|
||||
|
||||
- name: Setup pnpm cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ${{ env.STORE_PATH }}
|
||||
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pnpm-store-
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Build client
|
||||
run: pnpm build:client
|
||||
|
||||
# NOTE: Binary building disabled due to nexe ESM compatibility issues
|
||||
# To be re-enabled once ESM support improves or alternative tool is used
|
||||
# - name: Build server binaries
|
||||
# run: pnpm build:server
|
||||
|
||||
- name: Upload dist artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: songdash-dist
|
||||
path: dist/
|
||||
retention-days: 30
|
||||
|
||||
# - name: Upload Windows binary
|
||||
# uses: actions/upload-artifact@v4
|
||||
# with:
|
||||
# name: songdash-windows-x64
|
||||
# path: build/songdash-windows-x64.exe
|
||||
# retention-days: 30
|
||||
|
||||
# - name: Upload Linux binary
|
||||
# uses: actions/upload-artifact@v4
|
||||
# with:
|
||||
# name: songdash-linux-x64
|
||||
# path: build/songdash-linux-x64
|
||||
# retention-days: 30
|
||||
|
||||
# - name: Create Release (on tag)
|
||||
# if: startsWith(github.ref, 'refs/tags/')
|
||||
# uses: softprops/action-gh-release@v1
|
||||
# with:
|
||||
# files: |
|
||||
# build/songdash-windows-x64.exe
|
||||
# build/songdash-linux-x64
|
||||
# env:
|
||||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
+4
-1
@@ -1,2 +1,5 @@
|
||||
node_modules/
|
||||
.env
|
||||
.env
|
||||
|
||||
dist/
|
||||
build/
|
||||
@@ -15,27 +15,48 @@ When a player presses their button, the music pauses and they join the queue. Th
|
||||
|
||||
## Setup
|
||||
|
||||
### Development
|
||||
|
||||
1. Clone the repository
|
||||
2. Install dependencies:
|
||||
```bash
|
||||
pnpm install
|
||||
```
|
||||
3. Modifications:
|
||||
3. Configuration (optional):
|
||||
|
||||
For customizations, look at `.env.example` for possible values, and change them in `.env` before launching
|
||||
For customizations, look at `.env.example` for possible values, and change them in `.env` before launching
|
||||
|
||||
IMPORTANT: for a working QR code generation, create a `.env` file with at least `SERVER_HOST`
|
||||
|
||||
4. Start the server:
|
||||
4. Start the development server:
|
||||
|
||||
```bash
|
||||
pnpm start
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
5. Open the interfaces:
|
||||
- Host: `http://<ip-address>:2500/host.html`
|
||||
- TV: `http://<ip-address>:2500/tv.html`
|
||||
- Players: `http://<ip-address>:2500/player.html`
|
||||
- Host: `http://<ip-address>:2500/host`
|
||||
- TV: `http://<ip-address>:2500/tv`
|
||||
- Players: `http://<ip-address>:2500/player`
|
||||
- Debug: `http://<ip-address>:2500/debug`
|
||||
|
||||
### Production Build
|
||||
|
||||
Build optimized client files and server:
|
||||
|
||||
```bash
|
||||
pnpm build
|
||||
```
|
||||
|
||||
This will:
|
||||
1. Bundle and minify all client-side code with Vite
|
||||
2. Generate standalone binaries for Windows and Linux (Note: Binary generation currently has ESM compatibility issues and is under development)
|
||||
|
||||
Run the production server:
|
||||
|
||||
```bash
|
||||
pnpm start
|
||||
```
|
||||
|
||||
## Technical Details
|
||||
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
import { compile } from 'nexe'
|
||||
import { join } from 'path'
|
||||
|
||||
// NOTE: nexe currently has limited ESM (ES Modules) support
|
||||
// The binary build works but has issues with ES module imports at runtime
|
||||
// This is a known limitation: https://github.com/nexe/nexe/issues/836
|
||||
// Workarounds:
|
||||
// 1. Convert to CommonJS (require/module.exports)
|
||||
// 2. Use a different tool like `pkg` or `caxa`
|
||||
// 3. Wait for better ESM support in nexe
|
||||
|
||||
const targets = [
|
||||
{ platform: 'windows', arch: 'x64' },
|
||||
{ platform: 'linux', arch: 'x64' },
|
||||
]
|
||||
|
||||
async function buildBinary(target) {
|
||||
const outputName = `songdash-${target.platform}-${target.arch}${
|
||||
target.platform === 'windows' ? '.exe' : ''
|
||||
}`
|
||||
|
||||
console.log(`Building ${outputName}...`)
|
||||
|
||||
await compile({
|
||||
input: './dist-server/server.cjs', // Use Vite-bundled CommonJS file
|
||||
output: join('build', outputName),
|
||||
target: `${target.platform}-${target.arch}-14.15.3`, // Node.js version with pre-built binaries
|
||||
resources: ['./dist/**/*', './public/**/*'],
|
||||
build: false, // Use pre-built Node binaries
|
||||
loglevel: 'info',
|
||||
})
|
||||
|
||||
console.log(`✓ Built ${outputName}`)
|
||||
}
|
||||
|
||||
async function buildAll() {
|
||||
console.log('Building binaries for all platforms...\n')
|
||||
|
||||
for (const target of targets) {
|
||||
try {
|
||||
await buildBinary(target)
|
||||
} catch (error) {
|
||||
console.error(`Failed to build for ${target.platform}-${target.arch}:`, error)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
console.log('\n✓ All binaries built successfully!')
|
||||
}
|
||||
|
||||
buildAll()
|
||||
+11
-3
@@ -5,8 +5,14 @@
|
||||
"type": "module",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
"start": "node .",
|
||||
"dev": "nodemon ."
|
||||
"start": "NODE_ENV=production node .",
|
||||
"dev": "nodemon .",
|
||||
"build:client": "vite build",
|
||||
"build:server-bundle": "vite build --config vite.config.server.js",
|
||||
"build:server-binary": "node build.js",
|
||||
"build:server": "pnpm build:server-bundle && pnpm build:server-binary",
|
||||
"build": "pnpm build:client && pnpm build:server",
|
||||
"preview": "NODE_ENV=production node ."
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -34,6 +40,8 @@
|
||||
"ws": "^8.11.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nodemon": "^3.1.11"
|
||||
"nexe": "5.0.0-beta.4",
|
||||
"nodemon": "^3.1.11",
|
||||
"vite": "^7.2.7"
|
||||
}
|
||||
}
|
||||
Generated
+3379
File diff suppressed because it is too large.
Load diff
@@ -1,6 +1,8 @@
|
||||
import { WebSocketServer } from 'ws'
|
||||
import express from 'express'
|
||||
import os from 'os'
|
||||
import { fileURLToPath } from 'url'
|
||||
import { dirname, join } from 'path'
|
||||
|
||||
import env from './env.js'
|
||||
import logger from './logger.js'
|
||||
@@ -10,15 +12,44 @@ import Qr from './backend/Qr.js'
|
||||
import Queue from './backend/Queue.js'
|
||||
import Board from './backend/Board.js'
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url)
|
||||
const __dirname = dirname(__filename)
|
||||
|
||||
const app = express()
|
||||
|
||||
app.use(express.static('public'))
|
||||
// Determine if we're in production (built) or development
|
||||
const isProduction = process.env.NODE_ENV === 'production'
|
||||
const pagesDir = isProduction ? 'dist' : 'src/pages'
|
||||
|
||||
// Serve pages from /pages directory with clean URLs
|
||||
// When running as nexe binary, use process.cwd() as base path
|
||||
// Otherwise use __dirname (for normal node execution)
|
||||
const isNexeBinary = process.argv[0].includes('songdash')
|
||||
const basePath = isNexeBinary ? process.cwd() : __dirname
|
||||
|
||||
// Serve static files from public directory
|
||||
app.use(express.static(join(basePath, 'public')))
|
||||
|
||||
// In development, also serve src directory for Vite assets
|
||||
if (!isProduction) {
|
||||
app.use('/src', express.static(join(basePath, 'src')))
|
||||
// Serve styles and scripts directly for relative imports from HTML
|
||||
app.use('/styles', express.static(join(basePath, 'src/styles')))
|
||||
app.use('/scripts', express.static(join(basePath, 'src/scripts')))
|
||||
}
|
||||
|
||||
// Serve built pages from /dist in production
|
||||
if (isProduction) {
|
||||
app.use(express.static(join(basePath, 'dist')))
|
||||
}
|
||||
|
||||
// Serve pages with clean URLs
|
||||
app.get('/:page', (req, res, next) => {
|
||||
const allowedPages = ['host', 'player', 'tv', 'debug']
|
||||
if (allowedPages.includes(req.params.page)) {
|
||||
res.sendFile(`pages/${req.params.page}.html`, { root: '.' })
|
||||
const filePath = isProduction
|
||||
? join(basePath, 'dist', `${req.params.page}.html`)
|
||||
: join(basePath, pagesDir, `${req.params.page}.html`)
|
||||
res.sendFile(filePath)
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>SongDash Debug</title>
|
||||
<link rel="stylesheet" href="../styles/debug.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>SongDash Debug Panel <span class="timestamp" id="timestamp">--</span></h1>
|
||||
|
||||
<div class="section">
|
||||
<h2>Music Status</h2>
|
||||
<div class="key-value">
|
||||
<div class="key">Status:</div>
|
||||
<div class="value"><span id="music-status" class="status">--</span></div>
|
||||
</div>
|
||||
<div class="key-value">
|
||||
<div class="key">Platform:</div>
|
||||
<div class="value" id="music-platform">--</div>
|
||||
</div>
|
||||
<div class="key-value">
|
||||
<div class="key">Listeners:</div>
|
||||
<div class="value" id="music-listeners">--</div>
|
||||
</div>
|
||||
<div class="key-value">
|
||||
<div class="key">Metadata:</div>
|
||||
<div class="value">
|
||||
<div id="music-metadata-author">--</div>
|
||||
<div id="music-metadata-track">--</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2>Queue (<span id="queue-length">0</span> players)</h2>
|
||||
<table id="queue-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Pos</th>
|
||||
<th>IP</th>
|
||||
<th>Nick</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="queue-body">
|
||||
<tr>
|
||||
<td colspan="4" class="empty">No players in queue</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2>Scoreboard (<span id="board-total">0</span> players)</h2>
|
||||
<table id="board-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>IP</th>
|
||||
<th>Nick</th>
|
||||
<th>Score</th>
|
||||
<th>Connected</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="board-body">
|
||||
<tr>
|
||||
<td colspan="4" class="empty">No scores recorded</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2>Clients (<span id="client-count">0</span> total)</h2>
|
||||
<table id="client-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>IP</th>
|
||||
<th>Type</th>
|
||||
<th>Nick</th>
|
||||
<th>User-Agent</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="client-body">
|
||||
<tr>
|
||||
<td colspan="4" class="empty">No clients connected</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<script src="/socket.js"></script>
|
||||
<script type="module" src="../scripts/debug.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,57 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
||||
<title>Host - Jaka To Melodia</title>
|
||||
|
||||
<link rel="stylesheet" href="/pattern.css" />
|
||||
<link rel="stylesheet" href="../styles/host.css" />
|
||||
</head>
|
||||
|
||||
<body class="patterned">
|
||||
<div class="container">
|
||||
<h1>Host Panel</h1>
|
||||
|
||||
<div class="track-info">
|
||||
<div class="track" id="track">—</div>
|
||||
<div class="artist" id="artist">—</div>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<div class="section-title">Playback</div>
|
||||
<div class="button-group">
|
||||
<button onclick="socket.host('play')">Play</button>
|
||||
<button onclick="socket.host('pause')">Pause</button>
|
||||
<button onclick="socket.host('next')">Next</button>
|
||||
<button onclick="socket.host('clear')">Clear</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<div class="section-title">Points</div>
|
||||
<div class="button-group">
|
||||
<button onclick="socket.host('points', { points: 0.5 })">+0.5</button>
|
||||
<button onclick="socket.host('points', { points: 1 })">+1</button>
|
||||
<button onclick="socket.host('points', { points: 2 })">+2</button>
|
||||
<button onclick="socket.host('nextPlayer')">Next Player</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<div class="section-title">QR Code</div>
|
||||
<div class="button-group">
|
||||
<button onclick="socket.host('showQr', { show: true })">Show QR</button>
|
||||
<button onclick="socket.host('showQr', { show: false })">Hide QR</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/socket.js"></script>
|
||||
<script type="module" src="../scripts/host.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,32 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
||||
<title>Player - Jaka To Melodia</title>
|
||||
|
||||
<link rel="stylesheet" href="/pattern.css" />
|
||||
<link rel="stylesheet" href="../styles/player.css" />
|
||||
</head>
|
||||
|
||||
<body class="patterned">
|
||||
<!-- <div id="score">
|
||||
<span>Punkty:</span>
|
||||
<span id="points">0</span>
|
||||
</div> -->
|
||||
|
||||
<input type="text" id="nick" placeholder="nick" maxlength="20" />
|
||||
|
||||
<button>
|
||||
<!-- <img src="twerk.gif" alt="doopa" /> -->
|
||||
</button>
|
||||
|
||||
<script src="/wakelock.js"></script>
|
||||
<script src="/socket.js"></script>
|
||||
<script type="module" src="../scripts/player.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,61 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
||||
<title>TV - Jaka To Melodia</title>
|
||||
|
||||
<link rel="stylesheet" href="/common.css" />
|
||||
<link rel="stylesheet" href="/pattern.css" />
|
||||
<link rel="stylesheet" href="/loader.css" />
|
||||
<link rel="stylesheet" href="../styles/tv.css" />
|
||||
</head>
|
||||
|
||||
<body class="patterned">
|
||||
<!-- Status Indicator -->
|
||||
<div id="status" class="status"></div>
|
||||
|
||||
<!-- Left: Queue -->
|
||||
<div class="section l">
|
||||
<div class="title">
|
||||
<i class="icon-stopwatch"></i>
|
||||
</div>
|
||||
<div id="queue">
|
||||
<!-- Example
|
||||
<div class="nick active"> </div>
|
||||
-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Right: Scoreboard -->
|
||||
<div class="section r">
|
||||
<div class="title">
|
||||
<i class="icon-award"></i>
|
||||
</div>
|
||||
<div id="scoreboard">
|
||||
<!-- Example
|
||||
<div class="item">
|
||||
<span class="rank"> </span>
|
||||
<span class="nick"> </span>
|
||||
<span class="score"> </span>
|
||||
</div>
|
||||
-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- QR Modal -->
|
||||
<div id="qr-modal">
|
||||
<div class="content">
|
||||
<img src="/qr" alt="QR Code" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/wakelock.js"></script>
|
||||
<script src="/socket.js"></script>
|
||||
<script type="module" src="../scripts/tv.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,111 @@
|
||||
const socket = new Socket('debug')
|
||||
|
||||
socket.on('update', data => {
|
||||
updateDebug(data)
|
||||
})
|
||||
|
||||
function updateDebug(data) {
|
||||
// Update timestamp
|
||||
document.getElementById('timestamp').textContent = new Date(data.timestamp).toLocaleTimeString()
|
||||
|
||||
// Update Music Status
|
||||
const musicStatus = document.getElementById('music-status')
|
||||
musicStatus.textContent = data.music.status
|
||||
musicStatus.className = 'status ' + data.music.status
|
||||
|
||||
document.getElementById('music-platform').textContent = data.music.platform || '--'
|
||||
document.getElementById('music-listeners').textContent = data.music.listenerCount
|
||||
|
||||
if (data.music.metadata && data.music.metadata.author && data.music.metadata.track) {
|
||||
const metadataText = `${data.music.metadata.author} - ${data.music.metadata.track}`
|
||||
document.getElementById('music-metadata-author').textContent = metadataText
|
||||
document.getElementById('music-metadata-track').textContent = ''
|
||||
} else {
|
||||
document.getElementById('music-metadata-author').textContent = '--'
|
||||
document.getElementById('music-metadata-track').textContent = ''
|
||||
}
|
||||
|
||||
// Update Queue
|
||||
document.getElementById('queue-length').textContent = data.queue.length
|
||||
const queueBody = document.getElementById('queue-body')
|
||||
|
||||
if (data.queue.queue.length === 0) {
|
||||
queueBody.innerHTML = '<tr><td colspan="4" class="empty">No players in queue</td></tr>'
|
||||
} else {
|
||||
queueBody.innerHTML = data.queue.queue
|
||||
.map(
|
||||
item => `
|
||||
<tr>
|
||||
<td>${item.position + 1}</td>
|
||||
<td>${item.ip}</td>
|
||||
<td>${item.nick || '--'}</td>
|
||||
<td>${item.isActive ? '<span class="status active">ACTIVE</span>' : ''}</td>
|
||||
</tr>
|
||||
`
|
||||
)
|
||||
.join('')
|
||||
}
|
||||
|
||||
// Update Scoreboard
|
||||
document.getElementById('board-total').textContent = data.board.totalPlayers
|
||||
const boardBody = document.getElementById('board-body')
|
||||
|
||||
if (data.board.scores.length === 0) {
|
||||
boardBody.innerHTML = '<tr><td colspan="4" class="empty">No scores recorded</td></tr>'
|
||||
} else {
|
||||
boardBody.innerHTML = data.board.scores
|
||||
.map(
|
||||
item => `
|
||||
<tr>
|
||||
<td>${item.ip}</td>
|
||||
<td>${item.nick}</td>
|
||||
<td>${item.score}</td>
|
||||
<td><span class="status ${item.connected ? 'connected' : 'disconnected'}">${
|
||||
item.connected ? 'YES' : 'NO'
|
||||
}</span></td>
|
||||
</tr>
|
||||
`
|
||||
)
|
||||
.join('')
|
||||
}
|
||||
|
||||
// Update Clients
|
||||
document.getElementById('client-count').textContent = data.client.clients.length
|
||||
const clientBody = document.getElementById('client-body')
|
||||
|
||||
if (data.client.clients.length === 0) {
|
||||
clientBody.innerHTML = '<tr><td colspan="4" class="empty">No clients connected</td></tr>'
|
||||
} else {
|
||||
// Sort clients: special types (tv, host, debug) first, then players
|
||||
const specialTypes = ['tv', 'host', 'debug']
|
||||
const sortedClients = [...data.client.clients].sort((a, b) => {
|
||||
const aSpecial = specialTypes.includes(a.type)
|
||||
const bSpecial = specialTypes.includes(b.type)
|
||||
if (aSpecial && !bSpecial) return -1
|
||||
if (!aSpecial && bSpecial) return 1
|
||||
return 0
|
||||
})
|
||||
|
||||
clientBody.innerHTML = sortedClients
|
||||
.map(item => {
|
||||
let uaDisplay = '--'
|
||||
let uaTitle = '--'
|
||||
if (item.userAgent) {
|
||||
uaDisplay = `${item.userAgent.browser || 'Unknown'} / ${item.userAgent.os || 'Unknown'} / ${
|
||||
item.userAgent.device
|
||||
}`
|
||||
uaTitle = item.userAgent.raw
|
||||
}
|
||||
const typeClass = specialTypes.includes(item.type) ? `type-${item.type}` : ''
|
||||
return `
|
||||
<tr>
|
||||
<td>${item.ip}</td>
|
||||
<td class="${typeClass}">${item.type || '--'}</td>
|
||||
<td>${item.nick || '--'}</td>
|
||||
<td title="${uaTitle}">${uaDisplay}</td>
|
||||
</tr>
|
||||
`
|
||||
})
|
||||
.join('')
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// Create socket and expose globally for inline onclick handlers
|
||||
window.socket = new Socket('host')
|
||||
|
||||
const artistElement = document.querySelector('#artist')
|
||||
const trackElement = document.querySelector('#track')
|
||||
|
||||
// Use custom event listener for metadata updates
|
||||
socket.on('metadata', metadata => {
|
||||
artistElement.textContent = metadata.author
|
||||
trackElement.textContent = metadata.track
|
||||
})
|
||||
@@ -0,0 +1,31 @@
|
||||
const socket = new Socket('player')
|
||||
|
||||
requestWakeLock()
|
||||
|
||||
// Cache DOM elements
|
||||
const nodeButton = document.querySelector('button'),
|
||||
nodeNick = document.querySelector('#nick'),
|
||||
nodePoints = document.querySelector('#points')
|
||||
|
||||
// Initialize nickname
|
||||
const savedNick = localStorage.getItem('nick') || ''
|
||||
nodeNick.value = savedNick
|
||||
socket.player('setNick', { nick: savedNick })
|
||||
|
||||
// Handle button press
|
||||
nodeButton.addEventListener('mousedown', () => socket.player('enter'))
|
||||
nodeButton.addEventListener('touchstart', () => socket.player('enter'), { passive: true })
|
||||
|
||||
// Handle nickname changes
|
||||
const setNick = e => {
|
||||
const nick = e.target.value.trim().toLowerCase()
|
||||
socket.player('setNick', { nick })
|
||||
localStorage.setItem('nick', nick)
|
||||
}
|
||||
|
||||
nodeNick.addEventListener('change', setNick)
|
||||
|
||||
// // Update points display using custom event listener
|
||||
// socket.on('points', points => {
|
||||
// nodePoints.textContent = points
|
||||
// })
|
||||
@@ -0,0 +1,72 @@
|
||||
// SETUP
|
||||
const statuses = {
|
||||
paused: '<i class="icon-pause-circled"></i>',
|
||||
playing: '<i class="icon-play-circled"></i>',
|
||||
waiting: '<i class="icon-stop-circled"></i>',
|
||||
}
|
||||
|
||||
const nodeStatus = document.querySelector('#status'),
|
||||
nodeQueue = document.querySelector('#queue'),
|
||||
nodeScore = document.querySelector('#scoreboard'),
|
||||
nodeQrModal = document.querySelector('#qr-modal')
|
||||
|
||||
const socket = new Socket('tv')
|
||||
|
||||
var localStatus = 'waiting',
|
||||
localQueue = [],
|
||||
localActive = 0
|
||||
|
||||
function setStatus(status = 'waiting') {
|
||||
const patternColors = {
|
||||
playing: { fg: '#18dd5c', bg: '#1bc957' },
|
||||
paused: { fg: '#82abdd', bg: '#88b2e3' },
|
||||
waiting: { fg: '#9e82dd', bg: '#ab91e5' },
|
||||
}
|
||||
|
||||
console.info('status', status)
|
||||
|
||||
nodeStatus.innerHTML = statuses[status]
|
||||
document.body.style.setProperty('--fgcolor', patternColors[status].fg)
|
||||
document.body.style.setProperty('--bgcolor', patternColors[status].bg)
|
||||
}
|
||||
|
||||
function setQueue(queue, active = 0) {
|
||||
nodeQueue.innerHTML = queue
|
||||
.map((nick, i) => `<div class="nick ${i == active ? 'active' : ''}">${nick}</div>`)
|
||||
.join('')
|
||||
}
|
||||
|
||||
function showQrModal(show = true) {
|
||||
if (show) nodeQrModal.classList.add('show')
|
||||
else nodeQrModal.classList.remove('show')
|
||||
}
|
||||
|
||||
function setScoreboard(scoreboard) {
|
||||
const sorted = [...scoreboard].sort((a, b) => b.score - a.score)
|
||||
|
||||
const icon = '<i class="icon-award-1"></i>'
|
||||
|
||||
nodeScore.innerHTML = sorted
|
||||
.map((player, i) => {
|
||||
return `<div class="item">
|
||||
<span class="rank">${i < 3 ? icon : `#${i + 1}`}</span>
|
||||
<span class="nick">${player.nick || '---'}</span>
|
||||
<span class="score">${player.score}</span>
|
||||
</div>`
|
||||
})
|
||||
.join('')
|
||||
}
|
||||
|
||||
// Initialize
|
||||
requestWakeLock()
|
||||
setStatus()
|
||||
|
||||
socket.on('update', ({ board, active, queue, status }) => {
|
||||
setQueue(queue, active)
|
||||
setStatus(status)
|
||||
setScoreboard(board)
|
||||
})
|
||||
|
||||
socket.on('showQr', data => {
|
||||
showQrModal(data.show)
|
||||
})
|
||||
@@ -0,0 +1,148 @@
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Courier New', monospace;
|
||||
background: #1a1a1a;
|
||||
color: #e0e0e0;
|
||||
padding: 10px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 16px;
|
||||
margin-bottom: 10px;
|
||||
color: #00ff00;
|
||||
border-bottom: 1px solid #333;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 14px;
|
||||
margin: 15px 0 5px 0;
|
||||
color: #00aaff;
|
||||
}
|
||||
|
||||
.section {
|
||||
margin-bottom: 15px;
|
||||
border: 1px solid #333;
|
||||
padding: 10px;
|
||||
background: #0a0a0a;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin: 5px 0;
|
||||
}
|
||||
|
||||
th,
|
||||
td {
|
||||
text-align: left;
|
||||
padding: 4px 8px;
|
||||
border: 1px solid #333;
|
||||
}
|
||||
|
||||
th {
|
||||
background: #222;
|
||||
color: #ffaa00;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
td {
|
||||
background: #111;
|
||||
}
|
||||
|
||||
.status {
|
||||
display: inline-block;
|
||||
padding: 2px 6px;
|
||||
border-radius: 3px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.status.connected {
|
||||
background: #004400;
|
||||
color: #00ff00;
|
||||
}
|
||||
|
||||
.status.disconnected {
|
||||
background: #440000;
|
||||
color: #ff0000;
|
||||
}
|
||||
|
||||
.status.playing {
|
||||
background: #004400;
|
||||
color: #00ff00;
|
||||
}
|
||||
|
||||
.status.paused {
|
||||
background: #444400;
|
||||
color: #ffff00;
|
||||
}
|
||||
|
||||
.status.waiting {
|
||||
background: #444444;
|
||||
color: #888888;
|
||||
}
|
||||
|
||||
.status.active {
|
||||
background: #000044;
|
||||
color: #00aaff;
|
||||
}
|
||||
|
||||
.type-tv {
|
||||
background: #440044;
|
||||
color: #ff00ff;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.type-host {
|
||||
background: #004444;
|
||||
color: #00ffff;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.type-debug {
|
||||
background: #444400;
|
||||
color: #ffff00;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.timestamp {
|
||||
float: right;
|
||||
color: #666;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.key-value {
|
||||
display: grid;
|
||||
grid-template-columns: 150px 1fr;
|
||||
gap: 5px;
|
||||
margin: 3px 0;
|
||||
}
|
||||
|
||||
.key {
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.value {
|
||||
color: #e0e0e0;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.empty {
|
||||
color: #666;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.json {
|
||||
background: #000;
|
||||
border: 1px solid #333;
|
||||
padding: 5px;
|
||||
margin: 5px 0;
|
||||
overflow-x: auto;
|
||||
font-size: 11px;
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
--fgcolor: #e77021;
|
||||
--bgcolor: #f97a1e;
|
||||
--pattern: 22px;
|
||||
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.container {
|
||||
width: 100%;
|
||||
max-width: 600px;
|
||||
border-radius: 1rem;
|
||||
padding: 2rem;
|
||||
background: #1a1a1a;
|
||||
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
|
||||
}
|
||||
|
||||
h1 {
|
||||
text-align: center;
|
||||
margin-bottom: 1.5rem;
|
||||
color: #f0f0f0;
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
.track-info {
|
||||
background: var(--bgcolor);
|
||||
border-radius: 0.75rem;
|
||||
padding: 1.5rem;
|
||||
margin-bottom: 2rem;
|
||||
color: white;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.track-info .artist {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 600;
|
||||
margin-bottom: 0.5rem;
|
||||
opacity: 0.95;
|
||||
}
|
||||
|
||||
.track-info .track {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.section {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.05em;
|
||||
color: #999;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
|
||||
.button-group {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
button {
|
||||
padding: 1rem;
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
color: white;
|
||||
background: var(--bgcolor);
|
||||
border: none;
|
||||
border-radius: 0.5rem;
|
||||
cursor: pointer;
|
||||
transition: transform 0.2s, box-shadow 0.2s;
|
||||
box-shadow: 0 4px 12px rgba(255, 68, 68, 0.4);
|
||||
}
|
||||
|
||||
button:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 6px 20px rgba(255, 68, 68, 0.6);
|
||||
}
|
||||
|
||||
button:active {
|
||||
transform: translateY(0);
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
body {
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
|
||||
--fgcolor: #e7213b;
|
||||
--bgcolor: #b93834;
|
||||
--pattern: 22px;
|
||||
}
|
||||
|
||||
button {
|
||||
width: calc(100vw - 2rem);
|
||||
height: calc(100vw - 2rem);
|
||||
|
||||
border-radius: 100%;
|
||||
margin: 1rem;
|
||||
background-color: #ee1020;
|
||||
user-select: none;
|
||||
border-width: 4px;
|
||||
}
|
||||
|
||||
button > img {
|
||||
height: 50%;
|
||||
transition: 0.2s;
|
||||
}
|
||||
|
||||
button:active > img {
|
||||
height: 60%;
|
||||
transform: skewx(-49deg);
|
||||
}
|
||||
|
||||
button:active {
|
||||
background-color: #bb1020;
|
||||
}
|
||||
|
||||
input {
|
||||
width: calc(100vw - 2rem);
|
||||
box-sizing: border-box;
|
||||
margin: 1rem;
|
||||
margin-bottom: 0;
|
||||
font-size: 1rem;
|
||||
text-align: center;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
#score {
|
||||
font-family: monospace;
|
||||
box-sizing: border-box;
|
||||
padding: 1em;
|
||||
background-color: #fff6;
|
||||
font-size: 1rem;
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
body {
|
||||
height: 100vh;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
--pattern: 22px;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.section {
|
||||
flex: 1;
|
||||
padding: 2rem;
|
||||
overflow-y: auto;
|
||||
background: #0005;
|
||||
--margin: 1em;
|
||||
margin: var(--margin);
|
||||
border-radius: 1em;
|
||||
}
|
||||
|
||||
.section.l {
|
||||
margin-right: calc(var(--margin) / 2);
|
||||
}
|
||||
|
||||
.section.r {
|
||||
margin-left: calc(var(--margin) / 2);
|
||||
}
|
||||
|
||||
.section .title {
|
||||
font-size: 2.5rem;
|
||||
font-weight: bold;
|
||||
margin-bottom: 1.5rem;
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
font-family: monospace;
|
||||
border-bottom: 1px solid #fff3;
|
||||
padding-bottom: 0.5em;
|
||||
}
|
||||
|
||||
#status {
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
z-index: -1;
|
||||
pointer-events: none;
|
||||
font-size: 500px;
|
||||
--opacity: 0.25;
|
||||
text-shadow: 0 0 20px rgba(0, 0, 0, var(--opacity));
|
||||
color: rgba(0, 0, 0, var(--opacity));
|
||||
}
|
||||
|
||||
#queue {
|
||||
font-size: 30px;
|
||||
font-family: monospace;
|
||||
text-align: left;
|
||||
counter-reset: poz;
|
||||
}
|
||||
|
||||
#queue>.nick {
|
||||
display: flex;
|
||||
padding: 0.8rem 1.5rem;
|
||||
margin: 0.5rem 0;
|
||||
background-color: rgba(255, 255, 255, 0.15);
|
||||
border-radius: 0.5rem;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#queue>.nick::before {
|
||||
counter-increment: poz;
|
||||
content: '#' counter(poz) ' ';
|
||||
font-weight: bold;
|
||||
color: #ccc;
|
||||
padding-right: 1em;
|
||||
width: 1.5em;
|
||||
}
|
||||
|
||||
#queue>img {
|
||||
height: 10vh;
|
||||
}
|
||||
|
||||
#queue .nick.active {
|
||||
outline: 2px solid #fff;
|
||||
}
|
||||
|
||||
#qr-modal {
|
||||
display: none;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.9);
|
||||
z-index: 1000;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
#qr-modal.show {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
#qr-modal .content {
|
||||
background-color: white;
|
||||
padding: 2rem;
|
||||
border-radius: 1rem;
|
||||
text-align: center;
|
||||
max-width: 90vw;
|
||||
max-height: 90vh;
|
||||
}
|
||||
|
||||
#qr-modal .content img {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
|
||||
#scoreboard {
|
||||
width: 100%;
|
||||
font-size: 1.5rem;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
#scoreboard .item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 0.8rem 1.5rem;
|
||||
margin: 0.5rem 0;
|
||||
background-color: rgba(255, 255, 255, 0.15);
|
||||
border-radius: 0.5rem;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#scoreboard .item .rank i {
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
#scoreboard .item:nth-child(1) .rank {
|
||||
color: gold;
|
||||
}
|
||||
|
||||
#scoreboard .item:nth-child(2) .rank {
|
||||
color: silver;
|
||||
}
|
||||
|
||||
#scoreboard .item:nth-child(3) .rank {
|
||||
color: #cd7f32;
|
||||
/* Bronze */
|
||||
}
|
||||
|
||||
#scoreboard .item>.rank {
|
||||
font-weight: bold;
|
||||
margin-right: 1rem;
|
||||
min-width: 2.5rem;
|
||||
}
|
||||
|
||||
#scoreboard .item>.nick {
|
||||
flex: 1;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
#scoreboard .item>.score {
|
||||
font-weight: bold;
|
||||
min-width: 3rem;
|
||||
text-align: right;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import { resolve } from 'path'
|
||||
|
||||
export default defineConfig({
|
||||
root: 'src/pages',
|
||||
build: {
|
||||
outDir: '../../dist',
|
||||
emptyOutDir: true,
|
||||
rollupOptions: {
|
||||
input: {
|
||||
debug: resolve(__dirname, 'src/pages/debug.html'),
|
||||
host: resolve(__dirname, 'src/pages/host.html'),
|
||||
player: resolve(__dirname, 'src/pages/player.html'),
|
||||
tv: resolve(__dirname, 'src/pages/tv.html'),
|
||||
},
|
||||
},
|
||||
// Inline assets to reduce HTTP requests
|
||||
assetsInlineLimit: 10000, // 10kb - inline smaller assets
|
||||
},
|
||||
server: {
|
||||
port: 5173,
|
||||
open: false,
|
||||
},
|
||||
publicDir: '../../public',
|
||||
})
|
||||
@@ -0,0 +1,25 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import { resolve } from 'path'
|
||||
|
||||
export default defineConfig({
|
||||
build: {
|
||||
ssr: true,
|
||||
outDir: 'dist-server',
|
||||
emptyOutDir: true,
|
||||
rollupOptions: {
|
||||
input: './server.js',
|
||||
output: {
|
||||
format: 'cjs', // CommonJS for nexe compatibility
|
||||
entryFileNames: 'server.cjs',
|
||||
},
|
||||
},
|
||||
target: 'node14',
|
||||
minify: false, // Keep readable for debugging
|
||||
},
|
||||
ssr: {
|
||||
// Bundle most dependencies, but exclude native modules
|
||||
noExternal: true,
|
||||
// Keep native/binary modules external for nexe to handle
|
||||
external: ['ws'],
|
||||
},
|
||||
})
|
||||
Reference in new issue
Block a user