@sendbird/uikit-utils 1.1.2 → 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.
- package/lib/commonjs/hooks/react-native.js +34 -0
- package/lib/commonjs/hooks/react-native.js.map +1 -0
- package/lib/commonjs/index.js +31 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/hooks/react-native.js +22 -0
- package/lib/module/hooks/react-native.js.map +1 -0
- package/lib/module/index.js +8 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/hooks/react-native.d.ts +4 -0
- package/lib/typescript/src/index.d.ts +8 -0
- package/package.json +3 -2
- package/src/hooks/react-native.ts +26 -0
- package/src/index.ts +10 -0
|
@@ -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"}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -8,6 +8,9 @@ var _exportNames = {
|
|
|
8
8
|
ASYNC_NOOP: true,
|
|
9
9
|
PASS: true,
|
|
10
10
|
toMegabyte: true,
|
|
11
|
+
isFunction: true,
|
|
12
|
+
SBErrorCode: true,
|
|
13
|
+
SBErrorMessage: true,
|
|
11
14
|
Logger: true,
|
|
12
15
|
arrayToMap: true,
|
|
13
16
|
arrayToMapWithGetter: true,
|
|
@@ -30,7 +33,7 @@ Object.defineProperty(exports, "Logger", {
|
|
|
30
33
|
return _logger.Logger;
|
|
31
34
|
}
|
|
32
35
|
});
|
|
33
|
-
exports.PASS = exports.NOOP = void 0;
|
|
36
|
+
exports.SBErrorMessage = exports.SBErrorCode = exports.PASS = exports.NOOP = void 0;
|
|
34
37
|
Object.defineProperty(exports, "arrayToMap", {
|
|
35
38
|
enumerable: true,
|
|
36
39
|
get: function () {
|
|
@@ -79,6 +82,7 @@ Object.defineProperty(exports, "imageExtRegex", {
|
|
|
79
82
|
return _regex.imageExtRegex;
|
|
80
83
|
}
|
|
81
84
|
});
|
|
85
|
+
exports.isFunction = void 0;
|
|
82
86
|
Object.defineProperty(exports, "newLineRegex", {
|
|
83
87
|
enumerable: true,
|
|
84
88
|
get: function () {
|
|
@@ -135,6 +139,20 @@ Object.keys(_hooks).forEach(function (key) {
|
|
|
135
139
|
});
|
|
136
140
|
});
|
|
137
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
|
+
|
|
138
156
|
var _groupChannel = require("./ui-format/groupChannel");
|
|
139
157
|
|
|
140
158
|
Object.keys(_groupChannel).forEach(function (key) {
|
|
@@ -226,4 +244,16 @@ exports.PASS = PASS;
|
|
|
226
244
|
const toMegabyte = byte => byte / 1024 / 1024;
|
|
227
245
|
|
|
228
246
|
exports.toMegabyte = toMegabyte;
|
|
247
|
+
|
|
248
|
+
const isFunction = param => typeof param === 'function';
|
|
249
|
+
|
|
250
|
+
exports.isFunction = isFunction;
|
|
251
|
+
const SBErrorCode = {
|
|
252
|
+
NON_AUTHORIZED: 400108
|
|
253
|
+
};
|
|
254
|
+
exports.SBErrorCode = SBErrorCode;
|
|
255
|
+
const SBErrorMessage = {
|
|
256
|
+
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.'
|
|
257
|
+
};
|
|
258
|
+
exports.SBErrorMessage = SBErrorMessage;
|
|
229
259
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NOOP","ASYNC_NOOP","PASS","val","toMegabyte","byte"],"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;\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":"
|
|
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"}
|
package/lib/module/index.js
CHANGED
|
@@ -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';
|
|
@@ -13,4 +14,11 @@ export const NOOP = () => void 0;
|
|
|
13
14
|
export const ASYNC_NOOP = async () => void 0;
|
|
14
15
|
export const PASS = val => val;
|
|
15
16
|
export const toMegabyte = byte => byte / 1024 / 1024;
|
|
17
|
+
export const isFunction = param => typeof param === 'function';
|
|
18
|
+
export const SBErrorCode = {
|
|
19
|
+
NON_AUTHORIZED: 400108
|
|
20
|
+
};
|
|
21
|
+
export const SBErrorMessage = {
|
|
22
|
+
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.'
|
|
23
|
+
};
|
|
16
24
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -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"],"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;\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"}
|
|
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"}
|
|
@@ -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';
|
|
@@ -13,4 +14,11 @@ export declare const NOOP: () => void;
|
|
|
13
14
|
export declare const ASYNC_NOOP: () => Promise<undefined>;
|
|
14
15
|
export declare const PASS: <T>(val: T) => T;
|
|
15
16
|
export declare const toMegabyte: (byte: number) => number;
|
|
17
|
+
export declare const isFunction: <T>(param?: T | undefined) => param is NonNullable<T>;
|
|
18
|
+
export declare const SBErrorCode: {
|
|
19
|
+
NON_AUTHORIZED: number;
|
|
20
|
+
};
|
|
21
|
+
export declare const SBErrorMessage: {
|
|
22
|
+
ACL: string;
|
|
23
|
+
};
|
|
16
24
|
export type { FilterByValueType, UnionToIntersection, OmittedValues, PartialDeep, Optional, ContextValue, SendbirdMessage, SendbirdChatSDK, SendbirdChannel, SendbirdBaseChannel, SendbirdGroupChannel, SendbirdOpenChannel, SendbirdUser, SendbirdMember, SendbirdBaseMessage, SendbirdUserMessage, SendbirdFileMessage, SendbirdAdminMessage, SendbirdGroupChannelParams, SendbirdFileMessageParams, SendbirdUserMessageParams, SendbirdError, SendbirdMessageCollection, SendbirdGroupChannelCollection, NotificationFiles, NotificationMentionedUsers, NotificationTranslations, PartialNullable, SendbirdDataPayload, } from './types';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sendbird/uikit-utils",
|
|
3
|
-
"version": "1.1.
|
|
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": "
|
|
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';
|
|
@@ -25,6 +26,15 @@ export const NOOP: () => void = () => void 0;
|
|
|
25
26
|
export const ASYNC_NOOP = async () => void 0;
|
|
26
27
|
export const PASS = <T>(val: T) => val;
|
|
27
28
|
export const toMegabyte = (byte: number) => byte / 1024 / 1024;
|
|
29
|
+
export const isFunction = <T>(param?: T): param is NonNullable<T> => typeof param === 'function';
|
|
30
|
+
export const SBErrorCode = {
|
|
31
|
+
NON_AUTHORIZED: 400108,
|
|
32
|
+
};
|
|
33
|
+
export const SBErrorMessage = {
|
|
34
|
+
ACL:
|
|
35
|
+
"An error occurred because you don't have access to the user list in your application.\n" +
|
|
36
|
+
'In order to gain access, you can turn on this attribute in the Access Control List settings on Sendbird Dashboard.',
|
|
37
|
+
};
|
|
28
38
|
|
|
29
39
|
export type {
|
|
30
40
|
FilterByValueType,
|