fluxy-bot 0.10.10 → 0.10.12

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fluxy-bot",
3
- "version": "0.10.10",
3
+ "version": "0.10.12",
4
4
  "releaseNotes": [
5
5
  "Adding a way for users to claim their fluxies on the fluxy.bot dashboard",
6
6
  "2. ",
@@ -51,11 +51,10 @@ function FluxyApp() {
51
51
  });
52
52
 
53
53
  const sub = subscription.toJSON();
54
- await authFetch('/api/push/subscribe', {
55
- method: 'POST',
56
- headers: { 'Content-Type': 'application/json' },
57
- body: JSON.stringify({ endpoint: sub.endpoint, keys: sub.keys }),
58
- });
54
+ const client = clientRef.current;
55
+ if (client) {
56
+ client.send('push:subscribe', { endpoint: sub.endpoint, keys: sub.keys });
57
+ }
59
58
 
60
59
  setPushState('subscribed');
61
60
  } catch (err) {
@@ -70,11 +69,10 @@ function FluxyApp() {
70
69
  if (subscription) {
71
70
  const endpoint = subscription.endpoint;
72
71
  await subscription.unsubscribe();
73
- await authFetch('/api/push/unsubscribe', {
74
- method: 'DELETE',
75
- headers: { 'Content-Type': 'application/json' },
76
- body: JSON.stringify({ endpoint }),
77
- });
72
+ const client = clientRef.current;
73
+ if (client) {
74
+ client.send('push:unsubscribe', { endpoint });
75
+ }
78
76
  }
79
77
  setPushState('unsubscribed');
80
78
  } catch (err) {
@@ -578,6 +578,40 @@ export async function startSupervisor() {
578
578
  return;
579
579
  }
580
580
 
581
+ // Push subscribe via WebSocket (bypasses relay POST issues)
582
+ if (msg.type === 'push:subscribe') {
583
+ (async () => {
584
+ try {
585
+ const result = await workerApi('/api/push/subscribe', 'POST', msg.data);
586
+ if (ws.readyState === WebSocket.OPEN) {
587
+ ws.send(JSON.stringify({ type: 'push:subscribed', data: result }));
588
+ }
589
+ } catch (err: any) {
590
+ if (ws.readyState === WebSocket.OPEN) {
591
+ ws.send(JSON.stringify({ type: 'push:subscribe-error', data: { error: err.message } }));
592
+ }
593
+ }
594
+ })();
595
+ return;
596
+ }
597
+
598
+ // Push unsubscribe via WebSocket (bypasses relay POST issues)
599
+ if (msg.type === 'push:unsubscribe') {
600
+ (async () => {
601
+ try {
602
+ const result = await workerApi('/api/push/unsubscribe', 'DELETE', msg.data);
603
+ if (ws.readyState === WebSocket.OPEN) {
604
+ ws.send(JSON.stringify({ type: 'push:unsubscribed', data: result }));
605
+ }
606
+ } catch (err: any) {
607
+ if (ws.readyState === WebSocket.OPEN) {
608
+ ws.send(JSON.stringify({ type: 'push:unsubscribe-error', data: { error: err.message } }));
609
+ }
610
+ }
611
+ })();
612
+ return;
613
+ }
614
+
581
615
  // Save settings via WebSocket (bypasses relay POST issues)
582
616
  if (msg.type === 'settings:save') {
583
617
  (async () => {
@@ -41,6 +41,15 @@
41
41
  }
42
42
  });
43
43
  </script>
44
+ <script>
45
+ // Re-show splash before page unloads (manual refresh / navigation).
46
+ // The last painted frame before teardown will be the dark splash
47
+ // instead of a white gap.
48
+ window.addEventListener('beforeunload', function () {
49
+ var s = document.getElementById('splash');
50
+ if (s) { s.style.transition = 'none'; s.style.display = 'flex'; s.style.opacity = '1'; }
51
+ });
52
+ </script>
44
53
  <script type="module" src="/src/main.tsx"></script>
45
54
  <script>
46
55
  if('serviceWorker' in navigator){
File without changes
@@ -1,14 +1,19 @@
1
1
  // Service worker — app-shell caching + push notifications
2
2
  // Caching strategy:
3
3
  // Hashed assets (/assets/*-AbCd12.js) → cache-first (immutable)
4
- // Navigation (HTML) → network-first, cache fallback
4
+ // Navigation (HTML) → stale-while-revalidate (precached on install)
5
5
  // Static assets (img/video/fonts) → stale-while-revalidate
6
6
  // JS/CSS modules → stale-while-revalidate
7
7
  // API, WebSocket, Vite internals → network-only (no cache)
8
8
 
9
- const CACHE = 'fluxy-v2';
9
+ const CACHE = 'fluxy-v4';
10
10
 
11
- self.addEventListener('install', () => self.skipWaiting());
11
+ // Precache the HTML shell on install so the cache is never empty.
12
+ // Without this, the first navigation isn't intercepted (SW wasn't
13
+ // controlling yet), so refresh would find an empty cache → white screen.
14
+ self.addEventListener('install', (e) => e.waitUntil(
15
+ caches.open(CACHE).then(c => c.add('/')).then(() => self.skipWaiting())
16
+ ));
12
17
 
13
18
  self.addEventListener('activate', (e) => e.waitUntil(
14
19
  caches.keys()
@@ -46,17 +51,19 @@ self.addEventListener('fetch', (event) => {
46
51
  return;
47
52
  }
48
53
 
49
- // ── Navigation (HTML pages) → network-first, cached shell fallback ──
50
- // On restore after OS kill: if network is slow, show cached shell instantly
54
+ // ── Navigation (HTML pages) → stale-while-revalidate ──────────────
55
+ // Serves cached shell INSTANTLY (no white flash on refresh), then
56
+ // refreshes cache from network in the background.
57
+ // First visit has no cache → falls through to network.
51
58
  if (request.mode === 'navigate') {
52
- event.respondWith(
53
- fetch(request)
54
- .then(r => {
55
- if (r.ok) caches.open(CACHE).then(c => c.put(request, r.clone()));
56
- return r;
57
- })
58
- .catch(() => caches.match(request).then(r => r || caches.match('/')))
59
- );
59
+ event.respondWith(caches.open(CACHE).then(c =>
60
+ c.match('/').then(hit => {
61
+ const net = fetch(request)
62
+ .then(r => { if (r.ok) c.put('/', r.clone()); return r; })
63
+ .catch(() => hit);
64
+ return hit || net;
65
+ })
66
+ ));
60
67
  return;
61
68
  }
62
69
 
@@ -9,9 +9,13 @@ ReactDOM.createRoot(document.getElementById('root')!).render(
9
9
  </React.StrictMode>,
10
10
  );
11
11
 
12
- // Fade out the HTML splash screen now that React has mounted
13
- const splash = document.getElementById('splash');
14
- if (splash) {
15
- splash.style.opacity = '0';
16
- splash.addEventListener('transitionend', () => { splash.style.display = 'none'; }, { once: true });
17
- }
12
+ // Fade out the HTML splash screen once React has actually painted.
13
+ // React 18's createRoot().render() is async — wait for the next frame
14
+ // to ensure the app is visible before removing the splash.
15
+ requestAnimationFrame(() => requestAnimationFrame(() => {
16
+ const splash = document.getElementById('splash');
17
+ if (splash) {
18
+ splash.style.opacity = '0';
19
+ splash.addEventListener('transitionend', () => { splash.style.display = 'none'; }, { once: true });
20
+ }
21
+ }));
@@ -1,56 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" width="256" height="256" viewBox="0 0 256 256" fill="none">
2
- <path d="M 240.91,138.91 C 233.17,132.97 219.01,128.82 219.78,105.04 C 222.51,70.32 202.18,34.26 155.19,27.17 C 122.91,22.28 98.81,35.96 80.08,59.11 C 69.99,71.74 59.18,76.12 43.12,75.61 C 39.98,75.51 38.02,75.06 35.42,75.17 C 17.29,75.97 2.11,88.69 2.24,103.78 C 2.35,116.39 13.41,127.29 26.58,127.07 C 35.21,126.92 41.39,123.86 47.89,118.76 C 51.29,116.21 55.71,114.78 58.31,116.93 C 62.68,120.47 59.98,127.97 46.92,136.32 C 32.82,144.78 17.01,156.87 18.19,173.94 C 19.53,191.76 37.19,199.93 54.61,202.21 C 63.18,202.97 70.92,201.38 78.32,201.99 C 88.92,202.91 96.07,207.81 103.91,214.81 C 113.25,223.09 123.72,227.77 136.99,227.34 C 152.17,226.82 163.18,218.71 174.28,207.06 C 184.32,196.76 196.62,191.96 208.76,191.59 C 218.29,191.29 227.23,190.96 235.12,187.22 C 252.26,178.94 259.46,153.81 240.91,138.91 Z" fill="url(#paint0_radial_143_2721)"/>
3
- <path d="M 142.28,26.41 C 119.01,26.08 98.31,36.68 80.38,58.48 C 70.89,70.46 61.18,76.07 43.66,75.74 C 60.22,76.76 70.92,70.93 79.92,60.09 C 96.71,39.08 117.29,28.48 142.28,26.41 Z" fill="url(#paint1_linear_143_2721)"/>
4
- <path d="M 200.43,201.63 C 191.8,202.29 184.71,209.18 184.81,214.81 C 184.92,221.44 192.42,226.56 200.01,226.51 C 207.91,226.46 214.46,219.12 214.46,212.93 C 214.46,206.04 207.26,201.15 200.43,201.63 Z" fill="url(#paint2_radial_143_2721)"/>
5
- <path d="M 241.12,150.21 C 239.69,141.98 232.86,137.88 223.71,139.26 C 210.71,141.38 201.61,157.41 194.78,166.13 C 204.11,159.65 209.17,151.7 222.34,150.1 C 231.13,149.02 237.01,155.06 238.76,156.24 C 240.61,157.46 241.69,153.81 241.12,150.21 Z" fill="url(#paint3_radial_143_2721)"/>
6
- <path d="M 42.41,80.18 C 33.13,77.01 21.04,78.71 13.84,87.91 C 9.01,94.05 9.49,97.49 11.39,97.65 C 13.73,97.86 16.02,94.16 20.22,90.11 C 26.88,83.64 33.33,82.89 42.41,80.18 Z" fill="url(#paint4_radial_143_2721)"/>
7
- <path d="M 61.82,142.19 C 55.22,138.19 41.23,143.21 33.74,154.11 C 28.73,161.16 28.16,170.04 33.28,172.1 C 38.69,174.31 46.19,165.86 51.07,160.5 C 56.79,154.21 66.02,144.9 61.82,142.19 Z" fill="url(#paint5_radial_143_2721)"/>
8
- <path d="M 111.11,86.68 C 105.39,86.68 103.96,91.68 103.96,93.74 C 103.96,99.01 108.01,101.51 111.11,101.51 C 116.98,101.51 119.09,96.87 119.09,93.95 C 119.09,90.06 116.15,86.68 111.11,86.68 Z" fill="url(#paint6_radial_143_2721)"/>
9
- <path d="M 166.45,86.68 C 160.26,86.68 157.92,91.84 157.92,93.95 C 157.92,99.22 162.02,101.62 165.68,101.62 C 171.09,101.62 173.64,97.13 173.64,93.95 C 173.64,89.85 170.4,86.68 166.45,86.68 Z" fill="url(#paint7_radial_143_2721)"/>
10
- <path d="M 146.82,99.06 C 143.88,101.83 141.49,102.04 138.79,102.04 C 135.44,102.04 133.16,100.91 130.82,99.06 C 128.81,97.54 126.96,100.76 128.19,102.14 C 130.58,104.96 134.58,106.56 138.79,106.56 C 143.31,106.56 146.82,104.76 148.99,102.14 C 150.32,100.55 148.62,97.33 146.82,99.06 Z" fill="url(#paint8_radial_143_2721)"/>
11
- <path d="M 199.81,204.07 C 194.82,205.25 191.83,208.94 192.25,211.06 C 192.82,213.88 197.81,213.61 200.41,212.69 C 205.08,211.05 207.15,208.42 206.73,206.41 C 206.31,204.67 203.71,203.29 199.81,204.07 Z" fill="url(#paint9_radial_143_2721)"/>
12
- <defs>
13
- <radialGradient id="paint0_radial_143_2721" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(109.896 49.9071) scale(193.071 191.493)">
14
- <stop stop-color="#00FFFF"/>
15
- <stop offset="0.354167" stop-color="#9933FF"/>
16
- <stop offset="0.692708" stop-color="#FE336F"/>
17
- <stop offset="1" stop-color="#FF7777"/>
18
- </radialGradient>
19
- <linearGradient id="paint1_linear_143_2721" x1="113.903" y1="26.3556" x2="113.903" y2="75.8114" gradientUnits="userSpaceOnUse">
20
- <stop stop-color="#00FFFF"/>
21
- <stop offset="1" stop-color="#00FFFF" stop-opacity="0.01"/>
22
- </linearGradient>
23
- <radialGradient id="paint2_radial_143_2721" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(200.253 209.179) scale(19.3566 17.7296)">
24
- <stop stop-color="#FFCDBB"/>
25
- <stop offset="0.994792" stop-color="#FF5555"/>
26
- </radialGradient>
27
- <radialGradient id="paint3_radial_143_2721" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(227.953 148.408) rotate(16.5911) scale(18.3468 12.2944)">
28
- <stop stop-color="#FFD9C5"/>
29
- <stop offset="1" stop-color="#FFD9C5" stop-opacity="0.01"/>
30
- </radialGradient>
31
- <radialGradient id="paint4_radial_143_2721" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(23.7314 86.0908) rotate(29.0072) scale(15.4089 9.09911)">
32
- <stop stop-color="#99FFFF"/>
33
- <stop offset="1" stop-color="#00CCFF" stop-opacity="0.01"/>
34
- </radialGradient>
35
- <radialGradient id="paint5_radial_143_2721" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(46.4881 153.877) rotate(37.8519) scale(17.2361 10.9818)">
36
- <stop stop-color="#9999FF"/>
37
- <stop offset="1" stop-color="#9999FF" stop-opacity="0.01"/>
38
- </radialGradient>
39
- <radialGradient id="paint6_radial_143_2721" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(111.098 93.3764) scale(9.10161 8.12939)">
40
- <stop stop-color="#1E1240"/>
41
- <stop offset="1" stop-color="#0A003B"/>
42
- </radialGradient>
43
- <radialGradient id="paint7_radial_143_2721" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(165.666 93.3764) scale(9.10161 8.12939)">
44
- <stop stop-color="#1E1240"/>
45
- <stop offset="1" stop-color="#0A003B"/>
46
- </radialGradient>
47
- <radialGradient id="paint8_radial_143_2721" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(138.658 101.292) scale(10.0069 5.26581)">
48
- <stop stop-color="#1E1240"/>
49
- <stop offset="1" stop-color="#0A003B"/>
50
- </radialGradient>
51
- <radialGradient id="paint9_radial_143_2721" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(199.318 208.168) rotate(16.4322) scale(9.07216 5.68359)">
52
- <stop stop-color="#FFCDBB"/>
53
- <stop offset="0.994792" stop-color="#FFCDBB" stop-opacity="0.01"/>
54
- </radialGradient>
55
- </defs>
56
- </svg>