@shopify/react-native-skia 0.1.221 → 0.1.223

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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,4 @@
1
+ import React from "react";
2
+ import type { ParagraphProps } from "../../../dom/types/Paragraph";
3
+ import type { SkiaProps } from "../../processors";
4
+ export declare const Paragraph: (props: SkiaProps<ParagraphProps>) => React.JSX.Element;
@@ -0,0 +1 @@
1
+ export * from "./Paragraph";
@@ -0,0 +1,56 @@
1
+ import type { SkCanvas } from "../Canvas";
2
+ import type { SkJSIInstance } from "../JsiInstance";
3
+ import type { SkRect } from "../Rect";
4
+ import type { SkTextDirection } from "./ParagraphStyle";
5
+ export interface SkRectWithDirection {
6
+ rect: SkRect;
7
+ direction: SkTextDirection;
8
+ }
9
+ export interface SkParagraph extends SkJSIInstance<"Paragraph"> {
10
+ /**
11
+ * Calculates the position of the the glyphs in the paragraph
12
+ * @param width Max width of the paragraph
13
+ */
14
+ layout(width: number): void;
15
+ /**
16
+ * Paints the paragraph to the provded canvas
17
+ * @param canvas Canvas to paint into
18
+ * @param x X coordinate to paint at
19
+ * @param y Y coordinate to paint at
20
+ */
21
+ paint(canvas: SkCanvas, x: number, y: number): void;
22
+ /**
23
+ * Returns the height of the paragraph. This method requires the layout
24
+ * method to have been called first.
25
+ */
26
+ getHeight(): number;
27
+ /**
28
+ * Returns the max width of the paragraph. This method requires the layout
29
+ * method to have been called first.
30
+ */
31
+ getMaxWidth(): number;
32
+ /**
33
+ * Returns the index of the glyph at the given position. This method requires
34
+ * the layout method to have been called first.
35
+ * @param x X coordinate of the position
36
+ * @param y Y coordinate of the position
37
+ */
38
+ getGlyphPositionAtCoordinate(x: number, y: number): number;
39
+ /**
40
+ * Returns the bounding boxes of the glyphs in the given range. This method
41
+ * requires the layout method to have been called first.
42
+ * @param start Start index of the range
43
+ * @param end End index of the range
44
+ */
45
+ getRectsForRange(start: number, end: number): SkRect[];
46
+ /**
47
+ * Returns the bounding boxes for all lines in the paragraph. This method
48
+ * requires the layout method to have been called first.
49
+ */
50
+ getLineMetrics(): Array<SkRect>;
51
+ /**
52
+ * Returns a list of rects with direction info for the placeholders added
53
+ * to the paragraph.
54
+ */
55
+ getRectsForPlaceholders(): SkRectWithDirection[];
56
+ }
@@ -0,0 +1,60 @@
1
+ import type { SkJSIInstance } from "../JsiInstance";
2
+ import type { SkPaint } from "../Paint";
3
+ import type { SkParagraph } from "./Paragraph";
4
+ import type { SkParagraphStyle } from "./ParagraphStyle";
5
+ import type { SkTextStyle, TextBaseline } from "./TextStyle";
6
+ import type { SkTypefaceFontProvider } from "./TypefaceFontProvider";
7
+ export interface ParagraphBuilderFactory {
8
+ /**
9
+ * Creates a new ParagraphBuilder object from custom fonts.
10
+ * @param paragraphStyle Initial paragraph style
11
+ * @param typefaceProvider Typeface provider
12
+ */
13
+ Make(paragraphStyle?: SkParagraphStyle, typefaceProvider?: SkTypefaceFontProvider): SkParagraphBuilder;
14
+ }
15
+ export declare enum PlaceholderAlignment {
16
+ Baseline = 0,
17
+ AboveBaseline = 1,
18
+ BelowBaseline = 2,
19
+ Top = 3,
20
+ Bottom = 4,
21
+ Middle = 5
22
+ }
23
+ export interface SkParagraphBuilder extends SkJSIInstance<"ParagraphBuilder"> {
24
+ /**
25
+ * Creates a Paragraph object from the builder and the inputs given to the builder.
26
+ */
27
+ build(): SkParagraph;
28
+ /**
29
+ * Restores the builder to its initial empty state.
30
+ */
31
+ reset(): void;
32
+ /**
33
+ * Pushes a text-style to the builder
34
+ * @param style Style to push
35
+ * @param foregroundPaint Foreground paint object
36
+ * @param backgroundPaint Background paint object
37
+ * @returns The builder
38
+ */
39
+ pushStyle: (style: SkTextStyle, foregroundPaint?: SkPaint | undefined, backgroundPaint?: SkPaint | undefined) => SkParagraphBuilder;
40
+ /**
41
+ * Pops the current text style from the builder
42
+ * @returns The builder
43
+ */
44
+ pop: () => SkParagraphBuilder;
45
+ /**
46
+ * Adds text to the builder
47
+ * @param text
48
+ * @returns The builder
49
+ */
50
+ addText: (text: string) => SkParagraphBuilder;
51
+ /**
52
+ * Pushes the information required to leave an open space.
53
+ * @param width
54
+ * @param height
55
+ * @param alignment
56
+ * @param baseline
57
+ * @param offset
58
+ */
59
+ addPlaceholder(width?: number, height?: number, alignment?: PlaceholderAlignment, baseline?: TextBaseline, offset?: number): SkParagraphBuilder;
60
+ }
@@ -0,0 +1,41 @@
1
+ import type { SkTextFontStyle, SkTextStyle } from "./TextStyle";
2
+ export declare enum SkTextDirection {
3
+ RTL = 0,
4
+ LTR = 1
5
+ }
6
+ export declare enum SkTextAlign {
7
+ Left = 0,
8
+ Right = 1,
9
+ Center = 2,
10
+ Justify = 3,
11
+ Start = 4,
12
+ End = 5
13
+ }
14
+ export interface SkStrutStyle {
15
+ strutEnabled?: boolean;
16
+ fontFamilies?: string[];
17
+ fontStyle?: SkTextFontStyle;
18
+ fontSize?: number;
19
+ heightMultiplier?: number;
20
+ halfLeading?: boolean;
21
+ leading?: number;
22
+ forceStrutHeight?: boolean;
23
+ }
24
+ export declare enum SkTextHeightBehavior {
25
+ All = 0,
26
+ DisableFirstAscent = 1,
27
+ DisableLastDescent = 2,
28
+ DisableAll = 3
29
+ }
30
+ export interface SkParagraphStyle {
31
+ disableHinting?: boolean;
32
+ ellipsis?: string;
33
+ heightMultiplier?: number;
34
+ maxLines?: number;
35
+ replaceTabCharacters?: boolean;
36
+ strutStyle?: SkStrutStyle;
37
+ textAlign?: SkTextAlign;
38
+ textDirection?: SkTextDirection;
39
+ textHeightBehavior?: SkTextHeightBehavior;
40
+ textStyle?: SkTextStyle;
41
+ }
@@ -0,0 +1,62 @@
1
+ import type { SkColor } from "../Color";
2
+ import type { FontSlant, FontWeight, FontWidth } from "../Font";
3
+ import type { SkPoint } from "../Point";
4
+ export declare enum TextDecoration {
5
+ NoDecoration = 0,
6
+ Underline = 1,
7
+ Overline = 2,
8
+ LineThrough = 4
9
+ }
10
+ export declare enum TextDecorationStyle {
11
+ Solid = 0,
12
+ Double = 1,
13
+ Dotted = 2,
14
+ Dashed = 3,
15
+ Wavy = 4
16
+ }
17
+ export interface SkTextShadow {
18
+ color?: SkColor;
19
+ /**
20
+ * 2d array for x and y offset. Defaults to [0, 0]
21
+ */
22
+ offset?: SkPoint;
23
+ blurRadius?: number;
24
+ }
25
+ export interface SkTextFontFeatures {
26
+ name: string;
27
+ value: number;
28
+ }
29
+ export interface SkTextFontStyle {
30
+ weight?: FontWeight;
31
+ width?: FontWidth;
32
+ slant?: FontSlant;
33
+ }
34
+ export interface SkTextFontVariations {
35
+ axis: string;
36
+ value: number;
37
+ }
38
+ export declare enum TextBaseline {
39
+ Alphabetic = 0,
40
+ Ideographic = 1
41
+ }
42
+ export interface SkTextStyle {
43
+ backgroundColor?: SkColor;
44
+ color?: SkColor;
45
+ decoration?: number;
46
+ decorationColor?: SkColor;
47
+ decorationThickness?: number;
48
+ decorationStyle?: TextDecoration;
49
+ fontFamilies?: string[];
50
+ fontFeatures?: SkTextFontFeatures[];
51
+ fontSize?: number;
52
+ fontStyle?: SkTextFontStyle;
53
+ fontVariations?: SkTextFontVariations[];
54
+ foregroundColor?: SkColor;
55
+ heightMultiplier?: number;
56
+ halfLeading?: boolean;
57
+ letterSpacing?: number;
58
+ locale?: string;
59
+ shadows?: SkTextShadow[];
60
+ textBaseline?: TextBaseline;
61
+ wordSpacing?: number;
62
+ }
@@ -0,0 +1,6 @@
1
+ export * from "./TypefaceFontProvider";
2
+ export * from "./TypefaceFontProviderFactory";
3
+ export * from "./Paragraph";
4
+ export * from "./ParagraphBuilder";
5
+ export * from "./ParagraphStyle";
6
+ export * from "./TextStyle";
@@ -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
  }
