@shopify/react-native-skia 0.1.209 → 0.1.211

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. package/cpp/api/JsiSkAnimatedImage.h +60 -0
  2. package/cpp/api/JsiSkAnimatedImageFactory.h +39 -0
  3. package/cpp/api/JsiSkApi.h +4 -0
  4. package/cpp/api/JsiSkFont.h +17 -0
  5. package/cpp/api/JsiSkImage.h +15 -23
  6. package/lib/commonjs/external/reanimated/moduleWrapper.d.ts +2 -0
  7. package/lib/commonjs/external/reanimated/moduleWrapper.js +11 -11
  8. package/lib/commonjs/external/reanimated/moduleWrapper.js.map +1 -1
  9. package/lib/commonjs/skia/core/AnimatedImage.d.ts +6 -0
  10. package/lib/commonjs/skia/core/AnimatedImage.js +65 -0
  11. package/lib/commonjs/skia/core/AnimatedImage.js.map +1 -0
  12. package/lib/commonjs/skia/core/index.d.ts +1 -0
  13. package/lib/commonjs/skia/core/index.js +13 -0
  14. package/lib/commonjs/skia/core/index.js.map +1 -1
  15. package/lib/commonjs/skia/types/AnimatedImage/AnimatedImage.d.ts +24 -0
  16. package/lib/commonjs/{dom/nodes/PaintContext.js → skia/types/AnimatedImage/AnimatedImage.js} +1 -1
  17. package/lib/commonjs/skia/types/AnimatedImage/AnimatedImage.js.map +1 -0
  18. package/lib/commonjs/skia/types/AnimatedImage/AnimatedImageFactory.d.ts +13 -0
  19. package/lib/commonjs/skia/types/AnimatedImage/AnimatedImageFactory.js +6 -0
  20. package/lib/commonjs/skia/types/AnimatedImage/AnimatedImageFactory.js.map +1 -0
  21. package/lib/commonjs/skia/types/AnimatedImage/index.d.ts +2 -0
  22. package/lib/commonjs/skia/types/AnimatedImage/index.js +32 -0
  23. package/lib/commonjs/skia/types/AnimatedImage/index.js.map +1 -0
  24. package/lib/commonjs/skia/types/Font/Font.d.ts +9 -0
  25. package/lib/commonjs/skia/types/Font/Font.js.map +1 -1
  26. package/lib/commonjs/skia/types/Skia.d.ts +2 -0
  27. package/lib/commonjs/skia/types/Skia.js.map +1 -1
  28. package/lib/commonjs/skia/types/index.d.ts +1 -0
  29. package/lib/commonjs/skia/types/index.js +13 -0
  30. package/lib/commonjs/skia/types/index.js.map +1 -1
  31. package/lib/commonjs/skia/web/JsiSkAnimatedImage.d.ts +11 -0
  32. package/lib/commonjs/skia/web/JsiSkAnimatedImage.js +44 -0
  33. package/lib/commonjs/skia/web/JsiSkAnimatedImage.js.map +1 -0
  34. package/lib/commonjs/skia/web/JsiSkAnimatedImageFactory.d.ts +9 -0
  35. package/lib/commonjs/skia/web/JsiSkAnimatedImageFactory.js +32 -0
  36. package/lib/commonjs/skia/web/JsiSkAnimatedImageFactory.js.map +1 -0
  37. package/lib/commonjs/skia/web/JsiSkFont.d.ts +2 -1
  38. package/lib/commonjs/skia/web/JsiSkFont.js +4 -0
  39. package/lib/commonjs/skia/web/JsiSkFont.js.map +1 -1
  40. package/lib/commonjs/skia/web/JsiSkia.js +3 -0
  41. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  42. package/lib/module/external/reanimated/moduleWrapper.d.ts +2 -0
  43. package/lib/module/external/reanimated/moduleWrapper.js +8 -11
  44. package/lib/module/external/reanimated/moduleWrapper.js.map +1 -1
  45. package/lib/module/skia/core/AnimatedImage.d.ts +6 -0
  46. package/lib/module/skia/core/AnimatedImage.js +49 -0
  47. package/lib/module/skia/core/AnimatedImage.js.map +1 -0
  48. package/lib/module/skia/core/index.d.ts +1 -0
  49. package/lib/module/skia/core/index.js +1 -0
  50. package/lib/module/skia/core/index.js.map +1 -1
  51. package/lib/module/skia/types/AnimatedImage/AnimatedImage.d.ts +24 -0
  52. package/lib/module/skia/types/AnimatedImage/AnimatedImage.js +2 -0
  53. package/lib/module/skia/types/AnimatedImage/AnimatedImage.js.map +1 -0
  54. package/lib/module/skia/types/AnimatedImage/AnimatedImageFactory.d.ts +13 -0
  55. package/lib/module/skia/types/AnimatedImage/AnimatedImageFactory.js +2 -0
  56. package/lib/module/skia/types/AnimatedImage/AnimatedImageFactory.js.map +1 -0
  57. package/lib/module/skia/types/AnimatedImage/index.d.ts +2 -0
  58. package/lib/module/skia/types/AnimatedImage/index.js +3 -0
  59. package/lib/module/skia/types/AnimatedImage/index.js.map +1 -0
  60. package/lib/module/skia/types/Font/Font.d.ts +9 -0
  61. package/lib/module/skia/types/Font/Font.js.map +1 -1
  62. package/lib/module/skia/types/Skia.d.ts +2 -0
  63. package/lib/module/skia/types/Skia.js.map +1 -1
  64. package/lib/module/skia/types/index.d.ts +1 -0
  65. package/lib/module/skia/types/index.js +1 -0
  66. package/lib/module/skia/types/index.js.map +1 -1
  67. package/lib/module/skia/web/JsiSkAnimatedImage.d.ts +11 -0
  68. package/lib/module/skia/web/JsiSkAnimatedImage.js +33 -0
  69. package/lib/module/skia/web/JsiSkAnimatedImage.js.map +1 -0
  70. package/lib/module/skia/web/JsiSkAnimatedImageFactory.d.ts +9 -0
  71. package/lib/module/skia/web/JsiSkAnimatedImageFactory.js +20 -0
  72. package/lib/module/skia/web/JsiSkAnimatedImageFactory.js.map +1 -0
  73. package/lib/module/skia/web/JsiSkFont.d.ts +2 -1
  74. package/lib/module/skia/web/JsiSkFont.js +5 -1
  75. package/lib/module/skia/web/JsiSkFont.js.map +1 -1
  76. package/lib/module/skia/web/JsiSkia.js +2 -0
  77. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  78. package/lib/typescript/src/external/reanimated/moduleWrapper.d.ts +2 -0
  79. package/lib/typescript/src/skia/core/AnimatedImage.d.ts +6 -0
  80. package/lib/typescript/src/skia/core/index.d.ts +1 -0
  81. package/lib/typescript/src/skia/types/AnimatedImage/AnimatedImage.d.ts +24 -0
  82. package/lib/typescript/src/skia/types/AnimatedImage/AnimatedImageFactory.d.ts +13 -0
  83. package/lib/typescript/src/skia/types/AnimatedImage/index.d.ts +2 -0
  84. package/lib/typescript/src/skia/types/Font/Font.d.ts +9 -0
  85. package/lib/typescript/src/skia/types/Skia.d.ts +2 -0
  86. package/lib/typescript/src/skia/types/index.d.ts +1 -0
  87. package/lib/typescript/src/skia/web/JsiSkAnimatedImage.d.ts +11 -0
  88. package/lib/typescript/src/skia/web/JsiSkAnimatedImageFactory.d.ts +9 -0
  89. package/lib/typescript/src/skia/web/JsiSkFont.d.ts +2 -1
  90. package/package.json +1 -1
  91. package/src/external/reanimated/moduleWrapper.ts +9 -8
  92. package/src/skia/core/AnimatedImage.ts +63 -0
  93. package/src/skia/core/index.ts +1 -0
  94. package/src/skia/types/AnimatedImage/AnimatedImage.ts +29 -0
  95. package/src/skia/types/AnimatedImage/AnimatedImageFactory.ts +15 -0
  96. package/src/skia/types/AnimatedImage/index.ts +2 -0
  97. package/src/skia/types/Font/Font.ts +10 -0
  98. package/src/skia/types/Skia.ts +3 -0
  99. package/src/skia/types/index.ts +1 -0
  100. package/src/skia/web/JsiSkAnimatedImage.ts +35 -0
  101. package/src/skia/web/JsiSkAnimatedImageFactory.ts +27 -0
  102. package/src/skia/web/JsiSkFont.ts +6 -1
  103. package/src/skia/web/JsiSkia.ts +2 -0
  104. package/lib/commonjs/dom/nodes/PaintContext.d.ts +0 -19
  105. package/lib/commonjs/dom/nodes/PaintContext.js.map +0 -1
  106. package/lib/module/dom/nodes/PaintContext.d.ts +0 -19
  107. package/lib/module/dom/nodes/PaintContext.js +0 -2
  108. package/lib/module/dom/nodes/PaintContext.js.map +0 -1
  109. package/lib/typescript/src/dom/nodes/PaintContext.d.ts +0 -19
  110. package/src/dom/nodes/PaintContext.ts +0 -32
@@ -24,6 +24,7 @@ import type { SkContourMeasureIter } from "./ContourMeasure";
24
24
  import type { PictureFactory, SkPictureRecorder } from "./Picture";
25
25
  import type { Color, SkColor } from "./Color";
26
26
  import type { TypefaceFontProviderFactory } from "./Paragraph/TypefaceFontProviderFactory";
27
+ import type { AnimatedImageFactory } from "./AnimatedImage";
27
28
  /**
28
29
  * Declares the interface for the native Skia API
29
30
  */
