@cometchat/skills-cli 2.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.
Files changed (95) hide show
  1. package/README.md +70 -0
  2. package/bin/cometchat.mjs +7 -0
  3. package/dist/index.js +4395 -0
  4. package/dist/registry/schemas/template.schema.json +142 -0
  5. package/dist/registry/v6/experiences/1-conversation-list/astro.template.json +89 -0
  6. package/dist/registry/v6/experiences/1-conversation-list/nextjs-pages.template.json +83 -0
  7. package/dist/registry/v6/experiences/1-conversation-list/nextjs.template.json +83 -0
  8. package/dist/registry/v6/experiences/1-conversation-list/react-router.template.json +102 -0
  9. package/dist/registry/v6/experiences/1-conversation-list/reactjs.template.json +86 -0
  10. package/dist/registry/v6/experiences/1-conversation-list/templates/astro/ChatApp.css.tpl +39 -0
  11. package/dist/registry/v6/experiences/1-conversation-list/templates/astro/ChatApp.tsx.tpl +86 -0
  12. package/dist/registry/v6/experiences/1-conversation-list/templates/astro/CometChatSelector.tsx.tpl +40 -0
  13. package/dist/registry/v6/experiences/1-conversation-list/templates/astro/chat.astro.tpl +17 -0
  14. package/dist/registry/v6/experiences/1-conversation-list/templates/nextjs/CometChatNoSSR.css.tpl +39 -0
  15. package/dist/registry/v6/experiences/1-conversation-list/templates/nextjs/CometChatNoSSR.tsx.tpl +86 -0
  16. package/dist/registry/v6/experiences/1-conversation-list/templates/nextjs/CometChatSelector.tsx.tpl +41 -0
  17. package/dist/registry/v6/experiences/1-conversation-list/templates/nextjs/chat-page.tsx.tpl +11 -0
  18. package/dist/registry/v6/experiences/1-conversation-list/templates/nextjs-pages/CometChatNoSSR.css.tpl +39 -0
  19. package/dist/registry/v6/experiences/1-conversation-list/templates/nextjs-pages/CometChatNoSSR.tsx.tpl +88 -0
  20. package/dist/registry/v6/experiences/1-conversation-list/templates/nextjs-pages/CometChatSelector.tsx.tpl +41 -0
  21. package/dist/registry/v6/experiences/1-conversation-list/templates/nextjs-pages/chat-page.tsx.tpl +15 -0
  22. package/dist/registry/v6/experiences/1-conversation-list/templates/react-router/CometChat-route.tsx.tpl +22 -0
  23. package/dist/registry/v6/experiences/1-conversation-list/templates/react-router/CometChatNoSSR.css.tpl +39 -0
  24. package/dist/registry/v6/experiences/1-conversation-list/templates/react-router/CometChatNoSSR.tsx.tpl +87 -0
  25. package/dist/registry/v6/experiences/1-conversation-list/templates/react-router/CometChatSelector.tsx.tpl +40 -0
  26. package/dist/registry/v6/experiences/1-conversation-list/templates/reactjs/App.css.tpl +32 -0
  27. package/dist/registry/v6/experiences/1-conversation-list/templates/reactjs/App.tsx.tpl +55 -0
  28. package/dist/registry/v6/experiences/1-conversation-list/templates/reactjs/CometChatSelector.tsx.tpl +40 -0
  29. package/dist/registry/v6/experiences/1-conversation-list/templates/reactjs/main.tsx.tpl +46 -0
  30. package/dist/registry/v6/experiences/2-one-to-one/astro.template.json +81 -0
  31. package/dist/registry/v6/experiences/2-one-to-one/nextjs.template.json +77 -0
  32. package/dist/registry/v6/experiences/2-one-to-one/react-router.template.json +93 -0
  33. package/dist/registry/v6/experiences/2-one-to-one/reactjs.template.json +77 -0
  34. package/dist/registry/v6/experiences/2-one-to-one/templates/astro/ChatApp.css.tpl +21 -0
  35. package/dist/registry/v6/experiences/2-one-to-one/templates/astro/ChatApp.tsx.tpl +66 -0
  36. package/dist/registry/v6/experiences/2-one-to-one/templates/astro/chat.astro.tpl +17 -0
  37. package/dist/registry/v6/experiences/2-one-to-one/templates/nextjs/CometChatNoSSR.css.tpl +21 -0
  38. package/dist/registry/v6/experiences/2-one-to-one/templates/nextjs/CometChatNoSSR.tsx.tpl +66 -0
  39. package/dist/registry/v6/experiences/2-one-to-one/templates/nextjs/chat-page.tsx.tpl +11 -0
  40. package/dist/registry/v6/experiences/2-one-to-one/templates/react-router/CometChat-route.tsx.tpl +21 -0
  41. package/dist/registry/v6/experiences/2-one-to-one/templates/react-router/CometChatNoSSR.css.tpl +21 -0
  42. package/dist/registry/v6/experiences/2-one-to-one/templates/react-router/CometChatNoSSR.tsx.tpl +67 -0
  43. package/dist/registry/v6/experiences/2-one-to-one/templates/reactjs/App.css.tpl +4 -0
  44. package/dist/registry/v6/experiences/2-one-to-one/templates/reactjs/App.tsx.tpl +44 -0
  45. package/dist/registry/v6/experiences/2-one-to-one/templates/reactjs/main.tsx.tpl +46 -0
  46. package/dist/registry/v6/experiences/3-tab-based/astro.template.json +93 -0
  47. package/dist/registry/v6/experiences/3-tab-based/nextjs.template.json +90 -0
  48. package/dist/registry/v6/experiences/3-tab-based/react-router.template.json +105 -0
  49. package/dist/registry/v6/experiences/3-tab-based/reactjs.template.json +90 -0
  50. package/dist/registry/v6/experiences/3-tab-based/templates/astro/ChatApp.css.tpl +39 -0
  51. package/dist/registry/v6/experiences/3-tab-based/templates/astro/ChatApp.tsx.tpl +93 -0
  52. package/dist/registry/v6/experiences/3-tab-based/templates/astro/CometChatTabs.css.tpl +43 -0
  53. package/dist/registry/v6/experiences/3-tab-based/templates/astro/CometChatTabs.tsx.tpl +72 -0
  54. package/dist/registry/v6/experiences/3-tab-based/templates/astro/chat.astro.tpl +17 -0
  55. package/dist/registry/v6/experiences/3-tab-based/templates/nextjs/CometChatNoSSR.css.tpl +39 -0
  56. package/dist/registry/v6/experiences/3-tab-based/templates/nextjs/CometChatNoSSR.tsx.tpl +93 -0
  57. package/dist/registry/v6/experiences/3-tab-based/templates/nextjs/CometChatTabs.css.tpl +43 -0
  58. package/dist/registry/v6/experiences/3-tab-based/templates/nextjs/CometChatTabs.tsx.tpl +73 -0
  59. package/dist/registry/v6/experiences/3-tab-based/templates/nextjs/chat-page.tsx.tpl +11 -0
  60. package/dist/registry/v6/experiences/3-tab-based/templates/react-router/CometChat-route.tsx.tpl +21 -0
  61. package/dist/registry/v6/experiences/3-tab-based/templates/react-router/CometChatNoSSR.css.tpl +39 -0
  62. package/dist/registry/v6/experiences/3-tab-based/templates/react-router/CometChatNoSSR.tsx.tpl +94 -0
  63. package/dist/registry/v6/experiences/3-tab-based/templates/react-router/CometChatTabs.css.tpl +43 -0
  64. package/dist/registry/v6/experiences/3-tab-based/templates/react-router/CometChatTabs.tsx.tpl +72 -0
  65. package/dist/registry/v6/experiences/3-tab-based/templates/reactjs/App.css.tpl +7 -0
  66. package/dist/registry/v6/experiences/3-tab-based/templates/reactjs/App.tsx.tpl +62 -0
  67. package/dist/registry/v6/experiences/3-tab-based/templates/reactjs/CometChatTabs.css.tpl +43 -0
  68. package/dist/registry/v6/experiences/3-tab-based/templates/reactjs/CometChatTabs.tsx.tpl +72 -0
  69. package/dist/registry/v6/experiences/3-tab-based/templates/reactjs/main.tsx.tpl +46 -0
  70. package/dist/registry/v6/features/catalog.json +344 -0
  71. package/dist/registry/v6/production/astro/cometchat-token.ts.tpl +86 -0
  72. package/dist/registry/v6/production/astro.template.json +51 -0
  73. package/dist/registry/v6/production/nextjs/route.ts.tpl +79 -0
  74. package/dist/registry/v6/production/nextjs.template.json +50 -0
  75. package/dist/registry/v6/production/react-router/api.cometchat-token.ts.tpl +73 -0
  76. package/dist/registry/v6/production/react-router.template.json +58 -0
  77. package/dist/registry/v6/user-mgmt/astro/cometchat-user.ts.tpl +164 -0
  78. package/dist/registry/v6/user-mgmt/astro.template.json +33 -0
  79. package/dist/registry/v6/user-mgmt/nextjs/route.ts.tpl +212 -0
  80. package/dist/registry/v6/user-mgmt/nextjs.template.json +57 -0
  81. package/dist/registry/v6/user-mgmt/react-router/api.cometchat-user.ts.tpl +176 -0
  82. package/dist/registry/v6/user-mgmt/react-router.template.json +40 -0
  83. package/dist/registry/v6/widget/astro/CometChatWidget.css.tpl +105 -0
  84. package/dist/registry/v6/widget/astro/CometChatWidget.tsx.tpl +88 -0
  85. package/dist/registry/v6/widget/astro.template.json +38 -0
  86. package/dist/registry/v6/widget/nextjs/CometChatWidget.css.tpl +105 -0
  87. package/dist/registry/v6/widget/nextjs/CometChatWidget.tsx.tpl +88 -0
  88. package/dist/registry/v6/widget/nextjs.template.json +40 -0
  89. package/dist/registry/v6/widget/react-router/CometChatWidget.css.tpl +105 -0
  90. package/dist/registry/v6/widget/react-router/CometChatWidget.tsx.tpl +98 -0
  91. package/dist/registry/v6/widget/react-router.template.json +36 -0
  92. package/dist/registry/v6/widget/reactjs/CometChatWidget.css.tpl +105 -0
  93. package/dist/registry/v6/widget/reactjs/CometChatWidget.tsx.tpl +89 -0
  94. package/dist/registry/v6/widget/reactjs.template.json +36 -0
  95. package/package.json +53 -0
