import type { ChucK, RunResult, ChuginEntry, AudioConfig, ShredInfo, ReplaceResult, GlobalVariableInfo } from './types/chuck.js'; /** * Configuration object passed to {@link ChuGL.init}. */ interface ChuGLConfig { /** **Required.** Canvas element for WebGPU rendering. */ canvas: HTMLCanvasElement; /** * Base URL where WebChuGL runtime assets are hosted (`index.js`, * `webchugl.wasm`, `audio-worklet-processor.js`, `jszip.min.js`). * Must end with `/`. Defaults to the jsdelivr CDN. */ whereIsChuGL?: string; /** * Array of ChuGins to load before the VM starts. Each entry is either * a URL string (fetched automatically) or a `{ name, buf }` object * with a pre-fetched ArrayBuffer. Loaded in parallel with WebGPU init. */ chugins?: ChuginEntry[]; /** * Register a service worker that injects COOP/COEP headers for * cross-origin isolation. Set to `false` if your server already * sends these headers. Defaults to `true`. */ serviceWorker?: boolean; /** Audio configuration. */ audioConfig?: AudioConfig; /** Progress callback, receives 0-100. */ onProgress?: (pct: number) => void; /** Error callback, receives a message string. */ onError?: (msg: string) => void; /** Called when WebGPU init completes and the canvas is ready for rendering. */ onReady?: () => void; } /** * The ChuGL entry point. Call {@link ChuGL.init} to create a * {@link ChucK} instance. * * @example * import ChuGL from 'https://cdn.jsdelivr.net/npm/webchugl/+esm'; * * var ck = await ChuGL.init({ * canvas: document.getElementById('canvas'), * }); */ declare const ChuGL: { /** * Initialize WebChuGL and return a {@link ChucK} instance. * Multiple instances are supported — each call creates an independent * ChucK VM with its own canvas, audio, and graphics state. * * @param config - Configuration options. * @returns Resolves to a {@link ChucK} instance. * * @example * var ck = await ChuGL.init({ * canvas: document.getElementById('canvas'), * chugins: ['./chugins/Bitcrusher.chug.wasm'], * audioConfig: { sampleRate: 44100 }, * }); */ init: (config: ChuGLConfig) => Promise; }; export default ChuGL; export { ChuGL }; export type { ChucK, RunResult, ChuGLConfig, ChuginEntry, AudioConfig, ShredInfo, ReplaceResult, GlobalVariableInfo, };