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