@shopify/react-native-skia 1.3.9 → 1.3.11

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 (30) hide show
  1. package/android/CMakeLists.txt +2 -0
  2. package/android/build.gradle +4 -2
  3. package/android/cpp/jni/JniSkiaManager.cpp +9 -4
  4. package/cpp/api/JsiSkAnimatedImage.h +6 -1
  5. package/cpp/api/JsiSkParagraph.h +10 -1
  6. package/ios/RNSkiaModule.mm +5 -3
  7. package/lib/commonjs/skia/types/AnimatedImage/AnimatedImage.d.ts +5 -0
  8. package/lib/commonjs/skia/types/AnimatedImage/AnimatedImage.js.map +1 -1
  9. package/lib/commonjs/skia/types/Vertices/Vertices.d.ts +1 -1
  10. package/lib/commonjs/skia/types/Vertices/Vertices.js +1 -1
  11. package/lib/commonjs/skia/types/Vertices/Vertices.js.map +1 -1
  12. package/lib/commonjs/skia/web/JsiSkAnimatedImage.d.ts +1 -0
  13. package/lib/commonjs/skia/web/JsiSkAnimatedImage.js +3 -0
  14. package/lib/commonjs/skia/web/JsiSkAnimatedImage.js.map +1 -1
  15. package/lib/module/skia/types/AnimatedImage/AnimatedImage.d.ts +5 -0
  16. package/lib/module/skia/types/AnimatedImage/AnimatedImage.js.map +1 -1
  17. package/lib/module/skia/types/Vertices/Vertices.d.ts +1 -1
  18. package/lib/module/skia/types/Vertices/Vertices.js +1 -1
  19. package/lib/module/skia/types/Vertices/Vertices.js.map +1 -1
  20. package/lib/module/skia/web/JsiSkAnimatedImage.d.ts +1 -0
  21. package/lib/module/skia/web/JsiSkAnimatedImage.js +3 -0
  22. package/lib/module/skia/web/JsiSkAnimatedImage.js.map +1 -1
  23. package/lib/typescript/src/skia/types/AnimatedImage/AnimatedImage.d.ts +5 -0
  24. package/lib/typescript/src/skia/types/Vertices/Vertices.d.ts +1 -1
  25. package/lib/typescript/src/skia/web/JsiSkAnimatedImage.d.ts +1 -0
  26. package/package.json +1 -1
  27. package/src/skia/types/AnimatedImage/AnimatedImage.ts +6 -0
  28. package/src/skia/types/Vertices/Vertices.tsx +1 -1
  29. package/src/skia/web/JsiSkAnimatedImage.ts +4 -0
  30. /package/android/src/{reactnative69 → latest}/java/com/shopify/reactnative/skia/ReactNativeCompatible.java +0 -0
@@ -220,6 +220,8 @@ else()
220
220
  endif()
221
221
  message("-- TURBO : " ${TURBOMODULES_LIB})
222
222
 
223
+ add_definitions(-DREACT_NATIVE_VERSION=${REACT_NATIVE_VERSION})
224
+
223
225
  # Link
224
226
  target_link_libraries(
225
227
  ${PACKAGE_NAME}
@@ -172,13 +172,15 @@ android {
172
172
  ]
173
173
  }
174
174
 
175
- if (REACT_NATIVE_VERSION >= 74) {
175
+ if (REACT_NATIVE_VERSION == 74) {
176
176
  srcDirs += [
177
177
  "src/reactnative74/java"
178
178
  ]
179
179
  } else {
180
+ // the name latest here might be confusing as it applies for versions
181
+ // below 74 as well
180
182
  srcDirs += [
181
- "src/reactnative69/java"
183
+ "src/latest/java"
182
184
  ]
183
185
  }
184
186
  }
@@ -20,12 +20,17 @@ public:
20
20
  facebook::react::RuntimeExecutor runtimeExecutor)
21
21
  : runtimeExecutor_(std::move(runtimeExecutor)) {}
22
22
 
