| Crates.io | monaco-vscode-server |
| lib.rs | monaco-vscode-server |
| version | 0.1.0 |
| created_at | 2025-05-25 03:02:25.502376+00 |
| updated_at | 2025-05-25 03:02:25.502376+00 |
| description | vscode server backend for codingame monaco-vscode-api |
| homepage | |
| repository | https://github.com/entrepeneur4lyf/monaco-vscode-server |
| max_upload_size | |
| id | 1687956 |
| size | 101,847 |
A Rust crate for managing VSCode server backend for applications using monaco-vscode-api.
Perfect for Tauri applications that need a VSCode-compatible backend for the Monaco editor.
Add to your Cargo.toml:
[dependencies]
monaco-vscode-server = "0.1.0" # Or the latest version
use monaco_vscode_server::{VscodeServerManager, ServerConfig};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create manager with default config
let mut manager = VscodeServerManager::new().await?;
// Ensure server is downloaded
manager.ensure_server().await?;
// Start the server
manager.start().await?;
println!("VSCode server running at: {}", manager.url());
// Your application code here...
// Server stops automatically when manager is dropped
Ok(())
}
In your Tauri app's main.rs:
use tauri::{Manager, State};
use monaco_vscode_server::{TauriVscodeServer, TauriConfig};
// State type for the server
struct ServerState(Arc<TauriVscodeServer>);
#[tauri::command]
async fn get_server_info(state: State<'_, ServerState>) -> Result<serde_json::Value, String> {
state.0.get_info().await.map_err(|e| e.to_string())
}
#[tauri::command]
async fn restart_server(state: State<'_, ServerState>) -> Result<(), String> {
state.0.restart().await.map_err(|e| e.to_string())
}
fn main() {
tauri::Builder::default()
.setup(|app| {
let runtime = tokio::runtime::Runtime::new().unwrap();
// Initialize VSCode server
let server = runtime.block_on(async {
let server = TauriVscodeServer::new(TauriConfig::default()).await?;
server.initialize().await?;
Ok::<_, Box<dyn std::error::Error>>(server)
})?;
app.manage(ServerState(Arc::new(server)));
Ok(())
})
.invoke_handler(tauri::generate_handler![
get_server_info,
restart_server
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
In your frontend (with monaco-vscode-api):
// Get server configuration from Tauri
const serverInfo = await invoke('get_server_info');
// Initialize monaco-vscode-api with the server URL
import { initialize } from '@codingame/monaco-vscode-api';
await initialize({
serviceConfig: {
baseUrl: serverInfo.serverUrl,
connectionToken: serverInfo.serviceConfig.connectionToken
}
});
use monaco_vscode_server::{VscodeServerManager, ServerConfig};
let config = ServerConfig {
port: 8001,
host: "127.0.0.1".to_string(),
server_dir: PathBuf::from("./my-vscode-server"),
disable_telemetry: true,
connection_token: None,
args: vec![
"--accept-server-license-terms".to_string(),
],
};
let manager = VscodeServerManager::with_config(config).await?;
VscodeServerManagerMain manager for the VSCode server.
new() - Create with default configurationwith_config(config) - Create with custom configurationensure_server() - Download server if neededstart() - Start the serverstop() - Stop the serveris_running() - Check if server is runningurl() - Get the server URLinfo() - Get server version informationTauriVscodeServerHelper specifically for Tauri applications.
new(config) - Create new instanceinitialize() - Download and optionally start serverget_info() - Get info for frontendstop() - Stop the serverrestart() - Restart the server| Platform | Architecture | Status |
|---|---|---|
| Windows | x86_64 | ✅ |
| macOS | x86_64 | ✅ |
| macOS | ARM64 | ✅ |
| Linux | x86_64 | ✅ |
| Linux | ARM64 | ✅ |
| Linux | ARMv7 | ✅ |
By default, servers are stored in:
~/.cache/monaco-vscode-server/%LOCALAPPDATA%\monaco-vscode-server\Override the server directory using the server_dir field in ServerConfig or by setting the VSCODE_SERVER_DIR environment variable.
The crate automatically:
package.json to find the VSCode commitThis ensures compatibility between monaco-vscode-api and the VSCode server.
Check that the port isn't already in use. The default port is 8001. If you need to change it:
let config = ServerConfig {
port: 8002, // Try a different port
..Default::default()
};
The crate respects system proxy settings. For custom proxy:
export HTTPS_PROXY=http://proxy.example.com:8080
Ensure the server directory is writable. Use a custom directory:
let config = ServerConfig {
server_dir: PathBuf::from("/tmp/vscode-server"),
..Default::default()
};
MIT - See LICENSE file for details.
Note: The VSCode server itself is subject to Microsoft's license terms.