feat: Remove PWA and TWA features

This commit is contained in:
2026-02-10 15:02:06 +08:00
parent 48cf6c44f5
commit 550138005b
6 changed files with 9 additions and 85 deletions

View File

@@ -1,12 +0,0 @@
[
{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "com.example.makuro",
"sha256_cert_fingerprints": [
"00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00:00"
]
}
}
]

View File

@@ -6,21 +6,13 @@
<base href="/" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/svg+xml" href="./logo.svg" />
<link rel="manifest" href="./manifest.json" />
<meta name="theme-color" content="#f3d5a3" />
<title>Bun + React</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/frontend.tsx"></script>
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/sw.js').catch(err => {
console.log('ServiceWorker registration failed: ', err);
});
});
}
</script>
</body>
</html>

View File

@@ -17,14 +17,7 @@ if (!isProduction) {
// Serve PWA/TWA assets in dev (root and nested path support)
const servePwaAsset = (srcPath: string) => () => Bun.file(srcPath);
app.get("/manifest.json", servePwaAsset("src/manifest.json"));
app.get("**/manifest.json", servePwaAsset("src/manifest.json"));
app.get("/sw.js", servePwaAsset("src/sw.js"));
app.get("**/sw.js", servePwaAsset("src/sw.js"));
app.get(
"/.well-known/assetlinks.json",
servePwaAsset("src/.well-known/assetlinks.json"),
);
app.post("/__open-in-editor", ({ body }) => {
const { relativePath, lineNumber, columnNumber } = body as {
@@ -54,9 +47,6 @@ if (!isProduction) {
!pathname.startsWith("/@") &&
!pathname.startsWith("/inspector") &&
!pathname.startsWith("/__open-stack-frame-in-editor") &&
!pathname.startsWith("/manifest.json") &&
!pathname.startsWith("/sw.js") &&
!pathname.startsWith("/.well-known/"))
) {
try {
const htmlPath = path.resolve("src/index.html");
@@ -150,9 +140,6 @@ if (!isProduction) {
// 1.1 Special handling for PWA/TWA assets that might not be in dist (since we use custom bun build)
if (
pathname === "/manifest.json" ||
pathname === "/sw.js" ||
pathname === "/.well-known/assetlinks.json"
) {
const srcPath = path.join("src", pathname);
if (fs.existsSync(srcPath)) {
@@ -175,12 +162,10 @@ if (!isProduction) {
}
// Special handling for PWA files in src
else if (
filename === "manifest.json" ||
filename === "sw.js" ||
pathname.includes("assetlinks.json")
) {
const srcFilename = pathname.includes("assetlinks.json")
? ".well-known/assetlinks.json"
: filename;
const fallbackSrcPath = path.join("src", srcFilename);
if (

View File

@@ -1,17 +0,0 @@
{
"name": "Darmasaba Dashboard Noc",
"short_name": "Darmasaba",
"description": "A high-performance full-stack React template",
"start_url": "/",
"display": "standalone",
"background_color": "#1a1a1a",
"theme_color": "#f3d5a3",
"icons": [
{
"src": "/logo.svg",
"sizes": "any",
"type": "image/svg+xml",
"purpose": "any maskable"
}
]
}

View File

@@ -1,24 +0,0 @@
const CACHE_NAME = "darmasaba-v1";
const ASSETS = ["/", "/index.html", "/logo.svg"];
self.addEventListener("install", (event) => {
event.waitUntil(
caches.open(CACHE_NAME).then((cache) => {
console.log("SW: Pre-caching assets");
return cache.addAll(ASSETS).catch((err) => {
console.error(
"SW: Pre-cache failed (likely due to Vary header or missing file):",
err,
);
});
}),
);
});
self.addEventListener("fetch", (event) => {
event.respondWith(
caches.match(event.request).then((response) => {
return response || fetch(event.request);
}),
);
});

View File

@@ -40,8 +40,8 @@ export async function createVite() {
"react",
"react-dom",
"@mantine/core",
"manifest.json",
"sw.js",
],
},
});