How stremio/stremio-core-web works
1. Overall role
- This repository is a WebAssembly bridge package between the Rust-based stremio-core and the JavaScript application stremio-web.
- Its job is not to implement the whole product, but to adapt core domain data and events into a web-friendly boundary that can be consumed from JS/npm.
2. Top-level runtime split
- The codebase is split into a Rust/WASM side and a JavaScript integration side.
- Rust owns the domain-facing logic and serialization adapters.
- JS owns the package entry points and worker/bridge glue used by the web app.
3. Rust crate as the main architecture center
- Cargo.toml, Cargo.lock, rust-toolchain.toml, and src/lib.rs indicate the primary deliverable is a Rust library compiled to WASM.
- src/stremio_core_web.rs is likely the crate façade that exposes the web bridge API.
- src/env.rs and src/event.rs suggest the bridge depends on a controlled runtime environment and an event channel for notifications back to the web layer.
4. Boundary between core models and web serialization
- The src/model/ directory is the most important subsystem.
- It contains a set of serializer/adaptor modules such as serialize_library.rs, serialize_player.rs, serialize_streaming_server.rs, serialize_discover.rs, and others.
- This indicates the repo translates internal stremio-core structures into JS/WASM-safe shapes for specific product areas instead of exposing raw core types.
5. Feature-oriented model adapters
- src/model/model.rs and src/model/mod.rs likely define the shared model layer and module wiring.
- The various serialize_* files map to distinct product domains: library, discover, player, local search, remote addons, installed addons, data export, meta details, continue-watching preview, and catalogs.
- This means the architecture is organized around use-case slices, not around generic transport helpers.
6. Deep-link support as a dedicated extension layer
- src/model/deep_links_ext/ is a separate subsystem for deep-link handling.
- Files like video_deep_links.rs, stream_deep_links.rs, library_deep_links.rs, and search_history_deep_links.rs show that navigation/state-entry points are modeled explicitly.
- This layer likely converts app-specific routes or intents into core actions and serializable link targets.
7. JavaScript bridge and worker boundary
- src/bridge.js and src/worker.js are the browser-side integration points.
- Their presence strongly suggests the WASM module runs behind a worker-based or message-passing bridge, isolating heavy core logic from the UI thread.
- This is the main boundary where JS communicates with Rust-generated behavior.
8. Data flow through the package
- The likely flow is: stremio-web sends requests/events into the JS bridge → JS forwards them to the WASM/Rust layer → Rust uses core-derived models and env/event abstractions → results are serialized back to JS.
- The event module implies asynchronous updates are pushed back out, not just request/response calls.
- The model serializers are the main output boundary for these flows.
9. Build and packaging architecture
- package.json, package-lock.json, .babelrc, and .npmignore show this repo is packaged for the npm ecosystem.
- scripts/build.sh and the README’s build flow indicate a production build compiles the Rust crate to WASM and then prepares JS/package artifacts.
- The repo is therefore a cross-language build pipeline, not a single-language library.
10. Development and debug mode
- The README notes a --dev build path and a cargo wasm-watch workflow from .cargo/config.toml.
- That implies the package supports incremental recompilation and verbose debug logging during development, with a warning that debug logs may include sensitive data.
- This is a tooling concern that affects how the bridge is operated locally.
11. CI/CD and release lifecycle
- .github/workflows/build.yml, prerelease.yml, and publish.yml define automated build and release flows.
- Publishing targets both GitHub Releases and the npm registry.
- Versioning is coordinated across Cargo and npm manifests, so release management is part of the repo’s operational architecture.
12. External dependencies and product boundaries
- The repository depends structurally on stremio-core and is consumed by stremio-web.
- That makes it an adapter layer between a shared domain core and a web client, with a stable contract defined by WASM exports, JS bridges, and serialized model shapes.
- For an architecture diagram, this repo should be shown as a middle-tier packaging/interop layer rather than an end-user application or backend service.
Main entry points: mod.rs Model layer · stremio_core_web.rs Web facade · build.sh Build script · publish.yml Publish
Components 23
JavaScript bridge
Package entry points and worker boundary used by the web app.
Rust/WASM core
Primary library compiled to WebAssembly and hosting bridge logic.
- Library · Crate root and WASM-exported public surface.
src/lib.rs - Web facade · High-level Rust facade for the web bridge API.
src/stremio_core_web.rs - Env · Controlled execution environment for bridge operations.
src/env.rs - Events · Async event channel back to the JavaScript layer.
src/event.rs
Model adapters
Feature-oriented serializers and deep-link extensions.
- Model layer · Module wiring for all web-safe model adapters.
src/model/mod.rs - Shared model · Common model definitions and adapter support.
src/model/model.rs - Context · Shared serialization context and helpers.
src/model/serialize_ctx.rs - Library data · Library domain serialization for web consumption.
src/model/serialize_library.rs - Player data · Player-related serialization boundary.
src/model/serialize_player.rs - Discover data · Discovery/catalog browsing serialization.
src/model/serialize_discover.rs - Streaming server · Streaming-server and playback-adjacent serialization.
src/model/serialize_streaming_server.rs - Remote addons · Remote addon listing and shape conversion.
src/model/serialize_remote_addons.rs - Deep links · Route and intent adapters for entry-point links.
src/model/deep_links_ext/mod.rs - Video links · Video-level deep-link handling.
src/model/deep_links_ext/video_deep_links.rs
Build and release
Cross-language build, packaging, and publishing pipeline.
- Build script · Repository build orchestration for Rust-to-WASM packaging.
scripts/build.sh - Cargo · Crate configuration and dependency boundary.
Cargo.toml - CI build · Automated build and verification pipeline.
.github/workflows/build.yml - Pre-release · Pre-release automation for distributable artifacts.
.github/workflows/prerelease.yml - Publish · Release publishing to package and release channels.
.github/workflows/publish.yml
Other components
- stremio-web · Browser client consuming the bridge package.
- stremio-core · Shared Rust domain core adapted by this package.
Connections 22
- stremio-web → Bridge: uses · Web app calls into the package bridge.
- Bridge → Worker: spawns · JS bridge delegates heavy work to the worker boundary.
- Worker → Library: loads WASM · Worker communicates with the Rust/WASM library.
- Library → Web facade: exposes · Public facade for web-facing bridge behavior.
- Web facade → Env: uses · Facade relies on controlled runtime environment.
- Web facade → Events: emits · Facade forwards async events back to JS.
- Web facade → Model layer: adapts · Facade uses the model adapter layer.
- Model layer → Shared model: shares · Common model definitions underpin serializers.
- Model layer → Context: builds on · Serializer wiring uses shared context helpers.
- Model layer → Library data: includes · Library-domain serialization boundary.
- Model layer → Player data: includes · Player-domain serialization boundary.
- Model layer → Discover data: includes · Discover-domain serialization boundary.
- Model layer → Streaming server: includes · Streaming-server serialization boundary.
- Model layer → Remote addons: includes · Remote-addon serialization boundary.
- Model layer → Deep links: extends · Wires in explicit deep-link handling.
- Deep links → Video links: specializes · One representative deep-link adapter.
- Web facade → stremio-core: adapts · Rust bridge translates shared core domain into web-safe shapes.
- Build script → Cargo: drives · Build script orchestrates the Rust/WASM package build.
- CI build → Build script: runs · CI executes the build pipeline.
- Pre-release → Build script: runs · Pre-release automation reuses the build pipeline.
- Publish → Cargo: packages · Release workflow coordinates Rust package versioning.
- Publish → stremio-web: delivers to · Published artifacts are intended for the web client ecosystem.