@djangocfg/nextjs 2.1.36 → 2.1.38
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/README.md +146 -1
- package/dist/config/index.d.mts +7 -428
- package/dist/config/index.mjs +80 -396
- package/dist/config/index.mjs.map +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +80 -396
- package/dist/index.mjs.map +1 -1
- package/dist/plugin-DuRJ_Jq6.d.mts +100 -0
- package/dist/pwa/cli.d.mts +1 -0
- package/dist/pwa/cli.mjs +140 -0
- package/dist/pwa/cli.mjs.map +1 -0
- package/dist/pwa/index.d.mts +274 -0
- package/dist/pwa/index.mjs +327 -0
- package/dist/pwa/index.mjs.map +1 -0
- package/dist/pwa/server/index.d.mts +86 -0
- package/dist/pwa/server/index.mjs +175 -0
- package/dist/pwa/server/index.mjs.map +1 -0
- package/dist/pwa/server/routes.d.mts +2 -0
- package/dist/pwa/server/routes.mjs +149 -0
- package/dist/pwa/server/routes.mjs.map +1 -0
- package/dist/pwa/worker/index.d.mts +56 -0
- package/dist/pwa/worker/index.mjs +97 -0
- package/dist/pwa/worker/index.mjs.map +1 -0
- package/dist/routes-DXA29sS_.d.mts +68 -0
- package/package.json +39 -8
- package/src/config/createNextConfig.ts +9 -13
- package/src/config/index.ts +2 -20
- package/src/config/plugins/devStartup.ts +35 -36
- package/src/config/plugins/index.ts +1 -1
- package/src/config/utils/index.ts +0 -1
- package/src/index.ts +4 -0
- package/src/pwa/cli.ts +171 -0
- package/src/pwa/index.ts +9 -0
- package/src/pwa/manifest.ts +355 -0
- package/src/pwa/notifications.ts +192 -0
- package/src/pwa/plugin.ts +194 -0
- package/src/pwa/server/index.ts +23 -0
- package/src/pwa/server/push.ts +166 -0
- package/src/pwa/server/routes.ts +137 -0
- package/src/pwa/worker/index.ts +174 -0
- package/src/pwa/worker/package.json +3 -0
- package/src/config/plugins/pwa.ts +0 -616
- package/src/config/utils/manifest.ts +0 -214
package/README.md
CHANGED
|
@@ -116,7 +116,7 @@ export default withBundleAnalyzer(createBaseNextConfig({
|
|
|
116
116
|
|
|
117
117
|
```tsx
|
|
118
118
|
// app/manifest.ts
|
|
119
|
-
import { createManifest } from '@djangocfg/nextjs/config';
|
|
119
|
+
import { createManifest, createScreenshots } from '@djangocfg/nextjs/config';
|
|
120
120
|
import { settings } from '@core/settings';
|
|
121
121
|
|
|
122
122
|
export default createManifest({
|
|
@@ -129,6 +129,12 @@ export default createManifest({
|
|
|
129
129
|
logo384: settings.app.icons.logo384,
|
|
130
130
|
logo512: settings.app.icons.logo512,
|
|
131
131
|
},
|
|
132
|
+
// Optional: Add screenshots for Richer PWA Install UI
|
|
133
|
+
// IMPORTANT: Image dimensions must match sizes parameter!
|
|
134
|
+
// screenshots: createScreenshots([
|
|
135
|
+
// '/screenshots/desktop-1920x1080.png', // Wide: 1920x1080
|
|
136
|
+
// '/screenshots/mobile-390x844.png', // Narrow: 390x844
|
|
137
|
+
// ]),
|
|
132
138
|
});
|
|
133
139
|
```
|
|
134
140
|
|
|
@@ -173,6 +179,141 @@ export default createBaseNextConfig({
|
|
|
173
179
|
|
|
174
180
|
See [PWA.md](./PWA.md) for complete guide.
|
|
175
181
|
|
|
182
|
+
### Push Notifications
|
|
183
|
+
|
|
184
|
+
**Zero-config push notifications** using standard Web Push Protocol (no Firebase needed).
|
|
185
|
+
|
|
186
|
+
#### PWA CLI
|
|
187
|
+
|
|
188
|
+
Quick commands for managing push notifications:
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
# Generate VAPID keys
|
|
192
|
+
pnpm pwa vapid
|
|
193
|
+
|
|
194
|
+
# Check PWA status
|
|
195
|
+
pnpm pwa status
|
|
196
|
+
|
|
197
|
+
# Send test push
|
|
198
|
+
pnpm pwa send '<subscription-json>'
|
|
199
|
+
|
|
200
|
+
# Show help
|
|
201
|
+
pnpm pwa info
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
#### 1. Generate VAPID keys
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
pnpm pwa vapid
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Add to `.env.local`:
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
NEXT_PUBLIC_VAPID_PUBLIC_KEY=your_public_key_here
|
|
214
|
+
VAPID_PRIVATE_KEY=your_private_key_here
|
|
215
|
+
VAPID_MAILTO=mailto:your-email@example.com
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
#### 2. Add API routes
|
|
219
|
+
|
|
220
|
+
```tsx
|
|
221
|
+
// app/api/push/subscribe/route.ts
|
|
222
|
+
export { POST, GET } from '@djangocfg/nextjs/pwa/server/routes';
|
|
223
|
+
|
|
224
|
+
// app/api/push/send/route.ts
|
|
225
|
+
export { handleSend as POST } from '@djangocfg/nextjs/pwa/server/routes';
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
#### 3. Enable push in service worker
|
|
229
|
+
|
|
230
|
+
```tsx
|
|
231
|
+
// app/sw.ts
|
|
232
|
+
import { createServiceWorker } from '@djangocfg/nextjs/pwa/worker';
|
|
233
|
+
import { settings } from '@core/settings';
|
|
234
|
+
|
|
235
|
+
createServiceWorker({
|
|
236
|
+
offlineFallback: '/_offline',
|
|
237
|
+
enablePushNotifications: true,
|
|
238
|
+
notificationIcon: settings.app.icons.logo192,
|
|
239
|
+
notificationBadge: settings.app.icons.logo192,
|
|
240
|
+
});
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
#### 4. Subscribe from client
|
|
244
|
+
|
|
245
|
+
```tsx
|
|
246
|
+
import { subscribeToPushNotifications } from '@djangocfg/nextjs/pwa';
|
|
247
|
+
|
|
248
|
+
const subscription = await subscribeToPushNotifications({
|
|
249
|
+
vapidPublicKey: process.env.NEXT_PUBLIC_VAPID_PUBLIC_KEY!,
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
// Save subscription to server
|
|
253
|
+
await fetch('/api/push/subscribe', {
|
|
254
|
+
method: 'POST',
|
|
255
|
+
headers: { 'Content-Type': 'application/json' },
|
|
256
|
+
body: JSON.stringify(subscription),
|
|
257
|
+
});
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
#### Testing with CLI
|
|
261
|
+
|
|
262
|
+
```bash
|
|
263
|
+
# 1. Start dev server
|
|
264
|
+
pnpm dev
|
|
265
|
+
|
|
266
|
+
# 2. Open browser console at http://localhost:3000
|
|
267
|
+
# 3. Subscribe to push notifications:
|
|
268
|
+
await (async () => {
|
|
269
|
+
const { subscribeToPushNotifications } = await import('@djangocfg/nextjs/pwa');
|
|
270
|
+
const sub = await subscribeToPushNotifications({
|
|
271
|
+
vapidPublicKey: 'YOUR_PUBLIC_KEY'
|
|
272
|
+
});
|
|
273
|
+
await fetch('/api/push/subscribe', {
|
|
274
|
+
method: 'POST',
|
|
275
|
+
headers: { 'Content-Type': 'application/json' },
|
|
276
|
+
body: JSON.stringify(sub)
|
|
277
|
+
});
|
|
278
|
+
console.log('Subscribed!', sub);
|
|
279
|
+
})();
|
|
280
|
+
|
|
281
|
+
# 4. Send test notification (from another console tab or curl):
|
|
282
|
+
fetch('/api/push/send', {
|
|
283
|
+
method: 'POST',
|
|
284
|
+
headers: { 'Content-Type': 'application/json' },
|
|
285
|
+
body: JSON.stringify({
|
|
286
|
+
subscription: { /* paste subscription object */ },
|
|
287
|
+
notification: {
|
|
288
|
+
title: 'Test Push',
|
|
289
|
+
body: 'Hello from CLI!',
|
|
290
|
+
icon: '/static/logos/192x192.png'
|
|
291
|
+
}
|
|
292
|
+
})
|
|
293
|
+
});
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
Or use curl:
|
|
297
|
+
|
|
298
|
+
```bash
|
|
299
|
+
curl -X POST http://localhost:3000/api/push/send \
|
|
300
|
+
-H "Content-Type: application/json" \
|
|
301
|
+
-d '{
|
|
302
|
+
"subscription": {...},
|
|
303
|
+
"notification": {
|
|
304
|
+
"title": "Test",
|
|
305
|
+
"body": "Hello!"
|
|
306
|
+
}
|
|
307
|
+
}'
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
**Features:**
|
|
311
|
+
- Standard Web Push Protocol (VAPID)
|
|
312
|
+
- No Firebase or external services required
|
|
313
|
+
- Auto-configuration with helpful warnings
|
|
314
|
+
- Ready-to-use route handlers
|
|
315
|
+
- Built-in subscription management
|
|
316
|
+
|
|
176
317
|
### Sitemap Generation
|
|
177
318
|
|
|
178
319
|
Generate dynamic XML sitemaps for SEO:
|
|
@@ -299,6 +440,10 @@ import { RedirectPage } from '@djangocfg/layouts/components/RedirectPage';
|
|
|
299
440
|
| `@djangocfg/nextjs` | Main exports (all modules) |
|
|
300
441
|
| `@djangocfg/nextjs/ai` | AI documentation search and MCP config |
|
|
301
442
|
| `@djangocfg/nextjs/config` | Base Next.js configuration factory |
|
|
443
|
+
| `@djangocfg/nextjs/pwa` | PWA client utilities (service worker registration, push subscriptions) |
|
|
444
|
+
| `@djangocfg/nextjs/pwa/worker` | Service worker creation helpers |
|
|
445
|
+
| `@djangocfg/nextjs/pwa/server` | Server-side push notification utilities |
|
|
446
|
+
| `@djangocfg/nextjs/pwa/server/routes` | Ready-to-use API route handlers for push |
|
|
302
447
|
| `@djangocfg/nextjs/sitemap` | Sitemap generation utilities |
|
|
303
448
|
| `@djangocfg/nextjs/health` | Health check handlers |
|
|
304
449
|
| `@djangocfg/nextjs/og-image` | OG image generation |
|
package/dist/config/index.d.mts
CHANGED
|
@@ -1,313 +1,8 @@
|
|
|
1
|
-
import { NextConfig
|
|
1
|
+
import { NextConfig } from 'next';
|
|
2
2
|
import { Configuration, Compiler } from 'webpack';
|
|
3
|
+
import { P as PWAPluginOptions } from '../plugin-DuRJ_Jq6.mjs';
|
|
3
4
|
export { A as AI_DOCS_HINT, b as MCP_API_URL, M as MCP_BASE_URL, a as MCP_SERVER_URL } from '../constants-HezbftFb.mjs';
|
|
4
5
|
|
|
5
|
-
/**
|
|
6
|
-
* PWA (Progressive Web App) Plugin
|
|
7
|
-
*
|
|
8
|
-
* Configures @ducanh2912/next-pwa for service worker and offline support
|
|
9
|
-
* Modern fork that supports Next.js 13+ with app directory
|
|
10
|
-
*
|
|
11
|
-
* @see https://www.npmjs.com/package/@ducanh2912/next-pwa
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Runtime caching handler strategies
|
|
16
|
-
*/
|
|
17
|
-
type CacheStrategy = 'CacheFirst' | 'CacheOnly' | 'NetworkFirst' | 'NetworkOnly' | 'StaleWhileRevalidate';
|
|
18
|
-
/**
|
|
19
|
-
* Runtime cache entry configuration
|
|
20
|
-
*/
|
|
21
|
-
interface RuntimeCacheEntry {
|
|
22
|
-
urlPattern: RegExp | string | ((context: {
|
|
23
|
-
url: URL;
|
|
24
|
-
request: Request;
|
|
25
|
-
}) => boolean);
|
|
26
|
-
handler: CacheStrategy;
|
|
27
|
-
options?: {
|
|
28
|
-
cacheName?: string;
|
|
29
|
-
expiration?: {
|
|
30
|
-
maxEntries?: number;
|
|
31
|
-
maxAgeSeconds?: number;
|
|
32
|
-
purgeOnQuotaError?: boolean;
|
|
33
|
-
};
|
|
34
|
-
cacheableResponse?: {
|
|
35
|
-
statuses?: number[];
|
|
36
|
-
headers?: Record<string, string>;
|
|
37
|
-
};
|
|
38
|
-
rangeRequests?: boolean;
|
|
39
|
-
backgroundSync?: {
|
|
40
|
-
name: string;
|
|
41
|
-
options?: {
|
|
42
|
-
maxRetentionTime?: number;
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
broadcastUpdate?: {
|
|
46
|
-
channelName?: string;
|
|
47
|
-
options?: {
|
|
48
|
-
headersToCheck?: string[];
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
matchOptions?: {
|
|
52
|
-
ignoreSearch?: boolean;
|
|
53
|
-
ignoreMethod?: boolean;
|
|
54
|
-
ignoreVary?: boolean;
|
|
55
|
-
};
|
|
56
|
-
networkTimeoutSeconds?: number;
|
|
57
|
-
plugins?: any[];
|
|
58
|
-
fetchOptions?: RequestInit;
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
interface PWAPluginOptions {
|
|
62
|
-
/**
|
|
63
|
-
* Destination directory for service worker files
|
|
64
|
-
* @default 'public'
|
|
65
|
-
*/
|
|
66
|
-
dest: string;
|
|
67
|
-
/**
|
|
68
|
-
* Disable PWA completely
|
|
69
|
-
* @default false in production, true in development
|
|
70
|
-
* @example disable: process.env.NODE_ENV === 'development'
|
|
71
|
-
*/
|
|
72
|
-
disable?: boolean;
|
|
73
|
-
/**
|
|
74
|
-
* Auto-register service worker
|
|
75
|
-
* @default true
|
|
76
|
-
* @description Set to false if you want to register SW manually
|
|
77
|
-
*/
|
|
78
|
-
register?: boolean;
|
|
79
|
-
/**
|
|
80
|
-
* URL scope for PWA
|
|
81
|
-
* @default '/'
|
|
82
|
-
* @example '/app' - only /app/** will be PWA
|
|
83
|
-
*/
|
|
84
|
-
scope?: string;
|
|
85
|
-
/**
|
|
86
|
-
* Service worker file name
|
|
87
|
-
* @default 'sw.js'
|
|
88
|
-
*/
|
|
89
|
-
sw?: string;
|
|
90
|
-
/**
|
|
91
|
-
* Skip waiting for service worker activation
|
|
92
|
-
* @default true
|
|
93
|
-
* @description Activate new SW immediately
|
|
94
|
-
*/
|
|
95
|
-
skipWaiting?: boolean;
|
|
96
|
-
/**
|
|
97
|
-
* Client claim - take control of uncontrolled clients immediately
|
|
98
|
-
* @default true
|
|
99
|
-
*/
|
|
100
|
-
clientsClaim?: boolean;
|
|
101
|
-
/**
|
|
102
|
-
* Cleanup outdated caches automatically
|
|
103
|
-
* @default true
|
|
104
|
-
*/
|
|
105
|
-
cleanupOutdatedCaches?: boolean;
|
|
106
|
-
/**
|
|
107
|
-
* Runtime caching strategies
|
|
108
|
-
* @default defaultRuntimeCaching
|
|
109
|
-
* @see defaultRuntimeCaching for default configuration
|
|
110
|
-
*/
|
|
111
|
-
runtimeCaching?: RuntimeCacheEntry[];
|
|
112
|
-
/**
|
|
113
|
-
* Exclude files from build directory precaching
|
|
114
|
-
* @example [/chunks\/images\/.*$/] - don't precache images
|
|
115
|
-
*/
|
|
116
|
-
buildExcludes?: (string | RegExp | ((chunk: any) => boolean))[];
|
|
117
|
-
/**
|
|
118
|
-
* Exclude files from public directory precaching
|
|
119
|
-
* @default ['!noprecache/**\/*']
|
|
120
|
-
* @example ['!videos/**\/*', '!large-images/**\/*']
|
|
121
|
-
*/
|
|
122
|
-
publicExcludes?: string[];
|
|
123
|
-
/**
|
|
124
|
-
* Cache start URL (_app or / route)
|
|
125
|
-
* @default true
|
|
126
|
-
*/
|
|
127
|
-
cacheStartUrl?: boolean;
|
|
128
|
-
/**
|
|
129
|
-
* Dynamic start URL (returns different HTML for different states)
|
|
130
|
-
* @default true
|
|
131
|
-
* @description Set to false if start URL always returns same HTML
|
|
132
|
-
*/
|
|
133
|
-
dynamicStartUrl?: boolean;
|
|
134
|
-
/**
|
|
135
|
-
* Redirect URL if start URL redirects (e.g., to /login)
|
|
136
|
-
* @example '/login'
|
|
137
|
-
*/
|
|
138
|
-
dynamicStartUrlRedirect?: string;
|
|
139
|
-
/**
|
|
140
|
-
* Enable additional route caching on front-end navigation
|
|
141
|
-
* @default false
|
|
142
|
-
* @description Cache routes when navigating with next/link
|
|
143
|
-
*/
|
|
144
|
-
cacheOnFrontEndNav?: boolean;
|
|
145
|
-
/**
|
|
146
|
-
* Subdomain prefix for static files
|
|
147
|
-
* @deprecated Use basePath in next.config.js instead
|
|
148
|
-
*/
|
|
149
|
-
subdomainPrefix?: string;
|
|
150
|
-
/**
|
|
151
|
-
* Reload app when device goes back online
|
|
152
|
-
* @default true
|
|
153
|
-
*/
|
|
154
|
-
reloadOnOnline?: boolean;
|
|
155
|
-
/**
|
|
156
|
-
* Custom worker directory
|
|
157
|
-
* @default 'worker'
|
|
158
|
-
* @description Directory containing custom worker implementation
|
|
159
|
-
*/
|
|
160
|
-
customWorkerDir?: string;
|
|
161
|
-
/**
|
|
162
|
-
* Custom service worker source (for InjectManifest mode)
|
|
163
|
-
* @description Path to your custom service worker source
|
|
164
|
-
*/
|
|
165
|
-
swSrc?: string;
|
|
166
|
-
/**
|
|
167
|
-
* Offline fallback pages
|
|
168
|
-
* @example { document: '/_offline', image: '/offline.jpg' }
|
|
169
|
-
*/
|
|
170
|
-
fallbacks?: {
|
|
171
|
-
document?: string;
|
|
172
|
-
image?: string;
|
|
173
|
-
audio?: string;
|
|
174
|
-
video?: string;
|
|
175
|
-
font?: string;
|
|
176
|
-
};
|
|
177
|
-
/**
|
|
178
|
-
* Additional workbox options
|
|
179
|
-
* @see https://developer.chrome.com/docs/workbox/modules/workbox-webpack-plugin
|
|
180
|
-
*/
|
|
181
|
-
workboxOptions?: Record<string, any>;
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Check if @ducanh2912/next-pwa is installed
|
|
185
|
-
*
|
|
186
|
-
* Note: @ducanh2912/next-pwa is included as a dependency,
|
|
187
|
-
* so this should always return true unless there's an installation issue
|
|
188
|
-
*/
|
|
189
|
-
declare function isPWAAvailable(): boolean;
|
|
190
|
-
/**
|
|
191
|
-
* Add PWA configuration to Next.js config
|
|
192
|
-
*
|
|
193
|
-
* @example
|
|
194
|
-
* ```ts
|
|
195
|
-
* // Basic usage
|
|
196
|
-
* export default withPWA(nextConfig, {
|
|
197
|
-
* dest: 'public',
|
|
198
|
-
* disable: process.env.NODE_ENV === 'development',
|
|
199
|
-
* });
|
|
200
|
-
*
|
|
201
|
-
* // With custom runtime caching
|
|
202
|
-
* export default withPWA(nextConfig, {
|
|
203
|
-
* dest: 'public',
|
|
204
|
-
* runtimeCaching: [
|
|
205
|
-
* {
|
|
206
|
-
* urlPattern: /^https:\/\/api\.example\.com\/.* /i,
|
|
207
|
-
* handler: 'NetworkFirst',
|
|
208
|
-
* options: {
|
|
209
|
-
* cacheName: 'api-cache',
|
|
210
|
-
* expiration: { maxEntries: 50, maxAgeSeconds: 300 },
|
|
211
|
-
* },
|
|
212
|
-
* },
|
|
213
|
-
* ],
|
|
214
|
-
* });
|
|
215
|
-
*
|
|
216
|
-
* // With offline fallbacks
|
|
217
|
-
* export default withPWA(nextConfig, {
|
|
218
|
-
* dest: 'public',
|
|
219
|
-
* fallbacks: {
|
|
220
|
-
* document: '/_offline',
|
|
221
|
-
* image: '/offline.jpg',
|
|
222
|
-
* },
|
|
223
|
-
* });
|
|
224
|
-
* ```
|
|
225
|
-
*/
|
|
226
|
-
declare function withPWA(nextConfig: NextConfig, options?: Partial<PWAPluginOptions>): NextConfig;
|
|
227
|
-
/**
|
|
228
|
-
* Default runtime caching strategies
|
|
229
|
-
*
|
|
230
|
-
* Optimized caching rules for common assets:
|
|
231
|
-
* - Google Fonts (webfonts + stylesheets)
|
|
232
|
-
* - Static assets (images, fonts, audio, video)
|
|
233
|
-
* - Next.js resources (JS, CSS, data, images)
|
|
234
|
-
* - API routes excluded from page cache
|
|
235
|
-
*
|
|
236
|
-
* @example
|
|
237
|
-
* ```ts
|
|
238
|
-
* // Use default caching
|
|
239
|
-
* withPWA(nextConfig, {
|
|
240
|
-
* dest: 'public',
|
|
241
|
-
* runtimeCaching: defaultRuntimeCaching,
|
|
242
|
-
* });
|
|
243
|
-
*
|
|
244
|
-
* // Extend with custom rules
|
|
245
|
-
* withPWA(nextConfig, {
|
|
246
|
-
* dest: 'public',
|
|
247
|
-
* runtimeCaching: [
|
|
248
|
-
* ...defaultRuntimeCaching,
|
|
249
|
-
* {
|
|
250
|
-
* urlPattern: /^https:\/\/api\.example\.com\/.* /i,
|
|
251
|
-
* handler: 'NetworkFirst',
|
|
252
|
-
* options: { cacheName: 'api-cache' },
|
|
253
|
-
* },
|
|
254
|
-
* ],
|
|
255
|
-
* });
|
|
256
|
-
* ```
|
|
257
|
-
*/
|
|
258
|
-
declare const defaultRuntimeCaching: RuntimeCacheEntry[];
|
|
259
|
-
/**
|
|
260
|
-
* Helper: Create API caching rule
|
|
261
|
-
*
|
|
262
|
-
* @example
|
|
263
|
-
* ```ts
|
|
264
|
-
* createApiCacheRule('https://api.example.com', {
|
|
265
|
-
* strategy: 'NetworkFirst',
|
|
266
|
-
* maxAge: 300, // 5 minutes
|
|
267
|
-
* });
|
|
268
|
-
* ```
|
|
269
|
-
*/
|
|
270
|
-
declare function createApiCacheRule(apiUrl: string, options?: {
|
|
271
|
-
strategy?: CacheStrategy;
|
|
272
|
-
maxAge?: number;
|
|
273
|
-
maxEntries?: number;
|
|
274
|
-
cacheName?: string;
|
|
275
|
-
}): RuntimeCacheEntry;
|
|
276
|
-
/**
|
|
277
|
-
* Helper: Create static asset caching rule
|
|
278
|
-
*
|
|
279
|
-
* @example
|
|
280
|
-
* ```ts
|
|
281
|
-
* createStaticAssetRule(['jpg', 'png', 'webp'], {
|
|
282
|
-
* strategy: 'CacheFirst',
|
|
283
|
-
* maxAge: 86400, // 1 day
|
|
284
|
-
* });
|
|
285
|
-
* ```
|
|
286
|
-
*/
|
|
287
|
-
declare function createStaticAssetRule(extensions: string[], options?: {
|
|
288
|
-
strategy?: CacheStrategy;
|
|
289
|
-
maxAge?: number;
|
|
290
|
-
maxEntries?: number;
|
|
291
|
-
cacheName?: string;
|
|
292
|
-
}): RuntimeCacheEntry;
|
|
293
|
-
/**
|
|
294
|
-
* Helper: Create CDN caching rule
|
|
295
|
-
*
|
|
296
|
-
* @example
|
|
297
|
-
* ```ts
|
|
298
|
-
* createCdnCacheRule('https://cdn.example.com', {
|
|
299
|
-
* strategy: 'CacheFirst',
|
|
300
|
-
* maxAge: 2592000, // 30 days
|
|
301
|
-
* });
|
|
302
|
-
* ```
|
|
303
|
-
*/
|
|
304
|
-
declare function createCdnCacheRule(cdnUrl: string, options?: {
|
|
305
|
-
strategy?: CacheStrategy;
|
|
306
|
-
maxAge?: number;
|
|
307
|
-
maxEntries?: number;
|
|
308
|
-
cacheName?: string;
|
|
309
|
-
}): RuntimeCacheEntry;
|
|
310
|
-
|
|
311
6
|
/**
|
|
312
7
|
* Base Next.js Configuration Factory
|
|
313
8
|
*
|
|
@@ -338,12 +33,6 @@ interface BaseNextConfigOptions {
|
|
|
338
33
|
transpilePackages?: string[];
|
|
339
34
|
/** Additional optimize package imports (merged with defaults) */
|
|
340
35
|
optimizePackageImports?: string[];
|
|
341
|
-
/**
|
|
342
|
-
* Automatically open browser in dev mode (default: false)
|
|
343
|
-
* NOTE: Only works with webpack mode in Next.js 16+ (Turbopack doesn't support webpack plugins)
|
|
344
|
-
* For Turbopack compatibility, use a custom dev script instead of this option
|
|
345
|
-
*/
|
|
346
|
-
openBrowser?: boolean;
|
|
347
36
|
/** Check for @djangocfg/* package updates on startup (default: true) */
|
|
348
37
|
checkUpdates?: boolean;
|
|
349
38
|
/** Auto-update outdated packages without prompting (default: false) */
|
|
@@ -365,6 +54,8 @@ interface BaseNextConfigOptions {
|
|
|
365
54
|
* @default { enabled: true (in production), disable: true (in development) }
|
|
366
55
|
*/
|
|
367
56
|
pwa?: PWAPluginOptions | false;
|
|
57
|
+
/** Turbopack configuration (Next.js 16+ default bundler) */
|
|
58
|
+
turbopack?: NextConfig['turbopack'];
|
|
368
59
|
/** Custom webpack configuration function (called after base webpack logic) */
|
|
369
60
|
webpack?: (config: Configuration, options: {
|
|
370
61
|
isServer: boolean;
|
|
@@ -612,12 +303,10 @@ declare function resetUpdaterPreferences(): void;
|
|
|
612
303
|
/**
|
|
613
304
|
* Dev Startup Webpack Plugin
|
|
614
305
|
*
|
|
615
|
-
* Handles banner display, version checking, package updates
|
|
306
|
+
* Handles banner display, version checking, and package updates.
|
|
616
307
|
*/
|
|
617
308
|
|
|
618
309
|
interface DevStartupPluginOptions {
|
|
619
|
-
/** Auto-open browser */
|
|
620
|
-
openBrowser?: boolean;
|
|
621
310
|
/** Check for missing optional packages (default: true) */
|
|
622
311
|
checkPackages?: boolean;
|
|
623
312
|
/** Auto-install missing packages without prompting */
|
|
@@ -637,7 +326,7 @@ declare class DevStartupPlugin {
|
|
|
637
326
|
constructor(options?: DevStartupPluginOptions);
|
|
638
327
|
apply(compiler: Compiler): void;
|
|
639
328
|
private runStartupTasks;
|
|
640
|
-
private
|
|
329
|
+
private checkPWASetup;
|
|
641
330
|
}
|
|
642
331
|
/**
|
|
643
332
|
* Reset plugin state (useful for tests)
|
|
@@ -673,114 +362,4 @@ declare function addCompressionPlugins(config: Configuration, options?: Compress
|
|
|
673
362
|
*/
|
|
674
363
|
declare function isCompressionAvailable(): boolean;
|
|
675
364
|
|
|
676
|
-
|
|
677
|
-
* PWA Manifest Metadata Utilities
|
|
678
|
-
*
|
|
679
|
-
* Helper functions for creating Next.js metadata for PWA manifest
|
|
680
|
-
*/
|
|
681
|
-
|
|
682
|
-
interface ManifestConfig {
|
|
683
|
-
name: string;
|
|
684
|
-
shortName?: string;
|
|
685
|
-
description?: string;
|
|
686
|
-
themeColor?: string;
|
|
687
|
-
backgroundColor?: string;
|
|
688
|
-
display?: 'standalone' | 'fullscreen' | 'minimal-ui' | 'browser';
|
|
689
|
-
orientation?: 'portrait' | 'landscape' | 'any';
|
|
690
|
-
startUrl?: string;
|
|
691
|
-
scope?: string;
|
|
692
|
-
lang?: string;
|
|
693
|
-
dir?: 'ltr' | 'rtl' | 'auto';
|
|
694
|
-
icons?: {
|
|
695
|
-
src: string;
|
|
696
|
-
sizes: string;
|
|
697
|
-
type?: string;
|
|
698
|
-
purpose?: string;
|
|
699
|
-
}[];
|
|
700
|
-
}
|
|
701
|
-
/**
|
|
702
|
-
* Icon paths configuration
|
|
703
|
-
*/
|
|
704
|
-
interface IconPaths {
|
|
705
|
-
logo192?: string;
|
|
706
|
-
logo384?: string;
|
|
707
|
-
logo512?: string;
|
|
708
|
-
}
|
|
709
|
-
/**
|
|
710
|
-
* Create viewport configuration for Next.js app
|
|
711
|
-
*
|
|
712
|
-
* @example
|
|
713
|
-
* ```typescript
|
|
714
|
-
* export const viewport: Viewport = createViewport({
|
|
715
|
-
* themeColor: '#ffffff',
|
|
716
|
-
* });
|
|
717
|
-
* ```
|
|
718
|
-
*/
|
|
719
|
-
declare function createViewport(config: {
|
|
720
|
-
themeColor?: string;
|
|
721
|
-
}): Viewport;
|
|
722
|
-
/**
|
|
723
|
-
* Create manifest metadata for Next.js app
|
|
724
|
-
*
|
|
725
|
-
* Note: themeColor and viewport should be exported separately using createViewport()
|
|
726
|
-
*
|
|
727
|
-
* @example
|
|
728
|
-
* ```typescript
|
|
729
|
-
* export const metadata: Metadata = {
|
|
730
|
-
* ...createManifestMetadata({
|
|
731
|
-
* name: 'My App',
|
|
732
|
-
* shortName: 'App',
|
|
733
|
-
* description: 'My awesome app',
|
|
734
|
-
* }),
|
|
735
|
-
* };
|
|
736
|
-
*
|
|
737
|
-
* export const viewport: Viewport = createViewport({
|
|
738
|
-
* themeColor: '#ffffff',
|
|
739
|
-
* });
|
|
740
|
-
* ```
|
|
741
|
-
*/
|
|
742
|
-
declare function createManifestMetadata(config: ManifestConfig): Metadata;
|
|
743
|
-
/**
|
|
744
|
-
* Create Next.js manifest function
|
|
745
|
-
*
|
|
746
|
-
* Use this in your app/manifest.ts file
|
|
747
|
-
*
|
|
748
|
-
* @example
|
|
749
|
-
* ```typescript
|
|
750
|
-
* // app/manifest.ts
|
|
751
|
-
* import { createManifest } from '@djangocfg/nextjs/config';
|
|
752
|
-
* import { settings } from '@core/settings';
|
|
753
|
-
*
|
|
754
|
-
* export default createManifest({
|
|
755
|
-
* name: settings.app.name,
|
|
756
|
-
* description: settings.app.description,
|
|
757
|
-
* icons: {
|
|
758
|
-
* logo192: settings.app.icons.logo192,
|
|
759
|
-
* logo384: settings.app.icons.logo384,
|
|
760
|
-
* logo512: settings.app.icons.logo512,
|
|
761
|
-
* },
|
|
762
|
-
* });
|
|
763
|
-
* ```
|
|
764
|
-
*/
|
|
765
|
-
declare function createManifest(config: {
|
|
766
|
-
name: string;
|
|
767
|
-
shortName?: string;
|
|
768
|
-
description?: string;
|
|
769
|
-
themeColor?: string;
|
|
770
|
-
backgroundColor?: string;
|
|
771
|
-
display?: 'standalone' | 'fullscreen' | 'minimal-ui' | 'browser';
|
|
772
|
-
orientation?: 'portrait' | 'landscape' | 'any';
|
|
773
|
-
startUrl?: string;
|
|
774
|
-
scope?: string;
|
|
775
|
-
lang?: string;
|
|
776
|
-
dir?: 'ltr' | 'rtl' | 'auto';
|
|
777
|
-
icons?: IconPaths | ManifestConfig['icons'];
|
|
778
|
-
}): () => MetadataRoute.Manifest;
|
|
779
|
-
/**
|
|
780
|
-
* Generate manifest.json content (legacy)
|
|
781
|
-
*
|
|
782
|
-
* @deprecated Use createManifest() instead
|
|
783
|
-
*/
|
|
784
|
-
declare function generateManifest(config: ManifestConfig): Record<string, any>;
|
|
785
|
-
|
|
786
|
-
export { type BaseNextConfigOptions, type CacheStrategy, type CompressionPluginOptions, DEFAULT_OPTIMIZE_PACKAGES, DEFAULT_TRANSPILE_PACKAGES, DJANGOCFG_PACKAGES, DJANGO_CFG_BANNER, DevStartupPlugin, type DevStartupPluginOptions, type IconPaths, type InstallOptions, type InstallProgress, type ManifestConfig, type MissingPackage, OPTIONAL_PACKAGES, PACKAGE_NAME, PEER_DEPENDENCIES, type PWAPluginOptions, type PackageDefinition, type PackageVersion, type RuntimeCacheEntry, type UpdateOptions, addCompressionPlugins, buildInstallCommand, buildSingleInstallCommand, checkAndInstallPackages, checkAndUpdatePackages, checkForUpdate, checkForUpdates, checkPackages, createApiCacheRule, createBaseNextConfig, createCdnCacheRule, createManifest, createManifestMetadata, createStaticAssetRule, createViewport, deepMerge, defaultRuntimeCaching, detectPackageManager, fetchLatestVersion, generateManifest, getApiUrl, getBasePath, getCurrentVersion, getInstalledVersion, getMissingPackages, getOutdatedPackages, getPackagesForContext, getSiteUrl, getUpdateCommand, installPackages, installPackagesWithProgress, isCI, isCompressionAvailable, isDev, isPWAAvailable, isPackageInstalled, isProduction, isStaticBuild, printVersionInfo, resetDevStartupState, resetInstallerPreferences, resetUpdaterPreferences, updatePackagesWithProgress, withPWA };
|
|
365
|
+
export { type BaseNextConfigOptions, type CompressionPluginOptions, DEFAULT_OPTIMIZE_PACKAGES, DEFAULT_TRANSPILE_PACKAGES, DJANGOCFG_PACKAGES, DJANGO_CFG_BANNER, DevStartupPlugin, type DevStartupPluginOptions, type InstallOptions, type InstallProgress, type MissingPackage, OPTIONAL_PACKAGES, PACKAGE_NAME, PEER_DEPENDENCIES, type PackageDefinition, type PackageVersion, type UpdateOptions, addCompressionPlugins, buildInstallCommand, buildSingleInstallCommand, checkAndInstallPackages, checkAndUpdatePackages, checkForUpdate, checkForUpdates, checkPackages, createBaseNextConfig, deepMerge, detectPackageManager, fetchLatestVersion, getApiUrl, getBasePath, getCurrentVersion, getInstalledVersion, getMissingPackages, getOutdatedPackages, getPackagesForContext, getSiteUrl, getUpdateCommand, installPackages, installPackagesWithProgress, isCI, isCompressionAvailable, isDev, isPackageInstalled, isProduction, isStaticBuild, printVersionInfo, resetDevStartupState, resetInstallerPreferences, resetUpdaterPreferences, updatePackagesWithProgress };
|