@sendbird/uikit-utils 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/lib/commonjs/hooks/index.js +14 -1
  2. package/lib/commonjs/hooks/index.js.map +1 -1
  3. package/lib/commonjs/index.js +24 -1
  4. package/lib/commonjs/index.js.map +1 -1
  5. package/lib/commonjs/sendbird/channel.js +7 -1
  6. package/lib/commonjs/sendbird/channel.js.map +1 -1
  7. package/lib/commonjs/sendbird/message.js +12 -2
  8. package/lib/commonjs/sendbird/message.js.map +1 -1
  9. package/lib/commonjs/sendbird/user.js +5 -0
  10. package/lib/commonjs/sendbird/user.js.map +1 -1
  11. package/lib/commonjs/shared/regex.js +52 -6
  12. package/lib/commonjs/shared/regex.js.map +1 -1
  13. package/lib/commonjs/shared/replace.js +14 -0
  14. package/lib/commonjs/shared/replace.js.map +1 -0
  15. package/lib/commonjs/types.js +3 -1
  16. package/lib/commonjs/types.js.map +1 -1
  17. package/lib/commonjs/ui-format/common.js +17 -14
  18. package/lib/commonjs/ui-format/common.js.map +1 -1
  19. package/lib/commonjs/ui-format/groupChannel.js +7 -10
  20. package/lib/commonjs/ui-format/groupChannel.js.map +1 -1
  21. package/lib/module/hooks/index.js +10 -0
  22. package/lib/module/hooks/index.js.map +1 -1
  23. package/lib/module/index.js +2 -1
  24. package/lib/module/index.js.map +1 -1
  25. package/lib/module/sendbird/channel.js +3 -0
  26. package/lib/module/sendbird/channel.js.map +1 -1
  27. package/lib/module/sendbird/message.js +9 -3
  28. package/lib/module/sendbird/message.js.map +1 -1
  29. package/lib/module/sendbird/user.js +3 -0
  30. package/lib/module/sendbird/user.js.map +1 -1
  31. package/lib/module/shared/regex.js +43 -3
  32. package/lib/module/shared/regex.js.map +1 -1
  33. package/lib/module/shared/replace.js +6 -0
  34. package/lib/module/shared/replace.js.map +1 -0
  35. package/lib/module/types.js +1 -4
  36. package/lib/module/types.js.map +1 -1
  37. package/lib/module/ui-format/common.js +12 -7
  38. package/lib/module/ui-format/common.js.map +1 -1
  39. package/lib/module/ui-format/groupChannel.js +5 -4
  40. package/lib/module/ui-format/groupChannel.js.map +1 -1
  41. package/lib/typescript/src/hooks/index.d.ts +3 -2
  42. package/lib/typescript/src/index.d.ts +3 -2
  43. package/lib/typescript/src/sendbird/channel.d.ts +1 -0
  44. package/lib/typescript/src/sendbird/message.d.ts +4 -2
  45. package/lib/typescript/src/sendbird/user.d.ts +2 -0
  46. package/lib/typescript/src/shared/bufferedRequest.d.ts +1 -1
  47. package/lib/typescript/src/shared/logger.d.ts +1 -1
  48. package/lib/typescript/src/shared/pubsub.d.ts +2 -2
  49. package/lib/typescript/src/shared/regex.d.ts +8 -0
  50. package/lib/typescript/src/shared/replace.d.ts +2 -0
  51. package/lib/typescript/src/types.d.ts +42 -36
  52. package/lib/typescript/src/ui-format/common.d.ts +7 -6
  53. package/package.json +3 -3
  54. package/src/hooks/index.ts +11 -0
  55. package/src/index.ts +8 -0
  56. package/src/sendbird/channel.ts +4 -0
  57. package/src/sendbird/message.ts +13 -3
  58. package/src/sendbird/user.ts +6 -0
  59. package/src/shared/regex.ts +35 -0
  60. package/src/shared/replace.ts +5 -0
  61. package/src/types.ts +20 -3
  62. package/src/ui-format/common.ts +9 -7
  63. package/src/ui-format/groupChannel.ts +5 -4
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.useUniqId = exports.useIsMountedRef = exports.useIIFE = exports.useFreshCallback = exports.useForceUpdate = exports.useAsyncLayoutEffect = exports.useAsyncEffect = void 0;
6
+ exports.useUniqId = exports.useIsMountedRef = exports.useIsFirstMount = exports.useIIFE = exports.useFreshCallback = exports.useForceUpdate = exports.useAsyncLayoutEffect = exports.useAsyncEffect = void 0;
7
7
 
8
8
  var _react = require("react");
9
9
 
