@shopify/react-native-skia 0.1.185 → 0.1.187

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) 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/globalJestSetup.js +6 -0
  72. package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +16 -13
  73. package/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm +8 -0
  74. package/ios/RNSkia-iOS/SkiaManager.mm +20 -1
  75. package/ios/RNSkia-iOS/ViewScreenshotService.h +21 -0
  76. package/ios/RNSkia-iOS/ViewScreenshotService.mm +79 -0
  77. package/jestSetup.js +2 -3
  78. package/lib/commonjs/dom/nodes/drawings/ImageNode.js +22 -1
  79. package/lib/commonjs/dom/nodes/drawings/ImageNode.js.map +1 -1
  80. package/lib/commonjs/dom/nodes/drawings/ImageSVG.js +5 -0
  81. package/lib/commonjs/dom/nodes/drawings/ImageSVG.js.map +1 -1
  82. package/lib/commonjs/dom/nodes/drawings/Text.d.ts +2 -2
  83. package/lib/commonjs/dom/nodes/drawings/Text.js +13 -2
  84. package/lib/commonjs/dom/nodes/drawings/Text.js.map +1 -1
  85. package/lib/commonjs/dom/nodes/paint/Shaders.js +5 -0
  86. package/lib/commonjs/dom/nodes/paint/Shaders.js.map +1 -1
  87. package/lib/commonjs/dom/types/Drawings.d.ts +5 -5
  88. package/lib/commonjs/dom/types/Drawings.js.map +1 -1
  89. package/lib/commonjs/dom/types/Shaders.d.ts +1 -1
  90. package/lib/commonjs/dom/types/Shaders.js.map +1 -1
  91. package/lib/commonjs/mock/index.d.ts +2 -15
  92. package/lib/commonjs/mock/index.js +37 -110
  93. package/lib/commonjs/mock/index.js.map +1 -1
  94. package/lib/commonjs/skia/core/Image.d.ts +14 -2
  95. package/lib/commonjs/skia/core/Image.js +37 -1
  96. package/lib/commonjs/skia/core/Image.js.map +1 -1
  97. package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +7 -0
  98. package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
  99. package/lib/commonjs/skia/types/SVG/SVG.d.ts +4 -1
  100. package/lib/commonjs/skia/types/SVG/SVG.js.map +1 -1
  101. package/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +2 -1
  102. package/lib/commonjs/skia/web/JsiSkImageFactory.js +7 -0
  103. package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
  104. package/lib/module/dom/nodes/drawings/ImageNode.js +22 -1
  105. package/lib/module/dom/nodes/drawings/ImageNode.js.map +1 -1
  106. package/lib/module/dom/nodes/drawings/ImageSVG.js +5 -0
  107. package/lib/module/dom/nodes/drawings/ImageSVG.js.map +1 -1
  108. package/lib/module/dom/nodes/drawings/Text.d.ts +2 -2
  109. package/lib/module/dom/nodes/drawings/Text.js +13 -2
  110. package/lib/module/dom/nodes/drawings/Text.js.map +1 -1
  111. package/lib/module/dom/nodes/paint/Shaders.js +5 -0
  112. package/lib/module/dom/nodes/paint/Shaders.js.map +1 -1
  113. package/lib/module/dom/types/Drawings.d.ts +5 -5
  114. package/lib/module/dom/types/Drawings.js.map +1 -1
  115. package/lib/module/dom/types/Shaders.d.ts +1 -1
  116. package/lib/module/dom/types/Shaders.js.map +1 -1
  117. package/lib/module/mock/index.d.ts +2 -15
  118. package/lib/module/mock/index.js +33 -95
  119. package/lib/module/mock/index.js.map +1 -1
  120. package/lib/module/skia/core/Image.d.ts +14 -2
  121. package/lib/module/skia/core/Image.js +32 -0
  122. package/lib/module/skia/core/Image.js.map +1 -1
  123. package/lib/module/skia/types/Image/ImageFactory.d.ts +7 -0
  124. package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
  125. package/lib/module/skia/types/SVG/SVG.d.ts +4 -1
  126. package/lib/module/skia/types/SVG/SVG.js.map +1 -1
  127. package/lib/module/skia/web/JsiSkImageFactory.d.ts +2 -1
  128. package/lib/module/skia/web/JsiSkImageFactory.js +7 -0
  129. package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
  130. package/lib/typescript/globalJestSetup.d.ts +2 -0
  131. package/lib/typescript/src/dom/nodes/drawings/Text.d.ts +2 -2
  132. package/lib/typescript/src/dom/types/Drawings.d.ts +5 -5
  133. package/lib/typescript/src/dom/types/Shaders.d.ts +1 -1
  134. package/lib/typescript/src/mock/index.d.ts +2 -15
  135. package/lib/typescript/src/skia/core/Image.d.ts +14 -2
  136. package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +7 -0
  137. package/lib/typescript/src/skia/types/SVG/SVG.d.ts +4 -1
  138. package/lib/typescript/src/skia/web/JsiSkImageFactory.d.ts +2 -1
  139. package/package.json +3 -2
  140. package/scripts/install-npm.js +3 -2
  141. package/src/dom/nodes/drawings/ImageNode.ts +9 -1
  142. package/src/dom/nodes/drawings/ImageSVG.ts +3 -0
  143. package/src/dom/nodes/drawings/Text.ts +13 -3
  144. package/src/dom/nodes/paint/Shaders.ts +4 -0
  145. package/src/dom/types/Drawings.ts +5 -5
  146. package/src/dom/types/Shaders.ts +1 -1
  147. package/src/mock/index.ts +35 -98
  148. package/src/skia/core/Image.ts +43 -1
  149. package/src/skia/types/Image/ImageFactory.ts +8 -0
  150. package/src/skia/types/SVG/SVG.ts +4 -1
  151. package/src/skia/web/JsiSkImageFactory.ts +8 -1
