vatts 2.0.2 → 2.1.0-canary.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.
Files changed (40) hide show
  1. package/LICENSE +12 -12
  2. package/README.md +63 -63
  3. package/dist/api/console.d.ts +28 -5
  4. package/dist/api/console.js +305 -137
  5. package/dist/api/native-server.js +25 -4
  6. package/dist/bin/vatts.js +192 -4
  7. package/dist/builder.js +70 -69
  8. package/dist/core-go/core-linux-arm64.node +0 -0
  9. package/dist/core-go/core-linux-x64.node +0 -0
  10. package/dist/core-go/core-win-x64.node +0 -0
  11. package/dist/global/global.d.ts +176 -176
  12. package/dist/helpers.d.ts +2 -2
  13. package/dist/helpers.js +20 -41
  14. package/dist/hotReload.js +205 -205
  15. package/dist/index.d.ts +2 -1
  16. package/dist/index.js +104 -19
  17. package/dist/loaders.js +15 -15
  18. package/dist/react/BuildingPage.js +202 -202
  19. package/dist/react/DefaultNotFound.js +16 -16
  20. package/dist/react/DevIndicator.js +101 -101
  21. package/dist/react/entry.client.js +7 -8
  22. package/dist/react/image/Image.js +1 -1
  23. package/dist/react/renderer-react.js +270 -33
  24. package/dist/react/server-error.d.ts +8 -0
  25. package/dist/react/server-error.js +346 -0
  26. package/dist/router.js +1 -65
  27. package/dist/types.d.ts +1 -5
  28. package/dist/utils/utils.d.ts +1 -0
  29. package/dist/utils/utils.js +68 -0
  30. package/dist/vue/App.vue +191 -191
  31. package/dist/vue/BuildingPage.vue +280 -280
  32. package/dist/vue/DefaultNotFound.vue +328 -328
  33. package/dist/vue/DevIndicator.vue +225 -225
  34. package/dist/vue/ErrorModal.vue +316 -316
  35. package/dist/vue/Link.vue +38 -38
  36. package/dist/vue/entry.client.js +7 -7
  37. package/dist/vue/image/Image.vue +106 -106
  38. package/dist/vue/renderer.vue.js +266 -46
  39. package/dist/vue/server-error.vue +351 -0
  40. package/package.json +1 -1
