${message.body}
${message.command === undefined ? null : html`${message.command}`}
import type { TemplateResult } from "lit"; import type { HtmlTemplateTag, PiWebComponentStatus, PiWebInstallationInfo, PiWebPlugin, PiWebStatusMessage, PiWebStatusResponse, PluginRuntimeState } from "@jmfederico/pi-web/plugin-api"; function messagesFor(state: PluginRuntimeState | undefined): PiWebStatusMessage[] { return state?.piWebStatus?.messages ?? []; } function statusFor(state: PluginRuntimeState | undefined): PiWebStatusResponse | undefined { return state?.piWebStatus; } function messageCount(state: PluginRuntimeState | undefined): number { return messagesFor(state).length; } function isLocalOrUnknownInstallation(installation: PiWebInstallationInfo | undefined): boolean { return installation === undefined || installation.kind === "local" || installation.kind === "unknown"; } function shouldShowUpdatesPanel(state: PluginRuntimeState | undefined): boolean { const status = statusFor(state); if (messageCount(state) > 0) return true; if (status === undefined) return false; return isLocalOrUnknownInstallation(status.components.web.installation) || isLocalOrUnknownInstallation(status.components.sessiond.installation); } function formatVersion(version: string | undefined): string { return version === undefined || version === "" ? "unknown" : version; } function installationLabel(installation: PiWebInstallationInfo | undefined): string { if (installation === undefined) return "installation unknown"; if (installation.kind === "pi-package") { const scope = installation.scope === undefined ? "" : ` · ${installation.scope}`; const source = installation.source ?? "Pi package"; return `${source}${scope}`; } if (installation.kind === "npm-global") return "global npm package"; if (installation.kind === "local") return "local checkout"; return "installation unknown"; } function renderComponent(html: HtmlTemplateTag, component: PiWebComponentStatus): TemplateResult { const status = !component.available ? "unavailable" : component.stale ? "restart needed" : "current"; return html`
${command}
Checking PI WEB update status…
No PI WEB update or restart messages.
` : messages.map((message) => html` `)}