@cometchat/skills 4.3.0 → 4.4.1

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 (233) hide show
  1. package/LICENSE +21 -0
  2. package/bin/install.js +27 -0
  3. package/package.json +14 -1
  4. package/skills/cometchat/SKILL.md +233 -69
  5. package/skills/cometchat/references/asking-questions.md +48 -0
  6. package/skills/cometchat-a11y/SKILL.md +3 -2
  7. package/skills/cometchat-android-v5/SKILL.md +2 -1
  8. package/skills/cometchat-android-v5-calls/SKILL.md +36 -22
  9. package/skills/cometchat-android-v5-calls/references/README.md +1 -1
  10. package/skills/cometchat-android-v5-calls/references/add-calls-to-existing-chat.md +7 -5
  11. package/skills/cometchat-android-v5-calls/references/audio-controls.md +4 -4
  12. package/skills/cometchat-android-v5-calls/references/call-layouts.md +33 -25
  13. package/skills/cometchat-android-v5-calls/references/call-session.md +2 -2
  14. package/skills/cometchat-android-v5-calls/references/custom-ui.md +5 -5
  15. package/skills/cometchat-android-v5-calls/references/event-listeners.md +2 -2
  16. package/skills/cometchat-android-v5-calls/references/idle-timeout.md +20 -14
  17. package/skills/cometchat-android-v5-calls/references/in-call-chat.md +1 -1
  18. package/skills/cometchat-android-v5-calls/references/migration-v4-to-v5.md +43 -27
  19. package/skills/cometchat-android-v5-calls/references/participant-management.md +3 -3
  20. package/skills/cometchat-android-v5-calls/references/raise-hand.md +25 -19
  21. package/skills/cometchat-android-v5-calls/references/recording.md +2 -2
  22. package/skills/cometchat-android-v5-calls/references/ringing-integration.md +1 -1
  23. package/skills/cometchat-android-v5-calls/references/screen-sharing.md +5 -9
  24. package/skills/cometchat-android-v5-calls/references/session-settings.md +3 -3
  25. package/skills/cometchat-android-v5-calls/references/setup.md +1 -1
  26. package/skills/cometchat-android-v5-calls/references/share-invite.md +9 -4
  27. package/skills/cometchat-android-v5-calls/references/video-controls.md +4 -4
  28. package/skills/cometchat-android-v5-calls/references/voip-calling.md +2 -2
  29. package/skills/cometchat-android-v5-components/SKILL.md +4 -3
  30. package/skills/cometchat-android-v5-core/SKILL.md +5 -3
  31. package/skills/cometchat-android-v5-customization/SKILL.md +171 -7
  32. package/skills/cometchat-android-v5-extensions/SKILL.md +7 -4
  33. package/skills/cometchat-android-v5-features/SKILL.md +5 -4
  34. package/skills/cometchat-android-v5-placement/SKILL.md +2 -1
  35. package/skills/cometchat-android-v5-production/SKILL.md +2 -1
  36. package/skills/cometchat-android-v5-push/SKILL.md +2 -3
  37. package/skills/cometchat-android-v5-testing/SKILL.md +2 -1
  38. package/skills/cometchat-android-v5-theming/SKILL.md +2 -1
  39. package/skills/cometchat-android-v5-troubleshooting/SKILL.md +3 -2
  40. package/skills/cometchat-android-v6/SKILL.md +2 -1
  41. package/skills/cometchat-android-v6-builder-settings/SKILL.md +11 -7
  42. package/skills/cometchat-android-v6-calls/SKILL.md +79 -18
  43. package/skills/cometchat-android-v6-calls/references/advanced-features.md +87 -0
  44. package/skills/cometchat-android-v6-calls/references/call-layouts.md +24 -15
  45. package/skills/cometchat-android-v6-calls/references/call-session.md +2 -2
  46. package/skills/cometchat-android-v6-calls/references/device-management.md +17 -16
  47. package/skills/cometchat-android-v6-calls/references/idle-timeout.md +7 -4
  48. package/skills/cometchat-android-v6-calls/references/in-call-chat.md +13 -8
  49. package/skills/cometchat-android-v6-calls/references/raise-hand.md +6 -4
  50. package/skills/cometchat-android-v6-compose-components/SKILL.md +52 -29
  51. package/skills/cometchat-android-v6-compose-customization/SKILL.md +156 -1
  52. package/skills/cometchat-android-v6-compose-placement/SKILL.md +129 -40
  53. package/skills/cometchat-android-v6-compose-theming/SKILL.md +27 -1
  54. package/skills/cometchat-android-v6-core/SKILL.md +208 -28
  55. package/skills/cometchat-android-v6-events/SKILL.md +4 -1
  56. package/skills/cometchat-android-v6-extensions/SKILL.md +2 -1
  57. package/skills/cometchat-android-v6-features/SKILL.md +26 -2
  58. package/skills/cometchat-android-v6-kotlin-components/SKILL.md +31 -1
  59. package/skills/cometchat-android-v6-kotlin-customization/SKILL.md +172 -1
  60. package/skills/cometchat-android-v6-kotlin-placement/SKILL.md +20 -5
  61. package/skills/cometchat-android-v6-kotlin-theming/SKILL.md +36 -5
  62. package/skills/cometchat-android-v6-migration/SKILL.md +44 -42
  63. package/skills/cometchat-android-v6-production/SKILL.md +6 -3
  64. package/skills/cometchat-android-v6-push/SKILL.md +43 -2
  65. package/skills/cometchat-android-v6-testing/SKILL.md +11 -8
  66. package/skills/cometchat-android-v6-troubleshooting/SKILL.md +26 -5
  67. package/skills/cometchat-angular-calls/SKILL.md +256 -389
  68. package/skills/cometchat-angular-calls/references/add-calls-to-existing-chat.md +3 -2
  69. package/skills/cometchat-angular-calls/references/call-layouts.md +29 -12
  70. package/skills/cometchat-angular-calls/references/call-session.md +2 -2
  71. package/skills/cometchat-angular-calls/references/custom-ui.md +18 -10
  72. package/skills/cometchat-angular-calls/references/device-management.md +53 -34
  73. package/skills/cometchat-angular-calls/references/group-calls.md +45 -24
  74. package/skills/cometchat-angular-calls/references/idle-timeout.md +31 -15
  75. package/skills/cometchat-angular-calls/references/ngzone-and-async-callbacks.md +7 -6
  76. package/skills/cometchat-angular-calls/references/raise-hand.md +9 -4
  77. package/skills/cometchat-angular-calls/references/recording-screen-share.md +32 -39
  78. package/skills/cometchat-angular-calls/references/ringing-integration.md +3 -1
  79. package/skills/cometchat-angular-calls/references/share-invite.md +11 -5
  80. package/skills/cometchat-angular-calls/references/virtual-background.md +29 -0
  81. package/skills/cometchat-angular-components/SKILL.md +149 -620
  82. package/skills/cometchat-angular-core/SKILL.md +232 -312
  83. package/skills/cometchat-angular-customization/SKILL.md +415 -223
  84. package/skills/cometchat-angular-features/SKILL.md +216 -334
  85. package/skills/cometchat-angular-patterns/SKILL.md +168 -359
  86. package/skills/cometchat-angular-placement/SKILL.md +189 -560
  87. package/skills/cometchat-angular-production/SKILL.md +241 -92
  88. package/skills/cometchat-angular-push/SKILL.md +280 -294
  89. package/skills/cometchat-angular-testing/SKILL.md +430 -158
  90. package/skills/cometchat-angular-theming/SKILL.md +190 -265
  91. package/skills/cometchat-angular-troubleshooting/SKILL.md +192 -157
  92. package/skills/cometchat-astro-patterns/SKILL.md +3 -2
  93. package/skills/cometchat-calls/SKILL.md +25 -19
  94. package/skills/cometchat-calls/references/use-case-broadcast.md +15 -10
  95. package/skills/cometchat-calls/references/use-case-marketplace.md +2 -3
  96. package/skills/cometchat-calls/references/use-case-support.md +3 -4
  97. package/skills/cometchat-calls/references/use-case-team.md +23 -12
  98. package/skills/cometchat-calls/references/use-case-telehealth.md +3 -4
  99. package/skills/cometchat-components/SKILL.md +163 -25
  100. package/skills/cometchat-core/SKILL.md +258 -20
  101. package/skills/cometchat-customization/SKILL.md +50 -25
  102. package/skills/cometchat-features/SKILL.md +314 -35
  103. package/skills/cometchat-flutter-v5/SKILL.md +10 -4
  104. package/skills/cometchat-flutter-v5-calls/SKILL.md +188 -158
  105. package/skills/cometchat-flutter-v5-calls/references/add-calls-to-existing-chat.md +48 -24
  106. package/skills/cometchat-flutter-v5-calls/references/call-layouts.md +20 -15
  107. package/skills/cometchat-flutter-v5-calls/references/call-session.md +100 -145
  108. package/skills/cometchat-flutter-v5-calls/references/device-management.md +12 -8
  109. package/skills/cometchat-flutter-v5-calls/references/group-calls.md +30 -36
  110. package/skills/cometchat-flutter-v5-calls/references/idle-timeout.md +15 -13
  111. package/skills/cometchat-flutter-v5-calls/references/in-call-chat.md +12 -9
  112. package/skills/cometchat-flutter-v5-calls/references/migration-v4-to-v5.md +115 -65
  113. package/skills/cometchat-flutter-v5-calls/references/raise-hand.md +41 -30
  114. package/skills/cometchat-flutter-v5-calls/references/ringing-integration.md +17 -14
  115. package/skills/cometchat-flutter-v5-calls/references/share-invite.md +8 -2
  116. package/skills/cometchat-flutter-v5-conversations/SKILL.md +2 -1
  117. package/skills/cometchat-flutter-v5-core/SKILL.md +5 -4
  118. package/skills/cometchat-flutter-v5-customization/SKILL.md +136 -5
  119. package/skills/cometchat-flutter-v5-events/SKILL.md +2 -1
  120. package/skills/cometchat-flutter-v5-messages/SKILL.md +2 -1
  121. package/skills/cometchat-flutter-v5-production/SKILL.md +15 -6
  122. package/skills/cometchat-flutter-v5-push/SKILL.md +2 -1
  123. package/skills/cometchat-flutter-v5-testing/SKILL.md +17 -6
  124. package/skills/cometchat-flutter-v5-theming/SKILL.md +2 -1
  125. package/skills/cometchat-flutter-v5-troubleshooting/SKILL.md +7 -6
  126. package/skills/cometchat-flutter-v5-users-groups/SKILL.md +3 -2
  127. package/skills/cometchat-flutter-v6/SKILL.md +17 -16
  128. package/skills/cometchat-flutter-v6-calls/SKILL.md +72 -57
  129. package/skills/cometchat-flutter-v6-calls/references/add-calls-to-existing-chat.md +5 -3
  130. package/skills/cometchat-flutter-v6-calls/references/advanced-features.md +89 -0
  131. package/skills/cometchat-flutter-v6-calls/references/call-layouts.md +15 -12
  132. package/skills/cometchat-flutter-v6-calls/references/call-session.md +2 -2
  133. package/skills/cometchat-flutter-v6-calls/references/device-management.md +9 -3
  134. package/skills/cometchat-flutter-v6-calls/references/group-calls.md +10 -10
  135. package/skills/cometchat-flutter-v6-calls/references/idle-timeout.md +15 -7
  136. package/skills/cometchat-flutter-v6-calls/references/in-call-chat.md +6 -3
  137. package/skills/cometchat-flutter-v6-calls/references/raise-hand.md +23 -16
  138. package/skills/cometchat-flutter-v6-components/SKILL.md +32 -11
  139. package/skills/cometchat-flutter-v6-conversations/SKILL.md +39 -11
  140. package/skills/cometchat-flutter-v6-core/SKILL.md +182 -21
  141. package/skills/cometchat-flutter-v6-customization/SKILL.md +97 -25
  142. package/skills/cometchat-flutter-v6-events/SKILL.md +3 -2
  143. package/skills/cometchat-flutter-v6-features/SKILL.md +15 -6
  144. package/skills/cometchat-flutter-v6-messages/SKILL.md +111 -60
  145. package/skills/cometchat-flutter-v6-migration/SKILL.md +18 -25
  146. package/skills/cometchat-flutter-v6-placement/SKILL.md +79 -50
  147. package/skills/cometchat-flutter-v6-production/SKILL.md +13 -12
  148. package/skills/cometchat-flutter-v6-push/SKILL.md +41 -19
  149. package/skills/cometchat-flutter-v6-testing/SKILL.md +4 -4
  150. package/skills/cometchat-flutter-v6-theming/SKILL.md +38 -5
  151. package/skills/cometchat-flutter-v6-troubleshooting/SKILL.md +182 -17
  152. package/skills/cometchat-flutter-v6-users-groups/SKILL.md +12 -4
  153. package/skills/cometchat-i18n/SKILL.md +140 -79
  154. package/skills/cometchat-ios/SKILL.md +4 -2
  155. package/skills/cometchat-ios-calls/SKILL.md +225 -95
  156. package/skills/cometchat-ios-calls/references/add-calls-to-existing-chat.md +11 -9
  157. package/skills/cometchat-ios-calls/references/audio-modes-and-controls.md +45 -0
  158. package/skills/cometchat-ios-calls/references/avaudiosession-routing.md +6 -7
  159. package/skills/cometchat-ios-calls/references/call-layouts.md +31 -91
  160. package/skills/cometchat-ios-calls/references/call-session.md +51 -54
  161. package/skills/cometchat-ios-calls/references/callkit-and-pushkit.md +33 -29
  162. package/skills/cometchat-ios-calls/references/custom-ui.md +38 -38
  163. package/skills/cometchat-ios-calls/references/group-calls.md +33 -70
  164. package/skills/cometchat-ios-calls/references/idle-timeout.md +24 -25
  165. package/skills/cometchat-ios-calls/references/in-call-chat.md +19 -23
  166. package/skills/cometchat-ios-calls/references/migration-v4-to-v5.md +128 -70
  167. package/skills/cometchat-ios-calls/references/picture-in-picture.md +20 -20
  168. package/skills/cometchat-ios-calls/references/raise-hand.md +14 -227
  169. package/skills/cometchat-ios-calls/references/recording-screen-share.md +35 -122
  170. package/skills/cometchat-ios-calls/references/ringing-integration.md +17 -16
  171. package/skills/cometchat-ios-calls/references/share-invite.md +8 -12
  172. package/skills/cometchat-ios-calls/references/swiftui-uikit-hosting.md +4 -4
  173. package/skills/cometchat-ios-components/SKILL.md +200 -12
  174. package/skills/cometchat-ios-core/SKILL.md +173 -45
  175. package/skills/cometchat-ios-customization/SKILL.md +276 -110
  176. package/skills/cometchat-ios-features/SKILL.md +64 -36
  177. package/skills/cometchat-ios-placement/SKILL.md +15 -12
  178. package/skills/cometchat-ios-production/SKILL.md +12 -4
  179. package/skills/cometchat-ios-push/SKILL.md +53 -19
  180. package/skills/cometchat-ios-testing/SKILL.md +14 -9
  181. package/skills/cometchat-ios-theming/SKILL.md +39 -3
  182. package/skills/cometchat-ios-troubleshooting/SKILL.md +41 -21
  183. package/skills/cometchat-native-bare-patterns/SKILL.md +36 -19
  184. package/skills/cometchat-native-calls/SKILL.md +29 -17
  185. package/skills/cometchat-native-calls/references/add-calls-to-existing-chat.md +2 -2
  186. package/skills/cometchat-native-calls/references/call-layouts.md +15 -14
  187. package/skills/cometchat-native-calls/references/call-session.md +2 -2
  188. package/skills/cometchat-native-calls/references/custom-ui.md +12 -8
  189. package/skills/cometchat-native-calls/references/device-management.md +53 -30
  190. package/skills/cometchat-native-calls/references/group-calls.md +35 -30
  191. package/skills/cometchat-native-calls/references/idle-timeout.md +6 -6
  192. package/skills/cometchat-native-calls/references/in-call-chat.md +10 -8
  193. package/skills/cometchat-native-calls/references/migration-v4-to-v5.md +2 -2
  194. package/skills/cometchat-native-calls/references/raise-hand.md +15 -13
  195. package/skills/cometchat-native-calls/references/recording-screen-share.md +49 -170
  196. package/skills/cometchat-native-calls/references/share-invite.md +7 -5
  197. package/skills/cometchat-native-calls/references/voip-push-end-to-end.md +4 -2
  198. package/skills/cometchat-native-components/SKILL.md +84 -52
  199. package/skills/cometchat-native-core/SKILL.md +102 -33
  200. package/skills/cometchat-native-customization/SKILL.md +150 -28
  201. package/skills/cometchat-native-expo-patterns/SKILL.md +60 -29
  202. package/skills/cometchat-native-features/SKILL.md +24 -17
  203. package/skills/cometchat-native-placement/SKILL.md +19 -10
  204. package/skills/cometchat-native-production/SKILL.md +9 -3
  205. package/skills/cometchat-native-push/SKILL.md +2 -1
  206. package/skills/cometchat-native-testing/SKILL.md +1 -2
  207. package/skills/cometchat-native-theming/SKILL.md +54 -29
  208. package/skills/cometchat-native-troubleshooting/SKILL.md +11 -5
  209. package/skills/cometchat-nextjs-patterns/SKILL.md +22 -8
  210. package/skills/cometchat-placement/SKILL.md +42 -3
  211. package/skills/cometchat-production/SKILL.md +12 -5
  212. package/skills/cometchat-react-calls/SKILL.md +220 -10
  213. package/skills/cometchat-react-calls/references/add-calls-to-existing-chat.md +4 -3
  214. package/skills/cometchat-react-calls/references/call-layouts.md +5 -6
  215. package/skills/cometchat-react-calls/references/call-session.md +1 -1
  216. package/skills/cometchat-react-calls/references/custom-ui.md +61 -15
  217. package/skills/cometchat-react-calls/references/device-management.md +55 -51
  218. package/skills/cometchat-react-calls/references/group-calls.md +18 -23
  219. package/skills/cometchat-react-calls/references/idle-timeout.md +25 -12
  220. package/skills/cometchat-react-calls/references/in-call-chat.md +7 -7
  221. package/skills/cometchat-react-calls/references/migration-v4-to-v5.md +9 -11
  222. package/skills/cometchat-react-calls/references/raise-hand.md +14 -14
  223. package/skills/cometchat-react-calls/references/recording-screen-share.md +39 -38
  224. package/skills/cometchat-react-calls/references/ringing-integration.md +2 -2
  225. package/skills/cometchat-react-calls/references/share-invite.md +4 -5
  226. package/skills/cometchat-react-calls/references/testing-calls-on-web.md +20 -2
  227. package/skills/cometchat-react-calls/references/virtual-background.md +32 -0
  228. package/skills/cometchat-react-patterns/SKILL.md +45 -5
  229. package/skills/cometchat-react-push/SKILL.md +258 -72
  230. package/skills/cometchat-react-router-patterns/SKILL.md +12 -6
  231. package/skills/cometchat-react-testing/SKILL.md +14 -5
  232. package/skills/cometchat-theming/SKILL.md +181 -18
  233. package/skills/cometchat-troubleshooting/SKILL.md +40 -20
