@sendbird/uikit-utils 2.0.3 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) 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 +39 -2
  4. package/lib/commonjs/index.js.map +1 -1
  5. package/lib/commonjs/sendbird/channel.js +18 -6
  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 +23 -0
  10. package/lib/commonjs/sendbird/user.js.map +1 -0
  11. package/lib/commonjs/shared/bufferedRequest.js +38 -12
  12. package/lib/commonjs/shared/bufferedRequest.js.map +1 -1
  13. package/lib/commonjs/shared/regex.js +52 -6
  14. package/lib/commonjs/shared/regex.js.map +1 -1
  15. package/lib/commonjs/shared/replace.js +14 -0
  16. package/lib/commonjs/shared/replace.js.map +1 -0
  17. package/lib/commonjs/types.js +3 -1
  18. package/lib/commonjs/types.js.map +1 -1
  19. package/lib/commonjs/ui-format/common.js +17 -14
  20. package/lib/commonjs/ui-format/common.js.map +1 -1
  21. package/lib/commonjs/ui-format/groupChannel.js +7 -10
  22. package/lib/commonjs/ui-format/groupChannel.js.map +1 -1
  23. package/lib/module/hooks/index.js +10 -0
  24. package/lib/module/hooks/index.js.map +1 -1
  25. package/lib/module/index.js +4 -2
  26. package/lib/module/index.js.map +1 -1
  27. package/lib/module/sendbird/channel.js +14 -4
  28. package/lib/module/sendbird/channel.js.map +1 -1
  29. package/lib/module/sendbird/message.js +9 -3
  30. package/lib/module/sendbird/message.js.map +1 -1
  31. package/lib/module/sendbird/user.js +12 -0
  32. package/lib/module/sendbird/user.js.map +1 -0
  33. package/lib/module/shared/bufferedRequest.js +39 -12
  34. package/lib/module/shared/bufferedRequest.js.map +1 -1
  35. package/lib/module/shared/regex.js +43 -3
  36. package/lib/module/shared/regex.js.map +1 -1
  37. package/lib/module/shared/replace.js +6 -0
  38. package/lib/module/shared/replace.js.map +1 -0
  39. package/lib/module/types.js +1 -4
  40. package/lib/module/types.js.map +1 -1
  41. package/lib/module/ui-format/common.js +12 -7
  42. package/lib/module/ui-format/common.js.map +1 -1
  43. package/lib/module/ui-format/groupChannel.js +5 -4
  44. package/lib/module/ui-format/groupChannel.js.map +1 -1
  45. package/lib/typescript/src/hooks/index.d.ts +3 -2
  46. package/lib/typescript/src/index.d.ts +4 -2
  47. package/lib/typescript/src/sendbird/channel.d.ts +6 -1
  48. package/lib/typescript/src/sendbird/message.d.ts +4 -2
  49. package/lib/typescript/src/sendbird/user.d.ts +7 -0
  50. package/lib/typescript/src/shared/bufferedRequest.d.ts +6 -4
  51. package/lib/typescript/src/shared/logger.d.ts +1 -1
  52. package/lib/typescript/src/shared/pubsub.d.ts +2 -2
  53. package/lib/typescript/src/shared/regex.d.ts +8 -0
  54. package/lib/typescript/src/shared/replace.d.ts +2 -0
  55. package/lib/typescript/src/types.d.ts +42 -35
  56. package/lib/typescript/src/ui-format/common.d.ts +7 -6
  57. package/package.json +3 -3
  58. package/src/hooks/index.ts +11 -0
  59. package/src/index.ts +14 -2
  60. package/src/sendbird/channel.ts +11 -4
  61. package/src/sendbird/message.ts +13 -3
  62. package/src/sendbird/user.ts +21 -0
  63. package/src/shared/bufferedRequest.ts +37 -12
  64. package/src/shared/regex.ts +35 -0
  65. package/src/shared/replace.ts +5 -0
  66. package/src/types.ts +21 -3
  67. package/src/ui-format/common.ts +9 -7
  68. 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,EAAm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","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,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,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) {
@@ -239,6 +262,20 @@ Object.keys(_attrs).forEach(function (key) {
239
262
  });
240
263
  });
241
264
 
