From 2ab613694935eadb649030094d609c254f35af47 Mon Sep 17 00:00:00 2001 From: GENTILHOMME Thomas Date: Tue, 24 Mar 2026 18:27:48 +0100 Subject: [PATCH 1/2] chore: start working on d.ts --- public/global.d.ts | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 public/global.d.ts diff --git a/public/global.d.ts b/public/global.d.ts new file mode 100644 index 00000000..a5c5f307 --- /dev/null +++ b/public/global.d.ts @@ -0,0 +1,5 @@ +declare global { + interface Window { + + } +} From b6307be60e8086d23117734ff5efc0b747d461eb Mon Sep 17 00:00:00 2001 From: GENTILHOMME Thomas Date: Tue, 24 Mar 2026 21:35:46 +0100 Subject: [PATCH 2/2] chore(ui): add global.d.ts to extend Window interface --- public/global.d.ts | 84 ++++++++++++++++++++++++++++++++++++++++++++ public/jsconfig.json | 10 ++++++ 2 files changed, 94 insertions(+) create mode 100644 public/jsconfig.json diff --git a/public/global.d.ts b/public/global.d.ts index a5c5f307..84b76275 100644 --- a/public/global.d.ts +++ b/public/global.d.ts @@ -1,5 +1,89 @@ +// Import Third-party Dependencies +import type { HLJSApi } from "highlight.js"; + +// Import Internal Dependencies +import type { Settings } from "./components/views/settings/settings.js"; +import type { ViewNavigation } from "./components/navigation/navigation.js"; +import type { Wiki } from "./components/wiki/wiki.js"; +import type { NetworkNavigation } from "./core/network-navigation.js"; +import type { WebSocketClient } from "./websocket.js"; + declare global { interface Window { + /** + * Cached package specifications received from the server (e.g. `"express@4.18.0"`). + * Populated on the `INIT` / `RELOAD` WebSocket events. + */ + cachedSpecs: string[]; + + /** + * The `` custom element placed in the network view. + * `null` until the network dataset is first loaded. + */ + locker: (HTMLElement & { nsn: unknown }) | null; + + /** + * Application settings instance, hydrated from the `/config` endpoint. + * Contains the active theme, ignored warnings/flags, and other UI preferences. + */ + settings: Settings; + + /** + * Localisation dictionary fetched from `/i18n`. + * Indexed as `window.i18n[lang][section][key]`. + */ + i18n: Record>>; + + /** + * Controls which top-level view (network / home / settings / search) is active. + */ + navigation: ViewNavigation; + + /** + * The slide-in documentation / wiki panel controller. + */ + wiki: Wiki; + /** + * The currently active package displayed in the network graph, in `"name@version"` format. + */ + activePackage: string; + + /** + * Vulnerability strategy identifier coming from the loaded `NodeSecureDataSet` + * (e.g. `"npm"`, `"sonatype"`, …). + */ + vulnerabilityStrategy: string; + + /** + * Keyboard / arrow-key navigation controller for the dependency network graph. + */ + networkNav: NetworkNavigation; + + /** + * The `` custom element rendered in the network view. + * Exposes `show()` / `hide()` helpers and the reactive `isVisible` property. + */ + legend: HTMLElement & { isVisible: boolean; show(): void; hide(): void }; + + /** + * WebSocket client used to communicate with the local nsecure server. + * Assigned during app startup; dispatches typed `CustomEvent`s via `EventTarget`. + */ + socket: WebSocketClient; + + /** + * The currently expanded `` legend element. + * `null` when no legend item is open. + */ + activeLegendElement: HTMLElement | null; + + /** + * The `highlight.js` core instance, exposed globally for the inline code-fetcher widget. + * The `highlightjs-line-numbers` plugin attaches `initLineNumbersOnLoad` at runtime. + */ + hljs: HLJSApi & { initLineNumbersOnLoad(): void }; } } + +export {}; diff --git a/public/jsconfig.json b/public/jsconfig.json new file mode 100644 index 00000000..da73add0 --- /dev/null +++ b/public/jsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "checkJs": false, + "lib": ["dom", "dom.iterable", "ESNext"], + "module": "ESNext", + "moduleResolution": "bundler", + "target": "ESNext" + }, + "include": ["./**/*.js", "./global.d.ts"] +}