Detecting app blocks and app embed blocks

I believe you should be able to use this to get the content of theme files.

With that you should be able to query for the files and check the templates to see if any of them are using the app blocks and app embed blocks.

You may want to use the .dev Assistant to help generate some code for fetching what you want.