@sendbird/uikit-utils 1.1.3 → 1.1.4

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.
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useAppState = void 0;
7
+
8
+ var _react = require("react");
9
+
10
+ var _reactNative = require("react-native");
11
+
12
+ const useAppState = (type, listener) => {
13
+ const callbackRef = (0, _react.useRef)(listener);
14
+ callbackRef.current = listener;
15
+ (0, _react.useEffect)(() => {
16
+ const eventListener = state => callbackRef.current(state);
17
+
18
+ const subscriber = _reactNative.AppState.addEventListener(type, eventListener);
19
+
20
+ return () => {
21
+ // @ts-ignore
22
+ if (subscriber !== null && subscriber !== void 0 && subscriber.remove) {
23
+ subscriber.remove();
24
+ } // @ts-ignore
25
+ else if (_reactNative.AppState.removeEventListener) {
26
+ // @ts-ignore
27
+ _reactNative.AppState.removeEventListener(type, eventListener);
28
+ }
29
+ };
30
+ }, []);
31
+ };
32
+
33
+ exports.useAppState = useAppState;
34
+ //# sourceMappingURL=react-native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useAppState","type","listener","callbackRef","useRef","current","useEffect","eventListener","state","subscriber","AppState","addEventListener","remove","removeEventListener"],"sources":["react-native.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport { AppState, AppStateEvent, AppStateStatus } from 'react-native';\n\ntype AppStateListener = (status: AppStateStatus) => void;\n\nexport const useAppState = (type: AppStateEvent, listener: AppStateListener) => {\n const callbackRef = useRef<AppStateListener>(listener);\n callbackRef.current = listener;\n\n useEffect(() => {\n const eventListener = (state: AppStateStatus) => callbackRef.current(state);\n const subscriber = AppState.addEventListener(type, eventListener);\n\n return () => {\n // @ts-ignore\n if (subscriber?.remove) {\n subscriber.remove();\n }\n // @ts-ignore\n else if (AppState.removeEventListener) {\n // @ts-ignore\n AppState.removeEventListener(type, eventListener);\n }\n };\n }, []);\n};\n"],"mappings":";;;;;;;AAAA;;AACA;;AAIO,MAAMA,WAAW,GAAG,CAACC,IAAD,EAAsBC,QAAtB,KAAqD;EAC9E,MAAMC,WAAW,GAAG,IAAAC,aAAA,EAAyBF,QAAzB,CAApB;EACAC,WAAW,CAACE,OAAZ,GAAsBH,QAAtB;EAEA,IAAAI,gBAAA,EAAU,MAAM;IACd,MAAMC,aAAa,GAAIC,KAAD,IAA2BL,WAAW,CAACE,OAAZ,CAAoBG,KAApB,CAAjD;;IACA,MAAMC,UAAU,GAAGC,qBAAA,CAASC,gBAAT,CAA0BV,IAA1B,EAAgCM,aAAhC,CAAnB;;IAEA,OAAO,MAAM;MACX;MACA,IAAIE,UAAJ,aAAIA,UAAJ,eAAIA,UAAU,CAAEG,MAAhB,EAAwB;QACtBH,UAAU,CAACG,MAAX;MACD,CAFD,CAGA;MAHA,KAIK,IAAIF,qBAAA,CAASG,mBAAb,EAAkC;QACrC;QACAH,qBAAA,CAASG,mBAAT,CAA6BZ,IAA7B,EAAmCM,aAAnC;MACD;IACF,CAVD;EAWD,CAfD,EAeG,EAfH;AAgBD,CApBM"}
@@ -139,6 +139,20 @@ Object.keys(_hooks).forEach(function (key) {
139
139
  });
140
140
  });
141
141
 
142
+ var _reactNative = require("./hooks/react-native");
143
+
144
+ Object.keys(_reactNative).forEach(function (key) {
145
+ if (key === "default" || key === "__esModule") return;
146
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
147
+ if (key in exports && exports[key] === _reactNative[key]) return;
148
+ Object.defineProperty(exports, key, {
149
+ enumerable: true,
150
+ get: function () {
151
+ return _reactNative[key];
152
+ }
153
+ });
154
+ });
155
+
142
156
  var _groupChannel = require("./ui-format/groupChannel");
143
157
 