23
- void invokeAsync(std::function<void()> &&func) noexcept override {
24
- runtimeExecutor_(
25
- [func = std::move(func)](facebook::jsi::Runtime &runtime) { func(); });
23
+ void invokeAsync(facebook::react::CallFunc &&func) noexcept override {
24
+ runtimeExecutor_([func = std::move(func)](facebook::jsi::Runtime &runtime) {
25
+ #if REACT_NATIVE_VERSION >= 75
26
+ func(runtime);
27
+ #else
28
+ func();
29
+ #endif
30
+ });
26
31
  }
27
32
 
28
- void invokeSync(std::function<void()> &&func) override {
33
+ void invokeSync(facebook::react::CallFunc &&func) override {
29
34
  throw std::runtime_error(
30
35
  "Synchronous native -> JS calls are currently not supported.");
31
36
  }
@@ -35,6 +35,10 @@ public:
35
35
  runtime, std::make_shared<JsiSkImage>(getContext(), std::move(image)));
36
36
  }
37
37
 
38
+ JSI_HOST_FUNCTION(getFrameCount) {
39
+ return static_cast<int>(getObject()->getFrameCount());
40
+ }
41
+
38
42
  JSI_HOST_FUNCTION(currentFrameDuration) {
39
43
  return static_cast<int>(getObject()->currentFrameDuration());
40
44
  }
@@ -43,9 +47,10 @@ public:
43
47
  return static_cast<int>(getObject()->decodeNextFrame());
44
48
  }
45
49
 
46
- EXPORT_JSI_API_TYPENAME(JsiSkAnimatedImage, "AnimatedImage")
50
+ EXPORT_JSI_API_TYPENAME(JsiSkAnimatedImage, AnimatedImage)
47
51
 
48
52
  JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkAnimatedImage, dispose),
53
+ JSI_EXPORT_FUNC(JsiSkAnimatedImage, getFrameCount),
49
54
  JSI_EXPORT_FUNC(JsiSkAnimatedImage, getCurrentFrame),
50
55
  JSI_EXPORT_FUNC(JsiSkAnimatedImage,
51
56
  currentFrameDuration),
@@ -32,6 +32,8 @@ namespace para = skia::textlayout;
32
32
  */
33
33
  class JsiSkParagraph : public JsiSkHostObject {
34
34
  public:
35
+ EXPORT_JSI_API_TYPENAME(JsiSkParagraph, Paragraph)
36
+
35
37
  JSI_HOST_FUNCTION(layout) {
36
38
  auto width = getArgumentAsNumber(runtime, arguments, count, 0);
37
39
  _paragraph->layout(width);
@@ -122,6 +124,12 @@ public:
122
124
  return returnValue;
123
125
  }
124
126
 
127
+ JSI_HOST_FUNCTION(dispose) {
128
+ _paragraph = nullptr;
129
+
130
+ return jsi::Value::undefined();
131
+ }
132
+
125
133
  JSI_EXPORT_FUNCTIONS(JSI_EXPORT_FUNC(JsiSkParagraph, layout),
126
134
  JSI_EXPORT_FUNC(JsiSkParagraph, paint),
127
135
  JSI_EXPORT_FUNC(JsiSkParagraph, getMaxWidth),
@@ -133,7 +141,8 @@ public:
133
141
  JSI_EXPORT_FUNC(JsiSkParagraph,
134
142
  getGlyphPositionAtCoordinate),
135
143
  JSI_EXPORT_FUNC(JsiSkParagraph, getRectsForRange),
136
- JSI_EXPORT_FUNC(JsiSkParagraph, getLineMetrics))
144
+ JSI_EXPORT_FUNC(JsiSkParagraph, getLineMetrics),
145
+ JSI_EXPORT_FUNC(JsiSkParagraph, dispose))
137
146
 
138
147
  explicit JsiSkParagraph(std::shared_ptr<RNSkPlatformContext> context,
139
148
  para::ParagraphBuilder *paragraphBuilder)
@@ -9,6 +9,7 @@
9
9
  }
10
10
 
11
11
  RCT_EXPORT_MODULE()
12
+ @synthesize bridge = _bridge;
12
13
 
13
14
  #pragma Accessors
14
15
 
@@ -34,11 +35,12 @@ RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install) {
34
35
  // Already initialized, ignore call.
35
36
  return @true;
36
37
  }
