UNPKG

@farmfe/runtime

Version:
25 lines (24 loc) 1.12 kB
import { Module } from './module.js'; import type { ModuleSystem } from './module-system.js'; import type { Resource } from './resource-loader.js'; export interface ResourceLoadResult { success: boolean; retryWithDefaultResourceLoader?: boolean; err?: Error; } export interface FarmRuntimePlugin { name: string; bootstrap?: (moduleSystem: ModuleSystem) => void | Promise<void>; moduleCreated?: (module: Module) => void | Promise<void>; moduleInitialized?: (module: Module) => void | Promise<void>; readModuleCache?: (module: Module) => boolean | Promise<boolean>; moduleNotFound?: (moduleId: string) => void | Promise<void>; loadResource?: (resource: Resource, targetEnv: 'browser' | 'node') => Promise<ResourceLoadResult>; } export declare class FarmRuntimePluginContainer { plugins: FarmRuntimePlugin[]; constructor(plugins: FarmRuntimePlugin[]); hookSerial(hookName: Exclude<keyof FarmRuntimePlugin, 'name'>, ...args: any[]): void; hookBail<T = any>(hookName: Exclude<keyof FarmRuntimePlugin, 'name'>, ...args: any[]): // ): Promise<T> { T | undefined; }