@shopify/react-native-skia 2.6.9 → 2.8.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 (247) hide show
  1. package/android/cpp/jni/include/JniSkiaBaseView.h +6 -4
  2. package/android/cpp/jni/include/JniSkiaPictureView.h +8 -6
  3. package/android/cpp/rnskia-android/OpenGLContext.h +10 -1
  4. package/android/cpp/rnskia-android/RNSkAndroidView.h +8 -8
  5. package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +9 -5
  6. package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.h +4 -2
  7. package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseView.java +48 -12
  8. package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseViewManager.java +5 -0
  9. package/android/src/main/java/com/shopify/reactnative/skia/SkiaPictureView.java +2 -2
  10. package/android/src/main/java/com/shopify/reactnative/skia/ViewScreenshotService.java +11 -7
  11. package/apple/MetalContext.h +7 -6
  12. package/apple/MetalLayerColorSpace.mm +39 -0
  13. package/apple/MetalLayerColorSpaceUtils.h +34 -0
  14. package/apple/MetalWindowContext.h +3 -1
  15. package/apple/MetalWindowContext.mm +9 -8
  16. package/apple/RNSkAppleView.h +6 -0
  17. package/apple/RNSkMetalCanvasProvider.h +2 -0
  18. package/apple/RNSkMetalCanvasProvider.mm +15 -2
  19. package/apple/SkiaPictureView.mm +1 -0
  20. package/apple/SkiaPictureViewManager.mm +5 -0
  21. package/apple/SkiaUIView.h +1 -0
  22. package/apple/SkiaUIView.mm +9 -0
  23. package/cpp/api/JsiSkParagraph.h +114 -0
  24. package/cpp/api/JsiSkSurface.h +8 -2
  25. package/cpp/rnskia/RNDawnContext.h +4 -3
  26. package/cpp/rnskia/RNDawnUtils.h +25 -6
  27. package/cpp/rnskia/RNDawnWindowContext.h +44 -10
  28. package/cpp/rnskia/RNMetalLayerColorSpace.h +16 -0
  29. package/cpp/rnskia/RNSkJsiViewApi.h +46 -24
  30. package/cpp/rnwgpu/SurfaceRegistry.h +10 -4
  31. package/lib/commonjs/Platform/Platform.web.js +2 -90
  32. package/lib/commonjs/Platform/Platform.web.js.map +1 -1
  33. package/lib/commonjs/external/reanimated/useVideoLoading.js +11 -2
  34. package/lib/commonjs/external/reanimated/useVideoLoading.js.map +1 -1
  35. package/lib/commonjs/mock/index.js +1 -0
  36. package/lib/commonjs/mock/index.js.map +1 -1
  37. package/lib/commonjs/renderer/Canvas.d.ts +10 -1
  38. package/lib/commonjs/renderer/Canvas.js +2 -0
  39. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  40. package/lib/commonjs/skia/core/SVG.web.js +4 -5
  41. package/lib/commonjs/skia/core/SVG.web.js.map +1 -1
  42. package/lib/commonjs/skia/types/Paragraph/Paragraph.d.ts +62 -0
  43. package/lib/commonjs/skia/types/Paragraph/Paragraph.js.map +1 -1
  44. package/lib/commonjs/skia/types/Surface/Surface.d.ts +5 -1
  45. package/lib/commonjs/skia/types/Surface/Surface.js.map +1 -1
  46. package/lib/commonjs/skia/web/Host.js +7 -0
  47. package/lib/commonjs/skia/web/Host.js.map +1 -1
  48. package/lib/commonjs/skia/web/JsiSkPaint.js +5 -0
  49. package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
  50. package/lib/commonjs/skia/web/JsiSkParagraph.d.ts +3 -1
  51. package/lib/commonjs/skia/web/JsiSkParagraph.js +6 -0
  52. package/lib/commonjs/skia/web/JsiSkParagraph.js.map +1 -1
  53. package/lib/commonjs/skia/web/JsiSkParagraphStyle.js +14 -3
  54. package/lib/commonjs/skia/web/JsiSkParagraphStyle.js.map +1 -1
  55. package/lib/commonjs/skia/web/JsiSkSurface.d.ts +1 -1
  56. package/lib/commonjs/skia/web/JsiSkSurface.js +2 -1
  57. package/lib/commonjs/skia/web/JsiSkSurface.js.map +1 -1
  58. package/lib/commonjs/sksg/Container.native.d.ts +1 -0
  59. package/lib/commonjs/sksg/Container.native.js +11 -0
  60. package/lib/commonjs/sksg/Container.native.js.map +1 -1
  61. package/lib/commonjs/sksg/Container.web.d.ts +1 -0
  62. package/lib/commonjs/sksg/Container.web.js +45 -3
  63. package/lib/commonjs/sksg/Container.web.js.map +1 -1
  64. package/lib/commonjs/sksg/Recorder/DrawingContext.d.ts +2 -0
  65. package/lib/commonjs/sksg/Recorder/DrawingContext.js +22 -6
  66. package/lib/commonjs/sksg/Recorder/DrawingContext.js.map +1 -1
  67. package/lib/commonjs/sksg/Recorder/FrameScope.d.ts +18 -0
  68. package/lib/commonjs/sksg/Recorder/FrameScope.js +66 -0
  69. package/lib/commonjs/sksg/Recorder/FrameScope.js.map +1 -0
  70. package/lib/commonjs/sksg/Recorder/FrameScope.native.d.ts +10 -0
  71. package/lib/commonjs/sksg/Recorder/FrameScope.native.js +26 -0
  72. package/lib/commonjs/sksg/Recorder/FrameScope.native.js.map +1 -0
  73. package/lib/commonjs/sksg/Recorder/Player.js +1 -2
  74. package/lib/commonjs/sksg/Recorder/Player.js.map +1 -1
  75. package/lib/commonjs/sksg/Recorder/Recorder.d.ts +3 -1
  76. package/lib/commonjs/sksg/Recorder/Recorder.js +12 -1
  77. package/lib/commonjs/sksg/Recorder/Recorder.js.map +1 -1
  78. package/lib/commonjs/sksg/Recorder/commands/Drawing.js +3 -3
  79. package/lib/commonjs/sksg/Recorder/commands/Drawing.js.map +1 -1
  80. package/lib/commonjs/sksg/Recorder/commands/Shaders.js +3 -3
  81. package/lib/commonjs/sksg/Recorder/commands/Shaders.js.map +1 -1
  82. package/lib/commonjs/sksg/StaticContainer.d.ts +1 -0
  83. package/lib/commonjs/sksg/StaticContainer.js +27 -1
  84. package/lib/commonjs/sksg/StaticContainer.js.map +1 -1
  85. package/lib/commonjs/specs/NativeSkiaModule.web.d.ts +2 -0
  86. package/lib/commonjs/specs/NativeSkiaModule.web.js +32 -7
  87. package/lib/commonjs/specs/NativeSkiaModule.web.js.map +1 -1
  88. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.d.ts +1 -0
  89. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js.map +1 -1
  90. package/lib/commonjs/views/SkiaPictureView.js +2 -0
  91. package/lib/commonjs/views/SkiaPictureView.js.map +1 -1
  92. package/lib/commonjs/views/SkiaPictureView.web.js +279 -94
  93. package/lib/commonjs/views/SkiaPictureView.web.js.map +1 -1
  94. package/lib/commonjs/views/formats.d.ts +1 -0
  95. package/lib/commonjs/views/formats.js +28 -0
  96. package/lib/commonjs/views/formats.js.map +1 -0
  97. package/lib/commonjs/views/index.d.ts +1 -0
  98. package/lib/commonjs/views/index.js +11 -0
  99. package/lib/commonjs/views/index.js.map +1 -1
  100. package/lib/commonjs/views/types.d.ts +6 -0
  101. package/lib/commonjs/views/types.js.map +1 -1
  102. package/lib/module/Platform/Platform.web.js +3 -91
  103. package/lib/module/Platform/Platform.web.js.map +1 -1
  104. package/lib/module/external/reanimated/useVideoLoading.js +12 -2
  105. package/lib/module/external/reanimated/useVideoLoading.js.map +1 -1
  106. package/lib/module/mock/index.js +1 -0
  107. package/lib/module/mock/index.js.map +1 -1
  108. package/lib/module/renderer/Canvas.d.ts +10 -1
  109. package/lib/module/renderer/Canvas.js +2 -0
  110. package/lib/module/renderer/Canvas.js.map +1 -1
  111. package/lib/module/skia/core/SVG.web.js +4 -5
  112. package/lib/module/skia/core/SVG.web.js.map +1 -1
  113. package/lib/module/skia/types/Paragraph/Paragraph.d.ts +62 -0
  114. package/lib/module/skia/types/Paragraph/Paragraph.js.map +1 -1
  115. package/lib/module/skia/types/Surface/Surface.d.ts +5 -1
  116. package/lib/module/skia/types/Surface/Surface.js.map +1 -1
  117. package/lib/module/skia/web/Host.js +7 -0
  118. package/lib/module/skia/web/Host.js.map +1 -1
  119. package/lib/module/skia/web/JsiSkPaint.js +5 -0
  120. package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
  121. package/lib/module/skia/web/JsiSkParagraph.d.ts +3 -1
  122. package/lib/module/skia/web/JsiSkParagraph.js +7 -1
  123. package/lib/module/skia/web/JsiSkParagraph.js.map +1 -1
  124. package/lib/module/skia/web/JsiSkParagraphStyle.js +14 -3
  125. package/lib/module/skia/web/JsiSkParagraphStyle.js.map +1 -1
  126. package/lib/module/skia/web/JsiSkSurface.d.ts +1 -1
  127. package/lib/module/skia/web/JsiSkSurface.js +2 -1
  128. package/lib/module/skia/web/JsiSkSurface.js.map +1 -1
  129. package/lib/module/sksg/Container.native.d.ts +1 -0
  130. package/lib/module/sksg/Container.native.js +11 -0
  131. package/lib/module/sksg/Container.native.js.map +1 -1
  132. package/lib/module/sksg/Container.web.d.ts +1 -0
  133. package/lib/module/sksg/Container.web.js +46 -4
  134. package/lib/module/sksg/Container.web.js.map +1 -1
  135. package/lib/module/sksg/Recorder/DrawingContext.d.ts +2 -0
  136. package/lib/module/sksg/Recorder/DrawingContext.js +22 -6
  137. package/lib/module/sksg/Recorder/DrawingContext.js.map +1 -1
  138. package/lib/module/sksg/Recorder/FrameScope.d.ts +18 -0
  139. package/lib/module/sksg/Recorder/FrameScope.js +59 -0
  140. package/lib/module/sksg/Recorder/FrameScope.js.map +1 -0
  141. package/lib/module/sksg/Recorder/FrameScope.native.d.ts +10 -0
  142. package/lib/module/sksg/Recorder/FrameScope.native.js +19 -0
  143. package/lib/module/sksg/Recorder/FrameScope.native.js.map +1 -0
  144. package/lib/module/sksg/Recorder/Player.js +1 -2
  145. package/lib/module/sksg/Recorder/Player.js.map +1 -1
  146. package/lib/module/sksg/Recorder/Recorder.d.ts +3 -1
  147. package/lib/module/sksg/Recorder/Recorder.js +10 -0
  148. package/lib/module/sksg/Recorder/Recorder.js.map +1 -1
  149. package/lib/module/sksg/Recorder/commands/Drawing.js +3 -3
  150. package/lib/module/sksg/Recorder/commands/Drawing.js.map +1 -1
  151. package/lib/module/sksg/Recorder/commands/Shaders.js +3 -3
  152. package/lib/module/sksg/Recorder/commands/Shaders.js.map +1 -1
  153. package/lib/module/sksg/StaticContainer.d.ts +1 -0
  154. package/lib/module/sksg/StaticContainer.js +28 -2
  155. package/lib/module/sksg/StaticContainer.js.map +1 -1
  156. package/lib/module/specs/NativeSkiaModule.web.d.ts +2 -0
  157. package/lib/module/specs/NativeSkiaModule.web.js +32 -7
  158. package/lib/module/specs/NativeSkiaModule.web.js.map +1 -1
  159. package/lib/module/specs/SkiaPictureViewNativeComponent.d.ts +1 -0
  160. package/lib/module/specs/SkiaPictureViewNativeComponent.js.map +1 -1
  161. package/lib/module/views/SkiaPictureView.js +2 -0
  162. package/lib/module/views/SkiaPictureView.js.map +1 -1
  163. package/lib/module/views/SkiaPictureView.web.js +280 -95
  164. package/lib/module/views/SkiaPictureView.web.js.map +1 -1
  165. package/lib/module/views/formats.d.ts +1 -0
  166. package/lib/module/views/formats.js +22 -0
  167. package/lib/module/views/formats.js.map +1 -0
  168. package/lib/module/views/index.d.ts +1 -0
  169. package/lib/module/views/index.js +1 -0
  170. package/lib/module/views/index.js.map +1 -1
  171. package/lib/module/views/types.d.ts +6 -0
  172. package/lib/module/views/types.js.map +1 -1
  173. package/lib/typescript/lib/commonjs/Platform/Platform.web.d.ts +1 -2
  174. package/lib/typescript/lib/commonjs/mock/index.d.ts +1 -0
  175. package/lib/typescript/lib/commonjs/renderer/Canvas.d.ts +2 -1
  176. package/lib/typescript/lib/commonjs/skia/web/JsiSkParagraph.d.ts +2 -0
  177. package/lib/typescript/lib/commonjs/skia/web/JsiSkSurface.d.ts +1 -1
  178. package/lib/typescript/lib/commonjs/sksg/Container.native.d.ts +1 -1
  179. package/lib/typescript/lib/commonjs/sksg/Container.web.d.ts +3 -3
  180. package/lib/typescript/lib/commonjs/sksg/Recorder/DrawingContext.d.ts +2 -0
  181. package/lib/typescript/lib/commonjs/sksg/Recorder/FrameScope.d.ts +17 -0
  182. package/lib/typescript/lib/commonjs/sksg/Recorder/FrameScope.native.d.ts +13 -0
  183. package/lib/typescript/lib/commonjs/sksg/Recorder/Recorder.d.ts +1 -0
  184. package/lib/typescript/lib/commonjs/sksg/StaticContainer.d.ts +2 -2
  185. package/lib/typescript/lib/commonjs/views/formats.d.ts +2 -0
  186. package/lib/typescript/lib/module/Platform/Platform.web.d.ts +1 -3
  187. package/lib/typescript/lib/module/mock/index.d.ts +2 -2
  188. package/lib/typescript/lib/module/renderer/Canvas.d.ts +2 -1
  189. package/lib/typescript/lib/module/skia/web/JsiSkParagraph.d.ts +2 -0
  190. package/lib/typescript/lib/module/skia/web/JsiSkSurface.d.ts +1 -1
  191. package/lib/typescript/lib/module/sksg/Container.native.d.ts +1 -1
  192. package/lib/typescript/lib/module/sksg/Container.web.d.ts +3 -3
  193. package/lib/typescript/lib/module/sksg/Recorder/DrawingContext.d.ts +2 -0
  194. package/lib/typescript/lib/module/sksg/Recorder/FrameScope.d.ts +5 -0
  195. package/lib/typescript/lib/module/sksg/Recorder/FrameScope.native.d.ts +5 -0
  196. package/lib/typescript/lib/module/sksg/Recorder/Recorder.d.ts +1 -0
  197. package/lib/typescript/lib/module/sksg/StaticContainer.d.ts +2 -2
  198. package/lib/typescript/lib/module/views/formats.d.ts +1 -0
  199. package/lib/typescript/lib/module/views/index.d.ts +1 -0
  200. package/lib/typescript/src/renderer/Canvas.d.ts +10 -1
  201. package/lib/typescript/src/skia/types/Paragraph/Paragraph.d.ts +62 -0
  202. package/lib/typescript/src/skia/types/Surface/Surface.d.ts +5 -1
  203. package/lib/typescript/src/skia/web/JsiSkParagraph.d.ts +3 -1
  204. package/lib/typescript/src/skia/web/JsiSkSurface.d.ts +1 -1
  205. package/lib/typescript/src/sksg/Container.native.d.ts +1 -0
  206. package/lib/typescript/src/sksg/Container.web.d.ts +1 -0
  207. package/lib/typescript/src/sksg/Recorder/DrawingContext.d.ts +2 -0
  208. package/lib/typescript/src/sksg/Recorder/FrameScope.d.ts +18 -0
  209. package/lib/typescript/src/sksg/Recorder/FrameScope.native.d.ts +10 -0
  210. package/lib/typescript/src/sksg/Recorder/Recorder.d.ts +3 -1
  211. package/lib/typescript/src/sksg/StaticContainer.d.ts +1 -0
  212. package/lib/typescript/src/specs/NativeSkiaModule.web.d.ts +2 -0
  213. package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.d.ts +1 -0
  214. package/lib/typescript/src/views/formats.d.ts +1 -0
  215. package/lib/typescript/src/views/index.d.ts +1 -0
  216. package/lib/typescript/src/views/types.d.ts +6 -0
  217. package/package.json +4 -1
  218. package/react-native-skia.podspec +1 -0
  219. package/src/Platform/Platform.web.tsx +7 -99
  220. package/src/external/reanimated/useVideoLoading.ts +12 -2
  221. package/src/mock/index.ts +1 -0
  222. package/src/renderer/Canvas.tsx +11 -0
  223. package/src/skia/core/SVG.web.ts +5 -14
  224. package/src/skia/types/Paragraph/Paragraph.ts +67 -0
  225. package/src/skia/types/Surface/Surface.ts +5 -1
  226. package/src/skia/web/Host.ts +7 -0
  227. package/src/skia/web/JsiSkPaint.ts +5 -0
  228. package/src/skia/web/JsiSkParagraph.ts +9 -1
  229. package/src/skia/web/JsiSkParagraphStyle.ts +16 -2
  230. package/src/skia/web/JsiSkSurface.ts +2 -1
  231. package/src/sksg/Container.native.ts +12 -0
  232. package/src/sksg/Container.web.ts +43 -4
  233. package/src/sksg/Recorder/DrawingContext.ts +19 -6
  234. package/src/sksg/Recorder/FrameScope.native.ts +21 -0
  235. package/src/sksg/Recorder/FrameScope.ts +69 -0
  236. package/src/sksg/Recorder/Player.ts +1 -2
  237. package/src/sksg/Recorder/Recorder.ts +15 -1
  238. package/src/sksg/Recorder/commands/Drawing.ts +3 -3
  239. package/src/sksg/Recorder/commands/Shaders.ts +22 -16
  240. package/src/sksg/StaticContainer.ts +29 -2
  241. package/src/specs/NativeSkiaModule.web.ts +39 -7
  242. package/src/specs/SkiaPictureViewNativeComponent.ts +1 -0
  243. package/src/views/SkiaPictureView.tsx +2 -0
  244. package/src/views/SkiaPictureView.web.tsx +318 -106
  245. package/src/views/formats.ts +21 -0
  246. package/src/views/index.ts +1 -0
  247. package/src/views/types.ts +7 -0