@@ -63,6 +64,7 @@ export interface Skia {
63
64
  MakeVertices(mode: VertexMode, positions: SkPoint[], textureCoordinates?: SkPoint[] | null, colors?: SkColor[], indices?: number[] | null, isVolatile?: boolean): SkVertices;
64
65
  Data: DataFactory;
65
66
  Image: ImageFactory;
67
+ AnimatedImage: AnimatedImageFactory;
66
68
  SVG: SVGFactory;
67
69
  TextBlob: TextBlobFactory;
68
70
  Surface: SurfaceFactory;
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["Skia.ts"],"sourcesContent":["import type { ImageFilterFactory } from \"./ImageFilter\";\nimport type { PathFactory } from \"./Path\";\nimport type { ColorFilterFactory } from \"./ColorFilter\";\nimport type { SkFont, FontMgrFactory } from \"./Font\";\nimport type { SkTypeface, TypefaceFactory } from \"./Typeface\";\nimport type { ImageFactory } from \"./Image\";\nimport type { MaskFilterFactory } from \"./MaskFilter\";\nimport type { SkPaint } from \"./Paint\";\nimport type { SkRect } from \"./Rect\";\nimport type { SkRRect } from \"./RRect\";\nimport type {\n RuntimeEffectFactory,\n SkRuntimeEffect,\n SkRuntimeShaderBuilder,\n} from \"./RuntimeEffect\";\nimport type { ShaderFactory } from \"./Shader\";\nimport type { SkMatrix } from \"./Matrix\";\nimport type { PathEffectFactory } from \"./PathEffect\";\nimport type { SkPoint } from \"./Point\";\nimport type { SkVertices, VertexMode } from \"./Vertices/Vertices\";\nimport type { DataFactory } from \"./Data\";\nimport type { SVGFactory } from \"./SVG\";\nimport type { TextBlobFactory } from \"./TextBlob\";\nimport type { SurfaceFactory } from \"./Surface\";\nimport type { SkRSXform } from \"./RSXform\";\nimport type { SkPath } from \"./Path/Path\";\nimport type { SkContourMeasureIter } from \"./ContourMeasure\";\nimport type { PictureFactory, SkPictureRecorder } from \"./Picture\";\nimport type { Color, SkColor } from \"./Color\";\nimport type { TypefaceFontProviderFactory } from \"./Paragraph/TypefaceFontProviderFactory\";\n/**\n * Declares the interface for the native Skia API\n */\nexport interface Skia {\n Point: (x: number, y: number) => SkPoint;\n XYWHRect: (x: number, y: number, width: number, height: number) => SkRect;\n RuntimeShaderBuilder: (rt: SkRuntimeEffect) => SkRuntimeShaderBuilder;\n RRectXY: (rect: SkRect, rx: number, ry: number) => SkRRect;\n RSXform: (scos: number, ssin: number, tx: number, ty: number) => SkRSXform;\n Color: (color: Color) => SkColor;\n ContourMeasureIter: (\n path: SkPath,\n forceClosed: boolean,\n resScale: number\n ) => SkContourMeasureIter;\n Paint: () => SkPaint;\n PictureRecorder: () => SkPictureRecorder;\n Picture: PictureFactory;\n Path: PathFactory;\n Matrix: (matrix?: readonly number[]) => SkMatrix;\n ColorFilter: ColorFilterFactory;\n Font: (typeface?: SkTypeface, size?: number) => SkFont;\n Typeface: TypefaceFactory;\n TypefaceFontProvider: TypefaceFontProviderFactory;\n FontMgr: FontMgrFactory;\n MaskFilter: MaskFilterFactory;\n RuntimeEffect: RuntimeEffectFactory;\n ImageFilter: ImageFilterFactory;\n Shader: ShaderFactory;\n PathEffect: PathEffectFactory;\n /**\n * Returns an Vertices based on the given positions and optional parameters.\n * See SkVertices.h (especially the Builder) for more details.\n * @param mode\n * @param positions\n * @param textureCoordinates\n * @param colors - either a list of int colors or a flattened color array.\n * @param indices\n * @param isVolatile\n */\n MakeVertices(\n mode: VertexMode,\n positions: SkPoint[],\n textureCoordinates?: SkPoint[] | null,\n colors?: SkColor[],\n indices?: number[] | null,\n isVolatile?: boolean\n ): SkVertices;\n Data: DataFactory;\n Image: ImageFactory;\n SVG: SVGFactory;\n TextBlob: TextBlobFactory;\n Surface: SurfaceFactory;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["Skia.ts"],"sourcesContent":["import type { ImageFilterFactory } from \"./ImageFilter\";\nimport type { PathFactory } from \"./Path\";\nimport type { ColorFilterFactory } from \"./ColorFilter\";\nimport type { SkFont, FontMgrFactory } from \"./Font\";\nimport type { SkTypeface, TypefaceFactory } from \"./Typeface\";\nimport type { ImageFactory } from \"./Image\";\nimport type { MaskFilterFactory } from \"./MaskFilter\";\nimport type { SkPaint } from \"./Paint\";\nimport type { SkRect } from \"./Rect\";\nimport type { SkRRect } from \"./RRect\";\nimport type {\n RuntimeEffectFactory,\n SkRuntimeEffect,\n SkRuntimeShaderBuilder,\n} from \"./RuntimeEffect\";\nimport type { ShaderFactory } from \"./Shader\";\nimport type { SkMatrix } from \"./Matrix\";\nimport type { PathEffectFactory } from \"./PathEffect\";\nimport type { SkPoint } from \"./Point\";\nimport type { SkVertices, VertexMode } from \"./Vertices/Vertices\";\nimport type { DataFactory } from \"./Data\";\nimport type { SVGFactory } from \"./SVG\";\nimport type { TextBlobFactory } from \"./TextBlob\";\nimport type { SurfaceFactory } from \"./Surface\";\nimport type { SkRSXform } from \"./RSXform\";\nimport type { SkPath } from \"./Path/Path\";\nimport type { SkContourMeasureIter } from \"./ContourMeasure\";\nimport type { PictureFactory, SkPictureRecorder } from \"./Picture\";\nimport type { Color, SkColor } from \"./Color\";\nimport type { TypefaceFontProviderFactory } from \"./Paragraph/TypefaceFontProviderFactory\";\nimport type { AnimatedImageFactory } from \"./AnimatedImage\";\n\n/**\n * Declares the interface for the native Skia API\n */\nexport interface Skia {\n Point: (x: number, y: number) => SkPoint;\n XYWHRect: (x: number, y: number, width: number, height: number) => SkRect;\n RuntimeShaderBuilder: (rt: SkRuntimeEffect) => SkRuntimeShaderBuilder;\n RRectXY: (rect: SkRect, rx: number, ry: number) => SkRRect;\n RSXform: (scos: number, ssin: number, tx: number, ty: number) => SkRSXform;\n Color: (color: Color) => SkColor;\n ContourMeasureIter: (\n path: SkPath,\n forceClosed: boolean,\n resScale: number\n ) => SkContourMeasureIter;\n Paint: () => SkPaint;\n PictureRecorder: () => SkPictureRecorder;\n Picture: PictureFactory;\n Path: PathFactory;\n Matrix: (matrix?: readonly number[]) => SkMatrix;\n ColorFilter: ColorFilterFactory;\n Font: (typeface?: SkTypeface, size?: number) => SkFont;\n Typeface: TypefaceFactory;\n TypefaceFontProvider: TypefaceFontProviderFactory;\n FontMgr: FontMgrFactory;\n MaskFilter: MaskFilterFactory;\n RuntimeEffect: RuntimeEffectFactory;\n ImageFilter: ImageFilterFactory;\n Shader: ShaderFactory;\n PathEffect: PathEffectFactory;\n /**\n * Returns an Vertices based on the given positions and optional parameters.\n * See SkVertices.h (especially the Builder) for more details.\n * @param mode\n * @param positions\n * @param textureCoordinates\n * @param colors - either a list of int colors or a flattened color array.\n * @param indices\n * @param isVolatile\n */\n MakeVertices(\n mode: VertexMode,\n positions: SkPoint[],\n textureCoordinates?: SkPoint[] | null,\n colors?: SkColor[],\n indices?: number[] | null,\n isVolatile?: boolean\n ): SkVertices;\n Data: DataFactory;\n Image: ImageFactory;\n AnimatedImage: AnimatedImageFactory;\n SVG: SVGFactory;\n TextBlob: TextBlobFactory;\n Surface: SurfaceFactory;\n}\n"],"mappings":""}
@@ -6,6 +6,7 @@ export * from "./Vertices";
6
6
  export * from "./RuntimeEffect";
7
7
  export * from "./Shader";
8
8
  export * from "./Image";
9
+ export * from "./AnimatedImage";
9
10
  export * from "./ColorFilter";
10
11
  export * from "./ImageFilter";
11
12
  export * from "./Font";
@@ -6,6 +6,7 @@ export * from "./Vertices";
6
6
  export * from "./RuntimeEffect";
7
7
  export * from "./Shader";
8
8
  export * from "./Image";
9
+ export * from "./AnimatedImage";
9
10
  export * from "./ColorFilter";
10
11
  export * from "./ImageFilter";
