vatts 1.1.4-alpha.9 → 1.2.0-alpha.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/dist/adapters/express.js +3 -8
- package/dist/adapters/factory.js +22 -59
- package/dist/adapters/fastify.js +3 -8
- package/dist/adapters/native.js +7 -12
- package/dist/api/console.js +28 -34
- package/dist/api/framework.d.ts +2 -0
- package/dist/api/framework.js +30 -0
- package/dist/api/http.js +13 -18
- package/dist/bin/vatts.js +50 -87
- package/dist/builder.js +182 -108
- package/dist/client/clientRouter.js +3 -7
- package/dist/client/rpc.js +4 -7
- package/dist/env/env.js +11 -18
- package/dist/global/global.d.ts +5 -0
- package/dist/helpers.d.ts +8 -0
- package/dist/helpers.js +68 -104
- package/dist/hotReload.js +46 -85
- package/dist/index.js +140 -167
- package/dist/loaders.js +110 -31
- package/dist/{client → react}/BuildingPage.js +3 -6
- package/dist/{client → react}/DefaultNotFound.js +9 -12
- package/dist/{client → react}/DevIndicator.js +10 -13
- package/dist/{client → react}/ErrorModal.js +18 -21
- package/dist/react/Link.js +10 -0
- package/dist/{client → react}/client.d.ts +3 -3
- package/dist/react/client.js +23 -0
- package/dist/{client → react}/entry.client.js +30 -68
- package/dist/{client → react}/image/Image.js +3 -5
- package/dist/react/renderer-react.d.ts +15 -0
- package/dist/react/renderer-react.js +343 -0
- package/dist/renderer.d.ts +1 -2
- package/dist/renderer.js +8 -351
- package/dist/router.d.ts +1 -1
- package/dist/router.js +77 -90
- package/dist/rpc/annotations.js +3 -7
- package/dist/rpc/server.js +15 -21
- package/dist/rpc/types.js +1 -4
- package/dist/types/framework.js +1 -2
- package/dist/types.d.ts +1 -2
- package/dist/types.js +1 -2
- package/dist/vue/App.vue +183 -0
- package/dist/vue/BuildingPage.vue +256 -0
- package/dist/vue/DefaultNotFound.vue +307 -0
- package/dist/vue/DevIndicator.vue +210 -0
- package/dist/vue/ErrorModal.vue +319 -0
- package/dist/vue/Link.vue +22 -0
- package/dist/vue/client.d.ts +7 -0
- package/dist/vue/client.js +24 -0
- package/dist/vue/entry.client.d.ts +6 -0
- package/dist/vue/entry.client.js +94 -0
- package/dist/vue/image/Image.vue +101 -0
- package/dist/vue/renderer.vue.d.ts +15 -0
- package/dist/vue/renderer.vue.js +452 -0
- package/package.json +30 -7
- package/dist/client/client.js +0 -34
- package/dist/components/Link.js +0 -13
- /package/dist/{client → react}/BuildingPage.d.ts +0 -0
- /package/dist/{client → react}/DefaultNotFound.d.ts +0 -0
- /package/dist/{client → react}/DevIndicator.d.ts +0 -0
- /package/dist/{client → react}/ErrorModal.d.ts +0 -0
- /package/dist/{components → react}/Link.d.ts +0 -0
- /package/dist/{client → react}/entry.client.d.ts +0 -0
- /package/dist/{client → react}/image/Image.d.ts +0 -0
package/dist/adapters/express.js
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ExpressAdapter = void 0;
|
|
4
|
-
class ExpressAdapter {
|
|
5
|
-
constructor() {
|
|
6
|
-
this.type = 'express';
|
|
7
|
-
}
|
|
1
|
+
export class ExpressAdapter {
|
|
2
|
+
type = 'express';
|
|
8
3
|
parseRequest(req) {
|
|
9
4
|
return {
|
|
10
5
|
method: req.method,
|
|
@@ -21,8 +16,8 @@ class ExpressAdapter {
|
|
|
21
16
|
return new ExpressResponseWrapper(res);
|
|
22
17
|
}
|
|
23
18
|
}
|
|
24
|
-
exports.ExpressAdapter = ExpressAdapter;
|
|
25
19
|
class ExpressResponseWrapper {
|
|
20
|
+
res;
|
|
26
21
|
constructor(res) {
|
|
27
22
|
this.res = res;
|
|
28
23
|
}
|
package/dist/adapters/factory.js
CHANGED
|
@@ -1,47 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.FrameworkAdapterFactory = void 0;
|
|
37
|
-
const express_1 = require("./express");
|
|
38
|
-
const fastify_1 = require("./fastify");
|
|
39
|
-
const native_1 = require("./native");
|
|
40
|
-
const console_1 = __importStar(require("../api/console"));
|
|
1
|
+
import { ExpressAdapter } from './express';
|
|
2
|
+
import { FastifyAdapter } from './fastify';
|
|
3
|
+
import { NativeAdapter } from './native';
|
|
4
|
+
import Console, { Colors } from "../api/console";
|
|
41
5
|
/**
|
|
42
6
|
* Factory para criar o adapter correto baseado no framework detectado
|
|
43
7
|
*/
|
|
44
|
-
class FrameworkAdapterFactory {
|
|
8
|
+
export class FrameworkAdapterFactory {
|
|
9
|
+
static adapter = null;
|
|
45
10
|
/**
|
|
46
11
|
* Detecta automaticamente o framework baseado na requisição/resposta
|
|
47
12
|
*/
|
|
@@ -50,40 +15,40 @@ class FrameworkAdapterFactory {
|
|
|
50
15
|
if (this.adapter) {
|
|
51
16
|
return this.adapter;
|
|
52
17
|
}
|
|
53
|
-
const msg =
|
|
18
|
+
const msg = Console.dynamicLine(` ${Colors.FgYellow}● ${Colors.Reset}Detecting web framework...`);
|
|
54
19
|
// Detecta Express
|
|
55
20
|
if (req.app && req.route && res.locals !== undefined) {
|
|
56
|
-
msg.end(` ${
|
|
57
|
-
this.adapter = new
|
|
21
|
+
msg.end(` ${Colors.FgGreen}● ${Colors.Reset}Framework detected: Express`);
|
|
22
|
+
this.adapter = new ExpressAdapter();
|
|
58
23
|
return this.adapter;
|
|
59
24
|
}
|
|
60
25
|
// Detecta Fastify
|
|
61
26
|
if (req.server && req.routerPath !== undefined && res.request) {
|
|
62
|
-
msg.end(` ${
|
|
63
|
-
this.adapter = new
|
|
27
|
+
msg.end(` ${Colors.FgGreen}● ${Colors.Reset}Framework detected: Fastify`);
|
|
28
|
+
this.adapter = new FastifyAdapter();
|
|
64
29
|
return this.adapter;
|
|
65
30
|
}
|
|
66
31
|
// Detecta HTTP nativo do Node.js
|
|
67
32
|
if (req.method !== undefined && req.url !== undefined && req.headers !== undefined &&
|
|
68
33
|
res.statusCode !== undefined && res.setHeader !== undefined && res.end !== undefined) {
|
|
69
|
-
msg.end(` ${
|
|
70
|
-
this.adapter = new
|
|
34
|
+
msg.end(` ${Colors.FgGreen}● ${Colors.Reset}Framework detected: Vatts.js Native (HTTP)`);
|
|
35
|
+
this.adapter = new NativeAdapter();
|
|
71
36
|
return this.adapter;
|
|
72
37
|
}
|
|
73
38
|
// Fallback mais específico para Express
|
|
74
39
|
if (res.status && res.send && res.json && res.cookie) {
|
|
75
|
-
msg.end(` ${
|
|
76
|
-
this.adapter = new
|
|
40
|
+
msg.end(` ${Colors.FgGreen}● ${Colors.Reset}Framework detected: Express (fallback)`);
|
|
41
|
+
this.adapter = new ExpressAdapter();
|
|
77
42
|
return this.adapter;
|
|
78
43
|
}
|
|
79
44
|
// Fallback mais específico para Fastify
|
|
80
45
|
if (res.code && res.send && res.type && res.setCookie) {
|
|
81
|
-
msg.end(` ${
|
|
82
|
-
this.adapter = new
|
|
46
|
+
msg.end(` ${Colors.FgGreen}● ${Colors.Reset}Framework detected: Fastify (fallback)`);
|
|
47
|
+
this.adapter = new FastifyAdapter();
|
|
83
48
|
return this.adapter;
|
|
84
49
|
}
|
|
85
|
-
msg.end(` ${
|
|
86
|
-
this.adapter = new
|
|
50
|
+
msg.end(` ${Colors.FgYellow}● ${Colors.Reset}Unable to detect framework. Using Vatts.js Native as default.`);
|
|
51
|
+
this.adapter = new NativeAdapter();
|
|
87
52
|
return this.adapter;
|
|
88
53
|
}
|
|
89
54
|
/**
|
|
@@ -92,13 +57,13 @@ class FrameworkAdapterFactory {
|
|
|
92
57
|
static setFramework(framework) {
|
|
93
58
|
switch (framework) {
|
|
94
59
|
case 'express':
|
|
95
|
-
this.adapter = new
|
|
60
|
+
this.adapter = new ExpressAdapter();
|
|
96
61
|
break;
|
|
97
62
|
case 'fastify':
|
|
98
|
-
this.adapter = new
|
|
63
|
+
this.adapter = new FastifyAdapter();
|
|
99
64
|
break;
|
|
100
65
|
case 'native':
|
|
101
|
-
this.adapter = new
|
|
66
|
+
this.adapter = new NativeAdapter();
|
|
102
67
|
break;
|
|
103
68
|
default:
|
|
104
69
|
throw new Error(`Unsupported framework: ${framework}`);
|
|
@@ -117,5 +82,3 @@ class FrameworkAdapterFactory {
|
|
|
117
82
|
return this.adapter;
|
|
118
83
|
}
|
|
119
84
|
}
|
|
120
|
-
exports.FrameworkAdapterFactory = FrameworkAdapterFactory;
|
|
121
|
-
FrameworkAdapterFactory.adapter = null;
|
package/dist/adapters/fastify.js
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.FastifyAdapter = void 0;
|
|
4
|
-
class FastifyAdapter {
|
|
5
|
-
constructor() {
|
|
6
|
-
this.type = 'fastify';
|
|
7
|
-
}
|
|
1
|
+
export class FastifyAdapter {
|
|
2
|
+
type = 'fastify';
|
|
8
3
|
parseRequest(req) {
|
|
9
4
|
return {
|
|
10
5
|
method: req.method,
|
|
@@ -21,8 +16,8 @@ class FastifyAdapter {
|
|
|
21
16
|
return new FastifyResponseWrapper(reply);
|
|
22
17
|
}
|
|
23
18
|
}
|
|
24
|
-
exports.FastifyAdapter = FastifyAdapter;
|
|
25
19
|
class FastifyResponseWrapper {
|
|
20
|
+
reply;
|
|
26
21
|
constructor(reply) {
|
|
27
22
|
this.reply = reply;
|
|
28
23
|
}
|
package/dist/adapters/native.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NativeAdapter = void 0;
|
|
4
1
|
// --- Funções Auxiliares de Segurança ---
|
|
5
2
|
/**
|
|
6
3
|
* Remove caracteres de quebra de linha (\r, \n) de uma string para prevenir
|
|
@@ -23,10 +20,8 @@ function isValidCookieName(name) {
|
|
|
23
20
|
const validCookieNameRegex = /^[a-zA-Z0-9!#$%&'*+-.^_`|~]+$/;
|
|
24
21
|
return validCookieNameRegex.test(name);
|
|
25
22
|
}
|
|
26
|
-
class NativeAdapter {
|
|
27
|
-
|
|
28
|
-
this.type = 'native';
|
|
29
|
-
}
|
|
23
|
+
export class NativeAdapter {
|
|
24
|
+
type = 'native';
|
|
30
25
|
parseRequest(req) {
|
|
31
26
|
// URL absoluta é obrigatória para a API WHATWG
|
|
32
27
|
const fullUrl = new URL(req.url || '/', `http://${req.headers.host || 'localhost'}`);
|
|
@@ -68,14 +63,14 @@ class NativeAdapter {
|
|
|
68
63
|
return cookies;
|
|
69
64
|
}
|
|
70
65
|
}
|
|
71
|
-
exports.NativeAdapter = NativeAdapter;
|
|
72
66
|
class NativeResponseWrapper {
|
|
67
|
+
res;
|
|
68
|
+
statusCode = 200;
|
|
69
|
+
headers = {};
|
|
70
|
+
cookiesToSet = []; // Array para lidar corretamente com múltiplos cookies.
|
|
71
|
+
finished = false;
|
|
73
72
|
constructor(res) {
|
|
74
73
|
this.res = res;
|
|
75
|
-
this.statusCode = 200;
|
|
76
|
-
this.headers = {};
|
|
77
|
-
this.cookiesToSet = []; // Array para lidar corretamente com múltiplos cookies.
|
|
78
|
-
this.finished = false;
|
|
79
74
|
}
|
|
80
75
|
get raw() {
|
|
81
76
|
return this.res;
|
package/dist/api/console.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/*
|
|
3
2
|
* This file is part of the Vatts.js Project.
|
|
4
3
|
* Copyright (c) 2026 itsmuzin
|
|
@@ -15,21 +14,16 @@
|
|
|
15
14
|
* See the License for the specific language governing permissions and
|
|
16
15
|
* limitations under the License.
|
|
17
16
|
*/
|
|
18
|
-
|
|
19
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
20
|
-
};
|
|
21
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.Levels = exports.Colors = exports.DynamicLine = void 0;
|
|
23
|
-
const node_readline_1 = __importDefault(require("node:readline"));
|
|
17
|
+
import readline from 'node:readline';
|
|
24
18
|
/**
|
|
25
19
|
* Um "handle" para uma linha dinâmica. As instâncias desta classe
|
|
26
20
|
* são retornadas por `Console.dynamicLine()` e usadas para controlar
|
|
27
21
|
* o conteúdo da linha.
|
|
28
22
|
*/
|
|
29
|
-
class DynamicLine {
|
|
23
|
+
export class DynamicLine {
|
|
24
|
+
// A ID é usada internamente pela classe Console para rastrear esta linha.
|
|
25
|
+
_id = Symbol();
|
|
30
26
|
constructor(initialContent) {
|
|
31
|
-
// A ID é usada internamente pela classe Console para rastrear esta linha.
|
|
32
|
-
this._id = Symbol();
|
|
33
27
|
// Registra esta nova linha na classe Console para que ela seja renderizada.
|
|
34
28
|
Console['registerDynamicLine'](this._id, initialContent);
|
|
35
29
|
}
|
|
@@ -48,8 +42,7 @@ class DynamicLine {
|
|
|
48
42
|
Console['endDynamicLine'](this._id, finalContent);
|
|
49
43
|
}
|
|
50
44
|
}
|
|
51
|
-
|
|
52
|
-
var Colors;
|
|
45
|
+
export var Colors;
|
|
53
46
|
(function (Colors) {
|
|
54
47
|
Colors["Reset"] = "\u001B[0m";
|
|
55
48
|
Colors["Bright"] = "\u001B[1m";
|
|
@@ -77,29 +70,33 @@ var Colors;
|
|
|
77
70
|
Colors["BgCyan"] = "\u001B[46m";
|
|
78
71
|
Colors["BgWhite"] = "\u001B[47m";
|
|
79
72
|
Colors["BgGray"] = "\u001B[100m";
|
|
80
|
-
})(Colors || (
|
|
81
|
-
var Levels;
|
|
73
|
+
})(Colors || (Colors = {}));
|
|
74
|
+
export var Levels;
|
|
82
75
|
(function (Levels) {
|
|
83
76
|
Levels["ERROR"] = "ERROR";
|
|
84
77
|
Levels["WARN"] = "WARN";
|
|
85
78
|
Levels["INFO"] = "INFO";
|
|
86
79
|
Levels["DEBUG"] = "DEBUG";
|
|
87
80
|
Levels["SUCCESS"] = "SUCCESS";
|
|
88
|
-
})(Levels || (
|
|
89
|
-
class Console {
|
|
81
|
+
})(Levels || (Levels = {}));
|
|
82
|
+
export default class Console {
|
|
83
|
+
// Armazena o estado de todas as linhas dinâmicas ativas
|
|
84
|
+
static activeLines = [];
|
|
85
|
+
// Quantas linhas foram efetivamente renderizadas na última operação.
|
|
86
|
+
static lastRenderedLines = 0;
|
|
90
87
|
// --- MÉTODOS PRIVADOS PARA GERENCIAR A RENDERIZAÇÃO ---
|
|
91
88
|
static redrawDynamicLines() {
|
|
92
89
|
const stream = process.stdout;
|
|
93
90
|
if (this.lastRenderedLines > 0) {
|
|
94
91
|
try {
|
|
95
|
-
|
|
92
|
+
readline.moveCursor(stream, 0, -this.lastRenderedLines);
|
|
96
93
|
}
|
|
97
94
|
catch (_e) {
|
|
98
95
|
// Em terminais estranhos a movimentação pode falhar — ignoramos.
|
|
99
96
|
}
|
|
100
97
|
}
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
readline.cursorTo(stream, 0);
|
|
99
|
+
readline.clearScreenDown(stream);
|
|
103
100
|
if (this.activeLines.length > 0) {
|
|
104
101
|
// ATUALIZADO: Aplica o formato de log (Timestamp + Style) nas linhas dinâmicas
|
|
105
102
|
// Usamos um nível pseudo 'WAIT' para indicar processo em andamento
|
|
@@ -111,15 +108,17 @@ class Console {
|
|
|
111
108
|
const stream = process.stdout;
|
|
112
109
|
if (this.lastRenderedLines > 0) {
|
|
113
110
|
try {
|
|
114
|
-
|
|
111
|
+
readline.moveCursor(stream, 0, -this.lastRenderedLines);
|
|
115
112
|
}
|
|
116
113
|
catch (_e) { }
|
|
117
|
-
|
|
118
|
-
|
|
114
|
+
readline.cursorTo(stream, 0);
|
|
115
|
+
readline.clearScreenDown(stream);
|
|
119
116
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
stream.write
|
|
117
|
+
// MODIFICAÇÃO PRINCIPAL:
|
|
118
|
+
// Substituímos stream.write por console.log aqui.
|
|
119
|
+
// O console.log é interceptado pelos debuggers (VSCode, etc), o stream.write não.
|
|
120
|
+
// Removemos a quebra de linha final (\n$) pois o console.log já adiciona uma automaticamente.
|
|
121
|
+
console.log(content.replace(/\n$/, ''));
|
|
123
122
|
if (this.activeLines.length > 0) {
|
|
124
123
|
// ATUALIZADO: Garante que ao redesenhar após um log estático, o formato se mantém
|
|
125
124
|
stream.write(this.activeLines.map(l => this.formatLog('WAIT', l.content, Colors.FgRed)).join('\n') + '\n');
|
|
@@ -239,13 +238,13 @@ class Console {
|
|
|
239
238
|
const stream = process.stdout;
|
|
240
239
|
if (this.lastRenderedLines > 0) {
|
|
241
240
|
try {
|
|
242
|
-
|
|
241
|
+
readline.moveCursor(stream, 0, -this.lastRenderedLines);
|
|
243
242
|
}
|
|
244
243
|
catch (_e) { }
|
|
245
|
-
|
|
246
|
-
|
|
244
|
+
readline.cursorTo(stream, 0);
|
|
245
|
+
readline.clearScreenDown(stream);
|
|
247
246
|
}
|
|
248
|
-
const readlineInterface =
|
|
247
|
+
const readlineInterface = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
249
248
|
const defaultPart = defaultValue ? ` (${defaultValue})` : '';
|
|
250
249
|
const prompt = ` ${Colors.FgRed}?${Colors.Reset} ${question}${Colors.FgGray}${defaultPart}${Colors.Reset} \n ${Colors.FgRed}➜${Colors.Reset} `;
|
|
251
250
|
return new Promise(resolve => {
|
|
@@ -299,8 +298,3 @@ class Console {
|
|
|
299
298
|
return new DynamicLine(initialContent);
|
|
300
299
|
}
|
|
301
300
|
}
|
|
302
|
-
// Armazena o estado de todas as linhas dinâmicas ativas
|
|
303
|
-
Console.activeLines = [];
|
|
304
|
-
// Quantas linhas foram efetivamente renderizadas na última operação.
|
|
305
|
-
Console.lastRenderedLines = 0;
|
|
306
|
-
exports.default = Console;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
// Variável para armazenar o resultado em memória
|
|
4
|
+
export let cachedFramework = null;
|
|
5
|
+
export default function detectFramework(projectDir = process.cwd()) {
|
|
6
|
+
// Se já tivermos um resultado, retorna ele direto sem ler o disco
|
|
7
|
+
if (cachedFramework)
|
|
8
|
+
return cachedFramework;
|
|
9
|
+
try {
|
|
10
|
+
const pkgPath = path.join(projectDir, 'package.json');
|
|
11
|
+
if (fs.existsSync(pkgPath)) {
|
|
12
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
|
|
13
|
+
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
14
|
+
if (deps.react || deps['react-dom']) {
|
|
15
|
+
cachedFramework = 'react';
|
|
16
|
+
return cachedFramework;
|
|
17
|
+
}
|
|
18
|
+
if (deps.vue || deps['nuxt']) {
|
|
19
|
+
cachedFramework = 'vue';
|
|
20
|
+
return cachedFramework;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
// Ignora erro de leitura
|
|
26
|
+
}
|
|
27
|
+
// Salva o fallback no cache para evitar re-execução em caso de falha
|
|
28
|
+
cachedFramework = 'react';
|
|
29
|
+
return cachedFramework;
|
|
30
|
+
}
|
package/dist/api/http.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VattsResponse = exports.VattsRequest = void 0;
|
|
4
1
|
// Input validation and sanitization utilities
|
|
5
2
|
class SecurityUtils {
|
|
3
|
+
static MAX_HEADER_LENGTH = 8192;
|
|
4
|
+
static MAX_COOKIE_LENGTH = 4096;
|
|
5
|
+
static MAX_URL_LENGTH = 2048;
|
|
6
|
+
static MAX_BODY_SIZE = 10 * 1024 * 1024; // 10MB
|
|
6
7
|
static sanitizeHeader(value) {
|
|
7
8
|
if (Array.isArray(value)) {
|
|
8
9
|
return value.map(v => this.sanitizeString(v, this.MAX_HEADER_LENGTH));
|
|
@@ -34,15 +35,13 @@ class SecurityUtils {
|
|
|
34
35
|
return length >= 0 && length <= this.MAX_BODY_SIZE;
|
|
35
36
|
}
|
|
36
37
|
}
|
|
37
|
-
SecurityUtils.MAX_HEADER_LENGTH = 8192;
|
|
38
|
-
SecurityUtils.MAX_COOKIE_LENGTH = 4096;
|
|
39
|
-
SecurityUtils.MAX_URL_LENGTH = 2048;
|
|
40
|
-
SecurityUtils.MAX_BODY_SIZE = 10 * 1024 * 1024; // 10MB
|
|
41
38
|
/**
|
|
42
39
|
* Abstração sobre a requisição HTTP de entrada.
|
|
43
40
|
* Funciona com qualquer framework web (Express, Fastify, etc.)
|
|
44
41
|
*/
|
|
45
|
-
class VattsRequest {
|
|
42
|
+
export class VattsRequest {
|
|
43
|
+
/** A requisição genérica parseada pelo adapter */
|
|
44
|
+
_req;
|
|
46
45
|
constructor(req) {
|
|
47
46
|
// Validate and sanitize request data
|
|
48
47
|
this._req = this.validateAndSanitizeRequest(req);
|
|
@@ -247,19 +246,16 @@ class VattsRequest {
|
|
|
247
246
|
return Array.isArray(ua) ? ua[0] : ua;
|
|
248
247
|
}
|
|
249
248
|
}
|
|
250
|
-
exports.VattsRequest = VattsRequest;
|
|
251
249
|
/**
|
|
252
250
|
* Abstração para construir a resposta HTTP.
|
|
253
251
|
* Funciona com qualquer framework web (Express, Fastify, etc.)
|
|
254
252
|
*/
|
|
255
|
-
class VattsResponse {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
this._sent = false;
|
|
262
|
-
}
|
|
253
|
+
export class VattsResponse {
|
|
254
|
+
_status = 200;
|
|
255
|
+
_headers = {};
|
|
256
|
+
_cookies = [];
|
|
257
|
+
_body = null;
|
|
258
|
+
_sent = false;
|
|
263
259
|
/**
|
|
264
260
|
* Define o status HTTP da resposta
|
|
265
261
|
*/
|
|
@@ -466,4 +462,3 @@ class VattsResponse {
|
|
|
466
462
|
return VattsResponse.text(message, { status: 403 });
|
|
467
463
|
}
|
|
468
464
|
}
|
|
469
|
-
exports.VattsResponse = VattsResponse;
|