Not sure this is the best way to handle this, but it does work.
The other day I was working on a block plugin and needed a way to include JavaScript and CSS, but only if that block was in use. Relatively easy on single pages, but I wanted it to work on archive pages as well.
Turns out it doesn't take too much code to get a list of all the current post IDs and loop through each calling has_block
along the way. Even better, this works for archive and single pages. If it's a singular page then $post_ids
will be a 1 element array with that post. If it's an archive page the all the post IDs will be in that array.