blob: f294a454c6046f3c0e1ce758cfdddd637a89445e [file]
// Generated by src/wasm/idl/generate.py from bindings.py and
// lane_layout.py. Do not edit.
//
// What each kind of lane module may import, which the page runner
// checks it against, and the numbers lanes and the page agree on.
// The console imports every lane gets.
export const kLaneConsole = [
'console.log',
'console.debug',
'console.info',
'console.warn',
'console.error',
];
// [module, name or null for all of it, kinds, refusal or null], the
// first match deciding.
const kLaneImportRules = [
['rive_rt_v1', 'now', ['job', 'worker'], null],
['rive_lanes_v1', 'wait_within', [], 'blocks on a signal, which only the main lane may; a worker awaits Signal.next or Port.receive instead'],
['rive_shared_v1', 'region_lock', ['job', 'worker'], 'locks a shared region, which the audio thread may not wait on; share through atomics, rings and snapshots instead'],
['rive_shared_v1', 'read_done', [], null],
['rive_shared_v1', null, ['job', 'worker', 'processor'], null],
['rive_lane_v1', null, ['job', 'worker', 'processor'], null],
['rive_job_v1', null, ['job'], null],
['rive_worker_v1', null, ['worker'], null],
['env', 'console.log', ['job', 'worker', 'processor'], null],
['env', 'console.debug', ['job', 'worker', 'processor'], null],
['env', 'console.info', ['job', 'worker', 'processor'], null],
['env', 'console.warn', ['job', 'worker', 'processor'], null],
['env', 'console.error', ['job', 'worker', 'processor'], null],
['env', 'console.time', ['job', 'worker'], null],
['env', 'console.timeLog', ['job', 'worker'], null],
['env', 'console.timeEnd', ['job', 'worker'], null],
];
// Why a lane module of kind ('job', 'worker' or 'processor') may not
// import module.name: null when it may, else the end of "<kind> code ...",
// empty when no rule says why.
export function laneImportRefusal(kind, module, name) {
for (const [ruleModule, ruleName, kinds, refusal] of kLaneImportRules) {
if (module === ruleModule && (ruleName === null || name === ruleName)) {
return kinds.includes(kind) ? null : refusal ?? '';
}
}
return '';
}
// [section, kind] for each lane kind, in rive_lanes_v1's order.
export const kLaneSections = [
['rive.jobs', 'job'],
['rive.workers', 'worker'],
['rive.audio', 'processor'],
];
// The prefix each kind's entries export under, before their number.
export const kLaneEntryPrefixes = {
'job': '__rive_job_',
'worker': '__rive_worker_',
'processor': '__rive_processor_',
};
// The rive_lanes_v1 states every lane moves through.
export const kLaneStates = {
'starting': 0,
'running': 1,
'done': 2,
'failed': 3,
'stopped': 4,
};
// What a processor event carries for a console line, in place of a state.
export const kProcessorEventLog = 0xffffffff;
// The most 64 KiB pages a job instance's memory may have grown to for another
// job to reuse it, as memory never shrinks.
export const kReuseMaxPages = 256;
// How long a processor's init may run in milliseconds, natively per step and in
// a worklet as a whole, far longer than a block as it may build tables.
export const kProcessorInitMs = 1000;
// Where a parallel call's control block keeps each word, in bytes from its
// start. The words its parts race on sit 128 bytes apart, each alone on a cache
// line, Apple's included. The claim takes 8 bytes, so no grain can wrap it.
export const kParallelThunk = 0;
export const kParallelArgs = 4;
export const kParallelParts = 8;
export const kParallelCount = 12;
export const kParallelAtOnce = 16;
export const kParallelCallerParks = 20;
export const kParallelGeneration = 128;
export const kParallelArrived = 256;
export const kParallelSleepers = 384;
export const kParallelClaim = 512;
export const kParallelStop = 640;
// The exports a lane module may carry besides its entries.
export const kLaneAllocExport = '__rive_lane_alloc';
export const kLaneFreeExport = '__rive_lane_free';
export const kWorkerWakeExport = '__rive_worker_wake';
export const kProcessorProcessExport = '__rive_processor_process';
export const kFrameMinorExport = '__riveFrameMinor';
export const kLiftedStartExport = '__riveLiftedStart';
export const kLaneResetExport = '__riveLaneReset';
// What lanes report the same way on every host.
export const kProcessorHolds =
'a processor cannot pass shared objects through rings or snapshots, as the audio thread may ' +
'not hold or give them back; pass them in Audio.start\'s argument';
export const kProcessorOverran = 'processor overran its block budget';
export const kProcessorInitOverran = 'processor init overran its budget';
export const kProcessorNode = 'rive-processors';
// A processor block's budget in milliseconds, first for its first block; 0 for none.
export function processorBlockBudgetMs(hardBlocks, frames, sampleRate, first) {
return hardBlocks === 0 ? 0.0 : Math.max(first ? 100.0 : 1.0, Math.ceil(hardBlocks * 1000.0 * frames / sampleRate));
}
// Why a lane module that imports module.name cannot load.
export function laneImportError(module, name) {
return 'lane module imports ' + module + '.' + name + ', which it cannot reach';
}