@hydra-acp/browser 0.1.24 → 0.1.26
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/hydra/client.js.map +1 -1
- package/dist/server/http.js +1 -0
- package/dist/server/http.js.map +1 -1
- package/dist/server/routes-root.js +19 -0
- package/dist/server/routes-root.js.map +1 -1
- package/dist/server/ws-bridge.js +63 -3
- package/dist/server/ws-bridge.js.map +1 -1
- package/dist/ui/index.html +144 -30
- package/dist/ui/sw.js +44 -0
- package/package.json +1 -1
package/dist/ui/sw.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Registration-only service worker. Its sole job is to exist so
|
|
2
|
+
// registration.showNotification() is available — Safari (desktop and
|
|
3
|
+
// iOS) requires notifications go through a service worker; it doesn't
|
|
4
|
+
// support the plain `new Notification()` constructor called from page
|
|
5
|
+
// script. See notifications.ts for the page-side half.
|
|
6
|
+
//
|
|
7
|
+
// No fetch/push handling: this app doesn't do offline caching or real
|
|
8
|
+
// Web Push (notifications only fire while the page is alive and asks
|
|
9
|
+
// for one), so there's nothing else for this worker to do. Kept as
|
|
10
|
+
// plain JS, not bundled with the rest of the app — it must be servable
|
|
11
|
+
// at its own URL for registration to work.
|
|
12
|
+
self.addEventListener("install", () => {
|
|
13
|
+
self.skipWaiting();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
self.addEventListener("activate", (event) => {
|
|
17
|
+
event.waitUntil(self.clients.claim());
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
// A notification is owned by the worker, not the page that created it,
|
|
21
|
+
// so bringing the tab to front on click has to happen here rather than
|
|
22
|
+
// via a plain onclick back in page script.
|
|
23
|
+
self.addEventListener("notificationclick", (event) => {
|
|
24
|
+
event.notification.close();
|
|
25
|
+
const url = (event.notification.data && event.notification.data.url) || "/";
|
|
26
|
+
event.waitUntil(
|
|
27
|
+
self.clients
|
|
28
|
+
.matchAll({ type: "window", includeUncontrolled: true })
|
|
29
|
+
.then((clients) => {
|
|
30
|
+
for (const client of clients) {
|
|
31
|
+
if ("focus" in client) {
|
|
32
|
+
if ("navigate" in client) {
|
|
33
|
+
client.navigate(url).catch(() => {});
|
|
34
|
+
}
|
|
35
|
+
return client.focus();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (self.clients.openWindow) {
|
|
39
|
+
return self.clients.openWindow(url);
|
|
40
|
+
}
|
|
41
|
+
return undefined;
|
|
42
|
+
}),
|
|
43
|
+
);
|
|
44
|
+
});
|