@oxy.so/bloom 6.0.0 → 6.2.0

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 (293) hide show
  1. package/README.md +1 -1
  2. package/docs/adoption-matrix.mdx +5 -3
  3. package/docs/chat-composer.mdx +5 -1
  4. package/docs/cover-header.mdx +56 -0
  5. package/docs/message-media.mdx +5 -0
  6. package/docs/sticker.mdx +64 -0
  7. package/lib/commonjs/ai-profile-card/AiProfileCard.js +186 -263
  8. package/lib/commonjs/ai-profile-card/AiProfileCard.js.map +1 -1
  9. package/lib/commonjs/chat-composer/SuggestionList.js +3 -1
  10. package/lib/commonjs/chat-composer/SuggestionList.js.map +1 -1
  11. package/lib/commonjs/chat-composer/SuggestionList.web.js +3 -1
  12. package/lib/commonjs/chat-composer/SuggestionList.web.js.map +1 -1
  13. package/lib/commonjs/chat-composer/create-suggestion-list.js +64 -10
  14. package/lib/commonjs/chat-composer/create-suggestion-list.js.map +1 -1
  15. package/lib/commonjs/chat-composer/messages.js +7 -0
  16. package/lib/commonjs/chat-composer/messages.js.map +1 -1
  17. package/lib/commonjs/cover-header/CoverHeader.js +83 -0
  18. package/lib/commonjs/cover-header/CoverHeader.js.map +1 -0
  19. package/lib/commonjs/cover-header/CoverImage.js +72 -0
  20. package/lib/commonjs/cover-header/CoverImage.js.map +1 -0
  21. package/lib/commonjs/cover-header/index.js +13 -0
  22. package/lib/commonjs/cover-header/index.js.map +1 -0
  23. package/lib/commonjs/cover-header/types.js +6 -0
  24. package/lib/commonjs/cover-header/types.js.map +1 -0
  25. package/lib/commonjs/index.js +972 -938
  26. package/lib/commonjs/index.js.map +1 -1
  27. package/lib/commonjs/index.web.js +982 -948
  28. package/lib/commonjs/index.web.js.map +1 -1
  29. package/lib/commonjs/locale/translations/ar.js +7 -0
  30. package/lib/commonjs/locale/translations/ar.js.map +1 -1
  31. package/lib/commonjs/locale/translations/bn.js +7 -0
  32. package/lib/commonjs/locale/translations/bn.js.map +1 -1
  33. package/lib/commonjs/locale/translations/ca.js +7 -0
  34. package/lib/commonjs/locale/translations/ca.js.map +1 -1
  35. package/lib/commonjs/locale/translations/de.js +7 -0
  36. package/lib/commonjs/locale/translations/de.js.map +1 -1
  37. package/lib/commonjs/locale/translations/es.js +7 -0
  38. package/lib/commonjs/locale/translations/es.js.map +1 -1
  39. package/lib/commonjs/locale/translations/fr.js +7 -0
  40. package/lib/commonjs/locale/translations/fr.js.map +1 -1
  41. package/lib/commonjs/locale/translations/hi.js +7 -0
  42. package/lib/commonjs/locale/translations/hi.js.map +1 -1
  43. package/lib/commonjs/locale/translations/id.js +7 -0
  44. package/lib/commonjs/locale/translations/id.js.map +1 -1
  45. package/lib/commonjs/locale/translations/it.js +7 -0
  46. package/lib/commonjs/locale/translations/it.js.map +1 -1
  47. package/lib/commonjs/locale/translations/ja.js +7 -0
  48. package/lib/commonjs/locale/translations/ja.js.map +1 -1
  49. package/lib/commonjs/locale/translations/pt.js +7 -0
  50. package/lib/commonjs/locale/translations/pt.js.map +1 -1
  51. package/lib/commonjs/locale/translations/ru.js +7 -0
  52. package/lib/commonjs/locale/translations/ru.js.map +1 -1
  53. package/lib/commonjs/locale/translations/tr.js +7 -0
  54. package/lib/commonjs/locale/translations/tr.js.map +1 -1
  55. package/lib/commonjs/locale/translations/zh.js +7 -0
  56. package/lib/commonjs/locale/translations/zh.js.map +1 -1
  57. package/lib/commonjs/message-media/StickerMessage.js +11 -2
  58. package/lib/commonjs/message-media/StickerMessage.js.map +1 -1
  59. package/lib/commonjs/sticker/Sticker.js +14 -0
  60. package/lib/commonjs/sticker/Sticker.js.map +1 -0
  61. package/lib/commonjs/sticker/Sticker.web.js +14 -0
  62. package/lib/commonjs/sticker/Sticker.web.js.map +1 -0
  63. package/lib/commonjs/sticker/create-sticker.js +118 -0
  64. package/lib/commonjs/sticker/create-sticker.js.map +1 -0
  65. package/lib/commonjs/sticker/index.js +26 -0
  66. package/lib/commonjs/sticker/index.js.map +1 -0
  67. package/lib/commonjs/sticker/index.web.js +26 -0
  68. package/lib/commonjs/sticker/index.web.js.map +1 -0
  69. package/lib/commonjs/sticker/lottie-module.js +97 -0
  70. package/lib/commonjs/sticker/lottie-module.js.map +1 -0
  71. package/lib/commonjs/sticker/lottie-module.web.js +96 -0
  72. package/lib/commonjs/sticker/lottie-module.web.js.map +1 -0
  73. package/lib/commonjs/sticker/types.js +6 -0
  74. package/lib/commonjs/sticker/types.js.map +1 -0
  75. package/lib/module/ai-profile-card/AiProfileCard.js +185 -262
  76. package/lib/module/ai-profile-card/AiProfileCard.js.map +1 -1
  77. package/lib/module/chat-composer/SuggestionList.js +3 -1
  78. package/lib/module/chat-composer/SuggestionList.js.map +1 -1
  79. package/lib/module/chat-composer/SuggestionList.web.js +3 -1
  80. package/lib/module/chat-composer/SuggestionList.web.js.map +1 -1
  81. package/lib/module/chat-composer/create-suggestion-list.js +64 -10
  82. package/lib/module/chat-composer/create-suggestion-list.js.map +1 -1
  83. package/lib/module/chat-composer/messages.js +7 -0
  84. package/lib/module/chat-composer/messages.js.map +1 -1
  85. package/lib/module/cover-header/CoverHeader.js +78 -0
  86. package/lib/module/cover-header/CoverHeader.js.map +1 -0
  87. package/lib/module/cover-header/CoverImage.js +68 -0
  88. package/lib/module/cover-header/CoverImage.js.map +1 -0
  89. package/lib/module/cover-header/index.js +4 -0
  90. package/lib/module/cover-header/index.js.map +1 -0
  91. package/lib/module/cover-header/types.js +4 -0
  92. package/lib/module/cover-header/types.js.map +1 -0
  93. package/lib/module/index.js +2 -0
  94. package/lib/module/index.js.map +1 -1
  95. package/lib/module/index.web.js +2 -0
  96. package/lib/module/index.web.js.map +1 -1
  97. package/lib/module/locale/translations/ar.js +7 -0
  98. package/lib/module/locale/translations/ar.js.map +1 -1
  99. package/lib/module/locale/translations/bn.js +7 -0
  100. package/lib/module/locale/translations/bn.js.map +1 -1
  101. package/lib/module/locale/translations/ca.js +7 -0
  102. package/lib/module/locale/translations/ca.js.map +1 -1
  103. package/lib/module/locale/translations/de.js +7 -0
  104. package/lib/module/locale/translations/de.js.map +1 -1
  105. package/lib/module/locale/translations/es.js +7 -0
  106. package/lib/module/locale/translations/es.js.map +1 -1
  107. package/lib/module/locale/translations/fr.js +7 -0
  108. package/lib/module/locale/translations/fr.js.map +1 -1
  109. package/lib/module/locale/translations/hi.js +7 -0
  110. package/lib/module/locale/translations/hi.js.map +1 -1
  111. package/lib/module/locale/translations/id.js +7 -0
  112. package/lib/module/locale/translations/id.js.map +1 -1
  113. package/lib/module/locale/translations/it.js +7 -0
  114. package/lib/module/locale/translations/it.js.map +1 -1
  115. package/lib/module/locale/translations/ja.js +7 -0
  116. package/lib/module/locale/translations/ja.js.map +1 -1
  117. package/lib/module/locale/translations/pt.js +7 -0
  118. package/lib/module/locale/translations/pt.js.map +1 -1
  119. package/lib/module/locale/translations/ru.js +7 -0
  120. package/lib/module/locale/translations/ru.js.map +1 -1
  121. package/lib/module/locale/translations/tr.js +7 -0
  122. package/lib/module/locale/translations/tr.js.map +1 -1
  123. package/lib/module/locale/translations/zh.js +7 -0
  124. package/lib/module/locale/translations/zh.js.map +1 -1
  125. package/lib/module/message-media/StickerMessage.js +11 -2
  126. package/lib/module/message-media/StickerMessage.js.map +1 -1
  127. package/lib/module/sticker/Sticker.js +11 -0
  128. package/lib/module/sticker/Sticker.js.map +1 -0
  129. package/lib/module/sticker/Sticker.web.js +11 -0
  130. package/lib/module/sticker/Sticker.web.js.map +1 -0
  131. package/lib/module/sticker/create-sticker.js +113 -0
  132. package/lib/module/sticker/create-sticker.js.map +1 -0
  133. package/lib/module/sticker/index.js +5 -0
  134. package/lib/module/sticker/index.js.map +1 -0
  135. package/lib/module/sticker/index.web.js +10 -0
  136. package/lib/module/sticker/index.web.js.map +1 -0
  137. package/lib/module/sticker/lottie-module.js +90 -0
  138. package/lib/module/sticker/lottie-module.js.map +1 -0
  139. package/lib/module/sticker/lottie-module.web.js +88 -0
  140. package/lib/module/sticker/lottie-module.web.js.map +1 -0
  141. package/lib/module/sticker/types.js +4 -0
  142. package/lib/module/sticker/types.js.map +1 -0
  143. package/lib/typescript/commonjs/ai-profile-card/AiProfileCard.d.ts.map +1 -1
  144. package/lib/typescript/commonjs/chat-composer/SuggestionList.d.ts +1 -1
  145. package/lib/typescript/commonjs/chat-composer/SuggestionList.d.ts.map +1 -1
  146. package/lib/typescript/commonjs/chat-composer/SuggestionList.web.d.ts +1 -1
  147. package/lib/typescript/commonjs/chat-composer/SuggestionList.web.d.ts.map +1 -1
  148. package/lib/typescript/commonjs/chat-composer/create-suggestion-list.d.ts +4 -2
  149. package/lib/typescript/commonjs/chat-composer/create-suggestion-list.d.ts.map +1 -1
  150. package/lib/typescript/commonjs/chat-composer/messages.d.ts +6 -0
  151. package/lib/typescript/commonjs/chat-composer/messages.d.ts.map +1 -1
  152. package/lib/typescript/commonjs/chat-composer/types.d.ts +17 -0
  153. package/lib/typescript/commonjs/chat-composer/types.d.ts.map +1 -1
  154. package/lib/typescript/commonjs/cover-header/CoverHeader.d.ts +21 -0
  155. package/lib/typescript/commonjs/cover-header/CoverHeader.d.ts.map +1 -0
  156. package/lib/typescript/commonjs/cover-header/CoverImage.d.ts +11 -0
  157. package/lib/typescript/commonjs/cover-header/CoverImage.d.ts.map +1 -0
  158. package/lib/typescript/commonjs/cover-header/index.d.ts +3 -0
  159. package/lib/typescript/commonjs/cover-header/index.d.ts.map +1 -0
  160. package/lib/typescript/commonjs/cover-header/types.d.ts +33 -0
  161. package/lib/typescript/commonjs/cover-header/types.d.ts.map +1 -0
  162. package/lib/typescript/commonjs/index.d.ts +3 -0
  163. package/lib/typescript/commonjs/index.d.ts.map +1 -1
  164. package/lib/typescript/commonjs/index.web.d.ts +3 -0
  165. package/lib/typescript/commonjs/index.web.d.ts.map +1 -1
  166. package/lib/typescript/commonjs/locale/translations/ar.d.ts.map +1 -1
  167. package/lib/typescript/commonjs/locale/translations/bn.d.ts.map +1 -1
  168. package/lib/typescript/commonjs/locale/translations/ca.d.ts.map +1 -1
  169. package/lib/typescript/commonjs/locale/translations/de.d.ts.map +1 -1
  170. package/lib/typescript/commonjs/locale/translations/es.d.ts.map +1 -1
  171. package/lib/typescript/commonjs/locale/translations/fr.d.ts.map +1 -1
  172. package/lib/typescript/commonjs/locale/translations/hi.d.ts.map +1 -1
  173. package/lib/typescript/commonjs/locale/translations/id.d.ts.map +1 -1
  174. package/lib/typescript/commonjs/locale/translations/it.d.ts.map +1 -1
  175. package/lib/typescript/commonjs/locale/translations/ja.d.ts.map +1 -1
  176. package/lib/typescript/commonjs/locale/translations/pt.d.ts.map +1 -1
  177. package/lib/typescript/commonjs/locale/translations/ru.d.ts.map +1 -1
  178. package/lib/typescript/commonjs/locale/translations/tr.d.ts.map +1 -1
  179. package/lib/typescript/commonjs/locale/translations/zh.d.ts.map +1 -1
  180. package/lib/typescript/commonjs/message-media/StickerMessage.d.ts +3 -2
  181. package/lib/typescript/commonjs/message-media/StickerMessage.d.ts.map +1 -1
  182. package/lib/typescript/commonjs/message-media/types.d.ts +3 -0
  183. package/lib/typescript/commonjs/message-media/types.d.ts.map +1 -1
  184. package/lib/typescript/commonjs/sticker/Sticker.d.ts +3 -0
  185. package/lib/typescript/commonjs/sticker/Sticker.d.ts.map +1 -0
  186. package/lib/typescript/commonjs/sticker/Sticker.web.d.ts +3 -0
  187. package/lib/typescript/commonjs/sticker/Sticker.web.d.ts.map +1 -0
  188. package/lib/typescript/commonjs/sticker/create-sticker.d.ts +23 -0
  189. package/lib/typescript/commonjs/sticker/create-sticker.d.ts.map +1 -0
  190. package/lib/typescript/commonjs/sticker/index.d.ts +4 -0
  191. package/lib/typescript/commonjs/sticker/index.d.ts.map +1 -0
  192. package/lib/typescript/commonjs/sticker/index.web.d.ts +4 -0
  193. package/lib/typescript/commonjs/sticker/index.web.d.ts.map +1 -0
  194. package/lib/typescript/commonjs/sticker/lottie-module.d.ts +23 -0
  195. package/lib/typescript/commonjs/sticker/lottie-module.d.ts.map +1 -0
  196. package/lib/typescript/commonjs/sticker/lottie-module.web.d.ts +18 -0
  197. package/lib/typescript/commonjs/sticker/lottie-module.web.d.ts.map +1 -0
  198. package/lib/typescript/commonjs/sticker/types.d.ts +43 -0
  199. package/lib/typescript/commonjs/sticker/types.d.ts.map +1 -0
  200. package/lib/typescript/module/ai-profile-card/AiProfileCard.d.ts.map +1 -1
  201. package/lib/typescript/module/chat-composer/SuggestionList.d.ts +1 -1
  202. package/lib/typescript/module/chat-composer/SuggestionList.d.ts.map +1 -1
  203. package/lib/typescript/module/chat-composer/SuggestionList.web.d.ts +1 -1
  204. package/lib/typescript/module/chat-composer/SuggestionList.web.d.ts.map +1 -1
  205. package/lib/typescript/module/chat-composer/create-suggestion-list.d.ts +4 -2
  206. package/lib/typescript/module/chat-composer/create-suggestion-list.d.ts.map +1 -1
  207. package/lib/typescript/module/chat-composer/messages.d.ts +6 -0
  208. package/lib/typescript/module/chat-composer/messages.d.ts.map +1 -1
  209. package/lib/typescript/module/chat-composer/types.d.ts +17 -0
  210. package/lib/typescript/module/chat-composer/types.d.ts.map +1 -1
  211. package/lib/typescript/module/cover-header/CoverHeader.d.ts +21 -0
  212. package/lib/typescript/module/cover-header/CoverHeader.d.ts.map +1 -0
  213. package/lib/typescript/module/cover-header/CoverImage.d.ts +11 -0
  214. package/lib/typescript/module/cover-header/CoverImage.d.ts.map +1 -0
  215. package/lib/typescript/module/cover-header/index.d.ts +3 -0
  216. package/lib/typescript/module/cover-header/index.d.ts.map +1 -0
  217. package/lib/typescript/module/cover-header/types.d.ts +33 -0
  218. package/lib/typescript/module/cover-header/types.d.ts.map +1 -0
  219. package/lib/typescript/module/index.d.ts +3 -0
  220. package/lib/typescript/module/index.d.ts.map +1 -1
  221. package/lib/typescript/module/index.web.d.ts +3 -0
  222. package/lib/typescript/module/index.web.d.ts.map +1 -1
  223. package/lib/typescript/module/locale/translations/ar.d.ts.map +1 -1
  224. package/lib/typescript/module/locale/translations/bn.d.ts.map +1 -1
  225. package/lib/typescript/module/locale/translations/ca.d.ts.map +1 -1
  226. package/lib/typescript/module/locale/translations/de.d.ts.map +1 -1
  227. package/lib/typescript/module/locale/translations/es.d.ts.map +1 -1
  228. package/lib/typescript/module/locale/translations/fr.d.ts.map +1 -1
  229. package/lib/typescript/module/locale/translations/hi.d.ts.map +1 -1
  230. package/lib/typescript/module/locale/translations/id.d.ts.map +1 -1
  231. package/lib/typescript/module/locale/translations/it.d.ts.map +1 -1
  232. package/lib/typescript/module/locale/translations/ja.d.ts.map +1 -1
  233. package/lib/typescript/module/locale/translations/pt.d.ts.map +1 -1
  234. package/lib/typescript/module/locale/translations/ru.d.ts.map +1 -1
  235. package/lib/typescript/module/locale/translations/tr.d.ts.map +1 -1
  236. package/lib/typescript/module/locale/translations/zh.d.ts.map +1 -1
  237. package/lib/typescript/module/message-media/StickerMessage.d.ts +3 -2
  238. package/lib/typescript/module/message-media/StickerMessage.d.ts.map +1 -1
  239. package/lib/typescript/module/message-media/types.d.ts +3 -0
  240. package/lib/typescript/module/message-media/types.d.ts.map +1 -1
  241. package/lib/typescript/module/sticker/Sticker.d.ts +3 -0
  242. package/lib/typescript/module/sticker/Sticker.d.ts.map +1 -0
  243. package/lib/typescript/module/sticker/Sticker.web.d.ts +3 -0
  244. package/lib/typescript/module/sticker/Sticker.web.d.ts.map +1 -0
  245. package/lib/typescript/module/sticker/create-sticker.d.ts +23 -0
  246. package/lib/typescript/module/sticker/create-sticker.d.ts.map +1 -0
  247. package/lib/typescript/module/sticker/index.d.ts +4 -0
  248. package/lib/typescript/module/sticker/index.d.ts.map +1 -0
  249. package/lib/typescript/module/sticker/index.web.d.ts +4 -0
  250. package/lib/typescript/module/sticker/index.web.d.ts.map +1 -0
  251. package/lib/typescript/module/sticker/lottie-module.d.ts +23 -0
  252. package/lib/typescript/module/sticker/lottie-module.d.ts.map +1 -0
  253. package/lib/typescript/module/sticker/lottie-module.web.d.ts +18 -0
  254. package/lib/typescript/module/sticker/lottie-module.web.d.ts.map +1 -0
  255. package/lib/typescript/module/sticker/types.d.ts +43 -0
  256. package/lib/typescript/module/sticker/types.d.ts.map +1 -0
  257. package/package.json +48 -1
  258. package/src/ai-profile-card/AiProfileCard.tsx +159 -241
  259. package/src/chat-composer/SuggestionList.tsx +2 -1
  260. package/src/chat-composer/SuggestionList.web.tsx +2 -1
  261. package/src/chat-composer/create-suggestion-list.tsx +54 -8
  262. package/src/chat-composer/messages.ts +9 -0
  263. package/src/chat-composer/types.ts +17 -0
  264. package/src/cover-header/CoverHeader.tsx +75 -0
  265. package/src/cover-header/CoverImage.tsx +60 -0
  266. package/src/cover-header/index.ts +3 -0
  267. package/src/cover-header/types.ts +30 -0
  268. package/src/index.ts +3 -0
  269. package/src/index.web.ts +3 -0
  270. package/src/locale/translations/ar.ts +3 -0
  271. package/src/locale/translations/bn.ts +3 -0
  272. package/src/locale/translations/ca.ts +3 -0
  273. package/src/locale/translations/de.ts +3 -0
  274. package/src/locale/translations/es.ts +3 -0
  275. package/src/locale/translations/fr.ts +3 -0
  276. package/src/locale/translations/hi.ts +3 -0
  277. package/src/locale/translations/id.ts +3 -0
  278. package/src/locale/translations/it.ts +3 -0
  279. package/src/locale/translations/ja.ts +3 -0
  280. package/src/locale/translations/pt.ts +3 -0
  281. package/src/locale/translations/ru.ts +3 -0
  282. package/src/locale/translations/tr.ts +3 -0
  283. package/src/locale/translations/zh.ts +3 -0
  284. package/src/message-media/StickerMessage.tsx +21 -8
  285. package/src/message-media/types.ts +3 -0
  286. package/src/sticker/Sticker.tsx +5 -0
  287. package/src/sticker/Sticker.web.tsx +5 -0
  288. package/src/sticker/create-sticker.tsx +129 -0
  289. package/src/sticker/index.ts +3 -0
  290. package/src/sticker/index.web.ts +8 -0
  291. package/src/sticker/lottie-module.ts +109 -0
  292. package/src/sticker/lottie-module.web.ts +107 -0
  293. package/src/sticker/types.ts +45 -0
