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}
brainrotdbmain.tsx5 matches
67// Ensure table exists
8async function ensureTable() {
9await sqlite.execute(`
10CREATE TABLE IF NOT EXISTS ${KEY}_regex_explanations_${SCHEMA_VERSION} (
1819// Save a new regex explanation, returns the ULID
20export async function saveRegexExplanation(regex: string, explanation: string): Promise<string> {
21await ensureTable();
223536// Get a random explanation for a specific regex
37export async function getRandomRegexExplanation(
38regex: string,
39): Promise<{ id: string; explanation: string; shares: number } | null> {
5556// Get a specific explanation by ID
57export async function getRegexExplanationById(
58id: string,
59): Promise<{ regex: string; explanation: string; shares: number } | null> {
7374// Increment share count for a specific explanation
75export async function incrementRegexExplanationShares(id: string): Promise<void> {
76await ensureTable();
77
reactRouter7server.tsx1 match
1import { handler } from "./entry.server.tsx";
23export default async function(request: Request) {
4const url = new URL(request.url);
5if (url.pathname == "/js/entry.client.js") {
reactRouter7layout.tsx1 match
8import { type loader } from "./layout.server.ts";
910export default function Layout() {
11let data = useLoaderData<typeof loader>();
12return (
reactRouter7layout.server.ts4 matches
1import {
2ActionFunctionArgs,
3type LoaderFunctionArgs,
4} from "https://esm.sh/react-router@7.1.3?deps=react@18.2.0,react-dom@18.2.0";
56let db = { message: "Hello world!" };
78export async function loader(args: LoaderFunctionArgs) {
9await new Promise(resolve => setTimeout(resolve, 200));
10return { message: db.message };
11}
1213export async function action({ request }: ActionFunctionArgs) {
14let formData = await request.formData();
15db.message = String(formData.get("message"));
reactRouter7layout.client.ts3 matches
1import { type LoaderFunctionArgs } from "https://esm.sh/react-router@7.1.3?deps=react@18.2.0,react-dom@18.2.0";
23export async function loader({ request }: LoaderFunctionArgs) {
4let url = new URL(request.url);
5let res = await fetch(url, {
12}
1314export async function action({ request }: LoaderFunctionArgs) {
15let url = new URL(request.url);
16// call the server action
reactRouter7index.ts4 matches
1import {
2ActionFunctionArgs,
3LoaderFunctionArgs,
4} from "https://esm.sh/react-router@7.1.3?deps=react@18.2.0,react-dom@18.2.0";
5import aboutLoader from "./about.loader.ts";
18// imports the correct one to avoid putting the server code in client
19// bundles
20async loader(args: LoaderFunctionArgs) {
21let mod = await (isServer
22? import("./layout.server.ts")
26// same with the action, you'll probably want to abstract this kind of stuff
27// in a createRoute() kind of thing
28async action(args: ActionFunctionArgs) {
29let mod = await (isServer
30? import("./layout.server.ts")