Skip to content

evaluateBaseHeadless

Unofficial

Evaluate a base in headless mode — with no leaf or open view — and return its entries.

It renders the base off-screen via getBasesControllerFromRender, waits for the initial vault scan to settle, then reads the controller’s results. Everything is torn down before returning.

Import:

import { evaluateBaseHeadless } from '@obsidian-typings/obsidian-catalyst-latest/implementations';

Evaluate a .base file in headless mode — with no leaf or open view — and return its entries.

The file is read with obsidian#Vault.cachedRead, and its own path supplies the query’s file context.

Signature:

function evaluateBaseHeadless(app: App, base: string | TFile): Promise<BasesEntry[]>

Parameters:

Parameter Type Description
app App The app instance.
base string | TFile The .base file, or its vault path.

Returns: Promise<BasesEntry[]> — The evaluated base entries.

Example:

const entries = await evaluateBaseHeadless(app, 'Projects/Tasks.base');

Evaluate .base content in headless mode — with no leaf or open view — and return its entries.

Use this form for content that is not a .base file of its own, such as the body of a base code block in a note.

Signature:

function evaluateBaseHeadless(app: App, content: string, sourcePath: string): Promise<BasesEntry[]>

Parameters:

Parameter Type Description
app App The app instance.
content string The .base file content (the body of a base code block).
sourcePath string The path supplying the query’s file context.

Returns: Promise<BasesEntry[]> — The evaluated base entries.

Example:

const entries = await evaluateBaseHeadless(app, 'filters:\n and:\n - file.hasTag("task")\n', 'Notes/Today.md');