265
+ var _user = require("./sendbird/user");
266
+
267
+ Object.keys(_user).forEach(function (key) {
268
+ if (key === "default" || key === "__esModule") return;
269
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
270
+ if (key in exports && exports[key] === _user[key]) return;
271
+ Object.defineProperty(exports, key, {
272
+ enumerable: true,
273
+ get: function () {
274
+ return _user[key];
275
+ }
276
+ });
277
+ });
278
+
242
279
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
243
280
 
244
281
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -269,7 +306,7 @@ const SBErrorCode = {
269
306
  };
270
307
  exports.SBErrorCode = SBErrorCode;
271
308
  const SBErrorMessage = {
272
- ACL: "An error occurred because you don't have access to the user list in your application.\n" + 'In order to gain access, you can turn on this attribute in the Access Control List settings on Sendbird Dashboard.'
309
+ ACL: 'Sendbird provides various access control options when using the Chat SDK.\n' + 'By default, the Allow retrieving user list attribute is turned on to facilitate creating sample apps.\n' + 'However, this may grant access to unwanted data or operations, leading to potential security concerns.\n' + 'To manage your access control settings, you can turn on or off each setting on Sendbird Dashboard.'
273
310
  };
274
311
  exports.SBErrorMessage = SBErrorMessage;
275
312
  //# sourceMappingURL=index.js.map
@@ -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';\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 \"An error occurred because you don't have access to the user list in your application.\\n\" +\n 'In order to gain access, you can turn on this attribute in the Access Control List settings 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} 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;;;;;;;;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,4FACA;AAH0B,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":";;;;;;;;;;;;;;;;;;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value: true
5
5
  });
6
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;
10
12
  exports.isDefaultCoverImage = isDefaultCoverImage;
11
13
  exports.isDifferentChannel = isDifferentChannel;
12
- exports.isGroupChannelChatUnavailable = void 0;
13
14
 
14
15
  var _bufferedRequest = require("../shared/bufferedRequest");
15
16
 
@@ -24,20 +25,27 @@ function isDifferentChannel(a, b) {
24
25
  return a.url !== b.url;
25
26
  }
26
27
 
