hightjs 0.5.1 → 0.5.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.
package/dist/router.js CHANGED
@@ -60,7 +60,7 @@ function clearRequireCache(filePath) {
60
60
  const resolvedPath = require.resolve(filePath);
61
61
  delete require.cache[resolvedPath];
62
62
  // Também limpa arquivos temporários relacionados (apenas se existir no cache)
63
- const tempFile = filePath.replace(/\.(tsx|ts)$/, '.temp.$1');
63
+ const tempFile = filePath.replace(/\.(tsx|ts|jsx|js)$/, '.temp.$1');
64
64
  const tempResolvedPath = require.cache[require.resolve(tempFile)];
65
65
  if (tempResolvedPath) {
66
66
  delete require.cache[require.resolve(tempFile)];
@@ -110,9 +110,13 @@ function clearFileCache(changedFilePath) {
110
110
  */
111
111
  function loadLayout(webDir) {
112
112
  const layoutPath = path_1.default.join(webDir, 'layout.tsx');
113
- const layoutPathJs = path_1.default.join(webDir, 'layout.ts');
113
+ const layoutPathTs = path_1.default.join(webDir, 'layout.ts');
114
+ const layoutPathJsx = path_1.default.join(webDir, 'layout.jsx');
115
+ const layoutPathJs = path_1.default.join(webDir, 'layout.js');
114
116
  const layoutFile = fs_1.default.existsSync(layoutPath) ? layoutPath :
115
- fs_1.default.existsSync(layoutPathJs) ? layoutPathJs : null;
117
+ fs_1.default.existsSync(layoutPathTs) ? layoutPathTs :
118
+ fs_1.default.existsSync(layoutPathJsx) ? layoutPathJsx :
119
+ fs_1.default.existsSync(layoutPathJs) ? layoutPathJs : null;
116
120
  if (layoutFile) {
117
121
  const absolutePath = path_1.default.resolve(layoutFile);
118
122
  const componentPath = path_1.default.relative(process.cwd(), layoutFile).replace(/\\/g, '/');
@@ -123,7 +127,7 @@ function loadLayout(webDir) {
123
127
  .replace(/import\s+['"][^'"]*\.css['"];?/g, '// CSS import removido para servidor')
124
128
  .replace(/import\s+['"][^'"]*\.scss['"];?/g, '// SCSS import removido para servidor')
125
129
  .replace(/import\s+['"][^'"]*\.sass['"];?/g, '// SASS import removido para servidor');
126
- const tempFile = layoutFile.replace(/\.(tsx|ts)$/, '.temp.$1');
130
+ const tempFile = layoutFile.replace(/\.(tsx|ts|jsx|js)$/, '.temp.$1');
127
131
  fs_1.default.writeFileSync(tempFile, tempContent);
128
132
  // Otimização: limpa cache apenas se existir
129
133
  try {
@@ -181,8 +185,9 @@ function loadRoutes(routesDir) {
181
185
  scanDirectory(path_1.default.join(dir, entry.name), relativePath);
182
186
  }
183
187
  else if (entry.isFile()) {
184
- // Filtra apenas arquivos .ts/.tsx
185
- if (entry.name.endsWith('.ts') || entry.name.endsWith('.tsx')) {
188
+ // Filtra apenas arquivos .ts/.tsx/.js/.jsx
189
+ if (entry.name.endsWith('.ts') || entry.name.endsWith('.tsx') ||
190
+ entry.name.endsWith('.js') || entry.name.endsWith('.jsx')) {
186
191
  routeFiles.push(relativePath);
187
192
  }
188
193
  }
@@ -260,11 +265,15 @@ let loadedMiddlewares = new Map();
260
265
  */
261
266
  function loadMiddlewareFromDirectory(dir) {
262
267
  const middlewares = [];
263
- // Procura por middleware.ts ou middleware.tsx
268
+ // Procura por middleware.ts, middleware.tsx, middleware.js ou middleware.jsx
264
269
  const middlewarePath = path_1.default.join(dir, 'middleware.ts');
265
270
  const middlewarePathTsx = path_1.default.join(dir, 'middleware.tsx');
271
+ const middlewarePathJs = path_1.default.join(dir, 'middleware.js');
272
+ const middlewarePathJsx = path_1.default.join(dir, 'middleware.jsx');
266
273
  const middlewareFile = fs_1.default.existsSync(middlewarePath) ? middlewarePath :
267
- fs_1.default.existsSync(middlewarePathTsx) ? middlewarePathTsx : null;
274
+ fs_1.default.existsSync(middlewarePathTsx) ? middlewarePathTsx :
275
+ fs_1.default.existsSync(middlewarePathJs) ? middlewarePathJs :
276
+ fs_1.default.existsSync(middlewarePathJsx) ? middlewarePathJsx : null;
268
277
  if (middlewareFile) {
269
278
  try {
270
279
  const absolutePath = path_1.default.resolve(middlewareFile);
@@ -331,8 +340,9 @@ function loadBackendRoutes(backendRoutesDir) {
331
340
  scanDirectory(path_1.default.join(dir, entry.name), relativePath);
332
341
  }
333
342
  else if (entry.isFile()) {
334
- const isTypeScript = entry.name.endsWith('.ts') || entry.name.endsWith('.tsx');
335
- if (!isTypeScript)
343
+ const isSupported = entry.name.endsWith('.ts') || entry.name.endsWith('.tsx') ||
344
+ entry.name.endsWith('.js') || entry.name.endsWith('.jsx');
345
+ if (!isSupported)
336
346
  continue;
337
347
  // Identifica middlewares durante o scan
338
348
  if (entry.name.startsWith('middleware')) {
@@ -445,9 +455,13 @@ function findMatchingBackendRoute(pathname, method) {
445
455
  */
446
456
  function loadNotFound(webDir) {
447
457
  const notFoundPath = path_1.default.join(webDir, 'notFound.tsx');
448
- const notFoundPathJs = path_1.default.join(webDir, 'notFound.ts');
458
+ const notFoundPathTs = path_1.default.join(webDir, 'notFound.ts');
459
+ const notFoundPathJsx = path_1.default.join(webDir, 'notFound.jsx');
460
+ const notFoundPathJs = path_1.default.join(webDir, 'notFound.js');
449
461
  const notFoundFile = fs_1.default.existsSync(notFoundPath) ? notFoundPath :
450
- fs_1.default.existsSync(notFoundPathJs) ? notFoundPathJs : null;
462
+ fs_1.default.existsSync(notFoundPathTs) ? notFoundPathTs :
463
+ fs_1.default.existsSync(notFoundPathJsx) ? notFoundPathJsx :
464
+ fs_1.default.existsSync(notFoundPathJs) ? notFoundPathJs : null;
451
465
  if (notFoundFile) {
452
466
  const absolutePath = path_1.default.resolve(notFoundFile);
453
467
  const componentPath = path_1.default.relative(process.cwd(), notFoundFile).replace(/\\/g, '/');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hightjs",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "HightJS 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
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/router.ts CHANGED
@@ -51,7 +51,7 @@ function clearRequireCache(filePath: string) {
51
51
  delete require.cache[resolvedPath];
52
52
 
53
53
  // Também limpa arquivos temporários relacionados (apenas se existir no cache)
54
- const tempFile = filePath.replace(/\.(tsx|ts)$/, '.temp.$1');
54
+ const tempFile = filePath.replace(/\.(tsx|ts|jsx|js)$/, '.temp.$1');
55
55
  const tempResolvedPath = require.cache[require.resolve(tempFile)];
56
56
  if (tempResolvedPath) {
57
57
  delete require.cache[require.resolve(tempFile)];
@@ -107,9 +107,13 @@ export function clearFileCache(changedFilePath: string) {
107
107
  */
108
108
  export function loadLayout(webDir: string): { componentPath: string; metadata?: any } | null {
109
109
  const layoutPath = path.join(webDir, 'layout.tsx');
110
- const layoutPathJs = path.join(webDir, 'layout.ts');
110
+ const layoutPathTs = path.join(webDir, 'layout.ts');
111
+ const layoutPathJsx = path.join(webDir, 'layout.jsx');
112
+ const layoutPathJs = path.join(webDir, 'layout.js');
111
113
 
112
114
  const layoutFile = fs.existsSync(layoutPath) ? layoutPath :
115
+ fs.existsSync(layoutPathTs) ? layoutPathTs :
116
+ fs.existsSync(layoutPathJsx) ? layoutPathJsx :
113
117
  fs.existsSync(layoutPathJs) ? layoutPathJs : null;
114
118
 
115
119
  if (layoutFile) {
@@ -124,7 +128,7 @@ export function loadLayout(webDir: string): { componentPath: string; metadata?:
124
128
  .replace(/import\s+['"][^'"]*\.scss['"];?/g, '// SCSS import removido para servidor')
125
129
  .replace(/import\s+['"][^'"]*\.sass['"];?/g, '// SASS import removido para servidor');
126
130
 
127
- const tempFile = layoutFile.replace(/\.(tsx|ts)$/, '.temp.$1');
131
+ const tempFile = layoutFile.replace(/\.(tsx|ts|jsx|js)$/, '.temp.$1');
128
132
  fs.writeFileSync(tempFile, tempContent);
129
133
 
130
134
  // Otimização: limpa cache apenas se existir
@@ -189,8 +193,9 @@ export function loadRoutes(routesDir: string): (RouteConfig & { componentPath: s
189
193
  if (entry.name === 'backend') continue;
190
194
  scanDirectory(path.join(dir, entry.name), relativePath);
191
195
  } else if (entry.isFile()) {
192
- // Filtra apenas arquivos .ts/.tsx
193
- if (entry.name.endsWith('.ts') || entry.name.endsWith('.tsx')) {
196
+ // Filtra apenas arquivos .ts/.tsx/.js/.jsx
197
+ if (entry.name.endsWith('.ts') || entry.name.endsWith('.tsx') ||
198
+ entry.name.endsWith('.js') || entry.name.endsWith('.jsx')) {
194
199
  routeFiles.push(relativePath);
195
200
  }
196
201
  }
@@ -283,12 +288,16 @@ let loadedMiddlewares: Map<string, HightMiddleware[]> = new Map();
283
288
  function loadMiddlewareFromDirectory(dir: string): HightMiddleware[] {
284
289
  const middlewares: HightMiddleware[] = [];
285
290
 
286
- // Procura por middleware.ts ou middleware.tsx
291
+ // Procura por middleware.ts, middleware.tsx, middleware.js ou middleware.jsx
287
292
  const middlewarePath = path.join(dir, 'middleware.ts');
288
293
  const middlewarePathTsx = path.join(dir, 'middleware.tsx');
294
+ const middlewarePathJs = path.join(dir, 'middleware.js');
295
+ const middlewarePathJsx = path.join(dir, 'middleware.jsx');
289
296
 
290
297
  const middlewareFile = fs.existsSync(middlewarePath) ? middlewarePath :
291
- fs.existsSync(middlewarePathTsx) ? middlewarePathTsx : null;
298
+ fs.existsSync(middlewarePathTsx) ? middlewarePathTsx :
299
+ fs.existsSync(middlewarePathJs) ? middlewarePathJs :
300
+ fs.existsSync(middlewarePathJsx) ? middlewarePathJsx : null;
292
301
 
293
302
  if (middlewareFile) {
294
303
  try {
@@ -365,8 +374,9 @@ export function loadBackendRoutes(backendRoutesDir: string) {
365
374
  if (entry.isDirectory()) {
366
375
  scanDirectory(path.join(dir, entry.name), relativePath);
367
376
  } else if (entry.isFile()) {
368
- const isTypeScript = entry.name.endsWith('.ts') || entry.name.endsWith('.tsx');
369
- if (!isTypeScript) continue;
377
+ const isSupported = entry.name.endsWith('.ts') || entry.name.endsWith('.tsx') ||
378
+ entry.name.endsWith('.js') || entry.name.endsWith('.jsx');
379
+ if (!isSupported) continue;
370
380
 
371
381
  // Identifica middlewares durante o scan
372
382
  if (entry.name.startsWith('middleware')) {
@@ -487,9 +497,13 @@ export function findMatchingBackendRoute(pathname: string, method: string) {
487
497
  */
488
498
  export function loadNotFound(webDir: string): { componentPath: string } | null {
489
499
  const notFoundPath = path.join(webDir, 'notFound.tsx');
490
- const notFoundPathJs = path.join(webDir, 'notFound.ts');
500
+ const notFoundPathTs = path.join(webDir, 'notFound.ts');
501
+ const notFoundPathJsx = path.join(webDir, 'notFound.jsx');
502
+ const notFoundPathJs = path.join(webDir, 'notFound.js');
491
503
 
492
504
  const notFoundFile = fs.existsSync(notFoundPath) ? notFoundPath :
505
+ fs.existsSync(notFoundPathTs) ? notFoundPathTs :
506
+ fs.existsSync(notFoundPathJsx) ? notFoundPathJsx :
493
507
  fs.existsSync(notFoundPathJs) ? notFoundPathJs : null;
494
508
 
495
509
  if (notFoundFile) {