@shopify/react-native-skia 0.1.138 → 0.1.139

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. package/cpp/api/JsiSkApi.h +0 -4
  2. package/cpp/api/JsiSkFont.h +0 -19
  3. package/lib/commonjs/mock/index.js +0 -4
  4. package/lib/commonjs/mock/index.js.map +1 -1
  5. package/lib/commonjs/renderer/Canvas.js +5 -8
  6. package/lib/commonjs/renderer/Canvas.js.map +1 -1
  7. package/lib/commonjs/renderer/components/text/Glyphs.js +4 -6
  8. package/lib/commonjs/renderer/components/text/Glyphs.js.map +1 -1
  9. package/lib/commonjs/renderer/components/text/Text.js +4 -6
  10. package/lib/commonjs/renderer/components/text/Text.js.map +1 -1
  11. package/lib/commonjs/renderer/components/text/TextPath.js +3 -4
  12. package/lib/commonjs/renderer/components/text/TextPath.js.map +1 -1
  13. package/lib/commonjs/renderer/processors/Font.js +1 -27
  14. package/lib/commonjs/renderer/processors/Font.js.map +1 -1
  15. package/lib/commonjs/skia/core/Data.js +4 -5
  16. package/lib/commonjs/skia/core/Data.js.map +1 -1
  17. package/lib/commonjs/skia/core/Image.js +4 -1
  18. package/lib/commonjs/skia/core/Image.js.map +1 -1
  19. package/lib/commonjs/skia/core/SVG.js +3 -1
  20. package/lib/commonjs/skia/core/SVG.js.map +1 -1
  21. package/lib/commonjs/skia/core/Typeface.js +4 -1
  22. package/lib/commonjs/skia/core/Typeface.js.map +1 -1
  23. package/lib/commonjs/skia/core/index.js +0 -26
  24. package/lib/commonjs/skia/core/index.js.map +1 -1
  25. package/lib/commonjs/skia/types/Font/Font.js.map +1 -1
  26. package/lib/commonjs/skia/types/index.js +0 -13
  27. package/lib/commonjs/skia/types/index.js.map +1 -1
  28. package/lib/commonjs/skia/web/JsiSkFont.js +0 -6
  29. package/lib/commonjs/skia/web/JsiSkFont.js.map +1 -1
  30. package/lib/commonjs/skia/web/JsiSkTextBlobFactory.js +1 -1
  31. package/lib/commonjs/skia/web/JsiSkTextBlobFactory.js.map +1 -1
  32. package/lib/commonjs/skia/web/JsiSkia.js +0 -3
  33. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  34. package/lib/commonjs/values/hooks/useComputedValue.js +1 -8
  35. package/lib/commonjs/values/hooks/useComputedValue.js.map +1 -1
  36. package/lib/commonjs/views/SkiaView.web.js +53 -33
  37. package/lib/commonjs/views/SkiaView.web.js.map +1 -1
  38. package/lib/module/mock/index.js +0 -4
  39. package/lib/module/mock/index.js.map +1 -1
  40. package/lib/module/renderer/Canvas.js +5 -6
  41. package/lib/module/renderer/Canvas.js.map +1 -1
  42. package/lib/module/renderer/components/text/Glyphs.js +4 -5
  43. package/lib/module/renderer/components/text/Glyphs.js.map +1 -1
  44. package/lib/module/renderer/components/text/Text.js +4 -5
  45. package/lib/module/renderer/components/text/Text.js.map +1 -1
  46. package/lib/module/renderer/components/text/TextPath.js +3 -3
  47. package/lib/module/renderer/components/text/TextPath.js.map +1 -1
  48. package/lib/module/renderer/processors/Font.js +0 -23
  49. package/lib/module/renderer/processors/Font.js.map +1 -1
  50. package/lib/module/skia/core/Data.js +4 -5
  51. package/lib/module/skia/core/Data.js.map +1 -1
  52. package/lib/module/skia/core/Image.js +2 -1
  53. package/lib/module/skia/core/Image.js.map +1 -1
  54. package/lib/module/skia/core/SVG.js +2 -1
  55. package/lib/module/skia/core/SVG.js.map +1 -1
  56. package/lib/module/skia/core/Typeface.js +2 -1
  57. package/lib/module/skia/core/Typeface.js.map +1 -1
  58. package/lib/module/skia/core/index.js +0 -2
  59. package/lib/module/skia/core/index.js.map +1 -1
  60. package/lib/module/skia/types/Font/Font.js.map +1 -1
  61. package/lib/module/skia/types/index.js +0 -1
  62. package/lib/module/skia/types/index.js.map +1 -1
  63. package/lib/module/skia/web/JsiSkFont.js +0 -6
  64. package/lib/module/skia/web/JsiSkFont.js.map +1 -1
  65. package/lib/module/skia/web/JsiSkTextBlobFactory.js +1 -1
  66. package/lib/module/skia/web/JsiSkTextBlobFactory.js.map +1 -1
  67. package/lib/module/skia/web/JsiSkia.js +0 -2
  68. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  69. package/lib/module/values/hooks/useComputedValue.js +0 -4
  70. package/lib/module/values/hooks/useComputedValue.js.map +1 -1
  71. package/lib/module/views/SkiaView.web.js +53 -34
  72. package/lib/module/views/SkiaView.web.js.map +1 -1
  73. package/lib/typescript/src/renderer/Canvas.d.ts +1 -3
  74. package/lib/typescript/src/renderer/DrawingContext.d.ts +1 -2
  75. package/lib/typescript/src/renderer/processors/Font.d.ts +1 -5
  76. package/lib/typescript/src/skia/core/index.d.ts +0 -2
  77. package/lib/typescript/src/skia/types/Font/Font.d.ts +0 -12
  78. package/lib/typescript/src/skia/types/Skia.d.ts +0 -2
  79. package/lib/typescript/src/skia/types/index.d.ts +0 -1
  80. package/lib/typescript/src/skia/web/JsiSkFont.d.ts +1 -2
  81. package/lib/typescript/src/values/hooks/useComputedValue.d.ts +0 -1
  82. package/lib/typescript/src/views/SkiaView.web.d.ts +5 -5
  83. package/package.json +1 -1
  84. package/src/mock/index.ts +0 -4
  85. package/src/renderer/Canvas.tsx +5 -8
  86. package/src/renderer/DrawingContext.ts +1 -2
  87. package/src/renderer/components/text/Glyphs.tsx +2 -6
  88. package/src/renderer/components/text/Text.tsx +2 -3
  89. package/src/renderer/components/text/TextPath.tsx +2 -3
  90. package/src/renderer/processors/Font.ts +2 -25
  91. package/src/skia/core/Data.ts +8 -5
  92. package/src/skia/core/Image.ts +3 -1
  93. package/src/skia/core/SVG.ts +3 -1
  94. package/src/skia/core/Typeface.ts +4 -6
  95. package/src/skia/core/index.ts +0 -2
  96. package/src/skia/types/Font/Font.ts +0 -13
  97. package/src/skia/types/Skia.ts +0 -2
  98. package/src/skia/types/index.ts +0 -1
  99. package/src/skia/web/JsiSkFont.ts +0 -9
  100. package/src/skia/web/JsiSkTextBlobFactory.ts +1 -1
  101. package/src/skia/web/JsiSkia.ts +0 -2
  102. package/src/values/hooks/useComputedValue.ts +0 -5
  103. package/src/views/SkiaView.web.tsx +41 -46
  104. package/cpp/api/JsiSkFontMgr.h +0 -84
  105. package/cpp/api/JsiSkFontMgrFactory.h +0 -48
  106. package/lib/commonjs/skia/core/Paint.js +0 -28
  107. package/lib/commonjs/skia/core/Paint.js.map +0 -1
  108. package/lib/commonjs/skia/core/Path.js +0 -72
  109. package/lib/commonjs/skia/core/Path.js.map +0 -1
  110. package/lib/commonjs/skia/types/FontMgr/FontMgr.js +0 -6
  111. package/lib/commonjs/skia/types/FontMgr/FontMgr.js.map +0 -1
  112. package/lib/commonjs/skia/types/FontMgr/FontMgrFactory.js +0 -6
  113. package/lib/commonjs/skia/types/FontMgr/FontMgrFactory.js.map +0 -1
  114. package/lib/commonjs/skia/types/FontMgr/index.js +0 -32
  115. package/lib/commonjs/skia/types/FontMgr/index.js.map +0 -1
  116. package/lib/commonjs/skia/web/JsiSkFontMgr.js +0 -33
  117. package/lib/commonjs/skia/web/JsiSkFontMgr.js.map +0 -1
  118. package/lib/commonjs/skia/web/JsiSkFontMgrFactory.js +0 -25
  119. package/lib/commonjs/skia/web/JsiSkFontMgrFactory.js.map +0 -1
  120. package/lib/module/skia/core/Paint.js +0 -17
  121. package/lib/module/skia/core/Paint.js.map +0 -1
  122. package/lib/module/skia/core/Path.js +0 -53
  123. package/lib/module/skia/core/Path.js.map +0 -1
  124. package/lib/module/skia/types/FontMgr/FontMgr.js +0 -2
  125. package/lib/module/skia/types/FontMgr/FontMgr.js.map +0 -1
  126. package/lib/module/skia/types/FontMgr/FontMgrFactory.js +0 -2
  127. package/lib/module/skia/types/FontMgr/FontMgrFactory.js.map +0 -1
  128. package/lib/module/skia/types/FontMgr/index.js +0 -3
  129. package/lib/module/skia/types/FontMgr/index.js.map +0 -1
  130. package/lib/module/skia/web/JsiSkFontMgr.js +0 -23
  131. package/lib/module/skia/web/JsiSkFontMgr.js.map +0 -1
  132. package/lib/module/skia/web/JsiSkFontMgrFactory.js +0 -14
  133. package/lib/module/skia/web/JsiSkFontMgrFactory.js.map +0 -1
  134. package/lib/typescript/src/skia/core/Paint.d.ts +0 -6
  135. package/lib/typescript/src/skia/core/Path.d.ts +0 -21
  136. package/lib/typescript/src/skia/types/FontMgr/FontMgr.d.ts +0 -18
  137. package/lib/typescript/src/skia/types/FontMgr/FontMgrFactory.d.ts +0 -4
  138. package/lib/typescript/src/skia/types/FontMgr/index.d.ts +0 -2
  139. package/lib/typescript/src/skia/web/JsiSkFontMgr.d.ts +0 -9
  140. package/lib/typescript/src/skia/web/JsiSkFontMgrFactory.d.ts +0 -8
  141. package/src/skia/core/Paint.ts +0 -22
  142. package/src/skia/core/Path.ts +0 -60
  143. package/src/skia/types/FontMgr/FontMgr.ts +0 -24
  144. package/src/skia/types/FontMgr/FontMgrFactory.ts +0 -12
  145. package/src/skia/types/FontMgr/index.ts +0 -2
  146. package/src/skia/web/JsiSkFontMgr.ts +0 -38
  147. package/src/skia/web/JsiSkFontMgrFactory.ts +0 -18
@@ -56,19 +56,6 @@ Object.keys(_Surface).forEach(function (key) {
56
56
  });
57
57
  });
58
58
 
