3import { createProject, getCode, getNextVersionNumber, insertVersion } from "./database/queries";
4
5async function servePublicFile(path: string): Promise<Response> {
6 const url = new URL("./public/" + path, import.meta.url);
7 const text = await (await fetch(url, {
20await createTables();
21
22export default async function cerebras_coder(req: Request): Promise<Response> {
23 if (req.method === "POST") {
24 let { prompt, currentCode, versionHistory, projectId } = await req.json();
23);
24
25function Hero({
26 prompt,
27 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("");
169 });
170
171 function handleStarterPromptClick(promptItem: typeof prompts[number]) {
172 setLoading(true);
173 setTimeout(() => handleSubmit(promptItem.prompt), 0);
174 }
175
176 async function handleSubmit(e: React.FormEvent | string) {
177 if (typeof e !== "string") {
178 e.preventDefault();
225 }
226
227 function handleVersionChange(direction: "back" | "forward") {
228 const { currentVersionIndex, versions } = versionHistory;
229 if (direction === "back" && currentVersionIndex > 0) {
973);
974
975function client() {
976 const path = window.location.pathname;
977 const root = createRoot(document.getElementById("root")!);
2import STARTER_PROMPTS from "../public/starter-prompts.js";
3
4function extractCodeFromFence(text: string): string {
5 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
6 return htmlMatch ? htmlMatch[1].trim() : text;
7}
8
9export async function generateCode(prompt: string, currentCode: string) {
10 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
11 if (starterPrompt) {
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function App() {
6 const [formData, setFormData] = useState({
7 name: '',
190}
191
192function client() {
193 createRoot(document.getElementById("root")).render(<App />);
194}
195if (typeof document !== "undefined") { client(); }
196
197export default async function server(request: Request): Promise<Response> {
198 if (request.method === 'POST' && new URL(request.url).pathname === '/submit-inquiry') {
199 try {
60];
61
62function WeatherDashboard() {
63 // Styles remain unchanged from previous implementation
64
95 const messagesEndRef = useRef(null);
96
97 // Rest of the utility functions remain the same
98 const renderWeatherIcon = (temperature) => {
99 if (temperature > 30) return "🔥";
276}
277
278function client() {
279 createRoot(document.getElementById("root")).render(<WeatherDashboard />);
280}
281if (typeof document !== "undefined") { client(); }
282
283export default async function server(request: Request): Promise<Response> {
284 return new Response(`
285 <html>
2import { easyAQI } from "https://esm.town/v/stevekrouse/easyAQI?v=5";
3
4export async function aqi(interval: Interval) {
5 const location = "new york"; // <-- change to place, city, or zip code
6 const data = await easyAQI({ location });
2import { easyAQI } from "https://esm.town/v/stevekrouse/easyAQI?v=5";
3
4export async function aqi(interval: Interval) {
5 const location = "downtown brooklyn"; // <-- change to place, city, or zip code
6 const data = await easyAQI({ location });
4import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
5
6function SocialLinks() {
7 const [hoveredLink, setHoveredLink] = useState(null);
8
42}
43
44function App() {
45 return (
46 <div
76}
77
78function client() {
79 createRoot(document.getElementById("root")).render(<App />);
80}
81if (typeof document !== "undefined") { client(); }
82
83export default async function(req: Request) {
84 return new Response(
85 renderToString(
2import { renderToString } from "npm:react-dom/server";
3
4export default async function(req: Request) {
5 return new Response(
6 renderToString(
3import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
4
5function WeatherDashboard() {
6 const [location, setLocation] = useState({ latitude: 40.7128, longitude: -74.0060 }); // Default to New York City
7 const [weatherData, setWeatherData] = useState(null);
9
10 useEffect(() => {
11 async function fetchWeather() {
12 try {
13 const response = await fetch(
74}
75
76function client() {
77 createRoot(document.getElementById("root")).render(<WeatherDashboard />);
78}
79if (typeof document !== "undefined") { client(); }
80
81export default async function server(request: Request): Promise<Response> {
82 return new Response(
83 `