144
158
  Object.keys(_groupChannel).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} from './shared/regex';\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 SendbirdGroupChannelParams,\n SendbirdFileMessageParams,\n SendbirdUserMessageParams,\n SendbirdError,\n SendbirdMessageCollection,\n SendbirdGroupChannelCollection,\n NotificationFiles,\n NotificationMentionedUsers,\n NotificationTranslations,\n PartialNullable,\n SendbirdDataPayload,\n} from './types';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAYA;;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} from './shared/regex';\n\nexport * from './hooks';\nexport * from './hooks/react-native';\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 SendbirdGroupChannelParams,\n SendbirdFileMessageParams,\n SendbirdUserMessageParams,\n SendbirdError,\n SendbirdMessageCollection,\n SendbirdGroupChannelCollection,\n NotificationFiles,\n NotificationMentionedUsers,\n NotificationTranslations,\n PartialNullable,\n SendbirdDataPayload,\n} from './types';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAYA;;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,4FACA;AAH0B,CAAvB"}
@@ -0,0 +1,22 @@
1
+ import { useEffect, useRef } from 'react';
2
+ import { AppState } from 'react-native';
3
+ export const useAppState = (type, listener) => {
4
+ const callbackRef = useRef(listener);
5
+ callbackRef.current = listener;
6
+ useEffect(() => {
7
+ const eventListener = state => callbackRef.current(state);
8
+
9
+ const subscriber = AppState.addEventListener(type, eventListener);
10
+ return () => {
11
+ // @ts-ignore
12
+ if (subscriber !== null && subscriber !== void 0 && subscriber.remove) {
13
+ subscriber.remove();
14
+ } // @ts-ignore
15
+ else if (AppState.removeEventListener) {
16
+ // @ts-ignore
17
+ AppState.removeEventListener(type, eventListener);
18
+ }
19
+ };
20
+ }, []);
21
+ };
22
+ //# sourceMappingURL=react-native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEffect","useRef","AppState","useAppState","type","listener","callbackRef","current","eventListener","state","subscriber","addEventListener","remove","removeEventListener"],"sources":["react-native.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport { AppState, AppStateEvent, AppStateStatus } from 'react-native';\n\ntype AppStateListener = (status: AppStateStatus) => void;\n\nexport const useAppState = (type: AppStateEvent, listener: AppStateListener) => {\n const callbackRef = useRef<AppStateListener>(listener);\n callbackRef.current = listener;\n\n useEffect(() => {\n const eventListener = (state: AppStateStatus) => callbackRef.current(state);\n const subscriber = AppState.addEventListener(type, eventListener);\n\n return () => {\n // @ts-ignore\n if (subscriber?.remove) {\n subscriber.remove();\n }\n // @ts-ignore\n else if (AppState.removeEventListener) {\n // @ts-ignore\n AppState.removeEventListener(type, eventListener);\n }\n };\n }, []);\n};\n"],"mappings":"AAAA,SAASA,SAAT,EAAoBC,MAApB,QAAkC,OAAlC;AACA,SAASC,QAAT,QAAwD,cAAxD;AAIA,OAAO,MAAMC,WAAW,GAAG,CAACC,IAAD,EAAsBC,QAAtB,KAAqD;EAC9E,MAAMC,WAAW,GAAGL,MAAM,CAAmBI,QAAnB,CAA1B;EACAC,WAAW,CAACC,OAAZ,GAAsBF,QAAtB;EAEAL,SAAS,CAAC,MAAM;IACd,MAAMQ,aAAa,GAAIC,KAAD,IAA2BH,WAAW,CAACC,OAAZ,CAAoBE,KAApB,CAAjD;;IACA,MAAMC,UAAU,GAAGR,QAAQ,CAACS,gBAAT,CAA0BP,IAA1B,EAAgCI,aAAhC,CAAnB;IAEA,OAAO,MAAM;MACX;MACA,IAAIE,UAAJ,aAAIA,UAAJ,eAAIA,UAAU,CAAEE,MAAhB,EAAwB;QACtBF,UAAU,CAACE,MAAX;MACD,CAFD,CAGA;MAHA,KAIK,IAAIV,QAAQ,CAACW,mBAAb,EAAkC;QACrC;QACAX,QAAQ,CAACW,mBAAT,CAA6BT,IAA7B,EAAmCI,aAAnC;MACD;IACF,CAVD;EAWD,CAfQ,EAeN,EAfM,CAAT;AAgBD,CApBM"}
@@ -4,6 +4,7 @@ export { createPubSub } from './shared/pubsub';
4
4
  export { default as conditionChaining } from './shared/conditionChaining';
