vatts 1.4.1-test.2 → 2.0.0-canary.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.
Files changed (39) hide show
  1. package/LICENSE +12 -12
  2. package/README.md +63 -52
  3. package/dist/api/native-server.d.ts +38 -0
  4. package/dist/api/native-server.js +155 -0
  5. package/dist/api/optimizer.d.ts +1 -0
  6. package/dist/api/optimizer.js +14 -2
  7. package/dist/builder.d.ts +4 -4
  8. package/dist/builder.js +167 -73
  9. package/dist/core-go/core-linux-arm64.node +0 -0
  10. package/dist/core-go/core-linux-x64.node +0 -0
  11. package/dist/core-go/core-win-x64.node +0 -0
  12. package/dist/global/global.d.ts +176 -176
  13. package/dist/helpers.js +159 -106
  14. package/dist/hotReload.js +220 -208
  15. package/dist/index.js +58 -113
  16. package/dist/loaders.js +15 -15
  17. package/dist/react/BuildingPage.js +201 -201
  18. package/dist/react/DefaultNotFound.js +15 -15
  19. package/dist/react/DevIndicator.js +101 -101
  20. package/dist/react/entry.client.js +8 -7
  21. package/dist/react/react.build.js +1 -3
  22. package/dist/react/renderer-react.js +11 -11
  23. package/dist/router.js +20 -0
  24. package/dist/types.d.ts +1 -1
  25. package/dist/vue/App.vue +191 -191
  26. package/dist/vue/BuildingPage.vue +280 -280
  27. package/dist/vue/DefaultNotFound.vue +328 -328
  28. package/dist/vue/DevIndicator.vue +225 -225
  29. package/dist/vue/ErrorModal.vue +316 -316
  30. package/dist/vue/Link.vue +38 -38
  31. package/dist/vue/entry.client.js +8 -7
  32. package/dist/vue/image/Image.vue +106 -106
  33. package/dist/vue/renderer.vue.js +20 -20
  34. package/package.json +1 -1
  35. package/dist/api/http3.d.ts +0 -62
  36. package/dist/api/http3.js +0 -162
  37. package/dist/core-go/dev-linux-arm64.node +0 -0
  38. package/dist/core-go/dev-linux-x64.node +0 -0
  39. package/dist/core-go/dev-win-x64.node +0 -0
package/LICENSE CHANGED
@@ -1,13 +1,13 @@
1
- Copyright 2026 mfraz
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License.
5
- You may obtain a copy of the License at
6
-
7
- http://www.apache.org/licenses/LICENSE-2.0
8
-
9
- Unless required by applicable law or agreed to in writing, software
10
- distributed under the License is distributed on an "AS IS" BASIS,
11
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- See the License for the specific language governing permissions and
1
+ Copyright 2026 mfraz
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
13
  limitations under the License.
