screengraft 0.61.0 → 0.62.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "screengraft",
3
- "version": "0.61.0",
3
+ "version": "0.62.0",
4
4
  "description": "Put a UI screenshot or screen recording onto a photographed device screen with the perspective exactly right \u2014 a homography you confirm by hand, not a generative guess.",
5
5
  "keywords": [
6
6
  "mockup",
@@ -5,7 +5,7 @@ description: Injects a UI screenshot OR a screen recording onto a photographed d
5
5
 
6
6
  # Inject a screenshot onto a photographed device
7
7
 
8
- **What ships (v0.61):** a local browser UI (`scripts/ui.py`) that walks the designer through the whole job — pick the photo and the screen source, which may be an image **or a video** (the images you have used before, drag-drop, browse, path, or a **Figma frame link**), auto-detect the screen as a starting position — and when detection cannot tell which region is a screen, **Point at screen**: one click inside it and the detector uses that point — or, if this photograph has been fitted before, **the fit it was saved with comes back** as the starting position instead of a detection, recognised by the photo's own pixels so a rename or a drag-drop still match — and every save also writes a **portable `.fit.json` beside the mockup** that can be dropped back onto the page later, which is how a fit survives a re-export, another machine, or someone else's hands — then **match the four edges** (drag an edge's middle to slide it, near an end to pivot; corners still draggable) with canvas navigation that follows the usual conventions — **hold ⌘ and scroll to zoom to the pointer, hold space and drag to pan** — and a rectified strip loupe. The fit and the composite sit **side by side and always have** — the result pane re-renders as you drag, which is how a corner gets judged, so it is the layout rather than a mode you can switch off. Then an on-by-default realism pass that colour-matches the source to the photo's light, **Save** (or **Render**, for a video) into the project folder (`--out-dir`), and a **Send to Claude** button that reaches you through the plugin's own MCP server. The UI is a hand port of the project's Figma design file — dark only.
8
+ **What ships (v0.62):** a local browser UI (`scripts/ui.py`) that walks the designer through the whole job — pick the photo and the screen source, which may be an image **or a video** (the images you have used before, drag-drop, browse, path, or a **Figma frame link**), auto-detect the screen as a starting position — and when detection cannot tell which region is a screen, **Point at screen**: one click inside it and the detector uses that point — or, if this photograph has been fitted before, **the fit it was saved with comes back** as the starting position instead of a detection, recognised by the photo's own pixels so a rename or a drag-drop still match — and every save also writes a **portable `.fit.json` beside the mockup** that can be dropped back onto the page later, which is how a fit survives a re-export, another machine, or someone else's hands — then **match the four edges** (drag an edge's middle to slide it, near an end to pivot; corners still draggable) with canvas navigation that follows the usual conventions — **hold ⌘ and scroll to zoom to the pointer, hold space and drag to pan** — and a rectified strip loupe. The fit and the composite sit **side by side and always have** — the result pane re-renders as you drag, which is how a corner gets judged, so it is the layout rather than a mode you can switch off. Then an on-by-default realism pass that colour-matches the source to the photo's light, **Save** (or **Render**, for a video) into the project folder (`--out-dir`), and a **Send to Claude** button that reaches you through the plugin's own MCP server. The UI is a hand port of the project's Figma design file — dark only.
9
9
 
10
10
  The geometry is exact (`warp.py`); the detection is advisory (`detect.py`) and the human corrects it. **When a detection is wrong and you want to know why**, ask for the candidate list: `POST /api/detect {"trace": true}` writes `<session>/candidates.json`, or run `python3 scripts/detect.py --photo P --out-corners /tmp/c.json --trace /tmp/t.json` (add `--click X,Y`). Every candidate quad is in there with its score and whether it was accepted, rejected, never reached, or filtered out by the click — which is what separates "the screen was never proposed" from "it was proposed and something else won".
11
11
 
package/ui/index.html CHANGED
@@ -39,6 +39,8 @@
39
39
  /* surface/float is a real token (#26262b, the chip hover surface). The
40
40
  canvas overlay is a separate thing and gets its own name. */
41
41
  --float:#26262b;
42
+ /* --float at 86%: the popover's glass, over a background blur. */
43
+ --float-glass:rgba(38,38,43,.86);
42
44
  --overlay:rgba(17,17,18,.98);
43
45
  --ink:#e9ecf1; --mute:#8f939a; --faint:#8f939ab2;
44
46
  --line:#1d1e20; --edge:#3a3b41; --edge-mid:#494a50; --edge-hi:#6d6f79;
@@ -1006,8 +1008,13 @@
1006
1008
  opacity:0;visibility:hidden;
1007
1009
  transition:opacity var(--t-pop), visibility 0s linear var(--t-pop)}
1008
1010
  .scrim.on{opacity:1;visibility:visible;transition:opacity var(--t-pop), visibility 0s}
1011
+ /* surface/float at 86% over a background blur. Figma's blur radius is
1012
+ about twice CSS's -- a Figma background blur of 10 is blur(5px) here
1013
+ (14 Sep 2026, on request). Enough shows through to read as glass; the
1014
+ stroke stays a hairline. */
1009
1015
  .pop{position:fixed;z-index:51;width:640px;max-width:calc(100vw - 24px);
1010
- max-height:78vh;overflow:auto;background:var(--float);border:1px solid var(--edge);
1016
+ max-height:78vh;overflow:auto;background:var(--float-glass);border:var(--bw) solid var(--edge);
1017
+ backdrop-filter:blur(5px);-webkit-backdrop-filter:blur(5px);
1011
1018
  border-radius:var(--r-lg);box-shadow:var(--shadow), var(--hi);padding:16px;
1012
1019
  opacity:0;visibility:hidden;transform:translateY(6px) scale(.985);
1013
1020
  transform-origin:50% 0;
@@ -1047,11 +1054,23 @@
1047
1054
  .pv{border-radius:var(--r-md);background:var(--sunk);min-height:0;
1048
1055
  display:grid;place-items:center;overflow:hidden}
1049
1056
  .pv img{max-width:100%;max-height:300px;object-fit:contain;display:block}
1050
- .drop{border:var(--bw) dashed var(--edge);border-radius:var(--r-md);padding:30px 14px;text-align:center;
1057
+ /* The drop zone's dashed rule is drawn, not bordered: CSS `dashed` fixes the
1058
+ dash at ~3× the stroke and cannot be tuned. A masked pseudo-element paints
1059
+ a token colour through an SVG rounded rect with a 5px dash / 4px gap
1060
+ (2 longer / 1 longer than the browser's, on request, 14 Sep 2026) and a
1061
+ 1px stroke centred on the box edge, so half a pixel shows inside -- the
1062
+ same hairline weight as every other stroke -- in the lighter edge tone. */
1063
+ .drop{position:relative;border:0;border-radius:var(--r-md);padding:30px 14px;text-align:center;
1051
1064
  color:var(--mute);cursor:pointer;margin-top:12px;font-size:12px;
1052
1065
  transition:var(--t-all)}
1053
- .drop:hover{border-color:var(--edge-hi);color:var(--ink)}
1054
- .drop.over{border-color:var(--acc);color:var(--ink);background:var(--acc-soft)}
1066
+ .drop::before{content:"";position:absolute;inset:0;border-radius:inherit;pointer-events:none;
1067
+ background:var(--edge-mid);transition:background-color var(--t);
1068
+ -webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='100%25' height='100%25' rx='8' fill='none' stroke='%23000' stroke-width='1' stroke-dasharray='5 4'/%3E%3C/svg%3E") 0 0/100% 100% no-repeat;
1069
+ mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='100%25' height='100%25' rx='8' fill='none' stroke='%23000' stroke-width='1' stroke-dasharray='5 4'/%3E%3C/svg%3E") 0 0/100% 100% no-repeat}
1070
+ .drop:hover{color:var(--ink)}
1071
+ .drop:hover::before{background:var(--edge-hi)}
1072
+ .drop.over{color:var(--ink);background:var(--acc-soft)}
1073
+ .drop.over::before{background:var(--acc-stroke)}
1055
1074
  .sm{font-size:12px}
1056
1075
  code{font:12px ui-monospace,Menlo,monospace;background:var(--sunk);padding:2px 6px;
1057
1076
  border-radius:var(--r-sm);box-shadow:inset 0 0 0 1px var(--line)}
@@ -1850,8 +1869,11 @@ for (const [n, role] of [[1,'photo'],[2,'screenshot']]){
1850
1869
  // popover. Same upload path as the popover's drop zone.
1851
1870
  const chip = $('#chip'+n);
1852
1871
  chip.ondragover = e => { if ([...(e.dataTransfer?.items || [])].some(i => i.kind === 'file')) { e.preventDefault(); chip.classList.add('over'); } };
1853
- chip.ondragleave = () => chip.classList.remove('over');
1854
- chip.ondrop = e => { e.preventDefault(); chip.classList.remove('over'); const f = e.dataTransfer.files[0]; if (f) upload(role, f); };
1872
+ // Leaving with a drag only un-lights the chip if its popover is not the
1873
+ // reason it is lit.
1874
+ const popOpen = () => $('#pop'+n).classList.contains('on');
1875
+ chip.ondragleave = () => { if (!popOpen()) chip.classList.remove('over'); };
1876
+ chip.ondrop = e => { e.preventDefault(); if (!popOpen()) chip.classList.remove('over'); const f = e.dataTransfer.files[0]; if (f) upload(role, f); };
1855
1877
  }
1856
1878
  /* One popover mechanic for every popover: anchor it under whatever opened it,
1857
1879
  clamped into the viewport. The pickers and the preview both use it. */
@@ -1862,10 +1884,16 @@ function openPopAt(pop, anchor){
1862
1884
  pop.style.left = Math.max(12, Math.min(window.innerWidth - w - 12, anchor.left)) + 'px';
1863
1885
  pop.style.top = (anchor.bottom + 8) + 'px';
1864
1886
  }
1865
- function openPop(n){ openPopAt($('#pop'+n), $('#chip'+n).getBoundingClientRect()); }
1887
+ // The chip whose popover is open wears the Input chip's ACTIVE state (the
1888
+ // same one a file dragged over it shows): the popover is about that chip.
1889
+ function openPop(n){
1890
+ openPopAt($('#pop'+n), $('#chip'+n).getBoundingClientRect());
1891
+ $('#chip'+n).classList.add('over');
1892
+ }
1866
1893
  function closePop(){
1867
1894
  document.querySelectorAll('.pop').forEach(p=>p.classList.remove('on'));
1868
1895
  $('#scrim').classList.remove('on');
1896
+ document.querySelectorAll('.inputchip.over').forEach(c => c.classList.remove('over'));
1869
1897
  }
1870
1898
  $('#scrim').onclick = closePop;
1871
1899
 
@@ -3078,10 +3106,22 @@ function swingText(mode){
3078
3106
  the strip (H / 2·stripHalf, so the ± buttons work here too), centred on the
3079
3107
  corner, unrotated, with both edges drawn through it and the ring at the
3080
3108
  centre. Requested 13 Sep 2026; edges keep the strip as it is. */
3109
+ // The corner view's own scale. A corner is an ARC, not a point: it starts a
3110
+ // radius away from where the two edges would meet, on each edge. At the edge
3111
+ // strip's magnification (±14px) a rounded corner showed only the bezel's
3112
+ // blank curve and neither edge, so there was nothing to judge (14 Sep 2026).
3113
+ // The window covers 2.5 radii on each side -- the whole arc plus enough straight
3114
+ // edge to see it land -- never tighter than the strip. The radius in photo px
3115
+ // is the radius fraction (of the screenshot's width) times the quad's top edge.
3116
+ function cornerHalf(){
3117
+ const C = st.corners; if (!C) return stripHalf;
3118
+ const rPhoto = (typeof radiusValue === 'function' ? radiusValue() : 0) * vlen(sub(C[1], C[0]));
3119
+ return Math.max(stripHalf, 1.25 * rPhoto, 24);
3120
+ }
3081
3121
  function paintCorner(c, W, H, i){
3082
3122
  c.setTransform(1,0,0,1,0,0);
3083
3123
  c.fillStyle = '#0c0c0b'; c.fillRect(0,0,W,H);
3084
- const P = st.corners[i], M = H / (2*stripHalf);
3124
+ const P = st.corners[i], M = H / (2*cornerHalf());
3085
3125
  c.save();
3086
3126
  c.setTransform(M, 0, 0, M, W/2 - P[0]*M, H/2 - P[1]*M);
3087
3127
  c.imageSmoothingEnabled = true;
@@ -3115,7 +3155,7 @@ function drawStrip(){
3115
3155
  }
3116
3156
  if (corner){
3117
3157
  paintCorner(sctx, W, H, a.i);
3118
- $('#stripSt').textContent = `${LBL[a.i]} corner · ${(H/(2*stripHalf)).toFixed(1)}× — where the two edges meet`;
3158
+ $('#stripSt').textContent = `${LBL[a.i]} corner · ${(H/(2*cornerHalf())).toFixed(1)}× — the whole arc, and where each edge lands on it`;
3119
3159
  } else {
3120
3160
  paintStrip(sctx, W, H, a.i, a.mode);
3121
3161
  $('#stripSt').textContent = `${EDGE_LBL[a.i]} edge · ±${stripHalf}px · ${(H/(2*stripHalf)).toFixed(1)}× across the boundary — ${swingText(a.mode)}`;
@@ -3125,7 +3165,7 @@ function drawStrip(){
3125
3165
  if (!has){ fl.classList.remove('on'); return; }
3126
3166
  if (corner){
3127
3167
  paintCorner(fctx, stripF.width, stripF.height, a.i);
3128
- $('#stripFCap').textContent = `${LBL[a.i]} corner · ${(stripF.height/(2*stripHalf)).toFixed(1)}× — where the two edges meet`;
3168
+ $('#stripFCap').textContent = `${LBL[a.i]} corner · ${(stripF.height/(2*cornerHalf())).toFixed(1)}× — the whole arc, and where each edge lands on it`;
3129
3169
  } else {
3130
3170
  paintStrip(fctx, stripF.width, stripF.height, a.i, a.mode);
3131
3171
  $('#stripFCap').textContent = `${EDGE_LBL[a.i]} edge · ±${stripHalf}px — ${swingText(a.mode)}`;