feat(plugin): add namespaced hook API (#33416)
This commit is contained in:
parent
dc468bdcfd
commit
909a1a6d78
150 changed files with 3276 additions and 3906 deletions
|
|
@ -1,11 +1,28 @@
|
|||
import type { Effect, Scope } from "effect"
|
||||
import type { PluginHost } from "./host.js"
|
||||
import type { PluginContext } from "./context.js"
|
||||
import type { PluginOptions } from "../options.js"
|
||||
import type { Hooks } from "./registration.js"
|
||||
|
||||
export interface Plugin<R = never> {
|
||||
export interface Plugin {
|
||||
readonly id: string
|
||||
readonly effect: (host: PluginHost) => Effect.Effect<void, never, R | Scope.Scope>
|
||||
readonly effect: (context: PluginContext) => Effect.Effect<void, never, Scope.Scope>
|
||||
}
|
||||
|
||||
export function define<R>(plugin: Plugin<R>) {
|
||||
export function define(plugin: Plugin) {
|
||||
return plugin
|
||||
}
|
||||
|
||||
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
|
||||
}>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue