@marktoflow/gui 2.0.0-alpha.12 → 2.0.0-alpha.13

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 (121) hide show
  1. package/package.json +1 -3
  2. package/.marktoflow/state/workflow-state.db +0 -0
  3. package/.marktoflow/state/workflow-state.db-shm +0 -0
  4. package/.marktoflow/state/workflow-state.db-wal +0 -0
  5. package/.turbo/turbo-build.log +0 -42
  6. package/.turbo/turbo-test.log +0 -38
  7. package/marktoflow-gui-2.0.0-alpha.12.tgz +0 -0
  8. package/playwright.config.ts +0 -27
  9. package/postcss.config.js +0 -6
  10. package/src/client/App.tsx +0 -520
  11. package/src/client/components/Canvas/Canvas.tsx +0 -425
  12. package/src/client/components/Canvas/ExecutionOverlay.tsx +0 -935
  13. package/src/client/components/Canvas/ForEachNode.tsx +0 -152
  14. package/src/client/components/Canvas/IfElseNode.tsx +0 -141
  15. package/src/client/components/Canvas/NodeContextMenu.tsx +0 -192
  16. package/src/client/components/Canvas/OutputNode.tsx +0 -111
  17. package/src/client/components/Canvas/ParallelNode.tsx +0 -157
  18. package/src/client/components/Canvas/StepNode.tsx +0 -106
  19. package/src/client/components/Canvas/SubWorkflowNode.tsx +0 -141
  20. package/src/client/components/Canvas/SwitchNode.tsx +0 -185
  21. package/src/client/components/Canvas/Toolbar.tsx +0 -227
  22. package/src/client/components/Canvas/TransformNode.tsx +0 -194
  23. package/src/client/components/Canvas/TriggerNode.tsx +0 -128
  24. package/src/client/components/Canvas/TryCatchNode.tsx +0 -164
  25. package/src/client/components/Canvas/WhileNode.tsx +0 -161
  26. package/src/client/components/Canvas/index.ts +0 -24
  27. package/src/client/components/Debug/VariableInspector.tsx +0 -148
  28. package/src/client/components/Editor/InputsEditor.tsx +0 -458
  29. package/src/client/components/Editor/NewStepWizard.tsx +0 -344
  30. package/src/client/components/Editor/StepEditor.tsx +0 -532
  31. package/src/client/components/Editor/YamlEditor.tsx +0 -160
  32. package/src/client/components/Panels/PropertiesPanel.tsx +0 -589
  33. package/src/client/components/Prompt/ChangePreview.tsx +0 -281
  34. package/src/client/components/Prompt/PromptHistoryPanel.tsx +0 -209
  35. package/src/client/components/Prompt/PromptInput.tsx +0 -110
  36. package/src/client/components/Settings/ProviderSwitcher.tsx +0 -228
  37. package/src/client/components/Sidebar/ImportDialog.tsx +0 -257
  38. package/src/client/components/Sidebar/Sidebar.tsx +0 -362
  39. package/src/client/components/common/Breadcrumb.tsx +0 -40
  40. package/src/client/components/common/Button.tsx +0 -68
  41. package/src/client/components/common/ContextMenu.tsx +0 -202
  42. package/src/client/components/common/KeyboardShortcuts.tsx +0 -149
  43. package/src/client/components/common/Modal.tsx +0 -93
  44. package/src/client/components/common/Tabs.tsx +0 -57
  45. package/src/client/components/common/ThemeToggle.tsx +0 -63
  46. package/src/client/components/index.ts +0 -32
  47. package/src/client/hooks/index.ts +0 -4
  48. package/src/client/hooks/useAIPrompt.ts +0 -108
  49. package/src/client/hooks/useCanvas.ts +0 -247
  50. package/src/client/hooks/useWebSocket.ts +0 -164
  51. package/src/client/hooks/useWorkflow.ts +0 -138
  52. package/src/client/main.tsx +0 -10
  53. package/src/client/stores/agentStore.ts +0 -109
  54. package/src/client/stores/canvasStore.ts +0 -348
  55. package/src/client/stores/editorStore.ts +0 -133
  56. package/src/client/stores/executionStore.ts +0 -502
  57. package/src/client/stores/index.ts +0 -4
  58. package/src/client/stores/layoutStore.ts +0 -103
  59. package/src/client/stores/navigationStore.ts +0 -49
  60. package/src/client/stores/promptStore.ts +0 -113
  61. package/src/client/stores/themeStore.ts +0 -75
  62. package/src/client/stores/workflowStore.ts +0 -185
  63. package/src/client/styles/globals.css +0 -452
  64. package/src/client/utils/cn.ts +0 -9
  65. package/src/client/utils/index.ts +0 -4
  66. package/src/client/utils/platform.ts +0 -46
  67. package/src/client/utils/serviceIcons.tsx +0 -97
  68. package/src/client/utils/stepValidation.ts +0 -155
  69. package/src/client/utils/workflowToGraph.ts +0 -523
  70. package/src/server/index.ts +0 -137
  71. package/src/server/routes/ai.ts +0 -91
  72. package/src/server/routes/execute.ts +0 -71
  73. package/src/server/routes/executions.ts +0 -136
  74. package/src/server/routes/tools.ts +0 -970
  75. package/src/server/routes/workflows.ts +0 -147
  76. package/src/server/services/AIService.ts +0 -105
  77. package/src/server/services/FileWatcher.ts +0 -69
  78. package/src/server/services/WorkflowService.ts +0 -601
  79. package/src/server/services/agents/claude-code-provider.ts +0 -320
  80. package/src/server/services/agents/claude-provider.ts +0 -248
  81. package/src/server/services/agents/codex-provider.ts +0 -398
  82. package/src/server/services/agents/copilot-provider.ts +0 -311
  83. package/src/server/services/agents/demo-provider.ts +0 -184
  84. package/src/server/services/agents/index.ts +0 -31
  85. package/src/server/services/agents/ollama-provider.ts +0 -267
  86. package/src/server/services/agents/prompts.ts +0 -509
  87. package/src/server/services/agents/registry.ts +0 -310
  88. package/src/server/services/agents/types.ts +0 -146
  89. package/src/server/websocket/index.ts +0 -117
  90. package/src/shared/constants.ts +0 -180
  91. package/src/shared/types.ts +0 -179
  92. package/tailwind.config.ts +0 -73
  93. package/tests/e2e/app.spec.ts +0 -90
  94. package/tests/e2e/canvas.spec.ts +0 -128
  95. package/tests/e2e/workflow.spec.ts +0 -185
  96. package/tests/integration/api.test.ts +0 -452
  97. package/tests/integration/testApp.ts +0 -31
  98. package/tests/setup.ts +0 -72
  99. package/tests/unit/ForEachNode.test.tsx +0 -308
  100. package/tests/unit/IfElseNode.test.tsx +0 -235
  101. package/tests/unit/ParallelNode.test.tsx +0 -344
  102. package/tests/unit/SwitchNode.test.tsx +0 -327
  103. package/tests/unit/TransformNode.test.tsx +0 -386
  104. package/tests/unit/TryCatchNode.test.tsx +0 -243
  105. package/tests/unit/WhileNode.test.tsx +0 -230
  106. package/tests/unit/agentStore.test.ts +0 -218
  107. package/tests/unit/canvasStore.test.ts +0 -502
  108. package/tests/unit/codexProvider.test.ts +0 -399
  109. package/tests/unit/components.test.tsx +0 -151
  110. package/tests/unit/executionStore.test.ts +0 -567
  111. package/tests/unit/layoutStore.test.ts +0 -194
  112. package/tests/unit/navigationStore.test.ts +0 -152
  113. package/tests/unit/platform.test.ts +0 -118
  114. package/tests/unit/serviceIcons.test.ts +0 -197
  115. package/tests/unit/stepValidation.test.ts +0 -226
  116. package/tests/unit/themeStore.test.ts +0 -141
  117. package/tests/unit/workflowToGraph.test.ts +0 -311
  118. package/tsconfig.json +0 -29
  119. package/tsconfig.server.json +0 -28
  120. package/vite.config.ts +0 -31
  121. package/vitest.config.ts +0 -26
