create-safehash-serversql.ts7 matches
2122// // One SQL query
23// export async function execute(sql: string, args: SqlParam[] = []): Promise<ResultSet> {
24// return await sqlite.execute(sql, args);
25// }
2627// // Batch of queries
28// export async function batch(
29// statements: { sql: string; args: SqlParam[] }[],
30// mode: "write" | "read" | "deferred" = "write",
3435// // Insert
36// export async function insert(table: string, data: Record<string, SqlParam>): Promise<ResultSet> {
37// const columns = Object.keys(data);
38// const placeholders = columns.map(() => "?").join(", ");
4344// // Update
45// export async function update(
46// table: string,
47// data: Record<string, SqlParam>,
5758// // Delete
59// export async function remove(
60// table: string,
61// where: string,
6768// // Select
69// export async function select(
70// table: string,
71// columns: string[] = ["*"],
79// }
8081// function sanitizeIdent(ident: string): string {
82// if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(ident)) {
83// throw new Error(`Invalid SQL identifier: ${ident}`);
62// --- FRONTEND GENERATION ---
6364// FIX: The function signature is updated to accept an optional errorMessage.
65function generateHtml(sourceUrl: string, errorMessage?: string) {
66return `<!DOCTYPE html>
67<html lang="en">
296297<script>
298(async function() {
299// If an error message is present, the app is in a failure state. Do not run the script.
300if (${!!errorMessage}) return;
428};
429430async function initialize() {
431showLoading(true);
432try {
untitled-6822main.tsx1 match
1export default async function (req: Request): Promise<Response> {
2return Response.json({ ok: true })
3}
5556// --- HTML & FRONTEND ---
57function generateHtml(sourceUrl: string) {
58return `<!DOCTYPE html>
59<html lang="en">
323const idleAnimations = ["E:blink", "B:1.05,0.95@400 R:all@600", "E:0.9@500 R:all@500"];
324325function resizeCanvas() { canvas.width = window.innerWidth; canvas.height = window.innerHeight; }
326resizeCanvas();
327window.addEventListener('resize', resizeCanvas);
328329function particleLoop() {
330ctx.clearRect(0, 0, canvas.width, canvas.height);
331particles.forEach((p, index) => {
351}
352353function emitParticles(type, amount) {
354const monsterRect = monster.getBoundingClientRect();
355const startX = monsterRect.left + monsterRect.width / 2;
364});
365366function updateParallax() {
367const faceOffsetX = mouse.x * -15, faceOffsetY = mouse.y * -15;
368monsterFace.style.transform = \`translate3d(\${faceOffsetX}px, \${faceOffsetY}px, 50px)\`;
378}
379
380function resetIdleTimer() {
381clearTimeout(idleTimer);
382if (!isAnimating) idleTimer = setTimeout(() => parseAndEnqueue(idleAnimations[Math.floor(Math.random() * idleAnimations.length)]), 7000);
383}
384385function parseAndEnqueue(script) {
386resetIdleTimer();
387animationQueue.push(...script.trim().split(/\\s+/));
389}
390391async function processQueue() {
392if (animationQueue.length === 0) { isAnimating = false; resetIdleTimer(); return; }
393isAnimating = true;
415}
416417function setMouthShape(shape) {
418monsterMouth.className = 'monster__mouth ' + shape;
419let yOffset = '0px';
424}
425426function setEyeState(value) {
427root.style.setProperty('--eye-scale', value === 'blink' ? 0.1 : parseFloat(value));
428if (value === 'blink') setTimeout(() => root.style.setProperty('--eye-scale', 1), 150);
429}
430
431function setBodyState(value, duration) {
432const [scaleY, scaleX] = value.split(',').map(parseFloat);
433monster.style.transitionDuration = \`\${duration / 1000}s\`;
437}
438
439function setColorScheme(name, duration) {
440const scheme = colorSchemes[name]; if (!scheme) return;
441root.style.transition = \`--monster-color-hsl \${duration / 1000}s ease, --bg-color-hsl \${duration / 1000}s ease\`;
444}
445446function setTextureState(name) {
447if (!name) return;
448const url = \`https://www.transparenttextures.com/patterns/\${name}.png\`;
451}
452
453function setFx(value, duration) {
454const [type, strength] = value.split(',');
455const s = parseFloat(strength);
470}
471
472function setDiscoMode(state) {
473if (state === 'on') {
474discoBall.classList.add('active');
485}
486487function resetState(duration) { setBodyState("1,1", duration); root.style.setProperty('--eye-scale', 1); }
488489function playSound(value, duration) {
490if (!audioContext || !value) return;
491const [type, freqStr] = value.split(',');
533});
534535function setTypingIndicator(isTyping, text = "...") {
536chatBubble.classList.remove('visible');
537// A short delay to allow the fade out transition to complete before changing text or starting fade-in
549}
550551function initialGreeting() {
552setTypingIndicator(false, "Hi friend! Me Blorp. I have learned a few new tricks.");
553parseAndEnqueue("W:500 B:0.9,1.1@300 E:1.2@200 R:all@500 M:smile@2000");
566// --- VAL TOWN SERVER-SIDE LOGIC ---
567568export default async function(req: Request) {
569const url = new URL(req.url);
570
claude-apimain.tsx1 match
1export default async function(req: Request): Promise<Response> {
2try {
3// Create a new URL object from the incoming request URL
adventofcode2015solutions.ts6 matches
1export function day1(input: string) {
2let currentFloor = 0;
3let currentChar = 0;
21}
2223export function day2(input: string) {
24let sqFtPaper = 0;
25let ftRibbon = 0;
60}
6162export function day3(input: string) {
63// Part uno
64const visitedLocs = new Set(["0,0"]);
6667// Check where santa be shmooving and store new location if its a new casa
68function updateAndCheckLoc(coordinateToUpdate: number, incrementOrDecrement: number) {
69const currentCoordinates = currentLoc.split(",");
70const newCoordinate = Number(currentCoordinates[coordinateToUpdate]) + incrementOrDecrement;
107108// Check where santa be shmooving and store new location if its a new casa with added logic for mr roboto santa
109function updateAndCheckLocDups(coordinateToUpdate: number, incrementOrDecrement: number, whichSanta: number) {
110const currentCoordinates = currentLocNthSanta[whichSanta].split(",");
111const newCoordinate = Number(currentCoordinates[coordinateToUpdate]) + incrementOrDecrement;
144}
145146async function getAnswer() {
147// Import the readFile utility from Val Town's standard library
148const { readFile } = await import("https://esm.town/v/std/utils/index.ts");
6263// --- HTML & FRONTEND ---
64function generateHtml(sourceUrl: string) {
65return `<!DOCTYPE html>
66<html lang="en">
208209<script>
210(function() {
211const API_URL = '${sourceUrl}';
212const speakBtn = document.getElementById('speakBtn');
225let animationStartTime;
226227function setViseme(visemeClass) {
228mouth.className = 'monster__mouth ' + visemeClass;
229}
230231function applyHeadTilt(degrees) {
232monster.style.transform = \`rotate(\${degrees}deg)\`;
233}
234
235function applyHeadNod(distance) {
236monsterFace.style.transform = \`translateY(\${distance}px) translateX(-50%)\`;
237}
238239function applyEyeDart(x, y) {
240eyesContainer.style.transform = \`translate(\${x}px, \${y}px)\`;
241}
242243function applyBlink(start) {
244if (start) {
245allEyes.forEach(eye => eye.style.height = '2px');
249}
250251function applyEyebrows(position) {
252let lTransform = '', rTransform = '';
253switch(position) {
274}
275276function stopAnimation() {
277if (animationFrameId) {
278cancelAnimationFrame(animationFrameId);
286}
287288function animationLoop(plan) {
289const elapsed = performance.now() - animationStartTime;
290332}
333334async function getAndPlayAnimation() {
335const text = speechText.value.trim();
336if (!text) return;
python_clockindex.ts1 match
1export default async function(req: Request) {
2const now = new Date();
3const timeString = now.toLocaleTimeString("en-US", {
MiniAppStarterui.tsx8 matches
3import { useEffect, useState } from "https://esm.sh/react@19";
45export function Section({ children, ...props }: any) {
6const sectionClass = `p-5 rounded-3xl bg-neutral-400/15 ${props.className || ""}`;
7return <div class={sectionClass}>{children}</div>;
93};
9495// export function Input(props: any) {
96// const inputClass = "dark:bg-white dark:text-black bg-black text-white rounded-md px-3 py-1 ";
97// return <input class={inputClass} {...props} />;
98// }
99100// export function Button(props: any) {
101// const buttonClass = "dark:bg-white dark:text-black bg-black text-white rounded-md px-3 py-1 ";
102// return <button class={buttonClass} {...props} />;
103// }
104105export function MonoButton(props: any) {
106return (
107<Button {...props}>
111}
112113export function MonoButtonWithStatus(props: any) {
114const [status, setStatus] = useState<any>();
115const handleClick = async () => {
132}
133134export function formatJSON(json: any) {
135return JSON.stringify(json, null, 2);
136}
146};
147148export function BackButton({}) {
149return <ArrowLeft className="w-5 h-5 m-2 cursor-pointer opacity-50" onClick={() => window.location.href = "/"} />;
150}
151152export function ShareButton({ onClick }) {
153return <Share className="w-5 h-5 m-2 cursor-pointer opacity-50" onClick={onClick} />;
154}
MiniAppStartersupabase.ts1 match
6)
78export async function sendAnalyticsEvent(payload: {
9event: string
10param?: string