@shopify/react-native-skia 0.1.185 → 0.1.186

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. package/android/build.gradle +2 -1
  2. package/android/cpp/jni/JniPlatformContext.cpp +92 -3
  3. package/android/cpp/jni/include/JniPlatformContext.h +4 -0
  4. package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +8 -0
  5. package/android/src/main/java/com/shopify/reactnative/skia/PlatformContext.java +17 -1
  6. package/android/src/main/java/com/shopify/reactnative/skia/ViewScreenshotService.java +180 -0
  7. package/cpp/api/JsiSkFont.h +1 -1
  8. package/cpp/api/JsiSkHostObjects.h +1 -1
  9. package/cpp/api/JsiSkImage.h +1 -1
  10. package/cpp/api/JsiSkImageFactory.h +29 -0
  11. package/cpp/api/JsiSkPaint.h +7 -7
  12. package/cpp/api/JsiSkPathFactory.h +1 -1
  13. package/cpp/api/JsiSkPicture.h +2 -2
  14. package/cpp/api/JsiSkRuntimeEffect.h +3 -3
  15. package/cpp/api/JsiSkSVG.h +12 -2
  16. package/cpp/api/JsiSkShader.h +1 -1
  17. package/cpp/api/JsiSkSurface.h +3 -3
  18. package/cpp/api/JsiSkSurfaceFactory.h +1 -1
  19. package/cpp/api/JsiSkTypeface.h +1 -1
  20. package/cpp/rnskia/RNSkAnimation.h +3 -3
  21. package/cpp/rnskia/RNSkDomView.h +9 -9
  22. package/cpp/rnskia/RNSkInfoParameter.h +2 -2
  23. package/cpp/rnskia/RNSkJsView.h +8 -8
  24. package/cpp/rnskia/RNSkJsiViewApi.h +5 -5
  25. package/cpp/rnskia/RNSkPictureView.h +8 -8
  26. package/cpp/rnskia/RNSkPlatformContext.h +32 -3
  27. package/cpp/rnskia/RNSkValueApi.h +5 -5
  28. package/cpp/rnskia/RNSkView.h +6 -6
  29. package/cpp/rnskia/dom/base/ConcatablePaint.h +6 -6
  30. package/cpp/rnskia/dom/base/Declaration.h +1 -1
  31. package/cpp/rnskia/dom/base/DeclarationContext.h +7 -7
  32. package/cpp/rnskia/dom/base/DrawingContext.h +3 -3
  33. package/cpp/rnskia/dom/base/NodePropsContainer.h +1 -1
  34. package/cpp/rnskia/dom/nodes/JsiBlurMaskNode.h +1 -1
  35. package/cpp/rnskia/dom/nodes/JsiColorFilterNodes.h +1 -1
  36. package/cpp/rnskia/dom/nodes/JsiGlyphsNode.h +8 -7
  37. package/cpp/rnskia/dom/nodes/JsiImageFilterNodes.h +1 -1
  38. package/cpp/rnskia/dom/nodes/JsiImageNode.h +5 -2
  39. package/cpp/rnskia/dom/nodes/JsiImageSvgNode.h +9 -9
  40. package/cpp/rnskia/dom/nodes/JsiPathEffectNodes.h +1 -1
  41. package/cpp/rnskia/dom/nodes/JsiPathNode.h +1 -1
  42. package/cpp/rnskia/dom/nodes/JsiPointsNode.h +1 -1
  43. package/cpp/rnskia/dom/nodes/JsiShaderNodes.h +7 -3
  44. package/cpp/rnskia/dom/nodes/JsiTextNode.h +5 -4
  45. package/cpp/rnskia/dom/nodes/JsiTextPathNode.h +3 -1
  46. package/cpp/rnskia/dom/props/BlendModeProp.h +1 -1
  47. package/cpp/rnskia/dom/props/CircleProp.h +1 -1
  48. package/cpp/rnskia/dom/props/ClipProp.h +1 -1
  49. package/cpp/rnskia/dom/props/FontProp.h +15 -10
  50. package/cpp/rnskia/dom/props/ImageProps.h +30 -16
  51. package/cpp/rnskia/dom/props/PaintProps.h +1 -1
  52. package/cpp/rnskia/dom/props/PathProp.h +1 -1
  53. package/cpp/rnskia/dom/props/PointProp.h +1 -1
  54. package/cpp/rnskia/dom/props/PointsProp.h +1 -1
  55. package/cpp/rnskia/dom/props/RRectProp.h +2 -2
  56. package/cpp/rnskia/dom/props/RadiusProp.h +1 -1
  57. package/cpp/rnskia/dom/props/RectProp.h +1 -1
  58. package/cpp/rnskia/dom/props/StrokeProps.h +1 -1
  59. package/cpp/rnskia/dom/props/SvgProp.h +18 -12
  60. package/cpp/rnskia/dom/props/TextBlobProp.h +60 -57
  61. package/cpp/rnskia/dom/props/TileModeProp.h +1 -1
  62. package/cpp/rnskia/dom/props/UniformsProp.h +1 -1
  63. package/cpp/rnskia/dom/props/VertexModeProp.h +1 -1
  64. package/cpp/rnskia/dom/props/VerticesProps.h +1 -1
  65. package/cpp/rnskia/values/RNSkClockValue.h +2 -2
  66. package/cpp/rnskia/values/RNSkComputedValue.h +1 -1
  67. package/cpp/rnskia/values/RNSkReadonlyValue.h +3 -3
  68. package/cpp/rnskia/values/RNSkValue.h +4 -4
  69. package/cpp/utils/RNSkMeasureTime.h +1 -1
  70. package/cpp/utils/RNSkTimingInfo.h +1 -1
  71. package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +16 -13
  72. package/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm +8 -0
  73. package/ios/RNSkia-iOS/SkiaManager.mm +20 -1
  74. package/ios/RNSkia-iOS/ViewScreenshotService.h +21 -0
  75. package/ios/RNSkia-iOS/ViewScreenshotService.mm +79 -0
  76. package/lib/commonjs/dom/nodes/drawings/ImageNode.js +22 -1
  77. package/lib/commonjs/dom/nodes/drawings/ImageNode.js.map +1 -1
  78. package/lib/commonjs/dom/nodes/drawings/ImageSVG.js +5 -0
  79. package/lib/commonjs/dom/nodes/drawings/ImageSVG.js.map +1 -1
  80. package/lib/commonjs/dom/nodes/drawings/Text.d.ts +2 -2
  81. package/lib/commonjs/dom/nodes/drawings/Text.js +13 -2
  82. package/lib/commonjs/dom/nodes/drawings/Text.js.map +1 -1
  83. package/lib/commonjs/dom/nodes/paint/Shaders.js +5 -0
  84. package/lib/commonjs/dom/nodes/paint/Shaders.js.map +1 -1
  85. package/lib/commonjs/dom/types/Drawings.d.ts +5 -5
  86. package/lib/commonjs/dom/types/Drawings.js.map +1 -1
  87. package/lib/commonjs/dom/types/Shaders.d.ts +1 -1
  88. package/lib/commonjs/dom/types/Shaders.js.map +1 -1
  89. package/lib/commonjs/mock/index.js +2 -1
  90. package/lib/commonjs/mock/index.js.map +1 -1
  91. package/lib/commonjs/skia/core/Image.d.ts +14 -2
  92. package/lib/commonjs/skia/core/Image.js +37 -1
  93. package/lib/commonjs/skia/core/Image.js.map +1 -1
  94. package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +7 -0
  95. package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
  96. package/lib/commonjs/skia/types/SVG/SVG.d.ts +4 -1
  97. package/lib/commonjs/skia/types/SVG/SVG.js.map +1 -1
  98. package/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +2 -1
  99. package/lib/commonjs/skia/web/JsiSkImageFactory.js +7 -0
  100. package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
  101. package/lib/module/dom/nodes/drawings/ImageNode.js +22 -1
  102. package/lib/module/dom/nodes/drawings/ImageNode.js.map +1 -1
  103. package/lib/module/dom/nodes/drawings/ImageSVG.js +5 -0
  104. package/lib/module/dom/nodes/drawings/ImageSVG.js.map +1 -1
  105. package/lib/module/dom/nodes/drawings/Text.d.ts +2 -2
  106. package/lib/module/dom/nodes/drawings/Text.js +13 -2
  107. package/lib/module/dom/nodes/drawings/Text.js.map +1 -1
  108. package/lib/module/dom/nodes/paint/Shaders.js +5 -0
  109. package/lib/module/dom/nodes/paint/Shaders.js.map +1 -1
  110. package/lib/module/dom/types/Drawings.d.ts +5 -5
  111. package/lib/module/dom/types/Drawings.js.map +1 -1
  112. package/lib/module/dom/types/Shaders.d.ts +1 -1
  113. package/lib/module/dom/types/Shaders.js.map +1 -1
  114. package/lib/module/mock/index.js +2 -1
  115. package/lib/module/mock/index.js.map +1 -1
  116. package/lib/module/skia/core/Image.d.ts +14 -2
  117. package/lib/module/skia/core/Image.js +32 -0
  118. package/lib/module/skia/core/Image.js.map +1 -1
  119. package/lib/module/skia/types/Image/ImageFactory.d.ts +7 -0
  120. package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
  121. package/lib/module/skia/types/SVG/SVG.d.ts +4 -1
  122. package/lib/module/skia/types/SVG/SVG.js.map +1 -1
  123. package/lib/module/skia/web/JsiSkImageFactory.d.ts +2 -1
  124. package/lib/module/skia/web/JsiSkImageFactory.js +7 -0
  125. package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
  126. package/lib/typescript/src/dom/nodes/drawings/Text.d.ts +2 -2
  127. package/lib/typescript/src/dom/types/Drawings.d.ts +5 -5
  128. package/lib/typescript/src/dom/types/Shaders.d.ts +1 -1
  129. package/lib/typescript/src/skia/core/Image.d.ts +14 -2
  130. package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +7 -0
  131. package/lib/typescript/src/skia/types/SVG/SVG.d.ts +4 -1
  132. package/lib/typescript/src/skia/web/JsiSkImageFactory.d.ts +2 -1
  133. package/package.json +2 -2
  134. package/scripts/install-npm.js +3 -2
  135. package/src/dom/nodes/drawings/ImageNode.ts +9 -1
  136. package/src/dom/nodes/drawings/ImageSVG.ts +3 -0
  137. package/src/dom/nodes/drawings/Text.ts +13 -3
  138. package/src/dom/nodes/paint/Shaders.ts +4 -0
  139. package/src/dom/types/Drawings.ts +5 -5
  140. package/src/dom/types/Shaders.ts +1 -1
  141. package/src/mock/index.ts +1 -0
  142. package/src/skia/core/Image.ts +43 -1
  143. package/src/skia/types/Image/ImageFactory.ts +8 -0
  144. package/src/skia/types/SVG/SVG.ts +4 -1
  145. package/src/skia/web/JsiSkImageFactory.ts +8 -1
