@cometchat/skills 3.0.0 → 4.0.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.
- package/LICENSE +21 -0
- package/README.md +44 -17
- package/bin/install.js +389 -43
- package/package.json +19 -9
- package/skills/cometchat/SKILL.md +1066 -265
- package/skills/cometchat-android-v5/SKILL.md +120 -0
- package/skills/cometchat-android-v5-components/SKILL.md +430 -0
- package/skills/cometchat-android-v5-core/SKILL.md +468 -0
- package/skills/cometchat-android-v5-customization/SKILL.md +305 -0
- package/skills/cometchat-android-v5-extensions/SKILL.md +124 -0
- package/skills/cometchat-android-v5-features/SKILL.md +130 -0
- package/skills/cometchat-android-v5-placement/SKILL.md +276 -0
- package/skills/cometchat-android-v5-production/SKILL.md +94 -0
- package/skills/cometchat-android-v5-push/SKILL.md +620 -0
- package/skills/cometchat-android-v5-testing/SKILL.md +187 -0
- package/skills/cometchat-android-v5-theming/SKILL.md +166 -0
- package/skills/cometchat-android-v5-troubleshooting/SKILL.md +73 -0
- package/skills/cometchat-android-v6/SKILL.md +107 -0
- package/skills/cometchat-android-v6-builder-settings/SKILL.md +145 -0
- package/skills/cometchat-android-v6-compose-components/SKILL.md +202 -0
- package/skills/cometchat-android-v6-compose-customization/SKILL.md +280 -0
- package/skills/cometchat-android-v6-compose-placement/SKILL.md +213 -0
- package/skills/cometchat-android-v6-compose-theming/SKILL.md +224 -0
- package/skills/cometchat-android-v6-core/SKILL.md +354 -0
- package/skills/cometchat-android-v6-events/SKILL.md +212 -0
- package/skills/cometchat-android-v6-extensions/SKILL.md +191 -0
- package/skills/cometchat-android-v6-features/SKILL.md +130 -0
- package/skills/cometchat-android-v6-kotlin-components/SKILL.md +197 -0
- package/skills/cometchat-android-v6-kotlin-customization/SKILL.md +268 -0
- package/skills/cometchat-android-v6-kotlin-placement/SKILL.md +248 -0
- package/skills/cometchat-android-v6-kotlin-theming/SKILL.md +202 -0
- package/skills/cometchat-android-v6-production/SKILL.md +187 -0
- package/skills/cometchat-android-v6-push/SKILL.md +274 -0
- package/skills/cometchat-android-v6-testing/SKILL.md +279 -0
- package/skills/cometchat-android-v6-troubleshooting/SKILL.md +249 -0
- package/skills/cometchat-angular-components/SKILL.md +706 -0
- package/skills/cometchat-angular-core/SKILL.md +444 -0
- package/skills/cometchat-angular-customization/SKILL.md +424 -0
- package/skills/cometchat-angular-features/SKILL.md +447 -0
- package/skills/cometchat-angular-patterns/SKILL.md +447 -0
- package/skills/cometchat-angular-placement/SKILL.md +685 -0
- package/skills/cometchat-angular-production/SKILL.md +415 -0
- package/skills/cometchat-angular-theming/SKILL.md +365 -0
- package/skills/cometchat-angular-troubleshooting/SKILL.md +329 -0
- package/skills/cometchat-astro-patterns/SKILL.md +3 -3
- package/skills/cometchat-components/SKILL.md +11 -0
- package/skills/cometchat-core/SKILL.md +11 -6
- package/skills/cometchat-customization/references/component-catalog.md +1 -1
- package/skills/cometchat-features/SKILL.md +176 -108
- package/skills/cometchat-flutter-v5/SKILL.md +167 -0
- package/skills/cometchat-flutter-v5-calls/SKILL.md +192 -0
- package/skills/cometchat-flutter-v5-conversations/SKILL.md +117 -0
- package/skills/cometchat-flutter-v5-core/SKILL.md +221 -0
- package/skills/cometchat-flutter-v5-customization/SKILL.md +227 -0
- package/skills/cometchat-flutter-v5-events/SKILL.md +155 -0
- package/skills/cometchat-flutter-v5-messages/SKILL.md +258 -0
- package/skills/cometchat-flutter-v5-production/SKILL.md +207 -0
- package/skills/cometchat-flutter-v5-push/SKILL.md +284 -0
- package/skills/cometchat-flutter-v5-theming/SKILL.md +160 -0
- package/skills/cometchat-flutter-v5-troubleshooting/SKILL.md +129 -0
- package/skills/cometchat-flutter-v5-users-groups/SKILL.md +151 -0
- package/skills/cometchat-flutter-v6/SKILL.md +445 -0
- package/skills/cometchat-flutter-v6-calls/SKILL.md +333 -0
- package/skills/cometchat-flutter-v6-components/SKILL.md +365 -0
- package/skills/cometchat-flutter-v6-conversations/SKILL.md +210 -0
- package/skills/cometchat-flutter-v6-core/SKILL.md +305 -0
- package/skills/cometchat-flutter-v6-customization/SKILL.md +666 -0
- package/skills/cometchat-flutter-v6-events/SKILL.md +216 -0
- package/skills/cometchat-flutter-v6-features/SKILL.md +406 -0
- package/skills/cometchat-flutter-v6-messages/SKILL.md +333 -0
- package/skills/cometchat-flutter-v6-migration/SKILL.md +381 -0
- package/skills/cometchat-flutter-v6-placement/SKILL.md +398 -0
- package/skills/cometchat-flutter-v6-production/SKILL.md +632 -0
- package/skills/cometchat-flutter-v6-theming/SKILL.md +260 -0
- package/skills/cometchat-flutter-v6-troubleshooting/SKILL.md +726 -0
- package/skills/cometchat-flutter-v6-users-groups/SKILL.md +216 -0
- package/skills/cometchat-ios/SKILL.md +323 -0
- package/skills/cometchat-ios-components/SKILL.md +651 -0
- package/skills/cometchat-ios-core/SKILL.md +822 -0
- package/skills/cometchat-ios-customization/SKILL.md +825 -0
- package/skills/cometchat-ios-features/SKILL.md +725 -0
- package/skills/cometchat-ios-placement/SKILL.md +750 -0
- package/skills/cometchat-ios-production/SKILL.md +730 -0
- package/skills/cometchat-ios-push/SKILL.md +582 -0
- package/skills/cometchat-ios-theming/SKILL.md +631 -0
- package/skills/cometchat-ios-troubleshooting/SKILL.md +983 -0
- package/skills/cometchat-native-bare-patterns/SKILL.md +470 -0
- package/skills/cometchat-native-components/SKILL.md +594 -0
- package/skills/cometchat-native-core/SKILL.md +407 -0
- package/skills/cometchat-native-customization/SKILL.md +594 -0
- package/skills/cometchat-native-expo-patterns/SKILL.md +485 -0
- package/skills/cometchat-native-features/SKILL.md +608 -0
- package/skills/cometchat-native-placement/SKILL.md +500 -0
- package/skills/cometchat-native-production/SKILL.md +694 -0
- package/skills/cometchat-native-push/SKILL.md +593 -0
- package/skills/cometchat-native-testing/SKILL.md +583 -0
- package/skills/cometchat-native-theming/SKILL.md +656 -0
- package/skills/cometchat-native-troubleshooting/SKILL.md +433 -0
- package/skills/cometchat-nextjs-patterns/SKILL.md +5 -5
- package/skills/cometchat-production/SKILL.md +60 -0
- package/skills/cometchat-react-router-patterns/SKILL.md +23 -21
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cometchat-angular-core
|
|
3
|
+
description: "Foundational rules for CometChat Angular UI Kit v4 integration — UIKitSettingsBuilder init pattern, login order, CometChatThemeService, environment config via src/environments/environment.ts, and anti-patterns that break real Angular apps."
|
|
4
|
+
license: "MIT"
|
|
5
|
+
compatibility: "Angular >=12 <=15; @cometchat/chat-uikit-angular ^4; @cometchat/chat-sdk-javascript ^4"
|
|
6
|
+
allowed-tools: "executeBash, readFile, fileSearch, listDirectory, AskUserQuestion"
|
|
7
|
+
metadata:
|
|
8
|
+
author: "CometChat"
|
|
9
|
+
version: "3.0.0"
|
|
10
|
+
tags: "cometchat angular typescript core init login uikit-wb-source environment provider"
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Purpose
|
|
14
|
+
|
|
15
|
+
This is the foundational skill for every CometChat Angular UI Kit v4 integration using the shared `uikit-wb-source` internally. It teaches Claude HOW CometChat works in Angular — initialization order, UIKitSettingsBuilder pattern, login, environment config, module imports, and the anti-patterns that break real apps.
|
|
16
|
+
|
|
17
|
+
**Supported Angular versions: 12, 13, 14, and 15.** Angular 16+ (Signals / standalone-first) is not covered by this skill set.
|
|
18
|
+
|
|
19
|
+
**Read this skill first, before any placement or patterns skill.**
|
|
20
|
+
|
|
21
|
+
Ground truth: `docs/ui-kit/angular/getting-started`, `docs/ui-kit/angular/methods`, `@cometchat/chat-uikit-angular@4.x` exports, `@cometchat/uikit-shared` exports, `@cometchat/uikit-resources` exports.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## 1. The init-login-render order
|
|
26
|
+
|
|
27
|
+
CometChat Angular has exactly one valid lifecycle:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
CometChatUIKit.init(UIKitSettings) → CometChatUIKit.login({ uid }) → render <cometchat-*> components
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Breaking this order produces a blank component, a "CometChat is not initialized" console error, or a hung login. No exceptions.
|
|
34
|
+
|
|
35
|
+
### UIKitSettingsBuilder — the Angular init pattern
|
|
36
|
+
|
|
37
|
+
The Angular UI Kit uses `UIKitSettingsBuilder` from `@cometchat/uikit-shared` (unlike React Native which uses a flat object). Always use the builder:
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { UIKitSettingsBuilder } from "@cometchat/uikit-shared";
|
|
41
|
+
import { CometChatUIKit } from "@cometchat/chat-uikit-angular";
|
|
42
|
+
import { environment } from "../environments/environment";
|
|
43
|
+
|
|
44
|
+
const UIKitSettings = new UIKitSettingsBuilder()
|
|
45
|
+
.setAppId(environment.cometchat.appId)
|
|
46
|
+
.setRegion(environment.cometchat.region)
|
|
47
|
+
.setAuthKey(environment.cometchat.authKey) // dev only — omit in production
|
|
48
|
+
.subscribePresenceForAllUsers()
|
|
49
|
+
.build();
|
|
50
|
+
|
|
51
|
+
CometChatUIKit.init(UIKitSettings)
|
|
52
|
+
.then(() => {
|
|
53
|
+
console.log("CometChat initialized");
|
|
54
|
+
// Now safe to call login
|
|
55
|
+
})
|
|
56
|
+
.catch(console.error);
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**⚠️ `UIKitSettingsBuilder` is the Angular pattern.** Unlike React Native (which uses a flat object), Angular's UI Kit requires the builder chain. Passing a plain object to `CometChatUIKit.init()` will fail silently or throw a type error.
|
|
60
|
+
|
|
61
|
+
### Init must happen once, before the app bootstraps
|
|
62
|
+
|
|
63
|
+
The correct place is `app.component.ts`'s `ngOnInit` or a dedicated `AppInitService` called from `APP_INITIALIZER`. Do NOT call `init()` inside a lazy-loaded module or a component that mounts after routing — by then, components that depend on CometChat may already be rendering.
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
// app.component.ts
|
|
67
|
+
import { Component, OnInit } from "@angular/core";
|
|
68
|
+
import { UIKitSettingsBuilder } from "@cometchat/uikit-shared";
|
|
69
|
+
import { CometChatUIKit } from "@cometchat/chat-uikit-angular";
|
|
70
|
+
import { environment } from "../environments/environment";
|
|
71
|
+
|
|
72
|
+
@Component({
|
|
73
|
+
selector: "app-root",
|
|
74
|
+
templateUrl: "./app.component.html",
|
|
75
|
+
})
|
|
76
|
+
export class AppComponent implements OnInit {
|
|
77
|
+
isReady = false;
|
|
78
|
+
|
|
79
|
+
ngOnInit(): void {
|
|
80
|
+
const settings = new UIKitSettingsBuilder()
|
|
81
|
+
.setAppId(environment.cometchat.appId)
|
|
82
|
+
.setRegion(environment.cometchat.region)
|
|
83
|
+
.setAuthKey(environment.cometchat.authKey)
|
|
84
|
+
.subscribePresenceForAllUsers()
|
|
85
|
+
.build();
|
|
86
|
+
|
|
87
|
+
CometChatUIKit.init(settings)
|
|
88
|
+
.then(() => CometChatUIKit.getLoggedinUser())
|
|
89
|
+
.then((user) => {
|
|
90
|
+
if (!user) {
|
|
91
|
+
return CometChatUIKit.login({ uid: "cometchat-uid-1" });
|
|
92
|
+
}
|
|
93
|
+
return user;
|
|
94
|
+
})
|
|
95
|
+
.then(() => {
|
|
96
|
+
this.isReady = true;
|
|
97
|
+
})
|
|
98
|
+
.catch(console.error);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
```html
|
|
104
|
+
<!-- app.component.html -->
|
|
105
|
+
<ng-container *ngIf="isReady">
|
|
106
|
+
<router-outlet></router-outlet>
|
|
107
|
+
</ng-container>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Gate the router outlet (or any CometChat component) on `isReady`. Rendering `<cometchat-*>` before init + login completes produces blank components.
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## 2. Login
|
|
115
|
+
|
|
116
|
+
### Development mode
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
import { CometChatUIKit } from "@cometchat/chat-uikit-angular";
|
|
120
|
+
|
|
121
|
+
CometChatUIKit.getLoggedinUser().then((user) => {
|
|
122
|
+
if (!user) {
|
|
123
|
+
CometChatUIKit.login({ uid: "cometchat-uid-1" })
|
|
124
|
+
.then((loggedInUser) => {
|
|
125
|
+
console.log("Login successful:", loggedInUser);
|
|
126
|
+
})
|
|
127
|
+
.catch(console.error);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Every new CometChat app ships 5 pre-seeded test users — `cometchat-uid-1` through `cometchat-uid-5`. Use one for development.
|
|
133
|
+
|
|
134
|
+
**⚠️ `login()` takes an object `{ uid: "..." }`, not a bare string.** Passing `"cometchat-uid-1"` directly throws a type error in TypeScript and silently fails in JavaScript.
|
|
135
|
+
|
|
136
|
+
### Getting the current logged-in user
|
|
137
|
+
|
|
138
|
+
Two getters exist for different contexts:
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
// Async — use inside the init/login flow or APP_INITIALIZER
|
|
142
|
+
const user = await CometChatUIKit.getLoggedinUser(); // note lowercase 'i' in 'in'
|
|
143
|
+
const myUid = user?.getUid();
|
|
144
|
+
|
|
145
|
+
// Sync — use in guards, components, and anywhere after login completes
|
|
146
|
+
import { CometChatUIKitLoginListener } from "@cometchat/chat-uikit-angular";
|
|
147
|
+
const user = CometChatUIKitLoginListener.getLoggedInUser(); // note capital 'I' in 'In'
|
|
148
|
+
const myUid = user?.getUid();
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
**Default to the sync version** in components and route guards — by the time they run, login is already complete. Use the async version only inside the init/login flow itself.
|
|
152
|
+
|
|
153
|
+
**Never hardcode a UID** to identify the logged-in user in app logic. Always use one of these getters — in production the UID comes from your auth system, not a test string.
|
|
154
|
+
|
|
155
|
+
### Production mode
|
|
156
|
+
|
|
157
|
+
Use `CometChatUIKit.login({ authToken: "..." })` with a token from your backend. The backend generates the token with the CometChat REST API using the server-only **REST API Key**. See `cometchat-angular-production` for the server-side token endpoint patterns.
|
|
158
|
+
|
|
159
|
+
### Logout
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
CometChatUIKit.logout().then(() => {
|
|
163
|
+
// Navigate to login page
|
|
164
|
+
});
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## 3. Module setup (mandatory)
|
|
170
|
+
|
|
171
|
+
Angular requires explicit module imports. Every CometChat component must be imported in the module where it's used.
|
|
172
|
+
|
|
173
|
+
### AppModule setup
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
// app.module.ts
|
|
177
|
+
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from "@angular/core";
|
|
178
|
+
import { BrowserModule } from "@angular/platform-browser";
|
|
179
|
+
import { BrowserAnimationsModule } from "@angular/platform-browser/animations";
|
|
180
|
+
import {
|
|
181
|
+
CometChatConversationsWithMessages,
|
|
182
|
+
CometChatConversations,
|
|
183
|
+
CometChatMessages,
|
|
184
|
+
CometChatMessageHeader,
|
|
185
|
+
CometChatMessageList,
|
|
186
|
+
CometChatMessageComposer,
|
|
187
|
+
CometChatUsers,
|
|
188
|
+
CometChatGroups,
|
|
189
|
+
} from "@cometchat/chat-uikit-angular";
|
|
190
|
+
import { AppComponent } from "./app.component";
|
|
191
|
+
|
|
192
|
+
@NgModule({
|
|
193
|
+
imports: [
|
|
194
|
+
BrowserModule,
|
|
195
|
+
BrowserAnimationsModule,
|
|
196
|
+
// Import only the CometChat components you use
|
|
197
|
+
CometChatConversationsWithMessages,
|
|
198
|
+
CometChatConversations,
|
|
199
|
+
CometChatMessages,
|
|
200
|
+
CometChatMessageHeader,
|
|
201
|
+
CometChatMessageList,
|
|
202
|
+
CometChatMessageComposer,
|
|
203
|
+
CometChatUsers,
|
|
204
|
+
CometChatGroups,
|
|
205
|
+
],
|
|
206
|
+
declarations: [AppComponent],
|
|
207
|
+
providers: [],
|
|
208
|
+
bootstrap: [AppComponent],
|
|
209
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA], // Required for web components
|
|
210
|
+
})
|
|
211
|
+
export class AppModule {}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
**⚠️ `CUSTOM_ELEMENTS_SCHEMA` is required.** Without it, Angular throws "Unknown element" errors for every `<cometchat-*>` tag. Add it to every module that uses CometChat components.
|
|
215
|
+
|
|
216
|
+
### Standalone component setup (Angular 14+)
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
// chat.component.ts
|
|
220
|
+
import { Component } from "@angular/core";
|
|
221
|
+
import { CommonModule } from "@angular/common";
|
|
222
|
+
import { CometChatConversations } from "@cometchat/chat-uikit-angular";
|
|
223
|
+
import { CUSTOM_ELEMENTS_SCHEMA } from "@angular/core";
|
|
224
|
+
|
|
225
|
+
@Component({
|
|
226
|
+
selector: "app-chat",
|
|
227
|
+
standalone: true,
|
|
228
|
+
imports: [CommonModule, CometChatConversations],
|
|
229
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
|
230
|
+
template: `<cometchat-conversations></cometchat-conversations>`,
|
|
231
|
+
})
|
|
232
|
+
export class ChatComponent {}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## 4. Assets configuration (mandatory)
|
|
238
|
+
|
|
239
|
+
The Angular UI Kit ships icon assets that must be linked in `angular.json`. Without this, icons render as broken images.
|
|
240
|
+
|
|
241
|
+
```json
|
|
242
|
+
// angular.json — inside build.options.assets
|
|
243
|
+
"assets": [
|
|
244
|
+
"src/favicon.ico",
|
|
245
|
+
"src/assets",
|
|
246
|
+
{
|
|
247
|
+
"glob": "**/*",
|
|
248
|
+
"input": "./node_modules/@cometchat/chat-uikit-angular/assets/",
|
|
249
|
+
"output": "assets/"
|
|
250
|
+
}
|
|
251
|
+
]
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
**⚠️ Missing assets config = broken icons throughout the UI Kit.** This is the most commonly missed setup step. Always verify `angular.json` before debugging icon issues.
|
|
255
|
+
|
|
256
|
+
---
|
|
257
|
+
|
|
258
|
+
## 5. Environment variables
|
|
259
|
+
|
|
260
|
+
Angular does not use `.env` files or `process.env`. Configuration lives in `src/environments/environment.ts` (TypeScript constant objects).
|
|
261
|
+
|
|
262
|
+
### Environment file structure
|
|
263
|
+
|
|
264
|
+
```typescript
|
|
265
|
+
// src/environments/environment.ts (development)
|
|
266
|
+
export const environment = {
|
|
267
|
+
production: false,
|
|
268
|
+
cometchat: {
|
|
269
|
+
appId: "YOUR_APP_ID",
|
|
270
|
+
region: "us", // "us" | "eu" | "in"
|
|
271
|
+
authKey: "YOUR_AUTH_KEY", // dev only — never in production builds
|
|
272
|
+
},
|
|
273
|
+
};
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
```typescript
|
|
277
|
+
// src/environments/environment.prod.ts (production)
|
|
278
|
+
export const environment = {
|
|
279
|
+
production: true,
|
|
280
|
+
cometchat: {
|
|
281
|
+
appId: "YOUR_APP_ID",
|
|
282
|
+
region: "us",
|
|
283
|
+
// No authKey in production — use server-minted auth tokens
|
|
284
|
+
tokenEndpoint: "https://api.yourapp.com/cometchat-token",
|
|
285
|
+
},
|
|
286
|
+
};
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
**⚠️ Never put `REST_API_KEY` in any environment file.** Angular bundles `environment.ts` into the client-side JavaScript. The REST API Key is server-only — it lives in your backend's environment variables, never in the Angular app.
|
|
290
|
+
|
|
291
|
+
### Using environment values
|
|
292
|
+
|
|
293
|
+
```typescript
|
|
294
|
+
import { environment } from "../environments/environment";
|
|
295
|
+
|
|
296
|
+
// In your component or service:
|
|
297
|
+
const appId = environment.cometchat.appId;
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
Angular's build system automatically swaps `environment.ts` for `environment.prod.ts` when building with `--configuration production`.
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
## 6. CometChatThemeService
|
|
305
|
+
|
|
306
|
+
The Angular UI Kit uses `CometChatThemeService` (injected via Angular's DI) to control the palette. Inject it in your root component's constructor.
|
|
307
|
+
|
|
308
|
+
```typescript
|
|
309
|
+
import { Component } from "@angular/core";
|
|
310
|
+
import { CometChatThemeService } from "@cometchat/chat-uikit-angular";
|
|
311
|
+
|
|
312
|
+
@Component({ selector: "app-root", templateUrl: "./app.component.html" })
|
|
313
|
+
export class AppComponent {
|
|
314
|
+
constructor(private themeService: CometChatThemeService) {
|
|
315
|
+
// Set mode: "light" | "dark"
|
|
316
|
+
themeService.theme.palette.setMode("light");
|
|
317
|
+
// Set primary brand color
|
|
318
|
+
themeService.theme.palette.setPrimary({ light: "#6851D6", dark: "#6851D6" });
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
`CometChatThemeService` is a singleton provided at the root level — inject it once in `AppComponent` and the theme applies globally. See `cometchat-angular-theming` for the full token reference.
|
|
324
|
+
|
|
325
|
+
---
|
|
326
|
+
|
|
327
|
+
## 7. Package installation
|
|
328
|
+
|
|
329
|
+
```bash
|
|
330
|
+
npm install @cometchat/chat-uikit-angular
|
|
331
|
+
npm install @cometchat/uikit-elements @cometchat/uikit-resources @cometchat/uikit-shared
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
The UI Kit depends on `@cometchat/chat-sdk-javascript` (installed automatically as a peer dep). Do NOT install `@cometchat/chat-sdk-javascript` separately unless you need a specific version — let the UI Kit manage it.
|
|
335
|
+
|
|
336
|
+
### Peer dependencies
|
|
337
|
+
|
|
338
|
+
```bash
|
|
339
|
+
# Required for Angular animations (used by some UI Kit components)
|
|
340
|
+
npm install @angular/animations
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
Ensure `BrowserAnimationsModule` is imported in `AppModule` (see § 3).
|
|
344
|
+
|
|
345
|
+
---
|
|
346
|
+
|
|
347
|
+
## 8. Anti-patterns
|
|
348
|
+
|
|
349
|
+
1. **Do NOT call `CometChatUIKit.init()` inside a lazy-loaded module.** Init must complete before any `<cometchat-*>` component renders. Lazy-loaded modules mount after routing, which is too late.
|
|
350
|
+
|
|
351
|
+
2. **Do NOT use a flat settings object with `CometChatUIKit.init()`.** Angular requires `UIKitSettingsBuilder` from `@cometchat/uikit-shared`. The flat-object pattern is React Native only.
|
|
352
|
+
|
|
353
|
+
3. **Do NOT omit `CUSTOM_ELEMENTS_SCHEMA` from the module.** Every module that declares a component using `<cometchat-*>` tags needs it.
|
|
354
|
+
|
|
355
|
+
4. **Do NOT skip the assets config in `angular.json`.** Icons will be broken without it.
|
|
356
|
+
|
|
357
|
+
5. **Do NOT put `authKey` in `environment.prod.ts`.** Use server-minted auth tokens in production. See `cometchat-angular-production`.
|
|
358
|
+
|
|
359
|
+
6. **Do NOT render `<cometchat-*>` components before `isReady`.** Gate on the init + login promise resolving. Use `*ngIf="isReady"` on the container.
|
|
360
|
+
|
|
361
|
+
7. **Do NOT call `login()` with a bare string.** It takes `{ uid: "..." }` or `{ authToken: "..." }`.
|
|
362
|
+
|
|
363
|
+
8. **Do NOT import `@cometchat/chat-sdk-javascript` directly** unless you need SDK-level access (e.g., `CometChat.getUser(uid)`). The UI Kit re-exports the SDK's `CometChat` namespace — import from `@cometchat/chat-sdk-javascript` only when you need the raw SDK.
|
|
364
|
+
|
|
365
|
+
9. **Do NOT forget `BrowserAnimationsModule`** in `AppModule`. Some UI Kit components use Angular animations; missing this module causes runtime errors.
|
|
366
|
+
|
|
367
|
+
10. **Do NOT bundle `REST_API_KEY` in any Angular file.** Angular bundles everything in `src/` into the client JavaScript. Server-only keys belong on your backend.
|
|
368
|
+
|
|
369
|
+
---
|
|
370
|
+
|
|
371
|
+
## 9. i18n, RTL, and accessibility
|
|
372
|
+
|
|
373
|
+
### i18n (translations)
|
|
374
|
+
|
|
375
|
+
The Angular UI Kit ships `CometChatLocalize` for built-in translations (~40 languages). Initialize it once alongside `CometChatUIKit.init()`:
|
|
376
|
+
|
|
377
|
+
```typescript
|
|
378
|
+
import { CometChatLocalize } from "@cometchat/chat-uikit-angular";
|
|
379
|
+
|
|
380
|
+
// In AppComponent.ngOnInit, after init resolves:
|
|
381
|
+
CometChatLocalize.init("es"); // "fr", "de", "ar", "hi", etc.
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
To override specific strings, pass a resources object as the second positional argument:
|
|
385
|
+
|
|
386
|
+
```typescript
|
|
387
|
+
CometChatLocalize.init("en", {
|
|
388
|
+
en: {
|
|
389
|
+
"type a message": "Write your message…",
|
|
390
|
+
},
|
|
391
|
+
});
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
### RTL (right-to-left)
|
|
395
|
+
|
|
396
|
+
The UI Kit reads `dir="rtl"` from the document root. Set it in `index.html` or toggle it dynamically:
|
|
397
|
+
|
|
398
|
+
```html
|
|
399
|
+
<!-- index.html -->
|
|
400
|
+
<html dir="rtl" lang="ar">
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
```typescript
|
|
404
|
+
// Toggle dynamically:
|
|
405
|
+
document.documentElement.setAttribute("dir", isRtl ? "rtl" : "ltr");
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
CometChat components flip automatically — no CometChat-specific config needed.
|
|
409
|
+
|
|
410
|
+
### Accessibility
|
|
411
|
+
|
|
412
|
+
Default components ship with `aria-label` on icon-only buttons, `role="listbox"` on lists, and keyboard navigation (`Tab`, `Enter`, `Esc`). When writing custom `ng-template` slot views:
|
|
413
|
+
|
|
414
|
+
1. **Icon-only buttons** — add `aria-label="<verb>"` (e.g. `aria-label="Send message"`)
|
|
415
|
+
2. **Custom list items** — keep `role="option"` + `aria-selected` on the wrapper
|
|
416
|
+
3. **Color overrides** — verify text contrast ≥ 4.5:1 against background
|
|
417
|
+
|
|
418
|
+
---
|
|
419
|
+
|
|
420
|
+
## 10. Docs MCP (recommended, not required)
|
|
421
|
+
|
|
422
|
+
The CometChat docs MCP gives runtime access to the most current Angular UI Kit docs. Install:
|
|
423
|
+
|
|
424
|
+
```bash
|
|
425
|
+
claude mcp add --transport http cometchat-docs https://www.cometchat.com/docs/mcp
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
Use the MCP to verify prop names, callback signatures, theme token names, or error message meanings before writing any non-obvious code.
|
|
429
|
+
|
|
430
|
+
---
|
|
431
|
+
|
|
432
|
+
## Skill routing reference
|
|
433
|
+
|
|
434
|
+
| Skill | When to load |
|
|
435
|
+
|---|---|
|
|
436
|
+
| `cometchat-angular-core` | Always — before any integration code |
|
|
437
|
+
| `cometchat-angular-components` | Always — before writing any `<cometchat-*>` HTML |
|
|
438
|
+
| `cometchat-angular-placement` | When integrating — for placement patterns |
|
|
439
|
+
| `cometchat-angular-patterns` | For Angular-specific routing and module wiring |
|
|
440
|
+
| `cometchat-angular-theming` | When customizing colors, dark mode, typography |
|
|
441
|
+
| `cometchat-angular-features` | When adding calls, extensions, AI |
|
|
442
|
+
| `cometchat-angular-customization` | When customizing components (slot views, formatters, builders) |
|
|
443
|
+
| `cometchat-angular-production` | When setting up server-side auth + user management |
|
|
444
|
+
| `cometchat-angular-troubleshooting` | When diagnosing build errors, runtime failures |
|