@nethesis/phone-island 0.7.74 → 0.7.76
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/dist/components/AudioBars.d.ts +1 -0
- package/dist/components/AudioBars.js +1 -1
- package/dist/components/AudioBars.js.map +1 -1
- package/dist/components/CallView/index.js +1 -1
- package/dist/components/CallView/index.js.map +1 -1
- package/dist/events/CallEvents.js +1 -1
- package/dist/events/CallEvents.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");require("../node_modules/react-redux/es/index.js");var r=require("../store/index.js"),t=require("../node_modules/react-redux/es/hooks/useDispatch.js");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=n(e),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");require("../node_modules/react-redux/es/index.js");var r=require("../store/index.js"),t=require("../node_modules/react-redux/es/hooks/useDispatch.js");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=n(e),a={0:4,1:3,2:2,3:1,4:1,5:2,6:3,7:4},i={0:2,1:1,2:1,3:2};exports.AudioBars=function(n){var c=n.audioStream,o=void 0===c?null:c,s=n.audioElement,l=void 0===s?null:s,d=n.paused,f=n.size,m=e.useRef(null),p=e.useRef(null),v="large"===f?a:i,y=e.useRef(null),h=e.useRef(null),A=e.useRef(null),E=t.useDispatch();function x(){var e,r=requestAnimationFrame(j);(e=r)&&(p.current=e)}function j(){var e;if(h&&h.current){var r=new Uint8Array(h.current.frequencyBinCount);h.current.getByteFrequencyData(r);var t=Object.values(r),n=null===(e=m.current)||void 0===e?void 0:e.children;if(n&&(null==n?void 0:n.length)>0){for(var u=0;u<Object.keys(v).length;++u){var a=t[v[u]]/255,i=n&&n[u]&&n[u].style;i&&a>0&&(i.height="".concat(100*a,"%"))}x()}}}return e.useEffect((function(){var e=r.store.getState().audioBars,t=e.audioElementContext,n=e.audioElementAnalyser,u=e.audioElementSource,a=e.isReady;return l&&a?(y.current=t,h.current=n,A.current=u):(y.current=new AudioContext,h.current=y.current.createAnalyser(),h.current.smoothingTimeConstant=.8,h.current.fftSize=32,o?A.current=y.current.createMediaStreamSource(o):l&&(A.current=y.current.createMediaElementSource(l),E.audioBars.setAudioElementContext(y.current),E.audioBars.setAudioElementAnalyser(h.current),E.audioBars.setAudioElementSource(A.current),E.audioBars.setIsReady(!0))),h.current&&A.current&&A.current.connect(h.current),x(),function(){var e;p.current&&cancelAnimationFrame(p.current),null===(e=A.current)||void 0===e||e.disconnect()}}),[]),e.useEffect((function(){p.current&&(d?cancelAnimationFrame(p.current):(cancelAnimationFrame(p.current),x()))}),[f,d]),u.default.createElement("div",{className:"".concat("small"===f?"pi-h-6 pi-w-6":"pi-h-12 pi-w-12"," pi-flex pi-justify-center pi-items-center")},u.default.createElement("div",{className:"".concat("small"===f?"pi-h-6":"pi-h-8"," pi-w-fit pi-flex pi-justify-center pi-items-center pi-gap-1 pi-overflow-hidden"),ref:m},(o||l)&&Object.keys(v).map((function(e){return u.default.createElement("span",{key:e,className:"pi-bg-emerald-600 pi-w-0.5 pi-rounded-sm"})}))))};
|
|
2
2
|
//# sourceMappingURL=AudioBars.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AudioBars.js","sources":["../../src/components/AudioBars.tsx"],"sourcesContent":["// Copyright (C) 2022 Nethesis S.r.l.\n// SPDX-License-Identifier: AGPL-3.0-or-later\n\nimport React, { type FC, useEffect, useRef } from 'react'\nimport { ContextSourceType } from '../models/audioBars'\nimport { useDispatch } from 'react-redux'\nimport { store } from '../store'\nimport { Dispatch } from '../store'\n\nconst large = {\n 0: 4,\n 1: 3,\n 2: 2,\n 3: 1,\n 4: 1,\n 5: 2,\n 6: 3,\n 7: 4,\n}\n\nconst small = {\n 0: 2,\n 1: 1,\n 2: 1,\n 3: 2,\n}\n\n/**\n * This component shows a dynamic audio spectrum given an audio stream\n *\n * @param audioStream An audio stream to analyse\n * @param audioElement An audio element to analyse\n */\nexport const AudioBars: FC<AudioBarsProps> = ({\n audioStream = null,\n audioElement = null,\n size,\n}) => {\n // Initialize the main elements\n const containerElement = useRef<HTMLDivElement | null>(null)\n const animationRequest = useRef<number | null>(null)\n const barsMap: BarsMapType = size === 'large' ? large : small\n const context = useRef<AudioContext | null>(null)\n const analyser = useRef<AnalyserNode | null>(null)\n const source = useRef<ContextSourceType>(null)\n const dispatch = useDispatch<Dispatch>()\n\n function saveAnimationRequest(requestId: number) {\n if (requestId) {\n animationRequest.current = requestId\n }\n }\n\n function startAnimation() {\n const animationRequestId: number = requestAnimationFrame(animationFrame)\n saveAnimationRequest(animationRequestId)\n }\n\n // The function that renders the frames of animation\n function animationFrame() {\n if (analyser && analyser.current) {\n const frequencyData = new Uint8Array(analyser.current.frequencyBinCount)\n analyser.current.getByteFrequencyData(frequencyData)\n const values = Object.values(frequencyData)\n\n const bars = containerElement.current?.children\n if (bars && bars?.length > 0) {\n // Change styles to every bar\n for (let i = 0; i < Object.keys(barsMap).length; ++i) {\n const value = values[barsMap[i]] / 255\n // @ts-ignore\n const barStyles = bars && bars[i] && bars[i].style\n if (barStyles && value > 0) {\n barStyles.height = `${100 * value}%`\n }\n }\n startAnimation()\n }\n }\n }\n\n useEffect(() => {\n const { audioElementContext, audioElementAnalyser, audioElementSource, isReady } =\n store.getState().audioBars\n // Initialize audio context and analyser once\n if (audioElement && isReady) {\n // The source is an audio element\n context.current = audioElementContext\n analyser.current = audioElementAnalyser\n source.current = audioElementSource\n } else {\n // The source is an audio stream\n context.current = new AudioContext()\n analyser.current = context.current.createAnalyser()\n analyser.current.smoothingTimeConstant = 0.8\n analyser.current.fftSize = 32\n // Create the media source stream\n if (audioStream) {\n source.current = context.current.createMediaStreamSource(audioStream)\n } else if (audioElement) {\n source.current = context.current.createMediaElementSource(audioElement)\n // Save the audio elements to stores\n dispatch.audioBars.setAudioElementContext(context.current)\n dispatch.audioBars.setAudioElementAnalyser(analyser.current)\n dispatch.audioBars.setAudioElementSource(source.current)\n dispatch.audioBars.setIsReady(true)\n }\n }\n\n // Connect the audio source to the analyser\n analyser.current && source.current && source.current.connect(analyser.current)\n
|
|
1
|
+
{"version":3,"file":"AudioBars.js","sources":["../../src/components/AudioBars.tsx"],"sourcesContent":["// Copyright (C) 2022 Nethesis S.r.l.\n// SPDX-License-Identifier: AGPL-3.0-or-later\n\nimport React, { type FC, useEffect, useRef } from 'react'\nimport { ContextSourceType } from '../models/audioBars'\nimport { useDispatch } from 'react-redux'\nimport { store } from '../store'\nimport { Dispatch } from '../store'\n\nconst large = {\n 0: 4,\n 1: 3,\n 2: 2,\n 3: 1,\n 4: 1,\n 5: 2,\n 6: 3,\n 7: 4,\n}\n\nconst small = {\n 0: 2,\n 1: 1,\n 2: 1,\n 3: 2,\n}\n\n/**\n * This component shows a dynamic audio spectrum given an audio stream\n *\n * @param audioStream An audio stream to analyse\n * @param audioElement An audio element to analyse\n */\nexport const AudioBars: FC<AudioBarsProps> = ({\n audioStream = null,\n audioElement = null,\n paused,\n size,\n}) => {\n // Initialize the main elements\n const containerElement = useRef<HTMLDivElement | null>(null)\n const animationRequest = useRef<number | null>(null)\n const barsMap: BarsMapType = size === 'large' ? large : small\n const context = useRef<AudioContext | null>(null)\n const analyser = useRef<AnalyserNode | null>(null)\n const source = useRef<ContextSourceType>(null)\n const dispatch = useDispatch<Dispatch>()\n\n function saveAnimationRequest(requestId: number) {\n if (requestId) {\n animationRequest.current = requestId\n }\n }\n\n function startAnimation() {\n const animationRequestId: number = requestAnimationFrame(animationFrame)\n saveAnimationRequest(animationRequestId)\n }\n\n // The function that renders the frames of animation\n function animationFrame() {\n if (analyser && analyser.current) {\n const frequencyData = new Uint8Array(analyser.current.frequencyBinCount)\n analyser.current.getByteFrequencyData(frequencyData)\n const values = Object.values(frequencyData)\n\n const bars = containerElement.current?.children\n if (bars && bars?.length > 0) {\n // Change styles to every bar\n for (let i = 0; i < Object.keys(barsMap).length; ++i) {\n const value = values[barsMap[i]] / 255\n // @ts-ignore\n const barStyles = bars && bars[i] && bars[i].style\n if (barStyles && value > 0) {\n barStyles.height = `${100 * value}%`\n }\n }\n startAnimation()\n }\n }\n }\n\n useEffect(() => {\n const { audioElementContext, audioElementAnalyser, audioElementSource, isReady } =\n store.getState().audioBars\n // Initialize audio context and analyser once\n if (audioElement && isReady) {\n // The source is an audio element\n context.current = audioElementContext\n analyser.current = audioElementAnalyser\n source.current = audioElementSource\n } else {\n // The source is an audio stream\n context.current = new AudioContext()\n analyser.current = context.current.createAnalyser()\n analyser.current.smoothingTimeConstant = 0.8\n analyser.current.fftSize = 32\n // Create the media source stream\n if (audioStream) {\n source.current = context.current.createMediaStreamSource(audioStream)\n } else if (audioElement) {\n source.current = context.current.createMediaElementSource(audioElement)\n // Save the audio elements to stores\n dispatch.audioBars.setAudioElementContext(context.current)\n dispatch.audioBars.setAudioElementAnalyser(analyser.current)\n dispatch.audioBars.setAudioElementSource(source.current)\n dispatch.audioBars.setIsReady(true)\n }\n }\n\n // Connect the audio source to the analyser\n analyser.current && source.current && source.current.connect(analyser.current)\n startAnimation()\n\n // Cleanup bars animation\n return () => {\n animationRequest.current && cancelAnimationFrame(animationRequest.current)\n source.current?.disconnect()\n }\n }, [])\n\n useEffect(() => {\n if (animationRequest.current) {\n if (!paused) {\n cancelAnimationFrame(animationRequest.current)\n startAnimation()\n } else {\n cancelAnimationFrame(animationRequest.current)\n }\n }\n }, [size, paused])\n\n return (\n <div\n className={`${\n size === 'small' ? 'pi-h-6 pi-w-6' : 'pi-h-12 pi-w-12'\n } pi-flex pi-justify-center pi-items-center`}\n >\n {/* The bars container */}\n <div\n className={`${\n size === 'small' ? 'pi-h-6' : 'pi-h-8'\n } pi-w-fit pi-flex pi-justify-center pi-items-center pi-gap-1 pi-overflow-hidden`}\n ref={containerElement}\n >\n {/* Every single bar */}\n {(audioStream || audioElement) &&\n Object.keys(barsMap).map((key) => (\n <span key={key} className='pi-bg-emerald-600 pi-w-0.5 pi-rounded-sm'></span>\n ))}\n </div>\n </div>\n )\n}\n\ninterface AudioBarsProps {\n audioStream?: MediaStream | null\n audioElement?: HTMLAudioElement | null\n size?: 'large' | 'small'\n paused?: boolean\n}\n\ninterface BarsMapType {\n [key: number]: number\n}\n"],"names":["large","small","_a","_b","audioStream","_c","audioElement","paused","size","containerElement","useRef","animationRequest","barsMap","context","analyser","source","dispatch","useDispatch","startAnimation","requestId","animationRequestId","requestAnimationFrame","animationFrame","current","frequencyData","Uint8Array","frequencyBinCount","getByteFrequencyData","values","Object","bars","children","length","i","keys","value","barStyles","style","height","concat","useEffect","store","getState","audioBars","audioElementContext","audioElementAnalyser","audioElementSource","isReady","AudioContext","createAnalyser","smoothingTimeConstant","fftSize","createMediaStreamSource","createMediaElementSource","setAudioElementContext","setAudioElementAnalyser","setAudioElementSource","setIsReady","connect","cancelAnimationFrame","disconnect","React","createElement","className","ref","map","key"],"mappings":"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"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../../styles/Island.styles.js");require("../../node_modules/react-redux/es/index.js");var r=require("../../node_modules/@fortawesome/react-fontawesome/index.es.js"),l=require("../../node_modules/@nethesis/nethesis-solid-svg-icons/index.mjs.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../../styles/Island.styles.js");require("../../node_modules/react-redux/es/index.js");var r=require("../../node_modules/@fortawesome/react-fontawesome/index.es.js"),l=require("../../node_modules/@nethesis/nethesis-solid-svg-icons/index.mjs.js"),a=require("../../lib/phone/call.js");require("../../store/index.js"),require("../../node_modules/socket.io-client/build/esm/index.js"),require("../../node_modules/webrtc-adapter/src/js/adapter_core.js"),require("../../lib/webrtc/janus.js"),require("../../node_modules/mic-check/lib/index.js"),require("../Island.js");var i=require("../Button.js"),u=require("../AudioBars.js");require("../../node_modules/framer-motion/dist/framer-motion.js");var n=require("./Timer.js"),s=require("./Number.js"),d=require("./DisplayName.js"),o=require("./Avatar.js"),c=require("./Actions.js"),m=require("../Hangup.js"),f=require("../../node_modules/react-redux/es/hooks/useSelector.js");function p(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var j=p(e);function q(e,t){return!e&&!t}exports.default=function(){var e=f.useSelector((function(e){return e.currentCall})),p=e.incoming,g=e.accepted,E=e.outgoing,v=e.startTime,y=e.paused,_=f.useSelector((function(e){return e.island})).isOpen,b=f.useSelector((function(e){return e.webrtc})).remoteAudioStream;return j.default.createElement(t.StyledCallView,{incoming:p,accepted:g,outgoing:E,isOpen:_},j.default.createElement(t.StyledTopContent,{isOpen:_,incoming:p,accepted:g,outgoing:E},j.default.createElement(o.default,null),_&&j.default.createElement(t.StyledDetails,null,j.default.createElement(d.default,null),g?j.default.createElement(n.default,{startTime:v}):j.default.createElement(s.default,null)),!_&&!g&&j.default.createElement(d.default,null),!_&&g&&j.default.createElement(n.default,{startTime:v}),g&&b&&j.default.createElement(u.AudioBars,{audioStream:b,paused:y,size:_?"large":"small"})),_&&j.default.createElement("div",{className:"pi-grid pi-gap-y-5"},g&&j.default.createElement(c.default,null),j.default.createElement("div",{className:"pi-grid ".concat(q(E,g)?"pi-grid-cols-2":g?"pi-grid-cols-1 pi-justify-items-center":"pi-grid-cols-1 pi-justify-items-end"," pi-gap-3.5")},j.default.createElement(m.default,null),q(E,g)&&j.default.createElement(i.Button,{onClick:a.answerIncomingCall,variant:"green"},j.default.createElement(r.FontAwesomeIcon,{className:"pi-w-6 pi-h-6",icon:l.faPhone})))))};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/CallView/index.tsx"],"sourcesContent":["// Copyright (C) 2022 Nethesis S.r.l.\n// SPDX-License-Identifier: AGPL-3.0-or-later\n\nimport React, { type FC } from 'react'\nimport { StyledDetails, StyledCallView, StyledTopContent } from '../../styles/Island.styles'\nimport { useSelector } from 'react-redux'\nimport { RootState } from '../../store'\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome'\nimport { faPhone } from '@nethesis/nethesis-solid-svg-icons'\nimport { Button } from '../'\nimport Timer from './Timer'\nimport Number from './Number'\nimport DisplayName from './DisplayName'\nimport { AudioBars } from '../'\nimport { answerIncomingCall } from '../../lib/phone/call'\nimport Avatar from './Avatar'\nimport Actions from './Actions'\nimport Hangup from '../Hangup'\n\nfunction isAnswerVisible(outgoing: boolean, accepted: boolean): boolean {\n return !outgoing && !accepted\n}\n\n/**\n * The main view to manage calls, the starting point for calls actions flows\n */\nconst CallView: FC<CallViewProps> = () => {\n // Get multiple values from currentCall store\n const { incoming, accepted, outgoing, startTime } = useSelector(\n (state: RootState) => state.currentCall,\n )\n // Get isOpen and view from island store\n const { isOpen } = useSelector((state: RootState) => state.island)\n\n // Retrieve the audio stream from the webrtc store\n const { remoteAudioStream } = useSelector((state: RootState) => state.webrtc)\n\n return (\n <StyledCallView incoming={incoming} accepted={accepted} outgoing={outgoing} isOpen={isOpen}>\n <StyledTopContent isOpen={isOpen} incoming={incoming} accepted={accepted} outgoing={outgoing}>\n <Avatar />\n {isOpen && (\n <StyledDetails>\n <DisplayName />\n {/* The timer when expanded */}\n {accepted ? <Timer startTime={startTime} /> : <Number />}\n </StyledDetails>\n )}\n {/* The display name when collepsed */}\n {!isOpen && !accepted && <DisplayName />}\n {/* The timer when collapsed */}\n {!isOpen && accepted && <Timer startTime={startTime} />}\n {accepted && remoteAudioStream && (\n <AudioBars
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/CallView/index.tsx"],"sourcesContent":["// Copyright (C) 2022 Nethesis S.r.l.\n// SPDX-License-Identifier: AGPL-3.0-or-later\n\nimport React, { type FC } from 'react'\nimport { StyledDetails, StyledCallView, StyledTopContent } from '../../styles/Island.styles'\nimport { useSelector } from 'react-redux'\nimport { RootState } from '../../store'\nimport { FontAwesomeIcon } from '@fortawesome/react-fontawesome'\nimport { faPhone } from '@nethesis/nethesis-solid-svg-icons'\nimport { Button } from '../'\nimport Timer from './Timer'\nimport Number from './Number'\nimport DisplayName from './DisplayName'\nimport { AudioBars } from '../'\nimport { answerIncomingCall } from '../../lib/phone/call'\nimport Avatar from './Avatar'\nimport Actions from './Actions'\nimport Hangup from '../Hangup'\n\nfunction isAnswerVisible(outgoing: boolean, accepted: boolean): boolean {\n return !outgoing && !accepted\n}\n\n/**\n * The main view to manage calls, the starting point for calls actions flows\n */\nconst CallView: FC<CallViewProps> = () => {\n // Get multiple values from currentCall store\n const { incoming, accepted, outgoing, startTime, paused } = useSelector(\n (state: RootState) => state.currentCall,\n )\n // Get isOpen and view from island store\n const { isOpen } = useSelector((state: RootState) => state.island)\n\n // Retrieve the audio stream from the webrtc store\n const { remoteAudioStream } = useSelector((state: RootState) => state.webrtc)\n\n return (\n <StyledCallView incoming={incoming} accepted={accepted} outgoing={outgoing} isOpen={isOpen}>\n <StyledTopContent isOpen={isOpen} incoming={incoming} accepted={accepted} outgoing={outgoing}>\n <Avatar />\n {isOpen && (\n <StyledDetails>\n <DisplayName />\n {/* The timer when expanded */}\n {accepted ? <Timer startTime={startTime} /> : <Number />}\n </StyledDetails>\n )}\n {/* The display name when collepsed */}\n {!isOpen && !accepted && <DisplayName />}\n {/* The timer when collapsed */}\n {!isOpen && accepted && <Timer startTime={startTime} />}\n {accepted && remoteAudioStream && (\n <AudioBars\n audioStream={remoteAudioStream}\n paused={paused}\n size={isOpen ? 'large' : 'small'}\n />\n )}\n </StyledTopContent>\n {isOpen && (\n <div className='pi-grid pi-gap-y-5'>\n {accepted && <Actions />}\n <div\n className={`pi-grid ${\n isAnswerVisible(outgoing, accepted)\n ? 'pi-grid-cols-2'\n : accepted\n ? 'pi-grid-cols-1 pi-justify-items-center'\n : 'pi-grid-cols-1 pi-justify-items-end'\n } pi-gap-3.5`}\n >\n {/* The button to hangup the currentCall */}\n {/* {incoming || outgoing ? (\n <Button onClick={hangupCurrentCall} variant='red'>\n <FontAwesomeIcon className='pi-rotate-135 pi-w-6 pi-h-6' icon={faPhone} />\n </Button>\n ) : ( */}\n <Hangup />\n {/* )} */}\n {/* The button to answer the incoming call */}\n {isAnswerVisible(outgoing, accepted) && (\n <Button onClick={answerIncomingCall} variant='green'>\n <FontAwesomeIcon className='pi-w-6 pi-h-6' icon={faPhone} />\n </Button>\n )}\n </div>\n </div>\n )}\n </StyledCallView>\n )\n}\n\nexport default CallView\n\nexport interface CallViewProps {}\n"],"names":["isAnswerVisible","outgoing","accepted","_a","useSelector","state","currentCall","incoming","startTime","paused","isOpen","island","remoteAudioStream","webrtc","React","createElement","StyledCallView","StyledTopContent","Avatar","StyledDetails","DisplayName","Timer","Number","AudioBars","audioStream","size","className","Actions","concat","Hangup","Button","onClick","answerIncomingCall","variant","FontAwesomeIcon","icon","faPhone"],"mappings":"4kCAmBA,SAASA,EAAgBC,EAAmBC,GAC1C,OAAQD,IAAaC,CACvB,iBAKoC,WAE5B,IAAAC,EAAsDC,EAAAA,aAC1D,SAACC,GAAqB,OAAAA,EAAMC,WAAW,IADjCC,EAAQJ,EAAAI,SAAEL,EAAQC,EAAAD,SAAED,EAAQE,EAAAF,SAAEO,EAASL,EAAAK,UAAEC,EAAMN,EAAAM,OAI/CC,EAAWN,eAAY,SAACC,GAAqB,OAAAA,EAAMM,iBAGnDC,EAAsBR,eAAY,SAACC,GAAqB,OAAAA,EAAMQ,4BAEtE,OACEC,UAACC,cAAAC,EAAcA,gBAACT,SAAUA,EAAUL,SAAUA,EAAUD,SAAUA,EAAUS,OAAQA,GAClFI,EAAAA,QAAAC,cAACE,mBAAiB,CAAAP,OAAQA,EAAQH,SAAUA,EAAUL,SAAUA,EAAUD,SAAUA,GAClFa,UAAAC,cAACG,EAAM,QAAG,MACTR,GACCI,EAAA,QAAAC,cAACI,EAAAA,cAAa,KACZL,UAAAC,cAACK,EAAW,QAAG,MAEdlB,EAAWY,EAAAA,QAACC,cAAAM,EAAK,SAACb,UAAWA,IAAgBM,wBAACQ,UAAM,QAIvDZ,IAAWR,GAAYY,EAAA,QAAAC,cAACK,EAAW,QAAG,OAEtCV,GAAUR,GAAYY,UAAAC,cAACM,EAAAA,QAAM,CAAAb,UAAWA,IACzCN,GAAYU,GACXE,EAAC,QAAAC,cAAAQ,EAASA,UACR,CAAAC,YAAaZ,EACbH,OAAQA,EACRgB,KAAMf,EAAS,QAAU,WAI9BA,GACCI,EAAK,QAAAC,cAAA,MAAA,CAAAW,UAAU,sBACZxB,GAAYY,EAAC,QAAAC,cAAAY,EAAAA,QAAU,MACxBb,UACEC,cAAA,MAAA,CAAAW,UAAW,WACTE,OAAA5B,EAAgBC,EAAUC,GACtB,iBACAA,EACA,yCACA,sCACO,gBAQbY,UAAAC,cAACc,EAAM,QAAG,MAGT7B,EAAgBC,EAAUC,IACzBY,UAAAC,cAACe,EAAMA,OAAA,CAACC,QAASC,qBAAoBC,QAAQ,SAC3CnB,EAAAA,QAAAC,cAACmB,kBAAgB,CAAAR,UAAU,gBAAgBS,KAAMC,EAAAA,aAQjE"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../utils/customHooks/useEventListener.js"),r=require("../utils/genericFunctions/eventDispatch.js");require("../node_modules/react-redux/es/index.js");var s=require("../lib/phone/call.js"),n=require("../node_modules/react-redux/es/hooks/useSelector.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("../node_modules/react-redux/es/components/Context.js"),require("../node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js"),require("../node_modules/react-redux/node_modules/react-is/index.js");var o=u(e);exports.CallEvents=function(){return n.useSelector((function(e){return e.webrtc})).sipcall,t.useEventListener("phone-island-call-start",(function(e){s.callNumber(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../utils/customHooks/useEventListener.js"),r=require("../utils/genericFunctions/eventDispatch.js");require("../node_modules/react-redux/es/index.js");var s=require("../lib/phone/call.js"),n=require("../node_modules/react-redux/es/hooks/useSelector.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("../node_modules/react-redux/es/components/Context.js"),require("../node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js"),require("../node_modules/react-redux/node_modules/react-is/index.js");var o=u(e);exports.CallEvents=function(){return n.useSelector((function(e){return e.webrtc})).sipcall,t.useEventListener("phone-island-call-start",(function(e){var t=e.number.replace(/\s/g,"");s.callNumber(t)})),o.default.createElement(o.default.Fragment,null)},exports.dispatchOutgoingCallStarted=function(e,t){void 0===e&&(e=""),void 0===t&&(t="");var s={name:e,number:t};r.eventDispatch("phone-island-outgoing-call-started",s)};
|
|
2
2
|
//# sourceMappingURL=CallEvents.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CallEvents.js","sources":["../../src/events/CallEvents.tsx"],"sourcesContent":["// Copyright (C) 2022 Nethesis S.r.l.\n// SPDX-License-Identifier: AGPL-3.0-or-later\n\nimport React, { FC } from 'react'\nimport { useEventListener, eventDispatch } from '../utils'\nimport { useSelector } from 'react-redux'\nimport { RootState } from '../store'\nimport { callNumber } from '../lib/phone/call'\n\nexport const CallEvents: FC = () => {\n const { sipcall }: any = useSelector((state: RootState) => state.webrtc)\n /**\n * Event listner for phone-island-call-start event\n */\n useEventListener('phone-island-call-start', (data) => {\n
|
|
1
|
+
{"version":3,"file":"CallEvents.js","sources":["../../src/events/CallEvents.tsx"],"sourcesContent":["// Copyright (C) 2022 Nethesis S.r.l.\n// SPDX-License-Identifier: AGPL-3.0-or-later\n\nimport React, { FC } from 'react'\nimport { useEventListener, eventDispatch } from '../utils'\nimport { useSelector } from 'react-redux'\nimport { RootState } from '../store'\nimport { callNumber } from '../lib/phone/call'\n\nexport const CallEvents: FC = () => {\n const { sipcall }: any = useSelector((state: RootState) => state.webrtc)\n /**\n * Event listner for phone-island-call-start event\n */\n useEventListener('phone-island-call-start', (data: CallStartTypes) => {\n const number = data.number.replace(/\\s/g, '')\n callNumber(number)\n })\n return <></>\n}\n\n// !TODO add phone-island-outgoing-call-started phone-island-outgoing-call-ended\n\n/**\n * Dispatch the phone-island-outgoing-call-started event\n */\nexport function dispatchOutgoingCallStarted(name: string = '', number: string = '') {\n const data: OutgoingCallStartedTypes = {\n name,\n number,\n }\n eventDispatch('phone-island-outgoing-call-started', data)\n}\n\nexport interface OutgoingCallStartedTypes {\n name: string\n number: string\n}\n\ninterface CallStartTypes {\n number: string\n}\n"],"names":["useSelector","state","webrtc","useEventListener","data","number","replace","callNumber","React","name","eventDispatch"],"mappings":"sqBAS8B,WAS5B,OARyBA,EAAWA,aAAC,SAACC,GAAqB,OAAAA,EAAMC,MAAM,YAIvEC,mBAAiB,2BAA2B,SAACC,GAC3C,IAAMC,EAASD,EAAKC,OAAOC,QAAQ,MAAO,IAC1CC,EAAUA,WAACF,EACb,IACOG,gDACT,sCAOgB,SAA4BC,EAAmBJ,QAAnB,IAAAI,IAAAA,EAAiB,SAAE,IAAAJ,IAAAA,EAAmB,IAChF,IAAMD,EAAiC,CACrCK,KAAIA,EACJJ,OAAMA,GAERK,gBAAc,qCAAsCN,EACtD"}
|