@shopify/react-native-skia 2.7.0 → 2.9.0

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 (157) hide show
  1. package/android/build.gradle +10 -4
  2. package/android/cpp/rnskia-android/OpenGLContext.h +29 -3
  3. package/android/cpp/rnskia-android/OpenGLWindowContext.cpp +9 -2
  4. package/android/cpp/rnskia-android/gl/Context.h +3 -0
  5. package/android/cpp/rnskia-android/gl/Surface.h +1 -1
  6. package/cpp/api/JsiSkParagraph.h +114 -0
  7. package/cpp/api/JsiSkiaContext.h +4 -0
  8. package/cpp/rnskia/RNSkView.h +6 -0
  9. package/lib/commonjs/Platform/Platform.js +5 -2
  10. package/lib/commonjs/Platform/Platform.js.map +1 -1
  11. package/lib/commonjs/Platform/Platform.web.js +8 -7
  12. package/lib/commonjs/Platform/Platform.web.js.map +1 -1
  13. package/lib/commonjs/external/reanimated/useVideoLoading.js +11 -2
  14. package/lib/commonjs/external/reanimated/useVideoLoading.js.map +1 -1
  15. package/lib/commonjs/skia/core/Font.d.ts +21 -6
  16. package/lib/commonjs/skia/core/Font.js +24 -4
  17. package/lib/commonjs/skia/core/Font.js.map +1 -1
  18. package/lib/commonjs/skia/core/SVG.web.js +4 -5
  19. package/lib/commonjs/skia/core/SVG.web.js.map +1 -1
  20. package/lib/commonjs/skia/types/Data/Data.d.ts +5 -4
  21. package/lib/commonjs/skia/types/Data/Data.js +7 -1
  22. package/lib/commonjs/skia/types/Data/Data.js.map +1 -1
  23. package/lib/commonjs/skia/types/Paragraph/Paragraph.d.ts +62 -0
  24. package/lib/commonjs/skia/types/Paragraph/Paragraph.js.map +1 -1
  25. package/lib/commonjs/skia/web/Host.js +7 -0
  26. package/lib/commonjs/skia/web/Host.js.map +1 -1
  27. package/lib/commonjs/skia/web/JsiSkFont.d.ts +1 -1
  28. package/lib/commonjs/skia/web/JsiSkFont.js +43 -2
  29. package/lib/commonjs/skia/web/JsiSkFont.js.map +1 -1
  30. package/lib/commonjs/skia/web/JsiSkPaint.js +5 -0
  31. package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
  32. package/lib/commonjs/skia/web/JsiSkParagraph.d.ts +3 -1
  33. package/lib/commonjs/skia/web/JsiSkParagraph.js +6 -0
  34. package/lib/commonjs/skia/web/JsiSkParagraph.js.map +1 -1
  35. package/lib/commonjs/sksg/Container.web.js +34 -3
  36. package/lib/commonjs/sksg/Container.web.js.map +1 -1
  37. package/lib/commonjs/sksg/Recorder/DrawingContext.d.ts +2 -0
  38. package/lib/commonjs/sksg/Recorder/DrawingContext.js +22 -6
  39. package/lib/commonjs/sksg/Recorder/DrawingContext.js.map +1 -1
  40. package/lib/commonjs/sksg/Recorder/FrameScope.d.ts +18 -0
  41. package/lib/commonjs/sksg/Recorder/FrameScope.js +66 -0
  42. package/lib/commonjs/sksg/Recorder/FrameScope.js.map +1 -0
  43. package/lib/commonjs/sksg/Recorder/FrameScope.native.d.ts +10 -0
  44. package/lib/commonjs/sksg/Recorder/FrameScope.native.js +26 -0
  45. package/lib/commonjs/sksg/Recorder/FrameScope.native.js.map +1 -0
  46. package/lib/commonjs/sksg/Recorder/Player.js +1 -2
  47. package/lib/commonjs/sksg/Recorder/Player.js.map +1 -1
  48. package/lib/commonjs/sksg/Recorder/Recorder.d.ts +3 -1
  49. package/lib/commonjs/sksg/Recorder/Recorder.js +12 -1
  50. package/lib/commonjs/sksg/Recorder/Recorder.js.map +1 -1
  51. package/lib/commonjs/sksg/Recorder/commands/Drawing.js +3 -3
  52. package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -1
  53. package/lib/commonjs/sksg/Recorder/commands/Shaders.js +3 -3
  54. package/lib/commonjs/sksg/Recorder/commands/Shaders.js.map +1 -1
  55. package/lib/commonjs/sksg/StaticContainer.d.ts +1 -0
  56. package/lib/commonjs/sksg/StaticContainer.js +27 -1
  57. package/lib/commonjs/sksg/StaticContainer.js.map +1 -1
  58. package/lib/module/Platform/Platform.js +6 -3
  59. package/lib/module/Platform/Platform.js.map +1 -1
  60. package/lib/module/Platform/Platform.web.js +9 -8
  61. package/lib/module/Platform/Platform.web.js.map +1 -1
  62. package/lib/module/external/reanimated/useVideoLoading.js +12 -2
  63. package/lib/module/external/reanimated/useVideoLoading.js.map +1 -1
  64. package/lib/module/skia/core/Font.d.ts +21 -6
  65. package/lib/module/skia/core/Font.js +26 -5
  66. package/lib/module/skia/core/Font.js.map +1 -1
  67. package/lib/module/skia/core/SVG.web.js +4 -5
  68. package/lib/module/skia/core/SVG.web.js.map +1 -1
  69. package/lib/module/skia/types/Data/Data.d.ts +5 -4
  70. package/lib/module/skia/types/Data/Data.js +5 -0
  71. package/lib/module/skia/types/Data/Data.js.map +1 -1
  72. package/lib/module/skia/types/Paragraph/Paragraph.d.ts +62 -0
  73. package/lib/module/skia/types/Paragraph/Paragraph.js.map +1 -1
  74. package/lib/module/skia/web/Host.js +7 -0
  75. package/lib/module/skia/web/Host.js.map +1 -1
  76. package/lib/module/skia/web/JsiSkFont.d.ts +1 -1
  77. package/lib/module/skia/web/JsiSkFont.js +44 -3
  78. package/lib/module/skia/web/JsiSkFont.js.map +1 -1
  79. package/lib/module/skia/web/JsiSkPaint.js +5 -0
  80. package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
  81. package/lib/module/skia/web/JsiSkParagraph.d.ts +3 -1
  82. package/lib/module/skia/web/JsiSkParagraph.js +7 -1
  83. package/lib/module/skia/web/JsiSkParagraph.js.map +1 -1
  84. package/lib/module/sksg/Container.web.js +35 -4
  85. package/lib/module/sksg/Container.web.js.map +1 -1
  86. package/lib/module/sksg/Recorder/DrawingContext.d.ts +2 -0
  87. package/lib/module/sksg/Recorder/DrawingContext.js +22 -6
  88. package/lib/module/sksg/Recorder/DrawingContext.js.map +1 -1
  89. package/lib/module/sksg/Recorder/FrameScope.d.ts +18 -0
  90. package/lib/module/sksg/Recorder/FrameScope.js +59 -0
  91. package/lib/module/sksg/Recorder/FrameScope.js.map +1 -0
  92. package/lib/module/sksg/Recorder/FrameScope.native.d.ts +10 -0
  93. package/lib/module/sksg/Recorder/FrameScope.native.js +19 -0
  94. package/lib/module/sksg/Recorder/FrameScope.native.js.map +1 -0
  95. package/lib/module/sksg/Recorder/Player.js +1 -2
  96. package/lib/module/sksg/Recorder/Player.js.map +1 -1
  97. package/lib/module/sksg/Recorder/Recorder.d.ts +3 -1
  98. package/lib/module/sksg/Recorder/Recorder.js +10 -0
  99. package/lib/module/sksg/Recorder/Recorder.js.map +1 -1
  100. package/lib/module/sksg/Recorder/commands/Drawing.js +3 -3
  101. package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -1
  102. package/lib/module/sksg/Recorder/commands/Shaders.js +3 -3
  103. package/lib/module/sksg/Recorder/commands/Shaders.js.map +1 -1
  104. package/lib/module/sksg/StaticContainer.d.ts +1 -0
  105. package/lib/module/sksg/StaticContainer.js +28 -2
  106. package/lib/module/sksg/StaticContainer.js.map +1 -1
  107. package/lib/typescript/lib/commonjs/skia/types/Data/Data.d.ts +1 -0
  108. package/lib/typescript/lib/commonjs/skia/web/JsiSkFont.d.ts +1 -1
  109. package/lib/typescript/lib/commonjs/skia/web/JsiSkParagraph.d.ts +2 -0
  110. package/lib/typescript/lib/commonjs/sksg/Container.web.d.ts +2 -2
  111. package/lib/typescript/lib/commonjs/sksg/Recorder/DrawingContext.d.ts +2 -0
  112. package/lib/typescript/lib/commonjs/sksg/Recorder/FrameScope.d.ts +17 -0
  113. package/lib/typescript/lib/commonjs/sksg/Recorder/FrameScope.native.d.ts +13 -0
  114. package/lib/typescript/lib/commonjs/sksg/Recorder/Recorder.d.ts +1 -0
  115. package/lib/typescript/lib/commonjs/sksg/StaticContainer.d.ts +2 -2
  116. package/lib/typescript/lib/module/mock/index.d.ts +1 -0
  117. package/lib/typescript/lib/module/skia/types/Data/Data.d.ts +1 -0
  118. package/lib/typescript/lib/module/skia/web/JsiSkFont.d.ts +1 -1
  119. package/lib/typescript/lib/module/skia/web/JsiSkParagraph.d.ts +2 -0
  120. package/lib/typescript/lib/module/sksg/Container.web.d.ts +2 -2
  121. package/lib/typescript/lib/module/sksg/Recorder/DrawingContext.d.ts +2 -0
  122. package/lib/typescript/lib/module/sksg/Recorder/FrameScope.d.ts +5 -0
  123. package/lib/typescript/lib/module/sksg/Recorder/FrameScope.native.d.ts +5 -0
  124. package/lib/typescript/lib/module/sksg/Recorder/Recorder.d.ts +1 -0
  125. package/lib/typescript/lib/module/sksg/StaticContainer.d.ts +2 -2
  126. package/lib/typescript/src/skia/core/Font.d.ts +21 -6
  127. package/lib/typescript/src/skia/types/Data/Data.d.ts +5 -4
  128. package/lib/typescript/src/skia/types/Paragraph/Paragraph.d.ts +62 -0
  129. package/lib/typescript/src/skia/web/JsiSkFont.d.ts +1 -1
  130. package/lib/typescript/src/skia/web/JsiSkParagraph.d.ts +3 -1
  131. package/lib/typescript/src/sksg/Recorder/DrawingContext.d.ts +2 -0
  132. package/lib/typescript/src/sksg/Recorder/FrameScope.d.ts +18 -0
  133. package/lib/typescript/src/sksg/Recorder/FrameScope.native.d.ts +10 -0
  134. package/lib/typescript/src/sksg/Recorder/Recorder.d.ts +3 -1
  135. package/lib/typescript/src/sksg/StaticContainer.d.ts +1 -0
  136. package/package.json +8 -2
  137. package/react-native-skia.podspec +18 -10
  138. package/src/Platform/Platform.ts +6 -7
  139. package/src/Platform/Platform.web.tsx +9 -8
  140. package/src/external/reanimated/useVideoLoading.ts +12 -2
  141. package/src/skia/core/Font.ts +34 -13
  142. package/src/skia/core/SVG.web.ts +5 -14
  143. package/src/skia/types/Data/Data.ts +14 -4
  144. package/src/skia/types/Paragraph/Paragraph.ts +67 -0
  145. package/src/skia/web/Host.ts +7 -0
  146. package/src/skia/web/JsiSkFont.ts +48 -4
  147. package/src/skia/web/JsiSkPaint.ts +5 -0
  148. package/src/skia/web/JsiSkParagraph.ts +9 -1
  149. package/src/sksg/Container.web.ts +31 -4
  150. package/src/sksg/Recorder/DrawingContext.ts +19 -6
  151. package/src/sksg/Recorder/FrameScope.native.ts +21 -0
  152. package/src/sksg/Recorder/FrameScope.ts +69 -0
  153. package/src/sksg/Recorder/Player.ts +1 -2
  154. package/src/sksg/Recorder/Recorder.ts +15 -1
  155. package/src/sksg/Recorder/commands/Drawing.ts +3 -3
  156. package/src/sksg/Recorder/commands/Shaders.ts +22 -16
  157. package/src/sksg/StaticContainer.ts +29 -2