@@ -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";
@@ -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,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,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,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,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
+ }
@@ -6,32 +6,32 @@
6
6
  <array>
7
7
  <dict>
8
8
  <key>LibraryIdentifier</key>
9
- <string>ios-arm64_arm64e</string>
9
+ <string>ios-arm64_arm64e_x86_64-simulator</string>
10
10
  <key>LibraryPath</key>
11
11
  <string>libskottie.a</string>
12
12
  <key>SupportedArchitectures</key>
13
13
  <array>
14
14
  <string>arm64</string>
15
15
  <string>arm64e</string>
16
+ <string>x86_64</string>
16
17
  </array>
17
18
  <key>SupportedPlatform</key>
18
19
  <string>ios</string>
20
+ <key>SupportedPlatformVariant</key>
21
+ <string>simulator</string>
19
22
  </dict>
20
23
  <dict>
21
24
  <key>LibraryIdentifier</key>
22
- <string>ios-arm64_arm64e_x86_64-simulator</string>
25
+ <string>ios-arm64_arm64e</string>
23
26
  <key>LibraryPath</key>
24
27
  <string>libskottie.a</string>
25
28
  <key>SupportedArchitectures</key>
26
29
  <array>
27
30
  <string>arm64</string>
28
31
  <string>arm64e</string>
