Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ WORKDIR /app

COPY package.json package-lock.json ./
COPY packages/jsEval/package.json ./packages/jsEval/
COPY packages/runtime/package.json ./packages/runtime/

RUN --mount=type=cache,target=/root/.npm \
npm ci --no-audit --no-fund
Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ Cloudflare Worker のビルドログとステータス表示が見れますが

## markdown仕様

実行環境の説明は ./packages/runtime/README.md を参照

````
```言語名-repl
>>> コマンド
Expand All @@ -162,9 +164,9 @@ Cloudflare Worker のビルドログとステータス表示が見れますが
````

でターミナルを埋め込む。
* ターミナル表示部は app/terminal/terminal.tsx
* コマンド入力処理は app/terminal/repl.tsx
* 各言語の実行環境は app/terminal/言語名/ 内に書く。
* ターミナル表示部は ./packages/runtime/terminal.tsx
* コマンド入力処理は ./packages/runtime/repl.tsx
* 各言語の実行環境は ./packages/runtime/言語名/ 内に書く。
* 実行結果はSectionContextにも送られ、section.tsxからアクセスできる

````
Expand All @@ -174,10 +176,10 @@ Cloudflare Worker のビルドログとステータス表示が見れますが
````

でテキストエディターを埋め込む。
* app/terminal/editor.tsx
* ./packages/runtime/editor.tsx
* editor.tsx内で `import "ace-builds/src-min-noconflict/mode-言語名";` を追加すればその言語に対応した色付けがされる。
* importできる言語の一覧は https://github.com/ajaxorg/ace-builds/tree/master/src-noconflict
* 編集した内容は app/terminal/file.tsx のFileContextで管理される。
* 編集した内容は ./packages/runtime/file.tsx のFileContextで管理される。
* 編集中のコードはFileContextに即時送られる
* FileContextが書き換えられたら即時すべてのエディターに反映される
* 編集したファイルの一覧はSectionContextにも送られ、section.tsxからアクセスできる
Expand All @@ -198,7 +200,7 @@ Cloudflare Worker のビルドログとステータス表示が見れますが

で実行ボタンを表示する
* 実行ボタンを押した際にFileContextからファイルを読み、実行し、結果を表示する
* app/terminal/exec.tsx に各言語ごとの実装を書く (それぞれ app/terminal/言語名/ 内に定義した関数を呼び出す)
* ./packages/runtime/exec.tsx に各言語ごとの実装を書く (それぞれ ./packages/runtime/言語名/ 内に定義した関数を呼び出す)
* 実行結果はSectionContextにも送られ、section.tsxからアクセスできる


Expand Down
2 changes: 1 addition & 1 deletion app/[lang]/[pageId]/chatForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useState, FormEvent, useEffect } from "react";
// } from "../actions/questionExample";
// import { getLanguageName } from "../pagesList";
import { DynamicMarkdownSection } from "./pageContent";
import { useEmbedContext } from "@/terminal/embedContext";
import { useEmbedContext } from "@my-code/runtime/embedContext";
import { useChatHistoryContext } from "./chatHistory";
import { askAI } from "@/actions/chatActions";

Expand Down
8 changes: 4 additions & 4 deletions app/[lang]/[pageId]/markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import Markdown, { Components, ExtraProps } from "react-markdown";
import remarkGfm from "remark-gfm";
import removeComments from "remark-remove-comments";
import remarkCjkFriendly from "remark-cjk-friendly";
import { EditorComponent, getAceLang } from "@/terminal/editor";
import { ExecFile } from "@/terminal/exec";
import { EditorComponent, getAceLang } from "@my-code/runtime/editor";
import { ExecFile } from "@my-code/runtime/exec";
import { JSX, ReactNode } from "react";
import { getRuntimeLang } from "@/terminal/runtime";
import { ReplTerminal } from "@/terminal/repl";
import { getRuntimeLang } from "@my-code/runtime/languages";
import { ReplTerminal } from "@my-code/runtime/repl";
import {
getSyntaxHighlighterLang,
MarkdownLang,
Expand Down
2 changes: 1 addition & 1 deletion app/actions/chatActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// import { z } from "zod";
import { generateContent } from "./gemini";
import { DynamicMarkdownSection } from "../[lang]/[pageId]/pageContent";
import { ReplCommand, ReplOutput } from "../terminal/repl";
import { ReplCommand, ReplOutput } from "@my-code/runtime/repl";
import { addChat, ChatWithMessages } from "@/lib/chatHistory";

type ChatResult =
Expand Down
4 changes: 2 additions & 2 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import "./globals.css";
import { Navbar } from "./navbar";
import { Sidebar } from "./sidebar";
import { ReactNode } from "react";
import { EmbedContextProvider } from "./terminal/embedContext";
import { EmbedContextProvider } from "@my-code/runtime/embedContext";
import { AutoAnonymousLogin } from "./accountMenu";
import { SidebarMdProvider } from "./sidebar";
import { RuntimeProvider } from "./terminal/runtime";
import { RuntimeProvider } from "@my-code/runtime/context";
import { getPagesList } from "@/lib/docs";

export const metadata: Metadata = {
Expand Down
4 changes: 2 additions & 2 deletions app/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import {
} from "react";
import { DynamicMarkdownSection } from "./[lang]/[pageId]/pageContent";
import clsx from "clsx";
import { LanguageIcon } from "./terminal/icons";
import { RuntimeLang } from "./terminal/runtime";
import { LanguageIcon } from "@my-code/runtime/icons";
import { RuntimeLang } from "@my-code/runtime/languages";

export interface ISidebarMdContext {
loadedDocsId: { lang: string; pageId: string } | null;
Expand Down
43 changes: 22 additions & 21 deletions app/terminal/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,29 @@
import { Heading } from "@/[lang]/[pageId]/markdown";
import "mocha/mocha.css";
import { Fragment, useEffect, useRef, useState } from "react";
import { useWandbox } from "./wandbox/runtime";
import { RuntimeContext, RuntimeLang } from "./runtime";
import { useEmbedContext } from "./embedContext";
import { defineTests } from "./tests";
import { usePyodide } from "./worker/pyodide";
import { useRuby } from "./worker/ruby";
import { useJSEval } from "./worker/jsEval";
import { ReplTerminal } from "./repl";
import { EditorComponent, getAceLang } from "./editor";
import { ExecFile } from "./exec";
import { useTypeScript } from "./typescript/runtime";
import { useTerminal } from "./terminal";
import { useWandbox } from "@my-code/runtime/wandbox/runtime";
import { RuntimeContext } from "@my-code/runtime/interface";
import { RuntimeLang } from "@my-code/runtime/languages";
import { useEmbedContext } from "@my-code/runtime/embedContext";
import { defineTests } from "@my-code/runtime/tests";
import { usePyodide } from "@my-code/runtime/worker/pyodide";
import { useRuby } from "@my-code/runtime/worker/ruby";
import { useJSEval } from "@my-code/runtime/worker/jsEval";
import { ReplTerminal } from "@my-code/runtime/repl";
import { EditorComponent, getAceLang } from "@my-code/runtime/editor";
import { ExecFile } from "@my-code/runtime/exec";
import { useTypeScript } from "@my-code/runtime/typescript/runtime";
import { useTerminal } from "@my-code/runtime/terminal";

import main_py from "./samples/main.py?raw";
import main_rb from "./samples/main.rb?raw";
import main_js from "./samples/main.js?raw";
import main2_ts from "./samples/main2.ts?raw";
import main_cpp from "./samples/main.cpp?raw";
import sub_h from "./samples/sub.h?raw";
import sub_cpp from "./samples/sub.cpp?raw";
import main2_rs from "./samples/main2.rs?raw";
import sub_rs from "./samples/sub.rs?raw";
import main_py from "@my-code/runtime/samples/main.py?raw";
import main_rb from "@my-code/runtime/samples/main.rb?raw";
import main_js from "@my-code/runtime/samples/main.js?raw";
import main2_ts from "@my-code/runtime/samples/main2.ts?raw";
import main_cpp from "@my-code/runtime/samples/main.cpp?raw";
import sub_h from "@my-code/runtime/samples/sub.h?raw";
import sub_cpp from "@my-code/runtime/samples/sub.cpp?raw";
import main2_rs from "@my-code/runtime/samples/main2.rs?raw";
import sub_rs from "@my-code/runtime/samples/sub.rs?raw";

export default function RuntimeTestPage() {
return (
Expand Down
218 changes: 0 additions & 218 deletions app/terminal/runtime.tsx

This file was deleted.

Loading