37
- RCTBridge *bridge = [RCTBridge currentBridge];
38
+ RCTCxxBridge *cxxBridge = (RCTCxxBridge *)self.bridge;
38
39
  if (!jsInvoker) {
39
- jsInvoker = bridge.jsCallInvoker;
40
+ jsInvoker = cxxBridge.jsCallInvoker;
40
41
  }
41
- skiaManager = [[SkiaManager alloc] initWithBridge:bridge jsInvoker:jsInvoker];
42
+ skiaManager = [[SkiaManager alloc] initWithBridge:cxxBridge
43
+ jsInvoker:jsInvoker];
42
44
  return @true;
43
45
  }
44
46
 
@@ -21,4 +21,9 @@ export interface SkAnimatedImage extends SkJSIInstance<"AnimatedImage"> {
21
21
  * internally.
22
22
  */
23
23
  currentFrameDuration(): number;
24
+ /**
25
+ * Returns the number of frames in the animation.
26
+ *
27
+ */
28
+ getFrameCount(): number;
24
29
  }
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["AnimatedImage.ts"],"sourcesContent":["import type { SkJSIInstance } from \"../JsiInstance\";\nimport type { SkImage } from \"../Image\";\n\nexport interface SkAnimatedImage extends SkJSIInstance<\"AnimatedImage\"> {\n /**\n * Decode the next frame.\n *\n * If the animation is on the last frame or has hit an error, returns\n * kFinished (-1).\n */\n decodeNextFrame(): number;\n\n /**\n * Returns the current frame as an SkImage. The SkImage will not change\n * after it has been returned.\n * If there is no current frame, null will be returned.\n */\n getCurrentFrame(): SkImage | null;\n\n /**\n * How long to display the current frame.\n *\n * Useful for the first frame, for which decodeNextFrame is called\n * internally.\n */\n currentFrameDuration(): number;\n\n // TODO - add the rest of the methods from the Skia API (see SkAnimatedImage.h)\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["AnimatedImage.ts"],"sourcesContent":["import type { SkJSIInstance } from \"../JsiInstance\";\nimport type { SkImage } from \"../Image\";\n\nexport interface SkAnimatedImage extends SkJSIInstance<\"AnimatedImage\"> {\n /**\n * Decode the next frame.\n *\n * If the animation is on the last frame or has hit an error, returns\n * kFinished (-1).\n */\n decodeNextFrame(): number;\n\n /**\n * Returns the current frame as an SkImage. The SkImage will not change\n * after it has been returned.\n * If there is no current frame, null will be returned.\n */\n getCurrentFrame(): SkImage | null;\n\n /**\n * How long to display the current frame.\n *\n * Useful for the first frame, for which decodeNextFrame is called\n * internally.\n */\n currentFrameDuration(): number;\n\n /**\n * Returns the number of frames in the animation.\n *\n */\n getFrameCount(): number;\n\n // TODO - add the rest of the methods from the Skia API (see SkAnimatedImage.h)\n}\n"],"mappings":""}
@@ -2,7 +2,7 @@ import type { SkRect } from "../Rect";
2
2
  import type { SkJSIInstance } from "../JsiInstance";
3
3
  export declare enum VertexMode {
4
4
  Triangles = 0,
5
- TrianglesStrip = 1,
5
+ TriangleStrip = 1,
6
6
  TriangleFan = 2
7
7
  }
