@celestia-island/hikari 0.55.399 → 0.55.401

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celestia-island/hikari",
3
- "version": "0.55.399",
3
+ "version": "0.55.401",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Hikari UI library, Vue 3 runtime — one design system for Vue 3 and Rust/WASM applications",
@@ -1,13 +1,73 @@
1
1
  /**
2
2
  * HkDockBar.scss — the shared dock surface chrome (single source of
3
- * truth). `--hk-dock-inset` is declared by the foundation layer so every
4
- * dock reads a defined value; change it once, all surfaces move
5
- * together.
3
+ * truth).
4
+ *
5
+ * Geometry contract — the dock edge gap family (2026-11-15). A dock owns
6
+ * BOTH distances on its content side, and reads both from ONE token
7
+ * family:
8
+ *
9
+ * 1. RESTING INSET — how far the dock box sits from the viewport edge it
10
+ * hugs, plus that edge's safe-area inset (0 on desktop, so the gap is
11
+ * the visual distance everywhere a notch is absent);
12
+ * 2. CONTENT BAND — a transparent padding on the face that points at the
13
+ * content, so content never comes closer to the surface than the same
14
+ * gap.
15
+ *
16
+ * G(edge) = var(--hk-dock-gap-<edge>, var(--hk-dock-inset, var(--hk-dock-gap, var(--space-16, 1rem))))
17
+ *
18
+ * `--hk-dock-gap` is DECLARED exactly once, on `:root` in scale.scss (16px
19
+ * by default); `--hk-dock-gap-<edge>` and the older single-value
20
+ * `--hk-dock-inset` are override-only (any host ancestor, or inline), and
21
+ * the `gap` prop writes `--hk-dock-gap` inline on the dock itself.
22
+ *
23
+ * The per-edge public names are NEVER pre-declared: a custom property
24
+ * resolves on the element that DECLARES it, so a `:root`-level
25
+ * `--hk-dock-gap-bottom: var(--hk-dock-gap)` would freeze the bottom edge
26
+ * against every descendant `--hk-dock-gap` override (the cascade trap this
27
+ * contract exists to avoid). The four `--_hk-dock-gap-*` private names
28
+ * below are the ONLY place the fallback chain is written, and they are
29
+ * resolved on the dock element itself.
30
+ *
31
+ * Why the band lives in the DOCK's box, never in a view padding:
32
+ * - pin slot — the dock is a flex SIBLING of the scroll viewport, so the
33
+ * wrapper box IS the dock box (band + surface + inset) and the viewport
34
+ * yields the band by layout: the content end rests `gap` above the
35
+ * surface with NO view padding at all, so a content box that inflates
36
+ * itself to `min-height: 100%` cannot resurrect the phantom-scroll
37
+ * trap;
38
+ * - floating docks (page / plane) — the occupancy a host measures and
39
+ * publishes (its own getBoundingClientRect, which already includes
40
+ * padding) now contains the band, so a consumer's tail reservation
41
+ * automatically becomes "surface + inset + band" and no JS ever has to
42
+ * read a CSS length.
43
+ *
44
+ * Which is also why HkScrollContainer's measurement / gate formulas did not
45
+ * change: they read scrollHeight / clientHeight / gBCR, all decided by
46
+ * layout — this sheet only changes what the dock's own box contains.
47
+ *
48
+ * PHYSICAL bands on the inline faces (2026-11-15, review S1). The anchors are
49
+ * physical too: `left` / `right` and `env(safe-area-inset-left/right)` mean the
50
+ * literal edges, not the writing-mode ones. A logical band — a
51
+ * `padding-inline-start` / `padding-inline-end` — therefore flips under
52
+ * `dir="rtl"`: on a left-anchored dock it would land on the SAME side as the
53
+ * pinned edge (the surface pushed one gap further in, reading `gap + gap` from
54
+ * the edge) while the face that actually points at the content stays bare, so
55
+ * content touches the surface again. The block axis is direction-independent
56
+ * in the writing modes a dock lives in, so `padding-block-start/end` stay
57
+ * logical.
6
58
  */
7
59
 
8
60
  @use "../styles/polyfill" as *;
9
61
 
