orvyn-lang 0.0.0-stage → 0.1.1

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.
Files changed (49) hide show
  1. package/LANGUAGE.md +227 -0
  2. package/LICENSE +21 -0
  3. package/README.md +181 -2
  4. package/package.json +39 -4
  5. package/src/cli/orvyn.js +856 -0
  6. package/src/core/context.js +19 -0
  7. package/src/core/lifecycle.js +8 -0
  8. package/src/core/resource.js +27 -0
  9. package/src/core/router.js +20 -0
  10. package/src/core/scheduler.js +153 -0
  11. package/src/core/signal.js +151 -0
  12. package/src/core/theme.js +10 -0
  13. package/src/devtools/devicePreview/PreviewFrame.js +214 -0
  14. package/src/devtools/devicePreview/index.js +6 -0
  15. package/src/devtools/overlay.js +105 -0
  16. package/src/devtools/runtime.js +190 -0
  17. package/src/lang/bundle-native.js +47 -0
  18. package/src/lang/codegen.js +478 -0
  19. package/src/lang/index.js +13 -0
  20. package/src/lang/lexer.js +224 -0
  21. package/src/lang/native/android/MainActivity.kt +93 -0
  22. package/src/lang/native/android/OrvynEngine.kt +127 -0
  23. package/src/lang/native/android/OrvynRenderer.kt +301 -0
  24. package/src/lang/native/android.js +144 -0
  25. package/src/lang/native/build.js +252 -0
  26. package/src/lang/native/ios/OrvynApp.swift +12 -0
  27. package/src/lang/native/ios/OrvynEngine.swift +267 -0
  28. package/src/lang/native/ios/OrvynViews.swift +275 -0
  29. package/src/lang/native/ios.js +244 -0
  30. package/src/lang/native-runtime.js +214 -0
  31. package/src/lang/parser.js +520 -0
  32. package/src/lang/runtime-shared.js +74 -0
  33. package/src/lang/runtime.js +139 -0
  34. package/src/lang/vite-plugin.js +39 -0
  35. package/src/runtime/createRenderer.js +22 -0
  36. package/src/runtime/h.js +93 -0
  37. package/src/runtime/hydrate.js +59 -0
  38. package/src/runtime/jsx-dev-runtime.js +7 -0
  39. package/src/runtime/jsx-runtime.js +13 -0
  40. package/src/runtime/mount.js +109 -0
  41. package/src/runtime/partialHydration.js +154 -0
  42. package/src/runtime/patch.js +199 -0
  43. package/src/runtime/platform.js +135 -0
  44. package/src/runtime/renderToStream.js +127 -0
  45. package/src/runtime/renderToString.js +121 -0
  46. package/src/runtime/resume.js +62 -0
  47. package/src/runtime/style.js +75 -0
  48. package/src/runtime/vnode.js +10 -0
  49. package/src/styling/fluid.js +743 -0