@@ -1 +1 @@
1
- {"version":3,"names":["TextNode","JsiDrawingNode","constructor","ctx","props","NodeType","Text","deriveProps","draw","canvas","paint","text","x","y","font","drawText","TextPathNode","TextPath","path","processPath","Skia","initialOffset","ids","getGlyphIDs","widths","getGlyphWidths","rsx","meas","ContourMeasureIter","cont","next","dist","i","length","width","substring","p","t","getPosTan","adjustedX","adjustedY","push","RSXform","TextBlob","MakeFromRSXform","derived","Error","drawTextBlob","TextBlobNode","blob","GlyphsNode","Glyphs","glyphs","reduce","acc","glyph","id","pos","positions","drawGlyphs"],"sources":["Text.ts"],"sourcesContent":["import type { SkRSXform, SkTextBlob, SkPoint } from \"../../../skia/types\";\nimport type {\n DrawingContext,\n TextBlobProps,\n TextPathProps,\n TextProps,\n} from \"../../types\";\nimport { NodeType } from \"../../types\";\nimport { processPath } from \"../datatypes\";\nimport type { GlyphsProps } from \"../../types/Drawings\";\nimport { JsiDrawingNode } from \"../DrawingNode\";\nimport type { NodeContext } from \"../Node\";\n\nexport class TextNode extends JsiDrawingNode<TextProps, null> {\n constructor(ctx: NodeContext, props: TextProps) {\n super(ctx, NodeType.Text, props);\n }\n\n protected deriveProps() {\n return null;\n }\n\n draw({ canvas, paint }: DrawingContext) {\n const { text, x, y, font } = this.props;\n canvas.drawText(text, x, y, paint, font);\n }\n}\n\nexport class TextPathNode extends JsiDrawingNode<TextPathProps, SkTextBlob> {\n constructor(ctx: NodeContext, props: TextPathProps) {\n super(ctx, NodeType.TextPath, props);\n }\n\n deriveProps() {\n const path = processPath(this.Skia, this.props.path);\n const { font, initialOffset } = this.props;\n let { text } = this.props;\n const ids = font.getGlyphIDs(text);\n const widths = font.getGlyphWidths(ids);\n const rsx: SkRSXform[] = [];\n const meas = this.Skia.ContourMeasureIter(path, false, 1);\n let cont = meas.next();\n let dist = initialOffset;\n for (let i = 0; i < text.length && cont; i++) {\n const width = widths[i];\n dist += width / 2;\n if (dist > cont.length()) {\n // jump to next contour\n cont = meas.next();\n if (!cont) {\n // We have come to the end of the path - terminate the string\n // right here.\n text = text.substring(0, i);\n break;\n }\n dist = width / 2;\n }\n // Gives us the (x, y) coordinates as well as the cos/sin of the tangent\n // line at that position.\n const [p, t] = cont.getPosTan(dist);\n const adjustedX = p.x - (width / 2) * t.x;\n const adjustedY = p.y - (width / 2) * t.y;\n rsx.push(this.Skia.RSXform(t.x, t.y, adjustedX, adjustedY));\n dist += width / 2;\n }\n return this.Skia.TextBlob.MakeFromRSXform(text, rsx, font);\n }\n\n draw({ canvas, paint }: DrawingContext) {\n if (!this.derived) {\n throw new Error(\"TextPathNode: blob is null\");\n }\n canvas.drawTextBlob(this.derived, 0, 0, paint);\n }\n}\n\nexport class TextBlobNode extends JsiDrawingNode<TextBlobProps, null> {\n constructor(ctx: NodeContext, props: TextBlobProps) {\n super(ctx, NodeType.TextBlob, props);\n }\n\n protected deriveProps() {\n return null;\n }\n\n draw({ canvas, paint }: DrawingContext) {\n const { blob, x, y } = this.props;\n canvas.drawTextBlob(blob, x, y, paint);\n }\n}\n\ninterface ProcessedGlyphs {\n glyphs: number[];\n positions: SkPoint[];\n}\n\nexport class GlyphsNode extends JsiDrawingNode<GlyphsProps, ProcessedGlyphs> {\n constructor(ctx: NodeContext, props: GlyphsProps) {\n super(ctx, NodeType.Glyphs, props);\n }\n\n deriveProps() {\n return this.props.glyphs.reduce<ProcessedGlyphs>(\n (acc, glyph) => {\n const { id, pos } = glyph;\n acc.glyphs.push(id);\n acc.positions.push(pos);\n return acc;\n },\n { glyphs: [], positions: [] }\n );\n }\n\n draw({ canvas, paint }: DrawingContext) {\n if (!this.derived) {\n throw new Error(\"GlyphsNode: processedGlyphs is null\");\n }\n const { glyphs, positions } = this.derived;\n const { x, y, font } = this.props;\n canvas.drawGlyphs(glyphs, positions, x, y, font, paint);\n }\n}\n"],"mappings":";;;;;;;AAOA;;AACA;;AAEA;;AAGO,MAAMA,QAAN,SAAuBC,2BAAvB,CAAuD;EAC5DC,WAAW,CAACC,GAAD,EAAmBC,KAAnB,EAAqC;IAC9C,MAAMD,GAAN,EAAWE,eAAA,CAASC,IAApB,EAA0BF,KAA1B;EACD;;EAESG,WAAW,GAAG;IACtB,OAAO,IAAP;EACD;;EAEDC,IAAI,OAAoC;IAAA,IAAnC;MAAEC,MAAF;MAAUC;IAAV,CAAmC;IACtC,MAAM;MAAEC,IAAF;MAAQC,CAAR;MAAWC,CAAX;MAAcC;IAAd,IAAuB,KAAKV,KAAlC;IACAK,MAAM,CAACM,QAAP,CAAgBJ,IAAhB,EAAsBC,CAAtB,EAAyBC,CAAzB,EAA4BH,KAA5B,EAAmCI,IAAnC;EACD;;AAZ2D;;;;AAevD,MAAME,YAAN,SAA2Bf,2BAA3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AApB,EAA0BrC,CAA1B,EAA6BC,CAA7B,EAAgCH,KAAhC;EACD;;AAZmE;;;;AAoB/D,MAAMwC,UAAN,SAAyBjD,2BAAzB,CAAsE;EAC3EC,WAAW,CAACC,GAAD,EAAmBC,KAAnB,EAAuC;IAChD,MAAMD,GAAN,EAAWE,eAAA,CAAS8C,MAApB,EAA4B/C,KAA5B;EACD;;EAEDG,WAAW,GAAG;IACZ,OAAO,KAAKH,KAAL,CAAWgD,MAAX,CAAkBC,MAAlB,CACL,CAACC,GAAD,EAAMC,KAAN,KAAgB;MACd,MAAM;QAAEC,EAAF;QAAMC;MAAN,IAAcF,KAApB;MACAD,GAAG,CAACF,MAAJ,CAAWX,IAAX,CAAgBe,EAAhB;MACAF,GAAG,CAACI,SAAJ,CAAcjB,IAAd,CAAmBgB,GAAnB;MACA,OAAOH,GAAP;IACD,CANI,EAOL;MAAEF,MAAM,EAAE,EAAV;MAAcM,SAAS,EAAE;IAAzB,CAPK,CAAP;EASD;;EAEDlD,IAAI,QAAoC;IAAA,IAAnC;MAAEC,MAAF;MAAUC;IAAV,CAAmC;;IACtC,IAAI,CAAC,KAAKmC,OAAV,EAAmB;MACjB,MAAM,IAAIC,KAAJ,CAAU,qCAAV,CAAN;IACD;;IACD,MAAM;MAAEM,MAAF;MAAUM;IAAV,IAAwB,KAAKb,OAAnC;IACA,MAAM;MAAEjC,CAAF;MAAKC,CAAL;MAAQC;IAAR,IAAiB,KAAKV,KAA5B;IACAK,MAAM,CAACkD,UAAP,CAAkBP,MAAlB,EAA0BM,SAA1B,EAAqC9C,CAArC,EAAwCC,CAAxC,EAA2CC,IAA3C,EAAiDJ,KAAjD;EACD;;AAxB0E"}
1
+ {"version":3,"names":["TextNode","JsiDrawingNode","constructor","ctx","props","NodeType","Text","deriveProps","draw","canvas","paint","text","x","y","font","drawText","TextPathNode","TextPath","path","processPath","Skia","initialOffset","ids","getGlyphIDs","widths","getGlyphWidths","rsx","meas","ContourMeasureIter","cont","next","dist","i","length","width","substring","p","t","getPosTan","adjustedX","adjustedY","push","RSXform","TextBlob","MakeFromRSXform","derived","Error","drawTextBlob","TextBlobNode","blob","GlyphsNode","Glyphs","glyphs","reduce","acc","glyph","id","pos","positions","drawGlyphs"],"sources":["Text.ts"],"sourcesContent":["import type { SkRSXform, SkTextBlob, SkPoint } from \"../../../skia/types\";\nimport type {\n DrawingContext,\n TextBlobProps,\n TextPathProps,\n TextProps,\n} from \"../../types\";\nimport { NodeType } from \"../../types\";\nimport { processPath } from \"../datatypes\";\nimport type { GlyphsProps } from \"../../types/Drawings\";\nimport { JsiDrawingNode } from \"../DrawingNode\";\nimport type { NodeContext } from \"../Node\";\n\nexport class TextNode extends JsiDrawingNode<TextProps, null> {\n constructor(ctx: NodeContext, props: TextProps) {\n super(ctx, NodeType.Text, props);\n }\n\n protected deriveProps() {\n return null;\n }\n\n draw({ canvas, paint }: DrawingContext) {\n const { text, x, y, font } = this.props;\n if (font) {\n canvas.drawText(text, x, y, paint, font);\n }\n }\n}\n\nexport class TextPathNode extends JsiDrawingNode<\n TextPathProps,\n SkTextBlob | null\n> {\n constructor(ctx: NodeContext, props: TextPathProps) {\n super(ctx, NodeType.TextPath, props);\n }\n\n deriveProps() {\n const path = processPath(this.Skia, this.props.path);\n const { font, initialOffset } = this.props;\n if (!font) {\n return null;\n }\n let { text } = this.props;\n const ids = font.getGlyphIDs(text);\n const widths = font.getGlyphWidths(ids);\n const rsx: SkRSXform[] = [];\n const meas = this.Skia.ContourMeasureIter(path, false, 1);\n let cont = meas.next();\n let dist = initialOffset;\n for (let i = 0; i < text.length && cont; i++) {\n const width = widths[i];\n dist += width / 2;\n if (dist > cont.length()) {\n // jump to next contour\n cont = meas.next();\n if (!cont) {\n // We have come to the end of the path - terminate the string\n // right here.\n text = text.substring(0, i);\n break;\n }\n dist = width / 2;\n }\n // Gives us the (x, y) coordinates as well as the cos/sin of the tangent\n // line at that position.\n const [p, t] = cont.getPosTan(dist);\n const adjustedX = p.x - (width / 2) * t.x;\n const adjustedY = p.y - (width / 2) * t.y;\n rsx.push(this.Skia.RSXform(t.x, t.y, adjustedX, adjustedY));\n dist += width / 2;\n }\n return this.Skia.TextBlob.MakeFromRSXform(text, rsx, font);\n }\n\n draw({ canvas, paint }: DrawingContext) {\n if (!this.derived) {\n throw new Error(\"TextPathNode: blob is null\");\n }\n canvas.drawTextBlob(this.derived, 0, 0, paint);\n }\n}\n\nexport class TextBlobNode extends JsiDrawingNode<TextBlobProps, null> {\n constructor(ctx: NodeContext, props: TextBlobProps) {\n super(ctx, NodeType.TextBlob, props);\n }\n\n protected deriveProps() {\n return null;\n }\n\n draw({ canvas, paint }: DrawingContext) {\n const { blob, x, y } = this.props;\n canvas.drawTextBlob(blob, x, y, paint);\n }\n}\n\ninterface ProcessedGlyphs {\n glyphs: number[];\n positions: SkPoint[];\n}\n\nexport class GlyphsNode extends JsiDrawingNode<GlyphsProps, ProcessedGlyphs> {\n constructor(ctx: NodeContext, props: GlyphsProps) {\n super(ctx, NodeType.Glyphs, props);\n }\n\n deriveProps() {\n return this.props.glyphs.reduce<ProcessedGlyphs>(\n (acc, glyph) => {\n const { id, pos } = glyph;\n acc.glyphs.push(id);\n acc.positions.push(pos);\n return acc;\n },\n { glyphs: [], positions: [] }\n );\n }\n\n draw({ canvas, paint }: DrawingContext) {\n if (!this.derived) {\n throw new Error(\"GlyphsNode: processedGlyphs is null\");\n }\n const { glyphs, positions } = this.derived;\n const { x, y, font } = this.props;\n if (font) {\n canvas.drawGlyphs(glyphs, positions, x, y, font, paint);\n }\n }\n}\n"],"mappings":";;;;;;;AAOA;;AACA;;AAEA;;AAGO,MAAMA,QAAN,SAAuBC,2BAAvB,CAAuD;EAC5DC,WAAW,CAACC,GAAD,EAAmBC,KAAnB,EAAqC;IAC9C,MAAMD,GAAN,EAAWE,eAAA,CAASC,IAApB,EAA0BF,KAA1B;EACD;;EAESG,WAAW,GAAG;IACtB,OAAO,IAAP;EACD;;EAEDC,IAAI,OAAoC;IAAA,IAA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AAQC;IAAR,IAAiB,KAAKV,KAA5B;;IACA,IAAIU,IAAJ,EAAU;MACRL,MAAM,CAACkD,UAAP,CAAkBP,MAAlB,EAA0BM,SAA1B,EAAqC9C,CAArC,EAAwCC,CAAxC,EAA2CC,IAA3C,EAAiDJ,KAAjD;IACD;EACF;;AA1B0E"}
@@ -59,6 +59,11 @@ class ImageShaderNode extends ShaderDeclaration {
59
59
  mm,
60
60
  ...imageShaderProps
61
61
  } = this.props;
62
+
63
+ if (!image) {
64
+ return;
65
+ }
66
+
62
67
  const rct = (0, _datatypes.getRect)(this.Skia, imageShaderProps);
63
68
  const m3 = this.Skia.Matrix();
64
69
 
