@reekon-tools/boldr-utils 1.7.3 → 1.7.4

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.
@@ -42,6 +42,11 @@ const useBackgroundUrl = (image, resolveUrl) => {
42
42
  // on a null/undefined source (despite its DataSourceParam type), so it can't
43
43
  // be called unconditionally from a component that usually renders raster
44
44
  // backgrounds. An empty url resolves to null (nothing to draw yet).
45
+ // Loaded through Skia's own scheme-agnostic data loader rather than fetch():
46
+ // RN's Android networking rejects non-http(s) schemes, and offline-first
47
+ // consumers resolve the background to a local file:// URI (fromURI handles
48
+ // file://, http(s) and data: on native and web alike). fetch() remains as a
49
+ // fallback for any environment where fromURI can't service the URL.
45
50
  const useBackgroundSvg = (url) => {
46
51
  const [svg, setSvg] = useState(null);
47
52
  useEffect(() => {
@@ -52,9 +57,16 @@ const useBackgroundSvg = (url) => {
52
57
  let cancelled = false;
53
58
  (async () => {
54
59
  try {
55
- const res = await fetch(url);
56
- const text = await res.text();
57
- const next = Skia.SVG.MakeFromString(text);
60
+ let next = null;
61
+ try {
62
+ const data = await Skia.Data.fromURI(url);
63
+ next = Skia.SVG.MakeFromData(data);
64
+ data.dispose();
65
+ }
66
+ catch {
67
+ const res = await fetch(url);
68
+ next = Skia.SVG.MakeFromString(await res.text());
69
+ }
58
70
  if (!cancelled)
59
71
  setSvg(next);
60
72
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reekon-tools/boldr-utils",
3
- "version": "1.7.3",
3
+ "version": "1.7.4",
4
4
  "description": "Shared utilities for formulas and measurement conversion used in Reekon apps",
5
5
  "author": "REEKON Tools",
6
6
  "license": "MIT",