@@ -0,0 +1,109 @@
1
+ /**
2
+ * The optional-peer boundary for the NATIVE Lottie player, `lottie-react-native`.
3
+ *
4
+ * Same contract as `media-flight/expo-video-module.ts`, and for the same reason:
5
+ * Bloom ships no native code, so an app that shows no animated sticker must not
6
+ * be made to install a native module. The `require` is a string literal as a
7
+ * direct statement of a `try` block — the one shape Metro collects as an
8
+ * optional dependency — and the `typeof require` guard stays OUTSIDE the try.
9
+ *
10
+ * Whatever player loads is adapted to {@link LottiePlayerProps}, so `Sticker`
11
+ * drives the native and the web player (`lottie-module.web.ts`) the same way.
12
+ */
13
+ import { createElement, useEffect, useRef, type ComponentType } from 'react';
14
+ import type { StyleProp, ViewStyle } from 'react-native';
15
+
16
+ import type { LottiePlayerProps } from './types';
17
+
18
+ declare const require: (moduleName: string) => unknown;
19
+
20
+ /** The slice of `lottie-react-native`'s `LottieView` Bloom depends on. */
21
+ interface LottieViewLikeProps {
22
+ source: { uri: string };
23
+ autoPlay?: boolean;
24
+ loop?: boolean;
25
+ resizeMode?: 'contain';
26
+ onAnimationLoaded?: () => void;
27
+ onAnimationFailure?: (error: string) => void;
28
+ style?: StyleProp<ViewStyle>;
29
+ }
30
+
31
+ interface LottieViewHandle {
32
+ pause(): void;
33
+ resume(): void;
34
+ }
35
+
36
+ type LottieViewLike = ComponentType<LottieViewLikeProps & { ref?: unknown }>;
37
+
38
+ let providedPlayer: ComponentType<LottiePlayerProps> | null | undefined;
39
+ let loadedPlayer: ComponentType<LottiePlayerProps> | null | undefined;
40
+ let hasWarned = false;
41
+
42
+ /** Tests (and an app with its own build of the player) hand one in here. */
43
+ export function provideLottiePlayer(player: ComponentType<LottiePlayerProps> | null): void {
44
+ providedPlayer = player;
45
+ }
46
+
47
+ /** Forget the loaded player — for tests. */
48
+ export function resetLottiePlayer(): void {
49
+ providedPlayer = undefined;
50
+ loadedPlayer = undefined;
51
+ hasWarned = false;
52
+ }
53
+
54
+ function isComponent(candidate: unknown): candidate is LottieViewLike {
55
+ if (typeof candidate === 'function') return true;
56
+ return typeof candidate === 'object' && candidate !== null && '$$typeof' in candidate;
57
+ }
58
+
59
+ function adapt(LottieView: LottieViewLike): ComponentType<LottiePlayerProps> {
60
+ function NativeLottiePlayer({ uri, loop, paused, onLoad, onError, style }: LottiePlayerProps) {
61
+ const ref = useRef<LottieViewHandle | null>(null);
62
+ useEffect(() => {
63
+ if (paused) ref.current?.pause();
64
+ else ref.current?.resume();
65
+ }, [paused]);
66
+ return createElement(LottieView, {
67
+ ref,
68
+ source: { uri },
69
+ autoPlay: !paused,
70
+ loop,
71
+ resizeMode: 'contain',
72
+ onAnimationLoaded: onLoad,
73
+ onAnimationFailure: onError,
74
+ style,
75
+ });
76
+ }
77
+ return NativeLottiePlayer;
78
+ }
79
+
80
+ /** The native player, adapted, or `null` when `lottie-react-native` is not installed. */
81
+ export function loadLottiePlayer(): ComponentType<LottiePlayerProps> | null {
82
+ if (providedPlayer !== undefined && providedPlayer !== null) return providedPlayer;
83
+ if (loadedPlayer !== undefined) return loadedPlayer;
84
+ loadedPlayer = null;
85
+
86
+ if (typeof require === 'undefined') return loadedPlayer;
87
+
88
+ try {
89
+ const loaded = require('lottie-react-native') as { default?: unknown } | null | undefined;
90
+ const view = isComponent(loaded) ? loaded : loaded?.default;
91
+ if (isComponent(view)) loadedPlayer = adapt(view);
92
+ } catch {
93
+ loadedPlayer = null;
94
+ }
95
+ return loadedPlayer;
96
+ }
97
+
98
+ /** One dev warning per module lifetime: a still sticker looks like a working one. */
99
+ export function warnLottieUnavailable(): void {
100
+ if (process.env.NODE_ENV === 'production' || hasWarned) return;
101
+ hasWarned = true;
102
+ // eslint-disable-next-line no-console
103
+ console.warn(
104
+ '[Bloom] An animated Sticker fell back to its still image: the optional peer ' +
105
+ '`lottie-react-native` could not be loaded. Install it (`npx expo install ' +
106
+ 'lottie-react-native`) to animate stickers.',
107
+ );
108
+ }
109
+
@@ -0,0 +1,107 @@
1
+ /**
2
+ * The optional-peer boundary for the WEB Lottie player,
3
+ * `@lottiefiles/dotlottie-react` — the web half of `lottie-module.ts`, with the
4
+ * same loading contract and the same adapted surface.
5
+ *
6
+ * dotLottie draws with ThorVG compiled to WebAssembly, which plays both `.lottie`
7
+ * archives and plain Lottie JSON, and exposes its instance through a ref
8
+ * callback rather than props: load, failure and pause all go through it.
9
+ */
10
+ import { createElement, useEffect, useRef, type ComponentType } from 'react';
11
+
12
+ import type { LottiePlayerProps } from './types';
13
+
14
+ declare const require: (moduleName: string) => unknown;
15
+
16
+ interface DotLottieInstance {
17
+ play(): void;
18
+ pause(): void;
19
+ addEventListener(event: 'load' | 'loadError', listener: () => void): void;
20
+ removeEventListener(event: 'load' | 'loadError', listener: () => void): void;
21
+ }
22
+
23
+ interface DotLottieReactLikeProps {
24
+ src: string;
25
+ autoplay?: boolean;
26
+ loop?: boolean;
27
+ dotLottieRefCallback?: (instance: DotLottieInstance | null) => void;
28
+ style?: unknown;
29
+ }
30
+
31
+ type DotLottieReactLike = ComponentType<DotLottieReactLikeProps>;
32
+
33
+ let providedPlayer: ComponentType<LottiePlayerProps> | null | undefined;
34
+ let loadedPlayer: ComponentType<LottiePlayerProps> | null | undefined;
35
+ let hasWarned = false;
36
+
37
+ export function provideLottiePlayer(player: ComponentType<LottiePlayerProps> | null): void {
38
+ providedPlayer = player;
39
+ }
40
+
41
+ /** Forget the loaded player — for tests. */
42
+ export function resetLottiePlayer(): void {
43
+ providedPlayer = undefined;
44
+ loadedPlayer = undefined;
45
+ hasWarned = false;
46
+ }
47
+
48
+ function isComponent(candidate: unknown): candidate is DotLottieReactLike {
49
+ if (typeof candidate === 'function') return true;
50
+ return typeof candidate === 'object' && candidate !== null && '$$typeof' in candidate;
51
+ }
52
+
53
+ function adapt(DotLottieReact: DotLottieReactLike): ComponentType<LottiePlayerProps> {
54
+ function WebLottiePlayer({ uri, loop, paused, onLoad, onError, style }: LottiePlayerProps) {
55
+ const instance = useRef<DotLottieInstance | null>(null);
56
+ const callbacks = useRef({ onLoad, onError });
57
+ callbacks.current = { onLoad, onError };
58
+
59
+ useEffect(() => {
60
+ if (paused) instance.current?.pause();
61
+ else instance.current?.play();
62
+ }, [paused]);
63
+
64
+ return createElement(DotLottieReact, {
65
+ src: uri,
66
+ autoplay: !paused,
67
+ loop,
68
+ style,
69
+ dotLottieRefCallback: (next) => {
70
+ if (instance.current === next) return;
71
+ instance.current = next;
72
+ if (!next) return;
73
+ next.addEventListener('load', () => callbacks.current.onLoad?.());
74
+ next.addEventListener('loadError', () => callbacks.current.onError?.('load failed'));
75
+ },
76
+ });
77
+ }
78
+ return WebLottiePlayer;
79
+ }
80
+
81
+ /** The web player, adapted, or `null` when `@lottiefiles/dotlottie-react` is not installed. */
82
+ export function loadLottiePlayer(): ComponentType<LottiePlayerProps> | null {
83
+ if (providedPlayer !== undefined && providedPlayer !== null) return providedPlayer;
84
+ if (loadedPlayer !== undefined) return loadedPlayer;
85
+ loadedPlayer = null;
86
+
87
+ if (typeof require === 'undefined') return loadedPlayer;
88
+
89
+ try {
90
+ const loaded = require('@lottiefiles/dotlottie-react') as { DotLottieReact?: unknown } | null | undefined;
91
+ if (isComponent(loaded?.DotLottieReact)) loadedPlayer = adapt(loaded.DotLottieReact);
92
+ } catch {
93
+ loadedPlayer = null;
94
+ }
95
+ return loadedPlayer;
96
+ }
97
+
98
+ export function warnLottieUnavailable(): void {
99
+ if (process.env.NODE_ENV === 'production' || hasWarned) return;
100
+ hasWarned = true;
101
+ // eslint-disable-next-line no-console
102
+ console.warn(
103
+ '[Bloom] An animated Sticker fell back to its still image: the optional peer ' +
104
+ '`@lottiefiles/dotlottie-react` could not be loaded. Install it to animate ' +
105
+ 'stickers on the web.',
106
+ );
107
+ }
@@ -0,0 +1,45 @@
1
+ import type { StyleProp, ViewStyle } from 'react-native';
2
+
3
+ import type { MessageMediaSource } from '../message-media/types';
4
+
5
+ export interface StickerProps {
6
+ /**
7
+ * URL of the Lottie animation (JSON or `.lottie`). Omit it for a still
8
+ * sticker; the `fallback` is then the sticker.
9
+ */
10
+ animation?: string;
11
+ /**
12
+ * The still image of the same sticker. Shown while the animation loads, when
13
+ * it cannot play (no Lottie player installed, the file failed), and always
14
+ * when the person asked for reduced motion.
15
+ */
16
+ fallback: MessageMediaSource;
17
+ /** Square edge. Default 128. */
18
+ size?: number;
19
+ /** Default true. */
20
+ loop?: boolean;
21
+ /** Hold the current frame — e.g. while the sticker is scrolled out of view. */
22
+ paused?: boolean;
23
+ /**
24
+ * A sticker IS its meaning; with no name it announces "Sticker" and conveys
25
+ * nothing. Pass what the pack author gave it — its emoji or its word.
26
+ */
27
+ accessibilityLabel?: string;
28
+ /**
29
+ * Hide it from assistive technology because its container already names it —
30
+ * `StickerMessage` does, on its pressable. Default false.
31
+ */
32
+ decorative?: boolean;
33
+ style?: StyleProp<ViewStyle>;
34
+ testID?: string;
35
+ }
36
+
37
+ /** What `Sticker` needs from a Lottie player, whichever platform supplies it. */
38
+ export interface LottiePlayerProps {
39
+ uri: string;
40
+ loop: boolean;
41
+ paused: boolean;
42
+ onLoad?: () => void;
43
+ onError?: (error: string) => void;
44
+ style?: StyleProp<ViewStyle>;
45
+ }