Skip to content
olimpiadi-informaticaPublic

About

Wasm-based IDE

Resources

Stars

5 stars

Watchers

5 watching

Forks

Repository files navigation

wasm-ide

wasm-ide is a browser-based IDE for competitive programming. It compiles and runs code in a Web Worker, stores workspaces in the browser filesystem, and can optionally connect to remote evaluation and contest systems.

Using a precompiled release

Download wasm-ide.tar.gz or wasm-ide.zip from the latest release, extract it into a directory served by your web server, and adjust config.json as needed.

The application must be served over HTTPS; opening index.html directly is not supported. It also requires cross-origin isolation, so every response must include these headers:

Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Opener-Policy: same-origin

Compiler archives in the release are Brotli-compressed. Requests for /compilers/<language>.tar must be served from the corresponding .tar.br file with Brotli content encoding. For example, an nginx server with the ngx_brotli module can use:

server {
    listen 80;
    server_name _;

    root /path/to/wasm-ide;
    index index.html;

    add_header Cross-Origin-Embedder-Policy require-corp always;
    add_header Cross-Origin-Opener-Policy same-origin always;

    location / {
        try_files $uri $uri/ =404;
    }

    location /compilers/ {
        brotli_static on;
    }
}

Use HTTPS for a public deployment. TLS configuration is omitted from this minimal example.

Configuration

The frontend loads config.json from the web root at startup. The release archive includes a ready-to-use configuration; source builds use config.json when present and otherwise fall back to config.example.json.

The main fields are:

  • title: an optional window/tab title for the application. Set to null or omit to preserve the default title.
  • default_ws: initial code and stdin files for a new local workspace. Each object maps a filename to either a UTF-8 string or an array of bytes.
  • remote_eval: an optional endpoint for a remote evaluation backend. Set it to null to use only the in-browser backends.
  • contest: an optional contest-system connection. Set it to null when no contest integration is needed.
  • workspace_enabled: whether to show workspace management. It defaults to true; set it to false to use a persistent workspace named default automatically. This mode cannot be combined with a contest integration.
  • auto_init_contest_tasks: an optional language name (e.g., "C++"). When configured with a contest system, wasm-ide automatically queries the contest API at startup and creates non-deletable workspaces for all contest tasks using this language (if not already present).
  • default_locale: the initial interface language. A locale previously selected by the user takes precedence; set this field to null to use the browser language.
  • default_settings: default values for user settings. It can contain any subset of the settings stored by wasm-ide; omitted values use the built-in defaults. These values are used only when the browser has no saved settings.
  • compilers: the generated map of compiler archive names to their uncompressed sizes. Preserve this field in a precompiled release. Source builds generate it from the archives in compilers/.

Contest configuration is internally tagged. For CMS:

{
  "contest": {
    "type": "cms",
    "endpoint": "https://cms.example"
  }
}

For Terry, use "type": "terry" with the appropriate endpoint. Only one contest system can be configured at a time.

Evaluation backends

By default, wasm-ide compiles and runs C, C++, Python, Rust, and JavaScript locally in the browser. Additional languages can be made available through a remote evaluator by setting remote_eval in config.json.

The recommended remote evaluator is eval-server from olimpiadi-informatica/task-maker-rust. Remote evaluation does not support streaming input or language-server features.

Compiling from source

Install Rust and ensure ~/.cargo/bin is in PATH. The repository's toolchain file selects stable Rust and the WebAssembly target; then install Trunk:

rustup target add wasm32-unknown-unknown
cargo install --locked trunk

The build also requires npm, jq, and brotli in PATH.

Download the .tar.br compiler archives from olimpiadi-informatica/wasm-compilers and place them in compilers/. With the GitHub CLI installed, this can be done with:

mkdir -p compilers
gh release download --repo olimpiadi-informatica/wasm-compilers \
  --dir compilers --pattern '*.tar.br'

Optionally create config.json to override the example configuration, then build the production bundle:

trunk build --release

The complete static application is written to dist/. Serve that directory with the headers and Brotli handling described above.

Adding a translation

Translations are stored as JSON files in frontend/locales. To add a language:

  1. Copy frontend/locales/en.json to a file named after the new locale.
  2. Translate the values while preserving every key and placeholder such as {{score}}.
  3. Add the locale to the locales list in frontend/Cargo.toml.
  4. Rebuild the frontend and check the new language in the interface.

Adding a contest integration

Contest integrations live in frontend/src/contest_api. Start with the module documentation in frontend/src/contest_api/mod.rs, which describes the extension process and the ContestAPI contract.

In short, a new integration needs a protocol-specific module, a ContestConfig variant, an implementation of the ContestAPI trait, and a constructor entry in contest_api::init. The existing CMS and Terry modules are working examples.

About

Wasm-based IDE

Resources

Stars

5 stars

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages