@whzxc/agent-design-gallery 0.10.0 → 0.13.1

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.
Files changed (52) hide show
  1. package/README.md +3 -3
  2. package/package.json +1 -1
  3. package/public/annotations.js +816 -0
  4. package/public/app.js +245 -12
  5. package/public/assets.js +4 -13
  6. package/public/frame-identity.js +223 -0
  7. package/public/icons.js +1 -0
  8. package/public/index.html +3 -0
  9. package/public/selection.js +1 -1
  10. package/public/style.css +72 -2
  11. package/src/annotations.mjs +238 -0
  12. package/src/cli-output.mjs +25 -2
  13. package/src/cli.mjs +46 -7
  14. package/src/http.mjs +2 -1
  15. package/src/hub/instances.mjs +1 -1
  16. package/src/hub/registry.mjs +1 -1
  17. package/src/hub.mjs +2 -2
  18. package/src/server.mjs +59 -11
  19. package/src/service.mjs +1 -1
  20. package/src/toolkit/arch-overlay.mjs +1 -1
  21. package/src/toolkit/asset-rules.mjs +42 -3
  22. package/src/toolkit/build-store.mjs +1 -1
  23. package/src/toolkit/build-worker.mjs +1 -1
  24. package/src/toolkit/build.mjs +27 -11
  25. package/src/toolkit/commands.mjs +60 -8
  26. package/src/toolkit/config.mjs +2 -1
  27. package/src/toolkit/diff.mjs +4 -1
  28. package/src/toolkit/document.mjs +6 -6
  29. package/src/toolkit/frame-document.mjs +1 -1
  30. package/src/toolkit/frame-facets.mjs +167 -0
  31. package/src/toolkit/frame-identity.mjs +100 -0
  32. package/src/toolkit/frame-observation.mjs +147 -0
  33. package/src/toolkit/frame-primitives.mjs +85 -0
  34. package/src/toolkit/html.mjs +1 -0
  35. package/src/toolkit/impact-inputs.mjs +2 -21
  36. package/src/toolkit/impact.mjs +3 -24
  37. package/src/toolkit/input-generation.mjs +51 -0
  38. package/src/toolkit/inspect-encoding.mjs +459 -0
  39. package/src/toolkit/inspect-observation.mjs +56 -0
  40. package/src/toolkit/inspect-output.mjs +169 -0
  41. package/src/toolkit/inspect-styles.mjs +34 -0
  42. package/src/toolkit/inspect.d.ts +118 -0
  43. package/src/toolkit/inspect.mjs +125 -0
  44. package/src/toolkit/owner-observation.mjs +23 -189
  45. package/src/toolkit/owner-search.mjs +2 -2
  46. package/src/toolkit/owner.mjs +33 -4
  47. package/src/toolkit/part-diff.mjs +2 -0
  48. package/src/toolkit/part-snapshot.mjs +15 -23
  49. package/src/toolkit/project-index.mjs +22 -5
  50. package/src/toolkit/project.mjs +52 -6
  51. package/src/toolkit/runtime.d.ts +7 -5
  52. package/src/toolkit/runtime.mjs +20 -7
package/public/app.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { createAnnotations, createContextMenu, formatElementReference, READABLE_ANNOTATION_SCALE } from './annotations.js';
1
2
  import { initSwitcher, updateSwitcherLabels } from './switcher.js';
2
3
  import { dataFetch, keyURL, isUnauthorized } from './auth.js';
3
4
  import { Labels } from "./labels.js";
@@ -306,6 +307,9 @@ function syncSelectionURL() {
306
307
  const url = viewURL(location.href, initializedScope, target, { isolated: queryView, onlyFrame });
307
308
  if (url.href !== location.href) window.history.replaceState(window.history.state, '', url);
308
309
  }
