XRack for VS Code
The extension adds definition navigation, semantic highlighting, context-sensitive completions, diagnostics, a component outline, and live previews for .xr files. The Rust server reuses the XRack parser and semantic analyzer.
Use Go to Definition (F12 or Ctrl/Cmd-click) on properties, component IDs, callbacks, parameters, repeat bindings, record fields, and imported types. Hover for symbol information, or place the cursor on a symbol to highlight its occurrences in the current file. Semantic highlighting distinguishes declared components, records, built-in types, enum variants, properties, callbacks, and local bindings. The TextMate grammar provides highlighting while the server starts.
Use Find All References or Rename Symbol (F2) to work across the open workspace's .xr sources and their imports. Renaming an explicit import alias updates the alias and its local uses. Renaming an exported component updates the original name in import clauses and leaves explicit aliases intact. Rename checks the affected scopes and rejects edits that introduce a declaration conflict or change which declaration a reference resolves to.
The server reports progress while indexing workspace files in the background. Unsaved edits take precedence over disk contents. Rapid changes are grouped before diagnostics and indexing run. File watcher events update the affected entries, and closing a document restores its saved contents. Reference and rename requests wait for pending index updates and can be cancelled while waiting.
The workspace index is cached in VS Code's extension storage. On restart XRack checks saved file contents and import paths before reusing references. Changed files and affected importers are rebuilt. Unsaved buffers stay in memory.
Definition and rename use the compiler's resolved declarations where available, including inherited members. The editor index continues to provide navigation while a file is incomplete. Use Go to Symbol in Workspace to find components and records. In an element or type position, completion can offer an exported declaration from another file and insert its import when you accept it.
Callback calls show parameter names and types as you type, including the active argument in nested calls. Ctrl/Cmd-click an import path to open its file. When a diagnostic reports a missing component, use Quick Fix to import an exported component with that name.
Use Format Document to format a .xr file. The formatter uses the editor's tab size and space settings and preserves comments and string literals. The XRack repository enables formatting on save. To enable it in another workspace, add these settings to its .vscode/settings.json.
{
"[xrack]": {
"editor.defaultFormatter": "SunJiahe.xrack",
"editor.formatOnSave": true
}
}
Type { to see the current component's writable properties and event handlers. Type a prefix such as anchor-r to narrow the list, or select clicked to insert a handler body. Handler snippets include editable parameter names and can give an unnamed control a unique ID. In an expression or handler, use root., self., or a named element such as field. to see the receiver's properties and methods. Press Ctrl+Space to reopen suggestions.
If import { Card as Tile } from "widgets.xr"; introduces a component, card := Tile { } makes its public properties and callbacks available after card.. In the instance body, selecting a callback inserts a handler using its declared parameter names and shows the return type. Open files are read from the editor buffer, so unsaved changes to exported members show up in completions.
With the from "widgets.xr" path in place, completion inside the import braces suggests exported components and records. A preceding font import can stay in the same file. In for item[index] in root.people : Text { ... }, a declared [Person] model lets item. suggest the record's fields and shows index as an int.
Install the VSIX for your platform with Extensions → Install from VSIX… and open an .xr file. The platform package includes xrack-lsp, xrackc, the xrack-preview host, and runtime sources for the generated-code fallback.
Type Math., Strings., Model., or Log. for built-in functions and constants. Type @ for constructs such as @tr. Hover over a built-in to see its signature and usage. Signature help follows the active argument in calls such as Log.write(LogLevel.debug, Strings.format("count={}", root.count)), and LogLevel. offers all five levels inside Log.write.
Live preview
The platform VSIX includes the media backend for MediaPlayer and SoundEffect. Use XRack: Open Live Preview to play or seek a video. In examples/sound_effect/sound_effect.xr, click the play button or press F2 with the preview focused to trigger a preloaded WAV. In a source checkout, build the media-enabled host with bazel build --config=media //crates/xrack-preview. Relative media paths are resolved from the .xr file. FFmpeg source and build inputs are available with each XRack release. XRack releases
Open a saved .xr file and choose XRack: Open Live Preview from the Command Palette or use the preview button in the editor title bar. The side panel follows edits to that file and its open imports, including unsaved edits. Use the component dropdown to choose an entry component. Click buttons in the preview to run their XRack handlers and see the updated component state. While a new frame is building, the previous frame stays visible. Compiler errors appear above it and clear automatically after the next successful render.
For supported components, the bundled preview host loads optimized XR MLIR into the XRack interpreter and keeps the XRack wgpu renderer alive across edits. Click a text input to type or paste into it, and click a slider track to change its value. Use the wheel to scroll a viewport or click its scrollbar track. Supported transitions and animated GIFs play in the panel. PNG, SVG, sprite atlases, and nine-slice images use the same renderer as compiled components. Source edits create a fresh component instance, and a failed edit leaves the previous frame available. This path requires a working graphics adapter. Components that use operations the interpreter does not yet support use the generated-code preview, which requires Cargo and a compatible Rust toolchain. In a source checkout, build the preview host with bazel build //crates/xrack-preview. Use xrack.preview.compilerPath to configure the compiler for the generated-code preview.
Drag the canvas background to move the preview. Turn on Pan or hold Alt to drag directly on the component. Use −, +, or Alt + wheel to zoom, the percentage button to return to actual size, and Fit to keep the component centered and within the panel. Trackpad pinch also zooms the view in Pan mode. These controls change the view of the rendered component while preserving its layout and state.
Open View → Output and select XRack Preview to see UI logs as handlers run. For example, Log.debug(Strings.format("count={}", root.count)); prints the current value together with the component and source location.
Window presentation commands update the preview component's window state inside the panel. If the component calls minimize(), use Restore preview window to show it again.
In the interpreter preview, open Inspect to see the rendered element tree and the component's public property declarations. Select an element to highlight its visible bounds. The tree shows which element has focus and which elements are disabled.
In a 3D preview, turn on 3D Edit and select a model in the image or a node in the 3D scene tree. The tree groups nodes by viewport and shows cameras, lights, probes, and spatial panels. Selecting a declared node shows its properties and can navigate to its source, including an imported component. Go to source reveals the matching declaration. In the current file, edit explicit transform literals and choose Apply to source to update the unsaved editor buffer and redraw the preview. Expressions and inherited values stay read-only. A selection outline shows its clipped viewport bounds, including individual instances and mounted 2D panels. Use Frame selected to bring the selection into view, then Reset camera to return to the authored camera. Framing is scoped to the preview window. After framing, turn on Navigate to orbit by dragging, pan with Shift-drag and move the camera with the wheel. Alt + wheel zooms the preview image.
Drag a visible X, Y, or Z handle to move the selected model in its parent's coordinate space. The handle and value follow the drag, and releasing applies a single undoable edit and redraws the scene. The preview pauses automatic frame updates while 3D Edit is enabled.
For static mesh references, Reveal asset locates the file in Explorer. Replace mesh… opens a file picker and updates the selected record. Import options are retained. Inherited mesh references are overridden on the selected record.
Source debugging
Set a breakpoint on a statement in a .xr callback or function, then run XRack: Debug Preview. Interact with the preview to reach the breakpoint. Use Step Over, Step Into, and Step Out in the VS Code debug toolbar. The Call Stack links to XR source, and Variables shows locals and cached properties for the innermost call. Restart the debug session after editing the source.
Development
From the XRack repository root, build the server and install the extension dependencies.
bazel build //crates/xrack-lsp:xrack-lsp //:xrackc
bazel run --config=vsix @xrack_pnpm//:pnpm -- --dir "$PWD/crates/xrack-lsp/vscode" install --frozen-lockfile
code crates/xrack-lsp/vscode
Press F5 in that VS Code window to open an Extension Development Host at the XRack repository root. Open examples/counter/counter.xr. Change count * 2 in doubled to missing * 2 to see a diagnostic without saving. Undo the change to clear it. The Outline view shows Counter.
The extension first uses its bundled server if available. In development, it looks for the Bazel build under the workspace's bazel-bin/crates/xrack-lsp/ directory and then for xrack-lsp on PATH. Set xrack.server.path to override the executable, then reload the window. The server uses stdio and can also be launched by other LSP clients.
Semantic diagnostics follow direct and transitive imports. Open buffers take precedence over disk, and changing or closing a dependency refreshes diagnostics for the files that import it. VS Code also reports changes to .xr files on disk. When an error is in an imported file, the dependent file shows a diagnostic with a link to the original location. Run xrackc --check for MLIR and resource checks.
bazel test //crates/xrack-lsp:xrack_lsp_test
Packaging and Marketplace releases
GitHub Actions builds and smoke-tests all five VSIX files on pushes to main. You can also enable package-vsix on a manual CI run. The packages target darwin-arm64, linux-x64, linux-arm64, win32-x64, and win32-arm64. Each includes the host's compiler, language server, preview executable, and fallback runtime sources.
Build the native VSIX from the repository root. Bazel uses aspect_rules_js to fetch the extension and vsce packages from their checked-in pnpm lockfiles. Packaging and publishing use the generated vsce_binary. Its launcher supplies Bazel's Node.js and npm for dependency discovery. The packager arranges the locked extension packages in a portable npm layout using package-lock.json and includes the native binaries, fallback SDK and notices.
bazel build --config=vsix //crates/xrack-lsp:vsix
The package is in bazel-bin/tools/xrack-<version>-<platform>.vsix. To run the JavaScript tests and the native smoke test used by CI:
bazel test --config=vsix //tools:vscode_js_test //tools:vscode_vsix_test
Sign in to Visual Studio Marketplace publisher management and create or select the publisher. Its ID must match publisher in this extension's package.json, currently SunJiahe.
In the GitHub repository's Environments settings, create vscode-marketplace. If you restrict deployments to selected branches and tags, allow release tags such as v0.12.0.
In the Marketplace publisher, open Trusted Publishing and create the following policy.
| Field |
Value |
| Policy name |
XRack VS Code release |
| Repository owner |
smallsunsun1 |
| Repository |
xrack |
| Workflow |
release-crates.yml |
| Environment |
vscode-marketplace |
The publish job uses GitHub OIDC via vsce publish --oidc. The policy supplies its publishing authorization. Trusted Publishing documentation
Publish a version
Set the extension version in package.json and package-lock.json to match the Cargo workspace. Once CI passes on the release commit on main, push the matching tag.
git fetch origin
git tag -a v0.12.0 origin/main -m "XRack 0.12.0"
git push origin v0.12.0
Release XRack checks the tag and downloads the verified artifacts from the successful native matrix on that exact commit. If an upload fails after some targets have been published, rerun the failed jobs to finish the release.