@@ -74,6 +74,19 @@ const useIsMountedRef = () => {
74
74
 
75
75
  exports.useIsMountedRef = useIsMountedRef;
76
76
 
77
+ const useIsFirstMount = () => {
78
+ const isFirstMount = (0, _react.useRef)(true);
79
+
80
+ if (isFirstMount.current) {
81
+ isFirstMount.current = false;
82
+ return true;
83
+ }
84
+
85
+ return isFirstMount.current;
86
+ };
87
+
88
+ exports.useIsFirstMount = useIsFirstMount;
89
+
77
90
  const useFreshCallback = callback => {
78
91
  const ref = (0, _react.useRef)(callback);
79
92
  ref.current = callback;
@@ -1 +1 @@
1
- {"version":3,"names":["idPool","useUniqId","key","useState","useForceUpdate","updater","useCallback","prev","useAsyncEffect","asyncEffect","deps","useEffect","createAsyncEffectCallback","useAsyncLayoutEffect","useLayoutEffect","useIIFE","callback","iife","destructor","Promise","awaitedDestructor","useIsMountedRef","isMounted","useRef","current","useFreshCallback","ref"],"sources":["index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { DependencyList } from 'react';\nimport { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';\n\ntype Destructor = () => void;\ntype AsyncEffectCallback = () => void | Destructor | Promise<void> | Promise<Destructor>;\n\nconst idPool: { [key: string]: number } = {};\nexport const useUniqId = (key: string) => {\n return useState(() => {\n if (!idPool[key]) idPool[key] = 1;\n return idPool[key]++;\n })[0];\n};\n\nexport const useForceUpdate = () => {\n const [, updater] = useState(0);\n return useCallback(() => updater((prev) => prev + 1), []);\n};\n\nexport const useAsyncEffect = (asyncEffect: AsyncEffectCallback, deps?: DependencyList) => {\n useEffect(createAsyncEffectCallback(asyncEffect), deps);\n};\nexport const useAsyncLayoutEffect = (asyncEffect: AsyncEffectCallback, deps?: DependencyList) => {\n useLayoutEffect(createAsyncEffectCallback(asyncEffect), deps);\n};\nexport const useIIFE = <T>(callback: () => T) => {\n return iife(callback);\n};\nconst iife = <T extends (...args: any[]) => any>(callback: T): ReturnType<T> => callback();\nconst createAsyncEffectCallback = (asyncEffect: AsyncEffectCallback) => () => {\n const destructor = iife(asyncEffect);\n return () => {\n if (!destructor) return;\n\n if (destructor instanceof Promise) {\n iife(async () => {\n const awaitedDestructor = await destructor;\n if (awaitedDestructor) awaitedDestructor();\n });\n } else {\n iife(destructor);\n }\n };\n};\n\nexport const useIsMountedRef = () => {\n const isMounted = useRef(true);\n\n useEffect(() => {\n return () => {\n isMounted.current = false;\n };\n }, []);\n\n return isMounted;\n};\n\nexport const useFreshCallback = <T extends (...args: any[]) => any>(callback: T): T => {\n const ref = useRef<T>(callback);\n ref.current = callback;\n return useCallback(((...args) => ref.current(...args)) as T, []);\n};\n"],"mappings":";;;;;;;AAEA;;AAFA;AAOA,MAAMA,MAAiC,GAAG,EAA1C;;AACO,MAAMC,SAAS,GAAIC,GAAD,IAAiB;EACxC,OAAO,IAAAC,eAAA,EAAS,MAAM;IACpB,IAAI,CAACH,MAAM,CAACE,GAAD,CAAX,EAAkBF,MAAM,CAACE,GAAD,CAAN,GAAc,CAAd;IAClB,OAAOF,MAAM,CAACE,GAAD,CAAN,EAAP;EACD,CAHM,EAGJ,CAHI,CAAP;AAID,CALM;;;;AAOA,MAAME,cAAc,GAAG,MAAM;EAClC,MAAM,GAAGC,OAAH,IAAc,IAAAF,eAAA,EAAS,CAAT,CAApB;EACA,OAAO,IAAAG,kBAAA,EAAY,MAAMD,OAAO,CAAEE,IAAD,IAAUA,IAAI,GAAG,CAAlB,CAAzB,EAA+C,EAA/C,CAAP;AACD,CAHM;;;;AAKA,MAAMC,cAAc,GAAG,CAACC,WAAD,EAAmCC,IAAnC,KAA6D;EACzF,IAAAC,gBAAA,EAAUC,yBAAyB,CAACH,WAAD,CAAnC,EAAkDC,IAAlD;AACD,CAFM;;;;AAGA,MAAMG,oBAAoB,GAAG,CAACJ,WAAD,EAAmCC,IAAnC,KAA6D;EAC/F,IAAAI,sBAAA,EAAgBF,yBAAyB,CAACH,WAAD,CAAzC,EAAwDC,IAAxD;AACD,CAFM;;;;AAGA,MAAMK,OAAO,GAAOC,QAAJ,IAA0B;EAC/C,OAAOC,IAAI,CAACD,QAAD,CAAX;AACD,CAFM;;;;AAGP,MAAMC,IAAI,GAAuCD,QAApC,IAAmEA,QAAQ,EAAxF;;AACA,MAAMJ,yBAAyB,GAAIH,WAAD,IAAsC,MAAM;EAC5E,MAAMS,UAAU,GAAGD,IAAI,CAACR,WAAD,CAAvB;EACA,OAAO,MAAM;IACX,IAAI,CAACS,UAAL,EAAiB;;IAEjB,IAAIA,UAAU,YAAYC,OAA1B,EAAmC;MACjCF,IAAI,CAAC,YAAY;QACf,MAAMG,iBAAiB,GAAG,MAAMF,UAAhC;QACA,IAAIE,iBAAJ,EAAuBA,iBAAiB;MACzC,CAHG,CAAJ;IAID,CALD,MAKO;MACLH,IAAI,CAACC,UAAD,CAAJ;IACD;EACF,CAXD;AAYD,CAdD;;AAgBO,MAAMG,eAAe,GAAG,MAAM;EACnC,MAAMC,SAAS,GAAG,IAAAC,aAAA,EAAO,IAAP,CAAlB;EAEA,IAAAZ,gBAAA,EAAU,MAAM;IACd,OAAO,MAAM;MACXW,SAAS,CAACE,OAAV,GAAoB,KAApB;IACD,CAFD;EAGD,CAJD,EAIG,EAJH;EAMA,OAAOF,SAAP;AACD,CAVM;;;;AAYA,MAAMG,gBAAgB,GAAuCT,QAApC,IAAuD;EACrF,MAAMU,GAAG,GAAG,IAAAH,aAAA,EAAUP,QAAV,CAAZ;EACAU,GAAG,CAACF,OAAJ,GAAcR,QAAd;EACA,OAAO,IAAAV,kBAAA,EAAa;IAAA,OAAaoB,GAAG,CAACF,OAAJ,CAAY,YAAZ,CAAb;EAAA,CAAb,EAAsD,EAAtD,CAAP;AACD,CAJM"}
1
+ {"version":3,"names":["idPool","useUniqId","key","useState","useForceUpdate","updater","useCallback","prev","useAsyncEffect","asyncEffect","deps","useEffect","createAsyncEffectCallback","useAsyncLayoutEffect","useLayoutEffect","useIIFE","callback","iife","destructor","Promise","awaitedDestructor","useIsMountedRef","isMounted","useRef","current","useIsFirstMount","isFirstMount","useFreshCallback","ref"],"sources":["index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { DependencyList } from 'react';\nimport { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';\n\ntype Destructor = () => void;\ntype AsyncEffectCallback = () => void | Destructor | Promise<void> | Promise<Destructor>;\n\nconst idPool: { [key: string]: number } = {};\nexport const useUniqId = (key: string) => {\n return useState(() => {\n if (!idPool[key]) idPool[key] = 1;\n return idPool[key]++;\n })[0];\n};\n\nexport const useForceUpdate = () => {\n const [, updater] = useState(0);\n return useCallback(() => updater((prev) => prev + 1), []);\n};\n\nexport const useAsyncEffect = (asyncEffect: AsyncEffectCallback, deps?: DependencyList) => {\n useEffect(createAsyncEffectCallback(asyncEffect), deps);\n};\nexport const useAsyncLayoutEffect = (asyncEffect: AsyncEffectCallback, deps?: DependencyList) => {\n useLayoutEffect(createAsyncEffectCallback(asyncEffect), deps);\n};\nexport const useIIFE = <T>(callback: () => T) => {\n return iife(callback);\n};\nconst iife = <T extends (...args: any[]) => any>(callback: T): ReturnType<T> => callback();\nconst createAsyncEffectCallback = (asyncEffect: AsyncEffectCallback) => () => {\n const destructor = iife(asyncEffect);\n return () => {\n if (!destructor) return;\n\n if (destructor instanceof Promise) {\n iife(async () => {\n const awaitedDestructor = await destructor;\n if (awaitedDestructor) awaitedDestructor();\n });\n } else {\n iife(destructor);\n }\n };\n};\n\nexport const useIsMountedRef = () => {\n const isMounted = useRef(true);\n\n useEffect(() => {\n return () => {\n isMounted.current = false;\n };\n }, []);\n\n return isMounted;\n};\n\nexport const useIsFirstMount = () => {\n const isFirstMount = useRef(true);\n\n if (isFirstMount.current) {\n isFirstMount.current = false;\n return true;\n }\n\n return isFirstMount.current;\n};\n\nexport const useFreshCallback = <T extends (...args: any[]) => any>(callback: T): T => {\n const ref = useRef<T>(callback);\n ref.current = callback;\n return useCallback(((...args) => ref.current(...args)) as T, []);\n};\n"],"mappings":";;;;;;;AAEA;;AAFA;AAOA,MAAMA,MAAiC,GAAG,EAA1C;;AACO,MAAMC,S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;MACLH,IAAI,CAACC,UAAD,CAAJ;IACD;EACF,CAXD;AAYD,CAdD;;AAgBO,MAAMG,eAAe,GAAG,MAAM;EACnC,MAAMC,SAAS,GAAG,IAAAC,aAAA,EAAO,IAAP,CAAlB;EAEA,IAAAZ,gBAAA,EAAU,MAAM;IACd,OAAO,MAAM;MACXW,SAAS,CAACE,OAAV,GAAoB,KAApB;IACD,CAFD;EAGD,CAJD,EAIG,EAJH;EAMA,OAAOF,SAAP;AACD,CAVM;;;;AAYA,MAAMG,eAAe,GAAG,MAAM;EACnC,MAAMC,YAAY,GAAG,IAAAH,aAAA,EAAO,IAAP,CAArB;;EAEA,IAAIG,YAAY,CAACF,OAAjB,EAA0B;IACxBE,YAAY,CAACF,OAAb,GAAuB,KAAvB;IACA,OAAO,IAAP;EACD;;EAED,OAAOE,YAAY,CAACF,OAApB;AACD,CATM;;;;AAWA,MAAMG,gBAAgB,GAAuCX,QAApC,IAAuD;EACrF,MAAMY,GAAG,GAAG,IAAAL,aAAA,EAAUP,QAAV,CAAZ;EACAY,GAAG,CAACJ,OAAJ,GAAcR,QAAd;EACA,OAAO,IAAAV,kBAAA,EAAa;IAAA,OAAasB,GAAG,CAACJ,OAAJ,CAAY,YAAZ,CAAb;EAAA,CAAb,EAAsD,EAAtD,CAAP;AACD,CAJM"}
@@ -28,7 +28,10 @@ var _exportNames = {
28
28
  normalizeFileName: true,
29
29
  emailRegex: true,
30
30
  phoneRegex: true,
31
- BufferedRequest: true
31
+ replaceWithRegex: true,
32
+ createMentionTemplateRegex: true,
33
+ BufferedRequest: true,
34
+ replace: true
32
35
  };
33
36
  exports.ASYNC_NOOP = void 0;
34
37
  Object.defineProperty(exports, "BufferedRequest", {
@@ -68,6 +71,12 @@ Object.defineProperty(exports, "conditionChaining", {
68
71
  return _conditionChaining.default;
69
72
  }
70
73
  });
74
+ Object.defineProperty(exports, "createMentionTemplateRegex", {
75
+ enumerable: true,
76
+ get: function () {
77
+ return _regex.createMentionTemplateRegex;
78
+ }
79
+ });
71
80
  Object.defineProperty(exports, "createPubSub", {
72
81
  enumerable: true,
73
82
  get: function () {
@@ -117,12 +126,24 @@ Object.defineProperty(exports, "phoneRegex", {
117
126
  return _regex.phoneRegex;
118
127
  }
119
128
  });
129
+ Object.defineProperty(exports, "replace", {
130
+ enumerable: true,
131
+ get: function () {
132
+ return _replace.default;
133
+ }
134
+ });
120
135
  Object.defineProperty(exports, "replaceUrlAsComponents", {
121
136
  enumerable: true,
122
137
  get: function () {
123
138
  return _regex.replaceUrlAsComponents;
124
139
  }
125
140
  });
141
+ Object.defineProperty(exports, "replaceWithRegex", {
142
+ enumerable: true,
143
+ get: function () {
144
+ return _regex.replaceWithRegex;
145
+ }
146
+ });
126
147
  exports.toMegabyte = void 0;
127
148
  Object.defineProperty(exports, "urlRegexRough", {
128
149
  enumerable: true,
@@ -155,6 +176,8 @@ var _regex = require("./shared/regex");
155
176
 
156
177
  var _bufferedRequest = require("./shared/bufferedRequest");
157
178
 
179
+ var _replace = _interopRequireDefault(require("./shared/replace"));
180
+
158
181
  var _hooks = require("./hooks");
159
182
 
160
183
  Object.keys(_hooks).forEach(function (key) {
@@ -1 +1 @@
1
- {"version":3,"names":["NOOP","ASYNC_NOOP","PASS","val","toMegabyte","byte","isFunction","param","SBErrorCode","NON_AUTHORIZED","SBErrorMessage","ACL"],"sources":["index.ts"],"sourcesContent":["export { Logger } from './shared/logger';\nexport { default as arrayToMap, arrayToMapWithGetter } from './shared/arrayToMap';\nexport { createPubSub } from './shared/pubsub';\nexport { default as conditionChaining } from './shared/conditionChaining';\nexport {\n urlRegexStrict,\n urlRegexRough,\n newLineRegex,\n audioExtRegex,\n videoExtRegex,\n imageExtRegex,\n getFileType,\n getFileExtension,\n replaceUrlAsComponents,\n normalizeFileName,\n emailRegex,\n phoneRegex,\n} from './shared/regex';\nexport { BufferedRequest } from './shared/bufferedRequest';\n\nexport * from './hooks';\nexport * from './ui-format/groupChannel';\nexport * from './ui-format/common';\nexport * from './sendbird/channel';\nexport * from './sendbird/message';\nexport * from './sendbird/attrs';\nexport * from './sendbird/user';\n\nexport const NOOP: () => void = () => void 0;\nexport const ASYNC_NOOP = async () => void 0;\nexport const PASS = <T>(val: T) => val;\nexport const toMegabyte = (byte: number) => byte / 1024 / 1024;\nexport const isFunction = <T>(param?: T): param is NonNullable<T> => typeof param === 'function';\nexport const SBErrorCode = {\n NON_AUTHORIZED: 400108,\n};\nexport const SBErrorMessage = {\n ACL:\n 'Sendbird provides various access control options when using the Chat SDK.\\n' +\n 'By default, the Allow retrieving user list attribute is turned on to facilitate creating sample apps.\\n' +\n 'However, this may grant access to unwanted data or operations, leading to potential security concerns.\\n' +\n 'To manage your access control settings, you can turn on or off each setting on Sendbird Dashboard.',\n};\n\nexport type {\n FilterByValueType,\n UnionToIntersection,\n OmittedValues,\n PartialDeep,\n Optional,\n ContextValue,\n SendbirdMessage,\n SendbirdChatSDK,\n SendbirdChannel,\n SendbirdBaseChannel,\n SendbirdGroupChannel,\n SendbirdOpenChannel,\n SendbirdUser,\n SendbirdMember,\n SendbirdBaseMessage,\n SendbirdUserMessage,\n SendbirdFileMessage,\n SendbirdAdminMessage,\n SendbirdGroupChannelCreateParams,\n SendbirdFileMessageCreateParams,\n SendbirdUserMessageCreateParams,\n SendbirdError,\n SendbirdMessageCollection,\n SendbirdGroupChannelCollection,\n NotificationFiles,\n NotificationMentionedUsers,\n NotificationTranslations,\n PartialNullable,\n SendbirdDataPayload,\n SendbirdPreviousMessageListQuery,\n SendbirdSendableMessage,\n SendbirdGroupChannelListQuery,\n SendbirdGroupChannelUpdateParams,\n SendbirdUserMessageUpdateParams,\n SendbirdFileMessageUpdateParams,\n SendbirdUserUpdateParams,\n SendbirdRestrictedUser,\n} from './types';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAcA;;AAEA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;;;;;;;AAEO,MAAMA,IAAgB,GAAG,MAAM,KAAK,CAApC;;;;AACA,MAAMC,UAAU,GAAG,YAAY,KAAK,CAApC;;;;AACA,MAAMC,IAAI,GAAOC,GAAJ,IAAeA,GAA5B;;;;AACA,MAAMC,UAAU,GAAIC,IAAD,IAAkBA,IAAI,GAAG,IAAP,GAAc,IAAnD;;;;AACA,MAAMC,UAAU,GAAOC,KAAJ,IAA2C,OAAOA,KAAP,KAAiB,UAA/E;;;AACA,MAAMC,WAAW,GAAG;EACzBC,cAAc,EAAE;AADS,CAApB;;AAGA,MAAMC,cAAc,GAAG;EAC5BC,GAAG,EACD,gFACA,yGADA,GAEA,0GAFA,GAGA;AAL0B,CAAvB"}
1
+ {"version":3,"names":["NOOP","ASYNC_NOOP","PASS","val","toMegabyte","byte","isFunction","param","SBErrorCode","NON_AUTHORIZED","SBErrorMessage","ACL"],"sources":["index.ts"],"sourcesContent":["export { Logger } from './shared/logger';\nexport { default as arrayToMap, arrayToMapWithGetter } from './shared/arrayToMap';\nexport { createPubSub } from './shared/pubsub';\nexport { default as conditionChaining } from './shared/conditionChaining';\nexport {\n urlRegexStrict,\n urlRegexRough,\n newLineRegex,\n audioExtRegex,\n videoExtRegex,\n imageExtRegex,\n getFileType,\n getFileExtension,\n replaceUrlAsComponents,\n normalizeFileName,\n emailRegex,\n phoneRegex,\n replaceWithRegex,\n createMentionTemplateRegex,\n} from './shared/regex';\nexport { BufferedRequest } from './shared/bufferedRequest';\nexport { default as replace } from './shared/replace';\n\nexport * from './hooks';\nexport * from './ui-format/groupChannel';\nexport * from './ui-format/common';\nexport * from './sendbird/channel';\nexport * from './sendbird/message';\nexport * from './sendbird/attrs';\nexport * from './sendbird/user';\n\nexport const NOOP: () => void = () => void 0;\nexport const ASYNC_NOOP = async () => void 0;\nexport const PASS = <T>(val: T) => val;\nexport const toMegabyte = (byte: number) => byte / 1024 / 1024;\nexport const isFunction = <T>(param?: T): param is NonNullable<T> => typeof param === 'function';\nexport const SBErrorCode = {\n NON_AUTHORIZED: 400108,\n};\nexport const SBErrorMessage = {\n ACL:\n 'Sendbird provides various access control options when using the Chat SDK.\\n' +\n 'By default, the Allow retrieving user list attribute is turned on to facilitate creating sample apps.\\n' +\n 'However, this may grant access to unwanted data or operations, leading to potential security concerns.\\n' +\n 'To manage your access control settings, you can turn on or off each setting on Sendbird Dashboard.',\n};\n\nexport type {\n UserStruct,\n FilterByValueType,\n UnionToIntersection,\n OmittedValues,\n PartialDeep,\n Optional,\n ContextValue,\n SendbirdMessage,\n SendbirdChatSDK,\n SendbirdChannel,\n SendbirdBaseChannel,\n SendbirdGroupChannel,\n SendbirdOpenChannel,\n SendbirdUser,\n SendbirdMember,\n SendbirdBaseMessage,\n SendbirdUserMessage,\n SendbirdFileMessage,\n SendbirdAdminMessage,\n SendbirdGroupChannelCreateParams,\n SendbirdFileMessageCreateParams,\n SendbirdUserMessageCreateParams,\n SendbirdError,\n SendbirdMessageCollection,\n SendbirdGroupChannelCollection,\n NotificationFiles,\n NotificationMentionedUsers,\n NotificationTranslations,\n PartialNullable,\n SendbirdDataPayload,\n SendbirdPreviousMessageListQuery,\n SendbirdSendableMessage,\n SendbirdGroupChannelListQuery,\n SendbirdGroupChannelUpdateParams,\n SendbirdUserMessageUpdateParams,\n SendbirdFileMessageUpdateParams,\n SendbirdUserUpdateParams,\n SendbirdRestrictedUser,\n SendbirdReaction,\n SendbirdEmojiContainer,\n SendbirdEmoji,\n SendbirdEmojiCategory,\n} from './types';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAgBA;;AACA;;AAEA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;;;;;;;AAEO,MAAMA,IAAgB,GAAG,MAAM,KAAK,CAApC;;;;AACA,MAAMC,UAAU,GAAG,YAAY,KAAK,CAApC;;;;AACA,MAAMC,IAAI,GAAOC,GAAJ,IAAeA,GAA5B;;;;AACA,MAAMC,UAAU,GAAIC,IAAD,IAAkBA,IAAI,GAAG,IAAP,GAAc,IAAnD;;;;AACA,MAAMC,UAAU,GAAOC,KAAJ,IAA2C,OAAOA,KAAP,KAAiB,UAA/E;;;AACA,MAAMC,WAAW,GAAG;EACzBC,cAAc,EAAE;AADS,CAApB;;AAGA,MAAMC,cAAc,GAAG;EAC5BC,GAAG,EACD,gFACA,yGADA,GAEA,0GAFA,GAGA;AAL0B,CAAvB"}
@@ -3,7 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getGroupChannelChatAvailableState = exports.confirmAndMarkAsRead = exports.confirmAndMarkAsDelivered = void 0;
6
+ exports.confirmAndMarkAsRead = exports.confirmAndMarkAsDelivered = void 0;
7
+ exports.getChannelUniqId = getChannelUniqId;
8
+ exports.getGroupChannelChatAvailableState = void 0;
7
9
  exports.getGroupChannels = getGroupChannels;
8
10
  exports.getMembersExcludeMe = getMembersExcludeMe;
9
11
  exports.getOpenChannels = getOpenChannels;
@@ -63,4 +65,8 @@ function getGroupChannels(channels) {
63
65
  function getOpenChannels(channels) {
64
66
  return channels.filter(c => c.isOpenChannel());
65
67
  }
68
+
69
+ function getChannelUniqId(channel) {
70
+ return channel.url;
71
+ }
66
72
  //# sourceMappingURL=channel.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["isDifferentChannel","a","b","url","getGroupChannelChatAvailableState","channel","frozen","isFrozen","myRole","muted","myMutedState","disabled","confirmAndMarkAsRead","channels","filter","it","isGroupChannel","unreadMessageCount","forEach","BufferedRequest","markAsRead","push","confirmAndMarkAsDelivered","markAsDelivered","isDefaultCoverImage","coverUrl","startsWith","getMembersExcludeMe","currentUserId","members","m","userId","getGroupChannels","c","getOpenChannels","isOpenChannel"],"sources":["channel.ts"],"sourcesContent":["import { BufferedRequest } from '../shared/bufferedRequest';\nimport type { SendbirdBaseChannel, SendbirdChannel, SendbirdGroupChannel, SendbirdOpenChannel } from '../types';\n\n/**\n * Diff utils for channel\n * @param {SendbirdBaseChannel} [a]\n * @param {SendbirdBaseChannel} [b]\n * @returns {boolean}\n * */\nexport function isDifferentChannel<T extends SendbirdBaseChannel>(a?: T, b?: T): boolean {\n if (!a || !b) return true;\n return a.url !== b.url;\n}\n\nexport const getGroupChannelChatAvailableState = (channel: SendbirdGroupChannel) => {\n const frozen = channel.isFrozen && channel.myRole !== 'operator';\n const muted = channel.myMutedState === 'muted';\n const disabled = frozen || muted;\n return { disabled, frozen, muted };\n};\n\nexport const confirmAndMarkAsRead = async (channels: SendbirdBaseChannel[]) => {\n channels\n .filter((it): it is SendbirdGroupChannel => it.isGroupChannel() && it.unreadMessageCount > 0)\n .forEach((it) => BufferedRequest.markAsRead.push(() => it.markAsRead(), it.url));\n};\n\nexport const confirmAndMarkAsDelivered = async (channels: SendbirdBaseChannel[]) => {\n channels\n .filter((it): it is SendbirdGroupChannel => it.isGroupChannel() && it.unreadMessageCount > 0)\n .forEach((it) => BufferedRequest.markAsDelivered.push(() => it.markAsDelivered(), it.url));\n};\n\nexport function isDefaultCoverImage(coverUrl: string) {\n return coverUrl === '' || coverUrl.startsWith('https://static.sendbird.com/sample/cover');\n}\n\nexport function getMembersExcludeMe(channel: SendbirdGroupChannel, currentUserId?: string) {\n return channel.members.filter((m) => m.userId !== currentUserId);\n}\n\nexport function getGroupChannels(channels: SendbirdChannel[]): SendbirdGroupChannel[] {\n return channels.filter((c): c is SendbirdGroupChannel => c.isGroupChannel());\n}\n\nexport function getOpenChannels(channels: SendbirdChannel[]): SendbirdOpenChannel[] {\n return channels.filter((c): c is SendbirdOpenChannel => c.isOpenChannel());\n}\n"],"mappings":";;;;;;;;;;;;AAAA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,kBAAT,CAA2DC,CAA3D,EAAkEC,CAAlE,EAAkF;EACvF,IAAI,CAACD,CAAD,IAAM,CAACC,CAAX,EAAc,OAAO,IAAP;EACd,OAAOD,CAAC,CAACE,GAAF,KAAUD,CAAC,CAACC,GAAnB;AACD;;AAEM,MA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AP;AACD;;AAEM,SAASI,gBAAT,CAA0BnB,QAA1B,EAA+E;EACpF,OAAOA,QAAQ,CAACC,MAAT,CAAiBmB,CAAD,IAAkCA,CAAC,CAACjB,cAAF,EAAlD,CAAP;AACD;;AAEM,SAASkB,eAAT,CAAyBrB,QAAzB,EAA6E;EAClF,OAAOA,QAAQ,CAACC,MAAT,CAAiBmB,CAAD,IAAiCA,CAAC,CAACE,aAAF,EAAjD,CAAP;AACD"}
1
+ {"version":3,"names":["isDifferentChannel","a","b","url","getGroupChannelChatAvailableState","channel","frozen","isFrozen","myRole","muted","myMutedState","disabled","confirmAndMarkAsRead","channels","filter","it","isGroupChannel","unreadMessageCount","forEach","BufferedRequest","markAsRead","push","confirmAndMarkAsDelivered","markAsDelivered","isDefaultCoverImage","coverUrl","startsWith","getMembersExcludeMe","currentUserId","members","m","userId","getGroupChannels","c","getOpenChannels","isOpenChannel","getChannelUniqId"],"sources":["channel.ts"],"sourcesContent":["import { BufferedRequest } from '../shared/bufferedRequest';\nimport type { SendbirdBaseChannel, SendbirdChannel, SendbirdGroupChannel, SendbirdOpenChannel } from '../types';\n\n/**\n * Diff utils for channel\n * @param {SendbirdBaseChannel} [a]\n * @param {SendbirdBaseChannel} [b]\n * @returns {boolean}\n * */\nexport function isDifferentChannel<T extends SendbirdBaseChannel>(a?: T, b?: T): boolean {\n if (!a || !b) return true;\n return a.url !== b.url;\n}\n\nexport const getGroupChannelChatAvailableState = (channel: SendbirdGroupChannel) => {\n const frozen = channel.isFrozen && channel.myRole !== 'operator';\n const muted = channel.myMutedState === 'muted';\n const disabled = frozen || muted;\n return { disabled, frozen, muted };\n};\n\nexport const confirmAndMarkAsRead = async (channels: SendbirdBaseChannel[]) => {\n channels\n .filter((it): it is SendbirdGroupChannel => it.isGroupChannel() && it.unreadMessageCount > 0)\n .forEach((it) => BufferedRequest.markAsRead.push(() => it.markAsRead(), it.url));\n};\n\nexport const confirmAndMarkAsDelivered = async (channels: SendbirdBaseChannel[]) => {\n channels\n .filter((it): it is SendbirdGroupChannel => it.isGroupChannel() && it.unreadMessageCount > 0)\n .forEach((it) => BufferedRequest.markAsDelivered.push(() => it.markAsDelivered(), it.url));\n};\n\nexport function isDefaultCoverImage(coverUrl: string) {\n return coverUrl === '' || coverUrl.startsWith('https://static.sendbird.com/sample/cover');\n}\n\nexport function getMembersExcludeMe(channel: SendbirdGroupChannel, currentUserId?: string) {\n return channel.members.filter((m) => m.userId !== currentUserId);\n}\n\nexport function getGroupChannels(channels: SendbirdChannel[]): SendbirdGroupChannel[] {\n return channels.filter((c): c is SendbirdGroupChannel => c.isGroupChannel());\n}\n\nexport function getOpenChannels(channels: SendbirdChannel[]): SendbirdOpenChannel[] {\n return channels.filter((c): c is SendbirdOpenChannel => c.isOpenChannel());\n}\n\nexport function getChannelUniqId(channel: SendbirdChannel) {\n return channel.url;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,kBAAT,CAA2DC,CAA3D,EAAkEC,CAAlE,EAAkF;EACvF,IAAI,CAACD,CAAD,IAAM,CAACC,CAAX,EAAc,OAAO,IAAP;EACd,OAAOD,CAAC,CAACE,GAAF,KAAUD,CAAC,CAACC,GAAnB;AACD;;AAEM,MAAMC,iCAAiC,GAAIC,OAAD,IAAmC;EAClF,MAAMC,MAAM,GAAGD,OAAO,CAACE,QAAR,IAAoBF,OAAO,CAACG,MAAR,KAAmB,UAAtD;EACA,MAAMC,KAAK,GAAGJ,OAAO,CAACK,YAAR,KAAyB,OAAvC;EACA,MAAMC,QAAQ,GAAGL,MAAM,IAAIG,KAA3B;EACA,OAAO;IAAEE,QAAF;IAAYL,MAAZ;IAAoBG;EAApB,CAAP;AACD,CALM;;;;AAOA,MAAMG,oBAAoB,GAAG,MAAOC,QAAP,IAA2C;EAC7EA,QAAQ,CACLC,MADH,CACWC,EAAD,IAAoCA,EAAE,CAACC,cAAH,MAAuBD,EAAE,CAACE,kBAAH,GAAwB,CAD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
  exports.getAvailableUriFromFileMessage = getAvailableUriFromFileMessage;
8
8
  exports.getMessageUniqId = getMessageUniqId;
9
+ exports.getReactionCount = getReactionCount;
9
10
  exports.hasSameSender = hasSameSender;
10
11
  exports.isMyMessage = isMyMessage;
11
12
  exports.isNewMessage = isNewMessage;
@@ -14,6 +15,7 @@ exports.isSendbirdNotification = isSendbirdNotification;
14
15
  exports.messageComparator = messageComparator;
15
16
  exports.messageKeyExtractor = messageKeyExtractor;
16
17
  exports.parseSendbirdNotification = parseSendbirdNotification;
18
+ exports.shouldRenderReaction = shouldRenderReaction;
17
19
 
18
20
  var _common = require("../ui-format/common");
19
21
 
@@ -70,7 +72,7 @@ function calcMessageGrouping(groupEnabled, curr, prev, next) {
70
72
  if (!prev) return false;
71
73
  if (curr.isAdminMessage()) return false;
72
74
  if (!hasSameSender(curr, prev)) return false;
73
- if ((0, _common.messageTime)(new Date(curr.createdAt)) !== (0, _common.messageTime)(new Date(prev.createdAt))) return false;
75
+ if ((0, _common.getMessageTimeFormat)(new Date(curr.createdAt)) !== (0, _common.getMessageTimeFormat)(new Date(prev.createdAt))) return false;
74
76
  return true;
75
77
  };
76
78
 
@@ -79,7 +81,7 @@ function calcMessageGrouping(groupEnabled, curr, prev, next) {
79
81
  if (!next) return false;
80
82
  if (curr.isAdminMessage()) return false;
81
83
  if (!hasSameSender(curr, next)) return false;
82
- if ((0, _common.messageTime)(new Date(curr.createdAt)) !== (0, _common.messageTime)(new Date(next.createdAt))) return false;
84
+ if ((0, _common.getMessageTimeFormat)(new Date(curr.createdAt)) !== (0, _common.getMessageTimeFormat)(new Date(next.createdAt))) return false;
83
85
  return true;
84
86
  };
85
87
 
@@ -114,4 +116,12 @@ function isSendbirdNotification(dataPayload) {
114
116
  function parseSendbirdNotification(dataPayload) {
115
117
  return typeof dataPayload.sendbird === 'string' ? JSON.parse(dataPayload.sendbird) : dataPayload.sendbird;
116
118
  }
119
+
120
+ function shouldRenderReaction(channel, reactionEnabled) {
121
+ return channel.isGroupChannel() && !channel.isBroadcast && !channel.isSuper && reactionEnabled;
122
+ }
123
+
124
+ function getReactionCount(reaction) {
125
+ return reaction.userIds.length;
126
+ }
117
127
  //# sourceMappingURL=message.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["isNewMessage","msg","currentUserId","myMessage","isMyMessage","isAdminMessage","updatedAt","isSendableMessage","undefined","sender","userId","sendingStatus","messageKeyExtractor","message","getMessageUniqId","messageComparator","a","b","aStatusOffset","bStatusOffset","createdAt","hasSameSender","calcMessageGrouping","groupEnabled","curr","prev","next","getPrev","messageTime","Date","getNext","groupWithPrev","groupWithNext","isUserMessage","isFileMessage","String","messageId","reqId","getAvailableUriFromFileMessage","url","messageParams","file","uri","isSendbirdNotification","dataPayload","Boolean","parseSendbirdNotification","sendbird","JSON","parse"],"sources":["message.ts"],"sourcesContent":["import type {\n SendbirdBaseMessage,\n SendbirdDataPayload,\n SendbirdFileMessage,\n SendbirdMessage,\n SendbirdSendableMessage,\n} from '../types';\nimport { messageTime } from '../ui-format/common';\n\nexport function isNewMessage(msg: SendbirdMessage, currentUserId?: string) {\n const myMessage = isMyMessage(msg, currentUserId);\n if (myMessage) return false;\n if (msg.isAdminMessage()) return false;\n return msg.updatedAt === 0;\n}\n\nexport function isSendableMessage(msg?: SendbirdMessage | null): msg is SendbirdSendableMessage {\n return msg !== undefined && msg !== null && 'sendingStatus' in msg;\n}\n\nexport function isMyMessage(msg?: SendbirdMessage | null, currentUserId = '##__USER_ID_IS_NOT_PROVIDED__##') {\n if (!isSendableMessage(msg)) return false;\n return (\n ('sender' in msg && msg.sender?.userId === currentUserId) ||\n msg.sendingStatus === 'pending' ||\n msg.sendingStatus === 'failed' ||\n msg.sendingStatus === 'canceled'\n );\n}\n\nexport function messageKeyExtractor(message: SendbirdMessage): string {\n return getMessageUniqId(message);\n}\n\n// |-------------------|-------------------|-----------------|-------------------|\n// | sending status | reqId | messageId | createdAt |\n// |-------------------|-------------------|-----------------|-------------------|\n// | pending | timestamp(A) | 0 | timestamp(B) |\n// | canceled | timestamp(A) | 0 | ? |\n// | failed | timestamp(A) | 0 | ? |\n// | succeeded | timestamp(A) / '' | id from DB | timestamp(C) |\n// |-------------------|-------------------|-----------------|-------------------|\nexport function messageComparator(a: SendbirdMessage, b: SendbirdMessage) {\n let aStatusOffset = 0;\n let bStatusOffset = 0;\n\n if (isSendableMessage(a) && a.sendingStatus !== 'succeeded') aStatusOffset = 999999;\n if (isSendableMessage(b) && b.sendingStatus !== 'succeeded') bStatusOffset = 999999;\n\n return b.createdAt + bStatusOffset - (a.createdAt + aStatusOffset);\n}\n\nexport function hasSameSender(a?: SendbirdMessage, b?: SendbirdMessage) {\n if (!a || !b) return false;\n if ('sender' in a && 'sender' in b) return a.sender?.userId === b.sender?.userId;\n return false;\n}\n\nexport function calcMessageGrouping(\n groupEnabled: boolean,\n curr: SendbirdMessage,\n prev?: SendbirdMessage,\n next?: SendbirdMessage,\n) {\n const getPrev = () => {\n if (!groupEnabled) return false;\n if (!prev) return false;\n if (curr.isAdminMessage()) return false;\n if (!hasSameSender(curr, prev)) return false;\n if (messageTime(new Date(curr.createdAt)) !== messageTime(new Date(prev.createdAt))) return false;\n return true;\n };\n\n const getNext = () => {\n if (!groupEnabled) return false;\n if (!next) return false;\n if (curr.isAdminMessage()) return false;\n if (!hasSameSender(curr, next)) return false;\n if (messageTime(new Date(curr.createdAt)) !== messageTime(new Date(next.createdAt))) return false;\n return true;\n };\n\n return { groupWithPrev: getPrev(), groupWithNext: getNext() };\n}\n\nexport function getMessageUniqId(msg: SendbirdBaseMessage) {\n if (msg.isUserMessage() || msg.isFileMessage()) {\n if (msg.sendingStatus === 'succeeded') return String(msg.messageId);\n return msg.reqId;\n }\n\n return String(msg.messageId);\n}\n\nexport function getAvailableUriFromFileMessage(message: SendbirdFileMessage) {\n if (!message.url && message.messageParams.file && 'uri' in message.messageParams.file) {\n return message.messageParams.file.uri;\n }\n return message.url;\n}\n\ntype RawSendbirdDataPayload = { sendbird: string | object };\nexport function isSendbirdNotification(dataPayload?: {\n [key: string]: string | object;\n}): dataPayload is RawSendbirdDataPayload {\n if (!dataPayload) return false;\n return Boolean(dataPayload['sendbird']);\n}\n\nexport function parseSendbirdNotification(dataPayload: RawSendbirdDataPayload): SendbirdDataPayload {\n return typeof dataPayload.sendbird === 'string' ? JSON.parse(dataPayload.sendbird) : dataPayload.sendbird;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAOA;;AAEO,SAASA,YAAT,CAAsBC,GAAtB,EAA4CC,aAA5C,EAAoE;EACzE,MAAMC,SAAS,GAAGC,WAAW,CAACH,GAAD,EAAMC,aAAN,CAA7B;EACA,IAAIC,SAAJ,EAAe,OAAO,KAAP;EACf,IAAIF,GAAG,CAACI,cAAJ,EAAJ,EAA0B,OAAO,KAAP;EAC1B,OAAOJ,GAAG,CAACK,SAAJ,KAAkB,CAAzB;AACD;;AAEM,SAASC,iBAAT,CAA2BN,GAA3B,EAAyF;EAC9F,OAAOA,GAAG,KAAKO,SAAR,IAAqBP,GAAG,KAAK,IAA7B,IAAqC,mBAAmBA,GAA/D;AACD;;AAEM,SAASG,WAAT,CAAqBH,GAArB,EAAsG;EAAA;;EAAA,IAAnDC,aAAmD,uEAAnC,iCAAmC;EAC3G,IAAI,CAACK,iBAAiB,CAACN,GAAD,CAAtB,EAA6B,OAAO,KAAP;EAC7B,OACG,YAAYA,GAAZ,IAAmB,gBAAAA,GAAG,CAACQ,MAAJ,4DAAYC,MAAZ,MAAuBR,aAA3C,IACAD,GAAG,CAACU,aAAJ,KAAsB,SADtB,IAEAV,GAAG,CAACU,aAAJ,KAAsB,QAFtB,IAGAV,GAAG,CAACU,aAAJ,KAAsB,UAJxB;AAMD;;AAEM,SAASC,mBAAT,CAA6BC,OAA7B,EAA+D;EACpE,OAAOC,gBAAgB,CAACD,OAAD,CAAvB;AACD,C,CAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASE,iBAAT,CAA2BC,CAA3B,EAA+CC,C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AAI,CAACA,WAAL,EAAkB,OAAO,KAAP;EAClB,OAAOC,OAAO,CAACD,WAAW,CAAC,UAAD,CAAZ,CAAd;AACD;;AAEM,SAASE,yBAAT,CAAmCF,WAAnC,EAA6F;EAClG,OAAO,OAAOA,WAAW,CAACG,QAAnB,KAAgC,QAAhC,GAA2CC,IAAI,CAACC,KAAL,CAAWL,WAAW,CAACG,QAAvB,CAA3C,GAA8EH,WAAW,CAACG,QAAjG;AACD"}
1
+ {"version":3,"names":["isNewMessage","msg","currentUserId","myMessage","isMyMessage","isAdminMessage","updatedAt","isSendableMessage","undefined","sender","userId","sendingStatus","messageKeyExtractor","message","getMessageUniqId","messageComparator","a","b","aStatusOffset","bStatusOffset","createdAt","hasSameSender","calcMessageGrouping","groupEnabled","curr","prev","next","getPrev","getMessageTimeFormat","Date","getNext","groupWithPrev","groupWithNext","isUserMessage","isFileMessage","String","messageId","reqId","getAvailableUriFromFileMessage","url","messageParams","file","uri","isSendbirdNotification","dataPayload","Boolean","parseSendbirdNotification","sendbird","JSON","parse","shouldRenderReaction","channel","reactionEnabled","isGroupChannel","isBroadcast","isSuper","getReactionCount","reaction","userIds","length"],"sources":["message.ts"],"sourcesContent":["import type {\n SendbirdBaseChannel,\n SendbirdBaseMessage,\n SendbirdDataPayload,\n SendbirdFileMessage,\n SendbirdMessage,\n SendbirdReaction,\n SendbirdSendableMessage,\n} from '../types';\nimport { getMessageTimeFormat } from '../ui-format/common';\n\nexport function isNewMessage(msg: SendbirdMessage, currentUserId?: string) {\n const myMessage = isMyMessage(msg, currentUserId);\n if (myMessage) return false;\n if (msg.isAdminMessage()) return false;\n return msg.updatedAt === 0;\n}\n\nexport function isSendableMessage(msg?: SendbirdMessage | null): msg is SendbirdSendableMessage {\n return msg !== undefined && msg !== null && 'sendingStatus' in msg;\n}\n\nexport function isMyMessage(msg?: SendbirdMessage | null, currentUserId = '##__USER_ID_IS_NOT_PROVIDED__##') {\n if (!isSendableMessage(msg)) return false;\n return (\n ('sender' in msg && msg.sender?.userId === currentUserId) ||\n msg.sendingStatus === 'pending' ||\n msg.sendingStatus === 'failed' ||\n msg.sendingStatus === 'canceled'\n );\n}\n\nexport function messageKeyExtractor(message: SendbirdMessage): string {\n return getMessageUniqId(message);\n}\n\n// |-------------------|-------------------|-----------------|-------------------|\n// | sending status | reqId | messageId | createdAt |\n// |-------------------|-------------------|-----------------|-------------------|\n// | pending | timestamp(A) | 0 | timestamp(B) |\n// | canceled | timestamp(A) | 0 | ? |\n// | failed | timestamp(A) | 0 | ? |\n// | succeeded | timestamp(A) / '' | id from DB | timestamp(C) |\n// |-------------------|-------------------|-----------------|-------------------|\nexport function messageComparator(a: SendbirdMessage, b: SendbirdMessage) {\n let aStatusOffset = 0;\n let bStatusOffset = 0;\n\n if (isSendableMessage(a) && a.sendingStatus !== 'succeeded') aStatusOffset = 999999;\n if (isSendableMessage(b) && b.sendingStatus !== 'succeeded') bStatusOffset = 999999;\n\n return b.createdAt + bStatusOffset - (a.createdAt + aStatusOffset);\n}\n\nexport function hasSameSender(a?: SendbirdMessage, b?: SendbirdMessage) {\n if (!a || !b) return false;\n if ('sender' in a && 'sender' in b) return a.sender?.userId === b.sender?.userId;\n return false;\n}\n\nexport function calcMessageGrouping(\n groupEnabled: boolean,\n curr: SendbirdMessage,\n prev?: SendbirdMessage,\n next?: SendbirdMessage,\n) {\n const getPrev = () => {\n if (!groupEnabled) return false;\n if (!prev) return false;\n if (curr.isAdminMessage()) return false;\n if (!hasSameSender(curr, prev)) return false;\n if (getMessageTimeFormat(new Date(curr.createdAt)) !== getMessageTimeFormat(new Date(prev.createdAt))) return false;\n return true;\n };\n\n const getNext = () => {\n if (!groupEnabled) return false;\n if (!next) return false;\n if (curr.isAdminMessage()) return false;\n if (!hasSameSender(curr, next)) return false;\n if (getMessageTimeFormat(new Date(curr.createdAt)) !== getMessageTimeFormat(new Date(next.createdAt))) return false;\n return true;\n };\n\n return { groupWithPrev: getPrev(), groupWithNext: getNext() };\n}\n\nexport function getMessageUniqId(msg: SendbirdBaseMessage) {\n if (msg.isUserMessage() || msg.isFileMessage()) {\n if (msg.sendingStatus === 'succeeded') return String(msg.messageId);\n return msg.reqId;\n }\n\n return String(msg.messageId);\n}\n\nexport function getAvailableUriFromFileMessage(message: SendbirdFileMessage) {\n if (!message.url && message.messageParams.file && 'uri' in message.messageParams.file) {\n return message.messageParams.file.uri;\n }\n return message.url;\n}\n\ntype RawSendbirdDataPayload = { sendbird: string | object };\nexport function isSendbirdNotification(dataPayload?: {\n [key: string]: string | object;\n}): dataPayload is RawSendbirdDataPayload {\n if (!dataPayload) return false;\n return Boolean(dataPayload['sendbird']);\n}\n\nexport function parseSendbirdNotification(dataPayload: RawSendbirdDataPayload): SendbirdDataPayload {\n return typeof dataPayload.sendbird === 'string' ? JSON.parse(dataPayload.sendbird) : dataPayload.sendbird;\n}\n\nexport function shouldRenderReaction(channel: SendbirdBaseChannel, reactionEnabled: boolean) {\n return channel.isGroupChannel() && !channel.isBroadcast && !channel.isSuper && reactionEnabled;\n}\n\nexport function getReactionCount(reaction: SendbirdReaction) {\n return reaction.userIds.length;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AASA;;AAEO,SAASA,YAAT,CAAsBC,GAAtB,EAA4CC,aAA5C,EAAoE;EACzE,MAAMC,SAAS,GAAGC,WAAW,CAACH,GAAD,EAAMC,aAAN,CAA7B;EACA,IAAIC,SAAJ,EAAe,OAAO,KAAP;EACf,IAAIF,GAAG,CAACI,cAAJ,EAAJ,EAA0B,OAAO,KAAP;EAC1B,OAAOJ,GAAG,CAACK,SAAJ,KAAkB,CAAzB;AACD;;AAEM,SAASC,iBAAT,CAA2BN,GAA3B,EAAyF;EAC9F,OAAOA,GAAG,KAAKO,SAAR,IAAqBP,GAAG,KAAK,IAA7B,IAAqC,mBAAmBA,GAA/D;AACD;;AAEM,SAASG,WAAT,CAAqBH,GAArB,EAAsG;EAAA;;EAAA,IAAnDC,aAAmD,uEAAnC,iCAAmC;EAC3G,IAAI,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Ab;IACvC,OAAOnC,GAAG,CAACoC,KAAX;EACD;;EAED,OAAOF,MAAM,CAAClC,GAAG,CAACmC,SAAL,CAAb;AACD;;AAEM,SAASE,8BAAT,CAAwCzB,OAAxC,EAAsE;EAC3E,IAAI,CAACA,OAAO,CAAC0B,GAAT,IAAgB1B,OAAO,CAAC2B,aAAR,CAAsBC,IAAtC,IAA8C,SAAS5B,OAAO,CAAC2B,aAAR,CAAsBC,IAAjF,EAAuF;IACrF,OAAO5B,OAAO,CAAC2B,aAAR,CAAsBC,IAAtB,CAA2BC,GAAlC;EACD;;EACD,OAAO7B,OAAO,CAAC0B,GAAf;AACD;;AAGM,SAASI,sBAAT,CAAgCC,WAAhC,EAEmC;EACxC,IAAI,CAACA,WAAL,EAAkB,OAAO,KAAP;EAClB,OAAOC,OAAO,CAACD,WAAW,CAAC,UAAD,CAAZ,CAAd;AACD;;AAEM,SAASE,yBAAT,CAAmCF,WAAnC,EAA6F;EAClG,OAAO,OAAOA,WAAW,CAACG,QAAnB,KAAgC,QAAhC,GAA2CC,IAAI,CAACC,KAAL,CAAWL,WAAW,CAACG,QAAvB,CAA3C,GAA8EH,WAAW,CAACG,QAAjG;AACD;;AAEM,SAASG,oBAAT,CAA8BC,OAA9B,EAA4DC,eAA5D,EAAsF;EAC3F,OAAOD,OAAO,CAACE,cAAR,MAA4B,CAACF,OAAO,CAACG,WAArC,IAAoD,CAACH,OAAO,CAACI,OAA7D,IAAwEH,eAA/E;AACD;;AAEM,SAASI,gBAAT,CAA0BC,QAA1B,EAAsD;EAC3D,OAAOA,QAAQ,CAACC,OAAT,CAAiBC,MAAxB;AACD"}
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.getUserUniqId = getUserUniqId;
6
7
  exports.ifMuted = ifMuted;
7
8
  exports.ifOperator = ifOperator;
8
9
 
@@ -15,4 +16,8 @@ function ifMuted(muted, then, or) {
15
16
  if (muted) return then;
16
17
  return or;
17
18
  }
19
+
20
+ function getUserUniqId(user) {
21
+ return user.userId;
22
+ }
18
23
  //# sourceMappingURL=user.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["ifOperator","role","then","or","ifMuted","muted"],"sources":["user.ts"],"sourcesContent":["import type { Role } from '@sendbird/chat';\n\nexport function ifOperator<T>(role: Role, then: T): T | undefined;\nexport function ifOperator<T, V>(role: Role, then: T, or: V): T | V;\nexport function ifOperator(role: Role, then: unknown, or?: unknown) {\n if (role === 'operator') return then;\n return or;\n}\n\nexport function ifMuted<T>(muted: boolean, then: T): T | undefined;\nexport function ifMuted<T, V>(muted: boolean, then: T, or: V): T | V;\nexport function ifMuted(muted: boolean, then: unknown, or?: unknown) {\n if (muted) return then;\n return or;\n}\n"],"mappings":";;;;;;;;AAIO,SAASA,UAAT,CAAoBC,IAApB,EAAgCC,IAAhC,EAA+CC,EAA/C,EAA6D;EAClE,IAAIF,IAAI,KAAK,UAAb,EAAyB,OAAOC,IAAP;EACzB,OAAOC,EAAP;AACD;;AAIM,SAASC,OAAT,CAAiBC,KAAjB,EAAiCH,IAAjC,EAAgDC,EAAhD,EAA8D;EACnE,IAAIE,KAAJ,EAAW,OAAOH,IAAP;EACX,OAAOC,EAAP;AACD"}
1
+ {"version":3,"names":["ifOperator","role","then","or","ifMuted","muted","getUserUniqId","user","userId"],"sources":["user.ts"],"sourcesContent":["import type { Role } from '@sendbird/chat';\n\nimport type { UserStruct } from '../types';\n\nexport function ifOperator<T>(role: Role, then: T): T | undefined;\nexport function ifOperator<T, V>(role: Role, then: T, or: V): T | V;\nexport function ifOperator(role: Role, then: unknown, or?: unknown) {\n if (role === 'operator') return then;\n return or;\n}\n\nexport function ifMuted<T>(muted: boolean, then: T): T | undefined;\nexport function ifMuted<T, V>(muted: boolean, then: T, or: V): T | V;\nexport function ifMuted(muted: boolean, then: unknown, or?: unknown) {\n if (muted) return then;\n return or;\n}\n\nexport function getUserUniqId<T extends UserStruct>(user: T) {\n return user.userId;\n}\n"],"mappings":";;;;;;;;;AAMO,SAASA,UAAT,CAAoBC,IAApB,EAAgCC,IAAhC,EAA+CC,EAA/C,EAA6D;EAClE,IAAIF,IAAI,KAAK,UAAb,EAAyB,OAAOC,IAAP;EACzB,OAAOC,EAAP;AACD;;AAIM,SAASC,OAAT,CAAiBC,KAAjB,EAAiCH,IAAjC,EAAgDC,EAAhD,EAA8D;EACnE,IAAIE,KAAJ,EAAW,OAAOH,IAAP;EACX,OAAOC,EAAP;AACD;;AAEM,SAASG,aAAT,CAA6CC,IAA7C,EAAsD;EAC3D,OAAOA,IAAI,CAACC,MAAZ;AACD"}
@@ -3,11 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.emailRegex = exports.audioExtRegex = void 0;
6
+ exports.emailRegex = exports.createMentionTemplateRegex = exports.audioExtRegex = void 0;
7
7
  exports.getFileExtension = getFileExtension;
8
8
  exports.newLineRegex = exports.imageExtRegex = exports.getFileType = void 0;
9
9
  exports.normalizeFileName = normalizeFileName;
10
- exports.videoExtRegex = exports.urlRegexStrict = exports.urlRegexRough = exports.replaceUrlAsComponents = exports.phoneRegex = void 0;
10
+ exports.videoExtRegex = exports.urlRegexStrict = exports.urlRegexRough = exports.replaceWithRegex = exports.replaceUrlAsComponents = exports.phoneRegex = void 0;
11
11
 
12
12
  // For iOS 12 backwards compatibility
13
13
  require('string.prototype.matchall').shim();
@@ -20,7 +20,10 @@ const phoneRegex = /[+]?[(]?[0-9]{3}[)]?[-\s.]?[0-9]{3}[-\s.]?[0-9]{4,7}/;
20
20
  exports.phoneRegex = phoneRegex;
21
21
  const emailRegex = /\S+@\S+\.\S+/;
22
22
  exports.emailRegex = emailRegex;
23
- const newLineRegex = /\r\n|\r|\n/g; // const cases = [
23
+ const newLineRegex = /\r\n|\r|\n/g;
24
+ exports.newLineRegex = newLineRegex;
25
+
26
+ const createMentionTemplateRegex = trigger => new RegExp(`(${trigger}[{])(.*?)([}])`, 'g'); // const cases = [
24
27
  // {
25
28
  // type: 'urlStrict',
26
29
  // regex: urlRegexStrict,
@@ -39,7 +42,50 @@ const newLineRegex = /\r\n|\r|\n/g; // const cases = [
39
42
  // },
40
43
  // ];
41
44
 
42
- exports.newLineRegex = newLineRegex;
45
+
46
+ exports.createMentionTemplateRegex = createMentionTemplateRegex;
47
+
48
+ const replaceWithRegex = (text, regex, replacer, keyPrefix) => {
49
+ const matches = [...text.matchAll(regex)];
50
+ const founds = matches.map(value => {
51
+ const text = value[0];
52
+ const start = value.index ?? 0;
53
+ const end = start + text.length;
54
+ return {
55
+ text,
56
+ start,
57
+ end,
58
+ groups: value,
59
+ matchIndex: value.index
60
+ };
61
+ });
62
+ const items = [text];
63
+ let cursor = 0;
64
+ founds.forEach((_ref, index) => {
65
+ let {
66
+ text,
67
+ start,
68
+ end,
69
+ groups,
70
+ matchIndex
71
+ } = _ref;
72
+ const restText = items.pop();
73
+ const head = restText.slice(0, start - cursor);
74
+ const mid = replacer({
75
+ match: text,
76
+ groups,
77
+ matchIndex,
78
+ index,
79
+ keyPrefix
80
+ });
81
+ const tail = restText.slice(end - cursor);
82
+ items.push(head, mid, tail);
83
+ cursor = end;
84
+ });
85
+ return items;
86
+ };
87
+
88
+ exports.replaceWithRegex = replaceWithRegex;
43
89
 
44
90
  const replaceUrlAsComponents = (originText, replacer, strict) => {
45
91
  const matches = [...originText.matchAll(strict ? urlRegexStrict : urlRegexRough)];
@@ -55,12 +101,12 @@ const replaceUrlAsComponents = (originText, replacer, strict) => {
55
101
  });
56
102
  const items = [originText];
57
103
  let cursor = 0;
58
- founds.forEach(_ref => {
104
+ founds.forEach(_ref2 => {
59
105
  let {
60
106
  text,
61
107
  start,
62
108
  end
63
- } = _ref;
109
+ } = _ref2;
64
110
  const restText = items.pop();
65
111
  const head = restText.slice(0, start - cursor);
66
112
  const mid = replacer(text);
@@ -1 +1 @@
1
- {"version":3,"names":["require","shim","urlRegexStrict","urlRegexRough","phoneRegex","emailRegex","newLineRegex","replaceUrlAsComponents","originText","replacer","strict","matches","matchAll","founds","map","value","text","start","index","end","length","items","cursor","forEach","restText","pop","head","slice","mid","tail","push","imageExtRegex","audioExtRegex","videoExtRegex","getFileType","extOrType","indexOf","type","split","match","getFileExtension","filePath","idx","lastIndexOf","toLowerCase","normalizeFileName","fileName","extension"],"sources":["regex.ts"],"sourcesContent":["// For iOS 12 backwards compatibility\nrequire('string.prototype.matchall').shim();\n\nexport const urlRegexStrict =\n /(https?:\\/\\/|www\\.)[-a-zA-Z0-9@:%._+~#=]{1,256}\\.(xn--)?[a-z0-9-]{2,20}\\b([-a-zA-Z0-9@:%_+[\\],.~#?&/=]*[-a-zA-Z0-9@:%_+\\]~#?&/=])*/g;\nexport const urlRegexRough =\n /(https?:\\/\\/|www\\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/g;\nexport const phoneRegex = /[+]?[(]?[0-9]{3}[)]?[-\\s.]?[0-9]{3}[-\\s.]?[0-9]{4,7}/;\nexport const emailRegex = /\\S+@\\S+\\.\\S+/;\nexport const newLineRegex = /\\r\\n|\\r|\\n/g;\n\n// const cases = [\n// {\n// type: 'urlStrict',\n// regex: urlRegexStrict,\n// },\n// {\n// type: 'urlRough',\n// regex: urlRegexStrict,\n// },\n// {\n// type: 'email',\n// regex: emailRegex,\n// },\n// {\n// type: 'phone',\n// regex: urlRegexStrict,\n// },\n// ];\n\nexport const replaceUrlAsComponents = <T>(originText: string, replacer: (url: string) => T, strict?: boolean) => {\n const matches = [...originText.matchAll(strict ? urlRegexStrict : urlRegexRough)];\n const founds = matches.map((value) => {\n const text = value[0];\n const start = value.index ?? 0;\n const end = start + text.length;\n return { text, start, end };\n });\n\n const items: Array<string | T> = [originText];\n let cursor = 0;\n founds.forEach(({ text, start, end }) => {\n const restText = items.pop() as string;\n const head = restText.slice(0, start - cursor);\n const mid = replacer(text);\n const tail = restText.slice(end - cursor);\n items.push(head, mid, tail);\n cursor = end;\n });\n return items;\n};\n\nexport const imageExtRegex = /jpeg|jpg|png|webp|gif/i;\nexport const audioExtRegex = /3gp|aac|aax|act|aiff|flac|gsm|m4a|m4b|m4p|tta|wma|mp3|webm|wav/i;\nexport const videoExtRegex = /mov|vod|mp4|avi/i;\nexport const getFileType = (extOrType: string) => {\n if (extOrType.indexOf('/') > -1) {\n const type = extOrType.split('/')[0];\n if (type === 'video') return 'video';\n if (type === 'audio') return 'audio';\n if (type === 'image') return 'image';\n return 'file';\n }\n\n if (extOrType.match(imageExtRegex)) return 'image';\n if (extOrType.match(audioExtRegex)) return 'audio';\n if (extOrType.match(videoExtRegex)) return 'video';\n return 'file';\n};\nexport function getFileExtension(filePath: string) {\n const idx = filePath.lastIndexOf('.');\n if (idx === -1) return '';\n return filePath.slice(idx - filePath.length).toLowerCase();\n}\nexport function normalizeFileName(fileName: string, extension: string) {\n if (fileName.indexOf(extension) > -1) {\n return fileName;\n } else {\n if (extension.indexOf('.') === 0) {\n return `${fileName}${extension}`;\n } else {\n return `${fileName}.${extension}`;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;AACAA,OAAO,CAAC,2BAAD,CAAP,CAAqCC,IAArC;;AAEO,MAAMC,cAAc,GACzB,qIADK;;AAEA,MAAMC,aAAa,GACxB,uGADK;;AAEA,MAAMC,UAAU,GAAG,sDAAnB;;AACA,MAAMC,UAAU,GAAG,cAAnB;;AACA,MAAMC,YAAY,GAAG,aAArB,C,CAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AAEO,MAAMC,sBAAsB,GAAG,CAAIC,UAAJ,EAAwBC,QAAxB,EAAsDC,MAAtD,KAA2E;EAC/G,MAAMC,OAAO,GAAG,CAAC,GAAGH,UAAU,CAACI,QAAX,CAAoBF,MAAM,GAAGR,cAAH,GAAoBC,aAA9C,CAAJ,CAAhB;EACA,MAAMU,MAAM,GAAGF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Ab,EAAsB,OAAO,OAAP;IACtB,IAAIA,IAAI,KAAK,OAAb,EAAsB,OAAO,OAAP;IACtB,OAAO,MAAP;EACD;;EAED,IAAIF,SAAS,CAACI,KAAV,CAAgBR,aAAhB,CAAJ,EAAoC,OAAO,OAAP;EACpC,IAAII,SAAS,CAACI,KAAV,CAAgBP,aAAhB,CAAJ,EAAoC,OAAO,OAAP;EACpC,IAAIG,SAAS,CAACI,KAAV,CAAgBN,aAAhB,CAAJ,EAAoC,OAAO,OAAP;EACpC,OAAO,MAAP;AACD,CAbM;;;;AAcA,SAASO,gBAAT,CAA0BC,QAA1B,EAA4C;EACjD,MAAMC,GAAG,GAAGD,QAAQ,CAACE,WAAT,CAAqB,GAArB,CAAZ;EACA,IAAID,GAAG,KAAK,CAAC,CAAb,EAAgB,OAAO,EAAP;EAChB,OAAOD,QAAQ,CAACd,KAAT,CAAee,GAAG,GAAGD,QAAQ,CAACrB,MAA9B,EAAsCwB,WAAtC,EAAP;AACD;;AACM,SAASC,iBAAT,CAA2BC,QAA3B,EAA6CC,SAA7C,EAAgE;EACrE,IAAID,QAAQ,CAACV,OAAT,CAAiBW,SAAjB,IAA8B,CAAC,CAAnC,EAAsC;IACpC,OAAOD,QAAP;EACD,CAFD,MAEO;IACL,IAAIC,SAAS,CAACX,OAAV,CAAkB,GAAlB,MAA2B,CAA/B,EAAkC;MAChC,OAAQ,GAAEU,QAAS,GAAEC,SAAU,EAA/B;IACD,CAFD,MAEO;MACL,OAAQ,GAAED,QAAS,IAAGC,SAAU,EAAhC;IACD;EACF;AACF"}
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","imageExtRegex","audioExtRegex","videoExtRegex","getFileType","extOrType","indexOf","type","split","getFileExtension","filePath","idx","lastIndexOf","toLowerCase","normalizeFileName","fileName","extension"],"sources":["regex.ts"],"sourcesContent":["// For iOS 12 backwards compatibility\nrequire('string.prototype.matchall').shim();\n\nexport const urlRegexStrict =\n /(https?:\\/\\/|www\\.)[-a-zA-Z0-9@:%._+~#=]{1,256}\\.(xn--)?[a-z0-9-]{2,20}\\b([-a-zA-Z0-9@:%_+[\\],.~#?&/=]*[-a-zA-Z0-9@:%_+\\]~#?&/=])*/g;\nexport const urlRegexRough =\n /(https?:\\/\\/|www\\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/g;\nexport const phoneRegex = /[+]?[(]?[0-9]{3}[)]?[-\\s.]?[0-9]{3}[-\\s.]?[0-9]{4,7}/;\nexport const emailRegex = /\\S+@\\S+\\.\\S+/;\nexport const newLineRegex = /\\r\\n|\\r|\\n/g;\n\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\nexport const imageExtRegex = /jpeg|jpg|png|webp|gif/i;\nexport const audioExtRegex = /3gp|aac|aax|act|aiff|flac|gsm|m4a|m4b|m4p|tta|wma|mp3|webm|wav/i;\nexport const videoExtRegex = /mov|vod|mp4|avi/i;\nexport const getFileType = (extOrType: string) => {\n if (extOrType.indexOf('/') > -1) {\n const type = extOrType.split('/')[0];\n if (type === 'video') return 'video';\n if (type === 'audio') return 'audio';\n if (type === 'image') return 'image';\n return 'file';\n }\n\n if (extOrType.match(imageExtRegex)) return 'image';\n if (extOrType.match(audioExtRegex)) return 'audio';\n if (extOrType.match(videoExtRegex)) return 'video';\n return 'file';\n};\nexport function getFileExtension(filePath: string) {\n const idx = filePath.lastIndexOf('.');\n if (idx === -1) return '';\n return filePath.slice(idx - filePath.length).toLowerCase();\n}\nexport function normalizeFileName(fileName: string, extension: string) {\n if (fileName.indexOf(extension) > -1) {\n return fileName;\n } else {\n if (extension.indexOf('.') === 0) {\n return `${fileName}${extension}`;\n } else {\n return `${fileName}.${extension}`;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;AAAA;AACAA,OAAO,CAAC,2BAAD,CAAP,CAAqCC,IAArC;;AAEO,MAAMC,cAAc,GACzB,qIADK;;AAEA,MAAMC,aAAa,GACxB,uGADK;;AAEA,MA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,SAA7C,EAAgE;EACrE,IAAID,QAAQ,CAACT,OAAT,CAAiBU,SAAjB,IAA8B,CAAC,CAAnC,EAAsC;IACpC,OAAOD,QAAP;EACD,CAFD,MAEO;IACL,IAAIC,SAAS,CAACV,OAAV,CAAkB,GAAlB,MAA2B,CAA/B,EAAkC;MAChC,OAAQ,GAAES,QAAS,GAAEC,SAAU,EAA/B;IACD,CAFD,MAEO;MACL,OAAQ,GAAED,QAAS,IAAGC,SAAU,EAAhC;IACD;EACF;AACF"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ const replace = (original, start, end, str) => {
9
+ return original.slice(0, start) + str + original.slice(end);
10
+ };
11
+
12
+ var _default = replace;
13
+ exports.default = _default;
14
+ //# sourceMappingURL=replace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["replace","original","start","end","str","slice"],"sources":["replace.ts"],"sourcesContent":["const replace = (original: string, start: number, end: number, str: string) => {\n return original.slice(0, start) + str + original.slice(end);\n};\n\nexport default replace;\n"],"mappings":";;;;;;;AAAA,MAAMA,OAAO,GAAG,CAACC,QAAD,EAAmBC,KAAnB,EAAkCC,GAAlC,EAA+CC,GAA/C,KAA+D;EAC7E,OAAOH,QAAQ,CAACI,KAAT,CAAe,CAAf,EAAkBH,KAAlB,IAA2BE,GAA3B,GAAiCH,QAAQ,CAACI,KAAT,CAAeF,GAAf,CAAxC;AACD,CAFD;;eAIeH,O"}
@@ -1,4 +1,6 @@
1
1
  "use strict";
2
2
 
3
- require("./");
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
4
6
  //# sourceMappingURL=types.js.map
@@ -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 { BaseChannel, RestrictedUser, SendbirdError as SBError, User, UserUpdateParams } from '@sendbird/chat';\nimport type {\n GroupChannel,\n GroupChannelCollection,\n GroupChannelCreateParams,\n GroupChannelListQuery,\n GroupChannelModule,\n GroupChannelUpdateParams,\n Member,\n MessageCollection,\n} from '@sendbird/chat/groupChannel';\nimport type { ModuleNamespaces, SendableMessage } from '@sendbird/chat/lib/__definition';\nimport type {\n AdminMessage,\n BaseMessage,\n FileMessage,\n FileMessageCreateParams,\n FileMessageUpdateParams,\n PreviousMessageListQuery,\n UserMessage,\n UserMessageCreateParams,\n UserMessageUpdateParams,\n} from '@sendbird/chat/message';\nimport type { OpenChannel, OpenChannelModule } from '@sendbird/chat/openChannel';\n\nimport './';\n\nexport type FilterByValueType<T extends object, Type> = {\n [K in keyof T as T[K] extends Type ? K : never]: T[K];\n};\n\nexport type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void\n ? I\n : never;\n\nexport type OmittedValues<T, K extends keyof T> = Omit<T, K>[keyof Omit<T, K>];\n\nexport type PartialDeep<T> = T extends object\n ? T extends Function\n ? T\n : {\n [P in keyof T]?: PartialDeep<T[P]>;\n }\n : T;\n\nexport type PartialNullable<T> = {\n [P in keyof T]?: T[P] | null;\n};\n\nexport type Optional<T> = T | undefined;\n\nexport type ContextValue<T extends React.Context<any>> = T extends React.Context<infer V> ? V : never;\n\nexport type SendbirdChatSDK = SendbirdChat & ModuleNamespaces<[GroupChannelModule, OpenChannelModule]>;\nexport type SendbirdMessage = BaseMessage | FileMessage | UserMessage | AdminMessage | SendableMessage;\nexport type SendbirdChannel = BaseChannel | GroupChannel | OpenChannel;\nexport type SendbirdUserMessage = UserMessage;\nexport type SendbirdFileMessage = FileMessage;\nexport type SendbirdAdminMessage = AdminMessage;\nexport type SendbirdBaseMessage = BaseMessage;\nexport type SendbirdSendableMessage = SendableMessage;\nexport type SendbirdFileMessageCreateParams = FileMessageCreateParams;\nexport type SendbirdFileMessageUpdateParams = FileMessageUpdateParams;\nexport type SendbirdUserMessageCreateParams = UserMessageCreateParams;\nexport type SendbirdUserMessageUpdateParams = UserMessageUpdateParams;\nexport type SendbirdGroupChannelCreateParams = GroupChannelCreateParams;\nexport type SendbirdGroupChannelUpdateParams = GroupChannelUpdateParams;\nexport type SendbirdUserUpdateParams = UserUpdateParams;\nexport type SendbirdUser = User;\nexport type SendbirdRestrictedUser = RestrictedUser;\nexport type SendbirdMember = Member;\nexport type SendbirdGroupChannel = GroupChannel;\nexport type SendbirdBaseChannel = BaseChannel;\nexport type SendbirdOpenChannel = OpenChannel;\n\nexport type SendbirdGroupChannelCollection = GroupChannelCollection;\nexport type SendbirdGroupChannelListQuery = GroupChannelListQuery;\nexport type SendbirdMessageCollection = MessageCollection;\nexport type SendbirdPreviousMessageListQuery = PreviousMessageListQuery;\n\nexport type SendbirdError = SBError;\n\nexport interface SendbirdDataPayload {\n app_id: string;\n audience_type: string;\n category: string;\n channel: {\n channel_unread_message_count: number;\n channel_url: string;\n custom_type: string;\n name: string;\n };\n channel_type: string;\n created_at: number;\n custom_type: string;\n files: NotificationFiles[];\n mentioned_users: NotificationMentionedUsers[];\n message: string;\n message_id: number;\n push_sound: string;\n push_title: null;\n recipient: {\n id: string;\n name: string;\n push_template: string;\n };\n sender?: {\n id: string;\n name: string;\n profile_url: string;\n require_auth_for_profile_image: boolean;\n };\n sqs_ts: number;\n translations: NotificationTranslations;\n type: 'ADMM' | 'MESG' | 'FILE' | string;\n unread_message_count: number;\n}\nexport interface NotificationFiles {\n type: string;\n url: string;\n name: string;\n size: number;\n require_auth: boolean;\n}\n\nexport interface NotificationTranslations {}\nexport interface NotificationMentionedUsers {}\n"],"mappings":";;AA+BA"}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\n/* eslint-disable @typescript-eslint/no-empty-interface */\nimport type React from 'react';\n\nimport type SendbirdChat from '@sendbird/chat';\nimport type {\n BaseChannel,\n Emoji,\n EmojiCategory,\n EmojiContainer,\n RestrictedUser,\n SendbirdError as SBError,\n User,\n UserUpdateParams,\n} from '@sendbird/chat';\nimport type {\n GroupChannel,\n GroupChannelCollection,\n GroupChannelCreateParams,\n GroupChannelListQuery,\n GroupChannelModule,\n GroupChannelUpdateParams,\n Member,\n MessageCollection,\n} from '@sendbird/chat/groupChannel';\nimport type { ModuleNamespaces, SendableMessage } from '@sendbird/chat/lib/__definition';\nimport type {\n AdminMessage,\n BaseMessage,\n FileMessage,\n FileMessageCreateParams,\n FileMessageUpdateParams,\n PreviousMessageListQuery,\n Reaction,\n UserMessage,\n UserMessageCreateParams,\n UserMessageUpdateParams,\n} from '@sendbird/chat/message';\nimport type { OpenChannel, OpenChannelModule } from '@sendbird/chat/openChannel';\n\nexport type FilterByValueType<T extends object, Type> = {\n [K in keyof T as T[K] extends Type ? K : never]: T[K];\n};\n\nexport type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) extends (k: infer I) => void\n ? I\n : never;\n\nexport type OmittedValues<T, K extends keyof T> = Omit<T, K>[keyof Omit<T, K>];\n\nexport type PartialDeep<T> = T extends object\n ? T extends Function\n ? T\n : {\n [P in keyof T]?: PartialDeep<T[P]>;\n }\n : T;\n\nexport type PartialNullable<T> = {\n [P in keyof T]?: T[P] | null;\n};\n\nexport type Optional<T> = T | undefined;\n\nexport type ContextValue<T extends React.Context<any>> = T extends React.Context<infer V> ? V : never;\n\nexport interface UserStruct {\n userId: string;\n}\n\nexport type SendbirdChatSDK = SendbirdChat & ModuleNamespaces<[GroupChannelModule, OpenChannelModule]>;\nexport type SendbirdMessage = BaseMessage | FileMessage | UserMessage | AdminMessage | SendableMessage;\nexport type SendbirdChannel = BaseChannel | GroupChannel | OpenChannel;\nexport type SendbirdUserMessage = UserMessage;\nexport type SendbirdFileMessage = FileMessage;\nexport type SendbirdAdminMessage = AdminMessage;\nexport type SendbirdBaseMessage = BaseMessage;\nexport type SendbirdSendableMessage = SendableMessage;\nexport type SendbirdFileMessageCreateParams = FileMessageCreateParams;\nexport type SendbirdFileMessageUpdateParams = FileMessageUpdateParams;\nexport type SendbirdUserMessageCreateParams = UserMessageCreateParams;\nexport type SendbirdUserMessageUpdateParams = UserMessageUpdateParams;\nexport type SendbirdGroupChannelCreateParams = GroupChannelCreateParams;\nexport type SendbirdGroupChannelUpdateParams = GroupChannelUpdateParams;\nexport type SendbirdUserUpdateParams = UserUpdateParams;\nexport type SendbirdUser = User;\nexport type SendbirdRestrictedUser = RestrictedUser;\nexport type SendbirdMember = Member;\nexport type SendbirdGroupChannel = GroupChannel;\nexport type SendbirdBaseChannel = BaseChannel;\nexport type SendbirdOpenChannel = OpenChannel;\n\nexport type SendbirdReaction = Reaction;\nexport type SendbirdEmoji = Emoji;\nexport type SendbirdEmojiCategory = EmojiCategory;\nexport type SendbirdEmojiContainer = EmojiContainer;\n\nexport type SendbirdGroupChannelCollection = GroupChannelCollection;\nexport type SendbirdGroupChannelListQuery = GroupChannelListQuery;\nexport type SendbirdMessageCollection = MessageCollection;\nexport type SendbirdPreviousMessageListQuery = PreviousMessageListQuery;\n\nexport type SendbirdError = SBError;\n\nexport interface SendbirdDataPayload {\n app_id: string;\n audience_type: string;\n category: string;\n channel: {\n channel_unread_message_count: number;\n channel_url: string;\n custom_type: string;\n name: string;\n };\n channel_type: string;\n created_at: number;\n custom_type: string;\n files: NotificationFiles[];\n mentioned_users: NotificationMentionedUsers[];\n message: string;\n message_id: number;\n push_sound: string;\n push_title: null;\n recipient: {\n id: string;\n name: string;\n push_template: string;\n };\n sender?: {\n id: string;\n name: string;\n profile_url: string;\n require_auth_for_profile_image: boolean;\n };\n sqs_ts: number;\n translations: NotificationTranslations;\n type: 'ADMM' | 'MESG' | 'FILE' | string;\n unread_message_count: number;\n}\nexport interface NotificationFiles {\n type: string;\n url: string;\n name: string;\n size: number;\n require_auth: boolean;\n}\n\nexport interface NotificationTranslations {}\nexport interface NotificationMentionedUsers {}\n"],"mappings":""}
@@ -3,11 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.truncatedBadgeCount = exports.truncate = exports.messageTime = exports.dateSeparator = void 0;
6
+ exports.truncatedCount = exports.truncate = exports.getMessageTimeFormat = exports.getDateSeparatorFormat = void 0;
7
7
 
8
- var _format = _interopRequireDefault(require("date-fns/format"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
+ var _dateFns = require("date-fns");
11
9
 
12
10
  const defaultOpts = {
13
11
  mode: 'mid',
@@ -53,20 +51,22 @@ const truncate = function (str) {
53
51
  throw new Error('Invalid truncate mode: ' + mode);
54
52
  };
55
53
  /**
56
- * Badge count truncate util
54
+ * Count truncate util
57
55
  * If count exceed the limit, it comes in the form of "MAX+"
58
56
  *
59
57
  * @param {number} count
60
58
  * @param {number} MAX default 99
59
+ * @param {string} MAX_SUFFIX default +
61
60
  * @returns {string}
62
61
  * */
63
62
 
64
63
 
65
64
  exports.truncate = truncate;
66
65
 
67
- const truncatedBadgeCount = function (count) {
66
+ const truncatedCount = function (count) {
68
67
  let MAX = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 99;
69
- if (count >= MAX) return `${MAX}+`;
68
+ let MAX_SUFFIX = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '+';
69
+ if (count >= MAX) return `${MAX}${MAX_SUFFIX}`;
70
70
  return `${count}`;
71
71
  };
72
72
  /**
@@ -78,10 +78,13 @@ const truncatedBadgeCount = function (count) {
78
78
  * */
79
79
 
80
80
 
81
- exports.truncatedBadgeCount = truncatedBadgeCount;
81
+ exports.truncatedCount = truncatedCount;
82
82
 
83
- const dateSeparator = (date, locale) => {
84
- return (0, _format.default)(date, 'E, LLL dd', {
83
+ const getDateSeparatorFormat = (date, locale) => {
84
+ if ((0, _dateFns.isThisYear)(date)) return (0, _dateFns.format)(date, 'MMM dd, yyyy', {
85
+ locale
86
+ });
87
+ return (0, _dateFns.format)(date, 'E, MMM dd', {
85
88
  locale
86
89
  });
87
90
  };
@@ -94,13 +97,13 @@ const dateSeparator = (date, locale) => {
94
97
  * */
95
98
 
96
99
 
97
- exports.dateSeparator = dateSeparator;
100
+ exports.getDateSeparatorFormat = getDateSeparatorFormat;
98
101
 
99
- const messageTime = (date, locale) => {
100
- return (0, _format.default)(date, 'p', {
102
+ const getMessageTimeFormat = (date, locale) => {
103
+ return (0, _dateFns.format)(date, 'p', {
101
104
  locale
102
105
  });
103
106
  };
104
107
 
105
- exports.messageTime = messageTime;
108
+ exports.getMessageTimeFormat = getMessageTimeFormat;
106
109
  //# sourceMappingURL=common.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["defaultOpts","mode","maxLen","separator","truncate","str","opts","options","length","slice","lead","Math","ceil","trail","floor","Error","truncatedBadgeCount","count","MAX","dateSeparator","date","locale","format","messageTime"],"sources":["common.ts"],"sourcesContent":["import type { Locale } from 'date-fns';\nimport format from 'date-fns/format';\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 * Badge 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 * @returns {string}\n * */\nexport const truncatedBadgeCount = (count: number, MAX = 99) => {\n if (count >= MAX) return `${MAX}+`;\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 dateSeparator = (date: Date, locale?: Locale): string => {\n return format(date, 'E, LLL dd', { locale });\n};\n\n/**\n * Message time format\n *\n * @param {Date} date\n * @param {Locale} [locale]\n * @returns {string}\n * */\nexport const messageTime = (date: Date, locale?: Locale): string => {\n return format(date, 'p', { locale });\n};\n"],"mappings":";;;;;;;AACA;;;;AAIA,MAAMA,WAA2B,GAAG;EAAEC,IAAI,EAAE,KAAR;EAAeC,MAAM,EAAE,EAAvB;EAA2BC,SAAS,EAAE;AAAtC,CAApC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,MAAMC,QAAQ,GAAG,UAACC,GAAD,EAAsE;EAAA,IAAxDC,IAAwD,uEAAxBN,WAAwB;EAC5F,MAAMO,OAAO,GAAG,EAAE,GAAGP,WAAL;IAAkB,GAAGM;EAArB,CAAhB;EACA,MAAM;IAAEJ,MAAF;IAAUD,IAAV;IAAgBE;EAAhB,IAA8BI,OAApC;EAEA,IAAIF,GAAG,CAACG,MAAJ,IAAcN,MAAlB,EAA0B,OAAOG,GAAP;;EAE1B,IAAIJ,IAAI,KAAK,MAAb,EAAqB;IACnB,OAAOE,SAAS,GAAGE,GAAG,CAACI,KAAJ,CAAU,CAACP,MAAX,CAAnB;EACD;;EAED,IAAID,IAAI,KAAK,KAAb,EAAoB;IAClB,MAAMS,IAAI,GAAGC,IAAI,CAACC,IAAL,CAAUV,MAAM,GAAG,CAAnB,CAAb;IACA,MAAMW,KAAK,GAAGF,IAAI,CAACG,KAAL,CAAWZ,MAAM,GAAG,CAApB,CAAd;IACA,OAAOG,GAAG,CAACI,KAAJ,CAAU,CAAV,EAAaC,IAAb,IAAqBP,SAArB,GAAiCE,GAAG,CAACI,KAAJ,CAAU,CAACI,KAAX,CAAxC;EACD;;EAED,IAAIZ,IAAI,KAAK,MAAb,EAAqB;IACnB,OAAOI,GAAG,CAACI,KAAJ,CAAU,CAAV,EAAaP,MAAb,IAAuBC,SAA9B;EACD;;EAED,MAAM,IAAIY,KAAJ,CAAU,4BAA4Bd,IAAtC,CAAN;AACD,CArBM;AAuBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMe,mBAAmB,GAAG,UAACC,KAAD,EAA6B;EAAA,IAAbC,GAAa,uEAAP,EAAO;EAC9D,IAAID,KAAK,IAAIC,GAAb,EAAkB,OAAQ,GAAEA,GAAI,GAAd;EAClB,OAAQ,GAAED,KAAM,EAAhB;AACD,CAHM;AAKP;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAME,aAAa,GAAG,CAACC,IAAD,EAAaC,MAAb,KAAyC;EACpE,OAAO,IAAAC,eAAA,EAAOF,IAAP,EAAa,WAAb,EAA0B;IAAEC;EAAF,CAA1B,CAAP;AACD,CAFM;AAIP;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAME,WAAW,GAAG,CAACH,IAAD,EAAaC,MAAb,KAAyC;EAClE,OAAO,IAAAC,eAAA,EAAOF,IAAP,EAAa,GAAb,EAAkB;IAAEC;EAAF,CAAlB,CAAP;AACD,CAFM"}
1
+ {"version":3,"names":["defaultOpts","mode","maxLen","separator","truncate","str","opts","options","length","slice","lead","Math","ceil","trail","floor","Error","truncatedCount","count","MAX","MAX_SUFFIX","getDateSeparatorFormat","date","locale","isThisYear","format","getMessageTimeFormat"],"sources":["common.ts"],"sourcesContent":["import type { Locale } from 'date-fns';\nimport { format, isThisYear } from 'date-fns';\n\ntype TruncateMode = 'head' | 'mid' | 'tail';\ntype TruncateOption = { mode: TruncateMode; maxLen: number; separator: string };\nconst defaultOpts: TruncateOption = { mode: 'mid', maxLen: 40, separator: '...' };\n\n/**\n * String truncate util\n * @param {string} str\n * @param {Object} opts Options for truncate\n * @param {'head' | 'mid' | 'tail'} opts.mode default \"mid\"\n * @param {number} opts.maxLen default 40\n * @param {string} opts.separator default \"...\"\n * @returns {string}\n * */\nexport const truncate = (str: string, opts: Partial<TruncateOption> = defaultOpts): string => {\n const options = { ...defaultOpts, ...opts };\n const { maxLen, mode, separator } = options;\n\n if (str.length <= maxLen) return str;\n\n if (mode === 'head') {\n return separator + str.slice(-maxLen);\n }\n\n if (mode === 'mid') {\n const lead = Math.ceil(maxLen / 2);\n const trail = Math.floor(maxLen / 2);\n return str.slice(0, lead) + separator + str.slice(-trail);\n }\n\n if (mode === 'tail') {\n return str.slice(0, maxLen) + separator;\n }\n\n throw new Error('Invalid truncate mode: ' + mode);\n};\n\n/**\n * Count truncate util\n * If count exceed the limit, it comes in the form of \"MAX+\"\n *\n * @param {number} count\n * @param {number} MAX default 99\n * @param {string} MAX_SUFFIX default +\n * @returns {string}\n * */\nexport const truncatedCount = (count: number, MAX = 99, MAX_SUFFIX = '+') => {\n if (count >= MAX) return `${MAX}${MAX_SUFFIX}`;\n return `${count}`;\n};\n\n/**\n * Messages date separator format\n *\n * @param {Date} date\n * @param {Locale} [locale]\n * @returns {string}\n * */\nexport const getDateSeparatorFormat = (date: Date, locale?: Locale): string => {\n if (isThisYear(date)) return format(date, 'MMM dd, yyyy', { locale });\n return format(date, 'E, MMM dd', { locale });\n};\n\n/**\n * Message time format\n *\n * @param {Date} date\n * @param {Locale} [locale]\n * @returns {string}\n * */\nexport const getMessageTimeFormat = (date: Date, locale?: Locale): string => {\n return format(date, 'p', { locale });\n};\n"],"mappings":";;;;;;;AACA;;AAIA,MAAMA,WAA2B,GAAG;EAAEC,IAAI,EAAE,KAAR;EAAeC,MAAM,EAAE,EAAvB;EAA2BC,SAAS,EAAE;AAAtC,CAApC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,MAAMC,QAAQ,GAAG,UAACC,GAAD,EAAs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AACC,IAAD,EAAaC,MAAb,KAAyC;EAC7E,IAAI,IAAAC,mBAAA,EAAWF,IAAX,CAAJ,EAAsB,OAAO,IAAAG,eAAA,EAAOH,IAAP,EAAa,cAAb,EAA6B;IAAEC;EAAF,CAA7B,CAAP;EACtB,OAAO,IAAAE,eAAA,EAAOH,IAAP,EAAa,WAAb,EAA0B;IAAEC;EAAF,CAA1B,CAAP;AACD,CAHM;AAKP;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMG,oBAAoB,GAAG,CAACJ,IAAD,EAAaC,MAAb,KAAyC;EAC3E,OAAO,IAAAE,eAAA,EAAOH,IAAP,EAAa,GAAb,EAAkB;IAAEC;EAAF,CAAlB,CAAP;AACD,CAFM"}
@@ -5,16 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getGroupChannelTitle = exports.getGroupChannelPreviewTime = exports.getGroupChannelLastMessage = void 0;
7
7
 
8
- var _format = _interopRequireDefault(require("date-fns/format"));
9
-
10
- var _isToday = _interopRequireDefault(require("date-fns/isToday"));
11
-
12
- var _isYesterday = _interopRequireDefault(require("date-fns/isYesterday"));
8
+ var _dateFns = require("date-fns");
13
9
 
14
10
  var _common = require("./common");
15
11
 
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
12
  const getGroupChannelTitle = function (currentUserId, channel) {
19
13
  let EMPTY_USERNAME = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '(No name)';
20
14
  let NO_MEMBERS = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '(No members)';
@@ -40,11 +34,14 @@ const getGroupChannelPreviewTime = (channel, locale) => {
40
34
  var _channel$lastMessage;
41
35
 
42
36
  const timestamp = ((_channel$lastMessage = channel.lastMessage) === null || _channel$lastMessage === void 0 ? void 0 : _channel$lastMessage.createdAt) || channel.joinedAt * 1000 || channel.createdAt;
43
- if ((0, _isToday.default)(timestamp)) return (0, _format.default)(timestamp, 'p', {
37
+ if ((0, _dateFns.isToday)(timestamp)) return (0, _dateFns.format)(timestamp, 'p', {
38
+ locale
39
+ });
40
+ if ((0, _dateFns.isYesterday)(timestamp)) return 'Yesterday';
41
+ if ((0, _dateFns.isThisYear)(timestamp)) return (0, _dateFns.format)(timestamp, 'MMM dd', {
44
42
  locale
45
43
  });
46
- if ((0, _isYesterday.default)(timestamp)) return 'Yesterday';
47
- return (0, _format.default)(timestamp, 'MMM dd', {
44
+ return (0, _dateFns.format)(timestamp, 'yyyy/MM/dd', {
48
45
  locale
49
46
  });
50
47
  };