27
- const isGroupChannelChatUnavailable = channel => {
28
- return channel.myMutedState === 'muted' || channel.isFrozen && channel.myRole !== 'operator';
28
+ const getGroupChannelChatAvailableState = channel => {
29
+ const frozen = channel.isFrozen && channel.myRole !== 'operator';
30
+ const muted = channel.myMutedState === 'muted';
31
+ const disabled = frozen || muted;
32
+ return {
33
+ disabled,
34
+ frozen,
35
+ muted
36
+ };
29
37
  };
30
38
 
31
- exports.isGroupChannelChatUnavailable = isGroupChannelChatUnavailable;
39
+ exports.getGroupChannelChatAvailableState = getGroupChannelChatAvailableState;
32
40
 
33
41
  const confirmAndMarkAsRead = async channels => {
34
- channels.filter(it => it.isGroupChannel() && it.unreadMessageCount > 0).forEach(it => _bufferedRequest.BufferedRequest.markAsRead.push(() => it.markAsRead()));
42
+ channels.filter(it => it.isGroupChannel() && it.unreadMessageCount > 0).forEach(it => _bufferedRequest.BufferedRequest.markAsRead.push(() => it.markAsRead(), it.url));
35
43
  };
36
44
 
37
45
  exports.confirmAndMarkAsRead = confirmAndMarkAsRead;
38
46
 
39
47
  const confirmAndMarkAsDelivered = async channels => {
40
- channels.filter(it => it.isGroupChannel() && it.unreadMessageCount > 0).forEach(it => _bufferedRequest.BufferedRequest.markAsDelivered.push(() => it.markAsDelivered()));
48
+ channels.filter(it => it.isGroupChannel() && it.unreadMessageCount > 0).forEach(it => _bufferedRequest.BufferedRequest.markAsDelivered.push(() => it.markAsDelivered(), it.url));
41
49
  };
42
50
 
43
51
  exports.confirmAndMarkAsDelivered = confirmAndMarkAsDelivered;
@@ -57,4 +65,8 @@ function getGroupChannels(channels) {
57
65
  function getOpenChannels(channels) {
58
66
  return channels.filter(c => c.isOpenChannel());
59
67
  }
68
+
69
+ function getChannelUniqId(channel) {
70
+ return channel.url;
71
+ }
60
72
  //# sourceMappingURL=channel.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["isDifferentChannel","a","b","url","isGroupChannelChatUnavailable","channel","myMutedState","isFrozen","myRole","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 isGroupChannelChatUnavailable = (channel: SendbirdGroupChannel) => {\n return channel.myMutedState === 'muted' || (channel.isFrozen && channel.myRole !== 'operator');\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()));\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()));\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,MAAMC,6BAA6B,GAAIC,OAAD,IAAmC;EAC9E,OAAOA,OAAO,CAACC,YAAR,KAAyB,OAAzB,IAAqCD,OAAO,CAACE,QAAR,IAAoBF,OAAO,CAACG,MAAR,KAAmB,UAAnF;AACD,CAFM;;;;AAIA,MAAMC,oBAAoB,GAAG,MAAOC,QAAP,IAA2C;EAC7EA,QAAQ,CACLC,MADH,CACWC,EAAD,IAAoCA,EAAE,CAACC,cAAH,MAAuBD,EAAE,CAACE,kBAAH,GAAwB,CAD7F,EAEGC,OAFH,CAEYH,EAAD,IAAQI,gCAAA,CAAgBC,UAAhB,CAA2BC,IAA3B,CAAgC,MAAMN,EAAE,CAACK,UAAH,EAAtC,CAFnB;AAGD,CAJM;;;;AAMA,MAAME,yBAAyB,GAAG,MAAOT,QAAP,IAA2C;EAClFA,QAAQ,CACLC,MADH,CACWC,EAAD,IAAoCA,EAAE,CAACC,cAAH,MAAuBD,EAAE,CAACE,kBAAH,GAAwB,CAD7F,EAEGC,OAFH,CAEYH,EAAD,IAAQI,gCAAA,CAAgBI,eAAhB,CAAgCF,IAAhC,CAAqC,MAAMN,EAAE,CAACQ,eAAH,EAA3C,CAFnB;AAGD,CAJM;;;;AAMA,SAASC,mBAAT,CAA6BC,QAA7B,EAA+C;EACpD,OAAOA,QAAQ,KAAK,EAAb,IAAmBA,QAAQ,CAACC,UAAT,CAAoB,0CAApB,CAA1B;AACD;;AAEM,SAASC,mBAAT,CAA6BnB,OAA7B,EAA4DoB,aAA5D,EAAoF;EACzF,OAAOpB,OAAO,CAACqB,OAAR,CAAgBf,MAAhB,CAAwBgB,CAAD,IAAOA,CAAC,CAACC,MAAF,KAAaH,aAA3C,CAAP;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,OA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,OAAR,CAAgBf,MAAhB,CAAwBgB,CAAD,IAAOA,CAAC,CAACC,MAAF,KAAaH,aAA3C,CAAP;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;;AAEM,SAASC,gBAAT,CAA0B/B,OAA1B,EAAoD;EACzD,OAAOA,OAAO,CAACF,GAAf;AACD"}
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.calcMessageGrouping = calcMessageGrouping;
7
7
  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,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G,CAACU,aAAJ,KAAsB,WAA1B,EAAuC,OAAOwB,MAAM,CAAClC,GAAG,CAACmC,SAAL,CAAb;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"}
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":";;;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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"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getUserUniqId = getUserUniqId;
7
+ exports.ifMuted = ifMuted;
8
+ exports.ifOperator = ifOperator;
9
+
10
+ function ifOperator(role, then, or) {
11
+ if (role === 'operator') return then;
12
+ return or;
13
+ }
14
+
15
+ function ifMuted(muted, then, or) {
16
+ if (muted) return then;
17
+ return or;
18
+ }
19
+
20
+ function getUserUniqId(user) {
21
+ return user.userId;
22
+ }
23
+ //# sourceMappingURL=user.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ifOperator","role","then","or","ifMuted","muted","getUserUniqId","user","userId"],"sources":["user.ts"],"sourcesContent":["import type { Role } from '@sendbird/chat';\n\nimport type { UserStruct } from '../types';\n\nexport function ifOperator<T>(role: Role, then: T): T | undefined;\nexport function ifOperator<T, V>(role: Role, then: T, or: V): T | V;\nexport function ifOperator(role: Role, then: unknown, or?: unknown) {\n if (role === 'operator') return then;\n return or;\n}\n\nexport function ifMuted<T>(muted: boolean, then: T): T | undefined;\nexport function ifMuted<T, V>(muted: boolean, then: T, or: V): T | V;\nexport function ifMuted(muted: boolean, then: unknown, or?: unknown) {\n if (muted) return then;\n return or;\n}\n\nexport function getUserUniqId<T extends UserStruct>(user: T) {\n return user.userId;\n}\n"],"mappings":";;;;;;;;;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"}
@@ -11,7 +11,19 @@ let REQ_PER_TIMEOUT = 5;
11
11
  let TIMEOUT_MILLS = 1000;
12
12
  const SAFE_TIMEOUT_BUFFER = 100;
13
13
 
14
+ function generateRandomId() {
15
+ return Math.random().toString(16).slice(2);
16
+ }
17
+
14
18
  class BufferedRequest {
19
+ static updateMarkAsReadOptions(reqPerTimeout, timeoutMills) {
20
+ BufferedRequest.markAsRead = BufferedRequest.create(reqPerTimeout, timeoutMills);
21
+ }
22
+
23
+ static updateMarkAsDeliveredOptions(reqPerTimeout, timeoutMills) {
24
+ BufferedRequest.markAsDelivered = BufferedRequest.create(reqPerTimeout, timeoutMills);
25
+ }
26
+
15
27
  static get reqPerTimeout() {
16
28
  return REQ_PER_TIMEOUT;
17
29
  }
@@ -35,29 +47,35 @@ class BufferedRequest {
35
47
  static create() {
36
48
  let reqPerTimeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : REQ_PER_TIMEOUT;
37
49
  let timeoutMills = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : TIMEOUT_MILLS;
38
- const waitQueue = [];
39
- const nextQueue = [];
50
+ const waitQueue = new Map();
51
+ const nextQueue = new Map();
40
52
  let state = 'idle';
41
53
  let timeout;
42
54
  return {
43
- push(func) {
44
- waitQueue.push(func);
55
+ push(func, lane) {
56
+ waitQueue.set(lane ?? generateRandomId(), func);
45
57
  this.invoke();
46
58
  },
47
59
 
48
60
  shift() {
49
- if (nextQueue.length < reqPerTimeout) {
50
- const nextRemains = Math.min(reqPerTimeout - nextQueue.length, waitQueue.length);
61
+ if (nextQueue.size < reqPerTimeout) {
62
+ const nextRemains = Math.min(reqPerTimeout - nextQueue.size, waitQueue.size);
63
+ const lanes = [...waitQueue.keys()];
51
64
 
52
65
  for (let n = 0; n < nextRemains; n++) {
53
- const func = waitQueue.shift();
54
- if (func) nextQueue.push(func);
66
+ const lane = lanes[n];
67
+ const func = waitQueue.get(lane);
68
+
69
+ if (func) {
70
+ waitQueue.delete(lane);
71
+ nextQueue.set(lane, func);
72
+ }
55
73
  }
56
74
  }
57
75
  },
58
76
 
59
77
  handleIdle() {
60
- if (0 < nextQueue.length) {
78
+ if (0 < nextQueue.size) {
61
79
  state = 'processing';
62
80
  this.invoke();
63
81
  }
@@ -68,14 +86,22 @@ class BufferedRequest {
68
86
  timeout = setTimeout(() => {
69
87
  timeout = undefined;
70
88
 
71
- if (0 < nextQueue.length || 0 < waitQueue.length) {
89
+ if (0 < nextQueue.size || 0 < waitQueue.size) {
72
90
  this.invoke();
73
91
  } else {
74
92
  state = 'idle';
75
93
  }
76
94
  }, timeoutMills + SAFE_TIMEOUT_BUFFER);
77
- nextQueue.forEach(func => func());
78
- nextQueue.length = 0;
95
+ let index = 0;
96
+ const nextRequestBaseTimeout = timeoutMills / nextQueue.size;
97
+ nextQueue.forEach(func => {
98
+ setTimeout(() => {
99
+ func(); // TODO: Add retry
100
+ //.catch(() => waitQueue.set(lane, func));
101
+ }, nextRequestBaseTimeout * index);
102
+ index++;
103
+ });
104
+ nextQueue.clear();
79
105
  },
80
106
 
81
107
  async invoke() {
@@ -1 +1 @@
1
- {"version":3,"names":["REQ_PER_TIMEOUT","TIMEOUT_MILLS","SAFE_TIMEOUT_BUFFER","BufferedRequest","reqPerTimeout","value","markAsRead","create","markAsDelivered","timeoutMills","waitQueue","nextQueue","state","timeout","push","func","invoke","shift","length","nextRemains","Math","min","n","handleIdle","handleProcessing","setTimeout","undefined","forEach"],"sources":["bufferedRequest.ts"],"sourcesContent":["type Func = (...args: unknown[]) => Promise<unknown>;\ntype State = 'idle' | 'processing';\n\nlet REQ_PER_TIMEOUT = 5;\nlet TIMEOUT_MILLS = 1000;\nconst SAFE_TIMEOUT_BUFFER = 100;\n\nexport class BufferedRequest {\n public static markAsRead = BufferedRequest.create();\n public static markAsDelivered = BufferedRequest.create();\n\n public static get reqPerTimeout() {\n return REQ_PER_TIMEOUT;\n }\n public static set reqPerTimeout(value: number) {\n REQ_PER_TIMEOUT = value;\n BufferedRequest.markAsRead = BufferedRequest.create();\n BufferedRequest.markAsDelivered = BufferedRequest.create();\n }\n\n public static get timeoutMills() {\n return TIMEOUT_MILLS;\n }\n public static set timeoutMills(value: number) {\n TIMEOUT_MILLS = value;\n BufferedRequest.markAsRead = BufferedRequest.create();\n BufferedRequest.markAsDelivered = BufferedRequest.create();\n }\n\n public static create(reqPerTimeout = REQ_PER_TIMEOUT, timeoutMills = TIMEOUT_MILLS) {\n const waitQueue: Func[] = [];\n const nextQueue: Func[] = [];\n\n let state: State = 'idle';\n let timeout: NodeJS.Timeout | undefined;\n\n return {\n push(func: Func) {\n waitQueue.push(func);\n this.invoke();\n },\n shift() {\n if (nextQueue.length < reqPerTimeout) {\n const nextRemains = Math.min(reqPerTimeout - nextQueue.length, waitQueue.length);\n for (let n = 0; n < nextRemains; n++) {\n const func = waitQueue.shift();\n if (func) nextQueue.push(func);\n }\n }\n },\n handleIdle() {\n if (0 < nextQueue.length) {\n state = 'processing';\n this.invoke();\n }\n },\n handleProcessing() {\n if (timeout) return;\n\n timeout = setTimeout(() => {\n timeout = undefined;\n if (0 < nextQueue.length || 0 < waitQueue.length) {\n this.invoke();\n } else {\n state = 'idle';\n }\n }, timeoutMills + SAFE_TIMEOUT_BUFFER);\n\n nextQueue.forEach((func) => func());\n nextQueue.length = 0;\n },\n async invoke() {\n this.shift();\n\n if (state === 'idle') {\n this.handleIdle();\n }\n\n if (state === 'processing') {\n this.handleProcessing();\n }\n },\n };\n }\n}\n"],"mappings":";;;;;;;;;AAGA,IAAI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AAMP,IAAI,GAAGL,SAAS,CAACO,KAAV,EAAb;YACA,IAAIF,IAAJ,EAAUJ,SAAS,CAACG,IAAV,CAAeC,IAAf;UACX;QACF;MACF,CAbI;;MAcLQ,UAAU,GAAG;QACX,IAAI,IAAIZ,SAAS,CAACO,MAAlB,EAA0B;UACxBN,KAAK,GAAG,YAAR;UACA,KAAKI,MAAL;QACD;MACF,CAnBI;;MAoBLQ,gBAAgB,GAAG;QACjB,IAAIX,OAAJ,EAAa;QAEbA,OAAO,GAAGY,UAAU,CAAC,MAAM;UACzBZ,OAAO,GAAGa,SAAV;;UACA,IAAI,IAAIf,SAAS,CAACO,MAAd,IAAwB,IAAIR,SAAS,CAACQ,MAA1C,EAAkD;YAChD,KAAKF,MAAL;UACD,CAFD,MAEO;YACLJ,KAAK,GAAG,MAAR;UACD;QACF,CAPmB,EAOjBH,YAAY,GAAGP,mBAPE,CAApB;QASAS,SAAS,CAACgB,OAAV,CAAmBZ,IAAD,IAAUA,IAAI,EAAhC;QACAJ,SAAS,CAACO,MAAV,GAAmB,CAAnB;MACD,CAlCI;;MAmCL,MAAMF,MAAN,GAAe;QACb,KAAKC,KAAL;;QAEA,IAAIL,KAAK,KAAK,MAAd,EAAsB;UACpB,KAAKW,UAAL;QACD;;QAED,IAAIX,KAAK,KAAK,YAAd,EAA4B;UAC1B,KAAKY,gBAAL;QACD;MACF;;IA7CI,CAAP;EA+CD;;AA5E0B;;;;gBAAhBrB,e,gBACgBA,eAAe,CAACI,MAAhB,E;;gBADhBJ,e,qBAEqBA,eAAe,CAACI,MAAhB,E"}
1
+ {"version":3,"names":["REQ_PER_TIMEOUT","TIMEOUT_MILLS","SAFE_TIMEOUT_BUFFER","generateRandomId","Math","random","toString","slice","BufferedRequest","updateMarkAsReadOptions","reqPerTimeout","timeoutMills","markAsRead","create","updateMarkAsDeliveredOptions","markAsDelivered","value","waitQueue","Map","nextQueue","state","timeout","push","func","lane","set","invoke","shift","size","nextRemains","min","lanes","keys","n","get","delete","handleIdle","handleProcessing","setTimeout","undefined","index","nextRequestBaseTimeout","forEach","clear"],"sources":["bufferedRequest.ts"],"sourcesContent":["type Func = (...args: unknown[]) => Promise<unknown>;\ntype State = 'idle' | 'processing';\n\nlet REQ_PER_TIMEOUT = 5;\nlet TIMEOUT_MILLS = 1000;\nconst SAFE_TIMEOUT_BUFFER = 100;\n\nfunction generateRandomId() {\n return Math.random().toString(16).slice(2);\n}\n\nexport class BufferedRequest {\n public static markAsRead = BufferedRequest.create();\n public static markAsDelivered = BufferedRequest.create();\n\n public static updateMarkAsReadOptions(reqPerTimeout: number, timeoutMills: number) {\n BufferedRequest.markAsRead = BufferedRequest.create(reqPerTimeout, timeoutMills);\n }\n public static updateMarkAsDeliveredOptions(reqPerTimeout: number, timeoutMills: number) {\n BufferedRequest.markAsDelivered = BufferedRequest.create(reqPerTimeout, timeoutMills);\n }\n\n public static get reqPerTimeout() {\n return REQ_PER_TIMEOUT;\n }\n public static set reqPerTimeout(value: number) {\n REQ_PER_TIMEOUT = value;\n BufferedRequest.markAsRead = BufferedRequest.create();\n BufferedRequest.markAsDelivered = BufferedRequest.create();\n }\n\n public static get timeoutMills() {\n return TIMEOUT_MILLS;\n }\n public static set timeoutMills(value: number) {\n TIMEOUT_MILLS = value;\n BufferedRequest.markAsRead = BufferedRequest.create();\n BufferedRequest.markAsDelivered = BufferedRequest.create();\n }\n\n public static create(reqPerTimeout = REQ_PER_TIMEOUT, timeoutMills = TIMEOUT_MILLS) {\n const waitQueue = new Map<string, Func>();\n const nextQueue = new Map<string, Func>();\n\n let state: State = 'idle';\n let timeout: NodeJS.Timeout | undefined;\n\n return {\n push(func: Func, lane?: string) {\n waitQueue.set(lane ?? generateRandomId(), func);\n this.invoke();\n },\n shift() {\n if (nextQueue.size < reqPerTimeout) {\n const nextRemains = Math.min(reqPerTimeout - nextQueue.size, waitQueue.size);\n const lanes = [...waitQueue.keys()];\n for (let n = 0; n < nextRemains; n++) {\n const lane = lanes[n];\n const func = waitQueue.get(lane);\n if (func) {\n waitQueue.delete(lane);\n nextQueue.set(lane, func);\n }\n }\n }\n },\n handleIdle() {\n if (0 < nextQueue.size) {\n state = 'processing';\n this.invoke();\n }\n },\n handleProcessing() {\n if (timeout) return;\n\n timeout = setTimeout(() => {\n timeout = undefined;\n if (0 < nextQueue.size || 0 < waitQueue.size) {\n this.invoke();\n } else {\n state = 'idle';\n }\n }, timeoutMills + SAFE_TIMEOUT_BUFFER);\n\n let index = 0;\n const nextRequestBaseTimeout = timeoutMills / nextQueue.size;\n nextQueue.forEach((func) => {\n setTimeout(() => {\n func();\n // TODO: Add retry\n //.catch(() => waitQueue.set(lane, func));\n }, nextRequestBaseTimeout * index);\n index++;\n });\n nextQueue.clear();\n },\n async invoke() {\n this.shift();\n\n if (state === 'idle') {\n this.handleIdle();\n }\n\n if (state === 'processing') {\n this.handleProcessing();\n }\n },\n };\n }\n}\n"],"mappings":";;;;;;;;;AAGA,IAAIA,eAAe,GAAG,CAAtB;AACA,IAAIC,aAAa,GAAG,IAApB;AACA,MAAMC,mBAAmB,GAAG,GAA5B;;AAEA,SAASC,gBAAT,GAA4B;EAC1B,OAAOC,IAAI,CAACC,MAAL,GAAcC,QAAd,CAAuB,EAAvB,EAA2BC,KAA3B,CAAiC,CAAjC,CAAP;AACD;;AAEM,MAAMC,eAAN,CAAsB;EAIU,OAAvBC,uBAAuB,CAACC,aAAD,EAAwBC,YAAxB,EAA8C;IACjFH,eAAe,CAACI,UAAhB,GAA6BJ,eAAe,CAACK,MAAhB,CAAuBH,aAAvB,EAAsCC,YAAtC,CAA7B;EACD;;EACyC,OAA5BG,4BAA4B,CAACJ,aAAD,EAAwBC,YAAxB,EAA8C;IACtFH,eAAe,CAACO,eAAhB,GAAkCP,eAAe,CAACK,MAAhB,CAAuBH,aAAvB,EAAsCC,YAAtC,CAAlC;EACD;;EAE8B,WAAbD,aAAa,GAAG;IAChC,OAAOV,eAAP;EACD;;EAC8B,WAAbU,aAAa,CAACM,KAAD,EAAgB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BAEqBA,eAAe,CAACK,MAAhB,E"}
@@ -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,OAAO,CAACG,GAAR,CAAaC,KAAD,IAAW;IACpC,MAAMC,IAAI,GAAGD,KAAK,CAAC,CAAD,CAAlB;IACA,MAAME,KAAK,GAAGF,KAAK,CAACG,KAAN,IAAe,CAA7B;IACA,MAAMC,GAAG,GAAGF,KAAK,GAAGD,IAAI,CAACI,MAAzB;IACA,OAAO;MAAEJ,IAAF;MAAQC,KAAR;MAAeE;IAAf,CAAP;EACD,CALc,CAAf;EAOA,MAAME,KAAwB,GAAG,CAACb,UAAD,CAAjC;EACA,IAAIc,MAAM,GAAG,CAA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AcA,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,MAAMC,UAAU,GAAG,sDAAnB;;AACA,MAAMC,UAAU,GAAG,cAAnB;;AACA,MAAMC,YAAY,GAAG,aAArB;;;AAEA,MAAMC,0BAA0B,GAAIC,OAAD,IAAqB,IAAIC,MAAJ,CAAY,IAAGD,OAAQ,gBAAvB,EAAwC,GAAxC,CAAxD,C,CAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AAEO,MAAME,gBAAgB,GAAG,CAC9BC,IAD8B,EAE9BC,KAF8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