UNPKG

@cornerstonejs/core

Version:
26 lines (25 loc) 895 B
export class DefaultRenderPathResolver { constructor(paths = []) { this.paths = []; paths.forEach((path) => this.add(path)); } register(path) { this.add(path); } add(path) { const existingPath = this.paths.find((candidate) => candidate.id === path.id); if (existingPath) { console.debug(`[DefaultRenderPathResolver] Duplicate render path registration ignored for "${path.id}"`); return; } this.paths.push(path); } resolve(type, data, options) { const path = this.paths.find((candidate) => candidate.type === type && candidate.matches(data, options)); if (!path) { throw new Error(`No render path for ${type}/${data.type}/${options.renderMode}`); } return path; } } export const defaultRenderPathResolver = new DefaultRenderPathResolver();