hightjs 0.4.0 → 0.5.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 +42 -126
- package/dist/bin/hightjs.js +51 -23
- package/dist/builder.js +139 -4
- package/dist/client/DefaultNotFound.d.ts +1 -1
- package/dist/client/DefaultNotFound.js +72 -46
- package/dist/client/client.d.ts +3 -0
- package/dist/{client.js → client/client.js} +4 -4
- package/dist/client/entry.client.js +39 -29
- package/dist/global/global.d.ts +117 -0
- package/dist/{auth/types.js → global/global.js} +0 -1
- package/dist/helpers.js +80 -2
- package/dist/hotReload.js +2 -2
- package/dist/index.js +16 -16
- package/dist/loaders.d.ts +1 -0
- package/dist/loaders.js +46 -0
- package/dist/renderer.js +158 -4
- package/dist/types.d.ts +44 -0
- package/package.json +37 -31
- package/src/bin/hightjs.js +59 -29
- package/src/builder.js +163 -4
- package/src/client/DefaultNotFound.tsx +88 -53
- package/src/{client.ts → client/client.ts} +4 -3
- package/src/client/entry.client.tsx +44 -29
- package/src/global/global.ts +171 -0
- package/src/helpers.ts +91 -2
- package/src/hotReload.ts +2 -2
- package/src/index.ts +2 -0
- package/src/loaders.js +53 -0
- package/src/renderer.tsx +162 -4
- package/src/types.ts +51 -0
- package/.idea/HightJS.iml +0 -9
- package/.idea/copilot.data.migration.agent.xml +0 -6
- package/.idea/copilot.data.migration.ask.xml +0 -6
- package/.idea/copilot.data.migration.ask2agent.xml +0 -6
- package/.idea/copilot.data.migration.edit.xml +0 -6
- package/.idea/copilotDiffState.xml +0 -67
- package/.idea/inspectionProfiles/Project_Default.xml +0 -13
- package/.idea/libraries/test_package.xml +0 -9
- package/.idea/libraries/ts_commonjs_default_export.xml +0 -9
- package/.idea/misc.xml +0 -7
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
- package/dist/auth/client.d.ts +0 -24
- package/dist/auth/client.js +0 -146
- package/dist/auth/components.d.ts +0 -29
- package/dist/auth/components.js +0 -100
- package/dist/auth/core.d.ts +0 -55
- package/dist/auth/core.js +0 -189
- package/dist/auth/index.d.ts +0 -7
- package/dist/auth/index.js +0 -45
- package/dist/auth/jwt.d.ts +0 -41
- package/dist/auth/jwt.js +0 -185
- package/dist/auth/providers/credentials.d.ts +0 -60
- package/dist/auth/providers/credentials.js +0 -97
- package/dist/auth/providers/discord.d.ts +0 -63
- package/dist/auth/providers/discord.js +0 -190
- package/dist/auth/providers/google.d.ts +0 -63
- package/dist/auth/providers/google.js +0 -186
- package/dist/auth/providers/index.d.ts +0 -2
- package/dist/auth/providers/index.js +0 -35
- package/dist/auth/providers.d.ts +0 -3
- package/dist/auth/providers.js +0 -26
- package/dist/auth/react/index.d.ts +0 -6
- package/dist/auth/react/index.js +0 -48
- package/dist/auth/react.d.ts +0 -22
- package/dist/auth/react.js +0 -199
- package/dist/auth/routes.d.ts +0 -16
- package/dist/auth/routes.js +0 -152
- package/dist/auth/types.d.ts +0 -76
- package/dist/client.d.ts +0 -3
- package/docs/README.md +0 -58
- package/docs/arquivos-especiais.md +0 -10
- package/docs/autenticacao.md +0 -212
- package/docs/checklist.md +0 -9
- package/docs/cli.md +0 -72
- package/docs/config.md +0 -216
- package/docs/estrutura.md +0 -20
- package/docs/faq.md +0 -10
- package/docs/hot-reload.md +0 -5
- package/docs/integracoes.md +0 -240
- package/docs/middlewares.md +0 -73
- package/docs/rotas-backend.md +0 -45
- package/docs/rotas-frontend.md +0 -66
- package/docs/seguranca.md +0 -8
- package/docs/websocket.md +0 -45
- package/example/certs/cert.pem +0 -20
- package/example/certs/key.pem +0 -27
- package/example/hightjs.config.ts +0 -87
- package/example/package-lock.json +0 -1174
- package/example/package.json +0 -26
- package/example/postcss.config.js +0 -8
- package/example/src/backend/auth.ts +0 -42
- package/example/src/backend/routes/auth.ts +0 -3
- package/example/src/backend/routes/version.ts +0 -13
- package/example/src/web/components/Home.tsx +0 -140
- package/example/src/web/components/LoginPage.tsx +0 -149
- package/example/src/web/globals.css +0 -5
- package/example/src/web/layout.tsx +0 -100
- package/example/src/web/routes/index.tsx +0 -13
- package/example/src/web/routes/login.tsx +0 -30
- package/example/tailwind.config.js +0 -12
- package/example/tsconfig.json +0 -15
- package/src/auth/client.ts +0 -171
- package/src/auth/components.tsx +0 -125
- package/src/auth/core.ts +0 -215
- package/src/auth/index.ts +0 -25
- package/src/auth/jwt.ts +0 -210
- package/src/auth/providers/credentials.ts +0 -139
- package/src/auth/providers/discord.ts +0 -239
- package/src/auth/providers/google.ts +0 -234
- package/src/auth/providers/index.ts +0 -20
- package/src/auth/providers.ts +0 -20
- package/src/auth/react/index.ts +0 -25
- package/src/auth/react.tsx +0 -234
- package/src/auth/routes.ts +0 -183
- package/src/auth/types.ts +0 -108
- package/tsconfig.json +0 -17
package/README.md
CHANGED
|
@@ -1,158 +1,74 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
<picture>
|
|
3
3
|
<source media="(prefers-color-scheme: dark)" srcset="https://repository-images.githubusercontent.com/1069175740/e5c59d3a-e1fd-446c-a89f-785ed08f6a16">
|
|
4
|
-
<img alt="
|
|
4
|
+
<img alt="HightJS logo" src="https://repository-images.githubusercontent.com/1069175740/e5c59d3a-e1fd-446c-a89f-785ed08f6a16" height="128">
|
|
5
5
|
</picture>
|
|
6
6
|
<h1>HightJS</h1>
|
|
7
7
|
|
|
8
8
|
[](https://www.npmjs.com/package/hightjs)
|
|
9
|
-
[](
|
|
10
|
-
|
|
9
|
+
[](../../LICENSE)
|
|
11
10
|
|
|
12
11
|
</div>
|
|
13
12
|
|
|
14
|
-
>
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
# Precisa de ajuda?
|
|
18
|
-
Caso tenha alguma dúvida, entre em contato por uma das redes abaixo:
|
|
19
|
-
|
|
20
|
-
[](https://discord.com/users/1264710048786026588)
|
|
21
|
-
[](mailto:murillofrazaocunha@gmail.com)
|
|
22
|
-
[](https://instagram.com/itsmuh_)
|
|
23
|
-
[](https://github.com/murillo-frazao-cunha)
|
|
13
|
+
> A modern full-stack web framework for Node.js, focused on simplicity, developer experience, and speed.
|
|
24
14
|
|
|
25
15
|
---
|
|
26
16
|
|
|
27
|
-
##
|
|
17
|
+
## ✨ Features
|
|
18
|
+
|
|
19
|
+
- **🚀 Blazing Fast** - Built on esbuild for lightning-fast builds and hot reload
|
|
20
|
+
- **📁 File-based Routing** - Automatic routing for pages (`src/web/routes`) and APIs (`src/backend/routes`)
|
|
21
|
+
- **⚛️ React 19** - Latest React with client-side hydration and streaming SSR
|
|
22
|
+
- **📘 TypeScript First** - Fully typed out of the box
|
|
23
|
+
- **🎨 Asset Imports** - Import images, markdown, SVG, JSON, fonts, audio, video directly
|
|
24
|
+
- **🔌 WebSockets** - Native WebSocket support in backend routes
|
|
25
|
+
- **🎯 Dynamic Routes** - Support for dynamic parameters in frontend and backend
|
|
26
|
+
- **🛡️ Middleware** - Per-folder and per-route middleware support
|
|
27
|
+
- **🔄 Hot Reload** - Native hot reload via internal WebSocket in dev mode
|
|
28
|
+
- **🎭 Layouts** - Global layouts and custom 404 pages
|
|
29
|
+
- **📝 Dynamic Metadata** - Per-page metadata generation
|
|
30
|
+
- **📦 Smart Bundling** - Single bundle or code splitting
|
|
31
|
+
- **🔒 Built-in SSL** - HTTPS out-of-the-box in Native mode
|
|
32
|
+
- **🔐 Authentication** - JWT authentication built-in (HWebAuth)
|
|
33
|
+
- **⚙️ CLI** - Own CLI (`hight`) for dev and production
|
|
34
|
+
- **📂 Static Files** - Serve static files from `public/`
|
|
35
|
+
- **🛡️ Security** - Built-in sanitization and rate limiting
|
|
28
36
|
|
|
29
|
-
- [✨ Principais Recursos](#-principais-recursos)
|
|
30
|
-
- [🚀 Início Rápido](#-início-rápido)
|
|
31
|
-
- [📚 Documentação](#-documentação)
|
|
32
|
-
- [🪪 Licença](#-licença)
|
|
33
37
|
---
|
|
34
38
|
|
|
35
|
-
##
|
|
36
|
-
|
|
37
|
-
- **Roteamento automático** de páginas [`src/web/routes`] e APIs [`src/backend/routes`]
|
|
38
|
-
- **React 19** com client-side hydration
|
|
39
|
-
- **TypeScript** first (totalmente tipado)
|
|
40
|
-
- **WebSockets** nativo nas rotas backend
|
|
41
|
-
- **Rotas dinâmicas** com parâmetros (frontend e backend)
|
|
42
|
-
- **Middlewares** por pasta ou rota
|
|
43
|
-
- **Hot Reload** nativo (WebSocket interno) em dev
|
|
44
|
-
- **Layouts globais** e página 404 customizada
|
|
45
|
-
- **Metadata** dinâmica por página
|
|
46
|
-
- **Build inteligente** (single bundle ou chunks)
|
|
47
|
-
- **SSL integrado** no modo Native (HTTPS out-of-the-box)
|
|
48
|
-
- **Autenticação** JWT embutida (HWebAuth)
|
|
49
|
-
- **CLI própria** (`hight`) para dev e produção
|
|
50
|
-
- **Entrega de estáticos** (`public/`)
|
|
51
|
-
- Segurança, saneamento e limitações nativas
|
|
39
|
+
## 📚 Documentation
|
|
52
40
|
|
|
53
|
-
|
|
41
|
+
For complete documentation, tutorials, and guides, visit:
|
|
54
42
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
> O mínimo para rodar!
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
npm init -y
|
|
61
|
-
npm install typescript --save-dev
|
|
62
|
-
npx tsc --init
|
|
63
|
-
npm install hightjs react@19 react-dom@19 ts-node
|
|
64
|
-
npm install --save-dev @types/react
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
Crie um `tsconfig.json` na raiz do projeto:
|
|
68
|
-
|
|
69
|
-
```json
|
|
70
|
-
{
|
|
71
|
-
"compilerOptions": {
|
|
72
|
-
"target": "ES6",
|
|
73
|
-
"module": "CommonJS",
|
|
74
|
-
"jsx": "react",
|
|
75
|
-
"strict": true,
|
|
76
|
-
"esModuleInterop": true,
|
|
77
|
-
"resolveJsonModule": true,
|
|
78
|
-
"skipLibCheck": true,
|
|
79
|
-
"forceConsistentCasingInFileNames": true,
|
|
80
|
-
"outDir": "./dist",
|
|
81
|
-
"moduleResolution": "nodenext"
|
|
82
|
-
},
|
|
83
|
-
"include": ["src/**/*"]
|
|
84
|
-
}
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
Estrutura mínima:
|
|
88
|
-
|
|
89
|
-
```
|
|
90
|
-
src/
|
|
91
|
-
web/
|
|
92
|
-
routes/
|
|
93
|
-
index.tsx
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
Exemplo de página inicial em `src/web/routes/index.tsx`:
|
|
97
|
-
|
|
98
|
-
```tsx
|
|
99
|
-
import { RouteConfig } from 'hightjs/client';
|
|
100
|
-
import React from 'react';
|
|
101
|
-
|
|
102
|
-
function Home() {
|
|
103
|
-
return <h1>Bem-vindo ao HightJS 🚀</h1>;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export const config: RouteConfig = {
|
|
107
|
-
pattern: '/',
|
|
108
|
-
component: Home,
|
|
109
|
-
generateMetadata: () => ({ title: 'HightJS | Home' })
|
|
110
|
-
};
|
|
111
|
-
export default config;
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
Rode em modo dev:
|
|
115
|
-
|
|
116
|
-
```bash
|
|
117
|
-
npx hight dev
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
Acesse: [http://localhost:3000](http://localhost:3000)
|
|
43
|
+
**[https://docs.hgo.me](https://docs.hgo.me)**
|
|
121
44
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
45
|
+
Learn about:
|
|
46
|
+
- Getting started
|
|
47
|
+
- Routing (frontend & backend)
|
|
48
|
+
- Authentication
|
|
49
|
+
- Middleware
|
|
50
|
+
- Layouts & Metadata
|
|
51
|
+
- Static export
|
|
52
|
+
- And much more!
|
|
125
53
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
### Fundamentos
|
|
129
|
-
- [📦 Estrutura Recomendada](./docs/estrutura.md)
|
|
130
|
-
- [🖥️ Rotas Frontend](./docs/rotas-frontend.md)
|
|
131
|
-
- [🌐 Rotas Backend](./docs/rotas-backend.md)
|
|
54
|
+
---
|
|
132
55
|
|
|
133
|
-
|
|
134
|
-
- [🛜 WebSocket](./docs/websocket.md)
|
|
135
|
-
- [🧩 Middlewares](./docs/middlewares.md)
|
|
136
|
-
- [🔐 Autenticação](./docs/autenticacao.md)
|
|
56
|
+
## 💬 Need Help?
|
|
137
57
|
|
|
138
|
-
|
|
139
|
-
- [🛠️ CLI](./docs/cli.md)
|
|
140
|
-
- [📂 Arquivos Especiais](./docs/arquivos-especiais.md)
|
|
141
|
-
- [🔌 Integrações](./docs/integracoes.md)
|
|
142
|
-
- [🔐 Segurança Interna](./docs/seguranca.md)
|
|
143
|
-
- [♻️ Hot Reload](./docs/hot-reload.md)
|
|
58
|
+
If you have questions or need support, feel free to reach out:
|
|
144
59
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
60
|
+
[](https://discord.com/users/1264710048786026588)
|
|
61
|
+
[](mailto:murillofrazaocunha@gmail.com)
|
|
62
|
+
[](https://instagram.com/itsmuh_)
|
|
63
|
+
[](https://github.com/murillo-frazao-cunha)
|
|
148
64
|
|
|
149
65
|
---
|
|
150
66
|
|
|
151
|
-
## 🪪
|
|
67
|
+
## 🪪 License
|
|
152
68
|
|
|
153
69
|
Copyright 2025 itsmuzin
|
|
154
70
|
|
|
155
|
-
|
|
71
|
+
This project is licensed under the [Apache License 2.0](../../LICENSE).
|
|
156
72
|
|
|
157
73
|
---
|
|
158
74
|
|
package/dist/bin/hightjs.js
CHANGED
|
@@ -18,6 +18,9 @@
|
|
|
18
18
|
*/
|
|
19
19
|
// Registra o ts-node para que o Node.js entenda TypeScript/TSX
|
|
20
20
|
require('ts-node').register();
|
|
21
|
+
// Registra loaders customizados para arquivos markdown, imagens, etc.
|
|
22
|
+
const { registerLoaders } = require('../loaders');
|
|
23
|
+
registerLoaders();
|
|
21
24
|
const { program } = require('commander');
|
|
22
25
|
program
|
|
23
26
|
.version('1.0.0')
|
|
@@ -90,14 +93,44 @@ program
|
|
|
90
93
|
.action((options) => {
|
|
91
94
|
initializeApp(options, false); // Chama a função com dev: false
|
|
92
95
|
});
|
|
93
|
-
|
|
96
|
+
/**
|
|
97
|
+
* Função corrigida para copiar diretórios recursivamente.
|
|
98
|
+
* Ela agora verifica se um item é um arquivo ou um diretório.
|
|
99
|
+
*/
|
|
100
|
+
function copyDirRecursive(src, dest) {
|
|
101
|
+
try {
|
|
102
|
+
// Garante que o diretório de destino exista
|
|
103
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
104
|
+
// Usamos { withFileTypes: true } para evitar uma chamada extra de fs.statSync
|
|
105
|
+
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
106
|
+
for (let entry of entries) {
|
|
107
|
+
const srcPath = path.join(src, entry.name);
|
|
108
|
+
const destPath = path.join(dest, entry.name);
|
|
109
|
+
if (entry.isDirectory()) {
|
|
110
|
+
// Se for um diretório, chama a si mesma (recursão)
|
|
111
|
+
copyDirRecursive(srcPath, destPath);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
// Se for um arquivo, apenas copia
|
|
115
|
+
fs.copyFileSync(srcPath, destPath);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
console.error(`❌ Erro ao copiar ${src} para ${dest}:`, error);
|
|
121
|
+
// Lança o erro para parar o processo de exportação se a cópia falhar
|
|
122
|
+
throw error;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
// --- INÍCIO DO SEU CÓDIGO (AGORA CORRIGIDO) ---
|
|
94
126
|
program
|
|
95
127
|
.command('export')
|
|
96
128
|
.description('Exports the application as static HTML to the "exported" folder.')
|
|
97
129
|
.option('-o, --output <path>', 'Specifies the output directory', 'exported')
|
|
98
130
|
.action(async (options) => {
|
|
99
131
|
const projectDir = process.cwd();
|
|
100
|
-
|
|
132
|
+
// Usar path.resolve é mais seguro para garantir um caminho absoluto
|
|
133
|
+
const exportDir = path.resolve(projectDir, options.output);
|
|
101
134
|
console.log('🚀 Starting export...\n');
|
|
102
135
|
try {
|
|
103
136
|
// 1. Cria a pasta exported (limpa se já existir)
|
|
@@ -109,43 +142,36 @@ program
|
|
|
109
142
|
console.log('✅ Export folder created\n');
|
|
110
143
|
// 2. Inicializa e prepara o build
|
|
111
144
|
console.log('🔨 Building application...');
|
|
145
|
+
// ATENÇÃO: Ajuste o caminho deste 'require' conforme a estrutura do seu projeto!
|
|
112
146
|
const teste = require("../helpers");
|
|
113
147
|
const app = teste.default({ dev: false, port: 3000, hostname: '0.0.0.0', framework: 'native' });
|
|
114
148
|
await app.prepare();
|
|
115
149
|
console.log('✅ Build complete\n');
|
|
116
|
-
// 3. Copia a pasta .hight para exported
|
|
150
|
+
// 3. Copia a pasta .hight para exported (*** CORRIGIDO ***)
|
|
117
151
|
const distDir = path.join(projectDir, '.hight');
|
|
118
152
|
if (fs.existsSync(distDir)) {
|
|
119
153
|
console.log('📦 Copying JavaScript files...');
|
|
120
154
|
const exportDistDir = path.join(exportDir, '.hight');
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
});
|
|
155
|
+
// --- Lógica de cópia substituída ---
|
|
156
|
+
// A função copyDirRecursive agora lida com tudo (arquivos e subpastas)
|
|
157
|
+
copyDirRecursive(distDir, exportDistDir);
|
|
158
|
+
// --- Fim da substituição ---
|
|
126
159
|
console.log('✅ JavaScript files copied\n');
|
|
127
160
|
}
|
|
128
|
-
// 4. Copia a pasta public se existir
|
|
161
|
+
// 4. Copia a pasta public se existir (*** CORRIGIDO ***)
|
|
129
162
|
const publicDir = path.join(projectDir, 'public');
|
|
130
163
|
if (fs.existsSync(publicDir)) {
|
|
131
164
|
console.log('📁 Copying public files...');
|
|
132
165
|
const exportPublicDir = path.join(exportDir, 'public');
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
copyRecursive(path.join(src, file), path.join(dest, file));
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
fs.copyFileSync(src, dest);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
copyRecursive(publicDir, exportPublicDir);
|
|
166
|
+
// --- Lógica de cópia substituída ---
|
|
167
|
+
// Reutilizamos a mesma função corrigida
|
|
168
|
+
copyDirRecursive(publicDir, exportPublicDir);
|
|
169
|
+
// --- Fim da substituição ---
|
|
145
170
|
console.log('✅ Public files copied\n');
|
|
146
171
|
}
|
|
147
172
|
// 5. Gera o index.html
|
|
148
173
|
console.log('📝 Generating index.html...');
|
|
174
|
+
// ATENÇÃO: Ajuste os caminhos destes 'requires' conforme a estrutura do seu projeto!
|
|
149
175
|
const { render } = require('../renderer');
|
|
150
176
|
const { loadRoutes, loadLayout, loadNotFound } = require('../router');
|
|
151
177
|
// Carrega as rotas para gerar o HTML
|
|
@@ -170,15 +196,17 @@ program
|
|
|
170
196
|
params: {},
|
|
171
197
|
allRoutes: routes
|
|
172
198
|
});
|
|
199
|
+
const scriptReplaced = html.replace('/_hight/', './.hight/');
|
|
173
200
|
const indexPath = path.join(exportDir, 'index.html');
|
|
174
|
-
fs.writeFileSync(indexPath,
|
|
201
|
+
fs.writeFileSync(indexPath, scriptReplaced, 'utf8');
|
|
175
202
|
console.log('✅ index.html generated\n');
|
|
176
203
|
}
|
|
177
204
|
console.log('🎉 Export completed successfully!');
|
|
178
205
|
console.log(`📂 Files exported to: ${exportDir}\n`);
|
|
179
206
|
}
|
|
180
207
|
catch (error) {
|
|
181
|
-
|
|
208
|
+
// Logar o erro completo (com stack trace) é mais útil
|
|
209
|
+
console.error('❌ Error during export:', error);
|
|
182
210
|
process.exit(1);
|
|
183
211
|
}
|
|
184
212
|
});
|
package/dist/builder.js
CHANGED
|
@@ -212,6 +212,142 @@ if (typeof window !== 'undefined' && window.__HWEB_HMR__) {
|
|
|
212
212
|
});
|
|
213
213
|
}
|
|
214
214
|
};
|
|
215
|
+
/**
|
|
216
|
+
* Plugin para suportar importação de arquivos Markdown (.md)
|
|
217
|
+
*/
|
|
218
|
+
const markdownPlugin = {
|
|
219
|
+
name: 'markdown-plugin',
|
|
220
|
+
setup(build) {
|
|
221
|
+
build.onLoad({ filter: /\.md$/ }, async (args) => {
|
|
222
|
+
const fs = require('fs');
|
|
223
|
+
const content = await fs.promises.readFile(args.path, 'utf8');
|
|
224
|
+
return {
|
|
225
|
+
contents: `export default ${JSON.stringify(content)};`,
|
|
226
|
+
loader: 'js'
|
|
227
|
+
};
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* Plugin para suportar importação de arquivos de imagem e outros assets
|
|
233
|
+
*/
|
|
234
|
+
const assetsPlugin = {
|
|
235
|
+
name: 'assets-plugin',
|
|
236
|
+
setup(build) {
|
|
237
|
+
// Suporte para imagens (PNG, JPG, JPEG, GIF, SVG, WEBP, etc)
|
|
238
|
+
build.onLoad({ filter: /\.(png|jpe?g|gif|webp|avif|ico|bmp|tiff?)$/i }, async (args) => {
|
|
239
|
+
const fs = require('fs');
|
|
240
|
+
const buffer = await fs.promises.readFile(args.path);
|
|
241
|
+
const base64 = buffer.toString('base64');
|
|
242
|
+
const ext = path.extname(args.path).slice(1).toLowerCase();
|
|
243
|
+
// Mapeamento de extensões para MIME types
|
|
244
|
+
const mimeTypes = {
|
|
245
|
+
'png': 'image/png',
|
|
246
|
+
'jpg': 'image/jpeg',
|
|
247
|
+
'jpeg': 'image/jpeg',
|
|
248
|
+
'gif': 'image/gif',
|
|
249
|
+
'webp': 'image/webp',
|
|
250
|
+
'avif': 'image/avif',
|
|
251
|
+
'ico': 'image/x-icon',
|
|
252
|
+
'bmp': 'image/bmp',
|
|
253
|
+
'tif': 'image/tiff',
|
|
254
|
+
'tiff': 'image/tiff'
|
|
255
|
+
};
|
|
256
|
+
const mimeType = mimeTypes[ext] || 'application/octet-stream';
|
|
257
|
+
return {
|
|
258
|
+
contents: `export default "data:${mimeType};base64,${base64}";`,
|
|
259
|
+
loader: 'js'
|
|
260
|
+
};
|
|
261
|
+
});
|
|
262
|
+
// Suporte especial para SVG (pode ser usado como string ou data URL)
|
|
263
|
+
build.onLoad({ filter: /\.svg$/i }, async (args) => {
|
|
264
|
+
const fs = require('fs');
|
|
265
|
+
const content = await fs.promises.readFile(args.path, 'utf8');
|
|
266
|
+
const base64 = Buffer.from(content).toString('base64');
|
|
267
|
+
return {
|
|
268
|
+
contents: `
|
|
269
|
+
export default "data:image/svg+xml;base64,${base64}";
|
|
270
|
+
export const svgContent = ${JSON.stringify(content)};
|
|
271
|
+
`,
|
|
272
|
+
loader: 'js'
|
|
273
|
+
};
|
|
274
|
+
});
|
|
275
|
+
// Suporte para arquivos JSON
|
|
276
|
+
build.onLoad({ filter: /\.json$/i }, async (args) => {
|
|
277
|
+
const fs = require('fs');
|
|
278
|
+
const content = await fs.promises.readFile(args.path, 'utf8');
|
|
279
|
+
return {
|
|
280
|
+
contents: `export default ${content};`,
|
|
281
|
+
loader: 'js'
|
|
282
|
+
};
|
|
283
|
+
});
|
|
284
|
+
// Suporte para arquivos de texto (.txt)
|
|
285
|
+
build.onLoad({ filter: /\.txt$/i }, async (args) => {
|
|
286
|
+
const fs = require('fs');
|
|
287
|
+
const content = await fs.promises.readFile(args.path, 'utf8');
|
|
288
|
+
return {
|
|
289
|
+
contents: `export default ${JSON.stringify(content)};`,
|
|
290
|
+
loader: 'js'
|
|
291
|
+
};
|
|
292
|
+
});
|
|
293
|
+
// Suporte para arquivos de fonte (WOFF, WOFF2, TTF, OTF, EOT)
|
|
294
|
+
build.onLoad({ filter: /\.(woff2?|ttf|otf|eot)$/i }, async (args) => {
|
|
295
|
+
const fs = require('fs');
|
|
296
|
+
const buffer = await fs.promises.readFile(args.path);
|
|
297
|
+
const base64 = buffer.toString('base64');
|
|
298
|
+
const ext = path.extname(args.path).slice(1).toLowerCase();
|
|
299
|
+
const mimeTypes = {
|
|
300
|
+
'woff': 'font/woff',
|
|
301
|
+
'woff2': 'font/woff2',
|
|
302
|
+
'ttf': 'font/ttf',
|
|
303
|
+
'otf': 'font/otf',
|
|
304
|
+
'eot': 'application/vnd.ms-fontobject'
|
|
305
|
+
};
|
|
306
|
+
const mimeType = mimeTypes[ext] || 'application/octet-stream';
|
|
307
|
+
return {
|
|
308
|
+
contents: `export default "data:${mimeType};base64,${base64}";`,
|
|
309
|
+
loader: 'js'
|
|
310
|
+
};
|
|
311
|
+
});
|
|
312
|
+
// Suporte para arquivos de áudio (MP3, WAV, OGG, etc)
|
|
313
|
+
build.onLoad({ filter: /\.(mp3|wav|ogg|m4a|aac|flac)$/i }, async (args) => {
|
|
314
|
+
const fs = require('fs');
|
|
315
|
+
const buffer = await fs.promises.readFile(args.path);
|
|
316
|
+
const base64 = buffer.toString('base64');
|
|
317
|
+
const ext = path.extname(args.path).slice(1).toLowerCase();
|
|
318
|
+
const mimeTypes = {
|
|
319
|
+
'mp3': 'audio/mpeg',
|
|
320
|
+
'wav': 'audio/wav',
|
|
321
|
+
'ogg': 'audio/ogg',
|
|
322
|
+
'm4a': 'audio/mp4',
|
|
323
|
+
'aac': 'audio/aac',
|
|
324
|
+
'flac': 'audio/flac'
|
|
325
|
+
};
|
|
326
|
+
const mimeType = mimeTypes[ext] || 'audio/mpeg';
|
|
327
|
+
return {
|
|
328
|
+
contents: `export default "data:${mimeType};base64,${base64}";`,
|
|
329
|
+
loader: 'js'
|
|
330
|
+
};
|
|
331
|
+
});
|
|
332
|
+
// Suporte para arquivos de vídeo (MP4, WEBM, OGV)
|
|
333
|
+
build.onLoad({ filter: /\.(mp4|webm|ogv)$/i }, async (args) => {
|
|
334
|
+
const fs = require('fs');
|
|
335
|
+
const buffer = await fs.promises.readFile(args.path);
|
|
336
|
+
const base64 = buffer.toString('base64');
|
|
337
|
+
const ext = path.extname(args.path).slice(1).toLowerCase();
|
|
338
|
+
const mimeTypes = {
|
|
339
|
+
'mp4': 'video/mp4',
|
|
340
|
+
'webm': 'video/webm',
|
|
341
|
+
'ogv': 'video/ogg'
|
|
342
|
+
};
|
|
343
|
+
const mimeType = mimeTypes[ext] || 'video/mp4';
|
|
344
|
+
return {
|
|
345
|
+
contents: `export default "data:${mimeType};base64,${base64}";`,
|
|
346
|
+
loader: 'js'
|
|
347
|
+
};
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
};
|
|
215
351
|
/**
|
|
216
352
|
* Builds with code splitting into multiple chunks based on module types.
|
|
217
353
|
* @param {string} entryPoint - The path to the entry file.
|
|
@@ -232,7 +368,7 @@ async function buildWithChunks(entryPoint, outdir, isProduction = false) {
|
|
|
232
368
|
outdir: outdir,
|
|
233
369
|
loader: { '.js': 'jsx', '.ts': 'tsx' },
|
|
234
370
|
external: nodeBuiltIns,
|
|
235
|
-
plugins: [postcssPlugin, npmDependenciesPlugin, reactResolvePlugin],
|
|
371
|
+
plugins: [postcssPlugin, npmDependenciesPlugin, reactResolvePlugin, markdownPlugin, assetsPlugin],
|
|
236
372
|
format: 'esm', // ESM suporta melhor o code splitting
|
|
237
373
|
jsx: 'automatic',
|
|
238
374
|
define: {
|
|
@@ -293,7 +429,7 @@ async function watchWithChunks(entryPoint, outdir, hotReloadManager = null) {
|
|
|
293
429
|
outdir: outdir,
|
|
294
430
|
loader: { '.js': 'jsx', '.ts': 'tsx' },
|
|
295
431
|
external: nodeBuiltIns,
|
|
296
|
-
plugins: [postcssPlugin, npmDependenciesPlugin, reactResolvePlugin, hmrPlugin, buildCompletePlugin],
|
|
432
|
+
plugins: [postcssPlugin, npmDependenciesPlugin, reactResolvePlugin, hmrPlugin, buildCompletePlugin, markdownPlugin, assetsPlugin],
|
|
297
433
|
format: 'esm',
|
|
298
434
|
jsx: 'automatic',
|
|
299
435
|
define: {
|
|
@@ -337,7 +473,7 @@ async function build(entryPoint, outfile, isProduction = false) {
|
|
|
337
473
|
outfile: outfile,
|
|
338
474
|
loader: { '.js': 'jsx', '.ts': 'tsx' },
|
|
339
475
|
external: nodeBuiltIns,
|
|
340
|
-
plugins: [postcssPlugin, npmDependenciesPlugin, reactResolvePlugin],
|
|
476
|
+
plugins: [postcssPlugin, npmDependenciesPlugin, reactResolvePlugin, markdownPlugin, assetsPlugin],
|
|
341
477
|
format: 'iife',
|
|
342
478
|
globalName: 'HwebApp',
|
|
343
479
|
jsx: 'automatic',
|
|
@@ -399,7 +535,6 @@ async function watch(entryPoint, outfile, hotReloadManager = null) {
|
|
|
399
535
|
outfile: outfile,
|
|
400
536
|
loader: { '.js': 'jsx', '.ts': 'tsx' },
|
|
401
537
|
external: nodeBuiltIns,
|
|
402
|
-
plugins: [postcssPlugin, npmDependenciesPlugin, reactResolvePlugin, buildCompletePlugin],
|
|
403
538
|
format: 'iife',
|
|
404
539
|
globalName: 'HwebApp',
|
|
405
540
|
jsx: 'automatic',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function
|
|
1
|
+
export default function App(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,53 +1,79 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default =
|
|
3
|
+
exports.default = App;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
/* Alterado de cor sólida para gradiente */
|
|
19
|
-
background: linear-gradient(to bottom, #e9e9e9, #ffffff);
|
|
20
|
-
margin: 0;
|
|
21
|
-
}
|
|
5
|
+
function App() {
|
|
6
|
+
const globalStyles = `
|
|
7
|
+
|
|
8
|
+
html, body {
|
|
9
|
+
margin: 0;
|
|
10
|
+
padding: 0;
|
|
11
|
+
width: 100%;
|
|
12
|
+
height: 100%;
|
|
13
|
+
font-family: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
|
|
14
|
+
-webkit-font-smoothing: antialiased;
|
|
15
|
+
-moz-osx-font-smoothing: grayscale;
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
}
|
|
22
18
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
19
|
+
*, *:before, *:after {
|
|
20
|
+
box-sizing: inherit;
|
|
21
|
+
}
|
|
26
22
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
body {
|
|
24
|
+
color: #000;
|
|
25
|
+
background: linear-gradient(to bottom, #e9e9e9, #ffffff);
|
|
26
|
+
background-attachment: fixed;
|
|
27
|
+
|
|
28
|
+
display: flex;
|
|
29
|
+
align-items: center;
|
|
30
|
+
justify-content: center;
|
|
31
|
+
min-height: 100vh;
|
|
32
|
+
text-align: center;
|
|
33
|
+
padding: 20px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.error-container {
|
|
37
|
+
/* Remove qualquer estilo de "card" anterior */
|
|
38
|
+
}
|
|
33
39
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
40
|
+
.hight-error-h1 {
|
|
41
|
+
border-right: 1px solid rgba(0, 0, 0, .3);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@media (prefers-color-scheme: dark) {
|
|
45
|
+
body {
|
|
46
|
+
color: #fff;
|
|
47
|
+
background: linear-gradient(to bottom, #222, #000);
|
|
48
|
+
}
|
|
49
|
+
.hight-error-h2 {
|
|
50
|
+
color: white;
|
|
51
|
+
}
|
|
52
|
+
.hight-error-h1 {
|
|
53
|
+
color: white;
|
|
54
|
+
border-right: 1px solid rgba(255, 255, 255, .3);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
`;
|
|
58
|
+
// Estilos inline do seu exemplo original
|
|
59
|
+
const h1Styles = {
|
|
60
|
+
display: 'inline-block',
|
|
61
|
+
margin: '0px 20px 0px 0px',
|
|
62
|
+
padding: '0px 23px 0px 0px',
|
|
63
|
+
fontSize: '24px',
|
|
64
|
+
fontWeight: '500',
|
|
65
|
+
verticalAlign: 'top',
|
|
66
|
+
lineHeight: '49px'
|
|
67
|
+
};
|
|
68
|
+
const h2ContainerStyles = {
|
|
69
|
+
display: 'inline-block',
|
|
70
|
+
verticalAlign: 'top', // Alinha com o topo do H1
|
|
71
|
+
};
|
|
72
|
+
const h2Styles = {
|
|
73
|
+
fontSize: '14px',
|
|
74
|
+
fontWeight: '400',
|
|
75
|
+
lineHeight: '49px',
|
|
76
|
+
margin: '0px'
|
|
77
|
+
};
|
|
78
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("style", { dangerouslySetInnerHTML: { __html: globalStyles } }), (0, jsx_runtime_1.jsxs)("div", { className: "error-container", children: [(0, jsx_runtime_1.jsx)("h1", { className: "hight-error-h1", style: h1Styles, children: "404" }), (0, jsx_runtime_1.jsx)("div", { style: h2ContainerStyles, children: (0, jsx_runtime_1.jsx)("h2", { style: h2Styles, className: "hight-error-h2", children: "This page cannot be found." }) })] })] }));
|
|
53
79
|
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.router = exports.Link = void 0;
|
|
4
2
|
/*
|
|
5
3
|
* This file is part of the HightJS Project.
|
|
6
4
|
* Copyright (c) 2025 itsmuzin
|
|
@@ -17,8 +15,10 @@ exports.router = exports.Link = void 0;
|
|
|
17
15
|
* See the License for the specific language governing permissions and
|
|
18
16
|
* limitations under the License.
|
|
19
17
|
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.router = exports.Link = void 0;
|
|
20
20
|
// Este arquivo exporta apenas código seguro para o cliente (navegador)
|
|
21
|
-
var Link_1 = require("
|
|
21
|
+
var Link_1 = require("../components/Link");
|
|
22
22
|
Object.defineProperty(exports, "Link", { enumerable: true, get: function () { return Link_1.Link; } });
|
|
23
|
-
var clientRouter_1 = require("./
|
|
23
|
+
var clientRouter_1 = require("./clientRouter");
|
|
24
24
|
Object.defineProperty(exports, "router", { enumerable: true, get: function () { return clientRouter_1.router; } });
|