@shopify/react-native-skia 0.1.180 → 0.1.182

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. package/android/build.gradle +6 -1
  2. package/cpp/api/JsiSkData.h +7 -0
  3. package/cpp/api/JsiSkImage.h +7 -1
  4. package/cpp/api/JsiSkSVG.h +7 -0
  5. package/cpp/api/JsiSkTypeface.h +7 -0
  6. package/cpp/jsi/RuntimeAwareCache.cpp +0 -2
  7. package/cpp/rnskia/RNSkDomView.cpp +2 -2
  8. package/cpp/rnskia/RNSkPlatformContext.h +2 -2
  9. package/cpp/rnskia/dom/base/DerivedNodeProp.h +1 -1
  10. package/cpp/rnskia/dom/base/JsiDependencyManager.h +10 -6
  11. package/cpp/rnskia/dom/base/JsiDomNode.h +133 -78
  12. package/cpp/rnskia/dom/base/JsiDomRenderNode.h +17 -5
  13. package/cpp/rnskia/dom/base/NodeProp.h +5 -5
  14. package/cpp/rnskia/dom/base/NodePropsContainer.h +8 -2
  15. package/cpp/rnskia/dom/props/ClipProp.h +13 -20
  16. package/cpp/rnskia/dom/props/PathProp.h +16 -14
  17. package/cpp/rnskia/dom/props/PointProp.h +1 -1
  18. package/cpp/rnskia/dom/props/RRectProp.h +39 -61
  19. package/cpp/rnskia/dom/props/RectProp.h +27 -25
  20. package/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm +0 -2
  21. package/lib/commonjs/dom/nodes/JsiSkDOM.js +56 -54
  22. package/lib/commonjs/dom/nodes/JsiSkDOM.js.map +1 -1
  23. package/lib/commonjs/renderer/Canvas.js +30 -9
  24. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  25. package/lib/commonjs/renderer/HostComponents.d.ts +1 -0
  26. package/lib/commonjs/renderer/HostComponents.js +6 -1
  27. package/lib/commonjs/renderer/HostComponents.js.map +1 -1
  28. package/lib/commonjs/renderer/Reconciler.js +3 -1
  29. package/lib/commonjs/renderer/Reconciler.js.map +1 -1
  30. package/lib/commonjs/skia/core/Data.d.ts +2 -2
  31. package/lib/commonjs/skia/core/Data.js +5 -0
  32. package/lib/commonjs/skia/core/Data.js.map +1 -1
  33. package/lib/commonjs/skia/types/Data/Data.d.ts +2 -2
  34. package/lib/commonjs/skia/types/Data/Data.js.map +1 -1
  35. package/lib/commonjs/skia/types/Image/Image.d.ts +2 -2
  36. package/lib/commonjs/skia/types/Image/Image.js.map +1 -1
  37. package/lib/commonjs/skia/types/JsiInstance.d.ts +3 -0
  38. package/lib/commonjs/skia/types/JsiInstance.js.map +1 -1
  39. package/lib/commonjs/skia/types/SVG/SVG.d.ts +2 -2
  40. package/lib/commonjs/skia/types/SVG/SVG.js.map +1 -1
  41. package/lib/commonjs/skia/types/Typeface/Typeface.d.ts +2 -2
  42. package/lib/commonjs/skia/types/Typeface/Typeface.js.map +1 -1
  43. package/lib/commonjs/skia/web/JsiSkData.d.ts +1 -0
  44. package/lib/commonjs/skia/web/JsiSkData.js +3 -0
  45. package/lib/commonjs/skia/web/JsiSkData.js.map +1 -1
  46. package/lib/commonjs/skia/web/JsiSkImage.d.ts +1 -0
  47. package/lib/commonjs/skia/web/JsiSkImage.js +4 -0
  48. package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
  49. package/lib/commonjs/skia/web/JsiSkTypeface.d.ts +1 -0
  50. package/lib/commonjs/skia/web/JsiSkTypeface.js +4 -0
  51. package/lib/commonjs/skia/web/JsiSkTypeface.js.map +1 -1
  52. package/lib/commonjs/views/SkiaBaseWebView.js +5 -1
  53. package/lib/commonjs/views/SkiaBaseWebView.js.map +1 -1
  54. package/lib/module/dom/nodes/JsiSkDOM.js +55 -54
  55. package/lib/module/dom/nodes/JsiSkDOM.js.map +1 -1
  56. package/lib/module/renderer/Canvas.js +29 -10
  57. package/lib/module/renderer/Canvas.js.map +1 -1
  58. package/lib/module/renderer/HostComponents.d.ts +1 -0
  59. package/lib/module/renderer/HostComponents.js +3 -0
  60. package/lib/module/renderer/HostComponents.js.map +1 -1
  61. package/lib/module/renderer/Reconciler.js +2 -1
  62. package/lib/module/renderer/Reconciler.js.map +1 -1
  63. package/lib/module/skia/core/Data.d.ts +2 -2
  64. package/lib/module/skia/core/Data.js +5 -0
  65. package/lib/module/skia/core/Data.js.map +1 -1
  66. package/lib/module/skia/types/Data/Data.d.ts +2 -2
  67. package/lib/module/skia/types/Data/Data.js.map +1 -1
  68. package/lib/module/skia/types/Image/Image.d.ts +2 -2
  69. package/lib/module/skia/types/Image/Image.js.map +1 -1
  70. package/lib/module/skia/types/JsiInstance.d.ts +3 -0
  71. package/lib/module/skia/types/JsiInstance.js.map +1 -1
  72. package/lib/module/skia/types/SVG/SVG.d.ts +2 -2
  73. package/lib/module/skia/types/SVG/SVG.js.map +1 -1
  74. package/lib/module/skia/types/Typeface/Typeface.d.ts +2 -2
  75. package/lib/module/skia/types/Typeface/Typeface.js.map +1 -1
  76. package/lib/module/skia/web/JsiSkData.d.ts +1 -0
  77. package/lib/module/skia/web/JsiSkData.js +3 -0
  78. package/lib/module/skia/web/JsiSkData.js.map +1 -1
  79. package/lib/module/skia/web/JsiSkImage.d.ts +1 -0
  80. package/lib/module/skia/web/JsiSkImage.js +4 -0
  81. package/lib/module/skia/web/JsiSkImage.js.map +1 -1
  82. package/lib/module/skia/web/JsiSkTypeface.d.ts +1 -0
  83. package/lib/module/skia/web/JsiSkTypeface.js +4 -0
  84. package/lib/module/skia/web/JsiSkTypeface.js.map +1 -1
  85. package/lib/module/views/SkiaBaseWebView.js +5 -1
  86. package/lib/module/views/SkiaBaseWebView.js.map +1 -1
  87. package/lib/typescript/src/renderer/HostComponents.d.ts +1 -0
  88. package/lib/typescript/src/skia/core/Data.d.ts +2 -2
  89. package/lib/typescript/src/skia/types/Data/Data.d.ts +2 -2
  90. package/lib/typescript/src/skia/types/Image/Image.d.ts +2 -2
  91. package/lib/typescript/src/skia/types/JsiInstance.d.ts +3 -0
  92. package/lib/typescript/src/skia/types/SVG/SVG.d.ts +2 -2
  93. package/lib/typescript/src/skia/types/Typeface/Typeface.d.ts +2 -2
  94. package/lib/typescript/src/skia/web/JsiSkData.d.ts +1 -0
  95. package/lib/typescript/src/skia/web/JsiSkImage.d.ts +1 -0
  96. package/lib/typescript/src/skia/web/JsiSkTypeface.d.ts +1 -0
  97. package/package.json +1 -1
  98. package/src/dom/nodes/JsiSkDOM.ts +55 -54
  99. package/src/renderer/Canvas.tsx +34 -14
  100. package/src/renderer/HostComponents.ts +4 -0
  101. package/src/renderer/Reconciler.tsx +2 -1
  102. package/src/skia/core/Data.ts +14 -6
  103. package/src/skia/types/Data/Data.ts +2 -2
  104. package/src/skia/types/Image/Image.ts +2 -2
  105. package/src/skia/types/JsiInstance.ts +4 -0
  106. package/src/skia/types/SVG/SVG.ts +2 -2
  107. package/src/skia/types/Typeface/Typeface.ts +2 -2
  108. package/src/skia/web/JsiSkData.ts +4 -0
  109. package/src/skia/web/JsiSkImage.ts +4 -0
  110. package/src/skia/web/JsiSkTypeface.ts +4 -0
  111. package/src/views/SkiaBaseWebView.tsx +5 -0
