idk doesnt work
parent
7a11f92f13
commit
f7355f8576
@ -1,18 +1,79 @@
|
|||||||
import Html from "@kitajs/html";
|
import Html from "@kitajs/html";
|
||||||
|
import { config } from "../config";
|
||||||
|
|
||||||
export const BaseHtml = ({ children }: Html.PropsWithChildren) => `
|
export const BaseHtml = ({ children }: Html.PropsWithChildren) => (
|
||||||
<!DOCTYPE html>
|
<html>
|
||||||
<html lang="en">
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
<head>
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<meta charset="UTF-8">
|
<title>THE BETH STACK</title>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<script src="https://unpkg.com/htmx.org@1.9.3"></script>
|
||||||
<title>THE BETH STACK</title>
|
<script src="https://unpkg.com/hyperscript.org@0.9.9"></script>
|
||||||
<script src="https://unpkg.com/htmx.org@1.9.3"></script>
|
<link
|
||||||
<script src="https://unpkg.com/hyperscript.org@0.9.9"></script>
|
rel="stylesheet"
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@unocss/reset/tailwind.min.css">
|
href="https://cdn.jsdelivr.net/npm/@unocss/reset/tailwind.min.css"
|
||||||
<link rel="stylesheet" href="/public/dist/unocss.css">
|
/>
|
||||||
</head>
|
<link rel="stylesheet" href="/public/dist/unocss.css" />
|
||||||
|
<script>
|
||||||
${children}
|
{`
|
||||||
`;
|
(function () {
|
||||||
|
var consoleOutput = document.getElementById('consoleOutput');
|
||||||
|
|
||||||
|
if (!window.console) {
|
||||||
|
window.console = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
var oldConsoleLog = console.log;
|
||||||
|
|
||||||
|
console.log = function (message) {
|
||||||
|
// Append the log message to the consoleOutput div
|
||||||
|
if (consoleOutput) {
|
||||||
|
var logMessage = document.createElement('p');
|
||||||
|
logMessage.textContent = message;
|
||||||
|
consoleOutput.appendChild(logMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call the original console.log function
|
||||||
|
oldConsoleLog.apply(console, arguments);
|
||||||
|
};
|
||||||
|
|
||||||
|
// You can do the same for other console methods like error, warn, etc. if needed
|
||||||
|
|
||||||
|
})()
|
||||||
|
`}
|
||||||
|
</script>
|
||||||
|
<script>
|
||||||
|
{`
|
||||||
|
(function () {
|
||||||
|
let socket = new WebSocket("ws://localhost:3001/ws");
|
||||||
|
|
||||||
|
socket.onopen = function(e) {
|
||||||
|
console.log("connected")
|
||||||
|
};
|
||||||
|
|
||||||
|
socket.onmessage = function(event) {
|
||||||
|
console.log(event.data);
|
||||||
|
location.reload();
|
||||||
|
};
|
||||||
|
|
||||||
|
socket.onclose = function(event) {
|
||||||
|
console.log("closed");
|
||||||
|
};
|
||||||
|
|
||||||
|
socket.onerror = function(error) {
|
||||||
|
console.log("error: " + error.message);
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
`}
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div
|
||||||
|
id="consoleOutput"
|
||||||
|
style="background-color: #f0f0f0; padding: 10px;"
|
||||||
|
></div>
|
||||||
|
<script>console.log("Hello from the client side!");</script>
|
||||||
|
{children}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
);
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
import { Elysia, ws } from "elysia";
|
||||||
|
import { type ElysiaWS } from "elysia/ws";
|
||||||
|
import { watch } from "chokidar";
|
||||||
|
|
||||||
|
let wsConnections = new Set<ElysiaWS<any>>();
|
||||||
|
|
||||||
|
watch("src/**/*.{ts,tsx}").on("all", (event, path) => {
|
||||||
|
console.log("sending event");
|
||||||
|
wsConnections.forEach((connection) => {
|
||||||
|
connection.send("refresh");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const app = new Elysia()
|
||||||
|
.use(ws())
|
||||||
|
.ws("/ws", {
|
||||||
|
open(ws) {
|
||||||
|
console.log("open");
|
||||||
|
wsConnections.add(ws);
|
||||||
|
},
|
||||||
|
close(ws) {
|
||||||
|
console.log("close");
|
||||||
|
wsConnections.delete(ws);
|
||||||
|
},
|
||||||
|
message(ws, message) {
|
||||||
|
console.log("message", message);
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.listen(3001);
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
`🦊 Livereload running ${app.server?.hostname}:${app.server?.port}`
|
||||||
|
);
|
Loading…
Reference in New Issue