vatts 2.2.6 → 2.3.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.
- package/LICENSE +12 -12
- package/README.md +65 -65
- package/dist/builder.js +79 -42
- package/dist/frameworks/FrontCore.d.ts +34 -0
- package/dist/frameworks/FrontCore.js +128 -0
- package/dist/{vue → frameworks/builds}/vue.build.js +1 -1
- package/dist/frameworks/react/client.d.ts +8 -0
- package/dist/{react → frameworks/react}/client.js +14 -14
- package/dist/{react → frameworks/react/components}/Link.js +2 -2
- package/dist/frameworks/react/entry.client.d.ts +14 -0
- package/dist/frameworks/react/entry.client.js +211 -0
- package/dist/frameworks/react/react-elements.d.ts +10 -0
- package/dist/{react → frameworks/renderers}/renderer-react.d.ts +2 -2
- package/dist/{react → frameworks/renderers}/renderer-react.js +53 -86
- package/dist/{vue → frameworks/renderers}/renderer.vue.d.ts +2 -2
- package/dist/frameworks/renderers/renderer.vue.js +193 -0
- package/dist/frameworks/themes/BuildingPage.d.ts +1 -0
- package/dist/frameworks/themes/BuildingPage.js +312 -0
- package/dist/frameworks/themes/DefaultNotFound.d.ts +1 -0
- package/dist/frameworks/themes/DefaultNotFound.js +330 -0
- package/dist/frameworks/themes/ErrorModal.d.ts +1 -0
- package/dist/frameworks/themes/ErrorModal.js +345 -0
- package/dist/frameworks/themes/ServerError.d.ts +1 -0
- package/dist/frameworks/themes/ServerError.js +401 -0
- package/dist/frameworks/themes/VattsDevBadge.d.ts +1 -0
- package/dist/frameworks/themes/VattsDevBadge.js +232 -0
- package/dist/frameworks/vue/App.vue +149 -0
- package/dist/frameworks/vue/client.d.ts +9 -0
- package/dist/{vue → frameworks/vue}/client.js +13 -11
- package/dist/{vue → frameworks/vue/components}/Link.vue +38 -38
- package/dist/{vue → frameworks/vue/components}/image/Image.vue +128 -128
- package/dist/frameworks/vue/entry.client.js +75 -0
- package/dist/global/global.d.ts +179 -180
- package/dist/hotReload.js +77 -77
- package/dist/index.js +12 -1
- package/dist/loaders.js +15 -15
- package/dist/renderer.js +2 -2
- package/dist/renderers/common.js +3 -3
- package/dist/utils/core-go.js +2 -2
- package/dist/utils/utils.js +5 -5
- package/package.json +10 -26
- package/dist/react/BuildingPage.d.ts +0 -2
- package/dist/react/BuildingPage.js +0 -270
- package/dist/react/DefaultNotFound.d.ts +0 -2
- package/dist/react/DefaultNotFound.js +0 -248
- package/dist/react/DevIndicator.d.ts +0 -5
- package/dist/react/DevIndicator.js +0 -203
- package/dist/react/ErrorModal.d.ts +0 -20
- package/dist/react/ErrorModal.js +0 -266
- package/dist/react/client.d.ts +0 -8
- package/dist/react/entry.client.d.ts +0 -6
- package/dist/react/entry.client.js +0 -325
- package/dist/react/server-error.d.ts +0 -8
- package/dist/react/server-error.js +0 -346
- package/dist/vue/App.vue +0 -199
- package/dist/vue/BuildingPage.vue +0 -281
- package/dist/vue/DefaultNotFound.vue +0 -329
- package/dist/vue/DevIndicator.vue +0 -226
- package/dist/vue/ErrorModal.vue +0 -317
- package/dist/vue/client.d.ts +0 -9
- package/dist/vue/entry.client.js +0 -110
- package/dist/vue/renderer.vue.js +0 -387
- package/dist/vue/server-error.vue +0 -351
- /package/dist/{react → frameworks/builds}/react.build.d.ts +0 -0
- /package/dist/{react → frameworks/builds}/react.build.js +0 -0
- /package/dist/{vue → frameworks/builds}/vue.build.d.ts +0 -0
- /package/dist/{react → frameworks/react/components}/Link.d.ts +0 -0
- /package/dist/{react → frameworks/react/components}/image/Image.d.ts +0 -0
- /package/dist/{react → frameworks/react/components}/image/Image.js +0 -0
- /package/dist/{vue → frameworks/vue}/entry.client.d.ts +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,65 +1,65 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
<picture>
|
|
3
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/murillo-frazao-cunha/vatts-docs/master/public/logo.png">
|
|
4
|
-
<img alt="Vatts.js logo" src="https://raw.githubusercontent.com/murillo-frazao-cunha/vatts-docs/master/public/logo.png" width="128">
|
|
5
|
-
</picture>
|
|
6
|
-
<h1>Vatts.js</h1>
|
|
7
|
-
|
|
8
|
-
[](https://www.npmjs.com/package/vatts)
|
|
9
|
-
[](./LICENSE)
|
|
10
|
-
[](https://github.com/murillo-frazao-cunha/vatts.js)
|
|
11
|
-
|
|
12
|
-
[](#)
|
|
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 a Go-based HTTP server with built-in SSL termination. Applications run directly on the latest web transport protocol, without proxies or external layers.
|
|
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 HTTP** — 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.js), where you can ask questions, share ideas, and showcase your projects with others.
|
|
51
|
-
|
|
52
|
-
___
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
## Security
|
|
56
|
-
|
|
57
|
-
Vatts.js uses a security-first hybrid architecture in which Node.js coordinates the application layer and a high-performance Go networking engine manages HTTP connections and transport protocols.
|
|
58
|
-
By delegating network handling to Go, the platform achieves strong isolation, predictable request processing, and native support for modern transports like HTTP/3 under SSL — all while maintaining consistent security enforcement across environments, including local and non-TLS setups.
|
|
59
|
-
|
|
60
|
-
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**.
|
|
61
|
-
|
|
62
|
-
To participate in our vulnerability disclosure program, please email [contact@mfraz.ovh](mailto:contact@mfraz.ovh). We will add you to the program and provide further instructions for submitting your report.
|
|
63
|
-
|
|
64
|
-
___
|
|
65
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/murillo-frazao-cunha/vatts-docs/master/public/logo.png">
|
|
4
|
+
<img alt="Vatts.js logo" src="https://raw.githubusercontent.com/murillo-frazao-cunha/vatts-docs/master/public/logo.png" width="128">
|
|
5
|
+
</picture>
|
|
6
|
+
<h1>Vatts.js</h1>
|
|
7
|
+
|
|
8
|
+
[](https://www.npmjs.com/package/vatts)
|
|
9
|
+
[](./LICENSE)
|
|
10
|
+
[](https://github.com/murillo-frazao-cunha/vatts.js)
|
|
11
|
+
|
|
12
|
+
[](#)
|
|
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 a Go-based HTTP server with built-in SSL termination. Applications run directly on the latest web transport protocol, without proxies or external layers.
|
|
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 HTTP** — 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.js), where you can ask questions, share ideas, and showcase your projects with others.
|
|
51
|
+
|
|
52
|
+
___
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
## Security
|
|
56
|
+
|
|
57
|
+
Vatts.js uses a security-first hybrid architecture in which Node.js coordinates the application layer and a high-performance Go networking engine manages HTTP connections and transport protocols.
|
|
58
|
+
By delegating network handling to Go, the platform achieves strong isolation, predictable request processing, and native support for modern transports like HTTP/3 under SSL — all while maintaining consistent security enforcement across environments, including local and non-TLS setups.
|
|
59
|
+
|
|
60
|
+
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**.
|
|
61
|
+
|
|
62
|
+
To participate in our vulnerability disclosure program, please email [contact@mfraz.ovh](mailto:contact@mfraz.ovh). We will add you to the program and provide further instructions for submitting your report.
|
|
63
|
+
|
|
64
|
+
___
|
|
65
|
+
|
package/dist/builder.js
CHANGED
|
@@ -22,8 +22,8 @@ const fs = require('fs');
|
|
|
22
22
|
const { readdir, stat, rm, rename } = require("node:fs/promises");
|
|
23
23
|
const { config } = require("./helpers");
|
|
24
24
|
// Import Framework specific builders
|
|
25
|
-
const { createReactConfig } = require('./
|
|
26
|
-
const { createVueConfig } = require('./
|
|
25
|
+
const { createReactConfig } = require('./frameworks/builds/react.build');
|
|
26
|
+
const { createVueConfig } = require('./frameworks/builds/vue.build');
|
|
27
27
|
const routerModule = require("./router");
|
|
28
28
|
const excludedFiles = ['vatts.sock'];
|
|
29
29
|
// --- Custom Plugin: Require Context (Adapted for Esbuild) ---
|
|
@@ -146,28 +146,36 @@ const virtualEntryPlugin = (options) => ({
|
|
|
146
146
|
.join('\n');
|
|
147
147
|
const layoutImport = layout ? `import LayoutComponent from '${layout.componentPath.replace(/\\/g, '/')}';` : '';
|
|
148
148
|
const notFoundImport = notFound ? `import NotFoundComponent from '${notFound.componentPath.replace(/\\/g, '/')}';` : '';
|
|
149
|
-
const defaultNotFoundPath = path.join(__dirname,
|
|
149
|
+
const defaultNotFoundPath = path.join(__dirname, 'frameworks', 'themes', 'DefaultNotFound.js').replace(/\\/g, '/');
|
|
150
150
|
let componentRegistration = routes
|
|
151
151
|
.map((route, index) => ` '${route.componentPath.replace(/\\/g, '/')}': (route${index} && route${index}.default) ? route${index}.default : route${index},`)
|
|
152
152
|
.join('\n');
|
|
153
153
|
const layoutRegistration = layout ? `window.__VATTS_LAYOUT__ = LayoutComponent.default || LayoutComponent;` : `window.__VATTS_LAYOUT__ = null;`;
|
|
154
154
|
const notFoundRegistration = notFound ? `window.__VATTS_NOT_FOUND__ = NotFoundComponent.default || NotFoundComponent;` : `window.__VATTS_NOT_FOUND__ = null;`;
|
|
155
|
-
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
${
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
${
|
|
167
|
-
|
|
168
|
-
window.
|
|
169
|
-
|
|
170
|
-
|
|
155
|
+
// Mapeamos as rotas e injetamos globalmente na entry
|
|
156
|
+
const clientRoutes = routes.map(r => ({
|
|
157
|
+
pattern: r.pattern,
|
|
158
|
+
componentPath: r.componentPath,
|
|
159
|
+
metadata: r.metadata || {}
|
|
160
|
+
}));
|
|
161
|
+
const entryClientPath = path.join(__dirname, 'frameworks', framework, 'entry.client.js').replace(/\\/g, '/');
|
|
162
|
+
const code = `
|
|
163
|
+
${imports}
|
|
164
|
+
${layoutImport}
|
|
165
|
+
${notFoundImport}
|
|
166
|
+
import DefaultNotFound from '${defaultNotFoundPath}';
|
|
167
|
+
|
|
168
|
+
window.__VATTS_COMPONENTS__ = {
|
|
169
|
+
${componentRegistration}
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
window.__VATTS_ROUTES__ = ${JSON.stringify(clientRoutes)};
|
|
173
|
+
|
|
174
|
+
${layoutRegistration}
|
|
175
|
+
${notFoundRegistration}
|
|
176
|
+
window.__VATTS_DEFAULT_NOT_FOUND__ = DefaultNotFound;
|
|
177
|
+
|
|
178
|
+
import '${entryClientPath}';
|
|
171
179
|
`;
|
|
172
180
|
return { contents: code, loader: 'js', resolveDir: projectDir };
|
|
173
181
|
});
|
|
@@ -187,13 +195,13 @@ const nodeBuiltinStubPlugin = () => ({
|
|
|
187
195
|
return { path: args.path, namespace: 'node-stub' };
|
|
188
196
|
});
|
|
189
197
|
build.onLoad({ filter: /.*/, namespace: 'node-stub' }, () => ({
|
|
190
|
-
contents: `
|
|
191
|
-
function noop() {}
|
|
192
|
-
export const resolve = noop; export const join = noop; export const parse = () => ({});
|
|
193
|
-
export const createHash = () => ({ update: () => ({ digest: () => '' }) });
|
|
194
|
-
export class EventEmitter { on(){} emit(){} off(){} once(){} }
|
|
195
|
-
export class Readable extends EventEmitter {} export class Writable extends EventEmitter {}
|
|
196
|
-
export default Object.assign(noop, { resolve, join, parse, createHash, EventEmitter, Readable, Writable });
|
|
198
|
+
contents: `
|
|
199
|
+
function noop() {}
|
|
200
|
+
export const resolve = noop; export const join = noop; export const parse = () => ({});
|
|
201
|
+
export const createHash = () => ({ update: () => ({ digest: () => '' }) });
|
|
202
|
+
export class EventEmitter { on(){} emit(){} off(){} once(){} }
|
|
203
|
+
export class Readable extends EventEmitter {} export class Writable extends EventEmitter {}
|
|
204
|
+
export default Object.assign(noop, { resolve, join, parse, createHash, EventEmitter, Readable, Writable });
|
|
197
205
|
`,
|
|
198
206
|
loader: 'js'
|
|
199
207
|
}));
|
|
@@ -207,9 +215,9 @@ const smartSvgPlugin = () => ({
|
|
|
207
215
|
const base64 = buffer.toString('base64');
|
|
208
216
|
const content = buffer.toString('utf8');
|
|
209
217
|
return {
|
|
210
|
-
contents: `
|
|
211
|
-
export default "data:image/svg+xml;base64,${base64}";
|
|
212
|
-
export const svgContent = ${JSON.stringify(content)};
|
|
218
|
+
contents: `
|
|
219
|
+
export default "data:image/svg+xml;base64,${base64}";
|
|
220
|
+
export const svgContent = ${JSON.stringify(content)};
|
|
213
221
|
`,
|
|
214
222
|
loader: 'js'
|
|
215
223
|
};
|
|
@@ -296,12 +304,48 @@ async function getFrameworkConfig(vattsOptions, outdir, isProduction, isWatch =
|
|
|
296
304
|
];
|
|
297
305
|
const pluginConfig = { prePlugins, postPlugins, isWatch };
|
|
298
306
|
const entryPoint = 'virtual:vatts-entry';
|
|
307
|
+
let config;
|
|
299
308
|
if (framework === 'vue') {
|
|
300
|
-
|
|
309
|
+
config = await createVueConfig(entryPoint, outdir, isProduction, pluginConfig);
|
|
301
310
|
}
|
|
302
311
|
else {
|
|
303
|
-
|
|
312
|
+
config = await createReactConfig(entryPoint, outdir, isProduction, pluginConfig);
|
|
304
313
|
}
|
|
314
|
+
// --- INÍCIO DA IMPLEMENTAÇÃO DE CHUNKS E OTIMIZAÇÃO MÁXIMA ---
|
|
315
|
+
const entryPoints = { 'main': entryPoint };
|
|
316
|
+
if (vattsOptions.layout) {
|
|
317
|
+
entryPoints['pages/layout'] = vattsOptions.layout.componentPath;
|
|
318
|
+
}
|
|
319
|
+
if (vattsOptions.notFound) {
|
|
320
|
+
entryPoints['pages/not-found'] = vattsOptions.notFound.componentPath;
|
|
321
|
+
}
|
|
322
|
+
if (vattsOptions.routes && Array.isArray(vattsOptions.routes)) {
|
|
323
|
+
vattsOptions.routes.forEach((route, index) => {
|
|
324
|
+
const fileName = path.basename(route.componentPath, path.extname(route.componentPath));
|
|
325
|
+
entryPoints[`pages/${fileName}-${index}`] = route.componentPath;
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
config.entryPoints = entryPoints;
|
|
329
|
+
config.format = 'esm';
|
|
330
|
+
config.splitting = true;
|
|
331
|
+
config.chunkNames = 'chunks/[name]-[hash]';
|
|
332
|
+
config.assetNames = 'assets/[name]-[hash]';
|
|
333
|
+
config.treeShaking = true;
|
|
334
|
+
config.legalComments = 'none';
|
|
335
|
+
config.define = {
|
|
336
|
+
...(config.define || {}),
|
|
337
|
+
'process.env.NODE_ENV': isProduction ? '"production"' : '"development"'
|
|
338
|
+
};
|
|
339
|
+
if (isProduction) {
|
|
340
|
+
config.minify = true;
|
|
341
|
+
config.minifyWhitespace = true;
|
|
342
|
+
config.minifyIdentifiers = true;
|
|
343
|
+
config.minifySyntax = true;
|
|
344
|
+
config.target = ['es2020'];
|
|
345
|
+
}
|
|
346
|
+
// --- FIM DA IMPLEMENTAÇÃO ---
|
|
347
|
+
config.entryNames = '[name]-[hash]';
|
|
348
|
+
return config;
|
|
305
349
|
}
|
|
306
350
|
async function buildWithChunks(vattsOptions, outdir, isProduction = false) {
|
|
307
351
|
await cleanDirectoryExcept(outdir, excludedFiles);
|
|
@@ -313,24 +357,18 @@ async function buildWithChunks(vattsOptions, outdir, isProduction = false) {
|
|
|
313
357
|
try {
|
|
314
358
|
const { runOptimizer } = require('./api/optimizer');
|
|
315
359
|
const optimizedDir = path.join(outdir, 'optimized');
|
|
316
|
-
runOptimizer({ targetDir: outdir, outputDir: optimizedDir, ignoredPatterns: ['assets'] });
|
|
317
|
-
const rootFiles = await readdir(outdir);
|
|
318
|
-
for (const file of rootFiles) {
|
|
319
|
-
if ((file.startsWith('main') && file.endsWith('.js')) || file === 'chunks') {
|
|
320
|
-
await rm(path.join(outdir, file), { recursive: true, force: true });
|
|
321
|
-
}
|
|
322
|
-
}
|
|
360
|
+
runOptimizer({ targetDir: outdir, outputDir: optimizedDir, ignoredPatterns: ['assets', 'chunks', 'pages'] });
|
|
323
361
|
if (fs.existsSync(optimizedDir)) {
|
|
324
362
|
const optFiles = await readdir(optimizedDir);
|
|
325
363
|
for (const file of optFiles) {
|
|
326
364
|
const srcPath = path.join(optimizedDir, file);
|
|
327
365
|
const destPath = path.join(outdir, file);
|
|
328
|
-
await rm(destPath, { recursive: true, force: true });
|
|
366
|
+
await rm(destPath, { recursive: true, force: true }).catch(() => { });
|
|
329
367
|
await rename(srcPath, destPath);
|
|
330
368
|
}
|
|
331
|
-
await rm(optimizedDir, { recursive: true, force: true });
|
|
369
|
+
await rm(optimizedDir, { recursive: true, force: true }).catch(() => { });
|
|
332
370
|
}
|
|
333
|
-
Console.log("✅ Build successfully optimized with
|
|
371
|
+
Console.log("✅ Build successfully optimized with heavy chunking enabled.");
|
|
334
372
|
}
|
|
335
373
|
catch (err) {
|
|
336
374
|
Console.error('Native optimization failed:', err);
|
|
@@ -351,7 +389,6 @@ async function watchWithChunks(vattsOptions, outdir, hotReloadManager = null) {
|
|
|
351
389
|
config.plugins.push({
|
|
352
390
|
name: 'watch-notifier',
|
|
353
391
|
setup(build) {
|
|
354
|
-
// AGORA ELE AVISA O HOT RELOAD EXATAMENTE QUANDO O ESBUILD INICIA
|
|
355
392
|
build.onStart(() => {
|
|
356
393
|
if (hotReloadManager && typeof hotReloadManager.onBuildStart === 'function') {
|
|
357
394
|
hotReloadManager.onBuildStart();
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface VattsBuildError {
|
|
2
|
+
message?: string;
|
|
3
|
+
name?: string;
|
|
4
|
+
stack?: string;
|
|
5
|
+
frame?: string;
|
|
6
|
+
id?: string;
|
|
7
|
+
plugin?: string;
|
|
8
|
+
pluginCode?: string;
|
|
9
|
+
loc?: any;
|
|
10
|
+
watchFiles?: any;
|
|
11
|
+
cause?: any;
|
|
12
|
+
ts?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface RouteConfig {
|
|
15
|
+
pattern: string;
|
|
16
|
+
componentPath: string;
|
|
17
|
+
metadata?: any;
|
|
18
|
+
}
|
|
19
|
+
export declare function renderCriticalError(error: any, framework: string): void;
|
|
20
|
+
export declare function findRouteForPath(path: string, routes: RouteConfig[]): {
|
|
21
|
+
componentPath: string;
|
|
22
|
+
params: {
|
|
23
|
+
[key: string]: string;
|
|
24
|
+
};
|
|
25
|
+
metadata: any;
|
|
26
|
+
} | null;
|
|
27
|
+
export declare function updateDocumentTitle(title?: string): void;
|
|
28
|
+
export declare function copyBuildError(error: VattsBuildError | null): Promise<void>;
|
|
29
|
+
export declare function setupBuildErrorEvents(onErr: (error: VattsBuildError) => void, onOk: () => void): () => void;
|
|
30
|
+
export declare function setupHMREvents(onComponentUpdate: (file: string | null, timestamp: number) => void): () => void;
|
|
31
|
+
export declare function dispatchHmrReady(pending: {
|
|
32
|
+
file: string | null;
|
|
33
|
+
timestamp: number;
|
|
34
|
+
} | null): void;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* This file is part of the Vatts.js Project.
|
|
4
|
+
* Copyright (c) 2026 mfraz
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* ...
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.renderCriticalError = renderCriticalError;
|
|
11
|
+
exports.findRouteForPath = findRouteForPath;
|
|
12
|
+
exports.updateDocumentTitle = updateDocumentTitle;
|
|
13
|
+
exports.copyBuildError = copyBuildError;
|
|
14
|
+
exports.setupBuildErrorEvents = setupBuildErrorEvents;
|
|
15
|
+
exports.setupHMREvents = setupHMREvents;
|
|
16
|
+
exports.dispatchHmrReady = dispatchHmrReady;
|
|
17
|
+
// --- Funções de Dados e Inicialização ---
|
|
18
|
+
function renderCriticalError(error, framework) {
|
|
19
|
+
console.error(`[Vatts Core] ❌ Critical Error rendering application (${framework}):`, error);
|
|
20
|
+
if (typeof document !== 'undefined') {
|
|
21
|
+
document.body.innerHTML = `
|
|
22
|
+
<div style="font-family: monospace; padding: 20px; color: #ff4444; background: #000000; min-height: 100vh;">
|
|
23
|
+
<h1>Vatts Client Error (${framework})</h1>
|
|
24
|
+
<p>A critical error occurred while initializing the application.</p>
|
|
25
|
+
<pre style="background: #0a0a0a; padding: 15px; border-radius: 5px; overflow: auto;">${error?.message || error}</pre>
|
|
26
|
+
<pre style="color: #666; font-size: 12px; margin-top: 10px;">${error?.stack || ''}</pre>
|
|
27
|
+
</div>
|
|
28
|
+
`;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
// --- Roteamento e Utils ---
|
|
32
|
+
function findRouteForPath(path, routes) {
|
|
33
|
+
for (const route of routes) {
|
|
34
|
+
const regexPattern = route.pattern
|
|
35
|
+
.replace(/\[\[\.\.\.(\w+)\]\]/g, '(?<$1>.+)?')
|
|
36
|
+
.replace(/\[\.\.\.(\w+)\]/g, '(?<$1>.+)')
|
|
37
|
+
.replace(/\/\[\[(\w+)\]\]/g, '(?:/(?<$1>[^/]+))?')
|
|
38
|
+
.replace(/\[\[(\w+)\]\]/g, '(?<$1>[^/]+)?')
|
|
39
|
+
.replace(/\[(\w+)\]/g, '(?<$1>[^/]+)');
|
|
40
|
+
const regex = new RegExp(`^${regexPattern}/?$`);
|
|
41
|
+
const match = path.match(regex);
|
|
42
|
+
if (match) {
|
|
43
|
+
return {
|
|
44
|
+
componentPath: route.componentPath,
|
|
45
|
+
params: match.groups || {},
|
|
46
|
+
metadata: route.metadata
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
function updateDocumentTitle(title) {
|
|
53
|
+
if (title != null) {
|
|
54
|
+
try {
|
|
55
|
+
window.document.title = decodeURIComponent(escape(title));
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
window.document.title = title;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async function copyBuildError(error) {
|
|
63
|
+
try {
|
|
64
|
+
if (!error)
|
|
65
|
+
return;
|
|
66
|
+
const payload = JSON.stringify(error, null, 2);
|
|
67
|
+
await navigator.clipboard.writeText(payload);
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
console.error('[Vatts Core] ❌ Falha ao copiar o erro.');
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// --- Gerenciadores de Eventos (HMR & Errors) ---
|
|
74
|
+
function setupBuildErrorEvents(onErr, onOk) {
|
|
75
|
+
const handleErr = (ev) => {
|
|
76
|
+
const e = ev?.detail;
|
|
77
|
+
console.error('[Vatts Core] 🛑 Erro de build (vatts:build-error):', e);
|
|
78
|
+
window.__VATTS_HAD_BUILD_ERROR__ = true;
|
|
79
|
+
onErr(e);
|
|
80
|
+
};
|
|
81
|
+
const handleOk = () => {
|
|
82
|
+
const hadError = window.__VATTS_HAD_BUILD_ERROR__;
|
|
83
|
+
onOk();
|
|
84
|
+
if (hadError) {
|
|
85
|
+
window.__VATTS_HAD_BUILD_ERROR__ = false;
|
|
86
|
+
console.log('[Vatts Core] 🔄 Erro foi corrigido! Sincronizando dados de rotas com servidor...');
|
|
87
|
+
setTimeout(() => {
|
|
88
|
+
window.location.reload();
|
|
89
|
+
}, 300);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
window.addEventListener('vatts:build-error', handleErr);
|
|
93
|
+
window.addEventListener('vatts:build-ok', handleOk);
|
|
94
|
+
return () => {
|
|
95
|
+
window.removeEventListener('vatts:build-error', handleErr);
|
|
96
|
+
window.removeEventListener('vatts:build-ok', handleOk);
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function setupHMREvents(onComponentUpdate) {
|
|
100
|
+
window.__HWEB_HMR__ = true;
|
|
101
|
+
const handleHMRUpdate = (event) => {
|
|
102
|
+
const { file, timestamp } = event.detail;
|
|
103
|
+
const fileName = file ? file.split('/').pop()?.split('\\').pop() : 'unknown';
|
|
104
|
+
try {
|
|
105
|
+
const fileLower = (file || '').toLowerCase();
|
|
106
|
+
const isPageFile = fileLower.includes('page.tsx') || fileLower.includes('page.jsx') ||
|
|
107
|
+
fileLower.includes('page.ts') || fileLower.includes('page.js') ||
|
|
108
|
+
fileLower.includes('page.vue');
|
|
109
|
+
if (isPageFile) {
|
|
110
|
+
console.log('[Vatts Core] 📄 Page file HMR detected, reloading to sync route data...');
|
|
111
|
+
setTimeout(() => window.location.reload(), 300);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
console.log(`[Vatts Core] ⚡ HMR Update Triggered: ${fileName}`);
|
|
115
|
+
onComponentUpdate(file || null, timestamp);
|
|
116
|
+
}
|
|
117
|
+
catch (error) {
|
|
118
|
+
console.error('[Vatts Core] ❌ HMR Error:', error);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
window.addEventListener('hmr:component-update', handleHMRUpdate);
|
|
122
|
+
return () => window.removeEventListener('hmr:component-update', handleHMRUpdate);
|
|
123
|
+
}
|
|
124
|
+
function dispatchHmrReady(pending) {
|
|
125
|
+
if (!pending)
|
|
126
|
+
return;
|
|
127
|
+
window.dispatchEvent(new CustomEvent('vatts:hmr-ready', { detail: pending }));
|
|
128
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { Link } from './components/Link.tsx';
|
|
2
|
+
export { RouteConfig, Metadata } from "../../types.ts";
|
|
3
|
+
export { router } from '../../client/clientRouter.ts';
|
|
4
|
+
export { requireDynamic } from '../../client/requireDynamic.ts';
|
|
5
|
+
export { importServer } from '../../client/rpc.ts';
|
|
6
|
+
export { importPhpServer } from '../../client/rpcPhp.ts';
|
|
7
|
+
export { default as Image } from "./components/image/Image.tsx";
|
|
8
|
+
export { default as VattsImage } from "./components/image/Image.tsx";
|
|
@@ -21,18 +21,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
22
|
exports.VattsImage = exports.Image = exports.importPhpServer = exports.importServer = exports.requireDynamic = exports.router = exports.Link = void 0;
|
|
23
23
|
// Este arquivo exporta apenas código seguro para o cliente (navegador)
|
|
24
|
-
var
|
|
25
|
-
Object.defineProperty(exports, "Link", { enumerable: true, get: function () { return
|
|
26
|
-
var
|
|
27
|
-
Object.defineProperty(exports, "router", { enumerable: true, get: function () { return
|
|
28
|
-
var
|
|
29
|
-
Object.defineProperty(exports, "requireDynamic", { enumerable: true, get: function () { return
|
|
24
|
+
var Link_tsx_1 = require("./components/Link.js");
|
|
25
|
+
Object.defineProperty(exports, "Link", { enumerable: true, get: function () { return Link_tsx_1.Link; } });
|
|
26
|
+
var clientRouter_ts_1 = require("../../client/clientRouter.js");
|
|
27
|
+
Object.defineProperty(exports, "router", { enumerable: true, get: function () { return clientRouter_ts_1.router; } });
|
|
28
|
+
var requireDynamic_ts_1 = require("../../client/requireDynamic.js");
|
|
29
|
+
Object.defineProperty(exports, "requireDynamic", { enumerable: true, get: function () { return requireDynamic_ts_1.requireDynamic; } });
|
|
30
30
|
// RPC (client-side)
|
|
31
|
-
var
|
|
32
|
-
Object.defineProperty(exports, "importServer", { enumerable: true, get: function () { return
|
|
33
|
-
var
|
|
34
|
-
Object.defineProperty(exports, "importPhpServer", { enumerable: true, get: function () { return
|
|
35
|
-
var
|
|
36
|
-
Object.defineProperty(exports, "Image", { enumerable: true, get: function () { return __importDefault(
|
|
37
|
-
var
|
|
38
|
-
Object.defineProperty(exports, "VattsImage", { enumerable: true, get: function () { return __importDefault(
|
|
31
|
+
var rpc_ts_1 = require("../../client/rpc.js");
|
|
32
|
+
Object.defineProperty(exports, "importServer", { enumerable: true, get: function () { return rpc_ts_1.importServer; } });
|
|
33
|
+
var rpcPhp_ts_1 = require("../../client/rpcPhp.js");
|
|
34
|
+
Object.defineProperty(exports, "importPhpServer", { enumerable: true, get: function () { return rpcPhp_ts_1.importPhpServer; } });
|
|
35
|
+
var Image_tsx_1 = require("./components/image/Image.js");
|
|
36
|
+
Object.defineProperty(exports, "Image", { enumerable: true, get: function () { return __importDefault(Image_tsx_1).default; } });
|
|
37
|
+
var Image_tsx_2 = require("./components/image/Image.js");
|
|
38
|
+
Object.defineProperty(exports, "VattsImage", { enumerable: true, get: function () { return __importDefault(Image_tsx_2).default; } });
|
|
@@ -21,12 +21,12 @@ exports.Link = Link;
|
|
|
21
21
|
* limitations under the License.
|
|
22
22
|
*/
|
|
23
23
|
const react_1 = __importDefault(require("react"));
|
|
24
|
-
const
|
|
24
|
+
const clientRouter_ts_1 = require("../../../client/clientRouter.js");
|
|
25
25
|
function Link({ href, children, ...props }) {
|
|
26
26
|
const handleClick = async (e) => {
|
|
27
27
|
e.preventDefault();
|
|
28
28
|
// Usa o novo sistema de router
|
|
29
|
-
await
|
|
29
|
+
await clientRouter_ts_1.router.push(href);
|
|
30
30
|
};
|
|
31
31
|
return (react_1.default.createElement("a", { href: href, ...props, onClick: handleClick }, children));
|
|
32
32
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Root } from 'react-dom/client';
|
|
2
|
+
import '../themes/VattsDevBadge';
|
|
3
|
+
import '../themes/ErrorModal';
|
|
4
|
+
declare global {
|
|
5
|
+
namespace JSX {
|
|
6
|
+
interface IntrinsicElements {
|
|
7
|
+
'vatts-dev-badge': any;
|
|
8
|
+
'vatts-error-modal': any;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
interface Window {
|
|
12
|
+
__VATTS_ROOT__?: Root;
|
|
13
|
+
}
|
|
14
|
+
}
|