@@ -1 +1 @@
1
- {"version":3,"names":["ShaderDeclaration","JsiDeclarationNode","constructor","ctx","type","props","DeclarationType","Shader","ShaderNode","NodeType","decorate","decorateChildren","source","uniforms","transform","m3","Skia","Matrix","processTransformProps","shader","makeShaderWithChildren","processUniforms","shaders","popAll","push","ImageShaderNode","ImageShader","fit","image","tx","ty","fm","mm","imageShaderProps","rct","getRect","rects","fitRects","x","y","width","height","sx","sy","rect2rect","src","dst","translate","translateX","translateY","scale","scaleX","scaleY","lm","concat","makeShaderOptions","TileMode","enumKey","FilterMode","MipmapMode","ColorNode","ColorShader","color","MakeColor","Color","TurbulenceNode","Turbulence","freqX","freqY","octaves","seed","tileWidth","tileHeight","MakeTurbulence","FractalNoiseNode","FractalNoise","MakeFractalNoise","LinearGradientNode","LinearGradient","start","end","colors","positions","mode","localMatrix","flags","processGradientProps","MakeLinearGradient","RadialGradientNode","RadialGradient","c","r","MakeRadialGradient","SweepGradientNode","SweepGradient","MakeSweepGradient","TwoPointConicalGradientNode","TwoPointConicalGradient","startR","endR","MakeTwoPointConicalGradient"],"sources":["Shaders.ts"],"sourcesContent":["import {\n processUniforms,\n FilterMode,\n MipmapMode,\n TileMode,\n} from \"../../../skia/types\";\nimport type { NodeContext } from \"../Node\";\nimport { JsiDeclarationNode } from \"../Node\";\nimport type {\n ColorProps,\n DeclarationContext,\n FractalNoiseProps,\n ImageShaderProps,\n LinearGradientProps,\n RadialGradientProps,\n ShaderProps,\n SweepGradientProps,\n TurbulenceProps,\n TwoPointConicalGradientProps,\n} from \"../../types\";\nimport { DeclarationType, NodeType } from \"../../types\";\nimport {\n enumKey,\n fitRects,\n getRect,\n processGradientProps,\n processTransformProps,\n rect2rect,\n} from \"../datatypes\";\n\nexport abstract class ShaderDeclaration<P> extends JsiDeclarationNode<P> {\n constructor(ctx: NodeContext, type: NodeType, props: P) {\n super(ctx, DeclarationType.Shader, type, props);\n }\n}\n\nexport class ShaderNode extends ShaderDeclaration<ShaderProps> {\n constructor(ctx: NodeContext, props: ShaderProps) {\n super(ctx, NodeType.Shader, props);\n }\n\n decorate(ctx: DeclarationContext) {\n this.decorateChildren(ctx);\n const { source, uniforms, ...transform } = this.props;\n const m3 = this.Skia.Matrix();\n processTransformProps(m3, transform);\n const shader = source.makeShaderWithChildren(\n processUniforms(source, uniforms),\n ctx.shaders.popAll(),\n m3\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class ImageShaderNode extends ShaderDeclaration<ImageShaderProps> {\n constructor(ctx: NodeContext, props: ImageShaderProps) {\n super(ctx, NodeType.ImageShader, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { fit, image, tx, ty, fm, mm, ...imageShaderProps } = this.props;\n const rct = getRect(this.Skia, imageShaderProps);\n const m3 = this.Skia.Matrix();\n if (rct) {\n const rects = fitRects(\n fit,\n { x: 0, y: 0, width: image.width(), height: image.height() },\n rct\n );\n const [x, y, sx, sy] = rect2rect(rects.src, rects.dst);\n m3.translate(x.translateX, y.translateY);\n m3.scale(sx.scaleX, sy.scaleY);\n }\n const lm = this.Skia.Matrix();\n lm.concat(m3);\n processTransformProps(lm, imageShaderProps);\n const shader = image.makeShaderOptions(\n TileMode[enumKey(tx)],\n TileMode[enumKey(ty)],\n FilterMode[enumKey(fm)],\n MipmapMode[enumKey(mm)],\n lm\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class ColorNode extends ShaderDeclaration<ColorProps> {\n constructor(ctx: NodeContext, props: ColorProps) {\n super(ctx, NodeType.ColorShader, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { color } = this.props;\n const shader = this.Skia.Shader.MakeColor(this.Skia.Color(color));\n ctx.shaders.push(shader);\n }\n}\n\nexport class TurbulenceNode extends ShaderDeclaration<TurbulenceProps> {\n constructor(ctx: NodeContext, props: TurbulenceProps) {\n super(ctx, NodeType.Turbulence, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { freqX, freqY, octaves, seed, tileWidth, tileHeight } = this.props;\n const shader = this.Skia.Shader.MakeTurbulence(\n freqX,\n freqY,\n octaves,\n seed,\n tileWidth,\n tileHeight\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class FractalNoiseNode extends ShaderDeclaration<FractalNoiseProps> {\n constructor(ctx: NodeContext, props: FractalNoiseProps) {\n super(ctx, NodeType.FractalNoise, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { freqX, freqY, octaves, seed, tileWidth, tileHeight } = this.props;\n const shader = this.Skia.Shader.MakeFractalNoise(\n freqX,\n freqY,\n octaves,\n seed,\n tileWidth,\n tileHeight\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class LinearGradientNode extends ShaderDeclaration<LinearGradientProps> {\n constructor(ctx: NodeContext, props: LinearGradientProps) {\n super(ctx, NodeType.LinearGradient, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { start, end } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n const shader = this.Skia.Shader.MakeLinearGradient(\n start,\n end,\n colors,\n positions ?? null,\n mode,\n localMatrix,\n flags\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class RadialGradientNode extends ShaderDeclaration<RadialGradientProps> {\n constructor(ctx: NodeContext, props: RadialGradientProps) {\n super(ctx, NodeType.RadialGradient, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { c, r } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n const shader = this.Skia.Shader.MakeRadialGradient(\n c,\n r,\n colors,\n positions,\n mode,\n localMatrix,\n flags\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class SweepGradientNode extends ShaderDeclaration<SweepGradientProps> {\n constructor(ctx: NodeContext, props: SweepGradientProps) {\n super(ctx, NodeType.SweepGradient, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { c, start, end } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n const shader = this.Skia.Shader.MakeSweepGradient(\n c.x,\n c.y,\n colors,\n positions,\n mode,\n localMatrix,\n flags,\n start,\n end\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class TwoPointConicalGradientNode extends ShaderDeclaration<TwoPointConicalGradientProps> {\n constructor(ctx: NodeContext, props: TwoPointConicalGradientProps) {\n super(ctx, NodeType.TwoPointConicalGradient, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { startR, endR, start, end } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n const shader = this.Skia.Shader.MakeTwoPointConicalGradient(\n start,\n startR,\n end,\n endR,\n colors,\n positions,\n mode,\n localMatrix,\n flags\n );\n ctx.shaders.push(shader);\n }\n}\n"],"mappings":";;;;;;;AAAA;;AAOA;;AAaA;;AACA;;AASO,MAAeA,iBAAf,SAA4CC,wBAA5C,CAAkE;EACvEC,WAAW,CAACC,GAAD,EAAmBC,IAAnB,EAAmCC,KAAnC,EAA6C;IACtD,MAAMF,GAAN,EAAWG,uBAAA,CAAgBC,MAA3B,EAAmCH,IAAnC,EAAyCC,KAAzC;EACD;;AAHsE;;;;AAMlE,MAAMG,UAAN,SAAyBR,iBAAzB,CAAwD;EAC7DE,WAAW,CAACC,GAAD,EAAmBE,KAAnB,EAAuC;IAChD,MAAMF,GAAN,EAAWM,gBAAA,CAASF,MAApB,EAA4BF,KAA5B;EACD;;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G,KAAKH,IAAL,CAAUT,MAAV,CAAiB6F,2BAAjB,CACbrB,KADa,EAEbmB,MAFa,EAGblB,GAHa,EAIbmB,IAJa,EAKblB,MALa,EAMbC,SANa,EAObC,IAPa,EAQbC,WARa,EASbC,KATa,CAAf;IAWAlF,GAAG,CAACmB,OAAJ,CAAYE,IAAZ,CAAiBL,MAAjB;EACD;;AArB8F"}
1
+ {"version":3,"names":["ShaderDeclaration","JsiDeclarationNode","constructor","ctx","type","props","DeclarationType","Shader","ShaderNode","NodeType","decorate","decorateChildren","source","uniforms","transform","m3","Skia","Matrix","processTransformProps","shader","makeShaderWithChildren","processUniforms","shaders","popAll","push","ImageShaderNode","ImageShader","fit","image","tx","ty","fm","mm","imageShaderProps","rct","getRect","rects","fitRects","x","y","width","height","sx","sy","rect2rect","src","dst","translate","translateX","translateY","scale","scaleX","scaleY","lm","concat","makeShaderOptions","TileMode","enumKey","FilterMode","MipmapMode","ColorNode","ColorShader","color","MakeColor","Color","TurbulenceNode","Turbulence","freqX","freqY","octaves","seed","tileWidth","tileHeight","MakeTurbulence","FractalNoiseNode","FractalNoise","MakeFractalNoise","LinearGradientNode","LinearGradient","start","end","colors","positions","mode","localMatrix","flags","processGradientProps","MakeLinearGradient","RadialGradientNode","RadialGradient","c","r","MakeRadialGradient","SweepGradientNode","SweepGradient","MakeSweepGradient","TwoPointConicalGradientNode","TwoPointConicalGradient","startR","endR","MakeTwoPointConicalGradient"],"sources":["Shaders.ts"],"sourcesContent":["import {\n processUniforms,\n FilterMode,\n MipmapMode,\n TileMode,\n} from \"../../../skia/types\";\nimport type { NodeContext } from \"../Node\";\nimport { JsiDeclarationNode } from \"../Node\";\nimport type {\n ColorProps,\n DeclarationContext,\n FractalNoiseProps,\n ImageShaderProps,\n LinearGradientProps,\n RadialGradientProps,\n ShaderProps,\n SweepGradientProps,\n TurbulenceProps,\n TwoPointConicalGradientProps,\n} from \"../../types\";\nimport { DeclarationType, NodeType } from \"../../types\";\nimport {\n enumKey,\n fitRects,\n getRect,\n processGradientProps,\n processTransformProps,\n rect2rect,\n} from \"../datatypes\";\n\nexport abstract class ShaderDeclaration<P> extends JsiDeclarationNode<P> {\n constructor(ctx: NodeContext, type: NodeType, props: P) {\n super(ctx, DeclarationType.Shader, type, props);\n }\n}\n\nexport class ShaderNode extends ShaderDeclaration<ShaderProps> {\n constructor(ctx: NodeContext, props: ShaderProps) {\n super(ctx, NodeType.Shader, props);\n }\n\n decorate(ctx: DeclarationContext) {\n this.decorateChildren(ctx);\n const { source, uniforms, ...transform } = this.props;\n const m3 = this.Skia.Matrix();\n processTransformProps(m3, transform);\n const shader = source.makeShaderWithChildren(\n processUniforms(source, uniforms),\n ctx.shaders.popAll(),\n m3\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class ImageShaderNode extends ShaderDeclaration<ImageShaderProps> {\n constructor(ctx: NodeContext, props: ImageShaderProps) {\n super(ctx, NodeType.ImageShader, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { fit, image, tx, ty, fm, mm, ...imageShaderProps } = this.props;\n if (!image) {\n return;\n }\n\n const rct = getRect(this.Skia, imageShaderProps);\n const m3 = this.Skia.Matrix();\n if (rct) {\n const rects = fitRects(\n fit,\n { x: 0, y: 0, width: image.width(), height: image.height() },\n rct\n );\n const [x, y, sx, sy] = rect2rect(rects.src, rects.dst);\n m3.translate(x.translateX, y.translateY);\n m3.scale(sx.scaleX, sy.scaleY);\n }\n const lm = this.Skia.Matrix();\n lm.concat(m3);\n processTransformProps(lm, imageShaderProps);\n const shader = image.makeShaderOptions(\n TileMode[enumKey(tx)],\n TileMode[enumKey(ty)],\n FilterMode[enumKey(fm)],\n MipmapMode[enumKey(mm)],\n lm\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class ColorNode extends ShaderDeclaration<ColorProps> {\n constructor(ctx: NodeContext, props: ColorProps) {\n super(ctx, NodeType.ColorShader, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { color } = this.props;\n const shader = this.Skia.Shader.MakeColor(this.Skia.Color(color));\n ctx.shaders.push(shader);\n }\n}\n\nexport class TurbulenceNode extends ShaderDeclaration<TurbulenceProps> {\n constructor(ctx: NodeContext, props: TurbulenceProps) {\n super(ctx, NodeType.Turbulence, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { freqX, freqY, octaves, seed, tileWidth, tileHeight } = this.props;\n const shader = this.Skia.Shader.MakeTurbulence(\n freqX,\n freqY,\n octaves,\n seed,\n tileWidth,\n tileHeight\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class FractalNoiseNode extends ShaderDeclaration<FractalNoiseProps> {\n constructor(ctx: NodeContext, props: FractalNoiseProps) {\n super(ctx, NodeType.FractalNoise, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { freqX, freqY, octaves, seed, tileWidth, tileHeight } = this.props;\n const shader = this.Skia.Shader.MakeFractalNoise(\n freqX,\n freqY,\n octaves,\n seed,\n tileWidth,\n tileHeight\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class LinearGradientNode extends ShaderDeclaration<LinearGradientProps> {\n constructor(ctx: NodeContext, props: LinearGradientProps) {\n super(ctx, NodeType.LinearGradient, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { start, end } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n const shader = this.Skia.Shader.MakeLinearGradient(\n start,\n end,\n colors,\n positions ?? null,\n mode,\n localMatrix,\n flags\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class RadialGradientNode extends ShaderDeclaration<RadialGradientProps> {\n constructor(ctx: NodeContext, props: RadialGradientProps) {\n super(ctx, NodeType.RadialGradient, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { c, r } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n const shader = this.Skia.Shader.MakeRadialGradient(\n c,\n r,\n colors,\n positions,\n mode,\n localMatrix,\n flags\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class SweepGradientNode extends ShaderDeclaration<SweepGradientProps> {\n constructor(ctx: NodeContext, props: SweepGradientProps) {\n super(ctx, NodeType.SweepGradient, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { c, start, end } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n const shader = this.Skia.Shader.MakeSweepGradient(\n c.x,\n c.y,\n colors,\n positions,\n mode,\n localMatrix,\n flags,\n start,\n end\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class TwoPointConicalGradientNode extends ShaderDeclaration<TwoPointConicalGradientProps> {\n constructor(ctx: NodeContext, props: TwoPointConicalGradientProps) {\n super(ctx, NodeType.TwoPointConicalGradient, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { startR, endR, start, end } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n const shader = this.Skia.Shader.MakeTwoPointConicalGradient(\n start,\n startR,\n end,\n endR,\n colors,\n positions,\n mode,\n localMatrix,\n flags\n );\n ctx.shaders.push(shader);\n }\n}\n"],"mappings":";;;;;;;AAAA;;AAOA;;AAaA;;AACA;;AASO,MAAeA,iBAAf,SAA4CC,wBAA5C,CAAkE;EACvEC,WAAW,CAACC,GAAD,EAAmBC,IAAnB,EAAmCC,KAAnC,EAA6C;IACtD,MAAMF,GAAN,EAAWG,uBAAA,CAAgBC,MAA3B,EAAmCH,IAAnC,EAAyCC,KAAzC;EACD;;AAHsE;;;;AAMlE,MAAMG,UAAN,SAAyBR,iBAAzB,CAAwD;EAC7DE,WAAW,CAACC,GAAD,EAAmBE,KAAnB,EAAuC;IAChD,MAAMF,GAAN,EAAWM,gBAAA,CAASF,MAApB,EAA4BF,KAA5B;EACD;;EAEDK,QAAQ,CAACP,GAAD,EAA0B;IAChC,KAAKQ,gBAAL,CAAsBR,GAAtB;IACA,MAAM;MAAES,MAAF;MAAUC,QAAV;MAAoB,GAAGC;IAAvB,IAAqC,KAAKT,KAAhD;IACA,MAAMU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SANa,EAObC,IAPa,EAQbC,WARa,EASbC,KATa,CAAf;IAWAlF,GAAG,CAACmB,OAAJ,CAAYE,IAAZ,CAAiBL,MAAjB;EACD;;AArB8F"}
@@ -6,7 +6,7 @@ export interface DrawingNodeProps extends GroupProps {
6
6
  }
