vatts 1.0.1 → 1.0.2-alpha.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/dist/index.js CHANGED
@@ -256,9 +256,18 @@ function hweb(options) {
256
256
  // Função para regenerar o entry file
257
257
  const regenerateEntryFile = () => {
258
258
  // Recarrega todas as rotas e componentes
259
- frontendRoutes = (0, router_1.loadRoutes)(userWebRoutesDir);
260
- (0, router_1.loadLayout)(userWebDir);
261
- (0, router_1.loadNotFound)(userWebDir);
259
+ const newFrontendRoutes = (0, router_1.loadRoutes)(userWebRoutesDir);
260
+ const newLayout = (0, router_1.loadLayout)(userWebDir);
261
+ const newNotFound = (0, router_1.loadNotFound)(userWebDir);
262
+ // Se nada mudou, não reescreve o entry file (evita disparar rebuild extra)
263
+ const oldKey = frontendRoutes.map(r => `${r.pattern ?? ''}:${r.componentPath}`).join('|');
264
+ const newKey = newFrontendRoutes.map(r => `${r.pattern ?? ''}:${r.componentPath}`).join('|');
265
+ if (oldKey === newKey) {
266
+ // Ainda atualiza refs internas de layout/notFound, mas evita re-gerar o entry.
267
+ frontendRoutes = newFrontendRoutes;
268
+ return;
269
+ }
270
+ frontendRoutes = newFrontendRoutes;
262
271
  // Regenera o entry file
263
272
  entryPoint = createEntryFile(dir, frontendRoutes);
264
273
  };
package/dist/router.d.ts CHANGED
@@ -1,101 +1,50 @@
1
1
  import { RouteConfig, BackendRouteConfig, VattsMiddleware, WebSocketHandler } from './types';
2
- /**
3
- * Limpa todo o cache de rotas carregadas
4
- */
5
2
  export declare function clearAllRouteCache(): void;
6
- /**
7
- * Limpa o cache de um arquivo específico e recarrega as rotas se necessário
8
- * @param changedFilePath Caminho do arquivo que foi alterado
9
- */
10
3
  export declare function clearFileCache(changedFilePath: string): void;
11
- /**
12
- * Carrega o layout.tsx se existir no diretório web
13
- * @param webDir O diretório web onde procurar o layout
14
- * @returns O layout carregado ou null se não existir
15
- */
16
4
  export declare function loadLayout(webDir: string): {
17
5
  componentPath: string;
18
6
  metadata?: any;
19
7
  } | null;
20
- /**
21
- * Retorna o layout atual se carregado
22
- */
23
8
  export declare function getLayout(): {
24
9
  componentPath: string;
25
10
  metadata?: any;
26
11
  } | null;
27
- /**
28
- * Carrega dinamicamente todas as rotas de frontend do diretório do usuário.
29
- * @param routesDir O diretório onde as rotas de página estão localizadas.
30
- * @returns A lista de rotas de página que foram carregadas.
31
- */
32
12
  export declare function loadRoutes(routesDir: string): (RouteConfig & {
33
13
  componentPath: string;
34
14
  })[];
35
- /**
36
- * Encontra a rota de página correspondente para uma URL.
37
- * @param pathname O caminho da URL (ex: "/users/123").
38
- * @returns Um objeto com a rota e os parâmetros, ou null se não encontrar.
39
- */
40
15
  export declare function findMatchingRoute(pathname: string): {
41
- route: RouteConfig & {
16
+ route: {
42
17
  componentPath: string;
18
+ pattern: string;
19
+ component: import("react").ComponentType<any>;
20
+ generateMetadata?: (params: any, req: import(".").GenericRequest) => Promise<import("./types").Metadata> | import("./types").Metadata;
43
21
  };
44
22
  params: {
45
23
  [key: string]: string;
46
24
  };
47
25
  } | null;
48
- /**
49
- * Carrega dinamicamente todas as rotas de API do diretório de backend.
50
- * @param backendRoutesDir O diretório onde as rotas de API estão localizadas.
51
- */
52
26
  export declare function loadBackendRoutes(backendRoutesDir: string): void;
53
- /**
54
- * Encontra a rota de API correspondente para uma URL e método HTTP.
55
- * @param pathname O caminho da URL (ex: "/api/users/123").
56
- * @param method O método HTTP da requisição (GET, POST, etc.).
57
- * @returns Um objeto com a rota e os parâmetros, ou null se não encontrar.
58
- */
59
27
  export declare function findMatchingBackendRoute(pathname: string, method: string): {
60
28
  route: BackendRouteConfig;
61
29
  params: {
62
30
  [key: string]: string;
63
31
  };
64
32
  } | null;
65
- /**
66
- * Carrega o notFound.tsx se existir no diretório web
67
- * @param webDir O diretório web onde procurar o notFound
68
- * @returns O notFound carregado ou null se não existir
69
- */
70
33
  export declare function loadNotFound(webDir: string): {
71
34
  componentPath: string;
72
35
  } | null;
73
- /**
74
- * Retorna o componente 404 atual se carregado
75
- */
76
36
  export declare function getNotFound(): {
77
37
  componentPath: string;
78
38
  } | null;
79
- /**
80
- * Processa e registra rotas WebSocket encontradas nas rotas backend
81
- */
82
39
  export declare function processWebSocketRoutes(): void;
83
- /**
84
- * Encontra a rota WebSocket correspondente para uma URL
85
- */
86
40
  export declare function findMatchingWebSocketRoute(pathname: string): {
87
41
  route: {
88
42
  pattern: string;
89
43
  handler: WebSocketHandler;
90
- middleware?: VattsMiddleware[];
44
+ middleware: VattsMiddleware[] | undefined;
91
45
  };
92
46
  params: {
93
47
  [key: string]: string;
94
48
  };
95
49
  } | null;
96
- /**
97
- * Configura WebSocket upgrade no servidor HTTP existente
98
- * @param server Servidor HTTP (Express, Fastify ou Native)
99
- * @param hotReloadManager Instância do gerenciador de hot-reload para coordenação
100
- */
101
50
  export declare function setupWebSocketUpgrade(server: any, hotReloadManager?: any): void;