vatts 1.4.1-test.1 → 1.4.1-test.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/api/http3.d.ts +35 -14
- package/dist/api/http3.js +97 -45
- package/dist/builder.js +12 -5
- package/dist/core-go/core-linux-arm64.node +0 -0
- package/dist/core-go/core-linux-x64.node +0 -0
- package/dist/core-go/core-win-x64.node +0 -0
- package/dist/core-go/dev-linux-arm64.node +0 -0
- package/dist/core-go/dev-linux-x64.node +0 -0
- package/dist/core-go/dev-win-x64.node +0 -0
- package/dist/helpers.js +48 -2
- package/dist/index.js +2 -2
- package/dist/react/react.build.js +6 -1
- package/dist/react/renderer-react.js +6 -6
- package/dist/vue/renderer.vue.js +5 -5
- package/package.json +1 -1
package/dist/api/http3.d.ts
CHANGED
|
@@ -12,30 +12,51 @@ export interface ProxyOptions {
|
|
|
12
12
|
certPath: string;
|
|
13
13
|
/** Caminho para o arquivo de chave privada SSL (.pem) */
|
|
14
14
|
keyPath: string;
|
|
15
|
+
/** Habilita suporte a WebTransport */
|
|
16
|
+
enableWebTransport?: boolean;
|
|
15
17
|
/** (Opcional) Sobrescreve o caminho da biblioteca manualmente */
|
|
16
18
|
customLibPath?: string;
|
|
17
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Interface para os callbacks do WebTransport.
|
|
22
|
+
* Use isso para tipar o handler ao chamar addTransport.
|
|
23
|
+
*/
|
|
24
|
+
export interface WebTransportCallbacks {
|
|
25
|
+
/** Chamado quando um cliente conecta na rota */
|
|
26
|
+
onConnect?: (client: WebTransportClient) => void;
|
|
27
|
+
/** Chamado quando uma mensagem é recebida do cliente */
|
|
28
|
+
onMessage: (client: WebTransportClient, msg: string) => void;
|
|
29
|
+
/** Chamado quando a conexão é fechada */
|
|
30
|
+
onClose?: (client: WebTransportClient) => void;
|
|
31
|
+
}
|
|
32
|
+
export declare class WebTransportClient {
|
|
33
|
+
readonly id: string;
|
|
34
|
+
private sendFunc;
|
|
35
|
+
private closeFunc;
|
|
36
|
+
constructor(id: string, sendFunc: Function, closeFunc: Function);
|
|
37
|
+
send(data: string): void;
|
|
38
|
+
close(): void;
|
|
39
|
+
}
|
|
18
40
|
export declare class NativeProxy {
|
|
19
|
-
private static
|
|
41
|
+
private static instanceStart;
|
|
42
|
+
private static instanceSend;
|
|
43
|
+
private static instanceClose;
|
|
44
|
+
private static transportRoutes;
|
|
45
|
+
private static activeClients;
|
|
20
46
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
47
|
+
* Registra uma rota WebTransport.
|
|
48
|
+
* @param route Caminho da rota (ex: "/chat")
|
|
49
|
+
* @param handler Objeto com callbacks
|
|
24
50
|
*/
|
|
25
|
-
static
|
|
51
|
+
static addTransportRoute(route: string, handler: WebTransportCallbacks): void;
|
|
26
52
|
/**
|
|
27
|
-
*
|
|
53
|
+
* Detecta a plataforma e arquitetura para montar o nome do arquivo.
|
|
28
54
|
*/
|
|
55
|
+
static getLibPath(): string;
|
|
29
56
|
private static loadLibrary;
|
|
30
|
-
|
|
31
|
-
* Inicia o servidor Proxy.
|
|
32
|
-
* Nota: A execução no Go é assíncrona (non-blocking), então esta função retorna
|
|
33
|
-
* imediatamente após iniciar as threads do servidor, a menos que haja um erro inicial.
|
|
34
|
-
*/
|
|
57
|
+
private static handleGoCallback;
|
|
35
58
|
static start(options: ProxyOptions): void;
|
|
36
59
|
}
|
|
37
|
-
/**
|
|
38
|
-
* API Pública
|
|
39
|
-
*/
|
|
40
60
|
export declare const startProxy: (options: ProxyOptions) => void;
|
|
61
|
+
export declare const addTransport: (route: string, handler: WebTransportCallbacks) => void;
|
|
41
62
|
export default startProxy;
|
package/dist/api/http3.js
CHANGED
|
@@ -3,24 +3,55 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.startProxy = exports.NativeProxy = void 0;
|
|
6
|
+
exports.addTransport = exports.startProxy = exports.NativeProxy = exports.WebTransportClient = void 0;
|
|
7
7
|
const koffi_1 = __importDefault(require("koffi"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const fs_1 = __importDefault(require("fs"));
|
|
10
10
|
const os_1 = __importDefault(require("os"));
|
|
11
|
+
// Wrapper para interagir com o cliente conectado via Go
|
|
12
|
+
class WebTransportClient {
|
|
13
|
+
id;
|
|
14
|
+
sendFunc;
|
|
15
|
+
closeFunc;
|
|
16
|
+
constructor(id, sendFunc, closeFunc) {
|
|
17
|
+
this.id = id;
|
|
18
|
+
this.sendFunc = sendFunc;
|
|
19
|
+
this.closeFunc = closeFunc;
|
|
20
|
+
}
|
|
21
|
+
// Envia dados para o cliente (Vue)
|
|
22
|
+
send(data) {
|
|
23
|
+
this.sendFunc(this.id, data);
|
|
24
|
+
}
|
|
25
|
+
// Força o fechamento da conexão
|
|
26
|
+
close() {
|
|
27
|
+
this.closeFunc(this.id);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.WebTransportClient = WebTransportClient;
|
|
11
31
|
class NativeProxy {
|
|
12
|
-
static
|
|
32
|
+
static instanceStart = null;
|
|
33
|
+
static instanceSend = null;
|
|
34
|
+
static instanceClose = null;
|
|
35
|
+
// Mapa de rotas -> callbacks
|
|
36
|
+
static transportRoutes = new Map();
|
|
37
|
+
// Cache de clientes ativos para evitar recriar o objeto a cada mensagem
|
|
38
|
+
static activeClients = new Map();
|
|
39
|
+
/**
|
|
40
|
+
* Registra uma rota WebTransport.
|
|
41
|
+
* @param route Caminho da rota (ex: "/chat")
|
|
42
|
+
* @param handler Objeto com callbacks
|
|
43
|
+
*/
|
|
44
|
+
static addTransportRoute(route, handler) {
|
|
45
|
+
this.transportRoutes.set(route, handler);
|
|
46
|
+
}
|
|
13
47
|
/**
|
|
14
48
|
* Detecta a plataforma e arquitetura para montar o nome do arquivo.
|
|
15
|
-
* Padrão esperado: vatts-proxy-{os}-{arch}.node
|
|
16
|
-
* Ex: vatts-proxy-win-x64.node
|
|
17
49
|
*/
|
|
18
50
|
static getLibPath() {
|
|
19
51
|
const platform = os_1.default.platform();
|
|
20
52
|
const arch = os_1.default.arch();
|
|
21
53
|
let osName = '';
|
|
22
|
-
let ext = '.node';
|
|
23
|
-
// Mapeamento de SO
|
|
54
|
+
let ext = '.node';
|
|
24
55
|
switch (platform) {
|
|
25
56
|
case 'win32':
|
|
26
57
|
osName = 'win';
|
|
@@ -31,10 +62,8 @@ class NativeProxy {
|
|
|
31
62
|
case 'darwin':
|
|
32
63
|
osName = 'darwin';
|
|
33
64
|
break;
|
|
34
|
-
default:
|
|
35
|
-
throw new Error(`Sistema operacional não suportado: ${platform}`);
|
|
65
|
+
default: throw new Error(`Sistema operacional não suportado: ${platform}`);
|
|
36
66
|
}
|
|
37
|
-
// Mapeamento de Arquitetura
|
|
38
67
|
let archName = '';
|
|
39
68
|
switch (arch) {
|
|
40
69
|
case 'x64':
|
|
@@ -43,68 +72,91 @@ class NativeProxy {
|
|
|
43
72
|
case 'arm64':
|
|
44
73
|
archName = 'arm64';
|
|
45
74
|
break;
|
|
46
|
-
default:
|
|
47
|
-
throw new Error(`Arquitetura não suportada: ${arch}`);
|
|
75
|
+
default: throw new Error(`Arquitetura não suportada: ${arch}`);
|
|
48
76
|
}
|
|
49
77
|
const filename = `core-${osName}-${archName}${ext}`;
|
|
50
|
-
// Ajuste o caminho relativo conforme a estrutura do seu projeto
|
|
51
|
-
// Assumindo que estará na pasta '../proxy' relativo a este arquivo
|
|
52
78
|
return path_1.default.resolve(__dirname, '..', 'core-go', filename);
|
|
53
79
|
}
|
|
54
|
-
/**
|
|
55
|
-
* Carrega a biblioteca nativa usando Koffi.
|
|
56
|
-
*/
|
|
57
80
|
static loadLibrary(customPath) {
|
|
58
|
-
if (this.
|
|
59
|
-
return
|
|
81
|
+
if (this.instanceStart)
|
|
82
|
+
return;
|
|
60
83
|
const libPath = customPath || this.getLibPath();
|
|
61
84
|
if (!fs_1.default.existsSync(libPath)) {
|
|
62
85
|
throw new Error(`Biblioteca nativa não encontrada: ${libPath}.\n`);
|
|
63
86
|
}
|
|
64
87
|
try {
|
|
65
88
|
const lib = koffi_1.default.load(libPath);
|
|
66
|
-
//
|
|
67
|
-
|
|
68
|
-
//
|
|
69
|
-
this.
|
|
70
|
-
|
|
89
|
+
// 1. Define o callback do C (Go chama isso)
|
|
90
|
+
const OnWebTransportMessage = koffi_1.default.proto('void OnWebTransportMessage(str id, str path, str event, str data)');
|
|
91
|
+
// 2. Mapeia as funções do Go
|
|
92
|
+
this.instanceStart = lib.func('StartServer', 'str', ['str', 'str', 'str', 'str', 'str', 'str']);
|
|
93
|
+
this.instanceSend = lib.func('WebTransportSend', 'void', ['str', 'str']);
|
|
94
|
+
this.instanceClose = lib.func('WebTransportClose', 'void', ['str']);
|
|
95
|
+
const registerCallback = lib.func('RegisterWebTransportCallback', 'void', [koffi_1.default.pointer(OnWebTransportMessage)]);
|
|
96
|
+
// 3. Registra a função JS que o Go vai chamar
|
|
97
|
+
const jsCallback = (id, path, event, data) => {
|
|
98
|
+
this.handleGoCallback(id, path, event, data);
|
|
99
|
+
};
|
|
100
|
+
registerCallback(jsCallback);
|
|
71
101
|
}
|
|
72
102
|
catch (error) {
|
|
73
|
-
throw new Error(`Falha ao carregar a biblioteca nativa
|
|
103
|
+
throw new Error(`Falha ao carregar a biblioteca nativa: ${error}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
static handleGoCallback(id, path, event, data) {
|
|
107
|
+
const routeHandler = this.transportRoutes.get(path);
|
|
108
|
+
// Se não tiver rota registrada, o Go vai manter a conexão aberta mas sem lógica,
|
|
109
|
+
// ou podemos fechar. Por enquanto, ignoramos.
|
|
110
|
+
if (!routeHandler)
|
|
111
|
+
return;
|
|
112
|
+
let client = this.activeClients.get(id);
|
|
113
|
+
if (!client) {
|
|
114
|
+
client = new WebTransportClient(id, this.instanceSend, this.instanceClose);
|
|
115
|
+
this.activeClients.set(id, client);
|
|
116
|
+
}
|
|
117
|
+
try {
|
|
118
|
+
if (event === 'CONNECT') {
|
|
119
|
+
if (routeHandler.onConnect)
|
|
120
|
+
routeHandler.onConnect(client);
|
|
121
|
+
}
|
|
122
|
+
else if (event === 'MESSAGE') {
|
|
123
|
+
if (routeHandler.onMessage)
|
|
124
|
+
routeHandler.onMessage(client, data);
|
|
125
|
+
}
|
|
126
|
+
else if (event === 'CLOSE') {
|
|
127
|
+
if (routeHandler.onClose)
|
|
128
|
+
routeHandler.onClose(client);
|
|
129
|
+
this.activeClients.delete(id);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
catch (e) {
|
|
133
|
+
console.error(`[Vatts WebTransport Error] Handler failed for ${path}:`, e);
|
|
74
134
|
}
|
|
75
135
|
}
|
|
76
|
-
/**
|
|
77
|
-
* Inicia o servidor Proxy.
|
|
78
|
-
* Nota: A execução no Go é assíncrona (non-blocking), então esta função retorna
|
|
79
|
-
* imediatamente após iniciar as threads do servidor, a menos que haja um erro inicial.
|
|
80
|
-
*/
|
|
81
136
|
static start(options) {
|
|
82
|
-
const { httpPort, httpsPort, backendUrl, certPath, keyPath, customLibPath } = options;
|
|
83
|
-
|
|
84
|
-
// Resolve caminhos absolutos para evitar erros no Go
|
|
137
|
+
const { httpPort, httpsPort, backendUrl, certPath, keyPath, customLibPath, enableWebTransport } = options;
|
|
138
|
+
this.loadLibrary(customLibPath);
|
|
85
139
|
const absCert = path_1.default.resolve(certPath);
|
|
86
140
|
const absKey = path_1.default.resolve(keyPath);
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
// Chama a função nativa
|
|
95
|
-
const errorMsg = startServer(httpPort, httpsPort, backendUrl, absCert, absKey);
|
|
141
|
+
if (!fs_1.default.existsSync(absCert))
|
|
142
|
+
throw new Error(`Certificado não encontrado: ${absCert}`);
|
|
143
|
+
if (!fs_1.default.existsSync(absKey))
|
|
144
|
+
throw new Error(`Chave não encontrada: ${absKey}`);
|
|
145
|
+
const strWebTransport = enableWebTransport ? "true" : "false";
|
|
146
|
+
// Chama StartServer no Go
|
|
147
|
+
const errorMsg = this.instanceStart(httpPort, httpsPort, backendUrl, absCert, absKey, strWebTransport);
|
|
96
148
|
if (errorMsg) {
|
|
97
149
|
throw new Error(`[Vatts Proxy Error] ${errorMsg}`);
|
|
98
150
|
}
|
|
99
151
|
}
|
|
100
152
|
}
|
|
101
153
|
exports.NativeProxy = NativeProxy;
|
|
102
|
-
/**
|
|
103
|
-
* API Pública
|
|
104
|
-
*/
|
|
105
154
|
const startProxy = (options) => {
|
|
106
155
|
return NativeProxy.start(options);
|
|
107
156
|
};
|
|
108
157
|
exports.startProxy = startProxy;
|
|
109
|
-
|
|
158
|
+
const addTransport = (route, handler) => {
|
|
159
|
+
return NativeProxy.addTransportRoute(route, handler);
|
|
160
|
+
};
|
|
161
|
+
exports.addTransport = addTransport;
|
|
110
162
|
exports.default = exports.startProxy;
|
package/dist/builder.js
CHANGED
|
@@ -263,7 +263,10 @@ function getOptimizationPlugins(isProduction) {
|
|
|
263
263
|
'process.env.NODE_ENV': JSON.stringify(env),
|
|
264
264
|
'process.env': JSON.stringify({ NODE_ENV: env }),
|
|
265
265
|
'process.browser': 'true',
|
|
266
|
-
|
|
266
|
+
// [FIX] Use bracket notation string replacement.
|
|
267
|
+
// This prevents SyntaxError "window.({ isDisabled: true })"
|
|
268
|
+
// and bypasses recursive replacements by downstream plugins.
|
|
269
|
+
'__REACT_DEVTOOLS_GLOBAL_HOOK__': 'window["__REACT_DEVTOOLS_GLOBAL_HOOK__"]',
|
|
267
270
|
preventAssignment: true,
|
|
268
271
|
objectGuards: true
|
|
269
272
|
}));
|
|
@@ -367,7 +370,8 @@ async function buildWithChunks(entryPoint, outdir, isProduction = false) {
|
|
|
367
370
|
if (replacePlugin)
|
|
368
371
|
inputOptions.plugins.unshift(replacePlugin);
|
|
369
372
|
inputOptions.plugins.push(...otherPlugins);
|
|
370
|
-
|
|
373
|
+
// [FIX] Injected polyfill for React DevTools Hook to prevent ReferenceError
|
|
374
|
+
const processPolyfill = `var process = { env: { NODE_ENV: "${isProduction ? 'production' : 'development'}" } }; try { if (typeof window !== 'undefined' && typeof window.__REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') { window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = { isDisabled: true }; } } catch(e) {}`;
|
|
371
375
|
const outputOptions = {
|
|
372
376
|
dir: outdir,
|
|
373
377
|
format: 'es',
|
|
@@ -496,7 +500,8 @@ async function build(entryPoint, outfile, isProduction = false) {
|
|
|
496
500
|
if (replacePlugin)
|
|
497
501
|
inputOptions.plugins.unshift(replacePlugin);
|
|
498
502
|
inputOptions.plugins.push(...otherPlugins);
|
|
499
|
-
|
|
503
|
+
// [FIX] Injected polyfill for React DevTools Hook
|
|
504
|
+
const processPolyfill = `var process = { env: { NODE_ENV: "${isProduction ? 'production' : 'development'}" } }; try { if (typeof window !== 'undefined' && typeof window.__REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') { window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = { isDisabled: true }; } } catch(e) {}`;
|
|
500
505
|
const outputOptions = {
|
|
501
506
|
file: outfile,
|
|
502
507
|
format: 'iife',
|
|
@@ -574,7 +579,8 @@ async function watchWithChunks(entryPoint, outdir, hotReloadManager = null) {
|
|
|
574
579
|
inputOptions.external = nodeBuiltIns;
|
|
575
580
|
const optimizationPlugins = getOptimizationPlugins(false);
|
|
576
581
|
inputOptions.plugins = [...inputOptions.plugins, ...optimizationPlugins];
|
|
577
|
-
|
|
582
|
+
// [FIX] Injected polyfill for React DevTools Hook
|
|
583
|
+
const processPolyfill = `var process = { env: { NODE_ENV: "development" } }; try { if (typeof window !== 'undefined' && typeof window.__REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') { window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = { isDisabled: true }; } } catch(e) {}`;
|
|
578
584
|
const outputOptions = {
|
|
579
585
|
dir: outdir,
|
|
580
586
|
format: 'es',
|
|
@@ -606,7 +612,8 @@ async function watch(entryPoint, outfile, hotReloadManager = null) {
|
|
|
606
612
|
inputOptions.external = nodeBuiltIns;
|
|
607
613
|
const optimizationPlugins = getOptimizationPlugins(false);
|
|
608
614
|
inputOptions.plugins = [...inputOptions.plugins, ...optimizationPlugins];
|
|
609
|
-
|
|
615
|
+
// [FIX] Injected polyfill for React DevTools Hook
|
|
616
|
+
const processPolyfill = `var process = { env: { NODE_ENV: "development" } }; try { if (typeof window !== 'undefined' && typeof window.__REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') { window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = { isDisabled: true }; } } catch(e) {}`;
|
|
610
617
|
const outputOptions = {
|
|
611
618
|
file: outfile,
|
|
612
619
|
format: 'es',
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/helpers.js
CHANGED
|
@@ -66,7 +66,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
66
66
|
const index_js_1 = __importStar(require("./index.js")); // Importando o tipo
|
|
67
67
|
const console_1 = __importStar(require("./api/console"));
|
|
68
68
|
const fs_1 = __importDefault(require("fs"));
|
|
69
|
-
const http3_1 =
|
|
69
|
+
const http3_1 = __importStar(require("./api/http3"));
|
|
70
70
|
// Registra loaders customizados para importar arquivos não-JS
|
|
71
71
|
const { registerLoaders } = require('./loaders');
|
|
72
72
|
registerLoaders({ projectDir: process.cwd() });
|
|
@@ -498,8 +498,54 @@ async function initNativeServer(vattsApp, options, hostname) {
|
|
|
498
498
|
httpsPort: `:${publicPort}`, // Porta Principal (UDP/TCP)
|
|
499
499
|
backendUrl: `http://127.0.0.1:${backendPort}`, // Para onde enviar o tráfego
|
|
500
500
|
certPath: exports.config?.ssl?.cert,
|
|
501
|
-
keyPath: exports.config?.ssl?.key
|
|
501
|
+
keyPath: exports.config?.ssl?.key,
|
|
502
|
+
enableWebTransport: true
|
|
502
503
|
});
|
|
504
|
+
// Lista de clientes conectados na sala
|
|
505
|
+
const connectedClients = new Set();
|
|
506
|
+
// Configura a rota do WebTransport
|
|
507
|
+
(0, http3_1.addTransport)('/chat', {
|
|
508
|
+
onConnect: (client) => {
|
|
509
|
+
console.log(`[Chat] Cliente conectado: ${client.id}`);
|
|
510
|
+
connectedClients.add(client);
|
|
511
|
+
// Avisa todo mundo que alguém entrou
|
|
512
|
+
broadcast(client.id, JSON.stringify({
|
|
513
|
+
type: 'system',
|
|
514
|
+
text: `Usuário ${client.id.substring(0, 4)} entrou na sala.`
|
|
515
|
+
}));
|
|
516
|
+
},
|
|
517
|
+
onMessage: (client, message) => {
|
|
518
|
+
try {
|
|
519
|
+
// O frontend manda JSON, a gente repassa pra geral
|
|
520
|
+
console.log(`[Chat] Msg de ${client.id}: ${message}`);
|
|
521
|
+
const payload = JSON.stringify({
|
|
522
|
+
type: 'user',
|
|
523
|
+
sender: client.id.substring(0, 4),
|
|
524
|
+
text: message
|
|
525
|
+
});
|
|
526
|
+
broadcast(null, payload); // Null = envia para todos
|
|
527
|
+
}
|
|
528
|
+
catch (e) {
|
|
529
|
+
console.error('Erro ao processar mensagem:', e);
|
|
530
|
+
}
|
|
531
|
+
},
|
|
532
|
+
onClose: (client) => {
|
|
533
|
+
console.log(`[Chat] Cliente desconectou: ${client.id}`);
|
|
534
|
+
connectedClients.delete(client);
|
|
535
|
+
broadcast(null, JSON.stringify({
|
|
536
|
+
type: 'system',
|
|
537
|
+
text: `Usuário ${client.id.substring(0, 4)} saiu.`
|
|
538
|
+
}));
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
// Função auxiliar para enviar mensagem para todos
|
|
542
|
+
function broadcast(senderId, msg) {
|
|
543
|
+
for (const client of connectedClients) {
|
|
544
|
+
// Opcional: Não enviar de volta para quem mandou (se quiser echo, remova o if)
|
|
545
|
+
// if (senderId && client.id === senderId) continue;
|
|
546
|
+
client.send(msg);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
503
549
|
// Atualiza o box de info para mostrar a porta pública correta
|
|
504
550
|
sendBox({ ...options });
|
|
505
551
|
msg.end(`${console_1.Colors.Bright}Ready on port ${console_1.Colors.BgGreen} ${publicPort} (HTTP/3 Enabled) ${console_1.Colors.Reset}\n` +
|
package/dist/index.js
CHANGED
|
@@ -534,7 +534,7 @@ function vatts(options) {
|
|
|
534
534
|
// Se o arquivo solicitado termina em .js e NÃO existe fisicamente (foi deletado pelo otimizador),
|
|
535
535
|
// tentamos encontrar a versão .js.gz
|
|
536
536
|
if (filePath && !fs_1.default.existsSync(filePath) && filePath.endsWith('.js')) {
|
|
537
|
-
const gzipPath = filePath + '.
|
|
537
|
+
const gzipPath = filePath + '.br';
|
|
538
538
|
if (fs_1.default.existsSync(gzipPath)) {
|
|
539
539
|
filePath = gzipPath;
|
|
540
540
|
isGzipped = true;
|
|
@@ -568,7 +568,7 @@ function vatts(options) {
|
|
|
568
568
|
}
|
|
569
569
|
// --- HEADER VITAL PARA GZIP ---
|
|
570
570
|
if (isGzipped) {
|
|
571
|
-
genericRes.header('Content-Encoding', '
|
|
571
|
+
genericRes.header('Content-Encoding', 'br');
|
|
572
572
|
}
|
|
573
573
|
const lastModified = stats.mtime.toUTCString();
|
|
574
574
|
genericRes.header('Last-Modified', lastModified);
|
|
@@ -33,6 +33,9 @@ async function createReactConfig(entryPoint, outdir, isProduction, { prePlugins
|
|
|
33
33
|
const replaceValues = {
|
|
34
34
|
'process.env.NODE_ENV': JSON.stringify(isProduction ? 'production' : 'development'),
|
|
35
35
|
'process.env.PORT': JSON.stringify(process.vatts?.port || 3000),
|
|
36
|
+
// [FIX] Define o hook do DevTools como um objeto vazio seguro caso não exista,
|
|
37
|
+
// evitando o ReferenceError em builds de produção ou ambientes restritos.
|
|
38
|
+
'__REACT_DEVTOOLS_GLOBAL_HOOK__': '({ isDisabled: true })',
|
|
36
39
|
preventAssignment: true
|
|
37
40
|
};
|
|
38
41
|
const extensions = ['.mjs', '.js', '.json', '.node', '.jsx', '.tsx', '.ts'];
|
|
@@ -86,7 +89,9 @@ async function createReactConfig(entryPoint, outdir, isProduction, { prePlugins
|
|
|
86
89
|
treeShaking: true,
|
|
87
90
|
target: 'esnext',
|
|
88
91
|
jsx: 'automatic',
|
|
89
|
-
define: {
|
|
92
|
+
define: {
|
|
93
|
+
__VERSION__: '"1.0.0"',
|
|
94
|
+
},
|
|
90
95
|
loaders: esbuildLoaders
|
|
91
96
|
})
|
|
92
97
|
],
|
|
@@ -171,9 +171,9 @@ function getBuildAssets(req) {
|
|
|
171
171
|
const fullPath = path_1.default.join(directory, file);
|
|
172
172
|
const stat = fs_1.default.statSync(fullPath);
|
|
173
173
|
if (stat.isFile()) {
|
|
174
|
-
// MODIFICADO: Aceita .js OU .js.
|
|
175
|
-
if (file.endsWith('.js') || file.endsWith('.js.
|
|
176
|
-
scripts.push(`${urlPrefix}/${file.replace(".
|
|
174
|
+
// MODIFICADO: Aceita .js OU .js.br
|
|
175
|
+
if (file.endsWith('.js') || file.endsWith('.js.br')) {
|
|
176
|
+
scripts.push(`${urlPrefix}/${file.replace(".br", '')}`);
|
|
177
177
|
}
|
|
178
178
|
else if (file.endsWith('.css')) {
|
|
179
179
|
styles.push(`${urlPrefix}/${file}`);
|
|
@@ -188,9 +188,9 @@ function getBuildAssets(req) {
|
|
|
188
188
|
const manifest = JSON.parse(fs_1.default.readFileSync(manifestPath, 'utf8'));
|
|
189
189
|
const manifestFiles = Object.values(manifest);
|
|
190
190
|
scripts = manifestFiles
|
|
191
|
-
// MODIFICADO: Filtra .js E .js.
|
|
192
|
-
.filter((f) => f.endsWith('.js') || f.endsWith('.js.
|
|
193
|
-
.map((f) => `/_vatts/${f.replace(".
|
|
191
|
+
// MODIFICADO: Filtra .js E .js.br no manifesto
|
|
192
|
+
.filter((f) => f.endsWith('.js') || f.endsWith('.js.br'))
|
|
193
|
+
.map((f) => `/_vatts/${f.replace(".br", "")}`);
|
|
194
194
|
styles = manifestFiles
|
|
195
195
|
.filter((f) => f.endsWith('.css'))
|
|
196
196
|
.map((f) => `/_vatts/${f}`);
|
package/dist/vue/renderer.vue.js
CHANGED
|
@@ -101,9 +101,9 @@ function extractComponentPreloads(componentPath) {
|
|
|
101
101
|
tags.add(`<link rel="preload" as="style" href="${publicUrl}">`);
|
|
102
102
|
tags.add(`<link rel="stylesheet" href="${publicUrl}">`);
|
|
103
103
|
}
|
|
104
|
-
else if (['.js', '.js.
|
|
104
|
+
else if (['.js', '.js.br'].includes(ext)) {
|
|
105
105
|
// Adicionado suporte para JS
|
|
106
|
-
tags.add(`<link rel="preload" as="script" href="${publicUrl.replace(".
|
|
106
|
+
tags.add(`<link rel="preload" as="script" href="${publicUrl.replace(".br", '')}">`);
|
|
107
107
|
}
|
|
108
108
|
else if (['.png', '.jpg', '.jpeg', '.gif', '.svg', '.webp', '.avif'].includes(ext)) {
|
|
109
109
|
tags.add(`<link rel="preload" as="image" href="${publicUrl}">`);
|
|
@@ -331,8 +331,8 @@ function getBuildAssets(req) {
|
|
|
331
331
|
return;
|
|
332
332
|
const fullPath = path_1.default.join(directory, file);
|
|
333
333
|
if (fs_1.default.statSync(fullPath).isFile()) {
|
|
334
|
-
if (file.endsWith('.js') || file.endsWith(".js.
|
|
335
|
-
scripts.push(`${urlPrefix}/${file.replace(".
|
|
334
|
+
if (file.endsWith('.js') || file.endsWith(".js.br"))
|
|
335
|
+
scripts.push(`${urlPrefix}/${file.replace(".br", '')}`);
|
|
336
336
|
else if (file.endsWith('.css'))
|
|
337
337
|
styles.push(`${urlPrefix}/${file}`);
|
|
338
338
|
}
|
|
@@ -343,7 +343,7 @@ function getBuildAssets(req) {
|
|
|
343
343
|
if (fs_1.default.existsSync(manifestPath)) {
|
|
344
344
|
const manifest = JSON.parse(fs_1.default.readFileSync(manifestPath, 'utf8'));
|
|
345
345
|
const manifestFiles = Object.values(manifest);
|
|
346
|
-
scripts = manifestFiles.filter((f) => f.endsWith('.js') || f.endsWith(".js.
|
|
346
|
+
scripts = manifestFiles.filter((f) => f.endsWith('.js') || f.endsWith(".js.br")).map((f) => `/_vatts/${f.replace('.br', '')}`);
|
|
347
347
|
styles = manifestFiles.filter((f) => f.endsWith('.css')).map((f) => `/_vatts/${f}`);
|
|
348
348
|
}
|
|
349
349
|
else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vatts",
|
|
3
|
-
"version": "1.4.1-test.
|
|
3
|
+
"version": "1.4.1-test.2",
|
|
4
4
|
"description": "Vatts.js 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
|
"types": "dist/index.d.ts",
|
|
6
6
|
"author": "mfraz",
|