10
62
  .hk-dock-bar {
63
+ /* The edge gap family, resolved once per edge. Read by the anchor rules
64
+ * below (inset) and by the surface rules (max-width / max-height); never
65
+ * set by a host — a host overrides the PUBLIC names in the chain. */
66
+ --_hk-dock-gap-top: var(--hk-dock-gap-top, var(--hk-dock-inset, var(--hk-dock-gap, var(--space-16, 1rem))));
67
+ --_hk-dock-gap-right: var(--hk-dock-gap-right, var(--hk-dock-inset, var(--hk-dock-gap, var(--space-16, 1rem))));
68
+ --_hk-dock-gap-bottom: var(--hk-dock-gap-bottom, var(--hk-dock-inset, var(--hk-dock-gap, var(--space-16, 1rem))));
69
+ --_hk-dock-gap-left: var(--hk-dock-gap-left, var(--hk-dock-inset, var(--hk-dock-gap, var(--space-16, 1rem))));
70
+
11
71
  /* Transparent anchor box — never intercepts canvas gestures around
12
72
  * the docked surface. */
13
73
  pointer-events: none;
@@ -17,22 +77,25 @@
17
77
  gap: var(--space-4, 4px);
18
78
 
19
79
  /* ── page anchor (SOUTH edge): absolute bottom-center of the nearest
20
- * positioned ancestor, resting --hk-dock-inset above its content
21
- * floor. `bottom` below is the compass spelling of the same
22
- * geometry. */
80
+ * positioned ancestor, resting one bottom gap above its content
81
+ * floor; the block-start band is the content side. `bottom` below is
82
+ * the compass spelling of the same geometry. */
23
83
  &[data-anchor="page"] {
24
84
  position: absolute;
25
85
  left: 50%;
26
- bottom: var(--hk-dock-inset, 12px);
86
+ bottom: calc(var(--_hk-dock-gap-bottom) + env(safe-area-inset-bottom, 0px));
27
87
  transform: translateX(-50%);
28
88
  z-index: 50;
89
+ padding-block-start: var(--_hk-dock-gap-bottom);
29
90
  }
30
91
 
31
92
  /* ── plane anchor: in-flow inside a host plane (a fixed footer band);
32
93
  * the host owns the positioning, this container centers the
33
- * surface horizontally and lifts it by the shared dock inset. */
94
+ * surface horizontally, lifts it by one bottom gap and opens the
95
+ * same gap above it toward the content. */
34
96
  &[data-anchor="plane"] {
35
- margin: 0 auto var(--hk-dock-inset, 12px);
97
+ margin: 0 auto calc(var(--_hk-dock-gap-bottom) + env(safe-area-inset-bottom, 0px));
98
+ padding-block-start: var(--_hk-dock-gap-bottom);
36
99
  }
37
100
 
38
101
  /* ── horizontal edge anchors: north and the compass spelling of the
@@ -46,15 +109,19 @@
46
109
  }
47
110
 
48
111
  &[data-anchor="top"] {
49
- top: var(--hk-dock-inset, 12px);
112
+ top: calc(var(--_hk-dock-gap-top) + env(safe-area-inset-top, 0px));
113
+ padding-block-end: var(--_hk-dock-gap-top);
50
114
  }
51
115
 
52
116
  &[data-anchor="bottom"] {
53
- bottom: var(--hk-dock-inset, 12px);
117
+ bottom: calc(var(--_hk-dock-gap-bottom) + env(safe-area-inset-bottom, 0px));
118
+ padding-block-start: var(--_hk-dock-gap-bottom);
54
119
  }
55
120
 
56
121
  /* ── vertical edge anchors (west / east): the dock runs vertically,
57
- * centered on the edge midpoint. */
122
+ * centered on the edge midpoint, with the band on the PHYSICAL side
123
+ * that faces the content (see the header note: a logical padding would
124
+ * flip under dir="rtl" and leave the content face bare). */
58
125
  &[data-anchor="left"],
59
126
  &[data-anchor="right"] {
60
127
  position: absolute;
@@ -64,15 +131,19 @@
64
131
  }
65
132
 
66
133
  &[data-anchor="left"] {
67
- left: var(--hk-dock-inset, 12px);
134
+ left: calc(var(--_hk-dock-gap-left) + env(safe-area-inset-left, 0px));
135
+ padding-right: var(--_hk-dock-gap-left);
68
136
  }
69
137
 
70
138
  &[data-anchor="right"] {
71
- right: var(--hk-dock-inset, 12px);
139
+ right: calc(var(--_hk-dock-gap-right) + env(safe-area-inset-right, 0px));
140
+ padding-left: var(--_hk-dock-gap-right);
72
141
  }
73
142
 
74
- /* ── corner anchors: absolute attachment with the same inset, for
75
- * pagers, toolbars and HUD panels that live off-center. */
143
+ /* ── corner anchors: absolute attachment with both edge gaps, for
144
+ * pagers, toolbars and HUD panels that live off-center. The band opens
145
+ * on both content-facing sides — physical on the inline face, logical on
146
+ * the block one. */
76
147
  &[data-anchor="top-left"],
77
148
  &[data-anchor="top-right"],
78
149
  &[data-anchor="bottom-left"],
@@ -82,27 +153,35 @@
82
153
  }
