@hansenexus/hud 0.6.0 → 0.8.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.
Files changed (102) hide show
  1. package/README.md +172 -25
  2. package/dist/{a11y-B5DUaiCs.js → a11y-BGWw4jBr.js} +14 -2
  3. package/dist/{a11y-panel-p_t4eD7p.js → a11y-panel-DcfXnPHk.js} +1 -1
  4. package/dist/{access-D_ewAEJG.d.ts → access-CwPCPsv0.d.ts} +1 -1
  5. package/dist/{access-panel-CEfTr9ZI.js → access-panel-grAsMEDk.js} +1 -1
  6. package/dist/auto/runtime.d.ts +9 -9
  7. package/dist/auto.d.ts +2 -2
  8. package/dist/auto.js +5 -5
  9. package/dist/cli.js +34 -1
  10. package/dist/{data-panel-BmcHCQnM.js → data-panel-B6WPNmV6.js} +1 -1
  11. package/dist/{data-store-ChF1td_P.js → data-store-FNTQKMkG.js} +1 -1
  12. package/dist/{define-hud-CHPedaQ5.d.ts → define-hud-B0aFXrcK.d.ts} +15 -5
  13. package/dist/{design-D0kGgPoP.js → design-BIXY1-Ex.js} +45 -11
  14. package/dist/{dispatch-panel-B-xr_Giy.js → dispatch-panel-BDHgMhOk.js} +1 -1
  15. package/dist/{force-state-panel-_otVYh9i.js → force-state-panel-D5oDydLs.js} +1 -1
  16. package/dist/{handler-BpVhxEmU.js → handler-BKzaOhlJ.js} +1 -1
  17. package/dist/{handler-DtYVCZY6.d.ts → handler-BmFhaA2D.d.ts} +1 -1
  18. package/dist/icons-ByDyNq_E.js +71 -0
  19. package/dist/index-5B7foZut.d.ts +116 -0
  20. package/dist/{index-ReFbhQ9p.d.ts → index-B2KCKkN0.d.ts} +5 -0
  21. package/dist/index-B7qaEUgh.d.ts +44 -0
  22. package/dist/{index-DcH9V3cU.d.ts → index-BGFyuJyN.d.ts} +3 -0
  23. package/dist/{index-Hhh7OXzU.d.ts → index-BeqWehuh.d.ts} +44 -10
  24. package/dist/{index-DstI_ike.d.ts → index-BqKysxTq.d.ts} +5 -1
  25. package/dist/{index-DqOyNf1u.d.ts → index-D97Fnoie.d.ts} +4 -2
  26. package/dist/{index-CwfX-W87.d.ts → index-DS0yT0c-.d.ts} +3 -0
  27. package/dist/{index-BAV_1W8a.d.ts → index-DvlCkGB1.d.ts} +3 -1
  28. package/dist/index.d.ts +4 -4
  29. package/dist/index.js +1226 -256
  30. package/dist/{inspect-C9Ft8fqn.js → inspect-CSkm8tn3.js} +14 -2
  31. package/dist/{inspect-root-BkaupBMp.js → inspect-root-CmiFX0e5.js} +1 -1
  32. package/dist/navigation-CX6AXm7H.js +176 -0
  33. package/dist/next.d.ts +4 -1
  34. package/dist/next.js +12 -1
  35. package/dist/{observe-CdDnDBRP.js → observe-CBNLU148.js} +12 -2
  36. package/dist/{observe-panel-Cgp1M8oT.js → observe-panel-zU5LD-U9.js} +1 -1
  37. package/dist/obstacles-CCmRFTcZ.js +176 -0
  38. package/dist/{ops-panel-CEqDe_UT.js → ops-panel-DHhAnChL.js} +1 -1
  39. package/dist/plugins/a11y.d.ts +1 -1
  40. package/dist/plugins/a11y.js +1 -1
  41. package/dist/plugins/access/server.d.ts +3 -3
  42. package/dist/plugins/access/server.js +1 -1
  43. package/dist/plugins/access.d.ts +5 -2
  44. package/dist/plugins/access.js +18 -5
  45. package/dist/plugins/agent/server.js +2 -2
  46. package/dist/plugins/agent.d.ts +4 -2
  47. package/dist/plugins/agent.js +6 -3
  48. package/dist/plugins/capture/server.js +1 -1
  49. package/dist/plugins/capture.d.ts +2 -2
  50. package/dist/plugins/capture.js +1 -1
  51. package/dist/plugins/data/server.d.ts +1 -1
  52. package/dist/plugins/data/server.js +2 -2
  53. package/dist/plugins/data.d.ts +1 -1
  54. package/dist/plugins/data.js +30 -9
  55. package/dist/plugins/design/server.d.ts +55 -15
  56. package/dist/plugins/design/server.js +188 -123
  57. package/dist/plugins/design.d.ts +3 -3
  58. package/dist/plugins/design.js +1 -1
  59. package/dist/plugins/inspect.d.ts +1 -1
  60. package/dist/plugins/inspect.js +1 -1
  61. package/dist/plugins/observe.d.ts +1 -1
  62. package/dist/plugins/observe.js +1 -1
  63. package/dist/plugins/ops/server.d.ts +1 -1
  64. package/dist/plugins/ops/server.js +1 -1
  65. package/dist/plugins/ops.d.ts +5 -1
  66. package/dist/plugins/ops.js +16 -4
  67. package/dist/plugins/routes/server.d.ts +1 -1
  68. package/dist/plugins/routes/server.js +1 -1
  69. package/dist/plugins/routes.d.ts +3 -3
  70. package/dist/plugins/routes.js +384 -53
  71. package/dist/plugins/seo.d.ts +1 -1
  72. package/dist/plugins/seo.js +1 -1
  73. package/dist/plugins/vitals.d.ts +1 -1
  74. package/dist/plugins/vitals.js +9 -1
  75. package/dist/{plugins-DVy_vaYr.js → plugins-CcW_K7c2.js} +9 -1
  76. package/dist/{plugins-BZvDqGx5.d.ts → plugins-pL2CoWzI.d.ts} +39 -3
  77. package/dist/{poll-CjKsWZi8.js → poll-Dm0OijM4.js} +1 -1
  78. package/dist/same-origin-BHuZO1_H.js +36 -0
  79. package/dist/{seo-Dq9q_QkO.js → seo-BnnGq_vj.js} +13 -2
  80. package/dist/{seo-panel-CfiY-TnT.js → seo-panel-BThx56KM.js} +1 -1
  81. package/dist/server.d.ts +2 -2
  82. package/dist/server.js +2 -2
  83. package/dist/{sessions-panel-COvhPAzv.js → sessions-panel-MknKsTge.js} +1 -1
  84. package/dist/store.d.ts +1 -1
  85. package/dist/store.js +2 -2
  86. package/dist/{meta-C_G7MB5w.d.ts → types-Dc6JWZR7.d.ts} +6 -6
  87. package/dist/{unlock-store-4V3vR4Eg.js → unlock-store-CrGXQx1V.js} +1 -1
  88. package/dist/variant-bar-BzZ0ln-C.js +768 -0
  89. package/dist/variant-picks-Byc0hC8a.js +144 -0
  90. package/dist/variants-export-vEtZ-OGC.js +75 -0
  91. package/dist/{variants-panel-BDoSkwBJ.js → variants-panel-D23v5KIp.js} +72 -55
  92. package/dist/variants-types-BOsZ5fDz.js +65 -0
  93. package/dist/variants-types-VkW7vFZF.d.ts +139 -0
  94. package/dist/variants.d.ts +1 -1
  95. package/dist/variants.js +1 -1
  96. package/dist/vite.d.ts +2 -2
  97. package/dist/vite.js +1 -1
  98. package/package.json +1 -1
  99. package/dist/index-BnQ0dTZf.d.ts +0 -19
  100. package/dist/index-gCZBO53s.d.ts +0 -73
  101. package/dist/same-origin-BGet22CC.js +0 -21
  102. package/dist/variants-types-CcRf119M.d.ts +0 -63
