1
0
silverbullet/plugos/types.ts

36 lines
902 B
TypeScript
Raw Normal View History

import { System } from "./system.ts";
2022-10-12 09:47:13 +00:00
import { AssetJson } from "./asset_bundle/bundle.ts";
export interface Manifest<HookT> {
2022-04-26 17:04:36 +00:00
name: string;
2022-03-25 11:03:06 +00:00
requiredPermissions?: string[];
2022-10-13 13:16:18 +00:00
// URLs to plugs whose dependencies are presumed to already be loaded (main use case: global.plug.json)
imports?: string[];
2022-10-12 09:47:13 +00:00
assets?: string[] | AssetJson;
2022-05-13 12:36:26 +00:00
dependencies?: {
[key: string]: string;
};
functions: {
2022-03-27 09:26:13 +00:00
[key: string]: FunctionDef<HookT>;
};
}
2022-03-27 09:26:13 +00:00
export type FunctionDef<HookT> = {
// Read the function from this path and inline it
// Format: filename:functionName
path?: string;
// Reuse an
// Format: plugName.functionName
redirect?: string;
code?: string;
2022-03-23 14:41:12 +00:00
env?: RuntimeEnvironment;
2022-03-27 09:26:13 +00:00
} & HookT;
2022-03-23 14:41:12 +00:00
export type RuntimeEnvironment = "client" | "server";
export interface Hook<HookT> {
2022-03-23 14:41:12 +00:00
validateManifest(manifest: Manifest<HookT>): string[];
2022-03-21 14:21:34 +00:00
2022-03-23 14:41:12 +00:00
apply(system: System<HookT>): void;
}