|
| 1 | +// Import Third-party Dependencies |
| 2 | +import { getScoreColor } from "@nodesecure/utils"; |
| 3 | + |
1 | 4 | // Import Internal Dependencies |
2 | 5 | import "../bundlephobia/bundlephobia.js"; |
3 | 6 | import { PackageHeader } from "./header/header.js"; |
@@ -211,7 +214,23 @@ export class PackageInfo { |
211 | 214 | this.addNavigationSignal(/** @type {HTMLElement} */ (clone.getElementById("vulnerabilities-nav-menu")), |
212 | 215 | this.dependency.vulnerabilities.length); |
213 | 216 | if (utils.getSettingsConfig().disableExternalRequests === false) { |
214 | | - new Pannels.Scorecard(this).generate(clone); |
| 217 | + const scorecard = new Pannels.Scorecard(); |
| 218 | + scorecard.repository = this.links.github.href ?? ""; |
| 219 | + scorecard.id = "pan-scorecard"; |
| 220 | + scorecard.classList.add("package-container", "hidden"); |
| 221 | + const menu = /** @type {HTMLElement} */ (clone.getElementById("scorecard-menu")); |
| 222 | + const score = /** @type {HTMLElement} */ (clone.getElementById("ossf-score")); |
| 223 | + |
| 224 | + scorecard.addEventListener("scorecard-loaded", (event) => { |
| 225 | + const { detail: data } = /** @type {CustomEvent<import("../../common/scorecard.js").ScorecardData | null>} */ (event); |
| 226 | + menu.style.display = data ? "flex" : "none"; |
| 227 | + if (data) { |
| 228 | + menu.classList.add(getScoreColor(data.score)); |
| 229 | + score.textContent = String(data.score); |
| 230 | + } |
| 231 | + }); |
| 232 | + |
| 233 | + /** @type {HTMLElement} */ (clone.getElementById("pan-scorecard")).replaceWith(scorecard); |
215 | 234 | } |
216 | 235 |
|
217 | 236 | return clone; |
|
0 commit comments