@shopify/react-native-skia 0.1.175 → 0.1.178

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. package/android/CMakeLists.txt +2 -0
  2. package/android/build.gradle +2 -1
  3. package/cpp/jsi/JsiHostObject.cpp +13 -7
  4. package/cpp/jsi/JsiHostObject.h +3 -1
  5. package/cpp/jsi/RuntimeAwareCache.cpp +9 -0
  6. package/cpp/jsi/RuntimeAwareCache.h +101 -0
  7. package/cpp/jsi/RuntimeLifecycleMonitor.cpp +57 -0
  8. package/cpp/jsi/RuntimeLifecycleMonitor.h +32 -0
  9. package/cpp/rnskia/RNSkJsView.cpp +1 -1
  10. package/cpp/rnskia/RNSkManager.cpp +4 -0
  11. package/cpp/rnskia/dom/base/JsiDomNode.h +22 -2
  12. package/ios/RNSkia-iOS/RNSkMetalCanvasProvider.mm +12 -8
  13. package/lib/commonjs/external/reanimated/index.d.ts +1 -0
  14. package/lib/commonjs/external/reanimated/index.js +13 -0
  15. package/lib/commonjs/external/reanimated/index.js.map +1 -1
  16. package/lib/commonjs/external/reanimated/moduleWrapper.d.ts +8 -0
  17. package/lib/commonjs/external/reanimated/moduleWrapper.js +72 -0
  18. package/lib/commonjs/external/reanimated/moduleWrapper.js.map +1 -0
  19. package/lib/commonjs/external/reanimated/renderHelpers.d.ts +5 -0
  20. package/lib/commonjs/external/reanimated/renderHelpers.js +85 -0
  21. package/lib/commonjs/external/reanimated/renderHelpers.js.map +1 -0
  22. package/lib/commonjs/external/reanimated/useSharedValueEffect.d.ts +2 -5
  23. package/lib/commonjs/external/reanimated/useSharedValueEffect.js +10 -25
  24. package/lib/commonjs/external/reanimated/useSharedValueEffect.js.map +1 -1
  25. package/lib/commonjs/headless/index.d.ts +3 -0
  26. package/lib/commonjs/headless/index.js +57 -0
  27. package/lib/commonjs/headless/index.js.map +1 -0
  28. package/lib/commonjs/mock/index.d.ts +1 -2
  29. package/lib/commonjs/mock/index.js +0 -4
  30. package/lib/commonjs/mock/index.js.map +1 -1
  31. package/lib/commonjs/renderer/Canvas.js +7 -1
  32. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  33. package/lib/commonjs/renderer/Container.d.ts +2 -1
  34. package/lib/commonjs/renderer/Container.js +2 -0
  35. package/lib/commonjs/renderer/Container.js.map +1 -1
  36. package/lib/commonjs/renderer/HostConfig.js +6 -4
  37. package/lib/commonjs/renderer/HostConfig.js.map +1 -1
  38. package/lib/commonjs/renderer/Reconciler.d.ts +1 -1
  39. package/lib/commonjs/renderer/Reconciler.js +2 -1
  40. package/lib/commonjs/renderer/Reconciler.js.map +1 -1
  41. package/lib/commonjs/renderer/processors/Animations/Animations.d.ts +4 -1
  42. package/lib/commonjs/renderer/processors/Animations/Animations.js.map +1 -1
  43. package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js +8 -1
  44. package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js.map +1 -1
  45. package/lib/module/external/reanimated/index.d.ts +1 -0
  46. package/lib/module/external/reanimated/index.js +1 -0
  47. package/lib/module/external/reanimated/index.js.map +1 -1
  48. package/lib/module/external/reanimated/moduleWrapper.d.ts +8 -0
  49. package/lib/module/external/reanimated/moduleWrapper.js +51 -0
  50. package/lib/module/external/reanimated/moduleWrapper.js.map +1 -0
  51. package/lib/module/external/reanimated/renderHelpers.d.ts +5 -0
  52. package/lib/module/external/reanimated/renderHelpers.js +76 -0
  53. package/lib/module/external/reanimated/renderHelpers.js.map +1 -0
  54. package/lib/module/external/reanimated/useSharedValueEffect.d.ts +2 -5
  55. package/lib/module/external/reanimated/useSharedValueEffect.js +7 -22
  56. package/lib/module/external/reanimated/useSharedValueEffect.js.map +1 -1
  57. package/lib/module/headless/index.d.ts +3 -0
  58. package/lib/module/headless/index.js +29 -0
  59. package/lib/module/headless/index.js.map +1 -0
  60. package/lib/module/mock/index.d.ts +1 -2
  61. package/lib/module/mock/index.js +0 -3
  62. package/lib/module/mock/index.js.map +1 -1
  63. package/lib/module/renderer/Canvas.js +7 -1
  64. package/lib/module/renderer/Canvas.js.map +1 -1
  65. package/lib/module/renderer/Container.d.ts +2 -1
  66. package/lib/module/renderer/Container.js +2 -0
  67. package/lib/module/renderer/Container.js.map +1 -1
  68. package/lib/module/renderer/HostConfig.js +5 -4
  69. package/lib/module/renderer/HostConfig.js.map +1 -1
  70. package/lib/module/renderer/Reconciler.d.ts +1 -1
  71. package/lib/module/renderer/Reconciler.js +2 -1
  72. package/lib/module/renderer/Reconciler.js.map +1 -1
  73. package/lib/module/renderer/processors/Animations/Animations.d.ts +4 -1
  74. package/lib/module/renderer/processors/Animations/Animations.js.map +1 -1
  75. package/lib/module/skia/web/JsiSkSurfaceFactory.js +8 -1
  76. package/lib/module/skia/web/JsiSkSurfaceFactory.js.map +1 -1
  77. package/lib/typescript/src/external/reanimated/index.d.ts +1 -0
  78. package/lib/typescript/src/external/reanimated/moduleWrapper.d.ts +8 -0
  79. package/lib/typescript/src/external/reanimated/renderHelpers.d.ts +5 -0
  80. package/lib/typescript/src/external/reanimated/useSharedValueEffect.d.ts +2 -5
  81. package/lib/typescript/src/headless/index.d.ts +3 -0
  82. package/lib/typescript/src/mock/index.d.ts +1 -2
  83. package/lib/typescript/src/renderer/Container.d.ts +2 -1
  84. package/lib/typescript/src/renderer/Reconciler.d.ts +1 -1
  85. package/lib/typescript/src/renderer/processors/Animations/Animations.d.ts +4 -1
  86. package/libs/ios/libskia.xcframework/Info.plist +5 -5
  87. package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  88. package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  89. package/libs/ios/libskottie.xcframework/Info.plist +5 -5
  90. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
  91. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  92. package/libs/ios/libsksg.xcframework/Info.plist +5 -5
  93. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
  94. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  95. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  96. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  97. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  98. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  99. package/package.json +1 -1
  100. package/react-native-skia.podspec +7 -26
  101. package/src/external/reanimated/index.ts +1 -0
  102. package/src/external/reanimated/moduleWrapper.ts +62 -0
  103. package/src/external/reanimated/renderHelpers.ts +74 -0
  104. package/src/external/reanimated/useSharedValueEffect.ts +17 -23
  105. package/src/headless/index.ts +31 -0
  106. package/src/mock/index.ts +0 -5
  107. package/src/renderer/Canvas.tsx +6 -2
  108. package/src/renderer/Container.tsx +2 -1
  109. package/src/renderer/HostConfig.ts +8 -2
  110. package/src/renderer/Reconciler.tsx +3 -2
  111. package/src/renderer/processors/Animations/Animations.ts +9 -1
  112. package/src/skia/web/JsiSkSurfaceFactory.ts +6 -3
