release: WRNexusJS 0.6.0

This commit is contained in:
2026-08-01 01:09:58 +05:30
parent 3e565e8d03
commit 687d345882
502 changed files with 33038 additions and 11358 deletions
+16
View File
@@ -55,6 +55,8 @@ export interface Router {
components: ComponentRef[];
/** Named page layouts (`app/layouts/<name>.wrn`); a page picks one via `layout`. */
layouts: ComponentRef[];
/** Typed global/page stores discovered under `app/stores/`. */
stores: ComponentRef[];
/** Validation schemas (`app/schemas/<name>.ts`) shared by API + forms. */
schemas: ComponentRef[];
matchPage(pathname: string): RouteMatch | null;
@@ -255,6 +257,19 @@ export function buildRouter(appDir: string, opts: RouterOptions = {}): Router {
layouts.push({ name, file: f.file });
}
const stores: ComponentRef[] = [];
for (const f of scanDir(join(appDir, "stores"))) {
if (!f.file.endsWith(".wrn")) continue;
try {
const source = readFileSync(f.file, "utf8");
const declaration = /\b(?:global|page)\s+store\s+([A-Za-z_$][\w$]*)\s*\{/.exec(source);
if (!declaration) continue;
stores.push({ name: declaration[1]!, file: f.file });
} catch (error) {
console.warn(`[wrnexus] unable to inspect store declaration in ${f.file}`, error);
}
}
// Validation schemas: app/schemas/<name>.{ts,js}. Imported by API routes and
// referenced by forms via `data-schema="<name>"`.
const schemas: ComponentRef[] = [];
@@ -275,6 +290,7 @@ export function buildRouter(appDir: string, opts: RouterOptions = {}): Router {
middlewareFiles,
components,
layouts,
stores,
schemas,
matchPage: (p) => matchRoute(pages, p),
matchApi: (p) => matchRoute(api, p),