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 @@
1
+ {"version":3,"file":"componentUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/componentUtils.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAmBrD,OAAO,EAAE,cAAc,EAAE,CAAC;AA2B1B;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,CA6C9D;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAEzD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,SAAS,GAAG,SAAS,EAAE,CAmBhE;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAUnE;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,GAAG,GAAE,MAAW,EAAE,GAAG,GAAE,MAAW,GAAG,MAAM,CAGtE"}
@@ -0,0 +1,3 @@
1
+ export { resolveStyle, extractDimensions, isPercentage, percentageToNumber } from './styleUtils';
2
+ export { getComponentName, isFragment, flattenChildren, isTouchableComponent, randomWidth, } from './componentUtils';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEjG,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,oBAAoB,EACpB,WAAW,GACZ,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,41 @@
1
+ import type { DimensionValue } from 'react-native';
2
+ import type { ResolvedStyle } from '../types';
3
+ /**
4
+ * Flatten and resolve styles from React Native style prop
5
+ *
6
+ * @param style - Style prop (can be object, array, or StyleSheet reference)
7
+ * @returns Flattened style object
8
+ */
9
+ export declare function resolveStyle(style: any): ResolvedStyle;
10
+ /**
11
+ * Extract dimensions from resolved style
12
+ *
13
+ * @param style - Resolved style object
14
+ * @returns Object with width and height (if present)
15
+ */
16
+ export declare function extractDimensions(style: ResolvedStyle): {
17
+ width?: DimensionValue;
18
+ height?: DimensionValue;
19
+ };
20
+ /**
21
+ * Check if a resolved style declares both an explicit width and height
22
+ *
23
+ * @param style - Resolved style object
24
+ * @returns True if both width and height are defined
25
+ */
26
+ export declare function hasExplicitSize(style: ResolvedStyle): boolean;
27
+ /**
28
+ * Check if a value is a percentage string
29
+ *
30
+ * @param value - Value to check
31
+ * @returns True if value is a percentage string
32
+ */
33
+ export declare function isPercentage(value: any): boolean;
34
+ /**
35
+ * Convert percentage to number (strips %)
36
+ *
37
+ * @param value - Percentage string (e.g., "50%")
38
+ * @returns Number without % sign
39
+ */
40
+ export declare function percentageToNumber(value: string): number;
41
+ //# sourceMappingURL=styleUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styleUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/styleUtils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,GAAG,GAAG,aAAa,CAetD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,aAAa,GAAG;IACvD,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB,CAKA;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAE7D;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAEhD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAExD"}
package/package.json CHANGED
@@ -1,7 +1,52 @@
1
1
  {
2
2
  "name": "react-native-skelo",
3
- "version": "0.0.1",
4
- "description": "🚧 Coming soon — Automatic skeleton loading for React Native. Write your UI once, Skelo builds the loading state automatically.",
3
+ "version": "0.0.2",
4
+ "description": "Automatic skeleton loading for React Native. Write your UI once, Skelo builds the loading state automatically.",
5
+ "main": "lib/commonjs/index.js",
6
+ "module": "lib/module/index.js",
7
+ "types": "lib/typescript/index.d.ts",
8
+ "react-native": "src/index.ts",
9
+ "source": "src/index.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./lib/typescript/index.d.ts",
13
+ "react-native": "./src/index.ts",
14
+ "import": "./lib/module/index.js",
15
+ "require": "./lib/commonjs/index.js",
16
+ "default": "./lib/commonjs/index.js"
17
+ },
18
+ "./deep": {
19
+ "types": "./lib/typescript/deep.d.ts",
20
+ "react-native": "./src/deep.ts",
21
+ "import": "./lib/module/deep.js",
22
+ "require": "./lib/commonjs/deep.js",
23
+ "default": "./lib/commonjs/deep.js"
24
+ },
25
+ "./package.json": "./package.json"
26
+ },
27
+ "files": [
28
+ "src",
29
+ "lib",
30
+ "!**/__tests__",
31
+ "!**/__mocks__"
32
+ ],
33
+ "scripts": {
34
+ "test": "jest",
35
+ "test:watch": "jest --watch",
36
+ "test:coverage": "jest --coverage",
37
+ "typecheck": "tsc --noEmit",
38
+ "build": "bob build",
39
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
40
+ "lint:fix": "eslint \"**/*.{js,ts,tsx}\" --fix",
41
+ "format": "prettier --write \"**/*.{js,ts,tsx,json,md}\"",
42
+ "prepare": "bob build",
43
+ "prepublishOnly": "bob build",
44
+ "publish:npm": "npm publish --access public",
45
+ "publish:alpha": "npm publish --tag alpha --access public",
46
+ "publish:git": "git push origin HEAD --tags",
47
+ "release": "npm run build && npm publish --access public && git push origin HEAD --tags",
48
+ "clean": "del-cli lib"
49
+ },
5
50
  "keywords": [
6
51
  "react-native",
7
52
  "skeleton",
@@ -11,23 +56,138 @@
11
56
  "skeleton-screen",
12
57
  "skeleton-loader",
13
58
  "loading-state",
14
- "reanimated"
59
+ "reanimated",
60
+ "fabric",
61
+ "automatic",
62
+ "zero-config"
15
63
  ],
