vatts 1.2.0-alpha.1 → 1.2.0-test.0

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 (47) hide show
  1. package/dist/adapters/express.js +5 -1
  2. package/dist/adapters/factory.js +58 -21
  3. package/dist/adapters/fastify.js +5 -1
  4. package/dist/adapters/native.js +5 -1
  5. package/dist/api/console.js +25 -17
  6. package/dist/api/framework.js +22 -15
  7. package/dist/api/http.js +7 -2
  8. package/dist/builder.js +19 -10
  9. package/dist/client/clientRouter.js +6 -2
  10. package/dist/client/rpc.js +7 -4
  11. package/dist/env/env.js +18 -11
  12. package/dist/global/global.d.ts +177 -122
  13. package/dist/helpers.js +108 -67
  14. package/dist/hotReload.d.ts +6 -0
  15. package/dist/hotReload.js +179 -31
  16. package/dist/index.js +159 -115
  17. package/dist/loaders.js +29 -13
  18. package/dist/react/BuildingPage.d.ts +2 -1
  19. package/dist/react/BuildingPage.js +47 -4
  20. package/dist/react/DefaultNotFound.d.ts +2 -1
  21. package/dist/react/DefaultNotFound.js +92 -17
  22. package/dist/react/DevIndicator.js +66 -23
  23. package/dist/react/ErrorModal.js +91 -40
  24. package/dist/react/Link.d.ts +2 -2
  25. package/dist/react/Link.js +27 -5
  26. package/dist/react/client.js +16 -5
  27. package/dist/react/entry.client.js +70 -30
  28. package/dist/react/image/Image.js +8 -3
  29. package/dist/react/renderer-react.js +53 -25
  30. package/dist/renderer.d.ts +4 -0
  31. package/dist/renderer.js +13 -5
  32. package/dist/router.js +82 -63
  33. package/dist/rpc/annotations.js +7 -3
  34. package/dist/rpc/server.js +21 -15
  35. package/dist/rpc/types.js +4 -1
  36. package/dist/types/framework.js +2 -1
  37. package/dist/types.js +2 -1
  38. package/dist/vue/App.vue +34 -37
  39. package/dist/vue/BuildingPage.vue +118 -102
  40. package/dist/vue/ErrorModal.vue +19 -37
  41. package/dist/vue/Link.vue +8 -7
  42. package/dist/vue/client.js +16 -6
  43. package/dist/vue/entry.client.js +8 -3
  44. package/dist/vue/image/Image.vue +25 -19
  45. package/dist/vue/renderer.vue.js +80 -26
  46. package/package.json +25 -12
  47. package/dist/global/global.js +0 -17
@@ -1,9 +1,14 @@
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 });
1
6
  /*
2
7
  * This file is part of the Vatts.js Project.
3
8
  * Copyright (c) 2026 itsmuzin
4
9
  */
5
- import { createApp } from 'vue';
6
- import App from './App.vue';
10
+ const vue_1 = require("vue");
11
+ const App_vue_1 = __importDefault(require("./App.vue"));
7
12
  // --- Inicialização do Cliente (CSR - Client-Side Rendering) ---
