fluxy-bot 0.10.13 → 0.10.14
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/widget.js +25 -0
package/package.json
CHANGED
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
|
})();
|