@@ -0,0 +1,40 @@
1
+ import { useEffect, useState } from "react";
2
+ import { CometChat } from "@cometchat/chat-sdk-javascript";
3
+ import {
4
+ CometChatConversations,
5
+ CometChatUIKitLoginListener,
6
+ } from "@cometchat/chat-uikit-react";
7
+
8
+ interface SelectorProps {
9
+ onSelectorItemClicked?: (
10
+ input: CometChat.Conversation | CometChat.User | CometChat.Group,
11
+ type: string
12
+ ) => void;
13
+ }
14
+
15
+ export const CometChatSelector = ({
16
+ onSelectorItemClicked = () => {},
17
+ }: SelectorProps) => {
18
+ const [loggedInUser, setLoggedInUser] = useState<CometChat.User | null>(null);
19
+ const [activeConversation, setActiveConversation] = useState<
20
+ CometChat.Conversation | undefined
21
+ >();
22
+
23
+ useEffect(() => {
24
+ setLoggedInUser(CometChatUIKitLoginListener.getLoggedInUser());
25
+ }, []);
26
+
27
+ return (
28
+ <>
29
+ {loggedInUser && (
30
+ <CometChatConversations
31
+ activeConversation={activeConversation}
32
+ onItemClick={(e) => {
33
+ setActiveConversation(e);
34
+ onSelectorItemClicked(e, "updateSelectedItem");
35
+ }}
36
+ />
37
+ )}
38
+ </>
39
+ );
40
+ };
@@ -0,0 +1,32 @@
1
+ /* CometChat layout — IMPORTANT: read this before customizing.
2
+ *
3
+ * The CometChat React UI Kit v6 wraps every component in a `<div class="cometchat">`
4
+ * which does NOT set `height: 100%`. CSS flex with `flex: 1` alone WILL NOT propagate
5
+ * height through this wrapper, so the message list (which uses `overflow: hidden auto`
6
+ * + `height: 100%` internally) collapses to content size — disabling scroll and
7
+ * showing messages from the top instead of bottom-anchored.
8
+ *
9
+ * The required workaround is to give EVERY ancestor of `.cometchat-message-list` an
10
+ * explicit fixed height. That's why this stylesheet sets:
11
+ * - #root → 100vh / 100vw (anchor the whole layout in the viewport)
12
+ * - .conversations-with-messages → height: 100% from #root
13
+ * - .conversations-wrapper → height: 100vh (fixed left panel)
14
+ * - .messages-wrapper → height: 100% (right panel inherits from the
15
+ * flex parent which has 100vh)
16
+ *
17
+ * If you customize this layout, every container in the chain from <html> down to
18
+ * the message list MUST have a resolved height. If you switch to inline styles or
19
+ * a different parent component, give the chat container a fixed pixel/viewport
20
+ * height OR measure it with a ResizeObserver and set it imperatively.
21
+ *
22
+ * If you see "blank panel where messages should be" or "messages stuck at top
23
+ * instead of scrolling to bottom", this is the bug. See:
24
+ * https://www.cometchat.com/docs/ui-kit/react/components-overview
25
+ */
26
+ #root { width: 100vw; height: 100vh; }
27
+ .conversations-with-messages { display: flex; height: 100%; width: 100%; }
28
+ .conversations-wrapper { height: 100vh; width: 480px; overflow: hidden; display: flex; flex-direction: column; }
29
+ .conversations-wrapper > .cometchat { overflow: hidden; }
30
+ .messages-wrapper { width: 100%; height: 100%; display: flex; flex-direction: column; }
31
+ .empty-conversation { height: 100vh; width: 100%; display: flex; justify-content: center; align-items: center; background: var(--cometchat-background-color-03, #F5F5F5); color: var(--cometchat-text-color-secondary, #727272); font: var(--cometchat-font-body-regular, 400 14px Roboto); }
32
+ .cometchat .cometchat-message-composer { border-radius: 0; }
@@ -0,0 +1,55 @@
1
+ import { useState } from "react";
2
+ import {
3
+ CometChatMessageComposer,
4
+ CometChatMessageHeader,
5
+ CometChatMessageList,
6
+ } from "@cometchat/chat-uikit-react";
7
+ import { CometChat } from "@cometchat/chat-sdk-javascript";
8
+ import { CometChatSelector } from "./cometchat/CometChatSelector";
9
+ import "./App.css";
10
+
11
+ function App() {
12
+ const [selectedUser, setSelectedUser] = useState<
13
+ CometChat.User | undefined
14
+ >();
15
+ const [selectedGroup, setSelectedGroup] = useState<
16
+ CometChat.Group | undefined
17
+ >();
18
+
19
+ return (
20
+ <div className="conversations-with-messages">
21
+ <div className="conversations-wrapper">
22
+ <CometChatSelector
23
+ onSelectorItemClicked={(activeItem) => {
24
+ const item =
25
+ activeItem instanceof CometChat.Conversation
26
+ ? activeItem.getConversationWith()
27
+ : activeItem;
28
+ if (item instanceof CometChat.User) {
29
+ setSelectedUser(item);
30
+ setSelectedGroup(undefined);
31
+ } else if (item instanceof CometChat.Group) {
32
+ setSelectedUser(undefined);
33
+ setSelectedGroup(item);
34
+ }
35
+ }}
36
+ />
37
+ </div>
38
+ {selectedUser || selectedGroup ? (
39
+ <div className="messages-wrapper">
40
+ {selectedUser && <CometChatMessageHeader user={selectedUser} />}
41
+ {selectedGroup && <CometChatMessageHeader group={selectedGroup} />}
42
+ {selectedUser && <CometChatMessageList user={selectedUser} />}
43
+ {selectedGroup && <CometChatMessageList group={selectedGroup} />}
44
+ {selectedUser && <CometChatMessageComposer user={selectedUser} />}
45
+ {selectedGroup && <CometChatMessageComposer group={selectedGroup} />}
46
+ </div>
47
+ ) : (
48
+ <div className="empty-conversation">
49
+ Select a conversation to start chatting
50
+ </div>
51
+ )}
52
+ </div>
53
+ );
54
+ }
55
+ export default App;
@@ -0,0 +1,40 @@
1
+ import { useEffect, useState } from "react";
2
+ import { CometChat } from "@cometchat/chat-sdk-javascript";
3
+ import {
4
+ CometChatConversations,
5
+ CometChatUIKitLoginListener,
6
+ } from "@cometchat/chat-uikit-react";
7
+
8
+ interface SelectorProps {
9
+ onSelectorItemClicked?: (
10
+ input: CometChat.Conversation | CometChat.User | CometChat.Group,
11
+ type: string
12
+ ) => void;
13
+ }
14
+
15
+ export const CometChatSelector = ({
16
+ onSelectorItemClicked = () => {},
17
+ }: SelectorProps) => {
18
+ const [loggedInUser, setLoggedInUser] = useState<CometChat.User | null>(null);
19
+ const [activeConversation, setActiveConversation] = useState<
20
+ CometChat.Conversation | undefined
21
+ >();
22
+
23
+ useEffect(() => {
24
+ setLoggedInUser(CometChatUIKitLoginListener.getLoggedInUser());
25
+ }, []);
26
+
27
+ return (
28
+ <>
29
+ {loggedInUser && (
30
+ <CometChatConversations
31
+ activeConversation={activeConversation}
32
+ onItemClick={(e) => {
33
+ setActiveConversation(e);
34
+ onSelectorItemClicked(e, "updateSelectedItem");
35
+ }}
36
+ />
37
+ )}
38
+ </>
39
+ );
40
+ };
@@ -0,0 +1,46 @@
1
+ import { StrictMode } from 'react'
2
+ import { createRoot } from 'react-dom/client'
3
+ import { CometChatUIKit, UIKitSettingsBuilder } from '@cometchat/chat-uikit-react'
4
+ import './index.css'
5
+ import App from './App.tsx'
6
+
7
+ const COMETCHAT_CONSTANTS = {
8
+ APP_ID: import.meta.env.{{ENV_PREFIX}}COMETCHAT_APP_ID as string,
9
+ REGION: import.meta.env.{{ENV_PREFIX}}COMETCHAT_REGION as string,
10
+ AUTH_KEY: import.meta.env.{{ENV_PREFIX}}COMETCHAT_AUTH_KEY as string,
11
+ }
12
+
13
+ const settings = new UIKitSettingsBuilder()
14
+ .setAppId(COMETCHAT_CONSTANTS.APP_ID)
15
+ .setRegion(COMETCHAT_CONSTANTS.REGION)
16
+ .setAuthKey(COMETCHAT_CONSTANTS.AUTH_KEY)
17
+ .subscribePresenceForAllUsers()
18
+ .build()
19
+
20
+ CometChatUIKit.init(settings)
21
+ ?.then(() => {
22
+ CometChatUIKit.getLoggedinUser().then((user) => {
23
+ if (!user) {
24
+ CometChatUIKit.login('{{LOGIN_UID}}')
25
+ .then(() => mount())
26
+ .catch((e: unknown) => mountError(String(e)))
27
+ } else {
28
+ mount()
29
+ }
30
+ })
31
+ })
32
+ .catch((e: unknown) => mountError(String(e)))
33
+
34
+ function mount() {
35
+ createRoot(document.getElementById('root')!).render(
36
+ <StrictMode>
37
+ <App />
38
+ </StrictMode>,
39
+ )
40
+ }
41
+
42
+ function mountError(message: string) {
43
+ createRoot(document.getElementById('root')!).render(
44
+ <div style={{ color: 'red', padding: 16, fontFamily: 'monospace' }}>{message}</div>,
45
+ )
46
+ }
@@ -0,0 +1,81 @@
1
+ {
2
+ "$schema": "../../../schemas/template.schema.json",
3
+ "version": "1.0.0",
4
+ "experience_id": 2,
5
+ "framework": "astro",
6
+ "sdk_compatibility": ">=6.0.0 <7.0.0",
7
+ "default_placement": "dedicated-route",
8
+ "deps": [
9
+ {
10
+ "name": "@cometchat/chat-uikit-react",
11
+ "version": "^6"
12
+ },
13
+ {
14
+ "name": "@cometchat/chat-sdk-javascript",
15
+ "version": "^4"
16
+ },
17
+ {
18
+ "name": "@astrojs/react",
19
+ "version": "^4"
20
+ },
21
+ {
22
+ "name": "react",
23
+ "version": "^18"
24
+ },
25
+ {
26
+ "name": "react-dom",
27
+ "version": "^18"
28
+ }
29
+ ],
30
+ "env_vars": [
31
+ {
32
+ "name": "{{ENV_PREFIX}}COMETCHAT_APP_ID",
33
+ "required": true,
34
+ "description": "CometChat App ID from your dashboard"
35
+ },
36
+ {
37
+ "name": "{{ENV_PREFIX}}COMETCHAT_REGION",
38
+ "required": true,
39
+ "description": "CometChat region (us, eu, in, etc.)"
40
+ },
41
+ {
42
+ "name": "{{ENV_PREFIX}}COMETCHAT_AUTH_KEY",
43
+ "required": true,
44
+ "secret": true,
45
+ "description": "CometChat Auth Key (development only)"
46
+ }
47
+ ],
48
+ "files": [
49
+ {
50
+ "path": "src/cometchat/ChatApp.tsx",
51
+ "action": "create",
52
+ "template_ref": "ChatApp.tsx.tpl",
53
+ "owned": true
54
+ },
55
+ {
56
+ "path": "src/cometchat/ChatApp.css",
57
+ "action": "create",
58
+ "template_ref": "ChatApp.css.tpl",
59
+ "owned": true
60
+ },
61
+ {
62
+ "path": "src/pages/chat.astro",
63
+ "action": "create",
64
+ "template_ref": "chat.astro.tpl",
65
+ "owned": true
66
+ }
67
+ ],
68
+ "verify_rules": [
69
+ "init_before_login",
70
+ "no_user_and_group_same_component",
71
+ "no_auth_key_in_source",
72
+ "render_gated_on_login_resolve",
73
+ "error_ui_visible_on_failure"
74
+ ],
75
+ "next_steps": [
76
+ "If `@astrojs/react` isn't installed yet, run: `npx astro add react`",
77
+ "Run `npm run dev` to start the dev server",
78
+ "Visit http://localhost:4321/chat — you'll see a one-to-one chat with `{{CHAT_UID}}`",
79
+ "Edit `CHAT_UID` in `src/cometchat/ChatApp.tsx` to change the chat partner"
80
+ ]
81
+ }
@@ -0,0 +1,77 @@
1
+ {
2
+ "$schema": "../../../schemas/template.schema.json",
3
+ "version": "1.0.0",
4
+ "experience_id": 2,
5
+ "framework": "nextjs",
6
+ "sdk_compatibility": ">=6.0.0 <7.0.0",
7
+ "default_placement": "dedicated-route",
8
+ "deps": [
9
+ {
10
+ "name": "@cometchat/chat-uikit-react",
11
+ "version": "^6"
12
+ },
13
+ {
14
+ "name": "@cometchat/chat-sdk-javascript",
15
+ "version": "^4"
16
+ }
17
+ ],
18
+ "env_vars": [
19
+ {
20
+ "name": "{{ENV_PREFIX}}COMETCHAT_APP_ID",
21
+ "required": true,
22
+ "description": "CometChat App ID from your dashboard"
23
+ },
24
+ {
25
+ "name": "{{ENV_PREFIX}}COMETCHAT_REGION",
26
+ "required": true,
27
+ "description": "CometChat region (us, eu, in, etc.)"
28
+ },
29
+ {
30
+ "name": "{{ENV_PREFIX}}COMETCHAT_AUTH_KEY",
31
+ "required": true,
32
+ "secret": true,
33
+ "description": "CometChat Auth Key (development only)"
34
+ }
35
+ ],
36
+ "files": [
37
+ {
38
+ "path": "src/app/cometchat/CometChatNoSSR.tsx",
39
+ "action": "create",
40
+ "template_ref": "CometChatNoSSR.tsx.tpl",
41
+ "owned": true
42
+ },
43
+ {
44
+ "path": "src/app/cometchat/CometChatNoSSR.css",
45
+ "action": "create",
46
+ "template_ref": "CometChatNoSSR.css.tpl",
47
+ "owned": true
48
+ },
49
+ {
50
+ "path": "src/app/chat/page.tsx",
51
+ "action": "create",
52
+ "template_ref": "chat-page.tsx.tpl",
53
+ "owned": true
54
+ },
55
+ {
56
+ "path": "src/app/globals.css",
57
+ "action": "patch",
58
+ "patch_mode": "prepend",
59
+ "patch_content": "@import url(\"@cometchat/chat-uikit-react/css-variables.css\");\n",
60
+ "skip_if_exists": "@cometchat/chat-uikit-react/css-variables.css"
61
+ }
62
+ ],
63
+ "verify_rules": [
64
+ "css_variables_imported_once",
65
+ "init_before_login",
66
+ "no_user_and_group_same_component",
67
+ "no_auth_key_in_source",
68
+ "render_gated_on_login_resolve",
69
+ "error_ui_visible_on_failure"
70
+ ],
71
+ "next_steps": [
72
+ "Run `npm run dev` to start the dev server",
73
+ "Visit http://localhost:3000/chat — you'll see a one-to-one chat with `{{CHAT_UID}}`",
74
+ "Edit `UID` in `src/app/cometchat/CometChatNoSSR.tsx` to change the chat partner",
75
+ "When ready for production, run `cometchat apply --production` to set up server-side auth tokens"
76
+ ]
77
+ }
@@ -0,0 +1,93 @@
1
+ {
2
+ "$schema": "../../../schemas/template.schema.json",
3
+ "version": "1.0.0",
4
+ "experience_id": 2,
5
+ "framework": "react-router",
6
+ "sdk_compatibility": ">=6.0.0 <7.0.0",
7
+ "default_placement": "dedicated-route",
8
+ "deps": [
9
+ {
10
+ "name": "@cometchat/chat-uikit-react",
11
+ "version": "^6"
12
+ },
13
+ {
14
+ "name": "@cometchat/chat-sdk-javascript",
15
+ "version": "^4"
16
+ }
17
+ ],
18
+ "env_vars": [
19
+ {
20
+ "name": "{{ENV_PREFIX}}COMETCHAT_APP_ID",
21
+ "required": true,
22
+ "description": "CometChat App ID from your dashboard"
23
+ },
24
+ {
25
+ "name": "{{ENV_PREFIX}}COMETCHAT_REGION",
26
+ "required": true,
27
+ "description": "CometChat region (us, eu, in, etc.)"
28
+ },
29
+ {
30
+ "name": "{{ENV_PREFIX}}COMETCHAT_AUTH_KEY",
31
+ "required": true,
32
+ "secret": true,
33
+ "description": "CometChat Auth Key (development only)"
34
+ }
35
+ ],
36
+ "files": [
37
+ {
38
+ "path": "app/cometchat/CometChatNoSSR.tsx",
39
+ "action": "create",
40
+ "template_ref": "CometChatNoSSR.tsx.tpl",
41
+ "owned": true
42
+ },
43
+ {
44
+ "path": "app/cometchat/CometChatNoSSR.css",
45
+ "action": "create",
46
+ "template_ref": "CometChatNoSSR.css.tpl",
47
+ "owned": true
48
+ },
49
+ {
50
+ "path": "app/routes/CometChat.tsx",
51
+ "action": "create",
52
+ "template_ref": "CometChat-route.tsx.tpl",
53
+ "owned": true
54
+ },
55
+ {
56
+ "path": "app/routes.ts",
57
+ "action": "patch",
58
+ "patch_mode": "replace-section",
59
+ "anchor": "import { type RouteConfig, index }",
60
+ "patch_content": "import { type RouteConfig, index, route } from \"@react-router/dev/routes\";",
61
+ "skip_if_exists": "import { type RouteConfig, index, route }"
62
+ },
63
+ {
64
+ "path": "app/routes.ts",
65
+ "action": "patch",
66
+ "patch_mode": "insert-before",
67
+ "anchor": "] satisfies RouteConfig",
68
+ "patch_content": " route(\"chat\", \"routes/CometChat.tsx\"),\n",
69
+ "skip_if_exists": "routes/CometChat.tsx"
70
+ },
71
+ {
72
+ "path": "app/app.css",
73
+ "action": "patch",
74
+ "patch_mode": "prepend",
75
+ "patch_content": "@import url(\"@cometchat/chat-uikit-react/css-variables.css\");\n",
76
+ "skip_if_exists": "@cometchat/chat-uikit-react/css-variables.css"
77
+ }
78
+ ],
79
+ "verify_rules": [
80
+ "css_variables_imported_once",
81
+ "init_before_login",
82
+ "no_user_and_group_same_component",
83
+ "no_auth_key_in_source",
84
+ "render_gated_on_login_resolve",
85
+ "error_ui_visible_on_failure"
86
+ ],
87
+ "next_steps": [
88
+ "Add the chat route to app/routes.ts: route(\"chat\", \"routes/CometChat.tsx\")",
89
+ "Run `npm run dev` to start the dev server",
90
+ "Visit http://localhost:5173/chat — you'll see a one-to-one chat with `{{CHAT_UID}}`",
91
+ "Edit `CHAT_UID` in `app/cometchat/CometChatNoSSR.tsx` to change the chat partner"
92
+ ]
93
+ }
@@ -0,0 +1,77 @@
1
+ {
2
+ "$schema": "../../../schemas/template.schema.json",
3
+ "version": "1.0.0",
4
+ "experience_id": 2,
5
+ "framework": "reactjs",
6
+ "sdk_compatibility": ">=6.0.0 <7.0.0",
7
+ "default_placement": "spa-root",
8
+ "deps": [
9
+ {
10
+ "name": "@cometchat/chat-uikit-react",
11
+ "version": "^6"
12
+ },
13
+ {
14
+ "name": "@cometchat/chat-sdk-javascript",
15
+ "version": "^4"
16
+ }
17
+ ],
18
+ "env_vars": [
19
+ {
20
+ "name": "{{ENV_PREFIX}}COMETCHAT_APP_ID",
21
+ "required": true,
22
+ "description": "CometChat App ID from your dashboard"
23
+ },
24
+ {
25
+ "name": "{{ENV_PREFIX}}COMETCHAT_REGION",
26
+ "required": true,
27
+ "description": "CometChat region (us, eu, in, etc.)"
28
+ },
29
+ {
30
+ "name": "{{ENV_PREFIX}}COMETCHAT_AUTH_KEY",
31
+ "required": true,
32
+ "secret": true,
33
+ "description": "CometChat Auth Key (development only — use auth tokens in production)"
34
+ }
35
+ ],
36
+ "files": [
37
+ {
38
+ "path": "src/main.tsx",
39
+ "action": "create",
40
+ "template_ref": "main.tsx.tpl",
41
+ "owned": true
42
+ },
43
+ {
44
+ "path": "src/App.tsx",
45
+ "action": "create",
46
+ "template_ref": "App.tsx.tpl",
47
+ "owned": true
48
+ },
49
+ {
50
+ "path": "src/App.css",
51
+ "action": "create",
52
+ "template_ref": "App.css.tpl",
53
+ "owned": true
54
+ },
55
+ {
56
+ "path": "src/index.css",
57
+ "action": "patch",
58
+ "patch_mode": "prepend",
59
+ "patch_content": "@import url(\"@cometchat/chat-uikit-react/css-variables.css\");\n",
60
+ "skip_if_exists": "@cometchat/chat-uikit-react/css-variables.css"
61
+ }
62
+ ],
63
+ "verify_rules": [
64
+ "css_variables_imported_once",
65
+ "init_before_login",
66
+ "no_user_and_group_same_component",
67
+ "no_auth_key_in_source",
68
+ "render_gated_on_login_resolve",
69
+ "error_ui_visible_on_failure"
70
+ ],
71
+ "next_steps": [
72
+ "Run `npm run dev` to start the dev server",
73
+ "Visit http://localhost:5173 — you'll see a one-to-one chat with `{{CHAT_UID}}`",
74
+ "To change the chat partner, edit `CHAT_UID` in `src/App.tsx`",
75
+ "When ready for production, run `cometchat apply --production` to set up server-side auth tokens"
76
+ ]
77
+ }
@@ -0,0 +1,21 @@
1
+ .messages-wrapper {
2
+ width: 100%;
3
+ height: 100vh;
4
+ display: flex;
5
+ flex-direction: column;
6
+ }
7
+
8
+ .empty-conversation {
9
+ height: 100vh;
10
+ width: 100%;
11
+ display: flex;
12
+ justify-content: center;
13
+ align-items: center;
14
+ background: white;
15
+ color: var(--cometchat-text-color-secondary, #727272);
16
+ font: var(--cometchat-font-body-regular, 400 14px Roboto);
17
+ }
18
+
19
+ .cometchat .cometchat-message-composer {
20
+ border-radius: 0;
21
+ }
@@ -0,0 +1,66 @@
1
+ import { useEffect, useState } from "react";
2
+ import {
3
+ CometChatMessageComposer,
4
+ CometChatMessageHeader,
5
+ CometChatMessageList,
6
+ CometChatUIKit,
7
+ UIKitSettingsBuilder,
8
+ } from "@cometchat/chat-uikit-react";
9
+ import { CometChat } from "@cometchat/chat-sdk-javascript";
10
+ // IMPORTANT: css-variables.css MUST be imported here (inside the React island)
11
+ // — global stylesheets imported in .astro files do not apply to client:only islands.
12
+ import "@cometchat/chat-uikit-react/css-variables.css";
13
+ import "./ChatApp.css";
14
+
15
+ const COMETCHAT_CONSTANTS = {
16
+ APP_ID: import.meta.env.{{ENV_PREFIX}}COMETCHAT_APP_ID as string,
17
+ REGION: import.meta.env.{{ENV_PREFIX}}COMETCHAT_REGION as string,
18
+ AUTH_KEY: import.meta.env.{{ENV_PREFIX}}COMETCHAT_AUTH_KEY as string,
19
+ };
20
+ const LOGIN_UID = "{{LOGIN_UID}}";
21
+ const CHAT_UID = "{{CHAT_UID}}";
22
+
23
+ export default function ChatApp() {
24
+ const [loggedIn, setLoggedIn] = useState(false);
25
+ const [chatUser, setChatUser] = useState<CometChat.User | undefined>();
26
+ const [error, setError] = useState<string | null>(null);
27
+
28
+ useEffect(() => {
29
+ const settings = new UIKitSettingsBuilder()
30
+ .setAppId(COMETCHAT_CONSTANTS.APP_ID)
31
+ .setRegion(COMETCHAT_CONSTANTS.REGION)
32
+ .setAuthKey(COMETCHAT_CONSTANTS.AUTH_KEY)
33
+ .subscribePresenceForAllUsers()
34
+ .build();
35
+
36
+ CometChatUIKit.init(settings)?.then(() => {
37
+ CometChatUIKit.getLoggedinUser().then((u) => {
38
+ if (!u) {
39
+ CometChatUIKit.login(LOGIN_UID)
40
+ .then(() => setLoggedIn(true))
41
+ .catch((e: unknown) => setError(String(e)));
42
+ } else {
43
+ setLoggedIn(true);
44
+ }
45
+ });
46
+ }).catch((e: unknown) => setError(String(e)));
47
+ }, []);
48
+
49
+ useEffect(() => {
50
+ if (!loggedIn) return;
51
+ CometChat.getUser(CHAT_UID)
52
+ .then((u) => setChatUser(u))
53
+ .catch((e: unknown) => setError(String(e)));
54
+ }, [loggedIn]);
55
+
56
+ if (error) return <div style={{ color: "red", padding: 16, fontFamily: "monospace" }}>{error}</div>;
57
+ if (!loggedIn || !chatUser) return <div className="empty-conversation">Loading chat…</div>;
58
+
59
+ return (
60
+ <div className="messages-wrapper">
61
+ <CometChatMessageHeader user={chatUser} />
62
+ <CometChatMessageList user={chatUser} />
63
+ <CometChatMessageComposer user={chatUser} />
64
+ </div>
65
+ );
66
+ }
@@ -0,0 +1,17 @@
1
+ ---
2
+ import ChatApp from "../cometchat/ChatApp.tsx";
3
+ ---
4
+
5
+ <html lang="en">
6
+ <head>
7
+ <meta charset="utf-8" />
8
+ <meta name="viewport" content="width=device-width" />
9
+ <title>Chat</title>
10
+ <style>
11
+ html, body { margin: 0; padding: 0; height: 100%; }
12
+ </style>
13
+ </head>
14
+ <body>
15
+ <ChatApp client:only="react" />
16
+ </body>
17
+ </html>
@@ -0,0 +1,21 @@
1
+ .messages-wrapper {
2
+ width: 100%;
3
+ height: 100vh;
4
+ display: flex;
5
+ flex-direction: column;
6
+ }
7
+
8
+ .empty-conversation {
9
+ height: 100vh;
10
+ width: 100%;
11
+ display: flex;
12
+ justify-content: center;
13
+ align-items: center;
14
+ background: white;
15
+ color: var(--cometchat-text-color-secondary, #727272);
16
+ font: var(--cometchat-font-body-regular, 400 14px Roboto);
17
+ }
18
+
19
+ .cometchat .cometchat-message-composer {
20
+ border-radius: 0;
21
+ }