@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
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* PWA Manifest Metadata Utilities
|
|
3
|
-
*
|
|
4
|
-
* Helper functions for creating Next.js metadata for PWA manifest
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type { Metadata, MetadataRoute, Viewport } from 'next';
|
|
8
|
-
|
|
9
|
-
export interface ManifestConfig {
|
|
10
|
-
name: string;
|
|
11
|
-
shortName?: string;
|
|
12
|
-
description?: string;
|
|
13
|
-
themeColor?: string;
|
|
14
|
-
backgroundColor?: string;
|
|
15
|
-
display?: 'standalone' | 'fullscreen' | 'minimal-ui' | 'browser';
|
|
16
|
-
orientation?: 'portrait' | 'landscape' | 'any';
|
|
17
|
-
startUrl?: string;
|
|
18
|
-
scope?: string;
|
|
19
|
-
lang?: string;
|
|
20
|
-
dir?: 'ltr' | 'rtl' | 'auto';
|
|
21
|
-
icons?: {
|
|
22
|
-
src: string;
|
|
23
|
-
sizes: string;
|
|
24
|
-
type?: string;
|
|
25
|
-
purpose?: string;
|
|
26
|
-
}[];
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Icon paths configuration
|
|
31
|
-
*/
|
|
32
|
-
export interface IconPaths {
|
|
33
|
-
logo192?: string;
|
|
34
|
-
logo384?: string;
|
|
35
|
-
logo512?: string;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Create viewport configuration for Next.js app
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```typescript
|
|
43
|
-
* export const viewport: Viewport = createViewport({
|
|
44
|
-
* themeColor: '#ffffff',
|
|
45
|
-
* });
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
|
-
export function createViewport(config: { themeColor?: string }): Viewport {
|
|
49
|
-
return {
|
|
50
|
-
width: 'device-width',
|
|
51
|
-
initialScale: 1,
|
|
52
|
-
maximumScale: 1,
|
|
53
|
-
themeColor: config.themeColor || '#000000',
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Create manifest metadata for Next.js app
|
|
59
|
-
*
|
|
60
|
-
* Note: themeColor and viewport should be exported separately using createViewport()
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* ```typescript
|
|
64
|
-
* export const metadata: Metadata = {
|
|
65
|
-
* ...createManifestMetadata({
|
|
66
|
-
* name: 'My App',
|
|
67
|
-
* shortName: 'App',
|
|
68
|
-
* description: 'My awesome app',
|
|
69
|
-
* }),
|
|
70
|
-
* };
|
|
71
|
-
*
|
|
72
|
-
* export const viewport: Viewport = createViewport({
|
|
73
|
-
* themeColor: '#ffffff',
|
|
74
|
-
* });
|
|
75
|
-
* ```
|
|
76
|
-
*/
|
|
77
|
-
export function createManifestMetadata(config: ManifestConfig): Metadata {
|
|
78
|
-
return {
|
|
79
|
-
manifest: '/manifest.json',
|
|
80
|
-
appleWebApp: {
|
|
81
|
-
capable: true,
|
|
82
|
-
statusBarStyle: 'default',
|
|
83
|
-
title: config.shortName || config.name,
|
|
84
|
-
},
|
|
85
|
-
applicationName: config.name,
|
|
86
|
-
formatDetection: {
|
|
87
|
-
telephone: false,
|
|
88
|
-
},
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Create Next.js manifest function
|
|
94
|
-
*
|
|
95
|
-
* Use this in your app/manifest.ts file
|
|
96
|
-
*
|
|
97
|
-
* @example
|
|
98
|
-
* ```typescript
|
|
99
|
-
* // app/manifest.ts
|
|
100
|
-
* import { createManifest } from '@djangocfg/nextjs/config';
|
|
101
|
-
* import { settings } from '@core/settings';
|
|
102
|
-
*
|
|
103
|
-
* export default createManifest({
|
|
104
|
-
* name: settings.app.name,
|
|
105
|
-
* description: settings.app.description,
|
|
106
|
-
* icons: {
|
|
107
|
-
* logo192: settings.app.icons.logo192,
|
|
108
|
-
* logo384: settings.app.icons.logo384,
|
|
109
|
-
* logo512: settings.app.icons.logo512,
|
|
110
|
-
* },
|
|
111
|
-
* });
|
|
112
|
-
* ```
|
|
113
|
-
*/
|
|
114
|
-
export function createManifest(config: {
|
|
115
|
-
name: string;
|
|
116
|
-
shortName?: string;
|
|
117
|
-
description?: string;
|
|
118
|
-
themeColor?: string;
|
|
119
|
-
backgroundColor?: string;
|
|
120
|
-
display?: 'standalone' | 'fullscreen' | 'minimal-ui' | 'browser';
|
|
121
|
-
orientation?: 'portrait' | 'landscape' | 'any';
|
|
122
|
-
startUrl?: string;
|
|
123
|
-
scope?: string;
|
|
124
|
-
lang?: string;
|
|
125
|
-
dir?: 'ltr' | 'rtl' | 'auto';
|
|
126
|
-
icons?: IconPaths | ManifestConfig['icons'];
|
|
127
|
-
}): () => MetadataRoute.Manifest {
|
|
128
|
-
return () => {
|
|
129
|
-
// Convert IconPaths to manifest icons format
|
|
130
|
-
let manifestIcons: MetadataRoute.Manifest['icons'];
|
|
131
|
-
|
|
132
|
-
if (Array.isArray(config.icons)) {
|
|
133
|
-
// Already in manifest format
|
|
134
|
-
manifestIcons = config.icons as MetadataRoute.Manifest['icons'];
|
|
135
|
-
} else if (config.icons) {
|
|
136
|
-
// Convert IconPaths to manifest icons
|
|
137
|
-
const { logo192, logo384, logo512 } = config.icons as IconPaths;
|
|
138
|
-
manifestIcons = [
|
|
139
|
-
...(logo192
|
|
140
|
-
? [
|
|
141
|
-
{
|
|
142
|
-
src: logo192,
|
|
143
|
-
sizes: '192x192',
|
|
144
|
-
type: 'image/png',
|
|
145
|
-
purpose: 'maskable' as const,
|
|
146
|
-
},
|
|
147
|
-
]
|
|
148
|
-
: []),
|
|
149
|
-
...(logo384
|
|
150
|
-
? [
|
|
151
|
-
{
|
|
152
|
-
src: logo384,
|
|
153
|
-
sizes: '384x384',
|
|
154
|
-
type: 'image/png',
|
|
155
|
-
},
|
|
156
|
-
]
|
|
157
|
-
: []),
|
|
158
|
-
...(logo512
|
|
159
|
-
? [
|
|
160
|
-
{
|
|
161
|
-
src: logo512,
|
|
162
|
-
sizes: '512x512',
|
|
163
|
-
type: 'image/png',
|
|
164
|
-
},
|
|
165
|
-
]
|
|
166
|
-
: []),
|
|
167
|
-
];
|
|
168
|
-
} else {
|
|
169
|
-
// Default icons
|
|
170
|
-
manifestIcons = [
|
|
171
|
-
{
|
|
172
|
-
src: '/static/logos/192x192.png',
|
|
173
|
-
sizes: '192x192',
|
|
174
|
-
type: 'image/png',
|
|
175
|
-
purpose: 'maskable' as const,
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
src: '/static/logos/384x384.png',
|
|
179
|
-
sizes: '384x384',
|
|
180
|
-
type: 'image/png',
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
src: '/static/logos/512x512.png',
|
|
184
|
-
sizes: '512x512',
|
|
185
|
-
type: 'image/png',
|
|
186
|
-
},
|
|
187
|
-
];
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
return {
|
|
191
|
-
name: config.name,
|
|
192
|
-
short_name: config.shortName || config.name,
|
|
193
|
-
description: config.description || config.name,
|
|
194
|
-
start_url: config.startUrl || '/',
|
|
195
|
-
scope: config.scope || '/',
|
|
196
|
-
display: config.display || 'standalone',
|
|
197
|
-
orientation: config.orientation || 'portrait',
|
|
198
|
-
background_color: config.backgroundColor || '#000000',
|
|
199
|
-
theme_color: config.themeColor || '#ffffff',
|
|
200
|
-
lang: config.lang || 'en',
|
|
201
|
-
dir: config.dir || 'ltr',
|
|
202
|
-
icons: manifestIcons,
|
|
203
|
-
};
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
/**
|
|
208
|
-
* Generate manifest.json content (legacy)
|
|
209
|
-
*
|
|
210
|
-
* @deprecated Use createManifest() instead
|
|
211
|
-
*/
|
|
212
|
-
export function generateManifest(config: ManifestConfig): Record<string, any> {
|
|
213
|
-
return createManifest(config)();
|
|
214
|
-
}
|