release: WRNexusJS 0.5.10
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/syntax",
|
||||
"version": "0.5.1",
|
||||
"version": "0.5.10",
|
||||
"type": "module",
|
||||
"main": "src/index.ts",
|
||||
"exports": {
|
||||
|
||||
@@ -409,7 +409,11 @@ export function parse(source: string): PageAst {
|
||||
} else {
|
||||
expect("eq");
|
||||
}
|
||||
states.push({ name: sName, valueType, expr: lx.readToLineEnd() });
|
||||
// State values may be multiline structured expressions. Use the same
|
||||
// balanced initializer reader as props so formatted arrays/objects
|
||||
// remain one declaration instead of exposing their inner braces as
|
||||
// component members on the next line.
|
||||
states.push({ name: sName, valueType, expr: lx.readPropInitializer() });
|
||||
break;
|
||||
}
|
||||
case "computed": {
|
||||
|
||||
@@ -30,6 +30,32 @@ component Navigation {
|
||||
expect(sidebar.attrs.find((attr) => attr.name === "options")?.value).toBe('{{"dense":true}}');
|
||||
});
|
||||
|
||||
test("parses formatted multiline arrays and objects in state", () => {
|
||||
const ast = parse(`component Navigation {
|
||||
state items = [
|
||||
{
|
||||
"label": "Home",
|
||||
"href": "/"
|
||||
},
|
||||
{
|
||||
"label": "Services",
|
||||
"children": [
|
||||
{ "label": "Reports", "href": "/reports" }
|
||||
]
|
||||
}
|
||||
]
|
||||
state options = {
|
||||
"dense": true,
|
||||
"columns": 4
|
||||
}
|
||||
view { <nav></nav> }
|
||||
}`);
|
||||
|
||||
expect(ast.states[0]?.expr).toContain('"Services"');
|
||||
expect(ast.states[0]?.expr).toContain('"Reports"');
|
||||
expect(ast.states[1]?.expr).toContain('"columns": 4');
|
||||
});
|
||||
|
||||
test("parses WRN 0.3 execution, data, security, and reactivity blocks", () => {
|
||||
const ast = parse(`page Dashboard {
|
||||
runtime = "universal"
|
||||
|
||||
Reference in New Issue
Block a user