Dateien nach "frontend" hochladen

This commit is contained in:
2026-05-25 15:55:53 +02:00
parent 2310043891
commit 3fb18d1390
4 changed files with 153 additions and 0 deletions

View File

@@ -0,0 +1,101 @@
import { writeFileSync, mkdirSync } from 'fs';
mkdirSync('./public', { recursive: true });
function crc32(buf) {
const table = new Uint32Array(256);
for (let n = 0; n < 256; n++) {
let c = n;
for (let k = 0; k < 8; k++) c = (c & 1) ? (0xedb88320 ^ (c >>> 1)) : (c >>> 1);
table[n] = c;
}
let crc = 0xffffffff;
for (const b of buf) crc = (table[(crc ^ b) & 0xff] ^ (crc >>> 8));
return ((crc ^ 0xffffffff) >>> 0);
}
function chunk(type, data) {
const t = Buffer.from(type, 'ascii');
const len = Buffer.allocUnsafe(4);
len.writeUInt32BE(data.length, 0);
const crcInput = Buffer.concat([t, data]);
const crcBuf = Buffer.allocUnsafe(4);
crcBuf.writeUInt32BE(crc32(crcInput), 0);
return Buffer.concat([len, t, data, crcBuf]);
}
function deflateStore(raw) {
// zlib header (deflate, no compression)
const header = Buffer.from([0x78, 0x01]);
const blocks = [];
const SIZE = 32768;
for (let i = 0; i < raw.length; i += SIZE) {
const slice = raw.slice(i, i + SIZE);
const last = (i + SIZE >= raw.length) ? 1 : 0;
const h = Buffer.allocUnsafe(5);
h[0] = last;
h.writeUInt16LE(slice.length, 1);
h.writeUInt16LE((~slice.length) & 0xffff, 3);
blocks.push(h, slice);
}
// Adler-32
let s1 = 1, s2 = 0;
for (const b of raw) {
s1 = (s1 + b) % 65521;
s2 = (s2 + s1) % 65521;
}
const adler = Buffer.allocUnsafe(4);
adler.writeUInt32BE(((s2 << 16) | s1) >>> 0, 0);
return Buffer.concat([header, ...blocks, adler]);
}
function makePNG(size) {
const cx = size / 2, cy = size / 2;
const outerR = size * 0.42, innerR = size * 0.30;
// IHDR
const ihdr = Buffer.allocUnsafe(13);
ihdr.writeUInt32BE(size, 0);
ihdr.writeUInt32BE(size, 4);
ihdr[8] = 8; // bit depth
ihdr[9] = 2; // RGB
ihdr[10] = ihdr[11] = ihdr[12] = 0;
// Raw pixel data (filter byte 0 per row)
const rows = [];
for (let y = 0; y < size; y++) {
const row = Buffer.allocUnsafe(1 + size * 3);
row[0] = 0; // filter none
for (let x = 0; x < size; x++) {
const dx = x - cx, dy = y - cy;
const d = Math.sqrt(dx * dx + dy * dy);
let r, g, b;
if (d < innerR) {
r = 0x4e; g = 0xcd; b = 0xc4; // teal
} else if (d < outerR) {
r = 0x1e; g = 0x6a; b = 0x65; // dark teal ring
} else {
r = 0x0d; g = 0x0d; b = 0x0f; // background
}
row[1 + x * 3] = r;
row[2 + x * 3] = g;
row[3 + x * 3] = b;
}
rows.push(row);
}
const raw = Buffer.concat(rows);
const idat = deflateStore(raw);
const sig = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
return Buffer.concat([
sig,
chunk('IHDR', ihdr),
chunk('IDAT', idat),
chunk('IEND', Buffer.alloc(0)),
]);
}
writeFileSync('./public/icon-192.png', makePNG(192));
writeFileSync('./public/icon-512.png', makePNG(512));
console.log('✅ Icons generiert: icon-192.png + icon-512.png');

28
frontend/index-2.html Normal file
View File

@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
<meta name="theme-color" content="#0d0d0f" />
<meta name="mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="apple-mobile-web-app-title" content="DickenDock" />
<link rel="manifest" href="/manifest.json" />
<link rel="apple-touch-icon" href="/icon-192.png" />
<title>Dicken Dock</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/sw.js')
.then(r => console.log('SW registriert:', r.scope))
.catch(e => console.warn('SW Fehler:', e));
});
}
</script>
</body>
</html>

17
frontend/package-2.json Normal file
View File

@@ -0,0 +1,17 @@
{
"name": "dickendock-frontend",
"version": "1.0.0",
"scripts": {
"prebuild": "node generate-icons.mjs",
"dev": "vite",
"build": "vite build"
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@vitejs/plugin-react": "^4.0.0",
"vite": "^5.0.0"
}
}

View File

@@ -0,0 +1,7 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [react()],
server: { proxy: { '/api': 'http://localhost:4000' } },
})