opencode/packages/widget/test/fixtures/wire/controls.json
OpenCode Agent 523750c6a1 feat(core): widget protocol 2: split native step output, keys and depth rules, function rule
- __widget_native_step(__input()) hands the view to the host global __widget_emit and returns the
  rest of the step output as the run's result, under its JSON rules; the TypeScript host uses it.
- The prelude's first line declares __widget_protocol = 2; hosts refuse older programs as a program
  error (ask the agent to post it again) and newer ones as a client error.
- Keys are strings, numbers or booleans, and views nest at most 100 levels; both are program errors
  in phase view, in the prelude's tree building and in native hosts. The boundary depth for 100
  levels is 202.
- A function in a host call's argument anywhere but a node's handler props fails the call with the
  runtime's TypeError, the view's included.
- Wire fixtures gain the run's result, failures, keys, depth and JSON edge cases.
2026-11-22 13:25:02 +00:00

213 lines
4.3 KiB
JSON

{
"name": "controls",
"source": "function view(state, data) {\n return ui.column([ui.button(\"b\"), ui.button(\"bh\", { onPress: (s) => s, variant: \"primary\" }), ui.checkbox(\"c\", true), ui.checkbox(\"ch\", false, { onChange: (s) => s }), ui.slider({ value: 1, min: 0, max: 2 }), ui.slider({ value: 1, min: 0, max: 2, onChange: (s) => s }), ui.select([\"a\", \"b\"], { value: \"a\" }), ui.select([\"a\"], { multiple: true, onChange: (s) => s }), ui.input(\"v\"), ui.input(\"w\", { onChange: (s) => s, multiline: true }), ui.card({ selected: true }, [ui.text(\"no handler\")]), ui.card({ onPress: (s) => s }, [ui.text(\"handler\")])])\n}",
"input": {
"phase": "init",
"data": null
},
"built": {
"type": "column",
"children": [
{
"type": "button",
"label": "b"
},
{
"onPress": "$function",
"variant": "primary",
"type": "button",
"label": "bh"
},
{
"type": "checkbox",
"label": "c",
"checked": true
},
{
"onChange": "$function",
"type": "checkbox",
"label": "ch",
"checked": false
},
{
"value": 1,
"min": 0,
"max": 2,
"type": "slider"
},
{
"value": 1,
"min": 0,
"max": 2,
"onChange": "$function",
"type": "slider"
},
{
"value": "a",
"type": "select",
"options": [
{
"value": "a",
"label": "a"
},
{
"value": "b",
"label": "b"
}
]
},
{
"multiple": true,
"onChange": "$function",
"type": "select",
"options": [
{
"value": "a",
"label": "a"
}
]
},
{
"type": "input",
"value": "v"
},
{
"onChange": "$function",
"multiline": true,
"type": "input",
"value": "w"
},
{
"selected": true,
"type": "card",
"children": [
{
"type": "text",
"text": "no handler"
}
]
},
{
"onPress": "$function",
"type": "card",
"children": [
{
"type": "text",
"text": "handler"
}
]
}
]
},
"view": {
"type": "column",
"children": [
{
"type": "button",
"label": "b",
"id": "0/0"
},
{
"variant": "primary",
"type": "button",
"label": "bh",
"id": "0/1"
},
{
"type": "checkbox",
"label": "c",
"checked": true,
"id": "0/2"
},
{
"type": "checkbox",
"label": "ch",
"checked": false,
"id": "0/3"
},
{
"value": 1,
"min": 0,
"max": 2,
"type": "slider",
"id": "0/4"
},
{
"value": 1,
"min": 0,
"max": 2,
"type": "slider",
"id": "0/5"
},
{
"value": "a",
"type": "select",
"options": [
{
"value": "a",
"label": "a"
},
{
"value": "b",
"label": "b"
}
],
"id": "0/6"
},
{
"multiple": true,
"type": "select",
"options": [
{
"value": "a",
"label": "a"
}
],
"id": "0/7"
},
{
"type": "input",
"value": "v",
"id": "0/8"
},
{
"multiline": true,
"type": "input",
"value": "w",
"id": "0/9"
},
{
"selected": true,
"type": "card",
"children": [
{
"type": "text",
"text": "no handler"
}
]
},
{
"type": "card",
"id": "0/11",
"children": [
{
"type": "text",
"text": "handler"
}
]
}
]
},
"handlers": {
"0/1": "press",
"0/3": "change",
"0/5": "change",
"0/7": "change",
"0/9": "change",
"0/11": "press"
},
"canvases": {},
"result": {
"state": {}
}
}