24);
25
26function Hero({
27 prompt,
28 setPrompt,
44
45 <p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
46 Turn your ideas into fully functional apps in{" "}
47 <span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
48 less than a second
115}
116
117function App() {
118 const previewRef = React.useRef<HTMLDivElement>(null);
119 const [prompt, setPrompt] = useState("");
168 });
169
170 function handleStarterPromptClick(promptItem: typeof prompts[number]) {
171 setLoading(true);
172 setTimeout(() => handleSubmit(promptItem.prompt), 0);
173 }
174
175 async function handleSubmit(e: React.FormEvent | string) {
176 if (typeof e !== "string") {
177 e.preventDefault();
224 }
225
226 function handleVersionChange(direction: "back" | "forward") {
227 const { currentVersionIndex, versions } = versionHistory;
228 if (direction === "back" && currentVersionIndex > 0) {
972);
973
974function client() {
975 const path = window.location.pathname;
976 const root = createRoot(document.getElementById("root")!);
1008}
1009
1010function extractCodeFromFence(text: string): string {
1011 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
1012 return htmlMatch ? htmlMatch[1].trim() : text;
1013}
1014
1015async function generateCode(prompt: string, currentCode: string) {
1016 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
1017 if (starterPrompt) {
1057}
1058
1059export default async function server(req: Request): Promise<Response> {
1060 // Dynamic import for SQLite to avoid client-side import
1061 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
24);
25
26function Hero({
27 prompt,
28 setPrompt,
45
46 <p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
47 Turn your ideas into fully functional apps in{" "}
48 <span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
49 less than a second
116}
117
118function App() {
119 const previewRef = React.useRef<HTMLDivElement>(null);
120 const [prompt, setPrompt] = useState("");
171 });
172
173 function handleStarterPromptClick(promptItem: typeof prompts[number]) {
174 setLoading(true);
175 setTimeout(() => handleSubmit(promptItem.prompt), 0);
176 }
177
178 async function handleSubmit(e: React.FormEvent | string) {
179 if (typeof e !== "string") {
180 e.preventDefault();
227 }
228
229 function handleVersionChange(direction: "back" | "forward") {
230 const { currentVersionIndex, versions } = versionHistory;
231 if (direction === "back" && currentVersionIndex > 0) {
975);
976
977function client() {
978 const path = window.location.pathname;
979 const root = createRoot(document.getElementById("root")!);
1011}
1012
1013function extractCodeFromFence(text: string): string {
1014 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
1015 return htmlMatch ? htmlMatch[1].trim() : text;
1016}
1017
1018async function generateCode(prompt: string, currentCode: string) {
1019 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
1020 if (starterPrompt) {
1081}
1082
1083export default async function server(req: Request): Promise<Response> {
1084 // Dynamic import for SQLite to avoid client-side import
1085 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
3import { deleteCookie, getCookies, setCookie } from "jsr:@std/http/cookie";
4
5async function createSession(email: string, hostname: string) {
6 const sessionID = crypto.randomUUID();
7 const expiresAt = new Date();
23}
24
25async function getSession(sessionID: string, hostname: string) {
26 try {
27 const res = await sqlite.execute({
49}
50
51async function deleteSession(sessionID: string) {
52 await sqlite.execute({
53 sql: `DELETE FROM lastlogin_session WHERE sessionID=?`,
65};
66
67export function lastlogin(
68 handler: (req: Request) => Response | Promise<Response>,
69 options: LastLoginOptions,
1async function fetchUser(token: string): Promise<{ email: string }> {
2 const resp = await fetch("https://api.val.town/v1/me", {
3 headers: {
13}
14
15export async function verifyEmail(email: string) {
16 try {
17 const user = await fetchUser(Deno.env.get("valtown"));
4import { GoogleGenerativeAI } from "https://esm.sh/@google/generative-ai";
5
6function ProgressBar({ progress }) {
7 return (
8 <div className="w-full bg-gray-200 rounded-full h-2.5 dark:bg-gray-700 mb-4">
16}
17
18function PostDetails({ post }) {
19 if (!post) return null;
20 const hnDiscussionUrl = `https://news.ycombinator.com/item?id=${post.id}`;
76}
77
78function App() {
79 const [postId, setPostId] = useState("");
80 const [postDetails, setPostDetails] = useState(null);
216}
217
218function client() {
219 console.log("Client function called");
220 const root = document.getElementById("root");
221 if (root) {
244}
245
246export default async function server(request: Request): Promise<Response> {
247 console.log("Server function called", request.method, request.url);
248
249 // Handle root GET request
279 <script>
280 console.log("Inline script executed");
281 window.addEventListener('load', function() {
282 console.log("Window load event fired");
283 setTimeout(function() {
284 var loadingMessage = document.getElementById('loading-message');
285 if (loadingMessage) {
11type PromptItem = typeof prompts[number];
12
13function Hero({
14 prompt,
15 setPrompt,
49
50 <p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
51 Turn your ideas into fully functional apps in{" "}
52 <span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
53 less than a second
120}
121
122function App() {
123 const previewRef = React.useRef<HTMLDivElement>(null);
124 const [prompt, setPrompt] = useState("");
173 });
174
175 function handleStarterPromptClick(promptItem: typeof prompts[number]) {
176 setLoading(true);
177 setTimeout(() => handleSubmit(promptItem.prompt), 0);
178 }
179
180 async function handleSubmit(e: React.FormEvent | string) {
181 if (typeof e !== "string") {
182 e.preventDefault();
229 }
230
231 function handleVersionChange(direction: "back" | "forward") {
232 const { currentVersionIndex, versions } = versionHistory;
233 if (direction === "back" && currentVersionIndex > 0) {
992);
993
994function client() {
995 const path = window.location.pathname;
996 const root = createRoot(document.getElementById("root")!);
1028}
1029
1030function extractCodeFromFence(text: string): string {
1031 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
1032 return htmlMatch ? htmlMatch[1].trim() : text;
1033}
1034
1035async function generateCode(prompt: string, currentCode: string) {
1036 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
1037 if (starterPrompt) {
1074}
1075
1076export default async function server(req: Request): Promise<Response> {
1077 // Dynamic import for SQLite to avoid client-side import
1078 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
12type PromptItem = typeof prompts[number];
13
14function Hero({
15 prompt,
16 setPrompt,
50
51 <p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
52 Turn your ideas into fully functional apps in{" "}
53 <span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
54 less than a second
121}
122
123function App() {
124 const previewRef = React.useRef<HTMLDivElement>(null);
125 const [prompt, setPrompt] = useState("");
174 });
175
176 function handleStarterPromptClick(promptItem: typeof prompts[number]) {
177 setLoading(true);
178 setTimeout(() => handleSubmit(promptItem.prompt), 0);
179 }
180
181 async function handleSubmit(e: React.FormEvent | string) {
182 if (typeof e !== "string") {
183 e.preventDefault();
230 }
231
232 function handleVersionChange(direction: "back" | "forward") {
233 const { currentVersionIndex, versions } = versionHistory;
234 if (direction === "back" && currentVersionIndex > 0) {
993);
994
995function client() {
996 const path = window.location.pathname;
997 const root = createRoot(document.getElementById("root")!);
1029}
1030
1031function extractCodeFromFence(text: string): string {
1032 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
1033 return htmlMatch ? htmlMatch[1].trim() : text;
1034}
1035
1036async function generateCode(prompt: string, currentCode: string) {
1037 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
1038 if (starterPrompt) {
1075}
1076
1077export default async function server(req: Request): Promise<Response> {
1078 // Dynamic import for SQLite to avoid client-side import
1079 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
777 }
778
779 function predictDraw(teamA, teamB, tournament) {
780 if (!teamA || !teamB) return 0;
781
782 // Helper function to calculate draw rate
783 const calculateDrawRate = (team) =>
784 team.results.draws / team.totalMatches;
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function App() {
6 const handlePostMessage = () => {
7 window.parent.postMessage('{"data": "foo", "field": "expected", "type": "update"}', '*');
29}
30
31function client() {
32 createRoot(document.getElementById("root")).render(<App />);
33}
34if (typeof document !== "undefined") { client(); }
35
36export default async function server(request: Request): Promise<Response> {
37 return new Response(`
38 <html>
2import { wholefoodssales } from "https://esm.town/v/Glench/wholefoodssales";
3
4export default async function(req: Request): Promise<Response> {
5 return new Response(dataToRSS(await wholefoodssales(), {
6 title: "Whole Foods Sales — Personal",