create-plugin.ts 746 B

123456789101112131415161718192021222324
  1. import {
  2. definePluginCreator,
  3. type PluginBindConfig,
  4. type PluginContext,
  5. } from '@flowgram.ai/core';
  6. import { NodePanelPluginOptions } from './type';
  7. import { WorkflowNodePanelService } from './service';
  8. import { WorkflowNodePanelLayer } from './layer';
  9. export const createFreeNodePanelPlugin = definePluginCreator({
  10. onBind({ bind }: PluginBindConfig) {
  11. bind(WorkflowNodePanelService).toSelf().inSingletonScope();
  12. },
  13. onInit: (ctx: PluginContext, opts: NodePanelPluginOptions) => {
  14. ctx.playground.registerLayer(WorkflowNodePanelLayer, {
  15. renderer: opts.renderer,
  16. });
  17. },
  18. onDispose: (ctx: PluginContext) => {
  19. const nodePanelService = ctx.get(WorkflowNodePanelService);
  20. nodePanelService.dispose();
  21. },
  22. });