@cometchat/skills-cli 2.4.0 → 3.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 (111) hide show
  1. package/README.md +45 -37
  2. package/dist/index.js +1690 -12609
  3. package/dist/utils/error-dictionary.js +0 -69
  4. package/package.json +10 -12
  5. package/dist/registry/schemas/config.schema.json +0 -119
  6. package/dist/registry/schemas/template.schema.json +0 -142
  7. package/dist/registry/v6/experiences/1-conversation-list/astro.template.json +0 -89
  8. package/dist/registry/v6/experiences/1-conversation-list/nextjs-pages.template.json +0 -83
  9. package/dist/registry/v6/experiences/1-conversation-list/nextjs.template.json +0 -83
  10. package/dist/registry/v6/experiences/1-conversation-list/react-router.template.json +0 -102
  11. package/dist/registry/v6/experiences/1-conversation-list/reactjs-dedicated-route.template.json +0 -81
  12. package/dist/registry/v6/experiences/1-conversation-list/reactjs.template.json +0 -86
  13. package/dist/registry/v6/experiences/1-conversation-list/templates/astro/ChatApp.css.tpl +0 -43
  14. package/dist/registry/v6/experiences/1-conversation-list/templates/astro/ChatApp.tsx.tpl +0 -86
  15. package/dist/registry/v6/experiences/1-conversation-list/templates/astro/CometChatSelector.tsx.tpl +0 -40
  16. package/dist/registry/v6/experiences/1-conversation-list/templates/astro/chat.astro.tpl +0 -17
  17. package/dist/registry/v6/experiences/1-conversation-list/templates/nextjs/CometChatNoSSR.css.tpl +0 -43
  18. package/dist/registry/v6/experiences/1-conversation-list/templates/nextjs/CometChatNoSSR.tsx.tpl +0 -86
  19. package/dist/registry/v6/experiences/1-conversation-list/templates/nextjs/CometChatSelector.tsx.tpl +0 -41
  20. package/dist/registry/v6/experiences/1-conversation-list/templates/nextjs/chat-page.tsx.tpl +0 -11
  21. package/dist/registry/v6/experiences/1-conversation-list/templates/nextjs-pages/CometChatNoSSR.css.tpl +0 -43
  22. package/dist/registry/v6/experiences/1-conversation-list/templates/nextjs-pages/CometChatNoSSR.tsx.tpl +0 -88
  23. package/dist/registry/v6/experiences/1-conversation-list/templates/nextjs-pages/CometChatSelector.tsx.tpl +0 -41
  24. package/dist/registry/v6/experiences/1-conversation-list/templates/nextjs-pages/chat-page.tsx.tpl +0 -15
  25. package/dist/registry/v6/experiences/1-conversation-list/templates/react-router/CometChat-route.tsx.tpl +0 -22
  26. package/dist/registry/v6/experiences/1-conversation-list/templates/react-router/CometChatNoSSR.css.tpl +0 -43
  27. package/dist/registry/v6/experiences/1-conversation-list/templates/react-router/CometChatNoSSR.tsx.tpl +0 -87
  28. package/dist/registry/v6/experiences/1-conversation-list/templates/react-router/CometChatSelector.tsx.tpl +0 -40
  29. package/dist/registry/v6/experiences/1-conversation-list/templates/reactjs/App.css.tpl +0 -40
  30. package/dist/registry/v6/experiences/1-conversation-list/templates/reactjs/App.tsx.tpl +0 -55
  31. package/dist/registry/v6/experiences/1-conversation-list/templates/reactjs/CometChatSelector.tsx.tpl +0 -40
  32. package/dist/registry/v6/experiences/1-conversation-list/templates/reactjs/main.tsx.tpl +0 -46
  33. package/dist/registry/v6/experiences/1-conversation-list/templates/reactjs-dedicated-route/ChatPage.tsx.tpl +0 -87
  34. package/dist/registry/v6/experiences/1-conversation-list/templates/reactjs-dedicated-route/CometChatMessenger.css.tpl +0 -20
  35. package/dist/registry/v6/experiences/1-conversation-list/templates/reactjs-dedicated-route/CometChatMessenger.tsx.tpl +0 -54
  36. package/dist/registry/v6/experiences/1-conversation-list/templates/reactjs-dedicated-route/CometChatSelector.tsx.tpl +0 -40
  37. package/dist/registry/v6/experiences/2-one-to-one/astro.template.json +0 -81
  38. package/dist/registry/v6/experiences/2-one-to-one/nextjs.template.json +0 -77
  39. package/dist/registry/v6/experiences/2-one-to-one/react-router.template.json +0 -93
  40. package/dist/registry/v6/experiences/2-one-to-one/reactjs-dedicated-route.template.json +0 -75
  41. package/dist/registry/v6/experiences/2-one-to-one/reactjs.template.json +0 -80
  42. package/dist/registry/v6/experiences/2-one-to-one/templates/astro/ChatApp.css.tpl +0 -21
  43. package/dist/registry/v6/experiences/2-one-to-one/templates/astro/ChatApp.tsx.tpl +0 -66
  44. package/dist/registry/v6/experiences/2-one-to-one/templates/astro/chat.astro.tpl +0 -17
  45. package/dist/registry/v6/experiences/2-one-to-one/templates/nextjs/CometChatNoSSR.css.tpl +0 -21
  46. package/dist/registry/v6/experiences/2-one-to-one/templates/nextjs/CometChatNoSSR.tsx.tpl +0 -66
  47. package/dist/registry/v6/experiences/2-one-to-one/templates/nextjs/chat-page.tsx.tpl +0 -11
  48. package/dist/registry/v6/experiences/2-one-to-one/templates/react-router/CometChat-route.tsx.tpl +0 -21
  49. package/dist/registry/v6/experiences/2-one-to-one/templates/react-router/CometChatNoSSR.css.tpl +0 -21
  50. package/dist/registry/v6/experiences/2-one-to-one/templates/react-router/CometChatNoSSR.tsx.tpl +0 -67
  51. package/dist/registry/v6/experiences/2-one-to-one/templates/reactjs/App.css.tpl +0 -4
  52. package/dist/registry/v6/experiences/2-one-to-one/templates/reactjs/App.tsx.tpl +0 -44
  53. package/dist/registry/v6/experiences/2-one-to-one/templates/reactjs/main.tsx.tpl +0 -46
  54. package/dist/registry/v6/experiences/2-one-to-one/templates/reactjs-dedicated-route/ChatPage.tsx.tpl +0 -84
  55. package/dist/registry/v6/experiences/2-one-to-one/templates/reactjs-dedicated-route/CometChatMessenger.css.tpl +0 -9
  56. package/dist/registry/v6/experiences/2-one-to-one/templates/reactjs-dedicated-route/CometChatMessenger.tsx.tpl +0 -43
  57. package/dist/registry/v6/experiences/3-tab-based/astro.template.json +0 -93
  58. package/dist/registry/v6/experiences/3-tab-based/nextjs.template.json +0 -90
  59. package/dist/registry/v6/experiences/3-tab-based/react-router.template.json +0 -105
  60. package/dist/registry/v6/experiences/3-tab-based/reactjs-dedicated-route.template.json +0 -89
  61. package/dist/registry/v6/experiences/3-tab-based/reactjs.template.json +0 -93
  62. package/dist/registry/v6/experiences/3-tab-based/templates/astro/ChatApp.css.tpl +0 -39
  63. package/dist/registry/v6/experiences/3-tab-based/templates/astro/ChatApp.tsx.tpl +0 -93
  64. package/dist/registry/v6/experiences/3-tab-based/templates/astro/CometChatTabs.css.tpl +0 -43
  65. package/dist/registry/v6/experiences/3-tab-based/templates/astro/CometChatTabs.tsx.tpl +0 -72
  66. package/dist/registry/v6/experiences/3-tab-based/templates/astro/chat.astro.tpl +0 -17
  67. package/dist/registry/v6/experiences/3-tab-based/templates/nextjs/CometChatNoSSR.css.tpl +0 -39
  68. package/dist/registry/v6/experiences/3-tab-based/templates/nextjs/CometChatNoSSR.tsx.tpl +0 -93
  69. package/dist/registry/v6/experiences/3-tab-based/templates/nextjs/CometChatTabs.css.tpl +0 -43
  70. package/dist/registry/v6/experiences/3-tab-based/templates/nextjs/CometChatTabs.tsx.tpl +0 -73
  71. package/dist/registry/v6/experiences/3-tab-based/templates/nextjs/chat-page.tsx.tpl +0 -11
  72. package/dist/registry/v6/experiences/3-tab-based/templates/react-router/CometChat-route.tsx.tpl +0 -21
  73. package/dist/registry/v6/experiences/3-tab-based/templates/react-router/CometChatNoSSR.css.tpl +0 -39
  74. package/dist/registry/v6/experiences/3-tab-based/templates/react-router/CometChatNoSSR.tsx.tpl +0 -94
  75. package/dist/registry/v6/experiences/3-tab-based/templates/react-router/CometChatTabs.css.tpl +0 -43
  76. package/dist/registry/v6/experiences/3-tab-based/templates/react-router/CometChatTabs.tsx.tpl +0 -72
  77. package/dist/registry/v6/experiences/3-tab-based/templates/reactjs/App.css.tpl +0 -7
  78. package/dist/registry/v6/experiences/3-tab-based/templates/reactjs/App.tsx.tpl +0 -62
  79. package/dist/registry/v6/experiences/3-tab-based/templates/reactjs/CometChatTabs.css.tpl +0 -43
  80. package/dist/registry/v6/experiences/3-tab-based/templates/reactjs/CometChatTabs.tsx.tpl +0 -72
  81. package/dist/registry/v6/experiences/3-tab-based/templates/reactjs/main.tsx.tpl +0 -46
  82. package/dist/registry/v6/experiences/3-tab-based/templates/reactjs-dedicated-route/ChatPage.tsx.tpl +0 -84
  83. package/dist/registry/v6/experiences/3-tab-based/templates/reactjs-dedicated-route/CometChatMessenger.css.tpl +0 -11
  84. package/dist/registry/v6/experiences/3-tab-based/templates/reactjs-dedicated-route/CometChatMessenger.tsx.tpl +0 -61
  85. package/dist/registry/v6/experiences/3-tab-based/templates/reactjs-dedicated-route/CometChatTabs.css.tpl +0 -43
  86. package/dist/registry/v6/experiences/3-tab-based/templates/reactjs-dedicated-route/CometChatTabs.tsx.tpl +0 -72
  87. package/dist/registry/v6/features/catalog.json +0 -526
  88. package/dist/registry/v6/production/astro/cometchat-token.ts.tpl +0 -86
  89. package/dist/registry/v6/production/astro.template.json +0 -51
  90. package/dist/registry/v6/production/nextjs/route.ts.tpl +0 -79
  91. package/dist/registry/v6/production/nextjs.template.json +0 -50
  92. package/dist/registry/v6/production/react-router/api.cometchat-token.ts.tpl +0 -73
  93. package/dist/registry/v6/production/react-router.template.json +0 -58
  94. package/dist/registry/v6/user-mgmt/astro/cometchat-user.ts.tpl +0 -164
  95. package/dist/registry/v6/user-mgmt/astro.template.json +0 -33
  96. package/dist/registry/v6/user-mgmt/nextjs/route.ts.tpl +0 -212
  97. package/dist/registry/v6/user-mgmt/nextjs.template.json +0 -57
  98. package/dist/registry/v6/user-mgmt/react-router/api.cometchat-user.ts.tpl +0 -176
  99. package/dist/registry/v6/user-mgmt/react-router.template.json +0 -40
  100. package/dist/registry/v6/widget/astro/CometChatWidget.css.tpl +0 -105
  101. package/dist/registry/v6/widget/astro/CometChatWidget.tsx.tpl +0 -88
  102. package/dist/registry/v6/widget/astro.template.json +0 -38
  103. package/dist/registry/v6/widget/nextjs/CometChatWidget.css.tpl +0 -105
  104. package/dist/registry/v6/widget/nextjs/CometChatWidget.tsx.tpl +0 -88
  105. package/dist/registry/v6/widget/nextjs.template.json +0 -40
  106. package/dist/registry/v6/widget/react-router/CometChatWidget.css.tpl +0 -105
  107. package/dist/registry/v6/widget/react-router/CometChatWidget.tsx.tpl +0 -98
  108. package/dist/registry/v6/widget/react-router.template.json +0 -36
  109. package/dist/registry/v6/widget/reactjs/CometChatWidget.css.tpl +0 -105
  110. package/dist/registry/v6/widget/reactjs/CometChatWidget.tsx.tpl +0 -89
  111. package/dist/registry/v6/widget/reactjs.template.json +0 -36
