@16x/webphone-sdk 3.0.1 → 3.0.2
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/CHANGELOG.md +8 -4
- package/LICENSE +0 -1
- package/README.md +1 -1
- package/dist/CCBarClient-DdLM2NKm.cjs +1 -0
- package/dist/{CCBarClient-BdbynNBi.js → CCBarClient-xC63i3Qd.js} +345 -156
- package/dist/{Diagnostics-Cw2HVrCD.js → Diagnostics-BhsVHELt.js} +9 -9
- package/dist/{Diagnostics-BYVvmxil.cjs → Diagnostics-CvH6cjih.cjs} +1 -1
- package/dist/JsSipAdapter-BM7I95Xb.cjs +1 -0
- package/dist/{JsSipAdapter-GHzVSCDh.js → JsSipAdapter-CV6q6UUY.js} +20 -13
- package/dist/SharedWorkerProtocol-V_x8Erjv.cjs +1 -0
- package/dist/{SharedWorkerProtocol-BqUafs8d.js → SharedWorkerProtocol-jfo9N5wa.js} +27 -17
- package/dist/core/CCBarClient.d.ts +14 -2
- package/dist/core/CallManager.d.ts +2 -0
- package/dist/diagnostics/Diagnostics.d.ts +1 -0
- package/dist/diagnostics/index.cjs +1 -1
- package/dist/diagnostics/index.d.ts +1 -1
- package/dist/diagnostics/index.js +3 -6
- package/dist/index.cjs +1 -1
- package/dist/index.js +9 -139
- package/dist/index.umd.js +17 -17
- package/dist/legacy/index.cjs +1 -1
- package/dist/legacy/index.js +2 -2
- package/dist/shared-worker.cjs +1 -1
- package/dist/shared-worker.js +13 -6
- package/dist/types.d.ts +5 -0
- package/dist/ui/XCallCCBarElement.d.ts +2 -0
- package/dist/ui/index.cjs +1 -1
- package/dist/ui/index.js +138 -130
- package/package.json +3 -1
- package/dist/CCBarClient-DKWdvgf5.cjs +0 -1
- package/dist/CCBarError-CIqJE8zK.cjs +0 -1
- package/dist/CCBarError-DSbPw2dA.js +0 -14
- package/dist/JsSipAdapter-jtGdoXrm.cjs +0 -1
- package/dist/SharedWorkerProtocol-CYN0AprP.cjs +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e=class extends Error{code;category;retryable;requestId;callId;cause;constructor(e,t,n,r={}){super(e),this.name=`CCBarError`,this.code=e,this.category=t,this.retryable=n,this.requestId=r.requestId,this.callId=r.callId,this.cause=r.cause}};Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return e}});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
//#region src/errors/CCBarError.ts
|
|
2
|
-
var e = class extends Error {
|
|
3
|
-
code;
|
|
4
|
-
category;
|
|
5
|
-
retryable;
|
|
6
|
-
requestId;
|
|
7
|
-
callId;
|
|
8
|
-
cause;
|
|
9
|
-
constructor(e, t, n, r = {}) {
|
|
10
|
-
super(e), this.name = "CCBarError", this.code = e, this.category = t, this.retryable = n, this.requestId = r.requestId, this.callId = r.callId, this.cause = r.cause;
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
//#endregion
|
|
14
|
-
export { e as t };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require("./CCBarError-CIqJE8zK.cjs");require("./createJsSipFactory-2X4FBIU2.cjs");function t(e){let t=new Map;return{peerConnection:{getSenders:()=>e.getSenders().map(n=>{let r=t.get(n);if(r!==void 0)return r;let i={get track(){return n.track},get senderKind(){let t=n.track;if(t!==null)return t.kind===`audio`||t.kind===`video`?t.kind:void 0;let r=e.getTransceivers().find(e=>e.sender===n)?.receiver.track;if(r?.kind===`audio`||r?.kind===`video`)return r.kind;let i=n.getParameters().codecs?.find(e=>typeof e.mimeType==`string`);if(i?.mimeType?.toLowerCase().startsWith(`video/`))return`video`;if(i?.mimeType?.toLowerCase().startsWith(`audio/`))return`audio`},replaceTrack:e=>n.replaceTrack(e)};return t.set(n,i),i}),close:()=>{e.connectionState!==`closed`&&e.close()}},trackSource:{onTrack(t){let n=e=>{let n=e.track;t({streams:[...e.streams],track:n})};return e.addEventListener(`track`,n),()=>e.removeEventListener(`track`,n)}}}}var n=300,r=class{factory;transportBaseUrl;ua;uaListeners;incomingHandlers;iceServers;pendingConnection;disposed=!1;connectionHandlers=new Set;constructor(e,t){this.factory=e,this.transportBaseUrl=t}connect(e){this.assertNotDisposed(),this.disconnect(this.registrationError(`SIP connection replaced`));try{let t=this.factory.createUa({sockets:s(this.factory.createSocket(this.withoutTicket(this.resolveWssUrl(e.transport.wssUrl)),e.transport.ticket)),uri:e.sip.uri,password:e.sip.registerTicket,registrar_server:e.sip.registrar,register:!0,register_expires:n});return this.ua=t,this.iceServers=e.iceServers,this.uaListeners=[],this.startRegistration(t)}catch(e){let t=this.transportError(e);return this.disconnect(t),Promise.reject(t)}}disconnect(e=this.registrationError(`SIP connection disconnected`)){let t=this.pendingConnection;this.pendingConnection=void 0,this.ua!==void 0&&(this.removeUaListeners(this.ua),this.ua.stop()),this.ua=void 0,this.uaListeners=void 0,this.iceServers=void 0,t?.reject(e)}dial(t,n){let r=this.requireUa();if(t.trim()===``)throw new e.t(`CALL_INVALID_DESTINATION`,`call`,!1);try{let e=n===void 0?{mediaConstraints:{audio:!0,video:!1},sessionTimersExpires:1800,pcConfig:{iceServers:this.iceServers}}:{mediaConstraints:{audio:!0,video:!1},sessionTimersExpires:1800,pcConfig:{iceServers:[...n.iceServers]},extraHeaders:[...n.extraHeaders,...n.type===`extension`?[`X-XCall-Destination-Type: extension`]:[]]};return new i(r.call(t,e))}catch(t){throw new e.t(`CALL_OPERATION_NOT_ALLOWED`,`call`,!1,{cause:t})}}onIncoming(e){this.assertNotDisposed();let t=this.incomingHandlers??new Set;return this.incomingHandlers=t,t.add(e),()=>t.delete(e)}onConnectionStateChanged(e){return this.disposed?()=>void 0:(this.connectionHandlers.add(e),()=>this.connectionHandlers.delete(e))}dispose(){this.disposed||(this.disposed=!0,this.disconnect(),this.incomingHandlers=void 0,this.connectionHandlers.clear())}getResourceCounts(){return{listeners:(this.uaListeners?.length??0)+(this.incomingHandlers?.size??0)+this.connectionHandlers.size,webSockets:this.ua===void 0?0:1}}handleIncoming(e){if(!a(e))return;let t=e.session;if(t===void 0)return;let n=new i(t);this.incomingHandlers?.forEach(e=>e(n))}startRegistration(e){let t=!0,n=!1,r=new Promise((t,n)=>{this.pendingConnection={ua:e,resolve:t,reject:n}});this.listen(e,`registered`,()=>{if(this.isCurrentUa(e)){if(t){n=!0;return}this.resolveConnection(e)}}),this.listen(e,`registrationFailed`,t=>{if(!this.isCurrentUa(e))return;let n=this.registrationError(this.registrationFailureCause(t));this.connectionHandlers.forEach(e=>e(`failed`,n)),this.disconnect(n)}),this.listen(e,`disconnected`,t=>{if(!this.isCurrentUa(e))return;let n=this.transportError(t);this.connectionHandlers.forEach(e=>e(`disconnected`,n)),this.disconnect(n)}),this.listen(e,`newRTCSession`,t=>{this.isCurrentUa(e)&&this.handleIncoming(t)});try{e.start()}catch(e){let t=this.transportError(e);this.connectionHandlers.forEach(e=>e(`failed`,t)),this.disconnect(t)}finally{t=!1}return n&&this.resolveConnection(e),r}listen(e,t,n){e.on(t,n),this.uaListeners?.push({event:t,handler:n})}removeUaListeners(e){this.uaListeners?.forEach(({event:t,handler:n})=>e.off(t,n))}isCurrentUa(e){return this.ua===e}resolveConnection(e){let t=this.pendingConnection;t?.ua===e&&(this.pendingConnection=void 0,t.resolve(),this.connectionHandlers.forEach(e=>e(`registered`)))}resolveWssUrl(e){let t=this.transportBaseUrl?.trim()===``||this.transportBaseUrl===void 0?typeof location>`u`?`http://localhost`:location.origin:this.transportBaseUrl,n=e.startsWith(`/`)?new URL(e,t):new URL(e);return n.protocol===`http:`&&(n.protocol=`ws:`),n.protocol===`https:`&&(n.protocol=`wss:`),n.toString()}withoutTicket(e){let t=new URL(e);return t.searchParams.delete(`ticket`),t.toString()}requireUa(){if(this.assertNotDisposed(),this.ua===void 0)throw new e.t(`CALL_NOT_CONNECTED`,`call`,!1);return this.ua}assertNotDisposed(){if(this.disposed)throw new e.t(`SDK_ALREADY_DISPOSED`,`internal`,!1)}registrationError(t){return new e.t(`REGISTRATION_FAILED`,`registration`,!0,{cause:t})}transportError(t){return new e.t(`SIP_WS_UNAVAILABLE`,`registration`,!0,{cause:t})}registrationFailureCause(e){return typeof e==`object`&&e&&`cause`in e?e.cause:e}},i=class{session;pendingHoldReject;mediaRegistration;mediaConnection;constructor(e){this.session=e}get id(){return this.session.id}get from(){return this.session.from??c(this.session.remote_identity)}getMediaRegistration(){let e=this.session.connection;if(e!==void 0)return this.mediaRegistration!==void 0&&this.mediaConnection===e?this.mediaRegistration:(this.mediaConnection=e,this.mediaRegistration=t(e),this.mediaRegistration)}answer(e){this.session.answer({mediaConstraints:e.mediaConstraints,pcConfig:{iceServers:[...e.pcConfig.iceServers]}})}terminate(){this.pendingHoldReject?.(Error(`SIP session terminated`)),this.session.terminate()}hold(){return this.changeHoldState(`hold`)}unhold(){return this.changeHoldState(`unhold`)}mute(){this.session.mute()}unmute(){this.session.unmute()}sendDtmf(e){this.session.sendDTMF(e)}refer(e){this.session.refer(e)}on(e,t){return this.session.on(e,t),()=>this.session.off(e,t)}changeHoldState(t){return new Promise((n,r)=>{let i=!1,a=e=>{c(e)},o=()=>{try{this.session.off(`ended`,a)}catch{}try{this.session.off(`failed`,a)}catch{}this.pendingHoldReject===c&&(this.pendingHoldReject=void 0)},s=()=>{i||(i=!0,o(),n())},c=t=>{i||(i=!0,o(),r(new e.t(`CALL_OPERATION_NOT_ALLOWED`,`call`,!1,{cause:t})))};try{this.session.on(`ended`,a),this.session.on(`failed`,a)}catch(e){c(e);return}this.pendingHoldReject=c;try{this.session[t](void 0,s)||c()}catch(e){c(e)}})}};function a(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.originator===`remote`&&o(t.session)}function o(e){return typeof e==`object`&&!!e&&`id`in e}function s(e){return typeof e==`object`&&e&&(e.via_transport=`WSS`),e}function c(e){let t=e?.uri;if(t==null)return;if(typeof t.user==`string`&&t.user!==``)return t.user;let n=t.toString();return n.match(/^sips?:([^@;>]+)/i)?.[1]??(n===``?void 0:n)}exports.JsSipAdapter=r;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=require("./CCBarError-CIqJE8zK.cjs"),t=require("./redact-Bq26pObO.cjs");var n=[`new`,`dialing`,`ringing`,`connecting`,`active`,`held`,`ended`,`failed`];function r(e){if(!c(e)||typeof e.id!=`string`||typeof e.destination!=`string`||typeof e.incoming!=`boolean`||!s(e.state))throw u(`Invalid call snapshot`);return{id:e.id,...typeof e.from==`string`?{from:e.from}:{},destination:e.destination,state:e.state,incoming:e.incoming,...typeof e.ownerTabId==`string`?{ownerTabId:e.ownerTabId}:{}}}function i(t){return t instanceof e.t?{code:t.code,category:t.category,retryable:t.retryable,...t.requestId===void 0?{}:{requestId:t.requestId},...t.callId===void 0?{}:{callId:t.callId},message:l(t.message)}:{code:`SDK_INTERNAL_ERROR`,category:`internal`,retryable:!1,message:l(t instanceof Error?t.message:String(t))}}function a(e){if(!c(e))throw u(`Invalid worker message`);if(e.version!==1)throw u(`Unsupported worker protocol version`);if(e.type===`attach`||e.type===`detach`)return o(e),e;if(e.type===`command`){if(o(e),typeof e.command!=`string`||e.payload!==void 0&&!c(e.payload))throw u(`Invalid worker command`);return e}if(e.type===`response`){if(typeof e.requestId!=`string`||typeof e.ok!=`boolean`)throw u(`Invalid worker response`);return e}if(e.type===`event`){if(typeof e.event!=`string`||!(`payload`in e))throw u(`Invalid worker event`);return e}throw u(`Unknown worker message type`)}function o(e){if(typeof e.requestId!=`string`||typeof e.tabId!=`string`)throw u(`Worker request requires requestId and tabId`)}function s(e){return typeof e==`string`&&n.includes(e)}function c(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function l(e){return t.t(e).replace(/(?:authorization|token|ticket|credential|password|secret)/gi,`[REDACTED]`)}function u(t){return new e.t(`SDK_INTERNAL_ERROR`,`internal`,!1,{cause:t})}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return a}});
|