@cometchat/skills 4.0.0 → 4.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 (258) hide show
  1. package/README.md +42 -2
  2. package/bin/install.js +448 -57
  3. package/package.json +1 -1
  4. package/skills/cometchat/SKILL.md +337 -80
  5. package/skills/cometchat-a11y/SKILL.md +476 -0
  6. package/skills/cometchat-android-v5/SKILL.md +1 -1
  7. package/skills/cometchat-android-v5-calls/SKILL.md +413 -0
  8. package/skills/cometchat-android-v5-calls/references/README.md +53 -0
  9. package/skills/cometchat-android-v5-calls/references/add-calls-to-existing-chat.md +195 -0
  10. package/skills/cometchat-android-v5-calls/references/audio-controls.md +91 -0
  11. package/skills/cometchat-android-v5-calls/references/background-handling.md +168 -0
  12. package/skills/cometchat-android-v5-calls/references/call-layouts.md +123 -0
  13. package/skills/cometchat-android-v5-calls/references/call-logs.md +113 -0
  14. package/skills/cometchat-android-v5-calls/references/call-session.md +274 -0
  15. package/skills/cometchat-android-v5-calls/references/custom-ui.md +150 -0
  16. package/skills/cometchat-android-v5-calls/references/event-listeners.md +123 -0
  17. package/skills/cometchat-android-v5-calls/references/group-calls.md +205 -0
  18. package/skills/cometchat-android-v5-calls/references/idle-timeout.md +111 -0
  19. package/skills/cometchat-android-v5-calls/references/in-call-chat.md +134 -0
  20. package/skills/cometchat-android-v5-calls/references/join-session.md +120 -0
  21. package/skills/cometchat-android-v5-calls/references/migration-v4-to-v5.md +206 -0
  22. package/skills/cometchat-android-v5-calls/references/participant-management.md +110 -0
  23. package/skills/cometchat-android-v5-calls/references/picture-in-picture.md +106 -0
  24. package/skills/cometchat-android-v5-calls/references/raise-hand.md +242 -0
  25. package/skills/cometchat-android-v5-calls/references/recording.md +101 -0
  26. package/skills/cometchat-android-v5-calls/references/ringing-integration.md +152 -0
  27. package/skills/cometchat-android-v5-calls/references/screen-sharing.md +82 -0
  28. package/skills/cometchat-android-v5-calls/references/server-fcm-voip.md +215 -0
  29. package/skills/cometchat-android-v5-calls/references/session-settings.md +121 -0
  30. package/skills/cometchat-android-v5-calls/references/setup.md +137 -0
  31. package/skills/cometchat-android-v5-calls/references/share-invite.md +151 -0
  32. package/skills/cometchat-android-v5-calls/references/video-controls.md +87 -0
  33. package/skills/cometchat-android-v5-calls/references/voip-calling.md +526 -0
  34. package/skills/cometchat-android-v5-components/SKILL.md +1 -1
  35. package/skills/cometchat-android-v5-core/SKILL.md +1 -1
  36. package/skills/cometchat-android-v5-customization/SKILL.md +1 -1
  37. package/skills/cometchat-android-v5-extensions/SKILL.md +1 -1
  38. package/skills/cometchat-android-v5-features/SKILL.md +1 -1
  39. package/skills/cometchat-android-v5-placement/SKILL.md +1 -1
  40. package/skills/cometchat-android-v5-production/SKILL.md +1 -1
  41. package/skills/cometchat-android-v5-push/SKILL.md +1 -1
  42. package/skills/cometchat-android-v5-testing/SKILL.md +1 -1
  43. package/skills/cometchat-android-v5-theming/SKILL.md +1 -1
  44. package/skills/cometchat-android-v5-troubleshooting/SKILL.md +1 -1
  45. package/skills/cometchat-android-v6/SKILL.md +1 -1
  46. package/skills/cometchat-android-v6-builder-settings/SKILL.md +1 -1
  47. package/skills/cometchat-android-v6-calls/SKILL.md +375 -0
  48. package/skills/cometchat-android-v6-calls/references/add-calls-to-existing-chat.md +97 -0
  49. package/skills/cometchat-android-v6-calls/references/call-layouts.md +91 -0
  50. package/skills/cometchat-android-v6-calls/references/call-session.md +163 -0
  51. package/skills/cometchat-android-v6-calls/references/device-management.md +171 -0
  52. package/skills/cometchat-android-v6-calls/references/group-calls.md +191 -0
  53. package/skills/cometchat-android-v6-calls/references/idle-timeout.md +107 -0
  54. package/skills/cometchat-android-v6-calls/references/in-call-chat.md +136 -0
  55. package/skills/cometchat-android-v6-calls/references/raise-hand.md +186 -0
  56. package/skills/cometchat-android-v6-calls/references/ringing-integration.md +176 -0
  57. package/skills/cometchat-android-v6-calls/references/server-fcm-voip.md +127 -0
  58. package/skills/cometchat-android-v6-calls/references/share-invite.md +105 -0
  59. package/skills/cometchat-android-v6-compose-components/SKILL.md +2 -2
  60. package/skills/cometchat-android-v6-compose-customization/SKILL.md +1 -1
  61. package/skills/cometchat-android-v6-compose-placement/SKILL.md +1 -1
  62. package/skills/cometchat-android-v6-compose-theming/SKILL.md +1 -1
  63. package/skills/cometchat-android-v6-core/SKILL.md +1 -1
  64. package/skills/cometchat-android-v6-events/SKILL.md +1 -1
  65. package/skills/cometchat-android-v6-extensions/SKILL.md +1 -1
  66. package/skills/cometchat-android-v6-features/SKILL.md +1 -1
  67. package/skills/cometchat-android-v6-kotlin-components/SKILL.md +1 -1
  68. package/skills/cometchat-android-v6-kotlin-customization/SKILL.md +1 -1
  69. package/skills/cometchat-android-v6-kotlin-placement/SKILL.md +1 -1
  70. package/skills/cometchat-android-v6-kotlin-theming/SKILL.md +1 -1
  71. package/skills/cometchat-android-v6-migration/SKILL.md +398 -0
  72. package/skills/cometchat-android-v6-production/SKILL.md +1 -1
  73. package/skills/cometchat-android-v6-push/SKILL.md +1 -1
  74. package/skills/cometchat-android-v6-testing/SKILL.md +1 -1
  75. package/skills/cometchat-android-v6-troubleshooting/SKILL.md +1 -1
  76. package/skills/cometchat-angular-calls/SKILL.md +511 -0
  77. package/skills/cometchat-angular-calls/references/add-calls-to-existing-chat.md +95 -0
  78. package/skills/cometchat-angular-calls/references/call-layouts.md +106 -0
  79. package/skills/cometchat-angular-calls/references/call-session.md +167 -0
  80. package/skills/cometchat-angular-calls/references/custom-ui.md +231 -0
  81. package/skills/cometchat-angular-calls/references/device-management.md +135 -0
  82. package/skills/cometchat-angular-calls/references/group-calls.md +412 -0
  83. package/skills/cometchat-angular-calls/references/idle-timeout.md +145 -0
  84. package/skills/cometchat-angular-calls/references/in-call-chat.md +148 -0
  85. package/skills/cometchat-angular-calls/references/lazy-loading-pitfalls.md +205 -0
  86. package/skills/cometchat-angular-calls/references/migration-v4-to-v5.md +53 -0
  87. package/skills/cometchat-angular-calls/references/ngzone-and-async-callbacks.md +183 -0
  88. package/skills/cometchat-angular-calls/references/picture-in-picture.md +285 -0
  89. package/skills/cometchat-angular-calls/references/raise-hand.md +167 -0
  90. package/skills/cometchat-angular-calls/references/recording-screen-share.md +267 -0
  91. package/skills/cometchat-angular-calls/references/ringing-integration.md +131 -0
  92. package/skills/cometchat-angular-calls/references/server-web-push-vapid.md +100 -0
  93. package/skills/cometchat-angular-calls/references/share-invite.md +116 -0
  94. package/skills/cometchat-angular-components/SKILL.md +1 -1
  95. package/skills/cometchat-angular-core/SKILL.md +1 -1
  96. package/skills/cometchat-angular-customization/SKILL.md +1 -1
  97. package/skills/cometchat-angular-features/SKILL.md +1 -1
  98. package/skills/cometchat-angular-patterns/SKILL.md +1 -1
  99. package/skills/cometchat-angular-placement/SKILL.md +1 -1
  100. package/skills/cometchat-angular-production/SKILL.md +1 -1
  101. package/skills/cometchat-angular-push/SKILL.md +403 -0
  102. package/skills/cometchat-angular-testing/SKILL.md +333 -0
  103. package/skills/cometchat-angular-theming/SKILL.md +1 -1
  104. package/skills/cometchat-angular-troubleshooting/SKILL.md +1 -1
  105. package/skills/cometchat-astro-patterns/SKILL.md +1 -1
  106. package/skills/cometchat-calls/SKILL.md +358 -0
  107. package/skills/cometchat-calls/references/use-case-broadcast.md +194 -0
  108. package/skills/cometchat-calls/references/use-case-marketplace.md +158 -0
  109. package/skills/cometchat-calls/references/use-case-support.md +190 -0
  110. package/skills/cometchat-calls/references/use-case-team.md +169 -0
  111. package/skills/cometchat-calls/references/use-case-telehealth.md +154 -0
  112. package/skills/cometchat-components/SKILL.md +1 -1
  113. package/skills/cometchat-core/SKILL.md +1 -1
  114. package/skills/cometchat-customization/SKILL.md +2 -2
  115. package/skills/cometchat-features/SKILL.md +2 -2
  116. package/skills/cometchat-flutter-v5/SKILL.md +1 -1
  117. package/skills/cometchat-flutter-v5-calls/SKILL.md +325 -94
  118. package/skills/cometchat-flutter-v5-calls/references/add-calls-to-existing-chat.md +169 -0
  119. package/skills/cometchat-flutter-v5-calls/references/call-layouts.md +98 -0
  120. package/skills/cometchat-flutter-v5-calls/references/call-session.md +330 -0
  121. package/skills/cometchat-flutter-v5-calls/references/device-management.md +120 -0
  122. package/skills/cometchat-flutter-v5-calls/references/group-calls.md +187 -0
  123. package/skills/cometchat-flutter-v5-calls/references/idle-timeout.md +97 -0
  124. package/skills/cometchat-flutter-v5-calls/references/in-call-chat.md +132 -0
  125. package/skills/cometchat-flutter-v5-calls/references/migration-v4-to-v5.md +160 -0
  126. package/skills/cometchat-flutter-v5-calls/references/raise-hand.md +244 -0
  127. package/skills/cometchat-flutter-v5-calls/references/ringing-integration.md +193 -0
  128. package/skills/cometchat-flutter-v5-calls/references/server-push-bridge.md +101 -0
  129. package/skills/cometchat-flutter-v5-calls/references/share-invite.md +142 -0
  130. package/skills/cometchat-flutter-v5-conversations/SKILL.md +1 -1
  131. package/skills/cometchat-flutter-v5-core/SKILL.md +1 -1
  132. package/skills/cometchat-flutter-v5-customization/SKILL.md +1 -1
  133. package/skills/cometchat-flutter-v5-events/SKILL.md +1 -1
  134. package/skills/cometchat-flutter-v5-messages/SKILL.md +1 -1
  135. package/skills/cometchat-flutter-v5-production/SKILL.md +1 -1
  136. package/skills/cometchat-flutter-v5-push/SKILL.md +1 -1
  137. package/skills/cometchat-flutter-v5-testing/SKILL.md +390 -0
  138. package/skills/cometchat-flutter-v5-theming/SKILL.md +1 -1
  139. package/skills/cometchat-flutter-v5-troubleshooting/SKILL.md +1 -1
  140. package/skills/cometchat-flutter-v5-users-groups/SKILL.md +1 -1
  141. package/skills/cometchat-flutter-v6/SKILL.md +1 -1
  142. package/skills/cometchat-flutter-v6-calls/SKILL.md +308 -243
  143. package/skills/cometchat-flutter-v6-calls/references/add-calls-to-existing-chat.md +134 -0
  144. package/skills/cometchat-flutter-v6-calls/references/call-layouts.md +102 -0
  145. package/skills/cometchat-flutter-v6-calls/references/call-session.md +229 -0
  146. package/skills/cometchat-flutter-v6-calls/references/device-management.md +99 -0
  147. package/skills/cometchat-flutter-v6-calls/references/group-calls.md +190 -0
  148. package/skills/cometchat-flutter-v6-calls/references/idle-timeout.md +80 -0
  149. package/skills/cometchat-flutter-v6-calls/references/in-call-chat.md +122 -0
  150. package/skills/cometchat-flutter-v6-calls/references/raise-hand.md +268 -0
  151. package/skills/cometchat-flutter-v6-calls/references/ringing-integration.md +171 -0
  152. package/skills/cometchat-flutter-v6-calls/references/server-push-bridge.md +93 -0
  153. package/skills/cometchat-flutter-v6-calls/references/share-invite.md +102 -0
  154. package/skills/cometchat-flutter-v6-components/SKILL.md +1 -1
  155. package/skills/cometchat-flutter-v6-conversations/SKILL.md +1 -1
  156. package/skills/cometchat-flutter-v6-core/SKILL.md +1 -1
  157. package/skills/cometchat-flutter-v6-customization/SKILL.md +1 -1
  158. package/skills/cometchat-flutter-v6-events/SKILL.md +1 -1
  159. package/skills/cometchat-flutter-v6-features/SKILL.md +1 -1
  160. package/skills/cometchat-flutter-v6-messages/SKILL.md +1 -1
  161. package/skills/cometchat-flutter-v6-migration/SKILL.md +1 -1
  162. package/skills/cometchat-flutter-v6-placement/SKILL.md +1 -1
  163. package/skills/cometchat-flutter-v6-production/SKILL.md +1 -1
  164. package/skills/cometchat-flutter-v6-push/SKILL.md +452 -0
  165. package/skills/cometchat-flutter-v6-testing/SKILL.md +319 -0
  166. package/skills/cometchat-flutter-v6-theming/SKILL.md +1 -1
  167. package/skills/cometchat-flutter-v6-troubleshooting/SKILL.md +1 -1
  168. package/skills/cometchat-flutter-v6-users-groups/SKILL.md +1 -1
  169. package/skills/cometchat-i18n/SKILL.md +358 -0
  170. package/skills/cometchat-ios/SKILL.md +5 -5
  171. package/skills/cometchat-ios-calls/SKILL.md +409 -0
  172. package/skills/cometchat-ios-calls/references/add-calls-to-existing-chat.md +172 -0
  173. package/skills/cometchat-ios-calls/references/avaudiosession-routing.md +189 -0
  174. package/skills/cometchat-ios-calls/references/call-layouts.md +136 -0
  175. package/skills/cometchat-ios-calls/references/call-session.md +221 -0
  176. package/skills/cometchat-ios-calls/references/callkit-and-pushkit.md +353 -0
  177. package/skills/cometchat-ios-calls/references/custom-ui.md +322 -0
  178. package/skills/cometchat-ios-calls/references/device-management.md +171 -0
  179. package/skills/cometchat-ios-calls/references/group-calls.md +396 -0
  180. package/skills/cometchat-ios-calls/references/idle-timeout.md +185 -0
  181. package/skills/cometchat-ios-calls/references/in-call-chat.md +183 -0
  182. package/skills/cometchat-ios-calls/references/migration-v4-to-v5.md +138 -0
  183. package/skills/cometchat-ios-calls/references/picture-in-picture.md +246 -0
  184. package/skills/cometchat-ios-calls/references/raise-hand.md +239 -0
  185. package/skills/cometchat-ios-calls/references/recording-screen-share.md +339 -0
  186. package/skills/cometchat-ios-calls/references/ringing-integration.md +142 -0
  187. package/skills/cometchat-ios-calls/references/server-apns-pushkit.md +267 -0
  188. package/skills/cometchat-ios-calls/references/share-invite.md +152 -0
  189. package/skills/cometchat-ios-calls/references/swiftui-uikit-hosting.md +246 -0
  190. package/skills/cometchat-ios-calls/references/voip-cert-setup.md +166 -0
  191. package/skills/cometchat-ios-components/SKILL.md +1 -1
  192. package/skills/cometchat-ios-core/SKILL.md +1 -1
  193. package/skills/cometchat-ios-customization/SKILL.md +1 -1
  194. package/skills/cometchat-ios-features/SKILL.md +1 -1
  195. package/skills/cometchat-ios-placement/SKILL.md +1 -1
  196. package/skills/cometchat-ios-production/SKILL.md +1 -1
  197. package/skills/cometchat-ios-push/SKILL.md +1 -1
  198. package/skills/cometchat-ios-testing/SKILL.md +371 -0
  199. package/skills/cometchat-ios-theming/SKILL.md +1 -1
  200. package/skills/cometchat-ios-troubleshooting/SKILL.md +1 -1
  201. package/skills/cometchat-native-bare-patterns/SKILL.md +45 -3
  202. package/skills/cometchat-native-calls/SKILL.md +599 -0
  203. package/skills/cometchat-native-calls/references/add-calls-to-existing-chat.md +203 -0
  204. package/skills/cometchat-native-calls/references/call-layouts.md +124 -0
  205. package/skills/cometchat-native-calls/references/call-session.md +182 -0
  206. package/skills/cometchat-native-calls/references/custom-ui.md +250 -0
  207. package/skills/cometchat-native-calls/references/device-management.md +135 -0
  208. package/skills/cometchat-native-calls/references/expo-vs-bare.md +179 -0
  209. package/skills/cometchat-native-calls/references/group-calls.md +291 -0
  210. package/skills/cometchat-native-calls/references/idle-timeout.md +128 -0
  211. package/skills/cometchat-native-calls/references/in-call-chat.md +143 -0
  212. package/skills/cometchat-native-calls/references/migration-v4-to-v5.md +72 -0
  213. package/skills/cometchat-native-calls/references/picture-in-picture.md +276 -0
  214. package/skills/cometchat-native-calls/references/raise-hand.md +203 -0
  215. package/skills/cometchat-native-calls/references/recording-screen-share.md +290 -0
  216. package/skills/cometchat-native-calls/references/ringing-integration.md +118 -0
  217. package/skills/cometchat-native-calls/references/server-push-bridge.md +135 -0
  218. package/skills/cometchat-native-calls/references/server-push-payloads.md +193 -0
  219. package/skills/cometchat-native-calls/references/share-invite.md +144 -0
  220. package/skills/cometchat-native-calls/references/voip-push-end-to-end.md +317 -0
  221. package/skills/cometchat-native-components/SKILL.md +1 -1
  222. package/skills/cometchat-native-core/SKILL.md +1 -1
  223. package/skills/cometchat-native-customization/SKILL.md +1 -1
  224. package/skills/cometchat-native-expo-patterns/SKILL.md +18 -1
  225. package/skills/cometchat-native-features/SKILL.md +1 -1
  226. package/skills/cometchat-native-placement/SKILL.md +1 -1
  227. package/skills/cometchat-native-production/SKILL.md +1 -1
  228. package/skills/cometchat-native-push/SKILL.md +1 -1
  229. package/skills/cometchat-native-testing/SKILL.md +1 -1
  230. package/skills/cometchat-native-theming/SKILL.md +1 -1
  231. package/skills/cometchat-native-troubleshooting/SKILL.md +1 -1
  232. package/skills/cometchat-nextjs-patterns/SKILL.md +1 -1
  233. package/skills/cometchat-placement/SKILL.md +29 -1
  234. package/skills/cometchat-production/SKILL.md +1 -1
  235. package/skills/cometchat-react-calls/SKILL.md +539 -0
  236. package/skills/cometchat-react-calls/references/add-calls-to-existing-chat.md +145 -0
  237. package/skills/cometchat-react-calls/references/call-layouts.md +161 -0
  238. package/skills/cometchat-react-calls/references/call-session.md +235 -0
  239. package/skills/cometchat-react-calls/references/custom-ui.md +201 -0
  240. package/skills/cometchat-react-calls/references/device-management.md +206 -0
  241. package/skills/cometchat-react-calls/references/group-calls.md +262 -0
  242. package/skills/cometchat-react-calls/references/idle-timeout.md +175 -0
  243. package/skills/cometchat-react-calls/references/in-call-chat.md +212 -0
  244. package/skills/cometchat-react-calls/references/migration-v4-to-v5.md +172 -0
  245. package/skills/cometchat-react-calls/references/picture-in-picture.md +245 -0
  246. package/skills/cometchat-react-calls/references/raise-hand.md +238 -0
  247. package/skills/cometchat-react-calls/references/recording-screen-share.md +143 -0
  248. package/skills/cometchat-react-calls/references/ringing-integration.md +255 -0
  249. package/skills/cometchat-react-calls/references/server-web-push-vapid.md +241 -0
  250. package/skills/cometchat-react-calls/references/share-invite.md +176 -0
  251. package/skills/cometchat-react-calls/references/testing-calls-on-web.md +198 -0
  252. package/skills/cometchat-react-calls/references/voip-and-web-push.md +165 -0
  253. package/skills/cometchat-react-patterns/SKILL.md +56 -8
  254. package/skills/cometchat-react-push/SKILL.md +448 -0
  255. package/skills/cometchat-react-router-patterns/SKILL.md +1 -1
  256. package/skills/cometchat-react-testing/SKILL.md +404 -0
  257. package/skills/cometchat-theming/SKILL.md +3 -3
  258. package/skills/cometchat-troubleshooting/SKILL.md +2 -2
