@nitronjs/framework 0.1.24 → 0.2.1
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 +331 -253
- package/lib/Build/CssBuilder.js +129 -0
- package/lib/Build/FileAnalyzer.js +395 -0
- package/lib/Build/HydrationBuilder.js +173 -0
- package/lib/Build/Manager.js +290 -943
- package/lib/Build/colors.js +10 -0
- package/lib/Build/jsxRuntime.js +116 -0
- package/lib/Build/plugins.js +264 -0
- package/lib/Console/Commands/BuildCommand.js +6 -5
- package/lib/Console/Commands/DevCommand.js +151 -311
- package/lib/Console/Stubs/page-hydration-dev.tsx +72 -0
- package/lib/Console/Stubs/page-hydration.tsx +9 -10
- package/lib/Console/Stubs/vendor-dev.tsx +50 -0
- package/lib/Core/Environment.js +29 -2
- package/lib/Core/Paths.js +12 -4
- package/lib/Database/Drivers/MySQLDriver.js +5 -4
- package/lib/Database/Migration/MigrationRepository.js +2 -6
- package/lib/Database/Model.js +7 -8
- package/lib/Database/QueryBuilder.js +2 -3
- package/lib/Database/Seeder/SeederRepository.js +2 -6
- package/lib/Filesystem/Manager.js +32 -7
- package/lib/HMR/Server.js +87 -0
- package/lib/Http/Server.js +9 -5
- package/lib/Logging/Manager.js +68 -18
- package/lib/Route/Loader.js +3 -4
- package/lib/Route/Manager.js +24 -3
- package/lib/Runtime/Entry.js +26 -1
- package/lib/Session/File.js +18 -7
- package/lib/View/Client/hmr-client.js +166 -0
- package/lib/View/Client/spa.js +142 -0
- package/lib/View/Layout.js +94 -0
- package/lib/View/Manager.js +390 -46
- package/lib/index.d.ts +55 -0
- package/package.json +2 -1
- package/skeleton/.env.example +0 -2
- package/skeleton/app/Controllers/HomeController.js +4 -4
- package/skeleton/config/app.js +15 -14
- package/skeleton/config/session.js +1 -1
- package/skeleton/globals.d.ts +3 -63
- package/skeleton/resources/views/Site/Home.tsx +62 -42
- package/skeleton/tsconfig.json +5 -1
package/skeleton/config/app.js
CHANGED
|
@@ -5,20 +5,21 @@ export default {
|
|
|
5
5
|
/**
|
|
6
6
|
* Content Security Policy (CSP) Whitelist
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* Format 1 - Simple URL array (applies to all resource types):
|
|
9
|
+
* csp: ["https://fonts.googleapis.com", "https://fonts.gstatic.com"]
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* Format 2 - Wildcard (allows all external resources - not recommended for production):
|
|
12
|
+
* csp: ["*"]
|
|
13
|
+
*
|
|
14
|
+
* Format 3 - Detailed per-type configuration:
|
|
15
|
+
* csp: {
|
|
16
|
+
* styles: ["https://fonts.googleapis.com"],
|
|
17
|
+
* fonts: ["https://fonts.gstatic.com"],
|
|
18
|
+
* scripts: ["https://cdnjs.cloudflare.com"],
|
|
19
|
+
* images: [],
|
|
20
|
+
* connect: [],
|
|
21
|
+
* frames: [],
|
|
22
|
+
* }
|
|
15
23
|
*/
|
|
16
|
-
csp:
|
|
17
|
-
styles: [],
|
|
18
|
-
fonts: [],
|
|
19
|
-
images: [],
|
|
20
|
-
scripts: [],
|
|
21
|
-
connect: [],
|
|
22
|
-
frames: [],
|
|
23
|
-
},
|
|
24
|
+
csp: [],
|
|
24
25
|
}
|
package/skeleton/globals.d.ts
CHANGED
|
@@ -1,68 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* NitronJS Global Types
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* This file imports global type declarations from the framework.
|
|
5
|
+
* All global functions (csrf, route, request) are available without import.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
* Returns the CSRF token for the current request.
|
|
10
|
-
* Works on both SSR and client-side.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* // In a form
|
|
14
|
-
* <input type="hidden" name="_csrf" value={csrf()} />
|
|
15
|
-
*
|
|
16
|
-
* // In a fetch request
|
|
17
|
-
* fetch('/api/action', {
|
|
18
|
-
* method: 'POST',
|
|
19
|
-
* headers: { 'X-CSRF-Token': csrf() }
|
|
20
|
-
* })
|
|
21
|
-
*/
|
|
22
|
-
declare function csrf(): string;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Returns the URL for a named route.
|
|
26
|
-
* Works on both SSR and client-side.
|
|
27
|
-
*
|
|
28
|
-
* @param name - The route name as defined in routes/web.js
|
|
29
|
-
* @param params - Optional route parameters
|
|
30
|
-
* @example
|
|
31
|
-
* <a href={route('home')}>Home</a>
|
|
32
|
-
* <a href={route('admin.dashboard')}>Dashboard</a>
|
|
33
|
-
* <a href={route('admin.users.edit', { id: 1 })}>Edit User</a>
|
|
34
|
-
*/
|
|
35
|
-
declare function route(name: string, params?: Record<string, any>): string;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Returns the current request object.
|
|
39
|
-
* Only works in Server Components during SSR.
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* // Get query parameters
|
|
43
|
-
* const tab = request().query.tab || 'general';
|
|
44
|
-
*
|
|
45
|
-
* // Get URL parameters
|
|
46
|
-
* const id = request().params.id;
|
|
47
|
-
*
|
|
48
|
-
* // Get request method
|
|
49
|
-
* const method = request().method;
|
|
50
|
-
*/
|
|
51
|
-
declare function request(): {
|
|
52
|
-
path: string;
|
|
53
|
-
method: string;
|
|
54
|
-
query: Record<string, any>;
|
|
55
|
-
params: Record<string, any>;
|
|
56
|
-
body: Record<string, any>;
|
|
57
|
-
headers: Record<string, string>;
|
|
58
|
-
cookies: Record<string, string>;
|
|
59
|
-
ip: string;
|
|
60
|
-
isAjax: boolean;
|
|
61
|
-
session: {
|
|
62
|
-
get<T = any>(key: string, defaultValue?: T): T;
|
|
63
|
-
set(key: string, value: any): void;
|
|
64
|
-
has(key: string): boolean;
|
|
65
|
-
forget(key: string): void;
|
|
66
|
-
flash(key: string, value: any): void;
|
|
67
|
-
};
|
|
68
|
-
};
|
|
8
|
+
/// <reference types="@nitronjs/framework" />
|
|
@@ -1,65 +1,85 @@
|
|
|
1
1
|
type HomeProps = {
|
|
2
|
-
|
|
2
|
+
version?: string;
|
|
3
3
|
};
|
|
4
4
|
|
|
5
|
-
export default function Home({
|
|
5
|
+
export default function Home({ version = "0.2.0" }: HomeProps) {
|
|
6
6
|
return (
|
|
7
7
|
<main style={{
|
|
8
8
|
minHeight: "100vh",
|
|
9
|
+
background: "#0a0a0a",
|
|
10
|
+
fontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",
|
|
11
|
+
color: "#e4e4e7",
|
|
9
12
|
display: "flex",
|
|
10
13
|
flexDirection: "column",
|
|
11
14
|
alignItems: "center",
|
|
12
15
|
justifyContent: "center",
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
background: "radial-gradient(circle at top, #111827, #0b0f19)",
|
|
16
|
-
fontFamily: "system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, sans-serif",
|
|
17
|
-
padding: "4rem 1.5rem"
|
|
16
|
+
padding: "2rem",
|
|
17
|
+
boxSizing: "border-box"
|
|
18
18
|
}}>
|
|
19
|
+
<div style={{
|
|
20
|
+
width: 64,
|
|
21
|
+
height: 64,
|
|
22
|
+
background: "#fff",
|
|
23
|
+
borderRadius: 14,
|
|
24
|
+
display: "flex",
|
|
25
|
+
alignItems: "center",
|
|
26
|
+
justifyContent: "center",
|
|
27
|
+
marginBottom: "2rem"
|
|
28
|
+
}}>
|
|
29
|
+
<svg width="36" height="36" viewBox="0 0 24 24" fill="none" stroke="#0a0a0a" strokeWidth="2.5">
|
|
30
|
+
<path d="M13 2L3 14h9l-1 8 10-12h-9l1-8z"/>
|
|
31
|
+
</svg>
|
|
32
|
+
</div>
|
|
33
|
+
|
|
19
34
|
<h1 style={{
|
|
20
|
-
fontSize: "
|
|
21
|
-
|
|
35
|
+
fontSize: "2.5rem",
|
|
36
|
+
fontWeight: 700,
|
|
22
37
|
margin: 0,
|
|
23
|
-
|
|
38
|
+
color: "#fff",
|
|
39
|
+
letterSpacing: "-0.02em"
|
|
24
40
|
}}>
|
|
25
|
-
Welcome to
|
|
41
|
+
Welcome to NitronJS
|
|
26
42
|
</h1>
|
|
43
|
+
|
|
27
44
|
<p style={{
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
margin: 0,
|
|
32
|
-
|
|
45
|
+
fontSize: "1.1rem",
|
|
46
|
+
color: "#71717a",
|
|
47
|
+
maxWidth: 400,
|
|
48
|
+
margin: "1.5rem 0 2rem",
|
|
49
|
+
lineHeight: 1.6,
|
|
50
|
+
textAlign: "center"
|
|
33
51
|
}}>
|
|
34
|
-
Your
|
|
52
|
+
Your application is ready. Start building by editing the files in <code style={{ color: "#a1a1aa", background: "#1a1a1a", padding: "2px 6px", borderRadius: 4 }}>resources/views</code>
|
|
35
53
|
</p>
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
padding: "0.75rem 1.5rem",
|
|
44
|
-
borderRadius: "10px",
|
|
45
|
-
background: "#3b82f6",
|
|
46
|
-
color: "#fff",
|
|
47
|
-
textDecoration: "none",
|
|
48
|
-
fontWeight: 600
|
|
49
|
-
}}>
|
|
50
|
-
Documentation
|
|
51
|
-
</a>
|
|
52
|
-
<a href="https://nitronjs.dev" style={{
|
|
54
|
+
|
|
55
|
+
<a
|
|
56
|
+
href="https://nitronjs.dev/docs"
|
|
57
|
+
style={{
|
|
58
|
+
display: "inline-flex",
|
|
59
|
+
alignItems: "center",
|
|
60
|
+
gap: "0.5rem",
|
|
53
61
|
padding: "0.75rem 1.5rem",
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
color: "#e2e8f0",
|
|
62
|
+
background: "#fff",
|
|
63
|
+
color: "#0a0a0a",
|
|
57
64
|
textDecoration: "none",
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
65
|
+
fontWeight: 600,
|
|
66
|
+
fontSize: "0.9rem",
|
|
67
|
+
borderRadius: 8
|
|
68
|
+
}}
|
|
69
|
+
>
|
|
70
|
+
Documentation
|
|
71
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2.5">
|
|
72
|
+
<path d="M5 12h14M12 5l7 7-7 7"/>
|
|
73
|
+
</svg>
|
|
74
|
+
</a>
|
|
75
|
+
|
|
76
|
+
<div style={{
|
|
77
|
+
position: "fixed",
|
|
78
|
+
bottom: "1.5rem",
|
|
79
|
+
color: "#3f3f46",
|
|
80
|
+
fontSize: "0.8rem"
|
|
81
|
+
}}>
|
|
82
|
+
v{version}
|
|
63
83
|
</div>
|
|
64
84
|
</main>
|
|
65
85
|
);
|
package/skeleton/tsconfig.json
CHANGED