@storm-stack/core
Version:
A build toolkit and runtime used by Storm Software in TypeScript applications
139 lines (136 loc) • 4.74 kB
text/typescript
import { cx as Context, cO as PluginBaseOptions, cR as PluginInterface, aH as PluginConfig, cP as PluginOptions, cQ as __STORM_STACK_IS_PLUGIN__, cN as PluginPackageDependencies, aC as LogFn, a0 as EngineHooks } from '../build-B-FJ5_Zf.cjs';
import '@storm-software/config-tools/types';
import '@stryke/types/base';
import '@stryke/types/configuration';
import 'esbuild';
import 'hookable';
import 'vite';
import 'magic-string';
import '@babel/core';
import '@rspack/core';
import '@storm-software/build-tools/types';
import '@storm-software/config/types';
import '@storm-software/esbuild/types';
import '@storm-software/unbuild/types';
import 'c12';
import 'rolldown';
import 'rollup';
import 'unplugin';
import 'webpack';
import '@babel/types';
import '@storm-stack/core/deepkit/type';
import '@stryke/env/get-env-paths';
import '@stryke/types/package-json';
import 'jest-worker';
import 'jiti';
import 'memfs';
import 'unimport';
import '@stryke/capnp';
import 'semver';
import '../types/tsconfig.cjs';
import '@stryke/types/tsconfig';
import 'typescript';
import '../types/vfs.cjs';
import 'node:fs';
import 'unionfs';
/**
* The base class for all plugins
*/
declare abstract class Plugin<TContext extends Context = Context, TOptions extends PluginBaseOptions = PluginBaseOptions> implements PluginInterface<TContext, 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 property to identify the object as a Storm Stack Plugin.
*/
get [__STORM_STACK_IS_PLUGIN__](): true;
/**
* 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: PluginPackageDependencies;
/**
* 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;
/**
* 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;
/**
* 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;
/**
* 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 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<TContext, TOptions>): boolean;
/**
* Adds hooks to the engine's hook system.
*
* @param hooks - The hooks to add to the engine.
*/
addHooks(hooks: EngineHooks<TContext>): void;
/**
* Gets the resolved options for the plugin.
*
* @param context - The context to use
* @returns The resolved options for the plugin
*/
protected getOptions(context: TContext): TOptions;
}
export { Plugin };