@celestia-island/hikari 0.55.253 → 0.55.255
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/board3dSurface.test.ts +11 -1
- package/src/components/HkAffixPicker.scss +4 -3
- package/src/components/HkLocalePicker.scss +29 -32
- package/src/components/HkLocalePicker.tsx +35 -94
- package/src/components/HkLocalePickerPopup.tsx +3 -1
- package/src/components/HkMinimap.tsx +2 -2
- package/src/components/HkMinimap3D.test.tsx +43 -1
- package/src/components/HkMinimap3D.tsx +31 -6
- package/src/components/HkStarSystem.scss +29 -0
- package/src/components/HkStarSystem.styles.test.ts +14 -0
- package/src/components/HkStarSystem.test.tsx +163 -0
- package/src/components/HkStarSystem.tsx +172 -0
- package/src/components/HkTimeZoneGlobe.test.tsx +9 -0
- package/src/components/HkTitleBar.scss +28 -12
- package/src/components/HkTitleBar.test.tsx +35 -1
- package/src/components/HkZoomToolbar.tsx +2 -2
- package/src/components/_menu-item.contract.test.ts +80 -0
- package/src/index.ts +6 -0
- package/src/scene3d/holographicFleetBody.test.ts +89 -0
- package/src/scene3d/holographicFleetBody.ts +256 -0
- package/src/scene3d/holographicFleetScene.test.ts +1076 -0
- package/src/scene3d/holographicFleetScene.ts +651 -0
- package/src/scene3d/holographicFleetSpec.test.ts +474 -0
- package/src/scene3d/holographicFleetSpec.ts +419 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HkStarSystem — a reusable star / planet / satellite business scene.
|
|
3
|
+
*
|
|
4
|
+
* The host owns real node data and selection; this component owns the
|
|
5
|
+
* deterministic layout, holographic bodies, data-bound HUD bands, camera
|
|
6
|
+
* follow, labels, minimap markers and every GPU resource it creates. RPC,
|
|
7
|
+
* permissions and node actions deliberately stay in the host product.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
defineComponent,
|
|
12
|
+
onBeforeUnmount,
|
|
13
|
+
shallowRef,
|
|
14
|
+
watch,
|
|
15
|
+
type PropType,
|
|
16
|
+
} from "vue";
|
|
17
|
+
|
|
18
|
+
import HkBoard3D, { type Board3DEngine } from "./HkBoard3D";
|
|
19
|
+
import {
|
|
20
|
+
buildFleetScene,
|
|
21
|
+
type FleetSceneHandle,
|
|
22
|
+
} from "../scene3d/holographicFleetScene";
|
|
23
|
+
import {
|
|
24
|
+
buildHolographicFleetSpec,
|
|
25
|
+
type FleetBodySpec,
|
|
26
|
+
type StarSystemBodyInput,
|
|
27
|
+
} from "../scene3d/holographicFleetSpec";
|
|
28
|
+
import "./HkStarSystem.scss";
|
|
29
|
+
|
|
30
|
+
export default defineComponent({
|
|
31
|
+
name: "HkStarSystem",
|
|
32
|
+
props: {
|
|
33
|
+
bodies: {
|
|
34
|
+
type: Array as PropType<readonly StarSystemBodyInput[]>,
|
|
35
|
+
required: true,
|
|
36
|
+
},
|
|
37
|
+
/** Controlled selection. Remounts restore the cursor without an
|
|
38
|
+
* unsolicited camera flight; an explicit change focuses the body. */
|
|
39
|
+
selectedId: { type: String as PropType<string | null>, default: null },
|
|
40
|
+
/** CSS2D needs real elements. Host products may localize and enrich
|
|
41
|
+
* these chips while the HUD band still uses the body's real fields. */
|
|
42
|
+
makeLabel: {
|
|
43
|
+
type: Function as PropType<(body: FleetBodySpec) => HTMLElement>,
|
|
44
|
+
default: undefined,
|
|
45
|
+
},
|
|
46
|
+
makeCoreLabel: {
|
|
47
|
+
type: Function as PropType<() => HTMLElement>,
|
|
48
|
+
default: undefined,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
emits: {
|
|
52
|
+
"update:selectedId": (_id: string | null) => true,
|
|
53
|
+
},
|
|
54
|
+
setup(props, { emit, expose, slots }) {
|
|
55
|
+
const engineRef = shallowRef<Board3DEngine | null>(null);
|
|
56
|
+
let sceneHandle: FleetSceneHandle | null = null;
|
|
57
|
+
let handleEngine: Board3DEngine | null = null;
|
|
58
|
+
let currentSelection: string | null = null;
|
|
59
|
+
|
|
60
|
+
function dropScene(): void {
|
|
61
|
+
sceneHandle?.dispose();
|
|
62
|
+
sceneHandle = null;
|
|
63
|
+
handleEngine = null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function defaultLabel(body: FleetBodySpec): HTMLElement {
|
|
67
|
+
const chip = document.createElement("div");
|
|
68
|
+
chip.className = "hk-star-system-chip";
|
|
69
|
+
chip.textContent = [body.label, body.status, body.detail]
|
|
70
|
+
.filter((part) => part.trim().length > 0)
|
|
71
|
+
.join(" · ");
|
|
72
|
+
chip.addEventListener("click", (event) => {
|
|
73
|
+
event.stopPropagation();
|
|
74
|
+
selectBody(body.id);
|
|
75
|
+
});
|
|
76
|
+
return chip;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function defaultCoreLabel(): HTMLElement {
|
|
80
|
+
const chip = document.createElement("div");
|
|
81
|
+
chip.className = "hk-star-system-chip is-core";
|
|
82
|
+
chip.textContent = "Core";
|
|
83
|
+
return chip;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function selectBody(id: string | null): void {
|
|
87
|
+
const changed = currentSelection !== id;
|
|
88
|
+
currentSelection = id;
|
|
89
|
+
sceneHandle?.setSelected(id);
|
|
90
|
+
// An explicit click on the ALREADY selected body still re-centres it,
|
|
91
|
+
// matching the original fleet scene; only deselect is idempotent.
|
|
92
|
+
if (id) sceneHandle?.focusBody(id);
|
|
93
|
+
else if (changed) sceneHandle?.frameFleet(600);
|
|
94
|
+
emit("update:selectedId", id);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
watch(() => props.selectedId, (id) => {
|
|
98
|
+
if (id === currentSelection) return;
|
|
99
|
+
currentSelection = id;
|
|
100
|
+
sceneHandle?.setSelected(id);
|
|
101
|
+
if (id) sceneHandle?.focusBody(id);
|
|
102
|
+
else sceneHandle?.frameFleet(600);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
watch(
|
|
106
|
+
[engineRef, () => props.bodies],
|
|
107
|
+
([engine]) => {
|
|
108
|
+
if (!engine) return;
|
|
109
|
+
if (!sceneHandle || handleEngine !== engine) {
|
|
110
|
+
dropScene();
|
|
111
|
+
sceneHandle = buildFleetScene(engine, {
|
|
112
|
+
makeLabel: (body) => props.makeLabel?.(body) ?? defaultLabel(body),
|
|
113
|
+
registryCoreLabel: () => props.makeCoreLabel?.() ?? defaultCoreLabel(),
|
|
114
|
+
});
|
|
115
|
+
handleEngine = engine;
|
|
116
|
+
// A fresh board restores only the cursor. Focusing here would
|
|
117
|
+
// hijack a scene → list → scene round trip with a new flight.
|
|
118
|
+
currentSelection = props.selectedId;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const spec = buildHolographicFleetSpec(props.bodies);
|
|
122
|
+
sceneHandle.update(
|
|
123
|
+
spec,
|
|
124
|
+
Object.fromEntries(props.bodies.map((body) => [body.id, !body.online])),
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
const selected = props.selectedId;
|
|
128
|
+
const stillExists = selected !== null && props.bodies.some((body) => body.id === selected);
|
|
129
|
+
if (selected && !stillExists) {
|
|
130
|
+
// update() has already re-anchored/stopped the old follow.
|
|
131
|
+
currentSelection = null;
|
|
132
|
+
sceneHandle.setSelected(null);
|
|
133
|
+
emit("update:selectedId", null);
|
|
134
|
+
} else {
|
|
135
|
+
currentSelection = selected;
|
|
136
|
+
sceneHandle.setSelected(selected);
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
{ immediate: true, deep: true },
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
onBeforeUnmount(dropScene);
|
|
143
|
+
|
|
144
|
+
expose({
|
|
145
|
+
focusBody(id: string) {
|
|
146
|
+
selectBody(id);
|
|
147
|
+
},
|
|
148
|
+
frameFleet(durationMs?: number): boolean {
|
|
149
|
+
return sceneHandle?.frameFleet(durationMs) ?? false;
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
return () => (
|
|
154
|
+
<HkBoard3D
|
|
155
|
+
fov={45}
|
|
156
|
+
minDistance={3}
|
|
157
|
+
maxDistance={420}
|
|
158
|
+
transparentBackground
|
|
159
|
+
initialPosition={[22, -19, 34]}
|
|
160
|
+
onReady={(engine: Board3DEngine) => {
|
|
161
|
+
engineRef.value = engine;
|
|
162
|
+
}}
|
|
163
|
+
onObjectClick={selectBody}
|
|
164
|
+
>
|
|
165
|
+
{{
|
|
166
|
+
default: () => slots.default?.(),
|
|
167
|
+
...(slots.fallback ? { fallback: () => slots.fallback?.() } : {}),
|
|
168
|
+
}}
|
|
169
|
+
</HkBoard3D>
|
|
170
|
+
);
|
|
171
|
+
},
|
|
172
|
+
});
|
|
@@ -140,4 +140,13 @@ describe("HkTimeZoneGlobe look contract (source-level)", () => {
|
|
|
140
140
|
expect(src).toContain("minimapCollapsible");
|
|
141
141
|
expect(src).toContain("minimapDefaultCollapsed");
|
|
142
142
|
});
|
|
143
|
+
});
|
|
144
|
+
describe("minimap reset icon contract (user direction 2026-10-31)", () => {
|
|
145
|
+
it("reset buttons use RotateCcw, never the expand-looking Maximize2", () => {
|
|
146
|
+
for (const name of ["HkMinimap.tsx", "HkMinimap3D.tsx", "HkZoomToolbar.tsx"]) {
|
|
147
|
+
const src = readFileSync(join(import.meta.dirname, name), "utf8");
|
|
148
|
+
expect(src, name + " imports RotateCcw").toContain("RotateCcw");
|
|
149
|
+
expect(src, name + " dropped Maximize2").not.toContain("Maximize2");
|
|
150
|
+
}
|
|
151
|
+
});
|
|
143
152
|
});
|
|
@@ -18,6 +18,16 @@
|
|
|
18
18
|
--hk-tb-focus: rgb(var(--color-primary, 122 162 247) / 0.6);
|
|
19
19
|
--hk-tb-close-hover: #e81123;
|
|
20
20
|
--hk-tb-close-active: #f1707a;
|
|
21
|
+
/* --hk-tb-close-ink and --hk-tb-icon-size are HOST-CONFIGURABLE, so they
|
|
22
|
+
are read with fallbacks at their use sites instead of being declared
|
|
23
|
+
here: a declaration on .hk-titlebar itself would out-rank a value the
|
|
24
|
+
host sets on :root (local declarations beat inherited ones), which
|
|
25
|
+
made the tokens look configurable while only the component could win.
|
|
26
|
+
The close fill is a FIXED danger red, so its ink default is fixed too:
|
|
27
|
+
deriving it from the theme's on-solid choice (the default dark preset
|
|
28
|
+
picks polar-night ink for its pale primary fills) painted a dark X on
|
|
29
|
+
dark red at roughly 1:1 - the host-visible bug both wowsp and momoi
|
|
30
|
+
filed. */
|
|
21
31
|
--hk-tb-radius-close: 0 8px 0 0;
|
|
22
32
|
|
|
23
33
|
position: fixed;
|
|
@@ -47,8 +57,8 @@
|
|
|
47
57
|
}
|
|
48
58
|
|
|
49
59
|
.hk-titlebar-icon {
|
|
50
|
-
width: 16px;
|
|
51
|
-
height: 16px;
|
|
60
|
+
width: var(--hk-tb-icon-size, 16px);
|
|
61
|
+
height: var(--hk-tb-icon-size, 16px);
|
|
52
62
|
display: block;
|
|
53
63
|
pointer-events: none;
|
|
54
64
|
}
|
|
@@ -80,7 +90,13 @@
|
|
|
80
90
|
height: 100%;
|
|
81
91
|
}
|
|
82
92
|
|
|
83
|
-
|
|
93
|
+
/* Caption buttons are scoped under the bar on purpose: a host's element
|
|
94
|
+
rules (`button:hover:not(:disabled)` scores (0,2,1)) would otherwise
|
|
95
|
+
out-rank the component's class-level hover and repaint the caption -
|
|
96
|
+
the momoi field report. Scoped selectors sit at (0,3,0), one level
|
|
97
|
+
above any plausible element rule, while the close-specific rules stay
|
|
98
|
+
later in the sheet so they keep winning among themselves. */
|
|
99
|
+
.hk-titlebar .hk-titlebar-btn {
|
|
84
100
|
width: 46px;
|
|
85
101
|
height: var(--hk-tb-height);
|
|
86
102
|
border: none;
|
|
@@ -95,24 +111,24 @@
|
|
|
95
111
|
padding: 0;
|
|
96
112
|
}
|
|
97
113
|
|
|
98
|
-
.hk-titlebar-btn:hover {
|
|
114
|
+
.hk-titlebar .hk-titlebar-btn:hover {
|
|
99
115
|
background: var(--hk-tb-hover);
|
|
100
116
|
color: var(--hk-tb-fg-strong);
|
|
101
117
|
}
|
|
102
118
|
|
|
103
|
-
.hk-titlebar-btn:active {
|
|
119
|
+
.hk-titlebar .hk-titlebar-btn:active {
|
|
104
120
|
background: var(--hk-tb-active);
|
|
105
121
|
}
|
|
106
122
|
|
|
107
123
|
/* Only the rightmost (close) button carries the window's top-right
|
|
108
124
|
corner radius; the other captions highlight as plain rectangles. */
|
|
109
|
-
.hk-titlebar-btn-close {
|
|
125
|
+
.hk-titlebar .hk-titlebar-btn-close {
|
|
110
126
|
border-radius: var(--hk-tb-radius-close);
|
|
111
127
|
}
|
|
112
128
|
|
|
113
129
|
/* RTL mirrors the caption row, so the close button lands top-left and
|
|
114
130
|
the window corner radius flips with it. */
|
|
115
|
-
[dir="rtl"] .hk-titlebar-btn-close {
|
|
131
|
+
[dir="rtl"] .hk-titlebar .hk-titlebar-btn-close {
|
|
116
132
|
border-radius: 8px 0 0 0;
|
|
117
133
|
}
|
|
118
134
|
|
|
@@ -125,17 +141,17 @@
|
|
|
125
141
|
border-radius: 0;
|
|
126
142
|
}
|
|
127
143
|
|
|
128
|
-
.hk-titlebar-btn-close:hover {
|
|
144
|
+
.hk-titlebar .hk-titlebar-btn-close:hover {
|
|
129
145
|
background: var(--hk-tb-close-hover);
|
|
130
|
-
color: var(--
|
|
146
|
+
color: var(--hk-tb-close-ink, #ffffff);
|
|
131
147
|
}
|
|
132
148
|
|
|
133
|
-
.hk-titlebar-btn-close:active {
|
|
149
|
+
.hk-titlebar .hk-titlebar-btn-close:active {
|
|
134
150
|
background: var(--hk-tb-close-active);
|
|
135
|
-
color: var(--
|
|
151
|
+
color: var(--hk-tb-close-ink, #ffffff);
|
|
136
152
|
}
|
|
137
153
|
|
|
138
|
-
.hk-titlebar-btn:focus-visible {
|
|
154
|
+
.hk-titlebar .hk-titlebar-btn:focus-visible {
|
|
139
155
|
outline: 2px solid var(--hk-tb-focus);
|
|
140
156
|
outline-offset: -2px;
|
|
141
157
|
}
|
|
@@ -213,7 +213,41 @@ describe("HkTitleBar stylesheet contract", () => {
|
|
|
213
213
|
it("keeps the windowed radius var wired to the close button", () => {
|
|
214
214
|
const scss = readFileSync(resolve(componentDir, "HkTitleBar.scss"), "utf8");
|
|
215
215
|
expect(scss).toContain("--hk-tb-radius-close:");
|
|
216
|
-
const body = ruleBody(css, ".hk-titlebar-btn-close");
|
|
216
|
+
const body = ruleBody(css, ".hk-titlebar .hk-titlebar-btn-close");
|
|
217
217
|
expect(body).toContain("border-radius: var(--hk-tb-radius-close)");
|
|
218
218
|
});
|
|
219
|
+
|
|
220
|
+
it("inks the close fill from its own host-configurable token, never the theme's on-solid", () => {
|
|
221
|
+
// The fill is a fixed danger red; the ink is fixed with it. The
|
|
222
|
+
// theme-derived --hi-color-text-on-danger painted a dark X on dark red
|
|
223
|
+
// under the default dark preset (the wowsp/momoi field report). The
|
|
224
|
+
// token is read with its fallback at the use site rather than declared
|
|
225
|
+
// on .hk-titlebar, so a host's :root assignment actually wins - a local
|
|
226
|
+
// declaration would beat the inherited value (the momoi follow-up).
|
|
227
|
+
const hover = ruleBody(css, ".hk-titlebar .hk-titlebar-btn-close:hover");
|
|
228
|
+
expect(hover).toContain("color: var(--hk-tb-close-ink, #ffffff)");
|
|
229
|
+
expect(hover).not.toContain("--hi-color-text-on-danger");
|
|
230
|
+
const active = ruleBody(css, ".hk-titlebar .hk-titlebar-btn-close:active");
|
|
231
|
+
expect(active).toContain("color: var(--hk-tb-close-ink, #ffffff)");
|
|
232
|
+
const scss = readFileSync(resolve(componentDir, "HkTitleBar.scss"), "utf8");
|
|
233
|
+
expect(scss).not.toMatch(/^\s*--hk-tb-close-ink:/m);
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
it("outranks host element rules with caption-scoped buttons", () => {
|
|
237
|
+
// (0,3,0) beats a host's `button:hover:not(:disabled)` at (0,2,1);
|
|
238
|
+
// the close-specific rules stay later in the sheet, so they still win.
|
|
239
|
+
const hover = ruleBody(css, ".hk-titlebar .hk-titlebar-btn:hover");
|
|
240
|
+
expect(hover).toContain("background: var(--hk-tb-hover)");
|
|
241
|
+
const closeHoverAt = css.indexOf(".hk-titlebar .hk-titlebar-btn-close:hover");
|
|
242
|
+
const hoverAt = css.indexOf(".hk-titlebar .hk-titlebar-btn:hover");
|
|
243
|
+
expect(closeHoverAt).toBeGreaterThan(hoverAt);
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
it("sizes the caption icon through a host-configurable token", () => {
|
|
247
|
+
const body = ruleBody(css, ".hk-titlebar-icon");
|
|
248
|
+
expect(body).toContain("width: var(--hk-tb-icon-size, 16px)");
|
|
249
|
+
expect(body).toContain("height: var(--hk-tb-icon-size, 16px)");
|
|
250
|
+
const scss = readFileSync(resolve(componentDir, "HkTitleBar.scss"), "utf8");
|
|
251
|
+
expect(scss).not.toMatch(/^\s*--hk-tb-icon-size:/m);
|
|
252
|
+
});
|
|
219
253
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RotateCcw, ZoomIn, ZoomOut } from "lucide-vue-next";
|
|
2
2
|
import { defineComponent } from "vue";
|
|
3
3
|
|
|
4
4
|
|
|
@@ -62,7 +62,7 @@ export default defineComponent({
|
|
|
62
62
|
ariaLabel={t("hikari::zoomToolbar.reset", "Reset zoom")}
|
|
63
63
|
onClick={() => emit("reset")}
|
|
64
64
|
>
|
|
65
|
-
<
|
|
65
|
+
<RotateCcw size={14} />
|
|
66
66
|
</HButton>
|
|
67
67
|
)}
|
|
68
68
|
</div>
|
|
@@ -35,6 +35,9 @@ const menuScss = readFileSync(join(here, "HkMenu.scss"), "utf-8");
|
|
|
35
35
|
const affixScss = readFileSync(join(here, "HkAffixPicker.scss"), "utf-8");
|
|
36
36
|
const tagInputScss = readFileSync(join(here, "HkTagInput.scss"), "utf-8");
|
|
37
37
|
const tplScss = readFileSync(join(here, "HkTemplateField.scss"), "utf-8");
|
|
38
|
+
const userPickerScss = readFileSync(join(here, "HkUserPicker.scss"), "utf-8");
|
|
39
|
+
const tagInputTsx = readFileSync(join(here, "HkTagInput.tsx"), "utf-8");
|
|
40
|
+
const userPickerTsx = readFileSync(join(here, "HkUserPicker.tsx"), "utf-8");
|
|
38
41
|
const themeTsx = readFileSync(join(here, "HkThemePanelContent.tsx"), "utf8");
|
|
39
42
|
const adminTokens = readFileSync(join(here, "../styles/admin-tokens.scss"), "utf-8");
|
|
40
43
|
const panelScss = readFileSync(join(here, "HkMenuPanel.scss"), "utf-8");
|
|
@@ -242,6 +245,13 @@ describe("menu-item grammar contract", () => {
|
|
|
242
245
|
expect(adminTokens).toMatch(
|
|
243
246
|
/\.s-user-header \{[^}]*padding: var\(--space-10\) var\(--space-14\) var\(--space-12\)/,
|
|
244
247
|
);
|
|
248
|
+
// The drawer is the third hosting surface (.hk-drawer-panel is one of
|
|
249
|
+
// the grammar's sheet contexts) — its twin carries the SHEET pad-x.
|
|
250
|
+
// Without it a drawer identity block kept the bare 14px while the
|
|
251
|
+
// drawer rows around it rode 1px + 16px (2026-10-31 audit finding 9).
|
|
252
|
+
expect(adminTokens).toMatch(
|
|
253
|
+
/\.hk-drawer-panel \.s-user-header \{[^}]*padding-inline: calc\(1px \+ var\(--hk-menu-item-pad-x, 16px\)\)/,
|
|
254
|
+
);
|
|
245
255
|
});
|
|
246
256
|
|
|
247
257
|
it("spends the italic overhang cushion in the label mixin only", () => {
|
|
@@ -777,4 +787,74 @@ describe("menu-item grammar contract", () => {
|
|
|
777
787
|
).toEqual([]);
|
|
778
788
|
}
|
|
779
789
|
});
|
|
790
|
+
|
|
791
|
+
it("keeps the adopted row families on the mixin's geometry (no local padding/min-height)", () => {
|
|
792
|
+
// The 2026-10-31 adoption gave four hand-rolled row families
|
|
793
|
+
// @include mi.item — the mixin OWNS their padding and min-height
|
|
794
|
+
// (6×12 desktop / 10×16 sheet via the registration lists). A local
|
|
795
|
+
// padding or min-height declaration in the family's own rule
|
|
796
|
+
// overrides the mixin at the same specificity and silently forks
|
|
797
|
+
// that family off the grammar again (the pre-adoption stock was
|
|
798
|
+
// exactly such a fork). Layout-axis restatements (flex direction,
|
|
799
|
+
// justify, text-align, color) are content decisions and stay legal.
|
|
800
|
+
const sources: Array<[string, string]> = [
|
|
801
|
+
[".hk-affix-row", affixScss],
|
|
802
|
+
[".hk-tag-input-row", tagInputScss],
|
|
803
|
+
[".hk-tpl-row", tplScss],
|
|
804
|
+
[".hk-user-picker-row", userPickerScss],
|
|
805
|
+
];
|
|
806
|
+
for (const [selector, sheet] of sources) {
|
|
807
|
+
const block = flattenBlocks(parseScss(stripScssComments(sheet))).find(
|
|
808
|
+
(candidate) =>
|
|
809
|
+
candidate.prelude
|
|
810
|
+
.trim()
|
|
811
|
+
.split(",")
|
|
812
|
+
.map((sel) => sel.trim())
|
|
813
|
+
.includes(selector),
|
|
814
|
+
);
|
|
815
|
+
expect(block, `${selector} rule exists`).toBeTruthy();
|
|
816
|
+
const offenders = block!.statements
|
|
817
|
+
.map((stmt) => stmt.replace(/\s+/g, " ").trim())
|
|
818
|
+
.filter((stmt) => /^(padding|min-height)\s*[:]/.test(stmt));
|
|
819
|
+
expect(
|
|
820
|
+
offenders,
|
|
821
|
+
`${selector} declares NO padding/min-height of its own — @mixin item owns the row box (a local declaration forks the family off the grammar)`,
|
|
822
|
+
).toEqual([]);
|
|
823
|
+
}
|
|
824
|
+
});
|
|
825
|
+
|
|
826
|
+
it("keeps the grammar's data-checked emission beside the legacy state attrs", () => {
|
|
827
|
+
// The sharpest honest gap of the adoption R3: TagInput/UserPicker
|
|
828
|
+
// rows carry BOTH the legacy state (data-selected / .is-selected —
|
|
829
|
+
// tests and hosts key on those) and the grammar's data-checked (the
|
|
830
|
+
// face + the hover guard). A tsx-only revert of the emission keeps
|
|
831
|
+
// every test green while the checked face silently dies to the
|
|
832
|
+
// hover rule — so the emission itself is pinned at source level.
|
|
833
|
+
expect(
|
|
834
|
+
tagInputTsx,
|
|
835
|
+
"HkTagInput must emit data-checked beside its legacy data-selected (the grammar's checked face and hover guard key on it)",
|
|
836
|
+
).toMatch(/data-checked=\{selected \|\| undefined\}/);
|
|
837
|
+
expect(
|
|
838
|
+
userPickerTsx,
|
|
839
|
+
"HkUserPicker must emit data-checked for the multi-mode draft pick beside the legacy .is-selected class",
|
|
840
|
+
).toMatch(/data-checked=\{props\.mode === "multi" && inDraft\(user\.uid\) \|\| undefined\}/);
|
|
841
|
+
});
|
|
842
|
+
|
|
843
|
+
it("sizes the tag-input grip to the adopted row's content box", () => {
|
|
844
|
+
// The grip is fixed-size inside a flex-auto row: taller than the
|
|
845
|
+
// content box and every selected+reorderable row grows past the
|
|
846
|
+
// grammar min-height while siblings stay on it (the 2026-10-31 R2
|
|
847
|
+
// S1 — 28px grip in a 22px box). Pinned at source level: the grip
|
|
848
|
+
// height must equal 34px − 2×6px.
|
|
849
|
+
const grip = flattenBlocks(parseScss(stripScssComments(tagInputScss))).find(
|
|
850
|
+
(block) => block.prelude.trim() === ".hk-tag-input-grip",
|
|
851
|
+
);
|
|
852
|
+
expect(grip, ".hk-tag-input-grip rule exists").toBeTruthy();
|
|
853
|
+
const height = grip!.statements.find((stmt) => stmt.includes("height:"));
|
|
854
|
+
expect(height, "the grip declares a height").toBeTruthy();
|
|
855
|
+
expect(
|
|
856
|
+
height!.replace(/\s+/g, " ").trim(),
|
|
857
|
+
"grip height = 22px (the 34px row's content box: 34 − 2×6px)",
|
|
858
|
+
).toBe("height: 1.375rem");
|
|
859
|
+
});
|
|
780
860
|
});
|
package/src/index.ts
CHANGED
|
@@ -822,6 +822,12 @@ export {
|
|
|
822
822
|
BOARD3D_HELPERS_LAYER,
|
|
823
823
|
BOARD3D_MAIN_LAYER,
|
|
824
824
|
} from "./components/HkBoard3D";
|
|
825
|
+
export { default as HkStarSystem } from "./components/HkStarSystem";
|
|
826
|
+
export { default as HStarSystem } from "./components/HkStarSystem";
|
|
827
|
+
export type {
|
|
828
|
+
StarSystemBodyInput as HkStarSystemBodyInput,
|
|
829
|
+
FleetBodySpec as HkStarSystemBodySpec,
|
|
830
|
+
} from "./scene3d/holographicFleetSpec";
|
|
825
831
|
export { default as HkMinimap3D } from "./components/HkMinimap3D";
|
|
826
832
|
export { default as HkTrendChart } from "./components/HkTrendChart";
|
|
827
833
|
export { default as HkTreemap } from "./components/HkTreemap";
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import * as THREE from "three";
|
|
3
|
+
|
|
4
|
+
import { fakeAs } from "../test-utils/fakes";
|
|
5
|
+
import {
|
|
6
|
+
hologramHudText,
|
|
7
|
+
makeFleetHologram,
|
|
8
|
+
poseFleetHologram,
|
|
9
|
+
type FleetHologramInput,
|
|
10
|
+
} from "./holographicFleetBody";
|
|
11
|
+
|
|
12
|
+
const INPUT: FleetHologramInput = {
|
|
13
|
+
id: "node-1",
|
|
14
|
+
label: "node-1 engine stack",
|
|
15
|
+
status: "Online",
|
|
16
|
+
detail: "3 endpoints",
|
|
17
|
+
role: "planet",
|
|
18
|
+
radius: 1,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
function mockCanvas(): ReturnType<typeof vi.fn> {
|
|
22
|
+
const fillText = vi.fn();
|
|
23
|
+
const gradient = fakeAs<CanvasGradient>({ addColorStop: vi.fn() });
|
|
24
|
+
const context = fakeAs<CanvasRenderingContext2D>({
|
|
25
|
+
clearRect: vi.fn(),
|
|
26
|
+
fillRect: vi.fn(),
|
|
27
|
+
fillText,
|
|
28
|
+
measureText: (text: string) => fakeAs<TextMetrics>({ width: text.length * 24 }),
|
|
29
|
+
createRadialGradient: () => gradient,
|
|
30
|
+
});
|
|
31
|
+
vi.spyOn(HTMLCanvasElement.prototype, "getContext").mockReturnValue(context);
|
|
32
|
+
return fillText;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
afterEach(() => {
|
|
36
|
+
vi.restoreAllMocks();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
describe("hologramHudText", () => {
|
|
40
|
+
it("contains only the real label, current status and supplied detail", () => {
|
|
41
|
+
expect(hologramHudText(INPUT)).toBe("node-1 engine stack · Online · 3 endpoints");
|
|
42
|
+
expect(hologramHudText({ ...INPUT, status: "Offline", detail: "" }))
|
|
43
|
+
.toBe("node-1 engine stack · Offline");
|
|
44
|
+
expect(hologramHudText({ ...INPUT, label: "", status: "", detail: "" }))
|
|
45
|
+
.toBe("node-1");
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe("makeFleetHologram", () => {
|
|
50
|
+
it("draws the real data on the cylindrical band and animates each layer", () => {
|
|
51
|
+
const fillText = mockCanvas();
|
|
52
|
+
const hologram = makeFleetHologram(INPUT, new THREE.Color(0x7fb8dd), false);
|
|
53
|
+
|
|
54
|
+
expect(hologram.hudTexture).not.toBeNull();
|
|
55
|
+
const band = hologram.group.getObjectByName("fleet-hologram-hud-band");
|
|
56
|
+
expect(band).toBeInstanceOf(THREE.Mesh);
|
|
57
|
+
expect((band as THREE.Mesh).geometry).toBeInstanceOf(THREE.CylinderGeometry);
|
|
58
|
+
expect(fillText).toHaveBeenCalled();
|
|
59
|
+
for (const call of fillText.mock.calls) {
|
|
60
|
+
expect(call[0]).toBe("node-1 engine stack · Online · 3 endpoints");
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Decorative rings and the text band never widen the body's pointer
|
|
64
|
+
// target. Only the central polyhedron keeps the default raycaster.
|
|
65
|
+
const hits: THREE.Intersection[] = [];
|
|
66
|
+
band?.raycast(new THREE.Raycaster(), hits);
|
|
67
|
+
expect(hits).toHaveLength(0);
|
|
68
|
+
|
|
69
|
+
const initialRingY = hologram.rings.map((ring) => ring.pivot.rotation.y);
|
|
70
|
+
poseFleetHologram(hologram, 5, 20);
|
|
71
|
+
expect(hologram.mesh.rotation.y).toBeCloseTo(Math.PI / 2, 6);
|
|
72
|
+
hologram.rings.forEach((ring, index) => {
|
|
73
|
+
expect(ring.pivot.rotation.y).not.toBe(initialRingY[index]);
|
|
74
|
+
});
|
|
75
|
+
expect(hologram.hudTexture?.offset.x).toBeCloseTo(0.09, 6);
|
|
76
|
+
poseFleetHologram(hologram, 10, 20);
|
|
77
|
+
expect(hologram.hudTexture?.offset.x).toBeCloseTo(0.18, 6);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("uses three rings for a hub and two for a standard node", () => {
|
|
81
|
+
mockCanvas();
|
|
82
|
+
const hub = makeFleetHologram({ ...INPUT, role: "star" }, new THREE.Color(), false);
|
|
83
|
+
const planet = makeFleetHologram(INPUT, new THREE.Color(), false);
|
|
84
|
+
expect(hub.rings).toHaveLength(3);
|
|
85
|
+
expect(planet.rings).toHaveLength(2);
|
|
86
|
+
expect(hub.mesh.geometry).toBeInstanceOf(THREE.IcosahedronGeometry);
|
|
87
|
+
expect(planet.mesh.geometry).toBeInstanceOf(THREE.DodecahedronGeometry);
|
|
88
|
+
});
|
|
89
|
+
});
|