vatts 1.2.0-alpha.1 → 1.2.0-alpha.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 (46) 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/react/BuildingPage.d.ts +2 -1
  18. package/dist/react/BuildingPage.js +47 -4
  19. package/dist/react/DefaultNotFound.d.ts +2 -1
  20. package/dist/react/DefaultNotFound.js +92 -17
  21. package/dist/react/DevIndicator.js +66 -23
  22. package/dist/react/ErrorModal.js +91 -40
  23. package/dist/react/Link.d.ts +2 -2
  24. package/dist/react/Link.js +27 -5
  25. package/dist/react/client.js +16 -5
  26. package/dist/react/entry.client.js +70 -30
  27. package/dist/react/image/Image.js +8 -3
  28. package/dist/react/renderer-react.js +53 -25
  29. package/dist/renderer.d.ts +4 -0
  30. package/dist/renderer.js +13 -5
  31. package/dist/router.js +82 -63
  32. package/dist/rpc/annotations.js +7 -3
  33. package/dist/rpc/server.js +21 -15
  34. package/dist/rpc/types.js +4 -1
  35. package/dist/types/framework.js +2 -1
  36. package/dist/types.js +2 -1
  37. package/dist/vue/App.vue +34 -37
  38. package/dist/vue/BuildingPage.vue +118 -102
  39. package/dist/vue/ErrorModal.vue +19 -37
  40. package/dist/vue/Link.vue +8 -7
  41. package/dist/vue/client.js +16 -6
  42. package/dist/vue/entry.client.js +8 -3
  43. package/dist/vue/image/Image.vue +25 -19
  44. package/dist/vue/renderer.vue.js +80 -26
  45. package/package.json +25 -12
  46. package/dist/global/global.js +0 -17
