From 335f9ee4b72a283521cb424cae8fc7ac2c4a1337 Mon Sep 17 00:00:00 2001 From: Nystik <236107-Nystik@users.noreply.gitlab.com> Date: Tue, 10 Mar 2026 22:31:01 +0100 Subject: [PATCH] vault management --- .gitignore | 3 +- scripts/patch-obsidian.js | 47 +++++----- server/config.js | 42 ++++++++- server/index.js | 19 +++- server/routes/fs.js | 86 ++++++++++------- server/routes/vault.js | 71 ++++++++++++-- shims/electron/ipc-renderer.js | 59 +++++++++++- shims/fs/transport.js | 10 +- shims/loader.js | 73 ++++++++++----- shims/path.js | 15 ++- shims/ui/vault-manager.js | 163 +++++++++++++++++++++++++++++++++ 11 files changed, 495 insertions(+), 93 deletions(-) create mode 100644 shims/ui/vault-manager.js diff --git a/.gitignore b/.gitignore index 9343a22..7018a64 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ node_modules/ dist/shim-loader.js investigation/ -test-vault/ - +vaults/ diff --git a/scripts/patch-obsidian.js b/scripts/patch-obsidian.js index 018bb9e..c4d8b8e 100644 --- a/scripts/patch-obsidian.js +++ b/scripts/patch-obsidian.js @@ -2,6 +2,7 @@ // Patches the extracted Obsidian asar for browser use: // 1. Removes Content-Security-Policy meta tag // 2. Injects shim-loader.js script (non-deferred, before all other scripts) +// Patches both index.html and starter.html. const fs = require("fs"); const path = require("path"); @@ -12,27 +13,29 @@ if (!asarDir) { process.exit(1); } -const indexPath = path.join(asarDir, "index.html"); -if (!fs.existsSync(indexPath)) { - console.error(`Not found: ${indexPath}`); - process.exit(1); +function patchHtml(filePath) { + if (!fs.existsSync(filePath)) { + console.warn(`[patch] Skipping (not found): ${filePath}`); + return; + } + + let html = fs.readFileSync(filePath, "utf-8"); + + // Remove CSP meta tag + html = html.replace( + /\s*]*>\s*/g, + "\n", + ); + + // Inject shim-loader before the first \n' + + '\n' + - '