offline-page-kit 0.2.1 โ†’ 0.2.2

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 ADDED
File without changes
package/README.md ADDED
@@ -0,0 +1,264 @@
1
+ <!-- =============================================== -->
2
+ <!-- ๐Ÿ”ฅ Animated SVG Header Banner -->
3
+ <!-- =============================================== -->
4
+
5
+ <p align="center">
6
+ <img src="https://capsule-render.vercel.app/api?type=waving&color=ff7a00&height=200&section=header&text=offline-page-kit&fontSize=42&fontColor=ffffff&animation=fadeIn&fontAlignY=38" />
7
+ </p>
8
+
9
+ <p align="center">
10
+ <b>Framework-agnostic Offline Fallback System</b><br/>
11
+ Lightweight โ€ข Deterministic โ€ข Production-Safe
12
+ </p>
13
+
14
+ ---
15
+
16
+ <!-- =============================================== -->
17
+ <!-- ๐ŸŒ Social & Community Links -->
18
+ <!-- =============================================== -->
19
+
20
+ <p align="center">
21
+ ๐ŸŒ <b>Website:</b> <a href="https://devcrack.dev">devcrack.dev</a> &nbsp; | &nbsp;
22
+ โ–ถ๏ธ <b>YouTube:</b> <a href="https://www.youtube.com/@dev-crack">DevCrack Channel</a><br/>
23
+ ๐Ÿ”น <b>Facebook:</b> <a href="https://web.facebook.com/profile.php?id=61573018852861">Profile</a> &nbsp; | &nbsp;
24
+ ๐Ÿ”น <b>Community Group:</b> <a href="https://web.facebook.com/groups/1672263410026163">Join Community</a>
25
+ </p>
26
+
27
+ ---
28
+
29
+ <!-- =============================================== -->
30
+ <!-- ๐ŸŸข NPM + CI + Coverage Badges -->
31
+ <!-- =============================================== -->
32
+
33
+ <p align="center">
34
+ <a href="https://www.npmjs.com/package/offline-page-kit">
35
+ <img src="https://img.shields.io/npm/v/offline-page-kit?style=for-the-badge&color=orange" alt="npm version">
36
+ </a>
37
+ <a href="https://www.npmjs.com/package/offline-page-kit">
38
+ <img src="https://img.shields.io/npm/dm/offline-page-kit?style=for-the-badge&color=blue" alt="npm downloads">
39
+ </a>
40
+ <a href="https://bundlephobia.com/package/offline-page-kit">
41
+ <img src="https://img.shields.io/bundlephobia/minzip/offline-page-kit?style=for-the-badge&color=purple" alt="bundle size">
42
+ </a>
43
+ <img src="https://img.shields.io/github/actions/workflow/status/YOUR_GITHUB_USERNAME/offline-page-kit/ci.yml?style=for-the-badge" alt="CI status">
44
+ <img src="https://img.shields.io/codecov/c/github/YOUR_GITHUB_USERNAME/offline-page-kit?style=for-the-badge" alt="coverage">
45
+ <img src="https://img.shields.io/badge/TypeScript-Ready-3178c6?style=for-the-badge&logo=typescript&logoColor=white" alt="TypeScript Ready">
46
+ <img src="https://img.shields.io/badge/Zero-Dependencies-black?style=for-the-badge" alt="Zero Dependencies">
47
+ </p>
48
+
49
+ ---
50
+
51
+ # ๐Ÿ“ฆ offline-page-kit
52
+
53
+ > Minimal, framework-agnostic Service Worker generator that prevents blank screens during network failure.
54
+
55
+ ---
56
+
57
+ # ๐ŸŸก Professional npm Description
58
+
59
+ **offline-page-kit** is a lightweight, zero-dependency Service Worker toolkit that provides deterministic offline fallback behavior for modern web applications.
60
+
61
+ It guarantees that when network connectivity fails, users see a controlled offline experience instead of browser error pages or blank screens.
62
+
63
+ Designed for production-grade stability across:
64
+
65
+ - Next.js
66
+ - Vite
67
+ - React
68
+ - Vue
69
+ - Static sites
70
+ - Any public-folder architecture
71
+
72
+ No Workbox.
73
+ No complex runtime caching layers.
74
+ No unpredictable asset behavior.
75
+
76
+ Just reliable navigation fallback.
77
+
78
+ ---
79
+
80
+ # ๐Ÿš€ Quick Start
81
+
82
+ ### 1๏ธโƒฃ Install
83
+
84
+ ```
85
+ npm install offline-page-kit
86
+ ```
87
+
88
+ ### 2๏ธโƒฃ Generate Service Worker
89
+
90
+ ```
91
+ npx offline-page-kit init --outDir public
92
+ ```
93
+
94
+ This generates:
95
+
96
+ ```
97
+ public/
98
+ โ”œโ”€โ”€ sw.js
99
+ โ”œโ”€โ”€ offline.html
100
+ โ””โ”€โ”€ offline.svg
101
+ ```
102
+
103
+ ### 3๏ธโƒฃ Register in Client
104
+
105
+ ```ts
106
+ import { registerOfflineKit } from "offline-page-kit";
107
+
108
+ registerOfflineKit({ debug: true });
109
+ ```
110
+
111
+ Done โœ…
112
+
113
+ ---
114
+
115
+ # ๐Ÿง  Architecture
116
+
117
+ ```
118
+ Browser
119
+ โ†“
120
+ Service Worker
121
+ โ†“
122
+ Fetch Navigation Request
123
+ โ”œโ”€ Network OK โ†’ return live page
124
+ โ””โ”€ Network FAIL โ†’ return cached offline.html
125
+ ```
126
+
127
+ Only navigation requests are intercepted.
128
+
129
+ No API mutation.
130
+ No asset rewriting.
131
+ No hidden caching layers.
132
+
133
+ ---
134
+
135
+ # ๐Ÿ”„ Lifecycle
136
+
137
+ ```
138
+ Install โ†’ Activate โ†’ Control โ†’ Fetch
139
+ ```
140
+
141
+ ### Install
142
+ - Caches offline page + fallback image
143
+ - Uses Promise.allSettled() to avoid failure
144
+
145
+ ### Activate
146
+ - Immediately claims clients
147
+
148
+ ### Fetch
149
+ - Applies network-first
150
+ - Falls back to offline page
151
+
152
+ ---
153
+
154
+ # ๐Ÿงฉ Framework Examples
155
+
156
+ ## Next.js (App Router)
157
+
158
+ ```tsx
159
+ "use client";
160
+
161
+ import { useEffect } from "react";
162
+ import { registerOfflineKit } from "offline-page-kit";
163
+
164
+ export default function SWRegister() {
165
+ useEffect(() => {
166
+ registerOfflineKit({ debug: true });
167
+ }, []);
168
+ return null;
169
+ }
170
+ ```
171
+
172
+ ---
173
+
174
+ ## Vite / React
175
+
176
+ ```ts
177
+ import { registerOfflineKit } from "offline-page-kit";
178
+
179
+ registerOfflineKit();
180
+ ```
181
+
182
+ ---
183
+
184
+ # โš™ CLI Options
185
+
186
+ ```
187
+ npx offline-page-kit init \
188
+ --outDir public \
189
+ --offlinePage /offline.html \
190
+ --offlineImage /offline.svg \
191
+ --cacheName my-app-cache
192
+ ```
193
+
194
+ | Option | Default | Description |
195
+ |--------|---------|------------|
196
+ | outDir | public | Static folder |
197
+ | offlinePage | /offline.html | Navigation fallback |
198
+ | offlineImage | /offline.svg | Fallback asset |
199
+ | cacheName | offline-page-kit | Cache namespace |
200
+
201
+ ---
202
+
203
+ # ๐Ÿ” Security
204
+
205
+ - Requires HTTPS (or localhost)
206
+ - Does not cache authenticated APIs
207
+ - Does not alter CORS behavior
208
+ - Per-origin scoped
209
+
210
+ ---
211
+
212
+ # โšก Performance
213
+
214
+ - Zero runtime dependencies
215
+ - Minimal memory usage
216
+ - No background sync
217
+ - No bundle overhead
218
+
219
+ ---
220
+
221
+ # ๐Ÿงช Testing
222
+
223
+ 1. Load site
224
+ 2. Reload once
225
+ 3. DevTools โ†’ Application โ†’ Service Workers
226
+ 4. Enable Offline
227
+ 5. Refresh
228
+
229
+ Offline page should render.
230
+
231
+ ---
232
+
233
+ # ๐Ÿข Production Notes
234
+
235
+ - Always deploy over HTTPS
236
+ - Version cache when updating logic
237
+ - Avoid multiple SWs in same scope
238
+
239
+ ---
240
+
241
+ # ๐Ÿงญ Roadmap
242
+
243
+ - Asset caching layer
244
+ - API strategy module
245
+ - Auto public folder scan
246
+ - Cache version hashing
247
+ - Metrics integration
248
+ - Advanced fallback strategies
249
+
250
+ ---
251
+
252
+ # ๐Ÿ“œ License
253
+
254
+ MIT
255
+
256
+ ---
257
+
258
+ <p align="center">
259
+ Built for modern web applications.
260
+ </p>
261
+
262
+ <p align="center">
263
+ <img src="https://capsule-render.vercel.app/api?type=waving&color=ff7a00&height=120&section=footer"/>
264
+ </p>