@@ -31,7 +31,10 @@ class TextNode extends _DrawingNode.JsiDrawingNode {
31
31
  y,
32
32
  font
33
33
  } = this.props;
34
- canvas.drawText(text, x, y, paint, font);
34
+
35
+ if (font) {
36
+ canvas.drawText(text, x, y, paint, font);
37
+ }
35
38
  }
36
39
 
37
40
  }
@@ -49,6 +52,11 @@ class TextPathNode extends _DrawingNode.JsiDrawingNode {
49
52
  font,
50
53
  initialOffset
51
54
  } = this.props;
55
+
56
+ if (!font) {
57
+ return null;
58
+ }
59
+
52
60
  let {
53
61
  text
54
62
  } = this.props;
@@ -171,7 +179,10 @@ class GlyphsNode extends _DrawingNode.JsiDrawingNode {
171
179
  y,
172
180
  font
173
181
  } = this.props;
174
- canvas.drawGlyphs(glyphs, positions, x, y, font, paint);
182
+
183
+ if (font) {
184
+ canvas.drawGlyphs(glyphs, positions, x, y, font, paint);
185
+ }
175
186
  }
176
187
 
177
188
  }
@@ -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,2BAA3B,CAAqE;EAC1EC,WAAW,CAACC,GAAD,EAAmBC,KAAnB,EAAyC;IAClD,MAAMD,GAAN,EAAWE,eAAA,CAASY,QAApB,EAA8Bb,KAA9B;EACD;;EAEDG,WAAW,GAAG;IACZ,MAAMW,IAAI,GAAG,IAAAC,sBAAA,EAAY,KAAKC,IAAjB,EAAuB,KAAKhB,KAAL,CAAWc,IAAlC,CAAb;IACA,MAAM;MAAEJ,IAAF;MAAQO;IAAR,IAA0B,KAAKjB,KAArC;IACA,IAAI;MAAEO;IAAF,IAAW,KAAKP,KAApB;IACA,MAAMkB,GAAG,GAAGR,IAAI,CAACS,WAAL,CAAiBZ,IAAjB,CAAZ;IACA,MAAMa,MAAM,GAAGV,IAAI,CAACW,cAAL,CAAoBH,GAApB,CAAf;IAC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,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,IAAnC;MAAEC,MAAF;MAAUC;IAAV,CAAmC;IACtC,MAAM;MAAEC,IAAF;MAAQC,CAAR;MAAWC,CAAX;MAAcC;IAAd,IAAuB,KAAKV,KAAlC;;IACA,IAAIU,IAAJ,EAAU;MACRL,MAAM,CAACM,QAAP,CAAgBJ,IAAhB,EAAsBC,CAAtB,EAAyBC,CAAzB,EAA4BH,KAA5B,EAAmCI,IAAnC;IACD;EACF;;AAd2D;;;;AAiBvD,MAAME,YAAN,SAA2Bf,2BAA3B,CAGL;EACAC,WAAW,CAACC,GAAD,EAAmBC,KAAnB,EAAyC;IAClD,MAAMD,GAAN,EAAWE,eAAA,CAASY,QAApB,EAA8Bb,KAA9B;EACD;;EAEDG,WAAW,GAAG;IACZ,MAAMW,IAAI,GAAG,IAAAC,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AAW,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;;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;;EAEDK,QAAQ,CAACP,GAAD,EAA0B;IAChC,KAAKQ,gBAAL,CAAsBR,GAAtB;IACA,MAAM;MAAES,MAAF;MAAUC,QAAV;MAAoB,GAAGC;IAAvB,IAAqC,KAAKT,KAAhD;IACA,MAAMU,EAAE,GAAG,KAAKC,IAAL,CAAUC,MAAV,EAAX;IACA,IAAAC,gCAAA,EAAsBH,EAAtB,EAA0BD,SAA1B;IACA,MAAMK,MAAM,GAAGP,MAAM,CAACQ,sBAAP,CACb,IAAAC,sBAAA,EAAgBT,MAAhB,EAAwBC,QAAxB,CADa,EAEbV,GAAG,CAACmB,OAAJ,CAAYC,MAAZ,EAFa,EAGbR,EAHa,CAAf;IAKAZ,GAAG,CAACmB,OAAJ,CAAYE,IAAZ,CAAiBL,MAAjB;E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M,GAAG,KAAKH,IAAL,CAAUT,MAAV,CAAiBwF,iBAAjB,CACbL,CAAC,CAACpD,CADW,EAEboD,CAAC,CAACnD,CAFW,EAGb0C,MAHa,EAIbC,SAJa,EAKbC,IALa,EAMbC,WANa,EAObC,KAPa,EAQbN,KARa,EASbC,GATa,CAAf;IAWA7E,GAAG,CAACmB,OAAJ,CAAYE,IAAZ,CAAiBL,MAAjB;EACD;;AArB0E;;;;AAwBtE,MAAM6E,2BAAN,SAA0ChG,iBAA1C,CAA0F;EAC/FE,WAAW,CAACC,GAAD,EAAmBE,KAAnB,EAAwD;IACjE,MAAMF,GAAN,EAAWM,gBAAA,CAASwF,uBAApB,EAA6C5F,KAA7C;EACD;;EAEDK,QAAQ,CAACP,GAAD,EAA0B;IAChC,MAAM;MAAE+F,MAAF;MAAUC,IAAV;MAAgBpB,KAAhB;MAAuBC;IAAvB,IAA+B,KAAK3E,KAA1C;IACA,MAAM;MAAE4E,MAAF;MAAUC,SAAV;MAAqBC,IAArB;MAA2BC,WAA3B;MAAwCC;IAAxC,IACJ,IAAAC,+BAAA,EAAqB,KAAKtE,IAA1B,EAAgC,KAAKX,KAArC,CADF;IAEA,MAAMc,MAAM,GAAG,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,EAAE,GAAG,KAAKC,IAAL,CAAUC,MAAV,EAAX;IACA,IAAAC,gCAAA,EAAsBH,EAAtB,EAA0BD,SAA1B;IACA,MAAMK,MAAM,GAAGP,MAAM,CAACQ,sBAAP,CACb,IAAAC,sBAAA,EAAgBT,MAAhB,EAAwBC,QAAxB,CADa,EAEbV,GAAG,CAACmB,OAAJ,CAAYC,MAAZ,EAFa,EAGbR,EAHa,CAAf;IAKAZ,GAAG,CAACmB,OAAJ,CAAYE,IAAZ,CAAiBL,MAAjB;EACD;;AAhB4D;;;;AAmBxD,MAAMM,eAAN,SAA8BzB,iBAA9B,CAAkE;EACvEE,WAAW,CAACC,GAAD,EAAmBE,KAAnB,EAA4C;IACrD,MAAMF,GAAN,EAAWM,gBAAA,CAASiB,WAApB,EA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IbC,SAJa,EAKbC,IALa,EAMbC,WANa,EAObC,KAPa,EAQbN,KARa,EASbC,GATa,CAAf;IAWA7E,GAAG,CAACmB,OAAJ,CAAYE,IAAZ,CAAiBL,MAAjB;EACD;;AArB0E;;;;AAwBtE,MAAM6E,2BAAN,SAA0ChG,iBAA1C,CAA0F;EAC/FE,WAAW,CAACC,GAAD,EAAmBE,KAAnB,EAAwD;IACjE,MAAMF,GAAN,EAAWM,gBAAA,CAASwF,uBAApB,EAA6C5F,KAA7C;EACD;;EAEDK,QAAQ,CAACP,GAAD,EAA0B;IAChC,MAAM;MAAE+F,MAAF;MAAUC,IAAV;MAAgBpB,KAAhB;MAAuBC;IAAvB,IAA+B,KAAK3E,KAA1C;IACA,MAAM;MAAE4E,MAAF;MAAUC,SAAV;MAAqBC,IAArB;MAA2BC,WAA3B;MAAwCC;IAAxC,IACJ,IAAAC,+BAAA,EAAqB,KAAKtE,IAA1B,EAAgC,KAAKX,KAArC,CADF;IAEA,MAAMc,MAAM,GAAG,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"}
@@ -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":""}
@@ -1,15 +1,2 @@
1
- import type { Skia as SkiaApi } from "../skia/types";
2
- import type * as SkiaExports from "../skia";
3
- import type * as ValueExports from "../values";
4
- import type * as AnimationExports from "../animation";
5
- import { ShaderLib } from "../renderer/components/shaders/ShaderLib";
6
- export declare const Skia: SkiaApi;
7
- export declare const vec: (x?: number, y?: number) => {
8
- x: number;
9
- y: number;
10
- };
11
- export declare const Mock: typeof SkiaExports & typeof ValueExports & typeof AnimationExports & {
12
- createDrawing: () => any;
13
- createDeclaration: () => any;
14
- ShaderLib: typeof ShaderLib;
15
- };
1
+ import type { CanvasKit } from "canvaskit-wasm";
2
+ export declare const Mock: (CanvasKit: CanvasKit) => any;
@@ -3,122 +3,49 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.vec = exports.Skia = exports.Mock = void 0;
6
+ exports.Mock = void 0;
7
7
 
