doxa-maps/plugin-designs/plugin-studio
Doxa Maps d0939c0492 library: one embedScript for the app shells, replacing four private copies
DEDUP-AUDIT.md (measured today: 253 files, 31 cross-plugin duplicate clusters,
622 duplicated lines) ranks this tenth by raw cost and first by suitability. It
is the only cluster where the copies are identical in code, close over nothing,
and sit in two plugins with one owner between them.

loadScriptOnce (13 lines) and whenTagDefined (11) were byte-identical between
doxa-maps-spa and plugin-studio. deriveTreeBase (9) differed by ONE COMMENT LINE
and not one character of code -- drift in the documentation of a shared function,
which is its own argument for having one copy.

They are one concern, not three: load a bundle's script once, wait for its custom
element to register, and work out the tree base to load it from. That is what a
capability-5 app shell does to nest another plugin, and both plugins here ARE the
capability-5 shells. Any future shell needs the same three.

Verbatim move: no parameterisation, no behaviour change, callers import instead
of declaring. The comments travel with the code because each records a
measurement -- particularly the one explaining why onload is not a usable success
signal for a dev-server ES module.

ONE BEHAVIOUR CHANGE, AND IT IS AN IMPROVEMENT: the _loaded cache is now shared.
Two shells on one page previously kept separate caches and each loaded the same
bundle; the second now reuses the first's promise.

deriveTreeBase reads document.currentScript, so it is only valid AT MODULE
EVALUATION TIME. The call sites did not move -- both entries still call it at
module top level -- and the library file documents the constraint, because a
later call silently returns '' and every nested bundle URL would break.

Verified: both bundles build; each built file contains all three functions
exactly once and still derives currentScript; check:sri, check:series-isolation,
check:studio-rail and check:capability-derived all PASS.

library/utils/embedScript.js is the build owner's under rule 5B. The
plugin-designs and public/ changes are in the same commit because they import it
-- landing them apart breaks the build in between.
2026-09-28 07:07:33 +00:00
..
src Plugin Studio: the Experimental section no longer reads CAP 0, and clicking a plugin no longer unfolds it 2026-09-27 23:14:14 +00:00
index.html Bake profile type into manifest; plugin-studio cap-5 element; UPG-100 print+dots 2026-09-19 06:56:27 +00:00
index.js library: one embedScript for the app shells, replacing four private copies 2026-09-28 07:07:33 +00:00
plugin-studio.instances.json Bake profile type into manifest; plugin-studio cap-5 element; UPG-100 print+dots 2026-09-19 06:56:27 +00:00
plugin-studio.meta.json Plugin studio: give the plugin the whole stage, and stop showing the grid twice 2026-09-24 19:25:50 +00:00
plugin-studio.vue library: one embedScript for the app shells, replacing four private copies 2026-09-28 07:07:33 +00:00