@shopify/react-native-skia 1.11.1 → 1.11.2
Sign up to get free protection for your applications and to get access to all the features.
- package/android/CMakeLists.txt +0 -8
- package/android/cpp/jni/JniLoad.cpp +0 -2
- package/android/src/main/java/com/shopify/reactnative/skia/RNSkiaPackage.java +1 -1
- package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaPictureViewManagerDelegate.java +4 -2
- package/cpp/jsi/ViewProperty.h +5 -16
- package/cpp/rnskia/RNSkManager.cpp +1 -7
- package/lib/commonjs/dom/nodes/index.d.ts +0 -1
- package/lib/commonjs/dom/nodes/index.js +0 -11
- package/lib/commonjs/dom/nodes/index.js.map +1 -1
- package/lib/commonjs/external/reanimated/renderHelpers.d.ts +0 -6
- package/lib/commonjs/external/reanimated/renderHelpers.js +0 -73
- package/lib/commonjs/external/reanimated/renderHelpers.js.map +1 -1
- package/lib/commonjs/index.d.ts +0 -1
- package/lib/commonjs/index.js +0 -12
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/renderer/Canvas.d.ts +10 -1
- package/lib/commonjs/renderer/Canvas.js +3 -1
- package/lib/commonjs/renderer/Canvas.js.map +1 -1
- package/lib/commonjs/sksg/Container.d.ts +2 -0
- package/lib/commonjs/sksg/Container.js +10 -0
- package/lib/commonjs/sksg/Container.js.map +1 -1
- package/lib/commonjs/sksg/Elements.d.ts +65 -0
- package/lib/commonjs/sksg/Elements.js +6 -0
- package/lib/commonjs/sksg/Elements.js.map +1 -0
- package/lib/commonjs/sksg/Reconciler.d.ts +1 -0
- package/lib/commonjs/sksg/Reconciler.js +2 -0
- package/lib/commonjs/sksg/Reconciler.js.map +1 -1
- package/lib/commonjs/views/index.d.ts +0 -1
- package/lib/commonjs/views/index.js +0 -11
- package/lib/commonjs/views/index.js.map +1 -1
- package/lib/module/dom/nodes/index.d.ts +0 -1
- package/lib/module/dom/nodes/index.js +0 -1
- package/lib/module/dom/nodes/index.js.map +1 -1
- package/lib/module/external/reanimated/renderHelpers.d.ts +0 -6
- package/lib/module/external/reanimated/renderHelpers.js +0 -68
- package/lib/module/external/reanimated/renderHelpers.js.map +1 -1
- package/lib/module/index.d.ts +0 -1
- package/lib/module/index.js +0 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/renderer/Canvas.d.ts +10 -1
- package/lib/module/renderer/Canvas.js +1 -0
- package/lib/module/renderer/Canvas.js.map +1 -1
- package/lib/module/sksg/Container.d.ts +2 -0
- package/lib/module/sksg/Container.js +10 -0
- package/lib/module/sksg/Container.js.map +1 -1
- package/lib/module/sksg/Elements.d.ts +65 -0
- package/lib/module/sksg/Elements.js +2 -0
- package/lib/module/sksg/Elements.js.map +1 -0
- package/lib/module/sksg/Reconciler.d.ts +1 -0
- package/lib/module/sksg/Reconciler.js +2 -0
- package/lib/module/sksg/Reconciler.js.map +1 -1
- package/lib/module/views/index.d.ts +0 -1
- package/lib/module/views/index.js +0 -1
- package/lib/module/views/index.js.map +1 -1
- package/lib/typescript/lib/commonjs/external/reanimated/renderHelpers.d.ts +0 -3
- package/lib/typescript/lib/commonjs/renderer/Canvas.d.ts +1 -0
- package/lib/typescript/lib/commonjs/sksg/Container.d.ts +2 -0
- package/lib/typescript/lib/commonjs/sksg/Elements.d.ts +1 -0
- package/lib/typescript/lib/commonjs/sksg/Reconciler.d.ts +6 -0
- package/lib/typescript/lib/module/dom/nodes/index.d.ts +0 -1
- package/lib/typescript/lib/module/external/reanimated/renderHelpers.d.ts +0 -3
- package/lib/typescript/lib/module/index.d.ts +0 -1
- package/lib/typescript/lib/module/mock/index.d.ts +0 -1
- package/lib/typescript/lib/module/renderer/Canvas.d.ts +1 -0
- package/lib/typescript/lib/module/sksg/Container.d.ts +2 -0
- package/lib/typescript/lib/module/sksg/Elements.d.ts +1 -0
- package/lib/typescript/lib/module/sksg/Reconciler.d.ts +6 -0
- package/lib/typescript/lib/module/views/index.d.ts +0 -1
- package/lib/typescript/src/dom/nodes/index.d.ts +0 -1
- package/lib/typescript/src/external/reanimated/renderHelpers.d.ts +0 -6
- package/lib/typescript/src/index.d.ts +0 -1
- package/lib/typescript/src/renderer/Canvas.d.ts +10 -1
- package/lib/typescript/src/sksg/Container.d.ts +2 -0
- package/lib/typescript/src/sksg/Elements.d.ts +65 -0
- package/lib/typescript/src/sksg/Reconciler.d.ts +1 -0
- package/lib/typescript/src/views/index.d.ts +0 -1
- package/package.json +1 -1
- package/src/dom/nodes/index.ts +0 -1
- package/src/external/reanimated/renderHelpers.ts +1 -78
- package/src/index.ts +0 -1
- package/src/renderer/Canvas.tsx +11 -1
- package/src/sksg/Container.ts +11 -0
- package/src/sksg/Elements.tsx +136 -0
- package/src/sksg/Reconciler.ts +2 -0
- package/src/views/index.ts +0 -1
- package/android/cpp/jni/include/JniSkiaDomView.h +0 -82
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaDomView.java +0 -41
- package/android/src/main/java/com/shopify/reactnative/skia/SkiaDomViewManager.java +0 -32
- package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaDomViewManagerDelegate.java +0 -34
- package/android/src/paper/java/com/facebook/react/viewmanagers/SkiaDomViewManagerInterface.java +0 -18
- package/cpp/rnskia/RNSkDomView.cpp +0 -121
- package/cpp/rnskia/RNSkDomView.h +0 -97
- package/cpp/rnskia/dom/JsiDomApi.h +0 -165
- package/cpp/rnskia/dom/base/BaseNodeProp.h +0 -72
- package/cpp/rnskia/dom/base/ConcatablePaint.cpp +0 -117
- package/cpp/rnskia/dom/base/ConcatablePaint.h +0 -49
- package/cpp/rnskia/dom/base/Declaration.h +0 -86
- package/cpp/rnskia/dom/base/DeclarationContext.h +0 -79
- package/cpp/rnskia/dom/base/DerivedNodeProp.h +0 -203
- package/cpp/rnskia/dom/base/DrawingContext.cpp +0 -55
- package/cpp/rnskia/dom/base/DrawingContext.h +0 -104
- package/cpp/rnskia/dom/base/JsiDomDeclarationNode.h +0 -119
- package/cpp/rnskia/dom/base/JsiDomDrawingNode.h +0 -71
- package/cpp/rnskia/dom/base/JsiDomNode.h +0 -572
- package/cpp/rnskia/dom/base/JsiDomRenderNode.h +0 -262
- package/cpp/rnskia/dom/base/NodeProp.h +0 -139
- package/cpp/rnskia/dom/base/NodePropsContainer.h +0 -158
- package/cpp/rnskia/dom/nodes/JsiAtlasNode.h +0 -64
- package/cpp/rnskia/dom/nodes/JsiBackdropFilterNode.h +0 -49
- package/cpp/rnskia/dom/nodes/JsiBlendNode.h +0 -94
- package/cpp/rnskia/dom/nodes/JsiBlurMaskNode.h +0 -75
- package/cpp/rnskia/dom/nodes/JsiBoxNode.h +0 -94
- package/cpp/rnskia/dom/nodes/JsiBoxShadowNode.h +0 -33
- package/cpp/rnskia/dom/nodes/JsiCircleNode.h +0 -35
- package/cpp/rnskia/dom/nodes/JsiColorFilterNodes.h +0 -164
- package/cpp/rnskia/dom/nodes/JsiDiffRectNode.h +0 -37
- package/cpp/rnskia/dom/nodes/JsiFillNode.h +0 -22
- package/cpp/rnskia/dom/nodes/JsiGlyphsNode.h +0 -53
- package/cpp/rnskia/dom/nodes/JsiGroupNode.h +0 -25
- package/cpp/rnskia/dom/nodes/JsiImageFilterNodes.h +0 -361
- package/cpp/rnskia/dom/nodes/JsiImageNode.h +0 -43
- package/cpp/rnskia/dom/nodes/JsiImageSvgNode.h +0 -63
- package/cpp/rnskia/dom/nodes/JsiLayerNode.h +0 -74
- package/cpp/rnskia/dom/nodes/JsiLineNode.h +0 -38
- package/cpp/rnskia/dom/nodes/JsiOvalNode.h +0 -32
- package/cpp/rnskia/dom/nodes/JsiPaintNode.h +0 -119
- package/cpp/rnskia/dom/nodes/JsiParagraphNode.h +0 -62
- package/cpp/rnskia/dom/nodes/JsiPatchNode.h +0 -50
- package/cpp/rnskia/dom/nodes/JsiPathEffectNodes.h +0 -268
- package/cpp/rnskia/dom/nodes/JsiPathNode.h +0 -181
- package/cpp/rnskia/dom/nodes/JsiPictureNode.h +0 -31
- package/cpp/rnskia/dom/nodes/JsiPointsNode.h +0 -48
- package/cpp/rnskia/dom/nodes/JsiRRectNode.h +0 -33
- package/cpp/rnskia/dom/nodes/JsiRectNode.h +0 -33
- package/cpp/rnskia/dom/nodes/JsiShaderNodes.h +0 -434
- package/cpp/rnskia/dom/nodes/JsiTextBlobNode.h +0 -44
- package/cpp/rnskia/dom/nodes/JsiTextNode.h +0 -51
- package/cpp/rnskia/dom/nodes/JsiTextPathNode.h +0 -33
- package/cpp/rnskia/dom/nodes/JsiVerticesNode.h +0 -41
- package/cpp/rnskia/dom/props/BezierProps.h +0 -65
- package/cpp/rnskia/dom/props/BlendModeProp.h +0 -103
- package/cpp/rnskia/dom/props/BoxShadowProps.h +0 -62
- package/cpp/rnskia/dom/props/CircleProp.h +0 -49
- package/cpp/rnskia/dom/props/ClipProp.h +0 -57
- package/cpp/rnskia/dom/props/ColorProp.h +0 -96
- package/cpp/rnskia/dom/props/FontProp.h +0 -42
- package/cpp/rnskia/dom/props/GlyphsProp.h +0 -55
- package/cpp/rnskia/dom/props/LayerProp.h +0 -52
- package/cpp/rnskia/dom/props/MatrixProp.h +0 -54
- package/cpp/rnskia/dom/props/NumbersProp.h +0 -67
- package/cpp/rnskia/dom/props/PaintProps.h +0 -133
- package/cpp/rnskia/dom/props/ParagraphProp.h +0 -45
- package/cpp/rnskia/dom/props/PathProp.h +0 -59
- package/cpp/rnskia/dom/props/PictureProp.h +0 -40
- package/cpp/rnskia/dom/props/PointProp.h +0 -65
- package/cpp/rnskia/dom/props/PointsProp.h +0 -81
- package/cpp/rnskia/dom/props/RRectProp.h +0 -222
- package/cpp/rnskia/dom/props/RSXformProp.h +0 -52
- package/cpp/rnskia/dom/props/RadiusProp.h +0 -43
- package/cpp/rnskia/dom/props/RectProp.h +0 -164
- package/cpp/rnskia/dom/props/SamplingProp.h +0 -54
- package/cpp/rnskia/dom/props/SkImageProps.h +0 -196
- package/cpp/rnskia/dom/props/StrokeProps.h +0 -79
- package/cpp/rnskia/dom/props/SvgProp.h +0 -45
- package/cpp/rnskia/dom/props/TextBlobProp.h +0 -133
- package/cpp/rnskia/dom/props/TileModeProp.h +0 -52
- package/cpp/rnskia/dom/props/TransformProp.h +0 -147
- package/cpp/rnskia/dom/props/TransformsProps.h +0 -66
- package/cpp/rnskia/dom/props/UniformsProp.h +0 -159
- package/cpp/rnskia/dom/props/VertexModeProp.h +0 -49
- package/cpp/rnskia/dom/props/VerticesProps.h +0 -63
- package/ios/RNSkia-iOS/SkiaDomView.h +0 -7
- package/ios/RNSkia-iOS/SkiaDomView.mm +0 -63
- package/ios/RNSkia-iOS/SkiaDomViewManager.h +0 -8
- package/ios/RNSkia-iOS/SkiaDomViewManager.mm +0 -51
- package/lib/commonjs/dom/nodes/JsiSkDOM.d.ts +0 -64
- package/lib/commonjs/dom/nodes/JsiSkDOM.js +0 -196
- package/lib/commonjs/dom/nodes/JsiSkDOM.js.map +0 -1
- package/lib/commonjs/renderer/CanvasOld.d.ts +0 -11
- package/lib/commonjs/renderer/CanvasOld.js +0 -96
- package/lib/commonjs/renderer/CanvasOld.js.map +0 -1
- package/lib/commonjs/renderer/Container.d.ts +0 -10
- package/lib/commonjs/renderer/Container.js +0 -26
- package/lib/commonjs/renderer/Container.js.map +0 -1
- package/lib/commonjs/renderer/HostComponents.d.ts +0 -129
- package/lib/commonjs/renderer/HostComponents.js +0 -141
- package/lib/commonjs/renderer/HostComponents.js.map +0 -1
- package/lib/commonjs/renderer/HostConfig.d.ts +0 -18
- package/lib/commonjs/renderer/HostConfig.js +0 -157
- package/lib/commonjs/renderer/HostConfig.js.map +0 -1
- package/lib/commonjs/renderer/Reconciler.d.ts +0 -9
- package/lib/commonjs/renderer/Reconciler.js +0 -44
- package/lib/commonjs/renderer/Reconciler.js.map +0 -1
- package/lib/commonjs/specs/SkiaDomViewNativeComponent.d.ts +0 -6
- package/lib/commonjs/specs/SkiaDomViewNativeComponent.js +0 -11
- package/lib/commonjs/specs/SkiaDomViewNativeComponent.js.map +0 -1
- package/lib/commonjs/views/SkiaDomView.d.ts +0 -33
- package/lib/commonjs/views/SkiaDomView.js +0 -119
- package/lib/commonjs/views/SkiaDomView.js.map +0 -1
- package/lib/commonjs/views/SkiaDomView.web.d.ts +0 -0
- package/lib/commonjs/views/SkiaDomView.web.js +0 -2
- package/lib/commonjs/views/SkiaDomView.web.js.map +0 -1
- package/lib/module/dom/nodes/JsiSkDOM.d.ts +0 -64
- package/lib/module/dom/nodes/JsiSkDOM.js +0 -189
- package/lib/module/dom/nodes/JsiSkDOM.js.map +0 -1
- package/lib/module/renderer/CanvasOld.d.ts +0 -11
- package/lib/module/renderer/CanvasOld.js +0 -87
- package/lib/module/renderer/CanvasOld.js.map +0 -1
- package/lib/module/renderer/Container.d.ts +0 -10
- package/lib/module/renderer/Container.js +0 -19
- package/lib/module/renderer/Container.js.map +0 -1
- package/lib/module/renderer/HostComponents.d.ts +0 -129
- package/lib/module/renderer/HostComponents.js +0 -134
- package/lib/module/renderer/HostComponents.js.map +0 -1
- package/lib/module/renderer/HostConfig.d.ts +0 -18
- package/lib/module/renderer/HostConfig.js +0 -150
- package/lib/module/renderer/HostConfig.js.map +0 -1
- package/lib/module/renderer/Reconciler.d.ts +0 -9
- package/lib/module/renderer/Reconciler.js +0 -36
- package/lib/module/renderer/Reconciler.js.map +0 -1
- package/lib/module/specs/SkiaDomViewNativeComponent.d.ts +0 -6
- package/lib/module/specs/SkiaDomViewNativeComponent.js +0 -4
- package/lib/module/specs/SkiaDomViewNativeComponent.js.map +0 -1
- package/lib/module/views/SkiaDomView.d.ts +0 -33
- package/lib/module/views/SkiaDomView.js +0 -111
- package/lib/module/views/SkiaDomView.js.map +0 -1
- package/lib/module/views/SkiaDomView.web.d.ts +0 -0
- package/lib/module/views/SkiaDomView.web.js +0 -2
- package/lib/module/views/SkiaDomView.web.js.map +0 -1
- package/lib/typescript/lib/commonjs/dom/nodes/JsiSkDOM.d.ts +0 -60
- package/lib/typescript/lib/commonjs/renderer/CanvasOld.d.ts +0 -3
- package/lib/typescript/lib/commonjs/renderer/Container.d.ts +0 -9
- package/lib/typescript/lib/commonjs/renderer/HostComponents.d.ts +0 -2
- package/lib/typescript/lib/commonjs/renderer/HostConfig.d.ts +0 -40
- package/lib/typescript/lib/commonjs/renderer/Reconciler.d.ts +0 -10
- package/lib/typescript/lib/commonjs/specs/SkiaDomViewNativeComponent.d.ts +0 -3
- package/lib/typescript/lib/commonjs/views/SkiaDomView.d.ts +0 -30
- package/lib/typescript/lib/commonjs/views/SkiaDomView.web.d.ts +0 -0
- package/lib/typescript/lib/module/dom/nodes/JsiSkDOM.d.ts +0 -59
- package/lib/typescript/lib/module/renderer/CanvasOld.d.ts +0 -3
- package/lib/typescript/lib/module/renderer/Container.d.ts +0 -9
- package/lib/typescript/lib/module/renderer/HostComponents.d.ts +0 -1
- package/lib/typescript/lib/module/renderer/HostConfig.d.ts +0 -39
- package/lib/typescript/lib/module/renderer/Reconciler.d.ts +0 -9
- package/lib/typescript/lib/module/specs/SkiaDomViewNativeComponent.d.ts +0 -2
- package/lib/typescript/lib/module/views/SkiaDomView.d.ts +0 -27
- package/lib/typescript/lib/module/views/SkiaDomView.web.d.ts +0 -0
- package/lib/typescript/src/dom/nodes/JsiSkDOM.d.ts +0 -64
- package/lib/typescript/src/renderer/CanvasOld.d.ts +0 -11
- package/lib/typescript/src/renderer/Container.d.ts +0 -10
- package/lib/typescript/src/renderer/HostComponents.d.ts +0 -129
- package/lib/typescript/src/renderer/HostConfig.d.ts +0 -18
- package/lib/typescript/src/renderer/Reconciler.d.ts +0 -9
- package/lib/typescript/src/specs/SkiaDomViewNativeComponent.d.ts +0 -6
- package/lib/typescript/src/views/SkiaDomView.d.ts +0 -33
- package/lib/typescript/src/views/SkiaDomView.web.d.ts +0 -0
- package/src/dom/nodes/JsiSkDOM.ts +0 -298
- package/src/renderer/CanvasOld.tsx +0 -126
- package/src/renderer/Container.tsx +0 -19
- package/src/renderer/HostComponents.ts +0 -399
- package/src/renderer/HostConfig.ts +0 -258
- package/src/renderer/Reconciler.tsx +0 -54
- package/src/specs/SkiaDomViewNativeComponent.ts +0 -9
- package/src/views/SkiaDomView.tsx +0 -124
- package/src/views/SkiaDomView.web.tsx +0 -0
@@ -8,6 +8,7 @@ var _reactReconciler = _interopRequireDefault(require("react-reconciler"));
|
|
8
8
|
var _types = require("../dom/types");
|
9
9
|
var _HostConfig = require("./HostConfig");
|
10
10
|
var _Container = require("./Container");
|
11
|
+
require("./Elements");
|
11
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
12
13
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
13
14
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
@@ -51,6 +52,7 @@ class SkiaSGRoot {
|
|
51
52
|
return recorder.finishRecordingAsPicture();
|
52
53
|
}
|
53
54
|
unmount() {
|
55
|
+
this.container.unmount();
|
54
56
|
skiaReconciler.updateContainer(null, this.root, null, () => {
|
55
57
|
(0, _HostConfig.debug)("unmountContainer");
|
56
58
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_reactReconciler","_interopRequireDefault","require","_types","_HostConfig","_Container","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","skiaReconciler","ReactReconciler","sksgHostConfig","injectIntoDevTools","bundleType","version","rendererPackageName","SkiaSGRoot","constructor","Skia","nativeId","container","createContainer","root","console","error","sg","children","type","NodeType","Group","props","isDeclaration","render","element","updateContainer","debug","drawOnCanvas","canvas","getPicture","recorder","PictureRecorder","beginRecording","finishRecordingAsPicture","unmount","exports"],"sources":["Reconciler.ts"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { OpaqueRoot } from \"react-reconciler\";\nimport ReactReconciler from \"react-reconciler\";\n\nimport type { SkCanvas, Skia } from \"../skia/types\";\nimport { NodeType } from \"../dom/types\";\n\nimport { debug, sksgHostConfig } from \"./HostConfig\";\nimport type { Container } from \"./Container\";\nimport { createContainer } from \"./Container\";\n\nconst skiaReconciler = ReactReconciler(sksgHostConfig);\n\nskiaReconciler.injectIntoDevTools({\n bundleType: 1,\n version: \"0.0.1\",\n rendererPackageName: \"react-native-skia\",\n});\n\nexport class SkiaSGRoot {\n private root: OpaqueRoot;\n private container: Container;\n\n constructor(public Skia: Skia, nativeId = -1) {\n this.container = createContainer(Skia, nativeId);\n this.root = skiaReconciler.createContainer(\n this.container,\n 0,\n null,\n true,\n null,\n \"\",\n console.error,\n null\n );\n }\n\n get sg() {\n const children = this.container.root;\n return { type: NodeType.Group, props: {}, children, isDeclaration: false };\n }\n\n render(element: ReactNode) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n skiaReconciler.updateContainer(element as any, this.root, null, () => {\n debug(\"updateContainer\");\n });\n }\n\n drawOnCanvas(canvas: SkCanvas) {\n this.container.drawOnCanvas(canvas);\n }\n\n getPicture() {\n const recorder = this.Skia.PictureRecorder();\n const canvas = recorder.beginRecording();\n this.drawOnCanvas(canvas);\n return recorder.finishRecordingAsPicture();\n }\n\n unmount() {\n skiaReconciler.updateContainer(null, this.root, null, () => {\n debug(\"unmountContainer\");\n });\n }\n}\n"],"mappings":";;;;;;AAEA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AAEA,IAAAG,UAAA,GAAAH,OAAA;
|
1
|
+
{"version":3,"names":["_reactReconciler","_interopRequireDefault","require","_types","_HostConfig","_Container","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","skiaReconciler","ReactReconciler","sksgHostConfig","injectIntoDevTools","bundleType","version","rendererPackageName","SkiaSGRoot","constructor","Skia","nativeId","container","createContainer","root","console","error","sg","children","type","NodeType","Group","props","isDeclaration","render","element","updateContainer","debug","drawOnCanvas","canvas","getPicture","recorder","PictureRecorder","beginRecording","finishRecordingAsPicture","unmount","exports"],"sources":["Reconciler.ts"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { OpaqueRoot } from \"react-reconciler\";\nimport ReactReconciler from \"react-reconciler\";\n\nimport type { SkCanvas, Skia } from \"../skia/types\";\nimport { NodeType } from \"../dom/types\";\n\nimport { debug, sksgHostConfig } from \"./HostConfig\";\nimport type { Container } from \"./Container\";\nimport { createContainer } from \"./Container\";\nimport \"./Elements\";\n\nconst skiaReconciler = ReactReconciler(sksgHostConfig);\n\nskiaReconciler.injectIntoDevTools({\n bundleType: 1,\n version: \"0.0.1\",\n rendererPackageName: \"react-native-skia\",\n});\n\nexport class SkiaSGRoot {\n private root: OpaqueRoot;\n private container: Container;\n\n constructor(public Skia: Skia, nativeId = -1) {\n this.container = createContainer(Skia, nativeId);\n this.root = skiaReconciler.createContainer(\n this.container,\n 0,\n null,\n true,\n null,\n \"\",\n console.error,\n null\n );\n }\n\n get sg() {\n const children = this.container.root;\n return { type: NodeType.Group, props: {}, children, isDeclaration: false };\n }\n\n render(element: ReactNode) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n skiaReconciler.updateContainer(element as any, this.root, null, () => {\n debug(\"updateContainer\");\n });\n }\n\n drawOnCanvas(canvas: SkCanvas) {\n this.container.drawOnCanvas(canvas);\n }\n\n getPicture() {\n const recorder = this.Skia.PictureRecorder();\n const canvas = recorder.beginRecording();\n this.drawOnCanvas(canvas);\n return recorder.finishRecordingAsPicture();\n }\n\n unmount() {\n this.container.unmount();\n skiaReconciler.updateContainer(null, this.root, null, () => {\n debug(\"unmountContainer\");\n });\n }\n}\n"],"mappings":";;;;;;AAEA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AAEA,IAAAG,UAAA,GAAAH,OAAA;AACAA,OAAA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|
@@ -14,17 +14,6 @@ Object.keys(_SkiaPictureView).forEach(function (key) {
|
|
14
14
|
}
|
15
15
|
});
|
16
16
|
});
|
17
|
-
var _SkiaDomView = require("./SkiaDomView");
|
18
|
-
Object.keys(_SkiaDomView).forEach(function (key) {
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
20
|
-
if (key in exports && exports[key] === _SkiaDomView[key]) return;
|
21
|
-
Object.defineProperty(exports, key, {
|
22
|
-
enumerable: true,
|
23
|
-
get: function () {
|
24
|
-
return _SkiaDomView[key];
|
25
|
-
}
|
26
|
-
});
|
27
|
-
});
|
28
17
|
var _types = require("./types");
|
29
18
|
Object.keys(_types).forEach(function (key) {
|
30
19
|
if (key === "default" || key === "__esModule") return;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_SkiaPictureView","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","
|
1
|
+
{"version":3,"names":["_SkiaPictureView","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_types"],"sources":["index.ts"],"sourcesContent":["export * from \"./SkiaPictureView\";\nexport * from \"./types\";\n"],"mappings":";;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,gBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,gBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,gBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,MAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,MAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,MAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,MAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"../types\";\nexport * from \"./
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"../types\";\nexport * from \"./datatypes\";\n"],"mappings":"AAAA,cAAc,UAAU;AACxB,cAAc,aAAa","ignoreList":[]}
|
@@ -1,7 +1 @@
|
|
1
|
-
import type { Container } from "../../renderer/Container";
|
2
|
-
import type { AnimatedProps } from "../../renderer/processors";
|
3
|
-
import type { Node } from "../../dom/types";
|
4
1
|
export declare let HAS_REANIMATED_3: boolean;
|
5
|
-
export declare const unbindReanimatedNode: (node: Node<unknown>) => void;
|
6
|
-
export declare function extractReanimatedProps(props: AnimatedProps<any>): AnimatedProps<any, never>[];
|
7
|
-
export declare function bindReanimatedProps(container: Container, node: Node<any>, reanimatedProps: AnimatedProps<any>): void;
|
@@ -1,6 +1,3 @@
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
2
|
-
|
3
|
-
import Rea from "./ReanimatedProxy";
|
4
1
|
export let HAS_REANIMATED_3 = false;
|
5
2
|
try {
|
6
3
|
// This logic is convoluted but necessary
|
@@ -15,69 +12,4 @@ try {
|
|
15
12
|
} catch (e) {
|
16
13
|
// do nothing
|
17
14
|
}
|
18
|
-
const _bindings = new WeakMap();
|
19
|
-
export const unbindReanimatedNode = node => {
|
20
|
-
if (!HAS_REANIMATED_3) {
|
21
|
-
return;
|
22
|
-
}
|
23
|
-
const previousMapperId = _bindings.get(node);
|
24
|
-
if (previousMapperId !== undefined) {
|
25
|
-
Rea.stopMapper(previousMapperId);
|
26
|
-
}
|
27
|
-
};
|
28
|
-
export function extractReanimatedProps(props) {
|
29
|
-
if (!HAS_REANIMATED_3) {
|
30
|
-
return [props, {}];
|
31
|
-
}
|
32
|
-
const reanimatedProps = {};
|
33
|
-
const otherProps = {};
|
34
|
-
for (const propName in props) {
|
35
|
-
if (propName === "children") {
|
36
|
-
continue;
|
37
|
-
}
|
38
|
-
const propValue = props[propName];
|
39
|
-
if (Rea.isSharedValue(propValue)) {
|
40
|
-
reanimatedProps[propName] = propValue;
|
41
|
-
otherProps[propName] = propValue.value;
|
42
|
-
} else {
|
43
|
-
otherProps[propName] = propValue;
|
44
|
-
}
|
45
|
-
}
|
46
|
-
return [otherProps, reanimatedProps];
|
47
|
-
}
|
48
|
-
export function bindReanimatedProps(container, node, reanimatedProps) {
|
49
|
-
if (!HAS_REANIMATED_3) {
|
50
|
-
return;
|
51
|
-
}
|
52
|
-
const sharedValues = Object.values(reanimatedProps);
|
53
|
-
const previousMapperId = _bindings.get(node);
|
54
|
-
if (previousMapperId !== undefined) {
|
55
|
-
Rea.stopMapper(previousMapperId);
|
56
|
-
}
|
57
|
-
if (sharedValues.length > 0) {
|
58
|
-
const viewId = container.getNativeId();
|
59
|
-
const {
|
60
|
-
SkiaViewApi
|
61
|
-
} = global;
|
62
|
-
const mapperId = Rea.startMapper(() => {
|
63
|
-
"worklet";
|
64
|
-
|
65
|
-
if (node) {
|
66
|
-
for (const propName in reanimatedProps) {
|
67
|
-
node.setProp(propName, reanimatedProps[propName].value);
|
68
|
-
}
|
69
|
-
}
|
70
|
-
// On React Native we use the SkiaViewApi to redraw because it can
|
71
|
-
// run on the worklet thread (container.redraw can't)
|
72
|
-
// if SkiaViewApi is undefined, we are on web and container.redraw()
|
73
|
-
// can safely be invoked
|
74
|
-
if (SkiaViewApi) {
|
75
|
-
SkiaViewApi.requestRedraw(viewId);
|
76
|
-
} else {
|
77
|
-
container.redraw();
|
78
|
-
}
|
79
|
-
}, sharedValues);
|
80
|
-
_bindings.set(node, mapperId);
|
81
|
-
}
|
82
|
-
}
|
83
15
|
//# sourceMappingURL=renderHelpers.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["
|
1
|
+
{"version":3,"names":["HAS_REANIMATED_3","reanimatedVersion","require","version","includes","e"],"sources":["renderHelpers.ts"],"sourcesContent":["export let HAS_REANIMATED_3 = false;\n\ntry {\n // This logic is convoluted but necessary\n // In most systems, `require(\"react-native-reanimated\")` throws an error, all is well.\n // In webpack, in some configuration it will return an empty object.\n // So it will not throw an error and we need to check the version to know if it's there.\n const reanimatedVersion =\n require(\"react-native-reanimated/package.json\").version;\n require(\"react-native-reanimated\");\n if (\n reanimatedVersion &&\n (reanimatedVersion >= \"3.0.0\" || reanimatedVersion.includes(\"3.0.0-\"))\n ) {\n HAS_REANIMATED_3 = true;\n }\n} catch (e) {\n // do nothing\n}\n"],"mappings":"AAAA,OAAO,IAAIA,gBAAgB,GAAG,KAAK;AAEnC,IAAI;EACF;EACA;EACA;EACA;EACA,MAAMC,iBAAiB,GACrBC,OAAO,CAAC,sCAAsC,CAAC,CAACC,OAAO;EACzDD,OAAO,CAAC,yBAAyB,CAAC;EAClC,IACED,iBAAiB,KAChBA,iBAAiB,IAAI,OAAO,IAAIA,iBAAiB,CAACG,QAAQ,CAAC,QAAQ,CAAC,CAAC,EACtE;IACAJ,gBAAgB,GAAG,IAAI;EACzB;AACF,CAAC,CAAC,OAAOK,CAAC,EAAE;EACV;AAAA","ignoreList":[]}
|
package/lib/module/index.d.ts
CHANGED
package/lib/module/index.js
CHANGED
package/lib/module/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["JsiSkImage"],"sources":["index.ts"],"sourcesContent":["import \"./skia/NativeSetup\";\nexport { JsiSkImage } from \"./skia/web/JsiSkImage\";\nexport * from \"./renderer\";\nexport * from \"./renderer/
|
1
|
+
{"version":3,"names":["JsiSkImage"],"sources":["index.ts"],"sourcesContent":["import \"./skia/NativeSetup\";\nexport { JsiSkImage } from \"./skia/web/JsiSkImage\";\nexport * from \"./renderer\";\nexport * from \"./renderer/Canvas\";\nexport * from \"./renderer/Offscreen\";\nexport * from \"./views\";\nexport * from \"./skia\";\nexport * from \"./external\";\nexport * from \"./animation\";\nexport * from \"./dom/types\";\nexport * from \"./dom/nodes\";\n"],"mappings":"AAAA,OAAO,oBAAoB;AAC3B,SAASA,UAAU,QAAQ,uBAAuB;AAClD,cAAc,YAAY;AAC1B,cAAc,mBAAmB;AACjC,cAAc,sBAAsB;AACpC,cAAc,SAAS;AACvB,cAAc,QAAQ;AACtB,cAAc,YAAY;AAC1B,cAAc,aAAa;AAC3B,cAAc,aAAa;AAC3B,cAAc,aAAa","ignoreList":[]}
|
@@ -1,6 +1,14 @@
|
|
1
|
+
import type { FC } from "react";
|
1
2
|
import type { ViewProps } from "react-native";
|
2
3
|
import type { SharedValue } from "react-native-reanimated";
|
3
|
-
import type { SkSize } from "../skia/types";
|
4
|
+
import type { SkImage, SkRect, SkSize } from "../skia/types";
|
5
|
+
interface CanvasRef extends FC<CanvasProps> {
|
6
|
+
makeImageSnapshot(rect?: SkRect): SkImage;
|
7
|
+
makeImageSnapshotAsync(rect?: SkRect): Promise<SkImage>;
|
8
|
+
redraw(): void;
|
9
|
+
getNativeId(): number;
|
10
|
+
}
|
11
|
+
export declare const useCanvasRef: () => import("react").RefObject<CanvasRef>;
|
4
12
|
export interface CanvasProps extends ViewProps {
|
5
13
|
debug?: boolean;
|
6
14
|
opaque?: boolean;
|
@@ -8,3 +16,4 @@ export interface CanvasProps extends ViewProps {
|
|
8
16
|
mode?: "continuous" | "default";
|
9
17
|
}
|
10
18
|
export declare const Canvas: import("react").ForwardRefExoticComponent<CanvasProps & import("react").RefAttributes<unknown>>;
|
19
|
+
export {};
|
@@ -4,6 +4,7 @@ import { SkiaViewNativeId } from "../views/SkiaViewNativeId";
|
|
4
4
|
import SkiaPictureViewNativeComponent from "../specs/SkiaPictureViewNativeComponent";
|
5
5
|
import { SkiaSGRoot } from "../sksg/Reconciler";
|
6
6
|
import { Skia } from "../skia";
|
7
|
+
export const useCanvasRef = () => useRef(null);
|
7
8
|
const NativeSkiaPictureView = SkiaPictureViewNativeComponent;
|
8
9
|
|
9
10
|
// TODO: no need to go through the JS thread for this
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["forwardRef","useCallback","useEffect","useImperativeHandle","useMemo","useRef","SkiaViewNativeId","SkiaPictureViewNativeComponent","SkiaSGRoot","Skia","NativeSkiaPictureView","useOnSizeEvent","resultValue","onLayout","event","width","height","nativeEvent","layout","value","Canvas","mode","debug","opaque","children","onSize","_onLayout","viewProps","ref","rafId","nativeId","current","root","render","unmount","requestRedraw","requestAnimationFrame","console","warn","cancelAnimationFrame","makeImageSnapshot","rect","SkiaViewApi","makeImageSnapshotAsync","redraw","getNativeId","React","createElement","_extends","collapsable","nativeID"],"sources":["Canvas.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n} from \"react\";\nimport type { LayoutChangeEvent, ViewProps } from \"react-native\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nimport { SkiaViewNativeId } from \"../views/SkiaViewNativeId\";\nimport SkiaPictureViewNativeComponent from \"../specs/SkiaPictureViewNativeComponent\";\nimport type { SkRect, SkSize } from \"../skia/types\";\nimport { SkiaSGRoot } from \"../sksg/Reconciler\";\nimport { Skia } from \"../skia\";\nimport type { SkiaBaseViewProps } from \"../views\";\n\nconst NativeSkiaPictureView = SkiaPictureViewNativeComponent;\n\n// TODO: no need to go through the JS thread for this\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 interface CanvasProps extends ViewProps {\n debug?: boolean;\n opaque?: boolean;\n onSize?: SharedValue<SkSize>;\n mode?: \"continuous\" | \"default\";\n}\n\nexport const Canvas = forwardRef(\n (\n {\n mode,\n debug,\n opaque,\n children,\n onSize,\n onLayout: _onLayout,\n ...viewProps\n }: CanvasProps,\n ref\n ) => {\n const rafId = useRef<number | null>(null);\n const onLayout = useOnSizeEvent(onSize, _onLayout);\n // Native ID\n const nativeId = useMemo(() => {\n return SkiaViewNativeId.current++;\n }, []);\n\n // Root\n const root = useMemo(() => new SkiaSGRoot(Skia, nativeId), [nativeId]);\n\n // Render effects\n useEffect(() => {\n root.render(children);\n }, [children, root]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n const requestRedraw = useCallback(() => {\n rafId.current = requestAnimationFrame(() => {\n root.render(children);\n if (mode === \"continuous\") {\n requestRedraw();\n }\n });\n }, [children, mode, root]);\n\n useEffect(() => {\n if (mode === \"continuous\") {\n console.warn(\"The `mode` property in `Canvas` is deprecated.\");\n requestRedraw();\n }\n return () => {\n if (rafId.current !== null) {\n cancelAnimationFrame(rafId.current);\n }\n };\n }, [mode, requestRedraw]);\n // Component methods\n useImperativeHandle(ref, () => ({\n makeImageSnapshot: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshot(nativeId, rect);\n },\n makeImageSnapshotAsync: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshotAsync(nativeId, rect);\n },\n redraw: () => {\n SkiaViewApi.requestRedraw(nativeId);\n },\n getNativeId: () => {\n return nativeId;\n },\n }));\n return (\n <NativeSkiaPictureView\n collapsable={false}\n nativeID={`${nativeId}`}\n debug={debug}\n opaque={opaque}\n onLayout={onLayout}\n {...viewProps}\n />\n );\n }\n);\n"],"mappings":";
|
1
|
+
{"version":3,"names":["forwardRef","useCallback","useEffect","useImperativeHandle","useMemo","useRef","SkiaViewNativeId","SkiaPictureViewNativeComponent","SkiaSGRoot","Skia","useCanvasRef","NativeSkiaPictureView","useOnSizeEvent","resultValue","onLayout","event","width","height","nativeEvent","layout","value","Canvas","mode","debug","opaque","children","onSize","_onLayout","viewProps","ref","rafId","nativeId","current","root","render","unmount","requestRedraw","requestAnimationFrame","console","warn","cancelAnimationFrame","makeImageSnapshot","rect","SkiaViewApi","makeImageSnapshotAsync","redraw","getNativeId","React","createElement","_extends","collapsable","nativeID"],"sources":["Canvas.tsx"],"sourcesContent":["import type { FC } from \"react\";\nimport {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n} from \"react\";\nimport type { LayoutChangeEvent, ViewProps } from \"react-native\";\nimport type { SharedValue } from \"react-native-reanimated\";\n\nimport { SkiaViewNativeId } from \"../views/SkiaViewNativeId\";\nimport SkiaPictureViewNativeComponent from \"../specs/SkiaPictureViewNativeComponent\";\nimport type { SkImage, SkRect, SkSize } from \"../skia/types\";\nimport { SkiaSGRoot } from \"../sksg/Reconciler\";\nimport { Skia } from \"../skia\";\nimport type { SkiaBaseViewProps } from \"../views\";\n\ninterface CanvasRef extends FC<CanvasProps> {\n makeImageSnapshot(rect?: SkRect): SkImage;\n makeImageSnapshotAsync(rect?: SkRect): Promise<SkImage>;\n redraw(): void;\n getNativeId(): number;\n}\n\nexport const useCanvasRef = () => useRef<CanvasRef>(null);\n\nconst NativeSkiaPictureView = SkiaPictureViewNativeComponent;\n\n// TODO: no need to go through the JS thread for this\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 interface CanvasProps extends ViewProps {\n debug?: boolean;\n opaque?: boolean;\n onSize?: SharedValue<SkSize>;\n mode?: \"continuous\" | \"default\";\n}\n\nexport const Canvas = forwardRef(\n (\n {\n mode,\n debug,\n opaque,\n children,\n onSize,\n onLayout: _onLayout,\n ...viewProps\n }: CanvasProps,\n ref\n ) => {\n const rafId = useRef<number | null>(null);\n const onLayout = useOnSizeEvent(onSize, _onLayout);\n // Native ID\n const nativeId = useMemo(() => {\n return SkiaViewNativeId.current++;\n }, []);\n\n // Root\n const root = useMemo(() => new SkiaSGRoot(Skia, nativeId), [nativeId]);\n\n // Render effects\n useEffect(() => {\n root.render(children);\n }, [children, root]);\n\n useEffect(() => {\n return () => {\n root.unmount();\n };\n }, [root]);\n\n const requestRedraw = useCallback(() => {\n rafId.current = requestAnimationFrame(() => {\n root.render(children);\n if (mode === \"continuous\") {\n requestRedraw();\n }\n });\n }, [children, mode, root]);\n\n useEffect(() => {\n if (mode === \"continuous\") {\n console.warn(\"The `mode` property in `Canvas` is deprecated.\");\n requestRedraw();\n }\n return () => {\n if (rafId.current !== null) {\n cancelAnimationFrame(rafId.current);\n }\n };\n }, [mode, requestRedraw]);\n // Component methods\n useImperativeHandle(ref, () => ({\n makeImageSnapshot: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshot(nativeId, rect);\n },\n makeImageSnapshotAsync: (rect?: SkRect) => {\n return SkiaViewApi.makeImageSnapshotAsync(nativeId, rect);\n },\n redraw: () => {\n SkiaViewApi.requestRedraw(nativeId);\n },\n getNativeId: () => {\n return nativeId;\n },\n }));\n return (\n <NativeSkiaPictureView\n collapsable={false}\n nativeID={`${nativeId}`}\n debug={debug}\n opaque={opaque}\n onLayout={onLayout}\n {...viewProps}\n />\n );\n }\n);\n"],"mappings":";AACA,SACEA,UAAU,EACVC,WAAW,EACXC,SAAS,EACTC,mBAAmB,EACnBC,OAAO,EACPC,MAAM,QACD,OAAO;AAId,SAASC,gBAAgB,QAAQ,2BAA2B;AAC5D,OAAOC,8BAA8B,MAAM,yCAAyC;AAEpF,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,IAAI,QAAQ,SAAS;AAU9B,OAAO,MAAMC,YAAY,GAAGA,CAAA,KAAML,MAAM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QAAQ,EAAE,GAAGpB,QAAQ,EAAG;IACxBR,KAAK,EAAEA,KAAM;IACbC,MAAM,EAAEA,MAAO;IACfV,QAAQ,EAAEA;EAAS,GACfc,SAAS,CACd,CAAC;AAEN,CACF,CAAC","ignoreList":[]}
|
@@ -6,7 +6,9 @@ export declare abstract class Container {
|
|
6
6
|
protected nativeId: number;
|
7
7
|
root: Node[];
|
8
8
|
protected recording: Recording | null;
|
9
|
+
protected unmounted: boolean;
|
9
10
|
constructor(Skia: Skia, nativeId: number);
|
11
|
+
unmount(): void;
|
10
12
|
drawOnCanvas(canvas: SkCanvas): void;
|
11
13
|
abstract redraw(): void;
|
12
14
|
}
|
@@ -46,6 +46,10 @@ export class Container {
|
|
46
46
|
this.nativeId = nativeId;
|
47
47
|
_defineProperty(this, "root", []);
|
48
48
|
_defineProperty(this, "recording", null);
|
49
|
+
_defineProperty(this, "unmounted", false);
|
50
|
+
}
|
51
|
+
unmount() {
|
52
|
+
this.unmounted = true;
|
49
53
|
}
|
50
54
|
drawOnCanvas(canvas) {
|
51
55
|
if (!this.recording) {
|
@@ -82,6 +86,9 @@ class ReanimatedContainer extends Container {
|
|
82
86
|
if (this.mapperId !== null) {
|
83
87
|
Rea.stopMapper(this.mapperId);
|
84
88
|
}
|
89
|
+
if (this.unmounted) {
|
90
|
+
return;
|
91
|
+
}
|
85
92
|
const recorder = new Recorder();
|
86
93
|
visit(recorder, this.root);
|
87
94
|
const record = recorder.getRecording();
|
@@ -120,6 +127,9 @@ class NativeReanimatedContainer extends Container {
|
|
120
127
|
if (this.mapperId !== null) {
|
121
128
|
Rea.stopMapper(this.mapperId);
|
122
129
|
}
|
130
|
+
if (this.unmounted) {
|
131
|
+
return;
|
132
|
+
}
|
123
133
|
const {
|
124
134
|
nativeId,
|
125
135
|
Skia
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["Rea","HAS_REANIMATED_3","Platform","Recorder","visit","replay","createDrawingContext","ReanimatedRecorder","drawOnscreen","Skia","nativeId","recording","rec","PictureRecorder","canvas","beginRecording","ctx","paintPool","commands","picture","finishRecordingAsPicture","SkiaViewApi","setJsiProperty","dispose","nativeDrawOnscreen","recorder","play","Container","constructor","_defineProperty","drawOnCanvas","Error","StaticContainer","redraw","root","getRecording","isOnScreen","ReanimatedContainer","mapperId","stopMapper","record","animationValues","size","startMapper","Array","from","runOnUI","NativeReanimatedContainer","sharedValues","getSharedValues","sharedRecorder","getRecorder","length","applyUpdates","createContainer","native","OS"],"sources":["Container.ts"],"sourcesContent":["import Rea from \"../external/reanimated/ReanimatedProxy\";\nimport type { Skia, SkCanvas } from \"../skia/types\";\nimport { HAS_REANIMATED_3 } from \"../external/reanimated/renderHelpers\";\nimport type { JsiRecorder } from \"../skia/types/Recorder\";\nimport { Platform } from \"../Platform\";\n\nimport type { Node } from \"./Node\";\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 { ReanimatedRecorder } from \"./Recorder/ReanimatedRecorder\";\n\nconst drawOnscreen = (Skia: Skia, nativeId: number, recording: Recording) => {\n \"worklet\";\n\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 //const end = performance.now();\n //console.log(\"Recording time: \", end - start);\n SkiaViewApi.setJsiProperty(nativeId, \"picture\", picture);\n rec.dispose();\n picture.dispose();\n};\n\nconst nativeDrawOnscreen = (\n Skia: Skia,\n nativeId: number,\n recorder: JsiRecorder\n) => {\n \"worklet\";\n\n const rec = Skia.PictureRecorder();\n const canvas = rec.beginRecording();\n //const start = performance.now();\n\n recorder.play(canvas);\n const picture = rec.finishRecordingAsPicture();\n //const end = performance.now();\n //console.log(\"Recording time: \", end - start);\n SkiaViewApi.setJsiProperty(nativeId, \"picture\", picture);\n rec.dispose();\n picture.dispose();\n};\n\nexport abstract class Container {\n public root: Node[] = [];\n protected recording: Recording | null = null;\n\n constructor(protected Skia: Skia, protected nativeId: number) {}\n\n drawOnCanvas(canvas: SkCanvas) {\n if (!this.recording) {\n throw new Error(\"No recording to draw\");\n }\n const ctx = createDrawingContext(\n this.Skia,\n this.recording.paintPool,\n canvas\n );\n replay(ctx, this.recording.commands);\n }\n\n abstract redraw(): void;\n}\n\nclass StaticContainer extends Container {\n constructor(Skia: Skia, nativeId: number) {\n super(Skia, nativeId);\n }\n\n redraw() {\n const recorder = new Recorder();\n visit(recorder, this.root);\n this.recording = recorder.getRecording();\n const isOnScreen = this.nativeId !== -1;\n if (isOnScreen) {\n const rec = this.Skia.PictureRecorder();\n const canvas = rec.beginRecording();\n this.drawOnCanvas(canvas);\n const picture = rec.finishRecordingAsPicture();\n SkiaViewApi.setJsiProperty(this.nativeId, \"picture\", picture);\n }\n }\n}\n\nclass ReanimatedContainer extends Container {\n private mapperId: number | null = null;\n\n constructor(Skia: Skia, nativeId: number) {\n super(Skia, nativeId);\n }\n\n redraw() {\n if (this.mapperId !== null) {\n Rea.stopMapper(this.mapperId);\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\nclass NativeReanimatedContainer extends Container {\n private mapperId: number | null = null;\n\n constructor(Skia: Skia, nativeId: number) {\n super(Skia, nativeId);\n }\n\n redraw() {\n if (this.mapperId !== null) {\n Rea.stopMapper(this.mapperId);\n }\n const { nativeId, Skia } = this;\n const recorder = new ReanimatedRecorder(Skia);\n visit(recorder, this.root);\n const sharedValues = recorder.getSharedValues();\n const sharedRecorder = recorder.getRecorder();\n if (sharedValues.length > 0) {\n this.mapperId = Rea.startMapper(() => {\n \"worklet\";\n sharedRecorder.applyUpdates(sharedValues);\n nativeDrawOnscreen(Skia, nativeId, sharedRecorder);\n }, sharedValues);\n }\n Rea.runOnUI(() => {\n \"worklet\";\n nativeDrawOnscreen(Skia, nativeId, sharedRecorder);\n })();\n }\n}\n\nexport const createContainer = (Skia: Skia, nativeId: number) => {\n const native = Platform.OS !== \"web\";\n if (HAS_REANIMATED_3 && nativeId !== -1) {\n if (native) {\n return new NativeReanimatedContainer(Skia, nativeId);\n } else {\n return new ReanimatedContainer(Skia, nativeId);\n }\n } else {\n return new StaticContainer(Skia, nativeId);\n }\n};\n"],"mappings":";;;AAAA,OAAOA,GAAG,MAAM,wCAAwC;AAExD,SAASC,gBAAgB,QAAQ,sCAAsC;AAEvE,SAASC,QAAQ,QAAQ,aAAa;AAItC,SAASC,QAAQ,QAAQ,qBAAqB;AAC9C,SAASC,KAAK,QAAQ,oBAAoB;AAC1C,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,kBAAkB,QAAQ,+BAA+B;AAElE,MAAMC,YAAY,GAAGA,CAACC,IAAU,EAAEC,QAAgB,EAAEC,SAAoB,KAAK;EAC3E,SAAS;;EAET,MAAMC,GAAG,GAAGH,IAAI,CAACI,eAAe,CAAC,CAAC;EAClC,MAAMC,MAAM,GAAGF,GAAG,CAACG,cAAc,CAAC,CAAC;EACnC;;EAEA,MAAMC,GAAG,GAAGV,oBAAoB,CAACG,IAAI,EAAEE,SAAS,CAACM,SAAS,EAAEH,MAAM,CAAC;EACnET,MAAM,CAACW,GAAG,EAAEL,SAAS,CAACO,QAAQ,CAAC;EAC/B,MAAMC,OAAO,GAAGP,GAAG,CAACQ,wBAAwB,CAAC,CAAC;EAC9C;EACA;EACAC,W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,GAAG,CAAC,EAAE;MAC3B,IAAI,CAACd,QAAQ,GAAGtC,GAAG,CAAC2C,WAAW,CAAC,MAAM;QACpC,SAAS;;QACTO,cAAc,CAACG,YAAY,CAACL,YAAY,CAAC;QACzCxB,kBAAkB,CAACf,IAAI,EAAEC,QAAQ,EAAEwC,cAAc,CAAC;MACpD,CAAC,EAAEF,YAAY,CAAC;IAClB;IACAhD,GAAG,CAAC8C,OAAO,CAAC,MAAM;MAChB,SAAS;;MACTtB,kBAAkB,CAACf,IAAI,EAAEC,QAAQ,EAAEwC,cAAc,CAAC;IACpD,CAAC,CAAC,CAAC,CAAC;EACN;AACF;AAEA,OAAO,MAAMI,eAAe,GAAGA,CAAC7C,IAAU,EAAEC,QAAgB,KAAK;EAC/D,MAAM6C,MAAM,GAAGrD,QAAQ,CAACsD,EAAE,KAAK,KAAK;EACpC,IAAIvD,gBAAgB,IAAIS,QAAQ,KAAK,CAAC,CAAC,EAAE;IACvC,IAAI6C,MAAM,EAAE;MACV,OAAO,IAAIR,yBAAyB,CAACtC,IAAI,EAAEC,QAAQ,CAAC;IACtD,CAAC,MAAM;MACL,OAAO,IAAI2B,mBAAmB,CAAC5B,IAAI,EAAEC,QAAQ,CAAC;IAChD;EACF,CAAC,MAAM;IACL,OAAO,IAAIsB,eAAe,CAACvB,IAAI,EAAEC,QAAQ,CAAC;EAC5C;AACF,CAAC","ignoreList":[]}
|
1
|
+
{"version":3,"names":["Rea","HAS_REANIMATED_3","Platform","Recorder","visit","replay","createDrawingContext","ReanimatedRecorder","drawOnscreen","Skia","nativeId","recording","rec","PictureRecorder","canvas","beginRecording","ctx","paintPool","commands","picture","finishRecordingAsPicture","SkiaViewApi","setJsiProperty","dispose","nativeDrawOnscreen","recorder","play","Container","constructor","_defineProperty","unmount","unmounted","drawOnCanvas","Error","StaticContainer","redraw","root","getRecording","isOnScreen","ReanimatedContainer","mapperId","stopMapper","record","animationValues","size","startMapper","Array","from","runOnUI","NativeReanimatedContainer","sharedValues","getSharedValues","sharedRecorder","getRecorder","length","applyUpdates","createContainer","native","OS"],"sources":["Container.ts"],"sourcesContent":["import Rea from \"../external/reanimated/ReanimatedProxy\";\nimport type { Skia, SkCanvas } from \"../skia/types\";\nimport { HAS_REANIMATED_3 } from \"../external/reanimated/renderHelpers\";\nimport type { JsiRecorder } from \"../skia/types/Recorder\";\nimport { Platform } from \"../Platform\";\n\nimport type { Node } from \"./Node\";\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 { ReanimatedRecorder } from \"./Recorder/ReanimatedRecorder\";\n\nconst drawOnscreen = (Skia: Skia, nativeId: number, recording: Recording) => {\n \"worklet\";\n\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 //const end = performance.now();\n //console.log(\"Recording time: \", end - start);\n SkiaViewApi.setJsiProperty(nativeId, \"picture\", picture);\n rec.dispose();\n picture.dispose();\n};\n\nconst nativeDrawOnscreen = (\n Skia: Skia,\n nativeId: number,\n recorder: JsiRecorder\n) => {\n \"worklet\";\n\n const rec = Skia.PictureRecorder();\n const canvas = rec.beginRecording();\n //const start = performance.now();\n\n recorder.play(canvas);\n const picture = rec.finishRecordingAsPicture();\n //const end = performance.now();\n //console.log(\"Recording time: \", end - start);\n SkiaViewApi.setJsiProperty(nativeId, \"picture\", picture);\n rec.dispose();\n picture.dispose();\n};\n\nexport abstract class Container {\n public root: Node[] = [];\n protected recording: Recording | null = null;\n protected unmounted = false;\n\n constructor(protected Skia: Skia, protected nativeId: number) {}\n\n unmount() {\n this.unmounted = true;\n }\n\n drawOnCanvas(canvas: SkCanvas) {\n if (!this.recording) {\n throw new Error(\"No recording to draw\");\n }\n const ctx = createDrawingContext(\n this.Skia,\n this.recording.paintPool,\n canvas\n );\n replay(ctx, this.recording.commands);\n }\n\n abstract redraw(): void;\n}\n\nclass StaticContainer extends Container {\n constructor(Skia: Skia, nativeId: number) {\n super(Skia, nativeId);\n }\n\n redraw() {\n const recorder = new Recorder();\n visit(recorder, this.root);\n this.recording = recorder.getRecording();\n const isOnScreen = this.nativeId !== -1;\n if (isOnScreen) {\n const rec = this.Skia.PictureRecorder();\n const canvas = rec.beginRecording();\n this.drawOnCanvas(canvas);\n const picture = rec.finishRecordingAsPicture();\n SkiaViewApi.setJsiProperty(this.nativeId, \"picture\", picture);\n }\n }\n}\n\nclass ReanimatedContainer extends Container {\n private mapperId: number | null = null;\n\n constructor(Skia: Skia, nativeId: number) {\n super(Skia, nativeId);\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\nclass NativeReanimatedContainer extends Container {\n private mapperId: number | null = null;\n\n constructor(Skia: Skia, nativeId: number) {\n super(Skia, nativeId);\n }\n\n redraw() {\n if (this.mapperId !== null) {\n Rea.stopMapper(this.mapperId);\n }\n if (this.unmounted) {\n return;\n }\n const { nativeId, Skia } = this;\n const recorder = new ReanimatedRecorder(Skia);\n visit(recorder, this.root);\n const sharedValues = recorder.getSharedValues();\n const sharedRecorder = recorder.getRecorder();\n if (sharedValues.length > 0) {\n this.mapperId = Rea.startMapper(() => {\n \"worklet\";\n sharedRecorder.applyUpdates(sharedValues);\n nativeDrawOnscreen(Skia, nativeId, sharedRecorder);\n }, sharedValues);\n }\n Rea.runOnUI(() => {\n \"worklet\";\n nativeDrawOnscreen(Skia, nativeId, sharedRecorder);\n })();\n }\n}\n\nexport const createContainer = (Skia: Skia, nativeId: number) => {\n const native = Platform.OS !== \"web\";\n if (HAS_REANIMATED_3 && nativeId !== -1) {\n if (native) {\n return new NativeReanimatedContainer(Skia, nativeId);\n } else {\n return new ReanimatedContainer(Skia, nativeId);\n }\n } else {\n return new StaticContainer(Skia, nativeId);\n }\n};\n"],"mappings":";;;AAAA,OAAOA,GAAG,MAAM,wCAAwC;AAExD,SAASC,gBAAgB,QAAQ,sCAAsC;AAEvE,SAASC,QAAQ,QAAQ,aAAa;AAItC,SAASC,QAAQ,QAAQ,qBAAqB;AAC9C,SAASC,KAAK,QAAQ,oBAAoB;AAC1C,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,oBAAoB,QAAQ,2BAA2B;AAChE,SAASC,kBAAkB,QAAQ,+BAA+B;AAElE,MAAMC,YAAY,GAAGA,CAACC,IAAU,EAAEC,QAAgB,EAAEC,SAAoB,KAAK;EAC3E,SAAS;;EAET,MAAMC,GAAG,GAAGH,IAAI,CAACI,eAAe,CAAC,CAAC;EAClC,MAAMC,MAAM,GAAGF,GAAG,CAACG,cAAc,CAAC,CAAC;EACnC;;EAEA,MAAMC,GAAG,GAAGV,oBAAoB,CAACG,IAAI,EAAEE,SAAS,CAACM,SAAS,EAAEH,MAAM,CAAC;EACnET,MAAM,CAACW,GAAG,EAAEL,SAAS,CAACO,QAAQ,CAAC;EAC/B,MAAMC,OAAO,GAAGP,GAAG,CAACQ,wBAAwB,CAAC,CAAC;EAC9C;EACA;EACAC,WAAW,CAACC,cAAc,CAACZ,QAAQ,EAAE,SAAS,EAAES,OAAO,CAAC;EACxDP,GAAG,CAACW,OAAO,CAAC,CAAC;EACbJ,OAAO,CAACI,OAAO,CAAC,CAAC;AACnB,CAAC;AAED,MAAMC,kBAAkB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AAIH,YAAY,CAACI,MAAM,GAAG,CAAC,EAAE;MAC3B,IAAI,CAACd,QAAQ,GAAGxC,GAAG,CAAC6C,WAAW,CAAC,MAAM;QACpC,SAAS;;QACTO,cAAc,CAACG,YAAY,CAACL,YAAY,CAAC;QACzC1B,kBAAkB,CAACf,IAAI,EAAEC,QAAQ,EAAE0C,cAAc,CAAC;MACpD,CAAC,EAAEF,YAAY,CAAC;IAClB;IACAlD,GAAG,CAACgD,OAAO,CAAC,MAAM;MAChB,SAAS;;MACTxB,kBAAkB,CAACf,IAAI,EAAEC,QAAQ,EAAE0C,cAAc,CAAC;IACpD,CAAC,CAAC,CAAC,CAAC;EACN;AACF;AAEA,OAAO,MAAMI,eAAe,GAAGA,CAAC/C,IAAU,EAAEC,QAAgB,KAAK;EAC/D,MAAM+C,MAAM,GAAGvD,QAAQ,CAACwD,EAAE,KAAK,KAAK;EACpC,IAAIzD,gBAAgB,IAAIS,QAAQ,KAAK,CAAC,CAAC,EAAE;IACvC,IAAI+C,MAAM,EAAE;MACV,OAAO,IAAIR,yBAAyB,CAACxC,IAAI,EAAEC,QAAQ,CAAC;IACtD,CAAC,MAAM;MACL,OAAO,IAAI6B,mBAAmB,CAAC9B,IAAI,EAAEC,QAAQ,CAAC;IAChD;EACF,CAAC,MAAM;IACL,OAAO,IAAIwB,eAAe,CAACzB,IAAI,EAAEC,QAAQ,CAAC;EAC5C;AACF,CAAC","ignoreList":[]}
|
@@ -0,0 +1,65 @@
|
|
1
|
+
import type { FractalNoiseProps, CircleProps, DrawingNodeProps, ImageProps, PaintProps, PathProps, LineProps, OvalProps, DiffRectProps, PointsProps, RectProps, RoundedRectProps, TextProps, VerticesProps, BlurMaskFilterProps, BlendImageFilterProps, BlurImageFilterProps, DisplacementMapImageFilterProps, DropShadowImageFilterProps, OffsetImageFilterProps, RuntimeShaderImageFilterProps, MatrixColorFilterProps, ShaderProps, ImageShaderProps, LinearGradientProps, GroupProps, PatchProps, BlendColorFilterProps, DashPathEffectProps, DiscretePathEffectProps, CornerPathEffectProps, Line2DPathEffectProps, Path1DPathEffectProps, Path2DPathEffectProps, TextPathProps, TextBlobProps, GlyphsProps, TwoPointConicalGradientProps, TurbulenceProps, SweepGradientProps, RadialGradientProps, ColorProps, PictureProps, ImageSVGProps, LerpColorFilterProps, BoxProps, BoxShadowProps, ParagraphProps, AtlasProps, ChildrenProps, MorphologyImageFilterProps, BlendProps } from "../dom/types";
|
2
|
+
import type { SkiaProps } from "../renderer";
|
3
|
+
declare global {
|
4
|
+
namespace JSX {
|
5
|
+
interface IntrinsicElements {
|
6
|
+
skGroup: SkiaProps<GroupProps>;
|
7
|
+
skLayer: SkiaProps<ChildrenProps>;
|
8
|
+
skPaint: SkiaProps<PaintProps>;
|
9
|
+
skFill: SkiaProps<DrawingNodeProps>;
|
10
|
+
skImage: SkiaProps<ImageProps>;
|
11
|
+
skCircle: SkiaProps<CircleProps>;
|
12
|
+
skPath: SkiaProps<PathProps>;
|
13
|
+
skLine: SkiaProps<LineProps>;
|
14
|
+
skOval: SkiaProps<OvalProps>;
|
15
|
+
skPatch: SkiaProps<PatchProps>;
|
16
|
+
skPoints: SkiaProps<PointsProps>;
|
17
|
+
skRect: SkiaProps<RectProps>;
|
18
|
+
skRRect: SkiaProps<RoundedRectProps>;
|
19
|
+
skAtlas: SkiaProps<AtlasProps>;
|
20
|
+
skVertices: SkiaProps<VerticesProps>;
|
21
|
+
skText: SkiaProps<TextProps>;
|
22
|
+
skTextPath: SkiaProps<TextPathProps>;
|
23
|
+
skTextBlob: SkiaProps<TextBlobProps>;
|
24
|
+
skGlyphs: SkiaProps<GlyphsProps>;
|
25
|
+
skDiffRect: SkiaProps<DiffRectProps>;
|
26
|
+
skPicture: SkiaProps<PictureProps>;
|
27
|
+
skImageSVG: SkiaProps<ImageSVGProps>;
|
28
|
+
skBlurMaskFilter: SkiaProps<BlurMaskFilterProps>;
|
29
|
+
skBlendImageFilter: SkiaProps<BlendImageFilterProps>;
|
30
|
+
skBlurImageFilter: SkiaProps<BlurImageFilterProps>;
|
31
|
+
skOffsetImageFilter: SkiaProps<OffsetImageFilterProps>;
|
32
|
+
skDropShadowImageFilter: SkiaProps<DropShadowImageFilterProps>;
|
33
|
+
skDisplacementMapImageFilter: SkiaProps<DisplacementMapImageFilterProps>;
|
34
|
+
skRuntimeShaderImageFilter: SkiaProps<RuntimeShaderImageFilterProps>;
|
35
|
+
skMorphologyImageFilter: SkiaProps<MorphologyImageFilterProps>;
|
36
|
+
skMatrixColorFilter: SkiaProps<MatrixColorFilterProps>;
|
37
|
+
skBlendColorFilter: SkiaProps<BlendColorFilterProps>;
|
38
|
+
skLinearToSRGBGammaColorFilter: SkiaProps<ChildrenProps>;
|
39
|
+
skSRGBToLinearGammaColorFilter: SkiaProps<ChildrenProps>;
|
40
|
+
skLumaColorFilter: SkiaProps<ChildrenProps>;
|
41
|
+
skLerpColorFilter: SkiaProps<LerpColorFilterProps>;
|
42
|
+
skShader: SkiaProps<ShaderProps>;
|
43
|
+
skImageShader: SkiaProps<ImageShaderProps>;
|
44
|
+
skColorShader: SkiaProps<ColorProps>;
|
45
|
+
skTurbulence: SkiaProps<TurbulenceProps>;
|
46
|
+
skFractalNoise: SkiaProps<FractalNoiseProps>;
|
47
|
+
skLinearGradient: SkiaProps<LinearGradientProps>;
|
48
|
+
skRadialGradient: SkiaProps<RadialGradientProps>;
|
49
|
+
skSweepGradient: SkiaProps<SweepGradientProps>;
|
50
|
+
skTwoPointConicalGradient: SkiaProps<TwoPointConicalGradientProps>;
|
51
|
+
skDiscretePathEffect: SkiaProps<DiscretePathEffectProps>;
|
52
|
+
skDashPathEffect: SkiaProps<DashPathEffectProps>;
|
53
|
+
skPath1DPathEffect: SkiaProps<Path1DPathEffectProps>;
|
54
|
+
skPath2DPathEffect: SkiaProps<Path2DPathEffectProps>;
|
55
|
+
skCornerPathEffect: SkiaProps<CornerPathEffectProps>;
|
56
|
+
skSumPathEffect: ChildrenProps;
|
57
|
+
skLine2DPathEffect: SkiaProps<Line2DPathEffectProps>;
|
58
|
+
skBlend: SkiaProps<BlendProps>;
|
59
|
+
skBackdropFilter: SkiaProps<ChildrenProps>;
|
60
|
+
skBox: SkiaProps<BoxProps>;
|
61
|
+
skBoxShadow: SkiaProps<BoxShadowProps>;
|
62
|
+
skParagraph: SkiaProps<ParagraphProps>;
|
63
|
+
}
|
64
|
+
}
|
65
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":[],"sources":["Elements.tsx"],"sourcesContent":["import type {\n FractalNoiseProps,\n CircleProps,\n DrawingNodeProps,\n ImageProps,\n PaintProps,\n PathProps,\n LineProps,\n OvalProps,\n DiffRectProps,\n PointsProps,\n RectProps,\n RoundedRectProps,\n TextProps,\n VerticesProps,\n BlurMaskFilterProps,\n BlendImageFilterProps,\n BlurImageFilterProps,\n DisplacementMapImageFilterProps,\n DropShadowImageFilterProps,\n OffsetImageFilterProps,\n RuntimeShaderImageFilterProps,\n MatrixColorFilterProps,\n ShaderProps,\n ImageShaderProps,\n LinearGradientProps,\n GroupProps,\n PatchProps,\n BlendColorFilterProps,\n DashPathEffectProps,\n DiscretePathEffectProps,\n CornerPathEffectProps,\n Line2DPathEffectProps,\n Path1DPathEffectProps,\n Path2DPathEffectProps,\n TextPathProps,\n TextBlobProps,\n GlyphsProps,\n TwoPointConicalGradientProps,\n TurbulenceProps,\n SweepGradientProps,\n RadialGradientProps,\n ColorProps,\n PictureProps,\n ImageSVGProps,\n LerpColorFilterProps,\n BoxProps,\n BoxShadowProps,\n ParagraphProps,\n AtlasProps,\n ChildrenProps,\n MorphologyImageFilterProps,\n BlendProps,\n} from \"../dom/types\";\nimport type { SkiaProps } from \"../renderer\";\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace JSX {\n interface IntrinsicElements {\n skGroup: SkiaProps<GroupProps>;\n skLayer: SkiaProps<ChildrenProps>;\n skPaint: SkiaProps<PaintProps>;\n\n // Drawings\n skFill: SkiaProps<DrawingNodeProps>;\n skImage: SkiaProps<ImageProps>;\n skCircle: SkiaProps<CircleProps>;\n skPath: SkiaProps<PathProps>;\n skLine: SkiaProps<LineProps>;\n skOval: SkiaProps<OvalProps>;\n skPatch: SkiaProps<PatchProps>;\n skPoints: SkiaProps<PointsProps>;\n skRect: SkiaProps<RectProps>;\n skRRect: SkiaProps<RoundedRectProps>;\n skAtlas: SkiaProps<AtlasProps>;\n skVertices: SkiaProps<VerticesProps>;\n skText: SkiaProps<TextProps>;\n skTextPath: SkiaProps<TextPathProps>;\n skTextBlob: SkiaProps<TextBlobProps>;\n skGlyphs: SkiaProps<GlyphsProps>;\n skDiffRect: SkiaProps<DiffRectProps>;\n skPicture: SkiaProps<PictureProps>;\n skImageSVG: SkiaProps<ImageSVGProps>;\n\n // BlurMaskFilters\n skBlurMaskFilter: SkiaProps<BlurMaskFilterProps>;\n\n // ImageFilters\n skBlendImageFilter: SkiaProps<BlendImageFilterProps>;\n skBlurImageFilter: SkiaProps<BlurImageFilterProps>;\n skOffsetImageFilter: SkiaProps<OffsetImageFilterProps>;\n skDropShadowImageFilter: SkiaProps<DropShadowImageFilterProps>;\n skDisplacementMapImageFilter: SkiaProps<DisplacementMapImageFilterProps>;\n skRuntimeShaderImageFilter: SkiaProps<RuntimeShaderImageFilterProps>;\n skMorphologyImageFilter: SkiaProps<MorphologyImageFilterProps>;\n\n // ColorFilters\n skMatrixColorFilter: SkiaProps<MatrixColorFilterProps>;\n skBlendColorFilter: SkiaProps<BlendColorFilterProps>;\n skLinearToSRGBGammaColorFilter: SkiaProps<ChildrenProps>;\n skSRGBToLinearGammaColorFilter: SkiaProps<ChildrenProps>;\n skLumaColorFilter: SkiaProps<ChildrenProps>;\n skLerpColorFilter: SkiaProps<LerpColorFilterProps>;\n\n // Shaders\n skShader: SkiaProps<ShaderProps>;\n skImageShader: SkiaProps<ImageShaderProps>;\n skColorShader: SkiaProps<ColorProps>;\n skTurbulence: SkiaProps<TurbulenceProps>;\n skFractalNoise: SkiaProps<FractalNoiseProps>;\n skLinearGradient: SkiaProps<LinearGradientProps>;\n skRadialGradient: SkiaProps<RadialGradientProps>;\n skSweepGradient: SkiaProps<SweepGradientProps>;\n skTwoPointConicalGradient: SkiaProps<TwoPointConicalGradientProps>;\n\n // Path Effects\n skDiscretePathEffect: SkiaProps<DiscretePathEffectProps>;\n skDashPathEffect: SkiaProps<DashPathEffectProps>;\n skPath1DPathEffect: SkiaProps<Path1DPathEffectProps>;\n skPath2DPathEffect: SkiaProps<Path2DPathEffectProps>;\n skCornerPathEffect: SkiaProps<CornerPathEffectProps>;\n skSumPathEffect: ChildrenProps;\n skLine2DPathEffect: SkiaProps<Line2DPathEffectProps>;\n\n // Mixed declarations/drawings\n skBlend: SkiaProps<BlendProps>;\n skBackdropFilter: SkiaProps<ChildrenProps>;\n skBox: SkiaProps<BoxProps>;\n skBoxShadow: SkiaProps<BoxShadowProps>;\n\n // Paragraph\n skParagraph: SkiaProps<ParagraphProps>;\n }\n }\n}\n"],"mappings":"","ignoreList":[]}
|
@@ -5,6 +5,7 @@ import ReactReconciler from "react-reconciler";
|
|
5
5
|
import { NodeType } from "../dom/types";
|
6
6
|
import { debug, sksgHostConfig } from "./HostConfig";
|
7
7
|
import { createContainer } from "./Container";
|
8
|
+
import "./Elements";
|
8
9
|
const skiaReconciler = ReactReconciler(sksgHostConfig);
|
9
10
|
skiaReconciler.injectIntoDevTools({
|
10
11
|
bundleType: 1,
|
@@ -44,6 +45,7 @@ export class SkiaSGRoot {
|
|
44
45
|
return recorder.finishRecordingAsPicture();
|
45
46
|
}
|
46
47
|
unmount() {
|
48
|
+
this.container.unmount();
|
47
49
|
skiaReconciler.updateContainer(null, this.root, null, () => {
|
48
50
|
debug("unmountContainer");
|
49
51
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["ReactReconciler","NodeType","debug","sksgHostConfig","createContainer","skiaReconciler","injectIntoDevTools","bundleType","version","rendererPackageName","SkiaSGRoot","constructor","Skia","nativeId","_defineProperty","container","root","console","error","sg","children","type","Group","props","isDeclaration","render","element","updateContainer","drawOnCanvas","canvas","getPicture","recorder","PictureRecorder","beginRecording","finishRecordingAsPicture","unmount"],"sources":["Reconciler.ts"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { OpaqueRoot } from \"react-reconciler\";\nimport ReactReconciler from \"react-reconciler\";\n\nimport type { SkCanvas, Skia } from \"../skia/types\";\nimport { NodeType } from \"../dom/types\";\n\nimport { debug, sksgHostConfig } from \"./HostConfig\";\nimport type { Container } from \"./Container\";\nimport { createContainer } from \"./Container\";\n\nconst skiaReconciler = ReactReconciler(sksgHostConfig);\n\nskiaReconciler.injectIntoDevTools({\n bundleType: 1,\n version: \"0.0.1\",\n rendererPackageName: \"react-native-skia\",\n});\n\nexport class SkiaSGRoot {\n private root: OpaqueRoot;\n private container: Container;\n\n constructor(public Skia: Skia, nativeId = -1) {\n this.container = createContainer(Skia, nativeId);\n this.root = skiaReconciler.createContainer(\n this.container,\n 0,\n null,\n true,\n null,\n \"\",\n console.error,\n null\n );\n }\n\n get sg() {\n const children = this.container.root;\n return { type: NodeType.Group, props: {}, children, isDeclaration: false };\n }\n\n render(element: ReactNode) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n skiaReconciler.updateContainer(element as any, this.root, null, () => {\n debug(\"updateContainer\");\n });\n }\n\n drawOnCanvas(canvas: SkCanvas) {\n this.container.drawOnCanvas(canvas);\n }\n\n getPicture() {\n const recorder = this.Skia.PictureRecorder();\n const canvas = recorder.beginRecording();\n this.drawOnCanvas(canvas);\n return recorder.finishRecordingAsPicture();\n }\n\n unmount() {\n skiaReconciler.updateContainer(null, this.root, null, () => {\n debug(\"unmountContainer\");\n });\n }\n}\n"],"mappings":";;;AAEA,OAAOA,eAAe,MAAM,kBAAkB;AAG9C,SAASC,QAAQ,QAAQ,cAAc;AAEvC,SAASC,KAAK,EAAEC,cAAc,QAAQ,cAAc;AAEpD,SAASC,eAAe,QAAQ,aAAa;
|
1
|
+
{"version":3,"names":["ReactReconciler","NodeType","debug","sksgHostConfig","createContainer","skiaReconciler","injectIntoDevTools","bundleType","version","rendererPackageName","SkiaSGRoot","constructor","Skia","nativeId","_defineProperty","container","root","console","error","sg","children","type","Group","props","isDeclaration","render","element","updateContainer","drawOnCanvas","canvas","getPicture","recorder","PictureRecorder","beginRecording","finishRecordingAsPicture","unmount"],"sources":["Reconciler.ts"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport type { OpaqueRoot } from \"react-reconciler\";\nimport ReactReconciler from \"react-reconciler\";\n\nimport type { SkCanvas, Skia } from \"../skia/types\";\nimport { NodeType } from \"../dom/types\";\n\nimport { debug, sksgHostConfig } from \"./HostConfig\";\nimport type { Container } from \"./Container\";\nimport { createContainer } from \"./Container\";\nimport \"./Elements\";\n\nconst skiaReconciler = ReactReconciler(sksgHostConfig);\n\nskiaReconciler.injectIntoDevTools({\n bundleType: 1,\n version: \"0.0.1\",\n rendererPackageName: \"react-native-skia\",\n});\n\nexport class SkiaSGRoot {\n private root: OpaqueRoot;\n private container: Container;\n\n constructor(public Skia: Skia, nativeId = -1) {\n this.container = createContainer(Skia, nativeId);\n this.root = skiaReconciler.createContainer(\n this.container,\n 0,\n null,\n true,\n null,\n \"\",\n console.error,\n null\n );\n }\n\n get sg() {\n const children = this.container.root;\n return { type: NodeType.Group, props: {}, children, isDeclaration: false };\n }\n\n render(element: ReactNode) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n skiaReconciler.updateContainer(element as any, this.root, null, () => {\n debug(\"updateContainer\");\n });\n }\n\n drawOnCanvas(canvas: SkCanvas) {\n this.container.drawOnCanvas(canvas);\n }\n\n getPicture() {\n const recorder = this.Skia.PictureRecorder();\n const canvas = recorder.beginRecording();\n this.drawOnCanvas(canvas);\n return recorder.finishRecordingAsPicture();\n }\n\n unmount() {\n this.container.unmount();\n skiaReconciler.updateContainer(null, this.root, null, () => {\n debug(\"unmountContainer\");\n });\n }\n}\n"],"mappings":";;;AAEA,OAAOA,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;EACrC;EAEAC,UAAUA,CAAA,EAAG;IACX,MAAMC,QAAQ,GAAG,IAAI,CAACnB,IAAI,CAACoB,eAAe,CAAC,CAAC;IAC5C,MAAMH,MAAM,GAAGE,QAAQ,CAACE,cAAc,CAAC,CAAC;IACxC,IAAI,CAACL,YAAY,CAACC,MAAM,CAAC;IACzB,OAAOE,QAAQ,CAACG,wBAAwB,CAAC,CAAC;EAC5C;EAEAC,OAAOA,CAAA,EAAG;IACR,IAAI,CAACpB,SAAS,CAACoB,OAAO,CAAC,CAAC;IACxB9B,cAAc,CAACsB,eAAe,CAAC,IAAI,EAAE,IAAI,CAACX,IAAI,EAAE,IAAI,EAAE,MAAM;MAC1Dd,KAAK,CAAC,kBAAkB,CAAC;IAC3B,CAAC,CAAC;EACJ;AACF","ignoreList":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./SkiaPictureView\";\nexport * from \"./
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./SkiaPictureView\";\nexport * from \"./types\";\n"],"mappings":"AAAA,cAAc,mBAAmB;AACjC,cAAc,SAAS","ignoreList":[]}
|
@@ -1,5 +1,2 @@
|
|
1
1
|
export const __esModule: boolean;
|
2
2
|
export const HAS_REANIMATED_3: any;
|
3
|
-
export function bindReanimatedProps(container: any, node: any, reanimatedProps: any): void;
|
4
|
-
export function extractReanimatedProps(props: any): any[];
|
5
|
-
export function unbindReanimatedNode(node: any): void;
|
@@ -3,6 +3,8 @@ export class Container {
|
|
3
3
|
constructor(Skia: any, nativeId: any);
|
4
4
|
Skia: any;
|
5
5
|
nativeId: any;
|
6
|
+
unmount(): void;
|
7
|
+
unmounted: boolean | undefined;
|
6
8
|
drawOnCanvas(canvas: any): void;
|
7
9
|
}
|
8
10
|
export function createContainer(Skia: any, nativeId: any): NativeReanimatedContainer | ReanimatedContainer | StaticContainer;
|
@@ -0,0 +1 @@
|
|
1
|
+
export const __esModule: boolean;
|
@@ -7,6 +7,8 @@ export class SkiaSGRoot {
|
|
7
7
|
mapperId: any;
|
8
8
|
Skia: any;
|
9
9
|
nativeId: any;
|
10
|
+
unmount(): void;
|
11
|
+
unmounted: boolean | undefined;
|
10
12
|
drawOnCanvas(canvas: any): void;
|
11
13
|
} | {
|
12
14
|
redraw(): void;
|
@@ -17,6 +19,8 @@ export class SkiaSGRoot {
|
|
17
19
|
mapperId: any;
|
18
20
|
Skia: any;
|
19
21
|
nativeId: any;
|
22
|
+
unmount(): void;
|
23
|
+
unmounted: boolean | undefined;
|
20
24
|
drawOnCanvas(canvas: any): void;
|
21
25
|
} | {
|
22
26
|
redraw(): void;
|
@@ -27,6 +31,8 @@ export class SkiaSGRoot {
|
|
27
31
|
} | undefined;
|
28
32
|
Skia: any;
|
29
33
|
nativeId: any;
|
34
|
+
unmount(): void;
|
35
|
+
unmounted: boolean | undefined;
|
30
36
|
drawOnCanvas(canvas: any): void;
|
31
37
|
};
|
32
38
|
root: any;
|