@redneckz/wildless-cms-uni-blocks 0.14.770 → 0.14.772
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/bundle/bundle.umd.js +19 -26
- package/bundle/bundle.umd.min.js +1 -1
- package/bundle/components/Header/useChatBot.d.ts +1 -1
- package/bundle/utils/url.d.ts +2 -2
- package/dist/components/Header/useChatBot.d.ts +1 -1
- package/dist/components/Header/useChatBot.js +7 -3
- package/dist/components/Header/useChatBot.js.map +1 -1
- package/dist/utils/url.d.ts +2 -2
- package/dist/utils/url.js +10 -2
- package/dist/utils/url.js.map +1 -1
- package/lib/components/Header/useChatBot.d.ts +1 -1
- package/lib/components/Header/useChatBot.js +7 -3
- package/lib/components/Header/useChatBot.js.map +1 -1
- package/lib/utils/url.d.ts +2 -2
- package/lib/utils/url.js +9 -1
- package/lib/utils/url.js.map +1 -1
- package/mobile/bundle/bundle.umd.js +12 -23
- package/mobile/bundle/bundle.umd.min.js +1 -1
- package/mobile/bundle/components/Header/useChatBot.d.ts +1 -1
- package/mobile/bundle/utils/url.d.ts +2 -2
- package/mobile/dist/components/Header/useChatBot.d.ts +1 -1
- package/mobile/dist/components/Header/useChatBot.js +7 -3
- package/mobile/dist/components/Header/useChatBot.js.map +1 -1
- package/mobile/dist/utils/url.d.ts +2 -2
- package/mobile/dist/utils/url.js +10 -2
- package/mobile/dist/utils/url.js.map +1 -1
- package/mobile/lib/components/Header/useChatBot.d.ts +1 -1
- package/mobile/lib/components/Header/useChatBot.js +7 -3
- package/mobile/lib/components/Header/useChatBot.js.map +1 -1
- package/mobile/lib/utils/url.d.ts +2 -2
- package/mobile/lib/utils/url.js +9 -1
- package/mobile/lib/utils/url.js.map +1 -1
- package/mobile/src/components/Header/useChatBot.ts +17 -3
- package/mobile/src/utils/url.ts +11 -2
- package/package.json +1 -1
- package/src/components/Header/useChatBot.ts +17 -3
- package/src/utils/url.ts +11 -2
- package/bundle/utils/joinPath.d.ts +0 -2
- package/dist/utils/joinPath.d.ts +0 -2
- package/dist/utils/joinPath.js +0 -24
- package/dist/utils/joinPath.js.map +0 -1
- package/lib/utils/joinPath.d.ts +0 -2
- package/lib/utils/joinPath.js +0 -20
- package/lib/utils/joinPath.js.map +0 -1
- package/mobile/bundle/utils/joinPath.d.ts +0 -2
- package/mobile/dist/utils/joinPath.d.ts +0 -2
- package/mobile/dist/utils/joinPath.js +0 -24
- package/mobile/dist/utils/joinPath.js.map +0 -1
- package/mobile/lib/utils/joinPath.d.ts +0 -2
- package/mobile/lib/utils/joinPath.js +0 -20
- package/mobile/lib/utils/joinPath.js.map +0 -1
- package/mobile/src/utils/joinPath.ts +0 -24
- package/src/utils/joinPath.ts +0 -24
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type PreventableEventWithTarget } from '../../ui-kit/PreventableEvent';
|
|
2
|
-
export declare const useChatBot: (chat?: string) => (ev: PreventableEventWithTarget) => void
|
|
2
|
+
export declare const useChatBot: (chat?: string) => (ev: PreventableEventWithTarget) => Promise<void>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Target } from '../model/LinkProps';
|
|
2
|
-
export declare const isURL: (href: string | undefined
|
|
2
|
+
export declare const isURL: (href: string | undefined) => href is `${string}:${string}`;
|
|
3
3
|
export declare const isLocalURL: (href: string | undefined, target?: Target) => boolean;
|
|
4
4
|
export declare const isHash: (href: string | undefined) => href is `#${string}`;
|
|
5
5
|
export declare const withoutQuery: (href: string | undefined) => string;
|
|
6
|
-
export
|
|
6
|
+
export declare const joinPath: (...path: (string | undefined | null)[]) => string;
|
|
7
7
|
export declare const hasPrefix: (href?: string) => (prefix?: string) => boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type PreventableEventWithTarget } from '../../ui-kit/PreventableEvent';
|
|
2
|
-
export declare const useChatBot: (chat?: string) => (ev: PreventableEventWithTarget) => void
|
|
2
|
+
export declare const useChatBot: (chat?: string) => (ev: PreventableEventWithTarget) => Promise<void>;
|
|
@@ -8,17 +8,21 @@ const CHAT_FRAME_ID = 'webchat-js-container:webchat_rshb';
|
|
|
8
8
|
const CHAT_STORAGE_NAME = 'webchat-keep-open';
|
|
9
9
|
const CHATBOT_URL = {
|
|
10
10
|
personal: '//chat.mes.rshb.ru/assets/js/webchat_rshb',
|
|
11
|
-
business: '',
|
|
11
|
+
business: '/webchat',
|
|
12
12
|
};
|
|
13
13
|
const useChatBot = (chat) => {
|
|
14
14
|
(0, hooks_1.useEffect)(() => globalThis.localStorage?.setItem(CHAT_STORAGE_NAME, String(Date.now())), []);
|
|
15
15
|
const chatUrl = CHATBOT_URL[chat ?? ''];
|
|
16
|
-
return (ev) => {
|
|
16
|
+
return async (ev) => {
|
|
17
17
|
if (!chatUrl) {
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
20
|
if (chat !== 'personal') {
|
|
21
|
-
(0, useExternalNS_1.initializeExternalNS)(CHAT_NAMESPACE
|
|
21
|
+
(0, useExternalNS_1.initializeExternalNS)(`${CHAT_NAMESPACE}_business_css`, `${chatUrl}/bundle.css`);
|
|
22
|
+
const businessChat = (await (0, useExternalNS_1.initializeExternalNS)(CHAT_NAMESPACE, `${chatUrl}/bundle.js`));
|
|
23
|
+
if (businessChat?.render) {
|
|
24
|
+
businessChat.render(CHAT_FRAME_ID, true);
|
|
25
|
+
}
|
|
22
26
|
}
|
|
23
27
|
else {
|
|
24
28
|
const target = ev.target;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChatBot.js","sourceRoot":"","sources":["../../../src/components/Header/useChatBot.ts"],"names":[],"mappings":";;AAAA,uDAAwD;AACxD,6DAAiE;AAGjE,MAAM,cAAc,GAAG,SAAS,CAAC;AACjC,MAAM,yBAAyB,GAAG,qBAAqB,CAAC;AACxD,MAAM,aAAa,GAAG,mCAAmC,CAAC;AAC1D,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AAE9C,MAAM,WAAW,GAA2B;IAC1C,QAAQ,EAA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E;gBAC1D,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;aAClD;YAED,MAAM,SAAS,GAAG,QAAQ,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;YACzD,IAAI,CAAC,SAAS,EAAE;gBACd,IAAA,oCAAoB,EAAC,cAAc,EAAE,OAAO,CAAC,CAAC;aAC/C;SACF;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAjCW,QAAA,UAAU,cAiCrB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Target } from '../model/LinkProps';
|
|
2
|
-
export declare const isURL: (href: string | undefined
|
|
2
|
+
export declare const isURL: (href: string | undefined) => href is `${string}:${string}`;
|
|
3
3
|
export declare const isLocalURL: (href: string | undefined, target?: Target) => boolean;
|
|
4
4
|
export declare const isHash: (href: string | undefined) => href is `#${string}`;
|
|
5
5
|
export declare const withoutQuery: (href: string | undefined) => string;
|
|
6
|
-
export
|
|
6
|
+
export declare const joinPath: (...path: (string | undefined | null)[]) => string;
|
|
7
7
|
export declare const hasPrefix: (href?: string) => (prefix?: string) => boolean;
|
package/mobile/dist/utils/url.js
CHANGED
|
@@ -8,8 +8,16 @@ const isHash = (href) => Boolean(href?.startsWith('#'));
|
|
|
8
8
|
exports.isHash = isHash;
|
|
9
9
|
const withoutQuery = (href) => (href ?? '').replace(/\?.*/, '').replace(/\/$/, '');
|
|
10
10
|
exports.withoutQuery = withoutQuery;
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const joinPath = (...path) => path
|
|
12
|
+
.filter(Boolean)
|
|
13
|
+
.join('/')
|
|
14
|
+
.replace(/\/+/g, '/')
|
|
15
|
+
.replace(/^(.+):\//, '$1://') // TODO Череда очень странных преобрвзований
|
|
16
|
+
.replace(/^file:/, 'file:/')
|
|
17
|
+
.replace(/\/(\?|&|#[^!])/g, '$1')
|
|
18
|
+
.replace(/\?/g, '&')
|
|
19
|
+
.replace('&', '?');
|
|
20
|
+
exports.joinPath = joinPath;
|
|
13
21
|
const hasPrefix = (href) => (prefix) => Boolean(href &&
|
|
14
22
|
prefix &&
|
|
15
23
|
href.startsWith(prefix) &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/utils/url.ts"],"names":[],"mappings":";;AAEO,MAAM,KAAK,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/utils/url.ts"],"names":[],"mappings":";;AAEO,MAAM,KAAK,GAAG,CAAC,IAAwB,EAAiC,EAAE,CAC/E,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;AADlB,QAAA,KAAK,SACa;AAExB,MAAM,UAAU,GAAG,CAAC,IAAwB,EAAE,MAAe,EAAE,EAAE,CACtE,OAAO,CAAC,IAAI,IAAI,CAAC,IAAA,aAAK,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC;AADtD,QAAA,UAAU,cAC4C;AAE5D,MAAM,MAAM,GAAG,CAAC,IAAwB,EAAwB,EAAE,CACvE,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;AADpB,QAAA,MAAM,UACc;AAE1B,MAAM,YAAY,GAAG,CAAC,IAAwB,EAAU,EAAE,CAC/D,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AADzC,QAAA,YAAY,gBAC6B;AAE/C,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAmC,EAAU,EAAE,CACzE,IAAI;KACD,MAAM,CAAC,OAAO,CAAC;KACf,IAAI,CAAC,GAAG,CAAC;KACT,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;KACpB,OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,4CAA4C;KACzE,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC;KAC3B,OAAO,CAAC,iBAAiB,EAAE,IAAI,CAAC;KAChC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;KACnB,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AATV,QAAA,QAAQ,YASE;AAEhB,MAAM,SAAS,GAAG,CAAC,IAAa,EAAE,EAAE,CAAC,CAAC,MAAe,EAAE,EAAE,CAC9D,OAAO,CACL,IAAI;IACF,MAAM;IACN,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC;IACvB,CAAC,MAAM,KAAK,GAAG,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CACrE,CAAC;AANS,QAAA,SAAS,aAMlB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type PreventableEventWithTarget } from '../../ui-kit/PreventableEvent';
|
|
2
|
-
export declare const useChatBot: (chat?: string) => (ev: PreventableEventWithTarget) => void
|
|
2
|
+
export declare const useChatBot: (chat?: string) => (ev: PreventableEventWithTarget) => Promise<void>;
|
|
@@ -6,17 +6,21 @@ const CHAT_FRAME_ID = 'webchat-js-container:webchat_rshb';
|
|
|
6
6
|
const CHAT_STORAGE_NAME = 'webchat-keep-open';
|
|
7
7
|
const CHATBOT_URL = {
|
|
8
8
|
personal: '//chat.mes.rshb.ru/assets/js/webchat_rshb',
|
|
9
|
-
business: '',
|
|
9
|
+
business: '/webchat',
|
|
10
10
|
};
|
|
11
11
|
export const useChatBot = (chat) => {
|
|
12
12
|
useEffect(() => globalThis.localStorage?.setItem(CHAT_STORAGE_NAME, String(Date.now())), []);
|
|
13
13
|
const chatUrl = CHATBOT_URL[chat ?? ''];
|
|
14
|
-
return (ev) => {
|
|
14
|
+
return async (ev) => {
|
|
15
15
|
if (!chatUrl) {
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
18
|
if (chat !== 'personal') {
|
|
19
|
-
initializeExternalNS(CHAT_NAMESPACE
|
|
19
|
+
initializeExternalNS(`${CHAT_NAMESPACE}_business_css`, `${chatUrl}/bundle.css`);
|
|
20
|
+
const businessChat = (await initializeExternalNS(CHAT_NAMESPACE, `${chatUrl}/bundle.js`));
|
|
21
|
+
if (businessChat?.render) {
|
|
22
|
+
businessChat.render(CHAT_FRAME_ID, true);
|
|
23
|
+
}
|
|
20
24
|
}
|
|
21
25
|
else {
|
|
22
26
|
const target = ev.target;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChatBot.js","sourceRoot":"","sources":["../../../src/components/Header/useChatBot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAGjE,MAAM,cAAc,GAAG,SAAS,CAAC;AACjC,MAAM,yBAAyB,GAAG,qBAAqB,CAAC;AACxD,MAAM,aAAa,GAAG,mCAAmC,CAAC;AAC1D,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AAE9C,MAAM,WAAW,GAA2B;IAC1C,QAAQ,EAAE,2CAA2C;IACrD,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"useChatBot.js","sourceRoot":"","sources":["../../../src/components/Header/useChatBot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAGjE,MAAM,cAAc,GAAG,SAAS,CAAC;AACjC,MAAM,yBAAyB,GAAG,qBAAqB,CAAC;AACxD,MAAM,aAAa,GAAG,mCAAmC,CAAC;AAC1D,MAAM,iBAAiB,GAAG,mBAAmB,CAAC;AAE9C,MAAM,WAAW,GAA2B;IAC1C,QAAQ,EAAE,2CAA2C;IACrD,QAAQ,EAAE,UAAU;CACrB,CAAC;AAOF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAa,EAAE,EAAE;IAC1C,SAAS,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,YAAY,EAAE,OAAO,CAAC,iBAAiB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC7F,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IAExC,OAAO,KAAK,EAAE,EAA8B,EAAE,EAAE;QAC9C,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO;SACR;QAED,IAAI,IAAI,KAAK,UAAU,EAAE;YACvB,oBAAoB,CAAC,GAAG,cAAc,eAAe,EAAE,GAAG,OAAO,aAAa,CAAC,CAAC;YAEhF,MAAM,YAAY,GAAG,CAAC,MAAM,oBAAoB,CAC9C,cAAc,EACd,GAAG,OAAO,YAAY,CACvB,CAAY,CAAC;YAEd,IAAI,YAAY,EAAE,MAAM,EAAE;gBACxB,YAAY,CAAC,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;aAC1C;SACF;aAAM;YACL,MAAM,MAAM,GAAG,EAAE,CAAC,MAAqB,CAAC;YAExC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,yBAAyB,CAAC,EAAE;gBAC1D,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;aAClD;YAED,MAAM,SAAS,GAAG,QAAQ,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;YACzD,IAAI,CAAC,SAAS,EAAE;gBACd,oBAAoB,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;aAC/C;SACF;IACH,CAAC,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Target } from '../model/LinkProps';
|
|
2
|
-
export declare const isURL: (href: string | undefined
|
|
2
|
+
export declare const isURL: (href: string | undefined) => href is `${string}:${string}`;
|
|
3
3
|
export declare const isLocalURL: (href: string | undefined, target?: Target) => boolean;
|
|
4
4
|
export declare const isHash: (href: string | undefined) => href is `#${string}`;
|
|
5
5
|
export declare const withoutQuery: (href: string | undefined) => string;
|
|
6
|
-
export
|
|
6
|
+
export declare const joinPath: (...path: (string | undefined | null)[]) => string;
|
|
7
7
|
export declare const hasPrefix: (href?: string) => (prefix?: string) => boolean;
|
package/mobile/lib/utils/url.js
CHANGED
|
@@ -2,7 +2,15 @@ export const isURL = (href) => Boolean(href?.includes(':'));
|
|
|
2
2
|
export const isLocalURL = (href, target) => Boolean(href && !isURL(href) && (!target || target === '_self'));
|
|
3
3
|
export const isHash = (href) => Boolean(href?.startsWith('#'));
|
|
4
4
|
export const withoutQuery = (href) => (href ?? '').replace(/\?.*/, '').replace(/\/$/, '');
|
|
5
|
-
export
|
|
5
|
+
export const joinPath = (...path) => path
|
|
6
|
+
.filter(Boolean)
|
|
7
|
+
.join('/')
|
|
8
|
+
.replace(/\/+/g, '/')
|
|
9
|
+
.replace(/^(.+):\//, '$1://') // TODO Череда очень странных преобрвзований
|
|
10
|
+
.replace(/^file:/, 'file:/')
|
|
11
|
+
.replace(/\/(\?|&|#[^!])/g, '$1')
|
|
12
|
+
.replace(/\?/g, '&')
|
|
13
|
+
.replace('&', '?');
|
|
6
14
|
export const hasPrefix = (href) => (prefix) => Boolean(href &&
|
|
7
15
|
prefix &&
|
|
8
16
|
href.startsWith(prefix) &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/utils/url.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"url.js","sourceRoot":"","sources":["../../src/utils/url.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,IAAwB,EAAiC,EAAE,CAC/E,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;AAE/B,MAAM,CAAC,MAA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@@ const CHAT_STORAGE_NAME = 'webchat-keep-open';
|
|
|
9
9
|
|
|
10
10
|
const CHATBOT_URL: Record<string, string> = {
|
|
11
11
|
personal: '//chat.mes.rshb.ru/assets/js/webchat_rshb',
|
|
12
|
-
business: '',
|
|
12
|
+
business: '/webchat',
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
+
interface WebChat {
|
|
16
|
+
render?: (id?: string, isOpen?: boolean) => void;
|
|
17
|
+
chatOpen?: () => void;
|
|
18
|
+
}
|
|
19
|
+
|
|
15
20
|
export const useChatBot = (chat?: string) => {
|
|
16
21
|
useEffect(() => globalThis.localStorage?.setItem(CHAT_STORAGE_NAME, String(Date.now())), []);
|
|
17
22
|
const chatUrl = CHATBOT_URL[chat ?? ''];
|
|
18
23
|
|
|
19
|
-
return (ev: PreventableEventWithTarget) => {
|
|
24
|
+
return async (ev: PreventableEventWithTarget) => {
|
|
20
25
|
if (!chatUrl) {
|
|
21
26
|
return;
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
if (chat !== 'personal') {
|
|
25
|
-
initializeExternalNS(CHAT_NAMESPACE
|
|
30
|
+
initializeExternalNS(`${CHAT_NAMESPACE}_business_css`, `${chatUrl}/bundle.css`);
|
|
31
|
+
|
|
32
|
+
const businessChat = (await initializeExternalNS(
|
|
33
|
+
CHAT_NAMESPACE,
|
|
34
|
+
`${chatUrl}/bundle.js`,
|
|
35
|
+
)) as WebChat;
|
|
36
|
+
|
|
37
|
+
if (businessChat?.render) {
|
|
38
|
+
businessChat.render(CHAT_FRAME_ID, true);
|
|
39
|
+
}
|
|
26
40
|
} else {
|
|
27
41
|
const target = ev.target as HTMLElement;
|
|
28
42
|
|
package/mobile/src/utils/url.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Target } from '../model/LinkProps';
|
|
2
2
|
|
|
3
|
-
export const isURL = (href: string | undefined
|
|
3
|
+
export const isURL = (href: string | undefined): href is `${string}:${string}` =>
|
|
4
4
|
Boolean(href?.includes(':'));
|
|
5
5
|
|
|
6
6
|
export const isLocalURL = (href: string | undefined, target?: Target) =>
|
|
@@ -12,7 +12,16 @@ export const isHash = (href: string | undefined): href is `#${string}` =>
|
|
|
12
12
|
export const withoutQuery = (href: string | undefined): string =>
|
|
13
13
|
(href ?? '').replace(/\?.*/, '').replace(/\/$/, '');
|
|
14
14
|
|
|
15
|
-
export
|
|
15
|
+
export const joinPath = (...path: (string | undefined | null)[]): string =>
|
|
16
|
+
path
|
|
17
|
+
.filter(Boolean)
|
|
18
|
+
.join('/')
|
|
19
|
+
.replace(/\/+/g, '/')
|
|
20
|
+
.replace(/^(.+):\//, '$1://') // TODO Череда очень странных преобрвзований
|
|
21
|
+
.replace(/^file:/, 'file:/')
|
|
22
|
+
.replace(/\/(\?|&|#[^!])/g, '$1')
|
|
23
|
+
.replace(/\?/g, '&')
|
|
24
|
+
.replace('&', '?');
|
|
16
25
|
|
|
17
26
|
export const hasPrefix = (href?: string) => (prefix?: string) =>
|
|
18
27
|
Boolean(
|
package/package.json
CHANGED
|
@@ -9,20 +9,34 @@ const CHAT_STORAGE_NAME = 'webchat-keep-open';
|
|
|
9
9
|
|
|
10
10
|
const CHATBOT_URL: Record<string, string> = {
|
|
11
11
|
personal: '//chat.mes.rshb.ru/assets/js/webchat_rshb',
|
|
12
|
-
business: '',
|
|
12
|
+
business: '/webchat',
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
+
interface WebChat {
|
|
16
|
+
render?: (id?: string, isOpen?: boolean) => void;
|
|
17
|
+
chatOpen?: () => void;
|
|
18
|
+
}
|
|
19
|
+
|
|
15
20
|
export const useChatBot = (chat?: string) => {
|
|
16
21
|
useEffect(() => globalThis.localStorage?.setItem(CHAT_STORAGE_NAME, String(Date.now())), []);
|
|
17
22
|
const chatUrl = CHATBOT_URL[chat ?? ''];
|
|
18
23
|
|
|
19
|
-
return (ev: PreventableEventWithTarget) => {
|
|
24
|
+
return async (ev: PreventableEventWithTarget) => {
|
|
20
25
|
if (!chatUrl) {
|
|
21
26
|
return;
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
if (chat !== 'personal') {
|
|
25
|
-
initializeExternalNS(CHAT_NAMESPACE
|
|
30
|
+
initializeExternalNS(`${CHAT_NAMESPACE}_business_css`, `${chatUrl}/bundle.css`);
|
|
31
|
+
|
|
32
|
+
const businessChat = (await initializeExternalNS(
|
|
33
|
+
CHAT_NAMESPACE,
|
|
34
|
+
`${chatUrl}/bundle.js`,
|
|
35
|
+
)) as WebChat;
|
|
36
|
+
|
|
37
|
+
if (businessChat?.render) {
|
|
38
|
+
businessChat.render(CHAT_FRAME_ID, true);
|
|
39
|
+
}
|
|
26
40
|
} else {
|
|
27
41
|
const target = ev.target as HTMLElement;
|
|
28
42
|
|
package/src/utils/url.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Target } from '../model/LinkProps';
|
|
2
2
|
|
|
3
|
-
export const isURL = (href: string | undefined
|
|
3
|
+
export const isURL = (href: string | undefined): href is `${string}:${string}` =>
|
|
4
4
|
Boolean(href?.includes(':'));
|
|
5
5
|
|
|
6
6
|
export const isLocalURL = (href: string | undefined, target?: Target) =>
|
|
@@ -12,7 +12,16 @@ export const isHash = (href: string | undefined): href is `#${string}` =>
|
|
|
12
12
|
export const withoutQuery = (href: string | undefined): string =>
|
|
13
13
|
(href ?? '').replace(/\?.*/, '').replace(/\/$/, '');
|
|
14
14
|
|
|
15
|
-
export
|
|
15
|
+
export const joinPath = (...path: (string | undefined | null)[]): string =>
|
|
16
|
+
path
|
|
17
|
+
.filter(Boolean)
|
|
18
|
+
.join('/')
|
|
19
|
+
.replace(/\/+/g, '/')
|
|
20
|
+
.replace(/^(.+):\//, '$1://') // TODO Череда очень странных преобрвзований
|
|
21
|
+
.replace(/^file:/, 'file:/')
|
|
22
|
+
.replace(/\/(\?|&|#[^!])/g, '$1')
|
|
23
|
+
.replace(/\?/g, '&')
|
|
24
|
+
.replace('&', '?');
|
|
16
25
|
|
|
17
26
|
export const hasPrefix = (href?: string) => (prefix?: string) =>
|
|
18
27
|
Boolean(
|
package/dist/utils/joinPath.d.ts
DELETED
package/dist/utils/joinPath.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.joinSearchParams = exports.joinPath = void 0;
|
|
3
|
-
const PLACEHOLDER = 'http://_';
|
|
4
|
-
const joinPath = (...path) => {
|
|
5
|
-
const urls = path.filter(Boolean).map((_) => new URL(_, PLACEHOLDER));
|
|
6
|
-
const origin = urls.find((_) => _.origin !== PLACEHOLDER)?.origin;
|
|
7
|
-
const pathname = cleanPath(urls.map((_) => _.pathname));
|
|
8
|
-
const query = (0, exports.joinSearchParams)(...urls.map((_) => _.searchParams)).toString();
|
|
9
|
-
const hash = urls.find((_) => _.hash)?.hash;
|
|
10
|
-
return [origin, pathname, query ? `?${query}` : '', hash].filter(Boolean).join('');
|
|
11
|
-
};
|
|
12
|
-
exports.joinPath = joinPath;
|
|
13
|
-
const joinSearchParams = (...list) => {
|
|
14
|
-
const result = new URLSearchParams();
|
|
15
|
-
for (const searchParams of list) {
|
|
16
|
-
for (const [k, v] of searchParams) {
|
|
17
|
-
result.set(k, v);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return result;
|
|
21
|
-
};
|
|
22
|
-
exports.joinSearchParams = joinSearchParams;
|
|
23
|
-
const cleanPath = (pathParts) => pathParts.join('/').replace(/\/+/g, '/');
|
|
24
|
-
//# sourceMappingURL=joinPath.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"joinPath.js","sourceRoot":"","sources":["../../src/utils/joinPath.ts"],"names":[],"mappings":";;AAAA,MAAM,WAAW,GAAG,UAAU,CAAC;AAExB,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAmC,EAAU,EAAE;IACzE,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG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EF,MAAM,SAAS,GAAG,CAAC,SAAmB,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC"}
|
package/lib/utils/joinPath.d.ts
DELETED
package/lib/utils/joinPath.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const PLACEHOLDER = 'http://_';
|
|
2
|
-
export const joinPath = (...path) => {
|
|
3
|
-
const urls = path.filter(Boolean).map((_) => new URL(_, PLACEHOLDER));
|
|
4
|
-
const origin = urls.find((_) => _.origin !== PLACEHOLDER)?.origin;
|
|
5
|
-
const pathname = cleanPath(urls.map((_) => _.pathname));
|
|
6
|
-
const query = joinSearchParams(...urls.map((_) => _.searchParams)).toString();
|
|
7
|
-
const hash = urls.find((_) => _.hash)?.hash;
|
|
8
|
-
return [origin, pathname, query ? `?${query}` : '', hash].filter(Boolean).join('');
|
|
9
|
-
};
|
|
10
|
-
export const joinSearchParams = (...list) => {
|
|
11
|
-
const result = new URLSearchParams();
|
|
12
|
-
for (const searchParams of list) {
|
|
13
|
-
for (const [k, v] of searchParams) {
|
|
14
|
-
result.set(k, v);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return result;
|
|
18
|
-
};
|
|
19
|
-
const cleanPath = (pathParts) => pathParts.join('/').replace(/\/+/g, '/');
|
|
20
|
-
//# sourceMappingURL=joinPath.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"joinPath.js","sourceRoot":"","sources":["../../src/utils/joinPath.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,GAAG,UAAU,CAAC;AAE/B,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAmC,EAAU,EAAE;IACzE,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,CAAW,EAA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,EAAE,GAAG,CAAC,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
|
-
exports.joinSearchParams = exports.joinPath = void 0;
|
|
3
|
-
const PLACEHOLDER = 'http://_';
|
|
4
|
-
const joinPath = (...path) => {
|
|
5
|
-
const urls = path.filter(Boolean).map((_) => new URL(_, PLACEHOLDER));
|
|
6
|
-
const origin = urls.find((_) => _.origin !== PLACEHOLDER)?.origin;
|
|
7
|
-
const pathname = cleanPath(urls.map((_) => _.pathname));
|
|
8
|
-
const query = (0, exports.joinSearchParams)(...urls.map((_) => _.searchParams)).toString();
|
|
9
|
-
const hash = urls.find((_) => _.hash)?.hash;
|
|
10
|
-
return [origin, pathname, query ? `?${query}` : '', hash].filter(Boolean).join('');
|
|
11
|
-
};
|
|
12
|
-
exports.joinPath = joinPath;
|
|
13
|
-
const joinSearchParams = (...list) => {
|
|
14
|
-
const result = new URLSearchParams();
|
|
15
|
-
for (const searchParams of list) {
|
|
16
|
-
for (const [k, v] of searchParams) {
|
|
17
|
-
result.set(k, v);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return result;
|
|
21
|
-
};
|
|
22
|
-
exports.joinSearchParams = joinSearchParams;
|
|
23
|
-
const cleanPath = (pathParts) => pathParts.join('/').replace(/\/+/g, '/');
|
|
24
|
-
//# sourceMappingURL=joinPath.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"joinPath.js","sourceRoot":"","sources":["../../src/utils/joinPath.ts"],"names":[],"mappings":";;AAAA,MAAM,WAAW,GAAG,UAAU,CAAC;AAExB,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAmC,EAAU,EAAE;IACzE,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,CAAW,EAAE,WAAW,CAAC,CAAC,CA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,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
const PLACEHOLDER = 'http://_';
|
|
2
|
-
export const joinPath = (...path) => {
|
|
3
|
-
const urls = path.filter(Boolean).map((_) => new URL(_, PLACEHOLDER));
|
|
4
|
-
const origin = urls.find((_) => _.origin !== PLACEHOLDER)?.origin;
|
|
5
|
-
const pathname = cleanPath(urls.map((_) => _.pathname));
|
|
6
|
-
const query = joinSearchParams(...urls.map((_) => _.searchParams)).toString();
|
|
7
|
-
const hash = urls.find((_) => _.hash)?.hash;
|
|
8
|
-
return [origin, pathname, query ? `?${query}` : '', hash].filter(Boolean).join('');
|
|
9
|
-
};
|
|
10
|
-
export const joinSearchParams = (...list) => {
|
|
11
|
-
const result = new URLSearchParams();
|
|
12
|
-
for (const searchParams of list) {
|
|
13
|
-
for (const [k, v] of searchParams) {
|
|
14
|
-
result.set(k, v);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return result;
|
|
18
|
-
};
|
|
19
|
-
const cleanPath = (pathParts) => pathParts.join('/').replace(/\/+/g, '/');
|
|
20
|
-
//# sourceMappingURL=joinPath.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"joinPath.js","sourceRoot":"","sources":["../../src/utils/joinPath.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,GAAG,UAAU,CAAC;AAE/B,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAmC,EAAU,EAAE;IACzE,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC,CAAW,EAAE,WAAW,CAAC,CAAC,CAAC;IAChF,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,WAAW,CAAC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string => {
|
|
4
|
-
const urls = path.filter(Boolean).map((_) => new URL(_ as string, PLACEHOLDER));
|
|
5
|
-
const origin = urls.find((_) => _.origin !== PLACEHOLDER)?.origin;
|
|
6
|
-
const pathname = cleanPath(urls.map((_) => _.pathname));
|
|
7
|
-
const query = joinSearchParams(...urls.map((_) => _.searchParams)).toString();
|
|
8
|
-
const hash = urls.find((_) => _.hash)?.hash;
|
|
9
|
-
|
|
10
|
-
return [origin, pathname, query ? `?${query}` : '', hash].filter(Boolean).join('');
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const joinSearchParams = (...list: URLSearchParams[]): URLSearchParams => {
|
|
14
|
-
const result = new URLSearchParams();
|
|
15
|
-
for (const searchParams of list) {
|
|
16
|
-
for (const [k, v] of searchParams) {
|
|
17
|
-
result.set(k, v);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return result;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const cleanPath = (pathParts: string[]) => pathParts.join('/').replace(/\/+/g, '/');
|
package/src/utils/joinPath.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
const PLACEHOLDER = 'http://_';
|
|
2
|
-
|
|
3
|
-
export const joinPath = (...path: (string | undefined | null)[]): string => {
|
|
4
|
-
const urls = path.filter(Boolean).map((_) => new URL(_ as string, PLACEHOLDER));
|
|
5
|
-
const origin = urls.find((_) => _.origin !== PLACEHOLDER)?.origin;
|
|
6
|
-
const pathname = cleanPath(urls.map((_) => _.pathname));
|
|
7
|
-
const query = joinSearchParams(...urls.map((_) => _.searchParams)).toString();
|
|
8
|
-
const hash = urls.find((_) => _.hash)?.hash;
|
|
9
|
-
|
|
10
|
-
return [origin, pathname, query ? `?${query}` : '', hash].filter(Boolean).join('');
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const joinSearchParams = (...list: URLSearchParams[]): URLSearchParams => {
|
|
14
|
-
const result = new URLSearchParams();
|
|
15
|
-
for (const searchParams of list) {
|
|
16
|
-
for (const [k, v] of searchParams) {
|
|
17
|
-
result.set(k, v);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return result;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const cleanPath = (pathParts: string[]) => pathParts.join('/').replace(/\/+/g, '/');
|