Skip to content

Commit f82dbf2

Browse files
committed
chore(ui): add global.d.ts to extend Window interface
1 parent 2ab6136 commit f82dbf2

1 file changed

Lines changed: 84 additions & 0 deletions

File tree

public/global.d.ts

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,89 @@
1+
// Import Third-party Dependencies
2+
import type { HLJSApi } from "highlight.js";
3+
4+
// Import Internal Dependencies
5+
import type { Settings } from "./components/views/settings/settings.js";
6+
import type { ViewNavigation } from "./components/navigation/navigation.js";
7+
import type { Wiki } from "./components/wiki/wiki.js";
8+
import type { NetworkNavigation } from "./core/network-navigation.js";
9+
import type { WebSocketClient } from "./websocket.js";
10+
111
declare global {
212
interface Window {
13+
/**
14+
* Cached package specifications received from the server (e.g. `"express@4.18.0"`).
15+
* Populated on the `INIT` / `RELOAD` WebSocket events.
16+
*/
17+
cachedSpecs: string[];
18+
19+
/**
20+
* The `<nsecure-locker>` custom element placed in the network view.
21+
* `null` until the network dataset is first loaded.
22+
*/
23+
locker: (HTMLElement & { nsn: unknown }) | null;
24+
25+
/**
26+
* Application settings instance, hydrated from the `/config` endpoint.
27+
* Contains the active theme, ignored warnings/flags, and other UI preferences.
28+
*/
29+
settings: Settings;
30+
31+
/**
32+
* Localisation dictionary fetched from `/i18n`.
33+
* Indexed as `window.i18n[lang][section][key]`.
34+
*/
35+
i18n: Record<string, Record<string, Record<string, string>>>;
36+
37+
/**
38+
* Controls which top-level view (network / home / settings / search) is active.
39+
*/
40+
navigation: ViewNavigation;
41+
42+
/**
43+
* The slide-in documentation / wiki panel controller.
44+
*/
45+
wiki: Wiki;
346

47+
/**
48+
* The currently active package displayed in the network graph, in `"name@version"` format.
49+
*/
50+
activePackage: string;
51+
52+
/**
53+
* Vulnerability strategy identifier coming from the loaded `NodeSecureDataSet`
54+
* (e.g. `"npm"`, `"sonatype"`, …).
55+
*/
56+
vulnerabilityStrategy: string;
57+
58+
/**
59+
* Keyboard / arrow-key navigation controller for the dependency network graph.
60+
*/
61+
networkNav: NetworkNavigation;
62+
63+
/**
64+
* The `<nsecure-legend>` custom element rendered in the network view.
65+
* Exposes `show()` / `hide()` helpers and the reactive `isVisible` property.
66+
*/
67+
legend: HTMLElement & { isVisible: boolean; show(): void; hide(): void };
68+
69+
/**
70+
* WebSocket client used to communicate with the local nsecure server.
71+
* Assigned during app startup; dispatches typed `CustomEvent`s via `EventTarget`.
72+
*/
73+
socket: WebSocketClient;
74+
75+
/**
76+
* The currently expanded `<expandable-span>` legend element.
77+
* `null` when no legend item is open.
78+
*/
79+
activeLegendElement: HTMLElement | null;
80+
81+
/**
82+
* The `highlight.js` core instance, exposed globally for the inline code-fetcher widget.
83+
* The `highlightjs-line-numbers` plugin attaches `initLineNumbersOnLoad` at runtime.
84+
*/
85+
hljs: HLJSApi & { initLineNumbersOnLoad(): void };
486
}
587
}
88+
89+
export {};

0 commit comments

Comments
 (0)