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,41 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
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 });
2
39
  /*
3
40
  * This file is part of the Vatts.js Project.
4
41
  * Copyright (c) 2026 itsmuzin
@@ -15,20 +52,20 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
15
52
  * See the License for the specific language governing permissions and
16
53
  * limitations under the License.
17
54
  */
18
- import React, { useState, useEffect, useCallback } from 'react';
19
- import { createRoot } from 'react-dom/client';
20
- import { router } from '../client/clientRouter';
21
- import { ErrorModal } from './ErrorModal';
22
- import DevIndicator from "./DevIndicator";
55
+ const react_1 = __importStar(require("react"));
56
+ const client_1 = require("react-dom/client");
57
+ const clientRouter_1 = require("../client/clientRouter");
58
+ const ErrorModal_1 = require("./ErrorModal");
59
+ const DevIndicator_1 = __importDefault(require("./DevIndicator"));
23
60
  function App({ componentMap, routes, initialComponentPath, initialParams, layoutComponent }) {
24
61
  // Estado que guarda o componente a ser renderizado atualmente
25
- const [hmrTimestamp, setHmrTimestamp] = useState(Date.now());
62
+ const [hmrTimestamp, setHmrTimestamp] = (0, react_1.useState)(Date.now());
26
63
  // Estado de erro de build recebido pelo hot-reload (via eventos globais)
27
- const [buildError, setBuildError] = useState(() => {
64
+ const [buildError, setBuildError] = (0, react_1.useState)(() => {
28
65
  return window.__VATTS_BUILD_ERROR__ || null;
29
66
  });
30
- const [isErrorOpen, setIsErrorOpen] = useState(() => !!window.__VATTS_BUILD_ERROR__);
31
- useEffect(() => {
67
+ const [isErrorOpen, setIsErrorOpen] = (0, react_1.useState)(() => !!window.__VATTS_BUILD_ERROR__);
68
+ (0, react_1.useEffect)(() => {
32
69
  const onErr = (ev) => {
33
70
  const e = ev?.detail;
34
71
  setBuildError(e || null);
@@ -45,7 +82,7 @@ function App({ componentMap, routes, initialComponentPath, initialParams, layout
45
82
  window.removeEventListener('vatts:build-ok', onOk);
46
83
  };
47
84
  }, []);
48
- const copyBuildError = useCallback(async () => {
85
+ const copyBuildError = (0, react_1.useCallback)(async () => {
49
86
  try {
50
87
  if (!buildError)
51
88
  return;
@@ -57,7 +94,7 @@ function App({ componentMap, routes, initialComponentPath, initialParams, layout
57
94
  }
58
95
  }, [buildError]);
59
96
  // Helper para encontrar rota baseado no path
60
- const findRouteForPath = useCallback((path) => {
97
+ const findRouteForPath = (0, react_1.useCallback)((path) => {
61
98
  for (const route of routes) {
62
99
  const regexPattern = route.pattern
63
100
  // [[...param]] → opcional catch-all
@@ -83,7 +120,7 @@ function App({ componentMap, routes, initialComponentPath, initialParams, layout
83
120
  return null;
84
121
  }, [routes]);
85
122
  // Inicializa o componente e params baseado na URL ATUAL (não no initialComponentPath)
86
- const [CurrentPageComponent, setCurrentPageComponent] = useState(() => {
123
+ const [CurrentPageComponent, setCurrentPageComponent] = (0, react_1.useState)(() => {
87
124
  // Pega a rota atual da URL
88
125
  const currentPath = window.location.pathname.replace("index.html", '');
89
126
  const match = findRouteForPath(currentPath);
@@ -93,14 +130,14 @@ function App({ componentMap, routes, initialComponentPath, initialParams, layout
93
130
  // Se não encontrou rota, retorna null para mostrar 404
94
131
  return null;
95
132
  });
96
- const [params, setParams] = useState(() => {
133
+ const [params, setParams] = (0, react_1.useState)(() => {
97
134
  // Pega os params da URL atual
98
135
  const currentPath = window.location.pathname.replace("index.html", '');
99
136
  const match = findRouteForPath(currentPath);
100
137
  return match ? match.params : {};
101
138
  });
102
139
  // HMR: Escuta eventos de hot reload
103
- useEffect(() => {
140
+ (0, react_1.useEffect)(() => {
104
141
  // Ativa o sistema de HMR
105
142
  window.__HWEB_HMR__ = true;
106
143
  const handleHMRUpdate = async (event) => {
@@ -127,8 +164,8 @@ function App({ componentMap, routes, initialComponentPath, initialParams, layout
127
164
  window.removeEventListener('hmr:component-update', handleHMRUpdate);
128
165
  };
129
166
  }, []);
130
- const updateRoute = useCallback(() => {
131
- const currentPath = router.pathname.replace("index.html", '');
167
+ const updateRoute = (0, react_1.useCallback)(() => {
168
+ const currentPath = clientRouter_1.router.pathname.replace("index.html", '');
132
169
  const match = findRouteForPath(currentPath);
133
170
  if (match) {
134
171
  setCurrentPageComponent(() => componentMap[match.componentPath]);
@@ -145,15 +182,15 @@ function App({ componentMap, routes, initialComponentPath, initialParams, layout
145
182
  setCurrentPageComponent(null);
146
183
  setParams({});
147
184
  }
148
- }, [router.pathname, findRouteForPath, componentMap]);
185
+ }, [clientRouter_1.router.pathname, findRouteForPath, componentMap]);
149
186
  // Ouve os eventos de "voltar" e "avançar" do navegador
150
- useEffect(() => {
187
+ (0, react_1.useEffect)(() => {
151
188
  const handlePopState = () => {
152
189
  updateRoute();
153
190
  };
154
191
  window.addEventListener('popstate', handlePopState);
155
192
  // Também se inscreve no router para mudanças de rota
156
- const unsubscribe = router.subscribe(updateRoute);
193
+ const unsubscribe = clientRouter_1.router.subscribe(updateRoute);
157
194
  return () => {
158
195
  window.removeEventListener('popstate', handlePopState);
159
196
  unsubscribe();
@@ -165,26 +202,29 @@ function App({ componentMap, routes, initialComponentPath, initialParams, layout
165
202
  if (!CurrentPageComponent || initialComponentPath === '__404__') {
166
203
  const NotFoundComponent = window.__VATTS_NOT_FOUND__;
167
204
  if (NotFoundComponent) {
168
- const NotFoundContent = _jsx(NotFoundComponent, {});
205
+ const NotFoundContent = react_1.default.createElement(NotFoundComponent, null);
169
206
  resolvedContent = layoutComponent
170
- ? React.createElement(layoutComponent, { children: NotFoundContent })
207
+ ? react_1.default.createElement(layoutComponent, { children: NotFoundContent })
171
208
  : NotFoundContent;
172
209
  }
173
210
  else {
174
211
  const DefaultNotFound = window.__VATTS_DEFAULT_NOT_FOUND__;
175
- const NotFoundContent = _jsx(DefaultNotFound, {});
212
+ const NotFoundContent = react_1.default.createElement(DefaultNotFound, null);
176
213
  resolvedContent = layoutComponent
177
- ? React.createElement(layoutComponent, { children: NotFoundContent })
214
+ ? react_1.default.createElement(layoutComponent, { children: NotFoundContent })
178
215
  : NotFoundContent;
179
216
  }
180
217
  }
181
218
  else {
182
- const PageContent = _jsx(CurrentPageComponent, { params: params }, `page-${hmrTimestamp}`);
219
+ const PageContent = react_1.default.createElement(CurrentPageComponent, { key: `page-${hmrTimestamp}`, params: params });
183
220
  resolvedContent = layoutComponent
184
- ? React.createElement(layoutComponent, { children: PageContent })
185
- : _jsx("div", { children: PageContent });
221
+ ? react_1.default.createElement(layoutComponent, { children: PageContent })
222
+ : react_1.default.createElement("div", null, PageContent);
186
223
  }
187
- return (_jsxs(_Fragment, { children: [resolvedContent, process.env.NODE_ENV !== 'production' && (_jsx(DevIndicator, { hasBuildError: !!buildError, onClickBuildError: () => setIsErrorOpen(true) })), _jsx(ErrorModal, { error: buildError, isOpen: isErrorOpen, onClose: () => setIsErrorOpen(false), onCopy: copyBuildError })] }));
224
+ return (react_1.default.createElement(react_1.default.Fragment, null,
225
+ resolvedContent,
226
+ process.env.NODE_ENV !== 'production' && (react_1.default.createElement(DevIndicator_1.default, { hasBuildError: !!buildError, onClickBuildError: () => setIsErrorOpen(true) })),
227
+ react_1.default.createElement(ErrorModal_1.ErrorModal, { error: buildError, isOpen: isErrorOpen, onClose: () => setIsErrorOpen(false), onCopy: copyBuildError })));
188
228
  }
189
229
  // --- Inicialização do Cliente (CSR - Client-Side Rendering) ---
190
230
  function deobfuscateData(obfuscated) {
@@ -251,10 +291,10 @@ function initializeClient() {
251
291
  }
252
292
  }
253
293
  // Usar createRoot para render inicial (CSR)
254
- const root = createRoot(container);
294
+ const root = (0, client_1.createRoot)(container);
255
295
  // Salva a referência globalmente
256
296
  window.__VATTS_ROOT__ = root;
257
- root.render(_jsx(App, { componentMap: componentMap, routes: initialData.routes, initialComponentPath: initialData.initialComponentPath, initialParams: initialData.initialParams, layoutComponent: window.__VATTS_LAYOUT__ }));
297
+ root.render(react_1.default.createElement(App, { componentMap: componentMap, routes: initialData.routes, initialComponentPath: initialData.initialComponentPath, initialParams: initialData.initialParams, layoutComponent: window.__VATTS_LAYOUT__ }));
258
298
  }
259
299
  catch (error) {
260
300
  console.error('[Watts] Critical Error rendering application:', error);
@@ -1,4 +1,9 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
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
+ const react_1 = __importDefault(require("react"));
2
7
  const Image = ({ src, width, height, quality = 75, priority = false, className, style, alt = "", ...props }) => {
3
8
  function getBaseUrl() {
4
9
  if (typeof window === "undefined")
@@ -42,6 +47,6 @@ const Image = ({ src, width, height, quality = 75, priority = false, className,
42
47
  height: height ? (typeof height === 'number' ? `${height}px` : height) : 'auto',
43
48
  ...style,
44
49
  };
45
- return (_jsx("img", { ...props, src: optimizedSrc, alt: alt, loading: priority ? 'eager' : 'lazy', decoding: priority ? 'sync' : 'async', width: typeof width === 'string' ? width.replace('px', '') : width, height: typeof height === 'string' ? height.replace('px', '') : height, className: `vatts-image ${className || ''}`, style: baseStyle }));
50
+ return (react_1.default.createElement("img", { ...props, src: optimizedSrc, alt: alt, loading: priority ? 'eager' : 'lazy', decoding: priority ? 'sync' : 'async', width: typeof width === 'string' ? width.replace('px', '') : width, height: typeof height === 'string' ? height.replace('px', '') : height, className: `vatts-image ${className || ''}`, style: baseStyle }));
46
51
  };
47
- export default Image;
52
+ exports.default = Image;
@@ -1,9 +1,31 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { renderToPipeableStream } from 'react-dom/server';
3
- import { getLayout } from '../router';
4
- import fs from 'fs';
5
- import path from 'path';
6
- import BuildingScreen from "../react/BuildingPage";
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.render = render;
7
+ /*
8
+ * This file is part of the Vatts.js Project.
9
+ * Copyright (c) 2026 itsmuzin
10
+ *
11
+ * Licensed under the Apache License, Version 2.0 (the "License");
12
+ * you may not use this file except in compliance with the License.
13
+ * You may obtain a copy of the License at
14
+ *
15
+ * http://www.apache.org/licenses/LICENSE-2.0
16
+ *
17
+ * Unless required by applicable law or agreed to in writing, software
18
+ * distributed under the License is distributed on an "AS IS" BASIS,
19
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
+ * See the License for the specific language governing permissions and
21
+ * limitations under the License.
22
+ */
23
+ const react_1 = __importDefault(require("react"));
24
+ const server_1 = require("react-dom/server");
25
+ const router_1 = require("../router");
26
+ const fs_1 = __importDefault(require("fs"));
27
+ const path_1 = __importDefault(require("path"));
28
+ const BuildingPage_1 = __importDefault(require("../react/BuildingPage"));
7
29
  // --- Helpers de Servidor ---
8
30
  // Função auxiliar para importar módulos ignorando CSS (mesma lógica do router.ts)
9
31
  function requireWithoutStyles(modulePath) {
@@ -149,22 +171,22 @@ function obfuscateData(data) {
149
171
  // Procura em .vatts/ e .vatts/assets/
150
172
  function getBuildAssets(req) {
151
173
  const projectDir = process.cwd();
152
- const distDir = path.join(projectDir, '.vatts');
153
- const assetsDir = path.join(distDir, 'assets');
154
- if (!fs.existsSync(distDir))
174
+ const distDir = path_1.default.join(projectDir, '.vatts');
175
+ const assetsDir = path_1.default.join(distDir, 'assets');
176
+ if (!fs_1.default.existsSync(distDir))
155
177
  return null;
156
178
  let scripts = [];
157
179
  let styles = [];
158
180
  // Helper para processar arquivos de um diretório
159
181
  const processDirectory = (directory, urlPrefix) => {
160
- if (!fs.existsSync(directory))
182
+ if (!fs_1.default.existsSync(directory))
161
183
  return;
162
- const files = fs.readdirSync(directory);
184
+ const files = fs_1.default.readdirSync(directory);
163
185
  files.forEach(file => {
164
186
  if (file.endsWith('.map'))
165
187
  return; // Ignora sourcemaps
166
- const fullPath = path.join(directory, file);
167
- const stat = fs.statSync(fullPath);
188
+ const fullPath = path_1.default.join(directory, file);
189
+ const stat = fs_1.default.statSync(fullPath);
168
190
  if (stat.isFile()) {
169
191
  if (file.endsWith('.js')) {
170
192
  scripts.push(`${urlPrefix}/${file}`);
@@ -177,9 +199,9 @@ function getBuildAssets(req) {
177
199
  };
178
200
  try {
179
201
  // 1. Verificar Manifesto (se existir)
180
- const manifestPath = path.join(distDir, 'manifest.json');
181
- if (fs.existsSync(manifestPath)) {
182
- const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
202
+ const manifestPath = path_1.default.join(distDir, 'manifest.json');
203
+ if (fs_1.default.existsSync(manifestPath)) {
204
+ const manifest = JSON.parse(fs_1.default.readFileSync(manifestPath, 'utf8'));
183
205
  const manifestFiles = Object.values(manifest);
184
206
  scripts = manifestFiles
185
207
  .filter((f) => f.endsWith('.js'))
@@ -221,9 +243,14 @@ function ServerRoot({ lang, title, metaTagsHtml, stylesHtml, initialDataScript,
221
243
  ${metaTagsHtml || ''}
222
244
  ${stylesHtml || ''}
223
245
  `;
224
- return (_jsxs("html", { lang: lang, children: [_jsx("head", { dangerouslySetInnerHTML: { __html: headContent } }), _jsxs("body", { children: [dataScript, _jsx("div", { id: "root", children: children }), hotReloadScript && (_jsx("div", { style: { display: 'none' }, dangerouslySetInnerHTML: { __html: hotReloadScript } }))] })] }));
246
+ return (react_1.default.createElement("html", { lang: lang },
247
+ react_1.default.createElement("head", { dangerouslySetInnerHTML: { __html: headContent } }),
248
+ react_1.default.createElement("body", null,
249
+ dataScript,
250
+ react_1.default.createElement("div", { id: "root" }, children),
251
+ hotReloadScript && (react_1.default.createElement("div", { style: { display: 'none' }, dangerouslySetInnerHTML: { __html: hotReloadScript } })))));
225
252
  }
226
- export async function render({ req, res, route, params, allRoutes }) {
253
+ async function render({ req, res, route, params, allRoutes }) {
227
254
  const { generateMetadata } = route;
228
255
  const isProduction = !req.hwebDev;
229
256
  const hotReloadManager = req.hotReloadManager;
@@ -236,7 +263,7 @@ export async function render({ req, res, route, params, allRoutes }) {
236
263
  // Se falhar o build, restauramos o console para o erro aparecer se necessário
237
264
  restoreConsole();
238
265
  // Usando stream para a tela de loading também, agora via React Component
239
- const { pipe } = renderToPipeableStream(_jsx(BuildingScreen, {}), {
266
+ const { pipe } = (0, server_1.renderToPipeableStream)(react_1.default.createElement(BuildingPage_1.default, null), {
240
267
  onShellReady() {
241
268
  res.setHeader('Content-Type', 'text/html');
242
269
  pipe(res);
@@ -245,12 +272,12 @@ export async function render({ req, res, route, params, allRoutes }) {
245
272
  return;
246
273
  }
247
274
  // 2. Preparar Layout
248
- const layoutInfo = getLayout();
275
+ const layoutInfo = (0, router_1.getLayout)();
249
276
  let LayoutComponent = null;
250
277
  if (layoutInfo) {
251
278
  try {
252
279
  // Recarrega o componente de layout para ter acesso à função (o router só guarda metadata)
253
- const layoutModule = requireWithoutStyles(path.resolve(process.cwd(), layoutInfo.componentPath));
280
+ const layoutModule = requireWithoutStyles(path_1.default.resolve(process.cwd(), layoutInfo.componentPath));
254
281
  LayoutComponent = layoutModule.default;
255
282
  }
256
283
  catch (e) {
@@ -299,16 +326,16 @@ export async function render({ req, res, route, params, allRoutes }) {
299
326
  // 5. Componente da Página Atual
300
327
  const PageComponent = route.component;
301
328
  // Monta a árvore da aplicação
302
- let AppTree = _jsx(PageComponent, { params: params });
329
+ let AppTree = react_1.default.createElement(PageComponent, { params: params });
303
330
  if (LayoutComponent) {
304
- AppTree = _jsx(LayoutComponent, { children: AppTree });
331
+ AppTree = react_1.default.createElement(LayoutComponent, null, AppTree);
305
332
  }
306
333
  // 6. Streaming
307
334
  return new Promise((resolve, reject) => {
308
335
  let didError = false;
309
- const { pipe } = renderToPipeableStream(_jsx(ServerRoot, { lang: htmlLang, title: metadata.title || 'Vatts.js', metaTagsHtml: metaTagsHtml, stylesHtml: stylesHtml,
336
+ const { pipe } = (0, server_1.renderToPipeableStream)(react_1.default.createElement(ServerRoot, { lang: htmlLang, title: metadata.title || 'Vatts.js', metaTagsHtml: metaTagsHtml, stylesHtml: stylesHtml,
310
337
  // Recriando o script de dados exatamente como o client espera
311
- initialDataScript: `/* Data Injection */`, hotReloadScript: hotReloadScript, dataScript: _jsx("script", { id: "__vatts_data__", type: "text/plain", "data-h": obfuscatedData }), children: AppTree }), {
338
+ initialDataScript: `/* Data Injection */`, hotReloadScript: hotReloadScript, dataScript: react_1.default.createElement("script", { id: "__vatts_data__", type: "text/plain", "data-h": obfuscatedData }) }, AppTree), {
312
339
  // Usar bootstrapModules para scripts tipo módulo (ESM)
313
340
  bootstrapModules: assets.scripts,
314
341
  onShellReady() {
@@ -341,3 +368,4 @@ export async function render({ req, res, route, params, allRoutes }) {
341
368
  throw err;
342
369
  }
343
370
  }
371
+ // --- Componente de Tela de Building (Substituto do getBuildingHTML) ---
@@ -11,5 +11,9 @@ interface RenderOptions {
11
11
  componentPath: string;
12
12
  })[];
13
13
  }
14
+ /**
15
+ * Renderiza a requisição como stream, carregando o driver apropriado dinamicamente.
16
+ * Isso evita erros de "Module Not Found" quando um dos frameworks não está instalado.
17
+ */
14
18
  export declare function renderAsStream(params: RenderOptions): Promise<void>;
15
19
  export {};
package/dist/renderer.js CHANGED
@@ -1,11 +1,19 @@
1
- import { cachedFramework } from "./api/framework";
2
- import { render } from "./react/renderer-react";
3
- import { renderVue } from "./vue/renderer.vue";
4
- export async function renderAsStream(params) {
5
- if (cachedFramework === 'react') {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderAsStream = renderAsStream;
4
+ const framework_1 = require("./api/framework");
5
+ /**
6
+ * Renderiza a requisição como stream, carregando o driver apropriado dinamicamente.
7
+ * Isso evita erros de "Module Not Found" quando um dos frameworks não está instalado.
8
+ */
9
+ async function renderAsStream(params) {
10
+ if (framework_1.cachedFramework === 'react') {
11
+ // Import dinâmico garante que o código do React só seja avaliado se necessário
12
+ const { render } = await import("./react/renderer-react.js");
6
13
  return await render(params);
7
14
  }
8
15
  else {
16
+ const { renderVue } = await import("./vue/renderer.vue.js");
9
17
  return await renderVue(params);
10
18
  }
11
19
  }