Toys Free: Plugin Selection
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])); plugin selection toys
interface ToyPlugin "physics"; icon: string; // emoji or asset URL cost?: number; // for resource-limited toys exclusiveGroup?: string; // e.g., "reverb-group" – only one per group apply: (context: ToyContext) => ToyContext; // core transformation ui?: knob?: string[]; toggle?: boolean ; // user configurable params getPipeline() return Array
const echoPlugin = id: "echo-delay", name: "Echo Tunnel", category: "audio", exclusiveGroup: "delay", apply: (ctx) => // apply echo effect to ctx.audioBuffer ctx.userParams.delayTime = ctx.userParams.delayTime , 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); check exclusive group if (plugin

