obsidian/desktop-demo-vault-opener
Downloads and opens a plugin’s shipped demo vault in a new Obsidian window (desktop only).
A plugin can attach a <plugin-id>-demo-vault.zip archive to each GitHub release (see archivePluginDemoVault in script-utils/demo-vault.ts; every name shared with it comes from demo-vault-naming.ts). This resolves the plugin’s repository from Obsidian’s community registry, downloads the archive for the chosen version, and opens it as a vault in a new window. When the installed plugin version is behind the latest release, the user is offered a choice between the two versions.
A progress notice is shown immediately (download + extraction can take a while, so the user must see something is happening right away). Only the downloaded ARCHIVE is cached (under the OS temp directory); every invocation extracts a FRESH copy into its own temporary folder and opens that, so a previous session’s edits never leak into a new one. The vault folder is the archive’s own single top-level folder, <plugin-id>-demo-vault-<version>, which reads nicely in Obsidian’s vault switcher and is the same name a hand-unzipped archive produces. Orphaned extracted folders left over from earlier sessions are cleaned up (best-effort) on each open.
Nothing here may touch a platform-only API while the module INITIALIZES. The node: imports below are safe to merely evaluate on mobile — require hands back undefined there and nothing reads it at load time — and because the generated barrels re-export this module, that is a load-bearing property of the whole library rather than a detail of this file. It was learned the hard way: this module once imported adm-zip, whose zip-crypto method opens with a top-level const { randomFillSync } = require('crypto'), and a static import AdmZip from 'adm-zip' therefore killed the library’s load on Android (see the mobile-load check in scripts/helpers/assert-mobile-loadable-bundle.ts, which fails the build on exactly that). Extraction now goes through desktop-zip-extractor.ts, which needs no dependency at all — but any future dependency that initializes against a platform-only API still has to be deferred behind a call-time import().
Interfaces
Section titled “Interfaces”| Interface | Description |
|---|---|
| OpenDemoVaultParams | Parameters for openDemoVault. |
Functions
Section titled “Functions”| Function | Description |
|---|---|
| openDemoVault | Downloads and opens the plugin’s demo vault in a new Obsidian window. Desktop only. If the installed plugin version is the latest (or newer), its demo vault opens directly; otherwise the user chooses between the latest and the currently-installed version. A progress notice is shown immediately. The chosen version’s archive is downloaded once (then reused from the archive cache), but a fresh copy is extracted into its own temporary folder on every open — the vault is never reused across sessions. |