@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/dist/url.js ADDED
@@ -0,0 +1,303 @@
1
+ /**
2
+ * A standard `URL` for the phone, installed when the platform's is not one.
3
+ *
4
+ * React Native's `URL` (0.87) parses with regular expressions: a relative
5
+ * reference is appended to the base (`new URL("/b", "https://h/a")` gives
6
+ * `https://h/a/b`), and `searchParams` is a copy that `search` never sees.
7
+ * photon's router — and any code an app shares with the browser — resolves
8
+ * links and builds queries through it. `installStandardUrl()` probes the
9
+ * global `URL` and, when it gets either wrong, puts this one in its place.
10
+ *
11
+ * Scope: hierarchical URLs (`http:`, `https:`, `ws:`, `wss:`, `file:`…)
12
+ * resolved as RFC 3986 says, parts read and written as WHATWG's `URL` does;
13
+ * an opaque one (`mailto:`, `tel:`, `blob:`) is kept as written.
14
+ */
15
+ import { E_ORBIT_INVALID_URL, E_ORBIT_OBJECT_URL_UNAVAILABLE, } from "./errors.js";
16
+ const SCHEME = /^([a-zA-Z][a-zA-Z\d+.-]*):/;
17
+ const DEFAULT_PORTS = {
18
+ "http:": "80",
19
+ "https:": "443",
20
+ "ws:": "80",
21
+ "wss:": "443",
22
+ "ftp:": "21",
23
+ };
24
+ const SPECIAL = new Set(["http:", "https:", "ws:", "wss:", "ftp:", "file:"]);
25
+ /** RFC 3986 §5.2.4. */
26
+ function removeDotSegments(path) {
27
+ const out = [];
28
+ const segments = path.split("/");
29
+ for (let i = 0; i < segments.length; i++) {
30
+ const segment = segments[i] ?? "";
31
+ const last = i === segments.length - 1;
32
+ if (segment === ".") {
33
+ if (last)
34
+ out.push("");
35
+ }
36
+ else if (segment === "..") {
37
+ if (out.length > 1)
38
+ out.pop();
39
+ if (last)
40
+ out.push("");
41
+ }
42
+ else {
43
+ out.push(segment);
44
+ }
45
+ }
46
+ const joined = out.join("/");
47
+ return joined.startsWith("/") ? joined : `/${joined}`;
48
+ }
49
+ function splitTail(rest) {
50
+ const hashAt = rest.indexOf("#");
51
+ const hash = hashAt >= 0 ? rest.slice(hashAt) : "";
52
+ const beforeHash = hashAt >= 0 ? rest.slice(0, hashAt) : rest;
53
+ const queryAt = beforeHash.indexOf("?");
54
+ const search = queryAt >= 0 ? beforeHash.slice(queryAt) : "";
55
+ const path = queryAt >= 0 ? beforeHash.slice(0, queryAt) : beforeHash;
56
+ return {
57
+ path,
58
+ search: search === "?" ? "" : search,
59
+ hash: hash === "#" ? "" : hash,
60
+ };
61
+ }
62
+ function parseAbsolute(input) {
63
+ const scheme = SCHEME.exec(input);
64
+ if (scheme === null)
65
+ return null;
66
+ const protocol = `${(scheme[1] ?? "").toLowerCase()}:`;
67
+ let rest = input.slice(scheme[0].length).replace(/\\/g, "/");
68
+ if (!SPECIAL.has(protocol) && !rest.startsWith("//")) {
69
+ return {
70
+ protocol,
71
+ username: "",
72
+ password: "",
73
+ hostname: "",
74
+ port: "",
75
+ pathname: rest,
76
+ search: "",
77
+ hash: "",
78
+ opaque: rest,
79
+ };
80
+ }
81
+ rest = rest.replace(/^\/*/, "");
82
+ const end = rest.search(/[/?#]/);
83
+ const authority = end >= 0 ? rest.slice(0, end) : rest;
84
+ const tail = splitTail(end >= 0 ? rest.slice(end) : "");
85
+ const at = authority.lastIndexOf("@");
86
+ const userInfo = at >= 0 ? authority.slice(0, at) : "";
87
+ const hostPort = at >= 0 ? authority.slice(at + 1) : authority;
88
+ const colon = userInfo.indexOf(":");
89
+ const portMatch = /:(\d*)$/.exec(hostPort);
90
+ const hostname = (portMatch ? hostPort.slice(0, portMatch.index) : hostPort).toLowerCase();
91
+ if (hostname === "" && protocol !== "file:")
92
+ return null;
93
+ const port = portMatch?.[1] ?? "";
94
+ return {
95
+ protocol,
96
+ username: colon >= 0 ? userInfo.slice(0, colon) : userInfo,
97
+ password: colon >= 0 ? userInfo.slice(colon + 1) : "",
98
+ hostname,
99
+ port: port === DEFAULT_PORTS[protocol] ? "" : port.replace(/^0+(?=\d)/, ""),
100
+ pathname: removeDotSegments(tail.path === "" ? "/" : tail.path),
101
+ search: tail.search,
102
+ hash: tail.hash,
103
+ opaque: null,
104
+ };
105
+ }
106
+ /** RFC 3986 §5.2.2: `reference` against an absolute `base`. */
107
+ function resolve(reference, base) {
108
+ const ref = reference.trim();
109
+ if (SCHEME.test(ref))
110
+ return parseAbsolute(ref);
111
+ if (base.opaque !== null)
112
+ return null;
113
+ if (ref.startsWith("//") || ref.startsWith("\\\\")) {
114
+ return parseAbsolute(`${base.protocol}${ref}`);
115
+ }
116
+ const tail = splitTail(ref.replace(/\\/g, "/"));
117
+ const next = { ...base, hash: tail.hash };
118
+ if (tail.path === "") {
119
+ if (tail.search !== "" || ref.includes("?"))
120
+ next.search = tail.search;
121
+ return next;
122
+ }
123
+ next.search = tail.search;
124
+ if (tail.path.startsWith("/")) {
125
+ next.pathname = removeDotSegments(tail.path);
126
+ }
127
+ else {
128
+ const dir = base.pathname.slice(0, base.pathname.lastIndexOf("/") + 1);
129
+ next.pathname = removeDotSegments(`${dir}${tail.path}`);
130
+ }
131
+ return next;
132
+ }
133
+ /** A query whose changes reach the URL it belongs to, as WHATWG's does. */
134
+ class LinkedSearchParams extends URLSearchParams {
135
+ #changed;
136
+ constructor(query, changed) {
137
+ super(query);
138
+ this.#changed = changed;
139
+ }
140
+ append(name, value) {
141
+ super.append(name, value);
142
+ this.#changed(this.toString());
143
+ }
144
+ delete(name) {
145
+ super.delete(name);
146
+ this.#changed(this.toString());
147
+ }
148
+ set(name, value) {
149
+ super.set(name, value);
150
+ this.#changed(this.toString());
151
+ }
152
+ sort() {
153
+ super.sort();
154
+ this.#changed(this.toString());
155
+ }
156
+ }
157
+ let platformUrl;
158
+ export class StandardURL {
159
+ #parts;
160
+ #query = null;
161
+ static createObjectURL(blob) {
162
+ if (platformUrl === undefined)
163
+ throw new E_ORBIT_OBJECT_URL_UNAVAILABLE("URL.createObjectURL is not available");
164
+ return platformUrl.createObjectURL(blob);
165
+ }
166
+ static revokeObjectURL(url) {
167
+ platformUrl?.revokeObjectURL(url);
168
+ }
169
+ static canParse(url, base) {
170
+ try {
171
+ new StandardURL(url, base);
172
+ return true;
173
+ }
174
+ catch {
175
+ return false;
176
+ }
177
+ }
178
+ constructor(url, base) {
179
+ const input = String(url);
180
+ let parts;
181
+ if (base === undefined) {
182
+ parts = parseAbsolute(input.trim());
183
+ }
184
+ else {
185
+ const from = base instanceof StandardURL
186
+ ? base.#parts
187
+ : parseAbsolute(String(base).trim());
188
+ if (from === null)
189
+ throw new E_ORBIT_INVALID_URL(`Invalid base URL: ${String(base)}`);
190
+ parts = resolve(input, from);
191
+ }
192
+ if (parts === null)
193
+ throw new E_ORBIT_INVALID_URL(`Invalid URL: ${input}`);
194
+ this.#parts = parts;
195
+ }
196
+ get protocol() {
197
+ return this.#parts.protocol;
198
+ }
199
+ get username() {
200
+ return this.#parts.username;
201
+ }
202
+ get password() {
203
+ return this.#parts.password;
204
+ }
205
+ get hostname() {
206
+ return this.#parts.hostname;
207
+ }
208
+ get port() {
209
+ return this.#parts.port;
210
+ }
211
+ get host() {
212
+ const { hostname, port } = this.#parts;
213
+ return port === "" ? hostname : `${hostname}:${port}`;
214
+ }
215
+ get origin() {
216
+ const { protocol, opaque } = this.#parts;
217
+ if (opaque !== null || protocol === "file:")
218
+ return "null";
219
+ return `${protocol}//${this.host}`;
220
+ }
221
+ get pathname() {
222
+ return this.#parts.pathname;
223
+ }
224
+ set pathname(value) {
225
+ if (this.#parts.opaque !== null)
226
+ return;
227
+ this.#parts.pathname = removeDotSegments(value.startsWith("/") ? value : `/${value}`);
228
+ }
229
+ get search() {
230
+ return this.#parts.search;
231
+ }
232
+ set search(value) {
233
+ const query = value.startsWith("?") ? value.slice(1) : value;
234
+ this.#parts.search = query === "" ? "" : `?${query}`;
235
+ this.#query = null;
236
+ }
237
+ get hash() {
238
+ return this.#parts.hash;
239
+ }
240
+ set hash(value) {
241
+ const fragment = value.startsWith("#") ? value.slice(1) : value;
242
+ this.#parts.hash = fragment === "" ? "" : `#${fragment}`;
243
+ }
244
+ get searchParams() {
245
+ if (this.#query === null) {
246
+ this.#query = new LinkedSearchParams(this.#parts.search, (query) => {
247
+ this.#parts.search = query === "" ? "" : `?${query}`;
248
+ });
249
+ }
250
+ return this.#query;
251
+ }
252
+ get href() {
253
+ const { protocol, username, password, opaque, pathname, search, hash } = this.#parts;
254
+ if (opaque !== null)
255
+ return `${protocol}${opaque}`;
256
+ const credentials = username === "" && password === ""
257
+ ? ""
258
+ : `${username}${password === "" ? "" : `:${password}`}@`;
259
+ return `${protocol}//${credentials}${this.host}${pathname}${search}${hash}`;
260
+ }
261
+ toString() {
262
+ return this.href;
263
+ }
264
+ toJSON() {
265
+ return this.href;
266
+ }
267
+ }
268
+ /** Whether `Url` resolves references and links its query as the standard says. */
269
+ function isStandard(Url) {
270
+ try {
271
+ if (new Url("/b?x=1", "https://h.test/a/c").href !== "https://h.test/b?x=1") {
272
+ return false;
273
+ }
274
+ if (new Url("../d", "https://h.test/a/b/c").href !== "https://h.test/a/d") {
275
+ return false;
276
+ }
277
+ const url = new Url("https://h.test/");
278
+ url.searchParams.append("q", "1");
279
+ return url.search === "?q=1";
280
+ }
281
+ catch {
282
+ return false;
283
+ }
284
+ }
285
+ /**
286
+ * Put a standard `URL` in place of the platform's when the platform's is not
287
+ * one; true when it did. The platform's `createObjectURL` (blobs) stays
288
+ * reachable through the new one.
289
+ */
290
+ export function installStandardUrl() {
291
+ const current = Reflect.get(globalThis, "URL");
292
+ if (typeof current !== "function") {
293
+ Reflect.set(globalThis, "URL", StandardURL);
294
+ return true;
295
+ }
296
+ const platform = Reflect.get(globalThis, "URL");
297
+ if (isStandard(platform))
298
+ return false;
299
+ platformUrl = platform;
300
+ Reflect.set(globalThis, "URL", StandardURL);
301
+ return true;
302
+ }
303
+ //# sourceMappingURL=url.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url.js","sourceRoot":"","sources":["../src/url.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACN,mBAAmB,EACnB,8BAA8B,GAC9B,MAAM,aAAa,CAAC;AAErB,MAAM,MAAM,GAAG,4BAA4B,CAAC;AAC5C,MAAM,aAAa,GAAiC;IACnD,OAAO,EAAE,IAAI;IACb,QAAQ,EAAE,KAAK;IACf,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,KAAK;IACb,MAAM,EAAE,IAAI;CACZ,CAAC;AACF,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAe7E,uBAAuB;AACvB,SAAS,iBAAiB,CAAC,IAAY;IACtC,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC1C,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAClC,MAAM,IAAI,GAAG,CAAC,KAAK,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;QACvC,IAAI,OAAO,KAAK,GAAG,EAAE,CAAC;YACrB,IAAI,IAAI;gBAAE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACxB,CAA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,GAAG,GAAG,IAAI,GAAG,CAAC,iBAAiB,CAAC,CAAC;QACvC,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QAClC,OAAO,GAAG,CAAC,MAAM,KAAK,MAAM,CAAC;IAC9B,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,KAAK,CAAC;IACd,CAAC;AACF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB;IACjC,MAAM,OAAO,GAAY,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IACxD,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;QACnC,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;QAC5C,OAAO,IAAI,CAAC;IACb,CAAC;IACD,MAAM,QAAQ,GAAgB,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;IAC7D,IAAI,UAAU,CAAC,QAAQ,CAAC;QAAE,OAAO,KAAK,CAAC;IACvC,WAAW,GAAG,QAAQ,CAAC;IACvB,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC;IAC5C,OAAO,IAAI,CAAC;AACb,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,99 @@
1
1
  {
2
2
  "name": "@c9up/orbit",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.1",
4
+ "description": "Orbit — aurora components as native views on a phone, laid out and diffed by a Rust host",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/C9up/orbit.git"
9
+ },
10
+ "type": "module",
11
+ "main": "./dist/index.js",
12
+ "types": "./dist/index.d.ts",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js",
17
+ "default": "./dist/index.js"
18
+ },
19
+ "./react-native": {
20
+ "types": "./dist/react-native/index.d.ts",
21
+ "import": "./dist/react-native/index.js",
22
+ "default": "./dist/react-native/index.js"
23
+ },
24
+ "./pages": {
25
+ "types": "./dist/pages.d.ts",
26
+ "import": "./dist/pages.js",
27
+ "default": "./dist/pages.js"
28
+ }
29
+ },
30
+ "peerDependencies": {
31
+ "@c9up/aurora": "^0.1.53",
32
+ "@c9up/photon": "^0.1.25"
33
+ },
34
+ "dependencies": {
35
+ "@c9up/flare": "^0.1.0"
36
+ },
37
+ "devDependencies": {
38
+ "@biomejs/biome": "^2.6.8",
39
+ "@c9up/aurora": "^0.1.53",
40
+ "@c9up/photon": "^0.1.25",
41
+ "@tailwindcss/cli": "^4.3.3",
42
+ "@vitest/coverage-v8": "4.1.12",
43
+ "tailwindcss": "^4.3.3",
44
+ "typescript": "^6.0.3",
45
+ "vitest": "4.1.12"
46
+ },
47
+ "files": [
48
+ "src",
49
+ "dist",
50
+ "specs",
51
+ "scripts",
52
+ "Cargo.toml",
53
+ "Cargo.lock",
54
+ "crates/orbit-host/src",
55
+ "crates/orbit-host/Cargo.toml",
56
+ "android/orbit.cmake",
57
+ "android/src",
58
+ "README.md",
59
+ "LICENSE"
60
+ ],
61
+ "reamNative": {
62
+ "specs": "specs",
63
+ "rust": [
64
+ {
65
+ "manifest": "crates/orbit-host/Cargo.toml",
66
+ "lib": "orbit_host"
67
+ }
68
+ ],
69
+ "android": {
70
+ "java": "android/src/main/java",
71
+ "cmake": {
72
+ "file": "android/orbit.cmake",
73
+ "link": "orbit_link"
74
+ },
75
+ "cxxModules": [
76
+ {
77
+ "name": "NativeOrbit",
78
+ "header": "NativeOrbit.h"
79
+ }
80
+ ]
81
+ }
82
+ },
83
+ "publishConfig": {
84
+ "access": "public"
85
+ },
86
+ "peerDependenciesMeta": {
87
+ "@c9up/photon": {
88
+ "optional": true
89
+ }
90
+ },
91
+ "scripts": {
92
+ "build": "tsc -p tsconfig.build.json",
93
+ "test": "vitest run",
94
+ "test:rust": "cargo test --manifest-path crates/orbit-host/Cargo.toml",
95
+ "lint": "biome check src/ tests/",
96
+ "test:coverage": "vitest run --coverage",
97
+ "typecheck": "tsc --noEmit -p ."
98
+ }
6
99
  }
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env bash
2
+ # Builds orbit-host as a static library per Android ABI into
3
+ # android/libs/<abi>/liborbit_host.a, which the app's native library links
4
+ # (see android/orbit.cmake). Until `ream` builds mobile apps, an app runs
5
+ # this before its Gradle build.
6
+ set -euo pipefail
7
+
8
+ HERE="$(cd "$(dirname "$0")/.." && pwd)"
9
+ NDK="${ANDROID_NDK_HOME:-$HOME/Android/Sdk/ndk/27.1.12297006}"
10
+ API=24
11
+ BIN="$NDK/toolchains/llvm/prebuilt/linux-x86_64/bin"
12
+ CARGO="${CARGO:-cargo}"
13
+ export CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-$HERE/target}"
14
+ ABIS="${ABIS:-arm64-v8a x86_64}"
15
+
16
+ declare -A TRIPLES=([x86_64]=x86_64-linux-android [arm64-v8a]=aarch64-linux-android)
17
+
18
+ for abi in $ABIS; do
19
+ triple="${TRIPLES[$abi]}"
20
+ env_triple="$(echo "$triple" | tr 'a-z-' 'A-Z_')"
21
+ export "CARGO_TARGET_${env_triple}_LINKER=$BIN/${triple}${API}-clang"
22
+ export "CC_${triple//-/_}=$BIN/${triple}${API}-clang"
23
+ export "AR_${triple//-/_}=$BIN/llvm-ar"
24
+ "$CARGO" build --release --manifest-path "$HERE/crates/orbit-host/Cargo.toml" --target "$triple"
25
+ mkdir -p "$HERE/android/libs/$abi"
26
+ cp "$CARGO_TARGET_DIR/$triple/release/liborbit_host.a" "$HERE/android/libs/$abi/"
27
+ done
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Rebuild the style table orbit's unit tests use: Tailwind over the tests
3
+ * (tests/styles/app.css), then `ream css:compile`, as `ream android:*` does
4
+ * for an app. Run after adding a class to a test.
5
+ *
6
+ * node scripts/test-styles.mjs # `ream` from PATH
7
+ * REAM=/path/to/ream node scripts/test-styles.mjs
8
+ */
9
+ import { execFileSync } from "node:child_process";
10
+ import { mkdtempSync, rmSync } from "node:fs";
11
+ import { tmpdir } from "node:os";
12
+ import { dirname, join } from "node:path";
13
+ import { fileURLToPath } from "node:url";
14
+
15
+ const root = join(dirname(fileURLToPath(import.meta.url)), "..");
16
+ const scratch = mkdtempSync(join(tmpdir(), "orbit-styles-"));
17
+ const css = join(scratch, "app.css");
18
+ try {
19
+ execFileSync(
20
+ join(root, "node_modules", ".bin", "tailwindcss"),
21
+ ["-i", join(root, "tests", "styles", "app.css"), "-o", css],
22
+ { stdio: "inherit", cwd: root },
23
+ );
24
+ execFileSync(
25
+ process.env.REAM ?? "ream",
26
+ ["css:compile", css, "-o", join(root, "tests", "styles", "table.json")],
27
+ { stdio: "inherit" },
28
+ );
29
+ } finally {
30
+ rmSync(scratch, { recursive: true, force: true });
31
+ }
@@ -0,0 +1,34 @@
1
+ import type {TurboModule} from 'react-native';
2
+ import {TurboModuleRegistry} from 'react-native';
3
+
4
+ /** orbit's Rust native host (orbit-host), over JSI. Mirrors `OrbitHost` in src/host.ts. */
5
+ export interface Spec extends TurboModule {
6
+ /** The root's size in dp. */
7
+ readonly setViewport: (width: number, height: number) => void;
8
+ /** Commit a JSON batch of tree ops; returns the host's JSON report. */
9
+ readonly commit: (ops: string) => string;
10
+ /** An image node's bytes (a Uint8Array or ArrayBuffer), held in memory until the node goes. */
11
+ readonly imageBytes: (tag: number, bytes: Object) => void;
12
+ /** Where nodes were laid out: a JSON array of tags in, of [x, y, w, h] (dp) or null out. */
13
+ readonly layout: (tags: string) => string;
14
+ /** Scroll a scroll view by `by` dp, or to its end. */
15
+ readonly scroll: (tag: number, by: number, toEnd: boolean) => void;
16
+ /** Touches on host views, as React Native's touch event types, in dp. */
17
+ /** Touches (dp), text-field events with their text in `data`, `topViewport` on tag 0 (window resized). */
18
+ readonly setEventHandler: (handler: (tag: number, type: string, x: number, y: number, data: string) => void) => void;
19
+
20
+ // UI-thread animation, driven by orbit-host on every vsync (no JS per frame).
21
+ readonly motionValue: (tag: number, initial: number) => void;
22
+ readonly motionInterpolate: (tag: number, input: number, from: ReadonlyArray<number>, to: ReadonlyArray<number>) => void;
23
+ readonly motionSet: (tag: number, value: number) => void;
24
+ readonly motionStop: (tag: number) => void;
25
+ readonly motionFrames: (tag: number, frames: ReadonlyArray<number>, to: number, loop: boolean) => void;
26
+ readonly motionSpring: (tag: number, to: number, stiffness: number, damping: number, mass: number) => void;
27
+ /** Forget a motion value or interpolation, its animation and its bindings. */
28
+ readonly motionDispose: (tag: number) => void;
29
+ /** prop: 0 opacity, 1 translateX, 2 translateY, 3 scale, 4 visible (> 0.5). */
30
+ readonly motionBind: (view: number, prop: number, node: number) => void;
31
+ readonly motionBindScroll: (scrollView: number, value: number) => void;
32
+ }
33
+
34
+ export default TurboModuleRegistry.getEnforcing<Spec>('NativeOrbit');
package/src/color.ts ADDED
@@ -0,0 +1,68 @@
1
+ import type { Exception } from "@c9up/flare";
2
+ import { E_ORBIT_INVALID_COLOR } from "./errors.js";
3
+
4
+ /**
5
+ * A CSS colour as the 32-bit ARGB integer the native host reads (signed, as
6
+ * Android's `Color` int), without React Native's `processColor`: the core of
7
+ * orbit runs and is tested without React Native.
8
+ *
9
+ * Reads `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`, `rgb()` / `rgba()` with
10
+ * comma or space syntax, and `transparent`.
11
+ */
12
+ export function colorToArgb(css: string): number {
13
+ const value = css.trim().toLowerCase();
14
+ if (value === "transparent") return 0;
15
+ if (value.startsWith("#")) return fromHex(value.slice(1), css);
16
+ const fn = /^rgba?\(\s*([^)]+)\)$/.exec(value);
17
+ if (fn) return fromRgb(fn[1] ?? "", css);
18
+ throw new E_ORBIT_INVALID_COLOR([css]);
19
+ }
20
+
21
+ function pack(r: number, g: number, b: number, a: number): number {
22
+ const byte = (n: number) => Math.max(0, Math.min(255, Math.round(n)));
23
+ return (byte(a) << 24) | (byte(r) << 16) | (byte(g) << 8) | byte(b) | 0;
24
+ }
25
+
26
+ function fromHex(hex: string, css: string): number {
27
+ if (!/^[0-9a-f]+$/.test(hex)) throw invalid(css);
28
+ const at = (i: number, len: number) =>
29
+ Number.parseInt(
30
+ len === 1 ? hex.charAt(i).repeat(2) : hex.slice(i, i + 2),
31
+ 16,
32
+ );
33
+ switch (hex.length) {
34
+ case 3:
35
+ return pack(at(0, 1), at(1, 1), at(2, 1), 255);
36
+ case 4:
37
+ return pack(at(0, 1), at(1, 1), at(2, 1), at(3, 1));
38
+ case 6:
39
+ return pack(at(0, 2), at(2, 2), at(4, 2), 255);
40
+ case 8:
41
+ return pack(at(0, 2), at(2, 2), at(4, 2), at(6, 2));
42
+ default:
43
+ throw invalid(css);
44
+ }
45
+ }
46
+
47
+ function fromRgb(args: string, css: string): number {
48
+ const parts = args.split(/[\s,/]+/).filter(Boolean);
49
+ if (parts.length !== 3 && parts.length !== 4) throw invalid(css);
50
+ const channel = (p: string) =>
51
+ p.endsWith("%") ? (Number.parseFloat(p) * 255) / 100 : Number.parseFloat(p);
52
+ const alpha = (p: string | undefined) => {
53
+ if (p === undefined) return 255;
54
+ return (
55
+ (p.endsWith("%") ? Number.parseFloat(p) / 100 : Number.parseFloat(p)) *
56
+ 255
57
+ );
58
+ };
59
+ const [r, g, b] = parts.map(channel);
60
+ const a = alpha(parts[3]);
61
+ if ([r, g, b, a].some((n) => n === undefined || Number.isNaN(n)))
62
+ throw invalid(css);
63
+ return pack(r ?? 0, g ?? 0, b ?? 0, a);
64
+ }
65
+
66
+ function invalid(css: string): Exception {
67
+ return new E_ORBIT_INVALID_COLOR([css]);
68
+ }