react-native-skelo 0.0.1 → 0.0.3

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 +149 -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 +52 -0
  8. package/lib/commonjs/animations/PulseAnimation.js.map +1 -0
  9. package/lib/commonjs/animations/ShimmerAnimation.js +73 -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 +45 -0
  84. package/lib/module/animations/PulseAnimation.js.map +1 -0
  85. package/lib/module/animations/ShimmerAnimation.js +66 -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 +15 -0
  160. package/lib/typescript/animations/PulseAnimation.d.ts.map +1 -0
  161. package/lib/typescript/animations/ShimmerAnimation.d.ts +15 -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 +169 -11
  232. package/src/Skelo.ts +103 -0
  233. package/src/animations/AnimationWrapper.tsx +139 -0
  234. package/src/animations/PulseAnimation.tsx +76 -0
  235. package/src/animations/ShimmerAnimation.tsx +101 -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
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Shubhanshu Barnwal <connect@shubhanshubb.dev> (https://shubhanshubb.dev)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -2,41 +2,170 @@
2
2
 
3
3
  # react-native-skelo
4
4
 
5
- ### 🚧 Coming soon
5
+ **Write your UI once. Skelo builds the loading state automatically.**
6
6
 
7
- **Automatic skeleton loading for React Native.**
8
- Write your UI once — Skelo builds the loading state automatically.
7
+ [![npm](https://img.shields.io/npm/v/react-native-skelo)](https://www.npmjs.com/package/react-native-skelo)
8
+ [![license](https://img.shields.io/npm/l/react-native-skelo)](./LICENSE)
9
9
 
10
10
  </div>
11
11
 
12
- ---
12
+ > ⚠️ **Pre-release (`0.0.x`).** Early and evolving — the API may change. The first **stable** release will be **`0.1.0`**. The `deep` engine is experimental — see [caveats](#deep-mode-caveats-experimental).
13
+
14
+ Skeleton loading screens usually mean building — and maintaining — a second copy of your UI. Skelo derives the skeleton from the UI you already wrote.
13
15
 
14
16
  ```tsx
15
- // Instead of hand-building skeleton screens:
16
- <Skeleton loading={loading}>
17
+ import { Skeleton } from 'react-native-skelo';
18
+
19
+ <Skeleton loading={isLoading}>
20
+ <View style={styles.card}>
21
+ <Image style={styles.avatar} />
22
+ <Text style={styles.name}>{user.name}</Text>
23
+ </View>
24
+ </Skeleton>
25
+ ```
26
+
27
+ While `loading`, Skelo reads the tree and its styles and renders a matching skeleton (circle avatar, text bar). When `loading` is `false`, it renders your real content.
28
+
29
+ ## Installation
30
+
31
+ ```bash
32
+ npm install react-native-skelo react-native-reanimated
33
+ ```
34
+
35
+ That's all you need for the basic (inline) and `styles` usage. The shimmer uses
36
+ React Native's built-in `experimental_backgroundImage` gradient (New
37
+ Architecture) — no gradient library required.
38
+
39
+ ### To enable `deep` mode (optional)
40
+
41
+ `deep` mode is opt-in so the core library never bundles a reconciler you don't
42
+ use. Install `react-reconciler` (matching your React version) and import the
43
+ deep entry **once** in your app's entry file:
44
+
45
+ ```bash
46
+ # React 19:
47
+ npm install react-reconciler@0.31.0
48
+ # React 18:
49
+ npm install react-reconciler@0.29.2
50
+ ```
51
+
52
+ ```js
53
+ // index.js (app entry)
54
+ import 'react-native-skelo/deep';
55
+ ```
56
+
57
+ Without this, `<Skeleton deep>` simply falls back to static parsing (no crash).
58
+
59
+ ## Usage
60
+
61
+ ### Basic — inline host elements
62
+
63
+ Skelo traverses the `View` / `Text` / `Image` tree you pass and mirrors it:
64
+
65
+ ```tsx
66
+ <Skeleton loading={loading} animation="shimmer">
67
+ <View style={styles.row}>
68
+ <Image style={styles.avatar} /> {/* → circle / box */}
69
+ <Text style={styles.title}>Title</Text> {/* → text bar */}
70
+ </View>
71
+ </Skeleton>
72
+ ```
73
+
74
+ Structure comes from the JSX; dimensions come from each element's `style`.
75
+
76
+ ### `deep` — wrap any component (experimental)
77
+
78
+ Don't want to inline? Wrap an opaque component and let Skelo introspect it:
79
+
80
+ ```tsx
81
+ import { Skeleton, withSkeleton } from 'react-native-skelo';
82
+
83
+ <Skeleton loading={loading} deep>
17
84
  <ProfileScreen />
18
85
  </Skeleton>
19
86
 
20
- // Skelo generates the skeleton loading state for you.
87
+ // or as an HOC:
88
+ const Home = withSkeleton(HomeScreen);
89
+ <Home loading={loading} {...props} />
90
+ ```
91
+
92
+ Requires `react-reconciler` + `import 'react-native-skelo/deep'` (see [Installation](#to-enable-deep-mode-optional)). See also [caveats](#deep-mode-caveats-experimental).
93
+
94
+ ### `styles` — generate from a StyleSheet
95
+
96
+ Pass styles directly to get a stack of skeleton shapes (no children needed):
97
+
98
+ ```tsx
99
+ <Skeleton loading={loading} styles={styles} excludeStyles={['container']} />
100
+ ```
101
+
102
+ A StyleSheet has no hierarchy, so this produces one shape per style that has visual dimensions.
103
+
104
+ ### `Skeleton.Ignore` — keep something visible
105
+
106
+ ```tsx
107
+ <Skeleton loading={loading}>
108
+ <Skeleton.Ignore>
109
+ <Text style={styles.heading}>Profile</Text> {/* stays real */}
110
+ </Skeleton.Ignore>
111
+ <ProfileBody />
112
+ </Skeleton>
113
+ ```
114
+
115
+ ### Custom components — register a plugin
116
+
117
+ ```tsx
118
+ import { Skelo } from 'react-native-skelo';
119
+ import { Avatar } from 'my-design-system';
120
+
121
+ Skelo.register({
122
+ name: 'Avatar',
123
+ component: Avatar,
124
+ strategy: (props, { primitives }) => (
125
+ <primitives.Circle size={props.size ?? 40} />
126
+ ),
127
+ });
21
128
  ```
22
129
 
23
- ## Status
130
+ ## API
131
+
132
+ ### `<Skeleton>` props
133
+
134
+ | Prop | Type | Default | Description |
135
+ |---|---|---|---|
136
+ | `loading` | `boolean` | — | Show skeleton (`true`) or real content (`false`) |
137
+ | `animation` | `'shimmer' \| 'pulse' \| 'none'` | `'shimmer'` | Animation style |
138
+ | `duration` | `number` | `1200` | Animation duration (ms) |
139
+ | `baseColor` / `highlightColor` | `string` | theme | Skeleton colors |
140
+ | `borderRadius` | `number` | `4` | Default corner radius |
141
+ | `deep` | `boolean` | `false` | Expand opaque components (experimental) |
142
+ | `styles` | `StyleSheet \| style[]` | — | Generate from styles instead of children |
143
+ | `excludeStyles` | `string[]` | — | Style keys to skip in `styles` mode |
144
+ | `accessibilityLabel` | `string` | `'Loading content'` | Screen-reader label |
145
+
146
+ Also exported: `withSkeleton`, `SkeletonIgnore`, `StyleSkeleton`, the primitives (`SkeletonBox`, `SkeletonText`, `SkeletonImage`, `SkeletonCircle`), and `Skelo` (plugin registry + `Skelo.fromStyles`).
147
+
148
+ ## How it works
149
+
150
+ - **Inline mode** — static traversal of the host-element tree (`React.Children` + `StyleSheet.flatten`).
151
+ - **`deep` mode** — a JS-only `react-reconciler` renderer renders the component off-screen to recover its real host tree + styles, then feeds the same skeleton renderer.
152
+ - Anything Skelo can't introspect (a custom component without `deep`, or native content) is measured and shown as a single size-matched block.
24
153
 
25
- This package name is reserved. The first public release is on its way.
154
+ ## `deep` mode caveats (experimental)
26
155
 
27
- - **Star / watch the repo** to get notified: https://github.com/shubhanshubb/react-native-skelo
28
- - 🐛 Issues & ideas: https://github.com/shubhanshubb/react-native-skelo/issues
156
+ `deep` renders your component offline to read its structure, which means:
29
157
 
30
- > **Not installable yet.** Installing this version gives you a placeholder only.
31
- > The real library ships as `v0.1.0`.
158
+ - **Mount effects run** during introspection a screen that fetches on mount may fetch twice. Prefer `deep` for presentational trees; register a plugin or provide a manual skeleton for effectful screens.
159
+ - **Renders outside your providers** components that require navigation/theme/redux context may fail to expand; Skelo catches this and falls back to a measured block.
160
+ - Only the **React host tree** is visible. `WebView`, `MapView`, `Video`, etc. render their content natively (outside React), so they can only become a single sized block.
32
161
 
33
- ## Planned for v0.1.0
162
+ ## Requirements
34
163
 
35
- - Automatic skeleton generation for standard components (View, Text, Image)
36
- - Shimmer & pulse animations powered by Reanimated 3
37
- - Zero-config out of the box, extensible via a plugin system
38
- - Full TypeScript support
164
+ - React Native New Architecture recommended (the shimmer's
165
+ `experimental_backgroundImage` gradient needs it)
166
+ - `react-native-reanimated` 3
167
+ - `react-reconciler` (optional, for `deep`) — must match your React version
39
168
 
40
- ---
169
+ ## License
41
170
 
42
- Made by [Shubhanshu Barnwal](https://shubhanshubb.dev) · MIT License
171
+ MIT © [Shubhanshu Barnwal](https://shubhanshubb.dev)
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Skelo = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _registry = require("./core/registry");
9
+ var _StyleSkeleton = require("./core/generator/StyleSkeleton");
10
+ var _defaults = require("./constants/defaults");
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ /**
13
+ * Global Skelo API for plugin management
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * import { Skelo } from 'react-native-skelo';
18
+ * import { Avatar } from 'my-ui-library';
19
+ *
20
+ * Skelo.register({
21
+ * name: 'Avatar',
22
+ * component: Avatar,
23
+ * strategy: (props, { primitives }) => {
24
+ * return <primitives.Circle size={props.size || 40} />;
25
+ * },
26
+ * });
27
+ * ```
28
+ */
29
+ const Skelo = exports.Skelo = {
30
+ /**
31
+ * Register a plugin
32
+ *
33
+ * @param plugin - Plugin configuration
34
+ */
35
+ register(plugin) {
36
+ _registry.registry.register(plugin);
37
+ },
38
+ /**
39
+ * Unregister a plugin
40
+ *
41
+ * @param component - Component type to unregister
42
+ */
43
+ unregister(component) {
44
+ _registry.registry.unregister(component);
45
+ },
46
+ /**
47
+ * Get plugin for component
48
+ *
49
+ * @param component - Component type
50
+ * @returns Plugin or undefined
51
+ */
52
+ getPlugin(component) {
53
+ return _registry.registry.getPlugin(component);
54
+ },
55
+ /**
56
+ * Check if plugin exists
57
+ *
58
+ * @param component - Component type
59
+ * @returns True if plugin is registered
60
+ */
61
+ hasPlugin(component) {
62
+ return _registry.registry.hasPlugin(component);
63
+ },
64
+ /**
65
+ * Get all plugins
66
+ *
67
+ * @returns Array of all registered plugins
68
+ */
69
+ getAllPlugins() {
70
+ return _registry.registry.getAllPlugins();
71
+ },
72
+ /**
73
+ * Clear all plugins (useful for testing)
74
+ */
75
+ clearPlugins() {
76
+ _registry.registry.clear();
77
+ },
78
+ /**
79
+ * Generate a skeleton element directly from a set of styles.
80
+ *
81
+ * @param styles - A `StyleSheet.create` object or an array of styles
82
+ * @param config - Optional animation/color overrides
83
+ * @returns A skeleton React element
84
+ *
85
+ * @example
86
+ * ```tsx
87
+ * {loading ? Skelo.fromStyles(styles) : <Screen />}
88
+ * ```
89
+ */
90
+ fromStyles(styles, config = {}) {
91
+ return /*#__PURE__*/_react.default.createElement(_StyleSkeleton.StyleSkeleton, {
92
+ styles,
93
+ config: {
94
+ ..._defaults.DEFAULT_CONFIG,
95
+ ...config
96
+ }
97
+ });
98
+ },
99
+ /**
100
+ * Library version
101
+ */
102
+ version: '0.1.0'
103
+ };
104
+ //# sourceMappingURL=Skelo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","_interopRequireDefault","require","_registry","_StyleSkeleton","_defaults","e","__esModule","default","Skelo","exports","register","plugin","registry","unregister","component","getPlugin","hasPlugin","getAllPlugins","clearPlugins","clear","fromStyles","styles","config","React","createElement","StyleSkeleton","DEFAULT_CONFIG","version"],"sourceRoot":"../../src","sources":["Skelo.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAAsD,SAAAD,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEtD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,KAAK,GAAAC,OAAA,CAAAD,KAAA,GAAG;EACnB;AACF;AACA;AACA;AACA;EACEE,QAAQA,CAAUC,MAAyB,EAAQ;IACjDC,kBAAQ,CAACF,QAAQ,CAACC,MAAM,CAAC;EAC3B,CAAC;EAED;AACF;AACA;AACA;AACA;EACEE,UAAUA,CAACC,SAAwB,EAAQ;IACzCF,kBAAQ,CAACC,UAAU,CAACC,SAAS,CAAC;EAChC,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;EACEC,SAASA,CAACD,SAAwB,EAA8B;IAC9D,OAAOF,kBAAQ,CAACG,SAAS,CAACD,SAAS,CAAC;EACtC,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;EACEE,SAASA,CAACF,SAAwB,EAAW;IAC3C,OAAOF,kBAAQ,CAACI,SAAS,CAACF,SAAS,CAAC;EACtC,CAAC;EAED;AACF;AACA;AACA;AACA;EACEG,aAAaA,CAAA,EAAqB;IAChC,OAAOL,kBAAQ,CAACK,aAAa,CAAC,CAAC;EACjC,CAAC;EAED;AACF;AACA;EACEC,YAAYA,CAAA,EAAS;IACnBN,kBAAQ,CAACO,KAAK,CAAC,CAAC;EAClB,CAAC;EAED;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEC,UAAUA,CAACC,MAAkB,EAAEC,MAA+B,GAAG,CAAC,CAAC,EAAgB;IACjF,oBAAOC,cAAK,CAACC,aAAa,CAACC,4BAAa,EAAE;MACxCJ,MAAM;MACNC,MAAM,EAAE;QAAE,GAAGI,wBAAc;QAAE,GAAGJ;MAAO;IACzC,CAAC,CAAC;EACJ,CAAC;EAED;AACF;AACA;EACEK,OAAO,EAAE;AACX,CAAC","ignoreList":[]}
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.AnimationWrapper = AnimationWrapper;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _ShimmerAnimation = require("./ShimmerAnimation");
10
+ var _PulseAnimation = require("./PulseAnimation");
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ /**
13
+ * Animation wrapper that selects the appropriate animation type
14
+ *
15
+ * Provides a unified interface for all skeleton animations:
16
+ * - shimmer: Left-to-right shimmer effect
17
+ * - pulse: Breathing/pulsing opacity
18
+ * - none: Static skeleton (no animation)
19
+ *
20
+ * @example
21
+ * ```tsx
22
+ * <AnimationWrapper
23
+ * animation="shimmer"
24
+ * width={200}
25
+ * height={20}
26
+ * />
27
+ * ```
28
+ */
29
+ function AnimationWrapper({
30
+ animation = 'shimmer',
31
+ width,
32
+ height,
33
+ baseColor = '#E1E9EE',
34
+ highlightColor = '#F2F8FC',
35
+ duration,
36
+ borderRadius = 4,
37
+ style,
38
+ children
39
+ }) {
40
+ // No animation - static skeleton
41
+ if (animation === 'none') {
42
+ return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
43
+ style: [{
44
+ width,
45
+ height,
46
+ borderRadius,
47
+ backgroundColor: baseColor
48
+ }, style]
49
+ }, children);
50
+ }
51
+
52
+ // Shimmer animation
53
+ if (animation === 'shimmer') {
54
+ return /*#__PURE__*/_react.default.createElement(_ShimmerAnimation.ShimmerAnimation, {
55
+ width: width,
56
+ height: height,
57
+ baseColor: baseColor,
58
+ highlightColor: highlightColor,
59
+ duration: duration ?? 1500,
60
+ borderRadius: borderRadius,
61
+ style: style
62
+ }, children);
63
+ }
64
+
65
+ // Pulse animation
66
+ return /*#__PURE__*/_react.default.createElement(_PulseAnimation.PulseAnimation, {
67
+ width: width,
68
+ height: height,
69
+ baseColor: baseColor,
70
+ highlightColor: highlightColor,
71
+ duration: duration ?? 1000,
72
+ borderRadius: borderRadius,
73
+ style: style
74
+ }, children);
75
+ }
76
+ //# sourceMappingURL=AnimationWrapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","_interopRequireDefault","require","_reactNative","_ShimmerAnimation","_PulseAnimation","e","__esModule","default","AnimationWrapper","animation","width","height","baseColor","highlightColor","duration","borderRadius","style","children","createElement","View","backgroundColor","ShimmerAnimation","PulseAnimation"],"sourceRoot":"../../../src","sources":["animations/AnimationWrapper.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;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Q,IAAI,IAAK;IAC3BC,YAAY,EAAEA,YAAa;IAC3BC,KAAK,EAAEA;EAAM,GAEZC,QACa,CAAC;AAErB","ignoreList":[]}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.PulseAnimation = PulseAnimation;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
10
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
11
+ // Breathing opacity loop on the UI thread with Reanimated.
12
+ function PulseAnimation({
13
+ width,
14
+ height,
15
+ baseColor = '#E1E9EE',
16
+ duration = 1000,
17
+ borderRadius = 4,
18
+ style,
19
+ children
20
+ }) {
21
+ const opacity = (0, _reactNativeReanimated.useSharedValue)(1);
22
+ (0, _react.useEffect)(() => {
23
+ opacity.value = (0, _reactNativeReanimated.withRepeat)((0, _reactNativeReanimated.withSequence)((0, _reactNativeReanimated.withTiming)(0.5, {
24
+ duration: duration / 2,
25
+ easing: _reactNativeReanimated.Easing.inOut(_reactNativeReanimated.Easing.ease)
26
+ }), (0, _reactNativeReanimated.withTiming)(1, {
27
+ duration: duration / 2,
28
+ easing: _reactNativeReanimated.Easing.inOut(_reactNativeReanimated.Easing.ease)
29
+ })), -1, false);
30
+ }, [duration, opacity]);
31
+ const animatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
32
+ 'worklet';
33
+
34
+ return {
35
+ opacity: opacity.value
36
+ };
37
+ }, []);
38
+ return /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
39
+ style: [styles.container, {
40
+ width,
41
+ height,
42
+ borderRadius,
43
+ backgroundColor: baseColor
44
+ }, animatedStyle, style]
45
+ }, children);
46
+ }
47
+ const styles = _reactNative.StyleSheet.create({
48
+ container: {
49
+ overflow: 'hidden'
50
+ }
51
+ });
52
+ //# sourceMappingURL=PulseAnimation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","PulseAnimation","width","height","baseColor","duration","borderRadius","style","children","opacity","useSharedValue","useEffect","value","withRepeat","withSequence","withTiming","easing","Easing","inOut","ease","animatedStyle","useAnimatedStyle","createElement","View","styles","container","backgroundColor","StyleSheet","create","overflow"],"sourceRoot":"../../../src","sources":["animations/PulseAnimation.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAH,uBAAA,CAAAC,OAAA;AAOiC,SAAAD,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,CAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,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d,QAAQ,EAAEI,OAAO,CAAC,CAAC;EAEvB,MAAMW,aAAa,GAAG,IAAAC,uCAAgB,EAAC,MAAM;IAC3C,SAAS;;IACT,OAAO;MAAEZ,OAAO,EAAEA,OAAO,CAACG;IAAM,CAAC;EACnC,CAAC,EAAE,EAAE,CAAC;EAEN,oBACEnC,MAAA,CAAAe,OAAA,CAAA8B,aAAA,CAACzC,sBAAA,CAAAW,OAAQ,CAAC+B,IAAI;IACZhB,KAAK,EAAE,CACLiB,MAAM,CAACC,SAAS,EAChB;MAAEvB,KAAK;MAAEC,MAAM;MAAEG,YAAY;MAAEoB,eAAe,EAAEtB;IAAU,CAAC,EAC3DgB,aAAa,EACbb,KAAK;EACL,GAEDC,QACY,CAAC;AAEpB;AAEA,MAAMgB,MAAM,GAAGG,uBAAU,CAACC,MAAM,CAAC;EAC/BH,SAAS,EAAE;IACTI,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ShimmerAnimation = ShimmerAnimation;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
10
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
11
+ // Shimmer with no gradient library: the sweeping overlay uses React Native's
12
+ // built-in `experimental_backgroundImage` CSS gradient (New Architecture),
13
+ // animated on the UI thread with Reanimated.
14
+ function ShimmerAnimation({
15
+ width,
16
+ height,
17
+ baseColor = '#E1E9EE',
18
+ highlightColor = '#F2F8FC',
19
+ duration = 1500,
20
+ borderRadius = 4,
21
+ style,
22
+ children
23
+ }) {
24
+ const progress = (0, _reactNativeReanimated.useSharedValue)(0);
25
+ const [measuredWidth, setMeasuredWidth] = (0, _react.useState)(0);
26
+ (0, _react.useEffect)(() => {
27
+ progress.value = (0, _reactNativeReanimated.withRepeat)((0, _reactNativeReanimated.withTiming)(1, {
28
+ duration,
29
+ easing: _reactNativeReanimated.Easing.linear
30
+ }), -1, false);
31
+ }, [duration, progress]);
32
+ const onLayout = event => {
33
+ const w = event.nativeEvent.layout.width;
34
+ setMeasuredWidth(prev => prev === w ? prev : w);
35
+ };
36
+ const containerWidth = typeof width === 'number' ? width : measuredWidth;
37
+ const animatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
38
+ 'worklet';
39
+
40
+ const translateX = (0, _reactNativeReanimated.interpolate)(progress.value, [0, 1], [-containerWidth, containerWidth]);
41
+ return {
42
+ transform: [{
43
+ translateX
44
+ }]
45
+ };
46
+ }, [containerWidth]);
47
+
48
+ // `experimental_backgroundImage` isn't in the ViewStyle types yet.
49
+ const gradientStyle = {
50
+ ..._reactNative.StyleSheet.absoluteFillObject,
51
+ experimental_backgroundImage: `linear-gradient(to right, ${baseColor}, ${highlightColor}, ${baseColor})`
52
+ };
53
+ return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
54
+ onLayout: onLayout,
55
+ style: [styles.container, {
56
+ width,
57
+ height,
58
+ borderRadius,
59
+ backgroundColor: baseColor
60
+ }, style]
61
+ }, /*#__PURE__*/_react.default.createElement(_reactNativeReanimated.default.View, {
62
+ pointerEvents: "none",
63
+ style: [_reactNative.StyleSheet.absoluteFill, animatedStyle]
64
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
65
+ style: gradientStyle
66
+ })), children);
67
+ }
68
+ const styles = _reactNative.StyleSheet.create({
69
+ container: {
70
+ overflow: 'hidden'
71
+ }
72
+ });
73
+ //# sourceMappingURL=ShimmerAnimation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeReanimated","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","ShimmerAnimation","width","height","baseColor","highlightColor","duration","borderRadius","style","children","progress","useSharedValue","measuredWidth","setMeasuredWidth","useState","useEffect","value","withRepeat","withTiming","easing","Easing","linear","onLayout","event","w","nativeEvent","layout","prev","containerWidth","animatedStyle","useAnimatedStyle","translateX","interpolate","transform","gradientStyle","StyleSheet","absoluteFillObject","experimental_backgroundImage","createElement","View","styles","container","backgroundColor","pointerEvents","absoluteFill","create","overflow"],"sourceRoot":"../../../src","sources":["animations/ShimmerAnimation.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAOA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,sBAAA,GAAAH,uBAAA,CAAAC,OAAA;AAOiC,SAAAD,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,CAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,G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EAAE;IACTK,QAAQ,EAAE;EACZ;AACF,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "AnimationWrapper", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _AnimationWrapper.AnimationWrapper;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "PulseAnimation", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _PulseAnimation.PulseAnimation;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "ShimmerAnimation", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _ShimmerAnimation.ShimmerAnimation;
22
+ }
23
+ });
24
+ var _ShimmerAnimation = require("./ShimmerAnimation");
25
+ var _PulseAnimation = require("./PulseAnimation");
26
+ var _AnimationWrapper = require("./AnimationWrapper");
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_ShimmerAnimation","require","_PulseAnimation","_AnimationWrapper"],"sourceRoot":"../../../src","sources":["animations/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA","ignoreList":[]}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.MeasuredBlock = MeasuredBlock;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _animations = require("../animations");
10
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
11
+ /**
12
+ * Renders an opaque (non-host) component hidden so it lays out at its real
13
+ * size, measures that size via `onLayout`, then overlays a shimmer block of
14
+ * exactly those dimensions.
15
+ *
16
+ * This is Skelo's runtime-measurement fallback: when the parser can't
17
+ * introspect a component (e.g. a user-defined function component), we can't
18
+ * know its internal View/Text/Image structure without native view-tree access,
19
+ * but we *can* render it off-screen and reproduce its footprint accurately.
20
+ *
21
+ * The result is a single, correctly-sized skeleton block rather than a
22
+ * misleading fixed-size placeholder.
23
+ */
24
+ function MeasuredBlock({
25
+ children,
26
+ config
27
+ }) {
28
+ const [size, setSize] = (0, _react.useState)(null);
29
+ const handleLayout = event => {
30
+ const {
31
+ width,
32
+ height
33
+ } = event.nativeEvent.layout;
34
+ setSize(prev => prev && prev.width === width && prev.height === height ? prev : {
35
+ width,
36
+ height
37
+ });
38
+ };
39
+ return /*#__PURE__*/_react.default.createElement(_reactNative.View, null, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
40
+ style: styles.hidden,
41
+ pointerEvents: "none",
42
+ importantForAccessibility: "no-hide-descendants",
43
+ accessibilityElementsHidden: true,
44
+ onLayout: handleLayout
45
+ }, children), size && size.width > 0 && size.height > 0 && /*#__PURE__*/_react.default.createElement(_reactNative.View, {
46
+ style: _reactNative.StyleSheet.absoluteFill,
47
+ pointerEvents: "none"
48
+ }, /*#__PURE__*/_react.default.createElement(_animations.AnimationWrapper, {
49
+ animation: config.animation,
50
+ width: size.width,
51
+ height: size.height,
52
+ baseColor: config.baseColor,
53
+ highlightColor: config.highlightColor,
54
+ duration: config.duration,
55
+ borderRadius: config.borderRadius
56
+ })));
57
+ }
58
+ const styles = _reactNative.StyleSheet.create({
59
+ hidden: {
60
+ opacity: 0
61
+ }
62
+ });
63
+ MeasuredBlock.displayName = 'Skeleton.MeasuredBlock';
64
+ //# sourceMappingURL=MeasuredBlock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_animations","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","MeasuredBlock","children","config","size","setSize","useState","handleLayout","event","width","height","nativeEvent","layout","prev","createElement","View","style","styles","hidden","pointerEvents","importantForAccessibility","accessibilityElementsHidden","onLayout","StyleSheet","absoluteFill","AnimationWrapper","animation","baseColor","highlightColor","duration","borderRadius","create","opacity","displayName"],"sourceRoot":"../../../src","sources":["components/MeasuredBlock.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AAGA,IAAAE,WAAA,GAAAF,OAAA;AAAiD,SAAAD,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,CAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU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