Dependency Management
Declaring Dependencies
Section titled “Declaring Dependencies”Plugins can declare dependencies on other plugins:
class AdvancedPhysicsPlugin implements IPlugin { readonly name = 'advanced-physics'; readonly version = '2.0.0';
// Declare dependency on base physics plugin readonly dependencies = ['physics-plugin'] as const;
install(core: Core, services: ServiceContainer): void { // Can safely use services from physics-plugin const physicsService = services.resolve(PhysicsService); // ... }
uninstall(): void { // Cleanup }}Dependency Checking
Section titled “Dependency Checking”The framework automatically checks dependencies and throws an error if not satisfied:
// Error: physics-plugin not installedtry { await Core.installPlugin(new AdvancedPhysicsPlugin());} catch (error) { console.error(error); // Plugin advanced-physics has unmet dependencies: physics-plugin}
// Correct: install dependency firstawait Core.installPlugin(new PhysicsPlugin());await Core.installPlugin(new AdvancedPhysicsPlugin());Uninstall Order
Section titled “Uninstall Order”The framework checks dependencies to prevent uninstalling plugins required by others:
await Core.installPlugin(new PhysicsPlugin());await Core.installPlugin(new AdvancedPhysicsPlugin());
// Error: physics-plugin is required by advanced-physicstry { await Core.uninstallPlugin('physics-plugin');} catch (error) { console.error(error); // Cannot uninstall plugin physics-plugin: it is required by advanced-physics}
// Correct: uninstall dependent plugin firstawait Core.uninstallPlugin('advanced-physics');await Core.uninstallPlugin('physics-plugin');Dependency Graph Example
Section titled “Dependency Graph Example”physics-plugin (base) ↑advanced-physics (depends on physics-plugin) ↑game-physics (depends on advanced-physics)Install order: physics-plugin → advanced-physics → game-physics
Uninstall order: game-physics → advanced-physics → physics-plugin
Multiple Dependencies
Section titled “Multiple Dependencies”class GamePlugin implements IPlugin { readonly name = 'game'; readonly version = '1.0.0';
// Declare multiple dependencies readonly dependencies = [ 'physics-plugin', 'network-plugin', 'audio-plugin' ] as const;
install(core: Core, services: ServiceContainer): void { // All dependencies are available const physics = services.resolve(PhysicsService); const network = services.resolve(NetworkService); const audio = services.resolve(AudioService); }
uninstall(): void {}}