/** * @file * * Mock of Obsidian's `BasesView`, the base class plugins extend to render a Base. */ import type { BasesPropertyId as BasesPropertyIdOriginal, BasesView as BasesViewOriginal, TFile as TFileOriginal } from 'obsidian'; import type { QueryController } from './QueryController.mjs'; import { App } from './App.mjs'; import { BasesQueryResult } from './BasesQueryResult.mjs'; import { BasesViewConfig } from './BasesViewConfig.mjs'; import { Component } from './Component.mjs'; /** * Mock of Obsidian's abstract `BasesView`, which plugins extend to render a Base. * * A new view gets a freshly configured mock app, an empty unnamed {@link BasesViewConfig} and an empty * {@link BasesQueryResult}; the controller is not used. */ export declare abstract class BasesView extends Component { /** * All properties available in the dataset. Empty in the mock until a test assigns it. */ allProperties: BasesPropertyIdOriginal[]; /** * The app the view belongs to; a new configured mock app per view. */ app: App; /** * The configuration of this view, as set from the Bases toolbar and view options. */ config: BasesViewConfig; /** * The most recent query result. Obsidian replaces it whenever the vault or the Base changes, so views should not * keep a reference to it. */ data: BasesQueryResult; /** * The type id of this view, supplied by the subclass. */ abstract type: string; /** * Creates the view with a new mock app, an empty config and an empty query result. * * @param controller - The query controller driving the view; only forwarded to the construction hook. */ constructor(controller: QueryController); /** * Mock-only: views a value typed as Obsidian's `BasesView` as this mock. Numbered because `Component` already * declares `fromOriginalType__` with an incompatible signature. * * @param value - The value typed as the original `BasesView`. * @returns The same object, typed as the mock. */ static fromOriginalType2__(value: BasesViewOriginal): BasesView; /** * Mock-only: views this mock as Obsidian's `BasesView` type. Numbered because `Component` already declares * `asOriginalType__`. * * @returns The same object, typed as the original `BasesView`. */ asOriginalType2__(): BasesViewOriginal; /** * Mock-only construction hook, called at the end of the constructor; a no-op meant for * `vi.spyOn(BasesView.prototype, 'constructor2__')`. * * @param _controller - The query controller the view was created with. */ constructor2__(_controller: QueryController): void; /** * Shows the new-note menu for a file created from this view, optionally adjusting its frontmatter. A no-op in the * mock: no menu is shown and no file is created. * * @param _baseFileName - The file name to suggest for the new note. * @param _frontmatterProcessor - A function that modifies the new note's frontmatter, given that frontmatter and the * new note. */ createFileForView(_baseFileName?: string, _frontmatterProcessor?: (frontmatter: unknown, file: TFileOriginal) => void): Promise; /** * Called when the query has new data; the view should re-render from {@link BasesView.data}. The mock never * calls it on its own. */ abstract onDataUpdated(): void; }