@shopify/react-native-skia 1.11.18 → 1.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/android/cpp/jni/JniPlatformContext.cpp +1 -0
  2. package/cpp/api/JsiSkContourMeasure.h +1 -1
  3. package/cpp/api/JsiSkHostObjects.h +21 -10
  4. package/cpp/api/JsiSkParagraph.h +17 -27
  5. package/cpp/api/JsiSkPathEffect.h +1 -1
  6. package/cpp/api/JsiSkPictureFactory.h +1 -1
  7. package/cpp/api/recorder/Drawings.h +4 -3
  8. package/cpp/rnskia/DawnContext.h +1 -1
  9. package/cpp/skia/include/codec/SkCodec.h +7 -2
  10. package/cpp/skia/include/config/SkUserConfig.h +11 -0
  11. package/cpp/skia/include/core/SkCanvas.h +11 -7
  12. package/cpp/skia/include/core/SkColor.h +10 -0
  13. package/cpp/skia/include/core/SkColorSpace.h +184 -2
  14. package/cpp/skia/include/core/SkColorType.h +114 -32
  15. package/cpp/skia/include/core/SkFontScanner.h +5 -8
  16. package/cpp/skia/include/core/SkFontStyle.h +1 -1
  17. package/cpp/skia/include/core/SkMaskFilter.h +0 -8
  18. package/cpp/skia/include/core/SkMilestone.h +1 -1
  19. package/cpp/skia/include/core/SkPath.h +1 -1
  20. package/cpp/skia/include/core/SkRRect.h +3 -1
  21. package/cpp/skia/include/core/SkShader.h +3 -3
  22. package/cpp/skia/include/core/SkString.h +8 -8
  23. package/cpp/skia/include/core/SkSurface.h +14 -0
  24. package/cpp/skia/include/core/SkTypeface.h +24 -7
  25. package/cpp/skia/include/effects/SkGradientShader.h +6 -1
  26. package/cpp/skia/include/effects/SkRuntimeEffect.h +1 -0
  27. package/cpp/skia/include/encode/SkPngEncoder.h +14 -0
  28. package/cpp/skia/include/gpu/GpuTypes.h +9 -0
  29. package/cpp/skia/include/gpu/ganesh/GrContextOptions.h +135 -133
  30. package/cpp/skia/include/gpu/ganesh/GrDirectContext.h +5 -0
  31. package/cpp/skia/include/gpu/ganesh/GrDriverBugWorkarounds.h +3 -3
  32. package/cpp/skia/include/gpu/ganesh/GrTypes.h +14 -9
  33. package/cpp/skia/include/gpu/graphite/Context.h +25 -2
  34. package/cpp/skia/include/gpu/graphite/ContextOptions.h +23 -5
  35. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +20 -1
  36. package/cpp/skia/include/gpu/graphite/Image.h +1 -0
  37. package/cpp/skia/include/gpu/graphite/LogPriority.h +36 -0
  38. package/cpp/skia/include/gpu/graphite/PrecompileContext.h +52 -0
  39. package/cpp/skia/include/gpu/graphite/Recorder.h +6 -0
  40. package/cpp/skia/include/gpu/graphite/Recording.h +3 -1
  41. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes.h +4 -36
  42. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypesUtils.h +48 -0
  43. package/cpp/skia/include/gpu/graphite/precompile/Precompile.h +3 -2
  44. package/cpp/skia/include/pathops/SkPathOps.h +9 -1
  45. package/cpp/skia/include/ports/SkFontMgr_FontConfigInterface.h +3 -0
  46. package/cpp/skia/include/private/SkPathRef.h +15 -21
  47. package/cpp/skia/include/private/base/SkAttributes.h +16 -10
  48. package/cpp/skia/include/private/base/SkMutex.h +8 -0
  49. package/cpp/skia/include/private/base/SkTArray.h +1 -1
  50. package/cpp/skia/include/private/base/SkTDArray.h +1 -1
  51. package/cpp/skia/include/private/base/SkTemplates.h +24 -11
  52. package/cpp/skia/include/private/gpu/ganesh/GrTypesPriv.h +1 -1
  53. package/cpp/skia/include/sksl/SkSLDebugTrace.h +0 -3
  54. package/cpp/skia/modules/skcms/src/Transform_inl.h +20 -20
  55. package/cpp/skia/modules/skcms/src/skcms_Transform.h +4 -3
  56. package/cpp/skia/modules/skcms/src/skcms_public.h +19 -15
  57. package/cpp/skia/modules/skresources/include/SkResources.h +3 -1
  58. package/cpp/skia/modules/svg/include/SkSVGCircle.h +1 -1
  59. package/cpp/skia/modules/svg/include/SkSVGContainer.h +1 -1
  60. package/cpp/skia/modules/svg/include/SkSVGFeLightSource.h +1 -1
  61. package/cpp/skia/modules/svg/include/SkSVGImage.h +2 -2
  62. package/cpp/skia/modules/svg/include/SkSVGPath.h +1 -1
  63. package/cpp/skia/modules/svg/include/SkSVGPoly.h +1 -1
  64. package/cpp/skia/modules/svg/include/SkSVGRect.h +1 -1
  65. package/cpp/skia/modules/svg/include/SkSVGRenderContext.h +2 -0
  66. package/cpp/skia/modules/svg/include/SkSVGShape.h +1 -0
  67. package/cpp/skia/modules/svg/include/SkSVGText.h +1 -1
  68. package/cpp/skia/modules/svg/include/SkSVGTransformableNode.h +4 -0
  69. package/cpp/skia/modules/svg/include/SkSVGUse.h +1 -1
  70. package/cpp/skia/src/core/SkLRUCache.h +19 -13
  71. package/cpp/skia/src/core/SkTHash.h +50 -4
  72. package/cpp/skia/src/gpu/ganesh/gl/GrGLDefines.h +1 -0
  73. package/lib/commonjs/external/reanimated/useAnimatedImageValue.js +4 -3
  74. package/lib/commonjs/external/reanimated/useAnimatedImageValue.js.map +1 -1
  75. package/lib/commonjs/mock/index.js +1 -2
  76. package/lib/commonjs/mock/index.js.map +1 -1
  77. package/lib/commonjs/skia/web/Host.d.ts +1 -3
  78. package/lib/commonjs/skia/web/Host.js +7 -6
  79. package/lib/commonjs/skia/web/Host.js.map +1 -1
  80. package/lib/commonjs/skia/web/JsiSkFont.js +1 -1
  81. package/lib/commonjs/skia/web/JsiSkFont.js.map +1 -1
  82. package/lib/commonjs/skia/web/JsiSkFontMgr.js +1 -1
  83. package/lib/commonjs/skia/web/JsiSkFontMgr.js.map +1 -1
  84. package/lib/commonjs/skia/web/JsiSkImageFactory.js +1 -1
  85. package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
  86. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js +6 -6
  87. package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js.map +1 -1
  88. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js +2 -2
  89. package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  90. package/lib/commonjs/skia/web/JsiSkPathFactory.d.ts +1 -1
  91. package/lib/commonjs/skia/web/JsiSkPathFactory.js +1 -1
  92. package/lib/commonjs/skia/web/JsiSkPathFactory.js.map +1 -1
  93. package/lib/commonjs/skia/web/JsiSkTypefaceFontProvider.js +1 -1
  94. package/lib/commonjs/skia/web/JsiSkTypefaceFontProvider.js.map +1 -1
  95. package/lib/commonjs/skia/web/JsiSkia.js +4 -3
  96. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  97. package/lib/commonjs/skia/web/JsiVideo.js +2 -1
  98. package/lib/commonjs/skia/web/JsiVideo.js.map +1 -1
  99. package/lib/commonjs/sksg/Recorder/Core.d.ts +1 -5
  100. package/lib/commonjs/sksg/Recorder/Core.js +12 -4
  101. package/lib/commonjs/sksg/Recorder/Core.js.map +1 -1
  102. package/lib/commonjs/sksg/Recorder/Player.js +4 -5
  103. package/lib/commonjs/sksg/Recorder/Player.js.map +1 -1
  104. package/lib/commonjs/sksg/Recorder/commands/Box.js +2 -4
  105. package/lib/commonjs/sksg/Recorder/commands/Box.js.map +1 -1
  106. package/lib/module/external/reanimated/useAnimatedImageValue.js +4 -3
  107. package/lib/module/external/reanimated/useAnimatedImageValue.js.map +1 -1
  108. package/lib/module/mock/index.js +1 -2
  109. package/lib/module/mock/index.js.map +1 -1
  110. package/lib/module/skia/web/Host.d.ts +1 -3
  111. package/lib/module/skia/web/Host.js +5 -4
  112. package/lib/module/skia/web/Host.js.map +1 -1
  113. package/lib/module/skia/web/JsiSkFont.js +2 -2
  114. package/lib/module/skia/web/JsiSkFont.js.map +1 -1
  115. package/lib/module/skia/web/JsiSkFontMgr.js +2 -2
  116. package/lib/module/skia/web/JsiSkFontMgr.js.map +1 -1
  117. package/lib/module/skia/web/JsiSkImageFactory.js +2 -2
  118. package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
  119. package/lib/module/skia/web/JsiSkImageFilterFactory.js +7 -7
  120. package/lib/module/skia/web/JsiSkImageFilterFactory.js.map +1 -1
  121. package/lib/module/skia/web/JsiSkPathEffectFactory.js +3 -3
  122. package/lib/module/skia/web/JsiSkPathEffectFactory.js.map +1 -1
  123. package/lib/module/skia/web/JsiSkPathFactory.d.ts +1 -1
  124. package/lib/module/skia/web/JsiSkPathFactory.js +2 -2
  125. package/lib/module/skia/web/JsiSkPathFactory.js.map +1 -1
  126. package/lib/module/skia/web/JsiSkTypefaceFontProvider.js +2 -2
  127. package/lib/module/skia/web/JsiSkTypefaceFontProvider.js.map +1 -1
  128. package/lib/module/skia/web/JsiSkia.js +4 -3
  129. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  130. package/lib/module/skia/web/JsiVideo.js +2 -1
  131. package/lib/module/skia/web/JsiVideo.js.map +1 -1
  132. package/lib/module/sksg/Recorder/Core.d.ts +1 -5
  133. package/lib/module/sksg/Recorder/Core.js +10 -2
  134. package/lib/module/sksg/Recorder/Core.js.map +1 -1
  135. package/lib/module/sksg/Recorder/Player.js +5 -6
  136. package/lib/module/sksg/Recorder/Player.js.map +1 -1
  137. package/lib/module/sksg/Recorder/commands/Box.js +3 -5
  138. package/lib/module/sksg/Recorder/commands/Box.js.map +1 -1
  139. package/lib/typescript/lib/commonjs/mock/index.d.ts +1 -1
  140. package/lib/typescript/lib/commonjs/skia/web/Host.d.ts +1 -3
  141. package/lib/typescript/lib/commonjs/skia/web/JsiSkFont.d.ts +1 -1
  142. package/lib/typescript/lib/commonjs/skia/web/JsiSkFontMgr.d.ts +1 -1
  143. package/lib/typescript/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +1 -1
  144. package/lib/typescript/lib/commonjs/skia/web/JsiSkImageFilterFactory.d.ts +1 -1
  145. package/lib/typescript/lib/commonjs/skia/web/JsiSkPathEffectFactory.d.ts +2 -2
  146. package/lib/typescript/lib/commonjs/skia/web/JsiSkPathFactory.d.ts +1 -1
  147. package/lib/typescript/lib/commonjs/skia/web/JsiSkTypefaceFontProvider.d.ts +1 -1
  148. package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +3 -3
  149. package/lib/typescript/lib/commonjs/skia/web/JsiVideo.d.ts +1 -1
  150. package/lib/typescript/lib/commonjs/sksg/Recorder/Core.d.ts +1 -1
  151. package/lib/typescript/lib/module/mock/index.d.ts +1 -1
  152. package/lib/typescript/lib/module/skia/Skia.web.d.ts +3 -3
  153. package/lib/typescript/lib/module/skia/web/Host.d.ts +1 -3
  154. package/lib/typescript/lib/module/skia/web/JsiSkFont.d.ts +1 -1
  155. package/lib/typescript/lib/module/skia/web/JsiSkFontMgr.d.ts +1 -1
  156. package/lib/typescript/lib/module/skia/web/JsiSkImageFactory.d.ts +1 -1
  157. package/lib/typescript/lib/module/skia/web/JsiSkImageFilterFactory.d.ts +1 -1
  158. package/lib/typescript/lib/module/skia/web/JsiSkPathEffectFactory.d.ts +2 -2
  159. package/lib/typescript/lib/module/skia/web/JsiSkPathFactory.d.ts +1 -1
  160. package/lib/typescript/lib/module/skia/web/JsiSkTypefaceFontProvider.d.ts +1 -1
  161. package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +3 -3
  162. package/lib/typescript/lib/module/skia/web/JsiVideo.d.ts +1 -1
  163. package/lib/typescript/lib/module/sksg/Recorder/Core.d.ts +1 -1
  164. package/lib/typescript/src/skia/web/Host.d.ts +1 -3
  165. package/lib/typescript/src/skia/web/JsiSkPathFactory.d.ts +1 -1
  166. package/lib/typescript/src/sksg/Recorder/Core.d.ts +1 -5
  167. package/package.json +1 -1
  168. package/react-native-skia.podspec +3 -3
  169. package/src/external/reanimated/useAnimatedImageValue.ts +4 -3
  170. package/src/mock/index.ts +1 -2
  171. package/src/skia/web/Host.ts +5 -4
  172. package/src/skia/web/JsiSkFont.ts +3 -3
  173. package/src/skia/web/JsiSkFontMgr.ts +3 -3
  174. package/src/skia/web/JsiSkImageFactory.ts +3 -3
  175. package/src/skia/web/JsiSkImageFilterFactory.ts +8 -18
  176. package/src/skia/web/JsiSkPathEffectFactory.ts +5 -5
  177. package/src/skia/web/JsiSkPathFactory.ts +3 -8
  178. package/src/skia/web/JsiSkTypefaceFontProvider.ts +3 -3
  179. package/src/skia/web/JsiSkia.ts +7 -4
  180. package/src/skia/web/JsiVideo.ts +2 -1
  181. package/src/sksg/Recorder/Core.ts +5 -7
  182. package/src/sksg/Recorder/Player.ts +5 -6
  183. package/src/sksg/Recorder/commands/Box.ts +3 -5
  184. package/ios/RNSkia-iOS/MetalContext.h +0 -134
  185. package/ios/RNSkia-iOS/MetalContext.mm +0 -34
  186. package/ios/RNSkia-iOS/MetalWindowContext.h +0 -39
  187. package/ios/RNSkia-iOS/MetalWindowContext.mm +0 -60
  188. package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.h +0 -38
  189. package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.mm +0 -103
  190. package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +0 -75
  191. package/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm +0 -303
  192. package/ios/RNSkia-iOS/RNSkiOSVideo.h +0 -51
  193. package/ios/RNSkia-iOS/RNSkiOSVideo.mm +0 -137
  194. package/ios/RNSkia-iOS/RNSkiOSView.h +0 -37
  195. package/ios/RNSkia-iOS/RNSkiOSView.mm +0 -35
  196. package/ios/RNSkia-iOS/SkiaCVPixelBufferUtils.h +0 -119
  197. package/ios/RNSkia-iOS/SkiaCVPixelBufferUtils.mm +0 -344
  198. package/ios/RNSkia-iOS/SkiaManager.h +0 -25
  199. package/ios/RNSkia-iOS/SkiaManager.mm +0 -62
  200. package/ios/RNSkia-iOS/SkiaPictureView.h +0 -7
  201. package/ios/RNSkia-iOS/SkiaPictureView.mm +0 -66
  202. package/ios/RNSkia-iOS/SkiaPictureViewManager.h +0 -8
  203. package/ios/RNSkia-iOS/SkiaPictureViewManager.mm +0 -51
  204. package/ios/RNSkia-iOS/SkiaUIView.h +0 -37
  205. package/ios/RNSkia-iOS/SkiaUIView.mm +0 -168
  206. package/ios/RNSkia-iOS/ViewScreenshotService.h +0 -21
  207. package/ios/RNSkia-iOS/ViewScreenshotService.mm +0 -85
  208. package/ios/RNSkiaModule.h +0 -20
  209. package/ios/RNSkiaModule.mm +0 -55
  210. package/ios/Rnskia.xcodeproj/project.pbxproj +0 -281
  211. package/ios/Rnskia.xcworkspace/contents.xcworkspacedata +0 -7
