Plugin Selection Toys May 2026
interface ToyPlugin "visual" interface ToyContext // shared state across plugins audioBuffer?: AudioBuffer; canvas?: HTMLCanvasElement; physicsWorld?: Matter.World; userParams: Record<string, any>;
const echoPlugin = id: "echo-delay", name: "Echo Tunnel", category: "audio", exclusiveGroup: "delay", apply: (ctx) => , ui: knob: ["delayTime (0–1)"] ; Part 3: Selection Manager Logic The core engine that enables/disables plugins and resolves conflicts. 3.1. Basic Manager class PluginSelectionManager constructor() this.activePlugins = new Map(); // id -> plugin instance this.groups = new Map(); // exclusiveGroup -> active id enable(plugin) // 1. check exclusive group if (plugin.exclusiveGroup) const existing = this.groups.get(plugin.exclusiveGroup); if (existing) this.disable(existing); this.groups.set(plugin.exclusiveGroup, plugin.id); plugin selection toys
disable(pluginId) /* remove from maps */ check exclusive group if (plugin
// 2. apply to context in order (order matters!) this.activePlugins.set(plugin.id, plugin); this.reorder(); // sort by category/priority if (existing) this.disable(existing)
getPipeline() return Array.from(this.activePlugins.values());
reorder() // sort: visual → physics → audio (example) this.activePlugins = new Map([...this.activePlugins.entries()] .sort((a,b) => orderMap[a[1].category] - orderMap[b[1].category]));
