@celestia-island/hikari 0.55.358 → 0.55.359
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/HkAboutModal.test.tsx +33 -1
- package/src/components/HkAboutModal.tsx +11 -0
- package/src/components/HkDrawer.scss +14 -4
- package/src/components/HkLoadingVeil.scss +6 -1
- package/src/components/HkMarkdownRenderer.tsx +32 -1
- package/src/components/HkPopover.scss +6 -1
- package/src/components/HkSelect.scss +6 -2
- package/src/components/HkTitleBar.tsx +12 -0
- package/src/components/HkTooltip.tsx +11 -1
- package/src/components/__tests__/hkMarkdownLinks.test.ts +152 -0
- package/src/components/chromeBand.contract.test.ts +54 -1
- package/src/index.ts +17 -0
- package/src/runtime/hyperlink.test.ts +231 -0
- package/src/runtime/hyperlink.ts +294 -0
- package/src/runtime/popupBounds.test.ts +58 -1
- package/src/runtime/popupBounds.ts +45 -2
- package/src/runtime/tooltipBridge.test.ts +88 -0
- package/src/runtime/tooltipBridge.ts +21 -0
- package/src/runtime/tooltipPosition.ts +28 -4
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { afterEach, describe, expect, it } from "vitest";
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
2
|
import { createApp, defineComponent, h, nextTick, ref } from "vue";
|
|
3
3
|
|
|
4
4
|
import { HkAboutModal } from "./HkAboutModal";
|
|
5
5
|
import { setLocale } from "../i18n/context";
|
|
6
|
+
import { provideHyperlinkCoordinator } from "../runtime/hyperlink";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* HkAboutModal contract tests for the branding + redesign waves:
|
|
@@ -77,6 +78,9 @@ afterEach(() => {
|
|
|
77
78
|
app.unmount();
|
|
78
79
|
container.remove();
|
|
79
80
|
}
|
|
81
|
+
provideHyperlinkCoordinator(null);
|
|
82
|
+
vi.unstubAllGlobals();
|
|
83
|
+
vi.restoreAllMocks();
|
|
80
84
|
setLocale("en");
|
|
81
85
|
});
|
|
82
86
|
|
|
@@ -499,4 +503,32 @@ describe("HkAboutModal branding", () => {
|
|
|
499
503
|
);
|
|
500
504
|
expect(subtitle.querySelector(".s-about-modal-subtitle-sep")).toBeTruthy();
|
|
501
505
|
});
|
|
506
|
+
|
|
507
|
+
it("routes a link click through the hyperlink coordinator (never the default)", async () => {
|
|
508
|
+
// The coordination contract (runtime/hyperlink.ts): the About dialog's
|
|
509
|
+
// rows are exactly the "help links" class — on the web face a click
|
|
510
|
+
// must open a hardened new tab through the coordinator, and the
|
|
511
|
+
// anchor's own default must stay dead so the dialog never navigates
|
|
512
|
+
// away. Observed through the resolver half: it saw the About source,
|
|
513
|
+
// and its null verdict swallowed the activation.
|
|
514
|
+
const seen: Array<{ href: string; source: string }> = [];
|
|
515
|
+
provideHyperlinkCoordinator({
|
|
516
|
+
resolve: (info) => {
|
|
517
|
+
seen.push({ href: info.href, source: info.source });
|
|
518
|
+
return null;
|
|
519
|
+
},
|
|
520
|
+
});
|
|
521
|
+
mountAbout({
|
|
522
|
+
links: [{ label: "Homepage", href: "https://example.com" }],
|
|
523
|
+
});
|
|
524
|
+
await flushModal();
|
|
525
|
+
|
|
526
|
+
const link = query<HTMLAnchorElement>('.s-about-modal-link[href="https://example.com"]');
|
|
527
|
+
const event = new MouseEvent("click", { bubbles: true, cancelable: true });
|
|
528
|
+
link.dispatchEvent(event);
|
|
529
|
+
await flushModal();
|
|
530
|
+
|
|
531
|
+
expect(seen).toEqual([{ href: "https://example.com", source: "about" }]);
|
|
532
|
+
expect(event.defaultPrevented).toBe(true);
|
|
533
|
+
});
|
|
502
534
|
});
|
|
@@ -3,6 +3,7 @@ import { Github } from "lucide-vue-next";
|
|
|
3
3
|
import { HBadge, HModal } from "@celestia-island/hikari";
|
|
4
4
|
|
|
5
5
|
import { useI18n } from "../i18n/context";
|
|
6
|
+
import { openHyperlink } from "../runtime/hyperlink";
|
|
6
7
|
|
|
7
8
|
import "./HkAboutModal.scss";
|
|
8
9
|
|
|
@@ -177,6 +178,16 @@ export const HkAboutBody = defineComponent({
|
|
|
177
178
|
href={item.href}
|
|
178
179
|
target="_blank"
|
|
179
180
|
rel="noopener noreferrer"
|
|
181
|
+
// The activation rides the hyperlink coordinator (runtime/
|
|
182
|
+
// hyperlink.ts): a new tab on the web face, the system browser
|
|
183
|
+
// in the native shell — the webview itself never navigates.
|
|
184
|
+
// The href/target attributes stay for semantics and the
|
|
185
|
+
// browser's link menu; only the left-click default is taken
|
|
186
|
+
// over.
|
|
187
|
+
onClick={(event: MouseEvent) => {
|
|
188
|
+
event.preventDefault();
|
|
189
|
+
void openHyperlink(item.href, { source: "about" });
|
|
190
|
+
}}
|
|
180
191
|
// A text link is named by its own label unless the host names it
|
|
181
192
|
// explicitly; an icon-only link has no text to be named by, so it
|
|
182
193
|
// always needs a name of its own.
|
|
@@ -7,7 +7,13 @@
|
|
|
7
7
|
* through to the page below (2026-10-15 defect). */
|
|
8
8
|
pointer-events: auto;
|
|
9
9
|
position: fixed;
|
|
10
|
-
inset:
|
|
10
|
+
/* --hk-chrome-band-inset: the chrome-band geometry leg (see
|
|
11
|
+
* .hk-modal-overlay) — the dim/blur curtain yields its top edge to the
|
|
12
|
+
* host caption band on native shells, same as every windowed veil. */
|
|
13
|
+
top: var(--hk-chrome-band-inset, 0px);
|
|
14
|
+
right: 0;
|
|
15
|
+
bottom: 0;
|
|
16
|
+
left: 0;
|
|
11
17
|
background: var(--hk-drawer-overlay-bg, rgba(0, 0, 0, 0.45));
|
|
12
18
|
@include backdrop-filter(var(--hk-drawer-overlay-blur, blur(6px)));
|
|
13
19
|
}
|
|
@@ -47,7 +53,9 @@
|
|
|
47
53
|
}
|
|
48
54
|
|
|
49
55
|
.hk-drawer-left {
|
|
50
|
-
|
|
56
|
+
/* Panels dock BELOW the caption band too (geometry leg): the drawer
|
|
57
|
+
* slides in under the host caption, never over it. */
|
|
58
|
+
top: var(--hk-chrome-band-inset, 0px);
|
|
51
59
|
bottom: 0;
|
|
52
60
|
left: 0;
|
|
53
61
|
border-right: 1px solid var(--hi-color-border, rgba(100,100,100,0.08));
|
|
@@ -55,7 +63,8 @@
|
|
|
55
63
|
}
|
|
56
64
|
|
|
57
65
|
.hk-drawer-right {
|
|
58
|
-
|
|
66
|
+
/* Below the caption band, same as the left panel. */
|
|
67
|
+
top: var(--hk-chrome-band-inset, 0px);
|
|
59
68
|
bottom: 0;
|
|
60
69
|
right: 0;
|
|
61
70
|
border-left: 1px solid var(--hi-color-border, rgba(100,100,100,0.08));
|
|
@@ -63,7 +72,8 @@
|
|
|
63
72
|
}
|
|
64
73
|
|
|
65
74
|
.hk-drawer-top {
|
|
66
|
-
|
|
75
|
+
/* Below the caption band, same as the side panels. */
|
|
76
|
+
top: var(--hk-chrome-band-inset, 0px);
|
|
67
77
|
left: 0;
|
|
68
78
|
right: 0;
|
|
69
79
|
border-bottom: 1px solid var(--hi-color-border, rgba(100,100,100,0.08));
|
|
@@ -7,7 +7,12 @@
|
|
|
7
7
|
|
|
8
8
|
.hk-loading-veil {
|
|
9
9
|
position: fixed;
|
|
10
|
-
|
|
10
|
+
/* The chrome-band geometry leg: the blocking veil starts below the
|
|
11
|
+
* host caption band on native shells (see .hk-modal-overlay). */
|
|
12
|
+
top: var(--hk-chrome-band-inset, 0px);
|
|
13
|
+
right: 0;
|
|
14
|
+
bottom: 0;
|
|
15
|
+
left: 0;
|
|
11
16
|
z-index: var(--hk-overlay-z-veil, 150);
|
|
12
17
|
display: flex;
|
|
13
18
|
align-items: center;
|
|
@@ -5,6 +5,7 @@ import HkMermaidDiagram from "./HkMermaidDiagram";
|
|
|
5
5
|
import { applyInlineChipsToBody } from "./inlineChips";
|
|
6
6
|
import { attachOverlayScrollbars, type OverlayScrollbarHandle } from "../composables/useOverlayScrollbar";
|
|
7
7
|
import { getMermaidEngine } from "../mermaid/engine";
|
|
8
|
+
import { openHyperlink } from "../runtime/hyperlink";
|
|
8
9
|
import { asIndexable } from "../utils/typing";
|
|
9
10
|
import "./HkMarkdownRenderer.scss";
|
|
10
11
|
|
|
@@ -149,6 +150,13 @@ export default defineComponent({
|
|
|
149
150
|
* consumer renders exactly as before.
|
|
150
151
|
*/
|
|
151
152
|
inlineChips: { type: Boolean, default: false },
|
|
153
|
+
/**
|
|
154
|
+
* Opaque per-surface tag carried on every link activation this body
|
|
155
|
+
* fires — the host coordinator scopes its resolution with it (the
|
|
156
|
+
* chest tags vendored protocol docs so their relative links map to
|
|
157
|
+
* the docs site). Never interpreted by hikari itself.
|
|
158
|
+
*/
|
|
159
|
+
linkContext: { type: String, default: undefined },
|
|
152
160
|
},
|
|
153
161
|
setup(props) {
|
|
154
162
|
const renderedHtml = ref("");
|
|
@@ -266,9 +274,32 @@ export default defineComponent({
|
|
|
266
274
|
mermaidApps.length = 0;
|
|
267
275
|
});
|
|
268
276
|
|
|
277
|
+
// THE link path (runtime/hyperlink.ts): every anchor this body
|
|
278
|
+
// renders activates through the coordinator — a plain browser opens a
|
|
279
|
+
// new tab, the native shell hands the URL to the system browser, and
|
|
280
|
+
// the webview itself NEVER navigates (the 2026-11-12 protocol-modal
|
|
281
|
+
// 404 was exactly an anchor left to its default behavior). All
|
|
282
|
+
// modifier combos intercept too: ctrl/middle-click on the desktop
|
|
283
|
+
// would otherwise navigate the app window the same way.
|
|
284
|
+
function onBodyClick(event: MouseEvent): void {
|
|
285
|
+
const target = event.target as HTMLElement | null;
|
|
286
|
+
const anchor = target?.closest?.("a[href]") as HTMLAnchorElement | null;
|
|
287
|
+
if (!anchor) return;
|
|
288
|
+
event.preventDefault();
|
|
289
|
+
void openHyperlink(anchor.getAttribute("href") ?? "", {
|
|
290
|
+
source: "markdown",
|
|
291
|
+
...(props.linkContext !== undefined ? { linkContext: props.linkContext } : {}),
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
|
|
269
295
|
return () => (
|
|
270
296
|
<div class="hk-markdown" data-plain={props.plain || undefined} data-loading={props.loading}>
|
|
271
|
-
<div
|
|
297
|
+
<div
|
|
298
|
+
ref={bodyRef}
|
|
299
|
+
class="hk-markdown-body"
|
|
300
|
+
innerHTML={renderedHtml.value}
|
|
301
|
+
onClick={onBodyClick}
|
|
302
|
+
/>
|
|
272
303
|
{props.loading && (
|
|
273
304
|
<div class="hk-markdown-overlay">
|
|
274
305
|
<HSpinner center />
|
|
@@ -103,7 +103,12 @@
|
|
|
103
103
|
// ------
|
|
104
104
|
.hk-popover-scrim {
|
|
105
105
|
position: fixed;
|
|
106
|
-
|
|
106
|
+
/* The chrome-band geometry leg (see .hk-modal-overlay): the sheet's
|
|
107
|
+
* dim curtain yields its top edge to the host caption band. */
|
|
108
|
+
top: var(--hk-chrome-band-inset, 0px);
|
|
109
|
+
right: 0;
|
|
110
|
+
bottom: 0;
|
|
111
|
+
left: 0;
|
|
107
112
|
pointer-events: auto;
|
|
108
113
|
background: rgb(0 0 0 / 40%);
|
|
109
114
|
}
|
|
@@ -292,8 +292,12 @@
|
|
|
292
292
|
.hk-select-sheet-scrim {
|
|
293
293
|
pointer-events: auto;
|
|
294
294
|
position: fixed;
|
|
295
|
-
|
|
296
|
-
|
|
295
|
+
/* The chrome-band geometry leg (see .hk-modal-overlay): the sheet's
|
|
296
|
+
* dim curtain yields its top edge to the host caption band. */
|
|
297
|
+
top: var(--hk-chrome-band-inset, 0px);
|
|
298
|
+
right: 0;
|
|
299
|
+
bottom: 0;
|
|
300
|
+
left: 0;
|
|
297
301
|
background: rgb(0 0 0 / 40%);
|
|
298
302
|
}
|
|
299
303
|
|
|
@@ -96,6 +96,9 @@ export default defineComponent({
|
|
|
96
96
|
class="hk-titlebar-btn"
|
|
97
97
|
title={a.label}
|
|
98
98
|
aria-label={a.label}
|
|
99
|
+
// Caption-row trigger: the tooltip MAY pin over the strip —
|
|
100
|
+
// the explicit band-overlap exemption (runtime/tooltipBridge).
|
|
101
|
+
data-hk-tooltip-band-overlap="true"
|
|
99
102
|
onClick={(e: MouseEvent) => {
|
|
100
103
|
e.stopPropagation();
|
|
101
104
|
emit("action", a.id);
|
|
@@ -110,6 +113,9 @@ export default defineComponent({
|
|
|
110
113
|
class="hk-titlebar-btn"
|
|
111
114
|
title={t("hikari::titleBar.minimize", "Minimize")}
|
|
112
115
|
aria-label={t("hikari::titleBar.minimize", "Minimize")}
|
|
116
|
+
// Caption-row trigger: the tooltip MAY pin over the strip —
|
|
117
|
+
// the explicit band-overlap exemption (runtime/tooltipBridge).
|
|
118
|
+
data-hk-tooltip-band-overlap="true"
|
|
113
119
|
onClick={(e: MouseEvent) => {
|
|
114
120
|
e.stopPropagation();
|
|
115
121
|
emit("minimize");
|
|
@@ -124,6 +130,9 @@ export default defineComponent({
|
|
|
124
130
|
class="hk-titlebar-btn"
|
|
125
131
|
title={props.maximized ? t("hikari::titleBar.restore", "Restore") : t("hikari::titleBar.maximize", "Maximize")}
|
|
126
132
|
aria-label={props.maximized ? t("hikari::titleBar.restore", "Restore") : t("hikari::titleBar.maximize", "Maximize")}
|
|
133
|
+
// Caption-row trigger: the tooltip MAY pin over the strip —
|
|
134
|
+
// the explicit band-overlap exemption (runtime/tooltipBridge).
|
|
135
|
+
data-hk-tooltip-band-overlap="true"
|
|
127
136
|
onClick={(e: MouseEvent) => {
|
|
128
137
|
e.stopPropagation();
|
|
129
138
|
emit("toggle-maximize");
|
|
@@ -142,6 +151,9 @@ export default defineComponent({
|
|
|
142
151
|
class="hk-titlebar-btn hk-titlebar-btn-close"
|
|
143
152
|
title={t("hikari::titleBar.close", "Close")}
|
|
144
153
|
aria-label={t("hikari::titleBar.close", "Close")}
|
|
154
|
+
// Caption-row trigger: the tooltip MAY pin over the strip —
|
|
155
|
+
// the explicit band-overlap exemption (runtime/tooltipBridge).
|
|
156
|
+
data-hk-tooltip-band-overlap="true"
|
|
145
157
|
onClick={(e: MouseEvent) => {
|
|
146
158
|
e.stopPropagation();
|
|
147
159
|
emit("close");
|
|
@@ -56,6 +56,14 @@ export default defineComponent({
|
|
|
56
56
|
* ignored in this mode.
|
|
57
57
|
*/
|
|
58
58
|
trigger: { type: String as PropType<TooltipTrigger>, default: "hover" },
|
|
59
|
+
/**
|
|
60
|
+
* The EXPLICIT caption-band exemption (2026-11-12 user direction):
|
|
61
|
+
* default false — the placed bubble keeps at least a 4px gap under the
|
|
62
|
+
* host caption strip (popupBounds floors the popup frame at the
|
|
63
|
+
* chrome-band inset); true lets the bubble pin over the strip, for
|
|
64
|
+
* triggers that live ON the caption (the title bar's own buttons).
|
|
65
|
+
*/
|
|
66
|
+
allowBandOverlap: { type: Boolean, default: false },
|
|
59
67
|
},
|
|
60
68
|
slots: Object as SlotsType<{
|
|
61
69
|
default?: (props: HkTooltipSlotProps) => unknown;
|
|
@@ -113,7 +121,9 @@ export default defineComponent({
|
|
|
113
121
|
// that keeps the measured bubble inside the viewport gutter (flip,
|
|
114
122
|
// cap, shift) instead of spilling off-screen or shrinking to the
|
|
115
123
|
// containing block's leftover space.
|
|
116
|
-
applyTooltipPosition(popupRef.value, rect, props.placement, props.maxWidth
|
|
124
|
+
applyTooltipPosition(popupRef.value, rect, props.placement, props.maxWidth, {
|
|
125
|
+
allowBandOverlap: props.allowBandOverlap,
|
|
126
|
+
});
|
|
117
127
|
}
|
|
118
128
|
|
|
119
129
|
function stopPositionTracking() {
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { createApp, defineComponent, h, nextTick, ref } from "vue";
|
|
3
|
+
|
|
4
|
+
import HkMarkdownRenderer from "../HkMarkdownRenderer";
|
|
5
|
+
import { provideHyperlinkCoordinator } from "../../runtime/hyperlink";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The markdown link activation contract (runtime/hyperlink.ts): every
|
|
9
|
+
* anchor a rendered body carries activates through the coordinator — the
|
|
10
|
+
* web face opens a hardened new tab, the native shell hands the URL to
|
|
11
|
+
* the opener bridge — and the anchor's default is ALWAYS taken over, so
|
|
12
|
+
* the webview itself never navigates (the 2026-11-12 protocol-modal 404:
|
|
13
|
+
* the chest login window followed a vendored relative href onto the app
|
|
14
|
+
* origin). The linkContext prop rides the activation for host resolvers.
|
|
15
|
+
*
|
|
16
|
+
* (Repo test convention: raw createApp + document queries, no
|
|
17
|
+
* @vue/test-utils dependency.)
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const mounts: Array<{ app: ReturnType<typeof createApp>; container: HTMLElement }> = [];
|
|
21
|
+
|
|
22
|
+
async function mountMarkdown(content: string, linkContext?: string): Promise<void> {
|
|
23
|
+
const container = document.createElement("div");
|
|
24
|
+
document.body.appendChild(container);
|
|
25
|
+
const Wrapper = defineComponent({
|
|
26
|
+
setup() {
|
|
27
|
+
return () =>
|
|
28
|
+
h(HkMarkdownRenderer, {
|
|
29
|
+
content,
|
|
30
|
+
...(linkContext !== undefined ? { linkContext } : {}),
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
const app = createApp(Wrapper);
|
|
35
|
+
app.mount(container);
|
|
36
|
+
mounts.push({ app, container });
|
|
37
|
+
// The renderer lazy-imports marked + DOMPurify on the first non-plain
|
|
38
|
+
// parse — POLL for the rendered body (the chest suites learned this
|
|
39
|
+
// the same way: a fixed settle races the module transform).
|
|
40
|
+
for (let i = 0; i < 100; i += 1) {
|
|
41
|
+
await nextTick();
|
|
42
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
43
|
+
if (document.body.querySelector(".hk-markdown-body a[href]")) return;
|
|
44
|
+
}
|
|
45
|
+
throw new Error(
|
|
46
|
+
"markdown body never rendered an anchor; body HTML: " +
|
|
47
|
+
(document.body.querySelector(".hk-markdown-body")?.innerHTML ?? "(no body)") +
|
|
48
|
+
" / rendered: " +
|
|
49
|
+
(document.body.querySelector(".hk-markdown")?.outerHTML.slice(0, 300) ?? "(none)"),
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function bodyAnchor(href: string): HTMLAnchorElement {
|
|
54
|
+
const anchor = document.body.querySelector<HTMLAnchorElement>(
|
|
55
|
+
'.hk-markdown-body a[href="' + href + '"]',
|
|
56
|
+
);
|
|
57
|
+
expect(anchor, 'anchor "' + href + '" renders').toBeTruthy();
|
|
58
|
+
return anchor!;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
afterEach(() => {
|
|
62
|
+
for (const { app, container } of mounts.splice(0)) {
|
|
63
|
+
app.unmount();
|
|
64
|
+
container.remove();
|
|
65
|
+
}
|
|
66
|
+
provideHyperlinkCoordinator(null);
|
|
67
|
+
vi.unstubAllGlobals();
|
|
68
|
+
vi.restoreAllMocks();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
describe("markdown link activation", () => {
|
|
72
|
+
it("opens an external anchor in a hardened new tab on the web face", async () => {
|
|
73
|
+
const open = vi.fn(() => ({}));
|
|
74
|
+
vi.stubGlobal("open", open);
|
|
75
|
+
|
|
76
|
+
await mountMarkdown("[CLA](https://docs.celestia.world/meta/cla.html)");
|
|
77
|
+
const anchor = bodyAnchor("https://docs.celestia.world/meta/cla.html");
|
|
78
|
+
anchor.dispatchEvent(
|
|
79
|
+
new MouseEvent("click", { bubbles: true, cancelable: true }),
|
|
80
|
+
);
|
|
81
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
82
|
+
|
|
83
|
+
expect(open).toHaveBeenCalledWith(
|
|
84
|
+
"https://docs.celestia.world/meta/cla.html",
|
|
85
|
+
"_blank",
|
|
86
|
+
"noopener,noreferrer",
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("never lets the anchor default through (the webview must not navigate)", async () => {
|
|
91
|
+
const open = vi.fn(() => ({}));
|
|
92
|
+
vi.stubGlobal("open", open);
|
|
93
|
+
|
|
94
|
+
const locationBefore = window.location.href;
|
|
95
|
+
await mountMarkdown("[guide](cla.md)", "protocol");
|
|
96
|
+
const anchor = bodyAnchor("cla.md");
|
|
97
|
+
const event = new MouseEvent("click", { bubbles: true, cancelable: true });
|
|
98
|
+
anchor.dispatchEvent(event);
|
|
99
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
100
|
+
|
|
101
|
+
// The DEFAULT is taken over (the webview never follows the href); the
|
|
102
|
+
// web face instead opens the resolved tab — the open() call IS the
|
|
103
|
+
// designed routing here, the assertion is that no navigation happened.
|
|
104
|
+
expect(event.defaultPrevented).toBe(true);
|
|
105
|
+
expect(window.location.href).toBe(locationBefore);
|
|
106
|
+
expect(open).toHaveBeenCalledTimes(1);
|
|
107
|
+
const firstCall = open.mock.calls[0] as unknown as [string] | undefined;
|
|
108
|
+
expect(firstCall?.[0]).toBe(new URL("cla.md", document.baseURI).href);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("carries the linkContext so the host resolver can canonicalize", async () => {
|
|
112
|
+
const open = vi.fn(() => ({}));
|
|
113
|
+
vi.stubGlobal("open", open);
|
|
114
|
+
const seen: Array<{ href: string; linkContext?: string; source: string }> = [];
|
|
115
|
+
provideHyperlinkCoordinator({
|
|
116
|
+
resolve: (info) => {
|
|
117
|
+
seen.push({ href: info.href, linkContext: info.linkContext, source: info.source });
|
|
118
|
+
return null; // swallow — this pin only observes the handoff
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
await mountMarkdown("[CLA](cla.md)", "protocol");
|
|
123
|
+
bodyAnchor("cla.md").dispatchEvent(
|
|
124
|
+
new MouseEvent("click", { bubbles: true, cancelable: true }),
|
|
125
|
+
);
|
|
126
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
127
|
+
|
|
128
|
+
expect(seen).toEqual([
|
|
129
|
+
{ href: "cla.md", linkContext: "protocol", source: "markdown" },
|
|
130
|
+
]);
|
|
131
|
+
expect(open).not.toHaveBeenCalled();
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it("activates through the opener IPC on the native shell", async () => {
|
|
135
|
+
const invoke = vi.fn(() => Promise.resolve());
|
|
136
|
+
vi.stubGlobal("__TAURI_INTERNALS__", { invoke });
|
|
137
|
+
const open = vi.fn();
|
|
138
|
+
vi.stubGlobal("open", open);
|
|
139
|
+
|
|
140
|
+
await mountMarkdown("[site](https://example.com)");
|
|
141
|
+
bodyAnchor("https://example.com").dispatchEvent(
|
|
142
|
+
new MouseEvent("click", { bubbles: true, cancelable: true }),
|
|
143
|
+
);
|
|
144
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
145
|
+
|
|
146
|
+
expect(invoke).toHaveBeenCalledWith("plugin:opener|open_url", {
|
|
147
|
+
url: "https://example.com",
|
|
148
|
+
with: null,
|
|
149
|
+
});
|
|
150
|
+
expect(open).not.toHaveBeenCalled();
|
|
151
|
+
});
|
|
152
|
+
});
|
|
@@ -41,7 +41,13 @@ import { fileURLToPath } from "node:url";
|
|
|
41
41
|
* the contract — keep the prose home in sync);
|
|
42
42
|
* 7. the GEOMETRY leg exists: both HkModal fixed plates read
|
|
43
43
|
* --hk-chrome-band-inset on their top edge (the stacking-proof
|
|
44
|
-
* fallback for hosts whose wrappers trap the band)
|
|
44
|
+
* fallback for hosts whose wrappers trap the band), and so does
|
|
45
|
+
* every OTHER windowed veil the library ships — the drawer's
|
|
46
|
+
* overlay and its left/right/top panels, the loading veil, and the
|
|
47
|
+
* mobile sheet scrims of the popover and the select panel (2026-11-12
|
|
48
|
+
* extension: the modal got the leg first; a drawer or a blocking
|
|
49
|
+
* veil covering the caption row again would be the same field
|
|
50
|
+
* report with a different component).
|
|
45
51
|
*/
|
|
46
52
|
|
|
47
53
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
@@ -52,6 +58,13 @@ const adminHeader = readFileSync(join(here, "HkAdminHeader.tsx"), "utf8");
|
|
|
52
58
|
const titleBarScss = readFileSync(join(here, "HkTitleBar.scss"), "utf8");
|
|
53
59
|
const windowControls = readFileSync(join(here, "HkWindowControls.tsx"), "utf8");
|
|
54
60
|
const modalScss = readFileSync(join(here, "HkModal.scss"), "utf8");
|
|
61
|
+
const drawerScss = readFileSync(join(here, "HkDrawer.scss"), "utf8");
|
|
62
|
+
const veilScss = readFileSync(join(here, "HkLoadingVeil.scss"), "utf8");
|
|
63
|
+
const selectScss = readFileSync(join(here, "HkSelect.scss"), "utf8");
|
|
64
|
+
const popoverScss = readFileSync(join(here, "HkPopover.scss"), "utf8");
|
|
65
|
+
const titleBarTsx = readFileSync(join(here, "HkTitleBar.tsx"), "utf8");
|
|
66
|
+
const tooltipBridge = readFileSync(join(here, "..", "runtime", "tooltipBridge.ts"), "utf8");
|
|
67
|
+
const popupBounds = readFileSync(join(here, "..", "runtime", "popupBounds.ts"), "utf8");
|
|
55
68
|
|
|
56
69
|
/** The numeric value a root z-token declaration carries, or null. */
|
|
57
70
|
function rootTokenZ(source: string, token: string): number | null {
|
|
@@ -179,4 +192,44 @@ describe("chrome-band layer contract (the host caption stayed under the veil)",
|
|
|
179
192
|
it("names .hk-chrome-band on HkWindowControls (the prose home)", () => {
|
|
180
193
|
expect(windowControls).toContain(".hk-chrome-band");
|
|
181
194
|
});
|
|
195
|
+
|
|
196
|
+
it("yields the other windowed veils' top edge to --hk-chrome-band-inset", () => {
|
|
197
|
+
// The geometry leg across the windowed family: every fixed dim/blur
|
|
198
|
+
// curtain (and every panel that would physically cover the band row)
|
|
199
|
+
// starts BELOW the host caption band. A missing leg on any of these
|
|
200
|
+
// re-dims — or re-covers — the caption row on native shells.
|
|
201
|
+
const expectInset = (source: string, selector: string, file: string) => {
|
|
202
|
+
const rules = allRuleDeclarations(source, selector).filter((r) => !r.nested);
|
|
203
|
+
expect(rules.length, selector + " in " + file + " must exist at top level").toBe(1);
|
|
204
|
+
expect(rules[0].decls).toContainEqual(["top", "var(--hk-chrome-band-inset, 0px)"]);
|
|
205
|
+
};
|
|
206
|
+
expectInset(drawerScss, ".hk-drawer-overlay", "HkDrawer.scss");
|
|
207
|
+
expectInset(drawerScss, ".hk-drawer-left", "HkDrawer.scss");
|
|
208
|
+
expectInset(drawerScss, ".hk-drawer-right", "HkDrawer.scss");
|
|
209
|
+
expectInset(drawerScss, ".hk-drawer-top", "HkDrawer.scss");
|
|
210
|
+
expectInset(veilScss, ".hk-loading-veil", "HkLoadingVeil.scss");
|
|
211
|
+
expectInset(selectScss, ".hk-select-sheet-scrim", "HkSelect.scss");
|
|
212
|
+
expectInset(popoverScss, ".hk-popover-scrim", "HkPopover.scss");
|
|
213
|
+
// A BOTTOM-docked drawer still owns its bottom edge — the inset is a
|
|
214
|
+
// top-edge contract only.
|
|
215
|
+
const bottom = allRuleDeclarations(drawerScss, ".hk-drawer-bottom").filter((r) => !r.nested);
|
|
216
|
+
expect(bottom[0].decls).not.toContainEqual(["top", "var(--hk-chrome-band-inset, 0px)"]);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
it("keeps tooltips off the band by default with an explicit exemption", () => {
|
|
220
|
+
// The tooltip leg of the contract (2026-11-12 user direction): the
|
|
221
|
+
// popup frame floors at the band inset + POPUP_BAND_GAP_PX (4) —
|
|
222
|
+
// default NO cover; pinning over the strip is an explicit per-trigger
|
|
223
|
+
// marker or install option, which the caption's OWN buttons carry.
|
|
224
|
+
// Three pins: the floor exists, the bridge reads the marker, and the
|
|
225
|
+
// title bar's buttons carry it.
|
|
226
|
+
expect(popupBounds).toMatch(/bandInset > 0 \? bandInset \+ POPUP_BAND_GAP_PX : 0/);
|
|
227
|
+
expect(popupBounds).toContain("POPUP_BAND_GAP_PX = 4");
|
|
228
|
+
expect(tooltipBridge).toContain('data-hk-tooltip-band-overlap');
|
|
229
|
+
expect(tooltipBridge).toMatch(/el\.hasAttribute\(\"data-hk-tooltip-band-overlap\"\)/);
|
|
230
|
+
// Every caption-row button of the reference title bar opts in —
|
|
231
|
+
// custom actions, minimize, maximize/restore, close.
|
|
232
|
+
const markers = (titleBarTsx.match(/data-hk-tooltip-band-overlap="true"/g) ?? []).length;
|
|
233
|
+
expect(markers, "all four caption buttons must carry the exemption").toBe(4);
|
|
234
|
+
});
|
|
182
235
|
});
|
package/src/index.ts
CHANGED
|
@@ -1072,6 +1072,23 @@ export {
|
|
|
1072
1072
|
RESIZE_FALLBACK_TICKS,
|
|
1073
1073
|
type WindowApiLike,
|
|
1074
1074
|
} from "./runtime/windowChrome";
|
|
1075
|
+
// THE hyperlink coordination context (runtime/hyperlink.ts): every link
|
|
1076
|
+
// activation — markdown anchors, About-dialog rows, host surfaces — goes
|
|
1077
|
+
// through openHyperlink so the environment picks the destination (new tab
|
|
1078
|
+
// on the web, the system browser in the native shell) and the webview
|
|
1079
|
+
// itself never navigates. Hosts register resolve/open overrides once at
|
|
1080
|
+
// bootstrap with provideHyperlinkCoordinator.
|
|
1081
|
+
export {
|
|
1082
|
+
classifyHyperlink,
|
|
1083
|
+
openExternalHyperlink,
|
|
1084
|
+
openHyperlink,
|
|
1085
|
+
provideHyperlinkCoordinator,
|
|
1086
|
+
useHyperlinkCoordinator,
|
|
1087
|
+
type HyperlinkCoordinator,
|
|
1088
|
+
type HyperlinkInfo,
|
|
1089
|
+
type HyperlinkKind,
|
|
1090
|
+
type HyperlinkSource,
|
|
1091
|
+
} from "./runtime/hyperlink";
|
|
1075
1092
|
// Pre-boot caption bar (`bootChromePlugin`) is NOT exported here. It ships from
|
|
1076
1093
|
// its own published subpath — `@celestia-island/hikari/plugins/boot-chrome` —
|
|
1077
1094
|
// resolved to a self-contained ESM module, and that is what a host imports in
|