G7 증명과 G8 clean-head 승격 준비
This commit is contained in:
parent
94c681d450
commit
5221f79e3f
52 changed files with 6876 additions and 506 deletions
|
|
@ -74,6 +74,8 @@
|
|||
var errors = [];
|
||||
var loadedAt = Date.now();
|
||||
var sentDiagnostics = {};
|
||||
var healthyCheckTimer = null;
|
||||
var healthyObserver = null;
|
||||
function short(value) {
|
||||
return String(value || "").slice(0, 900);
|
||||
}
|
||||
|
|
@ -116,14 +118,68 @@
|
|||
style.opacity !== "0"
|
||||
);
|
||||
}
|
||||
function visibleCount() {
|
||||
function visibleCount(scope) {
|
||||
var root = scope || document;
|
||||
var nodes = Array.prototype.slice.call(
|
||||
document.querySelectorAll(
|
||||
root.querySelectorAll(
|
||||
"main,header,h1,h2,p,a,button,input,select,article,section,.vg-shell,.vg-route-error,.vgops-head,.vgops-diagnostic,.lg-root",
|
||||
),
|
||||
);
|
||||
return nodes.filter(isVisiblyRendered).length;
|
||||
}
|
||||
function appHealth() {
|
||||
var root = document.getElementById("root");
|
||||
var path = window.location.pathname;
|
||||
var isAdmin = path === "/admin" || path.indexOf("/admin/") === 0;
|
||||
var text = (root && root.innerText ? root.innerText : "").trim();
|
||||
var visible = root ? visibleCount(root) : 0;
|
||||
var adminContent = root
|
||||
? root.querySelector(
|
||||
"[data-vignette-admin-root],[data-vignette-admin-diagnostic],[data-testid='admin-ai-page']",
|
||||
)
|
||||
: null;
|
||||
var hasAdminContent = !isAdmin || isVisiblyRendered(adminContent);
|
||||
return {
|
||||
healthy: Boolean(
|
||||
root &&
|
||||
root.childElementCount > 0 &&
|
||||
text.length > 24 &&
|
||||
visible > 0 &&
|
||||
hasAdminContent,
|
||||
),
|
||||
visible: visible,
|
||||
};
|
||||
}
|
||||
function dismissDiagnosticIfHealthy() {
|
||||
if (!appHealth().healthy) return false;
|
||||
var panel = document.getElementById("vignette-boot-diagnostic");
|
||||
if (panel) panel.remove();
|
||||
return true;
|
||||
}
|
||||
function scheduleHealthyCheck() {
|
||||
if (healthyCheckTimer !== null) window.clearTimeout(healthyCheckTimer);
|
||||
healthyCheckTimer = window.setTimeout(function () {
|
||||
healthyCheckTimer = null;
|
||||
dismissDiagnosticIfHealthy();
|
||||
}, 60);
|
||||
}
|
||||
function observeAppHealth() {
|
||||
if (healthyObserver || !window.MutationObserver) return;
|
||||
var root = document.getElementById("root");
|
||||
if (!root) {
|
||||
window.setTimeout(observeAppHealth, 100);
|
||||
return;
|
||||
}
|
||||
healthyObserver = new MutationObserver(scheduleHealthyCheck);
|
||||
healthyObserver.observe(root, {
|
||||
attributes: true,
|
||||
attributeFilter: ["aria-hidden", "class", "hidden", "style"],
|
||||
characterData: true,
|
||||
childList: true,
|
||||
subtree: true,
|
||||
});
|
||||
scheduleHealthyCheck();
|
||||
}
|
||||
function diagnosticApiBase() {
|
||||
var host = window.location.hostname;
|
||||
if (host === "vignette.chanpaca.net" || host.endsWith(".pages.dev")) {
|
||||
|
|
@ -183,19 +239,16 @@
|
|||
}
|
||||
function render(reason) {
|
||||
var path = window.location.pathname;
|
||||
var isAdmin = path === "/admin" || path.indexOf("/admin/") === 0;
|
||||
var text = (document.body && document.body.innerText ? document.body.innerText : "").trim();
|
||||
var visible = visibleCount();
|
||||
var adminContent = document.querySelector(
|
||||
"[data-vignette-admin-root],[data-vignette-admin-diagnostic],[data-testid='admin-ai-page']",
|
||||
);
|
||||
var hasAdminContent = !isAdmin || isVisiblyRendered(adminContent);
|
||||
if (reason === "watchdog" && text.length > 24 && visible > 0 && hasAdminContent) {
|
||||
var old = document.getElementById("vignette-boot-diagnostic");
|
||||
if (old) old.remove();
|
||||
var health = appHealth();
|
||||
if (health.healthy && reason !== "manual") {
|
||||
if (reason !== "watchdog") {
|
||||
sendDiagnostic(reason, text.length, health.visible);
|
||||
}
|
||||
dismissDiagnosticIfHealthy();
|
||||
return;
|
||||
}
|
||||
sendDiagnostic(reason, text.length, visible);
|
||||
sendDiagnostic(reason, text.length, health.visible);
|
||||
|
||||
var panel = document.getElementById("vignette-boot-diagnostic");
|
||||
if (!panel) {
|
||||
|
|
@ -229,7 +282,7 @@
|
|||
text.length +
|
||||
"</dd>",
|
||||
"<dt style=\"padding:7px 9px;background:rgba(0,0,0,.04);font-weight:700\">visibleNodes</dt><dd style=\"margin:0;padding:7px 9px;overflow-wrap:anywhere\">" +
|
||||
visible +
|
||||
health.visible +
|
||||
"</dd>",
|
||||
"<dt style=\"padding:7px 9px;background:rgba(0,0,0,.04);font-weight:700\">elapsed</dt><dd style=\"margin:0;padding:7px 9px;overflow-wrap:anywhere\">" +
|
||||
(Date.now() - loadedAt) +
|
||||
|
|
@ -260,6 +313,7 @@
|
|||
render("manual");
|
||||
},
|
||||
};
|
||||
observeAppHealth();
|
||||
window.setTimeout(function () {
|
||||
render("watchdog");
|
||||
}, 3500);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue