RuntimeOptions
Interface in Runtime
How createRuntime() makes a runtime.
import type { RuntimeOptions } from 'typeshade/runtime'
The signature, the description and the examples come from the compiler's own source at commit af54ddad5.
Syntax
interface RuntimeOptions<D extends object = object> { readonly device?: D; readonly prefer?: readonly RuntimeTier[]; readonly programs?: readonly Pack[]; readonly limits?: Readonly<Record<string, number>>; readonly console?: 'print' | ConsoleSink; readonly consoleBytes?: number; readonly emit?: (manifest: Pack, options: { readonly console?: boolean }) => Pack;}Instance properties
deviceoptionalread onlyDThe host’s
GPUDeviceorWebGL2RenderingContext, which the runtime uses and never destroys; the runtime’s tier is the one it belongs to (change 0054). Omitted: the runtime tries the tiers ofpreferin order, requesting a device with the featuresprogramsneed, or making a WebGL2 context of its own. Escape hatch (Rule 11.17): the host’s own device or context, which it keeps and calls beside the runtime.preferoptionalread onlyreadonly RuntimeTier[]The tiers
createRuntimetries when it is given no device, in order:['webgpu', 'webgl2']by default. A list of one tier makes it required. On WebGL2 the runtime runs compute entries and draws from the GLSL programs the manifest carries (change 0054).programsoptionalread onlyreadonly Pack[]The programs the requested device must be able to run.
limitsoptionalread onlyReadonly<Record<string, number>>WebGPU limits the device must have, by their names in
GPUSupportedLimits(change 0051):{ maxStorageBufferBindingSize: 1 << 30 }. Withoutdevice, the runtime requests each, with the limitsprogramsneed, and the larger of the two where both name one. A binding size named here raisesmaxBufferSizewith it, up to the adapter’s. Withdevice, the runtime checks the device against each. A WebGL2devicehas no WebGPU limits, so it refuses this option. Omitted: none.consoleoptionalread only'print' | ConsoleSinkWhere the events of an entry’s
console.*calls go: printed to the host’s console, with a warning for the calls that did not fit the buffer ('print', the default), or handed to a sink, which takes the lines and the count and prints nothing. The count of each buffer’s lines and dropped calls is whatsubmit()resolves to, either way.consoleBytesoptionalread onlynumberThe console buffer’s size for each dispatch and draw that records, in bytes. 1 MiB. A call the buffer has no room for is dropped whole, and counted in the
droppedofsubmit()’s row for that dispatch or draw.emitoptionalread only(manifest: Pack, options: { readonly console?: boolean }) => PackThe load-time emitter,
repackfromtypeshade/emit, which emits a manifest again from the portable IR it carries when a load asks for a variant the build did not write (load(m, { console: true })), under the options the manifest was packed under (packModule(m, { emit })). The runtime never imports it itself, so a host that does not pass it ships no emitter. Normal builds need none for console variants.
Source
src/runtime/runtime.ts, line 45, at commit af54ddad5