@sendbird/uikit-utils 2.1.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/hooks/index.js +14 -1
- package/lib/commonjs/hooks/index.js.map +1 -1
- package/lib/commonjs/hooks/react-native.js +56 -0
- package/lib/commonjs/hooks/react-native.js.map +1 -0
- package/lib/commonjs/index.js +38 -7
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/sendbird/channel.js +7 -1
- package/lib/commonjs/sendbird/channel.js.map +1 -1
- package/lib/commonjs/sendbird/message.js +12 -2
- package/lib/commonjs/sendbird/message.js.map +1 -1
- package/lib/commonjs/sendbird/user.js +5 -0
- package/lib/commonjs/sendbird/user.js.map +1 -1
- package/lib/commonjs/shared/index.js +74 -0
- package/lib/commonjs/shared/index.js.map +1 -0
- package/lib/commonjs/shared/regex.js +52 -6
- package/lib/commonjs/shared/regex.js.map +1 -1
- package/lib/commonjs/types.js +3 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/ui-format/common.js +17 -14
- package/lib/commonjs/ui-format/common.js.map +1 -1
- package/lib/commonjs/ui-format/groupChannel.js +7 -10
- package/lib/commonjs/ui-format/groupChannel.js.map +1 -1
- package/lib/module/hooks/index.js +10 -0
- package/lib/module/hooks/index.js.map +1 -1
- package/lib/module/hooks/react-native.js +39 -0
- package/lib/module/hooks/react-native.js.map +1 -0
- package/lib/module/index.js +3 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/sendbird/channel.js +3 -0
- package/lib/module/sendbird/channel.js.map +1 -1
- package/lib/module/sendbird/message.js +9 -3
- package/lib/module/sendbird/message.js.map +1 -1
- package/lib/module/sendbird/user.js +3 -0
- package/lib/module/sendbird/user.js.map +1 -1
- package/lib/module/shared/index.js +57 -0
- package/lib/module/shared/index.js.map +1 -0
- package/lib/module/shared/regex.js +43 -3
- package/lib/module/shared/regex.js.map +1 -1
- package/lib/module/types.js +1 -4
- package/lib/module/types.js.map +1 -1
- package/lib/module/ui-format/common.js +12 -7
- package/lib/module/ui-format/common.js.map +1 -1
- package/lib/module/ui-format/groupChannel.js +5 -4
- package/lib/module/ui-format/groupChannel.js.map +1 -1
- package/lib/typescript/src/hooks/index.d.ts +3 -2
- package/lib/typescript/src/hooks/react-native.d.ts +12 -0
- package/lib/typescript/src/index.d.ts +4 -3
- package/lib/typescript/src/sendbird/channel.d.ts +1 -0
- package/lib/typescript/src/sendbird/message.d.ts +4 -2
- package/lib/typescript/src/sendbird/user.d.ts +2 -0
- package/lib/typescript/src/shared/bufferedRequest.d.ts +1 -1
- package/lib/typescript/src/shared/index.d.ts +26 -0
- package/lib/typescript/src/shared/logger.d.ts +1 -1
- package/lib/typescript/src/shared/pubsub.d.ts +2 -2
- package/lib/typescript/src/shared/regex.d.ts +8 -0
- package/lib/typescript/src/types.d.ts +42 -36
- package/lib/typescript/src/ui-format/common.d.ts +7 -6
- package/package.json +4 -3
- package/src/hooks/index.ts +11 -0
- package/src/hooks/react-native.ts +56 -0
- package/src/index.ts +10 -1
- package/src/sendbird/channel.ts +4 -0
- package/src/sendbird/message.ts +13 -3
- package/src/sendbird/user.ts +6 -0
- package/src/shared/index.ts +56 -0
- package/src/shared/regex.ts +35 -0
- package/src/types.ts +20 -3
- package/src/ui-format/common.ts +9 -7
- package/src/ui-format/groupChannel.ts +5 -4
- package/lib/commonjs/shared/conditionChaining.js +0 -15
- package/lib/commonjs/shared/conditionChaining.js.map +0 -1
- package/lib/module/shared/conditionChaining.js +0 -7
- package/lib/module/shared/conditionChaining.js.map +0 -1
- package/lib/typescript/src/shared/conditionChaining.d.ts +0 -2
- package/src/shared/conditionChaining.ts +0 -6
|
@@ -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,CAA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ncEffect","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"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useSafeAreaPadding = exports.useAppState = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
var _reactNative = require("react-native");
|
|
11
|
+
|
|
12
|
+
var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
|
|
13
|
+
|
|
14
|
+
const edgePaddingMap = {
|
|
15
|
+
left: 'paddingLeft',
|
|
16
|
+
right: 'paddingRight',
|
|
17
|
+
top: 'paddingTop',
|
|
18
|
+
bottom: 'paddingBottom'
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const useSafeAreaPadding = edges => {
|
|
22
|
+
const safeAreaInsets = (0, _reactNativeSafeAreaContext.useSafeAreaInsets)();
|
|
23
|
+
return (0, _react.useMemo)(() => {
|
|
24
|
+
return edges.reduce((map, edge) => {
|
|
25
|
+
const paddingKey = edgePaddingMap[edge];
|
|
26
|
+
map[paddingKey] = safeAreaInsets[edge];
|
|
27
|
+
return map;
|
|
28
|
+
}, {});
|
|
29
|
+
}, edges);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
exports.useSafeAreaPadding = useSafeAreaPadding;
|
|
33
|
+
|
|
34
|
+
const useAppState = (type, listener) => {
|
|
35
|
+
const callbackRef = (0, _react.useRef)(listener);
|
|
36
|
+
callbackRef.current = listener;
|
|
37
|
+
(0, _react.useEffect)(() => {
|
|
38
|
+
const eventListener = state => callbackRef.current(state);
|
|
39
|
+
|
|
40
|
+
const subscriber = _reactNative.AppState.addEventListener(type, eventListener);
|
|
41
|
+
|
|
42
|
+
return () => {
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
if (subscriber !== null && subscriber !== void 0 && subscriber.remove) {
|
|
45
|
+
subscriber.remove();
|
|
46
|
+
} // @ts-ignore
|
|
47
|
+
else if (_reactNative.AppState.removeEventListener) {
|
|
48
|
+
// @ts-ignore
|
|
49
|
+
_reactNative.AppState.removeEventListener(type, eventListener);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}, []);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
exports.useAppState = useAppState;
|
|
56
|
+
//# sourceMappingURL=react-native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["edgePaddingMap","left","right","top","bottom","useSafeAreaPadding","edges","safeAreaInsets","useSafeAreaInsets","useMemo","reduce","map","edge","paddingKey","useAppState","type","listener","callbackRef","useRef","current","useEffect","eventListener","state","subscriber","AppState","addEventListener","remove","removeEventListener"],"sources":["react-native.ts"],"sourcesContent":["import { useEffect, useMemo, useRef } from 'react';\nimport { AppState, AppStateEvent, AppStateStatus } from 'react-native';\nimport { EdgeInsets, useSafeAreaInsets } from 'react-native-safe-area-context';\n\ntype EdgePaddingMap = {\n left: 'paddingLeft';\n right: 'paddingRight';\n top: 'paddingTop';\n bottom: 'paddingBottom';\n};\nconst edgePaddingMap: EdgePaddingMap = {\n left: 'paddingLeft',\n right: 'paddingRight',\n top: 'paddingTop',\n bottom: 'paddingBottom',\n};\n\nexport const useSafeAreaPadding = <\n T extends keyof EdgeInsets,\n Result extends { [key in EdgePaddingMap[T]]: EdgeInsets[T] },\n>(\n edges: T[],\n): Result => {\n const safeAreaInsets = useSafeAreaInsets();\n return useMemo(() => {\n return edges.reduce((map, edge) => {\n const paddingKey = edgePaddingMap[edge];\n map[paddingKey] = safeAreaInsets[edge];\n return map;\n }, {} as { [key in EdgePaddingMap[T]]: EdgeInsets[T] });\n }, edges) as Result;\n};\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;;AACA;;AAQA,MAAMA,cAA8B,GAAG;EACrCC,IAAI,EAAE,aAD+B;EAErCC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ToMap: true,
|
|
16
16
|
arrayToMapWithGetter: true,
|
|
17
17
|
createPubSub: true,
|
|
18
|
-
conditionChaining: true,
|
|
19
18
|
urlRegexStrict: true,
|
|
20
19
|
urlRegexRough: true,
|
|
21
20
|
newLineRegex: true,
|
|
@@ -28,6 +27,8 @@ var _exportNames = {
|
|
|
28
27
|
normalizeFileName: true,
|
|
29
28
|
emailRegex: true,
|
|
30
29
|
phoneRegex: true,
|
|
30
|
+
replaceWithRegex: true,
|
|
31
|
+
createMentionTemplateRegex: true,
|
|
31
32
|
BufferedRequest: true
|
|
32
33
|
};
|
|
33
34
|
exports.ASYNC_NOOP = void 0;
|
|
@@ -62,10 +63,10 @@ Object.defineProperty(exports, "audioExtRegex", {
|
|
|
62
63
|
return _regex.audioExtRegex;
|
|
63
64
|
}
|
|
64
65
|
});
|
|
65
|
-
Object.defineProperty(exports, "
|
|
66
|
+
Object.defineProperty(exports, "createMentionTemplateRegex", {
|
|
66
67
|
enumerable: true,
|
|
67
68
|
get: function () {
|
|
68
|
-
return
|
|
69
|
+
return _regex.createMentionTemplateRegex;
|
|
69
70
|
}
|
|
70
71
|
});
|
|
71
72
|
Object.defineProperty(exports, "createPubSub", {
|
|
@@ -123,6 +124,12 @@ Object.defineProperty(exports, "replaceUrlAsComponents", {
|
|
|
123
124
|
return _regex.replaceUrlAsComponents;
|
|
124
125
|
}
|
|
125
126
|
});
|
|
127
|
+
Object.defineProperty(exports, "replaceWithRegex", {
|
|
128
|
+
enumerable: true,
|
|
129
|
+
get: function () {
|
|
130
|
+
return _regex.replaceWithRegex;
|
|
131
|
+
}
|
|
132
|
+
});
|
|
126
133
|
exports.toMegabyte = void 0;
|
|
127
134
|
Object.defineProperty(exports, "urlRegexRough", {
|
|
128
135
|
enumerable: true,
|
|
@@ -149,12 +156,24 @@ var _arrayToMap = _interopRequireWildcard(require("./shared/arrayToMap"));
|
|
|
149
156
|
|
|
150
157
|
var _pubsub = require("./shared/pubsub");
|
|
151
158
|
|
|
152
|
-
var _conditionChaining = _interopRequireDefault(require("./shared/conditionChaining"));
|
|
153
|
-
|
|
154
159
|
var _regex = require("./shared/regex");
|
|
155
160
|
|
|
156
161
|
var _bufferedRequest = require("./shared/bufferedRequest");
|
|
157
162
|
|
|
163
|
+
var _shared = require("./shared");
|
|
164
|
+
|
|
165
|
+
Object.keys(_shared).forEach(function (key) {
|
|
166
|
+
if (key === "default" || key === "__esModule") return;
|
|
167
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
168
|
+
if (key in exports && exports[key] === _shared[key]) return;
|
|
169
|
+
Object.defineProperty(exports, key, {
|
|
170
|
+
enumerable: true,
|
|
171
|
+
get: function () {
|
|
172
|
+
return _shared[key];
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
|
|
158
177
|
var _hooks = require("./hooks");
|
|
159
178
|
|
|
160
179
|
Object.keys(_hooks).forEach(function (key) {
|
|
@@ -169,6 +188,20 @@ Object.keys(_hooks).forEach(function (key) {
|
|
|
169
188
|
});
|
|
170
189
|
});
|
|
171
190
|
|
|
191
|
+
var _reactNative = require("./hooks/react-native");
|
|
192
|
+
|
|
193
|
+
Object.keys(_reactNative).forEach(function (key) {
|
|
194
|
+
if (key === "default" || key === "__esModule") return;
|
|
195
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
196
|
+
if (key in exports && exports[key] === _reactNative[key]) return;
|
|
197
|
+
Object.defineProperty(exports, key, {
|
|
198
|
+
enumerable: true,
|
|
199
|
+
get: function () {
|
|
200
|
+
return _reactNative[key];
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
|
|
172
205
|
var _groupChannel = require("./ui-format/groupChannel");
|
|
173
206
|
|
|
174
207
|
Object.keys(_groupChannel).forEach(function (key) {
|
|
@@ -253,8 +286,6 @@ Object.keys(_user).forEach(function (key) {
|
|
|
253
286
|
});
|
|
254
287
|
});
|
|
255
288
|
|
|
256
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
257
|
-
|
|
258
289
|
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); }
|
|
259
290
|
|
|
260
291
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -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 {
|
|
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 {\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';\n\nexport * from './shared';\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';\nexport * from './sendbird/user';\n\nexport const NOOP: () => void = () => void 0;\nexport const ASYNC_NOOP = async () => void 0;\nexport const PASS = <T>(val: T) => val;\nexport const toMegabyte = (byte: number) => byte / 1024 / 1024;\nexport const isFunction = <T>(param?: T): param is NonNullable<T> => typeof param === 'function';\nexport const SBErrorCode = {\n NON_AUTHORIZED: 400108,\n};\nexport const SBErrorMessage = {\n ACL:\n 'Sendbird provides various access control options when using the Chat SDK.\\n' +\n 'By default, the Allow retrieving user list attribute is turned on to facilitate creating sample apps.\\n' +\n 'However, this may grant access to unwanted data or operations, leading to potential security concerns.\\n' +\n 'To manage your access control settings, you can turn on or off each setting on Sendbird Dashboard.',\n};\n\nexport type {\n UserStruct,\n FilterByValueType,\n UnionToIntersection,\n OmittedValues,\n PartialDeep,\n Optional,\n ContextValue,\n SendbirdMessage,\n SendbirdChatSDK,\n SendbirdChannel,\n SendbirdBaseChannel,\n SendbirdGroupChannel,\n SendbirdOpenChannel,\n SendbirdUser,\n SendbirdMember,\n SendbirdBaseMessage,\n SendbirdUserMessage,\n SendbirdFileMessage,\n SendbirdAdminMessage,\n SendbirdGroupChannelCreateParams,\n SendbirdFileMessageCreateParams,\n SendbirdUserMessageCreateParams,\n SendbirdError,\n SendbirdMessageCollection,\n SendbirdGroupChannelCollection,\n NotificationFiles,\n NotificationMentionedUsers,\n NotificationTranslations,\n PartialNullable,\n SendbirdDataPayload,\n SendbirdPreviousMessageListQuery,\n SendbirdSendableMessage,\n SendbirdGroupChannelListQuery,\n SendbirdGroupChannelUpdateParams,\n SendbirdUserMessageUpdateParams,\n SendbirdFileMessageUpdateParams,\n SendbirdUserUpdateParams,\n SendbirdRestrictedUser,\n SendbirdReaction,\n SendbirdEmojiContainer,\n SendbirdEmoji,\n SendbirdEmojiCategory,\n} from './types';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAgBA;;AAEA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAEA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;;;;;AAEO,MAAMA,IAAgB,GAAG,MAAM,KAAK,CAApC;;;;AACA,MAAMC,UAAU,GAAG,YAAY,KAAK,CAApC;;;;AACA,MAAMC,IAAI,GAAOC,GAAJ,IAAeA,GAA5B;;;;AACA,MAAMC,UAAU,GAAIC,IAAD,IAAkBA,IAAI,GAAG,IAAP,GAAc,IAAnD;;;;AACA,MAAMC,UAAU,GAAOC,KAAJ,IAA2C,OAAOA,KAAP,KAAiB,UAA/E;;;AACA,MAAMC,WAAW,GAAG;EACzBC,cAAc,EAAE;AADS,CAApB;;AAGA,MAAMC,cAAc,GAAG;EAC5BC,GAAG,EACD,gFACA,yGADA,GAEA,0GAFA,GAGA;AAL0B,CAAvB"}
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.confirmAndMarkAsRead = exports.confirmAndMarkAsDelivered = void 0;
|
|
7
|
+
exports.getChannelUniqId = getChannelUniqId;
|
|
8
|
+
exports.getGroupChannelChatAvailableState = void 0;
|
|
7
9
|
exports.getGroupChannels = getGroupChannels;
|
|
8
10
|
exports.getMembersExcludeMe = getMembersExcludeMe;
|
|
9
11
|
exports.getOpenChannels = getOpenChannels;
|
|
@@ -63,4 +65,8 @@ function getGroupChannels(channels) {
|
|
|
63
65
|
function getOpenChannels(channels) {
|
|
64
66
|
return channels.filter(c => c.isOpenChannel());
|
|
65
67
|
}
|
|
68
|
+
|
|
69
|
+
function getChannelUniqId(channel) {
|
|
70
|
+
return channel.url;
|
|
71
|
+
}
|
|
66
72
|
//# sourceMappingURL=channel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isDifferentChannel","a","b","url","getGroupChannelChatAvailableState","channel","frozen","isFrozen","myRole","muted","myMutedState","disabled","confirmAndMarkAsRead","channels","filter","it","isGroupChannel","unreadMessageCount","forEach","BufferedRequest","markAsRead","push","confirmAndMarkAsDelivered","markAsDelivered","isDefaultCoverImage","coverUrl","startsWith","getMembersExcludeMe","currentUserId","members","m","userId","getGroupChannels","c","getOpenChannels","isOpenChannel"],"sources":["channel.ts"],"sourcesContent":["import { BufferedRequest } from '../shared/bufferedRequest';\nimport type { SendbirdBaseChannel, SendbirdChannel, SendbirdGroupChannel, SendbirdOpenChannel } from '../types';\n\n/**\n * Diff utils for channel\n * @param {SendbirdBaseChannel} [a]\n * @param {SendbirdBaseChannel} [b]\n * @returns {boolean}\n * */\nexport function isDifferentChannel<T extends SendbirdBaseChannel>(a?: T, b?: T): boolean {\n if (!a || !b) return true;\n return a.url !== b.url;\n}\n\nexport const getGroupChannelChatAvailableState = (channel: SendbirdGroupChannel) => {\n const frozen = channel.isFrozen && channel.myRole !== 'operator';\n const muted = channel.myMutedState === 'muted';\n const disabled = frozen || muted;\n return { disabled, frozen, muted };\n};\n\nexport const confirmAndMarkAsRead = async (channels: SendbirdBaseChannel[]) => {\n channels\n .filter((it): it is SendbirdGroupChannel => it.isGroupChannel() && it.unreadMessageCount > 0)\n .forEach((it) => BufferedRequest.markAsRead.push(() => it.markAsRead(), it.url));\n};\n\nexport const confirmAndMarkAsDelivered = async (channels: SendbirdBaseChannel[]) => {\n channels\n .filter((it): it is SendbirdGroupChannel => it.isGroupChannel() && it.unreadMessageCount > 0)\n .forEach((it) => BufferedRequest.markAsDelivered.push(() => it.markAsDelivered(), it.url));\n};\n\nexport function isDefaultCoverImage(coverUrl: string) {\n return coverUrl === '' || coverUrl.startsWith('https://static.sendbird.com/sample/cover');\n}\n\nexport function getMembersExcludeMe(channel: SendbirdGroupChannel, currentUserId?: string) {\n return channel.members.filter((m) => m.userId !== currentUserId);\n}\n\nexport function getGroupChannels(channels: SendbirdChannel[]): SendbirdGroupChannel[] {\n return channels.filter((c): c is SendbirdGroupChannel => c.isGroupChannel());\n}\n\nexport function getOpenChannels(channels: SendbirdChannel[]): SendbirdOpenChannel[] {\n return channels.filter((c): c is SendbirdOpenChannel => c.isOpenChannel());\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["isDifferentChannel","a","b","url","getGroupChannelChatAvailableState","channel","frozen","isFrozen","myRole","muted","myMutedState","disabled","confirmAndMarkAsRead","channels","filter","it","isGroupChannel","unreadMessageCount","forEach","BufferedRequest","markAsRead","push","confirmAndMarkAsDelivered","markAsDelivered","isDefaultCoverImage","coverUrl","startsWith","getMembersExcludeMe","currentUserId","members","m","userId","getGroupChannels","c","getOpenChannels","isOpenChannel","getChannelUniqId"],"sources":["channel.ts"],"sourcesContent":["import { BufferedRequest } from '../shared/bufferedRequest';\nimport type { SendbirdBaseChannel, SendbirdChannel, SendbirdGroupChannel, SendbirdOpenChannel } from '../types';\n\n/**\n * Diff utils for channel\n * @param {SendbirdBaseChannel} [a]\n * @param {SendbirdBaseChannel} [b]\n * @returns {boolean}\n * */\nexport function isDifferentChannel<T extends SendbirdBaseChannel>(a?: T, b?: T): boolean {\n if (!a || !b) return true;\n return a.url !== b.url;\n}\n\nexport const getGroupChannelChatAvailableState = (channel: SendbirdGroupChannel) => {\n const frozen = channel.isFrozen && channel.myRole !== 'operator';\n const muted = channel.myMutedState === 'muted';\n const disabled = frozen || muted;\n return { disabled, frozen, muted };\n};\n\nexport const confirmAndMarkAsRead = async (channels: SendbirdBaseChannel[]) => {\n channels\n .filter((it): it is SendbirdGroupChannel => it.isGroupChannel() && it.unreadMessageCount > 0)\n .forEach((it) => BufferedRequest.markAsRead.push(() => it.markAsRead(), it.url));\n};\n\nexport const confirmAndMarkAsDelivered = async (channels: SendbirdBaseChannel[]) => {\n channels\n .filter((it): it is SendbirdGroupChannel => it.isGroupChannel() && it.unreadMessageCount > 0)\n .forEach((it) => BufferedRequest.markAsDelivered.push(() => it.markAsDelivered(), it.url));\n};\n\nexport function isDefaultCoverImage(coverUrl: string) {\n return coverUrl === '' || coverUrl.startsWith('https://static.sendbird.com/sample/cover');\n}\n\nexport function getMembersExcludeMe(channel: SendbirdGroupChannel, currentUserId?: string) {\n return channel.members.filter((m) => m.userId !== currentUserId);\n}\n\nexport function getGroupChannels(channels: SendbirdChannel[]): SendbirdGroupChannel[] {\n return channels.filter((c): c is SendbirdGroupChannel => c.isGroupChannel());\n}\n\nexport function getOpenChannels(channels: SendbirdChannel[]): SendbirdOpenChannel[] {\n return channels.filter((c): c is SendbirdOpenChannel => c.isOpenChannel());\n}\n\nexport function getChannelUniqId(channel: SendbirdChannel) {\n return channel.url;\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,kBAAT,CAA2DC,CAA3D,EAAkEC,CAAlE,EAAkF;EACvF,IAAI,CAACD,CAAD,IAAM,CAACC,CAAX,EAAc,OAAO,IAAP;EACd,OAAOD,CAAC,CAACE,GAAF,KAAUD,CAAC,CAACC,GAAnB;AACD;;AAEM,MAAMC,iCAAiC,GAAIC,OAAD,IAAmC;EAClF,MAAMC,MAAM,GAAGD,OAAO,CAACE,QAAR,IAAoBF,OAAO,CAACG,MAAR,KAAmB,UAAtD;EACA,MAAMC,KAAK,GAAGJ,OAAO,CAACK,YAAR,KAAyB,OAAvC;EACA,MAAMC,QAAQ,GAAGL,MAAM,IAAIG,KAA3B;EACA,OAAO;IAAEE,QAAF;IAAYL,MAAZ;IAAoBG;EAApB,CAAP;AACD,CALM;;;;AAOA,MAAMG,oBAAoB,GAAG,MAAOC,QAAP,IAA2C;EAC7EA,QAAQ,CACLC,MADH,CACWC,EAAD,IAAoCA,EAAE,CAACC,cAAH,MAAuBD,EAAE,CAACE,kBAAH,GAAwB,CAD7F,EAEGC,OAFH,CAEYH,EAAD,IAAQI,gCAAA,CAAgBC,UAAhB,CAA2BC,IAA3B,CAAgC,MAAMN,EAAE,CAACK,UAAH,EAAtC,EAAuDL,EAAE,CAACZ,GAA1D,CAFnB;AAGD,CAJM;;;;AAMA,MAAMmB,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,EAAiER,EAAE,CAACZ,GAApE,CAFnB;AAGD,CAJM;;;;AAMA,SAASqB,mBAAT,CAA6BC,QAA7B,EAA+C;EACpD,OAAOA,QAAQ,KAAK,EAAb,IAAmBA,QAAQ,CAACC,UAAT,CAAoB,0CAApB,CAA1B;AACD;;AAEM,SAASC,mBAAT,CAA6BtB,OAA7B,EAA4DuB,aAA5D,EAAoF;EACzF,OAAOvB,OAAO,CAACwB,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.
|
|
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.
|
|
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","
|
|
1
|
+
{"version":3,"names":["isNewMessage","msg","currentUserId","myMessage","isMyMessage","isAdminMessage","updatedAt","isSendableMessage","undefined","sender","userId","sendingStatus","messageKeyExtractor","message","getMessageUniqId","messageComparator","a","b","aStatusOffset","bStatusOffset","createdAt","hasSameSender","calcMessageGrouping","groupEnabled","curr","prev","next","getPrev","getMessageTimeFormat","Date","getNext","groupWithPrev","groupWithNext","isUserMessage","isFileMessage","String","messageId","reqId","getAvailableUriFromFileMessage","url","messageParams","file","uri","isSendbirdNotification","dataPayload","Boolean","parseSendbirdNotification","sendbird","JSON","parse","shouldRenderReaction","channel","reactionEnabled","isGroupChannel","isBroadcast","isSuper","getReactionCount","reaction","userIds","length"],"sources":["message.ts"],"sourcesContent":["import type {\n SendbirdBaseChannel,\n SendbirdBaseMessage,\n SendbirdDataPayload,\n SendbirdFileMessage,\n SendbirdMessage,\n SendbirdReaction,\n SendbirdSendableMessage,\n} from '../types';\nimport { getMessageTimeFormat } from '../ui-format/common';\n\nexport function isNewMessage(msg: SendbirdMessage, currentUserId?: string) {\n const myMessage = isMyMessage(msg, currentUserId);\n if (myMessage) return false;\n if (msg.isAdminMessage()) return false;\n return msg.updatedAt === 0;\n}\n\nexport function isSendableMessage(msg?: SendbirdMessage | null): msg is SendbirdSendableMessage {\n return msg !== undefined && msg !== null && 'sendingStatus' in msg;\n}\n\nexport function isMyMessage(msg?: SendbirdMessage | null, currentUserId = '##__USER_ID_IS_NOT_PROVIDED__##') {\n if (!isSendableMessage(msg)) return false;\n return (\n ('sender' in msg && msg.sender?.userId === currentUserId) ||\n msg.sendingStatus === 'pending' ||\n msg.sendingStatus === 'failed' ||\n msg.sendingStatus === 'canceled'\n );\n}\n\nexport function messageKeyExtractor(message: SendbirdMessage): string {\n return getMessageUniqId(message);\n}\n\n// |-------------------|-------------------|-----------------|-------------------|\n// | sending status | reqId | messageId | createdAt |\n// |-------------------|-------------------|-----------------|-------------------|\n// | pending | timestamp(A) | 0 | timestamp(B) |\n// | canceled | timestamp(A) | 0 | ? |\n// | failed | timestamp(A) | 0 | ? |\n// | succeeded | timestamp(A) / '' | id from DB | timestamp(C) |\n// |-------------------|-------------------|-----------------|-------------------|\nexport function messageComparator(a: SendbirdMessage, b: SendbirdMessage) {\n let aStatusOffset = 0;\n let bStatusOffset = 0;\n\n if (isSendableMessage(a) && a.sendingStatus !== 'succeeded') aStatusOffset = 999999;\n if (isSendableMessage(b) && b.sendingStatus !== 'succeeded') bStatusOffset = 999999;\n\n return b.createdAt + bStatusOffset - (a.createdAt + aStatusOffset);\n}\n\nexport function hasSameSender(a?: SendbirdMessage, b?: SendbirdMessage) {\n if (!a || !b) return false;\n if ('sender' in a && 'sender' in b) return a.sender?.userId === b.sender?.userId;\n return false;\n}\n\nexport function calcMessageGrouping(\n groupEnabled: boolean,\n curr: SendbirdMessage,\n prev?: SendbirdMessage,\n next?: SendbirdMessage,\n) {\n const getPrev = () => {\n if (!groupEnabled) return false;\n if (!prev) return false;\n if (curr.isAdminMessage()) return false;\n if (!hasSameSender(curr, prev)) return false;\n if (getMessageTimeFormat(new Date(curr.createdAt)) !== getMessageTimeFormat(new Date(prev.createdAt))) return false;\n return true;\n };\n\n const getNext = () => {\n if (!groupEnabled) return false;\n if (!next) return false;\n if (curr.isAdminMessage()) return false;\n if (!hasSameSender(curr, next)) return false;\n if (getMessageTimeFormat(new Date(curr.createdAt)) !== getMessageTimeFormat(new Date(next.createdAt))) return false;\n return true;\n };\n\n return { groupWithPrev: getPrev(), groupWithNext: getNext() };\n}\n\nexport function getMessageUniqId(msg: SendbirdBaseMessage) {\n if (msg.isUserMessage() || msg.isFileMessage()) {\n if (msg.sendingStatus === 'succeeded') return String(msg.messageId);\n return msg.reqId;\n }\n\n return String(msg.messageId);\n}\n\nexport function getAvailableUriFromFileMessage(message: SendbirdFileMessage) {\n if (!message.url && message.messageParams.file && 'uri' in message.messageParams.file) {\n return message.messageParams.file.uri;\n }\n return message.url;\n}\n\ntype RawSendbirdDataPayload = { sendbird: string | object };\nexport function isSendbirdNotification(dataPayload?: {\n [key: string]: string | object;\n}): dataPayload is RawSendbirdDataPayload {\n if (!dataPayload) return false;\n return Boolean(dataPayload['sendbird']);\n}\n\nexport function parseSendbirdNotification(dataPayload: RawSendbirdDataPayload): SendbirdDataPayload {\n return typeof dataPayload.sendbird === 'string' ? JSON.parse(dataPayload.sendbird) : dataPayload.sendbird;\n}\n\nexport function shouldRenderReaction(channel: SendbirdBaseChannel, reactionEnabled: boolean) {\n return channel.isGroupChannel() && !channel.isBroadcast && !channel.isSuper && reactionEnabled;\n}\n\nexport function getReactionCount(reaction: SendbirdReaction) {\n return reaction.userIds.length;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AASA;;AAEO,SAASA,YAAT,CAAsBC,GAAtB,EAA4CC,aAA5C,EAAoE;EACzE,MAAMC,SAAS,GAAGC,WAAW,CAACH,GAAD,EAAMC,aAAN,CAA7B;EACA,IAAIC,SAAJ,EAAe,OAAO,KAAP;EACf,IAAIF,GAAG,CAACI,cAAJ,EAAJ,EAA0B,OAAO,KAAP;EAC1B,OAAOJ,GAAG,CAACK,SAAJ,KAAkB,CAAzB;AACD;;AAEM,SAASC,iBAAT,CAA2BN,GAA3B,EAAyF;EAC9F,OAAOA,GAAG,KAAKO,SAAR,IAAqBP,GAAG,KAAK,IAA7B,IAAqC,mBAAmBA,GAA/D;AACD;;AAEM,SAASG,WAAT,CAAqBH,GAArB,EAAsG;EAAA;;EAAA,IAAnDC,aAAmD,uEAAnC,iCAAmC;EAC3G,IAAI,CAACK,iBAAiB,CAACN,GAAD,CAAtB,EAA6B,OAAO,KAAP;EAC7B,OACG,YAAYA,GAAZ,IAAmB,gBAAAA,GAAG,CAACQ,MAAJ,4DAAYC,MAAZ,MAA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,EAAsE;EAC3E,IAAI,CAACA,OAAO,CAAC0B,GAAT,IAAgB1B,OAAO,CAAC2B,aAAR,CAAsBC,IAAtC,IAA8C,SAAS5B,OAAO,CAAC2B,aAAR,CAAsBC,IAAjF,EAAuF;IACrF,OAAO5B,OAAO,CAAC2B,aAAR,CAAsBC,IAAtB,CAA2BC,GAAlC;EACD;;EACD,OAAO7B,OAAO,CAAC0B,GAAf;AACD;;AAGM,SAASI,sBAAT,CAAgCC,WAAhC,EAEmC;EACxC,IAAI,CAACA,WAAL,EAAkB,OAAO,KAAP;EAClB,OAAOC,OAAO,CAACD,WAAW,CAAC,UAAD,CAAZ,CAAd;AACD;;AAEM,SAASE,yBAAT,CAAmCF,WAAnC,EAA6F;EAClG,OAAO,OAAOA,WAAW,CAACG,QAAnB,KAAgC,QAAhC,GAA2CC,IAAI,CAACC,KAAL,CAAWL,WAAW,CAACG,QAAvB,CAA3C,GAA8EH,WAAW,CAACG,QAAjG;AACD;;AAEM,SAASG,oBAAT,CAA8BC,OAA9B,EAA4DC,eAA5D,EAAsF;EAC3F,OAAOD,OAAO,CAACE,cAAR,MAA4B,CAACF,OAAO,CAACG,WAArC,IAAoD,CAACH,OAAO,CAACI,OAA7D,IAAwEH,eAA/E;AACD;;AAEM,SAASI,gBAAT,CAA0BC,QAA1B,EAAsD;EAC3D,OAAOA,QAAQ,CAACC,OAAT,CAAiBC,MAAxB;AACD"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.getUserUniqId = getUserUniqId;
|
|
6
7
|
exports.ifMuted = ifMuted;
|
|
7
8
|
exports.ifOperator = ifOperator;
|
|
8
9
|
|
|
@@ -15,4 +16,8 @@ function ifMuted(muted, then, or) {
|
|
|
15
16
|
if (muted) return then;
|
|
16
17
|
return or;
|
|
17
18
|
}
|
|
19
|
+
|
|
20
|
+
function getUserUniqId(user) {
|
|
21
|
+
return user.userId;
|
|
22
|
+
}
|
|
18
23
|
//# sourceMappingURL=user.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ifOperator","role","then","or","ifMuted","muted"],"sources":["user.ts"],"sourcesContent":["import type { Role } from '@sendbird/chat';\n\nexport function ifOperator<T>(role: Role, then: T): T | undefined;\nexport function ifOperator<T, V>(role: Role, then: T, or: V): T | V;\nexport function ifOperator(role: Role, then: unknown, or?: unknown) {\n if (role === 'operator') return then;\n return or;\n}\n\nexport function ifMuted<T>(muted: boolean, then: T): T | undefined;\nexport function ifMuted<T, V>(muted: boolean, then: T, or: V): T | V;\nexport function ifMuted(muted: boolean, then: unknown, or?: unknown) {\n if (muted) return then;\n return or;\n}\n"],"mappings":"
|
|
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"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.conditionChaining = conditionChaining;
|
|
7
|
+
exports.getDownscaleSize = getDownscaleSize;
|
|
8
|
+
exports.hash = hash;
|
|
9
|
+
exports.isImage = isImage;
|
|
10
|
+
exports.replace = replace;
|
|
11
|
+
exports.shouldCompressImage = shouldCompressImage;
|
|
12
|
+
|
|
13
|
+
var _regex = require("./regex");
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Converts a given string to a hashed string.
|
|
17
|
+
* */
|
|
18
|
+
function hash(str) {
|
|
19
|
+
return String(Math.abs(str.split('').reduce((a, c) => (a << 5) - a + c.charCodeAt(0) | 0, 0)));
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Replace a specific range of text in the string with another text.
|
|
23
|
+
* */
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
function replace(str, start, end, text) {
|
|
27
|
+
return str.slice(0, start) + text + str.slice(end);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Returns the value corresponding to the first true index of a given condition array.
|
|
31
|
+
* */
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
function conditionChaining(conditions, values) {
|
|
35
|
+
const idx = conditions.findIndex(state => Boolean(state));
|
|
36
|
+
return idx > -1 ? values[idx] : values[values.length - 1];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Calculates the downscale size.
|
|
40
|
+
* */
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
function getDownscaleSize(origin, resizing) {
|
|
44
|
+
let ratio;
|
|
45
|
+
const maxWidth = resizing.width || origin.width,
|
|
46
|
+
maxHeight = resizing.height || origin.height;
|
|
47
|
+
|
|
48
|
+
if (origin.width <= maxWidth && origin.height <= maxHeight) {
|
|
49
|
+
ratio = 1;
|
|
50
|
+
} else if (origin.width > maxWidth && origin.height <= maxHeight) {
|
|
51
|
+
ratio = maxWidth / origin.width;
|
|
52
|
+
} else if (origin.width <= maxWidth && origin.height > maxHeight) {
|
|
53
|
+
ratio = maxHeight / origin.height;
|
|
54
|
+
} else {
|
|
55
|
+
ratio = Math.max(maxWidth / origin.width, maxHeight / origin.height);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
width: origin.width * ratio,
|
|
60
|
+
height: origin.height * ratio
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function isImage(filePath, mimeType) {
|
|
65
|
+
const type = (0, _regex.getFileType)(mimeType || (0, _regex.getFileExtension)(filePath));
|
|
66
|
+
return type === 'image';
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function shouldCompressImage(filePath) {
|
|
70
|
+
let compressionEnabled = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
71
|
+
const extension = (0, _regex.getFileExtension)(filePath);
|
|
72
|
+
return Boolean(extension.match(/jpg|jpeg|png/i) && compressionEnabled);
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["hash","str","String","Math","abs","split","reduce","a","c","charCodeAt","replace","start","end","text","slice","conditionChaining","conditions","values","idx","findIndex","state","Boolean","length","getDownscaleSize","origin","resizing","ratio","maxWidth","width","maxHeight","height","max","isImage","filePath","mimeType","type","getFileType","getFileExtension","shouldCompressImage","compressionEnabled","extension","match"],"sources":["index.ts"],"sourcesContent":["import { getFileExtension, getFileType } from './regex';\n\n/**\n * Converts a given string to a hashed string.\n * */\nexport function hash(str: string) {\n return String(Math.abs(str.split('').reduce((a, c) => ((a << 5) - a + c.charCodeAt(0)) | 0, 0)));\n}\n\n/**\n * Replace a specific range of text in the string with another text.\n * */\nexport function replace(str: string, start: number, end: number, text: string) {\n return str.slice(0, start) + text + str.slice(end);\n}\n\n/**\n * Returns the value corresponding to the first true index of a given condition array.\n * */\nexport function conditionChaining<T, V>(conditions: T[], values: V[]) {\n const idx = conditions.findIndex((state) => Boolean(state));\n return idx > -1 ? values[idx] : values[values.length - 1];\n}\n\n/**\n * Calculates the downscale size.\n * */\ntype Size = { width: number; height: number };\nexport function getDownscaleSize(origin: Size, resizing: Partial<Size>) {\n let ratio;\n\n const maxWidth = resizing.width || origin.width,\n maxHeight = resizing.height || origin.height;\n\n if (origin.width <= maxWidth && origin.height <= maxHeight) {\n ratio = 1;\n } else if (origin.width > maxWidth && origin.height <= maxHeight) {\n ratio = maxWidth / origin.width;\n } else if (origin.width <= maxWidth && origin.height > maxHeight) {\n ratio = maxHeight / origin.height;\n } else {\n ratio = Math.max(maxWidth / origin.width, maxHeight / origin.height);\n }\n\n return { width: origin.width * ratio, height: origin.height * ratio };\n}\n\nexport function isImage(filePath: string, mimeType?: string) {\n const type = getFileType(mimeType || getFileExtension(filePath));\n return type === 'image';\n}\n\nexport function shouldCompressImage(filePath: string, compressionEnabled = true) {\n const extension = getFileExtension(filePath);\n return Boolean(extension.match(/jpg|jpeg|png/i) && compressionEnabled);\n}\n"],"mappings":";;;;;;;;;;;;AAAA;;AAEA;AACA;AACA;AACO,SAASA,IAAT,CAAcC,GAAd,EAA2B;EAChC,OAAOC,MAAM,CAACC,IAAI,CAACC,GAAL,CAASH,GAAG,CAACI,KAAJ,CAAU,EAAV,EAAcC,MAAd,CAAqB,CAACC,CAAD,EAAIC,CAAJ,KAAW,CAACD,CAAC,IAAI,CAAN,IAAWA,CAAX,GAAeC,CAAC,CAACC,UAAF,CAAa,CAAb,CAAhB,GAAmC,CAAlE,EAAqE,CAArE,CAAT,CAAD,CAAb;AACD;AAED;AACA;AACA;;;AACO,SAASC,OAAT,CAAiBT,GAAjB,EAA8BU,KAA9B,EAA6CC,GAA7C,EAA0DC,IAA1D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AkCC,SAAS,GAAGL,MAAM,CAACM,MAArD,CAAR;EACD;;EAED,OAAO;IAAEF,KAAK,EAAEJ,MAAM,CAACI,KAAP,GAAeF,KAAxB;IAA+BI,MAAM,EAAEN,MAAM,CAACM,MAAP,GAAgBJ;EAAvD,CAAP;AACD;;AAEM,SAASM,OAAT,CAAiBC,QAAjB,EAAmCC,QAAnC,EAAsD;EAC3D,MAAMC,IAAI,GAAG,IAAAC,kBAAA,EAAYF,QAAQ,IAAI,IAAAG,uBAAA,EAAiBJ,QAAjB,CAAxB,CAAb;EACA,OAAOE,IAAI,KAAK,OAAhB;AACD;;AAEM,SAASG,mBAAT,CAA6BL,QAA7B,EAA0E;EAAA,IAA3BM,kBAA2B,uEAAN,IAAM;EAC/E,MAAMC,SAAS,GAAG,IAAAH,uBAAA,EAAiBJ,QAAjB,CAAlB;EACA,OAAOZ,OAAO,CAACmB,SAAS,CAACC,KAAV,CAAgB,eAAhB,KAAoCF,kBAArC,CAAd;AACD"}
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.emailRegex = exports.audioExtRegex = void 0;
|
|
6
|
+
exports.emailRegex = exports.createMentionTemplateRegex = exports.audioExtRegex = void 0;
|
|
7
7
|
exports.getFileExtension = getFileExtension;
|
|
8
8
|
exports.newLineRegex = exports.imageExtRegex = exports.getFileType = void 0;
|
|
9
9
|
exports.normalizeFileName = normalizeFileName;
|
|
10
|
-
exports.videoExtRegex = exports.urlRegexStrict = exports.urlRegexRough = exports.replaceUrlAsComponents = exports.phoneRegex = void 0;
|
|
10
|
+
exports.videoExtRegex = exports.urlRegexStrict = exports.urlRegexRough = exports.replaceWithRegex = exports.replaceUrlAsComponents = exports.phoneRegex = void 0;
|
|
11
11
|
|
|
12
12
|
// For iOS 12 backwards compatibility
|
|
13
13
|
require('string.prototype.matchall').shim();
|
|
@@ -20,7 +20,10 @@ const phoneRegex = /[+]?[(]?[0-9]{3}[)]?[-\s.]?[0-9]{3}[-\s.]?[0-9]{4,7}/;
|
|
|
20
20
|
exports.phoneRegex = phoneRegex;
|
|
21
21
|
const emailRegex = /\S+@\S+\.\S+/;
|
|
22
22
|
exports.emailRegex = emailRegex;
|
|
23
|
-
const newLineRegex = /\r\n|\r|\n/g;
|
|
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
|
-
|
|
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(
|
|
104
|
+
founds.forEach(_ref2 => {
|
|
59
105
|
let {
|
|
60
106
|
text,
|
|
61
107
|
start,
|
|
62
108
|
end
|
|
63
|
-
} =
|
|
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","
|
|
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,O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