@c9up/orbit 0.0.0-stage → 0.1.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/Cargo.lock +146 -0
- package/Cargo.toml +16 -0
- package/LICENSE +21 -0
- package/README.md +314 -2
- package/android/orbit.cmake +31 -0
- package/android/src/main/cpp/NativeOrbit.cpp +309 -0
- package/android/src/main/cpp/NativeOrbit.h +35 -0
- package/android/src/main/cpp/orbit_host.h +34 -0
- package/android/src/main/java/com/c9up/orbit/OrbitEffects.kt +286 -0
- package/android/src/main/java/com/c9up/orbit/OrbitHost.kt +258 -0
- package/android/src/main/java/com/c9up/orbit/OrbitImage.kt +346 -0
- package/android/src/main/java/com/c9up/orbit/OrbitInput.kt +145 -0
- package/android/src/main/java/com/c9up/orbit/OrbitPress.kt +110 -0
- package/android/src/main/java/com/c9up/orbit/OrbitVector.kt +115 -0
- package/android/src/main/java/com/c9up/orbit/OrbitViews.kt +362 -0
- package/crates/orbit-host/Cargo.toml +14 -0
- package/crates/orbit-host/src/gesture.rs +561 -0
- package/crates/orbit-host/src/lib.rs +1608 -0
- package/crates/orbit-host/src/motion.rs +328 -0
- package/crates/orbit-host/src/vector.rs +917 -0
- package/dist/color.d.ts +10 -0
- package/dist/color.d.ts.map +1 -0
- package/dist/color.js +62 -0
- package/dist/color.js.map +1 -0
- package/dist/commit.d.ts +45 -0
- package/dist/commit.d.ts.map +1 -0
- package/dist/commit.js +172 -0
- package/dist/commit.js.map +1 -0
- package/dist/errors.d.ts +42 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +15 -0
- package/dist/errors.js.map +1 -0
- package/dist/host.d.ts +49 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +18 -0
- package/dist/host.js.map +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/motion.d.ts +18 -0
- package/dist/motion.d.ts.map +1 -0
- package/dist/motion.js +66 -0
- package/dist/motion.js.map +1 -0
- package/dist/node.d.ts +46 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +110 -0
- package/dist/node.js.map +1 -0
- package/dist/pages.d.ts +56 -0
- package/dist/pages.d.ts.map +1 -0
- package/dist/pages.js +157 -0
- package/dist/pages.js.map +1 -0
- package/dist/react-native/index.d.ts +25 -0
- package/dist/react-native/index.d.ts.map +1 -0
- package/dist/react-native/index.js +43 -0
- package/dist/react-native/index.js.map +1 -0
- package/dist/server.d.ts +85 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +282 -0
- package/dist/server.js.map +1 -0
- package/dist/stack.d.ts +117 -0
- package/dist/stack.d.ts.map +1 -0
- package/dist/stack.js +299 -0
- package/dist/stack.js.map +1 -0
- package/dist/styles.d.ts +138 -0
- package/dist/styles.d.ts.map +1 -0
- package/dist/styles.js +920 -0
- package/dist/styles.js.map +1 -0
- package/dist/template.d.ts +27 -0
- package/dist/template.d.ts.map +1 -0
- package/dist/template.js +1392 -0
- package/dist/template.js.map +1 -0
- package/dist/url.d.ts +45 -0
- package/dist/url.d.ts.map +1 -0
- package/dist/url.js +302 -0
- package/dist/url.js.map +1 -0
- package/package.json +90 -3
- package/scripts/build-android.sh +27 -0
- package/scripts/test-styles.mjs +31 -0
- package/specs/NativeOrbit.ts +34 -0
- package/src/color.ts +73 -0
- package/src/commit.ts +206 -0
- package/src/errors.ts +48 -0
- package/src/host.ts +92 -0
- package/src/index.ts +60 -0
- package/src/motion.ts +86 -0
- package/src/node.ts +133 -0
- package/src/pages.ts +210 -0
- package/src/react-native/index.ts +76 -0
- package/src/react-native/react-native.d.ts +31 -0
- package/src/server.ts +359 -0
- package/src/stack.ts +434 -0
- package/src/styles.ts +1024 -0
- package/src/template.ts +1657 -0
- package/src/url.ts +326 -0
package/Cargo.lock
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 4
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "arrayvec"
|
|
7
|
+
version = "0.7.8"
|
|
8
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
9
|
+
checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56"
|
|
10
|
+
|
|
11
|
+
[[package]]
|
|
12
|
+
name = "grid"
|
|
13
|
+
version = "1.0.1"
|
|
14
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
15
|
+
checksum = "b40ca9252762c466af32d0b1002e91e4e1bc5398f77455e55474deb466355ff5"
|
|
16
|
+
|
|
17
|
+
[[package]]
|
|
18
|
+
name = "itoa"
|
|
19
|
+
version = "1.0.19"
|
|
20
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
21
|
+
checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4"
|
|
22
|
+
|
|
23
|
+
[[package]]
|
|
24
|
+
name = "memchr"
|
|
25
|
+
version = "2.8.3"
|
|
26
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
27
|
+
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
|
|
28
|
+
|
|
29
|
+
[[package]]
|
|
30
|
+
name = "orbit-host"
|
|
31
|
+
version = "0.1.0"
|
|
32
|
+
dependencies = [
|
|
33
|
+
"serde_json",
|
|
34
|
+
"taffy",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
[[package]]
|
|
38
|
+
name = "proc-macro2"
|
|
39
|
+
version = "1.0.107"
|
|
40
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
41
|
+
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
|
42
|
+
dependencies = [
|
|
43
|
+
"unicode-ident",
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
[[package]]
|
|
47
|
+
name = "quote"
|
|
48
|
+
version = "1.0.47"
|
|
49
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
50
|
+
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
|
51
|
+
dependencies = [
|
|
52
|
+
"proc-macro2",
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
[[package]]
|
|
56
|
+
name = "serde"
|
|
57
|
+
version = "1.0.229"
|
|
58
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
59
|
+
checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
|
|
60
|
+
dependencies = [
|
|
61
|
+
"serde_core",
|
|
62
|
+
"serde_derive",
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
[[package]]
|
|
66
|
+
name = "serde_core"
|
|
67
|
+
version = "1.0.229"
|
|
68
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
69
|
+
checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
|
|
70
|
+
dependencies = [
|
|
71
|
+
"serde_derive",
|
|
72
|
+
]
|
|
73
|
+
|
|
74
|
+
[[package]]
|
|
75
|
+
name = "serde_derive"
|
|
76
|
+
version = "1.0.229"
|
|
77
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
78
|
+
checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
|
|
79
|
+
dependencies = [
|
|
80
|
+
"proc-macro2",
|
|
81
|
+
"quote",
|
|
82
|
+
"syn",
|
|
83
|
+
]
|
|
84
|
+
|
|
85
|
+
[[package]]
|
|
86
|
+
name = "serde_json"
|
|
87
|
+
version = "1.0.154"
|
|
88
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
89
|
+
checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6"
|
|
90
|
+
dependencies = [
|
|
91
|
+
"itoa",
|
|
92
|
+
"memchr",
|
|
93
|
+
"serde",
|
|
94
|
+
"serde_core",
|
|
95
|
+
"zmij",
|
|
96
|
+
]
|
|
97
|
+
|
|
98
|
+
[[package]]
|
|
99
|
+
name = "slotmap"
|
|
100
|
+
version = "1.1.1"
|
|
101
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
102
|
+
checksum = "bdd58c3c93c3d278ca835519292445cb4b0d4dc59ccfdf7ceadaab3f8aeb4038"
|
|
103
|
+
dependencies = [
|
|
104
|
+
"version_check",
|
|
105
|
+
]
|
|
106
|
+
|
|
107
|
+
[[package]]
|
|
108
|
+
name = "syn"
|
|
109
|
+
version = "3.0.10"
|
|
110
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
111
|
+
checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79"
|
|
112
|
+
dependencies = [
|
|
113
|
+
"proc-macro2",
|
|
114
|
+
"quote",
|
|
115
|
+
"unicode-ident",
|
|
116
|
+
]
|
|
117
|
+
|
|
118
|
+
[[package]]
|
|
119
|
+
name = "taffy"
|
|
120
|
+
version = "0.9.2"
|
|
121
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
122
|
+
checksum = "41ba83ebaf2954d31d05d67340fd46cebe99da2b7133b0dd68d70c65473a437b"
|
|
123
|
+
dependencies = [
|
|
124
|
+
"arrayvec",
|
|
125
|
+
"grid",
|
|
126
|
+
"serde",
|
|
127
|
+
"slotmap",
|
|
128
|
+
]
|
|
129
|
+
|
|
130
|
+
[[package]]
|
|
131
|
+
name = "unicode-ident"
|
|
132
|
+
version = "1.0.27"
|
|
133
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
134
|
+
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
|
|
135
|
+
|
|
136
|
+
[[package]]
|
|
137
|
+
name = "version_check"
|
|
138
|
+
version = "0.9.5"
|
|
139
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
140
|
+
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
|
141
|
+
|
|
142
|
+
[[package]]
|
|
143
|
+
name = "zmij"
|
|
144
|
+
version = "1.0.23"
|
|
145
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
146
|
+
checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
|
package/Cargo.toml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
[workspace]
|
|
2
|
+
resolver = "2"
|
|
3
|
+
members = ["crates/orbit-host"]
|
|
4
|
+
|
|
5
|
+
[workspace.package]
|
|
6
|
+
edition = "2021"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
repository = "https://github.com/C9up/orbit"
|
|
9
|
+
|
|
10
|
+
# The host is linked into the app's native library (a static library behind a
|
|
11
|
+
# C ABI, called from the JSI module). No `panic = "abort"`: every exported
|
|
12
|
+
# function wraps its body in `catch_unwind`, and abort would kill the app.
|
|
13
|
+
[profile.release]
|
|
14
|
+
opt-level = 3
|
|
15
|
+
lto = "fat"
|
|
16
|
+
codegen-units = 1
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 C9up
|
|
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,315 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @c9up/orbit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
aurora components as native views on a phone.
|
|
4
|
+
|
|
5
|
+
A component written with `@c9up/aurora/core` — `html`, `component`, signals,
|
|
6
|
+
Tailwind classes — renders unchanged on Android: orbit keeps a tree of native
|
|
7
|
+
nodes that aurora's signals patch, and commits it over JSI to a Rust host. The
|
|
8
|
+
host lays the tree out (taffy), diffs it against what is on screen and hands
|
|
9
|
+
mount operations to the platform's own views. Animations and scroll-driven
|
|
10
|
+
values run on the UI thread, driven by the host on every vsync, so a busy JS
|
|
11
|
+
thread does not stop them. No React, no Expo.
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { component, html, MotionValue, signal } from "@c9up/aurora/core";
|
|
15
|
+
import { mount, useHost } from "@c9up/orbit";
|
|
16
|
+
import { Dimensions, TurboModuleRegistry } from "react-native";
|
|
17
|
+
|
|
18
|
+
const Counter = component(() => {
|
|
19
|
+
const count = signal(0);
|
|
20
|
+
return html`<div class="flex items-center justify-between p-4 bg-white rounded-lg">
|
|
21
|
+
<span class="text-base text-slate-700">Compteur : ${count}</span>
|
|
22
|
+
<div class="px-4 py-2 bg-blue-600 rounded-md" @click=${() => count((n) => n + 1)}>
|
|
23
|
+
<span class="text-white font-semibold">+1</span>
|
|
24
|
+
</div>
|
|
25
|
+
</div>`;
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
useHost(TurboModuleRegistry.getEnforcing("NativeOrbit"));
|
|
29
|
+
mount(Counter({}), { viewport: Dimensions.get("window") });
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## What maps to what
|
|
33
|
+
|
|
34
|
+
| Template | Native |
|
|
35
|
+
|---|---|
|
|
36
|
+
| block elements (`div`, `section`, …) | a view |
|
|
37
|
+
| `p`, `h1`–`h6`, `label` | a text |
|
|
38
|
+
| inline elements (`span`, `strong`, `em`, …) | a run inside the surrounding text |
|
|
39
|
+
| text sitting in a view | wrapped in an anonymous text, as CSS does |
|
|
40
|
+
| `class="…"` | the app's own Tailwind build, compiled at build time (see Styles); text styles cascade |
|
|
41
|
+
| a `flex` container | each child its own item; `flex` is a row, as on the web |
|
|
42
|
+
| `overflow-y-auto` | a native scroll view around a content view |
|
|
43
|
+
| `overflow-hidden` | children clipped to the box (and its rounded corners); otherwise they may overflow, as in CSS |
|
|
44
|
+
| `shadow-*` | a CSS box shadow, drawn by the parent outside the box (Android 8+) |
|
|
45
|
+
| `backdrop-blur-*` | what is behind the view, blurred (Android 12+; the translucent background alone below) |
|
|
46
|
+
| `@click=${fn}` | a press, recognized natively: fires on release if the finger stayed put; a ripple shows at once |
|
|
47
|
+
| `@longpress`, `@pan`, `@swipe` | recognized natively too (see Gestures) |
|
|
48
|
+
| `motion=${{ opacity, translateX, translateY, scale, visible }}` | UI-thread animation (aurora's `MotionValue`, the same one the browser animates; `visible` hides at or below 0.5, laid out but not drawn or touchable) |
|
|
49
|
+
| `scroll-y=${value}` | the scroll offset feeds a `MotionValue` |
|
|
50
|
+
| `input`, `textarea` | the platform's text field (`EditText`): typing never waits for JS |
|
|
51
|
+
| `@input`, `@change`, `@focus`, `@blur`, Enter as `@keydown` | the field's events, `event.target.value` carrying the text |
|
|
52
|
+
| `.value=${() => text()}` | sets the field only when the app changes it, never over what is being typed |
|
|
53
|
+
| `field-sizing-content` (+ `max-h-*`) | a `textarea` that grows with its lines, up to its maximum |
|
|
54
|
+
| `img` | an image view, decoded off the UI thread at the size it is shown |
|
|
55
|
+
| `each(items, key, render)` | one row per key: a kept row keeps its views and moves, a new key builds one row, a key that left deletes its row |
|
|
56
|
+
| `each(…, { lazy })` | only the rows in the nearest scroll view's viewport, plus a margin, exist (see below) |
|
|
57
|
+
| `svg` | a vector view: paths, basic shapes and `g`, drawn by the host (see below) |
|
|
58
|
+
|
|
59
|
+
Both read `placeholder`, `maxlength`, `autocomplete`, `inputmode` and
|
|
60
|
+
`disabled`; `input` reads `type` for the keyboard and for a password field,
|
|
61
|
+
`textarea` reads `rows`. The root lays out inside the safe area: the status bar, the navigation
|
|
62
|
+
buttons, a display cutout and the open keyboard are kept clear of content.
|
|
63
|
+
|
|
64
|
+
An `img` reads `src` and `alt`, and is sized by its classes (`w-*`, `h-*`,
|
|
65
|
+
`size-*`, `aspect-square`, `aspect-video`): its box never waits for the image
|
|
66
|
+
to learn a size, so an unsized image takes no height. `object-cover`,
|
|
67
|
+
`object-contain`, `object-none` and `object-scale-down` fit it (`fill` by
|
|
68
|
+
default, as in CSS), `rounded-*` clips it and a border is drawn over it.
|
|
69
|
+
`src` is
|
|
70
|
+
|
|
71
|
+
- an `https://` URL (plain `http:` throws `E_ORBIT_INSECURE_IMAGE_URL`);
|
|
72
|
+
- a path (`/data/…` or `file://…`), or a `content://` URI from a picker;
|
|
73
|
+
- a bare name, read from the app's bundled assets;
|
|
74
|
+
- bytes, a `Uint8Array` or an `ArrayBuffer` (`src=${bytes}`): sent to the
|
|
75
|
+
native side's memory at the next commit, never written to disk, and zeroed
|
|
76
|
+
with the node, so a decrypted media stays out of storage. orbit reads the
|
|
77
|
+
array when it commits: keep it unchanged until the image shows.
|
|
78
|
+
|
|
79
|
+
Any other scheme (`data:`, `javascript:`…) throws `E_ORBIT_IMAGE_SOURCE`.
|
|
80
|
+
Images are decoded at the size their box is laid out to, never above the
|
|
81
|
+
source's own size nor 4096 px a side, and kept decoded in a memory cache
|
|
82
|
+
bounded to an eighth of the app's heap; a download or a file over 64 MB is
|
|
83
|
+
refused. Remote images have no disk cache yet.
|
|
84
|
+
|
|
85
|
+
Not mapped yet (`E_ORBIT_UNSUPPORTED_ELEMENT`): `select`, `canvas`. Accessibility is still to come.
|
|
86
|
+
|
|
87
|
+
## Styles
|
|
88
|
+
|
|
89
|
+
The app's classes are its Tailwind classes, styled by its own Tailwind build.
|
|
90
|
+
`ream android:*` runs Tailwind over the app (its `mobile.css`, as on the web)
|
|
91
|
+
and compiles the output into a style table (`ream css:compile`): every rule
|
|
92
|
+
with its values resolved against the theme — lengths in px, colours light and
|
|
93
|
+
dark — and only what classes compose at run time left open (`--tw-shadow`,
|
|
94
|
+
`--tw-leading`…). `run()` loads it; `useStyles(table)` does by hand.
|
|
95
|
+
|
|
96
|
+
orbit applies it as a browser applies the stylesheet: rules matched by class,
|
|
97
|
+
cascaded by specificity and order, the base layer's element rules included
|
|
98
|
+
(nebula's `* { border-color }`, `body { background; color }` on the root),
|
|
99
|
+
custom properties resolved, and the result read into the host's style keys.
|
|
100
|
+
Variants are conditions on orbit's own tree, followed when they change:
|
|
101
|
+
|
|
102
|
+
- an attribute of the element: `data-[state=open]:`, `aria-invalid:`,
|
|
103
|
+
`disabled:` (aurora's `?disabled`), `[class*=…]`;
|
|
104
|
+
- `dark:` and the theme's dark values, through `colorScheme("dark")`;
|
|
105
|
+
- an ancestor (`group-data-[…]:`), a previous sibling (`peer-checked:`), the
|
|
106
|
+
element's children and descendants (`*:`, `space-y-*`, `[&_svg]:size-4`);
|
|
107
|
+
- the viewport's width (`sm:`, `md:`).
|
|
108
|
+
|
|
109
|
+
What a touch screen never is (`hover:` sits behind `@media (hover:hover)`),
|
|
110
|
+
what orbit does not see yet (`:has()`, `:first-child`, `::after`) and what it
|
|
111
|
+
does not draw (transitions, transforms, gradients, `grid` — laid out as a
|
|
112
|
+
column) leave the class known and inert. A class the stylesheet does not have
|
|
113
|
+
lands in `unknownClasses`.
|
|
114
|
+
|
|
115
|
+
Text gets its line height (`leading-*`, and a size's own): every line exactly
|
|
116
|
+
that tall, the glyphs centred, as CSS's line box; weights are exact
|
|
117
|
+
(`font-medium` is 500).
|
|
118
|
+
|
|
119
|
+
On the maintainer's phone nebula's Button, Card and a list of Items render as
|
|
120
|
+
Chromium does with the same stylesheet and font: across the screen's 55 boxes,
|
|
121
|
+
heights and positions agree within 0.9 dp (a physical pixel is 0.36 dp there).
|
|
122
|
+
|
|
123
|
+
## Vector drawings
|
|
124
|
+
|
|
125
|
+
`<svg>` becomes a vector view. orbit-host (`crates/orbit-host/src/vector.rs`)
|
|
126
|
+
reads the drawing — path data with every command (relative, smooth curves,
|
|
127
|
+
arcs), `rect` (rounded), `circle`, `ellipse`, `line`, `polyline`, `polygon`,
|
|
128
|
+
`g`, `transform`, `fill` / `stroke` and their opacities, `stroke-width`,
|
|
129
|
+
caps, joins, `fill-rule` — and hands the platform plain paths to replay,
|
|
130
|
+
scaled to the box (`viewBox`, `preserveAspectRatio` meet or `none`).
|
|
131
|
+
|
|
132
|
+
- `currentColor` paints with the svg's text colour: its own `text-*`, else
|
|
133
|
+
the one it inherits — an icon takes the colour of the text it sits in.
|
|
134
|
+
- The class sizes it; `width` / `height` do when the class does not, and the
|
|
135
|
+
viewBox keeps its proportions.
|
|
136
|
+
- `shape-rendering="crispEdges"` draws without antialiasing: a QR code's
|
|
137
|
+
modules stay pure black and white at any scale.
|
|
138
|
+
- Anything else inside (`text`, `use`, gradients, masks) is refused, by name.
|
|
139
|
+
|
|
140
|
+
On the maintainer's phone nebula's icons match Chromium's rendering at the
|
|
141
|
+
same scale (mean difference under 1.2 / 255 per icon), and a QR code of
|
|
142
|
+
53 × 53 modules drawn at 288 dp has no grey pixel and decodes.
|
|
143
|
+
|
|
144
|
+
## Screens
|
|
145
|
+
|
|
146
|
+
A stack of screens, each an aurora component:
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
import { createStack, useScreen } from "@c9up/orbit";
|
|
150
|
+
|
|
151
|
+
export const App = component(() => html`${createStack(Home)}`);
|
|
152
|
+
|
|
153
|
+
const Home = component(() => {
|
|
154
|
+
const screen = useScreen();
|
|
155
|
+
return html`<div @click=${() => screen.push(Detail, { id: 3 })}>…</div>`;
|
|
156
|
+
});
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
- `push(Screen, props)` shows a screen on top; `pop()` ends the top one;
|
|
160
|
+
`replace(Screen, props)` swaps it. The Android back button and back gesture
|
|
161
|
+
pop the innermost stack shown; with nothing to pop, the app goes back as
|
|
162
|
+
any Android app does.
|
|
163
|
+
- A covered screen stays built: its views are laid out under the top one (a
|
|
164
|
+
scroll view keeps its offset), its signals and effects keep running, and it
|
|
165
|
+
is hidden once covered — not drawn, not touchable. `screen.focused()` is
|
|
166
|
+
true while a screen is the one shown; an effect that should pause reads it.
|
|
167
|
+
- A popped or replaced screen ends at once: its effects stop and its
|
|
168
|
+
`onUnmount` runs; its views go when its transition is over.
|
|
169
|
+
- Transitions are motion values, played by orbit-host on the UI thread: the
|
|
170
|
+
new screen slides in from the right edge while the covered one drifts left
|
|
171
|
+
(`transition: 'none'` switches at once; `duration`, default 300 ms).
|
|
172
|
+
- A screen paints its own background (its root's `bg-…`): the stack paints
|
|
173
|
+
none, since each full-screen layer is filled again on every frame. With
|
|
174
|
+
screens that leave areas transparent, `background` paints one behind each.
|
|
175
|
+
- A screen sees what was provided around its stack (`provide`/`inject`), even
|
|
176
|
+
one pushed long after; a stack can sit in a screen (a tab with its own
|
|
177
|
+
history).
|
|
178
|
+
|
|
179
|
+
Nothing here knows URLs: a router, or server-driven pages, pushes the screen
|
|
180
|
+
a URL names.
|
|
181
|
+
|
|
182
|
+
## Server-driven pages
|
|
183
|
+
|
|
184
|
+
```ts
|
|
185
|
+
import { serverPages } from '@c9up/orbit/pages'
|
|
186
|
+
import Home from './pages/Home.js'
|
|
187
|
+
import Orders from './pages/Orders.js'
|
|
188
|
+
|
|
189
|
+
run(() => html`${serverPages({ server: 'https://app.example', pages: { Home, Orders } })}`)
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
The ream server stays the router: the app asks it for the first page object,
|
|
193
|
+
and each link or `router.visit()` asks for the next one, through photon's
|
|
194
|
+
protocol — the one the browser speaks after aurora's `visits: true`. The same
|
|
195
|
+
controller answers both; the app shows the page it names, an aurora
|
|
196
|
+
component bundled with the app (the very module the browser loads, when the
|
|
197
|
+
page imports from `@c9up/aurora` and `@c9up/photon/client/core`).
|
|
198
|
+
|
|
199
|
+
- Each page is a screen of a stack: a visit to a new address slides one in;
|
|
200
|
+
a partial reload, a deferred prop or a redirect back to the same address
|
|
201
|
+
replaces it in place.
|
|
202
|
+
- The back button goes through photon's history: the covered page comes back
|
|
203
|
+
as it was left, without a request.
|
|
204
|
+
- A stale version (the server was deployed again) starts over from the page
|
|
205
|
+
asked for, as a browser's full load does.
|
|
206
|
+
- Requests carry the session cookie (`credentials: 'include'`) and echo the
|
|
207
|
+
`XSRF-TOKEN` the server set; a link off the server goes to `open`.
|
|
208
|
+
- `server` must be https; plain http only reaches this machine (`localhost`,
|
|
209
|
+
through `adb reverse`) or the emulator's host (`10.0.2.2`).
|
|
210
|
+
- An `<a href>` in a view is a touch target of its own; one inside a sentence
|
|
211
|
+
(`<p>… <a>…</a> …</p>`) is not pressable yet.
|
|
212
|
+
- React Native's `URL` resolves relative references wrongly; the app entry
|
|
213
|
+
installs a standard one (`installStandardUrl()` for an app wired by hand).
|
|
214
|
+
|
|
215
|
+
One connection to the server carries pages, comet calls and relay
|
|
216
|
+
subscriptions: `connectServer(origin)` gives `fetch` (that origin only, the
|
|
217
|
+
session cookie, the `XSRF-TOKEN` echoed on mutations), `json` (comet's
|
|
218
|
+
transport), `stream` (server-sent events over React Native's streaming XHR,
|
|
219
|
+
for `configureRelay({ stream, fetch })`) and `authorize(token)` (a Bearer
|
|
220
|
+
token on every request and stream). Pass it as `serverPages({ server })`.
|
|
221
|
+
|
|
222
|
+
## Long lists
|
|
223
|
+
|
|
224
|
+
`each(items, key, render, { lazy: { estimate, overscan, from } })` builds only
|
|
225
|
+
the rows intersecting its scroll view's viewport, plus `overscan` dp on each
|
|
226
|
+
side, between two spacer views that stand for the others at their measured
|
|
227
|
+
heights (`estimate` for a row not shown yet). It picks its rows with aurora's
|
|
228
|
+
own window math, so a list behaves as on the web. On each scroll it records
|
|
229
|
+
the offset and picks the window once per frame; after each commit it reads
|
|
230
|
+
its rows' frames from the host, and when a measure corrects an estimate
|
|
231
|
+
above the viewport it scrolls the native view by the difference, so what is
|
|
232
|
+
on screen stays put. `from: 'end'` starts at the bottom and follows new rows
|
|
233
|
+
while the reader is there: a conversation.
|
|
234
|
+
|
|
235
|
+
On the maintainer's phone, a conversation of 10 000 messages of varying
|
|
236
|
+
length mounts in about 70 ms (30 messages: about 40 ms, the same rows built)
|
|
237
|
+
and scrolls without a dropped frame.
|
|
238
|
+
|
|
239
|
+
## Gestures
|
|
240
|
+
|
|
241
|
+
orbit-host recognizes gestures on the UI thread (`crates/orbit-host/src/gesture.rs`),
|
|
242
|
+
the way react-native-gesture-handler does for React Native: every touch goes
|
|
243
|
+
to Rust before any view, so the press feedback starts even while the JS
|
|
244
|
+
thread is busy, and JS receives the outcome when it can.
|
|
245
|
+
|
|
246
|
+
- `@click`: fires on release if the finger stayed within 10 dp and nothing
|
|
247
|
+
took the touch over. A ripple, masked by the view's rounded box, starts
|
|
248
|
+
where the finger is — at once, or after 100 ms inside a scroll view so a
|
|
249
|
+
scroll that starts on a row does not flash it.
|
|
250
|
+
- `@longpress`: after 500 ms held; the release then fires no click.
|
|
251
|
+
- `@pan`: once the finger moves past the slop, `{ phase, dx, dy, vx, vy }`
|
|
252
|
+
(dp, dp/s) on `start`, each `move`, and `end` or `cancel`.
|
|
253
|
+
- `@swipe`: a pan that ended at 500 dp/s or more, `{ direction, vx, vy }`.
|
|
254
|
+
|
|
255
|
+
Inside a scroll view a drag along its axis is the scroll view's; across it,
|
|
256
|
+
a pan or a swipe claims the touch and the scroll view gets a cancel. A
|
|
257
|
+
swipe started on a pressable row of a list scrolls it without selecting.
|
|
258
|
+
|
|
259
|
+
## Shadows and glass
|
|
260
|
+
|
|
261
|
+
A shadow is drawn the way browsers draw one: a blurred rounded rectangle
|
|
262
|
+
rendered once into a small alpha bitmap per radius and blur, then drawn as
|
|
263
|
+
nine slices around the box, so a list of shadowed cards costs bitmap draws,
|
|
264
|
+
not a blur per card per frame. It is painted outside the box only, so a
|
|
265
|
+
translucent view does not show its own shadow.
|
|
266
|
+
|
|
267
|
+
`backdrop-blur-*` blurs what the view's parent drew before it — its
|
|
268
|
+
background and earlier siblings, such as the list scrolling under a glass
|
|
269
|
+
header — recorded at a quarter of the size into a render node blurred by
|
|
270
|
+
`RenderEffect`. Content that is not an earlier sibling (an ancestor's
|
|
271
|
+
siblings) is not part of the backdrop.
|
|
272
|
+
|
|
273
|
+
Measured on the maintainer's phone (Adreno 610, 90 Hz) on the glass demo
|
|
274
|
+
while scrolling, against the same screen without effects: 15.5 ms per frame
|
|
275
|
+
against 13.0 (RenderThread 3.6 against 1.1 ms, GPU 9.5 against 10.1 ms) when
|
|
276
|
+
the RenderThread runs on a fast core; that screen does not hold 90 Hz
|
|
277
|
+
without effects either.
|
|
278
|
+
|
|
279
|
+
## Pieces
|
|
280
|
+
|
|
281
|
+
- `src/` — the JS side: the native node tree, the template mapping, the commit
|
|
282
|
+
protocol, motion values, colours. It imports nothing from React Native and is
|
|
283
|
+
tested in Node against a fake host (`tests/unit`).
|
|
284
|
+
- `crates/orbit-host` — the Rust host behind a C ABI: tree, taffy layout (React
|
|
285
|
+
Native's defaults: column, no shrink), text measured by the platform, diff
|
|
286
|
+
into mount operations, UI-thread motion.
|
|
287
|
+
- `android/` — the platform layer (Kotlin views whose frames come from Rust,
|
|
288
|
+
touch forwarding, the vsync tick) and the JSI module (`NativeOrbit.cpp`).
|
|
289
|
+
- `specs/NativeOrbit.ts` — the TurboModule spec React Native's codegen reads.
|
|
290
|
+
|
|
291
|
+
An app's entry calls `run` from `@c9up/orbit/react-native`, which registers
|
|
292
|
+
the app, gives orbit its native host and mounts the root component:
|
|
293
|
+
|
|
294
|
+
```ts
|
|
295
|
+
import { run } from "@c9up/orbit/react-native";
|
|
296
|
+
import { App } from "./App.js";
|
|
297
|
+
|
|
298
|
+
run(App);
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
`ream android:run` and `ream android:build` build such an app: orbit declares
|
|
302
|
+
its native parts in its package.json (`reamNative`: the Kotlin sources, the
|
|
303
|
+
CMake that links the JSI module and the Rust host, the C++ module to register,
|
|
304
|
+
the spec, the Rust crate), and ream wires them into the Android project it
|
|
305
|
+
generates and cross-compiles the Rust host for the phone. See the CLI's
|
|
306
|
+
"Mobile apps". An app wired by hand still can: run
|
|
307
|
+
`bash node_modules/@c9up/orbit/scripts/build-android.sh`, include
|
|
308
|
+
`android/orbit.cmake` in its native build, register `NativeOrbit` in its module
|
|
309
|
+
provider, and add the spec and the Kotlin sources to the app module. iOS is
|
|
310
|
+
not there yet.
|
|
311
|
+
|
|
312
|
+
## Requirements
|
|
313
|
+
|
|
314
|
+
`@c9up/aurora` 0.1.53 or later (its host-free `./core` and `./renderer`
|
|
315
|
+
entries), React Native 0.87 with the new architecture, Hermes.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Link orbit into a React Native app's native library (`appmodules`).
|
|
2
|
+
#
|
|
3
|
+
# include(${ORBIT_DIR}/android/orbit.cmake) # in the app's jni/CMakeLists.txt
|
|
4
|
+
# orbit_link(${CMAKE_PROJECT_NAME})
|
|
5
|
+
#
|
|
6
|
+
# and register the module in the app's OnLoad.cpp cxxModuleProvider:
|
|
7
|
+
# if (name == NativeOrbit::kModuleName) return std::make_shared<NativeOrbit>(jsInvoker);
|
|
8
|
+
#
|
|
9
|
+
# The TurboModule spec (specs/NativeOrbit.ts) must be in the app's codegen
|
|
10
|
+
# sources so `AppSpecsJSI.h` declares NativeOrbitCxxSpec. The Kotlin sources
|
|
11
|
+
# under android/src/main/java belong to the app module. `ream` will do all of
|
|
12
|
+
# this for an app once it builds mobile apps.
|
|
13
|
+
|
|
14
|
+
set(ORBIT_ANDROID_DIR ${CMAKE_CURRENT_LIST_DIR})
|
|
15
|
+
|
|
16
|
+
# `ream android:*` builds the Rust host into REAM_RUST_DIR/<abi>/; an app wired
|
|
17
|
+
# by hand runs scripts/build-android.sh, which writes android/libs/<abi>/.
|
|
18
|
+
if(DEFINED REAM_RUST_DIR)
|
|
19
|
+
set(ORBIT_HOST_LIB ${REAM_RUST_DIR}/${ANDROID_ABI}/liborbit_host.a)
|
|
20
|
+
else()
|
|
21
|
+
set(ORBIT_HOST_LIB ${ORBIT_ANDROID_DIR}/libs/${ANDROID_ABI}/liborbit_host.a)
|
|
22
|
+
endif()
|
|
23
|
+
|
|
24
|
+
function(orbit_link target)
|
|
25
|
+
target_sources(${target} PRIVATE ${ORBIT_ANDROID_DIR}/src/main/cpp/NativeOrbit.cpp)
|
|
26
|
+
target_include_directories(${target} PUBLIC ${ORBIT_ANDROID_DIR}/src/main/cpp)
|
|
27
|
+
add_library(orbit_host STATIC IMPORTED)
|
|
28
|
+
set_target_properties(orbit_host PROPERTIES
|
|
29
|
+
IMPORTED_LOCATION ${ORBIT_HOST_LIB})
|
|
30
|
+
target_link_libraries(${target} orbit_host)
|
|
31
|
+
endfunction()
|