29
- <string>x86_64</string>
30
32
  </array>
31
33
  <key>SupportedPlatform</key>
32
34
  <string>ios</string>
33
- <key>SupportedPlatformVariant</key>
34
- <string>simulator</string>
35
35
  </dict>
36
36
  </array>
37
37
  <key>CFBundlePackageType</key>
@@ -6,32 +6,32 @@
6
6
  <array>
7
7
  <dict>
8
8
  <key>LibraryIdentifier</key>
9
- <string>ios-arm64_arm64e</string>
9
+ <string>ios-arm64_arm64e_x86_64-simulator</string>
10
10
  <key>LibraryPath</key>
11
11
  <string>libskparagraph.a</string>
12
12
  <key>SupportedArchitectures</key>
13
13
  <array>
14
14
  <string>arm64</string>
15
15
  <string>arm64e</string>
16
+ <string>x86_64</string>
16
17
  </array>
17
18
  <key>SupportedPlatform</key>
18
19
  <string>ios</string>
20
+ <key>SupportedPlatformVariant</key>
21
+ <string>simulator</string>
19
22
  </dict>
20
23
  <dict>
21
24
  <key>LibraryIdentifier</key>
22
- <string>ios-arm64_arm64e_x86_64-simulator</string>
25
+ <string>ios-arm64_arm64e</string>
23
26
  <key>LibraryPath</key>
24
27
  <string>libskparagraph.a</string>
25
28
  <key>SupportedArchitectures</key>
26
29
  <array>
27
30
  <string>arm64</string>
28
31
  <string>arm64e</string>
29
- <string>x86_64</string>
30
32
  </array>
31
33
  <key>SupportedPlatform</key>
32
34
  <string>ios</string>
