ci-platforms / darwin amd64 smoke (push) Skipped
GitHub / linux amd64 native GitHub-hosted native CI: success
ci-platforms / windows amd64 smoke (push) Skipped
GitHub / windows amd64 native GitHub-hosted native CI: success
GitHub / darwin arm64 native GitHub-hosted native CI: success
GitHub / darwin amd64 native GitHub-hosted native CI: success
ci / checks (push) Failing after 1h21m34s
ci / native-authoring (push) Skipped
ci-platforms / darwin arm64 smoke (push) Skipped
github-native / gitea-pending (push) Skipped
github-native / darwin amd64 native (push) Skipped
github-native / linux amd64 native (push) Skipped
github-native / windows amd64 native (push) Skipped
github-native / darwin arm64 native (push) Skipped
github-native / gitea-result (push) Skipped
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 12m4s
ci / release (push) Skipped
Add dockable Art tools, animation and previews, guarded asset workflows, and the Web Asset Studio built on the shared Art Core. Expand English and Russian documentation, interactive Try scenes, examples and editor icons. Add audio waveform navigation, source analysis, guarded previews and a browser Worker mixer. Preserve source changes and recovery with bounded checks, and strengthen native, browser and interoperability CI. Prepare version 0.12.5 and manually built native artifact candidates. Fix the production site image demo build dependency. Reuse immutable scene indices when capturing keyframes. Wait for real Persist save/load completion in component tests. Stabilize browser Game View captures outside pointer hover. Aseprite interchange and persistent Audio EDL recovery remain limited; the artifact workflow does not publish releases or change stable.
298 lines
13 KiB
JavaScript
298 lines
13 KiB
JavaScript
"use strict";
|
|
|
|
const assetV = (document.querySelector('meta[name="aego-assets"]') || {}).content || "";
|
|
|
|
(function () {
|
|
const root = document.querySelector('meta[name="aego-root"]').content;
|
|
const ru = document.documentElement.lang === "ru";
|
|
const input = document.getElementById("docs-search");
|
|
const results = document.getElementById("results");
|
|
const NAV_KEY = "aego.docs.groups";
|
|
const SECTIONS = ru
|
|
? { start: "Начало работы", guides: "Руководства", reference: "Справочник" }
|
|
: { start: "Getting started", guides: "Guides", reference: "Reference" };
|
|
let indexRequest = null;
|
|
let active = 0;
|
|
let shown = [];
|
|
|
|
const menu = document.querySelector(".menu");
|
|
const scrim = document.querySelector(".scrim");
|
|
const doc = document.querySelector(".doc");
|
|
const narrow = matchMedia("(max-width: 899px)");
|
|
function setNav(open) {
|
|
document.body.classList.toggle("nav-open", open);
|
|
menu.setAttribute("aria-expanded", String(open));
|
|
scrim.hidden = !open;
|
|
doc.inert = open;
|
|
document.body.style.overflow = open ? "hidden" : "";
|
|
|
|
}
|
|
menu.addEventListener("click", () => setNav(!document.body.classList.contains("nav-open")));
|
|
scrim.addEventListener("click", () => setNav(false));
|
|
document.querySelector(".side").addEventListener("click", (e) => {
|
|
if (e.target.closest("a") && narrow.matches) setNav(false);
|
|
});
|
|
document.addEventListener("keydown", (e) => {
|
|
if (e.key === "Escape" && document.body.classList.contains("nav-open")) setNav(false);
|
|
});
|
|
narrow.addEventListener("change", (e) => {
|
|
if (!e.matches) setNav(false);
|
|
});
|
|
|
|
// The theme switch cycles Auto, Dark and Light; Auto follows the system (D345).
|
|
const THEME_KEY = "aego.docs.theme";
|
|
const MODES = ["auto", "dark", "light"];
|
|
const LABELS = ru ? { auto: "Системная", dark: "Тёмная", light: "Светлая" } : { auto: "Auto", dark: "Dark", light: "Light" };
|
|
const prefersLight = matchMedia("(prefers-color-scheme: light)");
|
|
const themeButton = document.querySelector(".theme");
|
|
const effective = () => document.documentElement.dataset.theme || (prefersLight.matches ? "light" : "dark");
|
|
function applyMode(mode) {
|
|
if (mode === "auto") delete document.documentElement.dataset.theme;
|
|
else document.documentElement.dataset.theme = mode;
|
|
themeButton.dataset.mode = mode;
|
|
themeButton.title = themeButton.ariaLabel = (ru ? "Тема: " : "Theme: ") + LABELS[mode];
|
|
globalThis.aegoTheme = effective();
|
|
const media = mode === "auto" ? "(prefers-color-scheme: light)" : mode === "light" ? "all" : "not all";
|
|
for (const s of document.querySelectorAll("picture.themed source")) s.media = media;
|
|
document.dispatchEvent(new CustomEvent("aego-theme", { detail: globalThis.aegoTheme }));
|
|
}
|
|
let mode = "auto";
|
|
try {
|
|
const saved = localStorage.getItem(THEME_KEY);
|
|
if (MODES.includes(saved)) mode = saved;
|
|
} catch (_) {}
|
|
applyMode(mode);
|
|
themeButton.addEventListener("click", () => {
|
|
mode = MODES[(MODES.indexOf(mode) + 1) % MODES.length];
|
|
applyMode(mode);
|
|
try {
|
|
localStorage.setItem(THEME_KEY, mode);
|
|
} catch (_) {}
|
|
});
|
|
prefersLight.addEventListener("change", () => {
|
|
if (mode === "auto") applyMode("auto");
|
|
});
|
|
|
|
function loadState() {
|
|
try {
|
|
return JSON.parse(localStorage.getItem(NAV_KEY)) || {};
|
|
} catch (_) {
|
|
return {};
|
|
}
|
|
}
|
|
|
|
const state = loadState();
|
|
for (const d of document.querySelectorAll(".side details.group")) {
|
|
const id = d.dataset.group;
|
|
d.addEventListener("toggle", () => {
|
|
state[id] = d.open;
|
|
try {
|
|
localStorage.setItem(NAV_KEY, JSON.stringify(state));
|
|
} catch (_) {}
|
|
});
|
|
}
|
|
const side = document.querySelector(".side");
|
|
addEventListener("pagehide", () => {
|
|
try {
|
|
sessionStorage.setItem("aego.docs.side", String(side.scrollTop));
|
|
} catch (_) {}
|
|
});
|
|
|
|
for (const pre of document.querySelectorAll(".doc pre")) {
|
|
const code = pre.querySelector("code");
|
|
if (!code || pre.classList.contains("sig")) continue;
|
|
const btn = document.createElement("button");
|
|
btn.type = "button";
|
|
btn.className = "copy";
|
|
btn.textContent = ru ? "Копировать" : "Copy";
|
|
btn.addEventListener("click", async () => {
|
|
try {
|
|
await navigator.clipboard.writeText(code.textContent);
|
|
btn.textContent = ru ? "Скопировано" : "Copied";
|
|
} catch (_) {
|
|
btn.textContent = ru ? "Нет доступа" : "Blocked";
|
|
}
|
|
setTimeout(() => (btn.textContent = ru ? "Копировать" : "Copy"), 1200);
|
|
});
|
|
pre.appendChild(btn);
|
|
}
|
|
|
|
const tocLinks = [...document.querySelectorAll(".toc a")];
|
|
if (tocLinks.length && "IntersectionObserver" in window) {
|
|
const byId = new Map(tocLinks.map((a) => [decodeURIComponent(a.hash.slice(1)), a]));
|
|
const obs = new IntersectionObserver(
|
|
(entries) => {
|
|
for (const e of entries) {
|
|
if (!e.isIntersecting) continue;
|
|
const a = byId.get(e.target.id);
|
|
if (!a) continue;
|
|
for (const x of tocLinks) x.classList.toggle("active", x === a);
|
|
}
|
|
},
|
|
{ rootMargin: "-60px 0px -70% 0px" },
|
|
);
|
|
for (const id of byId.keys()) {
|
|
const el = document.getElementById(id);
|
|
if (el) obs.observe(el);
|
|
}
|
|
}
|
|
|
|
function escapeHTML(s) {
|
|
return s.replace(/[&<>"]/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c]);
|
|
}
|
|
|
|
// Search data is JSON, not trusted HTML or a source of external URLs.
|
|
function searchHref(u) {
|
|
if (typeof u !== "string" || !u || u.trim() !== u || /[\\\u0000-\u001f\u007f]/.test(u) ||
|
|
/^(?:[a-z][a-z0-9+.-]*:|\/)/i.test(u)) return null;
|
|
return root + u;
|
|
}
|
|
|
|
function render(items) {
|
|
let html = "";
|
|
let last = null;
|
|
items.forEach((it, i) => {
|
|
if (it.c !== last) {
|
|
html += `<li class="cat">${escapeHTML(SECTIONS[it.c] || (ru ? "Другое" : "Other"))}</li>`;
|
|
last = it.c;
|
|
}
|
|
const icon = typeof it.ic === "string" && /^[A-Za-z0-9_.-]+$/.test(it.ic) ? it.ic : "";
|
|
const ic = icon ? `<svg width="16" height="16" class="ic" aria-hidden="true"><use href="${escapeHTML(root + "assets/icons.svg?v=" + assetV + "#" + icon)}"/></svg>` : "<span></span>";
|
|
html += `<li${i === active ? ' class="active"' : ""}><a href="${escapeHTML(searchHref(it.u))}">${ic}<span>${escapeHTML(it.t)}</span><span class="kind">${escapeHTML(it.l || it.k)}</span><span class="search-context">${escapeHTML([it.g, it.v].filter(Boolean).join(" · "))}</span>${it.s ? `<span class="summary">${escapeHTML(it.s)}</span>` : ""}</a></li>`;
|
|
});
|
|
results.innerHTML = html || `<li class="cat">${ru ? "Ничего не найдено. Попробуйте название, ID или описание задачи." : "No results. Try a name, ID or task description."}</li>`;
|
|
results.hidden = false;
|
|
}
|
|
|
|
async function search() {
|
|
const q = input.value.trim().toLowerCase();
|
|
if (!q) {
|
|
results.hidden = true;
|
|
return;
|
|
}
|
|
let index;
|
|
try {
|
|
if (!indexRequest) indexRequest = fetch((document.querySelector('meta[name="aego-search"]') || {}).content || root + "search.json").then((response) => {
|
|
if (!response.ok) throw new Error("Search index: " + response.status);
|
|
return response.json();
|
|
});
|
|
index = await indexRequest;
|
|
} catch (_) {
|
|
indexRequest = null;
|
|
if (input.value.trim().toLowerCase() !== q) return;
|
|
shown = [];
|
|
results.innerHTML = `<li class="cat">${ru ? "Не удалось загрузить поиск. Проверьте соединение и повторите запрос." : "Search could not load. Check your connection and try again."}</li>`;
|
|
results.hidden = false;
|
|
return;
|
|
}
|
|
const top = AegoDocsSearch.rank(index.filter((item) => item && searchHref(item.u) !== null), q);
|
|
if (input.value.trim().toLowerCase() !== q) return;
|
|
// Preserve relevance: a technical ID/error code must not move below
|
|
// unrelated guides merely because its navigation category is Reference.
|
|
shown = top;
|
|
active = 0;
|
|
render(shown);
|
|
}
|
|
|
|
input.addEventListener("input", search);
|
|
input.addEventListener("keydown", (e) => {
|
|
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
e.preventDefault();
|
|
active = Math.max(0, Math.min(shown.length - 1, active + (e.key === "ArrowDown" ? 1 : -1)));
|
|
render(shown);
|
|
} else if (e.key === "Enter" && shown[active]) {
|
|
const href = searchHref(shown[active].u);
|
|
if (href !== null) location.href = href;
|
|
} else if (e.key === "Escape") {
|
|
results.hidden = true;
|
|
input.blur();
|
|
}
|
|
});
|
|
document.addEventListener("keydown", (e) => {
|
|
if (e.key === "/" && document.activeElement !== input && !/INPUT|TEXTAREA/.test(document.activeElement.tagName)) {
|
|
e.preventDefault();
|
|
input.focus();
|
|
}
|
|
});
|
|
document.addEventListener("click", (e) => {
|
|
if (!e.target.closest(".search")) results.hidden = true;
|
|
});
|
|
})();
|
|
|
|
(function () {
|
|
const demo = document.querySelector(".demo[data-src]");
|
|
if (!demo) return;
|
|
const play = () => {
|
|
if (demo.querySelector("iframe")) return;
|
|
const f = document.createElement("iframe");
|
|
f.src = demo.dataset.src;
|
|
f.title = "Aego demo";
|
|
f.allow = "fullscreen; gamepad; autoplay";
|
|
demo.textContent = "";
|
|
demo.appendChild(f);
|
|
f.addEventListener("load", () => f.focus());
|
|
};
|
|
const KEY = "aego-demo-played";
|
|
demo.querySelector(".demo-play").addEventListener("click", () => {
|
|
try {
|
|
localStorage.setItem(KEY, "1");
|
|
} catch (_) {}
|
|
play();
|
|
});
|
|
try {
|
|
if (localStorage.getItem(KEY)) play();
|
|
} catch (_) {}
|
|
})();
|
|
|
|
(function () {
|
|
const input = document.querySelector(".member-filter input");
|
|
if (!input) return;
|
|
const items = [...document.querySelectorAll("table.api tr[data-name], section.member[data-name]")];
|
|
input.addEventListener("input", () => {
|
|
const q = input.value.trim().toLowerCase();
|
|
for (const el of items) el.classList.toggle("hidden-by-filter", q !== "" && !el.dataset.name.includes(q));
|
|
});
|
|
})();
|
|
|
|
(function () {
|
|
const done = new Set();
|
|
const prefetch = (href) => {
|
|
if (!href || done.has(href)) return;
|
|
done.add(href);
|
|
const l = document.createElement("link");
|
|
l.rel = "prefetch";
|
|
l.href = href;
|
|
document.head.appendChild(l);
|
|
};
|
|
const next = document.querySelector(".pager a.next");
|
|
if (next) prefetch(next.href);
|
|
const local = (a) => a && a.origin === location.origin && a.pathname !== location.pathname && /(\/|\/[^./]+)$/.test(a.pathname);
|
|
const hover = (e) => {
|
|
const a = e.target.closest && e.target.closest("a[href]");
|
|
if (local(a)) prefetch(a.href.split("#")[0]);
|
|
};
|
|
document.addEventListener("pointerover", hover, { passive: true });
|
|
document.addEventListener("focusin", hover);
|
|
})();
|
|
|
|
(function () {
|
|
const OS_NAMES = { windows: "Windows", macos: "macOS", linux: "Linux" };
|
|
const ru = document.documentElement.lang === "ru";
|
|
const ua = ((navigator.userAgentData && navigator.userAgentData.platform) || navigator.platform || navigator.userAgent).toLowerCase();
|
|
const os = /win/.test(ua) ? "windows" : /mac|iphone|ipad/.test(ua) ? "macos" : /linux|x11/.test(ua) && !/android/.test(ua) ? "linux" : "";
|
|
for (const box of document.querySelectorAll(".download")) {
|
|
const main = box.querySelector(".dl-main");
|
|
const pick = os && box.querySelector(`.dl-list li[data-os="${os}"] a`);
|
|
if (pick) {
|
|
main.href = pick.href;
|
|
main.querySelector("span").textContent = ru ? `Скачать для ${OS_NAMES[os]}` : `Download for ${OS_NAMES[os]}`;
|
|
box.querySelector(".dl-file").textContent = pick.dataset.file;
|
|
pick.classList.add("picked");
|
|
pick.parentElement.classList.add("picked");
|
|
} else {
|
|
main.href = box.dataset.fallback;
|
|
main.querySelector("span").textContent = ru ? (os ? `Установить на ${OS_NAMES[os]}` : "Установить") : os ? `Install on ${OS_NAMES[os]}` : "Install";
|
|
}
|
|
}
|
|
})();
|