@shopify/react-native-skia 2.9.1 → 2.10.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 (387) hide show
  1. package/android/CMakeLists.txt +8 -46
  2. package/android/build.gradle +33 -0
  3. package/android/src/main/java/com/shopify/reactnative/skia/RNSkiaPackage.java +1 -2
  4. package/cpp/api/JsiNativeBuffer.h +23 -24
  5. package/cpp/api/JsiSkAnimatedImage.h +24 -25
  6. package/cpp/api/JsiSkAnimatedImageFactory.h +18 -17
  7. package/cpp/api/JsiSkApi.h +254 -96
  8. package/cpp/api/JsiSkCanvas.h +141 -266
  9. package/cpp/api/JsiSkColor.h +7 -5
  10. package/cpp/api/JsiSkColorFilter.h +15 -8
  11. package/cpp/api/JsiSkColorFilterFactory.h +49 -67
  12. package/cpp/api/JsiSkContourMeasure.h +31 -38
  13. package/cpp/api/JsiSkContourMeasureIter.h +20 -23
  14. package/cpp/api/JsiSkConverters.h +410 -0
  15. package/cpp/api/JsiSkData.h +13 -7
  16. package/cpp/api/JsiSkDataFactory.h +27 -32
  17. package/cpp/api/JsiSkFont.h +123 -192
  18. package/cpp/api/JsiSkFontMgr.h +33 -26
  19. package/cpp/api/JsiSkFontMgrFactory.h +12 -11
  20. package/cpp/api/JsiSkFontStyle.h +14 -12
  21. package/cpp/api/JsiSkImage.h +90 -79
  22. package/cpp/api/JsiSkImageFactory.h +93 -95
  23. package/cpp/api/JsiSkImageFilter.h +21 -11
  24. package/cpp/api/JsiSkImageFilterFactory.h +375 -629
  25. package/cpp/api/JsiSkImageInfo.h +25 -25
  26. package/cpp/api/JsiSkMaskFilter.h +21 -11
  27. package/cpp/api/JsiSkMaskFilterFactory.h +17 -17
  28. package/cpp/api/JsiSkMatrix.h +51 -88
  29. package/cpp/api/JsiSkNativeObjects.h +387 -0
  30. package/cpp/api/JsiSkPaint.h +104 -142
  31. package/cpp/api/JsiSkParagraph.h +54 -64
  32. package/cpp/api/JsiSkParagraphBuilder.h +43 -68
  33. package/cpp/api/JsiSkParagraphBuilderFactory.h +20 -24
  34. package/cpp/api/JsiSkPath.h +242 -350
  35. package/cpp/api/JsiSkPathBuilder.h +153 -273
  36. package/cpp/api/JsiSkPathBuilderFactory.h +19 -20
  37. package/cpp/api/JsiSkPathEffect.h +21 -11
  38. package/cpp/api/JsiSkPathEffectFactory.h +61 -80
  39. package/cpp/api/JsiSkPathFactory.h +148 -238
  40. package/cpp/api/JsiSkPicture.h +32 -27
  41. package/cpp/api/JsiSkPictureFactory.h +21 -26
  42. package/cpp/api/JsiSkPictureRecorder.h +27 -29
  43. package/cpp/api/JsiSkPoint.h +20 -23
  44. package/cpp/api/JsiSkRRect.h +24 -32
  45. package/cpp/api/JsiSkRSXform.h +31 -48
  46. package/cpp/api/JsiSkRect.h +40 -50
  47. package/cpp/api/JsiSkRuntimeEffect.h +85 -92
  48. package/cpp/api/JsiSkRuntimeEffectFactory.h +14 -18
  49. package/cpp/api/JsiSkRuntimeShaderBuilder.h +28 -30
  50. package/cpp/api/JsiSkSVG.h +15 -15
  51. package/cpp/api/JsiSkSVGFactory.h +17 -20
  52. package/cpp/api/JsiSkShader.h +15 -8
  53. package/cpp/api/JsiSkShaderFactory.h +159 -238
  54. package/cpp/api/JsiSkSkottie.h +131 -143
  55. package/cpp/api/JsiSkSurface.h +29 -32
  56. package/cpp/api/JsiSkSurfaceFactory.h +18 -20
  57. package/cpp/api/JsiSkTextBlob.h +15 -8
  58. package/cpp/api/JsiSkTextBlobFactory.h +40 -66
  59. package/cpp/api/JsiSkTypeface.h +25 -22
  60. package/cpp/api/JsiSkTypefaceFactory.h +17 -15
  61. package/cpp/api/JsiSkTypefaceFontProvider.h +43 -39
  62. package/cpp/api/JsiSkTypefaceFontProviderFactory.h +13 -12
  63. package/cpp/api/JsiSkVertices.h +23 -22
  64. package/cpp/api/JsiSkiaContext.h +22 -23
  65. package/cpp/api/JsiSkottieFactory.h +16 -17
  66. package/cpp/api/JsiVideo.h +43 -81
  67. package/cpp/api/recorder/Convertor.h +31 -61
  68. package/cpp/api/recorder/DataTypes.h +8 -16
  69. package/cpp/api/recorder/JsiRecorder.h +83 -55
  70. package/cpp/api/recorder/RNRecorder.h +1 -1
  71. package/cpp/jsi/BoxedNativeObject.h +146 -0
  72. package/cpp/{jsi2 → jsi}/EnumMapper.h +4 -1
  73. package/cpp/{jsi2 → jsi}/JSIConverter.h +0 -31
  74. package/cpp/{jsi2 → jsi}/NativeObject.h +131 -152
  75. package/cpp/jsi/RuntimeAwareCache.cpp +1 -1
  76. package/cpp/jsi/RuntimeAwareCache.h +26 -8
  77. package/cpp/jsi/ViewProperty.h +5 -11
  78. package/cpp/rnskia/RNDawnContext.h +18 -2
  79. package/cpp/rnskia/RNDawnInterop.cpp +19 -0
  80. package/cpp/rnskia/RNDawnUtils.h +18 -1
  81. package/cpp/rnskia/RNSkJsiViewApi.h +20 -11
  82. package/cpp/rnskia/RNSkManager.cpp +9 -168
  83. package/cpp/rnskia/RNSkPictureView.h +1 -1
  84. package/cpp/skia/include/gpu/ganesh/GrDriverBugWorkaroundsAutogen.h +2 -0
  85. package/lib/commonjs/external/reanimated/renderHelpers.d.ts +15 -0
  86. package/lib/commonjs/external/reanimated/renderHelpers.js +30 -1
  87. package/lib/commonjs/external/reanimated/renderHelpers.js.map +1 -1
  88. package/lib/commonjs/mock/index.js +0 -1
  89. package/lib/commonjs/mock/index.js.map +1 -1
  90. package/lib/commonjs/skia/NativeSetup.js +4 -0
  91. package/lib/commonjs/skia/NativeSetup.js.map +1 -1
  92. package/lib/commonjs/skia/SkiaWorkletSerialization.d.ts +1 -0
  93. package/lib/commonjs/skia/SkiaWorkletSerialization.js +66 -0
  94. package/lib/commonjs/skia/SkiaWorkletSerialization.js.map +1 -0
  95. package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +15 -6
  96. package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
  97. package/lib/commonjs/skia/types/Skia.d.ts +5 -15
  98. package/lib/commonjs/skia/types/Skia.js.map +1 -1
  99. package/lib/commonjs/skia/types/index.d.ts +0 -1
  100. package/lib/commonjs/skia/types/index.js +0 -11
  101. package/lib/commonjs/skia/types/index.js.map +1 -1
  102. package/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +2 -2
  103. package/lib/commonjs/skia/web/JsiSkImageFactory.js +2 -2
  104. package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
  105. package/lib/commonjs/skia/web/JsiSkia.js +1 -4
  106. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  107. package/lib/commonjs/sksg/Container.native.js +20 -1
  108. package/lib/commonjs/sksg/Container.native.js.map +1 -1
  109. package/lib/commonjs/views/index.d.ts +0 -1
  110. package/lib/commonjs/views/index.js +0 -11
  111. package/lib/commonjs/views/index.js.map +1 -1
  112. package/lib/module/external/reanimated/renderHelpers.d.ts +15 -0
  113. package/lib/module/external/reanimated/renderHelpers.js +29 -0
  114. package/lib/module/external/reanimated/renderHelpers.js.map +1 -1
  115. package/lib/module/mock/index.js +0 -1
  116. package/lib/module/mock/index.js.map +1 -1
  117. package/lib/module/skia/NativeSetup.js +4 -0
  118. package/lib/module/skia/NativeSetup.js.map +1 -1
  119. package/lib/module/skia/SkiaWorkletSerialization.d.ts +1 -0
  120. package/lib/module/skia/SkiaWorkletSerialization.js +59 -0
  121. package/lib/module/skia/SkiaWorkletSerialization.js.map +1 -0
  122. package/lib/module/skia/types/Image/ImageFactory.d.ts +15 -6
  123. package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
  124. package/lib/module/skia/types/Skia.d.ts +5 -15
  125. package/lib/module/skia/types/Skia.js.map +1 -1
  126. package/lib/module/skia/types/index.d.ts +0 -1
  127. package/lib/module/skia/types/index.js +0 -1
  128. package/lib/module/skia/types/index.js.map +1 -1
  129. package/lib/module/skia/web/JsiSkImageFactory.d.ts +2 -2
  130. package/lib/module/skia/web/JsiSkImageFactory.js +2 -2
  131. package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
  132. package/lib/module/skia/web/JsiSkia.js +1 -4
  133. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  134. package/lib/module/sksg/Container.native.js +21 -2
  135. package/lib/module/sksg/Container.native.js.map +1 -1
  136. package/lib/module/views/index.d.ts +0 -1
  137. package/lib/module/views/index.js +0 -1
  138. package/lib/module/views/index.js.map +1 -1
  139. package/lib/typescript/lib/commonjs/external/reanimated/renderHelpers.d.ts +2 -0
  140. package/lib/typescript/lib/commonjs/mock/index.d.ts +0 -1
  141. package/lib/typescript/lib/commonjs/skia/SkiaWorkletSerialization.d.ts +2 -0
  142. package/lib/typescript/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +2 -2
  143. package/lib/typescript/lib/commonjs/skia/web/JsiSkia.d.ts +1 -2
  144. package/lib/typescript/lib/module/external/reanimated/renderHelpers.d.ts +15 -0
  145. package/lib/typescript/lib/module/mock/index.d.ts +0 -2
  146. package/lib/typescript/lib/module/skia/Skia.web.d.ts +1 -2
  147. package/lib/typescript/lib/module/skia/SkiaWorkletSerialization.d.ts +1 -0
  148. package/lib/typescript/lib/module/skia/types/index.d.ts +0 -1
  149. package/lib/typescript/lib/module/skia/web/JsiSkImageFactory.d.ts +2 -2
  150. package/lib/typescript/lib/module/skia/web/JsiSkia.d.ts +1 -2
  151. package/lib/typescript/lib/module/views/index.d.ts +0 -1
  152. package/lib/typescript/src/external/reanimated/renderHelpers.d.ts +15 -0
  153. package/lib/typescript/src/skia/SkiaWorkletSerialization.d.ts +1 -0
  154. package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +15 -6
  155. package/lib/typescript/src/skia/types/Skia.d.ts +5 -15
  156. package/lib/typescript/src/skia/types/index.d.ts +0 -1
  157. package/lib/typescript/src/skia/web/JsiSkImageFactory.d.ts +2 -2
  158. package/lib/typescript/src/views/index.d.ts +0 -1
  159. package/package.json +8 -5
  160. package/react-native-skia.podspec +38 -5
  161. package/src/external/reanimated/renderHelpers.ts +30 -0
  162. package/src/mock/index.ts +0 -1
  163. package/src/skia/NativeSetup.ts +5 -0
  164. package/src/skia/SkiaWorkletSerialization.ts +67 -0
  165. package/src/skia/types/Image/ImageFactory.ts +15 -6
  166. package/src/skia/types/Skia.ts +5 -15
  167. package/src/skia/types/index.ts +0 -1
  168. package/src/skia/web/JsiSkImageFactory.ts +3 -3
  169. package/src/skia/web/JsiSkia.ts +2 -5
  170. package/src/sksg/Container.native.ts +40 -2
  171. package/src/views/index.ts +0 -1
  172. package/android/cpp/jni/JniWebGPUView.cpp +0 -112
  173. package/android/cpp/rnskia-android/SkiaPlatformContext.h +0 -26
  174. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUSurfaceView.java +0 -43
  175. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUTextureView.java +0 -50
  176. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUView.java +0 -98
  177. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUViewAPI.java +0 -19
  178. package/android/src/main/java/com/shopify/reactnative/skia/WebGPUViewManager.java +0 -58
  179. package/apple/RNWebGPUAppleNativeBuffer.mm +0 -33
  180. package/apple/SkiaPlatformContext.h +0 -20
  181. package/apple/SkiaPlatformContext.mm +0 -21
  182. package/apple/SkiaWebGPUView.mm +0 -81
  183. package/apple/WebGPUMetalView.mm +0 -136
  184. package/cpp/api/JsiSkHostObjects.h +0 -257
  185. package/cpp/jsi/JsiHostObject.cpp +0 -137
  186. package/cpp/jsi/JsiHostObject.h +0 -385
  187. package/cpp/rnwgpu/ArrayBuffer.h +0 -117
  188. package/cpp/rnwgpu/Canvas.h +0 -50
  189. package/cpp/rnwgpu/PlatformContext.h +0 -18
  190. package/cpp/rnwgpu/SurfaceRegistry.h +0 -605
  191. package/cpp/rnwgpu/api/AppleNativeBuffer.h +0 -22
  192. package/cpp/rnwgpu/api/Convertors.h +0 -783
  193. package/cpp/rnwgpu/api/External.h +0 -12
  194. package/cpp/rnwgpu/api/GPU.cpp +0 -162
  195. package/cpp/rnwgpu/api/GPU.h +0 -60
  196. package/cpp/rnwgpu/api/GPUAdapter.cpp +0 -240
  197. package/cpp/rnwgpu/api/GPUAdapter.h +0 -60
  198. package/cpp/rnwgpu/api/GPUAdapterInfo.h +0 -57
  199. package/cpp/rnwgpu/api/GPUBindGroup.cpp +0 -3
  200. package/cpp/rnwgpu/api/GPUBindGroup.h +0 -51
  201. package/cpp/rnwgpu/api/GPUBindGroupLayout.h +0 -52
  202. package/cpp/rnwgpu/api/GPUBuffer.cpp +0 -107
  203. package/cpp/rnwgpu/api/GPUBuffer.h +0 -88
  204. package/cpp/rnwgpu/api/GPUCanvasContext.cpp +0 -75
  205. package/cpp/rnwgpu/api/GPUCanvasContext.h +0 -70
  206. package/cpp/rnwgpu/api/GPUCommandBuffer.h +0 -45
  207. package/cpp/rnwgpu/api/GPUCommandEncoder.cpp +0 -179
  208. package/cpp/rnwgpu/api/GPUCommandEncoder.h +0 -111
  209. package/cpp/rnwgpu/api/GPUCompilationInfo.h +0 -79
  210. package/cpp/rnwgpu/api/GPUCompilationMessage.h +0 -36
  211. package/cpp/rnwgpu/api/GPUComputePassEncoder.cpp +0 -60
  212. package/cpp/rnwgpu/api/GPUComputePassEncoder.h +0 -85
  213. package/cpp/rnwgpu/api/GPUComputePipeline.cpp +0 -12
  214. package/cpp/rnwgpu/api/GPUComputePipeline.h +0 -60
  215. package/cpp/rnwgpu/api/GPUDevice.cpp +0 -614
  216. package/cpp/rnwgpu/api/GPUDevice.h +0 -258
  217. package/cpp/rnwgpu/api/GPUDeviceLostInfo.cpp +0 -7
  218. package/cpp/rnwgpu/api/GPUDeviceLostInfo.h +0 -40
  219. package/cpp/rnwgpu/api/GPUError.h +0 -35
  220. package/cpp/rnwgpu/api/GPUExtent3D.h +0 -66
  221. package/cpp/rnwgpu/api/GPUExternalTexture.cpp +0 -139
  222. package/cpp/rnwgpu/api/GPUExternalTexture.h +0 -95
  223. package/cpp/rnwgpu/api/GPUFeatures.h +0 -203
  224. package/cpp/rnwgpu/api/GPUInternalError.h +0 -31
  225. package/cpp/rnwgpu/api/GPUOrigin2D.h +0 -55
  226. package/cpp/rnwgpu/api/GPUOrigin3D.h +0 -62
  227. package/cpp/rnwgpu/api/GPUOutOfMemoryError.h +0 -33
  228. package/cpp/rnwgpu/api/GPUPipelineLayout.h +0 -45
  229. package/cpp/rnwgpu/api/GPUQuerySet.cpp +0 -11
  230. package/cpp/rnwgpu/api/GPUQuerySet.h +0 -73
  231. package/cpp/rnwgpu/api/GPUQueue.cpp +0 -179
  232. package/cpp/rnwgpu/api/GPUQueue.h +0 -84
  233. package/cpp/rnwgpu/api/GPURenderBundle.h +0 -44
  234. package/cpp/rnwgpu/api/GPURenderBundleEncoder.cpp +0 -131
  235. package/cpp/rnwgpu/api/GPURenderBundleEncoder.h +0 -110
  236. package/cpp/rnwgpu/api/GPURenderPassEncoder.cpp +0 -165
  237. package/cpp/rnwgpu/api/GPURenderPassEncoder.h +0 -130
  238. package/cpp/rnwgpu/api/GPURenderPipeline.cpp +0 -13
  239. package/cpp/rnwgpu/api/GPURenderPipeline.h +0 -61
  240. package/cpp/rnwgpu/api/GPUSampler.h +0 -44
  241. package/cpp/rnwgpu/api/GPUShaderModule.cpp +0 -56
  242. package/cpp/rnwgpu/api/GPUShaderModule.h +0 -66
  243. package/cpp/rnwgpu/api/GPUSharedFence.cpp +0 -80
  244. package/cpp/rnwgpu/api/GPUSharedFence.h +0 -53
  245. package/cpp/rnwgpu/api/GPUSharedTextureMemory.cpp +0 -135
  246. package/cpp/rnwgpu/api/GPUSharedTextureMemory.h +0 -75
  247. package/cpp/rnwgpu/api/GPUSupportedLimits.cpp +0 -129
  248. package/cpp/rnwgpu/api/GPUSupportedLimits.h +0 -131
  249. package/cpp/rnwgpu/api/GPUTexture.cpp +0 -47
  250. package/cpp/rnwgpu/api/GPUTexture.h +0 -162
  251. package/cpp/rnwgpu/api/GPUTextureView.h +0 -44
  252. package/cpp/rnwgpu/api/GPUUncapturedErrorEvent.h +0 -60
  253. package/cpp/rnwgpu/api/GPUValidationError.h +0 -32
  254. package/cpp/rnwgpu/api/ImageBitmap.h +0 -62
  255. package/cpp/rnwgpu/api/NativeBufferUtils.h +0 -87
  256. package/cpp/rnwgpu/api/RNWebGPU.h +0 -82
  257. package/cpp/rnwgpu/api/WebGPUConstants.h +0 -36
  258. package/cpp/rnwgpu/api/descriptors/GPUBindGroupDescriptor.h +0 -64
  259. package/cpp/rnwgpu/api/descriptors/GPUBindGroupEntry.h +0 -78
  260. package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutDescriptor.h +0 -56
  261. package/cpp/rnwgpu/api/descriptors/GPUBindGroupLayoutEntry.h +0 -97
  262. package/cpp/rnwgpu/api/descriptors/GPUBlendComponent.h +0 -57
  263. package/cpp/rnwgpu/api/descriptors/GPUBlendState.h +0 -52
  264. package/cpp/rnwgpu/api/descriptors/GPUBufferBinding.h +0 -56
  265. package/cpp/rnwgpu/api/descriptors/GPUBufferBindingLayout.h +0 -56
  266. package/cpp/rnwgpu/api/descriptors/GPUBufferDescriptor.h +0 -59
  267. package/cpp/rnwgpu/api/descriptors/GPUBufferUsage.h +0 -39
  268. package/cpp/rnwgpu/api/descriptors/GPUCanvasConfiguration.h +0 -76
  269. package/cpp/rnwgpu/api/descriptors/GPUColor.h +0 -66
  270. package/cpp/rnwgpu/api/descriptors/GPUColorTargetState.h +0 -58
  271. package/cpp/rnwgpu/api/descriptors/GPUColorWrite.h +0 -29
  272. package/cpp/rnwgpu/api/descriptors/GPUCommandBufferDescriptor.h +0 -45
  273. package/cpp/rnwgpu/api/descriptors/GPUCommandEncoderDescriptor.h +0 -45
  274. package/cpp/rnwgpu/api/descriptors/GPUComputePassDescriptor.h +0 -56
  275. package/cpp/rnwgpu/api/descriptors/GPUComputePassTimestampWrites.h +0 -58
  276. package/cpp/rnwgpu/api/descriptors/GPUComputePipelineDescriptor.h +0 -67
  277. package/cpp/rnwgpu/api/descriptors/GPUDawnTogglesDescriptor.h +0 -56
  278. package/cpp/rnwgpu/api/descriptors/GPUDepthStencilState.h +0 -103
  279. package/cpp/rnwgpu/api/descriptors/GPUDeviceDescriptor.h +0 -109
  280. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureBindingLayout.h +0 -38
  281. package/cpp/rnwgpu/api/descriptors/GPUExternalTextureDescriptor.h +0 -90
  282. package/cpp/rnwgpu/api/descriptors/GPUFragmentState.h +0 -73
  283. package/cpp/rnwgpu/api/descriptors/GPUImageCopyBuffer.h +0 -62
  284. package/cpp/rnwgpu/api/descriptors/GPUImageCopyExternalImage.h +0 -63
  285. package/cpp/rnwgpu/api/descriptors/GPUImageCopyTexture.h +0 -65
  286. package/cpp/rnwgpu/api/descriptors/GPUImageCopyTextureTagged.h +0 -81
  287. package/cpp/rnwgpu/api/descriptors/GPUImageDataLayout.h +0 -54
  288. package/cpp/rnwgpu/api/descriptors/GPUMapMode.h +0 -22
  289. package/cpp/rnwgpu/api/descriptors/GPUMultisampleState.h +0 -54
  290. package/cpp/rnwgpu/api/descriptors/GPUPipelineLayoutDescriptor.h +0 -57
  291. package/cpp/rnwgpu/api/descriptors/GPUPrimitiveState.h +0 -69
  292. package/cpp/rnwgpu/api/descriptors/GPUProgrammableStage.h +0 -61
  293. package/cpp/rnwgpu/api/descriptors/GPUQuerySetDescriptor.h +0 -55
  294. package/cpp/rnwgpu/api/descriptors/GPUQueueDescriptor.h +0 -43
  295. package/cpp/rnwgpu/api/descriptors/GPURenderBundleDescriptor.h +0 -45
  296. package/cpp/rnwgpu/api/descriptors/GPURenderBundleEncoderDescriptor.h +0 -80
  297. package/cpp/rnwgpu/api/descriptors/GPURenderPassColorAttachment.h +0 -81
  298. package/cpp/rnwgpu/api/descriptors/GPURenderPassDepthStencilAttachment.h +0 -101
  299. package/cpp/rnwgpu/api/descriptors/GPURenderPassDescriptor.h +0 -92
  300. package/cpp/rnwgpu/api/descriptors/GPURenderPassTimestampWrites.h +0 -58
  301. package/cpp/rnwgpu/api/descriptors/GPURenderPipelineDescriptor.h +0 -103
  302. package/cpp/rnwgpu/api/descriptors/GPURequestAdapterOptions.h +0 -51
  303. package/cpp/rnwgpu/api/descriptors/GPUSamplerBindingLayout.h +0 -45
  304. package/cpp/rnwgpu/api/descriptors/GPUSamplerDescriptor.h +0 -110
  305. package/cpp/rnwgpu/api/descriptors/GPUShaderModuleCompilationHint.h +0 -60
  306. package/cpp/rnwgpu/api/descriptors/GPUShaderModuleDescriptor.h +0 -62
  307. package/cpp/rnwgpu/api/descriptors/GPUShaderStage.h +0 -25
  308. package/cpp/rnwgpu/api/descriptors/GPUSharedFenceDescriptor.h +0 -58
  309. package/cpp/rnwgpu/api/descriptors/GPUSharedFenceState.h +0 -51
  310. package/cpp/rnwgpu/api/descriptors/GPUSharedTextureMemoryDescriptor.h +0 -73
  311. package/cpp/rnwgpu/api/descriptors/GPUStencilFaceState.h +0 -64
  312. package/cpp/rnwgpu/api/descriptors/GPUStorageTextureBindingLayout.h +0 -59
  313. package/cpp/rnwgpu/api/descriptors/GPUTextureBindingLayout.h +0 -59
  314. package/cpp/rnwgpu/api/descriptors/GPUTextureDescriptor.h +0 -91
  315. package/cpp/rnwgpu/api/descriptors/GPUTextureUsage.h +0 -29
  316. package/cpp/rnwgpu/api/descriptors/GPUTextureViewDescriptor.h +0 -91
  317. package/cpp/rnwgpu/api/descriptors/GPUUncapturedErrorEventInit.h +0 -64
  318. package/cpp/rnwgpu/api/descriptors/GPUVertexAttribute.h +0 -53
  319. package/cpp/rnwgpu/api/descriptors/GPUVertexBufferLayout.h +0 -62
  320. package/cpp/rnwgpu/api/descriptors/GPUVertexState.h +0 -73
  321. package/cpp/rnwgpu/api/descriptors/Unions.h +0 -1969
  322. package/cpp/rnwgpu/async/AsyncTaskHandle.cpp +0 -214
  323. package/cpp/rnwgpu/async/AsyncTaskHandle.h +0 -58
  324. package/cpp/rnwgpu/async/RuntimeContext.cpp +0 -199
  325. package/cpp/rnwgpu/async/RuntimeContext.h +0 -134
  326. package/lib/commonjs/skia/types/WebGPU.d.ts +0 -184
  327. package/lib/commonjs/skia/types/WebGPU.js +0 -105
  328. package/lib/commonjs/skia/types/WebGPU.js.map +0 -1
  329. package/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +0 -8
  330. package/lib/commonjs/specs/WebGPUViewNativeComponent.js +0 -10
  331. package/lib/commonjs/specs/WebGPUViewNativeComponent.js.map +0 -1
  332. package/lib/commonjs/specs/WebGPUViewNativeComponent.web.d.ts +0 -8
  333. package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js +0 -103
  334. package/lib/commonjs/specs/WebGPUViewNativeComponent.web.js.map +0 -1
  335. package/lib/commonjs/specs/utils.d.ts +0 -1
  336. package/lib/commonjs/specs/utils.js +0 -11
  337. package/lib/commonjs/specs/utils.js.map +0 -1
  338. package/lib/commonjs/views/WebGPUCanvas.d.ts +0 -33
  339. package/lib/commonjs/views/WebGPUCanvas.js +0 -79
  340. package/lib/commonjs/views/WebGPUCanvas.js.map +0 -1
  341. package/lib/commonjs/views/WebGPUCanvas.web.d.ts +0 -23
  342. package/lib/commonjs/views/WebGPUCanvas.web.js +0 -20
  343. package/lib/commonjs/views/WebGPUCanvas.web.js.map +0 -1
  344. package/lib/module/skia/types/WebGPU.d.ts +0 -184
  345. package/lib/module/skia/types/WebGPU.js +0 -99
  346. package/lib/module/skia/types/WebGPU.js.map +0 -1
  347. package/lib/module/specs/WebGPUViewNativeComponent.d.ts +0 -8
  348. package/lib/module/specs/WebGPUViewNativeComponent.js +0 -4
  349. package/lib/module/specs/WebGPUViewNativeComponent.js.map +0 -1
  350. package/lib/module/specs/WebGPUViewNativeComponent.web.d.ts +0 -8
  351. package/lib/module/specs/WebGPUViewNativeComponent.web.js +0 -96
  352. package/lib/module/specs/WebGPUViewNativeComponent.web.js.map +0 -1
  353. package/lib/module/specs/utils.d.ts +0 -1
  354. package/lib/module/specs/utils.js +0 -5
  355. package/lib/module/specs/utils.js.map +0 -1
  356. package/lib/module/views/WebGPUCanvas.d.ts +0 -33
  357. package/lib/module/views/WebGPUCanvas.js +0 -70
  358. package/lib/module/views/WebGPUCanvas.js.map +0 -1
  359. package/lib/module/views/WebGPUCanvas.web.d.ts +0 -23
  360. package/lib/module/views/WebGPUCanvas.web.js +0 -12
  361. package/lib/module/views/WebGPUCanvas.web.js.map +0 -1
  362. package/lib/typescript/lib/commonjs/skia/types/WebGPU.d.ts +0 -2
  363. package/lib/typescript/lib/commonjs/specs/WebGPUViewNativeComponent.d.ts +0 -4
  364. package/lib/typescript/lib/commonjs/specs/WebGPUViewNativeComponent.web.d.ts +0 -3
  365. package/lib/typescript/lib/commonjs/specs/utils.d.ts +0 -2
  366. package/lib/typescript/lib/commonjs/views/WebGPUCanvas.d.ts +0 -6
  367. package/lib/typescript/lib/commonjs/views/WebGPUCanvas.web.d.ts +0 -6
  368. package/lib/typescript/lib/module/skia/types/WebGPU.d.ts +0 -31
  369. package/lib/typescript/lib/module/specs/WebGPUViewNativeComponent.d.ts +0 -2
  370. package/lib/typescript/lib/module/specs/WebGPUViewNativeComponent.web.d.ts +0 -2
  371. package/lib/typescript/lib/module/specs/utils.d.ts +0 -1
  372. package/lib/typescript/lib/module/views/WebGPUCanvas.d.ts +0 -7
  373. package/lib/typescript/lib/module/views/WebGPUCanvas.web.d.ts +0 -8
  374. package/lib/typescript/src/skia/types/WebGPU.d.ts +0 -184
  375. package/lib/typescript/src/specs/WebGPUViewNativeComponent.d.ts +0 -8
  376. package/lib/typescript/src/specs/WebGPUViewNativeComponent.web.d.ts +0 -8
  377. package/lib/typescript/src/specs/utils.d.ts +0 -1
  378. package/lib/typescript/src/views/WebGPUCanvas.d.ts +0 -33
  379. package/lib/typescript/src/views/WebGPUCanvas.web.d.ts +0 -23
  380. package/src/skia/types/WebGPU.ts +0 -226
  381. package/src/specs/WebGPUViewNativeComponent.ts +0 -11
  382. package/src/specs/WebGPUViewNativeComponent.web.ts +0 -110
  383. package/src/specs/utils.ts +0 -4
  384. package/src/views/WebGPUCanvas.tsx +0 -125
  385. package/src/views/WebGPUCanvas.web.tsx +0 -36
  386. /package/cpp/{jsi2 → jsi}/Promise.cpp +0 -0
  387. /package/cpp/{jsi2 → jsi}/Promise.h +0 -0