package/LANGUAGE.md ADDED
@@ -0,0 +1,227 @@
1
+ # The Orvyn Language (v0.1)
2
+
3
+ Orvyn files end in `.orv`. Write your app once; the Orvyn compiler turns it into
4
+ JavaScript for the web today, with iOS and Android output coming next.
5
+
6
+ ```orv
7
+ state count = 0
8
+
9
+ fn increment() {
10
+ count = count + 1
11
+ }
12
+
13
+ screen Home {
14
+ Column gap: 16, padding: 24 {
15
+ Text "Count: {count}", size: 32
16
+ Button "Add", bg: black, color: white, onTap: increment
17
+ }
18
+ }
19
+ ```
20
+
21
+ ## Install Orvyn (once)
22
+
23
+ ```bash
24
+ cd orvyn # this repo
25
+ npm install
26
+ npm link # makes the `orvyn` command work in any folder
27
+ ```
28
+
29
+ ## Make and run an app
30
+
31
+ ```bash
32
+ orvyn new my-app # creates the app and installs it
33
+ cd my-app
34
+
35
+ orvyn dev # web → http://localhost:5173, reloads when you save
36
+ orvyn ios # iPhone simulator, reloads when you save
37
+ orvyn android # Android emulator or phone
38
+ orvyn check # find mistakes
39
+ orvyn build # website → dist/web/
40
+ orvyn build ios # Xcode project → dist/ios/ (real iPhones, App Store)
41
+ orvyn build android # Android Studio project → dist/android/
42
+ ```
43
+
44
+ Your code lives in `src/app.orv`. Orvyn finds it by itself.
45
+
46
+ ### Live reload on iPhone
47
+
48
+ `orvyn ios` builds the app once, then keeps running:
49
+
50
+ | You do | What happens |
51
+ |---|---|
52
+ | Save any `.orv` file | The app reloads by itself (no Xcode rebuild) |
53
+ | Press `r` in the terminal | Reload now |
54
+ | Press `Cmd+R` in the simulator | Reload now |
55
+ | Press `l` | Relaunch the app |
56
+ | Press `q` | Quit |
57
+
58
+ Mistakes show in red on the phone and in the terminal, with the line number.
59
+
60
+ ### Notes
61
+
62
+ - iOS needs Xcode. Android needs Java 17, the Android SDK and Gradle, or just open `dist/android/` in Android Studio.
63
+ - App name, id and version come from `native` in `orvyn.config.ts`.
64
+ - How it works: your app's logic runs in the phone's built-in JavaScript engine, and every screen is drawn with real native views (SwiftUI on iPhone, Android Views on Android).
65
+ - Examples in this repo: `examples/counter.orv`, `examples/todo.orv`, `examples/shop.orv`. Run one with `orvyn ios examples/shop.orv`, or on the web with `npm run dev` here and open `/lang.html?app=shop`.
66
+
67
+ ## Declarations (top level)
68
+
69
+ | Syntax | Meaning |
70
+ |---|---|
71
+ | `state name = value` | A value that changes. The screen updates when it changes. |
72
+ | `saved state name = value` | Like `state`, but kept after a reload or app restart (cart, settings, login). |
73
+ | `let name = value` | A value that never changes. |
74
+ | `fn name(a, b) { ... }` | A function. |
75
+ | `screen Name { ... }` | A screen of your app. `App` (or the first screen) is shown first. |
76
+ | `component Name(param) { ... }` | A reusable piece of UI. |
77
+ | `start { ... }` | Runs once when the app opens (load data here). |
78
+ | `use Card, Badge from "./ui"` | Use components or functions from another `.orv` file. |
79
+
80
+ ## Statements (inside `fn` and handlers)
81
+
82
+ ```orv
83
+ let total = price * 2 // local variable
84
+ total += 1 // also -=, *=, /=
85
+ count = 0 // update state
86
+ if count > 10 { ... } else { ... }
87
+ for item in items { ... }
88
+ return total
89
+ print("hello") // logs to the console
90
+ ```
91
+
92
+ ### Lists and objects
93
+
94
+ Change them with these, and the screen updates by itself:
95
+
96
+ ```orv
97
+ state todos = []
98
+ state user = { name: "Asha", age: 20 }
99
+
100
+ todos.add({ text: "Milk", done: false }) // add to the end
101
+ todos.remove(todo) // remove this item
102
+ todos.removeAt(0) // remove by position
103
+ todos.update(todo, { done: true }) // change fields of one item
104
+ todos.clear() // empty the list
105
+ user.name = "Ravi" // change one field
106
+ ```
107
+
108
+ Reading is safe even before data arrives: `user.name` is just empty while `user` is `null`.
109
+
110
+ ### Remember things after the app closes
111
+
112
+ Put `saved` in front of `state`:
113
+
114
+ ```orv
115
+ saved state cart = []
116
+ saved state darkMode = false
117
+ ```
118
+
119
+ The value is stored on the device (browser storage on the web, UserDefaults on
120
+ iPhone, SharedPreferences on Android) and comes back the next time the app opens.
121
+ It also survives live reload while you develop.
122
+
123
+ ### Internet data
124
+
125
+ ```orv
126
+ state users = []
127
+
128
+ start {
129
+ users = wait fetch("https://api.example.com/users")
130
+ }
131
+ ```
132
+
133
+ `fetch` gives back the JSON directly. To send data: `fetch(url, { method: "POST", body: { name: "A" } })`.
134
+ `wait` pauses until it's done: use it with `fetch` and `sleep(1000)`.
135
+
136
+ ### Built-in functions
137
+
138
+ | Function | Does |
139
+ |---|---|
140
+ | `print(x)` | Log to the console |
141
+ | `fetch(url)` | Get data from the internet |
142
+ | `go(Screen)` | Open another screen |
143
+ | `sleep(ms)` | Wait (use with `wait`) |
144
+ | `random(1, 6)` | Random whole number |
145
+ | `len(list)` | Number of items |
146
+
147
+ Short functions: `todos.filter(t => t.done)`, `prices.map((p, i) => p * 2)`.
148
+ Choose a value: `done ? "Yes" : "No"`.
149
+
150
+ ## Values
151
+
152
+ `12`, `3.5`, `"text"`, `"Hi {name}"` (interpolation), `true`, `false`, `null`,
153
+ `[1, 2, 3]`, `#1e293b` (colors), `a.b`, `list[0]`, `f(x)`.
154
+
155
+ Operators: `+ - * / %`, `== != < > <= >=`, `&& || !`.
156
+
157
+ ## Elements
158
+
159
+ `Element firstArgument, name: value, name: value { children }`
160
+
161
+ | Element | First argument | Renders as |
162
+ |---|---|---|
163
+ | `Column` | — | vertical stack |
164
+ | `Row` | — | horizontal stack |
165
+ | `Box` | — | container |
166
+ | `Text`, `Heading` | text | text |
167
+ | `Button` | label | button |
168
+ | `Input` | placeholder | text field |
169
+ | `Image` | source URL | image |
170
+ | `Link` | text | link (`href: "..."`) |
171
+
172
+ Style props: `bg`, `color`, `size`, `padding`, `margin`, `gap`, `radius`, `width`,
173
+ `height`, `align`, `justify`, `border`, `shadow`, and the rest of Orvyn's style props.
174
+ Plain words like `black` or `center` are treated as text.
175
+
176
+ Events: `onTap`, `onChange`, `onSubmit`, `onHover`, `onLeave`. Give a function name,
177
+ one statement, or a block:
178
+
179
+ ```orv
180
+ Button "Add", onTap: increment
181
+ Button "-1", onTap: count -= 1
182
+ Input "Name", onChange: { name = value } // value = the typed text
183
+ ```
184
+
185
+ Inside a view you can use `if` / `else` and `for item in list { ... }`.
186
+
187
+ ### Screens and navigation
188
+
189
+ ```orv
190
+ screen Home {
191
+ Button "About", onTap: go(About)
192
+ }
193
+
194
+ screen About {
195
+ Button "Back", onTap: go(Home)
196
+ }
197
+ ```
198
+
199
+ `App` (or the first screen in the file) opens first.
200
+
201
+ ## Editor colours (VS Code)
202
+
203
+ ```bash
204
+ ln -s "$PWD/editors/vscode" ~/.vscode/extensions/orvyn-lang
205
+ ```
206
+
207
+ Then restart VS Code. `.orv` files get colours, comment toggling and bracket matching.
208
+
209
+ ## Errors
210
+
211
+ The compiler stops at the first error and shows the line:
212
+
213
+ ```
214
+ ✗ app.orv:4:3
215
+ Unknown element "Buton". Available: Column, Row, Box, Text, ...
216
+
217
+ 4 | Buton "x"
218
+ | ^
219
+ ```
220
+
221
+ ## Not in v0.1 yet
222
+
223
+ - Native: `Image` sizes, `justify`, and hover events are basic on phones
224
+ - Live reload is iPhone-only for now (Android: `orvyn android` rebuilds)
225
+ - `state` inside components (keep state at the top of the file for now)
226
+ - Browser back button with `go()`
227
+ - `while` loops
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Orvyn
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,182 @@
1
- # Temporary Holding Version
1
+ # Orvyn
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **One language for web, iPhone and Android.** Write `.orv` files once and get a
4
+ website, a native iPhone app (SwiftUI) and a native Android app.
5
+
6
+ ```bash
7
+ npm install -g orvyn-lang
8
+ orvyn new my-app
9
+ cd my-app
10
+ orvyn dev # web, live reload
11
+ orvyn ios # iPhone simulator, live reload (needs Xcode)
12
+ ```
13
+
14
+ ```orv
15
+ state count = 0
16
+
17
+ screen Home {
18
+ Column gap: 16, padding: 24 {
19
+ Text "Count: {count}", size: 32
20
+ Button "Add", bg: black, color: white, onTap: count += 1
21
+ }
22
+ }
23
+ ```
24
+
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 or functions from another `.orv` file. |
38
+
39
+ ## Statements (inside `fn` and handlers)
40
+
41
+ ```orv
42
+ let total = price * 2 // local variable
43
+ total += 1 // also -=, *=, /=
44
+ count = 0 // update state
45
+ if count > 10 { ... } else { ... }
46
+ for item in items { ... }
47
+ return total
48
+ print("hello") // logs to the console
49
+ ```
50
+
51
+ ### Lists and objects
52
+
53
+ Change them with these, and the screen updates by itself:
54
+
55
+ ```orv
56
+ state todos = []
57
+ state user = { name: "Asha", age: 20 }
58
+
59
+ todos.add({ text: "Milk", done: false }) // add to the end
60
+ todos.remove(todo) // remove this item
61
+ todos.removeAt(0) // remove by position
62
+ todos.update(todo, { done: true }) // change fields of one item
63
+ todos.clear() // empty the list
64
+ user.name = "Ravi" // change one field
65
+ ```
66
+
67
+ Reading is safe even before data arrives: `user.name` is just empty while `user` is `null`.
68
+
69
+ ### Remember things after the app closes
70
+
71
+ Put `saved` in front of `state`:
72
+
73
+ ```orv
74
+ saved state cart = []
75
+ saved state darkMode = false
76
+ ```
77
+
78
+ The value is stored on the device (browser storage on the web, UserDefaults on
79
+ iPhone, SharedPreferences on Android) and comes back the next time the app opens.
80
+ It also survives live reload while you develop.
81
+
82
+ ### Internet data
83
+
84
+ ```orv
85
+ state users = []
86
+
87
+ start {
88
+ users = wait fetch("https://api.example.com/users")
89
+ }
90
+ ```
91
+
92
+ `fetch` gives back the JSON directly. To send data: `fetch(url, { method: "POST", body: { name: "A" } })`.
93
+ `wait` pauses until it's done: use it with `fetch` and `sleep(1000)`.
94
+
95
+ ### Built-in functions
96
+
97
+ | Function | Does |
98
+ |---|---|
99
+ | `print(x)` | Log to the console |
100
+ | `fetch(url)` | Get data from the internet |
101
+ | `go(Screen)` | Open another screen |
102
+ | `sleep(ms)` | Wait (use with `wait`) |
103
+ | `random(1, 6)` | Random whole number |
104
+ | `len(list)` | Number of items |
105
+
106
+ Short functions: `todos.filter(t => t.done)`, `prices.map((p, i) => p * 2)`.
107
+ Choose a value: `done ? "Yes" : "No"`.
108
+
109
+ ## Values
110
+
111
+ `12`, `3.5`, `"text"`, `"Hi {name}"` (interpolation), `true`, `false`, `null`,
112
+ `[1, 2, 3]`, `#1e293b` (colors), `a.b`, `list[0]`, `f(x)`.
113
+
114
+ Operators: `+ - * / %`, `== != < > <= >=`, `&& || !`.
115
+
116
+ ## Elements
117
+
118
+ `Element firstArgument, name: value, name: value { children }`
119
+
120
+ | Element | First argument | Renders as |
121
+ |---|---|---|
122
+ | `Column` | — | vertical stack |
123
+ | `Row` | — | horizontal stack |
124
+ | `Box` | — | container |
125
+ | `Text`, `Heading` | text | text |
126
+ | `Button` | label | button |
127
+ | `Input` | placeholder | text field |
128
+ | `Image` | source URL | image |
129
+ | `Link` | text | link (`href: "..."`) |
130
+
131
+ Style props: `bg`, `color`, `size`, `padding`, `margin`, `gap`, `radius`, `width`,
132
+ `height`, `align`, `justify`, `border`, `shadow`, and the rest of Orvyn's style props.
133
+ Plain words like `black` or `center` are treated as text.
134
+
135
+ Events: `onTap`, `onChange`, `onSubmit`, `onHover`, `onLeave`. Give a function name,
136
+ one statement, or a block:
137
+
138
+ ```orv
139
+ Button "Add", onTap: increment
140
+ Button "-1", onTap: count -= 1
141
+ Input "Name", onChange: { name = value } // value = the typed text
142
+ ```
143
+
144
+ Inside a view you can use `if` / `else` and `for item in list { ... }`.
145
+
146
+ ### Screens and navigation
147
+
148
+ ```orv
149
+ screen Home {
150
+ Button "About", onTap: go(About)
151
+ }
152
+
153
+ screen About {
154
+ Button "Back", onTap: go(Home)
155
+ }
156
+ ```
157
+
158
+ `App` (or the first screen in the file) opens first.
159
+
160
+ ## Editor colours (VS Code)
161
+
162
+ Install **Orvyn Language** from the VS Code Extensions panel.
163
+
164
+ ## Errors
165
+
166
+ The compiler stops at the first error and shows the line:
167
+
168
+ ```
169
+ ✗ app.orv:4:3
170
+ Unknown element "Buton". Available: Column, Row, Box, Text, ...
171
+
172
+ 4 | Buton "x"
173
+ | ^
174
+ ```
175
+
176
+ ## Not in v0.1 yet
177
+
178
+ - Native: `Image` sizes, `justify`, and hover events are basic on phones
179
+ - Live reload is iPhone-only for now (Android: `orvyn android` rebuilds)
180
+ - `state` inside components (keep state at the top of the file for now)
181
+ - Browser back button with `go()`
182
+ - `while` loops
package/package.json CHANGED
@@ -1,6 +1,41 @@
1
1
  {
2
2
  "name": "orvyn-lang",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "Orvyn — one language for web, iPhone and Android. Write .orv files once, get a website and native apps.",
5
+ "type": "module",
6
+ "bin": {
7
+ "orvyn": "src/cli/orvyn.js"
8
+ },
9
+ "exports": {
10
+ "./lang": "./src/lang/index.js",
11
+ "./lang/*": "./src/lang/*.js",
12
+ "./core/*": "./src/core/*.js",
13
+ "./runtime/*": "./src/runtime/*.js",
14
+ "./styling/*": "./src/styling/*.js",
15
+ "./package.json": "./package.json"
16
+ },
17
+ "files": [
18
+ "src",
19
+ "README.md",
20
+ "LANGUAGE.md",
21
+ "LICENSE"
22
+ ],
23
+ "engines": {
24
+ "node": ">=20.19"
25
+ },
26
+ "dependencies": {
27
+ "vite": "^7.0.0"
28
+ },
29
+ "keywords": [
30
+ "orvyn",
31
+ "language",
32
+ "compiler",
33
+ "ios",
34
+ "android",
35
+ "swiftui",
36
+ "cross-platform",
37
+ "mobile",
38
+ "web"
39
+ ],
40
+ "license": "MIT"
41
+ }