Skip to content

Fix inserted widget runtime to honor external script load order (Leaflet/map rendering)#31

Draft
Copilot wants to merge 4 commits intomainfrom
copilot/fix-map-insertion-issue
Draft

Fix inserted widget runtime to honor external script load order (Leaflet/map rendering)#31
Copilot wants to merge 4 commits intomainfrom
copilot/fix-map-insertion-issue

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 2, 2026

Inserted map widgets could render in Preview but fail after insertion because widget JS executed before external library scripts (e.g., Leaflet) were ready. This change aligns inserted-widget runtime behavior with expected browser script ordering so library-dependent widgets initialize reliably.

  • Runtime script execution ordering

    • Updated widget.html widget bootstrap to execute injected <script> tags sequentially.
    • For external scripts (src), execution now advances on onload/onerror, then runs source.js only after the injected script queue completes.
    • Added explicit error logging for failed external script loads to improve diagnosability without changing flow control.
  • Regression coverage

    • Added tests/unit/widget-runtime.test.ts to assert that source.js observes external library side effects before it runs.

Example of the ordering behavior now enforced:

<!-- source.html -->
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<div id="map"></div>
// source.js (runs after external scripts finish)
const map = L.map('map').setView([36.5, 128.5], 6);

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • example.com
    • Triggering command: /opt/hostedtoolcache/node/24.14.0/x64/bin/node /opt/hostedtoolcache/node/24.14.0/x64/bin/node -e const sendRequest = require(&#39;https&#39;).request; const options = { &#34;method&#34;: &#34;GET&#34;, &#34;headers&#34;: { &#34;Accept&#34;: &#34;*/*&#34;, &#34;Accept-Encoding&#34;: &#34;gzip, deflate, br&#34;, &#34;Connection&#34;: &#34;close&#34;, &#34;Origin&#34; saryBeforeUnloadCheckSync,DestroyProfileOnBrowserClose,DialMediaRouteProvider,GlobalMediaControls,HttpsUpgrades,LensOverlay,MediaRouter,PaintHolding,ThirdPartyStoragePartition (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI linked an issue Apr 2, 2026 that may be closed by this pull request
Copilot AI and others added 3 commits April 2, 2026 20:37
Agent-Logs-Url: https://github.com/wigify/wigify/sessions/3dc5cf5e-0cc1-42e0-9522-c0256e6aa9e7

Co-authored-by: saeedvaziry <61919774+saeedvaziry@users.noreply.github.com>
Agent-Logs-Url: https://github.com/wigify/wigify/sessions/3dc5cf5e-0cc1-42e0-9522-c0256e6aa9e7

Co-authored-by: saeedvaziry <61919774+saeedvaziry@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix map insertion issue in widget Fix inserted widget runtime to honor external script load order (Leaflet/map rendering) Apr 2, 2026
Copilot AI requested a review from saeedvaziry April 2, 2026 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Map

2 participants