tova 0.2.4 → 0.2.6
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 +30 -13
- package/package.json +1 -1
- package/src/version.js +1 -1
package/bin/tova.js
CHANGED
|
@@ -500,6 +500,28 @@ async function devServer(args) {
|
|
|
500
500
|
|
|
501
501
|
const reloadPort = basePort + 100;
|
|
502
502
|
|
|
503
|
+
// Start live-reload SSE server early so actualReloadPort is available for HTML generation
|
|
504
|
+
const reloadClients = new Set();
|
|
505
|
+
let reloadServer;
|
|
506
|
+
let actualReloadPort = reloadPort;
|
|
507
|
+
for (let attempt = 0; attempt < 10; attempt++) {
|
|
508
|
+
try {
|
|
509
|
+
reloadServer = Bun.serve({
|
|
510
|
+
port: actualReloadPort,
|
|
511
|
+
fetch(req) {
|
|
512
|
+
return handleReloadFetch(req);
|
|
513
|
+
},
|
|
514
|
+
});
|
|
515
|
+
break;
|
|
516
|
+
} catch {
|
|
517
|
+
actualReloadPort++;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
if (!reloadServer) {
|
|
521
|
+
console.log(' ⚠ Could not start live-reload server (ports in use)');
|
|
522
|
+
actualReloadPort = 0;
|
|
523
|
+
}
|
|
524
|
+
|
|
503
525
|
console.log(`\n Tova dev server starting...\n`);
|
|
504
526
|
|
|
505
527
|
// Compile all files
|
|
@@ -544,7 +566,7 @@ async function devServer(args) {
|
|
|
544
566
|
if (output.client) {
|
|
545
567
|
const p = join(outDir, `${outBaseName}.client.js`);
|
|
546
568
|
writeFileSync(p, output.client);
|
|
547
|
-
clientHTML = await generateDevHTML(output.client, srcDir,
|
|
569
|
+
clientHTML = await generateDevHTML(output.client, srcDir, actualReloadPort);
|
|
548
570
|
writeFileSync(join(outDir, 'index.html'), clientHTML);
|
|
549
571
|
hasClient = true;
|
|
550
572
|
}
|
|
@@ -624,11 +646,7 @@ async function devServer(args) {
|
|
|
624
646
|
console.log(` ✓ Client: ${relative('.', outDir)}/index.html`);
|
|
625
647
|
}
|
|
626
648
|
|
|
627
|
-
|
|
628
|
-
const reloadClients = new Set();
|
|
629
|
-
const reloadServer = Bun.serve({
|
|
630
|
-
port: reloadPort,
|
|
631
|
-
fetch(req) {
|
|
649
|
+
function handleReloadFetch(req) {
|
|
632
650
|
const url = new URL(req.url);
|
|
633
651
|
if (url.pathname === '/__tova_reload') {
|
|
634
652
|
const stream = new ReadableStream({
|
|
@@ -655,8 +673,7 @@ async function devServer(args) {
|
|
|
655
673
|
});
|
|
656
674
|
}
|
|
657
675
|
return new Response('Not Found', { status: 404 });
|
|
658
|
-
|
|
659
|
-
});
|
|
676
|
+
}
|
|
660
677
|
|
|
661
678
|
function notifyReload() {
|
|
662
679
|
const msg = new TextEncoder().encode('data: reload\n\n');
|
|
@@ -665,7 +682,7 @@ async function devServer(args) {
|
|
|
665
682
|
}
|
|
666
683
|
}
|
|
667
684
|
|
|
668
|
-
console.log(` ✓ Live reload on port ${
|
|
685
|
+
if (reloadServer) console.log(` ✓ Live reload on port ${actualReloadPort}`);
|
|
669
686
|
|
|
670
687
|
// Start file watcher for auto-rebuild
|
|
671
688
|
const watcher = startWatcher(srcDir, async () => {
|
|
@@ -698,7 +715,7 @@ async function devServer(args) {
|
|
|
698
715
|
}
|
|
699
716
|
if (output.client) {
|
|
700
717
|
writeFileSync(join(outDir, `${outBaseName}.client.js`), output.client);
|
|
701
|
-
rebuildClientHTML = await generateDevHTML(output.client, srcDir,
|
|
718
|
+
rebuildClientHTML = await generateDevHTML(output.client, srcDir, actualReloadPort);
|
|
702
719
|
writeFileSync(join(outDir, 'index.html'), rebuildClientHTML);
|
|
703
720
|
}
|
|
704
721
|
if (output.server) {
|
|
@@ -757,9 +774,9 @@ async function devServer(args) {
|
|
|
757
774
|
process.on('SIGINT', () => {
|
|
758
775
|
console.log('\n Shutting down...');
|
|
759
776
|
watcher.close();
|
|
760
|
-
reloadServer.stop();
|
|
777
|
+
if (reloadServer) reloadServer.stop();
|
|
761
778
|
for (const p of processes) {
|
|
762
|
-
p.child.kill('
|
|
779
|
+
try { p.child.kill('SIGKILL'); } catch {}
|
|
763
780
|
}
|
|
764
781
|
process.exit(0);
|
|
765
782
|
});
|
|
@@ -942,7 +959,7 @@ client {
|
|
|
942
959
|
|
|
943
960
|
component App {
|
|
944
961
|
<div class="app">
|
|
945
|
-
<h1>"
|
|
962
|
+
<h1>"{message}"</h1>
|
|
946
963
|
<p>"Edit src/app.tova to get started."</p>
|
|
947
964
|
</div>
|
|
948
965
|
}
|
package/package.json
CHANGED
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.2.
|
|
2
|
+
export const VERSION = "0.2.6";
|