@@ -74,12 +74,18 @@ static def resolveNodePackage(packageName, baseDir) {
74
74
  return proc.text.trim()
75
75
  }
76
76
 
77
- // Graphite is detected via a marker file created by install-skia-graphite, which
78
- // downloads its binaries directly into libs/. For the default (Ganesh) build the
79
- // binaries live in the react-native-skia-android npm package and are read in place.
77
+ // Graphite is detected via a marker file (created by install-skia-graphite for
78
+ // in-repo development, or shipped in the npm tarball for next-channel releases).
79
+ // The prebuilt binaries live in the react-native-skia-android npm package for the
80
+ // default (Ganesh) build and in react-native-skia-graphite-android for Graphite.
81
+ // In-repo Graphite development downloads them directly into libs/android instead,
82
+ // which takes precedence over the npm package when present.
80
83
  def useGraphite = file("${projectDir}/../libs/.graphite").exists()
84
+ def localGraphiteLibs = file("${projectDir}/../libs/android")
81
85
  def skiaLibsPath = useGraphite
82
- ? "${projectDir}/../libs/android"
86
+ ? (localGraphiteLibs.exists()
87
+ ? "${projectDir}/../libs/android"
88
+ : "${resolveNodePackage('react-native-skia-graphite-android', projectDir)}/libs")
83
89
  : "${resolveNodePackage('react-native-skia-android', projectDir)}/libs"
84
90
 
85
91
  logger.warn("react-native-skia: SK_GRAPHITE: ${useGraphite}")
@@ -42,6 +42,11 @@ private:
42
42
  _glConfig = _glDisplay->chooseConfig();
43
43
  _glContext = _glDisplay->makeContext(_glConfig, nullptr);
44
44
  _glSurface = _glDisplay->makePixelBufferSurface(_glConfig, 1, 1);
45
+ if (_glContext == nullptr || _glSurface == nullptr) {
46
+ RNSkLogger::logToConsole(
47
+ "Couldn't create the shared OpenGL context or surface");
48
+ return;
49
+ }
45
50
  _glContext->makeCurrent(_glSurface.get());
46
51
  }
47
52
  };
@@ -60,6 +65,10 @@ public:
60
65
 