59
- var _FontMgr = require("./FontMgr");
60
-
61
- Object.keys(_FontMgr).forEach(function (key) {
62
- if (key === "default" || key === "__esModule") return;
63
- if (key in exports && exports[key] === _FontMgr[key]) return;
64
- Object.defineProperty(exports, key, {
65
- enumerable: true,
66
- get: function () {
67
- return _FontMgr[key];
68
- }
69
- });
70
- });
71
-
72
59
  var _Vertices = require("./Vertices");
73
60
 
74
61
  Object.keys(_Vertices).forEach(function (key) {
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["export * from \"./Picture\";\nexport * from \"./Data\";\nexport * from \"./SVG\";\nexport * from \"./Surface\";\nexport * from \"./FontMgr\";\nexport * from \"./Vertices\";\nexport * from \"./RuntimeEffect\";\nexport * from \"./Shader\";\nexport * from \"./Image\";\nexport * from \"./ColorFilter\";\nexport * from \"./ImageFilter\";\nexport * from \"./Font\";\nexport * from \"./Typeface\";\nexport * from \"./Paint\";\nexport * from \"./Path\";\nexport * from \"./Color\";\nexport * from \"./Canvas\";\nexport * from \"./ContourMeasure\";\nexport * from \"./MaskFilter\";\nexport * from \"./Matrix\";\nexport * from \"./PathEffect\";\nexport * from \"./Point\";\nexport * from \"./Rect\";\nexport * from \"./RRect\";\nexport * from \"./RSXform\";\nexport * from \"./JsiInstance\";\nexport * from \"./Skia\";\nexport * from \"./TextBlob\";\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["export * from \"./Picture\";\nexport * from \"./Data\";\nexport * from \"./SVG\";\nexport * from \"./Surface\";\nexport * from \"./Vertices\";\nexport * from \"./RuntimeEffect\";\nexport * from \"./Shader\";\nexport * from \"./Image\";\nexport * from \"./ColorFilter\";\nexport * from \"./ImageFilter\";\nexport * from \"./Font\";\nexport * from \"./Typeface\";\nexport * from \"./Paint\";\nexport * from \"./Path\";\nexport * from \"./Color\";\nexport * from \"./Canvas\";\nexport * from \"./ContourMeasure\";\nexport * from \"./MaskFilter\";\nexport * from \"./Matrix\";\nexport * from \"./PathEffect\";\nexport * from \"./Point\";\nexport * from \"./Rect\";\nexport * from \"./RRect\";\nexport * from \"./RSXform\";\nexport * from \"./JsiInstance\";\nexport * from \"./Skia\";\nexport * from \"./TextBlob\";\n"]}
@@ -16,12 +16,6 @@ class JsiSkFont extends _Host.HostObject {
16
16
  super(CanvasKit, ref, "Font");
17
17
  }
18
18
 
19
- measureText(_text, _paint) {
20
- console.warn(`measureText() is deprecated an returns an empty rectangle on React Native Web.
21
- Clients should use "Font.getGlyphWidths" instead (the latter does no shaping)`);
22
- return new _JsiSkRect.JsiSkRect(this.CanvasKit, this.CanvasKit.XYWHRect(0, 0, 0, 0));
23
- }
24
-
25
19
  getTextWidth(text, paint) {
26
20
  const ids = this.getGlyphIDs(text);
27
21
  const widths = this.getGlyphWidths(ids, paint);
@@ -1 +1 @@
1
- {"version":3,"sources":["JsiSkFont.ts"],"names":["JsiSkFont","HostObject","constructor","CanvasKit","ref","measureText","_text","_paint","console","warn","JsiSkRect","XYWHRect","getTextWidth","text","paint","ids","getGlyphIDs","widths","getGlyphWidths","reduce","a","b","getMetrics","result","ascent","descent","leading","bounds","undefined","str","numCodePoints","glyphs","getGlyphIntercepts","positions","top","bottom","map","p","getScaleX","getSize","getSkewX","isEmbolden","getTypeface","tf","JsiSkTypeface","setEdging","edging","setEmbeddedBitmaps","embeddedBitmaps","setHinting","hinting","setLinearMetrics","linearMetrics","setScaleX","sx","setSize","points","setSkewX","setEmbolden","embolden","setSubpixel","subpixel","setTypeface","face"],"mappings":";;;;;;;AAYA;;AACA;;AACA;;AAEO,MAAMA,SAAN,SAAwBC,gBAAxB,CAAmE;AACxEC,EAAAA,WAAW,CAACC,SAAD,EAAuBC,GAAvB,EAAkC;AAC3C,UAAMD,SAAN,EAAiBC,GAAjB,EAAsB,MAAtB;AACD;;AAEDC,EAAAA,WAAW,CAACC,KAAD,EAAgBC,MAAhB,EAA0C;AACnDC,IAAAA,OAAO,CAACC,IAAR,CACG;AACP,8EAFI;AAIA,WAAO,IAAIC,oBAAJ,CAAc,KAAKP,SAAnB,EAA8B,KAAKA,SAAL,CAAeQ,QAAf,CAAwB,CAAxB,EAA2B,CAA3B,EAA8B,CAA9B,EAAiC,CAAjC,CAA9B,CAAP;AACD;;AAEDC,EAAAA,YAAY,CAACC,IAAD,EAAeC,KAAf,EAA4C;AACtD,UAAMC,GAAG,GAAG,KAAKC,WAAL,CAAiBH,IAAjB,CAAZ;AACA,UAAMI,MAAM,GAAG,KAAKC,cAAL,CAAoBH,GAApB,EAAyBD,KAAzB,CAAf;AACA,WAAOG,MAAM,CAACE,MAAP,CAAc,CAACC,CAAD,EAAIC,CAAJ,KAAUD,CAAC,GAAGC,CAA5B,EAA+B,CAA/B,CAAP;AACD;;AAEDC,EAAAA,UAAU,GAAG;AACX,UAAMC,MAAM,GAAG,KAAKnB,GAAL,CAASkB,UAAT,EAAf;AACA,WAAO;AACLE,MAAAA,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asKit, Font } from \"canvaskit-wasm\";\n\nimport type {\n FontEdging,\n FontHinting,\n SkFont,\n SkPaint,\n SkPoint,\n SkRect,\n SkTypeface,\n} from \"../types\";\n\nimport { HostObject, toValue, ckEnum } from \"./Host\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { JsiSkTypeface } from \"./JsiSkTypeface\";\n\nexport class JsiSkFont extends HostObject<Font, \"Font\"> implements SkFont {\n constructor(CanvasKit: CanvasKit, ref: Font) {\n super(CanvasKit, ref, \"Font\");\n }\n\n measureText(_text: string, _paint?: SkPaint): SkRect {\n console.warn(\n `measureText() is deprecated an returns an empty rectangle on React Native Web.\nClients should use \"Font.getGlyphWidths\" instead (the latter does no shaping)`\n );\n return new JsiSkRect(this.CanvasKit, this.CanvasKit.XYWHRect(0, 0, 0, 0));\n }\n\n getTextWidth(text: string, paint?: SkPaint | undefined) {\n const ids = this.getGlyphIDs(text);\n const widths = this.getGlyphWidths(ids, paint);\n return widths.reduce((a, b) => a + b, 0);\n }\n\n getMetrics() {\n const result = this.ref.getMetrics();\n return {\n ascent: result.ascent,\n descent: result.descent,\n leading: result.leading,\n bounds: result.bounds\n ? new JsiSkRect(this.CanvasKit, result.bounds)\n : undefined,\n };\n }\n\n getGlyphIDs(str: string, numCodePoints?: number) {\n // TODO: Fix return value in the C++ implementation\n return [...this.ref.getGlyphIDs(str, numCodePoints)];\n }\n\n // TODO: Fix return value in the C++ implementation, it return float32\n getGlyphWidths(glyphs: number[], paint?: SkPaint | null) {\n return [...this.ref.getGlyphWidths(glyphs, paint ? toValue(paint) : null)];\n }\n\n getGlyphIntercepts(\n glyphs: number[],\n positions: SkPoint[],\n top: number,\n bottom: number\n ) {\n return [\n ...this.ref.getGlyphIntercepts(\n glyphs,\n positions.map((p) => toValue(p)),\n top,\n bottom\n ),\n ];\n }\n\n getScaleX() {\n return this.ref.getScaleX();\n }\n\n getSize() {\n return this.ref.getSize();\n }\n\n getSkewX() {\n return this.ref.getSkewX();\n }\n\n isEmbolden() {\n return this.ref.isEmbolden();\n }\n\n getTypeface() {\n const tf = this.ref.getTypeface();\n return tf ? new JsiSkTypeface(this.CanvasKit, tf) : null;\n }\n\n setEdging(edging: FontEdging) {\n this.ref.setEdging(ckEnum(edging));\n }\n\n setEmbeddedBitmaps(embeddedBitmaps: boolean) {\n this.ref.setEmbeddedBitmaps(embeddedBitmaps);\n }\n\n setHinting(hinting: FontHinting) {\n this.ref.setHinting(ckEnum(hinting));\n }\n\n setLinearMetrics(linearMetrics: boolean) {\n this.ref.setLinearMetrics(linearMetrics);\n }\n\n setScaleX(sx: number) {\n this.ref.setScaleX(sx);\n }\n\n setSize(points: number) {\n this.ref.setSize(points);\n }\n\n setSkewX(sx: number) {\n this.ref.setSkewX(sx);\n }\n\n setEmbolden(embolden: boolean) {\n this.ref.setEmbolden(embolden);\n }\n\n setSubpixel(subpixel: boolean) {\n this.ref.setSubpixel(subpixel);\n }\n\n setTypeface(face: SkTypeface | null) {\n this.ref.setTypeface(face ? toValue(face) : null);\n }\n}\n"]}
1
+ {"version":3,"sources":["JsiSkFont.ts"],"names":["JsiSkFont","HostObject","constructor","CanvasKit","ref","getTextWidth","text","paint","ids","getGlyphIDs","widths","getGlyphWidths","reduce","a","b","getMetrics","result","ascent","descent","leading","bounds","JsiSkRect","undefined","str","numCodePoints","glyphs","getGlyphIntercepts","positions","top","bottom","map","p","getScaleX","getSize","getSkewX","isEmbolden","getTypeface","tf","JsiSkTypeface","setEdging","edging","setEmbeddedBitmaps","embeddedBitmaps","setHinting","hinting","setLinearMetrics","linearMetrics","setScaleX","sx","setSize","points","setSkewX","setEmbolden","embolden","setSubpixel","subpixel","setTypeface","face"],"mappings":";;;;;;;AAWA;;AACA;;AACA;;AAEO,MAAMA,SAAN,SAAwBC,gBAAxB,CAAmE;AACxEC,EAAAA,WAAW,CAACC,SAAD,EAAuBC,GAAvB,EAAkC;AAC3C,UAAMD,SAAN,EAAiBC,GAAjB,EAAsB,MAAtB;AACD;;AAEDC,EAA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SAAK5C,GAAL,CAAS+C,QAAT,CAAkBH,EAAlB;AACD;;AAEDI,EAAAA,WAAW,CAACC,QAAD,EAAoB;AAC7B,SAAKjD,GAAL,CAASgD,WAAT,CAAqBC,QAArB;AACD;;AAEDC,EAAAA,WAAW,CAACC,QAAD,EAAoB;AAC7B,SAAKnD,GAAL,CAASkD,WAAT,CAAqBC,QAArB;AACD;;AAEDC,EAAAA,WAAW,CAACC,IAAD,EAA0B;AACnC,SAAKrD,GAAL,CAASoD,WAAT,CAAqBC,IAAI,GAAG,mBAAQA,IAAR,CAAH,GAAmB,IAA5C;AACD;;AA5GuE","sourcesContent":["import type { CanvasKit, Font } from \"canvaskit-wasm\";\n\nimport type {\n FontEdging,\n FontHinting,\n SkFont,\n SkPaint,\n SkPoint,\n SkTypeface,\n} from \"../types\";\n\nimport { HostObject, toValue, ckEnum } from \"./Host\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { JsiSkTypeface } from \"./JsiSkTypeface\";\n\nexport class JsiSkFont extends HostObject<Font, \"Font\"> implements SkFont {\n constructor(CanvasKit: CanvasKit, ref: Font) {\n super(CanvasKit, ref, \"Font\");\n }\n\n getTextWidth(text: string, paint?: SkPaint | undefined) {\n const ids = this.getGlyphIDs(text);\n const widths = this.getGlyphWidths(ids, paint);\n return widths.reduce((a, b) => a + b, 0);\n }\n\n getMetrics() {\n const result = this.ref.getMetrics();\n return {\n ascent: result.ascent,\n descent: result.descent,\n leading: result.leading,\n bounds: result.bounds\n ? new JsiSkRect(this.CanvasKit, result.bounds)\n : undefined,\n };\n }\n\n getGlyphIDs(str: string, numCodePoints?: number) {\n // TODO: Fix return value in the C++ implementation\n return [...this.ref.getGlyphIDs(str, numCodePoints)];\n }\n\n // TODO: Fix return value in the C++ implementation, it return float32\n getGlyphWidths(glyphs: number[], paint?: SkPaint | null) {\n return [...this.ref.getGlyphWidths(glyphs, paint ? toValue(paint) : null)];\n }\n\n getGlyphIntercepts(\n glyphs: number[],\n positions: SkPoint[],\n top: number,\n bottom: number\n ) {\n return [\n ...this.ref.getGlyphIntercepts(\n glyphs,\n positions.map((p) => toValue(p)),\n top,\n bottom\n ),\n ];\n }\n\n getScaleX() {\n return this.ref.getScaleX();\n }\n\n getSize() {\n return this.ref.getSize();\n }\n\n getSkewX() {\n return this.ref.getSkewX();\n }\n\n isEmbolden() {\n return this.ref.isEmbolden();\n }\n\n getTypeface() {\n const tf = this.ref.getTypeface();\n return tf ? new JsiSkTypeface(this.CanvasKit, tf) : null;\n }\n\n setEdging(edging: FontEdging) {\n this.ref.setEdging(ckEnum(edging));\n }\n\n setEmbeddedBitmaps(embeddedBitmaps: boolean) {\n this.ref.setEmbeddedBitmaps(embeddedBitmaps);\n }\n\n setHinting(hinting: FontHinting) {\n this.ref.setHinting(ckEnum(hinting));\n }\n\n setLinearMetrics(linearMetrics: boolean) {\n this.ref.setLinearMetrics(linearMetrics);\n }\n\n setScaleX(sx: number) {\n this.ref.setScaleX(sx);\n }\n\n setSize(points: number) {\n this.ref.setSize(points);\n }\n\n setSkewX(sx: number) {\n this.ref.setSkewX(sx);\n }\n\n setEmbolden(embolden: boolean) {\n this.ref.setEmbolden(embolden);\n }\n\n setSubpixel(subpixel: boolean) {\n this.ref.setSubpixel(subpixel);\n }\n\n setTypeface(face: SkTypeface | null) {\n this.ref.setTypeface(face ? toValue(face) : null);\n }\n}\n"]}
@@ -23,7 +23,7 @@ class JsiSkTextBlobFactory extends _Host.Host {
23
23
  }
24
24
 
25
25
  MakeFromRSXform(str, rsxforms, font) {
26
- return new _JsiSkTextBlob.JsiSkTextBlob(this.CanvasKit, this.CanvasKit.TextBlob.MakeFromRSXform(str, rsxforms.map(f => (0, _Host.toValue)(f)), (0, _Host.toValue)(font)));
26
+ return new _JsiSkTextBlob.JsiSkTextBlob(this.CanvasKit, this.CanvasKit.TextBlob.MakeFromRSXform(str, rsxforms.map(f => Array.from((0, _Host.toValue)(f))).flat(), (0, _Host.toValue)(font)));
27
27
  }
28
28
 
29
29
  MakeFromRSXformGlyphs(glyphs, rsxforms, font) {
@@ -1 +1 @@
1
- {"version":3,"sources":["JsiSkTextBlobFactory.ts"],"names":["JsiSkTextBlobFactory","Host","constructor","CanvasKit","MakeFromText","str","font","JsiSkTextBlob","TextBlob","MakeFromGlyphs","glyphs","MakeFromRSXform","rsxforms","map","f","MakeFromRSXformGlyphs"],"mappings":";;;;;;;AAKA;;AACA;;AAEO,MAAMA,oBAAN,SAAmCC,UAAnC,CAAmE;AACxEC,EAAAA,WAAW,CAACC,SAAD,EAAuB;AAChC,UAAMA,SAAN;AACD;;AAEDC,EAAAA,YAAY,CAACC,GAAD,EAAcC,IAAd,EAA4B;AACtC,WAAO,IAAIC,4BAAJ,CACL,KAAKJ,SADA,EAEL,KAAKA,SAAL,CAAeK,QAAf,CAAwBJ,YAAxB,CAAqCC,GAArC,EAA0C,mBAAQC,IAAR,CAA1C,CAFK,CAAP;AAID;;AAEDG,EAAAA,cAAc,CAACC,MAAD,EAAmBJ,IAAnB,EAAiC;AAC7C,WAAO,IAAIC,4BAAJ,CACL,KAAKJ,SADA,EAEL,KAAKA,SAAL,CAAeK,QAAf,CAAwBC,cAAxB,CAAuCC,MAAvC,EAA+C,mBAAQJ,IAAR,CAA/C,CAFK,CAAP;AAID;;AAEDK,EAAAA,eAAe,CAACN,GAAD,EAAcO,QAAd,EAAqCN,IAArC,EAAmD;AAChE,WAAO,IAAIC,4BAAJ,CACL,KAAKJ,SADA,EAEL,KAAKA,SAAL,CAAeK,QAAf,CAAwBG,eAAxB,CACEN,GADF,EAEEO,QAAQ,CAACC,GAAT,CAAcC,CAAD,IAAO,mBAAQA,CAAR,CAApB,CAFF,EAGE,mBAAQR,IAAR,CAHF,CAFK,CAAP;AAQD;;AAEDS,EAAAA,qBAAqB,CAACL,MAAD,EAAmBE,QAAnB,EAA0CN,IAA1C,EAAwD;AAC3E,WAAO,IAAIC,4BAAJ,CACL,KAAKJ,SADA,EAEL,KAAKA,SAAL,CAAeK,QAAf,CAAwBO,qBAAxB,CACEL,MADF,EAEEE,QAAQ,CAACC,GAAT,CAAcC,CAAD,IAAO,mBAAQA,CAAR,CAApB,CAFF,EAGE,mBAAQR,IAAR,CAHF,CAFK,CAAP;AAQD;;AAvCuE","sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type { SkFont, SkRSXform } from \"../types\";\nimport type { TextBlobFactory } from \"../types/TextBlob\";\n\nimport { Host, toValue } from \"./Host\";\nimport { JsiSkTextBlob } from \"./JsiSkTextBlob\";\n\nexport class JsiSkTextBlobFactory extends Host implements TextBlobFactory {\n constructor(CanvasKit: CanvasKit) {\n super(CanvasKit);\n }\n\n MakeFromText(str: string, font: SkFont) {\n return new JsiSkTextBlob(\n this.CanvasKit,\n this.CanvasKit.TextBlob.MakeFromText(str, toValue(font))\n );\n }\n\n MakeFromGlyphs(glyphs: number[], font: SkFont) {\n return new JsiSkTextBlob(\n this.CanvasKit,\n this.CanvasKit.TextBlob.MakeFromGlyphs(glyphs, toValue(font))\n );\n }\n\n MakeFromRSXform(str: string, rsxforms: SkRSXform[], font: SkFont) {\n return new JsiSkTextBlob(\n this.CanvasKit,\n this.CanvasKit.TextBlob.MakeFromRSXform(\n str,\n rsxforms.map((f) => toValue(f)),\n toValue(font)\n )\n );\n }\n\n MakeFromRSXformGlyphs(glyphs: number[], rsxforms: SkRSXform[], font: SkFont) {\n return new JsiSkTextBlob(\n this.CanvasKit,\n this.CanvasKit.TextBlob.MakeFromRSXformGlyphs(\n glyphs,\n rsxforms.map((f) => toValue(f)),\n toValue(font)\n )\n );\n }\n}\n"]}
1
+ {"version":3,"sources":["JsiSkTextBlobFactory.ts"],"names":["JsiSkTextBlobFactory","Host","constructor","CanvasKit","MakeFromText","str","font","JsiSkTextBlob","TextBlob","MakeFromGlyphs","glyphs","MakeFromRSXform","rsxforms","map","f","Array","from","flat","MakeFromRSXformGlyphs"],"mappings":";;;;;;;AAKA;;AACA;;AAEO,MAAMA,oBAAN,SAAmCC,UAAnC,CAAmE;AACxEC,EAAAA,WAAW,CAACC,SAAD,EAAuB;AAChC,UAAMA,SAAN;AACD;;AAEDC,EAAAA,YAAY,CAACC,GAAD,EAAcC,IAAd,EAA4B;AACtC,WAAO,IAAIC,4BAAJ,CACL,KAAKJ,SADA,EAEL,KAAKA,SAAL,CAAeK,QAAf,CAAwBJ,YAAxB,CAAqCC,GAArC,EAA0C,mBAAQC,IAAR,CAA1C,CAFK,CAAP;AAID;;AAEDG,EAAAA,cAAc,CAACC,MAAD,EAAmBJ,IAAnB,EAAiC;AAC7C,WAAO,IAAIC,4BAAJ,CACL,KAAKJ,SADA,EAEL,KAAKA,SAAL,CAAeK,QAAf,CAAwBC,cAAxB,CAAuCC,MAAvC,EAA+C,mBAAQJ,IAAR,CAA/C,CAFK,CAAP;AAID;;AAEDK,EAAAA,eAAe,CAACN,GAAD,EAAcO,QAAd,EAAqCN,IAArC,EAAmD;AAChE,WAAO,IAAIC,4BAAJ,CACL,KAAKJ,SADA,EAEL,KAAKA,SAAL,CAAeK,QAAf,CAAwBG,eAAxB,CACEN,GADF,EAEEO,QAAQ,CAACC,GAAT,CAAcC,CAAD,IAAOC,KAAK,CAACC,IAAN,CAAW,mBAAsBF,CAAtB,CAAX,CAApB,EAA0DG,IAA1D,EAFF,EAGE,mBAAQX,IAAR,CAHF,CAFK,CAAP;AAQD;;AAEDY,EAAAA,qBAAqB,CAACR,MAAD,EAAmBE,QAAnB,EAA0CN,IAA1C,EAAwD;AAC3E,WAAO,IAAIC,4BAAJ,CACL,KAAKJ,SADA,EAEL,KAAKA,SAAL,CAAeK,QAAf,CAAwBU,qBAAxB,CACER,MADF,EAEEE,QAAQ,CAACC,GAAT,CAAcC,CAAD,IAAO,mBAAQA,CAAR,CAApB,CAFF,EAGE,mBAAQR,IAAR,CAHF,CAFK,CAAP;AAQD;;AAvCuE","sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type { SkFont, SkRSXform } from \"../types\";\nimport type { TextBlobFactory } from \"../types/TextBlob\";\n\nimport { Host, toValue } from \"./Host\";\nimport { JsiSkTextBlob } from \"./JsiSkTextBlob\";\n\nexport class JsiSkTextBlobFactory extends Host implements TextBlobFactory {\n constructor(CanvasKit: CanvasKit) {\n super(CanvasKit);\n }\n\n MakeFromText(str: string, font: SkFont) {\n return new JsiSkTextBlob(\n this.CanvasKit,\n this.CanvasKit.TextBlob.MakeFromText(str, toValue(font))\n );\n }\n\n MakeFromGlyphs(glyphs: number[], font: SkFont) {\n return new JsiSkTextBlob(\n this.CanvasKit,\n this.CanvasKit.TextBlob.MakeFromGlyphs(glyphs, toValue(font))\n );\n }\n\n MakeFromRSXform(str: string, rsxforms: SkRSXform[], font: SkFont) {\n return new JsiSkTextBlob(\n this.CanvasKit,\n this.CanvasKit.TextBlob.MakeFromRSXform(\n str,\n rsxforms.map((f) => Array.from(toValue<Float32Array>(f))).flat(),\n toValue(font)\n )\n );\n }\n\n MakeFromRSXformGlyphs(glyphs: number[], rsxforms: SkRSXform[], font: SkFont) {\n return new JsiSkTextBlob(\n this.CanvasKit,\n this.CanvasKit.TextBlob.MakeFromRSXformGlyphs(\n glyphs,\n rsxforms.map((f) => toValue(f)),\n toValue(font)\n )\n );\n }\n}\n"]}
@@ -53,8 +53,6 @@ var _JsiSkSVGFactory = require("./JsiSkSVGFactory");
53
53
 