@@ -1,177 +1,177 @@
1
- /*
2
- * This file is part of the Vatts.js Project.
3
- * Copyright (c) 2026 mfraz
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
-
18
- /**
19
- * Type declarations for asset imports
20
- * This allows TypeScript to understand imports of various file types
21
- */
22
-
23
- // Markdown files
24
- declare module "*.md" {
25
- const content: string;
26
- export default content;
27
- }
28
-
29
- // Images
30
- declare module "*.png" {
31
- const src: string;
32
- export default src;
33
- }
34
-
35
- declare module "*.jpg" {
36
- const src: string;
37
- export default src;
38
- }
39
-
40
- declare module "*.jpeg" {
41
- const src: string;
42
- export default src;
43
- }
44
-
45
- declare module "*.gif" {
46
- const src: string;
47
- export default src;
48
- }
49
-
50
- declare module "*.webp" {
51
- const src: string;
52
- export default src;
53
- }
54
-
55
- declare module "*.avif" {
56
- const src: string;
57
- export default src;
58
- }
59
-
60
- declare module "*.ico" {
61
- const src: string;
62
- export default src;
63
- }
64
-
65
- declare module "*.bmp" {
66
- const src: string;
67
- export default src;
68
- }
69
-
70
- declare module "*.tif" {
71
- const src: string;
72
- export default src;
73
- }
74
-
75
- declare module "*.tiff" {
76
- const src: string;
77
- export default src;
78
- }
79
-
80
- // SVG (with additional export for raw content)
81
- declare module "*.svg" {
82
- const src: string;
83
- export const svgContent: string;
84
- export default src;
85
- }
86
-
87
- // JSON files
88
- declare module "*.json" {
89
- const value: any;
90
- export default value;
91
- }
92
-
93
- // Text files
94
- declare module "*.txt" {
95
- const content: string;
96
- export default content;
97
- }
98
-
99
- // Fonts
100
- declare module "*.woff" {
101
- const src: string;
102
- export default src;
103
- }
104
-
105
- declare module "*.woff2" {
106
- const src: string;
107
- export default src;
108
- }
109
-
110
- declare module "*.ttf" {
111
- const src: string;
112
- export default src;
113
- }
114
-
115
- declare module "*.otf" {
116
- const src: string;
117
- export default src;
118
- }
119
-
120
- declare module "*.eot" {
121
- const src: string;
122
- export default src;
123
- }
124
-
125
- // Audio files
126
- declare module "*.mp3" {
127
- const src: string;
128
- export default src;
129
- }
130
-
131
- declare module "*.wav" {
132
- const src: string;
133
- export default src;
134
- }
135
-
136
- declare module "*.ogg" {
137
- const src: string;
138
- export default src;
139
- }
140
-
141
- declare module "*.m4a" {
142
- const src: string;
143
- export default src;
144
- }
145
-
146
- declare module "*.aac" {
147
- const src: string;
148
- export default src;
149
- }
150
-
151
- declare module "*.flac" {
152
- const src: string;
153
- export default src;
154
- }
155
-
156
- // Video files
157
- declare module "*.mp4" {
158
- const src: string;
159
- export default src;
160
- }
161
-
162
- declare module "*.webm" {
163
- const src: string;
164
- export default src;
165
- }
166
-
167
- declare module "*.ogv" {
168
- const src: string;
169
- export default src;
170
- }
171
-
172
- /* eslint-disable */
173
- declare module '*.vue' {
174
- // Usamos import('vue') para não transformar o arquivo em um módulo
175
- const component: import('vue').DefineComponent<{}, {}, any>
176
- export default component
1
+ /*
2
+ * This file is part of the Vatts.js Project.
3
+ * Copyright (c) 2026 mfraz
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ /**
19
+ * Type declarations for asset imports
20
+ * This allows TypeScript to understand imports of various file types
21
+ */
22
+
23
+ // Markdown files
24
+ declare module "*.md" {
25
+ const content: string;
26
+ export default content;
27
+ }
28
+
29
+ // Images
30
+ declare module "*.png" {
31
+ const src: string;
32
+ export default src;
33
+ }
34
+
35
+ declare module "*.jpg" {
36
+ const src: string;
37
+ export default src;
38
+ }
39
+
40
+ declare module "*.jpeg" {
41
+ const src: string;
42
+ export default src;
43
+ }
44
+
45
+ declare module "*.gif" {
46
+ const src: string;
47
+ export default src;
48
+ }
49
+
50
+ declare module "*.webp" {
51
+ const src: string;
52
+ export default src;
53
+ }
54
+
55
+ declare module "*.avif" {
56
+ const src: string;
57
+ export default src;
58
+ }
59
+
60
+ declare module "*.ico" {
61
+ const src: string;
62
+ export default src;
63
+ }
64
+
65
+ declare module "*.bmp" {
66
+ const src: string;
67
+ export default src;
68
+ }
69
+
70
+ declare module "*.tif" {
71
+ const src: string;
72
+ export default src;
73
+ }
74
+
75
+ declare module "*.tiff" {
76
+ const src: string;
77
+ export default src;
78
+ }
79
+
80
+ // SVG (with additional export for raw content)
81
+ declare module "*.svg" {
82
+ const src: string;
83
+ export const svgContent: string;
84
+ export default src;
85
+ }
86
+
87
+ // JSON files
88
+ declare module "*.json" {
89
+ const value: any;
90
+ export default value;
91
+ }
92
+
93
+ // Text files
94
+ declare module "*.txt" {
95
+ const content: string;
96
+ export default content;
97
+ }
98
+
99
+ // Fonts
100
+ declare module "*.woff" {
101
+ const src: string;
102
+ export default src;
103
+ }
104
+
105
+ declare module "*.woff2" {
106
+ const src: string;
107
+ export default src;
108
+ }
109
+
110
+ declare module "*.ttf" {
111
+ const src: string;
112
+ export default src;
113
+ }
114
+
115
+ declare module "*.otf" {
116
+ const src: string;
117
+ export default src;
118
+ }
119
+
120
+ declare module "*.eot" {
121
+ const src: string;
122
+ export default src;
123
+ }
124
+
125
+ // Audio files
126
+ declare module "*.mp3" {
127
+ const src: string;
128
+ export default src;
129
+ }
130
+
131
+ declare module "*.wav" {
132
+ const src: string;
133
+ export default src;
134
+ }
135
+
136
+ declare module "*.ogg" {
137
+ const src: string;
138
+ export default src;
139
+ }
140
+
141
+ declare module "*.m4a" {
142
+ const src: string;
143
+ export default src;
144
+ }
145
+
146
+ declare module "*.aac" {
147
+ const src: string;
148
+ export default src;
149
+ }
150
+
151
+ declare module "*.flac" {
152
+ const src: string;
153
+ export default src;
154
+ }
155
+
156
+ // Video files
157
+ declare module "*.mp4" {
158
+ const src: string;
159
+ export default src;
160
+ }
161
+
162
+ declare module "*.webm" {
163
+ const src: string;
164
+ export default src;
165
+ }
166
+
167
+ declare module "*.ogv" {
168
+ const src: string;
169
+ export default src;
170
+ }
171
+
172
+ /* eslint-disable */
173
+ declare module '*.vue' {
174
+ // Usamos import('vue') para não transformar o arquivo em um módulo
175
+ const component: import('vue').DefineComponent<{}, {}, any>
176
+ export default component
177
177
  }
package/dist/helpers.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import http, { Server } from 'http';
3
- import type { VattsOptions, VattsConfig } from './types';
3
+ import type { VattsConfig, VattsOptions } from './types';
4
4
  /**
5
5
  * Carrega o arquivo de configuração vatts.config.ts ou vatts.config.js do projeto
6
6
  * @param projectDir Diretório raiz do projeto
@@ -20,7 +20,7 @@ export declare function app(options?: VattsOptions): {
20
20
  * Inicia um servidor Vatts.js fechado (o usuário não tem acesso ao framework)
21
21
  */
22
22
  init: () => Promise<http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>>;
23
- prepare: () => Promise<void>;
23
+ prepare: (skipBuild?: boolean) => Promise<void>;
24
24
  getRequestHandler: () => (req: any, res: any, next?: any) => Promise<void> | void;
25
25
  setupWebSocket: (server: Server | any) => void;
26
26
  executeInstrumentation: () => void;
package/dist/helpers.js CHANGED
@@ -62,8 +62,7 @@ const http_1 = __importDefault(require("http"));
62
62
  const os_1 = __importDefault(require("os"));
63
63
  const url_1 = require("url"); // API moderna, substitui 'querystring'
64
64
  const path_1 = __importDefault(require("path"));
65
- const stream_1 = require("stream"); // Necessário para a ponte do Socket
66
- // Helpers para integração com diferentes frameworks
65
+ const stream_1 = require("stream");
67
66
  const index_js_1 = __importStar(require("./index.js")); // Importando o tipo
68
67
  const console_1 = __importStar(require("./api/console"));
69
68
  const fs_1 = __importDefault(require("fs"));
@@ -105,7 +104,6 @@ const sendBox = (options) => {
105
104
  // Pequeno espaçamento visual antes dos logs de acesso
106
105
  console.log('');
107
106
  console.log(timer + labelStyle + ' Access on:');
108
- console.log(' ');
109
107
  // 1. Local (Alinhamento: Local tem 6 letras + 4 espaços = 10)
110
108
  console.info(timer + `${labelStyle} ┃ Local:${console_1.Colors.Reset} ${urlStyle}${protocol}://localhost:${exports.config?.port}${console_1.Colors.Reset}`);
111
109
  // 2. Network (Alinhamento: Network tem 8 letras + 2 espaços = 10)
@@ -144,7 +142,6 @@ async function loadVattsConfig(projectDir, phase) {
144
142
  maxUrlLength: 2048,
145
143
  accessLogging: true,
146
144
  envFiles: [],
147
- pathRouter: false,
148
145
  port: 3000,
149
146
  // backendPort removido do padrão lógico, mas mantido na tipagem se necessário para compatibilidade retroativa
150
147
  };
@@ -336,7 +333,7 @@ async function initNativeServer(vattsApp, options, hostname, vattsConfig) {
336
333
  exports.config = vattsConfig;
337
334
  // Passa envFiles da config para as opções do vatts
338
335
  options.envFiles = vattsConfig.envFiles;
339
- await vattsApp.prepare();
336
+ await vattsApp.prepare(options.skipBuild || false);
340
337
  const handler = vattsApp.getRequestHandler();
341
338
  const msg = console_1.default.dynamicLine(`${console_1.Colors.Bright}Starting Vatts.js on port ${exports.config?.port}${console_1.Colors.Reset}`);
342
339
  // --- LÓGICA DO LISTENER (REUTILIZÁVEL) ---
@@ -361,6 +358,8 @@ async function initNativeServer(vattsApp, options, hostname, vattsConfig) {
361
358
  res.setHeader('X-Frame-Options', 'DENY');
362
359
  res.setHeader('X-XSS-Protection', '1; mode=block');
363
360
  res.setHeader('Referrer-Policy', 'strict-origin-when-cross-origin');
361
+ // REMOVIDO: A injeção de Alt-Svc aqui causava duplicação.
362
+ // O servidor Go (NativeServer) já injeta este header corretamente.
364
363
  // Aplica headers de segurança configurados
365
364
  if (vattsConfig.security?.contentSecurityPolicy) {
366
365
  res.setHeader('Content-Security-Policy', vattsConfig.security.contentSecurityPolicy);
@@ -569,12 +568,17 @@ async function initNativeServer(vattsApp, options, hostname, vattsConfig) {
569
568
  // httpsPort vazio diz pro Go não iniciar TLS
570
569
  }
571
570
  try {
571
+ // Garante que a porta HTTP/3 seja uma string limpa ou vazia, sem criar ::
572
+ const h3PortValue = exports.config.ssl?.http3Port
573
+ ? String(exports.config.ssl.http3Port)
574
+ : "";
575
+ // Se já tiver :, deixa. Se não, o Go normaliza. Mas enviamos string limpa.
572
576
  native_server_1.NativeServer.start({
573
577
  httpPort: goHttpPort,
574
578
  httpsPort: goHttpsPort,
575
579
  certPath: certPath,
576
580
  keyPath: keyPath,
577
- http3Port: exports.config.ssl?.http3Port ? `:${exports.config.ssl?.http3Port}` : "",
581
+ http3Port: h3PortValue ? (h3PortValue.includes(':') ? h3PortValue : `:${h3PortValue}`) : "",
578
582
  devMode: options.dev ? "true" : "false",
579
583
  // Callback: Chegou dados do Go (Browser -> Go -> Node)
580
584
  onData: (connId, data) => {
@@ -608,16 +612,21 @@ async function initNativeServer(vattsApp, options, hostname, vattsConfig) {
608
612
  sendBox({ ...options });
609
613
  const httpLabel = vattsConfig.ssl?.http3Port ? `HTTP/3 (${vattsConfig.ssl?.http3Port || ''})` : "HTTP/2";
610
614
  const modeLabel = isSSL ? httpLabel : "HTTP (Shield active)";
611
- msg.end(`${console_1.Colors.Bright}Ready on port ${console_1.Colors.BgGreen} ${publicPort} (${modeLabel}) ${console_1.Colors.Reset}\n` +
612
- `${console_1.Colors.Dim} ↳ Engine running on Native Bridge in ${Date.now() - time}ms${console_1.Colors.Reset}\n`);
615
+ msg.end("end_clear");
616
+ console_1.default.success(`${console_1.Colors.Bright}Ready on port ${console_1.Colors.BgGreen} ${publicPort} (${modeLabel}) ${console_1.Colors.Reset}\n` +
617
+ `${console_1.Colors.Dim} ↳ Engine running on Native Server in ${Date.now() - time}ms${console_1.Colors.Reset}\n`);
613
618
  // MANTÉM O PROCESSO VIVO
614
619
  // Como não chamamos server.listen(), o event loop do Node ficaria vazio e o processo morreria.
615
620
  // Este intervalo mantém o processo rodando para processar os callbacks do CGO.
616
621
  setInterval(() => { }, 2147483647);
617
622
  }
618
623
  catch (e) {
619
- console_1.default.error(`${console_1.Colors.FgRed}[Critical] Failed to start Native Server:${console_1.Colors.Reset} ${e.message}`);
620
- process.exit(1);
624
+ console_1.default.error(`${console_1.Colors.FgRed}[Critical] Failed to start Native Server:`, e);
625
+ // Graceful shutdown
626
+ console.log(`${console_1.Colors.FgGray}Shutting down gracefully...${console_1.Colors.Reset}`);
627
+ setTimeout(() => {
628
+ process.exit(1);
629
+ }, 1000);
621
630
  }
622
631
  // Configura WebSocket (Funciona através do Proxy pois ele suporta upgrade de conexão via raw bytes)
623
632
  vattsApp.setupWebSocket(server);
@@ -688,37 +697,7 @@ function app(options = {}) {
688
697
  init: async () => {
689
698
  const projectDir = options.dir || process.cwd();
690
699
  const phase = options.dev ? 'development' : 'production';
691
- const vattsConfig = await loadVattsConfig(projectDir, phase);
692
- exports.config = vattsConfig;
693
- const currentVersion = require('../package.json').version;
694
- async function verifyVersion() {
695
- // node fetch
696
- try {
697
- const response = await fetch('https://registry.npmjs.org/vatts/latest');
698
- const data = await response.json();
699
- return data.version;
700
- }
701
- catch (error) {
702
- console_1.default.error('Could not check for the latest Vatts.js version:', error);
703
- return currentVersion; // Retorna a versão atual em caso de erro
704
- }
705
- }
706
- const latestVersion = await verifyVersion();
707
- const isUpToDate = latestVersion === currentVersion;
708
- let message;
709
- if (!isUpToDate) {
710
- message = `${console_1.Colors.FgRed} A new version is available (v${latestVersion})${console_1.Colors.FgMagenta}`;
711
- }
712
- else {
713
- message = `${console_1.Colors.FgGreen} You are on the latest version${console_1.Colors.FgMagenta}`;
714
- }
715
- // JS STICK LETTERS
716
- console.log(`${console_1.Colors.Bright + console_1.Colors.FgCyan}
717
- ${console_1.Colors.Bright + console_1.Colors.FgCyan} ___ ___ __ ${console_1.Colors.FgWhite} __
718
- ${console_1.Colors.Bright + console_1.Colors.FgCyan} \\ / /\\ | | /__\`${console_1.Colors.FgWhite} | /__\` ${console_1.Colors.Bright + console_1.Colors.FgCyan}Vatts${console_1.Colors.FgWhite}.js ${console_1.Colors.FgGray}(v${require('../package.json').version}) - mfraz
719
- ${console_1.Colors.Bright + console_1.Colors.FgCyan} \\/ /~~\\ | | .__/ .${console_1.Colors.FgWhite} \\__/ .__/ ${message}
720
-
721
- `);
700
+ exports.config = await loadVattsConfig(projectDir, phase);
722
701
  const actualHostname = options.hostname || "0.0.0.0";
723
702
  if (framework !== 'native') {
724
703
  console_1.default.warn(`The "${framework}" framework was selected, but the init() method only works with the "native" framework. Starting native server...`);