import { Fragment, h, VNode } from "preact"; import * as hooks from "preact/hooks"; import * as triliumHooks from "../widgets/react/hooks"; import RightPanelWidget from "../widgets/sidebar/RightPanelWidget"; export interface WidgetDefinition { parent: "right-pane", render: () => VNode, position?: number, } export interface WidgetDefinitionWithType extends WidgetDefinition { type: "preact-widget" } export interface LauncherWidgetDefinitionWithType { type: "preact-launcher-widget" render: () => VNode } export const preactAPI = Object.freeze({ // Core h, Fragment, /** * Method that must be run for widget scripts that run on Preact, using JSX. The method just returns the same definition, reserved for future typechecking and perhaps validation purposes. * * @param definition the widget definition. */ defineWidget(definition: WidgetDefinition) { return { type: "preact-widget", ...definition }; }, defineLauncherWidget(definition: Omit) { return { type: "preact-launcher-widget", ...definition }; }, RightPanelWidget, ...hooks, ...triliumHooks });