@rsc-xray/schemas
v0.8.0
Published
TypeScript types and JSON schema for RSC X-Ray model: shared contracts for analyzer, CLI, and reporting tools
Maintainers
Readme
@rsc-xray/schemas
Shared TypeScript types and JSON schema that define the model.json contract between the analyzer, CLI, HTML report, and Pro tooling.
What it solves
- Provides canonical TypeScript types (
Model,XNode, etc.) so packages can share a single source of truth. - Exposes a JSON schema suitable for runtime validation (used by the CLI and CI workflows).
- Keeps the OSS analyzer and Pro overlay in lockstep when the model evolves.
Installation
pnpm add -D @rsc-xray/schemasStep-by-step usage
Import the types where you consume
model.json:import type { Model } from '@rsc-xray/schemas'; const model: Model = JSON.parse(await fs.promises.readFile('model.json', 'utf8'));Validate at runtime (optional but recommended):
import Ajv from 'ajv'; import { modelSchema } from '@rsc-xray/schemas'; const ajv = new Ajv({ allErrors: true }); const validate = ajv.compile(modelSchema); if (!validate(model)) { throw new Error(ajv.errorsText(validate.errors)); }Sync with the CLI/analyzer — both rely on this package, so your code stays compatible as long as you import the same version.
Tests
packages/cli/src/commands/__tests__/analyze.test.tsandpackages/cli/src/commands/__tests__/report.test.tsvalidate models against this schema.packages/schemas/src/index.test.tssnapshots the exported schema to prevent accidental breaking changes.
Run the schema tests with:
pnpm -F @rsc-xray/schemas test -- --runRSC X‑Ray Pro
Paid plans available — unlock the full toolkit:
- Overlay UI — live boundary tree, Suspense markers, bundle bytes, hydration timings
- Flight tap & timeline — capture React Flight streaming; visualize chunk order, sizes, labels
- Cache lens — inspect
tags, revalidate policies, and route impact - Waterfall detector — find sequential awaits; guided fixes (preload/parallelize)
- Codemods —
use client, wrap with Suspense, add preload/hydration hook - VS Code extension — analyzer diagnostics + “Open in XRay” deep links
- CI budgets & trends — PR comments, thresholds, and historical deltas
Learn more → https://rsc-xray.dev • Pricing → https://rsc-xray.dev/pricing
