feat: release design system engine, studio and component contracts

This commit is contained in:
Clintchiz committed 2026-10-19 13:09:03 +05:30
1 parent ff1065fb27
commit 3943b946d6
693 files changed
+175546 -3894

No files matched your search

+27 -8
View File
@@ -23,7 +23,13 @@ import {
} from "node:fs";
import { basename, dirname, extname, join, relative, resolve } from "node:path";
import { buildRouter, type Route } from "@wrnexus/router";
import { getComponentControllerRuntime, getReactiveRuntime, getNavRuntime, getActionRuntime, getRealtimeRuntime } from "@wrnexus/csr";
import {
getComponentControllerRuntime,
getReactiveRuntime,
getNavRuntime,
getActionRuntime,
getRealtimeRuntime,
} from "@wrnexus/csr";
import { getIslandRuntime } from "@wrnexus/react/runtime";
import {
analyzeRuntimeImports,
@@ -351,7 +357,11 @@ export async function runBuild(appRoot: string): Promise<void> {
const bundledClientOut = join(clientModulesDir, `${clientStem}-${bundleHash}.mjs`);
writeFileSync(bundledClientOut, browserSource, "utf8");
clientFiles.set(file, bundledClientOut);
writeFileSync(out, code.replaceAll(clientUrl, `/__wrnexus/client/${basename(bundledClientOut)}`), "utf8");
writeFileSync(
out,
code.replaceAll(clientUrl, `/__wrnexus/client/${basename(bundledClientOut)}`),
"utf8",
);
rmSync(clientEntry, { force: true });
} catch (error) {
compiledFiles.delete(file);
@@ -724,14 +734,17 @@ applyAuthzManifestEarly([${authzSetupEntries}]);
const runtimeConfigPath = ["wrnexus.config.ts", "wrnexus.config.js", "wrnexus.config.mjs"]
.map((name) => resolve(appRoot, name))
.find(existsSync);
if (runtimeConfigPath && config.auth) {
if (runtimeConfigPath && "auth" in config && config.auth) {
// Importing config creates the engine, but does not run plugin.configure.
// Initialize route options before route/middleware modules are evaluated.
// Credentials are read by the config at server startup, never serialized here.
writeFileSync(join(distDir, ".auth-runtime.ts"),
writeFileSync(
join(distDir, ".auth-runtime.ts"),
`import config from ${JSON.stringify(fwd(runtimeConfigPath))};\n` +
`import { configureAuthRuntime } from "@wrnexus/auth/plugin";\n` +
`configureAuthRuntime(config.auth);\n`, "utf8");
`import { configureAuthRuntime } from "@wrnexus/auth/plugin";\n` +
`configureAuthRuntime(config.auth);\n`,
"utf8",
);
imports.push(`import "./.auth-runtime.ts";`);
} else if (runtimeConfigPath) imports.push(`import ${JSON.stringify(fwd(runtimeConfigPath))};`);
@@ -1072,8 +1085,14 @@ async function emitPluginAssets(
// Keep that alias revalidatable while the HTML uses the immutable URL.
const stablePath = runtime.publicPath ?? `/__wrnexus/assets/${safeAssetName(runtime.id)}.js`;
if (stablePath !== publicPath) {
assets.push({ id: runtime.id, publicPath: stablePath, file,
contentType: "text/javascript; charset=utf-8", runtime: true, immutable: false });
assets.push({
id: runtime.id,
publicPath: stablePath,
file,
contentType: "text/javascript; charset=utf-8",
runtime: true,
immutable: false,
});
}
// Keep an empty source marker so @wrnexus/plugin can normalize this
// already-emitted descriptor during production HTML rendering without
+46
View File
@@ -0,0 +1,46 @@
import { readFileSync, statSync } from "node:fs";
import { resolve } from "node:path";
import {
assertDesignSystem,
compileDesignSystem,
DesignSystemError,
resolveDesignSystem,
validateDesignSystem,
type DesignSystem,
type ResolveOptions,
} from "@wrnexus/design-system";
function readJson(file: string): unknown {
const path = resolve(file);
if (statSync(path).size > 1024 * 1024)
throw new Error("WRN-DS-LIMIT: Design input exceeds 1 MiB.");
return JSON.parse(readFileSync(path, "utf8"));
}
/** Data-only CLI: never imports executable user configuration or writes files. */
export async function runDesignCommand(args: string[]): Promise<string> {
const [command, file, ...flags] = args;
if (!file || !["validate", "inspect", "compile"].includes(command ?? ""))
throw new Error(
"Usage: wrnexus design <validate|inspect|compile> <system.json> [--mode=name] [--density=name] [--registry=systems.json]",
);
const options: ResolveOptions = {};
for (const flag of flags) {
const match = /^--(mode|density|registry)=(.+)$/.exec(flag);
if (!match) throw new Error(`WRN-DS-OPTION: Unknown design option '${flag}'.`);
if (match[1] === "registry") {
const registry = readJson(match[2]!);
if (!registry || typeof registry !== "object" || Array.isArray(registry))
throw new Error("WRN-DS-SCHEMA: Registry must map identifiers to systems.");
for (const value of Object.values(registry)) assertDesignSystem(value);
options.registry = registry as Record<string, DesignSystem>;
} else options[match[1] as "mode" | "density"] = match[2]!;
}
const system = readJson(file);
const diagnostics = validateDesignSystem(system, options);
if (diagnostics.length) throw new DesignSystemError(diagnostics);
assertDesignSystem(system);
if (command === "compile") return compileDesignSystem(system, options).css.trimEnd();
if (command === "inspect") return JSON.stringify(resolveDesignSystem(system, options), null, 2);
return JSON.stringify({ valid: true, id: system.id, schemaVersion: system.schemaVersion });
}
+7
View File
@@ -39,6 +39,8 @@ function help(): void {
console.log(`wrnexus — WrNexus CLI
Usage:
wrnexus design <validate|inspect|compile> <system.json> [--mode=light] [--density=compact]
Validate or compile an opt-in design system
wrnexus dev [app-dir] [--port=3000] [--host=::]
Start the development server (live reload)
wrnexus dev [app-dir] --services Start local production-service simulators with the app
@@ -121,6 +123,11 @@ async function main(): Promise<void> {
notifyIfUpdateAvailable(currentCliVersion(), command);
switch (command) {
case "design": {
const { runDesignCommand } = await import("./design.ts");
console.log(await runDesignCommand(rest));
break;
}
case "dev": {
const appRoot = rest.find((a) => !a.startsWith("--")) ?? ".";
const portArg = rest.find((a) => a.startsWith("--port="));