@storm-stack/core
Version:
A build toolkit and runtime used by Storm Software in TypeScript applications
126 lines (123 loc) • 4.29 kB
text/typescript
import { PluginBaseOptions, Context, PluginInterface, PluginConfig, PluginOptions, LogFn, EngineHooks } from '../types/index.cjs';
import '@babel/core';
import '@babel/types';
import '@storm-stack/types/shared/error';
import '@stryke/types/base';
import 'magic-string';
import '@storm-software/config-tools/types';
import '@stryke/types/configuration';
import 'hookable';
import '@storm-software/build-tools/types';
import '@storm-software/config/types';
import '@storm-software/esbuild/types';
import '@storm-software/unbuild/types';
import 'c12';
import 'esbuild';
import 'unbuild';
import '@deepkit/type';
import '../reflection-DTM1oT21.cjs';
import '@stryke/capnp';
import '@storm-stack/types/shared/log';
import '@stryke/env/get-env-paths';
import '@stryke/types/package-json';
import 'jest-worker';
import 'jiti';
import 'memfs';
import 'unimport';
import '../types/tsconfig.cjs';
import '@stryke/types/tsconfig';
import 'typescript';
import '../types/vfs.cjs';
import 'memfs/lib/volume';
import 'node:fs';
import 'unionfs';
/**
* The base class for all plugins
*/
declare abstract class Plugin<TOptions extends PluginBaseOptions = PluginBaseOptions, TContext extends Context = Context> implements PluginInterface<TOptions> {
#private;
/**
* A list of plugin modules required as dependencies by the current Plugin.
*
* @remarks
* These plugins will be called prior to the current Plugin.
*/
dependencies: Array<string | PluginConfig>;
/**
* The configuration options for the plugin
*
* @remarks
* This is used to store the configuration options for the plugin, which can be accessed by the plugin's methods.
*/
options: PluginOptions<TOptions>;
/**
* A list of dependencies that are required for the plugin to work. These dependencies will be installed when Storm Stack CLI is run.
*/
protected packageDeps: Record<string, "dependency" | "devDependency">;
/**
* A property to override the plugin's {@link name} field.
*
* @remarks
* This is useful for plugins that need to have a different name than the default one derived from the class name.
*/
protected get overrideName(): string | undefined;
/**
* The name of the plugin
*
* @remarks
* This is used to identify the plugin's name used in {@link Context.options}, logs, and other output.
*/
get name(): string;
/**
* The primary keys for the plugin's options.
*
* @remarks
* This is used to identify when a two instances of the plugin are the same and can be de-duplicated.
*/
get primaryKeys(): any[];
/**
* Returns true if the plugin is a singleton. Singleton plugins can only be instantiated once (so whenever other plugins specify them as dependencies, they will be de-duplicated).
*
* @remarks
* A plugin is considered a singleton if it has zero primary key option fields defined.
*/
get isSingleton(): boolean;
/**
* A list of primary keys for the plugin's options.
*
* @remarks
* This is used to identify when a two instances of the plugin are the same and can be de-duplicated.
*/
protected get primaryKeyFields(): string[];
/**
* The identifier for the plugin used in the {@link isSame} method
*
* @remarks
* Child plugins can override this to provide a more or less specific identifier. This is used to identify the plugin's options in {@link Context.options}.
*/
get identifier(): string;
/**
* The logger function to use
*/
protected get log(): LogFn;
/**
* The constructor for the plugin
*
* @param options - The configuration options for the plugin
*/
constructor(options: PluginOptions<TOptions>);
/**
* Checks if the current plugin is the same as another plugin based on primary key fields.
*
* @param plugin - The plugin to compare with.
* @returns `true` if the plugins are the same, `false` otherwise.
*/
isSame(plugin: PluginInterface): boolean;
/**
* Adds hooks to the engine's hook system.
*
* @param hooks - The hooks to add to the engine.
*/
addHooks(hooks: EngineHooks<TContext>): void;
}
export { Plugin };