Files
tetrig/sw.js
tkrmagid a8ff780248 Revert to spec's free web plan + PWA install (iPhone/Android, $0)
명세서 준수: 네이티브(Flutter/Kotlin) 경로 폐기 — 유료 iOS 개발자 등록·맥이 필요해 비용 0 원칙과 명세서에 어긋남.
- app/(Flutter) 전부 제거, 원래 웹 클라이언트 복원.
- PWA 추가: manifest.webmanifest + sw.js(오프라인 캐시) + 앱 아이콘(192/512/apple-touch).
  → iPhone Safari·Android Chrome에서 '홈화면에 추가'로 전체화면 앱처럼 실행, 스토어/맥/등록비 불필요.
- Cloudflare Pages 무료 배포 대상. 서버(Workers) 계획 불변.
2026-08-22 15:08:51 +09:00

33 lines
856 B
JavaScript

// TETRIG 서비스 워커 — 오프라인 캐시 (앱처럼 설치/실행)
const CACHE = 'tetrig-v1';
const ASSETS = [
'./',
'./index.html',
'./manifest.webmanifest',
'./icon-192.png',
'./icon-512.png',
'./apple-touch-icon.png',
];
self.addEventListener('install', (e) => {
e.waitUntil(caches.open(CACHE).then((c) => c.addAll(ASSETS)));
self.skipWaiting();
});
self.addEventListener('activate', (e) => {
e.waitUntil(
caches.keys().then((keys) =>
Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k)))
)
);
self.clients.claim();
});
// 캐시 우선, 없으면 네트워크 (게임은 정적이라 오프라인 완전 동작)
self.addEventListener('fetch', (e) => {
if (e.request.method !== 'GET') return;
e.respondWith(
caches.match(e.request).then((r) => r || fetch(e.request))
);
});