tova 0.4.3 → 0.4.5
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/bin/tova.js +2 -1
- package/package.json +1 -1
- package/src/codegen/server-codegen.js +16 -11
- package/src/version.js +1 -1
package/bin/tova.js
CHANGED
|
@@ -4393,7 +4393,8 @@ _tova "$@"
|
|
|
4393
4393
|
|
|
4394
4394
|
function detectInstallMethod() {
|
|
4395
4395
|
const execPath = process.execPath || process.argv[0];
|
|
4396
|
-
|
|
4396
|
+
const scriptPath = process.argv[1] || '';
|
|
4397
|
+
if (execPath.includes('.tova/bin') || scriptPath.includes('.tova/')) return 'binary';
|
|
4397
4398
|
return 'npm';
|
|
4398
4399
|
}
|
|
4399
4400
|
|
package/package.json
CHANGED
|
@@ -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 (
|
|
2385
|
-
for (let ri = 0; ri <
|
|
2386
|
-
const method =
|
|
2387
|
-
const 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 (
|
|
2405
|
-
for (let ri = 0; ri <
|
|
2406
|
-
const method =
|
|
2407
|
-
const 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 <
|
|
2413
|
-
if (
|
|
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(
|
|
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.
|
|
2
|
+
export const VERSION = "0.4.5";
|