@@ -5,15 +5,26 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.JsiSkParagraphStyle = void 0;
7
7
  var _types = require("../types");
8
+ var _JsiSkTextStyle = require("./JsiSkTextStyle");
8
9
  class JsiSkParagraphStyle {
9
10
  static toParagraphStyle(ck, value) {
10
11
  var _value$disableHinting, _value$ellipsis, _value$heightMultipli, _value$maxLines, _value$replaceTabChar, _ps$strutStyle, _value$strutStyle$fon, _value$strutStyle, _value$strutStyle$fon2, _value$strutStyle2, _value$strutStyle$hei, _value$strutStyle3, _value$strutStyle$lea, _value$strutStyle4, _value$strutStyle$for, _value$strutStyle5, _ps$strutStyle$fontSt, _value$strutStyle6, _value$strutStyle7, _value$strutStyle8, _value$strutStyle$hal, _value$strutStyle9, _value$strutStyle$str, _value$strutStyle0;
11
12
  // Seems like we need to provide the textStyle.color value, otherwise
12
13
  // the constructor crashes.
14
+ const textStyle = {
15
+ color: ck.BLACK
16
+ };
17
+ if (value.textStyle) {
18
+ // Only merge the properties that are set; toTextStyle() emits undefined
19
+ // for the others and the ParagraphStyle constructor requires a color.
20
+ Object.entries(_JsiSkTextStyle.JsiSkTextStyle.toTextStyle(value.textStyle)).forEach(([key, v]) => {
21
+ if (v !== undefined) {
22
+ textStyle[key] = v;
23
+ }
24
+ });
25
+ }
13
26
  const ps = new ck.ParagraphStyle({
14
- textStyle: {
15
- color: ck.BLACK
16
- }
27
+ textStyle
17
28
  });
18
29
  ps.disableHinting = (_value$disableHinting = value.disableHinting) !== null && _value$disableHinting !== void 0 ? _value$disableHinting : ps.disableHinting;
19
30
  ps.ellipsis = (_value$ellipsis = value.ellipsis) !== null && _value$ellipsis !== void 0 ? _value$ellipsis : ps.ellipsis;
@@ -1 +1 @@
1
- {"version":3,"names":["_types","require","JsiSkParagraphStyle","toParagraphStyle","ck","value","_value$disableHinting","_value$ellipsis","_value$heightMultipli","_value$maxLines","_value$replaceTabChar","_ps$strutStyle","_value$strutStyle$fon","_value$strutStyle","_value$strutStyle$fon2","_value$strutStyle2","_value$strutStyle$hei","_value$strutStyle3","_value$strutStyle$lea","_value$strutStyle4","_value$strutStyle$for","_value$strutStyle5","_ps$strutStyle$fontSt","_value$strutStyle6","_value$strutStyle7","_value$strutStyle8","_value$strutStyle$hal","_value$strutStyle9","_value$strutStyle$str","_value$strutStyle0","ps","ParagraphStyle","textStyle","color","BLACK","disableHinting","ellipsis","heightMultiplier","maxLines","replaceTabCharacters","textAlign","undefined","textDirection","TextDirection","LTR","textHeightBehavior","strutStyle","fontFamilies","fontSize","leading","forceStrutHeight","fontStyle","slant","width","weight","halfLeading","strutEnabled","exports"],"sources":["JsiSkParagraphStyle.ts"],"sourcesContent":["import type { CanvasKit, ParagraphStyle } from \"canvaskit-wasm\";\n\nimport { TextDirection } from \"../types\";\nimport type { SkParagraphStyle } from \"../types\";\n\nexport class JsiSkParagraphStyle {\n static toParagraphStyle(\n ck: CanvasKit,\n value: SkParagraphStyle\n ): ParagraphStyle {\n // Seems like we need to provide the textStyle.color value, otherwise\n // the constructor crashes.\n const ps = new ck.ParagraphStyle({ textStyle: { color: ck.BLACK } });\n\n ps.disableHinting = value.disableHinting ?? ps.disableHinting;\n ps.ellipsis = value.ellipsis ?? ps.ellipsis;\n ps.heightMultiplier = value.heightMultiplier ?? ps.heightMultiplier;\n ps.maxLines = value.maxLines ?? ps.maxLines;\n ps.replaceTabCharacters =\n value.replaceTabCharacters ?? ps.replaceTabCharacters;\n ps.textAlign =\n value.textAlign !== undefined ? { value: value.textAlign } : ps.textAlign;\n ps.textDirection =\n value.textDirection !== undefined\n ? { value: value.textDirection === TextDirection.LTR ? 1 : 0 }\n : ps.textDirection;\n ps.textHeightBehavior =\n value.textHeightBehavior !== undefined\n ? { value: value.textHeightBehavior }\n : ps.textHeightBehavior;\n\n ps.strutStyle = ps.strutStyle ?? {};\n ps.strutStyle.fontFamilies =\n value.strutStyle?.fontFamilies ?? ps.strutStyle.fontFamilies;\n ps.strutStyle.fontSize =\n value.strutStyle?.fontSize ?? ps.strutStyle.fontSize;\n ps.strutStyle.heightMultiplier =\n value.strutStyle?.heightMultiplier ?? ps.strutStyle.heightMultiplier;\n ps.strutStyle.leading = value.strutStyle?.leading ?? ps.strutStyle.leading;\n ps.strutStyle.forceStrutHeight =\n value.strutStyle?.forceStrutHeight ?? ps.strutStyle.forceStrutHeight;\n\n ps.strutStyle.fontStyle = ps.strutStyle.fontStyle ?? {};\n\n ps.strutStyle.fontStyle.slant =\n value.strutStyle?.fontStyle?.slant !== undefined\n ? { value: value.strutStyle.fontStyle.slant }\n : ps.strutStyle.fontStyle.slant;\n ps.strutStyle.fontStyle.width =\n value.strutStyle?.fontStyle?.width !== undefined\n ? { value: value.strutStyle.fontStyle.width }\n : ps.strutStyle.fontStyle.width;\n ps.strutStyle.fontStyle.weight =\n value.strutStyle?.fontStyle?.weight !== undefined\n ? { value: value.strutStyle.fontStyle.weight }\n : ps.strutStyle.fontStyle.weight;\n ps.strutStyle.halfLeading =\n value.strutStyle?.halfLeading ?? ps.strutStyle.halfLeading;\n ps.strutStyle.strutEnabled =\n value.strutStyle?.strutEnabled ?? ps.strutStyle.strutEnabled;\n\n return ps;\n }\n}\n"],"mappings":";;;;;;AAEA,IAAAA,MAAA,GAAAC,OAAA;AAGO,MAAMC,mBAAmB,CAAC;EAC/B,OAAOC,gBAAgBA,CACrBC,EAAa,EACbC,KAAuB,EACP;IAAA,IAAAC,qBAAA,EAAAC,eAAA,EAAAC,qBAAA,EAAAC,eAAA,EAAAC,qBAAA,EAAAC,cAAA,EAAAC,qBAAA,EAAAC,iBAAA,EAAAC,sBAAA,EAAAC,kBAAA,EAAAC,qBAAA,EAAAC,kBAAA,EAAAC,qBAAA,EAAAC,kBAAA,EAAAC,qBAAA,EAAAC,kBAAA,EAAAC,qBAAA,EAAAC,kBAAA,EAAAC,kBAAA,EAAAC,kBAAA,EAAAC,qBAAA,EAAAC,kBAAA,EAAAC,qBAAA,EAAAC,kBAAA;IAChB;IACA;IACA,MAAMC,EAAE,GAAG,IAAI1B,EAAE,CAAC2B,cAAc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7B,qBAAA,IAAAC,kBAAA,GACvBtB,KAAK,CAACyC,UAAU,cAAAnB,kBAAA,uBAAhBA,kBAAA,CAAkB4B,WAAW,cAAA7B,qBAAA,cAAAA,qBAAA,GAAII,EAAE,CAACgB,UAAU,CAACS,WAAW;IAC5DzB,EAAE,CAACgB,UAAU,CAACU,YAAY,IAAA5B,qBAAA,IAAAC,kBAAA,GACxBxB,KAAK,CAACyC,UAAU,cAAAjB,kBAAA,uBAAhBA,kBAAA,CAAkB2B,YAAY,cAAA5B,qBAAA,cAAAA,qBAAA,GAAIE,EAAE,CAACgB,UAAU,CAACU,YAAY;IAE9D,OAAO1B,EAAE;EACX;AACF;AAAC2B,OAAA,CAAAvD,mBAAA,GAAAA,mBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_types","require","_JsiSkTextStyle","JsiSkParagraphStyle","toParagraphStyle","ck","value","_value$disableHinting","_value$ellipsis","_value$heightMultipli","_value$maxLines","_value$replaceTabChar","_ps$strutStyle","_value$strutStyle$fon","_value$strutStyle","_value$strutStyle$fon2","_value$strutStyle2","_value$strutStyle$hei","_value$strutStyle3","_value$strutStyle$lea","_value$strutStyle4","_value$strutStyle$for","_value$strutStyle5","_ps$strutStyle$fontSt","_value$strutStyle6","_value$strutStyle7","_value$strutStyle8","_value$strutStyle$hal","_value$strutStyle9","_value$strutStyle$str","_value$strutStyle0","textStyle","color","BLACK","Object","entries","JsiSkTextStyle","toTextStyle","forEach","key","v","undefined","ps","ParagraphStyle","disableHinting","ellipsis","heightMultiplier","maxLines","replaceTabCharacters","textAlign","textDirection","TextDirection","LTR","textHeightBehavior","strutStyle","fontFamilies","fontSize","leading","forceStrutHeight","fontStyle","slant","width","weight","halfLeading","strutEnabled","exports"],"sources":["JsiSkParagraphStyle.ts"],"sourcesContent":["import type { CanvasKit, ParagraphStyle, TextStyle } from \"canvaskit-wasm\";\n\nimport { TextDirection } from \"../types\";\nimport type { SkParagraphStyle } from \"../types\";\n\nimport { JsiSkTextStyle } from \"./JsiSkTextStyle\";\n\nexport class JsiSkParagraphStyle {\n static toParagraphStyle(\n ck: CanvasKit,\n value: SkParagraphStyle\n ): ParagraphStyle {\n // Seems like we need to provide the textStyle.color value, otherwise\n // the constructor crashes.\n const textStyle: TextStyle = { color: ck.BLACK };\n if (value.textStyle) {\n // Only merge the properties that are set; toTextStyle() emits undefined\n // for the others and the ParagraphStyle constructor requires a color.\n Object.entries(JsiSkTextStyle.toTextStyle(value.textStyle)).forEach(\n ([key, v]) => {\n if (v !== undefined) {\n (textStyle as Record<string, unknown>)[key] = v;\n }\n }\n );\n }\n const ps = new ck.ParagraphStyle({ textStyle });\n\n ps.disableHinting = value.disableHinting ?? ps.disableHinting;\n ps.ellipsis = value.ellipsis ?? ps.ellipsis;\n ps.heightMultiplier = value.heightMultiplier ?? ps.heightMultiplier;\n ps.maxLines = value.maxLines ?? ps.maxLines;\n ps.replaceTabCharacters =\n value.replaceTabCharacters ?? ps.replaceTabCharacters;\n ps.textAlign =\n value.textAlign !== undefined ? { value: value.textAlign } : ps.textAlign;\n ps.textDirection =\n value.textDirection !== undefined\n ? { value: value.textDirection === TextDirection.LTR ? 1 : 0 }\n : ps.textDirection;\n ps.textHeightBehavior =\n value.textHeightBehavior !== undefined\n ? { value: value.textHeightBehavior }\n : ps.textHeightBehavior;\n\n ps.strutStyle = ps.strutStyle ?? {};\n ps.strutStyle.fontFamilies =\n value.strutStyle?.fontFamilies ?? ps.strutStyle.fontFamilies;\n ps.strutStyle.fontSize =\n value.strutStyle?.fontSize ?? ps.strutStyle.fontSize;\n ps.strutStyle.heightMultiplier =\n value.strutStyle?.heightMultiplier ?? ps.strutStyle.heightMultiplier;\n ps.strutStyle.leading = value.strutStyle?.leading ?? ps.strutStyle.leading;\n ps.strutStyle.forceStrutHeight =\n value.strutStyle?.forceStrutHeight ?? ps.strutStyle.forceStrutHeight;\n\n ps.strutStyle.fontStyle = ps.strutStyle.fontStyle ?? {};\n\n ps.strutStyle.fontStyle.slant =\n value.strutStyle?.fontStyle?.slant !== undefined\n ? { value: value.strutStyle.fontStyle.slant }\n : ps.strutStyle.fontStyle.slant;\n ps.strutStyle.fontStyle.width =\n value.strutStyle?.fontStyle?.width !== undefined\n ? { value: value.strutStyle.fontStyle.width }\n : ps.strutStyle.fontStyle.width;\n ps.strutStyle.fontStyle.weight =\n value.strutStyle?.fontStyle?.weight !== undefined\n ? { value: value.strutStyle.fontStyle.weight }\n : ps.strutStyle.fontStyle.weight;\n ps.strutStyle.halfLeading =\n value.strutStyle?.halfLeading ?? ps.strutStyle.halfLeading;\n ps.strutStyle.strutEnabled =\n value.strutStyle?.strutEnabled ?? ps.strutStyle.strutEnabled;\n\n return ps;\n }\n}\n"],"mappings":";;;;;;AAEA,IAAAA,MAAA,GAAAC,OAAA;AAGA,IAAAC,eAAA,GAAAD,OAAA;AAEO,MAAME,mBAAmB,CAAC;EAC/B,OAAOC,gBAAgBA,CACrBC,EAAa,EACbC,KAAuB,EACP;IAAA,IAAAC,qBAAA,EAAAC,eAAA,EAAAC,qBAAA,EAAAC,eAAA,EAAAC,qBAAA,EAAAC,cAAA,EAAAC,qBAAA,EAAAC,iBAAA,EAAAC,sBAAA,EAAAC,kBAAA,EAAAC,qBAAA,EAAAC,kBAAA,EAAAC,qBAAA,EAAAC,kBAAA,EAAAC,qBAAA,EAAAC,kBAAA,EAAAC,qBAAA,EAAAC,kBAAA,EAAAC,kBAAA,EAAAC,kBAAA,EAAAC,qBAAA,EAAAC,kBAAA,EAAAC,qBAAA,EAAAC,kBAAA;IAChB;IACA;IACA,MAAMC,SAAoB,GAAG;MAAEC,KAAK,EAAE3B,EAAE,CAAC4B;IAAM,CAAC;IAChD,IAAI3B,KAAK,CAACyB,SAAS,EAAE;MACnB;MACA;MACAG,MAAM,CAACC,OAAO,CAACC,8BAAc,CAACC,WAAW,CAAC/B,KAAK,CAACyB,SAAS,CAAC,CAAC,CAACO,OAAO,CACjE,CAAC,CAACC,GAAG,EAAEC,CAAC,CAAC,KAAK;QACZ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AACK,SAAS,CAACG,MAAM;IACpCpB,EAAE,CAACY,UAAU,CAACS,WAAW,IAAApC,qBAAA,IAAAC,kBAAA,GACvBtB,KAAK,CAACgD,UAAU,cAAA1B,kBAAA,uBAAhBA,kBAAA,CAAkBmC,WAAW,cAAApC,qBAAA,cAAAA,qBAAA,GAAIe,EAAE,CAACY,UAAU,CAACS,WAAW;IAC5DrB,EAAE,CAACY,UAAU,CAACU,YAAY,IAAAnC,qBAAA,IAAAC,kBAAA,GACxBxB,KAAK,CAACgD,UAAU,cAAAxB,kBAAA,uBAAhBA,kBAAA,CAAkBkC,YAAY,cAAAnC,qBAAA,cAAAA,qBAAA,GAAIa,EAAE,CAACY,UAAU,CAACU,YAAY;IAE9D,OAAOtB,EAAE;EACX;AACF;AAACuB,OAAA,CAAA9D,mBAAA,GAAAA,mBAAA","ignoreList":[]}
@@ -5,7 +5,7 @@ import { JsiSkImage } from "./JsiSkImage";
5
5
  export declare class JsiSkSurface extends HostObject<Surface, "Surface"> implements SkSurface {
6
6
  constructor(CanvasKit: CanvasKit, ref: Surface);
7
7
  [Symbol.dispose](): void;
8
- flush(): void;
8
+ flush(_sync?: boolean): void;
9
9
  width(): number;
10
10
  height(): number;
11
11
  getCanvas(): SkCanvas;
@@ -15,7 +15,8 @@ class JsiSkSurface extends _Host.HostObject {
15
15
  [Symbol.dispose]() {
16
16
  this.ref.dispose();
17
17
  }
18
- flush() {
18
+ flush(_sync) {
19
+ // CanvasKit has no separate CPU sync; flush() is sufficient on the web backend.
19
20
  this.ref.flush();
20
21
  }
21
22
  width() {
@@ -1 +1 @@
1
- {"version":3,"names":["_Host","require","_JsiSkCanvas","_JsiSkImage","_JsiSkRect","JsiSkSurface","HostObject","constructor","CanvasKit","ref","Symbol","dispose","flush","width","height","getCanvas","JsiSkCanvas","makeImageSnapshot","bounds","outputImage","image","Array","from","JsiSkRect","fromValue","undefined","JsiSkImage","getNativeTextureUnstable","console","warn","exports"],"sources":["JsiSkSurface.ts"],"sourcesContent":["import type { CanvasKit, Surface } from \"canvaskit-wasm\";\n\nimport type { SkCanvas, SkImage, SkRect, SkSurface } from \"../types\";\n\nimport { HostObject } from \"./Host\";\nimport { JsiSkCanvas } from \"./JsiSkCanvas\";\nimport { JsiSkImage } from \"./JsiSkImage\";\nimport { JsiSkRect } from \"./JsiSkRect\";\n\nexport class JsiSkSurface\n extends HostObject<Surface, \"Surface\">\n implements SkSurface\n{\n constructor(CanvasKit: CanvasKit, ref: Surface) {\n super(CanvasKit, ref, \"Surface\");\n }\n\n [Symbol.dispose]() {\n this.ref.dispose();\n }\n\n flush() {\n this.ref.flush();\n }\n\n width() {\n return this.ref.width();\n }\n\n height() {\n return this.ref.height();\n }\n\n getCanvas(): SkCanvas {\n return new JsiSkCanvas(this.CanvasKit, this.ref.getCanvas());\n }\n\n makeImageSnapshot(bounds?: SkRect, outputImage?: JsiSkImage): SkImage {\n const image = this.ref.makeImageSnapshot(\n bounds\n ? Array.from(JsiSkRect.fromValue(this.CanvasKit, bounds))\n : undefined\n );\n if (outputImage) {\n outputImage.ref = image;\n }\n return new JsiSkImage(this.CanvasKit, image);\n }\n\n getNativeTextureUnstable(): unknown {\n console.warn(\"getBackendTexture is not implemented on Web\");\n return null;\n }\n}\n"],"mappings":";;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAEO,MAAMI,YAAY,SACfC,gBAAU,CAEpB;EACEC,WAAWA,CAACC,SAAoB,EAAEC,GAAY,EAAE;IAC9C,KAAK,CAACD,SAAS,EAAEC,GAAG,EAAE,SAAS,CAAC;EAClC;EAEA,CAACC,MAAM,CAACC,OAAO,IAAI;IACjB,IAAI,CAACF,GAAG,CAACE,OAAO,CAAC,CAAC;EACpB;EAEAC,KAAKA,CAAA,EAAG;IACN,IAAI,CAACH,GAAG,CAACG,KAAK,CAAC,CAAC;EAClB;EAEAC,KAAKA,CAAA,EAAG;IACN,OAAO,IAAI,CAACJ,GAAG,CAACI,KAAK,CAAC,CAAC;EACzB;EAEAC,MAAMA,CAAA,EAAG;IACP,OAAO,IAAI,CAACL,GAAG,CAACK,MAAM,CAAC,CAAC;EAC1B;EAEAC,SAASA,CAAA,EAAa;IACpB,OAAO,IAAIC,wBAAW,CAAC,IAAI,CAACR,SAAS,EAAE,IAAI,CAACC,GAAG,CAACM,SAAS,CAAC,CAAC,CAAC;EAC9D;EAEAE,iBAAiBA,CAACC,MAAe,EAAEC,WAAwB,EAAW;IACpE,MAAMC,KAAK,GAAG,IAAI,CAACX,GAAG,CAACQ,iBAAiB,CACtCC,MAAM,GACFG,KAAK,CAACC,IAAI,CAACC,oBAAS,CAACC,SAAS,CAAC,IAAI,CAAChB,SAAS,EAAEU,MAAM,CAAC,CAAC,GACvDO,SACN,CAAC;IACD,IAAIN,WAAW,EAAE;MACfA,WAAW,CAACV,GAAG,GAAGW,KAAK;IACzB;IACA,OAAO,IAAIM,sBAAU,CAAC,IAAI,CAAClB,SAAS,EAAEY,KAAK,CAAC;EAC9C;EAEAO,wBAAwBA,CAAA,EAAY;IAClCC,OAAO,CAACC,IAAI,CAAC,6CAA6C,CAAC;IAC3D,OAAO,IAAI;EACb;AACF;AAACC,OAAA,CAAAzB,YAAA,GAAAA,YAAA","ignoreList":[]}
1
+ {"version":3,"names":["_Host","require","_JsiSkCanvas","_JsiSkImage","_JsiSkRect","JsiSkSurface","HostObject","constructor","CanvasKit","ref","Symbol","dispose","flush","_sync","width","height","getCanvas","JsiSkCanvas","makeImageSnapshot","bounds","outputImage","image","Array","from","JsiSkRect","fromValue","undefined","JsiSkImage","getNativeTextureUnstable","console","warn","exports"],"sources":["JsiSkSurface.ts"],"sourcesContent":["import type { CanvasKit, Surface } from \"canvaskit-wasm\";\n\nimport type { SkCanvas, SkImage, SkRect, SkSurface } from \"../types\";\n\nimport { HostObject } from \"./Host\";\nimport { JsiSkCanvas } from \"./JsiSkCanvas\";\nimport { JsiSkImage } from \"./JsiSkImage\";\nimport { JsiSkRect } from \"./JsiSkRect\";\n\nexport class JsiSkSurface\n extends HostObject<Surface, \"Surface\">\n implements SkSurface\n{\n constructor(CanvasKit: CanvasKit, ref: Surface) {\n super(CanvasKit, ref, \"Surface\");\n }\n\n [Symbol.dispose]() {\n this.ref.dispose();\n }\n\n flush(_sync?: boolean) {\n // CanvasKit has no separate CPU sync; flush() is sufficient on the web backend.\n this.ref.flush();\n }\n\n width() {\n return this.ref.width();\n }\n\n height() {\n return this.ref.height();\n }\n\n getCanvas(): SkCanvas {\n return new JsiSkCanvas(this.CanvasKit, this.ref.getCanvas());\n }\n\n makeImageSnapshot(bounds?: SkRect, outputImage?: JsiSkImage): SkImage {\n const image = this.ref.makeImageSnapshot(\n bounds\n ? Array.from(JsiSkRect.fromValue(this.CanvasKit, bounds))\n : undefined\n );\n if (outputImage) {\n outputImage.ref = image;\n }\n return new JsiSkImage(this.CanvasKit, image);\n }\n\n getNativeTextureUnstable(): unknown {\n console.warn(\"getBackendTexture is not implemented on Web\");\n return null;\n }\n}\n"],"mappings":";;;;;;AAIA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAEO,MAAMI,YAAY,SACfC,gBAAU,CAEpB;EACEC,WAAWA,CAACC,SAAoB,EAAEC,GAAY,EAAE;IAC9C,KAAK,CAACD,SAAS,EAAEC,GAAG,EAAE,SAAS,CAAC;EAClC;EAEA,CAACC,MAAM,CAACC,OAAO,IAAI;IACjB,IAAI,CAACF,GAAG,CAACE,OAAO,CAAC,CAAC;EACpB;EAEAC,KAAKA,CAACC,KAAe,EAAE;IACrB;IACA,IAAI,CAACJ,GAAG,CAACG,KAAK,CAAC,CAAC;EAClB;EAEAE,KAAKA,CAAA,EAAG;IACN,OAAO,IAAI,CAACL,GAAG,CAACK,KAAK,CAAC,CAAC;EACzB;EAEAC,MAAMA,CAAA,EAAG;IACP,OAAO,IAAI,CAACN,GAAG,CAACM,MAAM,CAAC,CAAC;EAC1B;EAEAC,SAASA,CAAA,EAAa;IACpB,OAAO,IAAIC,wBAAW,CAAC,IAAI,CAACT,SAAS,EAAE,IAAI,CAACC,GAAG,CAACO,SAAS,CAAC,CAAC,CAAC;EAC9D;EAEAE,iBAAiBA,CAACC,MAAe,EAAEC,WAAwB,EAAW;IACpE,MAAMC,KAAK,GAAG,IAAI,CAACZ,GAAG,CAACS,iBAAiB,CACtCC,MAAM,GACFG,KAAK,CAACC,IAAI,CAACC,oBAAS,CAACC,SAAS,CAAC,IAAI,CAACjB,SAAS,EAAEW,MAAM,CAAC,CAAC,GACvDO,SACN,CAAC;IACD,IAAIN,WAAW,EAAE;MACfA,WAAW,CAACX,GAAG,GAAGY,KAAK;IACzB;IACA,OAAO,IAAIM,sBAAU,CAAC,IAAI,CAACnB,SAAS,EAAEa,KAAK,CAAC;EAC9C;EAEAO,wBAAwBA,CAAA,EAAY;IAClCC,OAAO,CAACC,IAAI,CAAC,6CAA6C,CAAC;IAC3D,OAAO,IAAI;EACb;AACF;AAACC,OAAA,CAAA1B,YAAA,GAAAA,YAAA","ignoreList":[]}
@@ -7,6 +7,7 @@ declare class NativeReanimatedContainer extends Container {
7
7
  private mapperId;
8
8
  private picture;
9
9
  constructor(Skia: Skia, nativeId: number);
10
+ unmount(): void;
10
11
  redraw(): void;
11
12
  }
12
13
  export declare const createContainer: (Skia: Skia, nativeId: number) => StaticContainer | NativeReanimatedContainer;
@@ -36,9 +36,20 @@ class NativeReanimatedContainer extends _StaticContainer.Container {
36
36
  _defineProperty(this, "picture", void 0);
37
37
  this.picture = Skia.Picture.MakePicture(null);
38
38
  }
39
+ unmount() {
40
+ super.unmount();
41
+ if (this.mapperId !== null) {
42
+ // The mapper closure retains the recorder and its resources (e.g.
43
+ // images) on the UI runtime and keeps updating the picture of an
44
+ // unmounted view — stop it or it leaks for the lifetime of the app.
45
+ _ReanimatedProxy.default.stopMapper(this.mapperId);
46
+ this.mapperId = null;
47
+ }
48
+ }
39
49
  redraw() {
40
50
  if (this.mapperId !== null) {
41
51
  _ReanimatedProxy.default.stopMapper(this.mapperId);
52
+ this.mapperId = null;
42
53
  }
43
54
  if (this.unmounted) {
44
55
  return;
@@ -1 +1 @@
1
- {"version":3,"names":["_ReanimatedProxy","_interopRequireDefault","require","_renderHelpers","_ReanimatedRecorder","_StaticContainer","_Visitor","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","SkiaViewApi","globalThis","nativeDrawOnscreen","nativeId","recorder","picture","play","setJsiProperty","NativeReanimatedContainer","Container","constructor","Skia","Picture","MakePicture","redraw","mapperId","Rea","stopMapper","unmounted","ReanimatedRecorder","visit","root","sharedValues","getSharedValues","sharedRecorder","getRecorder","runOnUI","length","startMapper","applyUpdates","createContainer","HAS_REANIMATED_3","StaticContainer","exports"],"sources":["Container.native.ts"],"sourcesContent":["import Rea from \"../external/reanimated/ReanimatedProxy\";\nimport type { Skia, SkPicture } from \"../skia/types\";\nimport { HAS_REANIMATED_3 } from \"../external/reanimated/renderHelpers\";\nimport type { JsiRecorder } from \"../skia/types/Recorder\";\n\nimport { ReanimatedRecorder } from \"./Recorder/ReanimatedRecorder\";\nimport { Container, StaticContainer } from \"./StaticContainer\";\nimport { visit } from \"./Recorder/Visitor\";\n\nimport \"../skia/NativeSetup\";\nimport \"../views/api\";\n\n// create local reference for `strictGlobal` option in Worklets\nconst { SkiaViewApi } = globalThis;\n\nconst nativeDrawOnscreen = (\n nativeId: number,\n recorder: JsiRecorder,\n picture: SkPicture\n) => {\n \"worklet\";\n\n //const start = performance.now();\n recorder.play(picture);\n //const end = performance.now();\n //console.log(\"Recording time: \", end - start);\n SkiaViewApi.setJsiProperty(nativeId, \"picture\", picture);\n};\n\nclass NativeReanimatedContainer extends Container {\n private mapperId: number | null = null;\n private picture: SkPicture;\n\n constructor(\n Skia: Skia,\n private nativeId: number\n ) {\n super(Skia);\n this.picture = Skia.Picture.MakePicture(null)!;\n }\n\n redraw() {\n if (this.mapperId !== null) {\n Rea.stopMapper(this.mapperId);\n }\n if (this.unmounted) {\n return;\n }\n const recorder = new ReanimatedRecorder(this.Skia);\n const { nativeId, picture } = this;\n visit(recorder, this.root);\n const sharedValues = recorder.getSharedValues();\n const sharedRecorder = recorder.getRecorder();\n // Draw first frame\n Rea.runOnUI(() => {\n \"worklet\";\n nativeDrawOnscreen(nativeId, sharedRecorder, picture);\n })();\n // Animate\n if (sharedValues.length > 0) {\n this.mapperId = Rea.startMapper(() => {\n \"worklet\";\n sharedRecorder.applyUpdates(sharedValues);\n nativeDrawOnscreen(nativeId, sharedRecorder, picture);\n }, sharedValues);\n }\n }\n}\n\nexport const createContainer = (Skia: Skia, nativeId: number) => {\n if (HAS_REANIMATED_3 && nativeId !== -1) {\n return new NativeReanimatedContainer(Skia, nativeId);\n } else {\n return new StaticContainer(Skia, nativeId);\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,cAAA,GAAAD,OAAA;AAGA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAEAA,OAAA;AACAA,OAAA;AAAsB,SAAAD,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,gBAAAH,CAAA,EAAAI,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAJ,CAAA,GAAAO,MAAA,CAAAC,cAAA,CAAAR,CAAA,EAAAI,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA,MAAAC,QAAA,UAAA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,QAAQ,GAAG,IAAIe,sCAAkB,CAAC,IAAI,CAACR,IAAI,CAAC;IAClD,MAAM;MAAER,QAAQ;MAAEE;IAAQ,CAAC,GAAG,IAAI;IAClC,IAAAe,cAAK,EAAChB,QAAQ,EAAE,IAAI,CAACiB,IAAI,CAAC;IAC1B,MAAMC,YAAY,GAAGlB,QAAQ,CAACmB,eAAe,CAAC,CAAC;IAC/C,MAAMC,cAAc,GAAGpB,QAAQ,CAACqB,WAAW,CAAC,CAAC;IAC7C;IACAT,wBAAG,CAACU,OAAO,CAAC,MAAM;MAChB,SAAS;;MACTxB,kBAAkB,CAACC,QAAQ,EAAEqB,cAAc,EAAEnB,OAAO,CAAC;IACvD,CAAC,CAAC,CAAC,CAAC;IACJ;IACA,IAAIiB,YAAY,CAACK,MAAM,GAAG,CAAC,EAAE;MAC3B,IAAI,CAACZ,QAAQ,GAAGC,wBAAG,CAACY,WAAW,CAAC,MAAM;QACpC,SAAS;;QACTJ,cAAc,CAACK,YAAY,CAACP,YAAY,CAAC;QACzCpB,kBAAkB,CAACC,QAAQ,EAAEqB,cAAc,EAAEnB,OAAO,CAAC;MACvD,CAAC,EAAEiB,YAAY,CAAC;IAClB;EACF;AACF;AAEO,MAAMQ,eAAe,GAAGA,CAACnB,IAAU,EAAER,QAAgB,KAAK;EAC/D,IAAI4B,+BAAgB,IAAI5B,QAAQ,KAAK,CAAC,CAAC,EAAE;IACvC,OAAO,IAAIK,yBAAyB,CAACG,IAAI,EAAER,QAAQ,CAAC;EACtD,CAAC,MAAM;IACL,OAAO,IAAI6B,gCAAe,CAACrB,IAAI,EAAER,QAAQ,CAAC;EAC5C;AACF,CAAC;AAAC8B,OAAA,CAAAH,eAAA,GAAAA,eAAA","ignoreList":[]}
1
+ {"version":3,"names":["_ReanimatedProxy","_interopRequireDefault","require","_renderHelpers","_ReanimatedRecorder","_StaticContainer","_Visitor","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","SkiaViewApi","globalThis","nativeDrawOnscreen","nativeId","recorder","picture","play","setJsiProperty","NativeReanimatedContainer","Container","constructor","Skia","Picture","MakePicture","unmount","mapperId","Rea","stopMapper","redraw","unmounted","ReanimatedRecorder","visit","root","sharedValues","getSharedValues","sharedRecorder","getRecorder","runOnUI","length","startMapper","applyUpdates","createContainer","HAS_REANIMATED_3","StaticContainer","exports"],"sources":["Container.native.ts"],"sourcesContent":["import Rea from \"../external/reanimated/ReanimatedProxy\";\nimport type { Skia, SkPicture } from \"../skia/types\";\nimport { HAS_REANIMATED_3 } from \"../external/reanimated/renderHelpers\";\nimport type { JsiRecorder } from \"../skia/types/Recorder\";\n\nimport { ReanimatedRecorder } from \"./Recorder/ReanimatedRecorder\";\nimport { Container, StaticContainer } from \"./StaticContainer\";\nimport { visit } from \"./Recorder/Visitor\";\n\nimport \"../skia/NativeSetup\";\nimport \"../views/api\";\n\n// create local reference for `strictGlobal` option in Worklets\nconst { SkiaViewApi } = globalThis;\n\nconst nativeDrawOnscreen = (\n nativeId: number,\n recorder: JsiRecorder,\n picture: SkPicture\n) => {\n \"worklet\";\n\n //const start = performance.now();\n recorder.play(picture);\n //const end = performance.now();\n //console.log(\"Recording time: \", end - start);\n SkiaViewApi.setJsiProperty(nativeId, \"picture\", picture);\n};\n\nclass NativeReanimatedContainer extends Container {\n private mapperId: number | null = null;\n private picture: SkPicture;\n\n constructor(\n Skia: Skia,\n private nativeId: number\n ) {\n super(Skia);\n this.picture = Skia.Picture.MakePicture(null)!;\n }\n\n unmount() {\n super.unmount();\n if (this.mapperId !== null) {\n // The mapper closure retains the recorder and its resources (e.g.\n // images) on the UI runtime and keeps updating the picture of an\n // unmounted view — stop it or it leaks for the lifetime of the app.\n Rea.stopMapper(this.mapperId);\n this.mapperId = null;\n }\n }\n\n redraw() {\n if (this.mapperId !== null) {\n Rea.stopMapper(this.mapperId);\n this.mapperId = null;\n }\n if (this.unmounted) {\n return;\n }\n const recorder = new ReanimatedRecorder(this.Skia);\n const { nativeId, picture } = this;\n visit(recorder, this.root);\n const sharedValues = recorder.getSharedValues();\n const sharedRecorder = recorder.getRecorder();\n // Draw first frame\n Rea.runOnUI(() => {\n \"worklet\";\n nativeDrawOnscreen(nativeId, sharedRecorder, picture);\n })();\n // Animate\n if (sharedValues.length > 0) {\n this.mapperId = Rea.startMapper(() => {\n \"worklet\";\n sharedRecorder.applyUpdates(sharedValues);\n nativeDrawOnscreen(nativeId, sharedRecorder, picture);\n }, sharedValues);\n }\n }\n}\n\nexport const createContainer = (Skia: Skia, nativeId: number) => {\n if (HAS_REANIMATED_3 && nativeId !== -1) {\n return new NativeReanimatedContainer(Skia, nativeId);\n } else {\n return new StaticContainer(Skia, nativeId);\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,cAAA,GAAAD,OAAA;AAGA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAEAA,OAAA;AACAA,OAAA;AAAsB,SAAAD,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,gBAAAH,CAAA,EAAAI,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAJ,CAAA,GAAAO,MAAA,CAAAC,cAAA,CAAAR,CAAA,EAAAI,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA,MAAAC,QAAA,UAAAZ,CAAA,CAAAI,CAAA,IAAAC,CAAA,EAAAL,CAAA;AAAA,SAAAM,eAAAD,CAAA,QAAAQ,CAAA,GAAAC,YAAA,CAAAT,CAAA,uCAAAQ,CAAA,GAAAA,CAAA,GAAAA,CAAA;AAAA,SAAAC,aAAAT,CA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apperId;
8
8
  constructor(Skia: Skia, nativeId: number);
9
+ unmount(): void;
9
10
  redraw(): void;
10
11
  }
11
12
  export declare const createContainer: (Skia: Skia, nativeId: number) => StaticContainer | ReanimatedContainer;
@@ -24,17 +24,30 @@ const {
24
24
  const drawOnscreen = (Skia, nativeId, recording) => {
25
25
  "worklet";
26
26
 
27
+ var _recording$lastPictur;
27
28
  const rec = Skia.PictureRecorder();
28
29
  const canvas = rec.beginRecording();
29
30
  //const start = performance.now();
30
31
 
31
32
  const ctx = (0, _DrawingContext.createDrawingContext)(Skia, recording.paintPool, canvas);
32
- (0, _Player.replay)(ctx, recording.commands);
33
- const picture = rec.finishRecordingAsPicture();
34
- rec.dispose();
33
+ let picture;
34
+ try {
35
+ (0, _Player.replay)(ctx, recording.commands);
36
+ picture = rec.finishRecordingAsPicture();
37
+ } finally {
38
+ // Frame-scoped objects (shaders, filters, paint copies, ...) are
39
+ // referenced by the picture once it is finished — delete the JS handles,
40
+ // otherwise they leak on Web where the GC cannot see WASM memory.
41
+ ctx.dispose();
42
+ rec.dispose();
43
+ }
35
44
  //const end = performance.now();
36
45
  //console.log("Recording time: ", end - start);
37
46
  SkiaViewApi.setJsiProperty(nativeId, "picture", picture);
47
+ // The view now references the new picture; the previous one is ours to
48
+ // delete.
49
+ (_recording$lastPictur = recording.lastPicture) === null || _recording$lastPictur === void 0 || _recording$lastPictur.dispose();
50
+ recording.lastPicture = picture;
38
51
  };
39
52
  class ReanimatedContainer extends _StaticContainer.Container {
40
53
  constructor(Skia, nativeId) {
@@ -42,13 +55,38 @@ class ReanimatedContainer extends _StaticContainer.Container {
42
55
  this.nativeId = nativeId;
43
56
  _defineProperty(this, "mapperId", null);
44
57
  }
58
+ unmount() {
59
+ super.unmount();
60
+ if (this.mapperId !== null) {
61
+ // The mapper closure retains the recording and keeps updating the
62
+ // picture of an unmounted view — stop it or it leaks for the
63
+ // lifetime of the app.
64
+ _ReanimatedProxy.default.stopMapper(this.mapperId);
65
+ this.mapperId = null;
66
+ }
67
+ const {
68
+ recording
69
+ } = this;
70
+ if (recording) {
71
+ this.recording = null;
72
+ // Deferred through the same channel as the draw calls so it runs after
73
+ // any of them that are still queued.
74
+ _ReanimatedProxy.default.runOnUI(() => {
75
+ "worklet";
76
+
77
+ (0, _Recorder.disposeRecording)(recording);
78
+ })();
79
+ }
80
+ }
45
81
  redraw() {
46
82
  if (this.mapperId !== null) {
47
83
  _ReanimatedProxy.default.stopMapper(this.mapperId);
84
+ this.mapperId = null;
48
85
  }
49
86
  if (this.unmounted) {
50
87
  return;
51
88
  }
89
+ const previousRecording = this.recording;
52
90
  const recorder = new _Recorder.Recorder();
53
91
  (0, _Visitor.visit)(recorder, this.root);
54
92
  const record = recorder.getRecording();
@@ -74,6 +112,10 @@ class ReanimatedContainer extends _StaticContainer.Container {
74
112
  _ReanimatedProxy.default.runOnUI(() => {
75
113
  "worklet";
76
114
 
115
+ if (previousRecording) {
116
+ // Runs after any still-queued draw of the previous recording.
117
+ (0, _Recorder.disposeRecording)(previousRecording);
118
+ }
77
119
  drawOnscreen(Skia, nativeId, recording);
78
120
  })();
79
121
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_ReanimatedProxy","_interopRequireDefault","require","_renderHelpers","_Recorder","_Visitor","_Player","_DrawingContext","_StaticContainer","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","SkiaViewApi","globalThis","drawOnscreen","Skia","nativeId","recording","rec","PictureRecorder","canvas","beginRecording","ctx","createDrawingContext","paintPool","replay","commands","picture","finishRecordingAsPicture","dispose","setJsiProperty","ReanimatedContainer","Container","constructor","redraw","mapperId","Rea","stopMapper","unmounted","recorder","Recorder","visit","root","record","getRecording","animationValues","size","startMapper","Array","from","runOnUI","createContainer","HAS_REANIMATED_3","StaticContainer","exports"],"sources":["Container.web.ts"],"sourcesContent":["import Rea from \"../external/reanimated/ReanimatedProxy\";\nimport type { Skia } from \"../skia/types\";\nimport { HAS_REANIMATED_3 } from \"../external/reanimated/renderHelpers\";\n\nimport type { Recording } from \"./Recorder/Recorder\";\nimport { Recorder } from \"./Recorder/Recorder\";\nimport { visit } from \"./Recorder/Visitor\";\nimport { replay } from \"./Recorder/Player\";\nimport { createDrawingContext } from \"./Recorder/DrawingContext\";\nimport { Container, StaticContainer } from \"./StaticContainer\";\n\nimport \"../skia/NativeSetup\";\nimport \"../views/api\";\n\n// create local reference for `strictGlobal` option in Worklets\nconst { SkiaViewApi } = globalThis;\n\nconst drawOnscreen = (Skia: Skia, nativeId: number, recording: Recording) => {\n \"worklet\";\n const rec = Skia.PictureRecorder();\n const canvas = rec.beginRecording();\n //const start = performance.now();\n\n const ctx = createDrawingContext(Skia, recording.paintPool, canvas);\n replay(ctx, recording.commands);\n const picture = rec.finishRecordingAsPicture();\n rec.dispose();\n //const end = performance.now();\n //console.log(\"Recording time: \", end - start);\n SkiaViewApi.setJsiProperty(nativeId, \"picture\", picture);\n};\n\nclass ReanimatedContainer extends Container {\n private mapperId: number | null = null;\n\n constructor(\n Skia: Skia,\n private nativeId: number\n ) {\n super(Skia);\n }\n\n redraw() {\n if (this.mapperId !== null) {\n Rea.stopMapper(this.mapperId);\n }\n if (this.unmounted) {\n return;\n }\n const recorder = new Recorder();\n visit(recorder, this.root);\n const record = recorder.getRecording();\n const { animationValues } = record;\n this.recording = {\n commands: record.commands,\n paintPool: record.paintPool,\n };\n const { nativeId, Skia, recording } = this;\n if (animationValues.size > 0) {\n this.mapperId = Rea.startMapper(() => {\n \"worklet\";\n drawOnscreen(Skia, nativeId, recording!);\n }, Array.from(animationValues));\n }\n Rea.runOnUI(() => {\n \"worklet\";\n drawOnscreen(Skia, nativeId, recording!);\n })();\n }\n}\n\nexport const createContainer = (Skia: Skia, nativeId: number) => {\n if (HAS_REANIMATED_3 && nativeId !== -1) {\n return new ReanimatedContainer(Skia, nativeId);\n } else {\n return new StaticContainer(Skia, nativeId);\n }\n};\n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I;MAAEE;IAAU,CAAC,GAAG,IAAI;IAC1C,IAAI4B,eAAe,CAACC,IAAI,GAAG,CAAC,EAAE;MAC5B,IAAI,CAACX,QAAQ,GAAGC,wBAAG,CAACW,WAAW,CAAC,MAAM;QACpC,SAAS;;QACTjC,YAAY,CAACC,IAAI,EAAEC,QAAQ,EAAEC,SAAU,CAAC;MAC1C,CAAC,EAAE+B,KAAK,CAACC,IAAI,CAACJ,eAAe,CAAC,CAAC;IACjC;IACAT,wBAAG,CAACc,OAAO,CAAC,MAAM;MAChB,SAAS;;MACTpC,YAAY,CAACC,IAAI,EAAEC,QAAQ,EAAEC,SAAU,CAAC;IAC1C,CAAC,CAAC,CAAC,CAAC;EACN;AACF;AAEO,MAAMkC,eAAe,GAAGA,CAACpC,IAAU,EAAEC,QAAgB,KAAK;EAC/D,IAAIoC,+BAAgB,IAAIpC,QAAQ,KAAK,CAAC,CAAC,EAAE;IACvC,OAAO,IAAIe,mBAAmB,CAAChB,IAAI,EAAEC,QAAQ,CAAC;EAChD,CAAC,MAAM;IACL,OAAO,IAAIqC,gCAAe,CAACtC,IAAI,EAAEC,QAAQ,CAAC;EAC5C;AACF,CAAC;AAACsC,OAAA,CAAAH,eAAA,GAAAA,eAAA","ignoreList":[]}
1
+ {"version":3,"names":["_ReanimatedProxy","_interopRequireDefault","require","_renderHelpers","_Recorder","_Visitor","_Player","_DrawingContext","_StaticContainer","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","SkiaViewApi","globalThis","drawOnscreen","Skia","nativeId","recording","_recording$lastPictur","rec","PictureRecorder","canvas","beginRecording","ctx","createDrawingContext","paintPool","picture","replay","commands","finishRecordingAsPicture","dispose","setJsiProperty","lastPicture","ReanimatedContainer","Container","constructor","unmount","mapperId","Rea","stopMapper","runOnUI","disposeRecording","redraw","unmounted","previousRecording","recorder","Recorder","visit","root","record","getRecording","animationValues","size","startMapper","Array","from","createContainer","HAS_REANIMATED_3","StaticContainer","exports"],"sources":["Container.web.ts"],"sourcesContent":["import Rea from \"../external/reanimated/ReanimatedProxy\";\nimport type { Skia } from \"../skia/types\";\nimport { HAS_REANIMATED_3 } from \"../external/reanimated/renderHelpers\";\n\nimport type { Recording } from \"./Recorder/Recorder\";\nimport { Recorder, disposeRecording } from \"./Recorder/Recorder\";\nimport { visit } from \"./Recorder/Visitor\";\nimport { replay } from \"./Recorder/Player\";\nimport { createDrawingContext } from \"./Recorder/DrawingContext\";\nimport { Container, StaticContainer } from \"./StaticContainer\";\n\nimport \"../skia/NativeSetup\";\nimport \"../views/api\";\n\n// create local reference for `strictGlobal` option in Worklets\nconst { SkiaViewApi } = globalThis;\n\nconst drawOnscreen = (Skia: Skia, nativeId: number, recording: Recording) => {\n \"worklet\";\n const rec = Skia.PictureRecorder();\n const canvas = rec.beginRecording();\n //const start = performance.now();\n\n const ctx = createDrawingContext(Skia, recording.paintPool, canvas);\n let picture;\n try {\n replay(ctx, recording.commands);\n picture = rec.finishRecordingAsPicture();\n } finally {\n // Frame-scoped objects (shaders, filters, paint copies, ...) are\n // referenced by the picture once it is finished — delete the JS handles,\n // otherwise they leak on Web where the GC cannot see WASM memory.\n ctx.dispose();\n rec.dispose();\n }\n //const end = performance.now();\n //console.log(\"Recording time: \", end - start);\n SkiaViewApi.setJsiProperty(nativeId, \"picture\", picture);\n // The view now references the new picture; the previous one is ours to\n // delete.\n recording.lastPicture?.dispose();\n recording.lastPicture = picture;\n};\n\nclass ReanimatedContainer extends Container {\n private mapperId: number | null = null;\n\n constructor(\n Skia: Skia,\n private nativeId: number\n ) {\n super(Skia);\n }\n\n unmount() {\n super.unmount();\n if (this.mapperId !== null) {\n // The mapper closure retains the recording and keeps updating the\n // picture of an unmounted view — stop it or it leaks for the\n // lifetime of the app.\n Rea.stopMapper(this.mapperId);\n this.mapperId = null;\n }\n const { recording } = this;\n if (recording) {\n this.recording = null;\n // Deferred through the same channel as the draw calls so it runs after\n // any of them that are still queued.\n Rea.runOnUI(() => {\n \"worklet\";\n disposeRecording(recording);\n })();\n }\n }\n\n redraw() {\n if (this.mapperId !== null) {\n Rea.stopMapper(this.mapperId);\n this.mapperId = null;\n }\n if (this.unmounted) {\n return;\n }\n const previousRecording = this.recording;\n const recorder = new Recorder();\n visit(recorder, this.root);\n const record = recorder.getRecording();\n const { animationValues } = record;\n this.recording = {\n commands: record.commands,\n paintPool: record.paintPool,\n };\n const { nativeId, Skia, recording } = this;\n if (animationValues.size > 0) {\n this.mapperId = Rea.startMapper(() => {\n \"worklet\";\n drawOnscreen(Skia, nativeId, recording!);\n }, Array.from(animationValues));\n }\n Rea.runOnUI(() => {\n \"worklet\";\n if (previousRecording) {\n // Runs after any still-queued draw of the previous recording.\n disposeRecording(previousRecording);\n }\n drawOnscreen(Skia, nativeId, recording!);\n })();\n }\n}\n\nexport const createContainer = (Skia: Skia, nativeId: number) => {\n if (HAS_REANIMATED_3 && nativeId !== -1) {\n return new ReanimatedContainer(Skia, nativeId);\n } else {\n return new StaticContainer(Skia, nativeId);\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,cAAA,GAAAD,OAAA;AAGA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,eAAA,GAAAL,OAAA;AACA,IAAAM,gBAAA,GAAAN,OAAA;AAEAA,OAAA;AACAA,OAAA;AAAsB,SAAAD,uBAAAQ,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,gBAAAH,CAAA,EAAAI,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAJ,CAAA,GAAAO,MAAA,CAAAC,cAAA,CAAAR,CAAA,EAAAI,CAAA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CAACG,IAAI,CAAC;IAC1B,MAAMC,MAAM,GAAGJ,QAAQ,CAACK,YAAY,CAAC,CAAC;IACtC,MAAM;MAAEC;IAAgB,CAAC,GAAGF,MAAM;IAClC,IAAI,CAAChC,SAAS,GAAG;MACfW,QAAQ,EAAEqB,MAAM,CAACrB,QAAQ;MACzBH,SAAS,EAAEwB,MAAM,CAACxB;IACpB,CAAC;IACD,MAAM;MAAET,QAAQ;MAAED,IAAI;MAAEE;IAAU,CAAC,GAAG,IAAI;IAC1C,IAAIkC,eAAe,CAACC,IAAI,GAAG,CAAC,EAAE;MAC5B,IAAI,CAACf,QAAQ,GAAGC,wBAAG,CAACe,WAAW,CAAC,MAAM;QACpC,SAAS;;QACTvC,YAAY,CAACC,IAAI,EAAEC,QAAQ,EAAEC,SAAU,CAAC;MAC1C,CAAC,EAAEqC,KAAK,CAACC,IAAI,CAACJ,eAAe,CAAC,CAAC;IACjC;IACAb,wBAAG,CAACE,OAAO,CAAC,MAAM;MAChB,SAAS;;MACT,IAAII,iBAAiB,EAAE;QACrB;QACA,IAAAH,0BAAgB,EAACG,iBAAiB,CAAC;MACrC;MACA9B,YAAY,CAACC,IAAI,EAAEC,QAAQ,EAAEC,SAAU,CAAC;IAC1C,CAAC,CAAC,CAAC,CAAC;EACN;AACF;AAEO,MAAMuC,eAAe,GAAGA,CAACzC,IAAU,EAAEC,QAAgB,KAAK;EAC/D,IAAIyC,+BAAgB,IAAIzC,QAAQ,KAAK,CAAC,CAAC,EAAE;IACvC,OAAO,IAAIiB,mBAAmB,CAAClB,IAAI,EAAEC,QAAQ,CAAC;EAChD,CAAC,MAAM;IACL,OAAO,IAAI0C,gCAAe,CAAC3C,IAAI,EAAEC,QAAQ,CAAC;EAC5C;AACF,CAAC;AAAC2C,OAAA,CAAAH,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -2,6 +2,8 @@ import type { Skia, SkCanvas, SkColorFilter, SkPaint, SkShader, SkImageFilter, S
2
2
  export declare const createDrawingContext: (Skia: Skia, paintPool: SkPaint[], canvas: SkCanvas) => {
3
3
  Skia: Skia;
4
4
  canvas: SkCanvas;
5
+ track: <T>(value: T) => T;
6
+ dispose: () => void;
5
7
  paints: SkPaint[];
6
8
  colorFilters: SkColorFilter[];
7
9
  shaders: SkShader[];
@@ -4,9 +4,19 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createDrawingContext = void 0;
7
+ var _FrameScope = require("./FrameScope");
7
8
  const createDrawingContext = (Skia, paintPool, canvas) => {
8
9
  "worklet";
9
10
 
11
+ // Everything the renderer creates through frameSkia is frame-scoped and
12
+ // deleted by dispose() once the frame has been recorded. The paint pool is
13
+ // recording-scoped and deliberately allocated with the raw Skia instance.
14
+ const {
15
+ Skia: frameSkia,
16
+ track,
17
+ dispose
18
+ } = (0, _FrameScope.createFrameScope)(Skia);
19
+
10
20
  // State (formerly class fields)
11
21
  const paints = [];
12
22
  const colorFilters = [];
@@ -18,7 +28,11 @@ const createDrawingContext = (Skia, paintPool, canvas) => {
18
28
  let nextPaintIndex = 1;
19
29
 
20
30
  // Initialize first paint and opacity
21
- paintPool[0] = Skia.Paint();
31
+ if (paintPool.length === 0) {
32
+ paintPool.push(Skia.Paint());
33
+ } else {
34
+ paintPool[0].reset();
35
+ }
22
36
  paints.push(paintPool[0]);
23
37
  opacities.push(1);
24
38
 
@@ -48,7 +62,7 @@ const createDrawingContext = (Skia, paintPool, canvas) => {
48
62
  } else {
49
63
  const cf = colorFilters.pop();
50
64
  if (cf) {
51
- imageFilter = Skia.ImageFilter.MakeColorFilter(cf, null);
65
+ imageFilter = frameSkia.ImageFilter.MakeColorFilter(cf, null);
52
66
  }
53
67
  }
54
68
  canvas.saveLayer(undefined, null, imageFilter);
@@ -66,7 +80,7 @@ const createDrawingContext = (Skia, paintPool, canvas) => {
66
80
  const materializePaint = () => {
67
81
  // Color Filters
68
82
  if (colorFilters.length > 0) {
69
- getCurrentPaint().setColorFilter(colorFilters.reduceRight((inner, outer) => inner ? Skia.ColorFilter.MakeCompose(outer, inner) : outer));
83
+ getCurrentPaint().setColorFilter(colorFilters.reduceRight((inner, outer) => inner ? frameSkia.ColorFilter.MakeCompose(outer, inner) : outer));
70
84
  }
71
85
  // Shaders
72
86
  if (shaders.length > 0) {
@@ -74,12 +88,12 @@ const createDrawingContext = (Skia, paintPool, canvas) => {
74
88
  }
75
89
  // Image Filters
76
90
  if (imageFilters.length > 0) {
77
- getCurrentPaint().setImageFilter(imageFilters.reduceRight((inner, outer) => inner ? Skia.ImageFilter.MakeCompose(outer, inner) : outer));
91
+ getCurrentPaint().setImageFilter(imageFilters.reduceRight((inner, outer) => inner ? frameSkia.ImageFilter.MakeCompose(outer, inner) : outer));
78
92
  }
79
93
 
80
94
  // Path Effects
81
95
  if (pathEffects.length > 0) {
82
- getCurrentPaint().setPathEffect(pathEffects.reduceRight((inner, outer) => inner ? Skia.PathEffect.MakeCompose(outer, inner) : outer));
96
+ getCurrentPaint().setPathEffect(pathEffects.reduceRight((inner, outer) => inner ? frameSkia.PathEffect.MakeCompose(outer, inner) : outer));
83
97
  }
84
98
 
85
99
  // Clear arrays
@@ -92,8 +106,10 @@ const createDrawingContext = (Skia, paintPool, canvas) => {
92
106
  // Return an object containing the Skia reference, the canvas, and the methods
93
107
  return {
94
108
  // Public fields
95
- Skia,
109
+ Skia: frameSkia,
96
110
  canvas,
111
+ track,
112
+ dispose,
97
113
  paints,
98
114
  colorFilters,
99
115
  shaders,
@@ -1 +1 @@
1
- {"version":3,"names":["createDrawingContext","Skia","paintPool","canvas","paints","colorFilters","shaders","imageFilters","pathEffects","paintDeclarations","opacities","nextPaintIndex","Paint","push","savePaint","length","nextPaint","assign","getCurrentPaint","getOpacity","setOpacity","newOpacity","Math","max","min","saveBackdropFilter","imageFilter","imgf","pop","cf","ImageFilter","MakeColorFilter","saveLayer","undefined","restore","restorePaint","materializePaint","setColorFilter","reduceRight","inner","outer","ColorFilter","MakeCompose","setShader","setImageFilter","setPathEffect","PathEffect","paint","exports"],"sources":["DrawingContext.ts"],"sourcesContent":["import type {\n Skia,\n SkCanvas,\n SkColorFilter,\n SkPaint,\n SkShader,\n SkImageFilter,\n SkPathEffect,\n} from \"../../skia/types\";\n\nexport const createDrawingContext = (\n Skia: Skia,\n paintPool: SkPaint[],\n canvas: SkCanvas\n) => {\n \"worklet\";\n\n // State (formerly class fields)\n const paints: SkPaint[] = [];\n const colorFilters: SkColorFilter[] = [];\n const shaders: SkShader[] = [];\n const imageFilters: SkImageFilter[] = [];\n const pathEffects: SkPathEffect[] = [];\n const paintDeclarations: SkPaint[] = [];\n const opacities: number[] = [];\n\n let nextPaintIndex = 1;\n\n // Initialize first paint and opacity\n paintPool[0] = Skia.Paint();\n paints.push(paintPool[0]);\n opacities.push(1);\n\n // Methods (formerly class methods)\n const savePaint = () => {\n // Get next available paint from pool or create new one if needed\n if (nextPaintIndex >= paintPool.length) {\n paintPool.push(Skia.Paint());\n }\n\n const nextPaint = paintPool[nextPaintIndex];\n nextPaint.assign(getCurrentPaint()); // Reuse allocation by copying properties\n paints.push(nextPaint);\n opacities.push(opacities[opacities.length - 1]);\n nextPaintIndex++;\n };\n\n const getOpacity = () => {\n return opacities[opacities.length - 1];\n };\n\n const setOpacity = (newOpacity: number) => {\n opacities[opacities.length - 1] = Math.max(0, Math.min(1, newOpacity));\n };\n\n const saveBackdropFilter = () => {\n let imageFilter: SkImageFilter | null = null;\n const imgf = imageFilters.pop();\n if (imgf) {\n imageFilter = imgf;\n } else {\n const cf = colorFilters.pop();\n if (cf) {\n imageFilter = Skia.ImageFilter.MakeColorFilter(cf, null);\n }\n }\n canvas.saveLayer(undefined, null, imageFilter);\n canvas.restore();\n };\n\n // Equivalent to the `get paint()` getter in the original class\n const getCurrentPaint = () => {\n return paints[paints.length - 1];\n };\n\n const restorePaint = () => {\n opacities.pop();\n return paints.pop();\n };\n\n const materializePaint = () => {\n // Color Filters\n if (colorFilters.length > 0) {\n getCurrentPaint().setColorFilter(\n colorFilters.reduceRight((inner, outer) =>\n inner ? Skia.ColorFilter.MakeCompose(outer, inner) : outer\n )\n );\n }\n // Shaders\n if (shaders.length > 0) {\n getCurrentPaint().setShader(shaders[shaders.length - 1]);\n }\n // Image Filters\n if (imageFilters.length > 0) {\n getCurrentPaint().setImageFilter(\n imageFilters.reduceRight((inner, outer) =>\n inner ? Skia.ImageFilter.MakeCompose(outer, inner) : outer\n )\n );\n }\n\n // Path Effects\n if (pathEffects.length > 0) {\n getCurrentPaint().setPathEffect(\n pathEffects.reduceRight((inner, outer) =>\n inner ? Skia.PathEffect.MakeCompose(outer, inner) : outer\n )\n );\n }\n\n // Clear arrays\n colorFilters.length = 0;\n shaders.length = 0;\n imageFilters.length = 0;\n pathEffects.length = 0;\n };\n\n // Return an object containing the Skia reference, the canvas, and the methods\n return {\n // Public fields\n Skia,\n canvas,\n paints,\n colorFilters,\n shaders,\n imageFilters,\n pathEffects,\n paintDeclarations,\n paintPool,\n\n // Public methods\n savePaint,\n saveBackdropFilter,\n get paint() {\n return paints[paints.length - 1];\n }, // the \"getter\" for the current paint\n restorePaint,\n materializePaint,\n getOpacity,\n setOpacity,\n };\n};\n\nexport type DrawingContext = ReturnType<typeof createDrawingContext>;\n"],"mappings":";;;;;;AAUO,MAAMA,oBAAoB,GAAGA,CAClCC,IAAU,EACVC,SAAoB,EACpBC,MAAgB,KACb;EACH,SAAS;;EAET;EACA,MAAMC,MAAiB,GAAG,EAAE;EAC5B,MAAMC,YAA6B,GAAG,EAAE;EACxC,MAAMC,OAAmB,GAAG,EAAE;EAC9B,MAAMC,YAA6B,GAAG,EAAE;EACxC,MAAMC,WAA2B,GAAG,EAAE;EACtC,MAAMC,iBAA4B,GAAG,EAAE;EACvC,MAAMC,SAAmB,GAAG,EAAE;EAE9B,IAAIC,cAAc,GAAG,CAAC;;EAEtB;EACAT,SAAS,CAAC,CAAC,CAAC,GAAGD,IAAI,CAACW,KAAK,CAAC,CAAC;EAC3BR,MAAM,CAACS,IAAI,CAACX,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AC8B,WAAW,CAAC,CAACC,KAAK,EAAEC,KAAK,KACnCD,KAAK,GAAGtC,IAAI,CAAC6C,UAAU,CAACJ,WAAW,CAACF,KAAK,EAAED,KAAK,CAAC,GAAGC,KACtD,CACF,CAAC;IACH;;IAEA;IACAnC,YAAY,CAACU,MAAM,GAAG,CAAC;IACvBT,OAAO,CAACS,MAAM,GAAG,CAAC;IAClBR,YAAY,CAACQ,MAAM,GAAG,CAAC;IACvBP,WAAW,CAACO,MAAM,GAAG,CAAC;EACxB,CAAC;;EAED;EACA,OAAO;IACL;IACAd,IAAI;IACJE,MAAM;IACNC,MAAM;IACNC,YAAY;IACZC,OAAO;IACPC,YAAY;IACZC,WAAW;IACXC,iBAAiB;IACjBP,SAAS;IAET;IACAY,SAAS;IACTW,kBAAkB;IAClB,IAAIsB,KAAKA,CAAA,EAAG;MACV,OAAO3C,MAAM,CAACA,MAAM,CAACW,MAAM,GAAG,CAAC,CAAC;IAClC,CAAC;IAAE;IACHoB,YAAY;IACZC,gBAAgB;IAChBjB,UAAU;IACVC;EACF,CAAC;AACH,CAAC;AAAC4B,OAAA,CAAAhD,oBAAA,GAAAA,oBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_FrameScope","require","createDrawingContext","Skia","paintPool","canvas","frameSkia","track","dispose","createFrameScope","paints","colorFilters","shaders","imageFilters","pathEffects","paintDeclarations","opacities","nextPaintIndex","length","push","Paint","reset","savePaint","nextPaint","assign","getCurrentPaint","getOpacity","setOpacity","newOpacity","Math","max","min","saveBackdropFilter","imageFilter","imgf","pop","cf","ImageFilter","MakeColorFilter","saveLayer","undefined","restore","restorePaint","materializePaint","setColorFilter","reduceRight","inner","outer","ColorFilter","MakeCompose","setShader","setImageFilter","setPathEffect","PathEffect","paint","exports"],"sources":["DrawingContext.ts"],"sourcesContent":["import type {\n Skia,\n SkCanvas,\n SkColorFilter,\n SkPaint,\n SkShader,\n SkImageFilter,\n SkPathEffect,\n} from \"../../skia/types\";\n\nimport { createFrameScope } from \"./FrameScope\";\n\nexport const createDrawingContext = (\n Skia: Skia,\n paintPool: SkPaint[],\n canvas: SkCanvas\n) => {\n \"worklet\";\n\n // Everything the renderer creates through frameSkia is frame-scoped and\n // deleted by dispose() once the frame has been recorded. The paint pool is\n // recording-scoped and deliberately allocated with the raw Skia instance.\n const { Skia: frameSkia, track, dispose } = createFrameScope(Skia);\n\n // State (formerly class fields)\n const paints: SkPaint[] = [];\n const colorFilters: SkColorFilter[] = [];\n const shaders: SkShader[] = [];\n const imageFilters: SkImageFilter[] = [];\n const pathEffects: SkPathEffect[] = [];\n const paintDeclarations: SkPaint[] = [];\n const opacities: number[] = [];\n\n let nextPaintIndex = 1;\n\n // Initialize first paint and opacity\n if (paintPool.length === 0) {\n paintPool.push(Skia.Paint());\n } else {\n paintPool[0].reset();\n }\n paints.push(paintPool[0]);\n opacities.push(1);\n\n // Methods (formerly class methods)\n const savePaint = () => {\n // Get next available paint from pool or create new one if needed\n if (nextPaintIndex >= paintPool.length) {\n paintPool.push(Skia.Paint());\n }\n\n const nextPaint = paintPool[nextPaintIndex];\n nextPaint.assign(getCurrentPaint()); // Reuse allocation by copying properties\n paints.push(nextPaint);\n opacities.push(opacities[opacities.length - 1]);\n nextPaintIndex++;\n };\n\n const getOpacity = () => {\n return opacities[opacities.length - 1];\n };\n\n const setOpacity = (newOpacity: number) => {\n opacities[opacities.length - 1] = Math.max(0, Math.min(1, newOpacity));\n };\n\n const saveBackdropFilter = () => {\n let imageFilter: SkImageFilter | null = null;\n const imgf = imageFilters.pop();\n if (imgf) {\n imageFilter = imgf;\n } else {\n const cf = colorFilters.pop();\n if (cf) {\n imageFilter = frameSkia.ImageFilter.MakeColorFilter(cf, null);\n }\n }\n canvas.saveLayer(undefined, null, imageFilter);\n canvas.restore();\n };\n\n // Equivalent to the `get paint()` getter in the original class\n const getCurrentPaint = () => {\n return paints[paints.length - 1];\n };\n\n const restorePaint = () => {\n opacities.pop();\n return paints.pop();\n };\n\n const materializePaint = () => {\n // Color Filters\n if (colorFilters.length > 0) {\n getCurrentPaint().setColorFilter(\n colorFilters.reduceRight((inner, outer) =>\n inner ? frameSkia.ColorFilter.MakeCompose(outer, inner) : outer\n )\n );\n }\n // Shaders\n if (shaders.length > 0) {\n getCurrentPaint().setShader(shaders[shaders.length - 1]);\n }\n // Image Filters\n if (imageFilters.length > 0) {\n getCurrentPaint().setImageFilter(\n imageFilters.reduceRight((inner, outer) =>\n inner ? frameSkia.ImageFilter.MakeCompose(outer, inner) : outer\n )\n );\n }\n\n // Path Effects\n if (pathEffects.length > 0) {\n getCurrentPaint().setPathEffect(\n pathEffects.reduceRight((inner, outer) =>\n inner ? frameSkia.PathEffect.MakeCompose(outer, inner) : outer\n )\n );\n }\n\n // Clear arrays\n colorFilters.length = 0;\n shaders.length = 0;\n imageFilters.length = 0;\n pathEffects.length = 0;\n };\n\n // Return an object containing the Skia reference, the canvas, and the methods\n return {\n // Public fields\n Skia: frameSkia,\n canvas,\n track,\n dispose,\n paints,\n colorFilters,\n shaders,\n imageFilters,\n pathEffects,\n paintDeclarations,\n paintPool,\n\n // Public methods\n savePaint,\n saveBackdropFilter,\n get paint() {\n return paints[paints.length - 1];\n }, // the \"getter\" for the current paint\n restorePaint,\n materializePaint,\n getOpacity,\n setOpacity,\n };\n};\n\nexport type DrawingContext = ReturnType<typeof createDrawingContext>;\n"],"mappings":";;;;;;AAUA,IAAAA,WAAA,GAAAC,OAAA;AAEO,MAAMC,oBAAoB,GAAGA,CAClCC,IAAU,EACVC,SAAoB,EACpBC,MAAgB,KACb;EACH,SAAS;;EAET;EACA;EACA;EACA,MAAM;IAAEF,IAAI,EAAEG,SAAS;IAAEC,KAAK;IAAEC;EAAQ,CAAC,GAAG,IAAAC,4BAAgB,EAACN,IAAI,CAAC;;EAElE;EACA,MAAMO,MAAiB,GAAG,EAAE;EAC5B,MAAMC,YAA6B,GAAG,EAAE;EACxC,MAAMC,OAAmB,GAAG,EAAE;EAC9B,MAAMC,YAA6B,GAAG,EAAE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AIL,YAAY,CAACK,MAAM,GAAG,CAAC,EAAE;MAC3BO,eAAe,CAAC,CAAC,CAAC0B,cAAc,CAC9BtC,YAAY,CAACgC,WAAW,CAAC,CAACC,KAAK,EAAEC,KAAK,KACpCD,KAAK,GAAGxC,SAAS,CAAC+B,WAAW,CAACY,WAAW,CAACF,KAAK,EAAED,KAAK,CAAC,GAAGC,KAC5D,CACF,CAAC;IACH;;IAEA;IACA,IAAIjC,WAAW,CAACI,MAAM,GAAG,CAAC,EAAE;MAC1BO,eAAe,CAAC,CAAC,CAAC2B,aAAa,CAC7BtC,WAAW,CAAC+B,WAAW,CAAC,CAACC,KAAK,EAAEC,KAAK,KACnCD,KAAK,GAAGxC,SAAS,CAAC+C,UAAU,CAACJ,WAAW,CAACF,KAAK,EAAED,KAAK,CAAC,GAAGC,KAC3D,CACF,CAAC;IACH;;IAEA;IACApC,YAAY,CAACO,MAAM,GAAG,CAAC;IACvBN,OAAO,CAACM,MAAM,GAAG,CAAC;IAClBL,YAAY,CAACK,MAAM,GAAG,CAAC;IACvBJ,WAAW,CAACI,MAAM,GAAG,CAAC;EACxB,CAAC;;EAED;EACA,OAAO;IACL;IACAf,IAAI,EAAEG,SAAS;IACfD,MAAM;IACNE,KAAK;IACLC,OAAO;IACPE,MAAM;IACNC,YAAY;IACZC,OAAO;IACPC,YAAY;IACZC,WAAW;IACXC,iBAAiB;IACjBX,SAAS;IAET;IACAkB,SAAS;IACTU,kBAAkB;IAClB,IAAIsB,KAAKA,CAAA,EAAG;MACV,OAAO5C,MAAM,CAACA,MAAM,CAACQ,MAAM,GAAG,CAAC,CAAC;IAClC,CAAC;IAAE;IACHwB,YAAY;IACZC,gBAAgB;IAChBjB,UAAU;IACVC;EACF,CAAC;AACH,CAAC;AAAC4B,OAAA,CAAArD,oBAAA,GAAAA,oBAAA","ignoreList":[]}
@@ -0,0 +1,18 @@
1
+ import type { Skia } from "../../skia/types";
2
+ export interface FrameScope {
3
+ Skia: Skia;
4
+ track: <T>(value: T) => T;
5
+ dispose: () => void;
6
+ }
7
+ /**
8
+ * Wraps a Skia instance so that every object created through its factories is
9
+ * collected and deleted when the scope is disposed. The renderer only keeps
10
+ * the objects it creates alive for the duration of a frame: once the frame
11
+ * has been recorded they can be deleted. This is required on Web where
12
+ * CanvasKit objects live in WASM memory that the JS garbage collector does
13
+ * not perceive, so it (almost) never reclaims them on its own.
14
+ *
15
+ * Objects passed in via props are user-owned: they are not created through
16
+ * this facade and are therefore never tracked nor disposed.
17
+ */
18
+ export declare const createFrameScope: (Skia: Skia) => FrameScope;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createFrameScope = void 0;
7
+ const isDisposable = value => {
8
+ "worklet";
9
+
10
+ return value !== null && typeof value === "object" && typeof value.dispose === "function";
11
+ };
12
+ /**
13
+ * Wraps a Skia instance so that every object created through its factories is
14
+ * collected and deleted when the scope is disposed. The renderer only keeps
15
+ * the objects it creates alive for the duration of a frame: once the frame
16
+ * has been recorded they can be deleted. This is required on Web where
17
+ * CanvasKit objects live in WASM memory that the JS garbage collector does
18
+ * not perceive, so it (almost) never reclaims them on its own.
19
+ *
20
+ * Objects passed in via props are user-owned: they are not created through
21
+ * this facade and are therefore never tracked nor disposed.
22
+ */
23
+ const createFrameScope = Skia => {
24
+ "worklet";
25
+
26
+ const disposables = [];
27
+ const track = value => {
28
+ if (isDisposable(value)) {
29
+ disposables.push(value);
30
+ }
31
+ return value;
32
+ };
33
+ const wrap = obj => {
34
+ const cache = new Map();
35
+ return new Proxy(obj, {
36
+ get(target, prop) {
37
+ if (cache.has(prop)) {
38
+ return cache.get(prop);
39
+ }
40
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
+ const value = target[prop];
42
+ let wrapped = value;
43
+ if (typeof value === "function") {
44
+ wrapped = (...args) => track(value.apply(target, args));
45
+ } else if (value !== null && typeof value === "object") {
46
+ wrapped = wrap(value);
47
+ }
48
+ cache.set(prop, wrapped);
49
+ return wrapped;
50
+ }
51
+ });
52
+ };
53
+ const dispose = () => {
54
+ for (let i = 0; i < disposables.length; i++) {
55
+ disposables[i].dispose();
56
+ }
57
+ disposables.length = 0;
58
+ };
59
+ return {
60
+ Skia: wrap(Skia),
61
+ track,
62
+ dispose
63
+ };
64
+ };
65
+ exports.createFrameScope = createFrameScope;
66
+ //# sourceMappingURL=FrameScope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["isDisposable","value","dispose","createFrameScope","Skia","disposables","track","push","wrap","obj","cache","Map","Proxy","get","target","prop","has","wrapped","args","apply","set","i","length","exports"],"sources":["FrameScope.ts"],"sourcesContent":["import type { Skia } from \"../../skia/types\";\n\ninterface Disposable {\n dispose: () => void;\n}\n\nconst isDisposable = (value: unknown): value is Disposable => {\n \"worklet\";\n return (\n value !== null &&\n typeof value === \"object\" &&\n typeof (value as Disposable).dispose === \"function\"\n );\n};\n\nexport interface FrameScope {\n Skia: Skia;\n track: <T>(value: T) => T;\n dispose: () => void;\n}\n\n/**\n * Wraps a Skia instance so that every object created through its factories is\n * collected and deleted when the scope is disposed. The renderer only keeps\n * the objects it creates alive for the duration of a frame: once the frame\n * has been recorded they can be deleted. This is required on Web where\n * CanvasKit objects live in WASM memory that the JS garbage collector does\n * not perceive, so it (almost) never reclaims them on its own.\n *\n * Objects passed in via props are user-owned: they are not created through\n * this facade and are therefore never tracked nor disposed.\n */\nexport const createFrameScope = (Skia: Skia): FrameScope => {\n \"worklet\";\n const disposables: Disposable[] = [];\n const track = <T>(value: T): T => {\n if (isDisposable(value)) {\n disposables.push(value);\n }\n return value;\n };\n const wrap = <T extends object>(obj: T): T => {\n const cache = new Map<PropertyKey, unknown>();\n return new Proxy(obj, {\n get(target, prop) {\n if (cache.has(prop)) {\n return cache.get(prop);\n }\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const value = (target as any)[prop];\n let wrapped: unknown = value;\n if (typeof value === \"function\") {\n wrapped = (...args: unknown[]) => track(value.apply(target, args));\n } else if (value !== null && typeof value === \"object\") {\n wrapped = wrap(value);\n }\n cache.set(prop, wrapped);\n return wrapped;\n },\n }) as T;\n };\n const dispose = () => {\n for (let i = 0; i < disposables.length; i++) {\n disposables[i].dispose();\n }\n disposables.length = 0;\n };\n return { Skia: wrap(Skia), track, dispose };\n};\n"],"mappings":";;;;;;AAMA,MAAMA,YAAY,GAAIC,KAAc,IAA0B;EAC5D,SAAS;;EACT,OACEA,KAAK,KAAK,IAAI,IACd,OAAOA,KAAK,KAAK,QAAQ,IACzB,OAAQA,KAAK,CAAgBC,OAAO,KAAK,UAAU;AAEvD,CAAC;AAQD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,gBAAgB,GAAIC,IAAU,IAAiB;EAC1D,SAAS;;EACT,MAAMC,WAAyB,GAAG,EAAE;EACpC,MAAMC,KAAK,GAAOL,KAAQ,IAAQ;IAChC,IAAID,YAAY,CAACC,KAAK,CAAC,EAAE;MACvBI,WAAW,CAACE,IAAI,CAACN,KAAK,CAAC;IACzB;IACA,OAAOA,KAAK;EACd,CAAC;EACD,MAAMO,IAAI,GAAsBC,GAAM,IAAQ;IAC5C,MAAMC,KAAK,GAAG,IAAIC,GAAG,CAAuB,CAAC;IAC7C,OAAO,IAAIC,KAAK,CAACH,GAAG,EAAE;MACpBI,GAAGA,CAACC,MAAM,EAAEC,IAAI,EAAE;QAChB,IAAIL,KAAK,CAACM,GAAG,CAACD,IAAI,CAAC,EAAE;UACnB,OAAOL,KAAK,CAACG,GAAG,CAACE,IAAI,CAAC;QACxB;QACA;QACA,MAAMd,KAAK,GAAIa,MAAM,CAASC,IAAI,CAAC;QACnC,IAAIE,OAAgB,GAAGhB,KAAK;QAC5B,IAAI,OAAOA,KAAK,KAAK,UAAU,EAAE;UAC/BgB,OAAO,GAAGA,CAAC,GAAGC,IAAe,KAAKZ,KAAK,CAACL,KAAK,CAACkB,KAAK,CAACL,MAAM,EAAEI,IAAI,CAAC,CAAC;QACpE,CAAC,MAAM,IAAIjB,KAAK,KAAK,IAAI,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;UACtDgB,OAAO,GAAGT,IAAI,CAACP,KAAK,CAAC;QACvB;QACAS,KAAK,CAACU,GAAG,CAACL,IAAI,EAAEE,OAAO,CAAC;QACxB,OAAOA,OAAO;MAChB;IACF,CAAC,CAAC;EACJ,CAAC;EACD,MAAMf,OAAO,GAAGA,CAAA,KAAM;IACpB,KAAK,IAAImB,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGhB,WAAW,CAACiB,MAAM,EAAED,CAAC,EAAE,EAAE;MAC3ChB,WAAW,CAACgB,CAAC,CAAC,CAACnB,OAAO,CAAC,CAAC;IAC1B;IACAG,WAAW,CAACiB,MAAM,GAAG,CAAC;EACxB,CAAC;EACD,OAAO;IAAElB,IAAI,EAAEI,IAAI,CAACJ,IAAI,CAAC;IAAEE,KAAK;IAAEJ;EAAQ,CAAC;AAC7C,CAAC;AAACqB,OAAA,CAAApB,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -0,0 +1,10 @@
1
+ import type { Skia } from "../../skia/types";
2
+ import type { FrameScope } from "./FrameScope";
3
+ /**
4
+ * No-op on native. The JSI wrappers report the size of the native objects
5
+ * they hold to the garbage collector (setExternalMemoryPressure), so the GC
6
+ * is aware of the real cost of the objects the renderer creates and reclaims
7
+ * them on its own. The tracking scope is only needed on Web, where CanvasKit
8
+ * objects live in WASM memory the GC cannot see (see FrameScope.ts).
9
+ */
10
+ export declare const createFrameScope: (Skia: Skia) => FrameScope;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createFrameScope = void 0;
7
+ /**
8
+ * No-op on native. The JSI wrappers report the size of the native objects
9
+ * they hold to the garbage collector (setExternalMemoryPressure), so the GC
10
+ * is aware of the real cost of the objects the renderer creates and reclaims
11
+ * them on its own. The tracking scope is only needed on Web, where CanvasKit
12
+ * objects live in WASM memory the GC cannot see (see FrameScope.ts).
13
+ */
14
+ const createFrameScope = Skia => {
15
+ "worklet";
16
+
17
+ return {
18
+ Skia,
19
+ track: value => value,
20
+ dispose: () => {
21
+ // nothing to dispose: no objects are tracked on native
22
+ }
23
+ };
24
+ };
25
+ exports.createFrameScope = createFrameScope;
26
+ //# sourceMappingURL=FrameScope.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createFrameScope","Skia","track","value","dispose","exports"],"sources":["FrameScope.native.ts"],"sourcesContent":["import type { Skia } from \"../../skia/types\";\n\nimport type { FrameScope } from \"./FrameScope\";\n\n/**\n * No-op on native. The JSI wrappers report the size of the native objects\n * they hold to the garbage collector (setExternalMemoryPressure), so the GC\n * is aware of the real cost of the objects the renderer creates and reclaims\n * them on its own. The tracking scope is only needed on Web, where CanvasKit\n * objects live in WASM memory the GC cannot see (see FrameScope.ts).\n */\nexport const createFrameScope = (Skia: Skia): FrameScope => {\n \"worklet\";\n return {\n Skia,\n track: <T>(value: T): T => value,\n dispose: () => {\n // nothing to dispose: no objects are tracked on native\n },\n };\n};\n"],"mappings":";;;;;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,gBAAgB,GAAIC,IAAU,IAAiB;EAC1D,SAAS;;EACT,OAAO;IACLA,IAAI;IACJC,KAAK,EAAMC,KAAQ,IAAQA,KAAK;IAChCC,OAAO,EAAEA,CAAA,KAAM;MACb;IAAA;EAEJ,CAAC;AACH,CAAC;AAACC,OAAA,CAAAL,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -116,9 +116,8 @@ const play = (ctx, _command) => {
116
116
  } else if ((0, _Core.isCommand)(command, _Core.CommandType.RestoreCTM)) {
117
117
  ctx.canvas.restore();
118
118
  } else {
119
- // TODO: is a copy needed here?
120
119
  // apply opacity to the current paint.
121
- const paint = ctx.paint.copy();
120
+ const paint = ctx.track(ctx.paint.copy());
122
121
  paint.setAlphaf(paint.getAlphaf() * ctx.getOpacity());
123
122
  const paints = [paint, ...ctx.paintDeclarations];
124
123
  ctx.paintDeclarations = [];