11
12
  export * from "./Font";
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./Picture\";\nexport * from \"./Data\";\nexport * from \"./SVG\";\nexport * from \"./Surface\";\nexport * from \"./Vertices\";\nexport * from \"./RuntimeEffect\";\nexport * from \"./Shader\";\nexport * from \"./Image\";\nexport * from \"./ColorFilter\";\nexport * from \"./ImageFilter\";\nexport * from \"./Font\";\nexport * from \"./Typeface\";\nexport * from \"./Paint\";\nexport * from \"./Path\";\nexport * from \"./Color\";\nexport * from \"./Canvas\";\nexport * from \"./ContourMeasure\";\nexport * from \"./MaskFilter\";\nexport * from \"./Matrix\";\nexport * from \"./PathEffect\";\nexport * from \"./Point\";\nexport * from \"./Rect\";\nexport * from \"./RRect\";\nexport * from \"./RSXform\";\nexport * from \"./JsiInstance\";\nexport * from \"./Skia\";\nexport * from \"./TextBlob\";\nexport * from \"./Size\";\n"],"mappings":"AAAA,cAAc,WAAd;AACA,cAAc,QAAd;AACA,cAAc,OAAd;AACA,cAAc,WAAd;AACA,cAAc,YAAd;AACA,cAAc,iBAAd;AACA,cAAc,UAAd;AACA,cAAc,SAAd;AACA,cAAc,eAAd;AACA,cAAc,eAAd;AACA,cAAc,QAAd;AACA,cAAc,YAAd;AACA,cAAc,SAAd;AACA,cAAc,QAAd;AACA,cAAc,SAAd;AACA,cAAc,UAAd;AACA,cAAc,kBAAd;AACA,cAAc,cAAd;AACA,cAAc,UAAd;AACA,cAAc,cAAd;AACA,cAAc,SAAd;AACA,cAAc,QAAd;AACA,cAAc,SAAd;AACA,cAAc,WAAd;AACA,cAAc,eAAd;AACA,cAAc,QAAd;AACA,cAAc,YAAd;AACA,cAAc,QAAd"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./Picture\";\nexport * from \"./Data\";\nexport * from \"./SVG\";\nexport * from \"./Surface\";\nexport * from \"./Vertices\";\nexport * from \"./RuntimeEffect\";\nexport * from \"./Shader\";\nexport * from \"./Image\";\nexport * from \"./AnimatedImage\";\nexport * from \"./ColorFilter\";\nexport * from \"./ImageFilter\";\nexport * from \"./Font\";\nexport * from \"./Typeface\";\nexport * from \"./Paint\";\nexport * from \"./Path\";\nexport * from \"./Color\";\nexport * from \"./Canvas\";\nexport * from \"./ContourMeasure\";\nexport * from \"./MaskFilter\";\nexport * from \"./Matrix\";\nexport * from \"./PathEffect\";\nexport * from \"./Point\";\nexport * from \"./Rect\";\nexport * from \"./RRect\";\nexport * from \"./RSXform\";\nexport * from \"./JsiInstance\";\nexport * from \"./Skia\";\nexport * from \"./TextBlob\";\nexport * from \"./Size\";\n"],"mappings":"AAAA,cAAc,WAAd;AACA,cAAc,QAAd;AACA,cAAc,OAAd;AACA,cAAc,WAAd;AACA,cAAc,YAAd;AACA,cAAc,iBAAd;AACA,cAAc,UAAd;AACA,cAAc,SAAd;AACA,cAAc,iBAAd;AACA,cAAc,eAAd;AACA,cAAc,eAAd;AACA,cAAc,QAAd;AACA,cAAc,YAAd;AACA,cAAc,SAAd;AACA,cAAc,QAAd;AACA,cAAc,SAAd;AACA,cAAc,UAAd;AACA,cAAc,kBAAd;AACA,cAAc,cAAd;AACA,cAAc,UAAd;AACA,cAAc,cAAd;AACA,cAAc,SAAd;AACA,cAAc,QAAd;AACA,cAAc,SAAd;AACA,cAAc,WAAd;AACA,cAAc,eAAd;AACA,cAAc,QAAd;AACA,cAAc,YAAd;AACA,cAAc,QAAd"}
@@ -0,0 +1,11 @@
1
+ import type { AnimatedImage, CanvasKit } from "canvaskit-wasm";
2
+ import type { SkAnimatedImage } from "../types/AnimatedImage";
3
+ import { HostObject } from "./Host";
4
+ import { JsiSkImage } from "./JsiSkImage";
5
+ export declare class JsiSkAnimatedImage extends HostObject<AnimatedImage, "AnimatedImage"> implements SkAnimatedImage {
6
+ constructor(CanvasKit: CanvasKit, ref: AnimatedImage);
7
+ decodeNextFrame(): number;
8
+ currentFrameDuration(): number;
9
+ getCurrentFrame(): JsiSkImage | null;
10
+ dispose: () => void;
11
+ }
@@ -0,0 +1,33 @@
1
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+
3
+ import { HostObject } from "./Host";
4
+ import { JsiSkImage } from "./JsiSkImage";
5
+ export class JsiSkAnimatedImage extends HostObject {
6
+ constructor(CanvasKit, ref) {
7
+ super(CanvasKit, ref, "AnimatedImage");
8
+
9
+ _defineProperty(this, "dispose", () => {
10
+ this.ref.delete();
11
+ });
12
+ }
13
+
14
+ decodeNextFrame() {
15
+ return this.ref.decodeNextFrame();
16
+ }
17
+
18
+ currentFrameDuration() {
19
+ return this.ref.currentFrameDuration();
20
+ }
21
+
22
+ getCurrentFrame() {
23
+ const image = this.ref.makeImageAtCurrentFrame();
24
+
25
+ if (image === null) {
26
+ return null;
27
+ }
28
+
29
+ return new JsiSkImage(this.CanvasKit, image);
30
+ }
31
+
32
+ }
33
+ //# sourceMappingURL=JsiSkAnimatedImage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["HostObject","JsiSkImage","JsiSkAnimatedImage","constructor","CanvasKit","ref","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,UAAT,QAA2B,QAA3B;AACA,SAASC,UAAT,QAA2B,cAA3B;AAEA,OAAO,MAAMC,kBAAN,SACGF,UADH,CAGP;EACEG,WAAW,CAACC,SAAD,EAAuBC,GAAvB,EAA2C;IACpD,MAAMD,SAAN,EAAiBC,GAAjB,EAAsB,eAAtB;;IADoD,iCAoB5C,MAAM;MACd,KAAKA,GAAL,CAASC,MAAT;IACD,CAtBqD;EAErD;;EAEDC,eAAe,GAAG;IAChB,OAAO,KAAKF,GAAL,CAASE,eAAT,EAAP;EACD;;EAEDC,oBAAoB,GAAG;IACrB,OAAO,KAAKH,GAAL,CAASG,oBAAT,EAAP;EACD;;EAEDC,eAAe,GAAG;IAChB,MAAMC,KAAK,GAAG,KAAKL,GAAL,CAASM,uBAAT,EAAd;;IACA,IAAID,KAAK,KAAK,IAAd,EAAoB;MAClB,OAAO,IAAP;IACD;;IACD,OAAO,IAAIT,UAAJ,CAAe,KAAKG,SAApB,EAA+BM,KAA/B,CAAP;EACD;;AAnBH"}
@@ -0,0 +1,9 @@
1
+ import type { CanvasKit } from "canvaskit-wasm";
2
+ import type { SkData } from "../types";
3
+ import type { AnimatedImageFactory } from "../types/AnimatedImage/AnimatedImageFactory";
4
+ import { Host } from "./Host";
5
+ import { JsiSkAnimatedImage } from "./JsiSkAnimatedImage";
6
+ export declare class JsiSkAnimatedImageFactory extends Host implements AnimatedImageFactory {
7
+ constructor(CanvasKit: CanvasKit);
8
+ MakeAnimatedImageFromEncoded(encoded: SkData): JsiSkAnimatedImage | null;
9
+ }
@@ -0,0 +1,20 @@
1
+ import { Host } from "./Host";
2
+ import { JsiSkData } from "./JsiSkData";
3
+ import { JsiSkAnimatedImage } from "./JsiSkAnimatedImage";
4
+ export class JsiSkAnimatedImageFactory extends Host {
5
+ constructor(CanvasKit) {
6
+ super(CanvasKit);
7
+ }
8
+
9
+ MakeAnimatedImageFromEncoded(encoded) {
10
+ const image = this.CanvasKit.MakeAnimatedImageFromEncoded(JsiSkData.fromValue(encoded));
11
+
12
+ if (image === null) {
13
+ return null;
14
+ }
15
+
16
+ return new JsiSkAnimatedImage(this.CanvasKit, image);
17
+ }
18
+
19
+ }
20
+ //# sourceMappingURL=JsiSkAnimatedImageFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Host","JsiSkData","JsiSkAnimatedImage","JsiSkAnimatedImageFactory","constructor","CanvasKit","MakeAnimatedImageFromEncoded","encoded","image","fromValue"],"sources":["JsiSkAnimatedImageFactory.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type { SkData } from \"../types\";\nimport type { AnimatedImageFactory } from \"../types/AnimatedImage/AnimatedImageFactory\";\n\nimport { Host } from \"./Host\";\nimport { JsiSkData } from \"./JsiSkData\";\nimport { JsiSkAnimatedImage } from \"./JsiSkAnimatedImage\";\n\nexport class JsiSkAnimatedImageFactory\n extends Host\n implements AnimatedImageFactory\n{\n constructor(CanvasKit: CanvasKit) {\n super(CanvasKit);\n }\n\n MakeAnimatedImageFromEncoded(encoded: SkData) {\n const image = this.CanvasKit.MakeAnimatedImageFromEncoded(\n JsiSkData.fromValue(encoded)\n );\n if (image === null) {\n return null;\n }\n return new JsiSkAnimatedImage(this.CanvasKit, image);\n }\n}\n"],"mappings":"AAKA,SAASA,IAAT,QAAqB,QAArB;AACA,SAASC,SAAT,QAA0B,aAA1B;AACA,SAASC,kBAAT,QAAmC,sBAAnC;AAEA,OAAO,MAAMC,yBAAN,SACGH,IADH,CAGP;EACEI,WAAW,CAACC,SAAD,EAAuB;IAChC,MAAMA,SAAN;EACD;;EAEDC,4BAA4B,CAACC,OAAD,EAAkB;IAC5C,MAAMC,KAAK,GAAG,KAAKH,SAAL,CAAeC,4BAAf,CACZL,SAAS,CAACQ,SAAV,CAAoBF,OAApB,CADY,CAAd;;IAGA,IAAIC,KAAK,KAAK,IAAd,EAAoB;MAClB,OAAO,IAAP;IACD;;IACD,OAAO,IAAIN,kBAAJ,CAAuB,KAAKG,SAA5B,EAAuCG,KAAvC,CAAP;EACD;;AAbH"}
@@ -1,10 +1,11 @@
1
1
  import type { CanvasKit, Font } from "canvaskit-wasm";
