dishui 0.0.105 → 0.0.108

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.
Files changed (64) hide show
  1. package/dist/.release-verified.json +2 -2
  2. package/dist/components/ChoicePicker/index.js +8 -6
  3. package/dist/components/ChoicePicker/index.js.map +1 -1
  4. package/dist/components/Column/index.d.ts +3 -2
  5. package/dist/components/Column/index.js +5 -17
  6. package/dist/components/Column/index.js.map +1 -1
  7. package/dist/components/ConfirmDialog/index.d.ts +20 -0
  8. package/dist/components/ConfirmDialog/index.js +84 -0
  9. package/dist/components/ConfirmDialog/index.js.map +1 -0
  10. package/dist/components/DateTimeInput/index.js +28 -26
  11. package/dist/components/DateTimeInput/index.js.map +1 -1
  12. package/dist/components/Input/index.js +1 -1
  13. package/dist/components/Input/index.js.map +1 -1
  14. package/dist/components/MultipleChoice/index.js +2 -1
  15. package/dist/components/MultipleChoice/index.js.map +1 -1
  16. package/dist/components/Row/index.d.ts +3 -2
  17. package/dist/components/Row/index.js +5 -17
  18. package/dist/components/Row/index.js.map +1 -1
  19. package/dist/components/Tab/index.js +80 -0
  20. package/dist/components/Tab/index.js.map +1 -0
  21. package/dist/components/Tabs/index.js +28 -33
  22. package/dist/components/Tabs/index.js.map +1 -1
  23. package/dist/components/Tabs/tabNavigation.d.ts +2 -0
  24. package/dist/components/Tabs/tabNavigation.js +14 -0
  25. package/dist/components/Tabs/tabNavigation.js.map +1 -0
  26. package/dist/components/pro/CodeEditor/editors/MarkdownEditor.d.ts +1 -1
  27. package/dist/components/pro/CodeEditor/editors/MarkdownEditor.js +25 -26
  28. package/dist/components/pro/CodeEditor/editors/MarkdownEditor.js.map +1 -1
  29. package/dist/components/pro/FileExplorer/Breadcrumb.js +8 -11
  30. package/dist/components/pro/FileExplorer/Breadcrumb.js.map +1 -1
  31. package/dist/components/pro/Flow/Flow.js +184 -182
  32. package/dist/components/pro/Flow/Flow.js.map +1 -1
  33. package/dist/components/pro/Flow/archify/convert.js +26 -26
  34. package/dist/components/pro/Flow/archify/convert.js.map +1 -1
  35. package/dist/components/pro/Flow/hooks/useLayoutActions.js +13 -11
  36. package/dist/components/pro/Flow/hooks/useLayoutActions.js.map +1 -1
  37. package/dist/components/pro/RichTextEditor/AIRewrite.d.ts +1 -0
  38. package/dist/components/pro/RichTextEditor/AIRewrite.js +109 -88
  39. package/dist/components/pro/RichTextEditor/AIRewrite.js.map +1 -1
  40. package/dist/components/pro/RichTextEditor/BubbleToolbar.js +73 -83
  41. package/dist/components/pro/RichTextEditor/BubbleToolbar.js.map +1 -1
  42. package/dist/components/pro/RichTextEditor/RichTextEditor.js +133 -132
  43. package/dist/components/pro/RichTextEditor/RichTextEditor.js.map +1 -1
  44. package/dist/components/pro/RichTextEditor/Toolbar/ColorPicker.d.ts +2 -0
  45. package/dist/components/pro/RichTextEditor/Toolbar/ColorPicker.js +73 -49
  46. package/dist/components/pro/RichTextEditor/Toolbar/ColorPicker.js.map +1 -1
  47. package/dist/components/pro/RichTextEditor/Toolbar/SelectDropdown.d.ts +1 -0
  48. package/dist/components/pro/RichTextEditor/Toolbar/SelectDropdown.js +12 -14
  49. package/dist/components/pro/RichTextEditor/Toolbar/SelectDropdown.js.map +1 -1
  50. package/dist/components/pro/RichTextEditor/extensions/CodeBlockView.js +113 -113
  51. package/dist/components/pro/RichTextEditor/extensions/CodeBlockView.js.map +1 -1
  52. package/dist/components/pro/RichTextEditor/types.d.ts +2 -0
  53. package/dist/components/pro/RichTextEditor/types.js.map +1 -1
  54. package/dist/css.d.ts +1 -0
  55. package/dist/dishui.css +1 -1
  56. package/dist/index-nostyled.d.ts +2 -0
  57. package/dist/index.d.ts +4 -0
  58. package/dist/index.js +113 -111
  59. package/dist/layouts/Sidebar.js +201 -107
  60. package/dist/layouts/Sidebar.js.map +1 -1
  61. package/dist/utils/flexLayout.d.ts +5 -0
  62. package/dist/utils/flexLayout.js +19 -0
  63. package/dist/utils/flexLayout.js.map +1 -0
  64. package/package.json +63 -57
