@shopify/react-native-skia 2.4.6 → 2.4.14

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 (143) hide show
  1. package/android/cpp/jni/JniPlatformContext.cpp +1 -1
  2. package/android/src/main/java/com/shopify/reactnative/skia/ViewScreenshotService.java +11 -1
  3. package/apple/RNSkApplePlatformContext.h +4 -0
  4. package/apple/RNSkApplePlatformContext.mm +69 -0
  5. package/apple/SkiaCVPixelBufferUtils.mm +8 -4
  6. package/cpp/api/JsiSkFontMgr.h +30 -6
  7. package/cpp/api/JsiSkImageFilterFactory.h +4 -2
  8. package/cpp/api/JsiSkPictureFactory.h +9 -6
  9. package/cpp/api/recorder/RNRecorder.h +33 -55
  10. package/cpp/rnskia/RNSkPictureView.h +7 -5
  11. package/cpp/rnskia/RNSkPlatformContext.h +16 -0
  12. package/cpp/skia/include/codec/SkAndroidCodec.h +3 -2
  13. package/cpp/skia/include/codec/SkAvifDecoder.h +2 -2
  14. package/cpp/skia/include/codec/SkBmpDecoder.h +1 -1
  15. package/cpp/skia/include/codec/SkCodec.h +2 -8
  16. package/cpp/skia/include/codec/SkEncodedOrigin.h +17 -0
  17. package/cpp/skia/include/codec/SkGifDecoder.h +1 -1
  18. package/cpp/skia/include/codec/SkIcoDecoder.h +1 -1
  19. package/cpp/skia/include/codec/SkJpegDecoder.h +8 -1
  20. package/cpp/skia/include/codec/SkJpegxlDecoder.h +1 -1
  21. package/cpp/skia/include/codec/SkPngDecoder.h +8 -1
  22. package/cpp/skia/include/codec/SkRawDecoder.h +1 -1
  23. package/cpp/skia/include/codec/SkWbmpDecoder.h +1 -1
  24. package/cpp/skia/include/codec/SkWebpDecoder.h +8 -1
  25. package/cpp/skia/include/core/SkCPURecorder.h +1 -0
  26. package/cpp/skia/include/core/SkCanvas.h +3 -2
  27. package/cpp/skia/include/core/SkColorTable.h +1 -1
  28. package/cpp/skia/include/core/SkColorType.h +4 -0
  29. package/cpp/skia/include/core/SkDocument.h +1 -1
  30. package/cpp/skia/include/core/SkGraphics.h +7 -2
  31. package/cpp/skia/include/core/SkImage.h +5 -1
  32. package/cpp/skia/include/core/SkImageGenerator.h +5 -3
  33. package/cpp/skia/include/core/SkM44.h +3 -3
  34. package/cpp/skia/include/core/SkMatrix.h +0 -23
  35. package/cpp/skia/include/core/SkMilestone.h +1 -1
  36. package/cpp/skia/include/core/SkOverdrawCanvas.h +1 -1
  37. package/cpp/skia/include/core/SkPath.h +216 -185
  38. package/cpp/skia/include/core/SkPathBuilder.h +97 -47
  39. package/cpp/skia/include/core/SkPathTypes.h +7 -1
  40. package/cpp/skia/include/core/SkPixmap.h +8 -8
  41. package/cpp/skia/include/core/SkRRect.h +24 -3
  42. package/cpp/skia/include/core/SkRecorder.h +3 -1
  43. package/cpp/skia/include/core/SkScalar.h +1 -1
  44. package/cpp/skia/include/core/SkSerialProcs.h +8 -4
  45. package/cpp/skia/include/core/SkStream.h +16 -9
  46. package/cpp/skia/include/core/SkString.h +1 -1
  47. package/cpp/skia/include/core/SkStrokeRec.h +1 -1
  48. package/cpp/skia/include/core/SkYUVAInfo.h +3 -0
  49. package/cpp/skia/include/docs/SkPDFDocument.h +1 -1
  50. package/cpp/skia/include/docs/SkPDFJpegHelpers.h +1 -1
  51. package/cpp/skia/include/docs/SkXPSDocument.h +18 -2
  52. package/cpp/skia/include/effects/SkRuntimeEffect.h +3 -1
  53. package/cpp/skia/include/encode/SkPngRustEncoder.h +18 -0
  54. package/cpp/skia/include/gpu/ganesh/GrBackendSurface.h +1 -1
  55. package/cpp/skia/include/gpu/ganesh/GrExternalTextureGenerator.h +1 -1
  56. package/cpp/skia/include/gpu/ganesh/GrRecordingContext.h +7 -6
  57. package/cpp/skia/include/gpu/ganesh/gl/GrGLBackendSurface.h +6 -0
  58. package/cpp/skia/include/gpu/ganesh/vk/GrBackendDrawableInfo.h +2 -4
  59. package/cpp/skia/include/gpu/graphite/Context.h +15 -1
  60. package/cpp/skia/include/gpu/graphite/ContextOptions.h +52 -11
  61. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +44 -0
  62. package/cpp/skia/include/gpu/graphite/LogPriority.h +1 -1
  63. package/cpp/skia/include/gpu/graphite/PersistentPipelineStorage.h +45 -0
  64. package/cpp/skia/include/gpu/graphite/PrecompileContext.h +1 -1
  65. package/cpp/skia/include/gpu/graphite/Recorder.h +14 -0
  66. package/cpp/skia/include/gpu/graphite/TextureInfo.h +13 -5
  67. package/cpp/skia/include/gpu/graphite/dawn/DawnGraphiteTypes.h +1 -4
  68. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes.h +1 -4
  69. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +2 -8
  70. package/cpp/skia/include/gpu/vk/VulkanExtensions.h +1 -1
  71. package/cpp/skia/include/gpu/vk/VulkanTypes.h +124 -9
  72. package/cpp/skia/include/ports/SkFontMgr_fuchsia.h +3 -1
  73. package/cpp/skia/include/ports/SkImageGeneratorCG.h +1 -1
  74. package/cpp/skia/include/ports/SkImageGeneratorNDK.h +1 -1
  75. package/cpp/skia/include/ports/SkImageGeneratorWIC.h +1 -1
  76. package/cpp/skia/include/ports/SkTypeface_fontations.h +1 -1
  77. package/cpp/skia/include/private/SkEncodedInfo.h +38 -29
  78. package/cpp/skia/include/private/SkJpegMetadataDecoder.h +18 -13
  79. package/cpp/skia/include/private/SkPathRef.h +3 -6
  80. package/cpp/skia/include/private/base/SkAlign.h +3 -7
  81. package/cpp/skia/include/private/base/SkContainers.h +1 -1
  82. package/cpp/skia/include/private/base/SkSpan_impl.h +29 -0
  83. package/cpp/skia/include/private/base/SkTArray.h +7 -8
  84. package/cpp/skia/include/private/base/SkTDArray.h +4 -4
  85. package/cpp/skia/include/private/base/SkTemplates.h +5 -5
  86. package/cpp/skia/include/private/chromium/GrDeferredDisplayListRecorder.h +1 -1
  87. package/cpp/skia/include/private/gpu/ganesh/GrContext_Base.h +1 -1
  88. package/cpp/skia/include/private/gpu/ganesh/GrImageContext.h +1 -1
  89. package/cpp/skia/include/private/gpu/ganesh/GrTypesPriv.h +6 -5
  90. package/cpp/skia/include/svg/SkSVGCanvas.h +21 -1
  91. package/cpp/skia/include/utils/SkNoDrawCanvas.h +1 -1
  92. package/cpp/skia/include/utils/SkPaintFilterCanvas.h +1 -1
  93. package/cpp/skia/modules/skcms/src/skcms_public.h +29 -4
  94. package/cpp/skia/modules/skottie/include/Skottie.h +11 -0
  95. package/cpp/skia/modules/skottie/include/SlotManager.h +1 -1
  96. package/cpp/skia/modules/skparagraph/include/Metrics.h +1 -1
  97. package/cpp/skia/modules/skparagraph/include/Paragraph.h +1 -1
  98. package/cpp/skia/modules/sksg/include/SkSGMerge.h +1 -1
  99. package/cpp/skia/modules/sksg/include/SkSGPath.h +1 -1
  100. package/cpp/skia/modules/skshaper/include/SkShaper.h +2 -0
  101. package/cpp/skia/modules/skunicode/include/SkUnicode.h +4 -4
  102. package/cpp/skia/modules/svg/include/SkSVGAttributeParser.h +1 -1
  103. package/cpp/skia/modules/svg/include/SkSVGFeComponentTransfer.h +1 -1
  104. package/cpp/skia/modules/svg/include/SkSVGNode.h +1 -1
  105. package/cpp/skia/modules/svg/include/SkSVGPoly.h +1 -1
  106. package/cpp/skia/modules/svg/include/SkSVGShape.h +1 -1
  107. package/cpp/skia/modules/svg/include/SkSVGTransformableNode.h +1 -1
  108. package/cpp/skia/modules/svg/include/SkSVGValue.h +1 -1
  109. package/lib/commonjs/skia/core/Font.js +7 -1
  110. package/lib/commonjs/skia/core/Font.js.map +1 -1
  111. package/lib/commonjs/skia/web/JsiSkCanvas.d.ts +1 -1
  112. package/lib/commonjs/skia/web/JsiSkCanvas.js +1 -7
  113. package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
  114. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.d.ts +1 -1
  115. package/lib/commonjs/views/SkiaPictureView.web.d.ts +4 -1
  116. package/lib/commonjs/views/SkiaPictureView.web.js +7 -2
  117. package/lib/commonjs/views/SkiaPictureView.web.js.map +1 -1
  118. package/lib/module/skia/core/Font.js +7 -1
  119. package/lib/module/skia/core/Font.js.map +1 -1
  120. package/lib/module/skia/web/JsiSkCanvas.d.ts +1 -1
  121. package/lib/module/skia/web/JsiSkCanvas.js +1 -7
  122. package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
  123. package/lib/module/specs/SkiaPictureViewNativeComponent.web.d.ts +1 -1
  124. package/lib/module/views/SkiaPictureView.web.d.ts +4 -1
  125. package/lib/module/views/SkiaPictureView.web.js +7 -3
  126. package/lib/module/views/SkiaPictureView.web.js.map +1 -1
  127. package/lib/typescript/lib/commonjs/skia/core/Font.d.ts +1 -1
  128. package/lib/typescript/lib/commonjs/skia/web/JsiSkCanvas.d.ts +1 -1
  129. package/lib/typescript/lib/commonjs/specs/SkiaPictureViewNativeComponent.web.d.ts +1 -11
  130. package/lib/typescript/lib/commonjs/views/SkiaPictureView.web.d.ts +1 -1
  131. package/lib/typescript/lib/module/mock/index.d.ts +1 -1
  132. package/lib/typescript/lib/module/skia/core/Font.d.ts +1 -1
  133. package/lib/typescript/lib/module/skia/web/JsiSkCanvas.d.ts +1 -1
  134. package/lib/typescript/lib/module/specs/SkiaPictureViewNativeComponent.web.d.ts +1 -1
  135. package/lib/typescript/lib/module/views/SkiaPictureView.web.d.ts +1 -1
  136. package/lib/typescript/src/skia/web/JsiSkCanvas.d.ts +1 -1
  137. package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.web.d.ts +1 -1
  138. package/lib/typescript/src/views/SkiaPictureView.web.d.ts +4 -1
  139. package/package.json +8 -8
  140. package/scripts/install-skia.mjs +74 -1
  141. package/src/skia/core/Font.ts +9 -4
  142. package/src/skia/web/JsiSkCanvas.ts +1 -3
  143. package/src/views/SkiaPictureView.web.tsx +8 -7
