@hmduc16031996/claude-mb-bridge 2.0.0 → 2.2.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/dist/index.js +23 -16
- package/dist/server.d.ts +4 -1
- package/dist/server.js +23 -11
- package/package.json +1 -1
- package/public/app.js +235 -0
- package/public/index.html +114 -65
- package/public/manifest.json +25 -0
- package/public/styles.css +1970 -0
- package/public/sw.js +42 -0
package/public/sw.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Service Worker for Claude Code Remote notifications
|
|
2
|
+
|
|
3
|
+
self.addEventListener('install', () => self.skipWaiting());
|
|
4
|
+
self.addEventListener('activate', (event) => event.waitUntil(clients.claim()));
|
|
5
|
+
|
|
6
|
+
// Handle notification clicks - focus app and switch to session
|
|
7
|
+
self.addEventListener('notificationclick', (event) => {
|
|
8
|
+
event.notification.close();
|
|
9
|
+
const { sessionId } = event.notification.data || {};
|
|
10
|
+
|
|
11
|
+
event.waitUntil(
|
|
12
|
+
clients.matchAll({ type: 'window', includeUncontrolled: true }).then((clientList) => {
|
|
13
|
+
// Try to focus an existing window
|
|
14
|
+
for (const client of clientList) {
|
|
15
|
+
if ('focus' in client) {
|
|
16
|
+
return client.focus().then((focusedClient) => {
|
|
17
|
+
focusedClient.postMessage({ type: 'switch-session', sessionId });
|
|
18
|
+
return focusedClient;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
// No existing window - open a new one
|
|
23
|
+
return clients.openWindow('/');
|
|
24
|
+
})
|
|
25
|
+
);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Handle messages from main thread to show notifications
|
|
29
|
+
self.addEventListener('message', (event) => {
|
|
30
|
+
if (event.data.type === 'show-notification') {
|
|
31
|
+
const { title, body, sessionId, tag } = event.data;
|
|
32
|
+
self.registration.showNotification(title, {
|
|
33
|
+
body,
|
|
34
|
+
tag,
|
|
35
|
+
icon: '/icon-192.png',
|
|
36
|
+
badge: '/badge-72.png',
|
|
37
|
+
data: { sessionId },
|
|
38
|
+
requireInteraction: true,
|
|
39
|
+
vibrate: [100, 50, 100],
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
});
|