@@ -3,6 +3,6 @@ export class JsiSkFontMgr extends HostObject {
3
3
  dispose(): void;
4
4
  countFamilies(): any;
5
5
  getFamilyName(index: any): any;
6
- matchFamilyStyle(_familyName: any, _fontStyle: any): void;
6
+ matchFamilyStyle(_familyName: any, _fontStyle: any): jest.Mock<any, any, any>;
7
7
  }
8
8
  import { HostObject } from "./Host";
@@ -2,7 +2,7 @@ export class JsiSkImageFactory extends Host {
2
2
  MakeImageFromViewTag(viewTag: any): Promise<null>;
3
3
  MakeImageFromNativeBuffer(buffer: any, surface: any, image: any): JsiSkImage;
4
4
  MakeImageFromEncoded(encoded: any): JsiSkImage | null;
5
- MakeImageFromNativeTextureUnstable(): void;
5
+ MakeImageFromNativeTextureUnstable(): jest.Mock<any, any, any>;
6
6
  MakeImage(info: any, data: any, bytesPerRow: any): JsiSkImage | null;
7
7
  }
8
8
  import { Host } from "./Host";
@@ -10,7 +10,7 @@ export class JsiSkImageFilterFactory extends Host {
10
10
  MakeErode(rx: any, ry: any, input: any, cropRect: any): JsiSkImageFilter;
11
11
  MakeDilate(rx: any, ry: any, input: any, cropRect: any): JsiSkImageFilter;
12
12
  MakeBlend(mode: any, background: any, foreground: any, cropRect: any): JsiSkImageFilter;
13
- MakeRuntimeShader(_builder: any, _childShaderName: any, _input: any): void;
13
+ MakeRuntimeShader(_builder: any, _childShaderName: any, _input: any): jest.Mock<any, any, any>;
14
14
  }
