@shopify/react-native-skia 1.5.8 → 1.5.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. package/android/CMakeLists.txt +0 -1
  2. package/android/cpp/jni/JniPlatformContext.cpp +0 -49
  3. package/android/cpp/jni/include/JniPlatformContext.h +1 -17
  4. package/android/cpp/jni/include/JniSkiaBaseView.h +0 -2
  5. package/android/cpp/jni/include/JniSkiaDomView.h +0 -3
  6. package/android/cpp/jni/include/JniSkiaManager.h +0 -2
  7. package/android/cpp/jni/include/JniSkiaPictureView.h +0 -3
  8. package/android/cpp/rnskia-android/MainThreadDispatcher.h +69 -0
  9. package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +4 -11
  10. package/android/cpp/rnskia-android/RNSkAndroidView.h +3 -13
  11. package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +0 -1
  12. package/android/src/main/java/com/shopify/reactnative/skia/PlatformContext.java +0 -85
  13. package/android/src/main/java/com/shopify/reactnative/skia/RNSkiaModule.java +1 -21
  14. package/android/src/main/java/com/shopify/reactnative/skia/SkiaManager.java +0 -4
  15. package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaDomViewManagerDelegate.java +1 -4
  16. package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaDomViewManagerInterface.java +0 -1
  17. package/cpp/rnskia/RNSkManager.cpp +2 -3
  18. package/cpp/rnskia/RNSkPlatformContext.h +2 -114
  19. package/cpp/rnskia/RNSkView.h +16 -75
  20. package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +1 -10
  21. package/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm +0 -16
  22. package/ios/RNSkia-iOS/SkiaDomView.mm +0 -1
  23. package/ios/RNSkia-iOS/SkiaDomViewManager.mm +0 -6
  24. package/ios/RNSkia-iOS/SkiaPictureView.mm +0 -1
  25. package/ios/RNSkia-iOS/SkiaPictureViewManager.mm +0 -6
  26. package/ios/RNSkia-iOS/SkiaUIView.h +0 -1
  27. package/ios/RNSkia-iOS/SkiaUIView.mm +1 -14
  28. package/lib/commonjs/renderer/Canvas.d.ts +1 -0
  29. package/lib/commonjs/renderer/Canvas.js +5 -5
  30. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  31. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.d.ts +0 -1
  32. package/lib/commonjs/specs/SkiaPictureViewNativeComponent.js.map +1 -1
  33. package/lib/commonjs/views/SkiaBaseWebView.d.ts +1 -12
  34. package/lib/commonjs/views/SkiaBaseWebView.js +1 -19
  35. package/lib/commonjs/views/SkiaBaseWebView.js.map +1 -1
  36. package/lib/commonjs/views/SkiaDomView.d.ts +8 -1
  37. package/lib/commonjs/views/SkiaDomView.js +14 -2
  38. package/lib/commonjs/views/SkiaDomView.js.map +1 -1
  39. package/lib/commonjs/views/SkiaDomView.web.d.ts +3 -3
  40. package/lib/commonjs/views/SkiaDomView.web.js.map +1 -1
  41. package/lib/commonjs/views/SkiaJSDomView.d.ts +12 -6
  42. package/lib/commonjs/views/SkiaJSDomView.js +12 -3
  43. package/lib/commonjs/views/SkiaJSDomView.js.map +1 -1
  44. package/lib/commonjs/views/SkiaPictureView.d.ts +8 -1
  45. package/lib/commonjs/views/SkiaPictureView.js +14 -1
  46. package/lib/commonjs/views/SkiaPictureView.js.map +1 -1
  47. package/lib/commonjs/views/SkiaPictureView.web.d.ts +3 -3
  48. package/lib/commonjs/views/SkiaPictureView.web.js.map +1 -1
  49. package/lib/commonjs/views/types.d.ts +2 -12
  50. package/lib/commonjs/views/types.js.map +1 -1
  51. package/lib/module/renderer/Canvas.d.ts +1 -0
  52. package/lib/module/renderer/Canvas.js +5 -5
  53. package/lib/module/renderer/Canvas.js.map +1 -1
  54. package/lib/module/specs/SkiaPictureViewNativeComponent.d.ts +0 -1
  55. package/lib/module/specs/SkiaPictureViewNativeComponent.js.map +1 -1
  56. package/lib/module/views/SkiaBaseWebView.d.ts +1 -12
  57. package/lib/module/views/SkiaBaseWebView.js +1 -19
  58. package/lib/module/views/SkiaBaseWebView.js.map +1 -1
  59. package/lib/module/views/SkiaDomView.d.ts +8 -1
  60. package/lib/module/views/SkiaDomView.js +14 -2
  61. package/lib/module/views/SkiaDomView.js.map +1 -1
  62. package/lib/module/views/SkiaDomView.web.d.ts +3 -3
  63. package/lib/module/views/SkiaDomView.web.js.map +1 -1
  64. package/lib/module/views/SkiaJSDomView.d.ts +12 -6
  65. package/lib/module/views/SkiaJSDomView.js +12 -3
  66. package/lib/module/views/SkiaJSDomView.js.map +1 -1
  67. package/lib/module/views/SkiaPictureView.d.ts +8 -1
  68. package/lib/module/views/SkiaPictureView.js +14 -1
  69. package/lib/module/views/SkiaPictureView.js.map +1 -1
  70. package/lib/module/views/SkiaPictureView.web.d.ts +3 -3
  71. package/lib/module/views/SkiaPictureView.web.js.map +1 -1
  72. package/lib/module/views/types.d.ts +2 -12
  73. package/lib/module/views/types.js.map +1 -1
  74. package/lib/typescript/lib/commonjs/views/SkiaBaseWebView.d.ts +0 -11
  75. package/lib/typescript/lib/commonjs/views/SkiaDomView.d.ts +3 -0
  76. package/lib/typescript/lib/commonjs/views/SkiaJSDomView.d.ts +2 -0
  77. package/lib/typescript/lib/commonjs/views/SkiaPictureView.d.ts +3 -0
  78. package/lib/typescript/lib/module/views/SkiaBaseWebView.d.ts +0 -11
  79. package/lib/typescript/lib/module/views/SkiaDomView.d.ts +3 -0
  80. package/lib/typescript/lib/module/views/SkiaJSDomView.d.ts +2 -0
  81. package/lib/typescript/lib/module/views/SkiaPictureView.d.ts +3 -0
  82. package/lib/typescript/src/renderer/Canvas.d.ts +1 -0
  83. package/lib/typescript/src/specs/SkiaPictureViewNativeComponent.d.ts +0 -1
  84. package/lib/typescript/src/views/SkiaBaseWebView.d.ts +1 -12
  85. package/lib/typescript/src/views/SkiaDomView.d.ts +8 -1
  86. package/lib/typescript/src/views/SkiaDomView.web.d.ts +3 -3
  87. package/lib/typescript/src/views/SkiaJSDomView.d.ts +12 -6
  88. package/lib/typescript/src/views/SkiaPictureView.d.ts +8 -1
  89. package/lib/typescript/src/views/SkiaPictureView.web.d.ts +3 -3
  90. package/lib/typescript/src/views/types.d.ts +2 -12
  91. package/package.json +1 -1
  92. package/src/renderer/Canvas.tsx +4 -3
  93. package/src/specs/SkiaPictureViewNativeComponent.ts +0 -1
  94. package/src/views/SkiaBaseWebView.tsx +3 -19
  95. package/src/views/SkiaDomView.tsx +23 -4
  96. package/src/views/SkiaDomView.web.tsx +3 -3
  97. package/src/views/SkiaJSDomView.tsx +30 -9
  98. package/src/views/SkiaPictureView.tsx +22 -2
  99. package/src/views/SkiaPictureView.web.tsx +3 -3
  100. package/src/views/types.ts +2 -13
  101. package/cpp/rnskia/RNSkDispatchQueue.cpp +0 -73
  102. package/cpp/rnskia/RNSkDispatchQueue.h +0 -49
  103. package/ios/RNSkia-iOS/DisplayLink.h +0 -17
  104. package/ios/RNSkia-iOS/DisplayLink.mm +0 -41
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","_JsiSkSurface","_Platform","e","__esModule","default","_extends","Object","assign","bind","n","arguments","length","t","r","hasOwnProperty","call","apply","_defineProperty","_toPropertyKey","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","TypeError","String","Number","pd","Platform","PixelRatio","SkiaBaseWebView","React","Component","constructor","props","_props$mode","createRef","onLayoutEvent","_mode","mode","unsubscribeAll","_unsubscriptions","forEach","u","evt","CanvasKit","global","canvas","_canvasRef","current","width","clientWidth","height","clientHeight","surface","MakeWebGLCanvasSurface","Error","_surface","JsiSkSurface","_canvas","getCanvas","redraw","onLayout","getSize","componentDidMount","tick","componentDidUpdate","componentWillUnmount","cancelAnimationFrame","requestId","_this$_canvasRef$curr","getContext","getExtension","loseContext","makeImageSnapshot","rect","_this$_surface","_this$_surface2","clear","TRANSPARENT","renderInCanvas","ref","flush","_redrawRequests","_this$_surface3","Float32Array","of","save","scale","restore","requestAnimationFrame","setDrawMode","render","debug","viewProps","createElement","View","style","display","flex","exports"],"sources":["SkiaBaseWebView.tsx"],"sourcesContent":["/* global HTMLCanvasElement */\nimport React from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\n\nimport type { SkRect, SkCanvas } from \"../skia/types\";\nimport { JsiSkSurface } from \"../skia/web/JsiSkSurface\";\nimport { Platform } from \"../Platform\";\n\nimport type { DrawMode, SkiaBaseViewProps } from \"./types\";\n\nconst pd = Platform.PixelRatio;\n\nexport abstract class SkiaBaseWebView<\n TProps extends SkiaBaseViewProps\n> extends React.Component<TProps> {\n constructor(props: TProps) {\n super(props);\n this._mode = props.mode ?? \"default\";\n }\n\n private _surface: JsiSkSurface | null = null;\n private _unsubscriptions: Array<() => void> = [];\n private _canvas: SkCanvas | null = null;\n private _canvasRef = React.createRef<HTMLCanvasElement>();\n private _mode: DrawMode;\n private _redrawRequests = 0;\n private requestId = 0;\n\n protected width = 0;\n protected height = 0;\n\n private unsubscribeAll() {\n this._unsubscriptions.forEach((u) => u());\n this._unsubscriptions = [];\n }\n\n private onLayoutEvent(evt: LayoutChangeEvent) {\n const { CanvasKit } = global;\n // Reset canvas / surface on layout change\n const canvas = this._canvasRef.current;\n if (canvas) {\n this.width = canvas.clientWidth;\n this.height = canvas.clientHeight;\n canvas.width = this.width * pd;\n canvas.height = this.height * pd;\n const surface = CanvasKit.MakeWebGLCanvasSurface(canvas);\n if (!surface) {\n throw new Error(\"Could not create surface\");\n }\n this._surface = new JsiSkSurface(CanvasKit, surface);\n this._canvas = this._surface.getCanvas();\n this.redraw();\n }\n // Call onLayout callback if it exists\n if (this.props.onLayout) {\n this.props.onLayout(evt);\n }\n }\n\n protected getSize() {\n return { width: this.width, height: this.height };\n }\n\n componentDidMount() {\n // Start render loop\n this.tick();\n }\n\n componentDidUpdate() {\n this.redraw();\n }\n\n componentWillUnmount() {\n this.unsubscribeAll();\n cancelAnimationFrame(this.requestId);\n // eslint-disable-next-line max-len\n // https://stackoverflow.com/questions/23598471/how-do-i-clean-up-and-unload-a-webgl-canvas-context-from-gpu-after-use\n // https://developer.mozilla.org/en-US/docs/Web/API/WEBGL_lose_context\n // We delete the context, only if the context has been intialized\n if (this._surface) {\n this._canvasRef.current\n ?.getContext(\"webgl2\")\n ?.getExtension(\"WEBGL_lose_context\")\n ?.loseContext();\n }\n }\n\n /**\n * Creates a snapshot from the canvas in the surface\n * @param rect Rect to use as bounds. Optional.\n * @returns An Image object.\n */\n public makeImageSnapshot(rect?: SkRect) {\n this._canvas!.clear(CanvasKit.TRANSPARENT);\n this.renderInCanvas(this._canvas!);\n this._surface?.ref.flush();\n return this._surface?.makeImageSnapshot(rect);\n }\n\n /**\n * Override to render\n */\n protected abstract renderInCanvas(canvas: SkCanvas): void;\n\n /**\n * Sends a redraw request to the native SkiaView.\n */\n private tick() {\n if (this._mode === \"continuous\" || this._redrawRequests > 0) {\n this._redrawRequests = 0;\n if (this._canvas) {\n const canvas = this._canvas!;\n canvas.clear(Float32Array.of(0, 0, 0, 0));\n canvas.save();\n canvas.scale(pd, pd);\n this.renderInCanvas(canvas);\n canvas.restore();\n this._surface?.ref.flush();\n }\n }\n this.requestId = requestAnimationFrame(this.tick.bind(this));\n }\n\n public redraw() {\n this._redrawRequests++;\n }\n\n /**\n * Updates the drawing mode for the skia view. This is the same\n * as declaratively setting the mode property on the SkiaView.\n * There are two drawing modes, \"continuous\" and \"default\",\n * where the continuous mode will continuously redraw the view and\n * the default mode will only redraw when any of the regular react\n * properties are changed like size and margins.\n * @param mode Drawing mode to use.\n */\n public setDrawMode(mode: DrawMode) {\n this._mode = mode;\n this.tick();\n }\n\n private onLayout = this.onLayoutEvent.bind(this);\n\n render() {\n const { mode, debug = false, ...viewProps } = this.props;\n return (\n <Platform.View {...viewProps} onLayout={this.onLayout}>\n <canvas ref={this._canvasRef} style={{ display: \"flex\", flex: 1 }} />\n </Platform.View>\n );\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAA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sB,eAAe,EAAE;EACxB;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACSQ,WAAWA,CAACpD,IAAc,EAAE;IACjC,IAAI,CAACD,KAAK,GAAGC,IAAI;IACjB,IAAI,CAAC0B,IAAI,CAAC,CAAC;EACb;EAIA2B,MAAMA,CAAA,EAAG;IACP,MAAM;MAAErD,IAAI;MAAEsD,KAAK,GAAG,KAAK;MAAE,GAAGC;IAAU,CAAC,GAAG,IAAI,CAAC5D,KAAK;IACxD,oBACEzC,MAAA,CAAAO,OAAA,CAAA+F,aAAA,CAAClG,SAAA,CAAA+B,QAAQ,CAACoE,IAAI,EAAA/F,QAAA,KAAK6F,SAAS;MAAEhC,QAAQ,EAAE,IAAI,CAACA;IAAS,iBACpDrE,MAAA,CAAAO,OAAA,CAAA+F,aAAA;MAAQd,GAAG,EAAE,IAAI,CAACjC,UAAW;MAACiD,KAAK,EAAE;QAAEC,OAAO,EAAE,MAAM;QAAEC,IAAI,EAAE;MAAE;IAAE,CAAE,CACvD,CAAC;EAEpB;AACF;AAACC,OAAA,CAAAtE,eAAA,GAAAA,eAAA","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireDefault","require","_JsiSkSurface","_Platform","e","__esModule","default","_extends","Object","assign","bind","n","arguments","length","t","r","hasOwnProperty","call","apply","_defineProperty","_toPropertyKey","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","TypeError","String","Number","pd","Platform","PixelRatio","SkiaBaseWebView","React","Component","constructor","props","createRef","onLayoutEvent","unsubscribeAll","_unsubscriptions","forEach","u","evt","CanvasKit","global","canvas","_canvasRef","current","width","clientWidth","height","clientHeight","surface","MakeWebGLCanvasSurface","Error","_surface","JsiSkSurface","_canvas","getCanvas","redraw","onLayout","getSize","componentDidMount","tick","componentDidUpdate","componentWillUnmount","cancelAnimationFrame","requestId","_this$_canvasRef$curr","getContext","getExtension","loseContext","makeImageSnapshot","rect","_this$_surface","_this$_surface2","clear","TRANSPARENT","renderInCanvas","ref","flush","_redrawRequests","_this$_surface3","Float32Array","of","save","scale","restore","requestAnimationFrame","render","debug","viewProps","createElement","View","style","display","flex","exports"],"sources":["SkiaBaseWebView.tsx"],"sourcesContent":["/* global HTMLCanvasElement */\nimport React from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\n\nimport type { SkRect, SkCanvas } from \"../skia/types\";\nimport { JsiSkSurface } from \"../skia/web/JsiSkSurface\";\nimport { Platform } from \"../Platform\";\n\nimport type { SkiaBaseViewProps } from \"./types\";\n\nconst pd = Platform.PixelRatio;\n\nexport abstract class SkiaBaseWebView<\n TProps extends SkiaBaseViewProps\n> extends React.Component<TProps> {\n constructor(props: TProps) {\n super(props);\n }\n\n private _surface: JsiSkSurface | null = null;\n private _unsubscriptions: Array<() => void> = [];\n private _canvas: SkCanvas | null = null;\n private _canvasRef = React.createRef<HTMLCanvasElement>();\n private _redrawRequests = 0;\n private requestId = 0;\n\n protected width = 0;\n protected height = 0;\n\n private unsubscribeAll() {\n this._unsubscriptions.forEach((u) => u());\n this._unsubscriptions = [];\n }\n\n private onLayoutEvent(evt: LayoutChangeEvent) {\n const { CanvasKit } = global;\n // Reset canvas / surface on layout change\n const canvas = this._canvasRef.current;\n if (canvas) {\n this.width = canvas.clientWidth;\n this.height = canvas.clientHeight;\n canvas.width = this.width * pd;\n canvas.height = this.height * pd;\n const surface = CanvasKit.MakeWebGLCanvasSurface(canvas);\n if (!surface) {\n throw new Error(\"Could not create surface\");\n }\n this._surface = new JsiSkSurface(CanvasKit, surface);\n this._canvas = this._surface.getCanvas();\n this.redraw();\n }\n // Call onLayout callback if it exists\n if (this.props.onLayout) {\n this.props.onLayout(evt);\n }\n }\n\n protected getSize() {\n return { width: this.width, height: this.height };\n }\n\n componentDidMount() {\n // Start render loop\n this.tick();\n }\n\n componentDidUpdate() {\n this.redraw();\n }\n\n componentWillUnmount() {\n this.unsubscribeAll();\n cancelAnimationFrame(this.requestId);\n // eslint-disable-next-line max-len\n // https://stackoverflow.com/questions/23598471/how-do-i-clean-up-and-unload-a-webgl-canvas-context-from-gpu-after-use\n // https://developer.mozilla.org/en-US/docs/Web/API/WEBGL_lose_context\n // We delete the context, only if the context has been intialized\n if (this._surface) {\n this._canvasRef.current\n ?.getContext(\"webgl2\")\n ?.getExtension(\"WEBGL_lose_context\")\n ?.loseContext();\n }\n }\n\n /**\n * Creates a snapshot from the canvas in the surface\n * @param rect Rect to use as bounds. Optional.\n * @returns An Image object.\n */\n public makeImageSnapshot(rect?: SkRect) {\n this._canvas!.clear(CanvasKit.TRANSPARENT);\n this.renderInCanvas(this._canvas!);\n this._surface?.ref.flush();\n return this._surface?.makeImageSnapshot(rect);\n }\n\n /**\n * Override to render\n */\n protected abstract renderInCanvas(canvas: SkCanvas): void;\n\n /**\n * Sends a redraw request to the native SkiaView.\n */\n private tick() {\n if (this._redrawRequests > 0) {\n this._redrawRequests = 0;\n if (this._canvas) {\n const canvas = this._canvas!;\n canvas.clear(Float32Array.of(0, 0, 0, 0));\n canvas.save();\n canvas.scale(pd, pd);\n this.renderInCanvas(canvas);\n canvas.restore();\n this._surface?.ref.flush();\n }\n }\n this.requestId = requestAnimationFrame(this.tick.bind(this));\n }\n\n public redraw() {\n this._redrawRequests++;\n }\n\n private onLayout = this.onLayoutEvent.bind(this);\n\n render() {\n const { debug = false, ...viewProps } = this.props;\n return (\n <Platform.View {...viewProps} onLayout={this.onLayout}>\n <canvas ref={this._canvasRef} style={{ display: \"flex\", flex: 1 }} />\n </Platform.View>\n );\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAAuC,SAAAD,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,SAAA,WAAAA,QAAA,GAAAC,MAA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AE,IAAI,CAACjC,UAAW;MAACgD,KAAK,EAAE;QAAEC,OAAO,EAAE,MAAM;QAAEC,IAAI,EAAE;MAAE;IAAE,CAAE,CACvD,CAAC;EAEpB;AACF;AAACC,OAAA,CAAAlE,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -1,11 +1,17 @@
1
1
  import React from "react";
2
2
  import type { SkRect } from "../skia/types";
3
- import type { SkiaDomViewProps } from "./types";
3
+ import type { SkiaDomViewNativeProps } from "./types";
4
+ interface SkiaDomViewProps extends SkiaDomViewNativeProps {
5
+ mode?: "default" | "continuous";
6
+ }
4
7
  export declare class SkiaDomView extends React.Component<SkiaDomViewProps> {
5
8
  constructor(props: SkiaDomViewProps);
6
9
  private _nativeId;
10
+ private requestId;
7
11
  get nativeId(): number;
8
12
  componentDidUpdate(prevProps: SkiaDomViewProps): void;
13
+ componentWillUnmount(): void;
14
+ private tick;
9
15
  /**
10
16
  * Creates a snapshot from the canvas in the surface
11
17
  * @param rect Rect to use as bounds. Optional.
@@ -24,3 +30,4 @@ export declare class SkiaDomView extends React.Component<SkiaDomViewProps> {
24
30
  redraw(): void;
25
31
  render(): React.JSX.Element;
26
32
  }
33
+ export {};
@@ -21,6 +21,7 @@ class SkiaDomView extends _react.default.Component {
21
21
  constructor(props) {
22
22
  super(props);
23
23
  _defineProperty(this, "_nativeId", void 0);
24
+ _defineProperty(this, "requestId", 0);
24
25
  this._nativeId = _SkiaViewNativeId.SkiaViewNativeId.current++;
25
26
  const {
26
27
  root,
@@ -34,6 +35,7 @@ class SkiaDomView extends _react.default.Component {
34
35
  assertSkiaViewApi();
35
36
  _api.SkiaViewApi.setJsiProperty(this._nativeId, "onSize", onSize);
36
37
  }
38
+ this.tick();
37
39
  }
38
40
  get nativeId() {
39
41
  return this._nativeId;
@@ -51,6 +53,18 @@ class SkiaDomView extends _react.default.Component {
51
53
  assertSkiaViewApi();
52
54
  _api.SkiaViewApi.setJsiProperty(this._nativeId, "onSize", onSize);
53
55
  }
56
+ this.tick();
57
+ }
58
+ componentWillUnmount() {
59
+ if (this.requestId) {
60
+ cancelAnimationFrame(this.requestId);
61
+ }
62
+ }
63
+ tick() {
64
+ this.redraw();
65
+ if (this.props.mode === "continuous") {
66
+ this.requestId = requestAnimationFrame(this.tick.bind(this));
67
+ }
54
68
  }
55
69
 
56
70
  /**
@@ -82,14 +96,12 @@ class SkiaDomView extends _react.default.Component {
82
96
  }
83
97
  render() {
84
98
  const {
85
- mode,
86
99
  debug = false,
87
100
  ...viewProps
88
101
  } = this.props;
89
102
  return /*#__PURE__*/_react.default.createElement(NativeSkiaDomView, _extends({
90
103
  collapsable: false,
91
104
  nativeID: `${this._nativeId}`,
92
- mode: mode,
93
105
  debug: debug
94
106
  }, viewProps));
95
107
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","_Platform","_SkiaDomViewNativeComponent","_api","_SkiaViewNativeId","e","__esModule","default","_extends","Object","assign","bind","n","arguments","length","t","r","hasOwnProperty","call","apply","_defineProperty","_toPropertyKey","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","TypeError","String","Number","NativeSkiaDomView","Platform","OS","SkiaDomViewNativeComponent","SkiaDomView","React","Component","constructor","props","_nativeId","SkiaViewNativeId","current","root","onSize","assertSkiaViewApi","SkiaViewApi","setJsiProperty","nativeId","componentDidUpdate","prevProps","makeImageSnapshot","rect","makeImageSnapshotAsync","redraw","requestRedraw","render","mode","debug","viewProps","createElement","collapsable","nativeID","exports","Error"],"sources":["SkiaDomView.tsx"],"sourcesContent":["import React from \"react\";\nimport type { HostComponent } from \"react-native\";\n\nimport type { SkRect } from \"../skia/types\";\nimport { Platform } from \"../Platform\";\nimport SkiaDomViewNativeComponent from \"../specs/SkiaDomViewNativeComponent\";\n\nimport { SkiaViewApi } from \"./api\";\nimport type { SkiaDomViewProps } from \"./types\";\nimport { SkiaViewNativeId } from \"./SkiaViewNativeId\";\n\nconst NativeSkiaDomView: HostComponent<SkiaDomViewProps> =\n Platform.OS !== \"web\"\n ? SkiaDomViewNativeComponent\n : // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (null as any);\n\nexport class SkiaDomView extends React.Component<SkiaDomViewProps> {\n constructor(props: SkiaDomViewProps) {\n super(props);\n this._nativeId = SkiaViewNativeId.current++;\n const { root, onSize } = props;\n if (root) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"root\", root);\n }\n if (onSize) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"onSize\", onSize);\n }\n }\n\n private _nativeId: number;\n\n public get nativeId() {\n return this._nativeId;\n }\n\n componentDidUpdate(prevProps: SkiaDomViewProps) {\n const { root, onSize } = this.props;\n if (root !== prevProps.root) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"root\", root);\n }\n if (onSize !== prevProps.onSize) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"onSize\", onSize);\n }\n }\n\n /**\n * Creates a snapshot from the canvas in the surface\n * @param rect Rect to use as bounds. Optional.\n * @returns An Image object.\n */\n public makeImageSnapshot(rect?: SkRect) {\n assertSkiaViewApi();\n return SkiaViewApi.makeImageSnapshot(this._nativeId, rect);\n }\n\n /**\n * Creates a snapshot from the canvas in the surface\n * @param rect Rect to use as bounds. Optional.\n * @returns An Image object.\n */\n public makeImageSnapshotAsync(rect?: SkRect) {\n assertSkiaViewApi();\n return SkiaViewApi.makeImageSnapshotAsync(this._nativeId, rect);\n }\n\n /**\n * Sends a redraw request to the native SkiaView.\n */\n public redraw() {\n assertSkiaViewApi();\n SkiaViewApi.requestRedraw(this._nativeId);\n }\n\n render() {\n const { mode, debug = false, ...viewProps } = this.props;\n return (\n <NativeSkiaDomView\n collapsable={false}\n nativeID={`${this._nativeId}`}\n mode={mode}\n debug={debug}\n {...viewProps}\n />\n );\n }\n}\n\nconst assertSkiaViewApi = () => {\n if (\n SkiaViewApi === null ||\n SkiaViewApi.setJ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ACS,aAAa,KAAK,IAAI,IAClCT,gBAAW,CAACK,iBAAiB,KAAK,IAAI,EACtC;IACA,MAAMa,KAAK,CAAC,8BAA8B,CAAC;EAC7C;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireDefault","require","_Platform","_SkiaDomViewNativeComponent","_api","_SkiaViewNativeId","e","__esModule","default","_extends","Object","assign","bind","n","arguments","length","t","r","hasOwnProperty","call","apply","_defineProperty","_toPropertyKey","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","TypeError","String","Number","NativeSkiaDomView","Platform","OS","SkiaDomViewNativeComponent","SkiaDomView","React","Component","constructor","props","_nativeId","SkiaViewNativeId","current","root","onSize","assertSkiaViewApi","SkiaViewApi","setJsiProperty","tick","nativeId","componentDidUpdate","prevProps","componentWillUnmount","requestId","cancelAnimationFrame","redraw","mode","requestAnimationFrame","makeImageSnapshot","rect","makeImageSnapshotAsync","requestRedraw","render","debug","viewProps","createElement","collapsable","nativeID","exports","Error"],"sources":["SkiaDomView.tsx"],"sourcesContent":["import React from \"react\";\nimport type { HostComponent } from \"react-native\";\n\nimport type { SkRect } from \"../skia/types\";\nimport { Platform } from \"../Platform\";\nimport SkiaDomViewNativeComponent from \"../specs/SkiaDomViewNativeComponent\";\n\nimport { SkiaViewApi } from \"./api\";\nimport type { SkiaDomViewNativeProps } from \"./types\";\nimport { SkiaViewNativeId } from \"./SkiaViewNativeId\";\n\nconst NativeSkiaDomView: HostComponent<SkiaDomViewNativeProps> =\n Platform.OS !== \"web\"\n ? SkiaDomViewNativeComponent\n : // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (null as any);\n\ninterface SkiaDomViewProps extends SkiaDomViewNativeProps {\n mode?: \"default\" | \"continuous\";\n}\n\nexport class SkiaDomView extends React.Component<SkiaDomViewProps> {\n constructor(props: SkiaDomViewProps) {\n super(props);\n this._nativeId = SkiaViewNativeId.current++;\n const { root, onSize } = props;\n if (root) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"root\", root);\n }\n if (onSize) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"onSize\", onSize);\n }\n this.tick();\n }\n\n private _nativeId: number;\n private requestId = 0;\n\n public get nativeId() {\n return this._nativeId;\n }\n\n componentDidUpdate(prevProps: SkiaDomViewProps) {\n const { root, onSize } = this.props;\n if (root !== prevProps.root) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"root\", root);\n }\n if (onSize !== prevProps.onSize) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"onSize\", onSize);\n }\n this.tick();\n }\n\n componentWillUnmount(): void {\n if (this.requestId) {\n cancelAnimationFrame(this.requestId);\n }\n }\n\n private tick() {\n this.redraw();\n if (this.props.mode === \"continuous\") {\n this.requestId = requestAnimationFrame(this.tick.bind(this));\n }\n }\n\n /**\n * Creates a snapshot from the canvas in the surface\n * @param rect Rect to use as bounds. Optional.\n * @returns An Image object.\n */\n public makeImageSnapshot(rect?: SkRect) {\n assertSkiaViewApi();\n return SkiaViewApi.makeImageSnapshot(this._nativeId, rect);\n }\n\n /**\n * Creates a snapshot from the canvas in the surface\n * @param rect Rect to use as bounds. Optional.\n * @returns An Image object.\n */\n public makeImageSnapshotAsync(rect?: SkRect) {\n assertSkiaViewApi();\n return SkiaViewApi.makeImageSnapshotAsync(this._nativeId, rect);\n }\n\n /**\n * Sends a redraw request to the native SkiaView.\n */\n public redraw() {\n assertSkiaViewApi();\n SkiaViewApi.requestRedraw(this._nativeId);\n }\n\n render() {\n const { debug = false, ...viewProps } = this.props;\n return (\n <NativeSkiaDomView\n collapsable={false}\n nativeID={`${this._nativeId}`}\n debug={debug}\n {...viewProps}\n />\n );\n }\n}\n\nconst assertSkiaViewApi = () => {\n if (\n SkiaViewApi === null ||\n SkiaViewApi.setJsiProperty === null ||\n SkiaViewApi.requestRedraw === null ||\n SkiaViewApi.makeImageSnapshot === null\n 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AS,OAAA,CAAA6D,aAAA,CAAClC,iBAAiB,EAAA1B,QAAA;MAChB6D,WAAW,EAAE,KAAM;MACnBC,QAAQ,EAAE,GAAG,IAAI,CAAC3B,SAAS,EAAG;MAC9BuB,KAAK,EAAEA;IAAM,GACTC,SAAS,CACd,CAAC;EAEN;AACF;AAACI,OAAA,CAAAjC,WAAA,GAAAA,WAAA;AAED,MAAMU,iBAAiB,GAAGA,CAAA,KAAM;EAC9B,IACEC,gBAAW,KAAK,IAAI,IACpBA,gBAAW,CAACC,cAAc,KAAK,IAAI,IACnCD,gBAAW,CAACe,aAAa,KAAK,IAAI,IAClCf,gBAAW,CAACY,iBAAiB,KAAK,IAAI,EACtC;IACA,MAAMW,KAAK,CAAC,8BAA8B,CAAC;EAC7C;AACF,CAAC","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  import type { SkCanvas } from "../skia/types";
2
2
  import { SkiaBaseWebView } from "./SkiaBaseWebView";
3
- import type { SkiaDomViewProps } from "./types";
4
- export declare class SkiaDomView extends SkiaBaseWebView<SkiaDomViewProps> {
5
- constructor(props: SkiaDomViewProps);
3
+ import type { SkiaDomViewNativeProps } from "./types";
4
+ export declare class SkiaDomView extends SkiaBaseWebView<SkiaDomViewNativeProps> {
5
+ constructor(props: SkiaDomViewNativeProps);
6
6
  protected renderInCanvas(canvas: SkCanvas): void;
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_skia","require","_DrawingContext","_SkiaBaseWebView","SkiaDomView","SkiaBaseWebView","constructor","props","renderInCanvas","canvas","onSize","width","height","getSize","value","root","ctx","JsiDrawingContext","Skia","render","exports"],"sources":["SkiaDomView.web.tsx"],"sourcesContent":["import { Skia } from \"../skia\";\nimport type { SkCanvas } from \"../skia/types\";\nimport { JsiDrawingContext } from \"../dom/types/DrawingContext\";\n\nimport { SkiaBaseWebView } from \"./SkiaBaseWebView\";\nimport type { SkiaDomViewProps } from \"./types\";\n\nexport class SkiaDomView extends SkiaBaseWebView<SkiaDomViewProps> {\n constructor(props: SkiaDomViewProps) {\n super(props);\n }\n\n protected renderInCanvas(canvas: SkCanvas): void {\n if (this.props.onSize) {\n const { width, height } = this.getSize();\n this.props.onSize.value = { width, height };\n }\n if (this.props.root) {\n const ctx = new JsiDrawingContext(Skia, canvas);\n this.props.root.render(ctx);\n }\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAD,OAAA;AAEA,IAAAE,gBAAA,GAAAF,OAAA;AAGO,MAAMG,WAAW,SAASC,gCAAe,CAAmB;EACjEC,WAAWA,CAACC,KAAuB,EAAE;IACnC,KAAK,CAACA,KAAK,CAAC;EACd;EAEUC,cAAcA,CAACC,MAAgB,EAAQ;IAC/C,IAAI,IAAI,CAACF,KAAK,CAACG,MAAM,EAAE;MACrB,MAAM;QAAEC,KAAK;QAAEC;MAAO,CAAC,GAAG,IAAI,CAACC,OAAO,CAAC,CAAC;MACxC,IAAI,CAACN,KAAK,CAACG,MAAM,CAACI,KAAK,GAAG;QAAEH,KAAK;QAAEC;MAAO,CAAC;IAC7C;IACA,IAAI,IAAI,CAACL,KAAK,CAACQ,IAAI,EAAE;MACnB,MAAMC,GAAG,GAAG,IAAIC,iCAAiB,CAACC,UAAI,EAAET,MAAM,CAAC;MAC/C,IAAI,CAACF,KAAK,CAACQ,IAAI,CAACI,MAAM,CAACH,GAAG,CAAC;IAC7B;EACF;AACF;AAACI,OAAA,CAAAhB,WAAA,GAAAA,WAAA","ignoreList":[]}
1
+ {"version":3,"names":["_skia","require","_DrawingContext","_SkiaBaseWebView","SkiaDomView","SkiaBaseWebView","constructor","props","renderInCanvas","canvas","onSize","width","height","getSize","value","root","ctx","JsiDrawingContext","Skia","render","exports"],"sources":["SkiaDomView.web.tsx"],"sourcesContent":["import { Skia } from \"../skia\";\nimport type { SkCanvas } from \"../skia/types\";\nimport { JsiDrawingContext } from \"../dom/types/DrawingContext\";\n\nimport { SkiaBaseWebView } from \"./SkiaBaseWebView\";\nimport type { SkiaDomViewNativeProps } from \"./types\";\n\nexport class SkiaDomView extends SkiaBaseWebView<SkiaDomViewNativeProps> {\n constructor(props: SkiaDomViewNativeProps) {\n super(props);\n }\n\n protected renderInCanvas(canvas: SkCanvas): void {\n if (this.props.onSize) {\n const { width, height } = this.getSize();\n this.props.onSize.value = { width, height };\n }\n if (this.props.root) {\n const ctx = new JsiDrawingContext(Skia, canvas);\n this.props.root.render(ctx);\n }\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAD,OAAA;AAEA,IAAAE,gBAAA,GAAAF,OAAA;AAGO,MAAMG,WAAW,SAASC,gCAAe,CAAyB;EACvEC,WAAWA,CAACC,KAA6B,EAAE;IACzC,KAAK,CAACA,KAAK,CAAC;EACd;EAEUC,cAAcA,CAACC,MAAgB,EAAQ;IAC/C,IAAI,IAAI,CAACF,KAAK,CAACG,MAAM,EAAE;MACrB,MAAM;QAAEC,KAAK;QAAEC;MAAO,CAAC,GAAG,IAAI,CAACC,OAAO,CAAC,CAAC;MACxC,IAAI,CAACN,KAAK,CAACG,MAAM,CAACI,KAAK,GAAG;QAAEH,KAAK;QAAEC;MAAO,CAAC;IAC7C;IACA,IAAI,IAAI,CAACL,KAAK,CAACQ,IAAI,EAAE;MACnB,MAAMC,GAAG,GAAG,IAAIC,iCAAiB,CAACC,UAAI,EAAET,MAAM,CAAC;MAC/C,IAAI,CAACF,KAAK,CAACQ,IAAI,CAACI,MAAM,CAACH,GAAG,CAAC;IAC7B;EACF;AACF;AAACI,OAAA,CAAAhB,WAAA,GAAAA,WAAA","ignoreList":[]}
@@ -1,13 +1,18 @@
1
1
  import React from "react";
2
2
  import type { Skia, SkRect } from "../skia/types";
3
- import type { SkiaDomViewProps } from "./types";
4
- export declare class SkiaJSDomView extends React.Component<SkiaDomViewProps & {
3
+ import type { SkiaDomViewNativeProps } from "./types";
4
+ interface SkiaDomViewProps extends SkiaDomViewNativeProps {
5
+ mode?: "default" | "continuous";
6
+ }
7
+ type SkiaJSDomViewProps = SkiaDomViewProps & {
5
8
  Skia: Skia;
6
- }> {
7
- constructor(props: SkiaDomViewProps & {
8
- Skia: Skia;
9
- });
9
+ mode?: "default" | "continuous";
10
+ };
11
+ export declare class SkiaJSDomView extends React.Component<SkiaJSDomViewProps> {
12
+ constructor(props: SkiaJSDomViewProps);
10
13
  private _nativeId;
14
+ private requestId;
15
+ private tick;
11
16
  get nativeId(): number;
12
17
  componentDidUpdate(prevProps: SkiaDomViewProps & {
13
18
  Skia: Skia;
@@ -29,3 +34,4 @@ export declare class SkiaJSDomView extends React.Component<SkiaDomViewProps & {
29
34
  componentWillUnmount(): void;
30
35
  render(): React.JSX.Element;
31
36
  }
37
+ export {};
@@ -22,6 +22,7 @@ class SkiaJSDomView extends _react.default.Component {
22
22
  constructor(props) {
23
23
  super(props);
24
24
  _defineProperty(this, "_nativeId", void 0);
25
+ _defineProperty(this, "requestId", 0);
25
26
  this._nativeId = _SkiaViewNativeId.SkiaViewNativeId.current++;
26
27
  const {
27
28
  root,
@@ -35,6 +36,13 @@ class SkiaJSDomView extends _react.default.Component {
35
36
  assertSkiaViewApi();
36
37
  _api.SkiaViewApi.setJsiProperty(this._nativeId, "onSize", onSize);
37
38
  }
39
+ this.tick();
40
+ }
41
+ tick() {
42
+ this.redraw();
43
+ if (this.props.mode === "continuous") {
44
+ this.requestId = requestAnimationFrame(this.tick.bind(this));
45
+ }
38
46
  }
39
47
  get nativeId() {
40
48
  return this._nativeId;
@@ -52,6 +60,7 @@ class SkiaJSDomView extends _react.default.Component {
52
60
  assertSkiaViewApi();
53
61
  _api.SkiaViewApi.setJsiProperty(this._nativeId, "onSize", onSize);
54
62
  }
63
+ this.tick();
55
64
  }
56
65
 
57
66
  /**
@@ -70,7 +79,6 @@ class SkiaJSDomView extends _react.default.Component {
70
79
  redraw() {
71
80
  assertSkiaViewApi();
72
81
  this.draw();
73
- //SkiaViewApi.requestRedraw(this._nativeId);
74
82
  }
75
83
  draw() {
76
84
  const {
@@ -94,17 +102,18 @@ class SkiaJSDomView extends _react.default.Component {
94
102
  componentWillUnmount() {
95
103
  assertSkiaViewApi();
96
104
  _api.SkiaViewApi.setJsiProperty(this._nativeId, "picture", null);
105
+ if (this.requestId) {
106
+ cancelAnimationFrame(this.requestId);
107
+ }
97
108
  }
98
109
  render() {
99
110
  const {
100
- mode,
101
111
  debug = false,
102
112
  ...viewProps
103
113
  } = this.props;
104
114
  return /*#__PURE__*/_react.default.createElement(NativeSkiaPictureView, _extends({
105
115
  collapsable: false,
106
116
  nativeID: `${this._nativeId}`,
107
- mode: mode,
108
117
  debug: debug
109
118
  }, viewProps));
110
119
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","_Platform","_SkiaPictureViewNativeComponent","_types","_api","_SkiaViewNativeId","e","__esModule","default","_extends","Object","assign","bind","n","arguments","length","t","r","hasOwnProperty","call","apply","_defineProperty","_toPropertyKey","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","TypeError","String","Number","NativeSkiaPictureView","Platform","OS","SkiaPictureViewNativeComponent","SkiaJSDomView","React","Component","constructor","props","_nativeId","SkiaViewNativeId","current","root","onSize","assertSkiaViewApi","SkiaViewApi","setJsiProperty","nativeId","componentDidUpdate","prevProps","undefined","draw","makeImageSnapshot","rect","redraw","Skia","rec","PictureRecorder","canvas","beginRecording","ctx","JsiDrawingContext","render","picture","finishRecordingAsPicture","componentWillUnmount","mode","debug","viewProps","createElement","collapsable","nativeID","exports","requestRedraw","Error"],"sources":["SkiaJSDomView.tsx"],"sourcesContent":["import React from \"react\";\nimport type { HostComponent } from \"react-native\";\n\nimport type { Skia, SkRect } from \"../skia/types\";\nimport { Platform } from \"../Platform\";\nimport SkiaPictureViewNativeComponent from \"../specs/SkiaPictureViewNativeComponent\";\nimport { JsiDrawingContext } from \"../dom/types\";\n\nimport { SkiaViewApi } from \"./api\";\nimport type { SkiaPictureViewProps, SkiaDomViewProps } from \"./types\";\nimport { SkiaViewNativeId } from \"./SkiaViewNativeId\";\n\nconst NativeSkiaPictureView: HostComponent<SkiaPictureViewProps> =\n Platform.OS !== \"web\"\n ? SkiaPictureViewNativeComponent\n : // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (null as any);\n\nexport class SkiaJSDomView extends React.Component<\n SkiaDomViewProps & { Skia: Skia }\n> {\n constructor(props: SkiaDomViewProps & { Skia: Skia }) {\n super(props);\n this._nativeId = SkiaViewNativeId.current++;\n const { root, onSize } = props;\n if (root) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"root\", root);\n }\n if (onSize) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"onSize\", onSize);\n }\n }\n\n private _nativeId: number;\n\n public get nativeId() {\n return this._nativeId;\n }\n\n componentDidUpdate(prevProps: SkiaDomViewProps & { Skia: Skia }) {\n const { root, onSize } = this.props;\n if (root !== prevProps.root && root !== undefined) {\n assertSkiaViewApi();\n this.draw();\n }\n if (onSize !== prevProps.onSize) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"onSize\", onSize);\n }\n }\n\n /**\n * Creates a snapshot from the canvas in the surface\n * @param rect Rect to use as bounds. Optional.\n * @returns An Image object.\n */\n public makeImageSnapshot(rect?: SkRect) {\n assertSkiaViewApi();\n return SkiaViewApi.makeImageSnapshot(this._nativeId, rect);\n }\n\n /**\n * Sends a redraw request to the native SkiaView.\n */\n public redraw() {\n assertSkiaViewApi();\n this.draw();\n //SkiaViewApi.requestRedraw(this._nativeId);\n }\n\n private draw() {\n const { root, Skia } = this.props;\n if (root !== undefined) {\n assertSkiaViewApi();\n const rec = Skia.PictureRecorder();\n const canvas = rec.beginRecording();\n const ctx = new JsiDrawingContext(Skia, canvas);\n root.render(ctx);\n const picture = rec.finishRecordingAsPicture();\n SkiaViewApi.setJsiProperty(this._nativeId, \"picture\", picture);\n }\n }\n\n /**\n * Clear up the dom node when unmounting to release resources.\n */\n componentWillUnmount(): void {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"picture\", null);\n }\n\n render() {\n const { mode, debug = false, ...viewProps } = this.props;\n return (\n <NativeSkiaPictureView\n collapsable={false}\n nativeID={`${this._nativeId}`}\n mode={mode}\n debug={debug}\n {...viewProps}\n />\n );\n }\n}\n\nconst assertSkiaViewApi = () => {\n if (\n SkiaViewApi === null ||\n SkiaViewApi.setJsiProperty === null ||\n SkiaViewApi.requestRedraw === null ||\n SkiaViewApi.makeImageSnapshot === null\n ) {\n throw Error(\"Skia View Api was not found.\");\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,+BAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAEA,IAAAI,IAAA,GAAAJ,OAAA;AAEA,IAAAK,iBAAA,GAAAL,OAAA;AAAsD,SAAAD,uBAAAO,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,SAAA,WAAAA,QAAA,GAAAC,MAAA,CAAAC,MAAA,GAAAD,MAAA,CAAAC,MAAA,CAAAC,IAAA,eAAAC,CAAA,aAAAP,CAAA,MAAAA,CAAA,GAAAQ,SAAA,CAAAC,MAAA,EAAAT,CAAA,UAAAU,CAAA,GAAAF,SAAA,CAAAR,CAAA,YAAAW,CAAA,IAAAD,CAAA,OAAAE,cAAA,CAAAC,IAAA,CAAAH,CAAA,EAAAC,CAAA,MAAAJ,CAAA,CAAAI,CAAA,IAAAD,CAAA,CAAAC,CAAA,aAAAJ,CAAA,KAAAJ,QAAA,CAAAW,KAAA,OAAAN,SAAA;AAAA,SAAAO,gBAAAf,CAAA,EAAAW,CAAA,EAAAD,CAAA,YAAAC,CAA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GP,GAAG,CAACQ,wBAAwB,CAAC,CAAC;MAC9CnB,gBAAW,CAACC,cAAc,CAAC,IAAI,CAACP,SAAS,EAAE,SAAS,EAAEwB,OAAO,CAAC;IAChE;EACF;;EAEA;AACF;AACA;EACEE,oBAAoBA,CAAA,EAAS;IAC3BrB,iBAAiB,CAAC,CAAC;IACnBC,gBAAW,CAACC,cAAc,CAAC,IAAI,CAACP,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC;EAC7D;EAEAuB,MAAMA,CAAA,EAAG;IACP,MAAM;MAAEI,IAAI;MAAEC,KAAK,GAAG,KAAK;MAAE,GAAGC;IAAU,CAAC,GAAG,IAAI,CAAC9B,KAAK;IACxD,oBACE7C,MAAA,CAAAU,OAAA,CAAAkE,aAAA,CAACvC,qBAAqB,EAAA1B,QAAA;MACpBkE,WAAW,EAAE,KAAM;MACnBC,QAAQ,EAAE,GAAG,IAAI,CAAChC,SAAS,EAAG;MAC9B2B,IAAI,EAAEA,IAAK;MACXC,KAAK,EAAEA;IAAM,GACTC,SAAS,CACd,CAAC;EAEN;AACF;AAACI,OAAA,CAAAtC,aAAA,GAAAA,aAAA;AAED,MAAMU,iBAAiB,GAAGA,CAAA,KAAM;EAC9B,IACEC,gBAAW,KAAK,IAAI,IACpBA,gBAAW,CAACC,cAAc,KAAK,IAAI,IACnCD,gBAAW,CAAC4B,aAAa,KAAK,IAAI,IAClC5B,gBAAW,CAACO,iBAAiB,KAAK,IAAI,EACtC;IACA,MAAMsB,KAAK,CAAC,8BAA8B,CAAC;EAC7C;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireDefault","require","_Platform","_SkiaPictureViewNativeComponent","_types","_api","_SkiaViewNativeId","e","__esModule","default","_extends","Object","assign","bind","n","arguments","length","t","r","hasOwnProperty","call","apply","_defineProperty","_toPropertyKey","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","TypeError","String","Number","NativeSkiaPictureView","Platform","OS","SkiaPictureViewNativeComponent","SkiaJSDomView","React","Component","constructor","props","_nativeId","SkiaViewNativeId","current","root","onSize","assertSkiaViewApi","SkiaViewApi","setJsiProperty","tick","redraw","mode","requestId","requestAnimationFrame","nativeId","componentDidUpdate","prevProps","undefined","draw","makeImageSnapshot","rect","Skia","rec","PictureRecorder","canvas","beginRecording","ctx","JsiDrawingContext","render","picture","finishRecordingAsPicture","componentWillUnmount","cancelAnimationFrame","debug","viewProps","createElement","collapsable","nativeID","exports","requestRedraw","Error"],"sources":["SkiaJSDomView.tsx"],"sourcesContent":["import React from \"react\";\nimport type { HostComponent } from \"react-native\";\n\nimport type { Skia, SkRect } from \"../skia/types\";\nimport { Platform } from \"../Platform\";\nimport SkiaPictureViewNativeComponent from \"../specs/SkiaPictureViewNativeComponent\";\nimport { JsiDrawingContext } from \"../dom/types\";\n\nimport { SkiaViewApi } from \"./api\";\nimport type {\n SkiaPictureViewNativeProps,\n SkiaDomViewNativeProps,\n} from \"./types\";\nimport { SkiaViewNativeId } from \"./SkiaViewNativeId\";\n\nconst NativeSkiaPictureView: HostComponent<SkiaPictureViewNativeProps> =\n Platform.OS !== \"web\"\n ? SkiaPictureViewNativeComponent\n : // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (null as any);\n\ninterface SkiaDomViewProps extends SkiaDomViewNativeProps {\n mode?: \"default\" | \"continuous\";\n}\n\ntype SkiaJSDomViewProps = SkiaDomViewProps & {\n Skia: Skia;\n mode?: \"default\" | \"continuous\";\n};\n\nexport class SkiaJSDomView extends React.Component<SkiaJSDomViewProps> {\n constructor(props: SkiaJSDomViewProps) {\n super(props);\n this._nativeId = SkiaViewNativeId.current++;\n const { root, onSize } = props;\n if (root) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"root\", root);\n }\n if (onSize) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"onSize\", onSize);\n }\n this.tick();\n }\n\n private _nativeId: number;\n private requestId = 0;\n\n private tick() {\n this.redraw();\n if (this.props.mode === \"continuous\") {\n this.requestId = requestAnimationFrame(this.tick.bind(this));\n }\n }\n\n public get nativeId() {\n return this._nativeId;\n }\n\n componentDidUpdate(prevProps: SkiaDomViewProps & { Skia: Skia }) {\n const { root, onSize } = this.props;\n if (root !== prevProps.root && root !== undefined) {\n assertSkiaViewApi();\n this.draw();\n }\n if (onSize !== prevProps.onSize) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"onSize\", onSize);\n }\n this.tick();\n }\n\n /**\n * Creates a snapshot from the canvas in the surface\n * @param rect Rect to use as bounds. Optional.\n * @returns An Image object.\n */\n public makeImageSnapshot(rect?: SkRect) {\n assertSkiaViewApi();\n return SkiaViewApi.makeImageSnapshot(this._nativeId, rect);\n }\n\n /**\n * Sends a redraw request to the native SkiaView.\n */\n public redraw() {\n assertSkiaViewApi();\n this.draw();\n }\n\n private draw() {\n const { root, Skia } = this.props;\n if (root !== undefined) {\n assertSkiaViewApi();\n const rec = Skia.PictureRecorder();\n const canvas = rec.beginRecording();\n const ctx = new JsiDrawingContext(Skia, canvas);\n root.render(ctx);\n const picture = rec.finishRecordingAsPicture();\n SkiaViewApi.setJsiProperty(this._nativeId, \"picture\", picture);\n }\n }\n\n /**\n * Clear up the dom node when unmounting to release resources.\n */\n componentWillUnmount(): void {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"picture\", null);\n if (this.requestId) {\n cancelAnimationFrame(this.requestId);\n }\n }\n\n render() {\n const { debug = false, ...viewProps } = this.props;\n return (\n <NativeSkiaPictureView\n collapsable={false}\n nativeID={`${this._nativeId}`}\n debug={debug}\n {...viewProps}\n />\n );\n }\n}\n\nconst assertSkiaViewApi = () => {\n if (\n SkiaViewApi === null ||\n SkiaViewApi.setJsiProperty === null ||\n SkiaViewApi.requestRedraw === null ||\n SkiaViewApi.makeImageSnapshot === null\n ) {\n throw Error(\"Skia View Api was not found.\");\n }\n};\n"],"mappings":";;;;;;AAAA,I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SAAS,EAAE4B,OAAO,CAAC;IAChE;EACF;;EAEA;AACF;AACA;EACEE,oBAAoBA,CAAA,EAAS;IAC3BzB,iBAAiB,CAAC,CAAC;IACnBC,gBAAW,CAACC,cAAc,CAAC,IAAI,CAACP,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC;IAC3D,IAAI,IAAI,CAACW,SAAS,EAAE;MAClBoB,oBAAoB,CAAC,IAAI,CAACpB,SAAS,CAAC;IACtC;EACF;EAEAgB,MAAMA,CAAA,EAAG;IACP,MAAM;MAAEK,KAAK,GAAG,KAAK;MAAE,GAAGC;IAAU,CAAC,GAAG,IAAI,CAAClC,KAAK;IAClD,oBACE7C,MAAA,CAAAU,OAAA,CAAAsE,aAAA,CAAC3C,qBAAqB,EAAA1B,QAAA;MACpBsE,WAAW,EAAE,KAAM;MACnBC,QAAQ,EAAE,GAAG,IAAI,CAACpC,SAAS,EAAG;MAC9BgC,KAAK,EAAEA;IAAM,GACTC,SAAS,CACd,CAAC;EAEN;AACF;AAACI,OAAA,CAAA1C,aAAA,GAAAA,aAAA;AAED,MAAMU,iBAAiB,GAAGA,CAAA,KAAM;EAC9B,IACEC,gBAAW,KAAK,IAAI,IACpBA,gBAAW,CAACC,cAAc,KAAK,IAAI,IACnCD,gBAAW,CAACgC,aAAa,KAAK,IAAI,IAClChC,gBAAW,CAACY,iBAAiB,KAAK,IAAI,EACtC;IACA,MAAMqB,KAAK,CAAC,8BAA8B,CAAC;EAC7C;AACF,CAAC","ignoreList":[]}
@@ -1,11 +1,17 @@
1
1
  import React from "react";
2
2
  import type { SkRect } from "../skia/types";
3
- import type { SkiaPictureViewProps } from "./types";
3
+ import type { SkiaPictureViewNativeProps } from "./types";
4
+ interface SkiaPictureViewProps extends SkiaPictureViewNativeProps {
5
+ mode?: "default" | "continuous";
6
+ }
4
7
  export declare class SkiaPictureView extends React.Component<SkiaPictureViewProps> {
8
+ private requestId;
5
9
  constructor(props: SkiaPictureViewProps);
6
10
  private _nativeId;
7
11
  get nativeId(): number;
8
12
  componentDidUpdate(prevProps: SkiaPictureViewProps): void;
13
+ componentWillUnmount(): void;
14
+ private tick;
9
15
  /**
10
16
  * Creates a snapshot from the canvas in the surface
11
17
  * @param rect Rect to use as bounds. Optional.
@@ -18,3 +24,4 @@ export declare class SkiaPictureView extends React.Component<SkiaPictureViewProp
18
24
  redraw(): void;
19
25
  render(): React.JSX.Element;
20
26
  }
27
+ export {};
@@ -17,6 +17,7 @@ const NativeSkiaPictureView = _SkiaPictureViewNativeComponent.default;
17
17
  class SkiaPictureView extends _react.default.Component {
18
18
  constructor(props) {
19
19
  super(props);
20
+ _defineProperty(this, "requestId", 0);
20
21
  _defineProperty(this, "_nativeId", void 0);
21
22
  this._nativeId = _SkiaViewNativeId.SkiaViewNativeId.current++;
22
23
  const {
@@ -31,6 +32,7 @@ class SkiaPictureView extends _react.default.Component {
31
32
  assertSkiaViewApi();
32
33
  _api.SkiaViewApi.setJsiProperty(this._nativeId, "onSize", onSize);
33
34
  }
35
+ this.tick();
34
36
  }
35
37
  get nativeId() {
36
38
  return this._nativeId;
@@ -48,6 +50,18 @@ class SkiaPictureView extends _react.default.Component {
48
50
  assertSkiaViewApi();
49
51
  _api.SkiaViewApi.setJsiProperty(this._nativeId, "onSize", onSize);
50
52
  }
53
+ this.tick();
54
+ }
55
+ componentWillUnmount() {
56
+ if (this.requestId) {
57
+ cancelAnimationFrame(this.requestId);
58
+ }
59
+ }
60
+ tick() {
61
+ this.redraw();
62
+ if (this.props.mode === "continuous") {
63
+ this.requestId = requestAnimationFrame(this.tick.bind(this));
64
+ }
51
65
  }
52
66
 
53
67
  /**
@@ -76,7 +90,6 @@ class SkiaPictureView extends _react.default.Component {
76
90
  return /*#__PURE__*/_react.default.createElement(NativeSkiaPictureView, _extends({
77
91
  collapsable: false,
78
92
  nativeID: `${this._nativeId}`,
79
- mode: mode !== null && mode !== void 0 ? mode : "default",
80
93
  debug: debug
81
94
  }, viewProps));
82
95
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","_SkiaPictureViewNativeComponent","_api","_SkiaViewNativeId","e","__esModule","default","_extends","Object","assign","bind","n","arguments","length","t","r","hasOwnProperty","call","apply","_defineProperty","_toPropertyKey","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","TypeError","String","Number","NativeSkiaPictureView","SkiaPictureViewNativeComponent","SkiaPictureView","React","Component","constructor","props","_nativeId","SkiaViewNativeId","current","picture","onSize","assertSkiaViewApi","SkiaViewApi","setJsiProperty","nativeId","componentDidUpdate","prevProps","makeImageSnapshot","rect","redraw","requestRedraw","render","mode","debug","viewProps","createElement","collapsable","nativeID","exports","Error"],"sources":["SkiaPictureView.tsx"],"sourcesContent":["import React from \"react\";\n\nimport type { SkRect } from \"../skia/types\";\nimport SkiaPictureViewNativeComponent from \"../specs/SkiaPictureViewNativeComponent\";\n\nimport { SkiaViewApi } from \"./api\";\nimport type { SkiaPictureViewProps } from \"./types\";\nimport { SkiaViewNativeId } from \"./SkiaViewNativeId\";\n\nconst NativeSkiaPictureView = SkiaPictureViewNativeComponent;\n\nexport class SkiaPictureView extends React.Component<SkiaPictureViewProps> {\n constructor(props: SkiaPictureViewProps) {\n super(props);\n this._nativeId = SkiaViewNativeId.current++;\n const { picture, onSize } = props;\n if (picture) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"picture\", picture);\n }\n if (onSize) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"onSize\", onSize);\n }\n }\n\n private _nativeId: number;\n\n public get nativeId() {\n return this._nativeId;\n }\n\n componentDidUpdate(prevProps: SkiaPictureViewProps) {\n const { picture, onSize } = this.props;\n if (picture !== prevProps.picture) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"picture\", picture);\n }\n if (onSize !== prevProps.onSize) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"onSize\", onSize);\n }\n }\n\n /**\n * Creates a snapshot from the canvas in the surface\n * @param rect Rect to use as bounds. Optional.\n * @returns An Image object.\n */\n public makeImageSnapshot(rect?: SkRect) {\n assertSkiaViewApi();\n return SkiaViewApi.makeImageSnapshot(this._nativeId, rect);\n }\n\n /**\n * Sends a redraw request to the native SkiaView.\n */\n public redraw() {\n assertSkiaViewApi();\n SkiaViewApi.requestRedraw(this._nativeId);\n }\n\n render() {\n const { mode, debug = false, ...viewProps } = this.props;\n return (\n <NativeSkiaPictureView\n collapsable={false}\n nativeID={`${this._nativeId}`}\n mode={mode ?? \"default\"}\n debug={debug}\n {...viewProps}\n />\n );\n }\n}\n\nconst assertSkiaViewApi = () => {\n if (\n SkiaViewApi === null ||\n SkiaViewApi.setJsiProperty === null ||\n SkiaViewApi.requestRedraw === null ||\n SkiaViewApi.makeImageSnapshot === null\n ) {\n throw Error(\"Skia View Api was not found.\");\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,+BAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,IAAA,GAAAF,OAAA;AAEA,IAAAG,iBAAA,GAAAH,OAAA;AAAsD,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,SAAA,WAAAA,QAAA,GAAAC,MAAA,CAAAC,MAAA,GAAAD,MAAA,CAAAC,MAAA,CAAAC,IAAA,eAAAC,CAAA,aAAAP,CAAA,MAAAA,CAAA,GAAAQ,SAAA,CAAAC,MAAA,EAAAT,CAAA,UAAAU,CAAA,GAAAF,SAAA,CAAAR,CAAA,YAAAW,CAAA,IAAAD,CAAA,OAAAE,cAAA,CAAAC,IAAA,CAAAH,CAAA,EAAAC,CAAA,MAAAJ,CAAA,CAAAI,CAAA,IAAAD,CAAA,CAAAC,CAAA,aAAAJ,CAAA,KAAAJ,QAAA,CAAAW,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xBC,KAAK,EAAEA;IAAM,GACTC,SAAS,CACd,CAAC;EAEN;AACF;AAACI,OAAA,CAAA3B,eAAA,GAAAA,eAAA;AAED,MAAMU,iBAAiB,GAAGA,CAAA,KAAM;EAC9B,IACEC,gBAAW,KAAK,IAAI,IACpBA,gBAAW,CAACC,cAAc,KAAK,IAAI,IACnCD,gBAAW,CAACQ,aAAa,KAAK,IAAI,IAClCR,gBAAW,CAACK,iBAAiB,KAAK,IAAI,EACtC;IACA,MAAMY,KAAK,CAAC,8BAA8B,CAAC;EAC7C;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireDefault","require","_SkiaPictureViewNativeComponent","_api","_SkiaViewNativeId","e","__esModule","default","_extends","Object","assign","bind","n","arguments","length","t","r","hasOwnProperty","call","apply","_defineProperty","_toPropertyKey","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","TypeError","String","Number","NativeSkiaPictureView","SkiaPictureViewNativeComponent","SkiaPictureView","React","Component","constructor","props","_nativeId","SkiaViewNativeId","current","picture","onSize","assertSkiaViewApi","SkiaViewApi","setJsiProperty","tick","nativeId","componentDidUpdate","prevProps","componentWillUnmount","requestId","cancelAnimationFrame","redraw","mode","requestAnimationFrame","makeImageSnapshot","rect","requestRedraw","render","debug","viewProps","createElement","collapsable","nativeID","exports","Error"],"sources":["SkiaPictureView.tsx"],"sourcesContent":["import React from \"react\";\n\nimport type { SkRect } from \"../skia/types\";\nimport SkiaPictureViewNativeComponent from \"../specs/SkiaPictureViewNativeComponent\";\n\nimport { SkiaViewApi } from \"./api\";\nimport type { SkiaPictureViewNativeProps } from \"./types\";\nimport { SkiaViewNativeId } from \"./SkiaViewNativeId\";\n\nconst NativeSkiaPictureView = SkiaPictureViewNativeComponent;\n\ninterface SkiaPictureViewProps extends SkiaPictureViewNativeProps {\n mode?: \"default\" | \"continuous\";\n}\n\nexport class SkiaPictureView extends React.Component<SkiaPictureViewProps> {\n private requestId = 0;\n\n constructor(props: SkiaPictureViewProps) {\n super(props);\n this._nativeId = SkiaViewNativeId.current++;\n const { picture, onSize } = props;\n if (picture) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"picture\", picture);\n }\n if (onSize) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"onSize\", onSize);\n }\n this.tick();\n }\n\n private _nativeId: number;\n\n public get nativeId() {\n return this._nativeId;\n }\n\n componentDidUpdate(prevProps: SkiaPictureViewProps) {\n const { picture, onSize } = this.props;\n if (picture !== prevProps.picture) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"picture\", picture);\n }\n if (onSize !== prevProps.onSize) {\n assertSkiaViewApi();\n SkiaViewApi.setJsiProperty(this._nativeId, \"onSize\", onSize);\n }\n this.tick();\n }\n\n componentWillUnmount() {\n if (this.requestId) {\n cancelAnimationFrame(this.requestId);\n }\n }\n\n private tick() {\n this.redraw();\n if (this.props.mode === \"continuous\") {\n this.requestId = requestAnimationFrame(this.tick.bind(this));\n }\n }\n\n /**\n * Creates a snapshot from the canvas in the surface\n * @param rect Rect to use as bounds. Optional.\n * @returns An Image object.\n */\n public makeImageSnapshot(rect?: SkRect) {\n assertSkiaViewApi();\n return SkiaViewApi.makeImageSnapshot(this._nativeId, rect);\n }\n\n /**\n * Sends a redraw request to the native SkiaView.\n */\n public redraw() {\n assertSkiaViewApi();\n SkiaViewApi.requestRedraw(this._nativeId);\n }\n\n render() {\n const { mode, debug = false, ...viewProps } = this.props;\n return (\n <NativeSkiaPictureView\n collapsable={false}\n nativeID={`${this._nativeId}`}\n debug={debug}\n {...viewProps}\n />\n );\n }\n}\n\nconst assertSkiaViewApi = () => {\n if (\n SkiaViewApi === null ||\n SkiaViewApi.setJsiProperty === null ||\n SkiaViewApi.requestRedraw === null ||\n SkiaViewApi.makeImageSnapshot === null\n ) {\n throw Error(\"Skia View Api was not found.\");\n }\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA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Ac,KAAK,IAAI,IACnCD,gBAAW,CAACc,aAAa,KAAK,IAAI,IAClCd,gBAAW,CAACY,iBAAiB,KAAK,IAAI,EACtC;IACA,MAAMU,KAAK,CAAC,8BAA8B,CAAC;EAC7C;AACF,CAAC","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  import type { SkCanvas } from "../skia/types";
2
- import type { SkiaPictureViewProps } from "./types";
2
+ import type { SkiaPictureViewNativeProps } from "./types";
3
3
  import { SkiaBaseWebView } from "./SkiaBaseWebView";
4
- export declare class SkiaPictureView extends SkiaBaseWebView<SkiaPictureViewProps> {
5
- constructor(props: SkiaPictureViewProps);
4
+ export declare class SkiaPictureView extends SkiaBaseWebView<SkiaPictureViewNativeProps> {
5
+ constructor(props: SkiaPictureViewNativeProps);
6
6
  protected renderInCanvas(canvas: SkCanvas): void;
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_SkiaBaseWebView","require","SkiaPictureView","SkiaBaseWebView","constructor","props","renderInCanvas","canvas","picture","drawPicture","exports"],"sources":["SkiaPictureView.web.tsx"],"sourcesContent":["import type { SkCanvas } from \"../skia/types\";\n\nimport type { SkiaPictureViewProps } from \"./types\";\nimport { SkiaBaseWebView } from \"./SkiaBaseWebView\";\n\nexport class SkiaPictureView extends SkiaBaseWebView<SkiaPictureViewProps> {\n constructor(props: SkiaPictureViewProps) {\n super(props);\n }\n\n protected renderInCanvas(canvas: SkCanvas): void {\n if (this.props.picture) {\n canvas.drawPicture(this.props.picture);\n }\n }\n}\n"],"mappings":";;;;;;AAGA,IAAAA,gBAAA,GAAAC,OAAA;AAEO,MAAMC,eAAe,SAASC,gCAAe,CAAuB;EACzEC,WAAWA,CAACC,KAA2B,EAAE;IACvC,KAAK,CAACA,KAAK,CAAC;EACd;EAEUC,cAAcA,CAACC,MAAgB,EAAQ;IAC/C,IAAI,IAAI,CAACF,KAAK,CAACG,OAAO,EAAE;MACtBD,MAAM,CAACE,WAAW,CAAC,IAAI,CAACJ,KAAK,CAACG,OAAO,CAAC;IACxC;EACF;AACF;AAACE,OAAA,CAAAR,eAAA,GAAAA,eAAA","ignoreList":[]}
1
+ {"version":3,"names":["_SkiaBaseWebView","require","SkiaPictureView","SkiaBaseWebView","constructor","props","renderInCanvas","canvas","picture","drawPicture","exports"],"sources":["SkiaPictureView.web.tsx"],"sourcesContent":["import type { SkCanvas } from \"../skia/types\";\n\nimport type { SkiaPictureViewNativeProps } from \"./types\";\nimport { SkiaBaseWebView } from \"./SkiaBaseWebView\";\n\nexport class SkiaPictureView extends SkiaBaseWebView<SkiaPictureViewNativeProps> {\n constructor(props: SkiaPictureViewNativeProps) {\n super(props);\n }\n\n protected renderInCanvas(canvas: SkCanvas): void {\n if (this.props.picture) {\n canvas.drawPicture(this.props.picture);\n }\n }\n}\n"],"mappings":";;;;;;AAGA,IAAAA,gBAAA,GAAAC,OAAA;AAEO,MAAMC,eAAe,SAASC,gCAAe,CAA6B;EAC/EC,WAAWA,CAACC,KAAiC,EAAE;IAC7C,KAAK,CAACA,KAAK,CAAC;EACd;EAEUC,cAAcA,CAACC,MAAgB,EAAQ;IAC/C,IAAI,IAAI,CAACF,KAAK,CAACG,OAAO,EAAE;MACtBD,MAAM,CAACE,WAAW,CAAC,IAAI,CAACJ,KAAK,CAACG,OAAO,CAAC;IACxC;EACF;AACF;AAACE,OAAA,CAAAR,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -2,9 +2,7 @@ import type { ViewProps } from "react-native";
2
2
  import type { GroupProps, RenderNode } from "../dom/types";
3
3
  import type { SkImage, SkPicture, SkRect, SkSize } from "../skia/types";
4
4
  import type { SharedValueType } from "../renderer/processors/Animations/Animations";
5
- export type DrawMode = "continuous" | "default";
6
5
  export type NativeSkiaViewProps = ViewProps & {
7
- mode?: DrawMode;
8
6
  debug?: boolean;
9
7
  };
10
8
  export interface DrawingInfo {
@@ -19,14 +17,6 @@ export interface ISkiaViewApi {
19
17
  makeImageSnapshotAsync: (nativeId: number, rect?: SkRect) => Promise<SkImage>;
20
18
  }
21
19
  export interface SkiaBaseViewProps extends ViewProps {
22
- /**
23
- * Sets the drawing mode for the skia view. There are two drawing
24
- * modes, "continuous" and "default", where the continuous mode will
25
- * continuously redraw the view, and the default mode will only
26
- * redraw when any of the regular react properties are changed like
27
- * sizes and margins.
28
- */
29
- mode?: DrawMode;
30
20
  /**
31
21
  * When set to true the view will display information about the
32
22
  * average time it takes to render.
@@ -38,9 +28,9 @@ export interface SkiaBaseViewProps extends ViewProps {
38
28
  */
39
29
  onSize?: SharedValueType<SkSize>;
40
30
  }
41
- export interface SkiaPictureViewProps extends SkiaBaseViewProps {
31
+ export interface SkiaPictureViewNativeProps extends SkiaBaseViewProps {
42
32
  picture?: SkPicture;
43
33
  }
44
- export interface SkiaDomViewProps extends SkiaBaseViewProps {
34
+ export interface SkiaDomViewNativeProps extends SkiaBaseViewProps {
45
35
  root?: RenderNode<GroupProps>;
46
36
  }
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { ViewProps } from \"react-native\";\n\nimport type { GroupProps, RenderNode } from \"../dom/types\";\nimport type { SkImage, SkPicture, SkRect, SkSize } from \"../skia/types\";\nimport type { SharedValueType } from \"../renderer/processors/Animations/Animations\";\n\nexport type DrawMode = \"continuous\" | \"default\";\n\nexport type NativeSkiaViewProps = ViewProps & {\n mode?: DrawMode;\n debug?: boolean;\n};\n\nexport interface DrawingInfo {\n width: number;\n height: number;\n timestamp: number;\n}\n\nexport interface ISkiaViewApi {\n setJsiProperty: <T>(nativeId: number, name: string, value: T) => void;\n requestRedraw: (nativeId: number) => void;\n makeImageSnapshot: (nativeId: number, rect?: SkRect) => SkImage;\n makeImageSnapshotAsync: (nativeId: number, rect?: SkRect) => Promise<SkImage>;\n}\n\nexport interface SkiaBaseViewProps extends ViewProps {\n /**\n * Sets the drawing mode for the skia view. There are two drawing\n * modes, \"continuous\" and \"default\", where the continuous mode will\n * continuously redraw the view, and the default mode will only\n * redraw when any of the regular react properties are changed like\n * sizes and margins.\n */\n mode?: DrawMode;\n /**\n * When set to true the view will display information about the\n * average time it takes to render.\n */\n debug?: boolean;\n /**\n * Pass an animated value to the onSize property to get updates when\n * the Skia view is resized.\n */\n onSize?: SharedValueType<SkSize>;\n}\n\nexport interface SkiaPictureViewProps extends SkiaBaseViewProps {\n picture?: SkPicture;\n}\n\nexport interface SkiaDomViewProps extends SkiaBaseViewProps {\n root?: RenderNode<GroupProps>;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { ViewProps } from \"react-native\";\n\nimport type { GroupProps, RenderNode } from \"../dom/types\";\nimport type { SkImage, SkPicture, SkRect, SkSize } from \"../skia/types\";\nimport type { SharedValueType } from \"../renderer/processors/Animations/Animations\";\n\nexport type NativeSkiaViewProps = ViewProps & {\n debug?: boolean;\n};\n\nexport interface DrawingInfo {\n width: number;\n height: number;\n timestamp: number;\n}\n\nexport interface ISkiaViewApi {\n setJsiProperty: <T>(nativeId: number, name: string, value: T) => void;\n requestRedraw: (nativeId: number) => void;\n makeImageSnapshot: (nativeId: number, rect?: SkRect) => SkImage;\n makeImageSnapshotAsync: (nativeId: number, rect?: SkRect) => Promise<SkImage>;\n}\n\nexport interface SkiaBaseViewProps extends ViewProps {\n /**\n * When set to true the view will display information about the\n * average time it takes to render.\n */\n debug?: boolean;\n /**\n * Pass an animated value to the onSize property to get updates when\n * the Skia view is resized.\n */\n onSize?: SharedValueType<SkSize>;\n}\n\nexport interface SkiaPictureViewNativeProps extends SkiaBaseViewProps {\n picture?: SkPicture;\n}\n\nexport interface SkiaDomViewNativeProps extends SkiaBaseViewProps {\n root?: RenderNode<GroupProps>;\n}\n"],"mappings":"","ignoreList":[]}
@@ -6,5 +6,6 @@ export declare const useCanvasRef: () => React.RefObject<SkiaDomView>;
6
6
  export interface CanvasProps extends SkiaBaseViewProps {
7
7
  ref?: RefObject<SkiaDomView>;
8
8
  children: ReactNode;
9
+ mode?: "default" | "continuous";
9
10
  }
10
11
  export declare const Canvas: FunctionComponent<CanvasProps & React.RefAttributes<SkiaDomView>>;
@@ -27,7 +27,7 @@ export const Canvas = /*#__PURE__*/forwardRef(({
27
27
  children,
28
28
  style,
29
29
  debug,
30
- mode,
30
+ mode = "default",
31
31
  onSize: _onSize,
32
32
  onLayout: _onLayout,
33
33
  ...props
@@ -61,19 +61,19 @@ export const Canvas = /*#__PURE__*/forwardRef(({
61
61
  style: style,
62
62
  root: root.dom,
63
63
  onLayout: onLayout,
64
- mode: mode,
65
- debug: debug
64
+ debug: debug,
65
+ mode: mode
66
66
  }, props));
67
67
  } else {
68
68
  return /*#__PURE__*/React.createElement(SkiaJSDomView, _extends({
69
- Skia: Skia
69
+ Skia: Skia,
70
+ mode: mode
70
71
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
71
72
  ,
72
73
  ref: ref,
73
74
  style: style,
74
75
  root: root.dom,
75
76
  onLayout: onLayout,
76
- mode: mode,
77
77
  debug: debug
78
78
  }, props));
79
79
  }
@@ -1 +1 @@
1
- {"version":3,"names":["React","useEffect","useCallback","useMemo","forwardRef","useRef","SkiaDomView","Skia","SkiaJSDomView","SkiaRoot","NATIVE_DOM","useCanvasRef","useOnSizeEvent","resultValue","onLayout","event","width","height","nativeEvent","layout","value","Canvas","children","style","debug","mode","onSize","_onSize","_onLayout","props","forwardedRef","innerRef","ref","useCombinedRefs","redraw","_innerRef$current","current","getNativeId","_innerRef$current$nat","_innerRef$current2","id","nativeId","root","render","unmount","createElement","_extends","dom","refs","targetRef","forEach"],"sources":["Canvas.tsx"],"sourcesContent":["import React, {\n useEffect,\n useCallback,\n useMemo,\n forwardRef,\n useRef,\n} from \"react\";\nimport type {\n RefObject,\n ReactNode,\n MutableRefObject,\n ForwardedRef,\n FunctionComponent,\n} from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\n\nimport { SkiaDomView } from \"../views\";\nimport { Skia } from \"../skia/Skia\";\nimport type { SkiaBaseViewProps } from \"../views\";\nimport { SkiaJSDomView } from \"../views/SkiaJSDomView\";\n\nimport { SkiaRoot } from \"./Reconciler\";\nimport { NATIVE_DOM } from \"./HostComponents\";\n\nexport const useCanvasRef = () => useRef<SkiaDomView>(null);\n\nexport interface CanvasProps extends SkiaBaseViewProps {\n ref?: RefObject<SkiaDomView>;\n children: ReactNode;\n}\n\nconst useOnSizeEvent = (\n resultValue: SkiaBaseViewProps[\"onSize\"],\n onLayout?: (event: LayoutChangeEvent) => void\n) => {\n return useCallback(\n (event: LayoutChangeEvent) => {\n if (onLayout) {\n onLayout(event);\n }\n const { width, height } = event.nativeEvent.layout;\n\n if (resultValue) {\n resultValue.value = { width, height };\n }\n },\n [onLayout, resultValue]\n );\n};\n\nexport const Canvas = forwardRef<SkiaDomView, CanvasProps>(\n (\n {\n children,\n style,\n debug,\n mode,\n onSize: _onSize,\n onLayout: _onLayout,\n ...props\n },\n forwardedRef\n ) => {\n const onLayout = useOnSizeEvent(_onSize, _onLayout);\n const innerRef = useCanvasRef();\n const ref = useCombinedRefs(forwardedRef, innerRef);\n const redraw = useCallback(() => {\n innerRef.current?.redraw();\n }, [innerRef]);\n const getNativeId = useCallback(() => {\n const id = innerRef.current?.nativeId ?? -1;\n return id;\n }, [innerRef]);\n\n const root = useMemo(\n () => new SkiaRoot(Skia, NATIVE_DOM, redraw, getNativeId),\n [redraw, getNativeId]\n );\n\n // Render effect\n useEffect(() => {\n root.render(children);\n }, [children, root, redraw]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n if (NATIVE_DOM) {\n return (\n <SkiaDomView\n ref={ref}\n style={style}\n root={root.dom}\n onLayout={onLayout}\n mode={mode}\n debug={debug}\n {...props}\n />\n );\n } else {\n return (\n <SkiaJSDomView\n Skia={Skia}\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ref={ref as any}\n style={style}\n root={root.dom}\n onLayout={onLayout}\n mode={mode}\n debug={debug}\n {...props}\n />\n );\n }\n }\n) as FunctionComponent<CanvasProps & React.RefAttributes<SkiaDomView>>;\n\n/**\n * Combines a list of refs into a single ref. This can be used to provide\n * both a forwarded ref and an internal ref keeping the same functionality\n * on both of the refs.\n * @param refs Array of refs to combine\n * @returns A single ref that can be used in a ref prop.\n */\nconst useCombinedRefs = <T,>(\n ...refs: Array<MutableRefObject<T> | ForwardedRef<T>>\n) => {\n const targetRef = React.useRef<T>(null);\n React.useEffect(() => {\n refs.forEach((ref) => {\n if (ref) {\n if (typeof ref === \"function\") {\n ref(targetRef.current);\n } else {\n ref.current = targetRef.current;\n }\n }\n });\n }, [refs]);\n return targetRef;\n};\n"],"mappings":";AAAA,OAAOA,KAAK,IACVC,SAAS,EACTC,WAAW,EACXC,OAAO,EACPC,UAAU,EACVC,MAAM,QACD,OAAO;AAUd,SAASC,WAAW,QAAQ,UAAU;AACtC,SAASC,IAAI,QAAQ,cAAc;AAEnC,SAASC,aAAa,QAAQ,wBAAwB;AAEtD,SAASC,QAAQ,QAAQ,cAAc;AACvC,SAASC,UAAU,QAAQ,kBAAkB;AAE7C,OAAO,MAAMC,YAAY,GAAGA,CAAA,KAAMN,MAAM,CAAc,IAAI,CAAC;AAO3D,MAAMO,cAAc,GAAGA,CACrBC,WAAwC,EACxCC,QAA6C,KAC1C;EACH,OAAOZ,WAAW,CACfa,KAAwB,IAAK;IAC5B,IAAID,QAAQ,EAAE;MACZA,QAAQ,CAACC,KAAK,CAAC;IACjB;IACA,MAAM;MAAEC,KAAK;MAAEC;IAAO,CAAC,GAAGF,KAAK,CAACG,WAAW,CAACC,MAAM;IAElD,IAAIN,WAAW,EAAE;MACfA,WAAW,CAACO,KAAK,GAAG;QAAEJ,KAAK;QAAEC;MAAO,CAAC;IACvC;EACF,CAAC,EACD,CAACH,QAAQ,EAAED,WAAW,CACxB,CAAC;AACH,CAAC;AAED,OAAO,MAAMQ,MAAM,gBAAGjB,UAAU,CAC9B,CACE;EACEkB,QAAQ;EACRC,KAAK;EACLC,KAAK;EACLC,IAAI;EACJC,MAAM,E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AEV,IAAIhC,UAAU,EAAE;IACd,oBACEV,KAAA,CAAA6C,aAAA,CAACvC,WAAW,EAAAwC,QAAA;MACVd,GAAG,EAAEA,GAAI;MACTT,KAAK,EAAEA,KAAM;MACbmB,IAAI,EAAEA,IAAI,CAACK,GAAI;MACfjC,QAAQ,EAAEA,QAAS;MACnBW,IAAI,EAAEA,IAAK;MACXD,KAAK,EAAEA;IAAM,GACTK,KAAK,CACV,CAAC;EAEN,CAAC,MAAM;IACL,oBACE7B,KAAA,CAAA6C,aAAA,CAACrC,aAAa,EAAAsC,QAAA;MACZvC,IAAI,EAAEA;MACN;MAAA;MACAyB,GAAG,EAAEA,GAAW;MAChBT,KAAK,EAAEA,KAAM;MACbmB,IAAI,EAAEA,IAAI,CAACK,GAAI;MACfjC,QAAQ,EAAEA,QAAS;MACnBW,IAAI,EAAEA,IAAK;MACXD,KAAK,EAAEA;IAAM,GACTK,KAAK,CACV,CAAC;EAEN;AACF,CACF,CAAsE;;AAEtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMI,eAAe,GAAGA,CACtB,GAAGe,IAAkD,KAClD;EACH,MAAMC,SAAS,GAAGjD,KAAK,CAACK,MAAM,CAAI,IAAI,CAAC;EACvCL,KAAK,CAACC,SAAS,CAAC,MAAM;IACpB+C,IAAI,CAACE,OAAO,CAAElB,GAAG,IAAK;MACpB,IAAIA,GAAG,EAAE;QACP,IAAI,OAAOA,GAAG,KAAK,UAAU,EAAE;UAC7BA,GAAG,CAACiB,SAAS,CAACb,OAAO,CAAC;QACxB,CAAC,MAAM;UACLJ,GAAG,CAACI,OAAO,GAAGa,SAAS,CAACb,OAAO;QACjC;MACF;IACF,CAAC,CAAC;EACJ,CAAC,EAAE,CAACY,IAAI,CAAC,CAAC;EACV,OAAOC,SAAS;AAClB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","useEffect","useCallback","useMemo","forwardRef","useRef","SkiaDomView","Skia","SkiaJSDomView","SkiaRoot","NATIVE_DOM","useCanvasRef","useOnSizeEvent","resultValue","onLayout","event","width","height","nativeEvent","layout","value","Canvas","children","style","debug","mode","onSize","_onSize","_onLayout","props","forwardedRef","innerRef","ref","useCombinedRefs","redraw","_innerRef$current","current","getNativeId","_innerRef$current$nat","_innerRef$current2","id","nativeId","root","render","unmount","createElement","_extends","dom","refs","targetRef","forEach"],"sources":["Canvas.tsx"],"sourcesContent":["import React, {\n useEffect,\n useCallback,\n useMemo,\n forwardRef,\n useRef,\n} from \"react\";\nimport type {\n RefObject,\n ReactNode,\n MutableRefObject,\n ForwardedRef,\n FunctionComponent,\n} from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\n\nimport { SkiaDomView } from \"../views\";\nimport { Skia } from \"../skia/Skia\";\nimport type { SkiaBaseViewProps } from \"../views\";\nimport { SkiaJSDomView } from \"../views/SkiaJSDomView\";\n\nimport { SkiaRoot } from \"./Reconciler\";\nimport { NATIVE_DOM } from \"./HostComponents\";\n\nexport const useCanvasRef = () => useRef<SkiaDomView>(null);\n\nexport interface CanvasProps extends SkiaBaseViewProps {\n ref?: RefObject<SkiaDomView>;\n children: ReactNode;\n mode?: \"default\" | \"continuous\";\n}\n\nconst useOnSizeEvent = (\n resultValue: SkiaBaseViewProps[\"onSize\"],\n onLayout?: (event: LayoutChangeEvent) => void\n) => {\n return useCallback(\n (event: LayoutChangeEvent) => {\n if (onLayout) {\n onLayout(event);\n }\n const { width, height } = event.nativeEvent.layout;\n\n if (resultValue) {\n resultValue.value = { width, height };\n }\n },\n [onLayout, resultValue]\n );\n};\n\nexport const Canvas = forwardRef<SkiaDomView, CanvasProps>(\n (\n {\n children,\n style,\n debug,\n mode = \"default\",\n onSize: _onSize,\n onLayout: _onLayout,\n ...props\n },\n forwardedRef\n ) => {\n const onLayout = useOnSizeEvent(_onSize, _onLayout);\n const innerRef = useCanvasRef();\n const ref = useCombinedRefs(forwardedRef, innerRef);\n const redraw = useCallback(() => {\n innerRef.current?.redraw();\n }, [innerRef]);\n const getNativeId = useCallback(() => {\n const id = innerRef.current?.nativeId ?? -1;\n return id;\n }, [innerRef]);\n\n const root = useMemo(\n () => new SkiaRoot(Skia, NATIVE_DOM, redraw, getNativeId),\n [redraw, getNativeId]\n );\n\n // Render effect\n useEffect(() => {\n root.render(children);\n }, [children, root, redraw]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n if (NATIVE_DOM) {\n return (\n <SkiaDomView\n ref={ref}\n style={style}\n root={root.dom}\n onLayout={onLayout}\n debug={debug}\n mode={mode}\n {...props}\n />\n );\n } else {\n return (\n <SkiaJSDomView\n Skia={Skia}\n mode={mode}\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ref={ref as any}\n style={style}\n root={root.dom}\n onLayout={onLayout}\n debug={debug}\n {...props}\n />\n );\n }\n }\n) as FunctionComponent<CanvasProps & React.RefAttributes<SkiaDomView>>;\n\n/**\n * Combines a list of refs into a single ref. This can be used to provide\n * both a forwarded ref and an internal ref keeping the same functionality\n * on both of the refs.\n * @param refs Array of refs to combine\n * @returns A single ref that can be used in a ref prop.\n */\nconst useCombinedRefs = <T,>(\n ...refs: Array<MutableRefObject<T> | ForwardedRef<T>>\n) => {\n const targetRef = React.useRef<T>(null);\n React.useEffect(() => {\n refs.forEach((ref) => {\n if (ref) {\n if (typeof ref === \"function\") {\n ref(targetRef.current);\n } else {\n ref.current = targetRef.current;\n }\n }\n });\n }, [refs]);\n return targetRef;\n};\n"],"mappings":";AAAA,OAAOA,KAAK,IACVC,SAAS,EACTC,WAAW,EACXC,OAAO,EACPC,UAAU,EACVC,MAAM,QACD,OAAO;AAUd,SAASC,WAAW,QAAQ,UAAU;AACtC,SAASC,IAAI,QAAQ,cAAc;AAEnC,SAASC,aAAa,QAAQ,wBAAwB;AAEtD,SAASC,QAAQ,QAAQ,cAAc;AACvC,SAASC,UAAU,QAAQ,kBAAkB;AAE7C,OAAO,MAAMC,YAAY,GAAGA,CAAA,KAAMN,MAAM,CAAc,IAAI,CAAC;AAQ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AAMC,SAAS,GAAGjD,KAAK,CAACK,MAAM,CAAI,IAAI,CAAC;EACvCL,KAAK,CAACC,SAAS,CAAC,MAAM;IACpB+C,IAAI,CAACE,OAAO,CAAElB,GAAG,IAAK;MACpB,IAAIA,GAAG,EAAE;QACP,IAAI,OAAOA,GAAG,KAAK,UAAU,EAAE;UAC7BA,GAAG,CAACiB,SAAS,CAACb,OAAO,CAAC;QACxB,CAAC,MAAM;UACLJ,GAAG,CAACI,OAAO,GAAGa,SAAS,CAACb,OAAO;QACjC;MACF;IACF,CAAC,CAAC;EACJ,CAAC,EAAE,CAACY,IAAI,CAAC,CAAC;EACV,OAAOC,SAAS;AAClB,CAAC","ignoreList":[]}
@@ -1,6 +1,5 @@
1
1
  import type { ViewProps } from "react-native";
2
2
  export interface NativeProps extends ViewProps {
3
- mode: string;
4
3
  debug?: boolean;
5
4
  }
6
5
  declare const _default: import("react-native/Libraries/Utilities/codegenNativeComponent").NativeComponentType<NativeProps>;
@@ -1 +1 @@
1
- {"version":3,"names":["codegenNativeComponent"],"sources":["SkiaPictureViewNativeComponent.ts"],"sourcesContent":["import codegenNativeComponent from \"react-native/Libraries/Utilities/codegenNativeComponent\";\nimport type { ViewProps } from \"react-native\";\n\nexport interface NativeProps extends ViewProps {\n mode: string;\n debug?: boolean;\n}\n\n// eslint-disable-next-line import/no-default-export\nexport default codegenNativeComponent<NativeProps>(\"SkiaPictureView\");\n"],"mappings":"AAAA,OAAOA,sBAAsB,MAAM,yDAAyD;AAQ5F;AACA,eAAeA,sBAAsB,CAAc,iBAAiB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["codegenNativeComponent"],"sources":["SkiaPictureViewNativeComponent.ts"],"sourcesContent":["import codegenNativeComponent from \"react-native/Libraries/Utilities/codegenNativeComponent\";\nimport type { ViewProps } from \"react-native\";\n\nexport interface NativeProps extends ViewProps {\n debug?: boolean;\n}\n\n// eslint-disable-next-line import/no-default-export\nexport default codegenNativeComponent<NativeProps>(\"SkiaPictureView\");\n"],"mappings":"AAAA,OAAOA,sBAAsB,MAAM,yDAAyD;AAO5F;AACA,eAAeA,sBAAsB,CAAc,iBAAiB,CAAC","ignoreList":[]}