@@ -1 +1 @@
1
- {"version":3,"file":"convert.js","names":[],"sources":["../../../../../src/components/pro/Flow/archify/convert.ts"],"sourcesContent":["/**\n * Convert an Archify spec into a native Flow `FlowDocument`.\n *\n * One converter per diagram type reproduces Archify's fixed layout geometry\n * (constants copied from the reference renderers) so the imported diagram\n * matches the reference artifact, then emits editable Flow nodes/edges/lines.\n *\n * When `meta.animation === \"trace\"`, edges are marked `animated` so the Flow\n * presentation / preview mode plays the traveling gradient pulse.\n */\n\nimport type { FlowDocument, FlowNode, FlowEdge, FlowLine } from '../types';\nimport { ROOT_CANVAS_ID } from '../constants';\nimport type {\n ArchifySpec,\n ArchifyArchitectureSpec,\n ArchifyWorkflowSpec,\n ArchifySequenceSpec,\n ArchifyDataflowSpec,\n ArchifyLifecycleSpec,\n} from './spec';\nimport {\n ARCHIFY_LANE_STROKE,\n ARCHIFY_TEXT_MUTED,\n componentStyle,\n stateStyle,\n variantEdgeStyle,\n messageEdgeStyle,\n} from './palette';\nimport { card, frame, edge, sideHandle, uid } from './build';\n\nfunction isTrace(spec: ArchifySpec): boolean {\n return spec.meta?.animation === 'trace';\n}\n\n/* ========================================================================== */\n/* Architecture */\n/* ========================================================================== */\n\nconst ARCH_GRID = { origin: [40, 80], cols: 4, gapX: 30, gapY: 40, cellW: 130, cellH: 64 };\n\nfunction convertArchitecture(spec: ArchifyArchitectureSpec): FlowDocument {\n const trace = isTrace(spec);\n const grid = { ...ARCH_GRID, ...spec.layout };\n const nodes: FlowNode[] = [];\n const edges: FlowEdge[] = [];\n\n const rect = new Map<string, { x: number; y: number; w: number; h: number }>();\n\n for (const c of spec.components) {\n let x: number;\n let y: number;\n if (Array.isArray(c.pos)) {\n [x, y] = c.pos;\n } else if (Number.isInteger(c.row) && Number.isInteger(c.col)) {\n const stepX = grid.cellW + grid.gapX;\n const stepY = grid.cellH + grid.gapY;\n x = grid.origin[0] + (c.col ?? 0) * stepX;\n y = grid.origin[1] + (c.row ?? 0) * stepY;\n } else {\n x = grid.origin[0];\n y = grid.origin[1];\n }\n const w = c.size?.[0] ?? grid.cellW;\n const h = c.size?.[1] ?? grid.cellH;\n rect.set(c.id, { x, y, w, h });\n const style = componentStyle(c.type);\n nodes.push(\n card({\n id: c.id,\n x,\n y,\n width: w,\n height: h,\n label: c.label,\n sublabel: c.sublabel,\n tag: c.tag,\n fill: style.fill,\n stroke: style.stroke,\n text: style.text,\n sub: style.sub,\n }),\n );\n }\n\n // Boundaries wrap their member components with padding, rendered behind.\n for (const [i, b] of (spec.boundaries ?? []).entries()) {\n const members = b.wraps.map((id) => rect.get(id)).filter(Boolean) as Array<{\n x: number;\n y: number;\n w: number;\n h: number;\n }>;\n if (members.length === 0) continue;\n const pad = b.pad ?? 26;\n const minX = Math.min(...members.map((m) => m.x)) - pad;\n const minY = Math.min(...members.map((m) => m.y)) - pad - 14;\n const maxX = Math.max(...members.map((m) => m.x + m.w)) + pad;\n const maxY = Math.max(...members.map((m) => m.y + m.h)) + pad;\n nodes.push(\n frame({\n id: `boundary_${i}_${uid('b')}`,\n x: minX,\n y: minY,\n width: maxX - minX,\n height: maxY - minY,\n label: b.label,\n stroke: b.kind === 'security-group' ? '#fb7185' : ARCHIFY_LANE_STROKE,\n borderStyle: 'dashed',\n labelColor: b.kind === 'security-group' ? '#fb7185' : ARCHIFY_TEXT_MUTED,\n zIndex: -10 + i,\n }),\n );\n }\n\n for (const conn of spec.connections ?? []) {\n const style = variantEdgeStyle(conn.variant);\n edges.push(\n edge({\n id: conn.id,\n source: conn.from,\n target: conn.to,\n sourceHandle: sideHandle(conn.fromSide),\n targetHandle: sideHandle(conn.toSide),\n label: conn.label,\n color: style.color,\n width: conn.width ?? style.width,\n lineStyle: style.lineStyle,\n animated: trace,\n waypoints: conn.via?.map(([x, y]) => ({ x, y })),\n }),\n );\n }\n\n return wrap(nodes, edges, [], spec.meta.title);\n}\n\n/* ========================================================================== */\n/* Workflow */\n/* ========================================================================== */\n\nconst WF = {\n laneX: 40,\n laneY: 52,\n laneW: 640,\n laneH: 104,\n laneGap: 20,\n laneTitleH: 30,\n colXs: [88, 220, 300, 430, 500, 625],\n nodeW: 92,\n nodeH: 52,\n};\n\nfunction convertWorkflow(spec: ArchifyWorkflowSpec): FlowDocument {\n const trace = isTrace(spec);\n const nodes: FlowNode[] = [];\n const edges: FlowEdge[] = [];\n\n const laneIndex = new Map(spec.lanes.map((l, i) => [l.id, i]));\n const laneTop = (id: string) =>\n WF.laneY + (laneIndex.get(id) ?? 0) * (WF.laneH + WF.laneGap);\n\n // Lane frames (behind everything).\n for (const lane of spec.lanes) {\n const top = laneTop(lane.id);\n nodes.push(\n frame({\n id: `lane_${lane.id}`,\n x: WF.laneX,\n y: top,\n width: WF.laneW,\n height: WF.laneH,\n label: lane.label,\n stroke: lane.variant === 'exception' ? '#fb7185' : ARCHIFY_LANE_STROKE,\n labelColor: lane.variant === 'exception' ? '#fb7185' : ARCHIFY_TEXT_MUTED,\n zIndex: -20,\n }),\n );\n }\n\n // Phase bands (thin frames spanning columns, drawn just above lanes).\n for (const [i, phase] of (spec.phases ?? []).entries()) {\n const x0 = WF.colXs[phase.fromCol] - WF.nodeW / 2 - 12;\n const x1 = WF.colXs[phase.toCol] + WF.nodeW / 2 + 12;\n nodes.push(\n frame({\n id: `phase_${phase.id}`,\n x: x0,\n y: WF.laneY - 34,\n width: x1 - x0,\n height: 26,\n label: phase.label,\n stroke: variantEdgeStyle(phase.variant).color,\n labelColor: ARCHIFY_TEXT_MUTED,\n borderStyle: 'none',\n zIndex: -15 + i,\n }),\n );\n }\n\n // Workflow groups (nested emphasis frames inside a lane).\n for (const [i, g] of (spec.groups ?? []).entries()) {\n const top = laneTop(g.lane);\n const x0 = WF.colXs[g.fromCol] - WF.nodeW / 2 - 8;\n const x1 = WF.colXs[g.toCol] + WF.nodeW / 2 + 8;\n nodes.push(\n frame({\n id: `wfgroup_${g.id}`,\n x: x0,\n y: top + WF.laneTitleH - 6,\n width: x1 - x0,\n height: WF.laneH - WF.laneTitleH,\n label: g.label,\n stroke: variantEdgeStyle(g.variant).color,\n labelColor: ARCHIFY_TEXT_MUTED,\n borderStyle: 'dashed',\n zIndex: -12 + i,\n }),\n );\n }\n\n for (const n of spec.nodes) {\n const width = n.width ?? WF.nodeW;\n const height = n.height ?? (n.tag ? 68 : WF.nodeH);\n const cx = WF.colXs[n.col] ?? WF.colXs[WF.colXs.length - 1];\n const contentH = WF.laneH - WF.laneTitleH;\n const y = laneTop(n.lane) + WF.laneTitleH + (contentH - height) / 2 + (n.yOffset ?? 0);\n const style = componentStyle(n.type);\n nodes.push(\n card({\n id: n.id,\n x: cx - width / 2,\n y,\n width,\n height,\n label: n.label,\n sublabel: n.sublabel,\n tag: n.tag,\n fill: style.fill,\n stroke: style.stroke,\n text: style.text,\n sub: style.sub,\n fontSize: 12,\n }),\n );\n }\n\n const mainPath = new Set<string>();\n const mp = spec.mainPath ?? [];\n for (let i = 0; i < mp.length - 1; i++) mainPath.add(`${mp[i]}->${mp[i + 1]}`);\n\n for (const e of spec.edges) {\n const onMain = mainPath.has(`${e.from}->${e.to}`);\n const style = variantEdgeStyle(e.variant ?? (onMain ? 'emphasis' : 'default'));\n edges.push(\n edge({\n id: e.id,\n source: e.from,\n target: e.to,\n sourceHandle: sideHandle(e.fromSide),\n targetHandle: sideHandle(e.toSide),\n label: e.label,\n color: e.role === 'error' ? '#fb7185' : style.color,\n width: e.width ?? style.width,\n lineStyle: e.role === 'error' ? 'dashed' : style.lineStyle,\n animated: trace && onMain,\n waypoints: e.via?.map(([x, y]) => ({ x, y })),\n }),\n );\n }\n\n return wrap(nodes, edges, [], spec.meta.title);\n}\n\n/* ========================================================================== */\n/* Sequence */\n/* ========================================================================== */\n\nfunction convertSequence(spec: ArchifySequenceSpec): FlowDocument {\n const nodes: FlowNode[] = [];\n const edges: FlowEdge[] = [];\n const lines: FlowLine[] = [];\n\n const viewBox = spec.meta.viewBox ?? [920, 760];\n const sideMargin = 62;\n const participantW = 86;\n const colGap = 108;\n const topY = 72;\n const participantH = 54;\n const lifelineTop = 142;\n const lifelineBottom = viewBox[1] - 65;\n\n const cx = (i: number) => sideMargin + i * colGap;\n const partX = new Map<string, number>();\n\n spec.participants.forEach((p, i) => {\n const x = cx(i);\n partX.set(p.id, x);\n const style = componentStyle(p.type);\n nodes.push(\n card({\n id: p.id,\n x: x - participantW / 2,\n y: topY,\n width: participantW,\n height: participantH,\n label: p.label,\n sublabel: p.sublabel,\n fill: style.fill,\n stroke: style.stroke,\n text: style.text,\n sub: style.sub,\n fontSize: 11,\n zIndex: 5,\n }),\n );\n // Lifeline (dashed vertical guide beneath each participant).\n lines.push({\n id: `lifeline_${p.id}`,\n type: 'straight',\n points: [\n { x, y: lifelineTop },\n { x, y: lifelineBottom },\n ],\n strokeColor: ARCHIFY_LANE_STROKE,\n strokeWidth: 1,\n lineStyle: 'dashed',\n markerEnd: 'none',\n zIndex: -5,\n });\n });\n\n // Segment frames (labelled bands over ranges of the timeline).\n for (const [i, seg] of (spec.segments ?? []).entries()) {\n nodes.push(\n frame({\n id: `segment_${i}`,\n x: 48,\n y: seg.from,\n width: viewBox[0] - 96,\n height: seg.to - seg.from,\n label: seg.label,\n stroke: ARCHIFY_LANE_STROKE,\n labelColor: ARCHIFY_TEXT_MUTED,\n borderStyle: 'dashed',\n zIndex: -10,\n }),\n );\n }\n\n // Activation bars (thin vertical rects on a participant lifeline).\n for (const [i, act] of (spec.activations ?? []).entries()) {\n const x = partX.get(act.participant);\n if (x === undefined) continue;\n const style = componentStyle(act.type ?? 'backend');\n nodes.push({\n id: `activation_${i}_${act.participant}`,\n type: 'shapeRect',\n position: { x: x - 5, y: act.from },\n width: 10,\n height: Math.max(6, act.to - act.from),\n zIndex: 1,\n data: {\n label: '',\n fill: style.fill,\n stroke: style.stroke,\n strokeWidth: 1,\n color: style.text,\n fontSize: 10,\n borderStyle: 'solid',\n attributes: [],\n },\n });\n }\n\n // Messages become horizontal arrow lines at their y with a label above.\n for (const m of spec.messages) {\n const fromX = partX.get(m.from);\n const toX = partX.get(m.to);\n if (fromX === undefined || toX === undefined) continue;\n const dir = toX > fromX ? 1 : -1;\n const start = fromX + dir * 7;\n const end = toX - dir * 7;\n const style = messageEdgeStyle(m.variant);\n lines.push({\n id: m.id ?? uid('msg'),\n type: 'arrow',\n points: [\n { x: start, y: m.y },\n { x: end, y: m.y },\n ],\n strokeColor: style.color,\n strokeWidth: style.width,\n lineStyle: style.lineStyle,\n markerEnd: m.variant === 'return' ? 'arrow' : 'arrowclosed',\n zIndex: 3,\n });\n // Label as a tiny transparent text node centered above the arrow.\n nodes.push({\n id: `mlabel_${m.id ?? uid('m')}`,\n type: 'textLabel',\n position: { x: (start + end) / 2 - 70, y: m.y - 22 },\n width: 140,\n height: 16,\n zIndex: 4,\n data: {\n label: m.label,\n fill: 'transparent',\n stroke: 'transparent',\n strokeWidth: 0,\n color: style.color,\n labelColor: style.color,\n fontSize: 11,\n attributes: [],\n },\n });\n }\n\n return wrap(nodes, edges, lines, spec.meta.title);\n}\n\n/* ========================================================================== */\n/* Dataflow */\n/* ========================================================================== */\n\nconst DF = {\n stageY: 46,\n stageH: 36,\n stageBottomPad: 74,\n leftX: 100,\n colGap: 215,\n stageW: 168,\n nodeW: 112,\n nodeH: 58,\n rowYs: [128, 242, 356, 470, 584],\n};\n\nfunction convertDataflow(spec: ArchifyDataflowSpec): FlowDocument {\n const trace = isTrace(spec);\n const nodes: FlowNode[] = [];\n const edges: FlowEdge[] = [];\n\n const viewBox = spec.meta.viewBox ?? [940, 720];\n const stageX = (i: number) => DF.leftX + i * DF.colGap;\n\n // Stage frames (tall vertical bands).\n for (const [i, stage] of spec.stages.entries()) {\n nodes.push(\n frame({\n id: `stage_${i}`,\n x: stageX(i) - DF.stageW / 2,\n y: DF.stageY,\n width: DF.stageW,\n height: viewBox[1] - DF.stageY - DF.stageBottomPad,\n label: stage.label,\n stroke: ARCHIFY_LANE_STROKE,\n labelColor: ARCHIFY_TEXT_MUTED,\n borderStyle: 'dashed',\n zIndex: -10,\n }),\n );\n }\n\n for (const n of spec.nodes) {\n const width = n.width ?? DF.nodeW;\n const height = n.height ?? DF.nodeH;\n const cx = stageX(n.stage);\n const y = (DF.rowYs[n.row] ?? DF.rowYs[DF.rowYs.length - 1]) + (n.yOffset ?? 0);\n const style = componentStyle(n.type);\n nodes.push(\n card({\n id: n.id,\n x: cx - width / 2,\n y,\n width,\n height,\n label: n.label,\n sublabel: n.sublabel,\n tag: n.tag,\n fill: style.fill,\n stroke: style.stroke,\n text: style.text,\n sub: style.sub,\n fontSize: 12,\n }),\n );\n }\n\n for (const f of spec.flows) {\n const style = variantEdgeStyle(f.variant);\n edges.push(\n edge({\n id: f.id,\n source: f.from,\n target: f.to,\n sourceHandle: sideHandle(f.fromSide),\n targetHandle: sideHandle(f.toSide),\n label: f.label,\n color: style.color,\n width: f.width ?? style.width,\n lineStyle: style.lineStyle,\n animated: trace && f.variant === 'emphasis',\n waypoints: f.via?.map(([x, y]) => ({ x, y })),\n }),\n );\n }\n\n return wrap(nodes, edges, [], spec.meta.title);\n}\n\n/* ========================================================================== */\n/* Lifecycle */\n/* ========================================================================== */\n\nconst LC = {\n phaseY: 126,\n eventY: 278,\n outcomeY: 450,\n phaseW: 118,\n phaseH: 62,\n eventW: 126,\n eventH: 58,\n outcomeW: 118,\n outcomeH: 58,\n phaseXs: [94, 248, 402, 556, 710],\n eventXs: [402, 556, 710],\n outcomeXs: [402, 556, 710],\n};\n\nfunction lifecycleBand(lane: string): 'phase' | 'event' | 'outcome' {\n if (lane === 'main') return 'phase';\n if (lane === 'terminal') return 'outcome';\n return 'event';\n}\n\nfunction convertLifecycle(spec: ArchifyLifecycleSpec): FlowDocument {\n const trace = isTrace(spec);\n const nodes: FlowNode[] = [];\n const edges: FlowEdge[] = [];\n\n const viewBox = spec.meta.viewBox ?? [980, 660];\n\n // Band frames give the three horizontal groupings some structure.\n const laneLabel = new Map(spec.lanes.map((l) => [l.id, l.label]));\n const bandRows: Array<{ band: 'phase' | 'event' | 'outcome'; y: number; h: number; label: string }> = [\n { band: 'phase', y: LC.phaseY - 26, h: LC.phaseH + 40, label: laneLabel.get('main') ?? 'Lifecycle phases' },\n { band: 'event', y: LC.eventY - 26, h: LC.eventH + 40, label: 'Interruptions + Recovery' },\n { band: 'outcome', y: LC.outcomeY - 26, h: LC.outcomeH + 40, label: laneLabel.get('terminal') ?? 'Terminal exits' },\n ];\n for (const [i, b] of bandRows.entries()) {\n nodes.push(\n frame({\n id: `band_${b.band}`,\n x: 40,\n y: b.y,\n width: viewBox[0] - 80,\n height: b.h,\n label: `0${i + 1} / ${b.label}`,\n stroke: ARCHIFY_LANE_STROKE,\n labelColor: ARCHIFY_TEXT_MUTED,\n borderStyle: 'dashed',\n zIndex: -10,\n }),\n );\n }\n\n for (const s of spec.states) {\n const band = lifecycleBand(s.lane);\n const isPhase = band === 'phase';\n const isOutcome = band === 'outcome';\n const width = s.width ?? (isPhase ? LC.phaseW : isOutcome ? LC.outcomeW : LC.eventW);\n const height = s.height ?? (isPhase ? LC.phaseH : isOutcome ? LC.outcomeH : LC.eventH);\n const xs = isPhase ? LC.phaseXs : isOutcome ? LC.outcomeXs : LC.eventXs;\n const cx = xs[s.col] ?? xs[xs.length - 1];\n const y = (isPhase ? LC.phaseY : isOutcome ? LC.outcomeY : LC.eventY) + (s.yOffset ?? 0);\n const style = stateStyle(s.type);\n nodes.push(\n card({\n id: s.id,\n x: cx - width / 2,\n y,\n width,\n height,\n label: s.label,\n sublabel: s.sublabel,\n tag: s.tag ?? s.step,\n fill: style.fill,\n stroke: style.stroke,\n text: style.text,\n sub: style.sub,\n fontSize: 12,\n }),\n );\n }\n\n // Order states along the main lane to build the primary rail. Archify draws\n // this rail decoratively (not as explicit transitions), so synthesize edges\n // between consecutive phase states, connecting right-to-left across columns.\n const mainStates = spec.states\n .filter((s) => s.lane === 'main')\n .sort((a, b) => a.col - b.col);\n const explicitPairs = new Set(spec.transitions.map((t) => `${t.from}->${t.to}`));\n for (let i = 0; i < mainStates.length - 1; i++) {\n const from = mainStates[i];\n const to = mainStates[i + 1];\n // Skip if the author already provided this exact transition.\n if (explicitPairs.has(`${from.id}->${to.id}`)) continue;\n edges.push(\n edge({\n id: `mainrail_${from.id}_${to.id}`,\n source: from.id,\n target: to.id,\n sourceHandle: sideHandle('right'),\n targetHandle: sideHandle('left'),\n label: undefined,\n color: variantEdgeStyle('emphasis').color,\n width: 2.2,\n lineStyle: 'solid',\n animated: trace,\n }),\n );\n }\n\n const mainPairs = new Set<string>();\n for (let i = 0; i < mainStates.length - 1; i++) {\n mainPairs.add(`${mainStates[i].id}->${mainStates[i + 1].id}`);\n }\n\n for (const t of spec.transitions) {\n const style = variantEdgeStyle(t.variant);\n const onMain = mainPairs.has(`${t.from}->${t.to}`);\n edges.push(\n edge({\n id: t.id,\n source: t.from,\n target: t.to,\n sourceHandle: sideHandle(t.fromSide),\n targetHandle: sideHandle(t.toSide),\n label: t.label,\n color: style.color,\n width: t.width ?? style.width,\n lineStyle: style.lineStyle,\n animated: trace && onMain,\n waypoints: t.via?.map(([x, y]) => ({ x, y })),\n }),\n );\n }\n\n return wrap(nodes, edges, [], spec.meta.title);\n}\n\n/* ========================================================================== */\n\nfunction wrap(\n nodes: FlowNode[],\n edges: FlowEdge[],\n lines: FlowLine[],\n title?: string,\n): FlowDocument {\n return {\n canvases: {\n [ROOT_CANVAS_ID]: { nodes, edges, lines },\n },\n stack: [ROOT_CANVAS_ID],\n title,\n };\n}\n\n/** Convert any supported Archify spec into a Flow document. */\nexport function archifyToFlowDocument(spec: ArchifySpec): FlowDocument {\n switch (spec.diagram_type) {\n case 'architecture':\n return convertArchitecture(spec);\n case 'workflow':\n return convertWorkflow(spec);\n case 'sequence':\n return convertSequence(spec);\n case 'dataflow':\n return convertDataflow(spec);\n case 'lifecycle':\n return convertLifecycle(spec);\n default:\n return wrap([], [], []);\n }\n}\n"],"mappings":";;;;AA+BA,SAAS,EAAQ,GAA4B;CAC3C,OAAO,EAAK,MAAM,cAAc;AAClC;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C,GAAG,IAAI,EAAW,IAAI,EAAE,CAAC,IAAI;CAG9D,KAAK,IAAM,KAAK,EAAK,aAAa;EAChC,IAAM,IAAQ,EAAiB,EAAE,OAAO,GAClC,IAAS,EAAU,IAAI,GAAG,EAAE,KAAK,IAAI,EAAE,IAAI;EACjD,EAAM,KACJ,EAAK;GACH,IAAI,EAAE;GACN,QAAQ,EAAE;GACV,QAAQ,EAAE;GACV,cAAc,EAAW,EAAE,QAAQ;GACnC,cAAc,EAAW,EAAE,MAAM;GACjC,OAAO,EAAE;GACT,OAAO,EAAM;GACb,OAAO,EAAE,SAAS,EAAM;GACxB,WAAW,EAAM;GACjB,UAAU,KAAS;GACnB,WAAW,EAAE,KAAK,KAAK,CAAC,GAAG,QAAQ;IAAE;IAAG;GAAE,EAAE;EAC9C,CAAC,CACH;CACF;CAEA,OAAO,EAAK,GAAO,GAAO,CAAC,GAAG,EAAK,KAAK,KAAK;AAC/C;AAIA,SAAS,EACP,GACA,GACA,GACA,GACc;CACd,OAAO;EACL,UAAU,GACP,IAAiB;GAAE;GAAO;GAAO;EAAM,EAC1C;EACA,OAAO,CAAC,CAAc;EACtB;CACF;AACF;AAGA,SAAgB,EAAsB,GAAiC;CACrE,QAAQ,EAAK,cAAb;EACE,KAAK,gBACH,OAAO,EAAoB,CAAI;EACjC,KAAK,YACH,OAAO,EAAgB,CAAI;EAC7B,KAAK,YACH,OAAO,EAAgB,CAAI;EAC7B,KAAK,YACH,OAAO,EAAgB,CAAI;EAC7B,KAAK,aACH,OAAO,EAAiB,CAAI;EAC9B,SACE,OAAO,EAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;CAC1B;AACF"}
1
+ {"version":3,"file":"convert.js","names":[],"sources":["../../../../../src/components/pro/Flow/archify/convert.ts"],"sourcesContent":["/**\n * Convert an Archify spec into a native Flow `FlowDocument`.\n *\n * One converter per diagram type reproduces Archify's fixed layout geometry\n * (constants copied from the reference renderers) so the imported diagram\n * matches the reference artifact, then emits editable Flow nodes/edges/lines.\n *\n * When `meta.animation === \"trace\"`, edges are marked `animated` so the Flow\n * presentation / preview mode plays the traveling gradient pulse.\n */\n\nimport type { FlowDocument, FlowNode, FlowEdge, FlowLine } from '../types';\nimport { ROOT_CANVAS_ID } from '../constants';\nimport type {\n ArchifySpec,\n ArchifyArchitectureSpec,\n ArchifyWorkflowSpec,\n ArchifySequenceSpec,\n ArchifyDataflowSpec,\n ArchifyLifecycleSpec,\n} from './spec';\nimport {\n ARCHIFY_LANE_STROKE,\n ARCHIFY_TEXT_MUTED,\n componentStyle,\n stateStyle,\n variantEdgeStyle,\n messageEdgeStyle,\n} from './palette';\nimport { card, frame, edge, sideHandle, uid } from './build';\n\nfunction isTrace(spec: ArchifySpec): boolean {\n return spec.meta?.animation === 'trace';\n}\n\n/* ========================================================================== */\n/* Architecture */\n/* ========================================================================== */\n\nconst ARCH_GRID = { origin: [40, 80], cols: 4, gapX: 30, gapY: 40, cellW: 130, cellH: 64 };\n\nfunction convertArchitecture(spec: ArchifyArchitectureSpec): FlowDocument {\n const trace = isTrace(spec);\n const grid = { ...ARCH_GRID, ...spec.layout };\n const nodes: FlowNode[] = [];\n const edges: FlowEdge[] = [];\n\n const rect = new Map<string, { x: number; y: number; w: number; h: number }>();\n\n for (const c of spec.components) {\n let x: number;\n let y: number;\n if (Array.isArray(c.pos)) {\n [x, y] = c.pos;\n } else if (Number.isInteger(c.row) && Number.isInteger(c.col)) {\n const stepX = grid.cellW + grid.gapX;\n const stepY = grid.cellH + grid.gapY;\n x = grid.origin[0] + (c.col ?? 0) * stepX;\n y = grid.origin[1] + (c.row ?? 0) * stepY;\n } else {\n x = grid.origin[0];\n y = grid.origin[1];\n }\n const w = c.size?.[0] ?? grid.cellW;\n const h = c.size?.[1] ?? grid.cellH;\n rect.set(c.id, { x, y, w, h });\n const style = componentStyle(c.type);\n nodes.push(\n card({\n id: c.id,\n x,\n y,\n width: w,\n height: h,\n label: c.label,\n sublabel: c.sublabel,\n tag: c.tag,\n fill: style.fill,\n stroke: style.stroke,\n text: style.text,\n sub: style.sub,\n }),\n );\n }\n\n // Boundaries wrap their member components with padding, rendered behind.\n for (const [i, b] of (spec.boundaries ?? []).entries()) {\n const members = b.wraps.map((id) => rect.get(id)).filter(Boolean) as Array<{\n x: number;\n y: number;\n w: number;\n h: number;\n }>;\n if (members.length === 0) continue;\n const pad = b.pad ?? 26;\n const minX = Math.min(...members.map((m) => m.x)) - pad;\n const minY = Math.min(...members.map((m) => m.y)) - pad - 14;\n const maxX = Math.max(...members.map((m) => m.x + m.w)) + pad;\n const maxY = Math.max(...members.map((m) => m.y + m.h)) + pad;\n nodes.push(\n frame({\n id: `boundary_${i}_${uid('b')}`,\n x: minX,\n y: minY,\n width: maxX - minX,\n height: maxY - minY,\n label: b.label,\n stroke: b.kind === 'security-group' ? '#fb7185' : ARCHIFY_LANE_STROKE,\n borderStyle: 'dashed',\n labelColor: b.kind === 'security-group' ? '#fb7185' : ARCHIFY_TEXT_MUTED,\n zIndex: -10 + i,\n }),\n );\n }\n\n for (const conn of spec.connections ?? []) {\n const style = variantEdgeStyle(conn.variant);\n edges.push(\n edge({\n id: conn.id,\n source: conn.from,\n target: conn.to,\n sourceHandle: sideHandle(conn.fromSide),\n targetHandle: sideHandle(conn.toSide),\n label: conn.label,\n color: style.color,\n width: conn.width ?? style.width,\n lineStyle: style.lineStyle,\n animated: trace,\n waypoints: conn.via?.map(([x, y]) => ({ x, y })),\n }),\n );\n }\n\n return wrap(nodes, edges, [], spec.meta.title);\n}\n\n/* ========================================================================== */\n/* Workflow */\n/* ========================================================================== */\n\nconst WF = {\n laneX: 40,\n laneY: 52,\n laneW: 640,\n laneH: 104,\n laneGap: 20,\n laneTitleH: 30,\n colXs: [88, 220, 300, 430, 500, 625],\n nodeW: 92,\n nodeH: 52,\n};\n\nfunction convertWorkflow(spec: ArchifyWorkflowSpec): FlowDocument {\n const trace = isTrace(spec);\n const nodes: FlowNode[] = [];\n const edges: FlowEdge[] = [];\n\n const laneIndex = new Map(spec.lanes.map((l, i) => [l.id, i]));\n const laneTop = (id: string) =>\n WF.laneY + (laneIndex.get(id) ?? 0) * (WF.laneH + WF.laneGap);\n\n // Lane frames (behind everything).\n for (const lane of spec.lanes) {\n const top = laneTop(lane.id);\n nodes.push(\n frame({\n id: `lane_${lane.id}`,\n x: WF.laneX,\n y: top,\n width: WF.laneW,\n height: WF.laneH,\n label: lane.label,\n stroke: lane.variant === 'exception' ? '#fb7185' : ARCHIFY_LANE_STROKE,\n labelColor: lane.variant === 'exception' ? '#fb7185' : ARCHIFY_TEXT_MUTED,\n zIndex: -20,\n }),\n );\n }\n\n // Phase bands (thin frames spanning columns, drawn just above lanes).\n for (const [i, phase] of (spec.phases ?? []).entries()) {\n const x0 = WF.colXs[phase.fromCol] - WF.nodeW / 2 - 12;\n const x1 = WF.colXs[phase.toCol] + WF.nodeW / 2 + 12;\n nodes.push(\n frame({\n id: `phase_${phase.id}`,\n x: x0,\n y: WF.laneY - 34,\n width: x1 - x0,\n height: 26,\n label: phase.label,\n stroke: variantEdgeStyle(phase.variant).color,\n labelColor: ARCHIFY_TEXT_MUTED,\n borderStyle: 'none',\n zIndex: -15 + i,\n }),\n );\n }\n\n // Workflow groups (nested emphasis frames inside a lane).\n for (const [i, g] of (spec.groups ?? []).entries()) {\n const top = laneTop(g.lane);\n const x0 = WF.colXs[g.fromCol] - WF.nodeW / 2 - 8;\n const x1 = WF.colXs[g.toCol] + WF.nodeW / 2 + 8;\n nodes.push(\n frame({\n id: `wfgroup_${g.id}`,\n x: x0,\n y: top + WF.laneTitleH - 6,\n width: x1 - x0,\n height: WF.laneH - WF.laneTitleH,\n label: g.label,\n stroke: variantEdgeStyle(g.variant).color,\n labelColor: ARCHIFY_TEXT_MUTED,\n borderStyle: 'dashed',\n zIndex: -12 + i,\n }),\n );\n }\n\n for (const n of spec.nodes) {\n const width = n.width ?? WF.nodeW;\n const height = n.height ?? (n.tag ? 68 : WF.nodeH);\n const cx = WF.colXs[n.col] ?? WF.colXs[WF.colXs.length - 1];\n const contentH = WF.laneH - WF.laneTitleH;\n const y = laneTop(n.lane) + WF.laneTitleH + (contentH - height) / 2 + (n.yOffset ?? 0);\n const style = componentStyle(n.type);\n nodes.push(\n card({\n id: n.id,\n x: cx - width / 2,\n y,\n width,\n height,\n label: n.label,\n sublabel: n.sublabel,\n tag: n.tag,\n fill: style.fill,\n stroke: style.stroke,\n text: style.text,\n sub: style.sub,\n fontSize: 12,\n }),\n );\n }\n\n const mainPath = new Set<string>();\n const mp = spec.mainPath ?? [];\n for (let i = 0; i < mp.length - 1; i++) mainPath.add(`${mp[i]}->${mp[i + 1]}`);\n\n for (const e of spec.edges) {\n const onMain = mainPath.has(`${e.from}->${e.to}`);\n const style = variantEdgeStyle(e.variant ?? (onMain ? 'emphasis' : 'default'));\n edges.push(\n edge({\n id: e.id,\n source: e.from,\n target: e.to,\n sourceHandle: sideHandle(e.fromSide),\n targetHandle: sideHandle(e.toSide),\n label: e.label,\n color: e.role === 'error' ? '#fb7185' : style.color,\n width: e.width ?? style.width,\n lineStyle: e.role === 'error' ? 'dashed' : style.lineStyle,\n animated: trace && onMain,\n waypoints: e.via?.map(([x, y]) => ({ x, y })),\n }),\n );\n }\n\n return wrap(nodes, edges, [], spec.meta.title);\n}\n\n/* ========================================================================== */\n/* Sequence */\n/* ========================================================================== */\n\nfunction convertSequence(spec: ArchifySequenceSpec): FlowDocument {\n const nodes: FlowNode[] = [];\n const edges: FlowEdge[] = [];\n const lines: FlowLine[] = [];\n\n const viewBox = spec.meta.viewBox ?? [920, 760];\n const sideMargin = 62;\n const participantW = 86;\n const colGap = 108;\n const topY = 72;\n const participantH = 54;\n const lifelineTop = 142;\n const lifelineBottom = viewBox[1] - 65;\n\n const cx = (i: number) => sideMargin + i * colGap;\n const partX = new Map<string, number>();\n\n spec.participants.forEach((p, i) => {\n const x = cx(i);\n partX.set(p.id, x);\n const style = componentStyle(p.type);\n nodes.push(\n card({\n id: p.id,\n x: x - participantW / 2,\n y: topY,\n width: participantW,\n height: participantH,\n label: p.label,\n sublabel: p.sublabel,\n fill: style.fill,\n stroke: style.stroke,\n text: style.text,\n sub: style.sub,\n fontSize: 11,\n zIndex: 5,\n }),\n );\n // Lifeline (dashed vertical guide beneath each participant).\n lines.push({\n id: `lifeline_${p.id}`,\n type: 'straight',\n points: [\n { x, y: lifelineTop },\n { x, y: lifelineBottom },\n ],\n strokeColor: ARCHIFY_LANE_STROKE,\n strokeWidth: 1,\n lineStyle: 'dashed',\n markerEnd: 'none',\n zIndex: -5,\n });\n });\n\n // Segment frames (labelled bands over ranges of the timeline).\n for (const [i, seg] of (spec.segments ?? []).entries()) {\n nodes.push(\n frame({\n id: `segment_${i}`,\n x: 48,\n y: seg.from,\n width: viewBox[0] - 96,\n height: seg.to - seg.from,\n label: seg.label,\n stroke: ARCHIFY_LANE_STROKE,\n labelColor: ARCHIFY_TEXT_MUTED,\n borderStyle: 'dashed',\n zIndex: -10,\n }),\n );\n }\n\n // Activation bars (thin vertical rects on a participant lifeline).\n for (const [i, act] of (spec.activations ?? []).entries()) {\n const x = partX.get(act.participant);\n if (x === undefined) continue;\n const style = componentStyle(act.type ?? 'backend');\n nodes.push({\n id: `activation_${i}_${act.participant}`,\n type: 'shapeRect',\n position: { x: x - 5, y: act.from },\n width: 10,\n height: Math.max(6, act.to - act.from),\n zIndex: 1,\n data: {\n label: '',\n fill: style.fill,\n stroke: style.stroke,\n strokeWidth: 1,\n color: style.text,\n fontSize: 10,\n borderStyle: 'solid',\n attributes: [],\n },\n });\n }\n\n // Messages become horizontal arrow lines at their y with a label above.\n for (const m of spec.messages) {\n const fromX = partX.get(m.from);\n const toX = partX.get(m.to);\n if (fromX === undefined || toX === undefined) continue;\n const dir = toX > fromX ? 1 : -1;\n const start = fromX + dir * 7;\n const end = toX - dir * 7;\n const style = messageEdgeStyle(m.variant);\n lines.push({\n id: m.id ?? uid('msg'),\n type: 'arrow',\n points: [\n { x: start, y: m.y },\n { x: end, y: m.y },\n ],\n strokeColor: style.color,\n strokeWidth: style.width,\n lineStyle: style.lineStyle,\n markerEnd: m.variant === 'return' ? 'arrow' : 'arrowclosed',\n zIndex: 3,\n });\n // Label as a tiny transparent text node centered above the arrow.\n nodes.push({\n id: `mlabel_${m.id ?? uid('m')}`,\n type: 'textLabel',\n position: { x: (start + end) / 2 - 70, y: m.y - 22 },\n width: 140,\n height: 16,\n zIndex: 4,\n data: {\n label: m.label,\n fill: 'transparent',\n stroke: 'transparent',\n strokeWidth: 0,\n color: style.color,\n labelColor: style.color,\n fontSize: 11,\n attributes: [],\n },\n });\n }\n\n return wrap(nodes, edges, lines, spec.meta.title);\n}\n\n/* ========================================================================== */\n/* Dataflow */\n/* ========================================================================== */\n\nconst DF = {\n stageY: 46,\n stageH: 36,\n stageBottomPad: 74,\n leftX: 100,\n colGap: 215,\n stageW: 168,\n nodeW: 112,\n nodeH: 58,\n rowYs: [128, 242, 356, 470, 584],\n};\n\nconst stageX = (i: number) => DF.leftX + i * DF.colGap;\n\nfunction convertDataflow(spec: ArchifyDataflowSpec): FlowDocument {\n const trace = isTrace(spec);\n const nodes: FlowNode[] = [];\n const edges: FlowEdge[] = [];\n\n const viewBox = spec.meta.viewBox ?? [940, 720];\n\n // Stage frames (tall vertical bands).\n for (const [i, stage] of spec.stages.entries()) {\n nodes.push(\n frame({\n id: `stage_${i}`,\n x: stageX(i) - DF.stageW / 2,\n y: DF.stageY,\n width: DF.stageW,\n height: viewBox[1] - DF.stageY - DF.stageBottomPad,\n label: stage.label,\n stroke: ARCHIFY_LANE_STROKE,\n labelColor: ARCHIFY_TEXT_MUTED,\n borderStyle: 'dashed',\n zIndex: -10,\n }),\n );\n }\n\n for (const n of spec.nodes) {\n const width = n.width ?? DF.nodeW;\n const height = n.height ?? DF.nodeH;\n const cx = stageX(n.stage);\n const y = (DF.rowYs[n.row] ?? DF.rowYs[DF.rowYs.length - 1]) + (n.yOffset ?? 0);\n const style = componentStyle(n.type);\n nodes.push(\n card({\n id: n.id,\n x: cx - width / 2,\n y,\n width,\n height,\n label: n.label,\n sublabel: n.sublabel,\n tag: n.tag,\n fill: style.fill,\n stroke: style.stroke,\n text: style.text,\n sub: style.sub,\n fontSize: 12,\n }),\n );\n }\n\n for (const f of spec.flows) {\n const style = variantEdgeStyle(f.variant);\n edges.push(\n edge({\n id: f.id,\n source: f.from,\n target: f.to,\n sourceHandle: sideHandle(f.fromSide),\n targetHandle: sideHandle(f.toSide),\n label: f.label,\n color: style.color,\n width: f.width ?? style.width,\n lineStyle: style.lineStyle,\n animated: trace && f.variant === 'emphasis',\n waypoints: f.via?.map(([x, y]) => ({ x, y })),\n }),\n );\n }\n\n return wrap(nodes, edges, [], spec.meta.title);\n}\n\n/* ========================================================================== */\n/* Lifecycle */\n/* ========================================================================== */\n\nconst LC = {\n phaseY: 126,\n eventY: 278,\n outcomeY: 450,\n phaseW: 118,\n phaseH: 62,\n eventW: 126,\n eventH: 58,\n outcomeW: 118,\n outcomeH: 58,\n phaseXs: [94, 248, 402, 556, 710],\n eventXs: [402, 556, 710],\n outcomeXs: [402, 556, 710],\n};\n\nfunction lifecycleBand(lane: string): 'phase' | 'event' | 'outcome' {\n if (lane === 'main') return 'phase';\n if (lane === 'terminal') return 'outcome';\n return 'event';\n}\n\nfunction convertLifecycle(spec: ArchifyLifecycleSpec): FlowDocument {\n const trace = isTrace(spec);\n const nodes: FlowNode[] = [];\n const edges: FlowEdge[] = [];\n\n const viewBox = spec.meta.viewBox ?? [980, 660];\n\n // Band frames give the three horizontal groupings some structure.\n const laneLabel = new Map(spec.lanes.map((l) => [l.id, l.label]));\n const bandRows: Array<{ band: 'phase' | 'event' | 'outcome'; y: number; h: number; label: string }> = [\n { band: 'phase', y: LC.phaseY - 26, h: LC.phaseH + 40, label: laneLabel.get('main') ?? 'Lifecycle phases' },\n { band: 'event', y: LC.eventY - 26, h: LC.eventH + 40, label: 'Interruptions + Recovery' },\n { band: 'outcome', y: LC.outcomeY - 26, h: LC.outcomeH + 40, label: laneLabel.get('terminal') ?? 'Terminal exits' },\n ];\n for (const [i, b] of bandRows.entries()) {\n nodes.push(\n frame({\n id: `band_${b.band}`,\n x: 40,\n y: b.y,\n width: viewBox[0] - 80,\n height: b.h,\n label: `0${i + 1} / ${b.label}`,\n stroke: ARCHIFY_LANE_STROKE,\n labelColor: ARCHIFY_TEXT_MUTED,\n borderStyle: 'dashed',\n zIndex: -10,\n }),\n );\n }\n\n for (const s of spec.states) {\n const band = lifecycleBand(s.lane);\n const isPhase = band === 'phase';\n const isOutcome = band === 'outcome';\n const width = s.width ?? (isPhase ? LC.phaseW : isOutcome ? LC.outcomeW : LC.eventW);\n const height = s.height ?? (isPhase ? LC.phaseH : isOutcome ? LC.outcomeH : LC.eventH);\n const xs = isPhase ? LC.phaseXs : isOutcome ? LC.outcomeXs : LC.eventXs;\n const cx = xs[s.col] ?? xs[xs.length - 1];\n const y = (isPhase ? LC.phaseY : isOutcome ? LC.outcomeY : LC.eventY) + (s.yOffset ?? 0);\n const style = stateStyle(s.type);\n nodes.push(\n card({\n id: s.id,\n x: cx - width / 2,\n y,\n width,\n height,\n label: s.label,\n sublabel: s.sublabel,\n tag: s.tag ?? s.step,\n fill: style.fill,\n stroke: style.stroke,\n text: style.text,\n sub: style.sub,\n fontSize: 12,\n }),\n );\n }\n\n // Order states along the main lane to build the primary rail. Archify draws\n // this rail decoratively (not as explicit transitions), so synthesize edges\n // between consecutive phase states, connecting right-to-left across columns.\n const mainStates = spec.states\n .filter((s) => s.lane === 'main')\n .sort((a, b) => a.col - b.col);\n const explicitPairs = new Set(spec.transitions.map((t) => `${t.from}->${t.to}`));\n for (let i = 0; i < mainStates.length - 1; i++) {\n const from = mainStates[i];\n const to = mainStates[i + 1];\n // Skip if the author already provided this exact transition.\n if (explicitPairs.has(`${from.id}->${to.id}`)) continue;\n edges.push(\n edge({\n id: `mainrail_${from.id}_${to.id}`,\n source: from.id,\n target: to.id,\n sourceHandle: sideHandle('right'),\n targetHandle: sideHandle('left'),\n label: undefined,\n color: variantEdgeStyle('emphasis').color,\n width: 2.2,\n lineStyle: 'solid',\n animated: trace,\n }),\n );\n }\n\n const mainPairs = new Set<string>();\n for (let i = 0; i < mainStates.length - 1; i++) {\n mainPairs.add(`${mainStates[i].id}->${mainStates[i + 1].id}`);\n }\n\n for (const t of spec.transitions) {\n const style = variantEdgeStyle(t.variant);\n const onMain = mainPairs.has(`${t.from}->${t.to}`);\n edges.push(\n edge({\n id: t.id,\n source: t.from,\n target: t.to,\n sourceHandle: sideHandle(t.fromSide),\n targetHandle: sideHandle(t.toSide),\n label: t.label,\n color: style.color,\n width: t.width ?? style.width,\n lineStyle: style.lineStyle,\n animated: trace && onMain,\n waypoints: t.via?.map(([x, y]) => ({ x, y })),\n }),\n );\n }\n\n return wrap(nodes, edges, [], spec.meta.title);\n}\n\n/* ========================================================================== */\n\nfunction wrap(\n nodes: FlowNode[],\n edges: FlowEdge[],\n lines: FlowLine[],\n title?: string,\n): FlowDocument {\n return {\n canvases: {\n [ROOT_CANVAS_ID]: { nodes, edges, lines },\n },\n stack: [ROOT_CANVAS_ID],\n title,\n };\n}\n\n/** Convert any supported Archify spec into a Flow document. */\nexport function archifyToFlowDocument(spec: ArchifySpec): FlowDocument {\n switch (spec.diagram_type) {\n case 'architecture':\n return convertArchitecture(spec);\n case 'workflow':\n return convertWorkflow(spec);\n case 'sequence':\n return convertSequence(spec);\n case 'dataflow':\n return convertDataflow(spec);\n case 'lifecycle':\n return convertLifecycle(spec);\n default:\n return wrap([], [], []);\n }\n}\n"],"mappings":";;;;AA+BA,SAAS,EAAQ,GAA4B;CAC3C,OAAO,EAAK,MAAM,cAAc;AAClC;AAMA,IAAM,IAAY;CAAE,QAAQ,CAAC,IAAI,EAAE;CAAG,MAAM;CAAG,MAAM;CAAI,MAAM;CAAI,OAAO;CAAK,OAAO;AAAG;AAEzF,SAAS,EAAoB,GAA6C;CACxE,IAAM,IAAQ,EAAQ,CAAI,GACpB,IAAO;EAAE,GAAG;EAAW,GAAG,EA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I,EAAE;GACN,QAAQ,EAAE;GACV,QAAQ,EAAE;GACV,cAAc,EAAW,EAAE,QAAQ;GACnC,cAAc,EAAW,EAAE,MAAM;GACjC,OAAO,EAAE;GACT,OAAO,EAAM;GACb,OAAO,EAAE,SAAS,EAAM;GACxB,WAAW,EAAM;GACjB,UAAU,KAAS;GACnB,WAAW,EAAE,KAAK,KAAK,CAAC,GAAG,QAAQ;IAAE;IAAG;GAAE,EAAE;EAC9C,CAAC,CACH;CACF;CAEA,OAAO,EAAK,GAAO,GAAO,CAAC,GAAG,EAAK,KAAK,KAAK;AAC/C;AAIA,SAAS,EACP,GACA,GACA,GACA,GACc;CACd,OAAO;EACL,UAAU,GACP,IAAiB;GAAE;GAAO;GAAO;EAAM,EAC1C;EACA,OAAO,CAAC,CAAc;EACtB;CACF;AACF;AAGA,SAAgB,EAAsB,GAAiC;CACrE,QAAQ,EAAK,cAAb;EACE,KAAK,gBACH,OAAO,EAAoB,CAAI;EACjC,KAAK,YACH,OAAO,EAAgB,CAAI;EAC7B,KAAK,YACH,OAAO,EAAgB,CAAI;EAC7B,KAAK,YACH,OAAO,EAAgB,CAAI;EAC7B,KAAK,aACH,OAAO,EAAiB,CAAI;EAC9B,SACE,OAAO,EAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;CAC1B;AACF"}
@@ -140,23 +140,25 @@ function n() {
140
140
  ]),
