@yinshan-tech/webrtc-react 0.1.0 → 0.1.1
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/README.md +21 -21
- package/dist/OutboundCallButton.d.ts +43 -0
- package/dist/OutboundCallButton.js +80 -0
- package/dist/OutboundCallButton.js.map +1 -0
- package/dist/OutboundCallModal.d.ts +49 -0
- package/dist/OutboundCallModal.js +279 -0
- package/dist/OutboundCallModal.js.map +1 -0
- package/dist/ensureCallModalHost.d.ts +7 -0
- package/dist/ensureCallModalHost.js +104 -0
- package/dist/ensureCallModalHost.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.css +302 -0
- package/dist/useWebRTCInitialization.d.ts +6 -0
- package/dist/useWebRTCInitialization.js +17 -0
- package/dist/useWebRTCInitialization.js.map +1 -0
- package/package.json +9 -5
package/README.md
CHANGED
|
@@ -35,17 +35,17 @@ import { OutboundCallButton } from '@yinshan-tech/webrtc-react';
|
|
|
35
35
|
|
|
36
36
|
## OutboundCallButton 可配置项
|
|
37
37
|
|
|
38
|
-
| Prop
|
|
39
|
-
|
|
|
40
|
-
| `...OutboundCallParams`
|
|
41
|
-
| `buttonText` / `children` | string / node
|
|
42
|
-
| `loading` / `disabled`
|
|
43
|
-
| `className` / `style`
|
|
44
|
-
| `onNotify`
|
|
45
|
-
| `onResult`
|
|
46
|
-
| `confirmBeforeCall`
|
|
47
|
-
| `autoMountModal`
|
|
48
|
-
| `render`
|
|
38
|
+
| Prop | 类型 | 说明 |
|
|
39
|
+
| --- | --- | --- |
|
|
40
|
+
| `...OutboundCallParams` | - | casePoolId / role / outboundDialPhoneType / customerName / contactMobile / providerType / onCallStart / onCallSuccess 等 |
|
|
41
|
+
| `buttonText` / `children` | string / node | 按钮内容,默认取 kit messages `webrtc.outbound` |
|
|
42
|
+
| `loading` / `disabled` | boolean | 外部 loading / 禁用 |
|
|
43
|
+
| `className` / `style` | - | 样式(默认类名 `wro-btn`) |
|
|
44
|
+
| `onNotify` | `(notify) => void` | 注册 / 拨号过程提示,桥接宿主 toast |
|
|
45
|
+
| `onResult` | `(result) => void` | 拨号流程最终结果(ok / errorCode) |
|
|
46
|
+
| `confirmBeforeCall` | `() => boolean \| Promise<boolean>` | 拨号前拦截(如灰名单二次确认),返回 false 取消 |
|
|
47
|
+
| `autoMountModal` | boolean,默认 `true` | 自动挂载全局通话弹窗;自渲染弹窗时设为 false |
|
|
48
|
+
| `render` | `({ start, busy, disabled, text }) => element` | headless 模式:完全自定义按钮 UI,逻辑复用 |
|
|
49
49
|
|
|
50
50
|
`render` 示例(用 antd 按钮):
|
|
51
51
|
|
|
@@ -62,16 +62,16 @@ import { OutboundCallButton } from '@yinshan-tech/webrtc-react';
|
|
|
62
62
|
|
|
63
63
|
弹窗默认由按钮自动挂载;需要自定义时手动渲染一次(全局一个)并给按钮传 `autoMountModal={false}`。
|
|
64
64
|
|
|
65
|
-
| Prop
|
|
66
|
-
|
|
|
67
|
-
| `className` / `overlayClassName` / `style` | -
|
|
68
|
-
| `cssVars`
|
|
69
|
-
| `zIndex`
|
|
70
|
-
| `showMute`
|
|
71
|
-
| `texts`
|
|
72
|
-
| `filterInfo`
|
|
73
|
-
| `renderContent`
|
|
74
|
-
| `onStateChange`
|
|
65
|
+
| Prop | 类型 | 说明 |
|
|
66
|
+
| --- | --- | --- |
|
|
67
|
+
| `className` / `overlayClassName` / `style` | - | 弹窗 / 遮罩样式 |
|
|
68
|
+
| `cssVars` | `Record<string, string>` | 覆盖 CSS 变量,如 `{ '--wro-btn-bg': '#1677ff' }` |
|
|
69
|
+
| `zIndex` | number | 弹窗层级 |
|
|
70
|
+
| `showMute` | boolean,默认 true | 是否显示静音按钮 |
|
|
71
|
+
| `texts` | `{ hangup, mute, unmute, calling, connected, ... }` | 文案覆盖(优先级高于 kit messages) |
|
|
72
|
+
| `filterInfo` | `(info) => boolean` | 多实例时过滤要展示的通话 |
|
|
73
|
+
| `renderContent` | `({ info, muted, canHangup, hangup, toggleMute, stateText }) => node` | 完全自定义弹窗内容,保留遮罩与状态订阅 |
|
|
74
|
+
| `onStateChange` | `(info) => void` | 通话状态变化回调(埋点 / 宿主联动) |
|
|
75
75
|
|
|
76
76
|
全局默认样式也可以在初始化时统一配置:
|
|
77
77
|
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { OutboundCallParams, OutboundCallNotify, StartOutboundCallResult } from '@yinshan-tech/webrtc-sdk';
|
|
3
|
+
export interface OutboundCallButtonRenderProps {
|
|
4
|
+
/** Trigger the call (already guards busy/disabled) */
|
|
5
|
+
start: () => Promise<void>;
|
|
6
|
+
/** True while dialing flow is running */
|
|
7
|
+
busy: boolean;
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
text: string;
|
|
10
|
+
}
|
|
11
|
+
export declare type OutboundCallButtonProps = OutboundCallParams & {
|
|
12
|
+
/** Extra loading from parent (e.g. row data refreshing) */
|
|
13
|
+
loading?: boolean;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
children?: React.ReactNode;
|
|
16
|
+
className?: string;
|
|
17
|
+
style?: React.CSSProperties;
|
|
18
|
+
/** Fallback text when children omitted; default from kit messages `webrtc.outbound` */
|
|
19
|
+
buttonText?: string;
|
|
20
|
+
/** Bridge register/dial notifications to host toast (antd message, ElMessage, ...) */
|
|
21
|
+
onNotify?: (notify: OutboundCallNotify) => void;
|
|
22
|
+
/** Called with the final result of the dial flow (ok / errorCode) */
|
|
23
|
+
onResult?: (result: StartOutboundCallResult) => void;
|
|
24
|
+
/** Optional gate before dialing, e.g. graylist confirm. Return false to abort. */
|
|
25
|
+
confirmBeforeCall?: () => boolean | Promise<boolean>;
|
|
26
|
+
/**
|
|
27
|
+
* Auto-mount the global call modal on first render. Default true.
|
|
28
|
+
* Set false if you render <OutboundCallModal /> (or your own modal) manually.
|
|
29
|
+
*/
|
|
30
|
+
autoMountModal?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Fully custom rendering (headless mode): receive `start`/`busy` and render anything.
|
|
33
|
+
* When provided, className/style/children/buttonText are ignored.
|
|
34
|
+
*/
|
|
35
|
+
render?: (renderProps: OutboundCallButtonRenderProps) => React.ReactElement;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Plugin call button (one per table row).
|
|
39
|
+
* Usage: createWebRTCKit(...) once, then just render this component —
|
|
40
|
+
* the global call modal is auto-mounted.
|
|
41
|
+
*/
|
|
42
|
+
export declare const OutboundCallButton: React.FC<OutboundCallButtonProps>;
|
|
43
|
+
export default OutboundCallButton;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { startOutboundCall, tryGetActiveKit, } from '@yinshan-tech/webrtc-sdk';
|
|
3
|
+
import { ensureOutboundCallModalHost } from './ensureCallModalHost';
|
|
4
|
+
function defaultText() {
|
|
5
|
+
var _a;
|
|
6
|
+
return ((_a = tryGetActiveKit()) === null || _a === void 0 ? void 0 : _a.config.messages['webrtc.outbound']) || 'Call Center';
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Plugin call button (one per table row).
|
|
10
|
+
* Usage: createWebRTCKit(...) once, then just render this component —
|
|
11
|
+
* the global call modal is auto-mounted.
|
|
12
|
+
*/
|
|
13
|
+
export const OutboundCallButton = (props) => {
|
|
14
|
+
var _a, _b;
|
|
15
|
+
const { loading = false, disabled = false, children, className, style, buttonText, onNotify, onResult, confirmBeforeCall, autoMountModal = true, render, reviewerId, casePoolId, role, outboundDialPhoneType, customerName, contactMobile, customerHistoryMobile, providerType, instanceId, phoneNumber, onCallStart, onCallSuccess, } = props;
|
|
16
|
+
const [busy, setBusy] = useState(false);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (autoMountModal) {
|
|
19
|
+
ensureOutboundCallModalHost();
|
|
20
|
+
}
|
|
21
|
+
}, [autoMountModal]);
|
|
22
|
+
const start = useCallback(async () => {
|
|
23
|
+
if (disabled || busy || loading)
|
|
24
|
+
return;
|
|
25
|
+
if (confirmBeforeCall && !(await confirmBeforeCall()))
|
|
26
|
+
return;
|
|
27
|
+
if (autoMountModal) {
|
|
28
|
+
ensureOutboundCallModalHost();
|
|
29
|
+
}
|
|
30
|
+
setBusy(true);
|
|
31
|
+
try {
|
|
32
|
+
const result = await startOutboundCall({
|
|
33
|
+
reviewerId,
|
|
34
|
+
casePoolId,
|
|
35
|
+
role,
|
|
36
|
+
outboundDialPhoneType,
|
|
37
|
+
customerName,
|
|
38
|
+
contactMobile,
|
|
39
|
+
customerHistoryMobile,
|
|
40
|
+
providerType,
|
|
41
|
+
instanceId,
|
|
42
|
+
phoneNumber,
|
|
43
|
+
onCallStart,
|
|
44
|
+
onCallSuccess,
|
|
45
|
+
}, { onNotify });
|
|
46
|
+
onResult === null || onResult === void 0 ? void 0 : onResult(result);
|
|
47
|
+
}
|
|
48
|
+
finally {
|
|
49
|
+
setBusy(false);
|
|
50
|
+
}
|
|
51
|
+
}, [
|
|
52
|
+
disabled,
|
|
53
|
+
busy,
|
|
54
|
+
loading,
|
|
55
|
+
confirmBeforeCall,
|
|
56
|
+
autoMountModal,
|
|
57
|
+
reviewerId,
|
|
58
|
+
casePoolId,
|
|
59
|
+
role,
|
|
60
|
+
outboundDialPhoneType,
|
|
61
|
+
customerName,
|
|
62
|
+
contactMobile,
|
|
63
|
+
customerHistoryMobile,
|
|
64
|
+
providerType,
|
|
65
|
+
instanceId,
|
|
66
|
+
phoneNumber,
|
|
67
|
+
onCallStart,
|
|
68
|
+
onCallSuccess,
|
|
69
|
+
onNotify,
|
|
70
|
+
onResult,
|
|
71
|
+
]);
|
|
72
|
+
const isLoading = loading || busy;
|
|
73
|
+
const text = (_b = (_a = (typeof children === 'string' ? children : undefined)) !== null && _a !== void 0 ? _a : buttonText) !== null && _b !== void 0 ? _b : defaultText();
|
|
74
|
+
if (render) {
|
|
75
|
+
return render({ start, busy: isLoading, disabled, text });
|
|
76
|
+
}
|
|
77
|
+
return (React.createElement("button", { type: "button", className: ['wro-btn', className].filter(Boolean).join(' '), style: style, disabled: disabled || isLoading, onClick: start, "aria-busy": isLoading }, children !== null && children !== void 0 ? children : text));
|
|
78
|
+
};
|
|
79
|
+
export default OutboundCallButton;
|
|
80
|
+
//# sourceMappingURL=OutboundCallButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OutboundCallButton.js","sourceRoot":"","sources":["../src/OutboundCallButton.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EACL,iBAAiB,EACjB,eAAe,GAChB,MAAM,qBAAqB,CAAC;AAM7B,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAsCpE,SAAS,WAAW;;IAClB,OAAO,CAAA,MAAA,eAAe,EAAE,0CAAE,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAC,KAAI,aAAa,CAAC;AAChF,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAsC,CAAC,KAAK,EAAE,EAAE;;IAC7E,MAAM,EACJ,OAAO,GAAG,KAAK,EACf,QAAQ,GAAG,KAAK,EAChB,QAAQ,EACR,SAAS,EACT,KAAK,EACL,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,iBAAiB,EACjB,cAAc,GAAG,IAAI,EACrB,MAAM,EACN,UAAU,EACV,UAAU,EACV,IAAI,EACJ,qBAAqB,EACrB,YAAY,EACZ,aAAa,EACb,qBAAqB,EACrB,YAAY,EACZ,UAAU,EACV,WAAW,EACX,WAAW,EACX,aAAa,GACd,GAAG,KAAK,CAAC;IAEV,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAExC,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,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;QACV,OAAO,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;KAC3D;IAED,OAAO,CACL,gCACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAC3D,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,IAAI,SAAS,EAC/B,OAAO,EAAE,KAAK,eACH,SAAS,IAEnB,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,IAAI,CACV,CACV,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { CallInfo } from '@yinshan-tech/webrtc-sdk';
|
|
3
|
+
/** Text overrides; fall back to kit messages then English */
|
|
4
|
+
export interface OutboundCallModalTexts {
|
|
5
|
+
customer?: string;
|
|
6
|
+
calling?: string;
|
|
7
|
+
connected?: string;
|
|
8
|
+
ended?: string;
|
|
9
|
+
failed?: string;
|
|
10
|
+
waiting?: string;
|
|
11
|
+
timeout?: string;
|
|
12
|
+
hangup?: string;
|
|
13
|
+
close?: string;
|
|
14
|
+
mute?: string;
|
|
15
|
+
unmute?: string;
|
|
16
|
+
minimize?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface OutboundCallModalRenderProps {
|
|
19
|
+
info: CallInfo;
|
|
20
|
+
muted: boolean;
|
|
21
|
+
canHangup: boolean;
|
|
22
|
+
hangup: () => void;
|
|
23
|
+
toggleMute: () => void;
|
|
24
|
+
stateText: string;
|
|
25
|
+
}
|
|
26
|
+
export interface OutboundCallModalProps {
|
|
27
|
+
className?: string;
|
|
28
|
+
style?: React.CSSProperties;
|
|
29
|
+
/** CSS variable overrides on root */
|
|
30
|
+
cssVars?: Record<string, string>;
|
|
31
|
+
zIndex?: number;
|
|
32
|
+
/** Show mute button when connected. Default true */
|
|
33
|
+
showMute?: boolean;
|
|
34
|
+
/** Allow minimize. Default true */
|
|
35
|
+
showMinimize?: boolean;
|
|
36
|
+
/** Text overrides */
|
|
37
|
+
texts?: OutboundCallModalTexts;
|
|
38
|
+
/** Filter which call infos to show; default: non-predictive visible calls */
|
|
39
|
+
filterInfo?: (info: CallInfo) => boolean;
|
|
40
|
+
/** Fully custom modal body */
|
|
41
|
+
renderContent?: (renderProps: OutboundCallModalRenderProps) => React.ReactNode;
|
|
42
|
+
onStateChange?: (info: CallInfo) => void;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Global call modal — mount ONCE (auto by OutboundCallButton, or manually).
|
|
46
|
+
* Visual style aligned with hc-admin call widget; no antd dependency.
|
|
47
|
+
*/
|
|
48
|
+
export declare const OutboundCallModal: React.FC<OutboundCallModalProps>;
|
|
49
|
+
export default OutboundCallModal;
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { subscribeCallState, getAllCallInfo, webRTCServiceManager, tryGetActiveKit, setCallInfo, } from '@yinshan-tech/webrtc-sdk';
|
|
3
|
+
function kitMsg(code, fallback) {
|
|
4
|
+
var _a;
|
|
5
|
+
return ((_a = tryGetActiveKit()) === null || _a === void 0 ? void 0 : _a.config.messages[`webrtc.${code}`]) || fallback;
|
|
6
|
+
}
|
|
7
|
+
function IconMinus() {
|
|
8
|
+
return (React.createElement("svg", { width: "14", height: "14", viewBox: "0 0 14 14", "aria-hidden": true },
|
|
9
|
+
React.createElement("path", { d: "M2.5 7h9", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round" })));
|
|
10
|
+
}
|
|
11
|
+
function IconPhone() {
|
|
12
|
+
return (React.createElement("svg", { width: "22", height: "22", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true },
|
|
13
|
+
React.createElement("path", { d: "M6.62 10.79a15.05 15.05 0 006.59 6.59l2.2-2.2a1 1 0 011.01-.24c1.12.37 2.33.57 3.58.57a1 1 0 011 1V20a1 1 0 01-1 1C10.4 21 3 13.6 3 4a1 1 0 011-1h3.5a1 1 0 011 1c0 1.25.2 2.46.57 3.58a1 1 0 01-.24 1.01l-2.21 2.2z" })));
|
|
14
|
+
}
|
|
15
|
+
function IconMic({ muted }) {
|
|
16
|
+
if (muted) {
|
|
17
|
+
return (React.createElement("svg", { width: "22", height: "22", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true },
|
|
18
|
+
React.createElement("path", { d: "M19 11h-1.7a5.3 5.3 0 01-.5 2.1l1.3 1.3A7 7 0 0019 11zM12 4a3 3 0 013 3v.2l1.8 1.8V7a4.8 4.8 0 00-9.6 0v4c0 .3 0 .6.1.9l1.5 1.5.1-.4V7a3 3 0 013-3zM4.3 3L3 4.3 9.7 11v1a2.3 2.3 0 002.3 2.3h.2L16 18.5V19h-4v2h6.7L19.7 23 21 21.7 4.3 3z" })));
|
|
19
|
+
}
|
|
20
|
+
return (React.createElement("svg", { width: "22", height: "22", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": true },
|
|
21
|
+
React.createElement("path", { d: "M12 14a3 3 0 003-3V5a3 3 0 10-6 0v6a3 3 0 003 3zm5-3a5 5 0 01-10 0H5a7 7 0 006 6.9V21h2v-3.1A7 7 0 0019 11h-2z" })));
|
|
22
|
+
}
|
|
23
|
+
function pad2(n) {
|
|
24
|
+
return n.toString().padStart(2, '0');
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Global call modal — mount ONCE (auto by OutboundCallButton, or manually).
|
|
28
|
+
* Visual style aligned with hc-admin call widget; no antd dependency.
|
|
29
|
+
*/
|
|
30
|
+
export const OutboundCallModal = ({ className, style, cssVars, zIndex, showMute = true, showMinimize = true, texts, filterInfo, renderContent, onStateChange, }) => {
|
|
31
|
+
const [infos, setInfos] = useState(() => getAllCallInfo());
|
|
32
|
+
const [mutedMap, setMutedMap] = useState({});
|
|
33
|
+
const [minimizedMap, setMinimizedMap] = useState({});
|
|
34
|
+
const [durationMap, setDurationMap] = useState({});
|
|
35
|
+
/** Committed float positions (left/top). Absent = CSS default top-right. */
|
|
36
|
+
const [posMap, setPosMap] = useState({});
|
|
37
|
+
const startTimeRef = useRef({});
|
|
38
|
+
const dragRef = useRef(null);
|
|
39
|
+
const t = useCallback((code, fallback) => { var _a; return (_a = texts === null || texts === void 0 ? void 0 : texts[code]) !== null && _a !== void 0 ? _a : kitMsg(code, fallback); }, [texts]);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
return subscribeCallState((info) => {
|
|
42
|
+
onStateChange === null || onStateChange === void 0 ? void 0 : onStateChange(info);
|
|
43
|
+
setInfos((prev) => {
|
|
44
|
+
const idx = prev.findIndex((i) => i.instanceId === info.instanceId);
|
|
45
|
+
if (idx >= 0) {
|
|
46
|
+
const next = [...prev];
|
|
47
|
+
next[idx] = info;
|
|
48
|
+
return next;
|
|
49
|
+
}
|
|
50
|
+
return [...prev, info];
|
|
51
|
+
});
|
|
52
|
+
if (!info.visible) {
|
|
53
|
+
setMutedMap((prev) => (Object.assign(Object.assign({}, prev), { [info.instanceId]: false })));
|
|
54
|
+
setMinimizedMap((prev) => (Object.assign(Object.assign({}, prev), { [info.instanceId]: false })));
|
|
55
|
+
setDurationMap((prev) => (Object.assign(Object.assign({}, prev), { [info.instanceId]: '00:00' })));
|
|
56
|
+
setPosMap((prev) => {
|
|
57
|
+
if (!(info.instanceId in prev))
|
|
58
|
+
return prev;
|
|
59
|
+
const next = Object.assign({}, prev);
|
|
60
|
+
delete next[info.instanceId];
|
|
61
|
+
return next;
|
|
62
|
+
});
|
|
63
|
+
delete startTimeRef.current[info.instanceId];
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}, [onStateChange]);
|
|
67
|
+
// Duration timer when connected
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
const timer = setInterval(() => {
|
|
70
|
+
setDurationMap((prev) => {
|
|
71
|
+
let changed = false;
|
|
72
|
+
const next = Object.assign({}, prev);
|
|
73
|
+
infos.forEach((info) => {
|
|
74
|
+
if (info.visible && info.callState === 'connected') {
|
|
75
|
+
if (!startTimeRef.current[info.instanceId]) {
|
|
76
|
+
startTimeRef.current[info.instanceId] = Date.now();
|
|
77
|
+
}
|
|
78
|
+
const diff = Math.round((Date.now() - startTimeRef.current[info.instanceId]) / 1000);
|
|
79
|
+
const text = `${pad2(Math.floor(diff / 60))}:${pad2(diff % 60)}`;
|
|
80
|
+
if (next[info.instanceId] !== text) {
|
|
81
|
+
next[info.instanceId] = text;
|
|
82
|
+
changed = true;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
else if (prev[info.instanceId] && prev[info.instanceId] !== '00:00') {
|
|
86
|
+
next[info.instanceId] = '00:00';
|
|
87
|
+
changed = true;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
return changed ? next : prev;
|
|
91
|
+
});
|
|
92
|
+
}, 1000);
|
|
93
|
+
return () => clearInterval(timer);
|
|
94
|
+
}, [infos]);
|
|
95
|
+
const visibleInfos = useMemo(() => infos.filter((i) => i.visible &&
|
|
96
|
+
!i.isPredictive &&
|
|
97
|
+
(filterInfo ? filterInfo(i) : true)), [infos, filterInfo]);
|
|
98
|
+
const rootStyle = useMemo(() => {
|
|
99
|
+
const s = Object.assign({}, cssVars);
|
|
100
|
+
if (zIndex != null)
|
|
101
|
+
s['--wro-modal-z'] = String(zIndex);
|
|
102
|
+
return s;
|
|
103
|
+
}, [cssVars, zIndex]);
|
|
104
|
+
const stateText = useCallback((state) => {
|
|
105
|
+
switch (state) {
|
|
106
|
+
case 'calling':
|
|
107
|
+
return t('calling', 'Calling...');
|
|
108
|
+
case 'connected':
|
|
109
|
+
return t('connected', 'In call');
|
|
110
|
+
case 'ended':
|
|
111
|
+
return t('ended', 'Call ended');
|
|
112
|
+
case 'failed':
|
|
113
|
+
return t('failed', 'Call failed');
|
|
114
|
+
case 'waiting':
|
|
115
|
+
return t('waiting', 'Waiting...');
|
|
116
|
+
case 'timeout':
|
|
117
|
+
return t('timeout', 'Call timeout');
|
|
118
|
+
default:
|
|
119
|
+
return state;
|
|
120
|
+
}
|
|
121
|
+
}, [t]);
|
|
122
|
+
const hangup = useCallback((info) => {
|
|
123
|
+
const instance = webRTCServiceManager.getInstance(undefined, info.providerType, info.reviewerId);
|
|
124
|
+
instance === null || instance === void 0 ? void 0 : instance.hangup();
|
|
125
|
+
// Failed / timeout UI must close even if provider had nothing left to hang up
|
|
126
|
+
if (info.callState === 'failed' ||
|
|
127
|
+
info.callState === 'timeout' ||
|
|
128
|
+
info.callState === 'ended') {
|
|
129
|
+
setCallInfo(info.instanceId, {
|
|
130
|
+
providerType: info.providerType,
|
|
131
|
+
reviewerId: info.reviewerId,
|
|
132
|
+
visible: false,
|
|
133
|
+
callState: 'ended',
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
}, []);
|
|
137
|
+
const toggleMute = useCallback((info) => {
|
|
138
|
+
const instance = webRTCServiceManager.getInstance(undefined, info.providerType, info.reviewerId);
|
|
139
|
+
if (!instance)
|
|
140
|
+
return;
|
|
141
|
+
setMutedMap((prev) => {
|
|
142
|
+
const muted = !prev[info.instanceId];
|
|
143
|
+
if (muted)
|
|
144
|
+
instance.hold();
|
|
145
|
+
else
|
|
146
|
+
instance.unhold();
|
|
147
|
+
return Object.assign(Object.assign({}, prev), { [info.instanceId]: muted });
|
|
148
|
+
});
|
|
149
|
+
}, []);
|
|
150
|
+
const onDragStart = useCallback((e, id, isMini = false) => {
|
|
151
|
+
// Interactive controls: don't start drag (hangup / mute / minimize)
|
|
152
|
+
const target = e.target;
|
|
153
|
+
if (target.closest('button'))
|
|
154
|
+
return;
|
|
155
|
+
e.preventDefault();
|
|
156
|
+
const el = e.currentTarget;
|
|
157
|
+
const rect = el.getBoundingClientRect();
|
|
158
|
+
// Pin left/top immediately so dropping CSS `right` doesn't make the card jump
|
|
159
|
+
el.style.left = `${rect.left}px`;
|
|
160
|
+
el.style.top = `${rect.top}px`;
|
|
161
|
+
el.style.right = 'auto';
|
|
162
|
+
dragRef.current = {
|
|
163
|
+
id,
|
|
164
|
+
el,
|
|
165
|
+
startClientX: e.clientX,
|
|
166
|
+
startClientY: e.clientY,
|
|
167
|
+
originX: rect.left,
|
|
168
|
+
originY: rect.top,
|
|
169
|
+
moved: false,
|
|
170
|
+
isMini,
|
|
171
|
+
};
|
|
172
|
+
const onMove = (ev) => {
|
|
173
|
+
const d = dragRef.current;
|
|
174
|
+
if (!d)
|
|
175
|
+
return;
|
|
176
|
+
const dx = ev.clientX - d.startClientX;
|
|
177
|
+
const dy = ev.clientY - d.startClientY;
|
|
178
|
+
// Ignore tiny movement — plain click must not "drag"
|
|
179
|
+
if (!d.moved && Math.hypot(dx, dy) < 5)
|
|
180
|
+
return;
|
|
181
|
+
d.moved = true;
|
|
182
|
+
d.el.classList.add('is-dragging');
|
|
183
|
+
const maxX = Math.max(0, window.innerWidth - d.el.offsetWidth);
|
|
184
|
+
const maxY = Math.max(0, window.innerHeight - d.el.offsetHeight);
|
|
185
|
+
const x = Math.max(0, Math.min(d.originX + dx, maxX));
|
|
186
|
+
const y = Math.max(0, Math.min(d.originY + dy, maxY));
|
|
187
|
+
d.el.style.left = `${x}px`;
|
|
188
|
+
d.el.style.top = `${y}px`;
|
|
189
|
+
};
|
|
190
|
+
const onUp = () => {
|
|
191
|
+
const d = dragRef.current;
|
|
192
|
+
document.removeEventListener('mousemove', onMove);
|
|
193
|
+
document.removeEventListener('mouseup', onUp);
|
|
194
|
+
dragRef.current = null;
|
|
195
|
+
if (!d)
|
|
196
|
+
return;
|
|
197
|
+
d.el.classList.remove('is-dragging');
|
|
198
|
+
if (d.moved) {
|
|
199
|
+
const left = parseFloat(d.el.style.left) || d.originX;
|
|
200
|
+
const top = parseFloat(d.el.style.top) || d.originY;
|
|
201
|
+
setPosMap((prev) => (Object.assign(Object.assign({}, prev), { [d.id]: { x: left, y: top } })));
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
// Mini card: click without drag → restore
|
|
205
|
+
if (d.isMini) {
|
|
206
|
+
setMinimizedMap((prev) => (Object.assign(Object.assign({}, prev), { [d.id]: false })));
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
document.addEventListener('mousemove', onMove);
|
|
210
|
+
document.addEventListener('mouseup', onUp);
|
|
211
|
+
}, []);
|
|
212
|
+
if (visibleInfos.length === 0)
|
|
213
|
+
return null;
|
|
214
|
+
return (React.createElement("div", { className: "wro-root", style: rootStyle }, visibleInfos.map((info) => {
|
|
215
|
+
const muted = !!mutedMap[info.instanceId];
|
|
216
|
+
const minimized = !!minimizedMap[info.instanceId];
|
|
217
|
+
const canHangup = !(info.callState === 'calling' && info.canHangup === false);
|
|
218
|
+
const name = info.customerName || t('customer', 'Customer');
|
|
219
|
+
const avatar = name.trim().charAt(0).toUpperCase() || '?';
|
|
220
|
+
const pos = posMap[info.instanceId];
|
|
221
|
+
const floatStyle = pos
|
|
222
|
+
? { left: pos.x, top: pos.y, right: 'auto' }
|
|
223
|
+
: undefined;
|
|
224
|
+
if (renderContent) {
|
|
225
|
+
return (React.createElement("div", { key: info.instanceId, className: "wro-call-host" }, renderContent({
|
|
226
|
+
info,
|
|
227
|
+
muted,
|
|
228
|
+
canHangup,
|
|
229
|
+
hangup: () => hangup(info),
|
|
230
|
+
toggleMute: () => toggleMute(info),
|
|
231
|
+
stateText: stateText(info.callState),
|
|
232
|
+
})));
|
|
233
|
+
}
|
|
234
|
+
if (minimized) {
|
|
235
|
+
return (React.createElement("div", { key: info.instanceId, className: "wro-call-mini", style: floatStyle, onMouseDown: (e) => onDragStart(e, info.instanceId, true), role: "button", tabIndex: 0 },
|
|
236
|
+
React.createElement("div", { className: "wro-call-mini__name" }, name),
|
|
237
|
+
info.callState === 'connected' ? (React.createElement("div", { className: "wro-call-mini__duration" }, durationMap[info.instanceId] || '00:00')) : (React.createElement("div", { className: "wro-call-mini__status" }, stateText(info.callState)))));
|
|
238
|
+
}
|
|
239
|
+
const avatarClass = [
|
|
240
|
+
'wro-call__avatar',
|
|
241
|
+
info.callState === 'calling' || info.callState === 'waiting' ? 'is-calling' : '',
|
|
242
|
+
info.callState === 'connected' ? 'is-connected' : '',
|
|
243
|
+
info.callState === 'failed' || info.callState === 'timeout' ? 'is-failed' : '',
|
|
244
|
+
info.callState === 'ended' ? 'is-ended' : '',
|
|
245
|
+
]
|
|
246
|
+
.filter(Boolean)
|
|
247
|
+
.join(' ');
|
|
248
|
+
return (React.createElement("div", { key: info.instanceId, className: ['wro-call', className].filter(Boolean).join(' '), style: Object.assign(Object.assign({}, style), floatStyle), role: "dialog", "aria-modal": "false", onMouseDown: (e) => onDragStart(e, info.instanceId, false) },
|
|
249
|
+
showMinimize && (React.createElement("button", { type: "button", className: "wro-call__minimize", title: t('minimize', 'Minimize'), "aria-label": t('minimize', 'Minimize'), onClick: () => setMinimizedMap((prev) => (Object.assign(Object.assign({}, prev), { [info.instanceId]: true }))) },
|
|
250
|
+
React.createElement(IconMinus, null))),
|
|
251
|
+
React.createElement("div", { className: avatarClass, "aria-hidden": true }, avatar),
|
|
252
|
+
React.createElement("div", { className: "wro-call__name", title: name }, name),
|
|
253
|
+
React.createElement("div", { className: "wro-call__status" }, info.callState === 'connected' ? (React.createElement("span", { className: "wro-call__duration" }, durationMap[info.instanceId] || '00:00')) : (React.createElement("span", { className: [
|
|
254
|
+
'wro-call__state',
|
|
255
|
+
info.callState === 'calling' || info.callState === 'waiting'
|
|
256
|
+
? 'is-calling'
|
|
257
|
+
: '',
|
|
258
|
+
info.callState === 'failed' ? 'is-failed' : '',
|
|
259
|
+
info.callState === 'timeout' ? 'is-timeout' : '',
|
|
260
|
+
info.callState === 'ended' ? 'is-ended' : '',
|
|
261
|
+
]
|
|
262
|
+
.filter(Boolean)
|
|
263
|
+
.join(' ') }, stateText(info.callState)))),
|
|
264
|
+
info.callState !== 'ended' && (React.createElement("div", { className: "wro-call__actions" },
|
|
265
|
+
showMute && info.callState === 'connected' && (React.createElement("div", { className: "wro-call__action" },
|
|
266
|
+
React.createElement("button", { type: "button", className: ['wro-call__circle', muted ? 'is-muted' : 'is-unmuted'].join(' '), onClick: () => toggleMute(info) },
|
|
267
|
+
React.createElement(IconMic, { muted: muted })),
|
|
268
|
+
React.createElement("span", { className: "wro-call__label" }, muted ? t('unmute', 'Unmute') : t('mute', 'Mute')))),
|
|
269
|
+
React.createElement("div", { className: "wro-call__action" },
|
|
270
|
+
React.createElement("button", { type: "button", className: "wro-call__circle is-hangup", disabled: !canHangup, onClick: () => hangup(info) },
|
|
271
|
+
React.createElement("span", { className: "wro-call__hangup-icon" },
|
|
272
|
+
React.createElement(IconPhone, null))),
|
|
273
|
+
React.createElement("span", { className: "wro-call__label" }, info.callState === 'timeout' || info.callState === 'failed'
|
|
274
|
+
? t('close', 'Close')
|
|
275
|
+
: t('hangup', 'Hang up')))))));
|
|
276
|
+
})));
|
|
277
|
+
};
|
|
278
|
+
export default OutboundCallModal;
|
|
279
|
+
//# sourceMappingURL=OutboundCallModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OutboundCallModal.js","sourceRoot":"","sources":["../src/OutboundCallModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjF,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,eAAe,EACf,WAAW,GACZ,MAAM,qBAAqB,CAAC;AA+C7B,SAAS,MAAM,CAAC,IAAY,EAAE,QAAgB;;IAC5C,OAAO,CAAA,MAAA,eAAe,EAAE,0CAAE,MAAM,CAAC,QAAQ,CAAC,UAAU,IAAI,EAAE,CAAC,KAAI,QAAQ,CAAC;AAC1E,CAAC;AAED,SAAS,SAAS;IAChB,OAAO,CACL,6BAAK,KAAK,EAA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AI,CACrE,GAAG,CACJ,EACD,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC;wBAE/B,oBAAC,OAAO,IAAC,KAAK,EAAE,KAAK,GAAI,CAClB;oBACT,8BAAM,SAAS,EAAC,iBAAiB,IAC9B,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAC7C,CACH,CACP;gBACD,6BAAK,SAAS,EAAC,kBAAkB;oBAC/B,gCACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,4BAA4B,EACtC,QAAQ,EAAE,CAAC,SAAS,EACpB,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC;wBAE3B,8BAAM,SAAS,EAAC,uBAAuB;4BACrC,oBAAC,SAAS,OAAG,CACR,CACA;oBACT,8BAAM,SAAS,EAAC,iBAAiB,IAC9B,IAAI,CAAC,SAAS,KAAK,SAAS,IAAI,IAAI,CAAC,SAAS,KAAK,QAAQ;wBAC1D,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC;wBACrB,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,SAAS,CAAC,CACrB,CACH,CACF,CACP,CACG,CACP,CAAC;IACJ,CAAC,CAAC,CACE,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ensure global call modal is mounted (idempotent).
|
|
3
|
+
* Called automatically by OutboundCallButton.
|
|
4
|
+
*/
|
|
5
|
+
export declare function ensureOutboundCallModalHost(): void;
|
|
6
|
+
/** Unmount global modal host (rarely needed; e.g. tests / logout). */
|
|
7
|
+
export declare function destroyOutboundCallModalHost(): void;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lazily mount a single global OutboundCallModal for all OutboundCallButton instances.
|
|
3
|
+
* Host only needs: createWebRTCKit(...) + <OutboundCallButton />.
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import ReactDOM from 'react-dom';
|
|
7
|
+
import { OutboundCallModal } from './OutboundCallModal';
|
|
8
|
+
import { tryGetActiveKit } from '@yinshan-tech/webrtc-sdk';
|
|
9
|
+
const HOST_ID = 'wro-react-call-modal-host';
|
|
10
|
+
let mounted = false;
|
|
11
|
+
function injectStylesOnce() {
|
|
12
|
+
if (typeof document === 'undefined')
|
|
13
|
+
return;
|
|
14
|
+
// Always refresh stylesheet content so UI tweaks apply after rebuild
|
|
15
|
+
let style = document.getElementById('wro-outbound-styles');
|
|
16
|
+
if (!style) {
|
|
17
|
+
style = document.createElement('style');
|
|
18
|
+
style.id = 'wro-outbound-styles';
|
|
19
|
+
document.head.appendChild(style);
|
|
20
|
+
}
|
|
21
|
+
// Prefer built css if available via side-effect import path; fallback inline snapshot
|
|
22
|
+
style.textContent = `
|
|
23
|
+
.wro-root{--wro-btn-bg:#ef4444;--wro-btn-color:#fff;--wro-btn-radius:8px;--wro-btn-padding:6px 14px;--wro-btn-font-size:14px;--wro-modal-z:1000;font-family:system-ui,-apple-system,'Segoe UI',Roboto,sans-serif}
|
|
24
|
+
.wro-btn{background:var(--wro-btn-bg);color:var(--wro-btn-color);border:none;border-radius:var(--wro-btn-radius);padding:var(--wro-btn-padding);font-size:var(--wro-btn-font-size);cursor:pointer}
|
|
25
|
+
.wro-btn:disabled{opacity:.55;cursor:not-allowed}
|
|
26
|
+
.wro-call{position:fixed;top:20px;right:20px;z-index:var(--wro-modal-z);width:320px;padding:20px 24px 28px;background:linear-gradient(180deg,#f8fafc 0%,#fff 42%);color:#0f172a;border-radius:20px;box-shadow:0 12px 40px rgba(15,23,42,.16),0 2px 8px rgba(15,23,42,.06);text-align:center;cursor:grab;user-select:none}
|
|
27
|
+
.wro-call.is-dragging{cursor:grabbing}
|
|
28
|
+
.wro-call button{cursor:pointer}
|
|
29
|
+
.wro-call__minimize{position:absolute;top:10px;right:10px;display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:0;color:rgba(0,0,0,.45);background:transparent;border:none;border-radius:8px;cursor:pointer}
|
|
30
|
+
.wro-call__minimize:hover{color:rgba(0,0,0,.85);background:rgba(0,0,0,.06)}
|
|
31
|
+
.wro-call__avatar{position:relative;display:flex;align-items:center;justify-content:center;width:72px;height:72px;margin:8px auto 16px;color:#fff;font-weight:600;font-size:28px;background:linear-gradient(145deg,#3b82f6,#1d4ed8);border-radius:50%;box-shadow:0 8px 20px rgba(37,99,235,.28)}
|
|
32
|
+
.wro-call__avatar.is-calling::after{position:absolute;inset:-6px;border:2px solid rgba(59,130,246,.45);border-radius:50%;animation:wro-ring 1.6s ease-out infinite;content:''}
|
|
33
|
+
.wro-call__avatar.is-connected{background:linear-gradient(145deg,#22c55e,#15803d);box-shadow:0 8px 20px rgba(34,197,94,.28)}
|
|
34
|
+
.wro-call__avatar.is-failed{background:linear-gradient(145deg,#f87171,#dc2626);box-shadow:0 8px 20px rgba(239,68,68,.28)}
|
|
35
|
+
.wro-call__avatar.is-ended{background:linear-gradient(145deg,#94a3b8,#64748b);box-shadow:none}
|
|
36
|
+
.wro-call__name{max-width:100%;margin-bottom:8px;overflow:hidden;font-weight:600;font-size:20px;line-height:1.3;white-space:nowrap;text-overflow:ellipsis}
|
|
37
|
+
.wro-call__status{display:flex;align-items:center;justify-content:center;min-height:36px;margin-bottom:8px}
|
|
38
|
+
.wro-call__state{font-size:14px;color:#64748b}
|
|
39
|
+
.wro-call__state.is-calling{color:#2563eb;animation:wro-blink 1.5s ease-in-out infinite}
|
|
40
|
+
.wro-call__state.is-failed{color:#dc2626}
|
|
41
|
+
.wro-call__state.is-timeout{color:#d97706}
|
|
42
|
+
.wro-call__duration{color:#16a34a;font-weight:700;font-size:28px;font-variant-numeric:tabular-nums;letter-spacing:1px}
|
|
43
|
+
.wro-call__actions{display:flex;gap:28px;justify-content:center;margin-top:16px;cursor:grab}
|
|
44
|
+
.wro-call__action{display:flex;flex-direction:column;gap:8px;align-items:center}
|
|
45
|
+
.wro-call__circle{display:inline-flex;align-items:center;justify-content:center;width:56px;height:56px;padding:0;color:#fff;border:none;border-radius:50%;box-shadow:0 6px 14px rgba(15,23,42,.12);cursor:pointer}
|
|
46
|
+
.wro-call__circle:disabled{background:#fecaca!important;box-shadow:none;cursor:not-allowed}
|
|
47
|
+
.wro-call__circle.is-unmuted{background:#16a34a}
|
|
48
|
+
.wro-call__circle.is-muted{background:#dc2626}
|
|
49
|
+
.wro-call__circle.is-hangup{background:#ef4444}
|
|
50
|
+
.wro-call__hangup-icon{display:inline-flex;transform:rotate(135deg)}
|
|
51
|
+
.wro-call__label{color:#475569;font-size:13px;line-height:1}
|
|
52
|
+
.wro-call-mini{position:fixed;top:20px;right:20px;z-index:var(--wro-modal-z);display:flex;flex-direction:column;gap:4px;width:220px;min-height:64px;padding:12px 14px;background:#fff;border:1px solid #e2e8f0;border-radius:12px;box-shadow:0 8px 24px rgba(15,23,42,.12);cursor:grab;user-select:none}
|
|
53
|
+
.wro-call-mini.is-dragging{cursor:grabbing}
|
|
54
|
+
.wro-call-mini__name{overflow:hidden;color:#0f172a;font-weight:600;font-size:14px;white-space:nowrap;text-overflow:ellipsis}
|
|
55
|
+
.wro-call-mini__duration{color:#16a34a;font-weight:700;font-size:16px}
|
|
56
|
+
.wro-call-mini__status{color:#2563eb;font-size:12px}
|
|
57
|
+
@keyframes wro-blink{0%,100%{opacity:1}50%{opacity:.45}}
|
|
58
|
+
@keyframes wro-ring{0%{transform:scale(.92);opacity:.7}100%{transform:scale(1.18);opacity:0}}
|
|
59
|
+
`;
|
|
60
|
+
}
|
|
61
|
+
function resolveModalProps() {
|
|
62
|
+
var _a, _b, _c, _d, _e, _f;
|
|
63
|
+
try {
|
|
64
|
+
const ui = (_b = (_a = tryGetActiveKit()) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.ui;
|
|
65
|
+
return {
|
|
66
|
+
className: (_c = ui === null || ui === void 0 ? void 0 : ui.modal) === null || _c === void 0 ? void 0 : _c.className,
|
|
67
|
+
style: (_d = ui === null || ui === void 0 ? void 0 : ui.modal) === null || _d === void 0 ? void 0 : _d.style,
|
|
68
|
+
cssVars: (_e = ui === null || ui === void 0 ? void 0 : ui.modal) === null || _e === void 0 ? void 0 : _e.cssVars,
|
|
69
|
+
zIndex: (_f = ui === null || ui === void 0 ? void 0 : ui.modal) === null || _f === void 0 ? void 0 : _f.zIndex,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
catch (_g) {
|
|
73
|
+
return {};
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Ensure global call modal is mounted (idempotent).
|
|
78
|
+
* Called automatically by OutboundCallButton.
|
|
79
|
+
*/
|
|
80
|
+
export function ensureOutboundCallModalHost() {
|
|
81
|
+
if (typeof document === 'undefined' || mounted)
|
|
82
|
+
return;
|
|
83
|
+
injectStylesOnce();
|
|
84
|
+
let host = document.getElementById(HOST_ID);
|
|
85
|
+
if (!host) {
|
|
86
|
+
host = document.createElement('div');
|
|
87
|
+
host.id = HOST_ID;
|
|
88
|
+
document.body.appendChild(host);
|
|
89
|
+
}
|
|
90
|
+
ReactDOM.render(React.createElement(OutboundCallModal, resolveModalProps()), host);
|
|
91
|
+
mounted = true;
|
|
92
|
+
}
|
|
93
|
+
/** Unmount global modal host (rarely needed; e.g. tests / logout). */
|
|
94
|
+
export function destroyOutboundCallModalHost() {
|
|
95
|
+
if (typeof document === 'undefined')
|
|
96
|
+
return;
|
|
97
|
+
const host = document.getElementById(HOST_ID);
|
|
98
|
+
if (host) {
|
|
99
|
+
ReactDOM.unmountComponentAtNode(host);
|
|
100
|
+
host.remove();
|
|
101
|
+
}
|
|
102
|
+
mounted = false;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=ensureCallModalHost.js.map
|
|
@@ -0,0 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E,aAAF,EAAE,uBAAF,EAAE,CAAE,KAAK,0CAAE,MAAM;SAC1B,CAAC;KACH;IAAC,WAAM;QACN,OAAO,EAAE,CAAC;KACX;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,2BAA2B;IACzC,IAAI,OAAO,QAAQ,KAAK,WAAW,IAAI,OAAO;QAAE,OAAO;IAEvD,gBAAgB,EAAE,CAAC;IAEnB,IAAI,IAAI,GAAG,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAC5C,IAAI,CAAC,IAAI,EAAE;QACT,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACrC,IAAI,CAAC,EAAE,GAAG,OAAO,CAAC;QAClB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;KACjC;IAED,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,iBAAiB,EAAE,iBAAiB,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;IACnF,OAAO,GAAG,IAAI,CAAC;AACjB,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,4BAA4B;IAC1C,IAAI,OAAO,QAAQ,KAAK,WAAW;QAAE,OAAO;IAC5C,MAAM,IAAI,GAAG,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAC9C,IAAI,IAAI,EAAE;QACR,QAAQ,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC;QACtC,IAAI,CAAC,MAAM,EAAE,CAAC;KACf;IACD,OAAO,GAAG,KAAK,CAAC;AAClB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @yinshan-tech/webrtc-react
|
|
3
|
+
* React UI (no antd) on top of @yinshan-tech/webrtc-sdk.
|
|
4
|
+
*
|
|
5
|
+
* Typical usage:
|
|
6
|
+
* createWebRTCKit({...}) // once, from @yinshan-tech/webrtc-sdk
|
|
7
|
+
* <OutboundCallButton {...params}/> // global call modal auto-mounts
|
|
8
|
+
*/
|
|
9
|
+
export { OutboundCallButton } from './OutboundCallButton';
|
|
10
|
+
export type { OutboundCallButtonProps, OutboundCallButtonRenderProps, } from './OutboundCallButton';
|
|
11
|
+
export { OutboundCallModal } from './OutboundCallModal';
|
|
12
|
+
export type { OutboundCallModalProps, OutboundCallModalTexts, OutboundCallModalRenderProps, } from './OutboundCallModal';
|
|
13
|
+
export { ensureOutboundCallModalHost, destroyOutboundCallModalHost, } from './ensureCallModalHost';
|
|
14
|
+
export { useWebRTCInitialization } from './useWebRTCInitialization';
|
|
15
|
+
export type { UseWebRTCInitializationOptions } from './useWebRTCInitialization';
|
|
16
|
+
export { startOutboundCall, subscribeCallState, getAllCallInfo } from '@yinshan-tech/webrtc-sdk';
|
|
17
|
+
export type { OutboundCallParams, OutboundCallNotify, StartOutboundCallResult, CallInfo, } from '@yinshan-tech/webrtc-sdk';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @yinshan-tech/webrtc-react
|
|
3
|
+
* React UI (no antd) on top of @yinshan-tech/webrtc-sdk.
|
|
4
|
+
*
|
|
5
|
+
* Typical usage:
|
|
6
|
+
* createWebRTCKit({...}) // once, from @yinshan-tech/webrtc-sdk
|
|
7
|
+
* <OutboundCallButton {...params}/> // global call modal auto-mounts
|
|
8
|
+
*/
|
|
9
|
+
export { OutboundCallButton } from './OutboundCallButton';
|
|
10
|
+
export { OutboundCallModal } from './OutboundCallModal';
|
|
11
|
+
export { ensureOutboundCallModalHost, destroyOutboundCallModalHost, } from './ensureCallModalHost';
|
|
12
|
+
export { useWebRTCInitialization } from './useWebRTCInitialization';
|
|
13
|
+
// Convenience re-exports so UI callers rarely need the sdk package directly
|
|
14
|
+
export { startOutboundCall, subscribeCallState, getAllCallInfo } from '@yinshan-tech/webrtc-sdk';
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAM1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAOxD,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,GAC7B,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAGpE,4EAA4E;AAC5E,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/styles.css
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
/* @yinshan-tech/webrtc-react — override via CSS variables / className */
|
|
2
|
+
|
|
3
|
+
.wro-root {
|
|
4
|
+
--wro-btn-bg: #ef4444;
|
|
5
|
+
--wro-btn-color: #fff;
|
|
6
|
+
--wro-btn-radius: 8px;
|
|
7
|
+
--wro-btn-padding: 6px 14px;
|
|
8
|
+
--wro-btn-font-size: 14px;
|
|
9
|
+
--wro-modal-z: 1000;
|
|
10
|
+
font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.wro-btn {
|
|
14
|
+
background: var(--wro-btn-bg);
|
|
15
|
+
color: var(--wro-btn-color);
|
|
16
|
+
border: none;
|
|
17
|
+
border-radius: var(--wro-btn-radius);
|
|
18
|
+
padding: var(--wro-btn-padding);
|
|
19
|
+
font-size: var(--wro-btn-font-size);
|
|
20
|
+
cursor: pointer;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.wro-btn:disabled {
|
|
24
|
+
opacity: 0.55;
|
|
25
|
+
cursor: not-allowed;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/* Floating call card (no full-screen mask) */
|
|
29
|
+
.wro-call {
|
|
30
|
+
position: fixed;
|
|
31
|
+
top: 20px;
|
|
32
|
+
right: 20px;
|
|
33
|
+
z-index: var(--wro-modal-z);
|
|
34
|
+
width: 320px;
|
|
35
|
+
padding: 20px 24px 28px;
|
|
36
|
+
background: linear-gradient(180deg, #f8fafc 0%, #ffffff 42%);
|
|
37
|
+
color: #0f172a;
|
|
38
|
+
border-radius: 20px;
|
|
39
|
+
box-shadow: 0 12px 40px rgba(15, 23, 42, 0.16), 0 2px 8px rgba(15, 23, 42, 0.06);
|
|
40
|
+
text-align: center;
|
|
41
|
+
cursor: grab;
|
|
42
|
+
user-select: none;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.wro-call.is-dragging {
|
|
46
|
+
cursor: grabbing;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.wro-call button {
|
|
50
|
+
cursor: pointer;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.wro-call__minimize {
|
|
54
|
+
position: absolute;
|
|
55
|
+
top: 10px;
|
|
56
|
+
right: 10px;
|
|
57
|
+
display: inline-flex;
|
|
58
|
+
align-items: center;
|
|
59
|
+
justify-content: center;
|
|
60
|
+
width: 28px;
|
|
61
|
+
height: 28px;
|
|
62
|
+
padding: 0;
|
|
63
|
+
color: rgba(0, 0, 0, 0.45);
|
|
64
|
+
background: transparent;
|
|
65
|
+
border: none;
|
|
66
|
+
border-radius: 8px;
|
|
67
|
+
cursor: pointer;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.wro-call__minimize:hover {
|
|
71
|
+
color: rgba(0, 0, 0, 0.85);
|
|
72
|
+
background: rgba(0, 0, 0, 0.06);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.wro-call__avatar {
|
|
76
|
+
position: relative;
|
|
77
|
+
display: flex;
|
|
78
|
+
align-items: center;
|
|
79
|
+
justify-content: center;
|
|
80
|
+
width: 72px;
|
|
81
|
+
height: 72px;
|
|
82
|
+
margin: 8px auto 16px;
|
|
83
|
+
color: #fff;
|
|
84
|
+
font-weight: 600;
|
|
85
|
+
font-size: 28px;
|
|
86
|
+
background: linear-gradient(145deg, #3b82f6 0%, #1d4ed8 100%);
|
|
87
|
+
border-radius: 50%;
|
|
88
|
+
box-shadow: 0 8px 20px rgba(37, 99, 235, 0.28);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.wro-call__avatar.is-calling::after {
|
|
92
|
+
position: absolute;
|
|
93
|
+
inset: -6px;
|
|
94
|
+
border: 2px solid rgba(59, 130, 246, 0.45);
|
|
95
|
+
border-radius: 50%;
|
|
96
|
+
animation: wro-ring 1.6s ease-out infinite;
|
|
97
|
+
content: '';
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.wro-call__avatar.is-connected {
|
|
101
|
+
background: linear-gradient(145deg, #22c55e 0%, #15803d 100%);
|
|
102
|
+
box-shadow: 0 8px 20px rgba(34, 197, 94, 0.28);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.wro-call__avatar.is-failed {
|
|
106
|
+
background: linear-gradient(145deg, #f87171 0%, #dc2626 100%);
|
|
107
|
+
box-shadow: 0 8px 20px rgba(239, 68, 68, 0.28);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.wro-call__avatar.is-ended {
|
|
111
|
+
background: linear-gradient(145deg, #94a3b8 0%, #64748b 100%);
|
|
112
|
+
box-shadow: none;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.wro-call__name {
|
|
116
|
+
max-width: 100%;
|
|
117
|
+
margin-bottom: 8px;
|
|
118
|
+
overflow: hidden;
|
|
119
|
+
font-weight: 600;
|
|
120
|
+
font-size: 20px;
|
|
121
|
+
line-height: 1.3;
|
|
122
|
+
white-space: nowrap;
|
|
123
|
+
text-overflow: ellipsis;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.wro-call__status {
|
|
127
|
+
display: flex;
|
|
128
|
+
align-items: center;
|
|
129
|
+
justify-content: center;
|
|
130
|
+
min-height: 36px;
|
|
131
|
+
margin-bottom: 8px;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.wro-call__state {
|
|
135
|
+
font-size: 14px;
|
|
136
|
+
color: #64748b;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.wro-call__state.is-calling {
|
|
140
|
+
color: #2563eb;
|
|
141
|
+
animation: wro-blink 1.5s ease-in-out infinite;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.wro-call__state.is-failed {
|
|
145
|
+
color: #dc2626;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.wro-call__state.is-timeout {
|
|
149
|
+
color: #d97706;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.wro-call__state.is-ended {
|
|
153
|
+
color: #64748b;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.wro-call__duration {
|
|
157
|
+
color: #16a34a;
|
|
158
|
+
font-weight: 700;
|
|
159
|
+
font-size: 28px;
|
|
160
|
+
font-variant-numeric: tabular-nums;
|
|
161
|
+
letter-spacing: 1px;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.wro-call__actions {
|
|
165
|
+
display: flex;
|
|
166
|
+
gap: 28px;
|
|
167
|
+
justify-content: center;
|
|
168
|
+
margin-top: 16px;
|
|
169
|
+
cursor: grab;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.wro-call__action {
|
|
173
|
+
display: flex;
|
|
174
|
+
flex-direction: column;
|
|
175
|
+
gap: 8px;
|
|
176
|
+
align-items: center;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.wro-call__circle {
|
|
180
|
+
display: inline-flex;
|
|
181
|
+
align-items: center;
|
|
182
|
+
justify-content: center;
|
|
183
|
+
width: 56px;
|
|
184
|
+
height: 56px;
|
|
185
|
+
padding: 0;
|
|
186
|
+
color: #fff;
|
|
187
|
+
border: none;
|
|
188
|
+
border-radius: 50%;
|
|
189
|
+
box-shadow: 0 6px 14px rgba(15, 23, 42, 0.12);
|
|
190
|
+
cursor: pointer;
|
|
191
|
+
transition: transform 0.15s ease, box-shadow 0.15s ease;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.wro-call__circle:hover:not(:disabled) {
|
|
195
|
+
transform: translateY(-1px);
|
|
196
|
+
box-shadow: 0 8px 18px rgba(15, 23, 42, 0.16);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.wro-call__circle:disabled {
|
|
200
|
+
background: #fecaca !important;
|
|
201
|
+
box-shadow: none;
|
|
202
|
+
cursor: not-allowed;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.wro-call__circle.is-unmuted {
|
|
206
|
+
background: #16a34a;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.wro-call__circle.is-muted {
|
|
210
|
+
background: #dc2626;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.wro-call__circle.is-hangup {
|
|
214
|
+
background: #ef4444;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.wro-call__circle.is-hangup:hover:not(:disabled) {
|
|
218
|
+
background: #dc2626;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.wro-call__hangup-icon {
|
|
222
|
+
display: inline-flex;
|
|
223
|
+
transform: rotate(135deg);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.wro-call__label {
|
|
227
|
+
color: #475569;
|
|
228
|
+
font-size: 13px;
|
|
229
|
+
line-height: 1;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.wro-call-mini {
|
|
233
|
+
position: fixed;
|
|
234
|
+
top: 20px;
|
|
235
|
+
right: 20px;
|
|
236
|
+
z-index: var(--wro-modal-z);
|
|
237
|
+
display: flex;
|
|
238
|
+
flex-direction: column;
|
|
239
|
+
gap: 4px;
|
|
240
|
+
width: 220px;
|
|
241
|
+
min-height: 64px;
|
|
242
|
+
padding: 12px 14px;
|
|
243
|
+
background: #fff;
|
|
244
|
+
border: 1px solid #e2e8f0;
|
|
245
|
+
border-radius: 12px;
|
|
246
|
+
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
|
|
247
|
+
cursor: grab;
|
|
248
|
+
user-select: none;
|
|
249
|
+
transition: box-shadow 0.2s ease, transform 0.2s ease;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.wro-call-mini.is-dragging {
|
|
253
|
+
cursor: grabbing;
|
|
254
|
+
transition: none;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.wro-call-mini:hover {
|
|
258
|
+
box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
|
|
259
|
+
transform: translateY(-1px);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
.wro-call-mini__name {
|
|
263
|
+
overflow: hidden;
|
|
264
|
+
color: #0f172a;
|
|
265
|
+
font-weight: 600;
|
|
266
|
+
font-size: 14px;
|
|
267
|
+
white-space: nowrap;
|
|
268
|
+
text-overflow: ellipsis;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.wro-call-mini__duration {
|
|
272
|
+
color: #16a34a;
|
|
273
|
+
font-weight: 700;
|
|
274
|
+
font-size: 16px;
|
|
275
|
+
font-variant-numeric: tabular-nums;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
.wro-call-mini__status {
|
|
279
|
+
color: #2563eb;
|
|
280
|
+
font-size: 12px;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
@keyframes wro-blink {
|
|
284
|
+
0%,
|
|
285
|
+
100% {
|
|
286
|
+
opacity: 1;
|
|
287
|
+
}
|
|
288
|
+
50% {
|
|
289
|
+
opacity: 0.45;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
@keyframes wro-ring {
|
|
294
|
+
0% {
|
|
295
|
+
transform: scale(0.92);
|
|
296
|
+
opacity: 0.7;
|
|
297
|
+
}
|
|
298
|
+
100% {
|
|
299
|
+
transform: scale(1.18);
|
|
300
|
+
opacity: 0;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type InitializeWebRTCProvidersOptions } from '@yinshan-tech/webrtc-sdk';
|
|
2
|
+
export declare type UseWebRTCInitializationOptions = InitializeWebRTCProvidersOptions;
|
|
3
|
+
/**
|
|
4
|
+
* React hook: preload / register providers when entering a page.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useWebRTCInitialization(options?: UseWebRTCInitializationOptions): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { initializeWebRTCProviders, } from '@yinshan-tech/webrtc-sdk';
|
|
3
|
+
/**
|
|
4
|
+
* React hook: preload / register providers when entering a page.
|
|
5
|
+
*/
|
|
6
|
+
export function useWebRTCInitialization(options = {}) {
|
|
7
|
+
const { immediateProviders, instanceIdPrefix, onStateChange } = options;
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
void initializeWebRTCProviders({
|
|
10
|
+
immediateProviders,
|
|
11
|
+
instanceIdPrefix,
|
|
12
|
+
onStateChange,
|
|
13
|
+
});
|
|
14
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15
|
+
}, [instanceIdPrefix, (immediateProviders || []).join(',')]);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=useWebRTCInitialization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWebRTCInitialization.js","sourceRoot":"","sources":["../src/useWebRTCInitialization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EACL,yBAAyB,GAE1B,MAAM,qBAAqB,CAAC;AAI7B;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,UAA0C,EAAE;IAClF,MAAM,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IAExE,SAAS,CAAC,GAAG,EAAE;QACb,KAAK,yBAAyB,CAAC;YAC7B,kBAAkB;YAClB,gBAAgB;YAChB,aAAa;SACd,CAAC,CAAC;QACH,uDAAuD;IACzD,CAAC,EAAE,CAAC,gBAAgB,EAAE,CAAC,kBAAkB,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC/D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yinshan-tech/webrtc-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "React UI for @yinshan-tech/webrtc-sdk: OutboundCallButton, OutboundCallModal, hooks (no antd)",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -12,12 +12,13 @@
|
|
|
12
12
|
"README.md"
|
|
13
13
|
],
|
|
14
14
|
"scripts": {
|
|
15
|
-
"build": "rm -rf dist && tsc -p tsconfig.json && cp src/styles.css dist/styles.css"
|
|
15
|
+
"build": "rm -rf dist && tsc -p tsconfig.json && cp src/styles.css dist/styles.css",
|
|
16
|
+
"prepare": "node -e \"require(\\\"fs\\\").accessSync(\\\"dist/index.js\\\")\" || npm run build"
|
|
16
17
|
},
|
|
17
18
|
"peerDependencies": {
|
|
18
|
-
"@yinshan-tech/webrtc-sdk": "^0.1.0",
|
|
19
19
|
"react": ">=16.8.0",
|
|
20
|
-
"react-dom": ">=16.8.0"
|
|
20
|
+
"react-dom": ">=16.8.0",
|
|
21
|
+
"@yinshan-tech/webrtc-sdk": "^0.1.1"
|
|
21
22
|
},
|
|
22
23
|
"devDependencies": {
|
|
23
24
|
"@types/react": "^17.0.0",
|
|
@@ -30,5 +31,8 @@
|
|
|
30
31
|
"react",
|
|
31
32
|
"call-center"
|
|
32
33
|
],
|
|
33
|
-
"license": "UNLICENSED"
|
|
34
|
+
"license": "UNLICENSED",
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
}
|
|
34
38
|
}
|