@shopify/react-native-skia 2.4.7 → 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 (117) 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/RNSkPlatformContext.h +16 -0
  11. package/cpp/skia/include/codec/SkAndroidCodec.h +3 -2
  12. package/cpp/skia/include/codec/SkAvifDecoder.h +2 -2
  13. package/cpp/skia/include/codec/SkBmpDecoder.h +1 -1
  14. package/cpp/skia/include/codec/SkCodec.h +2 -8
  15. package/cpp/skia/include/codec/SkEncodedOrigin.h +17 -0
  16. package/cpp/skia/include/codec/SkGifDecoder.h +1 -1
  17. package/cpp/skia/include/codec/SkIcoDecoder.h +1 -1
  18. package/cpp/skia/include/codec/SkJpegDecoder.h +8 -1
  19. package/cpp/skia/include/codec/SkJpegxlDecoder.h +1 -1
  20. package/cpp/skia/include/codec/SkPngDecoder.h +8 -1
  21. package/cpp/skia/include/codec/SkRawDecoder.h +1 -1
  22. package/cpp/skia/include/codec/SkWbmpDecoder.h +1 -1
  23. package/cpp/skia/include/codec/SkWebpDecoder.h +8 -1
  24. package/cpp/skia/include/core/SkCPURecorder.h +1 -0
  25. package/cpp/skia/include/core/SkCanvas.h +3 -2
  26. package/cpp/skia/include/core/SkColorTable.h +1 -1
  27. package/cpp/skia/include/core/SkColorType.h +4 -0
  28. package/cpp/skia/include/core/SkDocument.h +1 -1
  29. package/cpp/skia/include/core/SkGraphics.h +7 -2
  30. package/cpp/skia/include/core/SkImage.h +5 -1
  31. package/cpp/skia/include/core/SkImageGenerator.h +5 -3
  32. package/cpp/skia/include/core/SkM44.h +3 -3
  33. package/cpp/skia/include/core/SkMatrix.h +0 -23
  34. package/cpp/skia/include/core/SkMilestone.h +1 -1
  35. package/cpp/skia/include/core/SkOverdrawCanvas.h +1 -1
  36. package/cpp/skia/include/core/SkPath.h +216 -185
  37. package/cpp/skia/include/core/SkPathBuilder.h +97 -47
  38. package/cpp/skia/include/core/SkPathTypes.h +7 -1
  39. package/cpp/skia/include/core/SkPixmap.h +8 -8
  40. package/cpp/skia/include/core/SkRRect.h +24 -3
  41. package/cpp/skia/include/core/SkRecorder.h +3 -1
  42. package/cpp/skia/include/core/SkScalar.h +1 -1
  43. package/cpp/skia/include/core/SkSerialProcs.h +8 -4
  44. package/cpp/skia/include/core/SkStream.h +16 -9
  45. package/cpp/skia/include/core/SkString.h +1 -1
  46. package/cpp/skia/include/core/SkStrokeRec.h +1 -1
  47. package/cpp/skia/include/core/SkYUVAInfo.h +3 -0
  48. package/cpp/skia/include/docs/SkPDFDocument.h +1 -1
  49. package/cpp/skia/include/docs/SkPDFJpegHelpers.h +1 -1
  50. package/cpp/skia/include/docs/SkXPSDocument.h +18 -2
  51. package/cpp/skia/include/effects/SkRuntimeEffect.h +3 -1
  52. package/cpp/skia/include/encode/SkPngRustEncoder.h +18 -0
  53. package/cpp/skia/include/gpu/ganesh/GrBackendSurface.h +1 -1
  54. package/cpp/skia/include/gpu/ganesh/GrExternalTextureGenerator.h +1 -1
  55. package/cpp/skia/include/gpu/ganesh/GrRecordingContext.h +7 -6
  56. package/cpp/skia/include/gpu/ganesh/gl/GrGLBackendSurface.h +6 -0
  57. package/cpp/skia/include/gpu/ganesh/vk/GrBackendDrawableInfo.h +2 -4
  58. package/cpp/skia/include/gpu/graphite/Context.h +15 -1
  59. package/cpp/skia/include/gpu/graphite/ContextOptions.h +52 -11
  60. package/cpp/skia/include/gpu/graphite/GraphiteTypes.h +44 -0
  61. package/cpp/skia/include/gpu/graphite/LogPriority.h +1 -1
  62. package/cpp/skia/include/gpu/graphite/PersistentPipelineStorage.h +45 -0
  63. package/cpp/skia/include/gpu/graphite/PrecompileContext.h +1 -1
  64. package/cpp/skia/include/gpu/graphite/Recorder.h +14 -0
  65. package/cpp/skia/include/gpu/graphite/TextureInfo.h +13 -5
  66. package/cpp/skia/include/gpu/graphite/dawn/DawnGraphiteTypes.h +1 -4
  67. package/cpp/skia/include/gpu/graphite/mtl/MtlGraphiteTypes.h +1 -4
  68. package/cpp/skia/include/gpu/graphite/vk/VulkanGraphiteTypes.h +2 -8
  69. package/cpp/skia/include/gpu/vk/VulkanExtensions.h +1 -1
  70. package/cpp/skia/include/gpu/vk/VulkanTypes.h +124 -9
  71. package/cpp/skia/include/ports/SkFontMgr_fuchsia.h +3 -1
  72. package/cpp/skia/include/ports/SkImageGeneratorCG.h +1 -1
  73. package/cpp/skia/include/ports/SkImageGeneratorNDK.h +1 -1
  74. package/cpp/skia/include/ports/SkImageGeneratorWIC.h +1 -1
  75. package/cpp/skia/include/ports/SkTypeface_fontations.h +1 -1
  76. package/cpp/skia/include/private/SkEncodedInfo.h +38 -29
  77. package/cpp/skia/include/private/SkJpegMetadataDecoder.h +18 -13
  78. package/cpp/skia/include/private/SkPathRef.h +3 -6
  79. package/cpp/skia/include/private/base/SkAlign.h +3 -7
  80. package/cpp/skia/include/private/base/SkContainers.h +1 -1
  81. package/cpp/skia/include/private/base/SkSpan_impl.h +29 -0
  82. package/cpp/skia/include/private/base/SkTArray.h +7 -8
  83. package/cpp/skia/include/private/base/SkTDArray.h +4 -4
  84. package/cpp/skia/include/private/base/SkTemplates.h +5 -5
  85. package/cpp/skia/include/private/chromium/GrDeferredDisplayListRecorder.h +1 -1
  86. package/cpp/skia/include/private/gpu/ganesh/GrContext_Base.h +1 -1
  87. package/cpp/skia/include/private/gpu/ganesh/GrImageContext.h +1 -1
  88. package/cpp/skia/include/private/gpu/ganesh/GrTypesPriv.h +6 -5
  89. package/cpp/skia/include/svg/SkSVGCanvas.h +21 -1
  90. package/cpp/skia/include/utils/SkNoDrawCanvas.h +1 -1
  91. package/cpp/skia/include/utils/SkPaintFilterCanvas.h +1 -1
  92. package/cpp/skia/modules/skcms/src/skcms_public.h +29 -4
  93. package/cpp/skia/modules/skottie/include/Skottie.h +11 -0
  94. package/cpp/skia/modules/skottie/include/SlotManager.h +1 -1
  95. package/cpp/skia/modules/skparagraph/include/Metrics.h +1 -1
  96. package/cpp/skia/modules/skparagraph/include/Paragraph.h +1 -1
  97. package/cpp/skia/modules/sksg/include/SkSGMerge.h +1 -1
  98. package/cpp/skia/modules/sksg/include/SkSGPath.h +1 -1
  99. package/cpp/skia/modules/skshaper/include/SkShaper.h +2 -0
  100. package/cpp/skia/modules/skunicode/include/SkUnicode.h +4 -4
  101. package/cpp/skia/modules/svg/include/SkSVGAttributeParser.h +1 -1
  102. package/cpp/skia/modules/svg/include/SkSVGFeComponentTransfer.h +1 -1
  103. package/cpp/skia/modules/svg/include/SkSVGNode.h +1 -1
  104. package/cpp/skia/modules/svg/include/SkSVGPoly.h +1 -1
  105. package/cpp/skia/modules/svg/include/SkSVGShape.h +1 -1
  106. package/cpp/skia/modules/svg/include/SkSVGTransformableNode.h +1 -1
  107. package/cpp/skia/modules/svg/include/SkSVGValue.h +1 -1
  108. package/lib/commonjs/skia/core/Font.js +7 -1
  109. package/lib/commonjs/skia/core/Font.js.map +1 -1
  110. package/lib/module/skia/core/Font.js +7 -1
  111. package/lib/module/skia/core/Font.js.map +1 -1
  112. package/lib/typescript/lib/commonjs/skia/core/Font.d.ts +1 -1
  113. package/lib/typescript/lib/module/mock/index.d.ts +1 -1
  114. package/lib/typescript/lib/module/skia/core/Font.d.ts +1 -1
  115. package/package.json +8 -8
  116. package/scripts/install-skia.mjs +74 -1
  117. package/src/skia/core/Font.ts +9 -4
@@ -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) => {