61
66
  sk_sp<SkSurface> MakeOffscreen(int width, int height,
62
67
  bool useP3ColorSpace = false) {
68
+ if (_directContext == nullptr) {
69
+ return nullptr;
70
+ }
71
+
63
72
  auto colorType = kRGBA_8888_SkColorType;
64
73
 
65
74
  SkSurfaceProps props(0, kUnknown_SkPixelGeometry);
@@ -110,6 +119,9 @@ public:
110
119
  sk_sp<SkImage> MakeImageFromBuffer(void *buffer,
111
120
  bool requireKnownFormat = false) {
112
121
  #if __ANDROID_API__ >= 26
122
+ if (_directContext == nullptr) {
123
+ return nullptr;
124
+ }
113
125
  const AHardwareBuffer *hardwareBuffer =
114
126
  static_cast<AHardwareBuffer *>(buffer);
115
127
  DeleteImageProc deleteImageProc = nullptr;
@@ -181,6 +193,11 @@ public:
181
193
  // TODO: remove width, height
182
194
  std::unique_ptr<WindowContext> MakeWindow(ANativeWindow *window,
183
195
  bool highBitDepth = false) {
196
+ if (_directContext == nullptr) {
197
+ RNSkLogger::logToConsole(
198
+ "The OpenGL context is invalid, the surface will not be rendered");
199
+ return nullptr;
200
+ }
184
201
  auto display = OpenGLSharedContext::getInstance().getDisplay();
185
202
  if (highBitDepth) {
186
203
  // A 10-bit window surface would require the shared EGL context to be
@@ -196,7 +213,11 @@ public:
196
213
  }
197
214
 
198
215
  GrDirectContext *getDirectContext() { return _directContext.get(); }
199
- void makeCurrent() { _glContext->makeCurrent(_glSurface.get()); }
216
+ void makeCurrent() {
217
+ if (_glContext != nullptr) {
218
+ _glContext->makeCurrent(_glSurface.get());
219
+ }
220
+ }
200
221
 
201
222
  private:
202
223
  std::unique_ptr<gl::Context> _glContext;
@@ -209,12 +230,17 @@ private:
209
230
  auto glConfig = OpenGLSharedContext::getInstance().getConfig();
210
231
  _glContext = display->makeContext(glConfig, sharedContext);
211
232
  _glSurface = display->makePixelBufferSurface(glConfig, 1, 1);
212
- _glContext->makeCurrent(_glSurface.get());
233
+ if (_glContext == nullptr || _glSurface == nullptr ||
234
+ !_glContext->makeCurrent(_glSurface.get())) {
235
+ RNSkLogger::logToConsole(
236
+ "Couldn't create the OpenGL context, Skia rendering is disabled");
237
+ return;
238
+ }
213
239
  auto backendInterface = GrGLMakeNativeInterface();
214
240
  _directContext = GrDirectContexts::MakeGL(backendInterface);
215
241
 
216
242
  if (_directContext == nullptr) {
217
- throw std::runtime_error("GrDirectContexts::MakeGL failed");
243
+ RNSkLogger::logToConsole("GrDirectContexts::MakeGL failed");
218
244
  }
219
245
  }
220
246
  };
@@ -16,7 +16,12 @@ namespace RNSkia {
16
16
 
17
17
  sk_sp<SkSurface> OpenGLWindowContext::getSurface() {
18
18
  if (_skSurface == nullptr) {
19
- _glContext->makeCurrent(_glSurface.get());
19
+ if (_glSurface == nullptr || !_glContext->makeCurrent(_glSurface.get())) {
20
+ RNSkLogger::logToConsole(
21
+ "Couldn't create the EGL window surface, the surface will not be "
22
+ "rendered");
23
+ return nullptr;
24
+ }
20
25
  GLint stencil;
21
26
  glGetIntegerv(GL_STENCIL_BITS, &stencil);
22
27
 
@@ -52,7 +57,9 @@ sk_sp<SkSurface> OpenGLWindowContext::getSurface() {
52
57
  }
53
58
 
54
59
  void OpenGLWindowContext::present() {
55
- _glContext->makeCurrent(_glSurface.get());
60
+ if (_glSurface == nullptr || !_glContext->makeCurrent(_glSurface.get())) {
61
+ return;
62
+ }
56
63
  _directContext->flushAndSubmit();
57
64
  _glSurface->present();
58
65
  }
@@ -26,6 +26,9 @@ public:
26
26
  if (_context == EGL_NO_CONTEXT) {
27
27
  return false;
28
28
  }
29
+ if (surface == nullptr || !surface->isValid()) {
30
+ return false;
31
+ }
29
32
  const auto result =
30
33
  eglMakeCurrentIfNecessary(_display, surface->getHandle(),
31
34
  surface->getHandle(), _context) == EGL_TRUE;
@@ -17,7 +17,7 @@ public:
17
17
  }
18
18
  }
19
19
 
20
- bool isValid() { return _surface != EGL_NO_SURFACE; }
20
+ bool isValid() const { return _surface != EGL_NO_SURFACE; }
21
21
 
22
22
  const EGLSurface &getHandle() const { return _surface; }
23
23
 
@@ -8,6 +8,7 @@
8
8
  #include <jsi/jsi.h>
9
9
 
10
10
  #include "JsiSkCanvas.h"
11
+ #include "JsiSkFont.h"
11
12
  #include "JsiSkHostObjects.h"
12
13
  #include "JsiSkPath.h"
13
14
  #include "JsiSkRect.h"
@@ -141,6 +142,117 @@ public:
141
142
  return returnValue;
142
143
  }
143
144
 
145
+ JSI_HOST_FUNCTION(getPath) {
146
+ auto lineNumber =
147
+ static_cast<int>(getArgumentAsNumber(runtime, arguments, count, 0));
148
+ auto paragraph = getObject();
149
+ // Paragraph::getPath does not bounds-check the line number.
150
+ if (lineNumber < 0 ||
151
+ static_cast<size_t>(lineNumber) >= paragraph->lineNumber()) {
152
+ return jsi::Value::null();
153
+ }
154
+ // Paragraph::getPath resets its path builder after every visual run, so
155
+ // for lines shaped as multiple runs (e.g. through font fallback) it only
156
+ // returns the glyphs of the last run. Build the path from the per-glyph
157
+ // data exposed by extendedVisit instead.
158
+ SkPathBuilder builder;
159
+ paragraph->extendedVisit(
160
+ [lineNumber, &builder](
161
+ int visitedLine, const para::Paragraph::ExtendedVisitorInfo *info) {
162
+ if (visitedLine != lineNumber || info == nullptr) {
163
+ return;
164
+ }
165
+ struct Rec {
166
+ SkPathBuilder *builder;
167
+ SkPoint origin;
168
+ const SkPoint *pos;
169
+ } rec = {&builder, info->origin, info->positions};
170
+ info->font.getPaths(
171
+ {info->glyphs, static_cast<size_t>(info->count)},
172
+ [](const SkPath *src, const SkMatrix &mx, void *ctx) {
173
+ auto *rec = static_cast<Rec *>(ctx);
174
+ if (src != nullptr) {
175
+ SkMatrix total = mx;
176
+ total.postTranslate(rec->origin.fX + rec->pos->fX,
177
+ rec->origin.fY + rec->pos->fY);
178
+ rec->builder->addPath(*src, total);
179
+ }
180
+ rec->pos += 1;
181
+ },
182
+ &rec);
183
+ });
184
+ SkPath path = builder.detach();
185
+ auto hostObjectInstance =
186
+ std::make_shared<JsiSkPath>(getContext(), std::move(path));
187
+ return JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
188
+ runtime, hostObjectInstance, getContext());
189
+ }
190
+
191
+ JSI_HOST_FUNCTION(extendedVisit) {
192
+ auto visitorObject = getArgumentAsFunction(runtime, arguments, count, 0);
193
+ auto visitor = visitorObject.asFunction(runtime);
194
+ auto context = getContext();
195
+ getObject()->extendedVisit(
196
+ [&runtime, &visitor, &context](
197
+ int lineNumber, const para::Paragraph::ExtendedVisitorInfo *info) {
198
+ if (info == nullptr) {
199
+ // Signals the end of the line
200
+ visitor.call(runtime, static_cast<double>(lineNumber),
201
+ jsi::Value::null());
202
+ return;
203
+ }
204
+ auto value = jsi::Object(runtime);
205
+
206
+ auto fontInstance = std::make_shared<JsiSkFont>(context, info->font);
207
+ value.setProperty(runtime, "font",
208
+ JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE(
209
+ runtime, fontInstance, context));
210
+
211
+ auto origin = jsi::Object(runtime);
212
+ origin.setProperty(runtime, "x",
213
+ static_cast<double>(info->origin.x()));
214
+ origin.setProperty(runtime, "y",
215
+ static_cast<double>(info->origin.y()));
216
+ value.setProperty(runtime, "origin", origin);
217
+
218
+ auto advance = jsi::Object(runtime);
219
+ advance.setProperty(runtime, "width",
220
+ static_cast<double>(info->advance.width()));
221
+ advance.setProperty(runtime, "height",
222
+ static_cast<double>(info->advance.height()));
223
+ value.setProperty(runtime, "advance", advance);
224
+
225
+ auto size = info->count;
226
+ auto glyphs = jsi::Array(runtime, size);
227
+ auto positions = jsi::Array(runtime, size);
228
+ auto bounds = jsi::Array(runtime, size);
229
+ auto utf8Starts = jsi::Array(runtime, size);
230
+ for (int i = 0; i < size; ++i) {
231
+ glyphs.setValueAtIndex(runtime, i,
232
+ static_cast<double>(info->glyphs[i]));
233
+ auto position = jsi::Object(runtime);
234
+ position.setProperty(runtime, "x",
235
+ static_cast<double>(info->positions[i].x()));
236
+ position.setProperty(runtime, "y",
237
+ static_cast<double>(info->positions[i].y()));
238
+ positions.setValueAtIndex(runtime, i, position);
239
+ bounds.setValueAtIndex(
240
+ runtime, i,
241
+ JsiSkRect::toValue(runtime, context, info->bounds[i]));
242
+ utf8Starts.setValueAtIndex(
243
+ runtime, i, static_cast<double>(info->utf8Starts[i]));
244
+ }
245
+ value.setProperty(runtime, "glyphs", glyphs);
246
+ value.setProperty(runtime, "positions", positions);
247
+ value.setProperty(runtime, "bounds", bounds);
248
+ value.setProperty(runtime, "utf8Starts", utf8Starts);
249
+ value.setProperty(runtime, "flags", static_cast<double>(info->flags));
250
+
251
+ visitor.call(runtime, static_cast<double>(lineNumber), value);
252
+ });
253
+ return jsi::Value::undefined();
254
+ }
255
+
144
256
  JSI_HOST_FUNCTION(getRectsForPlaceholders) {
145
257
  std::vector<para::TextBox> placeholderInfos =
146
258
  getObject()->getRectsForPlaceholders();
@@ -169,6 +281,8 @@ public:
169
281
  getGlyphPositionAtCoordinate),
170
282
  JSI_EXPORT_FUNC(JsiSkParagraph, getRectsForRange),
171
283
  JSI_EXPORT_FUNC(JsiSkParagraph, getLineMetrics),
284
+ JSI_EXPORT_FUNC(JsiSkParagraph, getPath),
285
+ JSI_EXPORT_FUNC(JsiSkParagraph, extendedVisit),
172
286
  JSI_EXPORT_FUNC(JsiSkParagraph, dispose))
173
287
 
174
288
  size_t getMemoryPressure() const override { return 1024 * 1024; }
@@ -79,6 +79,10 @@ public:
79
79
  }
80
80
  auto result =
81
81
  context->makeContextFromNativeSurface(surface, width, height);
82
+ if (result == nullptr) {
83
+ throw std::runtime_error(
84
+ "Couldn't create a Skia context from the native surface");
85
+ }
82
86
  // Return the newly constructed object
83
87
  auto hostObjectInstance =
84
88
  std::make_shared<JsiSkiaContext>(context, std::move(result));
@@ -84,6 +84,9 @@ public:
84
84
  Returns a snapshot of the current surface/canvas
85
85
  */
