23// Fetches a random joke.
4async function fetchRandomJoke() {
5const response = await fetch(
6"https://official-joke-api.appspot.com/random_joke",
1export default async function(req: Request): Promise<Response> {
2return new Response(
3`
3import { createRoot } from "https://esm.sh/react-dom/client";
45function App() {
6const [prompt, setPrompt] = useState("");
7const [imageData, setImageData] = useState("");
83}
8485function client() {
86createRoot(document.getElementById("root")).render(<App />);
87}
91}
9293// Utility function to validate and adjust image dimensions
94function validateImageDimensions(width: number, height: number): {
95width: number,
96height: number,
135}
136137export default async function server(request: Request): Promise<Response> {
138const url = new URL(request.url);
139const imagePrompt = url.searchParams.get('image');
cronIntervalLoggermain.tsx1 match
23// Fetches a random joke.
4async function fetchRandomJoke() {
5const response = await fetch(
6"https://official-joke-api.appspot.com/random_joke",
valSessionREADME.md1 match
25);
2627function formatPEM(b64: string, type: "PRIVATE KEY" | "PUBLIC KEY"): string {
28const lines = b64.match(/.{1,64}/g) || [];
29return `-----BEGIN ${type}-----\n${lines.join("\n")}\n-----END ${type}-----`;
3const uuid = "1fd98a05-4959-42bc4-2f83-2c487c1cde6d";
4const build = `https://${uuid}.cloudflarepreviews.com/?url=`;
5export async function cfetch(input: string | URL, requestInit?: RequestInit) {
6return fetch(`${build}${encodeURIComponent(input.toString())}`, {
7...requestInit,
Storyweavermain.tsx7 matches
3import { createRoot } from "https://esm.sh/react-dom/client";
45function LoadingSpinner() {
6return (
7<div className="loading-spinner">
12}
1314function cleanText(text: string) {
15return text
16.replace(/\*+/g, '')
19}
2021function App() {
22const [storyParts, setStoryParts] = useState({
23title: null,
133}
134135function client() {
136createRoot(document.getElementById("root")).render(<App />);
137}
138if (typeof document !== "undefined") { client(); }
139140// Utility function to implement timeout
141async function withTimeout<T>(promise: Promise<T>, timeoutMs: number): Promise<T> {
142let timeoutHandle: number;
143const timeoutPromise = new Promise<never>((_, reject) => {
152}
153154export default async function server(request: Request): Promise<Response> {
155if (request.method === 'POST' && new URL(request.url).pathname === '/generate-story') {
156const formData = await request.formData();
blob_adminmain.tsx8 matches
13}
1415function Tooltip({ children, content }: TooltipProps) {
16const [isVisible, setIsVisible] = useState(false);
17const tooltipRef = useRef<HTMLDivElement>(null);
52}
5354function formatBytes(bytes, decimals = 2) {
55if (bytes === 0) return "0 Bytes";
56const k = 1024;
61}
6263function copyToClipboard(text) {
64navigator.clipboard.writeText(text).then(() => {
65console.log("Text copied to clipboard");
69}
7071function ActionMenu({ blob, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
72const [isOpen, setIsOpen] = useState(false);
73const menuRef = useRef(null);
7677useEffect(() => {
78function handleClickOutside(event) {
79if (menuRef.current && !menuRef.current.contains(event.target)) {
80event.stopPropagation();
158}
159160function BlobItem({ blob, onSelect, isSelected, onDownload, onRename, onDelete, onMoveToPublic, onMoveOutOfPublic }) {
161const [isLoading, setIsLoading] = useState(false);
162const decodedKey = decodeURIComponent(blob.key);
219}
220221function App({ initialEmail, initialProfile }) {
222const encodeKey = (key: string) => encodeURIComponent(key);
223const decodeKey = (key: string) => decodeURIComponent(key);
645}
646647function client() {
648const initialEmail = document.getElementById("root").getAttribute("data-email");
649const initialProfile = JSON.parse(document.getElementById("root").getAttribute("data-profile"));
MathFlashCard_RetroEditionmain.tsx5 matches
4import confetti from "https://esm.sh/canvas-confetti";
56function generateProblem(config) {
7const operations = [];
8if (config.addition) operations.push('+');
54}
5556function MathFlashcards() {
57const MAX_STREAK = 5; // Number of segments in streak bar
58const SUPER_STREAK_THRESHOLD = 5; // Threshold for special animations
383}
384385function App() {
386return React.createElement("div", { className: "app" }, React.createElement(MathFlashcards, null));
387}
388389function client() {
390createRoot(document.getElementById("root")).render(React.createElement(App, null));
391}
392if (typeof document !== "undefined") { client(); }
393394export default async function server(request: Request): Promise<Response> {
395return new Response(
396`
katakanaWordApimain.tsx1 match
1import { OpenAI } from "https://esm.town/v/std/openai";
23export default async function(request: Request): Promise<Response> {
4try {
5const openai = new OpenAI();