33
- <key>SupportedPlatformVariant</key>
34
- <string>simulator</string>
35
35
  </dict>
36
36
  </array>
37
37
  <key>CFBundlePackageType</key>
@@ -6,32 +6,32 @@
6
6
  <array>
7
7
  <dict>
8
8
  <key>LibraryIdentifier</key>
9
- <string>ios-arm64_arm64e</string>
9
+ <string>ios-arm64_arm64e_x86_64-simulator</string>
10
10
  <key>LibraryPath</key>
11
11
  <string>libsvg.a</string>
12
12
  <key>SupportedArchitectures</key>
13
13
  <array>
14
14
  <string>arm64</string>
15
15
  <string>arm64e</string>
16
+ <string>x86_64</string>
16
17
  </array>
17
18
  <key>SupportedPlatform</key>
18
19
  <string>ios</string>
20
+ <key>SupportedPlatformVariant</key>
21
+ <string>simulator</string>
19
22
  </dict>
20
23
  <dict>
21
24
  <key>LibraryIdentifier</key>
22
- <string>ios-arm64_arm64e_x86_64-simulator</string>
25
+ <string>ios-arm64_arm64e</string>
23
26
  <key>LibraryPath</key>
24
27
  <string>libsvg.a</string>
25
28
  <key>SupportedArchitectures</key>
26
29
  <array>
27
30
  <string>arm64</string>
28
31
  <string>arm64e</string>
29
- <string>x86_64</string>
30
32
  </array>
31
33
  <key>SupportedPlatform</key>
32
34
  <string>ios</string>
33
- <key>SupportedPlatformVariant</key>
34
- <string>simulator</string>
35
35
  </dict>
36
36
  </array>
37
37
  <key>CFBundlePackageType</key>
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "setup-skia-web": "./scripts/setup-canvaskit.js"
8
8
  },
9
9
  "title": "React Native Skia",
10
- "version": "0.1.221",
10
+ "version": "0.1.223",
11
11
  "description": "High-performance React Native Graphics using Skia",
12
12
  "main": "lib/module/index.js",
