by adom
0402 SMD Red LED · 2.1 V drop · 25 mA max
← Commit history
Fix dark/unlit interactive viewer in the sandboxed wiki blob - shim localStorage and sessionStorage with no-ops before the bundle loads so the viewer's SceneBuilder (lights, IBL, shadows, skybox) completes instead of aborting on the sandbox SecurityError.
1 file changed
+9
IN-S42ATR-viewer.html+9@@ -70,6 +70,15 @@ <script> (async () => { const statusEl = document.getElementById('status');++ // Wiki blobs render SANDBOXED (no allow-same-origin): localStorage/sessionStorage throw a+ // SecurityError that aborts the viewer's SceneBuilder (leaving no lights / IBL / shadows /+ // skybox). Shim both with no-ops BEFORE his bundle loads so his own init completes normally.+ for (const k of ['localStorage','sessionStorage']) {+ try { window[k] && window[k].getItem('x'); }+ catch (e) { try { Object.defineProperty(window, k, { configurable:true, value:{ getItem:()=>null, setItem:()=>{}, removeItem:()=>{}, clear:()=>{}, key:()=>null, length:0 } }); } catch(_) {} }+ }+ // Wiki blob storage serves .js as application/octet-stream + nosniff, so a <script src> // of the bundle is refused by the browser. Fetch it as text and inject it as an inline // script (which executes). Behaves the same when served locally.