@shopify/react-native-skia 2.13.1 → 2.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/android/CMakeLists.txt +2 -0
  2. package/android/cpp/jni/include/JniSkiaPictureView.h +16 -15
  3. package/apple/RNSkApplePlatformContext.h +3 -4
  4. package/apple/RNSkiaModule.h +11 -3
  5. package/apple/RNSkiaModule.mm +46 -19
  6. package/apple/SkiaPictureView.mm +2 -2
  7. package/apple/SkiaUIView.h +0 -1
  8. package/apple/SkiaUIView.mm +1 -1
  9. package/apple/ViewScreenshotService.h +2 -2
  10. package/apple/ViewScreenshotService.mm +5 -4
  11. package/cpp/api/JsiSkPath.h +0 -431
  12. package/cpp/api/JsiSkSkottie.h +2 -3
  13. package/cpp/api/JsiSkStrutStyle.h +1 -1
  14. package/cpp/api/JsiSkSurfaceFactory.h +41 -0
  15. package/cpp/api/recorder/Convertor.h +152 -131
  16. package/cpp/api/recorder/DataTypes.h +11 -11
  17. package/cpp/api/recorder/ImageFit.h +8 -5
  18. package/cpp/api/recorder/JsiRecorder.h +9 -29
  19. package/cpp/api/recorder/Paint.h +3 -3
  20. package/cpp/api/recorder/RNRecorder.h +56 -0
  21. package/cpp/jsi/ViewProperty.cpp +23 -0
  22. package/cpp/jsi/ViewProperty.h +31 -10
  23. package/cpp/rnskia/RNDawnContext.h +33 -0
  24. package/cpp/rnskia/RNSkJsiViewApi.h +69 -2
  25. package/cpp/rnskia/RNSkPictureView.cpp +58 -0
  26. package/cpp/rnskia/RNSkPictureView.h +110 -24
  27. package/lib/commonjs/Platform/IPlatform.js.map +1 -1
  28. package/lib/commonjs/animation/functions/interpolate.js.map +1 -1
  29. package/lib/commonjs/skia/core/Image.js.map +1 -1
  30. package/lib/commonjs/skia/types/NativeBuffer/NativeBufferFactory.js.map +1 -1
  31. package/lib/commonjs/skia/types/Path/Path.d.ts +2 -336
  32. package/lib/commonjs/skia/types/Path/Path.js.map +1 -1
  33. package/lib/commonjs/skia/types/Recorder.d.ts +10 -0
  34. package/lib/commonjs/skia/types/Recorder.js.map +1 -1
  35. package/lib/commonjs/skia/types/Shader/Shader.js.map +1 -1
  36. package/lib/commonjs/skia/types/Surface/SurfaceFactory.d.ts +16 -0
  37. package/lib/commonjs/skia/types/Surface/SurfaceFactory.js.map +1 -1
  38. package/lib/commonjs/skia/web/JsiSkPath.d.ts +4 -38
  39. package/lib/commonjs/skia/web/JsiSkPath.js +3 -275
  40. package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
  41. package/lib/commonjs/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
  42. package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js +3 -0
  43. package/lib/commonjs/skia/web/JsiSkSurfaceFactory.js.map +1 -1
  44. package/lib/commonjs/sksg/Container.native.d.ts +15 -1
  45. package/lib/commonjs/sksg/Container.native.js +34 -33
  46. package/lib/commonjs/sksg/Container.native.js.map +1 -1
  47. package/lib/commonjs/specs/NativeSkiaModule.web.js +4 -0
  48. package/lib/commonjs/specs/NativeSkiaModule.web.js.map +1 -1
  49. package/lib/commonjs/views/types.d.ts +9 -0
  50. package/lib/commonjs/views/types.js.map +1 -1
  51. package/lib/module/Platform/IPlatform.js.map +1 -1
  52. package/lib/module/animation/functions/interpolate.js.map +1 -1
  53. package/lib/module/skia/core/Image.js.map +1 -1
  54. package/lib/module/skia/types/NativeBuffer/NativeBufferFactory.js.map +1 -1
  55. package/lib/module/skia/types/Path/Path.d.ts +2 -336
  56. package/lib/module/skia/types/Path/Path.js.map +1 -1
  57. package/lib/module/skia/types/Recorder.d.ts +10 -0
  58. package/lib/module/skia/types/Recorder.js.map +1 -1
  59. package/lib/module/skia/types/Shader/Shader.js.map +1 -1
  60. package/lib/module/skia/types/Surface/SurfaceFactory.d.ts +16 -0
  61. package/lib/module/skia/types/Surface/SurfaceFactory.js.map +1 -1
  62. package/lib/module/skia/web/JsiSkPath.d.ts +4 -38
  63. package/lib/module/skia/web/JsiSkPath.js +4 -276
  64. package/lib/module/skia/web/JsiSkPath.js.map +1 -1
  65. package/lib/module/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
  66. package/lib/module/skia/web/JsiSkSurfaceFactory.js +4 -1
  67. package/lib/module/skia/web/JsiSkSurfaceFactory.js.map +1 -1
  68. package/lib/module/sksg/Container.native.d.ts +15 -1
  69. package/lib/module/sksg/Container.native.js +34 -33
  70. package/lib/module/sksg/Container.native.js.map +1 -1
  71. package/lib/module/specs/NativeSkiaModule.web.js +4 -0
  72. package/lib/module/specs/NativeSkiaModule.web.js.map +1 -1
  73. package/lib/module/views/types.d.ts +9 -0
  74. package/lib/module/views/types.js.map +1 -1
  75. package/lib/typescript/lib/commonjs/skia/web/JsiSkPath.d.ts +1 -35
  76. package/lib/typescript/lib/commonjs/skia/web/JsiSkSurfaceFactory.d.ts +1 -0
  77. package/lib/typescript/lib/commonjs/sksg/Container.native.d.ts +15 -1
  78. package/lib/typescript/lib/module/skia/web/JsiSkPath.d.ts +3 -37
  79. package/lib/typescript/lib/module/skia/web/JsiSkSurfaceFactory.d.ts +1 -0
  80. package/lib/typescript/lib/module/sksg/Container.native.d.ts +15 -1
  81. package/lib/typescript/src/skia/types/Path/Path.d.ts +2 -336
  82. package/lib/typescript/src/skia/types/Recorder.d.ts +10 -0
  83. package/lib/typescript/src/skia/types/Surface/SurfaceFactory.d.ts +16 -0
  84. package/lib/typescript/src/skia/web/JsiSkPath.d.ts +4 -38
  85. package/lib/typescript/src/skia/web/JsiSkSurfaceFactory.d.ts +2 -1
  86. package/lib/typescript/src/sksg/Container.native.d.ts +15 -1
  87. package/lib/typescript/src/views/types.d.ts +9 -0
  88. package/package.json +2 -2
  89. package/src/Platform/IPlatform.ts +1 -4
  90. package/src/animation/functions/interpolate.ts +1 -4
  91. package/src/skia/core/Image.ts +1 -2
  92. package/src/skia/types/NativeBuffer/NativeBufferFactory.ts +2 -5
  93. package/src/skia/types/Path/Path.ts +2 -420
  94. package/src/skia/types/Recorder.ts +10 -0
  95. package/src/skia/types/Shader/Shader.ts +1 -5
  96. package/src/skia/types/Surface/SurfaceFactory.ts +17 -0
  97. package/src/skia/web/JsiSkPath.ts +4 -495
  98. package/src/skia/web/JsiSkSurfaceFactory.ts +6 -2
  99. package/src/sksg/Container.native.ts +34 -37
  100. package/src/specs/NativeSkiaModule.web.ts +4 -0
  101. package/src/views/types.ts +13 -0
  102. package/apple/SkiaManager.h +0 -23
  103. package/apple/SkiaManager.mm +0 -63
