@shopify/react-native-skia 0.1.221 → 0.1.223

Sign up to get free protection for your applications and to get access to all the features.
Files changed (223) hide show
  1. package/android/cpp/rnskia-android/RNSkAndroidView.h +3 -0
  2. package/android/cpp/rnskia-android/RNSkOpenGLCanvasProvider.cpp +1 -0
  3. package/android/cpp/rnskia-android/SkiaOpenGLHelper.h +0 -1
  4. package/android/cpp/rnskia-android/SkiaOpenGLSurfaceFactory.h +46 -6
  5. package/android/src/main/java/com/shopify/reactnative/skia/PlatformContext.java +3 -3
  6. package/android/src/main/java/com/shopify/reactnative/skia/SkiaBaseView.java +8 -14
  7. package/android/src/main/java/com/shopify/reactnative/skia/ViewScreenshotService.java +93 -105
  8. package/cpp/api/JsiSkApi.h +5 -0
  9. package/cpp/api/JsiSkFontMgrFactory.h +9 -4
  10. package/cpp/api/JsiSkParagraph.h +135 -0
  11. package/cpp/api/JsiSkParagraphBuilder.h +159 -0
  12. package/cpp/api/JsiSkParagraphStyle.h +124 -0
  13. package/cpp/api/JsiSkStrutStyle.h +96 -0
  14. package/cpp/api/JsiSkTextStyle.h +185 -0
  15. package/cpp/jsi/JsiHostObject.h +21 -0
  16. package/cpp/rnskia/dom/JsiDomApi.h +4 -0
  17. package/cpp/rnskia/dom/nodes/JsiParagraphNode.h +62 -0
  18. package/cpp/rnskia/dom/props/ParagraphProp.h +45 -0
  19. package/cpp/skia/modules/skunicode/include/SkUnicode.h +312 -0
  20. package/cpp/skia/src/base/SkTInternalLList.h +304 -0
  21. package/cpp/skia/src/base/SkUTF.h +95 -0
  22. package/cpp/skia/src/core/SkLRUCache.h +130 -0
  23. package/cpp/utils/RNSkLog.h +3 -3
  24. package/lib/commonjs/dom/nodes/JsiSkDOM.d.ts +2 -0
  25. package/lib/commonjs/dom/nodes/JsiSkDOM.js +7 -0
  26. package/lib/commonjs/dom/nodes/JsiSkDOM.js.map +1 -1
  27. package/lib/commonjs/dom/nodes/drawings/ParagraphNode.d.ts +8 -0
  28. package/lib/commonjs/dom/nodes/drawings/ParagraphNode.js +41 -0
  29. package/lib/commonjs/dom/nodes/drawings/ParagraphNode.js.map +1 -0
  30. package/lib/commonjs/dom/types/NodeType.d.ts +2 -1
  31. package/lib/commonjs/dom/types/NodeType.js +1 -0
  32. package/lib/commonjs/dom/types/NodeType.js.map +1 -1
  33. package/lib/commonjs/dom/types/Paragraph.d.ts +8 -0
  34. package/lib/commonjs/dom/types/Paragraph.js +6 -0
  35. package/lib/commonjs/dom/types/Paragraph.js.map +1 -0
  36. package/lib/commonjs/dom/types/SkDOM.d.ts +2 -0
  37. package/lib/commonjs/dom/types/SkDOM.js.map +1 -1
  38. package/lib/commonjs/dom/types/index.d.ts +1 -0
  39. package/lib/commonjs/dom/types/index.js +13 -0
  40. package/lib/commonjs/dom/types/index.js.map +1 -1
  41. package/lib/commonjs/renderer/HostComponents.d.ts +3 -1
  42. package/lib/commonjs/renderer/HostComponents.js +4 -0
  43. package/lib/commonjs/renderer/HostComponents.js.map +1 -1
  44. package/lib/commonjs/renderer/components/index.d.ts +1 -0
  45. package/lib/commonjs/renderer/components/index.js +13 -0
  46. package/lib/commonjs/renderer/components/index.js.map +1 -1
  47. package/lib/commonjs/renderer/components/paragraph/Paragraph.d.ts +4 -0
  48. package/lib/commonjs/renderer/components/paragraph/Paragraph.js +17 -0
  49. package/lib/commonjs/renderer/components/paragraph/Paragraph.js.map +1 -0
  50. package/lib/commonjs/renderer/components/paragraph/index.d.ts +1 -0
  51. package/lib/commonjs/renderer/components/paragraph/index.js +19 -0
  52. package/lib/commonjs/renderer/components/paragraph/index.js.map +1 -0
  53. package/lib/commonjs/skia/types/Paragraph/Paragraph.d.ts +56 -0
  54. package/lib/commonjs/skia/types/Paragraph/Paragraph.js +6 -0
  55. package/lib/commonjs/skia/types/Paragraph/Paragraph.js.map +1 -0
  56. package/lib/commonjs/skia/types/Paragraph/ParagraphBuilder.d.ts +60 -0
  57. package/lib/commonjs/skia/types/Paragraph/ParagraphBuilder.js +18 -0
  58. package/lib/commonjs/skia/types/Paragraph/ParagraphBuilder.js.map +1 -0
  59. package/lib/commonjs/skia/types/Paragraph/ParagraphStyle.d.ts +41 -0
  60. package/lib/commonjs/skia/types/Paragraph/ParagraphStyle.js +36 -0
  61. package/lib/commonjs/skia/types/Paragraph/ParagraphStyle.js.map +1 -0
  62. package/lib/commonjs/skia/types/Paragraph/TextStyle.d.ts +62 -0
  63. package/lib/commonjs/skia/types/Paragraph/TextStyle.js +35 -0
  64. package/lib/commonjs/skia/types/Paragraph/TextStyle.js.map +1 -0
  65. package/lib/commonjs/skia/types/Paragraph/index.d.ts +6 -0
  66. package/lib/commonjs/skia/types/Paragraph/index.js +84 -0
  67. package/lib/commonjs/skia/types/Paragraph/index.js.map +1 -0
  68. package/lib/commonjs/skia/types/Skia.d.ts +2 -0
  69. package/lib/commonjs/skia/types/Skia.js.map +1 -1
  70. package/lib/commonjs/skia/types/index.d.ts +1 -0
  71. package/lib/commonjs/skia/types/index.js +13 -0
  72. package/lib/commonjs/skia/types/index.js.map +1 -1
  73. package/lib/commonjs/skia/web/JsiSkImage.js +0 -6
  74. package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
  75. package/lib/commonjs/skia/web/JsiSkParagraph.d.ts +16 -0
  76. package/lib/commonjs/skia/web/JsiSkParagraph.js +91 -0
  77. package/lib/commonjs/skia/web/JsiSkParagraph.js.map +1 -0
  78. package/lib/commonjs/skia/web/JsiSkParagraphBuilder.d.ts +15 -0
  79. package/lib/commonjs/skia/web/JsiSkParagraphBuilder.js +85 -0
  80. package/lib/commonjs/skia/web/JsiSkParagraphBuilder.js.map +1 -0
  81. package/lib/commonjs/skia/web/JsiSkParagraphBuilderFactory.d.ts +8 -0
  82. package/lib/commonjs/skia/web/JsiSkParagraphBuilderFactory.js +34 -0
  83. package/lib/commonjs/skia/web/JsiSkParagraphBuilderFactory.js.map +1 -0
  84. package/lib/commonjs/skia/web/JsiSkParagraphStyle.d.ts +5 -0
  85. package/lib/commonjs/skia/web/JsiSkParagraphStyle.js +59 -0
  86. package/lib/commonjs/skia/web/JsiSkParagraphStyle.js.map +1 -0
  87. package/lib/commonjs/skia/web/JsiSkTextStyle.d.ts +5 -0
  88. package/lib/commonjs/skia/web/JsiSkTextStyle.js +54 -0
  89. package/lib/commonjs/skia/web/JsiSkTextStyle.js.map +1 -0
  90. package/lib/commonjs/skia/web/JsiSkia.js +4 -1
  91. package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
  92. package/lib/module/dom/nodes/JsiSkDOM.d.ts +2 -0
  93. package/lib/module/dom/nodes/JsiSkDOM.js +6 -0
  94. package/lib/module/dom/nodes/JsiSkDOM.js.map +1 -1
  95. package/lib/module/dom/nodes/drawings/ParagraphNode.d.ts +8 -0
  96. package/lib/module/dom/nodes/drawings/ParagraphNode.js +30 -0
  97. package/lib/module/dom/nodes/drawings/ParagraphNode.js.map +1 -0
  98. package/lib/module/dom/types/NodeType.d.ts +2 -1
  99. package/lib/module/dom/types/NodeType.js +1 -0
  100. package/lib/module/dom/types/NodeType.js.map +1 -1
  101. package/lib/module/dom/types/Paragraph.d.ts +8 -0
  102. package/lib/module/dom/types/Paragraph.js +2 -0
  103. package/lib/module/dom/types/Paragraph.js.map +1 -0
  104. package/lib/module/dom/types/SkDOM.d.ts +2 -0
  105. package/lib/module/dom/types/SkDOM.js.map +1 -1
  106. package/lib/module/dom/types/index.d.ts +1 -0
  107. package/lib/module/dom/types/index.js +1 -0
  108. package/lib/module/dom/types/index.js.map +1 -1
  109. package/lib/module/renderer/HostComponents.d.ts +3 -1
  110. package/lib/module/renderer/HostComponents.js +4 -0
  111. package/lib/module/renderer/HostComponents.js.map +1 -1
  112. package/lib/module/renderer/components/index.d.ts +1 -0
  113. package/lib/module/renderer/components/index.js +1 -0
  114. package/lib/module/renderer/components/index.js.map +1 -1
  115. package/lib/module/renderer/components/paragraph/Paragraph.d.ts +4 -0
  116. package/lib/module/renderer/components/paragraph/Paragraph.js +5 -0
  117. package/lib/module/renderer/components/paragraph/Paragraph.js.map +1 -0
  118. package/lib/module/renderer/components/paragraph/index.d.ts +1 -0
  119. package/lib/module/renderer/components/paragraph/index.js +2 -0
  120. package/lib/module/renderer/components/paragraph/index.js.map +1 -0
  121. package/lib/module/skia/types/Paragraph/Paragraph.d.ts +56 -0
  122. package/lib/module/skia/types/Paragraph/Paragraph.js +2 -0
  123. package/lib/module/skia/types/Paragraph/Paragraph.js.map +1 -0
  124. package/lib/module/skia/types/Paragraph/ParagraphBuilder.d.ts +60 -0
  125. package/lib/module/skia/types/Paragraph/ParagraphBuilder.js +11 -0
  126. package/lib/module/skia/types/Paragraph/ParagraphBuilder.js.map +1 -0
  127. package/lib/module/skia/types/Paragraph/ParagraphStyle.d.ts +41 -0
  128. package/lib/module/skia/types/Paragraph/ParagraphStyle.js +27 -0
  129. package/lib/module/skia/types/Paragraph/ParagraphStyle.js.map +1 -0
  130. package/lib/module/skia/types/Paragraph/TextStyle.d.ts +62 -0
  131. package/lib/module/skia/types/Paragraph/TextStyle.js +26 -0
  132. package/lib/module/skia/types/Paragraph/TextStyle.js.map +1 -0
  133. package/lib/module/skia/types/Paragraph/index.d.ts +6 -0
  134. package/lib/module/skia/types/Paragraph/index.js +7 -0
  135. package/lib/module/skia/types/Paragraph/index.js.map +1 -0
  136. package/lib/module/skia/types/Skia.d.ts +2 -0
  137. package/lib/module/skia/types/Skia.js.map +1 -1
  138. package/lib/module/skia/types/index.d.ts +1 -0
  139. package/lib/module/skia/types/index.js +1 -0
  140. package/lib/module/skia/types/index.js.map +1 -1
  141. package/lib/module/skia/web/JsiSkImage.js +0 -6
  142. package/lib/module/skia/web/JsiSkImage.js.map +1 -1
  143. package/lib/module/skia/web/JsiSkParagraph.d.ts +16 -0
  144. package/lib/module/skia/web/JsiSkParagraph.js +81 -0
  145. package/lib/module/skia/web/JsiSkParagraph.js.map +1 -0
  146. package/lib/module/skia/web/JsiSkParagraphBuilder.d.ts +15 -0
  147. package/lib/module/skia/web/JsiSkParagraphBuilder.js +73 -0
  148. package/lib/module/skia/web/JsiSkParagraphBuilder.js.map +1 -0
  149. package/lib/module/skia/web/JsiSkParagraphBuilderFactory.d.ts +8 -0
  150. package/lib/module/skia/web/JsiSkParagraphBuilderFactory.js +21 -0
  151. package/lib/module/skia/web/JsiSkParagraphBuilderFactory.js.map +1 -0
  152. package/lib/module/skia/web/JsiSkParagraphStyle.d.ts +5 -0
  153. package/lib/module/skia/web/JsiSkParagraphStyle.js +49 -0
  154. package/lib/module/skia/web/JsiSkParagraphStyle.js.map +1 -0
  155. package/lib/module/skia/web/JsiSkTextStyle.d.ts +5 -0
  156. package/lib/module/skia/web/JsiSkTextStyle.js +45 -0
  157. package/lib/module/skia/web/JsiSkTextStyle.js.map +1 -0
  158. package/lib/module/skia/web/JsiSkia.js +3 -1
  159. package/lib/module/skia/web/JsiSkia.js.map +1 -1
  160. package/lib/typescript/src/dom/nodes/JsiSkDOM.d.ts +2 -0
  161. package/lib/typescript/src/dom/nodes/drawings/ParagraphNode.d.ts +8 -0
  162. package/lib/typescript/src/dom/types/NodeType.d.ts +2 -1
  163. package/lib/typescript/src/dom/types/Paragraph.d.ts +8 -0
  164. package/lib/typescript/src/dom/types/SkDOM.d.ts +2 -0
  165. package/lib/typescript/src/dom/types/index.d.ts +1 -0
  166. package/lib/typescript/src/renderer/HostComponents.d.ts +3 -1
  167. package/lib/typescript/src/renderer/components/index.d.ts +1 -0
  168. package/lib/typescript/src/renderer/components/paragraph/Paragraph.d.ts +4 -0
  169. package/lib/typescript/src/renderer/components/paragraph/index.d.ts +1 -0
  170. package/lib/typescript/src/skia/types/Paragraph/Paragraph.d.ts +56 -0
  171. package/lib/typescript/src/skia/types/Paragraph/ParagraphBuilder.d.ts +60 -0
  172. package/lib/typescript/src/skia/types/Paragraph/ParagraphStyle.d.ts +41 -0
  173. package/lib/typescript/src/skia/types/Paragraph/TextStyle.d.ts +62 -0
  174. package/lib/typescript/src/skia/types/Paragraph/index.d.ts +6 -0
  175. package/lib/typescript/src/skia/types/Skia.d.ts +2 -0
  176. package/lib/typescript/src/skia/types/index.d.ts +1 -0
  177. package/lib/typescript/src/skia/web/JsiSkParagraph.d.ts +16 -0
  178. package/lib/typescript/src/skia/web/JsiSkParagraphBuilder.d.ts +15 -0
  179. package/lib/typescript/src/skia/web/JsiSkParagraphBuilderFactory.d.ts +8 -0
  180. package/lib/typescript/src/skia/web/JsiSkParagraphStyle.d.ts +5 -0
  181. package/lib/typescript/src/skia/web/JsiSkTextStyle.d.ts +5 -0
  182. package/libs/ios/libskia.xcframework/ios-arm64_arm64e/libskia.a +0 -0
  183. package/libs/ios/libskia.xcframework/ios-arm64_arm64e_x86_64-simulator/libskia.a +0 -0
  184. package/libs/ios/libskottie.xcframework/Info.plist +5 -5
  185. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e/libskottie.a +0 -0
  186. package/libs/ios/libskottie.xcframework/ios-arm64_arm64e_x86_64-simulator/libskottie.a +0 -0
  187. package/libs/ios/libskparagraph.xcframework/Info.plist +5 -5
  188. package/libs/ios/libskparagraph.xcframework/ios-arm64_arm64e/libskparagraph.a +0 -0
  189. package/libs/ios/libskparagraph.xcframework/ios-arm64_arm64e_x86_64-simulator/libskparagraph.a +0 -0
  190. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e/libsksg.a +0 -0
  191. package/libs/ios/libsksg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsksg.a +0 -0
  192. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e/libskshaper.a +0 -0
  193. package/libs/ios/libskshaper.xcframework/ios-arm64_arm64e_x86_64-simulator/libskshaper.a +0 -0
  194. package/libs/ios/libskunicode.xcframework/ios-arm64_arm64e/libskunicode.a +0 -0
  195. package/libs/ios/libskunicode.xcframework/ios-arm64_arm64e_x86_64-simulator/libskunicode.a +0 -0
  196. package/libs/ios/libsvg.xcframework/Info.plist +5 -5
  197. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e/libsvg.a +0 -0
  198. package/libs/ios/libsvg.xcframework/ios-arm64_arm64e_x86_64-simulator/libsvg.a +0 -0
  199. package/package.json +1 -1
  200. package/src/dom/nodes/JsiSkDOM.ts +9 -0
  201. package/src/dom/nodes/drawings/ParagraphNode.ts +22 -0
  202. package/src/dom/types/NodeType.ts +3 -0
  203. package/src/dom/types/Paragraph.ts +10 -0
  204. package/src/dom/types/SkDOM.ts +4 -0
  205. package/src/dom/types/index.ts +1 -0
  206. package/src/renderer/HostComponents.ts +10 -0
  207. package/src/renderer/components/index.ts +2 -0
  208. package/src/renderer/components/paragraph/Paragraph.tsx +8 -0
  209. package/src/renderer/components/paragraph/index.ts +1 -0
  210. package/src/skia/types/Paragraph/Paragraph.ts +59 -0
  211. package/src/skia/types/Paragraph/ParagraphBuilder.ts +96 -0
  212. package/src/skia/types/Paragraph/ParagraphStyle.ts +45 -0
  213. package/src/skia/types/Paragraph/TextStyle.ts +70 -0
  214. package/src/skia/types/Paragraph/index.ts +6 -0
  215. package/src/skia/types/Skia.ts +3 -0
  216. package/src/skia/types/index.ts +1 -0
  217. package/src/skia/web/JsiSkImage.ts +0 -6
  218. package/src/skia/web/JsiSkParagraph.ts +69 -0
  219. package/src/skia/web/JsiSkParagraphBuilder.ts +99 -0
  220. package/src/skia/web/JsiSkParagraphBuilderFactory.ts +42 -0
  221. package/src/skia/web/JsiSkParagraphStyle.ts +65 -0
  222. package/src/skia/web/JsiSkTextStyle.ts +53 -0
  223. package/src/skia/web/JsiSkia.ts +2 -0
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _TypefaceFontProvider = require("./TypefaceFontProvider");
8
+
9
+ Object.keys(_TypefaceFontProvider).forEach(function (key) {
10
+ if (key === "default" || key === "__esModule") return;
11
+ if (key in exports && exports[key] === _TypefaceFontProvider[key]) return;
12
+ Object.defineProperty(exports, key, {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _TypefaceFontProvider[key];
16
+ }
17
+ });
18
+ });
19
+
20
+ var _TypefaceFontProviderFactory = require("./TypefaceFontProviderFactory");
21
+
22
+ Object.keys(_TypefaceFontProviderFactory).forEach(function (key) {
23
+ if (key === "default" || key === "__esModule") return;
24
+ if (key in exports && exports[key] === _TypefaceFontProviderFactory[key]) return;
25
+ Object.defineProperty(exports, key, {
26
+ enumerable: true,
27
+ get: function () {
28
+ return _TypefaceFontProviderFactory[key];
29
+ }
30
+ });
31
+ });
32
+
33
+ var _Paragraph = require("./Paragraph");
34
+
35
+ Object.keys(_Paragraph).forEach(function (key) {
36
+ if (key === "default" || key === "__esModule") return;
37
+ if (key in exports && exports[key] === _Paragraph[key]) return;
38
+ Object.defineProperty(exports, key, {
39
+ enumerable: true,
40
+ get: function () {
41
+ return _Paragraph[key];
42
+ }
43
+ });
44
+ });
45
+
46
+ var _ParagraphBuilder = require("./ParagraphBuilder");
47
+
48
+ Object.keys(_ParagraphBuilder).forEach(function (key) {
49
+ if (key === "default" || key === "__esModule") return;
50
+ if (key in exports && exports[key] === _ParagraphBuilder[key]) return;
51
+ Object.defineProperty(exports, key, {
52
+ enumerable: true,
53
+ get: function () {
54
+ return _ParagraphBuilder[key];
55
+ }
56
+ });
57
+ });
58
+
59
+ var _ParagraphStyle = require("./ParagraphStyle");
60
+
61
+ Object.keys(_ParagraphStyle).forEach(function (key) {
62
+ if (key === "default" || key === "__esModule") return;
63
+ if (key in exports && exports[key] === _ParagraphStyle[key]) return;
64
+ Object.defineProperty(exports, key, {
65
+ enumerable: true,
66
+ get: function () {
67
+ return _ParagraphStyle[key];
68
+ }
69
+ });
70
+ });
71
+
72
+ var _TextStyle = require("./TextStyle");
73
+
74
+ Object.keys(_TextStyle).forEach(function (key) {
75
+ if (key === "default" || key === "__esModule") return;
76
+ if (key in exports && exports[key] === _TextStyle[key]) return;
77
+ Object.defineProperty(exports, key, {
78
+ enumerable: true,
79
+ get: function () {
80
+ return _TextStyle[key];
81
+ }
82
+ });
83
+ });
84
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./TypefaceFontProvider\";\nexport * from \"./TypefaceFontProviderFactory\";\nexport * from \"./Paragraph\";\nexport * from \"./ParagraphBuilder\";\nexport * from \"./ParagraphStyle\";\nexport * from \"./TextStyle\";\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
@@ -25,6 +25,7 @@ import type { PictureFactory, SkPictureRecorder } from "./Picture";
25
25
  import type { Color, SkColor } from "./Color";
