From b70ff03e07e22db5180843a70b5dbd63ab103389 Mon Sep 17 00:00:00 2001 From: Kur0mi Date: Sun, 14 Jun 2026 10:09:16 +0200 Subject: [PATCH] obsidian publication fix --- .github/workflows/release.yml | 10 +++++++ README.md | 2 +- main.js | 50 ++++++++++++++++++++++++++++------- manifest.json | 2 +- 4 files changed, 52 insertions(+), 12 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7f8c272..aafa53f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,6 +10,8 @@ jobs: runs-on: ubuntu-latest permissions: contents: write + id-token: write + attestations: write steps: - uses: actions/checkout@v4 @@ -20,6 +22,14 @@ jobs: test -f styles.css node -e "JSON.parse(require('fs').readFileSync('manifest.json', 'utf8'))" + - name: Attest release assets + uses: actions/attest-build-provenance@v2 + with: + subject-path: | + main.js + manifest.json + styles.css + - name: Create draft release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/README.md b/README.md index da0e7dc..644250d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Mini World Map -Mini World Map visualizes an Obsidian vault as a hierarchy-first world map with internal links layered on top. +Mini World Map visualizes your vault as a hierarchy-first world map with internal links layered on top. ## Features diff --git a/main.js b/main.js index c7ce53b..13cdaf1 100644 --- a/main.js +++ b/main.js @@ -155,7 +155,6 @@ class MiniWorldMapPlugin extends Plugin { this.app.workspace.onLayoutReady(() => { this.loadNativeGraphSettings(); - this.rebuildIndex("startup"); }); } @@ -179,6 +178,7 @@ class MiniWorldMapPlugin extends Plugin { } scheduleRebuild(reason) { + if (!this.index.ready && !this.hasOpenMapView()) return; if (this.rebuildTimer) window.clearTimeout(this.rebuildTimer); this.rebuildTimer = window.setTimeout(() => { this.rebuildTimer = null; @@ -186,6 +186,10 @@ class MiniWorldMapPlugin extends Plugin { }, 900); } + hasOpenMapView() { + return this.app.workspace.getLeavesOfType(VIEW_TYPE_MINI_WORLD_MAP).length > 0; + } + async rebuildIndex(reason) { try { const started = performance.now(); @@ -292,17 +296,12 @@ class WorldMapIndex { descendantCount: 0 }); - const loaded = typeof this.app.vault.getAllLoadedFiles === "function" - ? this.app.vault.getAllLoadedFiles() - : []; - const markdownFiles = typeof this.app.vault.getMarkdownFiles === "function" - ? this.app.vault.getMarkdownFiles() - : []; - this.stats.loadedEntries = loaded.length; + const { folders, markdownFiles, totalEntries } = this.collectVaultEntries(); + this.stats.loadedEntries = totalEntries; this.stats.scannedMarkdown = markdownFiles.length; - for (const entry of loaded) { - if (entry instanceof TFolder) this.addFolder(entry); + for (const folder of folders) { + this.addFolder(folder); } for (const file of markdownFiles) { @@ -317,6 +316,36 @@ class WorldMapIndex { this.ready = true; } + collectVaultEntries() { + const folders = []; + const markdownFiles = []; + let totalEntries = 0; + const root = typeof this.app.vault.getRoot === "function" + ? this.app.vault.getRoot() + : null; + const stack = root && Array.isArray(root.children) + ? root.children.slice() + : []; + + while (stack.length) { + const entry = stack.pop(); + totalEntries += 1; + + if (entry instanceof TFolder) { + folders.push(entry); + if (Array.isArray(entry.children)) { + for (let index = entry.children.length - 1; index >= 0; index -= 1) { + stack.push(entry.children[index]); + } + } + } else if (entry instanceof TFile && entry.extension === "md") { + markdownFiles.push(entry); + } + } + + return { folders, markdownFiles, totalEntries }; + } + addFolder(folder) { this.ensureFolderPath(normalizeVaultPath(folder.path)); } @@ -1118,6 +1147,7 @@ class MiniWorldMapView extends ItemView { this.contentEl.addClass("mini-world-map-view"); this.syncColorSchemeClass(); this.renderShell(); + if (!this.plugin.index.ready) await this.plugin.rebuildIndex("open"); this.refresh(); } diff --git a/manifest.json b/manifest.json index d915705..ca1b1d9 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "name": "Mini World Map", "version": "0.1.1", "minAppVersion": "1.5.0", - "description": "Visualize an Obsidian vault as a hierarchy-first world map with internal links layered on top.", + "description": "Visualize your vault as a hierarchy-first world map with internal links layered on top.", "author": "Miro0o and Codex", "authorUrl": "https://github.com/Miro0o", "isDesktopOnly": false