141
141
  changeZIndex: t((e) => {
142
142
  let t = i.nodeIds, a = i.lineIds;
143
- (t.size !== 0 || a.size !== 0) && n((n) => {
144
- let i = n.canvases[r];
145
- if (!i) return n;
146
- let o = i.nodes.map((e) => e.zIndex ?? 0), s = o.length > 0 ? Math.max(...o) : 0, c = o.length > 0 ? Math.min(...o) : 0, l = i.lines.map((e) => e.zIndex ?? 0), u = l.length > 0 ? Math.max(...l) : 0, d = l.length > 0 ? Math.min(...l) : 0, f = (t, n, r) => e === "front" ? n + 1 : e === "back" ? r - 1 : e === "up" ? t + 1 : t - 1;
143
+ if (t.size === 0 && a.size === 0) return;
144
+ let o = (t, n, r) => e === "front" ? n + 1 : e === "back" ? r - 1 : e === "up" ? t + 1 : t - 1;
145
+ n((e) => {
146
+ let n = e.canvases[r];
147
+ if (!n) return e;
148
+ let i = n.nodes.map((e) => e.zIndex ?? 0), s = i.length > 0 ? Math.max(...i) : 0, c = i.length > 0 ? Math.min(...i) : 0, l = n.lines.map((e) => e.zIndex ?? 0), u = l.length > 0 ? Math.max(...l) : 0, d = l.length > 0 ? Math.min(...l) : 0;
147
149
  return {
148
- ...n,
150
+ ...e,
149
151
  canvases: {
150
- ...n.canvases,
152
+ ...e.canvases,
151
153
  [r]: {
152
- ...i,
153
- nodes: i.nodes.map((e) => t.has(e.id) ? {
154
+ ...n,
155
+ nodes: n.nodes.map((e) => t.has(e.id) ? {
154
156
  ...e,
155
- zIndex: f(e.zIndex ?? 0, s, c)
157
+ zIndex: o(e.zIndex ?? 0, s, c)
156
158
  } : e),
157
- lines: i.lines.map((e) => a.has(e.id) ? {
159
+ lines: n.lines.map((e) => a.has(e.id) ? {
158
160
  ...e,
159
- zIndex: f(e.zIndex ?? 0, u, d)
161
+ zIndex: o(e.zIndex ?? 0, u, d)
160
162
  } : e)
161
163
  }
162
164
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useLayoutActions.js","names":[],"sources":["../../../../../src/components/pro/Flow/hooks/useLayoutActions.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useFlowContext } from '../context/FlowContext';\nimport type { FlowNode } from '../types';\n\ntype Align = 'left' | 'center-h' | 'right' | 'top' | 'center-v' | 'bottom';\ntype Distribute = 'horizontal' | 'vertical';\ntype LayerMode = 'front' | 'back' | 'up' | 'down';\n\nexport function useLayoutActions() {\n const { setDoc, currentCanvasId, selection, currentCanvas } = useFlowContext();\n\n const align = useCallback(\n (direction: Align) => {\n const ids = selection.nodeIds;\n if (ids.size < 2) return;\n const nodes = currentCanvas.nodes.filter(n => ids.has(n.id));\n if (nodes.length < 2) return;\n\n let target: number;\n switch (direction) {\n case 'left':\n target = Math.min(...nodes.map(n => n.position.x));\n break;\n case 'right':\n target = Math.max(...nodes.map(n => n.position.x + n.width));\n break;\n case 'center-h':\n target = nodes.reduce((s, n) => s + n.position.x + n.width / 2, 0) / nodes.length;\n break;\n case 'top':\n target = Math.min(...nodes.map(n => n.position.y));\n break;\n case 'bottom':\n target = Math.max(...nodes.map(n => n.position.y + n.height));\n break;\n case 'center-v':\n target = nodes.reduce((s, n) => s + n.position.y + n.height / 2, 0) / nodes.length;\n break;\n }\n\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasId];\n if (!canvas) return prev;\n return {\n ...prev,\n canvases: {\n ...prev.canvases,\n [currentCanvasId]: {\n ...canvas,\n nodes: canvas.nodes.map(n => {\n if (!ids.has(n.id)) return n;\n let newX = n.position.x;\n let newY = n.position.y;\n switch (direction) {\n case 'left': newX = target; break;\n case 'right': newX = target - n.width; break;\n case 'center-h': newX = target - n.width / 2; break;\n case 'top': newY = target; break;\n case 'bottom': newY = target - n.height; break;\n case 'center-v': newY = target - n.height / 2; break;\n }\n return { ...n, position: { x: newX, y: newY } };\n }),\n },\n },\n };\n });\n },\n [setDoc, currentCanvasId, selection, currentCanvas],\n );\n\n const distribute = useCallback(\n (direction: Distribute) => {\n const ids = selection.nodeIds;\n if (ids.size < 3) return;\n const nodes = currentCanvas.nodes.filter(n => ids.has(n.id));\n if (nodes.length < 3) return;\n\n const sorted = [...nodes].sort((a, b) =>\n direction === 'horizontal'\n ? a.position.x - b.position.x\n : a.position.y - b.position.y,\n );\n\n const first = sorted[0];\n const last = sorted[sorted.length - 1];\n\n if (direction === 'horizontal') {\n const totalWidth = sorted.reduce((s, n) => s + n.width, 0);\n const totalSpace = (last.position.x + last.width) - first.position.x - totalWidth;\n const gap = totalSpace / (sorted.length - 1);\n let x = first.position.x;\n\n const posMap = new Map<string, number>();\n for (const n of sorted) {\n posMap.set(n.id, x);\n x += n.width + gap;\n }\n\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasId];\n if (!canvas) return prev;\n return {\n ...prev,\n canvases: {\n ...prev.canvases,\n [currentCanvasId]: {\n ...canvas,\n nodes: canvas.nodes.map(n => {\n const newX = posMap.get(n.id);\n return newX !== undefined ? { ...n, position: { ...n.position, x: newX } } : n;\n }),\n },\n },\n };\n });\n } else {\n const totalHeight = sorted.reduce((s, n) => s + n.height, 0);\n const totalSpace = (last.position.y + last.height) - first.position.y - totalHeight;\n const gap = totalSpace / (sorted.length - 1);\n let y = first.position.y;\n\n const posMap = new Map<string, number>();\n for (const n of sorted) {\n posMap.set(n.id, y);\n y += n.height + gap;\n }\n\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasId];\n if (!canvas) return prev;\n return {\n ...prev,\n canvases: {\n ...prev.canvases,\n [currentCanvasId]: {\n ...canvas,\n nodes: canvas.nodes.map(n => {\n const newY = posMap.get(n.id);\n return newY !== undefined ? { ...n, position: { ...n.position, y: newY } } : n;\n }),\n },\n },\n };\n });\n }\n },\n [setDoc, currentCanvasId, selection, currentCanvas],\n );\n\n const changeZIndex = useCallback(\n (mode: LayerMode) => {\n const nodeIds = selection.nodeIds;\n const lineIds = selection.lineIds;\n if (nodeIds.size === 0 && lineIds.size === 0) return;\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasId];\n if (!canvas) return prev;\n const nodeAllZ = canvas.nodes.map(n => n.zIndex ?? 0);\n const nodeMaxZ = nodeAllZ.length > 0 ? Math.max(...nodeAllZ) : 0;\n const nodeMinZ = nodeAllZ.length > 0 ? Math.min(...nodeAllZ) : 0;\n const lineAllZ = canvas.lines.map(l => l.zIndex ?? 0);\n const lineMaxZ = lineAllZ.length > 0 ? Math.max(...lineAllZ) : 0;\n const lineMinZ = lineAllZ.length > 0 ? Math.min(...lineAllZ) : 0;\n const applyZ = (z: number, maxZ: number, minZ: number) => {\n if (mode === 'front') return maxZ + 1;\n if (mode === 'back') return minZ - 1;\n if (mode === 'up') return z + 1;\n return z - 1;\n };\n return {\n ...prev,\n canvases: {\n ...prev.canvases,\n [currentCanvasId]: {\n ...canvas,\n nodes: canvas.nodes.map(n => nodeIds.has(n.id) ? { ...n, zIndex: applyZ(n.zIndex ?? 0, nodeMaxZ, nodeMinZ) } : n),\n lines: canvas.lines.map(l => lineIds.has(l.id) ? { ...l, zIndex: applyZ(l.zIndex ?? 0, lineMaxZ, lineMinZ) } : l),\n },\n },\n };\n });\n },\n [setDoc, currentCanvasId, selection],\n );\n\n return { align, distribute, changeZIndex };\n}\n"],"mappings":";;;AAQA,SAAgB,IAAmB;CACjC,IAAM,EAAE,WAAQ,oBAAiB,cAAW,qBAAkB,EAAe;CAiL7E,OAAO;EAAE,OA/KK,GACX,MAAqB;GACpB,IAAM,IAAM,EAAU;GACtB,IAAI,EAAI,OAAO,GAAG;GAClB,IAAM,IAAQ,EAAc,MAAM,QAAO,MAAK,EAAI,IAAI,EAAE,EAAE,CAAC;GAC3D,IAAI,EAAM,SAAS,GAAG;GAEtB,IAAI;GACJ,QAAQ,GAAR;IACE,KAAK;KACH,IAAS,KAAK,IAAI,GAAG,EAAM,KAAI,MAAK,EAAE,SAAS,CAAC,CAAC;KACjD;IACF,KAAK;KACH,IAAS,KAAK,IAAI,GAAG,EAAM,KAAI,MAAK,EAAE,SAAS,IAAI,EAAE,KAAK,CAAC;KAC3D;IACF,KAAK;KACH,IAAS,EAAM,QAAQ,GAAG,MAAM,IAAI,EAAE,SAAS,IAAI,EAAE,QAAQ,GAAG,CAAC,IAAI,EAAM;KAC3E;IACF,KAAK;KACH,IAAS,KAAK,IAAI,GAAG,EAAM,KAAI,MAAK,EAAE,SAAS,CAAC,CAAC;KACjD;IACF,KAAK;KACH,IAAS,KAAK,IAAI,GAAG,EAAM,KAAI,MAAK,EAAE,SAAS,IAAI,EAAE,MAAM,CAAC;KAC5D;IACF,KAAK,YACH,IAAS,EAAM,QAAQ,GAAG,MAAM,IAAI,EAAE,SAAS,IAAI,EAAE,SAAS,GAAG,CAAC,IAAI,EAAM;GAEhF;GA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EAAa,CAuCpC;EAAY,cApCP,GAClB,MAAoB;GACnB,IAAM,IAAU,EAAU,SACpB,IAAU,EAAU;GACtB,GAAQ,SAAS,KAAK,EAAQ,SAAS,MAC3C,GAAO,MAAQ;IACb,IAAM,IAAS,EAAK,SAAS;IAC7B,IAAI,CAAC,GAAQ,OAAO;IACpB,IAAM,IAAW,EAAO,MAAM,KAAI,MAAK,EAAE,UAAU,CAAC,GAC9C,IAAW,EAAS,SAAS,IAAI,KAAK,IAAI,GAAG,CAAQ,IAAI,GACzD,IAAW,EAAS,SAAS,IAAI,KAAK,IAAI,GAAG,CAAQ,IAAI,GACzD,IAAW,EAAO,MAAM,KAAI,MAAK,EAAE,UAAU,CAAC,GAC9C,IAAW,EAAS,SAAS,IAAI,KAAK,IAAI,GAAG,CAAQ,IAAI,GACzD,IAAW,EAAS,SAAS,IAAI,KAAK,IAAI,GAAG,CAAQ,IAAI,GACzD,KAAU,GAAW,GAAc,MACnC,MAAS,UAAgB,IAAO,IAChC,MAAS,SAAe,IAAO,IAC/B,MAAS,OAAa,IAAI,IACvB,IAAI;IAEb,OAAO;KACL,GAAG;KACH,UAAU;MACR,GAAG,EAAK;OACP,IAAkB;OACjB,GAAG;OACH,OAAO,EAAO,MAAM,KAAI,MAAK,EAAQ,IAAI,EAAE,EAAE,IAAI;QAAE,GAAG;QAAG,QAAQ,EAAO,EAAE,UAAU,GAAG,GAAU,CAAQ;OAAE,IAAI,CAAC;OAChH,OAAO,EAAO,MAAM,KAAI,MAAK,EAAQ,IAAI,EAAE,EAAE,IAAI;QAAE,GAAG;QAAG,QAAQ,EAAO,EAAE,UAAU,GAAG,GAAU,CAAQ;OAAE,IAAI,CAAC;MAClH;KACF;IACF;GACF,CAAC;EACH,GACA;GAAC;GAAQ;GAAiB;EAAS,CAGT;CAAa;AAC3C"}
1
+ {"version":3,"file":"useLayoutActions.js","names":[],"sources":["../../../../../src/components/pro/Flow/hooks/useLayoutActions.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useFlowContext } from '../context/FlowContext';\nimport type { FlowNode } from '../types';\n\ntype Align = 'left' | 'center-h' | 'right' | 'top' | 'center-v' | 'bottom';\ntype Distribute = 'horizontal' | 'vertical';\ntype LayerMode = 'front' | 'back' | 'up' | 'down';\n\nexport function useLayoutActions() {\n const { setDoc, currentCanvasId, selection, currentCanvas } = useFlowContext();\n\n const align = useCallback(\n (direction: Align) => {\n const ids = selection.nodeIds;\n if (ids.size < 2) return;\n const nodes = currentCanvas.nodes.filter(n => ids.has(n.id));\n if (nodes.length < 2) return;\n\n let target: number;\n switch (direction) {\n case 'left':\n target = Math.min(...nodes.map(n => n.position.x));\n break;\n case 'right':\n target = Math.max(...nodes.map(n => n.position.x + n.width));\n break;\n case 'center-h':\n target = nodes.reduce((s, n) => s + n.position.x + n.width / 2, 0) / nodes.length;\n break;\n case 'top':\n target = Math.min(...nodes.map(n => n.position.y));\n break;\n case 'bottom':\n target = Math.max(...nodes.map(n => n.position.y + n.height));\n break;\n case 'center-v':\n target = nodes.reduce((s, n) => s + n.position.y + n.height / 2, 0) / nodes.length;\n break;\n }\n\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasId];\n if (!canvas) return prev;\n return {\n ...prev,\n canvases: {\n ...prev.canvases,\n [currentCanvasId]: {\n ...canvas,\n nodes: canvas.nodes.map(n => {\n if (!ids.has(n.id)) return n;\n let newX = n.position.x;\n let newY = n.position.y;\n switch (direction) {\n case 'left': newX = target; break;\n case 'right': newX = target - n.width; break;\n case 'center-h': newX = target - n.width / 2; break;\n case 'top': newY = target; break;\n case 'bottom': newY = target - n.height; break;\n case 'center-v': newY = target - n.height / 2; break;\n }\n return { ...n, position: { x: newX, y: newY } };\n }),\n },\n },\n };\n });\n },\n [setDoc, currentCanvasId, selection, currentCanvas],\n );\n\n const distribute = useCallback(\n (direction: Distribute) => {\n const ids = selection.nodeIds;\n if (ids.size < 3) return;\n const nodes = currentCanvas.nodes.filter(n => ids.has(n.id));\n if (nodes.length < 3) return;\n\n const sorted = [...nodes].sort((a, b) =>\n direction === 'horizontal'\n ? a.position.x - b.position.x\n : a.position.y - b.position.y,\n );\n\n const first = sorted[0];\n const last = sorted[sorted.length - 1];\n\n if (direction === 'horizontal') {\n const totalWidth = sorted.reduce((s, n) => s + n.width, 0);\n const totalSpace = (last.position.x + last.width) - first.position.x - totalWidth;\n const gap = totalSpace / (sorted.length - 1);\n let x = first.position.x;\n\n const posMap = new Map<string, number>();\n for (const n of sorted) {\n posMap.set(n.id, x);\n x += n.width + gap;\n }\n\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasId];\n if (!canvas) return prev;\n return {\n ...prev,\n canvases: {\n ...prev.canvases,\n [currentCanvasId]: {\n ...canvas,\n nodes: canvas.nodes.map(n => {\n const newX = posMap.get(n.id);\n return newX !== undefined ? { ...n, position: { ...n.position, x: newX } } : n;\n }),\n },\n },\n };\n });\n } else {\n const totalHeight = sorted.reduce((s, n) => s + n.height, 0);\n const totalSpace = (last.position.y + last.height) - first.position.y - totalHeight;\n const gap = totalSpace / (sorted.length - 1);\n let y = first.position.y;\n\n const posMap = new Map<string, number>();\n for (const n of sorted) {\n posMap.set(n.id, y);\n y += n.height + gap;\n }\n\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasId];\n if (!canvas) return prev;\n return {\n ...prev,\n canvases: {\n ...prev.canvases,\n [currentCanvasId]: {\n ...canvas,\n nodes: canvas.nodes.map(n => {\n const newY = posMap.get(n.id);\n return newY !== undefined ? { ...n, position: { ...n.position, y: newY } } : n;\n }),\n },\n },\n };\n });\n }\n },\n [setDoc, currentCanvasId, selection, currentCanvas],\n );\n\n const changeZIndex = useCallback(\n (mode: LayerMode) => {\n const nodeIds = selection.nodeIds;\n const lineIds = selection.lineIds;\n if (nodeIds.size === 0 && lineIds.size === 0) return;\n const applyZ = (z: number, maxZ: number, minZ: number) => {\n if (mode === 'front') return maxZ + 1;\n if (mode === 'back') return minZ - 1;\n if (mode === 'up') return z + 1;\n return z - 1;\n };\n setDoc(prev => {\n const canvas = prev.canvases[currentCanvasId];\n if (!canvas) return prev;\n const nodeAllZ = canvas.nodes.map(n => n.zIndex ?? 0);\n const nodeMaxZ = nodeAllZ.length > 0 ? Math.max(...nodeAllZ) : 0;\n const nodeMinZ = nodeAllZ.length > 0 ? Math.min(...nodeAllZ) : 0;\n const lineAllZ = canvas.lines.map(l => l.zIndex ?? 0);\n const lineMaxZ = lineAllZ.length > 0 ? Math.max(...lineAllZ) : 0;\n const lineMinZ = lineAllZ.length > 0 ? Math.min(...lineAllZ) : 0;\n return {\n ...prev,\n canvases: {\n ...prev.canvases,\n [currentCanvasId]: {\n ...canvas,\n nodes: canvas.nodes.map(n => nodeIds.has(n.id) ? { ...n, zIndex: applyZ(n.zIndex ?? 0, nodeMaxZ, nodeMinZ) } : n),\n lines: canvas.lines.map(l => lineIds.has(l.id) ? { ...l, zIndex: applyZ(l.zIndex ?? 0, lineMaxZ, lineMinZ) } : l),\n },\n },\n };\n });\n },\n [setDoc, currentCanvasId, selection],\n );\n\n return { align, distribute, changeZIndex };\n}\n"],"mappings":";;;AAQA,SAAgB,IAAmB;CACjC,IAAM,EAAE,WAAQ,oBAAiB,cAAW,qBAAkB,EAAe;CAiL7E,OAAO;EAAE,OA/KK,GACX,MAAqB;GACpB,IAAM,IAAM,EAAU;GACtB,IAAI,EAAI,OAAO,GAAG;GAClB,IAAM,IAAQ,EAAc,MAAM,QAAO,MAAK,EAAI,IAAI,EAAE,EAAE,CAAC;GAC3D,IAAI,EAAM,SAAS,GAAG;GAEtB,IAAI;GACJ,QAAQ,GAAR;IACE,KAAK;KACH,IAAS,KAAK,IAAI,GAAG,EAAM,KAAI,MAAK,EAAE,SAAS,CAAC,CAAC;KACjD;IACF,KAAK;KACH,IAAS,KAAK,IAAI,GAAG,EAAM,KAAI,MAAK,EAAE,SAAS,IAAI,EAAE,KAAK,CAAC;KAC3D;IACF,KAAK;KACH,IAAS,EAAM,QAAQ,GAAG,MAAM,IAAI,EAAE,SAAS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AAU,GAAG,GAAU,CAAQ;OAAE,IAAI,CAAC;OAChH,OAAO,EAAO,MAAM,KAAI,MAAK,EAAQ,IAAI,EAAE,EAAE,IAAI;QAAE,GAAG;QAAG,QAAQ,EAAO,EAAE,UAAU,GAAG,GAAU,CAAQ;OAAE,IAAI,CAAC;MAClH;KACF;IACF;GACF,CAAC;EACH,GACA;GAAC;GAAQ;GAAiB;EAAS,CAGT;CAAa;AAC3C"}
@@ -10,6 +10,7 @@ interface AIRewriteProps {
10
10
  from: number;
11
11
  to: number;
12
12
  };
