tova 0.4.3 → 0.4.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tova",
3
- "version": "0.4.3",
3
+ "version": "0.4.4",
4
4
  "description": "Tova — a modern programming language that transpiles to JavaScript, unifying frontend and backend",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -2380,11 +2380,16 @@ export class ServerCodegen extends BaseCodegen {
2380
2380
  // 21. Request Handler — with global rate limit check (F2)
2381
2381
  // ════════════════════════════════════════════════════════════
2382
2382
  if (isFastMode) {
2383
+ // Build combined list of all static routes (declared routes + RPC endpoints)
2384
+ const rpcRoutes = functions.map(fn => ({ method: 'POST', path: `/rpc/${fn.name}` }));
2385
+ const allFastRoutes = [...routes, ...rpcRoutes];
2386
+ const allFastStatic = allFastRoutes.every(r => !r.path.includes(':') && !r.path.includes('*'));
2387
+
2383
2388
  // Fast mode: emit direct handler references for static routes
2384
- if (allRoutesStatic && routes.length <= 16) {
2385
- for (let ri = 0; ri < routes.length; ri++) {
2386
- const method = routes[ri].method.toUpperCase();
2387
- const path = routes[ri].path;
2389
+ if (allFastStatic && allFastRoutes.length <= 16) {
2390
+ for (let ri = 0; ri < allFastRoutes.length; ri++) {
2391
+ const method = allFastRoutes[ri].method.toUpperCase();
2392
+ const path = allFastRoutes[ri].path;
2388
2393
  lines.push(`const __fh${ri} = __staticRoutes.get(${JSON.stringify(method + ' ' + path)}).handler;`);
2389
2394
  }
2390
2395
  }
@@ -2401,18 +2406,18 @@ export class ServerCodegen extends BaseCodegen {
2401
2406
  lines.push(' if (__method === "OPTIONS") return new Response(null, { status: 204, headers: __corsHeadersConst });');
2402
2407
 
2403
2408
  // Static route dispatch — emit direct if/else chain using named handler refs
2404
- if (allRoutesStatic && routes.length <= 16) {
2405
- for (let ri = 0; ri < routes.length; ri++) {
2406
- const method = routes[ri].method.toUpperCase();
2407
- const path = routes[ri].path;
2409
+ if (allFastStatic && allFastRoutes.length <= 16) {
2410
+ for (let ri = 0; ri < allFastRoutes.length; ri++) {
2411
+ const method = allFastRoutes[ri].method.toUpperCase();
2412
+ const path = allFastRoutes[ri].path;
2408
2413
  const handlerVar = `__fh${ri}`;
2409
2414
  lines.push(` if (__method === ${JSON.stringify(method)} && __pathname === ${JSON.stringify(path)}) return ${handlerVar}(req, {});`);
2410
2415
  }
2411
2416
  // HEAD fallback for GET routes
2412
- for (let ri = 0; ri < routes.length; ri++) {
2413
- if (routes[ri].method.toUpperCase() === 'GET') {
2417
+ for (let ri = 0; ri < allFastRoutes.length; ri++) {
2418
+ if (allFastRoutes[ri].method.toUpperCase() === 'GET') {
2414
2419
  const handlerVar = `__fh${ri}`;
2415
- lines.push(` if (__method === "HEAD" && __pathname === ${JSON.stringify(routes[ri].path)}) return ${handlerVar}(req, {});`);
2420
+ lines.push(` if (__method === "HEAD" && __pathname === ${JSON.stringify(allFastRoutes[ri].path)}) return ${handlerVar}(req, {});`);
2416
2421
  }
2417
2422
  }
2418
2423
  } else {
package/src/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Auto-generated by scripts/embed-runtime.js — do not edit
2
- export const VERSION = "0.4.3";
2
+ export const VERSION = "0.4.4";