2
- import type { FontEdging, FontHinting, SkFont, SkPaint, SkPoint, SkTypeface } from "../types";
2
+ import type { FontEdging, FontHinting, SkFont, SkPaint, SkPoint, SkRect, SkTypeface } from "../types";
3
3
  import { HostObject } from "./Host";
4
4
  import { JsiSkRect } from "./JsiSkRect";
5
5
  import { JsiSkTypeface } from "./JsiSkTypeface";
6
6
  export declare class JsiSkFont extends HostObject<Font, "Font"> implements SkFont {
7
7
  constructor(CanvasKit: CanvasKit, ref: Font);
8
+ measureText(_text: string, _paint?: SkPaint | undefined): SkRect;
8
9
  dispose: () => void;
9
10
  getTextWidth(text: string, paint?: SkPaint | undefined): number;
10
11
  getMetrics(): {
@@ -1,6 +1,6 @@
1
1
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
2
 
3
- import { HostObject, ckEnum } from "./Host";
3
+ import { HostObject, NotImplementedOnRNWeb, ckEnum } from "./Host";
4
4
  import { JsiSkPaint } from "./JsiSkPaint";
5
5
  import { JsiSkPoint } from "./JsiSkPoint";
6
6
  import { JsiSkRect } from "./JsiSkRect";
@@ -14,6 +14,10 @@ export class JsiSkFont extends HostObject {
14
14
  });
15
15
  }
16
16
 
17
+ measureText(_text, _paint) {
18
+ throw new NotImplementedOnRNWeb();
19
+ }
20
+
17
21
  getTextWidth(text, paint) {
18
22
  const ids = this.getGlyphIDs(text);
19
23
  const widths = this.getGlyphWidths(ids, paint);
@@ -1 +1 @@
1
- {"version":3,"names":["HostObject","ckEnum","JsiSkPaint","JsiSkPoint","JsiSkRect","JsiSkTypeface","JsiSkFont","constructor","CanvasKit","ref","delete","getTextWidth","text","paint","ids","getGlyphIDs","widths","getGlyphWidths","reduce","a","b","getMetrics","result","ascent","descent","leading","bounds","undefined","str","numCodePoints","glyphs","fromValue","getGlyphIntercepts","positions","top","bottom","map","p","Array","from","flat","getScaleX","getSize","getSkewX","isEmbolden","getTypeface","tf","setEdging","edging","setEmbeddedBitmaps","embeddedBitmaps","setHinting","hinting","setLinearMetrics","linearMetrics","setScaleX","sx","setSize","points","setSkewX","setEmbolden","embolden","setSubpixel","subpixel","setTypeface","face"],"sources":["JsiSkFont.ts"],"sourcesContent":["import type { CanvasKit, Font } from \"canvaskit-wasm\";\n\nimport type {\n FontEdging,\n FontHinting,\n SkFont,\n SkPaint,\n SkPoint,\n SkTypeface,\n} from \"../types\";\n\nimport { HostObject, ckEnum } from \"./Host\";\nimport { JsiSkPaint } from \"./JsiSkPaint\";\nimport { JsiSkPoint } from \"./JsiSkPoint\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { JsiSkTypeface } from \"./JsiSkTypeface\";\n\nexport class JsiSkFont extends HostObject<Font, \"Font\"> implements SkFont {\n constructor(CanvasKit: CanvasKit, ref: Font) {\n super(CanvasKit, ref, \"Font\");\n }\n\n dispose = () => {\n this.ref.delete();\n };\n\n getTextWidth(text: string, paint?: SkPaint | undefined) {\n const ids = this.getGlyphIDs(text);\n const widths = this.getGlyphWidths(ids, paint);\n return widths.reduce((a, b) => a + b, 0);\n }\n\n getMetrics() {\n const result = this.ref.getMetrics();\n return {\n ascent: result.ascent,\n descent: result.descent,\n leading: result.leading,\n bounds: result.bounds\n ? new JsiSkRect(this.CanvasKit, result.bounds)\n : undefined,\n };\n }\n\n getGlyphIDs(str: string, numCodePoints?: number) {\n // TODO: Fix return value in the C++ implementation\n return [...this.ref.getGlyphIDs(str, numCodePoints)];\n }\n\n // TODO: Fix return value in the C++ implementation, it return float32\n getGlyphWidths(glyphs: number[], paint?: SkPaint | null) {\n return [\n ...this.ref.getGlyphWidths(\n glyphs,\n paint ? JsiSkPaint.fromValue(paint) : null\n ),\n ];\n }\n\n getGlyphIntercepts(\n glyphs: number[],\n positions: SkPoint[],\n top: number,\n bottom: number\n ) {\n return [\n ...this.ref.getGlyphIntercepts(\n glyphs,\n positions.map((p) => Array.from(JsiSkPoint.fromValue(p))).flat(),\n top,\n bottom\n ),\n ];\n }\n\n getScaleX() {\n return this.ref.getScaleX();\n }\n\n getSize() {\n return this.ref.getSize();\n }\n\n getSkewX() {\n return this.ref.getSkewX();\n }\n\n isEmbolden() {\n return this.ref.isEmbolden();\n }\n\n getTypeface() {\n const tf = this.ref.getTypeface();\n return tf ? new JsiSkTypeface(this.CanvasKit, tf) : null;\n }\n\n setEdging(edging: FontEdging) {\n this.ref.setEdging(ckEnum(edging));\n }\n\n setEmbeddedBitmaps(embeddedBitmaps: boolean) {\n this.ref.setEmbeddedBitmaps(embeddedBitmaps);\n }\n\n setHinting(hinting: FontHinting) {\n this.ref.setHinting(ckEnum(hinting));\n }\n\n setLinearMetrics(linearMetrics: boolean) {\n this.ref.setLinearMetrics(linearMetrics);\n }\n\n setScaleX(sx: number) {\n this.ref.setScaleX(sx);\n }\n\n setSize(points: number) {\n this.ref.setSize(points);\n }\n\n setSkewX(sx: number) {\n this.ref.setSkewX(sx);\n }\n\n setEmbolden(embolden: boolean) {\n this.ref.setEmbolden(embolden);\n }\n\n setSubpixel(subpixel: boolean) {\n this.ref.setSubpixel(subpixel);\n }\n\n setTypeface(face: SkTypeface | null) {\n this.ref.setTypeface(face ? JsiSkTypeface.fromValue(face) : null);\n }\n}\n"],"mappings":";;AAWA,SAASA,UAAT,EAAqBC,MAArB,QAAmC,QAAnC;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,SAAT,QAA0B,aAA1B;AACA,SAASC,aAAT,QAA8B,iBAA9B;AAEA,OAAO,MAAMC,SAAN,SAAwBN,UAAxB,CAAmE;EACxEO,WAAW,CAACC,SAAD,EAAuBC,GAAvB,EAAkC;IAC3C,MAAMD,SAAN,EAAiBC,GAAjB,EAAsB,MAAtB;;IAD2C,iCAInC,MAAM;MACd,KAAKA,GAAL,CAASC,MAAT;IACD,CAN4C;EAE5C;;EAMDC,YAAY,CAACC,IAAD,EAAeC,KAAf,EAA4C;IACtD,MAAMC,GAAG,GAAG,KAAKC,WAAL,CAAiBH,IAAjB,CAAZ;IACA,MAAMI,MAAM,GAAG,KAAKC,cAAL,CAAoBH,GAApB,EAAyBD,KAAzB,CAAf;IACA,OAAOG,MAAM,CAACE,MAAP,CAAc,CAACC,CAAD,EAAIC,CAAJ,KAAUD,CAAC,GAAGC,CAA5B,EAA+B,CAA/B,CAAP;EACD;;EAEDC,UAAU,GAAG;IACX,MAAMC,MAAM,GAAG,KAAKb,GAAL,CA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,"names":["HostObject","NotImplementedOnRNWeb","ckEnum","JsiSkPaint","JsiSkPoint","JsiSkRect","JsiSkTypeface","JsiSkFont","constructor","CanvasKit","ref","delete","measureText","_text","_paint","getTextWidth","text","paint","ids","getGlyphIDs","widths","getGlyphWidths","reduce","a","b","getMetrics","result","ascent","descent","leading","bounds","undefined","str","numCodePoints","glyphs","fromValue","getGlyphIntercepts","positions","top","bottom","map","p","Array","from","flat","getScaleX","getSize","getSkewX","isEmbolden","getTypeface","tf","setEdging","edging","setEmbeddedBitmaps","embeddedBitmaps","setHinting","hinting","setLinearMetrics","linearMetrics","setScaleX","sx","setSize","points","setSkewX","setEmbolden","embolden","setSubpixel","subpixel","setTypeface","face"],"sources":["JsiSkFont.ts"],"sourcesContent":["import type { CanvasKit, Font } from \"canvaskit-wasm\";\n\nimport type {\n FontEdging,\n FontHinting,\n SkFont,\n SkPaint,\n SkPoint,\n SkRect,\n SkTypeface,\n} from \"../types\";\n\nimport { HostObject, NotImplementedOnRNWeb, ckEnum } from \"./Host\";\nimport { JsiSkPaint } from \"./JsiSkPaint\";\nimport { JsiSkPoint } from \"./JsiSkPoint\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { JsiSkTypeface } from \"./JsiSkTypeface\";\n\nexport class JsiSkFont extends HostObject<Font, \"Font\"> implements SkFont {\n constructor(CanvasKit: CanvasKit, ref: Font) {\n super(CanvasKit, ref, \"Font\");\n }\n\n measureText(_text: string, _paint?: SkPaint | undefined): SkRect {\n throw new NotImplementedOnRNWeb();\n }\n\n dispose = () => {\n this.ref.delete();\n };\n\n getTextWidth(text: string, paint?: SkPaint | undefined) {\n const ids = this.getGlyphIDs(text);\n const widths = this.getGlyphWidths(ids, paint);\n return widths.reduce((a, b) => a + b, 0);\n }\n\n getMetrics() {\n const result = this.ref.getMetrics();\n return {\n ascent: result.ascent,\n descent: result.descent,\n leading: result.leading,\n bounds: result.bounds\n ? new JsiSkRect(this.CanvasKit, result.bounds)\n : undefined,\n };\n }\n\n getGlyphIDs(str: string, numCodePoints?: number) {\n // TODO: Fix return value in the C++ implementation\n return [...this.ref.getGlyphIDs(str, numCodePoints)];\n }\n\n // TODO: Fix return value in the C++ implementation, it return float32\n getGlyphWidths(glyphs: number[], paint?: SkPaint | null) {\n return [\n ...this.ref.getGlyphWidths(\n glyphs,\n paint ? JsiSkPaint.fromValue(paint) : null\n ),\n ];\n }\n\n getGlyphIntercepts(\n glyphs: number[],\n positions: SkPoint[],\n top: number,\n bottom: number\n ) {\n return [\n ...this.ref.getGlyphIntercepts(\n glyphs,\n positions.map((p) => Array.from(JsiSkPoint.fromValue(p))).flat(),\n top,\n bottom\n ),\n ];\n }\n\n getScaleX() {\n return this.ref.getScaleX();\n }\n\n getSize() {\n return this.ref.getSize();\n }\n\n getSkewX() {\n return this.ref.getSkewX();\n }\n\n isEmbolden() {\n return this.ref.isEmbolden();\n }\n\n getTypeface() {\n const tf = this.ref.getTypeface();\n return tf ? new JsiSkTypeface(this.CanvasKit, tf) : null;\n }\n\n setEdging(edging: FontEdging) {\n this.ref.setEdging(ckEnum(edging));\n }\n\n setEmbeddedBitmaps(embeddedBitmaps: boolean) {\n this.ref.setEmbeddedBitmaps(embeddedBitmaps);\n }\n\n setHinting(hinting: FontHinting) {\n this.ref.setHinting(ckEnum(hinting));\n }\n\n setLinearMetrics(linearMetrics: boolean) {\n this.ref.setLinearMetrics(linearMetrics);\n }\n\n setScaleX(sx: number) {\n this.ref.setScaleX(sx);\n }\n\n setSize(points: number) {\n this.ref.setSize(points);\n }\n\n setSkewX(sx: number) {\n this.ref.setSkewX(sx);\n }\n\n setEmbolden(embolden: boolean) {\n this.ref.setEmbolden(embolden);\n }\n\n setSubpixel(subpixel: boolean) {\n this.ref.setSubpixel(subpixel);\n }\n\n setTypeface(face: SkTypeface | null) {\n this.ref.setTypeface(face ? JsiSkTypeface.fromValue(face) : null);\n }\n}\n"],"mappings":";;AAYA,SAASA,UAAT,EAAqBC,qBAArB,EAA4CC,MAA5C,QAA0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CAACC,OAAD,EAAuB;IAC/B,KAAK9C,GAAL,CAAS6C,UAAT,CAAoBrD,MAAM,CAACsD,OAAD,CAA1B;EACD;;EAEDC,gBAAgB,CAACC,aAAD,EAAyB;IACvC,KAAKhD,GAAL,CAAS+C,gBAAT,CAA0BC,aAA1B;EACD;;EAEDC,SAAS,CAACC,EAAD,EAAa;IACpB,KAAKlD,GAAL,CAASiD,SAAT,CAAmBC,EAAnB;EACD;;EAEDC,OAAO,CAACC,MAAD,EAAiB;IACtB,KAAKpD,GAAL,CAASmD,OAAT,CAAiBC,MAAjB;EACD;;EAEDC,QAAQ,CAACH,EAAD,EAAa;IACnB,KAAKlD,GAAL,CAASqD,QAAT,CAAkBH,EAAlB;EACD;;EAEDI,WAAW,CAACC,QAAD,EAAoB;IAC7B,KAAKvD,GAAL,CAASsD,WAAT,CAAqBC,QAArB;EACD;;EAEDC,WAAW,CAACC,QAAD,EAAoB;IAC7B,KAAKzD,GAAL,CAASwD,WAAT,CAAqBC,QAArB;EACD;;EAEDC,WAAW,CAACC,IAAD,EAA0B;IACnC,KAAK3D,GAAL,CAAS0D,WAAT,CAAqBC,IAAI,GAAG/D,aAAa,CAAC6B,SAAd,CAAwBkC,IAAxB,CAAH,GAAmC,IAA5D;EACD;;AAzHuE"}
@@ -27,6 +27,7 @@ import { JsiSkPath } from "./JsiSkPath";
27
27
  import { JsiSkTypeface } from "./JsiSkTypeface";