83
154
 
84
155
  &[data-anchor="top-left"] {
85
- top: var(--hk-dock-inset, 12px);
86
- left: var(--hk-dock-inset, 12px);
156
+ top: calc(var(--_hk-dock-gap-top) + env(safe-area-inset-top, 0px));
157
+ left: calc(var(--_hk-dock-gap-left) + env(safe-area-inset-left, 0px));
87
158
  align-items: flex-start;
159
+ padding-block-end: var(--_hk-dock-gap-top);
160
+ padding-right: var(--_hk-dock-gap-left);
88
161
  }
89
162
 
90
163
  &[data-anchor="top-right"] {
91
- top: var(--hk-dock-inset, 12px);
92
- right: var(--hk-dock-inset, 12px);
164
+ top: calc(var(--_hk-dock-gap-top) + env(safe-area-inset-top, 0px));
165
+ right: calc(var(--_hk-dock-gap-right) + env(safe-area-inset-right, 0px));
93
166
  align-items: flex-end;
167
+ padding-block-end: var(--_hk-dock-gap-top);
168
+ padding-left: var(--_hk-dock-gap-right);
94
169
  }
95
170
 
96
171
  &[data-anchor="bottom-left"] {
97
- bottom: var(--hk-dock-inset, 12px);
98
- left: var(--hk-dock-inset, 12px);
172
+ bottom: calc(var(--_hk-dock-gap-bottom) + env(safe-area-inset-bottom, 0px));
173
+ left: calc(var(--_hk-dock-gap-left) + env(safe-area-inset-left, 0px));
99
174
  align-items: flex-start;
175
+ padding-block-start: var(--_hk-dock-gap-bottom);
176
+ padding-right: var(--_hk-dock-gap-left);
100
177
  }
101
178
 
102
179
  &[data-anchor="bottom-right"] {
103
- bottom: var(--hk-dock-inset, 12px);
104
- right: var(--hk-dock-inset, 12px);
180
+ bottom: calc(var(--_hk-dock-gap-bottom) + env(safe-area-inset-bottom, 0px));
181
+ right: calc(var(--_hk-dock-gap-right) + env(safe-area-inset-right, 0px));
105
182
  align-items: flex-end;
183
+ padding-block-start: var(--_hk-dock-gap-bottom);
184
+ padding-left: var(--_hk-dock-gap-right);
106
185
  }
107
186
  }
108
187
 
@@ -112,7 +191,10 @@
112
191
  flex-direction: column;
113
192
  align-items: stretch;
114
193
  width: var(--dock-width, auto);
115
- max-width: var(--dock-max-width, calc(100vw - var(--space-16, 16px)));
194
+ /* The viewport cap reads the same edge gaps as the anchoring rules: the
195
+ * surface may never come closer to a horizontal edge than the dock would
196
+ * rest from one. */
197
+ max-width: var(--dock-max-width, calc(100vw - var(--_hk-dock-gap-left) - var(--_hk-dock-gap-right)));
116
198
  max-height: var(--dock-max-height, none);
117
199
  padding: var(--dock-padding, var(--space-8, 8px) var(--space-12, 12px));
118
200
  background: rgb(var(--color-surface));
@@ -130,11 +212,13 @@
130
212
  }
131
213
 
132
214
  /* Vertical side docks (west / east edges) stack along the viewport's
133
- * tall axis — cap them viewport-aware by default so a tall dock never
134
- * runs off-screen; --dock-max-height still overrides. */
215
+ * tall axis — cap them viewport-aware by default so a tall dock never runs
216
+ * off-screen; the cap subtracts the top AND bottom gaps, so a side dock
217
+ * can never out-reach the resting inset of a dock on either horizontal
218
+ * edge. --dock-max-height still overrides. */
135
219
  .hk-dock-bar[data-anchor="left"] .hk-dock-bar-surface,
