From f3ed47420b7cf4b173a9507abc195759ad033ef8 Mon Sep 17 00:00:00 2001 From: Kosmos Date: Mon, 20 Apr 2026 21:02:04 +0000 Subject: [PATCH] Release 0.0.5 --- module.json | 2 +- scripts/adapters/foundry-runtime.js | 4 ++- scripts/apps/audit-report-app.js | 40 +++++++++++++++++------------ tools/offline-analyze.mjs | 1 + 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/module.json b/module.json index 9295ccd..72b823a 100644 --- a/module.json +++ b/module.json @@ -2,7 +2,7 @@ "id": "kosmos-storage-audit", "title": "Kosmos Storage Audit", "description": "Analyzes media references and risky storage locations across Foundry data and public roots.", - "version": "0.0.4", + "version": "0.0.5", "compatibility": { "minimum": "13", "verified": "13" diff --git a/scripts/adapters/foundry-runtime.js b/scripts/adapters/foundry-runtime.js index 0b8cb36..af73279 100644 --- a/scripts/adapters/foundry-runtime.js +++ b/scripts/adapters/foundry-runtime.js @@ -26,6 +26,8 @@ function worldCollectionEntries() { if (!game.world) return []; const entries = []; for (const collection of game.collections ?? []) { + const collectionDocumentName = collection.documentName ?? null; + if (collectionDocumentName === "ChatMessage") continue; const docs = Array.from(collection.values?.() ?? []); for (const doc of docs) { entries.push({ @@ -34,7 +36,7 @@ function worldCollectionEntries() { ownerType: "world", ownerId: game.world.id, systemId: game.world.system, - subtype: doc.documentName?.toLowerCase() ?? collection.documentName?.toLowerCase() ?? "document" + subtype: doc.documentName?.toLowerCase() ?? collectionDocumentName?.toLowerCase() ?? "document" }, sourceLabel: `${doc.documentName ?? "Document"} ${doc.id}`, sourceName: doc.name ?? null, diff --git a/scripts/apps/audit-report-app.js b/scripts/apps/audit-report-app.js index bbf4832..08d8f29 100644 --- a/scripts/apps/audit-report-app.js +++ b/scripts/apps/audit-report-app.js @@ -7,8 +7,7 @@ export class StorageAuditReportApp extends foundry.applications.api.ApplicationV runAnalysis: StorageAuditReportApp.#onRunAnalysis, toggleShowAll: StorageAuditReportApp.#onToggleShowAll, toggleRaw: StorageAuditReportApp.#onToggleRaw, - exportReport: StorageAuditReportApp.#onExportReport, - openSource: StorageAuditReportApp.#onOpenSource + exportReport: StorageAuditReportApp.#onExportReport }, window: { title: "Kosmos Storage Audit", @@ -88,6 +87,13 @@ export class StorageAuditReportApp extends foundry.applications.api.ApplicationV _replaceHTML(result, content) { content.replaceChildren(result); + for (const link of content.querySelectorAll(".content-link[data-uuid]")) { + link.addEventListener("click", event => { + event.preventDefault(); + event.stopPropagation(); + void openSourceUuid(link.dataset.uuid); + }); + } } async runAnalysis() { @@ -199,20 +205,6 @@ export class StorageAuditReportApp extends foundry.applications.api.ApplicationV return this.exportReport(); } - static async #onOpenSource(_event, button) { - const uuid = button?.dataset?.uuid; - if (!uuid) return; - const document = await fromUuid(uuid); - if (document?.sheet) { - document.sheet.render(true, { focus: true }); - return; - } - if (document?.parent?.sheet) { - document.parent.sheet.render(true, { focus: true }); - return; - } - ui.notifications.warn(format("KSA.Notify.OpenSourceFailed", { uuid })); - } } function renderProgress(progress, loading) { @@ -558,5 +550,19 @@ function renderLocalizedCodeText(key, data, codeValues) { function renderSourceLink(source) { const label = source.sourceName ? `${source.sourceLabel} (${source.sourceName})` : source.sourceLabel; if (!source.sourceUuid) return escapeHtml(label); - return `${escapeHtml(source.sourceUuid)}${label ? ` ${escapeHtml(label)}` : ""}`; + return `${escapeHtml(source.sourceUuid)}${label ? ` ${escapeHtml(label)}` : ""}`; +} + +async function openSourceUuid(uuid) { + if (!uuid) return; + const document = await fromUuid(uuid); + if (document?.sheet) { + document.sheet.render(true, { focus: true }); + return; + } + if (document?.parent?.sheet) { + document.parent.sheet.render(true, { focus: true }); + return; + } + ui.notifications.warn(format("KSA.Notify.OpenSourceFailed", { uuid })); } diff --git a/tools/offline-analyze.mjs b/tools/offline-analyze.mjs index e643e81..c5c8b00 100644 --- a/tools/offline-analyze.mjs +++ b/tools/offline-analyze.mjs @@ -48,6 +48,7 @@ async function* listWorldSources() { const collectionsDir = path.join(dataRoot, "worlds", worldId, "data"); const collectionNames = await fs.readdir(collectionsDir); for (const collectionName of collectionNames.sort()) { + if (collectionName === "messages") continue; const dbPath = path.join(collectionsDir, collectionName); const db = new ClassicLevel(dbPath, { keyEncoding: "utf8", valueEncoding: "json" }); await db.open();