@sendbird/uikit-utils 2.0.3 → 2.2.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/lib/commonjs/hooks/index.js +14 -1
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/index.js +39 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/sendbird/channel.js +18 -6
- package/lib/commonjs/sendbird/channel.js.map +1 -1
- package/lib/commonjs/sendbird/message.js +12 -2
- package/lib/commonjs/sendbird/message.js.map +1 -1
- package/lib/commonjs/sendbird/user.js +23 -0
- package/lib/commonjs/sendbird/user.js.map +1 -0
- package/lib/commonjs/shared/bufferedRequest.js +38 -12
- package/lib/commonjs/shared/bufferedRequest.js.map +1 -1
- package/lib/commonjs/shared/regex.js +52 -6
- package/lib/commonjs/shared/regex.js.map +1 -1
- package/lib/commonjs/shared/replace.js +14 -0
- package/lib/commonjs/shared/replace.js.map +1 -0
- package/lib/commonjs/types.js +3 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/ui-format/common.js +17 -14
- package/lib/commonjs/ui-format/common.js.map +1 -1
- package/lib/commonjs/ui-format/groupChannel.js +7 -10
- package/lib/commonjs/ui-format/groupChannel.js.map +1 -1
- package/lib/module/hooks/index.js +10 -0
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/index.js +4 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/sendbird/channel.js +14 -4
- package/lib/module/sendbird/channel.js.map +1 -1
- package/lib/module/sendbird/message.js +9 -3
- package/lib/module/sendbird/message.js.map +1 -1
- package/lib/module/sendbird/user.js +12 -0
- package/lib/module/sendbird/user.js.map +1 -0
- package/lib/module/shared/bufferedRequest.js +39 -12
- package/lib/module/shared/bufferedRequest.js.map +1 -1
- package/lib/module/shared/regex.js +43 -3
- package/lib/module/shared/regex.js.map +1 -1
- package/lib/module/shared/replace.js +6 -0
- package/lib/module/shared/replace.js.map +1 -0
- package/lib/module/types.js +1 -4
- package/lib/module/types.js.map +1 -1
- package/lib/module/ui-format/common.js +12 -7
- package/lib/module/ui-format/common.js.map +1 -1
- package/lib/module/ui-format/groupChannel.js +5 -4
- package/lib/module/ui-format/groupChannel.js.map +1 -1
- package/lib/typescript/src/hooks/index.d.ts +3 -2
- package/lib/typescript/src/index.d.ts +4 -2
- package/lib/typescript/src/sendbird/channel.d.ts +6 -1
- package/lib/typescript/src/sendbird/message.d.ts +4 -2
- package/lib/typescript/src/sendbird/user.d.ts +7 -0
- package/lib/typescript/src/shared/bufferedRequest.d.ts +6 -4
- package/lib/typescript/src/shared/logger.d.ts +1 -1
- package/lib/typescript/src/shared/pubsub.d.ts +2 -2
- package/lib/typescript/src/shared/regex.d.ts +8 -0
- package/lib/typescript/src/shared/replace.d.ts +2 -0
- package/lib/typescript/src/types.d.ts +42 -35
- package/lib/typescript/src/ui-format/common.d.ts +7 -6
- package/package.json +3 -3
- package/src/hooks/index.ts +11 -0
- package/src/index.ts +14 -2
- package/src/sendbird/channel.ts +11 -4
- package/src/sendbird/message.ts +13 -3
- package/src/sendbird/user.ts +21 -0
- package/src/shared/bufferedRequest.ts +37 -12
- package/src/shared/regex.ts +35 -0
- package/src/shared/replace.ts +5 -0
- package/src/types.ts +21 -3
- package/src/ui-format/common.ts +9 -7
- package/src/ui-format/groupChannel.ts +5 -4
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
const replace = (original, start, end, str) => {
|
|
9
|
+
return original.slice(0, start) + str + original.slice(end);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
var _default = replace;
|
|
13
|
+
exports.default = _default;
|
|
14
|
+
//# sourceMappingURL=replace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["replace","original","start","end","str","slice"],"sources":["replace.ts"],"sourcesContent":["const replace = (original: string, start: number, end: number, str: string) => {\n return original.slice(0, start) + str + original.slice(end);\n};\n\nexport default replace;\n"],"mappings":";;;;;;;AAAA,MAAMA,OAAO,GAAG,CAACC,QAAD,EAAmBC,KAAnB,EAAkCC,GAAlC,EAA+CC,GAA/C,KAA+D;EAC7E,OAAOH,QAAQ,CAACI,KAAT,CAAe,CAAf,EAAkBH,KAAlB,IAA2BE,GAA3B,GAAiCH,QAAQ,CAACI,KAAT,CAAeF,GAAf,CAAxC;AACD,CAFD;;eAIeH,O"}
|
package/lib/commonjs/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/* eslint-disable @typescript-eslint/no-empty-interface */\nimport type React from 'react';\n\nimport type SendbirdChat from '@sendbird/chat';\nimport type {
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/* eslint-disable @typescript-eslint/no-empty-interface */\nimport type React from 'react';\n\nimport type SendbirdChat from '@sendbird/chat';\nimport type {\n BaseChannel,\n Emoji,\n EmojiCategory,\n EmojiContainer,\n RestrictedUser,\n SendbirdError as SBError,\n User,\n UserUpdateParams,\n} from '@sendbird/chat';\nimport type {\n GroupChannel,\n GroupChannelCollection,\n GroupChannelCreateParams,\n GroupChannelListQuery,\n GroupChannelModule,\n GroupChannelUpdateParams,\n Member,\n MessageCollection,\n} from '@sendbird/chat/groupChannel';\nimport type { ModuleNamespaces, SendableMessage } from '@sendbird/chat/lib/__definition';\nimport type {\n AdminMessage,\n BaseMessage,\n FileMessage,\n FileMessageCreateParams,\n FileMessageUpdateParams,\n PreviousMessageListQuery,\n Reaction,\n UserMessage,\n UserMessageCreateParams,\n UserMessageUpdateParams,\n} from '@sendbird/chat/message';\nimport type { OpenChannel, OpenChannelModule } from '@sendbird/chat/openChannel';\n\nexport type FilterByValueType<T extends object, Type> = {\n [K in keyof T as T[K] extends Type ? K : never]: T[K];\n};\n\nexport type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void\n ? I\n : never;\n\nexport type OmittedValues<T, K extends keyof T> = Omit<T, K>[keyof Omit<T, K>];\n\nexport type PartialDeep<T> = T extends object\n ? T extends Function\n ? T\n : {\n [P in keyof T]?: PartialDeep<T[P]>;\n }\n : T;\n\nexport type PartialNullable<T> = {\n [P in keyof T]?: T[P] | null;\n};\n\nexport type Optional<T> = T | undefined;\n\nexport type ContextValue<T extends React.Context<any>> = T extends React.Context<infer V> ? V : never;\n\nexport interface UserStruct {\n userId: string;\n}\n\nexport type SendbirdChatSDK = SendbirdChat & ModuleNamespaces<[GroupChannelModule, OpenChannelModule]>;\nexport type SendbirdMessage = BaseMessage | FileMessage | UserMessage | AdminMessage | SendableMessage;\nexport type SendbirdChannel = BaseChannel | GroupChannel | OpenChannel;\nexport type SendbirdUserMessage = UserMessage;\nexport type SendbirdFileMessage = FileMessage;\nexport type SendbirdAdminMessage = AdminMessage;\nexport type SendbirdBaseMessage = BaseMessage;\nexport type SendbirdSendableMessage = SendableMessage;\nexport type SendbirdFileMessageCreateParams = FileMessageCreateParams;\nexport type SendbirdFileMessageUpdateParams = FileMessageUpdateParams;\nexport type SendbirdUserMessageCreateParams = UserMessageCreateParams;\nexport type SendbirdUserMessageUpdateParams = UserMessageUpdateParams;\nexport type SendbirdGroupChannelCreateParams = GroupChannelCreateParams;\nexport type SendbirdGroupChannelUpdateParams = GroupChannelUpdateParams;\nexport type SendbirdUserUpdateParams = UserUpdateParams;\nexport type SendbirdUser = User;\nexport type SendbirdRestrictedUser = RestrictedUser;\nexport type SendbirdMember = Member;\nexport type SendbirdGroupChannel = GroupChannel;\nexport type SendbirdBaseChannel = BaseChannel;\nexport type SendbirdOpenChannel = OpenChannel;\n\nexport type SendbirdReaction = Reaction;\nexport type SendbirdEmoji = Emoji;\nexport type SendbirdEmojiCategory = EmojiCategory;\nexport type SendbirdEmojiContainer = EmojiContainer;\n\nexport type SendbirdGroupChannelCollection = GroupChannelCollection;\nexport type SendbirdGroupChannelListQuery = GroupChannelListQuery;\nexport type SendbirdMessageCollection = MessageCollection;\nexport type SendbirdPreviousMessageListQuery = PreviousMessageListQuery;\n\nexport type SendbirdError = SBError;\n\nexport interface SendbirdDataPayload {\n app_id: string;\n audience_type: string;\n category: string;\n channel: {\n channel_unread_message_count: number;\n channel_url: string;\n custom_type: string;\n name: string;\n };\n channel_type: string;\n created_at: number;\n custom_type: string;\n files: NotificationFiles[];\n mentioned_users: NotificationMentionedUsers[];\n message: string;\n message_id: number;\n push_sound: string;\n push_title: null;\n recipient: {\n id: string;\n name: string;\n push_template: string;\n };\n sender?: {\n id: string;\n name: string;\n profile_url: string;\n require_auth_for_profile_image: boolean;\n };\n sqs_ts: number;\n translations: NotificationTranslations;\n type: 'ADMM' | 'MESG' | 'FILE' | string;\n unread_message_count: number;\n}\nexport interface NotificationFiles {\n type: string;\n url: string;\n name: string;\n size: number;\n require_auth: boolean;\n}\n\nexport interface NotificationTranslations {}\nexport interface NotificationMentionedUsers {}\n"],"mappings":""}
|
|
@@ -3,11 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.truncatedCount = exports.truncate = exports.getMessageTimeFormat = exports.getDateSeparatorFormat = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
+
var _dateFns = require("date-fns");
|
|
11
9
|
|
|
12
10
|
const defaultOpts = {
|
|
13
11
|
mode: 'mid',
|
|
@@ -53,20 +51,22 @@ const truncate = function (str) {
|
|
|
53
51
|
throw new Error('Invalid truncate mode: ' + mode);
|
|
54
52
|
};
|
|
55
53
|
/**
|
|
56
|
-
*
|
|
54
|
+
* Count truncate util
|
|
57
55
|
* If count exceed the limit, it comes in the form of "MAX+"
|
|
58
56
|
*
|
|
59
57
|
* @param {number} count
|
|
60
58
|
* @param {number} MAX default 99
|
|
59
|
+
* @param {string} MAX_SUFFIX default +
|
|
61
60
|
* @returns {string}
|
|
62
61
|
* */
|
|
63
62
|
|
|
64
63
|
|
|
65
64
|
exports.truncate = truncate;
|
|
66
65
|
|
|
67
|
-
const
|
|
66
|
+
const truncatedCount = function (count) {
|
|
68
67
|
let MAX = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 99;
|
|
69
|
-
|
|
68
|
+
let MAX_SUFFIX = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '+';
|
|
69
|
+
if (count >= MAX) return `${MAX}${MAX_SUFFIX}`;
|
|
70
70
|
return `${count}`;
|
|
71
71
|
};
|
|
72
72
|
/**
|
|
@@ -78,10 +78,13 @@ const truncatedBadgeCount = function (count) {
|
|
|
78
78
|
* */
|
|
79
79
|
|
|
80
80
|
|
|
81
|
-
exports.
|
|
81
|
+
exports.truncatedCount = truncatedCount;
|
|
82
82
|
|
|
83
|
-
const
|
|
84
|
-
return (0,
|
|
83
|
+
const getDateSeparatorFormat = (date, locale) => {
|
|
84
|
+
if ((0, _dateFns.isThisYear)(date)) return (0, _dateFns.format)(date, 'MMM dd, yyyy', {
|
|
85
|
+
locale
|
|
86
|
+
});
|
|
87
|
+
return (0, _dateFns.format)(date, 'E, MMM dd', {
|
|
85
88
|
locale
|
|
86
89
|
});
|
|
87
90
|
};
|
|
@@ -94,13 +97,13 @@ const dateSeparator = (date, locale) => {
|
|
|
94
97
|
* */
|
|
95
98
|
|
|
96
99
|
|
|
97
|
-
exports.
|
|
100
|
+
exports.getDateSeparatorFormat = getDateSeparatorFormat;
|
|
98
101
|
|
|
99
|
-
const
|
|
100
|
-
return (0,
|
|
102
|
+
const getMessageTimeFormat = (date, locale) => {
|
|
103
|
+
return (0, _dateFns.format)(date, 'p', {
|
|
101
104
|
locale
|
|
102
105
|
});
|
|
103
106
|
};
|
|
104
107
|
|
|
105
|
-
exports.
|
|
108
|
+
exports.getMessageTimeFormat = getMessageTimeFormat;
|
|
106
109
|
//# sourceMappingURL=common.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["defaultOpts","mode","maxLen","separator","truncate","str","opts","options","length","slice","lead","Math","ceil","trail","floor","Error","
|
|
1
|
+
{"version":3,"names":["defaultOpts","mode","maxLen","separator","truncate","str","opts","options","length","slice","lead","Math","ceil","trail","floor","Error","truncatedCount","count","MAX","MAX_SUFFIX","getDateSeparatorFormat","date","locale","isThisYear","format","getMessageTimeFormat"],"sources":["common.ts"],"sourcesContent":["import type { Locale } from 'date-fns';\nimport { format, isThisYear } from 'date-fns';\n\ntype TruncateMode = 'head' | 'mid' | 'tail';\ntype TruncateOption = { mode: TruncateMode; maxLen: number; separator: string };\nconst defaultOpts: TruncateOption = { mode: 'mid', maxLen: 40, separator: '...' };\n\n/**\n * String truncate util\n * @param {string} str\n * @param {Object} opts Options for truncate\n * @param {'head' | 'mid' | 'tail'} opts.mode default \"mid\"\n * @param {number} opts.maxLen default 40\n * @param {string} opts.separator default \"...\"\n * @returns {string}\n * */\nexport const truncate = (str: string, opts: Partial<TruncateOption> = defaultOpts): string => {\n const options = { ...defaultOpts, ...opts };\n const { maxLen, mode, separator } = options;\n\n if (str.length <= maxLen) return str;\n\n if (mode === 'head') {\n return separator + str.slice(-maxLen);\n }\n\n if (mode === 'mid') {\n const lead = Math.ceil(maxLen / 2);\n const trail = Math.floor(maxLen / 2);\n return str.slice(0, lead) + separator + str.slice(-trail);\n }\n\n if (mode === 'tail') {\n return str.slice(0, maxLen) + separator;\n }\n\n throw new Error('Invalid truncate mode: ' + mode);\n};\n\n/**\n * Count truncate util\n * If count exceed the limit, it comes in the form of \"MAX+\"\n *\n * @param {number} count\n * @param {number} MAX default 99\n * @param {string} MAX_SUFFIX default +\n * @returns {string}\n * */\nexport const truncatedCount = (count: number, MAX = 99, MAX_SUFFIX = '+') => {\n if (count >= MAX) return `${MAX}${MAX_SUFFIX}`;\n return `${count}`;\n};\n\n/**\n * Messages date separator format\n *\n * @param {Date} date\n * @param {Locale} [locale]\n * @returns {string}\n * */\nexport const getDateSeparatorFormat = (date: Date, locale?: Locale): string => {\n if (isThisYear(date)) return format(date, 'MMM dd, yyyy', { locale });\n return format(date, 'E, MMM dd', { locale });\n};\n\n/**\n * Message time format\n *\n * @param {Date} date\n * @param {Locale} [locale]\n * @returns {string}\n * */\nexport const getMessageTimeFormat = (date: Date, locale?: Locale): string => {\n return format(date, 'p', { locale });\n};\n"],"mappings":";;;;;;;AACA;;AAIA,MAAMA,WAA2B,GAAG;EAAEC,IAAI,EAAE,KAAR;EAAeC,MAAM,EAAE,EAAvB;EAA2BC,SAAS,EAAE;AAAtC,CAApC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,MAAMC,QAAQ,GAAG,UAACC,GAAD,EAAsE;EAAA,IAAxDC,IAAwD,uEAAxBN,WAAwB;EAC5F,MAAMO,OAAO,GAAG,EAAE,GAAGP,WAAL;IAAkB,GAAGM;EAArB,CAAhB;EACA,MAAM;IAAEJ,MAAF;IAAUD,IAAV;IAAgBE;EAAhB,IAA8BI,OAApC;EAEA,IAAIF,GAAG,CAACG,MAAJ,IAAcN,MAAlB,EAA0B,OAAOG,GAAP;;EAE1B,IAAIJ,IAAI,KAAK,MAAb,EAAqB;IACnB,OAAOE,SAAS,GAAGE,GAAG,CAACI,KAAJ,CAAU,CAACP,MAAX,CAAnB;EACD;;EAED,IAAID,IAAI,KAAK,KAAb,EAAoB;IAClB,MAAMS,IAAI,GAAGC,IAAI,CAACC,IAAL,CAAUV,MAAM,GAAG,CAAnB,CAAb;IACA,MAAMW,KAAK,GAAGF,IAAI,CAACG,KAAL,CAAWZ,MAAM,GAAG,CAApB,CAAd;IACA,OAAOG,GAAG,CAACI,KAAJ,CAAU,CAAV,EAAaC,IAAb,IAAqBP,SAArB,GAAiCE,GAAG,CAACI,KAAJ,CAAU,CAACI,KAAX,CAAxC;EACD;;EAED,IAAIZ,IAAI,KAAK,MAAb,EAAqB;IACnB,OAAOI,GAAG,CAACI,KAAJ,CAAU,CAAV,EAAaP,MAAb,IAAuBC,SAA9B;EACD;;EAED,MAAM,IAAIY,KAAJ,CAAU,4BAA4Bd,IAAtC,CAAN;AACD,CArBM;AAuBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMe,cAAc,GAAG,UAACC,KAAD,EAA+C;EAAA,IAA/BC,GAA+B,uEAAzB,EAAyB;EAAA,IAArBC,UAAqB,uEAAR,GAAQ;EAC3E,IAAIF,KAAK,IAAIC,GAAb,EAAkB,OAAQ,GAAEA,GAAI,GAAEC,UAAW,EAA3B;EAClB,OAAQ,GAAEF,KAAM,EAAhB;AACD,CAHM;AAKP;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMG,sBAAsB,GAAG,CAACC,IAAD,EAAaC,MAAb,KAAyC;EAC7E,IAAI,IAAAC,mBAAA,EAAWF,IAAX,CAAJ,EAAsB,OAAO,IAAAG,eAAA,EAAOH,IAAP,EAAa,cAAb,EAA6B;IAAEC;EAAF,CAA7B,CAAP;EACtB,OAAO,IAAAE,eAAA,EAAOH,IAAP,EAAa,WAAb,EAA0B;IAAEC;EAAF,CAA1B,CAAP;AACD,CAHM;AAKP;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMG,oBAAoB,GAAG,CAACJ,IAAD,EAAaC,MAAb,KAAyC;EAC3E,OAAO,IAAAE,eAAA,EAAOH,IAAP,EAAa,GAAb,EAAkB;IAAEC;EAAF,CAAlB,CAAP;AACD,CAFM"}
|
|
@@ -5,16 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getGroupChannelTitle = exports.getGroupChannelPreviewTime = exports.getGroupChannelLastMessage = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
var _isToday = _interopRequireDefault(require("date-fns/isToday"));
|
|
11
|
-
|
|
12
|
-
var _isYesterday = _interopRequireDefault(require("date-fns/isYesterday"));
|
|
8
|
+
var _dateFns = require("date-fns");
|
|
13
9
|
|
|
14
10
|
var _common = require("./common");
|
|
15
11
|
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
12
|
const getGroupChannelTitle = function (currentUserId, channel) {
|
|
19
13
|
let EMPTY_USERNAME = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '(No name)';
|
|
20
14
|
let NO_MEMBERS = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '(No members)';
|
|
@@ -40,11 +34,14 @@ const getGroupChannelPreviewTime = (channel, locale) => {
|
|
|
40
34
|
var _channel$lastMessage;
|
|
41
35
|
|
|
42
36
|
const timestamp = ((_channel$lastMessage = channel.lastMessage) === null || _channel$lastMessage === void 0 ? void 0 : _channel$lastMessage.createdAt) || channel.joinedAt * 1000 || channel.createdAt;
|
|
43
|
-
if ((0,
|
|
37
|
+
if ((0, _dateFns.isToday)(timestamp)) return (0, _dateFns.format)(timestamp, 'p', {
|
|
38
|
+
locale
|
|
39
|
+
});
|
|
40
|
+
if ((0, _dateFns.isYesterday)(timestamp)) return 'Yesterday';
|
|
41
|
+
if ((0, _dateFns.isThisYear)(timestamp)) return (0, _dateFns.format)(timestamp, 'MMM dd', {
|
|
44
42
|
locale
|
|
45
43
|
});
|
|
46
|
-
|
|
47
|
-
return (0, _format.default)(timestamp, 'MMM dd', {
|
|
44
|
+
return (0, _dateFns.format)(timestamp, 'yyyy/MM/dd', {
|
|
48
45
|
locale
|
|
49
46
|
});
|
|
50
47
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getGroupChannelTitle","currentUserId","channel","EMPTY_USERNAME","NO_MEMBERS","DEFAULT_CHANNEL_NAME","name","memberCount","members","filter","userId","map","nickname","join","getGroupChannelPreviewTime","locale","timestamp","lastMessage","createdAt","joinedAt","isToday","format","isYesterday","getGroupChannelLastMessage","EMPTY_MESSAGE","MAX_LEN","message","isFileMessage","extIdx","lastIndexOf","file","slice","ext","truncate","maxLen","isUserMessage","isAdminMessage"],"sources":["groupChannel.ts"],"sourcesContent":["import type { Locale } from 'date-fns';\nimport
|
|
1
|
+
{"version":3,"names":["getGroupChannelTitle","currentUserId","channel","EMPTY_USERNAME","NO_MEMBERS","DEFAULT_CHANNEL_NAME","name","memberCount","members","filter","userId","map","nickname","join","getGroupChannelPreviewTime","locale","timestamp","lastMessage","createdAt","joinedAt","isToday","format","isYesterday","isThisYear","getGroupChannelLastMessage","EMPTY_MESSAGE","MAX_LEN","message","isFileMessage","extIdx","lastIndexOf","file","slice","ext","truncate","maxLen","isUserMessage","isAdminMessage"],"sources":["groupChannel.ts"],"sourcesContent":["import type { Locale } from 'date-fns';\nimport { format, isThisYear, isToday, isYesterday } from 'date-fns';\n\nimport type { SendbirdGroupChannel } from '../types';\nimport { truncate } from './common';\n\nexport const getGroupChannelTitle = (\n currentUserId: string,\n channel: SendbirdGroupChannel,\n EMPTY_USERNAME = '(No name)',\n NO_MEMBERS = '(No members)',\n DEFAULT_CHANNEL_NAME = 'Group Channel',\n) => {\n if (channel.name !== DEFAULT_CHANNEL_NAME && channel.name !== '') return channel.name;\n if (channel.memberCount === 1) return NO_MEMBERS;\n return channel.members\n .filter(({ userId }) => userId !== currentUserId)\n .map(({ nickname }) => nickname || EMPTY_USERNAME)\n .join(', ');\n};\n\nexport const getGroupChannelPreviewTime = (channel: SendbirdGroupChannel, locale?: Locale) => {\n const timestamp = channel.lastMessage?.createdAt || channel.joinedAt * 1000 || channel.createdAt;\n\n if (isToday(timestamp)) return format(timestamp, 'p', { locale });\n if (isYesterday(timestamp)) return 'Yesterday';\n if (isThisYear(timestamp)) return format(timestamp, 'MMM dd', { locale });\n\n return format(timestamp, 'yyyy/MM/dd', { locale });\n};\n\nexport const getGroupChannelLastMessage = (channel: SendbirdGroupChannel, EMPTY_MESSAGE = '', MAX_LEN = 15) => {\n const message = channel.lastMessage;\n if (!message) return EMPTY_MESSAGE;\n\n if (message.isFileMessage()) {\n const extIdx = message.name.lastIndexOf('.');\n if (extIdx > -1) {\n const file = message.name.slice(0, extIdx);\n const ext = message.name.slice(extIdx);\n return truncate(file, { maxLen: MAX_LEN }) + ext;\n }\n\n return truncate(message.name, { maxLen: MAX_LEN });\n }\n\n if (message.isUserMessage()) {\n return message.message ?? EMPTY_MESSAGE;\n }\n\n if (message.isAdminMessage()) {\n return message.message ?? EMPTY_MESSAGE;\n }\n\n return EMPTY_MESSAGE;\n};\n"],"mappings":";;;;;;;AACA;;AAGA;;AAEO,MAAMA,oBAAoB,GAAG,UAClCC,aADkC,EAElCC,OAFkC,EAM/B;EAAA,IAHHC,cAGG,uEAHc,WAGd;EAAA,IAFHC,UAEG,uEAFU,cAEV;EAAA,IADHC,oBACG,uEADoB,eACpB;EACH,IAAIH,OAAO,CAACI,IAAR,KAAiBD,oBAAjB,IAAyCH,OAAO,CAACI,IAAR,KAAiB,EAA9D,EAAkE,OAAOJ,OAAO,CAACI,IAAf;EAClE,IAAIJ,OAAO,CAACK,WAAR,KAAwB,CAA5B,EAA+B,OAAOH,UAAP;EAC/B,OAAOF,OAAO,CAACM,OAAR,CACJC,MADI,CACG;IAAA,IAAC;MAAEC;IAAF,CAAD;IAAA,OAAgBA,MAAM,KAAKT,aAA3B;EAAA,CADH,EAEJU,GAFI,CAEA;IAAA,IAAC;MAAEC;IAAF,CAAD;IAAA,OAAkBA,QAAQ,IAAIT,cAA9B;EAAA,CAFA,EAGJU,IAHI,CAGC,IAHD,CAAP;AAID,CAbM;;;;AAeA,MAAMC,0BAA0B,GAAG,CAACZ,OAAD,EAAgCa,MAAhC,KAAoD;EAAA;;EAC5F,MAAMC,SAAS,GAAG,yBAAAd,OAAO,CAACe,WAAR,8EAAqBC,SAArB,KAA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AAET;IAAV,CAAvB,CAAP;EACD;;EAED,IAAIC,OAAO,CAACS,aAAR,EAAJ,EAA6B;IAC3B,OAAOT,OAAO,CAACA,OAAR,IAAmBF,aAA1B;EACD;;EAED,IAAIE,OAAO,CAACU,cAAR,EAAJ,EAA8B;IAC5B,OAAOV,OAAO,CAACA,OAAR,IAAmBF,aAA1B;EACD;;EAED,OAAOA,aAAP;AACD,CAxBM"}
|
|
@@ -48,6 +48,16 @@ export const useIsMountedRef = () => {
|
|
|
48
48
|
}, []);
|
|
49
49
|
return isMounted;
|
|
50
50
|
};
|
|
51
|
+
export const useIsFirstMount = () => {
|
|
52
|
+
const isFirstMount = useRef(true);
|
|
53
|
+
|
|
54
|
+
if (isFirstMount.current) {
|
|
55
|
+
isFirstMount.current = false;
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return isFirstMount.current;
|
|
60
|
+
};
|
|
51
61
|
export const useFreshCallback = callback => {
|
|
52
62
|
const ref = useRef(callback);
|
|
53
63
|
ref.current = callback;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useCallback","useEffect","useLayoutEffect","useRef","useState","idPool","useUniqId","key","useForceUpdate","updater","prev","useAsyncEffect","asyncEffect","deps","createAsyncEffectCallback","useAsyncLayoutEffect","useIIFE","callback","iife","destructor","Promise","awaitedDestructor","useIsMountedRef","isMounted","current","useFreshCallback","ref"],"sources":["index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { DependencyList } from 'react';\nimport { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';\n\ntype Destructor = () => void;\ntype AsyncEffectCallback = () => void | Destructor | Promise<void> | Promise<Destructor>;\n\nconst idPool: { [key: string]: number } = {};\nexport const useUniqId = (key: string) => {\n return useState(() => {\n if (!idPool[key]) idPool[key] = 1;\n return idPool[key]++;\n })[0];\n};\n\nexport const useForceUpdate = () => {\n const [, updater] = useState(0);\n return useCallback(() => updater((prev) => prev + 1), []);\n};\n\nexport const useAsyncEffect = (asyncEffect: AsyncEffectCallback, deps?: DependencyList) => {\n useEffect(createAsyncEffectCallback(asyncEffect), deps);\n};\nexport const useAsyncLayoutEffect = (asyncEffect: AsyncEffectCallback, deps?: DependencyList) => {\n useLayoutEffect(createAsyncEffectCallback(asyncEffect), deps);\n};\nexport const useIIFE = <T>(callback: () => T) => {\n return iife(callback);\n};\nconst iife = <T extends (...args: any[]) => any>(callback: T): ReturnType<T> => callback();\nconst createAsyncEffectCallback = (asyncEffect: AsyncEffectCallback) => () => {\n const destructor = iife(asyncEffect);\n return () => {\n if (!destructor) return;\n\n if (destructor instanceof Promise) {\n iife(async () => {\n const awaitedDestructor = await destructor;\n if (awaitedDestructor) awaitedDestructor();\n });\n } else {\n iife(destructor);\n }\n };\n};\n\nexport const useIsMountedRef = () => {\n const isMounted = useRef(true);\n\n useEffect(() => {\n return () => {\n isMounted.current = false;\n };\n }, []);\n\n return isMounted;\n};\n\nexport const useFreshCallback = <T extends (...args: any[]) => any>(callback: T): T => {\n const ref = useRef<T>(callback);\n ref.current = callback;\n return useCallback(((...args) => ref.current(...args)) as T, []);\n};\n"],"mappings":"AAAA;AAEA,SAASA,WAAT,EAAsBC,SAAtB,EAAiCC,eAAjC,EAAkDC,MAAlD,EAA0DC,QAA1D,QAA0E,OAA1E;AAKA,MAAMC,MAAiC,GAAG,EAA1C;AACA,OAAO,MAAMC,SAAS,GAAIC,GAAD,IAAiB;EACxC,OAAOH,QAAQ,CAAC,MAAM;IACpB,IAAI,CAACC,MAAM,CAACE,GAAD,CAAX,EAAkBF,MAAM,CAACE,GAAD,CAAN,GAAc,CAAd;IAClB,OAAOF,MAAM,CAACE,GAAD,CAAN,EAAP;EACD,CAHc,CAAR,CAGJ,CAHI,CAAP;AAID,CALM;AAOP,OAAO,MAAMC,cAAc,GAAG,MAAM;EAClC,MAAM,GAAGC,OAAH,IAAcL,QAAQ,CAAC,CAAD,CAA5B;EACA,OAAOJ,WAAW,CAA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","useEffect","useLayoutEffect","useRef","useState","idPool","useUniqId","key","useForceUpdate","updater","prev","useAsyncEffect","asyncEffect","deps","createAsyncEffectCallback","useAsyncLayoutEffect","useIIFE","callback","iife","destructor","Promise","awaitedDestructor","useIsMountedRef","isMounted","current","useIsFirstMount","isFirstMount","useFreshCallback","ref"],"sources":["index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { DependencyList } from 'react';\nimport { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';\n\ntype Destructor = () => void;\ntype AsyncEffectCallback = () => void | Destructor | Promise<void> | Promise<Destructor>;\n\nconst idPool: { [key: string]: number } = {};\nexport const useUniqId = (key: string) => {\n return useState(() => {\n if (!idPool[key]) idPool[key] = 1;\n return idPool[key]++;\n })[0];\n};\n\nexport const useForceUpdate = () => {\n const [, updater] = useState(0);\n return useCallback(() => updater((prev) => prev + 1), []);\n};\n\nexport const useAsyncEffect = (asyncEffect: AsyncEffectCallback, deps?: DependencyList) => {\n useEffect(createAsyncEffectCallback(asyncEffect), deps);\n};\nexport const useAsyncLayoutEffect = (asyncEffect: AsyncEffectCallback, deps?: DependencyList) => {\n useLayoutEffect(createAsyncEffectCallback(asyncEffect), deps);\n};\nexport const useIIFE = <T>(callback: () => T) => {\n return iife(callback);\n};\nconst iife = <T extends (...args: any[]) => any>(callback: T): ReturnType<T> => callback();\nconst createAsyncEffectCallback = (asyncEffect: AsyncEffectCallback) => () => {\n const destructor = iife(asyncEffect);\n return () => {\n if (!destructor) return;\n\n if (destructor instanceof Promise) {\n iife(async () => {\n const awaitedDestructor = await destructor;\n if (awaitedDestructor) awaitedDestructor();\n });\n } else {\n iife(destructor);\n }\n };\n};\n\nexport const useIsMountedRef = () => {\n const isMounted = useRef(true);\n\n useEffect(() => {\n return () => {\n isMounted.current = false;\n };\n }, []);\n\n return isMounted;\n};\n\nexport const useIsFirstMount = () => {\n const isFirstMount = useRef(true);\n\n if (isFirstMount.current) {\n isFirstMount.current = false;\n return true;\n }\n\n return isFirstMount.current;\n};\n\nexport const useFreshCallback = <T extends (...args: any[]) => any>(callback: T): T => {\n const ref = useRef<T>(callback);\n ref.current = callback;\n return useCallback(((...args) => ref.current(...args)) as T, []);\n};\n"],"mappings":"AAAA;AAEA,SAASA,WAAT,EAAsBC,SAAtB,EAAiCC,eAAjC,EAAkDC,MAAlD,EAA0DC,QAA1D,QAA0E,OAA1E;AAKA,MAAMC,MAAiC,GAAG,EAA1C;AACA,OAAO,MAAMC,SAAS,GAAIC,GAAD,IAAiB;EACxC,OAAOH,QAAQ,CAAC,MAAM;IACpB,IAAI,CAACC,MAAM,CAACE,GAAD,CAAX,EAAkBF,MAAM,CAACE,GAAD,CAAN,GAAc,CAAd;IAClB,OAAOF,MAAM,CAACE,GAAD,CAAN,EAAP;EACD,CAHc,CAAR,CAGJ,CAHI,CAAP;AAID,CALM;AAOP,OAAO,MAAMC,cAAc,GAAG,MAAM;EAClC,MAAM,GAAGC,OAAH,IAAcL,QAAQ,CAAC,CAAD,CAA5B;EACA,OAAOJ,WAAW,CAAC,MAAMS,OAAO,CAAEC,IAAD,IAAUA,IAAI,GAAG,CAAlB,CAAd,EAAoC,EAApC,CAAlB;AACD,CAHM;AAKP,OAAO,MAAMC,cAAc,GAAG,CAACC,WAAD,EAAmCC,IAAnC,KAA6D;EACzFZ,SAAS,CAACa,yBAAyB,CAACF,WAAD,CAA1B,EAAyCC,IAAzC,CAAT;AACD,CAFM;AAGP,OAAO,MAAME,oBAAoB,GAAG,CAACH,WAAD,EAAmCC,IAAnC,KAA6D;EAC/FX,eAAe,CAACY,yBAAyB,CAACF,WAAD,CAA1B,EAAyCC,IAAzC,CAAf;AACD,CAFM;AAGP,OAAO,MAAMG,OAAO,GAAOC,QAAJ,IAA0B;EAC/C,OAAOC,IAAI,CAACD,QAAD,CAAX;AACD,CAFM;;AAGP,MAAMC,IAAI,GAAuCD,QAApC,IAAmEA,QAAQ,EAAxF;;AACA,MAAMH,yBAAyB,GAAIF,WAAD,IAAsC,MAAM;EAC5E,MAAMO,UAAU,GAAGD,IAAI,CAACN,WAAD,CAAvB;EACA,OAAO,MAAM;IACX,IAAI,CAACO,UAAL,EAAiB;;IAEjB,IAAIA,UAAU,YAAYC,OAA1B,EAAmC;MACjCF,IAAI,CAAC,YAAY;QACf,MAAMG,iBAAiB,GAAG,MAAMF,UAAhC;QACA,IAAIE,iBAAJ,EAAuBA,iBAAiB;MACzC,CAHG,CAAJ;IAID,CALD,MAKO;MACLH,IAAI,CAACC,UAAD,CAAJ;IACD;EACF,CAXD;AAYD,CAdD;;AAgBA,OAAO,MAAMG,eAAe,GAAG,MAAM;EACnC,MAAMC,SAAS,GAAGpB,MAAM,CAAC,IAAD,CAAxB;EAEAF,SAAS,CAAC,MAAM;IACd,OAAO,MAAM;MACXsB,SAAS,CAACC,OAAV,GAAoB,KAApB;IACD,CAFD;EAGD,CAJQ,EAIN,EAJM,CAAT;EAMA,OAAOD,SAAP;AACD,CAVM;AAYP,OAAO,MAAME,eAAe,GAAG,MAAM;EACnC,MAAMC,YAAY,GAAGvB,MAAM,CAAC,IAAD,CAA3B;;EAEA,IAAIuB,YAAY,CAACF,OAAjB,EAA0B;IACxBE,YAAY,CAACF,OAAb,GAAuB,KAAvB;IACA,OAAO,IAAP;EACD;;EAED,OAAOE,YAAY,CAACF,OAApB;AACD,CATM;AAWP,OAAO,MAAMG,gBAAgB,GAAuCV,QAApC,IAAuD;EACrF,MAAMW,GAAG,GAAGzB,MAAM,CAAIc,QAAJ,CAAlB;EACAW,GAAG,CAACJ,OAAJ,GAAcP,QAAd;EACA,OAAOjB,WAAW,CAAE;IAAA,OAAa4B,GAAG,CAACJ,OAAJ,CAAY,YAAZ,CAAb;EAAA,CAAF,EAA2C,EAA3C,CAAlB;AACD,CAJM"}
|
package/lib/module/index.js
CHANGED
|
@@ -2,14 +2,16 @@ export { Logger } from './shared/logger';
|
|
|
2
2
|
export { default as arrayToMap, arrayToMapWithGetter } from './shared/arrayToMap';
|
|
3
3
|
export { createPubSub } from './shared/pubsub';
|
|
4
4
|
export { default as conditionChaining } from './shared/conditionChaining';
|
|
5
|
-
export { urlRegexStrict, urlRegexRough, newLineRegex, audioExtRegex, videoExtRegex, imageExtRegex, getFileType, getFileExtension, replaceUrlAsComponents, normalizeFileName, emailRegex, phoneRegex } from './shared/regex';
|
|
5
|
+
export { urlRegexStrict, urlRegexRough, newLineRegex, audioExtRegex, videoExtRegex, imageExtRegex, getFileType, getFileExtension, replaceUrlAsComponents, normalizeFileName, emailRegex, phoneRegex, replaceWithRegex, createMentionTemplateRegex } from './shared/regex';
|
|
6
6
|
export { BufferedRequest } from './shared/bufferedRequest';
|
|
7
|
+
export { default as replace } from './shared/replace';
|
|
7
8
|
export * from './hooks';
|
|
8
9
|
export * from './ui-format/groupChannel';
|
|
9
10
|
export * from './ui-format/common';
|
|
10
11
|
export * from './sendbird/channel';
|
|
11
12
|
export * from './sendbird/message';
|
|
12
13
|
export * from './sendbird/attrs';
|
|
14
|
+
export * from './sendbird/user';
|
|
13
15
|
export const NOOP = () => void 0;
|
|
14
16
|
export const ASYNC_NOOP = async () => void 0;
|
|
15
17
|
export const PASS = val => val;
|
|
@@ -19,6 +21,6 @@ export const SBErrorCode = {
|
|
|
19
21
|
NON_AUTHORIZED: 400108
|
|
20
22
|
};
|
|
21
23
|
export const SBErrorMessage = {
|
|
22
|
-
ACL:
|
|
24
|
+
ACL: 'Sendbird provides various access control options when using the Chat SDK.\n' + 'By default, the Allow retrieving user list attribute is turned on to facilitate creating sample apps.\n' + 'However, this may grant access to unwanted data or operations, leading to potential security concerns.\n' + 'To manage your access control settings, you can turn on or off each setting on Sendbird Dashboard.'
|
|
23
25
|
};
|
|
24
26
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Logger","default","arrayToMap","arrayToMapWithGetter","createPubSub","conditionChaining","urlRegexStrict","urlRegexRough","newLineRegex","audioExtRegex","videoExtRegex","imageExtRegex","getFileType","getFileExtension","replaceUrlAsComponents","normalizeFileName","emailRegex","phoneRegex","BufferedRequest","NOOP","ASYNC_NOOP","PASS","val","toMegabyte","byte","isFunction","param","SBErrorCode","NON_AUTHORIZED","SBErrorMessage","ACL"],"sources":["index.ts"],"sourcesContent":["export { Logger } from './shared/logger';\nexport { default as arrayToMap, arrayToMapWithGetter } from './shared/arrayToMap';\nexport { createPubSub } from './shared/pubsub';\nexport { default as conditionChaining } from './shared/conditionChaining';\nexport {\n urlRegexStrict,\n urlRegexRough,\n newLineRegex,\n audioExtRegex,\n videoExtRegex,\n imageExtRegex,\n getFileType,\n getFileExtension,\n replaceUrlAsComponents,\n normalizeFileName,\n emailRegex,\n phoneRegex,\n} from './shared/regex';\nexport { BufferedRequest } from './shared/bufferedRequest';\n\nexport * from './hooks';\nexport * from './ui-format/groupChannel';\nexport * from './ui-format/common';\nexport * from './sendbird/channel';\nexport * from './sendbird/message';\nexport * from './sendbird/attrs';\n\nexport const NOOP: () => void = () => void 0;\nexport const ASYNC_NOOP = async () => void 0;\nexport const PASS = <T>(val: T) => val;\nexport const toMegabyte = (byte: number) => byte / 1024 / 1024;\nexport const isFunction = <T>(param?: T): param is NonNullable<T> => typeof param === 'function';\nexport const SBErrorCode = {\n NON_AUTHORIZED: 400108,\n};\nexport const SBErrorMessage = {\n ACL:\n
|
|
1
|
+
{"version":3,"names":["Logger","default","arrayToMap","arrayToMapWithGetter","createPubSub","conditionChaining","urlRegexStrict","urlRegexRough","newLineRegex","audioExtRegex","videoExtRegex","imageExtRegex","getFileType","getFileExtension","replaceUrlAsComponents","normalizeFileName","emailRegex","phoneRegex","replaceWithRegex","createMentionTemplateRegex","BufferedRequest","replace","NOOP","ASYNC_NOOP","PASS","val","toMegabyte","byte","isFunction","param","SBErrorCode","NON_AUTHORIZED","SBErrorMessage","ACL"],"sources":["index.ts"],"sourcesContent":["export { Logger } from './shared/logger';\nexport { default as arrayToMap, arrayToMapWithGetter } from './shared/arrayToMap';\nexport { createPubSub } from './shared/pubsub';\nexport { default as conditionChaining } from './shared/conditionChaining';\nexport {\n urlRegexStrict,\n urlRegexRough,\n newLineRegex,\n audioExtRegex,\n videoExtRegex,\n imageExtRegex,\n getFileType,\n getFileExtension,\n replaceUrlAsComponents,\n normalizeFileName,\n emailRegex,\n phoneRegex,\n replaceWithRegex,\n createMentionTemplateRegex,\n} from './shared/regex';\nexport { BufferedRequest } from './shared/bufferedRequest';\nexport { default as replace } from './shared/replace';\n\nexport * from './hooks';\nexport * from './ui-format/groupChannel';\nexport * from './ui-format/common';\nexport * from './sendbird/channel';\nexport * from './sendbird/message';\nexport * from './sendbird/attrs';\nexport * from './sendbird/user';\n\nexport const NOOP: () => void = () => void 0;\nexport const ASYNC_NOOP = async () => void 0;\nexport const PASS = <T>(val: T) => val;\nexport const toMegabyte = (byte: number) => byte / 1024 / 1024;\nexport const isFunction = <T>(param?: T): param is NonNullable<T> => typeof param === 'function';\nexport const SBErrorCode = {\n NON_AUTHORIZED: 400108,\n};\nexport const SBErrorMessage = {\n ACL:\n 'Sendbird provides various access control options when using the Chat SDK.\\n' +\n 'By default, the Allow retrieving user list attribute is turned on to facilitate creating sample apps.\\n' +\n 'However, this may grant access to unwanted data or operations, leading to potential security concerns.\\n' +\n 'To manage your access control settings, you can turn on or off each setting on Sendbird Dashboard.',\n};\n\nexport type {\n UserStruct,\n FilterByValueType,\n UnionToIntersection,\n OmittedValues,\n PartialDeep,\n Optional,\n ContextValue,\n SendbirdMessage,\n SendbirdChatSDK,\n SendbirdChannel,\n SendbirdBaseChannel,\n SendbirdGroupChannel,\n SendbirdOpenChannel,\n SendbirdUser,\n SendbirdMember,\n SendbirdBaseMessage,\n SendbirdUserMessage,\n SendbirdFileMessage,\n SendbirdAdminMessage,\n SendbirdGroupChannelCreateParams,\n SendbirdFileMessageCreateParams,\n SendbirdUserMessageCreateParams,\n SendbirdError,\n SendbirdMessageCollection,\n SendbirdGroupChannelCollection,\n NotificationFiles,\n NotificationMentionedUsers,\n NotificationTranslations,\n PartialNullable,\n SendbirdDataPayload,\n SendbirdPreviousMessageListQuery,\n SendbirdSendableMessage,\n SendbirdGroupChannelListQuery,\n SendbirdGroupChannelUpdateParams,\n SendbirdUserMessageUpdateParams,\n SendbirdFileMessageUpdateParams,\n SendbirdUserUpdateParams,\n SendbirdRestrictedUser,\n SendbirdReaction,\n SendbirdEmojiContainer,\n SendbirdEmoji,\n SendbirdEmojiCategory,\n} from './types';\n"],"mappings":"AAAA,SAASA,MAAT,QAAuB,iBAAvB;AACA,SAASC,OAAO,IAAIC,UAApB,EAAgCC,oBAAhC,QAA4D,qBAA5D;AACA,SAASC,YAAT,QAA6B,iBAA7B;AACA,SAASH,OAAO,IAAII,iBAApB,QAA6C,4BAA7C;AACA,SACEC,cADF,EAEEC,aAFF,EAGEC,YAHF,EAIEC,aAJF,EAKEC,aALF,EAMEC,aANF,EAOEC,WAPF,EAQEC,gBARF,EASEC,sBATF,EAUEC,iBAVF,EAWEC,UAXF,EAYEC,UAZF,EAaEC,gBAbF,EAcEC,0BAdF,QAeO,gBAfP;AAgBA,SAASC,eAAT,QAAgC,0BAAhC;AACA,SAASnB,OAAO,IAAIoB,OAApB,QAAmC,kBAAnC;AAEA,cAAc,SAAd;AACA,cAAc,0BAAd;AACA,cAAc,oBAAd;AACA,cAAc,oBAAd;AACA,cAAc,oBAAd;AACA,cAAc,kBAAd;AACA,cAAc,iBAAd;AAEA,OAAO,MAAMC,IAAgB,GAAG,MAAM,KAAK,CAApC;AACP,OAAO,MAAMC,UAAU,GAAG,YAAY,KAAK,CAApC;AACP,OAAO,MAAMC,IAAI,GAAOC,GAAJ,IAAeA,GAA5B;AACP,OAAO,MAAMC,UAAU,GAAIC,IAAD,IAAkBA,IAAI,GAAG,IAAP,GAAc,IAAnD;AACP,OAAO,MAAMC,UAAU,GAAOC,KAAJ,IAA2C,OAAOA,KAAP,KAAiB,UAA/E;AACP,OAAO,MAAMC,WAAW,GAAG;EACzBC,cAAc,EAAE;AADS,CAApB;AAGP,OAAO,MAAMC,cAAc,GAAG;EAC5BC,GAAG,EACD,gFACA,yGADA,GAEA,0GAFA,GAGA;AAL0B,CAAvB"}
|
|
@@ -10,14 +10,21 @@ export function isDifferentChannel(a, b) {
|
|
|
10
10
|
if (!a || !b) return true;
|
|
11
11
|
return a.url !== b.url;
|
|
12
12
|
}
|
|
13
|
-
export const
|
|
14
|
-
|
|
13
|
+
export const getGroupChannelChatAvailableState = channel => {
|
|
14
|
+
const frozen = channel.isFrozen && channel.myRole !== 'operator';
|
|
15
|
+
const muted = channel.myMutedState === 'muted';
|
|
16
|
+
const disabled = frozen || muted;
|
|
17
|
+
return {
|
|
18
|
+
disabled,
|
|
19
|
+
frozen,
|
|
20
|
+
muted
|
|
21
|
+
};
|
|
15
22
|
};
|
|
16
23
|
export const confirmAndMarkAsRead = async channels => {
|
|
17
|
-
channels.filter(it => it.isGroupChannel() && it.unreadMessageCount > 0).forEach(it => BufferedRequest.markAsRead.push(() => it.markAsRead()));
|
|
24
|
+
channels.filter(it => it.isGroupChannel() && it.unreadMessageCount > 0).forEach(it => BufferedRequest.markAsRead.push(() => it.markAsRead(), it.url));
|
|
18
25
|
};
|
|
19
26
|
export const confirmAndMarkAsDelivered = async channels => {
|
|
20
|
-
channels.filter(it => it.isGroupChannel() && it.unreadMessageCount > 0).forEach(it => BufferedRequest.markAsDelivered.push(() => it.markAsDelivered()));
|
|
27
|
+
channels.filter(it => it.isGroupChannel() && it.unreadMessageCount > 0).forEach(it => BufferedRequest.markAsDelivered.push(() => it.markAsDelivered(), it.url));
|
|
21
28
|
};
|
|
22
29
|
export function isDefaultCoverImage(coverUrl) {
|
|
23
30
|
return coverUrl === '' || coverUrl.startsWith('https://static.sendbird.com/sample/cover');
|
|
@@ -31,4 +38,7 @@ export function getGroupChannels(channels) {
|
|
|
31
38
|
export function getOpenChannels(channels) {
|
|
32
39
|
return channels.filter(c => c.isOpenChannel());
|
|
33
40
|
}
|
|
41
|
+
export function getChannelUniqId(channel) {
|
|
42
|
+
return channel.url;
|
|
43
|
+
}
|
|
34
44
|
//# sourceMappingURL=channel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BufferedRequest","isDifferentChannel","a","b","url","
|
|
1
|
+
{"version":3,"names":["BufferedRequest","isDifferentChannel","a","b","url","getGroupChannelChatAvailableState","channel","frozen","isFrozen","myRole","muted","myMutedState","disabled","confirmAndMarkAsRead","channels","filter","it","isGroupChannel","unreadMessageCount","forEach","markAsRead","push","confirmAndMarkAsDelivered","markAsDelivered","isDefaultCoverImage","coverUrl","startsWith","getMembersExcludeMe","currentUserId","members","m","userId","getGroupChannels","c","getOpenChannels","isOpenChannel","getChannelUniqId"],"sources":["channel.ts"],"sourcesContent":["import { BufferedRequest } from '../shared/bufferedRequest';\nimport type { SendbirdBaseChannel, SendbirdChannel, SendbirdGroupChannel, SendbirdOpenChannel } from '../types';\n\n/**\n * Diff utils for channel\n * @param {SendbirdBaseChannel} [a]\n * @param {SendbirdBaseChannel} [b]\n * @returns {boolean}\n * */\nexport function isDifferentChannel<T extends SendbirdBaseChannel>(a?: T, b?: T): boolean {\n if (!a || !b) return true;\n return a.url !== b.url;\n}\n\nexport const getGroupChannelChatAvailableState = (channel: SendbirdGroupChannel) => {\n const frozen = channel.isFrozen && channel.myRole !== 'operator';\n const muted = channel.myMutedState === 'muted';\n const disabled = frozen || muted;\n return { disabled, frozen, muted };\n};\n\nexport const confirmAndMarkAsRead = async (channels: SendbirdBaseChannel[]) => {\n channels\n .filter((it): it is SendbirdGroupChannel => it.isGroupChannel() && it.unreadMessageCount > 0)\n .forEach((it) => BufferedRequest.markAsRead.push(() => it.markAsRead(), it.url));\n};\n\nexport const confirmAndMarkAsDelivered = async (channels: SendbirdBaseChannel[]) => {\n channels\n .filter((it): it is SendbirdGroupChannel => it.isGroupChannel() && it.unreadMessageCount > 0)\n .forEach((it) => BufferedRequest.markAsDelivered.push(() => it.markAsDelivered(), it.url));\n};\n\nexport function isDefaultCoverImage(coverUrl: string) {\n return coverUrl === '' || coverUrl.startsWith('https://static.sendbird.com/sample/cover');\n}\n\nexport function getMembersExcludeMe(channel: SendbirdGroupChannel, currentUserId?: string) {\n return channel.members.filter((m) => m.userId !== currentUserId);\n}\n\nexport function getGroupChannels(channels: SendbirdChannel[]): SendbirdGroupChannel[] {\n return channels.filter((c): c is SendbirdGroupChannel => c.isGroupChannel());\n}\n\nexport function getOpenChannels(channels: SendbirdChannel[]): SendbirdOpenChannel[] {\n return channels.filter((c): c is SendbirdOpenChannel => c.isOpenChannel());\n}\n\nexport function getChannelUniqId(channel: SendbirdChannel) {\n return channel.url;\n}\n"],"mappings":"AAAA,SAASA,eAAT,QAAgC,2BAAhC;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAT,CAA2DC,CAA3D,EAAkEC,CAAlE,EAAkF;EACvF,IAAI,CAACD,CAAD,IAAM,CAACC,CAAX,EAAc,OAAO,IAAP;EACd,OAAOD,CAAC,CAACE,GAAF,KAAUD,CAAC,CAACC,GAAnB;AACD;AAED,OAAO,MAAMC,iCAAiC,GAAIC,OAAD,IAAmC;EAClF,MAAMC,MAAM,GAAGD,OAAO,CAACE,QAAR,IAAoBF,OAAO,CAACG,MAAR,KAAmB,UAAtD;EACA,MAAMC,KAAK,GAAGJ,OAAO,CAACK,YAAR,KAAyB,OAAvC;EACA,MAAMC,QAAQ,GAAGL,MAAM,IAAIG,KAA3B;EACA,OAAO;IAAEE,QAAF;IAAYL,MAAZ;IAAoBG;EAApB,CAAP;AACD,CALM;AAOP,OAAO,MAAMG,oBAAoB,GAAG,MAAOC,QAAP,IAA2C;EAC7EA,QAAQ,CACLC,MADH,CACWC,EAAD,IAAoCA,EAAE,CAACC,cAAH,MAAuBD,EAAE,CAACE,kBAAH,GAAwB,CAD7F,EAEGC,OAFH,CAEYH,EAAD,IAAQhB,eAAe,CAACoB,UAAhB,CAA2BC,IAA3B,CAAgC,MAAML,EAAE,CAACI,UAAH,EAAtC,EAAuDJ,EAAE,CAACZ,GAA1D,CAFnB;AAGD,CAJM;AAMP,OAAO,MAAMkB,yBAAyB,GAAG,MAAOR,QAAP,IAA2C;EAClFA,QAAQ,CACLC,MADH,CACWC,EAAD,IAAoCA,EAAE,CAACC,cAAH,MAAuBD,EAAE,CAACE,kBAAH,GAAwB,CAD7F,EAEGC,OAFH,CAEYH,EAAD,IAAQhB,eAAe,CAACuB,eAAhB,CAAgCF,IAAhC,CAAqC,MAAML,EAAE,CAACO,eAAH,EAA3C,EAAiEP,EAAE,CAACZ,GAApE,CAFnB;AAGD,CAJM;AAMP,OAAO,SAASoB,mBAAT,CAA6BC,QAA7B,EAA+C;EACpD,OAAOA,QAAQ,KAAK,EAAb,IAAmBA,QAAQ,CAACC,UAAT,CAAoB,0CAApB,CAA1B;AACD;AAED,OAAO,SAASC,mBAAT,CAA6BrB,OAA7B,EAA4DsB,aAA5D,EAAoF;EACzF,OAAOtB,OAAO,CAACuB,OAAR,CAAgBd,MAAhB,CAAwBe,CAAD,IAAOA,CAAC,CAACC,MAAF,KAAaH,aAA3C,CAAP;AACD;AAED,OAAO,SAASI,gBAAT,CAA0BlB,QAA1B,EAA+E;EACpF,OAAOA,QAAQ,CAACC,MAAT,CAAiBkB,CAAD,IAAkCA,CAAC,CAAChB,cAAF,EAAlD,CAAP;AACD;AAED,OAAO,SAASiB,eAAT,CAAyBpB,QAAzB,EAA6E;EAClF,OAAOA,QAAQ,CAACC,MAAT,CAAiBkB,CAAD,IAAiCA,CAAC,CAACE,aAAF,EAAjD,CAAP;AACD;AAED,OAAO,SAASC,gBAAT,CAA0B9B,OAA1B,EAAoD;EACzD,OAAOA,OAAO,CAACF,GAAf;AACD"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getMessageTimeFormat } from '../ui-format/common';
|
|
2
2
|
export function isNewMessage(msg, currentUserId) {
|
|
3
3
|
const myMessage = isMyMessage(msg, currentUserId);
|
|
4
4
|
if (myMessage) return false;
|
|
@@ -46,7 +46,7 @@ export function calcMessageGrouping(groupEnabled, curr, prev, next) {
|
|
|
46
46
|
if (!prev) return false;
|
|
47
47
|
if (curr.isAdminMessage()) return false;
|
|
48
48
|
if (!hasSameSender(curr, prev)) return false;
|
|
49
|
-
if (
|
|
49
|
+
if (getMessageTimeFormat(new Date(curr.createdAt)) !== getMessageTimeFormat(new Date(prev.createdAt))) return false;
|
|
50
50
|
return true;
|
|
51
51
|
};
|
|
52
52
|
|
|
@@ -55,7 +55,7 @@ export function calcMessageGrouping(groupEnabled, curr, prev, next) {
|
|
|
55
55
|
if (!next) return false;
|
|
56
56
|
if (curr.isAdminMessage()) return false;
|
|
57
57
|
if (!hasSameSender(curr, next)) return false;
|
|
58
|
-
if (
|
|
58
|
+
if (getMessageTimeFormat(new Date(curr.createdAt)) !== getMessageTimeFormat(new Date(next.createdAt))) return false;
|
|
59
59
|
return true;
|
|
60
60
|
};
|
|
61
61
|
|
|
@@ -86,4 +86,10 @@ export function isSendbirdNotification(dataPayload) {
|
|
|
86
86
|
export function parseSendbirdNotification(dataPayload) {
|
|
87
87
|
return typeof dataPayload.sendbird === 'string' ? JSON.parse(dataPayload.sendbird) : dataPayload.sendbird;
|
|
88
88
|
}
|
|
89
|
+
export function shouldRenderReaction(channel, reactionEnabled) {
|
|
90
|
+
return channel.isGroupChannel() && !channel.isBroadcast && !channel.isSuper && reactionEnabled;
|
|
91
|
+
}
|
|
92
|
+
export function getReactionCount(reaction) {
|
|
93
|
+
return reaction.userIds.length;
|
|
94
|
+
}
|
|
89
95
|
//# sourceMappingURL=message.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["getMessageTimeFormat","isNewMessage","msg","currentUserId","myMessage","isMyMessage","isAdminMessage","updatedAt","isSendableMessage","undefined","sender","userId","sendingStatus","messageKeyExtractor","message","getMessageUniqId","messageComparator","a","b","aStatusOffset","bStatusOffset","createdAt","hasSameSender","calcMessageGrouping","groupEnabled","curr","prev","next","getPrev","Date","getNext","groupWithPrev","groupWithNext","isUserMessage","isFileMessage","String","messageId","reqId","getAvailableUriFromFileMessage","url","messageParams","file","uri","isSendbirdNotification","dataPayload","Boolean","parseSendbirdNotification","sendbird","JSON","parse","shouldRenderReaction","channel","reactionEnabled","isGroupChannel","isBroadcast","isSuper","getReactionCount","reaction","userIds","length"],"sources":["message.ts"],"sourcesContent":["import type {\n SendbirdBaseChannel,\n SendbirdBaseMessage,\n SendbirdDataPayload,\n SendbirdFileMessage,\n SendbirdMessage,\n SendbirdReaction,\n SendbirdSendableMessage,\n} from '../types';\nimport { getMessageTimeFormat } from '../ui-format/common';\n\nexport function isNewMessage(msg: SendbirdMessage, currentUserId?: string) {\n const myMessage = isMyMessage(msg, currentUserId);\n if (myMessage) return false;\n if (msg.isAdminMessage()) return false;\n return msg.updatedAt === 0;\n}\n\nexport function isSendableMessage(msg?: SendbirdMessage | null): msg is SendbirdSendableMessage {\n return msg !== undefined && msg !== null && 'sendingStatus' in msg;\n}\n\nexport function isMyMessage(msg?: SendbirdMessage | null, currentUserId = '##__USER_ID_IS_NOT_PROVIDED__##') {\n if (!isSendableMessage(msg)) return false;\n return (\n ('sender' in msg && msg.sender?.userId === currentUserId) ||\n msg.sendingStatus === 'pending' ||\n msg.sendingStatus === 'failed' ||\n msg.sendingStatus === 'canceled'\n );\n}\n\nexport function messageKeyExtractor(message: SendbirdMessage): string {\n return getMessageUniqId(message);\n}\n\n// |-------------------|-------------------|-----------------|-------------------|\n// | sending status | reqId | messageId | createdAt |\n// |-------------------|-------------------|-----------------|-------------------|\n// | pending | timestamp(A) | 0 | timestamp(B) |\n// | canceled | timestamp(A) | 0 | ? |\n// | failed | timestamp(A) | 0 | ? |\n// | succeeded | timestamp(A) / '' | id from DB | timestamp(C) |\n// |-------------------|-------------------|-----------------|-------------------|\nexport function messageComparator(a: SendbirdMessage, b: SendbirdMessage) {\n let aStatusOffset = 0;\n let bStatusOffset = 0;\n\n if (isSendableMessage(a) && a.sendingStatus !== 'succeeded') aStatusOffset = 999999;\n if (isSendableMessage(b) && b.sendingStatus !== 'succeeded') bStatusOffset = 999999;\n\n return b.createdAt + bStatusOffset - (a.createdAt + aStatusOffset);\n}\n\nexport function hasSameSender(a?: SendbirdMessage, b?: SendbirdMessage) {\n if (!a || !b) return false;\n if ('sender' in a && 'sender' in b) return a.sender?.userId === b.sender?.userId;\n return false;\n}\n\nexport function calcMessageGrouping(\n groupEnabled: boolean,\n curr: SendbirdMessage,\n prev?: SendbirdMessage,\n next?: SendbirdMessage,\n) {\n const getPrev = () => {\n if (!groupEnabled) return false;\n if (!prev) return false;\n if (curr.isAdminMessage()) return false;\n if (!hasSameSender(curr, prev)) return false;\n if (getMessageTimeFormat(new Date(curr.createdAt)) !== getMessageTimeFormat(new Date(prev.createdAt))) return false;\n return true;\n };\n\n const getNext = () => {\n if (!groupEnabled) return false;\n if (!next) return false;\n if (curr.isAdminMessage()) return false;\n if (!hasSameSender(curr, next)) return false;\n if (getMessageTimeFormat(new Date(curr.createdAt)) !== getMessageTimeFormat(new Date(next.createdAt))) return false;\n return true;\n };\n\n return { groupWithPrev: getPrev(), groupWithNext: getNext() };\n}\n\nexport function getMessageUniqId(msg: SendbirdBaseMessage) {\n if (msg.isUserMessage() || msg.isFileMessage()) {\n if (msg.sendingStatus === 'succeeded') return String(msg.messageId);\n return msg.reqId;\n }\n\n return String(msg.messageId);\n}\n\nexport function getAvailableUriFromFileMessage(message: SendbirdFileMessage) {\n if (!message.url && message.messageParams.file && 'uri' in message.messageParams.file) {\n return message.messageParams.file.uri;\n }\n return message.url;\n}\n\ntype RawSendbirdDataPayload = { sendbird: string | object };\nexport function isSendbirdNotification(dataPayload?: {\n [key: string]: string | object;\n}): dataPayload is RawSendbirdDataPayload {\n if (!dataPayload) return false;\n return Boolean(dataPayload['sendbird']);\n}\n\nexport function parseSendbirdNotification(dataPayload: RawSendbirdDataPayload): SendbirdDataPayload {\n return typeof dataPayload.sendbird === 'string' ? JSON.parse(dataPayload.sendbird) : dataPayload.sendbird;\n}\n\nexport function shouldRenderReaction(channel: SendbirdBaseChannel, reactionEnabled: boolean) {\n return channel.isGroupChannel() && !channel.isBroadcast && !channel.isSuper && reactionEnabled;\n}\n\nexport function getReactionCount(reaction: SendbirdReaction) {\n return reaction.userIds.length;\n}\n"],"mappings":"AASA,SAASA,oBAAT,QAAqC,qBAArC;AAEA,OAAO,SAASC,YAAT,CAAsBC,GAAtB,EAA4CC,aAA5C,EAAoE;EACzE,MAAMC,SAAS,GAAGC,WAAW,CAACH,GAAD,EAAMC,aAAN,CAA7B;EACA,IAAIC,SAAJ,EAAe,OAAO,KAAP;EACf,IAAIF,GAAG,CAACI,cAAJ,EAAJ,EAA0B,OAAO,KAAP;EAC1B,OAAOJ,GAAG,CAACK,SAAJ,KAAkB,CAAzB;AACD;AAED,OAAO,SAASC,iBAAT,CAA2BN,GAA3B,EAAyF;EAC9F,OAAOA,GAAG,KAAKO,SAAR,IAAqBP,GAAG,KAAK,IAA7B,IAAqC,mBAAmBA,GAA/D;AACD;AAED,OAAO,SAASG,WAAT,CAAqBH,GAArB,EAAsG;EAAA;;EAAA,IAAnDC,aAAmD,uEAAnC,iCAAmC;EAC3G,IAAI,CAACK,iBAAiB,CAACN,GAAD,CAAtB,EAA6B,OAAO,KAAP;EAC7B,OACG,YAAYA,GAAZ,IAAmB,gBAAAA,GAAG,CAACQ,MAAJ,4DAAYC,MAAZ,MAAuBR,aAA3C,IACAD,GAAG,CAACU,aAAJ,KAAsB,SADtB,IAEAV,GAAG,CAACU,aAAJ,KAAsB,QAFtB,IAGAV,GAAG,CAACU,aAAJ,KAAsB,UAJxB;AAMD;AAED,OAAO,SAASC,mBAAT,CAA6BC,OAA7B,EAA+D;EACpE,OAAOC,gBAAgB,CAACD,OAAD,CAAvB;AACD,C,CAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,iBAAT,C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BAAT,CAAgCC,WAAhC,EAEmC;EACxC,IAAI,CAACA,WAAL,EAAkB,OAAO,KAAP;EAClB,OAAOC,OAAO,CAACD,WAAW,CAAC,UAAD,CAAZ,CAAd;AACD;AAED,OAAO,SAASE,yBAAT,CAAmCF,WAAnC,EAA6F;EAClG,OAAO,OAAOA,WAAW,CAACG,QAAnB,KAAgC,QAAhC,GAA2CC,IAAI,CAACC,KAAL,CAAWL,WAAW,CAACG,QAAvB,CAA3C,GAA8EH,WAAW,CAACG,QAAjG;AACD;AAED,OAAO,SAASG,oBAAT,CAA8BC,OAA9B,EAA4DC,eAA5D,EAAsF;EAC3F,OAAOD,OAAO,CAACE,cAAR,MAA4B,CAACF,OAAO,CAACG,WAArC,IAAoD,CAACH,OAAO,CAACI,OAA7D,IAAwEH,eAA/E;AACD;AAED,OAAO,SAASI,gBAAT,CAA0BC,QAA1B,EAAsD;EAC3D,OAAOA,QAAQ,CAACC,OAAT,CAAiBC,MAAxB;AACD"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function ifOperator(role, then, or) {
|
|
2
|
+
if (role === 'operator') return then;
|
|
3
|
+
return or;
|
|
4
|
+
}
|
|
5
|
+
export function ifMuted(muted, then, or) {
|
|
6
|
+
if (muted) return then;
|
|
7
|
+
return or;
|
|
8
|
+
}
|
|
9
|
+
export function getUserUniqId(user) {
|
|
10
|
+
return user.userId;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=user.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ifOperator","role","then","or","ifMuted","muted","getUserUniqId","user","userId"],"sources":["user.ts"],"sourcesContent":["import type { Role } from '@sendbird/chat';\n\nimport type { UserStruct } from '../types';\n\nexport function ifOperator<T>(role: Role, then: T): T | undefined;\nexport function ifOperator<T, V>(role: Role, then: T, or: V): T | V;\nexport function ifOperator(role: Role, then: unknown, or?: unknown) {\n if (role === 'operator') return then;\n return or;\n}\n\nexport function ifMuted<T>(muted: boolean, then: T): T | undefined;\nexport function ifMuted<T, V>(muted: boolean, then: T, or: V): T | V;\nexport function ifMuted(muted: boolean, then: unknown, or?: unknown) {\n if (muted) return then;\n return or;\n}\n\nexport function getUserUniqId<T extends UserStruct>(user: T) {\n return user.userId;\n}\n"],"mappings":"AAMA,OAAO,SAASA,UAAT,CAAoBC,IAApB,EAAgCC,IAAhC,EAA+CC,EAA/C,EAA6D;EAClE,IAAIF,IAAI,KAAK,UAAb,EAAyB,OAAOC,IAAP;EACzB,OAAOC,EAAP;AACD;AAID,OAAO,SAASC,OAAT,CAAiBC,KAAjB,EAAiCH,IAAjC,EAAgDC,EAAhD,EAA8D;EACnE,IAAIE,KAAJ,EAAW,OAAOH,IAAP;EACX,OAAOC,EAAP;AACD;AAED,OAAO,SAASG,aAAT,CAA6CC,IAA7C,EAAsD;EAC3D,OAAOA,IAAI,CAACC,MAAZ;AACD"}
|
|
@@ -3,7 +3,20 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
3
3
|
let REQ_PER_TIMEOUT = 5;
|
|
4
4
|
let TIMEOUT_MILLS = 1000;
|
|
5
5
|
const SAFE_TIMEOUT_BUFFER = 100;
|
|
6
|
+
|
|
7
|
+
function generateRandomId() {
|
|
8
|
+
return Math.random().toString(16).slice(2);
|
|
9
|
+
}
|
|
10
|
+
|
|
6
11
|
export class BufferedRequest {
|
|
12
|
+
static updateMarkAsReadOptions(reqPerTimeout, timeoutMills) {
|
|
13
|
+
BufferedRequest.markAsRead = BufferedRequest.create(reqPerTimeout, timeoutMills);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
static updateMarkAsDeliveredOptions(reqPerTimeout, timeoutMills) {
|
|
17
|
+
BufferedRequest.markAsDelivered = BufferedRequest.create(reqPerTimeout, timeoutMills);
|
|
18
|
+
}
|
|
19
|
+
|
|
7
20
|
static get reqPerTimeout() {
|
|
8
21
|
return REQ_PER_TIMEOUT;
|
|
9
22
|
}
|
|
@@ -27,29 +40,35 @@ export class BufferedRequest {
|
|
|
27
40
|
static create() {
|
|
28
41
|
let reqPerTimeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : REQ_PER_TIMEOUT;
|
|
29
42
|
let timeoutMills = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : TIMEOUT_MILLS;
|
|
30
|
-
const waitQueue =
|
|
31
|
-
const nextQueue =
|
|
43
|
+
const waitQueue = new Map();
|
|
44
|
+
const nextQueue = new Map();
|
|
32
45
|
let state = 'idle';
|
|
33
46
|
let timeout;
|
|
34
47
|
return {
|
|
35
|
-
push(func) {
|
|
36
|
-
waitQueue.
|
|
48
|
+
push(func, lane) {
|
|
49
|
+
waitQueue.set(lane ?? generateRandomId(), func);
|
|
37
50
|
this.invoke();
|
|
38
51
|
},
|
|
39
52
|
|
|
40
53
|
shift() {
|
|
41
|
-
if (nextQueue.
|
|
42
|
-
const nextRemains = Math.min(reqPerTimeout - nextQueue.
|
|
54
|
+
if (nextQueue.size < reqPerTimeout) {
|
|
55
|
+
const nextRemains = Math.min(reqPerTimeout - nextQueue.size, waitQueue.size);
|
|
56
|
+
const lanes = [...waitQueue.keys()];
|
|
43
57
|
|
|
44
58
|
for (let n = 0; n < nextRemains; n++) {
|
|
45
|
-
const
|
|
46
|
-
|
|
59
|
+
const lane = lanes[n];
|
|
60
|
+
const func = waitQueue.get(lane);
|
|
61
|
+
|
|
62
|
+
if (func) {
|
|
63
|
+
waitQueue.delete(lane);
|
|
64
|
+
nextQueue.set(lane, func);
|
|
65
|
+
}
|
|
47
66
|
}
|
|
48
67
|
}
|
|
49
68
|
},
|
|
50
69
|
|
|
51
70
|
handleIdle() {
|
|
52
|
-
if (0 < nextQueue.
|
|
71
|
+
if (0 < nextQueue.size) {
|
|
53
72
|
state = 'processing';
|
|
54
73
|
this.invoke();
|
|
55
74
|
}
|
|
@@ -60,14 +79,22 @@ export class BufferedRequest {
|
|
|
60
79
|
timeout = setTimeout(() => {
|
|
61
80
|
timeout = undefined;
|
|
62
81
|
|
|
63
|
-
if (0 < nextQueue.
|
|
82
|
+
if (0 < nextQueue.size || 0 < waitQueue.size) {
|
|
64
83
|
this.invoke();
|
|
65
84
|
} else {
|
|
66
85
|
state = 'idle';
|
|
67
86
|
}
|
|
68
87
|
}, timeoutMills + SAFE_TIMEOUT_BUFFER);
|
|
69
|
-
|
|
70
|
-
|
|
88
|
+
let index = 0;
|
|
89
|
+
const nextRequestBaseTimeout = timeoutMills / nextQueue.size;
|
|
90
|
+
nextQueue.forEach(func => {
|
|
91
|
+
setTimeout(() => {
|
|
92
|
+
func(); // TODO: Add retry
|
|
93
|
+
//.catch(() => waitQueue.set(lane, func));
|
|
94
|
+
}, nextRequestBaseTimeout * index);
|
|
95
|
+
index++;
|
|
96
|
+
});
|
|
97
|
+
nextQueue.clear();
|
|
71
98
|
},
|
|
72
99
|
|
|
73
100
|
async invoke() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["REQ_PER_TIMEOUT","TIMEOUT_MILLS","SAFE_TIMEOUT_BUFFER","BufferedRequest","reqPerTimeout","
|
|
1
|
+
{"version":3,"names":["REQ_PER_TIMEOUT","TIMEOUT_MILLS","SAFE_TIMEOUT_BUFFER","generateRandomId","Math","random","toString","slice","BufferedRequest","updateMarkAsReadOptions","reqPerTimeout","timeoutMills","markAsRead","create","updateMarkAsDeliveredOptions","markAsDelivered","value","waitQueue","Map","nextQueue","state","timeout","push","func","lane","set","invoke","shift","size","nextRemains","min","lanes","keys","n","get","delete","handleIdle","handleProcessing","setTimeout","undefined","index","nextRequestBaseTimeout","forEach","clear"],"sources":["bufferedRequest.ts"],"sourcesContent":["type Func = (...args: unknown[]) => Promise<unknown>;\ntype State = 'idle' | 'processing';\n\nlet REQ_PER_TIMEOUT = 5;\nlet TIMEOUT_MILLS = 1000;\nconst SAFE_TIMEOUT_BUFFER = 100;\n\nfunction generateRandomId() {\n return Math.random().toString(16).slice(2);\n}\n\nexport class BufferedRequest {\n public static markAsRead = BufferedRequest.create();\n public static markAsDelivered = BufferedRequest.create();\n\n public static updateMarkAsReadOptions(reqPerTimeout: number, timeoutMills: number) {\n BufferedRequest.markAsRead = BufferedRequest.create(reqPerTimeout, timeoutMills);\n }\n public static updateMarkAsDeliveredOptions(reqPerTimeout: number, timeoutMills: number) {\n BufferedRequest.markAsDelivered = BufferedRequest.create(reqPerTimeout, timeoutMills);\n }\n\n public static get reqPerTimeout() {\n return REQ_PER_TIMEOUT;\n }\n public static set reqPerTimeout(value: number) {\n REQ_PER_TIMEOUT = value;\n BufferedRequest.markAsRead = BufferedRequest.create();\n BufferedRequest.markAsDelivered = BufferedRequest.create();\n }\n\n public static get timeoutMills() {\n return TIMEOUT_MILLS;\n }\n public static set timeoutMills(value: number) {\n TIMEOUT_MILLS = value;\n BufferedRequest.markAsRead = BufferedRequest.create();\n BufferedRequest.markAsDelivered = BufferedRequest.create();\n }\n\n public static create(reqPerTimeout = REQ_PER_TIMEOUT, timeoutMills = TIMEOUT_MILLS) {\n const waitQueue = new Map<string, Func>();\n const nextQueue = new Map<string, Func>();\n\n let state: State = 'idle';\n let timeout: NodeJS.Timeout | undefined;\n\n return {\n push(func: Func, lane?: string) {\n waitQueue.set(lane ?? generateRandomId(), func);\n this.invoke();\n },\n shift() {\n if (nextQueue.size < reqPerTimeout) {\n const nextRemains = Math.min(reqPerTimeout - nextQueue.size, waitQueue.size);\n const lanes = [...waitQueue.keys()];\n for (let n = 0; n < nextRemains; n++) {\n const lane = lanes[n];\n const func = waitQueue.get(lane);\n if (func) {\n waitQueue.delete(lane);\n nextQueue.set(lane, func);\n }\n }\n }\n },\n handleIdle() {\n if (0 < nextQueue.size) {\n state = 'processing';\n this.invoke();\n }\n },\n handleProcessing() {\n if (timeout) return;\n\n timeout = setTimeout(() => {\n timeout = undefined;\n if (0 < nextQueue.size || 0 < waitQueue.size) {\n this.invoke();\n } else {\n state = 'idle';\n }\n }, timeoutMills + SAFE_TIMEOUT_BUFFER);\n\n let index = 0;\n const nextRequestBaseTimeout = timeoutMills / nextQueue.size;\n nextQueue.forEach((func) => {\n setTimeout(() => {\n func();\n // TODO: Add retry\n //.catch(() => waitQueue.set(lane, func));\n }, nextRequestBaseTimeout * index);\n index++;\n });\n nextQueue.clear();\n },\n async invoke() {\n this.shift();\n\n if (state === 'idle') {\n this.handleIdle();\n }\n\n if (state === 'processing') {\n this.handleProcessing();\n }\n },\n };\n }\n}\n"],"mappings":";;AAGA,IAAIA,eAAe,GAAG,CAAtB;AACA,IAAIC,aAAa,GAAG,IAApB;AACA,MAAMC,mBAAmB,GAAG,GAA5B;;AAEA,SAASC,gBAAT,GAA4B;EAC1B,OAAOC,IAAI,CAACC,MAAL,GAAcC,QAAd,CAAuB,EAAvB,EAA2BC,KAA3B,CAAiC,CAAjC,CAAP;AACD;;AAED,OAAO,MAAMC,eAAN,CAAsB;EAIU,OAAvBC,uBAAuB,CAACC,aAAD,EAAwBC,YAAxB,EAA8C;IACjFH,eAAe,CAACI,UAAhB,GAA6BJ,eAAe,CAACK,MAAhB,CAAuBH,aAAvB,EAAsCC,YAAtC,CAA7B;EACD;;EACyC,OAA5BG,4BAA4B,CAACJ,aAAD,EAAwBC,YAAxB,EAA8C;IACtFH,eAAe,CAACO,eAAhB,GAAkCP,eAAe,CAACK,MAAhB,CAAuBH,aAAvB,EAAsCC,YAAtC,CAAlC;EACD;;EAE8B,WAAbD,aAAa,GAAG;IAChC,OAAOV,eAAP;EACD;;EAC8B,WAAbU,aAAa,CAACM,KAAD,EAAgB;IAC7ChB,eAAe,GAAGgB,KAAlB;IACAR,eAAe,CAACI,UAAhB,GAA6BJ,eAAe,CAACK,MAAhB,EAA7B;IACAL,eAAe,CAACO,eAAhB,GAAkCP,eAAe,CAACK,MAAhB,EAAlC;EACD;;EAE6B,WAAZF,YAAY,GAAG;IAC/B,OAAOV,aAAP;EACD;;EAC6B,WAAZU,YAAY,CAACK,KAAD,EAAgB;IAC5Cf,aAAa,GAAGe,KAAhB;IACAR,eAAe,CAACI,UAAhB,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