@@ -1,447 +1,256 @@
1
1
  ---
2
2
  name: cometchat-angular-patterns
3
- description: "Angular-specific integration patterns for CometChat UI Kit v4lazy loading, route guards, Angular Router integration, APP_INITIALIZER setup, standalone vs NgModule, and SSR/Universal considerations."
3
+ description: "Angular-specific integration patterns for CometChat UI Kit v5 (@cometchat/chat-uikit-angular@5) standalone bootstrap with main.ts init-before-bootstrap, functional route guards (CanActivateFn), lazy standalone routes (loadComponent), NgZone correctness for SDK callbacks, OnPush change detection, and SSR/Angular-Universal considerations."
4
4
  license: "MIT"
5
- compatibility: "Angular >=12 <=15; @cometchat/chat-uikit-angular ^4; @cometchat/chat-sdk-javascript ^4"
6
- allowed-tools: "shell, file-read, file-search, file-list, ask-user"
5
+ compatibility: "Angular 17–21 (standalone APIs); @cometchat/chat-uikit-angular ^5.0"
7
6
  metadata:
8
7
  author: "CometChat"
9
- version: "3.0.0"
10
- tags: "cometchat angular patterns routing lazy-loading guards app-initializer standalone ssr"
8
+ version: "4.0.0"
9
+ tags: "cometchat angular patterns routing lazy guards standalone bootstrap ssr ngzone v5"
11
10
  ---