8
- var Values = _interopRequireWildcard(require("../values/web"));
8
+ var _web = require("../skia/web");
9
9
 
10
- var ValuesHooks = _interopRequireWildcard(require("../values/hooks"));
10
+ var _web2 = require("../values/web");
11
11
 
12
- var _selector = require("../values/selector");
12
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
+ const Noop = () => undefined;
13
14
 
14
- var BaseSkia = _interopRequireWildcard(require("../skia/types"));
15
-
16
- var timingFunctions = _interopRequireWildcard(require("../animation/timing"));
17
-
18
- var springFunctions = _interopRequireWildcard(require("../animation/spring"));
19
-
20
- var decayFunctions = _interopRequireWildcard(require("../animation/decay"));
21
-
22
- var interpolateFn = _interopRequireWildcard(require("../animation/functions/interpolate"));
23
-
24
- var interpolatePathFn = _interopRequireWildcard(require("../animation/functions/interpolatePaths"));
25
-
26
- var interpolateVectorFn = _interopRequireWildcard(require("../animation/functions/interpolateVector"));
27
-
28
- var _ShaderLib = require("../renderer/components/shaders/ShaderLib");
29
-
30
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
31
-
32
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
33
-
34
- /* eslint-disable @typescript-eslint/no-explicit-any */
35
- class Stub {
36
- constructor() {
37
- return new Proxy(() => {}, {
38
- get: () => new Stub(),
39
- apply: () => new Stub(),
40
- set: () => true
41
- });
42
- }
43
-
44
- }
45
-
46
- const Noop = () => {};
47
-
48
- const Skia = new Stub();
49
- exports.Skia = Skia;
50
-
51
- const vec = (x, y) => ({
52
- x: x ?? 0,
53
- y: y ?? x ?? 0
15
+ const NoopValue = () => ({
16
+ current: 0
54
17
  });
55
18
 
56
- exports.vec = vec;
57
- const Mock = {
58
- // SkiaExports
59
- // 1. Skia API. BaseSkia contains the enums, and functions like isPaint etc
60
- Skia,
61
- ...BaseSkia,
62
- // 2. Hooks
63
- useRawData: Noop,
64
- useData: Noop,
65
- useFont: Noop,
66
- useTypeface: Noop,
67
- useImage: Noop,
68
- useSVG: Noop,
69
- createPicture: Noop,
70
- // 3. Point/Rect/Transform utilities
71
- vec,
72
- rect: (x, y, width, height) => ({
73
- x,
74
- y,
75
- width,
76
- height
77
- }),
78
- rrect: (r, rx, ry) => ({
79
- rect: r,
80
- rx,
81
- ry
82
- }),
83
- point: vec,
84
- add: (a, b) => vec(a.x + b.x, a.y + b.y),
85
- sub: (a, b) => vec(a.x - b.x, a.y - b.y),
86
- neg: a => vec(-a.x, -a.y),
87
- dist: (a, b) => Math.hypot(a.x - b.x, a.y - b.y),
88
- translate: _ref => {
89
- let {
90
- x,
91
- y
92
- } = _ref;
93
- return [{
94
- translateX: x
95
- }, {
96
- translateY: y
97
- }];
98
- },
99
- bounds: Noop,
100
- topLeft: Noop,
101
- topRight: Noop,
102
- bottomLeft: Noop,
103
- bottomRight: Noop,
104
- center: Noop,
105
- processTransform2d: Noop,
106
- // ValueExports
107
- ...Values,
108
- ...ValuesHooks,
109
- Selector: _selector.Selector,
110
- // Animations
111
- ...timingFunctions,
112
- ...springFunctions,
113
- ...decayFunctions,
114
- ...interpolateFn,
115
- ...interpolatePathFn,
116
- ...interpolateVectorFn,
117
- interpolateColors: (_value, _inputRange, _outputRange) => Float32Array.of(0, 0, 0, 0),
118
- mixColors: (_v, _x, _y) => Float32Array.of(0, 0, 0, 0),
119
- ShaderLib: _ShaderLib.ShaderLib,
120
- createDrawing: Noop,
121
- createDeclaration: Noop
19
+ const Mock = CanvasKit => {
20
+ global.SkiaApi = (0, _web.JsiSkApi)(CanvasKit);
21
+ global.SkiaValueApi = _web2.ValueApi;
22
+ const Skia = global.SkiaApi;
23
+ return {
24
+ Skia,
25
+ ...require("../renderer/components"),
26
+ ...require("../skia"),
27
+ ...require("../values"),
28
+ ...require("../animation"),
29
+ ...require("../dom/types"),
30
+ ...require("../dom/nodes"),
31
+ // We could use the real Canvas if we mock the SkiaView component for node
32
+ Canvas: Noop,
33
+ useValue: NoopValue,
34
+ useComputedValue: NoopValue,
35
+ useTouchHandler: Noop,
36
+ useTiming: NoopValue,
37
+ useLoop: NoopValue,
38
+ useSpring: NoopValue,
39
+ useClockValue: NoopValue,
40
+ useValueEffect: Noop,
41
+ useRawData: Noop,
42
+ useData: Noop,
43
+ useFont: () => Skia.Font(undefined, 0),
44
+ useTypeface: () => null,
45
+ useImage: () => null,
46
+ useSVG: () => null
47
+ };
122
48
  };
49
+
123
50
  exports.Mock = Mock;
124
51
  //# 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,IAAIP,IAAJ,EAAtB;;;AAEA,MAAMQ,GAAG,GAAG,CAACC,CAAD,EAAaC,CAAb,MAA6B;EAAED,CAAC,EAAEA,CAAC,IAAI,CAAV;EAAaC,CAAC,EAAEA,CAAC,IAAID,CAAL,IAAU;AAA1B,CAA7B,CAAZ;;;AAEA,MAAME,IAMV,GAAG;EACJ;EACA;EACAJ,IAHI;EAIJ,GAAGK,QAJC;EAKJ;EACAC,UAAU,EAAEP,IANR;EAOJQ,OAAO,EAAER,IAPL;EAQJS,OAAO,EAAET,IARL;EASJU,WAAW,EAAEV,IATT;EAUJW,QAAQ,EAAEX,IAVN;EAWJY,MAAM,EAAEZ,IAXJ;EAYJa,aAAa,EAAEb,IAZX;EAaJ;EACAE,GAdI;EAeJY,IAAI,EAAE,CAACX,CAAD,EAAYC,CAAZ,EAAuBW,KAAvB,EAAsCC,MAAtC,MAA0D;IAC9Db,CAD8D;IAE9DC,CAF8D;IAG9DW,KAH8D;IAI9DC;EAJ8D,CAA1D,CAfF;EAqB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AAEvC,IAxChB;EAyCJ;EACA,GAAGwC,MA1CC;EA2CJ,GAAGC,WA3CC;EA4CJC,QAAQ,EAARA,kBA5CI;EA6CJ;EACA,GAAGC,eA9CC;EA+CJ,GAAGC,eA/CC;EAgDJ,GAAGC,cAhDC;EAiDJ,GAAGC,aAjDC;EAkDJ,GAAGC,iBAlDC;EAmDJ,GAAGC,mBAnDC;EAoDJC,iBAAiB,EAAE,CACjBC,MADiB,EAEjBC,WAFiB,EAGjBC,YAHiB,KAIdC,YAAY,CAACC,EAAb,CAAgB,CAAhB,EAAmB,CAAnB,EAAsB,CAAtB,EAAyB,CAAzB,CAxDD;EAyDJC,SAAS,EAAE,CAACC,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;AA5Df,CANC"}
1
+ {"version":3,"names":["Noop","undefined","NoopValue","current","Mock","CanvasKit","global","SkiaApi","JsiSkApi","SkiaValueApi","ValueApi","Skia","require","Canvas","useValue","useComputedValue","useTouchHandler","useTiming","useLoop","useSpring","useClockValue","useValueEffect","useRawData","useData","useFont","Font","useTypeface","useImage","useSVG"],"sources":["index.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport { JsiSkApi } from \"../skia/web\";\nimport { ValueApi } from \"../values/web\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst Noop: () => any = () => undefined;\nconst NoopValue = () => ({ current: 0 });\n\nexport const Mock = (CanvasKit: CanvasKit) => {\n global.SkiaApi = JsiSkApi(CanvasKit);\n global.SkiaValueApi = ValueApi;\n const Skia = global.SkiaApi;\n return {\n Skia,\n ...require(\"../renderer/components\"),\n ...require(\"../skia\"),\n ...require(\"../values\"),\n ...require(\"../animation\"),\n ...require(\"../dom/types\"),\n ...require(\"../dom/nodes\"),\n // We could use the real Canvas if we mock the SkiaView component for node\n Canvas: Noop,\n useValue: NoopValue,\n useComputedValue: NoopValue,\n useTouchHandler: Noop,\n useTiming: NoopValue,\n useLoop: NoopValue,\n useSpring: NoopValue,\n useClockValue: NoopValue,\n useValueEffect: Noop,\n useRawData: Noop,\n useData: Noop,\n useFont: () => Skia.Font(undefined, 0),\n useTypeface: () => null,\n useImage: () => null,\n useSVG: () => null,\n };\n};\n"],"mappings":";;;;;;;AAEA;;AACA;;AAEA;AACA,MAAMA,IAAe,GAAG,MAAMC,SAA9B;;AACA,MAAMC,SAAS,GAAG,OAAO;EAAEC,OAAO,EAAE;AAAX,CAAP,CAAlB;;AAEO,MAAMC,IAAI,GAAIC,SAAD,IAA0B;EAC5CC,MAAM,CAACC,OAAP,GAAiB,IAAAC,aAAA,EAASH,SAAT,CAAjB;EACAC,MAAM,CAACG,YAAP,GAAsBC,cAAtB;EACA,MAAMC,IAAI,GAAGL,MAAM,CAACC,OAApB;EACA,OAAO;IACLI,IADK;IAEL,GAAGC,OAAO,CAAC,wBAAD,CAFL;IAGL,GAAGA,OAAO,CAAC,SAAD,CAHL;IAIL,GAAGA,OAAO,CAAC,WAAD,CAJL;IAKL,GAAGA,OAAO,CAAC,cAAD,CALL;IAML,GAAGA,OAAO,CAAC,cAAD,CANL;IAOL,GAAGA,OAAO,CAAC,cAAD,CAPL;IAQL;IACAC,MAAM,EAAEb,IATH;IAULc,QAAQ,EAAEZ,SAVL;IAWLa,gBAAgB,EAAEb,SAXb;IAYLc,eAAe,EAAEhB,IAZZ;IAaLiB,SAAS,EAAEf,SAbN;IAcLgB,OAAO,EAAEhB,SAdJ;IAeLiB,SAAS,EAAEjB,SAfN;IAgBLkB,aAAa,EAAElB,SAhBV;IAiBLmB,cAAc,EAAErB,IAjBX;IAkBLsB,UAAU,EAAEtB,IAlBP;IAmBLuB,OAAO,EAAEvB,IAnBJ;IAoBLwB,OAAO,EAAE,MAAMb,IAAI,CAACc,IAAL,CAAUxB,SAAV,EAAqB,CAArB,CApBV;IAqBLyB,WAAW,EAAE,MAAM,IArBd;IAsBLC,QAAQ,EAAE,MAAM,IAtBX;IAuBLC,MAAM,EAAE,MAAM;EAvBT,CAAP;AAyBD,CA7BM"}
@@ -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
  }