termbeam 1.11.1 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/public/sw.js DELETED
@@ -1,88 +0,0 @@
1
- const CACHE_NAME = 'termbeam-v7';
2
- const SHELL_URLS = ['/', '/terminal'];
3
-
4
- self.addEventListener('install', (event) => {
5
- event.waitUntil(caches.open(CACHE_NAME).then((cache) => cache.addAll(SHELL_URLS)));
6
- self.skipWaiting();
7
- });
8
-
9
- self.addEventListener('activate', (event) => {
10
- event.waitUntil(
11
- caches
12
- .keys()
13
- .then((keys) =>
14
- Promise.all(keys.filter((k) => k !== CACHE_NAME).map((k) => caches.delete(k))),
15
- ),
16
- );
17
- self.clients.claim();
18
- });
19
-
20
- self.addEventListener('fetch', (event) => {
21
- const url = new URL(event.request.url);
22
-
23
- // Don't cache WebSocket upgrades
24
- if (event.request.mode === 'websocket' || url.protocol === 'ws:' || url.protocol === 'wss:') {
25
- return;
26
- }
27
-
28
- // Cache-first for CDN font files (NerdFont from jsdelivr)
29
- if (url.origin !== self.location.origin) {
30
- if (url.hostname === 'cdn.jsdelivr.net' && url.pathname.endsWith('.ttf')) {
31
- event.respondWith(
32
- caches.match(event.request).then((cached) => {
33
- if (cached) return cached;
34
- return fetch(event.request).then((response) => {
35
- if (response.ok) {
36
- const clone = response.clone();
37
- caches.open(CACHE_NAME).then((cache) => cache.put(event.request, clone));
38
- }
39
- return response;
40
- });
41
- }),
42
- );
43
- }
44
- return;
45
- }
46
-
47
- // Network-first for API calls
48
- if (url.pathname.startsWith('/api/')) {
49
- event.respondWith(fetch(event.request).catch(() => caches.match(event.request)));
50
- return;
51
- }
52
-
53
- // Network-first for HTML pages (always get latest code)
54
- if (
55
- event.request.mode === 'navigate' ||
56
- event.request.headers.get('accept')?.includes('text/html')
57
- ) {
58
- event.respondWith(
59
- fetch(event.request)
60
- .then((response) => {
61
- if (response.ok) {
62
- const clone = response.clone();
63
- caches.open(CACHE_NAME).then((cache) => cache.put(event.request, clone));
64
- }
65
- return response;
66
- })
67
- .catch(() => caches.match(event.request)),
68
- );
69
- return;
70
- }
71
-
72
- // Cache-first for static assets (JS, CSS, images)
73
- event.respondWith(
74
- caches
75
- .match(event.request)
76
- .then((cached) => {
77
- if (cached) return cached;
78
- return fetch(event.request).then((response) => {
79
- if (response.ok) {
80
- const clone = response.clone();
81
- caches.open(CACHE_NAME).then((cache) => cache.put(event.request, clone));
82
- }
83
- return response;
84
- });
85
- })
86
- .catch(() => new Response('Offline', { status: 503, statusText: 'Service Unavailable' })),
87
- );
88
- });