@react-native-ohos/react-native-svg 15.12.1-rc.1

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 (280) hide show
  1. package/LICENSE +21 -0
  2. package/README.OpenSource +11 -0
  3. package/README.md +13 -0
  4. package/css/package.json +6 -0
  5. package/harmony/svg/BuildProfile.ets +17 -0
  6. package/harmony/svg/build-profile.json5 +9 -0
  7. package/harmony/svg/hvigorfile.ts +2 -0
  8. package/harmony/svg/index.ets +7 -0
  9. package/harmony/svg/oh-package.json5 +13 -0
  10. package/harmony/svg/src/main/cpp/Attribute.h +52 -0
  11. package/harmony/svg/src/main/cpp/CMakeLists.txt +32 -0
  12. package/harmony/svg/src/main/cpp/FallbackProps.h +0 -0
  13. package/harmony/svg/src/main/cpp/FontHolderBase.cpp +22 -0
  14. package/harmony/svg/src/main/cpp/FontHolderBase.h +54 -0
  15. package/harmony/svg/src/main/cpp/SVGPackage.cpp +135 -0
  16. package/harmony/svg/src/main/cpp/SVGPackage.h +153 -0
  17. package/harmony/svg/src/main/cpp/SvgArkUINode.cpp +75 -0
  18. package/harmony/svg/src/main/cpp/SvgArkUINode.h +45 -0
  19. package/harmony/svg/src/main/cpp/SvgBaseAttribute.h +83 -0
  20. package/harmony/svg/src/main/cpp/SvgCircle.cpp +29 -0
  21. package/harmony/svg/src/main/cpp/SvgCircle.h +29 -0
  22. package/harmony/svg/src/main/cpp/SvgClipPath.h +22 -0
  23. package/harmony/svg/src/main/cpp/SvgContext.cpp +56 -0
  24. package/harmony/svg/src/main/cpp/SvgContext.h +71 -0
  25. package/harmony/svg/src/main/cpp/SvgDefs.h +46 -0
  26. package/harmony/svg/src/main/cpp/SvgEllipse.cpp +32 -0
  27. package/harmony/svg/src/main/cpp/SvgEllipse.h +34 -0
  28. package/harmony/svg/src/main/cpp/SvgFilter.cpp +505 -0
  29. package/harmony/svg/src/main/cpp/SvgFilter.h +112 -0
  30. package/harmony/svg/src/main/cpp/SvgGradient.cpp +116 -0
  31. package/harmony/svg/src/main/cpp/SvgGradient.h +49 -0
  32. package/harmony/svg/src/main/cpp/SvgGraphic.cpp +553 -0
  33. package/harmony/svg/src/main/cpp/SvgGraphic.h +77 -0
  34. package/harmony/svg/src/main/cpp/SvgGroup.cpp +86 -0
  35. package/harmony/svg/src/main/cpp/SvgGroup.h +41 -0
  36. package/harmony/svg/src/main/cpp/SvgHost.cpp +27 -0
  37. package/harmony/svg/src/main/cpp/SvgHost.h +38 -0
  38. package/harmony/svg/src/main/cpp/SvgImage.cpp +168 -0
  39. package/harmony/svg/src/main/cpp/SvgImage.h +52 -0
  40. package/harmony/svg/src/main/cpp/SvgLine.cpp +28 -0
  41. package/harmony/svg/src/main/cpp/SvgLine.h +32 -0
  42. package/harmony/svg/src/main/cpp/SvgMarker.cpp +61 -0
  43. package/harmony/svg/src/main/cpp/SvgMarker.h +86 -0
  44. package/harmony/svg/src/main/cpp/SvgMask.cpp +72 -0
  45. package/harmony/svg/src/main/cpp/SvgMask.h +68 -0
  46. package/harmony/svg/src/main/cpp/SvgNode.cpp +289 -0
  47. package/harmony/svg/src/main/cpp/SvgNode.h +347 -0
  48. package/harmony/svg/src/main/cpp/SvgPath.cpp +42 -0
  49. package/harmony/svg/src/main/cpp/SvgPath.h +29 -0
  50. package/harmony/svg/src/main/cpp/SvgPattern.cpp +77 -0
  51. package/harmony/svg/src/main/cpp/SvgPattern.h +64 -0
  52. package/harmony/svg/src/main/cpp/SvgQuote.h +87 -0
  53. package/harmony/svg/src/main/cpp/SvgRect.cpp +58 -0
  54. package/harmony/svg/src/main/cpp/SvgRect.h +33 -0
  55. package/harmony/svg/src/main/cpp/SvgSvg.cpp +83 -0
  56. package/harmony/svg/src/main/cpp/SvgSvg.h +52 -0
  57. package/harmony/svg/src/main/cpp/SvgSymbol.cpp +25 -0
  58. package/harmony/svg/src/main/cpp/SvgSymbol.h +37 -0
  59. package/harmony/svg/src/main/cpp/SvgTSpan.cpp +501 -0
  60. package/harmony/svg/src/main/cpp/SvgTSpan.h +101 -0
  61. package/harmony/svg/src/main/cpp/SvgText.cpp +48 -0
  62. package/harmony/svg/src/main/cpp/SvgText.h +29 -0
  63. package/harmony/svg/src/main/cpp/SvgTextPath.cpp +35 -0
  64. package/harmony/svg/src/main/cpp/SvgTextPath.h +51 -0
  65. package/harmony/svg/src/main/cpp/SvgUse.cpp +65 -0
  66. package/harmony/svg/src/main/cpp/SvgUse.h +46 -0
  67. package/harmony/svg/src/main/cpp/SvgViewManager.cpp +36 -0
  68. package/harmony/svg/src/main/cpp/SvgViewManager.h +37 -0
  69. package/harmony/svg/src/main/cpp/TextBase.cpp +20 -0
  70. package/harmony/svg/src/main/cpp/TextBase.h +114 -0
  71. package/harmony/svg/src/main/cpp/componentInstances/RNSVGBaseComponentInstance.h +212 -0
  72. package/harmony/svg/src/main/cpp/componentInstances/RNSVGCircleComponentInstance.cpp +31 -0
  73. package/harmony/svg/src/main/cpp/componentInstances/RNSVGCircleComponentInstance.h +27 -0
  74. package/harmony/svg/src/main/cpp/componentInstances/RNSVGClipPathComponentInstance.cpp +23 -0
  75. package/harmony/svg/src/main/cpp/componentInstances/RNSVGClipPathComponentInstance.h +27 -0
  76. package/harmony/svg/src/main/cpp/componentInstances/RNSVGDefsComponentInstance.cpp +23 -0
  77. package/harmony/svg/src/main/cpp/componentInstances/RNSVGDefsComponentInstance.h +28 -0
  78. package/harmony/svg/src/main/cpp/componentInstances/RNSVGEllipseComponentInstance.cpp +27 -0
  79. package/harmony/svg/src/main/cpp/componentInstances/RNSVGEllipseComponentInstance.h +27 -0
  80. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeBlendComponentInstance.cpp +40 -0
  81. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeBlendComponentInstance.h +48 -0
  82. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeColorMatrixComponentInstance.cpp +33 -0
  83. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeColorMatrixComponentInstance.h +48 -0
  84. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeCompositeComponentInstance.cpp +39 -0
  85. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeCompositeComponentInstance.h +55 -0
  86. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeFloodComponentInstance.cpp +33 -0
  87. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeFloodComponentInstance.h +49 -0
  88. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeGaussianBlurComponentInstance.cpp +34 -0
  89. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeGaussianBlurComponentInstance.h +48 -0
  90. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeOffsetComponentInstance.cpp +35 -0
  91. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFeOffsetComponentInstance.h +46 -0
  92. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFilterComponentInstance.cpp +199 -0
  93. package/harmony/svg/src/main/cpp/componentInstances/RNSVGFilterComponentInstance.h +48 -0
  94. package/harmony/svg/src/main/cpp/componentInstances/RNSVGGroupComponentInstance.cpp +32 -0
  95. package/harmony/svg/src/main/cpp/componentInstances/RNSVGGroupComponentInstance.h +27 -0
  96. package/harmony/svg/src/main/cpp/componentInstances/RNSVGImageComponentInstance.cpp +100 -0
  97. package/harmony/svg/src/main/cpp/componentInstances/RNSVGImageComponentInstance.h +43 -0
  98. package/harmony/svg/src/main/cpp/componentInstances/RNSVGLineComponentInstance.cpp +27 -0
  99. package/harmony/svg/src/main/cpp/componentInstances/RNSVGLineComponentInstance.h +27 -0
  100. package/harmony/svg/src/main/cpp/componentInstances/RNSVGLinearGradientComponentInstance.cpp +30 -0
  101. package/harmony/svg/src/main/cpp/componentInstances/RNSVGLinearGradientComponentInstance.h +28 -0
  102. package/harmony/svg/src/main/cpp/componentInstances/RNSVGMarkerComponentInstance.cpp +35 -0
  103. package/harmony/svg/src/main/cpp/componentInstances/RNSVGMarkerComponentInstance.h +27 -0
  104. package/harmony/svg/src/main/cpp/componentInstances/RNSVGMaskComponentInstance.cpp +30 -0
  105. package/harmony/svg/src/main/cpp/componentInstances/RNSVGMaskComponentInstance.h +27 -0
  106. package/harmony/svg/src/main/cpp/componentInstances/RNSVGPathComponentInstance.cpp +33 -0
  107. package/harmony/svg/src/main/cpp/componentInstances/RNSVGPathComponentInstance.h +29 -0
  108. package/harmony/svg/src/main/cpp/componentInstances/RNSVGPatternComponentInstance.cpp +40 -0
  109. package/harmony/svg/src/main/cpp/componentInstances/RNSVGPatternComponentInstance.h +27 -0
  110. package/harmony/svg/src/main/cpp/componentInstances/RNSVGRadialGradientComponentInstance.cpp +32 -0
  111. package/harmony/svg/src/main/cpp/componentInstances/RNSVGRadialGradientComponentInstance.h +28 -0
  112. package/harmony/svg/src/main/cpp/componentInstances/RNSVGRectComponentInstance.cpp +36 -0
  113. package/harmony/svg/src/main/cpp/componentInstances/RNSVGRectComponentInstance.h +27 -0
  114. package/harmony/svg/src/main/cpp/componentInstances/RNSVGSvgViewComponentInstance.cpp +86 -0
  115. package/harmony/svg/src/main/cpp/componentInstances/RNSVGSvgViewComponentInstance.h +47 -0
  116. package/harmony/svg/src/main/cpp/componentInstances/RNSVGSymbolComponentInstance.cpp +30 -0
  117. package/harmony/svg/src/main/cpp/componentInstances/RNSVGSymbolComponentInstance.h +27 -0
  118. package/harmony/svg/src/main/cpp/componentInstances/RNSVGTSpanComponentInstance.cpp +27 -0
  119. package/harmony/svg/src/main/cpp/componentInstances/RNSVGTSpanComponentInstance.h +27 -0
  120. package/harmony/svg/src/main/cpp/componentInstances/RNSVGTextComponentInstance.cpp +25 -0
  121. package/harmony/svg/src/main/cpp/componentInstances/RNSVGTextComponentInstance.h +27 -0
  122. package/harmony/svg/src/main/cpp/componentInstances/RNSVGTextPathComponentInstance.cpp +32 -0
  123. package/harmony/svg/src/main/cpp/componentInstances/RNSVGTextPathComponentInstance.h +27 -0
  124. package/harmony/svg/src/main/cpp/componentInstances/RNSVGUseComponentInstance.cpp +32 -0
  125. package/harmony/svg/src/main/cpp/componentInstances/RNSVGUseComponentInstance.h +32 -0
  126. package/harmony/svg/src/main/cpp/downloadUtils/HttpTaskProcessor.cpp +207 -0
  127. package/harmony/svg/src/main/cpp/downloadUtils/HttpTaskProcessor.h +88 -0
  128. package/harmony/svg/src/main/cpp/downloadUtils/ImageSourceResolver.cpp +106 -0
  129. package/harmony/svg/src/main/cpp/downloadUtils/ImageSourceResolver.h +97 -0
  130. package/harmony/svg/src/main/cpp/downloadUtils/LRUCache.h +98 -0
  131. package/harmony/svg/src/main/cpp/drawing/Brush.cpp +50 -0
  132. package/harmony/svg/src/main/cpp/drawing/Brush.h +52 -0
  133. package/harmony/svg/src/main/cpp/drawing/GlyPathBag.cpp +20 -0
  134. package/harmony/svg/src/main/cpp/drawing/GlyPathBag.h +31 -0
  135. package/harmony/svg/src/main/cpp/drawing/Matrix.cpp +100 -0
  136. package/harmony/svg/src/main/cpp/drawing/Matrix.h +68 -0
  137. package/harmony/svg/src/main/cpp/drawing/Path.cpp +173 -0
  138. package/harmony/svg/src/main/cpp/drawing/Path.h +127 -0
  139. package/harmony/svg/src/main/cpp/drawing/Pen.cpp +57 -0
  140. package/harmony/svg/src/main/cpp/drawing/Pen.h +59 -0
  141. package/harmony/svg/src/main/cpp/drawing/Rect.cpp +47 -0
  142. package/harmony/svg/src/main/cpp/drawing/Rect.h +56 -0
  143. package/harmony/svg/src/main/cpp/drawing/RoundRect.cpp +24 -0
  144. package/harmony/svg/src/main/cpp/drawing/RoundRect.h +39 -0
  145. package/harmony/svg/src/main/cpp/drawing/ShaderEffect.cpp +37 -0
  146. package/harmony/svg/src/main/cpp/drawing/ShaderEffect.h +51 -0
  147. package/harmony/svg/src/main/cpp/drawing/TextStyle.cpp +49 -0
  148. package/harmony/svg/src/main/cpp/drawing/TextStyle.h +41 -0
  149. package/harmony/svg/src/main/cpp/drawing/Typography.cpp +9 -0
  150. package/harmony/svg/src/main/cpp/drawing/Typography.h +25 -0
  151. package/harmony/svg/src/main/cpp/drawing/TypographyStyle.cpp +31 -0
  152. package/harmony/svg/src/main/cpp/drawing/TypographyStyle.h +41 -0
  153. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGCircleJSIBinder.h +54 -0
  154. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGClipPathJSIBinder.h +54 -0
  155. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGDefsJSIBinder.h +38 -0
  156. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGEllipseJSIBinder.h +55 -0
  157. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeBlendJSIBinder.h +26 -0
  158. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeColorMatrixJSIBinder.h +26 -0
  159. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeCompositeJSIBinder.h +30 -0
  160. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeFloodJSIBinder.h +26 -0
  161. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeGaussianBlurJSIBinder.h +27 -0
  162. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFeOffsetJSIBinder.h +26 -0
  163. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGFilterJSIBinder.h +44 -0
  164. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGForeignObjectJSIBinder.h +57 -0
  165. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGGroupJSIBinder.h +54 -0
  166. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGImageJSIBinder.h +58 -0
  167. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGLineJSIBinder.h +55 -0
  168. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGLinearGradientJSIBinder.h +45 -0
  169. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGMarkerJSIBinder.h +66 -0
  170. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGMaskJSIBinder.h +60 -0
  171. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGPathJSIBinder.h +52 -0
  172. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGPatternJSIBinder.h +67 -0
  173. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGRadialGradientJSIBinder.h +47 -0
  174. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGRectJSIBinder.h +57 -0
  175. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGSvgViewAndroidJSIBinder.h +67 -0
  176. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGSvgViewJSIBinder.h +36 -0
  177. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGSymbolJSIBinder.h +60 -0
  178. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGTSpanJSIBinder.h +66 -0
  179. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGTextJSIBinder.h +65 -0
  180. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGTextPathJSIBinder.h +71 -0
  181. package/harmony/svg/src/main/cpp/generated/RNOH/generated/components/RNSVGUseJSIBinder.h +56 -0
  182. package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/ComponentDescriptors.h +48 -0
  183. package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/EventEmitters.cpp +20 -0
  184. package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/EventEmitters.h +253 -0
  185. package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/Props.cpp +977 -0
  186. package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/Props.h +1280 -0
  187. package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/ShadowNodes.cpp +45 -0
  188. package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/ShadowNodes.h +331 -0
  189. package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/States.cpp +18 -0
  190. package/harmony/svg/src/main/cpp/generated/react/renderer/components/react_native_svg/States.h +441 -0
  191. package/harmony/svg/src/main/cpp/properties/Color.cpp +458 -0
  192. package/harmony/svg/src/main/cpp/properties/Color.h +144 -0
  193. package/harmony/svg/src/main/cpp/properties/Decoration.cpp +41 -0
  194. package/harmony/svg/src/main/cpp/properties/Decoration.h +483 -0
  195. package/harmony/svg/src/main/cpp/properties/Dimension.cpp +64 -0
  196. package/harmony/svg/src/main/cpp/properties/Dimension.h +243 -0
  197. package/harmony/svg/src/main/cpp/properties/Font.cpp +166 -0
  198. package/harmony/svg/src/main/cpp/properties/Font.h +163 -0
  199. package/harmony/svg/src/main/cpp/properties/Offset.h +119 -0
  200. package/harmony/svg/src/main/cpp/properties/PaintState.h +240 -0
  201. package/harmony/svg/src/main/cpp/properties/Rect.h +423 -0
  202. package/harmony/svg/src/main/cpp/properties/Size.h +246 -0
  203. package/harmony/svg/src/main/cpp/properties/SvgPaintState.h +452 -0
  204. package/harmony/svg/src/main/cpp/properties/TextProperties.cpp +91 -0
  205. package/harmony/svg/src/main/cpp/properties/TextProperties.h +56 -0
  206. package/harmony/svg/src/main/cpp/properties/ViewBox.h +108 -0
  207. package/harmony/svg/src/main/cpp/svgImage/RNSVGImageComponentDescriptor.h +41 -0
  208. package/harmony/svg/src/main/cpp/svgImage/RNSVGImageShadowNode.cpp +62 -0
  209. package/harmony/svg/src/main/cpp/svgImage/RNSVGImageShadowNode.h +63 -0
  210. package/harmony/svg/src/main/cpp/svgImage/RNSVGImageState.cpp +17 -0
  211. package/harmony/svg/src/main/cpp/svgImage/RNSVGImageState.h +58 -0
  212. package/harmony/svg/src/main/cpp/turboModules/RNSVGImageModule.cpp +54 -0
  213. package/harmony/svg/src/main/cpp/turboModules/RNSVGImageModule.h +32 -0
  214. package/harmony/svg/src/main/cpp/turboModules/RNSVGRenderableModule.cpp +101 -0
  215. package/harmony/svg/src/main/cpp/turboModules/RNSVGRenderableModule.h +32 -0
  216. package/harmony/svg/src/main/cpp/turboModules/RNSVGSvgViewModule.cpp +71 -0
  217. package/harmony/svg/src/main/cpp/turboModules/RNSVGSvgViewModule.h +32 -0
  218. package/harmony/svg/src/main/cpp/utils/DynamicUtils.h +55 -0
  219. package/harmony/svg/src/main/cpp/utils/FilterManager.h +190 -0
  220. package/harmony/svg/src/main/cpp/utils/GlyphContext.cpp +221 -0
  221. package/harmony/svg/src/main/cpp/utils/GlyphContext.h +106 -0
  222. package/harmony/svg/src/main/cpp/utils/LinearMap.h +69 -0
  223. package/harmony/svg/src/main/cpp/utils/PathParserUtils.cpp +591 -0
  224. package/harmony/svg/src/main/cpp/utils/PathParserUtils.h +93 -0
  225. package/harmony/svg/src/main/cpp/utils/StringUtils.cpp +134 -0
  226. package/harmony/svg/src/main/cpp/utils/StringUtils.h +644 -0
  227. package/harmony/svg/src/main/cpp/utils/SvgAttributesParser.cpp +239 -0
  228. package/harmony/svg/src/main/cpp/utils/SvgAttributesParser.h +277 -0
  229. package/harmony/svg/src/main/cpp/utils/SvgMarkerPositionUtils.h +200 -0
  230. package/harmony/svg/src/main/cpp/utils/SvgUtils.h +176 -0
  231. package/harmony/svg/src/main/cpp/utils/TextPathHelper.cpp +94 -0
  232. package/harmony/svg/src/main/cpp/utils/TextPathHelper.h +61 -0
  233. package/harmony/svg/src/main/ets/RNSVGImageModule.ts +21 -0
  234. package/harmony/svg/src/main/ets/RNSVGRenderableModule.ts +16 -0
  235. package/harmony/svg/src/main/ets/RNSVGSvgViewModule.ts +18 -0
  236. package/harmony/svg/src/main/ets/SvgPackage.ts +58 -0
  237. package/harmony/svg/src/main/module.json5 +7 -0
  238. package/harmony/svg/src/main/resources/base/element/string.json +8 -0
  239. package/harmony/svg/src/main/resources/en_US/element/string.json +8 -0
  240. package/harmony/svg/src/main/resources/zh_CN/element/string.json +8 -0
  241. package/harmony/svg/ts.ts +8 -0
  242. package/harmony/svg.har +0 -0
  243. package/lib/commonjs/css/index.js +55 -0
  244. package/lib/commonjs/css/index.js.map +1 -0
  245. package/lib/commonjs/index.js +26 -0
  246. package/lib/commonjs/index.js.map +1 -0
  247. package/lib/module/css/index.js +4 -0
  248. package/lib/module/css/index.js.map +1 -0
  249. package/lib/module/index.js +3 -0
  250. package/lib/module/index.js.map +1 -0
  251. package/lib/typescript/babel.config.d.ts +8 -0
  252. package/lib/typescript/babel.config.d.ts.map +1 -0
  253. package/lib/typescript/example/babel.config.d.ts +3 -0
  254. package/lib/typescript/example/babel.config.d.ts.map +1 -0
  255. package/lib/typescript/example/contexts.d.ts +3 -0
  256. package/lib/typescript/example/contexts.d.ts.map +1 -0
  257. package/lib/typescript/example/harmony/entry/hvigorfile.d.ts +2 -0
  258. package/lib/typescript/example/harmony/entry/hvigorfile.d.ts.map +1 -0
  259. package/lib/typescript/example/harmony/hvigorfile.d.ts +2 -0
  260. package/lib/typescript/example/harmony/hvigorfile.d.ts.map +1 -0
  261. package/lib/typescript/example/index.d.ts +2 -0
  262. package/lib/typescript/example/index.d.ts.map +1 -0
  263. package/lib/typescript/example/jest.config.d.ts +3 -0
  264. package/lib/typescript/example/jest.config.d.ts.map +1 -0
  265. package/lib/typescript/example/metro.config.d.ts +3 -0
  266. package/lib/typescript/example/metro.config.d.ts.map +1 -0
  267. package/lib/typescript/example/react-native.config.d.ts +3 -0
  268. package/lib/typescript/example/react-native.config.d.ts.map +1 -0
  269. package/lib/typescript/example/scripts/create-build-profile.d.ts +2 -0
  270. package/lib/typescript/example/scripts/create-build-profile.d.ts.map +1 -0
  271. package/lib/typescript/example/src/index.d.ts +3 -0
  272. package/lib/typescript/example/src/index.d.ts.map +1 -0
  273. package/lib/typescript/src/css/index.d.ts +4 -0
  274. package/lib/typescript/src/css/index.d.ts.map +1 -0
  275. package/lib/typescript/src/index.d.ts +3 -0
  276. package/lib/typescript/src/index.d.ts.map +1 -0
  277. package/package.json +54 -0
  278. package/src/css/index.tsx +20 -0
  279. package/src/index.tsx +3 -0
  280. package/tsconfig.json +12 -0
