update commit message

This commit is contained in:
2026-05-29 00:27:03 -07:00
parent ed1107a0c0
commit 254f488eca
21 changed files with 565 additions and 210 deletions
+56 -7
View File
@@ -181,6 +181,10 @@
};
}
function hasTarotAccess() {
return window.TarotAppConfig?.hasTarotAccess?.() === true;
}
function syncConnectionInputs() {
const { apiBaseUrlEl, apiKeyEl } = getElements();
const connectionSettings = getConnectionSettings();
@@ -251,8 +255,9 @@
const roles = normalizeConnectionValues(auth.roles);
const scopes = normalizeConnectionValues(auth.scopes);
const authenticated = auth.authenticated === true;
const tarotAccessEnabled = result?.capabilities?.tarot === true;
const accessValue = authenticated
? `${String(auth.accessLevel || "premium").trim() || "premium"}${hasAdminCapability(auth) ? " - admin capable" : ""}`
? `${String(auth.accessLevel || "premium").trim() || "premium"}${hasAdminCapability(auth) ? " - admin capable" : ""}${tarotAccessEnabled ? " - tarot enabled" : " - tarot hidden"}`
: (result.health?.apiKeyRequired ? "API key required" : "public");
const permissionsValue = authenticated
? `roles: ${formatConnectionValues(roles)} | scopes: ${formatConnectionValues(scopes)}`
@@ -399,6 +404,10 @@
}
function getKnownTarotDeckIds() {
if (!hasTarotAccess()) {
return new Set([String(config.defaultSettings?.tarotDeck || "ceremonial-magick").trim().toLowerCase()]);
}
const knownDeckIds = new Set();
const deckOptions = window.TarotCardImages?.getDeckOptions?.();
@@ -419,6 +428,10 @@
}
function getFallbackTarotDeckId() {
if (!hasTarotAccess()) {
return String(config.defaultSettings?.tarotDeck || "ceremonial-magick").trim().toLowerCase();
}
const deckOptions = window.TarotCardImages?.getDeckOptions?.();
if (Array.isArray(deckOptions)) {
for (let i = 0; i < deckOptions.length; i += 1) {
@@ -433,6 +446,11 @@
}
function normalizeTarotDeck(value) {
if (!hasTarotAccess()) {
const preservedValue = String(value || "").trim().toLowerCase();
return preservedValue || String(config.defaultSettings?.tarotDeck || "ceremonial-magick").trim().toLowerCase();
}
const normalized = String(value || "").trim().toLowerCase();
const knownDeckIds = getKnownTarotDeckIds();
@@ -571,6 +589,16 @@
return;
}
if (!hasTarotAccess()) {
tarotDeckEl.innerHTML = "";
const hiddenOption = document.createElement("option");
hiddenOption.value = String(config.defaultSettings?.tarotDeck || "ceremonial-magick").trim().toLowerCase();
hiddenOption.textContent = "Tarot deck unavailable for this API key";
tarotDeckEl.appendChild(hiddenOption);
tarotDeckEl.disabled = true;
return;
}
const deckOptions = window.TarotCardImages?.getDeckOptions?.();
const previousValue = String(tarotDeckEl.value || "").trim().toLowerCase();
tarotDeckEl.innerHTML = "";
@@ -602,6 +630,24 @@
tarotDeckEl.value = normalizeTarotDeck(previousValue);
}
function syncActiveTarotDeck(deckId) {
if (!hasTarotAccess()) {
return;
}
const normalizedDeckId = normalizeTarotDeck(deckId);
if (window.TarotCardImages?.setActiveDeck) {
window.TarotCardImages.setActiveDeck(normalizedDeckId);
}
const { tarotDeckEl } = getElements();
if (tarotDeckEl) {
tarotDeckEl.value = normalizedDeckId;
}
syncDeckCacheStatus(window.TarotCardImages?.getDeckPreloadStatus?.());
}
function applySettingsToInputs(settings) {
const { latEl, lngEl, timeFormatEl, birthDateEl, tarotDeckEl, stellariumBackgroundEl } = getElements();
syncTarotDeckInputOptions();
@@ -619,10 +665,7 @@
stellariumBackgroundEl.checked = normalized.stellariumBackgroundEnabled;
}
syncStellariumBackgroundAvailability();
if (window.TarotCardImages?.setActiveDeck) {
window.TarotCardImages.setActiveDeck(normalized.tarotDeck);
}
syncDeckCacheStatus(window.TarotCardImages?.getDeckPreloadStatus?.());
syncActiveTarotDeck(normalized.tarotDeck);
applyExternalSettings(normalized);
return normalized;
}
@@ -842,13 +885,19 @@
document.addEventListener("connection:updated", () => {
syncConnectionInputs();
void refreshConnectionSummary(getConnectionSettings());
});
document.addEventListener("connection:access-updated", () => {
syncTarotDeckInputOptions();
syncDeckCacheStatus(window.TarotCardImages?.getDeckPreloadStatus?.());
syncActiveTarotDeck(getElements().tarotDeckEl?.value || loadSavedSettings().tarotDeck);
void refreshConnectionSummary(getConnectionSettings());
});
document.addEventListener("tarot:deck-cache-status", (event) => {
syncDeckCacheStatus(event?.detail);
if (hasTarotAccess()) {
syncDeckCacheStatus(event?.detail);
}
});
}