diff --git a/library/layouts/StackLayout.vue b/library/layouts/StackLayout.vue index b13ed230f..cfdc0fa42 100644 --- a/library/layouts/StackLayout.vue +++ b/library/layouts/StackLayout.vue @@ -80,10 +80,8 @@ import { defineComponent } from 'vue' import { useShadowStyles } from '@map/composables/useShadowStyles.js' import { bundleTreeRoot } from '@map/utils/embedBase.js' +import { loadScriptOnce } from '@map/utils/embedScript.js' -// Inject a bundle script exactly once per URL (deduped across all layout instances). Same helper the -// tabs layout + the SPA use — resolves after the IIFE's customElements.define has run. -const _stlLoaded = {} // ★ ANCHOR A SIBLING-BUNDLE src TO THE TREE ROOT, NOT TO A GUESSED DEPTH. // THE BUG (Driver-reported 2026-09-23, verbatim console text): // Could not load from ../../doxa-research-map/doxa-research-map.js @@ -134,30 +132,11 @@ function resolveBundleSrc(url) { return url } +// Inject a bundle script exactly once per URL, through the ONE shared loader (library/utils/embedScript.js: +// the dedupe cache, the dev-server ES-module rule, the empty-url no-op). Only the src resolution is this +// layout's own: a sibling-bundle src is anchored to the tree root first (resolveBundleSrc above). function injectScriptOnce(rawUrl) { - const url = resolveBundleSrc(rawUrl) - if (!url) return Promise.resolve() - if (_stlLoaded[url]) return _stlLoaded[url] - _stlLoaded[url] = new Promise((ok, fail) => { - const s = document.createElement('script') - s.src = url - // ★ A DEV ENTRY IS AN ES MODULE, AND A CLASSIC