26
26
  import type { TypefaceFontProviderFactory } from "./Paragraph/TypefaceFontProviderFactory";
27
27
  import type { AnimatedImageFactory } from "./AnimatedImage";
28
+ import type { ParagraphBuilderFactory } from "./Paragraph/ParagraphBuilder";
28
29
  /**
29
30
  * Declares the interface for the native Skia API
30
31
  */
@@ -68,4 +69,5 @@ export interface Skia {
68
69
  SVG: SVGFactory;
69
70
  TextBlob: TextBlobFactory;
70
71
  Surface: SurfaceFactory;
72
+ ParagraphBuilder: ParagraphBuilderFactory;
71
73
  }
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["Skia.ts"],"sourcesContent":["import type { ImageFilterFactory } from \"./ImageFilter\";\nimport type { PathFactory } from \"./Path\";\nimport type { ColorFilterFactory } from \"./ColorFilter\";\nimport type { SkFont, FontMgrFactory } from \"./Font\";\nimport type { SkTypeface, TypefaceFactory } from \"./Typeface\";\nimport type { ImageFactory } from \"./Image\";\nimport type { MaskFilterFactory } from \"./MaskFilter\";\nimport type { SkPaint } from \"./Paint\";\nimport type { SkRect } from \"./Rect\";\nimport type { SkRRect } from \"./RRect\";\nimport type {\n RuntimeEffectFactory,\n SkRuntimeEffect,\n SkRuntimeShaderBuilder,\n} from \"./RuntimeEffect\";\nimport type { ShaderFactory } from \"./Shader\";\nimport type { SkMatrix } from \"./Matrix\";\nimport type { PathEffectFactory } from \"./PathEffect\";\nimport type { SkPoint } from \"./Point\";\nimport type { SkVertices, VertexMode } from \"./Vertices/Vertices\";\nimport type { DataFactory } from \"./Data\";\nimport type { SVGFactory } from \"./SVG\";\nimport type { TextBlobFactory } from \"./TextBlob\";\nimport type { SurfaceFactory } from \"./Surface\";\nimport type { SkRSXform } from \"./RSXform\";\nimport type { SkPath } from \"./Path/Path\";\nimport type { SkContourMeasureIter } from \"./ContourMeasure\";\nimport type { PictureFactory, SkPictureRecorder } from \"./Picture\";\nimport type { Color, SkColor } from \"./Color\";\nimport type { TypefaceFontProviderFactory } from \"./Paragraph/TypefaceFontProviderFactory\";\nimport type { AnimatedImageFactory } from \"./AnimatedImage\";\n\n/**\n * Declares the interface for the native Skia API\n */\nexport interface Skia {\n Point: (x: number, y: number) => SkPoint;\n XYWHRect: (x: number, y: number, width: number, height: number) => SkRect;\n RuntimeShaderBuilder: (rt: SkRuntimeEffect) => SkRuntimeShaderBuilder;\n RRectXY: (rect: SkRect, rx: number, ry: number) => SkRRect;\n RSXform: (scos: number, ssin: number, tx: number, ty: number) => SkRSXform;\n Color: (color: Color) => SkColor;\n ContourMeasureIter: (\n path: SkPath,\n forceClosed: boolean,\n resScale: number\n ) => SkContourMeasureIter;\n Paint: () => SkPaint;\n PictureRecorder: () => SkPictureRecorder;\n Picture: PictureFactory;\n Path: PathFactory;\n Matrix: (matrix?: readonly number[]) => SkMatrix;\n ColorFilter: ColorFilterFactory;\n Font: (typeface?: SkTypeface, size?: number) => SkFont;\n Typeface: TypefaceFactory;\n TypefaceFontProvider: TypefaceFontProviderFactory;\n FontMgr: FontMgrFactory;\n MaskFilter: MaskFilterFactory;\n RuntimeEffect: RuntimeEffectFactory;\n ImageFilter: ImageFilterFactory;\n Shader: ShaderFactory;\n PathEffect: PathEffectFactory;\n /**\n * Returns an Vertices based on the given positions and optional parameters.\n * See SkVertices.h (especially the Builder) for more details.\n * @param mode\n * @param positions\n * @param textureCoordinates\n * @param colors - either a list of int colors or a flattened color array.\n * @param indices\n * @param isVolatile\n */\n MakeVertices(\n mode: VertexMode,\n positions: SkPoint[],\n textureCoordinates?: SkPoint[] | null,\n colors?: SkColor[],\n indices?: number[] | null,\n isVolatile?: boolean\n ): SkVertices;\n Data: DataFactory;\n Image: ImageFactory;\n AnimatedImage: AnimatedImageFactory;\n SVG: SVGFactory;\n TextBlob: TextBlobFactory;\n Surface: SurfaceFactory;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["Skia.ts"],"sourcesContent":["import type { ImageFilterFactory } from \"./ImageFilter\";\nimport type { PathFactory } from \"./Path\";\nimport type { ColorFilterFactory } from \"./ColorFilter\";\nimport type { SkFont, FontMgrFactory } from \"./Font\";\nimport type { SkTypeface, TypefaceFactory } from \"./Typeface\";\nimport type { ImageFactory } from \"./Image\";\nimport type { MaskFilterFactory } from \"./MaskFilter\";\nimport type { SkPaint } from \"./Paint\";\nimport type { SkRect } from \"./Rect\";\nimport type { SkRRect } from \"./RRect\";\nimport type {\n RuntimeEffectFactory,\n SkRuntimeEffect,\n SkRuntimeShaderBuilder,\n} from \"./RuntimeEffect\";\nimport type { ShaderFactory } from \"./Shader\";\nimport type { SkMatrix } from \"./Matrix\";\nimport type { PathEffectFactory } from \"./PathEffect\";\nimport type { SkPoint } from \"./Point\";\nimport type { SkVertices, VertexMode } from \"./Vertices/Vertices\";\nimport type { DataFactory } from \"./Data\";\nimport type { SVGFactory } from \"./SVG\";\nimport type { TextBlobFactory } from \"./TextBlob\";\nimport type { SurfaceFactory } from \"./Surface\";\nimport type { SkRSXform } from \"./RSXform\";\nimport type { SkPath } from \"./Path/Path\";\nimport type { SkContourMeasureIter } from \"./ContourMeasure\";\nimport type { PictureFactory, SkPictureRecorder } from \"./Picture\";\nimport type { Color, SkColor } from \"./Color\";\nimport type { TypefaceFontProviderFactory } from \"./Paragraph/TypefaceFontProviderFactory\";\nimport type { AnimatedImageFactory } from \"./AnimatedImage\";\nimport type { ParagraphBuilderFactory } from \"./Paragraph/ParagraphBuilder\";\n\n/**\n * Declares the interface for the native Skia API\n */\nexport interface Skia {\n Point: (x: number, y: number) => SkPoint;\n XYWHRect: (x: number, y: number, width: number, height: number) => SkRect;\n RuntimeShaderBuilder: (rt: SkRuntimeEffect) => SkRuntimeShaderBuilder;\n RRectXY: (rect: SkRect, rx: number, ry: number) => SkRRect;\n RSXform: (scos: number, ssin: number, tx: number, ty: number) => SkRSXform;\n Color: (color: Color) => SkColor;\n ContourMeasureIter: (\n path: SkPath,\n forceClosed: boolean,\n resScale: number\n ) => SkContourMeasureIter;\n Paint: () => SkPaint;\n PictureRecorder: () => SkPictureRecorder;\n Picture: PictureFactory;\n Path: PathFactory;\n Matrix: (matrix?: readonly number[]) => SkMatrix;\n ColorFilter: ColorFilterFactory;\n Font: (typeface?: SkTypeface, size?: number) => SkFont;\n Typeface: TypefaceFactory;\n TypefaceFontProvider: TypefaceFontProviderFactory;\n FontMgr: FontMgrFactory;\n MaskFilter: MaskFilterFactory;\n RuntimeEffect: RuntimeEffectFactory;\n ImageFilter: ImageFilterFactory;\n Shader: ShaderFactory;\n PathEffect: PathEffectFactory;\n /**\n * Returns an Vertices based on the given positions and optional parameters.\n * See SkVertices.h (especially the Builder) for more details.\n * @param mode\n * @param positions\n * @param textureCoordinates\n * @param colors - either a list of int colors or a flattened color array.\n * @param indices\n * @param isVolatile\n */\n MakeVertices(\n mode: VertexMode,\n positions: SkPoint[],\n textureCoordinates?: SkPoint[] | null,\n colors?: SkColor[],\n indices?: number[] | null,\n isVolatile?: boolean\n ): SkVertices;\n Data: DataFactory;\n Image: ImageFactory;\n AnimatedImage: AnimatedImageFactory;\n SVG: SVGFactory;\n TextBlob: TextBlobFactory;\n Surface: SurfaceFactory;\n // Paragraph\n ParagraphBuilder: ParagraphBuilderFactory;\n}\n"],"mappings":""}
@@ -27,3 +27,4 @@ export * from "./JsiInstance";
27
27
  export * from "./Skia";
