feat: Implement Plugin Marketplace Manager and Client
- Added PluginMarketplaceManager to coordinate marketplace reads and manage installed plugins. - Introduced PluginMarketplaceClient for fetching marketplace metadata. - Implemented storage management for installed plugins using MemoryStorage. - Added methods for installing, uninstalling, and enabling/disabling plugins. - Created type definitions for PluginMarketplaceManager options and installed plugin records. - Added support for fetching full marketplace catalog and individual plugin metadata. - Included error handling for fetch operations and validation of plugin data. - Updated index.browser.ts to export new modules and types.
This commit is contained in:
88
dist/PluginMarketplaceManager.d.ts
vendored
Normal file
88
dist/PluginMarketplaceManager.d.ts
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
import { type IPluginStorage } from './interfaces.js';
|
||||
import type { PluginRegistry } from './PluginRegistry.js';
|
||||
import type { InstalledPlugin, PluginMetadata } from './types.js';
|
||||
import { PluginMarketplaceClient } from './PluginMarketplaceClient.js';
|
||||
/**
|
||||
* Host-visible installed-plugin metadata.
|
||||
*
|
||||
* Hosts may only know filesystem facts such as `id`, `name`, or `installedDate`.
|
||||
* Stored marketplace metadata fills remaining fields.
|
||||
*/
|
||||
export type PluginMarketplaceInstalledRecord = Partial<InstalledPlugin> & Pick<InstalledPlugin, 'id'>;
|
||||
/**
|
||||
* Host callbacks used by {@link PluginMarketplaceManager}.
|
||||
*/
|
||||
export interface PluginMarketplaceHostAdapter {
|
||||
/**
|
||||
* Returns host-known installed plugins.
|
||||
*/
|
||||
listInstalledPlugins?(): Promise<PluginMarketplaceInstalledRecord[]>;
|
||||
/**
|
||||
* Performs host-specific install side effects.
|
||||
*/
|
||||
installPlugin?(plugin: PluginMetadata): Promise<void>;
|
||||
/**
|
||||
* Performs host-specific uninstall side effects.
|
||||
*/
|
||||
uninstallPlugin?(pluginId: string): Promise<void>;
|
||||
}
|
||||
/**
|
||||
* Construction options for {@link PluginMarketplaceManager}.
|
||||
*/
|
||||
export interface PluginMarketplaceManagerOptions {
|
||||
/** Shared marketplace client used to query remote metadata. */
|
||||
client: PluginMarketplaceClient;
|
||||
/** Optional persistent storage for installed-plugin state. */
|
||||
storage?: IPluginStorage;
|
||||
/** Optional host adapter for install and discovery side effects. */
|
||||
host?: PluginMarketplaceHostAdapter;
|
||||
/** Optional registry used when disabling or uninstalling loaded plugins. */
|
||||
registry?: PluginRegistry;
|
||||
/** Optional override for installed-plugin storage key. */
|
||||
installedPluginsStorageKey?: string;
|
||||
}
|
||||
/**
|
||||
* Coordinates marketplace reads with host-specific install and enable state.
|
||||
*/
|
||||
export declare class PluginMarketplaceManager {
|
||||
private readonly client;
|
||||
private readonly storage;
|
||||
private readonly host?;
|
||||
private readonly registry?;
|
||||
private readonly installedPluginsStorageKey;
|
||||
constructor(options: PluginMarketplaceManagerOptions);
|
||||
/**
|
||||
* Fetches full marketplace catalog.
|
||||
*/
|
||||
fetchMarketplacePlugins(): Promise<PluginMetadata[]>;
|
||||
/**
|
||||
* Lists installed plugins merged with persisted enabled state.
|
||||
*/
|
||||
listInstalledPlugins(): Promise<InstalledPlugin[]>;
|
||||
/**
|
||||
* Lists installed plugins currently enabled.
|
||||
*/
|
||||
listEnabledPlugins(): Promise<InstalledPlugin[]>;
|
||||
/**
|
||||
* Returns whether plugin is recorded as installed.
|
||||
*/
|
||||
isPluginInstalled(pluginId: string): Promise<boolean>;
|
||||
/**
|
||||
* Installs marketplace plugin via host adapter and persists state.
|
||||
*/
|
||||
installPlugin(plugin: PluginMetadata): Promise<InstalledPlugin>;
|
||||
/**
|
||||
* Removes plugin from host and clears persisted install state.
|
||||
*/
|
||||
uninstallPlugin(pluginId: string): Promise<void>;
|
||||
/**
|
||||
* Enables or disables installed plugin.
|
||||
*
|
||||
* Disabling triggers `registry.unregisterPlugin` when registry exists.
|
||||
* Enabling only updates persisted state; host controls actual load timing.
|
||||
*/
|
||||
setPluginEnabled(pluginId: string, enabled: boolean): Promise<InstalledPlugin | null>;
|
||||
private readStoredInstalledPlugins;
|
||||
private writeStoredInstalledPlugins;
|
||||
}
|
||||
//# sourceMappingURL=PluginMarketplaceManager.d.ts.map
|
||||
Reference in New Issue
Block a user