136
220
  .hk-dock-bar[data-anchor="right"] .hk-dock-bar-surface {
137
- max-height: var(--dock-max-height, calc(100dvh - var(--space-16, 16px)));
221
+ max-height: var(--dock-max-height, calc(100dvh - var(--_hk-dock-gap-top) - var(--_hk-dock-gap-bottom)));
138
222
  }
139
223
 
140
224
  /* Glass surface (default) — blur the page canvas behind the dock. */
@@ -0,0 +1,341 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { dirname, resolve } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+
5
+ import { compile } from "sass";
6
+ import { describe, expect, it } from "vitest";
7
+
8
+ /**
9
+ * Compiled-stylesheet guard for the dock edge gap family (2026-11-15).
10
+ *
11
+ * The whole facility is CSS: `--hk-dock-gap` is declared ONCE by the
12
+ * foundation (scale.scss), every edge resolves it through one fallback
13
+ * chain declared once on the dock base class, and each anchor rule turns
14
+ * that resolved value into (a) its RESTING INSET from the viewport edge —
15
+ * gap plus that edge's safe-area inset — and (b) a transparent CONTENT BAND
16
+ * on the face that points at the content. Vitest stubs CSS, so
17
+ * HkDockBar.test.tsx can only read the SCSS source; this file compiles the
18
+ * real sheets and pins the emitted declarations, so a rule that silently
19
+ * regresses to a literal 12px inset, loses a band, or leaves the surface
20
+ * uncapped turns red here.
21
+ *
22
+ * The negative controls matter as much as the positive ones: a `:root`
23
+ * pre-declaration of `--hk-dock-gap-<edge>` would freeze that edge against
24
+ * every descendant `--hk-dock-gap` override (a custom property resolves on
25
+ * the element that DECLARES it), and a per-anchor re-spelling of the chain
26
+ * would let the family drift back into several mechanisms.
27
+ *
28
+ * Inline bands are PHYSICAL (`padding-right` / `padding-left`, review S1): the
29
+ * anchors are physical, so on a left-anchored dock a logical `padding-inline-
30
+ * end` resolves to the physical LEFT under `dir="rtl"` — the pinned side — and
31
+ * the surface reads `gap + gap` from the edge while the content face goes bare.
32
+ * The band table below therefore resolves each declaration under BOTH writing
33
+ * directions and demands the same content-facing side, which is only true for
34
+ * physical longhands.
35
+ */
36
+
37
+ const componentDir = resolve(dirname(fileURLToPath(import.meta.url)));
38
+ const srcDir = resolve(componentDir, "..");
39
+
40
+ const dockCss = compile(resolve(componentDir, "HkDockBar.scss"), {
41
+ style: "expanded",
42
+ }).css;
43
+ const scaleCss = compile(resolve(srcDir, "scale.scss"), { style: "expanded" }).css;
44
+ const scaleSource = readFileSync(resolve(srcDir, "scale.scss"), "utf8");
45
+
46
+ /** The sheet minus its block comments: the contract prose quotes the very
47
+ * declarations the negative controls scan for (the header comment spells the
48
+ * cascade trap as a literal `--hk-dock-gap-bottom` declaration), so the scans
49
+ * must only ever see real declarations. */
50
+ function withoutComments(css: string): string {
51
+ return css.replace(/\/\*[\s\S]*?\*\//g, "");
52
+ }
53
+
54
+ function escapeRe(text: string): string {
55
+ return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
56
+ }
57
+
58
+ /** The compiled rule that is EXACTLY `selector` followed by its own block. A
59
+ * selector shared with a sibling (`.a, .b { … }`) does not count: the anchor
60
+ * assertions must read that anchor's own rule body, never a shared one. */
61
+ function ruleFor(css: string, selector: string): string {
62
+ const start = new RegExp(`(?:^|\\n)[ \\t]*${escapeRe(selector)}\\s*\\{`).exec(css);
63
+ expect(start, `${selector} present in the compiled sheet`).not.toBeNull();
64
+ return sliceRule(css, start!.index);
65
+ }
66
+
67
+ /** The compiled rule whose selector LIST starts with `selector` (a shared rule
68
+ * such as the two side-anchor caps, emitted as one `.left, .right { … }`). */
69
+ function groupRuleFor(css: string, selector: string): string {
70
+ const start = new RegExp(`(?:^|\\n)[ \\t]*${escapeRe(selector)}(?=[\\s,{])`).exec(css);
71
+ expect(start, `${selector} present in the compiled sheet`).not.toBeNull();
72
+ return sliceRule(css, start!.index);
73
+ }
74
+
75
+ /** The rule body that begins at `from` (`{` … first `}`). */
76
+ function sliceRule(css: string, from: number): string {
77
+ const open = css.indexOf("{", from);
78
+ const close = css.indexOf("}", open);
79
+ return css.slice(from, close + 1);
80
+ }
81
+
82
+ const EDGES = ["top", "right", "bottom", "left"] as const;
83
+
84
+ /** The private resolved gap one edge reads (declared once on the base). */
85
+ function gap(edge: string): string {
86
+ return `var(--_hk-dock-gap-${edge})`;
87
+ }
88
+
89
+ /** The resting inset of an anchored edge: the gap plus its safe-area. */
90
+ function inset(edge: string): string {
91
+ return `calc(${gap(edge)} + env(safe-area-inset-${edge}, 0px))`;
92
+ }
93
+
94
+ /**
95
+ * The §2 anchor table, transcribed — every one of the ten `data-anchor`
96
+ * values the component accepts (nine geometries; `bottom` is `page`'s
97
+ * compass alias). Each row is `[css side, edge]` for the resting inset and
98
+ * `[padding property, edge]` for the content band, so a missing anchor row,
99
+ * a missing rule, or a band on the wrong face fails.
100
+ */
101
+ type AnchorRow = {
102
+ anchor: string;
103
+ insets: [string, string][];
104
+ bands: [string, string][];
105
+ };
106
+
107
+ const ANCHOR_TABLE: AnchorRow[] = [
108
+ {
109
+ anchor: "page",
110
+ insets: [["bottom", "bottom"]],
111
+ bands: [["padding-block-start", "bottom"]],
112
+ },
113
+ {
114
+ anchor: "bottom",
115
+ insets: [["bottom", "bottom"]],
116
+ bands: [["padding-block-start", "bottom"]],
117
+ },
118
+ {
119
+ anchor: "plane",
120
+ insets: [["margin", "bottom"]],
121
+ bands: [["padding-block-start", "bottom"]],
122
+ },
123
+ { anchor: "top", insets: [["top", "top"]], bands: [["padding-block-end", "top"]] },
124
+ { anchor: "left", insets: [["left", "left"]], bands: [["padding-right", "left"]] },
125
+ { anchor: "right", insets: [["right", "right"]], bands: [["padding-left", "right"]] },
126
+ {
127
+ anchor: "top-left",
128
+ insets: [
129
+ ["top", "top"],
130
+ ["left", "left"],
131
+ ],
132
+ bands: [
133
+ ["padding-block-end", "top"],
134
+ ["padding-right", "left"],
135
+ ],
136
+ },
137
+ {
138
+ anchor: "top-right",
139
+ insets: [
140
+ ["top", "top"],
141
+ ["right", "right"],
142
+ ],
143
+ bands: [
144
+ ["padding-block-end", "top"],
145
+ ["padding-left", "right"],
146
+ ],
147
+ },
148
+ {
149
+ anchor: "bottom-left",
150
+ insets: [
151
+ ["bottom", "bottom"],
152
+ ["left", "left"],
153
+ ],
154
+ bands: [
155
+ ["padding-block-start", "bottom"],
156
+ ["padding-right", "left"],
157
+ ],
158
+ },
159
+ {
160
+ anchor: "bottom-right",
161
+ insets: [
162
+ ["bottom", "bottom"],
163
+ ["right", "right"],
164
+ ],
165
+ bands: [
166
+ ["padding-block-start", "bottom"],
167
+ ["padding-left", "right"],
168
+ ],
169
+ },
170
+ ];
171
+
172
+ describe("dock edge gap token — foundation declaration", () => {
173
+ it("declares --hk-dock-gap exactly once, defaulting to the 16px step", () => {
174
+ const root = ruleFor(scaleCss, ":root");
175
+ expect(root).toContain("--hk-dock-gap: var(--space-16, 1rem);");
176
+ expect(withoutComments(scaleCss).match(/--hk-dock-gap\s*:/g) ?? []).toHaveLength(1);
177
+ // …and NOT inside the mobile media query that halves other gutters: the
178
+ // dock gap is a product decision, not a breakpoint-dependent gutter.
179
+ expect(scaleCss.split("@media")[0]).toContain("--hk-dock-gap:");
180
+ });
181
+
182
+ it("never pre-declares a per-edge gap (cascade trap negative control)", () => {
183
+ // A custom property resolves on the element that declares it, so a
184
+ // :root-level `--hk-dock-gap-bottom: var(--hk-dock-gap)` would freeze the
185
+ // bottom edge against every descendant override. Per-edge names may only
186
+ // appear as READ-time fallbacks.
187
+ for (const [name, css] of [
188
+ ["scale.scss", scaleCss],
189
+ ["HkDockBar.scss", dockCss],
190
+ ] as const) {
191
+ expect(
192
+ withoutComments(css).match(/(^|[^\w-])--hk-dock-gap-(top|right|bottom|left)\s*:/m),
193
+ `${name} must not declare a per-edge gap`,
194
+ ).toBeNull();
195
+ }
196
+ expect(scaleSource.replace(/\/\*[\s\S]*?\*\//g, "")).not.toMatch(
197
+ /--hk-dock-gap-(top|right|bottom|left)\s*:/,
198
+ );
199
+ });
200
+ });
201
+
202
+ describe("dock edge gap token — one resolver per edge", () => {
203
+ it("declares the four resolved gaps on the base class, each reading the full chain", () => {
204
+ const base = ruleFor(dockCss, ".hk-dock-bar");
205
+ for (const edge of EDGES) {
206
+ expect(base).toContain(
207
+ `--_hk-dock-gap-${edge}: var(--hk-dock-gap-${edge}, var(--hk-dock-inset, var(--hk-dock-gap, var(--space-16, 1rem))));`,
208
+ );
209
+ }
210
+ // Exactly four declarations: the chain lives in ONE place (the base), not
211
+ // re-spelled per anchor.
212
+ expect(dockCss.match(/--_hk-dock-gap-(top|right|bottom|left):/g) ?? []).toHaveLength(4);
213
+ });
214
+ });
215
+
216
+ describe("dock edge gap — anchor geometry", () => {
217
+ it("covers every anchor the component accepts, and no other", () => {
218
+ // Completeness in both directions: a new anchor must get a row here, and
219
+ // the table may not carry an anchor the sheet does not style.
220
+ const styled = new Set(
221
+ [...withoutComments(dockCss).matchAll(/\[data-anchor=([a-z-]+)\]/g)].map((m) => m[1]),
222
+ );
223
+ expect([...styled].sort()).toEqual(ANCHOR_TABLE.map((row) => row.anchor).sort());
224
+ });
225
+
226
+ it.each(ANCHOR_TABLE)(
227
+ '$anchor: edge gap inset(s) + content band(s) from the same family',
228
+ ({ anchor, insets, bands }) => {
229
+ const rule = ruleFor(dockCss, `.hk-dock-bar[data-anchor=${anchor}]`);
230
+ for (const [side, edge] of insets) {
231
+ if (side === "margin") {
232
+ // The in-flow plane anchor rests by a margin, not a pinned edge.
233
+ expect(rule).toContain(`margin: 0 auto ${inset(edge)};`);
234
+ } else {
235
+ expect(rule).toContain(`${side}: ${inset(edge)};`);
236
+ }
237
+ }
238
+ for (const [property, edge] of bands) {
239
+ expect(rule).toContain(`${property}: ${gap(edge)};`);
240
+ }
241
+ // No literal fallback left behind: every distance is a resolved edge gap.
242
+ expect(rule).not.toContain("--space-16");
243
+ expect(rule).not.toContain("--hk-dock-inset");
244
+ },
245
+ );
246
+
247
+ it("opens exactly two bands on each corner and one elsewhere", () => {
248
+ for (const { anchor, bands } of ANCHOR_TABLE) {
249
+ const rule = ruleFor(dockCss, `.hk-dock-bar[data-anchor=${anchor}]`);
250
+ const padding = rule.match(/padding-(?:inline-|block-)?(?:start|end|left|right):/g) ?? [];
251
+ expect(padding, anchor).toHaveLength(bands.length);
252
+ }
253
+ });
254
+
255
+ it("resolves the same content-facing band side in BOTH writing directions", () => {
256
+ // What a browser does with a padding longhand depends on the writing
257
+ // direction — but only for LOGICAL longhands. Each band is therefore
258
+ // resolved under `dir="ltr"` and `dir="rtl"` and must land on the physical
259
+ // side that faces the content both times: that is what makes the band hold
260
+ // on an RTL page instead of flipping onto the pinned edge (review S1).
261
+ type Side = "left" | "right" | "block-start" | "block-end";
262
+ // The physical face each anchor's content sits on, per axis.
263
+ const CONTENT_SIDES: Record<string, Side[]> = {
264
+ page: ["block-start"],
265
+ bottom: ["block-start"],
266
+ plane: ["block-start"],
267
+ top: ["block-end"],
268
+ left: ["right"],
269
+ right: ["left"],
270
+ "top-left": ["block-end", "right"],
271
+ "top-right": ["block-end", "left"],
272
+ "bottom-left": ["block-start", "right"],
273
+ "bottom-right": ["block-start", "left"],
274
+ };
275
+ /** Where one declared padding longhand actually lands, per direction. */
276
+ function resolve(decl: string, dir: "ltr" | "rtl"): Side | null {
277
+ switch (decl) {
278
+ case "padding-left":
279
+ return "left";
280
+ case "padding-right":
281
+ return "right";
282
+ case "padding-block-start":
283
+ return "block-start";
284
+ case "padding-block-end":
285
+ return "block-end";
286
+ case "padding-inline-start":
287
+ return dir === "ltr" ? "left" : "right";
288
+ case "padding-inline-end":
289
+ return dir === "ltr" ? "right" : "left";
290
+ default:
291
+ return null;
292
+ }
293
+ }
294
+ for (const { anchor } of ANCHOR_TABLE) {
295
+ const rule = ruleFor(dockCss, `.hk-dock-bar[data-anchor=${anchor}]`);
296
+ const declared = [...rule.matchAll(/padding-(?:inline-|block-)?(start|end|left|right):/g)].map(
297
+ (m) => m[0].slice(0, -1),
298
+ );
299
+ expect(declared.length, anchor).toBe(CONTENT_SIDES[anchor].length);
300
+ for (const dir of ["ltr", "rtl"] as const) {
301
+ const resolved = declared.map((decl) => resolve(decl, dir));
302
+ expect(resolved, `${anchor} in dir=${dir}`).toEqual(CONTENT_SIDES[anchor]);
303
+ }
304
+ // …which can only hold for BOTH directions when no logical inline
305
+ // longhand is used at all: the negative control for the S1 defect.
306
+ expect(rule, anchor).not.toMatch(/padding-inline-(start|end)/);
307
+ }
308
+ });
309
+
310
+ it("every anchored rule adds the safe-area inset for its own edge only", () => {
311
+ for (const { anchor, insets } of ANCHOR_TABLE) {
312
+ const rule = ruleFor(dockCss, `.hk-dock-bar[data-anchor=${anchor}]`);
313
+ for (const [, edge] of insets) {
314
+ expect(rule, anchor).toContain(`env(safe-area-inset-${edge}, 0px)`);
315
+ }
316
+ for (const other of EDGES.filter((e) => !insets.some(([, edge]) => edge === e))) {
317
+ expect(rule, anchor).not.toContain(`safe-area-inset-${other}`);
318
+ }
319
+ }
320
+ });
321
+ });
322
+
323
+ describe("dock edge gap — surface caps read the same family", () => {
324
+ it("caps the surface width on both horizontal edge gaps", () => {
325
+ const base = ruleFor(dockCss, ".hk-dock-bar-surface");
326
+ expect(base).toContain(
327
+ `max-width: var(--dock-max-width, calc(100vw - ${gap("left")} - ${gap("right")}));`,
328
+ );
329
+ expect(base).not.toContain("--space-16");
330
+ });
331
+
332
+ it("caps vertical side docks by both block gaps", () => {
333
+ // Sass emits the two side anchors as one selector list; the cap rule body
334
+ // is what this pins.
335
+ const cap = groupRuleFor(dockCss, '.hk-dock-bar[data-anchor=left] .hk-dock-bar-surface');
336
+ expect(cap).toContain(
337
+ `max-height: var(--dock-max-height, calc(100dvh - ${gap("top")} - ${gap("bottom")}));`,
338
+ );
339
+ expect(cap).not.toContain("--space-16");
340
+ });
341
+ });