@sendbird/uikit-utils 2.4.1 → 2.5.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/README.md +1 -1
- package/lib/commonjs/hooks/index.js +12 -31
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/react-native.js +2 -11
- package/lib/commonjs/hooks/react-native.js.map +1 -1
- package/lib/commonjs/index.js +16 -45
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/sendbird/attrs.js +8 -11
- package/lib/commonjs/sendbird/attrs.js.map +1 -1
- package/lib/commonjs/sendbird/channel.js +0 -16
- package/lib/commonjs/sendbird/channel.js.map +1 -1
- package/lib/commonjs/sendbird/message.js +13 -34
- package/lib/commonjs/sendbird/message.js.map +1 -1
- package/lib/commonjs/sendbird/user.js +0 -2
- package/lib/commonjs/sendbird/user.js.map +1 -1
- package/lib/commonjs/shared/arrayToMap.js +0 -6
- package/lib/commonjs/shared/arrayToMap.js.map +1 -1
- package/lib/commonjs/shared/bufferedRequest.js +5 -26
- package/lib/commonjs/shared/bufferedRequest.js.map +1 -1
- package/lib/commonjs/shared/file.js +11 -28
- package/lib/commonjs/shared/file.js.map +1 -1
- package/lib/commonjs/shared/index.js +3 -7
- package/lib/commonjs/shared/index.js.map +1 -1
- package/lib/commonjs/shared/logger.js +3 -22
- package/lib/commonjs/shared/logger.js.map +1 -1
- package/lib/commonjs/shared/regex.js +2 -9
- package/lib/commonjs/shared/regex.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/ui-format/common.js +62 -18
- package/lib/commonjs/ui-format/common.js.map +1 -1
- package/lib/commonjs/ui-format/groupChannel.js +2 -48
- package/lib/commonjs/ui-format/groupChannel.js.map +1 -1
- package/lib/commonjs/ui-format/openChannel.js +0 -4
- package/lib/commonjs/ui-format/openChannel.js.map +1 -1
- package/lib/module/hooks/index.js +10 -7
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/react-native.js +2 -2
- package/lib/module/hooks/react-native.js.map +1 -1
- package/lib/module/index.js +5 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/sendbird/attrs.js +6 -9
- package/lib/module/sendbird/attrs.js.map +1 -1
- package/lib/module/sendbird/channel.js +0 -1
- package/lib/module/sendbird/channel.js.map +1 -1
- package/lib/module/sendbird/message.js +12 -17
- package/lib/module/sendbird/message.js.map +1 -1
- package/lib/module/sendbird/user.js.map +1 -1
- package/lib/module/shared/arrayToMap.js +0 -4
- package/lib/module/shared/arrayToMap.js.map +1 -1
- package/lib/module/shared/bufferedRequest.js +5 -24
- package/lib/module/shared/bufferedRequest.js.map +1 -1
- package/lib/module/shared/file.js +11 -16
- package/lib/module/shared/file.js.map +1 -1
- package/lib/module/shared/index.js +3 -3
- package/lib/module/shared/index.js.map +1 -1
- package/lib/module/shared/logger.js +3 -21
- package/lib/module/shared/logger.js.map +1 -1
- package/lib/module/shared/regex.js +3 -2
- package/lib/module/shared/regex.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/module/ui-format/common.js +60 -10
- package/lib/module/ui-format/common.js.map +1 -1
- package/lib/module/ui-format/groupChannel.js +3 -41
- package/lib/module/ui-format/groupChannel.js.map +1 -1
- package/lib/module/ui-format/openChannel.js.map +1 -1
- package/lib/typescript/src/hooks/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts +5 -4
- package/lib/typescript/src/sendbird/message.d.ts +8 -1
- package/lib/typescript/src/types.d.ts +2 -1
- package/lib/typescript/src/ui-format/common.d.ts +13 -0
- package/lib/typescript/src/ui-format/groupChannel.d.ts +1 -1
- package/package.json +11 -8
- package/src/hooks/index.ts +10 -0
- package/src/index.ts +5 -52
- package/src/sendbird/message.ts +12 -0
- package/src/types.ts +2 -0
- package/src/ui-format/common.ts +53 -1
- package/src/ui-format/groupChannel.ts +4 -30
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["EXTENSION_MIME_MAP","imageExtRegex","audioExtRegex","videoExtRegex","getFileType","extOrType","indexOf","type","split","match","getDownscaleSize","origin","resizing","ratio","maxWidth","width","maxHeight","height","Math","min","normalizeFileName","fileName","extension","_extension","toLowerCase","_filename","hasExtension","lastIndexOf","length","parseMimeType","mimeType","fullType","parts","subtype","parameters","part","name","value","trim","getFileExtensionFromMime","MIME_EXTENSION_MAP","Object","entries","reduce","acc","key","getMimeFromFileExtension","ext","getFileExtension","filePath","pathWithoutParams","idx","result","slice","getFileExtensionFromUri","uri","fetch","then","response","headers","get","isImage","shouldCompressImage","mime","compressionEnabled","Boolean"],"sources":["file.ts"],"sourcesContent":["const EXTENSION_MIME_MAP = {\n // Image\n 'jpeg': 'image/jpeg',\n 'jpg': 'image/jpeg',\n 'png': 'image/png',\n 'gif': 'image/gif',\n 'webp': 'image/webp',\n 'svg': 'image/svg+xml',\n\n // Video\n '3gp': 'video/3gpp',\n 'mp4': 'video/mp4',\n 'mpeg': 'video/mpeg',\n 'ogv': 'video/ogg',\n 'video/quicktime': 'mov',\n 'webm': 'video/webm',\n 'avi': 'video/x-msvideo',\n\n // Audio\n 'aac': 'audio/aac',\n 'mid': 'audio/midi',\n 'mp3': 'audio/mpeg',\n 'ogg': 'audio/ogg',\n 'wav': 'audio/wav',\n 'weba': 'audio/webm',\n\n // Files\n 'txt': 'text/plain',\n 'pdf': 'application/pdf',\n 'doc': 'application/msword',\n 'docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n 'xls': 'application/vnd.ms-excel',\n 'xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n 'ppt': 'application/vnd.ms-powerpoint',\n 'pptx': 'application/vnd.openxmlformats-officedocument.presentationml.presentation',\n 'zip': 'application/zip',\n 'json': 'application/json',\n 'gzip': 'application/x-gzip',\n} as Record<string, string>;\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};\n\n/**\n * Calculates the downscaled size of an image while preserving its aspect ratio.\n *\n * @param {Object} origin - The original size object with `width` and `height` properties.\n * @param {Object} resizing - The resizing object with optional `width` and `height` properties.\n * @returns {Object} - A new size object with the downscaled `width` and `height` properties.\n * @example\n * ```ts\n * getDownscaleSize({ width: 1200, height: 800 }, { width: 600 }); // returns { width: 600, height: 400 }\n * ```\n */\ntype Size = { width: number; height: number };\nexport function getDownscaleSize(origin: Size, resizing: Partial<Size>) {\n let ratio: number;\n\n const maxWidth = resizing.width || origin.width,\n maxHeight = resizing.height || origin.height;\n\n if (origin.width <= maxWidth && origin.height <= maxHeight) {\n ratio = 1;\n } else if (origin.width > maxWidth && origin.height <= maxHeight) {\n ratio = maxWidth / origin.width;\n } else if (origin.width <= maxWidth && origin.height > maxHeight) {\n ratio = maxHeight / origin.height;\n } else {\n ratio = Math.min(maxWidth / origin.width, maxHeight / origin.height);\n }\n\n return { width: origin.width * ratio, height: origin.height * ratio };\n}\n\n/**\n * Normalize a file name by ensuring it has the given extension, if it doesn't already.\n *\n * @param {string} fileName - The file name to normalize.\n * @param {string} extension - The desired extension, without a leading period.\n * @returns {string} - The normalized file name, with the extension.\n */\nexport function normalizeFileName(fileName: string, extension: string) {\n if (!extension) return fileName;\n\n // .extension\n let _extension = extension.toLowerCase();\n if (_extension.indexOf('.') !== 0) {\n _extension = '.' + _extension;\n }\n\n // filename.extension | filename\n const _filename = fileName.toLowerCase();\n const hasExtension = _filename.lastIndexOf(_extension) === _filename.length - _extension.length;\n if (!hasExtension) {\n // filename.extension\n return fileName + _extension;\n } else {\n // filename.extension\n return fileName;\n }\n}\n\n/**\n * Parses a MIME type string into its components.\n *\n * @param mimeType - The MIME type string to parse.\n * @returns An object containing the type, subtype, and parameters of the MIME type.\n */\ntype MimeType = { type: string; subtype: string; parameters: Record<string, string> };\nexport function parseMimeType(mimeType: string): MimeType {\n const [fullType, ...parts] = mimeType.split(';');\n const [type, subtype] = fullType.split('/');\n const parameters: MimeType['parameters'] = {};\n\n for (const part of parts) {\n const [name, value] = part.trim().split('=');\n parameters[name] = value;\n }\n\n return { type, subtype, parameters };\n}\n\n/**\n * Returns the file extension based on the MIME type.\n *\n * @param {string | null | undefined} mimeType - The MIME type to look up.\n * @returns {string} - The file extension for the given MIME type, or an empty string if no matching file extension was found.\n */\nexport function getFileExtensionFromMime(mimeType?: string | null): string {\n if (!mimeType) return '';\n const MIME_EXTENSION_MAP = Object.entries(EXTENSION_MIME_MAP).reduce((acc, [key, value]) => {\n acc[value] = key;\n return acc;\n }, {} as Record<string, string>);\n return MIME_EXTENSION_MAP[mimeType.toLowerCase()] || '';\n}\n\n/**\n * Returns the MIME type based on the file extension.\n *\n * @param {string | null | undefined} ext - The file extension to look up.\n * @returns {string} - The MIME type for the given file extension, or an empty string if no matching MIME type was found.\n */\nexport function getMimeFromFileExtension(ext?: string | null) {\n if (!ext) return '';\n return EXTENSION_MIME_MAP[ext.toLowerCase()] || '';\n}\n\n/**\n * Returns the file extension of a file path.\n *\n * @param {string} filePath - The file path to extract the extension from.\n * @returns {string} - The file extension, or an empty string if the file path does not have an extension.\n */\nexport function getFileExtension(filePath: string) {\n const pathWithoutParams = filePath.split('?')[0];\n\n const idx = pathWithoutParams.lastIndexOf('.');\n if (idx === -1) return '';\n\n const result = pathWithoutParams.slice(idx - pathWithoutParams.length).toLowerCase();\n if (result === '.') return '';\n else return result;\n}\n\nexport function getFileExtensionFromUri(uri: string) {\n return fetch(uri).then((response) => response.headers.get('content-type'));\n}\n\nexport function isImage(filePath: string, mimeType?: string) {\n const type = getFileType(mimeType || getFileExtension(filePath));\n return type === 'image';\n}\n\nexport function shouldCompressImage(mime: string, compressionEnabled = true) {\n const extension = getFileExtensionFromMime(mime);\n return Boolean(extension.match(/jpg|jpeg|png/i) && compressionEnabled);\n}\n"],"mappings":"AAAA,MAAMA,kBAAkB,GAAG;EACzB;EACA,QAAQ,YAFiB;EAGzB,OAAO,YAHkB;EAIzB,OAAO,WAJkB;EAKzB,OAAO,WALkB;EAMzB,QAAQ,YANiB;EAOzB,OAAO,eAPkB;EASzB;EACA,OAAO,YAVkB;EAWzB,OAAO,WAXkB;EAYzB,QAAQ,YAZiB;EAazB,OAAO,WAbkB;EAczB,mBAAmB,KAdM;EAezB,QAAQ,YAfiB;EAgBzB,OAAO,iBAhBkB;EAkBzB;EACA,OAAO,WAnBkB;EAoBzB,OAAO,YApBkB;EAqBzB,OAAO,YArBkB;EAsBzB,OAAO,WAtBkB;EAuBzB,OAAO,WAvBkB;EAwBzB,QAAQ,YAxBiB;EA0BzB;EACA,OAAO,YA3BkB;EA4BzB,OAAO,iBA5BkB;EA6BzB,OAAO,oBA7BkB;EA8BzB,QAAQ,yEA9BiB;EA+BzB,OAAO,0BA/BkB;EAgCzB,QAAQ,mEAhCiB;EAiCzB,OAAO,+BAjCkB;EAkCzB,QAAQ,2EAlCiB;EAmCzB,OAAO,iBAnCkB;EAoCzB,QAAQ,kBApCiB;EAqCzB,QAAQ;AArCiB,CAA3B;AAwCA,OAAO,MAAMC,aAAa,GAAG,wBAAtB;AACP,OAAO,MAAMC,aAAa,GAAG,iEAAtB;AACP,OAAO,MAAMC,aAAa,GAAG,kBAAtB;AACP,OAAO,MAAMC,WAAW,GAAIC,SAAD,IAAuB;EAChD,IAAIA,SAAS,CAACC,OAAV,CAAkB,GAAlB,IAAyB,CAAC,CAA9B,EAAiC;IAC/B,MAAMC,IAAI,GAAGF,SAAS,CAACG,KAAV,CAAgB,GAAhB,EAAqB,CAArB,CAAb;IACA,IAA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AO,EAAP,CAApB,KACK,OAAOA,MAAP;AACN;AAED,OAAO,SAASE,uBAAT,CAAiCC,GAAjC,EAA8C;EACnD,OAAOC,KAAK,CAACD,GAAD,CAAL,CAAWE,IAAX,CAAiBC,QAAD,IAAcA,QAAQ,CAACC,OAAT,CAAiBC,GAAjB,CAAqB,cAArB,CAA9B,CAAP;AACD;AAED,OAAO,SAASC,OAAT,CAAiBZ,QAAjB,EAAmCnB,QAAnC,EAAsD;EAC3D,MAAMvB,IAAI,GAAGH,WAAW,CAAC0B,QAAQ,IAAIkB,gBAAgB,CAACC,QAAD,CAA7B,CAAxB;EACA,OAAO1C,IAAI,KAAK,OAAhB;AACD;AAED,OAAO,SAASuD,mBAAT,CAA6BC,IAA7B,EAAsE;EAAA,IAA3BC,kBAA2B,uEAAN,IAAM;EAC3E,MAAM1C,SAAS,GAAGiB,wBAAwB,CAACwB,IAAD,CAA1C;EACA,OAAOE,OAAO,CAAC3C,SAAS,CAACb,KAAV,CAAgB,eAAhB,KAAoCuD,kBAArC,CAAd;AACD"}
|
|
1
|
+
{"version":3,"names":["EXTENSION_MIME_MAP","imageExtRegex","audioExtRegex","videoExtRegex","getFileType","extOrType","indexOf","type","split","match","getDownscaleSize","origin","resizing","ratio","maxWidth","width","maxHeight","height","Math","min","normalizeFileName","fileName","extension","_extension","toLowerCase","_filename","hasExtension","lastIndexOf","length","parseMimeType","mimeType","fullType","parts","subtype","parameters","part","name","value","trim","getFileExtensionFromMime","MIME_EXTENSION_MAP","Object","entries","reduce","acc","_ref","key","getMimeFromFileExtension","ext","getFileExtension","filePath","pathWithoutParams","idx","result","slice","getFileExtensionFromUri","uri","fetch","then","response","headers","get","isImage","shouldCompressImage","mime","compressionEnabled","arguments","undefined","Boolean"],"sources":["file.ts"],"sourcesContent":["const EXTENSION_MIME_MAP = {\n // Image\n 'jpeg': 'image/jpeg',\n 'jpg': 'image/jpeg',\n 'png': 'image/png',\n 'gif': 'image/gif',\n 'webp': 'image/webp',\n 'svg': 'image/svg+xml',\n\n // Video\n '3gp': 'video/3gpp',\n 'mp4': 'video/mp4',\n 'mpeg': 'video/mpeg',\n 'ogv': 'video/ogg',\n 'video/quicktime': 'mov',\n 'webm': 'video/webm',\n 'avi': 'video/x-msvideo',\n\n // Audio\n 'aac': 'audio/aac',\n 'mid': 'audio/midi',\n 'mp3': 'audio/mpeg',\n 'ogg': 'audio/ogg',\n 'wav': 'audio/wav',\n 'weba': 'audio/webm',\n\n // Files\n 'txt': 'text/plain',\n 'pdf': 'application/pdf',\n 'doc': 'application/msword',\n 'docx': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\n 'xls': 'application/vnd.ms-excel',\n 'xlsx': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n 'ppt': 'application/vnd.ms-powerpoint',\n 'pptx': 'application/vnd.openxmlformats-officedocument.presentationml.presentation',\n 'zip': 'application/zip',\n 'json': 'application/json',\n 'gzip': 'application/x-gzip',\n} as Record<string, string>;\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};\n\n/**\n * Calculates the downscaled size of an image while preserving its aspect ratio.\n *\n * @param {Object} origin - The original size object with `width` and `height` properties.\n * @param {Object} resizing - The resizing object with optional `width` and `height` properties.\n * @returns {Object} - A new size object with the downscaled `width` and `height` properties.\n * @example\n * ```ts\n * getDownscaleSize({ width: 1200, height: 800 }, { width: 600 }); // returns { width: 600, height: 400 }\n * ```\n */\ntype Size = { width: number; height: number };\nexport function getDownscaleSize(origin: Size, resizing: Partial<Size>) {\n let ratio: number;\n\n const maxWidth = resizing.width || origin.width,\n maxHeight = resizing.height || origin.height;\n\n if (origin.width <= maxWidth && origin.height <= maxHeight) {\n ratio = 1;\n } else if (origin.width > maxWidth && origin.height <= maxHeight) {\n ratio = maxWidth / origin.width;\n } else if (origin.width <= maxWidth && origin.height > maxHeight) {\n ratio = maxHeight / origin.height;\n } else {\n ratio = Math.min(maxWidth / origin.width, maxHeight / origin.height);\n }\n\n return { width: origin.width * ratio, height: origin.height * ratio };\n}\n\n/**\n * Normalize a file name by ensuring it has the given extension, if it doesn't already.\n *\n * @param {string} fileName - The file name to normalize.\n * @param {string} extension - The desired extension, without a leading period.\n * @returns {string} - The normalized file name, with the extension.\n */\nexport function normalizeFileName(fileName: string, extension: string) {\n if (!extension) return fileName;\n\n // .extension\n let _extension = extension.toLowerCase();\n if (_extension.indexOf('.') !== 0) {\n _extension = '.' + _extension;\n }\n\n // filename.extension | filename\n const _filename = fileName.toLowerCase();\n const hasExtension = _filename.lastIndexOf(_extension) === _filename.length - _extension.length;\n if (!hasExtension) {\n // filename.extension\n return fileName + _extension;\n } else {\n // filename.extension\n return fileName;\n }\n}\n\n/**\n * Parses a MIME type string into its components.\n *\n * @param mimeType - The MIME type string to parse.\n * @returns An object containing the type, subtype, and parameters of the MIME type.\n */\ntype MimeType = { type: string; subtype: string; parameters: Record<string, string> };\nexport function parseMimeType(mimeType: string): MimeType {\n const [fullType, ...parts] = mimeType.split(';');\n const [type, subtype] = fullType.split('/');\n const parameters: MimeType['parameters'] = {};\n\n for (const part of parts) {\n const [name, value] = part.trim().split('=');\n parameters[name] = value;\n }\n\n return { type, subtype, parameters };\n}\n\n/**\n * Returns the file extension based on the MIME type.\n *\n * @param {string | null | undefined} mimeType - The MIME type to look up.\n * @returns {string} - The file extension for the given MIME type, or an empty string if no matching file extension was found.\n */\nexport function getFileExtensionFromMime(mimeType?: string | null): string {\n if (!mimeType) return '';\n const MIME_EXTENSION_MAP = Object.entries(EXTENSION_MIME_MAP).reduce((acc, [key, value]) => {\n acc[value] = key;\n return acc;\n }, {} as Record<string, string>);\n return MIME_EXTENSION_MAP[mimeType.toLowerCase()] || '';\n}\n\n/**\n * Returns the MIME type based on the file extension.\n *\n * @param {string | null | undefined} ext - The file extension to look up.\n * @returns {string} - The MIME type for the given file extension, or an empty string if no matching MIME type was found.\n */\nexport function getMimeFromFileExtension(ext?: string | null) {\n if (!ext) return '';\n return EXTENSION_MIME_MAP[ext.toLowerCase()] || '';\n}\n\n/**\n * Returns the file extension of a file path.\n *\n * @param {string} filePath - The file path to extract the extension from.\n * @returns {string} - The file extension, or an empty string if the file path does not have an extension.\n */\nexport function getFileExtension(filePath: string) {\n const pathWithoutParams = filePath.split('?')[0];\n\n const idx = pathWithoutParams.lastIndexOf('.');\n if (idx === -1) return '';\n\n const result = pathWithoutParams.slice(idx - pathWithoutParams.length).toLowerCase();\n if (result === '.') return '';\n else return result;\n}\n\nexport function getFileExtensionFromUri(uri: string) {\n return fetch(uri).then((response) => response.headers.get('content-type'));\n}\n\nexport function isImage(filePath: string, mimeType?: string) {\n const type = getFileType(mimeType || getFileExtension(filePath));\n return type === 'image';\n}\n\nexport function shouldCompressImage(mime: string, compressionEnabled = true) {\n const extension = getFileExtensionFromMime(mime);\n return Boolean(extension.match(/jpg|jpeg|png/i) && compressionEnabled);\n}\n"],"mappings":"AAAA,MAAMA,kBAAkB,GAAG;EACzB;EACA,MAAM,EAAE,YAAY;EACpB,KAAK,EAAE,YAAY;EACnB,KAAK,EAAE,WAAW;EAClB,KAAK,EAAE,WAAW;EAClB,MAAM,EAAE,YAAY;EACpB,KAAK,EAAE,eAAe;EAEtB;EACA,KAAK,EAAE,YAAY;EACnB,KAAK,EAAE,WAAW;EAClB,MAAM,EAAE,YAAY;EACpB,KAAK,EAAE,WAAW;EAClB,iBAAiB,EAAE,KAAK;EACxB,MAAM,EAAE,YAAY;EAC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AACC,IAAY,EAA6B;EAAA,IAA3BC,kBAAkB,GAAAC,SAAA,CAAAtC,MAAA,QAAAsC,SAAA,QAAAC,SAAA,GAAAD,SAAA,MAAG,IAAI;EACzE,MAAM5C,SAAS,GAAGiB,wBAAwB,CAACyB,IAAI,CAAC;EAChD,OAAOI,OAAO,CAAC9C,SAAS,CAACb,KAAK,CAAC,eAAe,CAAC,IAAIwD,kBAAkB,CAAC;AACxE"}
|
|
@@ -4,21 +4,22 @@
|
|
|
4
4
|
export function hash(str) {
|
|
5
5
|
return String(Math.abs(str.split('').reduce((a, c) => (a << 5) - a + c.charCodeAt(0) | 0, 0)));
|
|
6
6
|
}
|
|
7
|
+
|
|
7
8
|
/**
|
|
8
9
|
* Replace a specific range of text in the string with another text.
|
|
9
10
|
* */
|
|
10
|
-
|
|
11
11
|
export function replace(str, start, end, text) {
|
|
12
12
|
return str.slice(0, start) + text + str.slice(end);
|
|
13
13
|
}
|
|
14
|
+
|
|
14
15
|
/**
|
|
15
16
|
* Returns the value corresponding to the first true index of a given condition array.
|
|
16
17
|
* */
|
|
17
|
-
|
|
18
18
|
export function conditionChaining(conditions, values) {
|
|
19
19
|
const idx = conditions.findIndex(state => Boolean(state));
|
|
20
20
|
return idx > -1 ? values[idx] : values[values.length - 1];
|
|
21
21
|
}
|
|
22
|
+
|
|
22
23
|
/**
|
|
23
24
|
* Returns a new object with only the specified keys from the input object.
|
|
24
25
|
*
|
|
@@ -30,7 +31,6 @@ export function conditionChaining(conditions, values) {
|
|
|
30
31
|
* pick({ a: 1, b: '2', c: true }, ['a', 'c']); // returns { a: 1, c: true }
|
|
31
32
|
* ```
|
|
32
33
|
*/
|
|
33
|
-
|
|
34
34
|
export function pick(obj, keys) {
|
|
35
35
|
return keys.reduce((pickedObj, key) => {
|
|
36
36
|
pickedObj[key] = obj[key];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["hash","str","String","Math","abs","split","reduce","a","c","charCodeAt","replace","start","end","text","slice","conditionChaining","conditions","values","idx","findIndex","state","Boolean","length","pick","obj","keys","pickedObj","key"],"sources":["index.ts"],"sourcesContent":["/**\n * Converts a given string to a hashed string.\n * */\nexport function hash(str: string) {\n return String(Math.abs(str.split('').reduce((a, c) => ((a << 5) - a + c.charCodeAt(0)) | 0, 0)));\n}\n\n/**\n * Replace a specific range of text in the string with another text.\n * */\nexport function replace(str: string, start: number, end: number, text: string) {\n return str.slice(0, start) + text + str.slice(end);\n}\n\n/**\n * Returns the value corresponding to the first true index of a given condition array.\n * */\nexport function conditionChaining<T, V>(conditions: T[], values: V[]) {\n const idx = conditions.findIndex((state) => Boolean(state));\n return idx > -1 ? values[idx] : values[values.length - 1];\n}\n\n/**\n * Returns a new object with only the specified keys from the input object.\n *\n * @param {Object} obj - The input object to pick keys from.\n * @param {Array<string>} keys - An array of keys to pick from the input object.\n * @returns {Object} - A new object containing only the specified keys from the input object.\n * @example\n * ```ts\n * pick({ a: 1, b: '2', c: true }, ['a', 'c']); // returns { a: 1, c: true }\n * ```\n */\nexport function pick<T extends { [key: string]: unknown }, Keys extends keyof T>(obj: T, keys: Keys[]) {\n return keys.reduce((pickedObj, key) => {\n pickedObj[key] = obj[key];\n return pickedObj;\n }, {} as { [key in Keys]: T[key] });\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,SAASA,
|
|
1
|
+
{"version":3,"names":["hash","str","String","Math","abs","split","reduce","a","c","charCodeAt","replace","start","end","text","slice","conditionChaining","conditions","values","idx","findIndex","state","Boolean","length","pick","obj","keys","pickedObj","key"],"sources":["index.ts"],"sourcesContent":["/**\n * Converts a given string to a hashed string.\n * */\nexport function hash(str: string) {\n return String(Math.abs(str.split('').reduce((a, c) => ((a << 5) - a + c.charCodeAt(0)) | 0, 0)));\n}\n\n/**\n * Replace a specific range of text in the string with another text.\n * */\nexport function replace(str: string, start: number, end: number, text: string) {\n return str.slice(0, start) + text + str.slice(end);\n}\n\n/**\n * Returns the value corresponding to the first true index of a given condition array.\n * */\nexport function conditionChaining<T, V>(conditions: T[], values: V[]) {\n const idx = conditions.findIndex((state) => Boolean(state));\n return idx > -1 ? values[idx] : values[values.length - 1];\n}\n\n/**\n * Returns a new object with only the specified keys from the input object.\n *\n * @param {Object} obj - The input object to pick keys from.\n * @param {Array<string>} keys - An array of keys to pick from the input object.\n * @returns {Object} - A new object containing only the specified keys from the input object.\n * @example\n * ```ts\n * pick({ a: 1, b: '2', c: true }, ['a', 'c']); // returns { a: 1, c: true }\n * ```\n */\nexport function pick<T extends { [key: string]: unknown }, Keys extends keyof T>(obj: T, keys: Keys[]) {\n return keys.reduce((pickedObj, key) => {\n pickedObj[key] = obj[key];\n return pickedObj;\n }, {} as { [key in Keys]: T[key] });\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,SAASA,IAAIA,CAACC,GAAW,EAAE;EAChC,OAAOC,MAAM,CAACC,IAAI,CAACC,GAAG,CAACH,GAAG,CAACI,KAAK,CAAC,EAAE,CAAC,CAACC,MAAM,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAM,CAACD,CAAC,IAAI,CAAC,IAAIA,CAAC,GAAGC,CAAC,CAACC,UAAU,CAAC,CAAC,CAAC,GAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAClG;;AAEA;AACA;AACA;AACA,OAAO,SAASC,OAAOA,CAACT,GAAW,EAAEU,KAAa,EAAEC,GAAW,EAAEC,IAAY,EAAE;EAC7E,OAAOZ,GAAG,CAACa,KAAK,CAAC,CAAC,EAAEH,KAAK,CAAC,GAAGE,IAAI,GAAGZ,GAAG,CAACa,KAAK,CAACF,GAAG,CAAC;AACpD;;AAEA;AACA;AACA;AACA,OAAO,SAASG,iBAAiBA,CAAOC,UAAe,EAAEC,MAAW,EAAE;EACpE,MAAMC,GAAG,GAAGF,UAAU,CAACG,SAAS,CAAEC,KAAK,IAAKC,OAAO,CAACD,KAAK,CAAC,CAAC;EAC3D,OAAOF,GAAG,GAAG,CAAC,CAAC,GAAGD,MAAM,CAACC,GAAG,CAAC,GAAGD,MAAM,CAACA,MAAM,CAACK,MAAM,GAAG,CAAC,CAAC;AAC3D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,IAAIA,CAA6DC,GAAM,EAAEC,IAAY,EAAE;EACrG,OAAOA,IAAI,CAACnB,MAAM,CAAC,CAACoB,SAAS,EAAEC,GAAG,KAAK;IACrCD,SAAS,CAACC,GAAG,CAAC,GAAGH,GAAG,CAACG,GAAG,CAAC;IACzB,OAAOD,SAAS;EAClB,CAAC,EAAE,CAAC,CAAC,CAA8B;AACrC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
+
|
|
2
3
|
const LogLevelEnum = {
|
|
3
4
|
'none': 0,
|
|
4
5
|
'log': 1,
|
|
@@ -7,7 +8,6 @@ const LogLevelEnum = {
|
|
|
7
8
|
'info': 4,
|
|
8
9
|
'debug': 5
|
|
9
10
|
};
|
|
10
|
-
|
|
11
11
|
const createLogger = function () {
|
|
12
12
|
let level = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'warn';
|
|
13
13
|
let _logLevel = level;
|
|
@@ -16,74 +16,56 @@ const createLogger = function () {
|
|
|
16
16
|
setTitle(title) {
|
|
17
17
|
_title = title;
|
|
18
18
|
},
|
|
19
|
-
|
|
20
19
|
setLogLevel(lv) {
|
|
21
20
|
_logLevel = lv;
|
|
22
21
|
},
|
|
23
|
-
|
|
24
22
|
getLogLevel() {
|
|
25
23
|
return _logLevel;
|
|
26
24
|
},
|
|
27
|
-
|
|
28
25
|
log() {
|
|
29
26
|
if (LogLevelEnum[_logLevel] < LogLevelEnum.log) return LogLevelEnum.none;
|
|
30
|
-
|
|
31
27
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
32
28
|
args[_key] = arguments[_key];
|
|
33
29
|
}
|
|
34
|
-
|
|
35
30
|
console.log(_title, ...args);
|
|
36
31
|
return LogLevelEnum[_logLevel];
|
|
37
32
|
},
|
|
38
|
-
|
|
39
33
|
error() {
|
|
40
34
|
if (LogLevelEnum[_logLevel] < LogLevelEnum.error) return LogLevelEnum.none;
|
|
41
|
-
|
|
42
35
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
43
36
|
args[_key2] = arguments[_key2];
|
|
44
37
|
}
|
|
45
|
-
|
|
46
38
|
console.error(_title, ...args);
|
|
47
39
|
return LogLevelEnum[_logLevel];
|
|
48
40
|
},
|
|
49
|
-
|
|
50
41
|
warn() {
|
|
51
42
|
if (LogLevelEnum[_logLevel] < LogLevelEnum.warn) return LogLevelEnum.none;
|
|
52
|
-
|
|
53
43
|
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
54
44
|
args[_key3] = arguments[_key3];
|
|
55
45
|
}
|
|
56
|
-
|
|
57
46
|
console.warn(_title, ...args);
|
|
58
47
|
return LogLevelEnum[_logLevel];
|
|
59
48
|
},
|
|
60
|
-
|
|
61
49
|
info() {
|
|
62
50
|
if (LogLevelEnum[_logLevel] < LogLevelEnum.info) return LogLevelEnum.none;
|
|
63
|
-
|
|
64
51
|
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
65
52
|
args[_key4] = arguments[_key4];
|
|
66
53
|
}
|
|
67
|
-
|
|
68
54
|
console.info(_title, ...args);
|
|
69
55
|
return LogLevelEnum[_logLevel];
|
|
70
56
|
},
|
|
71
|
-
|
|
72
57
|
debug() {
|
|
73
58
|
if (LogLevelEnum[_logLevel] < LogLevelEnum.debug) return LogLevelEnum.none;
|
|
74
|
-
|
|
75
59
|
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
76
60
|
args[_key5] = arguments[_key5];
|
|
77
61
|
}
|
|
78
|
-
|
|
79
62
|
console.log(_title, ...args);
|
|
80
63
|
return LogLevelEnum[_logLevel];
|
|
81
64
|
}
|
|
82
|
-
|
|
83
65
|
};
|
|
84
66
|
};
|
|
85
|
-
|
|
86
|
-
|
|
67
|
+
export const Logger = {
|
|
68
|
+
...createLogger(),
|
|
87
69
|
LogLevelEnum,
|
|
88
70
|
create: createLogger
|
|
89
71
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["LogLevelEnum","createLogger","level","_logLevel","_title","setTitle","title","setLogLevel","lv","getLogLevel","log","none","args","console","error","warn","info","debug","Logger","create"],"sources":["logger.ts"],"sourcesContent":["/* eslint-disable no-console */\n\nconst LogLevelEnum = {\n 'none': 0,\n 'log': 1,\n 'error': 2,\n 'warn': 3,\n 'info': 4,\n 'debug': 5,\n};\ntype LogLevel = keyof typeof LogLevelEnum;\n\nconst createLogger = (level: LogLevel = 'warn') => {\n let _logLevel = level;\n let _title = '[UIKit]';\n\n return {\n setTitle(title: string) {\n _title = title;\n },\n setLogLevel(lv: LogLevel) {\n _logLevel = lv;\n },\n getLogLevel() {\n return _logLevel;\n },\n log(...args: unknown[]) {\n if (LogLevelEnum[_logLevel] < LogLevelEnum.log) return LogLevelEnum.none;\n console.log(_title, ...args);\n return LogLevelEnum[_logLevel];\n },\n error(...args: unknown[]) {\n if (LogLevelEnum[_logLevel] < LogLevelEnum.error) return LogLevelEnum.none;\n console.error(_title, ...args);\n return LogLevelEnum[_logLevel];\n },\n warn(...args: unknown[]) {\n if (LogLevelEnum[_logLevel] < LogLevelEnum.warn) return LogLevelEnum.none;\n console.warn(_title, ...args);\n return LogLevelEnum[_logLevel];\n },\n info(...args: unknown[]) {\n if (LogLevelEnum[_logLevel] < LogLevelEnum.info) return LogLevelEnum.none;\n console.info(_title, ...args);\n return LogLevelEnum[_logLevel];\n },\n debug(...args: unknown[]) {\n if (LogLevelEnum[_logLevel] < LogLevelEnum.debug) return LogLevelEnum.none;\n console.log(_title, ...args);\n return LogLevelEnum[_logLevel];\n },\n };\n};\n\nexport const Logger = {\n ...createLogger(),\n LogLevelEnum,\n create: createLogger,\n};\n"],"mappings":"AAAA
|
|
1
|
+
{"version":3,"names":["LogLevelEnum","createLogger","level","arguments","length","undefined","_logLevel","_title","setTitle","title","setLogLevel","lv","getLogLevel","log","none","_len","args","Array","_key","console","error","_len2","_key2","warn","_len3","_key3","info","_len4","_key4","debug","_len5","_key5","Logger","create"],"sources":["logger.ts"],"sourcesContent":["/* eslint-disable no-console */\n\nconst LogLevelEnum = {\n 'none': 0,\n 'log': 1,\n 'error': 2,\n 'warn': 3,\n 'info': 4,\n 'debug': 5,\n};\ntype LogLevel = keyof typeof LogLevelEnum;\n\nconst createLogger = (level: LogLevel = 'warn') => {\n let _logLevel = level;\n let _title = '[UIKit]';\n\n return {\n setTitle(title: string) {\n _title = title;\n },\n setLogLevel(lv: LogLevel) {\n _logLevel = lv;\n },\n getLogLevel() {\n return _logLevel;\n },\n log(...args: unknown[]) {\n if (LogLevelEnum[_logLevel] < LogLevelEnum.log) return LogLevelEnum.none;\n console.log(_title, ...args);\n return LogLevelEnum[_logLevel];\n },\n error(...args: unknown[]) {\n if (LogLevelEnum[_logLevel] < LogLevelEnum.error) return LogLevelEnum.none;\n console.error(_title, ...args);\n return LogLevelEnum[_logLevel];\n },\n warn(...args: unknown[]) {\n if (LogLevelEnum[_logLevel] < LogLevelEnum.warn) return LogLevelEnum.none;\n console.warn(_title, ...args);\n return LogLevelEnum[_logLevel];\n },\n info(...args: unknown[]) {\n if (LogLevelEnum[_logLevel] < LogLevelEnum.info) return LogLevelEnum.none;\n console.info(_title, ...args);\n return LogLevelEnum[_logLevel];\n },\n debug(...args: unknown[]) {\n if (LogLevelEnum[_logLevel] < LogLevelEnum.debug) return LogLevelEnum.none;\n console.log(_title, ...args);\n return LogLevelEnum[_logLevel];\n },\n };\n};\n\nexport const Logger = {\n ...createLogger(),\n LogLevelEnum,\n create: createLogger,\n};\n"],"mappings":"AAAA;;AAEA,MAAMA,YAAY,GAAG;EACnB,MAAM,EAAE,CA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,MAAA,EADpEY,IAAI,OAAAC,KAAA,CAAAa,KAAA,GAAAC,KAAA,MAAAA,KAAA,GAAAD,KAAA,EAAAC,KAAA;QAAJf,IAAI,CAAAe,KAAA,IAAA5B,SAAA,CAAA4B,KAAA;MAAA;MAEXZ,OAAO,CAACN,GAAG,CAACN,MAAM,EAAE,GAAGS,IAAI,CAAC;MAC5B,OAAOhB,YAAY,CAACM,SAAS,CAAC;IAChC;EACF,CAAC;AACH,CAAC;AAED,OAAO,MAAM0B,MAAM,GAAG;EACpB,GAAG/B,YAAY,EAAE;EACjBD,YAAY;EACZiC,MAAM,EAAEhC;AACV,CAAC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
// For iOS 12 backwards compatibility
|
|
2
2
|
require('string.prototype.matchall').shim();
|
|
3
|
-
|
|
4
3
|
export const urlRegexStrict = /(https?:\/\/|www\.)[-a-zA-Z0-9@:%._+~#=]{1,256}\.(xn--)?[a-z0-9-]{2,20}\b([-a-zA-Z0-9@:%_+[\],.~#?&/=]*[-a-zA-Z0-9@:%_+\]~#?&/=])*/g;
|
|
5
4
|
export const urlRegexRough = /(https?:\/\/|www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/g;
|
|
6
5
|
export const phoneRegex = /[+]?[(]?[0-9]{3}[)]?[-\s.]?[0-9]{3}[-\s.]?[0-9]{4,7}/;
|
|
7
6
|
export const emailRegex = /\S+@\S+\.\S+/;
|
|
8
7
|
export const newLineRegex = /\r\n|\r|\n/g;
|
|
9
|
-
export const createMentionTemplateRegex = trigger => new RegExp(`(${trigger}[{])(.*?)([}])`, 'g');
|
|
8
|
+
export const createMentionTemplateRegex = trigger => new RegExp(`(${trigger}[{])(.*?)([}])`, 'g');
|
|
9
|
+
|
|
10
|
+
// const cases = [
|
|
10
11
|
// {
|
|
11
12
|
// type: 'urlStrict',
|
|
12
13
|
// regex: urlRegexStrict,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["require","shim","urlRegexStrict","urlRegexRough","phoneRegex","emailRegex","newLineRegex","createMentionTemplateRegex","trigger","RegExp","replaceWithRegex","text","regex","replacer","keyPrefix","matches","matchAll","founds","map","value","start","index","end","length","groups","matchIndex","items","cursor","forEach","restText","pop","head","slice","mid","match","tail","push","replaceUrlAsComponents","originText","strict"],"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\nexport const createMentionTemplateRegex = (trigger: string) => new RegExp(`(${trigger}[{])(.*?)([}])`, '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 replaceWithRegex = <T>(\n text: string,\n regex: RegExp,\n replacer: (params: {\n match: string;\n groups: string[];\n matchIndex: number | undefined;\n index: number;\n keyPrefix: string;\n }) => T,\n keyPrefix: string,\n) => {\n const matches = [...text.matchAll(regex)];\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, groups: value, matchIndex: value.index };\n });\n\n const items: Array<T | string> = [text];\n let cursor = 0;\n founds.forEach(({ text, start, end, groups, matchIndex }, index) => {\n const restText = items.pop() as string;\n const head = restText.slice(0, start - cursor);\n const mid = replacer({ match: text, groups, matchIndex, index, keyPrefix });\n const tail = restText.slice(end - cursor);\n items.push(head, mid, tail);\n cursor = end;\n });\n return items;\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"],"mappings":"AAAA;AACAA,OAAO,CAAC,
|
|
1
|
+
{"version":3,"names":["require","shim","urlRegexStrict","urlRegexRough","phoneRegex","emailRegex","newLineRegex","createMentionTemplateRegex","trigger","RegExp","replaceWithRegex","text","regex","replacer","keyPrefix","matches","matchAll","founds","map","value","start","index","end","length","groups","matchIndex","items","cursor","forEach","_ref","restText","pop","head","slice","mid","match","tail","push","replaceUrlAsComponents","originText","strict","_ref2"],"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\nexport const createMentionTemplateRegex = (trigger: string) => new RegExp(`(${trigger}[{])(.*?)([}])`, '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 replaceWithRegex = <T>(\n text: string,\n regex: RegExp,\n replacer: (params: {\n match: string;\n groups: string[];\n matchIndex: number | undefined;\n index: number;\n keyPrefix: string;\n }) => T,\n keyPrefix: string,\n) => {\n const matches = [...text.matchAll(regex)];\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, groups: value, matchIndex: value.index };\n });\n\n const items: Array<T | string> = [text];\n let cursor = 0;\n founds.forEach(({ text, start, end, groups, matchIndex }, index) => {\n const restText = items.pop() as string;\n const head = restText.slice(0, start - cursor);\n const mid = replacer({ match: text, groups, matchIndex, index, keyPrefix });\n const tail = restText.slice(end - cursor);\n items.push(head, mid, tail);\n cursor = end;\n });\n return items;\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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,CAAC,GAAAmB,KAAA;IAClC,MAAMX,QAAQ,GAAGJ,KAAK,CAACK,GAAG,EAAY;IACtC,MAAMC,IAAI,GAAGF,QAAQ,CAACG,KAAK,CAAC,CAAC,EAAEb,KAAK,GAAGO,MAAM,CAAC;IAC9C,MAAMO,GAAG,GAAGrB,QAAQ,CAACF,IAAI,CAAC;IAC1B,MAAMyB,IAAI,GAAGN,QAAQ,CAACG,KAAK,CAACX,GAAG,GAAGK,MAAM,CAAC;IACzCD,KAAK,CAACW,IAAI,CAACL,IAAI,EAAEE,GAAG,EAAEE,IAAI,CAAC;IAC3BT,MAAM,GAAGL,GAAG;EACd,CAAC,CAAC;EACF,OAAOI,KAAK;AACd,CAAC"}
|
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';\n\nimport type SendbirdChat from '@sendbird/chat';\nimport type {\n BaseChannel,\n Emoji,\n EmojiCategory,\n EmojiContainer,\n Participant,\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 {\n ModuleNamespaces,\n OpenChannelCreateParams,\n OpenChannelUpdateParams,\n SendableMessage,\n} 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, OpenChannelListQuery, 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 type OnBeforeHandler<T> = (params: T) => T | Promise<T>;\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;\n\nexport type SendbirdGroupChannelCreateParams = GroupChannelCreateParams;\nexport type SendbirdGroupChannelUpdateParams = GroupChannelUpdateParams;\nexport type SendbirdOpenChannelCreateParams = OpenChannelCreateParams;\nexport type SendbirdOpenChannelUpdateParams = OpenChannelUpdateParams;\n\nexport type SendbirdUserUpdateParams = UserUpdateParams;\nexport type SendbirdUser = User;\nexport type SendbirdRestrictedUser = RestrictedUser;\nexport type SendbirdMember = Member;\nexport type SendbirdParticipant = Participant;\n\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 SendbirdOpenChannelListQuery = OpenChannelListQuery;\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":""}
|
|
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 Participant,\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 {\n ModuleNamespaces,\n OpenChannelCreateParams,\n OpenChannelUpdateParams,\n SendableMessage,\n} from '@sendbird/chat/lib/__definition';\nimport type {\n AdminMessage,\n BaseMessage,\n FileMessage,\n FileMessageCreateParams,\n FileMessageUpdateParams,\n MessageSearchQuery,\n PreviousMessageListQuery,\n Reaction,\n UserMessage,\n UserMessageCreateParams,\n UserMessageUpdateParams,\n} from '@sendbird/chat/message';\nimport type { OpenChannel, OpenChannelListQuery, 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 type OnBeforeHandler<T> = (params: T) => T | Promise<T>;\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;\n\nexport type SendbirdGroupChannelCreateParams = GroupChannelCreateParams;\nexport type SendbirdGroupChannelUpdateParams = GroupChannelUpdateParams;\nexport type SendbirdOpenChannelCreateParams = OpenChannelCreateParams;\nexport type SendbirdOpenChannelUpdateParams = OpenChannelUpdateParams;\n\nexport type SendbirdUserUpdateParams = UserUpdateParams;\nexport type SendbirdUser = User;\nexport type SendbirdRestrictedUser = RestrictedUser;\nexport type SendbirdMember = Member;\nexport type SendbirdParticipant = Participant;\n\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 SendbirdOpenChannelListQuery = OpenChannelListQuery;\nexport type SendbirdMessageCollection = MessageCollection;\nexport type SendbirdPreviousMessageListQuery = PreviousMessageListQuery;\nexport type SendbirdMessageSearchQuery = MessageSearchQuery;\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":""}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { format, isThisYear } from 'date-fns';
|
|
1
|
+
import { format, isThisYear, isToday, isYesterday } from 'date-fns';
|
|
2
2
|
const defaultOpts = {
|
|
3
3
|
mode: 'mid',
|
|
4
4
|
maxLen: 40,
|
|
5
5
|
separator: '...'
|
|
6
6
|
};
|
|
7
|
+
|
|
7
8
|
/**
|
|
8
9
|
* String truncate util
|
|
9
10
|
* @param {string} str
|
|
@@ -13,10 +14,10 @@ const defaultOpts = {
|
|
|
13
14
|
* @param {string} opts.separator default "..."
|
|
14
15
|
* @returns {string}
|
|
15
16
|
* */
|
|
16
|
-
|
|
17
17
|
export const truncate = function (str) {
|
|
18
18
|
let opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultOpts;
|
|
19
|
-
const options = {
|
|
19
|
+
const options = {
|
|
20
|
+
...defaultOpts,
|
|
20
21
|
...opts
|
|
21
22
|
};
|
|
22
23
|
const {
|
|
@@ -25,23 +26,20 @@ export const truncate = function (str) {
|
|
|
25
26
|
separator
|
|
26
27
|
} = options;
|
|
27
28
|
if (str.length <= maxLen) return str;
|
|
28
|
-
|
|
29
29
|
if (mode === 'head') {
|
|
30
30
|
return separator + str.slice(-maxLen);
|
|
31
31
|
}
|
|
32
|
-
|
|
33
32
|
if (mode === 'mid') {
|
|
34
33
|
const lead = Math.ceil(maxLen / 2);
|
|
35
34
|
const trail = Math.floor(maxLen / 2);
|
|
36
35
|
return str.slice(0, lead) + separator + str.slice(-trail);
|
|
37
36
|
}
|
|
38
|
-
|
|
39
37
|
if (mode === 'tail') {
|
|
40
38
|
return str.slice(0, maxLen) + separator;
|
|
41
39
|
}
|
|
42
|
-
|
|
43
40
|
throw new Error('Invalid truncate mode: ' + mode);
|
|
44
41
|
};
|
|
42
|
+
|
|
45
43
|
/**
|
|
46
44
|
* Count truncate util
|
|
47
45
|
* If count exceed the limit, it comes in the form of "MAX+"
|
|
@@ -51,13 +49,13 @@ export const truncate = function (str) {
|
|
|
51
49
|
* @param {string} MAX_SUFFIX default +
|
|
52
50
|
* @returns {string}
|
|
53
51
|
* */
|
|
54
|
-
|
|
55
52
|
export const truncatedCount = function (count) {
|
|
56
53
|
let MAX = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 99;
|
|
57
54
|
let MAX_SUFFIX = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '+';
|
|
58
55
|
if (count >= MAX) return `${MAX}${MAX_SUFFIX}`;
|
|
59
56
|
return `${count}`;
|
|
60
57
|
};
|
|
58
|
+
|
|
61
59
|
/**
|
|
62
60
|
* Messages date separator format
|
|
63
61
|
*
|
|
@@ -65,7 +63,6 @@ export const truncatedCount = function (count) {
|
|
|
65
63
|
* @param {Locale} [locale]
|
|
66
64
|
* @returns {string}
|
|
67
65
|
* */
|
|
68
|
-
|
|
69
66
|
export const getDateSeparatorFormat = (date, locale) => {
|
|
70
67
|
if (isThisYear(date)) return format(date, 'MMM dd, yyyy', {
|
|
71
68
|
locale
|
|
@@ -74,6 +71,7 @@ export const getDateSeparatorFormat = (date, locale) => {
|
|
|
74
71
|
locale
|
|
75
72
|
});
|
|
76
73
|
};
|
|
74
|
+
|
|
77
75
|
/**
|
|
78
76
|
* Message time format
|
|
79
77
|
*
|
|
@@ -81,10 +79,62 @@ export const getDateSeparatorFormat = (date, locale) => {
|
|
|
81
79
|
* @param {Locale} [locale]
|
|
82
80
|
* @returns {string}
|
|
83
81
|
* */
|
|
84
|
-
|
|
85
82
|
export const getMessageTimeFormat = (date, locale) => {
|
|
86
83
|
return format(date, 'p', {
|
|
87
84
|
locale
|
|
88
85
|
});
|
|
89
86
|
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Message preview title text
|
|
90
|
+
* */
|
|
91
|
+
export const getMessagePreviewTitle = function (message) {
|
|
92
|
+
let EMPTY_USERNAME = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '(No name)';
|
|
93
|
+
if (message.isFileMessage() || message.isUserMessage()) {
|
|
94
|
+
return message.sender.nickname || EMPTY_USERNAME;
|
|
95
|
+
}
|
|
96
|
+
if (message.isAdminMessage()) {
|
|
97
|
+
return 'Admin';
|
|
98
|
+
}
|
|
99
|
+
return EMPTY_USERNAME;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Message preview body text
|
|
104
|
+
* */
|
|
105
|
+
export const getMessagePreviewBody = function (message) {
|
|
106
|
+
let EMPTY_MESSAGE = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
107
|
+
if (message.isFileMessage()) {
|
|
108
|
+
const extIdx = message.name.lastIndexOf('.');
|
|
109
|
+
if (extIdx > -1) {
|
|
110
|
+
const file = message.name.slice(0, extIdx);
|
|
111
|
+
const ext = message.name.slice(extIdx);
|
|
112
|
+
return file + ext;
|
|
113
|
+
}
|
|
114
|
+
return message.name;
|
|
115
|
+
}
|
|
116
|
+
if (message.isUserMessage()) {
|
|
117
|
+
return message.message ?? EMPTY_MESSAGE;
|
|
118
|
+
}
|
|
119
|
+
if (message.isAdminMessage()) {
|
|
120
|
+
return message.message ?? EMPTY_MESSAGE;
|
|
121
|
+
}
|
|
122
|
+
return EMPTY_MESSAGE;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Message preview time format
|
|
127
|
+
* */
|
|
128
|
+
export const getMessagePreviewTime = (timestamp, locale) => {
|
|
129
|
+
if (isToday(timestamp)) return format(timestamp, 'p', {
|
|
130
|
+
locale
|
|
131
|
+
});
|
|
132
|
+
if (isYesterday(timestamp)) return 'Yesterday';
|
|
133
|
+
if (isThisYear(timestamp)) return format(timestamp, 'MMM dd', {
|
|
134
|
+
locale
|
|
135
|
+
});
|
|
136
|
+
return format(timestamp, 'yyyy/MM/dd', {
|
|
137
|
+
locale
|
|
138
|
+
});
|
|
139
|
+
};
|
|
90
140
|
//# sourceMappingURL=common.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["format","isThisYear","defaultOpts","mode","maxLen","separator","truncate","str","opts","
|
|
1
|
+
{"version":3,"names":["format","isThisYear","isToday","isYesterday","defaultOpts","mode","maxLen","separator","truncate","str","opts","arguments","length","undefined","options","slice","lead","Math","ceil","trail","floor","Error","truncatedCount","count","MAX","MAX_SUFFIX","getDateSeparatorFormat","date","locale","getMessageTimeFormat","getMessagePreviewTitle","message","EMPTY_USERNAME","isFileMessage","isUserMessage","sender","nickname","isAdminMessage","getMessagePreviewBody","EMPTY_MESSAGE","extIdx","name","lastIndexOf","file","ext","getMessagePreviewTime","timestamp"],"sources":["common.ts"],"sourcesContent":["import type { Locale } from 'date-fns';\nimport { format, isThisYear, isToday, isYesterday } from 'date-fns';\n\nimport type { SendbirdBaseMessage } from '../types';\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\n/**\n * Message preview title text\n * */\nexport const getMessagePreviewTitle = (message: SendbirdBaseMessage, EMPTY_USERNAME = '(No name)') => {\n if (message.isFileMessage() || message.isUserMessage()) {\n return message.sender.nickname || EMPTY_USERNAME;\n }\n if (message.isAdminMessage()) {\n return 'Admin';\n }\n return EMPTY_USERNAME;\n};\n\n/**\n * Message preview body text\n * */\nexport const getMessagePreviewBody = (message: SendbirdBaseMessage, EMPTY_MESSAGE = '') => {\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 file + ext;\n }\n\n return message.name;\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\n/**\n * Message preview time format\n * */\nexport const getMessagePreviewTime = (timestamp: number, locale?: Locale) => {\n if (isToday(timestamp)) return format(timestamp, 'p', { locale });\n if (isYesterday(timestamp)) return 'Yesterday';\n if (isThisYear(timestamp)) return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;EAC9C,IAAI7C,UAAU,CAAC6C,SAAS,CAAC,EAAE,OAAO9C,MAAM,CAAC8C,SAAS,EAAE,QAAQ,EAAE;IAAElB;EAAO,CAAC,CAAC;EAEzE,OAAO5B,MAAM,CAAC8C,SAAS,EAAE,YAAY,EAAE;IAAElB;EAAO,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { truncate } from './common';
|
|
1
|
+
import { getMessagePreviewBody, getMessagePreviewTime } from './common';
|
|
3
2
|
export const getGroupChannelTitle = function (currentUserId, channel) {
|
|
4
3
|
let EMPTY_USERNAME = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '(No name)';
|
|
5
4
|
let NO_MEMBERS = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '(No members)';
|
|
@@ -20,49 +19,12 @@ export const getGroupChannelTitle = function (currentUserId, channel) {
|
|
|
20
19
|
};
|
|
21
20
|
export const getGroupChannelPreviewTime = (channel, locale) => {
|
|
22
21
|
var _channel$lastMessage;
|
|
23
|
-
|
|
24
|
-
const timestamp = ((_channel$lastMessage = channel.lastMessage) === null || _channel$lastMessage === void 0 ? void 0 : _channel$lastMessage.createdAt) || channel.joinedAt * 1000 || channel.createdAt;
|
|
25
|
-
if (isToday(timestamp)) return format(timestamp, 'p', {
|
|
26
|
-
locale
|
|
27
|
-
});
|
|
28
|
-
if (isYesterday(timestamp)) return 'Yesterday';
|
|
29
|
-
if (isThisYear(timestamp)) return format(timestamp, 'MMM dd', {
|
|
30
|
-
locale
|
|
31
|
-
});
|
|
32
|
-
return format(timestamp, 'yyyy/MM/dd', {
|
|
33
|
-
locale
|
|
34
|
-
});
|
|
22
|
+
return getMessagePreviewTime(((_channel$lastMessage = channel.lastMessage) === null || _channel$lastMessage === void 0 ? void 0 : _channel$lastMessage.createdAt) || channel.joinedAt * 1000 || channel.createdAt, locale);
|
|
35
23
|
};
|
|
36
24
|
export const getGroupChannelLastMessage = function (channel) {
|
|
37
25
|
let EMPTY_MESSAGE = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
38
|
-
let MAX_LEN = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 15;
|
|
39
26
|
const message = channel.lastMessage;
|
|
40
27
|
if (!message) return EMPTY_MESSAGE;
|
|
41
|
-
|
|
42
|
-
if (message.isFileMessage()) {
|
|
43
|
-
const extIdx = message.name.lastIndexOf('.');
|
|
44
|
-
|
|
45
|
-
if (extIdx > -1) {
|
|
46
|
-
const file = message.name.slice(0, extIdx);
|
|
47
|
-
const ext = message.name.slice(extIdx);
|
|
48
|
-
return truncate(file, {
|
|
49
|
-
maxLen: MAX_LEN
|
|
50
|
-
}) + ext;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return truncate(message.name, {
|
|
54
|
-
maxLen: MAX_LEN
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (message.isUserMessage()) {
|
|
59
|
-
return message.message ?? EMPTY_MESSAGE;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (message.isAdminMessage()) {
|
|
63
|
-
return message.message ?? EMPTY_MESSAGE;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return EMPTY_MESSAGE;
|
|
28
|
+
return getMessagePreviewBody(message, EMPTY_MESSAGE);
|
|
67
29
|
};
|
|
68
30
|
//# sourceMappingURL=groupChannel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["getMessagePreviewBody","getMessagePreviewTime","getGroupChannelTitle","currentUserId","channel","EMPTY_USERNAME","arguments","length","undefined","NO_MEMBERS","DEFAULT_CHANNEL_NAME","name","memberCount","members","filter","_ref","userId","map","_ref2","nickname","join","getGroupChannelPreviewTime","locale","_channel$lastMessage","lastMessage","createdAt","joinedAt","getGroupChannelLastMessage","EMPTY_MESSAGE","message"],"sources":["groupChannel.ts"],"sourcesContent":["import type { Locale } from 'date-fns';\n\nimport type { SendbirdGroupChannel } from '../types';\nimport { getMessagePreviewBody, getMessagePreviewTime } 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 return getMessagePreviewTime(channel.lastMessage?.createdAt || channel.joinedAt * 1000 || channel.createdAt, locale);\n};\n\nexport const getGroupChannelLastMessage = (channel: SendbirdGroupChannel, EMPTY_MESSAGE = '') => {\n const message = channel.lastMessage;\n if (!message) return EMPTY_MESSAGE;\n\n return getMessagePreviewBody(message, EMPTY_MESSAGE);\n};\n"],"mappings":"AAGA,SAASA,qBAAqB,EAAEC,qBAAqB,QAAQ,UAAU;AAEvE,OAAO,MAAMC,oBAAoB,GAAG,SAAAA,CAClCC,aAAqB,EACrBC,OAA6B,EAI1B;EAAA,IAHHC,cAAc,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,WAAW;EAAA,IAC5BG,UAAU,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,cAAc;EAAA,IAC3BI,oBAAoB,GAAAJ,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,eAAe;EAEtC,IAAIF,OAAO,CAACO,IAAI,KAAKD,oBAAoB,IAAIN,OAAO,CAACO,IAAI,KAAK,EAAE,EAAE,OAAOP,OAAO,CAACO,IAAI;EACrF,IAAIP,OAAO,CAACQ,WAAW,KAAK,CAAC,EAAE,OAAOH,UAAU;EAChD,OAAOL,OAAO,CAACS,OAAO,CACnBC,MAAM,CAACC,IAAA;IAAA,IAAC;MAAEC;IAAO,CAAC,GAAAD,IAAA;IAAA,OAAKC,MAAM,KAAKb,aAAa;EAAA,EAAC,CAChDc,GAAG,CAACC,KAAA;IAAA,IAAC;MAAEC;IAAS,CAAC,GAAAD,KAAA;IAAA,OAAKC,QAAQ,IAAId,cAAc;EAAA,EAAC,CACjDe,IAAI,CAAC,IAAI,CAAC;AACf,CAAC;AAED,OAAO,MAAMC,0BAA0B,GAAGA,CAACjB,OAA6B,EAAEkB,MAAe,KAAK;EAAA,IAAAC,oBAAA;EAC5F,OAAOtB,qBAAqB,CAAC,EAAAsB,oBAAA,GAAAnB,OAAO,CAACoB,WAAW,cAAAD,oBAAA,uBAAnBA,oBAAA,CAAqBE,SAAS,KAAIrB,OAAO,CAACsB,QAAQ,GAAG,IAAI,IAAItB,OAAO,CAACqB,SAAS,EAAEH,MAAM,CAAC;AACtH,CAAC;AAED,OAAO,MAAMK,0BAA0B,GAAG,SAAAA,CAACvB,OAA6B,EAAyB;EAAA,IAAvBwB,aAAa,GAAAtB,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;EAC1F,MAAMuB,OAAO,GAAGzB,OAAO,CAACoB,WAAW;EACnC,IAAI,CAACK,OAAO,EAAE,OAAOD,aAAa;EAElC,OAAO5B,qBAAqB,CAAC6B,OAAO,EAAED,aAAa,CAAC;AACtD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getOpenChannelTitle","channel","DEFAULT_CHANNEL_NAME","trimmedChannelName","name","trim","getOpenChannelParticipants","participantCount"],"sources":["openChannel.ts"],"sourcesContent":["import type { SendbirdOpenChannel } from '../types';\n\nexport const getOpenChannelTitle = (channel: SendbirdOpenChannel, DEFAULT_CHANNEL_NAME = 'Open Channel') => {\n const trimmedChannelName = channel.name.trim();\n if (trimmedChannelName === '') return DEFAULT_CHANNEL_NAME;\n return trimmedChannelName;\n};\n\nexport const getOpenChannelParticipants = (channel: SendbirdOpenChannel) => {\n return `${channel.participantCount} participants`;\n};\n"],"mappings":"AAEA,OAAO,MAAMA,mBAAmB,GAAG,
|
|
1
|
+
{"version":3,"names":["getOpenChannelTitle","channel","DEFAULT_CHANNEL_NAME","arguments","length","undefined","trimmedChannelName","name","trim","getOpenChannelParticipants","participantCount"],"sources":["openChannel.ts"],"sourcesContent":["import type { SendbirdOpenChannel } from '../types';\n\nexport const getOpenChannelTitle = (channel: SendbirdOpenChannel, DEFAULT_CHANNEL_NAME = 'Open Channel') => {\n const trimmedChannelName = channel.name.trim();\n if (trimmedChannelName === '') return DEFAULT_CHANNEL_NAME;\n return trimmedChannelName;\n};\n\nexport const getOpenChannelParticipants = (channel: SendbirdOpenChannel) => {\n return `${channel.participantCount} participants`;\n};\n"],"mappings":"AAEA,OAAO,MAAMA,mBAAmB,GAAG,SAAAA,CAACC,OAA4B,EAA4C;EAAA,IAA1CC,oBAAoB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,cAAc;EACrG,MAAMG,kBAAkB,GAAGL,OAAO,CAACM,IAAI,CAACC,IAAI,EAAE;EAC9C,IAAIF,kBAAkB,KAAK,EAAE,EAAE,OAAOJ,oBAAoB;EAC1D,OAAOI,kBAAkB;AAC3B,CAAC;AAED,OAAO,MAAMG,0BAA0B,GAAIR,OAA4B,IAAK;EAC1E,OAAQ,GAAEA,OAAO,CAACS,gBAAiB,eAAc;AACnD,CAAC"}
|
|
@@ -12,4 +12,5 @@ export declare const useIsFirstMount: () => boolean;
|
|
|
12
12
|
export declare const useFreshCallback: <T extends (...args: any[]) => any>(callback: T) => T;
|
|
13
13
|
export declare const useDebounceEffect: (action: () => void, delay: number, deps?: DependencyList) => void;
|
|
14
14
|
export declare const usePartialState: <S>(initialState: S) => [S & Partial<S>, import("react").Dispatch<Partial<S>>];
|
|
15
|
+
export declare const useRefTracker: <T>(target: T) => import("react").MutableRefObject<T>;
|
|
15
16
|
export {};
|