fluxy-bot 0.10.13 → 0.10.16
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/package.json +1 -1
- package/supervisor/index.ts +22 -17
- package/supervisor/widget.js +25 -0
- package/workspace/client/public/sw.js +22 -18
package/package.json
CHANGED
package/supervisor/index.ts
CHANGED
|
@@ -58,7 +58,7 @@ const SW_JS = `// Service worker — app-shell caching + push notifications
|
|
|
58
58
|
// JS/CSS modules → stale-while-revalidate
|
|
59
59
|
// API, WebSocket, Vite internals → network-only (no cache)
|
|
60
60
|
|
|
61
|
-
var CACHE = 'fluxy-
|
|
61
|
+
var CACHE = 'fluxy-v5';
|
|
62
62
|
var HASHED_RE = new RegExp('/assets/.+-[a-zA-Z0-9]{6,}[.](js|css)$');
|
|
63
63
|
|
|
64
64
|
// Precache the HTML shell on install so the cache is never empty.
|
|
@@ -117,24 +117,29 @@ self.addEventListener('fetch', function(event) {
|
|
|
117
117
|
return;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
// Navigation
|
|
121
|
-
//
|
|
122
|
-
//
|
|
120
|
+
// Navigation: only stale-while-revalidate the dashboard root (/).
|
|
121
|
+
// /fluxy/* is a separate app — let it go to network to avoid
|
|
122
|
+
// caching the wrong HTML under the / key.
|
|
123
123
|
if (request.mode === 'navigate') {
|
|
124
124
|
console.log('[SW] navigate →', url.pathname);
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
125
|
+
if (url.pathname === '/' || url.pathname === '/index.html') {
|
|
126
|
+
event.respondWith(caches.open(CACHE).then(function(c) {
|
|
127
|
+
return c.match('/').then(function(hit) {
|
|
128
|
+
console.log('[SW] cache hit for /:', !!hit);
|
|
129
|
+
var net = fetch(request)
|
|
130
|
+
.then(function(r) {
|
|
131
|
+
console.log('[SW] network response for /:', r.status);
|
|
132
|
+
if (r.ok) c.put('/', r.clone());
|
|
133
|
+
return r;
|
|
134
|
+
})
|
|
135
|
+
.catch(function(err) { console.warn('[SW] network failed, using cache:', err.message); return hit; });
|
|
136
|
+
return hit || net;
|
|
137
|
+
});
|
|
138
|
+
}));
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
// Other navigations (/fluxy/*, etc.) — network only
|
|
142
|
+
console.log('[SW] navigate (network-only) →', url.pathname);
|
|
138
143
|
return;
|
|
139
144
|
}
|
|
140
145
|
|
package/supervisor/widget.js
CHANGED
|
@@ -145,4 +145,29 @@
|
|
|
145
145
|
var awsScript = document.createElement('script');
|
|
146
146
|
awsScript.src = '/fluxy/app-ws.js';
|
|
147
147
|
document.head.appendChild(awsScript);
|
|
148
|
+
|
|
149
|
+
// ── Splash / Service Worker upgrade logic ──────────────────────────
|
|
150
|
+
// This runs from the supervisor (always updated), so it fixes existing
|
|
151
|
+
// installs whose workspace/client/index.html is still old.
|
|
152
|
+
|
|
153
|
+
// Re-show splash before page unloads (manual refresh)
|
|
154
|
+
window.addEventListener('beforeunload', function () {
|
|
155
|
+
console.log('[widget] beforeunload — showing splash');
|
|
156
|
+
var s = document.getElementById('splash');
|
|
157
|
+
if (s) { s.style.transition = 'none'; s.style.display = 'flex'; s.style.opacity = '1'; }
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
// When a new SW takes control, show splash and reload so the new
|
|
161
|
+
// caching strategy (stale-while-revalidate) kicks in immediately.
|
|
162
|
+
if ('serviceWorker' in navigator) {
|
|
163
|
+
var swRefreshing = false;
|
|
164
|
+
navigator.serviceWorker.addEventListener('controllerchange', function () {
|
|
165
|
+
console.log('[widget] controllerchange — new SW took control, refreshing:', swRefreshing);
|
|
166
|
+
if (swRefreshing) return;
|
|
167
|
+
swRefreshing = true;
|
|
168
|
+
var s = document.getElementById('splash');
|
|
169
|
+
if (s) { s.style.transition = 'none'; s.style.display = 'flex'; s.style.opacity = '1'; }
|
|
170
|
+
location.reload();
|
|
171
|
+
});
|
|
172
|
+
}
|
|
148
173
|
})();
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// JS/CSS modules → stale-while-revalidate
|
|
7
7
|
// API, WebSocket, Vite internals → network-only (no cache)
|
|
8
8
|
|
|
9
|
-
const CACHE = 'fluxy-
|
|
9
|
+
const CACHE = 'fluxy-v5';
|
|
10
10
|
|
|
11
11
|
// Precache the HTML shell on install so the cache is never empty.
|
|
12
12
|
// Without this, the first navigation isn't intercepted (SW wasn't
|
|
@@ -64,25 +64,29 @@ self.addEventListener('fetch', (event) => {
|
|
|
64
64
|
return;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
// ── Navigation
|
|
68
|
-
//
|
|
69
|
-
//
|
|
70
|
-
// First visit has no cache → falls through to network.
|
|
67
|
+
// ── Navigation: only stale-while-revalidate the dashboard root (/) ──
|
|
68
|
+
// /fluxy/* is a separate app — let it go to network to avoid
|
|
69
|
+
// caching the wrong HTML under the / key.
|
|
71
70
|
if (request.mode === 'navigate') {
|
|
72
71
|
console.log('[SW] navigate →', url.pathname);
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
72
|
+
if (url.pathname === '/' || url.pathname === '/index.html') {
|
|
73
|
+
event.respondWith(caches.open(CACHE).then(c =>
|
|
74
|
+
c.match('/').then(hit => {
|
|
75
|
+
console.log('[SW] cache hit for /:', !!hit);
|
|
76
|
+
const net = fetch(request)
|
|
77
|
+
.then(r => {
|
|
78
|
+
console.log('[SW] network response for /:', r.status);
|
|
79
|
+
if (r.ok) c.put('/', r.clone());
|
|
80
|
+
return r;
|
|
81
|
+
})
|
|
82
|
+
.catch(err => { console.warn('[SW] network failed, using cache:', err.message); return hit; });
|
|
83
|
+
return hit || net;
|
|
84
|
+
})
|
|
85
|
+
));
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
// Other navigations (/fluxy/*, etc.) — network only
|
|
89
|
+
console.log('[SW] navigate (network-only) →', url.pathname);
|
|
86
90
|
return;
|
|
87
91
|
}
|
|
88
92
|
|