16
- "homepage": "https://github.com/shubhanshubb/react-native-skelo#readme",
17
- "bugs": {
18
- "url": "https://github.com/shubhanshubb/react-native-skelo/issues"
19
- },
20
64
  "repository": {
21
65
  "type": "git",
22
66
  "url": "git+https://github.com/shubhanshubb/react-native-skelo.git"
23
67
  },
24
- "license": "MIT",
25
68
  "author": "Shubhanshu Barnwal <connect@shubhanshubb.dev> (https://shubhanshubb.dev)",
26
- "files": [
27
- "README.md"
69
+ "maintainers": [
70
+ {
71
+ "name": "Shubhanshu Barnwal",
72
+ "email": "connect@shubhanshubb.dev",
73
+ "url": "https://shubhanshubb.dev"
74
+ }
28
75
  ],
76
+ "license": "MIT",
77
+ "bugs": {
78
+ "url": "https://github.com/shubhanshubb/react-native-skelo/issues"
79
+ },
80
+ "homepage": "https://github.com/shubhanshubb/react-native-skelo#readme",
81
+ "funding": {
82
+ "type": "individual",
83
+ "url": "https://buymeacoffee.com/shubhanshubb"
84
+ },
29
85
  "publishConfig": {
30
- "access": "public",
31
86
  "registry": "https://registry.npmjs.org/"
87
+ },
88
+ "peerDependencies": {
89
+ "react": "*",
90
+ "react-native": "*",
91
+ "react-native-linear-gradient": ">=2.8.0",
92
+ "react-native-reanimated": ">=3.0.0",
93
+ "react-reconciler": ">=0.29.0"
94
+ },
95
+ "peerDependenciesMeta": {
96
+ "react-reconciler": {
97
+ "optional": true
98
+ }
99
+ },
100
+ "devDependencies": {
101
+ "@commitlint/config-conventional": "^18.4.3",
102
+ "@react-native/eslint-config": "^0.73.1",
103
+ "@release-it/conventional-changelog": "^8.0.1",
104
+ "@testing-library/react-native": "^12.4.2",
105
+ "@types/jest": "^29.5.11",
106
+ "@types/react": "^18.2.45",
107
+ "del-cli": "^5.1.0",
108
+ "eslint": "^8.56.0",
109
+ "eslint-config-prettier": "^9.1.0",
110
+ "eslint-plugin-prettier": "^5.1.2",
111
+ "jest": "^29.7.0",
112
+ "prettier": "^3.1.1",
113
+ "react": "18.2.0",
114
+ "react-native": "0.73.1",
115
+ "react-native-builder-bob": "^0.23.2",
116
+ "react-native-linear-gradient": "^2.8.3",
117
+ "react-native-reanimated": "^3.6.1",
118
+ "react-reconciler": "^0.29.2",
119
+ "react-test-renderer": "18.2.0",
120
+ "release-it": "^17.0.1",
121
+ "typescript": "^5.3.3"
122
+ },
123
+ "jest": {
124
+ "preset": "react-native",
125
+ "setupFiles": [
126
+ "<rootDir>/jest.setup.js"
127
+ ],
128
+ "modulePathIgnorePatterns": [
129
+ "<rootDir>/lib/"
130
+ ],
131
+ "transformIgnorePatterns": [
132
+ "node_modules/(?!(@react-native|react-native|react-native-reanimated|react-native-linear-gradient)/)"
133
+ ],
134
+ "collectCoverageFrom": [
135
+ "src/**/*.{ts,tsx}",
136
+ "!src/**/*.d.ts",
137
+ "!src/**/index.ts",
138
+ "!src/types/**"
139
+ ],
140
+ "coverageThreshold": {
141
+ "global": {
142
+ "branches": 80,
143
+ "functions": 80,
144
+ "lines": 80,
145
+ "statements": 80
146
+ }
147
+ }
148
+ },
149
+ "commitlint": {
150
+ "extends": [
151
+ "@commitlint/config-conventional"
152
+ ]
153
+ },
154
+ "release-it": {
155
+ "git": {
156
+ "commitMessage": "chore: release ${version}",
157
+ "tagName": "v${version}"
158
+ },
159
+ "npm": {
160
+ "publish": true
161
+ },
162
+ "github": {
163
+ "release": true
164
+ },
165
+ "plugins": {
166
+ "@release-it/conventional-changelog": {
167
+ "preset": "angular"
168
+ }
169
+ }
170
+ },
171
+ "react-native-builder-bob": {
172
+ "source": "src",
173
+ "output": "lib",
174
+ "targets": [
175
+ "commonjs",
176
+ "module",
177
+ [
178
+ "typescript",
179
+ {
180
+ "project": "tsconfig.build.json"
181
+ }
182
+ ]
183
+ ]
184
+ },
185
+ "prettier": {
186
+ "singleQuote": true,
187
+ "trailingComma": "es5",
188
+ "tabWidth": 2,
189
+ "semi": true,
190
+ "printWidth": 100,
191
+ "arrowParens": "avoid"
32
192
  }
33
193
  }