12
11
 
13
- ## Purpose
12
+ > **Ground truth:** `@cometchat/chat-uikit-angular@5.x` (+ `@cometchat/calls-sdk-javascript@^5`) — installed package types + `ui-kit/angular`. **Official docs:** https://www.cometchat.com/docs/ui-kit/angular/overview · **Docs MCP:** `claude mcp add --transport http cometchat-docs https://www.cometchat.com/docs/mcp` (or fetch the URL directly without MCP). Verify symbols against the installed package/source before relying on them.
14
13
 
15
- Teaches Claude Angular-specific integration patterns for CometChat — how to wire init into Angular's bootstrap lifecycle, lazy-load the chat module, protect chat routes with guards, handle SSR/Universal, and integrate with Angular Material. Assumes a working base integration (see `cometchat-angular-core` + `cometchat-angular-placement`).
14
+ ## Purpose
16
15
 
17
- **Read `cometchat-angular-core` and `cometchat-angular-placement` first** — this skill builds on top of the base integration.
16
+ Angular-specific wiring for CometChat UI Kit **v5**how to hook init into Angular's standalone bootstrap, lazy-load chat routes, guard them, keep SDK callbacks inside Angular's zone, and handle SSR. Assumes the base integration from `cometchat-angular-core` + components from `cometchat-angular-components`.
18
17
 
