/** * @file * * Builds a complete {@link PopulateFilesParams} map for a plugin's in-repo `demo-vault/`, ready to seed into * the temp vault before Obsidian opens it. Composes {@link readDemoVaultTree} (the note tree) with the two * pieces it deliberately omits: selected `.obsidian/*` config files, and the built binaries (+ `data.json`) * of any extra community plugins the demo vault depends on (e.g. CodeScript Toolkit, `demo-vault-helper`). * * Pairs with the `enableCommunityPlugins` option of the global-setup `createSetup`: this seeds the binaries, * that turns them on. It intentionally does NOT write `community-plugins.json` — the harness owns that file * (it lists the plugin-under-test), and enabling the extras persists them. * * Stays **synchronous**, so an injected plugin whose binaries are absent is a throw rather than a download. * `demo-vault-bootstrap.ts` owns the headless install the throw's message points at — including * `buildDemoVaultPopulateAsync`, the self-healing sibling of {@link buildDemoVaultPopulate}. The * missing-plugin detection ({@link resolveMissingInjectedPlugins}) lives here and is shared with it, so the * two paths cannot disagree about what "not installed" means. */ import type { PopulateFilesParams } from './temporary-vault.mjs'; /** * Parameters for {@link buildDemoVaultPopulate}. */ export interface BuildDemoVaultPopulateParams { /** * Absolute path to the plugin repo's `demo-vault/` directory. */ readonly demoVaultPath: string; /** * Names (of files or directories, matched at any depth) to skip while reading the note tree — forwarded to * {@link readDemoVaultTree}. * * @default `['.git', '.obsidian']` */ readonly excludedNames?: Iterable; /** * Community plugins to seed into `.obsidian/plugins//` (binaries + optional `data.json`). Turn * them on with the global-setup `createSetup({ enableCommunityPlugins })` option. */ readonly injectPlugins?: readonly InjectPluginParams[]; /** * `.obsidian/*` config files to carry over from the demo vault. {@link readDemoVaultTree} excludes the whole * `.obsidian` directory, so config the vault relies on (preview-mode default, core plugins, appearance) must * be re-added explicitly. Files that do not exist are skipped. * * @default `['app.json', 'appearance.json', 'core-plugins.json']` */ readonly obsidianConfigFiles?: readonly string[]; } /** * A community plugin to seed into the demo vault alongside the note tree. */ export interface InjectPluginParams { /** * Overlay written as `.obsidian/plugins//data.json` (JSON, 2-space indent). Omit to keep whatever * `data.json` (if any) already lives in {@link InjectPluginParams.sourceDirectory}. */ readonly data?: unknown; /** * The community plugin's id (its `.obsidian/plugins/` folder name). */ readonly pluginId: string; /** * The GitHub repository (`owner/name`) publishing this plugin, consulted **only** by the headless * bootstrap (`bootstrapDemoVaultPlugins` / `buildDemoVaultPopulateAsync` / the * `bootstrap-demo-vault` CLI) when the binaries are missing from the demo vault. Supplying it skips * the lookup in Obsidian's community plugin registry, which is also the way to bootstrap a plugin * that is not listed there at all. Never used when the files are already on disk. */ readonly repo?: string | undefined; /** * Directory to read the plugin's built files from. Every file directly inside it is copied into * `.obsidian/plugins//`; `main.js` and `manifest.json` are required. * * Setting this also opts the plugin **out** of the headless bootstrap: an explicit source directory * names a local build output, not somewhere to download a published release into. * * @default `/.obsidian/plugins/` */ readonly sourceDirectory?: string; /** * The release tag the headless bootstrap downloads from, pinning the installed version. Omit for the * repository's latest release — what the in-app community browser installs. Like * {@link InjectPluginParams.repo}, consulted only while bootstrapping missing binaries. */ readonly version?: string | undefined; } /** * Parameters for {@link resolveInjectedPluginSourceDirectory}. */ export interface ResolveInjectedPluginSourceDirectoryParams { /** Absolute path to the plugin repo's `demo-vault/` directory. */ readonly demoVaultPath: string; /** The injected plugin whose source directory to resolve. */ readonly plugin: InjectPluginParams; } /** * Parameters for {@link resolveMissingInjectedPlugins}. */ export interface ResolveMissingInjectedPluginsParams { /** Absolute path to the plugin repo's `demo-vault/` directory. */ readonly demoVaultPath: string; /** The injected plugins to check. */ readonly injectPlugins: readonly InjectPluginParams[]; } /** * Builds the full populate map for a plugin's `demo-vault/`: the note tree, the selected `.obsidian/*` config * files, and every injected plugin's binaries (+ optional `data.json`). * * @param params - The {@link BuildDemoVaultPopulateParams}. * @returns The populate map, ready to hand to a global setup's `populate` or {@link TemporaryVault.populate}. */ export declare function buildDemoVaultPopulate(params: BuildDemoVaultPopulateParams): PopulateFilesParams; /** * Resolves the directory an injected plugin's built files are read from. * * @param params - The {@link ResolveInjectedPluginSourceDirectoryParams}. * @returns The explicit {@link InjectPluginParams.sourceDirectory} when set, otherwise the plugin's folder * inside the demo vault. */ export declare function resolveInjectedPluginSourceDirectory(params: ResolveInjectedPluginSourceDirectoryParams): string; /** * Selects the injected plugins whose binaries are missing from the demo vault and can therefore be * installed headlessly — the exact set {@link buildDemoVaultPopulate} would otherwise throw on. * * Plugins carrying an explicit {@link InjectPluginParams.sourceDirectory} are excluded: that names a local * build output, not somewhere to download a published release into. * * Shared with the bootstrap so "missing" has one definition rather than two that can drift apart. * * @param params - The {@link ResolveMissingInjectedPluginsParams}. * @returns The plugins to bootstrap, in the order given. */ export declare function resolveMissingInjectedPlugins(params: ResolveMissingInjectedPluginsParams): InjectPluginParams[];