13
13
  "files": [
@@ -57,6 +57,7 @@ import type {
57
57
  Path2DPathEffectProps,
58
58
  } from "../types/PathEffects";
59
59
  import { NATIVE_DOM } from "../../renderer/HostComponents";
60
+ import type { ParagraphProps } from "../types/Paragraph";
60
61
 
61
62
  import {
62
63
  FillNode,
@@ -123,6 +124,7 @@ import { GroupNode } from "./GroupNode";
123
124
  import { PaintNode } from "./PaintNode";
124
125
  import type { NodeContext } from "./Node";
125
126
  import { LayerNode } from "./LayerNode";
127
+ import { ParagraphNode } from "./drawings/ParagraphNode";
126
128
 
127
129
  export class JsiSkDOM implements SkDOM {
128
130
  constructor(private ctx: NodeContext) {}
@@ -470,4 +472,11 @@ export class JsiSkDOM implements SkDOM {
470
472
  ? global.SkiaDomApi.BoxShadowNode(props)
471
473
  : new BoxShadowNode(this.ctx, props);
472
474
  }
475
+
476
+ // Paragraph
477
+ Paragraph(props: ParagraphProps) {
478
+ return NATIVE_DOM
479
+ ? global.SkiaDomApi.ParagraphNode(props)
480
+ : new ParagraphNode(this.ctx, props);
481
+ }
473
482
  }
@@ -0,0 +1,22 @@
1
+ import type { DrawingContext, ParagraphProps } from "../../types";
2
+ import { NodeType } from "../../types";
3
+ import { JsiDrawingNode } from "../DrawingNode";
4
+ import type { NodeContext } from "../Node";
5
+
6
+ export class ParagraphNode extends JsiDrawingNode<ParagraphProps, null> {
7
+ constructor(ctx: NodeContext, props: ParagraphProps) {
8
+ super(ctx, NodeType.Paragraph, props);
9
+ }
10
+
11
+ deriveProps() {
12
+ return null;
13
+ }
14
+
15
+ draw({ canvas }: DrawingContext) {
16
+ const { paragraph, x, y, width } = this.props;
17
+ if (paragraph) {
18
+ paragraph.layout(width);
19
+ paragraph.paint(canvas, x, y);
20
+ }
21
+ }
22
+ }
@@ -68,6 +68,9 @@ export const enum NodeType {
68
68
  Glyphs = "skGlyphs",
69
69
  Picture = "skPicture",
70
70
  ImageSVG = "skImageSVG",
71
+
72
+ // Paragraph
73
+ Paragraph = "skParagraph",
71
74
  }
72
75
 
73
76
  export const enum DeclarationType {
@@ -0,0 +1,10 @@
1
+ import type { SkParagraph } from "../../skia/types/Paragraph";
2
+
3
+ import type { GroupProps } from "./Common";
4
+
5
+ export interface ParagraphProps extends GroupProps {
6
+ paragraph: SkParagraph | null;
7
+ x: number;
8
+ y: number;
9
+ width: number;
10
+ }
@@ -58,6 +58,7 @@ import type {
58
58
  Path1DPathEffectProps,
59
59
  Path2DPathEffectProps,
60
60
  } from "./PathEffects";
61
+ import type { ParagraphProps } from "./Paragraph";
61
62
 
62
63
  type ImageFilterNode<P> = DeclarationNode<P>;
63
64
 
@@ -179,4 +180,7 @@ export interface SkDOM {
179
180
  BackdropFilter(props: ChildrenProps): RenderNode<ChildrenProps>;
180
181
  Box(props: BoxProps): RenderNode<BoxProps>;
181
182
  BoxShadow(props: BoxShadowProps): DeclarationNode<BoxShadowProps>;
183
+
184
+ // Paragraph
185
+ Paragraph(props: ParagraphProps): RenderNode<ParagraphProps>;
182
186
  }
@@ -10,3 +10,4 @@ export * from "./ColorFilters";
10
10
  export * from "./MaskFilters";
11
11
  export * from "./PathEffects";
12
12
  export * from "./Shaders";
13
+ export * from "./Paragraph";
@@ -50,6 +50,7 @@ import type {
50
50
  LerpColorFilterProps,
51
51
  BoxProps,
52
52
  BoxShadowProps,
53
+ ParagraphProps,
53
54
  } from "../dom/types";
54
55
  import type { ChildrenProps } from "../dom/types/Common";
55
56
  import type {
@@ -193,6 +194,9 @@ declare global {
193
194
  BoxNode: (prop: BoxProps) => RenderNode<BoxProps>;
194
195
  BoxShadowNode: (prop: BoxShadowProps) => DeclarationNode<BoxShadowProps>;
195
196
  LayerNode: (prop: ChildrenProps) => RenderNode<ChildrenProps>;
197
+
198
+ // Paragraph
199
+ ParagraphNode: (props: ParagraphProps) => RenderNode<ParagraphProps>;
196
200
  };
197
201
 
198
202
  // eslint-disable-next-line @typescript-eslint/no-namespace
@@ -268,6 +272,9 @@ declare global {
268
272
  skBackdropFilter: SkiaProps<ChildrenProps>;
269
273
  skBox: SkiaProps<BoxProps>;
270
274
  skBoxShadow: SkiaProps<BoxShadowProps>;
275
+
276
+ // Paragraph
277
+ skParagraph: SkiaProps<ParagraphProps>;
271
278
  }
272
279
  }
273
280
  }
@@ -399,6 +406,9 @@ export const createNode = (
399
406
  return Sk.Box(props);
400
407
  case NodeType.BoxShadow:
401
408
  return Sk.BoxShadow(props);
409
+ // Paragraph
410
+ case NodeType.Paragraph:
411
+ return Sk.Paragraph(props);
402
412
  default:
403
413
  return exhaustiveCheck(type);
404
414
  }
@@ -15,3 +15,5 @@ export * from "./Mask";
15
15
  export * from "./Paint";
16
16
  export * from "./Blend";
17
17
  export * from "./Drawing";
18
+
19
+ export * from "./paragraph";
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+
3
+ import type { ParagraphProps } from "../../../dom/types/Paragraph";
4
+ import type { SkiaProps } from "../../processors";
5
+
6
+ export const Paragraph = (props: SkiaProps<ParagraphProps>) => {
7
+ return <skParagraph {...props} />;
8
+ };
@@ -0,0 +1 @@
1
+ export * from "./Paragraph";