2022-10-10 12:50:21 +00:00
|
|
|
import { System } from "./system.ts";
|
2022-10-12 09:47:13 +00:00
|
|
|
import { AssetJson } from "./asset_bundle/bundle.ts";
|
2022-03-20 08:56:28 +00:00
|
|
|
|
|
|
|
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-12 09:47:13 +00:00
|
|
|
assets?: string[] | AssetJson;
|
2022-03-20 08:56:28 +00:00
|
|
|
functions: {
|
2022-03-27 09:26:13 +00:00
|
|
|
[key: string]: FunctionDef<HookT>;
|
2022-03-20 08:56:28 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-03-27 09:26:13 +00:00
|
|
|
export type FunctionDef<HookT> = {
|
2022-10-28 14:17:40 +00:00
|
|
|
// Read the function from this path and inline it
|
|
|
|
// Format: filename:functionName
|
2022-03-20 08:56:28 +00:00
|
|
|
path?: string;
|
2022-10-28 14:17:40 +00:00
|
|
|
// Reuse an
|
|
|
|
// Format: plugName.functionName
|
|
|
|
redirect?: string;
|
2022-03-23 14:41:12 +00:00
|
|
|
env?: RuntimeEnvironment;
|
2022-03-27 09:26:13 +00:00
|
|
|
} & HookT;
|
2022-03-20 08:56:28 +00:00
|
|
|
|
2022-03-23 14:41:12 +00:00
|
|
|
export type RuntimeEnvironment = "client" | "server";
|
|
|
|
|
2022-03-29 09:21:32 +00:00
|
|
|
export interface Hook<HookT> {
|
2022-03-23 14:41:12 +00:00
|
|
|
validateManifest(manifest: Manifest<HookT>): string[];
|
|
|
|
apply(system: System<HookT>): void;
|
2022-03-20 08:56:28 +00:00
|
|
|
}
|