@@ -1,4 +1,5 @@
1
1
  import type { ViewProps } from "react-native";
2
+ import type { SharedValue } from "react-native-reanimated";
2
3
 
3
4
  import type { SkImage, SkPicture, SkRect, SkSize } from "../skia/types";
4
5
 
@@ -27,6 +28,18 @@ export interface ISkiaViewApi {
27
28
  web?: boolean;
28
29
  setJsiProperty: <T>(nativeId: number, name: string, value: T) => void;
29
30
  requestRedraw: (nativeId: number) => void;
31
+ /**
32
+ * Reads the shared values into the recording held for the view and
33
+ * schedules a redraw. Native only; called from a worklet on every frame.
34
+ * Until the view registers, the recording is queued for it and kept
35
+ * current all the same. Ignored when the recording `recorderId` is neither
36
+ * held by the view nor queued for it.
37
+ */
38
+ applyUpdates: (
39
+ nativeId: number,
40
+ recorderId: number,
41
+ values: SharedValue<unknown>[]
42
+ ) => void;
30
43
  makeImageSnapshot: (nativeId: number, rect?: SkRect) => SkImage;
31
44
  makeImageSnapshotAsync: (nativeId: number, rect?: SkRect) => Promise<SkImage>;
32
45
  size: (nativeId: number) => SkSize;
@@ -1,23 +0,0 @@
1
- #pragma once
2
-
3
- #import <React/RCTBridge.h>
4
-
5
- #import "RNSkManager.h"
6
-
7
- @interface SkiaManager : NSObject
8
-
9
- - (std::shared_ptr<RNSkia::RNSkManager>)skManager;
10
-
11
- - (instancetype)init NS_UNAVAILABLE;
12
-
13
- - (void)invalidate;
14
-
15
- - (instancetype)initWithBridge:(RCTBridge *)bridge
16
- jsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)
17
- jsInvoker;
18
-
19
- // Fabric components do not have a better way to interact with TurboModules.
20
- // Workaround to get the SkManager instance from singleton.
21
- + (std::shared_ptr<RNSkia::RNSkManager>)latestActiveSkManager;
22
-
23
- @end
@@ -1,63 +0,0 @@
1
- #import "SkiaManager.h"
2
-
3
- #import <Foundation/Foundation.h>
4
-
5
- #import <React/RCTBridge.h>
6
- #import <React/RCTUIManager.h>
7
-
8
- #import "RNSkApplePlatformContext.h"
9
-
10
- // Forward-declared runtime accessor satisfied by RCTBridgeProxy (bridgeless).
11
- // Avoids referencing RCTCxxBridge, which is compiled out when
12
- // RCT_REMOVE_LEGACY_ARCH is set (React Native 0.82+).
13
- @interface RCTBridge (RNSkiaRuntime)
14
- - (void *)runtime;
15
- @end
16
-
17
- static __weak SkiaManager *sharedInstance = nil;
18
-
19
- @implementation SkiaManager {
20
- std::shared_ptr<RNSkia::RNSkManager> _skManager;
21
- __weak RCTBridge *weakBridge;
22
- }
23
-
24
- - (std::shared_ptr<RNSkia::RNSkManager>)skManager {
25
- return _skManager;
26
- }
27
-
28
- - (void)invalidate {
29
- _skManager = nullptr;
30
- }
31
-
32
- - (instancetype)initWithBridge:(RCTBridge *)bridge
33
- jsInvoker:(std::shared_ptr<facebook::react::CallInvoker>)
34
- jsInvoker {
35
- self = [super init];
36
- if (self) {
37
- sharedInstance = self;
38
- if (bridge.runtime) {
39
- facebook::jsi::Runtime *jsRuntime =
40
- (facebook::jsi::Runtime *)bridge.runtime;
41
-
42
- // Create the RNSkiaManager (cross platform)
43
- _skManager = std::make_shared<RNSkia::RNSkManager>(
44
- jsRuntime, jsInvoker,
45
- std::make_shared<RNSkia::RNSkApplePlatformContext>(bridge,
46
- jsInvoker));
47
- }
48
- }
49
- return self;
50
- }
51
-
52
- - (void)dealloc {
53
- sharedInstance = nil;
54
- }
55
-
56
- + (std::shared_ptr<RNSkia::RNSkManager>)latestActiveSkManager {
57
- if (sharedInstance != nil) {
58
- return [sharedInstance skManager];
59
- }
60
- return nullptr;
61
- }
62
-
63
- @end