@@ -1,4 +1,4 @@
1
- import { d as HudRoutes } from "../../plugins-BZvDqGx5.js";
1
+ import { p as HudRoutes } from "../../plugins-pL2CoWzI.js";
2
2
  import { a as CiSnapshot, c as TelemetryRange, i as CiRun, l as TelemetryResponse, n as CiProvider, o as CiState, r as CiResponse, s as TelemetryProvider, t as CiDeployment, u as TelemetrySnapshot } from "../../types-f3jlNxzw.js";
3
3
  //#region src/plugins/ops/errors.d.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { i as definePlugin } from "../../plugins-DVy_vaYr.js";
1
+ import { i as definePlugin } from "../../plugins-CcW_K7c2.js";
2
2
  import { a as OPS_CAPABILITY, n as combineStates } from "../../state-CjjZPjPJ.js";
3
3
  import { t as TELEMETRY_RANGES } from "../../types-B-ulf2Jp.js";
4
4
  //#region src/plugins/ops/errors.ts
@@ -1,7 +1,9 @@
1
- import { c as HudPluginProps } from "../plugins-BZvDqGx5.js";
1
+ import { r as HudBadge, u as HudPluginProps } from "../plugins-pL2CoWzI.js";
2
2
  import { c as TelemetryRange, i as CiRun, l as TelemetryResponse, o as CiState, r as CiResponse, t as CiDeployment } from "../types-f3jlNxzw.js";
3
3
  //#region src/plugins/ops/index.d.ts
4
4
  declare function OpsPill({ ctx }: HudPluginProps): import("react").JSX.Element;