@@ -1,4 +1,4 @@
1
1
  export function useFont(font: any, size: number | undefined, onError: any): import("../../../..").SkFont | null;
2
2
  export function matchFont(inputStyle?: {}, fontMgr?: import("../../../..").SkFontMgr): import("../../../..").SkFont;
3
- export function listFontFamilies(fontMgr?: import("../../../..").SkFontMgr): string[];
3
+ export function listFontFamilies(fontMgr?: import("../../../..").SkFontMgr): any[];
4
4
  export function useFonts(sources: any): null;
@@ -24,7 +24,7 @@ export class JsiSkCanvas extends HostObject {
24
24
  drawText(str: any, x: any, y: any, paint: any, font: any): void;
25
25
  drawTextBlob(blob: any, x: any, y: any, paint: any): void;
26
26
  drawGlyphs(glyphs: any, positions: any, x: any, y: any, font: any, paint: any): void;
27
- drawSvg(svg: any, width: any, height: any): void;
27
+ drawSvg(svg: any, _width: any, _height: any): void;
28
28
  save(): any;
29
29
  saveLayer(paint: any, bounds: any, backdrop: any, flags: any): any;
30
30
  restore(): void;
@@ -5,4 +5,4 @@ declare function SkiaPictureViewNativeComponent({ nativeID, debug, opaque, onLay
5
5
  debug: any;
6
6
  opaque: any;
7
7
  onLayout: any;
8
- }): import("react").DetailedReactHTMLElement<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
8
+ }): import("react").FunctionComponentElement<any>;
@@ -1,2 +1,2 @@
1
- export const SkiaPictureView: React.ForwardRefExoticComponent<React.RefAttributes<any>>;
1
+ export function SkiaPictureView(props: any): React.CElement<import("react-native").ViewProps, import("react-native").View>;
2
2
  import React from "react";