8
8
  export interface SkVertices extends SkJSIInstance<"Vertices"> {
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.VertexMode = void 0;
7
7
  let VertexMode = exports.VertexMode = /*#__PURE__*/function (VertexMode) {
8
8
  VertexMode[VertexMode["Triangles"] = 0] = "Triangles";
9
- VertexMode[VertexMode["TrianglesStrip"] = 1] = "TrianglesStrip";
9
+ VertexMode[VertexMode["TriangleStrip"] = 1] = "TriangleStrip";
10
10
  VertexMode[VertexMode["TriangleFan"] = 2] = "TriangleFan";
11
11
  return VertexMode;
12
12
  }({});
@@ -1 +1 @@
1
- {"version":3,"names":["VertexMode","exports"],"sources":["Vertices.tsx"],"sourcesContent":["import type { SkRect } from \"../Rect\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\n\nexport enum VertexMode {\n Triangles,\n TrianglesStrip,\n TriangleFan,\n}\n\nexport interface SkVertices extends SkJSIInstance<\"Vertices\"> {\n /**\n * Return the bounding area for the vertices.\n */\n bounds(): SkRect;\n\n /**\n * Return a unique ID for this vertices object.\n */\n uniqueID(): number;\n}\n"],"mappings":";;;;;;IAGYA,UAAU,GAAAC,OAAA,CAAAD,UAAA,0BAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAA,OAAVA,UAAU;AAAA"}
1
+ {"version":3,"names":["VertexMode","exports"],"sources":["Vertices.tsx"],"sourcesContent":["import type { SkRect } from \"../Rect\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\n\nexport enum VertexMode {\n Triangles,\n TriangleStrip,\n TriangleFan,\n}\n\nexport interface SkVertices extends SkJSIInstance<\"Vertices\"> {\n /**\n * Return the bounding area for the vertices.\n */\n bounds(): SkRect;\n\n /**\n * Return a unique ID for this vertices object.\n */\n uniqueID(): number;\n}\n"],"mappings":";;;;;;IAGYA,UAAU,GAAAC,OAAA,CAAAD,UAAA,0BAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAA,OAAVA,UAAU;AAAA"}
@@ -6,6 +6,7 @@ export declare class JsiSkAnimatedImage extends HostObject<AnimatedImage, "Anima
6
6
  constructor(CanvasKit: CanvasKit, ref: AnimatedImage);
7
7
  decodeNextFrame(): number;
8
8
  currentFrameDuration(): number;
9
+ getFrameCount(): number;
9
10
  getCurrentFrame(): JsiSkImage | null;
10
11
  dispose: () => void;
11
12
  }
