@c9up/orbit 0.1.0 → 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 (77) hide show
  1. package/Cargo.lock +9 -16
  2. package/Cargo.toml +4 -0
  3. package/README.md +7 -1
  4. package/android/src/main/java/com/c9up/orbit/OrbitInput.kt +18 -2
  5. package/crates/orbit-host/Cargo.toml +1 -1
  6. package/crates/orbit-host/src/lib.rs +549 -115
  7. package/crates/orbit-host/src/vector.rs +312 -56
  8. package/dist/color.d.ts.map +1 -1
  9. package/dist/color.js +3 -3
  10. package/dist/color.js.map +1 -1
  11. package/dist/commit.d.ts +32 -0
  12. package/dist/commit.d.ts.map +1 -1
  13. package/dist/commit.js +142 -12
  14. package/dist/commit.js.map +1 -1
  15. package/dist/errors.d.ts +60 -26
  16. package/dist/errors.d.ts.map +1 -1
  17. package/dist/errors.js +85 -11
  18. package/dist/errors.js.map +1 -1
  19. package/dist/host.d.ts.map +1 -1
  20. package/dist/host.js +4 -2
  21. package/dist/host.js.map +1 -1
  22. package/dist/index.d.ts +4 -2
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +3 -1
  25. package/dist/index.js.map +1 -1
  26. package/dist/motion.d.ts.map +1 -1
  27. package/dist/motion.js +7 -6
  28. package/dist/motion.js.map +1 -1
  29. package/dist/pages.d.ts.map +1 -1
  30. package/dist/pages.js +3 -3
  31. package/dist/pages.js.map +1 -1
  32. package/dist/react-native/index.d.ts +9 -1
  33. package/dist/react-native/index.d.ts.map +1 -1
  34. package/dist/react-native/index.js +33 -5
  35. package/dist/react-native/index.js.map +1 -1
  36. package/dist/report.d.ts +13 -0
  37. package/dist/report.d.ts.map +1 -0
  38. package/dist/report.js +22 -0
  39. package/dist/report.js.map +1 -0
  40. package/dist/server.d.ts +27 -3
  41. package/dist/server.d.ts.map +1 -1
  42. package/dist/server.js +15 -7
  43. package/dist/server.js.map +1 -1
  44. package/dist/stack.d.ts.map +1 -1
  45. package/dist/stack.js +3 -3
  46. package/dist/stack.js.map +1 -1
  47. package/dist/styles.d.ts.map +1 -1
  48. package/dist/styles.js +2 -2
  49. package/dist/styles.js.map +1 -1
  50. package/dist/template.d.ts.map +1 -1
  51. package/dist/template.js +56 -12
  52. package/dist/template.js.map +1 -1
  53. package/dist/textDecoder.d.ts +29 -0
  54. package/dist/textDecoder.d.ts.map +1 -0
  55. package/dist/textDecoder.js +149 -0
  56. package/dist/textDecoder.js.map +1 -0
  57. package/dist/url.d.ts.map +1 -1
  58. package/dist/url.js +4 -3
  59. package/dist/url.js.map +1 -1
  60. package/package.json +13 -7
  61. package/scripts/build-android.sh +0 -0
  62. package/src/color.ts +5 -10
  63. package/src/commit.ts +184 -17
  64. package/src/errors.ts +174 -44
  65. package/src/host.ts +4 -5
  66. package/src/index.ts +5 -1
  67. package/src/motion.ts +8 -6
  68. package/src/pages.ts +3 -6
  69. package/src/react-native/index.ts +46 -7
  70. package/src/react-native/react-native.d.ts +8 -0
  71. package/src/report.ts +25 -0
  72. package/src/server.ts +50 -14
  73. package/src/stack.ts +3 -9
  74. package/src/styles.ts +2 -5
  75. package/src/template.ts +65 -41
  76. package/src/textDecoder.ts +162 -0
  77. package/src/url.ts +10 -3
@@ -18,6 +18,13 @@
18
18
  //! u8 crisp (no antialiasing)
19
19
  //! i32 verb count, then per verb: u8 verb, its f32 points
20
20
  //! (0 move x y, 1 line x y, 2 cubic x1 y1 x2 y2 x y, 3 quad x1 y1 x y, 4 close)
