@abhinav2203/codeflow-canvas 0.1.0
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.
- package/abhinav2203-codeflow-canvas-0.1.0.tgz +0 -0
- package/dist/bin/cli.d.ts +3 -0
- package/dist/bin/cli.d.ts.map +1 -0
- package/dist/bin/cli.js +84 -0
- package/dist/bin/cli.js.map +1 -0
- package/dist/components/blueprint-workbench.d.ts +2 -0
- package/dist/components/blueprint-workbench.d.ts.map +1 -0
- package/dist/components/blueprint-workbench.js +144 -0
- package/dist/components/blueprint-workbench.js.map +1 -0
- package/dist/components/code-diff-editor.d.ts +12 -0
- package/dist/components/code-diff-editor.d.ts.map +1 -0
- package/dist/components/code-diff-editor.js +39 -0
- package/dist/components/code-diff-editor.js.map +1 -0
- package/dist/components/code-editor.d.ts +25 -0
- package/dist/components/code-editor.d.ts.map +1 -0
- package/dist/components/code-editor.js +264 -0
- package/dist/components/code-editor.js.map +1 -0
- package/dist/components/file-tabs.d.ts +5 -0
- package/dist/components/file-tabs.d.ts.map +1 -0
- package/dist/components/file-tabs.js +164 -0
- package/dist/components/file-tabs.js.map +1 -0
- package/dist/components/file-tree.d.ts +7 -0
- package/dist/components/file-tree.d.ts.map +1 -0
- package/dist/components/file-tree.js +176 -0
- package/dist/components/file-tree.js.map +1 -0
- package/dist/components/graph-canvas.d.ts +25 -0
- package/dist/components/graph-canvas.d.ts.map +1 -0
- package/dist/components/graph-canvas.js +224 -0
- package/dist/components/graph-canvas.js.map +1 -0
- package/dist/components/ide-layout.d.ts +10 -0
- package/dist/components/ide-layout.d.ts.map +1 -0
- package/dist/components/ide-layout.js +40 -0
- package/dist/components/ide-layout.js.map +1 -0
- package/dist/components/ide-workbench.d.ts +4 -0
- package/dist/components/ide-workbench.d.ts.map +1 -0
- package/dist/components/ide-workbench.js +6 -0
- package/dist/components/ide-workbench.js.map +1 -0
- package/dist/components/index.d.ts +13 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +13 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/monaco-setup.d.ts +4 -0
- package/dist/components/monaco-setup.d.ts.map +1 -0
- package/dist/components/monaco-setup.js +34 -0
- package/dist/components/monaco-setup.js.map +1 -0
- package/dist/components/opencode-settings.d.ts +8 -0
- package/dist/components/opencode-settings.d.ts.map +1 -0
- package/dist/components/opencode-settings.js +33 -0
- package/dist/components/opencode-settings.js.map +1 -0
- package/dist/components/policy-workbench.d.ts +2 -0
- package/dist/components/policy-workbench.d.ts.map +1 -0
- package/dist/components/policy-workbench.js +102 -0
- package/dist/components/policy-workbench.js.map +1 -0
- package/dist/components/ts-language-service.d.ts +14 -0
- package/dist/components/ts-language-service.d.ts.map +1 -0
- package/dist/components/ts-language-service.js +123 -0
- package/dist/components/ts-language-service.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/browser/storage.d.ts +16 -0
- package/dist/lib/browser/storage.d.ts.map +1 -0
- package/dist/lib/browser/storage.js +18 -0
- package/dist/lib/browser/storage.js.map +1 -0
- package/dist/lib/edit.d.ts +14 -0
- package/dist/lib/edit.d.ts.map +1 -0
- package/dist/lib/edit.js +57 -0
- package/dist/lib/edit.js.map +1 -0
- package/dist/lib/flow-view.d.ts +80 -0
- package/dist/lib/flow-view.d.ts.map +1 -0
- package/dist/lib/flow-view.js +850 -0
- package/dist/lib/flow-view.js.map +1 -0
- package/dist/lib/heatmap.d.ts +28 -0
- package/dist/lib/heatmap.d.ts.map +1 -0
- package/dist/lib/heatmap.js +61 -0
- package/dist/lib/heatmap.js.map +1 -0
- package/dist/lib/index.d.ts +9 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +6 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/node-navigation.d.ts +36 -0
- package/dist/lib/node-navigation.d.ts.map +1 -0
- package/dist/lib/node-navigation.js +52 -0
- package/dist/lib/node-navigation.js.map +1 -0
- package/dist/lib/traces.d.ts +3 -0
- package/dist/lib/traces.d.ts.map +1 -0
- package/dist/lib/traces.js +64 -0
- package/dist/lib/traces.js.map +1 -0
- package/dist/lib/types.d.ts +57 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +7 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/store/blueprint-store.d.ts +35 -0
- package/dist/store/blueprint-store.d.ts.map +1 -0
- package/dist/store/blueprint-store.js +79 -0
- package/dist/store/blueprint-store.js.map +1 -0
- package/dist/store/index.d.ts +3 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +2 -0
- package/dist/store/index.js.map +1 -0
- package/package.json +52 -0
- package/scripts/wrap-cli.mjs +15 -0
- package/src/bin/cli.ts +128 -0
- package/src/components/blueprint-workbench.tsx +305 -0
- package/src/components/code-diff-editor.tsx +80 -0
- package/src/components/code-editor.tsx +389 -0
- package/src/components/file-tabs.tsx +288 -0
- package/src/components/file-tree.tsx +301 -0
- package/src/components/graph-canvas.tsx +404 -0
- package/src/components/ide-layout.tsx +104 -0
- package/src/components/ide-workbench.tsx +5 -0
- package/src/components/index.ts +12 -0
- package/src/components/monaco-setup.ts +67 -0
- package/src/components/opencode-settings.tsx +82 -0
- package/src/components/policy-workbench.tsx +233 -0
- package/src/components/ts-language-service.ts +170 -0
- package/src/index.ts +54 -0
- package/src/lib/browser/storage.ts +19 -0
- package/src/lib/edit.ts +74 -0
- package/src/lib/flow-view.ts +1176 -0
- package/src/lib/heatmap.ts +103 -0
- package/src/lib/index.ts +41 -0
- package/src/lib/node-navigation.ts +76 -0
- package/src/lib/traces.ts +79 -0
- package/src/lib/types.ts +79 -0
- package/src/store/blueprint-store.ts +136 -0
- package/src/store/index.ts +2 -0
- package/test-fixtures/minimal-blueprint.json +34 -0
- package/test-fixtures/sample-blueprint.json +184 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.json +22 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/vitest.config.ts +9 -0
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/bin/cli.ts"],"names":[],"mappings":""}
|
package/dist/bin/cli.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import { resolve, dirname } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
6
|
+
function renderJson(graph, options) {
|
|
7
|
+
if (options.nodeId) {
|
|
8
|
+
const node = graph.nodes.find((n) => n.id === options.nodeId);
|
|
9
|
+
if (!node) {
|
|
10
|
+
return JSON.stringify({ error: `Node ${options.nodeId} not found` }, null, 2);
|
|
11
|
+
}
|
|
12
|
+
return JSON.stringify(node, null, 2);
|
|
13
|
+
}
|
|
14
|
+
return JSON.stringify(graph, null, 2);
|
|
15
|
+
}
|
|
16
|
+
function renderText(graph) {
|
|
17
|
+
const lines = [];
|
|
18
|
+
lines.push(`# ${graph.projectName}`);
|
|
19
|
+
lines.push(`Phase: ${graph.phase}`);
|
|
20
|
+
lines.push("");
|
|
21
|
+
lines.push("## Nodes");
|
|
22
|
+
for (const node of graph.nodes) {
|
|
23
|
+
lines.push(`- [${node.kind}] ${node.name}: ${node.summary}`);
|
|
24
|
+
}
|
|
25
|
+
lines.push("");
|
|
26
|
+
lines.push("## Edges");
|
|
27
|
+
for (const edge of graph.edges) {
|
|
28
|
+
lines.push(`- ${edge.from} --[${edge.kind}]--> ${edge.to}`);
|
|
29
|
+
}
|
|
30
|
+
return lines.join("\n");
|
|
31
|
+
}
|
|
32
|
+
async function main() {
|
|
33
|
+
const args = process.argv.slice(2);
|
|
34
|
+
let filePath;
|
|
35
|
+
let command = "render";
|
|
36
|
+
const options = { format: "json" };
|
|
37
|
+
for (let i = 0; i < args.length; i++) {
|
|
38
|
+
if (args[i] === "render" && i + 1 < args.length) {
|
|
39
|
+
command = "render";
|
|
40
|
+
filePath = args[++i];
|
|
41
|
+
}
|
|
42
|
+
else if (args[i] === "--format" && i + 1 < args.length) {
|
|
43
|
+
options.format = args[++i];
|
|
44
|
+
}
|
|
45
|
+
else if (args[i] === "--node" && i + 1 < args.length) {
|
|
46
|
+
options.nodeId = args[++i];
|
|
47
|
+
}
|
|
48
|
+
else if (!args[i].startsWith("--")) {
|
|
49
|
+
filePath = args[i];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (!filePath) {
|
|
53
|
+
console.error("Usage: codeflow-canvas render <file> [--format json|text] [--node <id>]");
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
const resolvedPath = resolve(filePath);
|
|
57
|
+
let graph;
|
|
58
|
+
try {
|
|
59
|
+
const content = readFileSync(resolvedPath, "utf-8");
|
|
60
|
+
graph = JSON.parse(content);
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
console.error(`Failed to read or parse blueprint file: ${resolvedPath}`);
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
switch (command) {
|
|
67
|
+
case "render":
|
|
68
|
+
if (options.format === "text") {
|
|
69
|
+
console.log(renderText(graph));
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
console.log(renderJson(graph, options));
|
|
73
|
+
}
|
|
74
|
+
break;
|
|
75
|
+
default:
|
|
76
|
+
console.error(`Unknown command: ${command}`);
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
main().catch((err) => {
|
|
81
|
+
console.error("CLI error:", err);
|
|
82
|
+
process.exit(1);
|
|
83
|
+
});
|
|
84
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/bin/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE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,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;IACjC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blueprint-workbench.d.ts","sourceRoot":"","sources":["../../src/components/blueprint-workbench.tsx"],"names":[],"mappings":"AAmIA,wBAAgB,kBAAkB,4CA6KjC"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { useMemo, useRef, useState } from "react";
|
|
5
|
+
import { useBlueprintStore } from "../store/blueprint-store.js";
|
|
6
|
+
import { GraphCanvas } from "./graph-canvas.js";
|
|
7
|
+
import { buildDetailFlow, indexRuntimeExecutionResult } from "../lib/flow-view.js";
|
|
8
|
+
import { computeHeatmap } from "../lib/heatmap.js";
|
|
9
|
+
import { traceSpanSchema } from "@abhinav2203/codeflow-core/schema";
|
|
10
|
+
const tracesSchema = z.array(traceSpanSchema);
|
|
11
|
+
const maskApiKey = (value) => {
|
|
12
|
+
const trimmed = value.trim();
|
|
13
|
+
if (trimmed.length <= 8) {
|
|
14
|
+
return trimmed;
|
|
15
|
+
}
|
|
16
|
+
return `${trimmed.slice(0, 4)}...${trimmed.slice(-4)}`;
|
|
17
|
+
};
|
|
18
|
+
export function BlueprintWorkbench() {
|
|
19
|
+
const { activeFile, floatingGraph, graph, openFiles, repoPath, selectedNodeId, setActiveFile, setFloatingGraph, setGraph, setOpenFiles, setRepoPath, setSelectedNodeId } = useBlueprintStore();
|
|
20
|
+
const MIN_OBSERVABILITY_INTERVAL_SECS = 2;
|
|
21
|
+
const [projectName, setProjectName] = useState("CodeFlow Workspace");
|
|
22
|
+
const [prdText, setPrdText] = useState("");
|
|
23
|
+
const [aiPrompt, setAiPrompt] = useState("");
|
|
24
|
+
const [nvidiaApiKey, setNvidiaApiKey] = useState("");
|
|
25
|
+
const [executionMode, setExecutionMode] = useState("essential");
|
|
26
|
+
const [outputDir, setOutputDir] = useState("");
|
|
27
|
+
const [traceInput, setTraceInput] = useState("");
|
|
28
|
+
const [runInput, setRunInput] = useState("{}");
|
|
29
|
+
const [error, setError] = useState(null);
|
|
30
|
+
const [busyLabel, setBusyLabel] = useState(null);
|
|
31
|
+
const [exportResult, setExportResult] = useState(null);
|
|
32
|
+
const [runPlan, setRunPlan] = useState(null);
|
|
33
|
+
const [riskReport, setRiskReport] = useState(null);
|
|
34
|
+
const [session, setSession] = useState(null);
|
|
35
|
+
const [pendingApproval, setPendingApproval] = useState(null);
|
|
36
|
+
const [executionResult, setExecutionResult] = useState(null);
|
|
37
|
+
const [latestLogs, setLatestLogs] = useState([]);
|
|
38
|
+
const [latestSpans, setLatestSpans] = useState([]);
|
|
39
|
+
const [conflictReport, setConflictReport] = useState(null);
|
|
40
|
+
const [newNodeName, setNewNodeName] = useState("");
|
|
41
|
+
const [newNodeKind, setNewNodeKind] = useState("function");
|
|
42
|
+
const [edgeFrom, setEdgeFrom] = useState("");
|
|
43
|
+
const [edgeTo, setEdgeTo] = useState("");
|
|
44
|
+
const [edgeKind, setEdgeKind] = useState("calls");
|
|
45
|
+
const [useAI, setUseAI] = useState(true);
|
|
46
|
+
const [drilldownStack, setDrilldownStack] = useState([]);
|
|
47
|
+
const [selectedDetailNodeId, setSelectedDetailNodeId] = useState(null);
|
|
48
|
+
const [codeDrafts, setCodeDrafts] = useState({});
|
|
49
|
+
const [suggestionInstruction, setSuggestionInstruction] = useState("");
|
|
50
|
+
const [codeSuggestion, setCodeSuggestion] = useState(null);
|
|
51
|
+
const [liveCompletionsEnabled, setLiveCompletionsEnabled] = useState(true);
|
|
52
|
+
const [serverApiKeyConfigured, setServerApiKeyConfigured] = useState(false);
|
|
53
|
+
const [apiKeyStatusLoaded, setApiKeyStatusLoaded] = useState(false);
|
|
54
|
+
const [statusTitle, setStatusTitle] = useState("Ready to build");
|
|
55
|
+
const [statusDetail, setStatusDetail] = useState("Enter a project description or repo input, then build a blueprint.");
|
|
56
|
+
const [statusTone, setStatusTone] = useState("info");
|
|
57
|
+
const [activeDockTab, setActiveDockTab] = useState("terminal");
|
|
58
|
+
const [activityFeed, setActivityFeed] = useState([]);
|
|
59
|
+
const [showSettings, setShowSettings] = useState(false);
|
|
60
|
+
const [showPromptPanel, setShowPromptPanel] = useState(true);
|
|
61
|
+
const [showEditPanel, setShowEditPanel] = useState(false);
|
|
62
|
+
const [showInspector, setShowInspector] = useState(false);
|
|
63
|
+
const [showObservabilityPanel, setShowObservabilityPanel] = useState(false);
|
|
64
|
+
const [autoObservability, setAutoObservability] = useState(false);
|
|
65
|
+
const [observabilityIntervalSecs, setObservabilityIntervalSecs] = useState(5);
|
|
66
|
+
const autoObsRef = useRef(autoObservability);
|
|
67
|
+
autoObsRef.current = autoObservability;
|
|
68
|
+
const [autoImplementNodes, setAutoImplementNodes] = useState(false);
|
|
69
|
+
const [cycleReport, setCycleReport] = useState(null);
|
|
70
|
+
const [smellReport, setSmellReport] = useState(null);
|
|
71
|
+
const [graphMetrics, setGraphMetrics] = useState(null);
|
|
72
|
+
const [mermaidDiagram, setMermaidDiagram] = useState(null);
|
|
73
|
+
const [ghostSuggestions, setGhostSuggestions] = useState([]);
|
|
74
|
+
const [showMcpPanel, setShowMcpPanel] = useState(false);
|
|
75
|
+
const [mcpServerUrl, setMcpServerUrl] = useState("");
|
|
76
|
+
const [mcpHeadersJson, setMcpHeadersJson] = useState("{}");
|
|
77
|
+
const [mcpToolName, setMcpToolName] = useState("");
|
|
78
|
+
const [mcpToolArgsJson, setMcpToolArgsJson] = useState("{}");
|
|
79
|
+
const [availableMcpTools, setAvailableMcpTools] = useState([]);
|
|
80
|
+
const [mcpInvokeResult, setMcpInvokeResult] = useState(null);
|
|
81
|
+
const [mcpError, setMcpError] = useState(null);
|
|
82
|
+
const [branches, setBranches] = useState([]);
|
|
83
|
+
const [showBranchPanel, setShowBranchPanel] = useState(false);
|
|
84
|
+
const [newBranchName, setNewBranchName] = useState("");
|
|
85
|
+
const [newBranchDescription, setNewBranchDescription] = useState("");
|
|
86
|
+
const [activeBranchId, setActiveBranchId] = useState(null);
|
|
87
|
+
const [branchDiff, setBranchDiff] = useState(null);
|
|
88
|
+
const [diffTargetBranchId, setDiffTargetBranchId] = useState(null);
|
|
89
|
+
const [showVcrPanel, setShowVcrPanel] = useState(false);
|
|
90
|
+
const [vcrRecording, setVcrRecording] = useState(null);
|
|
91
|
+
const [vcrFrameIndex, setVcrFrameIndex] = useState(0);
|
|
92
|
+
const [vcrPlaying, setVcrPlaying] = useState(false);
|
|
93
|
+
const [vcrGraph, setVcrGraph] = useState(null);
|
|
94
|
+
const [vcrError, setVcrError] = useState(null);
|
|
95
|
+
const [showDigitalTwinPanel, setShowDigitalTwinPanel] = useState(false);
|
|
96
|
+
const [digitalTwinSnapshot, setDigitalTwinSnapshot] = useState(null);
|
|
97
|
+
const [digitalTwinGraph, setDigitalTwinGraph] = useState(null);
|
|
98
|
+
const [digitalTwinWindowSecs, setDigitalTwinWindowSecs] = useState(60);
|
|
99
|
+
const [autoDigitalTwin, setAutoDigitalTwin] = useState(false);
|
|
100
|
+
const autoDigitalTwinRef = useRef(autoDigitalTwin);
|
|
101
|
+
autoDigitalTwinRef.current = autoDigitalTwin;
|
|
102
|
+
const [simulateNodeIds, setSimulateNodeIds] = useState("");
|
|
103
|
+
const [simulateLabel, setSimulateLabel] = useState("");
|
|
104
|
+
const [digitalTwinError, setDigitalTwinError] = useState(null);
|
|
105
|
+
const [digitalTwinPollError, setDigitalTwinPollError] = useState(null);
|
|
106
|
+
const [digitalTwinLastUpdatedAt, setDigitalTwinLastUpdatedAt] = useState(null);
|
|
107
|
+
const [showRefactorPanel, setShowRefactorPanel] = useState(false);
|
|
108
|
+
const [refactorReport, setRefactorReport] = useState(null);
|
|
109
|
+
const [healResult, setHealResult] = useState(null);
|
|
110
|
+
const [refactorError, setRefactorError] = useState(null);
|
|
111
|
+
const graphReplacedByHealRef = useRef(false);
|
|
112
|
+
const refactorAbortRef = useRef(null);
|
|
113
|
+
const [showGeneticPanel, setShowGeneticPanel] = useState(false);
|
|
114
|
+
const [showMascotPanel, setShowMascotPanel] = useState(false);
|
|
115
|
+
const [showPhasePanel, setShowPhasePanel] = useState(false);
|
|
116
|
+
const [geneticGenerations, setGeneticGenerations] = useState(3);
|
|
117
|
+
const [geneticPopulationSize, setGeneticPopulationSize] = useState(6);
|
|
118
|
+
const [tournamentResult, setTournamentResult] = useState(null);
|
|
119
|
+
const [geneticError, setGeneticError] = useState(null);
|
|
120
|
+
const [editorRevealTarget, setEditorRevealTarget] = useState(null);
|
|
121
|
+
const [navigationError, setNavigationError] = useState(null);
|
|
122
|
+
const [showOpencodePanel, setShowOpencodePanel] = useState(false);
|
|
123
|
+
const [opencodeStatus, setOpencodeStatus] = useState({ status: "stopped" });
|
|
124
|
+
const [useOpencodeForAgent, setUseOpencodeForAgent] = useState(false);
|
|
125
|
+
const selectedNode = graph?.nodes.find((node) => node.id === selectedNodeId) ?? null;
|
|
126
|
+
const drilldownNodeId = drilldownStack.at(-1) ?? null;
|
|
127
|
+
const drilldownRootNode = graph?.nodes.find((node) => node.id === drilldownNodeId) ?? null;
|
|
128
|
+
const executionIndex = useMemo(() => indexRuntimeExecutionResult(executionResult), [executionResult]);
|
|
129
|
+
const detailFlow = graph && drilldownNodeId
|
|
130
|
+
? buildDetailFlow(graph, drilldownNodeId, selectedDetailNodeId ?? undefined, executionResult)
|
|
131
|
+
: null;
|
|
132
|
+
const heatmapData = useMemo(() => graph &&
|
|
133
|
+
graph.nodes.some((node) => node.traceState && node.traceState.count > 0)
|
|
134
|
+
? computeHeatmap(graph)
|
|
135
|
+
: undefined, [graph]);
|
|
136
|
+
const canStartImplementation = false;
|
|
137
|
+
const canStartIntegration = false;
|
|
138
|
+
const canImplementActiveNode = false;
|
|
139
|
+
const canRunActiveNode = false;
|
|
140
|
+
const isBusy = Boolean(busyLabel);
|
|
141
|
+
const isBuilding = busyLabel === "Building blueprint";
|
|
142
|
+
return (_jsx("div", { className: "workbench-shell", children: _jsx("div", { className: "workbench-main", children: _jsx("div", { className: "graph-panel", children: _jsx(GraphCanvas, { graph: graph, selectedNodeId: selectedNodeId, onSelect: setSelectedNodeId, heatmapData: heatmapData }) }) }) }));
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=blueprint-workbench.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blueprint-workbench.js","sourceRoot":"","sources":["../../src/components/blueprint-workbench.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAA0B,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AAE1F,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAKhE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,eAAe,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAsCnD,OAAO,EAAiB,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAuDnF,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;AAE9C,MAAM,UAAU,GAAG,CAAC,KAAa,EAAE,EAAE;IACnC,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,IAAI,OAAO,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;QACxB,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,MA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AM,gBAAgB,GAAG,KAAK,CAAC;IAC/B,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAClC,MAAM,UAAU,GAAG,SAAS,KAAK,oBAAoB,CAAC;IAEtD,OAAO,CACL,cAAK,SAAS,EAAC,iBAAiB,YAC9B,cAAK,SAAS,EAAC,gBAAgB,YAC7B,cAAK,SAAS,EAAC,aAAa,YAC1B,KAAC,WAAW,IACV,KAAK,EAAE,KAAK,EACZ,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,iBAAiB,EAC3B,WAAW,EAAE,WAAW,GACxB,GACE,GACF,GACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type CodeDiffEditorProps = {
|
|
2
|
+
originalValue: string;
|
|
3
|
+
modifiedValue: string;
|
|
4
|
+
language?: "typescript" | "javascript" | "json" | "markdown";
|
|
5
|
+
height?: string;
|
|
6
|
+
readOnly?: boolean;
|
|
7
|
+
theme?: "light" | "dark";
|
|
8
|
+
onModifiedChange?: (value: string) => void;
|
|
9
|
+
};
|
|
10
|
+
export declare function CodeDiffEditor({ originalValue, modifiedValue, language, height, readOnly, theme, onModifiedChange }: CodeDiffEditorProps): React.JSX.Element;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=code-diff-editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-diff-editor.d.ts","sourceRoot":"","sources":["../../src/components/code-diff-editor.tsx"],"names":[],"mappings":"AAcA,KAAK,mBAAmB,GAAG;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,YAAY,GAAG,YAAY,GAAG,MAAM,GAAG,UAAU,CAAC;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5C,CAAC;AAEF,wBAAgB,cAAc,CAAC,EAC7B,aAAa,EACb,aAAa,EACb,QAAuB,EACvB,MAAgB,EAChB,QAAgB,EAChB,KAAc,EACd,gBAAgB,EACjB,EAAE,mBAAmB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CA+CzC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useRef } from "react";
|
|
4
|
+
import dynamic from "next/dynamic";
|
|
5
|
+
import { prepareMonaco, toMonacoPath } from "./monaco-setup.js";
|
|
6
|
+
const MonacoDiffEditor = dynamic(() => import("@monaco-editor/react").then(mod => mod.DiffEditor), {
|
|
7
|
+
ssr: false,
|
|
8
|
+
loading: () => _jsx("div", { className: "code-diff-editor-loading", children: "Loading diff editor..." })
|
|
9
|
+
});
|
|
10
|
+
export function CodeDiffEditor({ originalValue, modifiedValue, language = "typescript", height = "28rem", readOnly = false, theme = "dark", onModifiedChange }) {
|
|
11
|
+
const monacoRef = useRef(null);
|
|
12
|
+
const modifiedListenerRef = useRef(null);
|
|
13
|
+
return (_jsx("div", { className: "code-diff-editor-shell", style: {
|
|
14
|
+
height,
|
|
15
|
+
minHeight: height === "100%" ? 0 : height
|
|
16
|
+
}, children: _jsx(MonacoDiffEditor, { beforeMount: prepareMonaco, height: height, language: language, modified: modifiedValue, modifiedModelPath: toMonacoPath("diff/modified.ts"), options: {
|
|
17
|
+
automaticLayout: true,
|
|
18
|
+
diffCodeLens: true,
|
|
19
|
+
enableSplitViewResizing: true,
|
|
20
|
+
fontFamily: "IBM Plex Mono, SFMono-Regular, SF Mono, monospace",
|
|
21
|
+
fontLigatures: true,
|
|
22
|
+
fontSize: 14,
|
|
23
|
+
lineNumbersMinChars: 3,
|
|
24
|
+
minimap: { enabled: false },
|
|
25
|
+
padding: { top: 16, bottom: 16 },
|
|
26
|
+
readOnly,
|
|
27
|
+
renderSideBySide: true,
|
|
28
|
+
scrollBeyondLastLine: false,
|
|
29
|
+
smoothScrolling: true,
|
|
30
|
+
wordWrap: "on"
|
|
31
|
+
}, original: originalValue, originalModelPath: toMonacoPath("diff/original.ts"), onMount: (editor, monaco) => {
|
|
32
|
+
monacoRef.current = monaco;
|
|
33
|
+
modifiedListenerRef.current?.dispose();
|
|
34
|
+
modifiedListenerRef.current = editor.getModifiedEditor().onDidChangeModelContent(() => {
|
|
35
|
+
onModifiedChange?.(editor.getModifiedEditor().getValue());
|
|
36
|
+
});
|
|
37
|
+
}, theme: theme === "dark" ? "vs-dark" : "vs-light" }) }));
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=code-diff-editor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-diff-editor.js","sourceRoot":"","sources":["../../src/components/code-diff-editor.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE/B,OAAO,OAAO,MAAM,cAAc,CAAC;AAGnC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEhE,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;IACjG,GAAG,EAAE,KAAK;IACV,OAAO,EAAE,GAAG,EAAE,CAAC,cAAK,SAAS,EAAC,0BAA0B,uCAA6B;CACtF,CAAC,CAAC;AAYH,MAAM,UAAU,cAAc,CAAC,EAC7B,aAAa,EACb,aAAa,EACb,QAAQ,GAAG,YAAY,EACvB,MAAM,GAAG,OAAO,EAChB,QAAQ,GAAG,KAAK,EAChB,KAAK,GAAG,MAAM,EACd,gBAAgB,EACI;IACpB,MAAM,SAA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C,iBAAiB,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;gBAC5D,CAAC,CAAC,CAAC;YACL,CAAC,EACD,KAAK,EAAE,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,GAChD,GACE,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { BlueprintGraph } from "@abhinav2203/codeflow-core/schema";
|
|
2
|
+
import type { NavigationTarget } from "../lib/node-navigation.js";
|
|
3
|
+
type CodeEditorProps = {
|
|
4
|
+
path: string;
|
|
5
|
+
value: string;
|
|
6
|
+
onChange: (value: string) => void;
|
|
7
|
+
language?: "typescript" | "javascript" | "json" | "markdown";
|
|
8
|
+
height?: string;
|
|
9
|
+
ariaLabel?: string;
|
|
10
|
+
readOnly?: boolean;
|
|
11
|
+
theme?: "light" | "dark";
|
|
12
|
+
onSave?: () => void | Promise<void>;
|
|
13
|
+
revealTarget?: NavigationTarget | null;
|
|
14
|
+
completionContext?: {
|
|
15
|
+
enabled: boolean;
|
|
16
|
+
graph: BlueprintGraph;
|
|
17
|
+
nodeId: string;
|
|
18
|
+
nvidiaApiKey?: string;
|
|
19
|
+
retrievalQuery?: string;
|
|
20
|
+
retrievalDepth?: number;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export declare function CodeEditor({ path, value, onChange, language, height, ariaLabel, readOnly, theme, onSave, revealTarget, completionContext }: CodeEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=code-editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-editor.d.ts","sourceRoot":"","sources":["../../src/components/code-editor.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AASlE,KAAK,eAAe,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,QAAQ,CAAC,EAAE,YAAY,GAAG,YAAY,GAAG,MAAM,GAAG,UAAU,CAAC;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,YAAY,CAAC,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACvC,iBAAiB,CAAC,EAAE;QAClB,OAAO,EAAE,OAAO,CAAC;QACjB,KAAK,EAAE,cAAc,CAAC;QACtB,MAAM,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;CACH,CAAC;AA2DF,wBAAgB,UAAU,CAAC,EACzB,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,QAAuB,EACvB,MAAgB,EAChB,SAAS,EACT,QAAgB,EAChB,KAAc,EACd,MAAM,EACN,YAAY,EACZ,iBAAiB,EAClB,EAAE,eAAe,2CAyRjB"}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
4
|
+
import dynamic from "next/dynamic";
|
|
5
|
+
import { prepareMonaco, toMonacoPath } from "./monaco-setup.js";
|
|
6
|
+
import { getTypeScriptLanguageService } from "./ts-language-service.js";
|
|
7
|
+
const MonacoEditor = dynamic(() => import("@monaco-editor/react"), {
|
|
8
|
+
ssr: false,
|
|
9
|
+
loading: () => _jsx("div", { className: "code-editor-loading", children: "Loading editor..." })
|
|
10
|
+
});
|
|
11
|
+
const COMPLETION_TTL_MS = 15_000;
|
|
12
|
+
const COMPLETION_DEBOUNCE_MS = 220;
|
|
13
|
+
const toCompletionKind = (monaco, kind) => {
|
|
14
|
+
switch (kind) {
|
|
15
|
+
case "method":
|
|
16
|
+
return monaco.languages.CompletionItemKind.Method;
|
|
17
|
+
case "function":
|
|
18
|
+
return monaco.languages.CompletionItemKind.Function;
|
|
19
|
+
case "constructor":
|
|
20
|
+
return monaco.languages.CompletionItemKind.Constructor;
|
|
21
|
+
case "field":
|
|
22
|
+
return monaco.languages.CompletionItemKind.Field;
|
|
23
|
+
case "variable":
|
|
24
|
+
return monaco.languages.CompletionItemKind.Variable;
|
|
25
|
+
case "class":
|
|
26
|
+
return monaco.languages.CompletionItemKind.Class;
|
|
27
|
+
case "interface":
|
|
28
|
+
return monaco.languages.CompletionItemKind.Interface;
|
|
29
|
+
case "module":
|
|
30
|
+
return monaco.languages.CompletionItemKind.Module;
|
|
31
|
+
case "property":
|
|
32
|
+
return monaco.languages.CompletionItemKind.Property;
|
|
33
|
+
case "unit":
|
|
34
|
+
return monaco.languages.CompletionItemKind.Unit;
|
|
35
|
+
case "value":
|
|
36
|
+
return monaco.languages.CompletionItemKind.Value;
|
|
37
|
+
case "enum":
|
|
38
|
+
return monaco.languages.CompletionItemKind.Enum;
|
|
39
|
+
case "keyword":
|
|
40
|
+
return monaco.languages.CompletionItemKind.Keyword;
|
|
41
|
+
case "snippet":
|
|
42
|
+
return monaco.languages.CompletionItemKind.Snippet;
|
|
43
|
+
case "color":
|
|
44
|
+
return monaco.languages.CompletionItemKind.Color;
|
|
45
|
+
case "file":
|
|
46
|
+
return monaco.languages.CompletionItemKind.File;
|
|
47
|
+
case "reference":
|
|
48
|
+
return monaco.languages.CompletionItemKind.Reference;
|
|
49
|
+
default:
|
|
50
|
+
return monaco.languages.CompletionItemKind.Text;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
export function CodeEditor({ path, value, onChange, language = "typescript", height = "28rem", ariaLabel, readOnly = false, theme = "dark", onSave, revealTarget, completionContext }) {
|
|
54
|
+
const monacoRef = useRef(null);
|
|
55
|
+
const editorRef = useRef(null);
|
|
56
|
+
const decorationIdsRef = useRef([]);
|
|
57
|
+
const completionContextRef = useRef(completionContext);
|
|
58
|
+
const providerRef = useRef(null);
|
|
59
|
+
const cacheRef = useRef(new Map());
|
|
60
|
+
const inflightRef = useRef(new Map());
|
|
61
|
+
const debounceRef = useRef({
|
|
62
|
+
timer: null,
|
|
63
|
+
resolve: null
|
|
64
|
+
});
|
|
65
|
+
const waitForDebounce = () => new Promise((resolve) => {
|
|
66
|
+
if (debounceRef.current.timer) {
|
|
67
|
+
window.clearTimeout(debounceRef.current.timer);
|
|
68
|
+
debounceRef.current.resolve?.(false);
|
|
69
|
+
}
|
|
70
|
+
debounceRef.current.resolve = resolve;
|
|
71
|
+
debounceRef.current.timer = window.setTimeout(() => {
|
|
72
|
+
debounceRef.current.timer = null;
|
|
73
|
+
debounceRef.current.resolve = null;
|
|
74
|
+
resolve(true);
|
|
75
|
+
}, COMPLETION_DEBOUNCE_MS);
|
|
76
|
+
});
|
|
77
|
+
const registerCompletionProvider = useCallback((monaco) => {
|
|
78
|
+
providerRef.current?.dispose();
|
|
79
|
+
if (readOnly || (language !== "typescript" && language !== "javascript")) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
providerRef.current = monaco.languages.registerCompletionItemProvider(language, {
|
|
83
|
+
triggerCharacters: [".", "("],
|
|
84
|
+
provideCompletionItems: async (model, position, context) => {
|
|
85
|
+
const activeContext = completionContextRef.current;
|
|
86
|
+
if (!activeContext?.enabled) {
|
|
87
|
+
return { suggestions: [] };
|
|
88
|
+
}
|
|
89
|
+
if (context.triggerKind === monaco.languages.CompletionTriggerKind.TriggerCharacter &&
|
|
90
|
+
![".", "("].includes(context.triggerCharacter ?? "")) {
|
|
91
|
+
return { suggestions: [] };
|
|
92
|
+
}
|
|
93
|
+
const word = model.getWordUntilPosition(position);
|
|
94
|
+
const lineContent = model.getLineContent(position.lineNumber);
|
|
95
|
+
const linePrefix = lineContent.slice(0, position.column - 1);
|
|
96
|
+
const lineSuffix = lineContent.slice(position.column - 1);
|
|
97
|
+
const currentCode = model.getValue();
|
|
98
|
+
const cursorOffset = model.getOffsetAt(position);
|
|
99
|
+
const recentPrefix = currentCode.slice(Math.max(0, cursorOffset - 180), cursorOffset);
|
|
100
|
+
if (context.triggerKind !== monaco.languages.CompletionTriggerKind.TriggerCharacter &&
|
|
101
|
+
recentPrefix.trim().length < 3) {
|
|
102
|
+
return { suggestions: [] };
|
|
103
|
+
}
|
|
104
|
+
const cacheKey = JSON.stringify([
|
|
105
|
+
activeContext.nodeId,
|
|
106
|
+
activeContext.retrievalQuery ?? "",
|
|
107
|
+
activeContext.retrievalDepth ?? 0,
|
|
108
|
+
context.triggerCharacter ?? "manual",
|
|
109
|
+
recentPrefix
|
|
110
|
+
]);
|
|
111
|
+
const cached = cacheRef.current.get(cacheKey);
|
|
112
|
+
if (cached && Date.now() - cached.createdAt < COMPLETION_TTL_MS) {
|
|
113
|
+
return { suggestions: cached.suggestions };
|
|
114
|
+
}
|
|
115
|
+
const inflight = inflightRef.current.get(cacheKey);
|
|
116
|
+
if (inflight) {
|
|
117
|
+
return { suggestions: await inflight };
|
|
118
|
+
}
|
|
119
|
+
const shouldContinue = await waitForDebounce();
|
|
120
|
+
if (!shouldContinue) {
|
|
121
|
+
return { suggestions: [] };
|
|
122
|
+
}
|
|
123
|
+
const completionPromise = (async () => {
|
|
124
|
+
try {
|
|
125
|
+
const response = await fetch("/api/code-completions", {
|
|
126
|
+
method: "POST",
|
|
127
|
+
headers: {
|
|
128
|
+
"content-type": "application/json"
|
|
129
|
+
},
|
|
130
|
+
body: JSON.stringify({
|
|
131
|
+
graph: activeContext.graph,
|
|
132
|
+
nodeId: activeContext.nodeId,
|
|
133
|
+
currentCode,
|
|
134
|
+
cursorOffset,
|
|
135
|
+
linePrefix,
|
|
136
|
+
lineSuffix,
|
|
137
|
+
triggerCharacter: context.triggerCharacter ?? undefined,
|
|
138
|
+
retrievalQuery: activeContext.retrievalQuery,
|
|
139
|
+
retrievalDepth: activeContext.retrievalDepth,
|
|
140
|
+
nvidiaApiKey: activeContext.nvidiaApiKey
|
|
141
|
+
})
|
|
142
|
+
});
|
|
143
|
+
if (!response.ok) {
|
|
144
|
+
return [];
|
|
145
|
+
}
|
|
146
|
+
const body = (await response.json());
|
|
147
|
+
const range = new monaco.Range(position.lineNumber, position.column - word.word.length, position.lineNumber, position.column);
|
|
148
|
+
return body.suggestions.map((suggestion) => ({
|
|
149
|
+
detail: suggestion.detail,
|
|
150
|
+
documentation: suggestion.documentation,
|
|
151
|
+
insertText: suggestion.insertText,
|
|
152
|
+
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
|
|
153
|
+
kind: toCompletionKind(monaco, suggestion.kind),
|
|
154
|
+
label: suggestion.label,
|
|
155
|
+
range
|
|
156
|
+
}));
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
return [];
|
|
160
|
+
}
|
|
161
|
+
})();
|
|
162
|
+
inflightRef.current.set(cacheKey, completionPromise);
|
|
163
|
+
try {
|
|
164
|
+
const suggestions = await completionPromise;
|
|
165
|
+
cacheRef.current.set(cacheKey, {
|
|
166
|
+
createdAt: Date.now(),
|
|
167
|
+
suggestions
|
|
168
|
+
});
|
|
169
|
+
return { suggestions };
|
|
170
|
+
}
|
|
171
|
+
finally {
|
|
172
|
+
inflightRef.current.delete(cacheKey);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}, [language, readOnly]);
|
|
177
|
+
useEffect(() => {
|
|
178
|
+
completionContextRef.current = completionContext;
|
|
179
|
+
}, [completionContext]);
|
|
180
|
+
useEffect(() => {
|
|
181
|
+
if (monacoRef.current) {
|
|
182
|
+
registerCompletionProvider(monacoRef.current);
|
|
183
|
+
}
|
|
184
|
+
}, [language, readOnly, registerCompletionProvider]);
|
|
185
|
+
useEffect(() => {
|
|
186
|
+
if (!monacoRef.current || (language !== "typescript" && language !== "javascript")) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
getTypeScriptLanguageService(monacoRef.current).upsertWorkspaceFile(path, value);
|
|
190
|
+
}, [language, path, value]);
|
|
191
|
+
useEffect(() => {
|
|
192
|
+
if (!editorRef.current || !monacoRef.current || !revealTarget) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
const monaco = monacoRef.current;
|
|
196
|
+
const editor = editorRef.current;
|
|
197
|
+
const startColumn = Math.max(1, revealTarget.columnStart ?? 1);
|
|
198
|
+
const endLineNumber = Math.max(revealTarget.endLineNumber ?? revealTarget.lineNumber, revealTarget.lineNumber);
|
|
199
|
+
const endColumn = Math.max(revealTarget.columnEnd ?? (endLineNumber === revealTarget.lineNumber ? startColumn + 1 : 1), 1);
|
|
200
|
+
const range = new monaco.Range(revealTarget.lineNumber, startColumn, endLineNumber, endColumn);
|
|
201
|
+
editor.revealRangeInCenter(range);
|
|
202
|
+
editor.setSelection(range);
|
|
203
|
+
decorationIdsRef.current = editor.deltaDecorations(decorationIdsRef.current, [
|
|
204
|
+
{
|
|
205
|
+
range,
|
|
206
|
+
options: {
|
|
207
|
+
className: "code-editor-highlight",
|
|
208
|
+
inlineClassName: "code-editor-highlight-inline",
|
|
209
|
+
isWholeLine: revealTarget.lineNumber === endLineNumber && startColumn === 1
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
]);
|
|
213
|
+
}, [revealTarget]);
|
|
214
|
+
useEffect(() => {
|
|
215
|
+
const debounceState = debounceRef.current;
|
|
216
|
+
return () => {
|
|
217
|
+
providerRef.current?.dispose();
|
|
218
|
+
if (editorRef.current) {
|
|
219
|
+
decorationIdsRef.current = editorRef.current.deltaDecorations(decorationIdsRef.current, []);
|
|
220
|
+
}
|
|
221
|
+
if (debounceState.timer) {
|
|
222
|
+
window.clearTimeout(debounceState.timer);
|
|
223
|
+
}
|
|
224
|
+
debounceState.resolve?.(false);
|
|
225
|
+
};
|
|
226
|
+
}, []);
|
|
227
|
+
return (_jsxs("div", { className: "code-editor-shell", style: {
|
|
228
|
+
height,
|
|
229
|
+
minHeight: height === "100%" ? 0 : height
|
|
230
|
+
}, children: [_jsx(MonacoEditor, { beforeMount: prepareMonaco, height: height, language: language, onMount: (editor, monaco) => {
|
|
231
|
+
monacoRef.current = monaco;
|
|
232
|
+
editorRef.current = editor;
|
|
233
|
+
getTypeScriptLanguageService(monaco).upsertWorkspaceFile(path, value);
|
|
234
|
+
registerCompletionProvider(monaco);
|
|
235
|
+
editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyS, () => {
|
|
236
|
+
void onSave?.();
|
|
237
|
+
});
|
|
238
|
+
}, onChange: (nextValue) => onChange(nextValue ?? ""), options: {
|
|
239
|
+
automaticLayout: true,
|
|
240
|
+
ariaLabel: ariaLabel ?? path,
|
|
241
|
+
fontFamily: "IBM Plex Mono, SFMono-Regular, SF Mono, monospace",
|
|
242
|
+
fontLigatures: true,
|
|
243
|
+
fontSize: 14,
|
|
244
|
+
lineNumbersMinChars: 3,
|
|
245
|
+
minimap: { enabled: false },
|
|
246
|
+
padding: { top: 16, bottom: 16 },
|
|
247
|
+
readOnly,
|
|
248
|
+
scrollBeyondLastLine: false,
|
|
249
|
+
smoothScrolling: true,
|
|
250
|
+
tabSize: 2,
|
|
251
|
+
wordWrap: "on"
|
|
252
|
+
}, path: toMonacoPath(path), theme: theme === "dark" ? "vs-dark" : "vs-light", value: value }), _jsx("style", { dangerouslySetInnerHTML: { __html: `
|
|
253
|
+
.code-editor-shell .code-editor-highlight {
|
|
254
|
+
background: rgba(96, 165, 250, 0.18);
|
|
255
|
+
border-left: 2px solid rgba(125, 211, 252, 0.8);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.code-editor-shell .code-editor-highlight-inline {
|
|
259
|
+
background: rgba(96, 165, 250, 0.18);
|
|
260
|
+
border-radius: 3px;
|
|
261
|
+
}
|
|
262
|
+
` } })] }));
|
|
263
|
+
}
|
|
264
|
+
//# sourceMappingURL=code-editor.js.map
|