@@ -27,7 +27,7 @@ export declare class JsiSkCanvas extends HostObject<Canvas, "Canvas"> implements
27
27
  drawText(str: string, x: number, y: number, paint: SkPaint, font: SkFont): void;
28
28
  drawTextBlob(blob: SkTextBlob, x: number, y: number, paint: SkPaint): void;
29
29
  drawGlyphs(glyphs: number[], positions: SkPoint[], x: number, y: number, font: SkFont, paint: SkPaint): void;
30
- drawSvg(svg: SkSVG, width?: number, height?: number): void;
30
+ drawSvg(svg: SkSVG, _width?: number, _height?: number): void;
31
31
  save(): number;
32
32
  saveLayer(paint?: SkPaint, bounds?: SkRect | null, backdrop?: SkImageFilter | null, flags?: SaveLayerFlag): number;
33
33
  restore(): void;
@@ -4,5 +4,5 @@ export interface NativeProps extends ViewProps {
4
4
  opaque?: boolean;
5
5
  nativeID: string;
6
6
  }
7
- declare const SkiaPictureViewNativeComponent: ({ nativeID, debug, opaque, onLayout, ...viewProps }: NativeProps) => import("react").FunctionComponentElement<import("..").SkiaPictureViewNativeProps & import("react").RefAttributes<import("../views/SkiaPictureView.web").SkiaPictureViewHandle>>;
7
+ declare const SkiaPictureViewNativeComponent: ({ nativeID, debug, opaque, onLayout, ...viewProps }: NativeProps) => import("react").FunctionComponentElement<import("../views/SkiaPictureView.web").SkiaPictureViewProps>;
8
8
  export default SkiaPictureViewNativeComponent;
