hightjs 0.3.3 → 0.3.5
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/dist/adapters/factory.js +8 -8
- package/dist/adapters/native.js +3 -3
- package/dist/api/console.js +1 -1
- package/dist/auth/client.js +5 -5
- package/dist/auth/components.js +2 -2
- package/dist/auth/core.js +2 -2
- package/dist/auth/react.js +4 -4
- package/dist/auth/routes.js +1 -1
- package/dist/bin/hightjs.js +32 -331
- package/dist/builder.js +7 -19
- package/dist/client/DefaultNotFound.js +1 -1
- package/dist/client/entry.client.js +98 -8
- package/dist/helpers.d.ts +1 -0
- package/dist/helpers.js +130 -29
- package/dist/hotReload.js +25 -16
- package/dist/index.d.ts +1 -1
- package/dist/index.js +26 -36
- package/dist/renderer.js +137 -18
- package/dist/router.js +133 -62
- package/dist/types.d.ts +81 -0
- package/docs/config.md +216 -0
- package/example/hightjs.config.ts +87 -0
- package/example/package-lock.json +633 -3054
- package/example/package.json +3 -3
- package/example/src/web/layout.tsx +57 -3
- package/example/src/web/routes/index.tsx +1 -1
- package/package.json +1 -1
- package/src/adapters/factory.ts +8 -8
- package/src/adapters/native.ts +3 -3
- package/src/api/console.ts +3 -1
- package/src/auth/client.ts +5 -5
- package/src/auth/components.tsx +2 -2
- package/src/auth/core.ts +2 -2
- package/src/auth/react.tsx +4 -4
- package/src/auth/routes.ts +1 -1
- package/src/bin/hightjs.js +33 -394
- package/src/builder.js +7 -20
- package/src/client/DefaultNotFound.tsx +1 -1
- package/src/client/entry.client.tsx +125 -10
- package/src/helpers.ts +144 -30
- package/src/hotReload.ts +25 -16
- package/src/index.ts +33 -39
- package/src/renderer.tsx +142 -18
- package/src/router.ts +142 -63
- package/src/types.ts +108 -0
- package/example/.hweb/entry.client.js +0 -24
- package/example/hweb-dist/main-5KKAYNUU.js +0 -1137
package/example/package.json
CHANGED
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"start": "hight start --
|
|
8
|
-
"dev": "hight dev --
|
|
7
|
+
"start": "hight start --port 80",
|
|
8
|
+
"dev": "hight dev --port 80"
|
|
9
9
|
},
|
|
10
10
|
"author": "itsmuzin",
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@tailwindcss/postcss": "^4.1.16",
|
|
14
14
|
"autoprefixer": "^10.4.21",
|
|
15
|
-
"hightjs": "
|
|
15
|
+
"hightjs": "../",
|
|
16
16
|
"postcss": "^8.5.6",
|
|
17
17
|
"react": "^19.2.0",
|
|
18
18
|
"react-dom": "^19.2.0",
|
|
@@ -8,11 +8,65 @@ interface LayoutProps {
|
|
|
8
8
|
children: React.ReactNode;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
export const metadata: Metadata = {
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
// --- Informações Básicas ---
|
|
14
|
+
// Título otimizado para abas do navegador e resultados de busca
|
|
15
|
+
title: "Hight JS | O Framework Web Rápido e Simples para React",
|
|
16
|
+
description: "O framework web mais rápido e simples para React! Comece a construir aplicações web performáticas hoje mesmo com Hight JS.",
|
|
17
|
+
keywords: ["Hight JS", "framework web", "React", "JavaScript", "TypeScript", "desenvolvimento web", "rápido", "simples", "SSR", "frontend"],
|
|
18
|
+
author: "Hight JS Team",
|
|
15
19
|
favicon: "/favicon.ico",
|
|
20
|
+
|
|
21
|
+
// --- Mobile e Viewport ---
|
|
22
|
+
// Essencial para design responsivo e boa pontuação no mobile
|
|
23
|
+
viewport: "width=device-width, initial-scale=1.0",
|
|
24
|
+
// Cor da barra de navegação em browsers mobile (ex: Chrome no Android)
|
|
25
|
+
themeColor: "#0A0A0A", // Sugestão de cor escura, ajuste conforme sua marca
|
|
26
|
+
|
|
27
|
+
// --- SEO ---
|
|
28
|
+
// URL principal do site para evitar conteúdo duplicado
|
|
29
|
+
canonical: "https://hightjs.com", // Substitua pelo seu domínio real
|
|
30
|
+
// Instruções para robôs de busca (Google, Bing, etc.)
|
|
31
|
+
robots: "index, follow",
|
|
32
|
+
|
|
33
|
+
// --- Open Graph (para Redes Sociais como Facebook, LinkedIn, Discord) ---
|
|
34
|
+
openGraph: {
|
|
35
|
+
title: "Hight JS | O Framework Web Rápido e Simples para React",
|
|
36
|
+
description: "Descubra o Hight JS, o framework web focado em performance e simplicidade para suas aplicações React.",
|
|
37
|
+
type: "website",
|
|
38
|
+
url: "https://hightjs.com", // Seu domínio real
|
|
39
|
+
// URL de uma imagem de preview (idealmente 1200x630px)
|
|
40
|
+
image: "https://hightjs.com/og-image.png",
|
|
41
|
+
siteName: "Hight JS",
|
|
42
|
+
locale: "pt_BR",
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
// --- Twitter Card (para compartilhamento no Twitter) ---
|
|
46
|
+
twitter: {
|
|
47
|
+
card: "summary_large_image", // Mostra uma imagem grande no tweet
|
|
48
|
+
site: "@hightjs_team", // Handle do Twitter do projeto (exemplo)
|
|
49
|
+
creator: "@seu_criador", // Handle do Twitter do criador (exemplo)
|
|
50
|
+
title: "Hight JS | O Framework Web Rápido e Simples para React",
|
|
51
|
+
description: "Cansado de complexidade? Conheça o Hight JS e construa sites React mais rápidos e leves.",
|
|
52
|
+
// Imagem específica para Twitter (ou pode reusar a 'og-image')
|
|
53
|
+
image: "https://hightjs.com/twitter-image.png",
|
|
54
|
+
imageAlt: "Logo e slogan do framework Hight JS",
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
// --- Ícones e Manifest (PWA) ---
|
|
58
|
+
// Ícone para dispositivos Apple (quando salvo na tela inicial)
|
|
59
|
+
appleTouchIcon: "/apple-touch-icon.png", // (ex: 180x180px)
|
|
60
|
+
// Link para o manifest de PWA (Progressive Web App)
|
|
61
|
+
manifest: "/site.webmanifest",
|
|
62
|
+
|
|
63
|
+
// --- Outros ---
|
|
64
|
+
language: "pt-BR", // Define o idioma principal da página
|
|
65
|
+
charset: "UTF-8", // Define o charset (embora geralmente setado no HTML)
|
|
66
|
+
other: {
|
|
67
|
+
// Tag útil para compatibilidade com navegadores legados (Edge/IE)
|
|
68
|
+
"X-UA-Compatible": "IE=edge"
|
|
69
|
+
}
|
|
16
70
|
};
|
|
17
71
|
|
|
18
72
|
export default function Layout({ children }: LayoutProps) {
|
|
@@ -21,7 +21,7 @@ function Home() {
|
|
|
21
21
|
{status === 'loading' && <p>Carregando...</p>}
|
|
22
22
|
{status === 'authenticated' && session?.user && (
|
|
23
23
|
<>
|
|
24
|
-
<p className="text-lg">Você está logado como <span className="font-bold text-purple-400">{session.user.name}</span
|
|
24
|
+
<p className="text-lg">Você está logado como <span className="font-bold text-purple-400">{session.user.name}</span>!</p>
|
|
25
25
|
<button
|
|
26
26
|
onClick={() => signOut({callbackUrl: '/'})}
|
|
27
27
|
className="rounded-full border border-solid border-transparent transition-all duration-300 flex items-center justify-center bg-purple-600 text-white gap-2 hover:bg-purple-500 font-medium text-sm sm:text-base h-10 sm:h-12 px-4 sm:px-5 w-40 shadow-[0_0_15px_-3px_theme(colors.purple.600)] hover:shadow-[0_0_25px_-3px_theme(colors.purple.500)]"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hightjs",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"description": "HightJS is a high-level framework for building web applications with ease and speed. It provides a robust set of tools and features to streamline development and enhance productivity.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
package/src/adapters/factory.ts
CHANGED
|
@@ -33,18 +33,18 @@ export class FrameworkAdapterFactory {
|
|
|
33
33
|
if (this.adapter) {
|
|
34
34
|
return this.adapter;
|
|
35
35
|
}
|
|
36
|
-
const msg = Console.dynamicLine(` ${Colors.FgYellow}● ${Colors.Reset}
|
|
36
|
+
const msg = Console.dynamicLine(` ${Colors.FgYellow}● ${Colors.Reset}Detecting web framework...`);
|
|
37
37
|
|
|
38
38
|
// Detecta Express
|
|
39
39
|
if (req.app && req.route && res.locals !== undefined) {
|
|
40
|
-
msg.end(` ${Colors.FgGreen}● ${Colors.Reset}Framework
|
|
40
|
+
msg.end(` ${Colors.FgGreen}● ${Colors.Reset}Framework detected: Express`);
|
|
41
41
|
this.adapter = new ExpressAdapter();
|
|
42
42
|
return this.adapter;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
// Detecta Fastify
|
|
46
46
|
if (req.server && req.routerPath !== undefined && res.request) {
|
|
47
|
-
msg.end(` ${Colors.FgGreen}● ${Colors.Reset}Framework
|
|
47
|
+
msg.end(` ${Colors.FgGreen}● ${Colors.Reset}Framework detected: Fastify`);
|
|
48
48
|
this.adapter = new FastifyAdapter();
|
|
49
49
|
return this.adapter;
|
|
50
50
|
}
|
|
@@ -52,27 +52,27 @@ export class FrameworkAdapterFactory {
|
|
|
52
52
|
// Detecta HTTP nativo do Node.js
|
|
53
53
|
if (req.method !== undefined && req.url !== undefined && req.headers !== undefined &&
|
|
54
54
|
res.statusCode !== undefined && res.setHeader !== undefined && res.end !== undefined) {
|
|
55
|
-
msg.end(` ${Colors.FgGreen}● ${Colors.Reset}Framework
|
|
55
|
+
msg.end(` ${Colors.FgGreen}● ${Colors.Reset}Framework detected: HightJS Native (HTTP)`);
|
|
56
56
|
this.adapter = new NativeAdapter();
|
|
57
57
|
return this.adapter;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
// Fallback mais específico para Express
|
|
61
61
|
if (res.status && res.send && res.json && res.cookie) {
|
|
62
|
-
msg.end(` ${Colors.FgGreen}● ${Colors.Reset}Framework
|
|
62
|
+
msg.end(` ${Colors.FgGreen}● ${Colors.Reset}Framework detected: Express (fallback)`);
|
|
63
63
|
this.adapter = new ExpressAdapter();
|
|
64
64
|
return this.adapter;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
// Fallback mais específico para Fastify
|
|
68
68
|
if (res.code && res.send && res.type && res.setCookie) {
|
|
69
|
-
msg.end(` ${Colors.FgGreen}● ${Colors.Reset}Framework
|
|
69
|
+
msg.end(` ${Colors.FgGreen}● ${Colors.Reset}Framework detected: Fastify (fallback)`);
|
|
70
70
|
this.adapter = new FastifyAdapter();
|
|
71
71
|
return this.adapter;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
// Default para HightJS Native se não conseguir detectar
|
|
75
|
-
msg.end(` ${Colors.FgYellow}● ${Colors.Reset}
|
|
75
|
+
msg.end(` ${Colors.FgYellow}● ${Colors.Reset}Unable to detect framework. Using HightJS Native as default.`);
|
|
76
76
|
this.adapter = new NativeAdapter();
|
|
77
77
|
return this.adapter;
|
|
78
78
|
}
|
|
@@ -92,7 +92,7 @@ export class FrameworkAdapterFactory {
|
|
|
92
92
|
this.adapter = new NativeAdapter();
|
|
93
93
|
break;
|
|
94
94
|
default:
|
|
95
|
-
throw new Error(`
|
|
95
|
+
throw new Error(`Unsupported framework: ${framework}`);
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
|
package/src/adapters/native.ts
CHANGED
|
@@ -81,7 +81,7 @@ export class NativeAdapter implements FrameworkAdapter {
|
|
|
81
81
|
cookies[name] = decodeURIComponent(rest.join('='));
|
|
82
82
|
} catch (e) {
|
|
83
83
|
// Prevenção de crash: Ignora cookies com valores malformados (e.g., URI inválida).
|
|
84
|
-
console.error(`
|
|
84
|
+
console.error(`Warning: Malformed cookie with name "${name}" was ignored.`);
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
});
|
|
@@ -114,7 +114,7 @@ class NativeResponseWrapper implements GenericResponse {
|
|
|
114
114
|
const sanitizedValue = sanitizeHeaderValue(value);
|
|
115
115
|
|
|
116
116
|
if (name !== sanitizedName || String(value) !== sanitizedValue) {
|
|
117
|
-
console.warn(`
|
|
117
|
+
console.warn(`Warning: Potential HTTP Header Injection attempt detected and sanitized. Original header: "${name}"`);
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
|
|
@@ -125,7 +125,7 @@ class NativeResponseWrapper implements GenericResponse {
|
|
|
125
125
|
cookie(name: string, value: string, options?: CookieOptions): GenericResponse {
|
|
126
126
|
// Medida de segurança: Valida o nome do cookie.
|
|
127
127
|
if (!isValidCookieName(name)) {
|
|
128
|
-
console.error(`
|
|
128
|
+
console.error(`Error: Invalid cookie name "${name}". The cookie will not be set.`);
|
|
129
129
|
return this;
|
|
130
130
|
}
|
|
131
131
|
|
package/src/api/console.ts
CHANGED
|
@@ -202,7 +202,9 @@ export default class Console {
|
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
static logWithout(level: Levels, colors?:Colors, ...args: any[]): void {
|
|
205
|
-
|
|
205
|
+
|
|
206
|
+
const color = colors ? colors : level === Levels.ERROR ? Colors.BgRed : level === Levels.WARN ? Colors.BgYellow : level === Levels.INFO ? Colors.BgMagenta : level === Levels.SUCCESS ? Colors.BgGreen : Colors.BgCyan;
|
|
207
|
+
|
|
206
208
|
let output = "";
|
|
207
209
|
for (const arg of args) {
|
|
208
210
|
let msg = (arg instanceof Error) ? arg.stack : (typeof arg === 'string') ? arg : JSON.stringify(arg, null, 2);
|
package/src/auth/client.ts
CHANGED
|
@@ -38,7 +38,7 @@ export async function getSession(): Promise<Session | null> {
|
|
|
38
38
|
const data = await response.json();
|
|
39
39
|
return data.session || null;
|
|
40
40
|
} catch (error) {
|
|
41
|
-
console.error('[hweb-auth]
|
|
41
|
+
console.error('[hweb-auth] Error fetching session:', error);
|
|
42
42
|
return null;
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -59,7 +59,7 @@ export async function getCsrfToken(): Promise<string | null> {
|
|
|
59
59
|
const data = await response.json();
|
|
60
60
|
return data.csrfToken || null;
|
|
61
61
|
} catch (error) {
|
|
62
|
-
console.error('[hweb-auth]
|
|
62
|
+
console.error('[hweb-auth] Error fetching CSRF token:', error);
|
|
63
63
|
return null;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -80,7 +80,7 @@ export async function getProviders(): Promise<any[] | null> {
|
|
|
80
80
|
const data = await response.json();
|
|
81
81
|
return data.providers || [];
|
|
82
82
|
} catch (error) {
|
|
83
|
-
console.error('[hweb-auth]
|
|
83
|
+
console.error('[hweb-auth] Error searching for providers:', error);
|
|
84
84
|
return null;
|
|
85
85
|
}
|
|
86
86
|
}
|
|
@@ -143,7 +143,7 @@ export async function signIn(
|
|
|
143
143
|
};
|
|
144
144
|
}
|
|
145
145
|
} catch (error) {
|
|
146
|
-
console.error('[hweb-auth]
|
|
146
|
+
console.error('[hweb-auth] Error on signIn:', error);
|
|
147
147
|
return {
|
|
148
148
|
error: 'Network error',
|
|
149
149
|
status: 500,
|
|
@@ -166,6 +166,6 @@ export async function signOut(options: { callbackUrl?: string } = {}): Promise<v
|
|
|
166
166
|
window.location.href = options.callbackUrl || '/';
|
|
167
167
|
}
|
|
168
168
|
} catch (error) {
|
|
169
|
-
console.error('[hweb-auth]
|
|
169
|
+
console.error('[hweb-auth] Error on signOut:', error);
|
|
170
170
|
}
|
|
171
171
|
}
|
package/src/auth/components.tsx
CHANGED
|
@@ -37,7 +37,7 @@ export function ProtectedRoute({
|
|
|
37
37
|
|
|
38
38
|
// Ainda carregando
|
|
39
39
|
if (isLoading) {
|
|
40
|
-
return fallback || <div>
|
|
40
|
+
return fallback || <div>Loading...</div>;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
// Requer auth mas não está autenticado
|
|
@@ -46,7 +46,7 @@ export function ProtectedRoute({
|
|
|
46
46
|
window.location.href = redirectTo;
|
|
47
47
|
return null;
|
|
48
48
|
}
|
|
49
|
-
return fallback || <div>
|
|
49
|
+
return fallback || <div>Unauthorized</div>;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
// Não requer auth mas está autenticado (ex: página de login)
|
package/src/auth/core.ts
CHANGED
|
@@ -91,7 +91,7 @@ export class HWebAuth {
|
|
|
91
91
|
|
|
92
92
|
return sessionResult;
|
|
93
93
|
} catch (error) {
|
|
94
|
-
console.error(`[hweb-auth]
|
|
94
|
+
console.error(`[hweb-auth] Error signing in with provider ${providerId}:`, error);
|
|
95
95
|
return null;
|
|
96
96
|
}
|
|
97
97
|
}
|
|
@@ -109,7 +109,7 @@ export class HWebAuth {
|
|
|
109
109
|
try {
|
|
110
110
|
await provider.handleSignOut();
|
|
111
111
|
} catch (error) {
|
|
112
|
-
console.error(`[hweb-auth]
|
|
112
|
+
console.error(`[hweb-auth] Signout error on provider ${provider.id}:`, error);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
}
|
package/src/auth/react.tsx
CHANGED
|
@@ -61,7 +61,7 @@ export function SessionProvider({
|
|
|
61
61
|
return null;
|
|
62
62
|
}
|
|
63
63
|
} catch (error) {
|
|
64
|
-
console.error('[hweb-auth]
|
|
64
|
+
console.error('[hweb-auth] Error fetching session:', error);
|
|
65
65
|
setSession(null);
|
|
66
66
|
setStatus('unauthenticated');
|
|
67
67
|
return null;
|
|
@@ -125,7 +125,7 @@ export function SessionProvider({
|
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
127
|
} catch (error) {
|
|
128
|
-
console.error('[hweb-auth]
|
|
128
|
+
console.error('[hweb-auth] Error on signIn:', error);
|
|
129
129
|
return {
|
|
130
130
|
error: 'Network error',
|
|
131
131
|
status: 500,
|
|
@@ -153,7 +153,7 @@ export function SessionProvider({
|
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
155
|
} catch (error) {
|
|
156
|
-
console.error('[hweb-auth]
|
|
156
|
+
console.error('[hweb-auth] Error on signOut:', error);
|
|
157
157
|
}
|
|
158
158
|
}, [basePath]);
|
|
159
159
|
|
|
@@ -215,7 +215,7 @@ export function SessionProvider({
|
|
|
215
215
|
export function useSession(): SessionContextType {
|
|
216
216
|
const context = useContext(SessionContext);
|
|
217
217
|
if (context === undefined) {
|
|
218
|
-
throw new Error('useSession
|
|
218
|
+
throw new Error('useSession must be used inside a SessionProvider');
|
|
219
219
|
}
|
|
220
220
|
return context;
|
|
221
221
|
}
|
package/src/auth/routes.ts
CHANGED
|
@@ -167,7 +167,7 @@ async function handleSignIn(req: HightJSRequest, auth: HWebAuth) {
|
|
|
167
167
|
type: 'session'
|
|
168
168
|
});
|
|
169
169
|
} catch (error) {
|
|
170
|
-
console.error('[hweb-auth]
|
|
170
|
+
console.error('[hweb-auth] Error on handleSignIn:', error);
|
|
171
171
|
return HightJSResponse.json(
|
|
172
172
|
{ error: 'Authentication failed' },
|
|
173
173
|
{ status: 500 }
|