@connectycube/chat-widget 0.19.0 → 0.20.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/CHANGELOG.md +158 -0
- package/dist/App.d.ts +5 -0
- package/dist/components/home/main/profile-info.d.ts +5 -2
- package/dist/components/shared/alert-busy.d.ts +2 -0
- package/dist/connectycube-chat-widget-sw.js +19 -0
- package/dist/helpers/connectycube.d.ts +4 -1
- package/dist/helpers/notifications.d.ts +10 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/store/useAlertBusyStore.d.ts +11 -0
- package/dist/hooks/store/useAppInterfaceStore.d.ts +6 -0
- package/dist/hooks/store/useAppNotificationStore.d.ts +12 -0
- package/dist/hooks/store/useAppSettingsStore.d.ts +4 -0
- package/dist/hooks/store/useUserSettingsStore.d.ts +4 -1
- package/dist/hooks/useNotification.d.ts +1 -1
- package/dist/index.es.js +5946 -5618
- package/dist/index.umd.js +33 -33
- package/dist/locales/el/translation.json.d.ts +5 -2
- package/dist/locales/en/translation.json.d.ts +7 -3
- package/dist/locales/ua/translation.json.d.ts +7 -3
- package/package.json +29 -26
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# CHANGELOG
|
|
2
|
+
|
|
3
|
+
## 0.20.0
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- Push Notifications support (receive notifications when browser tab is closed). New props: `webPushNotifications`, `webPushVapidPublicKey`, `serviceWorkerPath`
|
|
8
|
+
- Allow users search from 3 characters min (was 4)
|
|
9
|
+
- New props - `hideNewUserChatOption`, `hideNewGroupChatOption` - To hide 'New group' / 'New message' options in Create Chat dropdown menu
|
|
10
|
+
|
|
11
|
+
### Bug fixes
|
|
12
|
+
|
|
13
|
+
- [mobile] can't access own profile page
|
|
14
|
+
- `attachmetsAccept` prop: block sending unsupported attachments when select All Files in file picker
|
|
15
|
+
- Improved block list flow
|
|
16
|
+
|
|
17
|
+
## 0.19.0
|
|
18
|
+
|
|
19
|
+
### Bug fixes
|
|
20
|
+
|
|
21
|
+
- fix user session restore
|
|
22
|
+
|
|
23
|
+
## 0.18.0
|
|
24
|
+
|
|
25
|
+
### Misc
|
|
26
|
+
|
|
27
|
+
- update styles for chat item for not to interfere with host site styles
|
|
28
|
+
|
|
29
|
+
## 0.17.0
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
- added `My Profile`
|
|
34
|
+
- display blocked users list in `My Profile`
|
|
35
|
+
- added Notification Settings in `My Profile` (can on/off notifications and notification sound)
|
|
36
|
+
- shows a toast message when a blocked user tries to send a message;
|
|
37
|
+
- added `attachmentsAccept` prop to specify supported attachments types
|
|
38
|
+
- added `defaultChat` prop to force widget open particular chat
|
|
39
|
+
|
|
40
|
+
## 0.16.0
|
|
41
|
+
|
|
42
|
+
### Features
|
|
43
|
+
|
|
44
|
+
- report user feature (via `enableContentReporting` prop)
|
|
45
|
+
- block user feature (via `enableBlockList` prop)
|
|
46
|
+
- notification on new message (via `showNotifications`, `playSound` and `muted` props)
|
|
47
|
+
|
|
48
|
+
### Bug fixes
|
|
49
|
+
|
|
50
|
+
- change `break-all` to `break-word` for chat messages text
|
|
51
|
+
- chats list: last item is not visible
|
|
52
|
+
|
|
53
|
+
### Misc
|
|
54
|
+
|
|
55
|
+
- redux store was replaced by [zustand](https://github.com/pmndrs/zustand);
|
|
56
|
+
|
|
57
|
+
## 0.15.2
|
|
58
|
+
|
|
59
|
+
### Misc
|
|
60
|
+
|
|
61
|
+
- update styles for chat item for not to interfere with host site styles
|
|
62
|
+
|
|
63
|
+
## 0.15.1
|
|
64
|
+
|
|
65
|
+
### Bug fixes
|
|
66
|
+
|
|
67
|
+
- User profile link not displayed when open user profile from Users tab
|
|
68
|
+
|
|
69
|
+
### Misc
|
|
70
|
+
|
|
71
|
+
- set static height for user profile header
|
|
72
|
+
- set overflow-hidden for user profile container
|
|
73
|
+
|
|
74
|
+
## 0.15.0
|
|
75
|
+
|
|
76
|
+
### Features
|
|
77
|
+
|
|
78
|
+
- highlight links in chat messages;
|
|
79
|
+
- updated attachments to support uploading any file;
|
|
80
|
+
- create 1-1 chat on send 1st message, not when click on a user
|
|
81
|
+
- encapsulated chat widget styles to prevent global styling effects;
|
|
82
|
+
- implemented `open` prop to manage chat widget visibility state;
|
|
83
|
+
- implemented `window.ConnectyCubeChatWidget.toggle()` function to manage chat widget visibility state when used as UMD;
|
|
84
|
+
- implemented `onOpenChange` and `onUnreadCountChange` props as callbacks to receive updates on the visibility of the chat widget and the unread message counter, respectively;
|
|
85
|
+
- implemented `hideWidgetButton` prop to hide the chat widget button and use a custom one;
|
|
86
|
+
- implemented browser notifications and `showNotifications` prop to enable the feature;
|
|
87
|
+
|
|
88
|
+
### Bug fixes
|
|
89
|
+
|
|
90
|
+
- blocked sending files as attachments if they do not have `type` or `size` properties.
|
|
91
|
+
- fixed z-index for Chat button and widget view
|
|
92
|
+
|
|
93
|
+
### Misc
|
|
94
|
+
|
|
95
|
+
- upgraded tailwindcss to version 4;
|
|
96
|
+
- upgraded ShadCN-UI components to support TailwindCSS version 4;
|
|
97
|
+
|
|
98
|
+
## 0.14.4
|
|
99
|
+
|
|
100
|
+
### Bug fixes
|
|
101
|
+
|
|
102
|
+
- fix avatar crash when chat name is empty
|
|
103
|
+
|
|
104
|
+
## 0.14.3
|
|
105
|
+
|
|
106
|
+
### Bug fixes
|
|
107
|
+
|
|
108
|
+
- fix missing typings declaration
|
|
109
|
+
|
|
110
|
+
## 0.14.2
|
|
111
|
+
|
|
112
|
+
### Bug fixes
|
|
113
|
+
|
|
114
|
+
- fix README
|
|
115
|
+
|
|
116
|
+
## 0.14.0
|
|
117
|
+
|
|
118
|
+
### Features
|
|
119
|
+
|
|
120
|
+
- introduce user profile link via `userProfileLink` prop
|
|
121
|
+
- hide new chat button via `hideNewChatButton` prop
|
|
122
|
+
- English, Greek, Ukrainian languages supported via `translation` prop
|
|
123
|
+
|
|
124
|
+
## 0.13.0
|
|
125
|
+
|
|
126
|
+
### Features
|
|
127
|
+
|
|
128
|
+
- user avatar
|
|
129
|
+
- suggested messages
|
|
130
|
+
|
|
131
|
+
## 0.12.0
|
|
132
|
+
|
|
133
|
+
### Features
|
|
134
|
+
|
|
135
|
+
- message drafts
|
|
136
|
+
- allow to change `userId` prop on the flight
|
|
137
|
+
|
|
138
|
+
### Bug fixes
|
|
139
|
+
|
|
140
|
+
- fix mobile UI styles
|
|
141
|
+
|
|
142
|
+
## 0.11.0
|
|
143
|
+
|
|
144
|
+
### Features
|
|
145
|
+
|
|
146
|
+
- displays total unread messages counter;
|
|
147
|
+
- placeholders for empty lists;
|
|
148
|
+
|
|
149
|
+
### Bug fixes
|
|
150
|
+
|
|
151
|
+
- can restore expired session;
|
|
152
|
+
- can retrieve messages while the widget is collapsed;
|
|
153
|
+
- incoming notification sound;
|
|
154
|
+
- UI styles;
|
|
155
|
+
|
|
156
|
+
## 0.10.0
|
|
157
|
+
|
|
158
|
+
Initial release.
|
package/dist/App.d.ts
CHANGED
|
@@ -13,9 +13,14 @@ export type AppProps = {
|
|
|
13
13
|
splitView?: boolean;
|
|
14
14
|
showOnlineUsersTab?: boolean;
|
|
15
15
|
hideNewChatButton?: boolean;
|
|
16
|
+
hideNewUserChatOption?: boolean;
|
|
17
|
+
hideNewGroupChatOption?: boolean;
|
|
16
18
|
muted?: boolean;
|
|
17
19
|
showNotifications?: boolean;
|
|
18
20
|
playSound?: boolean;
|
|
21
|
+
webPushNotifications?: boolean;
|
|
22
|
+
webPushVapidPublicKey?: string;
|
|
23
|
+
serviceWorkerPath?: string | URL;
|
|
19
24
|
attachmentsAccept?: string;
|
|
20
25
|
enableContentReporting?: boolean;
|
|
21
26
|
enableBlockList?: boolean;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type ProfileInfoProps = {
|
|
3
|
+
profileClassName: string;
|
|
4
|
+
};
|
|
5
|
+
declare const _default: React.NamedExoticComponent<ProfileInfoProps>;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
self.addEventListener('install', (event) => {
|
|
2
|
+
self.skipWaiting();
|
|
3
|
+
});
|
|
4
|
+
|
|
5
|
+
self.addEventListener('push', (event) => {
|
|
6
|
+
const { data } = event.data?.json() || {};
|
|
7
|
+
const title = data.title || '';
|
|
8
|
+
const options = {
|
|
9
|
+
body: data.message || '',
|
|
10
|
+
icon: data.photo || '/logo.png',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
event.waitUntil(self.registration.showNotification(title, options));
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
self.addEventListener('notificationclick', (event) => {
|
|
17
|
+
event.notification.close();
|
|
18
|
+
event.waitUntil(clients.openWindow('/'));
|
|
19
|
+
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Config, Users, Auth, Chat } from '../../node_modules/connectycube/src/types';
|
|
1
|
+
import { Config, Users, Auth, Chat, EmptyResponse, PushNotifications } from '../../node_modules/connectycube/src/types';
|
|
2
|
+
import { PushSubscriptionData } from './notifications';
|
|
2
3
|
export declare const SESSION_KEY = "@connectycube/chat-widget:session";
|
|
3
4
|
export declare const initConnectyCubeSDK: (credentials: Config.Credentials, config?: Config.Options) => void;
|
|
4
5
|
export declare const tryReuseSession: (userName?: string, userId?: string, userAvatar?: string, userProfileLink?: string) => Promise<boolean>;
|
|
@@ -28,3 +29,5 @@ export declare const getUserName: (user: Users.User | null | undefined, force?:
|
|
|
28
29
|
export declare const getPhotoUrl: (photoOrAvatar?: string | null) => string;
|
|
29
30
|
export declare const generateConnectyCubeLogin: (userId?: string) => string;
|
|
30
31
|
export declare const createUserReport: (reportedUserId: number, reason: string) => Promise<import("@connectycube/types").Data.DataRecord>;
|
|
32
|
+
export declare const subscribeToPushNotifications: (pushSubscriptionData?: PushSubscriptionData) => Promise<PushNotifications.Subscription | undefined>;
|
|
33
|
+
export declare const unsubscribeFromPushNotifications: () => Promise<EmptyResponse[]>;
|
|
@@ -1 +1,11 @@
|
|
|
1
|
+
export type PushSubscriptionData = {
|
|
2
|
+
endpoint: string;
|
|
3
|
+
auth: string;
|
|
4
|
+
p256dh: string;
|
|
5
|
+
} | undefined;
|
|
1
6
|
export declare const requestNotificationPermission: () => Promise<void>;
|
|
7
|
+
export declare const registerWidgetServiceWorker: (serviceWorkerPath?: string | URL) => Promise<void>;
|
|
8
|
+
export declare const getWidgetServiceWorker: (serviceWorkerPath?: string | URL) => Promise<ServiceWorkerRegistration | void>;
|
|
9
|
+
export declare const getPushManagerSubscriptionData: (subscription?: PushSubscription | null) => PushSubscriptionData;
|
|
10
|
+
export declare const getPushManagerSubscription: (serviceWorkerPath?: string | URL, applicationServerKey?: PushSubscriptionOptionsInit["applicationServerKey"]) => Promise<PushSubscription | null>;
|
|
11
|
+
export declare const unsubscribePushManager: (serviceWorkerPath?: string | URL) => Promise<boolean>;
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const resetStore: (force?: boolean) => void;
|
|
2
2
|
export { default as useActiveTabsStore } from './store/useActiveTabsStore';
|
|
3
|
+
export { default as useAlertBusyStore } from './store/useAlertBusyStore';
|
|
3
4
|
export { default as useAppDefaultChatStore } from './store/useAppDefaultChatStore';
|
|
4
5
|
export { default as useAppInterfaceStore } from './store/useAppInterfaceStore';
|
|
5
6
|
export { default as useAppSettingsStore } from './store/useAppSettingsStore';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type AlertBusyStateProps = {
|
|
2
|
+
visible: boolean;
|
|
3
|
+
title: string;
|
|
4
|
+
};
|
|
5
|
+
interface AlertBusyState extends AlertBusyStateProps {
|
|
6
|
+
showAlertBusy: (title: string) => void;
|
|
7
|
+
hideAlertBusy: () => void;
|
|
8
|
+
}
|
|
9
|
+
declare const useAlertBusyStore: import('zustand').UseBoundStore<import('zustand').StoreApi<AlertBusyState>>;
|
|
10
|
+
export declare const resetAlertBusyStore: () => void;
|
|
11
|
+
export default useAlertBusyStore;
|
|
@@ -3,16 +3,22 @@ export type AppInterfaceStoreProps = {
|
|
|
3
3
|
splitView: boolean;
|
|
4
4
|
showOnlineUsersTab: boolean;
|
|
5
5
|
hideNewChatButton: boolean;
|
|
6
|
+
hideNewUserChatOption: boolean;
|
|
7
|
+
hideNewGroupChatOption: boolean;
|
|
6
8
|
};
|
|
7
9
|
export interface AppInterfaceStoreState extends AppInterfaceStoreProps {
|
|
8
10
|
setOpened: (opened: boolean) => void;
|
|
9
11
|
setSplitView: (splitView: boolean) => void;
|
|
10
12
|
setShowOnlineUsersTab: (showOnlineUsersTab: boolean) => void;
|
|
11
13
|
setHideNewChatButton: (hideNewChatButton: boolean) => void;
|
|
14
|
+
setHideNewUserChatOption: (hideNewUserChatOption: boolean) => void;
|
|
15
|
+
setHideNewGroupChatOption: (hideNewGroupChatOption: boolean) => void;
|
|
12
16
|
resetOpened: () => void;
|
|
13
17
|
resetSplitView: () => void;
|
|
14
18
|
resetShowOnlineUsersTab: () => void;
|
|
15
19
|
resetHideNewChatButton: () => void;
|
|
20
|
+
resetHideNewUserChatOption: () => void;
|
|
21
|
+
resetHideNewGroupChatOption: () => void;
|
|
16
22
|
}
|
|
17
23
|
export declare const appInterfaceStoreInitialState: AppInterfaceStoreProps;
|
|
18
24
|
declare const useAppInterfaceStore: import('zustand').UseBoundStore<import('zustand').StoreApi<AppInterfaceStoreState>>;
|
|
@@ -2,6 +2,9 @@ type AppNotificationStoreProps = {
|
|
|
2
2
|
muted: boolean;
|
|
3
3
|
showNotifications: boolean;
|
|
4
4
|
playSound: boolean;
|
|
5
|
+
webPushNotifications: boolean;
|
|
6
|
+
webPushVapidPublicKey?: string;
|
|
7
|
+
serviceWorkerPath?: string | URL;
|
|
5
8
|
};
|
|
6
9
|
export interface AppNotificationStoreState extends AppNotificationStoreProps {
|
|
7
10
|
setMuted: (muted: boolean) => void;
|
|
@@ -10,11 +13,20 @@ export interface AppNotificationStoreState extends AppNotificationStoreProps {
|
|
|
10
13
|
resetShowNotifications: () => void;
|
|
11
14
|
setPlaySound: (playSound: boolean) => void;
|
|
12
15
|
resetPlaySound: () => void;
|
|
16
|
+
setWebPushNotifications: (webPushNotifications: boolean) => void;
|
|
17
|
+
resetWebPushNotifications: () => void;
|
|
18
|
+
setWebPushVapidPublicKey: (webPushVapidPublicKey?: string) => void;
|
|
19
|
+
resetWebPushVapidPublicKey: () => void;
|
|
20
|
+
setServiceWorkerPath: (serviceWorkerPath?: string | URL) => void;
|
|
21
|
+
resetServiceWorkerPath: () => void;
|
|
13
22
|
}
|
|
14
23
|
export declare const notificationStoreInitialState: {
|
|
15
24
|
muted: boolean;
|
|
16
25
|
showNotifications: boolean;
|
|
17
26
|
playSound: boolean;
|
|
27
|
+
webPushNotifications: boolean;
|
|
28
|
+
webPushVapidPublicKey: undefined;
|
|
29
|
+
serviceWorkerPath: undefined;
|
|
18
30
|
};
|
|
19
31
|
declare const useAppNotificationStore: import('zustand').UseBoundStore<import('zustand').StoreApi<AppNotificationStoreState>>;
|
|
20
32
|
export declare const setAppNotificationStore: (state: Partial<AppNotificationStoreProps>) => void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type AppSettingStoreProps = {
|
|
2
2
|
attachmentsAccept: string;
|
|
3
|
+
attachmentsAcceptList: string[];
|
|
3
4
|
enableContentReporting: boolean;
|
|
4
5
|
enableBlockList: boolean;
|
|
5
6
|
};
|
|
@@ -10,9 +11,12 @@ export interface AppSettingStoreState extends AppSettingStoreProps {
|
|
|
10
11
|
resetAttachmentsAccept: () => void;
|
|
11
12
|
resetEnableContentReporting: () => void;
|
|
12
13
|
resetEnableBlockList: () => void;
|
|
14
|
+
isSupportedFile: (file: File) => boolean;
|
|
13
15
|
}
|
|
14
16
|
export declare const appSettingsStoreInitialState: AppSettingStoreProps;
|
|
15
17
|
declare const useAppSettingsStore: import('zustand').UseBoundStore<import('zustand').StoreApi<AppSettingStoreState>>;
|
|
16
18
|
export declare const setAppSettingsStore: (state: Partial<AppSettingStoreProps>) => void;
|
|
17
19
|
export declare const resetAppSettingsStore: () => void;
|
|
18
20
|
export default useAppSettingsStore;
|
|
21
|
+
export declare const getAttachmentsAcceptList: (attachmentsAccept: string) => string[];
|
|
22
|
+
export declare const isSupportedFileMimeType: (file: File, attachmentsAcceptList: AppSettingStoreState["attachmentsAcceptList"]) => boolean;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
type UserSettingsStateProps = {
|
|
2
2
|
isNotifications: boolean;
|
|
3
3
|
isNotificationSound: boolean;
|
|
4
|
+
isPushNotifications: boolean;
|
|
4
5
|
};
|
|
5
6
|
interface UserSettingsState extends UserSettingsStateProps {
|
|
6
7
|
setIsNotifications: (enabled: boolean) => Promise<void>;
|
|
7
8
|
setIsNotificationSound: (enabled: boolean) => Promise<void>;
|
|
9
|
+
setIsPushNotifications: (enabled: boolean) => Promise<void>;
|
|
8
10
|
}
|
|
9
11
|
declare const useUserSettingsStore: import('zustand').UseBoundStore<import('zustand').StoreApi<UserSettingsState>>;
|
|
10
|
-
export declare const
|
|
12
|
+
export declare const managePushNotificationsSubscription: (enable: boolean) => Promise<void>;
|
|
13
|
+
export declare const restoreUserSettingsStore: () => Promise<void>;
|
|
11
14
|
export default useUserSettingsStore;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Chat } from '../../node_modules/connectycube/src/types';
|
|
2
2
|
type NotificationHook = {
|
|
3
|
-
showNotification: (title: string, body: string, icon: string) => Notification | void
|
|
3
|
+
showNotification: (title: string, body: string, icon: string) => Promise<Notification | void>;
|
|
4
4
|
notifyOnMessage: (userId: number, message: Chat.Message) => Promise<Notification | void>;
|
|
5
5
|
playAudio: () => void;
|
|
6
6
|
};
|