5
+ /** The CI state as a rail badge: off until the server answers or when no provider is configured. */
6
+ declare function useOpsBadge({ ctx }: HudPluginProps): HudBadge;
5
7
  export interface OpsOptions {
6
8
  /** Show the CI section and the CI state in the pill. Default true. */
7
9
  ci?: boolean;
@@ -19,8 +21,10 @@ export declare function ops({ ci, telemetry }?: OpsOptions): {
19
21
  readonly id: "ops";
20
22
  readonly title: "Ops";
21
23
  readonly capability: "cicd.read";
24
+ readonly icon: import("react").ComponentType;
22
25
  readonly panel: ({ ctx }: HudPluginProps) => import("react").JSX.Element;
23
26
  readonly pill?: typeof OpsPill;
27
+ readonly badge?: typeof useOpsBadge;
24
28
  readonly pillPriority: 10;
25
29
  };
26
30
  //#endregion
@@ -1,10 +1,11 @@
1
- import { i as definePlugin } from "../plugins-DVy_vaYr.js";
1
+ import { i as hudIcon } from "../icons-ByDyNq_E.js";
2
+ import { a as ratingTone, i as definePlugin } from "../plugins-CcW_K7c2.js";
2
3
  import { a as OPS_CAPABILITY, i as stateRating, r as stateLabel, t as CI_POLL_MS } from "../state-CjjZPjPJ.js";
3
- import { t as usePoll } from "../poll-CjKsWZi8.js";
4
+ import { t as usePoll } from "../poll-Dm0OijM4.js";
4
5
  import { lazy } from "react";
5
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
7
  //#region src/plugins/ops/index.tsx
7
- const Panel = lazy(() => import("../ops-panel-CEqDe_UT.js"));
8
+ const Panel = lazy(() => import("../ops-panel-DHhAnChL.js"));
8
9
  function OpsPill({ ctx }) {
9
10
  const { data, error } = usePoll(ctx, "/ci", CI_POLL_MS);
10
11
  const label = !data && error ? "error" : !data ? "–" : !data.configured ? "off" : stateLabel(data.state);
@@ -13,6 +14,13 @@ function OpsPill({ ctx }) {
13
14
  "data-rating": data ? stateRating(data.state) : void 0
14
15
  }), `CI ${label}`] });
15
16
  }
17
+ /** The CI state as a rail badge: off until the server answers or when no provider is configured. */
18
+ function useOpsBadge({ ctx }) {
19
+ const { data, error } = usePoll(ctx, "/ci", CI_POLL_MS);
20
+ if (!data) return { tone: error ? "poor" : "off" };
21
+ if (!data.configured) return { tone: "off" };
22
+ return { tone: ratingTone(stateRating(data.state)) ?? "off" };
23
+ }
16
24
  /**
17
25
  * CI and telemetry: the pill shows the CI state of the branch the server runs
18
26
  * on, the panel lists recent runs, the deployment (when the CI provider knows
@@ -32,8 +40,12 @@ function ops({ ci = true, telemetry = true } = {}) {
32
40
  id: "ops",
33
41
  title: "Ops",
34
42
  capability: OPS_CAPABILITY,
43
+ icon: hudIcon("git-branch"),
35
44
  panel: OpsPanel,
36
- ...ci ? { pill: OpsPill } : {},
45
+ ...ci ? {
46
+ pill: OpsPill,
47
+ badge: useOpsBadge
48
+ } : {},
37
49
  pillPriority: 10
38
50
  });
39
51
  }
@@ -1,4 +1,4 @@
1
- import { a as RouteUrl, i as RouteSegment, n as ROUTES_ID, o as RoutesResponse, r as RouteEntry, t as ROUTES_CAPABILITY } from "../../meta-C_G7MB5w.js";
1
+ import { a as ROUTES_CAPABILITY, i as RoutesResponse, n as RouteSegment, o as ROUTES_ID, r as RouteUrl, t as RouteEntry } from "../../types-Dc6JWZR7.js";
2
2
  //#region src/plugins/routes/scan.d.ts
3
3
  /**
4
4
  * Pure derivation over a Next `app/` tree: folder names to patterns, patterns
@@ -1,4 +1,4 @@
1
- import { i as definePlugin } from "../../plugins-DVy_vaYr.js";
1
+ import { i as definePlugin } from "../../plugins-CcW_K7c2.js";
2
2
  import { n as ROUTES_ID, t as ROUTES_CAPABILITY } from "../../meta-Bv0sEao3.js";
3
3
  import { i as scanRoutes, n as findPages, t as buildUrls } from "../../scan-DzJNXqOk.js";
4
4
  //#region src/plugins/routes/server.ts
@@ -1,3 +1,3 @@
1
- import { a as RouteUrl, i as RouteSegment, n as ROUTES_ID, o as RoutesResponse, r as RouteEntry, t as ROUTES_CAPABILITY } from "../meta-C_G7MB5w.js";
2
- import { t as routes } from "../index-BnQ0dTZf.js";
3
- export { ROUTES_CAPABILITY, ROUTES_ID, type RouteEntry, type RouteSegment, type RouteUrl, type RoutesResponse, routes };
1
+ import { a as ROUTES_CAPABILITY, i as RoutesResponse, n as RouteSegment, o as ROUTES_ID, r as RouteUrl, t as RouteEntry } from "../types-Dc6JWZR7.js";
2
+ import { n as routes, t as RoutesOptions } from "../index-B7qaEUgh.js";
3
+ export { ROUTES_CAPABILITY, ROUTES_ID, type RouteEntry, type RouteSegment, type RouteUrl, RoutesOptions, type RoutesResponse, routes };
@@ -1,7 +1,9 @@
1
- import { i as definePlugin, n as HudApiError } from "../plugins-DVy_vaYr.js";
1
+ import { i as hudIcon } from "../icons-ByDyNq_E.js";
2
+ import { i as definePlugin, n as HudApiError } from "../plugins-CcW_K7c2.js";
2
3
  import { n as ROUTES_ID, t as ROUTES_CAPABILITY } from "../meta-Bv0sEao3.js";
3
- import { useCallback, useEffect, useState } from "react";
4
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
+ import { a as togglePin, c as usePrefs, i as takeFilterFocus, n as requestFilterFocus, o as useFilterFocusTick, r as startNavigationObserver, s as usePathname, t as navigateTo } from "../navigation-CX6AXm7H.js";
5
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
5
7
  //#region src/plugins/routes/styles.ts
6
8
  /** Panel styles, rendered as a `<style>` inside the panel, so inside the shadow root. */