package/README.md CHANGED
@@ -1,52 +1,63 @@
1
- <div align="center">
2
- <picture>
3
- <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/mfrazlab/vatts.js/master/docs/public/logo.png">
4
- <img alt="Vatts.js logo" src="https://raw.githubusercontent.com/mfrazlab/vatts.js/master/docs/public/logo.png" width="128">
5
- </picture>
6
- <h1>Vatts.js</h1>
7
-
8
- [![NPM](https://img.shields.io/npm/v/vatts.svg?style=for-the-badge&labelColor=000000)](https://www.npmjs.com/package/vatts)
9
- [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg?style=for-the-badge&labelColor=000000)](./LICENSE)
10
- [![GitHub](https://img.shields.io/badge/GitHub-mfrazlab/vatts.js-100000?style=for-the-badge&logo=github&logoColor=white)](https://github.com/mfrazlab/vatts.js)
11
- </div>
12
-
13
- ___
14
-
15
- ## Getting Started
16
-
17
- **Vatts.js** is a modern, full-featured web framework for **Node.js** with first-class support for **React and Vue**.
18
-
19
- It is a **multi-framework platform**, allowing you to build applications using **either React or Vue per project** — not both at the same time.
20
- This keeps the ecosystem clean, predictable, and optimized for performance and tooling.
21
-
22
- Vatts removes unnecessary configuration and complex abstractions, allowing you to focus on what truly matters: **building fast, secure, and scalable applications**.
23
-
24
- ### Why choose Vatts.js?
25
- - Extremely fast — architecture optimized for low overhead
26
- - Intuitive API easy to learn and pleasant to use
27
- - Productivity from the first minute zero unnecessary boilerplate
28
- - Multi-framework — choose **React or Vue per project**
29
- - Full integration between backend and frontend
30
- - Built for modern projects — TypeScript-friendly, modular, and extensible
31
-
32
- ___
33
-
34
- ## Documentation
35
-
36
- Visit [https://vatts.mfraz.ovh](https://vatts.mfraz.ovh) to view the full documentation.
37
-
38
- ___
39
-
40
- ## Community
41
-
42
- The Vatts.js community can be found on [GitHub Discussions](https://github.com/mfraz/vatts), where you can ask questions, share ideas, and showcase your projects with others.
43
-
44
- ___
45
-
46
- ## Security
47
-
48
- If you believe you have found a security vulnerability in Vatts.js, we encourage you to **responsibly disclose it and NOT open a public issue**.
49
-
50
- To participate in our vulnerability disclosure program, please email [helpers@mfraz.ovh](mailto:help@mfraz.ovh). We will add you to the program and provide further instructions for submitting your report.
51
-
52
- ___
1
+ <div align="center">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/mfrazlab/vatts.js/master/docs/public/logo.png">
4
+ <img alt="Vatts.js logo" src="https://raw.githubusercontent.com/mfrazlab/vatts.js/master/docs/public/logo.png" width="128">
5
+ </picture>
6
+ <h1>Vatts.js</h1>
7
+
8
+ [![NPM](https://img.shields.io/npm/v/vatts.svg?style=for-the-badge&labelColor=000000)](https://www.npmjs.com/package/vatts)
9
+ [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg?style=for-the-badge&labelColor=000000)](./LICENSE)
10
+ [![GitHub](https://img.shields.io/badge/GitHub-mfrazlab/vatts.js-100000?style=for-the-badge&logo=github&logoColor=white)](https://github.com/mfrazlab/vatts.js)
11
+
12
+ [![HTTP/3 Supported](https://img.shields.io/badge/SUPPORTED-HTTP/3-brightgreen?style=for-the-badge&labelColor=000000)](#)
13
+ </div>
14
+
15
+ ---
16
+
17
+
18
+
19
+
20
+ ## Getting Started
21
+
22
+ **Vatts.js** is a modern, full-featured web framework for **Node.js** with first-class support for **React and Vue**.
23
+
24
+ It is the first framework to offer native HTTP/3 support out of the box. Powered by an internal proxy engine that enables HTTP/3 with SSL termination. This means your applications benefit from the latest web transport protocol.
25
+
26
+ Vatts.js is a **multi-framework platform**, allowing you to build applications using **either React or Vue per project** — not both at the same time.
27
+ This keeps the ecosystem clean, predictable, and optimized for performance and tooling.
28
+
29
+ Vatts removes unnecessary configuration and complex abstractions, allowing you to focus on what truly matters: **building fast, secure, and scalable applications**.
30
+
31
+ ### Why choose Vatts.js?
32
+ - **Native Proxy** — modern, secure, and high-performance networking with **HTTP/3 support**
33
+ - Extremely fast — architecture optimized for low overhead
34
+ - Intuitive API — easy to learn and pleasant to use
35
+ - Productivity from the first minute — zero unnecessary boilerplate
36
+ - Multi-framework choose **React or Vue per project**
37
+ - Full integration between backend and frontend
38
+ - Built for modern projects — TypeScript-friendly, modular, and extensible
39
+
40
+ ___
41
+
42
+ ## Documentation
43
+
44
+ Visit [https://vatts.mfraz.ovh](https://vatts.mfraz.ovh) to view the full documentation.
45
+
46
+ ___
47
+
48
+ ## Community
49
+
50
+ The Vatts.js community can be found on [GitHub Discussions](https://github.com/mfraz/vatts), where you can ask questions, share ideas, and showcase your projects with others.
51
+
52
+ ___
53
+
54
+
55
+ ## Security
56
+
57
+ Vatts.js is engineered with a security-first architecture centered around an internal proxy layer that mediates all application traffic. This proxy is designed to support modern transports such as native HTTP/3 when SSL is enabled, while consistently enforcing built-in security guarantees at the protocol and application boundaries. Even in local or non-TLS environments, the proxy remains active, preserving request isolation, and secure handling by default.
58
+
59
+ If you believe you have found a security vulnerability in Vatts.js, we encourage you to **responsibly disclose it and NOT open a public issue**.
60
+
61
+ To participate in our vulnerability disclosure program, please email [helpers@mfraz.ovh](mailto:help@mfraz.ovh). We will add you to the program and provide further instructions for submitting your report.
62
+
63
+ ___
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Interface para opções do Servidor Nativo (Go HTTP/3)
3
+ */
4
+ export interface NativeServerOptions {
5
+ httpPort: string;
6
+ httpsPort: string;
7
+ http3Port?: string;
8
+ devMode: string;
9
+ certPath: string;
10
+ keyPath: string;
11
+ onData: (connId: number, data: Buffer) => void;
12
+ onClose?: (connId: number) => void;
13
+ customLibPath?: string;
14
+ }
15
+ export declare class NativeServer {
16
+ private static lib;
17
+ private static startFunc;
18
+ private static writeFunc;
19
+ private static closeConnFunc;
20
+ private static registeredCallbacks;
21
+ static getLibPath(): string;
22
+ private static loadLibrary;
23
+ static start(options: NativeServerOptions): void;
24
+ /**
25
+ * Envia dados binários de volta para o Go
26
+ */
27
+ static write(connId: number, data: Buffer | string): void;
28
+ static closeConnection(connId: number): void;
29
+ }
30
+ export declare const startServer: (options: NativeServerOptions) => void;
31
+ export declare const writeToConnection: (id: number, data: Buffer | string) => void;
32
+ export declare const closeConnection: (id: number) => void;
33
+ declare const _default: {
34
+ start: (options: NativeServerOptions) => void;
35
+ write: (id: number, data: Buffer | string) => void;
36
+ close: (id: number) => void;
37
+ };
38
+ export default _default;
@@ -0,0 +1,155 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.closeConnection = exports.writeToConnection = exports.startServer = exports.NativeServer = void 0;
7
+ const koffi_1 = __importDefault(require("koffi"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const fs_1 = __importDefault(require("fs"));
10
+ const os_1 = __importDefault(require("os"));
11
+ // Definição dos tipos dos callbacks C para o Koffi
12
+ // typedef void (*OnDataCallback)(int connID, void* data, int length);
13
+ // Usamos 'void*' para dados genéricos e 'int' para o tamanho
14
+ const OnDataCallback = koffi_1.default.proto('void OnDataCallback(int connID, void* data, int length)');
15
+ // typedef void (*OnCloseCallback)(int connID);
16
+ const OnCloseCallback = koffi_1.default.proto('void OnCloseCallback(int connID)');
17
+ class NativeServer {
18
+ static lib = null;
19
+ static startFunc = null;
20
+ static writeFunc = null;
21
+ static closeConnFunc = null;
22
+ static registeredCallbacks = [];
23
+ static getLibPath() {
24
+ const platform = os_1.default.platform();
25
+ const arch = os_1.default.arch();
26
+ let osName = '';
27
+ let ext = '.node';
28
+ switch (platform) {
29
+ case 'win32':
30
+ osName = 'win';
31
+ break;
32
+ case 'linux':
33
+ osName = 'linux';
34
+ break;
35
+ case 'darwin':
36
+ osName = 'darwin';
37
+ break;
38
+ default:
39
+ throw new Error(`Sistema operacional não suportado: ${platform}`);
40
+ }
41
+ let archName = '';
42
+ switch (arch) {
43
+ case 'x64':
44
+ archName = 'x64';
45
+ break;
46
+ case 'arm64':
47
+ archName = 'arm64';
48
+ break;
49
+ default:
50
+ throw new Error(`Arquitetura não suportada: ${arch}`);
51
+ }
52
+ const filename = `core-${osName}-${archName}${ext}`;
53
+ return path_1.default.resolve(__dirname, '..', 'core-go', filename);
54
+ }
55
+ static loadLibrary(customPath) {
56
+ if (this.lib)
57
+ return;
58
+ const libPath = customPath || this.getLibPath();
59
+ if (!fs_1.default.existsSync(libPath)) {
60
+ const altPath = path_1.default.resolve(process.cwd(), libPath);
61
+ if (!fs_1.default.existsSync(altPath)) {
62
+ console.warn(`Native Server Library not found at: ${libPath}`);
63
+ return;
64
+ }
65
+ }
66
+ try {
67
+ this.lib = koffi_1.default.load(libPath);
68
+ // func StartServer(..., onData, onClose)
69
+ this.startFunc = this.lib.func('StartServer', 'str', [
70
+ 'str', 'str', 'str', 'str',
71
+ koffi_1.default.pointer(OnDataCallback),
72
+ koffi_1.default.pointer(OnCloseCallback),
73
+ 'str',
74
+ 'str'
75
+ ]);
76
+ // Mapeando WriteToConn do Go (Atualizado para binário):
77
+ // func WriteToConn(connID int, dataC *void, length int) *char
78
+ this.writeFunc = this.lib.func('WriteToConn', 'str', ['int', 'void*', 'int']);
79
+ this.closeConnFunc = this.lib.func('CloseConn', 'void', ['int']);
80
+ }
81
+ catch (error) {
82
+ throw new Error(`Failed to load native library: ${error}`);
83
+ }
84
+ }
85
+ static start(options) {
86
+ const { httpPort, httpsPort, certPath, keyPath, onData, onClose, customLibPath, http3Port, devMode } = options;
87
+ this.loadLibrary(customLibPath);
88
+ if (!this.startFunc)
89
+ return;
90
+ // Callback de DADOS: Agora recebe pointer e length
91
+ const onDataPtr = koffi_1.default.register((connId, ptr, len) => {
92
+ try {
93
+ // Decodifica a memória crua do C para um Buffer do Node
94
+ // 'uint8' cria um array de bytes, Buffer.from empacota isso
95
+ const buffer = Buffer.from(koffi_1.default.decode(ptr, 'uint8', len));
96
+ onData(connId, buffer);
97
+ }
98
+ catch (e) {
99
+ console.error("Error inside NativeServer onData callback:", e);
100
+ }
101
+ }, koffi_1.default.pointer(OnDataCallback));
102
+ const onClosePtr = koffi_1.default.register((connId) => {
103
+ try {
104
+ if (onClose)
105
+ onClose(connId);
106
+ }
107
+ catch (e) {
108
+ console.error("Error inside NativeServer onClose callback:", e);
109
+ }
110
+ }, koffi_1.default.pointer(OnCloseCallback));
111
+ this.registeredCallbacks.push(onDataPtr, onClosePtr);
112
+ const err = this.startFunc(httpPort, httpsPort, certPath, keyPath, onDataPtr, onClosePtr, http3Port || '', devMode || '');
113
+ if (err) {
114
+ throw new Error(`Native Server Start Error: ${err}`);
115
+ }
116
+ }
117
+ /**
118
+ * Envia dados binários de volta para o Go
119
+ */
120
+ static write(connId, data) {
121
+ if (!this.writeFunc)
122
+ return;
123
+ let buffer;
124
+ if (typeof data === 'string') {
125
+ buffer = Buffer.from(data);
126
+ }
127
+ else {
128
+ buffer = data;
129
+ }
130
+ // Passa o buffer e o tamanho dele explicitamente
131
+ const err = this.writeFunc(connId, buffer, buffer.length);
132
+ if (err) {
133
+ // console.error(`Write error to conn ${connId}: ${err}`);
134
+ }
135
+ }
136
+ static closeConnection(connId) {
137
+ if (!this.closeConnFunc)
138
+ return;
139
+ this.closeConnFunc(connId);
140
+ }
141
+ }
142
+ exports.NativeServer = NativeServer;
143
+ const startServer = (options) => {
144
+ return NativeServer.start(options);
145
+ };
146
+ exports.startServer = startServer;
147
+ const writeToConnection = (id, data) => {
148
+ return NativeServer.write(id, data);
149
+ };
150
+ exports.writeToConnection = writeToConnection;
151
+ const closeConnection = (id) => {
152
+ return NativeServer.closeConnection(id);
153
+ };
154
+ exports.closeConnection = closeConnection;
155
+ exports.default = { start: exports.startServer, write: exports.writeToConnection, close: exports.closeConnection };
@@ -10,6 +10,7 @@ export interface OptimizerOptions {
10
10
  ignoredPatterns?: string[];
11
11
  /** (Opcional) Sobrescreve o caminho da biblioteca manualmemte */
12
12
  customLibPath?: string;
13
+ ssl?: boolean;
13
14
  }
14
15
  export declare class NativeOptimizer {
15
16
  private static instance;
@@ -8,6 +8,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
+ const helpers_1 = require("../helpers");
11
12
  class NativeOptimizer {
12
13
  static instance = null;
13
14
  /**
@@ -66,7 +67,8 @@ class NativeOptimizer {
66
67
  // Mapeia a função Go: func Optimize(...) *C.char
67
68
  // Em Koffi, 'str' como retorno significa char* (string C)
68
69
  // Se o Go retornar nil, o Koffi converte para null no JS
69
- this.instance = lib.func('Optimize', 'str', ['str', 'str', 'str']);
70
+ // CORREÇÃO: Adicionado o quarto 'str' para o argumento SSL
71
+ this.instance = lib.func('Optimize', 'str', ['str', 'str', 'str', 'str']);
70
72
  return this.instance;
71
73
  }
72
74
  catch (error) {
@@ -78,6 +80,16 @@ class NativeOptimizer {
78
80
  */
79
81
  static run(options) {
80
82
  const { targetDir, outputDir = '', ignoredPatterns = [], customLibPath } = options;
83
+ let ssl = "false";
84
+ // Verifica se ssl foi passado explicitamente, senão pega da config global
85
+ if (options.ssl !== undefined && options.ssl !== null) {
86
+ ssl = options.ssl ? 'true' : 'false';
87
+ }
88
+ else {
89
+ // Garante que config existe antes de acessar propriedades profundas
90
+ const isSSL = !!(helpers_1.config?.ssl?.key && helpers_1.config?.ssl?.cert);
91
+ ssl = isSSL ? 'true' : 'false';
92
+ }
81
93
  const optimize = this.loadLibrary(customLibPath);
82
94
  const absTarget = path_1.default.resolve(targetDir);
83
95
  const absOutput = outputDir ? path_1.default.resolve(outputDir) : '';
@@ -86,7 +98,7 @@ class NativeOptimizer {
86
98
  if (!fs_1.default.existsSync(absTarget)) {
87
99
  return;
88
100
  }
89
- const errorMsg = optimize(absTarget, absOutput, ignoredStr);
101
+ const errorMsg = optimize(absTarget, absOutput, ignoredStr, ssl);
90
102
  if (errorMsg) {
91
103
  throw new Error(errorMsg);
92
104
  }
package/dist/builder.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export function build(entryPoint: any, outfile: any, isProduction?: boolean): Promise<void>;
2
- export function watch(entryPoint: any, outfile: any, hotReloadManager?: null): Promise<import("rollup").RollupWatcher>;
3
- export function buildWithChunks(entryPoint: any, outdir: any, isProduction?: boolean): Promise<void>;
4
- export function watchWithChunks(entryPoint: any, outdir: any, hotReloadManager?: null): Promise<import("rollup").RollupWatcher>;
1
+ export function build(vattsOptions: any, outfile: any, isProduction?: boolean): Promise<void>;
2
+ export function watch(vattsOptions: any, outfile: any, hotReloadManager?: null): Promise<import("rollup").RollupWatcher>;
3
+ export function buildWithChunks(vattsOptions: any, outdir: any, isProduction?: boolean): Promise<void>;
4
+ export function watchWithChunks(vattsOptions: any, outdir: any, hotReloadManager?: null): Promise<import("rollup").RollupWatcher>;