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

@@ -0,0 +1,34 @@
import { expect, test } from "bun:test";
import { parse } from "@wrnexus/syntax";
import { generateBrowserModule } from "../src/client-codegen.ts";
const source = `component FunctionDefaults {
props { timezone = "UTC" }
state selected = ""
functions {
client function choose(section = "connections", hour = 9) { selected = section; return hour }
shared function label(prefix = "event", suffix = prefix + " details", zone = timezone) { return [prefix, suffix, zone] }
}
view { <button @click="choose()">Choose</button> }
}`;
test("browser functions retain defaults, prior-argument references and prop references", () => {
const module = generateBrowserModule(parse(source));
const functions = new Function(
module.replace(/\bexport\s+(?=const|function)/g, "") + ";return __wrnexusClientFunctions;",
)();
const context = {
state: { selected: "" },
props: { timezone: "Asia/Kolkata" },
batch: (apply: () => void) => apply(),
};
expect(functions.choose(context)).toBe(9);
expect(context.state.selected).toBe("connections");
expect(functions.label(context)).toEqual(["event", "event details", "Asia/Kolkata"]);
expect(functions.label(context, "meeting")).toEqual([
"meeting",
"meeting details",
"Asia/Kolkata",
]);
expect(functions.choose(context, undefined, 0)).toBe(0);
expect(functions.label(context, null, "explicit", "UTC")).toEqual([null, "explicit", "UTC"]);
});