import { inspectGraphicsCapabilities } from '@datamoc/mw_games/two-d/render';
// reads the real browser when no probe is given
const here = inspectGraphicsCapabilities();
// a fake probe, for a test or a host integration with no DOM
const capabilities = inspectGraphicsCapabilities({
createCanvas: () => ({ getContext: (kind) => (kind === 'webgl2' ? {} : null) }),
webgpu: false,
});
console.log(capabilities.webgl2); // true
console.log(capabilities.webgpu); // false
Reports browser graphics APIs without creating a renderer or selecting a fallback. Pass a probe in tests or host integrations; omitting it reads the current browser safely.
wgslcannot be checked synchronously - the only way to genuinely know a WGSL shader compiles isdetectWebGpu, which requests a real device and compiles one, and every step of that is asynchronous. Rather than assume WGSL works just becausenavigator.gpuexists (a browser can expose WebGPU behind a still-broken or disabled implementation), this staysfalseunless a caller supplies a real result throughprobe.wgsl.