13
+ followSelection?: boolean;
13
14
  onClose: () => void;
14
15
  }
15
16
  declare const AIRewrite: React.FC<AIRewriteProps>;
@@ -169,80 +169,101 @@ function h(e, t, n, r, i, a) {
169
169
  }
170
170
  return e.protocol === "anthropic" ? m(e, t, n, i) : p(e, t, n, i);
171
171
  }
172
- var g = ({ editor: f, aiConfig: p, labels: m, initialSelection: g, selectionRange: _, onClose: v }) => {
173
- let y = {
172
+ var g = ({ editor: f, aiConfig: p, labels: m, initialSelection: g, selectionRange: _, followSelection: v = !1, onClose: y }) => {
173
+ let b = {
174
174
  ...e,
175
175
  ...m
176
- }, b = a(), [x, S] = s(""), [C, w] = s(!1), [T, E] = s(""), [D, O] = s(null), k = o(null), A = o(null), [j, M] = s(() => !f.isDestroyed && f.isEditable), [N, P] = s(!1), F = o(f.state.doc), I = o(!1), L = r(() => {
177
- let e = k.current;
178
- k.current = null, e?.abort();
176
+ }, x = a(), [S, C] = s(""), [w, T] = s(!1), [E, D] = s(""), [O, k] = s(null), A = o(null), j = o(null), [M, N] = s(() => !f.isDestroyed && f.isEditable), [P, F] = s(!1), I = o(f.state.doc), L = o(!1), [R, z] = s(() => ({
177
+ from: _.from,
178
+ to: _.to,
179
+ text: g
180
+ })), B = o(R), V = r(() => {
181
+ let e = A.current;
182
+ A.current = null, e?.abort();
179
183
  }, []);
180
184
  i(() => {
181
- F.current = f.state.doc, I.current = !1, P(!1), E(""), w(!1), O(null);
185
+ B.current = {
186
+ from: _.from,
187
+ to: _.to,
188
+ text: g
189
+ }, z(B.current);
190
+ }, [
191
+ g,
192
+ _.from,
193
+ _.to
194
+ ]), i(() => {
195
+ I.current = f.state.doc, L.current = !1, F(!1), D(""), T(!1), k(null);
182
196
  let e = () => {
183
- M(!f.isDestroyed && f.isEditable), (f.isDestroyed || !f.isEditable || f.state.doc !== F.current) && (I.current = !0, P(!0), L(), w(!1), E(""), O("The document or editing permissions changed. Close and reopen AI Assistant."));
197
+ N(!f.isDestroyed && f.isEditable), (f.isDestroyed || !f.isEditable || f.state.doc !== I.current) && (L.current = !0, F(!0), V(), T(!1), D(""), k("The document or editing permissions changed. Close and reopen AI Assistant."));
198
+ }, t = () => {
199
+ if (!v || f.isDestroyed || !f.isEditable || f.state.doc !== I.current || L.current) return;
200
+ let { from: e, to: t } = f.state.selection, n = B.current;
201
+ if (e === t || e === n.from && t === n.to) return;
202
+ let r = {
203
+ from: e,
204
+ to: t,
205
+ text: f.state.doc.textBetween(e, t, " ")
206
+ };
207
+ B.current = r, z(r), V(), T(!1), D(""), k(null);
184
208
  };
185
- return e(), f.on("update", e), f.on("transaction", e), f.on("destroy", e), () => {
186
- L(), f.off("update", e), f.off("transaction", e), f.off("destroy", e);
209
+ return e(), f.on("update", e), f.on("transaction", e), f.on("selectionUpdate", t), f.on("destroy", e), () => {
210
+ V(), f.off("update", e), f.off("transaction", e), f.off("selectionUpdate", t), f.off("destroy", e);
187
211
  };
188
212
  }, [
189
213
  f,
190
- g,
191
- _.from,
192
- _.to,
193
- L
214
+ V,
215
+ v
194
216
  ]);
195
- let R = g;
217
+ let H = R.text;
196
218
  i(() => {
197
- A.current && A.current.focus();
219
+ j.current && j.current.focus();
198
220
  }, []);
199
- let z = r(async (e = "custom", t) => {
200
- if (f.isDestroyed || !f.isEditable || I.current || k.current) return;
201
- let n = R ? "replace" : "insert";
202
- if (n === "insert" && !x.trim()) return;
203
- let r = e === "custom" ? n === "replace" ? "Edit the selected text according to the user instruction. Return only the replacement text." : "Generate text according to the user instruction. Return only the text to insert." : d(e, t), i = [p.systemPrompt, r].filter(Boolean).join("\n\n"), a = n === "replace" ? x.trim() ? `Instruction:\n${x.trim()}\n\nSelected text:\n${R}` : R : x.trim();
204
- w(!0), E(""), O(null);
221
+ let U = r(async (e = "custom", t) => {
222
+ if (f.isDestroyed || !f.isEditable || L.current || A.current) return;
223
+ let n = H ? "replace" : "insert";
224
+ if (n === "insert" && !S.trim()) return;
225
+ let r = e === "custom" ? n === "replace" ? "Edit the selected text according to the user instruction. Return only the replacement text." : "Generate text according to the user instruction. Return only the text to insert." : d(e, t), i = [p.systemPrompt, r].filter(Boolean).join("\n\n"), a = n === "replace" ? S.trim() ? `Instruction:\n${S.trim()}\n\nSelected text:\n${H}` : H : S.trim();
226
+ T(!0), D(""), k(null);
205
227
  let o = new AbortController();
206
- k.current = o;
228
+ A.current = o;
207
229
  try {
208
230
  let t = "";
209
231
  for await (let r of h(p, a, i, e, o.signal, {
210
- prompt: x.trim(),
211
- selectedText: R,
232
+ prompt: S.trim(),
233
+ selectedText: H,
212
234
  mode: n
213
235
  })) {
214
- if (o.signal.aborted || k.current !== o) break;
215
- t += r, E(t);
236
+ if (o.signal.aborted || A.current !== o) break;
237
+ t += r, D(t);
216
238
  }
217
239
  } catch (e) {
218
- if (o.signal.aborted || k.current !== o) return;
219
- E(""), O(String(e instanceof Error ? e.message : e));
240
+ if (o.signal.aborted || A.current !== o) return;
241
+ D(""), k(String(e instanceof Error ? e.message : e));
220
242
  } finally {
221
- k.current === o && (k.current = null, w(!1));
243
+ A.current === o && (A.current = null, T(!1));
222
244
  }
223
245
  }, [
224
246
  f,
225
247
  p,
226
- R,
227
- x
228
- ]), B = r(() => {
229
- if (!T || k.current || f.isDestroyed || !f.isEditable || I.current) return;
230
- let { from: e, to: t } = _;
231
- if (f.state.doc !== F.current || !Number.isInteger(e) || !Number.isInteger(t) || e < 0 || t < e || t > f.state.doc.content.size) {
232
- O("The original selection is no longer valid. Close and reopen AI Assistant.");
248
+ H,
249
+ S
250
+ ]), W = r(() => {
251
+ if (!E || A.current || f.isDestroyed || !f.isEditable || L.current) return;
252
+ let { from: e, to: t } = B.current;
253
+ if (f.state.doc !== I.current || !Number.isInteger(e) || !Number.isInteger(t) || e < 0 || t < e || t > f.state.doc.content.size) {
254
+ k("The original selection is no longer valid. Close and reopen AI Assistant.");
233
255
  return;
234
256
  }
235
- f.view.dispatch(f.state.tr.insertText(T, e, t)), E(""), S(""), v();
257
+ f.view.dispatch(f.state.tr.insertText(E, e, t)), D(""), C(""), y();
236
258
  }, [
237
259
  f,
238
- T,
239
- _,
240
- v
241
- ]), V = r(() => {
242
- L(), E(""), w(!1), O(null);
243
- }, [L]), H = r((e) => {
244
- e.key === "Enter" && (e.metaKey || e.ctrlKey) && (e.preventDefault(), z());
245
- }, [z]);
260
+ E,
261
+ y
262
+ ]), G = r(() => {
263
+ V(), D(""), T(!1), k(null);
264
+ }, [V]), K = r((e) => {
265
+ e.key === "Enter" && (e.metaKey || e.ctrlKey) && (e.preventDefault(), U());
266
+ }, [U]);
246
267
  return /* @__PURE__ */ l("div", {
247
268
  className: "rte-ai-panel-v2",
248
269
  children: [
@@ -250,15 +271,15 @@ var g = ({ editor: f, aiConfig: p, labels: m, initialSelection: g, selectionRang
250
271
  className: "rte-ai-panel-v2__header",
251
272
  children: [/* @__PURE__ */ l("span", {
252
273
  className: "rte-ai-panel-v2__title",
253
- children: ["✨ ", y.ai || "AI Assistant"]
274
+ children: ["✨ ", b.ai || "AI Assistant"]
254
275
  }), /* @__PURE__ */ c("button", {
255
276
  type: "button",
256
277
  className: "rte-ai-panel-v2__close-btn",
257
278
  onClick: () => {
258
- L(), v();
279
+ V(), y();
259
280
  },
260
- title: y.aiClose,
261
- "aria-label": y.aiClose,
281
+ title: b.aiClose,
282
+ "aria-label": b.aiClose,
262
283
  children: /* @__PURE__ */ l("svg", {
263
284
  width: "14",
264
285
  height: "14",
@@ -286,30 +307,30 @@ var g = ({ editor: f, aiConfig: p, labels: m, initialSelection: g, selectionRang
286
307
  className: "rte-ai-panel-v2__prompt-section",
287
308
  children: [/* @__PURE__ */ c("label", {
288
309
  className: "rte-ai-panel-v2__label",
289
- htmlFor: b,
290
- children: y.aiPromptLabel
310
+ htmlFor: x,
311
+ children: b.aiPromptLabel
291
312
  }), /* @__PURE__ */ c("textarea", {
292
- id: b,
293
- ref: A,
313
+ id: x,
314
+ ref: j,
294
315
  className: "rte-ai-panel-v2__prompt-input",
295
- value: x,
296
- onChange: (e) => S(e.target.value),
297
- onKeyDown: H,
298
- placeholder: y.aiPromptPlaceholder,
316
+ value: S,
317
+ onChange: (e) => C(e.target.value),
318
+ onKeyDown: K,
319
+ placeholder: b.aiPromptPlaceholder,
299
320
  rows: 3,
300
- disabled: C || !j || N
321
+ disabled: w || !M || P
301
322
  })]
302
323
  }),
303
324
  /* @__PURE__ */ l("div", {
304
325
  className: "rte-ai-panel-v2__selection-section",
305
326
  children: [/* @__PURE__ */ c("span", {
306
327
  className: "rte-ai-panel-v2__label",
307
- children: y.aiSelectedText
328
+ children: b.aiSelectedText
308
329
  }), /* @__PURE__ */ c("div", {
309
330
  className: "rte-ai-panel-v2__selection-box",
310
- children: R ? /* @__PURE__ */ c("span", { children: R.length > 300 ? R.slice(0, 300) + "..." : R }) : /* @__PURE__ */ c("span", {
331
+ children: H ? /* @__PURE__ */ c("span", { children: H.length > 300 ? H.slice(0, 300) + "..." : H }) : /* @__PURE__ */ c("span", {
311
332
  className: "rte-ai-panel-v2__empty",
312
- children: y.aiInsertHint
333
+ children: b.aiInsertHint
313
334
  })
314
335
  })]
315
336
  }),
@@ -318,10 +339,10 @@ var g = ({ editor: f, aiConfig: p, labels: m, initialSelection: g, selectionRang
318
339
  children: u.map(({ key: e, labelKey: t, icon: n }) => /* @__PURE__ */ l("button", {
319
340
  type: "button",
320
341
  className: "rte-ai-panel-v2__quick-btn",
321
- onClick: () => z(e),
322
- disabled: C || !j || N || !R.trim(),
323
- title: R ? y[t] : y.aiInsertHint,
324
- children: [/* @__PURE__ */ c("span", { children: n }), /* @__PURE__ */ c("span", { children: y[t] })]
342
+ onClick: () => U(e),
343
+ disabled: w || !M || P || !H.trim(),
344
+ title: H ? b[t] : b.aiInsertHint,
345
+ children: [/* @__PURE__ */ c("span", { children: n }), /* @__PURE__ */ c("span", { children: b[t] })]
325
346
  }, e))
326
347
  }),
327
348
  /* @__PURE__ */ l("div", {
@@ -329,45 +350,45 @@ var g = ({ editor: f, aiConfig: p, labels: m, initialSelection: g, selectionRang
329
350
  children: [/* @__PURE__ */ c("button", {
330
351
  type: "button",
331
352
  className: "rte-ai-panel-v2__generate-btn",
332
- onClick: () => z(),
333
- disabled: C || !j || N || !x.trim() && !R.trim(),
334
- children: C ? y.aiProcessing : `✨ ${y.aiGenerate}`
335
- }), C && /* @__PURE__ */ c("button", {
353
+ onClick: () => U(),
354
+ disabled: w || !M || P || !S.trim() && !H.trim(),
355
+ children: w ? b.aiProcessing : `✨ ${b.aiGenerate}`
356
+ }), w && /* @__PURE__ */ c("button", {
336
357
  type: "button",
337
358
  className: "rte-ai-panel-v2__cancel-btn",
338
- onClick: V,
339
- children: y.aiCancel
359
+ onClick: G,
360
+ children: b.aiCancel
340
361
  })]
341
362
  }),
342
- C && !T && /* @__PURE__ */ c(n, {
363
+ w && !E && /* @__PURE__ */ c(n, {
343
364
  className: "rte-ai-panel-v2__loading",
344
- label: y.aiProcessing,
365
+ label: b.aiProcessing,
345
366
  variant: "dots",
346
367
  layout: "block",
347
368
  size: "sm"
348
369
  }),
349
- T && /* @__PURE__ */ l("div", {
370
+ E && /* @__PURE__ */ l("div", {
350
371
  className: "rte-ai-panel-v2__result",
351
372
  children: [
352
373
  /* @__PURE__ */ l("div", {
353
374
  className: "rte-ai-panel-v2__result-header",
354
375
  children: [/* @__PURE__ */ c("span", {
355
376
  className: "rte-ai-panel-v2__label",
356
- children: y.aiResult
377
+ children: b.aiResult
357
378
  }), /* @__PURE__ */ l("span", {
358
- className: `rte-ai-panel-v2__stream-status ${C ? "rte-ai-panel-v2__stream-status--live" : ""}`,
379
+ className: `rte-ai-panel-v2__stream-status ${w ? "rte-ai-panel-v2__stream-status--live" : ""}`,
359
380
  role: "status",
360
381
  children: [/* @__PURE__ */ c("span", {
361
382
  className: "rte-ai-panel-v2__stream-dot",
362
383
  "aria-hidden": "true"
363
- }), C ? y.aiProcessing : `${T.length} chars`]
384
+ }), w ? b.aiProcessing : `${E.length} chars`]
364
385
  })]
365
386
  }),
366
387
  /* @__PURE__ */ c("div", {
367
388
  className: "rte-ai-panel-v2__result-text",
368
389
  children: /* @__PURE__ */ c(t, {
369
- text: T,
370
- streaming: C
390
+ text: E,
391
+ streaming: w
371
392
  })
372
393
  }),
373
394
  /* @__PURE__ */ l("div", {
@@ -375,24 +396,24 @@ var g = ({ editor: f, aiConfig: p, labels: m, initialSelection: g, selectionRang
375
396
  children: [/* @__PURE__ */ c("button", {
376
397
  type: "button",
377
398
  className: "rte-ai-panel-v2__accept-btn",
378
- disabled: C || !j || N,
379
- onClick: B,
380
- children: y.aiAccept
399
+ disabled: w || !M || P,
400
+ onClick: W,
401
+ children: b.aiAccept
381
402
  }), /* @__PURE__ */ c("button", {
382
403
  type: "button",
383
404
  className: "rte-ai-panel-v2__reject-btn",
384
- onClick: V,
385
- children: y.aiReject
405
+ onClick: G,
406
+ children: b.aiReject
386
407
  })]
387
408
  })
388
409
  ]
389
410
  }),
390
- D && /* @__PURE__ */ l("div", {
411
+ O && /* @__PURE__ */ l("div", {
391
412
  className: "rte-ai-panel-v2__error",
392
- children: [/* @__PURE__ */ c("span", { children: D }), /* @__PURE__ */ c("button", {
413
+ children: [/* @__PURE__ */ c("span", { children: O }), /* @__PURE__ */ c("button", {
393
414
  type: "button",
394
- onClick: () => O(null),
395
- children: y.aiDismiss
415
+ onClick: () => k(null),
416
+ children: b.aiDismiss
396
417
  })]
397
418
  })
398
419
  ]