webtun 1.5.2 → 1.5.4
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/README.md +23 -5
- package/bin/webtun.js +12 -0
- package/electron/main.js +176 -0
- package/electron/preload.js +7 -0
- package/package.json +43 -4
- package/postinstall.js +38 -20
- package/public/commands.js +1 -1
- package/public/index.html +549 -177
- package/public/manifest.json +1 -1
- package/public/sw.js +16 -3
- package/server.js +719 -174
package/public/manifest.json
CHANGED
|
@@ -18,6 +18,6 @@
|
|
|
18
18
|
{ "src": "/icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "any maskable" }
|
|
19
19
|
],
|
|
20
20
|
"shortcuts": [
|
|
21
|
-
{ "name": "New Terminal", "url": "
|
|
21
|
+
{ "name": "New Terminal", "url": "/?newTerm=1", "description": "Open a new terminal session", "icons": [{ "src": "/icon-192.png", "sizes": "192x192", "type": "image/png" }] }
|
|
22
22
|
]
|
|
23
23
|
}
|
package/public/sw.js
CHANGED
|
@@ -9,7 +9,8 @@ const PRECACHE = [
|
|
|
9
9
|
|
|
10
10
|
self.addEventListener('install', e => {
|
|
11
11
|
e.waitUntil(
|
|
12
|
-
caches.open(CACHE).then(c => c.addAll(PRECACHE))
|
|
12
|
+
caches.open(CACHE).then(c => c.addAll(PRECACHE))
|
|
13
|
+
// Do not skipWaiting automatically — let activate wait for user prompt (F87)
|
|
13
14
|
);
|
|
14
15
|
});
|
|
15
16
|
|
|
@@ -33,6 +34,8 @@ self.addEventListener('fetch', e => {
|
|
|
33
34
|
|
|
34
35
|
const url = new URL(e.request.url);
|
|
35
36
|
if (url.pathname.startsWith('/api')) return;
|
|
37
|
+
if (url.pathname === '/ws' || url.pathname.startsWith('/ws')) return;
|
|
38
|
+
if (url.searchParams.has('token')) return;
|
|
36
39
|
|
|
37
40
|
// Network-First for HTML/navigation
|
|
38
41
|
const isNavigation = e.request.mode === 'navigate' || (url.pathname === '/') || (url.pathname.endsWith('.html') && e.request.mode === 'same-origin');
|
|
@@ -53,14 +56,24 @@ self.addEventListener('fetch', e => {
|
|
|
53
56
|
return;
|
|
54
57
|
}
|
|
55
58
|
|
|
56
|
-
// Cache-First for static assets
|
|
59
|
+
// Cache-First for static assets with stale-while-revalidate (max-age 7d via version bump)
|
|
57
60
|
// CDN resources are fetched from network (not precached) to avoid opaque response failures
|
|
58
61
|
e.respondWith(
|
|
59
62
|
caches.match(e.request).then(cached => {
|
|
60
|
-
if (cached)
|
|
63
|
+
if (cached) {
|
|
64
|
+
// Background revalidate without blocking
|
|
65
|
+
fetch(e.request).then(res => {
|
|
66
|
+
if (res && res.status === 200 && res.type !== 'opaque') {
|
|
67
|
+
const clone = res.clone();
|
|
68
|
+
caches.open(CACHE).then(c => { try { c.put(e.request, clone); } catch {} });
|
|
69
|
+
}
|
|
70
|
+
}).catch(()=>{});
|
|
71
|
+
return cached;
|
|
72
|
+
}
|
|
61
73
|
return fetch(e.request).then(res => {
|
|
62
74
|
if (res && res.status === 200 && res.type !== 'opaque') {
|
|
63
75
|
const clone = res.clone();
|
|
76
|
+
// Use waitUntil equivalent via open+put
|
|
64
77
|
caches.open(CACHE).then(c => { try { c.put(e.request, clone); } catch {} });
|
|
65
78
|
}
|
|
66
79
|
return res;
|