react-native-skelo 0.0.1 → 0.0.2

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 (269) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +147 -20
  3. package/lib/commonjs/Skelo.js +104 -0
  4. package/lib/commonjs/Skelo.js.map +1 -0
  5. package/lib/commonjs/animations/AnimationWrapper.js +76 -0
  6. package/lib/commonjs/animations/AnimationWrapper.js.map +1 -0
  7. package/lib/commonjs/animations/PulseAnimation.js +76 -0
  8. package/lib/commonjs/animations/PulseAnimation.js.map +1 -0
  9. package/lib/commonjs/animations/ShimmerAnimation.js +103 -0
  10. package/lib/commonjs/animations/ShimmerAnimation.js.map +1 -0
  11. package/lib/commonjs/animations/index.js +27 -0
  12. package/lib/commonjs/animations/index.js.map +1 -0
  13. package/lib/commonjs/components/MeasuredBlock.js +64 -0
  14. package/lib/commonjs/components/MeasuredBlock.js.map +1 -0
  15. package/lib/commonjs/components/Skeleton.js +144 -0
  16. package/lib/commonjs/components/Skeleton.js.map +1 -0
  17. package/lib/commonjs/components/SkeletonIgnore.js +30 -0
  18. package/lib/commonjs/components/SkeletonIgnore.js.map +1 -0
  19. package/lib/commonjs/components/SkeletonRenderer.js +270 -0
  20. package/lib/commonjs/components/SkeletonRenderer.js.map +1 -0
  21. package/lib/commonjs/components/primitives/SkeletonBox.js +47 -0
  22. package/lib/commonjs/components/primitives/SkeletonBox.js.map +1 -0
  23. package/lib/commonjs/components/primitives/SkeletonCircle.js +44 -0
  24. package/lib/commonjs/components/primitives/SkeletonCircle.js.map +1 -0
  25. package/lib/commonjs/components/primitives/SkeletonImage.js +46 -0
  26. package/lib/commonjs/components/primitives/SkeletonImage.js.map +1 -0
  27. package/lib/commonjs/components/primitives/SkeletonText.js +60 -0
  28. package/lib/commonjs/components/primitives/SkeletonText.js.map +1 -0
  29. package/lib/commonjs/components/primitives/index.js +34 -0
  30. package/lib/commonjs/components/primitives/index.js.map +1 -0
  31. package/lib/commonjs/components/withSkeleton.js +45 -0
  32. package/lib/commonjs/components/withSkeleton.js.map +1 -0
  33. package/lib/commonjs/constants/defaults.js +43 -0
  34. package/lib/commonjs/constants/defaults.js.map +1 -0
  35. package/lib/commonjs/core/deepRegistry.js +18 -0
  36. package/lib/commonjs/core/deepRegistry.js.map +1 -0
  37. package/lib/commonjs/core/generator/StyleSkeleton.js +101 -0
  38. package/lib/commonjs/core/generator/StyleSkeleton.js.map +1 -0
  39. package/lib/commonjs/core/parser/Parser.js +84 -0
  40. package/lib/commonjs/core/parser/Parser.js.map +1 -0
  41. package/lib/commonjs/core/parser/expandOffline.js +83 -0
  42. package/lib/commonjs/core/parser/expandOffline.js.map +1 -0
  43. package/lib/commonjs/core/parser/hostTreeReconciler.js +228 -0
  44. package/lib/commonjs/core/parser/hostTreeReconciler.js.map +1 -0
  45. package/lib/commonjs/core/parser/index.js +13 -0
  46. package/lib/commonjs/core/parser/index.js.map +1 -0
  47. package/lib/commonjs/core/registry/SkeletonRegistry.js +113 -0
  48. package/lib/commonjs/core/registry/SkeletonRegistry.js.map +1 -0
  49. package/lib/commonjs/core/registry/index.js +19 -0
  50. package/lib/commonjs/core/registry/index.js.map +1 -0
  51. package/lib/commonjs/core/resolver/StyleResolver.js +83 -0
  52. package/lib/commonjs/core/resolver/StyleResolver.js.map +1 -0
  53. package/lib/commonjs/core/resolver/index.js +13 -0
  54. package/lib/commonjs/core/resolver/index.js.map +1 -0
  55. package/lib/commonjs/deep.js +18 -0
  56. package/lib/commonjs/deep.js.map +1 -0
  57. package/lib/commonjs/index.js +66 -0
  58. package/lib/commonjs/index.js.map +1 -0
  59. package/lib/commonjs/plugins/ImagePlugin.js +60 -0
  60. package/lib/commonjs/plugins/ImagePlugin.js.map +1 -0
  61. package/lib/commonjs/plugins/TextPlugin.js +70 -0
  62. package/lib/commonjs/plugins/TextPlugin.js.map +1 -0
  63. package/lib/commonjs/plugins/ViewPlugin.js +71 -0
  64. package/lib/commonjs/plugins/ViewPlugin.js.map +1 -0
  65. package/lib/commonjs/plugins/index.js +27 -0
  66. package/lib/commonjs/plugins/index.js.map +1 -0
  67. package/lib/commonjs/types/index.js +2 -0
  68. package/lib/commonjs/types/index.js.map +1 -0
  69. package/lib/commonjs/types/plugin.js +6 -0
  70. package/lib/commonjs/types/plugin.js.map +1 -0
  71. package/lib/commonjs/types/skeleton.js +6 -0
  72. package/lib/commonjs/types/skeleton.js.map +1 -0
  73. package/lib/commonjs/utils/componentUtils.js +138 -0
  74. package/lib/commonjs/utils/componentUtils.js.map +1 -0
  75. package/lib/commonjs/utils/index.js +62 -0
  76. package/lib/commonjs/utils/index.js.map +1 -0
  77. package/lib/commonjs/utils/styleUtils.js +76 -0
  78. package/lib/commonjs/utils/styleUtils.js.map +1 -0
  79. package/lib/module/Skelo.js +98 -0
  80. package/lib/module/Skelo.js.map +1 -0
  81. package/lib/module/animations/AnimationWrapper.js +69 -0
  82. package/lib/module/animations/AnimationWrapper.js.map +1 -0
  83. package/lib/module/animations/PulseAnimation.js +69 -0
  84. package/lib/module/animations/PulseAnimation.js.map +1 -0
  85. package/lib/module/animations/ShimmerAnimation.js +96 -0
  86. package/lib/module/animations/ShimmerAnimation.js.map +1 -0
  87. package/lib/module/animations/index.js +4 -0
  88. package/lib/module/animations/index.js.map +1 -0
  89. package/lib/module/components/MeasuredBlock.js +57 -0
  90. package/lib/module/components/MeasuredBlock.js.map +1 -0
  91. package/lib/module/components/Skeleton.js +138 -0
  92. package/lib/module/components/Skeleton.js.map +1 -0
  93. package/lib/module/components/SkeletonIgnore.js +23 -0
  94. package/lib/module/components/SkeletonIgnore.js.map +1 -0
  95. package/lib/module/components/SkeletonRenderer.js +264 -0
  96. package/lib/module/components/SkeletonRenderer.js.map +1 -0
  97. package/lib/module/components/primitives/SkeletonBox.js +40 -0
  98. package/lib/module/components/primitives/SkeletonBox.js.map +1 -0
  99. package/lib/module/components/primitives/SkeletonCircle.js +37 -0
  100. package/lib/module/components/primitives/SkeletonCircle.js.map +1 -0
  101. package/lib/module/components/primitives/SkeletonImage.js +39 -0
  102. package/lib/module/components/primitives/SkeletonImage.js.map +1 -0
  103. package/lib/module/components/primitives/SkeletonText.js +53 -0
  104. package/lib/module/components/primitives/SkeletonText.js.map +1 -0
  105. package/lib/module/components/primitives/index.js +5 -0
  106. package/lib/module/components/primitives/index.js.map +1 -0
  107. package/lib/module/components/withSkeleton.js +38 -0
  108. package/lib/module/components/withSkeleton.js.map +1 -0
  109. package/lib/module/constants/defaults.js +37 -0
  110. package/lib/module/constants/defaults.js.map +1 -0
  111. package/lib/module/core/deepRegistry.js +11 -0
  112. package/lib/module/core/deepRegistry.js.map +1 -0
  113. package/lib/module/core/generator/StyleSkeleton.js +95 -0
  114. package/lib/module/core/generator/StyleSkeleton.js.map +1 -0
  115. package/lib/module/core/parser/Parser.js +77 -0
  116. package/lib/module/core/parser/Parser.js.map +1 -0
  117. package/lib/module/core/parser/expandOffline.js +77 -0
  118. package/lib/module/core/parser/expandOffline.js.map +1 -0
  119. package/lib/module/core/parser/hostTreeReconciler.js +222 -0
  120. package/lib/module/core/parser/hostTreeReconciler.js.map +1 -0
  121. package/lib/module/core/parser/index.js +2 -0
  122. package/lib/module/core/parser/index.js.map +1 -0
  123. package/lib/module/core/registry/SkeletonRegistry.js +106 -0
  124. package/lib/module/core/registry/SkeletonRegistry.js.map +1 -0
  125. package/lib/module/core/registry/index.js +2 -0
  126. package/lib/module/core/registry/index.js.map +1 -0
  127. package/lib/module/core/resolver/StyleResolver.js +77 -0
  128. package/lib/module/core/resolver/StyleResolver.js.map +1 -0
  129. package/lib/module/core/resolver/index.js +2 -0
  130. package/lib/module/core/resolver/index.js.map +1 -0
  131. package/lib/module/deep.js +11 -0
  132. package/lib/module/deep.js.map +1 -0
  133. package/lib/module/index.js +21 -0
  134. package/lib/module/index.js.map +1 -0
  135. package/lib/module/plugins/ImagePlugin.js +53 -0
  136. package/lib/module/plugins/ImagePlugin.js.map +1 -0
  137. package/lib/module/plugins/TextPlugin.js +63 -0
  138. package/lib/module/plugins/TextPlugin.js.map +1 -0
  139. package/lib/module/plugins/ViewPlugin.js +64 -0
  140. package/lib/module/plugins/ViewPlugin.js.map +1 -0
  141. package/lib/module/plugins/index.js +4 -0
  142. package/lib/module/plugins/index.js.map +1 -0
  143. package/lib/module/types/index.js +2 -0
  144. package/lib/module/types/index.js.map +1 -0
  145. package/lib/module/types/plugin.js +2 -0
  146. package/lib/module/types/plugin.js.map +1 -0
  147. package/lib/module/types/skeleton.js +2 -0
  148. package/lib/module/types/skeleton.js.map +1 -0
  149. package/lib/module/utils/componentUtils.js +123 -0
  150. package/lib/module/utils/componentUtils.js.map +1 -0
  151. package/lib/module/utils/index.js +3 -0
  152. package/lib/module/utils/index.js.map +1 -0
  153. package/lib/module/utils/styleUtils.js +66 -0
  154. package/lib/module/utils/styleUtils.js.map +1 -0
  155. package/lib/typescript/Skelo.d.ts +76 -0
  156. package/lib/typescript/Skelo.d.ts.map +1 -0
  157. package/lib/typescript/animations/AnimationWrapper.d.ts +66 -0
  158. package/lib/typescript/animations/AnimationWrapper.d.ts.map +1 -0
  159. package/lib/typescript/animations/PulseAnimation.d.ts +59 -0
  160. package/lib/typescript/animations/PulseAnimation.d.ts.map +1 -0
  161. package/lib/typescript/animations/ShimmerAnimation.d.ts +59 -0
  162. package/lib/typescript/animations/ShimmerAnimation.d.ts.map +1 -0
  163. package/lib/typescript/animations/index.d.ts +5 -0
  164. package/lib/typescript/animations/index.d.ts.map +1 -0
  165. package/lib/typescript/components/MeasuredBlock.d.ts +32 -0
  166. package/lib/typescript/components/MeasuredBlock.d.ts.map +1 -0
  167. package/lib/typescript/components/Skeleton.d.ts +37 -0
  168. package/lib/typescript/components/Skeleton.d.ts.map +1 -0
  169. package/lib/typescript/components/SkeletonIgnore.d.ts +26 -0
  170. package/lib/typescript/components/SkeletonIgnore.d.ts.map +1 -0
  171. package/lib/typescript/components/SkeletonRenderer.d.ts +39 -0
  172. package/lib/typescript/components/SkeletonRenderer.d.ts.map +1 -0
  173. package/lib/typescript/components/primitives/SkeletonBox.d.ts +21 -0
  174. package/lib/typescript/components/primitives/SkeletonBox.d.ts.map +1 -0
  175. package/lib/typescript/components/primitives/SkeletonCircle.d.ts +21 -0
  176. package/lib/typescript/components/primitives/SkeletonCircle.d.ts.map +1 -0
  177. package/lib/typescript/components/primitives/SkeletonImage.d.ts +21 -0
  178. package/lib/typescript/components/primitives/SkeletonImage.d.ts.map +1 -0
  179. package/lib/typescript/components/primitives/SkeletonText.d.ts +21 -0
  180. package/lib/typescript/components/primitives/SkeletonText.d.ts.map +1 -0
  181. package/lib/typescript/components/primitives/index.d.ts +5 -0
  182. package/lib/typescript/components/primitives/index.d.ts.map +1 -0
  183. package/lib/typescript/components/withSkeleton.d.ts +37 -0
  184. package/lib/typescript/components/withSkeleton.d.ts.map +1 -0
  185. package/lib/typescript/constants/defaults.d.ts +29 -0
  186. package/lib/typescript/constants/defaults.d.ts.map +1 -0
  187. package/lib/typescript/core/deepRegistry.d.ts +7 -0
  188. package/lib/typescript/core/deepRegistry.d.ts.map +1 -0
  189. package/lib/typescript/core/generator/StyleSkeleton.d.ts +36 -0
  190. package/lib/typescript/core/generator/StyleSkeleton.d.ts.map +1 -0
  191. package/lib/typescript/core/parser/Parser.d.ts +30 -0
  192. package/lib/typescript/core/parser/Parser.d.ts.map +1 -0
  193. package/lib/typescript/core/parser/expandOffline.d.ts +10 -0
  194. package/lib/typescript/core/parser/expandOffline.d.ts.map +1 -0
  195. package/lib/typescript/core/parser/hostTreeReconciler.d.ts +28 -0
  196. package/lib/typescript/core/parser/hostTreeReconciler.d.ts.map +1 -0
  197. package/lib/typescript/core/parser/index.d.ts +2 -0
  198. package/lib/typescript/core/parser/index.d.ts.map +1 -0
  199. package/lib/typescript/core/registry/SkeletonRegistry.d.ts +57 -0
  200. package/lib/typescript/core/registry/SkeletonRegistry.d.ts.map +1 -0
  201. package/lib/typescript/core/registry/index.d.ts +2 -0
  202. package/lib/typescript/core/registry/index.d.ts.map +1 -0
  203. package/lib/typescript/core/resolver/StyleResolver.d.ts +54 -0
  204. package/lib/typescript/core/resolver/StyleResolver.d.ts.map +1 -0
  205. package/lib/typescript/core/resolver/index.d.ts +2 -0
  206. package/lib/typescript/core/resolver/index.d.ts.map +1 -0
  207. package/lib/typescript/deep.d.ts +2 -0
  208. package/lib/typescript/deep.d.ts.map +1 -0
  209. package/lib/typescript/index.d.ts +17 -0
  210. package/lib/typescript/index.d.ts.map +1 -0
  211. package/lib/typescript/plugins/ImagePlugin.d.ts +11 -0
  212. package/lib/typescript/plugins/ImagePlugin.d.ts.map +1 -0
  213. package/lib/typescript/plugins/TextPlugin.d.ts +12 -0
  214. package/lib/typescript/plugins/TextPlugin.d.ts.map +1 -0
  215. package/lib/typescript/plugins/ViewPlugin.d.ts +11 -0
  216. package/lib/typescript/plugins/ViewPlugin.d.ts.map +1 -0
  217. package/lib/typescript/plugins/index.d.ts +4 -0
  218. package/lib/typescript/plugins/index.d.ts.map +1 -0
  219. package/lib/typescript/types/index.d.ts +3 -0
  220. package/lib/typescript/types/index.d.ts.map +1 -0
  221. package/lib/typescript/types/plugin.d.ts +144 -0
  222. package/lib/typescript/types/plugin.d.ts.map +1 -0
  223. package/lib/typescript/types/skeleton.d.ts +176 -0
  224. package/lib/typescript/types/skeleton.d.ts.map +1 -0
  225. package/lib/typescript/utils/componentUtils.d.ts +40 -0
  226. package/lib/typescript/utils/componentUtils.d.ts.map +1 -0
  227. package/lib/typescript/utils/index.d.ts +3 -0
  228. package/lib/typescript/utils/index.d.ts.map +1 -0
  229. package/lib/typescript/utils/styleUtils.d.ts +41 -0
  230. package/lib/typescript/utils/styleUtils.d.ts.map +1 -0
  231. package/package.json +171 -11
  232. package/src/Skelo.ts +103 -0
  233. package/src/animations/AnimationWrapper.tsx +139 -0
  234. package/src/animations/PulseAnimation.tsx +138 -0
  235. package/src/animations/ShimmerAnimation.tsx +169 -0
  236. package/src/animations/index.ts +4 -0
  237. package/src/components/MeasuredBlock.tsx +85 -0
  238. package/src/components/Skeleton.tsx +149 -0
  239. package/src/components/SkeletonIgnore.tsx +27 -0
  240. package/src/components/SkeletonRenderer.tsx +341 -0
  241. package/src/components/primitives/SkeletonBox.tsx +53 -0
  242. package/src/components/primitives/SkeletonCircle.tsx +48 -0
  243. package/src/components/primitives/SkeletonImage.tsx +50 -0
  244. package/src/components/primitives/SkeletonText.tsx +69 -0
  245. package/src/components/primitives/index.ts +4 -0
  246. package/src/components/withSkeleton.tsx +62 -0
  247. package/src/constants/defaults.ts +38 -0
  248. package/src/core/deepRegistry.ts +16 -0
  249. package/src/core/generator/StyleSkeleton.tsx +138 -0
  250. package/src/core/parser/Parser.ts +86 -0
  251. package/src/core/parser/expandOffline.tsx +83 -0
  252. package/src/core/parser/hostTreeReconciler.tsx +271 -0
  253. package/src/core/parser/index.ts +1 -0
  254. package/src/core/registry/SkeletonRegistry.ts +111 -0
  255. package/src/core/registry/index.ts +1 -0
  256. package/src/core/resolver/StyleResolver.ts +80 -0
  257. package/src/core/resolver/index.ts +1 -0
  258. package/src/deep.ts +12 -0
  259. package/src/index.ts +30 -0
  260. package/src/plugins/ImagePlugin.tsx +65 -0
  261. package/src/plugins/TextPlugin.tsx +71 -0
  262. package/src/plugins/ViewPlugin.tsx +67 -0
  263. package/src/plugins/index.ts +3 -0
  264. package/src/types/index.ts +14 -0
  265. package/src/types/plugin.ts +164 -0
  266. package/src/types/skeleton.ts +197 -0
  267. package/src/utils/componentUtils.ts +166 -0
  268. package/src/utils/index.ts +9 -0
  269. package/src/utils/styleUtils.ts +72 -0
