flashts 1.0.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.
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "client",
3
+ "private": true,
4
+ "version": "0.0.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "tsc -b && vite build",
9
+ "lint": "eslint .",
10
+ "preview": "vite preview"
11
+ },
12
+ "dependencies": {
13
+ "@monaco-editor/react": "^4.7.0",
14
+ "clsx": "^2.1.1",
15
+ "framer-motion": "^12.29.0",
16
+ "lucide-react": "^0.562.0",
17
+ "monaco-editor": "^0.55.1",
18
+ "react": "^19.2.0",
19
+ "react-dom": "^19.2.0",
20
+ "react-resizable-panels": "^4.4.1",
21
+ "tailwind-merge": "^3.4.0"
22
+ },
23
+ "devDependencies": {
24
+ "@eslint/js": "^9.39.1",
25
+ "@types/node": "^24.10.1",
26
+ "@types/react": "^19.2.5",
27
+ "@types/react-dom": "^19.2.3",
28
+ "@vitejs/plugin-react": "^5.1.1",
29
+ "autoprefixer": "^10.4.23",
30
+ "eslint": "^9.39.1",
31
+ "eslint-plugin-react-hooks": "^7.0.1",
32
+ "eslint-plugin-react-refresh": "^0.4.24",
33
+ "globals": "^16.5.0",
34
+ "postcss": "^8.5.6",
35
+ "tailwindcss": "3.4.17",
36
+ "typescript": "~5.9.3",
37
+ "typescript-eslint": "^8.46.4",
38
+ "vite": "npm:rolldown-vite@7.2.5"
39
+ },
40
+ "overrides": {
41
+ "vite": "npm:rolldown-vite@7.2.5"
42
+ }
43
+ }
@@ -0,0 +1,6 @@
1
+ export default {
2
+ plugins: {
3
+ tailwindcss: {},
4
+ autoprefixer: {},
5
+ },
6
+ }
@@ -0,0 +1,9 @@
1
+ <svg width="64" height="64" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M13 3L4 14H11L9 21L18 10H11L13 3Z" stroke="url(#paint0_linear)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" fill="url(#paint0_linear)" fill-opacity="0.2"/>
3
+ <defs>
4
+ <linearGradient id="paint0_linear" x1="4" y1="3" x2="18" y2="21" gradientUnits="userSpaceOnUse">
5
+ <stop stop-color="#facc15"/>
6
+ <stop offset="1" stop-color="#fb923c"/>
7
+ </linearGradient>
8
+ </defs>
9
+ </svg>
@@ -0,0 +1,42 @@
1
+ #root {
2
+ max-width: 1280px;
3
+ margin: 0 auto;
4
+ padding: 2rem;
5
+ text-align: center;
6
+ }
7
+
8
+ .logo {
9
+ height: 6em;
10
+ padding: 1.5em;
11
+ will-change: filter;
12
+ transition: filter 300ms;
13
+ }
14
+ .logo:hover {
15
+ filter: drop-shadow(0 0 2em #646cffaa);
16
+ }
17
+ .logo.react:hover {
18
+ filter: drop-shadow(0 0 2em #61dafbaa);
19
+ }
20
+
21
+ @keyframes logo-spin {
22
+ from {
23
+ transform: rotate(0deg);
24
+ }
25
+ to {
26
+ transform: rotate(360deg);
27
+ }
28
+ }
29
+
30
+ @media (prefers-reduced-motion: no-preference) {
31
+ a:nth-of-type(2) .logo {
32
+ animation: logo-spin infinite 20s linear;
33
+ }
34
+ }
35
+
36
+ .card {
37
+ padding: 2em;
38
+ }
39
+
40
+ .read-the-docs {
41
+ color: #888;
42
+ }
@@ -0,0 +1,247 @@
1
+ import { useState, useEffect, useMemo } from "react";
2
+ import { Play, Terminal as TerminalIcon, Trash2, Info } from "lucide-react";
3
+ import { CodeEditor } from "./components/CodeEditor";
4
+ import { Console } from "./components/Console";
5
+ import { LightningLogo } from "./components/LightningLogo";
6
+ import { PackageInstaller } from "./components/PackageInstaller";
7
+ import { FileTabs, type ProjectFile } from "./components/FileTabs";
8
+ import { WelcomeScreen } from "./components/WelcomeScreen";
9
+ import { Panel, Group as PanelGroup, Separator as PanelResizeHandle } from "react-resizable-panels";
10
+ import clsx from "clsx";
11
+
12
+ interface ExecutionResult {
13
+ stdout: string;
14
+ stderr: string;
15
+ exitCode: number;
16
+ }
17
+
18
+ function App() {
19
+ const [files, setFiles] = useState<ProjectFile[]>([
20
+ { id: 'main', name: 'main.ts', content: '// Welcome to FlashTS!\nconsole.log("Hello from main.ts");\n' }
21
+ ]);
22
+ const [activeFileId, setActiveFileId] = useState<string>('main');
23
+ const [output, setOutput] = useState<ExecutionResult | null>(null);
24
+ const [isLoading, setIsLoading] = useState(false);
25
+ const [isMobile, setIsMobile] = useState(false);
26
+ const [dependencies, setDependencies] = useState<Record<string, string>>({});
27
+ const [showWelcome, setShowWelcome] = useState(() => {
28
+ const saved = localStorage.getItem("flashts_show_welcome");
29
+ return saved === null ? true : saved === "true";
30
+ });
31
+ const [isWelcomeOpen, setIsWelcomeOpen] = useState(showWelcome);
32
+
33
+ const activeFile = useMemo(() =>
34
+ files.find(f => f.id === activeFileId) || files[0],
35
+ [files, activeFileId]);
36
+
37
+ const fetchDependencies = async () => {
38
+ try {
39
+ const response = await fetch("/dependencies");
40
+ const data = await response.json();
41
+ setDependencies(data);
42
+ } catch (e) {
43
+ console.error("Failed to fetch dependencies:", e);
44
+ }
45
+ };
46
+
47
+ useEffect(() => {
48
+ fetchDependencies();
49
+ const timer = setTimeout(fetchDependencies, 1500);
50
+ return () => clearTimeout(timer);
51
+ }, []);
52
+
53
+ useEffect(() => {
54
+ const checkMobile = () => setIsMobile(window.innerWidth < 768);
55
+ checkMobile();
56
+ window.addEventListener('resize', checkMobile);
57
+ return () => window.removeEventListener('resize', checkMobile);
58
+ }, []);
59
+
60
+ // Run shortcut (Ctrl + Shift + F)
61
+ useEffect(() => {
62
+ const handleKeyDown = (e: KeyboardEvent) => {
63
+ if ((e.ctrlKey || e.metaKey) && e.shiftKey && (e.key === 'F' || e.key === 'f')) {
64
+ e.preventDefault();
65
+ handleRun();
66
+ }
67
+ };
68
+ window.addEventListener('keydown', handleKeyDown);
69
+ return () => window.removeEventListener('keydown', handleKeyDown);
70
+ }, [files, activeFileId]); // Re-bind when project state changes to ensure handleRun uses latest closure
71
+
72
+ const handleRun = async () => {
73
+ setIsLoading(true);
74
+ try {
75
+ const payload = {
76
+ files: files.reduce((acc, f) => ({ ...acc, [f.name]: f.content }), {}),
77
+ entryPoint: activeFile.name
78
+ };
79
+
80
+ const response = await fetch("/execute", {
81
+ method: "POST",
82
+ headers: { "Content-Type": "application/json" },
83
+ body: JSON.stringify(payload),
84
+ });
85
+ const data = await response.json();
86
+ setOutput(data);
87
+ } catch (error) {
88
+ setOutput({
89
+ stdout: "",
90
+ stderr: "Failed to connect to server: " + String(error),
91
+ exitCode: 1,
92
+ });
93
+ } finally {
94
+ setIsLoading(false);
95
+ }
96
+ };
97
+
98
+ const handleAddFile = (name: string) => {
99
+ const id = crypto.randomUUID();
100
+ const newFile: ProjectFile = {
101
+ id,
102
+ name,
103
+ content: ""
104
+ };
105
+ setFiles([...files, newFile]);
106
+ setActiveFileId(id);
107
+ };
108
+
109
+ const handleCloseFile = (id: string) => {
110
+ if (files.length === 1) return;
111
+ const newFiles = files.filter(f => f.id !== id);
112
+ setFiles(newFiles);
113
+ if (activeFileId === id) {
114
+ setActiveFileId(newFiles[newFiles.length - 1].id);
115
+ }
116
+ };
117
+
118
+ const handleRenameFile = (id: string, newName: string) => {
119
+ setFiles(files.map(f => f.id === id ? { ...f, name: newName } : f));
120
+ };
121
+
122
+ const updateActiveCode = (newContent: string | undefined) => {
123
+ setFiles(files.map(f => f.id === activeFileId ? { ...f, content: newContent || "" } : f));
124
+ };
125
+
126
+ return (
127
+ <div className="h-screen w-screen flex flex-col bg-bg-primary text-text-primary overflow-hidden">
128
+ {/* Header */}
129
+ <header className="h-14 border-b border-border-color flex items-center justify-between px-4 md:px-6 bg-bg-secondary/50 glass z-50 shrink-0">
130
+ <div className="flex items-center gap-3">
131
+ <LightningLogo size={20} />
132
+
133
+ <h1 className="font-bold text-lg tracking-tight bg-gradient-to-r from-yellow-100 to-orange-100 bg-clip-text text-transparent hidden md:block">
134
+ FlashTS
135
+ </h1>
136
+ </div>
137
+
138
+ <div className="flex items-center gap-2 md:gap-4 h-full">
139
+ <button
140
+ onClick={() => setIsWelcomeOpen(true)}
141
+ className="hidden sm:flex items-center gap-2 px-3 py-1.5 hover:bg-white/10 rounded-lg text-text-secondary hover:text-white transition-all active:scale-95 outline-none font-medium"
142
+ title="How it works"
143
+ >
144
+ <Info size={18} />
145
+ <span className="text-[10px] font-bold uppercase tracking-wider">How it works</span>
146
+ </button>
147
+
148
+ <div className="h-4 w-px bg-border-color hidden sm:block mx-1" />
149
+
150
+ <PackageInstaller
151
+ dependencies={dependencies}
152
+ onRefresh={fetchDependencies}
153
+ />
154
+
155
+ <button
156
+ onClick={handleRun}
157
+ disabled={isLoading}
158
+ className={clsx(
159
+ "btn-primary ml-1",
160
+ isLoading && "opacity-75 cursor-wait"
161
+ )}
162
+ title="Run Active File (Ctrl + Shift + F)"
163
+ >
164
+ {isLoading ? <div className="animate-spin h-4 w-4 border-2 border-white/50 border-t-white rounded-full" /> : <Play size={18} fill="currentColor" />}
165
+ Run
166
+ </button>
167
+ </div>
168
+ </header>
169
+
170
+ <WelcomeScreen
171
+ isOpen={isWelcomeOpen}
172
+ onClose={() => setIsWelcomeOpen(false)}
173
+ showOnStartup={showWelcome}
174
+ onToggleStartup={(val) => {
175
+ setShowWelcome(val);
176
+ localStorage.setItem("flashts_show_welcome", String(val));
177
+ }}
178
+ />
179
+
180
+ {/* Main Content */}
181
+ <main className="flex-1 relative overflow-hidden">
182
+ <PanelGroup orientation={isMobile ? "vertical" : "horizontal"}>
183
+ {/* Editor Pane */}
184
+ <Panel defaultSize={60} minSize={20} className="flex flex-col min-h-0">
185
+ <div className="panel-header shrink-0 !h-auto !p-0">
186
+ <FileTabs
187
+ files={files}
188
+ activeFileId={activeFileId}
189
+ onSelect={setActiveFileId}
190
+ onAdd={handleAddFile}
191
+ onClose={handleCloseFile}
192
+ onRename={handleRenameFile}
193
+ />
194
+ </div>
195
+ <div className="flex-1 relative min-h-0">
196
+ <CodeEditor
197
+ code={activeFile.content}
198
+ fileName={activeFile.name}
199
+ files={files}
200
+ onChange={updateActiveCode}
201
+ dependencies={dependencies}
202
+ />
203
+ </div>
204
+ </Panel>
205
+
206
+ <PanelResizeHandle className="w-2 h-2 md:w-1 md:h-auto bg-bg-primary hover:bg-accent-primary transition-colors flex-center z-10 touch-none">
207
+ <div className="w-8 h-1 md:w-1 md:h-8 bg-border-color rounded-full opacity-50" />
208
+ </PanelResizeHandle>
209
+
210
+ {/* Output Pane */}
211
+ <Panel defaultSize={40} minSize={20} className="flex flex-col min-h-0">
212
+ <div className="panel-header shrink-0">
213
+ <div className="flex items-center gap-2">
214
+ <TerminalIcon size={16} />
215
+ Console
216
+ </div>
217
+ <div className="flex items-center gap-2">
218
+ {output && (
219
+ <span className="text-xs text-text-secondary mr-2">
220
+ Exit: {output.exitCode}
221
+ </span>
222
+ )}
223
+ <button
224
+ onClick={() => setOutput(null)}
225
+ disabled={!output}
226
+ className="p-1 hover:bg-white/10 rounded text-text-secondary hover:text-white disabled:opacity-30 disabled:hover:bg-transparent"
227
+ title="Clear Console"
228
+ >
229
+ <Trash2 size={14} />
230
+ </button>
231
+ </div>
232
+ </div>
233
+
234
+ <div className="flex-1 bg-[#0c0c0e] relative min-h-0 overflow-hidden">
235
+ <Console
236
+ output={output}
237
+ isLoading={isLoading}
238
+ />
239
+ </div>
240
+ </Panel>
241
+ </PanelGroup>
242
+ </main>
243
+ </div>
244
+ );
245
+ }
246
+
247
+ export default App;
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
@@ -0,0 +1,206 @@
1
+ import Editor, { type OnMount } from "@monaco-editor/react";
2
+ import { useRef, useEffect, useState } from "react";
3
+ import { type ProjectFile } from "./FileTabs";
4
+ import clsx from "clsx";
5
+
6
+ interface CodeEditorProps {
7
+ code: string;
8
+ onChange: (value: string | undefined) => void;
9
+ dependencies: Record<string, string>;
10
+ fileName: string;
11
+ files: ProjectFile[];
12
+ className?: string;
13
+ }
14
+
15
+ export const CodeEditor = ({ code, onChange, dependencies, fileName, files, className }: CodeEditorProps) => {
16
+ const [monacoInstance, setMonacoInstance] = useState<any>(null);
17
+ const editorRef = useRef<any>(null);
18
+ const libsRef = useRef<Record<string, any>>({});
19
+ const projectLibsRef = useRef<Record<string, any>>({});
20
+
21
+ const getLanguage = (name: string) => {
22
+ if (name.endsWith('.tsx')) return 'typescript';
23
+ if (name.endsWith('.ts')) return 'typescript';
24
+ if (name.endsWith('.jsx')) return 'javascript';
25
+ if (name.endsWith('.js')) return 'javascript';
26
+ if (name.endsWith('.json')) return 'json';
27
+ return 'typescript';
28
+ };
29
+
30
+ // 1. Sync all files into Monaco Models and ExtraLibs for ambient resolution
31
+ useEffect(() => {
32
+ if (!monacoInstance) return;
33
+ const monaco = monacoInstance;
34
+
35
+ // Cleanup old project ambient libs
36
+ Object.values(projectLibsRef.current).forEach(lib => lib.dispose());
37
+ projectLibsRef.current = {};
38
+
39
+ files.forEach(file => {
40
+ const uri = monaco.Uri.parse(`file:///${file.name}`);
41
+
42
+ // Update/Create Model
43
+ let model = monaco.editor.getModel(uri);
44
+ if (!model) {
45
+ model = monaco.editor.createModel(file.content, getLanguage(file.name), uri);
46
+ } else {
47
+ if (model.getValue() !== file.content) {
48
+ model.setValue(file.content);
49
+ }
50
+ }
51
+
52
+ // Sync language just in case it were renamed
53
+ const lang = getLanguage(file.name);
54
+ if (model.getLanguageId() !== lang) {
55
+ monaco.editor.setModelLanguage(model, lang);
56
+ }
57
+
58
+ // ALSO add as ExtraLib to ensure TS sees it in the global ambient context
59
+ // This is the "magic sauce" for resolving sibling imports in Monaco
60
+ projectLibsRef.current[file.id] = monaco.languages.typescript.typescriptDefaults.addExtraLib(
61
+ file.content,
62
+ uri.toString()
63
+ );
64
+ });
65
+
66
+ // Cleanup models for deleted files
67
+ const fileNames = new Set(files.map(f => `file:///${f.name}`));
68
+ monaco.editor.getModels().forEach((model:any) => {
69
+ const uri = model.uri.toString();
70
+ if (uri.startsWith('file:///') && !uri.includes('node_modules') && !fileNames.has(uri)) {
71
+ model.dispose();
72
+ }
73
+ });
74
+ }, [files, monacoInstance]);
75
+
76
+ // 2. Inject Type Definitions from Dependencies
77
+ useEffect(() => {
78
+ if (!monacoInstance) return;
79
+
80
+ const fetchAndInjectTypes = async () => {
81
+ const monaco = monacoInstance;
82
+ const deps = Object.keys(dependencies);
83
+
84
+ if (deps.length === 0) return;
85
+
86
+ for (const pkg of deps) {
87
+ if (libsRef.current[pkg]) continue;
88
+
89
+ try {
90
+ const res = await fetch(`/package-types/${encodeURIComponent(pkg)}`);
91
+ if (!res.ok) continue;
92
+ const { tree } = await res.json();
93
+
94
+ const disposables: any[] = [];
95
+ const filesMap = tree as Record<string, string>;
96
+
97
+ for (const [relativePath, content] of Object.entries(filesMap)) {
98
+ const uri = `file:///node_modules/${pkg}/${relativePath}`;
99
+ disposables.push(
100
+ monaco.languages.typescript.typescriptDefaults.addExtraLib(content, uri)
101
+ );
102
+ }
103
+
104
+ libsRef.current[pkg] = {
105
+ dispose: () => disposables.forEach(d => d.dispose())
106
+ };
107
+ } catch (e) {
108
+ console.error(`Error injecting types for ${pkg}:`, e);
109
+ }
110
+ }
111
+
112
+ for (const pkg in libsRef.current) {
113
+ if (!dependencies[pkg]) {
114
+ libsRef.current[pkg].dispose();
115
+ delete libsRef.current[pkg];
116
+ }
117
+ }
118
+ };
119
+
120
+ fetchAndInjectTypes();
121
+ }, [dependencies, monacoInstance]);
122
+
123
+ const handleEditorDidMount: OnMount = (editor, monaco) => {
124
+ editorRef.current = editor;
125
+ setMonacoInstance(monaco);
126
+
127
+ monaco.editor.defineTheme("flashts-dark", {
128
+ base: "vs-dark",
129
+ inherit: true,
130
+ rules: [
131
+ { token: '', foreground: 'd4d4d8' },
132
+ { token: 'comment', foreground: '71717a', fontStyle: 'italic' },
133
+ { token: 'keyword', foreground: 'f59e0b', fontStyle: 'bold' },
134
+ { token: 'operator', foreground: 'f97316' },
135
+ { token: 'string', foreground: 'a3e635' },
136
+ { token: 'function', foreground: 'fcd34d' },
137
+ { token: 'type', foreground: 'fbbf24' },
138
+ ],
139
+ colors: {
140
+ "editor.background": "#09090b",
141
+ "editor.foreground": "#d4d4d8",
142
+ "editor.lineHighlightBackground": "#18181b",
143
+ "editorCursor.foreground": "#f59e0b",
144
+ "editor.selectionBackground": "#f59e0b33",
145
+ },
146
+ });
147
+ monaco.editor.setTheme("flashts-dark");
148
+
149
+ monaco.languages.typescript.typescriptDefaults.setCompilerOptions({
150
+ target: monaco.languages.typescript.ScriptTarget.ESNext,
151
+ moduleResolution: 100, // Bundler
152
+ module: monaco.languages.typescript.ModuleKind.ESNext,
153
+ allowImportingTsExtensions: true,
154
+ allowNonTsExtensions: true,
155
+ noEmit: true,
156
+ esModuleInterop: true,
157
+ jsx: monaco.languages.typescript.JsxEmit.ReactJSX,
158
+ reactNamespace: "React",
159
+ allowJs: true,
160
+ baseUrl: "file:///",
161
+ rootDirs: ["file:///"],
162
+ typeRoots: ["file:///node_modules/@types"],
163
+ lib: ["esnext", "dom"],
164
+ paths: {
165
+ "react": ["node_modules/@types/react"],
166
+ "react/*": ["node_modules/@types/react/*"],
167
+ "*": ["*", "node_modules/*"]
168
+ }
169
+ });
170
+
171
+ monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
172
+ noSemanticValidation: false,
173
+ noSyntaxValidation: false,
174
+ });
175
+
176
+ monaco.languages.typescript.typescriptDefaults.addExtraLib(
177
+ `declare module 'react/jsx-runtime' { export namespace JSX { interface IntrinsicElements { [e: string]: any; } } }`,
178
+ 'file:///node_modules/@types/react/jsx-runtime.d.ts'
179
+ );
180
+ };
181
+
182
+ return (
183
+ <div className={clsx("h-full w-full overflow-hidden relative", className)}>
184
+ <Editor
185
+ path={`file:///${fileName}`}
186
+ height="100%"
187
+ defaultLanguage={getLanguage(fileName)}
188
+ language={getLanguage(fileName)}
189
+ value={code}
190
+ onChange={onChange}
191
+ onMount={handleEditorDidMount}
192
+ theme="vs-dark"
193
+ options={{
194
+ minimap: { enabled: false },
195
+ fontSize: 14,
196
+ fontFamily: "JetBrains Mono, monospace",
197
+ scrollBeyondLastLine: false,
198
+ smoothScrolling: true,
199
+ padding: { top: 16, bottom: 16 },
200
+ fixedOverflowWidgets: true,
201
+ automaticLayout: true,
202
+ }}
203
+ />
204
+ </div>
205
+ );
206
+ };
@@ -0,0 +1,52 @@
1
+ import clsx from "clsx";
2
+ import { Terminal } from "lucide-react";
3
+
4
+ interface ConsoleProps {
5
+ output: { stdout: string; stderr: string; exitCode: number } | null;
6
+ isLoading: boolean;
7
+ className?: string; // Removed onClear prop
8
+ }
9
+
10
+ export const Console = ({ output, isLoading, className }: ConsoleProps) => {
11
+ if (isLoading) {
12
+ return (
13
+ <div className={clsx("h-full w-full flex-center flex-col text-sm text-text-secondary gap-2", className)}>
14
+ <div className="animate-spin h-6 w-6 border-2 border-accent-primary border-t-transparent rounded-full" />
15
+ <span>Executing via Bun...</span>
16
+ </div>
17
+ );
18
+ }
19
+
20
+ if (!output) {
21
+ return (
22
+ <div className={clsx("h-full w-full flex-center flex-col text-sm text-text-secondary opacity-50", className)}>
23
+ <Terminal size={32} className="mb-2" />
24
+ <span>Ready to execute</span>
25
+ </div>
26
+ );
27
+ }
28
+
29
+ return (
30
+ <div className={clsx("h-full w-full flex flex-col font-mono text-sm overflow-auto p-4", className)}>
31
+ {/* Header removed, now in App.tsx */}
32
+
33
+ {output.stdout && (
34
+ <div className="mb-4">
35
+ <div className="text-text-secondary text-xs mb-1 uppercase tracking-wider">stdout</div>
36
+ <pre className="text-text-primary whitespace-pre-wrap">{output.stdout}</pre>
37
+ </div>
38
+ )}
39
+
40
+ {output.stderr && (
41
+ <div className="mb-4">
42
+ <div className="text-red-400 text-xs mb-1 uppercase tracking-wider">stderr</div>
43
+ <pre className="text-red-400 whitespace-pre-wrap">{output.stderr}</pre>
44
+ </div>
45
+ )}
46
+
47
+ {!output.stdout && !output.stderr && (
48
+ <div className="text-text-secondary italic opacity-50">No output</div>
49
+ )}
50
+ </div>
51
+ );
52
+ };