← Commit history

ROOT CAUSE FIX: localStorage shim - sandboxed docs throw on storage access, aborting the bundle's rig init (lights/env/ViewCube). Bundle rig now initializes; manual lights demoted to fallback

John Lauer ·967d0ab72b ·3mo ago ·parent f9d4b7e
3 files changed +31−10
package.json+1−1
@@ -2,7 +2,7 @@   "slug": "bq25792-charger",   "title": "BQ25792 Charger",   "type": "component",-  "version": "0.1.31",+  "version": "0.1.32",   "description": "BQ25792 Charger - buck-boost 1S-4S battery charger board by Adonis, with real 3D copper traces and measured stackup.",   "tags": [     "hardware"
page.json+10−3
@@ -4,9 +4,16 @@   "slug": "bq25792-charger",   "title": "BQ25792 Charger",   "brief": "Buck-boost 1S-4S battery charger board (TI BQ25792) with 14 Adom machine pins, by Adonis",-  "version": "0.1.31",+  "version": "0.1.32",   "tags": [-    "hardware"+    "adom",+    "adom-modular",+    "component",+    "charger",+    "battery",+    "bq25792",+    "power",+    "usb-c"   ],   "license": "proprietary",   "component": {@@ -49,7 +56,7 @@     "email": "[email protected]"   },   "visibility": "public",-  "description": "BQ25792 Charger - buck-boost 1S-4S battery charger board by Adonis, with real 3D copper traces and measured stackup.",+  "description": "BQ25792 Charger - a buck-boost 1S-4S battery charger board (Texas Instruments BQ25792) designed by Adonis in Fusion 360, with 14 Adom machine pins for the modular stack. Interactive colored 3D model, schematic and layout views.",   "dependencies": {},   "files": [     "README.md",
readme.html+20−6
@@ -4,6 +4,16 @@ <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>BQ25792 Charger</title>+<script>+// Sandbox shim: sandboxed docs (no allow-same-origin) THROW on localStorage/sessionStorage+// access. The viewer bundle touches storage during init and the exception aborts its+// whole scene rig (lights/env/ViewCube). Provide in-memory stand-ins BEFORE the bundle.+(function(){+  function mem(){ var st={}; return {getItem:function(k){return k in st?st[k]:null;},setItem:function(k,v){st[k]=String(v);},removeItem:function(k){delete st[k];},clear:function(){st={};},key:function(i){return Object.keys(st)[i]||null;},get length(){return Object.keys(st).length;}}; }+  try{ window.localStorage; }catch(e){ try{ Object.defineProperty(window,"localStorage",{value:mem(),configurable:true}); }catch(x){} }+  try{ window.sessionStorage; }catch(e){ try{ Object.defineProperty(window,"sessionStorage",{value:mem(),configurable:true}); }catch(x){} }+})();+</script> <link rel="stylesheet" href="/static/vendor/adom-3d-viewer-babylon9/style.css"> <script type="module" src="/static/vendor/adom-3d-viewer-babylon9/adom-3d-viewer-babylon9.esm.js?v=20260611d"></script> <style>@@ -252,15 +262,19 @@ exported bodies + design rules.</p>      // 5) the deployed bundle's light rig does not materialize in this sandbox - add a     // matching rig (hemi + key/fill) and a shadow generator; ground receives below.+    let sg=null;     if(sc.lights.length===0){+      // fallback rig only if the bundle's own rig (hemi+bottom+spot, PCF shadows) is absent       new (B().HemisphericLight)("hemi",new (B().Vector3)(0.2,0.2,1),sc).intensity=1.0;+      const key=new (B().DirectionalLight)("key",new (B().Vector3)(-0.4,-0.5,-1),sc);+      key.intensity=1.3; key.position=new (B().Vector3)(0.1,0.1,0.3);+      new (B().DirectionalLight)("fill",new (B().Vector3)(0.7,0.4,-0.5),sc).intensity=0.5;+      sg=new (B().ShadowGenerator)(2048,key);+      sg.useBlurExponentialShadowMap=true; sg.blurKernel=16;+    }else{+      sc.lights.forEach(l=>{ const g=l.getShadowGenerator&&l.getShadowGenerator(); if(g&&!sg) sg=g; });     }-    const key=new (B().DirectionalLight)("key",new (B().Vector3)(-0.4,-0.5,-1),sc);-    key.intensity=1.3; key.position=new (B().Vector3)(0.1,0.1,0.3);-    const fill=new (B().DirectionalLight)("fill",new (B().Vector3)(0.7,0.4,-0.5),sc); fill.intensity=0.5;-    const sg=new (B().ShadowGenerator)(2048,key);-    sg.useBlurExponentialShadowMap=true; sg.blurKernel=16;-    LAYERS.forEach(L=>L.meshes.forEach(m=>{ try{ sg.addShadowCaster(m,true);}catch(e){} }));+    if(sg) LAYERS.forEach(L=>L.meshes.forEach(m=>{ try{ sg.addShadowCaster(m,true);}catch(e){} }));     // keep a render loop alive without replacing the bundle's (viewcube scene safety)     var eng2=viewer.getEngine();     if(!eng2._activeRenderLoops || eng2._activeRenderLoops.length===0){ eng2.runRenderLoop(function(){ sc.render(); }); }