@@ -0,0 +1,77 @@
1
+ import { resolveStyle, extractDimensions } from '../../utils';
2
+
3
+ /**
4
+ * StyleResolver class for extracting and resolving component styles
5
+ */
6
+ export class StyleResolver {
7
+ /**
8
+ * Resolve styles from a React element
9
+ *
10
+ * @param element - React element
11
+ * @returns Resolved style object
12
+ */
13
+ static resolve(element) {
14
+ const props = element.props || {};
15
+ const style = props.style;
16
+ return resolveStyle(style);
17
+ }
18
+
19
+ /**
20
+ * Get dimensions from element props and style
21
+ *
22
+ * @param element - React element
23
+ * @returns Object with width and height
24
+ */
25
+ static getDimensions(element) {
26
+ const style = this.resolve(element);
27
+ return extractDimensions(style);
28
+ }
29
+
30
+ /**
31
+ * Check if element has explicit dimensions
32
+ *
33
+ * @param element - React element
34
+ * @returns True if both width and height are defined
35
+ */
36
+ static hasExplicitDimensions(element) {
37
+ const {
38
+ width,
39
+ height
40
+ } = this.getDimensions(element);
41
+ return width !== undefined && height !== undefined;
42
+ }
43
+
44
+ /**
45
+ * Get border radius from style
46
+ *
47
+ * @param element - React element
48
+ * @returns Border radius value or undefined
49
+ */
50
+ static getBorderRadius(element) {
51
+ const style = this.resolve(element);
52
+ return style.borderRadius;
53
+ }
54
+
55
+ /**
56
+ * Get font size from style
57
+ *
58
+ * @param element - React element
59
+ * @returns Font size value or undefined
60
+ */
61
+ static getFontSize(element) {
62
+ const style = this.resolve(element);
63
+ return style.fontSize;
64
+ }
65
+
66
+ /**
67
+ * Get line height from style
68
+ *
69
+ * @param element - React element
70
+ * @returns Line height value or undefined
71
+ */
72
+ static getLineHeight(element) {
73
+ const style = this.resolve(element);
74
+ return style.lineHeight;
75
+ }
76
+ }
77
+ //# sourceMappingURL=StyleResolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["resolveStyle","extractDimensions","StyleResolver","resolve","element","props","style","getDimensions","hasExplicitDimensions","width","height","undefined","getBorderRadius","borderRadius","getFontSize","fontSize","getLineHeight","lineHeight"],"sourceRoot":"../../../../src","sources":["core/resolver/StyleResolver.ts"],"mappings":"AAGA,SAASA,YAAY,EAAEC,iBAAiB,QAAQ,aAAa;;AAE7D;AACA;AACA;AACA,OAAO,MAAMC,aAAa,CAAC;EACzB;AACF;AACA;AACA;AACA;AACA;EACE,OAAOC,OAAOA,CAACC,OAAqB,EAAiB;IACnD,MAAMC,KAAK,GAAGD,OAAO,CAACC,KAAK,IAAI,CAAC,CAAC;IACjC,MAAMC,KAAK,GAAGD,KAAK,CAACC,KAAK;IAEzB,OAAON,YAAY,CAACM,KAAK,CAAC;EAC5B;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,OAAOC,aAAaA,CAACH,OAAqB,EAGxC;IACA,MAAME,KAAK,GAAG,IAAI,CAACH,OAAO,CAACC,OAAO,CAAC;IACnC,OAAOH,iBAAiB,CAACK,KAAK,CAAC;EACjC;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,OAAOE,qBAAqBA,CAACJ,OAAqB,EAAW;IAC3D,MAAM;MAAEK,KAAK;MAAEC;IAAO,CAAC,GAAG,IAAI,CAACH,aAAa,CAACH,OAAO,CAAC;IACrD,OAAOK,KAAK,KAAKE,SAAS,IAAID,MAAM,KAAKC,SAAS;EACpD;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,OAAOC,eAAeA,CAACR,OAAqB,EAAsB;IAChE,MAAME,KAAK,GAAG,IAAI,CAACH,OAAO,CAACC,OAAO,CAAC;IACnC,OAAOE,KAAK,CAACO,YAAY;EAC3B;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,OAAOC,WAAWA,CAACV,OAAqB,EAAsB;IAC5D,MAAME,KAAK,GAAG,IAAI,CAACH,OAAO,CAACC,OAAO,CAAC;IACnC,OAAOE,KAAK,CAACS,QAAQ;EACvB;;EAEA;AACF;AACA;AACA;AACA;AACA;EACE,OAAOC,aAAaA,CAACZ,OAAqB,EAAsB;IAC9D,MAAME,KAAK,GAAG,IAAI,CAACH,OAAO,CAACC,OAAO,CAAC;IACnC,OAAOE,KAAK,CAACW,UAAU;EACzB;AACF","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export { StyleResolver } from './StyleResolver';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["StyleResolver"],"sourceRoot":"../../../../src","sources":["core/resolver/index.ts"],"mappings":"AAAA,SAASA,aAAa,QAAQ,iBAAiB","ignoreList":[]}
@@ -0,0 +1,11 @@
1
+ // Opt-in deep mode. Import once in your app entry to enable `<Skeleton deep>`:
2
+ //
3
+ // import 'react-native-skelo/deep';
4
+ //
5
+ // This is the only module that pulls in react-reconciler, so apps that don't
6
+ // use deep mode never bundle it. Requires `react-reconciler` to be installed.
7
+ import { setDeepExpander } from './core/deepRegistry';
8
+ import { expandToComponentNodes } from './core/parser/expandOffline';
9
+ setDeepExpander(expandToComponentNodes);
10
+ export const deepEnabled = true;
11
+ //# sourceMappingURL=deep.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["setDeepExpander","expandToComponentNodes","deepEnabled"],"sourceRoot":"../../src","sources":["deep.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,eAAe,QAAQ,qBAAqB;AACrD,SAASC,sBAAsB,QAAQ,6BAA6B;AAEpED,eAAe,CAACC,sBAAsB,CAAC;AAEvC,OAAO,MAAMC,WAAW,GAAG,IAAI","ignoreList":[]}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Skelo - Automatic skeleton loading for React Native
3
+ *
4
+ * Write your UI once. Skelo builds the loading state automatically.
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+
9
+ // Main component
10
+ export { Skeleton } from './components/Skeleton';
11
+ export { SkeletonIgnore } from './components/SkeletonIgnore';
12
+ export { withSkeleton } from './components/withSkeleton';
13
+ export { StyleSkeleton } from './core/generator/StyleSkeleton';
14
+ // Global API
15
+ export { Skelo } from './Skelo';
16
+
17
+ // Types
18
+
19
+ // Primitives (for plugin development)
20
+ export { SkeletonBox, SkeletonText, SkeletonImage, SkeletonCircle } from './components/primitives';
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Skeleton","SkeletonIgnore","withSkeleton","StyleSkeleton","Skelo","SkeletonBox","SkeletonText","SkeletonImage","SkeletonCircle"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,SAASA,QAAQ,QAAQ,uBAAuB;AAChD,SAASC,cAAc,QAAQ,6BAA6B;AAC5D,SAASC,YAAY,QAAQ,2BAA2B;AAExD,SAASC,aAAa,QAAQ,gCAAgC;AAG9D;AACA,SAASC,KAAK,QAAQ,SAAS;;AAE/B;;AASA;AACA,SAASC,WAAW,EAAEC,YAAY,EAAEC,aAAa,EAAEC,cAAc,QAAQ,yBAAyB","ignoreList":[]}
@@ -0,0 +1,53 @@
1
+ import React from 'react';
2
+ import { Image } from 'react-native';
3
+ /**
4
+ * Built-in plugin for React Native Image component
5
+ *
6
+ * Renders Image as:
7
+ * - SkeletonCircle if circular (avatar-like)
8
+ * - SkeletonImage otherwise
9
+ */
10
+ export const ImagePlugin = {
11
+ name: 'Image',
12
+ component: Image,
13
+ version: '1.0.0',
14
+ strategy: (props, context) => {
15
+ const {
16
+ primitives,
17
+ config
18
+ } = context;
19
+ const style = props.style || {};
20
+ const flatStyle = Array.isArray(style) ? Object.assign({}, ...style) : style;
21
+ const width = flatStyle.width ?? 100;
22
+ const height = flatStyle.height ?? 100;
23
+ const borderRadius = flatStyle.borderRadius ?? 0;
24
+
25
+ // Check if it's a circular image (avatar)
26
+ const isCircle = typeof width === 'number' && typeof height === 'number' && width === height && borderRadius === width / 2;
27
+ if (isCircle) {
28
+ return /*#__PURE__*/React.createElement(primitives.Circle, {
29
+ size: width,
30
+ animation: config.animation,
31
+ baseColor: config.baseColor,
32
+ highlightColor: config.highlightColor,
33
+ duration: config.duration,
34
+ style: flatStyle
35
+ });
36
+ }
37
+ return /*#__PURE__*/React.createElement(primitives.Image, {
38
+ width: width,
39
+ height: height,
40
+ borderRadius: borderRadius,
41
+ animation: config.animation,
42
+ baseColor: config.baseColor,
43
+ highlightColor: config.highlightColor,
44
+ duration: config.duration,
45
+ style: flatStyle
46
+ });
47
+ },
48
+ metadata: {
49
+ description: 'Automatic skeleton generation for Image components',
50
+ author: 'Skelo'
51
+ }
52
+ };
53
+ //# sourceMappingURL=ImagePlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","Image","ImagePlugin","name","component","version","strategy","props","context","primitives","config","style","flatStyle","Array","isArray","Object","assign","width","height","borderRadius","isCircle","createElement","Circle","size","animation","baseColor","highlightColor","duration","metadata","description","author"],"sourceRoot":"../../../src","sources":["plugins/ImagePlugin.tsx"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,KAAK,QAAQ,cAAc;AAIpC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,WAAuC,GAAG;EACrDC,IAAI,EAAE,OAAO;EACbC,SAAS,EAAEH,KAAK;EAChBI,OAAO,EAAE,OAAO;EAEhBC,QAAQ,EAAEA,CAACC,KAAK,EAAEC,OAAO,KAAK;IAC5B,MAAM;MAAEC,UAAU;MAAEC;IAAO,CAAC,GAAGF,OAAO;IACtC,MAAMG,KAAK,GAAGJ,KAAK,CAACI,KAAK,IAAI,CAAC,CAAC;IAC/B,MAAMC,SAAS,GAAGC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,GAAGI,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAGL,KAAK,CAAC,GAAGA,KAAK;IAE5E,MAAMM,KAAK,GAAGL,SAAS,CAACK,KAAK,IAAI,GAAG;IACpC,MAAMC,MAAM,GAAGN,SAAS,CAACM,MAAM,IAAI,GAAG;IACtC,MAAMC,YAAY,GAAGP,SAAS,CAACO,YAAY,IAAI,CAAC;;IAEhD;IACA,MAAMC,QAAQ,GACZ,OAAOH,KAAK,KAAK,QAAQ,IACzB,OAAOC,MAAM,KAAK,QAAQ,IAC1BD,KAAK,KAAKC,MAAM,IAChBC,YAAY,KAAKF,KAAK,GAAG,CAAC;IAE5B,IAAIG,QAAQ,EAAE;MACZ,oBACEpB,KAAA,CAAAqB,aAAA,CAACZ,UAAU,CAACa,MAAM;QAChBC,IAAI,EAAEN,KAAgB;QACtBO,SAAS,EAAEd,MAAM,CAACc,SAAU;QAC5BC,SAAS,EAAEf,MAAM,CAACe,SAAU;QAC5BC,cAAc,EAAEhB,MAAM,CAACgB,cAAe;QACtCC,QAAQ,EAAEjB,MAAM,CAACiB,QAAS;QAC1BhB,KAAK,EAAEC;MAAU,CAClB,CAAC;IAEN;IAEA,oBACEZ,KAAA,CAAAqB,aAAA,CAACZ,UAAU,CAACR,KAAK;MACfgB,KAAK,EAAEA,KAAM;MACbC,MAAM,EAAEA,MAAO;MACfC,YAAY,EAAEA,YAAuB;MACrCK,SAAS,EAAEd,MAAM,CAACc,SAAU;MAC5BC,SAAS,EAAEf,MAAM,CAACe,SAAU;MAC5BC,cAAc,EAAEhB,MAAM,CAACgB,cAAe;MACtCC,QAAQ,EAAEjB,MAAM,CAACiB,QAAS;MAC1BhB,KAAK,EAAEC;IAAU,CAClB,CAAC;EAEN,CAAC;EAEDgB,QAAQ,EAAE;IACRC,WAAW,EAAE,oDAAoD;IACjEC,MAAM,EAAE;EACV;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,63 @@
1
+ import React from 'react';
2
+ import { Text } from 'react-native';
3
+ /**
4
+ * Built-in plugin for React Native Text component
5
+ *
6
+ * Renders Text as SkeletonText with:
7
+ * - Estimated line count from text content
8
+ * - Font size from style
9
+ * - Line height from style
10
+ */
11
+ export const TextPlugin = {
12
+ name: 'Text',
13
+ component: Text,
14
+ version: '1.0.0',
15
+ strategy: (props, context) => {
16
+ const {
17
+ primitives,
18
+ config
19
+ } = context;
20
+ const style = props.style || {};
21
+ const flatStyle = Array.isArray(style) ? Object.assign({}, ...style) : style;
22
+ const fontSize = flatStyle.fontSize ?? 14;
23
+ const lineHeight = flatStyle.lineHeight ?? fontSize * 1.4;
24
+
25
+ // Estimate number of lines from text content
26
+ const textContent = props.children;
27
+ const estimatedLines = estimateTextLines(textContent);
28
+ return /*#__PURE__*/React.createElement(primitives.Text, {
29
+ lines: estimatedLines,
30
+ fontSize: fontSize,
31
+ lineHeight: lineHeight,
32
+ width: flatStyle.width ?? '100%',
33
+ animation: config.animation,
34
+ baseColor: config.baseColor,
35
+ highlightColor: config.highlightColor,
36
+ duration: config.duration,
37
+ style: flatStyle
38
+ });
39
+ },
40
+ metadata: {
41
+ description: 'Automatic skeleton generation for Text components',
42
+ author: 'Skelo'
43
+ }
44
+ };
45
+
46
+ /**
47
+ * Estimate number of lines from text content
48
+ */
49
+ function estimateTextLines(children) {
50
+ if (!children) return 1;
51
+ if (typeof children === 'string' || typeof children === 'number') {
52
+ const text = String(children);
53
+ const avgCharsPerLine = 40;
54
+ const estimatedLines = Math.ceil(text.length / avgCharsPerLine);
55
+ return Math.max(1, Math.min(estimatedLines, 5)); // Cap at 5 lines
56
+ }
57
+ if (Array.isArray(children)) {
58
+ // Multiple text nodes - count as separate lines
59
+ return Math.min(children.length, 5);
60
+ }
61
+ return 1;
62
+ }
63
+ //# sourceMappingURL=TextPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","Text","TextPlugin","name","component","version","strategy","props","context","primitives","config","style","flatStyle","Array","isArray","Object","assign","fontSize","lineHeight","textContent","children","estimatedLines","estimateTextLines","createElement","lines","width","animation","baseColor","highlightColor","duration","metadata","description","author","text","String","avgCharsPerLine","Math","ceil","length","max","min"],"sourceRoot":"../../../src","sources":["plugins/TextPlugin.tsx"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,IAAI,QAAQ,cAAc;AAInC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,UAAqC,GAAG;EACnDC,IAAI,EAAE,MAAM;EACZC,SAAS,EAAEH,IAAI;EACfI,OAAO,EAAE,OAAO;EAEhBC,QAAQ,EAAEA,CAACC,KAAK,EAAEC,OAAO,KAAK;IAC5B,MAAM;MAAEC,UAAU;MAAEC;IAAO,CAAC,GAAGF,OAAO;IACtC,MAAMG,KAAK,GAAGJ,KAAK,CAACI,KAAK,IAAI,CAAC,CAAC;IAC/B,MAAMC,SAAS,GAAGC,KAAK,CAACC,OAA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H,IAAI,CAACI,GAAG,CAACnB,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;EACnD;EAEA,IAAIR,KAAK,CAACC,OAAO,CAACM,QAAQ,CAAC,EAAE;IAC3B;IACA,OAAOgB,IAAI,CAACI,GAAG,CAACpB,QAAQ,CAACkB,MAAM,EAAE,CAAC,CAAC;EACrC;EAEA,OAAO,CAAC;AACV","ignoreList":[]}
@@ -0,0 +1,64 @@
1
+ import React from 'react';
2
+ import { View } from 'react-native';
3
+ /**
4
+ * Built-in plugin for React Native View component
5
+ *
6
+ * Renders View as:
7
+ * - SkeletonBox if has explicit width/height
8
+ * - Container with parsed children otherwise
9
+ */
10
+ export const ViewPlugin = {
11
+ name: 'View',
12
+ component: View,
13
+ version: '1.0.0',
14
+ strategy: (props, context) => {
15
+ const {
16
+ primitives,
17
+ parseChildren,
18
+ config
19
+ } = context;
20
+ const style = props.style || {};
21
+ const flatStyle = Array.isArray(style) ? Object.assign({}, ...style) : style;
22
+ const width = flatStyle.width;
23
+ const height = flatStyle.height;
24
+ const borderRadius = flatStyle.borderRadius ?? config.borderRadius;
25
+
26
+ // If View has explicit dimensions, render as box
27
+ if (width && height) {
28
+ return /*#__PURE__*/React.createElement(primitives.Box, {
29
+ width: width,
30
+ height: height,
31
+ borderRadius: borderRadius,
32
+ animation: config.animation,
33
+ baseColor: config.baseColor,
34
+ highlightColor: config.highlightColor,
35
+ duration: config.duration,
36
+ style: flatStyle
37
+ });
38
+ }
39
+
40
+ // If View has children, render as container
41
+ if (props.children) {
42
+ return /*#__PURE__*/React.createElement(View, {
43
+ style: flatStyle
44
+ }, parseChildren(props.children));
45
+ }
46
+
47
+ // Empty View - render as small placeholder
48
+ return /*#__PURE__*/React.createElement(primitives.Box, {
49
+ width: width ?? 100,
50
+ height: height ?? 20,
51
+ borderRadius: borderRadius,
52
+ animation: config.animation,
53
+ baseColor: config.baseColor,
54
+ highlightColor: config.highlightColor,
55
+ duration: config.duration,
56
+ style: flatStyle
57
+ });
58
+ },
59
+ metadata: {
60
+ description: 'Automatic skeleton generation for View components',
61
+ author: 'Skelo'
62
+ }
63
+ };
64
+ //# sourceMappingURL=ViewPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","View","ViewPlugin","name","component","version","strategy","props","context","primitives","parseChildren","config","style","flatStyle","Array","isArray","Object","assign","width","height","borderRadius","createElement","Box","animation","baseColor","highlightColor","duration","children","metadata","description","author"],"sourceRoot":"../../../src","sources":["plugins/ViewPlugin.tsx"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,IAAI,QAAQ,cAAc;AAInC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,UAAqC,GAAG;EACnDC,IAAI,EAAE,MAAM;EACZC,SAAS,EAAEH,IAAI;EACfI,OAAO,EAAE,OAAO;EAEhBC,QAAQ,EAAEA,CAACC,KAAK,EAAEC,OAAO,KAAK;IAC5B,MAAM;MAAEC,UAAU;MAAEC,aAAa;MAAEC;IAAO,CAAC,GAAGH,OAAO;IACrD,MAAMI,KAAK,GAAGL,KAAK,CAACK,KAAK,IAAI,CAAC,CAAC;IAC/B,MAAMC,SAAS,GAAGC,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,GAAGI,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAE,GAAGL,KAAK,CAAC,GAAGA,KAAK;IAE5E,MAAMM,KAAK,GAAGL,SAAS,CAACK,KAAK;IAC7B,MAAMC,MAAM,GAAGN,SAAS,CAACM,MAAM;IAC/B,MAAMC,YAAY,GAAGP,SAAS,CAACO,YAAY,IAAIT,MAAM,CAACS,YAAY;;IAElE;IACA,IAAIF,KAAK,IAAIC,MAAM,EAAE;MACnB,oBACEnB,KAAA,CAAAqB,aAAA,CAACZ,UAAU,CAACa,GAAG;QACbJ,KAAK,EAAEA,KAAM;QACbC,MAAM,EAAEA,MAAO;QACfC,YAAY,EAAEA,YAAa;QAC3BG,SAAS,EAAEZ,MAAM,CAACY,SAAU;QAC5BC,SAAS,EAAEb,MAAM,CAACa,SAAU;QAC5BC,cAAc,EAAEd,MAAM,CAACc,cAAe;QACtCC,QAAQ,EAAEf,MAAM,CAACe,QAAS;QAC1Bd,KAAK,EAAEC;MAAU,CAClB,CAAC;IAEN;;IAEA;IACA,IAAIN,KAAK,CAACoB,QAAQ,EAAE;MAClB,oBAAO3B,KAAA,CAAAqB,aAAA,CAACpB,IAAI;QAACW,KAAK,EAAEC;MAAU,GAAEH,aAAa,CAACH,KAAK,CAACoB,QAAQ,CAAQ,CAAC;IACvE;;IAEA;IACA,oBACE3B,KAAA,CAAAqB,aAAA,CAACZ,UAAU,CAACa,GAAG;MACbJ,KAAK,EAAEA,KAAK,IAAI,GAAI;MACpBC,MAAM,EAAEA,MAAM,IAAI,EAAG;MACrBC,YAAY,EAAEA,YAAa;MAC3BG,SAAS,EAAEZ,MAAM,CAACY,SAAU;MAC5BC,SAAS,EAAEb,MAAM,CAACa,SAAU;MAC5BC,cAAc,EAAEd,MAAM,CAACc,cAAe;MACtCC,QAAQ,EAAEf,MAAM,CAACe,QAAS;MAC1Bd,KAAK,EAAEC;IAAU,CAClB,CAAC;EAEN,CAAC;EAEDe,QAAQ,EAAE;IACRC,WAAW,EAAE,mDAAmD;IAChEC,MAAM,EAAE;EACV;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ export { ViewPlugin } from './ViewPlugin';
2
+ export { TextPlugin } from './TextPlugin';
3
+ export { ImagePlugin } from './ImagePlugin';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ViewPlugin","TextPlugin","ImagePlugin"],"sourceRoot":"../../../src","sources":["plugins/index.ts"],"mappings":"AAAA,SAASA,UAAU,QAAQ,cAAc;AACzC,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,WAAW,QAAQ,eAAe","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/index.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/plugin.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=skeleton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/skeleton.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,123 @@
1
+ import React, { isValidElement } from 'react';
2
+ import { View, Text, Image, ImageBackground, ScrollView, SafeAreaView, FlatList, SectionList, VirtualizedList, TouchableOpacity, TouchableHighlight, TouchableWithoutFeedback, Pressable, KeyboardAvoidingView } from 'react-native';
3
+
4
+ // Re-exported so consumers can access it from the skelo utils surface
5
+ export { isValidElement };
6
+
7
+ /**
8
+ * Reference map of React Native host components to their canonical names.
9
+ *
10
+ * Modern RN components (View/Text/Image/...) are `forwardRef`/`memo` objects,
11
+ * not plain functions or strings, so name/displayName sniffing is unreliable.
12
+ * Identifying them by reference is exact. This works across the library/app
13
+ * module boundary because Metro resolves a single `react-native` instance.
14
+ */
15
+ const RN_COMPONENT_NAMES = new Map([[View, 'View'], [Text, 'Text'], [Image, 'Image'], [ImageBackground, 'ImageBackground'], [ScrollView, 'ScrollView'], [SafeAreaView, 'SafeAreaView'], [FlatList, 'FlatList'], [SectionList, 'SectionList'], [VirtualizedList, 'VirtualizedList'], [TouchableOpacity, 'TouchableOpacity'], [TouchableHighlight, 'TouchableHighlight'], [TouchableWithoutFeedback, 'TouchableWithoutFeedback'], [Pressable, 'Pressable'], [KeyboardAvoidingView, 'KeyboardAvoidingView']]);
16
+
17
+ /**
18
+ * Get component display name or type name
19
+ *
20
+ * @param element - React element
21
+ * @returns Component name as string
22
+ */
23
+ export function getComponentName(element) {
24
+ const type = element.type;
25
+ if (type === React.Fragment) {
26
+ return 'Fragment';
27
+ }
28
+
29
+ // Exact identification of RN host components (forwardRef/memo objects).
30
+ const mapped = RN_COMPONENT_NAMES.get(type);
31
+ if (mapped) {
32
+ return mapped;
33
+ }
34
+
35
+ // Intrinsic host string (e.g. web/DOM or raw native tags).
36
+ if (typeof type === 'string') {
37
+ return type;
38
+ }
39
+
40
+ // Plain function/class components.
41
+ if (typeof type === 'function') {
42
+ const fn = type;
43
+ return fn.displayName || fn.name || 'Anonymous';
44
+ }
45
+
46
+ // forwardRef / memo wrappers: unwrap to find a usable name.
47
+ if (typeof type === 'object' && type !== null) {
48
+ const obj = type;
49
+ if (obj.displayName) {
50
+ return obj.displayName;
51
+ }
52
+ if (obj.render) {
53
+ return obj.render.displayName || obj.render.name || 'Anonymous';
54
+ }
55
+ // memo(Component) nests the real component under `.type`.
56
+ if (obj.type) {
57
+ return getComponentName({
58
+ type: obj.type
59
+ });
60
+ }
61
+ return 'Anonymous';
62
+ }
63
+ return 'Unknown';
64
+ }
65
+
66
+ /**
67
+ * Check if element is a React Fragment
68
+ *
69
+ * @param element - React element
70
+ * @returns True if element is a Fragment
71
+ */
72
+ export function isFragment(element) {
73
+ return element.type === React.Fragment;
74
+ }
75
+
76
+ /**
77
+ * Flatten children, handling Fragments recursively
78
+ *
79
+ * @param children - React children
80
+ * @returns Flattened array of children
81
+ */
82
+ export function flattenChildren(children) {
83
+ const result = [];
84
+ React.Children.forEach(children, child => {
85
+ if (! /*#__PURE__*/isValidElement(child)) {
86
+ result.push(child);
87
+ return;
88
+ }
89
+ if (isFragment(child)) {
90
+ // Recursively flatten fragment children
91
+ const fragmentChildren = flattenChildren(child.props.children);
92
+ result.push(...fragmentChildren);
93
+ } else {
94
+ result.push(child);
95
+ }
96
+ });
97
+ return result;
98
+ }
99
+
100
+ /**
101
+ * Check if component is a touchable component
102
+ *
103
+ * @param element - React element
104
+ * @returns True if component is touchable
105
+ */
106
+ export function isTouchableComponent(element) {
107
+ const name = getComponentName(element);
108
+ const touchableTypes = ['TouchableOpacity', 'TouchableHighlight', 'TouchableWithoutFeedback', 'TouchableNativeFeedback', 'Pressable'];
109
+ return touchableTypes.includes(name);
110
+ }
111
+
112
+ /**
113
+ * Generate random width percentage for natural skeleton look
114
+ *
115
+ * @param min - Minimum percentage (0-100)
116
+ * @param max - Maximum percentage (0-100)
117
+ * @returns Random percentage as string (e.g., "75%")
118
+ */
119
+ export function randomWidth(min = 60, max = 90) {
120
+ const random = Math.floor(Math.random() * (max - min + 1)) + min;
121
+ return `${random}%`;
122
+ }
123
+ //# sourceMappingURL=componentUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","isValidElement","View","Text","Image","ImageBackground","ScrollView","SafeAreaView","FlatList","SectionList","VirtualizedList","TouchableOpacity","TouchableHighlight","TouchableWithoutFeedback","Pressable","KeyboardAvoidingView","RN_COMPONENT_NAMES","Map","getComponentName","element","type","Fragment","mapped","get","fn","displayName","name","obj","render","isFragment","flattenChildren","children","result","Children","forEach","child","push","fragmentChildren","props","isTouchableComponent","touchableTypes","includes","randomWidth","min","max","random","Math","floor"],"sourceRoot":"../../../src","sources":["utils/componentUtils.ts"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,cAAc,QAAQ,OAAO;AAE7C,SACEC,IAAI,EACJC,IAAI,EACJC,KAAK,EACLC,eAAe,EACfC,UAAU,EACVC,YAAY,EACZC,QAAQ,EACRC,WAAW,EACXC,eAAe,EACfC,gBAAgB,EAChBC,kBAAkB,EAClBC,wBAAwB,EACxBC,SAAS,EACTC,oBAAoB,QACf,cAAc;;AAErB;AACA,SAASd,cAAc;;AAEvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMe,kBAAkB,GAAG,IAAIC,GAAG,CAAkB,CAClD,CAACf,IAAI,EAAE,MAAM,CAAC,EACd,CAACC,IAAI,EAAE,MAAM,CAAC,EACd,CAACC,KAAK,EAAE,OAAO,CAAC,EAChB,CAACC,eAAe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CAAC;AACtC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASgB,WAAWA,CAACC,GAAW,GAAG,EAAE,EAAEC,GAAW,GAAG,EAAE,EAAU;EACtE,MAAMC,MAAM,GAAGC,IAAI,CAACC,KAAK,CAACD,IAAI,CAACD,MAAM,CAAC,CAAC,IAAID,GAAG,GAAGD,GAAG,GAAG,CAAC,CAAC,CAAC,GAAGA,GAAG;EAChE,OAAO,GAAGE,MAAM,GAAG;AACrB","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ export { resolveStyle, extractDimensions, isPercentage, percentageToNumber } from './styleUtils';
2
+ export { getComponentName, isFragment, flattenChildren, isTouchableComponent, randomWidth } from './componentUtils';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["resolveStyle","extractDimensions","isPercentage","percentageToNumber","getComponentName","isFragment","flattenChildren","isTouchableComponent","randomWidth"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":"AAAA,SAASA,YAAY,EAAEC,iBAAiB,EAAEC,YAAY,EAAEC,kBAAkB,QAAQ,cAAc;AAEhG,SACEC,gBAAgB,EAChBC,UAAU,EACVC,eAAe,EACfC,oBAAoB,EACpBC,WAAW,QACN,kBAAkB","ignoreList":[]}
@@ -0,0 +1,66 @@
1
+ import { StyleSheet } from 'react-native';
2
+ /**
3
+ * Flatten and resolve styles from React Native style prop
4
+ *
5
+ * @param style - Style prop (can be object, array, or StyleSheet reference)
6
+ * @returns Flattened style object
7
+ */
8
+ export function resolveStyle(style) {
9
+ if (!style) {
10
+ return {};
11
+ }
12
+ try {
13
+ const flattened = StyleSheet.flatten(style);
14
+ return flattened;
15
+ } catch (error) {
16
+ // Handle invalid styles gracefully
17
+ if (__DEV__) {
18
+ console.warn('[Skelo] Failed to resolve style:', error);
19
+ }
20
+ return {};
21
+ }
22
+ }
23
+
24
+ /**
25
+ * Extract dimensions from resolved style
26
+ *
27
+ * @param style - Resolved style object
28
+ * @returns Object with width and height (if present)
29
+ */
30
+ export function extractDimensions(style) {
31
+ return {
32
+ width: style.width,
33
+ height: style.height
34
+ };
35
+ }
36
+
37
+ /**
38
+ * Check if a resolved style declares both an explicit width and height
39
+ *
40
+ * @param style - Resolved style object
41
+ * @returns True if both width and height are defined
42
+ */
43
+ export function hasExplicitSize(style) {
44
+ return style.width !== undefined && style.height !== undefined;
45
+ }
46
+
47
+ /**
48
+ * Check if a value is a percentage string
49
+ *
50
+ * @param value - Value to check
51
+ * @returns True if value is a percentage string
52
+ */
53
+ export function isPercentage(value) {
54
+ return typeof value === 'string' && value.includes('%');
55
+ }
56
+
57
+ /**
58
+ * Convert percentage to number (strips %)
59
+ *
60
+ * @param value - Percentage string (e.g., "50%")
61
+ * @returns Number without % sign
62
+ */
63
+ export function percentageToNumber(value) {
64
+ return parseFloat(value.replace('%', ''));
65
+ }
66
+ //# sourceMappingURL=styleUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["StyleSheet","resolveStyle","style","flattened","flatten","error","__DEV__","console","warn","extractDimensions","width","height","hasExplicitSize","undefined","isPercentage","value","includes","percentageToNumber","parseFloat","replace"],"sourceRoot":"../../../src","sources":["utils/styleUtils.ts"],"mappings":"AAAA,SAASA,UAAU,QAAQ,cAAc;AAIzC;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAACC,KAAU,EAAiB;EACtD,IAAI,CAACA,KAAK,EAAE;IACV,OAAO,CAAC,CAAC;EACX;EAEA,IAAI;IACF,MAAMC,SAAS,GAAGH,UAAU,CAACI,OAAO,CAACF,KAAK,CAAC;IAC3C,OAAOC,SAAS;EAClB,CAAC,CAAC,OAAOE,KAAK,EAAE;IACd;IACA,IAAIC,OAAO,EAAE;MACXC,OAAO,CAACC,IAAI,CAAC,kCAAkC,EAAEH,KAAK,CAAC;IACzD;IACA,OAAO,CAAC,CAAC;EACX;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,iBAAiBA,CAACP,KAAoB,EAGpD;EACA,OAAO;IACLQ,KAAK,EAAER,KAAK,CAACQ,KAAK;IAClBC,MAAM,EAAET,KAAK,CAACS;EAChB,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAACV,KAAoB,EAAW;EAC7D,OAAOA,KAAK,CAACQ,KAAK,KAAKG,SAAS,IAAIX,KAAK,CAACS,MAAM,KAAKE,SAAS;AAChE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAACC,KAAU,EAAW;EAChD,OAAO,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,CAACC,QAAQ,CAAC,GAAG,CAAC;AACzD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAACF,KAAa,EAAU;EACxD,OAAOG,UAAU,CAACH,KAAK,CAACI,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AAC3C","ignoreList":[]}
@@ -0,0 +1,76 @@
1
+ import type { ComponentType, ReactElement } from 'react';
2
+ import type { SkeletonConfig, SkeletonPlugin } from './types';
3
+ import { type StyleInput } from './core/generator/StyleSkeleton';
4
+ /**
5
+ * Global Skelo API for plugin management
6
+ *
7
+ * @example
8
+ * ```tsx
9
+ * import { Skelo } from 'react-native-skelo';
10
+ * import { Avatar } from 'my-ui-library';
11
+ *
12
+ * Skelo.register({
13
+ * name: 'Avatar',
14
+ * component: Avatar,
15
+ * strategy: (props, { primitives }) => {
16
+ * return <primitives.Circle size={props.size || 40} />;
17
+ * },
18
+ * });
19
+ * ```
20
+ */
21
+ export declare const Skelo: {
22
+ /**
23
+ * Register a plugin
24
+ *
25
+ * @param plugin - Plugin configuration
26
+ */
27
+ register<P = any>(plugin: SkeletonPlugin<P>): void;
28
+ /**
29
+ * Unregister a plugin
30
+ *
31
+ * @param component - Component type to unregister
32
+ */
33
+ unregister(component: ComponentType): void;
34
+ /**
35
+ * Get plugin for component
36
+ *
37
+ * @param component - Component type
38
+ * @returns Plugin or undefined
39
+ */
40
+ getPlugin(component: ComponentType): SkeletonPlugin | undefined;
41
+ /**
42
+ * Check if plugin exists
43
+ *
44
+ * @param component - Component type
45
+ * @returns True if plugin is registered
46
+ */
47
+ hasPlugin(component: ComponentType): boolean;
48
+ /**
49
+ * Get all plugins
50
+ *
51
+ * @returns Array of all registered plugins
52
+ */
53
+ getAllPlugins(): SkeletonPlugin[];
54
+ /**
55
+ * Clear all plugins (useful for testing)
56
+ */
57
+ clearPlugins(): void;
58
+ /**
59
+ * Generate a skeleton element directly from a set of styles.
60
+ *
61
+ * @param styles - A `StyleSheet.create` object or an array of styles
62
+ * @param config - Optional animation/color overrides
63
+ * @returns A skeleton React element
64
+ *
65
+ * @example
66
+ * ```tsx
67
+ * {loading ? Skelo.fromStyles(styles) : <Screen />}
68
+ * ```
69
+ */
70
+ fromStyles(styles: StyleInput, config?: Partial<SkeletonConfig>): ReactElement;
71
+ /**
72
+ * Library version
73
+ */
74
+ version: string;
75
+ };
76
+ //# sourceMappingURL=Skelo.d.ts.map