21
+ //!
22
+ //! A value the host cannot read never fails the commit, as a browser draws
23
+ //! the rest of a page: a non-finite number counts as absent, path data and
24
+ //! `points` are drawn up to their first error (SVG 2, "Path data error
25
+ //! handling"), and an element whose paint or `transform` cannot be read is
26
+ //! left out with what it holds. Each such value is reported once in the
27
+ //! commit's `warnings`, coded `E_ORBIT_SVG_VALUE`.
21
28
 
22
29
  use serde_json::{Map, Value};
23
30
 
@@ -122,36 +129,68 @@ impl PathOut {
122
129
  }
123
130
  }
124
131
 
132
+ /// At most this many values are reported per commit: the report stays small
133
+ /// whatever a drawing holds.
134
+ pub const MAX_WARNINGS: usize = 16;
135
+
136
+ /// The longest excerpt of an attribute a warning quotes.
137
+ const EXCERPT: usize = 40;
138
+
139
+ /// Record a value left out (coded, bounded in count and length).
140
+ fn warn(warnings: &mut Vec<String>, message: String) {
141
+ if warnings.len() < MAX_WARNINGS {
142
+ warnings.push(format!("E_ORBIT_SVG_VALUE: {message}"));
143
+ }
144
+ }
145
+
146
+ /// The start of an attribute, quoted, for a warning.
147
+ fn excerpt(text: &str) -> String {
148
+ match text.char_indices().nth(EXCERPT) {
149
+ Some((end, _)) => format!("{:?}…", &text[..end]),
150
+ None => format!("{text:?}"),
151
+ }
152
+ }
153
+
125
154
  /// Read an `<svg>` description (`{ color, root }`) into the encoding above.
