Buttonbar based on extensions/plugins loaded

I have an editor (shell) that is generic, in that extensions/plugins are loaded (dynamic import) based on some metadata that is fetched. Together with import maps this is now working fine. However, I also want to display a buttonbar ‘dynamically’. I’m thinking of two approaches:

  1. Create the buttonbar entirely dynamically. Thinking out load, by looking at the schema I can determine which plugins are loaded, and maybe I can then parse the commands present to hook them up to the buttonbar (seems like a real long shot).

or

  1. Have a buttonbar (template) ready - and then depending on the schema dynamically switch off/hide the buttons that represent commands that are not part of the schema.

Any other suggestions?