| 1 |
import { finalize } from "./helpers/deep-array"; |
| 2 |
import type { ReadonlyDeepArray } from "./helpers/deep-array"; |
| 3 |
import type { PluginObject } from "./validation/plugins"; |
| 4 |
|
| 5 |
export default class Plugin { |
| 6 |
key: string | undefined | null; |
| 7 |
manipulateOptions?: (options: unknown, parserOpts: unknown) => void; |
| 8 |
post?: PluginObject["post"]; |
| 9 |
pre?: PluginObject["pre"]; |
| 10 |
visitor: PluginObject["visitor"]; |
| 11 |
|
| 12 |
parserOverride?: Function; |
| 13 |
generatorOverride?: Function; |
| 14 |
|
| 15 |
options: {}; |
| 16 |
|
| 17 |
externalDependencies: ReadonlyDeepArray<string>; |
| 18 |
|
| 19 |
constructor( |
| 20 |
plugin: PluginObject, |
| 21 |
options: {}, |
| 22 |
key?: string, |
| 23 |
externalDependencies: ReadonlyDeepArray<string> = finalize([]), |
| 24 |
) { |
| 25 |
this.key = plugin.name || key; |
| 26 |
|
| 27 |
this.manipulateOptions = plugin.manipulateOptions; |
| 28 |
this.post = plugin.post; |
| 29 |
this.pre = plugin.pre; |
| 30 |
this.visitor = plugin.visitor || {}; |
| 31 |
this.parserOverride = plugin.parserOverride; |
| 32 |
this.generatorOverride = plugin.generatorOverride; |
| 33 |
|
| 34 |
this.options = options; |
| 35 |
this.externalDependencies = externalDependencies; |
| 36 |
} |
| 37 |
} |