RP/1 reference¶
RP/1 is this project's own prototype language, not an Axure format. One source file describes pages, components, data, state and interactions, and compiles into an editable Axure project.
Two authoring forms feed the same compiler:
- a compact text form used in the README examples,
- a strict JSON AST with a published schema and type checking.
Text form¶
rp/1 target=9 name="Next encounter" domain=mobile theme=mobile-hifi
page #home name="Discover" device=iphone-17-pro
phone-shell #shell title="Meet your feathered neighbors." gap=16
card #bird [fillxhug] title="Kingfisher" body="A flash of blue." actionText="Record" goto="notes"
page #notes name="Journal" device=iphone-17-pro
phone-shell #shell title="My first field note" gap=16
input #note [fillx44] value="I spotted it by the water today."
button #back [fillx44] "Back to discovery" goto="home"
JSON form, minimal program¶
{
"language": "rp/1",
"target": 9,
"variables": {"count": {"type": "number", "value": 0}},
"pages": [{
"id": "home", "name": "Counter", "canvas": {"w": 480, "h": 320},
"root": {"type": "box", "id": "root", "layout": "column", "padding": 24, "gap": 16, "children": [
{"type": "label", "id": "value", "text": {"fn": "text", "args": [{"variable": "count"}]}},
{"type": "button", "id": "add", "text": "Add one", "on": {"click": [
{"type": "set-variable", "variable": "count", "value": {"op": "+", "left": {"variable": "count"}, "right": 1}}
]}}
]
}]
}
Header¶
Top-level fields: $schema, language, target, name, theme, palette, tokens, domain,
device, shell, static, strictAudit, devMode, product, models, datasets,
variables, computed, statecharts, transactions, invariants, components, views,
rules, masters, adaptiveViews, pages.
languageis"rp/1";targetis9or11;irVersionis2.- Unknown properties are errors, with a nearest-name hint.
domainisweb,mobile,docortest.canvasbelongs to a page, never to the root.- Colors must be a known
$tokenor#RRGGBB.
Pages and identity¶
- A page requires
idandroot;namedefaults toid. - Identifiers match
[A-Za-z_][A-Za-z0-9_-]*. - Without
canvas, a page withdevice: "iphone-17"uses402×874; web/doc defaults to1440×900, other domains to375×812. canvasalso accepts[w, h], measured as content size.namebecomes the native outline name; references always useid, so renaming a widget keeps its identity and interactions.
Layout primitives¶
| Primitive | Properties |
|---|---|
| common | x, y, w, h, flex; sizes accept numbers, fill, hug, auto |
box, card |
layout, padding, gap, align, justify, equalHeight, columns, columnGap, rowGap, children, fill, stroke, radius |
label, paragraph |
text, fontSize, fontWeight, color, align, letterSpacing; paragraphs add lineGap, lineHeight |
button, badge |
text properties plus variant, fill, stroke, radius |
input |
native TextBox: value, placeholder, fill, stroke, radius, fontSize, fontWeight, color, align, textPaddingX |
divider |
direction, color, fill |
image |
src |
dynamic-panel |
states: [{ id, root }] |
repeater |
dataset, key, template, rowHeight, rowGap, pageSize |
Layout modes are row, column, stack and grid. lineHeight is total line height;
lineGap is extra spacing outside the text ink.
Typed runtime values¶
Usable in label/button/badge text, set-text.text, set-variable.value, conditions, and
data actions.
| Form | Type |
|---|---|
"text", 12, true |
scalar literal |
{"variable": "count"} |
declared variable type |
{"widget": {"ref": "field"}} |
text of a widget on the same page |
{"item": "qty"} |
model field of the current or target row |
{"op": "+", "left": ..., "right": ...} |
numeric arithmetic: + - * / |
{"op": "==", "left": ..., "right": ...} |
equality; > < >= <= for numbers |
{"op": "&&", "left": ..., "right": ...} |
boolean logic: &&, \|\| |
{"fn": "text", "args": [...]} |
one scalar to text |
{"fn": "number", "args": [...]} |
text or number to number; non-numeric text becomes 0 |
{"fn": "not", "args": [...]} |
boolean negation |
{"fn": "lower" \| "upper" \| "length", "args": [...]} |
text transform |
{"fn": "concat", "args": [..., ...]} |
at least two texts |
No arbitrary code, converters or eval.
Data, components, repeats¶
{
"models": {"Item": {"id": "text", "title": "text", "qty": "number", "active": "boolean"}},
"datasets": {"items": {"model": "Item", "rows": [{"id": "i1", "title": "Note", "qty": 3, "active": true}]}},
"variables": {"selected": {"type": "text", "value": "i1"}}
}
- Variables belong to the project and need a type and an initial value.
- A dataset is compile input; two repeaters using it each keep their own initial rows, so runtime edits do not propagate.
{"type": "repeat", ...}expands static widgets at compile time;repeateris the runtime equivalent. Compile-timekeymust be a non-empty unique text.
Components:
{"components": {"Title": {"params": {"value": "text"}, "root": {"type": "label", "id": "title", "text": {"$": "value"}}}}}
Instantiate with {"type": "use", "id": "first", "component": "Title", "args": {"value": "Home"}}.
Missing, extra or mistyped arguments and recursive instantiation are errors.
Validate and compile¶
node scripts/proto.mjs check --spec ./source.json
node scripts/proto.mjs schema --out ./rp-language.schema.json
node scripts/proto.mjs format --spec ./source.json --out ./formatted.json
node scripts/proto.mjs generate --spec ./source.json --out-dir ./bundle --out-rp ./prototype.rp
check runs on the standard library alone — no fonts, Pillow, Axure or GUI permissions. Output
paths must be new: .rp, formatted files and schema output never overwrite.
Full contract, samples and error codes: references/rp-language.md.
Runnable examples live in examples/rp-language/.