28
28
  import { JsiSkTypefaceFontProviderFactory } from "./JsiSkTypefaceFontProviderFactory";
29
29
  import { JsiSkFontMgrFactory } from "./JsiSkFontMgrFactory";
30
+ import { JsiSkAnimatedImageFactory } from "./JsiSkAnimatedImageFactory";
30
31
  export const JsiSkApi = CanvasKit => ({
31
32
  Point: (x, y) => new JsiSkPoint(CanvasKit, Float32Array.of(x, y)),
32
33
  RuntimeShaderBuilder: _ => {
@@ -56,6 +57,7 @@ export const JsiSkApi = CanvasKit => ({
56
57
  MakeVertices: MakeVertices.bind(null, CanvasKit),
57
58
  Data: new JsiSkDataFactory(CanvasKit),
58
59
  Image: new JsiSkImageFactory(CanvasKit),
60
+ AnimatedImage: new JsiSkAnimatedImageFactory(CanvasKit),
59
61
  SVG: new JsiSkSVGFactory(CanvasKit),
60
62
  TextBlob: new JsiSkTextBlobFactory(CanvasKit),
61
63
  XYWHRect: (x, y, width, height) => {
@@ -1 +1 @@
1
- {"version":3,"names":["JsiSkPoint","JsiSkPaint","JsiSkRect","Color","JsiSkSurfaceFactory","JsiSkRRect","JsiSkRSXform","JsiSkContourMeasureIter","JsiSkPictureRecorder","JsiSkPictureFactory","JsiSkPathFactory","JsiSkMatrix","JsiSkColorFilterFactory","JsiSkTypefaceFactory","JsiSkMaskFilterFactory","JsiSkRuntimeEffectFactory","JsiSkImageFilterFactory","JsiSkShaderFactory","JsiSkPathEffectFactory","JsiSkDataFactory","JsiSkImageFactory","JsiSkSVGFactory","JsiSkTextBlobFactory","JsiSkFont","MakeVertices","JsiSkPath","JsiSkTypeface","JsiSkTypefaceFontProviderFactory","JsiSkFontMgrFactory","JsiSkApi","CanvasKit","Point","x","y","Float32Array","of","RuntimeShaderBuilder","_","Error","RRectXY","rect","rx","ry","RSXform","scos","ssin","tx","ty","ContourMeasureIter","path","forceClosed","resScale","fromValue","Paint","paint","setAntiAlias","PictureRecorder","Picture","Path","Matrix","matrix","identity","ColorFilter","Font","typeface","size","undefined","Typeface","MaskFilter","RuntimeEffect","ImageFilter","Shader","PathEffect","bind","Data","Image","SVG","TextBlob","XYWHRect","width","height","Surface","TypefaceFontProvider","FontMgr"],"sources":["JsiSkia.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type {\n SkContourMeasureIter,\n Skia,\n SkPath,\n SkRect,\n SkRuntimeEffect,\n SkRuntimeShaderBuilder,\n SkTypeface,\n} from \"../types\";\n\nimport { JsiSkPoint } from \"./JsiSkPoint\";\nimport { JsiSkPaint } from \"./JsiSkPaint\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { Color } from \"./JsiSkColor\";\nimport { JsiSkSurfaceFactory } from \"./JsiSkSurfaceFactory\";\nimport { JsiSkRRect } from \"./JsiSkRRect\";\nimport { JsiSkRSXform } from \"./JsiSkRSXform\";\nimport { JsiSkContourMeasureIter } from \"./JsiSkContourMeasureIter\";\nimport { JsiSkPictureRecorder } from \"./JsiSkPictureRecorder\";\nimport { JsiSkPictureFactory } from \"./JsiSkPictureFactory\";\nimport { JsiSkPathFactory } from \"./JsiSkPathFactory\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\nimport { JsiSkColorFilterFactory } from \"./JsiSkColorFilterFactory\";\nimport { JsiSkTypefaceFactory } from \"./JsiSkTypefaceFactory\";\nimport { JsiSkMaskFilterFactory } from \"./JsiSkMaskFilterFactory\";\nimport { JsiSkRuntimeEffectFactory } from \"./JsiSkRuntimeEffectFactory\";\nimport { JsiSkImageFilterFactory } from \"./JsiSkImageFilterFactory\";\nimport { JsiSkShaderFactory } from \"./JsiSkShaderFactory\";\nimport { JsiSkPathEffectFactory } from \"./JsiSkPathEffectFactory\";\nimport { JsiSkDataFactory } from \"./JsiSkDataFactory\";\nimport { JsiSkImageFactory } from \"./JsiSkImageFactory\";\nimport { JsiSkSVGFactory } from \"./JsiSkSVGFactory\";\nimport { JsiSkTextBlobFactory } from \"./JsiSkTextBlobFactory\";\nimport { JsiSkFont } from \"./JsiSkFont\";\nimport { MakeVertices } from \"./JsiSkVerticesFactory\";\nimport { JsiSkPath } from \"./JsiSkPath\";\nimport { JsiSkTypeface } from \"./JsiSkTypeface\";\nimport { JsiSkTypefaceFontProviderFactory } from \"./JsiSkTypefaceFontProviderFactory\";\nimport { JsiSkFontMgrFactory } from \"./JsiSkFontMgrFactory\";\n\nexport const JsiSkApi = (CanvasKit: CanvasKit): Skia => ({\n Point: (x: number, y: number) =>\n new JsiSkPoint(CanvasKit, Float32Array.of(x, y)),\n RuntimeShaderBuilder: (_: SkRuntimeEffect): SkRuntimeShaderBuilder => {\n throw new Error(\"Not implemented on React Native Web\");\n },\n RRectXY: (rect: SkRect, rx: number, ry: number) =>\n new JsiSkRRect(CanvasKit, rect, rx, ry),\n RSXform: (scos: number, ssin: number, tx: number, ty: number) =>\n new JsiSkRSXform(CanvasKit, Float32Array.of(scos, ssin, tx, ty)),\n Color,\n ContourMeasureIter: (\n path: SkPath,\n forceClosed: boolean,\n resScale: number\n ): SkContourMeasureIter =>\n new JsiSkContourMeasureIter(\n CanvasKit,\n new CanvasKit.ContourMeasureIter(\n JsiSkPath.fromValue(path),\n forceClosed,\n resScale\n )\n ),\n Paint: () => {\n const paint = new JsiSkPaint(CanvasKit, new CanvasKit.Paint());\n paint.setAntiAlias(true);\n return paint;\n },\n PictureRecorder: () =>\n new JsiSkPictureRecorder(CanvasKit, new CanvasKit.PictureRecorder()),\n Picture: new JsiSkPictureFactory(CanvasKit),\n Path: new JsiSkPathFactory(CanvasKit),\n Matrix: (matrix?: readonly number[]) =>\n new JsiSkMatrix(\n CanvasKit,\n matrix\n ? Float32Array.of(...matrix)\n : Float32Array.of(...CanvasKit.Matrix.identity())\n ),\n ColorFilter: new JsiSkColorFilterFactory(CanvasKit),\n Font: (typeface?: SkTypeface, size?: number) =>\n new JsiSkFont(\n CanvasKit,\n new CanvasKit.Font(\n typeface === undefined ? null : JsiSkTypeface.fromValue(typeface),\n size\n )\n ),\n Typeface: new JsiSkTypefaceFactory(CanvasKit),\n MaskFilter: new JsiSkMaskFilterFactory(CanvasKit),\n RuntimeEffect: new JsiSkRuntimeEffectFactory(CanvasKit),\n ImageFilter: new JsiSkImageFilterFactory(CanvasKit),\n Shader: new JsiSkShaderFactory(CanvasKit),\n PathEffect: new JsiSkPathEffectFactory(CanvasKit),\n MakeVertices: MakeVertices.bind(null, CanvasKit),\n Data: new JsiSkDataFactory(CanvasKit),\n Image: new JsiSkImageFactory(CanvasKit),\n SVG: new JsiSkSVGFactory(CanvasKit),\n TextBlob: new JsiSkTextBlobFactory(CanvasKit),\n XYWHRect: (x: number, y: number, width: number, height: number) => {\n return new JsiSkRect(CanvasKit, CanvasKit.XYWHRect(x, y, width, height));\n },\n Surface: new JsiSkSurfaceFactory(CanvasKit),\n TypefaceFontProvider: new JsiSkTypefaceFontProviderFactory(CanvasKit),\n FontMgr: new JsiSkFontMgrFactory(CanvasKit),\n});\n"],"mappings":"AAYA,SAASA,UAAT,QAA2B,cAA3B;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,SAAT,QAA0B,aAA1B;AACA,SAASC,KAAT,QAAsB,cAAtB;AACA,SAASC,mBAAT,QAAoC,uBAApC;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,SAASC,uBAAT,QAAwC,2BAAxC;AACA,SAASC,oBAAT,QAAqC,wBAArC;AACA,SAASC,mBAAT,QAAoC,uBAApC;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,WAAT,QAA4B,eAA5B;AACA,SAASC,uBAAT,QAAwC,2BAAxC;AACA,SAASC,oBAAT,QAAqC,wBAArC;AACA,SAASC,sBAAT,QAAuC,0BAAvC;AACA,SAASC,yBAAT,QAA0C,6BAA1C;AACA,SAASC,uBAAT,QAAwC,2BAAxC;AACA,SAASC,kBAAT,QAAmC,sBAAnC;AACA,SAASC,sBAAT,QAAuC,0BAAvC;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,iBAAT,QAAkC,qBAAlC;AACA,SAASC,eAAT,QAAgC,mBAAhC;AACA,SAASC,oBAAT,QAAqC,wBAArC;AACA,SAASC,SAAT,QAA0B,aAA1B;AACA,SAASC,YAAT,QAA6B,wBAA7B;AACA,SAASC,SAAT,QAA0B,aAA1B;AACA,SAASC,aAAT,QAA8B,iBAA9B;AACA,SAASC,gCAAT,QAAiD,oCAAjD;AACA,SAASC,mBAAT,QAAoC,uBAApC;AAEA,OAAO,MAAMC,QAAQ,GAAIC,SAAD,KAAiC;EACvDC,KAAK,EAAE,CAACC,CAAD,EAAYC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J,CAAyBQ,SAAzB,CA3D6C;EA4DvDgD,QAAQ,EAAE,CAAC9C,CAAD,EAAYC,CAAZ,EAAuB8C,KAAvB,EAAsCC,MAAtC,KAAyD;IACjE,OAAO,IAAI9E,SAAJ,CAAc4B,SAAd,EAAyBA,SAAS,CAACgD,QAAV,CAAmB9C,CAAnB,EAAsBC,CAAtB,EAAyB8C,KAAzB,EAAgCC,MAAhC,CAAzB,CAAP;EACD,CA9DsD;EA+DvDC,OAAO,EAAE,IAAI7E,mBAAJ,CAAwB0B,SAAxB,CA/D8C;EAgEvDoD,oBAAoB,EAAE,IAAIvD,gCAAJ,CAAqCG,SAArC,CAhEiC;EAiEvDqD,OAAO,EAAE,IAAIvD,mBAAJ,CAAwBE,SAAxB;AAjE8C,CAAjC,CAAjB"}
1
+ {"version":3,"names":["JsiSkPoint","JsiSkPaint","JsiSkRect","Color","JsiSkSurfaceFactory","JsiSkRRect","JsiSkRSXform","JsiSkContourMeasureIter","JsiSkPictureRecorder","JsiSkPictureFactory","JsiSkPathFactory","JsiSkMatrix","JsiSkColorFilterFactory","JsiSkTypefaceFactory","JsiSkMaskFilterFactory","JsiSkRuntimeEffectFactory","JsiSkImageFilterFactory","JsiSkShaderFactory","JsiSkPathEffectFactory","JsiSkDataFactory","JsiSkImageFactory","JsiSkSVGFactory","JsiSkTextBlobFactory","JsiSkFont","MakeVertices","JsiSkPath","JsiSkTypeface","JsiSkTypefaceFontProviderFactory","JsiSkFontMgrFactory","JsiSkAnimatedImageFactory","JsiSkApi","CanvasKit","Point","x","y","Float32Array","of","RuntimeShaderBuilder","_","Error","RRectXY","rect","rx","ry","RSXform","scos","ssin","tx","ty","ContourMeasureIter","path","forceClosed","resScale","fromValue","Paint","paint","setAntiAlias","PictureRecorder","Picture","Path","Matrix","matrix","identity","ColorFilter","Font","typeface","size","undefined","Typeface","MaskFilter","RuntimeEffect","ImageFilter","Shader","PathEffect","bind","Data","Image","AnimatedImage","SVG","TextBlob","XYWHRect","width","height","Surface","TypefaceFontProvider","FontMgr"],"sources":["JsiSkia.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type {\n SkContourMeasureIter,\n Skia,\n SkPath,\n SkRect,\n SkRuntimeEffect,\n SkRuntimeShaderBuilder,\n SkTypeface,\n} from \"../types\";\n\nimport { JsiSkPoint } from \"./JsiSkPoint\";\nimport { JsiSkPaint } from \"./JsiSkPaint\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { Color } from \"./JsiSkColor\";\nimport { JsiSkSurfaceFactory } from \"./JsiSkSurfaceFactory\";\nimport { JsiSkRRect } from \"./JsiSkRRect\";\nimport { JsiSkRSXform } from \"./JsiSkRSXform\";\nimport { JsiSkContourMeasureIter } from \"./JsiSkContourMeasureIter\";\nimport { JsiSkPictureRecorder } from \"./JsiSkPictureRecorder\";\nimport { JsiSkPictureFactory } from \"./JsiSkPictureFactory\";\nimport { JsiSkPathFactory } from \"./JsiSkPathFactory\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\nimport { JsiSkColorFilterFactory } from \"./JsiSkColorFilterFactory\";\nimport { JsiSkTypefaceFactory } from \"./JsiSkTypefaceFactory\";\nimport { JsiSkMaskFilterFactory } from \"./JsiSkMaskFilterFactory\";\nimport { JsiSkRuntimeEffectFactory } from \"./JsiSkRuntimeEffectFactory\";\nimport { JsiSkImageFilterFactory } from \"./JsiSkImageFilterFactory\";\nimport { JsiSkShaderFactory } from \"./JsiSkShaderFactory\";\nimport { JsiSkPathEffectFactory } from \"./JsiSkPathEffectFactory\";\nimport { JsiSkDataFactory } from \"./JsiSkDataFactory\";\nimport { JsiSkImageFactory } from \"./JsiSkImageFactory\";\nimport { JsiSkSVGFactory } from \"./JsiSkSVGFactory\";\nimport { JsiSkTextBlobFactory } from \"./JsiSkTextBlobFactory\";\nimport { JsiSkFont } from \"./JsiSkFont\";\nimport { MakeVertices } from \"./JsiSkVerticesFactory\";\nimport { JsiSkPath } from \"./JsiSkPath\";\nimport { JsiSkTypeface } from \"./JsiSkTypeface\";\nimport { JsiSkTypefaceFontProviderFactory } from \"./JsiSkTypefaceFontProviderFactory\";\nimport { JsiSkFontMgrFactory } from \"./JsiSkFontMgrFactory\";\nimport { JsiSkAnimatedImageFactory } from \"./JsiSkAnimatedImageFactory\";\n\nexport const JsiSkApi = (CanvasKit: CanvasKit): Skia => ({\n Point: (x: number, y: number) =>\n new JsiSkPoint(CanvasKit, Float32Array.of(x, y)),\n RuntimeShaderBuilder: (_: SkRuntimeEffect): SkRuntimeShaderBuilder => {\n throw new Error(\"Not implemented on React Native Web\");\n },\n RRectXY: (rect: SkRect, rx: number, ry: number) =>\n new JsiSkRRect(CanvasKit, rect, rx, ry),\n RSXform: (scos: number, ssin: number, tx: number, ty: number) =>\n new JsiSkRSXform(CanvasKit, Float32Array.of(scos, ssin, tx, ty)),\n Color,\n ContourMeasureIter: (\n path: SkPath,\n forceClosed: boolean,\n resScale: number\n ): SkContourMeasureIter =>\n new JsiSkContourMeasureIter(\n CanvasKit,\n new CanvasKit.ContourMeasureIter(\n JsiSkPath.fromValue(path),\n forceClosed,\n resScale\n )\n ),\n Paint: () => {\n const paint = new JsiSkPaint(CanvasKit, new CanvasKit.Paint());\n paint.setAntiAlias(true);\n return paint;\n },\n PictureRecorder: () =>\n new JsiSkPictureRecorder(CanvasKit, new CanvasKit.PictureRecorder()),\n Picture: new JsiSkPictureFactory(CanvasKit),\n Path: new JsiSkPathFactory(CanvasKit),\n Matrix: (matrix?: readonly number[]) =>\n new JsiSkMatrix(\n CanvasKit,\n matrix\n ? Float32Array.of(...matrix)\n : Float32Array.of(...CanvasKit.Matrix.identity())\n ),\n ColorFilter: new JsiSkColorFilterFactory(CanvasKit),\n Font: (typeface?: SkTypeface, size?: number) =>\n new JsiSkFont(\n CanvasKit,\n new CanvasKit.Font(\n typeface === undefined ? null : JsiSkTypeface.fromValue(typeface),\n size\n )\n ),\n Typeface: new JsiSkTypefaceFactory(CanvasKit),\n MaskFilter: new JsiSkMaskFilterFactory(CanvasKit),\n RuntimeEffect: new JsiSkRuntimeEffectFactory(CanvasKit),\n ImageFilter: new JsiSkImageFilterFactory(CanvasKit),\n Shader: new JsiSkShaderFactory(CanvasKit),\n PathEffect: new JsiSkPathEffectFactory(CanvasKit),\n MakeVertices: MakeVertices.bind(null, CanvasKit),\n Data: new JsiSkDataFactory(CanvasKit),\n Image: new JsiSkImageFactory(CanvasKit),\n AnimatedImage: new JsiSkAnimatedImageFactory(CanvasKit),\n SVG: new JsiSkSVGFactory(CanvasKit),\n TextBlob: new JsiSkTextBlobFactory(CanvasKit),\n XYWHRect: (x: number, y: number, width: number, height: number) => {\n return new JsiSkRect(CanvasKit, CanvasKit.XYWHRect(x, y, width, height));\n },\n Surface: new JsiSkSurfaceFactory(CanvasKit),\n TypefaceFontProvider: new JsiSkTypefaceFontProviderFactory(CanvasKit),\n FontMgr: new JsiSkFontMgrFactory(CanvasKit),\n});\n"],"mappings":"AAYA,SAASA,UAAT,QAA2B,cAA3B;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,SAAT,QAA0B,aAA1B;AACA,SAASC,KAAT,QAAsB,cAAtB;AACA,SAASC,mBAAT,QAAoC,uBAApC;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,SAASC,uBAAT,QAAwC,2BAAxC;AACA,SAASC,oBAAT,QAAqC,wBAArC;AACA,SAASC,mBAAT,QAAoC,uBAApC;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,WAAT,QAA4B,eAA5B;AACA,SAASC,uBAAT,QAAwC,2BAAxC;AACA,SAASC,oBAAT,QAAqC,wBAArC;AACA,SAASC,sBAAT,QAAuC,0BAAvC;AACA,SAASC,yBAAT,QAA0C,6BAA1C;AACA,SAASC,uBAAT,QAAwC,2BAAxC;AACA,SAASC,kBAAT,QAAmC,sBAAnC;AACA,SAASC,sBAAT,QAAuC,0BAAvC;AACA,SAASC,gBAAT,QAAi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,MAAM,EAAE,IAAIvD,kBAAJ,CAAuBc,SAAvB,CArD+C;EAsDvD0C,UAAU,EAAE,IAAIvD,sBAAJ,CAA2Ba,SAA3B,CAtD2C;EAuDvDP,YAAY,EAAEA,YAAY,CAACkD,IAAb,CAAkB,IAAlB,EAAwB3C,SAAxB,CAvDyC;EAwDvD4C,IAAI,EAAE,IAAIxD,gBAAJ,CAAqBY,SAArB,CAxDiD;EAyDvD6C,KAAK,EAAE,IAAIxD,iBAAJ,CAAsBW,SAAtB,CAzDgD;EA0DvD8C,aAAa,EAAE,IAAIhD,yBAAJ,CAA8BE,SAA9B,CA1DwC;EA2DvD+C,GAAG,EAAE,IAAIzD,eAAJ,CAAoBU,SAApB,CA3DkD;EA4DvDgD,QAAQ,EAAE,IAAIzD,oBAAJ,CAAyBS,SAAzB,CA5D6C;EA6DvDiD,QAAQ,EAAE,CAAC/C,CAAD,EAAYC,CAAZ,EAAuB+C,KAAvB,EAAsCC,MAAtC,KAAyD;IACjE,OAAO,IAAIhF,SAAJ,CAAc6B,SAAd,EAAyBA,SAAS,CAACiD,QAAV,CAAmB/C,CAAnB,EAAsBC,CAAtB,EAAyB+C,KAAzB,EAAgCC,MAAhC,CAAzB,CAAP;EACD,CA/DsD;EAgEvDC,OAAO,EAAE,IAAI/E,mBAAJ,CAAwB2B,SAAxB,CAhE8C;EAiEvDqD,oBAAoB,EAAE,IAAIzD,gCAAJ,CAAqCI,SAArC,CAjEiC;EAkEvDsD,OAAO,EAAE,IAAIzD,mBAAJ,CAAwBG,SAAxB;AAlE8C,CAAjC,CAAjB"}
@@ -1,7 +1,9 @@
1
1
  import type { SharedValueType } from "../../renderer/processors/Animations";
2
2
  export declare const HAS_REANIMATED2: boolean;
3
3
  export declare const HAS_REANIMATED3: boolean;
4
+ export declare function throwOnMissingReanimated(): void;
4
5
  export declare const useSharedValue: any;
6
+ export declare const useFrameCallback: (...args: any[]) => any;
5
7
  export declare const startMapper: any;
6
8
  export declare const stopMapper: any;
7
9
  export declare const runOnJS: any;
@@ -0,0 +1,6 @@
1
+ import type { DataSourceParam } from "../types";
2
+ /**
3
+ * Returns a Skia Animated Image object
4
+ * */
5
+ export declare const useAnimatedImage: (source: DataSourceParam, onError?: ((err: Error) => void) | undefined) => import("../types").SkAnimatedImage | null;
6
+ export declare const useAnimatedImageValue: (source: DataSourceParam) => any;
@@ -2,6 +2,7 @@ export * from "./Data";
2
2
  export * from "./Font";
3
3
  export * from "./Typeface";
4
4
  export * from "./Image";
5
+ export * from "./AnimatedImage";
5
6
  export * from "./Picture";
6
7
  export * from "./SVG";
7
8
  export * from "./Vector";
@@ -0,0 +1,24 @@
1
+ import type { SkJSIInstance } from "../JsiInstance";
2
+ import type { SkImage } from "../Image";
3
+ export interface SkAnimatedImage extends SkJSIInstance<"AnimatedImage"> {
4
+ /**
5
+ * Decode the next frame.
6
+ *
7
+ * If the animation is on the last frame or has hit an error, returns
8
+ * kFinished (-1).
9
+ */
10
+ decodeNextFrame(): number;
11
+ /**
12
+ * Returns the current frame as an SkImage. The SkImage will not change
13
+ * after it has been returned.
14
+ * If there is no current frame, null will be returned.
15
+ */
16
+ getCurrentFrame(): SkImage | null;
17
+ /**
18
+ * How long to display the current frame.
19
+ *
20
+ * Useful for the first frame, for which decodeNextFrame is called
21
+ * internally.
22
+ */
23
+ currentFrameDuration(): number;
24
+ }
@@ -0,0 +1,13 @@
1
+ import type { SkData } from "../Data";
2
+ import type { SkAnimatedImage } from "./AnimatedImage";
3
+ export interface AnimatedImageFactory {
4
+ /**
5
+ * Decodes the given bytes into an animated image. Returns null if the bytes were invalid.
6
+ * The passed in bytes will be copied into the WASM heap, so the caller can dispose of them.
7
+ *
8
+ * The returned AnimatedImage will be "pointing to" the first frame, i.e. currentFrameDuration
9
+ * and makeImageAtCurrentFrame will be referring to the first frame.
10
+ * @param encoded
11
+ */
12
+ MakeAnimatedImageFromEncoded: (encoded: SkData) => SkAnimatedImage | null;
13
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./AnimatedImage";
2
+ export * from "./AnimatedImageFactory";
@@ -10,10 +10,19 @@ export interface FontMetrics {
10
10
  bounds?: SkRect;
11
11
  }
12
12
  export interface SkFont extends SkJSIInstance<"Font"> {
13
+ /**
14
+ * Returns the advance width of text.
15
+ * The advance is the normal distance to move before drawing additional text.
16
+ * Returns the bounding box of text
17
+ * @param text
18
+ * @param paint
19
+ */
20
+ measureText(text: string, paint?: SkPaint): SkRect;
13
21
  /**
14
22
  * Retrieves the total width of the provided text
15
23
  * @param text
16
24
  * @param paint
25
+ * @deprecated Use measureText or getGlyphWidths instead
17
26
  */
18
27
  getTextWidth(text: string, paint?: SkPaint): number;
19
28
  /**
@@ -24,6 +24,7 @@ import type { SkContourMeasureIter } from "./ContourMeasure";
24
24
  import type { PictureFactory, SkPictureRecorder } from "./Picture";
25
25
  import type { Color, SkColor } from "./Color";
26
26
  import type { TypefaceFontProviderFactory } from "./Paragraph/TypefaceFontProviderFactory";
27
+ import type { AnimatedImageFactory } from "./AnimatedImage";
27
28
  /**
28
29
  * Declares the interface for the native Skia API
29
30
  */
@@ -63,6 +64,7 @@ export interface Skia {
63
64
  MakeVertices(mode: VertexMode, positions: SkPoint[], textureCoordinates?: SkPoint[] | null, colors?: SkColor[], indices?: number[] | null, isVolatile?: boolean): SkVertices;
64
65
  Data: DataFactory;
65
66
  Image: ImageFactory;
67
+ AnimatedImage: AnimatedImageFactory;
66
68
  SVG: SVGFactory;
67
69
  TextBlob: TextBlobFactory;
68
70
  Surface: SurfaceFactory;
@@ -6,6 +6,7 @@ export * from "./Vertices";
6
6
  export * from "./RuntimeEffect";
7
7
  export * from "./Shader";
8
8
  export * from "./Image";
9
+ export * from "./AnimatedImage";
9
10
  export * from "./ColorFilter";
10
11
  export * from "./ImageFilter";
11
12
  export * from "./Font";
@@ -0,0 +1,11 @@
1
+ import type { AnimatedImage, CanvasKit } from "canvaskit-wasm";
2
+ import type { SkAnimatedImage } from "../types/AnimatedImage";
3
+ import { HostObject } from "./Host";
4
+ import { JsiSkImage } from "./JsiSkImage";
5
+ export declare class JsiSkAnimatedImage extends HostObject<AnimatedImage, "AnimatedImage"> implements SkAnimatedImage {
6
+ constructor(CanvasKit: CanvasKit, ref: AnimatedImage);
7
+ decodeNextFrame(): number;
8
+ currentFrameDuration(): number;
9
+ getCurrentFrame(): JsiSkImage | null;
10
+ dispose: () => void;
11
+ }
@@ -0,0 +1,9 @@
1
+ import type { CanvasKit } from "canvaskit-wasm";
2
+ import type { SkData } from "../types";
3
+ import type { AnimatedImageFactory } from "../types/AnimatedImage/AnimatedImageFactory";
4
+ import { Host } from "./Host";
5
+ import { JsiSkAnimatedImage } from "./JsiSkAnimatedImage";
6
+ export declare class JsiSkAnimatedImageFactory extends Host implements AnimatedImageFactory {
7
+ constructor(CanvasKit: CanvasKit);
8
+ MakeAnimatedImageFromEncoded(encoded: SkData): JsiSkAnimatedImage | null;
9
+ }
@@ -1,10 +1,11 @@
1
1
  import type { CanvasKit, Font } from "canvaskit-wasm";
2
- import type { FontEdging, FontHinting, SkFont, SkPaint, SkPoint, SkTypeface } from "../types";
2
+ import type { FontEdging, FontHinting, SkFont, SkPaint, SkPoint, SkRect, SkTypeface } from "../types";
3
3
  import { HostObject } from "./Host";
4
4
  import { JsiSkRect } from "./JsiSkRect";
5
5
  import { JsiSkTypeface } from "./JsiSkTypeface";
6
6
  export declare class JsiSkFont extends HostObject<Font, "Font"> implements SkFont {
7
7
  constructor(CanvasKit: CanvasKit, ref: Font);
8
+ measureText(_text: string, _paint?: SkPaint | undefined): SkRect;
8
9
  dispose: () => void;
9
10
  getTextWidth(text: string, paint?: SkPaint | undefined): number;
10
11
  getMetrics(): {
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": "0.1.209",
10
+ "version": "0.1.211",
11
11
  "description": "High-performance React Native Graphics using Skia",
12
12
  "main": "lib/module/index.js",
13
13
  "files": [
@@ -1,12 +1,13 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
1
2
  import { useMemo } from "react";
2
3
 
3
4
  import type { SharedValueType } from "../../renderer/processors/Animations";
4
5
 
5
6
  // This one is needed for the deprecated useSharedValue function
6
7
  // We can remove it once we remove the deprecation
7
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
+
8
9
  let Reanimated2: any;
9
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+
10
11
  let Reanimated3: any;
11
12
  let reanimatedVersion: string;
12
13
 
@@ -26,7 +27,7 @@ try {
26
27
  export const HAS_REANIMATED2 = !!Reanimated2;
27
28
  export const HAS_REANIMATED3 = !!Reanimated3;
28
29
 
29
- function throwOnMissingReanimated2() {
30
+ export function throwOnMissingReanimated() {
30
31
  if (!HAS_REANIMATED2) {
31
32
  throw new Error(
32
33
  "Reanimated was not found, make sure react-native-reanimated package is installed if you want to use \
@@ -41,17 +42,17 @@ function throwOnMissingReanimated3() {
41
42
  `Reanimated version ${reanimatedVersion} is not supported, please upgrade to 3.0.0 or newer.`
42
43
  );
43
44
  }
44
- throwOnMissingReanimated2();
45
45
  }
46
46
 
47
47
  export const useSharedValue =
48
48
  Reanimated2?.useSharedValue ||
49
49
  ((value: number) => useMemo(() => ({ value }), [value]));
50
+ export const useFrameCallback: (...args: any[]) => any =
51
+ Reanimated2?.useFrameCallback || throwOnMissingReanimated;
50
52
 
51
- export const startMapper =
52
- Reanimated2?.startMapper || throwOnMissingReanimated2;
53
- export const stopMapper = Reanimated2?.stopMapper || throwOnMissingReanimated2;
54
- export const runOnJS = Reanimated2?.runOnJS || throwOnMissingReanimated2;
53
+ export const startMapper = Reanimated2?.startMapper || throwOnMissingReanimated;
54
+ export const stopMapper = Reanimated2?.stopMapper || throwOnMissingReanimated;
55
+ export const runOnJS = Reanimated2?.runOnJS || throwOnMissingReanimated;
55
56
  export const isSharedValue = <T>(
56
57
  value: unknown
57
58
  ): value is SharedValueType<T> => {
@@ -0,0 +1,63 @@
1
+ import {
2
+ throwOnMissingReanimated,
3
+ useFrameCallback,
4
+ useSharedValue,
5
+ } from "../../external/reanimated/moduleWrapper";
6
+ import { Skia } from "../Skia";
7
+ import type { DataSourceParam } from "../types";
8
+
9
+ import { useRawData } from "./Data";
10
+
11
+ const animatedImgFactory = Skia.AnimatedImage.MakeAnimatedImageFromEncoded.bind(
12
+ Skia.AnimatedImage
13
+ );
14
+
15
+ /**
16
+ * Returns a Skia Animated Image object
17
+ * */
18
+ export const useAnimatedImage = (
19
+ source: DataSourceParam,
20
+ onError?: (err: Error) => void
21
+ ) => useRawData(source, animatedImgFactory, onError);
22
+
23
+ const DEFAULT_FRAME_DURATION = 60;
24
+
25
+ export const useAnimatedImageValue = (source: DataSourceParam) => {
26
+ throwOnMissingReanimated();
27
+ const currentFrame = useSharedValue(null);
28
+ const lastTimestamp = useSharedValue(0);
29
+ const animatedImage = useAnimatedImage(source, (err) => {
30
+ console.error(err);
31
+ throw new Error(`Could not load animated image - got '${err.message}'`);
32
+ });
33
+ const frameDuration =
34
+ animatedImage?.currentFrameDuration() || DEFAULT_FRAME_DURATION;
35
+
36
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
37
+ useFrameCallback((frameInfo: any) => {
38
+ if (!animatedImage) {
39
+ currentFrame.value = null;
40
+ return;
41
+ }
42
+
43
+ const { timestamp } = frameInfo;
44
+ const elapsed = timestamp - lastTimestamp.value;
45
+
46
+ // Check if it's time to switch frames based on GIF frame duration
47
+ if (elapsed < frameDuration) {
48
+ return;
49
+ }
50
+
51
+ // Update the current frame
52
+ animatedImage.decodeNextFrame();
53
+ if (currentFrame.value) {
54
+ currentFrame.value.dispose();
55
+ }
56
+ currentFrame.value = animatedImage.getCurrentFrame();
57
+
58
+ // Update the last timestamp
59
+ lastTimestamp.value = timestamp;
60
+ // eslint-disable-next-line react-hooks/exhaustive-deps
61
+ }, true);
62
+ return currentFrame;
63
+ };
@@ -2,6 +2,7 @@ export * from "./Data";
2
2
  export * from "./Font";
3
3
  export * from "./Typeface";
4
4
  export * from "./Image";
5
+ export * from "./AnimatedImage";
5
6
  export * from "./Picture";
6
7
  export * from "./SVG";
7
8
  export * from "./Vector";
@@ -0,0 +1,29 @@
1
+ import type { SkJSIInstance } from "../JsiInstance";
2
+ import type { SkImage } from "../Image";
3
+
4
+ export interface SkAnimatedImage extends SkJSIInstance<"AnimatedImage"> {
5
+ /**
6
+ * Decode the next frame.
7
+ *
8
+ * If the animation is on the last frame or has hit an error, returns
9
+ * kFinished (-1).
10
+ */
11
+ decodeNextFrame(): number;
12
+
13
+ /**
14
+ * Returns the current frame as an SkImage. The SkImage will not change
15
+ * after it has been returned.
16
+ * If there is no current frame, null will be returned.
17
+ */
18
+ getCurrentFrame(): SkImage | null;
19
+
20
+ /**
21
+ * How long to display the current frame.
22
+ *
23
+ * Useful for the first frame, for which decodeNextFrame is called
24
+ * internally.
25
+ */
26
+ currentFrameDuration(): number;
27
+
28
+ // TODO - add the rest of the methods from the Skia API (see SkAnimatedImage.h)
29
+ }