| |
| |
| |
| |
|
|
| import { APP_NAME } from './app'; |
|
|
| export const MEDIA_QUERIES = { |
| DISPLAY_MODE_STANDALONE: '(display-mode: standalone)', |
| PREFERS_DARK: '(prefers-color-scheme: dark)', |
| PREFERS_LIGHT: '(prefers-color-scheme: light)' |
| } as const; |
|
|
| export const THEME_COLORS = { |
| ACCENT_BLUE: '#ff5400', |
| ACCENT_BLUE_HOVER: '#ff2a00', |
| BACKGROUND_DARK: '#140606', |
| BACKGROUND_LIGHT: '#faf8f5', |
| DARK: '#140606', |
| LIGHT: '#faf8f5', |
| TITLE_UPDATE_ALERT: { |
| BG_DARK: 'zinc-800', |
| BG_LIGHT: 'white', |
| BORDER_DARK: 'zinc-700', |
| BORDER_LIGHT: 'zinc-200', |
| TEXT_DARK: 'zinc-400', |
| TEXT_LIGHT: 'zinc-500' |
| } |
| } as const; |
|
|
| export const FAVICON_PATHS = { |
| ICO_DARK: 'favicon-dark.ico', |
| ICO_LIGHT: 'favicon.ico', |
| SVG_DARK: 'favicon-dark.svg', |
| SVG_LIGHT: 'favicon.svg' |
| } as const; |
|
|
| |
| |
| export const FAVICON_COLORS = { |
| DARK: '#fafafa', |
| LIGHT: '#111111' |
| } as const; |
|
|
| export const FAVICON_SELECTORS = { |
| ICO_48X48: 'link[rel="icon"][sizes="48x48"]', |
| SVG_ANY: 'link[rel="icon"][type="image/svg+xml"]' |
| } as const; |
|
|
| export const APPLE_ASSETS = { |
| TOUCH_ICON: 'apple-touch-icon-180x180.png' |
| } as const; |
|
|
| export const PWA_MANIFEST = { |
| background_color: THEME_COLORS.BACKGROUND_LIGHT, |
| description: 'Local AI chat interface powered by llama.cpp', |
| display: 'standalone' as const, |
| icons: [ |
| { sizes: '64x64', src: 'pwa-64x64.png', type: 'image/png' }, |
| { sizes: '192x192', src: 'pwa-192x192.png', type: 'image/png' }, |
| { purpose: 'any' as const, sizes: '512x512', src: 'pwa-512x512.png', type: 'image/png' }, |
| { |
| purpose: 'maskable' as const, |
| sizes: '512x512', |
| src: 'maskable-icon-512x512.png', |
| type: 'image/png' |
| } |
| ], |
| name: APP_NAME, |
| short_name: APP_NAME, |
| start_url: './', |
| theme_color: THEME_COLORS.BACKGROUND_LIGHT |
| }; |
|
|
| export const PWA_ICON_PATHS = { |
| MASKABLE_512: '/maskable-icon-512x512.png', |
| PWA_64: '/pwa-64x64.png', |
| PWA_192: '/pwa-192x192.png', |
| PWA_512: '/pwa-512x512.png' |
| } as const; |
|
|
| |
| export const APPLE_DEVICES = { |
| '640x1136': { dpr: 2, height: 568, width: 320 }, |
| '744x1133': { dpr: 2, height: 573, width: 376 }, |
| '750x1334': { dpr: 2, height: 667, width: 375 }, |
| '1032x1376': { dpr: 2, height: 1376, width: 1032 }, |
| |
| '1170x2532': { dpr: 3, height: 844, width: 390 }, |
| '1179x2556': { dpr: 3, height: 852, width: 393 }, |
| '1206x2622': { dpr: 3, height: 874, width: 402 }, |
| '1284x2778': { dpr: 3, height: 926, width: 428 }, |
| '1290x2796': { dpr: 3, height: 932, width: 430 }, |
| '1320x2868': { dpr: 3, height: 956, width: 440 }, |
| '1640x2360': { dpr: 2, height: 1180, width: 820 }, |
| |
| '1668x2388': { dpr: 2, height: 1194, width: 834 }, |
| '2048x2732': { dpr: 2, height: 1366, width: 1024 } |
| } as const; |
|
|
| export type AppleDeviceKey = keyof typeof APPLE_DEVICES; |
|
|
| export const PWA_FILE_PATHS = { |
| MANIFEST: '/manifest.webmanifest', |
| SERVICE_WORKER: '/sw.js', |
| VERSION: '/version.json', |
| WORKBOX: '/workbox-<hash>.js' |
| } as const; |
|
|
| |
| |
|
|
| export const PUBLIC_ENDPOINTS = [ |
| '/health', |
| '/v1/health', |
| '/models', |
| '/v1/models', |
| '/props', |
| '/metrics', |
| '/', |
| '/index.html', |
|
|
| '/favicon.ico', |
| '/favicon-dark.ico', |
| '/favicon.svg', |
| '/favicon-dark.svg', |
| '/pwa-64x64.png', |
| '/pwa-192x192.png', |
| '/pwa-512x512.png', |
| '/maskable-icon-512x512.png', |
| '/apple-touch-icon-180x180.png', |
| '/apple-splash-portrait-640x1136.png', |
| '/apple-splash-landscape-640x1136.png', |
| '/apple-splash-portrait-750x1334.png', |
| '/apple-splash-landscape-750x1334.png', |
| '/apple-splash-portrait-1170x2532.png', |
| '/apple-splash-landscape-1170x2532.png', |
| '/apple-splash-portrait-1179x2556.png', |
| '/apple-splash-landscape-1179x2556.png', |
| '/apple-splash-portrait-1206x2622.png', |
| '/apple-splash-landscape-1206x2622.png', |
| '/apple-splash-portrait-1284x2778.png', |
| '/apple-splash-landscape-1284x2778.png', |
| '/apple-splash-portrait-1290x2796.png', |
| '/apple-splash-landscape-1290x2796.png', |
| '/apple-splash-portrait-1320x2868.png', |
| '/apple-splash-landscape-1320x2868.png', |
| '/apple-splash-portrait-1488x2266.png', |
| '/apple-splash-landscape-1488x2266.png', |
| '/apple-splash-portrait-1640x2360.png', |
| '/apple-splash-landscape-1640x2360.png', |
| '/apple-splash-portrait-1668x2388.png', |
| '/apple-splash-landscape-1668x2388.png', |
| '/apple-splash-portrait-2048x2732.png', |
| '/apple-splash-landscape-2048x2732.png', |
| '/apple-splash-portrait-dark-640x1136.png', |
| '/apple-splash-landscape-dark-640x1136.png', |
| '/apple-splash-portrait-dark-750x1334.png', |
| '/apple-splash-landscape-dark-750x1334.png', |
| '/apple-splash-portrait-dark-1170x2532.png', |
| '/apple-splash-landscape-dark-1170x2532.png', |
| '/apple-splash-portrait-dark-1179x2556.png', |
| '/apple-splash-landscape-dark-1179x2556.png', |
| '/apple-splash-portrait-dark-1206x2622.png', |
| '/apple-splash-landscape-dark-1206x2622.png', |
| '/apple-splash-portrait-dark-1284x2778.png', |
| '/apple-splash-landscape-dark-1284x2778.png', |
| '/apple-splash-portrait-dark-1290x2796.png', |
| '/apple-splash-landscape-dark-1290x2796.png', |
| '/apple-splash-portrait-dark-1320x2868.png', |
| '/apple-splash-landscape-dark-1320x2868.png', |
| '/apple-splash-portrait-dark-1488x2266.png', |
| '/apple-splash-landscape-dark-1488x2266.png', |
| '/apple-splash-portrait-dark-1640x2360.png', |
| '/apple-splash-landscape-dark-1640x2360.png', |
| '/apple-splash-portrait-dark-1668x2388.png', |
| '/apple-splash-landscape-dark-1668x2388.png', |
| '/apple-splash-portrait-dark-2048x2732.png', |
| '/apple-splash-landscape-dark-2048x2732.png', |
| '/manifest.webmanifest', |
| '/sw.js', |
| '/version.json', |
| '/workbox-<hash>.js' |
| ] as const; |
| export const BUILD_CONFIG = { |
| GUIDE_COMMENT: ` |
| <!-- |
| This is a static build of the frontend. |
| It is automatically generated by the build process. |
| Do not edit this file directly. |
| To make changes, refer to the "Web UI" section in the README. |
| --> |
| `.trim(), |
| OUTPUT_DIR: './dist' |
| } as const; |
|
|
| export const REGEX_PATTERNS = { |
| HEAD_CLOSE: /\t*<\/head>/, |
| SPLASH_FILE: /^apple-splash-(portrait|landscape)-(dark-)?(\d+)x(\d+)\.png$/ |
| } as const; |
|
|
| |
| |
| export const PWA_GENERATOR_DEVICES = [ |
| 'iPhone 13', |
| 'iPhone 13 Pro', |
| 'iPhone 13 Pro Max', |
| 'iPhone 14', |
| 'iPhone 14 Plus', |
| 'iPhone 14 Pro', |
| 'iPhone 14 Pro Max', |
| 'iPhone 15', |
| 'iPhone 15 Plus', |
| 'iPhone 15 Pro', |
| 'iPhone 15 Pro Max', |
| 'iPhone 16', |
| 'iPhone 16 Plus', |
| 'iPhone 16 Pro', |
| 'iPhone 16 Pro Max', |
| 'iPhone 16e', |
| 'iPhone SE 4"', |
| 'iPhone SE 4.7"', |
| 'iPad 11"', |
| 'iPad Air 10.9"', |
| 'iPad Air 11"', |
| 'iPad Air 13"', |
| 'iPad Pro 11"', |
| 'iPad Pro 12.9"', |
| 'iPad mini 8.3"' |
| ] as const; |
|
|
| |
| |
| |
| |
| |
| export const PWA_ASSET_GENERATOR = { |
| ADD_MEDIA_SCREEN: true, |
| BASE_PATH: './', |
| DARK_PREFIX: 'dark-', |
| FAVICON_PADDING: 0.04, |
| FIT_MODE: 'contain', |
| LINK_PRESET: '2023', |
| PNG_COMPRESSION_LEVEL: 9, |
| PNG_QUALITY: 60, |
| SPLASH_PADDING: 0.75, |
| XHTML: false |
| } as const; |
|
|
| export const CACHE_SETTINGS = { |
| API_CACHE_MAX_AGE_SECONDS: 60 * 60 * 24, |
| API_CACHE_MAX_ENTRIES: 50, |
| IMMUTABLE_MAX_AGE_SECONDS: 31536000, |
| MAX_FILE_SIZE_BYTES: 10 * 1024 * 1024 |
| } as const; |
|
|
| export const GLOB_PATTERNS: string[] = [ |
| '**/*.{js,css,html,ico,svg,png,webp,woff,woff2,json,webmanifest}' |
| ]; |
|
|
| export const SW_CONFIG = { |
| CHECK_INTERVAL_MS: 60000, |
| UPDATE_FETCH_OPTIONS: { |
| CACHE: 'no-store', |
| HEADERS: { |
| CACHE: 'no-store', |
| CACHE_CONTROL: 'no-cache' |
| } |
| } |
| } as const; |
|
|
| |
| export const RUNTIME_CACHING = { |
| CACHE_NAME: 'api-cache', |
| HANDLER: 'NetworkFirst' |
| } as const; |
|
|
| |
| export const API_CACHING_PATTERNS = { |
| STATIC_API: /^\/(health|props|models|tools|slots|cors-proxy).*/, |
| V1_API: /^\/v1\/.*/ |
| } as const; |
|
|
| |
| export const PWA_KIT_OPTIONS = {} as const; |
|
|
| export const APPLE_META_TAGS = { |
| MOBILE_WEB_APP_CAPABLE: { content: 'yes', name: 'apple-mobile-web-app-capable' }, |
| MOBILE_WEB_APP_TITLE: { name: 'apple-mobile-web-app-title' }, |
| STATUS_BAR_STYLE: { content: 'black-translucent', name: 'apple-mobile-web-app-status-bar-style' } |
| } as const; |
|
|
| |
| export const SPLASH_LINK = { |
| DARK_MEDIA_SUFFIX: ' and (prefers-color-scheme: dark)', |
| HTML: '<link rel="apple-touch-startup-image"' |
| } as const; |
|
|
| |
| import type { SvelteKitPWAOptions } from '@vite-pwa/sveltekit'; |
|
|
| export const SVELTEKIT_PWA_OPTIONS: SvelteKitPWAOptions = { |
| devOptions: { |
| enabled: true, |
| suppressWarnings: true |
| }, |
|
|
| |
| kit: { |
| |
| includeVersionFile: true |
| }, |
|
|
| |
| |
| |
| manifest: PWA_MANIFEST, |
|
|
| |
| workbox: { |
| |
| |
| |
| globPatterns: GLOB_PATTERNS, |
| maximumFileSizeToCacheInBytes: CACHE_SETTINGS.MAX_FILE_SIZE_BYTES, |
|
|
| |
| |
| |
| |
| |
| |
| navigateFallback: '', |
|
|
| |
| runtimeCaching: [ |
| { |
| handler: RUNTIME_CACHING.HANDLER, |
| options: { |
| cacheName: RUNTIME_CACHING.CACHE_NAME, |
| expiration: { |
| maxAgeSeconds: CACHE_SETTINGS.API_CACHE_MAX_AGE_SECONDS, |
| maxEntries: CACHE_SETTINGS.API_CACHE_MAX_ENTRIES |
| } |
| }, |
| urlPattern: API_CACHING_PATTERNS.V1_API |
| }, |
| { |
| handler: RUNTIME_CACHING.HANDLER, |
| options: { |
| cacheName: RUNTIME_CACHING.CACHE_NAME, |
| expiration: { |
| maxAgeSeconds: CACHE_SETTINGS.API_CACHE_MAX_AGE_SECONDS, |
| maxEntries: CACHE_SETTINGS.API_CACHE_MAX_ENTRIES |
| } |
| }, |
| urlPattern: API_CACHING_PATTERNS.STATIC_API |
| } |
| ] |
| } |
| }; |
|
|