Hono と Node.js で実装された、Wandbox 互換の API サーバーおよび簡易 Web UI です。
ホストマシン上の gcc (C/C++) および rustc (Rust) を用いて、サンドボックスなしで直接コンパイル・実行します。
- Wandbox 互換 API:
GET /api/list.json: 利用可能なコンパイラの一覧および各コンパイラのオプションスイッチ・バージョン情報POST /api/compile.json: コンパイル&実行を行い、結果(標準出力・標準エラー・終了コード・メッセージ)を JSON で返却POST /api/compile.ndjson: コンパイル&実行ログをリアルタイムに NDJSON(New-line Delimited JSON)形式でストリーミング配信GET /api/template/{template_name}: C, C++, Rust などのコードテンプレートを取得POST /api/permlink&GET /api/permlink/{id}: コード・実行結果のパーマリンク作成・取得GET /api/sponsors.json,GET /api/hpplib.json: Wandbox 互換スタブエンドポイント
- 対応コンパイラ:
gcc(g++,gcc-cxx,cpp): GCC C++ Compiler (Boost / C++23 等対応)gcc-c(c,gcc-head-c): GCC C Compiler (C11/C17/C2x 等対応)rust(rustc): Rust Compiler- ※ コンパイラバージョンは環境の
gcc --version/rustc --versionから動的に取得されます。
- Boost C++ ライブラリ対応:
boost(またはboost-default) オプション指定でホストの Boost ライブラリを直接利用可能 (デフォルト有効)
- マルチファイル対応:
codes: [{ file: "sub.h", code: "..." }, ...]で複数ファイルを指定可能
- 簡易フロントエンド:
- ルート (
/) でモダンな Web UI を配信 - 言語/コンパイラ選択
- メインファイルおよびサブファイルの作成・削除・切り替えエディタ(Tab インデント対応)
- コンパイラスイッチ・生オプション・標準入力 (stdin) 指定
- NDJSON ストリーミングによるリアルタイム出力表示
- ルート (
ホストマシン上で直接コンパイル・実行するため、事前に gcc (または g++)、boost、rustc、Node.js (v20 以上)、pnpm をインストールしてください。
# GCC / G++ (ビルド必須ツール)
sudo apt update
sudo apt install -y build-essential
# Boost C++ ライブラリ (ヘッダーファイル)
sudo apt install -y libboost-dev
# Rust (rustc / cargo)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# または: sudo apt install -y rustc
# Node.js & pnpm
# (Node.js 20+ がインストールされている状態で)
npm install -g pnpm# Command Line Tools (Clang / C++ コンパイラ) または GCC
xcode-select --install
# (必要に応じて Homebrew GCC を利用する場合: brew install gcc)
# Boost C++ ライブラリ
brew install boost
# ※ Apple Silicon Mac (/opt/homebrew/opt/boost/include 等) および
# Intel Mac (/usr/local/opt/boost/include 等) の両インクルードパスに自動対応しています。
# Rust (rustc / cargo)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# または: brew install rust
# Node.js & pnpm
brew install node pnpmnpx unsandboxポートやホストを指定する場合:
npx unsandbox --port 8080 --host 0.0.0.0# 依存関係インストール
pnpm install
# 開発サーバー起動 (ファイル変更時自動リロード)
pnpm dev
# 本番ビルド & 起動
pnpm build
pnpm start
# テスト実行
pnpm test本パッケージは pnpm publish で npm レジストリに公開可能です。
# ログイン(初回のみ)
pnpm login
# ビルド & テストが自動実行されて公開されます (prepublishOnly)
pnpm publish --access public本ソフトウェアは MIT License のもとで公開されています。
本プロジェクトは melpon 氏によって作成された Wandbox (Boost Software License 1.0) の API 仕様および UI 設計を参考にしています。
curl http://localhost:3000/api/list.jsoncurl -X POST http://localhost:3000/api/compile.json \
-H "Content-Type: application/json" \
-d '{
"compiler": "gcc",
"code": "#include <stdio.h>\nint main() { printf(\"Hello, Unsandbox!\\n\"); return 0; }",
"options": "warning,c17"
}'レスポンス例:
{
"status": "0",
"signal": "",
"compiler_output": "",
"compiler_error": "",
"compiler_message": "",
"program_output": "Hello, Unsandbox!\n",
"program_error": "",
"program_message": "Hello, Unsandbox!\n"
}curl -X POST http://localhost:3000/api/compile.ndjson \
-H "Content-Type: application/json" \
-d '{
"compiler": "rustc",
"code": "fn main() { println!(\"Streaming Rust execution!\"); }"
}'レスポンス例:
{"type":"Control","data":"Start"}
{"type":"StdOut","data":"Streaming Rust execution!\n"}
{"type":"ExitCode","data":"0"}
{"type":"Control","data":"Finish"}