@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
|
@@ -58,7 +58,6 @@ const audioExtRegex = /3gp|aac|aax|act|aiff|flac|gsm|m4a|m4b|m4p|tta|wma|mp3|web
|
|
|
58
58
|
exports.audioExtRegex = audioExtRegex;
|
|
59
59
|
const videoExtRegex = /mov|vod|mp4|avi/i;
|
|
60
60
|
exports.videoExtRegex = videoExtRegex;
|
|
61
|
-
|
|
62
61
|
const getFileType = extOrType => {
|
|
63
62
|
if (extOrType.indexOf('/') > -1) {
|
|
64
63
|
const type = extOrType.split('/')[0];
|
|
@@ -67,12 +66,12 @@ const getFileType = extOrType => {
|
|
|
67
66
|
if (type === 'image') return 'image';
|
|
68
67
|
return 'file';
|
|
69
68
|
}
|
|
70
|
-
|
|
71
69
|
if (extOrType.match(imageExtRegex)) return 'image';
|
|
72
70
|
if (extOrType.match(audioExtRegex)) return 'audio';
|
|
73
71
|
if (extOrType.match(videoExtRegex)) return 'video';
|
|
74
72
|
return 'file';
|
|
75
73
|
};
|
|
74
|
+
|
|
76
75
|
/**
|
|
77
76
|
* Calculates the downscaled size of an image while preserving its aspect ratio.
|
|
78
77
|
*
|
|
@@ -84,15 +83,11 @@ const getFileType = extOrType => {
|
|
|
84
83
|
* getDownscaleSize({ width: 1200, height: 800 }, { width: 600 }); // returns { width: 600, height: 400 }
|
|
85
84
|
* ```
|
|
86
85
|
*/
|
|
87
|
-
|
|
88
|
-
|
|
89
86
|
exports.getFileType = getFileType;
|
|
90
|
-
|
|
91
87
|
function getDownscaleSize(origin, resizing) {
|
|
92
88
|
let ratio;
|
|
93
89
|
const maxWidth = resizing.width || origin.width,
|
|
94
|
-
|
|
95
|
-
|
|
90
|
+
maxHeight = resizing.height || origin.height;
|
|
96
91
|
if (origin.width <= maxWidth && origin.height <= maxHeight) {
|
|
97
92
|
ratio = 1;
|
|
98
93
|
} else if (origin.width > maxWidth && origin.height <= maxHeight) {
|
|
@@ -102,12 +97,12 @@ function getDownscaleSize(origin, resizing) {
|
|
|
102
97
|
} else {
|
|
103
98
|
ratio = Math.min(maxWidth / origin.width, maxHeight / origin.height);
|
|
104
99
|
}
|
|
105
|
-
|
|
106
100
|
return {
|
|
107
101
|
width: origin.width * ratio,
|
|
108
102
|
height: origin.height * ratio
|
|
109
103
|
};
|
|
110
104
|
}
|
|
105
|
+
|
|
111
106
|
/**
|
|
112
107
|
* Normalize a file name by ensuring it has the given extension, if it doesn't already.
|
|
113
108
|
*
|
|
@@ -115,22 +110,18 @@ function getDownscaleSize(origin, resizing) {
|
|
|
115
110
|
* @param {string} extension - The desired extension, without a leading period.
|
|
116
111
|
* @returns {string} - The normalized file name, with the extension.
|
|
117
112
|
*/
|
|
118
|
-
|
|
119
|
-
|
|
120
113
|
function normalizeFileName(fileName, extension) {
|
|
121
|
-
if (!extension) return fileName;
|
|
114
|
+
if (!extension) return fileName;
|
|
122
115
|
|
|
116
|
+
// .extension
|
|
123
117
|
let _extension = extension.toLowerCase();
|
|
124
|
-
|
|
125
118
|
if (_extension.indexOf('.') !== 0) {
|
|
126
119
|
_extension = '.' + _extension;
|
|
127
|
-
}
|
|
128
|
-
|
|
120
|
+
}
|
|
129
121
|
|
|
122
|
+
// filename.extension | filename
|
|
130
123
|
const _filename = fileName.toLowerCase();
|
|
131
|
-
|
|
132
124
|
const hasExtension = _filename.lastIndexOf(_extension) === _filename.length - _extension.length;
|
|
133
|
-
|
|
134
125
|
if (!hasExtension) {
|
|
135
126
|
// filename.extension
|
|
136
127
|
return fileName + _extension;
|
|
@@ -139,6 +130,7 @@ function normalizeFileName(fileName, extension) {
|
|
|
139
130
|
return fileName;
|
|
140
131
|
}
|
|
141
132
|
}
|
|
133
|
+
|
|
142
134
|
/**
|
|
143
135
|
* Parses a MIME type string into its components.
|
|
144
136
|
*
|
|
@@ -146,31 +138,27 @@ function normalizeFileName(fileName, extension) {
|
|
|
146
138
|
* @returns An object containing the type, subtype, and parameters of the MIME type.
|
|
147
139
|
*/
|
|
148
140
|
|
|
149
|
-
|
|
150
141
|
function parseMimeType(mimeType) {
|
|
151
142
|
const [fullType, ...parts] = mimeType.split(';');
|
|
152
143
|
const [type, subtype] = fullType.split('/');
|
|
153
144
|
const parameters = {};
|
|
154
|
-
|
|
155
145
|
for (const part of parts) {
|
|
156
146
|
const [name, value] = part.trim().split('=');
|
|
157
147
|
parameters[name] = value;
|
|
158
148
|
}
|
|
159
|
-
|
|
160
149
|
return {
|
|
161
150
|
type,
|
|
162
151
|
subtype,
|
|
163
152
|
parameters
|
|
164
153
|
};
|
|
165
154
|
}
|
|
155
|
+
|
|
166
156
|
/**
|
|
167
157
|
* Returns the file extension based on the MIME type.
|
|
168
158
|
*
|
|
169
159
|
* @param {string | null | undefined} mimeType - The MIME type to look up.
|
|
170
160
|
* @returns {string} - The file extension for the given MIME type, or an empty string if no matching file extension was found.
|
|
171
161
|
*/
|
|
172
|
-
|
|
173
|
-
|
|
174
162
|
function getFileExtensionFromMime(mimeType) {
|
|
175
163
|
if (!mimeType) return '';
|
|
176
164
|
const MIME_EXTENSION_MAP = Object.entries(EXTENSION_MIME_MAP).reduce((acc, _ref) => {
|
|
@@ -180,26 +168,24 @@ function getFileExtensionFromMime(mimeType) {
|
|
|
180
168
|
}, {});
|
|
181
169
|
return MIME_EXTENSION_MAP[mimeType.toLowerCase()] || '';
|
|
182
170
|
}
|
|
171
|
+
|
|
183
172
|
/**
|
|
184
173
|
* Returns the MIME type based on the file extension.
|
|
185
174
|
*
|
|
186
175
|
* @param {string | null | undefined} ext - The file extension to look up.
|
|
187
176
|
* @returns {string} - The MIME type for the given file extension, or an empty string if no matching MIME type was found.
|
|
188
177
|
*/
|
|
189
|
-
|
|
190
|
-
|
|
191
178
|
function getMimeFromFileExtension(ext) {
|
|
192
179
|
if (!ext) return '';
|
|
193
180
|
return EXTENSION_MIME_MAP[ext.toLowerCase()] || '';
|
|
194
181
|
}
|
|
182
|
+
|
|
195
183
|
/**
|
|
196
184
|
* Returns the file extension of a file path.
|
|
197
185
|
*
|
|
198
186
|
* @param {string} filePath - The file path to extract the extension from.
|
|
199
187
|
* @returns {string} - The file extension, or an empty string if the file path does not have an extension.
|
|
200
188
|
*/
|
|
201
|
-
|
|
202
|
-
|
|
203
189
|
function getFileExtension(filePath) {
|
|
204
190
|
const pathWithoutParams = filePath.split('?')[0];
|
|
205
191
|
const idx = pathWithoutParams.lastIndexOf('.');
|
|
@@ -207,16 +193,13 @@ function getFileExtension(filePath) {
|
|
|
207
193
|
const result = pathWithoutParams.slice(idx - pathWithoutParams.length).toLowerCase();
|
|
208
194
|
if (result === '.') return '';else return result;
|
|
209
195
|
}
|
|
210
|
-
|
|
211
196
|
function getFileExtensionFromUri(uri) {
|
|
212
197
|
return fetch(uri).then(response => response.headers.get('content-type'));
|
|
213
198
|
}
|
|
214
|
-
|
|
215
199
|
function isImage(filePath, mimeType) {
|
|
216
200
|
const type = getFileType(mimeType || getFileExtension(filePath));
|
|
217
201
|
return type === 'image';
|
|
218
202
|
}
|
|
219
|
-
|
|
220
203
|
function shouldCompressImage(mime) {
|
|
221
204
|
let compressionEnabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
222
205
|
const extension = getFileExtensionFromMime(mime);
|
|
@@ -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,W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OAAOE,OAAO,CAAC3C,SAAS,CAACb,KAAV,CAAgB,eAAhB,KAAoCuD,kBAArC,CAAd;AACD"}
|
|
1
|
+
{"version":3,"names":["EXTENSION_MIME_MAP","imageExtRegex","exports","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;EACpB,KAAK,EAAE,iBAAiB;EAExB;EACA,KAAK,EAAE,WAAW;EAClB,KAAK,EAAE,YAAY;EACnB,KAAK,EAAE,YAAY;EACnB,KAAK,EAAE,WAAW;EAClB,KAAK,EAAE,WAAW;EAClB,MAAM,EAAE,YAAY;EAEpB;EACA,KAAK,EAAE,YAAY;EACnB,KAAK,EAAE,iBAAiB;EACxB,KAAK,EAAE,oBAAoB;EAC3B,MAAM,EAAE,yEAAyE;EACjF,KAAK,EAAE,0BAA0B;EACjC,MAAM,EAAE,mEAAmE;EAC3E,KAAK,EAAE,+BAA+B;EACtC,MAAM,EAAE,2EAA2E;EACnF,KAAK,EAAE,iBAAiB;EACxB,MAAM,EAAE,kBAAkB;EAC1B,MAAM,EAAE;AACV,CAA2B;AAEpB,MAAMC,aAAa,GAAG,wBAAwB;AAACC,OAAA,CAAAD,aAAA,GAAAA,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,QAAQ,CAAC1C,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;EAEhD,MAAM4C,GAAG,GAAGD,iBAAiB,CAACxB,WAAW,CAAC,GAAG,CAAC;EAC9C,IAAIyB,GAAG,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE;EAEzB,MAAMC,MAAM,GAAGF,iBAAiB,CAACG,KAAK,CAACF,GAAG,GAAGD,iBAAiB,CAACvB,MAAM,CAAC,CAACJ,WAAW,EAAE;EACpF,IAAI6B,MAAM,KAAK,GAAG,EAAE,OAAO,EAAE,CAAC,KACzB,OAAOA,MAAM;AACpB;AAEO,SAASE,uBAAuBA,CAACC,GAAW,EAAE;EACnD,OAAOC,KAAK,CAACD,GAAG,CAAC,CAACE,IAAI,CAAEC,QAAQ,IAAKA,QAAQ,CAACC,OAAO,CAACC,GAAG,CAAC,cAAc,CAAC,CAAC;AAC5E;AAEO,SAASC,OAAOA,CAACZ,QAAgB,EAAEpB,QAAiB,EAAE;EAC3D,MAAMvB,IAAI,GAAGH,WAAW,CAAC0B,QAAQ,IAAImB,gBAAgB,CAACC,QAAQ,CAAC,CAAC;EAChE,OAAO3C,IAAI,KAAK,OAAO;AACzB;AAEO,SAASwD,mBAAmBA,CAACC,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"}
|
|
@@ -7,30 +7,28 @@ exports.conditionChaining = conditionChaining;
|
|
|
7
7
|
exports.hash = hash;
|
|
8
8
|
exports.pick = pick;
|
|
9
9
|
exports.replace = replace;
|
|
10
|
-
|
|
11
10
|
/**
|
|
12
11
|
* Converts a given string to a hashed string.
|
|
13
12
|
* */
|
|
14
13
|
function hash(str) {
|
|
15
14
|
return String(Math.abs(str.split('').reduce((a, c) => (a << 5) - a + c.charCodeAt(0) | 0, 0)));
|
|
16
15
|
}
|
|
16
|
+
|
|
17
17
|
/**
|
|
18
18
|
* Replace a specific range of text in the string with another text.
|
|
19
19
|
* */
|
|
20
|
-
|
|
21
|
-
|
|
22
20
|
function replace(str, start, end, text) {
|
|
23
21
|
return str.slice(0, start) + text + str.slice(end);
|
|
24
22
|
}
|
|
23
|
+
|
|
25
24
|
/**
|
|
26
25
|
* Returns the value corresponding to the first true index of a given condition array.
|
|
27
26
|
* */
|
|
28
|
-
|
|
29
|
-
|
|
30
27
|
function conditionChaining(conditions, values) {
|
|
31
28
|
const idx = conditions.findIndex(state => Boolean(state));
|
|
32
29
|
return idx > -1 ? values[idx] : values[values.length - 1];
|
|
33
30
|
}
|
|
31
|
+
|
|
34
32
|
/**
|
|
35
33
|
* Returns a new object with only the specified keys from the input object.
|
|
36
34
|
*
|
|
@@ -42,8 +40,6 @@ function conditionChaining(conditions, values) {
|
|
|
42
40
|
* pick({ a: 1, b: '2', c: true }, ['a', 'c']); // returns { a: 1, c: true }
|
|
43
41
|
* ```
|
|
44
42
|
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
43
|
function pick(obj, keys) {
|
|
48
44
|
return keys.reduce((pickedObj, key) => {
|
|
49
45
|
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":"
|
|
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;AACO,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;AACO,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;AACO,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;AACO,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"}
|
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Logger = void 0;
|
|
7
|
-
|
|
8
7
|
/* eslint-disable no-console */
|
|
8
|
+
|
|
9
9
|
const LogLevelEnum = {
|
|
10
10
|
'none': 0,
|
|
11
11
|
'log': 1,
|
|
@@ -14,7 +14,6 @@ const LogLevelEnum = {
|
|
|
14
14
|
'info': 4,
|
|
15
15
|
'debug': 5
|
|
16
16
|
};
|
|
17
|
-
|
|
18
17
|
const createLogger = function () {
|
|
19
18
|
let level = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'warn';
|
|
20
19
|
let _logLevel = level;
|
|
@@ -23,74 +22,56 @@ const createLogger = function () {
|
|
|
23
22
|
setTitle(title) {
|
|
24
23
|
_title = title;
|
|
25
24
|
},
|
|
26
|
-
|
|
27
25
|
setLogLevel(lv) {
|
|
28
26
|
_logLevel = lv;
|
|
29
27
|
},
|
|
30
|
-
|
|
31
28
|
getLogLevel() {
|
|
32
29
|
return _logLevel;
|
|
33
30
|
},
|
|
34
|
-
|
|
35
31
|
log() {
|
|
36
32
|
if (LogLevelEnum[_logLevel] < LogLevelEnum.log) return LogLevelEnum.none;
|
|
37
|
-
|
|
38
33
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
39
34
|
args[_key] = arguments[_key];
|
|
40
35
|
}
|
|
41
|
-
|
|
42
36
|
console.log(_title, ...args);
|
|
43
37
|
return LogLevelEnum[_logLevel];
|
|
44
38
|
},
|
|
45
|
-
|
|
46
39
|
error() {
|
|
47
40
|
if (LogLevelEnum[_logLevel] < LogLevelEnum.error) return LogLevelEnum.none;
|
|
48
|
-
|
|
49
41
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
50
42
|
args[_key2] = arguments[_key2];
|
|
51
43
|
}
|
|
52
|
-
|
|
53
44
|
console.error(_title, ...args);
|
|
54
45
|
return LogLevelEnum[_logLevel];
|
|
55
46
|
},
|
|
56
|
-
|
|
57
47
|
warn() {
|
|
58
48
|
if (LogLevelEnum[_logLevel] < LogLevelEnum.warn) return LogLevelEnum.none;
|
|
59
|
-
|
|
60
49
|
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
61
50
|
args[_key3] = arguments[_key3];
|
|
62
51
|
}
|
|
63
|
-
|
|
64
52
|
console.warn(_title, ...args);
|
|
65
53
|
return LogLevelEnum[_logLevel];
|
|
66
54
|
},
|
|
67
|
-
|
|
68
55
|
info() {
|
|
69
56
|
if (LogLevelEnum[_logLevel] < LogLevelEnum.info) return LogLevelEnum.none;
|
|
70
|
-
|
|
71
57
|
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
72
58
|
args[_key4] = arguments[_key4];
|
|
73
59
|
}
|
|
74
|
-
|
|
75
60
|
console.info(_title, ...args);
|
|
76
61
|
return LogLevelEnum[_logLevel];
|
|
77
62
|
},
|
|
78
|
-
|
|
79
63
|
debug() {
|
|
80
64
|
if (LogLevelEnum[_logLevel] < LogLevelEnum.debug) return LogLevelEnum.none;
|
|
81
|
-
|
|
82
65
|
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
83
66
|
args[_key5] = arguments[_key5];
|
|
84
67
|
}
|
|
85
|
-
|
|
86
68
|
console.log(_title, ...args);
|
|
87
69
|
return LogLevelEnum[_logLevel];
|
|
88
70
|
}
|
|
89
|
-
|
|
90
71
|
};
|
|
91
72
|
};
|
|
92
|
-
|
|
93
|
-
|
|
73
|
+
const Logger = {
|
|
74
|
+
...createLogger(),
|
|
94
75
|
LogLevelEnum,
|
|
95
76
|
create: createLogger
|
|
96
77
|
};
|
|
@@ -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":"
|
|
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","exports"],"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,CAAC;EACT,KAAK,EAAE,CAAC;EACR,OAAO,EAAE,CAAC;EACV,MAAM,EAAE,CAAC;EACT,MAAM,EAAE,CAAC;EACT,OAAO,EAAE;AACX,CAAC;AAGD,MAAMC,YAAY,GAAG,SAAAA,CAAA,EAA8B;EAAA,IAA7BC,KAAe,GAAAC,SAAA,CAAAC,MAAA,QAAA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AAC;MAC5B,OAAOhB,YAAY,CAACM,SAAS,CAAC;IAChC;EACF,CAAC;AACH,CAAC;AAEM,MAAM0B,MAAM,GAAG;EACpB,GAAG/B,YAAY,EAAE;EACjBD,YAAY;EACZiC,MAAM,EAAEhC;AACV,CAAC;AAACiC,OAAA,CAAAF,MAAA,GAAAA,MAAA"}
|
|
@@ -4,10 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.urlRegexStrict = exports.urlRegexRough = exports.replaceWithRegex = exports.replaceUrlAsComponents = exports.phoneRegex = exports.newLineRegex = exports.emailRegex = exports.createMentionTemplateRegex = void 0;
|
|
7
|
-
|
|
8
7
|
// For iOS 12 backwards compatibility
|
|
9
8
|
require('string.prototype.matchall').shim();
|
|
10
|
-
|
|
11
9
|
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;
|
|
12
10
|
exports.urlRegexStrict = urlRegexStrict;
|
|
13
11
|
const urlRegexRough = /(https?:\/\/|www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/g;
|
|
@@ -18,8 +16,9 @@ const emailRegex = /\S+@\S+\.\S+/;
|
|
|
18
16
|
exports.emailRegex = emailRegex;
|
|
19
17
|
const newLineRegex = /\r\n|\r|\n/g;
|
|
20
18
|
exports.newLineRegex = newLineRegex;
|
|
19
|
+
const createMentionTemplateRegex = trigger => new RegExp(`(${trigger}[{])(.*?)([}])`, 'g');
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
// const cases = [
|
|
23
22
|
// {
|
|
24
23
|
// type: 'urlStrict',
|
|
25
24
|
// regex: urlRegexStrict,
|
|
@@ -37,10 +36,7 @@ const createMentionTemplateRegex = trigger => new RegExp(`(${trigger}[{])(.*?)([
|
|
|
37
36
|
// regex: urlRegexStrict,
|
|
38
37
|
// },
|
|
39
38
|
// ];
|
|
40
|
-
|
|
41
|
-
|
|
42
39
|
exports.createMentionTemplateRegex = createMentionTemplateRegex;
|
|
43
|
-
|
|
44
40
|
const replaceWithRegex = (text, regex, replacer, keyPrefix) => {
|
|
45
41
|
const matches = [...text.matchAll(regex)];
|
|
46
42
|
const founds = matches.map(value => {
|
|
@@ -80,9 +76,7 @@ const replaceWithRegex = (text, regex, replacer, keyPrefix) => {
|
|
|
80
76
|
});
|
|
81
77
|
return items;
|
|
82
78
|
};
|
|
83
|
-
|
|
84
79
|
exports.replaceWithRegex = replaceWithRegex;
|
|
85
|
-
|
|
86
80
|
const replaceUrlAsComponents = (originText, replacer, strict) => {
|
|
87
81
|
const matches = [...originText.matchAll(strict ? urlRegexStrict : urlRegexRough)];
|
|
88
82
|
const founds = matches.map(value => {
|
|
@@ -112,6 +106,5 @@ const replaceUrlAsComponents = (originText, replacer, strict) => {
|
|
|
112
106
|
});
|
|
113
107
|
return items;
|
|
114
108
|
};
|
|
115
|
-
|
|
116
109
|
exports.replaceUrlAsComponents = replaceUrlAsComponents;
|
|
117
110
|
//# sourceMappingURL=regex.js.map
|
|
@@ -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":"
|
|
1
|
+
{"version":3,"names":["require","shim","urlRegexStrict","exports","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(head, mid, tail);\n cursor = end;\n });\n return items;\n};\n"],"mappings":";;;;;;AAAA;AACAA,OAAO,CAAC,2BAA2B,CAAC,CAACC,IAAI,EAAE;AAEpC,MAAMC,cAAc,GACzB,qIAAqI;AAACC,OAAA,CAAAD,cAAA,GAAAA,cAAA;AACjI,MAAME,aAAa,GACxB,uGAAuG;AAACD,OAAA,CAAAC,aAAA,GAAAA,aAAA;AACnG,MAAMC,UAAU,GAAG,sDAAsD;AAACF,OAAA,CAAAE,UAAA,GAAAA,UAAA;AAC1E,MAAMC,UAAU,GAAG,cAAc;AAACH,OAAA,CAAAG,UAAA,GAAAA,UAAA;AAClC,MAAMC,YAAY,GAAG,aAAa;AAACJ,OAAA,CAAAI,YAAA,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AAC;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;AAACxB,OAAA,CAAAoC,sBAAA,GAAAA,sBAAA"}
|
|
@@ -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":""}
|