@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
@@ -0,0 +1,10 @@
1
+ /**
2
+ * A CSS colour as the 32-bit ARGB integer the native host reads (signed, as
3
+ * Android's `Color` int), without React Native's `processColor`: the core of
4
+ * orbit runs and is tested without React Native.
5
+ *
6
+ * Reads `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`, `rgb()` / `rgba()` with
7
+ * comma or space syntax, and `transparent`.
8
+ */
9
+ export declare function colorToArgb(css: string): number;
10
+ //# sourceMappingURL=color.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../src/color.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAO/C"}
package/dist/color.js ADDED
@@ -0,0 +1,62 @@
1
+ import { E_ORBIT_INVALID_COLOR } from "./errors.js";
2
+ /**
3
+ * A CSS colour as the 32-bit ARGB integer the native host reads (signed, as
4
+ * Android's `Color` int), without React Native's `processColor`: the core of
5
+ * orbit runs and is tested without React Native.
6
+ *
7
+ * Reads `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`, `rgb()` / `rgba()` with
8
+ * comma or space syntax, and `transparent`.
9
+ */
10
+ export function colorToArgb(css) {
11
+ const value = css.trim().toLowerCase();
12
+ if (value === "transparent")
13
+ return 0;
14
+ if (value.startsWith("#"))
15
+ return fromHex(value.slice(1), css);
16
+ const fn = /^rgba?\(\s*([^)]+)\)$/.exec(value);
17
+ if (fn)
18
+ return fromRgb(fn[1] ?? "", css);
19
+ throw new E_ORBIT_INVALID_COLOR([css]);
20
+ }
21
+ function pack(r, g, b, a) {
22
+ const byte = (n) => 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
+ function fromHex(hex, css) {
26
+ if (!/^[0-9a-f]+$/.test(hex))
27
+ throw invalid(css);
28
+ const at = (i, len) => Number.parseInt(len === 1 ? hex.charAt(i).repeat(2) : hex.slice(i, i + 2), 16);
29
+ switch (hex.length) {
30
+ case 3:
31
+ return pack(at(0, 1), at(1, 1), at(2, 1), 255);
32
+ case 4:
33
+ return pack(at(0, 1), at(1, 1), at(2, 1), at(3, 1));
34
+ case 6:
35
+ return pack(at(0, 2), at(2, 2), at(4, 2), 255);
36
+ case 8:
37
+ return pack(at(0, 2), at(2, 2), at(4, 2), at(6, 2));
38
+ default:
39
+ throw invalid(css);
40
+ }
41
+ }
42
+ function fromRgb(args, css) {
43
+ const parts = args.split(/[\s,/]+/).filter(Boolean);
44
+ if (parts.length !== 3 && parts.length !== 4)
45
+ throw invalid(css);
46
+ const channel = (p) => p.endsWith("%") ? (Number.parseFloat(p) * 255) / 100 : Number.parseFloat(p);
47
+ const alpha = (p) => {
48
+ if (p === undefined)
49
+ return 255;
50
+ return ((p.endsWith("%") ? Number.parseFloat(p) / 100 : Number.parseFloat(p)) *
51
+ 255);
52
+ };
53
+ const [r, g, b] = parts.map(channel);
54
+ const a = alpha(parts[3]);
55
+ if ([r, g, b, a].some((n) => n === undefined || Number.isNaN(n)))
56
+ throw invalid(css);
57
+ return pack(r ?? 0, g ?? 0, b ?? 0, a);
58
+ }
59
+ function invalid(css) {
60
+ return new E_ORBIT_INVALID_COLOR([css]);
61
+ }
62
+ //# sourceMappingURL=color.js.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QAC/D,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;IACpB,OAAO,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;AACxC,CAAC;AAED,SAAS,OAAO,CAAC,GAAW;IAC3B,OAAO,IAAI,qBAAqB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AACzC,CAAC"}
@@ -0,0 +1,77 @@
1
+ import { type OrbitHost } from "./host.js";
2
+ import { type NativeNode } from "./node.js";
3
+ import { type ErrorListener } from "./report.js";
4
+ /**
5
+ * Committing the JS tree to the Rust host: one JSON batch per commit over JSI
6
+ * (create, props patch, children, root). Layout, diffing and mounting happen in
7
+ * Rust and on the platform side. Commits are batched to a microtask, so many
8
+ * signal writes in one turn cost one commit.
9
+ */
10
+ export interface OrbitReport {
11
+ deleted: number[];
12
+ parseUs: number;
13
+ layoutUs: number;
14
+ diffUs: number;
15
+ measures: number;
16
+ nodes: number;
17
+ opsBytes: number;
18
+ /** What the host left out of the drawings of this commit, coded (`E_ORBIT_SVG_VALUE: …`). */
19
+ warnings?: string[];
20
+ }
21
+ /**
22
+ * `text` with every unpaired surrogate replaced by U+FFFD, as
23
+ * `String.prototype.toWellFormed` does (Hermes has none). Half an emoji is
24
+ * ordinary content — `"Ana😀".slice(0, 4)` — and a browser shows it as U+FFFD.
25
+ */
26
+ export declare function toWellFormed(text: string): string;
27
+ /**
28
+ * The batch as JSON the host reads. `JSON.stringify` writes an unpaired
29
+ * surrogate as a `\ud…` escape (lower-case, per ECMA-262 and Hermes), which
30
+ * the host's strict JSON reader refuses: one cut emoji would fail the whole
31
+ * commit. Only a batch holding such an escape pays for the second pass.
32
+ */
33
+ export declare function serialise(ops: readonly unknown[]): string;
34
+ /** Run `listener` after every commit; returns what stops it. */
35
+ export declare function onEveryCommit(listener: () => void): () => void;
36
+ /** The host the mounted tree commits to (layout reads, scrolling). */
37
+ export declare function treeHost(): OrbitHost;
38
+ /** Run `hook` once the next commit has reached the host (aurora's onMount timing). */
39
+ export declare function afterCommit(hook: () => void): void;
40
+ export declare class Root {
41
+ #private;
42
+ /** Every commit's report, newest last (development and benchmarks). */
43
+ readonly reports: OrbitReport[];
44
+ constructor(host: OrbitHost, tree: NativeNode);
45
+ schedule(): void;
46
+ /** Commit what changed now, instead of at the end of the turn. */
47
+ flush(): OrbitReport;
48
+ /**
49
+ * A commit nobody waits on (scheduled, or after the window resized): a
50
+ * refusal goes to `mount`'s `onError` instead of out of a microtask or a
51
+ * native event. What the batch carried is sent again with the next commit.
52
+ */
53
+ commitOrReport(): void;
54
+ commit(): OrbitReport;
55
+ }
56
+ export interface MountOptions {
57
+ /** The root's size in dp (React Native: `Dimensions.get("window")`). */
58
+ viewport: {
59
+ width: number;
60
+ height: number;
61
+ };
62
+ /** Defaults to the host given to `useHost`. */
63
+ host?: OrbitHost;
64
+ /**
65
+ * Told of what orbit recovered from instead of throwing: a scheduled
66
+ * commit the host refused (`E_ORBIT_COMMIT_FAILED`, `E_ORBIT_TREE_TOO_DEEP`;
67
+ * the batch is sent again with the next commit), an image address from data
68
+ * orbit will not load (`E_ORBIT_INSECURE_IMAGE_URL`, `E_ORBIT_IMAGE_SOURCE`;
69
+ * that image shows nothing), a value of a drawing the host left out
70
+ * (`E_ORBIT_SVG_VALUE`). Default: `console.warn` in a development build
71
+ * (`__DEV__`), nothing in production.
72
+ */
73
+ onError?: ErrorListener;
74
+ }
75
+ /** Mount a native tree; returns its root (`flush()` commits synchronously). */
76
+ export declare function mountTree(tree: NativeNode, options: MountOptions): Root;
77
+ //# sourceMappingURL=commit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commit.d.ts","sourceRoot":"","sources":["../src/commit.ts"],"names":[],"mappings":"AAKA,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,KAAK,UAAU,EAAgC,MAAM,WAAW,CAAC;AAC1E,OAAO,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;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC;CACxB;AAED,+EAA+E;AAC/E,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI,CAkCvE"}
package/dist/commit.js ADDED
@@ -0,0 +1,302 @@
1
+ import { E_ORBIT_COMMIT_FAILED, E_ORBIT_SVG_VALUE, E_ORBIT_TREE_TOO_DEEP, } from "./errors.js";
2
+ import { currentHost } from "./host.js";
3
+ import { setDirtyListener } from "./node.js";
4
+ import { report } from "./report.js";
5
+ import { viewportSize } from "./styles.js";
6
+ function isReport(value) {
7
+ return (typeof value === "object" &&
8
+ value !== null &&
9
+ Array.isArray(Reflect.get(value, "deleted")));
10
+ }
11
+ /** The codes the host prefixes its messages with, as the errors orbit throws. */
12
+ const HOST_CODES = {
13
+ E_ORBIT_TREE_TOO_DEEP,
14
+ E_ORBIT_SVG_VALUE,
15
+ };
16
+ /** A coded host message (`E_ORBIT_X: what happened`) as orbit's error for it. */
17
+ function hostError(message, cause) {
18
+ const at = message.indexOf(": ");
19
+ const code = at < 0 ? "" : message.slice(0, at);
20
+ for (const [name, ErrorClass] of Object.entries(HOST_CODES)) {
21
+ if (name === code)
22
+ return new ErrorClass([message.slice(at + 2)], { cause });
23
+ }
24
+ return null;
25
+ }
26
+ /**
27
+ * Why the host refused a commit: its `{ "error": … }` report, thrown by the
28
+ * native module as the message of a JS error (or returned, by a host that
29
+ * does not throw).
30
+ */
31
+ function refusal(answer, cause) {
32
+ let detail = answer;
33
+ if (typeof answer === "string") {
34
+ try {
35
+ detail = JSON.parse(answer);
36
+ }
37
+ catch {
38
+ detail = answer;
39
+ }
40
+ }
41
+ const message = typeof detail === "object" && detail !== null
42
+ ? Reflect.get(detail, "error")
43
+ : undefined;
44
+ if (typeof message === "string") {
45
+ const coded = hostError(message, cause);
46
+ if (coded)
47
+ return coded;
48
+ }
49
+ return new E_ORBIT_COMMIT_FAILED([detail], { cause });
50
+ }
51
+ /**
52
+ * `text` with every unpaired surrogate replaced by U+FFFD, as
53
+ * `String.prototype.toWellFormed` does (Hermes has none). Half an emoji is
54
+ * ordinary content — `"Ana😀".slice(0, 4)` — and a browser shows it as U+FFFD.
55
+ */
56
+ export function toWellFormed(text) {
57
+ let out = "";
58
+ let from = 0;
59
+ for (let i = 0; i < text.length; i++) {
60
+ const unit = text.charCodeAt(i);
61
+ if (unit < 0xd800 || unit > 0xdfff)
62
+ continue;
63
+ if (unit <= 0xdbff && i + 1 < text.length) {
64
+ const next = text.charCodeAt(i + 1);
65
+ if (next >= 0xdc00 && next <= 0xdfff) {
66
+ i += 1;
67
+ continue;
68
+ }
69
+ }
70
+ out += `${text.slice(from, i)}\ufffd`;
71
+ from = i + 1;
72
+ }
73
+ return from === 0 ? text : out + text.slice(from);
74
+ }
75
+ const wellFormed = (_key, value) => typeof value === "string" ? toWellFormed(value) : value;
76
+ /**
77
+ * The batch as JSON the host reads. `JSON.stringify` writes an unpaired
78
+ * surrogate as a `\ud…` escape (lower-case, per ECMA-262 and Hermes), which
79
+ * the host's strict JSON reader refuses: one cut emoji would fail the whole
80
+ * commit. Only a batch holding such an escape pays for the second pass.
81
+ */
82
+ export function serialise(ops) {
83
+ const json = JSON.stringify(ops);
84
+ return json.includes("\\ud") ? JSON.stringify(ops, wellFormed) : json;
85
+ }
86
+ const created = new WeakSet();
87
+ const byTag = new Map();
88
+ const lastChildren = new WeakMap();
89
+ const afterCommitHooks = [];
90
+ const commitListeners = new Set();
91
+ let mountedHost = null;
92
+ /** Run `listener` after every commit; returns what stops it. */
93
+ export function onEveryCommit(listener) {
94
+ commitListeners.add(listener);
95
+ return () => commitListeners.delete(listener);
96
+ }
97
+ /** The host the mounted tree commits to (layout reads, scrolling). */
98
+ export function treeHost() {
99
+ return mountedHost ?? currentHost();
100
+ }
101
+ /** Run `hook` once the next commit has reached the host (aurora's onMount timing). */
102
+ export function afterCommit(hook) {
103
+ afterCommitHooks.push(hook);
104
+ }
105
+ function sameTags(a, b) {
106
+ if (!a || a.length !== b.length)
107
+ return false;
108
+ for (let i = 0; i < a.length; i++)
109
+ if (a[i] !== b[i])
110
+ return false;
111
+ return true;
112
+ }
113
+ // Only nodes the commit reaches hand their bytes over: the host drops them
114
+ // with the node, so bytes of a node it never saw would stay behind.
115
+ function takeBytes(node, bytes) {
116
+ if (node.pendingBytes) {
117
+ bytes.push([node.tag, node.pendingBytes]);
118
+ node.pendingBytes = null;
119
+ }
120
+ }
121
+ function visit(node, ops, bytes, sent) {
122
+ takeBytes(node, bytes);
123
+ if (!created.has(node)) {
124
+ ops.push(["c", node.tag, node.viewName, node.props]);
125
+ created.add(node);
126
+ byTag.set(node.tag, node);
127
+ sent.created.push(node);
128
+ node.pendingProps = null;
129
+ const kids = node.flatChildren();
130
+ for (const kid of kids)
131
+ visit(kid, ops, bytes, sent);
132
+ const tags = kids.map((kid) => kid.tag);
133
+ if (tags.length > 0)
134
+ ops.push(["k", node.tag, tags]);
135
+ lastChildren.set(node, tags);
136
+ node.childrenDirty = false;
137
+ return;
138
+ }
139
+ if (node.pendingProps) {
140
+ ops.push(["u", node.tag, node.pendingProps]);
141
+ sent.patched.push([node, node.pendingProps]);
142
+ node.pendingProps = null;
143
+ }
144
+ if (node.childrenDirty) {
145
+ sent.walked.push(node);
146
+ const kids = node.flatChildren();
147
+ for (const kid of kids)
148
+ visit(kid, ops, bytes, sent);
149
+ const tags = kids.map((kid) => kid.tag);
150
+ if (!sameTags(lastChildren.get(node), tags)) {
151
+ ops.push(["k", node.tag, tags]);
152
+ lastChildren.set(node, tags);
153
+ }
154
+ node.childrenDirty = false;
155
+ }
156
+ }
157
+ /**
158
+ * The host refused the batch: nothing it carried counts as applied. Created
159
+ * nodes are created again, patches sent again, and every children list the
160
+ * batch walked is sent again whole — the host may have applied part of the
161
+ * batch before it refused, so a list it holds is not known any more.
162
+ */
163
+ function unsend(sent) {
164
+ for (const node of sent.created) {
165
+ created.delete(node);
166
+ byTag.delete(node.tag);
167
+ lastChildren.delete(node);
168
+ node.childrenDirty = true;
169
+ }
170
+ for (const [node, patch] of sent.patched) {
171
+ node.pendingProps = node.pendingProps
172
+ ? Object.assign(patch, node.pendingProps)
173
+ : patch;
174
+ }
175
+ for (const node of sent.walked) {
176
+ lastChildren.delete(node);
177
+ node.childrenDirty = true;
178
+ }
179
+ }
180
+ export class Root {
181
+ #host;
182
+ #tree;
183
+ #scheduled = false;
184
+ #rootSent = false;
185
+ /** Every commit's report, newest last (development and benchmarks). */
186
+ reports = [];
187
+ constructor(host, tree) {
188
+ this.#host = host;
189
+ this.#tree = tree;
190
+ }
191
+ schedule() {
192
+ if (this.#scheduled)
193
+ return;
194
+ this.#scheduled = true;
195
+ void Promise.resolve().then(() => {
196
+ // A synchronous flush() may already have committed this batch.
197
+ if (this.#scheduled)
198
+ this.commitOrReport();
199
+ });
200
+ }
201
+ /** Commit what changed now, instead of at the end of the turn. */
202
+ flush() {
203
+ return this.commit();
204
+ }
205
+ /**
206
+ * A commit nobody waits on (scheduled, or after the window resized): a
207
+ * refusal goes to `mount`'s `onError` instead of out of a microtask or a
208
+ * native event. What the batch carried is sent again with the next commit.
209
+ */
210
+ commitOrReport() {
211
+ try {
212
+ this.commit();
213
+ }
214
+ catch (error) {
215
+ report(error instanceof Error
216
+ ? error
217
+ : new E_ORBIT_COMMIT_FAILED([String(error)]));
218
+ }
219
+ }
220
+ commit() {
221
+ this.#scheduled = false;
222
+ const ops = [];
223
+ const bytes = [];
224
+ const sent = { created: [], patched: [], walked: [] };
225
+ visit(this.#tree, ops, bytes, sent);
226
+ const rootSent = this.#rootSent;
227
+ if (!rootSent)
228
+ ops.push(["r", this.#tree.tag]);
229
+ // Before the ops that show them: the host reads them when it mounts.
230
+ // Bytes stay with the host once handed over, refused batch or not.
231
+ for (const [tag, data] of bytes)
232
+ this.#host.imageBytes(tag, data);
233
+ let answer;
234
+ try {
235
+ answer = JSON.parse(this.#host.commit(serialise(ops)));
236
+ }
237
+ catch (error) {
238
+ unsend(sent);
239
+ throw refusal(error instanceof Error ? error.message : error, error);
240
+ }
241
+ if (!isReport(answer)) {
242
+ unsend(sent);
243
+ throw refusal(answer);
244
+ }
245
+ this.#rootSent = true;
246
+ for (const tag of answer.deleted) {
247
+ const node = byTag.get(tag);
248
+ if (!node)
249
+ continue;
250
+ byTag.delete(tag);
251
+ created.delete(node);
252
+ lastChildren.delete(node);
253
+ }
254
+ for (const warning of answer.warnings ?? []) {
255
+ report(hostError(warning) ?? new E_ORBIT_SVG_VALUE([warning]));
256
+ }
257
+ this.reports.push(answer);
258
+ for (const hook of afterCommitHooks.splice(0))
259
+ hook();
260
+ for (const listener of [...commitListeners])
261
+ listener();
262
+ return answer;
263
+ }
264
+ }
265
+ /** Mount a native tree; returns its root (`flush()` commits synchronously). */
266
+ export function mountTree(tree, options) {
267
+ const host = options.host ?? currentHost();
268
+ const root = new Root(host, tree);
269
+ mountedHost = host;
270
+ setDirtyListener(() => root.schedule());
271
+ host.setViewport(options.viewport.width, options.viewport.height);
272
+ host.setEventHandler((tag, type, x, y, data) => {
273
+ if (type === "topScroll") {
274
+ for (const listener of byTag.get(tag)?.scrollListeners ?? [])
275
+ listener(y);
276
+ return;
277
+ }
278
+ if (type === "topViewport") {
279
+ // The window resized (the keyboard came or went): lay out again.
280
+ host.setViewport(x, y);
281
+ viewportSize({ width: x, height: y });
282
+ root.commitOrReport();
283
+ return;
284
+ }
285
+ const payload = {
286
+ pageX: x,
287
+ pageY: y,
288
+ locationX: x,
289
+ locationY: y,
290
+ text: data,
291
+ };
292
+ for (let node = byTag.get(tag) ?? null; node; node = node.parent) {
293
+ if (node.onEvent) {
294
+ node.onEvent(type, payload);
295
+ return;
296
+ }
297
+ }
298
+ });
299
+ root.commit();
300
+ return root;
301
+ }
302
+ //# sourceMappingURL=commit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commit.js","sourceRoot":"","sources":["../src/commit.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,qBAAqB,EACrB,i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CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YACvB,YAAY,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;YACtC,IAAI,CAAC,cAAc,EAAE,CAAC;YACtB,OAAO;QACR,CAAC;QACD,MAAM,OAAO,GAAG;YACf,KAAK,EAAE,CAAC;YACR,KAAK,EAAE,CAAC;YACR,SAAS,EAAE,CAAC;YACZ,SAAS,EAAE,CAAC;YACZ,IAAI,EAAE,IAAI;SACV,CAAC;QACF,KAAK,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;YAClE,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;gBAClB,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;gBAC5B,OAAO;YACR,CAAC;QACF,CAAC;IACF,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,MAAM,EAAE,CAAC;IACd,OAAO,IAAI,CAAC;AACb,CAAC"}
@@ -0,0 +1,76 @@
1
+ /** `mount` ran before `useHost` gave orbit a native host, or the module is not orbit's host. */
2
+ export declare const E_ORBIT_NO_HOST: import("@c9up/flare").ErrorClass<[string]>;
3
+ /** The native host refused a commit; the message carries its report. */
4
+ export declare const E_ORBIT_COMMIT_FAILED: import("@c9up/flare").ErrorClass<[unknown]>;
5
+ /**
6
+ * The views of a screen nest deeper than the host lays out (100 levels): the
7
+ * layout recurses once per level on the JS thread's stack, so the host refuses
8
+ * the commit instead of overflowing it.
9
+ */
10
+ export declare const E_ORBIT_TREE_TOO_DEEP: import("@c9up/flare").ErrorClass<[string]>;
11
+ /**
12
+ * A value of an `<svg>` the host cannot read (a `NaN` length, unreadable path
13
+ * data, `points` or `transform`): that part of the drawing is left out and the
14
+ * rest drawn. Reported to `mount`'s `onError`, never thrown.
15
+ */
16
+ export declare const E_ORBIT_SVG_VALUE: import("@c9up/flare").ErrorClass<[string]>;
17
+ /** An element with no native mapping yet (`<select>`, `<canvas>`, or `<text>` / a gradient inside an `<svg>`). */
18
+ export declare const E_ORBIT_UNSUPPORTED_ELEMENT: import("@c9up/flare").ErrorClass<[string, string]>;
19
+ /** A block element inside text: native text holds only inline runs. */
20
+ export declare const E_ORBIT_BLOCK_IN_TEXT: import("@c9up/flare").ErrorClass<[string]>;
21
+ /** `motion=${…}` was not an object of motion values. The message is aurora's. */
22
+ export declare const E_ORBIT_INVALID_MOTION: import("@c9up/flare").ErrorClass<[string]>;
23
+ /** `scroll-y=${…}` was not a motion value. */
24
+ export declare const E_ORBIT_INVALID_SCROLL_BINDING: import("@c9up/flare").ErrorClass<never>;
25
+ /** A colour orbit cannot read (named colours other than `transparent`, `hsl()`…). */
26
+ export declare const E_ORBIT_INVALID_COLOR: import("@c9up/flare").ErrorClass<[string]>;
27
+ /** `<img src>` over plain http: images are fetched over https only. */
28
+ export declare const E_ORBIT_INSECURE_IMAGE_URL: import("@c9up/flare").ErrorClass<[string]>;
29
+ /** `<img src>` with a scheme that is not an image source (`data:`, `javascript:`…). */
30
+ export declare const E_ORBIT_IMAGE_SOURCE: import("@c9up/flare").ErrorClass<[string, string]>;
31
+ /** Two elements of an `each` list share a key: a key names one row. */
32
+ export declare const E_ORBIT_DUPLICATE_KEY: import("@c9up/flare").ErrorClass<[string]>;
33
+ /** `useScreen()` in a component no screen of a stack built. */
34
+ export declare const E_ORBIT_NO_SCREEN: import("@c9up/flare").ErrorClass<never>;
35
+ /** One stack put in two places: a stack is shown once. */
36
+ export declare const E_ORBIT_STACK_SHOWN: import("@c9up/flare").ErrorClass<never>;
37
+ /** `useStyles` got something other than a table `ream css:compile` wrote. */
38
+ export declare const E_ORBIT_STYLE_TABLE: import("@c9up/flare").ErrorClass<never>;
39
+ /** `serverPages({ server })` over plain http to a host that is not this machine or the emulator's. */
40
+ export declare const E_ORBIT_INSECURE_SERVER: import("@c9up/flare").ErrorClass<[string]>;
41
+ /** The server named a page the app does not have (`serverPages({ pages })`). */
42
+ export declare const E_ORBIT_UNKNOWN_PAGE: import("@c9up/flare").ErrorClass<[string]>;
43
+ /** A server connection was asked for a path that resolves to another origin. */
44
+ export declare const E_ORBIT_FOREIGN_ORIGIN: import("@c9up/flare").ErrorClass<[string, string]>;
45
+ /** The server answered a JSON request with an empty non-2xx response. */
46
+ export declare const E_ORBIT_SERVER_REQUEST_FAILED: import("@c9up/flare").ErrorClass<[string, number]>;
47
+ /** Server events need an `XMLHttpRequest`, and the platform has none. */
48
+ export declare const E_ORBIT_NO_XHR: import("@c9up/flare").ErrorClass<never>;
49
+ /** An invariant inside orbit broke: a bug in orbit. The site says which one. */
50
+ export declare const E_ORBIT_INTERNAL: import("@c9up/flare").ErrorClass<[string]>;
51
+ /** `URL.createObjectURL` with no platform `URL` to make blob URLs. */
52
+ export declare class E_ORBIT_OBJECT_URL_UNAVAILABLE extends TypeError {
53
+ static readonly code = "E_ORBIT_OBJECT_URL_UNAVAILABLE";
54
+ readonly code = "E_ORBIT_OBJECT_URL_UNAVAILABLE";
55
+ }
56
+ /** A URL (or its base) that does not parse. */
57
+ export declare class E_ORBIT_INVALID_URL extends TypeError {
58
+ static readonly code = "E_ORBIT_INVALID_URL";
59
+ readonly code = "E_ORBIT_INVALID_URL";
60
+ }
61
+ /** `TextDecoder` given an encoding label other than UTF-8's. */
62
+ export declare class E_ORBIT_UNSUPPORTED_ENCODING extends RangeError {
63
+ static readonly code = "E_ORBIT_UNSUPPORTED_ENCODING";
64
+ readonly code = "E_ORBIT_UNSUPPORTED_ENCODING";
65
+ }
66
+ /** `TextDecoder.decode` given something that is not an `ArrayBuffer` or a view on one. */
67
+ export declare class E_ORBIT_INVALID_DECODER_INPUT extends TypeError {
68
+ static readonly code = "E_ORBIT_INVALID_DECODER_INPUT";
69
+ readonly code = "E_ORBIT_INVALID_DECODER_INPUT";
70
+ }
71
+ /** A `fatal` `TextDecoder` met bytes that are not valid UTF-8. */
72
+ export declare class E_ORBIT_INVALID_ENCODED_DATA extends TypeError {
73
+ static readonly code = "E_ORBIT_INVALID_ENCODED_DATA";
74
+ readonly code = "E_ORBIT_INVALID_ENCODED_DATA";
75
+ }
76
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAOA,gGAAgG;AAChG,eAAO,MAAM,eAAe,4CAG3B,CAAC;AAEF,wEAAwE;AACxE,eAAO,MAAM,qBAAqB,6CAGjC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,4CAGjC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,4CAG7B,CAAC;AAEF,kHAAkH;AAClH,eAAO,MAAM,2BAA2B,oDAGvC,CAAC;AAEF,uEAAuE;AACvE,eAAO,MAAM,qBAAqB,4CAGjC,CAAC;AAEF,iFAAiF;AACjF,eAAO,MAAM,sBAAsB,4CAGlC,CAAC;AAEF,8CAA8C;AAC9C,eAAO,MAAM,8BAA8B,yCAG1C,CAAC;AAEF,qFAAqF;AACrF,eAAO,MAAM,qBAAqB,4CAGjC,CAAC;AAEF,uEAAuE;AACvE,eAAO,MAAM,0BAA0B,4CAGtC,CAAC;AAEF,uFAAuF;AACvF,eAAO,MAAM,oBAAoB,oDAGhC,CAAC;AAEF,uEAAuE;AACvE,eAAO,MAAM,qBAAqB,4CAGjC,CAAC;AAEF,+DAA+D;AAC/D,eAAO,MAAM,iBAAiB,yCAG7B,CAAC;AAEF,0DAA0D;AAC1D,eAAO,MAAM,mBAAmB,yCAG/B,CAAC;AAEF,6EAA6E;AAC7E,eAAO,MAAM,mBAAmB,yCAG/B,CAAC;AAEF,sGAAsG;AACtG,eAAO,MAAM,uBAAuB,4CAGnC,CAAC;AAEF,gFAAgF;AAChF,eAAO,MAAM,oBAAoB,4CAGhC,CAAC;AAEF,gFAAgF;A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