@@ -12,4 +12,7 @@ export interface SkiaPictureViewHandle {
12
12
  measure(callback: (x: number, y: number, width: number, height: number, pageX: number, pageY: number) => void): void;
13
13
  measureInWindow(callback: (x: number, y: number, width: number, height: number) => void): void;
14
14
  }
15
- export declare const SkiaPictureView: React.ForwardRefExoticComponent<SkiaPictureViewNativeProps & React.RefAttributes<SkiaPictureViewHandle>>;
15
+ export interface SkiaPictureViewProps extends SkiaPictureViewNativeProps {
16
+ ref?: React.Ref<SkiaPictureViewHandle>;
17
+ }
18
+ export declare const SkiaPictureView: (props: SkiaPictureViewProps) => React.JSX.Element;
package/package.json CHANGED
@@ -8,15 +8,15 @@
8
8
  "setup-skia-web": "scripts/setup-canvaskit.js"
9
9
  },
10
10
  "title": "React Native Skia",
11
- "version": "2.4.6",
11
+ "version": "2.4.14",
12
12
  "skia": {
13
- "version": "m142",
13
+ "version": "m144",
14
14
  "checksums": {
15
- "android-armeabi-v7a": "5ae357eb26d9ec93797bacbc865b86eff6ac54b3a9466a1b0c41c27018cc3150",
16
- "android-arm64-v8a": "c310bd5261de1ab5f4afdb05aa51bf0f56d625f6285617e149af517a2d375e52",
17
- "android-x86": "26a18ade07de8318be2ec82bd82a1d7f2709893462229d70f0d353c6c8691cc3",
18
- "android-x86_64": "46a5576b6f8e7d1372c27576ad750384c2d6f892bfe3fc0ee260c68d08ebd844",
19
- "apple-xcframeworks": "343fad71c01e1f8331d4421c7efe0ae6dff3a7d25361c466dcda7dc3737cdd5c"
15
+ "android-armeabi-v7a": "8f7f83a4ae210cc28007f2c226d754e9ef7c929822ef60c56a4ccc134e726148",
16
+ "android-arm64-v8a": "5d799d988a6cbc0cb844a92882a2458e67990314791ea38f928d83d5e01cb828",
17
+ "android-x86": "711fbee4a1721b92604daa78fa6f8c7ce4a6a6c901973919bd030848adc4f81d",
18
+ "android-x86_64": "fe068aa70b5c8bcf991cfe99e9db38617aaeaf92defd08bc4f89384b4d4dbed4",
19
+ "apple-xcframeworks": "63e2789bd75236b16779abc7171b351aa50cd01c13f05b3e1d83b34336ceb77c"
20
20
  }
21
21
  },