package/src/Skelo.ts ADDED
@@ -0,0 +1,103 @@
1
+ import React from 'react';
2
+ import type { ComponentType, ReactElement } from 'react';
3
+ import type { SkeletonConfig, SkeletonPlugin } from './types';
4
+ import { registry } from './core/registry';
5
+ import { StyleSkeleton, type StyleInput } from './core/generator/StyleSkeleton';
6
+ import { DEFAULT_CONFIG } from './constants/defaults';
7
+
8
+ /**
9
+ * Global Skelo API for plugin management
10
+ *
11
+ * @example
12
+ * ```tsx
13
+ * import { Skelo } from 'react-native-skelo';
14
+ * import { Avatar } from 'my-ui-library';
15
+ *
16
+ * Skelo.register({
17
+ * name: 'Avatar',
18
+ * component: Avatar,
19
+ * strategy: (props, { primitives }) => {
20
+ * return <primitives.Circle size={props.size || 40} />;
21
+ * },
22
+ * });
23
+ * ```
24
+ */
25
+ export const Skelo = {
26
+ /**
27
+ * Register a plugin
28
+ *
29
+ * @param plugin - Plugin configuration
30
+ */
31
+ register<P = any>(plugin: SkeletonPlugin<P>): void {
32
+ registry.register(plugin);
33
+ },
34
+
35
+ /**
36
+ * Unregister a plugin
37
+ *
38
+ * @param component - Component type to unregister
39
+ */
40
+ unregister(component: ComponentType): void {
41
+ registry.unregister(component);
42
+ },
43
+
44
+ /**
45
+ * Get plugin for component
46
+ *
47
+ * @param component - Component type
48
+ * @returns Plugin or undefined
49
+ */
50
+ getPlugin(component: ComponentType): SkeletonPlugin | undefined {
51
+ return registry.getPlugin(component);
52
+ },
53
+
54
+ /**
55
+ * Check if plugin exists
56
+ *
57
+ * @param component - Component type
58
+ * @returns True if plugin is registered
59
+ */
60
+ hasPlugin(component: ComponentType): boolean {
61
+ return registry.hasPlugin(component);
62
+ },
63
+
64
+ /**
65
+ * Get all plugins
66
+ *
67
+ * @returns Array of all registered plugins
68
+ */
69
+ getAllPlugins(): SkeletonPlugin[] {
70
+ return registry.getAllPlugins();
71
+ },
72
+
73
+ /**
74
+ * Clear all plugins (useful for testing)
75
+ */
76
+ clearPlugins(): void {
77
+ registry.clear();
78
+ },
79
+
80
+ /**
81
+ * Generate a skeleton element directly from a set of styles.
82
+ *
83
+ * @param styles - A `StyleSheet.create` object or an array of styles
84
+ * @param config - Optional animation/color overrides
85
+ * @returns A skeleton React element
86
+ *
87
+ * @example
88
+ * ```tsx
89
+ * {loading ? Skelo.fromStyles(styles) : <Screen />}
90
+ * ```
91
+ */
92
+ fromStyles(styles: StyleInput, config: Partial<SkeletonConfig> = {}): ReactElement {
93
+ return React.createElement(StyleSkeleton, {
94
+ styles,
95
+ config: { ...DEFAULT_CONFIG, ...config },
96
+ });
97
+ },
98
+
99
+ /**
100
+ * Library version
101
+ */
102
+ version: '0.1.0',
103
+ };
@@ -0,0 +1,139 @@
1
+ import React from 'react';
2
+ import type { DimensionValue, StyleProp, ViewStyle } from 'react-native';
3
+ import { View } from 'react-native';
4
+ import { ShimmerAnimation } from './ShimmerAnimation';
5
+ import { PulseAnimation } from './PulseAnimation';
6
+
7
+ export type AnimationType = 'shimmer' | 'pulse' | 'none';
8
+
9
+ interface AnimationWrapperProps {
10
+ /**
11
+ * Type of animation to use
12
+ * @default 'shimmer'
13
+ */
14
+ animation?: AnimationType;
15
+
16
+ /**
17
+ * Width of the animated element
18
+ */
19
+ width?: DimensionValue;
20
+
21
+ /**
22
+ * Height of the animated element
23
+ */
24
+ height?: DimensionValue;
25
+
26
+ /**
27
+ * Base color of the skeleton
28
+ * @default '#E1E9EE'
29
+ */
30
+ baseColor?: string;
31
+
32
+ /**
33
+ * Highlight color for animation
34
+ * @default '#F2F8FC'
35
+ */
36
+ highlightColor?: string;
37
+
38
+ /**
39
+ * Animation duration in milliseconds
40
+ * @default 1500 for shimmer, 1000 for pulse
41
+ */
42
+ duration?: number;
43
+
44
+ /**
45
+ * Border radius
46
+ * @default 4
47
+ */
48
+ borderRadius?: number;
49
+
50
+ /**
51
+ * Additional styles
52
+ */
53
+ style?: StyleProp<ViewStyle>;
54
+
55
+ /**
56
+ * Child content
57
+ */
58
+ children?: React.ReactNode;
59
+ }
60
+
61
+ /**
62
+ * Animation wrapper that selects the appropriate animation type
63
+ *
64
+ * Provides a unified interface for all skeleton animations:
65
+ * - shimmer: Left-to-right shimmer effect
66
+ * - pulse: Breathing/pulsing opacity
67
+ * - none: Static skeleton (no animation)
68
+ *
69
+ * @example
70
+ * ```tsx
71
+ * <AnimationWrapper
72
+ * animation="shimmer"
73
+ * width={200}
74
+ * height={20}
75
+ * />
76
+ * ```
77
+ */
78
+ export function AnimationWrapper({
79
+ animation = 'shimmer',
80
+ width,
81
+ height,
82
+ baseColor = '#E1E9EE',
83
+ highlightColor = '#F2F8FC',
84
+ duration,
85
+ borderRadius = 4,
86
+ style,
87
+ children,
88
+ }: AnimationWrapperProps) {
89
+ // No animation - static skeleton
90
+ if (animation === 'none') {
91
+ return (
92
+ <View
93
+ style={[
94
+ {
95
+ width,
96
+ height,
97
+ borderRadius,
98
+ backgroundColor: baseColor,
99
+ },
100
+ style,
101
+ ]}
102
+ >
103
+ {children}
104
+ </View>
105
+ );
106
+ }
107
+
108
+ // Shimmer animation
109
+ if (animation === 'shimmer') {
110
+ return (
111
+ <ShimmerAnimation
112
+ width={width}
113
+ height={height}
114
+ baseColor={baseColor}
115
+ highlightColor={highlightColor}
116
+ duration={duration ?? 1500}
117
+ borderRadius={borderRadius}
118
+ style={style}
119
+ >
120
+ {children}
121
+ </ShimmerAnimation>
122
+ );
123
+ }
124
+
125
+ // Pulse animation
126
+ return (
127
+ <PulseAnimation
128
+ width={width}
129
+ height={height}
130
+ baseColor={baseColor}
131
+ highlightColor={highlightColor}
132
+ duration={duration ?? 1000}
133
+ borderRadius={borderRadius}
134
+ style={style}
135
+ >
136
+ {children}
137
+ </PulseAnimation>
138
+ );
139
+ }
@@ -0,0 +1,138 @@
1
+ import React, { useEffect } from 'react';
2
+ import type { DimensionValue, StyleProp, ViewStyle } from 'react-native';
3
+ import { StyleSheet } from 'react-native';
4
+ import Animated, {
5
+ useSharedValue,
6
+ useAnimatedStyle,
7
+ withRepeat,
8
+ withSequence,
9
+ withTiming,
10
+ Easing,
11
+ } from 'react-native-reanimated';
12
+
13
+ interface PulseProps {
14
+ /**
15
+ * Width of the pulse container
16
+ */
17
+ width?: DimensionValue;
18
+
19
+ /**
20
+ * Height of the pulse container
21
+ */
22
+ height?: DimensionValue;
23
+
24
+ /**
25
+ * Base color of the skeleton
26
+ * @default '#E1E9EE'
27
+ */
28
+ baseColor?: string;
29
+
30
+ /**
31
+ * Highlight color for pulse
32
+ * @default '#F2F8FC'
33
+ */
34
+ highlightColor?: string;
35
+
36
+ /**
37
+ * Animation duration in milliseconds
38
+ * @default 1000
39
+ */
40
+ duration?: number;
41
+
42
+ /**
43
+ * Border radius
44
+ */
45
+ borderRadius?: number;
46
+
47
+ /**
48
+ * Additional styles
49
+ */
50
+ style?: StyleProp<ViewStyle>;
51
+
52
+ /**
53
+ * Child content (rendered inside pulse)
54
+ */
55
+ children?: React.ReactNode;
56
+ }
57
+
58
+ /**
59
+ * Pulse animation component using Reanimated 3
60
+ *
61
+ * Creates a subtle breathing/pulsing effect using:
62
+ * - Shared values for performance
63
+ * - Worklets for 60 FPS on UI thread
64
+ * - Opacity animation for pulse effect
65
+ *
66
+ * @example
67
+ * ```tsx
68
+ * <PulseAnimation
69
+ * width={200}
70
+ * height={20}
71
+ * borderRadius={4}
72
+ * />
73
+ * ```
74
+ */
75
+ export function PulseAnimation({
76
+ width,
77
+ height,
78
+ baseColor = '#E1E9EE',
79
+ duration = 1000,
80
+ borderRadius = 4,
81
+ style,
82
+ children,
83
+ }: PulseProps) {
84
+ // Shared value for opacity (0 to 1)
85
+ const opacity = useSharedValue(1);
86
+
87
+ useEffect(() => {
88
+ // Start infinite pulse animation
89
+ // Sequence: fade out -> fade in
90
+ opacity.value = withRepeat(
91
+ withSequence(
92
+ withTiming(0.5, {
93
+ duration: duration / 2,
94
+ easing: Easing.inOut(Easing.ease),
95
+ }),
96
+ withTiming(1, {
97
+ duration: duration / 2,
98
+ easing: Easing.inOut(Easing.ease),
99
+ })
100
+ ),
101
+ -1, // Infinite repeat
102
+ false // Don't reverse
103
+ );
104
+ }, [duration, opacity]);
105
+
106
+ // Animated style for pulse effect
107
+ const animatedStyle = useAnimatedStyle(() => {
108
+ 'worklet';
109
+
110
+ return {
111
+ opacity: opacity.value,
112
+ };
113
+ }, []);
114
+
115
+ return (
116
+ <Animated.View
117
+ style={[
118
+ styles.container,
119
+ {
120
+ width,
121
+ height,
122
+ borderRadius,
123
+ backgroundColor: baseColor,
124
+ },
125
+ animatedStyle,
126
+ style,
127
+ ]}
128
+ >
129
+ {children}
130
+ </Animated.View>
131
+ );
132
+ }
133
+
134
+ const styles = StyleSheet.create({
135
+ container: {
136
+ overflow: 'hidden',
137
+ },
138
+ });