1export default async function(req: Request): Promise<Response> {
2const html = `<!DOCTYPE html>
3<html lang="en">
237<script>
238// Cookie utilities
239function setCookie(name, value, days = 30) {
240const expires = new Date();
241expires.setTime(expires.getTime() + (days * 24 * 60 * 60 * 1000));
243}
244245function getCookie(name) {
246const nameEQ = name + "=";
247const ca = document.cookie.split(';');
254}
255256// Enhanced error display function
257function displayError(error, context = {}) {
258const responseDiv = document.getElementById('responseContent');
259
330331// Load saved values
332function loadSavedValues() {
333// Load API key from cookie
334const savedApiKey = getCookie('nvidia_api_key');
361362// Save current form values
363function saveCurrentValues() {
364const form = document.getElementById('apiForm');
365const formData = new FormData(form);
397}
398399// Enhanced API request function
400async function makeApiRequest(requestData, apiKey) {
401const requestHeaders = {
402'Authorization': \`Bearer \${apiKey}\`,
455456// Handle streaming response with better error handling
457async function handleStreamingResponse(response) {
458const reader = response.body.getReader();
459const decoder = new TextDecoder();
493494// Handle non-streaming response with detailed info
495async function handleNonStreamingResponse(response) {
496const responseDiv = document.getElementById('responseContent');
497
boombox-generatorog.tsx1 match
3import { ImageResponse } from "npm:@vercel/og";
45export function generateOgImageResponse(code: string | undefined) {
6try {
7const bb = boomboxData();
test-render-haproxymain.ts1 match
1// Learn more: https://docs.val.town/vals/http/
2export default async function (req: Request): Promise<Response> {
3return Response.json({ ok: true })
4}
untitled-8620main.ts6 matches
59const openai = new OpenAI();
6061async function callAI(fact: string, prompt: string): Promise<Prerequisite[]> {
62try {
63const completion = await openai.chat.completions.create({
83* Tracks processed nodes to avoid redundant API calls and circular dependencies.
84*/
85async function buildTreeInBackground(jobId: string, rootNode: FactNode) {
86try {
87// This Map will store all nodes ever created, keyed by their fact string.
160// --- FRONTEND & ROUTER (No changes needed below this line) ---
161162function generateHtml(sourceUrl: string): string {
163return `<!DOCTYPE html>
164<html lang="en">
347const POLLING_INTERVAL = 2000;
348349function TreeNode({ node, seenIds = new Set() }) {
350const [isCollapsed, setIsCollapsed] = useState(false);
351
395}
396397function App() {
398const [view, setView] = useState('input'); // 'input', 'processing', 'tree'
399const [jobId, setJobId] = useState(null);
534}
535536export default async function (req: Request): Promise<Response> {
537const url = new URL(req.url);
538const path = url.pathname;
untitled-8264main.ts12 matches
1export default async function (req: Request): Promise<Response> {
2const html = `<!DOCTYPE html>
3<html lang="en">
48const startBtn = document.getElementById("startBtn");
49const errorBox = document.getElementById("errorBox");
50function showError(e) {
51console.error(e);
52errorBox.style.display = "block";
55const gl = canvas.getContext("webgl2", { antialias: true, alpha: false });
56if (!gl) { showError("WebGL2 not supported."); overlay.classList.add("hidden"); return; }
57function resize() {
58const dpr = Math.min(window.devicePixelRatio || 1, 2);
59const w = Math.floor(window.innerWidth * dpr);
154fragColor = vec4(col * sprite, alpha);
155}\`;
156function compileShader(type, src) {
157const s = gl.createShader(type);
158gl.shaderSource(s, src);
184185// Helper to create attribute buffers
186function createAttrib(data, name, usage) {
187const loc = gl.getAttribLocation(program, name);
188if (loc === -1) throw new Error("Attrib not found: " + name);
212213// Matrix helpers
214function mat4Perspective(fovDeg, aspect, near, far) {
215const f = 1.0 / Math.tan((fovDeg * Math.PI) / 360);
216const nf = 1 / (near - far);
223return out;
224}
225function subtract(a, b) { return [a[0]-b[0], a[1]-b[1], a[2]-b[2]]; }
226function normalize(v) { const l = Math.hypot(v[0], v[1], v[2]) || 1; return [v[0]/l, v[1]/l, v[2]/l]; }
227function cross(a, b) { return [a[1]*b[2]-a[2]*b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0]]; }
228function dot(a, b) { return a[0]*b[0] + a[1]*b[1] + a[2]*b[2]; }
229function mat4LookAt(eye, target, up) {
230const z = normalize(subtract(eye, target));
231const x = normalize(cross(up, z));
245const alphaRelease = 0.12;
246247function render(ts) {
248if (analyser) {
249analyser.getByteFrequencyData(fftBuffer);
20- **Apple Collection**: Red apples scattered around the maze provide bonus moves
21- **Win/Lose Conditions**: Clear victory and failure states
22- **Restart Functionality**: Easy game restart with a single button click
23- **Board Sharing**: Copy/paste board states using emoji-based text representation
24- **Custom Levels**: Load custom board configurations by pasting text
53โโโ index.tsx # Game implementation
54โโโ style.css # Styling including login component styles
55โโโ bluesky-oauth.ts # Bluesky OAuth functionality
56โโโ login-component.ts # Login UI component
57โโโ favicon.svg # Game icon
60โโโ shared/ # Shared utilities and types
61โ โโโ types.ts # TypeScript interfaces for Notion data
62โ โโโ utils.ts # Shared utility functions
63โ โโโ README.md
64โโโ main.tsx # Application entry point with static file serving
73- Extracts parameters from requests
74- Applies authentication middleware
75- Calls controller functions and formats responses
76- Manages HTTP status codes and error responses
778990### Response Format
91All controller functions return a consistent structure:
92```typescript
93{
137138#### **User Experience**
139- **Error Handling**: Graceful error states with retry functionality
140- **Loading States**: Smooth loading indicators
141- **Navigation**: Easy return to dashboard
208- Filter out button properties from Notion page data
209- Return standardized JSON responses (except authentication routes which redirect or show HTML)
210- Use the same controller functions as the API endpoints for consistency
211212### New User Registration Flow
432## Environment Variables
433434Configure these environment variables for full functionality:
435- `GLANCE_DEMOS_DB_ID` - Notion database ID for demos
436- `GLANCE_CONTENT_DB_ID` - Notion database ID for content
14* Update viewing status for a page in blob storage
15*/
16export async function updateViewingStatus(
17pageId: string,
18viewing: boolean,
111* Sync viewing data to Notion page properties
112*/
113async function syncViewingToNotion(pageId: string, viewingData: any, oldViewingState?: boolean) {
114// Derive viewing state from sessionStart
115const currentlyViewing = viewingData.sessionStart !== null;
156* Get current viewing status for a page
157*/
158export async function getViewingStatus(pageId: string): Promise<ViewingResponse> {
159try {
160// Validate page ID using existing helper
227* Clean up stale viewing sessions (called by cron)
228*/
229export async function cleanupStaleViewingSessions(): Promise<ViewingResponse> {
230try {
231const blobsResult = await listBlobKeys(generateBlobKeyPrefix("viewing"));
337* Get viewing statistics for a page (simplified - mostly transforms getViewingStatus)
338*/
339export async function getViewingStats(pageId: string): Promise<ViewingResponse> {
340try {
341// Validate page ID using existing helper
1/**
2* Viewing-specific utility functions
3*/
416* Migrate old blob structure to new unified sessionStart format
17*/
18export function migrateOldBlobStructure(data: any): any {
19if (!data || typeof data !== 'object') {
20return data;
32* Derive viewing state from sessionStart property
33*/
34export function deriveViewingState(data: any): boolean {
35if (!data || typeof data !== 'object') {
36return false;
42* Check if blob data is stale based on lastUpdate timestamp
43*/
44export function isDataStale(data: any, thresholdMinutes: number): boolean {
45if (!data?.lastUpdate) {
46return true; // No lastUpdate means stale
itsOnRendermain.tsx3 matches
1// export default async function(req: Request): Promise<Response> {
2// return Response.json({ ok: true, headers: [...req.headers.entries()] });
3// }
5const msg = new TextEncoder().encode("๐ฉ");
6const initialDelay = 20;
7export default async function (req: Request): Promise<Response> {
8let timerId: number | undefined;
9const body = new ReadableStream({
10start(controller) {
11let currentDelay = initialDelay;
12function writeToStream() {
13currentDelay *= 1.03;
14controller.enqueue(msg);