Expand description
Static analysis library for Components.js projects.
Components.js is a semantic dependency injection framework for TypeScript/JavaScript that
describes classes and their constructor parameters in JSON-LD files (components.jsonld) and
wires concrete instances together in configuration files (config/*.jsonld).
This crate reads those files and produces typed Rust structs that a language server can use to implement:
- Autocompletion of
@typevalues and parameter keys in config files - Hover documentation from
rdfs:commentstrings - Goto-definition via byte-range spans (
iri_span) stored on every extracted type - Diagnostics for missing required parameters or unknown component IRIs
§Typical usage (in an LSP)
ⓘ
use components_rs::{fs::OsFs, module_state::ModuleState,
components::registry::ComponentRegistry,
config::registry::ConfigRegistry};
let fs = OsFs;
let state = ModuleState::build(&fs, &project_root).await?;
let mut comp_reg = ComponentRegistry::new();
comp_reg.register_available_modules(&fs, &state).await?;
comp_reg.finalize(); // resolves inherited parameters
let mut cfg_reg = ConfigRegistry::new();
cfg_reg.discover_configs(&fs, &state).await?;§Module map
| Module | Purpose |
|---|---|
module_state | Entry point — discovers all packages and builds the shared lookup tables |
components | Extracted component classes, parameters, and modules |
config | Extracted configuration instances (concrete wirings) |
context | JSON-LD context resolution and IRI expansion/compaction |
discovery | Low-level node_modules traversal and package.json parsing |
fs | Abstract filesystem trait (swap in-memory impl for WASM/tests) |
error | Shared error type |
Modules§
- components
- Component extraction — the classes and parameters defined in
components.jsonldfiles. - config
- Configuration instance extraction — the concrete wirings in
config/*.jsonldfiles. - context
- JSON-LD context resolution: expanding compact IRIs to full IRIs and back.
- discovery
- Low-level discovery of npm packages and their Components.js metadata.
- error
- Shared error type for all fallible operations in this crate.
- fs
- Abstract filesystem trait and the default OS-backed implementation.
- module_
state - Project-wide state: the shared lookup tables built from all discovered packages.