export interface UploadHandle {
promise: Promise<{ status: number; body: string }>;
xhr: XMLHttpRequest;
}
export function uploadFile(
export type EventMap = Record<string, unknown[]>;
type Listener<Args extends unknown[]> = (...args: Args) => void;
export class TypedEmitter<Events extends EventMap> {
private listeners = new Map<keyof Events, Set<Listener<any>>>();
import { useCallback, useEffect, useRef, useState } from 'react';
export type CopyStatus = 'idle' | 'copied' | 'error';
function fallbackCopy(text: string): boolean {
const textarea = document.createElement('textarea');
import { Response } from 'express';
type Client = { id: number; res: Response };
const clients = new Map<string, Set<Client>>();
let nextId = 1;
import React, { useMemo } from 'react';
import { VirtualList } from './VirtualList';
interface LogEntry {
id: number;
level: 'info' | 'warn' | 'error';
import { useCallback, useEffect, useState } from 'react';
function parseSearch(search) {
const params = new URLSearchParams(search);
const out = {};
for (const [key, value] of params.entries()) out[key] = value;
import { useCallback, useEffect, useRef, useState } from 'react';
export function usePaginatedFetch(fetchPage, { pageSize = 20 } = {}) {
const [items, setItems] = useState([]);
const [loading, setLoading] = useState(false);
const [error, setError] = useState(null);
import { useMemo } from "react";
export type SortDir = "asc" | "desc";
export interface SortConfig<T> {
key: keyof T;
dir: SortDir;
import { useEffect, useState } from "react";
export function useDebouncedValue(value, delay = 300) {
const [debounced, setDebounced] = useState(value);
useEffect(() => {
export const initialCart = { items: {} };
export function cartReducer(state, action) {
switch (action.type) {
case 'ADD_ITEM': {
const { product, qty = 1 } = action;
import { createContext, useContext, useEffect, useMemo, useState } from 'react';
import { fetchCurrentUser, postLogin, postLogout } from './api';
const AuthContext = createContext(null);
export function AuthProvider({ children }) {
const BASE_URL = "/api/search";
export async function searchProducts(query, { signal } = {}) {
const params = new URLSearchParams({ q: query, limit: "10" });
const res = await fetch(`${BASE_URL}?${params}`, {
signal,