fluxy-bot 0.5.15 → 0.5.18
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/dist-fluxy/fluxy.html +1 -1
- package/package.json +1 -1
- package/supervisor/chat/fluxy.html +1 -1
- package/supervisor/index.ts +40 -4
package/dist-fluxy/fluxy.html
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<div id="root"></div>
|
|
13
13
|
<script>
|
|
14
14
|
if('serviceWorker' in navigator){
|
|
15
|
-
navigator.serviceWorker.register('/sw.js'
|
|
15
|
+
navigator.serviceWorker.register('/fluxy/sw.js').then(function(r){
|
|
16
16
|
r.update();
|
|
17
17
|
if(r.waiting){r.waiting.postMessage({type:'SKIP_WAITING'})}
|
|
18
18
|
r.addEventListener('updatefound',function(){
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<script type="module" src="/fluxy-main.tsx"></script>
|
|
11
11
|
<script>
|
|
12
12
|
if('serviceWorker' in navigator){
|
|
13
|
-
navigator.serviceWorker.register('/sw.js'
|
|
13
|
+
navigator.serviceWorker.register('/fluxy/sw.js').then(function(r){
|
|
14
14
|
r.update();
|
|
15
15
|
if(r.waiting){r.waiting.postMessage({type:'SKIP_WAITING'})}
|
|
16
16
|
r.addEventListener('updatefound',function(){
|
package/supervisor/index.ts
CHANGED
|
@@ -46,6 +46,43 @@ const MIME_TYPES: Record<string, string> = {
|
|
|
46
46
|
'.json': 'application/json',
|
|
47
47
|
};
|
|
48
48
|
|
|
49
|
+
// Service worker content — embedded here so it ships with supervisor/ (always updated)
|
|
50
|
+
const SW_JS = `// Service worker — PWA installability + push notifications
|
|
51
|
+
self.addEventListener('install', () => self.skipWaiting());
|
|
52
|
+
self.addEventListener('activate', (e) => e.waitUntil(self.clients.claim()));
|
|
53
|
+
self.addEventListener('fetch', () => {});
|
|
54
|
+
|
|
55
|
+
// Push notification
|
|
56
|
+
self.addEventListener('push', (event) => {
|
|
57
|
+
let data = { title: 'Fluxy', body: 'New message' };
|
|
58
|
+
try { data = event.data.json(); } catch {}
|
|
59
|
+
event.waitUntil(
|
|
60
|
+
self.registration.showNotification(data.title || 'Fluxy', {
|
|
61
|
+
body: data.body || '',
|
|
62
|
+
icon: '/fluxy-icon-192.png',
|
|
63
|
+
badge: '/fluxy-icon-192.png',
|
|
64
|
+
vibrate: [100, 50, 100],
|
|
65
|
+
tag: data.tag || 'fluxy-default',
|
|
66
|
+
data: { url: data.url || '/' },
|
|
67
|
+
})
|
|
68
|
+
);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// Notification click — focus or open app
|
|
72
|
+
self.addEventListener('notificationclick', (event) => {
|
|
73
|
+
event.notification.close();
|
|
74
|
+
const url = event.notification.data?.url || '/';
|
|
75
|
+
event.waitUntil(
|
|
76
|
+
self.clients.matchAll({ type: 'window', includeUncontrolled: true }).then((clients) => {
|
|
77
|
+
for (const client of clients) {
|
|
78
|
+
if (client.url.includes('/fluxy') && 'focus' in client) return client.focus();
|
|
79
|
+
}
|
|
80
|
+
return self.clients.openWindow(url);
|
|
81
|
+
})
|
|
82
|
+
);
|
|
83
|
+
});
|
|
84
|
+
`;
|
|
85
|
+
|
|
49
86
|
const RECOVERING_HTML = `<!DOCTYPE html><html><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Recovering</title>
|
|
50
87
|
<style>body{background:#0a0a0f;color:#94a3b8;font-family:system-ui;display:flex;align-items:center;justify-content:center;height:100vh;margin:0}
|
|
51
88
|
div{text-align:center}h1{font-size:18px;margin-bottom:8px;color:#e2e8f0}p{font-size:14px}a{color:#60a5fa}</style></head>
|
|
@@ -170,11 +207,10 @@ export async function startSupervisor() {
|
|
|
170
207
|
return;
|
|
171
208
|
}
|
|
172
209
|
|
|
173
|
-
// Service worker — served
|
|
174
|
-
if (req.url === '/sw.js') {
|
|
175
|
-
const swPath = path.join(PKG_DIR, 'workspace', 'client', 'public', 'sw.js');
|
|
210
|
+
// Service worker — served from embedded constant (supervisor/ is always updated)
|
|
211
|
+
if (req.url === '/sw.js' || req.url === '/fluxy/sw.js') {
|
|
176
212
|
res.writeHead(200, { 'Content-Type': 'application/javascript', 'Cache-Control': 'no-cache' });
|
|
177
|
-
res.end(
|
|
213
|
+
res.end(SW_JS);
|
|
178
214
|
return;
|
|
179
215
|
}
|
|
180
216
|
|