@@ -1,3 +1,7 @@
1
1
  export interface SkJSIInstance<T extends string> {
2
2
  __typename__: T;
3
3
  }
4
+
5
+ export interface JsiDisposable {
6
+ dispose: () => void;
7
+ }
@@ -1,3 +1,3 @@
1
- import type { SkJSIInstance } from "../JsiInstance";
1
+ import type { JsiDisposable, SkJSIInstance } from "../JsiInstance";
2
2
 
3
- export type SkSVG = SkJSIInstance<"SVG">;
3
+ export type SkSVG = SkJSIInstance<"SVG"> & JsiDisposable;
@@ -1,3 +1,3 @@
1
- import type { SkJSIInstance } from "../JsiInstance";
1
+ import type { JsiDisposable, SkJSIInstance } from "../JsiInstance";
2
2
 
3
- export type SkTypeface = SkJSIInstance<"Typeface">;
3
+ export type SkTypeface = SkJSIInstance<"Typeface"> & JsiDisposable;
@@ -10,4 +10,8 @@ export class JsiSkData extends HostObject<Data, "Data"> implements SkData {
10
10
  constructor(CanvasKit: CanvasKit, ref: Data) {
11
11
  super(CanvasKit, ref, "Data");
12
12
  }
13
+
14
+ dispose() {
15
+ // Not implemented in data
16
+ }
13
17
  }
@@ -109,4 +109,8 @@ export class JsiSkImage extends HostObject<Image, "Image"> implements SkImage {
109
109
  const bytes = this.encodeToBytes(fmt, quality);
110
110
  return toBase64String(bytes);
111
111
  }
112
+
113
+ dispose() {
114
+ this.ref.delete();
115
+ }
112
116
  }
@@ -25,4 +25,8 @@ export class JsiSkTypeface
25
25
  );
26
26
  return false;
27
27
  }
28
+
29
+ dispose() {
30
+ this.ref.delete();
31
+ }
28
32
  }
@@ -78,6 +78,11 @@ export abstract class SkiaBaseWebView<
78
78
  componentWillUnmount() {
79
79
  this.unsubscribeAll();
80
80
  cancelAnimationFrame(this.requestId);
81
+ // https://developer.mozilla.org/en-US/docs/Web/API/WEBGL_lose_context
82
+ this._canvasRef.current
83
+ ?.getContext("webgl2")
84
+ ?.getExtension("WEBGL_lose_context")
85
+ ?.loseContext();
81
86
  }
82
87
 
83
88
  /**