Skip to content

Commit f5fa9ac

Browse files
committed
Merge remote-tracking branch 'origin/main' into runtime-workspace
2 parents 1c2b679 + 4e7dd62 commit f5fa9ac

File tree

12 files changed

+634
-708
lines changed

12 files changed

+634
-708
lines changed

app/terminal/exec.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function ExecFile(props: ExecProps) {
3333
}
3434
},
3535
});
36-
const { files, clearExecResult, addExecOutput } = useEmbedContext();
36+
const { files, clearExecResult, addExecOutput, writeFile } = useEmbedContext();
3737

3838
const { ready, runFiles, getCommandlineStr, runtimeInfo, interrupt } =
3939
useRuntime(props.language);
@@ -53,6 +53,10 @@ export function ExecFile(props: ExecProps) {
5353
clearExecResult(filenameKey);
5454
let isFirstOutput = true;
5555
await runFiles(props.filenames, files, (output) => {
56+
if (output.type === "file") {
57+
writeFile({ [output.filename]: output.content });
58+
return;
59+
}
5660
addExecOutput(filenameKey, output);
5761
if (isFirstOutput) {
5862
// Clear "実行中です..." message only on first output
@@ -78,6 +82,7 @@ export function ExecFile(props: ExecProps) {
7882
runFiles,
7983
clearExecResult,
8084
addExecOutput,
85+
writeFile,
8186
terminalInstanceRef,
8287
props.language,
8388
files,

app/terminal/page.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,6 @@ function MochaTest() {
221221
const [mochaState, setMochaState] = useState<"idle" | "running" | "finished">(
222222
"idle"
223223
);
224-
const { files } = useEmbedContext();
225-
const filesRef = useRef(files);
226-
filesRef.current = files;
227-
228224
const runTest = async () => {
229225
if (typeof window !== "undefined") {
230226
setMochaState("running");
@@ -235,7 +231,7 @@ function MochaTest() {
235231

236232
for (const lang of Object.keys(runtimeRef.current) as RuntimeLang[]) {
237233
runtimeRef.current[lang].init?.();
238-
defineTests(lang, runtimeRef, filesRef);
234+
defineTests(lang, runtimeRef);
239235
}
240236

241237
const runner = mocha.run();

app/terminal/repl.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export function ReplTerminal({
6767
language,
6868
initContent,
6969
}: ReplComponentProps) {
70-
const { addReplCommand, addReplOutput } = useEmbedContext();
70+
const { addReplCommand, addReplOutput, writeFile } = useEmbedContext();
7171

7272
const [Prism, setPrism] = useState<typeof import("prismjs") | null>(null);
7373
useEffect(() => {
@@ -214,6 +214,10 @@ export function ReplTerminal({
214214
let executionDone = false;
215215
await runtimeMutex.runExclusive(async () => {
216216
await runCommand(command, (output) => {
217+
if (output.type === "file") {
218+
writeFile({ [output.filename]: output.content });
219+
return;
220+
}
217221
if (executionDone) {
218222
// すでに完了していて次のコマンドのプロンプトが出ている場合、その前に挿入
219223
updateBuffer(null, () => {
@@ -270,6 +274,7 @@ export function ReplTerminal({
270274
runtimeMutex,
271275
runCommand,
272276
handleOutput,
277+
writeFile,
273278
tabSize,
274279
addReplCommand,
275280
addReplOutput,
@@ -331,6 +336,10 @@ export function ReplTerminal({
331336
for (const cmd of initCommand!) {
332337
const outputs: ReplOutput[] = [];
333338
await runCommand(cmd.command, (output) => {
339+
if (output.type === "file") {
340+
writeFile({ [output.filename]: output.content });
341+
return;
342+
}
334343
outputs.push(output);
335344
});
336345
initCommandResult.push({
@@ -365,6 +374,7 @@ export function ReplTerminal({
365374
runtimeMutex,
366375
updateBuffer,
367376
handleOutput,
377+
writeFile,
368378
termReady,
369379
terminalInstanceRef,
370380
Prism,

0 commit comments

Comments
 (0)