create-plugin.ts 661 B

123456789101112131415161718
  1. import { definePluginCreator, PluginContext } from '@flowgram.ai/core';
  2. import { CreateMinimapPluginOptions } from './type';
  3. import { FlowMinimapService } from './service';
  4. import { FlowMinimapLayer } from './layer';
  5. export const createMinimapPlugin = definePluginCreator<CreateMinimapPluginOptions>({
  6. onBind: ({ bind }) => {
  7. bind(FlowMinimapService).toSelf().inSingletonScope();
  8. },
  9. onInit: (ctx: PluginContext, opts: CreateMinimapPluginOptions) => {
  10. ctx.playground.registerLayer(FlowMinimapLayer, opts);
  11. ctx.get(FlowMinimapService).init(opts);
  12. },
  13. onDispose: (ctx: PluginContext) => {
  14. ctx.get(FlowMinimapService).dispose();
  15. },
  16. });