28
28
  export * from "./TextBlob";
29
29
  export * from "./Size";
30
+ export * from "./Paragraph";
@@ -380,4 +380,17 @@ Object.keys(_Size).forEach(function (key) {
380
380
  }
381
381
  });
382
382
  });
383
+
384
+ var _Paragraph = require("./Paragraph");
385
+
386
+ Object.keys(_Paragraph).forEach(function (key) {
387
+ if (key === "default" || key === "__esModule") return;
388
+ if (key in exports && exports[key] === _Paragraph[key]) return;
389
+ Object.defineProperty(exports, key, {
390
+ enumerable: true,
391
+ get: function () {
392
+ return _Paragraph[key];
393
+ }
394
+ });
395
+ });
383
396
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"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 \"./AnimatedImage\";\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\";\nexport * from \"./Size\";\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAA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;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"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 \"./AnimatedImage\";\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\";\nexport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AAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
@@ -105,12 +105,6 @@ class JsiSkImage extends _Host.HostObject {
105
105
 
106
106
  readPixels(srcX, srcY, imageInfo) {
107
107
  const info = this.getImageInfo();
108
- console.log({
109
- alphaType: (0, _Host.ckEnum)(info.alphaType),
110
- colorType: (0, _Host.ckEnum)(info.colorType),
111
- realAlphaType: this.CanvasKit.AlphaType.Opaque.value,
112
- realColorType: this.CanvasKit.ColorType.RGBA_8888.value
113
- });
114
108
  const pxInfo = {
115
109
  colorSpace: this.CanvasKit.ColorSpace.SRGB,
116
110
  width: (imageInfo === null || imageInfo === void 0 ? void 0 : imageInfo.width) ?? info.width,
@@ -1 +1 @@
1
- {"version":3,"names":["toBase64String","bytes","Buffer","from","toString","CHUNK_SIZE","index","length","result","slice","Math","min","String","fromCharCode","apply","btoa","JsiSkImage","HostObject","constructor","CanvasKit","ref","delete","height","width","getImageInfo","info","colorType","value","alphaType","makeShaderOptions","tx","ty","fm","mm","localMatrix","JsiSkShader","ckEnum","JsiSkMatrix","fromValue","undefined","makeShaderCubic","B","C","encodeToBytes","fmt","quality","Error","encodeToBase64","readPixels","srcX","srcY","imageInfo","console","log","realAlphaType","AlphaType","Opaque","realColorType","ColorType","RGBA_8888","pxInfo","colorSpace","ColorSpace","SRGB","getCkEnum","makeNonTextureImage","MakeImageFromEncoded"],"sources":["JsiSkImage.ts"],"sourcesContent":["import type {\n CanvasKit,\n ImageInfo as CKImageInfo,\n Image,\n} from \"canvaskit-wasm\";\n\nimport type {\n FilterMode,\n MipmapMode,\n SkImage,\n SkMatrix,\n SkShader,\n TileMode,\n ImageFormat,\n ImageInfo,\n} from \"../types\";\n\nimport { ckEnum, getCkEnum, HostObject } from \"./Host\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\nimport { JsiSkShader } from \"./JsiSkShader\";\n\n// https://github.com/google/skia/blob/1f193df9b393d50da39570dab77a0bb5d28ec8ef/modules/canvaskit/htmlcanvas/util.js\nexport const toBase64String = (bytes: Uint8Array) => {\n if (typeof Buffer !== \"undefined\") {\n // Are we on node?\n return Buffer.from(bytes).toString(\"base64\");\n } else {\n // From https://stackoverflow.com/a/25644409\n // because the naive solution of\n // btoa(String.fromCharCode.apply(null, bytes));\n // would occasionally throw \"Maximum call stack size exceeded\"\n var CHUNK_SIZE = 0x8000; //arbitrary number\n var index = 0;\n var { length } = bytes;\n var result = \"\";\n var slice;\n while (index < length) {\n slice = bytes.slice(index, Math.min(index + CHUNK_SIZE, length));\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n result += String.fromCharCode.apply(null, slice as any);\n index += CHUNK_SIZE;\n }\n return btoa(result);\n }\n};\n\nexport class JsiSkImage extends HostObject<Image, \"Image\"> implements SkImage {\n constructor(CanvasKit: CanvasKit, ref: Image) {\n super(CanvasKit, ref, \"Image\");\n }\n\n height() {\n return this.ref.height();\n }\n\n width() {\n return this.ref.width();\n }\n\n getImageInfo(): ImageInfo {\n const info = this.ref.getImageInfo();\n return {\n width: info.width,\n height: info.height,\n colorType: info.colorType.value,\n alphaType: info.alphaType.value,\n };\n }\n\n makeShaderOptions(\n tx: TileMode,\n ty: TileMode,\n fm: FilterMode,\n mm: MipmapMode,\n localMatrix?: SkMatrix\n ): SkShader {\n return new JsiSkShader(\n this.CanvasKit,\n this.ref.makeShaderOptions(\n ckEnum(tx),\n ckEnum(ty),\n ckEnum(fm),\n ckEnum(mm),\n localMatrix ? JsiSkMatrix.fromValue(localMatrix) : undefined\n )\n );\n }\n\n makeShaderCubic(\n tx: TileMode,\n ty: TileMode,\n B: number,\n C: number,\n localMatrix?: SkMatrix\n ): SkShader {\n return new JsiSkShader(\n this.CanvasKit,\n this.ref.makeShaderCubic(\n ckEnum(tx),\n ckEnum(ty),\n B,\n C,\n localMatrix ? JsiSkMatrix.fromValue(localMatrix) : undefined\n )\n );\n }\n\n encodeToBytes(fmt?: ImageFormat, quality?: number) {\n let result: Uint8Array | null;\n if (fmt && quality) {\n result = this.ref.encodeToBytes(ckEnum(fmt), quality);\n } else if (fmt) {\n result = this.ref.encodeToBytes(ckEnum(fmt));\n } else {\n result = this.ref.encodeToBytes();\n }\n if (!result) {\n throw new Error(\"encodeToBytes failed\");\n }\n return result;\n }\n\n encodeToBase64(fmt?: ImageFormat, quality?: number) {\n const bytes = this.encodeToBytes(fmt, quality);\n return toBase64String(bytes);\n }\n\n readPixels(srcX?: number, srcY?: number, imageInfo?: ImageInfo) {\n const info = this.getImageInfo();\n console.log({\n alphaType: ckEnum(info.alphaType),\n colorType: ckEnum(info.colorType),\n realAlphaType: this.CanvasKit.AlphaType.Opaque.value,\n realColorType: this.CanvasKit.ColorType.RGBA_8888.value,\n });\n const pxInfo: CKImageInfo = {\n colorSpace: this.CanvasKit.ColorSpace.SRGB,\n width: imageInfo?.width ?? info.width,\n height: imageInfo?.height ?? info.height,\n alphaType: getCkEnum(\n this.CanvasKit.AlphaType,\n (imageInfo ?? info).alphaType\n ),\n colorType: getCkEnum(\n this.CanvasKit.ColorType,\n (imageInfo ?? info).colorType\n ),\n };\n return this.ref.readPixels(srcX ?? 0, srcY ?? 0, pxInfo);\n }\n\n dispose = () => {\n this.ref.delete();\n };\n\n makeNonTextureImage(): SkImage {\n return new JsiSkImage(\n this.CanvasKit,\n this.CanvasKit.MakeImageFromEncoded(this.encodeToBytes())!\n );\n }\n}\n"],"mappings":";;;;;;;AAiBA;;AACA;;AACA;;;;AAEA;AACO,MAAMA,cAAc,GAAIC,KAAD,IAAuB;EACnD,IAAI,OAAOC,MAAP,KAAkB,WAAtB,EAAmC;IACjC;IACA,OAAOA,MAAM,CAACC,IAAP,CAAYF,KAAZ,EAAmBG,QAAnB,CAA4B,QAA5B,CAAP;EACD,CAHD,MAGO;IACL;IACA;IACA;IACA;IACA,IAAIC,UAAU,GAAG,MAAjB,CALK,CAKoB;;IACzB,IAAIC,KAAK,GAAG,CAAZ;IACA,IAAI;MAAEC;IAAF,IAAaN,KAAjB;IACA,IAAIO,MAAM,GAAG,EAAb;IACA,IAAIC,KAAJ;;IACA,OAAOH,KAAK,GAAGC,MAAf,EAAuB;MACrBE,KAAK,GAAGR,KAAK,CAACQ,KAAN,CAAYH,KAAZ,EAAmBI,IAAI,CAACC,GAAL,CAASL,KAAK,GAAGD,UAAjB,EAA6BE,MAA7B,CAAnB,CAAR,CADqB,CAErB;;MACAC,MAAM,IAAII,MAAM,CAACC,YAAP,CAAoBC,KAApB,CAA0B,IAA1B,EAAgCL,KAAhC,CAAV;MACAH,KAAK,IAAID,UAAT;IACD;;IACD,OAAOU,IAAI,CAACP,MAAD,CAAX;EACD;AACF,CAtBM;;;;AAwBA,MAAMQ,UAAN,SAAyBC,gBAAzB,CAAuE;EA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SAAzB,CAAmChC;IAJxC,CAAZ;IAMA,MAAMiC,MAAmB,GAAG;MAC1BC,UAAU,EAAE,KAAK1C,SAAL,CAAe2C,UAAf,CAA0BC,IADZ;MAE1BxC,KAAK,EAAE,CAAA4B,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAE5B,KAAX,KAAoBE,IAAI,CAACF,KAFN;MAG1BD,MAAM,EAAE,CAAA6B,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAE7B,MAAX,KAAqBG,IAAI,CAACH,MAHR;MAI1BM,SAAS,EAAE,IAAAoC,eAAA,EACT,KAAK7C,SAAL,CAAeoC,SADN,EAET,CAACJ,SAAS,IAAI1B,IAAd,EAAoBG,SAFX,CAJe;MAQ1BF,SAAS,EAAE,IAAAsC,eAAA,EACT,KAAK7C,SAAL,CAAeuC,SADN,EAET,CAACP,SAAS,IAAI1B,IAAd,EAAoBC,SAFX;IARe,CAA5B;IAaA,OAAO,KAAKN,GAAL,CAAS4B,UAAT,CAAoBC,IAAI,IAAI,CAA5B,EAA+BC,IAAI,IAAI,CAAvC,EAA0CU,MAA1C,CAAP;EACD;;EAMDK,mBAAmB,GAAY;IAC7B,OAAO,IAAIjD,UAAJ,CACL,KAAKG,SADA,EAEL,KAAKA,SAAL,CAAe+C,oBAAf,CAAoC,KAAKvB,aAAL,EAApC,CAFK,CAAP;EAID;;AAlH2E"}
1
+ {"version":3,"names":["toBase64String","bytes","Buffer","from","toString","CHUNK_SIZE","index","length","result","slice","Math","min","String","fromCharCode","apply","btoa","JsiSkImage","HostObject","constructor","CanvasKit","ref","delete","height","width","getImageInfo","info","colorType","value","alphaType","makeShaderOptions","tx","ty","fm","mm","localMatrix","JsiSkShader","ckEnum","JsiSkMatrix","fromValue","undefined","makeShaderCubic","B","C","encodeToBytes","fmt","quality","Error","encodeToBase64","readPixels","srcX","srcY","imageInfo","pxInfo","colorSpace","ColorSpace","SRGB","getCkEnum","AlphaType","ColorType","makeNonTextureImage","MakeImageFromEncoded"],"sources":["JsiSkImage.ts"],"sourcesContent":["import type {\n CanvasKit,\n ImageInfo as CKImageInfo,\n Image,\n} from \"canvaskit-wasm\";\n\nimport type {\n FilterMode,\n MipmapMode,\n SkImage,\n SkMatrix,\n SkShader,\n TileMode,\n ImageFormat,\n ImageInfo,\n} from \"../types\";\n\nimport { ckEnum, getCkEnum, HostObject } from \"./Host\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\nimport { JsiSkShader } from \"./JsiSkShader\";\n\n// https://github.com/google/skia/blob/1f193df9b393d50da39570dab77a0bb5d28ec8ef/modules/canvaskit/htmlcanvas/util.js\nexport const toBase64String = (bytes: Uint8Array) => {\n if (typeof Buffer !== \"undefined\") {\n // Are we on node?\n return Buffer.from(bytes).toString(\"base64\");\n } else {\n // From https://stackoverflow.com/a/25644409\n // because the naive solution of\n // btoa(String.fromCharCode.apply(null, bytes));\n // would occasionally throw \"Maximum call stack size exceeded\"\n var CHUNK_SIZE = 0x8000; //arbitrary number\n var index = 0;\n var { length } = bytes;\n var result = \"\";\n var slice;\n while (index < length) {\n slice = bytes.slice(index, Math.min(index + CHUNK_SIZE, length));\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n result += String.fromCharCode.apply(null, slice as any);\n index += CHUNK_SIZE;\n }\n return btoa(result);\n }\n};\n\nexport class JsiSkImage extends HostObject<Image, \"Image\"> implements SkImage {\n constructor(CanvasKit: CanvasKit, ref: Image) {\n super(CanvasKit, ref, \"Image\");\n }\n\n height() {\n return this.ref.height();\n }\n\n width() {\n return this.ref.width();\n }\n\n getImageInfo(): ImageInfo {\n const info = this.ref.getImageInfo();\n return {\n width: info.width,\n height: info.height,\n colorType: info.colorType.value,\n alphaType: info.alphaType.value,\n };\n }\n\n makeShaderOptions(\n tx: TileMode,\n ty: TileMode,\n fm: FilterMode,\n mm: MipmapMode,\n localMatrix?: SkMatrix\n ): SkShader {\n return new JsiSkShader(\n this.CanvasKit,\n this.ref.makeShaderOptions(\n ckEnum(tx),\n ckEnum(ty),\n ckEnum(fm),\n ckEnum(mm),\n localMatrix ? JsiSkMatrix.fromValue(localMatrix) : undefined\n )\n );\n }\n\n makeShaderCubic(\n tx: TileMode,\n ty: TileMode,\n B: number,\n C: number,\n localMatrix?: SkMatrix\n ): SkShader {\n return new JsiSkShader(\n this.CanvasKit,\n this.ref.makeShaderCubic(\n ckEnum(tx),\n ckEnum(ty),\n B,\n C,\n localMatrix ? JsiSkMatrix.fromValue(localMatrix) : undefined\n )\n );\n }\n\n encodeToBytes(fmt?: ImageFormat, quality?: number) {\n let result: Uint8Array | null;\n if (fmt && quality) {\n result = this.ref.encodeToBytes(ckEnum(fmt), quality);\n } else if (fmt) {\n result = this.ref.encodeToBytes(ckEnum(fmt));\n } else {\n result = this.ref.encodeToBytes();\n }\n if (!result) {\n throw new Error(\"encodeToBytes failed\");\n }\n return result;\n }\n\n encodeToBase64(fmt?: ImageFormat, quality?: number) {\n const bytes = this.encodeToBytes(fmt, quality);\n return toBase64String(bytes);\n }\n\n readPixels(srcX?: number, srcY?: number, imageInfo?: ImageInfo) {\n const info = this.getImageInfo();\n const pxInfo: CKImageInfo = {\n colorSpace: this.CanvasKit.ColorSpace.SRGB,\n width: imageInfo?.width ?? info.width,\n height: imageInfo?.height ?? info.height,\n alphaType: getCkEnum(\n this.CanvasKit.AlphaType,\n (imageInfo ?? info).alphaType\n ),\n colorType: getCkEnum(\n this.CanvasKit.ColorType,\n (imageInfo ?? info).colorType\n ),\n };\n return this.ref.readPixels(srcX ?? 0, srcY ?? 0, pxInfo);\n }\n\n dispose = () => {\n this.ref.delete();\n };\n\n makeNonTextureImage(): SkImage {\n return new JsiSkImage(\n this.CanvasKit,\n this.CanvasKit.MakeImageFromEncoded(this.encodeToBytes())!\n );\n }\n}\n"],"mappings":";;;;;;;AAiBA;;AACA;;AACA;;;;AAEA;AACO,MAAMA,cAAc,GAAIC,KAAD,IAAuB;EACnD,IAAI,OAAOC,MAAP,KAAkB,WA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AP;EAID;;AA5G2E"}
@@ -0,0 +1,16 @@
1
+ import type { CanvasKit, Paragraph } from "canvaskit-wasm";
2
+ import type { SkRect, SkRectWithDirection, SkParagraph } from "../types";
3
+ import { HostObject } from "./Host";
4
+ import type { JsiSkCanvas } from "./JsiSkCanvas";
5
+ export declare class JsiSkParagraph extends HostObject<Paragraph, "Paragraph"> implements SkParagraph {
6
+ constructor(CanvasKit: CanvasKit, ref: Paragraph);
7
+ layout(width: number): void;
8
+ paint(canvas: JsiSkCanvas, x: number, y: number): void;
9
+ getHeight(): number;
10
+ getMaxWidth(): number;
11
+ getGlyphPositionAtCoordinate(x: number, y: number): number;
12
+ getRectsForPlaceholders(): SkRectWithDirection[];
13
+ getRectsForRange(start: number, end: number): SkRect[];
14
+ getLineMetrics(): SkRect[];
15
+ dispose(): void;
16
+ }
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.JsiSkParagraph = void 0;
7
+
8
+ var _Host = require("./Host");
9
+
10
+ class JsiSkParagraph extends _Host.HostObject {
11
+ constructor(CanvasKit, ref) {
12
+ super(CanvasKit, ref, "Paragraph");
13
+ }
14
+
15
+ layout(width) {
16
+ this.ref.layout(width);
17
+ }
18
+
19
+ paint(canvas, x, y) {
20
+ canvas.ref.drawParagraph(this.ref, x, y);
21
+ }
22
+
23
+ getHeight() {
24
+ return this.ref.getHeight();
25
+ }
26
+
27
+ getMaxWidth() {
28
+ return this.ref.getMaxWidth();
29
+ }
30
+
31
+ getGlyphPositionAtCoordinate(x, y) {
32
+ return this.ref.getGlyphPositionAtCoordinate(x, y).pos;
33
+ }
34
+
35
+ getRectsForPlaceholders() {
36
+ return this.ref.getRectsForPlaceholders().map(_ref => {
37
+ let {
38
+ rect,
39
+ dir
40
+ } = _ref;
41
+ return {
42
+ rect: {
43
+ x: rect.at(0),
44
+ y: rect.at(1),
45
+ width: rect.at(2),
46
+ height: rect.at(3)
47
+ },
48
+ direction: dir.value
49
+ };
50
+ });
51
+ }
52
+
53
+ getRectsForRange(start, end) {
54
+ return this.ref.getRectsForRange(start, end, {
55
+ value: 0
56
+ }
57
+ /** kTight */
58
+ , {
59
+ value: 0
60
+ }
61
+ /** kTight */
62
+ ).map(_ref2 => {
63
+ let {
64
+ rect
65
+ } = _ref2;
66
+ return {
67
+ x: rect[0],
68
+ y: rect[1],
69
+ width: rect[2],
70
+ height: rect[3]
71
+ };
72
+ });
73
+ }
74
+
75
+ getLineMetrics() {
76
+ return this.ref.getLineMetrics().map((r, index) => ({
77
+ x: r.left,
78
+ y: index * r.height,
79
+ width: r.width,
80
+ height: r.height
81
+ }));
82
+ }
83
+
84
+ dispose() {
85
+ this.ref.delete();
86
+ }
87
+
88
+ }
89
+
90
+ exports.JsiSkParagraph = JsiSkParagraph;
91
+ //# sourceMappingURL=JsiSkParagraph.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["JsiSkParagraph","HostObject","constructor","CanvasKit","ref","layout","width","paint","canvas","x","y","drawParagraph","getHeight","getMaxWidth","getGlyphPositionAtCoordinate","pos","getRectsForPlaceholders","map","rect","dir","at","height","direction","value","getRectsForRange","start","end","getLineMetrics","r","index","left","dispose","delete"],"sources":["JsiSkParagraph.ts"],"sourcesContent":["import type { CanvasKit, Paragraph } from \"canvaskit-wasm\";\n\nimport type { SkRect, SkRectWithDirection, SkParagraph } from \"../types\";\n\nimport { HostObject } from \"./Host\";\nimport type { JsiSkCanvas } from \"./JsiSkCanvas\";\n\nexport class JsiSkParagraph\n extends HostObject<Paragraph, \"Paragraph\">\n implements SkParagraph\n{\n constructor(CanvasKit: CanvasKit, ref: Paragraph) {\n super(CanvasKit, ref, \"Paragraph\");\n }\n\n layout(width: number): void {\n this.ref.layout(width);\n }\n paint(canvas: JsiSkCanvas, x: number, y: number): void {\n canvas.ref.drawParagraph(this.ref, x, y);\n }\n getHeight(): number {\n return this.ref.getHeight();\n }\n getMaxWidth(): number {\n return this.ref.getMaxWidth();\n }\n getGlyphPositionAtCoordinate(x: number, y: number): number {\n return this.ref.getGlyphPositionAtCoordinate(x, y).pos;\n }\n getRectsForPlaceholders(): SkRectWithDirection[] {\n return this.ref.getRectsForPlaceholders().map(({ rect, dir }) => ({\n rect: {\n x: rect.at(0)!,\n y: rect.at(1)!,\n width: rect.at(2)!,\n height: rect.at(3)!,\n },\n direction: dir.value,\n }));\n }\n getRectsForRange(start: number, end: number): SkRect[] {\n return this.ref\n .getRectsForRange(\n start,\n end,\n { value: 0 } /** kTight */,\n { value: 0 } /** kTight */\n )\n .map(({ rect }) => ({\n x: rect[0],\n y: rect[1],\n width: rect[2],\n height: rect[3],\n }));\n }\n getLineMetrics(): SkRect[] {\n return this.ref.getLineMetrics().map((r, index) => ({\n x: r.left,\n y: index * r.height,\n width: r.width,\n height: r.height,\n }));\n }\n\n dispose() {\n this.ref.delete();\n }\n}\n"],"mappings":";;;;;;;AAIA;;AAGO,MAAMA,cAAN,SACGC,gBADH,CAGP;EACEC,WAAW,CAACC,SAAD,EAAuBC,GAAvB,EAAuC;IAChD,MAAMD,SAAN,EAAiBC,GAAjB,EAAsB,WAAtB;EACD;;EAEDC,MAAM,CAACC,KAAD,EAAsB;IAC1B,KAAKF,GAAL,CAASC,MAAT,CAAgBC,KAAhB;EACD;;EACDC,KAAK,CAACC,MAAD,EAAsBC,CAAtB,EAAiCC,CAAjC,EAAkD;IACrDF,MAAM,CAACJ,GAAP,CAAWO,aAAX,CAAyB,KAAKP,GAA9B,EAAmCK,CAAnC,EAAsCC,CAAtC;EACD;;EACDE,SAAS,GAAW;IAClB,OAAO,KAAKR,GAAL,CAASQ,SAAT,EAAP;EACD;;EACDC,WAAW,GAAW;IACpB,OAAO,KAAKT,GAAL,CAASS,WAAT,EAAP;EACD;;EACDC,4BAA4B,CAACL,CAAD,EAAYC,CAAZ,EAA+B;IACzD,OAAO,KAAKN,GAAL,CAASU,4BAAT,CAAsCL,CAAtC,EAAyCC,CAAzC,EAA4CK,GAA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AAC,CAACP;IAJwC,CAAf,CAA9B,CAAP;EAMD;;EAEDU,OAAO,GAAG;IACR,KAAK3B,GAAL,CAAS4B,MAAT;EACD;;AAzDH"}
@@ -0,0 +1,15 @@
1
+ import type { CanvasKit, ParagraphBuilder } from "canvaskit-wasm";
2
+ import type { SkParagraphBuilder, SkParagraph, SkTextStyle, SkPaint } from "../types";
3
+ import { PlaceholderAlignment, TextBaseline } from "../types";
4
+ import { HostObject } from "./Host";
5
+ export declare class JsiSkParagraphBuilder extends HostObject<ParagraphBuilder, "ParagraphBuilder"> implements SkParagraphBuilder {
6
+ constructor(CanvasKit: CanvasKit, ref: ParagraphBuilder);
7
+ addPlaceholder(width?: number | undefined, height?: number | undefined, alignment?: PlaceholderAlignment | undefined, baseline?: TextBaseline | undefined, offset?: number | undefined): SkParagraphBuilder;
8
+ addText(text: string): SkParagraphBuilder;
9
+ build(): SkParagraph;
10
+ reset(): void;
11
+ pushStyle(style: SkTextStyle, foregroundPaint?: SkPaint | undefined, backgroundPaint?: SkPaint | undefined): SkParagraphBuilder;
12
+ pop(): SkParagraphBuilder;
13
+ dispose(): void;
14
+ private makePaint;
15
+ }
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.JsiSkParagraphBuilder = void 0;
7
+
8
+ var _types = require("../types");
9
+
10
+ var _Host = require("./Host");
11
+
12
+ var _JsiSkParagraph = require("./JsiSkParagraph");
13
+
14
+ var _JsiSkTextStyle = require("./JsiSkTextStyle");
15
+
16
+ var _JsiSkPaint = require("./JsiSkPaint");
17
+
18
+ class JsiSkParagraphBuilder extends _Host.HostObject {
19
+ constructor(CanvasKit, ref) {
20
+ super(CanvasKit, ref, "ParagraphBuilder");
21
+ }
22
+
23
+ addPlaceholder() {
24
+ let width = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
25
+ let height = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
26
+ let alignment = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _types.PlaceholderAlignment.Baseline;
27
+ let baseline = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : _types.TextBaseline.Alphabetic;
28
+ let offset = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
29
+ this.ref.addPlaceholder(width, height, {
30
+ value: alignment
31
+ }, {
32
+ value: baseline
33
+ }, offset);
34
+ return this;
35
+ }
36
+
37
+ addText(text) {
38
+ this.ref.addText(text);
39
+ return this;
40
+ }
41
+
42
+ build() {
43
+ return new _JsiSkParagraph.JsiSkParagraph(this.CanvasKit, this.ref.build());
44
+ }
45
+
46
+ reset() {
47
+ this.ref.reset();
48
+ }
49
+
50
+ pushStyle(style, foregroundPaint, backgroundPaint) {
51
+ const textStyle = _JsiSkTextStyle.JsiSkTextStyle.toTextStyle(style);
52
+
53
+ if (foregroundPaint || backgroundPaint) {
54
+ // Due the canvaskit API not exposing textStyle methods,
55
+ // we set the default paint color to black for the foreground
56
+ // and transparent for the background
57
+ const fg = foregroundPaint ? _JsiSkPaint.JsiSkPaint.fromValue(foregroundPaint) : this.makePaint(textStyle.color ?? Float32Array.of(0, 0, 0, 1));
58
+ const bg = backgroundPaint ? _JsiSkPaint.JsiSkPaint.fromValue(backgroundPaint) : this.makePaint(textStyle.backgroundColor ?? Float32Array.of(0, 0, 0, 0));
59
+ this.ref.pushPaintStyle(new this.CanvasKit.TextStyle(textStyle), fg, bg);
60
+ } else {
61
+ this.ref.pushStyle(new this.CanvasKit.TextStyle(textStyle));
62
+ }
63
+
64
+ return this;
65
+ }
66
+
67
+ pop() {
68
+ this.ref.pop();
69
+ return this;
70
+ }
71
+
72
+ dispose() {
73
+ this.ref.delete();
74
+ }
75
+
76
+ makePaint(color) {
77
+ const paint = new this.CanvasKit.Paint();
78
+ paint.setColor(color);
79
+ return paint;
80
+ }
81
+
82
+ }
83
+
84
+ exports.JsiSkParagraphBuilder = JsiSkParagraphBuilder;
85
+ //# sourceMappingURL=JsiSkParagraphBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["JsiSkParagraphBuilder","HostObject","constructor","CanvasKit","ref","addPlaceholder","width","height","alignment","PlaceholderAlignment","Baseline","baseline","TextBaseline","Alphabetic","offset","value","addText","text","build","JsiSkParagraph","reset","pushStyle","style","foregroundPaint","backgroundPaint","textStyle","JsiSkTextStyle","toTextStyle","fg","JsiSkPaint","fromValue","makePaint","color","Float32Array","of","bg","backgroundColor","pushPaintStyle","TextStyle","pop","dispose","delete","paint","Paint","setColor"],"sources":["JsiSkParagraphBuilder.ts"],"sourcesContent":["import type {\n CanvasKit,\n InputColor,\n Paint,\n ParagraphBuilder,\n TextStyle,\n} from \"canvaskit-wasm\";\n\nimport type {\n SkParagraphBuilder,\n SkParagraph,\n SkTextStyle,\n SkPaint,\n} from \"../types\";\nimport { PlaceholderAlignment, TextBaseline } from \"../types\";\n\nimport { HostObject } from \"./Host\";\nimport { JsiSkParagraph } from \"./JsiSkParagraph\";\nimport { JsiSkTextStyle } from \"./JsiSkTextStyle\";\nimport { JsiSkPaint } from \"./JsiSkPaint\";\n\nexport class JsiSkParagraphBuilder\n extends HostObject<ParagraphBuilder, \"ParagraphBuilder\">\n implements SkParagraphBuilder\n{\n constructor(CanvasKit: CanvasKit, ref: ParagraphBuilder) {\n super(CanvasKit, ref, \"ParagraphBuilder\");\n }\n\n addPlaceholder(\n width: number | undefined = 0,\n height: number | undefined = 0,\n alignment: PlaceholderAlignment | undefined = PlaceholderAlignment.Baseline,\n baseline: TextBaseline | undefined = TextBaseline.Alphabetic,\n offset: number | undefined = 0\n ): SkParagraphBuilder {\n this.ref.addPlaceholder(\n width,\n height,\n { value: alignment },\n { value: baseline },\n offset\n );\n return this;\n }\n addText(text: string): SkParagraphBuilder {\n this.ref.addText(text);\n return this;\n }\n\n build(): SkParagraph {\n return new JsiSkParagraph(this.CanvasKit, this.ref.build());\n }\n\n reset(): void {\n this.ref.reset();\n }\n\n pushStyle(\n style: SkTextStyle,\n foregroundPaint?: SkPaint | undefined,\n backgroundPaint?: SkPaint | undefined\n ): SkParagraphBuilder {\n const textStyle: TextStyle = JsiSkTextStyle.toTextStyle(style);\n if (foregroundPaint || backgroundPaint) {\n // Due the canvaskit API not exposing textStyle methods,\n // we set the default paint color to black for the foreground\n // and transparent for the background\n const fg: Paint = foregroundPaint\n ? JsiSkPaint.fromValue(foregroundPaint)\n : this.makePaint(textStyle.color ?? Float32Array.of(0, 0, 0, 1));\n const bg: Paint = backgroundPaint\n ? JsiSkPaint.fromValue(backgroundPaint)\n : this.makePaint(\n textStyle.backgroundColor ?? Float32Array.of(0, 0, 0, 0)\n );\n this.ref.pushPaintStyle(new this.CanvasKit.TextStyle(textStyle), fg, bg);\n } else {\n this.ref.pushStyle(new this.CanvasKit.TextStyle(textStyle));\n }\n\n return this;\n }\n\n pop(): SkParagraphBuilder {\n this.ref.pop();\n return this;\n }\n\n dispose() {\n this.ref.delete();\n }\n\n private makePaint(color: InputColor) {\n const paint = new this.CanvasKit.Paint();\n paint.setColor(color);\n return paint;\n }\n}\n"],"mappings":";;;;;;;AAcA;;AAEA;;AACA;;AACA;;AACA;;AAEO,MAAMA,qBAAN,SACGC,gBADH,CAGP;EACEC,WAAW,CAACC,SAAD,EAAuBC,GAAvB,EAA8C;IACvD,MAAMD,SAAN,EAAiBC,GAAjB,EAAsB,kBAAtB;EACD;;EAEDC,cAAc,GAMQ;IAAA,IALpBC,KAKoB,uEALQ,CAKR;IAAA,IAJpBC,MAIoB,uEAJS,CAIT;IAAA,IAHpBC,SAGoB,uEAH0BC,2BAAA,CAAqBC,QAG/C;IAAA,IAFpBC,QAEoB,uEAFiBC,mBAAA,CAAaC,UAE9B;IAAA,IADpBC,MACoB,uEADS,CACT;IACpB,KAAKV,GAAL,CAASC,cAAT,CACEC,KADF,EAEEC,MAFF,EAGE;MAAEQ,KAAK,EAAEP;IAAT,CAHF,EAIE;MAAEO,KAAK,EAAEJ;IAAT,CAJF,EAKEG,MAL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G,GAAuB;IACxB,KAAKnC,GAAL,CAASmC,GAAT;IACA,OAAO,IAAP;EACD;;EAEDC,OAAO,GAAG;IACR,KAAKpC,GAAL,CAASqC,MAAT;EACD;;EAEOV,SAAS,CAACC,KAAD,EAAoB;IACnC,MAAMU,KAAK,GAAG,IAAI,KAAKvC,SAAL,CAAewC,KAAnB,EAAd;IACAD,KAAK,CAACE,QAAN,CAAeZ,KAAf;IACA,OAAOU,KAAP;EACD;;AAzEH"}
@@ -0,0 +1,8 @@
1
+ import type { CanvasKit } from "canvaskit-wasm";
2
+ import type { ParagraphBuilderFactory, SkParagraphStyle, SkTypefaceFontProvider } from "../types";
3
+ import { Host } from "./Host";
4
+ import { JsiSkParagraphBuilder } from "./JsiSkParagraphBuilder";
5
+ export declare class JsiSkParagraphBuilderFactory extends Host implements ParagraphBuilderFactory {
6
+ constructor(CanvasKit: CanvasKit);
7
+ Make(paragraphStyle: SkParagraphStyle, typefaceProvider?: SkTypefaceFontProvider): JsiSkParagraphBuilder;
8
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.JsiSkParagraphBuilderFactory = void 0;
7
+
8
+ var _Host = require("./Host");
9
+
10
+ var _JsiSkParagraphBuilder = require("./JsiSkParagraphBuilder");
11
+
12
+ var _JsiSkParagraphStyle = require("./JsiSkParagraphStyle");
13
+
14
+ var _JsiSkTypeface = require("./JsiSkTypeface");
15
+
16
+ class JsiSkParagraphBuilderFactory extends _Host.Host {
17
+ constructor(CanvasKit) {
18
+ super(CanvasKit);
19
+ }
20
+
21
+ Make(paragraphStyle, typefaceProvider) {
22
+ const style = new this.CanvasKit.ParagraphStyle(_JsiSkParagraphStyle.JsiSkParagraphStyle.toParagraphStyle(this.CanvasKit, paragraphStyle ?? {}));
23
+
24
+ if (typefaceProvider === undefined) {
25
+ throw new Error("SkTypefaceFontProvider is required on React Native Web.");
26
+ }
27
+
28
+ return new _JsiSkParagraphBuilder.JsiSkParagraphBuilder(this.CanvasKit, this.CanvasKit.ParagraphBuilder.MakeFromFontProvider(style, _JsiSkTypeface.JsiSkTypeface.fromValue(typefaceProvider)));
29
+ }
30
+
31
+ }
32
+
33
+ exports.JsiSkParagraphBuilderFactory = JsiSkParagraphBuilderFactory;
34
+ //# sourceMappingURL=JsiSkParagraphBuilderFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["JsiSkParagraphBuilderFactory","Host","constructor","CanvasKit","Make","paragraphStyle","typefaceProvider","style","ParagraphStyle","JsiSkParagraphStyle","toParagraphStyle","undefined","Error","JsiSkParagraphBuilder","ParagraphBuilder","MakeFromFontProvider","JsiSkTypeface","fromValue"],"sources":["JsiSkParagraphBuilderFactory.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type {\n ParagraphBuilderFactory,\n SkParagraphStyle,\n SkTypefaceFontProvider,\n} from \"../types\";\n\nimport { Host } from \"./Host\";\nimport { JsiSkParagraphBuilder } from \"./JsiSkParagraphBuilder\";\nimport { JsiSkParagraphStyle } from \"./JsiSkParagraphStyle\";\nimport { JsiSkTypeface } from \"./JsiSkTypeface\";\n\nexport class JsiSkParagraphBuilderFactory\n extends Host\n implements ParagraphBuilderFactory\n{\n constructor(CanvasKit: CanvasKit) {\n super(CanvasKit);\n }\n\n Make(\n paragraphStyle: SkParagraphStyle,\n typefaceProvider?: SkTypefaceFontProvider\n ) {\n const style = new this.CanvasKit.ParagraphStyle(\n JsiSkParagraphStyle.toParagraphStyle(this.CanvasKit, paragraphStyle ?? {})\n );\n if (typefaceProvider === undefined) {\n throw new Error(\n \"SkTypefaceFontProvider is required on React Native Web.\"\n );\n }\n return new JsiSkParagraphBuilder(\n this.CanvasKit,\n this.CanvasKit.ParagraphBuilder.MakeFromFontProvider(\n style,\n JsiSkTypeface.fromValue(typefaceProvider)\n )\n );\n }\n}\n"],"mappings":";;;;;;;AAQA;;AACA;;AACA;;AACA;;AAEO,MAAMA,4BAAN,SACGC,UADH,CAGP;EACEC,WAAW,CAACC,SAAD,EAAuB;IAChC,MAAMA,SAAN;EACD;;EAEDC,IAAI,CACFC,cADE,EAEFC,gBAFE,EAGF;IACA,MAAMC,KAAK,GAAG,IAAI,KAAKJ,SAAL,CAAeK,cAAnB,CACZC,wCAAA,CAAoBC,gBAApB,CAAqC,KAAKP,SAA1C,EAAqDE,cAAc,IAAI,EAAvE,CADY,CAAd;;IAGA,IAAIC,gBAAgB,KAAKK,SAAzB,EAAoC;MAClC,MAAM,IAAIC,KAAJ,CACJ,yDADI,CAAN;IAGD;;IACD,OAAO,IAAIC,4CAAJ,CACL,KAAKV,SADA,EAEL,KAAKA,SAAL,CAAeW,gBAAf,CAAgCC,oBAAhC,CACER,KADF,EAEES,4BAAA,CAAcC,SAAd,CAAwBX,gBAAxB,CAFF,CAFK,CAAP;EAOD;;AAxBH"}
@@ -0,0 +1,5 @@
1
+ import type { CanvasKit, ParagraphStyle } from "canvaskit-wasm";
2
+ import { type SkParagraphStyle } from "../types";
3
+ export declare class JsiSkParagraphStyle {
4
+ static toParagraphStyle(ck: CanvasKit, value: SkParagraphStyle): ParagraphStyle;
5
+ }
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.JsiSkParagraphStyle = void 0;
7
+
8
+ var _types = require("../types");
9
+
10
+ class JsiSkParagraphStyle {
11
+ static toParagraphStyle(ck, value) {
12
+ var _value$strutStyle, _value$strutStyle2, _value$strutStyle3, _value$strutStyle4, _value$strutStyle5, _value$strutStyle6, _value$strutStyle6$fo, _value$strutStyle7, _value$strutStyle7$fo, _value$strutStyle8, _value$strutStyle8$fo, _value$strutStyle9, _value$strutStyle10;
13
+
14
+ // Seems like we need to provide the textStyle.color value, otherwise
15
+ // the constructor crashes.
16
+ const ps = new ck.ParagraphStyle({
17
+ textStyle: {
18
+ color: ck.BLACK
19
+ }
20
+ });
21
+ ps.disableHinting = value.disableHinting ?? ps.disableHinting;
22
+ ps.ellipsis = value.ellipsis ?? ps.ellipsis;
23
+ ps.heightMultiplier = value.heightMultiplier ?? ps.heightMultiplier;
24
+ ps.maxLines = value.maxLines ?? ps.maxLines;
25
+ ps.replaceTabCharacters = value.replaceTabCharacters ?? ps.replaceTabCharacters;
26
+ ps.textAlign = value.textAlign !== undefined ? {
27
+ value: value.textAlign
28
+ } : undefined ?? ps.textAlign;
29
+ ps.textDirection = value.textDirection !== undefined ? {
30
+ value: value.textDirection === _types.SkTextDirection.LTR ? 1 : 0
31
+ } : ps.textDirection;
32
+ ps.textHeightBehavior = value.textHeightBehavior !== undefined ? {
33
+ value: value.textHeightBehavior
34
+ } : ps.textHeightBehavior;
35
+ ps.strutStyle = ps.strutStyle ?? {};
36
+ ps.strutStyle.fontFamilies = ((_value$strutStyle = value.strutStyle) === null || _value$strutStyle === void 0 ? void 0 : _value$strutStyle.fontFamilies) ?? ps.strutStyle.fontFamilies;
37
+ ps.strutStyle.fontSize = ((_value$strutStyle2 = value.strutStyle) === null || _value$strutStyle2 === void 0 ? void 0 : _value$strutStyle2.fontSize) ?? ps.strutStyle.fontSize;
38
+ ps.strutStyle.heightMultiplier = ((_value$strutStyle3 = value.strutStyle) === null || _value$strutStyle3 === void 0 ? void 0 : _value$strutStyle3.heightMultiplier) ?? ps.strutStyle.heightMultiplier;
39
+ ps.strutStyle.leading = ((_value$strutStyle4 = value.strutStyle) === null || _value$strutStyle4 === void 0 ? void 0 : _value$strutStyle4.leading) ?? ps.strutStyle.leading;
40
+ ps.strutStyle.forceStrutHeight = ((_value$strutStyle5 = value.strutStyle) === null || _value$strutStyle5 === void 0 ? void 0 : _value$strutStyle5.forceStrutHeight) ?? ps.strutStyle.forceStrutHeight;
41
+ ps.strutStyle.fontStyle = ps.strutStyle.fontStyle ?? {};
42
+ ps.strutStyle.fontStyle.slant = ((_value$strutStyle6 = value.strutStyle) === null || _value$strutStyle6 === void 0 ? void 0 : (_value$strutStyle6$fo = _value$strutStyle6.fontStyle) === null || _value$strutStyle6$fo === void 0 ? void 0 : _value$strutStyle6$fo.slant) !== undefined ? {
43
+ value: value.strutStyle.fontStyle.slant
44
+ } : ps.strutStyle.fontStyle.slant;
45
+ ps.strutStyle.fontStyle.width = ((_value$strutStyle7 = value.strutStyle) === null || _value$strutStyle7 === void 0 ? void 0 : (_value$strutStyle7$fo = _value$strutStyle7.fontStyle) === null || _value$strutStyle7$fo === void 0 ? void 0 : _value$strutStyle7$fo.width) !== undefined ? {
46
+ value: value.strutStyle.fontStyle.width
47
+ } : ps.strutStyle.fontStyle.width;
48
+ ps.strutStyle.fontStyle.weight = ((_value$strutStyle8 = value.strutStyle) === null || _value$strutStyle8 === void 0 ? void 0 : (_value$strutStyle8$fo = _value$strutStyle8.fontStyle) === null || _value$strutStyle8$fo === void 0 ? void 0 : _value$strutStyle8$fo.weight) !== undefined ? {
49
+ value: value.strutStyle.fontStyle.weight
50
+ } : ps.strutStyle.fontStyle.weight;
51
+ ps.strutStyle.halfLeading = ((_value$strutStyle9 = value.strutStyle) === null || _value$strutStyle9 === void 0 ? void 0 : _value$strutStyle9.halfLeading) ?? ps.strutStyle.halfLeading;
52
+ ps.strutStyle.strutEnabled = ((_value$strutStyle10 = value.strutStyle) === null || _value$strutStyle10 === void 0 ? void 0 : _value$strutStyle10.strutEnabled) ?? ps.strutStyle.strutEnabled;
53
+ return ps;
54
+ }
55
+
56
+ }
57
+
58
+ exports.JsiSkParagraphStyle = JsiSkParagraphStyle;
59
+ //# sourceMappingURL=JsiSkParagraphStyle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["JsiSkParagraphStyle","toParagraphStyle","ck","value","ps","ParagraphStyle","textStyle","color","BLACK","disableHinting","ellipsis","heightMultiplier","maxLines","replaceTabCharacters","textAlign","undefined","textDirection","SkTextDirection","LTR","textHeightBehavior","strutStyle","fontFamilies","fontSize","leading","forceStrutHeight","fontStyle","slant","width","weight","halfLeading","strutEnabled"],"sources":["JsiSkParagraphStyle.ts"],"sourcesContent":["import type { CanvasKit, ParagraphStyle } from \"canvaskit-wasm\";\n\nimport { SkTextDirection, type SkParagraphStyle } from \"../types\";\n\nexport class JsiSkParagraphStyle {\n static toParagraphStyle(\n ck: CanvasKit,\n value: SkParagraphStyle\n ): ParagraphStyle {\n // Seems like we need to provide the textStyle.color value, otherwise\n // the constructor crashes.\n const ps = new ck.ParagraphStyle({ textStyle: { color: ck.BLACK } });\n\n ps.disableHinting = value.disableHinting ?? ps.disableHinting;\n ps.ellipsis = value.ellipsis ?? ps.ellipsis;\n ps.heightMultiplier = value.heightMultiplier ?? ps.heightMultiplier;\n ps.maxLines = value.maxLines ?? ps.maxLines;\n ps.replaceTabCharacters =\n value.replaceTabCharacters ?? ps.replaceTabCharacters;\n ps.textAlign =\n value.textAlign !== undefined\n ? { value: value.textAlign }\n : undefined ?? ps.textAlign;\n ps.textDirection =\n value.textDirection !== undefined\n ? { value: value.textDirection === SkTextDirection.LTR ? 1 : 0 }\n : ps.textDirection;\n ps.textHeightBehavior =\n value.textHeightBehavior !== undefined\n ? { value: value.textHeightBehavior }\n : ps.textHeightBehavior;\n\n ps.strutStyle = ps.strutStyle ?? {};\n ps.strutStyle.fontFamilies =\n value.strutStyle?.fontFamilies ?? ps.strutStyle.fontFamilies;\n ps.strutStyle.fontSize =\n value.strutStyle?.fontSize ?? ps.strutStyle.fontSize;\n ps.strutStyle.heightMultiplier =\n value.strutStyle?.heightMultiplier ?? ps.strutStyle.heightMultiplier;\n ps.strutStyle.leading = value.strutStyle?.leading ?? ps.strutStyle.leading;\n ps.strutStyle.forceStrutHeight =\n value.strutStyle?.forceStrutHeight ?? ps.strutStyle.forceStrutHeight;\n\n ps.strutStyle.fontStyle = ps.strutStyle.fontStyle ?? {};\n\n ps.strutStyle.fontStyle.slant =\n value.strutStyle?.fontStyle?.slant !== undefined\n ? { value: value.strutStyle.fontStyle.slant }\n : ps.strutStyle.fontStyle.slant;\n ps.strutStyle.fontStyle.width =\n value.strutStyle?.fontStyle?.width !== undefined\n ? { value: value.strutStyle.fontStyle.width }\n : ps.strutStyle.fontStyle.width;\n ps.strutStyle.fontStyle.weight =\n value.strutStyle?.fontStyle?.weight !== undefined\n ? { value: value.strutStyle.fontStyle.weight }\n : ps.strutStyle.fontStyle.weight;\n ps.strutStyle.halfLeading =\n value.strutStyle?.halfLeading ?? ps.strutStyle.halfLeading;\n ps.strutStyle.strutEnabled =\n value.strutStyle?.strutEnabled ?? ps.strutStyle.strutEnabled;\n\n return ps;\n }\n}\n"],"mappings":";;;;;;;AAEA;;AAEO,MAAMA,mBAAN,CAA0B;EACR,OAAhBC,gBAAgB,CACrBC,EADqB,EAErBC,KAFqB,EAGL;IAAA;;IAChB;IACA;IACA,MAAMC,EAAE,GAAG,IAAIF,EAAE,CAACG,cAAP,CAAsB;MAAEC,SAAS,EAAE;QAAEC,KAAK,EAAEL,EAAE,CAACM;MAAZ;IAAb,CAAtB,CAAX;IAEAJ,EAAE,CAACK,cAAH,GAAoBN,KAAK,CAACM,cAAN,IAAwBL,EAAE,CAACK,cAA/C;IACAL,EAAE,CAACM,QAAH,GAAcP,KAAK,CAACO,QAAN,IAAkBN,EAAE,CAACM,QAAnC;IACAN,EAAE,CAACO,gBAAH,GAAsBR,KAAK,CAACQ,gBAAN,IAA0BP,EAAE,CAACO,gBAAnD;IACAP,EAAE,CAACQ,QAAH,GAAcT,KAAK,CAACS,QAAN,IAAkBR,EAAE,CAACQ,QAAnC;IACAR,EAAE,CAACS,oBAAH,GACEV,KAAK,CAACU,oBAAN,IAA8BT,EAAE,CAACS,oBADnC;IAEAT,EAAE,CAACU,SAAH,GACEX,KAAK,CAACW,SAAN,KAAoBC,SAApB,GACI;MAAEZ,KAAK,EAAEA,KAAK,CAACW;IAAf,CADJ,GAEIC,SAAS,IAAIX,EAAE,CAACU,SAHtB;IAIAV,EAAE,CAACY,aAAH,GACEb,KAAK,CAACa,aAAN,KAAwBD,SAAxB,GACI;MAAEZ,KAAK,EA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AAvC,GACI;MAAEZ,KAAK,EAAEA,KAAK,CAACiB,UAAN,CAAiBK,SAAjB,CAA2BC;IAApC,CADJ,GAEItB,EAAE,CAACgB,UAAH,CAAcK,SAAd,CAAwBC,KAH9B;IAIAtB,EAAE,CAACgB,UAAH,CAAcK,SAAd,CAAwBE,KAAxB,GACE,uBAAAxB,KAAK,CAACiB,UAAN,mGAAkBK,SAAlB,gFAA6BE,KAA7B,MAAuCZ,SAAvC,GACI;MAAEZ,KAAK,EAAEA,KAAK,CAACiB,UAAN,CAAiBK,SAAjB,CAA2BE;IAApC,CADJ,GAEIvB,EAAE,CAACgB,UAAH,CAAcK,SAAd,CAAwBE,KAH9B;IAIAvB,EAAE,CAACgB,UAAH,CAAcK,SAAd,CAAwBG,MAAxB,GACE,uBAAAzB,KAAK,CAACiB,UAAN,mGAAkBK,SAAlB,gFAA6BG,MAA7B,MAAwCb,SAAxC,GACI;MAAEZ,KAAK,EAAEA,KAAK,CAACiB,UAAN,CAAiBK,SAAjB,CAA2BG;IAApC,CADJ,GAEIxB,EAAE,CAACgB,UAAH,CAAcK,SAAd,CAAwBG,MAH9B;IAIAxB,EAAE,CAACgB,UAAH,CAAcS,WAAd,GACE,uBAAA1B,KAAK,CAACiB,UAAN,0EAAkBS,WAAlB,KAAiCzB,EAAE,CAACgB,UAAH,CAAcS,WADjD;IAEAzB,EAAE,CAACgB,UAAH,CAAcU,YAAd,GACE,wBAAA3B,KAAK,CAACiB,UAAN,4EAAkBU,YAAlB,KAAkC1B,EAAE,CAACgB,UAAH,CAAcU,YADlD;IAGA,OAAO1B,EAAP;EACD;;AA3D8B"}
@@ -0,0 +1,5 @@
1
+ import type { TextStyle } from "canvaskit-wasm";
2
+ import type { SkTextStyle } from "../types";
3
+ export declare class JsiSkTextStyle {
4
+ static toTextStyle(value: SkTextStyle): TextStyle;
5
+ }