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,
52
53 <p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
54 Turn your ideas into fully functional apps in{" "}
55 <span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
56 less than a second
124}
125
126function App() {
127 const previewRef = React.useRef<HTMLDivElement>(null);
128 const [prompt, setPrompt] = useState("");
178 });
179
180 function handleStarterPromptClick(promptItem: typeof prompts[number]) {
181 setLoading(true);
182 setTimeout(() => handleSubmit(promptItem.prompt), 0);
183 }
184
185 async function handleSubmit(e: React.FormEvent | string) {
186 if (typeof e !== "string") {
187 e.preventDefault();
234 }
235
236 function handleVersionChange(direction: "back" | "forward") {
237 const { currentVersionIndex, versions } = versionHistory;
238 if (direction === "back" && currentVersionIndex > 0) {
982);
983
984async function client() {
985 const path = window.location.pathname;
986 const root = createRoot(document.getElementById("root")!);
1020}
1021
1022function extractCodeFromFence(text: string): string {
1023 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
1024 return htmlMatch ? htmlMatch[1].trim() : text;
1025}
1026
1027async function generateCode(prompt: string, currentCode: string) {
1028 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
1029 if (starterPrompt) {
1069}
1070
1071export default async function server(req: Request): Promise<Response> {
1072 // Dynamic import for SQLite to avoid client-side import
1073 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
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,
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,
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,
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) {