From 101e50926bc8c409bb6a9db492d600cef5dc2d30 Mon Sep 17 00:00:00 2001
From: naskya <m@naskya.net>
Date: Thu, 16 May 2024 04:12:10 +0900
Subject: [PATCH] chore: remove import assertion

---
 docs/notice-for-admins.md                     |  4 +
 packages/backend/src/server/web/manifest.json | 73 ---------------
 packages/backend/src/server/web/manifest.ts   | 93 ++++++++++++++++---
 3 files changed, 85 insertions(+), 85 deletions(-)
 delete mode 100644 packages/backend/src/server/web/manifest.json

diff --git a/docs/notice-for-admins.md b/docs/notice-for-admins.md
index 286575861a..32e23b296e 100644
--- a/docs/notice-for-admins.md
+++ b/docs/notice-for-admins.md
@@ -2,6 +2,10 @@
 
 You can skip intermediate versions when upgrading from an old version, but please read the notices and follow the instructions for each intermediate version before [upgrading](./upgrade.md).
 
+## Unreleased
+
+Firefish is now compatible with [Node v22](https://nodejs.org/en/blog/announcements/v22-release-announce).
+
 ## v20240430
 
 ### For all users
diff --git a/packages/backend/src/server/web/manifest.json b/packages/backend/src/server/web/manifest.json
deleted file mode 100644
index 9afcfb9429..0000000000
--- a/packages/backend/src/server/web/manifest.json
+++ /dev/null
@@ -1,73 +0,0 @@
-{
-	"short_name": "Firefish",
-	"name": "Firefish",
-	"description": "An open source, decentralized social media platform that's free forever!",
-	"start_url": "/",
-	"scope": "/",
-	"display": "standalone",
-	"background_color": "#1f1d2e",
-	"theme_color": "#31748f",
-	"orientation": "natural",
-	"icons": [
-		{
-			"src": "/static-assets/icons/192.png",
-			"sizes": "192x192",
-			"type": "image/png",
-			"purpose": "any"
-		},
-		{
-			"src": "/static-assets/icons/512.png",
-			"sizes": "512x512",
-			"type": "image/png",
-			"purpose": "any"
-		},
-		{
-			"src": "/static-assets/icons/maskable.png",
-			"sizes": "512x512",
-			"type": "image/png",
-			"purpose": "maskable"
-		},
-		{
-			"src": "/static-assets/icons/monochrome.png",
-			"sizes": "512x512",
-			"type": "image/png",
-			"purpose": "monochrome"
-		}
-	],
-	"share_target": {
-		"action": "/share/",
-		"params": {
-			"title": "title",
-			"text": "text",
-			"url": "url"
-		}
-	},
-	"screenshots": [
-		{
-			"src": "/static-assets/screenshots/1.webp",
-			"sizes": "1080x2340",
-			"type": "image/webp",
-			"platform": "narrow",
-			"label": "Profile page"
-		},
-		{
-			"src": "/static-assets/screenshots/2.webp",
-			"sizes": "1080x2340",
-			"type": "image/webp",
-			"platform": "narrow",
-			"label": "Posts"
-		}
-	],
-	"shortcuts": [
-		{
-			"name": "Notifications",
-			"short_name": "Notifs",
-			"url": "/my/notifications"
-		},
-		{
-			"name": "Chats",
-			"url": "/my/messaging"
-		}
-	],
-	"categories": ["social"]
-}
diff --git a/packages/backend/src/server/web/manifest.ts b/packages/backend/src/server/web/manifest.ts
index 77c8a57cf4..19c3b27ad6 100644
--- a/packages/backend/src/server/web/manifest.ts
+++ b/packages/backend/src/server/web/manifest.ts
@@ -1,27 +1,96 @@
 import type Koa from "koa";
 import { fetchMeta } from "backend-rs";
 import { config } from "@/config.js";
-import manifest from "./manifest.json" assert { type: "json" };
+
+const manifest = {
+	short_name: "Firefish",
+	name: "Firefish",
+	description: "An open source, decentralized social media platform that's free forever!",
+	start_url: "/",
+	scope: "/",
+	display: "standalone",
+	background_color: "#1f1d2e",
+	theme_color: "#31748f",
+	orientation: "natural",
+	icons: [
+		{
+			src: "/static-assets/icons/192.png",
+			sizes: "192x192",
+			type: "image/png",
+			purpose: "any"
+		},
+		{
+			src: "/static-assets/icons/512.png",
+			sizes: "512x512",
+			type: "image/png",
+			purpose: "any"
+		},
+		{
+			src: "/static-assets/icons/maskable.png",
+			sizes: "512x512",
+			type: "image/png",
+			purpose: "maskable"
+		},
+		{
+			src: "/static-assets/icons/monochrome.png",
+			sizes: "512x512",
+			type: "image/png",
+			purpose: "monochrome"
+		}
+	],
+	share_target: {
+		action: "/share/",
+		params: {
+			title: "title",
+			text: "text",
+			url: "url"
+		}
+	},
+	screenshots: [
+		{
+			src: "/static-assets/screenshots/1.webp",
+			sizes: "1080x2340",
+			type: "image/webp",
+			platform: "narrow",
+			label: "Profile page"
+		},
+		{
+			src: "/static-assets/screenshots/2.webp",
+			sizes: "1080x2340",
+			type: "image/webp",
+			platform: "narrow",
+			label: "Posts"
+		}
+	],
+	shortcuts: [
+		{
+			name: "Notifications",
+			short_name: "Notifs",
+			url: "/my/notifications"
+		},
+		{
+			name: "Chats",
+			url: "/my/messaging"
+		}
+	],
+	categories: ["social"]
+};
 
 export const manifestHandler = async (ctx: Koa.Context) => {
-	// TODO
-	//const res = structuredClone(manifest);
-	const res = JSON.parse(JSON.stringify(manifest));
+	const instance = await fetchMeta(true);
 
-	const instance = await fetchMeta(false);
-
-	res.short_name = instance.name || "Firefish";
-	res.name = instance.name || "Firefish";
-	if (instance.themeColor) res.theme_color = instance.themeColor;
-	for (const icon of res.icons) {
+	manifest.short_name = instance.name || "Firefish";
+	manifest.name = instance.name || "Firefish";
+	if (instance.themeColor) manifest.theme_color = instance.themeColor;
+	for (const icon of manifest.icons) {
 		icon.src = `${icon.src}?v=${config.version.replace(/[^0-9]/g, "")}`;
 	}
-	for (const screenshot of res.screenshots) {
+	for (const screenshot of manifest.screenshots) {
 		screenshot.src = `${screenshot.src}?v=${config.version.replace(
 			/[^0-9]/g,
 			"",
 		)}`;
 	}
 	ctx.set("Cache-Control", "max-age=300");
-	ctx.body = res;
+	ctx.body = manifest;
 };