linkInBioTemplatemain.tsx1 match
2import { renderToString } from "npm:react-dom/server";
34export default async function(req: Request) {
5return new Response(
6renderToString(
12});
1314async function main() {
15let session;
16let browser;
trackESMContentmain.tsx5 matches
10const TABLE_NAME = `${KEY}_versions_v1`;
1112async function fetchContent(url: string) {
13const response = await fetch(url);
14return await response.text();
15}
1617async function initializeDatabase() {
18await sqlite.execute(`
19CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (
26}
2728export default async function(interval: Interval) {
29await initializeDatabase();
3056}
5758async function sha256(message: string): Promise<string> {
59const msgUint8 = new TextEncoder().encode(message);
60const hashBuffer = await crypto.subtle.digest("SHA-256", msgUint8);
64}
6566export async function getAllVersions() {
67await initializeDatabase();
68const versions = await sqlite.execute(`SELECT * FROM ${TABLE_NAME} ORDER BY timestamp DESC`);
12});
1314async function main() {
15let session;
16let browser;
1export default function server(req: Request): Response {
2const svg = `<svg width="140" height="35" viewBox="0 0 140 35" fill="none" xmlns="http://www.w3.org/2000/svg">
3<g clip-path="url(#clip0_0_3)">
react_client_forkmain.tsx8 matches
1<think>
2Okay, so the user provided a React application written in TypeScript, and they mentioned that the requested changes are undefined. That probably means they just want the code to be formatted or cleaned up without any functional changes.
34Looking at the code, I notice that it's using a mix of JavaScript and some TypeScript features, but it's not strictly typed. The initialTodos prop is defined as an array of objects with a text property, which is good. However, the state for todos and newTodo could benefit from more specific types.
6I'll start by adding explicit types to the useState hooks. For the todos state, I'll define it as an array of { text: string }, and for newTodo, it should be a string. This helps with type checking and makes the code more robust.
78Next, I'll format the code for better readability. I'll adjust the indentation and spacing, especially in the JSX where inline styles are applied. This makes the code cleaner and easier to read without changing any functionality.
910I also notice that the server function handles different routes. I'll make sure the syntax is consistent and that all possible routes are handled correctly. Since there are no requested changes, I won't alter the functionality here.
1112Finally, I'll ensure that all imports and function calls are correctly formatted and that there are no syntax errors. This includes checking that the createRoot function is properly used and that the client-side rendering is correctly set up.
1314In summary, the main steps are adding explicit types, improving code formatting, and ensuring consistency without changing any functionality since the requested changes were undefined.
15</think>
1623import { blob } from "https://esm.town/v/std/blob?v=10";
2425function App({ initialTodos }: { initialTodos: { text: string; }[]; }) {
26const [todos, setTodos] = useState<{ text: string; }[]>(Array.isArray(initialTodos) ? initialTodos : []);
27const [newTodo, setNewTodo] = useState<string>("");
117}
118119function client() {
120const fetchTodos = async () => {
121const response = await fetch('/todos');
131if (typeof document !== "undefined") { client(); }
132133export default async function server(request: Request) {
134if (request.method === 'POST' && request.url.endsWith('/add-todo')) {
135const body = await request.json();
cerebras_codermain.tsx11 matches
24);
2526function Hero({
27prompt,
28setPrompt,
4546<p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
47Turn your ideas into fully functional apps in{" "}
48<span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
49less than a second
116}
117118function App() {
119const previewRef = React.useRef<HTMLDivElement>(null);
120const [prompt, setPrompt] = useState("");
170});
171172function handleStarterPromptClick(promptItem: typeof prompts[number]) {
173setLoading(true);
174setTimeout(() => handleSubmit(promptItem.prompt), 0);
175}
176177async function handleSubmit(e: React.FormEvent | string) {
178if (typeof e !== "string") {
179e.preventDefault();
226}
227228function handleVersionChange(direction: "back" | "forward") {
229const { currentVersionIndex, versions } = versionHistory;
230if (direction === "back" && currentVersionIndex > 0) {
974);
975976function client() {
977const path = window.location.pathname;
978const root = createRoot(document.getElementById("root")!);
1010}
10111012function extractCodeFromFence(text: string): string {
1013const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
1014return htmlMatch ? htmlMatch[1].trim() : text;
1015}
10161017async function generateCode(prompt: string, currentCode: string) {
1018const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
1019if (starterPrompt) {
1060}
10611062export default async function cerebras_coder(req: Request): Promise<Response> {
1063// Dynamic import for SQLite to avoid client-side import
1064const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
1163<meta property="og:site_name" content="Cerebras Coder">
1164<meta property="og:url" content="https://cerebrascoder.com"/>
1165<meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1166<meta property="og:type" content="website">
1167<meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">
floatingQuotaTracker_Testmain.tsx2 matches
2import { floatingQuotaTracker } from 'https://esm.town/v/rozek/floatingQuotaTracker'
34export default async function () {
5const TestCases = [
6/**** test constructor with defaults ****/
243/**** removeTable ****/
244245async function removeTable (TableName:string):Promise<void> {
246console.log('(cleaning up)')
247await sqlite.execute(
30* tests successful increments up to the limit
31* verifies LimitExceeded error is thrown when limit is reached
329. Reset functionality
33* increments usage
34* tests reset method
cerebras_codermain.tsx10 matches
24);
2526function Hero({
27prompt,
28setPrompt,
4546<p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
47Turn your ideas into fully functional apps in{" "}
48<span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
49less than a second
116}
117118function App() {
119const previewRef = React.useRef<HTMLDivElement>(null);
120const [prompt, setPrompt] = useState("");
170});
171172function handleStarterPromptClick(promptItem: typeof prompts[number]) {
173setLoading(true);
174setTimeout(() => handleSubmit(promptItem.prompt), 0);
175}
176177async function handleSubmit(e: React.FormEvent | string) {
178if (typeof e !== "string") {
179e.preventDefault();
226}
227228function handleVersionChange(direction: "back" | "forward") {
229const { currentVersionIndex, versions } = versionHistory;
230if (direction === "back" && currentVersionIndex > 0) {
974);
975976function client() {
977const path = window.location.pathname;
978const root = createRoot(document.getElementById("root")!);
1010}
10111012function extractCodeFromFence(text: string): string {
1013const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
1014return htmlMatch ? htmlMatch[1].trim() : text;
1015}
10161017async function generateCode(prompt: string, currentCode: string) {
1018const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
1019if (starterPrompt) {
1059}
10601061export default async function server(req: Request): Promise<Response> {
1062// Dynamic import for SQLite to avoid client-side import
1063const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");