chore(publish): replace source tree with static export at repo root
Publish the prerendered static export (index.html, 404.html, cinema/,
c/, about/, for-cinemas/, for-film-lovers/, assets/, images/, og/,
sitemap.xml, robots.txt) as the site root and remove the React Router
+ Nitro source tree from this branch. Source remains available in
history at 0548772.
Note: public/sw.js here reports VERSION v2.0.5 while the removed source
tree (v2.1.0) was newer, and .gitignore was not carried over.
This commit is contained in:
1 parent
05487728a7
commit
e6c4ebff48
394 files changed
+3977
-37891
No files matched your search
@@ -1,44 +0,0 @@
|
||||
/**
|
||||
* ลงทะเบียน service worker (PWA)
|
||||
*
|
||||
* - ลงทะเบียนทุกสภาพแวดล้อม: จำเป็นเพื่อ "ยึดอำนาจ" จาก SW เวอร์ชันเก่าที่อาจค้างอยู่
|
||||
* (SW ตัวใหม่จะลบแคชเก่าทิ้งในขั้น activate)
|
||||
* - ในโหมด dev ตัว SW จะไม่แตะโมดูลของ Vite (`/app/*`, `/node_modules/*`, `/@vite/*`)
|
||||
* เพราะกฎใน public/sw.js แคชเฉพาะ `/assets/*` กับไฟล์ static เท่านั้น → HMR ทำงานปกติ
|
||||
* - ถ้ามี SW ตัวใหม่รออยู่ ให้สั่ง skipWaiting ทันที (ไม่ต้องรอปิดแท็บทั้งหมด)
|
||||
* ไม่ reload หน้าอัตโนมัติเพื่อเลี่ยงลูปตอน dev
|
||||
*/
|
||||
export function registerServiceWorker(): void {
|
||||
if (typeof navigator === "undefined" || !("serviceWorker" in navigator)) return;
|
||||
|
||||
const start = () => {
|
||||
navigator.serviceWorker
|
||||
.register("/sw.js", { scope: "/", updateViaCache: "none" })
|
||||
.then((registration) => {
|
||||
// ตรวจไฟล์ sw.js ใหม่จากเครือข่ายทุกครั้ง (ไม่ใช้ HTTP cache)
|
||||
registration.update().catch(() => undefined);
|
||||
|
||||
const promote = (worker: ServiceWorker | null) => {
|
||||
if (!worker) return;
|
||||
worker.addEventListener("statechange", () => {
|
||||
if (worker.state === "installed" && navigator.serviceWorker.controller) {
|
||||
worker.postMessage("SKIP_WAITING");
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
registration.addEventListener("updatefound", () => {
|
||||
promote(registration.installing);
|
||||
});
|
||||
|
||||
// มีตัวใหม่รออยู่แล้ว (เช่น เปิดแท็บค้างไว้ตอนปล่อยเวอร์ชัน)
|
||||
if (registration.waiting) registration.waiting.postMessage("SKIP_WAITING");
|
||||
})
|
||||
.catch(() => {
|
||||
// ลงทะเบียนไม่ได้ (เบราว์เซอร์เก่า/โหมดส่วนตัว) — เว็บยังใช้งานปกติ
|
||||
});
|
||||
};
|
||||
|
||||
if (document.readyState === "complete") start();
|
||||
else window.addEventListener("load", start, { once: true });
|
||||
}
|
||||
Reference in new issue
Block a user