@@ -1,4 +1,7 @@
1
- export class ExpressAdapter {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExpressAdapter = void 0;
4
+ class ExpressAdapter {
2
5
  type = 'express';
3
6
  parseRequest(req) {
4
7
  return {
@@ -16,6 +19,7 @@ export class ExpressAdapter {
16
19
  return new ExpressResponseWrapper(res);
17
20
  }
18
21
  }
22
+ exports.ExpressAdapter = ExpressAdapter;
19
23
  class ExpressResponseWrapper {
20
24
  res;
21
25
  constructor(res) {
@@ -1,11 +1,47 @@
1
- import { ExpressAdapter } from './express';
2
- import { FastifyAdapter } from './fastify';
3
- import { NativeAdapter } from './native';
4
- import Console, { Colors } from "../api/console";
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
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.FrameworkAdapterFactory = void 0;
37
+ const express_1 = require("./express");
38
+ const fastify_1 = require("./fastify");
39
+ const native_1 = require("./native");
40
+ const console_1 = __importStar(require("../api/console"));
5
41
  /**
6
42
  * Factory para criar o adapter correto baseado no framework detectado
7
43
  */
8
- export class FrameworkAdapterFactory {
44
+ class FrameworkAdapterFactory {
9
45
  static adapter = null;
10
46
  /**
11
47
  * Detecta automaticamente o framework baseado na requisição/resposta
@@ -15,40 +51,40 @@ export class FrameworkAdapterFactory {
15
51
  if (this.adapter) {
16
52
  return this.adapter;
17
53
  }
18
- const msg = Console.dynamicLine(` ${Colors.FgYellow}● ${Colors.Reset}Detecting web framework...`);
54
+ const msg = console_1.default.dynamicLine(` ${console_1.Colors.FgYellow}● ${console_1.Colors.Reset}Detecting web framework...`);
19
55
  // Detecta Express
20
56
  if (req.app && req.route && res.locals !== undefined) {
21
- msg.end(` ${Colors.FgGreen}● ${Colors.Reset}Framework detected: Express`);
22
- this.adapter = new ExpressAdapter();
57
+ msg.end(` ${console_1.Colors.FgGreen}● ${console_1.Colors.Reset}Framework detected: Express`);
58
+ this.adapter = new express_1.ExpressAdapter();
23
59
  return this.adapter;
24
60
  }
25
61
  // Detecta Fastify
26
62
  if (req.server && req.routerPath !== undefined && res.request) {
27
- msg.end(` ${Colors.FgGreen}● ${Colors.Reset}Framework detected: Fastify`);
28
- this.adapter = new FastifyAdapter();
63
+ msg.end(` ${console_1.Colors.FgGreen}● ${console_1.Colors.Reset}Framework detected: Fastify`);
64
+ this.adapter = new fastify_1.FastifyAdapter();
29
65
  return this.adapter;
30
66
  }
31
67
  // Detecta HTTP nativo do Node.js
32
68
  if (req.method !== undefined && req.url !== undefined && req.headers !== undefined &&
33
69
  res.statusCode !== undefined && res.setHeader !== undefined && res.end !== undefined) {
34
- msg.end(` ${Colors.FgGreen}● ${Colors.Reset}Framework detected: Vatts.js Native (HTTP)`);
35
- this.adapter = new NativeAdapter();
70
+ msg.end(` ${console_1.Colors.FgGreen}● ${console_1.Colors.Reset}Framework detected: Vatts.js Native (HTTP)`);
71
+ this.adapter = new native_1.NativeAdapter();
36
72
  return this.adapter;
37
73
  }
38
74
  // Fallback mais específico para Express
39
75
  if (res.status && res.send && res.json && res.cookie) {
40
- msg.end(` ${Colors.FgGreen}● ${Colors.Reset}Framework detected: Express (fallback)`);
41
- this.adapter = new ExpressAdapter();
76
+ msg.end(` ${console_1.Colors.FgGreen}● ${console_1.Colors.Reset}Framework detected: Express (fallback)`);
77
+ this.adapter = new express_1.ExpressAdapter();
42
78
  return this.adapter;
43
79
  }
44
80
  // Fallback mais específico para Fastify
45
81
  if (res.code && res.send && res.type && res.setCookie) {
46
- msg.end(` ${Colors.FgGreen}● ${Colors.Reset}Framework detected: Fastify (fallback)`);
47
- this.adapter = new FastifyAdapter();
82
+ msg.end(` ${console_1.Colors.FgGreen}● ${console_1.Colors.Reset}Framework detected: Fastify (fallback)`);
83
+ this.adapter = new fastify_1.FastifyAdapter();
48
84
  return this.adapter;
49
85
  }
50
- msg.end(` ${Colors.FgYellow}● ${Colors.Reset}Unable to detect framework. Using Vatts.js Native as default.`);
51
- this.adapter = new NativeAdapter();
86
+ msg.end(` ${console_1.Colors.FgYellow}● ${console_1.Colors.Reset}Unable to detect framework. Using Vatts.js Native as default.`);
87
+ this.adapter = new native_1.NativeAdapter();
52
88
  return this.adapter;
53
89
  }
54
90
  /**
@@ -57,13 +93,13 @@ export class FrameworkAdapterFactory {
57
93
  static setFramework(framework) {
58
94
  switch (framework) {
59
95
  case 'express':
60
- this.adapter = new ExpressAdapter();
96
+ this.adapter = new express_1.ExpressAdapter();
61
97
  break;
62
98
  case 'fastify':
63
- this.adapter = new FastifyAdapter();
99
+ this.adapter = new fastify_1.FastifyAdapter();
64
100
  break;
65
101
  case 'native':
66
- this.adapter = new NativeAdapter();
102
+ this.adapter = new native_1.NativeAdapter();
67
103
  break;
68
104
  default:
69
105
  throw new Error(`Unsupported framework: ${framework}`);
@@ -82,3 +118,4 @@ export class FrameworkAdapterFactory {
82
118
  return this.adapter;
83
119
  }
84
120
  }
121
+ exports.FrameworkAdapterFactory = FrameworkAdapterFactory;
@@ -1,4 +1,7 @@
1
- export class FastifyAdapter {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FastifyAdapter = void 0;
4
+ class FastifyAdapter {
2
5
  type = 'fastify';
3
6
  parseRequest(req) {
4
7
  return {
@@ -16,6 +19,7 @@ export class FastifyAdapter {
16
19
  return new FastifyResponseWrapper(reply);
17
20
  }
18
21
  }
22
+ exports.FastifyAdapter = FastifyAdapter;
19
23
  class FastifyResponseWrapper {
20
24
  reply;
21
25
  constructor(reply) {
@@ -1,3 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NativeAdapter = void 0;
1
4
  // --- Funções Auxiliares de Segurança ---
2
5
  /**
3
6
  * Remove caracteres de quebra de linha (\r, \n) de uma string para prevenir
@@ -20,7 +23,7 @@ function isValidCookieName(name) {
20
23
  const validCookieNameRegex = /^[a-zA-Z0-9!#$%&'*+-.^_`|~]+$/;
21
24
  return validCookieNameRegex.test(name);
22
25
  }
23
- export class NativeAdapter {
26
+ class NativeAdapter {
24
27
  type = 'native';
25
28
  parseRequest(req) {
26
29
  // URL absoluta é obrigatória para a API WHATWG
@@ -63,6 +66,7 @@ export class NativeAdapter {
63
66
  return cookies;
64
67
  }
65
68
  }
69
+ exports.NativeAdapter = NativeAdapter;
66
70
  class NativeResponseWrapper {
67
71
  res;
68
72
  statusCode = 200;
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /*
2
3
  * This file is part of the Vatts.js Project.
3
4
  * Copyright (c) 2026 itsmuzin
@@ -14,13 +15,18 @@
14
15
  * See the License for the specific language governing permissions and
15
16
  * limitations under the License.
16
17
  */
17
- import readline from 'node:readline';
18
+ var __importDefault = (this && this.__importDefault) || function (mod) {
19
+ return (mod && mod.__esModule) ? mod : { "default": mod };
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.Levels = exports.Colors = exports.DynamicLine = void 0;
23
+ const node_readline_1 = __importDefault(require("node:readline"));
18
24
  /**
19
25
  * Um "handle" para uma linha dinâmica. As instâncias desta classe
20
26
  * são retornadas por `Console.dynamicLine()` e usadas para controlar
21
27
  * o conteúdo da linha.
22
28
  */
23
- export class DynamicLine {
29
+ class DynamicLine {
24
30
  // A ID é usada internamente pela classe Console para rastrear esta linha.
25
31
  _id = Symbol();
26
32
  constructor(initialContent) {
@@ -42,7 +48,8 @@ export class DynamicLine {
42
48
  Console['endDynamicLine'](this._id, finalContent);
43
49
  }
44
50
  }
45
- export var Colors;
51
+ exports.DynamicLine = DynamicLine;
52
+ var Colors;
46
53
  (function (Colors) {
47
54
  Colors["Reset"] = "\u001B[0m";
48
55
  Colors["Bright"] = "\u001B[1m";
@@ -70,16 +77,16 @@ export var Colors;
70
77
  Colors["BgCyan"] = "\u001B[46m";
71
78
  Colors["BgWhite"] = "\u001B[47m";
72
79
  Colors["BgGray"] = "\u001B[100m";
73
- })(Colors || (Colors = {}));
74
- export var Levels;
80
+ })(Colors || (exports.Colors = Colors = {}));
81
+ var Levels;
75
82
  (function (Levels) {
76
83
  Levels["ERROR"] = "ERROR";
77
84
  Levels["WARN"] = "WARN";
78
85
  Levels["INFO"] = "INFO";
79
86
  Levels["DEBUG"] = "DEBUG";
80
87
  Levels["SUCCESS"] = "SUCCESS";
81
- })(Levels || (Levels = {}));
82
- export default class Console {
88
+ })(Levels || (exports.Levels = Levels = {}));
89
+ class Console {
83
90
  // Armazena o estado de todas as linhas dinâmicas ativas
84
91
  static activeLines = [];
85
92
  // Quantas linhas foram efetivamente renderizadas na última operação.
@@ -89,14 +96,14 @@ export default class Console {
89
96
  const stream = process.stdout;
90
97
  if (this.lastRenderedLines > 0) {
91
98
  try {
92
- readline.moveCursor(stream, 0, -this.lastRenderedLines);
99
+ node_readline_1.default.moveCursor(stream, 0, -this.lastRenderedLines);
93
100
  }
94
101
  catch (_e) {
95
102
  // Em terminais estranhos a movimentação pode falhar — ignoramos.
96
103
  }
97
104
  }
98
- readline.cursorTo(stream, 0);
99
- readline.clearScreenDown(stream);
105
+ node_readline_1.default.cursorTo(stream, 0);
106
+ node_readline_1.default.clearScreenDown(stream);
100
107
  if (this.activeLines.length > 0) {
101
108
  // ATUALIZADO: Aplica o formato de log (Timestamp + Style) nas linhas dinâmicas
102
109
  // Usamos um nível pseudo 'WAIT' para indicar processo em andamento
@@ -108,11 +115,11 @@ export default class Console {
108
115
  const stream = process.stdout;
109
116
  if (this.lastRenderedLines > 0) {
110
117
  try {
111
- readline.moveCursor(stream, 0, -this.lastRenderedLines);
118
+ node_readline_1.default.moveCursor(stream, 0, -this.lastRenderedLines);
112
119
  }
113
120
  catch (_e) { }
114
- readline.cursorTo(stream, 0);
115
- readline.clearScreenDown(stream);
121
+ node_readline_1.default.cursorTo(stream, 0);
122
+ node_readline_1.default.clearScreenDown(stream);
116
123
  }
117
124
  // MODIFICAÇÃO PRINCIPAL:
118
125
  // Substituímos stream.write por console.log aqui.
@@ -238,13 +245,13 @@ export default class Console {
238
245
  const stream = process.stdout;
239
246
  if (this.lastRenderedLines > 0) {
240
247
  try {
241
- readline.moveCursor(stream, 0, -this.lastRenderedLines);
248
+ node_readline_1.default.moveCursor(stream, 0, -this.lastRenderedLines);
242
249
  }
243
250
  catch (_e) { }
244
- readline.cursorTo(stream, 0);
245
- readline.clearScreenDown(stream);
251
+ node_readline_1.default.cursorTo(stream, 0);
252
+ node_readline_1.default.clearScreenDown(stream);
246
253
  }
247
- const readlineInterface = readline.createInterface({ input: process.stdin, output: process.stdout });
254
+ const readlineInterface = node_readline_1.default.createInterface({ input: process.stdin, output: process.stdout });
248
255
  const defaultPart = defaultValue ? ` (${defaultValue})` : '';
249
256
  const prompt = ` ${Colors.FgRed}?${Colors.Reset} ${question}${Colors.FgGray}${defaultPart}${Colors.Reset} \n ${Colors.FgRed}➜${Colors.Reset} `;
250
257
  return new Promise(resolve => {
@@ -298,3 +305,4 @@ export default class Console {
298
305
  return new DynamicLine(initialContent);
299
306
  }
300
307
  }
308
+ exports.default = Console;
@@ -1,23 +1,30 @@
1
- import path from "path";
2
- import fs from "fs";
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.cachedFramework = void 0;
7
+ exports.default = detectFramework;
8
+ const path_1 = __importDefault(require("path"));
9
+ const fs_1 = __importDefault(require("fs"));
3
10
  // Variável para armazenar o resultado em memória
4
- export let cachedFramework = null;
5
- export default function detectFramework(projectDir = process.cwd()) {
11
+ exports.cachedFramework = null;
12
+ function detectFramework(projectDir = process.cwd()) {
6
13
  // Se já tivermos um resultado, retorna ele direto sem ler o disco
7
- if (cachedFramework)
8
- return cachedFramework;
14
+ if (exports.cachedFramework)
15
+ return exports.cachedFramework;
9
16
  try {
10
- const pkgPath = path.join(projectDir, 'package.json');
11
- if (fs.existsSync(pkgPath)) {
12
- const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
17
+ const pkgPath = path_1.default.join(projectDir, 'package.json');
18
+ if (fs_1.default.existsSync(pkgPath)) {
19
+ const pkg = JSON.parse(fs_1.default.readFileSync(pkgPath, 'utf8'));
13
20
  const deps = { ...pkg.dependencies, ...pkg.devDependencies };
14
21
  if (deps.react || deps['react-dom']) {
15
- cachedFramework = 'react';
16
- return cachedFramework;
22
+ exports.cachedFramework = 'react';
23
+ return exports.cachedFramework;
17
24
  }
18
25
  if (deps.vue || deps['nuxt']) {
19
- cachedFramework = 'vue';
20
- return cachedFramework;
26
+ exports.cachedFramework = 'vue';
27
+ return exports.cachedFramework;
21
28
  }
22
29
  }
23
30
  }
@@ -25,6 +32,6 @@ export default function detectFramework(projectDir = process.cwd()) {
25
32
  // Ignora erro de leitura
26
33
  }
27
34
  // Salva o fallback no cache para evitar re-execução em caso de falha
28
- cachedFramework = 'react';
29
- return cachedFramework;
35
+ exports.cachedFramework = 'react';
36
+ return exports.cachedFramework;
30
37
  }
package/dist/api/http.js CHANGED
@@ -1,3 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VattsResponse = exports.VattsRequest = void 0;
1
4
  // Input validation and sanitization utilities
2
5
  class SecurityUtils {
3
6
  static MAX_HEADER_LENGTH = 8192;
@@ -39,7 +42,7 @@ class SecurityUtils {
39
42
  * Abstração sobre a requisição HTTP de entrada.
40
43
  * Funciona com qualquer framework web (Express, Fastify, etc.)
41
44
  */
42
- export class VattsRequest {
45
+ class VattsRequest {
43
46
  /** A requisição genérica parseada pelo adapter */
44
47
  _req;
45
48
  constructor(req) {
@@ -246,11 +249,12 @@ export class VattsRequest {
246
249
  return Array.isArray(ua) ? ua[0] : ua;
247
250
  }
248
251
  }
252
+ exports.VattsRequest = VattsRequest;
249
253
  /**
250
254
  * Abstração para construir a resposta HTTP.
251
255
  * Funciona com qualquer framework web (Express, Fastify, etc.)
252
256
  */
253
- export class VattsResponse {
257
+ class VattsResponse {
254
258
  _status = 200;
255
259
  _headers = {};
256
260
  _cookies = [];
@@ -462,3 +466,4 @@ export class VattsResponse {
462
466
  return VattsResponse.text(message, { status: 403 });
463
467
  }
464
468
  }
469
+ exports.VattsResponse = VattsResponse;
package/dist/builder.js CHANGED
@@ -15,6 +15,14 @@
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
17
  */
18
+ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
19
+ if (typeof path === "string" && /^\.\.?\//.test(path)) {
20
+ return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
21
+ return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
22
+ });
23
+ }
24
+ return path;
25
+ };
18
26
  const { rollup, watch: rollupWatch } = require('rollup');
19
27
  const path = require('path');
20
28
  const Console = require("./api/console").default;
@@ -107,7 +115,7 @@ const customPostCssPlugin = (isProduction) => {
107
115
  try {
108
116
  let postcss;
109
117
  try {
110
- postcss = require(path.join(projectDir, 'node_modules', 'postcss'));
118
+ postcss = require(__rewriteRelativeImportExtension(path.join(projectDir, 'node_modules', 'postcss')));
111
119
  }
112
120
  catch {
113
121
  try {
@@ -118,7 +126,7 @@ const customPostCssPlugin = (isProduction) => {
118
126
  }
119
127
  }
120
128
  if (postcss) {
121
- const config = require(configPath);
129
+ const config = require(__rewriteRelativeImportExtension(configPath));
122
130
  const postcssConfig = config.default || config;
123
131
  const plugins = [];
124
132
  if (postcssConfig.plugins) {
@@ -127,10 +135,10 @@ const customPostCssPlugin = (isProduction) => {
127
135
  if (typeof p === 'string') {
128
136
  try {
129
137
  const resolved = require.resolve(p, { paths: [projectDir] });
130
- return require(resolved);
138
+ return require(__rewriteRelativeImportExtension(resolved));
131
139
  }
132
140
  catch {
133
- return require(p);
141
+ return require(__rewriteRelativeImportExtension(p));
134
142
  }
135
143
  }
136
144
  return p;
@@ -140,7 +148,7 @@ const customPostCssPlugin = (isProduction) => {
140
148
  for (const [name, options] of Object.entries(postcssConfig.plugins)) {
141
149
  try {
142
150
  const resolvedPath = require.resolve(name, { paths: [projectDir] });
143
- const pluginModule = require(resolvedPath);
151
+ const pluginModule = require(__rewriteRelativeImportExtension(resolvedPath));
144
152
  plugins.push(pluginModule(options || {}));
145
153
  }
146
154
  catch (e) {
@@ -343,11 +351,12 @@ async function createRollupConfig(entryPoint, outdir, isProduction) {
343
351
  esbuildInclude = /\.[jt]sx?$/; // React/Vanilla: ignora arquivos virtuais do Vue
344
352
  }
345
353
  const esbuildLoaders = {
346
- '.js': 'jsx'
347
- // FIX ERRO "__VLS_asFunctionalElement1":
348
- // REMOVIDO: '.vue': 'ts'.
349
- // O rollup-plugin-vue processa o .vue e emite JS/TS.
350
- // Forçar 'ts' no arquivo .vue bruto quebra o processamento do template.
354
+ '.js': 'jsx',
355
+ '.ts': 'ts',
356
+ '.tsx': 'tsx',
357
+ // RESTAURADO: .vue para ts. Isso é NECESSÁRIO para processar blocos <script lang="ts">
358
+ // Se houver erros do tipo __VLS_, o plugin 'block-volar-artifacts' abaixo deve resolver.
359
+ '.vue': 'ts'
351
360
  };
352
361
  // No Vue, partes do arquivo podem virar TS, mas isso é pego pela extensão do arquivo virtual,
353
362
  // não precisamos forçar no loader geral.
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /*
2
3
  * This file is part of the Vatts.js Project.
3
4
  * Copyright (c) 2026 itsmuzin
@@ -14,7 +15,9 @@
14
15
  * See the License for the specific language governing permissions and
15
16
  * limitations under the License.
16
17
  */
17
- export class Router {
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.router = exports.Router = void 0;
20
+ class Router {
18
21
  listeners = new Set();
19
22
  constructor() {
20
23
  // Só adiciona listener no lado do cliente
@@ -69,4 +72,5 @@ export class Router {
69
72
  this.listeners.forEach(listener => listener());
70
73
  }
71
74
  }
72
- export const router = new Router();
75
+ exports.Router = Router;
76
+ exports.router = new Router();
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /*
2
3
  * This file is part of the Vatts.js Project.
3
4
  * Copyright (c) 2026 itsmuzin
@@ -14,7 +15,9 @@
14
15
  * See the License for the specific language governing permissions and
15
16
  * limitations under the License.
16
17
  */
17
- import { RPC_ENDPOINT } from '../rpc/types';
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.importServer = importServer;
20
+ const types_1 = require("../rpc/types");
18
21
  function asErrorMessage(err) {
19
22
  if (err instanceof Error)
20
23
  return err.message;
@@ -35,10 +38,10 @@ function getRpcEndpoint() {
35
38
  const port = process.env.PORT || 3000;
36
39
  // Em SSR, sempre usamos HTTP e Loopback IP (127.0.0.1) para garantir
37
40
  // que a requisição chegue no próprio servidor localmente sem sair pra rede externa.
38
- return `http://127.0.0.1:${port}${RPC_ENDPOINT}`;
41
+ return `http://127.0.0.1:${port}${types_1.RPC_ENDPOINT}`;
39
42
  }
40
43
  // No cliente (browser), URL relativa funciona perfeitamente
41
- return RPC_ENDPOINT;
44
+ return types_1.RPC_ENDPOINT;
42
45
  }
43
46
  /**
44
47
  * `importServer("src/backend/index.ts")` returns a Proxy where every property is
@@ -55,7 +58,7 @@ function getRpcEndpoint() {
55
58
  * Security note: the server will still validate allowlisted directories.
56
59
  * @param {string} file
57
60
  */
58
- export function importServer(file) {
61
+ function importServer(file) {
59
62
  if (!file) {
60
63
  throw new Error('importServer(file) requires a non-empty string');
61
64
  }
package/dist/env/env.js CHANGED
@@ -1,6 +1,12 @@
1
- import fs from "fs";
2
- import path from "path";
3
- import Console from "../api/console";
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.loadEnv = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const console_1 = __importDefault(require("../api/console"));
4
10
  function parse(src) {
5
11
  const obj = {};
6
12
  const lines = src.toString().split('\n');
@@ -22,10 +28,10 @@ function parse(src) {
22
28
  return obj;
23
29
  }
24
30
  function applyEnv(filePath) {
25
- if (!fs.existsSync(filePath))
31
+ if (!fs_1.default.existsSync(filePath))
26
32
  return;
27
33
  try {
28
- const fileContent = fs.readFileSync(filePath, 'utf-8');
34
+ const fileContent = fs_1.default.readFileSync(filePath, 'utf-8');
29
35
  const parsed = parse(fileContent);
30
36
  for (const key in parsed) {
31
37
  if (!Object.prototype.hasOwnProperty.call(process.env, key)) {
@@ -34,24 +40,24 @@ function applyEnv(filePath) {
34
40
  }
35
41
  }
36
42
  catch (e) {
37
- Console.error(`Error loading env file ${filePath}:`, e);
43
+ console_1.default.error(`Error loading env file ${filePath}:`, e);
38
44
  }
39
45
  }
40
- export const loadEnv = (options) => {
46
+ const loadEnv = (options) => {
41
47
  const { dir, dev, envFiles = [] } = options;
42
- const filesToLoad = [".env", ...envFiles].map((file) => path.join(dir, file));
48
+ const filesToLoad = [".env", ...envFiles].map((file) => path_1.default.join(dir, file));
43
49
  filesToLoad.forEach(applyEnv);
44
50
  if (dev) {
45
51
  for (const file of filesToLoad) {
46
- if (fs.existsSync(file)) {
52
+ if (fs_1.default.existsSync(file)) {
47
53
  let watchTimeout;
48
- fs.watch(file, (eventType) => {
54
+ fs_1.default.watch(file, (eventType) => {
49
55
  if (eventType === 'change') {
50
56
  // Limpa o timeout anterior para evitar execuções múltiplas
51
57
  clearTimeout(watchTimeout);
52
58
  // Define um novo timeout de 100ms
53
59
  watchTimeout = setTimeout(() => {
54
- Console.info(`Reloading environment variables from ${path.basename(file)}.`);
60
+ console_1.default.info(`Reloading environment variables from ${path_1.default.basename(file)}.`);
55
61
  applyEnv(file);
56
62
  }, 100);
57
63
  }
@@ -60,3 +66,4 @@ export const loadEnv = (options) => {
60
66
  }
61
67
  }
62
68
  };
69
+ exports.loadEnv = loadEnv;