claudeck 1.0.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/LICENSE +21 -0
- package/README.md +233 -0
- package/cli.js +2 -0
- package/config/agent-chains.json +16 -0
- package/config/agent-dags.json +16 -0
- package/config/agents.json +46 -0
- package/config/bot-prompt.json +3 -0
- package/config/folders.json +66 -0
- package/config/prompts.json +92 -0
- package/config/repos.json +86 -0
- package/config/telegram-config.json +17 -0
- package/config/workflows.json +90 -0
- package/db.js +1198 -0
- package/package.json +55 -0
- package/plugins/claude-editor/client.css +171 -0
- package/plugins/claude-editor/client.js +183 -0
- package/plugins/event-stream/client.css +207 -0
- package/plugins/event-stream/client.js +271 -0
- package/plugins/linear/client.css +345 -0
- package/plugins/linear/client.js +380 -0
- package/plugins/linear/config.json +5 -0
- package/plugins/linear/server.js +312 -0
- package/plugins/repos/client.css +549 -0
- package/plugins/repos/client.js +663 -0
- package/plugins/repos/server.js +232 -0
- package/plugins/sudoku/client.css +196 -0
- package/plugins/sudoku/client.js +329 -0
- package/plugins/tasks/client.css +414 -0
- package/plugins/tasks/client.js +394 -0
- package/plugins/tasks/server.js +116 -0
- package/plugins/tic-tac-toe/client.css +167 -0
- package/plugins/tic-tac-toe/client.js +241 -0
- package/public/css/core/components.css +232 -0
- package/public/css/core/layout.css +330 -0
- package/public/css/core/print.css +18 -0
- package/public/css/core/reset.css +36 -0
- package/public/css/core/responsive.css +378 -0
- package/public/css/core/theme.css +116 -0
- package/public/css/core/variables.css +93 -0
- package/public/css/features/agent-monitor.css +297 -0
- package/public/css/features/agent-sidebar.css +525 -0
- package/public/css/features/agents.css +996 -0
- package/public/css/features/analytics.css +181 -0
- package/public/css/features/background-sessions.css +321 -0
- package/public/css/features/cost-dashboard.css +168 -0
- package/public/css/features/home.css +313 -0
- package/public/css/features/retro-terminal.css +88 -0
- package/public/css/features/telegram.css +127 -0
- package/public/css/features/tour.css +148 -0
- package/public/css/features/voice-input.css +60 -0
- package/public/css/features/welcome.css +241 -0
- package/public/css/panels/assistant-bot.css +442 -0
- package/public/css/panels/dev-docs.css +292 -0
- package/public/css/panels/file-explorer.css +322 -0
- package/public/css/panels/git-panel.css +221 -0
- package/public/css/panels/mcp-manager.css +199 -0
- package/public/css/panels/tips-feed.css +353 -0
- package/public/css/ui/commands.css +273 -0
- package/public/css/ui/context-gauge.css +76 -0
- package/public/css/ui/file-picker.css +69 -0
- package/public/css/ui/image-attachments.css +106 -0
- package/public/css/ui/messages.css +884 -0
- package/public/css/ui/modals.css +122 -0
- package/public/css/ui/parallel.css +217 -0
- package/public/css/ui/permissions.css +110 -0
- package/public/css/ui/right-panel.css +481 -0
- package/public/css/ui/sessions.css +689 -0
- package/public/css/ui/status-bar.css +425 -0
- package/public/css/ui/toolbox.css +206 -0
- package/public/data/tips.json +218 -0
- package/public/icons/favicon.png +0 -0
- package/public/icons/icon-192.png +0 -0
- package/public/icons/icon-512.png +0 -0
- package/public/icons/whaly.png +0 -0
- package/public/index.html +1140 -0
- package/public/js/core/api.js +591 -0
- package/public/js/core/constants.js +3 -0
- package/public/js/core/dom.js +270 -0
- package/public/js/core/events.js +10 -0
- package/public/js/core/plugin-loader.js +153 -0
- package/public/js/core/store.js +39 -0
- package/public/js/core/utils.js +25 -0
- package/public/js/core/ws.js +64 -0
- package/public/js/features/agent-monitor.js +222 -0
- package/public/js/features/agents.js +1209 -0
- package/public/js/features/analytics.js +397 -0
- package/public/js/features/attachments.js +251 -0
- package/public/js/features/background-sessions.js +475 -0
- package/public/js/features/chat.js +589 -0
- package/public/js/features/cost-dashboard.js +152 -0
- package/public/js/features/dag-editor.js +399 -0
- package/public/js/features/easter-egg.js +46 -0
- package/public/js/features/home.js +270 -0
- package/public/js/features/projects.js +372 -0
- package/public/js/features/prompts.js +228 -0
- package/public/js/features/sessions.js +332 -0
- package/public/js/features/telegram.js +131 -0
- package/public/js/features/tour.js +210 -0
- package/public/js/features/voice-input.js +185 -0
- package/public/js/features/welcome.js +43 -0
- package/public/js/features/workflows.js +277 -0
- package/public/js/main.js +51 -0
- package/public/js/panels/assistant-bot.js +445 -0
- package/public/js/panels/dev-docs.js +380 -0
- package/public/js/panels/file-explorer.js +486 -0
- package/public/js/panels/git-panel.js +285 -0
- package/public/js/panels/mcp-manager.js +311 -0
- package/public/js/panels/tips-feed.js +303 -0
- package/public/js/ui/commands.js +114 -0
- package/public/js/ui/context-gauge.js +100 -0
- package/public/js/ui/diff.js +124 -0
- package/public/js/ui/disabled-tools.js +36 -0
- package/public/js/ui/export.js +74 -0
- package/public/js/ui/formatting.js +206 -0
- package/public/js/ui/header-dropdowns.js +72 -0
- package/public/js/ui/input-meta.js +71 -0
- package/public/js/ui/max-turns.js +21 -0
- package/public/js/ui/messages.js +387 -0
- package/public/js/ui/model-selector.js +20 -0
- package/public/js/ui/notifications.js +232 -0
- package/public/js/ui/parallel.js +176 -0
- package/public/js/ui/permissions.js +168 -0
- package/public/js/ui/right-panel.js +173 -0
- package/public/js/ui/shortcuts.js +143 -0
- package/public/js/ui/sidebar-toggle.js +29 -0
- package/public/js/ui/status-bar.js +172 -0
- package/public/js/ui/tab-sdk.js +623 -0
- package/public/js/ui/theme.js +38 -0
- package/public/manifest.json +13 -0
- package/public/offline.html +190 -0
- package/public/style.css +42 -0
- package/public/sw.js +91 -0
- package/server/agent-loop.js +385 -0
- package/server/dag-executor.js +265 -0
- package/server/orchestrator.js +514 -0
- package/server/paths.js +61 -0
- package/server/plugin-mount.js +56 -0
- package/server/push-sender.js +31 -0
- package/server/routes/agents.js +294 -0
- package/server/routes/bot.js +45 -0
- package/server/routes/exec.js +35 -0
- package/server/routes/files.js +218 -0
- package/server/routes/mcp.js +82 -0
- package/server/routes/messages.js +36 -0
- package/server/routes/notifications.js +37 -0
- package/server/routes/projects.js +207 -0
- package/server/routes/prompts.js +53 -0
- package/server/routes/sessions.js +103 -0
- package/server/routes/stats.js +143 -0
- package/server/routes/telegram.js +71 -0
- package/server/routes/tips.js +135 -0
- package/server/routes/workflows.js +81 -0
- package/server/summarizer.js +55 -0
- package/server/telegram-poller.js +205 -0
- package/server/telegram-sender.js +304 -0
- package/server/ws-handler.js +926 -0
- package/server.js +179 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en" dir="ltr">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<meta name="theme-color" content="#0d1117">
|
|
7
|
+
<title>Claudeck :: offline</title>
|
|
8
|
+
<style>
|
|
9
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
10
|
+
|
|
11
|
+
body {
|
|
12
|
+
background: #050508;
|
|
13
|
+
color: #b8c4d0;
|
|
14
|
+
font-family: "SF Mono", "Fira Code", "JetBrains Mono", "Cascadia Code", "Consolas", monospace;
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
justify-content: center;
|
|
18
|
+
min-height: 100vh;
|
|
19
|
+
overflow: hidden;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.offline-container {
|
|
23
|
+
text-align: center;
|
|
24
|
+
padding: 2rem;
|
|
25
|
+
max-width: 480px;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/* ASCII art logo */
|
|
29
|
+
.ascii-logo {
|
|
30
|
+
margin: 0 auto 2rem;
|
|
31
|
+
font-size: 3.2px;
|
|
32
|
+
line-height: 1.15;
|
|
33
|
+
letter-spacing: 0.02em;
|
|
34
|
+
color: #33d17a;
|
|
35
|
+
white-space: pre;
|
|
36
|
+
overflow: hidden;
|
|
37
|
+
text-align: left;
|
|
38
|
+
display: inline-block;
|
|
39
|
+
text-shadow: 0 0 6px rgba(51, 209, 122, 0.3);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@media (min-width: 480px) {
|
|
43
|
+
.ascii-logo { font-size: 4.5px; }
|
|
44
|
+
}
|
|
45
|
+
@media (min-width: 640px) {
|
|
46
|
+
.ascii-logo { font-size: 5.5px; }
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.offline-title {
|
|
50
|
+
font-size: 1.4rem;
|
|
51
|
+
color: #33d17a;
|
|
52
|
+
margin-bottom: 0.5rem;
|
|
53
|
+
direction: ltr;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
.offline-message {
|
|
58
|
+
color: #6b7a8d;
|
|
59
|
+
font-size: 0.85rem;
|
|
60
|
+
line-height: 1.6;
|
|
61
|
+
margin-bottom: 2rem;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.retry-btn {
|
|
65
|
+
background: transparent;
|
|
66
|
+
border: 1px solid #33d17a;
|
|
67
|
+
color: #33d17a;
|
|
68
|
+
padding: 0.6rem 1.8rem;
|
|
69
|
+
font-family: inherit;
|
|
70
|
+
font-size: 0.85rem;
|
|
71
|
+
cursor: pointer;
|
|
72
|
+
border-radius: 4px;
|
|
73
|
+
transition: all 0.2s;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.retry-btn:hover {
|
|
77
|
+
background: rgba(51, 209, 122, 0.1);
|
|
78
|
+
box-shadow: 0 0 12px rgba(51, 209, 122, 0.2);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/* Subtle glow pulse on ASCII logo */
|
|
82
|
+
@keyframes ascii-glow {
|
|
83
|
+
0%, 100% { text-shadow: 0 0 6px rgba(51, 209, 122, 0.3); }
|
|
84
|
+
50% { text-shadow: 0 0 14px rgba(51, 209, 122, 0.5), 0 0 30px rgba(51, 209, 122, 0.15); }
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.ascii-logo { animation: ascii-glow 4s ease-in-out infinite; }
|
|
88
|
+
|
|
89
|
+
/* Floating geometric particles */
|
|
90
|
+
.particles {
|
|
91
|
+
position: fixed;
|
|
92
|
+
inset: 0;
|
|
93
|
+
pointer-events: none;
|
|
94
|
+
z-index: -1;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.particle {
|
|
98
|
+
position: absolute;
|
|
99
|
+
opacity: 0.06;
|
|
100
|
+
animation: float 20s infinite linear;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
@keyframes float {
|
|
104
|
+
0% { transform: translateY(100vh) rotate(0deg); }
|
|
105
|
+
100% { transform: translateY(-20vh) rotate(360deg); }
|
|
106
|
+
}
|
|
107
|
+
</style>
|
|
108
|
+
|
|
109
|
+
</head>
|
|
110
|
+
<body>
|
|
111
|
+
<!-- Floating geometric particles background -->
|
|
112
|
+
<div class="particles">
|
|
113
|
+
<svg class="particle" style="left:10%;width:30px;animation-delay:0s;animation-duration:25s" viewBox="0 0 40 40">
|
|
114
|
+
<polygon points="20,2 38,20 20,38 2,20" fill="none" stroke="#33d17a" stroke-width="1"/>
|
|
115
|
+
</svg>
|
|
116
|
+
<svg class="particle" style="left:30%;width:20px;animation-delay:5s;animation-duration:18s" viewBox="0 0 40 40">
|
|
117
|
+
<polygon points="20,0 40,20 20,40 0,20" fill="none" stroke="#c69ff5" stroke-width="1"/>
|
|
118
|
+
</svg>
|
|
119
|
+
<svg class="particle" style="left:55%;width:25px;animation-delay:2s;animation-duration:22s" viewBox="0 0 40 40">
|
|
120
|
+
<circle cx="20" cy="20" r="15" fill="none" stroke="#33d17a" stroke-width="1"/>
|
|
121
|
+
</svg>
|
|
122
|
+
<svg class="particle" style="left:75%;width:35px;animation-delay:8s;animation-duration:28s" viewBox="0 0 60 60">
|
|
123
|
+
<path d="M30,5 L55,30 L30,55 L5,30 Z" fill="none" stroke="#c69ff5" stroke-width="1"/>
|
|
124
|
+
<path d="M30,15 L45,30 L30,45 L15,30 Z" fill="none" stroke="#33d17a" stroke-width="1"/>
|
|
125
|
+
</svg>
|
|
126
|
+
<svg class="particle" style="left:90%;width:18px;animation-delay:12s;animation-duration:20s" viewBox="0 0 40 40">
|
|
127
|
+
<polygon points="20,2 38,20 20,38 2,20" fill="none" stroke="#33d17a" stroke-width="1"/>
|
|
128
|
+
</svg>
|
|
129
|
+
</div>
|
|
130
|
+
|
|
131
|
+
<div class="offline-container">
|
|
132
|
+
<!-- ASCII falcon logo -->
|
|
133
|
+
<div class="ascii-logo">
|
|
134
|
+
-%%%%%%%%%%%##**++==---::....
|
|
135
|
+
*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%%%%%##*+=--::...
|
|
136
|
+
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%#*######******##*****+
|
|
137
|
+
.#@%**+++**##%%@@@@@@@@@@@@@@@@@@%#*#*******************:
|
|
138
|
+
.#@#*+.-*######%%%%#**+++++=+#@@%%#*#####***************+
|
|
139
|
+
.#@#*=:=***####%%%%%%%%%%%%%#%@@%##*####*****************:
|
|
140
|
+
.%@#*--+****######%%%%%%%%%%%@@@%##*#####***************+:
|
|
141
|
+
:%@##-=+****########%%%%%%%%%@@@%##*####****************+.
|
|
142
|
+
:%@#*-===+++**########%%%%%%@@@@%#**#####**************+*.
|
|
143
|
+
:@@#*-====++++**###########%%@@@%#*######**************+*
|
|
144
|
+
-@@#*--====+++++++*****#####%@@@%#*#######*************++
|
|
145
|
+
-@@#*--======++++++++++*****#@@%%#*#####***************++
|
|
146
|
+
-@%#*--========+++++++++++++#@@%%#*######**************++
|
|
147
|
+
=@%#*--=================+===#@@%%#*##*****************++=
|
|
148
|
+
=@%#*---====================#@@%#**#####*#************++=
|
|
149
|
+
=@%#*----===================%@@%#*########************++-
|
|
150
|
+
+@%%@#*+====================@@@%#*######*************+++-
|
|
151
|
+
+@@@@@@@@@%%*==============-@@@%#*###*#**************+++:
|
|
152
|
+
+@@@@@@@@@@@@@@@@@@@#+======@@@%#**##****************+++:
|
|
153
|
+
*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%***#****************++++.
|
|
154
|
+
*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%********************++++.
|
|
155
|
+
*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%*******************+++++
|
|
156
|
+
*@@@@@@@@@@@@@##@@@@@@@@@@@@@@%#******************+++++=
|
|
157
|
+
#@%%@@@@@@@@@@@@@%#-:=*#%%@@@@%#*****************++++++=
|
|
158
|
+
.#@@@@@@@@@@@@@@@@@@@@@%=::*@@@%#*****************++++++=
|
|
159
|
+
+##%%@@@@@@@@@@@@@@@@@@@@@@@@@%*****************++++++=-
|
|
160
|
+
.*%#*#%##: .:+####%%%@@@@@@@@@@@@@@@@@@%*****************+++=+==-
|
|
161
|
+
.:*@%##+**++%%#%%*-:.-++===**##%%%@@@@@@@@@@@@@%***************+++=+=+==:
|
|
162
|
+
-*%%%##%*#+*****+#**##%%%#*=======++*##%%%%@@@@@%#************++*++++++-.
|
|
163
|
+
-%@@#%#**+#+##+**=#*+#*+#+##+#%@@#+=========+####%%##*********+++++++++:.
|
|
164
|
+
.=%@@@@##*+*#+##*+#+##***+**+**+#*+#**#%%@#++======-==+*=--=****++*+**+=: .:.
|
|
165
|
+
.*@@@@@@@%*##*###**+#***#+*#**#*+#***#=*+*#**%%%%#*+=====::++*****+***-: :.
|
|
166
|
+
+%@@@@@@@@@@########**#+#*+**+#*+*#*+#*+##+**+####%@@@#====++*****: ::
|
|
167
|
+
-*##%@@@@@@@@@%########*+#+*#*+*#+#*****=#*+*#****%@@@@@@#-=+=: :-
|
|
168
|
+
.:=*#%%@@@@@@@@@@%#########+*+##*+**+###******%@@@@@@%#*:...... ::
|
|
169
|
+
.*##%%@@@@@@@@@@%###*+####+*%%####****#@@@@@@@##**=--=-==++++. .-=.
|
|
170
|
+
.-+#%%@@@@@@@@@@@%###*+##*=+##***%@@@@@@%#**+-.:.. ..:-==: .:--:.
|
|
171
|
+
.-*#%%@@@@@@@@@@@%##**%%%%%@@@@@@@%#**+: .:=#**==-+---:.:----::::.
|
|
172
|
+
:+##%%@@@@@@@@@@@@@@@@@@@@@@##**+-. :#@#####***+--=.
|
|
173
|
+
.-+#%%%@@@@@@@@@@@@@@@%#**+-. .+@@@@@@@@%%%@@@%-
|
|
174
|
+
.:*##%%@@@@@@@@@%#**+: .=%@@@@@@@@@@@@@@##*=
|
|
175
|
+
.-*##%%@@@#**+=. .*@@@@@@@@@@@@@@%#*****.
|
|
176
|
+
:=*##**+-. =@@@@@@@@@@@@@%#****+-.
|
|
177
|
+
.::. +@@@@@@@@@@@#****+-.
|
|
178
|
+
:+#%@@@@@#***+=.
|
|
179
|
+
</div>
|
|
180
|
+
|
|
181
|
+
<div class="offline-title">> offline</div>
|
|
182
|
+
|
|
183
|
+
<p class="offline-message">
|
|
184
|
+
No network connection available.<br>
|
|
185
|
+
Claudeck requires a connection to communicate with Claude.
|
|
186
|
+
</p>
|
|
187
|
+
<button class="retry-btn" onclick="location.reload()">retry connection</button>
|
|
188
|
+
</div>
|
|
189
|
+
</body>
|
|
190
|
+
</html>
|
package/public/style.css
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* ── Claudeck styles ──────────────────────────────────── */
|
|
2
|
+
/* Split into focused modules loaded via @import */
|
|
3
|
+
|
|
4
|
+
@import url("css/core/variables.css");
|
|
5
|
+
@import url("css/core/reset.css");
|
|
6
|
+
@import url("css/core/components.css");
|
|
7
|
+
@import url("css/core/layout.css");
|
|
8
|
+
@import url("css/ui/sessions.css");
|
|
9
|
+
@import url("css/ui/messages.css");
|
|
10
|
+
@import url("css/ui/parallel.css");
|
|
11
|
+
@import url("css/ui/modals.css");
|
|
12
|
+
@import url("css/ui/toolbox.css");
|
|
13
|
+
@import url("css/ui/commands.css");
|
|
14
|
+
@import url("css/ui/file-picker.css");
|
|
15
|
+
@import url("css/features/home.css");
|
|
16
|
+
@import url("css/features/cost-dashboard.css");
|
|
17
|
+
@import url("css/features/analytics.css");
|
|
18
|
+
@import url("css/core/theme.css");
|
|
19
|
+
@import url("css/core/print.css");
|
|
20
|
+
@import url("css/features/background-sessions.css");
|
|
21
|
+
@import url("css/ui/permissions.css");
|
|
22
|
+
@import url("css/ui/right-panel.css");
|
|
23
|
+
@import url("css/panels/file-explorer.css");
|
|
24
|
+
@import url("css/panels/git-panel.css");
|
|
25
|
+
|
|
26
|
+
@import url("css/panels/mcp-manager.css");
|
|
27
|
+
@import url("css/ui/image-attachments.css");
|
|
28
|
+
@import url("css/panels/tips-feed.css");
|
|
29
|
+
@import url("css/ui/context-gauge.css");
|
|
30
|
+
|
|
31
|
+
@import url("css/panels/assistant-bot.css");
|
|
32
|
+
@import url("css/features/agents.css");
|
|
33
|
+
@import url("css/features/agent-monitor.css");
|
|
34
|
+
@import url("css/features/agent-sidebar.css");
|
|
35
|
+
@import url("css/ui/status-bar.css");
|
|
36
|
+
@import url("css/panels/dev-docs.css");
|
|
37
|
+
@import url("css/features/telegram.css");
|
|
38
|
+
@import url("css/features/voice-input.css");
|
|
39
|
+
@import url("css/features/retro-terminal.css");
|
|
40
|
+
@import url("css/features/welcome.css");
|
|
41
|
+
@import url("css/features/tour.css");
|
|
42
|
+
@import url("css/core/responsive.css");
|
package/public/sw.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// Service worker for PWA — offline fallback + push notifications
|
|
2
|
+
|
|
3
|
+
const CACHE_NAME = 'claudeck-v1';
|
|
4
|
+
const OFFLINE_URL = '/offline.html';
|
|
5
|
+
|
|
6
|
+
// Assets to pre-cache for offline support
|
|
7
|
+
const PRECACHE_URLS = [
|
|
8
|
+
OFFLINE_URL,
|
|
9
|
+
'/icons/icon-192.png',
|
|
10
|
+
'/icons/icon-512.png',
|
|
11
|
+
];
|
|
12
|
+
|
|
13
|
+
// ── Install: pre-cache offline page ──
|
|
14
|
+
self.addEventListener('install', (event) => {
|
|
15
|
+
event.waitUntil(
|
|
16
|
+
caches.open(CACHE_NAME).then((cache) => cache.addAll(PRECACHE_URLS))
|
|
17
|
+
);
|
|
18
|
+
self.skipWaiting();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// ── Activate: clean old caches ──
|
|
22
|
+
self.addEventListener('activate', (event) => {
|
|
23
|
+
event.waitUntil(
|
|
24
|
+
caches.keys().then((keys) =>
|
|
25
|
+
Promise.all(keys.filter((k) => k !== CACHE_NAME).map((k) => caches.delete(k)))
|
|
26
|
+
).then(() => self.clients.claim())
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
// ── Fetch: network-first, offline fallback for navigations ──
|
|
31
|
+
self.addEventListener('fetch', (event) => {
|
|
32
|
+
// Only handle GET requests
|
|
33
|
+
if (event.request.method !== 'GET') return;
|
|
34
|
+
|
|
35
|
+
// Navigation requests (HTML pages) — show offline page on failure
|
|
36
|
+
if (event.request.mode === 'navigate') {
|
|
37
|
+
event.respondWith(
|
|
38
|
+
fetch(event.request).catch(() => caches.match(OFFLINE_URL))
|
|
39
|
+
);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Static assets (icons) — cache-first
|
|
44
|
+
if (event.request.url.includes('/icons/')) {
|
|
45
|
+
event.respondWith(
|
|
46
|
+
caches.match(event.request).then((cached) => cached || fetch(event.request))
|
|
47
|
+
);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Everything else — network only (localhost app)
|
|
52
|
+
event.respondWith(fetch(event.request));
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// ── Web Push — show notification only when no client is focused ──
|
|
56
|
+
self.addEventListener('push', (event) => {
|
|
57
|
+
if (!event.data) return;
|
|
58
|
+
const data = event.data.json();
|
|
59
|
+
|
|
60
|
+
event.waitUntil(
|
|
61
|
+
clients.matchAll({ type: 'window', includeUncontrolled: true }).then((windowClients) => {
|
|
62
|
+
const anyFocused = windowClients.some((c) => c.focused);
|
|
63
|
+
if (anyFocused) return; // skip — user is already looking at the app
|
|
64
|
+
|
|
65
|
+
// Tell any open (unfocused) client to play a sound
|
|
66
|
+
windowClients.forEach((c) => c.postMessage({ type: 'play-notification-sound' }));
|
|
67
|
+
|
|
68
|
+
return self.registration.showNotification(data.title || 'Claudeck', {
|
|
69
|
+
body: data.body || '',
|
|
70
|
+
tag: data.tag || 'default',
|
|
71
|
+
icon: '/icons/icon-192.png',
|
|
72
|
+
silent: true, // suppress OS sound — client plays its own
|
|
73
|
+
});
|
|
74
|
+
})
|
|
75
|
+
);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// ── Focus or open the app when a notification is clicked ──
|
|
79
|
+
self.addEventListener('notificationclick', (event) => {
|
|
80
|
+
event.notification.close();
|
|
81
|
+
event.waitUntil(
|
|
82
|
+
clients.matchAll({ type: 'window', includeUncontrolled: true }).then((windowClients) => {
|
|
83
|
+
for (const client of windowClients) {
|
|
84
|
+
if (client.url.includes(self.location.origin) && 'focus' in client) {
|
|
85
|
+
return client.focus();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return clients.openWindow('/');
|
|
89
|
+
})
|
|
90
|
+
);
|
|
91
|
+
});
|