- Add web-push VAPID backend with push_subscriptions table (migration 078) - Backend push module with sendPushToUser/sendPushToRoom helpers - Push routes: GET vapid-key, POST subscribe, DELETE unsubscribe - Trigger push on new chat messages in direct/group rooms - PWA manifest, service worker, and icons (72–512px) - Frontend push lib: SW registration, subscribe/unsubscribe helpers - Push API in api.ts, SW registered in main.tsx - usePushSubscription hook for auto-subscribe on permission grant - PushPermissionRow component in ChatWidget settings view Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
23 lines
838 B
JavaScript
23 lines
838 B
JavaScript
import sharp from 'sharp'
|
|
import { mkdirSync } from 'fs'
|
|
|
|
mkdirSync('./public/icons', { recursive: true })
|
|
|
|
const sizes = [72, 96, 128, 144, 152, 180, 192, 384, 512]
|
|
|
|
const createSvg = (size) => {
|
|
const r = Math.round(size * 0.22)
|
|
const fontSize = Math.round(size * 0.36)
|
|
return `<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" viewBox="0 0 ${size} ${size}">
|
|
<rect width="${size}" height="${size}" rx="${r}" fill="#4F46E5"/>
|
|
<text x="${size/2}" y="${size/2 + fontSize*0.36}" font-family="Arial,sans-serif" font-weight="bold" font-size="${fontSize}" fill="white" text-anchor="middle">HS</text>
|
|
</svg>`
|
|
}
|
|
|
|
for (const size of sizes) {
|
|
const svg = Buffer.from(createSvg(size))
|
|
await sharp(svg).png().toFile(`./public/icons/icon-${size}.png`)
|
|
console.log(`✓ icon-${size}.png`)
|
|
}
|
|
console.log('Done!')
|