54
54
  var _JsiSkTextBlobFactory = require("./JsiSkTextBlobFactory");
55
55
 
56
- var _JsiSkFontMgrFactory = require("./JsiSkFontMgrFactory");
57
-
58
56
  var _JsiSkFont = require("./JsiSkFont");
59
57
 
60
58
  var _JsiSkVerticesFactory = require("./JsiSkVerticesFactory");
@@ -86,7 +84,6 @@ const JsiSkApi = CanvasKit => ({
86
84
  Image: new _JsiSkImageFactory.JsiSkImageFactory(CanvasKit),
87
85
  SVG: new _JsiSkSVGFactory.JsiSkSVGFactory(CanvasKit),
88
86
  TextBlob: new _JsiSkTextBlobFactory.JsiSkTextBlobFactory(CanvasKit),
89
- FontMgr: new _JsiSkFontMgrFactory.JsiSkFontMgrFactory(CanvasKit),
90
87
  XYWHRect: (x, y, width, height) => {
91
88
  return new _JsiSkRect.JsiSkRect(CanvasKit, CanvasKit.XYWHRect(x, y, width, height));
92
89
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["JsiSkia.ts"],"names":["JsiSkApi","CanvasKit","Point","x","y","JsiSkPoint","Float32Array","of","RuntimeShaderBuilder","_","Error","RRectXY","rect","rx","ry","JsiSkRRect","RSXform","scos","ssin","tx","ty","JsiSkRSXform","Color","ContourMeasureIter","path","forceClosed","resScale","JsiSkContourMeasureIter","Paint","JsiSkPaint","PictureRecorder","JsiSkPictureRecorder","Picture","JsiSkPictureFactory","Path","JsiSkPathFactory","Matrix","matrix","JsiSkMatrix","identity","ColorFilter","JsiSkColorFilterFactory","Font","typeface","size","JsiSkFont","undefined","Typeface","JsiSkTypefaceFactory","MaskFilter","JsiSkMaskFilterFactory","RuntimeEffect","JsiSkRuntimeEffectFactory","ImageFilter","JsiSkImageFilterFactory","Shader","JsiSkShaderFactory","PathEffect","JsiSkPathEffectFactory","MakeVertices","bind","Data","JsiSkDataFactory","Image","JsiSkImageFactory","SVG","JsiSkSVGFactory","TextBlob","JsiSkTextBlobFactory","FontMgr","JsiSkFontMgrFactory","XYWHRect","width","height","JsiSkRect","Surface","JsiSkSurfaceFactory"],"mappings":";;;;;;;AAYA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEO,MAAMA,QAAQ,GAAIC,SAAD,KAAiC;AACvDC,EAAAA,KAAK,EAAE,CAACC,CAAD,EAAYC,CAAZ,KACL,IAAIC,sBAAJ,CAAeJ,SAAf,EAA0BK,YAAY,CAACC,EAAb,CAAgBJ,CAAhB,EAAmBC,CAAnB,CAA1B,CAFqD;AAGvDI,EAAAA,oBAAo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AO,EAAE,IAAIC,wCAAJ,CAAwBrE,SAAxB,CApD8C;AAqDvDsE,EAAAA,QAAQ,EAAE,CAACpE,CAAD,EAAYC,CAAZ,EAAuBoE,KAAvB,EAAsCC,MAAtC,KAAyD;AACjE,WAAO,IAAIC,oBAAJ,CAAczE,SAAd,EAAyBA,SAAS,CAACsE,QAAV,CAAmBpE,CAAnB,EAAsBC,CAAtB,EAAyBoE,KAAzB,EAAgCC,MAAhC,CAAzB,CAAP;AACD,GAvDsD;AAwDvDE,EAAAA,OAAO,EAAE,IAAIC,wCAAJ,CAAwB3E,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":["JsiSkApi","CanvasKit","Point","x","y","JsiSkPoint","Float32Array","of","RuntimeShaderBuilder","_","Error","RRectXY","rect","rx","ry","JsiSkRRect","RSXform","scos","ssin","tx","ty","JsiSkRSXform","Color","ContourMeasureIter","path","forceClosed","resScale","JsiSkContourMeasureIter","Paint","JsiSkPaint","PictureRecorder","JsiSkPictureRecorder","Picture","JsiSkPictureFactory","Path","JsiSkPathFactory","Matrix","matrix","JsiSkMatrix","identity","ColorFilter","JsiSkColorFilterFactory","Font","typeface","size","JsiSkFont","undefined","Typeface","JsiSkTypefaceFactory","MaskFilter","JsiSkMaskFilterFactory","RuntimeEffect","JsiSkRuntimeEffectFactory","ImageFilter","JsiSkImageFilterFactory","Shader","JsiSkShaderFactory","PathEffect","JsiSkPathEffectFactory","MakeVertices","bind","Data","JsiSkDataFactory","Image","JsiSkImageFactory","SVG","JsiSkSVGFactory","TextBlob","Js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CvDwD,EAAAA,UAAU,EAAE,IAAIC,8CAAJ,CAA2BzD,SAA3B,CA9C2C;AA+CvD0D,EAAAA,YAAY,EAAEA,mCAAaC,IAAb,CAAkB,IAAlB,EAAwB3D,SAAxB,CA/CyC;AAgDvD4D,EAAAA,IAAI,EAAE,IAAIC,kCAAJ,CAAqB7D,SAArB,CAhDiD;AAiDvD8D,EAAAA,KAAK,EAAE,IAAIC,oCAAJ,CAAsB/D,SAAtB,CAjDgD;AAkDvDgE,EAAAA,GAAG,EAAE,IAAIC,gCAAJ,CAAoBjE,SAApB,CAlDkD;AAmDvDkE,EAAAA,QAAQ,EAAE,IAAIC,0CAAJ,CAAyBnE,SAAzB,CAnD6C;AAoDvDoE,EAAAA,QAAQ,EAAE,CAAClE,CAAD,EAAYC,CAAZ,EAAuBkE,KAAvB,EAAsCC,MAAtC,KAAyD;AACjE,WAAO,IAAIC,oBAAJ,CAAcvE,SAAd,EAAyBA,SAAS,CAACoE,QAAV,CAAmBlE,CAAnB,EAAsBC,CAAtB,EAAyBkE,KAAzB,EAAgCC,MAAhC,CAAzB,CAAP;AACD,GAtDsD;AAuDvDE,EAAAA,OAAO,EAAE,IAAIC,wCAAJ,CAAwBzE,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"]}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useDerivedValue = exports.useComputedValue = void 0;
6
+ exports.useComputedValue = void 0;
7
7
 
8
8
  var _react = require("react");
9
9
 
@@ -22,11 +22,4 @@ const useComputedValue = (cb, values) => (0, _react.useMemo)(() => _api.ValueApi
22
22
  values);
23
23
 
24
24
  exports.useComputedValue = useComputedValue;
25
-
26
- const useDerivedValue = (cb, values) => {
27
- console.warn("useDerivedValue is deprecated. Use useComputedValue instead.");
28
- return useComputedValue(cb, values);
29
- };
30
-
31
- exports.useDerivedValue = useDerivedValue;
32
25
  //# sourceMappingURL=useComputedValue.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["useComputedValue.ts"],"names":["useComputedValue","cb","values","ValueApi","createComputedValue","filter","isValue","useDerivedValue","console","warn"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,gBAAgB,GAAG,CAAIC,EAAJ,EAAiBC,MAAjB,KAC9B,oBACE,MAAMC,cAASC,mBAAT,CAAgCH,EAAhC,EAAoCC,MAAM,CAACG,MAAP,CAAcC,mBAAd,CAApC,CADR,EAEE;AACAJ,MAHF,CADK;;;;AAOA,MAAMK,eAAe,GAAG,CAAIN,EAAJ,EAAiBC,MAAjB,KAAuC;AACpEM,EAAAA,OAAO,CAACC,IAAR,CAAa,8DAAb;AACA,SAAOT,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":["useComputedValue","cb","values","ValueApi","createComputedValue","filter","isValue"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,gBAAgB,GAAG,CAAIC,EAAJ,EAAiBC,MAAjB,KAC9B,oBACE,MAAMC,cAASC,mBAAT,CAAgCH,EAAhC,EAAoCC,MAAM,CAACG,MAAP,CAAcC,mBAAd,CAApC,CADR,EAEE;AACAJ,MAHF,CADK","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"]}
@@ -19,6 +19,8 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
19
19
 
20
20
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
21
 
22
+ const pd = _reactNative.PixelRatio.get();
23
+
22
24
  class SkiaView extends _react.default.Component {
23
25
  constructor(props) {
24
26
  var _props$mode;
@@ -39,12 +41,12 @@ class SkiaView extends _react.default.Component {
39
41
 
40
42
  _defineProperty(this, "_redrawRequests", 0);
41
43
 
42
- _defineProperty(this, "_unmounted", false);
44
+ _defineProperty(this, "width", 0);
45
+
46
+ _defineProperty(this, "height", 0);
47
+
48
+ _defineProperty(this, "requestId", 0);
43
49
 
44
- this.state = {
45
- width: -1,
46
- height: -1
47
- };
48
50
  this._mode = (_props$mode = props.mode) !== null && _props$mode !== void 0 ? _props$mode : "default";
49
51
  }
50
52
 
@@ -55,21 +57,30 @@ class SkiaView extends _react.default.Component {
55
57
  }
56
58
 
57
59
  onLayout(evt) {
58
- this.setState({
59
- width: evt.nativeEvent.layout.width,
60
- height: evt.nativeEvent.layout.height
61
- }, () => {
62
- // Reset canvas / surface on layout change
63
- if (this._canvasRef.current) {
64
- // Create surface
65
- this._surface = new _JsiSkSurface.JsiSkSurface(global.CanvasKit, global.CanvasKit.MakeWebGLCanvasSurface(this._canvasRef.current)); // Get canvas and repaint
66
-
67
- if (this._surface) {
68
- this._canvas = this._surface.getCanvas();
69
- this.redraw();
70
- }
60
+ const {
61
+ CanvasKit
62
+ } = global;
63
+ const {
64
+ width,
65
+ height
66
+ } = evt.nativeEvent.layout;
67
+ this.width = width;
68
+ this.height = height; // Reset canvas / surface on layout change
69
+
70
+ if (this._canvasRef.current) {
71
+ const canvas = this._canvasRef.current;
72
+ canvas.width = canvas.clientWidth * pd;
73
+ canvas.height = canvas.clientHeight * pd;
74
+ const surface = CanvasKit.MakeWebGLCanvasSurface(this._canvasRef.current);
75
+
76
+ if (!surface) {
77
+ throw new Error("Could not create surface");
71
78
  }
72
- });
79
+
80
+ this._surface = new _JsiSkSurface.JsiSkSurface(CanvasKit, surface);
81
+ this._canvas = this._surface.getCanvas();
82
+ this.redraw();
83
+ }
73
84
  }
74
85
 
75
86
  componentDidMount() {
@@ -77,11 +88,13 @@ class SkiaView extends _react.default.Component {
77
88
  this.tick();
78
89
  }
79
90
 
91
+ componentDidUpdate() {
92
+ this.redraw();
93
+ }
94
+
80
95
  componentWillUnmount() {
81
96
  this.unsubscribeAll();
82
- this._surface = null;
83
- this._canvas = null;
84
- this._unmounted = true;
97
+ cancelAnimationFrame(this.requestId);
85
98
  }
86
99
  /**
87
100
  * Creates a snapshot from the canvas in the surface
@@ -104,26 +117,31 @@ class SkiaView extends _react.default.Component {
104
117
  if (this._mode === "continuous" || this._redrawRequests > 0) {
105
118
  this._redrawRequests = 0;
106
119
 
107
- if (this._canvas && this.props.onDraw && this.state.height !== -1 && this.state.width !== -1) {
120
+ if (this._canvas && this.props.onDraw) {
108
121
  var _this$_surface2;
109
122
 
110
123
  const touches = [...this._touches];
111
124
  this._touches = [];
112
125
  const info = {
113
- height: this.state.height,
114
- width: this.state.width,
126
+ height: this.height,
127
+ width: this.width,
115
128
  timestamp: Date.now(),
116
129
  touches: touches.map(t => [t])
117
130
  };
118
- this.props.onDraw && this.props.onDraw(this._canvas, info);
119
- (_this$_surface2 = this._surface) === null || _this$_surface2 === void 0 ? void 0 : _this$_surface2.ref.flush();
120
- }
121
- } // Always request a new redraw as long as we're not unmounted
122
131
 
132
+ if (this.props.onDraw) {
133
+ const canvas = this._canvas;
134
+ canvas.save();
135
+ canvas.scale(pd, pd);
136
+ this.props.onDraw(canvas, info);
137
+ canvas.restore();
138
+ }
123
139
 
124
- if (!this._unmounted) {
125
- requestAnimationFrame(this.tick.bind(this));
140
+ (_this$_surface2 = this._surface) === null || _this$_surface2 === void 0 ? void 0 : _this$_surface2.ref.flush();
141
+ }
126
142
  }
143
+
144
+ this.requestId = requestAnimationFrame(this.tick.bind(this));
127
145
  }
128
146
 
129
147
  redraw() {
@@ -189,8 +207,10 @@ class SkiaView extends _react.default.Component {
189
207
  onLayout: this.onLayout.bind(this)
190
208
  }), /*#__PURE__*/_react.default.createElement("canvas", {
191
209
  ref: this._canvasRef,
192
- width: this.state.width,
193
- height: this.state.height,
210
+ style: {
211
+ display: "flex",
212
+ flex: 1
213
+ },
194
214
  onPointerDown: this.createTouchHandler(_types.TouchType.Start),
195
215
  onPointerMove: this.createTouchHandler(_types.TouchType.Active),
196
216
  onPointerUp: this.createTouchHandler(_types.TouchType.End),
@@ -1 +1 @@
1
- {"version":3,"sources":["SkiaView.web.tsx"],"names":["SkiaView","React","Component","constructor","props","createRef","state","width","height","_mode","mode","unsubscribeAll","_unsubscriptions","forEach","u","onLayout","evt","setState","nativeEvent","layout","_canvasRef","current","_surface","JsiSkSurface","global","CanvasKit","MakeWebGLCanvasSurface","_canvas","getCanvas","redraw","componentDidMount","tick","componentWillUnmount","_unmounted","makeImageSnapshot","rect","_redrawRequests","onDraw","touches","_touches","info","timestamp","Date","now","map","t","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","TouchType","Start","Active","End","Cancelled"],"mappings":";;;;;;;AACA;;AAGA;;AAIA;;AAGA;;;;;;;;AAEO,MAAMA,QAAN,SAAuBC,eAAMC,SAA7B,CAGL;AACAC,EAAAA,WAAW,CAACC,KAAD,EAAuB;AAAA;;AAChC,UAAMA,KAAN;;AADgC,sCAMM,IANN;;AAAA,8CAOY,EAPZ;;AAAA,sCAQG,EARH;;AAAA,qCASC,IATD;;AAAA,qDAUuBH,eAAMI,SAAN,EAVvB;;AAAA;;AAAA,6CAYR,CAZQ;;AAAA,wCAab,KAba;;AAEhC,SAAKC,KAAL,GAAa;AAAEC,MAAAA,KAAK,EAAE,CAAC,CAAV;AAAaC,MAAAA,MAAM,EAAE,CAAC;AAAtB,KAAb;AACA,SAAKC,KAAL,kBAAaL,KAAK,CAACM,IAAnB,qDAA2B,SAA3B;AACD;;AAWOC,EAAAA,cAAc,GAAG;AACvB,SAAKC,gBAAL,CAAsBC,OAAtB,CAA+BC,CAAD,IAAOA,CAAC,EAAtC;;AACA,SAAKF,gBAAL,GAAwB,EAAxB;AACD;;AAEOG,EAAAA,QAAQ,CAACC,GAAD,EAAyB;AACvC,SAAKC,QAAL,CACE;AACEV,MAAAA,KAAK,EAAES,GAAG,CAACE,WAAJ,CAAgBC,MAAhB,CAAuBZ,KADhC;AAEEC,MAAAA,MAAM,EAAEQ,GAAG,CAACE,WAAJ,CAAgBC,MAAhB,CAAuBX;AAFjC,KADF,EAKE,MAAM;AACJ;AACA,UAAI,KAAKY,UAAL,CAAgBC,OAApB,EAA6B;AAC3B;AACA,aAAKC,QAAL,GAAgB,IAAIC,0BAAJ,CACdC,MAAM,CAACC,SADO,EAEdD,MAAM,CAACC,SAAP,CAAiBC,sBAAjB,CAAwC,KAAKN,UAAL,CAAgBC,OAAxD,CAFc,CAAhB,CAF2B,CAM3B;;AACA,YAAI,KAAKC,Q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b,SALW;AAMjBhB,MAAAA,SAAS,EAAEC,IAAI,CAACC,GAAL;AANM,KAAnB;;AAQA,SAAKd,MAAL;AACD;;AAED0C,EAAAA,kBAAkB,CAACd,SAAD,EAAuB;AACvC,WAAQzC,GAAD,IAAuB,KAAKwC,gBAAL,CAAsBxC,GAAtB,EAA2ByC,SAA3B,CAA9B;AACD;;AAEDe,EAAAA,MAAM,GAAG;AACP,UAAM;AAAE9D,MAAAA,IAAF;AAAQ+D,MAAAA,KAAK,GAAG,KAAhB;AAAuB,SAAGC;AAA1B,QAAwC,KAAKtE,KAAnD;AACA,wBACE,6BAAC,iBAAD,eAAUsE,SAAV;AAAqB,MAAA,QAAQ,EAAE,KAAK3D,QAAL,CAAckC,IAAd,CAAmB,IAAnB;AAA/B,qBACE;AACE,MAAA,GAAG,EAAE,KAAK7B,UADZ;AAEE,MAAA,KAAK,EAAE,KAAKd,KAAL,CAAWC,KAFpB;AAGE,MAAA,MAAM,EAAE,KAAKD,KAAL,CAAWE,MAHrB;AAIE,MAAA,aAAa,EAAE,KAAK+D,kBAAL,CAAwBI,iBAAUC,KAAlC,CAJjB;AAKE,MAAA,aAAa,EAAE,KAAKL,kBAAL,CAAwBI,iBAAUE,MAAlC,CALjB;AAME,MAAA,WAAW,EAAE,KAAKN,kBAAL,CAAwBI,iBAAUG,GAAlC,CANf;AAOE,MAAA,eAAe,EAAE,KAAKP,kBAAL,CAAwBI,iBAAUI,SAAlC,CAPnB;AAQE,MAAA,cAAc,EAAE,KAAKR,kBAAL,CAAwBI,iBAAUG,GAAlC,CARlB;AASE,MAAA,YAAY,EAAE,KAAKP,kBAAL,CAAwBI,iBAAUG,GAAlC;AAThB,MADF,CADF;AAeD;;AArKD","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.redraw();\n }\n }\n }\n );\n }\n\n componentDidMount() {\n // Start render loop\n this.tick();\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 tick() {\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.map((t) => [t]),\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.tick.bind(this));\n }\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 width={this.state.width}\n height={this.state.height}\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"]}
1
+ {"version":3,"sources":["SkiaView.web.tsx"],"names":["pd","PixelRatio","get","SkiaView","React","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","JsiSkSurface","_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","TouchType","Start","Active","End","Cancelled"],"mappings":";;;;;;;AACA;;AAGA;;AAIA;;AAGA;;;;;;;;AAEA,MAAMA,EAAE,GAAGC,wBAAWC,GAAX,EAAX;;AAEO,MAAMC,QAAN,SAAuBC,eAAMC,SAA7B,CAAsD;AAC3DC,EAAAA,WAAW,CAACC,KAAD,EAAuB;AAAA;;AAChC,UAAMA,KAAN;;AADgC,sCAKM,IALN;;AAAA,8CAMY,EANZ;;AAAA,sCAOG,EAPH;;AAAA,qCAQC,IARD;;AAAA,qDASbH,eAAMI,SAAN,EATa;;AAAA;;AAAA,6CAWR,CAXQ;;AAAA,mCAYlB,CAZkB;;AAAA,oCAajB,CAbiB;;AAAA,uCAcd,CAdc;;AAEhC,SAAKC,KAAL,kBAAaF,KAAK,CAACG,IAAnB,qDAA2B,SAA3B;AACD;;AAaOC,EAAAA,cAAc,GAAG;AACvB,SAAKC,gBAAL,CAAsBC,OAAtB,CAA+BC,CAAD,IAAOA,CAAC,EAAtC;;AACA,SAAKF,gBAAL,GAAwB,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B,IAAnB;AAA/B,qBACE;AACE,MAAA,GAAG,EAAE,KAAKrC,UADZ;AAEE,MAAA,KAAK,EAAE;AAAE+D,QAAAA,OAAO,EAAE,MAAX;AAAmBC,QAAAA,IAAI,EAAE;AAAzB,OAFT;AAGE,MAAA,aAAa,EAAE,KAAKL,kBAAL,CAAwBM,iBAAUC,KAAlC,CAHjB;AAIE,MAAA,aAAa,EAAE,KAAKP,kBAAL,CAAwBM,iBAAUE,MAAlC,CAJjB;AAKE,MAAA,WAAW,EAAE,KAAKR,kBAAL,CAAwBM,iBAAUG,GAAlC,CALf;AAME,MAAA,eAAe,EAAE,KAAKT,kBAAL,CAAwBM,iBAAUI,SAAlC,CANnB;AAOE,MAAA,cAAc,EAAE,KAAKV,kBAAL,CAAwBM,iBAAUG,GAAlC,CAPlB;AAQE,MAAA,YAAY,EAAE,KAAKT,kBAAL,CAAwBM,iBAAUG,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"]}
@@ -45,12 +45,8 @@ export const Mock = {
45
45
  useFont: Noop,
46
46
  useTypeface: Noop,
47
47
  useImage: Noop,
48
- usePath: Noop,
49
48
  useSVG: Noop,
50
- useTextPath: Noop,
51
- usePaint: Noop,
52
49
  usePicture: Noop,
53
- useSvgPath: Noop,
54
50
  // 3. Point/Rect/Transform utilities
55
51
  vec,
56
52
  rect: (x, y, width, height) => ({
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":["Values","ValuesHooks","BaseSkia","useSharedValueEffect","timingFunctions","springFunctions","decayFunctions","interpolateFn","interpolatePathFn","interpolateVectorFn","ShaderLib","Stub","constructor","Proxy","get","apply","set","Noop","Skia","vec","x","y","Mock","useDataCollection","useRawData","useData","useFont","useTypeface","useImage","usePath","useSVG","useTextPath","usePaint","usePicture","useSvgPath","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","interpolateColors","_value","_inputRange","_outputRange","Float32Array","of","mixColors","_v","_x","_y","createDrawing","createDeclaration"],"mappings":"AAAA;AAGA,OAAO,KAAKA,MAAZ,MAAwB,eAAxB;AACA,OAAO,KAAKC,WAAZ,MAA6B,iBAA7B;AACA,OAAO,KAAKC,QAAZ,MAA0B,eAA1B;AAKA,SAASC,oBAAT,QAAqC,6CAArC;AACA,OAAO,KAAKC,eAAZ,MAAiC,qBAAjC;AACA,OAAO,KAAKC,eAAZ,MAAiC,qBAAjC;AACA,OAAO,KAAKC,cAAZ,MAAgC,oBAAhC;AACA,OAAO,KAAKC,aAAZ,MAA+B,oCAA/B;AACA,OAAO,KAAKC,iBAAZ,MAAmC,yCAAnC;AACA,OAAO,KAAKC,mBAAZ,MAAqC,0CAArC;AACA,SAASC,SAAT,QAA0B,0CAA1B;;AAEA,MAAMC,IAAN,CAAW;AACTC,EAAAA,WAAW,GAAG;AACZ,WAAO,IAAIC,KAAJ,CAAU,MAAM,CAAE,CAAlB,EAAoB;AACzBC,MAAAA,GAAG,EAAE,MAAM,IAAIH,IAAJ,EADc;AAEzBI,MAAAA,KAAK,EAAE,MAAM,IAAIJ,IAAJ,EAFY;AAGzBK,MAAAA,GAAG,EAAE,MAAM;AAHc,KAApB,CAAP;AAKD;;AAPQ;;AAUX,MAAMC,IAAe,GAAG,MAAM,CAAE,CAAhC;;AAEA,OAAO,MAAMC,IAAa,GAAG,IAAIP,IAAJ,EAAtB;AAEP,OAAO,MAAMQ,GAAG,GAAG,CAACC,CAAD,EAAa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J,KAAGC,eArDC;AAsDJ,KAAGC,cAtDC;AAuDJ,KAAGC,aAvDC;AAwDJ,KAAGC,iBAxDC;AAyDJ,KAAGC,mBAzDC;AA0DJoD,EAAAA,iBAAiB,EAAE,CACjBC,MADiB,EAEjBC,WAFiB,EAGjBC,YAHiB,KAIdC,YAAY,CAACC,EAAb,CAAgB,CAAhB,EAAmB,CAAnB,EAAsB,CAAtB,EAAyB,CAAzB,CA9DD;AA+DJC,EAAAA,SAAS,EAAE,CAACC,EAAD,EAAaC,EAAb,EAAwBC,EAAxB,KAAsCL,YAAY,CAACC,EAAb,CAAgB,CAAhB,EAAmB,CAAnB,EAAsB,CAAtB,EAAyB,CAAzB,CA/D7C;AAgEJxD,EAAAA,SAhEI;AAiEJ6D,EAAAA,aAAa,EAAEtD,IAjEX;AAkEJuD,EAAAA,iBAAiB,EAAEvD;AAlEf,CAPC","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 * as BaseSkia from \"../skia/types\";\nimport type * as SkiaExports from \"../skia\";\nimport type * as ExternalExports from \"../external\";\nimport type * as ValueExports from \"../values\";\nimport type * as AnimationExports from \"../animation\";\nimport { useSharedValueEffect } from \"../external/reanimated/useSharedValueEffect\";\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 ExternalExports &\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 useDataCollection: Noop,\n useRawData: Noop,\n useData: Noop,\n useFont: Noop,\n useTypeface: Noop,\n useImage: Noop,\n usePath: Noop,\n useSVG: Noop,\n useTextPath: Noop,\n usePaint: Noop,\n usePicture: Noop,\n useSvgPath: 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 // ExternalExports\n useSharedValueEffect,\n // ValueExports\n ...Values,\n ...ValuesHooks,\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"]}
1
+ {"version":3,"sources":["index.ts"],"names":["Values","ValuesHooks","BaseSkia","useSharedValueEffect","timingFunctions","springFunctions","decayFunctions","interpolateFn","interpolatePathFn","interpolateVectorFn","ShaderLib","Stub","constructor","Proxy","get","apply","set","Noop","Skia","vec","x","y","Mock","useDataCollection","useRawData","useData","useFont","useTypeface","useImage","useSVG","usePicture","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","interpolateColors","_value","_inputRange","_outputRange","Float32Array","of","mixColors","_v","_x","_y","createDrawing","createDeclaration"],"mappings":"AAAA;AAGA,OAAO,KAAKA,MAAZ,MAAwB,eAAxB;AACA,OAAO,KAAKC,WAAZ,MAA6B,iBAA7B;AACA,OAAO,KAAKC,QAAZ,MAA0B,eAA1B;AAKA,SAASC,oBAAT,QAAqC,6CAArC;AACA,OAAO,KAAKC,eAAZ,MAAiC,qBAAjC;AACA,OAAO,KAAKC,eAAZ,MAAiC,qBAAjC;AACA,OAAO,KAAKC,cAAZ,MAAgC,oBAAhC;AACA,OAAO,KAAKC,aAAZ,MAA+B,oCAA/B;AACA,OAAO,KAAKC,iBAAZ,MAAmC,yCAAnC;AACA,OAAO,KAAKC,mBAAZ,MAAqC,0CAArC;AACA,SAASC,SAAT,QAA0B,0CAA1B;;AAEA,MAAMC,IAAN,CAAW;AACTC,EAAAA,WAAW,GAAG;AACZ,WAAO,IAAIC,KAAJ,CAAU,MAAM,CAAE,CAAlB,EAAoB;AACzBC,MAAAA,GAAG,EAAE,MAAM,IAAIH,IAAJ,EADc;AAEzBI,MAAAA,KAAK,EAAE,MAAM,IAAIJ,IAAJ,EAFY;AAGzBK,MAAAA,GAAG,EAAE,MAAM;AAHc,KAApB,CAAP;AAKD;;AAPQ;;AAUX,MAAMC,IAAe,GAAG,MAAM,CAAE,CAAhC;;AAEA,OAAO,MAAMC,IAAa,GAAG,IAAIP,IAAJ,EAAtB;AAEP,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AAsDJgD,EAAAA,iBAAiB,EAAE,CACjBC,MADiB,EAEjBC,WAFiB,EAGjBC,YAHiB,KAIdC,YAAY,CAACC,EAAb,CAAgB,CAAhB,EAAmB,CAAnB,EAAsB,CAAtB,EAAyB,CAAzB,CA1DD;AA2DJC,EAAAA,SAAS,EAAE,CAACC,EAAD,EAAaC,EAAb,EAAwBC,EAAxB,KAAsCL,YAAY,CAACC,EAAb,CAAgB,CAAhB,EAAmB,CAAnB,EAAsB,CAAtB,EAAyB,CAAzB,CA3D7C;AA4DJpD,EAAAA,SA5DI;AA6DJyD,EAAAA,aAAa,EAAElD,IA7DX;AA8DJmD,EAAAA,iBAAiB,EAAEnD;AA9Df,CAPC","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 * as BaseSkia from \"../skia/types\";\nimport type * as SkiaExports from \"../skia\";\nimport type * as ExternalExports from \"../external\";\nimport type * as ValueExports from \"../values\";\nimport type * as AnimationExports from \"../animation\";\nimport { useSharedValueEffect } from \"../external/reanimated/useSharedValueEffect\";\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 ExternalExports &\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 useDataCollection: Noop,\n useRawData: Noop,\n useData: Noop,\n useFont: Noop,\n useTypeface: Noop,\n useImage: Noop,\n useSVG: Noop,\n usePicture: 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 // ExternalExports\n useSharedValueEffect,\n // ValueExports\n ...Values,\n ...ValuesHooks,\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"]}
@@ -23,15 +23,13 @@ const render = (element, root, container) => {
23
23
  };
24
24
 
25
25
  export const useCanvasRef = () => useRef(null);
26
- const defaultFontMgr = Skia.FontMgr.RefDefault();
27
26
  export const Canvas = /*#__PURE__*/forwardRef((_ref, forwardedRef) => {
28
27
  let {
29
28
  children,
30
29
  style,
31
30
  debug,
32
31
  mode,
33
- onTouch,
34
- fontMgr
32
+ onTouch
35
33
  } = _ref;
36
34
  const size = useValue({
37
35
  width: 0,
@@ -83,16 +81,17 @@ export const Canvas = /*#__PURE__*/forwardRef((_ref, forwardedRef) => {
83
81
  opacity: 1,
84
82
  ref,
85
83
  center: Skia.Point(width / 2, height / 2),
86
- fontMgr: fontMgr !== null && fontMgr !== void 0 ? fontMgr : defaultFontMgr,
87
84
  Skia
88
85
  };
89
86
  container.draw(ctx);
90
87
  }, [tick, onTouch]);
91
88
  useEffect(() => {
92
89
  return () => {
93
- container.depMgr.unsubscribe();
90
+ skiaReconciler.updateContainer(null, root, null, () => {
91
+ container.depMgr.unsubscribe();
92
+ });
94
93
  };
95
- }, [container]);
94
+ }, [container, root]);
96
95
  return /*#__PURE__*/React.createElement(SkiaView, {
97
96
  ref: ref,
98
97
  style: style,
@@ -1 +1 @@
1
- {"version":3,"sources":["Canvas.tsx"],"names":["React","useEffect","useState","useCallback","useMemo","forwardRef","useRef","ReactReconciler","SkiaView","useDrawCallback","useValue","Skia","debug","hostDebug","skHostConfig","Container","DependencyManager","CanvasProvider","skiaReconciler","injectIntoDevTools","bundleType","version","rendererPackageName","render","element","root","container","updateContainer","depMgr","subscribe","useCanvasRef","defaultFontMgr","FontMgr","RefDefault","Canvas","forwardedRef","children","style","mode","onTouch","fontMgr","size","width","height","canvasCtx","innerRef","ref","useCombinedRefs","tick","setTick","redraw","t","createContainer","onDraw","canvas","info","timestamp","touches","current","paint","Paint","ctx","opacity","center","Point","draw","unsubscribe","refs","targetRef","forEach"],"mappings":"AAAA,OAAOA,KAAP,IACEC,SADF,EAEEC,QAFF,EAGEC,WAHF,EAIEC,OAJF,EAKEC,UALF,EAMEC,MANF,QAOO,OAPP;AAgBA,OAAOC,eAAP,MAA4B,kBAA5B;AAEA,SAASC,QAAT,EAAmBC,eAAnB,QAA0C,UAA1C;AAGA,SAASC,QAAT,QAAyB,0BAA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Ae,GAAG,YAEnB;AAAA,oCADAoB,IACA;AADAA,IAAAA,IACA;AAAA;;AACH,QAAMC,SAAS,GAAGpE,KAAK,CAACM,MAAN,CAAgB,IAAhB,CAAlB;AACAN,EAAAA,KAAK,CAACC,SAAN,CAAgB,MAAM;AACpBkE,IAAAA,IAAI,CAACE,OAAL,CAAcvB,GAAD,IAAS;AACpB,UAAIA,GAAJ,EAAS;AACP,YAAI,OAAOA,GAAP,KAAe,UAAnB,EAA+B;AAC7BA,UAAAA,GAAG,CAACsB,SAAS,CAACV,OAAX,CAAH;AACD,SAFD,MAEO;AACLZ,UAAAA,GAAG,CAACY,OAAJ,GAAcU,SAAS,CAACV,OAAxB;AACD;AACF;AACF,KARD;AASD,GAVD,EAUG,CAACS,IAAD,CAVH;AAWA,SAAOC,SAAP;AACD,CAhBD","sourcesContent":["import React, {\n useEffect,\n useState,\n useCallback,\n useMemo,\n forwardRef,\n useRef,\n} from \"react\";\nimport type {\n RefObject,\n ReactNode,\n ComponentProps,\n MutableRefObject,\n ForwardedRef,\n} from \"react\";\nimport type { OpaqueRoot } from \"react-reconciler\";\nimport ReactReconciler from \"react-reconciler\";\n\nimport { SkiaView, useDrawCallback } from \"../views\";\nimport type { TouchHandler } from \"../views\";\nimport type { SkFontMgr } from \"../skia/types\";\nimport { useValue } from \"../values/hooks/useValue\";\nimport { Skia } from \"../skia/Skia\";\n\nimport { debug as hostDebug, skHostConfig } from \"./HostConfig\";\n// import { debugTree } from \"./nodes\";\nimport { Container } from \"./nodes\";\nimport { DependencyManager } from \"./DependencyManager\";\nimport { CanvasProvider } from \"./useCanvas\";\n\nexport const skiaReconciler = ReactReconciler(skHostConfig);\n\nskiaReconciler.injectIntoDevTools({\n bundleType: 1,\n version: \"0.0.1\",\n rendererPackageName: \"react-native-skia\",\n});\n\nconst render = (element: ReactNode, root: OpaqueRoot, container: Container) => {\n skiaReconciler.updateContainer(element, root, null, () => {\n hostDebug(\"updateContainer\");\n\n container.depMgr.subscribe();\n });\n};\n\nexport const useCanvasRef = () => useRef<SkiaView>(null);\n\nexport interface CanvasProps extends ComponentProps<typeof SkiaView> {\n ref?: RefObject<SkiaView>;\n children: ReactNode;\n onTouch?: TouchHandler;\n fontMgr?: SkFontMgr;\n}\n\nconst defaultFontMgr = Skia.FontMgr.RefDefault();\n\nexport const Canvas = forwardRef<SkiaView, CanvasProps>(\n ({ children, style, debug, mode, onTouch, fontMgr }, forwardedRef) => {\n const size = useValue({ width: 0, height: 0 });\n const canvasCtx = useMemo(() => ({ Skia, size }), [size]);\n const innerRef = useCanvasRef();\n const ref = useCombinedRefs(forwardedRef, innerRef);\n const [tick, setTick] = useState(0);\n const redraw = useCallback(() => setTick((t) => t + 1), []);\n\n const container = useMemo(\n () => new Container(new DependencyManager(ref), redraw),\n [redraw, ref]\n );\n\n const root = useMemo(\n () => skiaReconciler.createContainer(container, 0, false, null),\n [container]\n );\n // Render effect\n useEffect(() => {\n render(\n <CanvasProvider value={canvasCtx}>{children}</CanvasProvider>,\n root,\n container\n );\n }, [children, root, redraw, container, canvasCtx]);\n\n // Draw callback\n const onDraw = useDrawCallback(\n (canvas, info) => {\n // TODO: if tree is empty (count === 1) maybe we should not render?\n const { width, height, timestamp } = info;\n if (onTouch) {\n onTouch(info.touches);\n }\n if (\n width !== canvasCtx.size.current.width ||\n height !== canvasCtx.size.current.height\n ) {\n canvasCtx.size.current = { width, height };\n }\n const paint = Skia.Paint();\n const ctx = {\n width,\n height,\n timestamp,\n canvas,\n paint,\n opacity: 1,\n ref,\n center: Skia.Point(width / 2, height / 2),\n fontMgr: fontMgr ?? defaultFontMgr,\n Skia,\n };\n container.draw(ctx);\n },\n [tick, onTouch]\n );\n\n useEffect(() => {\n return () => {\n container.depMgr.unsubscribe();\n };\n }, [container]);\n\n return (\n <SkiaView\n ref={ref}\n style={style}\n onDraw={onDraw}\n mode={mode}\n debug={debug}\n />\n );\n }\n);\n\n/**\n * Combines a list of refs into a single ref. This can be used to provide\n * both a forwarded ref and an internal ref keeping the same functionality\n * on both of the refs.\n * @param refs Array of refs to combine\n * @returns A single ref that can be used in a ref prop.\n */\nconst useCombinedRefs = <T,>(\n ...refs: Array<MutableRefObject<T> | ForwardedRef<T>>\n) => {\n const targetRef = React.useRef<T>(null);\n React.useEffect(() => {\n refs.forEach((ref) => {\n if (ref) {\n if (typeof ref === \"function\") {\n ref(targetRef.current);\n } else {\n ref.current = targetRef.current;\n }\n }\n });\n }, [refs]);\n return targetRef;\n};\n"]}
1
+ {"version":3,"sources":["Canvas.tsx"],"names":["React","useEffect","useState","useCallback","useMemo","forwardRef","useRef","ReactReconciler","SkiaView","useDrawCallback","useValue","Skia","debug","hostDebug","skHostConfig","Container","DependencyManager","CanvasProvider","skiaReconciler","injectIntoDevTools","bundleType","version","rendererPackageName","render","element","root","container","updateContainer","depMgr","subscribe","useCanvasRef","Canvas","forwardedRef","children","style","mode","onTouch","size","width","height","canvasCtx","innerRef","ref","useCombinedRefs","tick","setTick","redraw","t","createContainer","onDraw","canvas","info","timestamp","touches","current","paint","Paint","ctx","opacity","center","Point","draw","unsubscribe","refs","targetRef","forEach"],"mappings":"AAAA,OAAOA,KAAP,IACEC,SADF,EAEEC,QAFF,EAGEC,WAHF,EAIEC,OAJF,EAKEC,UALF,EAMEC,MANF,QAOO,OAPP;AAgBA,OAAOC,eAAP,MAA4B,kBAA5B;AAEA,SAASC,QAAT,EAAmBC,eAAnB,QAA0C,UAA1C;AAEA,SAASC,QAAT,QAAyB,0BAAzB;AACA,SAASC,IAAT,QAAqB,cAArB;AAEA,SAASC,KAAK,IAAIC,SAAlB,EAA6BC,YAA7B,QAAiD,cAAjD,C,CACA;;AACA,SAASC,SAAT,QAA0B,SAA1B;AACA,SAASC,iBAAT,QAAkC,qBAAlC;AACA,SAASC,cAAT,QAA+B,aAA/B;AAEA,OAAO,MAAMC,cAAc,GAAGX,eAAe,CAACO,YAAD,CAAtC;AAEPI,cAAc,CAACC,kBAAf,CAAkC;AAChCC,EAAAA,UAAU,EAAE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AACLZ,UAAAA,GAAG,CAACY,OAAJ,GAAcU,SAAS,CAACV,OAAxB;AACD;AACF;AACF,KARD;AASD,GAVD,EAUG,CAACS,IAAD,CAVH;AAWA,SAAOC,SAAP;AACD,CAhBD","sourcesContent":["import React, {\n useEffect,\n useState,\n useCallback,\n useMemo,\n forwardRef,\n useRef,\n} from \"react\";\nimport type {\n RefObject,\n ReactNode,\n ComponentProps,\n MutableRefObject,\n ForwardedRef,\n} from \"react\";\nimport type { OpaqueRoot } from \"react-reconciler\";\nimport ReactReconciler from \"react-reconciler\";\n\nimport { SkiaView, useDrawCallback } from \"../views\";\nimport type { TouchHandler } from \"../views\";\nimport { useValue } from \"../values/hooks/useValue\";\nimport { Skia } from \"../skia/Skia\";\n\nimport { debug as hostDebug, skHostConfig } from \"./HostConfig\";\n// import { debugTree } from \"./nodes\";\nimport { Container } from \"./nodes\";\nimport { DependencyManager } from \"./DependencyManager\";\nimport { CanvasProvider } from \"./useCanvas\";\n\nexport const skiaReconciler = ReactReconciler(skHostConfig);\n\nskiaReconciler.injectIntoDevTools({\n bundleType: 1,\n version: \"0.0.1\",\n rendererPackageName: \"react-native-skia\",\n});\n\nconst render = (element: ReactNode, root: OpaqueRoot, container: Container) => {\n skiaReconciler.updateContainer(element, root, null, () => {\n hostDebug(\"updateContainer\");\n\n container.depMgr.subscribe();\n });\n};\n\nexport const useCanvasRef = () => useRef<SkiaView>(null);\n\nexport interface CanvasProps extends ComponentProps<typeof SkiaView> {\n ref?: RefObject<SkiaView>;\n children: ReactNode;\n onTouch?: TouchHandler;\n}\n\nexport const Canvas = forwardRef<SkiaView, CanvasProps>(\n ({ children, style, debug, mode, onTouch }, forwardedRef) => {\n const size = useValue({ width: 0, height: 0 });\n const canvasCtx = useMemo(() => ({ Skia, size }), [size]);\n const innerRef = useCanvasRef();\n const ref = useCombinedRefs(forwardedRef, innerRef);\n const [tick, setTick] = useState(0);\n const redraw = useCallback(() => setTick((t) => t + 1), []);\n\n const container = useMemo(\n () => new Container(new DependencyManager(ref), redraw),\n [redraw, ref]\n );\n\n const root = useMemo(\n () => skiaReconciler.createContainer(container, 0, false, null),\n [container]\n );\n // Render effect\n useEffect(() => {\n render(\n <CanvasProvider value={canvasCtx}>{children}</CanvasProvider>,\n root,\n container\n );\n }, [children, root, redraw, container, canvasCtx]);\n\n // Draw callback\n const onDraw = useDrawCallback(\n (canvas, info) => {\n // TODO: if tree is empty (count === 1) maybe we should not render?\n const { width, height, timestamp } = info;\n if (onTouch) {\n onTouch(info.touches);\n }\n if (\n width !== canvasCtx.size.current.width ||\n height !== canvasCtx.size.current.height\n ) {\n canvasCtx.size.current = { width, height };\n }\n const paint = Skia.Paint();\n const ctx = {\n width,\n height,\n timestamp,\n canvas,\n paint,\n opacity: 1,\n ref,\n center: Skia.Point(width / 2, height / 2),\n Skia,\n };\n container.draw(ctx);\n },\n [tick, onTouch]\n );\n\n useEffect(() => {\n return () => {\n skiaReconciler.updateContainer(null, root, null, () => {\n container.depMgr.unsubscribe();\n });\n };\n }, [container, root]);\n\n return (\n <SkiaView\n ref={ref}\n style={style}\n onDraw={onDraw}\n mode={mode}\n debug={debug}\n />\n );\n }\n);\n\n/**\n * Combines a list of refs into a single ref. This can be used to provide\n * both a forwarded ref and an internal ref keeping the same functionality\n * on both of the refs.\n * @param refs Array of refs to combine\n * @returns A single ref that can be used in a ref prop.\n */\nconst useCombinedRefs = <T,>(\n ...refs: Array<MutableRefObject<T> | ForwardedRef<T>>\n) => {\n const targetRef = React.useRef<T>(null);\n React.useEffect(() => {\n refs.forEach((ref) => {\n if (ref) {\n if (typeof ref === \"function\") {\n ref(targetRef.current);\n } else {\n ref.current = targetRef.current;\n }\n }\n });\n }, [refs]);\n return targetRef;\n};\n"]}
@@ -2,13 +2,10 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
2
2
 
3
3
  import React from "react";
4
4
  import { createDrawing } from "../../nodes/Drawing";
5
- import { processFont } from "../../processors/Font";
6
5
  const onDraw = createDrawing((_ref, _ref2) => {
7
6
  let {
8
7
  canvas,
9
- paint,
10
- fontMgr,
11
- Skia
8
+ paint
12
9
  } = _ref;
13
10
  let {
14
11
  glyphs: rawGlyphs,
@@ -16,7 +13,9 @@ const onDraw = createDrawing((_ref, _ref2) => {
16
13
  y,
17
14
  ...fontDef
18
15
  } = _ref2;
19
- const font = processFont(Skia, fontMgr, fontDef);
16
+ const {
17
+ font
18
+ } = fontDef;
20
19
  const {
21
20
  glyphs,
22
21
  positions
@@ -1 +1 @@
1
- {"version":3,"sources":["Glyphs.tsx"],"names":["React","createDrawing","processFont","onDraw","canvas","paint","fontMgr","Skia","glyphs","rawGlyphs","x","y","fontDef","font","positions","reduce","acc","glyph","id","pos","push","drawGlyphs","Glyphs","props","defaultProps"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAGA,SAASC,aAAT,QAA8B,qBAA9B;AAGA,SAASC,WAAT,QAA4B,uBAA5B;AAmBA,MAAMC,MAAM,GAAGF,aAAa,CAC1B,iBAGK;AAAA,MAFH;AAAEG,IAAAA,MAAF;AAAUC,IAAAA,KAAV;AAAiBC,IAAAA,OAAjB;AAA0BC,IAAAA;AAA1B,GAEG;AAAA,MADH;AAAEC,IAAAA,MAAM,EAAEC,SAAV;AAAqBC,IAAAA,CAArB;AAAwBC,IAAAA,CAAxB;AAA2B,OAAGC;AAA9B,GACG;AACH,QAAMC,IAAI,GAAGX,WAAW,CAACK,IAAD,EAAOD,OAAP,EAAgBM,OAAhB,CAAxB;AACA,QAAM;AAAEJ,IAAAA,MAAF;AAAUM,IAAAA;AAAV,MAAwBL,SAAS,CAACM,MAAV,CAC5B,CAACC,GAAD,EAAMC,KAAN,KAAgB;AACd,UAAM;AAAEC,MAAAA,EAAF;AAAMC,MAAAA;AAAN,QAAcF,KAApB;AACAD,IAAAA,GAAG,CAACR,MAAJ,CAAWY,IAAX,CAAgBF,EAAhB;AACAF,IAAAA,GAAG,CAACF,SAAJ,CAAcM,IAAd,CAAmBD,GAAnB;AACA,WAAOH,GAAP;AACD,GAN2B,EAO5B;AAAER,IAAAA,MAAM,EAAE,EAAV;AAAcM,IAAAA,SAAS,EAAE;AAAzB,GAP4B,CAA9B;AASAV,EAAAA,MAAM,CAACiB,UAAP,CAAkBb,MAAlB,EAA0BM,SAA1B,EAAqCJ,CAArC,EAAwCC,CAAxC,EAA2CE,IAA3C,EAAiDR,KAAjD;AACD,CAhByB,CAA5B;AAmBA,OAAO,MAAMiB,MAAM,GAAIC,KAAD,IAAuC;AAC3D,sBAAO;AAAW,IAAA,MAAM,EAAEpB;AAAnB,KAA+BoB,KAA/B,EAAP;AACD,CAFM;AAIPD,MAAM,CAACE,YAAP,GAAsB;AACpBd,EAAAA,CAAC,EAAE,CADiB;AAEpBC,EAAAA,CAAC,EAAE;AAFiB,CAAtB","sourcesContent":["import React from \"react\";\n\nimport type { CustomPaintProps, AnimatedProps } from \"../../processors\";\nimport { createDrawing } from \"../../nodes/Drawing\";\nimport type { SkPoint } from \"../../../skia/types\";\nimport type { FontDef } from \"../../processors/Font\";\nimport { processFont } from \"../../processors/Font\";\n\nexport interface Glyph {\n id: number;\n pos: SkPoint;\n}\n\nexport type GlyphsProps = CustomPaintProps &\n FontDef & {\n x: number;\n y: number;\n glyphs: Glyph[];\n };\n\ninterface ProcessedGlyphs {\n glyphs: number[];\n positions: SkPoint[];\n}\n\nconst onDraw = createDrawing<GlyphsProps>(\n (\n { canvas, paint, fontMgr, Skia },\n { glyphs: rawGlyphs, x, y, ...fontDef }\n ) => {\n const font = processFont(Skia, fontMgr, fontDef);\n const { glyphs, positions } = rawGlyphs.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 canvas.drawGlyphs(glyphs, positions, x, y, font, paint);\n }\n);\n\nexport const Glyphs = (props: AnimatedProps<GlyphsProps>) => {\n return <skDrawing onDraw={onDraw} {...props} />;\n};\n\nGlyphs.defaultProps = {\n x: 0,\n y: 0,\n};\n"]}
1
+ {"version":3,"sources":["Glyphs.tsx"],"names":["React","createDrawing","onDraw","canvas","paint","glyphs","rawGlyphs","x","y","fontDef","font","positions","reduce","acc","glyph","id","pos","push","drawGlyphs","Glyphs","props","defaultProps"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AAGA,SAASC,aAAT,QAA8B,qBAA9B;AAqBA,MAAMC,MAAM,GAAGD,aAAa,CAC1B,iBAAgE;AAAA,MAA/D;AAAEE,IAAAA,MAAF;AAAUC,IAAAA;AAAV,GAA+D;AAAA,MAA5C;AAAEC,IAAAA,MAAM,EAAEC,SAAV;AAAqBC,IAAAA,CAArB;AAAwBC,IAAAA,CAAxB;AAA2B,OAAGC;AAA9B,GAA4C;AAC9D,QAAM;AAAEC,IAAAA;AAAF,MAAWD,OAAjB;AACA,QAAM;AAAEJ,IAAAA,MAAF;AAAUM,IAAAA;AAAV,MAAwBL,SAAS,CAACM,MAAV,CAC5B,CAACC,GAAD,EAAMC,KAAN,KAAgB;AACd,UAAM;AAAEC,MAAAA,EAAF;AAAMC,MAAAA;AAAN,QAAcF,KAApB;AACAD,IAAAA,GAAG,CAACR,MAAJ,CAAWY,IAAX,CAAgBF,EAAhB;AACAF,IAAAA,GAAG,CAACF,SAAJ,CAAcM,IAAd,CAAmBD,GAAnB;AACA,WAAOH,GAAP;AACD,GAN2B,EAO5B;AAAER,IAAAA,MAAM,EAAE,EAAV;AAAcM,IAAAA,SAAS,EAAE;AAAzB,GAP4B,CAA9B;AASAR,EAAAA,MAAM,CAACe,UAAP,CAAkBb,MAAlB,EAA0BM,SAA1B,EAAqCJ,CAArC,EAAwCC,CAAxC,EAA2CE,IAA3C,EAAiDN,KAAjD;AACD,CAbyB,CAA5B;AAgBA,OAAO,MAAMe,MAAM,GAAIC,KAAD,IAAuC;AAC3D,sBAAO;AAAW,IAAA,MAAM,EAAElB;AAAnB,KAA+BkB,KAA/B,EAAP;AACD,CAFM;AAIPD,MAAM,CAACE,YAAP,GAAsB;AACpBd,EAAAA,CAAC,EAAE,CADiB;AAEpBC,EAAAA,CAAC,EAAE;AAFiB,CAAtB","sourcesContent":["import React from \"react\";\n\nimport type { CustomPaintProps, AnimatedProps } from \"../../processors\";\nimport { createDrawing } from \"../../nodes/Drawing\";\nimport type { SkPoint } from \"../../../skia/types\";\nimport type { FontDef } from \"../../processors/Font\";\n\nexport interface Glyph {\n id: number;\n pos: SkPoint;\n}\n\nexport type GlyphsProps = CustomPaintProps &\n FontDef & {\n x: number;\n y: number;\n glyphs: Glyph[];\n };\n\ninterface ProcessedGlyphs {\n glyphs: number[];\n positions: SkPoint[];\n}\n\nconst onDraw = createDrawing<GlyphsProps>(\n ({ canvas, paint }, { glyphs: rawGlyphs, x, y, ...fontDef }) => {\n const { font } = fontDef;\n const { glyphs, positions } = rawGlyphs.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 canvas.drawGlyphs(glyphs, positions, x, y, font, paint);\n }\n);\n\nexport const Glyphs = (props: AnimatedProps<GlyphsProps>) => {\n return <skDrawing onDraw={onDraw} {...props} />;\n};\n\nGlyphs.defaultProps = {\n x: 0,\n y: 0,\n};\n"]}