@@ -0,0 +1,539 @@
1
+ ---
2
+ name: cometchat-react-calls
3
+ description: CometChat Calls SDK integration for web React apps (Vite, CRA, Next.js, React Router, Astro). Covers @cometchat/calls-sdk-javascript install, dual-SDK init (Chat SDK + Calls SDK), getRTCToken, the kit's CometChatIncomingCall / CometChatOutgoingCall / CometChatOngoingCall components, CallButtons composition, getUserMedia permissions, browser TURN/STUN handling, and additive-vs-standalone modes.
4
+ license: "MIT"
5
+ compatibility: "React >= 18, Next.js >= 13, React Router v6/v7, Astro >= 4; @cometchat/calls-sdk-javascript ^5 (v5.0.0 stable shipped; pin to `@5` because the npm `latest` dist-tag still points at v4.2.6 — see §Install); @cometchat/chat-sdk-javascript ^4.x; @cometchat/chat-uikit-react ^6.x (additive mode)"
6
+ allowed-tools: "shell, file-read, file-search, file-list, ask-user"
7
+ metadata:
8
+ author: "CometChat"
9
+ version: "4.0.0"
10
+ tags: "cometchat react calls voice video webrtc nextjs react-router astro getRTCToken getusermedia browser-permissions vite cra"
11
+ ---
12
+
13
+ ## ⚠️ STOP — mandatory precondition before any code
14
+
15
+ **Before writing one line of code, you MUST resolve `mode = ringing | session`.** This decides which entire integration shape you scaffold — they don't share UI, navigation, or surface.
16
+
17
+ | `mode` | Surface shape | Reference |
18
+ |---|---|---|
19
+ | `ringing` | `CometChatIncomingCall` at root + `CometChatCallButtons` near a user / contact / message header. Recipient's screen rings on incoming call. | `references/ringing-integration.md` |
20
+ | `session` | `/meet/:sessionId` route (or equivalent) + `CometChatCalls.joinSession` on a container `<div>`. No ringing — both parties enter the same session ID. | `references/call-session.md` |
21
+
22
+ **How to resolve mode (in order):**
23
+
24
+ 1. **Check `.cometchat/config.json` for `mode`** — if set by the `cometchat-calls` dispatcher's Step 3.0, trust it.
25
+ 2. **Infer from the user's words** — see `cometchat-calls/SKILL.md` Step 3.0 inference table. Confirm in one line: *"Got it — setting up Ringing. Say so if you wanted meeting-room URLs instead."*
26
+ 3. **If still ambiguous (e.g. user said only "integrate calls" with no qualifier) — ASK before scaffolding.** Don't default to ringing. Use this prompt **verbatim** — preserve the order, the labels, and the descriptions exactly. Do NOT rephrase. Do NOT swap options. Option 1 is "Session"; option 2 is "Ringing":
27
+
28
+ - **question:** "What kind of calling experience are you building?"
29
+ - **header:** "Calling mode"
30
+ - **multiSelect:** false
31
+ - **options (display in this exact order — Session FIRST, Ringing SECOND):**
32
+ 1. label: "Session — meeting / conference room", description: "Multiple users join the same session by ID or link. No ringing. Like Google Meet, Zoom, or a Slack huddle."
33
+ 2. label: "Ringing — 1:1 or group calls", description: "One user calls another (or a small group). Recipient's device rings; they accept or decline. Like FaceTime or WhatsApp calls."
34
+
35
+ > **Strict-order rule:** the agent's UI primitive must render option 1 above the option 2. Do not let auto-mode classifiers or your own bias reorder them. Session is shown first because the dashboard team has standardized on this order across CometChat product surfaces; consistency matters more than any subjective "first option" preference.
36
+
37
+ **Do not write `CometChatCallButtons` / `CometChatIncomingCall` / `CometChatOngoingCall` code without a confirmed `mode === "ringing"`.** Those components are the kit's implementation of ringing; using them silently locks the integration into ringing-shape even if the user wanted a meeting-room flow.
38
+
39
+ ---
40
+
41
+ ## ⚠️ Call container — must have non-zero dimensions when joinSession fires
42
+
43
+ The Calls SDK measures the container `<div>` **synchronously** when `joinSession` runs and throws `Container dimensions and number of tiles must be positive` if width or height is 0. This is the calls equivalent of the chat-layout flex-shrink trap.
44
+
45
+ **Common bug — `h-full` on a flex child resolves to 0:**
46
+
47
+ ```tsx
48
+ // ✗ WRONG — `h-full` is `height: 100%`, but the parent's height is auto
49
+ // so 100% of auto = 0. SDK crashes.
50
+ <section className="flex-1">
51
+ <div ref={containerRef} className="h-full w-full" />
52
+ </section>
53
+ ```
54
+
55
+ **Fix — use a flex chain with `min-h-0` and an explicit fallback:**
56
+
57
+ ```tsx
58
+ // ✓ RIGHT — section is a flex column with min-h-0 (so it can shrink), the
59
+ // container uses flex-1 to claim remaining space, plus an explicit
60
+ // `minHeight` safety net for very short viewports.
61
+ <section className="relative flex flex-1 min-h-0">
62
+ <div
63
+ ref={containerRef}
64
+ className="flex-1 w-full"
65
+ style={{ minHeight: 400 }}
66
+ />
67
+ </section>
68
+ ```
69
+
70
+ If you can't use flex (e.g. fixed-height modal), just give the container explicit pixels:
71
+
72
+ ```tsx
73
+ <div
74
+ ref={containerRef}
75
+ style={{ width: "100%", height: "calc(100vh - 100px)" }}
76
+ />
77
+ ```
78
+
79
+ `minHeight: 0` matters specifically for parent flex containers that house the call container — without it, a flex-column ancestor whose content overflows defaults to `min-height: auto` and the call surface gets squeezed to zero. This is the same trap as `cometchat-react-patterns`'s chat-layout rule, applied to calls.
80
+
81
+ ---
82
+
83
+ ## ⚠️ Next.js / SSR — mandatory bundler config
84
+
85
+ Both SDKs ship code that **breaks Next.js's SSR pass**:
86
+
87
+ - `@cometchat/chat-sdk-javascript` references `window` at module load time
88
+ - `@cometchat/calls-sdk-javascript` (v5) imports Node built-ins (`fs`, `path`) gated by a runtime check that the bundler still tries to statically resolve
89
+
90
+ `"use client"` alone does NOT fix this — Next.js evaluates client components during the initial SSR pass for hydration. You need to defer the SDK imports so they only execute in the browser.
91
+
92
+ **For Next.js (App Router or Pages Router), apply ALL of these:**
93
+
94
+ 1. **Switch dev/build to webpack** in `package.json` scripts (Turbopack's `fs`/`path` aliasing is fragile in Next 16):
95
+ ```json
96
+ {
97
+ "scripts": {
98
+ "dev": "next dev --webpack",
99
+ "build": "next build --webpack",
100
+ "start": "next start"
101
+ }
102
+ }
103
+ ```
104
+
105
+ 2. **Add a webpack `fs` fallback** in `next.config.ts`:
106
+ ```ts
107
+ import type { NextConfig } from "next";
108
+ const nextConfig: NextConfig = {
109
+ webpack: (config, { isServer }) => {
110
+ if (!isServer) {
111
+ config.resolve = config.resolve || {};
112
+ config.resolve.fallback = {
113
+ ...(config.resolve.fallback || {}),
114
+ fs: false,
115
+ path: false,
116
+ };
117
+ }
118
+ return config;
119
+ },
120
+ };
121
+ export default nextConfig;
122
+ ```
123
+
124
+ 3. **Wrap the CometChatProvider in `next/dynamic({ ssr: false })`** — create a small client wrapper and use it from a server-component layout:
125
+ ```tsx
126
+ // app/_components/CometChatGate.tsx
127
+ "use client";
128
+ import dynamic from "next/dynamic";
129
+ import type { ReactNode } from "react";
130
+
131
+ const CometChatProvider = dynamic(
132
+ () => import("@/cometchat/CometChatProvider").then((m) => m.CometChatProvider),
133
+ { ssr: false, loading: () => <div>Loading…</div> },
134
+ );
135
+
136
+ export function CometChatGate({ children }: { children: ReactNode }) {
137
+ return <CometChatProvider>{children}</CometChatProvider>;
138
+ }
139
+ ```
140
+
141
+ **⚠️ Provider placement for Ringing mode — mount at app root, not on a sub-route layout.** If the CometChatProvider registers a global `CallListener` for incoming calls (which it should — see "Ringing mode listener" below), it MUST be mounted in the root layout (`app/layout.tsx`). Mounting it on a sub-route layout like `app/meet/layout.tsx` means the listener is only armed while the user is browsing under that sub-route — incoming calls land silently when they're on the home page or any other route, and the caller sees a timeout/rejection.
142
+
143
+ ```tsx
144
+ // app/layout.tsx (server component, root layout)
145
+ import { CometChatGate } from "./_components/CometChatGate";
146
+ export default function RootLayout({ children }: { children: React.ReactNode }) {
147
+ return (
148
+ <html><body>
149
+ <CometChatGate>{children}</CometChatGate>
150
+ </body></html>
151
+ );
152
+ }
153
+ ```
154
+
155
+ For Session-only mode (no ringing — both parties navigate to a shared `/meet/:id` URL), the sub-route layout is fine — listener isn't load-bearing.
156
+
157
+ **Ringing mode listener** — inside `CometChatProvider`, after login:
158
+ ```ts
159
+ const { CometChat } = await import("@cometchat/chat-sdk-javascript");
160
+ CometChat.addCallListener("ringing-listener", new CometChat.CallListener({
161
+ onIncomingCallReceived: async (call: any) => {
162
+ const accepted = await CometChat.acceptCall(call.getSessionId());
163
+ router.push(`/meet/${encodeURIComponent(accepted.getSessionId())}`);
164
+ },
165
+ onOutgoingCallAccepted: (call: any) => {
166
+ router.push(`/meet/${encodeURIComponent(call.getSessionId())}`);
167
+ },
168
+ onOutgoingCallRejected: (call: any) => { /* show toast */ },
169
+ onIncomingCallCancelled: (call: any) => { /* dismiss any UI */ },
170
+ }));
171
+ ```
172
+ The `/meet/:sessionId` page handles `joinSession`. Validated end-to-end against Pixel 3 V6 Android peer on 2026-05-12.
173
+
174
+ 4. **Lazy-load the SDKs inside `init.ts`** — replace top-level static imports with `await import(...)` inside the init/login functions. The provider is gated by step 3, but `init.ts` is shared with any page that uses CometChatCalls directly, so belt-and-braces it:
175
+ ```ts
176
+ let chatModule: typeof import("@cometchat/chat-sdk-javascript") | null = null;
177
+ let callsModule: typeof import("@cometchat/calls-sdk-javascript") | null = null;
178
+
179
+ async function loadSdks() {
180
+ if (!chatModule) chatModule = await import("@cometchat/chat-sdk-javascript");
181
+ if (!callsModule) callsModule = await import("@cometchat/calls-sdk-javascript");
182
+ return { CometChat: chatModule.CometChat, CometChatCalls: callsModule.CometChatCalls };
183
+ }
184
+ ```
185
+
186
+ 5. **No top-level SDK imports in any page that's reachable via App Router routing.** Inside `useEffect` handlers, dynamic-import the SDK:
187
+ ```tsx
188
+ useEffect(() => {
189
+ let CallsSdk: typeof import("@cometchat/calls-sdk-javascript").CometChatCalls | null = null;
190
+ (async () => {
191
+ const mod = await import("@cometchat/calls-sdk-javascript");
192
+ CallsSdk = mod.CometChatCalls;
193
+ // ... use CallsSdk
194
+ })();
195
+ return () => {
196
+ try { CallsSdk?.leaveSession(); } catch { /* noop */ }
197
+ };
198
+ }, []);
199
+ ```
200
+
201
+ Skipping any of these reproduces the failure mode: the route 500s with either `Module not found: Can't resolve 'fs'` or `ReferenceError: window is not defined`. Verified empirically against Next.js 16.2.6 + Calls SDK 5.0.0-beta.2.
202
+
203
+ For Vite / React Router / Astro, none of this applies — those bundlers don't pre-evaluate client modules.
204
+
205
+ ---
206
+
207
+ ## Purpose
208
+
209
+ Production-grade voice + video calling for React-family web apps. Loaded by `cometchat-calls` when `framework` is one of `reactjs`, `nextjs`, `react-router`, or `astro`. Operates in two modes:
210
+
211
+ - **Standalone** — calls is the product. `@cometchat/chat-sdk-javascript` (signaling) + `@cometchat/calls-sdk-javascript` (WebRTC) + a small set of UI Kit call components. No `CometChatConversations` / `CometChatMessageList` / etc.
212
+ - **Additive** — calls layered onto an existing CometChat React UI Kit integration. Adds call buttons inline, mounts `CometChatIncomingCall` at app root.
213
+
214
+ **Read these other skills first:**
215
+ - `cometchat-calls` — dispatcher (modes, hard rules, anti-patterns)
216
+ - `cometchat-core` — Chat SDK init, login, env-var prefix per framework, SSR safety
217
+ - Framework-specific patterns: `cometchat-react-patterns` / `cometchat-nextjs-patterns` / `cometchat-react-router-patterns` / `cometchat-astro-patterns`
218
+
219
+ **Ground truth:**
220
+ - SDK source — `~/Downloads/calls-sdk/calls-sdk-javascript-5/package/`
221
+ - Sample apps — `~/Downloads/calls-sdk/calls-sdk-javascript-5/sample-apps/{react,vue,angular,svelte,ionic}/`
222
+ - Public docs — https://www.cometchat.com/docs/calls/javascript/overview
223
+
224
+ ---
225
+
226
+ ## 1. The seven hard rules — web specialization
227
+
228
+ ### 1.1 Dual-SDK contract
229
+
230
+ `@cometchat/chat-sdk-javascript` for ringing; `@cometchat/calls-sdk-javascript` for the WebRTC session. They are separate npm packages.
231
+
232
+ ```ts
233
+ // ✓ RIGHT — initiate ringing (Chat SDK)
234
+ import { CometChat } from "@cometchat/chat-sdk-javascript";
235
+
236
+ const outgoing = new CometChat.Call(receiverUid, CometChat.CALL_TYPE.VIDEO, CometChat.RECEIVER_TYPE.USER);
237
+ const initiated = await CometChat.initiateCall(outgoing);
238
+ // initiated.getSessionId() — the ID the Calls SDK will join
239
+ ```
240
+
241
+ ```ts
242
+ // ✓ RIGHT — join WebRTC session (Calls SDK v5)
243
+ import { CometChatCalls } from "@cometchat/calls-sdk-javascript";
244
+
245
+ // v5 — plain SessionSettings object, no Builder
246
+ const sessionSettings = {
247
+ sessionType: "VIDEO", // or "VOICE"
248
+ layout: "TILE",
249
+ };
250
+
251
+ // v5 — generateToken takes ONLY sessionId (Calls SDK has its own auth state
252
+ // after CometChatCalls.login(); no authToken arg needed).
253
+ const tokenRes = await CometChatCalls.generateToken(sessionId);
254
+
255
+ // htmlElement is REQUIRED — pass the DOM container the SDK should draw into
256
+ const container = document.getElementById("ongoing-call-root")!;
257
+ const result = await CometChatCalls.joinSession(tokenRes.token, sessionSettings, container);
258
+ if (result?.error) {
259
+ console.error("joinSession failed:", result.error);
260
+ }
261
+ ```
262
+
263
+ The two-`Call`-classes problem from Android does NOT exist on JS — there's only one `CometChat.Call` constructor. But the dual-SDK split still trips up agents trained on the chat-only docs.
264
+
265
+ ### 1.2 VoIP push — N/A on web (browsers don't have VoIP push)
266
+
267
+ The mandatory-VoIP-push rule from mobile families does not apply to web. Browsers cannot ring a closed tab. The standalone-mode equivalent is **Web Push notifications** (Service Worker + `Notification` API + push subscriptions) — useful for nudging the user to a tab where the call screen is open, but they do not bypass tab/page-load.
268
+
269
+ The skill scaffolds Web Push as an opt-in (asks user); it is not strictly required. Production calls UX on web typically pairs with email/SMS fallback for missed calls, not VoIP.
270
+
271
+ ### 1.3 Lifecycle — `getUserMedia` cleanup
272
+
273
+ Web's equivalent of Android's foreground-service correctness is `MediaStream` track cleanup. Browsers don't release the camera/mic until tracks are explicitly stopped. The kit handles this for `<CometChatOngoingCall />`, but custom WebRTC surfaces (Section 4) must do:
274
+
275
+ ```ts
276
+ function endCall() {
277
+ // 1. End the Calls SDK session — releases the kit's internal stream
278
+ CometChatCalls.leaveSession(); // v5 — was endSession() in v4 (still works as a deprecated shim)
279
+
280
+ // 2. If you grabbed a custom MediaStream (preview, screen-share), stop tracks
281
+ customStream?.getTracks().forEach(t => t.stop());
282
+ customStream = null;
283
+
284
+ // 3. Detach video elements
285
+ if (videoEl.current) videoEl.current.srcObject = null;
286
+ }
287
+ ```
288
+
289
+ Skipping this leaves the camera light on until the tab is closed. Same canonical bug as iOS rule 1.5.
290
+
291
+ ### 1.4 Server-minted auth tokens for production
292
+
293
+ In v5 the Calls SDK has **its own login step** — it no longer piggybacks on the Chat SDK's auth context implicitly. After `CometChat.login()` resolves on the chat side, call **`CometChatCalls.login(uid, apiKey)`** for dev or **`CometChatCalls.loginWithAuthToken(authToken)`** for production. The auth token is the same token your backend mints via the CometChat Create-Auth-Token API; the Calls SDK and Chat SDK accept it interchangeably.
294
+
295
+ ```ts
296
+ // Dev
297
+ await CometChatCalls.login(uid, import.meta.env.VITE_COMETCHAT_API_KEY);
298
+
299
+ // Production (server-minted token)
300
+ await CometChatCalls.loginWithAuthToken(authTokenFromBackend);
301
+ ```
302
+
303
+ `cometchat-production` (web) covers the token-endpoint pattern.
304
+
305
+ ### 1.5 Hangup cleanup — see rule 1.3
306
+
307
+ ### 1.6 Permissions — `getUserMedia` prompts
308
+
309
+ The browser handles the runtime permission prompt automatically when the Calls SDK calls `getUserMedia`. The integration must:
310
+
311
+ - Surface a `try/catch` around `startSession` to handle `NotAllowedError` (user denied)
312
+ - Surface `NotFoundError` (no camera/mic on device — common on desktops with no webcam)
313
+ - Render a clear in-app explanation BEFORE the browser prompts, so users know what they're agreeing to (browsers ignore this in autoplay/iframe contexts but it improves grant rates)
314
+
315
+ There are no manifest-level permission declarations on web. HTTPS is required — the skill detects `localhost` (allowed) vs other origins (must be HTTPS) and warns if the dev server is HTTP.
316
+
317
+ ### 1.7 IncomingCall mounted at app root
318
+
319
+ `<CometChatIncomingCall />` (additive mode) or a Service-Worker-driven web-push handler (standalone mode) must mount above the route boundary so calls fire on every page.
320
+
321
+ ```tsx
322
+ // app/layout.tsx (Next.js App Router) or App.tsx (Vite/CRA)
323
+ <CometChatProvider>
324
+ <CometChatIncomingCall /> {/* renders nothing when no call active; listens app-wide */}
325
+ <Routes>...</Routes>
326
+ </CometChatProvider>
327
+ ```
328
+
329
+ Mounting it inside a route component means it disappears on navigation — calls only ring on the screen where it's mounted. That's the canonical "calls don't work" bug on web.
330
+
331
+ ---
332
+
333
+ ## 2. Setup
334
+
335
+ ### Install
336
+
337
+ Calls SDK v5.0.0 stable shipped but the npm `latest` dist-tag still points at v4.2.6 (legacy). **Always pin to `@5` (or a specific `^5.0.0` version)** — `npm install @cometchat/calls-sdk-javascript` (no tag) resolves to v4.2.6, which is the previous generation. `@beta` is also published but pins to an older 5.0.0-beta.2 — prefer `@5` to get the latest stable 5.x.
338
+
339
+ ```bash
340
+ # v5 stable (current — pulls 5.0.0 or newer 5.x)
341
+ npm install @cometchat/chat-sdk-javascript @cometchat/calls-sdk-javascript@5
342
+ # additive mode: @cometchat/chat-uikit-react is already installed
343
+ ```
344
+
345
+ The kit (`@cometchat/chat-uikit-react@^6.x`) was built against the v4 calls API but Calls SDK v5 ships v4 deprecated-method shims that delegate to v5 implementations — so the kit's `CometChatCallButtons` / `CometChatIncomingCall` / `CometChatOngoingCall` keep working when you swap v4 for v5. Custom call surfaces should use v5 APIs directly.
346
+
347
+ ### Init order (web — v5)
348
+
349
+ ```tsx
350
+ // cometchat/init.ts
351
+ import { CometChat } from "@cometchat/chat-sdk-javascript";
352
+ import { CometChatCalls } from "@cometchat/calls-sdk-javascript";
353
+
354
+ let initialized = false;
355
+
356
+ export async function initCometChat() {
357
+ if (initialized) return;
358
+
359
+ // 1. Chat SDK init (signaling)
360
+ const appSettings = new CometChat.AppSettingsBuilder()
361
+ .subscribePresenceForAllUsers()
362
+ .setRegion(import.meta.env.VITE_COMETCHAT_REGION) // adjust for framework
363
+ .build();
364
+ await CometChat.init(import.meta.env.VITE_COMETCHAT_APP_ID, appSettings);
365
+
366
+ // 2. Calls SDK init (WebRTC) — v5 takes a plain object and returns {success, error}
367
+ const callsInit = await CometChatCalls.init({
368
+ appId: import.meta.env.VITE_COMETCHAT_APP_ID,
369
+ region: import.meta.env.VITE_COMETCHAT_REGION,
370
+ });
371
+ if (!callsInit?.success) {
372
+ throw new Error(`CometChatCalls.init failed: ${JSON.stringify(callsInit?.error)}`);
373
+ }
374
+
375
+ initialized = true;
376
+ }
377
+
378
+ // After your existing CometChat.login(uid, apiKey) call, login the Calls SDK too.
379
+ // In v5 the Calls SDK has its own auth state; this step is mandatory.
380
+ export async function loginCometChat(uid: string) {
381
+ await CometChat.login(uid, import.meta.env.VITE_COMETCHAT_AUTH_KEY);
382
+
383
+ // v5 — Calls SDK login. Either form is fine; loginWithAuthToken is for production.
384
+ if (!CometChatCalls.getLoggedInUser()) {
385
+ await CometChatCalls.login(uid, import.meta.env.VITE_COMETCHAT_API_KEY);
386
+ // OR: await CometChatCalls.loginWithAuthToken(serverMintedToken);
387
+ }
388
+ }
389
+ ```
390
+
391
+ The module-level `initialized` flag prevents StrictMode double-init in React 18+ dev mode. The `getLoggedInUser()` guard prevents re-login on hot reload.
392
+
393
+ ### Framework-specific env prefixes (already covered by `cometchat-core`)
394
+
395
+ | Framework | Env prefix |
396
+ |---|---|
397
+ | Vite (reactjs / react-router) | `VITE_` |
398
+ | CRA | `REACT_APP_` |
399
+ | Next.js | `NEXT_PUBLIC_` |
400
+ | Astro | `PUBLIC_` |
401
+
402
+ ### SSR safety
403
+
404
+ CometChat Calls SDK is browser-only — `window`, `MediaStream`, `RTCPeerConnection`, `navigator.mediaDevices`. Calls components must NOT render server-side:
405
+
406
+ - **Next.js App Router:** add `"use client"` to the file containing call components
407
+ - **Next.js Pages Router:** dynamic-import with `ssr: false`
408
+ - **React Router:** lazy + `<Suspense>` + `if (typeof window === "undefined") return null` guard in the component
409
+ - **Astro:** `client:only="react"` on the call component island
410
+
411
+ ---
412
+
413
+ ## 3. Components catalog
414
+
415
+ ### Calls SDK primitives — v5 (used in standalone or wherever you build custom UI)
416
+
417
+ | Class / function | Purpose |
418
+ |---|---|
419
+ | `CometChatCalls.init({ appId, region })` | One-time init. Returns `Promise<{ success, error }>` — check `.success`. |
420
+ | `CometChatCalls.login(uid, apiKey)` | Dev-mode login. Returns the logged-in `User`. |
421
+ | `CometChatCalls.loginWithAuthToken(authToken)` | Production login with server-minted token. |
422
+ | `CometChatCalls.getLoggedInUser()` | Returns a plain `{ uid, name, avatar?, status?, ... }` object or `null`. Access `.uid` as a PROPERTY (not `.getUid()` — that method belongs to the Chat SDK's `User` class, which session-only code does not import). Use to guard against double-login: `if (existing && existing.uid === uid) return existing;` |
423
+ | `CometChatCalls.logout()` | Clears Calls SDK auth state. |
424
+ | `CometChatCalls.generateToken(sessionId)` | Mint a session-scoped RTC token. **Single arg** — auth is implicit after `login()`. |
425
+ | `CometChatCalls.joinSession(callToken, sessionSettings, htmlElement)` | Join the WebRTC session — `htmlElement` is required. Returns `{ data, error }`. |
426
+ | `CometChatCalls.leaveSession()` | End + cleanup. Returns `void`. |
427
+ | `CometChatCalls.addEventListener(eventName, handler)` | Granular event subscription — replaces v4's monolithic `OngoingCallListener`. Returns an unsubscribe function. |
428
+ | `CometChatCalls.setLayout(layout)` | `"TILE"` / `"SIDEBAR"` / `"SPOTLIGHT"`. Per-participant. |
429
+ | `CometChatCalls.constants.LAYOUT` | Layout enum for type-safety. |
430
+
431
+ **v4 → v5 method mapping** (the deprecated v4 method names below all still work in v5 as shims that delegate to v5 implementations — your kit's v6 code is unaffected):
432
+
433
+ | v4 (deprecated) | v5 |
434
+ |---|---|
435
+ | `init(new CallAppSettingsBuilder().setAppId(...).build())` | `init({ appId, region })` |
436
+ | `generateToken(sid, authToken)` | `generateToken(sid)` (after `login()`) |
437
+ | `startSession(token, settings, el)` | `joinSession(token, settings, el)` |
438
+ | `endSession()` | `leaveSession()` |
439
+ | `setMode(mode)` | `setLayout(layout)` |
440
+ | `OngoingCallListener` (single object) | `addEventListener(name, handler)` (granular) |
441
+ | `enterPIPMode()` | `enablePictureInPictureLayout()` |
442
+
443
+ See `references/migration-v4-to-v5.md` for the full migration guide.
444
+
445
+ ### UI Kit components (additive mode — `@cometchat/chat-uikit-react`)
446
+
447
+ | Component | Purpose |
448
+ |---|---|
449
+ | `<CometChatCallButtons user={u} />` | Voice + video icon row, drop into any header |
450
+ | `<CometChatIncomingCall />` | Root-mounted; renders nothing when no call active |
451
+ | `<CometChatOutgoingCall />` | Auto-mounted by IncomingCall on initiateCall |
452
+ | `<CometChatOngoingCall />` | Active call view; hosts the WebRTC element |
453
+ | `<CometChatCallLogs onItemClick={fn} />` | Paginated history |
454
+
455
+ In standalone mode, you can compose just `<CometChatOngoingCall />` + `<CometChatCallLogs />` from the UI Kit even without using `CometChatConversations` etc. — the kit's calls components don't depend on its conversation components.
456
+
457
+ ---
458
+
459
+ ## 4. Standalone integration
460
+
461
+ When `product === "voice-video"` and there is no existing chat UI integration.
462
+
463
+ **Split by calling mode — these are two different shapes:**
464
+
465
+ ### 4a. Standalone — Session mode (meeting-room UX, no ringing)
466
+
467
+ Calls SDK ONLY. NO Chat SDK. Matches the upstream sample at `~/Downloads/calls-sdk/calls-sdk-javascript-5/sample-apps/cometchat-calls-sample-app-react/`. The skill scaffolds:
468
+
469
+ 1. **`cometchat/init.ts`** — `CometChatCalls.init({ appId, region, authKey })` ONLY. No `CometChat.init`, no `CometChat.login`. Pass `authKey` at init time so subsequent `CometChatCalls.login(uid)` calls need no second arg.
470
+ 2. **`cometchat/CometChatProvider.tsx`** — Runs Calls SDK init on mount, exposes `loggedInUser` via `CometChatCalls.getLoggedInUser()`, gates children on success.
471
+ 3. **`pages/Home.tsx`** — UID picker (dev mode) + "Start meeting" (mints UUID, navigates to `/meet/:id`) + "Join meeting" (paste sessionId).
472
+ 4. **`pages/CallRoom.tsx`** — `/meet/:sessionId` route. Container is `position: fixed; width: 100vw; height: 100vh`. `CometChatCalls.joinSession(token, {}, container)` with empty settings. See `references/call-session.md` for the canonical pattern.
473
+ 5. **HTTPS check** — warns if dev server is HTTP non-localhost.
474
+
475
+ **Why no Chat SDK:** session mode never touches the Chat SDK call entity. Initializing both SDKs adds two failure modes (Chat init, Chat login race) for zero benefit. The upstream sample confirms this — it never imports `@cometchat/chat-sdk-javascript`.
476
+
477
+ ### 4b. Standalone — Ringing mode (CallButtons + Incoming/Outgoing/Ongoing kit components)
478
+
479
+ Dual-SDK: Chat SDK signaling channel + Calls SDK media channel. The skill scaffolds:
480
+
481
+ 1. **`cometchat/init.ts`** — Chat SDK + Calls SDK init (sequential), module-level guard.
482
+ 2. **`cometchat/CometChatProvider.tsx`** — React provider, runs init+login on mount, gates children on success.
483
+ 3. **`components/CallButton.tsx`** — Voice + video buttons next to a user (your existing user listing / profile page).
484
+ 4. **`/calls` route or screen** — Renders `<CometChatCallLogs />` for history. (Path depends on framework — `app/calls/page.tsx` for Next.js App Router, `routes/calls.tsx` for React Router, etc.)
485
+ 5. **`OngoingCallView.tsx`** — Custom WebRTC view OR delegates to `<CometChatOngoingCall />`. Implements rule 1.3 cleanup.
486
+ 6. **Provider mounts `<CometChatIncomingCall />`** at the layout root (rule 1.7).
487
+ 7. **Optional Web Push** — Service Worker registration + push subscription endpoint, if the user opts in.
488
+ 8. **HTTPS check** — warns if dev server is HTTP non-localhost.
489
+
490
+ ## 5. Additive integration
491
+
492
+ When `cometchat-core` integration already exists. The skill:
493
+
494
+ 1. Adds `@cometchat/calls-sdk-javascript@5` to `package.json` (v5.0.0 stable — see Install section).
495
+ 2. Patches `cometchat/init.ts` to call `CometChatCalls.init({...})` after `CometChat.init` AND to call `CometChatCalls.login(uid, apiKey)` after `CometChat.login` (v5 — separate auth).
496
+ 3. Mounts `<CometChatIncomingCall />` at the layout root next to existing components (rule 1.7).
497
+ 4. Adds `<CometChatCallButtons user={user} />` inline on selected screens — usually inside `<CometChatMessageHeader />` (the kit auto-renders it there if a `user` prop is set).
498
+ 5. Adds a `/calls` route for `<CometChatCallLogs />` if the user picked the "dedicated route" option.
499
+
500
+ ## 6. Anti-patterns
501
+
502
+ 1. **Mounting `<CometChatIncomingCall />` inside a route component.** Disappears on navigation. Mount above the route boundary in the layout (rule 1.7).
503
+ 2. **Initializing both SDKs in parallel.** `CometChatCalls.init` requires the Chat SDK's app-id context; calling them with `Promise.all` causes intermittent "auth context null" errors. Sequence: chat init → calls init.
504
+ 3. **Skipping the `initialized` guard.** React StrictMode renders effects twice in dev — without the guard, you get duplicate listeners and double-init warnings.
505
+ 4. **Forgetting `getTracks().forEach(t => t.stop())` on custom streams.** Camera light stays on until tab close. Rule 1.3.
506
+ 5. **Embedding `<CometChatOngoingCall />` in an `<iframe>` without `allow="camera; microphone"`.** Browsers silently deny `getUserMedia`. The skill detects iframe contexts and writes the allow list.
507
+ 6. **Calling `joinSession` (v5) before `CometChatCalls.login()` resolves.** `generateToken` 401s — no Calls SDK auth state. Sequence: `CometChatCalls.init` → `CometChatCalls.login` → `generateToken` → `joinSession`.
508
+ 7. **Installing `@cometchat/calls-sdk-javascript` without a version pin.** Resolves to v4.2.6 (the `latest` dist-tag) instead of v5.0.0. The kit's v4 deprecated-method shims live INSIDE v5 — picking up plain v4 means you don't get them. Always `@5` (recommended) or pin a specific `^5.0.0` version. `@beta` is also valid but pins to an older `5.0.0-beta.2`.
509
+ 7. **Running over HTTP (non-localhost).** `getUserMedia` returns `NotAllowedError`. The skill warns; user must use HTTPS or `localhost`.
510
+
511
+ ## 7. Verification checklist
512
+
513
+ **Static:**
514
+
515
+ - [ ] Both `@cometchat/chat-sdk-javascript` and `@cometchat/calls-sdk-javascript@5` (v5 stable) in `package.json`
516
+ - [ ] `CometChatCalls.login(uid, apiKey)` is called after `CometChat.login` (v5 separate auth)
517
+ - [ ] Init order: chat init → calls init (sequential, not parallel)
518
+ - [ ] `<CometChatIncomingCall />` mounted at layout root (additive mode)
519
+ - [ ] Cleanup path stops MediaStream tracks + ends Calls SDK session
520
+ - [ ] Framework-correct SSR guard (`"use client"` / `ssr: false` / `client:only`)
521
+ - [ ] Env vars use the framework-correct prefix
522
+ - [ ] Module-level `initialized` flag for StrictMode safety
523
+
524
+ **Runtime (browser):**
525
+
526
+ - [ ] Outgoing call connects, two-way audio + video
527
+ - [ ] Incoming call rings on a separate page within the same SPA
528
+ - [ ] Camera light off within 2 seconds of hangup
529
+ - [ ] Tab refresh during call cleanly disconnects (no orphaned session)
530
+ - [ ] HTTPS or localhost only — `getUserMedia` works
531
+ - [ ] Multi-tab: closing one tab doesn't end the call in another tab
532
+
533
+ ## 8. Pointers
534
+
535
+ - `cometchat-core` — provider pattern, init guard, login order
536
+ - `cometchat-components` — full UI Kit catalog (additive mode)
537
+ - `cometchat-{nextjs,react,react-router,astro}-patterns` — framework-specific SSR guards, route placement
538
+ - `cometchat-production` — server-minted tokens, security
539
+ - `cometchat-troubleshooting` — common web failure modes (HTTPS, iframe permissions, StrictMode double-init)