Skip to main content

Environment

Before mounting, the editor probes the browser to decide which renderer backend and acceleration paths to use โ€” WebGL2 vs Canvas2D, WASM text/raster, workers, and tile caching. @oh-just-another/editor exposes this as detectCapabilities.

Detecting capabilitiesโ€‹

detectCapabilities runs the auto-detection sweep and returns a CapabilityProfile. It is async because WebGPU/WebGL2 detection awaits an adapter request.

import { detectCapabilities, type CapabilityProfile } from "@oh-just-another/editor";

const profile: CapabilityProfile = await detectCapabilities();
// { renderer, wasmText, wasmRaster, workers, tiles, touch }

The profile fields:

  • renderer โ€” the chosen RendererBackend (collapsed from auto to a concrete value).
  • wasmText โ€” use the bundled WASM text shaper for wrap measurements.
  • wasmRaster โ€” use the WASM rasterizer (currently only the WebGL2 backend calls it).
  • workers โ€” spawn OffscreenCanvas workers for rendering.
  • tiles โ€” use the tile-cache compositor for very large scenes.
  • touch โ€” pointer: coarse was reported (touch primary input).

Overriding detectionโ€‹

Pass a partial CapabilityOverrides to force individual fields. Each field is auto when omitted (let the detector pick); a concrete value short-circuits detection for that field.

import { detectCapabilities, type CapabilityOverrides } from "@oh-just-another/editor";

const overrides: CapabilityOverrides = { wasmText: false, renderer: "canvas2d" };
const profile = await detectCapabilities(overrides);

The same overrides can be passed to the component as <Editor capabilities={โ€ฆ}>, where they shallow-merge over the auto-detected result. (touch is detected only โ€” it is not overridable.)

Logging the resultโ€‹

logCapabilities prints a one-line, fixed-format summary to the console so you can grep it in DevTools. The <Editor> logs this automatically on mount.

import { logCapabilities } from "@oh-just-another/editor";

logCapabilities(profile);