2026-06-21 12:05:49 +00:00
|
|
|
import type { Effect, Scope } from "effect"
|
2026-06-22 23:06:57 +00:00
|
|
|
import type { PluginContext } from "./context.js"
|
|
|
|
|
import type { PluginOptions } from "../options.js"
|
|
|
|
|
import type { Hooks } from "./registration.js"
|
2026-06-21 12:05:49 +00:00
|
|
|
|
2026-06-22 23:06:57 +00:00
|
|
|
export interface Plugin {
|
2026-06-21 12:05:49 +00:00
|
|
|
readonly id: string
|
2026-06-22 23:06:57 +00:00
|
|
|
readonly effect: (context: PluginContext) => Effect.Effect<void, never, Scope.Scope>
|
2026-06-21 12:05:49 +00:00
|
|
|
}
|
|
|
|
|
|
2026-06-22 23:06:57 +00:00
|
|
|
export function define(plugin: Plugin) {
|
2026-06-21 12:05:49 +00:00
|
|
|
return plugin
|
|
|
|
|
}
|
2026-06-22 23:06:57 +00:00
|
|
|
|
|
|
|
|
export interface PluginRef {
|
|
|
|
|
readonly package: string
|
|
|
|
|
readonly options?: PluginOptions
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface PluginDraft {
|
|
|
|
|
list(): readonly Plugin[]
|
|
|
|
|
add(plugin: Plugin): void
|
|
|
|
|
remove(id: string): void
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type PluginHooks = Hooks<{
|
|
|
|
|
transform: PluginDraft
|
|
|
|
|
}>
|