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