Files
cobble/src/data/pwa-data.ts
T
tbenandClaude Opus 5.5 3b7c05bfa0 Name each install, fix the notification badge, switch to Archivo
- Settings > General: an App name (super admin) for the installed app.
  The manifest's name/short_name, the iOS head tags and the loading
  page's title use it, so two installs on one phone can be told apart.
- Notifications get a real badge (white stone silhouette): Android masks
  the badge by alpha, so the opaque app icon showed as a square.
- The loading and offline pages load the app's font.
- The font is now Archivo (variable, one request for every weight),
  matching the marketing site.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 10:17:40 +01:00

113 lines
3.1 KiB
TypeScript

import { SiteData } from "./site-data";
/**
* What makes the app installable, shared by the pages that advertise it,
* the server that serves it and the script that generates it.
*/
export const PwaStartPath = "/admin/bots";
export const PwaScope = "/";
export const PwaManifestPath = "/manifest.webmanifest";
export const PwaServiceWorkerPath = "/sw.js";
export const PwaOfflinePath = "/offline.html";
/**
* The page a browser gets instead of the app while it downloads a build
* it hasn't yet (`handlePrecacheGate`), generated like the offline page.
*/
export const PwaLoadingPath = "/loading.html";
/**
* The running build's id and files (`handle-build-info.ts`). Each build's
* `.bunext/public` files are downloaded into their own cache,
* `<prefix><build_id>`, which holds the marker once every file is in.
* `public/sw.js` repeats all three.
*/
export const PwaBuildInfoPath = "/build-info.json";
export const PwaPrecacheCachePrefix = "cobble-assets-";
export const PwaPrecacheMarkerPath = "/__cobble-precached";
export type PwaIcon = {
src: string;
sizes: string;
type: string;
purpose: "any" | "maskable";
};
/**
* Generated from `public/logos/logo.svg` by `bun run gen:favicon`.
*/
export const PwaIcons: PwaIcon[] = [
{
src: "/icons/icon-192.png",
sizes: "192x192",
type: "image/png",
purpose: "any",
},
{
src: "/icons/icon-512.png",
sizes: "512x512",
type: "image/png",
purpose: "any",
},
{
src: "/icons/maskable-192.png",
sizes: "192x192",
type: "image/png",
purpose: "maskable",
},
{
src: "/icons/maskable-512.png",
sizes: "512x512",
type: "image/png",
purpose: "maskable",
},
];
export type PwaShortcut = {
name: string;
url: string;
icons: { src: string; sizes: string; type: string }[];
};
export const PwaShortcuts: PwaShortcut[] = [
{
name: "Routines",
url: "/admin/routines",
icons: [{ src: "/icons/icon-192.png", sizes: "192x192", type: "image/png" }],
},
{
name: "Help",
url: "/admin/help",
icons: [{ src: "/icons/icon-192.png", sizes: "192x192", type: "image/png" }],
},
];
export const PwaIconPath = (name: `icon` | `maskable`, size: number) =>
`/icons/${name}-${size}.png`;
/**
* The app's install name: `SiteName` is lowercase, `PwaShortName` fits
* under an icon.
*/
export const PwaManifestName = SiteData["SiteName"];
export const PwaShortName = SiteData["SiteName"];
/**
* A notification's `badge`: the stone's white silhouette, since Android
* draws only its alpha. `public/sw.js` repeats the path.
*/
export const PwaBadgeSize = 96;
export const PwaBadgePath = `/icons/badge-${PwaBadgeSize}.png`;
/**
* What `handlePrecacheGate` swaps for the install's name in the loading
* page's title.
*/
export const PwaLoadingNamePlaceholder = "{{name}}";
/**
* The install's own name (Settings > General), so two installs on one
* phone don't both read `SiteName`. Saved in `app_settings`.
*/
export const PwaInstallNameSettingKey = "install_name";
export const PwaInstallNameMaxLength = 30;