@sendbird/uikit-utils 1.1.1 → 2.0.0-rc.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 +1 -3
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/index.js +22 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/sendbird/channel.js +19 -3
- package/lib/commonjs/sendbird/channel.js.map +1 -1
- package/lib/commonjs/sendbird/message.js +9 -4
- package/lib/commonjs/sendbird/message.js.map +1 -1
- package/lib/commonjs/shared/arrayToMap.js.map +1 -1
- package/lib/commonjs/shared/regex.js +15 -1
- package/lib/commonjs/shared/regex.js.map +1 -1
- package/lib/commonjs/types.js +1 -3
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/ui-format/groupChannel.js +9 -1
- package/lib/commonjs/ui-format/groupChannel.js.map +1 -1
- package/lib/module/hooks/index.js +1 -3
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/sendbird/channel.js +10 -1
- package/lib/module/sendbird/channel.js.map +1 -1
- package/lib/module/sendbird/message.js +7 -4
- package/lib/module/sendbird/message.js.map +1 -1
- package/lib/module/shared/arrayToMap.js.map +1 -1
- package/lib/module/shared/regex.js +11 -0
- package/lib/module/shared/regex.js.map +1 -1
- package/lib/module/types.js +4 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/ui-format/groupChannel.js +9 -1
- package/lib/module/ui-format/groupChannel.js.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/sendbird/channel.d.ts +5 -3
- package/lib/typescript/src/sendbird/message.d.ts +4 -3
- package/lib/typescript/src/shared/arrayToMap.d.ts +1 -1
- package/lib/typescript/src/shared/regex.d.ts +1 -0
- package/lib/typescript/src/types.d.ts +32 -19
- package/package.json +10 -5
- package/src/hooks/index.ts +1 -3
- package/src/index.ts +13 -3
- package/src/sendbird/channel.ts +19 -2
- package/src/sendbird/message.ts +17 -7
- package/src/shared/arrayToMap.ts +1 -4
- package/src/shared/regex.ts +11 -0
- package/src/types.ts +55 -24
- package/src/ui-format/groupChannel.ts +9 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["arrayToMap","arr","selector","fallbackSelector","combine","reduce","accum","curr","_key","arrayToMapWithGetter","getSelector"],"sources":["arrayToMap.ts"],"sourcesContent":["import type { FilterByValueType } from '../types';\n\nexport default function arrayToMap<T extends Record<K, unknown>, K extends keyof T = keyof T>(\n arr: T[],\n selector: keyof FilterByValueType<T, string | number>,\n): Record<string, T>;\n\nexport default function arrayToMap<T extends Record<K, unknown>, K extends keyof T = keyof T>(\n arr: T[],\n selector: string,\n fallbackSelector: K,\n): Record<string, T>;\n\nexport default function arrayToMap<T extends Record<K, unknown>, K extends keyof T = keyof T>(\n arr: T[],\n selector: string,\n selector2: string,\n combineKey: true,\n): Record<string, T>;\n\n/**\n * Convert Array of the object to Object\n * @param {object[]} arr\n * @param {keyof object} selector\n * @param {keyof object} [fallbackSelector]\n * @param {boolean} [combine]\n * @returns {Record<keyof object, object>}\n * @example\n * ```\n * const arr = [{name: 'john'}, {name: 'chris'}, {name: 'sravan'}, {name: 'hoon'}];\n * const obj = arrayToMap(arr, 'name');\n *\n * console.log(obj);\n * // {\n * // 'john': {name: 'john'},\n * // 'chris': {name: 'chris'},\n * // 'sravan': {name: 'sravan'},\n * // 'hoon': {name: 'hoon'}\n * // }\n * ```\n * */\nexport default function arrayToMap<T extends Record<K, unknown>, K extends keyof T = keyof T>(\n arr: T[],\n selector: K,\n fallbackSelector?: K,\n combine?: boolean,\n) {\n return arr.reduce((accum, curr) => {\n if (combine && fallbackSelector) {\n const _key = curr[selector] + (curr[fallbackSelector] as string);\n accum[_key] = curr;\n } else {\n const _key = (curr[selector] || curr[fallbackSelector as K]) as string;\n accum[_key] = curr;\n }\n\n return accum;\n }, {} as Record<string, T>);\n}\n\nexport function arrayToMapWithGetter<T
|
|
1
|
+
{"version":3,"names":["arrayToMap","arr","selector","fallbackSelector","combine","reduce","accum","curr","_key","arrayToMapWithGetter","getSelector"],"sources":["arrayToMap.ts"],"sourcesContent":["import type { FilterByValueType } from '../types';\n\nexport default function arrayToMap<T extends Record<K, unknown>, K extends keyof T = keyof T>(\n arr: T[],\n selector: keyof FilterByValueType<T, string | number>,\n): Record<string, T>;\n\nexport default function arrayToMap<T extends Record<K, unknown>, K extends keyof T = keyof T>(\n arr: T[],\n selector: string,\n fallbackSelector: K,\n): Record<string, T>;\n\nexport default function arrayToMap<T extends Record<K, unknown>, K extends keyof T = keyof T>(\n arr: T[],\n selector: string,\n selector2: string,\n combineKey: true,\n): Record<string, T>;\n\n/**\n * Convert Array of the object to Object\n * @param {object[]} arr\n * @param {keyof object} selector\n * @param {keyof object} [fallbackSelector]\n * @param {boolean} [combine]\n * @returns {Record<keyof object, object>}\n * @example\n * ```\n * const arr = [{name: 'john'}, {name: 'chris'}, {name: 'sravan'}, {name: 'hoon'}];\n * const obj = arrayToMap(arr, 'name');\n *\n * console.log(obj);\n * // {\n * // 'john': {name: 'john'},\n * // 'chris': {name: 'chris'},\n * // 'sravan': {name: 'sravan'},\n * // 'hoon': {name: 'hoon'}\n * // }\n * ```\n * */\nexport default function arrayToMap<T extends Record<K, unknown>, K extends keyof T = keyof T>(\n arr: T[],\n selector: K,\n fallbackSelector?: K,\n combine?: boolean,\n) {\n return arr.reduce((accum, curr) => {\n if (combine && fallbackSelector) {\n const _key = curr[selector] + (curr[fallbackSelector] as string);\n accum[_key] = curr;\n } else {\n const _key = (curr[selector] || curr[fallbackSelector as K]) as string;\n accum[_key] = curr;\n }\n\n return accum;\n }, {} as Record<string, T>);\n}\n\nexport function arrayToMapWithGetter<T>(arr: T[], getSelector: (item: T) => string) {\n return arr.reduce((accum, curr) => {\n const _key = getSelector(curr);\n accum[_key] = curr;\n return accum;\n }, {} as Record<string, T>);\n}\n"],"mappings":"AAoBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASA,UAAT,CACbC,GADa,EAEbC,QAFa,EAGbC,gBAHa,EAIbC,OAJa,EAKb;EACA,OAAOH,GAAG,CAACI,MAAJ,CAAW,CAACC,KAAD,EAAQC,IAAR,KAAiB;IACjC,IAAIH,OAAO,IAAID,gBAAf,EAAiC;MAC/B,MAAMK,IAAI,GAAGD,IAAI,CAACL,QAAD,CAAJ,GAAkBK,IAAI,CAACJ,gBAAD,CAAnC;;MACAG,KAAK,CAACE,IAAD,CAAL,GAAcD,IAAd;IACD,CAHD,MAGO;MACL,MAAMC,IAAI,GAAID,IAAI,CAACL,QAAD,CAAJ,IAAkBK,IAAI,CAACJ,gBAAD,CAApC;;MACAG,KAAK,CAACE,IAAD,CAAL,GAAcD,IAAd;IACD;;IAED,OAAOD,KAAP;EACD,CAVM,EAUJ,EAVI,CAAP;AAWD;AAED,OAAO,SAASG,oBAAT,CAAiCR,GAAjC,EAA2CS,WAA3C,EAA6E;EAClF,OAAOT,GAAG,CAACI,MAAJ,CAAW,CAACC,KAAD,EAAQC,IAAR,KAAiB;IACjC,MAAMC,IAAI,GAAGE,WAAW,CAACH,IAAD,CAAxB;;IACAD,KAAK,CAACE,IAAD,CAAL,GAAcD,IAAd;IACA,OAAOD,KAAP;EACD,CAJM,EAIJ,EAJI,CAAP;AAKD"}
|
|
@@ -75,4 +75,15 @@ export function getFileExtension(filePath) {
|
|
|
75
75
|
if (idx === -1) return '';
|
|
76
76
|
return filePath.slice(idx - filePath.length).toLowerCase();
|
|
77
77
|
}
|
|
78
|
+
export function normalizeFileName(fileName, extension) {
|
|
79
|
+
if (fileName.indexOf(extension) > -1) {
|
|
80
|
+
return fileName;
|
|
81
|
+
} else {
|
|
82
|
+
if (extension.indexOf('.') === 0) {
|
|
83
|
+
return `${fileName}${extension}`;
|
|
84
|
+
} else {
|
|
85
|
+
return `${fileName}.${extension}`;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
78
89
|
//# sourceMappingURL=regex.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["require","shim","urlRegexStrict","urlRegexRough","phoneRegex","emailRegex","newLineRegex","replaceUrlAsComponents","originText","replacer","strict","matches","matchAll","founds","map","value","text","start","index","end","length","items","cursor","forEach","restText","pop","head","slice","mid","tail","push","imageExtRegex","audioExtRegex","videoExtRegex","getFileType","extOrType","indexOf","type","split","match","getFileExtension","filePath","idx","lastIndexOf","toLowerCase"],"sources":["regex.ts"],"sourcesContent":["// For iOS 12 backwards compatibility\nrequire('string.prototype.matchall').shim();\n\nexport const urlRegexStrict =\n /(https?:\\/\\/|www\\.)[-a-zA-Z0-9@:%._+~#=]{1,256}\\.(xn--)?[a-z0-9-]{2,20}\\b([-a-zA-Z0-9@:%_+[\\],.~#?&/=]*[-a-zA-Z0-9@:%_+\\]~#?&/=])*/g;\nexport const urlRegexRough =\n /(https?:\\/\\/|www\\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/g;\nexport const phoneRegex = /[+]?[(]?[0-9]{3}[)]?[-\\s.]?[0-9]{3}[-\\s.]?[0-9]{4,7}/;\nexport const emailRegex = /\\S+@\\S+\\.\\S+/;\nexport const newLineRegex = /\\r\\n|\\r|\\n/g;\n\n// const cases = [\n// {\n// type: 'urlStrict',\n// regex: urlRegexStrict,\n// },\n// {\n// type: 'urlRough',\n// regex: urlRegexStrict,\n// },\n// {\n// type: 'email',\n// regex: emailRegex,\n// },\n// {\n// type: 'phone',\n// regex: urlRegexStrict,\n// },\n// ];\n\nexport const replaceUrlAsComponents = <T>(originText: string, replacer: (url: string) => T, strict?: boolean) => {\n const matches = [...originText.matchAll(strict ? urlRegexStrict : urlRegexRough)];\n const founds = matches.map((value) => {\n const text = value[0];\n const start = value.index ?? 0;\n const end = start + text.length;\n return { text, start, end };\n });\n\n const items: Array<string | T> = [originText];\n let cursor = 0;\n founds.forEach(({ text, start, end }) => {\n const restText = items.pop() as string;\n const head = restText.slice(0, start - cursor);\n const mid = replacer(text);\n const tail = restText.slice(end - cursor);\n items.push(head, mid, tail);\n cursor = end;\n });\n return items;\n};\n\nexport const imageExtRegex = /jpeg|jpg|png|webp|gif/i;\nexport const audioExtRegex = /3gp|aac|aax|act|aiff|flac|gsm|m4a|m4b|m4p|tta|wma|mp3|webm|wav/i;\nexport const videoExtRegex = /mov|vod|mp4|avi/i;\nexport const getFileType = (extOrType: string) => {\n if (extOrType.indexOf('/') > -1) {\n const type = extOrType.split('/')[0];\n if (type === 'video') return 'video';\n if (type === 'audio') return 'audio';\n if (type === 'image') return 'image';\n return 'file';\n }\n\n if (extOrType.match(imageExtRegex)) return 'image';\n if (extOrType.match(audioExtRegex)) return 'audio';\n if (extOrType.match(videoExtRegex)) return 'video';\n return 'file';\n};\nexport function getFileExtension(filePath: string) {\n const idx = filePath.lastIndexOf('.');\n if (idx === -1) return '';\n return filePath.slice(idx - filePath.length).toLowerCase();\n}\n"],"mappings":"AAAA;AACAA,OAAO,CAAC,2BAAD,CAAP,CAAqCC,IAArC;;AAEA,OAAO,MAAMC,cAAc,GACzB,qIADK;AAEP,OAAO,MAAMC,aAAa,GACxB,uGADK;AAEP,OAAO,MAAMC,UAAU,GAAG,sDAAnB;AACP,OAAO,MAAMC,UAAU,GAAG,cAAnB;AACP,OAAO,MAAMC,YAAY,GAAG,aAArB,C,CAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMC,sBAAsB,GAAG,CAAIC,UAAJ,EAAwBC,QAAxB,EAAsDC,MAAtD,KAA2E;EAC/G,MAAMC,OAAO,GAAG,CAAC,GAAGH,UAAU,CAACI,QAAX,CAAoBF,MAAM,GAAGR,c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IACA,IAAID,IAAI,KAAK,OAAb,EAAsB,OAAO,OAAP;IACtB,IAAIA,IAAI,KAAK,OAAb,EAAsB,OAAO,OAAP;IACtB,IAAIA,IAAI,KAAK,OAAb,EAAsB,OAAO,OAAP;IACtB,OAAO,MAAP;EACD;;EAED,IAAIF,SAAS,CAACI,KAAV,CAAgBR,aAAhB,CAAJ,EAAoC,OAAO,OAAP;EACpC,IAAII,SAAS,CAACI,KAAV,CAAgBP,aAAhB,CAAJ,EAAoC,OAAO,OAAP;EACpC,IAAIG,SAAS,CAACI,KAAV,CAAgBN,aAAhB,CAAJ,EAAoC,OAAO,OAAP;EACpC,OAAO,MAAP;AACD,CAbM;AAcP,OAAO,SAASO,gBAAT,CAA0BC,QAA1B,EAA4C;EACjD,MAAMC,GAAG,GAAGD,QAAQ,CAACE,WAAT,CAAqB,GAArB,CAAZ;EACA,IAAID,GAAG,KAAK,CAAC,CAAb,EAAgB,OAAO,EAAP;EAChB,OAAOD,QAAQ,CAACd,KAAT,CAAee,GAAG,GAAGD,QAAQ,CAACrB,MAA9B,EAAsCwB,WAAtC,EAAP;AACD"}
|
|
1
|
+
{"version":3,"names":["require","shim","urlRegexStrict","urlRegexRough","phoneRegex","emailRegex","newLineRegex","replaceUrlAsComponents","originText","replacer","strict","matches","matchAll","founds","map","value","text","start","index","end","length","items","cursor","forEach","restText","pop","head","slice","mid","tail","push","imageExtRegex","audioExtRegex","videoExtRegex","getFileType","extOrType","indexOf","type","split","match","getFileExtension","filePath","idx","lastIndexOf","toLowerCase","normalizeFileName","fileName","extension"],"sources":["regex.ts"],"sourcesContent":["// For iOS 12 backwards compatibility\nrequire('string.prototype.matchall').shim();\n\nexport const urlRegexStrict =\n /(https?:\\/\\/|www\\.)[-a-zA-Z0-9@:%._+~#=]{1,256}\\.(xn--)?[a-z0-9-]{2,20}\\b([-a-zA-Z0-9@:%_+[\\],.~#?&/=]*[-a-zA-Z0-9@:%_+\\]~#?&/=])*/g;\nexport const urlRegexRough =\n /(https?:\\/\\/|www\\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/g;\nexport const phoneRegex = /[+]?[(]?[0-9]{3}[)]?[-\\s.]?[0-9]{3}[-\\s.]?[0-9]{4,7}/;\nexport const emailRegex = /\\S+@\\S+\\.\\S+/;\nexport const newLineRegex = /\\r\\n|\\r|\\n/g;\n\n// const cases = [\n// {\n// type: 'urlStrict',\n// regex: urlRegexStrict,\n// },\n// {\n// type: 'urlRough',\n// regex: urlRegexStrict,\n// },\n// {\n// type: 'email',\n// regex: emailRegex,\n// },\n// {\n// type: 'phone',\n// regex: urlRegexStrict,\n// },\n// ];\n\nexport const replaceUrlAsComponents = <T>(originText: string, replacer: (url: string) => T, strict?: boolean) => {\n const matches = [...originText.matchAll(strict ? urlRegexStrict : urlRegexRough)];\n const founds = matches.map((value) => {\n const text = value[0];\n const start = value.index ?? 0;\n const end = start + text.length;\n return { text, start, end };\n });\n\n const items: Array<string | T> = [originText];\n let cursor = 0;\n founds.forEach(({ text, start, end }) => {\n const restText = items.pop() as string;\n const head = restText.slice(0, start - cursor);\n const mid = replacer(text);\n const tail = restText.slice(end - cursor);\n items.push(head, mid, tail);\n cursor = end;\n });\n return items;\n};\n\nexport const imageExtRegex = /jpeg|jpg|png|webp|gif/i;\nexport const audioExtRegex = /3gp|aac|aax|act|aiff|flac|gsm|m4a|m4b|m4p|tta|wma|mp3|webm|wav/i;\nexport const videoExtRegex = /mov|vod|mp4|avi/i;\nexport const getFileType = (extOrType: string) => {\n if (extOrType.indexOf('/') > -1) {\n const type = extOrType.split('/')[0];\n if (type === 'video') return 'video';\n if (type === 'audio') return 'audio';\n if (type === 'image') return 'image';\n return 'file';\n }\n\n if (extOrType.match(imageExtRegex)) return 'image';\n if (extOrType.match(audioExtRegex)) return 'audio';\n if (extOrType.match(videoExtRegex)) return 'video';\n return 'file';\n};\nexport function getFileExtension(filePath: string) {\n const idx = filePath.lastIndexOf('.');\n if (idx === -1) return '';\n return filePath.slice(idx - filePath.length).toLowerCase();\n}\nexport function normalizeFileName(fileName: string, extension: string) {\n if (fileName.indexOf(extension) > -1) {\n return fileName;\n } else {\n if (extension.indexOf('.') === 0) {\n return `${fileName}${extension}`;\n } else {\n return `${fileName}.${extension}`;\n }\n }\n}\n"],"mappings":"AAAA;AACAA,OAAO,CAAC,2BAAD,CAAP,CAAqCC,IAArC;;AAEA,OAAO,MAAMC,cAAc,GACzB,qIADK;AAEP,OAAO,MAAMC,aAAa,GACxB,uGADK;AAEP,OAAO,MAAMC,UAAU,GAAG,sDAAnB;AACP,OAAO,MAAMC,UAAU,GAAG,cAAnB;AACP,OAAO,MAAMC,YAAY,GAAG,aAArB,C,CAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMC,sBAAsB,GAAG,CAAIC,UAAJ,EAAwBC,QAAxB,EAAsDC,MAAtD,KAA2E;EAC/G,MAAMC,OAAO,GAAG,CAAC,GAAGH,UAAU,CAACI,QAAX,CAAoBF,MAAM,GAAGR,cAAH,GAAoBC,aAA9C,CAAJ,CAAhB;EACA,MAAMU,MAAM,GAAGF,OAAO,CAACG,GAAR,CAAaC,KAAD,IAAW;IACpC,MAAMC,IAAI,GAAGD,KAAK,CAAC,CAAD,CAAlB;IACA,MAAME,KAAK,GAAGF,KAAK,CAACG,KAAN,IAAe,CAA7B;IACA,MAAMC,GAAG,GAAGF,KAAK,GAAGD,IAAI,CAACI,MAAzB;IACA,OAAO;MAAEJ,IAAF;MAAQC,KAAR;MAAeE;IAAf,CAAP;EACD,CALc,CAAf;EAOA,MAAME,KAAwB,GAAG,CAACb,UAAD,CAAjC;EACA,IAAIc,MAAM,GAAG,CAAb;EACAT,MAAM,CAACU,OAAP,CAAe,QAA0B;IAAA,IAAzB;MAAEP,IAAF;MAAQC,KAAR;MAAeE;IAAf,CA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AACE,WAAT,CAAqB,GAArB,CAAZ;EACA,IAAID,GAAG,KAAK,CAAC,CAAb,EAAgB,OAAO,EAAP;EAChB,OAAOD,QAAQ,CAACd,KAAT,CAAee,GAAG,GAAGD,QAAQ,CAACrB,MAA9B,EAAsCwB,WAAtC,EAAP;AACD;AACD,OAAO,SAASC,iBAAT,CAA2BC,QAA3B,EAA6CC,SAA7C,EAAgE;EACrE,IAAID,QAAQ,CAACV,OAAT,CAAiBW,SAAjB,IAA8B,CAAC,CAAnC,EAAsC;IACpC,OAAOD,QAAP;EACD,CAFD,MAEO;IACL,IAAIC,SAAS,CAACX,OAAV,CAAkB,GAAlB,MAA2B,CAA/B,EAAkC;MAChC,OAAQ,GAAEU,QAAS,GAAEC,SAAU,EAA/B;IACD,CAFD,MAEO;MACL,OAAQ,GAAED,QAAS,IAAGC,SAAU,EAAhC;IACD;EACF;AACF"}
|
package/lib/module/types.js
CHANGED
package/lib/module/types.js.map
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';\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 { BaseChannel, SendbirdError as SBError, User, UserUpdateParams } 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 UserMessage,\n UserMessageCreateParams,\n UserMessageUpdateParams,\n} from '@sendbird/chat/message';\nimport type { OpenChannel, OpenChannelModule } from '@sendbird/chat/openChannel';\n\nimport './';\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 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 SendbirdMember = Member;\nexport type SendbirdGroupChannel = GroupChannel;\nexport type SendbirdBaseChannel = BaseChannel;\nexport type SendbirdOpenChannel = OpenChannel;\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":"AAAA;;AAEA;AA6BA,OAAO,IAAP"}
|
|
@@ -54,6 +54,14 @@ export const getGroupChannelLastMessage = function (channel) {
|
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
if (message.isUserMessage()) {
|
|
58
|
+
return message.message ?? EMPTY_MESSAGE;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (message.isAdminMessage()) {
|
|
62
|
+
return message.message ?? EMPTY_MESSAGE;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return EMPTY_MESSAGE;
|
|
58
66
|
};
|
|
59
67
|
//# sourceMappingURL=groupChannel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["format","isToday","isYesterday","truncate","getGroupChannelTitle","currentUserId","channel","EMPTY_USERNAME","NO_MEMBERS","DEFAULT_CHANNEL_NAME","name","memberCount","members","filter","userId","map","nickname","join","getGroupChannelPreviewTime","locale","timestamp","lastMessage","createdAt","joinedAt","getGroupChannelLastMessage","EMPTY_MESSAGE","MAX_LEN","message","isFileMessage","extIdx","lastIndexOf","file","slice","ext","maxLen"],"sources":["groupChannel.ts"],"sourcesContent":["import type { Locale } from 'date-fns';\nimport format from 'date-fns/format';\nimport isToday from 'date-fns/isToday';\nimport isYesterday from 'date-fns/isYesterday';\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 if (isToday(timestamp)) return format(timestamp, 'p', { locale });\n if (isYesterday(timestamp)) return 'Yesterday';\n return format(timestamp, 'MMM 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 return message.message ?? EMPTY_MESSAGE;\n};\n"],"mappings":"AACA,OAAOA,MAAP,MAAmB,iBAAnB;AACA,OAAOC,OAAP,MAA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qE;EAAA,IAArCmB,aAAqC,uEAArB,EAAqB;EAAA,IAAjBC,OAAiB,uEAAP,EAAO;EAC7G,MAAMC,OAAO,GAAGrB,OAAO,CAACe,WAAxB;EACA,IAAI,CAACM,OAAL,EAAc,OAAOF,aAAP;;EAEd,IAAIE,OAAO,CAACC,aAAR,EAAJ,EAA6B;IAC3B,MAAMC,MAAM,GAAGF,OAAO,CAACjB,IAAR,CAAaoB,WAAb,CAAyB,GAAzB,CAAf;;IACA,IAAID,MAAM,GAAG,CAAC,CAAd,EAAiB;MACf,MAAME,IAAI,GAAGJ,OAAO,CAACjB,IAAR,CAAasB,KAAb,CAAmB,CAAnB,EAAsBH,MAAtB,CAAb;MACA,MAAMI,GAAG,GAAGN,OAAO,CAACjB,IAAR,CAAasB,KAAb,CAAmBH,MAAnB,CAAZ;MACA,OAAO1B,QAAQ,CAAC4B,IAAD,EAAO;QAAEG,MAAM,EAAER;MAAV,CAAP,CAAR,GAAsCO,GAA7C;IACD;;IAED,OAAO9B,QAAQ,CAACwB,OAAO,CAACjB,IAAT,EAAe;MAAEwB,MAAM,EAAER;IAAV,CAAf,CAAf;EACD;;EAED,
|
|
1
|
+
{"version":3,"names":["format","isToday","isYesterday","truncate","getGroupChannelTitle","currentUserId","channel","EMPTY_USERNAME","NO_MEMBERS","DEFAULT_CHANNEL_NAME","name","memberCount","members","filter","userId","map","nickname","join","getGroupChannelPreviewTime","locale","timestamp","lastMessage","createdAt","joinedAt","getGroupChannelLastMessage","EMPTY_MESSAGE","MAX_LEN","message","isFileMessage","extIdx","lastIndexOf","file","slice","ext","maxLen","isUserMessage","isAdminMessage"],"sources":["groupChannel.ts"],"sourcesContent":["import type { Locale } from 'date-fns';\nimport format from 'date-fns/format';\nimport isToday from 'date-fns/isToday';\nimport isYesterday from 'date-fns/isYesterday';\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 if (isToday(timestamp)) return format(timestamp, 'p', { locale });\n if (isYesterday(timestamp)) return 'Yesterday';\n return format(timestamp, 'MMM 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,OAAOA,MAAP,MAAmB,iBAAnB;AACA,OAAOC,OAAP,MAAoB,kBAApB;AACA,OAAOC,WAAP,MAAwB,sBAAxB;AAGA,SAASC,QAAT,QAAyB,UAAzB;AAEA,OAAO,MAAMC,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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CAAf;;IACA,IAAID,MAAM,GAAG,CAAC,CAAd,EAAiB;MACf,MAAME,IAAI,GAAGJ,OAAO,CAACjB,IAAR,CAAasB,KAAb,CAAmB,CAAnB,EAAsBH,MAAtB,CAAb;MACA,MAAMI,GAAG,GAAGN,OAAO,CAACjB,IAAR,CAAasB,KAAb,CAAmBH,MAAnB,CAAZ;MACA,OAAO1B,QAAQ,CAAC4B,IAAD,EAAO;QAAEG,MAAM,EAAER;MAAV,CAAP,CAAR,GAAsCO,GAA7C;IACD;;IAED,OAAO9B,QAAQ,CAACwB,OAAO,CAACjB,IAAT,EAAe;MAAEwB,MAAM,EAAER;IAAV,CAAf,CAAf;EACD;;EAED,IAAIC,OAAO,CAACQ,aAAR,EAAJ,EAA6B;IAC3B,OAAOR,OAAO,CAACA,OAAR,IAAmBF,aAA1B;EACD;;EAED,IAAIE,OAAO,CAACS,cAAR,EAAJ,EAA8B;IAC5B,OAAOT,OAAO,CAACA,OAAR,IAAmBF,aAA1B;EACD;;EAED,OAAOA,aAAP;AACD,CAxBM"}
|
|
@@ -2,7 +2,7 @@ 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, } from './shared/regex';
|
|
5
|
+
export { urlRegexStrict, urlRegexRough, newLineRegex, audioExtRegex, videoExtRegex, imageExtRegex, getFileType, getFileExtension, replaceUrlAsComponents, normalizeFileName, emailRegex, phoneRegex, } from './shared/regex';
|
|
6
6
|
export * from './hooks';
|
|
7
7
|
export * from './ui-format/groupChannel';
|
|
8
8
|
export * from './ui-format/common';
|
|
@@ -13,4 +13,4 @@ export declare const NOOP: () => void;
|
|
|
13
13
|
export declare const ASYNC_NOOP: () => Promise<undefined>;
|
|
14
14
|
export declare const PASS: <T>(val: T) => T;
|
|
15
15
|
export declare const toMegabyte: (byte: number) => number;
|
|
16
|
-
export type { FilterByValueType, UnionToIntersection, OmittedValues, PartialDeep, Optional, ContextValue, SendbirdMessage, SendbirdChatSDK, SendbirdChannel, SendbirdBaseChannel, SendbirdGroupChannel, SendbirdOpenChannel, SendbirdUser, SendbirdMember, SendbirdBaseMessage, SendbirdUserMessage, SendbirdFileMessage, SendbirdAdminMessage,
|
|
16
|
+
export type { FilterByValueType, UnionToIntersection, OmittedValues, PartialDeep, Optional, ContextValue, SendbirdMessage, SendbirdChatSDK, SendbirdChannel, SendbirdBaseChannel, SendbirdGroupChannel, SendbirdOpenChannel, SendbirdUser, SendbirdMember, SendbirdBaseMessage, SendbirdUserMessage, SendbirdFileMessage, SendbirdAdminMessage, SendbirdGroupChannelCreateParams, SendbirdFileMessageCreateParams, SendbirdUserMessageCreateParams, SendbirdError, SendbirdMessageCollection, SendbirdGroupChannelCollection, NotificationFiles, NotificationMentionedUsers, NotificationTranslations, PartialNullable, SendbirdDataPayload, SendbirdPreviousMessageListQuery, SendbirdSendableMessage, SendbirdGroupChannelListQuery, SendbirdGroupChannelUpdateParams, SendbirdUserMessageUpdateParams, SendbirdFileMessageUpdateParams, SendbirdUserUpdateParams, } from './types';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SendbirdBaseChannel, SendbirdChannel, SendbirdGroupChannel, SendbirdOpenChannel } from '../types';
|
|
1
|
+
import type { SendbirdBaseChannel, SendbirdChannel, SendbirdChatSDK, SendbirdGroupChannel, SendbirdOpenChannel } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Diff utils for channel
|
|
4
4
|
* @param {SendbirdBaseChannel} [a]
|
|
@@ -6,8 +6,10 @@ import type { SendbirdBaseChannel, SendbirdChannel, SendbirdGroupChannel, Sendbi
|
|
|
6
6
|
* @returns {boolean}
|
|
7
7
|
* */
|
|
8
8
|
export declare function isDifferentChannel<T extends SendbirdBaseChannel>(a?: T, b?: T): boolean;
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const isGroupChannelChatUnavailable: (channel: SendbirdGroupChannel) => boolean;
|
|
10
|
+
export declare const confirmAndMarkAsRead: (sdk: SendbirdChatSDK, channels: SendbirdBaseChannel[]) => Promise<void>;
|
|
11
|
+
export declare const confirmAndMarkAsDelivered: (sdk: SendbirdChatSDK, channel: SendbirdBaseChannel) => Promise<void>;
|
|
10
12
|
export declare function isDefaultCoverImage(coverUrl: string): boolean;
|
|
11
|
-
export declare function getMembersExcludeMe(channel: SendbirdGroupChannel, currentUserId?: string): import("sendbird").Member[];
|
|
13
|
+
export declare function getMembersExcludeMe(channel: SendbirdGroupChannel, currentUserId?: string): import("@sendbird/chat/groupChannel").Member[];
|
|
12
14
|
export declare function getGroupChannels(channels: SendbirdChannel[]): SendbirdGroupChannel[];
|
|
13
15
|
export declare function getOpenChannels(channels: SendbirdChannel[]): SendbirdOpenChannel[];
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import type { SendbirdDataPayload, SendbirdFileMessage, SendbirdMessage } from '../types';
|
|
1
|
+
import type { SendbirdBaseMessage, SendbirdDataPayload, SendbirdFileMessage, SendbirdMessage, SendbirdSendableMessage } from '../types';
|
|
2
2
|
export declare function isNewMessage(msg: SendbirdMessage, currentUserId?: string): boolean;
|
|
3
|
+
export declare function isSendableMessage(msg?: SendbirdMessage | null): msg is SendbirdSendableMessage;
|
|
3
4
|
export declare function isMyMessage(msg?: SendbirdMessage | null, currentUserId?: string): boolean;
|
|
4
5
|
export declare function messageKeyExtractor(message: SendbirdMessage): string;
|
|
5
|
-
export declare function messageComparator
|
|
6
|
+
export declare function messageComparator(a: SendbirdMessage, b: SendbirdMessage): number;
|
|
6
7
|
export declare function hasSameSender(a?: SendbirdMessage, b?: SendbirdMessage): boolean;
|
|
7
8
|
export declare function calcMessageGrouping(groupEnabled: boolean, curr: SendbirdMessage, prev?: SendbirdMessage, next?: SendbirdMessage): {
|
|
8
9
|
groupWithPrev: boolean;
|
|
9
10
|
groupWithNext: boolean;
|
|
10
11
|
};
|
|
11
|
-
export declare function getMessageUniqId(msg:
|
|
12
|
+
export declare function getMessageUniqId(msg: SendbirdBaseMessage): string;
|
|
12
13
|
export declare function getAvailableUriFromFileMessage(message: SendbirdFileMessage): string;
|
|
13
14
|
declare type RawSendbirdDataPayload = {
|
|
14
15
|
sendbird: string | object;
|
|
@@ -2,4 +2,4 @@ import type { FilterByValueType } from '../types';
|
|
|
2
2
|
export default function arrayToMap<T extends Record<K, unknown>, K extends keyof T = keyof T>(arr: T[], selector: keyof FilterByValueType<T, string | number>): Record<string, T>;
|
|
3
3
|
export default function arrayToMap<T extends Record<K, unknown>, K extends keyof T = keyof T>(arr: T[], selector: string, fallbackSelector: K): Record<string, T>;
|
|
4
4
|
export default function arrayToMap<T extends Record<K, unknown>, K extends keyof T = keyof T>(arr: T[], selector: string, selector2: string, combineKey: true): Record<string, T>;
|
|
5
|
-
export declare function arrayToMapWithGetter<T
|
|
5
|
+
export declare function arrayToMapWithGetter<T>(arr: T[], getSelector: (item: T) => string): Record<string, T>;
|
|
@@ -9,3 +9,4 @@ export declare const audioExtRegex: RegExp;
|
|
|
9
9
|
export declare const videoExtRegex: RegExp;
|
|
10
10
|
export declare const getFileType: (extOrType: string) => "video" | "audio" | "image" | "file";
|
|
11
11
|
export declare function getFileExtension(filePath: string): string;
|
|
12
|
+
export declare function normalizeFileName(fileName: string, extension: string): string;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
-
import type
|
|
2
|
+
import type SendbirdChat from '@sendbird/chat';
|
|
3
|
+
import type { BaseChannel, SendbirdError as SBError, User, UserUpdateParams } from '@sendbird/chat';
|
|
4
|
+
import type { GroupChannel, GroupChannelCollection, GroupChannelCreateParams, GroupChannelListQuery, GroupChannelModule, GroupChannelUpdateParams, Member, MessageCollection } from '@sendbird/chat/groupChannel';
|
|
5
|
+
import type { ModuleNamespaces, SendableMessage } from '@sendbird/chat/lib/__definition';
|
|
6
|
+
import type { AdminMessage, BaseMessage, FileMessage, FileMessageCreateParams, FileMessageUpdateParams, PreviousMessageListQuery, UserMessage, UserMessageCreateParams, UserMessageUpdateParams } from '@sendbird/chat/message';
|
|
7
|
+
import type { OpenChannel, OpenChannelModule } from '@sendbird/chat/openChannel';
|
|
8
|
+
import './';
|
|
3
9
|
export declare type FilterByValueType<T extends object, Type> = {
|
|
4
10
|
[K in keyof T as T[K] extends Type ? K : never]: T[K];
|
|
5
11
|
};
|
|
@@ -13,24 +19,31 @@ export declare type PartialNullable<T> = {
|
|
|
13
19
|
};
|
|
14
20
|
export declare type Optional<T> = T | undefined;
|
|
15
21
|
export declare type ContextValue<T extends React.Context<any>> = T extends React.Context<infer V> ? V : never;
|
|
16
|
-
export declare type SendbirdChatSDK =
|
|
17
|
-
export declare type SendbirdMessage =
|
|
18
|
-
export declare type SendbirdChannel =
|
|
19
|
-
export declare type SendbirdUserMessage =
|
|
20
|
-
export declare type SendbirdFileMessage =
|
|
21
|
-
export declare type SendbirdAdminMessage =
|
|
22
|
-
export declare type SendbirdBaseMessage =
|
|
23
|
-
export declare type
|
|
24
|
-
export declare type
|
|
25
|
-
export declare type
|
|
26
|
-
export declare type
|
|
27
|
-
export declare type
|
|
28
|
-
export declare type
|
|
29
|
-
export declare type
|
|
30
|
-
export declare type
|
|
31
|
-
export declare type
|
|
32
|
-
export declare type
|
|
33
|
-
export declare type
|
|
22
|
+
export declare type SendbirdChatSDK = SendbirdChat & ModuleNamespaces<[GroupChannelModule, OpenChannelModule]>;
|
|
23
|
+
export declare type SendbirdMessage = BaseMessage | FileMessage | UserMessage | AdminMessage | SendableMessage;
|
|
24
|
+
export declare type SendbirdChannel = BaseChannel | GroupChannel | OpenChannel;
|
|
25
|
+
export declare type SendbirdUserMessage = UserMessage;
|
|
26
|
+
export declare type SendbirdFileMessage = FileMessage;
|
|
27
|
+
export declare type SendbirdAdminMessage = AdminMessage;
|
|
28
|
+
export declare type SendbirdBaseMessage = BaseMessage;
|
|
29
|
+
export declare type SendbirdSendableMessage = SendableMessage;
|
|
30
|
+
export declare type SendbirdFileMessageCreateParams = FileMessageCreateParams;
|
|
31
|
+
export declare type SendbirdFileMessageUpdateParams = FileMessageUpdateParams;
|
|
32
|
+
export declare type SendbirdUserMessageCreateParams = UserMessageCreateParams;
|
|
33
|
+
export declare type SendbirdUserMessageUpdateParams = UserMessageUpdateParams;
|
|
34
|
+
export declare type SendbirdGroupChannelCreateParams = GroupChannelCreateParams;
|
|
35
|
+
export declare type SendbirdGroupChannelUpdateParams = GroupChannelUpdateParams;
|
|
36
|
+
export declare type SendbirdUserUpdateParams = UserUpdateParams;
|
|
37
|
+
export declare type SendbirdUser = User;
|
|
38
|
+
export declare type SendbirdMember = Member;
|
|
39
|
+
export declare type SendbirdGroupChannel = GroupChannel;
|
|
40
|
+
export declare type SendbirdBaseChannel = BaseChannel;
|
|
41
|
+
export declare type SendbirdOpenChannel = OpenChannel;
|
|
42
|
+
export declare type SendbirdGroupChannelCollection = GroupChannelCollection;
|
|
43
|
+
export declare type SendbirdGroupChannelListQuery = GroupChannelListQuery;
|
|
44
|
+
export declare type SendbirdMessageCollection = MessageCollection;
|
|
45
|
+
export declare type SendbirdPreviousMessageListQuery = PreviousMessageListQuery;
|
|
46
|
+
export declare type SendbirdError = SBError;
|
|
34
47
|
export interface SendbirdDataPayload {
|
|
35
48
|
app_id: string;
|
|
36
49
|
audience_type: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sendbird/uikit-utils",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-rc.0",
|
|
4
4
|
"description": "UIKit utilities",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -44,13 +44,18 @@
|
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/react": "*",
|
|
46
46
|
"react": "17.0.2",
|
|
47
|
-
"react-native": "0.
|
|
47
|
+
"react-native": "0.67.4",
|
|
48
48
|
"react-native-builder-bob": "^0.18.0",
|
|
49
49
|
"typescript": "^4.1.3"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"
|
|
53
|
-
"
|
|
52
|
+
"@sendbird/chat": "^4.0.13",
|
|
53
|
+
"react": ">=16.13.1"
|
|
54
|
+
},
|
|
55
|
+
"peerDependenciesMeta": {
|
|
56
|
+
"@sendbird/chat": {
|
|
57
|
+
"optional": true
|
|
58
|
+
}
|
|
54
59
|
},
|
|
55
60
|
"react-native-builder-bob": {
|
|
56
61
|
"source": "src",
|
|
@@ -71,5 +76,5 @@
|
|
|
71
76
|
"readmeFile": "./README.md",
|
|
72
77
|
"displayName": "@sendbird/uikit-utils"
|
|
73
78
|
},
|
|
74
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "394d5e3e259086c2226a24406462f119d4af9860"
|
|
75
80
|
}
|
package/src/hooks/index.ts
CHANGED
|
@@ -58,8 +58,6 @@ export const useIsMountedRef = () => {
|
|
|
58
58
|
|
|
59
59
|
export const useFreshCallback = <T extends (...args: any[]) => any>(callback: T): T => {
|
|
60
60
|
const ref = useRef<T>(callback);
|
|
61
|
-
|
|
62
|
-
ref.current = callback;
|
|
63
|
-
});
|
|
61
|
+
ref.current = callback;
|
|
64
62
|
return useCallback(((...args) => ref.current(...args)) as T, []);
|
|
65
63
|
};
|
package/src/index.ts
CHANGED
|
@@ -12,6 +12,9 @@ export {
|
|
|
12
12
|
getFileType,
|
|
13
13
|
getFileExtension,
|
|
14
14
|
replaceUrlAsComponents,
|
|
15
|
+
normalizeFileName,
|
|
16
|
+
emailRegex,
|
|
17
|
+
phoneRegex,
|
|
15
18
|
} from './shared/regex';
|
|
16
19
|
|
|
17
20
|
export * from './hooks';
|
|
@@ -45,9 +48,9 @@ export type {
|
|
|
45
48
|
SendbirdUserMessage,
|
|
46
49
|
SendbirdFileMessage,
|
|
47
50
|
SendbirdAdminMessage,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
SendbirdGroupChannelCreateParams,
|
|
52
|
+
SendbirdFileMessageCreateParams,
|
|
53
|
+
SendbirdUserMessageCreateParams,
|
|
51
54
|
SendbirdError,
|
|
52
55
|
SendbirdMessageCollection,
|
|
53
56
|
SendbirdGroupChannelCollection,
|
|
@@ -56,4 +59,11 @@ export type {
|
|
|
56
59
|
NotificationTranslations,
|
|
57
60
|
PartialNullable,
|
|
58
61
|
SendbirdDataPayload,
|
|
62
|
+
SendbirdPreviousMessageListQuery,
|
|
63
|
+
SendbirdSendableMessage,
|
|
64
|
+
SendbirdGroupChannelListQuery,
|
|
65
|
+
SendbirdGroupChannelUpdateParams,
|
|
66
|
+
SendbirdUserMessageUpdateParams,
|
|
67
|
+
SendbirdFileMessageUpdateParams,
|
|
68
|
+
SendbirdUserUpdateParams,
|
|
59
69
|
} from './types';
|
package/src/sendbird/channel.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
SendbirdBaseChannel,
|
|
3
|
+
SendbirdChannel,
|
|
4
|
+
SendbirdChatSDK,
|
|
5
|
+
SendbirdGroupChannel,
|
|
6
|
+
SendbirdOpenChannel,
|
|
7
|
+
} from '../types';
|
|
2
8
|
|
|
3
9
|
/**
|
|
4
10
|
* Diff utils for channel
|
|
@@ -11,10 +17,21 @@ export function isDifferentChannel<T extends SendbirdBaseChannel>(a?: T, b?: T):
|
|
|
11
17
|
return a.url !== b.url;
|
|
12
18
|
}
|
|
13
19
|
|
|
14
|
-
export const
|
|
20
|
+
export const isGroupChannelChatUnavailable = (channel: SendbirdGroupChannel) => {
|
|
15
21
|
return channel.myMutedState === 'muted' || (channel.isFrozen && channel.myRole !== 'operator');
|
|
16
22
|
};
|
|
17
23
|
|
|
24
|
+
export const confirmAndMarkAsRead = async (sdk: SendbirdChatSDK, channels: SendbirdBaseChannel[]) => {
|
|
25
|
+
const channelUrls = channels.filter((it) => it.isGroupChannel() && it.unreadMessageCount > 0).map((it) => it.url);
|
|
26
|
+
await sdk.groupChannel.markAsReadWithChannelUrls(channelUrls);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const confirmAndMarkAsDelivered = async (sdk: SendbirdChatSDK, channel: SendbirdBaseChannel) => {
|
|
30
|
+
if (channel.isGroupChannel() && channel.unreadMessageCount > 0) {
|
|
31
|
+
await sdk.groupChannel.markAsDelivered(channel.url);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
18
35
|
export function isDefaultCoverImage(coverUrl: string) {
|
|
19
36
|
return coverUrl === '' || coverUrl.startsWith('https://static.sendbird.com/sample/cover');
|
|
20
37
|
}
|
package/src/sendbird/message.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
SendbirdBaseMessage,
|
|
3
|
+
SendbirdDataPayload,
|
|
4
|
+
SendbirdFileMessage,
|
|
5
|
+
SendbirdMessage,
|
|
6
|
+
SendbirdSendableMessage,
|
|
7
|
+
} from '../types';
|
|
2
8
|
import { messageTime } from '../ui-format/common';
|
|
3
9
|
|
|
4
10
|
export function isNewMessage(msg: SendbirdMessage, currentUserId?: string) {
|
|
@@ -8,8 +14,12 @@ export function isNewMessage(msg: SendbirdMessage, currentUserId?: string) {
|
|
|
8
14
|
return msg.updatedAt === 0;
|
|
9
15
|
}
|
|
10
16
|
|
|
17
|
+
export function isSendableMessage(msg?: SendbirdMessage | null): msg is SendbirdSendableMessage {
|
|
18
|
+
return msg !== undefined && msg !== null && 'sendingStatus' in msg;
|
|
19
|
+
}
|
|
20
|
+
|
|
11
21
|
export function isMyMessage(msg?: SendbirdMessage | null, currentUserId = '##__USER_ID_IS_NOT_PROVIDED__##') {
|
|
12
|
-
if (!msg) return false;
|
|
22
|
+
if (!isSendableMessage(msg)) return false;
|
|
13
23
|
return (
|
|
14
24
|
('sender' in msg && msg.sender?.userId === currentUserId) ||
|
|
15
25
|
msg.sendingStatus === 'pending' ||
|
|
@@ -30,12 +40,12 @@ export function messageKeyExtractor(message: SendbirdMessage): string {
|
|
|
30
40
|
// | failed | timestamp(A) | 0 | ? |
|
|
31
41
|
// | succeeded | timestamp(A) / '' | id from DB | timestamp(C) |
|
|
32
42
|
// |-------------------|-------------------|-----------------|-------------------|
|
|
33
|
-
export function messageComparator
|
|
43
|
+
export function messageComparator(a: SendbirdMessage, b: SendbirdMessage) {
|
|
34
44
|
let aStatusOffset = 0;
|
|
35
45
|
let bStatusOffset = 0;
|
|
36
46
|
|
|
37
|
-
if (a.sendingStatus !== 'succeeded') aStatusOffset = 999999;
|
|
38
|
-
if (b.sendingStatus !== 'succeeded') bStatusOffset = 999999;
|
|
47
|
+
if (isSendableMessage(a) && a.sendingStatus !== 'succeeded') aStatusOffset = 999999;
|
|
48
|
+
if (isSendableMessage(b) && b.sendingStatus !== 'succeeded') bStatusOffset = 999999;
|
|
39
49
|
|
|
40
50
|
return b.createdAt + bStatusOffset - (a.createdAt + aStatusOffset);
|
|
41
51
|
}
|
|
@@ -73,7 +83,7 @@ export function calcMessageGrouping(
|
|
|
73
83
|
return { groupWithPrev: getPrev(), groupWithNext: getNext() };
|
|
74
84
|
}
|
|
75
85
|
|
|
76
|
-
export function getMessageUniqId(msg:
|
|
86
|
+
export function getMessageUniqId(msg: SendbirdBaseMessage) {
|
|
77
87
|
if (msg.isUserMessage() || msg.isFileMessage()) {
|
|
78
88
|
if (msg.sendingStatus === 'succeeded') return String(msg.messageId);
|
|
79
89
|
return msg.reqId;
|
|
@@ -83,7 +93,7 @@ export function getMessageUniqId(msg: SendbirdMessage) {
|
|
|
83
93
|
}
|
|
84
94
|
|
|
85
95
|
export function getAvailableUriFromFileMessage(message: SendbirdFileMessage) {
|
|
86
|
-
if (!message.url && message.messageParams && 'uri' in message.messageParams.file) {
|
|
96
|
+
if (!message.url && message.messageParams.file && 'uri' in message.messageParams.file) {
|
|
87
97
|
return message.messageParams.file.uri;
|
|
88
98
|
}
|
|
89
99
|
return message.url;
|
package/src/shared/arrayToMap.ts
CHANGED
|
@@ -58,10 +58,7 @@ export default function arrayToMap<T extends Record<K, unknown>, K extends keyof
|
|
|
58
58
|
}, {} as Record<string, T>);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
export function arrayToMapWithGetter<T
|
|
62
|
-
arr: T[],
|
|
63
|
-
getSelector: (item: T) => string,
|
|
64
|
-
) {
|
|
61
|
+
export function arrayToMapWithGetter<T>(arr: T[], getSelector: (item: T) => string) {
|
|
65
62
|
return arr.reduce((accum, curr) => {
|
|
66
63
|
const _key = getSelector(curr);
|
|
67
64
|
accum[_key] = curr;
|
package/src/shared/regex.ts
CHANGED
|
@@ -72,3 +72,14 @@ export function getFileExtension(filePath: string) {
|
|
|
72
72
|
if (idx === -1) return '';
|
|
73
73
|
return filePath.slice(idx - filePath.length).toLowerCase();
|
|
74
74
|
}
|
|
75
|
+
export function normalizeFileName(fileName: string, extension: string) {
|
|
76
|
+
if (fileName.indexOf(extension) > -1) {
|
|
77
|
+
return fileName;
|
|
78
|
+
} else {
|
|
79
|
+
if (extension.indexOf('.') === 0) {
|
|
80
|
+
return `${fileName}${extension}`;
|
|
81
|
+
} else {
|
|
82
|
+
return `${fileName}.${extension}`;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -2,7 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-empty-interface */
|
|
4
4
|
import type React from 'react';
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
import type SendbirdChat from '@sendbird/chat';
|
|
7
|
+
import type { BaseChannel, SendbirdError as SBError, User, UserUpdateParams } from '@sendbird/chat';
|
|
8
|
+
import type {
|
|
9
|
+
GroupChannel,
|
|
10
|
+
GroupChannelCollection,
|
|
11
|
+
GroupChannelCreateParams,
|
|
12
|
+
GroupChannelListQuery,
|
|
13
|
+
GroupChannelModule,
|
|
14
|
+
GroupChannelUpdateParams,
|
|
15
|
+
Member,
|
|
16
|
+
MessageCollection,
|
|
17
|
+
} from '@sendbird/chat/groupChannel';
|
|
18
|
+
import type { ModuleNamespaces, SendableMessage } from '@sendbird/chat/lib/__definition';
|
|
19
|
+
import type {
|
|
20
|
+
AdminMessage,
|
|
21
|
+
BaseMessage,
|
|
22
|
+
FileMessage,
|
|
23
|
+
FileMessageCreateParams,
|
|
24
|
+
FileMessageUpdateParams,
|
|
25
|
+
PreviousMessageListQuery,
|
|
26
|
+
UserMessage,
|
|
27
|
+
UserMessageCreateParams,
|
|
28
|
+
UserMessageUpdateParams,
|
|
29
|
+
} from '@sendbird/chat/message';
|
|
30
|
+
import type { OpenChannel, OpenChannelModule } from '@sendbird/chat/openChannel';
|
|
31
|
+
|
|
32
|
+
import './';
|
|
6
33
|
|
|
7
34
|
export type FilterByValueType<T extends object, Type> = {
|
|
8
35
|
[K in keyof T as T[K] extends Type ? K : never]: T[K];
|
|
@@ -30,29 +57,33 @@ export type Optional<T> = T | undefined;
|
|
|
30
57
|
|
|
31
58
|
export type ContextValue<T extends React.Context<any>> = T extends React.Context<infer V> ? V : never;
|
|
32
59
|
|
|
33
|
-
|
|
34
|
-
export type
|
|
35
|
-
export type
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
export type
|
|
41
|
-
export type
|
|
42
|
-
export type
|
|
43
|
-
export type
|
|
44
|
-
export type
|
|
45
|
-
export type
|
|
46
|
-
export type
|
|
47
|
-
export type
|
|
48
|
-
export type
|
|
49
|
-
export type
|
|
50
|
-
export type
|
|
51
|
-
export type
|
|
52
|
-
export type
|
|
53
|
-
|
|
54
|
-
export type SendbirdGroupChannelCollection =
|
|
55
|
-
export type
|
|
60
|
+
export type SendbirdChatSDK = SendbirdChat & ModuleNamespaces<[GroupChannelModule, OpenChannelModule]>;
|
|
61
|
+
export type SendbirdMessage = BaseMessage | FileMessage | UserMessage | AdminMessage | SendableMessage;
|
|
62
|
+
export type SendbirdChannel = BaseChannel | GroupChannel | OpenChannel;
|
|
63
|
+
export type SendbirdUserMessage = UserMessage;
|
|
64
|
+
export type SendbirdFileMessage = FileMessage;
|
|
65
|
+
export type SendbirdAdminMessage = AdminMessage;
|
|
66
|
+
export type SendbirdBaseMessage = BaseMessage;
|
|
67
|
+
export type SendbirdSendableMessage = SendableMessage;
|
|
68
|
+
export type SendbirdFileMessageCreateParams = FileMessageCreateParams;
|
|
69
|
+
export type SendbirdFileMessageUpdateParams = FileMessageUpdateParams;
|
|
70
|
+
export type SendbirdUserMessageCreateParams = UserMessageCreateParams;
|
|
71
|
+
export type SendbirdUserMessageUpdateParams = UserMessageUpdateParams;
|
|
72
|
+
export type SendbirdGroupChannelCreateParams = GroupChannelCreateParams;
|
|
73
|
+
export type SendbirdGroupChannelUpdateParams = GroupChannelUpdateParams;
|
|
74
|
+
export type SendbirdUserUpdateParams = UserUpdateParams;
|
|
75
|
+
export type SendbirdUser = User;
|
|
76
|
+
export type SendbirdMember = Member;
|
|
77
|
+
export type SendbirdGroupChannel = GroupChannel;
|
|
78
|
+
export type SendbirdBaseChannel = BaseChannel;
|
|
79
|
+
export type SendbirdOpenChannel = OpenChannel;
|
|
80
|
+
|
|
81
|
+
export type SendbirdGroupChannelCollection = GroupChannelCollection;
|
|
82
|
+
export type SendbirdGroupChannelListQuery = GroupChannelListQuery;
|
|
83
|
+
export type SendbirdMessageCollection = MessageCollection;
|
|
84
|
+
export type SendbirdPreviousMessageListQuery = PreviousMessageListQuery;
|
|
85
|
+
|
|
86
|
+
export type SendbirdError = SBError;
|
|
56
87
|
|
|
57
88
|
export interface SendbirdDataPayload {
|
|
58
89
|
app_id: string;
|
|
@@ -43,5 +43,13 @@ export const getGroupChannelLastMessage = (channel: SendbirdGroupChannel, EMPTY_
|
|
|
43
43
|
return truncate(message.name, { maxLen: MAX_LEN });
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
if (message.isUserMessage()) {
|
|
47
|
+
return message.message ?? EMPTY_MESSAGE;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (message.isAdminMessage()) {
|
|
51
|
+
return message.message ?? EMPTY_MESSAGE;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return EMPTY_MESSAGE;
|
|
47
55
|
};
|