feat: Remove PWA and TWA features
This commit is contained in:
@@ -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"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@@ -6,21 +6,13 @@
|
|||||||
<base href="/" />
|
<base href="/" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<link rel="icon" type="image/svg+xml" href="./logo.svg" />
|
<link rel="icon" type="image/svg+xml" href="./logo.svg" />
|
||||||
<link rel="manifest" href="./manifest.json" />
|
|
||||||
<meta name="theme-color" content="#f3d5a3" />
|
<meta name="theme-color" content="#f3d5a3" />
|
||||||
<title>Bun + React</title>
|
<title>Bun + React</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="root"></div>
|
<div id="root"></div>
|
||||||
<script type="module" src="/src/frontend.tsx"></script>
|
<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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
25
src/index.ts
25
src/index.ts
@@ -17,14 +17,7 @@ if (!isProduction) {
|
|||||||
|
|
||||||
// Serve PWA/TWA assets in dev (root and nested path support)
|
// Serve PWA/TWA assets in dev (root and nested path support)
|
||||||
const servePwaAsset = (srcPath: string) => () => Bun.file(srcPath);
|
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 }) => {
|
app.post("/__open-in-editor", ({ body }) => {
|
||||||
const { relativePath, lineNumber, columnNumber } = body as {
|
const { relativePath, lineNumber, columnNumber } = body as {
|
||||||
@@ -54,10 +47,7 @@ if (!isProduction) {
|
|||||||
!pathname.startsWith("/@") &&
|
!pathname.startsWith("/@") &&
|
||||||
!pathname.startsWith("/inspector") &&
|
!pathname.startsWith("/inspector") &&
|
||||||
!pathname.startsWith("/__open-stack-frame-in-editor") &&
|
!pathname.startsWith("/__open-stack-frame-in-editor") &&
|
||||||
!pathname.startsWith("/manifest.json") &&
|
) {
|
||||||
!pathname.startsWith("/sw.js") &&
|
|
||||||
!pathname.startsWith("/.well-known/"))
|
|
||||||
) {
|
|
||||||
try {
|
try {
|
||||||
const htmlPath = path.resolve("src/index.html");
|
const htmlPath = path.resolve("src/index.html");
|
||||||
let html = fs.readFileSync(htmlPath, "utf-8");
|
let html = fs.readFileSync(htmlPath, "utf-8");
|
||||||
@@ -150,10 +140,7 @@ if (!isProduction) {
|
|||||||
|
|
||||||
// 1.1 Special handling for PWA/TWA assets that might not be in dist (since we use custom bun build)
|
// 1.1 Special handling for PWA/TWA assets that might not be in dist (since we use custom bun build)
|
||||||
if (
|
if (
|
||||||
pathname === "/manifest.json" ||
|
) {
|
||||||
pathname === "/sw.js" ||
|
|
||||||
pathname === "/.well-known/assetlinks.json"
|
|
||||||
) {
|
|
||||||
const srcPath = path.join("src", pathname);
|
const srcPath = path.join("src", pathname);
|
||||||
if (fs.existsSync(srcPath)) {
|
if (fs.existsSync(srcPath)) {
|
||||||
filePath = srcPath;
|
filePath = srcPath;
|
||||||
@@ -175,12 +162,10 @@ if (!isProduction) {
|
|||||||
}
|
}
|
||||||
// Special handling for PWA files in src
|
// Special handling for PWA files in src
|
||||||
else if (
|
else if (
|
||||||
filename === "manifest.json" ||
|
pathname.includes("assetlinks.json")
|
||||||
filename === "sw.js" ||
|
|
||||||
pathname.includes("assetlinks.json")
|
|
||||||
) {
|
) {
|
||||||
const srcFilename = pathname.includes("assetlinks.json")
|
const srcFilename = pathname.includes("assetlinks.json")
|
||||||
? ".well-known/assetlinks.json"
|
|
||||||
: filename;
|
: filename;
|
||||||
const fallbackSrcPath = path.join("src", srcFilename);
|
const fallbackSrcPath = path.join("src", srcFilename);
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -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"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
24
src/sw.js
24
src/sw.js
@@ -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);
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
@@ -40,8 +40,8 @@ export async function createVite() {
|
|||||||
"react",
|
"react",
|
||||||
"react-dom",
|
"react-dom",
|
||||||
"@mantine/core",
|
"@mantine/core",
|
||||||
"manifest.json",
|
|
||||||
"sw.js",
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user