@hansenexus/hud 0.7.0 → 0.9.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/README.md +153 -14
- package/dist/{access-Bc709qpl.d.ts → access-CwPCPsv0.d.ts} +1 -1
- package/dist/auto/runtime.d.ts +9 -9
- package/dist/auto.d.ts +2 -2
- package/dist/auto.js +1 -1
- package/dist/cli.js +34 -1
- package/dist/{define-hud-DTv3njuU.d.ts → define-hud-B0aFXrcK.d.ts} +1 -1
- package/dist/{design-BXG1a4we.js → design-BIXY1-Ex.js} +26 -8
- package/dist/{force-state-panel-mu-txJnA.js → force-state-panel-D5oDydLs.js} +1 -1
- package/dist/{handler-DMzSTqyG.d.ts → handler-BmFhaA2D.d.ts} +1 -1
- package/dist/{index-C3wzZS3o.d.ts → index-5B7foZut.d.ts} +2 -2
- package/dist/{index-D-hI-DRJ.d.ts → index-B2KCKkN0.d.ts} +1 -1
- package/dist/index-B7qaEUgh.d.ts +44 -0
- package/dist/{index-CQXiuMZQ.d.ts → index-BGFyuJyN.d.ts} +1 -1
- package/dist/{index-Caohnz3B.d.ts → index-BeqWehuh.d.ts} +38 -10
- package/dist/{index-BJJoAXJ2.d.ts → index-BqKysxTq.d.ts} +1 -1
- package/dist/{index-DLCSLWW4.d.ts → index-D97Fnoie.d.ts} +2 -2
- package/dist/{index-BR5OB7DO.d.ts → index-DS0yT0c-.d.ts} +1 -1
- package/dist/{index-BNoPbSYD.d.ts → index-DvlCkGB1.d.ts} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +49 -196
- package/dist/lanes-panel-Disg54DY.js +395 -0
- package/dist/navigation-CX6AXm7H.js +176 -0
- package/dist/next/config.cjs +2 -0
- package/dist/next/config.d.cts +1 -0
- package/dist/next/config.d.ts +1 -0
- package/dist/next/config.js +2 -0
- package/dist/next.d.ts +4 -1
- package/dist/next.js +12 -1
- package/dist/obstacles-CCmRFTcZ.js +176 -0
- package/dist/plugins/a11y.d.ts +1 -1
- package/dist/plugins/access/server.d.ts +3 -3
- package/dist/plugins/access.d.ts +2 -2
- package/dist/plugins/agent/server.js +1 -1
- package/dist/plugins/agent.d.ts +2 -2
- package/dist/plugins/capture.d.ts +2 -2
- package/dist/plugins/data/server.d.ts +1 -1
- package/dist/plugins/data/server.js +1 -1
- package/dist/plugins/data.d.ts +1 -1
- package/dist/plugins/design/server.d.ts +55 -15
- package/dist/plugins/design/server.js +187 -122
- package/dist/plugins/design.d.ts +3 -3
- package/dist/plugins/design.js +1 -1
- package/dist/plugins/inspect.d.ts +1 -1
- package/dist/plugins/lanes/server.d.ts +165 -0
- package/dist/plugins/lanes/server.js +845 -0
- package/dist/plugins/lanes.d.ts +22 -0
- package/dist/plugins/lanes.js +30 -0
- package/dist/plugins/observe.d.ts +1 -1
- package/dist/plugins/ops/server.d.ts +1 -1
- package/dist/plugins/ops.d.ts +1 -1
- package/dist/plugins/routes/server.d.ts +1 -1
- package/dist/plugins/routes.d.ts +3 -3
- package/dist/plugins/routes.js +381 -52
- package/dist/plugins/seo.d.ts +1 -1
- package/dist/plugins/vitals.d.ts +1 -1
- package/dist/{plugins-BZT-1LBe.d.ts → plugins-pL2CoWzI.d.ts} +7 -0
- package/dist/same-origin-BHuZO1_H.js +36 -0
- package/dist/server.d.ts +2 -2
- package/dist/store.d.ts +1 -1
- package/dist/store.js +1 -1
- package/dist/types-BkrkOP3h.js +6 -0
- package/dist/types-Dazn3aWZ.d.ts +86 -0
- package/dist/{meta-C_G7MB5w.d.ts → types-Dc6JWZR7.d.ts} +6 -6
- package/dist/variant-bar-BzZ0ln-C.js +768 -0
- package/dist/variant-picks-Byc0hC8a.js +144 -0
- package/dist/variants-export-vEtZ-OGC.js +75 -0
- package/dist/{variants-panel-B6zWcknV.js → variants-panel-D23v5KIp.js} +71 -54
- package/dist/variants-types-BOsZ5fDz.js +65 -0
- package/dist/variants-types-VkW7vFZF.d.ts +139 -0
- package/dist/variants.d.ts +1 -1
- package/dist/variants.js +1 -1
- package/dist/vite.d.ts +2 -2
- package/package.json +2 -2
- package/dist/index-B1vHAY9p.d.ts +0 -20
- package/dist/same-origin-BGet22CC.js +0 -21
- package/dist/variants-types-CcRf119M.d.ts +0 -63
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { n as HUD_HOST_TAG, t as HUD_DEV_MARKER } from "./marker-uZYPOJ4M.js";
|
|
|
4
4
|
import { a as ratingTone, i as definePlugin, n as HudApiError, o as resolvePlugins, r as createPluginContext } from "./plugins-CcW_K7c2.js";
|
|
5
5
|
import { a as buildGrabPayload, i as parseShortcut, n as isApplePlatform, o as describeElement, r as matchesShortcut, s as matchComponentHints, t as formatShortcut } from "./shortcut-s_mjGeU8.js";
|
|
6
6
|
import { i as PICKER_CSS, n as ShadowHost, r as ElementPicker, t as HUD_CSS } from "./styles-BA8ueHoV.js";
|
|
7
|
+
import { a as usePanels, i as PanelsContext, n as useObstacles, r as useVisualViewport, t as offsetObstacles } from "./obstacles-CCmRFTcZ.js";
|
|
7
8
|
import { Component, Suspense, createContext, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
8
9
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
10
|
//#region src/core/grabber/outline.tsx
|
|
@@ -421,6 +422,9 @@ function snapEdge(x, y, viewport) {
|
|
|
421
422
|
//#region src/shell/panels/panel-frame.tsx
|
|
422
423
|
/** The narrowest a floating panel renders (`.panel { min-width }`). */
|
|
423
424
|
const MIN_WIDTH = 240;
|
|
425
|
+
const MIN_HEIGHT = 160;
|
|
426
|
+
/** Room left between a floating panel and the viewport's bottom edge. */
|
|
427
|
+
const EDGE_GAP = 12;
|
|
424
428
|
const PIN_GLYPH = {
|
|
425
429
|
left: "◧",
|
|
426
430
|
right: "◨",
|
|
@@ -482,6 +486,7 @@ function PanelFrame({ title, z, viewport, position, pinned, onFocus, onClose, on
|
|
|
482
486
|
} : {
|
|
483
487
|
left: pos.x,
|
|
484
488
|
top: pos.y,
|
|
489
|
+
maxHeight: Math.max(MIN_HEIGHT, viewport.h - pos.y - EDGE_GAP),
|
|
485
490
|
zIndex: z
|
|
486
491
|
};
|
|
487
492
|
return /* @__PURE__ */ jsxs("section", {
|
|
@@ -566,14 +571,6 @@ function PanelSheet({ panels, active, onSelect, onClose, children }) {
|
|
|
566
571
|
});
|
|
567
572
|
}
|
|
568
573
|
//#endregion
|
|
569
|
-
//#region src/shell/panels/panels-context.ts
|
|
570
|
-
const PanelsContext = createContext(null);
|
|
571
|
-
function usePanels() {
|
|
572
|
-
const api = useContext(PanelsContext);
|
|
573
|
-
if (!api) throw new Error("usePanels() used outside <PanelManager>");
|
|
574
|
-
return api;
|
|
575
|
-
}
|
|
576
|
-
//#endregion
|
|
577
574
|
//#region src/shell/panels/reserve.ts
|
|
578
575
|
const PADDING = {
|
|
579
576
|
left: "padding-left",
|
|
@@ -690,7 +687,7 @@ function subscribeResize(listener) {
|
|
|
690
687
|
window.addEventListener("resize", listener);
|
|
691
688
|
return () => window.removeEventListener("resize", listener);
|
|
692
689
|
}
|
|
693
|
-
let cached
|
|
690
|
+
let cached = {
|
|
694
691
|
w: 0,
|
|
695
692
|
h: 0
|
|
696
693
|
};
|
|
@@ -702,11 +699,11 @@ function readViewport() {
|
|
|
702
699
|
const root = document.documentElement;
|
|
703
700
|
const w = root.clientWidth || window.innerWidth;
|
|
704
701
|
const h = root.clientHeight || window.innerHeight;
|
|
705
|
-
if (w !== cached
|
|
702
|
+
if (w !== cached.w || h !== cached.h) cached = {
|
|
706
703
|
w,
|
|
707
704
|
h
|
|
708
705
|
};
|
|
709
|
-
return cached
|
|
706
|
+
return cached;
|
|
710
707
|
}
|
|
711
708
|
function useViewport() {
|
|
712
709
|
return useSyncExternalStore(subscribeResize, readViewport, readViewport);
|
|
@@ -1049,55 +1046,6 @@ function clampOffset(rect, area, margin) {
|
|
|
1049
1046
|
};
|
|
1050
1047
|
}
|
|
1051
1048
|
//#endregion
|
|
1052
|
-
//#region src/shell/pill/visual-viewport.ts
|
|
1053
|
-
function subscribe$1(listener) {
|
|
1054
|
-
const vv = window.visualViewport;
|
|
1055
|
-
window.addEventListener("resize", listener);
|
|
1056
|
-
vv?.addEventListener("resize", listener);
|
|
1057
|
-
vv?.addEventListener("scroll", listener);
|
|
1058
|
-
return () => {
|
|
1059
|
-
window.removeEventListener("resize", listener);
|
|
1060
|
-
vv?.removeEventListener("resize", listener);
|
|
1061
|
-
vv?.removeEventListener("scroll", listener);
|
|
1062
|
-
};
|
|
1063
|
-
}
|
|
1064
|
-
let cached = {
|
|
1065
|
-
x: 0,
|
|
1066
|
-
y: 0,
|
|
1067
|
-
w: 0,
|
|
1068
|
-
h: 0,
|
|
1069
|
-
detached: false
|
|
1070
|
-
};
|
|
1071
|
-
/**
|
|
1072
|
-
* On a phone, a page wider than the screen (an image with a fixed width is
|
|
1073
|
-
* enough) grows the layout viewport past the visible area, and a pill fixed
|
|
1074
|
-
* to the bottom edge ends up below the fold. The visual viewport is what the
|
|
1075
|
-
* user sees; the pill places itself in it.
|
|
1076
|
-
*/
|
|
1077
|
-
function read$1() {
|
|
1078
|
-
const root = document.documentElement;
|
|
1079
|
-
const layoutW = root.clientWidth || window.innerWidth;
|
|
1080
|
-
const layoutH = root.clientHeight || window.innerHeight;
|
|
1081
|
-
const vv = window.visualViewport;
|
|
1082
|
-
const x = vv?.offsetLeft ?? 0;
|
|
1083
|
-
const y = vv?.offsetTop ?? 0;
|
|
1084
|
-
const w = Math.round(vv?.width ?? layoutW);
|
|
1085
|
-
const h = Math.round(vv?.height ?? layoutH);
|
|
1086
|
-
const detached = x !== 0 || y !== 0 || window.innerWidth > w + 1 || window.innerHeight > h + 1;
|
|
1087
|
-
const next = {
|
|
1088
|
-
x,
|
|
1089
|
-
y,
|
|
1090
|
-
w: detached ? w : layoutW,
|
|
1091
|
-
h: detached ? h : layoutH,
|
|
1092
|
-
detached
|
|
1093
|
-
};
|
|
1094
|
-
if (next.x !== cached.x || next.y !== cached.y || next.w !== cached.w || next.h !== cached.h || next.detached !== cached.detached) cached = next;
|
|
1095
|
-
return cached;
|
|
1096
|
-
}
|
|
1097
|
-
function useVisualViewport() {
|
|
1098
|
-
return useSyncExternalStore(subscribe$1, read$1, read$1);
|
|
1099
|
-
}
|
|
1100
|
-
//#endregion
|
|
1101
1049
|
//#region src/shell/panels/pill-menu.tsx
|
|
1102
1050
|
/** Distance the open menu keeps from the edges of the visible area. */
|
|
1103
1051
|
const MENU_MARGIN = 8;
|
|
@@ -1486,145 +1434,46 @@ function PluginPanelBody({ slot }) {
|
|
|
1486
1434
|
})
|
|
1487
1435
|
});
|
|
1488
1436
|
}
|
|
1437
|
+
/** A plugin's overlay. A loading or failed overlay is nothing; the rest of the HUD keeps going. */
|
|
1438
|
+
function PluginOverlay({ slot }) {
|
|
1439
|
+
const Overlay = slot.plugin.overlay;
|
|
1440
|
+
if (!Overlay) return null;
|
|
1441
|
+
return /* @__PURE__ */ jsx(PanelBoundary, {
|
|
1442
|
+
title: slot.title,
|
|
1443
|
+
silent: true,
|
|
1444
|
+
children: /* @__PURE__ */ jsx(Suspense, {
|
|
1445
|
+
fallback: null,
|
|
1446
|
+
children: /* @__PURE__ */ jsx(Overlay, { ctx: slot.ctx })
|
|
1447
|
+
})
|
|
1448
|
+
});
|
|
1449
|
+
}
|
|
1489
1450
|
var PanelBoundary = class extends Component {
|
|
1490
1451
|
state = { error: null };
|
|
1491
1452
|
static getDerivedStateFromError(error) {
|
|
1492
1453
|
return { error: error instanceof Error ? error : new Error(String(error)) };
|
|
1493
1454
|
}
|
|
1494
1455
|
componentDidCatch(error, info) {
|
|
1495
|
-
|
|
1456
|
+
const what = this.props.silent ? "overlay" : "panel";
|
|
1457
|
+
console.error(`hud: the ${this.props.title} ${what} failed`, error, info.componentStack);
|
|
1496
1458
|
}
|
|
1497
1459
|
render() {
|
|
1498
1460
|
const { error } = this.state;
|
|
1499
|
-
if (error)
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1461
|
+
if (error) {
|
|
1462
|
+
if (this.props.silent) return null;
|
|
1463
|
+
return /* @__PURE__ */ jsxs("p", {
|
|
1464
|
+
className: "empty panel-error",
|
|
1465
|
+
role: "alert",
|
|
1466
|
+
children: [
|
|
1467
|
+
this.props.title,
|
|
1468
|
+
" failed: ",
|
|
1469
|
+
error.message
|
|
1470
|
+
]
|
|
1471
|
+
});
|
|
1472
|
+
}
|
|
1508
1473
|
return this.props.children;
|
|
1509
1474
|
}
|
|
1510
1475
|
};
|
|
1511
1476
|
//#endregion
|
|
1512
|
-
//#region src/shell/pill/obstacles.ts
|
|
1513
|
-
/** Fixed elements covering more than this share of the viewport are backdrops, not corners. */
|
|
1514
|
-
const MAX_AREA_SHARE = .5;
|
|
1515
|
-
/** DOM changes settle for this long before the page is scanned again. */
|
|
1516
|
-
const RESCAN_MS = 250;
|
|
1517
|
-
function isFloating(el) {
|
|
1518
|
-
const { position } = getComputedStyle(el);
|
|
1519
|
-
return position === "fixed" || position === "sticky";
|
|
1520
|
-
}
|
|
1521
|
-
/**
|
|
1522
|
-
* The host page's fixed and sticky elements: what fights the pill for a
|
|
1523
|
-
* corner. Nested ones are dropped since their floating ancestor already
|
|
1524
|
-
* counts, and the HUD's own host is skipped.
|
|
1525
|
-
*/
|
|
1526
|
-
function scanFloating(root = document.body) {
|
|
1527
|
-
const found = [];
|
|
1528
|
-
const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, { acceptNode: (node) => {
|
|
1529
|
-
const el = node;
|
|
1530
|
-
if (el.localName === "hn-hud") return NodeFilter.FILTER_REJECT;
|
|
1531
|
-
return isFloating(el) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
1532
|
-
} });
|
|
1533
|
-
for (let node = walker.nextNode(); node; node = walker.nextNode()) {
|
|
1534
|
-
const el = node;
|
|
1535
|
-
if (!found.some((outer) => outer.contains(el))) found.push(el);
|
|
1536
|
-
}
|
|
1537
|
-
return found;
|
|
1538
|
-
}
|
|
1539
|
-
/** Visible rects of `elements`, minus backdrops and anything off screen. */
|
|
1540
|
-
function obstacleRects(elements) {
|
|
1541
|
-
const vw = window.innerWidth;
|
|
1542
|
-
const vh = window.innerHeight;
|
|
1543
|
-
const rects = [];
|
|
1544
|
-
for (const el of elements) {
|
|
1545
|
-
const { left, top, width, height } = el.getBoundingClientRect();
|
|
1546
|
-
if (width === 0 || height === 0) continue;
|
|
1547
|
-
if (width * height > vw * vh * MAX_AREA_SHARE) continue;
|
|
1548
|
-
if (left >= vw || top >= vh || left + width <= 0 || top + height <= 0) continue;
|
|
1549
|
-
const style = getComputedStyle(el);
|
|
1550
|
-
if (style.visibility === "hidden" || style.opacity === "0") continue;
|
|
1551
|
-
rects.push({
|
|
1552
|
-
left,
|
|
1553
|
-
top,
|
|
1554
|
-
width,
|
|
1555
|
-
height
|
|
1556
|
-
});
|
|
1557
|
-
}
|
|
1558
|
-
return rects;
|
|
1559
|
-
}
|
|
1560
|
-
function sameRects(a, b) {
|
|
1561
|
-
return a.length === b.length && a.every((r, i) => r.left === b[i]?.left && r.top === b[i]?.top && r.width === b[i]?.width && r.height === b[i]?.height);
|
|
1562
|
-
}
|
|
1563
|
-
const NONE = [];
|
|
1564
|
-
/** Obstacle rects moved into visible-area coordinates when the visual viewport is offset. */
|
|
1565
|
-
function offsetObstacles(rects, offset) {
|
|
1566
|
-
if (offset.x === 0 && offset.y === 0) return rects;
|
|
1567
|
-
return rects.map((o) => ({
|
|
1568
|
-
...o,
|
|
1569
|
-
left: o.left - offset.x,
|
|
1570
|
-
top: o.top - offset.y
|
|
1571
|
-
}));
|
|
1572
|
-
}
|
|
1573
|
-
/**
|
|
1574
|
-
* Live obstacle rects. The element list is rescanned when the DOM settles
|
|
1575
|
-
* after a change; rects are re-measured on scroll (sticky elements move) and
|
|
1576
|
-
* resize, once per frame.
|
|
1577
|
-
*/
|
|
1578
|
-
function useObstacles() {
|
|
1579
|
-
const [rects, setRects] = useState(NONE);
|
|
1580
|
-
useEffect(() => {
|
|
1581
|
-
let elements = scanFloating();
|
|
1582
|
-
let frame = 0;
|
|
1583
|
-
let timer;
|
|
1584
|
-
const measure = () => {
|
|
1585
|
-
frame = 0;
|
|
1586
|
-
const next = obstacleRects(elements);
|
|
1587
|
-
setRects((prev) => sameRects(prev, next) ? prev : next);
|
|
1588
|
-
};
|
|
1589
|
-
const schedule = () => {
|
|
1590
|
-
if (!frame) frame = requestAnimationFrame(measure);
|
|
1591
|
-
};
|
|
1592
|
-
const rescan = () => {
|
|
1593
|
-
schedule();
|
|
1594
|
-
clearTimeout(timer);
|
|
1595
|
-
timer = setTimeout(() => {
|
|
1596
|
-
elements = scanFloating();
|
|
1597
|
-
schedule();
|
|
1598
|
-
}, RESCAN_MS);
|
|
1599
|
-
};
|
|
1600
|
-
measure();
|
|
1601
|
-
const observer = new MutationObserver(rescan);
|
|
1602
|
-
observer.observe(document.body, {
|
|
1603
|
-
childList: true,
|
|
1604
|
-
subtree: true,
|
|
1605
|
-
attributes: true,
|
|
1606
|
-
attributeFilter: [
|
|
1607
|
-
"class",
|
|
1608
|
-
"style",
|
|
1609
|
-
"hidden"
|
|
1610
|
-
]
|
|
1611
|
-
});
|
|
1612
|
-
window.addEventListener("scroll", schedule, {
|
|
1613
|
-
capture: true,
|
|
1614
|
-
passive: true
|
|
1615
|
-
});
|
|
1616
|
-
window.addEventListener("resize", schedule);
|
|
1617
|
-
return () => {
|
|
1618
|
-
observer.disconnect();
|
|
1619
|
-
clearTimeout(timer);
|
|
1620
|
-
if (frame) cancelAnimationFrame(frame);
|
|
1621
|
-
window.removeEventListener("scroll", schedule, { capture: true });
|
|
1622
|
-
window.removeEventListener("resize", schedule);
|
|
1623
|
-
};
|
|
1624
|
-
}, []);
|
|
1625
|
-
return rects;
|
|
1626
|
-
}
|
|
1627
|
-
//#endregion
|
|
1628
1477
|
//#region src/shell/pill/pill.tsx
|
|
1629
1478
|
/** `.pill` gap, padding and border, which the item widths do not include. */
|
|
1630
1479
|
const ITEM_GAP = 2;
|
|
@@ -2854,16 +2703,20 @@ function Shell({ appSlug, envLabel, plugins, apiBase, can, dock }) {
|
|
|
2854
2703
|
panels,
|
|
2855
2704
|
commands,
|
|
2856
2705
|
apiRef: panelsRef,
|
|
2857
|
-
children: [
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2706
|
+
children: [
|
|
2707
|
+
/* @__PURE__ */ jsx(dock === "rail" ? Rail : Pill, {
|
|
2708
|
+
appSlug,
|
|
2709
|
+
envLabel,
|
|
2710
|
+
slots,
|
|
2711
|
+
grab
|
|
2712
|
+
}),
|
|
2713
|
+
slots.map((slot) => slot.plugin.overlay && /* @__PURE__ */ jsx(PluginOverlay, { slot }, slot.plugin.id)),
|
|
2714
|
+
/* @__PURE__ */ jsx(Grabber, {
|
|
2715
|
+
app: appSlug,
|
|
2716
|
+
store: grab,
|
|
2717
|
+
slots
|
|
2718
|
+
})
|
|
2719
|
+
]
|
|
2867
2720
|
});
|
|
2868
2721
|
}
|
|
2869
2722
|
//#endregion
|