page wrnexussyntax { seo { title = "@wrnexus/syntax" description = "Editor syntax definitions and language tooling for .wrn files." } view {
W WRNexusJS
Browse documentation
Frontend · Package reference

@wrnexus/syntax

Editor syntax definitions and language tooling for .wrn files.

v0.8.8Private registryFrontend

Install the package

After WorkRoot approves private registry access, install the release-aligned package:

bun add @wrnexus/syntax@0.8.8

Request preview access. Never put registry tokens in source control.

Canonical WRN lexer, parser, AST, language metadata, source positions, and stable diagnostics. Framework tooling should import this package instead of implementing a separate .wrn parser.

See docs/WRN-LANGUAGE-SPEC-1.0.md in the WRNexusJS repository.

Complete TypeScript API

Generated from the exact installed package declarations.

export { LexError, Lexer } from './tokenizer.js';
export { FormatWrnOptions, formatWrn } from './formatter.js';
export { A as ActionBlock, a as ApiBlock, b as Attr, C as ComputedDecl, D as DataApiBlock, c as DataMode, E as EffectBlock, d as EventDecl, F as FunctionParameterDecl, e as FunctionRuntime, L as LifecycleBlock, f as LoadBlock, M as ModeFunctionsBlock, O as OutputDecl, P as PageAst, g as ParseError, h as PersistDecl, i as PropDecl, R as RealtimeBlock, j as RealtimeHandler, k as RuntimeFunctionDecl, S as SeoBlock, l as StateDecl, m as StateRuntime, n as StoreKind, o as StoreLifecycleDecl, p as StructuredImportDecl, V as VOID_ELEMENTS, q as ViewNode, W as WatchBlock, r as parse, s as parseComputedDeclarations, t as parseHtmlView, u as parseOutputs, v as parsePersist, w as parseRuntimeFunctions, x as parseStateDeclarations, y as parseStoreLifecycle, z as parseStructuredImports, B as stripRuntimeFunctionModifiers } from './parser-CTLO4mcT.js';
export { RuntimeType, eraseFunctionTypes, inferredRuntimeType, runtimeTypeOf, validateTypedInitializer } from './types.js';
import { WrnDiagnostic } from './diagnostics.js';
export { DiagnoseOptions, WrnDiagnosticSeverity, WrnSourcePosition, assertValidAst, classifyParseError, containsReadonlyPropMutation, diagnose, diagnosticFromError, formatDiagnostic, isHydrationStrategy, isRuntimeTarget, positionAt } from './diagnostics.js';
export { WRN_DIAGNOSTIC_CODES, WRN_HYDRATION_STRATEGIES, WRN_LANGUAGE_VERSION, WRN_ROOT_KINDS, WRN_ROOT_MEMBERS, WRN_RUNTIME_TARGETS, WrnHydrationStrategy, WrnRootKind, WrnRootMember, WrnRuntimeTarget } from './spec.js';

/** Current stable syntax contract. Bump only when parsers/codegen need migration. */
declare const WRN_SYNTAX_VERSION: "0.4";
type WrnSyntaxFeature = "typed-declarations" | "layouts" | "server-client-blocks" | "effects" | "watch" | "lifecycle" | "embedded-api" | "realtime" | "runtime-markers";
declare const WRN_SYNTAX_FEATURES: Readonly<Record<WrnSyntaxFeature, boolean>>;
interface SourceRange {
    start: number;
    end: number;
}
declare function createSourceRange(start: number, end: number): SourceRange;
declare function sliceSource(source: string, range: SourceRange): string;
declare function diagnosticSummary(diagnostics: readonly WrnDiagnostic[]): {
    errors: number;
    warnings: number;
    info: number;
    codes: Record<string, number>;
};
declare function supportsSyntaxFeature(feature: string): feature is WrnSyntaxFeature;

export { type SourceRange, WRN_SYNTAX_FEATURES, WRN_SYNTAX_VERSION, WrnDiagnostic, type WrnSyntaxFeature, createSourceRange, diagnosticSummary, sliceSource, supportsSyntaxFeature };

Examples

Copy-ready examples from the installed package documentation.

Parse a WRNexusJS document

import { parse } from "@wrnexus/syntax";

const ast = parse('component Greeting { view { <p>Hello</p> } }');

Summarize syntax diagnostics

import { diagnose, diagnosticSummary } from "@wrnexus/syntax";

const summary = diagnosticSummary(diagnose(source));
} }