/** * embedScript — load another bundle's script and wait for its element to register. * * ★ WHAT AN APP SHELL DOES. A capability-5 plugin nests other plugins, so it needs three things: * work out the tree root it was served from, load a bundle's `.js` exactly once, and wait for the * custom element to actually exist before mounting it. Both shells in this repo — the Research * Gallery (`doxa-maps-spa`) and the Plugin Studio (`plugin-studio`) — had their own copy of all * three, identical in code (DEDUP-AUDIT.md, 2026-09-28: 33 lines, the only cross-plugin cluster * that is identical, closes over nothing, and spans one owner's plugins). * * Moved verbatim; the comments below are the originals, because each records a measurement. * * ★ ONE BEHAVIOUR CHANGE, AND IT IS AN IMPROVEMENT: `_loaded` is now shared. Two shells on one page * previously kept separate caches and would each load the same bundle. Now the second one reuses * the first's promise. Same result, one network request instead of two. */ /** * Load a bundle exactly once per URL; resolves after its script has executed. * * ★ A CLASSIC SCRIPT FIRES onload AND THEN FAILS, for a dev-server bundle. Measured 2026-09-22: * pointing a plain