brew_countermain.ts1 match
21`);
2223export default async function (req: Request): Promise<Response> {
24const url = new URL(req.url);
25
untitled-8264Main2.ts12 matches
1export default async function (req: Request): Promise<Response> {
2const fftSize = 2048;
3const TWO_PI = 2.0 * 3.141592653579;
7475
76function showError(e) {
77console.error(e);
78errorBox.style.display = "block";
8182// DPR-aware resize
83function resize() {
84const dpr = Math.min(window.devicePixelRatio || 1, 2);
85const w = Math.floor(window.innerWidth * dpr);
196\`;
197198function compileShader(type, src) {
199const s = gl.createShader(type);
200gl.shaderSource(s, src);
222gl.bindVertexArray(vao);
223224function createAttrib(data, attribName, usage) {
225const loc = gl.getAttribLocation(program, attribName);
226if (loc === -1) throw new Error("Attrib not found or optimized out: " + attribName);
248249// Matrices
250function mat4Perspective(fovDeg, aspect, near, far) {
251const f = 1.0 / Math.tan((fovDeg * Math.PI) / 360);
252const nf = 1 / (near - far);
259return out;
260}
261function subtract(a, b) { return [a[0]-b[0], a[1]-b[1], a[2]-b[2]]; }
262function normalize(v) {
263const l = Math.hypot(v[0], v[1], v[2]) || 1;
264return [v[0]/l, v[1]/l, v[2]/l];
265}
266function cross(a, b) {
267return [a[1]*b[2] - a[2]*b[1], a[2]*b[0] - a[0]*b[2], a[0]*b[1] - a[1]*b[0]];
268}
269function dot(a, b) { return a[0]*b[0] + a[1]*b[1] + a[2]*b[2]; }
270function mat4LookAt(eye, target, up) {
271const z = normalize(subtract(eye, target));
272const x = normalize(cross(up, z));
314315// Render loop
316function render(ts) {
317// Update audio only if ready
318if (analyser) {
TownieValTownLogo.tsx1 match
1/** @jsxImportSource https://esm.sh/react@18.2.0 */
23export function ValTownLogo () {
4return (
5<svg
Townieval-summary.ts1 match
5* Get usage data for a specific val
6*/
7export async function getValSummary(valId: string) {
8// Get summary data for the val from the usage table
9const usageSummaryResult = await sqlite.execute(`
Townieval-detail.ts1 match
36}
3738export function renderValDetail(valId: string, summary: ValSummary, requests: UsageRequest[] = []): string {
39// Generate the content
40const content = `
TownieuseUser.tsx1 match
3const USER_ENDPOINT = "/api/user";
45export function useUser() {
6const [data, setData] = useState<any>(null);
7const [loading, setLoading] = useState(true);
TownieuseUsageStats.ts1 match
1import { useEffect } from "react";
23export function useUsageStats(messages: any[], usages: any[]) {
4useEffect(() => {
5if (!messages?.length) return;
TownieuseScrollToBottom.tsx3 matches
7*
8* @param {Array} dependencies - Array of dependencies that trigger scrolling when changed
9* @returns {Object} An object containing containerRef and scrollToBottom function
10*/
11export function useScrollToBottomContainer(dependencies = []) {
12const containerRef = useRef(null);
132829// body scroll version
30export function useScrollToBottom(dependencies = []) {
31const bottomRef = useRef(null);
32
Townieuser-summary.ts1 match
6* This includes a fallback to inference calls data when usage data is missing
7*/
8export async function getUserSummary(userId?: string) {
9// First, get the standard grouped data from the usage table
10let query = `
Townieuser-detail.ts1 match
36}
3738export function renderUserDetail(data: UserSummaryRow[], userId: string, requests: UsageRequest[] = [], creditAdditions: CreditAddition[] = []): string {
39// User data should only have one row if we're filtering by user ID
40const userData = data[0] || {