fix: include vendored compiler runtime

This commit is contained in:
2026-08-03 00:10:08 +05:30
parent 76d4e5825a
commit 20f3564fb4
3 changed files with 3536 additions and 0 deletions
+2
View File
@@ -1,6 +1,8 @@
node_modules/ node_modules/
.wrnexus/ .wrnexus/
dist/ dist/
!vendor/compiler/dist/
!vendor/compiler/dist/**
**/.wrnexus/ **/.wrnexus/
coverage/ coverage/
.env .env
+242
View File
@@ -0,0 +1,242 @@
import { PageAst as PageAst$1, StructuredImportDecl, WrnDiagnostic } from '@wrnexus/syntax';
export { ActionBlock, ApiBlock, Attr, ComputedDecl, DataApiBlock, DataMode, EffectBlock, EventDecl, FormatWrnOptions, LexError, Lexer, LoadBlock, ModeFunctionsBlock, OutputDecl, PageAst, ParseError, PropDecl, RealtimeBlock, RuntimeFunctionDecl, SeoBlock, StateDecl, StateRuntime, StoreKind, StructuredImportDecl, ViewNode, WrnDiagnostic, assertValidAst, diagnose, diagnosticFromError, eraseFunctionTypes, formatDiagnostic, formatWrn, inferredRuntimeType, parse, runtimeTypeOf } from '@wrnexus/syntax';
import { PageAst } from '@wrnexus/syntax/parser';
/**
* Code generation: lower a `.wrn` AST to TypeScript that targets the framework's
* existing primitives.
*
* state -> a `data-scope` declaration consumed by the runtime
* view -> an HTML string returned by a page component
* @event="..." -> data-on-<event>="..."
* "...{expr}..." -> text kept verbatim ({expr} is mustache for runtime)
* api="<name>" -> SSR/client data binding declared in a mode block
* ssrGet/ssrText -> legacy server-side API fetch + render
* csrGet/csrText -> legacy browser-side API fetch + render
* style -> tagged local stylesheet metadata promoted by SSR
* functions -> server-only helpers for API/realtime code
* api M /p {b} -> export const M = async (ctx) => { b }
* realtime {..} -> export const websocket = { evt(ws, ...args) { b } }
*/
declare function generate(ast: PageAst): string;
interface ComponentContractMetadata {
name: string;
kind: PageAst$1["kind"];
props: Array<{
name: string;
type: string;
required: boolean;
default?: string;
options?: string[];
}>;
outputs: Array<{
name: string;
payloadName?: string;
payloadType?: string;
}>;
functions: Array<{
name: string;
runtime: string;
async: boolean;
parameters: Array<{
name: string;
type: string;
optional: boolean;
}>;
returnType: string;
}>;
states: Array<{
name: string;
runtime: string;
type: string;
initializer: string;
}>;
computed: Array<{
name: string;
type: string;
expression: string;
}>;
imports: Array<{
source: string;
typeOnly: boolean;
defaultImport?: string;
namedImports: string[];
}>;
}
declare function createComponentContract(ast: PageAst$1): ComponentContractMetadata;
interface RpcManifestEntry {
id: string;
component: string;
function: string;
parameters: Array<{
name: string;
type: string;
optional: boolean;
}>;
returnType: string;
}
declare function rpcManifest(ast: PageAst$1): RpcManifestEntry[];
declare function generateServerFunctionsModule(ast: PageAst$1): string;
interface CompileTargets {
server: string;
browser: string;
declarations: string;
contract: ReturnType<typeof createComponentContract>;
rpc: ReturnType<typeof rpcManifest>;
}
declare function generateTargets(ast: PageAst$1): CompileTargets;
declare function generateBrowserModule(ast: PageAst$1): string;
declare function generateDeclarations(ast: PageAst$1): string;
declare function generateStoreModule(ast: PageAst$1): string;
/** Standalone browser artifact for an imported `.wrn` store. */
declare function generateStoreBrowserModule(ast: PageAst$1): string;
type ImportMode = "legacy" | "compatible" | "explicit";
interface ImportResolverOptions {
appRoot: string;
mode?: ImportMode;
aliases?: Record<string, string>;
}
interface ResolvedImport {
declaration: StructuredImportDecl;
resolved?: string;
diagnostic?: {
code: string;
message: string;
severity: "error" | "warning";
};
}
declare function resolveWrnImport(declaration: StructuredImportDecl, importer: string, options: ImportResolverOptions): ResolvedImport;
declare function resolveWrnImports(declarations: StructuredImportDecl[], importer: string, options: ImportResolverOptions): ResolvedImport[];
interface WrnSourceMapEntry {
generatedLine: number;
sourceLine: number;
sourceColumn: number;
kind: string;
}
interface WrnSourceMap {
version: 1;
source: string;
generated: string;
mappings: WrnSourceMapEntry[];
}
declare function createWrnSourceMap(source: string, generated: string): WrnSourceMap;
type RouteExecutionKind = "static" | "static-interactive" | "request-ssr" | "authenticated-ssr" | "streaming-ssr" | "dynamic";
interface RuntimeRequirements {
kind: RouteExecutionKind;
canPrerender: boolean;
needsClientRuntime: boolean;
needsServerRuntime: boolean;
hydrationStrategy: string | null;
reasons: string[];
optimization: OptimizationReport;
cachePolicy: Record<string, string>;
requiredPermission: string | null;
}
interface OptimizationReport {
staticNodes: number;
reactiveRegions: number;
eliminatedBranches: number;
unusedState: string[];
unusedHandlers: string[];
constantProps: string[];
unusedLocalCssClasses: string[];
batchableStateUpdates: number;
memoizableComponents: string[];
preloadDependencies: string[];
serverOnlyModules: string[];
}
/** Safe compile-time folding for literal conditional branches. */
declare function optimizeAst(ast: PageAst$1): {
ast: PageAst$1;
eliminatedBranches: number;
};
declare function analyzeOptimizations(ast: PageAst$1): OptimizationReport;
declare function analyzeRuntimeRequirements(ast: PageAst$1): RuntimeRequirements;
type DeploymentRuntime = "bun" | "node" | "edge" | "worker" | "service-worker" | "browser";
type RuntimeCapability = "filesystem" | "tcp" | "process" | "websocket" | "crypto" | "streams" | "background-tasks";
interface RuntimeCapabilityDiagnostic {
code: "WRN-RUNTIME-CAPABILITY";
runtime: DeploymentRuntime;
module: string;
capability: RuntimeCapability;
message: string;
}
declare function runtimeCapabilities(runtime: DeploymentRuntime): ReadonlySet<RuntimeCapability>;
declare function analyzeRuntimeImports(source: string, runtime: DeploymentRuntime): RuntimeCapabilityDiagnostic[];
declare class NativeCompileError extends Error {
constructor(message: string);
}
/** Compile a parsed `.wrn` page to an Expo Router React Native screen. */
declare function generateNative(ast: PageAst): string;
interface CompilationCacheEntry extends CompileResult {
key: string;
file: string;
sourceHash: string;
createdAt: number;
}
interface CompilationCacheOptions {
maxEntries?: number;
now?: () => number;
}
interface CompilationCache {
compile(source: string, file?: string, salt?: string): CompilationCacheEntry;
get(key: string): CompilationCacheEntry | undefined;
invalidate(file?: string): number;
clear(): void;
size(): number;
stats(): {
hits: number;
misses: number;
entries: number;
};
}
declare function compilationKey(source: string, file?: string, salt?: string): string;
declare function createCompilationCache(options?: CompilationCacheOptions): CompilationCache;
declare class DependencyGraph {
#private;
set(file: string, dependencies: Iterable<string>): void;
remove(file: string): void;
dependencies(file: string): string[];
dependents(file: string): string[];
affected(file: string): string[];
}
/**
* @wrnexus/compiler — the `.wrn` language compiler.
*
* Parsing and language diagnostics are provided by the canonical
* `@wrnexus/syntax` package. This package owns platform-specific codegen.
*/
interface CompileResult {
code: string;
ast: PageAst$1;
/** Backward-compatible plain diagnostic messages. */
diagnostics: string[];
/** Structured diagnostics for editors, CI, and the DevToolbar. */
richDiagnostics: WrnDiagnostic[];
}
/** Compile `.wrn` source into an Expo Router React Native screen. */
declare function compileNativeWireFile(source: string): string;
/**
* Compile `.wrn` source into TypeScript source. Errors include a stable code,
* source location, code frame, and actionable hint whenever available.
*/
declare function compileWireFile(source: string, filePath?: string): string;
/** Richer entry point returning the AST and structured diagnostics. */
declare function compile(source: string, filePath?: string): CompileResult;
export { type CompilationCache, type CompilationCacheEntry, type CompilationCacheOptions, type CompileResult, DependencyGraph, type DeploymentRuntime, NativeCompileError, type OptimizationReport, type RouteExecutionKind, type RuntimeCapability, type RuntimeCapabilityDiagnostic, type RuntimeRequirements, analyzeOptimizations, analyzeRuntimeImports, analyzeRuntimeRequirements, compilationKey, compile, compileNativeWireFile, compileWireFile, createCompilationCache, createComponentContract, createWrnSourceMap, generate, generateBrowserModule, generateDeclarations, generateNative, generateServerFunctionsModule, generateStoreBrowserModule, generateStoreModule, generateTargets, optimizeAst, resolveWrnImport, resolveWrnImports, rpcManifest, runtimeCapabilities };
+3292
View File
File diff suppressed because it is too large Load Diff