5
5
  export { urlRegexStrict, urlRegexRough, newLineRegex, audioExtRegex, videoExtRegex, imageExtRegex, getFileType, getFileExtension, replaceUrlAsComponents } from './shared/regex';
6
6
  export * from './hooks';
7
+ export * from './hooks/react-native';
7
8
  export * from './ui-format/groupChannel';
8
9
  export * from './ui-format/common';
9
10
  export * from './sendbird/channel';
@@ -1 +1 @@
1
- {"version":3,"names":["Logger","default","arrayToMap","arrayToMapWithGetter","createPubSub","conditionChaining","urlRegexStrict","urlRegexRough","newLineRegex","audioExtRegex","videoExtRegex","imageExtRegex","getFileType","getFileExtension","replaceUrlAsComponents","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} from './shared/regex';\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 SendbirdGroupChannelParams,\n SendbirdFileMessageParams,\n SendbirdUserMessageParams,\n SendbirdError,\n SendbirdMessageCollection,\n SendbirdGroupChannelCollection,\n NotificationFiles,\n NotificationMentionedUsers,\n NotificationTranslations,\n PartialNullable,\n SendbirdDataPayload,\n} from './types';\n"],"mappings":"AAAA,SAASA,MAAT,QAAuB,iBAAvB;AACA,SAASC,OAAO,IAAIC,UAApB,EAAgCC,oBAAhC,QAA4D,qBAA5D;AACA,SAASC,YAAT,QAA6B,iBAA7B;AACA,SAASH,OAAO,IAAII,iBAApB,QAA6C,4BAA7C;AACA,SACEC,cADF,EAEEC,aAFF,EAGEC,YAHF,EAIEC,aAJF,EAKEC,aALF,EAMEC,aANF,EAOEC,WAPF,EAQEC,gBARF,EASEC,sBATF,QAUO,gBAVP;AAYA,cAAc,SAAd;AACA,cAAc,0BAAd;AACA,cAAc,oBAAd;AACA,cAAc,oBAAd;AACA,cAAc,oBAAd;AACA,cAAc,kBAAd;AAEA,OAAO,MAAMC,IAAgB,GAAG,MAAM,KAAK,CAApC;AACP,OAAO,MAAMC,UAAU,GAAG,YAAY,KAAK,CAApC;AACP,OAAO,MAAMC,IAAI,GAAOC,GAAJ,IAAeA,GAA5B;AACP,OAAO,MAAMC,UAAU,GAAIC,IAAD,IAAkBA,IAAI,GAAG,IAAP,GAAc,IAAnD;AACP,OAAO,MAAMC,UAAU,GAAOC,KAAJ,IAA2C,OAAOA,KAAP,KAAiB,UAA/E;AACP,OAAO,MAAMC,WAAW,GAAG;EACzBC,cAAc,EAAE;AADS,CAApB;AAGP,OAAO,MAAMC,cAAc,GAAG;EAC5BC,GAAG,EACD,4FACA;AAH0B,CAAvB"}
1
+ {"version":3,"names":["Logger","default","arrayToMap","arrayToMapWithGetter","createPubSub","conditionChaining","urlRegexStrict","urlRegexRough","newLineRegex","audioExtRegex","videoExtRegex","imageExtRegex","getFileType","getFileExtension","replaceUrlAsComponents","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} from './shared/regex';\n\nexport * from './hooks';\nexport * from './hooks/react-native';\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 SendbirdGroupChannelParams,\n SendbirdFileMessageParams,\n SendbirdUserMessageParams,\n SendbirdError,\n SendbirdMessageCollection,\n SendbirdGroupChannelCollection,\n NotificationFiles,\n NotificationMentionedUsers,\n NotificationTranslations,\n PartialNullable,\n SendbirdDataPayload,\n} from './types';\n"],"mappings":"AAAA,SAASA,MAAT,QAAuB,iBAAvB;AACA,SAASC,OAAO,IAAIC,UAApB,EAAgCC,oBAAhC,QAA4D,qBAA5D;AACA,SAASC,YAAT,QAA6B,iBAA7B;AACA,SAASH,OAAO,IAAII,iBAApB,QAA6C,4BAA7C;AACA,SACEC,cADF,EAEEC,aAFF,EAGEC,YAHF,EAIEC,aAJF,EAKEC,aALF,EAMEC,aANF,EAOEC,WAPF,EAQEC,gBARF,EASEC,sBATF,QAUO,gBAVP;AAYA,cAAc,SAAd;AACA,cAAc,sBAAd;AACA,cAAc,0BAAd;AACA,cAAc,oBAAd;AACA,cAAc,oBAAd;AACA,cAAc,oBAAd;AACA,cAAc,kBAAd;AAEA,OAAO,MAAMC,IAAgB,GAAG,MAAM,KAAK,CAApC;AACP,OAAO,MAAMC,UAAU,GAAG,YAAY,KAAK,CAApC;AACP,OAAO,MAAMC,IAAI,GAAOC,GAAJ,IAAeA,GAA5B;AACP,OAAO,MAAMC,UAAU,GAAIC,IAAD,IAAkBA,IAAI,GAAG,IAAP,GAAc,IAAnD;AACP,OAAO,MAAMC,UAAU,GAAOC,KAAJ,IAA2C,OAAOA,KAAP,KAAiB,UAA/E;AACP,OAAO,MAAMC,WAAW,GAAG;EACzBC,cAAc,EAAE;AADS,CAApB;AAGP,OAAO,MAAMC,cAAc,GAAG;EAC5BC,GAAG,EACD,4FACA;AAH0B,CAAvB"}
@@ -0,0 +1,4 @@
1
+ import { AppStateEvent, AppStateStatus } from 'react-native';
2
+ declare type AppStateListener = (status: AppStateStatus) => void;
3
+ export declare const useAppState: (type: AppStateEvent, listener: AppStateListener) => void;
4
+ export {};
@@ -4,6 +4,7 @@ export { createPubSub } from './shared/pubsub';
4
4
  export { default as conditionChaining } from './shared/conditionChaining';
