Inline Code Runner
VS Code extension untuk menampilkan hasil eksekusi kode secara inline (di samping baris kode), mirip seperti Quokka.js.
Fitur
- ✅ Eksekusi JavaScript (Node.js) dan Python (python3)
- ✅ Tampilkan output secara inline menggunakan VSCode Decoration API
- ✅ Format output:
=> hasil
- ✅ Support async/await di JavaScript
- ✅ Error handling ditampilkan inline dengan warna merah
- ✅ Auto-run (real-time execution) dengan debounce 500ms
- ✅ Timeout 5 detik untuk keamanan
Bahasa yang Didukung
| Ekstensi |
Runtime |
.js, .mjs, .cjs |
Node.js |
.py, .pyw |
Python3 |
Cara Install
Prerequisites
- Install Node.js dan npm
- Install Python3
- Install VS Code
Langkah Install
# 1. Clone atau download project ini
cd inline-code-runner
# 2. Install dependencies
npm install
# 3. Compile TypeScript
npm run compile
# 4. Buka folder ini di VS Code
code .
# 5. Tekan F5 untuk run extension di VS Code baru
Cara Pakai
Cara 1: Command Palette
- Buka file
.js atau .py
- Tekan
Ctrl+Shift+P (Mac: Cmd+Shift+P)
- Ketik
Run Inline Code
- Tekan Enter
Cara 2: Keyboard Shortcut
- Windows/Linux:
Ctrl+Shift+R
- Mac:
Cmd+Shift+R
Cara 3: Auto-Run (Real-time)
- Buka Command Palette
- Ketik
Enable Auto-Run
- Setiap perubahan kode akan otomatis menjalankan kode
Untuk matikan auto-run:
- Command Palette →
Disable Auto-Run
Contoh Penggunaan
JavaScript
Input:
let a = 1;
let b = 2;
console.log(a + b);
Output di Editor:
let a = 1;
let b = 2;
console.log(a + b); => 3
Python
Input:
a = 1
b = 2
print(a + b)
Output di Editor:
a = 1
b = 2
print(a + b) => 3
Async/Await (JavaScript)
Input:
const fetchData = async () => {
return "Hello World";
};
console.log(await fetchData());
Output:
const fetchData = async () => {
return "Hello World";
};
console.log(await fetchData()); => Hello World
Error Handling
Input:
console.log(undefinedVariable);
Output:
console.log(undefinedVariable); ❌ ReferenceError: undefinedVariable is not defined
Troubleshooting
Error: "Unsupported file type"
Pastikan file menggunakan ekstensi .js, .mjs, .cjs, .py, atau .pyw
Error: "Node.js/python3 not found"
Pastikan Node.js dan Python3 sudah terinstall dan ada di PATH
Output tidak muncul
- Coba refresh editor
- Pastikan tidak ada syntax error di kode
- Check Output panel untuk error details
Keamanan
- Timeout 5 detik untuk mencegah infinite loop
- Hanya execute file lokal
- Tidak support remote code execution
Lisensi
MIT