@@ -22,6 +22,9 @@ class JsiSkAnimatedImage extends _Host.HostObject {
22
22
  currentFrameDuration() {
23
23
  return this.ref.currentFrameDuration();
24
24
  }
25
+ getFrameCount() {
26
+ return this.ref.getFrameCount();
27
+ }
25
28
  getCurrentFrame() {
26
29
  const image = this.ref.makeImageAtCurrentFrame();
27
30
  if (image === null) {
@@ -1 +1 @@
1
- {"version":3,"names":["_Host","require","_JsiSkImage","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","JsiSkAnimatedImage","HostObject","constructor","CanvasKit","ref","delete","decodeNextFrame","currentFrameDuration","getCurrentFrame","image","makeImageAtCurrentFrame","JsiSkImage","exports"],"sources":["JsiSkAnimatedImage.ts"],"sourcesContent":["import type { AnimatedImage, CanvasKit } from \"canvaskit-wasm\";\n\nimport type { SkAnimatedImage } from \"../types/AnimatedImage\";\n\nimport { HostObject } from \"./Host\";\nimport { JsiSkImage } from \"./JsiSkImage\";\n\nexport class JsiSkAnimatedImage\n extends HostObject<AnimatedImage, \"AnimatedImage\">\n implements SkAnimatedImage\n{\n constructor(CanvasKit: CanvasKit, ref: AnimatedImage) {\n super(CanvasKit, ref, \"AnimatedImage\");\n }\n\n decodeNextFrame() {\n return this.ref.decodeNextFrame();\n }\n\n currentFrameDuration() {\n return this.ref.currentFrameDuration();\n }\n\n getCurrentFrame() {\n const image = this.ref.makeImageAtCurrentFrame();\n if (image === null) {\n return null;\n }\n return new JsiSkImage(this.CanvasKit, image);\n }\n\n dispose = () => {\n this.ref.delete();\n };\n}\n"],"mappings":";;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAA0C,SAAAE,gBAAAC,GAAA,EAAAC,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAD,GAAA,IAAAI,MAAA,CAAAC,cAAA,CAAAL,GAAA,EAAAC,G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Z,kBAAA,GAAAA,kBAAA"}
1
+ {"version":3,"names":["_Host","require","_JsiSkImage","_defineProperty","obj","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","JsiSkAnimatedImage","HostObject","constructor","CanvasKit","ref","delete","decodeNextFrame","currentFrameDuration","getFrameCount","getCurrentFrame","image","makeImageAtCurrentFrame","JsiSkImage","exports"],"sources":["JsiSkAnimatedImage.ts"],"sourcesContent":["import type { AnimatedImage, CanvasKit } from \"canvaskit-wasm\";\n\nimport type { SkAnimatedImage } from \"../types/AnimatedImage\";\n\nimport { HostObject } from \"./Host\";\nimport { JsiSkImage } from \"./JsiSkImage\";\n\nexport class JsiSkAnimatedImage\n extends HostObject<AnimatedImage, \"AnimatedImage\">\n implements SkAnimatedImage\n{\n constructor(CanvasKit: CanvasKit, ref: AnimatedImage) {\n super(CanvasKit, ref, \"AnimatedImage\");\n }\n\n decodeNextFrame() {\n return this.ref.decodeNextFrame();\n }\n\n currentFrameDuration() {\n return this.ref.currentFrameDuration();\n }\n\n getFrameCount() {\n return this.ref.getFrameCount();\n }\n\n getCurrentFrame() {\n const image = this.ref.makeImageAtCurrentFrame();\n if (image === null) {\n return null;\n }\n return new JsiSkImage(this.CanvasKit, image);\n }\n\n dispose = () => {\n this.ref.delete();\n };\n}\n"],"mappings":";;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAA0C,SAAAE,gBAAAC,GAAA,EAAAC,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAD,GAAA,IAAAI,MAAA,CAAAC,cAAA,CAAAL,GAAA,EAAAC,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAR,GAAA,CAAAC,GAAA,IAAAC,KAAA,WAAAF,GAAA;AAAA,SA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export interface SkAnimatedImage extends SkJSIInstance<"AnimatedImage"> {
21
21
  * internally.
22
22
  */
23
23
  currentFrameDuration(): number;
24
+ /**
25
+ * Returns the number of frames in the animation.
26
+ *
27
+ */
28
+ getFrameCount(): number;
24
29
  }
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["AnimatedImage.ts"],"sourcesContent":["import type { SkJSIInstance } from \"../JsiInstance\";\nimport type { SkImage } from \"../Image\";\n\nexport interface SkAnimatedImage extends SkJSIInstance<\"AnimatedImage\"> {\n /**\n * Decode the next frame.\n *\n * If the animation is on the last frame or has hit an error, returns\n * kFinished (-1).\n */\n decodeNextFrame(): number;\n\n /**\n * Returns the current frame as an SkImage. The SkImage will not change\n * after it has been returned.\n * If there is no current frame, null will be returned.\n */\n getCurrentFrame(): SkImage | null;\n\n /**\n * How long to display the current frame.\n *\n * Useful for the first frame, for which decodeNextFrame is called\n * internally.\n */\n currentFrameDuration(): number;\n\n // TODO - add the rest of the methods from the Skia API (see SkAnimatedImage.h)\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["AnimatedImage.ts"],"sourcesContent":["import type { SkJSIInstance } from \"../JsiInstance\";\nimport type { SkImage } from \"../Image\";\n\nexport interface SkAnimatedImage extends SkJSIInstance<\"AnimatedImage\"> {\n /**\n * Decode the next frame.\n *\n * If the animation is on the last frame or has hit an error, returns\n * kFinished (-1).\n */\n decodeNextFrame(): number;\n\n /**\n * Returns the current frame as an SkImage. The SkImage will not change\n * after it has been returned.\n * If there is no current frame, null will be returned.\n */\n getCurrentFrame(): SkImage | null;\n\n /**\n * How long to display the current frame.\n *\n * Useful for the first frame, for which decodeNextFrame is called\n * internally.\n */\n currentFrameDuration(): number;\n\n /**\n * Returns the number of frames in the animation.\n *\n */\n getFrameCount(): number;\n\n // TODO - add the rest of the methods from the Skia API (see SkAnimatedImage.h)\n}\n"],"mappings":""}
@@ -2,7 +2,7 @@ import type { SkRect } from "../Rect";
2
2
  import type { SkJSIInstance } from "../JsiInstance";
3
3
  export declare enum VertexMode {
4
4
  Triangles = 0,
5
- TrianglesStrip = 1,
5
+ TriangleStrip = 1,
6
6
  TriangleFan = 2
7
7
  }
8
8
  export interface SkVertices extends SkJSIInstance<"Vertices"> {
@@ -1,6 +1,6 @@
1
1
  export let VertexMode = /*#__PURE__*/function (VertexMode) {
2
2
  VertexMode[VertexMode["Triangles"] = 0] = "Triangles";
3
- VertexMode[VertexMode["TrianglesStrip"] = 1] = "TrianglesStrip";
3
+ VertexMode[VertexMode["TriangleStrip"] = 1] = "TriangleStrip";
4
4
  VertexMode[VertexMode["TriangleFan"] = 2] = "TriangleFan";
5
5
  return VertexMode;
6
6
  }({});
@@ -1 +1 @@
1
- {"version":3,"names":["VertexMode"],"sources":["Vertices.tsx"],"sourcesContent":["import type { SkRect } from \"../Rect\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\n\nexport enum VertexMode {\n Triangles,\n TrianglesStrip,\n TriangleFan,\n}\n\nexport interface SkVertices extends SkJSIInstance<\"Vertices\"> {\n /**\n * Return the bounding area for the vertices.\n */\n bounds(): SkRect;\n\n /**\n * Return a unique ID for this vertices object.\n */\n uniqueID(): number;\n}\n"],"mappings":"AAGA,WAAYA,UAAU,0BAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAA,OAAVA,UAAU;AAAA"}
1
+ {"version":3,"names":["VertexMode"],"sources":["Vertices.tsx"],"sourcesContent":["import type { SkRect } from \"../Rect\";\nimport type { SkJSIInstance } from \"../JsiInstance\";\n\nexport enum VertexMode {\n Triangles,\n TriangleStrip,\n TriangleFan,\n}\n\nexport interface SkVertices extends SkJSIInstance<\"Vertices\"> {\n /**\n * Return the bounding area for the vertices.\n */\n bounds(): SkRect;\n\n /**\n * Return a unique ID for this vertices object.\n */\n uniqueID(): number;\n}\n"],"mappings":"AAGA,WAAYA,UAAU,0BAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAA,OAAVA,UAAU;AAAA"}
@@ -6,6 +6,7 @@ export declare class JsiSkAnimatedImage extends HostObject<AnimatedImage, "Anima
6
6
  constructor(CanvasKit: CanvasKit, ref: AnimatedImage);
7
7
  decodeNextFrame(): number;
8
8
  currentFrameDuration(): number;
9
+ getFrameCount(): number;
9
10
  getCurrentFrame(): JsiSkImage | null;
10
11
  dispose: () => void;
11
12
  }
@@ -16,6 +16,9 @@ export class JsiSkAnimatedImage extends HostObject {
16
16
  currentFrameDuration() {
17
17
  return this.ref.currentFrameDuration();
18
18
  }
19
+ getFrameCount() {
20
+ return this.ref.getFrameCount();
21
+ }
19
22
  getCurrentFrame() {
20
23
  const image = this.ref.makeImageAtCurrentFrame();
21
24
  if (image === null) {
@@ -1 +1 @@
1
- {"version":3,"names":["HostObject","JsiSkImage","JsiSkAnimatedImage","constructor","CanvasKit","ref","_defineProperty","delete","decodeNextFrame","currentFrameDuration","getCurrentFrame","image","makeImageAtCurrentFrame"],"sources":["JsiSkAnimatedImage.ts"],"sourcesContent":["import type { AnimatedImage, CanvasKit } from \"canvaskit-wasm\";\n\nimport type { SkAnimatedImage } from \"../types/AnimatedImage\";\n\nimport { HostObject } from \"./Host\";\nimport { JsiSkImage } from \"./JsiSkImage\";\n\nexport class JsiSkAnimatedImage\n extends HostObject<AnimatedImage, \"AnimatedImage\">\n implements SkAnimatedImage\n{\n constructor(CanvasKit: CanvasKit, ref: AnimatedImage) {\n super(CanvasKit, ref, \"AnimatedImage\");\n }\n\n decodeNextFrame() {\n return this.ref.decodeNextFrame();\n }\n\n currentFrameDuration() {\n return this.ref.currentFrameDuration();\n }\n\n getCurrentFrame() {\n const image = this.ref.makeImageAtCurrentFrame();\n if (image === null) {\n return null;\n }\n return new JsiSkImage(this.CanvasKit, image);\n }\n\n dispose = () => {\n this.ref.delete();\n };\n}\n"],"mappings":";;;AAIA,SAASA,UAAU,QAAQ,QAAQ;AACnC,SAASC,UAAU,QAAQ,cAAc;AAEzC,OAAO,MAAMC,kBAAkB,SACrBF,UAAU,CAEpB;EACEG,WAAWA,CAACC,SAAoB,EAAEC,GAAkB,EAAE;IACpD,KAAK,CAACD,SAAS,EAAEC,GAAG,EAAE,eAAe,CAAC;IAACC,eAAA,kBAmB/B,MAAM;MACd,IAAI,CAACD,GAAG,CAACE,MAAM,CAAC,CAAC;IACnB,CAAC;EApBD;EAEAC,eAAeA,CAAA,EAAG;IAChB,OAAO,IAAI,CAACH,GAAG,CAACG,eAAe,CAAC,CAAC;EACnC;EAEAC,oBAAoBA,CAAA,EAAG;IACrB,OAAO,IAAI,CAACJ,GAAG,CAACI,oBAAoB,CAAC,CAAC;EACxC;EAEAC,eAAeA,CAAA,EAAG;IAChB,MAAMC,KAAK,GAAG,IAAI,CAACN,GAAG,CAACO,uBAAuB,CAAC,CAAC;IAChD,IAAID,KAAK,KAAK,IAAI,EAAE;MAClB,OAAO,IAAI;IACb;IACA,OAAO,IAAIV,UAAU,CAAC,IAAI,CAACG,SAAS,EAAEO,KAAK,CAAC;EAC9C;AAKF"}
1
+ {"version":3,"names":["HostObject","JsiSkImage","JsiSkAnimatedImage","constructor","CanvasKit","ref","_defineProperty","delete","decodeNextFrame","currentFrameDuration","getFrameCount","getCurrentFrame","image","makeImageAtCurrentFrame"],"sources":["JsiSkAnimatedImage.ts"],"sourcesContent":["import type { AnimatedImage, CanvasKit } from \"canvaskit-wasm\";\n\nimport type { SkAnimatedImage } from \"../types/AnimatedImage\";\n\nimport { HostObject } from \"./Host\";\nimport { JsiSkImage } from \"./JsiSkImage\";\n\nexport class JsiSkAnimatedImage\n extends HostObject<AnimatedImage, \"AnimatedImage\">\n implements SkAnimatedImage\n{\n constructor(CanvasKit: CanvasKit, ref: AnimatedImage) {\n super(CanvasKit, ref, \"AnimatedImage\");\n }\n\n decodeNextFrame() {\n return this.ref.decodeNextFrame();\n }\n\n currentFrameDuration() {\n return this.ref.currentFrameDuration();\n }\n\n getFrameCount() {\n return this.ref.getFrameCount();\n }\n\n getCurrentFrame() {\n const image = this.ref.makeImageAtCurrentFrame();\n if (image === null) {\n return null;\n }\n return new JsiSkImage(this.CanvasKit, image);\n }\n\n dispose = () => {\n this.ref.delete();\n };\n}\n"],"mappings":";;;AAIA,SAASA,UAAU,QAAQ,QAAQ;AACnC,SAASC,UAAU,QAAQ,cAAc;AAEzC,OAAO,MAAMC,kBAAkB,SACrBF,UAAU,CAEpB;EACEG,WAAWA,CAACC,SAAoB,EAAEC,GAAkB,EAAE;IACpD,KAAK,CAACD,SAAS,EAAEC,GAAG,EAAE,eAAe,CAAC;IAACC,eAAA,kBAuB/B,MAAM;MACd,IAAI,CAACD,GAAG,CAACE,MAAM,CAAC,CAAC;IACnB,CAAC;EAxBD;EAEAC,eAAeA,CAAA,EAAG;IAChB,OAAO,IAAI,CAACH,GAAG,CAACG,eAAe,CAAC,CAAC;EACnC;EAEAC,oBAAoBA,CAAA,EAAG;IACrB,OAAO,IAAI,CAACJ,GAAG,CAACI,oBAAoB,CAAC,CAAC;EACxC;EAEAC,aAAaA,CAAA,EAAG;IACd,OAAO,IAAI,CAACL,GAAG,CAACK,aAAa,CAAC,CAAC;EACjC;EAEAC,eAAeA,CAAA,EAAG;IAChB,MAAMC,KAAK,GAAG,IAAI,CAACP,GAAG,CAACQ,uBAAuB,CAAC,CAAC;IAChD,IAAID,KAAK,KAAK,IAAI,EAAE;MAClB,OAAO,IAAI;IACb;IACA,OAAO,IAAIX,UAAU,CAAC,IAAI,CAACG,SAAS,EAAEQ,KAAK,CAAC;EAC9C;AAKF"}
@@ -21,4 +21,9 @@ export interface SkAnimatedImage extends SkJSIInstance<"AnimatedImage"> {
21
21
  * internally.
22
22
  */
23
23
  currentFrameDuration(): number;
24
+ /**
25
+ * Returns the number of frames in the animation.
26
+ *
27
+ */
28
+ getFrameCount(): number;
24
29
  }
@@ -2,7 +2,7 @@ import type { SkRect } from "../Rect";
2
2
  import type { SkJSIInstance } from "../JsiInstance";
3
3
  export declare enum VertexMode {
4
4
  Triangles = 0,
5
- TrianglesStrip = 1,
5
+ TriangleStrip = 1,
6
6
  TriangleFan = 2
7
7
  }
8
8
  export interface SkVertices extends SkJSIInstance<"Vertices"> {
@@ -6,6 +6,7 @@ export declare class JsiSkAnimatedImage extends HostObject<AnimatedImage, "Anima
6
6
  constructor(CanvasKit: CanvasKit, ref: AnimatedImage);
7
7
  decodeNextFrame(): number;
8
8
  currentFrameDuration(): number;
9
+ getFrameCount(): number;
9
10
  getCurrentFrame(): JsiSkImage | null;
10
11
  dispose: () => void;
11
12
  }
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "setup-skia-web": "./scripts/setup-canvaskit.js"
8
8
  },
9
9
  "title": "React Native Skia",
10
- "version": "1.3.9",
10
+ "version": "1.3.11",
11
11
  "description": "High-performance React Native Graphics using Skia",
12
12
  "main": "lib/module/index.js",
13
13
  "react-native": "src/index.ts",
@@ -25,5 +25,11 @@ export interface SkAnimatedImage extends SkJSIInstance<"AnimatedImage"> {
25
25
  */
26
26
  currentFrameDuration(): number;
27
27
 
28
+ /**
29
+ * Returns the number of frames in the animation.
30
+ *
31
+ */
32
+ getFrameCount(): number;
33
+
28
34
  // TODO - add the rest of the methods from the Skia API (see SkAnimatedImage.h)
29
35
  }
@@ -3,7 +3,7 @@ import type { SkJSIInstance } from "../JsiInstance";
3
3
 
4
4
  export enum VertexMode {
5
5
  Triangles,
6
- TrianglesStrip,
6
+ TriangleStrip,
7
7
  TriangleFan,
8
8
  }
9
9
 
@@ -21,6 +21,10 @@ export class JsiSkAnimatedImage
21
21
  return this.ref.currentFrameDuration();
22
22
  }
23
23
 
24
+ getFrameCount() {
25
+ return this.ref.getFrameCount();
26
+ }
27
+
24
28
  getCurrentFrame() {
25
29
  const image = this.ref.makeImageAtCurrentFrame();
26
30
  if (image === null) {