← Commit history

0.5.45: widget helper measures intrinsic width

John Lauer ·0d771f4532 ·1mo ago ·parent 5609111
3 files changed +11−5
bin/hydrogen-widget-lib.py+8−2
@@ -48,9 +48,15 @@ function render(d){document.getElementById('w').innerHTML=%(render_js)s;postWidt /* THE WIDGET DECIDES ITS WIDTH: measure the content in the current layout (tall rows are narrow,    the compact row is wide) and ask the host for that width. Never fixed px; the host clamps. */ function postWidth(){try{const w=document.querySelector('.w');const rows=document.getElementById('w');if(!w||!rows)return;-  let need=0;for(const r of rows.children){need=Math.max(need,r.scrollWidth);}+  /* Intrinsic width: rows stretch to the slot, so never measure a row's box. Sum each row's children+     (a bar counts at its minimum in the tall layout, its fixed width in the short one) plus gaps. */+  const tall=window.innerHeight>=34;let need=0;+  for(const r of rows.children){const rs=getComputedStyle(r);const gap=parseFloat(rs.columnGap||rs.gap||'0')||0;let sum=0,n=0;+    for(const c of r.children){n++;if(c.classList.contains('bar')){sum+=tall?56:c.getBoundingClientRect().width;}else{sum+=Math.ceil(c.scrollWidth);}}+    if(n===0)sum=Math.ceil(r.scrollWidth);need=Math.max(need,sum+gap*Math.max(0,n-1));}+  if(!tall){const rg=parseFloat(getComputedStyle(rows).gap||'0')||0;let total=0,n=0;for(const r of rows.children){n++;const rs=getComputedStyle(r);const gap=parseFloat(rs.columnGap||rs.gap||'0')||0;let sum=0,k=0;for(const c of r.children){k++;sum+=c.classList.contains('bar')?c.getBoundingClientRect().width:Math.ceil(c.scrollWidth);}if(k===0)sum=Math.ceil(r.scrollWidth);total+=sum+gap*Math.max(0,k-1);}need=total+rg*Math.max(0,n-1);}   const mark=w.querySelector('.mark');const cs=getComputedStyle(w);-  const total=Math.ceil(need+(mark?mark.getBoundingClientRect().width+parseFloat(cs.gap||'0'):0)+parseFloat(cs.paddingLeft)+parseFloat(cs.paddingRight)+2);+  const total=Math.ceil(need+(mark?mark.getBoundingClientRect().width+(parseFloat(cs.gap||'0')||0):0)+parseFloat(cs.paddingLeft)+parseFloat(cs.paddingRight)+3);   if(total>0&&window.parent!==window)window.parent.postMessage({hdWidget:{width:total}},'*');}catch(e){}} async function tick(){try{const r=await fetch('/data.json',{cache:'no-store'});const d=await r.json();window.__last=d;render(d);}catch(e){document.getElementById('w').innerHTML='<span class="err">no data</span>';}} let tm=null;function arm(){if(tm)return;tm=setInterval(tick,R);}function disarm(){if(tm){clearInterval(tm);tm=null;}}
package.json+1−1
@@ -4,7 +4,7 @@   "type": "bootstrap",   "title": "Adom Hydrogen (platform base)",   "brief": "Layer Hydrogen's workspace onto a standard Adom workstation.",-  "version": "0.5.44",+  "version": "0.5.45",   "description": "Hydrogen's PLATFORM-GENERIC workspace layer on top of adom/core. Installs adom/core for the full Adom ecosystem, then adds everything common to running inside Hydrogen on ANY platform: the runtime-neutral hydrogen-* skills and the generic editor configuration (Claude Code CLI + extension, VS Code settings, trusted domains). Platform-specific layers depend on THIS: adom/hydrogen-windows-bootstrap (WSL2), adom/hydrogen-mac-bootstrap, adom/hydrogen-ubuntu-bootstrap. The reference design other orgs copy to build their own bootstrap on adom/core.",   "org": "adom",   "tags": [
page.json+2−2
@@ -4,7 +4,7 @@   "type": "bootstrap",   "title": "Adom Hydrogen (platform base)",   "brief": "Layer Hydrogen's workspace onto a standard Adom workstation.",-  "version": "0.5.44",+  "version": "0.5.45",   "description": "Hydrogen's PLATFORM-GENERIC workspace layer on top of adom/core. Installs adom/core for the full Adom ecosystem, then adds everything common to running inside Hydrogen on ANY platform: the runtime-neutral hydrogen-* skills and the generic editor configuration (Claude Code CLI + extension, VS Code settings, trusted domains). Platform-specific layers depend on THIS: adom/hydrogen-windows-bootstrap (WSL2), adom/hydrogen-mac-bootstrap, adom/hydrogen-ubuntu-bootstrap. The reference design other orgs copy to build their own bootstrap on adom/core.",   "org": "adom",   "tags": [@@ -49,4 +49,4 @@     "hydrogen editor configuration",     "where do hydrogen skills come from"   ]-}\ No newline at end of file+}