5
5
  export { urlRegexStrict, urlRegexRough, newLineRegex, audioExtRegex, videoExtRegex, imageExtRegex, getFileType, getFileExtension, replaceUrlAsComponents, } from './shared/regex';
6
6
  export * from './hooks';
7
+ export * from './hooks/react-native';
7
8
  export * from './ui-format/groupChannel';
8
9
  export * from './ui-format/common';
9
10
  export * from './sendbird/channel';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sendbird/uikit-utils",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "UIKit utilities",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -43,6 +43,7 @@
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/react": "*",
46
+ "@types/react-native": "*",
46
47
  "react": "17.0.2",
47
48
  "react-native": "0.66.4",
48
49
  "react-native-builder-bob": "^0.18.0",
@@ -76,5 +77,5 @@
76
77
  "readmeFile": "./README.md",
77
78
  "displayName": "@sendbird/uikit-utils"
78
79
  },
79
- "gitHead": "99c133a8bbee3d806bf72ffc040acdd5c883d1d7"
80
+ "gitHead": "8de6170b3df8284dc45a6bb4083bcf201a05c679"
80
81
  }
@@ -0,0 +1,26 @@
1
+ import { useEffect, useRef } from 'react';
2
+ import { AppState, AppStateEvent, AppStateStatus } from 'react-native';
3
+
4
+ type AppStateListener = (status: AppStateStatus) => void;
5
+
6
+ export const useAppState = (type: AppStateEvent, listener: AppStateListener) => {
7
+ const callbackRef = useRef<AppStateListener>(listener);
8
+ callbackRef.current = listener;
9
+
10
+ useEffect(() => {
11
+ const eventListener = (state: AppStateStatus) => callbackRef.current(state);
12
+ const subscriber = AppState.addEventListener(type, eventListener);
13
+
14
+ return () => {
15
+ // @ts-ignore
16
+ if (subscriber?.remove) {
17
+ subscriber.remove();
18
+ }
19
+ // @ts-ignore
20
+ else if (AppState.removeEventListener) {
21
+ // @ts-ignore
22
+ AppState.removeEventListener(type, eventListener);
23
+ }
24
+ };
25
+ }, []);
26
+ };
package/src/index.ts CHANGED
@@ -15,6 +15,7 @@ export {
15
15
  } from './shared/regex';
16
16
 
17
17
  export * from './hooks';
18
+ export * from './hooks/react-native';
18
19
  export * from './ui-format/groupChannel';
19
20
  export * from './ui-format/common';
20
21
  export * from './sendbird/channel';