@@ -0,0 +1,72 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ #include "SvgMask.h"
8
+ #include "drawing/Brush.h"
9
+ #include <native_drawing/drawing_color_filter.h>
10
+ #include <native_drawing/drawing_filter.h>
11
+ #include <native_drawing/drawing_canvas.h>
12
+ #include <native_drawing/drawing_color.h>
13
+
14
+ namespace rnoh {
15
+ namespace svg {
16
+
17
+ void SvgMask::OnDrawTraversedBefore(OH_Drawing_Canvas *canvas) {
18
+ DLOG(INFO) << "[RNSVGMask] OnDrawTraversedBefore";
19
+ // TODO implement proper support for units
20
+ auto nodeBounds = AsBounds();
21
+ DLOG(INFO) << "[RNSVGMask] Left0: " << nodeBounds.Left();
22
+ DLOG(INFO) << "[RNSVGMask] Top0: " << nodeBounds.Top();
23
+ DLOG(INFO) << "[RNSVGMask] Width0: " << nodeBounds.Width();
24
+ DLOG(INFO) << "[RNSVGMask] Height0: " << nodeBounds.Height();
25
+ auto left = static_cast<float>(ParseUnitsAttr(maskAttribute_.x, nodeBounds.Width()));
26
+ auto top = static_cast<float>(ParseUnitsAttr(maskAttribute_.y, nodeBounds.Height()));
27
+ auto width = static_cast<float>(ParseUnitsAttr(maskAttribute_.width, nodeBounds.Width()));
28
+ auto height = static_cast<float>(ParseUnitsAttr(maskAttribute_.height, nodeBounds.Height()));
29
+ drawing::Rect maskBounds(left, top, width + left, height + top);
30
+ maskBounds_ = maskBounds;
31
+
32
+ // create mask layer
33
+ OH_Drawing_CanvasSaveLayer(canvas, maskBounds_.get(), nullptr);
34
+ // ready to render mask content
35
+ canvasLayerCount_ = OH_Drawing_CanvasGetSaveCount(canvas);
36
+
37
+ // set mask
38
+ auto outerFilter = OH_Drawing_ColorFilterCreateLuma();
39
+ auto innerFilter = OH_Drawing_ColorFilterCreateSrgbGammaToLinear();
40
+ auto colorFilter = OH_Drawing_ColorFilterCreateCompose(outerFilter, innerFilter);
41
+ auto *filter = OH_Drawing_FilterCreate();
42
+ OH_Drawing_FilterSetColorFilter(filter, colorFilter);
43
+
44
+ drawing::Brush maskFilter;
45
+ OH_Drawing_BrushSetFilter(maskFilter.get(), filter);
46
+ OH_Drawing_CanvasSaveLayer(canvas, nullptr, maskFilter.get());
47
+ }
48
+
49
+ void SvgMask::OnDrawTraversedAfter(OH_Drawing_Canvas *canvas) {
50
+ DLOG(INFO) << "[RNSVGMask] OnDrawTraversedAfter";
51
+ OH_Drawing_CanvasRestoreToCount(canvas, canvasLayerCount_);
52
+ // create content layer and render content
53
+ drawing::Brush maskBrush;
54
+ OH_Drawing_BrushSetBlendMode(maskBrush.get(), BLEND_MODE_SRC_IN);
55
+
56
+ OH_Drawing_CanvasSaveLayer(canvas, maskBounds_.get(), maskBrush.get());
57
+ OH_Drawing_CanvasClipRect(canvas, maskBounds_.get(), INTERSECT, true);
58
+ }
59
+
60
+
61
+ void SvgMask::OnInitStyle() { DLOG(INFO) << "[RNSVGMask] OnInitStyle"; }
62
+
63
+ double SvgMask::ParseUnitsAttr(const Dimension &attr, double value) {
64
+ // percent and px
65
+ if (attr.Unit() == DimensionUnit::PERCENT) {
66
+ return value * attr.Value();
67
+ }
68
+ return attr.ConvertToPx(scale_);
69
+ }
70
+
71
+ } // namespace svg
72
+ } // namespace rnoh
@@ -0,0 +1,68 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+
7
+ #include "drawing/Rect.h"
8
+ #include "properties/Dimension.h"
9
+ #include "SvgQuote.h"
10
+
11
+ namespace rnoh {
12
+ namespace svg {
13
+
14
+ class SvgMask : public SvgQuote {
15
+ public:
16
+ SvgMask() = default;
17
+ ~SvgMask() override = default;
18
+
19
+ void setMaskX(const std::string &x) {
20
+ maskAttribute_.x = StringUtils::StringToDimensionWithUnit(x, defaultDimensionUnit_);
21
+ }
22
+
23
+ void setMaskY(const std::string &y) {
24
+ maskAttribute_.y = StringUtils::StringToDimensionWithUnit(y, defaultDimensionUnit_);
25
+ }
26
+
27
+ void setMaskHeight(const std::string &height) {
28
+ maskAttribute_.height = StringUtils::StringToDimensionWithUnit(height, defaultDimensionUnit_);
29
+ }
30
+
31
+ void setMaskWidth(const std::string &width) {
32
+ maskAttribute_.width = StringUtils::StringToDimensionWithUnit(width, defaultDimensionUnit_);
33
+ }
34
+
35
+ void isDefaultMaskUnits(bool isDefaultMaskUnits) { isDefaultMaskUnits_ = isDefaultMaskUnits; }
36
+
37
+ void isDefaultMaskContentUnits(bool isDefaultMaskContentUnits) {
38
+ isDefaultMaskContentUnits_ = isDefaultMaskContentUnits;
39
+ }
40
+
41
+ void setMaskUnits(const int &maskUnits) {
42
+ maskAttribute_.maskUnits = ToUnit(maskUnits);
43
+ isDefaultMaskUnits(maskAttribute_.maskUnits == Unit::objectBoundingBox);
44
+ }
45
+
46
+ void setMaskContentUnits(const int &maskContentUnits) {
47
+ maskAttribute_.maskContentUnits = ToUnit(maskContentUnits);
48
+ isDefaultMaskContentUnits(maskAttribute_.maskContentUnits == Unit::userSpaceOnUse);
49
+ }
50
+
51
+ protected:
52
+ void OnInitStyle() override;
53
+ void OnDrawTraversedBefore(OH_Drawing_Canvas *canvas) override;
54
+ void OnDrawTraversedAfter(OH_Drawing_Canvas *canvas) override;
55
+ double ParseUnitsAttr(const Dimension &attr, double value);
56
+
57
+ private:
58
+ bool isDefaultMaskUnits_ = true;
59
+ bool isDefaultMaskContentUnits_ = true;
60
+ SvgMaskAttribute maskAttribute_;
61
+
62
+ drawing::Rect maskBounds_;
63
+ int canvasLayerCount_ = -1;
64
+ DimensionUnit defaultDimensionUnit_ = DimensionUnit::VP;
65
+ };
66
+
67
+ } // namespace svg
68
+ } // namespace rnoh
@@ -0,0 +1,289 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ *
6
+ * This file incorporates from the OpenHarmony project, licensed under
7
+ * the Apache License, Version 2.0. Specifically:
8
+ * - [OpenHarmony/arkui_ace_engine] (https://gitee.com/openharmony/arkui_ace_engine)
9
+ *
10
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
11
+ * use this file except in compliance with the License. You may obtain a copy
12
+ * of the License at:
13
+ * http://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software
16
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18
+ * License for the specific language governing permissions and limitations
19
+ * under the License.
20
+ */
21
+
22
+ #include "SvgNode.h"
23
+ #include "utils/SvgUtils.h"
24
+ #include "SvgGradient.h"
25
+ #include "SvgPattern.h"
26
+ #include "SvgFilter.h"
27
+ #include <native_drawing/drawing_matrix.h>
28
+ #include <native_drawing/drawing_path.h>
29
+ #include <regex>
30
+ #include <string>
31
+
32
+ namespace rnoh {
33
+ namespace svg {
34
+
35
+ constexpr size_t MIN_TRANSFORM_SIZE = 6;
36
+ constexpr int TRANSFORM_SCALE_X_INDEX = 0;
37
+ constexpr int TRANSFORM_SKEW_Y_INDEX = 1;
38
+ constexpr int TRANSFORM_SKEW_X_INDEX = 2;
39
+ constexpr int TRANSFORM_SCALE_Y_INDEX = 3;
40
+ constexpr int TRANSFORM_TRANSLATE_X_INDEX = 4;
41
+ constexpr int TRANSFORM_TRANSLATE_Y_INDEX = 5;
42
+ constexpr double MATRIX_Z_VALUE = 1.0;
43
+
44
+ void SvgNode::InitStyle(const SvgBaseAttribute &attr) {
45
+ static thread_local int recursionDepth = 0;
46
+ static constexpr int MAX_RECURSION_DEPTH = 100;
47
+
48
+ if (recursionDepth >= MAX_RECURSION_DEPTH) {
49
+ return;
50
+ }
51
+
52
+ recursionDepth++;
53
+
54
+ // reset gradient to null
55
+ attributes_.fillState.SetGradient(std::nullopt, false);
56
+ attributes_.strokeState.SetGradient(std::nullopt, false);
57
+ InheritAttr(attr);
58
+ if (hrefFill_) {
59
+ auto fillHref = attributes_.fillState.GetHref();
60
+ if (!fillHref.empty()) {
61
+ auto gradient = GetGradient(fillHref);
62
+ if (gradient) {
63
+ attributes_.fillState.SetGradient(gradient.value(), true);
64
+ }
65
+ auto pattern = GetPatternAttr(fillHref);
66
+ if (pattern) {
67
+ attributes_.fillState.SetPattern(pattern);
68
+ }
69
+ }
70
+ auto strokeHref = attributes_.strokeState.GetHref();
71
+ if (!strokeHref.empty()) {
72
+ auto gradient = GetGradient(strokeHref);
73
+ if (gradient) {
74
+ attributes_.strokeState.SetGradient(gradient.value(), true);
75
+ }
76
+ }
77
+ }
78
+ if (passStyle_) {
79
+ for (auto &node : children_) {
80
+ if (node) {
81
+ node->InitStyle((node->inheritStyle_) ? attributes_ : SvgBaseAttribute());
82
+ }
83
+ }
84
+ }
85
+
86
+ recursionDepth--;
87
+ }
88
+
89
+ void SvgNode::OnDrawTraversed(OH_Drawing_Canvas *canvas) {
90
+ auto smoothEdge = GetSmoothEdge();
91
+ for (auto &node : children_) {
92
+ if (node && node->drawTraversed_) {
93
+ if (GreatNotEqual(smoothEdge, 0.0f)) {
94
+ node->SetSmoothEdge(smoothEdge);
95
+ }
96
+ node->Draw(canvas);
97
+ }
98
+ }
99
+ }
100
+
101
+ const Rect &SvgNode::GetRootViewBox() const {
102
+ if (!context_) {
103
+ static Rect empty;
104
+ return empty;
105
+ }
106
+ return context_->GetRootViewBox();
107
+ }
108
+
109
+ void SvgNode::OnClipPath(OH_Drawing_Canvas *canvas) {
110
+ DLOG(INFO) << "[SvgNode] Draw OnClipPath enter";
111
+ if (!context_) {
112
+ DLOG(WARNING) << "[SvgNode] OnClipPath: Context is null!";
113
+ return;
114
+ }
115
+ auto refSvgNode = context_->GetSvgNodeById(hrefClipPath_);
116
+ if (!refSvgNode) {
117
+ DLOG(WARNING) << "[SvgNode] OnClipPath: SvgNode is null!";
118
+ return;
119
+ };
120
+ auto clipPath = refSvgNode->AsPath();
121
+
122
+ // maybe return optional from AsPath?
123
+
124
+ // Set clipRule through Drawing API
125
+ clipPath.SetFillType(attributes_.clipState.GetClipRuleForDraw());
126
+ OH_Drawing_CanvasClipPath(canvas, clipPath.get(), OH_Drawing_CanvasClipOp::INTERSECT, true);
127
+ }
128
+
129
+ void SvgNode::OnMask(OH_Drawing_Canvas *canvas) {
130
+ if (!context_) {
131
+ DLOG(INFO) << "NO CONTEXT";
132
+ return;
133
+ }
134
+ auto refMask = context_->GetSvgNodeById(attributes_.maskId);
135
+ if (!refMask) {
136
+ return;
137
+ };
138
+ refMask->Draw(canvas);
139
+ }
140
+
141
+ void SvgNode::OnTransform(OH_Drawing_Canvas *canvas) {
142
+ // input transfrom: (float scaleX, float skewY, float skewX, float scaleY, float transX, float transY)
143
+ const auto &transform = attributes_.transform;
144
+ /* (OH_Drawing_Matrix* , float scaleX, float skewX, float transX, float skewY, float scaleY, float transY, float
145
+ persp0, float persp1, float persp2 )
146
+ */
147
+ if (!attributes_.strokeState.GetVectorEffect() && transform.size() >= MIN_TRANSFORM_SIZE) {
148
+ cTM_.SetMatrix(transform[TRANSFORM_SCALE_X_INDEX], transform[TRANSFORM_SKEW_X_INDEX],
149
+ transform[TRANSFORM_TRANSLATE_X_INDEX] * scale_, transform[TRANSFORM_SKEW_Y_INDEX],
150
+ transform[TRANSFORM_SCALE_Y_INDEX], transform[TRANSFORM_TRANSLATE_Y_INDEX] * scale_, 0, 0,
151
+ MATRIX_Z_VALUE);
152
+ OH_Drawing_CanvasConcatMatrix(canvas, cTM_.get());
153
+ }
154
+ }
155
+
156
+ std::optional<Gradient> SvgNode::GetGradient(const std::string &href) {
157
+ if (!context_) {
158
+ DLOG(INFO) << "NO CONTEXT";
159
+ return std::nullopt;
160
+ }
161
+ auto refSvgNode = context_->GetSvgNodeById(href);
162
+ CHECK_NULL_RETURN(refSvgNode, std::nullopt);
163
+ auto svgGradient = std::dynamic_pointer_cast<SvgGradient>(refSvgNode);
164
+ if (svgGradient) {
165
+ return std::make_optional(svgGradient->GetGradient());
166
+ }
167
+ return std::nullopt;
168
+ }
169
+
170
+ std::shared_ptr<PatternAttr> SvgNode::GetPatternAttr(const std::string &href) {
171
+ if (!context_) {
172
+ DLOG(INFO) << "NO CONTEXT";
173
+ return nullptr;
174
+ }
175
+ auto refSvgNode = context_->GetSvgNodeById(href);
176
+ CHECK_NULL_RETURN(refSvgNode, nullptr);
177
+ auto svgPattern = std::dynamic_pointer_cast<SvgPattern>(refSvgNode);
178
+ if (svgPattern) {
179
+ return svgPattern->GetPatternAttr();
180
+ }
181
+ return nullptr;
182
+ }
183
+
184
+ void SvgNode::Draw(OH_Drawing_Canvas *canvas) {
185
+ if (!display_) {
186
+ return;
187
+ }
188
+ // mask and filter create extra layers, need to record initial layer count
189
+ const auto count = OH_Drawing_CanvasGetSaveCount(canvas);
190
+ OH_Drawing_CanvasSave(canvas);
191
+ if (!attributes_.transform.empty()) {
192
+ OnTransform(canvas);
193
+ }
194
+ if (!hrefClipPath_.empty()) {
195
+ OnClipPath(canvas);
196
+ }
197
+ if (!attributes_.maskId.empty()) {
198
+ OnMask(canvas);
199
+ }
200
+
201
+ OH_Drawing_CanvasGetTotalMatrix(canvas, lastCanvasMatrix_.get());
202
+
203
+ OnDraw(canvas);
204
+ // on marker
205
+
206
+ OnDrawTraversed(canvas);
207
+ OH_Drawing_CanvasRestoreToCount(canvas, count);
208
+ }
209
+
210
+ Rect SvgNode::AsBounds() {
211
+ auto path = AsPath();
212
+ auto ohRect = path.GetBounds();
213
+ float x = ohRect.GetLeft();
214
+ float y = ohRect.GetTop();
215
+ float width = ohRect.GetWidth();
216
+ float height = ohRect.GetHeight();
217
+ auto rect = Rect(x, y, width, height);
218
+ return rect;
219
+ }
220
+
221
+ void SvgNode::ContextTraversal() {
222
+ static thread_local int recursionDepth = 0;
223
+ static constexpr int MAX_RECURSION_DEPTH = 100;
224
+
225
+ if (recursionDepth >= MAX_RECURSION_DEPTH) {
226
+ return;
227
+ }
228
+
229
+ recursionDepth++;
230
+
231
+ if (!context_) {
232
+ DLOG(INFO) << "NO CONTEXT";
233
+ recursionDepth--;
234
+ return;
235
+ }
236
+ if (!attributes_.id.empty()) {
237
+ context_->Push(attributes_.id, shared_from_this());
238
+ }
239
+ for (const auto &child : children_) {
240
+ if (child) {
241
+ child->SetContext(context_);
242
+ child->ContextTraversal();
243
+ }
244
+ }
245
+
246
+ recursionDepth--;
247
+ }
248
+
249
+ double SvgNode::relativeOnWidth(Dimension length) { return length.RelativeConvertToPx(getCanvasWidth(), scale_); }
250
+
251
+ double SvgNode::relativeOnHeight(Dimension length) { return length.RelativeConvertToPx(getCanvasHeight(), scale_); }
252
+
253
+ double SvgNode::relativeOnOther(Dimension length) { return length.RelativeConvertToPx(getCanvasDiagonal(), scale_); }
254
+
255
+ double SvgNode::getCanvasWidth() {
256
+ if (canvasWidth_ != -1) {
257
+ return canvasWidth_;
258
+ }
259
+ // to be done? if root is text root
260
+ if (context_) {
261
+ canvasWidth_ = context_->getCanvasBounds().Width() / context_->getCanvasScaleX();
262
+ return canvasWidth_;
263
+ }
264
+ return 0;
265
+ }
266
+
267
+ double SvgNode::getCanvasHeight() {
268
+ if (canvasHeight_ != -1) {
269
+ return canvasHeight_;
270
+ }
271
+ // to be done? if root is text root
272
+ if (context_) {
273
+ canvasHeight_ = context_->getCanvasBounds().Height() / context_->getCanvasScaleY();
274
+ return canvasHeight_;
275
+ }
276
+ return 0;
277
+ }
278
+
279
+ double SvgNode::getCanvasDiagonal() {
280
+ if (canvasDiagonal_ != -1) {
281
+ return canvasDiagonal_;
282
+ }
283
+ double powX = pow((getCanvasWidth()), 2);
284
+ double powY = pow((getCanvasHeight()), 2);
285
+ canvasDiagonal_ = sqrt(powX + powY) * M_SQRT1_2l;
286
+ return canvasDiagonal_;
287
+ }
288
+ } // namespace svg
289
+ } // namespace rnoh