1/**
2* Wraps a server function to add ETag-based caching
3* @param serverFn The original server function to be wrapped
4* @returns A new server function with caching logic
5*/
6export default function httpCache(
7serverFn: (request: Request) => Promise<Response>,
8valUrl: string,
regexToBrainrotmain.tsx6 matches
13const { Children, toChildArray, cloneElement, useMemo, useReducer, useState, useEffect } = React;
1415function hydrateReactElements(obj: any): any {
16if (obj == null || typeof obj !== "object") {
17return obj;
3435// Reducer to handle JSON patch updates
36function brainrotReducer(state: Object, action: { type: "PATCH"; patch: any[] } | { type: "SET"; value: any }) {
37switch (action.type) {
38case "PATCH":
70};
7172function Spinner() {
73return (
74<div
113};
114115function App({ state: { share } }: { state: State }) {
116const [regex, setRegex] = useState(share?.regex ?? "");
117const [brainrotExplanation, dispatch] = useReducer(
285}
286287function client() {
288React.hydrate(
289<App state={JSON.parse(document.getElementById("_state_")!.textContent!)} />,
293if (typeof document !== "undefined") { client(); }
294295export default async function server(request: Request): Promise<Response> {
296const url = new URL(request.url);
297const route = url.pathname.match(/^\/(?:share\/([^\/]+))?$/);
DualLangWebSpeechAPImain.tsx3 matches
3import React, { useCallback, useRef, useState } from "https://esm.sh/react@18.2.0";
45function App() {
6const [isRecording, setIsRecording] = useState(false);
7const [currentLanguage, setCurrentLanguage] = useState<"korean" | "english">("english");
210}
211212function client() {
213createRoot(document.getElementById("root")).render(<App />);
214}
215if (typeof document !== "undefined") { client(); }
216217export default async function server(request: Request): Promise<Response> {
218return new Response(
219`
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">
uiComponentPlaygroundmain.tsx12 matches
45// Accordion Component
6function Accordion() {
7const [activeIndex, setActiveIndex] = useState<number | null>(null);
8
14{
15title: "Advanced Features",
16content: "Explore advanced functionalities and tips for power users."
17}
18];
4344// Dialog Component
45function Dialog() {
46const [isOpen, setIsOpen] = useState(false);
477475// Checkbox Component
76function Checkbox() {
77const [isChecked, setIsChecked] = useState(false);
789697// Switch Component
98function Switch() {
99const [isOn, setIsOn] = useState(false);
100118119// Tabs Component
120function Tabs() {
121const [activeTab, setActiveTab] = useState(0);
122
153154// Tooltip Component
155function Tooltip() {
156const [isVisible, setIsVisible] = useState(false);
157175176// Progress Bar Component
177function ProgressBar() {
178const [progress, setProgress] = useState(0);
179201202// Radio Button Group Component
203function RadioButtonGroup() {
204const [selectedOption, setSelectedOption] = useState('');
205
232233// Main App Component
234function App() {
235return (
236<div className="app-container">
275276// Client-side rendering
277function client() {
278createRoot(document.getElementById("root")).render(<App />);
279}
281282// Server-side rendering
283export default async function server(request: Request): Promise<Response> {
284return new Response(`
285<html>
checkMixcloudIsLivemain.tsx5 matches
3import React, { useState } from "https://esm.sh/react@18.2.0";
45function App() {
6const [isLive, setIsLive] = useState(false);
7const [channelName, setChannelName] = useState("");
9const [submittedChannel, setSubmittedChannel] = React.useState<string | null>(null);
1011async function checkLiveStatus(channel: string) {
12try {
13setIsLoading(true);
83}
8485function client() {
86createRoot(document.getElementById("root")).render(<App />);
87}
88if (typeof document !== "undefined") { client(); }
8990export default async function server(request: Request): Promise<Response> {
91const url = new URL(request.url);
92182}
183184async function checkMixcloudLiveStatus(
185channelName: string,
186sqlite?: any,
textToImagePlaygroundmain.tsx2 matches
59<script type="module" src="https://esm.town/v/iamseeley/realtimeFormLogic"></script>
60<script>
61document.getElementById('generationType').addEventListener('change', function() {
62const type = this.value;
63if (type === 'regular') {
81`;
8283export default async function handler(req: Request): Promise<Response> {
84const url = new URL(req.url);
85
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">
1export default async function (req: Request): Promise<Response> {
2return Response.json({ ok: true })
3}
tsEvalpatchConsoleLog2 matches
1type ConsoleMethod = (...args: any[]) => void;
23export function patch(cb: (message: string) => void) {
4const consoleHandler: ProxyHandler<Console> = {
5get(target: Console, prop: keyof Console) {
6let originalMethod = target[prop] as ConsoleMethod;
7if (typeof originalMethod !== "function") {
8return originalMethod;
9}