create-plugin.ts 839 B

12345678910111213141516171819202122232425
  1. /**
  2. * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
  3. * SPDX-License-Identifier: MIT
  4. */
  5. import { definePluginCreator, type PluginBindConfig, type PluginContext } 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. });