import { EventBus } from '../core/EventBus'; export type PluginState = 'installed' | 'active' | 'inactive' | 'error'; export type PluginType = 'component' | 'system' | 'node' | 'editor-panel' | 'renderer' | 'template'; export interface PluginManifest { /** Unique plugin ID (reverse domain: com.author.plugin-name). */ id: string; name: string; version: string; description: string; author: string; license?: string; homepage?: string; repository?: string; /** Plugin types this plugin provides. */ types: PluginType[]; /** engine version compatibility (semver range). */ engineVersion: string; /** Dependencies (other plugin IDs → semver ranges). */ dependencies?: Record; /** Keywords for marketplace search. */ keywords?: string[]; /** Icon (data URL or relative path). */ icon?: string; /** Entry point filename (relative). */ main?: string; } /** The context passed to plugins on activation. */ export interface PluginContext { /** Plugin's own manifest. */ manifest: PluginManifest; /** Engine event bus for communication. */ events: EventBus; /** Register an extension point entry. */ registerExtension: (point: ExtensionPoint, entry: T) => void; /** Unregister an extension point entry. */ unregisterExtension: (point: ExtensionPoint, entry: T) => void; /** Plugin-scoped storage (persisted). */ storage: PluginStorage; /** Log a message under the plugin's namespace. */ log: (message: string) => void; /** Log a warning under the plugin's namespace. */ warn: (message: string) => void; } /** Interface a plugin must implement. */ export interface PluginDefinition { /** Plugin manifest (metadata). */ manifest: PluginManifest; /** Called when the plugin is activated. */ activate(ctx: PluginContext): void | Promise; /** Called when the plugin is deactivated. */ deactivate?(ctx: PluginContext): void | Promise; /** Called when the plugin is uninstalled (cleanup permanent data). */ uninstall?(ctx: PluginContext): void | Promise; } export type ExtensionPoint = 'component-type' | 'system-type' | 'node-type' | 'editor-panel' | 'renderer-pass' | 'asset-importer' | 'game-template' | 'menu-item'; export interface PluginStorage { get(key: string): T | undefined; set(key: string, value: T): void; remove(key: string): void; clear(): void; keys(): string[]; } /** Plugin instance (managed by PluginManager). */ export interface PluginInstance { definition: PluginDefinition; state: PluginState; activatedAt: number | null; error: string | null; extensions: Map; } export declare class PluginManager { readonly events: EventBus; private plugins; private extensions; install(definition: PluginDefinition): void; activate(id: string): Promise; deactivate(id: string): Promise; uninstall(id: string): Promise; getPlugin(id: string): PluginInstance | undefined; get allPlugins(): PluginInstance[]; get activePlugins(): PluginInstance[]; getExtensions(point: ExtensionPoint): T[]; /** Search plugins by keyword. */ search(query: string): PluginInstance[]; private createContext; /** Deactivate and remove all plugins. */ dispose(): Promise; } export interface PluginTemplate { type: PluginType; name: string; description: string; /** Template code (TypeScript source). */ code: string; } export declare const PLUGIN_TEMPLATES: PluginTemplate[]; export interface MarketplaceEntry { id: string; name: string; description: string; author: string; version: string; downloads: number; rating: number; types: PluginType[]; keywords: string[]; icon?: string; free: boolean; price?: number; updated: string; } export interface MarketplaceSearchResult { entries: MarketplaceEntry[]; total: number; page: number; pageSize: number; } /** Offline-capable marketplace API (can be backed by REST later). */ export declare class PluginMarketplace { private catalog; /** Register entries in the catalog (for offline/bundled). */ addEntries(entries: MarketplaceEntry[]): void; /** Search the marketplace. */ search(query: string, options?: { type?: PluginType; free?: boolean; page?: number; pageSize?: number; }): MarketplaceSearchResult; /** Get a single entry by ID. */ getEntry(id: string): MarketplaceEntry | undefined; /** Featured / top-rated plugins. */ getFeatured(count?: number): MarketplaceEntry[]; }