vatts 1.2.0-alpha.1 → 1.2.0-alpha.2
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/express.js +5 -1
- package/dist/adapters/factory.js +58 -21
- package/dist/adapters/fastify.js +5 -1
- package/dist/adapters/native.js +5 -1
- package/dist/api/console.js +25 -17
- package/dist/api/framework.js +22 -15
- package/dist/api/http.js +7 -2
- package/dist/builder.js +19 -10
- package/dist/client/clientRouter.js +6 -2
- package/dist/client/rpc.js +7 -4
- package/dist/env/env.js +18 -11
- package/dist/global/global.d.ts +177 -122
- package/dist/helpers.js +108 -67
- package/dist/hotReload.d.ts +6 -0
- package/dist/hotReload.js +179 -31
- package/dist/index.js +159 -115
- package/dist/react/BuildingPage.d.ts +2 -1
- package/dist/react/BuildingPage.js +47 -4
- package/dist/react/DefaultNotFound.d.ts +2 -1
- package/dist/react/DefaultNotFound.js +92 -17
- package/dist/react/DevIndicator.js +66 -23
- package/dist/react/ErrorModal.js +91 -40
- package/dist/react/Link.d.ts +2 -2
- package/dist/react/Link.js +27 -5
- package/dist/react/client.js +16 -5
- package/dist/react/entry.client.js +70 -30
- package/dist/react/image/Image.js +8 -3
- package/dist/react/renderer-react.js +53 -25
- package/dist/renderer.d.ts +4 -0
- package/dist/renderer.js +13 -5
- package/dist/router.js +82 -63
- package/dist/rpc/annotations.js +7 -3
- package/dist/rpc/server.js +21 -15
- package/dist/rpc/types.js +4 -1
- package/dist/types/framework.js +2 -1
- package/dist/types.js +2 -1
- package/dist/vue/App.vue +34 -37
- package/dist/vue/BuildingPage.vue +118 -102
- package/dist/vue/ErrorModal.vue +19 -37
- package/dist/vue/Link.vue +8 -7
- package/dist/vue/client.js +16 -6
- package/dist/vue/entry.client.js +8 -3
- package/dist/vue/image/Image.vue +25 -19
- package/dist/vue/renderer.vue.js +80 -26
- package/package.json +25 -12
- package/dist/global/global.js +0 -17
package/dist/helpers.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
2
3
|
/*
|
|
3
4
|
* This file is part of the Vatts.js Project.
|
|
4
5
|
* Copyright (c) 2026 itsmuzin
|
|
@@ -15,16 +16,57 @@
|
|
|
15
16
|
* See the License for the specific language governing permissions and
|
|
16
17
|
* limitations under the License.
|
|
17
18
|
*/
|
|
19
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
20
|
+
if (k2 === undefined) k2 = k;
|
|
21
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
22
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
23
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
24
|
+
}
|
|
25
|
+
Object.defineProperty(o, k2, desc);
|
|
26
|
+
}) : (function(o, m, k, k2) {
|
|
27
|
+
if (k2 === undefined) k2 = k;
|
|
28
|
+
o[k2] = m[k];
|
|
29
|
+
}));
|
|
30
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
31
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
32
|
+
}) : function(o, v) {
|
|
33
|
+
o["default"] = v;
|
|
34
|
+
});
|
|
35
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
36
|
+
var ownKeys = function(o) {
|
|
37
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
38
|
+
var ar = [];
|
|
39
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
40
|
+
return ar;
|
|
41
|
+
};
|
|
42
|
+
return ownKeys(o);
|
|
43
|
+
};
|
|
44
|
+
return function (mod) {
|
|
45
|
+
if (mod && mod.__esModule) return mod;
|
|
46
|
+
var result = {};
|
|
47
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
48
|
+
__setModuleDefault(result, mod);
|
|
49
|
+
return result;
|
|
50
|
+
};
|
|
51
|
+
})();
|
|
52
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
53
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
54
|
+
};
|
|
55
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
56
|
+
exports.config = void 0;
|
|
57
|
+
exports.loadVattsConfig = loadVattsConfig;
|
|
58
|
+
exports.setConfig = setConfig;
|
|
59
|
+
exports.app = app;
|
|
18
60
|
// Imports Nativos do Node.js (movidos para o topo)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
61
|
+
const http_1 = __importDefault(require("http"));
|
|
62
|
+
const os_1 = __importDefault(require("os"));
|
|
63
|
+
const url_1 = require("url"); // API moderna, substitui 'querystring'
|
|
64
|
+
const path_1 = __importDefault(require("path"));
|
|
23
65
|
// Helpers para integração com diferentes frameworks
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
66
|
+
const index_js_1 = __importStar(require("./index.js")); // Importando o tipo
|
|
67
|
+
const console_1 = __importStar(require("./api/console"));
|
|
68
|
+
const https_1 = __importDefault(require("https")); // <-- ADICIONAR
|
|
69
|
+
const fs_1 = __importDefault(require("fs")); // <-- ADICIONAR
|
|
28
70
|
// Registra loaders customizados para importar arquivos não-JS
|
|
29
71
|
const { registerLoaders } = require('./loaders');
|
|
30
72
|
registerLoaders({ projectDir: process.cwd() });
|
|
@@ -33,7 +75,7 @@ registerLoaders({ projectDir: process.cwd() });
|
|
|
33
75
|
* Encontra o IP externo local (rede)
|
|
34
76
|
*/
|
|
35
77
|
function getLocalExternalIp() {
|
|
36
|
-
const interfaces =
|
|
78
|
+
const interfaces = os_1.default.networkInterfaces();
|
|
37
79
|
for (const name of Object.keys(interfaces)) {
|
|
38
80
|
const ifaceList = interfaces[name];
|
|
39
81
|
if (ifaceList) {
|
|
@@ -52,28 +94,28 @@ const sendBox = (options) => {
|
|
|
52
94
|
const protocol = isSSL ? 'https' : 'http';
|
|
53
95
|
const localIp = getLocalExternalIp();
|
|
54
96
|
// Estilos Clean
|
|
55
|
-
const labelStyle = Colors.FgGray;
|
|
56
|
-
const urlStyle = Colors.Bright + Colors.FgRed; // Ciano para links é o padrão mais legível
|
|
97
|
+
const labelStyle = console_1.Colors.FgGray;
|
|
98
|
+
const urlStyle = console_1.Colors.Bright + console_1.Colors.FgRed; // Ciano para links é o padrão mais legível
|
|
57
99
|
const now = new Date();
|
|
58
100
|
const time = now.toLocaleTimeString('pt-BR', { hour12: false });
|
|
59
|
-
const timer = ` ${Colors.FgGray}${time}${Colors.Reset} `;
|
|
101
|
+
const timer = ` ${console_1.Colors.FgGray}${time}${console_1.Colors.Reset} `;
|
|
60
102
|
// Pequeno espaçamento visual antes dos logs de acesso
|
|
61
103
|
console.log('');
|
|
62
104
|
console.log(timer + labelStyle + ' Access on:');
|
|
63
105
|
console.log(' ');
|
|
64
106
|
// 1. Local (Alinhamento: Local tem 6 letras + 4 espaços = 10)
|
|
65
|
-
console.info(timer + `${labelStyle} ┃ Local:${Colors.Reset} ${urlStyle}${protocol}://localhost:${options.port}${Colors.Reset}`);
|
|
107
|
+
console.info(timer + `${labelStyle} ┃ Local:${console_1.Colors.Reset} ${urlStyle}${protocol}://localhost:${options.port}${console_1.Colors.Reset}`);
|
|
66
108
|
// 2. Network (Alinhamento: Network tem 8 letras + 2 espaços = 10)
|
|
67
109
|
if (localIp) {
|
|
68
|
-
console.info(timer + `${labelStyle} ┃ Network:${Colors.Reset} ${urlStyle}${protocol}://${localIp}:${options.port}${Colors.Reset}`);
|
|
110
|
+
console.info(timer + `${labelStyle} ┃ Network:${console_1.Colors.Reset} ${urlStyle}${protocol}://${localIp}:${options.port}${console_1.Colors.Reset}`);
|
|
69
111
|
}
|
|
70
112
|
// 3. Infos Extras (Redirect HTTP -> HTTPS)
|
|
71
113
|
if (isSSL && options.ssl?.redirectPort) {
|
|
72
|
-
console.info(timer + `${labelStyle} ┃ Redirect:${Colors.Reset} ${labelStyle}port ${options.ssl.redirectPort} ➜ https${Colors.Reset}`);
|
|
114
|
+
console.info(timer + `${labelStyle} ┃ Redirect:${console_1.Colors.Reset} ${labelStyle}port ${options.ssl.redirectPort} ➜ https${console_1.Colors.Reset}`);
|
|
73
115
|
}
|
|
74
116
|
// 4. Info de Ambiente
|
|
75
117
|
if (isDev) {
|
|
76
|
-
console.info(timer + `${labelStyle} ┃ Mode:${Colors.Reset} ${Colors.FgAlmostWhite}development${Colors.Reset}`);
|
|
118
|
+
console.info(timer + `${labelStyle} ┃ Mode:${console_1.Colors.Reset} ${console_1.Colors.FgAlmostWhite}development${console_1.Colors.Reset}`);
|
|
77
119
|
}
|
|
78
120
|
// Espaçamento final
|
|
79
121
|
console.log('\n');
|
|
@@ -84,7 +126,7 @@ const sendBox = (options) => {
|
|
|
84
126
|
* @param phase Fase de execução ('development' ou 'production')
|
|
85
127
|
* @returns Configuração mesclada com os valores padrão
|
|
86
128
|
*/
|
|
87
|
-
|
|
129
|
+
async function loadVattsConfig(projectDir, phase) {
|
|
88
130
|
const defaultConfig = {
|
|
89
131
|
maxHeadersCount: 100,
|
|
90
132
|
headersTimeout: 60000,
|
|
@@ -99,12 +141,12 @@ export async function loadVattsConfig(projectDir, phase) {
|
|
|
99
141
|
try {
|
|
100
142
|
// Tenta primeiro .ts, depois .js
|
|
101
143
|
const possiblePaths = [
|
|
102
|
-
|
|
103
|
-
|
|
144
|
+
path_1.default.join(projectDir, 'vatts.config.ts'),
|
|
145
|
+
path_1.default.join(projectDir, 'vatts.config.js'),
|
|
104
146
|
];
|
|
105
147
|
let configPath = null;
|
|
106
148
|
for (const p of possiblePaths) {
|
|
107
|
-
if (
|
|
149
|
+
if (fs_1.default.existsSync(p)) {
|
|
108
150
|
configPath = p;
|
|
109
151
|
break;
|
|
110
152
|
}
|
|
@@ -126,14 +168,14 @@ export async function loadVattsConfig(projectDir, phase) {
|
|
|
126
168
|
}
|
|
127
169
|
// Mescla a configuração do usuário com a padrão
|
|
128
170
|
const mergedConfig = { ...defaultConfig, ...userConfig };
|
|
129
|
-
const configFileName =
|
|
130
|
-
|
|
171
|
+
const configFileName = path_1.default.basename(configPath);
|
|
172
|
+
console_1.default.info(`Loaded ${configFileName}`);
|
|
131
173
|
return mergedConfig;
|
|
132
174
|
}
|
|
133
175
|
catch (error) {
|
|
134
176
|
if (error instanceof Error) {
|
|
135
|
-
|
|
136
|
-
|
|
177
|
+
console_1.default.warn(`${console_1.Colors.FgYellow}[Config]${console_1.Colors.Reset} Error loading vatts.config: ${error.message}`);
|
|
178
|
+
console_1.default.warn(`${console_1.Colors.FgYellow}[Config]${console_1.Colors.Reset} Using default configuration`);
|
|
137
179
|
}
|
|
138
180
|
return defaultConfig;
|
|
139
181
|
}
|
|
@@ -172,7 +214,7 @@ function applyCors(req, res, corsConfig) {
|
|
|
172
214
|
}
|
|
173
215
|
}
|
|
174
216
|
catch (error) {
|
|
175
|
-
|
|
217
|
+
console_1.default.warn(`${console_1.Colors.FgYellow}[CORS]${console_1.Colors.Reset} Error validating origin: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
176
218
|
}
|
|
177
219
|
}
|
|
178
220
|
// Se a origem não for permitida e não for wildcard, não aplica outros headers
|
|
@@ -258,7 +300,7 @@ const parseBody = (req) => {
|
|
|
258
300
|
}
|
|
259
301
|
else if (contentType.includes('application/x-www-form-urlencoded')) {
|
|
260
302
|
// Usa API moderna URLSearchParams (segura contra prototype pollution)
|
|
261
|
-
resolve(Object.fromEntries(new URLSearchParams(body)));
|
|
303
|
+
resolve(Object.fromEntries(new url_1.URLSearchParams(body)));
|
|
262
304
|
}
|
|
263
305
|
else {
|
|
264
306
|
resolve(body); // Fallback para texto plano
|
|
@@ -275,9 +317,8 @@ const parseBody = (req) => {
|
|
|
275
317
|
});
|
|
276
318
|
});
|
|
277
319
|
};
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
config = newConfig;
|
|
320
|
+
function setConfig(newConfig) {
|
|
321
|
+
exports.config = newConfig;
|
|
281
322
|
}
|
|
282
323
|
/**
|
|
283
324
|
* Inicializa servidor nativo do Vatts.js usando HTTP ou HTTPS
|
|
@@ -287,12 +328,12 @@ async function initNativeServer(vattsApp, options, port, hostname) {
|
|
|
287
328
|
const projectDir = options.dir || process.cwd();
|
|
288
329
|
const phase = options.dev ? 'development' : 'production';
|
|
289
330
|
const vattsConfig = await loadVattsConfig(projectDir, phase);
|
|
290
|
-
config = vattsConfig;
|
|
331
|
+
exports.config = vattsConfig;
|
|
291
332
|
// Passa envFiles da config para as opções do vatts
|
|
292
333
|
options.envFiles = vattsConfig.envFiles;
|
|
293
334
|
await vattsApp.prepare();
|
|
294
335
|
const handler = vattsApp.getRequestHandler();
|
|
295
|
-
const msg =
|
|
336
|
+
const msg = console_1.default.dynamicLine(`${console_1.Colors.Bright}Starting Vatts.js on port ${options.port}${console_1.Colors.Reset}`);
|
|
296
337
|
// --- LÓGICA DO LISTENER (REUTILIZÁVEL) ---
|
|
297
338
|
// Extraímos a lógica principal para uma variável
|
|
298
339
|
// para que possa ser usada tanto pelo servidor HTTP quanto HTTPS.
|
|
@@ -306,7 +347,7 @@ async function initNativeServer(vattsApp, options, port, hostname) {
|
|
|
306
347
|
// Requisição OPTIONS foi respondida pelo CORS
|
|
307
348
|
if (vattsConfig.accessLogging) {
|
|
308
349
|
const duration = Date.now() - requestStartTime;
|
|
309
|
-
|
|
350
|
+
console_1.default.logCustomLevel('OPTIONS', true, console_1.Colors.BgMagenta, `${url} ${console_1.Colors.FgGreen}204${console_1.Colors.Reset} ${console_1.Colors.FgGray}${duration}ms${console_1.Colors.Reset} ${console_1.Colors.FgCyan}[CORS]${console_1.Colors.Reset}`);
|
|
310
351
|
}
|
|
311
352
|
return;
|
|
312
353
|
}
|
|
@@ -337,7 +378,7 @@ async function initNativeServer(vattsApp, options, port, hostname) {
|
|
|
337
378
|
// Log de timeout
|
|
338
379
|
if (vattsConfig.accessLogging) {
|
|
339
380
|
const duration = Date.now() - requestStartTime;
|
|
340
|
-
|
|
381
|
+
console_1.default.info(`${console_1.Colors.FgYellow}${method}${console_1.Colors.Reset} ${url} ${console_1.Colors.FgRed}408${console_1.Colors.Reset} ${console_1.Colors.FgGray}${duration}ms${console_1.Colors.Reset}`);
|
|
341
382
|
}
|
|
342
383
|
});
|
|
343
384
|
// Intercepta o método end() para logar quando a resposta for enviada
|
|
@@ -349,24 +390,24 @@ async function initNativeServer(vattsApp, options, port, hostname) {
|
|
|
349
390
|
const duration = Date.now() - requestStartTime;
|
|
350
391
|
const statusCode = res.statusCode || 200;
|
|
351
392
|
// Define cor baseada no status code
|
|
352
|
-
let statusColor = Colors.FgGreen; // 2xx
|
|
393
|
+
let statusColor = console_1.Colors.FgGreen; // 2xx
|
|
353
394
|
if (statusCode >= 500)
|
|
354
|
-
statusColor = Colors.FgRed; // 5xx
|
|
395
|
+
statusColor = console_1.Colors.FgRed; // 5xx
|
|
355
396
|
else if (statusCode >= 400)
|
|
356
|
-
statusColor = Colors.FgYellow; // 4xx
|
|
397
|
+
statusColor = console_1.Colors.FgYellow; // 4xx
|
|
357
398
|
else if (statusCode >= 300)
|
|
358
|
-
statusColor = Colors.FgCyan; // 3xx
|
|
399
|
+
statusColor = console_1.Colors.FgCyan; // 3xx
|
|
359
400
|
// Formata o método com cor
|
|
360
|
-
let methodColor = Colors.FgRed;
|
|
401
|
+
let methodColor = console_1.Colors.FgRed;
|
|
361
402
|
if (method === 'POST')
|
|
362
|
-
methodColor = Colors.FgGreen;
|
|
403
|
+
methodColor = console_1.Colors.FgGreen;
|
|
363
404
|
else if (method === 'PUT')
|
|
364
|
-
methodColor = Colors.FgYellow;
|
|
405
|
+
methodColor = console_1.Colors.FgYellow;
|
|
365
406
|
else if (method === 'DELETE')
|
|
366
|
-
methodColor = Colors.FgRed;
|
|
407
|
+
methodColor = console_1.Colors.FgRed;
|
|
367
408
|
else if (method === 'PATCH')
|
|
368
|
-
methodColor = Colors.FgMagenta;
|
|
369
|
-
|
|
409
|
+
methodColor = console_1.Colors.FgMagenta;
|
|
410
|
+
console_1.default.logCustomLevel(method, true, methodColor, `${url} ${statusColor}${statusCode}${console_1.Colors.Reset} ${console_1.Colors.FgGray}${duration}ms${console_1.Colors.Reset}`);
|
|
370
411
|
}
|
|
371
412
|
// @ts-ignore
|
|
372
413
|
return originalEnd.apply(this, args);
|
|
@@ -388,10 +429,10 @@ async function initNativeServer(vattsApp, options, port, hostname) {
|
|
|
388
429
|
catch (error) {
|
|
389
430
|
// Log do erro no servidor
|
|
390
431
|
if (error instanceof Error) {
|
|
391
|
-
|
|
432
|
+
console_1.default.error(`Native server error: ${error.message}`);
|
|
392
433
|
}
|
|
393
434
|
else {
|
|
394
|
-
|
|
435
|
+
console_1.default.error('Unknown native server error:', error);
|
|
395
436
|
}
|
|
396
437
|
// Tratamento de erro (idêntico ao seu original)
|
|
397
438
|
if (!res.headersSent) {
|
|
@@ -426,15 +467,15 @@ async function initNativeServer(vattsApp, options, port, hostname) {
|
|
|
426
467
|
const isSSL = options.ssl && options.ssl.key && options.ssl.cert;
|
|
427
468
|
if (isSSL && options.ssl) {
|
|
428
469
|
const sslOptions = {
|
|
429
|
-
key:
|
|
430
|
-
cert:
|
|
431
|
-
ca: options.ssl.ca ?
|
|
470
|
+
key: fs_1.default.readFileSync(options.ssl.key),
|
|
471
|
+
cert: fs_1.default.readFileSync(options.ssl.cert),
|
|
472
|
+
ca: options.ssl.ca ? fs_1.default.readFileSync(options.ssl.ca) : undefined
|
|
432
473
|
};
|
|
433
474
|
// 1. Cria o servidor HTTPS principal
|
|
434
|
-
server =
|
|
475
|
+
server = https_1.default.createServer(sslOptions, requestListener);
|
|
435
476
|
// 2. Cria o servidor de REDIRECIONAMENTO (HTTP -> HTTPS)
|
|
436
477
|
const httpRedirectPort = options.ssl.redirectPort;
|
|
437
|
-
|
|
478
|
+
http_1.default.createServer((req, res) => {
|
|
438
479
|
// Evita host header injection/open redirect: prefere hostname configurado
|
|
439
480
|
const rawHost = String(req.headers['host'] || '').trim();
|
|
440
481
|
const configuredHost = (options.hostname || hostname || '').trim();
|
|
@@ -460,7 +501,7 @@ async function initNativeServer(vattsApp, options, port, hostname) {
|
|
|
460
501
|
else {
|
|
461
502
|
// --- MODO HTTP (Original) ---
|
|
462
503
|
// Cria o servidor HTTP nativo
|
|
463
|
-
server =
|
|
504
|
+
server = http_1.default.createServer(requestListener);
|
|
464
505
|
}
|
|
465
506
|
// Configurações de segurança do servidor (usa configuração personalizada)
|
|
466
507
|
server.setTimeout(vattsConfig.serverTimeout || 35000); // Timeout geral do servidor
|
|
@@ -469,7 +510,7 @@ async function initNativeServer(vattsApp, options, port, hostname) {
|
|
|
469
510
|
server.requestTimeout = vattsConfig.requestTimeout || 30000; // Timeout para requisições
|
|
470
511
|
server.listen(port, hostname, () => {
|
|
471
512
|
sendBox({ ...options, port });
|
|
472
|
-
msg.end(`${Colors.Bright}Ready on port ${Colors.BgGreen} ${options.port} ${Colors.Reset}${Colors.Bright} in ${Date.now() - time}ms${Colors.Reset}\n`);
|
|
513
|
+
msg.end(`${console_1.Colors.Bright}Ready on port ${console_1.Colors.BgGreen} ${options.port} ${console_1.Colors.Reset}${console_1.Colors.Bright} in ${Date.now() - time}ms${console_1.Colors.Reset}\n`);
|
|
473
514
|
});
|
|
474
515
|
// Configura WebSocket para hot reload (Comum a ambos)
|
|
475
516
|
vattsApp.setupWebSocket(server);
|
|
@@ -477,11 +518,11 @@ async function initNativeServer(vattsApp, options, port, hostname) {
|
|
|
477
518
|
return server;
|
|
478
519
|
}
|
|
479
520
|
// --- Função Principal ---
|
|
480
|
-
|
|
521
|
+
function app(options = {}) {
|
|
481
522
|
const framework = options.framework || 'native';
|
|
482
|
-
FrameworkAdapterFactory.setFramework(framework);
|
|
523
|
+
index_js_1.FrameworkAdapterFactory.setFramework(framework);
|
|
483
524
|
// Tipando a app principal do vatts
|
|
484
|
-
const vattsApp =
|
|
525
|
+
const vattsApp = (0, index_js_1.default)(options);
|
|
485
526
|
return {
|
|
486
527
|
...vattsApp,
|
|
487
528
|
/**
|
|
@@ -501,7 +542,7 @@ export function app(options = {}) {
|
|
|
501
542
|
serverApp.use(cookieParser());
|
|
502
543
|
}
|
|
503
544
|
catch (e) {
|
|
504
|
-
|
|
545
|
+
console_1.default.error("Could not find cookie-parser");
|
|
505
546
|
}
|
|
506
547
|
serverApp.use(express.json());
|
|
507
548
|
serverApp.use(express.urlencoded({ extended: true }));
|
|
@@ -513,13 +554,13 @@ export function app(options = {}) {
|
|
|
513
554
|
await serverApp.register(require('@fastify/cookie'));
|
|
514
555
|
}
|
|
515
556
|
catch (e) {
|
|
516
|
-
|
|
557
|
+
console_1.default.error("Could not find @fastify/cookie");
|
|
517
558
|
}
|
|
518
559
|
try {
|
|
519
560
|
await serverApp.register(require('@fastify/formbody'));
|
|
520
561
|
}
|
|
521
562
|
catch (e) {
|
|
522
|
-
|
|
563
|
+
console_1.default.error("Could not find @fastify/formbody");
|
|
523
564
|
}
|
|
524
565
|
await serverApp.register(async (fastify) => {
|
|
525
566
|
fastify.all('*', handler);
|
|
@@ -547,7 +588,7 @@ export function app(options = {}) {
|
|
|
547
588
|
return data.version;
|
|
548
589
|
}
|
|
549
590
|
catch (error) {
|
|
550
|
-
|
|
591
|
+
console_1.default.error('Could not check for the latest Vatts.js version:', error);
|
|
551
592
|
return currentVersion; // Retorna a versão atual em caso de erro
|
|
552
593
|
}
|
|
553
594
|
}
|
|
@@ -555,26 +596,26 @@ export function app(options = {}) {
|
|
|
555
596
|
const isUpToDate = latestVersion === currentVersion;
|
|
556
597
|
let message;
|
|
557
598
|
if (!isUpToDate) {
|
|
558
|
-
message = `${Colors.FgRed} A new version is available (v${latestVersion})${Colors.FgMagenta}`;
|
|
599
|
+
message = `${console_1.Colors.FgRed} A new version is available (v${latestVersion})${console_1.Colors.FgMagenta}`;
|
|
559
600
|
}
|
|
560
601
|
else {
|
|
561
|
-
message = `${Colors.FgGreen} You are on the latest version${Colors.FgMagenta}`;
|
|
602
|
+
message = `${console_1.Colors.FgGreen} You are on the latest version${console_1.Colors.FgMagenta}`;
|
|
562
603
|
}
|
|
563
604
|
// JS STICK LETTERS
|
|
564
|
-
console.log(`${Colors.Bright + Colors.FgRed}
|
|
565
|
-
${Colors.Bright + Colors.FgRed} ___ ___ __ ${Colors.FgWhite} __
|
|
566
|
-
${Colors.Bright + Colors.FgRed} \\ / /\\ | | /__\`${Colors.FgWhite} | /__\` ${Colors.Bright + Colors.FgRed}Vatts${Colors.FgWhite}.js ${Colors.FgGray}(v${require('../package.json').version}) - itsmuzin${Colors.FgMagenta}
|
|
567
|
-
${Colors.Bright + Colors.FgRed} \\/ /~~\\ | | .__/ .${Colors.FgWhite} \\__/ .__/ ${message}
|
|
605
|
+
console.log(`${console_1.Colors.Bright + console_1.Colors.FgRed}
|
|
606
|
+
${console_1.Colors.Bright + console_1.Colors.FgRed} ___ ___ __ ${console_1.Colors.FgWhite} __
|
|
607
|
+
${console_1.Colors.Bright + console_1.Colors.FgRed} \\ / /\\ | | /__\`${console_1.Colors.FgWhite} | /__\` ${console_1.Colors.Bright + console_1.Colors.FgRed}Vatts${console_1.Colors.FgWhite}.js ${console_1.Colors.FgGray}(v${require('../package.json').version}) - itsmuzin${console_1.Colors.FgMagenta}
|
|
608
|
+
${console_1.Colors.Bright + console_1.Colors.FgRed} \\/ /~~\\ | | .__/ .${console_1.Colors.FgWhite} \\__/ .__/ ${message}
|
|
568
609
|
|
|
569
610
|
`);
|
|
570
611
|
const actualPort = options.port || 3000;
|
|
571
612
|
const actualHostname = options.hostname || "0.0.0.0";
|
|
572
613
|
if (framework !== 'native') {
|
|
573
|
-
|
|
614
|
+
console_1.default.warn(`The "${framework}" framework was selected, but the init() method only works with the "native" framework. Starting native server...`);
|
|
574
615
|
}
|
|
575
616
|
return await initNativeServer(vattsApp, options, actualPort, actualHostname);
|
|
576
617
|
}
|
|
577
618
|
};
|
|
578
619
|
}
|
|
579
620
|
// Exporta a função 'app' como nomeada e também como padrão
|
|
580
|
-
|
|
621
|
+
exports.default = app;
|
package/dist/hotReload.d.ts
CHANGED
|
@@ -38,5 +38,11 @@ export declare class HotReloadManager {
|
|
|
38
38
|
stop(): void;
|
|
39
39
|
private lastTypecheckAt;
|
|
40
40
|
private lastTypecheckResult;
|
|
41
|
+
/**
|
|
42
|
+
* Verifica erros específicos de arquivos Vue usando @vue/compiler-sfc.
|
|
43
|
+
* Isso permite capturar erros de sintaxe (como falta de ponto e vírgula, tags mal fechadas)
|
|
44
|
+
* que o compilador padrão pode emitir mas que precisam ser formatados para o cliente.
|
|
45
|
+
*/
|
|
46
|
+
private checkVueFiles;
|
|
41
47
|
private typecheckFrontend;
|
|
42
48
|
}
|