7
9
  const ROUTES_CSS = `
@@ -30,11 +32,14 @@ const ROUTES_CSS = `
30
32
  color: var(--hud-fg-muted);
31
33
  }
32
34
  .routes ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
33
- .routes li a, .routes li > span {
35
+ .routes li { display: flex; align-items: center; gap: 4px; border-radius: 4px; }
36
+ .routes li a.row, .routes li > span {
37
+ flex: 1;
34
38
  display: grid;
35
39
  grid-template-columns: minmax(0, 1fr) auto;
36
40
  align-items: center;
37
41
  gap: 8px;
42
+ min-width: 0;
38
43
  padding: 3px 6px;
39
44
  border-radius: 4px;
40
45
  font-family: var(--hud-mono);
@@ -44,14 +49,191 @@ const ROUTES_CSS = `
44
49
  text-overflow: ellipsis;
45
50
  white-space: nowrap;
46
51
  }
47
- .routes li a:hover { background: var(--hud-bg-subtle); }
52
+ .routes li:hover, .routes li[data-active] { background: var(--hud-bg-subtle); }
53
+ .routes li[data-active] { box-shadow: inset 2px 0 0 var(--hud-accent); }
48
54
  .routes li a[aria-current="page"] { color: var(--hud-accent); font-weight: 600; }
49
55
  .routes li > span { color: var(--hud-fg-muted); }
50
56
  .routes li small { color: var(--hud-fg-muted); font-family: var(--hud-font); }
57
+ .routes .alts { display: flex; gap: 2px; }
58
+ .routes a.alt {
59
+ padding: 0 5px;
60
+ border: 1px solid var(--hud-border);
61
+ border-radius: 999px;
62
+ font-family: var(--hud-mono);
63
+ font-size: 10px;
64
+ color: var(--hud-fg-muted);
65
+ text-decoration: none;
66
+ }
67
+ .routes a.alt:hover, .routes a.alt[aria-current="page"] { color: var(--hud-accent); border-color: var(--hud-accent); }
68
+ .routes button.pin {
69
+ padding: 0 4px;
70
+ border: 0;
71
+ background: none;
72
+ color: var(--hud-fg-muted);
73
+ font: inherit;
74
+ cursor: pointer;
75
+ opacity: 0;
76
+ }
77
+ .routes li:hover button.pin, .routes li[data-active] button.pin, .routes button.pin[aria-pressed="true"],
78
+ .routes button.pin:focus-visible { opacity: 1; }
79
+ .routes button.pin[aria-pressed="true"] { color: var(--hud-accent); }
80
+ .routes button.pin:disabled { cursor: default; }
51
81
  .routes .warn { color: var(--hud-warn); margin: 0; }
52
82
  .routes .muted { color: var(--hud-fg-muted); margin: 0; }
53
83
  `;
54
84
  //#endregion
85
+ //#region src/plugins/routes/switcher.ts
86
+ /** 2 for a substring match, 1 when `query` is a subsequence of `text`, 0 otherwise. */
87
+ function fuzzyScore(text, query) {
88
+ if (!query) return 2;
89
+ const hay = text.toLowerCase();
90
+ if (hay.includes(query)) return 2;
91
+ let at = 0;
92
+ for (const char of query) {
93
+ at = hay.indexOf(char, at);
94
+ if (at === -1) return 0;
95
+ at += 1;
96
+ }
97
+ return 1;
98
+ }
99
+ function tokens(query) {
100
+ return query.toLowerCase().split(/\s+/).filter(Boolean);
101
+ }
102
+ /** The best score of `token` over the route's own fields. */
103
+ function routeScore(route, token) {
104
+ return Math.max(fuzzyScore(route.path, token), fuzzyScore(route.pattern, token), route.group ? fuzzyScore(route.group, token) : 0);
105
+ }
106
+ /**
107
+ * Routes matching every word of the query on path, pattern or group,
108
+ * substring first, then as a subsequence (`dsys` finds `/de/dev/design-system`).
109
+ * A word that only matches some of a route's URLs narrows the route to those.
110
+ */
111
+ function filterRoutes(routes, query) {
112
+ const words = tokens(query);
113
+ if (words.length === 0) return [...routes];
114
+ return routes.flatMap((route) => {
115
+ const own = words.map((word) => routeScore(route, word));
116
+ if (own.every((score) => score > 0)) return [{
117
+ route,
118
+ score: own.reduce((sum, score) => sum + score, 0)
119
+ }];
120
+ const urls = route.urls.filter(({ url }) => words.every((word, i) => (own[i] ?? 0) > 0 || fuzzyScore(url, word) > 0));
121
+ if (urls.length === 0) return [];
122
+ const score = words.reduce((sum, word, i) => sum + Math.max(own[i] ?? 0, ...urls.map(({ url }) => fuzzyScore(url, word))), 0);
123
+ return [{
124
+ route: {
125
+ ...route,
126
+ urls
127
+ },
128
+ score
129
+ }];
130
+ }).map((entry, index) => ({
131
+ ...entry,
132
+ index
133
+ })).sort((a, b) => b.score - a.score || a.index - b.index).map(({ route }) => route);
134
+ }
135
+ /** Fixture values of the `locale` segment across the routes, in fixture order. */
136
+ function localesOf(routes) {
137
+ const locales = [];
138
+ for (const route of routes) for (const { params } of route.urls) {
139
+ const locale = params.locale;
140
+ if (locale !== void 0 && !locales.includes(locale)) locales.push(locale);
141
+ }
142
+ return locales;
143
+ }
144
+ /**
145
+ * The locale the page is on: its first segment when that is a locale, else
146
+ * the empty locale when the fixtures have one (an `as-needed` default), else
147
+ * the first fixture value. Undefined without a `locale` segment.
148
+ */
149
+ function currentLocale(pathname, locales) {
150
+ if (locales.length === 0) return void 0;
151
+ const first = pathname.split("/")[1] ?? "";
152
+ if (first && locales.includes(first)) return first;
153
+ if (locales.includes("")) return "";
154
+ return locales[0];
155
+ }
156
+ function paramsKey(params) {
157
+ return JSON.stringify(Object.entries(params).filter(([name]) => name !== "locale").sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0));
158
+ }
159
+ /**
160
+ * The rows of a route: one per URL, except that with a `locale` fixture the
161
+ * locale variants of a page fold into one row for `locale`, the other
162
+ * locales listed as alternates. Unresolved routes have no rows.
163
+ */
164
+ function rowsOf(route, locale) {
165
+ if (route.urls.length === 0) return [];
166
+ if (!route.urls.some(({ params }) => params.locale !== void 0) || locale === void 0) return route.urls.map(({ url, params }) => ({
167
+ id: `${route.pattern}${paramsKey(params)}`,
168
+ url,
169
+ route,
170
+ params,
171
+ alternates: []
172
+ }));
173
+ const groups = /* @__PURE__ */ new Map();
174
+ for (const entry of route.urls) {
175
+ const key = paramsKey(entry.params);
176
+ const group = groups.get(key);
177
+ if (group) group.push(entry);
178
+ else groups.set(key, [entry]);
179
+ }
180
+ return [...groups.entries()].flatMap(([key, entries]) => {
181
+ const primary = entries.find(({ params }) => params.locale === locale) ?? entries[0];
182
+ if (!primary) return [];
183
+ return {
184
+ id: `${route.pattern}${key}`,
185
+ url: primary.url,
186
+ route,
187
+ params: primary.params,
188
+ alternates: entries.filter((entry) => entry !== primary).map(({ url, params }) => ({
189
+ locale: params.locale ?? "",
190
+ url
191
+ }))
192
+ };
193
+ });
194
+ }
195
+ /** `*` matches within a segment, `**` across segments; anchored at both ends. */
196
+ function matchesGlob(glob, pathname) {
197
+ const source = glob.split(/(\*\*|\*)/).map((part) => part === "**" ? ".*" : part === "*" ? "[^/]*" : escapeRegExp(part)).join("");
198
+ return new RegExp(`^${source}/?$`).test(pathname);
199
+ }
200
+ function escapeRegExp(text) {
201
+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
202
+ }
203
+ function rowUrls(row) {
204
+ return [row.url, ...row.alternates.map((alternate) => alternate.url)];
205
+ }
206
+ /** Whether the row, in any locale, matches a configured glob or a stored pin. */
207
+ function isPinned(row, globs, pins) {
208
+ return rowUrls(row).some((url) => pins.includes(url) || globs.some((glob) => matchesGlob(glob, url)));
209
+ }
210
+ /** Whether a configured glob (not a toggle) pins the row. */
211
+ function isGlobPinned(row, globs) {
212
+ return rowUrls(row).some((url) => globs.some((glob) => matchesGlob(glob, url)));
213
+ }
214
+ /**
215
+ * The rows for the recent pathnames, most recent first: the scanned row that
216
+ * owns the pathname (in any locale), else a bare row, each page once.
217
+ */
218
+ function recentRows(recent, rows) {
219
+ const seen = /* @__PURE__ */ new Set();
220
+ const out = [];
221
+ for (const pathname of recent) {
222
+ const row = rows.find((candidate) => rowUrls(candidate).includes(pathname));
223
+ const id = row ? row.id : `recent:${pathname}`;
224
+ if (seen.has(id)) continue;
225
+ seen.add(id);
226
+ out.push(row ?? {
227
+ id,
228
+ url: pathname,
229
+ route: null,
230
+ params: {},
231
+ alternates: []
232
+ });
233
+ }
234
+ return out;
235
+ }
236
+ //#endregion
55
237
  //#region src/plugins/routes/routes-panel.tsx
56
238
  /** A readable message for a failed request; the route's own 500 bodies carry one. */
57
239
  function describeError(error) {
@@ -94,47 +276,160 @@ function useRoutes(ctx) {
94
276
  function groupLabel(group) {
95
277
  return group ?? "root";
96
278
  }
97
- /**
98
- * Routes whose path or pattern contains the query, case-insensitive. A query
99
- * that only matches some of a route's URLs narrows the route to those.
100
- */
101
- function filterRoutes(routes, query) {
102
- const q = query.trim().toLowerCase();
103
- if (!q) return [...routes];
104
- return routes.flatMap((route) => {
105
- if (route.path.toLowerCase().includes(q) || route.pattern.toLowerCase().includes(q)) return [route];
106
- const urls = route.urls.filter(({ url }) => url.toLowerCase().includes(q));
107
- return urls.length > 0 ? [{
108
- ...route,
109
- urls
110
- }] : [];
111
- });
279
+ const NO_GLOBS = [];
280
+ /** A plain left click: no modifier, so the row navigates in place. */
281
+ function isPlainClick(event) {
282
+ return event.button === 0 && !event.metaKey && !event.ctrlKey && !event.shiftKey && !event.altKey;
112
283
  }
113
- function currentPath() {
114
- return typeof location === "undefined" ? void 0 : location.pathname;
284
+ function RouteRow({ row, here, active, pinned, byGlob, onGo, onPin }) {
285
+ const ref = useRef(null);
286
+ useEffect(() => {
287
+ if (active) ref.current?.scrollIntoView?.({ block: "nearest" });
288
+ }, [active]);
289
+ const route = row.route;
290
+ const values = Object.entries(row.params).filter(([name, value]) => name !== "locale" && value);
291
+ const go = (url) => (event) => {
292
+ if (!isPlainClick(event)) return;
293
+ event.preventDefault();
294
+ onGo(url);
295
+ };
296
+ return /* @__PURE__ */ jsxs("li", {
297
+ ref,
298
+ "data-active": active || void 0,
299
+ children: [
300
+ /* @__PURE__ */ jsxs("a", {
301
+ className: "row",
302
+ href: row.url,
303
+ title: route?.pattern,
304
+ "aria-current": row.url === here ? "page" : void 0,
305
+ onClick: go(row.url),
306
+ children: [row.url, route && values.length > 0 && /* @__PURE__ */ jsx("small", { children: route.path })]
307
+ }),
308
+ row.alternates.length > 0 && /* @__PURE__ */ jsx("span", {
309
+ className: "alts",
310
+ children: row.alternates.map((alternate) => /* @__PURE__ */ jsx("a", {
311
+ className: "alt",
312
+ href: alternate.url,
313
+ title: alternate.url,
314
+ "aria-current": alternate.url === here ? "page" : void 0,
315
+ onClick: go(alternate.url),
316
+ children: alternate.locale || "default"
317
+ }, alternate.url))
318
+ }),
319
+ /* @__PURE__ */ jsx("button", {
320
+ type: "button",
321
+ className: "pin",
322
+ "aria-label": `${pinned ? "Unpin" : "Pin"} ${row.url}`,
323
+ "aria-pressed": pinned,
324
+ disabled: byGlob,
325
+ title: byGlob ? "pinned by routes({ pinned })" : pinned ? "Unpin" : "Pin",
326
+ onClick: () => onPin(row.url),
327
+ children: pinned ? "★" : "☆"
328
+ })
329
+ ]
330
+ });
115
331
  }
116
- function RouteRow({ route, here }) {
117
- if (route.unresolved.length > 0) return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs("span", {
332
+ function UnresolvedRow({ route }) {
333
+ return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs("span", {
118
334
  title: `${route.pattern}: no fixture for ${route.unresolved.join(", ")}`,
119
335
  children: [route.path, /* @__PURE__ */ jsxs("small", { children: ["no fixture: ", route.unresolved.join(", ")] })]
120
336
  }) });
121
- return /* @__PURE__ */ jsx(Fragment, { children: route.urls.map(({ url, params }) => {
122
- const values = Object.values(params).filter(Boolean);
123
- return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs("a", {
124
- href: url,
125
- title: route.pattern,
126
- "aria-current": url === here ? "page" : void 0,
127
- children: [url, values.length > 0 && /* @__PURE__ */ jsx("small", { children: route.path })]
128
- }) }, url);
129
- }) });
130
337
  }
131
- function RoutesPanel({ ctx }) {
338
+ function RoutesPanel({ ctx, pinned: globs = NO_GLOBS, navigate }) {
132
339
  const { data, error, loading, refresh } = useRoutes(ctx);
133
340
  const [query, setQuery] = useState("");
134
- const here = currentPath();
135
- const routes = data ? filterRoutes(data.routes, query) : [];
136
- const groups = [...new Set(routes.map((route) => groupLabel(route.group)))].sort();
341
+ const [active, setActive] = useState(0);
342
+ const inputRef = useRef(null);
343
+ const here = usePathname();
344
+ const prefs = usePrefs(ctx.app);
345
+ const focusTick = useFilterFocusTick();
346
+ useEffect(() => startNavigationObserver(ctx.app), [ctx.app]);
347
+ useEffect(() => {
348
+ if (focusTick === 0 || !takeFilterFocus()) return;
349
+ const input = inputRef.current;
350
+ if (!input) return;
351
+ input.focus();
352
+ input.select();
353
+ }, [focusTick]);
354
+ const all = data?.routes ?? [];
355
+ const filtered = useMemo(() => filterRoutes(all, query), [all, query]);
356
+ const locale = useMemo(() => currentLocale(here, localesOf(all)), [all, here]);
357
+ const rows = useMemo(() => filtered.flatMap((route) => rowsOf(route, locale)), [filtered, locale]);
358
+ const allRows = useMemo(() => query ? all.flatMap((route) => rowsOf(route, locale)) : rows, [
359
+ all,
360
+ rows,
361
+ query,
362
+ locale
363
+ ]);
364
+ const sections = useMemo(() => {
365
+ const out = [];
366
+ if (!query) {
367
+ const pins = rows.filter((row) => isPinned(row, globs, prefs.pins));
368
+ if (pins.length > 0) out.push({
369
+ label: "Pinned",
370
+ rows: pins
371
+ });
372
+ const recent = recentRows(prefs.recent, allRows);
373
+ if (recent.length > 0) out.push({
374
+ label: "Recent",
375
+ rows: recent
376
+ });
377
+ }
378
+ const groups = [...new Set(filtered.map((route) => groupLabel(route.group)))].sort();
379
+ for (const group of groups) out.push({
380
+ label: group,
381
+ rows: rows.filter((row) => groupLabel(row.route?.group ?? null) === group)
382
+ });
383
+ return out;
384
+ }, [
385
+ query,
386
+ rows,
387
+ allRows,
388
+ filtered,
389
+ globs,
390
+ prefs
391
+ ]);
392
+ const items = useMemo(() => sections.flatMap((section) => section.rows), [sections]);
393
+ const count = items.length;
394
+ useEffect(() => {
395
+ setActive((index) => count === 0 ? 0 : Math.min(index, count - 1));
396
+ }, [count]);
397
+ const go = useCallback((url) => {
398
+ if (navigate) navigate(url);
399
+ else navigateTo(url);
400
+ }, [navigate]);
401
+ const onKeyDown = (event) => {
402
+ switch (event.key) {
403
+ case "ArrowDown":
404
+ event.preventDefault();
405
+ setActive((index) => count === 0 ? 0 : (index + 1) % count);
406
+ break;
407
+ case "ArrowUp":
408
+ event.preventDefault();
409
+ setActive((index) => count === 0 ? 0 : (index - 1 + count) % count);
410
+ break;
411
+ case "Enter": {
412
+ const row = items[active] ?? items[0];
413
+ if (!row) return;
414
+ event.preventDefault();
415
+ go(row.url);
416
+ break;
417
+ }
418
+ case "Escape":
419
+ event.preventDefault();
420
+ ctx.close();
421
+ break;
422
+ default: return;
423
+ }
424
+ };
425
+ const onChange = (value) => {
426
+ setQuery(value);
427
+ setActive(0);
428
+ };
429
+ const onPin = (url) => togglePin(ctx.app, url);
137
430
  const urlCount = data ? data.routes.reduce((n, route) => n + route.urls.length, 0) : 0;
431
+ const unresolved = filtered.filter((route) => route.unresolved.length > 0);
432
+ let offset = 0;
138
433
  return /* @__PURE__ */ jsxs("div", {
139
434
  className: "routes",
140
435
  children: [
@@ -143,17 +438,21 @@ function RoutesPanel({ ctx }) {
143
438
  className: "head",
144
439
  children: [
145
440
  /* @__PURE__ */ jsx("input", {
441
+ ref: inputRef,
146
442
  type: "search",
147
443
  value: query,
148
- onChange: (e) => setQuery(e.target.value),
444
+ onChange: (e) => onChange(e.target.value),
445
+ onKeyDown,
149
446
  placeholder: "Filter routes…",
150
- "aria-label": "Filter routes"
447
+ "aria-label": "Filter routes",
448
+ autoComplete: "off",
449
+ spellCheck: false
151
450
  }),
152
451
  data && /* @__PURE__ */ jsxs("span", {
153
452
  className: "count",
154
453
  title: `${data.routes.length} routes in ${data.dir}`,
155
454
  children: [
156
- routes.length,
455
+ filtered.length,
157
456
  "/",
158
457
  data.routes.length,
159
458
  " · ",
@@ -186,30 +485,62 @@ function RoutesPanel({ ctx }) {
186
485
  "."
187
486
  ]
188
487
  }),
189
- groups.map((group) => /* @__PURE__ */ jsxs("section", {
190
- "aria-label": group,
191
- children: [/* @__PURE__ */ jsx("h3", { children: group }), /* @__PURE__ */ jsx("ul", { children: routes.filter((route) => groupLabel(route.group) === group).map((route) => /* @__PURE__ */ jsx(RouteRow, {
192
- route,
193
- here
194
- }, route.pattern)) })]
195
- }, group))
488
+ sections.map((section) => {
489
+ const start = offset;
490
+ offset += section.rows.length;
491
+ return /* @__PURE__ */ jsxs("section", {
492
+ "aria-label": section.label,
493
+ children: [/* @__PURE__ */ jsx("h3", { children: section.label }), /* @__PURE__ */ jsxs("ul", { children: [section.rows.map((row, i) => /* @__PURE__ */ jsx(RouteRow, {
494
+ row,
495
+ here,
496
+ active: start + i === active,
497
+ pinned: isPinned(row, globs, prefs.pins),
498
+ byGlob: isGlobPinned(row, globs),
499
+ onGo: go,
500
+ onPin
501
+ }, row.id)), unresolved.filter((route) => groupLabel(route.group) === section.label).map((route) => /* @__PURE__ */ jsx(UnresolvedRow, { route }, route.pattern))] })]
502
+ }, section.label);
503
+ })
196
504
  ]
197
505
  });
198
506
  }
199
507
  //#endregion
200
508
  //#region src/plugins/routes/index.tsx
201
509
  /**
202
- * Route index: every page of the app's `app/` tree, dynamic segments filled
203
- * from the fixtures the server half knows, one click away. Client half; the
204
- * scanner lives in `@hansenexus/hud/plugins/routes/server`, which also feeds
205
- * the `hud sweep` CLI.
510
+ * Route index and quick switcher: every page of the app's `app/` tree,
511
+ * dynamic segments filled from the fixtures the server half knows, pinned
512
+ * and recent routes first, one keystroke away. Client half; the scanner lives
513
+ * in `@hansenexus/hud/plugins/routes/server`, which also feeds the `hud sweep`
514
+ * CLI.
206
515
  */
207
- function routes() {
516
+ function routes({ shortcut = "mod+shift+r", pinned = [], navigate } = {}) {
517
+ function RoutesSwitcher({ ctx }) {
518
+ return /* @__PURE__ */ jsx(RoutesPanel, {
519
+ ctx,
520
+ pinned,
521
+ navigate
522
+ });
523
+ }
524
+ function useRoutesBadge({ ctx }) {
525
+ useEffect(() => startNavigationObserver(ctx.app), [ctx.app]);
526
+ return null;
527
+ }
208
528
  return definePlugin({
209
529
  id: ROUTES_ID,
210
530
  title: "Routes",
211
531
  capability: ROUTES_CAPABILITY,
212
- panel: RoutesPanel
532
+ icon: hudIcon("route"),
533
+ badge: useRoutesBadge,
534
+ panel: RoutesSwitcher,
535
+ commands: [{
536
+ id: "go",
537
+ title: "Go to route",
538
+ shortcut,
539
+ run: (ctx) => {
540
+ ctx.open();
541
+ requestFilterFocus();
542
+ }
543
+ }]
213
544
  });
214
545
  }
215
546
  //#endregion
@@ -1,2 +1,2 @@
1
- import { a as SeoLevel, i as SeoGroup, n as SeoSnapshot, o as runSeoChecks, r as SeoCheck, t as seo } from "../index-DcH9V3cU.js";
1
+ import { a as SeoLevel, i as SeoGroup, n as SeoSnapshot, o as runSeoChecks, r as SeoCheck, t as seo } from "../index-BGFyuJyN.js";
2
2
  export { type SeoCheck, type SeoGroup, type SeoLevel, type SeoSnapshot, runSeoChecks, seo };
@@ -1,2 +1,2 @@
1
- import { a as runSeoChecks, t as seo } from "../seo-Dq9q_QkO.js";
1
+ import { a as runSeoChecks, t as seo } from "../seo-BnnGq_vj.js";
2
2
  export { runSeoChecks, seo };
@@ -1,2 +1,2 @@
1
- import { a as VitalsSnapshot, i as VitalRating, n as Vital, r as VitalName, t as vitals } from "../index-ReFbhQ9p.js";
1
+ import { a as VitalsSnapshot, i as VitalRating, n as Vital, r as VitalName, t as vitals } from "../index-B2KCKkN0.js";
2
2
  export { type Vital, type VitalName, type VitalRating, type VitalsSnapshot, vitals };
@@ -1,4 +1,5 @@
1
- import { i as definePlugin } from "../plugins-DVy_vaYr.js";
1
+ import { i as hudIcon } from "../icons-ByDyNq_E.js";
2
+ import { a as ratingTone, i as definePlugin } from "../plugins-CcW_K7c2.js";
2
3
  import { i as useVitals, n as formatVital, r as startVitals } from "../store-CQqIIKTc.js";
3
4
  import { lazy, useEffect } from "react";
4
5
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -14,11 +15,18 @@ function VitalsPill() {
14
15
  "data-rating": lcp?.rating
15
16
  }), lcp ? `LCP ${formatVital("LCP", lcp.value)}` : "LCP –"] });
16
17
  }
18
+ /** The LCP rating as a rail badge; nothing until it is reported. */
19
+ function useVitalsBadge() {
20
+ const tone = ratingTone(useVitals().LCP?.rating);
21
+ return tone ? { tone } : null;
22
+ }
17
23
  /** Core Web Vitals: LCP in the pill, all five metrics in the panel. Client only. */
18
24
  function vitals() {
19
25
  return definePlugin({
20
26
  id: "vitals",
21
27
  title: "Vitals",
28
+ icon: hudIcon("gauge"),
29
+ badge: useVitalsBadge,
22
30
  pill: VitalsPill,
23
31
  panel: VitalsPanel
24
32
  });