@oddessentials/agent-guild 0.32.0 → 0.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,5 @@
1
+ import { bindVisibleViewport } from './layout.js';
2
+
1
3
  const ARROWS = { ArrowUp: 'A', ArrowDown: 'B', ArrowRight: 'C', ArrowLeft: 'D' };
2
4
 
3
5
  /** Use the same cursor mode as a physical keyboard, including inside full-screen tools. */
@@ -102,29 +104,9 @@ export class TerminalControls {
102
104
 
103
105
  /** Fit the touch panel to a docked keyboard without changing global page layout. */
104
106
  export function bindTerminalViewport(panel, controls) {
105
- const viewport = window.visualViewport;
106
- let frame;
107
- const update = () => {
108
- if (panel.hidden || controls.hidden) {
109
- panel.style.removeProperty('--terminal-viewport-top');
110
- panel.style.removeProperty('--terminal-viewport-bottom');
111
- delete panel.dataset.compact;
112
- return;
113
- }
114
- // Magnification belongs to the browser; it must not resize the shared PTY.
115
- if (viewport && Math.abs(viewport.scale - 1) > 0.01) return;
116
- const top = viewport?.offsetTop || 0;
117
- const height = viewport?.height ?? innerHeight;
118
- panel.style.setProperty('--terminal-viewport-top', `${top}px`);
119
- panel.style.setProperty('--terminal-viewport-bottom', `${Math.max(0, innerHeight - top - height)}px`);
120
- panel.toggleAttribute('data-compact', height < 420);
121
- };
122
- const schedule = () => { cancelAnimationFrame(frame); frame = requestAnimationFrame(update); };
123
- viewport?.addEventListener('resize', schedule);
124
- viewport?.addEventListener('scroll', schedule);
125
- addEventListener('resize', schedule);
126
- addEventListener('pageshow', schedule);
127
- const observer = new MutationObserver(schedule);
128
- for (const element of [panel, controls]) observer.observe(element, { attributes: true, attributeFilter: ['hidden'] });
129
- schedule();
107
+ bindVisibleViewport(panel, 'terminal', {
108
+ shown: () => !panel.hidden && !controls.hidden,
109
+ watch: [panel, controls],
110
+ fitted: (height) => panel.toggleAttribute('data-compact', height !== null && height < 420),
111
+ });
130
112
  }