8
13
  function deobfuscateData(obfuscated) {
9
14
  try {
@@ -58,7 +63,7 @@ function initializeClient() {
58
63
  }
59
64
  }
60
65
  // Cria a instância do Vue
61
- const app = createApp(App, {
66
+ const app = (0, vue_1.createApp)(App_vue_1.default, {
62
67
  componentMap,
63
68
  routes: initialData.routes,
64
69
  initialComponentPath: initialData.initialComponentPath,
@@ -15,25 +15,31 @@
15
15
  * limitations under the License.
16
16
  -->
17
17
 
18
- <script setup lang="ts">
19
- import { computed, type StyleValue } from 'vue';
20
-
21
- interface VattsImageProps {
22
- src: string;
23
- width?: number | string;
24
- height?: number | string;
25
- quality?: number;
26
- priority?: boolean;
27
- alt?: string;
28
- }
29
-
30
- const props = withDefaults(defineProps<VattsImageProps>(), {
31
- quality: 75,
32
- priority: false,
33
- alt: ""
18
+ <script setup>
19
+ import { computed } from 'vue';
20
+
21
+ const props = defineProps({
22
+ src: {
23
+ type: String,
24
+ required: true
25
+ },
26
+ width: [Number, String],
27
+ height: [Number, String],
28
+ quality: {
29
+ type: Number,
30
+ default: 75
31
+ },
32
+ priority: {
33
+ type: Boolean,
34
+ default: false
35
+ },
36
+ alt: {
37
+ type: String,
38
+ default: ""
39
+ }
34
40
  });
35
41
 
36
- const getBaseUrl = (): string | null => {
42
+ const getBaseUrl = () => {
37
43
  if (typeof window === "undefined") return null;
38
44
  return window.location.origin;
39
45
  };
@@ -72,7 +78,7 @@ const optimizedSrc = computed(() => {
72
78
  return `/_vatts/image?${params.toString()}`;
73
79
  });
74
80
 
75
- const baseStyle = computed<StyleValue>(() => {
81
+ const baseStyle = computed(() => {
76
82
  return {
77
83
  width: props.width ? (typeof props.width === 'number' ? `${props.width}px` : props.width) : 'auto',
78
84
  height: props.height ? (typeof props.height === 'number' ? `${props.height}px` : props.height) : 'auto',
@@ -80,7 +86,7 @@ const baseStyle = computed<StyleValue>(() => {
80
86
  });
81
87
 
82
88
  // Remove "px" para os atributos nativos width/height da tag img
83
- const cleanDimension = (val?: string | number) => {
89
+ const cleanDimension = (val) => {
84
90
  if (typeof val === 'string') return val.replace('px', '');
85
91
  return val;
86
92
  };
@@ -1,8 +1,48 @@
1
- import { getLayout } from '../router';
2
- import fs from 'fs';
3
- import path from 'path';
4
- import * as vue from "vue";
5
- import * as vueServerRenderer from "@vue/server-renderer";
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.renderVue = renderVue;
40
+ const router_1 = require("../router");
41
+ const fs_1 = __importDefault(require("fs"));
42
+ const path_1 = __importDefault(require("path"));
43
+ const vue = __importStar(require("vue"));
44
+ const vueServerRenderer = __importStar(require("@vue/server-renderer"));
45
+ const BuildingPage_vue_1 = __importDefault(require("./BuildingPage.vue"));
6
46
  // --- Helpers de Servidor (Duplicados para manter isolamento) ---
7
47
  function requireWithoutStyles(modulePath) {
8
48
  const extensions = ['.css', '.scss', '.sass', '.less', '.png', '.jpg', '.jpeg', '.gif', '.svg'];
@@ -44,14 +84,14 @@ function obfuscateData(data) {
44
84
  * e gerar links de preload para injetar no head.
45
85
  */
46
86
  function extractComponentPreloads(componentPath) {
47
- if (!componentPath || !fs.existsSync(componentPath))
87
+ if (!componentPath || !fs_1.default.existsSync(componentPath))
48
88
  return [];
49
89
  try {
50
- const content = fs.readFileSync(componentPath, 'utf8');
90
+ const content = fs_1.default.readFileSync(componentPath, 'utf8');
51
91
  const tags = new Set();
52
92
  const processPath = (fullPath) => {
53
- const filename = path.basename(fullPath);
54
- const ext = path.extname(filename).toLowerCase();
93
+ const filename = path_1.default.basename(fullPath);
94
+ const ext = path_1.default.extname(filename).toLowerCase();
55
95
  // Assume estrutura flattened do Vatts em /_vatts/assets/ onde os arquivos finais residem
56
96
  const publicUrl = `/_vatts/assets/${filename}`;
57
97
  if (['.mp4', '.webm'].includes(ext)) {
@@ -122,7 +162,7 @@ function ensureVueComponent(existingComponent, componentPath) {
122
162
  // Se não tiver as ferramentas de build, não podemos corrigir
123
163
  return component;
124
164
  }
125
- const source = fs.readFileSync(componentPath, 'utf8');
165
+ const source = fs_1.default.readFileSync(componentPath, 'utf8');
126
166
  const { descriptor } = sfc.parse(source, { filename: componentPath });
127
167
  if (descriptor.template) {
128
168
  // Tenta obter bindings do script para otimização (opcional, mas bom para setup)
@@ -271,21 +311,21 @@ function generateMetaTags(metadata) {
271
311
  }
272
312
  function getBuildAssets(req) {
273
313
  const projectDir = process.cwd();
274
- const distDir = path.join(projectDir, '.vatts');
275
- const assetsDir = path.join(distDir, 'assets');
276
- if (!fs.existsSync(distDir))
314
+ const distDir = path_1.default.join(projectDir, '.vatts');
315
+ const assetsDir = path_1.default.join(distDir, 'assets');
316
+ if (!fs_1.default.existsSync(distDir))
277
317
  return null;
278
318
  let scripts = [];
279
319
  let styles = [];
280
320
  const processDirectory = (directory, urlPrefix) => {
281
- if (!fs.existsSync(directory))
321
+ if (!fs_1.default.existsSync(directory))
282
322
  return;
283
- const files = fs.readdirSync(directory);
323
+ const files = fs_1.default.readdirSync(directory);
284
324
  files.forEach(file => {
285
325
  if (file.endsWith('.map'))
286
326
  return;
287
- const fullPath = path.join(directory, file);
288
- if (fs.statSync(fullPath).isFile()) {
327
+ const fullPath = path_1.default.join(directory, file);
328
+ if (fs_1.default.statSync(fullPath).isFile()) {
289
329
  if (file.endsWith('.js'))
290
330
  scripts.push(`${urlPrefix}/${file}`);
291
331
  else if (file.endsWith('.css'))
@@ -294,9 +334,9 @@ function getBuildAssets(req) {
294
334
  });
295
335
  };
296
336
  try {
297
- const manifestPath = path.join(distDir, 'manifest.json');
298
- if (fs.existsSync(manifestPath)) {
299
- const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
337
+ const manifestPath = path_1.default.join(distDir, 'manifest.json');
338
+ if (fs_1.default.existsSync(manifestPath)) {
339
+ const manifest = JSON.parse(fs_1.default.readFileSync(manifestPath, 'utf8'));
300
340
  const manifestFiles = Object.values(manifest);
301
341
  scripts = manifestFiles.filter((f) => f.endsWith('.js')).map((f) => `/_vatts/${f}`);
302
342
  styles = manifestFiles.filter((f) => f.endsWith('.css')).map((f) => `/_vatts/${f}`);
@@ -321,7 +361,7 @@ function getBuildAssets(req) {
321
361
  return null;
322
362
  }
323
363
  }
324
- export async function renderVue({ req, res, route, params, allRoutes }) {
364
+ async function renderVue({ req, res, route, params, allRoutes }) {
325
365
  if (!vue) {
326
366
  res.statusCode = 500;
327
367
  res.end('Vue dependencies not installed.');
@@ -340,15 +380,29 @@ export async function renderVue({ req, res, route, params, allRoutes }) {
340
380
  try {
341
381
  const assets = getBuildAssets(req);
342
382
  if (!assets || assets.scripts.length === 0) {
383
+ const RootComponent = {
384
+ setup() {
385
+ return () => {
386
+ return BuildingPage_vue_1.default ? h(BuildingPage_vue_1.default, { params }) : h('div', 'Page not found/loaded');
387
+ };
388
+ }
389
+ };
390
+ const app = createSSRApp(RootComponent);
391
+ // 5. Stream
392
+ const stream = renderToNodeStream(app);
343
393
  res.setHeader('Content-Type', 'text/html');
344
- res.end('<!DOCTYPE html><html><body><div style="display:flex;justify-content:center;align-items:center;height:100vh;font-family:sans-serif;">Building...</div><script>setTimeout(()=>window.location.reload(), 1000)</script></body></html>');
394
+ // enviar stream direto
395
+ stream.pipe(res, { end: false });
396
+ stream.on('end', () => {
397
+ res.end();
398
+ });
345
399
  return;
346
400
  }
347
401
  // 1. Layout (Carrega e Corrige se necessário)
348
- const layoutInfo = getLayout();
402
+ const layoutInfo = (0, router_1.getLayout)();
349
403
  let LayoutComponent = null;
350
404
  if (layoutInfo) {
351
- LayoutComponent = ensureVueComponent(null, path.resolve(process.cwd(), layoutInfo.componentPath));
405
+ LayoutComponent = ensureVueComponent(null, path_1.default.resolve(process.cwd(), layoutInfo.componentPath));
352
406
  }
353
407
  // 2. Metadata
354
408
  let metadata = { title: 'Vatts App' };
@@ -386,13 +440,13 @@ export async function renderVue({ req, res, route, params, allRoutes }) {
386
440
  // Otimização: Adiciona modulepreload para scripts principais do bundle
387
441
  const scriptPreloadsHtml = assets.scripts.map(src => `<link rel="modulepreload" href="${src}">`).join('\n');
388
442
  // Otimização: Intercepta assets do componente atual para preload
389
- const componentPreloads = extractComponentPreloads(route.componentPath ? path.resolve(process.cwd(), route.componentPath) : '');
443
+ const componentPreloads = extractComponentPreloads(route.componentPath ? path_1.default.resolve(process.cwd(), route.componentPath) : '');
390
444
  const componentPreloadsHtml = componentPreloads.join('\n');
391
445
  const stylesHtml = assets.styles.map(styleUrl => `<link rel="stylesheet" href="${styleUrl}">`).join('\n');
392
446
  const scriptsHtml = assets.scripts.map(src => `<script type="module" src="${src}"></script>`).join('\n');
393
447
  // 4. Create Vue App
394
448
  // Carrega o componente da rota e aplica a correção (compile template) se o loader falhou
395
- let PageComponent = ensureVueComponent(route.component, route.componentPath ? path.resolve(process.cwd(), route.componentPath) : '');
449
+ let PageComponent = ensureVueComponent(route.component, route.componentPath ? path_1.default.resolve(process.cwd(), route.componentPath) : '');
396
450
  // Componente Root
397
451
  const RootComponent = {
398
452
  setup() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vatts",
3
- "version": "1.2.0-alpha.1",
3
+ "version": "1.2.0-test.0",
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": "itsmuzin",
@@ -21,6 +21,19 @@
21
21
  "bin": {
22
22
  "vatts": "./dist/bin/vatts.js"
23
23
  },
24
+ "typesVersions": {
25
+ "*": {
26
+ "global": [
27
+ "dist/global/global.d.ts"
28
+ ],
29
+ "console": [
30
+ "dist/api/console.d.ts"
31
+ ],
32
+ "rpc": [
33
+ "dist/rpc/annotations.d.ts"
34
+ ]
35
+ }
36
+ },
24
37
  "exports": {
25
38
  ".": {
26
39
  "types": "./dist/index.d.ts",
@@ -48,7 +61,8 @@
48
61
  "require": "./dist/helpers.js"
49
62
  },
50
63
  "./global": {
51
- "types": "./dist/global/global.d.ts"
64
+ "types": "./dist/global/global.d.ts",
65
+ "import": "./dist/global/global.d.ts"
52
66
  },
53
67
  "./eslint": {
54
68
  "types": "./dist/eslint/index.d.ts",
@@ -61,13 +75,6 @@
61
75
  "require": "./dist/rpc/annotations.js"
62
76
  }
63
77
  },
64
- "peerDependencies": {
65
- "express": "^4.0.0",
66
- "fastify": "^5.6.1",
67
- "react": "^19.2.3",
68
- "react-dom": "^19.2.3",
69
- "vue": "^3.5.27"
70
- },
71
78
  "peerDependenciesMeta": {
72
79
  "express": {
73
80
  "optional": true
@@ -85,6 +92,13 @@
85
92
  "optional": true
86
93
  }
87
94
  },
95
+ "peerDependencies": {
96
+ "express": "^4.0.0",
97
+ "fastify": "^5.6.1",
98
+ "react": "^19.2.3",
99
+ "react-dom": "^19.2.3",
100
+ "vue": "^3.5.27"
101
+ },
88
102
  "dependencies": {
89
103
  "@rollup/plugin-alias": "^6.0.0",
90
104
  "@rollup/plugin-commonjs": "^29.0.0",
@@ -95,7 +109,7 @@
95
109
  "chokidar": "^3.6.0",
96
110
  "commander": "^14.0.2",
97
111
  "esbuild": "^0.27.2",
98
- "rollup": "^4.55.2",
112
+ "rollup": "^4.56.0",
99
113
  "rollup-plugin-esbuild": "^6.2.1",
100
114
  "rollup-plugin-vue": "^6.0.0",
101
115
  "sharp": "^0.34.5",
@@ -114,7 +128,6 @@
114
128
  "@types/react": "^19.2.9",
115
129
  "@types/react-dom": "^19.2.3",
116
130
  "@types/ws": "^8.18.1",
117
- "@vue/server-renderer": "^3.5.27",
118
131
  "@vue/tsconfig": "^0.8.1",
119
132
  "copyfiles": "^2.4.1",
120
133
  "image-size": "^2.0.2",
@@ -122,6 +135,6 @@
122
135
  "vue-tsc": "^3.2.3"
123
136
  },
124
137
  "scripts": {
125
- "build": "tsc && copyfiles -u 1 \"src/**/*.vue\" dist"
138
+ "build": "tsc && copyfiles -u 1 \"src/**/*.{vue,d.ts}\" dist"
126
139
  }
127
140
  }
@@ -1,17 +0,0 @@
1
- "use strict";
2
- /*
3
- * This file is part of the Vatts.js Project.
4
- * Copyright (c) 2026 itsmuzin
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */