@shopify/react-native-skia 0.1.136 → 0.1.139

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (195) hide show
  1. package/README.md +4 -47
  2. package/android/build.gradle +1 -2
  3. package/cpp/api/JsiSkApi.h +0 -4
  4. package/cpp/api/JsiSkFont.h +0 -19
  5. package/cpp/api/JsiSkMatrix.h +12 -0
  6. package/cpp/api/JsiSkTypeface.h +1 -29
  7. package/lib/commonjs/mock/index.js +0 -4
  8. package/lib/commonjs/mock/index.js.map +1 -1
  9. package/lib/commonjs/renderer/Canvas.js +5 -8
  10. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  11. package/lib/commonjs/renderer/components/Group.js +1 -1
  12. package/lib/commonjs/renderer/components/Group.js.map +1 -1
  13. package/lib/commonjs/renderer/components/text/Glyphs.js +4 -6
  14. package/lib/commonjs/renderer/components/text/Glyphs.js.map +1 -1
  15. package/lib/commonjs/renderer/components/text/Text.js +4 -6
  16. package/lib/commonjs/renderer/components/text/Text.js.map +1 -1
  17. package/lib/commonjs/renderer/components/text/TextPath.js +3 -4
  18. package/lib/commonjs/renderer/components/text/TextPath.js.map +1 -1
  19. package/lib/commonjs/renderer/processors/Font.js +1 -27
  20. package/lib/commonjs/renderer/processors/Font.js.map +1 -1
  21. package/lib/commonjs/renderer/processors/Transform.js +8 -15
  22. package/lib/commonjs/renderer/processors/Transform.js.map +1 -1
  23. package/lib/commonjs/skia/core/Data.js +3 -1
  24. package/lib/commonjs/skia/core/Data.js.map +1 -1
  25. package/lib/commonjs/skia/core/Image.js +4 -1
  26. package/lib/commonjs/skia/core/Image.js.map +1 -1
  27. package/lib/commonjs/skia/core/SVG.js +3 -1
  28. package/lib/commonjs/skia/core/SVG.js.map +1 -1
  29. package/lib/commonjs/skia/core/Typeface.js +4 -1
  30. package/lib/commonjs/skia/core/Typeface.js.map +1 -1
  31. package/lib/commonjs/skia/core/index.js +0 -26
  32. package/lib/commonjs/skia/core/index.js.map +1 -1
  33. package/lib/commonjs/skia/types/Font/Font.js.map +1 -1
  34. package/lib/commonjs/skia/types/Matrix.js +18 -3
  35. package/lib/commonjs/skia/types/Matrix.js.map +1 -1
  36. package/lib/commonjs/skia/types/index.js +0 -13
  37. package/lib/commonjs/skia/types/index.js.map +1 -1
  38. package/lib/commonjs/skia/web/JsiSkFont.js +0 -6
  39. package/lib/commonjs/skia/web/JsiSkFont.js.map +1 -1
  40. package/lib/commonjs/skia/web/JsiSkMatrix.js +4 -0
  41. package/lib/commonjs/skia/web/JsiSkMatrix.js.map +1 -1
  42. package/lib/commonjs/skia/web/JsiSkTextBlobFactory.js +1 -1
  43. package/lib/commonjs/skia/web/JsiSkTextBlobFactory.js.map +1 -1
  44. package/lib/commonjs/skia/web/JsiSkia.js +0 -3
  45. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  46. package/lib/commonjs/values/hooks/useComputedValue.js +1 -8
  47. package/lib/commonjs/values/hooks/useComputedValue.js.map +1 -1
  48. package/lib/commonjs/views/SkiaView.web.js +67 -57
  49. package/lib/commonjs/views/SkiaView.web.js.map +1 -1
  50. package/lib/commonjs/web/LoadSkiaWeb.js +29 -0
  51. package/lib/commonjs/web/LoadSkiaWeb.js.map +1 -0
  52. package/lib/commonjs/web/WithSkiaWeb.js +39 -0
  53. package/lib/commonjs/web/WithSkiaWeb.js.map +1 -0
  54. package/lib/commonjs/web/index.js +22 -12
  55. package/lib/commonjs/web/index.js.map +1 -1
  56. package/lib/module/mock/index.js +0 -4
  57. package/lib/module/mock/index.js.map +1 -1
  58. package/lib/module/renderer/Canvas.js +5 -6
  59. package/lib/module/renderer/Canvas.js.map +1 -1
  60. package/lib/module/renderer/components/Group.js +1 -1
  61. package/lib/module/renderer/components/Group.js.map +1 -1
  62. package/lib/module/renderer/components/text/Glyphs.js +4 -5
  63. package/lib/module/renderer/components/text/Glyphs.js.map +1 -1
  64. package/lib/module/renderer/components/text/Text.js +4 -5
  65. package/lib/module/renderer/components/text/Text.js.map +1 -1
  66. package/lib/module/renderer/components/text/TextPath.js +3 -3
  67. package/lib/module/renderer/components/text/TextPath.js.map +1 -1
  68. package/lib/module/renderer/processors/Font.js +0 -23
  69. package/lib/module/renderer/processors/Font.js.map +1 -1
  70. package/lib/module/renderer/processors/Transform.js +8 -15
  71. package/lib/module/renderer/processors/Transform.js.map +1 -1
  72. package/lib/module/skia/core/Data.js +3 -1
  73. package/lib/module/skia/core/Data.js.map +1 -1
  74. package/lib/module/skia/core/Image.js +2 -1
  75. package/lib/module/skia/core/Image.js.map +1 -1
  76. package/lib/module/skia/core/SVG.js +2 -1
  77. package/lib/module/skia/core/SVG.js.map +1 -1
  78. package/lib/module/skia/core/Typeface.js +2 -1
  79. package/lib/module/skia/core/Typeface.js.map +1 -1
  80. package/lib/module/skia/core/index.js +0 -2
  81. package/lib/module/skia/core/index.js.map +1 -1
  82. package/lib/module/skia/types/Font/Font.js.map +1 -1
  83. package/lib/module/skia/types/Matrix.js +12 -2
  84. package/lib/module/skia/types/Matrix.js.map +1 -1
  85. package/lib/module/skia/types/index.js +0 -1
  86. package/lib/module/skia/types/index.js.map +1 -1
  87. package/lib/module/skia/web/JsiSkFont.js +0 -6
  88. package/lib/module/skia/web/JsiSkFont.js.map +1 -1
  89. package/lib/module/skia/web/JsiSkMatrix.js +4 -0
  90. package/lib/module/skia/web/JsiSkMatrix.js.map +1 -1
  91. package/lib/module/skia/web/JsiSkTextBlobFactory.js +1 -1
  92. package/lib/module/skia/web/JsiSkTextBlobFactory.js.map +1 -1
  93. package/lib/module/skia/web/JsiSkia.js +0 -2
  94. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  95. package/lib/module/values/hooks/useComputedValue.js +0 -4
  96. package/lib/module/values/hooks/useComputedValue.js.map +1 -1
  97. package/lib/module/views/SkiaView.web.js +67 -58
  98. package/lib/module/views/SkiaView.web.js.map +1 -1
  99. package/lib/module/web/LoadSkiaWeb.js +16 -0
  100. package/lib/module/web/LoadSkiaWeb.js.map +1 -0
  101. package/lib/module/web/WithSkiaWeb.js +23 -0
  102. package/lib/module/web/WithSkiaWeb.js.map +1 -0
  103. package/lib/module/web/index.js +2 -9
  104. package/lib/module/web/index.js.map +1 -1
  105. package/lib/typescript/src/renderer/Canvas.d.ts +1 -3
  106. package/lib/typescript/src/renderer/DrawingContext.d.ts +1 -2
  107. package/lib/typescript/src/renderer/processors/Font.d.ts +1 -5
  108. package/lib/typescript/src/renderer/processors/Transform.d.ts +2 -2
  109. package/lib/typescript/src/skia/core/index.d.ts +0 -2
  110. package/lib/typescript/src/skia/types/Font/Font.d.ts +0 -12
  111. package/lib/typescript/src/skia/types/Matrix.d.ts +6 -2
  112. package/lib/typescript/src/skia/types/Skia.d.ts +0 -2
  113. package/lib/typescript/src/skia/types/Typeface/Typeface.d.ts +1 -4
  114. package/lib/typescript/src/skia/types/index.d.ts +0 -1
  115. package/lib/typescript/src/skia/web/JsiSkFont.d.ts +1 -2
  116. package/lib/typescript/src/skia/web/JsiSkMatrix.d.ts +1 -0
  117. package/lib/typescript/src/values/hooks/useComputedValue.d.ts +0 -1
  118. package/lib/typescript/src/views/SkiaView.web.d.ts +9 -11
  119. package/lib/typescript/src/web/LoadSkiaWeb.d.ts +6 -0
  120. package/lib/typescript/src/web/WithSkiaWeb.d.ts +12 -0
  121. package/lib/typescript/src/web/index.d.ts +2 -5
  122. package/package.json +5 -1
  123. package/scripts/setup-canvaskit.js +74 -0
  124. package/src/mock/index.ts +0 -4
  125. package/src/renderer/Canvas.tsx +5 -8
  126. package/src/renderer/DrawingContext.ts +1 -2
  127. package/src/renderer/components/Group.tsx +1 -1
  128. package/src/renderer/components/text/Glyphs.tsx +2 -6
  129. package/src/renderer/components/text/Text.tsx +2 -3
  130. package/src/renderer/components/text/TextPath.tsx +2 -3
  131. package/src/renderer/processors/Font.ts +2 -25
  132. package/src/renderer/processors/Transform.ts +7 -10
  133. package/src/skia/core/Data.ts +3 -1
  134. package/src/skia/core/Image.ts +3 -1
  135. package/src/skia/core/SVG.ts +3 -1
  136. package/src/skia/core/Typeface.ts +4 -6
  137. package/src/skia/core/index.ts +0 -2
  138. package/src/skia/types/Font/Font.ts +0 -13
  139. package/src/skia/types/Matrix.ts +19 -3
  140. package/src/skia/types/Skia.ts +0 -2
  141. package/src/skia/types/Typeface/Typeface.ts +1 -4
  142. package/src/skia/types/index.ts +0 -1
  143. package/src/skia/web/JsiSkFont.ts +0 -9
  144. package/src/skia/web/JsiSkMatrix.ts +4 -0
  145. package/src/skia/web/JsiSkTextBlobFactory.ts +1 -1
  146. package/src/skia/web/JsiSkia.ts +0 -2
  147. package/src/values/hooks/useComputedValue.ts +0 -5
  148. package/src/views/SkiaView.web.tsx +55 -70
  149. package/src/web/LoadSkiaWeb.tsx +24 -0
  150. package/src/web/WithSkiaWeb.tsx +37 -0
  151. package/src/web/index.ts +2 -15
  152. package/cpp/api/JsiSkFontMgr.h +0 -84
  153. package/cpp/api/JsiSkFontMgrFactory.h +0 -48
  154. package/lib/commonjs/skia/core/Paint.js +0 -28
  155. package/lib/commonjs/skia/core/Paint.js.map +0 -1
  156. package/lib/commonjs/skia/core/Path.js +0 -72
  157. package/lib/commonjs/skia/core/Path.js.map +0 -1
  158. package/lib/commonjs/skia/types/FontMgr/FontMgr.js +0 -6
  159. package/lib/commonjs/skia/types/FontMgr/FontMgr.js.map +0 -1
  160. package/lib/commonjs/skia/types/FontMgr/FontMgrFactory.js +0 -6
  161. package/lib/commonjs/skia/types/FontMgr/FontMgrFactory.js.map +0 -1
  162. package/lib/commonjs/skia/types/FontMgr/index.js +0 -32
  163. package/lib/commonjs/skia/types/FontMgr/index.js.map +0 -1
  164. package/lib/commonjs/skia/web/JsiSkFontMgr.js +0 -33
  165. package/lib/commonjs/skia/web/JsiSkFontMgr.js.map +0 -1
  166. package/lib/commonjs/skia/web/JsiSkFontMgrFactory.js +0 -25
  167. package/lib/commonjs/skia/web/JsiSkFontMgrFactory.js.map +0 -1
  168. package/lib/module/skia/core/Paint.js +0 -17
  169. package/lib/module/skia/core/Paint.js.map +0 -1
  170. package/lib/module/skia/core/Path.js +0 -53
  171. package/lib/module/skia/core/Path.js.map +0 -1
  172. package/lib/module/skia/types/FontMgr/FontMgr.js +0 -2
  173. package/lib/module/skia/types/FontMgr/FontMgr.js.map +0 -1
  174. package/lib/module/skia/types/FontMgr/FontMgrFactory.js +0 -2
  175. package/lib/module/skia/types/FontMgr/FontMgrFactory.js.map +0 -1
  176. package/lib/module/skia/types/FontMgr/index.js +0 -3
  177. package/lib/module/skia/types/FontMgr/index.js.map +0 -1
  178. package/lib/module/skia/web/JsiSkFontMgr.js +0 -23
  179. package/lib/module/skia/web/JsiSkFontMgr.js.map +0 -1
  180. package/lib/module/skia/web/JsiSkFontMgrFactory.js +0 -14
  181. package/lib/module/skia/web/JsiSkFontMgrFactory.js.map +0 -1
  182. package/lib/typescript/src/skia/core/Paint.d.ts +0 -6
  183. package/lib/typescript/src/skia/core/Path.d.ts +0 -21
  184. package/lib/typescript/src/skia/types/FontMgr/FontMgr.d.ts +0 -18
  185. package/lib/typescript/src/skia/types/FontMgr/FontMgrFactory.d.ts +0 -4
  186. package/lib/typescript/src/skia/types/FontMgr/index.d.ts +0 -2
  187. package/lib/typescript/src/skia/web/JsiSkFontMgr.d.ts +0 -9
  188. package/lib/typescript/src/skia/web/JsiSkFontMgrFactory.d.ts +0 -8
  189. package/src/skia/core/Paint.ts +0 -22
  190. package/src/skia/core/Path.ts +0 -60
  191. package/src/skia/types/FontMgr/FontMgr.ts +0 -24
  192. package/src/skia/types/FontMgr/FontMgrFactory.ts +0 -12
  193. package/src/skia/types/FontMgr/index.ts +0 -2
  194. package/src/skia/web/JsiSkFontMgr.ts +0 -38
  195. package/src/skia/web/JsiSkFontMgrFactory.ts +0 -18
@@ -1 +1 @@
1
- {"version":3,"sources":["JsiSkia.ts"],"names":["JsiSkPoint","JsiSkPaint","JsiSkRect","Color","JsiSkSurfaceFactory","JsiSkRRect","JsiSkRSXform","toValue","JsiSkContourMeasureIter","JsiSkPictureRecorder","JsiSkPictureFactory","JsiSkPathFactory","JsiSkMatrix","JsiSkColorFilterFactory","JsiSkTypefaceFactory","JsiSkMaskFilterFactory","JsiSkRuntimeEffectFactory","JsiSkImageFilterFactory","JsiSkShaderFactory","JsiSkPathEffectFactory","JsiSkDataFactory","JsiSkImageFactory","JsiSkSVGFactory","JsiSkTextBlobFactory","JsiSkFontMgrFactory","JsiSkFont","MakeVertices","JsiSkApi","CanvasKit","Point","x","y","Float32Array","of","RuntimeShaderBuilder","_","Error","RRectXY","rect","rx","ry","RSXform","scos","ssin","tx","ty","ContourMeasureIter","path","forceClosed","resScale","Paint","PictureRecorder","Picture","Path","Matrix","matrix","identity","ColorFilter","Font","typeface","size","undefined","Typeface","MaskFilter","RuntimeEffect","ImageFilter","Shader","PathEffect","bind","Data","Image","SVG","TextBlob","FontMgr","XYWHRect","width","height","Surface"],"mappings":"AAYA,SAASA,UAAT,QAA2B,cAA3B;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,SAAT,QAA0B,aAA1B;AACA,SAASC,KAAT,QAAsB,cAAtB;AACA,SAASC,mBAAT,QAAoC,uBAApC;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,SAASC,OAAT,QAAwB,QAAxB;AACA,SAASC,uBAAT,QAAwC,2BAAxC;AACA,SAASC,oBAAT,QAAqC,wBAArC;AACA,SAASC,mBAAT,QAAoC,uBAApC;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,WAAT,QAA4B,eAA5B;AACA,SAASC,uBAAT,QAAwC,2BAAxC;AACA,SAASC,oBAAT,QAAqC,wBAArC;AACA,SAASC,sBAAT,QAAuC,0BAAvC;AACA,SAASC,yBAAT,QAA0C,6BAA1C;AACA,SAASC,uBAAT,QAAwC,2BAAxC;AACA,SAASC,kBAAT,QAAmC,sBAAnC;AACA,SAASC,sBAAT,QAAuC,0BAAvC;AACA,SAASC,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C+C;AA8CvDuC,EAAAA,UAAU,EAAE,IAAIhD,sBAAJ,CAA2BS,SAA3B,CA9C2C;AA+CvDF,EAAAA,YAAY,EAAEA,YAAY,CAAC0C,IAAb,CAAkB,IAAlB,EAAwBxC,SAAxB,CA/CyC;AAgDvDyC,EAAAA,IAAI,EAAE,IAAIjD,gBAAJ,CAAqBQ,SAArB,CAhDiD;AAiDvD0C,EAAAA,KAAK,EAAE,IAAIjD,iBAAJ,CAAsBO,SAAtB,CAjDgD;AAkDvD2C,EAAAA,GAAG,EAAE,IAAIjD,eAAJ,CAAoBM,SAApB,CAlDkD;AAmDvD4C,EAAAA,QAAQ,EAAE,IAAIjD,oBAAJ,CAAyBK,SAAzB,CAnD6C;AAoDvD6C,EAAAA,OAAO,EAAE,IAAIjD,mBAAJ,CAAwBI,SAAxB,CApD8C;AAqDvD8C,EAAAA,QAAQ,EAAE,CAAC5C,CAAD,EAAYC,CAAZ,EAAuB4C,KAAvB,EAAsCC,MAAtC,KAAyD;AACjE,WAAO,IAAI1E,SAAJ,CAAc0B,SAAd,EAAyBA,SAAS,CAAC8C,QAAV,CAAmB5C,CAAnB,EAAsBC,CAAtB,EAAyB4C,KAAzB,EAAgCC,MAAhC,CAAzB,CAAP;AACD,GAvDsD;AAwDvDC,EAAAA,OAAO,EAAE,IAAIzE,mBAAJ,CAAwBwB,SAAxB;AAxD8C,CAAjC,CAAjB","sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type {\n SkContourMeasureIter,\n Skia,\n SkPath,\n SkRect,\n SkRuntimeEffect,\n SkRuntimeShaderBuilder,\n SkTypeface,\n} from \"../types\";\n\nimport { JsiSkPoint } from \"./JsiSkPoint\";\nimport { JsiSkPaint } from \"./JsiSkPaint\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { Color } from \"./JsiSkColor\";\nimport { JsiSkSurfaceFactory } from \"./JsiSkSurfaceFactory\";\nimport { JsiSkRRect } from \"./JsiSkRRect\";\nimport { JsiSkRSXform } from \"./JsiSkRSXform\";\nimport { toValue } from \"./Host\";\nimport { JsiSkContourMeasureIter } from \"./JsiSkContourMeasureIter\";\nimport { JsiSkPictureRecorder } from \"./JsiSkPictureRecorder\";\nimport { JsiSkPictureFactory } from \"./JsiSkPictureFactory\";\nimport { JsiSkPathFactory } from \"./JsiSkPathFactory\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\nimport { JsiSkColorFilterFactory } from \"./JsiSkColorFilterFactory\";\nimport { JsiSkTypefaceFactory } from \"./JsiSkTypefaceFactory\";\nimport { JsiSkMaskFilterFactory } from \"./JsiSkMaskFilterFactory\";\nimport { JsiSkRuntimeEffectFactory } from \"./JsiSkRuntimeEffectFactory\";\nimport { JsiSkImageFilterFactory } from \"./JsiSkImageFilterFactory\";\nimport { JsiSkShaderFactory } from \"./JsiSkShaderFactory\";\nimport { JsiSkPathEffectFactory } from \"./JsiSkPathEffectFactory\";\nimport { JsiSkDataFactory } from \"./JsiSkDataFactory\";\nimport { JsiSkImageFactory } from \"./JsiSkImageFactory\";\nimport { JsiSkSVGFactory } from \"./JsiSkSVGFactory\";\nimport { JsiSkTextBlobFactory } from \"./JsiSkTextBlobFactory\";\nimport { JsiSkFontMgrFactory } from \"./JsiSkFontMgrFactory\";\nimport { JsiSkFont } from \"./JsiSkFont\";\nimport { MakeVertices } from \"./JsiSkVerticesFactory\";\n\nexport const JsiSkApi = (CanvasKit: CanvasKit): Skia => ({\n Point: (x: number, y: number) =>\n new JsiSkPoint(CanvasKit, Float32Array.of(x, y)),\n RuntimeShaderBuilder: (_: SkRuntimeEffect): SkRuntimeShaderBuilder => {\n throw new Error(\"Not implemented on React Native Web\");\n },\n RRectXY: (rect: SkRect, rx: number, ry: number) =>\n new JsiSkRRect(CanvasKit, CanvasKit.RRectXY(toValue(rect), rx, ry)),\n RSXform: (scos: number, ssin: number, tx: number, ty: number) =>\n new JsiSkRSXform(CanvasKit, Float32Array.of(scos, ssin, tx, ty)),\n Color,\n ContourMeasureIter: (\n path: SkPath,\n forceClosed: boolean,\n resScale: number\n ): SkContourMeasureIter =>\n new JsiSkContourMeasureIter(\n CanvasKit,\n new CanvasKit.ContourMeasureIter(toValue(path), forceClosed, resScale)\n ),\n Paint: () => new JsiSkPaint(CanvasKit, new CanvasKit.Paint()),\n PictureRecorder: () =>\n new JsiSkPictureRecorder(CanvasKit, new CanvasKit.PictureRecorder()),\n Picture: new JsiSkPictureFactory(CanvasKit),\n Path: new JsiSkPathFactory(CanvasKit),\n Matrix: (matrix?: readonly number[]) =>\n new JsiSkMatrix(\n CanvasKit,\n matrix\n ? Float32Array.of(...matrix)\n : Float32Array.of(...CanvasKit.Matrix.identity())\n ),\n ColorFilter: new JsiSkColorFilterFactory(CanvasKit),\n Font: (typeface?: SkTypeface, size?: number) =>\n new JsiSkFont(\n CanvasKit,\n new CanvasKit.Font(\n typeface === undefined ? null : toValue(typeface),\n size\n )\n ),\n Typeface: new JsiSkTypefaceFactory(CanvasKit),\n MaskFilter: new JsiSkMaskFilterFactory(CanvasKit),\n RuntimeEffect: new JsiSkRuntimeEffectFactory(CanvasKit),\n ImageFilter: new JsiSkImageFilterFactory(CanvasKit),\n Shader: new JsiSkShaderFactory(CanvasKit),\n PathEffect: new JsiSkPathEffectFactory(CanvasKit),\n MakeVertices: MakeVertices.bind(null, CanvasKit),\n Data: new JsiSkDataFactory(CanvasKit),\n Image: new JsiSkImageFactory(CanvasKit),\n SVG: new JsiSkSVGFactory(CanvasKit),\n TextBlob: new JsiSkTextBlobFactory(CanvasKit),\n FontMgr: new JsiSkFontMgrFactory(CanvasKit),\n XYWHRect: (x: number, y: number, width: number, height: number) => {\n return new JsiSkRect(CanvasKit, CanvasKit.XYWHRect(x, y, width, height));\n },\n Surface: new JsiSkSurfaceFactory(CanvasKit),\n});\n"]}
1
+ {"version":3,"sources":["JsiSkia.ts"],"names":["JsiSkPoint","JsiSkPaint","JsiSkRect","Color","JsiSkSurfaceFactory","JsiSkRRect","JsiSkRSXform","toValue","JsiSkContourMeasureIter","JsiSkPictureRecorder","JsiSkPictureFactory","JsiSkPathFactory","JsiSkMatrix","JsiSkColorFilterFactory","JsiSkTypefaceFactory","JsiSkMaskFilterFactory","JsiSkRuntimeEffectFactory","JsiSkImageFilterFactory","JsiSkShaderFactory","JsiSkPathEffectFactory","JsiSkDataFactory","JsiSkImageFactory","JsiSkSVGFactory","JsiSkTextBlobFactory","JsiSkFont","MakeVertices","JsiSkApi","CanvasKit","Point","x","y","Float32Array","of","RuntimeShaderBuilder","_","Error","RRectXY","rect","rx","ry","RSXform","scos","ssin","tx","ty","ContourMeasureIter","path","forceClosed","resScale","Paint","PictureRecorder","Picture","Path","Matrix","matrix","identity","ColorFilter","Font","typeface","size","undefined","Typeface","MaskFilter","RuntimeEffect","ImageFilter","Shader","PathEffect","bind","Data","Image","SVG","TextBlob","XYWHRect","width","height","Surface"],"mappings":"AAYA,SAASA,UAAT,QAA2B,cAA3B;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,SAAT,QAA0B,aAA1B;AACA,SAASC,KAAT,QAAsB,cAAtB;AACA,SAASC,mBAAT,QAAoC,uBAApC;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,SAASC,OAAT,QAAwB,QAAxB;AACA,SAASC,uBAAT,QAAwC,2BAAxC;AACA,SAASC,oBAAT,QAAqC,wBAArC;AACA,SAASC,mBAAT,QAAoC,uBAApC;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,WAAT,QAA4B,eAA5B;AACA,SAASC,uBAAT,QAAwC,2BAAxC;AACA,SAASC,oBAAT,QAAqC,wBAArC;AACA,SAASC,sBAAT,QAAuC,0BAAvC;AACA,SAASC,yBAAT,QAA0C,6BAA1C;AACA,SAASC,uBAAT,QAAwC,2BAAxC;AACA,SAASC,kBAAT,QAAmC,sBAAnC;AACA,SAASC,sBAAT,QAAuC,0BAAvC;AACA,SAASC,gBAAT,QAAiC,oBAAjC;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Q,SAA3B,CA9C2C;AA+CvDF,EAAAA,YAAY,EAAEA,YAAY,CAAC0C,IAAb,CAAkB,IAAlB,EAAwBxC,SAAxB,CA/CyC;AAgDvDyC,EAAAA,IAAI,EAAE,IAAIhD,gBAAJ,CAAqBO,SAArB,CAhDiD;AAiDvD0C,EAAAA,KAAK,EAAE,IAAIhD,iBAAJ,CAAsBM,SAAtB,CAjDgD;AAkDvD2C,EAAAA,GAAG,EAAE,IAAIhD,eAAJ,CAAoBK,SAApB,CAlDkD;AAmDvD4C,EAAAA,QAAQ,EAAE,IAAIhD,oBAAJ,CAAyBI,SAAzB,CAnD6C;AAoDvD6C,EAAAA,QAAQ,EAAE,CAAC3C,CAAD,EAAYC,CAAZ,EAAuB2C,KAAvB,EAAsCC,MAAtC,KAAyD;AACjE,WAAO,IAAIxE,SAAJ,CAAcyB,SAAd,EAAyBA,SAAS,CAAC6C,QAAV,CAAmB3C,CAAnB,EAAsBC,CAAtB,EAAyB2C,KAAzB,EAAgCC,MAAhC,CAAzB,CAAP;AACD,GAtDsD;AAuDvDC,EAAAA,OAAO,EAAE,IAAIvE,mBAAJ,CAAwBuB,SAAxB;AAvD8C,CAAjC,CAAjB","sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type {\n SkContourMeasureIter,\n Skia,\n SkPath,\n SkRect,\n SkRuntimeEffect,\n SkRuntimeShaderBuilder,\n SkTypeface,\n} from \"../types\";\n\nimport { JsiSkPoint } from \"./JsiSkPoint\";\nimport { JsiSkPaint } from \"./JsiSkPaint\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { Color } from \"./JsiSkColor\";\nimport { JsiSkSurfaceFactory } from \"./JsiSkSurfaceFactory\";\nimport { JsiSkRRect } from \"./JsiSkRRect\";\nimport { JsiSkRSXform } from \"./JsiSkRSXform\";\nimport { toValue } from \"./Host\";\nimport { JsiSkContourMeasureIter } from \"./JsiSkContourMeasureIter\";\nimport { JsiSkPictureRecorder } from \"./JsiSkPictureRecorder\";\nimport { JsiSkPictureFactory } from \"./JsiSkPictureFactory\";\nimport { JsiSkPathFactory } from \"./JsiSkPathFactory\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\nimport { JsiSkColorFilterFactory } from \"./JsiSkColorFilterFactory\";\nimport { JsiSkTypefaceFactory } from \"./JsiSkTypefaceFactory\";\nimport { JsiSkMaskFilterFactory } from \"./JsiSkMaskFilterFactory\";\nimport { JsiSkRuntimeEffectFactory } from \"./JsiSkRuntimeEffectFactory\";\nimport { JsiSkImageFilterFactory } from \"./JsiSkImageFilterFactory\";\nimport { JsiSkShaderFactory } from \"./JsiSkShaderFactory\";\nimport { JsiSkPathEffectFactory } from \"./JsiSkPathEffectFactory\";\nimport { JsiSkDataFactory } from \"./JsiSkDataFactory\";\nimport { JsiSkImageFactory } from \"./JsiSkImageFactory\";\nimport { JsiSkSVGFactory } from \"./JsiSkSVGFactory\";\nimport { JsiSkTextBlobFactory } from \"./JsiSkTextBlobFactory\";\nimport { JsiSkFont } from \"./JsiSkFont\";\nimport { MakeVertices } from \"./JsiSkVerticesFactory\";\n\nexport const JsiSkApi = (CanvasKit: CanvasKit): Skia => ({\n Point: (x: number, y: number) =>\n new JsiSkPoint(CanvasKit, Float32Array.of(x, y)),\n RuntimeShaderBuilder: (_: SkRuntimeEffect): SkRuntimeShaderBuilder => {\n throw new Error(\"Not implemented on React Native Web\");\n },\n RRectXY: (rect: SkRect, rx: number, ry: number) =>\n new JsiSkRRect(CanvasKit, CanvasKit.RRectXY(toValue(rect), rx, ry)),\n RSXform: (scos: number, ssin: number, tx: number, ty: number) =>\n new JsiSkRSXform(CanvasKit, Float32Array.of(scos, ssin, tx, ty)),\n Color,\n ContourMeasureIter: (\n path: SkPath,\n forceClosed: boolean,\n resScale: number\n ): SkContourMeasureIter =>\n new JsiSkContourMeasureIter(\n CanvasKit,\n new CanvasKit.ContourMeasureIter(toValue(path), forceClosed, resScale)\n ),\n Paint: () => new JsiSkPaint(CanvasKit, new CanvasKit.Paint()),\n PictureRecorder: () =>\n new JsiSkPictureRecorder(CanvasKit, new CanvasKit.PictureRecorder()),\n Picture: new JsiSkPictureFactory(CanvasKit),\n Path: new JsiSkPathFactory(CanvasKit),\n Matrix: (matrix?: readonly number[]) =>\n new JsiSkMatrix(\n CanvasKit,\n matrix\n ? Float32Array.of(...matrix)\n : Float32Array.of(...CanvasKit.Matrix.identity())\n ),\n ColorFilter: new JsiSkColorFilterFactory(CanvasKit),\n Font: (typeface?: SkTypeface, size?: number) =>\n new JsiSkFont(\n CanvasKit,\n new CanvasKit.Font(\n typeface === undefined ? null : toValue(typeface),\n size\n )\n ),\n Typeface: new JsiSkTypefaceFactory(CanvasKit),\n MaskFilter: new JsiSkMaskFilterFactory(CanvasKit),\n RuntimeEffect: new JsiSkRuntimeEffectFactory(CanvasKit),\n ImageFilter: new JsiSkImageFilterFactory(CanvasKit),\n Shader: new JsiSkShaderFactory(CanvasKit),\n PathEffect: new JsiSkPathEffectFactory(CanvasKit),\n MakeVertices: MakeVertices.bind(null, CanvasKit),\n Data: new JsiSkDataFactory(CanvasKit),\n Image: new JsiSkImageFactory(CanvasKit),\n SVG: new JsiSkSVGFactory(CanvasKit),\n TextBlob: new JsiSkTextBlobFactory(CanvasKit),\n XYWHRect: (x: number, y: number, width: number, height: number) => {\n return new JsiSkRect(CanvasKit, CanvasKit.XYWHRect(x, y, width, height));\n },\n Surface: new JsiSkSurfaceFactory(CanvasKit),\n});\n"]}
@@ -11,8 +11,4 @@ import { isValue } from "../../renderer/processors/Animations";
11
11
 
12
12
  export const useComputedValue = (cb, values) => useMemo(() => ValueApi.createComputedValue(cb, values.filter(isValue)), // eslint-disable-next-line react-hooks/exhaustive-deps
13
13
  values);
14
- export const useDerivedValue = (cb, values) => {
15
- console.warn("useDerivedValue is deprecated. Use useComputedValue instead.");
16
- return useComputedValue(cb, values);
17
- };
18
14
  //# sourceMappingURL=useComputedValue.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["useComputedValue.ts"],"names":["useMemo","ValueApi","isValue","useComputedValue","cb","values","createComputedValue","filter","useDerivedValue","console","warn"],"mappings":"AAAA,SAASA,OAAT,QAAwB,OAAxB;AAEA,SAASC,QAAT,QAAyB,QAAzB;AACA,SAASC,OAAT,QAAwB,sCAAxB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,gBAAgB,GAAG,CAAIC,EAAJ,EAAiBC,MAAjB,KAC9BL,OAAO,CACL,MAAMC,QAAQ,CAACK,mBAAT,CAAgCF,EAAhC,EAAoCC,MAAM,CAACE,MAAP,CAAcL,OAAd,CAApC,CADD,EAEL;AACAG,MAHK,CADF;AAOP,OAAO,MAAMG,eAAe,GAAG,CAAIJ,EAAJ,EAAiBC,MAAjB,KAAuC;AACpEI,EAAAA,OAAO,CAACC,IAAR,CAAa,8DAAb;AACA,SAAOP,gBAAgB,CAACC,EAAD,EAAKC,MAAL,CAAvB;AACD,CAHM","sourcesContent":["import { useMemo } from \"react\";\n\nimport { ValueApi } from \"../api\";\nimport { isValue } from \"../../renderer/processors/Animations\";\n\n/**\n * Creates a new computed value - a value that will calculate its value depending\n * on other values.\n * @param cb Callback to calculate new value\n * @param values Dependant values\n * @returns A readonly value\n */\nexport const useComputedValue = <R>(cb: () => R, values: unknown[]) =>\n useMemo(\n () => ValueApi.createComputedValue<R>(cb, values.filter(isValue)),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n values\n );\n\nexport const useDerivedValue = <R>(cb: () => R, values: unknown[]) => {\n console.warn(\"useDerivedValue is deprecated. Use useComputedValue instead.\");\n return useComputedValue(cb, values);\n};\n"]}
