{"version":3,"sources":["jsdelivr-header.js","/npm/@flowgram.ai/free-history-plugin@1.0.3/src/index.ts","/npm/@flowgram.ai/free-history-plugin@1.0.3/src/create-free-history-plugin.ts","/npm/@flowgram.ai/free-history-plugin@1.0.3/src/history-entity-manager.ts","/npm/@flowgram.ai/free-history-plugin@1.0.3/src/handlers/drag-nodes-handler.ts","/npm/@flowgram.ai/free-history-plugin@1.0.3/src/types.ts","/npm/@flowgram.ai/free-history-plugin@1.0.3/src/handlers/change-content-handler.ts","/npm/@flowgram.ai/free-history-plugin@1.0.3/src/free-history-config.ts","/npm/@flowgram.ai/free-history-plugin@1.0.3/src/changes/delete-node-change.ts","/npm/@flowgram.ai/free-history-plugin@1.0.3/src/changes/delete-line-change.ts","/npm/@flowgram.ai/free-history-plugin@1.0.3/src/changes/change-line-data.ts","/npm/@flowgram.ai/free-history-plugin@1.0.3/src/changes/add-node-change.ts","/npm/@flowgram.ai/free-history-plugin@1.0.3/src/changes/add-line-change.ts","/npm/@flowgram.ai/free-history-plugin@1.0.3/src/changes/index.ts","/npm/@flowgram.ai/free-history-plugin@1.0.3/src/free-history-registers.ts","/npm/@flowgram.ai/free-history-plugin@1.0.3/src/operation-metas/reset-layout.ts","/npm/@flowgram.ai/free-history-plugin@1.0.3/src/operation-metas/base.ts","/npm/@flowgram.ai/free-history-plugin@1.0.3/src/operation-metas/move-child-nodes.ts","/npm/@flowgram.ai/free-history-plugin@1.0.3/src/operation-metas/drag-nodes.ts","/npm/@flowgram.ai/free-history-plugin@1.0.3/src/operation-metas/delete-node.ts","/npm/@flowgram.ai/free-history-plugin@1.0.3/src/operation-metas/delete-line.ts","/npm/@flowgram.ai/free-history-plugin@1.0.3/src/operation-metas/change-line-data.ts","/npm/@flowgram.ai/free-history-plugin@1.0.3/src/operation-metas/add-node.ts","/npm/@flowgram.ai/free-history-plugin@1.0.3/src/operation-metas/add-line.ts","/npm/@flowgram.ai/free-history-plugin@1.0.3/src/operation-metas/index.ts","/npm/@flowgram.ai/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UACA,KAAM,IAAM,EAAe,OAC3B,KAAM,IAAM,EAAe,OAE/B","file":"/npm/@flowgram.ai/free-history-plugin@1.0.3/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@flowgram.ai/free-history-plugin@1.0.3/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nexport * from './create-free-history-plugin';\nexport * from './types';\nexport * from '@flowgram.ai/history';\nexport * from './free-history-config';\nexport * from './hooks';\nexport * from './free-history-registers';\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { HistoryContainerModule, OperationContribution } from '@flowgram.ai/history';\nimport { bindContributions, definePluginCreator } from '@flowgram.ai/core';\n\nimport { type FreeHistoryPluginOptions } from './types';\nimport { HistoryEntityManager } from './history-entity-manager';\nimport { DragNodesHandler } from './handlers/drag-nodes-handler';\nimport { ChangeContentHandler } from './handlers/change-content-handler';\nimport { FreeHistoryRegisters } from './free-history-registers';\nimport { FreeHistoryManager } from './free-history-manager';\nimport { FreeHistoryConfig } from './free-history-config';\n\nexport const createFreeHistoryPlugin = definePluginCreator<FreeHistoryPluginOptions>({\n  onBind: ({ bind }) => {\n    bindContributions(bind, FreeHistoryRegisters, [OperationContribution]);\n    bind(FreeHistoryConfig).toSelf().inSingletonScope();\n    bind(FreeHistoryManager).toSelf().inSingletonScope();\n    bind(HistoryEntityManager).toSelf().inSingletonScope();\n    bind(DragNodesHandler).toSelf().inSingletonScope();\n    bind(ChangeContentHandler).toSelf().inSingletonScope();\n  },\n  onInit(ctx, opts): void {\n    ctx.get<FreeHistoryConfig>(FreeHistoryConfig).init(ctx, opts);\n\n    if (!opts.enable) {\n      return;\n    }\n    ctx.get<FreeHistoryManager>(FreeHistoryManager).onInit(ctx, opts);\n  },\n  onDispose(ctx) {\n    ctx.get<HistoryEntityManager>(HistoryEntityManager).dispose();\n  },\n  containerModules: [HistoryContainerModule],\n});\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\n/* eslint-disable @typescript-eslint/naming-convention */\nimport { cloneDeep, isEqual } from 'lodash-es';\nimport { injectable } from 'inversify';\nimport { type Disposable, DisposableCollection } from '@flowgram.ai/utils';\nimport { type EntityData } from '@flowgram.ai/core';\n\n@injectable()\nexport class HistoryEntityManager implements Disposable {\n  private _entityDataValues: Map<EntityData, unknown> = new Map();\n\n  private _toDispose: DisposableCollection = new DisposableCollection();\n\n  addEntityData(entityData: EntityData) {\n    this._entityDataValues.set(entityData, cloneDeep(entityData.toJSON()));\n    this._toDispose.push(\n      entityData.onWillChange((event) => {\n        const value = event.toJSON();\n        const oldValue = this._entityDataValues.get(entityData);\n        if (isEqual(value, oldValue)) {\n          return;\n        }\n        this._entityDataValues.set(entityData, cloneDeep(value));\n      })\n    );\n  }\n\n  getValue(entityData: EntityData) {\n    return this._entityDataValues.get(entityData);\n  }\n\n  setValue(entityData: EntityData, value: unknown) {\n    return this._entityDataValues.set(entityData, value);\n  }\n\n  dispose() {\n    this._entityDataValues.clear();\n    this._toDispose.dispose();\n  }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\n/* eslint-disable @typescript-eslint/naming-convention */\nimport { injectable, inject } from 'inversify';\nimport { HistoryService } from '@flowgram.ai/history';\nimport { type NodesDragEndEvent } from '@flowgram.ai/free-layout-core';\nimport { TransformData } from '@flowgram.ai/core';\n\nimport { FreeOperationType, type IHandler } from '../types';\n\n@injectable()\nexport class DragNodesHandler implements IHandler<NodesDragEndEvent> {\n  @inject(HistoryService)\n  private _historyService: HistoryService;\n\n  handle(event: NodesDragEndEvent) {\n    if (event.type === 'onDragEnd') {\n      this._dragNode(event);\n    }\n  }\n\n  private _dragNode(event: NodesDragEndEvent) {\n    this._historyService.pushOperation(\n      {\n        type: FreeOperationType.dragNodes,\n        value: {\n          ids: event.nodes.map((node) => node.id),\n          value: event.nodes.map((node) => {\n            const { x, y } = node.getData(TransformData).position;\n            return {\n              x,\n              y,\n            };\n          }),\n          oldValue: event.startPositions,\n        },\n      },\n      { noApply: true }\n    );\n  }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\n/* eslint-disable @typescript-eslint/naming-convention */\nimport { type IPoint } from '@flowgram.ai/utils';\nimport { type Operation, type OperationMeta } from '@flowgram.ai/history';\nimport {\n  type WorkflowContentChangeType,\n  type WorkflowContentChangeEvent,\n  type WorkflowLineEntity,\n  type WorkflowLinePortInfo,\n  type WorkflowNodeJSON,\n  type PositionMap,\n} from '@flowgram.ai/free-layout-core';\nimport { type FlowNodeEntity, type FlowNodeJSON } from '@flowgram.ai/document';\nimport { type EntityData, type PluginContext } from '@flowgram.ai/core';\n\nexport enum FreeOperationType {\n  addLine = 'addLine',\n  deleteLine = 'deleteLine',\n  changeLineData = 'changeLineData',\n  moveNode = 'moveNode',\n  addNode = 'addNode',\n  deleteNode = 'deleteNode',\n  changeNodeData = 'changeNodeData',\n  resetLayout = 'resetLayout',\n  dragNodes = 'dragNodes',\n  moveChildNodes = 'moveChildNodes',\n}\n\nexport interface AddOrDeleteLineOperationValue extends WorkflowLinePortInfo {\n  id: string;\n}\n\nexport interface ChangeLineDataValue {\n  id: string;\n  oldValue: unknown;\n  newValue: unknown;\n}\nexport interface AddOrDeleteWorkflowNodeOperationValue {\n  node: WorkflowNodeJSON;\n  parentID?: string;\n}\n\nexport interface AddLineOperation extends Operation {\n  type: FreeOperationType.addLine;\n  value: AddOrDeleteLineOperationValue;\n}\n\nexport interface ChangeLineDataOperation extends Operation {\n  type: FreeOperationType.changeLineData;\n  value: ChangeLineDataValue;\n}\n\nexport interface DeleteLineOperation extends Operation {\n  type: FreeOperationType.deleteLine;\n  value: AddOrDeleteLineOperationValue;\n}\n\nexport interface MoveNodeOperation extends Operation {\n  type: FreeOperationType.moveNode;\n  value: MoveNodeOperationValue;\n}\n\nexport interface AddWorkflowNodeOperation extends Operation {\n  type: FreeOperationType.addNode;\n  value: AddOrDeleteWorkflowNodeOperationValue;\n}\n\nexport interface DeleteWorkflowNodeOperation extends Operation {\n  type: FreeOperationType.deleteNode;\n  value: AddOrDeleteWorkflowNodeOperationValue;\n}\n\nexport interface MoveNodeOperationValue {\n  id: string;\n  value: {\n    x: number;\n    y: number;\n  };\n  oldValue: {\n    x: number;\n    y: number;\n  };\n}\n\nexport interface DragNodeOperationValue {\n  ids: string[];\n  value: IPoint[];\n  oldValue: IPoint[];\n}\n\nexport interface ResetLayoutOperationValue {\n  ids: string[];\n  value: PositionMap;\n  oldValue: PositionMap;\n}\n\nexport interface ContentChangeTypeToOperation<T extends Operation> {\n  type: WorkflowContentChangeType;\n  toOperation: (event: WorkflowContentChangeEvent, ctx: PluginContext) => T | undefined;\n}\n\nexport interface EntityDataType {\n  type: FreeOperationType;\n  toEntityData: (node: FlowNodeEntity, ctx: PluginContext) => EntityData;\n}\n\nexport interface ChangeNodeDataValue {\n  id: string;\n  value: unknown;\n  oldValue: unknown;\n  path: string;\n}\n\nexport interface ChangeLineDataValue {\n  id: string;\n  newValue: unknown;\n  oldValue: unknown;\n}\n\n/**\n * 将node转成json\n */\nexport type NodeToJson = (node: FlowNodeEntity) => FlowNodeJSON;\n/**\n * 将line转成json\n */\nexport type LineToJson = (node: WorkflowLineEntity) => FlowNodeJSON;\n/**\n * 根据节点id获取label\n */\nexport type GetNodeLabelById = (id: string) => string;\n/**\n * 根据节点获取label\n */\nexport type GetNodeLabel = (node: FlowNodeJSON) => string;\n/**\n * 根据分支获取label\n */\nexport type GetBlockLabel = (node: FlowNodeJSON) => string;\n/**\n * 根据节点获取URI\n */\nexport type GetNodeURI = (id: string) => string | any;\n/**\n * 根据连线获取URI\n */\nexport type GetLineURI = (id: string) => string | any;\n\n/**\n * 插件配置\n */\nexport interface FreeHistoryPluginOptions<CTX extends PluginContext = PluginContext> {\n  enable?: boolean;\n  limit?: number;\n  nodeToJSON?: (ctx: CTX) => NodeToJson;\n  getNodeLabelById?: (ctx: CTX) => GetNodeLabelById;\n  getNodeLabel?: (ctx: CTX) => GetNodeLabel;\n  getBlockLabel?: (ctx: CTX) => GetBlockLabel;\n  getNodeURI?: (ctx: CTX) => GetNodeURI;\n  getLineURI?: (ctx: CTX) => GetLineURI;\n  operationMetas?: OperationMeta[];\n  enableChangeNode?: boolean; // default true\n  enableChangeLineData?: boolean; // default true\n  uri?: string | any;\n}\n\nexport interface IHandler<E> {\n  handle: (event: E, ctx: PluginContext) => void | Promise<void>;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\n/* eslint-disable @typescript-eslint/naming-convention */\nimport { injectable, inject } from 'inversify';\nimport { HistoryService, Operation } from '@flowgram.ai/history';\nimport {\n  type WorkflowContentChangeEvent,\n  WorkflowContentChangeType,\n} from '@flowgram.ai/free-layout-core';\nimport { type PluginContext } from '@flowgram.ai/core';\n\nimport { type IHandler } from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\nimport changes from '../changes';\n\n@injectable()\nexport class ChangeContentHandler implements IHandler<WorkflowContentChangeEvent> {\n  @inject(HistoryService)\n  private _historyService: HistoryService;\n\n  @inject(FreeHistoryConfig) private _historyConfig: FreeHistoryConfig;\n\n  handle(event: WorkflowContentChangeEvent, ctx: PluginContext) {\n    if (!this._historyService.undoRedoService.canPush()) {\n      return;\n    }\n    if (\n      !this._historyConfig.enableChangeLineData &&\n      event.type === WorkflowContentChangeType.LINE_DATA_CHANGE\n    ) {\n      return;\n    }\n\n    const change = changes.find((c) => c.type === event.type);\n    if (!change) {\n      return;\n    }\n    const operation: Operation | undefined = change.toOperation(event, ctx);\n    if (!operation) {\n      return;\n    }\n\n    this._historyService.pushOperation(operation, { noApply: true });\n  }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { injectable } from 'inversify';\nimport { type FlowNodeEntity, type FlowNodeJSON } from '@flowgram.ai/document';\nimport { type PluginContext } from '@flowgram.ai/core';\n\nimport {\n  type FreeHistoryPluginOptions,\n  type GetBlockLabel,\n  type GetLineURI,\n  type GetNodeLabel,\n  type GetNodeLabelById,\n  type GetNodeURI,\n  type NodeToJson,\n} from './types';\n\n@injectable()\nexport class FreeHistoryConfig {\n  init(ctx: PluginContext, options: FreeHistoryPluginOptions) {\n    this.enable = !!options?.enable;\n\n    if (options.nodeToJSON) {\n      this.nodeToJSON = options.nodeToJSON(ctx);\n    }\n\n    if (options.getNodeLabelById) {\n      this.getNodeLabelById = options.getNodeLabelById(ctx);\n    }\n\n    if (options.getNodeLabel) {\n      this.getNodeLabel = options.getNodeLabel(ctx);\n    }\n\n    if (options.getBlockLabel) {\n      this.getBlockLabel = options.getBlockLabel(ctx);\n    }\n\n    if (options.getNodeURI) {\n      this.getNodeURI = options.getNodeURI(ctx);\n    }\n\n    if (options.getLineURI) {\n      this.getLineURI = options.getLineURI(ctx);\n    }\n    if (options.enableChangeNode !== undefined) {\n      this.enableChangeNode = options.enableChangeNode;\n    }\n    if (options.enableChangeLineData !== undefined) {\n      this.enableChangeLineData = options.enableChangeLineData;\n    }\n  }\n\n  enableChangeNode = true;\n\n  enableChangeLineData = true;\n\n  enable = false;\n\n  nodeToJSON: NodeToJson = (node: FlowNodeEntity) => node.toJSON();\n\n  getNodeLabelById: GetNodeLabelById = (id: string) => id;\n\n  getNodeLabel: GetNodeLabel = (node: FlowNodeJSON) => node.id;\n\n  getBlockLabel: GetBlockLabel = (node: FlowNodeJSON) => node.id;\n\n  getNodeURI: GetNodeURI = (id: string) => `node:${id}`;\n\n  getLineURI: GetLineURI = (id: string) => `line:${id}`;\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\nimport { type FlowNodeEntity } from '@flowgram.ai/document';\n\nimport {\n  type ContentChangeTypeToOperation,\n  FreeOperationType,\n  type DeleteWorkflowNodeOperation,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const deleteNodeChange: ContentChangeTypeToOperation<DeleteWorkflowNodeOperation> = {\n  type: WorkflowContentChangeType.DELETE_NODE,\n  toOperation: (event, ctx) => {\n    const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n    const node = event.entity as FlowNodeEntity;\n    const json = event.toJSON();\n    const parentID = node.parent?.id;\n\n    return {\n      type: FreeOperationType.deleteNode,\n      value: {\n        node: json,\n        parentID,\n      },\n      uri: config.getNodeURI(node.id),\n    };\n  },\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { type WorkflowLineEntity } from '@flowgram.ai/free-layout-core';\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\n\nimport {\n  type AddOrDeleteLineOperationValue,\n  type ContentChangeTypeToOperation,\n  type DeleteLineOperation,\n  FreeOperationType,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const deleteLineChange: ContentChangeTypeToOperation<DeleteLineOperation> = {\n  type: WorkflowContentChangeType.DELETE_LINE,\n  toOperation: (event, ctx) => {\n    const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n    const line = event.entity as WorkflowLineEntity;\n    const value: AddOrDeleteLineOperationValue = {\n      from: line.info.from,\n      to: line.info.to || '',\n      fromPort: line.info.fromPort || '',\n      toPort: line.info.toPort || '',\n      data: line.info.data,\n      id: line.id,\n    };\n    return {\n      type: FreeOperationType.deleteLine,\n      value,\n      uri: config.getNodeURI(line.id),\n    };\n  },\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { type WorkflowLineEntity } from '@flowgram.ai/free-layout-core';\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\n\nimport {\n  type ChangeLineDataOperation,\n  type ChangeLineDataValue,\n  type ContentChangeTypeToOperation,\n  FreeOperationType,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const changeLineData: ContentChangeTypeToOperation<ChangeLineDataOperation> = {\n  type: WorkflowContentChangeType.LINE_DATA_CHANGE,\n  toOperation: (event, ctx) => {\n    const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n    const line = event.entity as WorkflowLineEntity;\n    const value: ChangeLineDataValue = {\n      id: line.id,\n      oldValue: event.oldValue,\n      newValue: line.lineData,\n    };\n    return {\n      type: FreeOperationType.changeLineData,\n      value,\n      uri: config.getLineURI(line.id),\n    };\n  },\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { WorkflowDocument, type WorkflowNodeJSON } from '@flowgram.ai/free-layout-core';\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\nimport { type FlowNodeEntity } from '@flowgram.ai/document';\n\nimport {\n  type AddWorkflowNodeOperation,\n  type ContentChangeTypeToOperation,\n  FreeOperationType,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const addNodeChange: ContentChangeTypeToOperation<AddWorkflowNodeOperation> = {\n  type: WorkflowContentChangeType.ADD_NODE,\n  toOperation: (event, ctx) => {\n    const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n    const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n    const node = event.entity as FlowNodeEntity;\n    const parentID = node.parent?.id;\n    const json: WorkflowNodeJSON = document.toNodeJSON(node);\n\n    return {\n      type: FreeOperationType.addNode,\n      value: {\n        node: json,\n        parentID,\n      },\n      uri: config.getNodeURI(node.id),\n    };\n  },\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { type WorkflowLineEntity } from '@flowgram.ai/free-layout-core';\nimport { WorkflowContentChangeType } from '@flowgram.ai/free-layout-core';\n\nimport {\n  type AddLineOperation,\n  type AddOrDeleteLineOperationValue,\n  type ContentChangeTypeToOperation,\n  FreeOperationType,\n} from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\n\nexport const addLineChange: ContentChangeTypeToOperation<AddLineOperation> = {\n  type: WorkflowContentChangeType.ADD_LINE,\n  toOperation: (event, ctx) => {\n    const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n    const line = event.entity as WorkflowLineEntity;\n    const value: AddOrDeleteLineOperationValue = {\n      from: line.info.from,\n      to: line.info.to || '',\n      fromPort: line.info.fromPort || '',\n      toPort: line.info.toPort || '',\n      data: line.info.data,\n      id: line.id,\n    };\n    return {\n      type: FreeOperationType.addLine,\n      value,\n      uri: config.getLineURI(line.id),\n    };\n  },\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { deleteNodeChange } from './delete-node-change';\nimport { deleteLineChange } from './delete-line-change';\nimport { changeLineData } from './change-line-data';\nimport { addNodeChange } from './add-node-change';\nimport { addLineChange } from './add-line-change';\n\nexport default [addLineChange, deleteLineChange, addNodeChange, deleteNodeChange, changeLineData];\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { injectable } from 'inversify';\nimport { type OperationContribution, type OperationRegistry } from '@flowgram.ai/history';\n\nimport { operationMetas } from './operation-metas';\n\n@injectable()\nexport class FreeHistoryRegisters implements OperationContribution {\n  registerOperationMeta(operationRegistry: OperationRegistry): void {\n    operationMetas.forEach(operationMeta => {\n      operationRegistry.registerOperationMeta(operationMeta);\n    });\n  }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { type PluginContext } from '@flowgram.ai/core';\nimport { WorkflowResetLayoutService } from '@flowgram.ai/free-layout-core';\nimport { type OperationMeta } from '@flowgram.ai/history';\n\nimport { FreeOperationType, type ResetLayoutOperationValue } from '../types';\nimport { baseOperationMeta } from './base';\n\nexport const resetLayoutOperationMeta: OperationMeta<\n  ResetLayoutOperationValue,\n  PluginContext,\n  void\n> = {\n  ...baseOperationMeta,\n  type: FreeOperationType.resetLayout,\n  inverse: op => ({\n    ...op,\n    value: {\n      ...op.value,\n      value: op.value.oldValue,\n      oldValue: op.value.value,\n    },\n  }),\n  apply: async (operation, ctx: PluginContext) => {\n    const reset = ctx.get<WorkflowResetLayoutService>(WorkflowResetLayoutService);\n    await reset.layoutToPositions(operation.value.ids, operation.value.value);\n  },\n  shouldMerge: () => false,\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { type OperationMeta } from '@flowgram.ai/history';\n\nexport const baseOperationMeta: Partial<OperationMeta> = {\n  shouldMerge: (_op, prev, element) => {\n    if (!prev) {\n      return false;\n    }\n\n    if (\n      // 合并500ms内的操作, 如删除节点会联动删除线条\n      Date.now() - element.getTimestamp() <\n      500\n    ) {\n      return true;\n    }\n    return false;\n  },\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { OperationMeta } from '@flowgram.ai/history';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { MoveChildNodesOperationValue, OperationType } from '@flowgram.ai/document';\nimport { FlowNodeBaseType } from '@flowgram.ai/document';\nimport { PluginContext, TransformData } from '@flowgram.ai/core';\n\nimport { baseOperationMeta } from './base';\n\nexport const moveChildNodesOperationMeta: OperationMeta<\n  MoveChildNodesOperationValue,\n  PluginContext,\n  void\n> = {\n  ...baseOperationMeta,\n  type: OperationType.moveChildNodes,\n  inverse: (op) => ({\n    ...op,\n    value: {\n      ...op.value,\n      fromIndex: op.value.toIndex,\n      toIndex: op.value.fromIndex,\n      fromParentId: op.value.toParentId,\n      toParentId: op.value.fromParentId,\n    },\n  }),\n  apply: (operation, ctx: PluginContext) => {\n    const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n    document.moveChildNodes(operation.value);\n    const fromContainer = document.getNode(operation.value.fromParentId);\n    requestAnimationFrame(() => {\n      if (fromContainer && fromContainer.flowNodeType !== FlowNodeBaseType.ROOT) {\n        const fromContainerTransformData = fromContainer.getData(TransformData);\n        fromContainerTransformData.fireChange();\n      }\n    });\n  },\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { type OperationMeta } from '@flowgram.ai/history';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { type PluginContext, TransformData } from '@flowgram.ai/core';\n\nimport { type DragNodeOperationValue, FreeOperationType } from '../types';\nimport { baseOperationMeta } from './base';\n\nexport const dragNodesOperationMeta: OperationMeta<DragNodeOperationValue, PluginContext, void> = {\n  ...baseOperationMeta,\n  type: FreeOperationType.dragNodes,\n  inverse: (op) => ({\n    ...op,\n    value: {\n      ...op.value,\n      value: op.value.oldValue,\n      oldValue: op.value.value,\n    },\n  }),\n  apply: (operation, ctx) => {\n    operation.value.ids.forEach((id, index) => {\n      const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n      const node = document.getNode(id);\n      if (!node) {\n        return;\n      }\n\n      const transform = node.getData(TransformData);\n      const point = operation.value.value[index];\n      transform.update({\n        position: {\n          x: point.x,\n          y: point.y,\n        },\n      });\n      document.layout.updateAffectedTransform(node);\n    });\n  },\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { type PluginContext } from '@flowgram.ai/core';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { type OperationMeta } from '@flowgram.ai/history';\n\nimport { type AddOrDeleteWorkflowNodeOperationValue, FreeOperationType } from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\nimport { baseOperationMeta } from './base';\n\nexport const deleteNodeOperationMeta: OperationMeta<\n  AddOrDeleteWorkflowNodeOperationValue,\n  PluginContext,\n  void\n> = {\n  ...baseOperationMeta,\n  type: FreeOperationType.deleteNode,\n  inverse: op => ({\n    ...op,\n    type: FreeOperationType.addNode,\n  }),\n  apply: (operation, ctx: PluginContext) => {\n    const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n    const node = document.getNode(operation.value.node.id);\n    if (node) {\n      node.dispose();\n    }\n  },\n  getLabel: (op, ctx) => {\n    const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n    return `Delete Node ${config.getNodeLabel(op.value.node)}`;\n  },\n  getDescription: (op, ctx) => {\n    const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n    let desc = `Delete Node ${config.getNodeLabel(op.value.node)}`;\n    if (op.value.node.meta?.position) {\n      desc += ` at ${op.value.node.meta.position.x},${op.value.node.meta.position.y}`;\n    }\n    return desc;\n  },\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { type OperationMeta } from '@flowgram.ai/history';\nimport { WorkflowDocument } from '@flowgram.ai/free-layout-core';\nimport { type PluginContext } from '@flowgram.ai/core';\n\nimport { type AddOrDeleteLineOperationValue, FreeOperationType } from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\nimport { baseOperationMeta } from './base';\n\nexport const deleteLineOperationMeta: OperationMeta<\n  AddOrDeleteLineOperationValue,\n  PluginContext,\n  void\n> = {\n  ...baseOperationMeta,\n  type: FreeOperationType.deleteLine,\n  inverse: (op) => ({\n    ...op,\n    type: FreeOperationType.addLine,\n  }),\n  apply: (operation, ctx: PluginContext) => {\n    const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n    document.removeNode(operation.value.id);\n  },\n  getLabel: (op, ctx) => 'Delete Line',\n  getDescription: (op, ctx) => {\n    const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n    const { value } = op;\n    if (!value.from || !value.to) {\n      return 'Delete Line';\n    }\n\n    const fromName = config.getNodeLabelById(value.from);\n    const toName = config.getNodeLabelById(value.to);\n    return `Delete Line from ${fromName} to ${toName}`;\n  },\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { type OperationMeta } from '@flowgram.ai/history';\nimport { WorkflowLinesManager } from '@flowgram.ai/free-layout-core';\nimport { type PluginContext } from '@flowgram.ai/core';\n\nimport { FreeOperationType, type ChangeLineDataValue } from '../types';\nimport { baseOperationMeta } from './base';\n\nexport const changeLineDataOperationMeta: OperationMeta<ChangeLineDataValue, PluginContext, void> =\n  {\n    ...baseOperationMeta,\n    type: FreeOperationType.changeLineData,\n    inverse: (op) => ({\n      ...op,\n      value: {\n        ...op.value,\n        newValue: op.value.oldValue,\n        oldValue: op.value.newValue,\n      },\n    }),\n    apply: (op, ctx: PluginContext) => {\n      const linesManager = ctx.get<WorkflowLinesManager>(WorkflowLinesManager);\n      const line = linesManager.getLineById(op.value.id);\n\n      if (!line) {\n        return;\n      }\n\n      line.lineData = op.value.newValue;\n    },\n    shouldMerge: (op, prev, element) => {\n      if (!prev) {\n        return false;\n      }\n\n      if (Date.now() - element.getTimestamp() < 500) {\n        if (\n          op.type === prev.type && // 相同类型\n          op.value.id === prev.value.id // 相同节点\n        ) {\n          return {\n            type: op.type,\n            value: {\n              ...op.value,\n              newValue: op.value.newValue,\n              oldValue: prev.value.oldValue,\n            },\n          };\n        }\n        return true;\n      }\n      return false;\n    },\n  };\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { cloneDeep } from 'lodash-es';\nimport { type OperationMeta } from '@flowgram.ai/history';\nimport { WorkflowDocument, type WorkflowNodeJSON } from '@flowgram.ai/free-layout-core';\nimport { type PluginContext } from '@flowgram.ai/core';\n\nimport { type AddOrDeleteWorkflowNodeOperationValue, FreeOperationType } from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\nimport { baseOperationMeta } from './base';\n\nexport const addNodeOperationMeta: OperationMeta<\n  AddOrDeleteWorkflowNodeOperationValue,\n  PluginContext,\n  void\n> = {\n  ...baseOperationMeta,\n  type: FreeOperationType.addNode,\n  inverse: (op) => ({\n    ...op,\n    type: FreeOperationType.deleteNode,\n  }),\n  apply: async (operation, ctx: PluginContext) => {\n    const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n    await document.createWorkflowNode(\n      cloneDeep(operation.value.node) as WorkflowNodeJSON,\n      false,\n      operation.value.parentID\n    );\n  },\n  getLabel: (op, ctx) => {\n    const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n    return `Create Node ${config.getNodeLabel(op.value.node)}`;\n  },\n  getDescription: (op, ctx) => {\n    const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n    let desc = `Create Node ${config.getNodeLabel(op.value.node)}`;\n    if (op.value.node.meta?.position) {\n      desc += ` at ${op.value.node.meta.position.x},${op.value.node.meta.position.y}`;\n    }\n    return desc;\n  },\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { type PluginContext } from '@flowgram.ai/core';\nimport { WorkflowLinesManager } from '@flowgram.ai/free-layout-core';\nimport { type OperationMeta } from '@flowgram.ai/history';\n\nimport { type AddOrDeleteLineOperationValue, FreeOperationType } from '../types';\nimport { FreeHistoryConfig } from '../free-history-config';\nimport { baseOperationMeta } from './base';\n\nexport const addLineOperationMeta: OperationMeta<\n  AddOrDeleteLineOperationValue,\n  PluginContext,\n  void\n> = {\n  ...baseOperationMeta,\n  type: FreeOperationType.addLine,\n  inverse: op => ({\n    ...op,\n    type: FreeOperationType.deleteLine,\n  }),\n  apply: (operation, ctx: PluginContext) => {\n    const linesManager = ctx.get<WorkflowLinesManager>(WorkflowLinesManager);\n    linesManager.createLine({\n      ...operation.value,\n      key: operation.value.id,\n    });\n  },\n  getLabel: (op, ctx) => 'Create Line',\n  getDescription: (op, ctx) => {\n    const config = ctx.get<FreeHistoryConfig>(FreeHistoryConfig);\n    const { value } = op;\n    if (!value.from || !value.to) {\n      return 'Create Line';\n    }\n\n    const fromName = config.getNodeLabelById(value.from);\n    const toName = config.getNodeLabelById(value.to);\n    return `Create Line from ${fromName} to ${toName}`;\n  },\n};\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { resetLayoutOperationMeta } from './reset-layout';\nimport { moveChildNodesOperationMeta } from './move-child-nodes';\nimport { dragNodesOperationMeta } from './drag-nodes';\nimport { deleteNodeOperationMeta } from './delete-node';\nimport { deleteLineOperationMeta } from './delete-line';\nimport { changeLineDataOperationMeta } from './change-line-data';\nimport { addNodeOperationMeta } from './add-node';\nimport { addLineOperationMeta } from './add-line';\n\nexport const operationMetas = [\n  addLineOperationMeta,\n  deleteLineOperationMeta,\n  addNodeOperationMeta,\n  deleteNodeOperationMeta,\n  resetLayoutOperationMeta,\n  dragNodesOperationMeta,\n  moveChildNodesOperationMeta,\n  changeLineDataOperationMeta,\n];\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\n/* eslint-disable @typescript-eslint/naming-convention */\nimport { injectable, inject } from 'inversify';\nimport { DisposableCollection } from '@flowgram.ai/utils';\nimport { HistoryService } from '@flowgram.ai/history';\nimport {\n  WorkflowDocument,\n  WorkflowResetLayoutService,\n  WorkflowDragService,\n  WorkflowOperationBaseService,\n} from '@flowgram.ai/free-layout-core';\nimport { OperationType } from '@flowgram.ai/document';\nimport { type PluginContext, PositionData } from '@flowgram.ai/core';\n\nimport { DragNodeOperationValue, type FreeHistoryPluginOptions, FreeOperationType } from './types';\nimport { HistoryEntityManager } from './history-entity-manager';\nimport { DragNodesHandler } from './handlers/drag-nodes-handler';\nimport { ChangeContentHandler } from './handlers/change-content-handler';\n\n/**\n * 历史管理\n */\n@injectable()\nexport class FreeHistoryManager {\n  @inject(DragNodesHandler)\n  private _dragNodesHandler: DragNodesHandler;\n\n  @inject(ChangeContentHandler)\n  private _changeContentHandler: ChangeContentHandler;\n\n  @inject(HistoryEntityManager)\n  private _entityManager: HistoryEntityManager;\n\n  private _toDispose: DisposableCollection = new DisposableCollection();\n\n  @inject(WorkflowOperationBaseService)\n  private _operationService: WorkflowOperationBaseService;\n\n  onInit(ctx: PluginContext, opts: FreeHistoryPluginOptions) {\n    const document = ctx.get<WorkflowDocument>(WorkflowDocument);\n    const historyService = ctx.get<HistoryService>(HistoryService);\n    const dragService = ctx.get<WorkflowDragService>(WorkflowDragService);\n\n    const resetLayoutService = ctx.get<WorkflowResetLayoutService>(WorkflowResetLayoutService);\n\n    if (opts?.limit) {\n      historyService.limit(opts.limit);\n    }\n    historyService.context.source = ctx;\n\n    this._toDispose.pushAll([\n      dragService.onNodesDrag(async (event) => {\n        if (event.type !== 'onDragEnd') {\n          return;\n        }\n        this._dragNodesHandler.handle(event);\n      }),\n      document.onNodeCreate(({ node, data }) => {\n        const positionData = node.getData(PositionData);\n        if (positionData) {\n          this._entityManager.addEntityData(positionData);\n        }\n      }),\n      document.onContentChange((event) => {\n        this._changeContentHandler.handle(event, ctx);\n      }),\n      document.onReload((_event) => {\n        historyService.clear();\n      }),\n      resetLayoutService.onResetLayout((event) => {\n        historyService.pushOperation(\n          {\n            type: FreeOperationType.resetLayout,\n            value: {\n              ids: event.nodeIds,\n              value: event.positionMap,\n              oldValue: event.oldPositionMap,\n            },\n          },\n          { noApply: true }\n        );\n      }),\n      this._operationService.onNodeMove(({ node, fromParent, fromIndex, toParent, toIndex }) => {\n        historyService.pushOperation(\n          {\n            type: OperationType.moveChildNodes,\n            value: {\n              fromParentId: fromParent.id,\n              fromIndex,\n              nodeIds: [node.id],\n              toParentId: toParent.id,\n              toIndex,\n            },\n          },\n          {\n            noApply: true,\n          }\n        );\n      }),\n      this._operationService.onNodePostionUpdate((event) => {\n        const value: DragNodeOperationValue = {\n          ids: [event.node.id],\n          value: [event.newPosition],\n          oldValue: [event.oldPosition],\n        };\n        historyService.pushOperation(\n          {\n            type: FreeOperationType.dragNodes,\n            value,\n          },\n          {\n            noApply: true,\n          }\n        );\n      }),\n    ]);\n  }\n\n  dispose() {\n    this._entityManager.dispose();\n    this._toDispose.dispose();\n  }\n}\n","/**\n * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates\n * SPDX-License-Identifier: MIT\n */\n\nimport { useEffect, useState } from 'react';\n\nimport { useService } from '@flowgram.ai/core';\nimport { HistoryService } from '@flowgram.ai/history';\n\ninterface UndoRedo {\n  canUndo: boolean;\n  canRedo: boolean;\n  undo: () => Promise<void>;\n  redo: () => Promise<void>;\n}\n\nexport function useUndoRedo(): UndoRedo {\n  const historyService = useService<HistoryService>(HistoryService);\n  const [canUndo, setCanUndo] = useState(false);\n  const [canRedo, setCanRedo] = useState(false);\n\n  useEffect(() => {\n    const toDispose = historyService.undoRedoService.onChange(() => {\n      setCanUndo(historyService.canUndo());\n      setCanRedo(historyService.canRedo());\n    });\n    return () => {\n      toDispose.dispose();\n    };\n  }, []);\n\n  return {\n    canUndo,\n    canRedo,\n    undo: () => historyService.undo(),\n    redo: () => historyService.redo(),\n  };\n}\n"]}