function escapeHtml(text) { return text.replace(/[&<>"]/g, (char) => { if (char === "&") return "&"; if (char === "<") return "<"; if (char === ">") return ">"; return """; }); } function time(at) { return new Date(at).toLocaleTimeString("zh-CN", { hour12: false }); } function checkRow(check) { return `
  • ${check.pass ? "PASS" : "FAIL"} ${escapeHtml(check.label)} ${escapeHtml(check.detail)}
  • `; } function stepRow(step, index) { return `
  • ${index + 1}
    ${escapeHtml(step.title)} 只展示
    ${escapeHtml(step.command)}

    ${escapeHtml(step.note)}

  • `; } export function mountApp(root) { root.innerHTML = `

    签名与公证准备

    Developer ID · hardened runtime · 公证 · Authenticode · GPG
    只读 · 不执行 —

    平台计划

    — —
      边界

        本机准备度

        —
          环境变量(只判断存在)

            这里只显示 key 是否存在,不读取、不展示、不记录任何值。

            计划自检

            —

              失败现象 → 检查 → 修法

              未实测,来自官方文档与公开报错
              现象检查修法
              签名不受信任证书链 / Team ID换 Developer ID 并补中间证书
              公证被拒notarytool log修 hardened runtime / 权限说明
              Gatekeeper 仍拦截是否装订票据staple 后再分发
              Windows 无签名时间戳服务器换可用 RFC3161 服务

              活动

              只读检查
                `; const score = root.querySelector('[data-testid="score"]'); const planTitle = root.querySelector('[data-testid="plan-title"]'); const planSummary = root.querySelector('[data-testid="plan-summary"]'); const stepsEl = root.querySelector('[data-testid="steps"]'); const limitsEl = root.querySelector('[data-testid="limits"]'); const readinessScore = root.querySelector('[data-testid="readiness-score"]'); const toolsEl = root.querySelector('[data-testid="tools"]'); const envEl = root.querySelector('[data-testid="env"]'); const checksEl = root.querySelector('[data-testid="checks"]'); const checkCount = root.querySelector('[data-testid="check-count"]'); const eventsEl = root.querySelector('[data-testid="events"]'); let state = null; let selected = "macos"; function current() { return state?.plans.find((plan) => plan.id === selected); } function renderPlan() { if (!state) return; const plan = current(); if (planTitle) planTitle.textContent = plan?.title ?? "—"; if (planSummary) planSummary.textContent = plan?.summary ?? "—"; if (stepsEl) { stepsEl.innerHTML = (plan?.steps ?? []).map(stepRow).join(""); } if (limitsEl) { limitsEl.innerHTML = (plan?.limits ?? []) .map((limit) => `
              • ${escapeHtml(limit)}
              • `) .join(""); } } function renderReadiness() { if (!state) return; if (readinessScore) { readinessScore.textContent = `${state.readiness.score} / 100 · ${state.readiness.platform}`; } if (toolsEl) { toolsEl.innerHTML = state.readiness.tools .map((tool) => `
              • ${tool.present ? "found" : "missing"} ${escapeHtml(tool.name)}
              • `) .join(""); } if (envEl) { envEl.innerHTML = state.readiness.env .map((row) => `
              • ${row.present ? "set" : "unset"} ${escapeHtml(row.key)}
              • `) .join(""); } } function renderChecks() { if (!state) return; if (checksEl) checksEl.innerHTML = state.checks.map(checkRow).join(""); if (checkCount) { const passed = state.checks.filter((check) => check.pass).length; checkCount.textContent = `${passed}/${state.checks.length} 通过`; } if (score) { score.textContent = `${state.score} / 100`; score.className = `pill ${state.score === 100 ? "ok-pill" : "bad-pill"}`; } } function renderEvents() { if (!eventsEl || !state) return; eventsEl.innerHTML = state.events.length === 0 ? `
              • 暂无活动
              • ` : state.events .slice(0, 8) .map((row) => `
              • ${time(row.at)} ${escapeHtml(row.kind)} ${escapeHtml(row.detail)}
              • `) .join(""); } function render(next) { state = next; renderPlan(); renderReadiness(); renderChecks(); renderEvents(); } function select(id) { selected = id; if (state) renderPlan(); } void window.api.signing.snapshot().then(render); window.api.signing.onEvent(() => { void window.api.signing.snapshot().then(render); }); root .querySelector('[data-testid="refresh"]') ?.addEventListener("click", async () => { render(await window.api.signing.refresh()); }); for (const id of ["macos", "windows", "linux"]) { root .querySelector(`[data-testid="plan-${id}"]`) ?.addEventListener("click", () => select(id)); } window.__prepareShots = async (stage) => { document.body.dataset.shot = stage; render(await window.api.signing.refresh()); select(stage === "matrix" ? "windows" : "macos"); if (stage === "notarize") { document .querySelector('[data-step="notarize"]') ?.scrollIntoView({ block: "center" }); return; } document.querySelector(".plan-card")?.scrollIntoView({ block: "start" }); }; window.__demo = async () => { const next = await window.api.signing.snapshot(); state = next; const mac = next.plans.find((plan) => plan.id === "macos"); const win = next.plans.find((plan) => plan.id === "windows"); const linux = next.plans.find((plan) => plan.id === "linux"); const macText = (mac?.steps ?? []).map((step) => step.command).join("\n"); return { score: next.score, checks: next.checks.length, passed: next.checks.filter((check) => check.pass).length, plans: next.plans.length, macSteps: mac?.steps.length ?? 0, winSteps: win?.steps.length ?? 0, linuxSteps: linux?.steps.length ?? 0, noExec: next.plans.every((plan) => plan.steps.every((step) => step.executes === false)), envKeys: next.readiness.env.length, tools: next.readiness.tools.length, secretsOnly: next.plans.every((plan) => plan.secrets.every((key) => /^[A-Z0-9_]+$/.test(key))), notary: macText.includes("submit") && macText.includes("--wait"), staple: macText.includes("staple"), }; }; } //# sourceMappingURL=App.js.map