22
22
  "skia-graphite": {
@@ -26,7 +26,7 @@
26
26
  "android-arm64-v8a": "6be2711ca4c31523d381420e98cabfe7e7939e246975c7b427968d5dd3b62be9",
27
27
  "android-x86": "888934ddc34f431c7fac5628f633dc11a4e84d68c41adb33307ae7586cc7b0b5",
28
28
  "android-x86_64": "2180a5be52d51bbf1dabaf95051ed0ce422b047157bcda6e486657c2c7b87ceb",
29
- "apple-xcframeworks": "cb50d9c85c9f02389ecc433912145e4a7ce2277bfe26a69dd7f7a9db74c9e276"
29
+ "apple-xcframeworks": "6c9e4c565977acaf9d4f4b113050cfe8f9804602fd3cd4ec982c605fa7b040e6"
30
30
  }
31
31
  },
32
32
  "description": "High-performance React Native Graphics using Skia",
@@ -59,10 +59,11 @@ console.log(
59
59
  `📦 Downloading Skia prebuilt binaries for ${releaseTag}`
60
60
  );
61
61
 
62
- const runCommand = (command, args) => {
62
+ const runCommand = (command, args, options = {}) => {
63
63
  return new Promise((resolve, reject) => {
64
64
  const child = spawn(command, args, {
65
65
  stdio: ["ignore", "inherit", "inherit"],
66
+ ...options,
66
67
  });
67
68
  child.on("error", (error) => {
68
69
  reject(error);
@@ -77,6 +78,75 @@ const runCommand = (command, args) => {
77
78
  });
78
79
  };
79
80
 
81
+ const runCommandWithOutput = (command, args, options = {}) => {
82
+ return new Promise((resolve, reject) => {
83
+ const child = spawn(command, args, {
84
+ stdio: ["ignore", "pipe", "pipe"],
85
+ ...options,
86
+ });
87
+ let stdout = "";
88
+ let stderr = "";
89
+ child.stdout.on("data", (data) => {
90
+ stdout += data.toString();
91
+ });
92
+ child.stderr.on("data", (data) => {
93
+ stderr += data.toString();
94
+ });
95
+ child.on("error", (error) => {
96
+ reject(error);
97
+ });
98
+ child.on("close", (code) => {
99
+ if (code === 0) {
100
+ resolve(stdout.trim());
101
+ } else {
102
+ reject(new Error(`Command ${command} exited with code ${code}: ${stderr}`));
103
+ }
104
+ });
105
+ });
106
+ };
107
+
108
+ const skiaDir = path.resolve(__dirname, "../../../externals/skia");
109
+
110
+ const checkoutSkiaBranch = async (version) => {
111
+ const branchName = `chrome/${version}`;
112
+
113
+ // Check if the skia directory exists and is a git repo
114
+ // (won't exist when installed via npm - submodule is not included in the package)
115
+ if (!fs.existsSync(skiaDir) || !fs.existsSync(path.join(skiaDir, ".git"))) {
116
+ return;
117
+ }
118
+
119
+ console.log(`🔀 Checking out Skia branch: ${branchName}`);
120
+
121
+ try {
122
+ // Get current branch/commit
123
+ const currentRef = await runCommandWithOutput("git", ["rev-parse", "--abbrev-ref", "HEAD"], { cwd: skiaDir });
124
+
125
+ if (currentRef === branchName) {
126
+ console.log(` ✓ Already on branch ${branchName}`);
127
+ return;
128
+ }
129
+
130
+ // Fetch the branch from origin
131
+ console.log(` Fetching branch ${branchName} from origin...`);
132
+ try {
133
+ await runCommand("git", ["fetch", "origin", `${branchName}:${branchName}`], { cwd: skiaDir });
134
+ } catch (e) {
135
+ // Branch might already exist locally, try to update it
136
+ await runCommand("git", ["fetch", "origin", branchName], { cwd: skiaDir });
137
+ }
138
+
139
+ // Checkout the branch (use -f to discard local changes in the submodule)
140
+ console.log(` Checking out ${branchName}...`);
141
+ await runCommand("git", ["checkout", "-f", branchName], { cwd: skiaDir });
142
+
143
+ console.log(` ✓ Successfully checked out ${branchName}`);
144
+ } catch (error) {
145
+ console.error(` ⚠️ Failed to checkout branch ${branchName}: ${error.message}`);
146
+ console.error(" Headers may not match the prebuilt binaries!");
147
+ }
148
+ };
149
+
80
150
  const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
81
151
 
82
152
  const downloadToFile = (url, destPath, maxRetries = 5) => {
@@ -359,6 +429,9 @@ const clearDirectory = (directory) => {
359
429
  };
360
430
 
361
431
  const main = async () => {
432
+ // Ensure the skia submodule is on the correct branch for copying headers
433
+ await checkoutSkiaBranch(skiaVersion);
434
+
362
435
  // Check if binaries are installed and checksums match
363
436
  if (areBinariesInstalled() && verifyChecksums()) {
364
437
  console.log("✅ Prebuilt binaries already installed with matching checksums, skipping download");
@@ -95,10 +95,15 @@ export const matchFont = (
95
95
  return Skia.Font(typeface, fontStyle.fontSize);
96
96
  };
97
97
 
98
- export const listFontFamilies = (fontMgr: SkFontMgr = Skia.FontMgr.System()) =>
99
- new Array(fontMgr.countFamilies())
100
- .fill(0)
101
- .map((_, i) => fontMgr.getFamilyName(i));
98
+ export const listFontFamilies = (
99
+ fontMgr: SkFontMgr = Skia.FontMgr.System()
100
+ ) => {
101
+ const families = new Set<string>();
102
+ for (let i = 0; i < fontMgr.countFamilies(); i++) {
103
+ families.add(fontMgr.getFamilyName(i));
104
+ }
105
+ return Array.from(families);
106
+ };
102
107
 
103
108
  const loadTypefaces = (typefacesToLoad: Record<string, DataModule[]>) => {
104
109
  const promises = Object.keys(typefacesToLoad).flatMap((familyName) => {
@@ -312,9 +312,7 @@ export class JsiSkCanvas
312
312
  );
313
313
  }
314
314
 
315
- drawSvg(svg: SkSVG, width?: number, height?: number) {
316
- const ctm = this.ref.getLocalToDevice();
317
- console.log({ ctm, width, height });
315
+ drawSvg(svg: SkSVG, _width?: number, _height?: number) {
318
316
  const image = this.CanvasKit.MakeImageFromCanvasImageSource(
319
317
  (svg as JsiSkSVG).ref
320
318
  );
@@ -4,7 +4,6 @@ import React, {
4
4
  useEffect,
5
5
  useCallback,
6
6
  useImperativeHandle,
7
- forwardRef,
8
7
  } from "react";
9
8
  import type { LayoutChangeEvent } from "react-native";
10
9
 
@@ -239,10 +238,12 @@ export interface SkiaPictureViewHandle {
239
238
  ): void;
240
239
  }
241
240
 
242
- export const SkiaPictureView = forwardRef<
243
- SkiaPictureViewHandle,
244
- SkiaPictureViewNativeProps
245
- >((props, ref) => {
241
+ export interface SkiaPictureViewProps extends SkiaPictureViewNativeProps {
242
+ ref?: React.Ref<SkiaPictureViewHandle>;
243
+ }
244
+
245
+ export const SkiaPictureView = (props: SkiaPictureViewProps) => {
246
+ const { ref } = props;
246
247
  const canvasRef = useRef<HTMLCanvasElement | null>(null);
247
248
  const renderer = useRef<Renderer | null>(null);
248
249
  const redrawRequestsRef = useRef(0);
@@ -415,10 +416,10 @@ export const SkiaPictureView = forwardRef<
415
416
  }
416
417
  }, [picture, redraw]);
417
418
 
418
- const { debug = false, ...viewProps } = props;
419
+ const { debug = false, ref: _ref, ...viewProps } = props;
419
420
  return (
420
421
  <Platform.View {...viewProps} onLayout={onLayoutEvent}>
421
422
  <canvas ref={canvasRef} style={{ display: "flex", flex: 1 }} />
422
423
  </Platform.View>
423
424
  );
424
- });
425
+ };