@sudobility/di_web 0.1.166 → 0.1.168

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.
@@ -53,8 +53,12 @@
53
53
  // 1. Import Firebase compat libraries
54
54
  // These scripts expose a global `firebase` object in the SW scope.
55
55
  // ---------------------------------------------------------------------------
56
- importScripts('https://www.gstatic.com/firebasejs/10.7.1/firebase-app-compat.js');
57
- importScripts('https://www.gstatic.com/firebasejs/10.7.1/firebase-messaging-compat.js');
56
+ importScripts(
57
+ 'https://www.gstatic.com/firebasejs/10.7.1/firebase-app-compat.js'
58
+ );
59
+ importScripts(
60
+ 'https://www.gstatic.com/firebasejs/10.7.1/firebase-messaging-compat.js'
61
+ );
58
62
 
59
63
  // ---------------------------------------------------------------------------
60
64
  // 2. Firebase configuration
@@ -89,7 +93,7 @@ const messaging = firebase.messaging();
89
93
  // closed and an FCM message arrives. Foreground messages are handled by
90
94
  // the main app via `onMessage()` from `firebase/messaging`.
91
95
  // ---------------------------------------------------------------------------
92
- messaging.onBackgroundMessage(payload => {
96
+ messaging.onBackgroundMessage((payload) => {
93
97
  // Extract notification title and body from the FCM payload, falling back
94
98
  // to sensible defaults if the fields are missing.
95
99
  const notificationTitle = payload.notification?.title || 'New Email';
@@ -134,7 +138,7 @@ messaging.onBackgroundMessage(payload => {
134
138
  // 6. Handle notification click events
135
139
  // Determines which action the user selected and routes accordingly.
136
140
  // ---------------------------------------------------------------------------
137
- self.addEventListener('notificationclick', event => {
141
+ self.addEventListener('notificationclick', (event) => {
138
142
  // Close the notification regardless of the action taken.
139
143
  event.notification.close();
140
144
 
@@ -148,7 +152,7 @@ self.addEventListener('notificationclick', event => {
148
152
  type: 'window',
149
153
  includeUncontrolled: true,
150
154
  })
151
- .then(clientList => {
155
+ .then((clientList) => {
152
156
  // If the app is already open in a tab, focus and navigate it.
153
157
  for (const client of clientList) {
154
158
  if (client.url.includes(self.location.origin)) {
@@ -173,7 +177,7 @@ self.addEventListener('notificationclick', event => {
173
177
  // 7. Handle notification close events (swipe-away / manual dismiss)
174
178
  // Currently a no-op. Add analytics or cleanup logic here if needed.
175
179
  // ---------------------------------------------------------------------------
176
- self.addEventListener('notificationclose', event => {
180
+ self.addEventListener('notificationclose', (event) => {
177
181
  // Notification was closed by the user without tapping an action.
178
182
  });
179
183
 
@@ -182,7 +186,7 @@ self.addEventListener('notificationclose', event => {
182
186
  // FCM messages are handled automatically by `onBackgroundMessage` above.
183
187
  // This handler is a catch-all for non-FCM push payloads.
184
188
  // ---------------------------------------------------------------------------
185
- self.addEventListener('push', event => {
189
+ self.addEventListener('push', (event) => {
186
190
  if (event.data) {
187
191
  const data = event.data.json();
188
192
 
package/dist/sw/sw.js CHANGED
@@ -29,9 +29,9 @@ const PRECACHE_URLS = ['/', '/manifest.json'];
29
29
  const ALLOWED_CDN_DOMAINS = ['cdn.jsdelivr.net', 'unpkg.com'];
30
30
 
31
31
  // Install event - precache essential files
32
- self.addEventListener('install', event => {
32
+ self.addEventListener('install', (event) => {
33
33
  event.waitUntil(
34
- caches.open(STATIC_CACHE).then(cache => {
34
+ caches.open(STATIC_CACHE).then((cache) => {
35
35
  return cache.addAll(PRECACHE_URLS);
36
36
  })
37
37
  );
@@ -39,25 +39,28 @@ self.addEventListener('install', event => {
39
39
  });
40
40
 
41
41
  // Activate event - clean up old caches
42
- self.addEventListener('activate', event => {
42
+ self.addEventListener('activate', (event) => {
43
43
  const CURRENT_CACHES = [STATIC_CACHE, DYNAMIC_CACHE, IMAGE_CACHE];
44
44
  const LEGACY_PREFIXES = ['web3mail-', 'shapeshyft-'];
45
45
 
46
46
  event.waitUntil(
47
47
  caches
48
48
  .keys()
49
- .then(cacheNames => {
49
+ .then((cacheNames) => {
50
50
  return Promise.all(
51
51
  cacheNames
52
- .filter(name => {
52
+ .filter((name) => {
53
53
  // Remove old sudobility caches
54
- if (name.startsWith('sudobility-') && !CURRENT_CACHES.includes(name)) {
54
+ if (
55
+ name.startsWith('sudobility-') &&
56
+ !CURRENT_CACHES.includes(name)
57
+ ) {
55
58
  return true;
56
59
  }
57
60
  // Remove legacy app-specific caches
58
- return LEGACY_PREFIXES.some(prefix => name.startsWith(prefix));
61
+ return LEGACY_PREFIXES.some((prefix) => name.startsWith(prefix));
59
62
  })
60
- .map(name => caches.delete(name))
63
+ .map((name) => caches.delete(name))
61
64
  );
62
65
  })
63
66
  .then(() => self.clients.claim())
@@ -86,7 +89,7 @@ function isExpired(response, cacheName) {
86
89
  }
87
90
 
88
91
  // Fetch event - implement caching strategies
89
- self.addEventListener('fetch', event => {
92
+ self.addEventListener('fetch', (event) => {
90
93
  const { request } = event;
91
94
  const url = new URL(request.url);
92
95
 
@@ -107,13 +110,14 @@ self.addEventListener('fetch', event => {
107
110
  // Skip non-same-origin requests unless on CDN allowlist
108
111
  if (
109
112
  url.origin !== location.origin &&
110
- !ALLOWED_CDN_DOMAINS.some(domain => url.hostname.includes(domain))
113
+ !ALLOWED_CDN_DOMAINS.some((domain) => url.hostname.includes(domain))
111
114
  ) {
112
115
  return;
113
116
  }
114
117
 
115
118
  // Skip API requests
116
- if (url.pathname.startsWith('/api/') || url.hostname.startsWith('api.')) return;
119
+ if (url.pathname.startsWith('/api/') || url.hostname.startsWith('api.'))
120
+ return;
117
121
 
118
122
  // Strategy: Cache First for static assets (JS, CSS, fonts)
119
123
  if (
@@ -198,7 +202,7 @@ async function staleWhileRevalidate(request, cacheName) {
198
202
  const cache = await caches.open(cacheName);
199
203
  const cached = await cache.match(request);
200
204
 
201
- const fetchPromise = fetch(request).then(response => {
205
+ const fetchPromise = fetch(request).then((response) => {
202
206
  if (response.ok) {
203
207
  cache.put(request, response.clone());
204
208
  }
@@ -209,14 +213,14 @@ async function staleWhileRevalidate(request, cacheName) {
209
213
  }
210
214
 
211
215
  // Handle messages from the main thread
212
- self.addEventListener('message', event => {
216
+ self.addEventListener('message', (event) => {
213
217
  if (event.data?.type === 'SKIP_WAITING') {
214
218
  self.skipWaiting();
215
219
  }
216
220
  });
217
221
 
218
222
  // Background sync for failed requests
219
- self.addEventListener('sync', event => {
223
+ self.addEventListener('sync', (event) => {
220
224
  if (event.tag === 'background-sync') {
221
225
  event.waitUntil(doBackgroundSync());
222
226
  }
@@ -237,7 +241,7 @@ async function doBackgroundSync() {
237
241
  }
238
242
 
239
243
  // Push notification handler
240
- self.addEventListener('push', event => {
244
+ self.addEventListener('push', (event) => {
241
245
  if (!event.data) return;
242
246
 
243
247
  try {
@@ -263,7 +267,7 @@ self.addEventListener('push', event => {
263
267
  });
264
268
 
265
269
  // Notification click handler
266
- self.addEventListener('notificationclick', event => {
270
+ self.addEventListener('notificationclick', (event) => {
267
271
  event.notification.close();
268
272
 
269
273
  if (event.action === 'dismiss') return;
@@ -271,7 +275,7 @@ self.addEventListener('notificationclick', event => {
271
275
  const urlToOpen = event.notification.data?.url || '/';
272
276
 
273
277
  event.waitUntil(
274
- self.clients.matchAll({ type: 'window' }).then(clients => {
278
+ self.clients.matchAll({ type: 'window' }).then((clients) => {
275
279
  for (const client of clients) {
276
280
  if (client.url === urlToOpen && 'focus' in client) {
277
281
  return client.focus();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sudobility/di_web",
3
- "version": "0.1.166",
3
+ "version": "0.1.168",
4
4
  "description": "Web implementations of dependency injection services for Sudobility",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -42,7 +42,7 @@
42
42
  "author": "Sudobility Inc",
43
43
  "license": "BUSL-1.1",
44
44
  "peerDependencies": {
45
- "@sudobility/components": "^5.0.57",
45
+ "@sudobility/components": "^5.0.58",
46
46
  "@sudobility/di": "^1.5.52",
47
47
  "@sudobility/types": "^1.9.61",
48
48
  "react": "^18.0.0 || ^19.0.0",
@@ -62,9 +62,9 @@
62
62
  },
63
63
  "devDependencies": {
64
64
  "@eslint/js": "^9.38.0",
65
- "@sudobility/components": "^5.0.57",
65
+ "@sudobility/components": "^5.0.58",
66
66
  "@sudobility/di": "^1.5.52",
67
- "@sudobility/subscription_lib": "^0.0.38",
67
+ "@sudobility/subscription_lib": "^0.0.40",
68
68
  "@sudobility/types": "^1.9.61",
69
69
  "@types/node": "^24.10.1",
70
70
  "@types/react": "^19.1.8",