@@ -1,164 +0,0 @@
1
- import { memo } from 'react';
2
- import { Handle, Position, type Node, type NodeProps } from '@xyflow/react';
3
- import { Shield, CheckCircle, XCircle, Clock, AlertTriangle } from 'lucide-react';
4
-
5
- export interface TryCatchNodeData extends Record<string, unknown> {
6
- id: string;
7
- name?: string;
8
- hasCatch?: boolean;
9
- hasFinally?: boolean;
10
- status?: 'pending' | 'running' | 'completed' | 'failed' | 'skipped';
11
- activeBranch?: 'try' | 'catch' | 'finally' | null;
12
- errorOccurred?: boolean;
13
- }
14
-
15
- export type TryCatchNodeType = Node<TryCatchNodeData, 'try'>;
16
-
17
- function TryCatchNodeComponent({ data, selected }: NodeProps<TryCatchNodeType>) {
18
- const statusConfig: Record<
19
- NonNullable<TryCatchNodeData['status']>,
20
- { icon: typeof Clock; color: string; bgColor: string; animate?: boolean }
21
- > = {
22
- pending: { icon: Clock, color: 'text-gray-400', bgColor: 'bg-gray-400/10' },
23
- running: {
24
- icon: Shield,
25
- color: 'text-yellow-400',
26
- bgColor: 'bg-yellow-400/10',
27
- animate: true,
28
- },
29
- completed: {
30
- icon: CheckCircle,
31
- color: 'text-success',
32
- bgColor: 'bg-success/10',
33
- },
34
- failed: { icon: XCircle, color: 'text-error', bgColor: 'bg-error/10' },
35
- skipped: {
36
- icon: XCircle,
37
- color: 'text-gray-500',
38
- bgColor: 'bg-gray-500/10',
39
- },
40
- };
41
-
42
- const status = data.status || 'pending';
43
- const config = statusConfig[status];
44
- const StatusIcon = config.icon;
45
-
46
- return (
47
- <div
48
- className={`control-flow-node try-catch-node p-0 ${selected ? 'selected' : ''} ${status === 'running' ? 'running' : ''}`}
49
- style={{
50
- background: 'linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%)',
51
- }}
52
- >
53
- {/* Input handle */}
54
- <Handle
55
- type="target"
56
- position={Position.Top}
57
- className="!w-3 !h-3 !bg-primary !border-2 !border-node-bg"
58
- />
59
-
60
- {/* Node header */}
61
- <div className="flex items-center gap-3 p-3 border-b border-white/20">
62
- <div className="w-8 h-8 rounded-lg bg-white/20 flex items-center justify-center">
63
- <Shield className="w-5 h-5 text-white" />
64
- </div>
65
- <div className="flex-1 min-w-0">
66
- <div className="text-sm font-medium text-white">
67
- {data.name || 'Try/Catch'}
68
- </div>
69
- <div className="text-xs text-white/70">Error Handling</div>
70
- </div>
71
- <div
72
- className={`w-6 h-6 rounded-full ${config.bgColor} flex items-center justify-center`}
73
- >
74
- <StatusIcon
75
- className={`w-4 h-4 ${config.color} ${config.animate ? 'animate-pulse' : ''}`}
76
- />
77
- </div>
78
- </div>
79
-
80
- {/* Node body */}
81
- <div className="p-3 bg-white/10">
82
- {/* Error indicator */}
83
- {data.errorOccurred && (
84
- <div className="mb-3 p-2 bg-red-500/20 border border-red-500/30 rounded flex items-center gap-2">
85
- <AlertTriangle className="w-4 h-4 text-red-200" />
86
- <span className="text-xs text-red-200 font-medium">Error occurred</span>
87
- </div>
88
- )}
89
-
90
- {/* Branch indicators */}
91
- <div className="space-y-2">
92
- <div
93
- className={`text-center p-2 rounded text-xs font-medium transition-colors ${
94
- data.activeBranch === 'try'
95
- ? 'bg-blue-500/30 text-blue-200 ring-1 ring-blue-400/50'
96
- : 'bg-white/5 text-white/60'
97
- }`}
98
- >
99
- ✓ Try
100
- </div>
101
-
102
- {data.hasCatch && (
103
- <div
104
- className={`text-center p-2 rounded text-xs font-medium transition-colors ${
105
- data.activeBranch === 'catch'
106
- ? 'bg-red-500/30 text-red-200 ring-1 ring-red-400/50'
107
- : 'bg-white/5 text-white/60'
108
- }`}
109
- >
110
- ⚠ Catch
111
- </div>
112
- )}
113
-
114
- {data.hasFinally && (
115
- <div
116
- className={`text-center p-2 rounded text-xs font-medium transition-colors ${
117
- data.activeBranch === 'finally'
118
- ? 'bg-purple-500/30 text-purple-200 ring-1 ring-purple-400/50'
119
- : 'bg-white/5 text-white/60'
120
- }`}
121
- >
122
- ⟳ Finally
123
- </div>
124
- )}
125
- </div>
126
-
127
- {/* Info */}
128
- <div className="mt-3 text-xs text-white/50 flex items-center gap-2">
129
- <span>ℹ️</span>
130
- <span>Finally always executes</span>
131
- </div>
132
- </div>
133
-
134
- {/* Output handles */}
135
- <Handle
136
- type="source"
137
- position={Position.Bottom}
138
- id="try"
139
- style={{ left: '25%' }}
140
- className="!w-2.5 !h-2.5 !bg-blue-500 !border-2 !border-node-bg"
141
- />
142
- {data.hasCatch && (
143
- <Handle
144
- type="source"
145
- position={Position.Bottom}
146
- id="catch"
147
- style={{ left: '50%' }}
148
- className="!w-2.5 !h-2.5 !bg-red-500 !border-2 !border-node-bg"
149
- />
150
- )}
151
- {data.hasFinally && (
152
- <Handle
153
- type="source"
154
- position={Position.Bottom}
155
- id="finally"
156
- style={{ left: '75%' }}
157
- className="!w-2.5 !h-2.5 !bg-purple-500 !border-2 !border-node-bg"
158
- />
159
- )}
160
- </div>
161
- );
162
- }
163
-
164
- export const TryCatchNode = memo(TryCatchNodeComponent);
@@ -1,161 +0,0 @@
1
- import { memo } from 'react';
2
- import { Handle, Position, type Node, type NodeProps } from '@xyflow/react';
3
- import { RotateCw, CheckCircle, XCircle, Clock, LogOut, AlertTriangle } from 'lucide-react';
4
-
5
- export interface WhileNodeData extends Record<string, unknown> {
6
- id: string;
7
- name?: string;
8
- condition: string;
9
- maxIterations?: number;
10
- status?: 'pending' | 'running' | 'completed' | 'failed' | 'skipped';
11
- currentIteration?: number;
12
- earlyExit?: boolean;
13
- exitReason?: 'break' | 'max_iterations' | 'error';
14
- }
15
-
16
- export type WhileNodeType = Node<WhileNodeData, 'while'>;
17
-
18
- function WhileNodeComponent({ data, selected }: NodeProps<WhileNodeType>) {
19
- const statusConfig: Record<
20
- NonNullable<WhileNodeData['status']>,
21
- { icon: typeof Clock; color: string; bgColor: string; animate?: boolean }
22
- > = {
23
- pending: { icon: Clock, color: 'text-gray-400', bgColor: 'bg-gray-400/10' },
24
- running: {
25
- icon: RotateCw,
26
- color: 'text-orange-400',
27
- bgColor: 'bg-orange-400/10',
28
- animate: true,
29
- },
30
- completed: {
31
- icon: CheckCircle,
32
- color: 'text-success',
33
- bgColor: 'bg-success/10',
34
- },
35
- failed: { icon: XCircle, color: 'text-error', bgColor: 'bg-error/10' },
36
- skipped: {
37
- icon: XCircle,
38
- color: 'text-gray-500',
39
- bgColor: 'bg-gray-500/10',
40
- },
41
- };
42
-
43
- const status = data.status || 'pending';
44
- const config = statusConfig[status];
45
- const StatusIcon = config.icon;
46
-
47
- return (
48
- <div
49
- className={`control-flow-node while-node p-0 ${selected ? 'selected' : ''} ${status === 'running' ? 'running' : ''} ${status === 'completed' ? 'completed' : ''} ${status === 'failed' ? 'failed' : ''}`}
50
- style={{
51
- background: 'linear-gradient(135deg, #fb923c 0%, #f97316 100%)',
52
- }}
53
- >
54
- {/* Input handle */}
55
- <Handle
56
- type="target"
57
- position={Position.Top}
58
- className="!w-3 !h-3 !bg-primary !border-2 !border-node-bg"
59
- />
60
-
61
- {/* Node header */}
62
- <div className="flex items-center gap-3 p-3 border-b border-white/20">
63
- <div className="w-8 h-8 rounded-lg bg-white/20 flex items-center justify-center">
64
- <RotateCw className="w-5 h-5 text-white" />
65
- </div>
66
- <div className="flex-1 min-w-0">
67
- <div className="text-sm font-medium text-white">
68
- {data.name || 'While'}
69
- </div>
70
- <div className="text-xs text-white/70">Loop</div>
71
- </div>
72
- <div
73
- className={`w-6 h-6 rounded-full ${config.bgColor} flex items-center justify-center`}
74
- >
75
- <StatusIcon
76
- className={`w-4 h-4 ${config.color} ${config.animate ? 'animate-pulse' : ''}`}
77
- />
78
- </div>
79
- </div>
80
-
81
- {/* Node body */}
82
- <div className="p-3 bg-white/10">
83
- <div className="text-xs text-white/90 mb-3">
84
- <span className="text-white/60">Condition:</span>{' '}
85
- <span className="font-mono">{data.condition || 'Not set'}</span>
86
- </div>
87
-
88
- {/* Max iterations */}
89
- <div className="text-xs text-white/90 mb-3">
90
- <span className="text-white/60">Max Iterations:</span>{' '}
91
- <span className="font-medium">{data.maxIterations || 100}</span>
92
- </div>
93
-
94
- {/* Early exit indicator */}
95
- {data.earlyExit && (
96
- <div className="mb-3 p-2 bg-orange-500/20 border border-orange-500/30 rounded flex items-center gap-2">
97
- {data.exitReason === 'max_iterations' ? (
98
- <AlertTriangle className="w-4 h-4 text-orange-200" />
99
- ) : (
100
- <LogOut className="w-4 h-4 text-orange-200" />
101
- )}
102
- <span className="text-xs text-orange-200 font-medium">
103
- {data.exitReason === 'break'
104
- ? 'Loop exited early (break)'
105
- : data.exitReason === 'max_iterations'
106
- ? 'Max iterations reached'
107
- : 'Loop stopped on error'}
108
- </span>
109
- </div>
110
- )}
111
-
112
- {/* Current iteration counter */}
113
- {data.currentIteration !== undefined && (
114
- <div className="mt-2 p-2 bg-white/5 rounded">
115
- <div className="flex items-center justify-between mb-1">
116
- <span className="text-xs text-white/70">Iterations</span>
117
- <span className="text-xs text-white font-medium">
118
- {data.currentIteration} / {data.maxIterations || 100}
119
- {data.earlyExit && (
120
- <span className="ml-1 text-orange-300 text-[10px]">(stopped)</span>
121
- )}
122
- </span>
123
- </div>
124
- <div className="w-full bg-white/10 rounded-full h-1.5">
125
- <div
126
- className={`h-1.5 rounded-full transition-all ${data.earlyExit ? 'bg-orange-400' : 'bg-orange-500'}`}
127
- style={{
128
- width: `${(data.currentIteration / (data.maxIterations || 100)) * 100}%`,
129
- }}
130
- />
131
- </div>
132
- </div>
133
- )}
134
-
135
- {/* Loop metadata */}
136
- <div className="mt-3 text-xs text-white/50 flex items-center gap-2">
137
- <span>⚠️</span>
138
- <span>Exits when condition becomes false</span>
139
- </div>
140
- </div>
141
-
142
- {/* Output handle */}
143
- <Handle
144
- type="source"
145
- position={Position.Bottom}
146
- className="!w-3 !h-3 !bg-primary !border-2 !border-node-bg"
147
- />
148
-
149
- {/* Loop-back handle (left side for iteration feedback) */}
150
- <Handle
151
- id="loop-back"
152
- type="source"
153
- position={Position.Left}
154
- className="!w-3 !h-3 !bg-orange-500 !border-2 !border-node-bg"
155
- style={{ top: '50%', left: '-6px' }}
156
- />
157
- </div>
158
- );
159
- }
160
-
161
- export const WhileNode = memo(WhileNodeComponent);
@@ -1,24 +0,0 @@
1
- // Export all canvas components
2
- export { Canvas } from './Canvas';
3
- export { StepNode } from './StepNode';
4
- export { SubWorkflowNode } from './SubWorkflowNode';
5
- export { TriggerNode } from './TriggerNode';
6
- export { OutputNode } from './OutputNode';
7
-
8
- // Control flow nodes
9
- export { IfElseNode } from './IfElseNode';
10
- export { ForEachNode } from './ForEachNode';
11
- export { WhileNode } from './WhileNode';
12
- export { SwitchNode } from './SwitchNode';
13
- export { ParallelNode } from './ParallelNode';
14
- export { TryCatchNode } from './TryCatchNode';
15
- export { TransformNode } from './TransformNode';
16
-
17
- // Export types
18
- export type { IfElseNodeData, IfElseNodeType } from './IfElseNode';
19
- export type { ForEachNodeData, ForEachNodeType } from './ForEachNode';
20
- export type { WhileNodeData, WhileNodeType } from './WhileNode';
21
- export type { SwitchNodeData, SwitchNodeType } from './SwitchNode';
22
- export type { ParallelNodeData, ParallelNodeType } from './ParallelNode';
23
- export type { TryCatchNodeData, TryCatchNodeType } from './TryCatchNode';
24
- export type { TransformNodeData, TransformNodeType } from './TransformNode';
@@ -1,148 +0,0 @@
1
- /**
2
- * Variable Inspector Component
3
- * Displays JSON data with syntax highlighting and expand/collapse functionality
4
- */
5
-
6
- import { useState } from 'react';
7
- import { ChevronRight, ChevronDown, Copy, Check } from 'lucide-react';
8
-
9
- interface VariableInspectorProps {
10
- data: unknown;
11
- name?: string;
12
- expanded?: boolean;
13
- }
14
-
15
- export function VariableInspector({ data, name, expanded = true }: VariableInspectorProps) {
16
- return (
17
- <div className="font-mono text-sm">
18
- <JsonNode value={data} name={name} depth={0} initiallyExpanded={expanded} />
19
- </div>
20
- );
21
- }
22
-
23
- interface JsonNodeProps {
24
- value: unknown;
25
- name?: string;
26
- depth: number;
27
- initiallyExpanded?: boolean;
28
- }
29
-
30
- function JsonNode({ value, name, depth, initiallyExpanded = true }: JsonNodeProps) {
31
- const [isExpanded, setIsExpanded] = useState(initiallyExpanded);
32
- const [copied, setCopied] = useState(false);
33
-
34
- const indent = depth * 16;
35
- const isObject = value !== null && typeof value === 'object' && !Array.isArray(value);
36
- const isArray = Array.isArray(value);
37
- const isExpandable = isObject || isArray;
38
-
39
- const handleCopy = () => {
40
- navigator.clipboard.writeText(JSON.stringify(value, null, 2));
41
- setCopied(true);
42
- setTimeout(() => setCopied(false), 2000);
43
- };
44
-
45
- const getValueColor = (val: unknown): string => {
46
- if (val === null) return 'text-gray-500';
47
- if (typeof val === 'string') return 'text-green-400';
48
- if (typeof val === 'number') return 'text-blue-400';
49
- if (typeof val === 'boolean') return 'text-purple-400';
50
- return 'text-gray-300';
51
- };
52
-
53
- const renderValue = (val: unknown): string => {
54
- if (val === null) return 'null';
55
- if (val === undefined) return 'undefined';
56
- if (typeof val === 'string') return `"${val}"`;
57
- if (typeof val === 'number' || typeof val === 'boolean') return String(val);
58
- return '';
59
- };
60
-
61
- if (!isExpandable) {
62
- return (
63
- <div className="flex items-center gap-2 py-0.5 hover:bg-white/5 rounded px-1" style={{ paddingLeft: indent }}>
64
- {name && (
65
- <>
66
- <span className="text-cyan-400">{name}</span>
67
- <span className="text-gray-500">:</span>
68
- </>
69
- )}
70
- <span className={getValueColor(value)}>{renderValue(value)}</span>
71
- </div>
72
- );
73
- }
74
-
75
- const entries = isArray
76
- ? (value as unknown[]).map((v, i) => [String(i), v] as [string, unknown])
77
- : Object.entries(value as Record<string, unknown>);
78
-
79
- const preview = isArray
80
- ? `Array(${entries.length})`
81
- : `Object {${entries.length} ${entries.length === 1 ? 'key' : 'keys'}}`;
82
-
83
- return (
84
- <div>
85
- <div
86
- className="flex items-center gap-2 py-0.5 hover:bg-white/5 rounded px-1 cursor-pointer group"
87
- style={{ paddingLeft: indent }}
88
- onClick={() => setIsExpanded(!isExpanded)}
89
- >
90
- <button className="text-gray-500 hover:text-white">
91
- {isExpanded ? (
92
- <ChevronDown className="w-3 h-3" />
93
- ) : (
94
- <ChevronRight className="w-3 h-3" />
95
- )}
96
- </button>
97
-
98
- {name && (
99
- <>
100
- <span className="text-cyan-400">{name}</span>
101
- <span className="text-gray-500">:</span>
102
- </>
103
- )}
104
-
105
- <span className="text-gray-500">
106
- {isArray ? '[' : '{'}
107
- {!isExpanded && <span className="text-gray-600 ml-1">{preview}</span>}
108
- </span>
109
-
110
- <button
111
- onClick={(e) => {
112
- e.stopPropagation();
113
- handleCopy();
114
- }}
115
- className="ml-auto opacity-0 group-hover:opacity-100 transition-opacity"
116
- title="Copy to clipboard"
117
- >
118
- {copied ? (
119
- <Check className="w-3 h-3 text-green-400" />
120
- ) : (
121
- <Copy className="w-3 h-3 text-gray-500 hover:text-white" />
122
- )}
123
- </button>
124
- </div>
125
-
126
- {isExpanded && (
127
- <>
128
- {entries.map(([key, val]) => (
129
- <JsonNode
130
- key={key}
131
- name={isArray ? undefined : key}
132
- value={val}
133
- depth={depth + 1}
134
- initiallyExpanded={depth < 1}
135
- />
136
- ))}
137
- <div className="text-gray-500 py-0.5 px-1" style={{ paddingLeft: indent }}>
138
- {isArray ? ']' : '}'}
139
- </div>
140
- </>
141
- )}
142
-
143
- {!isExpanded && (
144
- <div className="text-gray-500 inline">{isArray ? ']' : '}'}</div>
145
- )}
146
- </div>
147
- );
148
- }