@djangocfg/nextjs 2.1.34 → 2.1.36
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 +0 -21
- package/dist/config/index.d.mts +21 -2
- package/dist/config/index.mjs +11 -10
- package/dist/config/index.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +11 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -7
- package/src/config/index.ts +1 -0
- package/src/config/utils/manifest.ts +26 -7
- package/bin/dev-with-browser.js +0 -105
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@djangocfg/nextjs",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.36",
|
|
4
4
|
"description": "Next.js server utilities: sitemap, health, OG images, contact forms, navigation, config",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nextjs",
|
|
@@ -83,13 +83,11 @@
|
|
|
83
83
|
"files": [
|
|
84
84
|
"dist",
|
|
85
85
|
"src",
|
|
86
|
-
"bin",
|
|
87
86
|
"README.md",
|
|
88
87
|
"LICENSE"
|
|
89
88
|
],
|
|
90
89
|
"bin": {
|
|
91
|
-
"djangocfg-docs": "./dist/ai/cli.mjs"
|
|
92
|
-
"nextjs-dev": "./bin/dev-with-browser.js"
|
|
90
|
+
"djangocfg-docs": "./dist/ai/cli.mjs"
|
|
93
91
|
},
|
|
94
92
|
"scripts": {
|
|
95
93
|
"build": "tsup",
|
|
@@ -111,9 +109,9 @@
|
|
|
111
109
|
"semver": "^7.7.3"
|
|
112
110
|
},
|
|
113
111
|
"devDependencies": {
|
|
114
|
-
"@djangocfg/imgai": "^2.1.
|
|
115
|
-
"@djangocfg/layouts": "^2.1.
|
|
116
|
-
"@djangocfg/typescript-config": "^2.1.
|
|
112
|
+
"@djangocfg/imgai": "^2.1.36",
|
|
113
|
+
"@djangocfg/layouts": "^2.1.36",
|
|
114
|
+
"@djangocfg/typescript-config": "^2.1.36",
|
|
117
115
|
"@types/node": "^24.7.2",
|
|
118
116
|
"@types/react": "19.2.2",
|
|
119
117
|
"@types/react-dom": "19.2.1",
|
package/src/config/index.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Helper functions for creating Next.js metadata for PWA manifest
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import type { Metadata, MetadataRoute } from 'next';
|
|
7
|
+
import type { Metadata, MetadataRoute, Viewport } from 'next';
|
|
8
8
|
|
|
9
9
|
export interface ManifestConfig {
|
|
10
10
|
name: string;
|
|
@@ -35,9 +35,30 @@ export interface IconPaths {
|
|
|
35
35
|
logo512?: string;
|
|
36
36
|
}
|
|
37
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
|
+
|
|
38
57
|
/**
|
|
39
58
|
* Create manifest metadata for Next.js app
|
|
40
59
|
*
|
|
60
|
+
* Note: themeColor and viewport should be exported separately using createViewport()
|
|
61
|
+
*
|
|
41
62
|
* @example
|
|
42
63
|
* ```typescript
|
|
43
64
|
* export const metadata: Metadata = {
|
|
@@ -47,12 +68,15 @@ export interface IconPaths {
|
|
|
47
68
|
* description: 'My awesome app',
|
|
48
69
|
* }),
|
|
49
70
|
* };
|
|
71
|
+
*
|
|
72
|
+
* export const viewport: Viewport = createViewport({
|
|
73
|
+
* themeColor: '#ffffff',
|
|
74
|
+
* });
|
|
50
75
|
* ```
|
|
51
76
|
*/
|
|
52
77
|
export function createManifestMetadata(config: ManifestConfig): Metadata {
|
|
53
78
|
return {
|
|
54
79
|
manifest: '/manifest.json',
|
|
55
|
-
themeColor: config.themeColor || '#000000',
|
|
56
80
|
appleWebApp: {
|
|
57
81
|
capable: true,
|
|
58
82
|
statusBarStyle: 'default',
|
|
@@ -62,11 +86,6 @@ export function createManifestMetadata(config: ManifestConfig): Metadata {
|
|
|
62
86
|
formatDetection: {
|
|
63
87
|
telephone: false,
|
|
64
88
|
},
|
|
65
|
-
viewport: {
|
|
66
|
-
width: 'device-width',
|
|
67
|
-
initialScale: 1,
|
|
68
|
-
maximumScale: 1,
|
|
69
|
-
},
|
|
70
89
|
};
|
|
71
90
|
}
|
|
72
91
|
|
package/bin/dev-with-browser.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* Next.js Dev Server with Auto Browser Opening
|
|
4
|
-
*
|
|
5
|
-
* Cross-platform solution that works with both Turbopack and webpack
|
|
6
|
-
* Opens browser automatically when server is ready
|
|
7
|
-
*
|
|
8
|
-
* Usage:
|
|
9
|
-
* "dev": "dev-with-browser"
|
|
10
|
-
* "dev": "dev-with-browser --port 3000"
|
|
11
|
-
* "dev": "dev-with-browser --webpack"
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
const { spawn } = require('child_process');
|
|
15
|
-
const { exec } = require('child_process');
|
|
16
|
-
const consola = require('consola');
|
|
17
|
-
|
|
18
|
-
// Parse arguments
|
|
19
|
-
const args = process.argv.slice(2);
|
|
20
|
-
const portArg = args.find(arg => arg.startsWith('--port') || arg === '-p');
|
|
21
|
-
const portIndex = args.indexOf(portArg);
|
|
22
|
-
const PORT = portArg
|
|
23
|
-
? args[portIndex + 1]
|
|
24
|
-
: process.env.PORT || '3000';
|
|
25
|
-
|
|
26
|
-
// Build next dev command
|
|
27
|
-
const nextArgs = ['dev'];
|
|
28
|
-
|
|
29
|
-
// Add port
|
|
30
|
-
if (!args.includes('-p') && !args.includes('--port')) {
|
|
31
|
-
nextArgs.push('-p', PORT);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Pass through other flags (like --webpack)
|
|
35
|
-
args.forEach((arg, i) => {
|
|
36
|
-
if (arg !== '-p' && arg !== '--port' && args[i - 1] !== '-p' && args[i - 1] !== '--port') {
|
|
37
|
-
nextArgs.push(arg);
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
const URL = `http://localhost:${PORT}`;
|
|
42
|
-
|
|
43
|
-
consola.info(`Starting Next.js dev server on port ${PORT}...`);
|
|
44
|
-
|
|
45
|
-
// Start Next.js dev server
|
|
46
|
-
const devServer = spawn('next', nextArgs, {
|
|
47
|
-
stdio: 'inherit',
|
|
48
|
-
shell: true,
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
// Wait for server to be ready, then open browser
|
|
52
|
-
let serverReady = false;
|
|
53
|
-
let attempts = 0;
|
|
54
|
-
const maxAttempts = 60; // 30 seconds max
|
|
55
|
-
|
|
56
|
-
const checkInterval = setInterval(async () => {
|
|
57
|
-
if (serverReady || attempts >= maxAttempts) {
|
|
58
|
-
if (attempts >= maxAttempts) {
|
|
59
|
-
consola.warn('Server took too long to start, skipping browser open');
|
|
60
|
-
}
|
|
61
|
-
clearInterval(checkInterval);
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
attempts++;
|
|
66
|
-
|
|
67
|
-
try {
|
|
68
|
-
const response = await fetch(URL);
|
|
69
|
-
if (response.ok) {
|
|
70
|
-
serverReady = true;
|
|
71
|
-
clearInterval(checkInterval);
|
|
72
|
-
|
|
73
|
-
consola.success(`Server ready! Opening browser at ${URL}`);
|
|
74
|
-
|
|
75
|
-
// Open browser (cross-platform)
|
|
76
|
-
const command = process.platform === 'darwin'
|
|
77
|
-
? 'open'
|
|
78
|
-
: process.platform === 'win32'
|
|
79
|
-
? 'start'
|
|
80
|
-
: 'xdg-open';
|
|
81
|
-
|
|
82
|
-
exec(`${command} ${URL}`, (error) => {
|
|
83
|
-
if (error) {
|
|
84
|
-
consola.warn(`Failed to open browser: ${error.message}`);
|
|
85
|
-
consola.info(`Please open manually: ${URL}`);
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
} catch (err) {
|
|
90
|
-
// Server not ready yet, continue checking
|
|
91
|
-
}
|
|
92
|
-
}, 500);
|
|
93
|
-
|
|
94
|
-
// Cleanup on exit
|
|
95
|
-
process.on('SIGINT', () => {
|
|
96
|
-
clearInterval(checkInterval);
|
|
97
|
-
devServer.kill();
|
|
98
|
-
process.exit();
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
process.on('SIGTERM', () => {
|
|
102
|
-
clearInterval(checkInterval);
|
|
103
|
-
devServer.kill();
|
|
104
|
-
process.exit();
|
|
105
|
-
});
|