@flowgram.ai/minimap-plugin 0.1.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/component.tsx","../../src/constant.ts","../../src/create-plugin.ts","../../src/service.ts","../../src/draw.ts","../../src/layer.tsx"],"sourcesContent":["/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport React, { CSSProperties, useEffect, useRef, useState } from 'react';\n\nimport { MinimapInactiveStyle } from './type';\nimport { FlowMinimapService } from './service';\nimport { MinimapDefaultInactiveStyle } from './constant';\n\ninterface MinimapProps {\n service: FlowMinimapService;\n panelStyles?: CSSProperties;\n containerStyles?: CSSProperties;\n inactiveStyle?: Partial<MinimapInactiveStyle>;\n}\n\nexport const MinimapRender: React.FC<MinimapProps> = (props) => {\n const {\n service,\n panelStyles = {},\n containerStyles = {},\n inactiveStyle: customInactiveStyle = {},\n } = props;\n const inactiveStyle = {\n ...MinimapDefaultInactiveStyle,\n ...customInactiveStyle,\n };\n const panelRef = useRef<HTMLDivElement>(null);\n const [activated, setActivated] = useState<boolean>(false);\n\n useEffect(() => {\n const canvasContainer: HTMLDivElement | null = panelRef.current;\n if (canvasContainer && service.canvas) {\n canvasContainer.appendChild(service.canvas);\n }\n const disposer = service.onActive((activate: boolean) => {\n setActivated(activate);\n });\n return () => {\n disposer.dispose();\n };\n }, []);\n\n // 计算缩放比例和透明度\n const scale: number = activated ? 1 : inactiveStyle.scale;\n const opacity: number = activated ? 1 : inactiveStyle.opacity;\n\n // 计算偏移量\n const translateX: number = activated ? 0 : inactiveStyle.translateX; // 向右偏移的像素\n const translateY: number = activated ? 0 : inactiveStyle.translateY; // 向下偏移的像素\n\n return (\n <div\n className=\"minimap-container\"\n style={{\n position: 'fixed',\n right: 30,\n bottom: 70,\n transition: 'all 0.3s ease', // 添加过渡效果\n transform: `scale(${scale}) translate(${translateX}px, ${translateY}px)`,\n opacity: opacity,\n transformOrigin: 'bottom right', // 设置变换的原点\n ...containerStyles,\n }}\n >\n <div\n className=\"minimap-panel\"\n style={{\n display: 'flex',\n width: '100%',\n height: '100%',\n borderRadius: '10px',\n backgroundColor: 'rgba(255, 255, 255, 1)',\n border: '0.572px solid rgba(6, 7, 9, 0.10)',\n overflow: 'hidden',\n boxShadow:\n '0px 2.289px 6.867px 0px rgba(0, 0, 0, 0.08), 0px 4.578px 13.733px 0px rgba(0, 0, 0, 0.04)',\n boxSizing: 'border-box',\n padding: 8,\n ...panelStyles,\n }}\n data-flow-editor-selectable=\"false\"\n ref={panelRef}\n onMouseEnter={() => {\n service.setActivate(true);\n }}\n onMouseLeave={() => {\n service.setActivate(false);\n }}\n onTouchStartCapture={() => {\n service.setActivate(true);\n }}\n onTouchEndCapture={() => {\n service.setActivate(false);\n }}\n ></div>\n </div>\n );\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport type { MinimapCanvasStyle, MinimapInactiveStyle, MinimapServiceOptions } from './type';\n\nexport const MinimapDefaultCanvasStyle: MinimapCanvasStyle = {\n canvasWidth: 250,\n canvasHeight: 250,\n canvasPadding: 50,\n canvasBackground: 'rgba(242, 243, 245, 1)',\n canvasBorderRadius: 10,\n viewportBackground: 'rgba(255, 255, 255, 1)',\n viewportBorderRadius: 4,\n viewportBorderColor: 'rgba(6, 7, 9, 0.10)',\n viewportBorderWidth: 1,\n viewportBorderDashLength: undefined,\n nodeColor: 'rgba(0, 0, 0, 0.10)',\n nodeBorderRadius: 2,\n nodeBorderWidth: 0.145,\n nodeBorderColor: 'rgba(6, 7, 9, 0.10)',\n overlayColor: 'rgba(255, 255, 255, 0.55)',\n};\n\nexport const MinimapDefaultInactiveStyle: MinimapInactiveStyle = {\n scale: 0.7,\n opacity: 1,\n translateX: 15,\n translateY: 15,\n};\n\nexport const MinimapDefaultOptions: MinimapServiceOptions = {\n canvasStyle: MinimapDefaultCanvasStyle,\n canvasClassName: 'gedit-minimap-canvas',\n enableActiveDebounce: false,\n enableInactiveDebounce: true,\n enableDisplayAllNodes: false,\n activeDebounceTime: 0,\n inactiveDebounceTime: 5,\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { definePluginCreator, PluginContext } from '@flowgram.ai/core';\n\nimport { CreateMinimapPluginOptions } from './type';\nimport { FlowMinimapService } from './service';\nimport { FlowMinimapLayer } from './layer';\n\nexport const createMinimapPlugin = definePluginCreator<CreateMinimapPluginOptions>({\n onBind: ({ bind }) => {\n bind(FlowMinimapService).toSelf().inSingletonScope();\n },\n onInit: (ctx: PluginContext, opts: CreateMinimapPluginOptions) => {\n ctx.playground.registerLayer(FlowMinimapLayer, opts);\n ctx.get(FlowMinimapService).init(opts);\n },\n onDispose: (ctx: PluginContext) => {\n ctx.get(FlowMinimapService).dispose();\n },\n});\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { debounce } from 'lodash';\nimport { inject, injectable } from 'inversify';\nimport { Disposable, DisposableCollection, IPoint, Rectangle } from '@flowgram.ai/utils';\nimport { FlowNodeEntity, FlowNodeTransformData } from '@flowgram.ai/document';\nimport { FlowNodeBaseType } from '@flowgram.ai/document';\nimport { FlowDocument } from '@flowgram.ai/document';\nimport { EntityManager, MouseTouchEvent, PlaygroundConfigEntity } from '@flowgram.ai/core';\n\nimport type { MinimapRenderContext, MinimapServiceOptions, MinimapCanvasStyle } from './type';\nimport { MinimapDraw } from './draw';\nimport { MinimapDefaultCanvasStyle, MinimapDefaultOptions } from './constant';\n\n@injectable()\nexport class FlowMinimapService {\n @inject(FlowDocument) private readonly document: FlowDocument;\n\n @inject(EntityManager) private readonly entityManager: EntityManager;\n\n @inject(PlaygroundConfigEntity)\n private readonly playgroundConfig: PlaygroundConfigEntity;\n\n public readonly canvas: HTMLCanvasElement;\n\n public readonly context2D: CanvasRenderingContext2D;\n\n public activated;\n\n private onActiveCallbacks: Set<(activated: boolean) => void>;\n\n private options: MinimapServiceOptions;\n\n private toDispose: DisposableCollection;\n\n private initialized;\n\n private isDragging;\n\n private style: MinimapCanvasStyle;\n\n private dragStart?: IPoint;\n\n constructor() {\n this.canvas = document.createElement('canvas');\n this.context2D = this.canvas.getContext('2d')!;\n this.initialized = !!this.context2D;\n this.onActiveCallbacks = new Set();\n this.toDispose = new DisposableCollection();\n this.render = this._render;\n this.activated = false;\n this.isDragging = false;\n }\n\n public init(options?: Partial<MinimapServiceOptions>) {\n this.options = MinimapDefaultOptions;\n Object.assign(this.options, options);\n this.setDebounce({\n enableDebounce: this.options.enableInactiveDebounce,\n debounceTime: this.options.inactiveDebounceTime,\n });\n this.initStyle();\n this.mountListener();\n }\n\n public dispose(): void {\n this.toDispose.dispose();\n this.initialized = false;\n this.activated = false;\n this.removeEventListeners();\n }\n\n public setActivate(activate: boolean): void {\n if (activate === this.activated) {\n return;\n }\n if (!activate && this.isDragging) {\n // 拖拽时持续激活\n return;\n }\n this.activated = activate;\n if (activate) {\n this.setDebounce({\n enableDebounce: this.options.enableActiveDebounce,\n debounceTime: this.options.activeDebounceTime,\n });\n this.addEventListeners();\n } else {\n this.setDebounce({\n enableDebounce: this.options.enableInactiveDebounce,\n debounceTime: this.options.inactiveDebounceTime,\n });\n this.removeEventListeners();\n }\n this.render();\n this.onActiveCallbacks.forEach((callback) => callback(activate));\n }\n\n public onActive = (callback: (activated: boolean) => void): Disposable => {\n this.onActiveCallbacks.add(callback);\n return {\n dispose: () => {\n this.onActiveCallbacks.delete(callback);\n },\n };\n };\n\n private initStyle() {\n if (!this.initialized) {\n return;\n }\n const { canvasClassName, canvasStyle } = this.options;\n this.canvas.className = canvasClassName;\n this.style = {\n ...MinimapDefaultCanvasStyle,\n ...canvasStyle,\n };\n this.canvas.width = this.style.canvasWidth;\n this.canvas.height = this.style.canvasHeight;\n this.canvas.style.borderRadius = this.style.canvasBorderRadius\n ? `${this.style.canvasBorderRadius}px`\n : 'unset';\n }\n\n private setDebounce(params: { enableDebounce: boolean; debounceTime: number }) {\n const { enableDebounce, debounceTime } = params;\n if (enableDebounce) {\n this.render = debounce(this._render, debounceTime);\n } else {\n this.render = this._render;\n }\n }\n\n /**\n * 触发渲染\n */\n private render: () => void = this._render;\n\n private _render(): void {\n if (!this.initialized) {\n return;\n }\n const renderContext = this.createRenderContext();\n this.renderCanvas(renderContext);\n }\n\n private createRenderContext(): MinimapRenderContext {\n const { canvas, context2D, nodes } = this;\n const nodeTransforms: FlowNodeTransformData[] = this.nodeTransforms(nodes);\n const nodeRects: Rectangle[] = nodeTransforms.map((transform) => transform.bounds);\n const viewRect: Rectangle = this.viewRect();\n const renderRect: Rectangle = this.renderRect(nodeRects).withPadding({\n top: this.style.canvasPadding,\n bottom: this.style.canvasPadding,\n left: this.style.canvasPadding,\n right: this.style.canvasPadding,\n });\n const canvasRect: Rectangle = Rectangle.enlarge([viewRect, renderRect]);\n\n const { scale, offset } = this.calculateScaleAndOffset({ canvasRect });\n\n return {\n canvas,\n context2D,\n nodeRects,\n canvasRect,\n viewRect,\n renderRect,\n scale,\n offset,\n };\n }\n\n private renderCanvas(renderContext: MinimapRenderContext) {\n const { canvas, context2D, nodeRects, viewRect, scale, offset } = renderContext;\n\n // 清空画布\n MinimapDraw.clear({ canvas, context: context2D });\n\n // 设置背景色\n MinimapDraw.backgroundColor({\n canvas,\n context: context2D,\n color: this.style.canvasBackground,\n });\n\n // 绘制视窗\n MinimapDraw.roundRectangle({\n context: context2D,\n rect: this.rectOnCanvas({ rect: viewRect, scale, offset }),\n color: this.style.viewportBackground,\n radius: this.style.viewportBorderRadius as number,\n });\n\n // 绘制节点\n nodeRects.forEach((nodeRect: Rectangle) => {\n MinimapDraw.roundRectangle({\n context: context2D,\n rect: this.rectOnCanvas({ rect: nodeRect, scale, offset }),\n color: this.style.nodeColor as string,\n radius: this.style.nodeBorderRadius as number,\n borderWidth: this.style.nodeBorderWidth as number,\n borderColor: this.style.nodeBorderColor as string,\n });\n });\n\n // 绘制视窗边框\n MinimapDraw.roundRectangle({\n context: context2D,\n rect: this.rectOnCanvas({ rect: viewRect, scale, offset }),\n color: 'rgba(255, 255, 255, 0)' as string,\n radius: this.style.viewportBorderRadius as number,\n borderColor: this.style.viewportBorderColor as string,\n borderWidth: this.style.viewportBorderWidth as number,\n borderDashLength: this.style.viewportBorderDashLength as number,\n });\n\n // 绘制视窗外的蒙层\n MinimapDraw.overlay({\n canvas,\n context: context2D,\n offset,\n scale,\n rect: viewRect,\n color: this.style.overlayColor as string,\n });\n }\n\n private calculateScaleAndOffset(params: { canvasRect: Rectangle }): {\n scale: number;\n offset: IPoint;\n } {\n const { canvasRect } = params;\n const { width: canvasWidth, height: canvasHeight } = this.canvas;\n\n // 计算缩放比例\n const scaleX = canvasWidth / canvasRect.width;\n const scaleY = canvasHeight / canvasRect.height;\n const scale = Math.min(scaleX, scaleY);\n\n // 计算缩放后的渲染区域尺寸\n const scaledWidth = canvasRect.width * scale;\n const scaledHeight = canvasRect.height * scale;\n\n // 计算居中偏移量\n const centerOffsetX = (canvasWidth - scaledWidth) / 2;\n const centerOffsetY = (canvasHeight - scaledHeight) / 2;\n\n // 计算最终偏移量\n const offset = {\n x: centerOffsetX / scale - canvasRect.x,\n y: centerOffsetY / scale - canvasRect.y,\n };\n\n return { scale, offset };\n }\n\n private get nodes(): FlowNodeEntity[] {\n return this.document.getAllNodes().filter((node) => {\n // 去除不可见节点\n if (node.hidden) return false;\n // 去除根节点\n if (node.flowNodeType === FlowNodeBaseType.ROOT) return;\n // 去除非一级节点\n if (\n !this.options.enableDisplayAllNodes &&\n node.parent &&\n node.parent.flowNodeType !== FlowNodeBaseType.ROOT\n )\n return;\n return true;\n });\n }\n\n private nodeTransforms(nodes: FlowNodeEntity[]): FlowNodeTransformData[] {\n return nodes.map((node) => node.getData(FlowNodeTransformData)).filter(Boolean);\n }\n\n private renderRect(rects: Rectangle[]): Rectangle {\n return Rectangle.enlarge(rects);\n }\n\n private viewRect(): Rectangle {\n const { width, height, scrollX, scrollY, zoom } = this.playgroundConfig.config;\n return new Rectangle(scrollX / zoom, scrollY / zoom, width / zoom, height / zoom);\n }\n\n private mountListener(): void {\n const entityManagerDisposer = this.entityManager.onEntityChange(() => this.render());\n this.toDispose.push(entityManagerDisposer);\n }\n\n /** 计算画布坐标系下的矩形 */\n private rectOnCanvas(params: { rect: Rectangle; scale: number; offset: IPoint }): Rectangle {\n const { rect, scale, offset } = params;\n return new Rectangle(\n (rect.x + offset.x) * scale,\n (rect.y + offset.y) * scale,\n rect.width * scale,\n rect.height * scale\n );\n }\n\n private isPointInRect(params: { point: IPoint; rect: Rectangle }): boolean {\n const { point, rect } = params;\n return (\n point.x >= rect.x &&\n point.x <= rect.x + rect.width &&\n point.y >= rect.y &&\n point.y <= rect.y + rect.height\n );\n }\n\n private addEventListeners(): void {\n this.canvas.addEventListener('wheel', this.handleWheel);\n this.canvas.addEventListener('mousedown', this.handleStartDrag);\n this.canvas.addEventListener('touchstart', this.handleStartDrag, { passive: false });\n this.canvas.addEventListener('mousemove', this.handleCursor);\n }\n\n private removeEventListeners(): void {\n this.canvas.removeEventListener('wheel', this.handleWheel);\n this.canvas.removeEventListener('mousedown', this.handleStartDrag);\n this.canvas.removeEventListener('touchstart', this.handleStartDrag);\n this.canvas.removeEventListener('mousemove', this.handleCursor);\n }\n\n private handleWheel = (event: WheelEvent): void => {};\n\n private handleStartDrag = (event: MouseEvent | TouchEvent): void => {\n MouseTouchEvent.preventDefault(event);\n event.stopPropagation();\n const renderContext = this.createRenderContext();\n const { viewRect, scale, offset } = renderContext;\n const canvasRect = this.canvas.getBoundingClientRect();\n const { clientX, clientY } = MouseTouchEvent.getEventCoord(event);\n const mousePoint: IPoint = {\n x: clientX - canvasRect.left,\n y: clientY - canvasRect.top,\n };\n\n const viewRectOnCanvas = this.rectOnCanvas({\n rect: viewRect,\n scale,\n offset,\n });\n if (!this.isPointInRect({ point: mousePoint, rect: viewRectOnCanvas })) {\n return;\n }\n this.isDragging = true;\n this.dragStart = mousePoint;\n // click\n document.addEventListener('mousemove', this.handleDragging);\n document.addEventListener('mouseup', this.handleEndDrag);\n // touch\n document.addEventListener('touchmove', this.handleDragging, { passive: false });\n document.addEventListener('touchend', this.handleEndDrag);\n document.addEventListener('touchcancel', this.handleEndDrag);\n };\n\n private handleDragging = (event: MouseEvent | TouchEvent): void => {\n if (!this.isDragging || !this.dragStart) return;\n MouseTouchEvent.preventDefault(event);\n event.stopPropagation();\n\n const renderContext = this.createRenderContext();\n const { scale } = renderContext;\n const canvasRect = this.canvas.getBoundingClientRect();\n const { clientX, clientY } = MouseTouchEvent.getEventCoord(event);\n const mouseX = clientX - canvasRect.left;\n const mouseY = clientY - canvasRect.top;\n\n const deltaX = (mouseX - this.dragStart.x) / scale;\n const deltaY = (mouseY - this.dragStart.y) / scale;\n\n this.updateScrollPosition(deltaX, deltaY);\n\n this.dragStart = { x: mouseX, y: mouseY };\n this.render();\n };\n\n private handleEndDrag = (event: MouseEvent | TouchEvent): void => {\n MouseTouchEvent.preventDefault(event);\n event.stopPropagation();\n // click\n document.removeEventListener('mousemove', this.handleDragging);\n document.removeEventListener('mouseup', this.handleEndDrag);\n // touch\n document.removeEventListener('touchmove', this.handleDragging);\n document.removeEventListener('touchend', this.handleEndDrag);\n document.removeEventListener('touchcancel', this.handleEndDrag);\n this.isDragging = false;\n this.dragStart = undefined;\n this.setActivate(this.isMouseInCanvas(event));\n };\n\n private handleCursor = (event: MouseEvent): void => {\n if (!this.activated) return;\n\n const renderContext = this.createRenderContext();\n const { viewRect, scale, offset } = renderContext;\n const canvasRect = this.canvas.getBoundingClientRect();\n const mousePoint: IPoint = {\n x: event.clientX - canvasRect.left,\n y: event.clientY - canvasRect.top,\n };\n\n const viewRectOnCanvas = this.rectOnCanvas({\n rect: viewRect,\n scale,\n offset,\n });\n\n if (this.isPointInRect({ point: mousePoint, rect: viewRectOnCanvas })) {\n // 鼠标在视窗框内\n this.canvas.style.cursor = 'grab';\n } else {\n // 鼠标在视窗框外但在画布内\n this.canvas.style.cursor = 'default';\n }\n };\n\n private isMouseInCanvas(event: MouseEvent | TouchEvent): boolean {\n const canvasRect = this.canvas.getBoundingClientRect();\n const { clientX, clientY } = MouseTouchEvent.getEventCoord(event);\n return (\n clientX >= canvasRect.left &&\n clientX <= canvasRect.right &&\n clientY >= canvasRect.top &&\n clientY <= canvasRect.bottom\n );\n }\n\n private updateScrollPosition(deltaX: number, deltaY: number): void {\n const { scrollX, scrollY, zoom } = this.playgroundConfig.config;\n this.playgroundConfig.updateConfig({\n scrollX: scrollX + deltaX * zoom,\n scrollY: scrollY + deltaY * zoom,\n });\n }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport type { IPoint, Rectangle } from '@flowgram.ai/utils';\n\nexport namespace MinimapDraw {\n /** 矩形是否合法 */\n const isRectValid = (rect: Rectangle): boolean => rect.width > 0 && rect.height > 0;\n\n /** 清空画布 */\n export const clear = (params: {\n canvas: HTMLCanvasElement;\n context: CanvasRenderingContext2D;\n }) => {\n const { canvas, context } = params;\n context.clearRect(0, 0, canvas.width, canvas.height);\n };\n\n /** 设置背景色 */\n export const backgroundColor = (params: {\n canvas: HTMLCanvasElement;\n context: CanvasRenderingContext2D;\n color: string;\n }) => {\n const { canvas, context, color } = params;\n context.fillStyle = color;\n context.fillRect(0, 0, canvas.width, canvas.height);\n };\n\n /** 绘制矩形 */\n export const rectangle = (params: {\n context: CanvasRenderingContext2D;\n rect: Rectangle;\n color: string;\n }): void => {\n const { context, rect, color } = params;\n if (!isRectValid(rect)) {\n return;\n }\n context.fillStyle = color;\n context.fillRect(rect.x, rect.y, rect.width, rect.height);\n };\n\n /** 绘制圆角矩形 */\n export const roundRectangle = (params: {\n context: CanvasRenderingContext2D;\n rect: Rectangle;\n color: string;\n radius: number;\n borderColor?: string;\n borderWidth?: number;\n borderDashLength?: number;\n }): void => {\n const { context, rect, color, radius, borderColor, borderDashLength, borderWidth = 0 } = params;\n const { x, y, width, height } = rect;\n\n if (!isRectValid(rect)) {\n return;\n }\n\n // 开始新路径\n context.beginPath();\n\n // 绘制圆角矩形路径\n const drawRoundedRectPath = (): void => {\n context.moveTo(x + radius, y);\n context.lineTo(x + width - radius, y);\n context.quadraticCurveTo(x + width, y, x + width, y + radius);\n context.lineTo(x + width, y + height - radius);\n context.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);\n context.lineTo(x + radius, y + height);\n context.quadraticCurveTo(x, y + height, x, y + height - radius);\n context.lineTo(x, y + radius);\n context.quadraticCurveTo(x, y, x + radius, y);\n context.closePath();\n };\n\n drawRoundedRectPath();\n\n // 填充矩形\n context.fillStyle = color;\n context.fill();\n\n // 如果设置了边框,绘制边框\n if (borderColor && borderWidth > 0) {\n context.strokeStyle = borderColor;\n context.lineWidth = borderWidth;\n\n // 设置虚线样式\n if (borderDashLength) {\n context.setLineDash([borderDashLength, borderDashLength]);\n } else {\n context.setLineDash([]);\n }\n\n context.stroke();\n\n // 重置虚线样式\n context.setLineDash([]);\n }\n };\n\n /** 绘制矩形外的蒙层 */\n export const overlay = (params: {\n canvas: HTMLCanvasElement;\n context: CanvasRenderingContext2D;\n offset: IPoint;\n scale: number;\n rect: Rectangle;\n color: string;\n }): void => {\n const { canvas, context, offset, scale, rect, color } = params;\n\n if (!isRectValid(rect)) {\n return;\n }\n\n context.fillStyle = color;\n\n // 上方蒙层\n context.fillRect(0, 0, canvas.width, (rect.y + offset.y) * scale);\n\n // 下方蒙层\n context.fillRect(\n 0,\n (rect.y + rect.height + offset.y) * scale,\n canvas.width,\n canvas.height - (rect.y + rect.height + offset.y) * scale\n );\n\n // 左侧蒙层\n context.fillRect(\n 0,\n (rect.y + offset.y) * scale,\n (rect.x + offset.x) * scale,\n rect.height * scale\n );\n\n // 右侧蒙层\n context.fillRect(\n (rect.x + rect.width + offset.x) * scale,\n (rect.y + offset.y) * scale,\n canvas.width - (rect.x + rect.width + offset.x) * scale,\n rect.height * scale\n );\n };\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport React from 'react';\n\nimport { inject, injectable } from 'inversify';\nimport { Layer } from '@flowgram.ai/core';\nimport { domUtils } from '@flowgram.ai/utils';\n\nimport { MinimapLayerOptions } from './type';\nimport { FlowMinimapService } from './service';\nimport { MinimapRender } from './component';\n\n@injectable()\nexport class FlowMinimapLayer extends Layer<MinimapLayerOptions> {\n public static type = 'FlowMinimapLayer';\n\n @inject(FlowMinimapService) private readonly service: FlowMinimapService;\n\n public readonly node: HTMLElement;\n\n private readonly className = 'gedit-minimap-layer gedit-playground-layer';\n\n constructor() {\n super();\n this.node = domUtils.createDivWithClass(this.className);\n this.node.style.zIndex = '9999';\n }\n\n public render(): JSX.Element {\n if (this.options.disableLayer) {\n return <></>;\n }\n return (\n <MinimapRender\n service={this.service}\n panelStyles={this.options.panelStyles}\n containerStyles={this.options.containerStyles}\n inactiveStyle={this.options.inactiveStyle}\n />\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;AAKA,OAAO,SAAwB,WAAW,QAAQ,gBAAgB;;;ACE3D,IAAM,4BAAgD;AAAA,EAC3D,aAAa;AAAA,EACb,cAAc;AAAA,EACd,eAAe;AAAA,EACf,kBAAkB;AAAA,EAClB,oBAAoB;AAAA,EACpB,oBAAoB;AAAA,EACpB,sBAAsB;AAAA,EACtB,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EACrB,0BAA0B;AAAA,EAC1B,WAAW;AAAA,EACX,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,iBAAiB;AAAA,EACjB,cAAc;AAChB;AAEO,IAAM,8BAAoD;AAAA,EAC/D,OAAO;AAAA,EACP,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,YAAY;AACd;AAEO,IAAM,wBAA+C;AAAA,EAC1D,a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AAc;AACZ,UAAM;AAHR,SAAiB,YAAY;AAI3B,SAAK,OAAO,SAAS,mBAAmB,KAAK,SAAS;AACtD,SAAK,KAAK,MAAM,SAAS;AAAA,EAC3B;AAAA,EAEO,SAAsB;AAC3B,QAAI,KAAK,QAAQ,cAAc;AAC7B,aAAO,gBAAAC,OAAA,cAAAA,OAAA,cAAE;AAAA,IACX;AACA,WACE,gBAAAA,OAAA;AAAA,MAAC;AAAA;AAAA,QACC,SAAS,KAAK;AAAA,QACd,aAAa,KAAK,QAAQ;AAAA,QAC1B,iBAAiB,KAAK,QAAQ;AAAA,QAC9B,eAAe,KAAK,QAAQ;AAAA;AAAA,IAC9B;AAAA,EAEJ;AACF;AA5Ba,iBACG,OAAO;AAEwB;AAAA,EAA5CC,QAAO,kBAAkB;AAAA,GAHf,iBAGkC;AAHlC,mBAAN;AAAA,EADNC,YAAW;AAAA,GACC;;;AHLN,IAAM,sBAAsB,oBAAgD;AAAA,EACjF,QAAQ,CAAC,EAAE,KAAK,MAAM;AACpB,SAAK,kBAAkB,EAAE,OAAO,EAAE,iBAAiB;AAAA,EACrD;AAAA,EACA,QAAQ,CAAC,KAAoB,SAAqC;AAChE,QAAI,WAAW,cAAc,kBAAkB,IAAI;AACnD,QAAI,IAAI,kBAAkB,EAAE,KAAK,IAAI;AAAA,EACvC;AAAA,EACA,WAAW,CAAC,QAAuB;AACjC,QAAI,IAAI,kBAAkB,EAAE,QAAQ;AAAA,EACtC;AACF,CAAC;","names":["MinimapDraw","React","inject","injectable","React","inject","injectable"]}
@@ -0,0 +1,153 @@
1
+ import React, { CSSProperties } from 'react';
2
+ import { Rectangle, IPoint, Disposable } from '@flowgram.ai/utils';
3
+ import * as _flowgram_ai_core from '@flowgram.ai/core';
4
+ import { Layer } from '@flowgram.ai/core';
5
+
6
+ /**
7
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
8
+ * SPDX-License-Identifier: MIT
9
+ */
10
+
11
+ interface MinimapCanvasStyle {
12
+ canvasWidth: number;
13
+ canvasHeight: number;
14
+ canvasPadding: number;
15
+ canvasBackground: string;
16
+ canvasBorderRadius: number | undefined;
17
+ viewportBackground: string;
18
+ viewportBorderRadius: number | undefined;
19
+ viewportBorderColor: string;
20
+ viewportBorderWidth: number;
21
+ viewportBorderDashLength: number | undefined;
22
+ nodeColor: string;
23
+ nodeBorderRadius: number | undefined;
24
+ nodeBorderWidth: number;
25
+ nodeBorderColor: string | undefined;
26
+ overlayColor: string;
27
+ }
28
+ interface MinimapInactiveStyle {
29
+ scale: number;
30
+ opacity: number;
31
+ translateX: number;
32
+ translateY: number;
33
+ }
34
+ interface MinimapServiceOptions {
35
+ canvasStyle: Partial<MinimapCanvasStyle>;
36
+ canvasClassName: string;
37
+ enableInactiveDebounce: boolean;
38
+ enableActiveDebounce: boolean;
39
+ enableDisplayAllNodes: boolean;
40
+ activeDebounceTime: number;
41
+ inactiveDebounceTime: number;
42
+ }
43
+ interface MinimapLayerOptions {
44
+ disableLayer?: boolean;
45
+ panelStyles?: CSSProperties;
46
+ containerStyles?: CSSProperties;
47
+ inactiveStyle?: Partial<MinimapInactiveStyle>;
48
+ }
49
+ interface CreateMinimapPluginOptions extends MinimapLayerOptions, Partial<MinimapServiceOptions> {
50
+ }
51
+ interface MinimapRenderContext {
52
+ canvas: HTMLCanvasElement;
53
+ context2D: CanvasRenderingContext2D;
54
+ nodeRects: Rectangle[];
55
+ viewRect: Rectangle;
56
+ renderRect: Rectangle;
57
+ canvasRect: Rectangle;
58
+ scale: number;
59
+ offset: IPoint;
60
+ }
61
+
62
+ /**
63
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
64
+ * SPDX-License-Identifier: MIT
65
+ */
66
+
67
+ declare class FlowMinimapService {
68
+ private readonly document;
69
+ private readonly entityManager;
70
+ private readonly playgroundConfig;
71
+ readonly canvas: HTMLCanvasElement;
72
+ readonly context2D: CanvasRenderingContext2D;
73
+ activated: boolean;
74
+ private onActiveCallbacks;
75
+ private options;
76
+ private toDispose;
77
+ private initialized;
78
+ private isDragging;
79
+ private style;
80
+ private dragStart?;
81
+ constructor();
82
+ init(options?: Partial<MinimapServiceOptions>): void;
83
+ dispose(): void;
84
+ setActivate(activate: boolean): void;
85
+ onActive: (callback: (activated: boolean) => void) => Disposable;
86
+ private initStyle;
87
+ private setDebounce;
88
+ /**
89
+ * 触发渲染
90
+ */
91
+ private render;
92
+ private _render;
93
+ private createRenderContext;
94
+ private renderCanvas;
95
+ private calculateScaleAndOffset;
96
+ private get nodes();
97
+ private nodeTransforms;
98
+ private renderRect;
99
+ private viewRect;
100
+ private mountListener;
101
+ /** 计算画布坐标系下的矩形 */
102
+ private rectOnCanvas;
103
+ private isPointInRect;
104
+ private addEventListeners;
105
+ private removeEventListeners;
106
+ private handleWheel;
107
+ private handleStartDrag;
108
+ private handleDragging;
109
+ private handleEndDrag;
110
+ private handleCursor;
111
+ private isMouseInCanvas;
112
+ private updateScrollPosition;
113
+ }
114
+
115
+ /**
116
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
117
+ * SPDX-License-Identifier: MIT
118
+ */
119
+
120
+ interface MinimapProps {
121
+ service: FlowMinimapService;
122
+ panelStyles?: CSSProperties;
123
+ containerStyles?: CSSProperties;
124
+ inactiveStyle?: Partial<MinimapInactiveStyle>;
125
+ }
126
+ declare const MinimapRender: React.FC<MinimapProps>;
127
+
128
+ /**
129
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
130
+ * SPDX-License-Identifier: MIT
131
+ */
132
+
133
+ declare const MinimapDefaultCanvasStyle: MinimapCanvasStyle;
134
+ declare const MinimapDefaultInactiveStyle: MinimapInactiveStyle;
135
+ declare const MinimapDefaultOptions: MinimapServiceOptions;
136
+
137
+ declare const createMinimapPlugin: _flowgram_ai_core.PluginCreator<CreateMinimapPluginOptions>;
138
+
139
+ /**
140
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
141
+ * SPDX-License-Identifier: MIT
142
+ */
143
+
144
+ declare class FlowMinimapLayer extends Layer<MinimapLayerOptions> {
145
+ static type: string;
146
+ private readonly service;
147
+ readonly node: HTMLElement;
148
+ private readonly className;
149
+ constructor();
150
+ render(): JSX.Element;
151
+ }
152
+
153
+ export { type CreateMinimapPluginOptions, FlowMinimapLayer, FlowMinimapService, type MinimapCanvasStyle, MinimapDefaultCanvasStyle, MinimapDefaultInactiveStyle, MinimapDefaultOptions, type MinimapInactiveStyle, type MinimapLayerOptions, MinimapRender, type MinimapRenderContext, type MinimapServiceOptions, createMinimapPlugin };
@@ -0,0 +1,153 @@
1
+ import React, { CSSProperties } from 'react';
2
+ import { Rectangle, IPoint, Disposable } from '@flowgram.ai/utils';
3
+ import * as _flowgram_ai_core from '@flowgram.ai/core';
4
+ import { Layer } from '@flowgram.ai/core';
5
+
6
+ /**
7
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
8
+ * SPDX-License-Identifier: MIT
9
+ */
10
+
11
+ interface MinimapCanvasStyle {
12
+ canvasWidth: number;
13
+ canvasHeight: number;
14
+ canvasPadding: number;
15
+ canvasBackground: string;
16
+ canvasBorderRadius: number | undefined;
17
+ viewportBackground: string;
18
+ viewportBorderRadius: number | undefined;
19
+ viewportBorderColor: string;
20
+ viewportBorderWidth: number;
21
+ viewportBorderDashLength: number | undefined;
22
+ nodeColor: string;
23
+ nodeBorderRadius: number | undefined;
24
+ nodeBorderWidth: number;
25
+ nodeBorderColor: string | undefined;
26
+ overlayColor: string;
27
+ }
28
+ interface MinimapInactiveStyle {
29
+ scale: number;
30
+ opacity: number;
31
+ translateX: number;
32
+ translateY: number;
33
+ }
34
+ interface MinimapServiceOptions {
35
+ canvasStyle: Partial<MinimapCanvasStyle>;
36
+ canvasClassName: string;
37
+ enableInactiveDebounce: boolean;
38
+ enableActiveDebounce: boolean;
39
+ enableDisplayAllNodes: boolean;
40
+ activeDebounceTime: number;
41
+ inactiveDebounceTime: number;
42
+ }
43
+ interface MinimapLayerOptions {
44
+ disableLayer?: boolean;
45
+ panelStyles?: CSSProperties;
46
+ containerStyles?: CSSProperties;
47
+ inactiveStyle?: Partial<MinimapInactiveStyle>;
48
+ }
49
+ interface CreateMinimapPluginOptions extends MinimapLayerOptions, Partial<MinimapServiceOptions> {
50
+ }
51
+ interface MinimapRenderContext {
52
+ canvas: HTMLCanvasElement;
53
+ context2D: CanvasRenderingContext2D;
54
+ nodeRects: Rectangle[];
55
+ viewRect: Rectangle;
56
+ renderRect: Rectangle;
57
+ canvasRect: Rectangle;
58
+ scale: number;
59
+ offset: IPoint;
60
+ }
61
+
62
+ /**
63
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
64
+ * SPDX-License-Identifier: MIT
65
+ */
66
+
67
+ declare class FlowMinimapService {
68
+ private readonly document;
69
+ private readonly entityManager;
70
+ private readonly playgroundConfig;
71
+ readonly canvas: HTMLCanvasElement;
72
+ readonly context2D: CanvasRenderingContext2D;
73
+ activated: boolean;
74
+ private onActiveCallbacks;
75
+ private options;
76
+ private toDispose;
77
+ private initialized;
78
+ private isDragging;
79
+ private style;
80
+ private dragStart?;
81
+ constructor();
82
+ init(options?: Partial<MinimapServiceOptions>): void;
83
+ dispose(): void;
84
+ setActivate(activate: boolean): void;
85
+ onActive: (callback: (activated: boolean) => void) => Disposable;
86
+ private initStyle;
87
+ private setDebounce;
88
+ /**
89
+ * 触发渲染
90
+ */
91
+ private render;
92
+ private _render;
93
+ private createRenderContext;
94
+ private renderCanvas;
95
+ private calculateScaleAndOffset;
96
+ private get nodes();
97
+ private nodeTransforms;
98
+ private renderRect;
99
+ private viewRect;
100
+ private mountListener;
101
+ /** 计算画布坐标系下的矩形 */
102
+ private rectOnCanvas;
103
+ private isPointInRect;
104
+ private addEventListeners;
105
+ private removeEventListeners;
106
+ private handleWheel;
107
+ private handleStartDrag;
108
+ private handleDragging;
109
+ private handleEndDrag;
110
+ private handleCursor;
111
+ private isMouseInCanvas;
112
+ private updateScrollPosition;
113
+ }
114
+
115
+ /**
116
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
117
+ * SPDX-License-Identifier: MIT
118
+ */
119
+
120
+ interface MinimapProps {
121
+ service: FlowMinimapService;
122
+ panelStyles?: CSSProperties;
123
+ containerStyles?: CSSProperties;
124
+ inactiveStyle?: Partial<MinimapInactiveStyle>;
125
+ }
126
+ declare const MinimapRender: React.FC<MinimapProps>;
127
+
128
+ /**
129
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
130
+ * SPDX-License-Identifier: MIT
131
+ */
132
+
133
+ declare const MinimapDefaultCanvasStyle: MinimapCanvasStyle;
134
+ declare const MinimapDefaultInactiveStyle: MinimapInactiveStyle;
135
+ declare const MinimapDefaultOptions: MinimapServiceOptions;
136
+
137
+ declare const createMinimapPlugin: _flowgram_ai_core.PluginCreator<CreateMinimapPluginOptions>;
138
+
139
+ /**
140
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
141
+ * SPDX-License-Identifier: MIT
142
+ */
143
+
144
+ declare class FlowMinimapLayer extends Layer<MinimapLayerOptions> {
145
+ static type: string;
146
+ private readonly service;
147
+ readonly node: HTMLElement;
148
+ private readonly className;
149
+ constructor();
150
+ render(): JSX.Element;
151
+ }
152
+
153
+ export { type CreateMinimapPluginOptions, FlowMinimapLayer, FlowMinimapService, type MinimapCanvasStyle, MinimapDefaultCanvasStyle, MinimapDefaultInactiveStyle, MinimapDefaultOptions, type MinimapInactiveStyle, type MinimapLayerOptions, MinimapRender, type MinimapRenderContext, type MinimapServiceOptions, createMinimapPlugin };