untitled-8264Main2.ts12 matches
1export default async function (req: Request): Promise<Response> {
2const html = `<!DOCTYPE html>
3<html lang="en">
54const errorBox = document.getElementById("errorBox");
5556function showError(e) {
57console.error(e);
58errorBox.style.display = "block";
6162// DPR-aware resize
63function resize() {
64const dpr = Math.min(window.devicePixelRatio || 1, 2);
65const w = Math.floor(window.innerWidth * dpr);
173\`;
174175function compileShader(type, src) {
176const s = gl.createShader(type);
177gl.shaderSource(s, src);
199gl.bindVertexArray(vao);
200201function createAttrib(data, attribName, usage) {
202const loc = gl.getAttribLocation(program, attribName);
203if (loc === -1) throw new Error("Attrib not found or optimized out: " + attribName);
225226// Matrices
227function mat4Perspective(fovDeg, aspect, near, far) {
228const f = 1.0 / Math.tan((fovDeg * Math.PI) / 360);
229const nf = 1 / (near - far);
236return out;
237}
238function subtract(a, b) { return [a[0]-b[0], a[1]-b[1], a[2]-b[2]]; }
239function normalize(v) {
240const l = Math.hypot(v[0], v[1], v[2]) || 1;
241return [v[0]/l, v[1]/l, v[2]/l];
242}
243function cross(a, b) {
244return [a[1]*b[2] - a[2]*b[1], a[2]*b[0] - a[0]*b[2], a[0]*b[1] - a[1]*b[0]];
245}
246function dot(a, b) { return a[0]*b[0] + a[1]*b[1] + a[2]*b[2]; }
247function mat4LookAt(eye, target, up) {
248const z = normalize(subtract(eye, target));
249const x = normalize(cross(up, z));
284285// Render loop
286function render(ts) {
287// Update audio only if ready
288if (analyser) {
2import * as THREE from "three";
34// Import Bluesky OAuth functionality
5import { LoginComponent } from "./login-component.ts";
6import { blueskyAuth, type BlueskySession, type SavedGame } from "./bluesky-oauth.ts";
1535}
15361537// Save game functionality
1538private async saveGame() {
1539if (!this.blueskySession) {
chatterchatterApp.js6 matches
90} from './contentRenderers.js';
9192export default function chatterApp() {
93return {
94// Page routing
626const combo = parts.join('+');
627const handler = this.keyBindings && this.keyBindings[combo];
628if (typeof handler === 'function') {
629e.preventDefault();
630handler(this);
637try {
638const handler = this.keyBindings && this.keyBindings[combo];
639if (typeof handler === 'function') handler(this);
640else if (combo === 'mod+shift+b') this.toggleChatSettings();
641} catch (_) { /* ignore */ }
691try {
692const el = document.querySelector('textarea');
693if (el && typeof el.focus === 'function') {
694el.focus();
695// Put caret at end
1530const doScroll = () => {
1531try {
1532if (scrollerEl && typeof scrollerEl.scrollTo === 'function') {
1533scrollerEl.scrollTop = scrollerEl.scrollHeight;
1534} else if (scrollerEl) {
1540} catch (_) {}
1541};
1542if (typeof this.$nextTick === 'function') this.$nextTick(doScroll); else requestAnimationFrame(doScroll);
1543} catch (_) {}
1544},
7} from './core/chatCore.js';
89export async function onExportData(ctx) {
10try {
11ctx.dataStatusText = 'preparing export...';
31}
3233export async function copyCurrentChatJson(ctx) {
34try {
35if (!ctx.db) return;
59}
6061export function onClickImportReplace(ctx) {
62try {
63ctx.pendingImportMode = 'replace';
67}
6869export function onClickImportAppend(ctx) {
70try {
71ctx.pendingImportMode = 'append';
75}
7677export async function onImportFileChange(ctx, e) {
78try {
79const files = e && e.target && e.target.files ? e.target.files : null;
chatterchatCore.js32 matches
1// Core chat + DB helpers extracted from chatterApp
23export async function initDb(state) {
4try {
5state.db = new window.Dexie('chat_db');
58}
5960export async function loadChats(state) {
61try {
62const rows = await state.db.chats.orderBy('createdAt').reverse().toArray();
65}
6667export async function loadFolders(state) {
68try {
69const rows = await state.db.folders.orderBy('order').toArray();
72}
7374export async function createFolder(state) {
75try {
76const createdAt = Date.now();
84}
8586export function startEditingFolder(state, id, currentName) {
87state.editingFolderId = id;
88state.editingFolderName = currentName || '';
95}
9697export async function commitEditingFolder(state) {
98const rawId = state.editingFolderId;
99const id = typeof rawId === 'string' ? Number(rawId) : rawId;
109}
110111export function cancelEditingFolder(state) {
112state.editingFolderId = null;
113state.editingFolderName = '';
114}
115116export async function toggleFolderCollapsed(state, id) {
117try {
118const f = await state.db.folders.get(id);
123}
124125export async function moveChatToFolder(state, chatId, folderId) {
126try {
127if (!chatId) return;
134}
135136export function baseChats(state) {
137try {
138const list = (state.chats || []).filter(c => !c.folderId);
141}
142143export function chatsInFolder(state, folderId) {
144try { return (state.chats || []).filter(c => c.folderId === folderId); } catch (_) { return []; }
145}
146147export async function createNewChat(state) {
148const input = (state.chatInput || '').trim();
149// If no content, do NOT create a persisted chat. Switch to ephemeral new chat.
175}
176177export async function selectChat(state, id) {
178if (id === state.ephemeralChatId) {
179state.currentChatId = null;
414state.sidebarOpen = false;
415state.$nextTick && state.$nextTick(() => state.scrollToBottom && state.scrollToBottom());
416try { typeof state.updateDocumentTitle === 'function' && state.updateDocumentTitle(); } catch (_) { /* ignore */ }
417}
418419export function startEditingChat(state, id, currentTitle) {
420state.editingChatId = id;
421state.editingChatTitle = currentTitle || '';
428}
429430export async function commitEditingChat(state) {
431const rawId = state.editingChatId;
432const id = typeof rawId === 'string' ? Number(rawId) : rawId;
445state.editingChatId = null;
446state.editingChatTitle = '';
447try { typeof state.updateDocumentTitle === 'function' && state.updateDocumentTitle(); } catch (_) { /* ignore */ }
448}
449450export function cancelEditingChat(state) {
451state.editingChatId = null;
452state.editingChatTitle = '';
453}
454455export async function deleteChat(state, id) {
456try {
457if (!state.db) return;
473}
474475export async function duplicateChat(state, id) {
476try {
477if (!state || !state.db) return;
498}
499500export async function ensureChatExistsForEdits(state, opts = {}) {
501try {
502const force = !!opts.force;
515state.currentChatId = id;
516state.activeSearchId = id;
517try { typeof state.updateDocumentTitle === 'function' && state.updateDocumentTitle(); } catch (_) { /* ignore */ }
518// Initialize per-chat prompt defaults
519try { await state.db.chats.update(id, { systemPromptId: null, systemPromptText: '' }); } catch (_) { /* ignore */ }
522}
523524export async function ensureMessagePersisted(state, idx) {
525try {
526const m = state.messages?.[idx];
555}
556557export async function persistMessageAtIndex(state, idx) {
558try {
559const m = state.messages?.[idx];
575}
576577export async function deleteMessage(state, idx) {
578try {
579if (!Array.isArray(state.messages) || idx == null || idx < 0 || idx >= state.messages.length) return;
606}
607608export async function deleteMessagesBelow(state, idx) {
609try {
610if (!Array.isArray(state.messages) || idx == null || idx < 0 || idx >= state.messages.length) return;
652}
653654export async function rerunFromUser(state, idx) {
655try {
656if (state.isStreamingForCurrent) return;
686}
687688export async function sendMessage(state) {
689const text = (state.chatInput || '').trim();
690if (!text) return;
720}
721722function slugifyTitle(title) {
723try {
724const s = String(title || '').toLowerCase();
732// --- Data export/import helpers ---
733734export async function exportAllData(state) {
735try {
736if (!state || !state.db) {
757}
758759export async function importDataReplace(state, input) {
760const parsed = (() => {
761try {
810}
811812export async function importDataAppend(state, input) {
813const parsed = (() => {
814try {
chatterindex.html2 matches
17<meta property="twitter:image" content="https://imagedelivery.net/TysXuIP7qbyd6gh5m_zQIQ/1764955c-dd1f-4745-2aed-3b59717e3d00/medium">
18<script>
19window.deferLoadingAlpine = function (start) { window._startAlpine = start; };
20</script>
21<!-- Offline-first vendor (populated by deno task vendor:fetch) -->
33<script>
34// Minimal theme bootstrap: uses localStorage 'theme' = 'light' | 'dark' | 'auto'
35(function() {
36try {
37var pref = localStorage.getItem('theme') || 'auto';
qbatbluesky-oauth.ts1 match
1// Bluesky OAuth functionality for QBAT game
2import {
3BrowserOAuthClient,
boombox-generatorscad.ts1 match
1import { boomboxData } from "./boombox.js";
23export function generateScadCode(code: string | undefined) {
4const bb = boomboxData();
5if (code) {
boombox-generatorboombox.js5 matches
1import LZString from "https://esm.sh/lz-string";
23export function boomboxData() {
4const data = {
5showDragHandles: false,
369}
370371function svgPolygonPath([firstPoint, ...restPoints]) {
372return [
373`M${firstPoint[0]},${firstPoint[1]}`,
377}
378379function clamp(min, val, max) {
380return Math.min(Math.max(val, min), max);
381}
382383function random(min, max, n = 1) {
384const arr = new Array(n).fill(0).map(() => Math.random());
385return min + average(arr) * (max - min);
386}
387388function average(arr) {
389return arr.reduce((a, b) => a + b, 0) / arr.length;
390}
weatherAppmain.tsx4 matches
10];
1112function App() {
13const [city, setCity] = useState(cities[0]);
14const [weather, setWeather] = useState(null);
1516useEffect(() => {
17async function fetchWeather() {
18const url = `https://api.open-meteo.com/v1/forecast?latitude=${city.lat}&longitude=${city.lon}¤t_weather=true`;
19const res = await fetch(url);
49}
5051function client() {
52createRoot(document.getElementById("root")).render(<App />);
53}
54if (typeof document !== "undefined") client();
5556export default async function server(request: Request): Promise<Response> {
57return new Response(`<!DOCTYPE html>
58<html>