310
+ function elementOwner(element, fallbackSource) {
311
+ return element?.owner ?? element?.owners?.at(-1) ?? { source: fallbackSource, export: null };
312
+ }
309
313
  function restoreSelection(target) {
310
314
  if (!target) return;
311
315
  const source = manifest.assets.find(a => a.path === target.path);
@@ -317,8 +321,9 @@ function restoreSelection(target) {
317
321
  selectedForm = form?.id ?? null;
318
322
  const element = target.element && form?.elements?.find(e => e.id === target.element.id);
319
323
  const owner = target.element?.owner;
320
- if (element && (!owner || element.owners.some(o => o.source === owner.source && o.export === owner.export)))
321
- selectedElement = {...element, owner:owner ?? element.owners.at(-1)};
324
+ const resolvedOwner = element ? elementOwner(element, item.path) : null;
325
+ if (element && (!owner || (resolvedOwner.source === owner.source && resolvedOwner.export === owner.export) || (element.owners ?? []).some(o => o.source === owner.source && o.export === owner.export)))
326
+ selectedElement = {...element, owner:owner ?? resolvedOwner};
322
327
  active = item.group;
323
328
  } else {
324
329
  const group = groups.findIndex(g => g.title === target.group);
@@ -634,21 +639,22 @@ function selection() {
634
639
  $('#back').disabled = !history.length && !onlyFrame;
635
640
  const host=currentItem(), part=host?.parts.find(p=>p.id===selectedForm);
636
641
  const owner=selectedElement?.owner;
637
- const a=owner ? manifest?.assets.find(a=>a.path===owner.source) ?? {path:owner.source,parts:[]} : host;
642
+ const hasExport=!!owner?.export;
643
+ const a=hasExport ? manifest?.assets.find(a=>a.path===owner.source) ?? manifest?.extraAssets?.find(a=>a.path===owner.source) ?? {path:owner.source,parts:[]} : host;
638
644
  if(a) {
639
- $('#source-name').textContent=owner?.export ?? a.name;$('#source-path').textContent=a.path;
645
+ $('#source-name').textContent=hasExport ? owner.export : a.name;$('#source-path').textContent=a.path;
640
646
  $('#source-path').title=a.path;
641
647
  $('#frame-detail').hidden=!part;
642
648
  $('#frame-name').textContent=part?.name ?? '';
643
649
  const size=selectedElement ?? part;
644
650
  $('#frame-size').textContent=size?`${Math.round(size.width)} × ${Math.round(size.height)}`:'';
645
- $('#forms-heading').textContent=owner?'Frames using this export':a.component?'Forms':'Frames';
646
- const forms=owner?exportFrames(a,owner):a.parts;
651
+ $('#forms-heading').textContent=hasExport?'Frames using this export':a.component?'Forms':'Frames';
652
+ const forms=hasExport?exportFrames(a,owner):a.parts;
647
653
  $('#forms').replaceChildren(...forms.map(p=>{
648
654
  const button=makeRow(a.component?'component':'app-window',p.name,`${Math.round(p.width)} × ${Math.round(p.height)}`);
649
655
  button.classList.add('frame-row');button.title=p.name;
650
656
  button.dataset.frame=p.name;
651
- button.setAttribute('aria-current',String(!owner && selectedForm===p.id));
657
+ button.setAttribute('aria-current',String(!hasExport && selectedForm===p.id));
652
658
  button.onclick=()=>inspectForm(a,p);
653
659
  if (p.note) { const row=document.createElement('div');row.append(button);const note=document.createElement('p');note.textContent=p.note;note.className='frame-note';row.append(note);return row; }
654
660
  return button;
@@ -664,7 +670,7 @@ function selectSource(a) {
664
670
  }
665
671
  function selectFrame(a,p,element=null) {
666
672
  if (!a || !p) return;
667
- remember();selected=a.path;selectedId=a.id;selectedForm=p.id;active=a.group;selectedElement=element?{...element,owner:element.owners.at(-1)}:null;
673
+ remember();selected=a.path;selectedId=a.id;selectedForm=p.id;active=a.group;selectedElement=element?{...element,owner:elementOwner(element,a.path)}:null;
668
674
  expanded.add(active);selection();
669
675
  }
670
676
  function clearSelection() { selected=null;selectedId=null;selectedForm=null;selectedElement=null;inspection=null;selection(); }
@@ -674,7 +680,88 @@ function selectedBox() {
674
680
  const box=frameBox(a,p);
675
681
  return selectedElement?{...selectedElement,x:box.x+selectedElement.x,y:box.y+selectedElement.y}:box;
676
682
  }
683
+ function copyToClipboard(text) {
684
+ navigator.clipboard.writeText(text).catch(e => error(e.message));
685
+ }
686
+ function visibleFrames() {
687
+ const displayed = manifest?.renderTheme === effectiveTheme ? (inspection ? [inspection] : assets) : [];
688
+ const list = [];
689
+ for (const a of displayed) {
690
+ if (!visible(a, 320)) continue;
691
+ const parts = a.component ? a.parts : a.parts.filter(p => p.id === a.shown[0]?.id);
692
+ for (const part of parts) {
693
+ const worldBox = frameBox(a, part);
694
+ const box = {
695
+ x: view.x + worldBox.x * view.scale,
696
+ y: view.y + worldBox.y * view.scale,
697
+ width: worldBox.width * view.scale,
698
+ height: worldBox.height * view.scale,
699
+ };
700
+ if (box.x + box.width + 280 < 0 || box.x > width + 40 || box.y + box.height + 40 < 0 || box.y > height + 40) continue;
701
+ list.push({ asset: a, part, source: a.path, frame: part.name, world: worldBox, box });
702
+ }
703
+ }
704
+ return list;
705
+ }
706
+ function locateNoteOnCanvas(row, moveCamera = false) {
707
+ const run = () => {
708
+ const sourceAsset = manifest?.assets.find(a => a.path === row.source);
709
+ const part = sourceAsset?.parts.find(p => p.name === row.frame);
710
+ const item = assets.find(a => a.path === row.source && (a.component || !part || a.shown[0]?.id === part.id));
711
+ if (!item || !part) return false;
712
+ const el = row.element ? (part.elements ?? []).find(e => e.id === row.element.id) : null;
713
+ inspection = null;
714
+ selectFrame(item, part, el);
715
+ if (moveCamera) {
716
+ frame(frameBox(item, part), 48);
717
+ if (view.scale < READABLE_ANNOTATION_SCALE) zoom(READABLE_ANNOTATION_SCALE);
718
+ }
719
+ return true;
720
+ };
721
+ if (!run() && moveCamera && initializedScope !== 'all') {
722
+ changeScope('all');
723
+ pendingNavigation = () => { run(); annotationUI.render(); };
724
+ }
725
+ }
726
+ const contextMenu = createContextMenu($('#context-menu'), {
727
+ viewport,
728
+ onOverlayChange: () => { hideTooltip(); requestDraw(true, false); },
729
+ });
730
+ const annotationUI = createAnnotations({
731
+ viewport,
732
+ panel: $('#annotations-panel'),
733
+ toggleButton: $('#annotate'),
734
+ contextMenu,
735
+ getState: () => {
736
+ const a = currentItem(), p = a?.parts.find(part => part.id === selectedForm);
737
+ return {
738
+ opened: Boolean(manifest?.directory) && !tokenManifest,
739
+ projectRoot: manifest?.projectRoot ?? manifest?.directory ?? null,
740
+ sourcePrefix: manifest?.sourcePrefix ?? '',
741
+ revision: manifest?.revision ?? 0,
742
+ scope: initializedScope ?? manifest?.scope ?? 'all',
743
+ loading: Boolean(manifest?.loading),
744
+ view,
745
+ moving,
746
+ manifestAssets: manifest?.assets ?? [],
747
+ selectedFrame: a && p ? { asset: a, part: p, source: a.path, frame: p.name } : null,
748
+ visibleFrames: visibleFrames(),
749
+ };
750
+ },
751
+ hitFrameAt: (worldX, worldY) => {
752
+ const hit = hitSelection(inspection ? [inspection] : assets, worldX, worldY);
753
+ if (!hit?.part) return null;
754
+ return { ...hit, frameBox: frameBox(hit.asset, hit.part) };
755
+ },
756
+ navigateToNote: row => locateNoteOnCanvas(row, true),
757
+ selectNoteTarget: row => locateNoteOnCanvas(row, false),
758
+ inspectFrame: (a, p, minScale) => inspectForm(a, p, minScale),
759
+ onChromeChange: () => { updateChrome(); requestDraw(true, false); },
760
+ copyText: copyToClipboard,
761
+ fail: e => error(e.message ?? String(e)),
762
+ });
677
763
  function updateOutlines() {
764
+ annotationUI.render();
678
765
  const hover=hoveredElement,origin=hover?.part?frameBox(hover.asset,hover.part):null;
679
766
  const hoverBox=hover?.element?{...hover.element,x:origin.x+hover.element.x,y:origin.y+hover.element.y}:null;
680
767
  for (const [id,box] of [['selection-outline',selectedBox()],['hover-outline',hoverBox]]) {
@@ -710,11 +797,17 @@ function focusAsset(a) {
710
797
  selectSource(a);
711
798
  frame(a,24);
712
799
  }
713
- function inspectForm(a,p) {
800
+ function inspectForm(a,p,minScale=0) {
714
801
  if (!a || !p) return;
715
802
  const item=assets.find(item=>item.path===a.path && (a.component || item.shown[0].id===p.id));
716
- if (!item) return;
803
+ if (!item) {
804
+ if (initializedScope !== 'all') {
805
+ changeScope(`asset:${a.path}`, { target: { path: a.path, form: p.name } });
806
+ }
807
+ return;
808
+ }
717
809
  inspection=null;selectFrame(item,p);frame(frameBox(item,p),24);
810
+ if (minScale && view.scale < minScale) zoom(minScale);
718
811
  }
719
812
 
720
813
  function zoom(scale, x = cameraArea().x + cameraArea().width / 2, y = cameraArea().y + cameraArea().height / 2) {
@@ -1106,6 +1199,7 @@ viewport.addEventListener(
1106
1199
  );
1107
1200
  viewport.addEventListener("pointerdown", (e) => {
1108
1201
  if (e.button !== 0 && e.button !== 1) return;
1202
+ if(e.target.closest('.annotation-layer'))return;
1109
1203
  e.preventDefault();
1110
1204
  viewport.focus({ preventScroll: true });
1111
1205
  pointers.set(e.pointerId, { x: e.clientX, y: e.clientY });
@@ -1158,6 +1252,7 @@ function up(e) {
1158
1252
  x = (e.clientX - rect.left - view.x) / view.scale,
1159
1253
  y = (e.clientY - rect.top - view.y) / view.scale;
1160
1254
  const hit=hitSelection(inspection?[inspection]:assets,x,y);
1255
+ if(annotationUI.active()) { annotationUI.click(x,y); return; }
1161
1256
  if(hit?.part) selectFrame(hit.asset,hit.part,hit.element);
1162
1257
  else if(hit) selectSource(hit.asset);
1163
1258
  else clearSelection();
@@ -1168,6 +1263,140 @@ function up(e) {
1168
1263
  }
1169
1264
  for (const event of ["pointerup", "pointercancel", "lostpointercapture"])
1170
1265
  viewport.addEventListener(event, up);
1266
+ function openSelectionContextMenu({ worldPoint = null, screenX, screenY, returnFocus = viewport }) {
1267
+ const a = currentItem(), p = a?.parts.find(part => part.id === selectedForm), el = selectedElement;
1268
+ if (a && p && el) {
1269
+ const fb = frameBox(a, p);
1270
+ const owner = elementOwner(el, a.path);
1271
+ const fx = worldPoint ? Math.max(0, Math.min(1, (worldPoint.x - fb.x) / fb.width)) : (p.width > 0 ? Math.max(0, Math.min(1, (el.x + el.width / 2) / p.width)) : 0.5);
1272
+ const fy = worldPoint ? Math.max(0, Math.min(1, (worldPoint.y - fb.y) / fb.height)) : (p.height > 0 ? Math.max(0, Math.min(1, (el.y + el.height / 2) / p.height)) : 0.5);
1273
+ const ex = worldPoint && el.width > 0 ? Math.max(0, Math.min(1, (worldPoint.x - (fb.x + el.x)) / el.width)) : 0.5;
1274
+ const ey = worldPoint && el.height > 0 ? Math.max(0, Math.min(1, (worldPoint.y - (fb.y + el.y)) / el.height)) : 0.5;
1275
+ contextMenu.open([
1276
+ {
1277
+ label: 'Annotate here',
1278
+ action: () => annotationUI.annotateAt({
1279
+ source: a.path,
1280
+ frame: p.name,
1281
+ fx,
1282
+ fy,
1283
+ element: { id: el.id, owner, x: ex, y: ey },
1284
+ returnFocus,
1285
+ }),
1286
+ },
1287
+ {
1288
+ label: 'Copy element reference',
1289
+ action: () => copyToClipboard(formatElementReference({
1290
+ sourcePrefix: manifest?.sourcePrefix ?? '',
1291
+ source: a.path,
1292
+ owner,
1293
+ frame: p.name,
1294
+ elementId: el.id,
1295
+ })),
1296
+ },
1297
+ {
1298
+ label: 'Show in Inspector',
1299
+ action: () => {
1300
+ inspector = true;
1301
+ selection();
1302
+ $('#copy-path')?.focus({ preventScroll: true });
1303
+ },
1304
+ },
1305
+ {
1306
+ label: 'Select owning component',
1307
+ disabled: !owner?.export,
1308
+ action: async () => {
1309
+ inspector = true;
1310
+ if (owner?.source && !manifest?.assets.some(item => item.path === owner.source) && !manifest?.extraAssets?.some(item => item.path === owner.source)) {
1311
+ try {
1312
+ const loaded = await sourceFor({ path: owner.source, version: manifest?.revision ?? 0 }, effectiveTheme);
1313
+ if (manifest) manifest.extraAssets = [...(manifest.extraAssets ?? []), loaded];
1314
+ } catch {}
1315
+ }
1316
+ selection();
1317
+ $('#forms-heading')?.scrollIntoView({ block: 'nearest' });
1318
+ ($('#forms button') ?? $('#copy-path'))?.focus({ preventScroll: true });
1319
+ },
1320
+ },
1321
+ {
1322
+ label: 'Show usages',
1323
+ action: () => {
1324
+ inspector = true;
1325
+ selection();
1326
+ $('#used-by-heading')?.scrollIntoView({ block: 'nearest' });
1327
+ ($('#used-by button') ?? $('#copy-path'))?.focus({ preventScroll: true });
1328
+ },
1329
+ },
1330
+ ], { x: screenX, y: screenY, returnFocus });
1331
+ return;
1332
+ }
1333
+ if (a && p) {
1334
+ const fb = frameBox(a, p);
1335
+ const fx = worldPoint ? Math.max(0, Math.min(1, (worldPoint.x - fb.x) / fb.width)) : 0.5;
1336
+ const fy = worldPoint ? Math.max(0, Math.min(1, (worldPoint.y - fb.y) / fb.height)) : 0.5;
1337
+ contextMenu.open([
1338
+ {
1339
+ label: 'Annotate frame',
1340
+ action: () => annotationUI.annotateAt({ source: a.path, frame: p.name, fx, fy, element: null, returnFocus }),
1341
+ },
1342
+ { label: 'Copy frame name', action: () => copyToClipboard(p.name) },
1343
+ { label: 'Copy source path', action: () => copyToClipboard(a.path) },
1344
+ {
1345
+ label: 'Show in Inspector',
1346
+ action: () => {
1347
+ inspector = true;
1348
+ selection();
1349
+ $('#copy-frame')?.focus({ preventScroll: true });
1350
+ },
1351
+ },
1352
+ { label: 'Fit frame', action: () => frame(frameBox(a, p), 24) },
1353
+ {
1354
+ label: 'Copy open annotations as agent prompt',
1355
+ disabled: annotationUI.countOpenForFrame(a.path, p.name) === 0,
1356
+ action: () => annotationUI.copyOpenForFrame(a.path, p.name),
1357
+ },
1358
+ ], { x: screenX, y: screenY, returnFocus });
1359
+ return;
1360
+ }
1361
+ contextMenu.open([
1362
+ { label: 'Fit all', action: () => fit() },
1363
+ { label: 'Arrange current group', action: () => $('#arrange').click() },
1364
+ ], { x: screenX, y: screenY, returnFocus });
1365
+ }
1366
+ viewport.addEventListener('contextmenu', e => {
1367
+ if (tokenManifest || !manifest?.directory) return;
1368
+ if (e.target.closest('.annotation-point, .annotation-card')) return;
1369
+ e.preventDefault();
1370
+ viewport.focus({ preventScroll: true });
1371
+ const rect = viewport.getBoundingClientRect();
1372
+ const wx = (e.clientX - rect.left - view.x) / view.scale;
1373
+ const wy = (e.clientY - rect.top - view.y) / view.scale;
1374
+ const hit = hitSelection(inspection ? [inspection] : assets, wx, wy);
1375
+ if (hit?.part) selectFrame(hit.asset, hit.part, hit.element);
1376
+ else if (hit) selectSource(hit.asset);
1377
+ else clearSelection();
1378
+ openSelectionContextMenu({ worldPoint: { x: wx, y: wy }, screenX: e.clientX, screenY: e.clientY, returnFocus: viewport });
1379
+ });
1380
+ document.addEventListener('keydown', e => {
1381
+ if (!(e.key === 'ContextMenu' || (e.key === 'F10' && e.shiftKey))) return;
1382
+ if (tokenManifest || !manifest?.directory || document.querySelector('dialog[open]')) return;
1383
+ e.preventDefault();
1384
+ const activeEl = document.activeElement;
1385
+ const noteEl = activeEl?.closest?.('[data-annotation-id]');
1386
+ if (noteEl) {
1387
+ const row = annotationUI.getRow(noteEl.dataset.annotationId);
1388
+ if (row) {
1389
+ const r = noteEl.getBoundingClientRect();
1390
+ annotationUI.openNoteMenu(row, { x: r.left + r.width / 2, y: r.top + r.height / 2, returnFocus: activeEl });
1391
+ return;
1392
+ }
1393
+ }
1394
+ const box = selectedBox();
1395
+ const vr = viewport.getBoundingClientRect();
1396
+ const sx = box ? vr.left + view.x + (box.x + box.width / 2) * view.scale : vr.left + width / 2;
1397
+ const sy = box ? vr.top + view.y + (box.y + box.height / 2) * view.scale : vr.top + height / 2;
1398
+ openSelectionContextMenu({ worldPoint: null, screenX: sx, screenY: sy, returnFocus: activeEl instanceof HTMLElement ? activeEl : viewport });
1399
+ });
1171
1400
  document.addEventListener("keydown", (e) => {
1172
1401
  if (e.metaKey || e.ctrlKey || e.altKey || e.target.matches("input,textarea,[contenteditable]") || document.querySelector("dialog[open], :popover-open")) return;
1173
1402
  const v = view;
@@ -1347,6 +1576,7 @@ function applyTokenManifest(data) {
1347
1576
  if (url.href !== location.href) window.history.replaceState(window.history.state, '', url);
1348
1577
  }
1349
1578
  updateChrome();
1579
+ annotationUI.render();
1350
1580
  renderNav();
1351
1581
  }
1352
1582
  async function applyManifest(data, force = false) {
@@ -1504,7 +1734,8 @@ async function applyManifest(data, force = false) {
1504
1734
  else if (selectedForm!==null && !p) {selectedForm=null;selectedElement=null}
1505
1735
  else if (selectedElement) {
1506
1736
  const next=p?.elements?.find(e=>e.id===selectedElement.id);
1507
- selectedElement=next?.owners.some(o=>o.source===selectedElement.owner.source && o.export===selectedElement.owner.export)?{...next,owner:selectedElement.owner}:null;
1737
+ const nextOwner=next ? elementOwner(next,a.path) : null;
1738
+ selectedElement=next && ((nextOwner.source===selectedElement.owner.source && nextOwner.export===selectedElement.owner.export) || (next.owners ?? []).some(o=>o.source===selectedElement.owner.source && o.export===selectedElement.owner.export))?{...next,owner:selectedElement.owner}:null;
1508
1739
  }
1509
1740
  }
1510
1741
  if (inspection) {
@@ -1636,6 +1867,7 @@ if ((tokenManifest || manifest) && !isUnauthorized()) {
1636
1867
  events.onmessage = (e) => {
1637
1868
  const data = JSON.parse(e.data);
1638
1869
  if (data.error) error(data.error);
1870
+ else if (data.annotations) annotationUI.refresh().catch(err => error(err.message));
1639
1871
  else void refresh();
1640
1872
  };
1641
1873
  events.onerror = async () => {
@@ -1653,8 +1885,9 @@ document.addEventListener("keydown", (e) => {
1653
1885
  $("#search").focus();
1654
1886
  return;
1655
1887
  }
1656
- if (e.key !== "Escape" || $("#keys").open) return;
1888
+ if (e.key !== "Escape" || document.querySelector("dialog[open]")) return;
1657
1889
  if (document.querySelector(":popover-open")) return;
1890
+ if (annotationUI.cancelMove()) return;
1658
1891
  if (tokenManifest) {
1659
1892
  if ($('#search').value) $('#search-clear').click();
1660
1893
  return;
package/public/assets.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { dataFetch } from './auth.js';
2
+ import { collectViewerElements } from './frame-identity.js';
2
3
  import { blockForAsset, componentWrapWidth, layoutWorld } from "./layout.js";
3
4
  // Measure declared SVG content in an isolated, script-disabled document.
4
5
  export const metadataContext = () => `adaptive-wrap-v1|${navigator.userAgent}|${devicePixelRatio}`;
@@ -313,19 +314,9 @@ async function prepareSource(asset, built, theme, signal) {
313
314
  const styles=new Map(),rects=new Map();
314
315
  const styleFor=node=>{if(!styles.has(node))styles.set(node,frame.contentWindow.getComputedStyle(node));return styles.get(node)};
315
316
  const rectFor=node=>{if(!rects.has(node))rects.set(node,node.getBoundingClientRect());return rects.get(node)};
316
- const elements = [...shell.querySelectorAll('[data-adg-owners]')].flatMap((node,index) => {
317
- const rect = rectFor(node);
318
- let left=Math.max(rect.left,box.left),top=Math.max(rect.top,box.top),right=Math.min(rect.right,box.right),bottom=Math.min(rect.bottom,box.bottom);
319
- for (let parent=node.parentElement;parent && parent!==shell;parent=parent.parentElement) {
320
- const style=styleFor(parent);
321
- if (!/(hidden|clip|auto|scroll)/.test(style.overflowX+' '+style.overflowY)) continue;
322
- const clip=rectFor(parent);
323
- if (/(hidden|clip|auto|scroll)/.test(style.overflowX)) {left=Math.max(left,clip.left);right=Math.min(right,clip.right)}
324
- if (/(hidden|clip|auto|scroll)/.test(style.overflowY)) {top=Math.max(top,clip.top);bottom=Math.min(bottom,clip.bottom)}
325
- }
326
- if (right<=left || bottom<=top || styleFor(node).visibility==='hidden') return [];
327
- return [{id:String(index),owners:JSON.parse(node.dataset.adgOwners),x:left-box.x,y:top-box.y,width:right-left,height:bottom-top}];
328
- });
317
+ const elements = asset.path.endsWith('.tsx')
318
+ ? collectViewerElements(shell, { projectSource: built.projectSource ?? asset.projectSource ?? asset.path, assetPath: asset.path, frame: form.name, styleFor, rectFor, origin: box })
319
+ : [];
329
320
  const content=frame.contentDocument.createElement('div');
330
321
  content.setAttribute('xmlns','http://www.w3.org/1999/xhtml');
331
322
  content.setAttribute('style','font:16px/1.5 var(--font-ui);color:var(--text);');
@@ -0,0 +1,223 @@
1
+ const K = new Uint32Array([
2
+ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
3
+ 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
4
+ 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
5
+ 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
6
+ 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
7
+ 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
8
+ 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
9
+ 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
10
+ ]);
11
+ const encoder = new TextEncoder();
12
+ const W = new Uint32Array(64);
13
+ const rotr = (x, n) => (x >>> n) | (x << (32 - n));
14
+
15
+ export function sha256Hex(value) {
16
+ const bytes = encoder.encode(value);
17
+ const len = bytes.length;
18
+ const total = ((len + 9 + 63) >> 6) << 6;
19
+ const padded = new Uint8Array(total);
20
+ padded.set(bytes);
21
+ padded[len] = 0x80;
22
+ const view = new DataView(padded.buffer);
23
+ view.setUint32(total - 8, Math.floor((len * 8) / 0x100000000), false);
24
+ view.setUint32(total - 4, (len * 8) >>> 0, false);
25
+ let h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a;
26
+ let h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19;
27
+ for (let offset = 0; offset < total; offset += 64) {
28
+ for (let i = 0; i < 16; i++) W[i] = view.getUint32(offset + i * 4, false);
29
+ for (let i = 16; i < 64; i++) {
30
+ const s0 = rotr(W[i - 15], 7) ^ rotr(W[i - 15], 18) ^ (W[i - 15] >>> 3);
31
+ const s1 = rotr(W[i - 2], 17) ^ rotr(W[i - 2], 19) ^ (W[i - 2] >>> 10);
32
+ W[i] = (W[i - 16] + s0 + W[i - 7] + s1) >>> 0;
33
+ }
34
+ let a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7;
35
+ for (let i = 0; i < 64; i++) {
36
+ const S1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
37
+ const ch = (e & f) ^ (~e & g);
38
+ const temp1 = (h + S1 + ch + K[i] + W[i]) >>> 0;
39
+ const S0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);
40
+ const maj = (a & b) ^ (a & c) ^ (b & c);
41
+ const temp2 = (S0 + maj) >>> 0;
42
+ h = g; g = f; f = e; e = (d + temp1) >>> 0;
43
+ d = c; c = b; b = a; a = (temp1 + temp2) >>> 0;
44
+ }
45
+ h0 = (h0 + a) >>> 0; h1 = (h1 + b) >>> 0; h2 = (h2 + c) >>> 0; h3 = (h3 + d) >>> 0;
46
+ h4 = (h4 + e) >>> 0; h5 = (h5 + f) >>> 0; h6 = (h6 + g) >>> 0; h7 = (h7 + h) >>> 0;
47
+ }
48
+ return [h0, h1, h2, h3, h4, h5, h6, h7].map(v => v.toString(16).padStart(8, '0')).join('');
49
+ }
50
+
51
+ export const identityVersion = 1;
52
+ const digest = value => sha256Hex(value).slice(0, 24);
53
+ const normalize = value => value.normalize('NFC').replace(/\p{White_Space}+/gu, ' ').trim();
54
+ const namingAttributes = new Set(['id', 'data-part', 'role', 'aria-label', 'aria-labelledby', 'aria-describedby']);
55
+ const containerRoots = new Set(['div', 'main', 'section', 'article', 'aside', 'header', 'footer', 'nav', 'form']);
56
+
57
+ export function identityNode(node, path, parentPath, owners, styleFor) {
58
+ const attributes = {};
59
+ for (const name of ['id', 'data-part', 'data-adg-id', 'role', 'aria-label', 'aria-labelledby', 'aria-describedby']) {
60
+ if (node.hasAttribute(name)) attributes[name] = node.getAttribute(name);
61
+ }
62
+ const password = node.matches('input[type=password]');
63
+ const directText = password ? '' : [...node.childNodes].filter(n => n.nodeType === 3).map(n => n.data).join('');
64
+ let neutral = false;
65
+ if (!owners.length && !node.hasAttribute('data-adg-id') && !node.hasAttribute('data-adg-keys') &&
66
+ !Object.keys(attributes).length && /^(div|span)$/.test(node.localName) && !directText.trim()) {
67
+ const style = styleFor(node);
68
+ neutral = Boolean(style) && (node.children.length === 1 || style.display === 'contents') &&
69
+ ['block', 'inline', 'contents'].includes(style.display) && style.position === 'static' &&
70
+ style.transform === 'none' && style.overflowX === 'visible' && style.overflowY === 'visible' &&
71
+ style.opacity === '1' && style.backgroundColor === 'rgba(0, 0, 0, 0)' && style.boxShadow === 'none' &&
72
+ ['Top', 'Right', 'Bottom', 'Left'].every(side => parseFloat(style[`margin${side}`]) === 0 && parseFloat(style[`padding${side}`]) === 0 && parseFloat(style[`border${side}Width`]) === 0);
73
+ }
74
+ const native = { button: 'button', a: node.hasAttribute('href') ? 'link' : null, input: node.type === 'checkbox' ? 'checkbox' : node.type === 'radio' ? 'radio' : node.type === 'button' || node.type === 'submit' ? 'button' : 'textbox', select: 'combobox', textarea: 'textbox', h1: 'heading', h2: 'heading', h3: 'heading', h4: 'heading', h5: 'heading', h6: 'heading', img: 'img' };
75
+ const role = node.getAttribute('role') ?? native[node.localName];
76
+ const labelled = node.getAttribute('aria-labelledby')?.split(/\s+/).map(id => node.ownerDocument.getElementById(id)?.textContent ?? '').join(' ');
77
+ const name = normalize(labelled || node.getAttribute('aria-label') || node.getAttribute('alt') || (role === 'textbox' || role === 'combobox' ? Array.from(node.labels ?? []).map(l => l.textContent).join(' ') : role ? node.textContent : '') || '');
78
+ const resource = node.localName === 'svg' && (node.hasAttribute('data-adg-icon') || node.getAttribute('aria-hidden') === 'true' || !node.querySelector('text,foreignObject') && !node.hasAttribute('role'));
79
+ return {
80
+ path, parentPath, tag: node.localName, namespace: node.namespaceURI, attributes, owners, neutral, resource,
81
+ ...(role && name ? { semantic: { role, name } } : {}),
82
+ keys: JSON.parse(node.getAttribute('data-adg-keys') ?? '[]'),
83
+ password,
84
+ directText,
85
+ };
86
+ }
87
+
88
+ export function elementIdentities(nodes, { source, frame }, { hash = digest } = {}) {
89
+ const children = new Map(nodes.map(n => [n.path, []])), byPath = new Map(nodes.map(n => [n.path, n]));
90
+ for (const n of nodes) children.get(n.parentPath)?.push(n);
91
+ const result = new Map(), seen = new Map(), rootScope = JSON.stringify([identityVersion, source, frame]);
92
+ const conflict = message => { throw Object.assign(new Error(message), { code: 'INSPECT_IDENTITY_CONFLICT' }); };
93
+ function describe(node) {
94
+ const attrs = node.attributes ?? {}, owners = node.owners ?? [], keys = node.keys ?? [], anchor = attrs['data-adg-id'];
95
+ let defining = owners, ancestor = byPath.get(node.parentPath);
96
+ while (!defining.length && ancestor) { defining = ancestor.owners ?? []; ancestor = byPath.get(ancestor.parentPath); }
97
+ if (anchor !== undefined && (typeof anchor !== 'string' || !anchor.trim())) conflict('data-adg-id must be a nonempty string.');
98
+ const naming = Object.entries(attrs).filter(([name]) => namingAttributes.has(name)).sort(([a], [b]) => a.localeCompare(b));
99
+ const signature = [node.namespace, node.tag, naming, node.semantic ?? null, node.password ? '' : normalize(node.directText ?? '')];
100
+ const seed = anchor !== undefined ? ['anchor', anchor, owners, ...keys] : keys.length ? ['key', keys, owners] : [node.neutral ? 'wrapper' : 'semantic', signature, defining];
101
+ const boundary = !node.neutral && (anchor !== undefined || keys.length || owners.length || naming.length || node.semantic?.name);
102
+ return { node, signature, seed, defining, candidate: boundary, boundary: false, fixed: anchor !== undefined || keys.length > 0, strict: keys.length > 0 || anchor !== undefined && !owners.length };
103
+ }
104
+ const descriptors = new Map(nodes.map(n => [n.path, describe(n)]));
105
+ function assign(record, scope, ordinal, count, inherited) {
106
+ const duplicate = count > 1, id = `e1_${hash(JSON.stringify([scope, record.seed, ...(!record.strict && duplicate ? [ordinal] : [])]))}`;
107
+ if (seen.has(id)) conflict(`Element identity conflicts at ${source}#${frame}, paths ${seen.get(id)} and ${record.node.path}; use unique anchors or instance keys.`);
108
+ seen.set(id, record.node.path);
109
+ const positional = inherited || !record.strict && duplicate;
110
+ result.set(record.node.path, { path: record.node.path, id, defining: record.defining });
111
+ return { id, positional };
112
+ }
113
+ function resource(root, scope) {
114
+ let slot = 0;
115
+ function visit(node) {
116
+ const r = descriptors.get(node.path), local = slot++;
117
+ const original = r.seed; r.seed = ['resource-slot', local]; assign(r, scope, 0, 1, false); r.seed = original;
118
+ for (const child of children.get(node.path)) visit(child);
119
+ }
120
+ for (const child of children.get(root.path)) visit(child);
121
+ }
122
+ function scope(roots, address, inherited = false) {
123
+ let pool = [];
124
+ function gather(node) { const r = descriptors.get(node.path); pool.push(r); if (!r.boundary && !node.resource) for (const child of children.get(node.path)) gather(child); }
125
+ for (let changed = true; changed;) {
126
+ changed = false; pool = []; roots.forEach(gather);
127
+ const candidates = new Map();
128
+ for (const r of pool) if (r.candidate) { const key = JSON.stringify(r.seed); candidates.set(key, (candidates.get(key) ?? 0) + 1); }
129
+ for (const r of pool) if (r.candidate && !r.boundary && (r.fixed || candidates.get(JSON.stringify(r.seed)) === 1)) { r.boundary = true; changed = true; }
130
+ }
131
+ const groups = new Map();
132
+ for (const r of pool) {
133
+ let parent = byPath.get(r.node.parentPath); while (parent?.neutral) parent = byPath.get(parent.parentPath);
134
+ const key = JSON.stringify([r.seed, ...(r.node.keys?.length ? [parent?.path ?? null] : [])]);
135
+ const peers = groups.get(key) ?? []; peers.push(r); groups.set(key, peers); r.peers = peers;
136
+ }
137
+ const resolved = new Map();
138
+ function resolve(r) {
139
+ if (resolved.has(r.node.path)) return resolved.get(r.node.path);
140
+ let local = address, localPositional = inherited;
141
+ if (r.node.attributes?.['data-adg-id'] !== undefined && !r.node.owners?.length) {
142
+ let owner = byPath.get(r.node.parentPath); while (owner && !owner.owners?.length) owner = byPath.get(owner.parentPath);
143
+ const ownerRecord = pool.find(p => p.node === owner), value = ownerRecord ? resolve(ownerRecord) : null;
144
+ if (value) { local = value.id; localPositional ||= value.positional; }
145
+ }
146
+ if (r.node.keys?.length) {
147
+ let parent = byPath.get(r.node.parentPath); while (parent?.neutral) parent = byPath.get(parent.parentPath);
148
+ const parentRecord = pool.find(p => p.node === parent), parentValue = parentRecord ? resolve(parentRecord) : null;
149
+ local = parentValue?.id ?? result.get(parent?.path)?.id ?? address; localPositional ||= parentValue?.positional ?? false;
150
+ }
151
+ const value = assign(r, local, r.peers.indexOf(r), r.peers.length, localPositional);
152
+ resolved.set(r.node.path, value);
153
+ return value;
154
+ }
155
+ for (const r of pool) resolve(r);
156
+ for (const r of pool) {
157
+ const value = resolved.get(r.node.path);
158
+ if (r.node.resource) resource(r.node, value.id);
159
+ else if (r.boundary) scope(children.get(r.node.path), value.id, value.positional);
160
+ }
161
+ }
162
+ for (const root of nodes.filter(n => !byPath.has(n.parentPath))) {
163
+ const record = descriptors.get(root.path), seed = record.seed; record.seed = ['frame-root'];
164
+ const value = assign(record, rootScope, 0, 1, false); record.seed = seed;
165
+ if (root.resource) resource(root, value.id); else scope(children.get(root.path), value.id);
166
+ }
167
+ return nodes.map(node => result.get(node.path));
168
+ }
169
+
170
+ export function collectViewerElements(shell, { projectSource, assetPath, frame, styleFor, rectFor, origin }) {
171
+ const root = shell.firstElementChild;
172
+ if (!root || shell.children.length !== 1) return [];
173
+ const domNodes = [], inputs = [];
174
+ function walk(node, parentPath) {
175
+ const path = String(inputs.length);
176
+ const owners = node.hasAttribute('data-adg-owners') ? JSON.parse(node.getAttribute('data-adg-owners')) : [];
177
+ const entry = identityNode(node, path, parentPath, owners, styleFor);
178
+ domNodes.push(node);
179
+ inputs.push(entry);
180
+ if (!entry.resource) {
181
+ for (let child = node.firstElementChild; child; child = child.nextElementSibling) walk(child, path);
182
+ }
183
+ }
184
+ walk(root, null);
185
+ let assigned;
186
+ try {
187
+ assigned = elementIdentities(inputs, { source: projectSource, frame });
188
+ } catch (error) {
189
+ if (error.code === 'INSPECT_IDENTITY_CONFLICT') return [];
190
+ throw error;
191
+ }
192
+ const clean = n => n === 0 ? 0 : n;
193
+ const elements = [];
194
+ for (let i = 0; i < domNodes.length; i++) {
195
+ const node = domNodes[i], input = inputs[i], idRow = assigned[i];
196
+ if (input.neutral) continue;
197
+ if (node === root && !input.owners.length && !node.hasAttribute('data-adg-id') && !node.hasAttribute('role') && containerRoots.has(node.localName)) continue;
198
+ const rect = rectFor(node);
199
+ let left = Math.max(rect.left, origin.left), right = Math.min(rect.right, origin.right);
200
+ let top = Math.max(rect.top, origin.top), bottom = Math.min(rect.bottom, origin.bottom);
201
+ for (let p = node; p && p !== shell; p = p.parentElement) {
202
+ const s = styleFor(p);
203
+ if (s.display === 'none' || (p === node && s.visibility !== 'visible') || Number(s.opacity) === 0) { left = right; break; }
204
+ if (p !== node && s.display !== 'inline') {
205
+ const clip = rectFor(p);
206
+ if (/(hidden|clip|scroll|auto)/.test(s.overflowX)) { left = Math.max(left, clip.left); right = Math.min(right, clip.right); }
207
+ if (/(hidden|clip|scroll|auto)/.test(s.overflowY)) { top = Math.max(top, clip.top); bottom = Math.min(bottom, clip.bottom); }
208
+ }
209
+ }
210
+ if (right <= left || bottom <= top) continue;
211
+ const owner = idRow.defining.at(-1) ?? { source: assetPath, export: null };
212
+ elements.push({
213
+ id: idRow.id,
214
+ owners: input.owners,
215
+ owner,
216
+ x: clean(left - origin.left),
217
+ y: clean(top - origin.top),
218
+ width: Math.max(0, right - left),
219
+ height: Math.max(0, bottom - top),
220
+ });
221
+ }
222
+ return elements;
223
+ }
package/public/icons.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // Lucide geometry (ISC; see LICENSE). No runtime dependency.
2
2
  const geometry = {
3
+ "message-square": '<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" />',
3
4
  "palette": "<path d=\"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z\"></path><circle cx=\"13.5\" cy=\"6.5\" r=\".5\" fill=\"currentColor\"></circle><circle cx=\"17.5\" cy=\"10.5\" r=\".5\" fill=\"currentColor\"></circle><circle cx=\"6.5\" cy=\"12.5\" r=\".5\" fill=\"currentColor\"></circle><circle cx=\"8.5\" cy=\"7.5\" r=\".5\" fill=\"currentColor\"></circle>",
4
5
  "type": "<path d=\"M12 4v16\"></path><path d=\"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2\"></path><path d=\"M9 20h6\"></path>",
5
6
  "ruler": "<path d=\"M21.3 15.3a2.4 2.4 0 0 1 0 3.4l-2.6 2.6a2.4 2.4 0 0 1-3.4 0L2.7 8.7a2.41 2.41 0 0 1 0-3.4l2.6-2.6a2.41 2.41 0 0 1 3.4 0Z\"></path><path d=\"m14.5 12.5 2-2\"></path><path d=\"m11.5 9.5 2-2\"></path><path d=\"m8.5 6.5 2-2\"></path><path d=\"m17.5 15.5 2-2\"></path>",
package/public/index.html CHANGED
@@ -35,9 +35,11 @@
35
35
  <nav id="modules" aria-label="Design modules"></nav>
36
36
  </aside>
37
37
  <div id="tools" class="floating" role="toolbar" aria-label="View controls" hidden>
38
+ <button id="annotate" class="icon-button" aria-label="Annotations" aria-controls="annotations-panel" aria-expanded="false" data-tooltip="Annotations"><span data-icon="message-square"></span></button>
38
39
  <button id="more" class="icon-button" popovertarget="more-menu" aria-label="More" aria-expanded="false" data-tooltip="More"><span data-icon="ellipsis"></span></button>
39
40
  <button id="inspect" class="icon-button" aria-label="Inspector" aria-controls="source" aria-expanded="false" data-tooltip="Inspector" disabled><span data-icon="panel-right"></span></button>
40
41
  </div>
42
+ <aside id="annotations-panel" class="floating" hidden aria-label="Annotations"></aside>
41
43
  <aside id="source" class="floating" hidden aria-label="Inspector">
42
44
  <div class="inspector-heading"><h2 id="source-name"></h2><button id="copy-path" class="detail-copy" aria-label="Copy source path"><span id="source-path"></span><span data-icon="copy" data-size="12"></span></button><div id="frame-detail"><button id="copy-frame" class="detail-copy" aria-label="Copy frame name"><span id="frame-name"></span><span data-icon="copy" data-size="12"></span></button><span id="frame-size"></span></div></div>
43
45
  <div class="rule"></div><h3 id="forms-heading">Frames</h3><div id="forms"></div>
@@ -59,6 +61,7 @@
59
61
  <div id="canvas-actions"><div class="rule"></div><button id="arrange">Arrange current group</button><button id="shortcuts">Keyboard shortcuts<span class="key">?</span></button></div>
60
62
  </div>
61
63
  <div id="zoom-menu" class="menu" popover aria-label="Zoom"><button id="zoom-fit-all">Fit all<span class="key">0</span></button><button id="zoom-fit-group">Fit group</button><button id="zoom-fit-selection">Fit selection</button><div class="rule"></div><button id="zoom-actual">Zoom to 100%<span class="key">1</span></button></div>
64
+ <div id="context-menu" class="menu" popover role="menu" aria-label="Context menu"></div>
62
65
  <div id="tooltip" role="tooltip" hidden></div>
63
66
  <dialog id="keys" aria-labelledby="keys-title"><h2 id="keys-title">Keyboard shortcuts</h2><button id="keys-close" class="icon-button dialog-close" aria-label="Close keyboard shortcuts"><span data-icon="x" data-size="14"></span></button><dl>
64
67
  <div><dt>Search</dt><dd><kbd>⌘F</kbd></dd></div><div><dt>Fit all</dt><dd><kbd>0</kbd></dd></div><div><dt>Zoom to 100%</dt><dd><kbd>1</kbd></dd></div><div><dt>Zoom in or out</dt><dd><kbd>+</kbd><kbd>−</kbd></dd></div><div><dt>Pan</dt><dd><kbd>←</kbd><kbd>↑</kbd><kbd>→</kbd><kbd>↓</kbd></dd></div><div><dt>Focus selection</dt><dd><kbd>Enter</kbd></dd></div><div><dt>Back or close</dt><dd><kbd>Esc</kbd></dd></div>