@william_jin/autobrowse 0.8.40 → 0.8.41

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.
@@ -185,6 +185,10 @@ kbd{display:inline-flex;align-items:center;justify-content:center;min-width:18px
185
185
  .ph .nm.cut{-webkit-mask-image:linear-gradient(90deg,#000 80%,transparent)}
186
186
  .ph .tt{flex:1;min-width:0;color:var(--mut);white-space:nowrap;overflow:hidden;text-overflow:clip;-webkit-mask-image:linear-gradient(90deg,#000 85%,transparent)}
187
187
  .ph .rb.ico{width:22px;height:22px}
188
+ .ph .md{flex:none;display:flex;color:var(--mut)}
189
+ .ph .md svg{width:13px;height:13px}
190
+ /* a shrink from Focus: the bar waits for the new box (land()), so the page never resizes mid-sweep */
191
+ .pane.nobar .ph{display:none}
188
192
  .pane iframe{flex:1;width:100%;border:0;display:block;background:var(--bg)}
189
193
  #empty{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;color:var(--mut);opacity:0;pointer-events:none;transition:opacity .15s}
190
194
  #empty.on{opacity:1}
@@ -405,6 +409,8 @@ const ICON = {
405
409
  // a page another page opened: a window over its opener
406
410
  pop: '<rect x="5.25" y="2.25" width="8.5" height="7.5" rx="1.5"/><path d="M2.25 6.5v5.75c0 .83.67 1.5 1.5 1.5H9.5"/>',
407
411
  eye: '<path d="M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z"/><circle cx="8" cy="8" r="2"/>',
412
+ // input reaches the run
413
+ pen: '<path d="M10.75 2.75a1.77 1.77 0 0 1 2.5 2.5L5.5 13H3v-2.5z"/><path d="M9.5 4l2.5 2.5"/>',
408
414
  };
409
415
  const FILLED = new Set(['pause', 'play']);
410
416
  const icon = (n) => `<svg class="ic${FILLED.has(n) ? ' fill' : ''}" viewBox="0 0 16 16" aria-hidden="true">${ICON[n]}</svg>`;
@@ -474,7 +480,10 @@ const narrowQ = matchMedia('(max-width: 759px)');
474
480
  const shownMode = () => (narrowQ.matches && mode === 'full' ? 'rail' : mode);
475
481
  /** key → {el, frame, url, title, at} ; a pane out of the layout stays a while, hidden, for a quick return */
476
482
  const panes = new Map();
477
- const KEEP = 4;
483
+ /** every pane a layout can show stays loaded: a return or a Focus switch reuses its viewer and socket (WA-1526) */
484
+ const keep = () => Math.max(CAP.grid, CAP.focus);
485
+ /** a pane out of view streams this long before its viewer hears `on:false`: a quick switch back never restarts the run's stream */
486
+ const OFF_HOLD_MS = 1500;
478
487
  const idOf = (key) => key.split('#')[0];
479
488
 
480
489
  function sorted() {
@@ -630,9 +639,16 @@ const PICK_MARGIN = 1.04;
630
639
  const LAZY_PAGE = { w: 1280, h: 800, fixed: true, chrome: 0 };
631
640
  /** run id → its viewer's last `page`: a new pane of the run fits at once */
632
641
  const pageBy = new Map();
633
- function pageOf(key) {
634
- return panes.get(key)?.page ?? pageBy.get(idOf(key)) ?? (rows.get(idOf(key))?.lazy ? LAZY_PAGE : null);
635
- }
642
+ /** the page a pane shows, with the viewer's bars of the look it gets next (bare tile or full): a Focus to Grid switch sizes once */
643
+ function pageOf(key, i = cells.indexOf(key)) {
644
+ const p = panes.get(key), pg = p?.page ?? pageBy.get(idOf(key)) ?? (rows.get(idOf(key))?.lazy ? LAZY_PAGE : null);
645
+ if (!pg || i < 0) return pg;
646
+ const bare = !(max ? i === cur : cells.length === 1 && layout === 'focus');
647
+ const ch = p?.chromes?.[bare ? 'bare' : 'full'] ?? (bare ? undefined : fullChrome);
648
+ return ch === undefined || ch === pg.chrome ? pg : { ...pg, chrome: ch };
649
+ }
650
+ /** the last full viewer's bars: a pane's first Focus sizes with it */
651
+ let fullChrome;
636
652
  /** the viewer's own fit (viewer.html zs): whole, never above 1:1 */
637
653
  const fitScale = (w, h, pg) => Math.max(0, Math.min(1, w / pg.w, h / pg.h));
638
654
  /** the page area a cell shows: a fixed page scaled whole; any other page fills its cell */
@@ -705,15 +721,17 @@ function hug([l, t, w, h], pg, single) {
705
721
  }
706
722
  // --- §Hub motion: FLIP --------------------------------------------------------------
707
723
  // a pane takes its new box at once (one layout, one page resize); a transform plays from the old box
708
- const SWEEP_MS = 200, KF = 20;
709
- /** keyframe times where cubic-bezier(.16,1,.3,1) reaches k/KF: even steps in scale, so .pin's counter-scale stays near exact between keyframes */
724
+ // 300 ms ease-in-out: a pane moves on screen (MV-4, MV-6, MV-9)
725
+ const SWEEP_MS = 300, KF = 20, SWEEP_EASE = [.77, 0, .175, 1];
726
+ /** keyframe times where SWEEP_EASE reaches k/KF: even steps in scale, so .pin's counter-scale stays near exact between keyframes */
710
727
  const SWEEP_AT = (() => {
728
+ const [x1, y1, x2, y2] = SWEEP_EASE;
711
729
  const bz = (a, b, u) => 3 * a * u * (1 - u) ** 2 + 3 * b * u * u * (1 - u) + u ** 3;
712
730
  return Array.from({ length: KF + 1 }, (_, k) => {
713
731
  if (k === 0 || k === KF) return k / KF;
714
732
  let lo = 0, hi = 1;
715
- for (let j = 0; j < 30; j++) { const m = (lo + hi) / 2; if (bz(1, 1, m) < k / KF) lo = m; else hi = m; }
716
- return bz(.16, .3, (lo + hi) / 2);
733
+ for (let j = 0; j < 30; j++) { const m = (lo + hi) / 2; if (bz(y1, y2, m) < k / KF) lo = m; else hi = m; }
734
+ return bz(x1, x2, (lo + hi) / 2);
717
735
  });
718
736
  })();
719
737
  let stageWH = '', roomMoved = false, roomFrom = null, roomAt = 0;
@@ -730,18 +748,42 @@ function fade(p, show) {
730
748
  const v = 'visible';
731
749
  p.fade = p.el.animate(show ? [{ opacity: 0 }, { opacity: 1 }] : [{ opacity: 1, visibility: v }, { opacity: 0, visibility: v }], { duration: show ? 150 : 120, easing: EASE });
732
750
  }
733
- function stopSweep(p) { for (const a of p.sweep ?? []) a.cancel(); p.sweep = null; }
734
- function sweep(p, o, n, r) {
751
+ /** a cut sweep: a shrink still owed its box lands now */
752
+ function stopSweep(p) { const s = p.sweep; p.sweep = null; for (const a of s ?? []) a.cancel(); if (p.pend) land(p); }
753
+ const place = (el, [l, t, w, h]) => Object.assign(el.style, { left: `${l}px`, top: `${t}px`, width: `${w}px`, height: `${h}px` });
754
+ /** a shrink's end: the new box and bar, then the viewer's new look */
755
+ function land(p) {
756
+ const { box, xy, bar } = p.pend;
757
+ p.pend = null; p.box = box;
758
+ place(p.el, xy);
759
+ if (bar) {
760
+ p.el.classList.remove('nobar');
761
+ const nm = p.el.querySelector('.nm');
762
+ nm.classList.toggle('cut', nm.scrollWidth > nm.clientWidth);
763
+ if (motionOn()) p.el.querySelector('.ph').animate([{ opacity: 0 }, { opacity: 1 }], { duration: 150, easing: EASE });
764
+ }
765
+ tellViewers();
766
+ }
767
+ /** a shrink: the pane keeps its box and look and scales down to the new box; layout and viewer change once, at the end. A small layout is never magnified (no dark box, no blur) */
768
+ function shrink(p, o, n, at, box, xy, bar) {
769
+ stopSweep(p);
770
+ const [l, t, w, h] = p.box.split(',').map(Number), S = { left: at.left + l, top: at.top + t, width: w, height: h };
771
+ const T = (r) => `translate(${r.left - S.left}px,${r.top - S.top}px) scale(${r.width / S.width},${r.height / S.height})`;
772
+ p.pend = { box, xy, bar };
773
+ if (bar) p.el.classList.add('nobar');
774
+ const a = p.el.animate([{ transform: T(o) }, { transform: T(n) }], { duration: SWEEP_MS, easing: `cubic-bezier(${SWEEP_EASE})`, fill: 'forwards' });
775
+ p.sweep = [a];
776
+ a.onfinish = () => { if (p.sweep?.[0] !== a) return; p.sweep = null; land(p); a.cancel(); };
777
+ }
778
+ // transform only: the compositor plays it through a viewer's resize on the main thread (WebKit shares it); corners scale with the box for 300 ms
779
+ function sweep(p, o, n) {
735
780
  stopSweep(p);
736
781
  const sx = o.width / n.width, sy = o.height / n.height, dx = o.left - n.left, dy = o.top - n.top;
737
782
  if (Math.abs(dx) < .5 && Math.abs(dy) < .5 && Math.abs(sx - 1) < .002 && Math.abs(sy - 1) < .002) return;
738
783
  const box = [], pin = [];
739
784
  SWEEP_AT.forEach((offset, k) => {
740
785
  const e = k / KF, x = sx + (1 - sx) * e, y = sy + (1 - sy) * e;
741
- const f = { offset, transform: `translate(${dx * (1 - e)}px,${dy * (1 - e)}px) scale(${x},${y})` };
742
- // the window's corners stay round mid-scale
743
- if (r) f.borderRadius = `${r / x}px / ${r / y}px`;
744
- box.push(f);
786
+ box.push({ offset, transform: `translate(${dx * (1 - e)}px,${dy * (1 - e)}px) scale(${x},${y})` });
745
787
  pin.push({ offset, transform: `scale(${1 / x},${1 / y})` });
746
788
  });
747
789
  const t = { duration: SWEEP_MS, easing: 'linear' };
@@ -775,13 +817,32 @@ function packRows(items, gap) {
775
817
  }
776
818
  /** what a pane's viewer needs: tiles scale frames; one full pane or a session's first pane sets the viewport, never under SIZE_MIN */
777
819
  function embedOf(key) {
778
- const i = cells.indexOf(key), single = max ? i === cur : cells.length === 1 && layout === 'focus';
820
+ const i = cells.indexOf(key), p = panes.get(key);
821
+ // out of the layout: its last look holds (no chrome flip, no page resize on return); off after OFF_HOLD_MS
822
+ if (i < 0) return { ...(p?.look ?? { t: 'embed', tile: true, zoom: 0, bare: true }), on: hubOn && !!p?.outAt && Date.now() - p.outAt < OFF_HOLD_MS };
823
+ const single = max ? i === cur : cells.length === 1 && layout === 'focus';
779
824
  // a session's first pane sizes its page as a split browser does; a second view of it only scales
780
825
  const first = !key.includes('#') && cells.findIndex((k) => idOf(k) === idOf(key)) === i;
781
- const w = panes.get(key)?.w ?? 0, owns = i >= 0 && !max && first && w > 0;
782
- const sizes = i >= 0 && (single || owns);
826
+ const w = p?.w ?? 0, owns = !max && first && w > 0, sizes = single || owns;
783
827
  // the viewer knows its stage: under SIZE_MIN on either side it zooms out (no phone layout, no cut form, no bands)
784
- return { t: 'embed', tile: !sizes, zoom: sizes ? SIZE_MIN : 0, bare: !single, on: hubOn && i >= 0 && (!max || i === cur) };
828
+ const look = { t: 'embed', tile: !sizes, zoom: sizes ? SIZE_MIN : 0, bare: !single };
829
+ if (p) p.look = look;
830
+ return { ...look, on: hubOn && (!max || i === cur) };
831
+ }
832
+ /** each viewer hears only a change (each message makes it re-send `visible` to its session); at a sweep's start, so its bars change inside the motion */
833
+ let offT = 0;
834
+ function tellViewers() {
835
+ clearTimeout(offT);
836
+ let wait = Infinity;
837
+ for (const [k, p] of panes) {
838
+ const left = p.outAt ? p.outAt + OFF_HOLD_MS - Date.now() : 0;
839
+ if (left > 0) wait = Math.min(wait, left);
840
+ // a shrink tells its viewer when it lands
841
+ if (p.pend) continue;
842
+ const e = embedOf(k), j = JSON.stringify(e);
843
+ if (p.embed !== j) { p.embed = j; p.frame.contentWindow?.postMessage({ hub: e }, '*'); }
844
+ }
845
+ if (wait < Infinity) offT = setTimeout(tellViewers, wait + 20);
785
846
  }
786
847
 
787
848
  // --- panes -------------------------------------------------------------------------
@@ -791,7 +852,7 @@ function pane(key) {
791
852
  if (p) return p;
792
853
  const el = document.createElement('div');
793
854
  el.className = 'pane';
794
- el.innerHTML = `<div class="pin"><div class="ph" draggable="true"><span class="dot idle"></span><span class="nm"></span><span class="sw"></span><span class="tt"></span><button type="button" class="rb ico" data-a="max" title="Maximize (⌘⇧↩)" aria-label="Maximize (⌘⇧↩)">${icon('max')}</button><button type="button" class="rb ico" data-a="tear" title="Own window (⌘⇧T)" aria-label="Own window (⌘⇧T)">${icon('tear')}</button><button type="button" class="rb ico" data-a="x" title="Close pane" aria-label="Close pane">${icon('x')}</button></div></div>`;
855
+ el.innerHTML = `<div class="pin"><div class="ph" draggable="true"><span class="dot idle"></span><span class="md"></span><span class="nm"></span><span class="sw"></span><span class="tt"></span><button type="button" class="rb ico" data-a="max" title="Maximize (⌘⇧↩)" aria-label="Maximize (⌘⇧↩)">${icon('max')}</button><button type="button" class="rb ico" data-a="tear" title="Own window (⌘⇧T)" aria-label="Own window (⌘⇧T)">${icon('tear')}</button><button type="button" class="rb ico" data-a="x" title="Close pane" aria-label="Close pane">${icon('x')}</button></div></div>`;
795
856
  const frame = document.createElement('iframe');
796
857
  // the viewer keeps its own token, Host and Origin checks: the frame's origin is the session's
797
858
  const u = new URL(r.url);
@@ -931,7 +992,7 @@ function settle(was) {
931
992
  function render() {
932
993
  if (renderRaf) { cancelAnimationFrame(renderRaf); renderRaf = 0; }
933
994
  // reads first: after a frame, layout is clean and they cost nothing
934
- const was = sweepFrom(), rowsWas = places();
995
+ const was = sweepFrom(), rowsWas = places(), wasSingle = stage.classList.contains('single');
935
996
  if (picked) for (const k of picked) if (!cells.includes(k)) picked.delete(k);
936
997
  applySide();
937
998
  roomFrom = null;
@@ -950,7 +1011,7 @@ function render() {
950
1011
  renderRows(rowsWas);
951
1012
  // panes
952
1013
  const W = stage.clientWidth, H = stage.clientHeight, gap = single ? 0 : GAP;
953
- const R = rects(cells.length, W, H, cells.map(pageOf));
1014
+ const R = rects(cells.length, W, H, cells.map((k, i) => pageOf(k, i)));
954
1015
  shownRects = R;
955
1016
  // a window resize or a grip drag tracks the hand: no sweep; a sidebar mode change sweeps
956
1017
  const resized = `${W}x${H}` !== stageWH; stageWH = `${W}x${H}`;
@@ -960,17 +1021,20 @@ function render() {
960
1021
  const at = moves ? stage.getBoundingClientRect() : null, cuts = [];
961
1022
  const boxes = packRows(cells.map((key, i) => {
962
1023
  const cell = boxOf(max ? [0, 0, 1, 1] : R[i], W, H, gap);
963
- return { cell, fit: hug(cell, pageOf(key), single) };
1024
+ return { cell, fit: hug(cell, pageOf(key, i), single) };
964
1025
  }), gap);
965
1026
  cells.forEach((key, i) => {
966
1027
  const p = pane(key);
967
1028
  const r = rows.get(idOf(key));
968
- p.at = Date.now();
1029
+ p.at = Date.now(); p.outAt = 0;
969
1030
  const nm = p.el.querySelector('.nm');
970
1031
  txt(nm, r.site || 'session');
971
1032
  const [pd, pw] = stateOf(r);
972
1033
  cls(p.el.querySelector('.ph .dot'), `dot ${pd}`);
973
1034
  swapText(p.el.querySelector('.sw'), pw);
1035
+ // view only (a watched run) or input reaches the run: the viewer's own chip says the same in Focus
1036
+ const md = p.el.querySelector('.md'), mk = r.lazy ? 'eye' : 'pen';
1037
+ if (md.dataset.i !== mk) { md.dataset.i = mk; md.innerHTML = icon(mk); attr(md, 'title', r.lazy ? 'View only' : 'Can edit'); }
974
1038
  p.w = max ? W : Math.round(R[i][2] * W);
975
1039
  txt(p.el.querySelector('.tt'), p.title || r.state?.title || '');
976
1040
  // the bar is one line: the whole name and title on hover
@@ -990,12 +1054,16 @@ function render() {
990
1054
  // the name fades when cut: measured after every write, and only when name, word or width changed
991
1055
  const ck = `${nm.textContent}|${pw}|${width}`;
992
1056
  if (p.cutKey !== ck) cuts.push([p, nm, ck]);
993
- if (p.box !== box) {
994
- p.box = box;
995
- Object.assign(p.el.style, { left: `${left}px`, top: `${top}px`, width: `${width}px`, height: `${height}px` });
996
- const o = moves && !hidden && !back ? was.get(key) : null;
997
- if (o) sweep(p, o, { left: at.left + left, top: at.top + top, width, height }, single && !fit ? 0 : RADIUS);
998
- else stopSweep(p);
1057
+ if ((p.pend?.box ?? p.box) !== box) {
1058
+ const o = moves && !hidden && !back ? was.get(key) : null, n = o && { left: at.left + left, top: at.top + top, width, height };
1059
+ if (o && p.box && width * height < o.width * o.height) shrink(p, o, n, at, box, [left, top, width, height], wasSingle && !single);
1060
+ else {
1061
+ stopSweep(p);
1062
+ p.box = box;
1063
+ place(p.el, [left, top, width, height]);
1064
+ // a grow or a move: the new box at once, a transform from the old (the viewer draws its last frame to the new width)
1065
+ if (o) sweep(p, o, n);
1066
+ }
999
1067
  if (morph && !moves && !hidden && !back && was.has(key)) fade(p, true);
1000
1068
  }
1001
1069
  });
@@ -1004,14 +1072,10 @@ function render() {
1004
1072
  // panes out of the layout: hidden and off screen, the oldest go
1005
1073
  const out = [...panes.entries()].filter(([k]) => !cells.includes(k)).sort((a, b) => b[1].at - a[1].at);
1006
1074
  out.forEach(([k, p], i) => {
1007
- if (i >= KEEP || !placeable(idOf(k))) drop(k);
1008
- else if (!p.el.classList.contains('off')) { p.el.classList.add('off'); if (morph) fade(p, false); }
1075
+ if (i >= keep() || !placeable(idOf(k))) drop(k);
1076
+ else if (!p.el.classList.contains('off')) { p.el.classList.add('off'); stopSweep(p); p.outAt = Date.now(); if (morph) fade(p, false); }
1009
1077
  });
1010
- // a viewer hears only a change (each message makes it re-send `visible` to its session)
1011
- for (const [k, p] of panes) {
1012
- const e = embedOf(k), j = JSON.stringify(e);
1013
- if (p.embed !== j) { p.embed = j; p.frame.contentWindow?.postMessage({ hub: e }, '*'); }
1014
- }
1078
+ tellViewers();
1015
1079
  $('empty').classList.toggle('on', cells.length === 0);
1016
1080
  txt($('empty').querySelector('.h'), rows.size ? 'Pick a session' : 'No sessions');
1017
1081
  const es = $('empty').querySelector('.s'), want = rows.size ? 'pick' : 'none';
@@ -1706,6 +1770,9 @@ addEventListener('message', (e) => {
1706
1770
  else if (m.t === 'close') { cells = cells.filter((x) => x !== k); render(); }
1707
1771
  else if (m.t === 'page' && m.w > 0 && m.h > 0) {
1708
1772
  const pg = { w: +m.w, h: +m.h, fixed: !!m.fixed, chrome: Math.max(0, +m.chrome || 0) };
1773
+ p.chromes ??= {};
1774
+ p.chromes[m.bare === false ? 'full' : 'bare'] = pg.chrome;
1775
+ if (m.bare === false) fullChrome = pg.chrome;
1709
1776
  if (JSON.stringify(pg) === JSON.stringify(p.page)) return;
1710
1777
  p.page = pg; pageBy.set(idOf(k), pg);
1711
1778
  if (cells.includes(k)) render();
@@ -63,8 +63,8 @@ button{font:inherit;color:inherit;border:0;background:none;padding:0;cursor:defa
63
63
  #agent.held{background:var(--heldt);color:var(--held)}
64
64
  #agent.held .dot{animation:none;border-radius:2px}
65
65
  #agent .ic{width:14px;height:14px}
66
- #ro:not([hidden]){flex:none;height:26px;display:flex;align-items:center;gap:6px;padding:0 10px 0 8px;margin-right:4px;border-radius:999px;background:var(--tabh);color:var(--mut);font-size:12px;font-weight:600;white-space:nowrap}
67
- #ro .ic{width:14px;height:14px}
66
+ #ro:not([hidden]),#rw:not([hidden]){flex:none;height:26px;display:flex;align-items:center;gap:6px;padding:0 10px 0 8px;margin-right:4px;border-radius:999px;background:var(--tabh);color:var(--mut);font-size:12px;font-weight:600;white-space:nowrap}
67
+ #ro .ic,#rw .ic{width:14px;height:14px}
68
68
  /* a hub tile: the page scales to fit; the bar shrinks to the address */
69
69
  .embed #strip{padding-left:8px}
70
70
  /* a pane among others: the hub's pane header is its one bar; a second tab (a sign-in popup) brings a compact strip */
@@ -242,6 +242,7 @@ kbd{min-width:22px;height:22px;padding:0 6px;border-radius:6px;background:var(--
242
242
  <button type="button" class="nb" id="reload" title="Reload (⌘R)" aria-label="Reload (⌘R)"><svg class="ic" aria-hidden="true" viewBox="0 0 16 16"><path d="M13 8a5 5 0 1 1-1.5-3.5M13 2.5v3h-3"/></svg></button>
243
243
  <div id="field"><span id="lock" aria-hidden="true"></span><input id="url" spellcheck="false" autocomplete="off" aria-label="Address" placeholder="Search or enter an address" role="combobox" aria-autocomplete="both" aria-controls="sug" aria-expanded="false"><span id="disp" aria-hidden="true"></span><span id="prog"></span></div>
244
244
  <span id="ro" hidden title="A run you watch: it keeps its own size and input"><svg class="ic" aria-hidden="true" viewBox="0 0 16 16"><path d="M1.5 8S4 3.5 8 3.5 14.5 8 14.5 8 12 12.5 8 12.5 1.5 8 1.5 8z"/><circle cx="8" cy="8" r="2"/></svg>View only</span>
245
+ <span id="rw" hidden title="Your keys and clicks reach the run"><svg class="ic" aria-hidden="true" viewBox="0 0 16 16"><path d="M10.75 2.75a1.77 1.77 0 0 1 2.5 2.5L5.5 13H3v-2.5z"/><path d="M9.5 4l2.5 2.5"/></svg>Can edit</span>
245
246
  <button type="button" id="agent" aria-label="Pause the agent (⌃⌥P)" title="Pause the agent (⌃⌥P)"><span class="dot"></span><span class="lbl">Agent working</span><svg class="ic" aria-hidden="true" viewBox="0 0 16 16"><path d="M6 4v8M10 4v8"/></svg></button>
246
247
  <button type="button" class="nb" id="tbtn" hidden aria-pressed="false" title="Claude terminal (⌘J)" aria-label="Claude terminal (⌘J)" aria-controls="term"><svg class="ic" aria-hidden="true" viewBox="0 0 16 16"><rect x="1.5" y="2.5" width="13" height="11" rx="2"/><path d="M10 2.5v11"/></svg></button>
247
248
  <button type="button" class="nb" id="win" title="Open in a window (⌘⇧O)" aria-label="Open in a window (⌘⇧O)"><svg class="ic" aria-hidden="true" viewBox="0 0 16 16"><path d="M9 2.5h4.5V7M13.5 2.5 8 8M11.5 9.5v3a1 1 0 0 1-1 1h-7a1 1 0 0 1-1-1v-7a1 1 0 0 1 1-1h3"/></svg></button>
@@ -307,25 +308,55 @@ async function frame(buf) {
307
308
  for (let b = buf; b; b = waiting, waiting = null) {
308
309
  try {
309
310
  const bmp = await createImageBitmap(new Blob([b], { type: 'image/jpeg' }));
311
+ // a new page size (pane grew or shrank): the old frame fades out over it, never a one-frame rescale
312
+ if (last && !first && (bmp.width !== last.width || bmp.height !== last.height)) fadeFrom(last);
313
+ else if (last !== fade?.old) last?.close();
310
314
  draw(bmp);
311
- last?.close(); last = bmp;
315
+ last = bmp;
312
316
  if (first) { first = false; cover(null); }
313
317
  } catch {}
314
318
  }
315
319
  decoding = false;
316
320
  }
321
+ const FADE_MS = 150;
322
+ /** the frame before a size change, drawn on top at falling alpha */
323
+ let fade = null;
324
+ function fadeFrom(old) {
325
+ if (fade) fade.old.close();
326
+ fade = { old, t0: performance.now() };
327
+ const tick = () => {
328
+ if (!fade) return;
329
+ if (performance.now() - fade.t0 >= FADE_MS) { fade.old.close(); fade = null; }
330
+ if (last) draw(last);
331
+ if (fade) requestAnimationFrame(tick);
332
+ };
333
+ requestAnimationFrame(tick);
334
+ }
317
335
  function draw(bmp) {
336
+ paint(bmp);
337
+ if (!fade || bmp === fade.old) return;
338
+ const t = Math.min(1, (performance.now() - fade.t0) / FADE_MS);
339
+ const e = t * (2 - t); // ease-out
340
+ g.globalAlpha = 1 - e;
341
+ g.filter = `blur(${(2 * e).toFixed(2)}px)`; // two scales overlap: blur the old one (MV-17)
342
+ paint(fade.old, true);
343
+ g.globalAlpha = 1; g.filter = 'none';
344
+ }
345
+ function paint(bmp, over = false) {
318
346
  g.imageSmoothingQuality = 'high';
319
347
  // never stretch: the frame is view.w CSS px wide; a frame from a size in flight keeps its aspect.
320
348
  // scaled: the whole frame inside the box, by both sides (a taller frame never spills off the bottom)
321
349
  const k = c.width / (stage.clientWidth || 1);
322
- let s = ((view.w || stage.clientWidth) * zs() * k) / bmp.width;
323
- if ((scaled() || fixed) && view.h) s = Math.min(s, (view.h * zs() * k) / bmp.height);
324
- const dw = bmp.width * s, dh = bmp.height * s, dx = ox() * k, dy = oy() * k;
350
+ // a hub pane that grew (Grid to Focus): the last frame fills the new width until the page answers, never small in a dark box
351
+ // (zoomed may still be set: the new size goes out 150 ms later)
352
+ const grew = embed && !tile && !fixed && view.w > 0 && view.w < stage.clientWidth;
353
+ let s = grew ? (stage.clientWidth * k) / bmp.width : ((view.w || stage.clientWidth) * zs() * k) / bmp.width;
354
+ if (!grew && (scaled() || fixed) && view.h) s = Math.min(s, (view.h * zs() * k) / bmp.height);
355
+ const dw = bmp.width * s, dh = bmp.height * s, dx = grew ? 0 : ox() * k, dy = grew ? 0 : oy() * k;
325
356
  const gap = dx > 0 || dy > 0 || dw < c.width || dh < c.height;
326
- if (gap) g.clearRect(0, 0, c.width, c.height);
357
+ if (gap && !over) g.clearRect(0, 0, c.width, c.height);
327
358
  g.drawImage(bmp, dx, dy, dw, dh);
328
- if (gap && !scaled() && !fixed) edgeFill(dw, dh);
359
+ if (gap && !over && (grew || (!scaled() && !fixed))) edgeFill(dw, dh);
329
360
  }
330
361
 
331
362
  // a sized page short of the stage = resize in flight: the gap takes the page's corner color, not the dark stage
@@ -359,7 +390,8 @@ function pageOut() {
359
390
  // before the hub's embed the bars are a full viewer's: the pane would size twice
360
391
  if (!embed || !placed || !view.w || !view.h) return;
361
392
  const chrome = Math.max(0, $('web').clientHeight - stage.clientHeight);
362
- const m = { t: 'page', w: view.w, h: view.h, fixed, chrome };
393
+ // bare: the chrome is a tile's; the hub keeps one per look
394
+ const m = { t: 'page', w: view.w, h: view.h, fixed, chrome, bare: inPane };
363
395
  const j = JSON.stringify(m);
364
396
  if (j !== pageSent) { pageSent = j; hub(m); }
365
397
  }
@@ -423,6 +455,7 @@ function msg(m) {
423
455
  case 'hello':
424
456
  view = m.view; fixed = !!m.fixed; document.documentElement.classList.toggle('fixed', fixed); canWindow = !!m.window; $('win').hidden = !canWindow;
425
457
  if (m.readOnly) watchOnly();
458
+ else if (embed) $('rw').hidden = false;
426
459
  fitOverlay();
427
460
  pageOut();
428
461
  needs(m.needs);
@@ -461,6 +494,7 @@ function watchOnly() {
461
494
  function ended() {
462
495
  document.body.classList.add('ended');
463
496
  signingAs(null); accounts(null);
497
+ $('rw').hidden = true;
464
498
  for (const b of document.querySelectorAll('#nav button, #newtab, .tab .x')) b.disabled = true;
465
499
  urlEl.disabled = true;
466
500
  }
package/dist/llms.txt CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  > Signed-in browser and site-API automation for agents: stored logins, official APIs behind one facade, and a journaled browser whose acts compile into workflows.
4
4
 
5
- Version 0.8.40. Every command takes `--help --json`; `autobrowse list <words> --json` finds a route, flow or workflow. Errors are one JSON shape: `{code, message, hint, retryable, outcome?, artifact?}`.
5
+ Version 0.8.41. Every command takes `--help --json`; `autobrowse list <words> --json` finds a route, flow or workflow. Errors are one JSON shape: `{code, message, hint, retryable, outcome?, artifact?}`.
6
6
 
7
7
  ## Skill
8
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@william_jin/autobrowse",
3
- "version": "0.8.40",
3
+ "version": "0.8.41",
4
4
  "description": "Browser and account automation: recorded flows where no API exists, official API shapes where one does, a person in the loop for money, accounts and consent.",
5
5
  "repository": {
6
6
  "type": "git",