1
+ {"version":3,"sources":["useComputedValue.ts"],"names":["useMemo","ValueApi","isValue","useComputedValue","cb","values","createComputedValue","filter"],"mappings":"AAAA,SAASA,OAAT,QAAwB,OAAxB;AAEA,SAASC,QAAT,QAAyB,QAAzB;AACA,SAASC,OAAT,QAAwB,sCAAxB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,gBAAgB,GAAG,CAAIC,EAAJ,EAAiBC,MAAjB,KAC9BL,OAAO,CACL,MAAMC,QAAQ,CAACK,mBAAT,CAAgCF,EAAhC,EAAoCC,MAAM,CAACE,MAAP,CAAcL,OAAd,CAApC,CADD,EAEL;AACAG,MAHK,CADF","sourcesContent":["import { useMemo } from \"react\";\n\nimport { ValueApi } from \"../api\";\nimport { isValue } from \"../../renderer/processors/Animations\";\n\n/**\n * Creates a new computed value - a value that will calculate its value depending\n * on other values.\n * @param cb Callback to calculate new value\n * @param values Dependant values\n * @returns A readonly value\n */\nexport const useComputedValue = <R>(cb: () => R, values: unknown[]) =>\n useMemo(\n () => ValueApi.createComputedValue<R>(cb, values.filter(isValue)),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n values\n );\n"]}
@@ -4,9 +4,10 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
4
4
 
5
5
  /* global HTMLCanvasElement */
6
6
  import React from "react";
7
- import { View } from "react-native";
7
+ import { PixelRatio, View } from "react-native";
8
8
  import { JsiSkSurface } from "../skia/web/JsiSkSurface";
9
9
  import { TouchType } from "./types";
10
+ const pd = PixelRatio.get();
10
11
  export class SkiaView extends React.Component {
11
12
  constructor(props) {
12
13
  var _props$mode;
@@ -27,12 +28,12 @@ export class SkiaView extends React.Component {
27
28
 
28
29
  _defineProperty(this, "_redrawRequests", 0);
29
30
 
30
- _defineProperty(this, "_unmounted", false);
31
+ _defineProperty(this, "width", 0);
32
+
33
+ _defineProperty(this, "height", 0);
34
+
35
+ _defineProperty(this, "requestId", 0);
31
36
 
32
- this.state = {
33
- width: -1,
34
- height: -1
35
- };
36
37
  this._mode = (_props$mode = props.mode) !== null && _props$mode !== void 0 ? _props$mode : "default";
37
38
  }
38
39
 
@@ -43,33 +44,44 @@ export class SkiaView extends React.Component {
43
44
  }
44
45
 
45
46
  onLayout(evt) {
46
- this.setState({
47
- width: evt.nativeEvent.layout.width,
48
- height: evt.nativeEvent.layout.height
49
- }, () => {
50
- // Reset canvas / surface on layout change
51
- if (this._canvasRef.current) {
52
- // Create surface
53
- this._surface = new JsiSkSurface(global.CanvasKit, global.CanvasKit.MakeWebGLCanvasSurface(this._canvasRef.current)); // Get canvas and repaint
54
-
55
- if (this._surface) {
56
- this._canvas = this._surface.getCanvas();
57
- this.requestRedraw();
58
- }
47
+ const {
48
+ CanvasKit
49
+ } = global;
50
+ const {
51
+ width,
52
+ height
53
+ } = evt.nativeEvent.layout;
54
+ this.width = width;
55
+ this.height = height; // Reset canvas / surface on layout change
56
+
57
+ if (this._canvasRef.current) {
58
+ const canvas = this._canvasRef.current;
59
+ canvas.width = canvas.clientWidth * pd;
60
+ canvas.height = canvas.clientHeight * pd;
61
+ const surface = CanvasKit.MakeWebGLCanvasSurface(this._canvasRef.current);
62
+
63
+ if (!surface) {
64
+ throw new Error("Could not create surface");
59
65
  }
60
- });
66
+
67
+ this._surface = new JsiSkSurface(CanvasKit, surface);
68
+ this._canvas = this._surface.getCanvas();
69
+ this.redraw();
70
+ }
61
71
  }
62
72
 
63
73
  componentDidMount() {
64
74
  // Start render loop
75
+ this.tick();
76
+ }
77
+
78
+ componentDidUpdate() {
65
79
  this.redraw();
66
80
  }
67
81
 
68
82
  componentWillUnmount() {
69
83
  this.unsubscribeAll();
70
- this._surface = null;
71
- this._canvas = null;
72
- this._unmounted = true;
84
+ cancelAnimationFrame(this.requestId);
73
85
  }
74
86
  /**
75
87
  * Creates a snapshot from the canvas in the surface
@@ -88,33 +100,38 @@ export class SkiaView extends React.Component {
88
100
  */
89
101
 
90
102
 
91
- redraw() {
103
+ tick() {
92
104
  if (this._mode === "continuous" || this._redrawRequests > 0) {
93
105
  this._redrawRequests = 0;
94
106
 
95
- if (this._canvas && this.props.onDraw && this.state.height !== -1 && this.state.width !== -1) {
107
+ if (this._canvas && this.props.onDraw) {
96
108
  var _this$_surface2;
97
109
 
98
110
  const touches = [...this._touches];
99
111
  this._touches = [];
100
112
  const info = {
101
- height: this.state.height,
102
- width: this.state.width,
113
+ height: this.height,
114
+ width: this.width,
103
115
  timestamp: Date.now(),
104
- touches: [touches]
116
+ touches: touches.map(t => [t])
105
117
  };
106
- this.props.onDraw && this.props.onDraw(this._canvas, info);
107
- (_this$_surface2 = this._surface) === null || _this$_surface2 === void 0 ? void 0 : _this$_surface2.ref.flush();
108
- }
109
- } // Always request a new redraw as long as we're not unmounted
110
118
 
119
+ if (this.props.onDraw) {
120
+ const canvas = this._canvas;
121
+ canvas.save();
122
+ canvas.scale(pd, pd);
123
+ this.props.onDraw(canvas, info);
124
+ canvas.restore();
125
+ }
111
126
 
112
- if (!this._unmounted) {
113
- requestAnimationFrame(this.redraw.bind(this));
127
+ (_this$_surface2 = this._surface) === null || _this$_surface2 === void 0 ? void 0 : _this$_surface2.ref.flush();
128
+ }
114
129
  }
130
+
131
+ this.requestId = requestAnimationFrame(this.tick.bind(this));
115
132
  }
116
133
 
117
- requestRedraw() {
134
+ redraw() {
118
135
  this._redrawRequests++;
119
136
  }
120
137
  /**
@@ -130,7 +147,7 @@ export class SkiaView extends React.Component {
130
147
 
131
148
  setDrawMode(mode) {
132
149
  this._mode = mode;
133
- this.redraw();
150
+ this.tick();
134
151
  }
135
152
  /**
136
153
  * Registers one or move values as a dependant value of the Skia View. The view will
@@ -145,7 +162,7 @@ export class SkiaView extends React.Component {
145
162
 
146
163
  _values.forEach(v => {
147
164
  this._unsubscriptions.push(v.addListener(() => {
148
- this.requestRedraw();
165
+ this.redraw();
149
166
  }));
150
167
  });
151
168
  }
@@ -160,23 +177,11 @@ export class SkiaView extends React.Component {
160
177
  timestamp: Date.now()
161
178
  });
162
179
 
163
- this.requestRedraw();
164
- }
165
-
166
- handleTouchStart(evt) {
167
- this.handleTouchEvent(evt, TouchType.Start);
168
- }
169
-
170
- handleTouchMove(evt) {
171
- this.handleTouchEvent(evt, TouchType.Active);
172
- }
173
-
174
- handleTouchEnd(evt) {
175
- this.handleTouchEvent(evt, TouchType.Cancelled);
180
+ this.redraw();
176
181
  }
177
182
 
178
- handleTouchCancel(evt) {
179
- this.handleTouchEvent(evt, TouchType.End);
183
+ createTouchHandler(touchType) {
184
+ return evt => this.handleTouchEvent(evt, touchType);
180
185
  }
181
186
 
182
187
  render() {
@@ -189,12 +194,16 @@ export class SkiaView extends React.Component {
189
194
  onLayout: this.onLayout.bind(this)
190
195
  }), /*#__PURE__*/React.createElement("canvas", {
191
196
  ref: this._canvasRef,
192
- width: this.state.width,
193
- height: this.state.height,
194
- onPointerDown: this.handleTouchStart.bind(this),
195
- onPointerMove: this.handleTouchMove.bind(this),
196
- onPointerUp: this.handleTouchEnd.bind(this),
197
- onPointerCancel: this.handleTouchCancel.bind(this)
197
+ style: {
198
+ display: "flex",
199
+ flex: 1
200
+ },
201
+ onPointerDown: this.createTouchHandler(TouchType.Start),
202
+ onPointerMove: this.createTouchHandler(TouchType.Active),
203
+ onPointerUp: this.createTouchHandler(TouchType.End),
204
+ onPointerCancel: this.createTouchHandler(TouchType.Cancelled),
205
+ onPointerLeave: this.createTouchHandler(TouchType.End),
206
+ onPointerOut: this.createTouchHandler(TouchType.End)
198
207
  }));
199
208
  }
200
209
 
@@ -1 +1 @@
1
- {"version":3,"sources":["SkiaView.web.tsx"],"names":["React","View","JsiSkSurface","TouchType","SkiaView","Component","constructor","props","createRef","state","width","height","_mode","mode","unsubscribeAll","_unsubscriptions","forEach","u","onLayout","evt","setState","nativeEvent","layout","_canvasRef","current","_surface","global","CanvasKit","MakeWebGLCanvasSurface","_canvas","getCanvas","requestRedraw","componentDidMount","redraw","componentWillUnmount","_unmounted","makeImageSnapshot","rect","_redrawRequests","onDraw","touches","_touches","info","timestamp","Date","now","ref","flush","requestAnimationFrame","bind","setDrawMode","registerValues","_values","v","push","addListener","handleTouchEvent","touchType","id","pointerId","x","clientX","currentTarget","getClientRects","left","y","clientY","top","force","pressure","type","handleTouchStart","Start","handleTouchMove","Active","handleTouchEnd","Cancelled","handleTouchCancel","End","render","debug","viewProps"],"mappings":";;;;A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CADF;AAaD;;AA/KD","sourcesContent":["/* global HTMLCanvasElement */\nimport React from \"react\";\nimport type { PointerEvent } from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\nimport { View } from \"react-native\";\n\nimport type { SkRect, SkCanvas } from \"../skia/types\";\nimport type { SkiaValue } from \"../values\";\nimport { JsiSkSurface } from \"../skia/web/JsiSkSurface\";\n\nimport type { DrawingInfo, DrawMode, SkiaViewProps, TouchInfo } from \"./types\";\nimport { TouchType } from \"./types\";\n\nexport class SkiaView extends React.Component<\n SkiaViewProps,\n { width: number; height: number }\n> {\n constructor(props: SkiaViewProps) {\n super(props);\n this.state = { width: -1, height: -1 };\n this._mode = props.mode ?? \"default\";\n }\n\n private _surface: JsiSkSurface | null = null;\n private _unsubscriptions: Array<() => void> = [];\n private _touches: Array<TouchInfo> = [];\n private _canvas: SkCanvas | null = null;\n private _canvasRef: React.RefObject<HTMLCanvasElement> = React.createRef();\n private _mode: DrawMode;\n private _redrawRequests = 0;\n private _unmounted = false;\n\n private unsubscribeAll() {\n this._unsubscriptions.forEach((u) => u());\n this._unsubscriptions = [];\n }\n\n private onLayout(evt: LayoutChangeEvent) {\n this.setState(\n {\n width: evt.nativeEvent.layout.width,\n height: evt.nativeEvent.layout.height,\n },\n () => {\n // Reset canvas / surface on layout change\n if (this._canvasRef.current) {\n // Create surface\n this._surface = new JsiSkSurface(\n global.CanvasKit,\n global.CanvasKit.MakeWebGLCanvasSurface(this._canvasRef.current)!\n );\n // Get canvas and repaint\n if (this._surface) {\n this._canvas = this._surface.getCanvas();\n this.requestRedraw();\n }\n }\n }\n );\n }\n\n componentDidMount() {\n // Start render loop\n this.redraw();\n }\n\n componentWillUnmount() {\n this.unsubscribeAll();\n this._surface = null;\n this._canvas = null;\n this._unmounted = true;\n }\n\n /**\n * Creates a snapshot from the canvas in the surface\n * @param rect Rect to use as bounds. Optional.\n * @returns An Image object.\n */\n public makeImageSnapshot(rect?: SkRect) {\n return this._surface?.makeImageSnapshot(rect);\n }\n\n /**\n * Sends a redraw request to the native SkiaView.\n */\n private redraw() {\n if (this._mode === \"continuous\" || this._redrawRequests > 0) {\n this._redrawRequests = 0;\n if (\n this._canvas &&\n this.props.onDraw &&\n this.state.height !== -1 &&\n this.state.width !== -1\n ) {\n const touches = [...this._touches];\n this._touches = [];\n const info: DrawingInfo = {\n height: this.state.height,\n width: this.state.width,\n timestamp: Date.now(),\n touches: [touches],\n };\n this.props.onDraw && this.props.onDraw(this._canvas!, info);\n this._surface?.ref.flush();\n }\n }\n // Always request a new redraw as long as we're not unmounted\n if (!this._unmounted) {\n requestAnimationFrame(this.redraw.bind(this));\n }\n }\n\n public requestRedraw() {\n this._redrawRequests++;\n }\n\n /**\n * Updates the drawing mode for the skia view. This is the same\n * as declaratively setting the mode property on the SkiaView.\n * There are two drawing modes, \"continuous\" and \"default\",\n * where the continuous mode will continuously redraw the view and\n * the default mode will only redraw when any of the regular react\n * properties are changed like size and margins.\n * @param mode Drawing mode to use.\n */\n public setDrawMode(mode: DrawMode) {\n this._mode = mode;\n this.redraw();\n }\n\n /**\n * Registers one or move values as a dependant value of the Skia View. The view will\n * The view will redraw itself when any of the values change.\n * @param values Values to register\n */\n public registerValues(_values: SkiaValue<unknown>[]) {\n // Unsubscribe from dependency values\n this.unsubscribeAll();\n // Register redraw dependencies on values\n _values.forEach((v) => {\n this._unsubscriptions.push(\n v.addListener(() => {\n this.requestRedraw();\n })\n );\n });\n }\n\n private handleTouchEvent(evt: PointerEvent, touchType: TouchType) {\n this._touches.push({\n id: evt.pointerId,\n x: evt.clientX - evt.currentTarget.getClientRects()[0].left,\n y: evt.clientY - evt.currentTarget.getClientRects()[0].top,\n force: evt.pressure,\n type: touchType,\n timestamp: Date.now(),\n });\n this.requestRedraw();\n }\n\n handleTouchStart(evt: PointerEvent) {\n this.handleTouchEvent(evt, TouchType.Start);\n }\n\n handleTouchMove(evt: PointerEvent) {\n this.handleTouchEvent(evt, TouchType.Active);\n }\n\n handleTouchEnd(evt: PointerEvent) {\n this.handleTouchEvent(evt, TouchType.Cancelled);\n }\n\n handleTouchCancel(evt: PointerEvent) {\n this.handleTouchEvent(evt, TouchType.End);\n }\n\n render() {\n const { mode, debug = false, ...viewProps } = this.props;\n return (\n <View {...viewProps} onLayout={this.onLayout.bind(this)}>\n <canvas\n ref={this._canvasRef}\n width={this.state.width}\n height={this.state.height}\n onPointerDown={this.handleTouchStart.bind(this)}\n onPointerMove={this.handleTouchMove.bind(this)}\n onPointerUp={this.handleTouchEnd.bind(this)}\n onPointerCancel={this.handleTouchCancel.bind(this)}\n />\n </View>\n );\n }\n}\n"]}
1
+ {"version":3,"sources":["SkiaView.web.tsx"],"names":["React","PixelRatio","View","JsiSkSurface","TouchType","pd","get","SkiaView","Component","constructor","props","createRef","_mode","mode","unsubscribeAll","_unsubscriptions","forEach","u","onLayout","evt","CanvasKit","global","width","height","nativeEvent","layout","_canvasRef","current","canvas","clientWidth","clientHeight","surface","MakeWebGLCanvasSurface","Error","_surface","_canvas","getCanvas","redraw","componentDidMount","tick","componentDidUpdate","componentWillUnmount","cancelAnimationFrame","requestId","makeImageSnapshot","rect","_redrawRequests","onDraw","touches","_touches","info","timestamp","Date","now","map","t","save","scale","restore","ref","flush","requestAnimationFrame","bind","setDrawMode","registerValues","_values","v","push","addListener","handleTouchEvent","touchType","id","pointerId","x","clientX","currentTarget","getClientRects","left","y","clientY","top","force","pressure","type","createTouchHandler","render","debug","viewProps","display","flex","Start","Active","End","Cancelled"],"mappings":";;;;AAAA;AACA,OAAOA,KAAP,MAAkB,OAAlB;AAGA,SAASC,UAAT,EAAqBC,IAArB,QAAiC,cAAjC;AAIA,SAASC,YAAT,QAA6B,0BAA7B;AAGA,SAASC,SAAT,QAA0B,SAA1B;AAEA,MAAMC,EAAE,GAAGJ,UAAU,CAACK,GAAX,EAAX;AAEA,OAAO,MAAMC,QAAN,SAAuBP,KAAK,CAACQ,SAA7B,CAAsD;AAC3DC,EAAAA,WAAW,CAACC,KAAD,EAAuB;AAA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,IAAI,CAACC,GAAL;AANM,KAAnB;;AAQA,SAAKhB,MAAL;AACD;;AAED+C,EAAAA,kBAAkB,CAACd,SAAD,EAAuB;AACvC,WAAQnD,GAAD,IAAuB,KAAKkD,gBAAL,CAAsBlD,GAAtB,EAA2BmD,SAA3B,CAA9B;AACD;;AAEDe,EAAAA,MAAM,GAAG;AACP,UAAM;AAAExE,MAAAA,IAAF;AAAQyE,MAAAA,KAAK,GAAG,KAAhB;AAAuB,SAAGC;AAA1B,QAAwC,KAAK7E,KAAnD;AACA,wBACE,oBAAC,IAAD,eAAU6E,SAAV;AAAqB,MAAA,QAAQ,EAAE,KAAKrE,QAAL,CAAc4C,IAAd,CAAmB,IAAnB;AAA/B,qBACE;AACE,MAAA,GAAG,EAAE,KAAKpC,UADZ;AAEE,MAAA,KAAK,EAAE;AAAE8D,QAAAA,OAAO,EAAE,MAAX;AAAmBC,QAAAA,IAAI,EAAE;AAAzB,OAFT;AAGE,MAAA,aAAa,EAAE,KAAKL,kBAAL,CAAwBhF,SAAS,CAACsF,KAAlC,CAHjB;AAIE,MAAA,aAAa,EAAE,KAAKN,kBAAL,CAAwBhF,SAAS,CAACuF,MAAlC,CAJjB;AAKE,MAAA,WAAW,EAAE,KAAKP,kBAAL,CAAwBhF,SAAS,CAACwF,GAAlC,CALf;AAME,MAAA,eAAe,EAAE,KAAKR,kBAAL,CAAwBhF,SAAS,CAACyF,SAAlC,CANnB;AAOE,MAAA,cAAc,EAAE,KAAKT,kBAAL,CAAwBhF,SAAS,CAACwF,GAAlC,CAPlB;AAQE,MAAA,YAAY,EAAE,KAAKR,kBAAL,CAAwBhF,SAAS,CAACwF,GAAlC;AARhB,MADF,CADF;AAcD;;AAjK0D","sourcesContent":["/* global HTMLCanvasElement */\nimport React from \"react\";\nimport type { PointerEvent } from \"react\";\nimport type { LayoutChangeEvent } from \"react-native\";\nimport { PixelRatio, View } from \"react-native\";\n\nimport type { SkRect, SkCanvas } from \"../skia/types\";\nimport type { SkiaValue } from \"../values\";\nimport { JsiSkSurface } from \"../skia/web/JsiSkSurface\";\n\nimport type { DrawingInfo, DrawMode, SkiaViewProps, TouchInfo } from \"./types\";\nimport { TouchType } from \"./types\";\n\nconst pd = PixelRatio.get();\n\nexport class SkiaView extends React.Component<SkiaViewProps> {\n constructor(props: SkiaViewProps) {\n super(props);\n this._mode = props.mode ?? \"default\";\n }\n\n private _surface: JsiSkSurface | null = null;\n private _unsubscriptions: Array<() => void> = [];\n private _touches: Array<TouchInfo> = [];\n private _canvas: SkCanvas | null = null;\n private _canvasRef = React.createRef<HTMLCanvasElement>();\n private _mode: DrawMode;\n private _redrawRequests = 0;\n private width = 0;\n private height = 0;\n private requestId = 0;\n\n private unsubscribeAll() {\n this._unsubscriptions.forEach((u) => u());\n this._unsubscriptions = [];\n }\n\n private onLayout(evt: LayoutChangeEvent) {\n const { CanvasKit } = global;\n const { width, height } = evt.nativeEvent.layout;\n this.width = width;\n this.height = height;\n // Reset canvas / surface on layout change\n if (this._canvasRef.current) {\n const canvas = this._canvasRef.current;\n canvas.width = canvas.clientWidth * pd;\n canvas.height = canvas.clientHeight * pd;\n const surface = CanvasKit.MakeWebGLCanvasSurface(this._canvasRef.current);\n if (!surface) {\n throw new Error(\"Could not create surface\");\n }\n this._surface = new JsiSkSurface(CanvasKit, surface);\n this._canvas = this._surface.getCanvas();\n this.redraw();\n }\n }\n\n componentDidMount() {\n // Start render loop\n this.tick();\n }\n\n componentDidUpdate() {\n this.redraw();\n }\n\n componentWillUnmount() {\n this.unsubscribeAll();\n cancelAnimationFrame(this.requestId);\n }\n\n /**\n * Creates a snapshot from the canvas in the surface\n * @param rect Rect to use as bounds. Optional.\n * @returns An Image object.\n */\n public makeImageSnapshot(rect?: SkRect) {\n return this._surface?.makeImageSnapshot(rect);\n }\n\n /**\n * Sends a redraw request to the native SkiaView.\n */\n private tick() {\n if (this._mode === \"continuous\" || this._redrawRequests > 0) {\n this._redrawRequests = 0;\n if (this._canvas && this.props.onDraw) {\n const touches = [...this._touches];\n this._touches = [];\n const info: DrawingInfo = {\n height: this.height,\n width: this.width,\n timestamp: Date.now(),\n touches: touches.map((t) => [t]),\n };\n if (this.props.onDraw) {\n const canvas = this._canvas!;\n canvas.save();\n canvas.scale(pd, pd);\n this.props.onDraw(canvas, info);\n canvas.restore();\n }\n this._surface?.ref.flush();\n }\n }\n this.requestId = requestAnimationFrame(this.tick.bind(this));\n }\n\n public redraw() {\n this._redrawRequests++;\n }\n\n /**\n * Updates the drawing mode for the skia view. This is the same\n * as declaratively setting the mode property on the SkiaView.\n * There are two drawing modes, \"continuous\" and \"default\",\n * where the continuous mode will continuously redraw the view and\n * the default mode will only redraw when any of the regular react\n * properties are changed like size and margins.\n * @param mode Drawing mode to use.\n */\n public setDrawMode(mode: DrawMode) {\n this._mode = mode;\n this.tick();\n }\n\n /**\n * Registers one or move values as a dependant value of the Skia View. The view will\n * The view will redraw itself when any of the values change.\n * @param values Values to register\n */\n public registerValues(_values: SkiaValue<unknown>[]) {\n // Unsubscribe from dependency values\n this.unsubscribeAll();\n // Register redraw dependencies on values\n _values.forEach((v) => {\n this._unsubscriptions.push(\n v.addListener(() => {\n this.redraw();\n })\n );\n });\n }\n\n private handleTouchEvent(evt: PointerEvent, touchType: TouchType) {\n this._touches.push({\n id: evt.pointerId,\n x: evt.clientX - evt.currentTarget.getClientRects()[0].left,\n y: evt.clientY - evt.currentTarget.getClientRects()[0].top,\n force: evt.pressure,\n type: touchType,\n timestamp: Date.now(),\n });\n this.redraw();\n }\n\n createTouchHandler(touchType: TouchType) {\n return (evt: PointerEvent) => this.handleTouchEvent(evt, touchType);\n }\n\n render() {\n const { mode, debug = false, ...viewProps } = this.props;\n return (\n <View {...viewProps} onLayout={this.onLayout.bind(this)}>\n <canvas\n ref={this._canvasRef}\n style={{ display: \"flex\", flex: 1 }}\n onPointerDown={this.createTouchHandler(TouchType.Start)}\n onPointerMove={this.createTouchHandler(TouchType.Active)}\n onPointerUp={this.createTouchHandler(TouchType.End)}\n onPointerCancel={this.createTouchHandler(TouchType.Cancelled)}\n onPointerLeave={this.createTouchHandler(TouchType.End)}\n onPointerOut={this.createTouchHandler(TouchType.End)}\n />\n </View>\n );\n }\n}\n"]}
@@ -0,0 +1,16 @@
1
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
+ // @ts-expect-error
3
+ import CanvasKitInit from "canvaskit-wasm/bin/full/canvaskit";
4
+ export const LoadSkiaWeb = async opts => {
5
+ if (global.CanvasKit !== undefined) {
6
+ return;
7
+ }
8
+
9
+ const CanvasKit = await CanvasKitInit(opts); // The CanvasKit API is stored on the global object and used
10
+ // to create the JsiSKApi in the Skia.web.ts file.
11
+
12
+ global.CanvasKit = CanvasKit;
13
+ }; // We keep this function for backward compatibility
14
+
15
+ export const LoadSkia = LoadSkiaWeb;
16
+ //# sourceMappingURL=LoadSkiaWeb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["LoadSkiaWeb.tsx"],"names":["CanvasKitInit","LoadSkiaWeb","opts","global","CanvasKit","undefined","LoadSkia"],"mappings":"AAAA;AACA;AACA,OAAOA,aAAP,MAA0B,mCAA1B;AAUA,OAAO,MAAMC,WAAW,GAAG,MAAOC,IAAP,IAAuC;AAChE,MAAIC,MAAM,CAACC,SAAP,KAAqBC,SAAzB,EAAoC;AAClC;AACD;;AACD,QAAMD,SAAS,GAAG,MAAMJ,aAAa,CAACE,IAAD,CAArC,CAJgE,CAKhE;AACA;;AACAC,EAAAA,MAAM,CAACC,SAAP,GAAmBA,SAAnB;AACD,CARM,C,CAUP;;AACA,OAAO,MAAME,QAAQ,GAAGL,WAAjB","sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-expect-error\nimport CanvasKitInit from \"canvaskit-wasm/bin/full/canvaskit\";\nimport type {\n CanvasKit as CanvasKitType,\n CanvasKitInitOptions,\n} from \"canvaskit-wasm\";\n\ndeclare global {\n var CanvasKit: CanvasKitType;\n}\n\nexport const LoadSkiaWeb = async (opts?: CanvasKitInitOptions) => {\n if (global.CanvasKit !== undefined) {\n return;\n }\n const CanvasKit = await CanvasKitInit(opts);\n // The CanvasKit API is stored on the global object and used\n // to create the JsiSKApi in the Skia.web.ts file.\n global.CanvasKit = CanvasKit;\n};\n\n// We keep this function for backward compatibility\nexport const LoadSkia = LoadSkiaWeb;\n"]}
@@ -0,0 +1,23 @@
1
+ import React, { useMemo, lazy, Suspense } from "react";
2
+ import { Platform } from "react-native";
3
+ import { LoadSkiaWeb } from "./LoadSkiaWeb";
4
+ export const WithSkiaWeb = _ref => {
5
+ let {
6
+ getComponent,
7
+ fallback,
8
+ opts
9
+ } = _ref;
10
+ const Inner = useMemo(() => /*#__PURE__*/lazy(async () => {
11
+ if (Platform.OS === "web") {
12
+ await LoadSkiaWeb(opts);
13
+ } else {
14
+ console.warn("<WithSkiaWeb /> is only necessary on web. Consider not using on native.");
15
+ }
16
+
17
+ return getComponent();
18
+ }), [getComponent, opts]);
19
+ return /*#__PURE__*/React.createElement(Suspense, {
20
+ fallback: fallback !== null && fallback !== void 0 ? fallback : null
21
+ }, /*#__PURE__*/React.createElement(Inner, null));
22
+ };
23
+ //# sourceMappingURL=WithSkiaWeb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["WithSkiaWeb.tsx"],"names":["React","useMemo","lazy","Suspense","Platform","LoadSkiaWeb","WithSkiaWeb","getComponent","fallback","opts","Inner","OS","console","warn"],"mappings":"AACA,OAAOA,KAAP,IAAgBC,OAAhB,EAAyBC,IAAzB,EAA+BC,QAA/B,QAA+C,OAA/C;AACA,SAASC,QAAT,QAAyB,cAAzB;AAEA,SAASC,WAAT,QAA4B,eAA5B;AAQA,OAAO,MAAMC,WAAW,GAAG,QAIN;AAAA,MAJO;AAC1BC,IAAAA,YAD0B;AAE1BC,IAAAA,QAF0B;AAG1BC,IAAAA;AAH0B,GAIP;AACnB,QAAMC,KAAK,GAAGT,OAAO,CACnB,mBACEC,IAAI,CAAC,YAAY;AACf,QAAIE,QAAQ,CAACO,EAAT,KAAgB,KAApB,EAA2B;AACzB,YAAMN,WAAW,CAACI,IAAD,CAAjB;AACD,KAFD,MAEO;AACLG,MAAAA,OAAO,CAACC,IAAR,CACE,yEADF;AAGD;;AACD,WAAON,YAAY,EAAnB;AACD,GATG,CAFa,EAYnB,CAACA,YAAD,EAAeE,IAAf,CAZmB,CAArB;AAcA,sBACE,oBAAC,QAAD;AAAU,IAAA,QAAQ,EAAED,QAAF,aAAEA,QAAF,cAAEA,QAAF,GAAc;AAAhC,kBACE,oBAAC,KAAD,OADF,CADF;AAKD,CAxBM","sourcesContent":["import type { ComponentProps, ComponentType } from \"react\";\nimport React, { useMemo, lazy, Suspense } from \"react\";\nimport { Platform } from \"react-native\";\n\nimport { LoadSkiaWeb } from \"./LoadSkiaWeb\";\n\ninterface WithSkiaProps {\n fallback?: ComponentProps<typeof Suspense>[\"fallback\"];\n getComponent: () => Promise<{ default: ComponentType }>;\n opts?: Parameters<typeof LoadSkiaWeb>[0];\n}\n\nexport const WithSkiaWeb = ({\n getComponent,\n fallback,\n opts,\n}: WithSkiaProps) => {\n const Inner = useMemo(\n () =>\n lazy(async () => {\n if (Platform.OS === \"web\") {\n await LoadSkiaWeb(opts);\n } else {\n console.warn(\n \"<WithSkiaWeb /> is only necessary on web. Consider not using on native.\"\n );\n }\n return getComponent();\n }),\n [getComponent, opts]\n );\n return (\n <Suspense fallback={fallback ?? null}>\n <Inner />\n </Suspense>\n );\n};\n"]}
@@ -1,10 +1,3 @@
1
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
- // @ts-expect-error
3
- import CanvasKitInit from "canvaskit-wasm/bin/full/canvaskit";
4
- export const LoadSkia = async () => {
5
- const CanvasKit = await CanvasKitInit(); // The CanvasKit API is stored on the global object and used
6
- // to create the JsiSKApi in the Skia.web.ts file.
7
-
8
- global.CanvasKit = CanvasKit;
9
- };
1
+ export * from "./LoadSkiaWeb";
2
+ export * from "./WithSkiaWeb";
10
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":["CanvasKitInit","LoadSkia","CanvasKit","global"],"mappings":"AAAA;AACA;AACA,OAAOA,aAAP,MAA0B,mCAA1B;AAOA,OAAO,MAAMC,QAAQ,GAAG,YAAY;AAClC,QAAMC,SAAS,GAAG,MAAMF,aAAa,EAArC,CADkC,CAElC;AACA;;AACAG,EAAAA,MAAM,CAACD,SAAP,GAAmBA,SAAnB;AACD,CALM","sourcesContent":["// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n// @ts-expect-error\nimport CanvasKitInit from \"canvaskit-wasm/bin/full/canvaskit\";\nimport type { CanvasKit as CanvasKitType } from \"canvaskit-wasm\";\n\ndeclare global {\n var CanvasKit: CanvasKitType;\n}\n\nexport const LoadSkia = async () => {\n const CanvasKit = await CanvasKitInit();\n // The CanvasKit API is stored on the global object and used\n // to create the JsiSKApi in the Skia.web.ts file.\n global.CanvasKit = CanvasKit;\n};\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAd;AACA,cAAc,eAAd","sourcesContent":["export * from \"./LoadSkiaWeb\";\nexport * from \"./WithSkiaWeb\";\n"]}
@@ -3,7 +3,6 @@ import type { RefObject, ReactNode, ComponentProps } from "react";
3
3
  import ReactReconciler from "react-reconciler";
4
4
  import { SkiaView } from "../views";
5
5
  import type { TouchHandler } from "../views";
6
- import type { SkFontMgr } from "../skia/types";
7
6
  import { Container } from "./nodes";
8
7
  export declare const skiaReconciler: ReactReconciler.Reconciler<Container, import("./nodes").Node<unknown>, import("./nodes").Node<unknown>, import("./nodes").Node<unknown>, import("./nodes").Node<unknown>>;
9
8
  export declare const useCanvasRef: () => React.RefObject<SkiaView>;
@@ -11,6 +10,5 @@ export interface CanvasProps extends ComponentProps<typeof SkiaView> {
11
10
  ref?: RefObject<SkiaView>;
12
11
  children: ReactNode;
13
12
  onTouch?: TouchHandler;
14
- fontMgr?: SkFontMgr;
15
13
  }
16
- export declare const Canvas: React.ForwardRefExoticComponent<Pick<CanvasProps, "children" | "mode" | "debug" | "onDraw" | "hitSlop" | "onLayout" | "pointerEvents" | "removeClippedSubviews" | "style" | "testID" | "nativeID" | "collapsable" | "needsOffscreenAlphaCompositing" | "renderToHardwareTextureAndroid" | "focusable" | "shouldRasterizeIOS" | "isTVSelectable" | "hasTVPreferredFocus" | "tvParallaxProperties" | "tvParallaxShiftDistanceX" | "tvParallaxShiftDistanceY" | "tvParallaxTiltAngle" | "tvParallaxMagnification" | "onStartShouldSetResponder" | "onMoveShouldSetResponder" | "onResponderEnd" | "onResponderGrant" | "onResponderReject" | "onResponderMove" | "onResponderRelease" | "onResponderStart" | "onResponderTerminationRequest" | "onResponderTerminate" | "onStartShouldSetResponderCapture" | "onMoveShouldSetResponderCapture" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "onTouchCancel" | "onTouchEndCapture" | "accessible" | "accessibilityActions" | "accessibilityLabel" | "accessibilityRole" | "accessibilityState" | "accessibilityHint" | "accessibilityValue" | "onAccessibilityAction" | "accessibilityLiveRegion" | "importantForAccessibility" | "accessibilityElementsHidden" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors" | "fontMgr" | "onTouch"> & React.RefAttributes<SkiaView>>;
14
+ export declare const Canvas: React.ForwardRefExoticComponent<Pick<CanvasProps, "children" | "mode" | "debug" | "onDraw" | "hitSlop" | "onLayout" | "pointerEvents" | "removeClippedSubviews" | "style" | "testID" | "nativeID" | "collapsable" | "needsOffscreenAlphaCompositing" | "renderToHardwareTextureAndroid" | "focusable" | "shouldRasterizeIOS" | "isTVSelectable" | "hasTVPreferredFocus" | "tvParallaxProperties" | "tvParallaxShiftDistanceX" | "tvParallaxShiftDistanceY" | "tvParallaxTiltAngle" | "tvParallaxMagnification" | "onStartShouldSetResponder" | "onMoveShouldSetResponder" | "onResponderEnd" | "onResponderGrant" | "onResponderReject" | "onResponderMove" | "onResponderRelease" | "onResponderStart" | "onResponderTerminationRequest" | "onResponderTerminate" | "onStartShouldSetResponderCapture" | "onMoveShouldSetResponderCapture" | "onTouchStart" | "onTouchMove" | "onTouchEnd" | "onTouchCancel" | "onTouchEndCapture" | "accessible" | "accessibilityActions" | "accessibilityLabel" | "accessibilityRole" | "accessibilityState" | "accessibilityHint" | "accessibilityValue" | "onAccessibilityAction" | "accessibilityLiveRegion" | "importantForAccessibility" | "accessibilityElementsHidden" | "accessibilityViewIsModal" | "onAccessibilityEscape" | "onAccessibilityTap" | "onMagicTap" | "accessibilityIgnoresInvertColors" | "onTouch"> & React.RefAttributes<SkiaView>>;
@@ -1,12 +1,11 @@
1
1
  import type { RefObject } from "react";
2
2
  import type { DrawingInfo, SkiaView } from "../views";
3
- import type { SkFontMgr, SkCanvas, SkPaint, Skia, Vector } from "../skia/types";
3
+ import type { SkCanvas, SkPaint, Skia, Vector } from "../skia/types";
4
4
  export interface DrawingContext extends Omit<DrawingInfo, "touches"> {
5
5
  canvas: SkCanvas;
6
6
  paint: SkPaint;
7
7
  opacity: number;
8
8
  center: Vector;
9
9
  ref: RefObject<SkiaView>;
10
- fontMgr: SkFontMgr;
11
10
  Skia: Skia;
12
11
  }
@@ -1,11 +1,7 @@
1
- import type { SkFontMgr, SkFont, Skia } from "../../skia/types";
1
+ import type { SkFont } from "../../skia/types";
2
2
  export declare type FontDef = {
3
3
  font: SkFont;
4
- } | {
5
- familyName: string;
6
- size: number;
7
4
  };
8
5
  export declare const isFont: (fontDef: FontDef) => fontDef is {
9
6
  font: SkFont;
10
7
  };
11
- export declare const processFont: (Skia: Skia, fontMgr: SkFontMgr, fontDef: FontDef) => SkFont;
@@ -1,11 +1,11 @@
1
- import type { DrawingContext } from "../DrawingContext";
2
1
  import type { SkMatrix, Vector, Transforms2d } from "../../skia/types";
2
+ import type { SkCanvas } from "../../skia/types/Canvas";
3
3
  export interface TransformProps {
4
4
  transform?: Transforms2d;
5
5
  origin?: Vector;
6
6
  matrix?: SkMatrix;
7
7
  }
8
- export declare const processCanvasTransform: ({ canvas, Skia }: DrawingContext, { transform, origin, matrix }: TransformProps) => void;
8
+ export declare const processCanvasTransform: (canvas: SkCanvas, { transform, origin, matrix }: TransformProps) => void;
9
9
  export declare const localMatrix: (m: SkMatrix, { transform, origin }: TransformProps) => SkMatrix | undefined;
10
10
  export declare const transformOrigin: (origin: Vector, transform: Transforms2d) => (Pick<{
11
11
  readonly translateX: number;
@@ -4,9 +4,7 @@ export * from "./Typeface";
4
4
  export * from "./Image";
5
5
  export * from "./Picture";
6
6
  export * from "./SVG";
7
- export * from "./Path";
8
7
  export * from "./Vector";
9
8
  export * from "./Rect";
10
9
  export * from "./RRect";
11
10
  export * from "./Matrix";
12
- export * from "./Paint";
@@ -24,18 +24,6 @@ export interface SkFont extends SkJSIInstance<"Font"> {
24
24
  * @param paint
25
25
  */
26
26
  getGlyphWidths(glyphs: number[], paint?: SkPaint): number[];
27
- /** Returns the advance width of text.
28
- The advance is the normal distance to move before drawing additional text.
29
- Returns the bounding box of text if bounds is not nullptr. The paint
30
- stroke settings, mask filter, or path effect may modify the bounds.
31
-
32
- @param text character storage encoded with SkTextEncoding
33
- @param byteLength length of character storage in bytes
34
- @param bounds returns bounding box relative to (0, 0) if not nullptr
35
- @param paint optional; may be nullptr
36
- @return number of glyphs represented by text of length byteLength
37
- */
38
- measureText: (text: string, paint?: SkPaint) => SkRect;
39
27
  /**
40
28
  * Returns the FontMetrics for this font.
41
29
  */
@@ -1,4 +1,5 @@
1
1
  import type { SkJSIInstance } from "./JsiInstance";
2
+ import type { SkCanvas } from "./Canvas";
2
3
  export declare enum MatrixIndex {
3
4
  ScaleX = 0,
4
5
  SkewX = 1,
@@ -8,14 +9,16 @@ export declare enum MatrixIndex {
8
9
  TransY = 5,
9
10
  Persp0 = 6,
10
11
  Persp1 = 7,
11
- persp2 = 8
12
+ Persp2 = 8
12
13
  }
14
+ export declare const isMatrix: (obj: unknown) => obj is SkMatrix;
13
15
  export interface SkMatrix extends SkJSIInstance<"Matrix"> {
14
16
  concat: (matrix: SkMatrix) => void;
15
17
  translate: (x: number, y: number) => void;
16
18
  scale: (x: number, y?: number) => void;
17
19
  skew: (x: number, y: number) => void;
18
20
  rotate: (theta: number) => void;
21
+ identity: () => void;
19
22
  }
20
23
  declare type Transform2dName = "translateX" | "translateY" | "scale" | "skewX" | "skewY" | "scaleX" | "scaleY" | "rotateZ" | "rotate";
21
24
  declare type Transformations = {
@@ -25,5 +28,6 @@ export declare type Transforms2d = readonly (Pick<Transformations, "translateX">
25
28
  export interface TransformProp {
26
29
  transform?: Transforms2d;
27
30
  }
28
- export declare const processTransform: (m: SkMatrix, transforms: Transforms2d) => SkMatrix;
31
+ export declare const processTransform: <T extends SkMatrix | SkCanvas>(m: T, transforms: Transforms2d) => T;
32
+ export declare const toDegrees: (rad: number) => number;
29
33
  export {};
@@ -17,7 +17,6 @@ import type { SkVertices, VertexMode } from "./Vertices/Vertices";
17
17
  import type { DataFactory } from "./Data";
18
18
  import type { SVGFactory } from "./SVG";
19
19
  import type { TextBlobFactory } from "./TextBlob";
20
- import type { FontMgrFactory } from "./FontMgr/FontMgrFactory";
21
20
  import type { SurfaceFactory } from "./Surface";
22
21
  import type { SkRSXform } from "./RSXform";
23
22
  import type { SkPath } from "./Path/Path";
@@ -62,7 +61,6 @@ export interface Skia {
62
61
  Data: DataFactory;
63
62
  Image: ImageFactory;
64
63
  SVG: SVGFactory;
65
- FontMgr: FontMgrFactory;
66
64
  TextBlob: TextBlobFactory;
67
65
  Surface: SurfaceFactory;
68
66
  }
@@ -1,5 +1,2 @@
1
1
  import type { SkJSIInstance } from "../JsiInstance";
2
- export interface SkTypeface extends SkJSIInstance<"Typeface"> {
3
- readonly bold: boolean;
4
- readonly italic: boolean;
5
- }
2
+ export declare type SkTypeface = SkJSIInstance<"Typeface">;
@@ -2,7 +2,6 @@ export * from "./Picture";
2
2
  export * from "./Data";
3
3
  export * from "./SVG";
4
4
  export * from "./Surface";
5
- export * from "./FontMgr";
6
5
  export * from "./Vertices";
7
6
  export * from "./RuntimeEffect";
8
7
  export * from "./Shader";
@@ -1,11 +1,10 @@
1
1
  import type { CanvasKit, Font } from "canvaskit-wasm";
2
- import type { FontEdging, FontHinting, SkFont, SkPaint, SkPoint, SkRect, SkTypeface } from "../types";
2
+ import type { FontEdging, FontHinting, SkFont, SkPaint, SkPoint, SkTypeface } from "../types";
3
3
  import { HostObject } from "./Host";
4
4
  import { JsiSkRect } from "./JsiSkRect";
5
5
  import { JsiSkTypeface } from "./JsiSkTypeface";
6
6
  export declare class JsiSkFont extends HostObject<Font, "Font"> implements SkFont {
7
7
  constructor(CanvasKit: CanvasKit, ref: Font);
8
- measureText(_text: string, _paint?: SkPaint): SkRect;
9
8
  getTextWidth(text: string, paint?: SkPaint | undefined): number;
10
9
  getMetrics(): {
11
10
  ascent: number;
@@ -8,4 +8,5 @@ export declare class JsiSkMatrix extends HostObject<Matrix3x3, "Matrix"> impleme
8
8
  scale(x: number, y?: number): void;
9
9
  skew(x: number, y: number): void;
10
10
  rotate(value: number): void;
11
+ identity(): void;
11
12
  }
@@ -6,4 +6,3 @@
6
6
  * @returns A readonly value
7
7
  */
8
8
  export declare const useComputedValue: <R>(cb: () => R, values: unknown[]) => import("..").SkiaValue<R>;
9
- export declare const useDerivedValue: <R>(cb: () => R, values: unknown[]) => import("..").SkiaValue<R>;