@@ -31,10 +31,11 @@ export class SkiaRoot {
31
31
  constructor(
32
32
  Skia: Skia,
33
33
  registerValues: RegisterValues = () => () => {},
34
- redraw: () => void = () => {}
34
+ redraw: () => void = () => {},
35
+ getNativeId: () => number = () => 0
35
36
  ) {
36
37
  const depMgr = createDependencyManager(registerValues);
37
- this.container = new Container(Skia, depMgr, redraw);
38
+ this.container = new Container(Skia, depMgr, redraw, getNativeId);
38
39
  this.root = skiaReconciler.createContainer(
39
40
  this.container,
40
41
  0,
@@ -1,5 +1,9 @@
1
1
  import type { SkiaSelector, SkiaValue } from "../../../values";
2
2
 
3
+ export type SharedValueType<T = number> = {
4
+ value: T;
5
+ };
6
+
3
7
  export const isValue = (value: unknown): value is SkiaValue<unknown> => {
4
8
  if (value === undefined || value === null) {
5
9
  return false;
@@ -44,7 +48,11 @@ export const isAnimated = <T>(props: AnimatedProps<T>) => {
44
48
  };
45
49
 
46
50
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
- export type AnimatedProp<T, P = any> = T | SkiaValue<T> | SkiaSelector<T, P>;
51
+ export type AnimatedProp<T, P = any> =
52
+ | T
53
+ | SkiaValue<T>
54
+ | SkiaSelector<T, P>
55
+ | SharedValueType<T>;
48
56
 
49
57
  export type AnimatedProps<T, O extends keyof T | never = never> = {
50
58
  [K in keyof T]: K extends "children"
@@ -27,9 +27,12 @@ export class JsiSkSurfaceFactory extends Host implements SurfaceFactory {
27
27
  surface = this.CanvasKit.MakeSurface(width, height);
28
28
  } else {
29
29
  const offscreen = new OC(width, height);
30
- surface = this.CanvasKit.MakeWebGLCanvasSurface(
31
- offscreen as unknown as HTMLCanvasElement
32
- );
30
+ const webglContext = this.CanvasKit.GetWebGLContext(offscreen);
31
+ const grContext = this.CanvasKit.MakeWebGLContext(webglContext);
32
+ if (!grContext) {
33
+ throw new Error("Could not make a graphics context");
34
+ }
35
+ surface = this.CanvasKit.MakeRenderTarget(grContext, width, height);
33
36
  }
34
37
  if (!surface) {
35
38
  return null;