15
15
  import { Host } from "./Host";
16
16
  import { JsiSkImageFilter } from "./JsiSkImageFilter";
@@ -2,8 +2,8 @@ export class JsiSkPathEffectFactory extends Host {
2
2
  MakeCorner(radius: any): JsiSkPathEffect | null;
3
3
  MakeDash(intervals: any, phase: any): JsiSkPathEffect;
4
4
  MakeDiscrete(segLength: any, dev: any, seedAssist: any): JsiSkPathEffect;
5
- MakeCompose(_outer: any, _inner: any): void;
6
- MakeSum(_outer: any, _inner: any): void;
5
+ MakeCompose(_outer: any, _inner: any): jest.Mock<any, any, any>;
6
+ MakeSum(_outer: any, _inner: any): jest.Mock<any, any, any>;
7
7
  MakeLine2D(width: any, matrix: any): JsiSkPathEffect | null;
8
8
  MakePath1D(path: any, advance: any, phase: any, style: any): JsiSkPathEffect | null;
9
9
  MakePath2D(matrix: any, path: any): JsiSkPathEffect | null;
@@ -3,7 +3,7 @@ export class JsiSkPathFactory extends Host {
3
3
  MakeFromSVGString(str: any): JsiSkPath | null;
4
4
  MakeFromOp(one: any, two: any, op: any): JsiSkPath | null;
5
5
  MakeFromCmds(cmds: any): JsiSkPath | null;
6
- MakeFromText(_text: any, _x: any, _y: any, _font: any): void;
6
+ MakeFromText(_text: any, _x: any, _y: any, _font: any): jest.Mock<any, any, any>;
7
7
  }
8
8
  import { Host } from "./Host";
9
9
  import { JsiSkPath } from "./JsiSkPath";
@@ -1,6 +1,6 @@
1
1
  export class JsiSkTypefaceFontProvider extends HostObject {
2
2
  constructor(CanvasKit: any, ref: any);
3
- matchFamilyStyle(_name: any, _style: any): void;
3
+ matchFamilyStyle(_name: any, _style: any): jest.Mock<any, any, any>;
4
4
  countFamilies(): any;
5
5
  getFamilyName(index: any): any;
6
6
  registerFont(typeface: any, familyName: any): void;
@@ -1,6 +1,6 @@
1
1
  export function JsiSkApi(CanvasKit: any): {
2
2
  Point: (x: any, y: any) => JsiSkPoint;
3
- RuntimeShaderBuilder: (_: any) => never;
3
+ RuntimeShaderBuilder: (_: any) => jest.Mock<any, any, any>;
4
4
  RRectXY: (rect: any, rx: any, ry: any) => JsiSkRRect;
5
5
  RSXform: (scos: any, ssin: any, tx: any, ty: any) => JsiSkRSXform;
6
6
  RSXformFromRadians: (scale: any, r: any, tx: any, ty: any, px: any, py: any) => JsiSkRSXform;
@@ -32,8 +32,8 @@ export function JsiSkApi(CanvasKit: any): {
32
32
  ParagraphBuilder: JsiSkParagraphBuilderFactory;
33
33
  NativeBuffer: JsiSkNativeBufferFactory;
34
34
  Video: (url?: any) => Promise<any>;
35
- Context: (_surface: any, _width: any, _height: any) => never;
36
- Recorder: () => never;
35
+ Context: (_surface: any, _width: any, _height: any) => jest.Mock<any, any, any>;
36
+ Recorder: () => jest.Mock<any, any, any>;
37
37
  };
38
38
  import { JsiSkPoint } from "./JsiSkPoint";
39
39
  import { JsiSkRRect } from "./JsiSkRRect";
@@ -4,7 +4,7 @@ export class JsiVideo {
4
4
  ImageFactory: any;
5
5
  videoElement: any;
6
6
  duration(): number;
7
- framerate(): void;
7
+ framerate(): jest.Mock<any, any, any>;
8
8
  setSurface(surface: any): void;
9
9
  webglBuffer: CanvasKitWebGLBufferImpl | undefined;
10
10
  nextImage(): any;
@@ -1,5 +1,5 @@
1
1
  export let CommandType: {};
2
- export function materializeProps(command: any): void;
2
+ export function materializeCommand(command: any): any;
3
3
  export function isCommand(command: any, type: any): boolean;
4
4
  export function isGroup(command: any): boolean;
5
5
  export function isDrawCommand(command: any, type: any): boolean;
@@ -1,8 +1,6 @@
1
1
  import type { CanvasKit, EmbindEnumEntity, EmbindEnum } from "canvaskit-wasm";
2
2
  import type { SkJSIInstance } from "../types";
3
- export declare class NotImplementedOnRNWeb extends Error {
4
- constructor(msg?: string);
5
- }
3
+ export declare const throwNotImplementedOnRNWeb: <T>() => T;
6
4
  export declare abstract class Host {
7
5
  readonly CanvasKit: CanvasKit;
8
6
  constructor(CanvasKit: CanvasKit);
@@ -9,5 +9,5 @@ export declare class JsiSkPathFactory extends Host implements PathFactory {
9
9
  MakeFromSVGString(str: string): JsiSkPath | null;
10
10
  MakeFromOp(one: SkPath, two: SkPath, op: PathOp): JsiSkPath | null;
11
11
  MakeFromCmds(cmds: PathCommand[]): JsiSkPath | null;
12
- MakeFromText(_text: string, _x: number, _y: number, _font: SkFont): SkPath | null;
12
+ MakeFromText(_text: string, _x: number, _y: number, _font: SkFont): SkPath;
13
13
  }
@@ -1,4 +1,3 @@
1
- import type { SharedValue } from "react-native-reanimated";
2
1
  import type { BlurMaskFilterProps, CircleProps, CTMProps, ImageProps, PointsProps, PathProps, RectProps, RoundedRectProps, OvalProps, LineProps, PatchProps, VerticesProps, DiffRectProps, TextProps, TextPathProps, TextBlobProps, GlyphsProps, PictureProps, ImageSVGProps, ParagraphProps, AtlasProps, DrawingNodeProps } from "../../dom/types";
3
2
  export declare enum CommandType {
4
3
  Group = 0,
@@ -44,10 +43,7 @@ export type Command<T extends CommandType = CommandType> = {
44
43
  type: T;
45
44
  [key: string]: unknown;
46
45
  };
47
- export declare const materializeProps: (command: {
48
- props: Record<string, unknown>;
49
- animatedProps?: Record<string, SharedValue<unknown>>;
50
- }) => void;
46
+ export declare const materializeCommand: (command: any) => any;
51
47
  export declare const isCommand: <T extends CommandType>(command: Command, type: T) => command is Command<T>;
52
48
  interface GroupCommand extends Command<CommandType.Group> {
53
49
  children: Command[];
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "setup-skia-web": "scripts/setup-canvaskit.js"
9
9
  },
10
10
  "title": "React Native Skia",
11
- "version": "1.11.18",
11
+ "version": "1.12.1",
12
12
  "description": "High-performance React Native Graphics using Skia",
13
13
  "main": "lib/module/index.js",
14
14
  "react-native": "src/index.ts",
@@ -41,7 +41,7 @@ Pod::Spec.new do |s|
41
41
  "Christian Falch" => "christian.falch@gmail.com",
42
42
  "William Candillon" => "wcandillon@gmail.com"
43
43
  }
44
- s.platforms = { :ios => "13.0", :tvos => "13.0" }
44
+ s.platforms = { :ios => "13.0", :tvos => "13.0", :osx => "11" }
45
45
  s.source = { :git => "https://github.com/shopify/react-native-skia/react-native-skia.git", :tag => "#{s.version}" }
46
46
 
47
47
  s.requires_arc = true
@@ -54,13 +54,13 @@ Pod::Spec.new do |s|
54
54
 
55
55
  s.frameworks = ['MetalKit', 'AVFoundation', 'AVKit', 'CoreMedia']
56
56
 
57
- s.vendored_frameworks = use_graphite ?
57
+ s.vendored_frameworks = use_graphite ?
58
58
  base_frameworks + graphite_frameworks :
59
59
  base_frameworks
60
60
 
61
61
  # All iOS cpp/h files
62
62
  s.source_files = [
63
- "ios/**/*.{h,c,cc,cpp,m,mm,swift}",
63
+ "apple/**/*.{h,c,cc,cpp,m,mm,swift}",
64
64
  "cpp/**/*.{h,cpp}"
65
65
  ]
66
66
 
@@ -40,10 +40,11 @@ export const useAnimatedImageValue = (
40
40
 
41
41
  // Update the current frame
42
42
  animatedImage.decodeNextFrame();
43
- if (currentFrame.value) {
44
- currentFrame.value.dispose();
45
- }
43
+ const oldFrame = currentFrame.value;
46
44
  currentFrame.value = animatedImage.getCurrentFrame();
45
+ if (oldFrame) {
46
+ oldFrame.dispose();
47
+ }
47
48
 
48
49
  // Update the last timestamp
49
50
  lastTimestamp.value = timestamp;
package/src/mock/index.ts CHANGED
@@ -21,8 +21,7 @@ export const Mock = (CanvasKit: CanvasKit) => {
21
21
  ...require("../animation"),
22
22
  ...require("../dom/types"),
23
23
  ...require("../dom/nodes"),
24
- // We could use the real Canvas if we mock the SkiaView component for node
25
- Canvas: Noop,
24
+ Canvas: require("react-native").View,
26
25
  // Skia Animations
27
26
  useValue: NoopValue,
28
27
  useComputedValue: NoopValue,
@@ -2,11 +2,12 @@ import type { CanvasKit, EmbindEnumEntity, EmbindEnum } from "canvaskit-wasm";
2
2
 
3
3
  import type { SkJSIInstance } from "../types";
4
4
 
5
- export class NotImplementedOnRNWeb extends Error {
6
- constructor(msg?: string) {
7
- super(msg ?? "Not implemented on React Native Web");
5
+ export const throwNotImplementedOnRNWeb = <T>(): T => {
6
+ if (typeof jest !== "undefined") {
7
+ return jest.fn() as unknown as T;
8
8
  }
9
- }
9
+ throw new Error("Not implemented on React Native Web");
10
+ };
10
11
 
11
12
  export abstract class Host {
12
13
  readonly CanvasKit: CanvasKit;
@@ -10,7 +10,7 @@ import type {
10
10
  SkTypeface,
11
11
  } from "../types";
12
12
 
13
- import { HostObject, NotImplementedOnRNWeb, getEnum } from "./Host";
13
+ import { HostObject, getEnum, throwNotImplementedOnRNWeb } from "./Host";
14
14
  import { JsiSkPaint } from "./JsiSkPaint";
15
15
  import { JsiSkPoint } from "./JsiSkPoint";
16
16
  import { JsiSkRect } from "./JsiSkRect";
@@ -21,8 +21,8 @@ export class JsiSkFont extends HostObject<Font, "Font"> implements SkFont {
21
21
  super(CanvasKit, ref, "Font");
22
22
  }
23
23
 
24
- measureText(_text: string, _paint?: SkPaint | undefined): SkRect {
25
- throw new NotImplementedOnRNWeb();
24
+ measureText(_text: string, _paint?: SkPaint | undefined) {
25
+ return throwNotImplementedOnRNWeb<SkRect>();
26
26
  }
27
27
 
28
28
  dispose = () => {
@@ -2,7 +2,7 @@ import type { CanvasKit, FontMgr } from "canvaskit-wasm";
2
2
 
3
3
  import type { FontStyle, SkFontMgr, SkTypeface } from "../types";
4
4
 
5
- import { HostObject, NotImplementedOnRNWeb } from "./Host";
5
+ import { HostObject, throwNotImplementedOnRNWeb } from "./Host";
6
6
 
7
7
  export class JsiSkFontMgr
8
8
  extends HostObject<FontMgr, "FontMgr">
@@ -20,7 +20,7 @@ export class JsiSkFontMgr
20
20
  getFamilyName(index: number) {
21
21
  return this.ref.getFamilyName(index);
22
22
  }
23
- matchFamilyStyle(_familyName: string, _fontStyle: FontStyle): SkTypeface {
24
- throw new NotImplementedOnRNWeb();
23
+ matchFamilyStyle(_familyName: string, _fontStyle: FontStyle) {
24
+ return throwNotImplementedOnRNWeb<SkTypeface>();
25
25
  }
26
26
  }
@@ -9,7 +9,7 @@ import type {
9
9
  ImageFactory,
10
10
  } from "../types";
11
11
 
12
- import { Host, getEnum } from "./Host";
12
+ import { Host, getEnum, throwNotImplementedOnRNWeb } from "./Host";
13
13
  import { JsiSkImage } from "./JsiSkImage";
14
14
  import { JsiSkData } from "./JsiSkData";
15
15
  import type { JsiSkSurface } from "./JsiSkSurface";
@@ -75,8 +75,8 @@ export class JsiSkImageFactory extends Host implements ImageFactory {
75
75
  return new JsiSkImage(this.CanvasKit, image);
76
76
  }
77
77
 
78
- MakeImageFromNativeTextureUnstable(): SkImage {
79
- throw new Error("MakeImageFromNativeTexture is not implemented on web");
78
+ MakeImageFromNativeTextureUnstable() {
79
+ return throwNotImplementedOnRNWeb<SkImage>();
80
80
  }
81
81
 
82
82
  MakeImage(info: ImageInfo, data: SkData, bytesPerRow: number) {
@@ -13,7 +13,7 @@ import type {
13
13
  TileMode,
14
14
  } from "../types";
15
15
 
16
- import { Host, NotImplementedOnRNWeb, getEnum } from "./Host";
16
+ import { Host, throwNotImplementedOnRNWeb, getEnum } from "./Host";
17
17
  import { JsiSkImageFilter } from "./JsiSkImageFilter";
18
18
  import { JsiSkColorFilter } from "./JsiSkColorFilter";
19
19
 
@@ -107,9 +107,7 @@ export class JsiSkImageFilterFactory
107
107
  const inputFilter =
108
108
  input === null ? null : JsiSkImageFilter.fromValue<ImageFilter>(input);
109
109
  if (cropRect) {
110
- throw new NotImplementedOnRNWeb(
111
- "The cropRect argument is not yet supported on React Native Web."
112
- );
110
+ throwNotImplementedOnRNWeb<SkImageFilter>();
113
111
  }
114
112
  const filter = this.CanvasKit.ImageFilter.MakeDropShadow(
115
113
  dx,
@@ -134,9 +132,7 @@ export class JsiSkImageFilterFactory
134
132
  const inputFilter =
135
133
  input === null ? null : JsiSkImageFilter.fromValue<ImageFilter>(input);
136
134
  if (cropRect) {
137
- throw new NotImplementedOnRNWeb(
138
- "The cropRect argument is not yet supported on React Native Web."
139
- );
135
+ throwNotImplementedOnRNWeb<SkImageFilter>();
140
136
  }
141
137
  const filter = this.CanvasKit.ImageFilter.MakeDropShadowOnly(
142
138
  dx,
@@ -158,9 +154,7 @@ export class JsiSkImageFilterFactory
158
154
  const inputFilter =
159
155
  input === null ? null : JsiSkImageFilter.fromValue<ImageFilter>(input);
160
156
  if (cropRect) {
161
- throw new NotImplementedOnRNWeb(
162
- "The cropRect argument is not yet supported on React Native Web."
163
- );
157
+ throwNotImplementedOnRNWeb<SkImageFilter>();
164
158
  }
165
159
  const filter = this.CanvasKit.ImageFilter.MakeErode(rx, ry, inputFilter);
166
160
  return new JsiSkImageFilter(this.CanvasKit, filter);
@@ -175,9 +169,7 @@ export class JsiSkImageFilterFactory
175
169
  const inputFilter =
176
170
  input === null ? null : JsiSkImageFilter.fromValue<ImageFilter>(input);
177
171
  if (cropRect) {
178
- throw new NotImplementedOnRNWeb(
179
- "The cropRect argument is not yet supported on React Native Web."
180
- );
172
+ throwNotImplementedOnRNWeb<SkImageFilter>();
181
173
  }
182
174
  const filter = this.CanvasKit.ImageFilter.MakeDilate(rx, ry, inputFilter);
183
175
  return new JsiSkImageFilter(this.CanvasKit, filter);
@@ -194,9 +186,7 @@ export class JsiSkImageFilterFactory
194
186
  ? null
195
187
  : JsiSkImageFilter.fromValue<ImageFilter>(foreground);
196
188
  if (cropRect) {
197
- throw new NotImplementedOnRNWeb(
198
- "The cropRect argument is not yet supported on React Native Web."
199
- );
189
+ throwNotImplementedOnRNWeb<SkImageFilter>();
200
190
  }
201
191
  const filter = this.CanvasKit.ImageFilter.MakeBlend(
202
192
  getEnum(this.CanvasKit.BlendMode, mode),
@@ -210,7 +200,7 @@ export class JsiSkImageFilterFactory
210
200
  _builder: SkRuntimeShaderBuilder,
211
201
  _childShaderName: string | null,
212
202
  _input: SkImageFilter | null
213
- ): SkImageFilter {
214
- throw new NotImplementedOnRNWeb();
203
+ ) {
204
+ return throwNotImplementedOnRNWeb<SkImageFilter>();
215
205
  }
216
206
  }
@@ -8,7 +8,7 @@ import type {
8
8
  SkPathEffect,
9
9
  } from "../types";
10
10
 
11
- import { getEnum, Host, NotImplementedOnRNWeb } from "./Host";
11
+ import { getEnum, Host, throwNotImplementedOnRNWeb } from "./Host";
12
12
  import { JsiSkMatrix } from "./JsiSkMatrix";
13
13
  import { JsiSkPath } from "./JsiSkPath";
14
14
  import { JsiSkPathEffect } from "./JsiSkPathEffect";
@@ -40,12 +40,12 @@ export class JsiSkPathEffectFactory extends Host implements PathEffectFactory {
40
40
  return new JsiSkPathEffect(this.CanvasKit, pe);
41
41
  }
42
42
 
43
- MakeCompose(_outer: SkPathEffect, _inner: SkPathEffect): SkPathEffect {
44
- throw new NotImplementedOnRNWeb();
43
+ MakeCompose(_outer: SkPathEffect, _inner: SkPathEffect) {
44
+ return throwNotImplementedOnRNWeb<SkPathEffect>();
45
45
  }
46
46
 
47
- MakeSum(_outer: SkPathEffect, _inner: SkPathEffect): SkPathEffect {
48
- throw new NotImplementedOnRNWeb();
47
+ MakeSum(_outer: SkPathEffect, _inner: SkPathEffect) {
48
+ return throwNotImplementedOnRNWeb<SkPathEffect>();
49
49
  }
50
50
 
51
51
  MakeLine2D(width: number, matrix: SkMatrix) {
@@ -3,7 +3,7 @@ import type { CanvasKit } from "canvaskit-wasm";
3
3
  import type { PathCommand, PathOp, SkFont, SkPath } from "../types";
4
4
  import type { PathFactory } from "../types/Path/PathFactory";
5
5
 
6
- import { Host, getEnum, NotImplementedOnRNWeb } from "./Host";
6
+ import { Host, getEnum, throwNotImplementedOnRNWeb } from "./Host";
7
7
  import { JsiSkPath } from "./JsiSkPath";
8
8
 
9
9
  export class JsiSkPathFactory extends Host implements PathFactory {
@@ -43,12 +43,7 @@ export class JsiSkPathFactory extends Host implements PathFactory {
43
43
  return new JsiSkPath(this.CanvasKit, path);
44
44
  }
45
45
 
46
- MakeFromText(
47
- _text: string,
48
- _x: number,
49
- _y: number,
50
- _font: SkFont
51
- ): SkPath | null {
52
- throw new NotImplementedOnRNWeb();
46
+ MakeFromText(_text: string, _x: number, _y: number, _font: SkFont) {
47
+ return throwNotImplementedOnRNWeb<SkPath>();
53
48
  }
54
49
  }
@@ -3,7 +3,7 @@ import type { CanvasKit, TypefaceFontProvider } from "canvaskit-wasm";
3
3
  import type { SkTypefaceFontProvider } from "../types/Paragraph/TypefaceFontProvider";
4
4
  import type { FontStyle, SkTypeface } from "../types";
5
5
 
6
- import { HostObject, NotImplementedOnRNWeb } from "./Host";
6
+ import { HostObject, throwNotImplementedOnRNWeb } from "./Host";
7
7
 
8
8
  export class JsiSkTypefaceFontProvider
9
9
  extends HostObject<TypefaceFontProvider, "FontMgr">
@@ -15,8 +15,8 @@ export class JsiSkTypefaceFontProvider
15
15
  super(CanvasKit, ref, "FontMgr");
16
16
  }
17
17
 
18
- matchFamilyStyle(_name: string, _style: FontStyle): SkTypeface {
19
- throw new NotImplementedOnRNWeb();
18
+ matchFamilyStyle(_name: string, _style: FontStyle) {
19
+ return throwNotImplementedOnRNWeb<SkTypeface>();
20
20
  }
21
21
  countFamilies() {
22
22
  return this.ref.countFamilies();
@@ -1,8 +1,10 @@
1
1
  import type { CanvasKit } from "canvaskit-wasm";
2
2
 
3
3
  import type {
4
+ JsiRecorder,
4
5
  SkContourMeasureIter,
5
6
  Skia,
7
+ SkiaContext,
6
8
  SkPath,
7
9
  SkRect,
8
10
  SkRuntimeEffect,
@@ -43,12 +45,13 @@ import { JsiSkAnimatedImageFactory } from "./JsiSkAnimatedImageFactory";
43
45
  import { JsiSkParagraphBuilderFactory } from "./JsiSkParagraphBuilderFactory";
44
46
  import { JsiSkNativeBufferFactory } from "./JsiSkNativeBufferFactory";
45
47
  import { createVideo } from "./JsiVideo";
48
+ import { throwNotImplementedOnRNWeb } from "./Host";
46
49
 
47
50
  export const JsiSkApi = (CanvasKit: CanvasKit): Skia => ({
48
51
  Point: (x: number, y: number) =>
49
52
  new JsiSkPoint(CanvasKit, Float32Array.of(x, y)),
50
- RuntimeShaderBuilder: (_: SkRuntimeEffect): SkRuntimeShaderBuilder => {
51
- throw new Error("Not implemented on React Native Web");
53
+ RuntimeShaderBuilder: (_: SkRuntimeEffect) => {
54
+ return throwNotImplementedOnRNWeb<SkRuntimeShaderBuilder>();
52
55
  },
53
56
  RRectXY: (rect: SkRect, rx: number, ry: number) =>
54
57
  new JsiSkRRect(CanvasKit, rect, rx, ry),
@@ -130,9 +133,9 @@ export const JsiSkApi = (CanvasKit: CanvasKit): Skia => ({
130
133
  NativeBuffer: new JsiSkNativeBufferFactory(CanvasKit),
131
134
  Video: createVideo.bind(null, CanvasKit),
132
135
  Context: (_surface: bigint, _width: number, _height: number) => {
133
- throw new Error("Not implemented on React Native Web");
136
+ return throwNotImplementedOnRNWeb<SkiaContext>();
134
137
  },
135
138
  Recorder: () => {
136
- throw new Error("Not implemented on React Native Web");
139
+ return throwNotImplementedOnRNWeb<JsiRecorder>();
137
140
  },
138
141
  });
@@ -4,6 +4,7 @@ import type { CanvasKitWebGLBuffer, Video, ImageFactory } from "../types";
4
4
 
5
5
  import { CanvasKitWebGLBufferImpl } from "./CanvasKitWebGLBufferImpl";
6
6
  import { JsiSkImageFactory } from "./JsiSkImageFactory";
7
+ import { throwNotImplementedOnRNWeb } from "./Host";
7
8
 
8
9
  export const createVideo = async (
9
10
  CanvasKit: CanvasKit,
@@ -42,7 +43,7 @@ export class JsiVideo implements Video {
42
43
  }
43
44
 
44
45
  framerate(): number {
45
- throw new Error("Video.frame is not available on React Native Web");
46
+ return throwNotImplementedOnRNWeb<number>();
46
47
  }
47
48
 
48
49
  setSurface(surface: Surface) {
@@ -1,5 +1,3 @@
1
- import type { SharedValue } from "react-native-reanimated";
2
-
3
1
  import type {
4
2
  BlurMaskFilterProps,
5
3
  CircleProps,
@@ -115,16 +113,16 @@ export type Command<T extends CommandType = CommandType> = {
115
113
  [key: string]: unknown;
116
114
  };
117
115
 
118
- export const materializeProps = (command: {
119
- props: Record<string, unknown>;
120
- animatedProps?: Record<string, SharedValue<unknown>>;
121
- }) => {
116
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
117
+ export const materializeCommand = (command: any) => {
122
118
  "worklet";
119
+ const newProps = { ...command.props };
123
120
  if (command.animatedProps) {
124
121
  for (const key in command.animatedProps) {
125
- command.props[key] = command.animatedProps[key].value;
122
+ newProps[key] = command.animatedProps[key].value;
126
123
  }
127
124
  }
125
+ return { ...command, props: newProps };
128
126
  };
129
127
 
130
128
  export const isCommand = <T extends CommandType>(
@@ -44,19 +44,18 @@ import {
44
44
  isCommand,
45
45
  isDrawCommand,
46
46
  isGroup,
47
- materializeProps,
47
+ materializeCommand,
48
48
  type Command,
49
49
  } from "./Core";
50
50
  import type { DrawingContext } from "./DrawingContext";
51
51
 
52
- function play(ctx: DrawingContext, command: Command) {
52
+ function play(ctx: DrawingContext, _command: Command) {
53
53
  "worklet";
54
- if (isGroup(command)) {
55
- command.children.forEach((child) => play(ctx, child));
54
+ if (isGroup(_command)) {
55
+ _command.children.forEach((child) => play(ctx, child));
56
56
  return;
57
57
  }
58
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
59
- materializeProps(command as any);
58
+ const command = materializeCommand(_command);
60
59
  if (isCommand(command, CommandType.SaveBackdropFilter)) {
61
60
  ctx.saveBackdropFilter();
62
61
  } else if (isCommand(command, CommandType.SaveLayer)) {
@@ -2,7 +2,7 @@ import { deflate, inflate, processColor } from "../../../dom/nodes";
2
2
  import type { BoxProps, BoxShadowProps } from "../../../dom/types";
3
3
  import { BlurStyle, ClipOp, isRRect } from "../../../skia/types";
4
4
  import type { Command } from "../Core";
5
- import { CommandType, materializeProps } from "../Core";
5
+ import { CommandType, materializeCommand } from "../Core";
6
6
  import type { DrawingContext } from "../DrawingContext";
7
7
 
8
8
  interface BoxCommand extends Command<CommandType.DrawBox> {
@@ -17,11 +17,9 @@ export const isBoxCommand = (command: Command): command is BoxCommand => {
17
17
 
18
18
  export const drawBox = (ctx: DrawingContext, command: BoxCommand) => {
19
19
  "worklet";
20
- command.shadows.forEach((shadow) => {
21
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
- materializeProps(shadow as any);
20
+ const shadows = command.shadows.map((shadow) => {
21
+ return materializeCommand(shadow).props;
23
22
  });
24
- const shadows = command.shadows.map((shadow) => shadow.props);
25
23
  const { paint, Skia, canvas } = ctx;
26
24
  const { box: defaultBox } = command.props;
27
25
  const opacity = paint.getAlphaf();