orvyn-lang 0.2.0 → 0.3.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/GUIDE.md +149 -0
- package/LANGUAGE.md +744 -27
- package/README.md +211 -250
- package/brand/orvyn-sunset-animated.svg +15 -0
- package/package.json +3 -1
- package/src/cli/orvyn.js +186 -10
- package/src/core/signal.js +104 -6
- package/src/devtools/runtime.js +25 -1
- package/src/lang/a11y.js +102 -0
- package/src/lang/auth.js +239 -0
- package/src/lang/bundle-native.js +10 -6
- package/src/lang/codegen.js +428 -57
- package/src/lang/device.js +41 -0
- package/src/lang/doctor.js +60 -0
- package/src/lang/env.js +27 -0
- package/src/lang/errors.js +513 -0
- package/src/lang/form.js +69 -8
- package/src/lang/index.js +2 -1
- package/src/lang/lexer.js +2 -0
- package/src/lang/list.js +44 -0
- package/src/lang/native/android/MainActivity.kt +43 -4
- package/src/lang/native/android/OrvynDevice.kt +163 -0
- package/src/lang/native/android/OrvynEngine.kt +154 -7
- package/src/lang/native/android/OrvynRenderer.kt +518 -44
- package/src/lang/native/android.js +74 -11
- package/src/lang/native/build.js +130 -60
- package/src/lang/native/config.js +108 -0
- package/src/lang/native/ios/OrvynApp.swift +6 -0
- package/src/lang/native/ios/OrvynEngine.swift +266 -4
- package/src/lang/native/ios/OrvynViews.swift +429 -34
- package/src/lang/native/ios.js +75 -2
- package/src/lang/native-runtime.js +406 -56
- package/src/lang/page.js +52 -0
- package/src/lang/parser.js +243 -15
- package/src/lang/prerender.js +300 -0
- package/src/lang/read-import.js +11 -0
- package/src/lang/router.js +266 -0
- package/src/lang/runtime-shared.js +792 -10
- package/src/lang/runtime.js +362 -52
- package/src/lang/select.js +13 -0
- package/src/lang/server-code.js +233 -0
- package/src/lang/server-export.js +78 -0
- package/src/lang/server-libs.js +53 -0
- package/src/lang/server.js +409 -0
- package/src/lang/test-runner.js +134 -0
- package/src/lang/types.js +312 -0
- package/src/lang/vite-plugin.js +82 -3
- package/src/lang/web-overlay.js +578 -0
- package/src/lang/widgets.js +94 -0
- package/src/lang/words.js +38 -0
- package/src/runtime/mount.js +116 -27
- package/src/runtime/patch.js +90 -11
- package/src/runtime/style.js +11 -1
- package/src/styling/fluid.js +91 -4
- package/src/styling/spec.js +306 -0
package/GUIDE.md
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# Your first Orvyn app
|
|
2
|
+
|
|
3
|
+
In about 10 minutes you will build a shopping list that works on the web and on phones. No experience needed.
|
|
4
|
+
|
|
5
|
+
> This guide needs Orvyn 0.3.0 or newer.
|
|
6
|
+
|
|
7
|
+
## 1. Install
|
|
8
|
+
|
|
9
|
+
You need [Node.js](https://nodejs.org) 24 or newer. Then, in a terminal:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install -g orvyn-lang
|
|
13
|
+
orvyn new my-list
|
|
14
|
+
cd my-list
|
|
15
|
+
orvyn dev
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Your app opens in the browser. Leave this running: every time you save, the page updates.
|
|
19
|
+
|
|
20
|
+
## 2. Show something
|
|
21
|
+
|
|
22
|
+
Open `src/app.orv`, delete everything, and write:
|
|
23
|
+
|
|
24
|
+
```orvyn
|
|
25
|
+
screen Home {
|
|
26
|
+
Column gap: 12, padding: 24 {
|
|
27
|
+
Heading "Shopping list"
|
|
28
|
+
Text "Nothing here yet"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
A **screen** is one page. A **Column** puts things under each other.
|
|
34
|
+
|
|
35
|
+
## 3. Remember things
|
|
36
|
+
|
|
37
|
+
`state` is a value that can change. When it changes, the screen updates by itself.
|
|
38
|
+
|
|
39
|
+
```orvyn
|
|
40
|
+
state draft = ""
|
|
41
|
+
state items = []
|
|
42
|
+
|
|
43
|
+
screen Home {
|
|
44
|
+
Column gap: 12, padding: 24 {
|
|
45
|
+
Heading "Shopping list"
|
|
46
|
+
Input "What do you need?", bind: draft
|
|
47
|
+
Button "Add", onTap: add()
|
|
48
|
+
|
|
49
|
+
for item in items {
|
|
50
|
+
Text item
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
fn add() {
|
|
56
|
+
if draft != "" {
|
|
57
|
+
items.add(draft)
|
|
58
|
+
draft = ""
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
- `bind: draft` keeps the box and `draft` the same.
|
|
64
|
+
- `fn` is a set of steps with a name.
|
|
65
|
+
- `for` repeats something for every item.
|
|
66
|
+
|
|
67
|
+
## 4. Remove items and keep them
|
|
68
|
+
|
|
69
|
+
Change `state items = []` to this, and the list is still there after closing the app:
|
|
70
|
+
|
|
71
|
+
```orvyn
|
|
72
|
+
saved state items = []
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Then change the loop to add a delete button:
|
|
76
|
+
|
|
77
|
+
```orvyn
|
|
78
|
+
for item in items {
|
|
79
|
+
Row gap: 8, align: center {
|
|
80
|
+
Text item
|
|
81
|
+
Button "✕", label: "Delete", onTap: items.remove(item)
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
`label:` is what a screen reader says instead of "✕".
|
|
87
|
+
|
|
88
|
+
## 5. Add a second page
|
|
89
|
+
|
|
90
|
+
```orvyn
|
|
91
|
+
screen About {
|
|
92
|
+
Column gap: 12, padding: 24 {
|
|
93
|
+
Heading "About"
|
|
94
|
+
Text "My first Orvyn app"
|
|
95
|
+
Button "Back", onTap: back(Home)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Add this button inside `Home`:
|
|
101
|
+
|
|
102
|
+
```orvyn
|
|
103
|
+
Button "About", onTap: go(About)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## 6. Check that it works
|
|
107
|
+
|
|
108
|
+
Add this at the bottom of the file:
|
|
109
|
+
|
|
110
|
+
```orvyn
|
|
111
|
+
test "adds and deletes an item" {
|
|
112
|
+
type("What do you need?", "Milk")
|
|
113
|
+
tap("Add")
|
|
114
|
+
expect(text("Milk"))
|
|
115
|
+
tap("Delete")
|
|
116
|
+
expect(!text("Milk"))
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Open a second terminal in the same folder:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
orvyn test # does the app behave?
|
|
124
|
+
orvyn check # any mistakes?
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## 7. Put it on a phone
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
orvyn ios # iPhone simulator (needs a Mac with Xcode)
|
|
131
|
+
orvyn android # Android phone or emulator (needs the Android tools)
|
|
132
|
+
orvyn doctor # tells you what is missing
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Next
|
|
136
|
+
|
|
137
|
+
- [LANGUAGE.md](LANGUAGE.md) explains everything Orvyn can do.
|
|
138
|
+
- The `examples/` folder has apps with login, server data and saved storage.
|
|
139
|
+
|
|
140
|
+
## Bonus: ask your list questions
|
|
141
|
+
|
|
142
|
+
No special symbols to learn. Write the list, then a word:
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
Text "{items.count()} things to buy"
|
|
146
|
+
for item in items.search(draft) {
|
|
147
|
+
Text item
|
|
148
|
+
}
|
|
149
|
+
```
|