plugin.d.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import type { App } from './api/index.js';
  2. export interface PluginDescriptor {
  3. id: string;
  4. label: string;
  5. app: App;
  6. packageName?: string;
  7. homepage?: string;
  8. componentStateTypes?: string[];
  9. logo?: string;
  10. disableAppScope?: boolean;
  11. disablePluginScope?: boolean;
  12. /**
  13. * Run the plugin setup and expose the api even if the devtools is not opened yet.
  14. * Useful to record timeline events early.
  15. */
  16. enableEarlyProxy?: boolean;
  17. settings?: Record<string, PluginSettingsItem>;
  18. }
  19. export declare type PluginSettingsItem = {
  20. label: string;
  21. description?: string;
  22. } & ({
  23. type: 'boolean';
  24. defaultValue: boolean;
  25. } | {
  26. type: 'choice';
  27. defaultValue: string | number;
  28. options: {
  29. value: string | number;
  30. label: string;
  31. }[];
  32. component?: 'select' | 'button-group';
  33. } | {
  34. type: 'text';
  35. defaultValue: string;
  36. });
  37. declare type InferSettingsType<T extends PluginSettingsItem> = [T] extends [{
  38. type: 'boolean';
  39. }] ? boolean : [T] extends [{
  40. type: 'choice';
  41. }] ? T['options'][number]['value'] : [T] extends [{
  42. type: 'text';
  43. }] ? string : unknown;
  44. export declare type ExtractSettingsTypes<O extends Record<string, PluginSettingsItem>> = {
  45. [K in keyof O]: InferSettingsType<O[K]>;
  46. };
  47. export {};