Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion scripts/generate-icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ const root: string = resolve(Dirname, "..");

const svgBuffer: Buffer = readFileSync(resolve(root, "public/icons/icon.svg"));

/** Theme background matching `theme_color` / icon.svg fill (`#1a1a2e`). */
const THEME_BG = { r: 0x1a, g: 0x1a, b: 0x2e, alpha: 1 };

const density = 512;
const publicDir = resolve(root, "public");

const pngIcons: Array<{ name: string; size: number }> = [
{ name: "icons/apple-touch-icon.png", size: 180 },
{ name: "icons/icon-192.png", size: 192 },
Expand Down Expand Up @@ -37,7 +43,7 @@ writeFileSync(faviconDest, icoBuffer);
/** Branded placeholder screenshots for the Web App Manifest `screenshots` member. */
async function writeScreenshot(width: number, height: number, file: string): Promise<void> {
const iconSize = Math.round(Math.min(width, height) * 0.4);
const icon = await sharp(svg, { density }).resize(iconSize, iconSize).png().toBuffer();
const icon = await sharp(svgBuffer, { density }).resize(iconSize, iconSize).png().toBuffer();
await sharp({
create: {
width,
Expand Down
51 changes: 24 additions & 27 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,11 @@ const securityHeaders: Record<string, string> = {
"frame-ancestors 'none'",
].join("; "),
"Referrer-Policy": "strict-origin-when-cross-origin",
"Permissions-Policy": "camera=(), microphone=(), geolocation=()",
"Permissions-Policy": "camera=(self), microphone=(self), geolocation=()",
"X-Content-Type-Options": "nosniff",
"X-Frame-Options": "DENY",
};

/** Single-file mode: inline every imported asset as base64 (effectively unlimited). */
const INLINE_LIMIT_BYTES = 100 * 1024 * 1024;

/** Workbox precache ceiling — SceneryStack bundles exceed the default 2 MB limit. */
const WORKBOX_MAX_FILE_BYTES = 12 * 1024 * 1024;

Expand Down Expand Up @@ -196,15 +193,15 @@ export default defineConfig({
// biome-ignore lint/style/useNamingConvention: Web App Manifest spec requires snake_case keys
short_name: "trackLab",
description: "trackLab simulation",
categories: ["education", "science"],
categories: ["education", "science"],
// biome-ignore lint/style/useNamingConvention: Web App Manifest spec requires snake_case keys
theme_color: "#1a1a2e",
// biome-ignore lint/style/useNamingConvention: Web App Manifest spec requires snake_case keys
background_color: "#000000",
display: "standalone",
// biome-ignore lint/style/useNamingConvention: Web App Manifest spec requires snake_case keys
display_override: ["window-controls-overlay", "standalone"],
// No `orientation` — leave free so portrait-friendly sims are not forced landscape.
// biome-ignore lint/style/useNamingConvention: Web App Manifest spec requires snake_case keys
display_override: ["window-controls-overlay", "standalone"],
// No `orientation` — leave free so portrait-friendly sims are not forced landscape.
icons: [
{
src: "icons/icon-192.png",
Expand All @@ -223,25 +220,25 @@ export default defineConfig({
purpose: "maskable",
},
],
// Placeholder shots from `npm run icons`; replace with real sim screenshots before shipping.
screenshots: [
{
src: "screenshots/wide.png",
sizes: "1280x720",
type: "image/png",
// biome-ignore lint/style/useNamingConvention: Web App Manifest spec requires snake_case keys
form_factor: "wide",
label: "trackLab",
},
{
src: "screenshots/narrow.png",
sizes: "720x1280",
type: "image/png",
// biome-ignore lint/style/useNamingConvention: Web App Manifest spec requires snake_case keys
form_factor: "narrow",
label: "trackLab",
},
],
// Placeholder shots from `npm run icons`; replace with real sim screenshots before shipping.
screenshots: [
{
src: "screenshots/wide.png",
sizes: "1280x720",
type: "image/png",
// biome-ignore lint/style/useNamingConvention: Web App Manifest spec requires snake_case keys
form_factor: "wide",
label: "trackLab",
},
{
src: "screenshots/narrow.png",
sizes: "720x1280",
type: "image/png",
// biome-ignore lint/style/useNamingConvention: Web App Manifest spec requires snake_case keys
form_factor: "narrow",
label: "trackLab",
},
],
},
workbox: {
maximumFileSizeToCacheInBytes: WORKBOX_MAX_FILE_BYTES,
Expand Down