orvyn-lang 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LANGUAGE.md +139 -3
- package/README.md +293 -1
- package/package.json +1 -1
- package/src/cli/orvyn.js +31 -480
- package/src/lang/codegen.js +90 -27
- package/src/lang/form.js +99 -0
- package/src/lang/native/android/OrvynRenderer.kt +5 -0
- package/src/lang/native/ios/OrvynEngine.swift +2 -0
- package/src/lang/native/ios/OrvynViews.swift +3 -0
- package/src/lang/native-runtime.js +22 -6
- package/src/lang/runtime-shared.js +28 -0
- package/src/lang/runtime.js +14 -1
- package/src/lang/validation.js +55 -0
- package/src/core/context.js +0 -19
- package/src/core/lifecycle.js +0 -8
- package/src/core/resource.js +0 -27
- package/src/core/router.js +0 -20
- package/src/core/theme.js +0 -10
- package/src/devtools/devicePreview/PreviewFrame.js +0 -214
- package/src/devtools/devicePreview/index.js +0 -6
- package/src/devtools/overlay.js +0 -105
- package/src/runtime/createRenderer.js +0 -22
- package/src/runtime/h.js +0 -93
- package/src/runtime/hydrate.js +0 -59
- package/src/runtime/jsx-dev-runtime.js +0 -7
- package/src/runtime/jsx-runtime.js +0 -13
- package/src/runtime/partialHydration.js +0 -154
- package/src/runtime/platform.js +0 -135
- package/src/runtime/renderToStream.js +0 -127
- package/src/runtime/renderToString.js +0 -121
- package/src/runtime/resume.js +0 -62
package/LANGUAGE.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# The Orvyn Language (v0.1)
|
|
2
2
|
|
|
3
|
-
Orvyn files end in `.orv`.
|
|
4
|
-
|
|
3
|
+
Orvyn files end in `.orv`. The compiler turns your code into JavaScript. The web
|
|
4
|
+
runtime renders browser elements; generated iOS and Android projects run the
|
|
5
|
+
same logic with native views.
|
|
5
6
|
|
|
6
7
|
```orv
|
|
7
8
|
state count = 0
|
|
@@ -75,7 +76,32 @@ Mistakes show in red on the phone and in the terminal, with the line number.
|
|
|
75
76
|
| `screen Name { ... }` | A screen of your app. `App` (or the first screen) is shown first. |
|
|
76
77
|
| `component Name(param) { ... }` | A reusable piece of UI. |
|
|
77
78
|
| `start { ... }` | Runs once when the app opens (load data here). |
|
|
78
|
-
| `use Card, Badge from "./ui"` | Use components or
|
|
79
|
+
| `use Card, Badge from "./ui"` | Use components, functions, values, or state from another `.orv` file. |
|
|
80
|
+
|
|
81
|
+
### Share state between files
|
|
82
|
+
|
|
83
|
+
Every top-level declaration is exported automatically. Import state with `use`
|
|
84
|
+
and read or change it with the same syntax as local state:
|
|
85
|
+
|
|
86
|
+
```orv
|
|
87
|
+
// store.orv
|
|
88
|
+
state count = 0
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
```orv
|
|
92
|
+
// app.orv
|
|
93
|
+
use count from "./store"
|
|
94
|
+
|
|
95
|
+
screen Home {
|
|
96
|
+
Column gap: 16 {
|
|
97
|
+
Text "Count: {count}"
|
|
98
|
+
Button "Add", onTap: count += 1
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Imported state stays reactive. Assigning to an imported fixed value or function
|
|
104
|
+
reports a runtime error explaining that the declaration must use `state`.
|
|
79
105
|
|
|
80
106
|
## Statements (inside `fn` and handlers)
|
|
81
107
|
|
|
@@ -133,6 +159,32 @@ start {
|
|
|
133
159
|
`fetch` gives back the JSON directly. To send data: `fetch(url, { method: "POST", body: { name: "A" } })`.
|
|
134
160
|
`wait` pauses until it's done: use it with `fetch` and `sleep(1000)`.
|
|
135
161
|
|
|
162
|
+
Use `wait` inside a function, `start` block, event handler block, or lambda.
|
|
163
|
+
The compiler makes that function async automatically. A lambda containing
|
|
164
|
+
`wait` returns a promise; using it in `map` produces a list of promises, not
|
|
165
|
+
finished results. For sequential work, use `for` inside a function instead.
|
|
166
|
+
Top-level initializers and screen rendering cannot use `wait` directly.
|
|
167
|
+
|
|
168
|
+
```orv
|
|
169
|
+
state status = "Ready"
|
|
170
|
+
|
|
171
|
+
screen Home {
|
|
172
|
+
Button "Pause", onTap: {
|
|
173
|
+
status = "Waiting"
|
|
174
|
+
wait sleep(1000)
|
|
175
|
+
status = "Done"
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Try a complete offline app
|
|
181
|
+
|
|
182
|
+
From this repository, run `npm run dev` and open `/lang.html?app=todo`.
|
|
183
|
+
`examples/todo.orv` includes blank-input validation, saved tasks, completion
|
|
184
|
+
toggles, removal, clearing completed tasks, and navigation to an About screen.
|
|
185
|
+
It works without a network request. Saved tasks belong to the current browser
|
|
186
|
+
origin or installed app; they do not sync between devices.
|
|
187
|
+
|
|
136
188
|
### Built-in functions
|
|
137
189
|
|
|
138
190
|
| Function | Does |
|
|
@@ -156,6 +208,88 @@ Operators: `+ - * / %`, `== != < > <= >=`, `&& || !`.
|
|
|
156
208
|
|
|
157
209
|
## Elements
|
|
158
210
|
|
|
211
|
+
### Forms and validation
|
|
212
|
+
|
|
213
|
+
Use `bind` to show state in an input and update it when the user types:
|
|
214
|
+
|
|
215
|
+
```orv
|
|
216
|
+
state name = ""
|
|
217
|
+
|
|
218
|
+
screen Home {
|
|
219
|
+
Input "Your name", bind: name
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
`bind: name` replaces `value: name, onChange: { name = value }`. It works
|
|
224
|
+
with state names, one object field (`bind: profile.name`), or a list entry
|
|
225
|
+
(`bind: items[0]`), including imported state. Input values are text. Do not
|
|
226
|
+
combine `bind` with `value` or `onChange`. For a custom change handler, use the
|
|
227
|
+
explicit `value` and `onChange` form instead.
|
|
228
|
+
|
|
229
|
+
Put inputs inside `Form` and give it an `onSubmit` action. `SubmitButton` runs
|
|
230
|
+
that action; the browser form stays on the current page. Ordinary `Button`
|
|
231
|
+
elements default to `type: "button"`, so they do not submit a form accidentally.
|
|
232
|
+
On native, tapping `SubmitButton` runs the enclosing form's action. Put submission
|
|
233
|
+
logic on `Form onSubmit`, rather than adding an `onTap` to `SubmitButton`.
|
|
234
|
+
|
|
235
|
+
Put rules directly on your inputs. Orvyn displays field errors and runs your
|
|
236
|
+
submit action only when every field passes. You do not need an errors state,
|
|
237
|
+
a separate rules object, or a validation function for this:
|
|
238
|
+
|
|
239
|
+
```orv
|
|
240
|
+
state profile = { name: "", email: "" }
|
|
241
|
+
|
|
242
|
+
fn save() {
|
|
243
|
+
print("Ready to save", profile)
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
screen Home {
|
|
247
|
+
Form gap: 12, padding: 24, onSubmit: save {
|
|
248
|
+
Input "Name", bind: profile.name, required: true, minLength: 2
|
|
249
|
+
Input "Email", bind: profile.email, type: "email", required: true
|
|
250
|
+
SubmitButton "Save"
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
Errors appear after the first submission attempt. After that, they update as
|
|
256
|
+
users edit the fields. `type: "email"` also enables email validation and requests
|
|
257
|
+
an email keyboard in the generated iOS and Android apps. For a friendlier error,
|
|
258
|
+
add `label: "Full name"` or `message: "Please enter your full name"` to the input.
|
|
259
|
+
The placeholder is the default label used in automatic error messages.
|
|
260
|
+
|
|
261
|
+
Use `bind` for these fields, or explicit `value` and `onChange` props. A validated
|
|
262
|
+
input needs an update handler. Separate forms keep their own errors. If you render
|
|
263
|
+
repeated forms with the same state, give each Form a distinct string or numeric
|
|
264
|
+
`key` to keep their validation state separate. Do not nest forms.
|
|
265
|
+
|
|
266
|
+
For complete control of your own validation UI, `validate()` remains available.
|
|
267
|
+
See `examples/form-manual.orv` for the explicit version with a rules object and
|
|
268
|
+
manual error rendering.
|
|
269
|
+
|
|
270
|
+
`validate(values, rules)` returns `{ valid, errors }`. `valid` is true when
|
|
271
|
+
every field passes. `errors` contains one message per failing field and no entry
|
|
272
|
+
for passing fields. The same validator runs on web, iOS, and Android.
|
|
273
|
+
|
|
274
|
+
| Rule | Meaning |
|
|
275
|
+
|---|---|
|
|
276
|
+
| `required: true` | Reject missing, null, empty, or whitespace-only text. |
|
|
277
|
+
| `minLength: 2` | Require at least this many Unicode code points. |
|
|
278
|
+
| `maxLength: 40` | Allow at most this many Unicode code points. |
|
|
279
|
+
| `email: true` | Check a basic email format; does not verify the mailbox exists. |
|
|
280
|
+
| `label: "Name"` | Use this name in default messages, such as “Name is required.” |
|
|
281
|
+
| `message: "Enter your name"` | Replace the default message for this field. |
|
|
282
|
+
|
|
283
|
+
Validation checks trimmed text without changing your state. Optional empty fields
|
|
284
|
+
skip length and email checks. Length limits are non-negative whole numbers;
|
|
285
|
+
unknown or invalid rules produce an error explaining what to fix. These rules
|
|
286
|
+
validate text fields; numeric and cross-field rules are not included yet.
|
|
287
|
+
|
|
288
|
+
Standalone `validate()` runs only when called. Forms with inline input rules
|
|
289
|
+
handle submission checks and error display automatically.
|
|
290
|
+
To try the complete example, run `npm run dev` here and open `/lang.html?app=form`.
|
|
291
|
+
The example validates locally; it does not send data to a server.
|
|
292
|
+
|
|
159
293
|
`Element firstArgument, name: value, name: value { children }`
|
|
160
294
|
|
|
161
295
|
| Element | First argument | Renders as |
|
|
@@ -165,6 +299,8 @@ Operators: `+ - * / %`, `== != < > <= >=`, `&& || !`.
|
|
|
165
299
|
| `Box` | — | container |
|
|
166
300
|
| `Text`, `Heading` | text | text |
|
|
167
301
|
| `Button` | label | button |
|
|
302
|
+
| `Form` | — | form container with `onSubmit` |
|
|
303
|
+
| `SubmitButton` | label | submits the enclosing form |
|
|
168
304
|
| `Input` | placeholder | text field |
|
|
169
305
|
| `Image` | source URL | image |
|
|
170
306
|
| `Link` | text | link (`href: "..."`) |
|
package/README.md
CHANGED
|
@@ -22,4 +22,296 @@ screen Home {
|
|
|
22
22
|
}
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
|
|
26
|
+
## Declarations (top level)
|
|
27
|
+
|
|
28
|
+
| Syntax | Meaning |
|
|
29
|
+
|---|---|
|
|
30
|
+
| `state name = value` | A value that changes. The screen updates when it changes. |
|
|
31
|
+
| `saved state name = value` | Like `state`, but kept after a reload or app restart (cart, settings, login). |
|
|
32
|
+
| `let name = value` | A value that never changes. |
|
|
33
|
+
| `fn name(a, b) { ... }` | A function. |
|
|
34
|
+
| `screen Name { ... }` | A screen of your app. `App` (or the first screen) is shown first. |
|
|
35
|
+
| `component Name(param) { ... }` | A reusable piece of UI. |
|
|
36
|
+
| `start { ... }` | Runs once when the app opens (load data here). |
|
|
37
|
+
| `use Card, Badge from "./ui"` | Use components, functions, values, or state from another `.orv` file. |
|
|
38
|
+
|
|
39
|
+
### Share state between files
|
|
40
|
+
|
|
41
|
+
Every top-level declaration is exported automatically. Import state with `use`
|
|
42
|
+
and read or change it with the same syntax as local state:
|
|
43
|
+
|
|
44
|
+
```orv
|
|
45
|
+
// store.orv
|
|
46
|
+
state count = 0
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
```orv
|
|
50
|
+
// app.orv
|
|
51
|
+
use count from "./store"
|
|
52
|
+
|
|
53
|
+
screen Home {
|
|
54
|
+
Column gap: 16 {
|
|
55
|
+
Text "Count: {count}"
|
|
56
|
+
Button "Add", onTap: count += 1
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Imported state stays reactive. Assigning to an imported fixed value or function
|
|
62
|
+
reports a runtime error explaining that the declaration must use `state`.
|
|
63
|
+
|
|
64
|
+
## Statements (inside `fn` and handlers)
|
|
65
|
+
|
|
66
|
+
```orv
|
|
67
|
+
let total = price * 2 // local variable
|
|
68
|
+
total += 1 // also -=, *=, /=
|
|
69
|
+
count = 0 // update state
|
|
70
|
+
if count > 10 { ... } else { ... }
|
|
71
|
+
for item in items { ... }
|
|
72
|
+
return total
|
|
73
|
+
print("hello") // logs to the console
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Lists and objects
|
|
77
|
+
|
|
78
|
+
Change them with these, and the screen updates by itself:
|
|
79
|
+
|
|
80
|
+
```orv
|
|
81
|
+
state todos = []
|
|
82
|
+
state user = { name: "Asha", age: 20 }
|
|
83
|
+
|
|
84
|
+
todos.add({ text: "Milk", done: false }) // add to the end
|
|
85
|
+
todos.remove(todo) // remove this item
|
|
86
|
+
todos.removeAt(0) // remove by position
|
|
87
|
+
todos.update(todo, { done: true }) // change fields of one item
|
|
88
|
+
todos.clear() // empty the list
|
|
89
|
+
user.name = "Ravi" // change one field
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Reading is safe even before data arrives: `user.name` is just empty while `user` is `null`.
|
|
93
|
+
|
|
94
|
+
### Remember things after the app closes
|
|
95
|
+
|
|
96
|
+
Put `saved` in front of `state`:
|
|
97
|
+
|
|
98
|
+
```orv
|
|
99
|
+
saved state cart = []
|
|
100
|
+
saved state darkMode = false
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
The value is stored on the device (browser storage on the web, UserDefaults on
|
|
104
|
+
iPhone, SharedPreferences on Android) and comes back the next time the app opens.
|
|
105
|
+
It also survives live reload while you develop.
|
|
106
|
+
|
|
107
|
+
### Internet data
|
|
108
|
+
|
|
109
|
+
```orv
|
|
110
|
+
state users = []
|
|
111
|
+
|
|
112
|
+
start {
|
|
113
|
+
users = wait fetch("https://api.example.com/users")
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
`fetch` gives back the JSON directly. To send data: `fetch(url, { method: "POST", body: { name: "A" } })`.
|
|
118
|
+
`wait` pauses until it's done: use it with `fetch` and `sleep(1000)`.
|
|
119
|
+
|
|
120
|
+
Use `wait` inside a function, `start` block, event handler block, or lambda.
|
|
121
|
+
The compiler makes that function async automatically. A lambda containing
|
|
122
|
+
`wait` returns a promise; using it in `map` produces a list of promises, not
|
|
123
|
+
finished results. For sequential work, use `for` inside a function instead.
|
|
124
|
+
Top-level initializers and screen rendering cannot use `wait` directly.
|
|
125
|
+
|
|
126
|
+
```orv
|
|
127
|
+
state status = "Ready"
|
|
128
|
+
|
|
129
|
+
screen Home {
|
|
130
|
+
Button "Pause", onTap: {
|
|
131
|
+
status = "Waiting"
|
|
132
|
+
wait sleep(1000)
|
|
133
|
+
status = "Done"
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Try a complete offline app
|
|
139
|
+
|
|
140
|
+
From this repository, run `npm run dev` and open `/lang.html?app=todo`.
|
|
141
|
+
`examples/todo.orv` includes blank-input validation, saved tasks, completion
|
|
142
|
+
toggles, removal, clearing completed tasks, and navigation to an About screen.
|
|
143
|
+
It works without a network request. Saved tasks belong to the current browser
|
|
144
|
+
origin or installed app; they do not sync between devices.
|
|
145
|
+
|
|
146
|
+
### Built-in functions
|
|
147
|
+
|
|
148
|
+
| Function | Does |
|
|
149
|
+
|---|---|
|
|
150
|
+
| `print(x)` | Log to the console |
|
|
151
|
+
| `fetch(url)` | Get data from the internet |
|
|
152
|
+
| `go(Screen)` | Open another screen |
|
|
153
|
+
| `sleep(ms)` | Wait (use with `wait`) |
|
|
154
|
+
| `random(1, 6)` | Random whole number |
|
|
155
|
+
| `len(list)` | Number of items |
|
|
156
|
+
|
|
157
|
+
Short functions: `todos.filter(t => t.done)`, `prices.map((p, i) => p * 2)`.
|
|
158
|
+
Choose a value: `done ? "Yes" : "No"`.
|
|
159
|
+
|
|
160
|
+
## Values
|
|
161
|
+
|
|
162
|
+
`12`, `3.5`, `"text"`, `"Hi {name}"` (interpolation), `true`, `false`, `null`,
|
|
163
|
+
`[1, 2, 3]`, `#1e293b` (colors), `a.b`, `list[0]`, `f(x)`.
|
|
164
|
+
|
|
165
|
+
Operators: `+ - * / %`, `== != < > <= >=`, `&& || !`.
|
|
166
|
+
|
|
167
|
+
## Elements
|
|
168
|
+
|
|
169
|
+
### Forms and validation
|
|
170
|
+
|
|
171
|
+
Use `bind` to show state in an input and update it when the user types:
|
|
172
|
+
|
|
173
|
+
```orv
|
|
174
|
+
state name = ""
|
|
175
|
+
|
|
176
|
+
screen Home {
|
|
177
|
+
Input "Your name", bind: name
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
`bind: name` replaces `value: name, onChange: { name = value }`. It works
|
|
182
|
+
with state names, one object field (`bind: profile.name`), or a list entry
|
|
183
|
+
(`bind: items[0]`), including imported state. Input values are text. Do not
|
|
184
|
+
combine `bind` with `value` or `onChange`. For a custom change handler, use the
|
|
185
|
+
explicit `value` and `onChange` form instead.
|
|
186
|
+
|
|
187
|
+
Put inputs inside `Form` and give it an `onSubmit` action. `SubmitButton` runs
|
|
188
|
+
that action; the browser form stays on the current page. Ordinary `Button`
|
|
189
|
+
elements default to `type: "button"`, so they do not submit a form accidentally.
|
|
190
|
+
On native, tapping `SubmitButton` runs the enclosing form's action. Put submission
|
|
191
|
+
logic on `Form onSubmit`, rather than adding an `onTap` to `SubmitButton`.
|
|
192
|
+
|
|
193
|
+
Put rules directly on your inputs. Orvyn displays field errors and runs your
|
|
194
|
+
submit action only when every field passes. You do not need an errors state,
|
|
195
|
+
a separate rules object, or a validation function for this:
|
|
196
|
+
|
|
197
|
+
```orv
|
|
198
|
+
state profile = { name: "", email: "" }
|
|
199
|
+
|
|
200
|
+
fn save() {
|
|
201
|
+
print("Ready to save", profile)
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
screen Home {
|
|
205
|
+
Form gap: 12, padding: 24, onSubmit: save {
|
|
206
|
+
Input "Name", bind: profile.name, required: true, minLength: 2
|
|
207
|
+
Input "Email", bind: profile.email, type: "email", required: true
|
|
208
|
+
SubmitButton "Save"
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Errors appear after the first submission attempt. After that, they update as
|
|
214
|
+
users edit the fields. `type: "email"` also enables email validation and requests
|
|
215
|
+
an email keyboard in the generated iOS and Android apps. For a friendlier error,
|
|
216
|
+
add `label: "Full name"` or `message: "Please enter your full name"` to the input.
|
|
217
|
+
The placeholder is the default label used in automatic error messages.
|
|
218
|
+
|
|
219
|
+
Use `bind` for these fields, or explicit `value` and `onChange` props. A validated
|
|
220
|
+
input needs an update handler. Separate forms keep their own errors. If you render
|
|
221
|
+
repeated forms with the same state, give each Form a distinct string or numeric
|
|
222
|
+
`key` to keep their validation state separate. Do not nest forms.
|
|
223
|
+
|
|
224
|
+
For complete control of your own validation UI, `validate()` remains available.
|
|
225
|
+
See `examples/form-manual.orv` for the explicit version with a rules object and
|
|
226
|
+
manual error rendering.
|
|
227
|
+
|
|
228
|
+
`validate(values, rules)` returns `{ valid, errors }`. `valid` is true when
|
|
229
|
+
every field passes. `errors` contains one message per failing field and no entry
|
|
230
|
+
for passing fields. The same validator runs on web, iOS, and Android.
|
|
231
|
+
|
|
232
|
+
| Rule | Meaning |
|
|
233
|
+
|---|---|
|
|
234
|
+
| `required: true` | Reject missing, null, empty, or whitespace-only text. |
|
|
235
|
+
| `minLength: 2` | Require at least this many Unicode code points. |
|
|
236
|
+
| `maxLength: 40` | Allow at most this many Unicode code points. |
|
|
237
|
+
| `email: true` | Check a basic email format; does not verify the mailbox exists. |
|
|
238
|
+
| `label: "Name"` | Use this name in default messages, such as “Name is required.” |
|
|
239
|
+
| `message: "Enter your name"` | Replace the default message for this field. |
|
|
240
|
+
|
|
241
|
+
Validation checks trimmed text without changing your state. Optional empty fields
|
|
242
|
+
skip length and email checks. Length limits are non-negative whole numbers;
|
|
243
|
+
unknown or invalid rules produce an error explaining what to fix. These rules
|
|
244
|
+
validate text fields; numeric and cross-field rules are not included yet.
|
|
245
|
+
|
|
246
|
+
Standalone `validate()` runs only when called. Forms with inline input rules
|
|
247
|
+
handle submission checks and error display automatically.
|
|
248
|
+
To try the complete example, run `npm run dev` here and open `/lang.html?app=form`.
|
|
249
|
+
The example validates locally; it does not send data to a server.
|
|
250
|
+
|
|
251
|
+
`Element firstArgument, name: value, name: value { children }`
|
|
252
|
+
|
|
253
|
+
| Element | First argument | Renders as |
|
|
254
|
+
|---|---|---|
|
|
255
|
+
| `Column` | — | vertical stack |
|
|
256
|
+
| `Row` | — | horizontal stack |
|
|
257
|
+
| `Box` | — | container |
|
|
258
|
+
| `Text`, `Heading` | text | text |
|
|
259
|
+
| `Button` | label | button |
|
|
260
|
+
| `Form` | — | form container with `onSubmit` |
|
|
261
|
+
| `SubmitButton` | label | submits the enclosing form |
|
|
262
|
+
| `Input` | placeholder | text field |
|
|
263
|
+
| `Image` | source URL | image |
|
|
264
|
+
| `Link` | text | link (`href: "..."`) |
|
|
265
|
+
|
|
266
|
+
Style props: `bg`, `color`, `size`, `padding`, `margin`, `gap`, `radius`, `width`,
|
|
267
|
+
`height`, `align`, `justify`, `border`, `shadow`, and the rest of Orvyn's style props.
|
|
268
|
+
Plain words like `black` or `center` are treated as text.
|
|
269
|
+
|
|
270
|
+
Events: `onTap`, `onChange`, `onSubmit`, `onHover`, `onLeave`. Give a function name,
|
|
271
|
+
one statement, or a block:
|
|
272
|
+
|
|
273
|
+
```orv
|
|
274
|
+
Button "Add", onTap: increment
|
|
275
|
+
Button "-1", onTap: count -= 1
|
|
276
|
+
Input "Name", onChange: { name = value } // value = the typed text
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
Inside a view you can use `if` / `else` and `for item in list { ... }`.
|
|
280
|
+
|
|
281
|
+
### Screens and navigation
|
|
282
|
+
|
|
283
|
+
```orv
|
|
284
|
+
screen Home {
|
|
285
|
+
Button "About", onTap: go(About)
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
screen About {
|
|
289
|
+
Button "Back", onTap: go(Home)
|
|
290
|
+
}
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
`App` (or the first screen in the file) opens first.
|
|
294
|
+
|
|
295
|
+
## Editor colours (VS Code)
|
|
296
|
+
|
|
297
|
+
Install **Orvyn Language** from the VS Code Extensions panel.
|
|
298
|
+
|
|
299
|
+
## Errors
|
|
300
|
+
|
|
301
|
+
The compiler stops at the first error and shows the line:
|
|
302
|
+
|
|
303
|
+
```
|
|
304
|
+
✗ app.orv:4:3
|
|
305
|
+
Unknown element "Buton". Available: Column, Row, Box, Text, ...
|
|
306
|
+
|
|
307
|
+
4 | Buton "x"
|
|
308
|
+
| ^
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
## Not in v0.1 yet
|
|
312
|
+
|
|
313
|
+
- Native: `Image` sizes, `justify`, and hover events are basic on phones
|
|
314
|
+
- Live reload is iPhone-only for now (Android: `orvyn android` rebuilds)
|
|
315
|
+
- `state` inside components (keep state at the top of the file for now)
|
|
316
|
+
- Browser back button with `go()`
|
|
317
|
+
- `while` loops
|