@@ -1,105 +0,0 @@
1
- {
2
- "$schema": "../../../schemas/template.schema.json",
3
- "version": "1.0.0",
4
- "experience_id": 3,
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/cometchat/CometChatTabs.tsx",
51
- "action": "create",
52
- "template_ref": "CometChatTabs.tsx.tpl",
53
- "owned": true
54
- },
55
- {
56
- "path": "app/cometchat/CometChatTabs.css",
57
- "action": "create",
58
- "template_ref": "CometChatTabs.css.tpl",
59
- "owned": true
60
- },
61
- {
62
- "path": "app/routes/CometChat.tsx",
63
- "action": "create",
64
- "template_ref": "CometChat-route.tsx.tpl",
65
- "owned": true
66
- },
67
- {
68
- "path": "app/routes.ts",
69
- "action": "patch",
70
- "patch_mode": "replace-section",
71
- "anchor": "import { type RouteConfig, index }",
72
- "patch_content": "import { type RouteConfig, index, route } from \"@react-router/dev/routes\";",
73
- "skip_if_exists": "import { type RouteConfig, index, route }"
74
- },
75
- {
76
- "path": "app/routes.ts",
77
- "action": "patch",
78
- "patch_mode": "insert-before",
79
- "anchor": "] satisfies RouteConfig",
80
- "patch_content": " route(\"chat\", \"routes/CometChat.tsx\"),\n",
81
- "skip_if_exists": "routes/CometChat.tsx"
82
- },
83
- {
84
- "path": "app/app.css",
85
- "action": "patch",
86
- "patch_mode": "prepend",
87
- "patch_content": "@import url(\"@cometchat/chat-uikit-react/css-variables.css\");\n",
88
- "skip_if_exists": "@cometchat/chat-uikit-react/css-variables.css"
89
- }
90
- ],
91
- "verify_rules": [
92
- "css_variables_imported_once",
93
- "init_before_login",
94
- "no_user_and_group_same_component",
95
- "no_auth_key_in_source",
96
- "render_gated_on_login_resolve",
97
- "error_ui_visible_on_failure"
98
- ],
99
- "next_steps": [
100
- "Add the chat route to app/routes.ts: route(\"chat\", \"routes/CometChat.tsx\")",
101
- "Run `npm run dev` to start the dev server",
102
- "Visit http://localhost:5173/chat",
103
- "Click any of the 4 tabs (Chats / Calls / Users / Groups) to switch lists"
104
- ]
105
- }
@@ -1,89 +0,0 @@
1
- {
2
- "$schema": "../../../schemas/template.schema.json",
3
- "version": "1.0.0",
4
- "experience_id": 3,
5
- "framework": "reactjs-dedicated-route",
6
- "sdk_compatibility": ">=6.0.0 <7.0.0",
7
- "default_placement": "dedicated-route",
8
- "deps": [
9
- { "name": "@cometchat/chat-uikit-react", "version": "^6" },
10
- { "name": "@cometchat/chat-sdk-javascript", "version": "^4" }
11
- ],
12
- "env_vars": [
13
- { "name": "{{ENV_PREFIX}}COMETCHAT_APP_ID", "required": true, "description": "CometChat App ID from your dashboard" },
14
- { "name": "{{ENV_PREFIX}}COMETCHAT_REGION", "required": true, "description": "CometChat region (us, eu, in, etc.)" },
15
- { "name": "{{ENV_PREFIX}}COMETCHAT_AUTH_KEY", "required": true, "secret": true, "description": "CometChat Auth Key (development only — use auth tokens in production)" }
16
- ],
17
- "files": [
18
- {
19
- "path": "src/cometchat/CometChatTabs.tsx",
20
- "action": "create",
21
- "template_ref": "CometChatTabs.tsx.tpl",
22
- "owned": true
23
- },
24
- {
25
- "path": "src/cometchat/CometChatTabs.css",
26
- "action": "create",
27
- "template_ref": "CometChatTabs.css.tpl",
28
- "owned": true
29
- },
30
- {
31
- "path": "src/cometchat/CometChatMessenger.tsx",
32
- "action": "create",
33
- "template_ref": "CometChatMessenger.tsx.tpl",
34
- "owned": true
35
- },
36
- {
37
- "path": "src/cometchat/CometChatMessenger.css",
38
- "action": "create",
39
- "template_ref": "CometChatMessenger.css.tpl",
40
- "owned": true
41
- },
42
- {
43
- "path": "src/pages/ChatPage.tsx",
44
- "action": "create",
45
- "template_ref": "ChatPage.tsx.tpl",
46
- "owned": true,
47
- "is_entry": true
48
- },
49
- {
50
- "path": "src/App.tsx",
51
- "action": "patch",
52
- "patch_mode": "prepend",
53
- "patch_content": "import ChatPage from \"./pages/ChatPage\";\n",
54
- "skip_if_exists": "./pages/ChatPage",
55
- "embed_skip": true
56
- },
57
- {
58
- "path": "src/App.tsx",
59
- "action": "patch",
60
- "patch_mode": "insert-before",
61
- "anchor": "</Routes>",
62
- "patch_content": " <Route path=\"{{PLACEMENT_PATH}}\" element={<ChatPage />} />\n ",
63
- "skip_if_exists": "element={<ChatPage />}",
64
- "embed_skip": true
65
- },
66
- {
67
- "path": "src/index.css",
68
- "action": "patch",
69
- "patch_mode": "prepend",
70
- "patch_content": "@import url(\"@cometchat/chat-uikit-react/css-variables.css\");\n",
71
- "skip_if_exists": "@cometchat/chat-uikit-react/css-variables.css"
72
- }
73
- ],
74
- "verify_rules": [
75
- "css_variables_imported_once",
76
- "init_before_login",
77
- "no_user_and_group_same_component",
78
- "no_auth_key_in_source",
79
- "render_gated_on_login_resolve",
80
- "error_ui_visible_on_failure"
81
- ],
82
- "next_steps": [
83
- "Run `npm run dev` to start the dev server",
84
- "Visit http://localhost:5173{{PLACEMENT_PATH}}",
85
- "The left panel shows the tab bar (Chats / Calls / Users / Groups). Click any tab to switch.",
86
- "Click a conversation, user, or group to open the message thread on the right.",
87
- "If the route didn't wire up automatically (your App.tsx layout is non-standard), add: <Route path=\"{{PLACEMENT_PATH}}\" element={<ChatPage />} /> inside your existing <Routes> block and import ChatPage from ./pages/ChatPage"
88
- ]
89
- }
@@ -1,93 +0,0 @@
1
- {
2
- "$schema": "../../../schemas/template.schema.json",
3
- "version": "1.0.0",
4
- "experience_id": 3,
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
- "embed_skip": true
43
- },
44
- {
45
- "path": "src/App.tsx",
46
- "action": "create",
47
- "template_ref": "App.tsx.tpl",
48
- "owned": true,
49
- "is_entry": true
50
- },
51
- {
52
- "path": "src/App.css",
53
- "action": "create",
54
- "template_ref": "App.css.tpl",
55
- "owned": true,
56
- "move_with_entry": true
57
- },
58
- {
59
- "path": "src/cometchat/CometChatTabs.tsx",
60
- "action": "create",
61
- "template_ref": "CometChatTabs.tsx.tpl",
62
- "owned": true
63
- },
64
- {
65
- "path": "src/cometchat/CometChatTabs.css",
66
- "action": "create",
67
- "template_ref": "CometChatTabs.css.tpl",
68
- "owned": true
69
- },
70
- {
71
- "path": "src/index.css",
72
- "action": "patch",
73
- "patch_mode": "prepend",
74
- "patch_content": "@import url(\"@cometchat/chat-uikit-react/css-variables.css\");\n",
75
- "skip_if_exists": "@cometchat/chat-uikit-react/css-variables.css"
76
- }
77
- ],
78
- "verify_rules": [
79
- "css_variables_imported_once",
80
- "init_before_login",
81
- "no_user_and_group_same_component",
82
- "no_auth_key_in_source",
83
- "render_gated_on_login_resolve",
84
- "error_ui_visible_on_failure"
85
- ],
86
- "next_steps": [
87
- "Run `npm run dev` to start the dev server",
88
- "Visit http://localhost:5173",
89
- "The left panel shows the tab bar (Chats / Calls / Users / Groups). Click any tab to switch.",
90
- "Click a conversation, user, or group to open the message thread on the right.",
91
- "When ready for production, run `cometchat apply --production` to set up server-side auth tokens"
92
- ]
93
- }
@@ -1,39 +0,0 @@
1
- .conversations-with-messages {
2
- display: flex;
3
- height: 100vh;
4
- width: 100%;
5
- }
6
-
7
- .conversations-wrapper {
8
- height: 100%;
9
- width: 480px;
10
- overflow: hidden;
11
- display: flex;
12
- flex-direction: column;
13
- }
14
-
15
- .conversations-wrapper > .cometchat {
16
- overflow: hidden;
17
- }
18
-
19
- .messages-wrapper {
20
- width: calc(100% - 480px);
21
- height: 100%;
22
- display: flex;
23
- flex-direction: column;
24
- }
25
-
26
- .empty-conversation {
27
- height: 100%;
28
- width: 100%;
29
- display: flex;
30
- justify-content: center;
31
- align-items: center;
32
- background: white;
33
- color: var(--cometchat-text-color-secondary, #727272);
34
- font: var(--cometchat-font-body-regular, 400 14px Roboto);
35
- }
36
-
37
- .cometchat .cometchat-message-composer {
38
- border-radius: 0;
39
- }
@@ -1,93 +0,0 @@
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
- import { CometChatTabs, type CometChatTab } from "./CometChatTabs";
11
- // IMPORTANT: css-variables.css MUST be imported here (inside the React island)
12
- // — global stylesheets imported in .astro files do not apply to client:only islands.
13
- import "@cometchat/chat-uikit-react/css-variables.css";
14
- import "./ChatApp.css";
15
-
16
- const COMETCHAT_CONSTANTS = {
17
- APP_ID: import.meta.env.{{ENV_PREFIX}}COMETCHAT_APP_ID as string,
18
- REGION: import.meta.env.{{ENV_PREFIX}}COMETCHAT_REGION as string,
19
- AUTH_KEY: import.meta.env.{{ENV_PREFIX}}COMETCHAT_AUTH_KEY as string,
20
- };
21
- const UID = "{{LOGIN_UID}}";
22
-
23
- export default function ChatApp() {
24
- const [user, setUser] = useState<CometChat.User | undefined>();
25
- const [error, setError] = useState<string | null>(null);
26
- const [activeTab, setActiveTab] = useState<CometChatTab>("chats");
27
- const [selectedUser, setSelectedUser] = useState<CometChat.User | undefined>();
28
- const [selectedGroup, setSelectedGroup] = useState<CometChat.Group | undefined>();
29
-
30
- useEffect(() => {
31
- const settings = new UIKitSettingsBuilder()
32
- .setAppId(COMETCHAT_CONSTANTS.APP_ID)
33
- .setRegion(COMETCHAT_CONSTANTS.REGION)
34
- .setAuthKey(COMETCHAT_CONSTANTS.AUTH_KEY)
35
- .subscribePresenceForAllUsers()
36
- .build();
37
-
38
- CometChatUIKit.init(settings)?.then(() => {
39
- CometChatUIKit.getLoggedinUser().then((u) => {
40
- if (!u) {
41
- CometChatUIKit.login(UID)
42
- .then(setUser)
43
- .catch((e: unknown) => setError(String(e)));
44
- } else {
45
- setUser(u);
46
- }
47
- });
48
- }).catch((e: unknown) => setError(String(e)));
49
- }, []);
50
-
51
- const handleSelectorItemClicked = (
52
- activeItem: CometChat.Conversation | CometChat.User | CometChat.Group,
53
- ) => {
54
- const item =
55
- activeItem instanceof CometChat.Conversation
56
- ? activeItem.getConversationWith()
57
- : activeItem;
58
- if (item instanceof CometChat.User) {
59
- setSelectedUser(item);
60
- setSelectedGroup(undefined);
61
- } else if (item instanceof CometChat.Group) {
62
- setSelectedUser(undefined);
63
- setSelectedGroup(item);
64
- }
65
- };
66
-
67
- if (error) return <div style={{ color: "red", padding: 16, fontFamily: "monospace" }}>{error}</div>;
68
- if (!user) return null;
69
-
70
- return (
71
- <div className="conversations-with-messages">
72
- <div className="conversations-wrapper">
73
- <CometChatTabs
74
- activeTab={activeTab}
75
- onTabChange={setActiveTab}
76
- onItemClick={handleSelectorItemClicked}
77
- />
78
- </div>
79
- {selectedUser || selectedGroup ? (
80
- <div className="messages-wrapper">
81
- {selectedUser && <CometChatMessageHeader user={selectedUser} />}
82
- {selectedGroup && <CometChatMessageHeader group={selectedGroup} />}
83
- {selectedUser && <CometChatMessageList user={selectedUser} />}
84
- {selectedGroup && <CometChatMessageList group={selectedGroup} />}
85
- {selectedUser && <CometChatMessageComposer user={selectedUser} />}
86
- {selectedGroup && <CometChatMessageComposer group={selectedGroup} />}
87
- </div>
88
- ) : (
89
- <div className="empty-conversation">Select a conversation to start chatting</div>
90
- )}
91
- </div>
92
- );
93
- }
@@ -1,43 +0,0 @@
1
- .cometchat-tabs {
2
- height: 100%;
3
- width: 100%;
4
- display: flex;
5
- flex-direction: column;
6
- }
7
-
8
- .cometchat-tabs-content {
9
- flex: 1;
10
- overflow: hidden;
11
- display: flex;
12
- flex-direction: column;
13
- }
14
-
15
- .cometchat-tabs-content > .cometchat {
16
- flex: 1;
17
- overflow: hidden;
18
- }
19
-
20
- .cometchat-tabs-bar {
21
- display: flex;
22
- border-top: 1px solid var(--cometchat-border-color-default, #e8e8e8);
23
- background: var(--cometchat-background-color-01, #ffffff);
24
- }
25
-
26
- .cometchat-tabs-bar-tab {
27
- flex: 1;
28
- padding: 12px 8px;
29
- border: none;
30
- background: transparent;
31
- font: var(--cometchat-font-body-regular, 400 14px Roboto);
32
- color: var(--cometchat-text-color-secondary, #727272);
33
- cursor: pointer;
34
- }
35
-
36
- .cometchat-tabs-bar-tab.active {
37
- color: var(--cometchat-primary-color, #6852d6);
38
- font-weight: 600;
39
- }
40
-
41
- .cometchat-tabs-bar-tab:hover {
42
- background: var(--cometchat-background-color-02, #f8f8f8);
43
- }
@@ -1,72 +0,0 @@
1
- import { useEffect, useState } from "react";
2
- import type { CometChat } from "@cometchat/chat-sdk-javascript";
3
- import {
4
- CometChatCallLogs,
5
- CometChatConversations,
6
- CometChatGroups,
7
- CometChatUIKitLoginListener,
8
- CometChatUsers,
9
- } from "@cometchat/chat-uikit-react";
10
- import "./CometChatTabs.css";
11
-
12
- export type CometChatTab = "chats" | "calls" | "users" | "groups";
13
-
14
- interface CometChatTabsProps {
15
- activeTab: CometChatTab;
16
- onTabChange: (tab: CometChatTab) => void;
17
- onItemClick: (
18
- item: CometChat.Conversation | CometChat.User | CometChat.Group,
19
- ) => void;
20
- }
21
-
22
- const TABS: { id: CometChatTab; label: string }[] = [
23
- { id: "chats", label: "Chats" },
24
- { id: "calls", label: "Calls" },
25
- { id: "users", label: "Users" },
26
- { id: "groups", label: "Groups" },
27
- ];
28
-
29
- export const CometChatTabs = ({
30
- activeTab,
31
- onTabChange,
32
- onItemClick,
33
- }: CometChatTabsProps) => {
34
- const [loggedInUser, setLoggedInUser] = useState<CometChat.User | null>(null);
35
-
36
- useEffect(() => {
37
- setLoggedInUser(CometChatUIKitLoginListener.getLoggedInUser());
38
- }, []);
39
-
40
- if (!loggedInUser) return null;
41
-
42
- return (
43
- <div className="cometchat-tabs">
44
- <div className="cometchat-tabs-content">
45
- {activeTab === "chats" && (
46
- <CometChatConversations
47
- onItemClick={(c) => onItemClick(c)}
48
- />
49
- )}
50
- {activeTab === "calls" && <CometChatCallLogs />}
51
- {activeTab === "users" && (
52
- <CometChatUsers onItemClick={(u) => onItemClick(u)} />
53
- )}
54
- {activeTab === "groups" && (
55
- <CometChatGroups onItemClick={(g) => onItemClick(g)} />
56
- )}
57
- </div>
58
- <nav className="cometchat-tabs-bar">
59
- {TABS.map((tab) => (
60
- <button
61
- key={tab.id}
62
- type="button"
63
- className={`cometchat-tabs-bar-tab${activeTab === tab.id ? " active" : ""}`}
64
- onClick={() => onTabChange(tab.id)}
65
- >
66
- {tab.label}
67
- </button>
68
- ))}
69
- </nav>
70
- </div>
71
- );
72
- };
@@ -1,17 +0,0 @@
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>
@@ -1,39 +0,0 @@
1
- .conversations-with-messages {
2
- display: flex;
3
- height: 100vh;
4
- width: 100%;
5
- }
6
-
7
- .conversations-wrapper {
8
- height: 100%;
9
- width: 480px;
10
- overflow: hidden;
11
- display: flex;
12
- flex-direction: column;
13
- }
14
-
15
- .conversations-wrapper > .cometchat {
16
- overflow: hidden;
17
- }
18
-
19
- .messages-wrapper {
20
- width: calc(100% - 480px);
21
- height: 100%;
22
- display: flex;
23
- flex-direction: column;
24
- }
25
-
26
- .empty-conversation {
27
- height: 100%;
28
- width: 100%;
29
- display: flex;
30
- justify-content: center;
31
- align-items: center;
32
- background: white;
33
- color: var(--cometchat-text-color-secondary, #727272);
34
- font: var(--cometchat-font-body-regular, 400 14px Roboto);
35
- }
36
-
37
- .cometchat .cometchat-message-composer {
38
- border-radius: 0;
39
- }
@@ -1,93 +0,0 @@
1
- "use client";
2
- import React, { useEffect, useState } from "react";
3
- import {
4
- CometChatMessageComposer,
5
- CometChatMessageHeader,
6
- CometChatMessageList,
7
- CometChatUIKit,
8
- UIKitSettingsBuilder,
9
- } from "@cometchat/chat-uikit-react";
10
- import { CometChat } from "@cometchat/chat-sdk-javascript";
11
- import { CometChatTabs, type CometChatTab } from "./CometChatTabs";
12
- // css-variables.css is imported in app/globals.css — do NOT import it here
13
- import "./CometChatNoSSR.css";
14
-
15
- const COMETCHAT_CONSTANTS = {
16
- APP_ID: process.env.{{ENV_PREFIX}}COMETCHAT_APP_ID!,
17
- REGION: process.env.{{ENV_PREFIX}}COMETCHAT_REGION!,
18
- AUTH_KEY: process.env.{{ENV_PREFIX}}COMETCHAT_AUTH_KEY!,
19
- };
20
- const UID = "{{LOGIN_UID}}";
21
-
22
- const CometChatNoSSR: React.FC = () => {
23
- const [user, setUser] = useState<CometChat.User | undefined>();
24
- const [error, setError] = useState<string | null>(null);
25
- const [activeTab, setActiveTab] = useState<CometChatTab>("chats");
26
- const [selectedUser, setSelectedUser] = useState<CometChat.User | undefined>();
27
- const [selectedGroup, setSelectedGroup] = useState<CometChat.Group | undefined>();
28
-
29
- useEffect(() => {
30
- const settings = new UIKitSettingsBuilder()
31
- .setAppId(COMETCHAT_CONSTANTS.APP_ID)
32
- .setRegion(COMETCHAT_CONSTANTS.REGION)
33
- .setAuthKey(COMETCHAT_CONSTANTS.AUTH_KEY)
34
- .subscribePresenceForAllUsers()
35
- .build();
36
-
37
- CometChatUIKit.init(settings)?.then(() => {
38
- CometChatUIKit.getLoggedinUser().then((u) => {
39
- if (!u) {
40
- CometChatUIKit.login(UID)
41
- .then(setUser)
42
- .catch((e: unknown) => setError(String(e)));
43
- } else {
44
- setUser(u);
45
- }
46
- });
47
- }).catch((e: unknown) => setError(String(e)));
48
- }, []);
49
-
50
- const handleSelectorItemClicked = (
51
- activeItem: CometChat.Conversation | CometChat.User | CometChat.Group,
52
- ) => {
53
- const item =
54
- activeItem instanceof CometChat.Conversation
55
- ? activeItem.getConversationWith()
56
- : activeItem;
57
- if (item instanceof CometChat.User) {
58
- setSelectedUser(item);
59
- setSelectedGroup(undefined);
60
- } else if (item instanceof CometChat.Group) {
61
- setSelectedUser(undefined);
62
- setSelectedGroup(item);
63
- }
64
- };
65
-
66
- if (error) return <div style={{ color: "red", padding: 16, fontFamily: "monospace" }}>{error}</div>;
67
- if (!user) return null;
68
-
69
- return (
70
- <div className="conversations-with-messages">
71
- <div className="conversations-wrapper">
72
- <CometChatTabs
73
- activeTab={activeTab}
74
- onTabChange={setActiveTab}
75
- onItemClick={handleSelectorItemClicked}
76
- />
77
- </div>
78
- {selectedUser || selectedGroup ? (
79
- <div className="messages-wrapper">
80
- {selectedUser && <CometChatMessageHeader user={selectedUser} />}
81
- {selectedGroup && <CometChatMessageHeader group={selectedGroup} />}
82
- {selectedUser && <CometChatMessageList user={selectedUser} />}
83
- {selectedGroup && <CometChatMessageList group={selectedGroup} />}
84
- {selectedUser && <CometChatMessageComposer user={selectedUser} />}
85
- {selectedGroup && <CometChatMessageComposer group={selectedGroup} />}
86
- </div>
87
- ) : (
88
- <div className="empty-conversation">Select a conversation to start chatting</div>
89
- )}
90
- </div>
91
- );
92
- };
93
- export default CometChatNoSSR;