126
- pub fn encode(vector: &Value) -> Result<Vec<u8>, String> {
155
+ /// What cannot be read is left out and reported in `warnings`.
156
+ pub fn encode(vector: &Value, warnings: &mut Vec<String>) -> Vec<u8> {
127
157
  let current = vector
128
158
  .get("color")
129
159
  .and_then(Value::as_i64)
130
160
  .unwrap_or(0xFF00_0000) as u32;
131
- let root = vector.get("root").ok_or("vector: no root")?;
161
+ let root = vector.get("root").unwrap_or(&Value::Null);
132
162
  let attrs = attrs_of(root);
163
+ let sized = || {
164
+ let w = attr_num(attrs, "width").unwrap_or(300.0);
165
+ let h = attr_num(attrs, "height").unwrap_or(150.0);
166
+ [0.0, 0.0, w, h]
167
+ };
133
168
  let view_box = match attr_str(attrs, "viewBox") {
134
- Some(text) => {
135
- let n = numbers(text)?;
136
- if n.len() != 4 || n[2] <= 0.0 || n[3] <= 0.0 {
137
- return Err(format!(
138
- "svg: viewBox {text:?} is not four numbers with a positive size"
139
- ));
169
+ Some(text) => match numbers(text) {
170
+ Ok(n) if n.len() == 4 && n[2] > 0.0 && n[3] > 0.0 => [n[0], n[1], n[2], n[3]],
171
+ _ => {
172
+ warn(
173
+ warnings,
174
+ format!(
175
+ "svg: viewBox {} is not four numbers with a positive size",
176
+ excerpt(text)
177
+ ),
178
+ );
179
+ sized()
140
180
  }
141
- [n[0], n[1], n[2], n[3]]
142
- }
143
- None => {
144
- let w = attr_num(attrs, "width").unwrap_or(300.0);
145
- let h = attr_num(attrs, "height").unwrap_or(150.0);
146
- [0.0, 0.0, w, h]
147
- }
181
+ },
182
+ None => sized(),
148
183
  };
149
184
  let stretch = attr_str(attrs, "preserveAspectRatio").map(str::trim) == Some("none");
150
185
  let mut shapes: Vec<u8> = Vec::new();
151
186
  let mut count = 0i32;
152
- let inherited = inherit(Inherited::default(), attrs)?;
153
- for child in children_of(root) {
154
- walk(child, inherited, current, &mut shapes, &mut count)?;
187
+ match inherit(Inherited::default(), attrs) {
188
+ Ok(inherited) => {
189
+ for child in children_of(root) {
190
+ walk(child, inherited, current, &mut shapes, &mut count, warnings);
191
+ }
192
+ }
193
+ Err(e) => warn(warnings, format!("{e}: the drawing is left out")),
155
194
  }
156
195
  let mut out = Vec::with_capacity(21 + shapes.len());
157
196
  for v in view_box {
@@ -160,7 +199,7 @@ pub fn encode(vector: &Value) -> Result<Vec<u8>, String> {
160
199
  out.push(u8::from(stretch));
161
200
  out.extend_from_slice(&count.to_le_bytes());
162
201
  out.extend_from_slice(&shapes);
163
- Ok(out)
202
+ out
164
203
  }
165
204
 
166
205
  fn attrs_of(node: &Value) -> &Map<String, Value> {
@@ -180,19 +219,21 @@ fn attr_str<'a>(attrs: &'a Map<String, Value>, key: &str) -> Option<&'a str> {
180
219
  attrs.get(key).and_then(Value::as_str)
181
220
  }
182
221
 
222
+ /// A number attribute; a value that is not a finite number (`NaN`,
223
+ /// `Infinity`, `undefined`) counts as absent, as an attribute in error does.
183
224
  fn attr_num(attrs: &Map<String, Value>, key: &str) -> Option<f64> {
184
225
  match attrs.get(key)? {
185
- Value::Number(n) => n.as_f64(),
226
+ Value::Number(n) => n.as_f64().filter(|v| v.is_finite()),
186
227
  Value::String(s) => length(s),
187
228
  _ => None,
188
229
  }
189
230
  }
190
231
 
191
- /// A length attribute: a number, optionally in px.
232
+ /// A length attribute: a finite number, optionally in px.
192
233
  fn length(text: &str) -> Option<f64> {
193
234
  let text = text.trim();
194
235
  let text = text.strip_suffix("px").unwrap_or(text);
195
- text.parse().ok()
236
+ text.parse::<f64>().ok().filter(|v| v.is_finite())
196
237
  }
197
238
 
198
239
  fn paint(value: &Value) -> Result<PaintValue, String> {
@@ -200,7 +241,11 @@ fn paint(value: &Value) -> Result<PaintValue, String> {
200
241
  Value::Number(n) => Ok(PaintValue::Color(n.as_i64().unwrap_or(0) as u32)),
201
242
  Value::String(s) if s == "none" || s == "transparent" => Ok(PaintValue::None),
202
243
  Value::String(s) if s == "currentColor" => Ok(PaintValue::Current),
203
- other => Err(format!("svg: paint {other} is not a colour")),
244
+ Value::String(s) => Err(format!("svg: paint {} is not a colour", excerpt(s))),
245
+ other => Err(format!(
246
+ "svg: paint {} is not a colour",
247
+ excerpt(&other.to_string())
248
+ )),
204
249
  }
205
250
  }
206
251
 
@@ -259,29 +304,39 @@ fn walk(
259
304
  current: u32,
260
305
  out: &mut Vec<u8>,
261
306
  count: &mut i32,
262
- ) -> Result<(), String> {
307
+ warnings: &mut Vec<String>,
308
+ ) {
263
309
  let tag = node.get("t").and_then(Value::as_str).unwrap_or("");
264
310
  let attrs = attrs_of(node);
265
- let st = inherit(parent, attrs)?;
311
+ let st = match inherit(parent, attrs) {
312
+ Ok(st) => st,
313
+ Err(e) => {
314
+ warn(warnings, format!("{e}: <{}> is left out", excerpt(tag)));
315
+ return;
316
+ }
317
+ };
266
318
  let mut path = PathOut::default();
267
319
  let m = st.matrix;
268
320
  let num = |key: &str| attr_num(attrs, key).unwrap_or(0.0);
269
321
  match tag {
270
322
  "g" => {
271
323
  for child in children_of(node) {
272
- walk(child, st, current, out, count)?;
324
+ walk(child, st, current, out, count, warnings);
273
325
  }
274
- return Ok(());
326
+ return;
275
327
  }
276
328
  "path" => {
277
329
  if let Some(d) = attr_str(attrs, "d") {
278
- path_data(d, &m, &mut path)?;
330
+ // Drawn up to the first error, as SVG 2 says.
331
+ if let Err(e) = path_data(d, &m, &mut path) {
332
+ warn(warnings, format!("{e} in d={}", excerpt(d)));
333
+ }
279
334
  }
280
335
  }
281
336
  "rect" => {
282
337
  let (x, y, w, h) = (num("x"), num("y"), num("width"), num("height"));
283
338
  if w <= 0.0 || h <= 0.0 {
284
- return Ok(());
339
+ return;
285
340
  }
286
341
  let rx = attr_num(attrs, "rx");
287
342
  let ry = attr_num(attrs, "ry");
@@ -318,7 +373,13 @@ fn walk(
318
373
  path.push(VERB_LINE, &m, &[(num("x2"), num("y2"))]);
319
374
  }
320
375
  "polyline" | "polygon" => {
321
- let pts = numbers(attr_str(attrs, "points").unwrap_or(""))?;
376
+ let text = attr_str(attrs, "points").unwrap_or("");
377
+ // Drawn up to the first error, as SVG 2 says (an odd count
378
+ // leaves the last number out).
379
+ let (pts, error) = numbers_until_error(text);
380
+ if let Some(e) = error {
381
+ warn(warnings, format!("{e} in points={}", excerpt(text)));
382
+ }
322
383
  for (i, [x, y]) in pts.as_chunks::<2>().0.iter().enumerate() {
323
384
  let verb = if i == 0 { VERB_MOVE } else { VERB_LINE };
324
385
  path.push(verb, &m, &[(*x, *y)]);
@@ -327,11 +388,29 @@ fn walk(
327
388
  path.verbs.push(VERB_CLOSE);
328
389
  }
329
390
  }
330
- "title" | "desc" | "metadata" => return Ok(()),
331
- other => return Err(format!("svg: <{other}> is not drawn by orbit")),
391
+ "title" | "desc" | "metadata" => return,
392
+ other => {
393
+ warn(
394
+ warnings,
395
+ format!("svg: <{}> is not drawn by orbit", excerpt(other)),
396
+ );
397
+ return;
398
+ }
332
399
  }
333
400
  if path.verbs.is_empty() {
334
- return Ok(());
401
+ return;
402
+ }
403
+ // Finite numbers can still add up past what an f32 holds.
404
+ let width = (st.stroke_width * m.scale()) as f32;
405
+ if !width.is_finite() || path.points.iter().any(|v| !v.is_finite()) {
406
+ warn(
407
+ warnings,
408
+ format!(
409
+ "svg: <{}> lies outside the numbers a drawing holds",
410
+ excerpt(tag)
411
+ ),
412
+ );
413
+ return;
335
414
  }
336
415
  // A line has no inside: only its stroke shows.
337
416
  let fill = if tag == "line" {
@@ -341,12 +420,12 @@ fn walk(
341
420
  };
342
421
  let stroke = argb(st.stroke, current, st.stroke_opacity * st.opacity);
343
422
  if fill == 0 && (stroke == 0 || st.stroke_width == 0.0) {
344
- return Ok(());
423
+ return;
345
424
  }
346
425
  out.extend_from_slice(&fill.to_le_bytes());
347
426
  out.push(st.fill_rule);
348
427
  out.extend_from_slice(&stroke.to_le_bytes());
349
- out.extend_from_slice(&((st.stroke_width * m.scale()) as f32).to_le_bytes());
428
+ out.extend_from_slice(&width.to_le_bytes());
350
429
  out.push(st.cap);
351
430
  out.push(st.join);
352
431
  out.extend_from_slice(&(st.miter as f32).to_le_bytes());
@@ -367,7 +446,6 @@ fn walk(
367
446
  p += n;
368
447
  }
369
448
  *count += 1;
370
- Ok(())
371
449
  }
372
450
 
373
451
  /// A paint as ARGB with `opacity` folded into its alpha; 0 for none.
@@ -525,7 +603,8 @@ impl<'a> Scanner<'a> {
525
603
  }
526
604
  std::str::from_utf8(&s[start..self.i])
527
605
  .ok()
528
- .and_then(|t| t.parse().ok())
606
+ .and_then(|t| t.parse::<f64>().ok())
607
+ .filter(|v| v.is_finite())
529
608
  .ok_or_else(|| format!("svg: unreadable number at {start}"))
530
609
  }
531
610
 
@@ -546,12 +625,23 @@ impl<'a> Scanner<'a> {
546
625
  }
547
626
 
548
627
  fn numbers(text: &str) -> Result<Vec<f64>, String> {
628
+ match numbers_until_error(text) {
629
+ (out, None) => Ok(out),
630
+ (_, Some(e)) => Err(e),
631
+ }
632
+ }
633
+
634
+ /// The numbers read before the first error, and that error.
635
+ fn numbers_until_error(text: &str) -> (Vec<f64>, Option<String>) {
549
636
  let mut sc = Scanner::new(text);
550
637
  let mut out = Vec::new();
551
638
  while sc.peek().is_some() {
552
- out.push(sc.number()?);
639
+ match sc.number() {
640
+ Ok(n) => out.push(n),
641
+ Err(e) => return (out, Some(e)),
642
+ }
553
643
  }
554
- Ok(out)
644
+ (out, None)
555
645
  }
556
646
 
557
647
  /// A `transform` attribute: a list of matrix / translate / scale / rotate / skewX / skewY.
@@ -559,12 +649,10 @@ fn transform(text: &str) -> Result<Matrix, String> {
559
649
  let mut m = Matrix::IDENTITY;
560
650
  let mut rest = text.trim();
561
651
  while !rest.is_empty() {
562
- let open = rest
563
- .find('(')
564
- .ok_or_else(|| format!("svg: transform {text:?}"))?;
565
- let close = rest
566
- .find(')')
567
- .ok_or_else(|| format!("svg: transform {text:?}"))?;
652
+ let unreadable = || format!("svg: transform {} is not read", excerpt(text));
653
+ let open = rest.find('(').ok_or_else(unreadable)?;
654
+ // The `)` that closes this `(`, not one written before it.
655
+ let close = rest[open..].find(')').ok_or_else(unreadable)? + open;
568
656
  let name = rest[..open].trim().trim_start_matches(',').trim();
569
657
  let a = numbers(&rest[open + 1..close])?;
570
658
  let get = |i: usize| a.get(i).copied();
@@ -614,11 +702,7 @@ fn path_data(d: &str, m: &Matrix, out: &mut PathOut) -> Result<(), String> {
614
702
  Some(b'M') => b'L',
615
703
  Some(b'm') => b'l',
616
704
  Some(prev) if prev != b'Z' && prev != b'z' => prev,
617
- _ => {
618
- return Err(format!(
619
- "svg: path data {d:?} does not start with a command"
620
- ))
621
- }
705
+ _ => return Err("svg: path data does not start with a command".to_owned()),
622
706
  }
623
707
  };
624
708
  let rel = command.is_ascii_lowercase();
@@ -855,7 +939,9 @@ mod tests {
855
939
  }
856
940
 
857
941
  fn shapes(v: Value) -> Vec<(i32, i32, f32, usize)> {
858
- let buf = encode(&v).unwrap();
942
+ let mut warnings = Vec::new();
943
+ let buf = encode(&v, &mut warnings);
944
+ assert_eq!(warnings, Vec::<String>::new());
859
945
  let i32_at = |i: usize| i32::from_le_bytes([buf[i], buf[i + 1], buf[i + 2], buf[i + 3]]);
860
946
  let f32_at = |i: usize| f32::from_le_bytes([buf[i], buf[i + 1], buf[i + 2], buf[i + 3]]);
861
947
  let count = i32_at(17);
@@ -907,11 +993,181 @@ mod tests {
907
993
  assert_eq!(s[2].3, 10);
908
994
  }
909
995
 
996
+ /// The shapes a drawing holds and what was reported while reading it.
997
+ fn read(root: Value) -> (i32, Vec<String>) {
998
+ let mut warnings = Vec::new();
999
+ let buf = encode(&json!({ "root": root }), &mut warnings);
1000
+ (
1001
+ i32::from_le_bytes([buf[17], buf[18], buf[19], buf[20]]),
1002
+ warnings,
1003
+ )
1004
+ }
1005
+
1006
+ fn one(shape: Value) -> (i32, Vec<String>) {
1007
+ read(json!({ "t": "svg", "a": { "viewBox": "0 0 100 50" }, "c": [
1008
+ shape,
1009
+ { "t": "rect", "a": { "width": "10", "height": "10" } }
1010
+ ]}))
1011
+ }
1012
+
1013
+ #[test]
1014
+ fn leaves_out_what_it_does_not_draw_and_says_so() {
1015
+ let (count, warnings) = one(json!({ "t": "text" }));
1016
+ assert_eq!(count, 1);
1017
+ assert_eq!(warnings.len(), 1);
1018
+ assert!(warnings[0].starts_with("E_ORBIT_SVG_VALUE: "));
1019
+ assert!(warnings[0].contains("<\"text\">"));
1020
+ // A viewBox in error counts as absent: the width and height size it.
1021
+ let (count, warnings) = read(json!({ "t": "svg", "a": { "viewBox": "0 0 0 1" }, "c": [
1022
+ { "t": "rect", "a": { "width": "1", "height": "1" } }
1023
+ ]}));
1024
+ assert_eq!((count, warnings.len()), (1, 1));
1025
+ // No root at all: an empty drawing.
1026
+ let mut warnings = Vec::new();
1027
+ assert_eq!(encode(&json!({}), &mut warnings).len(), 21);
1028
+ }
1029
+
1030
+ #[test]
1031
+ fn a_number_that_is_not_finite_counts_as_absent() {
1032
+ // `(0 / 0) * 50`: a rect with no height is not drawn, and nothing panics.
1033
+ for height in ["NaN", "Infinity", "-Infinity", "undefined", "1e999"] {
1034
+ let (count, warnings) =
1035
+ one(json!({ "t": "rect", "a": { "width": "40", "height": height, "rx": "2" } }));
1036
+ assert_eq!(count, 1, "{height}");
1037
+ assert!(warnings.is_empty(), "{height}");
1038
+ }
1039
+ let (count, _) = one(
1040
+ json!({ "t": "rect", "a": { "width": 40, "height": 20, "rx": "NaN", "ry": "NaN" } }),
1041
+ );
1042
+ assert_eq!(count, 2);
1043
+ let (count, _) = one(json!({ "t": "circle", "a": { "r": "NaN" } }));
1044
+ assert_eq!(count, 1);
1045
+ // An opacity in error is ignored: the shape is drawn as if it had none.
1046
+ let (count, _) =
1047
+ one(json!({ "t": "rect", "a": { "width": "4", "height": "4", "opacity": "NaN" } }));
1048
+ assert_eq!(count, 2);
1049
+ }
1050
+
1051
+ #[test]
1052
+ fn path_data_and_points_are_drawn_up_to_their_first_error() {
1053
+ let mut out = PathOut::default();
1054
+ assert!(path_data("M0 0 L10 10 L10 NaN L20 20", &Matrix::IDENTITY, &mut out).is_err());
1055
+ assert_eq!(out.verbs, vec![VERB_MOVE, VERB_LINE]);
1056
+ let (count, warnings) =
1057
+ one(json!({ "t": "path", "a": { "d": "M0 0 L10 NaN", "stroke": -1 } }));
1058
+ assert_eq!(count, 2);
1059
+ assert_eq!(warnings.len(), 1);
1060
+ assert!(warnings[0].contains("d=\"M0 0 L10 NaN\""));
1061
+ let (count, warnings) = one(
1062
+ json!({ "t": "polyline", "a": { "points": "0,0 10,10 20,undefined", "stroke": -1 } }),
1063
+ );
1064
+ assert_eq!((count, warnings.len()), (2, 1));
1065
+ // Nothing readable: nothing drawn, still reported.
1066
+ let (count, warnings) = one(json!({ "t": "polygon", "a": { "points": "undefined" } }));
1067
+ assert_eq!((count, warnings.len()), (1, 1));
1068
+ }
1069
+
1070
+ #[test]
1071
+ fn an_unreadable_transform_or_paint_leaves_out_its_element() {
1072
+ for t in [
1073
+ ")(",
1074
+ "translate(",
1075
+ "scale)(2",
1076
+ "rotate(NaN)",
1077
+ "matrix(1 2)",
1078
+ ")",
1079
+ ] {
1080
+ assert!(transform(t).is_err(), "{t}");
1081
+ let (count, warnings) = one(json!({ "t": "g", "a": { "transform": t }, "c": [
1082
+ { "t": "rect", "a": { "width": "4", "height": "4" } }
1083
+ ]}));
1084
+ assert_eq!(count, 1, "{t}");
1085
+ assert_eq!(warnings.len(), 1, "{t}");
1086
+ }
1087
+ let (count, warnings) =
1088
+ one(json!({ "t": "rect", "a": { "width": "4", "height": "4", "fill": "chartreuse" } }));
1089
+ assert_eq!((count, warnings.len()), (1, 1));
1090
+ // On the svg itself: the whole drawing is left out.
1091
+ let (count, warnings) = read(json!({ "t": "svg", "a": { "transform": ")(" }, "c": [
1092
+ { "t": "rect", "a": { "width": "4", "height": "4" } }
1093
+ ]}));
1094
+ assert_eq!((count, warnings.len()), (0, 1));
1095
+ }
1096
+
910
1097
  #[test]
911
- fn refuses_what_it_does_not_draw() {
912
- let v = json!({ "root": { "t": "svg", "a": { "viewBox": "0 0 1 1" }, "c": [ { "t": "text" } ] } });
913
- assert!(encode(&v).unwrap_err().contains("<text>"));
914
- let v = json!({ "root": { "t": "svg", "a": { "viewBox": "0 0 0 1" } } });
915
- assert!(encode(&v).is_err());
1098
+ fn numbers_past_what_a_drawing_holds_leave_out_the_shape() {
1099
+ let (count, warnings) =
1100
+ one(json!({ "t": "rect", "a": { "x": "1e308", "width": "1e308", "height": "1e308" } }));
1101
+ assert_eq!((count, warnings.len()), (1, 1));
1102
+ let (count, warnings) = one(json!({ "t": "line", "a": { "x2": "1e300", "stroke": -1 } }));
1103
+ assert_eq!((count, warnings.len()), (1, 1));
1104
+ }
1105
+
1106
+ #[test]
1107
+ fn warnings_are_bounded_in_count_and_length() {
1108
+ let long = format!("M0 0 L{}", "9".repeat(10_000));
1109
+ let shapes: Vec<Value> = (0..100)
1110
+ .map(|_| json!({ "t": "path", "a": { "d": format!("{long} x") } }))
1111
+ .collect();
1112
+ let (_, warnings) = read(json!({ "t": "svg", "a": {}, "c": shapes }));
1113
+ assert_eq!(warnings.len(), MAX_WARNINGS);
1114
+ assert!(warnings.iter().all(|w| w.len() < 200));
1115
+ }
1116
+
1117
+ #[test]
1118
+ fn no_attribute_text_panics() {
1119
+ let texts = [
1120
+ "",
1121
+ ")",
1122
+ "(",
1123
+ ")(",
1124
+ "((",
1125
+ "))",
1126
+ "a(",
1127
+ "(1)",
1128
+ "1e",
1129
+ "-",
1130
+ ".",
1131
+ "+.e",
1132
+ "e1",
1133
+ "1e-",
1134
+ "NaN",
1135
+ "inf",
1136
+ "\u{fffd}",
1137
+ "é(1)",
1138
+ "rotate(1 2)",
1139
+ "M",
1140
+ "M1",
1141
+ "M1 1 A",
1142
+ "A1 1 0 2 1 1 1",
1143
+ "M0 0 a1 1 0 1 1 0 0",
1144
+ "M0 0 a0 0 0 1 1 5 5",
1145
+ "Z1",
1146
+ "m1e308 1e308 l1e308 1e308",
1147
+ "M0 0 A1e-300 1e-300 0 1 1 1e300 1e300",
1148
+ ];
1149
+ for t in texts {
1150
+ let _ = transform(t);
1151
+ let _ = path_data(t, &Matrix::IDENTITY, &mut PathOut::default());
1152
+ let _ = numbers_until_error(t);
1153
+ for key in [
1154
+ "d",
1155
+ "points",
1156
+ "transform",
1157
+ "viewBox",
1158
+ "width",
1159
+ "height",
1160
+ "rx",
1161
+ "r",
1162
+ ] {
1163
+ for tag in [
1164
+ "path", "polyline", "polygon", "rect", "circle", "ellipse", "line", "g",
1165
+ ] {
1166
+ let _ = read(json!({ "t": "svg", "a": { key: t }, "c": [
1167
+ { "t": tag, "a": { key: t, "width": "1", "height": "1" }, "c": [] }
1168
+ ]}));
1169
+ }
1170
+ }
1171
+ }
916
1172
  }
917
1173
  }
@@ -1 +1 @@
1
- {"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../src/color.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAU/C"}
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 CHANGED
@@ -1,4 +1,4 @@
1
- import { OrbitError } from "./errors.js";
1
+ import { E_ORBIT_INVALID_COLOR } from "./errors.js";
2
2
  /**
3
3
  * A CSS colour as the 32-bit ARGB integer the native host reads (signed, as
4
4
  * Android's `Color` int), without React Native's `processColor`: the core of
@@ -16,7 +16,7 @@ export function colorToArgb(css) {
16
16
  const fn = /^rgba?\(\s*([^)]+)\)$/.exec(value);
17
17
  if (fn)
18
18
  return fromRgb(fn[1] ?? "", css);
19
- throw new OrbitError("E_ORBIT_INVALID_COLOR", `[orbit] cannot read the colour "${css}"`);
19
+ throw new E_ORBIT_INVALID_COLOR([css]);
20
20
  }
21
21
  function pack(r, g, b, a) {
22
22
  const byte = (n) => Math.max(0, Math.min(255, Math.round(n)));
@@ -57,6 +57,6 @@ function fromRgb(args, css) {
57
57
  return pack(r ?? 0, g ?? 0, b ?? 0, a);
58
58
  }
59
59
  function invalid(css) {
60
- return new OrbitError("E_ORBIT_INVALID_COLOR", `[orbit] cannot read the colour "${css}"`);
60
+ return new E_ORBIT_INVALID_COLOR([css]);
61
61
  }
62
62
  //# sourceMappingURL=color.js.map
package/dist/color.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"color.js","sourceRoot":"","sources":["../src/color.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW;IACtC,MAAM,KAAK,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACvC,IAAI,KAAK,KAAK,aAAa;QAAE,OAAO,CAAC,CAAC;IACtC,IAAI,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC/D,MAAM,EAAE,GAAG,uBAAuB,CAAC,IAAI,CA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AO,IAAI,qBAAqB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AACzC,CAAC"}
package/dist/commit.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { type OrbitHost } from "./host.js";
2
2
  import { type NativeNode } from "./node.js";
3
+ import { type ErrorListener } from "./report.js";
3
4
  /**
4
5
  * Committing the JS tree to the Rust host: one JSON batch per commit over JSI
5
6
  * (create, props patch, children, root). Layout, diffing and mounting happen in
@@ -14,7 +15,22 @@ export interface OrbitReport {
14
15
  measures: number;
15
16
  nodes: number;
16
17
  opsBytes: number;
18
+ /** What the host left out of the drawings of this commit, coded (`E_ORBIT_SVG_VALUE: …`). */
19
+ warnings?: string[];
17
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;
18
34
  /** Run `listener` after every commit; returns what stops it. */
19
35
  export declare function onEveryCommit(listener: () => void): () => void;
20
36
  /** The host the mounted tree commits to (layout reads, scrolling). */
@@ -29,6 +45,12 @@ export declare class Root {
29
45
  schedule(): void;
30
46
  /** Commit what changed now, instead of at the end of the turn. */
31
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;
32
54
  commit(): OrbitReport;
33
55
  }
34
56
  export interface MountOptions {
@@ -39,6 +61,16 @@ export interface MountOptions {
39
61
  };
40
62
  /** Defaults to the host given to `useHost`. */
41
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;
42
74
  }
43
75
  /** Mount a native tree; returns its root (`flush()` commits synchronously). */
44
76
  export declare function mountTree(tree: NativeNode, options: MountOptions): Root;
@@ -1 +1 @@
1
- {"version":3,"file":"commit.d.ts","sourceRoot":"","sources":["../src/commit.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,KAAK,UAAU,EAAoB,MAAM,WAAW,CAAC;AAG9D;;;;;GAKG;AAEH,MAAM,WAAW,WAAW;IAC3B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CACjB;AAiBD,gEAAgE;AAChE,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAG9D;AAED,sEAAsE;AACtE,wBAAgB,QAAQ,IAAI,SAAS,CAEpC;AAED,sFAAsF;AACtF,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,IAAI,GAAG,IAAI,CAElD;AAqDD,qBAAa,IAAI;;IAKhB,uEAAuE;IACvE,Q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