19
- Ground truth: `docs/ui-kit/angular/getting-started`, Angular Router docs, `@cometchat/chat-uikit-angular@4.x` exports.
18
+ **v5 is standalone-first (Angular 17–21).** Everything below uses `bootstrapApplication` + `app.config.ts` + functional APIs. There is **no NgModule, no `AppModule`, no `declarations`, no `CUSTOM_ELEMENTS_SCHEMA`** — those are v4 patterns and must not appear in a v5 app.
20
19
 
21
20
  ---
22
21
 
23
- ## 1. APP_INITIALIZER pattern (production-grade init)
22
+ ## 1. Initialize in `main.ts` — before `bootstrapApplication`
24
23
 
25
- For production apps, use Angular's `APP_INITIALIZER` token to ensure CometChat is initialized before the app renders any component. This is cleaner than calling `init()` in `AppComponent.ngOnInit()`.
24
+ The v5 canonical (matches the kit's own sample app and the docs): call `CometChatUIKit.init()` in `main.ts` and bootstrap the Angular app **inside the resolved init promise**. This guarantees the SDK is ready before any `<cometchat-*>` component can mount. `init()` is a static method, so it works fine outside Angular's DI context.
26
25
 
27
26
  ```typescript
28
- // cometchat-init.service.ts
29
- import { Injectable } from "@angular/core";
30
- import { UIKitSettingsBuilder } from "@cometchat/uikit-shared";
31
- import { CometChatUIKit } from "@cometchat/chat-uikit-angular";
32
- import { environment } from "../environments/environment";
33
-
34
- @Injectable({ providedIn: "root" })
35
- export class CometChatInitService {
36
- private initialized = false;
37
-
38
- initialize(): Promise<void> {
39
- if (this.initialized) return Promise.resolve();
40
-
41
- const settings = new UIKitSettingsBuilder()
42
- .setAppId(environment.cometchat.appId)
43
- .setRegion(environment.cometchat.region)
44
- .setAuthKey(environment.cometchat.authKey)
45
- .subscribePresenceForAllUsers()
46
- .build();
47
-
48
- return CometChatUIKit.init(settings).then(() => {
49
- this.initialized = true;
50
- });
51
- }
52
- }
27
+ // src/main.ts
28
+ import { bootstrapApplication } from "@angular/platform-browser";
29
+ import { CometChatUIKit, UIKitSettingsBuilder } from "@cometchat/chat-uikit-angular";
30
+ import { AppComponent } from "./app/app.component";
31
+ import { appConfig } from "./app/app.config";
32
+ import { environment } from "./environments/environment";
33
+
34
+ const settings = new UIKitSettingsBuilder()
35
+ .setAppId(environment.cometchat.appId)
36
+ .setRegion(environment.cometchat.region)
37
+ .setAuthKey(environment.cometchat.authKey)
38
+ .subscribePresenceForAllUsers()
39
+ // .setCallingEnabled(true) // uncomment + install @cometchat/calls-sdk-javascript for voice/video
40
+ .build();
41
+
42
+ // `init(...)` is `Promise<InitResult> | undefined` (v5.0.2) — coalesce to a Promise so
43
+ // `.then`/`.catch` don't fail `tsc` strict (TS2532) on Angular 21.
44
+ (CometChatUIKit.init(settings) ?? Promise.resolve())
45
+ .then(() => {
46
+ bootstrapApplication(AppComponent, appConfig).catch((err) => console.error(err));
47
+ })
48
+ .catch((error) => {
49
+ console.error("CometChat UIKit init failed:", error);
50
+ // Still bootstrap so the app renders (it can show a "chat unavailable" state).
51
+ bootstrapApplication(AppComponent, appConfig).catch((err) => console.error(err));
52
+ });
53
53
  ```
54
54
 
55
55
  ```typescript
56
- // app.module.ts
57
- import { APP_INITIALIZER, NgModule } from "@angular/core";
58
- import { CometChatInitService } from "./cometchat-init.service";
59
-
60
- export function initCometChat(service: CometChatInitService): () => Promise<void> {
61
- return () => service.initialize();
62
- }
56
+ // src/app/app.config.ts — providers only; init does NOT live here
57
+ import { ApplicationConfig } from "@angular/core";
58
+ import { provideRouter } from "@angular/router";
59
+ import { routes } from "./app.routes";
63
60
 
64
- @NgModule({
65
- providers: [
66
- {
67
- provide: APP_INITIALIZER,
68
- useFactory: initCometChat,
69
- deps: [CometChatInitService],
70
- multi: true,
71
- },
72
- ],
73
- })
74
- export class AppModule {}
61
+ export const appConfig: ApplicationConfig = {
62
+ providers: [provideRouter(routes)],
63
+ };
75
64
  ```
76
65
 
77
- With `APP_INITIALIZER`, Angular waits for the init promise to resolve before bootstrapping the root component. No `*ngIf="isReady"` guard needed on the root template.
78
-
79
- **⚠️ `APP_INITIALIZER` blocks the entire app bootstrap.** If CometChat init fails (network error, wrong credentials), the app never renders. Add error handling:
80
-
81
66
  ```typescript
82
- initialize(): Promise<void> {
83
- return CometChatUIKit.init(settings).then(() => {
84
- this.initialized = true;
85
- }).catch((err) => {
86
- console.error("CometChat init failed:", err);
87
- // Don't re-throw let the app render and show an error state
88
- });
89
- }
67
+ // src/environments/environment.ts
68
+ export const environment = {
69
+ production: false,
70
+ cometchat: {
71
+ appId: "APP_ID", // Dashboard → Your App → Credentials
72
+ region: "REGION", // us | eu | in
73
+ authKey: "AUTH_KEY", // dev/testing only — use Auth Tokens in production
74
+ },
75
+ };
90
76
  ```
91
77
 
78
+ > Don't use `APP_INITIALIZER` for this. The kit's sample app and docs both init in `main.ts` and bootstrap inside `.then()` — that's the v5 canonical and avoids the DI-timing edge cases of an init factory provider. Always `.catch()` so a network/credential failure degrades gracefully instead of leaving a blank app.
79
+
92
80
  ---
93
81
 
94
- ## 2. Route guard for authenticated chat
82
+ ## 2. Login + functional route guard
95
83
 
96
- Protect chat routes so only logged-in users can access them.
84
+ Init readies the SDK; **login** establishes the session. Guard chat routes with a functional `CanActivateFn` (the v17+ idiom — no class guard, no `Injectable`). This mirrors the sample app's `authGuard`:
97
85
 
98
86
  ```typescript
99
- // cometchat-auth.guard.ts
100
- import { Injectable } from "@angular/core";
101
- import { CanActivate, Router } from "@angular/router";
102
- import { CometChatUIKit } from "@cometchat/chat-uikit-angular";
87
+ // src/app/guards/auth.guard.ts
88
+ import { CanActivateFn, Router } from "@angular/router";
89
+ import { inject } from "@angular/core";
90
+ import { CometChat } from "@cometchat/chat-sdk-javascript";
91
+
92
+ export const authGuard: CanActivateFn = async () => {
93
+ const router = inject(Router);
94
+ try {
95
+ const user = await CometChat.getLoggedinUser(); // async; note lowercase 'in'
96
+ if (user) return true;
97
+ return router.createUrlTree(["/login"]);
98
+ } catch {
99
+ return router.createUrlTree(["/login"]);
100
+ }
101
+ };
102
+ ```
103
103
 
104
- @Injectable({ providedIn: "root" })
105
- export class CometChatAuthGuard implements CanActivate {
106
- constructor(private router: Router) {}
104
+ For dev convenience you can auto-login a seeded user instead of redirecting:
107
105
 
108
- canActivate(): Promise<boolean> {
109
- return CometChatUIKit.getLoggedinUser().then((user) => {
110
- if (user) return true;
111
- this.router.navigate(["/login"]);
112
- return false;
113
- });
114
- }
106
+ ```typescript
107
+ import { CometChatUIKit } from "@cometchat/chat-uikit-angular";
108
+ // …inside the guard, when no user is found:
109
+ try {
110
+ await CometChatUIKit.login("cometchat-uid-1"); // bare UID string in v5 — NOT login({ uid })
111
+ return true;
112
+ } catch {
113
+ return router.createUrlTree(["/login"]);
115
114
  }
116
115
  ```
117
116
 
117
+ Two real session-check APIs exist; pick by context:
118
+ - `CometChat.getLoggedinUser()` / `CometChatUIKit.getLoggedinUser()` — **async** (returns `Promise<User | null>`, lowercase `in`). Use in guards/async flows. This is what the sample app guards use.
119
+ - `CometChatUIKit.getLoggedInUser()` — **sync** (returns `User | null`, capital `I`). Use inside components for a synchronous read after the session is known to exist.
120
+
118
121
  ```typescript
119
- // app-routing.module.ts
120
- import { CometChatAuthGuard } from "./cometchat-auth.guard";
122
+ // src/app/app.routes.ts
123
+ import { Routes } from "@angular/router";
124
+ import { authGuard } from "./guards/auth.guard";
121
125
 
122
126
  export const routes: Routes = [
123
127
  {
124
128
  path: "chat",
125
- canActivate: [CometChatAuthGuard],
126
- loadChildren: () => import("./chat/chat.module").then((m) => m.ChatModule),
129
+ canActivate: [authGuard],
130
+ // Lazy-load a standalone component — no NgModule, no loadChildren:
131
+ loadComponent: () => import("./chat/chat.component").then((m) => m.ChatComponent),
127
132
  },
128
- { path: "login", component: LoginComponent },
133
+ { path: "", redirectTo: "chat", pathMatch: "full" },
129
134
  ];
130
135
  ```
131
136
 
132
137
  ---
133
138
 
134
- ## 3. Lazy loading the chat module
139
+ ## 3. Lazy-loaded standalone chat route
135
140
 
136
- For apps where chat is a secondary feature, lazy-load the CometChat module to keep the initial bundle small.
141
+ The chat surface is a standalone component that imports only the CometChat components it renders.
137
142
 
138
143
  ```typescript
139
- // chat/chat.module.ts
140
- import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from "@angular/core";
141
- import { RouterModule, Routes } from "@angular/router";
142
- import { CommonModule } from "@angular/common";
144
+ // chat/chat.component.ts
145
+ import { Component } from "@angular/core";
143
146
  import {
144
- CometChatConversations,
145
- CometChatMessageHeader,
146
- CometChatMessageList,
147
- CometChatMessageComposer,
147
+ CometChatConversationsComponent,
148
+ CometChatMessageHeaderComponent,
149
+ CometChatMessageListComponent,
150
+ CometChatMessageComposerComponent,
148
151
  } from "@cometchat/chat-uikit-angular";
149
- import { ConversationsComponent } from "./conversations/conversations.component";
150
- import { MessagesComponent } from "./messages/messages.component";
151
-
152
- const routes: Routes = [
153
- { path: "", component: ConversationsComponent },
154
- { path: "messages/user/:uid", component: MessagesComponent },
155
- { path: "messages/group/:guid", component: MessagesComponent },
156
- ];
152
+ import { CometChat } from "@cometchat/chat-sdk-javascript";
157
153
 
158
- @NgModule({
154
+ @Component({
155
+ selector: "app-chat",
156
+ standalone: true,
159
157
  imports: [
160
- CommonModule,
161
- RouterModule.forChild(routes),
162
- CometChatConversations,
163
- CometChatMessageHeader,
164
- CometChatMessageList,
165
- CometChatMessageComposer,
158
+ CometChatConversationsComponent,
159
+ CometChatMessageHeaderComponent,
160
+ CometChatMessageListComponent,
161
+ CometChatMessageComposerComponent,
166
162
  ],
167
- declarations: [ConversationsComponent, MessagesComponent],
168
- schemas: [CUSTOM_ELEMENTS_SCHEMA],
163
+ templateUrl: "./chat.component.html",
169
164
  })
170
- export class ChatModule {}
171
- ```
165
+ export class ChatComponent {
166
+ selectedUser?: CometChat.User;
172
167
 
173
- ```typescript
174
- // app-routing.module.ts
175
- export const routes: Routes = [
176
- {
177
- path: "chat",
178
- loadChildren: () => import("./chat/chat.module").then((m) => m.ChatModule),
179
- },
180
- ];
168
+ onConversation(conversation: CometChat.Conversation) {
169
+ const entity = conversation.getConversationWith();
170
+ if (entity instanceof CometChat.User) this.selectedUser = entity;
171
+ }
172
+ }
181
173
  ```
182
174
 
183
- **⚠️ CometChat init must still happen at the app root level**, not inside the lazy-loaded module. The `APP_INITIALIZER` pattern 1) or `AppComponent.ngOnInit()` ensures init completes before the lazy module loads.
175
+ `loadComponent` (not `loadChildren`) is the standalone way to lazy-load there's no feature NgModule to point at.
184
176
 
185
177
  ---
186
178
 
187
- ## Standalone components with Angular Router (Angular 14+)
179
+ ## 4. NgZone keep SDK callbacks inside Angular's zone
188
180
 
189
- For apps using standalone components (no NgModule), wire routing directly:
181
+ CometChat SDK callbacks (event listeners, Promise resolutions from non-Angular timers) can fire **outside** Angular's zone, so a view bound to the result won't update until the next tick. If a UI value set inside an SDK callback isn't refreshing, re-enter the zone:
190
182
 
191
183
  ```typescript
192
- // main.ts
193
- import { bootstrapApplication } from "@angular/platform-browser";
194
- import { provideRouter } from "@angular/router";
195
- import { provideAnimations } from "@angular/platform-browser/animations";
196
- import { APP_INITIALIZER } from "@angular/core";
197
- import { AppComponent } from "./app/app.component";
198
- import { routes } from "./app/app.routes";
199
- import { CometChatInitService } from "./app/cometchat-init.service";
200
-
201
- bootstrapApplication(AppComponent, {
202
- providers: [
203
- provideRouter(routes),
204
- provideAnimations(),
205
- {
206
- provide: APP_INITIALIZER,
207
- useFactory: (service: CometChatInitService) => () => service.initialize(),
208
- deps: [CometChatInitService],
209
- multi: true,
210
- },
211
- ],
212
- });
213
- ```
214
-
215
- ```typescript
216
- // app.routes.ts
217
- import { Routes } from "@angular/router";
218
-
219
- export const routes: Routes = [
220
- {
221
- path: "chat",
222
- loadComponent: () =>
223
- import("./chat/conversations.component").then((m) => m.ConversationsComponent),
224
- },
225
- {
226
- path: "messages/user/:uid",
227
- loadComponent: () =>
228
- import("./chat/messages.component").then((m) => m.MessagesComponent),
229
- },
230
- ];
231
- ```
232
-
233
- ---
234
-
235
- ## 5. Login flow integration
236
-
237
- Wire CometChat login to your app's existing auth flow.
238
-
239
- ### Pattern A — Login on app startup (dev mode)
240
-
241
- ```typescript
242
- // app.component.ts
243
- import { Component, OnInit } from "@angular/core";
244
- import { CometChatUIKit } from "@cometchat/chat-uikit-angular";
245
-
246
- @Component({ selector: "app-root", templateUrl: "./app.component.html" })
247
- export class AppComponent implements OnInit {
248
- isReady = false;
249
-
250
- ngOnInit(): void {
251
- // CometChat.init() already called via APP_INITIALIZER
252
- CometChatUIKit.getLoggedinUser()
253
- .then((user) => {
254
- if (!user) {
255
- return CometChatUIKit.login({ uid: "cometchat-uid-1" });
256
- }
257
- return user;
258
- })
259
- .then(() => (this.isReady = true))
260
- .catch(console.error);
184
+ import { Component, NgZone } from "@angular/core";
185
+ import { CometChat } from "@cometchat/chat-sdk-javascript";
186
+
187
+ @Component({ /* */ })
188
+ export class PresenceComponent {
189
+ status = "offline";
190
+ constructor(private zone: NgZone) {}
191
+
192
+ ngOnInit() {
193
+ CometChat.addUserListener("presence", new CometChat.UserListener({
194
+ onUserOnline: (user: CometChat.User) =>
195
+ this.zone.run(() => { this.status = "online"; }), // ← re-enter zone
196
+ onUserOffline: (user: CometChat.User) =>
197
+ this.zone.run(() => { this.status = "offline"; }),
198
+ }));
261
199
  }
262
200
  }
263
201
  ```
264
202
 
265
- ### Pattern BLogin after your app's auth (production)
266
-
267
- ```typescript
268
- // auth.service.ts
269
- import { Injectable } from "@angular/core";
270
- import { HttpClient } from "@angular/common/http";
271
- import { CometChatUIKit } from "@cometchat/chat-uikit-angular";
272
- import { environment } from "../environments/environment";
273
-
274
- @Injectable({ providedIn: "root" })
275
- export class AuthService {
276
- constructor(private http: HttpClient) {}
277
-
278
- loginWithCometChat(appJwt: string): Promise<void> {
279
- // 1. Fetch CometChat auth token from your backend
280
- return this.http
281
- .post<{ authToken: string }>(environment.cometchat.tokenEndpoint, {}, {
282
- headers: { Authorization: `Bearer ${appJwt}` },
283
- })
284
- .toPromise()
285
- .then((response) => {
286
- // 2. Login with the auth token
287
- return CometChatUIKit.login({ authToken: response!.authToken });
288
- })
289
- .then(() => {
290
- // 3. CometChat session established
291
- });
292
- }
293
-
294
- logout(): Promise<void> {
295
- return CometChatUIKit.logout();
296
- }
297
- }
298
- ```
203
+ The kit's own `<cometchat-*>` components handle this internally you only need `zone.run()` for **your own** code that mutates view state inside an SDK callback. Prefer the kit's `@Output`s where they exist (they're already zone-correct). Alternatively, consume `CometChatUIKit.loggedInUser$` (an RxJS observable) with the `async` pipe — observables integrate with change detection cleanly.
299
204
 
300
205
  ---
301
206
 
302
- ## 6. Angular Material integration
303
-
304
- CometChat works alongside Angular Material. Common integration points:
305
-
306
- ### Theming coexistence
307
-
308
- CometChat uses its own `CometChatThemeService` — it does NOT read from Angular Material's theme. Set both independently:
309
-
310
- ```typescript
311
- // app.component.ts
312
- import { Component } from "@angular/core";
313
- import { CometChatThemeService } from "@cometchat/chat-uikit-angular";
314
-
315
- @Component({ selector: "app-root", templateUrl: "./app.component.html" })
316
- export class AppComponent {
317
- constructor(private cometChatTheme: CometChatThemeService) {
318
- // Set CometChat palette to match your Material theme's primary color
319
- cometChatTheme.theme.palette.setPrimary({ light: "#6200EE", dark: "#BB86FC" });
320
- cometChatTheme.theme.palette.setMode("light");
321
- }
322
- }
323
- ```
207
+ ## 5. OnPush change detection
324
208
 
325
- ### MatSidenav + CometChat sidebar
326
-
327
- ```html
328
- <!-- app.component.html -->
329
- <mat-sidenav-container style="height: 100vh;">
330
- <mat-sidenav mode="side" opened style="width: 320px;">
331
- <cometchat-conversations
332
- [onItemClick]="handleConvClick"
333
- style="height: 100%;"
334
- ></cometchat-conversations>
335
- </mat-sidenav>
336
- <mat-sidenav-content style="display: flex; flex-direction: column;">
337
- <cometchat-message-header [user]="selectedUser" [hideBackButton]="true"></cometchat-message-header>
338
- <cometchat-message-list [user]="selectedUser" style="flex: 1; overflow: hidden;"></cometchat-message-list>
339
- <cometchat-message-composer [user]="selectedUser"></cometchat-message-composer>
340
- </mat-sidenav-content>
341
- </mat-sidenav-container>
342
- ```
209
+ CometChat components are heavy; if your host component uses `ChangeDetectionStrategy.OnPush`, pass **immutable** references — reassign `selectedUser`/`selectedGroup` (a new object) rather than mutating, so OnPush detects the change. Binding the same mutated object won't trigger a re-render. (This mirrors the React "new reference per update" rule.)
343
210
 
344
211
  ---
345
212
 
346
- ## 7. SSR / Angular Universal considerations
213
+ ## 6. SSR / Angular Universal
214
+
215
+ CometChat is a **browser-only** SDK (WebSocket + IndexedDB + `window`). It must not run during server-side rendering. The recommended setup is `ng new --ssr false` (per the docs) — but if your app already uses `@angular/ssr`, keep CometChat off the server.
347
216
 
348
- CometChat's UI Kit uses browser APIs (`window`, `document`, `localStorage`) that are not available in Node.js during SSR. If the project uses Angular Universal:
217
+ - **Don't** call `CometChatUIKit.init()` / render `<cometchat-*>` on the server. Because init lives in `main.ts` (§1), gate it on the platform — `main.ts` runs in both the browser and server entry under SSR:
349
218
 
350
219
  ```typescript
351
- // cometchat-init.service.ts
220
+ // src/main.ts (SSR-safe)
352
221
  import { isPlatformBrowser } from "@angular/common";
353
- import { PLATFORM_ID, Inject } from "@angular/core";
354
-
355
- @Injectable({ providedIn: "root" })
356
- export class CometChatInitService {
357
- constructor(@Inject(PLATFORM_ID) private platformId: object) {}
358
-
359
- initialize(): Promise<void> {
360
- // Skip CometChat init on the server
361
- if (!isPlatformBrowser(this.platformId)) {
362
- return Promise.resolve();
363
- }
364
- // ... normal init
365
- }
366
- }
367
- ```
222
+ import { PLATFORM_ID } from "@angular/core";
368
223
 
369
- ```typescript
370
- // In any component that renders CometChat components:
371
- @Component({
372
- template: `
373
- <ng-container *ngIf="isBrowser">
374
- <cometchat-conversations></cometchat-conversations>
375
- </ng-container>
376
- `,
377
- })
378
- export class ChatComponent {
379
- isBrowser: boolean;
380
- constructor(@Inject(PLATFORM_ID) platformId: object) {
381
- this.isBrowser = isPlatformBrowser(platformId);
382
- }
224
+ // bootstrap once, unconditionally:
225
+ function boot() {
226
+ bootstrapApplication(AppComponent, appConfig).catch((err) => console.error(err));
383
227
  }
384
- ```
385
-
386
- **⚠️ CometChat components must not render during SSR.** They use browser APIs that throw in Node.js. Always guard with `isPlatformBrowser()`.
387
-
388
- ---
389
-
390
- ## 8. Change detection optimization
391
228
 
392
- CometChat components use Angular's default change detection. For performance-sensitive apps using `OnPush`:
393
-
394
- ```typescript
395
- @Component({
396
- changeDetection: ChangeDetectionStrategy.OnPush,
397
- template: `
398
- <cometchat-conversations
399
- [onItemClick]="handleConvClick"
400
- ></cometchat-conversations>
401
- `,
402
- })
403
- export class ChatComponent {
404
- constructor(private cdr: ChangeDetectorRef) {}
405
-
406
- handleConvClick = (conversation: CometChat.Conversation): void => {
407
- // Update component state
408
- this.selectedConversation = conversation;
409
- // Trigger change detection manually when using OnPush
410
- this.cdr.markForCheck();
411
- };
229
+ if (typeof window === "undefined") {
230
+ boot(); // server render — skip CometChat init entirely
231
+ } else {
232
+ (CometChatUIKit.init(settings) ?? Promise.resolve()).then(boot).catch((e) => { console.error(e); boot(); });
412
233
  }
413
234
  ```
414
235
 
415
- CometChat components themselves use default change detection internally — `OnPush` on the parent component is fine as long as you call `markForCheck()` after updating state from CometChat callbacks.
416
-
417
- ---
418
-
419
- ## 9. Anti-patterns
420
-
421
- 1. **Do NOT call `CometChatUIKit.init()` inside a lazy-loaded module.** Init must complete before any `<cometchat-*>` component renders. Use `APP_INITIALIZER` at the root level.
422
-
423
- 2. **Do NOT use `ChangeDetectionStrategy.OnPush` without calling `markForCheck()` after CometChat callbacks.** CometChat callbacks run outside Angular's zone — without `markForCheck()`, the view won't update.
424
-
425
- 3. **Do NOT import CometChat components in `AppModule` if they're only used in a lazy-loaded feature module.** Import them in the feature module to keep the initial bundle small.
426
-
427
- 4. **Do NOT skip `isPlatformBrowser()` guard in SSR apps.** CometChat uses browser APIs that crash in Node.js.
428
-
429
- 5. **Do NOT use `window.location.reload()` after login.** This is a common pattern in CometChat examples but it's an anti-pattern in Angular — use Angular Router navigation instead.
430
-
431
- 6. **Do NOT forget `CUSTOM_ELEMENTS_SCHEMA` in every module/component that uses `<cometchat-*>` tags.** Each standalone component and each NgModule needs it independently.
236
+ (Inside Angular providers/components, use `isPlatformBrowser(inject(PLATFORM_ID))` for the same guard.)
237
+ - Lazy-load the chat route (`loadComponent`) so the kit's bundle never enters the server build's initial chunk.
238
+ - With `@angular/ssr`, render the chat route client-side only (it's behind the auth guard + browser check above).
432
239
 
433
240
  ---
434
241
 
435
- ## Skill routing reference
436
-
437
- | Skill | When to route |
438
- |---|---|
439
- | `cometchat-angular-core` | Init, login, module setupalways first |
440
- | `cometchat-angular-components` | Component prop reference |
441
- | `cometchat-angular-placement` | Where to put chat (route / sidebar / modal / tab) |
442
- | `cometchat-angular-patterns` | This skillAngular-specific wiring (guards, lazy loading, SSR) |
443
- | `cometchat-angular-theming` | CometChatThemeService + palette |
444
- | `cometchat-angular-features` | Calls, extensions, AI |
445
- | `cometchat-angular-customization` | Custom slot views, formatters, event bus |
446
- | `cometchat-angular-production` | Server-minted auth tokens |
447
- | `cometchat-angular-troubleshooting` | Build errors, runtime failures, SSR crashes |
242
+ ## 7. Anti-patterns
243
+
244
+ 1. **Don't use NgModule wiring** (`@NgModule`, `AppModule`, `declarations`, `forRoot`, `CUSTOM_ELEMENTS_SCHEMA`) — those are v4. v5 is standalone: `app.config.ts` providers + `imports: []` on standalone components.
245
+ 2. **Don't put `CometChatUIKit.init()` in `APP_INITIALIZER`** — the v5 canonical inits in `main.ts` and bootstraps inside the resolved promise. `app.config.ts` carries providers only.
246
+ 3. **Don't use a class `CanActivate` guard** when a functional `CanActivateFn` is cleaner (v17+). Match the standalone idiom no `Injectable` guard class.
247
+ 4. **Don't init on the server** — gate `main.ts` init on the platform (`typeof window`/`isPlatformBrowser`).
248
+ 5. **Don't forget `zone.run()`** around view-state mutations inside raw SDK listener callbacks or use `loggedInUser$` + `async` pipe.
249
+ 6. **Don't `loadChildren` a chat NgModule**there isn't one; `loadComponent` a standalone component.
250
+ 7. **Don't call `login({ uid })`** — v5 takes a bare UID string (see `cometchat-angular-core`).
251
+
252
+ ## Pointers
253
+ - `cometchat-angular-core` init/login, standalone setup, env
254
+ - `cometchat-angular-components` the component catalog
255
+ - `cometchat-angular-placement` — where to mount chat (route/modal/drawer)
256
+ - `cometchat-angular-production` — server-minted auth tokens