2022-10-10 12:50:21 +00:00
|
|
|
import * as plugos from "../plugos/types.ts";
|
2023-01-20 15:08:01 +00:00
|
|
|
import { CronHookT } from "../plugos/hooks/cron.ts";
|
2022-10-10 12:50:21 +00:00
|
|
|
import { EventHookT } from "../plugos/hooks/event.ts";
|
|
|
|
import { CommandHookT } from "../web/hooks/command.ts";
|
|
|
|
import { SlashCommandHookT } from "../web/hooks/slash_command.ts";
|
2023-07-14 14:48:35 +00:00
|
|
|
import { PlugNamespaceHookT } from "./hooks/plug_namespace.ts";
|
2022-12-22 15:20:05 +00:00
|
|
|
import { CodeWidgetT } from "../web/hooks/code_widget.ts";
|
2023-08-10 16:32:41 +00:00
|
|
|
import { MQHookT } from "../plugos/hooks/mq.ts";
|
2023-08-11 18:37:13 +00:00
|
|
|
import { EndpointHookT } from "../plugos/hooks/endpoint.ts";
|
2022-10-10 12:50:21 +00:00
|
|
|
|
2023-08-20 05:24:17 +00:00
|
|
|
/** Silverbullet hooks give plugs access to silverbullet core systems.
|
|
|
|
*
|
|
|
|
* Hooks are associated with typescript functions through a manifest file.
|
|
|
|
* On various triggers (user enters a slash command, an HTTP endpoint is hit, user clicks, etc) the typescript function is called.
|
|
|
|
*
|
|
|
|
* related: plugos/type.ts#FunctionDef
|
|
|
|
*/
|
2022-10-10 12:50:21 +00:00
|
|
|
export type SilverBulletHooks =
|
|
|
|
& CommandHookT
|
|
|
|
& SlashCommandHookT
|
|
|
|
& CronHookT
|
2023-08-10 16:32:41 +00:00
|
|
|
& MQHookT
|
2022-10-10 12:50:21 +00:00
|
|
|
& EventHookT
|
2022-12-22 15:20:05 +00:00
|
|
|
& CodeWidgetT
|
2023-08-11 18:37:13 +00:00
|
|
|
& EndpointHookT
|
2023-07-14 14:48:35 +00:00
|
|
|
& PlugNamespaceHookT;
|
2022-10-10 12:50:21 +00:00
|
|
|
|
2023-08-20 05:24:17 +00:00
|
|
|
/** Syntax extension allow plugs to declaratively add new *inline* parse tree nodes to the markdown parser. */
|
2022-10-10 12:50:21 +00:00
|
|
|
export type SyntaxExtensions = {
|
2023-08-20 05:24:17 +00:00
|
|
|
/** A map of node **name** (also called "type"), to parsing and highlighting instructions. Each entry defines a new node. By convention node names (types) are UpperCamelCase (PascalCase).
|
|
|
|
*
|
|
|
|
* see: plug-api/lib/tree.ts#ParseTree
|
|
|
|
*/
|
2022-10-10 12:50:21 +00:00
|
|
|
syntax?: { [key: string]: NodeDef };
|
|
|
|
};
|
|
|
|
|
2023-08-20 05:24:17 +00:00
|
|
|
/** Parsing and highlighting instructions for SyntaxExtension */
|
2022-10-10 12:50:21 +00:00
|
|
|
export type NodeDef = {
|
2023-08-20 05:24:17 +00:00
|
|
|
/** An array of possible first characters to begin matching on.
|
|
|
|
*
|
|
|
|
* **Example**: If this node has the regex '[abc][123]', NodeDef.firstCharacters should be ["a", "b", "c"].
|
|
|
|
*/
|
2022-10-10 12:50:21 +00:00
|
|
|
firstCharacters: string[];
|
2023-08-20 05:24:17 +00:00
|
|
|
|
|
|
|
/** A regular expression that matches the *entire* syntax, including the first character. */
|
2022-10-10 12:50:21 +00:00
|
|
|
regex: string;
|
2023-08-20 05:24:17 +00:00
|
|
|
|
|
|
|
/** CSS styles to apply to the matched text.
|
|
|
|
*
|
|
|
|
* Key-value pair of CSS key to value:
|
|
|
|
*
|
|
|
|
* **Example**: `backgroundColor: "rgba(22,22,22,0.07)"`
|
|
|
|
*/
|
2022-10-10 12:50:21 +00:00
|
|
|
styles: { [key: string]: string };
|
2023-08-20 05:24:17 +00:00
|
|
|
|
|
|
|
/** CSS class name to apply to the matched text */
|
2022-10-10 12:50:21 +00:00
|
|
|
className?: string;
|
|
|
|
};
|
|
|
|
|
2023-08-20 05:24:17 +00:00
|
|
|
/** A plug manifest configures hooks, declares syntax extensions, and describes plug metadata.
|
|
|
|
*
|
|
|
|
* Typically the manifest file is in a plug's root directory, named `${plugName}.plug.yaml`.
|
|
|
|
*/
|
2022-10-10 12:50:21 +00:00
|
|
|
export type Manifest = plugos.Manifest<SilverBulletHooks> & SyntaxExtensions;
|