86
86
  sk_sp<SkImage> makeSnapshot(SkRect *bounds) {
87
+ if (_surface == nullptr) {
88
+ return nullptr;
89
+ }
87
90
  sk_sp<SkImage> image;
88
91
  if (bounds != nullptr) {
89
92
  SkIRect b =
@@ -120,6 +123,9 @@ public:
120
123
  Render to a canvas
121
124
  */
122
125
  bool renderToCanvas(const std::function<void(SkCanvas *)> &cb) override {
126
+ if (_surface == nullptr) {
127
+ return false;
128
+ }
123
129
  cb(_surface->getCanvas());
124
130
  return true;
125
131
  };
@@ -10,8 +10,11 @@ const Platform = exports.Platform = {
10
10
  OS: _reactNative.Platform.OS,
11
11
  PixelRatio: _reactNative.PixelRatio.get(),
12
12
  resolveAsset: source => {
13
- // eslint-disable-next-line no-nested-ternary
14
- return (0, _types.isRNModule)(source) ? _reactNative.Image.resolveAssetSource(source).uri : "uri" in source ? source.uri : source.default;
13
+ const asset = (0, _types.unwrapModule)(source);
14
+ if (typeof asset === "string") {
15
+ return asset;
16
+ }
17
+ return (0, _types.isRNModule)(asset) ? _reactNative.Image.resolveAssetSource(asset).uri : asset.uri;
15
18
  },
16
19
  findNodeHandle: _reactNative.findNodeHandle,
17
20
  View: _reactNative.View
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_types","Platform","exports","OS","RNPlatform","PixelRatio","get","resolveAsset","source","isRNModule","Image","resolveAssetSource","uri","default","findNodeHandle","View"],"sources":["Platform.ts"],"sourcesContent":["import {\n Image,\n PixelRatio,\n Platform as RNPlatform,\n findNodeHandle,\n View,\n} from \"react-native\";\n\nimport type { DataModule } from \"../skia/types\";\nimport { isRNModule } from \"../skia/types\";\n\nimport type { IPlatform } from \"./IPlatform\";\n\nexport const Platform: IPlatform = {\n OS: RNPlatform.OS,\n PixelRatio: PixelRatio.get(),\n resolveAsset: (source: DataModule) => {\n // eslint-disable-next-line no-nested-ternary\n return isRNModule(source)\n ? Image.resolveAssetSource(source).uri\n : \"uri\" in source\n ? source.uri\n : source.default;\n },\n findNodeHandle,\n View,\n};\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AASA,IAAAC,MAAA,GAAAD,OAAA;AAIO,MAAME,QAAmB,GAAAC,OAAA,CAAAD,QAAA,GAAG;EACjCE,EAAE,EAAEC,qBAAU,CAACD,EAAE;EACjBE,UAAU,EAAEA,uBAAU,CAACC,GAAG,CAAC,CAAC;EAC5BC,YAAY,EAAGC,MAAkB,IAAK;IACpC;IACA,OAAO,IAAAC,iBAAU,EAACD,MAAM,CAAC,GACrBE,kBAAK,CAACC,kBAAkB,CAACH,MAAM,CAAC,CAACI,GAAG,GACpC,KAAK,IAAIJ,MAAM,GACbA,MAAM,CAACI,GAAG,GACVJ,MAAM,CAACK,OAAO;EACtB,CAAC;EACDC,cAAc,EAAdA,2BAAc;EACdC,IAAI,EAAJA;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","_types","Platform","exports","OS","RNPlatform","PixelRatio","get","resolveAsset","source","asset","unwrapModule","isRNModule","Image","resolveAssetSource","uri","findNodeHandle","View"],"sources":["Platform.ts"],"sourcesContent":["import {\n Image,\n PixelRatio,\n Platform as RNPlatform,\n findNodeHandle,\n View,\n} from \"react-native\";\n\nimport type { DataModule } from \"../skia/types\";\nimport { isRNModule, unwrapModule } from \"../skia/types\";\n\nimport type { IPlatform } from \"./IPlatform\";\n\nexport const Platform: IPlatform = {\n OS: RNPlatform.OS,\n PixelRatio: PixelRatio.get(),\n resolveAsset: (source: DataModule) => {\n const asset = unwrapModule(source);\n if (typeof asset === \"string\") {\n return asset;\n }\n return isRNModule(asset) ? Image.resolveAssetSource(asset).uri : asset.uri;\n },\n findNodeHandle,\n View,\n};\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AASA,IAAAC,MAAA,GAAAD,OAAA;AAIO,MAAME,QAAmB,GAAAC,OAAA,CAAAD,QAAA,GAAG;EACjCE,EAAE,EAAEC,qBAAU,CAACD,EAAE;EACjBE,UAAU,EAAEA,uBAAU,CAACC,GAAG,CAAC,CAAC;EAC5BC,YAAY,EAAGC,MAAkB,IAAK;IACpC,MAAMC,KAAK,GAAG,IAAAC,mBAAY,EAACF,MAAM,CAAC;IAClC,IAAI,OAAOC,KAAK,KAAK,QAAQ,EAAE;MAC7B,OAAOA,KAAK;IACd;IACA,OAAO,IAAAE,iBAAU,EAACF,KAAK,CAAC,GAAGG,kBAAK,CAACC,kBAAkB,CAACJ,KAAK,CAAC,CAACK,GAAG,GAAGL,KAAK,CAACK,GAAG;EAC5E,CAAC;EACDC,cAAc,EAAdA,2BAAc;EACdC,IAAI,EAAJA;AACF,CAAC","ignoreList":[]}
@@ -44,8 +44,12 @@ const Platform = exports.Platform = {
44
44
  PixelRatio: typeof window !== "undefined" ? window.devicePixelRatio : 1,
45
45
  // window is not defined on node
46
46
  resolveAsset: source => {
47
- if ((0, _types.isRNModule)(source)) {
48
- if (typeof source === "number" && typeof require === "function") {
47
+ const asset = (0, _types.unwrapModule)(source);
48
+ if (typeof asset === "string") {
49
+ return asset;
50
+ }
51
+ if ((0, _types.isRNModule)(asset)) {
52
+ if (typeof require === "function") {
49
53
  const {
50
54
  getAssetByID
51
55
  } = require("react-native/Libraries/Image/AssetRegistry");
@@ -53,16 +57,13 @@ const Platform = exports.Platform = {
53
57
  httpServerLocation,
54
58
  name,
55
59
  type
56
- } = getAssetByID(source);
60
+ } = getAssetByID(asset);
57
61
  const uri = `${httpServerLocation}/${name}.${type}`;
58
62
  return uri;
59
63
  }
60
64
  throw new Error("Asset source is a number - this is not supported on the web");
61
65
  }
62
- if ("uri" in source) {
63
- return source.uri;
64
- }
65
- return source.default;
66
+ return asset.uri;
66
67
  },
67
68
  findNodeHandle: () => {
68
69
  throw new Error("findNodeHandle is not supported on the web");
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_types","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","View","children","style","rawStyle","useMemo","cssStyles","alignItems","backgroundColor","border","boxSizing","display","flexBasis","flexDirection","flexShrink","listStyle","margin","minHeight","minWidth","padding","position","textDecoration","zIndex","createElement","Platform","exports","OS","PixelRatio","window","devicePixelRatio","resolveAsset","source","isRNModule","getAssetByID","httpServerLocation","name","type","uri","Error","findNodeHandle"],"sources":["Platform.web.tsx"],"sourcesContent":["import type { CSSProperties } from \"react\";\nimport React, { useMemo } from \"react\";\nimport type { ViewComponent, ViewProps } from \"react-native\";\n\nimport type { DataModule } from \"../skia/types\";\nimport { isRNModule } from \"../skia/types\";\n\nimport type { IPlatform } from \"./IPlatform\";\n\n// Layout is observed by the views themselves (see SkiaPictureView.web.tsx):\n// this shim only reproduces react-native-web's default View styling.\nconst View = (({ children, style: rawStyle }: ViewProps) => {\n const style = useMemo(() => (rawStyle ?? {}) as CSSProperties, [rawStyle]);\n const cssStyles = useMemo(() => {\n return {\n alignItems: \"stretch\" as const,\n backgroundColor: \"transparent\" as const,\n border: \"0 solid black\" as const,\n boxSizing: \"border-box\" as const,\n display: \"flex\" as const,\n flexBasis: \"auto\" as const,\n flexDirection: \"column\" as const,\n flexShrink: 0,\n listStyle: \"none\" as const,\n margin: 0,\n minHeight: 0,\n minWidth: 0,\n padding: 0,\n position: \"relative\" as const,\n textDecoration: \"none\" as const,\n zIndex: 0,\n ...style,\n };\n }, [style]);\n\n return <div style={cssStyles}>{children}</div>;\n}) as unknown as typeof ViewComponent;\n\nexport const Platform: IPlatform = {\n OS: \"web\",\n PixelRatio: typeof window !== \"undefined\" ? window.devicePixelRatio : 1, // window is not defined on node\n resolveAsset: (source: DataModule) => {\n if (isRNModule(source)) {\n if (typeof source === \"number\" && typeof require === \"function\") {\n const {\n getAssetByID,\n } = require(\"react-native/Libraries/Image/AssetRegistry\");\n const { httpServerLocation, name, type } = getAssetByID(source);\n const uri = `${httpServerLocation}/${name}.${type}`;\n return uri;\n }\n throw new Error(\n \"Asset source is a number - this is not supported on the web\"\n );\n }\n if (\"uri\" in source) {\n return source.uri;\n }\n return source.default;\n },\n findNodeHandle: () => {\n throw new Error(\"findNode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,GAAG,GAAG,GAAGH,kBAAkB,IAAIC,IAAI,IAAIC,IAAI,EAAE;QACnD,OAAOC,GAAG;MACZ;MACA,MAAM,IAAIC,KAAK,CACb,6DACF,CAAC;IACH;IACA,IAAI,KAAK,IAAIP,MAAM,EAAE;MACnB,OAAOA,MAAM,CAACM,GAAG;IACnB;IACA,OAAON,MAAM,CAACvC,OAAO;EACvB,CAAC;EACD+C,cAAc,EAAEA,CAAA,KAAM;IACpB,MAAM,IAAID,KAAK,CAAC,4CAA4C,CAAC;EAC/D,CAAC;EACDrC;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_types","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","View","children","style","rawStyle","useMemo","cssStyles","alignItems","backgroundColor","border","boxSizing","display","flexBasis","flexDirection","flexShrink","listStyle","margin","minHeight","minWidth","padding","position","textDecoration","zIndex","createElement","Platform","exports","OS","PixelRatio","window","devicePixelRatio","resolveAsset","source","asset","unwrapModule","isRNModule","getAssetByID","httpServerLocation","name","type","uri","Error","findNodeHandle"],"sources":["Platform.web.tsx"],"sourcesContent":["import type { CSSProperties } from \"react\";\nimport React, { useMemo } from \"react\";\nimport type { ViewComponent, ViewProps } from \"react-native\";\n\nimport type { DataModule } from \"../skia/types\";\nimport { isRNModule, unwrapModule } from \"../skia/types\";\n\nimport type { IPlatform } from \"./IPlatform\";\n\n// Layout is observed by the views themselves (see SkiaPictureView.web.tsx):\n// this shim only reproduces react-native-web's default View styling.\nconst View = (({ children, style: rawStyle }: ViewProps) => {\n const style = useMemo(() => (rawStyle ?? {}) as CSSProperties, [rawStyle]);\n const cssStyles = useMemo(() => {\n return {\n alignItems: \"stretch\" as const,\n backgroundColor: \"transparent\" as const,\n border: \"0 solid black\" as const,\n boxSizing: \"border-box\" as const,\n display: \"flex\" as const,\n flexBasis: \"auto\" as const,\n flexDirection: \"column\" as const,\n flexShrink: 0,\n listStyle: \"none\" as const,\n margin: 0,\n minHeight: 0,\n minWidth: 0,\n padding: 0,\n position: \"relative\" as const,\n textDecoration: \"none\" as const,\n zIndex: 0,\n ...style,\n };\n }, [style]);\n\n return <div style={cssStyles}>{children}</div>;\n}) as unknown as typeof ViewComponent;\n\nexport const Platform: IPlatform = {\n OS: \"web\",\n PixelRatio: typeof window !== \"undefined\" ? window.devicePixelRatio : 1, // window is not defined on node\n resolveAsset: (source: DataModule) => {\n const asset = unwrapModule(source);\n if (typeof asset === \"string\") {\n return asset;\n }\n if (isRNModule(asset)) {\n if (typeof require === \"function\") {\n const {\n getAssetByID,\n } = require(\"react-native/Libraries/Image/AssetRegistry\");\n const { httpServerLocation, name, type } = getAssetByID(asset);\n const uri = `${httpServerLocation}/${name}.${type}`;\n return uri;\n }\n throw new Error(\n \"Asset source is a number - this is not supported on the web\"\n );\n }\n return asset.uri;\n },\n findNodeHandle: () => {\n throw new Error(\"findNodeHandle is not supported on the web\");\n },\n View,\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAIA,IAAAC,MAAA,GAAAD,OAAA;AAAyD,SAAAD,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAL,uBAAA,YAAAA,CAAAG,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,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zB,MAAA,CAAAc,OAAA,CAAA+B,aAAA;IAAKpB,KAAK,EAAEG;EAAU,GAAEJ,QAAc,CAAC;AAChD,CAAqC;AAE9B,MAAMsB,QAAmB,GAAAC,OAAA,CAAAD,QAAA,GAAG;EACjCE,EAAE,EAAE,KAAK;EACTC,UAAU,EAAE,OAAOC,MAAM,KAAK,WAAW,GAAGA,MAAM,CAACC,gBAAgB,GAAG,CAAC;EAAE;EACzEC,YAAY,EAAGC,MAAkB,IAAK;IACpC,MAAMC,KAAK,GAAG,IAAAC,mBAAY,EAACF,MAAM,CAAC;IAClC,IAAI,OAAOC,KAAK,KAAK,QAAQ,EAAE;MAC7B,OAAOA,KAAK;IACd;IACA,IAAI,IAAAE,iBAAU,EAACF,KAAK,CAAC,EAAE;MACrB,IAAI,OAAOpD,OAAO,KAAK,UAAU,EAAE;QACjC,MAAM;UACJuD;QACF,CAAC,GAAGvD,OAAO,CAAC,4CAA4C,CAAC;QACzD,MAAM;UAAEwD,kBAAkB;UAAEC,IAAI;UAAEC;QAAK,CAAC,GAAGH,YAAY,CAACH,KAAK,CAAC;QAC9D,MAAMO,GAAG,GAAG,GAAGH,kBAAkB,IAAIC,IAAI,IAAIC,IAAI,EAAE;QACnD,OAAOC,GAAG;MACZ;MACA,MAAM,IAAIC,KAAK,CACb,6DACF,CAAC;IACH;IACA,OAAOR,KAAK,CAACO,GAAG;EAClB,CAAC;EACDE,cAAc,EAAEA,CAAA,KAAM;IACpB,MAAM,IAAID,KAAK,CAAC,4CAA4C,CAAC;EAC/D,CAAC;EACDvC;AACF,CAAC","ignoreList":[]}
@@ -8,7 +8,16 @@ var _react = require("react");
8
8
  var _skia = require("../../skia");
9
9
  var _ReanimatedProxy = _interopRequireDefault(require("./ReanimatedProxy"));
10
10
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
- const runtime = _ReanimatedProxy.default.createWorkletRuntime("video-metadata-runtime");
11
+ // Created lazily: accessing the proxy at module scope would require
12
+ // react-native-reanimated as soon as the package is imported, and would spawn
13
+ // the runtime even for apps that never load a video.
14
+ let runtime;
15
+ const getRuntime = () => {
16
+ if (runtime === undefined) {
17
+ runtime = _ReanimatedProxy.default.createWorkletRuntime("video-metadata-runtime");
18
+ }
19
+ return runtime;
20
+ };
12
21
  const useVideoLoading = source => {
13
22
  const {
14
23
  runOnJS
@@ -22,7 +31,7 @@ const useVideoLoading = source => {
22
31
  }, [runOnJS]);
23
32
  (0, _react.useEffect)(() => {
24
33
  if (source) {
25
- _ReanimatedProxy.default.runOnRuntime(runtime, cb)(source);
34
+ _ReanimatedProxy.default.runOnRuntime(getRuntime(), cb)(source);
26
35
  }
27
36
  }, [cb, source]);
28
37
  return video;
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_skia","_ReanimatedProxy","_interopRequireDefault","e","__esModule","default","runtime","Rea","createWorkletRuntime","useVideoLoading","source","runOnJS","video","setVideo","useState","cb","useCallback","src","vid","Skia","Video","useEffect","runOnRuntime","exports"],"sources":["useVideoLoading.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from \"react\";\n\nimport type { Video } from \"../../skia/types\";\nimport { Skia } from \"../../skia\";\n\nimport Rea from \"./ReanimatedProxy\";\n\nconst runtime = Rea.createWorkletRuntime(\"video-metadata-runtime\");\n\ntype VideoSource = string | null;\n\nexport const useVideoLoading = (source: VideoSource) => {\n const { runOnJS } = Rea;\n const [video, setVideo] = useState<Video | null>(null);\n const cb = useCallback(\n (src: string) => {\n \"worklet\";\n const vid = Skia.Video(src) as Video;\n runOnJS(setVideo)(vid);\n },\n [runOnJS]\n );\n useEffect(() => {\n if (source) {\n Rea.runOnRuntime(runtime, cb)(source);\n }\n }, [cb, source]);\n return video;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,gBAAA,GAAAC,sBAAA,CAAAH,OAAA;AAAoC,SAAAG,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEpC,MAAMG,OAAO,GAAGC,wBAAG,CAACC,oBAAoB,CAAC,wBAAwB,CAAC;AAI3D,MAAMC,eAAe,GAAIC,MAAmB,IAAK;EACtD,MAAM;IAAEC;EAAQ,CAAC,GAAGJ,wBAAG;EACvB,MAAM,CAACK,KAAK,EAAEC,QAAQ,CAAC,GAAG,IAAAC,eAAQ,EAAe,IAAI,CAAC;EACtD,MAAMC,EAAE,GAAG,IAAAC,kBAAW,EACnBC,GAAW,IAAK;IACf,SAAS;;IACT,MAAMC,GAAG,GAAGC,UAAI,CAACC,KAAK,CAACH,GAAG,CAAU;IACpCN,OAAO,CAACE,QAAQ,CAAC,CAACK,GAAG,CAAC;EACxB,CAAC,EACD,CAACP,OAAO,CACV,CAAC;EACD,IAAAU,gBAAS,EAAC,MAAM;IACd,IAAIX,MAAM,EAAE;MACVH,wBAAG,CAACe,YAAY,CAAChB,OAAO,EAAES,EAAE,CAAC,CAACL,MAAM,CAAC;IACvC;EACF,CAAC,EAAE,CAACK,EAAE,EAAEL,MAAM,CAAC,CAAC;EAChB,OAAOE,KAAK;AACd,CAAC;AAACW,OAAA,CAAAd,eAAA,GAAAA,eAAA","ignoreList":[]}
1
+ {"version":3,"names":["_react","require","_skia","_ReanimatedProxy","_interopRequireDefault","e","__esModule","default","runtime","getRuntime","undefined","Rea","createWorkletRuntime","useVideoLoading","source","runOnJS","video","setVideo","useState","cb","useCallback","src","vid","Skia","Video","useEffect","runOnRuntime","exports"],"sources":["useVideoLoading.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from \"react\";\nimport type { WorkletRuntime } from \"react-native-reanimated\";\n\nimport type { Video } from \"../../skia/types\";\nimport { Skia } from \"../../skia\";\n\nimport Rea from \"./ReanimatedProxy\";\n\n// Created lazily: accessing the proxy at module scope would require\n// react-native-reanimated as soon as the package is imported, and would spawn\n// the runtime even for apps that never load a video.\nlet runtime: WorkletRuntime | undefined;\nconst getRuntime = () => {\n if (runtime === undefined) {\n runtime = Rea.createWorkletRuntime(\"video-metadata-runtime\");\n }\n return runtime;\n};\n\ntype VideoSource = string | null;\n\nexport const useVideoLoading = (source: VideoSource) => {\n const { runOnJS } = Rea;\n const [video, setVideo] = useState<Video | null>(null);\n const cb = useCallback(\n (src: string) => {\n \"worklet\";\n const vid = Skia.Video(src) as Video;\n runOnJS(setVideo)(vid);\n },\n [runOnJS]\n );\n useEffect(() => {\n if (source) {\n Rea.runOnRuntime(getRuntime(), cb)(source);\n }\n }, [cb, source]);\n return video;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAIA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,gBAAA,GAAAC,sBAAA,CAAAH,OAAA;AAAoC,SAAAG,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEpC;AACA;AACA;AACA,IAAIG,OAAmC;AACvC,MAAMC,UAAU,GAAGA,CAAA,KAAM;EACvB,IAAID,OAAO,KAAKE,SAAS,EAAE;IACzBF,OAAO,GAAGG,wBAAG,CAACC,oBAAoB,CAAC,wBAAwB,CAAC;EAC9D;EACA,OAAOJ,OAAO;AAChB,CAAC;AAIM,MAAMK,eAAe,GAAIC,MAAmB,IAAK;EACtD,MAAM;IAAEC;EAAQ,CAAC,GAAGJ,wBAAG;EACvB,MAAM,CAACK,KAAK,EAAEC,QAAQ,CAAC,GAAG,IAAAC,eAAQ,EAAe,IAAI,CAAC;EACtD,MAAMC,EAAE,GAAG,IAAAC,kBAAW,EACnBC,GAAW,IAAK;IACf,SAAS;;IACT,MAAMC,GAAG,GAAGC,UAAI,CAACC,KAAK,CAACH,GAAG,CAAU;IACpCN,OAAO,CAACE,QAAQ,CAAC,CAACK,GAAG,CAAC;EACxB,CAAC,EACD,CAACP,OAAO,CACV,CAAC;EACD,IAAAU,gBAAS,EAAC,MAAM;IACd,IAAIX,MAAM,EAAE;MACVH,wBAAG,CAACe,YAAY,CAACjB,UAAU,CAAC,CAAC,EAAEU,EAAE,CAAC,CAACL,MAAM,CAAC;IAC5C;EACF,CAAC,EAAE,CAACK,EAAE,EAAEL,MAAM,CAAC,CAAC;EAChB,OAAOE,KAAK;AACd,CAAC;AAACW,OAAA,CAAAd,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -1,18 +1,33 @@
1
+ import { FontSlant, FontWeight } from "../types";
1
2
  import type { DataModule, DataSourceParam, SkFontMgr } from "../types";
2
3
  import type { SkTypefaceFontProvider } from "../types/Paragraph/TypefaceFontProvider";
3
4
  /**
4
5
  * Returns a Skia Font object
5
6
  * */
6
7
  export declare const useFont: (font: DataSourceParam, size?: number, onError?: (err: Error) => void) => import("../types").SkFont | null;
7
- type Slant = "normal" | "italic" | "oblique";
8
- type Weight = "normal" | "bold" | "100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900";
9
- interface RNFontStyle {
8
+ /**
9
+ * React Native style font slant, as found in the `fontStyle` property of
10
+ * `TextStyle`. The Skia {@link FontSlant} enum is accepted as well.
11
+ */
12
+ export type RNFontSlant = "normal" | "italic" | "oblique" | FontSlant;
13
+ /**
14
+ * React Native style font weight, as found in the `fontWeight` property of
15
+ * `TextStyle`. Numeric weights such as the {@link FontWeight} enum values
16
+ * used by the Paragraph API are accepted as well.
17
+ */
18
+ export type RNFontWeight = "normal" | "bold" | "100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900" | FontWeight;
19
+ /**
20
+ * Font style accepted by {@link matchFont}.
21
+ * `fontStyle` and `fontWeight` accept both the React Native string values
22
+ * and the Skia enums ({@link FontSlant} and {@link FontWeight}), so the same
23
+ * values can be shared with the Paragraph API.
24
+ */
25
+ export interface RNFontStyle {
10
26
  fontFamily: string;
11
27
  fontSize: number;
12
- fontStyle: Slant;
13
- fontWeight: Weight;
28
+ fontStyle: RNFontSlant;
29
+ fontWeight: RNFontWeight;
14
30
  }
15
31
  export declare const matchFont: (inputStyle?: Partial<RNFontStyle>, fontMgr?: SkFontMgr) => import("../types").SkFont;
16
32
  export declare const listFontFamilies: (fontMgr?: SkFontMgr) => string[];
17
33
  export declare const useFonts: (sources: Record<string, DataModule[]>) => SkTypefaceFontProvider | null;
18
- export {};
@@ -26,6 +26,24 @@ const useFont = (font, size = defaultFontSize, onError) => {
26
26
  }
27
27
  }, [size, typeface]);
28
28
  };
29
+
30
+ /**
31
+ * React Native style font slant, as found in the `fontStyle` property of
32
+ * `TextStyle`. The Skia {@link FontSlant} enum is accepted as well.
33
+ */
34
+
35
+ /**
36
+ * React Native style font weight, as found in the `fontWeight` property of
37
+ * `TextStyle`. Numeric weights such as the {@link FontWeight} enum values
38
+ * used by the Paragraph API are accepted as well.
39
+ */
40
+
41
+ /**
42
+ * Font style accepted by {@link matchFont}.
43
+ * `fontStyle` and `fontWeight` accept both the React Native string values
44
+ * and the Skia enums ({@link FontSlant} and {@link FontWeight}), so the same
45
+ * values can be shared with the Paragraph API.
46
+ */
29
47
  exports.useFont = useFont;
30
48
  const defaultFontStyle = {
31
49
  fontFamily: "System",
@@ -34,7 +52,9 @@ const defaultFontStyle = {
34
52
  fontWeight: "normal"
35
53
  };
36
54
  const slant = s => {
37
- if (s === "italic") {
55
+ if (typeof s === "number") {
56
+ return s;
57
+ } else if (s === "italic") {
38
58
  return _types.FontSlant.Italic;
39
59
  } else if (s === "oblique") {
40
60
  return _types.FontSlant.Oblique;
@@ -45,11 +65,11 @@ const slant = s => {
45
65
  const weight = fontWeight => {
46
66
  switch (fontWeight) {
47
67
  case "normal":
48
- return 400;
68
+ return _types.FontWeight.Normal;
49
69
  case "bold":
50
- return 700;
70
+ return _types.FontWeight.Bold;
51
71
  default:
52
- return parseInt(fontWeight, 10);
72
+ return typeof fontWeight === "number" ? fontWeight : parseInt(fontWeight, 10);
53
73
  }
54
74
  };
55
75
  const matchFont = (inputStyle = {}, fontMgr = _Skia.Skia.FontMgr.System()) => {
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_Skia","_types","_Platform","_Typeface","defaultFontSize","useFont","font","size","onError","typeface","useTypeface","useMemo","Skia","Font","exports","defaultFontStyle","fontFamily","fontSize","fontStyle","fontWeight","slant","s","FontSlant","Italic","Oblique","Upright","weight","parseInt","matchFont","inputStyle","fontMgr","FontMgr","System","style","width","matchFamilyStyle","listFontFamilies","families","Set","i","countFamilies","add","getFamilyName","Array","from","loadTypefaces","typefacesToLoad","promises","Object","keys","flatMap","familyName","map","typefaceToLoad","Data","fromURI","Platform","resolveAsset","then","data","tf","Typeface","MakeFreeTypeFaceFromData","Error","Promise","all","useFonts","sources","setFontMgr","useState","useEffect","result","fMgr","TypefaceFontProvider","Make","forEach","registerFont"],"sources":["Font.ts"],"sourcesContent":["/*global SkiaApi*/\nimport { useEffect, useMemo, useState } from \"react\";\n\nimport { Skia } from \"../Skia\";\nimport { FontSlant } from \"../types\";\nimport type { DataModule, DataSourceParam, SkFontMgr } from \"../types\";\nimport { Platform } from \"../../Platform\";\nimport type { SkTypefaceFontProvider } from \"../types/Paragraph/TypefaceFontProvider\";\n\nimport { useTypeface } from \"./Typeface\";\n\nconst defaultFontSize = 14;\n\n/**\n * Returns a Skia Font object\n * */\nexport const useFont = (\n font: DataSourceParam,\n size = defaultFontSize,\n onError?: (err: Error) => void\n) => {\n const typeface = useTypeface(font, onError);\n return useMemo(() => {\n if (typeface) {\n return Skia.Font(typeface, size);\n } else {\n return null;\n }\n }, [size, typeface]);\n};\n\ntype Slant = \"normal\" | \"italic\" | \"oblique\";\ntype Weight =\n | \"normal\"\n | \"bold\"\n | \"100\"\n | \"200\"\n | \"300\"\n | \"400\"\n | \"500\"\n | \"600\"\n | \"700\"\n | \"800\"\n | \"900\";\n\ninterface RNFontStyle {\n fontFamily: string;\n fontSize: number;\n fontStyle: Slant;\n fontWeight: Weight;\n}\n\nconst defaultFontStyle: RNFontStyle = {\n fontFamily: \"System\",\n fontSize: defaultFontSize,\n fontStyle: \"normal\",\n fontWeight: \"normal\",\n};\n\nconst slant = (s: Slant) => {\n if (s === \"italic\") {\n return FontSlant.Italic;\n } else if (s === \"oblique\") {\n return FontSlant.Oblique;\n } else {\n return FontSlant.Upright;\n }\n};\n\nconst weight = (fontWeight: Weight) => {\n switch (fontWeight) {\n case \"normal\":\n return 400;\n case \"bold\":\n return 700;\n default:\n return parseInt(fontWeight, 10);\n }\n};\n\nexport const matchFont = (\n inputStyle: Partial<RNFontStyle> = {},\n fontMgr: SkFontMgr = Skia.FontMgr.System()\n) => {\n const fontStyle = {\n ...defaultFontStyle,\n ...inputStyle,\n };\n const style = {\n weight: weight(fontStyle.fontWeight),\n width: 5,\n slant: slant(fontStyle.fontStyle),\n };\n const typeface = fontMgr.matchFamilyStyle(fontStyle.fontFamily, style);\n return Skia.Font(typeface, fontStyle.fontSize);\n};\n\nexport const listFontFamilies = (\n fontMgr: SkFontMgr = Skia.FontMgr.System()\n) => {\n const families = new Set<string>();\n for (let i = 0; i < fontMgr.countFamilies(); i++) {\n families.add(fontMgr.getFamilyName(i));\n }\n return Array.from(families);\n};\n\nconst loadTypefaces = (typefacesToLoad: Record<string, DataModule[]>) => {\n const promises = Object.keys(typefacesToLoad).flatMap((familyName) => {\n return typefacesToLoad[familyName].map((typefaceToLoad) => {\n return Skia.Data.fromURI(Platform.resolveAsset(typefaceToLoad)).then(\n (data) => {\n const tf = Skia.Typeface.MakeFreeTypeFaceFromData(data);\n if (tf === null) {\n throw new Error(`Couldn't create typeface for ${familyName}`);\n }\n return [familyName, tf] as const;\n }\n );\n });\n });\n return Promise.all(promises);\n};\n\nexport const useFonts = (sources: Record<string, DataModule[]>) => {\n const [fontMgr, setFontMgr] = useState<null | SkTypefaceFontProvider>(null);\n\n useEffect(() => {\n loadTypefaces(sources).then((result) => {\n const fMgr = Skia.TypefaceFontProvider.Make();\n result.forEach(([familyName, typeface]) => {\n fMgr.registerFont(typeface, familyName);\n });\n setFontMgr(fMgr);\n });\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_types","_Platform","_Typeface","defaultFontSize","useFont","font","size","onError","typeface","useTypeface","useMemo","Skia","Font","exports","defaultFontStyle","fontFamily","fontSize","fontStyle","fontWeight","slant","s","FontSlant","Italic","Oblique","Upright","weight","FontWeight","Normal","Bold","parseInt","matchFont","inputStyle","fontMgr","FontMgr","System","style","width","matchFamilyStyle","listFontFamilies","families","Set","i","countFamilies","add","getFamilyName","Array","from","loadTypefaces","typefacesToLoad","promises","Object","keys","flatMap","familyName","map","typefaceToLoad","Data","fromURI","Platform","resolveAsset","then","data","tf","Typeface","MakeFreeTypeFaceFromData","Error","Promise","all","useFonts","sources","setFontMgr","useState","useEffect","result","fMgr","TypefaceFontProvider","Make","forEach","registerFont"],"sources":["Font.ts"],"sourcesContent":["/*global SkiaApi*/\nimport { useEffect, useMemo, useState } from \"react\";\n\nimport { Skia } from \"../Skia\";\nimport { FontSlant, FontWeight } from \"../types\";\nimport type { DataModule, DataSourceParam, SkFontMgr } from \"../types\";\nimport { Platform } from \"../../Platform\";\nimport type { SkTypefaceFontProvider } from \"../types/Paragraph/TypefaceFontProvider\";\n\nimport { useTypeface } from \"./Typeface\";\n\nconst defaultFontSize = 14;\n\n/**\n * Returns a Skia Font object\n * */\nexport const useFont = (\n font: DataSourceParam,\n size = defaultFontSize,\n onError?: (err: Error) => void\n) => {\n const typeface = useTypeface(font, onError);\n return useMemo(() => {\n if (typeface) {\n return Skia.Font(typeface, size);\n } else {\n return null;\n }\n }, [size, typeface]);\n};\n\n/**\n * React Native style font slant, as found in the `fontStyle` property of\n * `TextStyle`. The Skia {@link FontSlant} enum is accepted as well.\n */\nexport type RNFontSlant = \"normal\" | \"italic\" | \"oblique\" | FontSlant;\n\n/**\n * React Native style font weight, as found in the `fontWeight` property of\n * `TextStyle`. Numeric weights such as the {@link FontWeight} enum values\n * used by the Paragraph API are accepted as well.\n */\nexport type RNFontWeight =\n | \"normal\"\n | \"bold\"\n | \"100\"\n | \"200\"\n | \"300\"\n | \"400\"\n | \"500\"\n | \"600\"\n | \"700\"\n | \"800\"\n | \"900\"\n | FontWeight;\n\n/**\n * Font style accepted by {@link matchFont}.\n * `fontStyle` and `fontWeight` accept both the React Native string values\n * and the Skia enums ({@link FontSlant} and {@link FontWeight}), so the same\n * values can be shared with the Paragraph API.\n */\nexport interface RNFontStyle {\n fontFamily: string;\n fontSize: number;\n fontStyle: RNFontSlant;\n fontWeight: RNFontWeight;\n}\n\nconst defaultFontStyle: RNFontStyle = {\n fontFamily: \"System\",\n fontSize: defaultFontSize,\n fontStyle: \"normal\",\n fontWeight: \"normal\",\n};\n\nconst slant = (s: RNFontSlant): FontSlant => {\n if (typeof s === \"number\") {\n return s;\n } else if (s === \"italic\") {\n return FontSlant.Italic;\n } else if (s === \"oblique\") {\n return FontSlant.Oblique;\n } else {\n return FontSlant.Upright;\n }\n};\n\nconst weight = (fontWeight: RNFontWeight): FontWeight => {\n switch (fontWeight) {\n case \"normal\":\n return FontWeight.Normal;\n case \"bold\":\n return FontWeight.Bold;\n default:\n return typeof fontWeight === \"number\"\n ? fontWeight\n : (parseInt(fontWeight, 10) as FontWeight);\n }\n};\n\nexport const matchFont = (\n inputStyle: Partial<RNFontStyle> = {},\n fontMgr: SkFontMgr = Skia.FontMgr.System()\n) => {\n const fontStyle = {\n ...defaultFontStyle,\n ...inputStyle,\n };\n const style = {\n weight: weight(fontStyle.fontWeight),\n width: 5,\n slant: slant(fontStyle.fontStyle),\n };\n const typeface = fontMgr.matchFamilyStyle(fontStyle.fontFamily, style);\n return Skia.Font(typeface, fontStyle.fontSize);\n};\n\nexport const listFontFamilies = (\n fontMgr: SkFontMgr = Skia.FontMgr.System()\n) => {\n const families = new Set<string>();\n for (let i = 0; i < fontMgr.countFamilies(); i++) {\n families.add(fontMgr.getFamilyName(i));\n }\n return Array.from(families);\n};\n\nconst loadTypefaces = (typefacesToLoad: Record<string, DataModule[]>) => {\n const promises = Object.keys(typefacesToLoad).flatMap((familyName) => {\n return typefacesToLoad[familyName].map((typefaceToLoad) => {\n return Skia.Data.fromURI(Platform.resolveAsset(typefaceToLoad)).then(\n (data) => {\n const tf = Skia.Typeface.MakeFreeTypeFaceFromData(data);\n if (tf === null) {\n throw new Error(`Couldn't create typeface for ${familyName}`);\n }\n return [familyName, tf] as const;\n }\n );\n });\n });\n return Promise.all(promises);\n};\n\nexport const useFonts = (sources: Record<string, DataModule[]>) => {\n const [fontMgr, setFontMgr] = useState<null | SkTypefaceFontProvider>(null);\n\n useEffect(() => {\n loadTypefaces(sources).then((result) => {\n const fMgr = Skia.TypefaceFontProvider.Make();\n result.forEach(([familyName, typeface]) => {\n fMgr.registerFont(typeface, familyName);\n });\n setFontMgr(fMgr);\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n return fontMgr;\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEA,IAAAG,SAAA,GAAAH,OAAA;AAGA,IAAAI,SAAA,GAAAJ,OAAA;AATA;;AAWA,MAAMK,eAAe,GAAG,EAAE;;AAE1B;AACA;AACA;AACO,MAAMC,OAAO,GAAGA,CACrBC,IAAqB,EACrBC,IAAI,GAAGH,eAAe,EACtBI,OAA8B,KAC3B;EACH,MAAMC,QAAQ,GAAG,IAAAC,qBAAW,EAACJ,IAAI,EAAEE,OAAO,CAAC;EAC3C,OAAO,IAAAG,cAAO,EAAC,MAAM;IACnB,IAAIF,QAAQ,EAAE;MACZ,OAAOG,UAAI,CAACC,IAAI,CAACJ,QAAQ,EAAEF,IAAI,CAAC;IAClC,CAAC,MAAM;MACL,OAAO,IAAI;IACb;EACF,CAAC,EAAE,CAACA,IAAI,EAAEE,QAAQ,CAAC,CAAC;AACtB,CAAC;;AAED;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;;AAeA;AACA;AACA;AACA;AACA;AACA;AALAK,OAAA,CAAAT,OAAA,GAAAA,OAAA;AAaA,MAAM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;AAEM,MAAMmB,QAAQ,GAAIC,OAAqC,IAAK;EACjE,MAAM,CAACrC,OAAO,EAAEsC,UAAU,CAAC,GAAG,IAAAC,eAAQ,EAAgC,IAAI,CAAC;EAE3E,IAAAC,gBAAS,EAAC,MAAM;IACdzB,aAAa,CAACsB,OAAO,CAAC,CAACT,IAAI,CAAEa,MAAM,IAAK;MACtC,MAAMC,IAAI,GAAG/D,UAAI,CAACgE,oBAAoB,CAACC,IAAI,CAAC,CAAC;MAC7CH,MAAM,CAACI,OAAO,CAAC,CAAC,CAACxB,UAAU,EAAE7C,QAAQ,CAAC,KAAK;QACzCkE,IAAI,CAACI,YAAY,CAACtE,QAAQ,EAAE6C,UAAU,CAAC;MACzC,CAAC,CAAC;MACFiB,UAAU,CAACI,IAAI,CAAC;IAClB,CAAC,CAAC;IACF;EACF,CAAC,EAAE,EAAE,CAAC;EACN,OAAO1C,OAAO;AAChB,CAAC;AAACnB,OAAA,CAAAuD,QAAA,GAAAA,QAAA","ignoreList":[]}
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.useSVG = void 0;
7
7
  var _react = require("react");
8
8
  var _Skia = require("../Skia");
9
+ var _Platform = require("../../Platform");
9
10
  const useSVG = (source, onError) => {
10
11
  const [svg, setSVG] = (0, _react.useState)(null);
11
12
  if (source === null || source === undefined) {
@@ -16,12 +17,10 @@ const useSVG = (source, onError) => {
16
17
  let src;
17
18
  if (typeof source === "string") {
18
19
  src = source;
19
- } else if (typeof source === "object" && "default" in source && typeof source.default === "string") {
20
- src = source.default;
21
- } else if (typeof source === "object" && "uri" in source) {
22
- src = source.uri;
20
+ } else if (source instanceof Uint8Array) {
21
+ throw new Error(`Invalid svg data source. Make sure that the source resolves to a string. Got: ${source}`);
23
22
  } else {
24
- throw new Error(`Invalid svg data source. Make sure that the source resolves to a string. Got: ${JSON.stringify(source, null, 2)}`);
23
+ src = _Platform.Platform.resolveAsset(source);
25
24
  }
26
25
  const result = await fetch(src);
27
26
  const svgStr = await result.text();
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_Skia","useSVG","source","onError","svg","setSVG","useState","undefined","Error","useEffect","src","default","uri","JSON","stringify","result","fetch","svgStr","text","newSvg","Skia","SVG","MakeFromString","exports"],"sources":["SVG.web.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\nimport { Skia } from \"../Skia\";\nimport type { DataSourceParam, SkSVG } from \"../types\";\n\nexport const useSVG = (\n source: DataSourceParam,\n onError?: (err: Error) => void\n) => {\n const [svg, setSVG] = useState<SkSVG | null>(null);\n if (source === null || source === undefined) {\n throw new Error(`Invalid svg data source. Got: ${source}`);\n }\n useEffect(() => {\n (async () => {\n let src: string;\n if (typeof source === \"string\") {\n src = source;\n } else if (\n typeof source === \"object\" &&\n \"default\" in source &&\n typeof source.default === \"string\"\n ) {\n src = source.default;\n } else if (typeof source === \"object\" && \"uri\" in source) {\n src = source.uri;\n } else {\n throw new Error(\n `Invalid svg data source. Make sure that the source resolves to a string. Got: ${JSON.stringify(\n source,\n null,\n 2\n )}`\n );\n }\n const result = await fetch(src);\n const svgStr = await result.text();\n const newSvg = Skia.SVG.MakeFromString(svgStr);\n setSVG(newSvg);\n if (newSvg === null && onError !== undefined) {\n onError(new Error(\"Failed to create SVG from source.\"));\n }\n })();\n }, [onError, source]);\n return svg;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAD,OAAA;AAGO,MAAME,MAAM,GAAGA,CACpBC,MAAuB,EACvBC,OAA8B,KAC3B;EACH,MAAM,CAACC,GAAG,EAAEC,MAAM,CAAC,GAAG,IAAAC,eAAQ,EAAe,IAAI,CAAC;EAClD,IAAIJ,MAAM,KAAK,IAAI,IAAIA,MAAM,KAAKK,SAAS,EAAE;IAC3C,MAAM,IAAIC,KAAK,CAAC,iCAAiCN,MAAM,EAAE,CAAC;EAC5D;EACA,IAAAO,gBAAS,EAAC,MAAM;IACd,CAAC,YAAY;MACX,IAAIC,GAAW;MACf,IAAI,OAAOR,MAAM,KAAK,QAAQ,EAAE;QAC9BQ,GAAG,GAAGR,MAAM;MACd,CAAC,MAAM,IACL,OAAOA,MAAM,KAAK,QAAQ,IAC1B,SAAS,IAAIA,MAAM,IACnB,OAAOA,MAAM,CAACS,OAAO,KAAK,QAAQ,EAClC;QACAD,GAAG,GAAGR,MAAM,CAACS,OAAO;MACtB,CAAC,MAAM,IAAI,OAAOT,MAAM,KAAK,QAAQ,IAAI,KAAK,IAAIA,MAAM,EAAE;QACxDQ,GAAG,GAAGR,MAAM,CAACU,GAAG;MAClB,CAAC,MAAM;QACL,MAAM,IAAIJ,KAAK,CACb,iFAAiFK,IAAI,CAACC,SAAS,CAC7FZ,MAAM,EACN,IAAI,EACJ,CACF,CAAC,EACH,CAAC;MACH;MACA,MAAMa,MAAM,GAAG,MAAMC,KAAK,CAACN,GAAG,CAAC;MAC/B,MAAMO,MAAM,GAAG,MAAMF,MAAM,CAACG,IAAI,CAAC,CAAC;MAClC,MAAMC,MAAM,GAAGC,UAAI,CAACC,GAAG,CAACC,cAAc,CAACL,MAAM,CAAC;MAC9CZ,MAAM,CAACc,MAAM,CAAC;MACd,IAAIA,MAAM,KAAK,IAAI,IAAIhB,OAAO,KAAKI,SAAS,EAAE;QAC5CJ,OAAO,CAAC,IAAIK,KAAK,CAAC,mCAAmC,CAAC,CAAC;MACzD;IACF,CAAC,EAAE,CAAC;EACN,CAAC,EAAE,CAACL,OAAO,EAAED,MAAM,CAAC,CAAC;EACrB,OAAOE,GAAG;AACZ,CAAC;AAACmB,OAAA,CAAAtB,MAAA,GAAAA,MAAA","ignoreList":[]}
1
+ {"version":3,"names":["_react","require","_Skia","_Platform","useSVG","source","onError","svg","setSVG","useState","undefined","Error","useEffect","src","Uint8Array","Platform","resolveAsset","result","fetch","svgStr","text","newSvg","Skia","SVG","MakeFromString","exports"],"sources":["SVG.web.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\nimport { Skia } from \"../Skia\";\nimport type { DataSourceParam, SkSVG } from \"../types\";\nimport { Platform } from \"../../Platform\";\n\nexport const useSVG = (\n source: DataSourceParam,\n onError?: (err: Error) => void\n) => {\n const [svg, setSVG] = useState<SkSVG | null>(null);\n if (source === null || source === undefined) {\n throw new Error(`Invalid svg data source. Got: ${source}`);\n }\n useEffect(() => {\n (async () => {\n let src: string;\n if (typeof source === \"string\") {\n src = source;\n } else if (source instanceof Uint8Array) {\n throw new Error(\n `Invalid svg data source. Make sure that the source resolves to a string. Got: ${source}`\n );\n } else {\n src = Platform.resolveAsset(source);\n }\n const result = await fetch(src);\n const svgStr = await result.text();\n const newSvg = Skia.SVG.MakeFromString(svgStr);\n setSVG(newSvg);\n if (newSvg === null && onError !== undefined) {\n onError(new Error(\"Failed to create SVG from source.\"));\n }\n })();\n }, [onError, source]);\n return svg;\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAD,OAAA;AAEA,IAAAE,SAAA,GAAAF,OAAA;AAEO,MAAMG,MAAM,GAAGA,CACpBC,MAAuB,EACvBC,OAA8B,KAC3B;EACH,MAAM,CAACC,GAAG,EAAEC,MAAM,CAAC,GAAG,IAAAC,eAAQ,EAAe,IAAI,CAAC;EAClD,IAAIJ,MAAM,KAAK,IAAI,IAAIA,MAAM,KAAKK,SAAS,EAAE;IAC3C,MAAM,IAAIC,KAAK,CAAC,iCAAiCN,MAAM,EAAE,CAAC;EAC5D;EACA,IAAAO,gBAAS,EAAC,MAAM;IACd,CAAC,YAAY;MACX,IAAIC,GAAW;MACf,IAAI,OAAOR,MAAM,KAAK,QAAQ,EAAE;QAC9BQ,GAAG,GAAGR,MAAM;MACd,CAAC,MAAM,IAAIA,MAAM,YAAYS,UAAU,EAAE;QACvC,MAAM,IAAIH,KAAK,CACb,iFAAiFN,MAAM,EACzF,CAAC;MACH,CAAC,MAAM;QACLQ,GAAG,GAAGE,kBAAQ,CAACC,YAAY,CAACX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