7
7
  export declare type ImageProps = DrawingNodeProps & RectDef & {
8
8
  fit?: Fit;
9
- image: SkImage;
9
+ image: SkImage | null;
10
10
  };
11
11
  export declare type CircleProps = CircleDef & DrawingNodeProps;
12
12
  export interface PathProps extends DrawingNodeProps {
@@ -51,7 +51,7 @@ export interface VerticesProps extends DrawingNodeProps {
51
51
  indices?: number[];
52
52
  }
53
53
  export declare type ImageSVGProps = RectDef & {
54
- svg: SkSVG;
54
+ svg: SkSVG | null;
55
55
  } & DrawingNodeProps;
56
56
  export interface PictureProps extends DrawingNodeProps {
57
57
  picture: SkPicture;
@@ -65,13 +65,13 @@ export interface DiffRectProps extends DrawingNodeProps {
65
65
  outer: SkRRect;
66
66
  }
67
67
  export interface TextProps extends DrawingNodeProps {
68
- font: SkFont;
68
+ font: SkFont | null;
69
69
  text: string;
70
70
  x: number;
71
71
  y: number;
72
72
  }
73
73
  export interface TextPathProps extends DrawingNodeProps {
74
- font: SkFont;
74
+ font: SkFont | null;
75
75
  text: string;
76
76
  path: PathDef;
77
77
  initialOffset: number;
@@ -86,7 +86,7 @@ export interface Glyph {
86
86
  pos: SkPoint;
87
87
  }
88
88
  export interface GlyphsProps extends DrawingNodeProps {
89
- font: SkFont;
89
+ font: SkFont | null;
90
90
  x: number;
91
91
  y: number;
92
92
  glyphs: Glyph[];
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["Drawings.ts"],"sourcesContent":["import type {\n FillType,\n SkImage,\n StrokeOpts,\n Vector,\n Color,\n SkPoint,\n BlendMode,\n PointMode,\n VertexMode,\n SkFont,\n SkRRect,\n SkTextBlob,\n SkPicture,\n SkSVG,\n SkPaint,\n SkRect,\n} from \"../../skia/types\";\n\nimport type {\n CircleDef,\n Fit,\n GroupProps,\n PathDef,\n RectDef,\n RRectDef,\n SkEnum,\n} from \"./Common\";\nimport type { DrawingContext } from \"./DrawingContext\";\n\nexport interface DrawingNodeProps extends GroupProps {\n paint?: SkPaint;\n}\n\nexport type ImageProps = DrawingNodeProps &\n RectDef & {\n fit?: Fit;\n image: SkImage;\n };\n\nexport type CircleProps = CircleDef & DrawingNodeProps;\n\nexport interface PathProps extends DrawingNodeProps {\n path: PathDef;\n start: number;\n end: number;\n stroke?: StrokeOpts;\n fillType?: SkEnum<typeof FillType>;\n}\n\nexport interface CustomDrawingNodeProps extends DrawingNodeProps {\n drawing: (ctx: DrawingContext) => void;\n}\n\nexport interface LineProps extends DrawingNodeProps {\n p1: Vector;\n p2: Vector;\n}\n\nexport type OvalProps = RectDef & DrawingNodeProps;\n\nexport type RectProps = RectDef & DrawingNodeProps;\n\nexport type RoundedRectProps = RRectDef & DrawingNodeProps;\n\nexport interface CubicBezierHandle {\n pos: Vector;\n c1: Vector;\n c2: Vector;\n}\n\nexport interface PatchProps extends DrawingNodeProps {\n colors?: Color[];\n patch: [\n CubicBezierHandle,\n CubicBezierHandle,\n CubicBezierHandle,\n CubicBezierHandle\n ];\n texture?: readonly [SkPoint, SkPoint, SkPoint, SkPoint];\n blendMode?: SkEnum<typeof BlendMode>;\n}\n\nexport interface VerticesProps extends DrawingNodeProps {\n colors?: string[];\n vertices: SkPoint[];\n textures?: SkPoint[];\n mode: SkEnum<typeof VertexMode>;\n blendMode?: SkEnum<typeof BlendMode>;\n indices?: number[];\n}\n\nexport type ImageSVGProps = RectDef & {\n svg: SkSVG;\n} & DrawingNodeProps;\n\nexport interface PictureProps extends DrawingNodeProps {\n picture: SkPicture;\n}\n\nexport interface PointsProps extends DrawingNodeProps {\n points: SkPoint[];\n mode: SkEnum<typeof PointMode>;\n}\n\nexport interface DiffRectProps extends DrawingNodeProps {\n inner: SkRRect;\n outer: SkRRect;\n}\n\nexport interface TextProps extends DrawingNodeProps {\n font: SkFont;\n text: string;\n x: number;\n y: number;\n}\n\nexport interface TextPathProps extends DrawingNodeProps {\n font: SkFont;\n text: string;\n path: PathDef;\n initialOffset: number;\n}\n\nexport interface TextBlobProps extends DrawingNodeProps {\n blob: SkTextBlob;\n x: number;\n y: number;\n}\n\nexport interface Glyph {\n id: number;\n pos: SkPoint;\n}\n\nexport interface GlyphsProps extends DrawingNodeProps {\n font: SkFont;\n x: number;\n y: number;\n glyphs: Glyph[];\n}\n\nexport interface BoxProps extends DrawingNodeProps {\n box: SkRRect | SkRect;\n}\n\nexport interface BoxShadowProps {\n dx?: number;\n dy?: number;\n spread?: number;\n blur: number;\n color?: Color;\n inner?: boolean;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["Drawings.ts"],"sourcesContent":["import type {\n FillType,\n SkImage,\n StrokeOpts,\n Vector,\n Color,\n SkPoint,\n BlendMode,\n PointMode,\n VertexMode,\n SkFont,\n SkRRect,\n SkTextBlob,\n SkPicture,\n SkSVG,\n SkPaint,\n SkRect,\n} from \"../../skia/types\";\n\nimport type {\n CircleDef,\n Fit,\n GroupProps,\n PathDef,\n RectDef,\n RRectDef,\n SkEnum,\n} from \"./Common\";\nimport type { DrawingContext } from \"./DrawingContext\";\n\nexport interface DrawingNodeProps extends GroupProps {\n paint?: SkPaint;\n}\n\nexport type ImageProps = DrawingNodeProps &\n RectDef & {\n fit?: Fit;\n image: SkImage | null;\n };\n\nexport type CircleProps = CircleDef & DrawingNodeProps;\n\nexport interface PathProps extends DrawingNodeProps {\n path: PathDef;\n start: number;\n end: number;\n stroke?: StrokeOpts;\n fillType?: SkEnum<typeof FillType>;\n}\n\nexport interface CustomDrawingNodeProps extends DrawingNodeProps {\n drawing: (ctx: DrawingContext) => void;\n}\n\nexport interface LineProps extends DrawingNodeProps {\n p1: Vector;\n p2: Vector;\n}\n\nexport type OvalProps = RectDef & DrawingNodeProps;\n\nexport type RectProps = RectDef & DrawingNodeProps;\n\nexport type RoundedRectProps = RRectDef & DrawingNodeProps;\n\nexport interface CubicBezierHandle {\n pos: Vector;\n c1: Vector;\n c2: Vector;\n}\n\nexport interface PatchProps extends DrawingNodeProps {\n colors?: Color[];\n patch: [\n CubicBezierHandle,\n CubicBezierHandle,\n CubicBezierHandle,\n CubicBezierHandle\n ];\n texture?: readonly [SkPoint, SkPoint, SkPoint, SkPoint];\n blendMode?: SkEnum<typeof BlendMode>;\n}\n\nexport interface VerticesProps extends DrawingNodeProps {\n colors?: string[];\n vertices: SkPoint[];\n textures?: SkPoint[];\n mode: SkEnum<typeof VertexMode>;\n blendMode?: SkEnum<typeof BlendMode>;\n indices?: number[];\n}\n\nexport type ImageSVGProps = RectDef & {\n svg: SkSVG | null;\n} & DrawingNodeProps;\n\nexport interface PictureProps extends DrawingNodeProps {\n picture: SkPicture;\n}\n\nexport interface PointsProps extends DrawingNodeProps {\n points: SkPoint[];\n mode: SkEnum<typeof PointMode>;\n}\n\nexport interface DiffRectProps extends DrawingNodeProps {\n inner: SkRRect;\n outer: SkRRect;\n}\n\nexport interface TextProps extends DrawingNodeProps {\n font: SkFont | null;\n text: string;\n x: number;\n y: number;\n}\n\nexport interface TextPathProps extends DrawingNodeProps {\n font: SkFont | null;\n text: string;\n path: PathDef;\n initialOffset: number;\n}\n\nexport interface TextBlobProps extends DrawingNodeProps {\n blob: SkTextBlob;\n x: number;\n y: number;\n}\n\nexport interface Glyph {\n id: number;\n pos: SkPoint;\n}\n\nexport interface GlyphsProps extends DrawingNodeProps {\n font: SkFont | null;\n x: number;\n y: number;\n glyphs: Glyph[];\n}\n\nexport interface BoxProps extends DrawingNodeProps {\n box: SkRRect | SkRect;\n}\n\nexport interface BoxShadowProps {\n dx?: number;\n dy?: number;\n spread?: number;\n blur: number;\n color?: Color;\n inner?: boolean;\n}\n"],"mappings":""}
@@ -11,7 +11,7 @@ export interface ImageShaderProps extends TransformProps, Partial<RectCtor> {
11
11
  mm: SkEnum<typeof MipmapMode>;
12
12
  fit: Fit;
13
13
  rect?: SkRect;
14
- image: SkImage;
14
+ image: SkImage | null;
15
15
  }
16
16
  export interface ColorProps {
17
17
  color: Color;
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["Shaders.ts"],"sourcesContent":["import type {\n Color,\n FilterMode,\n MipmapMode,\n SkImage,\n SkRect,\n SkRuntimeEffect,\n TileMode,\n Uniforms,\n Vector,\n} from \"../../skia/types\";\n\nimport type {\n SkEnum,\n TransformProps,\n ChildrenProps,\n RectCtor,\n Fit,\n} from \"./Common\";\n\nexport interface ShaderProps extends TransformProps, ChildrenProps {\n source: SkRuntimeEffect;\n uniforms: Uniforms;\n}\n\nexport interface ImageShaderProps extends TransformProps, Partial<RectCtor> {\n tx: SkEnum<typeof TileMode>;\n ty: SkEnum<typeof TileMode>;\n fm: SkEnum<typeof FilterMode>;\n mm: SkEnum<typeof MipmapMode>;\n fit: Fit;\n rect?: SkRect;\n image: SkImage;\n}\n\nexport interface ColorProps {\n color: Color;\n}\n\nexport interface TurbulenceProps {\n freqX: number;\n freqY: number;\n octaves: number;\n seed: number;\n tileWidth: number;\n tileHeight: number;\n}\n\nexport interface FractalNoiseProps {\n freqX: number;\n freqY: number;\n octaves: number;\n seed: number;\n tileWidth: number;\n tileHeight: number;\n}\n\nexport interface GradientProps extends TransformProps {\n colors: Color[];\n positions?: number[];\n mode?: SkEnum<typeof TileMode>;\n flags?: number;\n}\n\nexport interface LinearGradientProps extends GradientProps {\n start: Vector;\n end: Vector;\n}\n\nexport interface RadialGradientProps extends GradientProps {\n c: Vector;\n r: number;\n}\n\nexport interface SweepGradientProps extends GradientProps {\n c: Vector;\n start?: number;\n end?: number;\n}\n\nexport interface TwoPointConicalGradientProps extends GradientProps {\n start: Vector;\n startR: number;\n end: Vector;\n endR: number;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["Shaders.ts"],"sourcesContent":["import type {\n Color,\n FilterMode,\n MipmapMode,\n SkImage,\n SkRect,\n SkRuntimeEffect,\n TileMode,\n Uniforms,\n Vector,\n} from \"../../skia/types\";\n\nimport type {\n SkEnum,\n TransformProps,\n ChildrenProps,\n RectCtor,\n Fit,\n} from \"./Common\";\n\nexport interface ShaderProps extends TransformProps, ChildrenProps {\n source: SkRuntimeEffect;\n uniforms: Uniforms;\n}\n\nexport interface ImageShaderProps extends TransformProps, Partial<RectCtor> {\n tx: SkEnum<typeof TileMode>;\n ty: SkEnum<typeof TileMode>;\n fm: SkEnum<typeof FilterMode>;\n mm: SkEnum<typeof MipmapMode>;\n fit: Fit;\n rect?: SkRect;\n image: SkImage | null;\n}\n\nexport interface ColorProps {\n color: Color;\n}\n\nexport interface TurbulenceProps {\n freqX: number;\n freqY: number;\n octaves: number;\n seed: number;\n tileWidth: number;\n tileHeight: number;\n}\n\nexport interface FractalNoiseProps {\n freqX: number;\n freqY: number;\n octaves: number;\n seed: number;\n tileWidth: number;\n tileHeight: number;\n}\n\nexport interface GradientProps extends TransformProps {\n colors: Color[];\n positions?: number[];\n mode?: SkEnum<typeof TileMode>;\n flags?: number;\n}\n\nexport interface LinearGradientProps extends GradientProps {\n start: Vector;\n end: Vector;\n}\n\nexport interface RadialGradientProps extends GradientProps {\n c: Vector;\n r: number;\n}\n\nexport interface SweepGradientProps extends GradientProps {\n c: Vector;\n start?: number;\n end?: number;\n}\n\nexport interface TwoPointConicalGradientProps extends GradientProps {\n start: Vector;\n startR: number;\n end: Vector;\n endR: number;\n}\n"],"mappings":""}
@@ -118,7 +118,8 @@ const Mock = {
118
118
  mixColors: (_v, _x, _y) => Float32Array.of(0, 0, 0, 0),
119
119
  ShaderLib: _ShaderLib.ShaderLib,
120
120
  createDrawing: Noop,
121
- createDeclaration: Noop
121
+ createDeclaration: Noop,
122
+ makeImageFromView: Noop
122
123
  };
123
124
  exports.Mock = Mock;
124
125
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Stub","constructor","Proxy","get","apply","set","Noop","Skia","vec","x","y","Mock","BaseSkia","useRawData","useData","useFont","useTypeface","useImage","useSVG","createPicture","rect","width","height","rrect","r","rx","ry","point","add","a","b","sub","neg","dist","Math","hypot","translate","translateX","translateY","bounds","topLeft","topRight","bottomLeft","bottomRight","center","processTransform2d","Values","ValuesHooks","Selector","timingFunctions","springFunctions","decayFunctions","interpolateFn","interpolatePathFn","interpolateVectorFn","interpolateColors","_value","_inputRange","_outputRange","Float32Array","of","mixColors","_v","_x","_y","ShaderLib","createDrawing","createDeclaration"],"sources":["index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { Color, Skia as SkiaApi, SkRect, Vector } from \"../skia/types\";\nimport * as Values from \"../values/web\";\nimport * as ValuesHooks from \"../values/hooks\";\nimport { Selector } from \"../values/selector\";\nimport * as BaseSkia from \"../skia/types\";\nimport type * as SkiaExports from \"../skia\";\nimport type * as ValueExports from \"../values\";\nimport type * as AnimationExports from \"../animation\";\nimport * as timingFunctions from \"../animation/timing\";\nimport * as springFunctions from \"../animation/spring\";\nimport * as decayFunctions from \"../animation/decay\";\nimport * as interpolateFn from \"../animation/functions/interpolate\";\nimport * as interpolatePathFn from \"../animation/functions/interpolatePaths\";\nimport * as interpolateVectorFn from \"../animation/functions/interpolateVector\";\nimport { ShaderLib } from \"../renderer/components/shaders/ShaderLib\";\n\nclass Stub {\n constructor() {\n return new Proxy(() => {}, {\n get: () => new Stub(),\n apply: () => new Stub(),\n set: () => true,\n });\n }\n}\n\nconst Noop: () => any = () => {};\n\nexport const Skia: SkiaApi = new Stub() as any;\n\nexport const vec = (x?: number, y?: number) => ({ x: x ?? 0, y: y ?? x ?? 0 });\n\nexport const Mock: typeof SkiaExports &\n typeof ValueExports &\n typeof AnimationExports & {\n createDrawing: () => any;\n createDeclaration: () => any;\n ShaderLib: typeof ShaderLib;\n } = {\n // SkiaExports\n // 1. Skia API. BaseSkia contains the enums, and functions like isPaint etc\n Skia,\n ...BaseSkia,\n // 2. Hooks\n useRawData: Noop,\n useData: Noop,\n useFont: Noop,\n useTypeface: Noop,\n useImage: Noop,\n useSVG: Noop,\n createPicture: Noop,\n // 3. Point/Rect/Transform utilities\n vec,\n rect: (x: number, y: number, width: number, height: number) => ({\n x,\n y,\n width,\n height,\n }),\n rrect: (r: SkRect, rx: number, ry: number) => ({\n rect: r,\n rx,\n ry,\n }),\n point: vec,\n add: (a: Vector, b: Vector) => vec(a.x + b.x, a.y + b.y),\n sub: (a: Vector, b: Vector) => vec(a.x - b.x, a.y - b.y),\n neg: (a: Vector) => vec(-a.x, -a.y),\n dist: (a: Vector, b: Vector) => Math.hypot(a.x - b.x, a.y - b.y),\n translate: ({ x, y }: Vector) =>\n [{ translateX: x }, { translateY: y }] as const,\n\n bounds: Noop,\n topLeft: Noop,\n topRight: Noop,\n bottomLeft: Noop,\n bottomRight: Noop,\n center: Noop,\n processTransform2d: Noop,\n // ValueExports\n ...Values,\n ...ValuesHooks,\n Selector,\n // Animations\n ...timingFunctions,\n ...springFunctions,\n ...decayFunctions,\n ...interpolateFn,\n ...interpolatePathFn,\n ...interpolateVectorFn,\n interpolateColors: (\n _value: number,\n _inputRange: number[],\n _outputRange: Color[]\n ) => Float32Array.of(0, 0, 0, 0),\n mixColors: (_v: number, _x: Color, _y: Color) => Float32Array.of(0, 0, 0, 0),\n ShaderLib,\n createDrawing: Noop,\n createDeclaration: Noop,\n};\n"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAhBA;AAkBA,MAAMA,IAAN,CAAW;EACTC,WAAW,GAAG;IACZ,OAAO,IAAIC,KAAJ,CAAU,MAAM,CAAE,CAAlB,EAAoB;MACzBC,GAAG,EAAE,MAAM,IAAIH,IAAJ,EADc;MAEzBI,KAAK,EAAE,MAAM,IAAIJ,IAAJ,EAFY;MAGzBK,GAAG,EAAE,MAAM;IAHc,CAApB,CAAP;EAKD;;AAPQ;;AAUX,MAAMC,IAAe,GAAG,MAAM,CAAE,CAAhC;;AAEO,MAAMC,IAAa,GAAG,I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D,IA3DX;EA4DJ6D,iBAAiB,EAAE7D;AA5Df,CANC"}
1
+ {"version":3,"names":["Stub","constructor","Proxy","get","apply","set","Noop","Skia","vec","x","y","Mock","BaseSkia","useRawData","useData","useFont","useTypeface","useImage","useSVG","createPicture","rect","width","height","rrect","r","rx","ry","point","add","a","b","sub","neg","dist","Math","hypot","translate","translateX","translateY","bounds","topLeft","topRight","bottomLeft","bottomRight","center","processTransform2d","Values","ValuesHooks","Selector","timingFunctions","springFunctions","decayFunctions","interpolateFn","interpolatePathFn","interpolateVectorFn","interpolateColors","_value","_inputRange","_outputRange","Float32Array","of","mixColors","_v","_x","_y","ShaderLib","createDrawing","createDeclaration","makeImageFromView"],"sources":["index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { Color, Skia as SkiaApi, SkRect, Vector } from \"../skia/types\";\nimport * as Values from \"../values/web\";\nimport * as ValuesHooks from \"../values/hooks\";\nimport { Selector } from \"../values/selector\";\nimport * as BaseSkia from \"../skia/types\";\nimport type * as SkiaExports from \"../skia\";\nimport type * as ValueExports from \"../values\";\nimport type * as AnimationExports from \"../animation\";\nimport * as timingFunctions from \"../animation/timing\";\nimport * as springFunctions from \"../animation/spring\";\nimport * as decayFunctions from \"../animation/decay\";\nimport * as interpolateFn from \"../animation/functions/interpolate\";\nimport * as interpolatePathFn from \"../animation/functions/interpolatePaths\";\nimport * as interpolateVectorFn from \"../animation/functions/interpolateVector\";\nimport { ShaderLib } from \"../renderer/components/shaders/ShaderLib\";\n\nclass Stub {\n constructor() {\n return new Proxy(() => {}, {\n get: () => new Stub(),\n apply: () => new Stub(),\n set: () => true,\n });\n }\n}\n\nconst Noop: () => any = () => {};\n\nexport const Skia: SkiaApi = new Stub() as any;\n\nexport const vec = (x?: number, y?: number) => ({ x: x ?? 0, y: y ?? x ?? 0 });\n\nexport const Mock: typeof SkiaExports &\n typeof ValueExports &\n typeof AnimationExports & {\n createDrawing: () => any;\n createDeclaration: () => any;\n ShaderLib: typeof ShaderLib;\n } = {\n // SkiaExports\n // 1. Skia API. BaseSkia contains the enums, and functions like isPaint etc\n Skia,\n ...BaseSkia,\n // 2. Hooks\n useRawData: Noop,\n useData: Noop,\n useFont: Noop,\n useTypeface: Noop,\n useImage: Noop,\n useSVG: Noop,\n createPicture: Noop,\n // 3. Point/Rect/Transform utilities\n vec,\n rect: (x: number, y: number, width: number, height: number) => ({\n x,\n y,\n width,\n height,\n }),\n rrect: (r: SkRect, rx: number, ry: number) => ({\n rect: r,\n rx,\n ry,\n }),\n point: vec,\n add: (a: Vector, b: Vector) => vec(a.x + b.x, a.y + b.y),\n sub: (a: Vector, b: Vector) => vec(a.x - b.x, a.y - b.y),\n neg: (a: Vector) => vec(-a.x, -a.y),\n dist: (a: Vector, b: Vector) => Math.hypot(a.x - b.x, a.y - b.y),\n translate: ({ x, y }: Vector) =>\n [{ translateX: x }, { translateY: y }] as const,\n\n bounds: Noop,\n topLeft: Noop,\n topRight: Noop,\n bottomLeft: Noop,\n bottomRight: Noop,\n center: Noop,\n processTransform2d: Noop,\n // ValueExports\n ...Values,\n ...ValuesHooks,\n Selector,\n // Animations\n ...timingFunctions,\n ...springFunctions,\n ...decayFunctions,\n ...interpolateFn,\n ...interpolatePathFn,\n ...interpolateVectorFn,\n interpolateColors: (\n _value: number,\n _inputRange: number[],\n _outputRange: Color[]\n ) => Float32Array.of(0, 0, 0, 0),\n mixColors: (_v: number, _x: Color, _y: Color) => Float32Array.of(0, 0, 0, 0),\n ShaderLib,\n createDrawing: Noop,\n createDeclaration: Noop,\n makeImageFromView: Noop,\n};\n"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAhBA;AAkBA,MAAMA,IAAN,CAAW;EACTC,WAAW,GAAG;IACZ,OAAO,IAAIC,KAAJ,CAAU,MAAM,CAAE,CAAlB,EAAoB;MACzBC,GAAG,EAAE,MAAM,IAAIH,IAAJ,EADc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AACC,EAAD,EAAaC,EAAb,EAAwBC,EAAxB,KAAsCL,YAAY,CAACC,EAAb,CAAgB,CAAhB,EAAmB,CAAnB,EAAsB,CAAtB,EAAyB,CAAzB,CAzD7C;EA0DJK,SAAS,EAATA,oBA1DI;EA2DJC,aAAa,EAAE5D,IA3DX;EA4DJ6D,iBAAiB,EAAE7D,IA5Df;EA6DJ8D,iBAAiB,EAAE9D;AA7Df,CANC"}
@@ -1,5 +1,17 @@
1
- import type { DataSourceParam } from "../types";
1
+ /// <reference types="react" />
2
+ import type { DataSourceParam, SkImage } from "../types";
2
3
  /**
3
4
  * Returns a Skia Image object
4
5
  * */
5
- export declare const useImage: (source: DataSourceParam, onError?: ((err: Error) => void) | undefined) => import("../types").SkImage | null;
6
+ export declare const useImage: (source: DataSourceParam, onError?: ((err: Error) => void) | undefined) => SkImage | null;
7
+ /**
8
+ * Creates an image from a given view reference. NOTE: This method has different implementations
9
+ * on web/native. On web, the callback is called with the view ref and the callback is expected to
10
+ * return a promise that resolves to a Skia Image object. On native, the view ref is used to
11
+ * find the view tag and the Skia Image object is created from the view tag. This means that on web
12
+ * you will need to implement the logic to create the image from the view ref yourself.
13
+ * @param viewRef Ref to the view we're creating an image from
14
+ * @returns A promise that resolves to a Skia Image object or rejects
15
+ * with an error id the view tag is invalid.
16
+ */
17
+ export declare const makeImageFromView: <T extends number | import("react").Component<unknown, unknown, any> | import("react").ComponentClass<unknown, any>>(viewRef: import("react").RefObject<T>, callback?: ((viewRef: import("react").RefObject<T>) => Promise<SkImage | null>) | null) => Promise<SkImage | null>;
@@ -3,7 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useImage = void 0;
6
+ exports.useImage = exports.makeImageFromView = void 0;
7
+
8
+ var _reactNative = require("react-native");
7
9
 
8
10
  var _Skia = require("../Skia");
9
11
 
@@ -16,6 +18,40 @@ const imgFactory = _Skia.Skia.Image.MakeImageFromEncoded.bind(_Skia.Skia.Image);
16
18
 
17
19
 
18
20
  const useImage = (source, onError) => (0, _Data.useRawData)(source, imgFactory, onError);
21
+ /**
22
+ * Creates an image from a given view reference. NOTE: This method has different implementations
23
+ * on web/native. On web, the callback is called with the view ref and the callback is expected to
24
+ * return a promise that resolves to a Skia Image object. On native, the view ref is used to
25
+ * find the view tag and the Skia Image object is created from the view tag. This means that on web
26
+ * you will need to implement the logic to create the image from the view ref yourself.
27
+ * @param viewRef Ref to the view we're creating an image from
28
+ * @returns A promise that resolves to a Skia Image object or rejects
29
+ * with an error id the view tag is invalid.
30
+ */
31
+
19
32
 
20
33
  exports.useImage = useImage;
34
+
35
+ const makeImageFromView = function (viewRef) {
36
+ let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
37
+
38
+ // In web implementation we just delegate the work to the provided callback
39
+ if (_reactNative.Platform.OS === "web") {
40
+ if (callback) {
41
+ return callback(viewRef);
42
+ } else {
43
+ Promise.reject(new Error("Callback is required on web in the makeImageFromView function."));
44
+ }
45
+ }
46
+
47
+ const viewTag = (0, _reactNative.findNodeHandle)(viewRef.current);
48
+
49
+ if (viewTag !== null && viewTag !== 0) {
50
+ return _Skia.Skia.Image.MakeImageFromViewTag(viewTag);
51
+ }
52
+
53
+ return Promise.reject(new Error("Invalid view tag"));
54
+ };
55
+
56
+ exports.makeImageFromView = makeImageFromView;
21
57
  //# sourceMappingURL=Image.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["imgFactory","Skia","Image","MakeImageFromEncoded","bind","useImage","source","onError","useRawData"],"sources":["Image.ts"],"sourcesContent":["import { Skia } from \"../Skia\";\nimport type { DataSourceParam } from \"../types\";\n\nimport { useRawData } from \"./Data\";\n\nconst imgFactory = Skia.Image.MakeImageFromEncoded.bind(Skia.Image);\n\n/**\n * Returns a Skia Image object\n * */\nexport const useImage = (\n source: DataSourceParam,\n onError?: (err: Error) => void\n) => useRawData(source, imgFactory, onError);\n"],"mappings":";;;;;;;AAAA;;AAGA;;AAEA,MAAMA,UAAU,GAAGC,UAAA,CAAKC,KAAL,CAAWC,oBAAX,CAAgCC,IAAhC,CAAqCH,UAAA,CAAKC,KAA1C,CAAnB;AAEA;AACA;AACA;;;AACO,MAAMG,QAAQ,GAAG,CACtBC,MADsB,EAEtBC,OAFsB,KAGnB,IAAAC,gBAAA,EAAWF,MAAX,EAAmBN,UAAnB,EAA+BO,OAA/B,CAHE"}
1
+ {"version":3,"names":["imgFactory","Skia","Image","MakeImageFromEncoded","bind","useImage","source","onError","useRawData","makeImageFromView","viewRef","callback","Platform","OS","Promise","reject","Error","viewTag","findNodeHandle","current","MakeImageFromViewTag"],"sources":["Image.ts"],"sourcesContent":["import { findNodeHandle, Platform } from \"react-native\";\n\nimport { Skia } from \"../Skia\";\nimport type { DataSourceParam, SkImage } from \"../types\";\n\nimport { useRawData } from \"./Data\";\n\nconst imgFactory = Skia.Image.MakeImageFromEncoded.bind(Skia.Image);\n\n/**\n * Returns a Skia Image object\n * */\nexport const useImage = (\n source: DataSourceParam,\n onError?: (err: Error) => void\n) => useRawData(source, imgFactory, onError);\n\n/**\n * Creates an image from a given view reference. NOTE: This method has different implementations\n * on web/native. On web, the callback is called with the view ref and the callback is expected to\n * return a promise that resolves to a Skia Image object. On native, the view ref is used to\n * find the view tag and the Skia Image object is created from the view tag. This means that on web\n * you will need to implement the logic to create the image from the view ref yourself.\n * @param viewRef Ref to the view we're creating an image from\n * @returns A promise that resolves to a Skia Image object or rejects\n * with an error id the view tag is invalid.\n */\nexport const makeImageFromView = <\n T extends\n | number\n | React.Component<unknown, unknown>\n | React.ComponentClass<unknown>\n>(\n viewRef: React.RefObject<T>,\n callback:\n | null\n | ((viewRef: React.RefObject<T>) => Promise<SkImage | null>) = null\n) => {\n // In web implementation we just delegate the work to the provided callback\n if (Platform.OS === \"web\") {\n if (callback) {\n return callback(viewRef);\n } else {\n Promise.reject(\n new Error(\n \"Callback is required on web in the makeImageFromView function.\"\n )\n );\n }\n }\n const viewTag = findNodeHandle(viewRef.current);\n if (viewTag !== null && viewTag !== 0) {\n return Skia.Image.MakeImageFromViewTag(viewTag);\n }\n return Promise.reject(new Error(\"Invalid view tag\"));\n};\n"],"mappings":";;;;;;;AAAA;;AAEA;;AAGA;;AAEA,MAAMA,UAAU,GAAGC,UAAA,CAAKC,KAAL,CAAWC,oBAAX,CAAgCC,IAAhC,CAAqCH,UAAA,CAAKC,KAA1C,CAAnB;AAEA;AACA;AACA;;;AACO,MAAMG,QAAQ,GAAG,CACtBC,MADsB,EAEtBC,OAFsB,KAGnB,IAAAC,gBAAA,EAAWF,MAAX,EAAmBN,UAAnB,EAA+BO,OAA/B,CAHE;AAKP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAME,iBAAiB,GAAG,UAM/BC,OAN+B,EAU5B;EAAA,IAHHC,QAGG,uEAD8D,IAC9D;;EACH;EACA,IAAIC,qBAAA,CAASC,EAAT,KAAgB,KAApB,EAA2B;IACzB,IAAIF,QAAJ,EAAc;MACZ,OAAOA,QAAQ,CAACD,OAAD,CAAf;IACD,CAFD,MAEO;MACLI,OAAO,CAACC,MAAR,CACE,IAAIC,KAAJ,CACE,gEADF,CADF;IAKD;EACF;;EACD,MAAMC,OAAO,GAAG,IAAAC,2BAAA,EAAeR,OAAO,CAACS,OAAvB,CAAhB;;EACA,IAAIF,OAAO,KAAK,IAAZ,IAAoBA,OAAO,KAAK,CAApC,EAAuC;IACrC,OAAOhB,UAAA,CAAKC,KAAL,CAAWkB,oBAAX,CAAgCH,OAAhC,CAAP;EACD;;EACD,OAAOH,OAAO,CAACC,MAAR,CAAe,IAAIC,KAAJ,CAAU,kBAAV,CAAf,CAAP;AACD,CA5BM"}
@@ -48,6 +48,13 @@ export interface ImageFactory {
48
48
  * image, nullptr is returned.
49
49
  */
50
50
  MakeImageFromEncoded: (encoded: SkData) => SkImage | null;
51
+ /**
52
+ * Returns an image that will be a screenshot of the view represented by
53
+ * the view tag
54
+ * @param viewTag - The tag of the view to make an image from.
55
+ * @returns Returns a valid SkImage, if the view tag is invalid, nullptr is returned.
56
+ */
57
+ MakeImageFromViewTag: (viewTag: number) => Promise<SkImage | null>;
51
58
  /**
52
59
  * Returns an image with the given pixel data and format.
53
60
  * Note that we will always make a copy of the pixel data, because of inconsistencies in
@@ -1 +1 @@
1
- {"version":3,"names":["AlphaType","ColorType"],"sources":["ImageFactory.ts"],"sourcesContent":["import type { SkData } from \"../Data\";\n\nimport type { SkImage } from \"./Image\";\n\nexport enum AlphaType {\n Unknown,\n Opaque,\n Premul,\n Unpremul,\n}\n\nexport enum ColorType {\n Unknown, //!< uninitialized\n Alpha_8, //!< pixel with alpha in 8-bit byte\n RGB_565, //!< pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word\n ARGB_4444, //!< pixel with 4 bits for alpha, red, green, blue; in 16-bit word\n RGBA_8888, //!< pixel with 8 bits for red, green, blue, alpha; in 32-bit word\n RGB_888x, //!< pixel with 8 bits each for red, green, blue; in 32-bit word\n BGRA_8888, //!< pixel with 8 bits for blue, green, red, alpha; in 32-bit word\n RGBA_1010102, //!< 10 bits for red, green, blue; 2 bits for alpha; in 32-bit word\n BGRA_1010102, //!< 10 bits for blue, green, red; 2 bits for alpha; in 32-bit word\n RGB_101010x, //!< pixel with 10 bits each for red, green, blue; in 32-bit word\n BGR_101010x, //!< pixel with 10 bits each for blue, green, red; in 32-bit word\n Gray_8, //!< pixel with grayscale level in 8-bit byte\n RGBA_F16Norm, //!< pixel with half floats in [0,1] for red, green, blue, alpha;\n // in 64-bit word\n RGBA_F16, //!< pixel with half floats for red, green, blue, alpha;\n // in 64-bit word\n RGBA_F32, //!< pixel using C float for red, green, blue, alpha; in 128-bit word\n\n // The following 6 colortypes are just for reading from - not for rendering to\n R8G8_unorm, //!< pixel with a uint8_t for red and green\n\n A16_float, //!< pixel with a half float for alpha\n R16G16_float, //!< pixel with a half float for red and green\n\n A16_unorm, //!< pixel with a little endian uint16_t for alpha\n R16G16_unorm, //!< pixel with a little endian uint16_t for red and green\n R16G16B16A16_unorm, //!< pixel with a little endian uint16_t for red, green, blue\n // and alpha\n SRGBA_8888,\n}\n\nexport interface ImageInfo {\n alphaType: AlphaType;\n // TODO: add support for color space\n // colorSpace: ColorSpace;\n colorType: ColorType;\n height: number;\n width: number;\n}\n\nexport interface ImageFactory {\n /**\n * Return an Image backed by the encoded data, but attempt to defer decoding until the image\n * is actually used/drawn. This deferral allows the system to cache the result, either on the\n * CPU or on the GPU, depending on where the image is drawn.\n * This decoding uses the codecs that have been compiled into CanvasKit. If the bytes are\n * invalid (or an unrecognized codec), null will be returned. See Image.h for more details.\n * @param data - Data object with bytes of data\n * @returns If the encoded format is not supported, or subset is outside of the bounds of the decoded\n * image, nullptr is returned.\n */\n MakeImageFromEncoded: (encoded: SkData) => SkImage | null;\n\n /**\n * Returns an image with the given pixel data and format.\n * Note that we will always make a copy of the pixel data, because of inconsistencies in\n * behavior between GPU and CPU (i.e. the pixel data will be turned into a GPU texture and\n * not modifiable after creation).\n *\n * @param info\n * @param data - bytes representing the pixel data.\n * @param bytesPerRow\n */\n MakeImage(info: ImageInfo, data: SkData, bytesPerRow: number): SkImage | null;\n}\n"],"mappings":";;;;;;IAIYA,S;;;WAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;GAAAA,S,yBAAAA,S;;IAOAC,S;;;WAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;GAAAA,S,yBAAAA,S"}
1
+ {"version":3,"names":["AlphaType","ColorType"],"sources":["ImageFactory.ts"],"sourcesContent":["import type { SkData } from \"../Data\";\n\nimport type { SkImage } from \"./Image\";\n\nexport enum AlphaType {\n Unknown,\n Opaque,\n Premul,\n Unpremul,\n}\n\nexport enum ColorType {\n Unknown, //!< uninitialized\n Alpha_8, //!< pixel with alpha in 8-bit byte\n RGB_565, //!< pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word\n ARGB_4444, //!< pixel with 4 bits for alpha, red, green, blue; in 16-bit word\n RGBA_8888, //!< pixel with 8 bits for red, green, blue, alpha; in 32-bit word\n RGB_888x, //!< pixel with 8 bits each for red, green, blue; in 32-bit word\n BGRA_8888, //!< pixel with 8 bits for blue, green, red, alpha; in 32-bit word\n RGBA_1010102, //!< 10 bits for red, green, blue; 2 bits for alpha; in 32-bit word\n BGRA_1010102, //!< 10 bits for blue, green, red; 2 bits for alpha; in 32-bit word\n RGB_101010x, //!< pixel with 10 bits each for red, green, blue; in 32-bit word\n BGR_101010x, //!< pixel with 10 bits each for blue, green, red; in 32-bit word\n Gray_8, //!< pixel with grayscale level in 8-bit byte\n RGBA_F16Norm, //!< pixel with half floats in [0,1] for red, green, blue, alpha;\n // in 64-bit word\n RGBA_F16, //!< pixel with half floats for red, green, blue, alpha;\n // in 64-bit word\n RGBA_F32, //!< pixel using C float for red, green, blue, alpha; in 128-bit word\n\n // The following 6 colortypes are just for reading from - not for rendering to\n R8G8_unorm, //!< pixel with a uint8_t for red and green\n\n A16_float, //!< pixel with a half float for alpha\n R16G16_float, //!< pixel with a half float for red and green\n\n A16_unorm, //!< pixel with a little endian uint16_t for alpha\n R16G16_unorm, //!< pixel with a little endian uint16_t for red and green\n R16G16B16A16_unorm, //!< pixel with a little endian uint16_t for red, green, blue\n // and alpha\n SRGBA_8888,\n}\n\nexport interface ImageInfo {\n alphaType: AlphaType;\n // TODO: add support for color space\n // colorSpace: ColorSpace;\n colorType: ColorType;\n height: number;\n width: number;\n}\n\nexport interface ImageFactory {\n /**\n * Return an Image backed by the encoded data, but attempt to defer decoding until the image\n * is actually used/drawn. This deferral allows the system to cache the result, either on the\n * CPU or on the GPU, depending on where the image is drawn.\n * This decoding uses the codecs that have been compiled into CanvasKit. If the bytes are\n * invalid (or an unrecognized codec), null will be returned. See Image.h for more details.\n * @param data - Data object with bytes of data\n * @returns If the encoded format is not supported, or subset is outside of the bounds of the decoded\n * image, nullptr is returned.\n */\n MakeImageFromEncoded: (encoded: SkData) => SkImage | null;\n\n /**\n * Returns an image that will be a screenshot of the view represented by\n * the view tag\n * @param viewTag - The tag of the view to make an image from.\n * @returns Returns a valid SkImage, if the view tag is invalid, nullptr is returned.\n */\n MakeImageFromViewTag: (viewTag: number) => Promise<SkImage | null>;\n\n /**\n * Returns an image with the given pixel data and format.\n * Note that we will always make a copy of the pixel data, because of inconsistencies in\n * behavior between GPU and CPU (i.e. the pixel data will be turned into a GPU texture and\n * not modifiable after creation).\n *\n * @param info\n * @param data - bytes representing the pixel data.\n * @param bytesPerRow\n */\n MakeImage(info: ImageInfo, data: SkData, bytesPerRow: number): SkImage | null;\n}\n"],"mappings":";;;;;;IAIYA,S;;;WAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;GAAAA,S,yBAAAA,S;;IAOAC,S;;;WAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;GAAAA,S,yBAAAA,S"}
@@ -1,2 +1,5 @@
1
1
  import type { JsiDisposable, SkJSIInstance } from "../JsiInstance";
2
- export declare type SkSVG = SkJSIInstance<"SVG"> & JsiDisposable;
2
+ export interface SkSVG extends SkJSIInstance<"SVG">, JsiDisposable {
3
+ width(): number;
4
+ height(): number;
5
+ }
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["SVG.ts"],"sourcesContent":["import type { JsiDisposable, SkJSIInstance } from \"../JsiInstance\";\n\nexport type SkSVG = SkJSIInstance<\"SVG\"> & JsiDisposable;\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["SVG.ts"],"sourcesContent":["import type { JsiDisposable, SkJSIInstance } from \"../JsiInstance\";\n\nexport interface SkSVG extends SkJSIInstance<\"SVG\">, JsiDisposable {\n width(): number;\n height(): number;\n}\n"],"mappings":""}
@@ -1,10 +1,11 @@
1
1
  import type { CanvasKit } from "canvaskit-wasm";
2
- import type { SkData, ImageInfo } from "../types";
2
+ import type { SkData, ImageInfo, SkImage } from "../types";
3
3
  import type { ImageFactory } from "../types/Image/ImageFactory";
4
4
  import { Host } from "./Host";
5
5
  import { JsiSkImage } from "./JsiSkImage";
6
6
  export declare class JsiSkImageFactory extends Host implements ImageFactory {
7
7
  constructor(CanvasKit: CanvasKit);
8
+ MakeImageFromViewTag(viewTag: number): Promise<SkImage | null>;
8
9
  MakeImageFromEncoded(encoded: SkData): JsiSkImage | null;
9
10
  MakeImage(info: ImageInfo, data: SkData, bytesPerRow: number): JsiSkImage | null;
10
11
  }
@@ -16,6 +16,13 @@ class JsiSkImageFactory extends _Host.Host {
16
16
  super(CanvasKit);
17
17
  }
18
18
 
19
+ MakeImageFromViewTag(viewTag) {
20
+ const view = viewTag; // TODO: Implement screenshot from view in React JS
21
+
22
+ console.log(view);
23
+ return Promise.resolve(null);
24
+ }
25
+
19
26
  MakeImageFromEncoded(encoded) {
20
27
  const image = this.CanvasKit.MakeImageFromEncoded(_JsiSkData.JsiSkData.fromValue(encoded));
21
28
 
@@ -1 +1 @@
1
- {"version":3,"names":["JsiSkImageFactory","Host","constructor","CanvasKit","MakeImageFromEncoded","encoded","image","JsiSkData","fromValue","JsiSkImage","MakeImage","info","data","bytesPerRow","alphaType","ckEnum","colorSpace","ColorSpace","SRGB","colorType","height","width"],"sources":["JsiSkImageFactory.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type { SkData, ImageInfo } from \"../types\";\nimport type { ImageFactory } from \"../types/Image/ImageFactory\";\n\nimport { Host, ckEnum } from \"./Host\";\nimport { JsiSkImage } from \"./JsiSkImage\";\nimport { JsiSkData } from \"./JsiSkData\";\n\nexport class JsiSkImageFactory extends Host implements ImageFactory {\n constructor(CanvasKit: CanvasKit) {\n super(CanvasKit);\n }\n\n MakeImageFromEncoded(encoded: SkData) {\n const image = this.CanvasKit.MakeImageFromEncoded(\n JsiSkData.fromValue(encoded)\n );\n if (image === null) {\n return null;\n }\n return new JsiSkImage(this.CanvasKit, image);\n }\n\n MakeImage(info: ImageInfo, data: SkData, bytesPerRow: number) {\n // see toSkImageInfo() from canvaskit\n const image = this.CanvasKit.MakeImage(\n {\n alphaType: ckEnum(info.alphaType),\n colorSpace: this.CanvasKit.ColorSpace.SRGB,\n colorType: ckEnum(info.colorType),\n height: info.height,\n width: info.width,\n },\n JsiSkData.fromValue(data),\n bytesPerRow\n );\n if (image === null) {\n return null;\n }\n return new JsiSkImage(this.CanvasKit, image);\n }\n}\n"],"mappings":";;;;;;;AAKA;;AACA;;AACA;;AAEO,MAAMA,iBAAN,SAAgCC,UAAhC,CAA6D;EAClEC,WAAW,CAACC,SAAD,EAAuB;IAChC,MAAMA,SAAN;EACD;;EAEDC,oBAAoB,CAACC,OAAD,EAAkB;IACpC,MAAMC,KAAK,GAAG,KAAKH,SAAL,CAAeC,oBAAf,CACZG,oBAAA,CAAUC,SAAV,CAAoBH,OAApB,CADY,CAAd;;IAGA,IAAIC,KAAK,KAAK,IAAd,EAAoB;MAClB,OAAO,IAAP;IACD;;IACD,OAAO,IAAIG,sBAAJ,CAAe,KAAKN,SAApB,EAA+BG,KAA/B,CAAP;EACD;;EAEDI,SAAS,CAACC,IAAD,EAAkBC,IAAlB,EAAgCC,WAAhC,EAAqD;IAC5D;IACA,MAAMP,KAAK,GAAG,KAAKH,SAAL,CAAeO,SAAf,CACZ;MACEI,SAAS,EAAE,IAAAC,YAAA,EAAOJ,IAAI,CAACG,SAAZ,CADb;MAEEE,UAAU,EAAE,KAAKb,SAAL,CAAec,UAAf,CAA0BC,IAFxC;MAGEC,SAAS,EAAE,IAAAJ,YAAA,EAAOJ,IAAI,CAACQ,SAAZ,CAHb;MAIEC,MAAM,EAAET,IAAI,CAACS,MAJf;MAKEC,KAAK,EAAEV,IAAI,CAACU;IALd,CADY,EAQZd,oBAAA,CAAUC,SAAV,CAAoBI,IAApB,CARY,EASZC,WATY,CAAd;;IAWA,IAAIP,KAAK,KAAK,IAAd,EAAoB;MAClB,OAAO,IAAP;IACD;;IACD,OAAO,IAAIG,sBAAJ,CAAe,KAAKN,SAApB,EAA+BG,KAA/B,CAAP;EACD;;AAhCiE"}
1
+ {"version":3,"names":["JsiSkImageFactory","Host","constructor","CanvasKit","MakeImageFromViewTag","viewTag","view","console","log","Promise","resolve","MakeImageFromEncoded","encoded","image","JsiSkData","fromValue","JsiSkImage","MakeImage","info","data","bytesPerRow","alphaType","ckEnum","colorSpace","ColorSpace","SRGB","colorType","height","width"],"sources":["JsiSkImageFactory.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type { SkData, ImageInfo, SkImage } from \"../types\";\nimport type { ImageFactory } from \"../types/Image/ImageFactory\";\n\nimport { Host, ckEnum } from \"./Host\";\nimport { JsiSkImage } from \"./JsiSkImage\";\nimport { JsiSkData } from \"./JsiSkData\";\n\nexport class JsiSkImageFactory extends Host implements ImageFactory {\n constructor(CanvasKit: CanvasKit) {\n super(CanvasKit);\n }\n\n MakeImageFromViewTag(viewTag: number): Promise<SkImage | null> {\n const view = viewTag as unknown as HTMLElement;\n // TODO: Implement screenshot from view in React JS\n console.log(view);\n return Promise.resolve(null);\n }\n\n MakeImageFromEncoded(encoded: SkData) {\n const image = this.CanvasKit.MakeImageFromEncoded(\n JsiSkData.fromValue(encoded)\n );\n if (image === null) {\n return null;\n }\n return new JsiSkImage(this.CanvasKit, image);\n }\n\n MakeImage(info: ImageInfo, data: SkData, bytesPerRow: number) {\n // see toSkImageInfo() from canvaskit\n const image = this.CanvasKit.MakeImage(\n {\n alphaType: ckEnum(info.alphaType),\n colorSpace: this.CanvasKit.ColorSpace.SRGB,\n colorType: ckEnum(info.colorType),\n height: info.height,\n width: info.width,\n },\n JsiSkData.fromValue(data),\n bytesPerRow\n );\n if (image === null) {\n return null;\n }\n return new JsiSkImage(this.CanvasKit, image);\n }\n}\n"],"mappings":";;;;;;;AAKA;;AACA;;AACA;;AAEO,MAAMA,iBAAN,SAAgCC,UAAhC,CAA6D;EAClEC,WAAW,CAACC,SAAD,EAAuB;IAChC,MAAMA,SAAN;EACD;;EAEDC,oBAAoB,CAACC,OAAD,EAA2C;IAC7D,MAAMC,IAAI,GAAGD,OAAb,CAD6D,CAE7D;;IACAE,OAAO,CAACC,GAAR,CAAYF,IAAZ;IACA,OAAOG,OAAO,CAACC,OAAR,CAAgB,IAAhB,CAAP;EACD;;EAEDC,oBAAoB,CAACC,OAAD,EAAkB;IACpC,MAAMC,KAAK,GAAG,KAAKV,SAAL,CAAeQ,oBAAf,CACZG,oBAAA,CAAUC,SAAV,CAAoBH,OAApB,CADY,CAAd;;IAGA,IAAIC,KAAK,KAAK,IAAd,EAAoB;MAClB,OAAO,IAAP;IACD;;IACD,OAAO,IAAIG,sBAAJ,CAAe,KAAKb,SAApB,EAA+BU,KAA/B,CAAP;EACD;;EAEDI,SAAS,CAACC,IAAD,EAAkBC,IAAlB,EAAgCC,WAAhC,EAAqD;IAC5D;IACA,MAAMP,KAAK,GAAG,KAAKV,SAAL,CAAec,SAAf,CACZ;MACEI,SAAS,EAAE,IAAAC,YAAA,EAAOJ,IAAI,CAACG,SAAZ,CADb;MAEEE,UAAU,EAAE,KAAKpB,SAAL,CAAeqB,UAAf,CAA0BC,IAFxC;MAGEC,SAAS,EAAE,IAAAJ,YAAA,EAAOJ,IAAI,CAACQ,SAAZ,CAHb;MAIEC,MAAM,EAAET,IAAI,CAACS,MAJf;MAKEC,KAAK,EAAEV,IAAI,CAACU;IALd,CADY,EAQZd,oBAAA,CAAUC,SAAV,CAAoBI,IAApB,CARY,EASZC,WATY,CAAd;;IAWA,IAAIP,KAAK,KAAK,IAAd,EAAoB;MAClB,OAAO,IAAP;IACD;;IACD,OAAO,IAAIG,sBAAJ,CAAe,KAAKb,SAApB,EAA+BU,KAA/B,CAAP;EACD;;AAvCiE"}
@@ -12,6 +12,24 @@ export class ImageNode extends JsiDrawingNode {
12
12
  const {
13
13
  image
14
14
  } = this.props;
15
+
16
+ if (!image) {
17
+ return {
18
+ src: {
19
+ x: 0,
20
+ y: 0,
21
+ width: 0,
22
+ height: 0
23
+ },
24
+ dst: {
25
+ x: 0,
26
+ y: 0,
27
+ width: 0,
28
+ height: 0
29
+ }
30
+ };
31
+ }
32
+
15
33
  const fit = (_this$props$fit = this.props.fit) !== null && _this$props$fit !== void 0 ? _this$props$fit : "contain";
16
34
  const rect = processRect(this.Skia, this.props);
17
35
  const {
@@ -46,7 +64,10 @@ export class ImageNode extends JsiDrawingNode {
46
64
  src,
47
65
  dst
48
66
  } = this.derived;
49
- canvas.drawImageRect(image, src, dst, paint);
67
+
68
+ if (image) {
69
+ canvas.drawImageRect(image, src, dst, paint);
70
+ }
50
71
  }
51
72
 
52
73
  }
@@ -1 +1 @@
1
- {"version":3,"names":["NodeType","fitRects","processRect","JsiDrawingNode","ImageNode","constructor","ctx","props","Image","deriveProps","image","fit","rect","Skia","src","dst","x","y","width","height","draw","canvas","paint","derived","Error","drawImageRect"],"sources":["ImageNode.ts"],"sourcesContent":["import type { SkRect } from \"../../../skia/types\";\nimport type { DrawingContext, ImageProps } from \"../../types\";\nimport { NodeType } from \"../../types\";\nimport { fitRects, processRect } from \"../datatypes\";\nimport { JsiDrawingNode } from \"../DrawingNode\";\nimport type { NodeContext } from \"../Node\";\n\nexport class ImageNode extends JsiDrawingNode<\n ImageProps,\n { src: SkRect; dst: SkRect }\n> {\n constructor(ctx: NodeContext, props: ImageProps) {\n super(ctx, NodeType.Image, props);\n }\n\n deriveProps() {\n const { image } = this.props;\n const fit = this.props.fit ?? \"contain\";\n const rect = processRect(this.Skia, this.props);\n const { src, dst } = fitRects(\n fit,\n {\n x: 0,\n y: 0,\n width: image.width(),\n height: image.height(),\n },\n rect\n );\n return { src, dst };\n }\n\n draw({ canvas, paint }: DrawingContext) {\n const { image } = this.props;\n if (!this.derived) {\n throw new Error(\"ImageNode: src and dst are undefined\");\n }\n const { src, dst } = this.derived;\n canvas.drawImageRect(image, src, dst, paint);\n }\n}\n"],"mappings":"AAEA,SAASA,QAAT,QAAyB,aAAzB;AACA,SAASC,QAAT,EAAmBC,WAAnB,QAAsC,cAAtC;AACA,SAASC,cAAT,QAA+B,gBAA/B;AAGA,OAAO,MAAMC,SAAN,SAAwBD,cAAxB,CAGL;EACAE,WAAW,CAACC,GAAD,EAAmBC,KAAnB,EAAsC;IAC/C,MAAMD,GAAN,EAAWN,QAAQ,CAACQ,KAApB,EAA2BD,KAA3B;EACD;;EAEDE,WAAW,GAAG;IAAA;;IACZ,MAAM;MAAEC;IAAF,IAAY,KAAKH,KAAvB;IACA,MAAMI,GAAG,sBAAG,KAAKJ,KAAL,CAAWI,GAAd,6DAAqB,SAA9B;IACA,MAAMC,IAAI,GAAGV,WAAW,CAAC,KAAKW,IAAN,EAAY,KAAKN,KAAjB,CAAxB;IACA,MAAM;MAAEO,GAAF;MAAOC;IAAP,IAAed,QAAQ,CAC3BU,GAD2B,EAE3B;MACEK,CAAC,EAAE,CADL;MAEEC,CAAC,EAAE,CAFL;MAGEC,KAAK,EAAER,KAAK,CAACQ,KAAN,EAHT;MAIEC,MAAM,EAAET,KAAK,CAACS,MAAN;IAJV,CAF2B,EAQ3BP,IAR2B,CAA7B;IAUA,OAAO;MAAEE,GAAF;MAAOC;IAAP,CAAP;EACD;;EAEDK,IAAI,OAAoC;IAAA,IAAnC;MAAEC,MAAF;MAAUC;IAAV,CAAmC;IACtC,MAAM;MAAEZ;IAAF,IAAY,KAAKH,KAAvB;;IACA,IAAI,CAAC,KAAKgB,OAAV,EAAmB;MACjB,MAAM,IAAIC,KAAJ,CAAU,sCAAV,CAAN;IACD;;IACD,MAAM;MAAEV,GAAF;MAAOC;IAAP,IAAe,KAAKQ,OAA1B;IACAF,MAAM,CAACI,aAAP,CAAqBf,KAArB,EAA4BI,GAA5B,EAAiCC,GAAjC,EAAsCO,KAAtC;EACD;;AA7BD"}
1
+ {"version":3,"names":["NodeType","fitRects","processRect","JsiDrawingNode","ImageNode","constructor","ctx","props","Image","deriveProps","image","src","x","y","width","height","dst","fit","rect","Skia","draw","canvas","paint","derived","Error","drawImageRect"],"sources":["ImageNode.ts"],"sourcesContent":["import type { SkRect } from \"../../../skia/types\";\nimport type { DrawingContext, ImageProps } from \"../../types\";\nimport { NodeType } from \"../../types\";\nimport { fitRects, processRect } from \"../datatypes\";\nimport { JsiDrawingNode } from \"../DrawingNode\";\nimport type { NodeContext } from \"../Node\";\n\nexport class ImageNode extends JsiDrawingNode<\n ImageProps,\n { src: SkRect; dst: SkRect }\n> {\n constructor(ctx: NodeContext, props: ImageProps) {\n super(ctx, NodeType.Image, props);\n }\n\n deriveProps() {\n const { image } = this.props;\n if (!image) {\n return {\n src: { x: 0, y: 0, width: 0, height: 0 },\n dst: { x: 0, y: 0, width: 0, height: 0 },\n };\n }\n const fit = this.props.fit ?? \"contain\";\n const rect = processRect(this.Skia, this.props);\n const { src, dst } = fitRects(\n fit,\n {\n x: 0,\n y: 0,\n width: image.width(),\n height: image.height(),\n },\n rect\n );\n return { src, dst };\n }\n\n draw({ canvas, paint }: DrawingContext) {\n const { image } = this.props;\n if (!this.derived) {\n throw new Error(\"ImageNode: src and dst are undefined\");\n }\n const { src, dst } = this.derived;\n if (image) {\n canvas.drawImageRect(image, src, dst, paint);\n }\n }\n}\n"],"mappings":"AAEA,SAASA,QAAT,QAAyB,aAAzB;AACA,SAASC,QAAT,EAAmBC,WAAnB,QAAsC,cAAtC;AACA,SAASC,cAAT,QAA+B,gBAA/B;AAGA,OAAO,MAAMC,SAAN,SAAwBD,cAAxB,CAGL;EACAE,WAAW,CAACC,GAAD,EAAmBC,KAAnB,EAAsC;IAC/C,MAAMD,GAAN,EAAWN,QAAQ,CAACQ,KAApB,EAA2BD,KAA3B;EACD;;EAEDE,WAAW,GAAG;IAAA;;IACZ,MAAM;MAAEC;IAAF,IAAY,KAAKH,KAAvB;;IACA,IAAI,CAACG,KAAL,EAAY;MACV,OAAO;QACLC,GAAG,EAAE;UAAEC,CAAC,EAAE,CAAL;UAAQC,CAAC,EAAE,CAAX;UAAcC,KAAK,EAAE,CAArB;UAAwBC,MAAM,EAAE;QAAhC,CADA;QAELC,GAAG,EAAE;UAAEJ,CAAC,EAAE,CAAL;UAAQC,CAAC,EAAE,CAAX;UAAcC,KAAK,EAAE,CAArB;UAAwBC,MAAM,EAAE;QAAhC;MAFA,CAAP;IAID;;IACD,MAAME,GAAG,sBAAG,KAAKV,KAAL,CAAWU,GAAd,6DAAqB,SAA9B;IACA,MAAMC,IAAI,GAAGhB,WAAW,CAAC,KAAKiB,IAAN,EAAY,KAAKZ,KAAjB,CAAxB;IACA,MAAM;MAAEI,GAAF;MAAOK;IAAP,IAAef,QAAQ,CAC3BgB,GAD2B,EAE3B;MACEL,CAAC,EAAE,CADL;MAEEC,CAAC,EAAE,CAFL;MAGEC,KAAK,EAAEJ,KAAK,CAACI,KAAN,EAHT;MAIEC,MAAM,EAAEL,KAAK,CAACK,MAAN;IAJV,CAF2B,EAQ3BG,IAR2B,CAA7B;IAUA,OAAO;MAAEP,GAAF;MAAOK;IAAP,CAAP;EACD;;EAEDI,IAAI,OAAoC;IAAA,IAAnC;MAAEC,MAAF;MAAUC;IAAV,CAAmC;IACtC,MAAM;MAAEZ;IAAF,IAAY,KAAKH,KAAvB;;IACA,IAAI,CAAC,KAAKgB,OAAV,EAAmB;MACjB,MAAM,IAAIC,KAAJ,CAAU,sCAAV,CAAN;IACD;;IACD,MAAM;MAAEb,GAAF;MAAOK;IAAP,IAAe,KAAKO,OAA1B;;IACA,IAAIb,KAAJ,EAAW;MACTW,MAAM,CAACI,aAAP,CAAqBf,KAArB,EAA4BC,GAA5B,EAAiCK,GAAjC,EAAsCM,KAAtC;IACD;EACF;;AArCD"}
@@ -17,6 +17,11 @@ export class ImageSVGNode extends JsiDrawingNode {
17
17
  const {
18
18
  svg
19
19
  } = this.props;
20
+
21
+ if (!svg) {
22
+ return;
23
+ }
24
+
20
25
  const {
21
26
  x,
22
27
  y,
@@ -1 +1 @@
1
- {"version":3,"names":["NodeType","processRect","JsiDrawingNode","ImageSVGNode","constructor","ctx","props","ImageSVG","deriveProps","draw","canvas","svg","x","y","width","height","Skia","save","translate","drawSvg","restore"],"sources":["ImageSVG.ts"],"sourcesContent":["import type { DrawingContext, ImageSVGProps } from \"../../types\";\nimport { NodeType } from \"../../types\";\nimport { processRect } from \"../datatypes\";\nimport { JsiDrawingNode } from \"../DrawingNode\";\nimport type { NodeContext } from \"../Node\";\n\nexport class ImageSVGNode extends JsiDrawingNode<ImageSVGProps, null> {\n constructor(ctx: NodeContext, props: ImageSVGProps) {\n super(ctx, NodeType.ImageSVG, props);\n }\n\n deriveProps() {\n return null;\n }\n\n draw({ canvas }: DrawingContext) {\n const { svg } = this.props;\n const { x, y, width, height } = processRect(this.Skia, this.props);\n canvas.save();\n canvas.translate(x, y);\n canvas.drawSvg(svg, width, height);\n canvas.restore();\n }\n}\n"],"mappings":"AACA,SAASA,QAAT,QAAyB,aAAzB;AACA,SAASC,WAAT,QAA4B,cAA5B;AACA,SAASC,cAAT,QAA+B,gBAA/B;AAGA,OAAO,MAAMC,YAAN,SAA2BD,cAA3B,CAA+D;EACpEE,WAAW,CAACC,GAAD,EAAmBC,KAAnB,EAAyC;IAClD,MAAMD,GAAN,EAAWL,QAAQ,CAACO,QAApB,EAA8BD,KAA9B;EACD;;EAEDE,WAAW,GAAG;IACZ,OAAO,IAAP;EACD;;EAEDC,IAAI,OAA6B;IAAA,IAA5B;MAAEC;IAAF,CAA4B;IAC/B,MAAM;MAAEC;IAAF,IAAU,KAAKL,KAArB;IACA,MAAM;MAAEM,CAAF;MAAKC,CAAL;MAAQC,KAAR;MAAeC;IAAf,IAA0Bd,WAAW,CAAC,KAAKe,IAAN,EAAY,KAAKV,KAAjB,CAA3C;IACAI,MAAM,CAACO,IAAP;IACAP,MAAM,CAACQ,SAAP,CAAiBN,CAAjB,EAAoBC,CAApB;IACAH,MAAM,CAACS,OAAP,CAAeR,GAAf,EAAoBG,KAApB,EAA2BC,MAA3B;IACAL,MAAM,CAACU,OAAP;EACD;;AAhBmE"}
1
+ {"version":3,"names":["NodeType","processRect","JsiDrawingNode","ImageSVGNode","constructor","ctx","props","ImageSVG","deriveProps","draw","canvas","svg","x","y","width","height","Skia","save","translate","drawSvg","restore"],"sources":["ImageSVG.ts"],"sourcesContent":["import type { DrawingContext, ImageSVGProps } from \"../../types\";\nimport { NodeType } from \"../../types\";\nimport { processRect } from \"../datatypes\";\nimport { JsiDrawingNode } from \"../DrawingNode\";\nimport type { NodeContext } from \"../Node\";\n\nexport class ImageSVGNode extends JsiDrawingNode<ImageSVGProps, null> {\n constructor(ctx: NodeContext, props: ImageSVGProps) {\n super(ctx, NodeType.ImageSVG, props);\n }\n\n deriveProps() {\n return null;\n }\n\n draw({ canvas }: DrawingContext) {\n const { svg } = this.props;\n if (!svg) {\n return;\n }\n const { x, y, width, height } = processRect(this.Skia, this.props);\n canvas.save();\n canvas.translate(x, y);\n canvas.drawSvg(svg, width, height);\n canvas.restore();\n }\n}\n"],"mappings":"AACA,SAASA,QAAT,QAAyB,aAAzB;AACA,SAASC,WAAT,QAA4B,cAA5B;AACA,SAASC,cAAT,QAA+B,gBAA/B;AAGA,OAAO,MAAMC,YAAN,SAA2BD,cAA3B,CAA+D;EACpEE,WAAW,CAACC,GAAD,EAAmBC,KAAnB,EAAyC;IAClD,MAAMD,GAAN,EAAWL,QAAQ,CAACO,QAApB,EAA8BD,KAA9B;EACD;;EAEDE,WAAW,GAAG;IACZ,OAAO,IAAP;EACD;;EAEDC,IAAI,OAA6B;IAAA,IAA5B;MAAEC;IAAF,CAA4B;IAC/B,MAAM;MAAEC;IAAF,IAAU,KAAKL,KAArB;;IACA,IAAI,CAACK,GAAL,EAAU;MACR;IACD;;IACD,MAAM;MAAEC,CAAF;MAAKC,CAAL;MAAQC,KAAR;MAAeC;IAAf,IAA0Bd,WAAW,CAAC,KAAKe,IAAN,EAAY,KAAKV,KAAjB,CAA3C;IACAI,MAAM,CAACO,IAAP;IACAP,MAAM,CAACQ,SAAP,CAAiBN,CAAjB,EAAoBC,CAApB;IACAH,MAAM,CAACS,OAAP,CAAeR,GAAf,EAAoBG,KAApB,EAA2BC,MAA3B;IACAL,MAAM,CAACU,OAAP;EACD;;AAnBmE"}
@@ -8,9 +8,9 @@ export declare class TextNode extends JsiDrawingNode<TextProps, null> {
8
8
  protected deriveProps(): null;
9
9
  draw({ canvas, paint }: DrawingContext): void;
10
10
  }
11
- export declare class TextPathNode extends JsiDrawingNode<TextPathProps, SkTextBlob> {
11
+ export declare class TextPathNode extends JsiDrawingNode<TextPathProps, SkTextBlob | null> {
12
12
  constructor(ctx: NodeContext, props: TextPathProps);
13
- deriveProps(): SkTextBlob;
13
+ deriveProps(): SkTextBlob | null;
14
14
  draw({ canvas, paint }: DrawingContext): void;
15
15
  }
16
16
  export declare class TextBlobNode extends JsiDrawingNode<TextBlobProps, null> {
@@ -21,7 +21,10 @@ export class TextNode extends JsiDrawingNode {
21
21
  y,
22
22
  font
23
23
  } = this.props;
24
- canvas.drawText(text, x, y, paint, font);
24
+
25
+ if (font) {
26
+ canvas.drawText(text, x, y, paint, font);
27
+ }
25
28
  }
26
29
 
27
30
  }
@@ -36,6 +39,11 @@ export class TextPathNode extends JsiDrawingNode {
36
39
  font,
37
40
  initialOffset
38
41
  } = this.props;
42
+
43
+ if (!font) {
44
+ return null;
45
+ }
46
+
39
47
  let {
40
48
  text
41
49
  } = this.props;
@@ -152,7 +160,10 @@ export class GlyphsNode extends JsiDrawingNode {
152
160
  y,
153
161
  font
154
162
  } = this.props;
155
- canvas.drawGlyphs(glyphs, positions, x, y, font, paint);
163
+
164
+ if (font) {
165
+ canvas.drawGlyphs(glyphs, positions, x, y, font, paint);
166
+ }
156
167
  }
157
168
 
158
169
  }