@droppii-org/chat-sdk 0.1.69 → 0.1.71
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/dist/components/media-collection/FileCollection.d.ts.map +1 -1
- package/dist/components/media-collection/FileCollection.js +1 -2
- package/dist/components/message/footer/FilePreview.d.ts +0 -6
- package/dist/components/message/footer/FilePreview.d.ts.map +1 -1
- package/dist/components/message/footer/FilePreview.js +1 -17
- package/dist/components/message/item/FileMessage.d.ts.map +1 -1
- package/dist/components/message/item/FileMessage.js +1 -2
- package/dist/components/message/reply/ReplyQuoteContent.d.ts.map +1 -1
- package/dist/components/message/reply/ReplyQuoteContent.js +5 -2
- package/dist/hooks/message/useSendMessage.d.ts.map +1 -1
- package/dist/hooks/message/useSendMessage.js +7 -4
- package/dist/locales/vi/common.json +1 -1
- package/dist/utils/common.d.ts +10 -1
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/utils/common.js +35 -8
- package/package.json +126 -132
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileCollection.d.ts","sourceRoot":"","sources":["../../../src/components/media-collection/FileCollection.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FileCollection.d.ts","sourceRoot":"","sources":["../../../src/components/media-collection/FileCollection.tsx"],"names":[],"mappings":"AAYA,QAAA,MAAM,cAAc,+CAqGnB,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -8,8 +8,7 @@ import dayjs from "dayjs";
|
|
|
8
8
|
import useConversationStore from "../../store/conversation";
|
|
9
9
|
import { useTranslation } from "react-i18next";
|
|
10
10
|
import { documentIcon } from "../../assets/svg";
|
|
11
|
-
import { shortenFileName } from "../../
|
|
12
|
-
import { renderFileSize } from "../../utils/common";
|
|
11
|
+
import { renderFileSize, shortenFileName } from "../../utils/common";
|
|
13
12
|
const FileCollection = () => {
|
|
14
13
|
const { t } = useTranslation();
|
|
15
14
|
const selectedSourceId = useConversationStore((state) => state.selectedSourceId);
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
import { UploadFile } from "antd";
|
|
2
|
-
interface ShortenOptions {
|
|
3
|
-
maxLength?: number;
|
|
4
|
-
keepStart?: number;
|
|
5
|
-
keepEnd?: number;
|
|
6
|
-
}
|
|
7
|
-
export declare const shortenFileName: (name?: string, options?: ShortenOptions) => string;
|
|
8
2
|
export declare function FilePreviewList({ files, onRemove, onVideoReady, }: {
|
|
9
3
|
files: UploadFile[];
|
|
10
4
|
onRemove: (file: UploadFile) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilePreview.d.ts","sourceRoot":"","sources":["../../../../src/components/message/footer/FilePreview.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"FilePreview.d.ts","sourceRoot":"","sources":["../../../../src/components/message/footer/FilePreview.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AA6IlC,wBAAgB,eAAe,CAAC,EAC9B,KAAK,EACL,QAAQ,EACR,YAAY,GACb,EAAE;IACD,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,QAAQ,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;IACrC,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;CAC3B,kDAsBA;AAED,QAAA,MAAM,WAAW,+CAQhB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -5,23 +5,7 @@ import { useMessageFooterContext } from ".";
|
|
|
5
5
|
import { Icon } from "../../../components/icon";
|
|
6
6
|
import { documentIcon } from "../../../assets/svg";
|
|
7
7
|
import { DOCUMENT_MIME_TYPES } from "../../../utils/fileValidation";
|
|
8
|
-
import { formatDuration } from "../../../utils/common";
|
|
9
|
-
export const shortenFileName = (name, options = {}) => {
|
|
10
|
-
if (!name)
|
|
11
|
-
return "";
|
|
12
|
-
const { maxLength = 20, keepStart = 8, keepEnd = 3 } = options;
|
|
13
|
-
if (name.length <= maxLength)
|
|
14
|
-
return name;
|
|
15
|
-
const dotIndex = name.lastIndexOf(".");
|
|
16
|
-
const ext = dotIndex !== -1 ? name.slice(dotIndex) : "";
|
|
17
|
-
const base = dotIndex !== -1 ? name.slice(0, dotIndex) : name;
|
|
18
|
-
const available = maxLength - ext.length - 3;
|
|
19
|
-
const startLen = keepStart !== null && keepStart !== void 0 ? keepStart : Math.floor(available / 2);
|
|
20
|
-
const endLen = keepEnd !== null && keepEnd !== void 0 ? keepEnd : Math.floor(available / 2);
|
|
21
|
-
const start = base.slice(0, startLen);
|
|
22
|
-
const end = base.slice(-endLen);
|
|
23
|
-
return `${start}...${end}${ext}`;
|
|
24
|
-
};
|
|
8
|
+
import { formatDuration, shortenFileName } from "../../../utils/common";
|
|
25
9
|
const formatFileSize = (bytes) => {
|
|
26
10
|
if (bytes === 0)
|
|
27
11
|
return "0 B";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileMessage.d.ts","sourceRoot":"","sources":["../../../../src/components/message/item/FileMessage.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAiB,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"FileMessage.d.ts","sourceRoot":"","sources":["../../../../src/components/message/item/FileMessage.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAiB,MAAM,yBAAyB,CAAC;AAMrE,UAAU,oBAAoB;IAC5B,OAAO,EAAE,WAAW,CAAC;CACtB;AAED,QAAA,MAAM,eAAe,GAAI,OAAO,oBAAoB,4CAiEnD,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -3,8 +3,7 @@ import { MessageStatus } from "@openim/wasm-client-sdk";
|
|
|
3
3
|
import { Spin } from "antd";
|
|
4
4
|
import { Icon } from "../../../components/icon";
|
|
5
5
|
import { documentIcon } from "../../../assets/svg";
|
|
6
|
-
import { shortenFileName } from "../../../
|
|
7
|
-
import { renderFileSize } from "../../../utils/common";
|
|
6
|
+
import { renderFileSize, shortenFileName } from "../../../utils/common";
|
|
8
7
|
const FileMessageItem = (props) => {
|
|
9
8
|
var _a;
|
|
10
9
|
const { message } = props;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReplyQuoteContent.d.ts","sourceRoot":"","sources":["../../../../src/components/message/reply/ReplyQuoteContent.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AASnE,eAAO,MAAM,oBAAoB,GAAI,aAAa,WAAW,YACb,CAAC;AAEjD,UAAU,sBAAsB;IAC9B,OAAO,EAAE,WAAW,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,iBAAiB,GAAI,qBAG/B,sBAAsB,
|
|
1
|
+
{"version":3,"file":"ReplyQuoteContent.d.ts","sourceRoot":"","sources":["../../../../src/components/message/reply/ReplyQuoteContent.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AASnE,eAAO,MAAM,oBAAoB,GAAI,aAAa,WAAW,YACb,CAAC;AAEjD,UAAU,sBAAsB;IAC9B,OAAO,EAAE,WAAW,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,iBAAiB,GAAI,qBAG/B,sBAAsB,4CA0BxB,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -9,9 +9,12 @@ const TEXT_LIKE_MESSAGE_TYPES = [
|
|
|
9
9
|
];
|
|
10
10
|
export const hasReplyMediaPreview = (contentType) => !TEXT_LIKE_MESSAGE_TYPES.includes(contentType);
|
|
11
11
|
export const ReplyQuoteContent = ({ message, title = "", }) => {
|
|
12
|
-
var _a, _b;
|
|
12
|
+
var _a, _b, _c, _d;
|
|
13
13
|
const { t } = useTranslation();
|
|
14
14
|
const hasMedia = hasReplyMediaPreview(message.contentType);
|
|
15
|
-
return (_jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-0.5 pr-2 self-stretch", children: [_jsx("div", { className: "w-[3px] shrink-0 self-stretch rounded bg-gray-cool-200" }), hasMedia && _jsx(ReplyPreviewMedia, { message: message }), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col justify-center py-1 pl-2", children: [_jsx("p", { className: "truncate text-[14px] font-medium leading-[160%] text-gray-900", children: title }), _jsx("p", { className: "truncate text-[13px] leading-[160%] text-gray-400", children: generateContentBasedOnMessageType(message.contentType, ((_a = message.textElem) === null || _a === void 0 ? void 0 : _a.content) || ((_b = message.quoteElem) === null || _b === void 0 ? void 0 : _b.text), t
|
|
15
|
+
return (_jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-0.5 pr-2 self-stretch", children: [_jsx("div", { className: "w-[3px] shrink-0 self-stretch rounded bg-gray-cool-200" }), hasMedia && _jsx(ReplyPreviewMedia, { message: message }), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col justify-center py-1 pl-2", children: [_jsx("p", { className: "truncate text-[14px] font-medium leading-[160%] text-gray-900", children: title }), _jsx("p", { className: "truncate text-[13px] leading-[160%] text-gray-400", children: generateContentBasedOnMessageType(message.contentType, ((_a = message.textElem) === null || _a === void 0 ? void 0 : _a.content) || ((_b = message.quoteElem) === null || _b === void 0 ? void 0 : _b.text), t, {
|
|
16
|
+
duration: (_c = message.videoElem) === null || _c === void 0 ? void 0 : _c.duration,
|
|
17
|
+
fileName: (_d = message.fileElem) === null || _d === void 0 ? void 0 : _d.fileName,
|
|
18
|
+
}) })] })] }));
|
|
16
19
|
};
|
|
17
20
|
export default ReplyQuoteContent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSendMessage.d.ts","sourceRoot":"","sources":["../../../src/hooks/message/useSendMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,WAAW,EAGZ,MAAM,yBAAyB,C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AE,MAAM,CAAA;KAAE,KAAK,eAAe,CAAC;CACxE;AAED,eAAO,MAAM,cAAc,GAAI,UAAU,qBAAqB;uGAsPvD;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;QACrB,cAAc,CAAC,EAAE,gBAAgB,CAAC;QAClC,UAAU,EAAE,OAAO,CAAC;QACpB,WAAW,CAAC,EAAE,eAAe,CAAC;QAC9B,IAAI,CAAC,EAAE,WAAW,CAAC;KACpB,KAAG,OAAO,CAAC,OAAO,CAAC;mCAxHE,WAAW;CA8SpC,CAAC;AAEF,eAAO,MAAM,yBAAyB,GAAI,kDAKvC;IACD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,cAAc,CAAC,EAAE,gBAAgB,CAAC;IAClC,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB,sBA8BA,CAAC"}
|
|
@@ -139,9 +139,12 @@ export const useSendMessage = (options) => {
|
|
|
139
139
|
}
|
|
140
140
|
}, [queryClient]);
|
|
141
141
|
const dispatchMessage = useCallback(async (message, currentSession) => {
|
|
142
|
-
var _a, _b, _c, _d;
|
|
143
|
-
const desc = generateContentBasedOnMessageType(message.contentType, ((_a = message === null || message === void 0 ? void 0 : message.textElem) === null || _a === void 0 ? void 0 : _a.content) || ""
|
|
144
|
-
|
|
142
|
+
var _a, _b, _c, _d, _e, _f;
|
|
143
|
+
const desc = generateContentBasedOnMessageType(message.contentType, ((_a = message === null || message === void 0 ? void 0 : message.textElem) === null || _a === void 0 ? void 0 : _a.content) || "", undefined, {
|
|
144
|
+
duration: (_b = message.videoElem) === null || _b === void 0 ? void 0 : _b.duration,
|
|
145
|
+
fileName: (_c = message.fileElem) === null || _c === void 0 ? void 0 : _c.fileName,
|
|
146
|
+
}) || t("new_message");
|
|
147
|
+
const pushMeta = (_e = (_d = options === null || options === void 0 ? void 0 : options.resolveOfflinePushMeta) === null || _d === void 0 ? void 0 : _d.call(options, { desc })) !== null && _e !== void 0 ? _e : {
|
|
145
148
|
title: (conversationData === null || conversationData === void 0 ? void 0 : conversationData.showName) || "Droppii Chat",
|
|
146
149
|
icon: (conversationData === null || conversationData === void 0 ? void 0 : conversationData.faceURL) || "",
|
|
147
150
|
conversationId: (conversationData === null || conversationData === void 0 ? void 0 : conversationData.conversationID) || "",
|
|
@@ -163,7 +166,7 @@ export const useSendMessage = (options) => {
|
|
|
163
166
|
iOSBadgeCount: true,
|
|
164
167
|
},
|
|
165
168
|
});
|
|
166
|
-
updateOneMessage(Object.assign(Object.assign({}, successMessage), { ex: successMessage.ex || message.ex || "{}", isInternal: (
|
|
169
|
+
updateOneMessage(Object.assign(Object.assign({}, successMessage), { ex: successMessage.ex || message.ex || "{}", isInternal: (_f = successMessage.isInternal) !== null && _f !== void 0 ? _f : message.isInternal }));
|
|
167
170
|
if (!message.isInternal) {
|
|
168
171
|
await syncSessionAfterPublicMessage(currentSession);
|
|
169
172
|
}
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"search_message_title": "Tìm kiếm tin nhắn",
|
|
101
101
|
"msg_type_image": "[Hình ảnh]",
|
|
102
102
|
"msg_type_voice": "[Tin nhắn thoại]",
|
|
103
|
-
"msg_type_file": "[
|
|
103
|
+
"msg_type_file": "[File]",
|
|
104
104
|
"msg_type_video": "[Video]",
|
|
105
105
|
"msg_type_unsupported": "Tin nhắn không khả dụng",
|
|
106
106
|
"session_started": "Phiên chat đã bắt đầu",
|
package/dist/utils/common.d.ts
CHANGED
|
@@ -5,7 +5,16 @@ import { PeerType } from "../types/conversation";
|
|
|
5
5
|
export declare const parseUrlMetadata: (ex?: string) => UrlMetadataInfo | undefined;
|
|
6
6
|
export declare function formatDuration(seconds: number): string;
|
|
7
7
|
export declare function renderFileSize(bytes: number): string;
|
|
8
|
-
|
|
8
|
+
interface ShortenFileNameOptions {
|
|
9
|
+
maxLength?: number;
|
|
10
|
+
keepStart?: number;
|
|
11
|
+
keepEnd?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare const shortenFileName: (name?: string, options?: ShortenFileNameOptions) => string;
|
|
14
|
+
export declare const generateContentBasedOnMessageType: (contentType: MessageType, plainText?: string, t?: TFunction, mediaMeta?: {
|
|
15
|
+
duration?: number;
|
|
16
|
+
fileName?: string;
|
|
17
|
+
}) => string;
|
|
9
18
|
export declare const parseLatestMessage: (latestMsg: string, currentUserId?: string, t?: TFunction, conversation?: {
|
|
10
19
|
peerType?: PeerType | string;
|
|
11
20
|
showName?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/utils/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGnE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAqB,eAAe,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGhD,eAAO,MAAM,gBAAgB,GAAI,KAAK,MAAM,KAAG,eAAe,GAAG,SAQhE,CAAC;AAwBF,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAItD;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAapD;AAED,eAAO,MAAM,iCAAiC,GAC5C,aAAa,WAAW,EACxB,YAAY,MAAM,EAClB,IAAI,SAAS,
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/utils/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAGnE,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAqB,eAAe,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGh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,GAAG,IAOrD,CAAC;AAKF,eAAO,MAAM,iBAAiB,GAAI,MAAM,MAAM,KAAG,OACf,CAAC;AAEnC,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,KAAG,MAO9B,CAAC;AAEZ;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAgEjD"}
|
package/dist/utils/common.js
CHANGED
|
@@ -46,7 +46,23 @@ export function renderFileSize(bytes) {
|
|
|
46
46
|
}
|
|
47
47
|
return `${size.toFixed(1)} ${units[index]}`;
|
|
48
48
|
}
|
|
49
|
-
export const
|
|
49
|
+
export const shortenFileName = (name, options = {}) => {
|
|
50
|
+
if (!name)
|
|
51
|
+
return "";
|
|
52
|
+
const { maxLength = 20, keepStart = 8, keepEnd = 3 } = options;
|
|
53
|
+
if (name.length <= maxLength)
|
|
54
|
+
return name;
|
|
55
|
+
const dotIndex = name.lastIndexOf(".");
|
|
56
|
+
const ext = dotIndex !== -1 ? name.slice(dotIndex) : "";
|
|
57
|
+
const base = dotIndex !== -1 ? name.slice(0, dotIndex) : name;
|
|
58
|
+
const available = maxLength - ext.length - 3;
|
|
59
|
+
const startLen = keepStart !== null && keepStart !== void 0 ? keepStart : Math.floor(available / 2);
|
|
60
|
+
const endLen = keepEnd !== null && keepEnd !== void 0 ? keepEnd : Math.floor(available / 2);
|
|
61
|
+
const start = base.slice(0, startLen);
|
|
62
|
+
const end = base.slice(-endLen);
|
|
63
|
+
return `${start}...${end}${ext}`;
|
|
64
|
+
};
|
|
65
|
+
export const generateContentBasedOnMessageType = (contentType, plainText, t, mediaMeta) => {
|
|
50
66
|
switch (contentType) {
|
|
51
67
|
case MessageType.TextMessage:
|
|
52
68
|
case MessageType.QuoteMessage:
|
|
@@ -58,10 +74,18 @@ export const generateContentBasedOnMessageType = (contentType, plainText, t) =>
|
|
|
58
74
|
return t ? t("msg_type_image") : "[Hình ảnh]";
|
|
59
75
|
case MessageType.VoiceMessage:
|
|
60
76
|
return t ? t("msg_type_voice") : "[Tin nhắn thoại]";
|
|
61
|
-
case MessageType.VideoMessage:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
77
|
+
case MessageType.VideoMessage: {
|
|
78
|
+
const base = t ? t("msg_type_video") : "[Video]";
|
|
79
|
+
const durationLabel = (mediaMeta === null || mediaMeta === void 0 ? void 0 : mediaMeta.duration) != null
|
|
80
|
+
? formatDuration(mediaMeta.duration / 1000)
|
|
81
|
+
: "";
|
|
82
|
+
return durationLabel ? `${base} ${durationLabel}` : base;
|
|
83
|
+
}
|
|
84
|
+
case MessageType.FileMessage: {
|
|
85
|
+
const base = t ? t("msg_type_file") : "[File]";
|
|
86
|
+
const fileName = shortenFileName(mediaMeta === null || mediaMeta === void 0 ? void 0 : mediaMeta.fileName);
|
|
87
|
+
return fileName ? `${base} ${fileName}` : base;
|
|
88
|
+
}
|
|
65
89
|
case MessageType.RevokeMessage:
|
|
66
90
|
return t ? t("revoked") : "Đã thu hồi tin nhắn";
|
|
67
91
|
default:
|
|
@@ -69,7 +93,7 @@ export const generateContentBasedOnMessageType = (contentType, plainText, t) =>
|
|
|
69
93
|
}
|
|
70
94
|
};
|
|
71
95
|
export const parseLatestMessage = (latestMsg, currentUserId, t, conversation) => {
|
|
72
|
-
var _a, _b, _c, _d;
|
|
96
|
+
var _a, _b, _c, _d, _e, _f;
|
|
73
97
|
if (!latestMsg || !t)
|
|
74
98
|
return "";
|
|
75
99
|
try {
|
|
@@ -91,11 +115,14 @@ export const parseLatestMessage = (latestMsg, currentUserId, t, conversation) =>
|
|
|
91
115
|
case MessageType.VoiceMessage:
|
|
92
116
|
case MessageType.VideoMessage:
|
|
93
117
|
case MessageType.FileMessage:
|
|
94
|
-
return formatWithSender(sender, generateContentBasedOnMessageType(contentType
|
|
118
|
+
return formatWithSender(sender, generateContentBasedOnMessageType(contentType, undefined, t, {
|
|
119
|
+
duration: (_d = msgData === null || msgData === void 0 ? void 0 : msgData.videoElem) === null || _d === void 0 ? void 0 : _d.duration,
|
|
120
|
+
fileName: (_e = msgData === null || msgData === void 0 ? void 0 : msgData.fileElem) === null || _e === void 0 ? void 0 : _e.fileName,
|
|
121
|
+
}));
|
|
95
122
|
case MessageType.RevokeMessage:
|
|
96
123
|
return sender ? t("revoked_with_sender", { name: sender }) : t("revoked");
|
|
97
124
|
case MessageType.CustomMessage: {
|
|
98
|
-
const customData = (
|
|
125
|
+
const customData = (_f = msgData.customElem) === null || _f === void 0 ? void 0 : _f.data;
|
|
99
126
|
if (customData === "#SESSION - START") {
|
|
100
127
|
return t("session_started");
|
|
101
128
|
}
|
package/package.json
CHANGED
|
@@ -1,132 +1,126 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@droppii-org/chat-sdk",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Droppii React Chat SDK",
|
|
5
|
-
"main": "./dist/index.js",
|
|
6
|
-
"types": "./dist/index.d.ts",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": {
|
|
9
|
-
"import": "./dist/index.js",
|
|
10
|
-
"types": "./dist/index.d.ts"
|
|
11
|
-
},
|
|
12
|
-
"./components/*": {
|
|
13
|
-
"import": "./dist/components/*.js",
|
|
14
|
-
"types": "./dist/components/*.d.ts"
|
|
15
|
-
},
|
|
16
|
-
"./hooks/*": {
|
|
17
|
-
"import": "./dist/hooks/*.js",
|
|
18
|
-
"types": "./dist/hooks/*.d.ts"
|
|
19
|
-
},
|
|
20
|
-
"./context/*": {
|
|
21
|
-
"import": "./dist/context/*.js",
|
|
22
|
-
"types": "./dist/context/*.d.ts"
|
|
23
|
-
},
|
|
24
|
-
"./types/*": {
|
|
25
|
-
"import": "./dist/types/*.js",
|
|
26
|
-
"types": "./dist/types/*.d.ts"
|
|
27
|
-
},
|
|
28
|
-
"./screens/*": {
|
|
29
|
-
"import": "./dist/screens/*.js",
|
|
30
|
-
"types": "./dist/screens/*.d.ts"
|
|
31
|
-
},
|
|
32
|
-
"./assets/*": {
|
|
33
|
-
"import": "./dist/assets/*.js",
|
|
34
|
-
"types": "./dist/assets/*.d.ts"
|
|
35
|
-
},
|
|
36
|
-
"./constants/*": {
|
|
37
|
-
"import": "./dist/constants/*.js",
|
|
38
|
-
"types": "./dist/constants/*.d.ts"
|
|
39
|
-
},
|
|
40
|
-
"./layout/*": {
|
|
41
|
-
"import": "./dist/layout/*.js",
|
|
42
|
-
"types": "./dist/layout/*.d.ts"
|
|
43
|
-
},
|
|
44
|
-
"./utils/*": {
|
|
45
|
-
"import": "./dist/utils/*.js",
|
|
46
|
-
"types": "./dist/utils/*.d.ts"
|
|
47
|
-
},
|
|
48
|
-
"./services/*": {
|
|
49
|
-
"import": "./dist/services/*.js",
|
|
50
|
-
"types": "./dist/services/*.d.ts"
|
|
51
|
-
},
|
|
52
|
-
"./locales/*": "./dist/locales/*",
|
|
53
|
-
"./styles/global.css": "./dist/styles/global.css"
|
|
54
|
-
},
|
|
55
|
-
"files": [
|
|
56
|
-
"dist"
|
|
57
|
-
],
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
"
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
"
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
"
|
|
100
|
-
"
|
|
101
|
-
"
|
|
102
|
-
"
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
"
|
|
106
|
-
"
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
"
|
|
110
|
-
"
|
|
111
|
-
"
|
|
112
|
-
"
|
|
113
|
-
"
|
|
114
|
-
"
|
|
115
|
-
"
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
"
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
"
|
|
123
|
-
"
|
|
124
|
-
"
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
"concurrently": "^9.1.0",
|
|
128
|
-
"shx": "^0.4.0",
|
|
129
|
-
"tsc-alias": "^1.8.17",
|
|
130
|
-
"typescript": "^5.2.2"
|
|
131
|
-
}
|
|
132
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@droppii-org/chat-sdk",
|
|
3
|
+
"version": "0.1.71",
|
|
4
|
+
"description": "Droppii React Chat SDK",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"import": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts"
|
|
11
|
+
},
|
|
12
|
+
"./components/*": {
|
|
13
|
+
"import": "./dist/components/*.js",
|
|
14
|
+
"types": "./dist/components/*.d.ts"
|
|
15
|
+
},
|
|
16
|
+
"./hooks/*": {
|
|
17
|
+
"import": "./dist/hooks/*.js",
|
|
18
|
+
"types": "./dist/hooks/*.d.ts"
|
|
19
|
+
},
|
|
20
|
+
"./context/*": {
|
|
21
|
+
"import": "./dist/context/*.js",
|
|
22
|
+
"types": "./dist/context/*.d.ts"
|
|
23
|
+
},
|
|
24
|
+
"./types/*": {
|
|
25
|
+
"import": "./dist/types/*.js",
|
|
26
|
+
"types": "./dist/types/*.d.ts"
|
|
27
|
+
},
|
|
28
|
+
"./screens/*": {
|
|
29
|
+
"import": "./dist/screens/*.js",
|
|
30
|
+
"types": "./dist/screens/*.d.ts"
|
|
31
|
+
},
|
|
32
|
+
"./assets/*": {
|
|
33
|
+
"import": "./dist/assets/*.js",
|
|
34
|
+
"types": "./dist/assets/*.d.ts"
|
|
35
|
+
},
|
|
36
|
+
"./constants/*": {
|
|
37
|
+
"import": "./dist/constants/*.js",
|
|
38
|
+
"types": "./dist/constants/*.d.ts"
|
|
39
|
+
},
|
|
40
|
+
"./layout/*": {
|
|
41
|
+
"import": "./dist/layout/*.js",
|
|
42
|
+
"types": "./dist/layout/*.d.ts"
|
|
43
|
+
},
|
|
44
|
+
"./utils/*": {
|
|
45
|
+
"import": "./dist/utils/*.js",
|
|
46
|
+
"types": "./dist/utils/*.d.ts"
|
|
47
|
+
},
|
|
48
|
+
"./services/*": {
|
|
49
|
+
"import": "./dist/services/*.js",
|
|
50
|
+
"types": "./dist/services/*.d.ts"
|
|
51
|
+
},
|
|
52
|
+
"./locales/*": "./dist/locales/*",
|
|
53
|
+
"./styles/global.css": "./dist/styles/global.css"
|
|
54
|
+
},
|
|
55
|
+
"files": [
|
|
56
|
+
"dist"
|
|
57
|
+
],
|
|
58
|
+
"keywords": [
|
|
59
|
+
"chat",
|
|
60
|
+
"sdk",
|
|
61
|
+
"react",
|
|
62
|
+
"messenger-style"
|
|
63
|
+
],
|
|
64
|
+
"author": "Garru",
|
|
65
|
+
"license": "MIT",
|
|
66
|
+
"publishConfig": {
|
|
67
|
+
"access": "public"
|
|
68
|
+
},
|
|
69
|
+
"dependencies": {
|
|
70
|
+
"@ant-design/icons": "^6.0.0",
|
|
71
|
+
"@lexical/code": "^0.34.0",
|
|
72
|
+
"@lexical/html": "^0.34.0",
|
|
73
|
+
"@lexical/link": "^0.34.0",
|
|
74
|
+
"@lexical/list": "^0.34.0",
|
|
75
|
+
"@lexical/react": "^0.34.0",
|
|
76
|
+
"@lexical/rich-text": "^0.34.0",
|
|
77
|
+
"@openim/wasm-client-sdk": "3.8.3-patch.10",
|
|
78
|
+
"@tailwindcss/postcss": "^4.1.12",
|
|
79
|
+
"@tanstack/react-query": "^5.85.5",
|
|
80
|
+
"ahooks": "^3.9.4",
|
|
81
|
+
"antd": "^5.27.0",
|
|
82
|
+
"axios": "^1.11.0",
|
|
83
|
+
"clsx": "^2.0.0",
|
|
84
|
+
"dayjs": "^1.11.13",
|
|
85
|
+
"dompurify": "^3.3.1",
|
|
86
|
+
"i18next": "^25.5.2",
|
|
87
|
+
"jwt-decode": "^4.0.0",
|
|
88
|
+
"lexical": "^0.34.0",
|
|
89
|
+
"lodash": "^4.17.21",
|
|
90
|
+
"lucide-react": "^0.263.1",
|
|
91
|
+
"mitt": "^3.0.1",
|
|
92
|
+
"postcss": "^8.5.6",
|
|
93
|
+
"query-string": "^9.3.1",
|
|
94
|
+
"react-i18next": "^15.7.3",
|
|
95
|
+
"react-icomoon": "^2.6.1",
|
|
96
|
+
"react-infinite-scroll-component": "^6.1.0",
|
|
97
|
+
"react-sticky-box": "^2.0.5",
|
|
98
|
+
"react-virtuoso": "^4.14.0",
|
|
99
|
+
"tailwind-merge": "^2.0.0",
|
|
100
|
+
"tailwindcss": "^3.3.0",
|
|
101
|
+
"uuid": "^11.1.0",
|
|
102
|
+
"zustand": "^5.0.7"
|
|
103
|
+
},
|
|
104
|
+
"peerDependencies": {
|
|
105
|
+
"react": "^18.0.0",
|
|
106
|
+
"react-dom": "^18.0.0"
|
|
107
|
+
},
|
|
108
|
+
"devDependencies": {
|
|
109
|
+
"@types/dompurify": "^3.2.0",
|
|
110
|
+
"@types/lodash": "^4.17.20",
|
|
111
|
+
"@types/node": "^20.0.0",
|
|
112
|
+
"@types/react": "^18.2.37",
|
|
113
|
+
"@types/react-dom": "^18.2.15",
|
|
114
|
+
"shx": "^0.4.0",
|
|
115
|
+
"tsc-alias": "^1.8.17",
|
|
116
|
+
"typescript": "^5.2.2"
|
|
117
|
+
},
|
|
118
|
+
"scripts": {
|
|
119
|
+
"build": "pnpm build:css && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json && pnpm copy-assets",
|
|
120
|
+
"build:css": "tailwindcss -i ./src/styles/global.css -o ./dist/styles/global.css --minify",
|
|
121
|
+
"dev": "tsc --noEmit --watch",
|
|
122
|
+
"lint": "eslint src/",
|
|
123
|
+
"type-check": "tsc --noEmit",
|
|
124
|
+
"copy-assets": "shx cp -r src/assets dist && shx cp -r src/locales dist"
|
|
125
|
+
}
|
|
126
|
+
}
|