@@ -1,136 +0,0 @@
1
- #import "WebGPUMetalView.h"
2
-
3
- #ifdef SK_GRAPHITE
4
-
5
- #import "webgpu/webgpu_cpp.h"
6
- #import <QuartzCore/CAMetalLayer.h>
7
-
8
- #import <ReactCommon/CallInvoker.h>
9
-
10
- #import "rnskia/RNDawnContext.h"
11
- #import "rnwgpu/SurfaceRegistry.h"
12
- #import "rnwgpu/async/RuntimeContext.h"
13
-
14
- namespace {
15
- // Applies a surface attach latched by the platform UI thread (see
16
- // SurfaceInfo::applyPendingAttach) from the JS thread. Surface attaches are
17
- // normally adopted at the next frame boundary by whichever thread renders;
18
- // this flush covers contexts that are not actively rendering (static
19
- // content), so the last offscreen frame still makes it on screen. Mirrors
20
- // react-native-webgpu's RNWebGPUManager::flushPendingSurfaceTransition.
21
- void flushPendingSurfaceTransition(std::shared_ptr<rnwgpu::SurfaceInfo> info) {
22
- if (info == nullptr) {
23
- return;
24
- }
25
- auto invoker = rnwgpu::async::RuntimeContext::mainCallInvoker();
26
- if (invoker == nullptr) {
27
- return;
28
- }
29
- invoker->invokeAsync([info = std::move(info)] { info->applyPendingAttach(); });
30
- }
31
- } // namespace
32
-
33
- @implementation WebGPUMetalView {
34
- BOOL _isConfigured;
35
- }
36
-
37
- #if !TARGET_OS_OSX
38
- + (Class)layerClass {
39
- return [CAMetalLayer class];
40
- }
41
- #else // !TARGET_OS_OSX
42
- - (instancetype)init {
43
- self = [super init];
44
- if (self) {
45
- self.wantsLayer = true;
46
- self.layer = [CAMetalLayer layer];
47
- }
48
- return self;
49
- }
50
- #endif // !TARGET_OS_OSX
51
-
52
- - (void)configure {
53
- auto size = self.frame.size;
54
- // Retain the layer for as long as SurfaceInfo holds the pointer: the
55
- // latched attach (and the flush lambda that adopts it) can outlive this
56
- // view, e.g. across a dev reload where the registry is cleared before
57
- // dealloc runs. Balanced by the releaser below.
58
- void *nativeSurface = (void *)CFBridgingRetain(self.layer);
59
- auto &registry = rnwgpu::SurfaceRegistry::getInstance();
60
- auto &dawnContext = RNSkia::DawnContext::getInstance();
61
- auto gpu = dawnContext.getWGPUInstance();
62
-
63
- // Create the surface using Dawn's API directly
64
- wgpu::SurfaceSourceMetalLayer metalSurfaceDesc;
65
- metalSurfaceDesc.layer = nativeSurface;
66
- wgpu::SurfaceDescriptor surfaceDescriptor;
67
- surfaceDescriptor.nextInChain = &metalSurfaceDesc;
68
- auto surface = gpu.CreateSurface(&surfaceDescriptor);
69
-
70
- // Find-or-create + attach runs atomically under the registry lock so a
71
- // concurrent destroyContext cannot orphan this surface.
72
- auto info = registry.attachSurface(
73
- [_contextId intValue], gpu, size.width, size.height, nativeSurface,
74
- surface, [](void *layer) {
75
- // The releaser can run on the rendering thread; CALayer teardown
76
- // belongs on the main thread.
77
- dispatch_async(dispatch_get_main_queue(), ^{
78
- CFBridgingRelease(layer);
79
- });
80
- });
81
- // The attach is adopted at the next frame boundary by the rendering thread;
82
- // schedule a flush so contexts that are not currently rendering still pick
83
- // it up (and present their last offscreen frame).
84
- flushPendingSurfaceTransition(info);
85
- }
86
-
87
- - (void)update {
88
- auto size = self.frame.size;
89
- auto &registry = rnwgpu::SurfaceRegistry::getInstance();
90
- auto surfaceInfo = registry.getSurfaceInfo([_contextId intValue]);
91
- if (surfaceInfo) {
92
- surfaceInfo->resize(size.width, size.height);
93
- }
94
- }
95
-
96
- - (void)dealloc {
97
- // The view dies with its Canvas (contextIds are never reused), so view
98
- // teardown retires the registry entry. The JS-side cleanup
99
- // (RNWebGPU.destroyContext) only handles entries that never had a native
100
- // surface; see RNWebGPU::destroyContext for the ownership split.
101
- auto &registry = rnwgpu::SurfaceRegistry::getInstance();
102
- if (auto info = registry.getSurfaceInfo([_contextId intValue])) {
103
- info->detachSurface();
104
- }
105
- registry.removeSurfaceInfo([_contextId intValue]);
106
- }
107
-
108
- @end
109
-
110
- #else // SK_GRAPHITE
111
-
112
- // Stub implementation when GRAPHITE is not enabled
113
- @implementation WebGPUMetalView
114
-
115
- #if !TARGET_OS_OSX
116
- + (Class)layerClass {
117
- return [CAMetalLayer class];
118
- }
119
- #else // !TARGET_OS_OSX
120
- - (instancetype)init {
121
- self = [super init];
122
- return self;
123
- }
124
- #endif // !TARGET_OS_OSX
125
-
126
- - (void)configure {
127
- // No-op when GRAPHITE is not enabled
128
- }
129
-
130
- - (void)update {
131
- // No-op when GRAPHITE is not enabled
132
- }
133
-
134
- @end
135
-
136
- #endif // SK_GRAPHITE
@@ -1,257 +0,0 @@
1
- #pragma once
2
-
3
- #include <algorithm>
4
- #include <memory>
5
- #include <string>
6
- #include <utility>
7
-
8
- #include "jsi/JsiHostObject.h"
9
- #include "utils/RNSkLog.h"
10
- #include "rnskia/RNSkPlatformContext.h"
11
-
12
- namespace RNSkia {
13
-
14
- namespace jsi = facebook::jsi;
15
-
16
- // Minimum memory pressure reported for any host object.
17
- // This accounts for C++ wrapper overhead and ensures dispose() never
18
- // increases reported memory pressure (which would defeat its purpose).
19
- static constexpr size_t kMinMemoryPressure = 256;
20
-
21
- /**
22
- * Base class for jsi host objects - these are all implemented as JsiHostObjects
23
- * and has a pointer to the platform context.
24
- */
25
- class JsiSkHostObject : public RNJsi::JsiHostObject {
26
- public:
27
- /**
28
- * Default constructor
29
- * @param context Platform context
30
- */
31
- explicit JsiSkHostObject(std::shared_ptr<RNSkPlatformContext> context)
32
- : _context(context) {}
33
-
34
- /**
35
- * Override this method to return the memory pressure for the wrapped object.
36
- * @return The memory pressure in bytes
37
- */
38
- virtual size_t getMemoryPressure() const = 0;
39
-
40
- /**
41
- * Returns the type name of the host object.
42
- */
43
- virtual std::string getObjectType() const = 0;
44
-
45
- protected:
46
- /**
47
- * @return A pointer to the platform context
48
- */
49
- std::shared_ptr<RNSkPlatformContext> getContext() { return _context; }
50
-
51
- private:
52
- std::shared_ptr<RNSkPlatformContext> _context;
53
- };
54
-
55
- #define JSI_API_TYPENAME(A) \
56
- JSI_PROPERTY_GET(__typename__) { \
57
- return jsi::String::createFromUtf8(runtime, #A); \
58
- }
59
-
60
- #define EXPORT_JSI_API_TYPENAME(CLASS, TYPENAME) \
61
- JSI_API_TYPENAME(TYPENAME) \
62
- JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(CLASS, __typename__))
63
-
64
- // Define this macro to enable memory pressure debug logging
65
- // #define RNSKIA_DEBUG_MEMORY_PRESSURE
66
-
67
- #ifdef RNSKIA_DEBUG_MEMORY_PRESSURE
68
- // Version with debug logging
69
- #define JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE( \
70
- runtime, hostObjectInstance, context) \
71
- [&]() { \
72
- auto result = \
73
- jsi::Object::createFromHostObject(runtime, hostObjectInstance); \
74
- auto memoryPressure = hostObjectInstance->getMemoryPressure(); \
75
- const void *hostObjectId = \
76
- static_cast<const void *>(hostObjectInstance.get()); \
77
- const char *mpUnit = "bytes"; \
78
- double mpValue = static_cast<double>(memoryPressure); \
79
- if (memoryPressure >= 1024ULL * 1024ULL) { \
80
- mpUnit = "MB"; \
81
- mpValue /= (1024.0 * 1024.0); \
82
- RNSkLogger::logToConsole( \
83
- "Host object %s (id=%p) memory pressure %.2f %s", \
84
- hostObjectInstance->getObjectType().c_str(), hostObjectId, mpValue, \
85
- mpUnit); \
86
- } else if (memoryPressure >= 1024ULL) { \
87
- mpUnit = "KB"; \
88
- mpValue /= 1024.0; \
89
- RNSkLogger::logToConsole( \
90
- "Host object %s (id=%p) memory pressure %.2f %s", \
91
- hostObjectInstance->getObjectType().c_str(), hostObjectId, mpValue, \
92
- mpUnit); \
93
- } else { \
94
- RNSkLogger::logToConsole( \
95
- "Host object %s (id=%p) memory pressure %zu %s", \
96
- hostObjectInstance->getObjectType().c_str(), hostObjectId, \
97
- memoryPressure, mpUnit); \
98
- } \
99
- if (memoryPressure > 0) { \
100
- result.setExternalMemoryPressure(runtime, memoryPressure); \
101
- } \
102
- return result; \
103
- }()
104
- #else
105
- // Version without debug logging (optimized)
106
- #define JSI_CREATE_HOST_OBJECT_WITH_MEMORY_PRESSURE( \
107
- runtime, hostObjectInstance, context) \
108
- [&]() { \
109
- auto result = \
110
- jsi::Object::createFromHostObject(runtime, hostObjectInstance); \
111
- auto memoryPressure = hostObjectInstance->getMemoryPressure(); \
112
- if (memoryPressure > 0) { \
113
- result.setExternalMemoryPressure(runtime, memoryPressure); \
114
- } \
115
- return result; \
116
- }()
117
- #endif
118
-
119
- template <typename T> class JsiSkWrappingHostObject : public JsiSkHostObject {
120
- public:
121
- /**
122
- * Default constructor
123
- * @param context Platform context
124
- */
125
- JsiSkWrappingHostObject(std::shared_ptr<RNSkPlatformContext> context,
126
- T object)
127
- : JsiSkHostObject(std::move(context)), _object(std::move(object)) {}
128
-
129
- /**
130
- * Returns the underlying object exposed by this host object. This object
131
- * should be wrapped in a shared pointer of some kind.
132
- * Throws if the object has been disposed.
133
- * @return Underlying object
134
- */
135
- T getObject() { return validateObject(); }
136
- const T getObject() const { return validateObject(); }
137
-
138
- /**
139
- * Updates the inner object with a new version of the object.
140
- */
141
- void setObject(T object) { _object = object; }
142
-
143
- /**
144
- * Dispose function that can be exposed to JS by using the JSI_API_TYPENAME
145
- * macro.
146
- */
147
- JSI_HOST_FUNCTION(dispose) {
148
- if (!isDisposed()) {
149
- thisValue.asObject(runtime).setExternalMemoryPressure(runtime,
150
- kMinMemoryPressure);
151
- }
152
- safeDispose();
153
- return jsi::Value::undefined();
154
- }
155
-
156
- protected:
157
- /**
158
- * Override to implement disposal of allocated resources like smart pointers.
159
- * This method will only be called once for each instance of this class.
160
- */
161
- virtual void releaseResources() = 0;
162
-
163
- /**
164
- * Returns true if the object has been disposed.
165
- */
166
- bool isDisposed() const {
167
- return _isDisposed.load(std::memory_order_acquire);
168
- }
169
-
170
- /**
171
- * Returns the underlying object without checking if disposed.
172
- * Use this in destructors and releaseResources() where we need to access
173
- * the object even after dispose() was called.
174
- */
175
- T getObjectUnchecked() const { return _object; }
176
-
177
- private:
178
- /**
179
- * Validates that _object was not disposed and returns it.
180
- */
181
- T validateObject() const {
182
- if (_isDisposed.load(std::memory_order_acquire)) {
183
- throw std::runtime_error("Attempted to access a disposed object.");
184
- }
185
- return _object;
186
- }
187
-
188
- void safeDispose() {
189
- bool expected = false;
190
- if (_isDisposed.compare_exchange_strong(expected, true,
191
- std::memory_order_acq_rel)) {
192
- releaseResources();
193
- }
194
- }
195
-
196
- /**
197
- * Wrapped object.
198
- */
199
- T _object;
200
-
201
- /**
202
- * Resource disposed flag.
203
- */
204
- std::atomic<bool> _isDisposed = {false};
205
- };
206
-
207
- template <typename T>
208
- class JsiSkWrappingSharedPtrHostObject
209
- : public JsiSkWrappingHostObject<std::shared_ptr<T>> {
210
- public:
211
- JsiSkWrappingSharedPtrHostObject(std::shared_ptr<RNSkPlatformContext> context,
212
- std::shared_ptr<T> object)
213
- : JsiSkWrappingHostObject<std::shared_ptr<T>>(std::move(context),
214
- std::move(object)) {}
215
-
216
- /**
217
- Returns the underlying object from a host object of this type
218
- */
219
- static std::shared_ptr<T> fromValue(jsi::Runtime &runtime,
220
- const jsi::Value &obj) {
221
- return std::static_pointer_cast<JsiSkWrappingSharedPtrHostObject>(
222
- obj.asObject(runtime).asHostObject(runtime))
223
- ->getObject();
224
- }
225
-
226
- protected:
227
- void releaseResources() override {
228
- // Clear internally allocated objects
229
- this->setObject(nullptr);
230
- }
231
- };
232
-
233
- template <typename T>
234
- class JsiSkWrappingSkPtrHostObject : public JsiSkWrappingHostObject<sk_sp<T>> {
235
- public:
236
- JsiSkWrappingSkPtrHostObject(std::shared_ptr<RNSkPlatformContext> context,
237
- sk_sp<T> object)
238
- : JsiSkWrappingHostObject<sk_sp<T>>(std::move(context),
239
- std::move(object)) {}
240
-
241
- /**
242
- Returns the underlying object from a host object of this type
243
- */
244
- static sk_sp<T> fromValue(jsi::Runtime &runtime, const jsi::Value &obj) {
245
- return std::static_pointer_cast<JsiSkWrappingSkPtrHostObject>(
246
- obj.asObject(runtime).asHostObject(runtime))
247
- ->getObject();
248
- }
249
-
250
- protected:
251
- void releaseResources() override {
252
- // Clear internally allocated objects
253
- this->setObject(nullptr);
254
- }
255
- };
256
-
257
- } // namespace RNSkia
@@ -1,137 +0,0 @@
1
- #include "JsiHostObject.h"
2
- #include <functional>
3
- #include <vector>
4
-
5
- namespace RNJsi {
6
-
7
- void JsiHostObject::set(jsi::Runtime &rt, const jsi::PropNameID &name,
8
- const jsi::Value &value) {
9
-
10
- auto nameStr = name.utf8(rt);
11
-
12
- /** Check the static setters map */
13
- const JsiPropertySettersMap &setters = getExportedPropertySettersMap();
14
- auto setter = setters.find(nameStr);
15
- if (setter != setters.end()) {
16
- auto dispatcher = std::bind(setter->second, this, std::placeholders::_1,
17
- std::placeholders::_2);
18
- return dispatcher(rt, value);
19
- }
20
-
21
- if (_propMap.count(nameStr) > 0) {
22
- auto prop = _propMap.at(nameStr);
23
- (prop.set)(rt, value);
24
- }
25
- }
26
-
27
- jsi::Value JsiHostObject::get(jsi::Runtime &runtime,
28
- const jsi::PropNameID &name) {
29
- auto nameStr = name.utf8(runtime);
30
-
31
- // Happy path - cached host functions are cheapest to look up
32
- const JsiFunctionMap &funcs = getExportedFunctionMap();
33
- auto func = funcs.find(nameStr);
34
-
35
- // Check function cache
36
- if (func != funcs.end()) {
37
- std::map<std::string, jsi::Function> &runtimeCache =
38
- _hostFunctionCache.get(runtime);
39
- auto cachedFunc = runtimeCache.find(nameStr);
40
- if (cachedFunc != runtimeCache.end()) {
41
- return cachedFunc->second.asFunction(runtime);
42
- }
43
- }
44
-
45
- // Check the static getters map
46
- const JsiPropertyGettersMap &getters = getExportedPropertyGettersMap();
47
- auto getter = getters.find(nameStr);
48
- if (getter != getters.end()) {
49
- auto dispatcher = std::bind(getter->second, this, std::placeholders::_1);
50
- return dispatcher(runtime);
51
- }
52
-
53
- // Check the static function map
54
- if (func != funcs.end()) {
55
-
56
- // Create dispatcher
57
- auto dispatcher =
58
- std::bind(func->second, reinterpret_cast<JsiHostObject *>(this),
59
- std::placeholders::_1, std::placeholders::_2,
60
- std::placeholders::_3, std::placeholders::_4);
61
-
62
- // Add to cache - it is important to cache the results from the
63
- // createFromHostFunction function which takes some time.
64
- return _hostFunctionCache.get(runtime)
65
- .emplace(nameStr, jsi::Function::createFromHostFunction(runtime, name,
66
- 0, dispatcher))
67
- .first->second.asFunction(runtime);
68
- }
69
-
70
- if (_funcMap.count(nameStr) > 0) {
71
- return jsi::Function::createFromHostFunction(runtime, name, 0,
72
- _funcMap.at(nameStr));
73
- }
74
-
75
- if (_propMap.count(nameStr) > 0) {
76
- auto prop = _propMap.at(nameStr);
77
- return (prop.get)(runtime);
78
- }
79
-
80
- // Check for dispose symbol as last resort
81
- static const auto disposeSymbol = jsi::PropNameID::forSymbol(
82
- runtime,
83
- runtime.global()
84
- .getPropertyAsObject(runtime, "Symbol")
85
- .getPropertyAsFunction(runtime, "for")
86
- .call(runtime, "Symbol.dispose")
87
- .getSymbol(runtime));
88
- if (jsi::PropNameID::compare(runtime, disposeSymbol, name)) {
89
- // Recursively call get with "dispose" string
90
- auto disposeName = jsi::PropNameID::forAscii(runtime, "dispose");
91
- return get(runtime, disposeName);
92
- }
93
-
94
- return jsi::Value::undefined();
95
- }
96
-
97
- std::vector<jsi::PropNameID>
98
- JsiHostObject::getPropertyNames(jsi::Runtime &runtime) {
99
- // statically exported functions
100
- const auto &funcs = getExportedFunctionMap();
101
-
102
- // Statically exported property getters
103
- const auto &getters = getExportedPropertyGettersMap();
104
-
105
- // Statically exported property setters
106
- const auto &setters = getExportedPropertySettersMap();
107
-
108
- std::vector<jsi::PropNameID> propNames;
109
- propNames.reserve(funcs.size() + getters.size() + setters.size() +
110
- _funcMap.size() + _propMap.size());
111
-
112
- for (auto it = funcs.cbegin(); it != funcs.cend(); ++it) {
113
- propNames.push_back(jsi::PropNameID::forAscii(runtime, it->first));
114
- }
115
-
116
- for (auto it = getters.cbegin(); it != getters.cend(); ++it) {
117
- propNames.push_back(jsi::PropNameID::forUtf8(runtime, it->first));
118
- }
119
-
120
- for (auto it = getters.cbegin(); it != getters.cend(); ++it) {
121
- if (getters.count(it->first) == 0) {
122
- propNames.push_back(jsi::PropNameID::forUtf8(runtime, it->first));
123
- }
124
- }
125
-
126
- // functions
127
- for (auto it = _funcMap.cbegin(); it != _funcMap.cend(); ++it) {
128
- propNames.push_back(jsi::PropNameID::forAscii(runtime, it->first));
129
- }
130
- // props
131
- for (auto it = _propMap.cbegin(); it != _propMap.cend(); ++it) {
132
- propNames.push_back(jsi::PropNameID::forAscii(runtime, it->first));
133
- }
134
- return propNames;
135
- }
136
-
137
- } // namespace RNJsi