Skip to content

PluginApiDeclaration<TApi>

One API a plugin exposes: the object, the contract version it satisfies, and optionally the contract itself. This is PublishPluginApiParams without the publishing plugin, so a plugin can DECLARE what it exposes without also stating who is publishing it — which is what lets PluginBase.getPluginApis collect the declarations and do the publishing itself.

Import:

import type { PluginApiDeclaration } from 'obsidian-dev-utils/obsidian/plugin/plugin-api';

Signature:

export interface PluginApiDeclaration<TApi extends object = object>

Properties

PropertyTypeDescription
apiTApiThe API object to publish. Its methods are handed to consumers through a revocable handle, and they are always invoked with this object as their this, so an implementation using private class fields keeps working.
apiVersionstringThe CONTRACT version, in semver form — independent of the plugin's own version. Plugin 1.4.7 may perfectly well expose API 2.0.0.
contract?PluginApiContractThe contract this version of the API satisfies. Optional: when omitted, no shape check is performed on the provider's behalf and the consumer's own contract (if any) is used instead.

Links to this page: