reorder() // sort: visual → physics → audio (example) this.activePlugins = new Map([...this.activePlugins.entries()] .sort((a,b) => orderMap[a[1].category] - orderMap[b[1].category]));
interface ToyPlugin "visual" interface ToyContext // shared state across plugins audioBuffer?: AudioBuffer; canvas?: HTMLCanvasElement; physicsWorld?: Matter.World; userParams: Record<string, any>;
// 2. apply to context in order (order matters!) this.activePlugins.set(plugin.id, plugin); this.reorder(); // sort by category/priority
