@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.
Files changed (34) hide show
  1. package/CHANGELOG.md +8 -4
  2. package/LICENSE +0 -1
  3. package/README.md +1 -1
  4. package/dist/CCBarClient-DdLM2NKm.cjs +1 -0
  5. package/dist/{CCBarClient-BdbynNBi.js → CCBarClient-xC63i3Qd.js} +345 -156
  6. package/dist/{Diagnostics-Cw2HVrCD.js → Diagnostics-BhsVHELt.js} +9 -9
  7. package/dist/{Diagnostics-BYVvmxil.cjs → Diagnostics-CvH6cjih.cjs} +1 -1
  8. package/dist/JsSipAdapter-BM7I95Xb.cjs +1 -0
  9. package/dist/{JsSipAdapter-GHzVSCDh.js → JsSipAdapter-CV6q6UUY.js} +20 -13
  10. package/dist/SharedWorkerProtocol-V_x8Erjv.cjs +1 -0
  11. package/dist/{SharedWorkerProtocol-BqUafs8d.js → SharedWorkerProtocol-jfo9N5wa.js} +27 -17
  12. package/dist/core/CCBarClient.d.ts +14 -2
  13. package/dist/core/CallManager.d.ts +2 -0
  14. package/dist/diagnostics/Diagnostics.d.ts +1 -0
  15. package/dist/diagnostics/index.cjs +1 -1
  16. package/dist/diagnostics/index.d.ts +1 -1
  17. package/dist/diagnostics/index.js +3 -6
  18. package/dist/index.cjs +1 -1
  19. package/dist/index.js +9 -139
  20. package/dist/index.umd.js +17 -17
  21. package/dist/legacy/index.cjs +1 -1
  22. package/dist/legacy/index.js +2 -2
  23. package/dist/shared-worker.cjs +1 -1
  24. package/dist/shared-worker.js +13 -6
  25. package/dist/types.d.ts +5 -0
  26. package/dist/ui/XCallCCBarElement.d.ts +2 -0
  27. package/dist/ui/index.cjs +1 -1
  28. package/dist/ui/index.js +138 -130
  29. package/package.json +3 -1
  30. package/dist/CCBarClient-DKWdvgf5.cjs +0 -1
  31. package/dist/CCBarError-CIqJE8zK.cjs +0 -1
  32. package/dist/CCBarError-DSbPw2dA.js +0 -14
  33. package/dist/JsSipAdapter-jtGdoXrm.cjs +0 -1
  34. package/dist/SharedWorkerProtocol-CYN0AprP.cjs +0 -1
@@ -1,6 +1,6 @@
1
1
  import { n as e, t } from "./redact-DB3CMbsK.js";
2
- //#region src/diagnostics/RingBuffer.ts
3
- var n = class {
2
+ //#region src/version.ts
3
+ var n = "3.0.2", r = class {
4
4
  capacity;
5
5
  entries = [];
6
6
  constructor(e) {
@@ -12,9 +12,9 @@ var n = class {
12
12
  toArray() {
13
13
  return [...this.entries];
14
14
  }
15
- }, r = "@16x/webphone-sdk", i = "0.1.0", a = 200, o = class {
15
+ }, i = "@16x/webphone-sdk", a = 200, o = class {
16
16
  dependencies;
17
- logs = new n(a);
17
+ logs = new r(a);
18
18
  now;
19
19
  constructor(e) {
20
20
  this.dependencies = e, this.now = e.now ?? (() => /* @__PURE__ */ new Date());
@@ -28,17 +28,17 @@ var n = class {
28
28
  });
29
29
  }
30
30
  async getReport(t = {}) {
31
- let n = t.includeRecentLogs !== !1, a = t.includeDeviceNames === !0, o = t.maskPhoneNumbers !== !1, d = this.dependencies.getSnapshot(), f = this.dependencies.getPermission === void 0 ? d.permission : await s(this.dependencies.getPermission, d.permission), p = a ? await c(this.dependencies.getDeviceNames) : void 0, m = u(l(this.dependencies.getUserAgent)), h = {
31
+ let r = t.includeRecentLogs !== !1, a = t.includeDeviceNames === !0, o = t.maskPhoneNumbers !== !1, d = this.dependencies.getSnapshot(), f = this.dependencies.getPermission === void 0 ? d.permission : await s(this.dependencies.getPermission, d.permission), p = a ? await c(this.dependencies.getDeviceNames) : void 0, m = u(l(this.dependencies.getUserAgent)), h = {
32
32
  generatedAt: this.now().toISOString(),
33
33
  sdk: {
34
- name: r,
35
- version: i
34
+ name: i,
35
+ version: n
36
36
  },
37
37
  browser: m.browser,
38
38
  os: m.os,
39
39
  ...d,
40
40
  permission: f,
41
- recentLogs: n ? this.logs.toArray() : [],
41
+ recentLogs: r ? this.logs.toArray() : [],
42
42
  ...p === void 0 ? {} : { deviceNames: p }
43
43
  };
44
44
  return e(h, { maskPhoneNumbers: o });
@@ -120,4 +120,4 @@ function f(e) {
120
120
  };
121
121
  }
122
122
  //#endregion
123
- export { n, o as t };
123
+ export { r as n, n as r, o as t };
@@ -1 +1 @@
1
- const e=require("./redact-Bq26pObO.cjs");var t=class{capacity;entries=[];constructor(e){if(this.capacity=e,!Number.isInteger(e)||e<=0)throw RangeError(`RingBuffer capacity must be a positive integer`)}push(e){this.entries.length===this.capacity&&this.entries.shift(),this.entries.push(e)}toArray(){return[...this.entries]}},n=`@16x/webphone-sdk`,r=`0.1.0`,i=200,a=class{dependencies;logs=new t(i);now;constructor(e){this.dependencies=e,this.now=e.now??(()=>new Date)}log(t,n,r){this.logs.push({timestamp:this.now().toISOString(),level:t,message:e.t(n),...r===void 0?{}:{context:e.n(r)}})}async getReport(t={}){let i=t.includeRecentLogs!==!1,a=t.includeDeviceNames===!0,u=t.maskPhoneNumbers!==!1,d=this.dependencies.getSnapshot(),f=this.dependencies.getPermission===void 0?d.permission:await o(this.dependencies.getPermission,d.permission),p=a?await s(this.dependencies.getDeviceNames):void 0,m=l(c(this.dependencies.getUserAgent)),h={generatedAt:this.now().toISOString(),sdk:{name:n,version:r},browser:m.browser,os:m.os,...d,permission:f,recentLogs:i?this.logs.toArray():[],...p===void 0?{}:{deviceNames:p}};return e.n(h,{maskPhoneNumbers:u})}};async function o(e,t){try{return await e()}catch{return t}}async function s(e){if(e===void 0)return[];try{return[...await e()]}catch{return[]}}function c(e){if(e!==void 0)try{return e()}catch{return``}return typeof navigator>`u`?``:navigator.userAgent}function l(e){return{browser:u(e),os:d(e)}}function u(e){for(let[t,n]of[[`Edge`,/Edg\/([\d.]+)/],[`Chrome`,/(?:Chrome|CriOS)\/([\d.]+)/],[`Firefox`,/(?:Firefox|FxiOS)\/([\d.]+)/],[`Safari`,/Version\/([\d.]+).*Safari/]]){let r=e.match(n);if(r?.[1]!==void 0)return{name:t,version:r[1]}}return{name:`unknown`,version:``}}function d(e){let t=e.match(/(?:iPhone|iPad).*OS ([\d_]+)/);if(t?.[1]!==void 0)return{name:`iOS`,version:t[1].replaceAll(`_`,`.`)};let n=e.match(/Android ([\d.]+)/);if(n?.[1]!==void 0)return{name:`Android`,version:n[1]};let r=e.match(/Windows NT ([\d.]+)/);if(r?.[1]!==void 0)return{name:`Windows`,version:r[1]};let i=e.match(/Mac OS X ([\d_]+)/);return i?.[1]===void 0?/Linux/.test(e)?{name:`Linux`,version:``}:{name:`unknown`,version:``}:{name:`macOS`,version:i[1].replaceAll(`_`,`.`)}}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return a}});
1
+ const e=require("./redact-Bq26pObO.cjs");var t=`3.0.2`,n=class{capacity;entries=[];constructor(e){if(this.capacity=e,!Number.isInteger(e)||e<=0)throw RangeError(`RingBuffer capacity must be a positive integer`)}push(e){this.entries.length===this.capacity&&this.entries.shift(),this.entries.push(e)}toArray(){return[...this.entries]}},r=`@16x/webphone-sdk`,i=200,a=class{dependencies;logs=new n(i);now;constructor(e){this.dependencies=e,this.now=e.now??(()=>new Date)}log(t,n,r){this.logs.push({timestamp:this.now().toISOString(),level:t,message:e.t(n),...r===void 0?{}:{context:e.n(r)}})}async getReport(n={}){let i=n.includeRecentLogs!==!1,a=n.includeDeviceNames===!0,u=n.maskPhoneNumbers!==!1,d=this.dependencies.getSnapshot(),f=this.dependencies.getPermission===void 0?d.permission:await o(this.dependencies.getPermission,d.permission),p=a?await s(this.dependencies.getDeviceNames):void 0,m=l(c(this.dependencies.getUserAgent)),h={generatedAt:this.now().toISOString(),sdk:{name:r,version:t},browser:m.browser,os:m.os,...d,permission:f,recentLogs:i?this.logs.toArray():[],...p===void 0?{}:{deviceNames:p}};return e.n(h,{maskPhoneNumbers:u})}};async function o(e,t){try{return await e()}catch{return t}}async function s(e){if(e===void 0)return[];try{return[...await e()]}catch{return[]}}function c(e){if(e!==void 0)try{return e()}catch{return``}return typeof navigator>`u`?``:navigator.userAgent}function l(e){return{browser:u(e),os:d(e)}}function u(e){for(let[t,n]of[[`Edge`,/Edg\/([\d.]+)/],[`Chrome`,/(?:Chrome|CriOS)\/([\d.]+)/],[`Firefox`,/(?:Firefox|FxiOS)\/([\d.]+)/],[`Safari`,/Version\/([\d.]+).*Safari/]]){let r=e.match(n);if(r?.[1]!==void 0)return{name:t,version:r[1]}}return{name:`unknown`,version:``}}function d(e){let t=e.match(/(?:iPhone|iPad).*OS ([\d_]+)/);if(t?.[1]!==void 0)return{name:`iOS`,version:t[1].replaceAll(`_`,`.`)};let n=e.match(/Android ([\d.]+)/);if(n?.[1]!==void 0)return{name:`Android`,version:n[1]};let r=e.match(/Windows NT ([\d.]+)/);if(r?.[1]!==void 0)return{name:`Windows`,version:r[1]};let i=e.match(/Mac OS X ([\d_]+)/);return i?.[1]===void 0?/Linux/.test(e)?{name:`Linux`,version:``}:{name:`unknown`,version:``}:{name:`macOS`,version:i[1].replaceAll(`_`,`.`)}}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return a}});
@@ -0,0 +1 @@
1
+ const e=require("./SharedWorkerProtocol-V_x8Erjv.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(t){this.assertNotDisposed(),this.disconnect(this.registrationError(`SIP connection replaced`));try{let e=this.factory.createUa({sockets:s(this.factory.createSocket(this.withoutTicket(this.resolveWssUrl(t.transport.wssUrl)),t.transport.ticket)),uri:t.sip.uri,password:t.sip.registerTicket,registrar_server:t.sip.registrar,register:!0,register_expires:n});return this.ua=e,this.iceServers=t.iceServers,this.uaListeners=[],this.startRegistration(e)}catch(t){let n=t instanceof e.i&&t.code===`CONFIG_INVALID`?t:this.transportError(t);return this.disconnect(n),Promise.reject(n)}}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.i(`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.i(`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:`),this.assertAllowedWssUrl(n),n.toString()}assertAllowedWssUrl(t){if(t.protocol!==`wss:`&&!(t.protocol===`ws:`&&c(t.hostname)))throw new e.i(`CONFIG_INVALID`,`configuration`,!1,{cause:t.origin})}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.i(`CALL_NOT_CONNECTED`,`call`,!1);return this.ua}assertNotDisposed(){if(this.disposed)throw new e.i(`SDK_ALREADY_DISPOSED`,`internal`,!1)}registrationError(t){return new e.i(`REGISTRATION_FAILED`,`registration`,!0,{cause:t})}transportError(t){return new e.i(`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??l(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.i(`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.replace(/^\[|\]$/g,``).toLowerCase();return t===`localhost`||t===`127.0.0.1`||t===`::1`||t===`0:0:0:0:0:0:0:1`}function l(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,4 +1,4 @@
1
- import { t as e } from "./CCBarError-DSbPw2dA.js";
1
+ import { i as e } from "./SharedWorkerProtocol-jfo9N5wa.js";
2
2
  //#region src/sip/nativeMediaAdapter.ts
3
3
  function t(e) {
4
4
  let t = /* @__PURE__ */ new Map();
@@ -55,21 +55,21 @@ var n = 300, r = class {
55
55
  constructor(e, t) {
56
56
  this.factory = e, this.transportBaseUrl = t;
57
57
  }
58
- connect(e) {
58
+ connect(t) {
59
59
  this.assertNotDisposed(), this.disconnect(this.registrationError("SIP connection replaced"));
60
60
  try {
61
- let t = this.factory.createUa({
62
- sockets: s(this.factory.createSocket(this.withoutTicket(this.resolveWssUrl(e.transport.wssUrl)), e.transport.ticket)),
63
- uri: e.sip.uri,
64
- password: e.sip.registerTicket,
65
- registrar_server: e.sip.registrar,
61
+ let e = this.factory.createUa({
62
+ sockets: s(this.factory.createSocket(this.withoutTicket(this.resolveWssUrl(t.transport.wssUrl)), t.transport.ticket)),
63
+ uri: t.sip.uri,
64
+ password: t.sip.registerTicket,
65
+ registrar_server: t.sip.registrar,
66
66
  register: !0,
67
67
  register_expires: n
68
68
  });
69
- return this.ua = t, this.iceServers = e.iceServers, this.uaListeners = [], this.startRegistration(t);
70
- } catch (e) {
71
- let t = this.transportError(e);
72
- return this.disconnect(t), Promise.reject(t);
69
+ return this.ua = e, this.iceServers = t.iceServers, this.uaListeners = [], this.startRegistration(e);
70
+ } catch (t) {
71
+ let n = t instanceof e && t.code === "CONFIG_INVALID" ? t : this.transportError(t);
72
+ return this.disconnect(n), Promise.reject(n);
73
73
  }
74
74
  }
75
75
  disconnect(e = this.registrationError("SIP connection disconnected")) {
@@ -180,7 +180,10 @@ var n = 300, r = class {
180
180
  }
181
181
  resolveWssUrl(e) {
182
182
  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);
183
- return n.protocol === "http:" && (n.protocol = "ws:"), n.protocol === "https:" && (n.protocol = "wss:"), n.toString();
183
+ return n.protocol === "http:" && (n.protocol = "ws:"), n.protocol === "https:" && (n.protocol = "wss:"), this.assertAllowedWssUrl(n), n.toString();
184
+ }
185
+ assertAllowedWssUrl(t) {
186
+ if (t.protocol !== "wss:" && !(t.protocol === "ws:" && c(t.hostname))) throw new e("CONFIG_INVALID", "configuration", !1, { cause: t.origin });
184
187
  }
185
188
  withoutTicket(e) {
186
189
  let t = new URL(e);
@@ -214,7 +217,7 @@ var n = 300, r = class {
214
217
  return this.session.id;
215
218
  }
216
219
  get from() {
217
- return this.session.from ?? c(this.session.remote_identity);
220
+ return this.session.from ?? l(this.session.remote_identity);
218
221
  }
219
222
  getMediaRegistration() {
220
223
  let e = this.session.connection;
@@ -294,6 +297,10 @@ function s(e) {
294
297
  return typeof e == "object" && e && (e.via_transport = "WSS"), e;
295
298
  }
296
299
  function c(e) {
300
+ let t = e.replace(/^\[|\]$/g, "").toLowerCase();
301
+ return t === "localhost" || t === "127.0.0.1" || t === "::1" || t === "0:0:0:0:0:0:0:1";
302
+ }
303
+ function l(e) {
297
304
  let t = e?.uri;
298
305
  if (t == null) return;
299
306
  if (typeof t.user == "string" && t.user !== "") return t.user;
@@ -0,0 +1 @@
1
+ const e=require("./redact-Bq26pObO.cjs");var t=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}},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(e){return e instanceof t?{code:e.code,category:e.category,retryable:e.retryable,...e.requestId===void 0?{}:{requestId:e.requestId},...e.callId===void 0?{}:{callId:e.callId},message:l(e.message)}:{code:`SDK_INTERNAL_ERROR`,category:`internal`,retryable:!1,message:l(e instanceof Error?e.message:String(e))}}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(t){return e.t(t).replace(/(?:authorization|token|ticket|credential|password|secret)/gi,`[REDACTED]`)}function u(e){return new t(`SDK_INTERNAL_ERROR`,`internal`,!1,{cause:e})}Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return 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}});
@@ -1,6 +1,16 @@
1
- import { t as e } from "./CCBarError-DSbPw2dA.js";
2
- import { t } from "./redact-DB3CMbsK.js";
3
- var n = [
1
+ import { t as e } from "./redact-DB3CMbsK.js";
2
+ //#region src/errors/CCBarError.ts
3
+ var t = class extends Error {
4
+ code;
5
+ category;
6
+ retryable;
7
+ requestId;
8
+ callId;
9
+ cause;
10
+ constructor(e, t, n, r = {}) {
11
+ 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;
12
+ }
13
+ }, n = [
4
14
  "new",
5
15
  "dialing",
6
16
  "ringing",
@@ -21,19 +31,19 @@ function r(e) {
21
31
  ...typeof e.ownerTabId == "string" ? { ownerTabId: e.ownerTabId } : {}
22
32
  };
23
33
  }
24
- function i(t) {
25
- return t instanceof e ? {
26
- code: t.code,
27
- category: t.category,
28
- retryable: t.retryable,
29
- ...t.requestId === void 0 ? {} : { requestId: t.requestId },
30
- ...t.callId === void 0 ? {} : { callId: t.callId },
31
- message: l(t.message)
34
+ function i(e) {
35
+ return e instanceof t ? {
36
+ code: e.code,
37
+ category: e.category,
38
+ retryable: e.retryable,
39
+ ...e.requestId === void 0 ? {} : { requestId: e.requestId },
40
+ ...e.callId === void 0 ? {} : { callId: e.callId },
41
+ message: l(e.message)
32
42
  } : {
33
43
  code: "SDK_INTERNAL_ERROR",
34
44
  category: "internal",
35
45
  retryable: !1,
36
- message: l(t instanceof Error ? t.message : String(t))
46
+ message: l(e instanceof Error ? e.message : String(e))
37
47
  };
38
48
  }
39
49
  function a(e) {
@@ -63,11 +73,11 @@ function s(e) {
63
73
  function c(e) {
64
74
  return typeof e == "object" && !!e && !Array.isArray(e);
65
75
  }
66
- function l(e) {
67
- return t(e).replace(/(?:authorization|token|ticket|credential|password|secret)/gi, "[REDACTED]");
76
+ function l(t) {
77
+ return e(t).replace(/(?:authorization|token|ticket|credential|password|secret)/gi, "[REDACTED]");
68
78
  }
69
- function u(t) {
70
- return new e("SDK_INTERNAL_ERROR", "internal", !1, { cause: t });
79
+ function u(e) {
80
+ return new t("SDK_INTERNAL_ERROR", "internal", !1, { cause: e });
71
81
  }
72
82
  //#endregion
73
- export { r as n, i as r, a as t };
83
+ export { t as i, r as n, i as r, a as t };
@@ -1,6 +1,7 @@
1
1
  import { MediaConstraints, WebPhoneSession } from '../api/contracts.js';
2
2
  import { TokenProvider } from '../auth/TokenManager.js';
3
- import { CCBarEvents, MediaManager as PublicMedia, SharedWorkerOptions } from '../types.js';
3
+ import { CCBarEvents, MediaManager as PublicMedia, SharedWorkerOptions, SharedWorkerState } from '../types.js';
4
+ import { SharedWorkerConstructor } from '../shared/SharedWorkerFactory.js';
4
5
  import { DialOptions } from './CallManager.js';
5
6
  import { CCBarCall, CallPlatform } from './CCBarCall.js';
6
7
  import { DiagnosticsOptions, DiagnosticsReport } from '../diagnostics/Diagnostics.js';
@@ -12,12 +13,18 @@ export interface CCBarClientOptions {
12
13
  readonly requestedCapabilities?: readonly string[];
13
14
  readonly maxConcurrentCalls?: number;
14
15
  readonly autoHoldPreviousCall?: boolean;
15
- /** SharedWorker is attempted by the multi-tab integration when enabled is omitted or 'auto'. */
16
+ /** SharedWorker attach/close is attempted when this option is provided. SIP remains tab-local until the next-minor adapter. */
16
17
  readonly sharedWorker?: SharedWorkerOptions;
17
18
  /** @internal Test/integration dependency injection; not required by consumers. */
18
19
  readonly api?: unknown;
19
20
  /** @internal Test/integration dependency injection; not required by consumers. */
20
21
  readonly sip?: unknown;
22
+ /** @internal Test/integration dependency injection; not required by consumers. */
23
+ readonly sharedWorkerHost?: {
24
+ readonly workerCtor?: SharedWorkerConstructor;
25
+ readonly locationHref?: string;
26
+ readonly tabId?: string;
27
+ };
21
28
  }
22
29
  export declare class CCBarClient {
23
30
  readonly media: PublicMedia;
@@ -53,6 +60,7 @@ export declare class CCBarClient {
53
60
  private readonly ownedSessionIds;
54
61
  private readonly terminalReleaseOperations;
55
62
  private tokenRequest;
63
+ private sharedWorkerSelection;
56
64
  constructor(options: CCBarClientOptions);
57
65
  static checkSupport(): Promise<import('../types.js').PlatformSupport>;
58
66
  initialize(): Promise<void>;
@@ -68,6 +76,7 @@ export declare class CCBarClient {
68
76
  getCalls(): readonly CCBarCall[];
69
77
  getActiveCall(): CCBarCall | undefined;
70
78
  getAgent(): WebPhoneSession['agent'] | undefined;
79
+ getSharedWorkerState(): SharedWorkerState;
71
80
  getDiagnostics(options?: DiagnosticsOptions): Promise<DiagnosticsReport>;
72
81
  setAgentStatus(status: 'available' | 'offline' | 'break'): Promise<void>;
73
82
  on<K extends keyof CCBarEvents>(event: K, handler: (payload: CCBarEvents[K]) => void): () => void;
@@ -102,12 +111,15 @@ export declare class CCBarClient {
102
111
  private getDiagnosticsResourceCounts;
103
112
  private readMicrophonePermission;
104
113
  private deleteSession;
114
+ private pruneDeletedSessionTombstones;
105
115
  private deleteOwnedSessions;
106
116
  private resolvePlatform;
107
117
  private setConnectionState;
108
118
  private assertConnected;
109
119
  private assertGeneration;
110
120
  private isCurrentGeneration;
121
+ private awaitSharedWorkerReady;
122
+ private releaseSharedWorker;
111
123
  private assertNotDisposed;
112
124
  private disposedError;
113
125
  }
@@ -52,6 +52,7 @@ export declare class CallManager {
52
52
  getResourceCounts(): {
53
53
  readonly timers: number;
54
54
  readonly listeners: number;
55
+ readonly terminalRecords: number;
55
56
  };
56
57
  getActiveCall(): CCBarCall | undefined;
57
58
  setActiveCall(callId: string, tabId?: string): Promise<void>;
@@ -82,6 +83,7 @@ export declare class CallManager {
82
83
  private requireCall;
83
84
  private emitOwnershipChanged;
84
85
  private notifyCallTerminal;
86
+ private pruneTerminalRecord;
85
87
  private assertNotDisposed;
86
88
  private callOperationError;
87
89
  private capabilityError;
@@ -14,6 +14,7 @@ export interface DiagnosticsResourceCounts {
14
14
  readonly peerConnections: number;
15
15
  readonly audioElements: number;
16
16
  readonly webSockets: number;
17
+ readonly deletedSessions: number;
17
18
  }
18
19
  export interface DiagnosticCallSnapshot {
19
20
  readonly callId: string;
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../Diagnostics-BYVvmxil.cjs"),t=require("../redact-Bq26pObO.cjs");require("../createJsSipFactory-2X4FBIU2.cjs");var n=`0.1.0`;exports.Diagnostics=e.t,exports.RingBuffer=e.n,exports.diagnosticsVersion=n,exports.redactText=t.t,exports.redactValue=t.n;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../Diagnostics-CvH6cjih.cjs"),t=require("../redact-Bq26pObO.cjs");require("../createJsSipFactory-2X4FBIU2.cjs"),exports.Diagnostics=e.t,exports.RingBuffer=e.n,exports.diagnosticsVersion=e.r,exports.redactText=t.t,exports.redactValue=t.n;
@@ -1,4 +1,4 @@
1
1
  export * from './Diagnostics.js';
2
2
  export * from './RingBuffer.js';
3
3
  export * from './redact.js';
4
- export declare const diagnosticsVersion = "0.1.0";
4
+ export { SDK_VERSION as diagnosticsVersion } from '../version.js';
@@ -1,6 +1,3 @@
1
- import { n as e, t } from "../Diagnostics-Cw2HVrCD.js";
2
- import { n, t as r } from "../redact-DB3CMbsK.js";
3
- //#region src/diagnostics/index.ts
4
- var i = "0.1.0";
5
- //#endregion
6
- export { t as Diagnostics, e as RingBuffer, i as diagnosticsVersion, r as redactText, n as redactValue };
1
+ import { n as e, r as t, t as n } from "../Diagnostics-BhsVHELt.js";
2
+ import { n as r, t as i } from "../redact-DB3CMbsK.js";
3
+ export { n as Diagnostics, e as RingBuffer, t as diagnosticsVersion, i as redactText, r as redactValue };
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./CCBarError-CIqJE8zK.cjs"),t=require("./CCBarClient-DKWdvgf5.cjs"),n=require("./Diagnostics-BYVvmxil.cjs"),r=require("./redact-Bq26pObO.cjs"),i=require("./diagnostics/index.cjs"),a=require("./SharedWorkerProtocol-CYN0AprP.cjs");require("./createJsSipFactory-2X4FBIU2.cjs");function o(e){if(e.code!==`OK`)throw TypeError(`Unexpected session response code: ${e.code}`);if(e.data===void 0||e.data===null)throw TypeError(`Unexpected session response: missing data`);return e.data}var s=class{port;timeoutMs;pending=new Map;eventHandlers=new Set;closed=!1;lifecycleState=`connected`;constructor(e,t={}){this.port=e,this.timeoutMs=t.timeoutMs??15e3,this.port.onmessage=e=>this.handleMessage(e.data),this.port.start()}request(t){return this.closed?Promise.reject(new e.t(`SDK_ALREADY_DISPOSED`,`internal`,!1)):this.pending.has(t.requestId)?Promise.reject(new e.t(`SDK_INTERNAL_ERROR`,`internal`,!1,{requestId:t.requestId})):this.lifecycleState===`reconnecting`&&t.type===`command`&&(t.command===`dial`||t.command===`answer`)?Promise.reject(new e.t(`CALL_OPERATION_NOT_ALLOWED`,`call`,!0,{callId:t.payload?.callId})):new Promise((n,r)=>{let i=setTimeout(()=>{this.pending.delete(t.requestId),r(new e.t(`NETWORK_TIMEOUT`,`network`,!0,{requestId:t.requestId}))},this.timeoutMs);this.pending.set(t.requestId,{resolve:e=>n(e),reject:r,timer:i}),this.port.postMessage(t)})}onEvent(e){return this.closed?()=>void 0:(this.eventHandlers.add(e),()=>this.eventHandlers.delete(e))}getLifecycleState(){return this.lifecycleState}close(){this.closed||(this.closed=!0,this.pending.forEach(t=>{clearTimeout(t.timer),t.reject(new e.t(`SDK_ALREADY_DISPOSED`,`internal`,!1))}),this.pending.clear(),this.eventHandlers.clear(),this.port.close())}handleMessage(e){try{let t=a.t(e);if(t.type===`event`){t.event===`connection.stateChanged`&&c(t.payload)&&(this.lifecycleState=t.payload.state),this.eventHandlers.forEach(e=>e(t));return}if(t.type!==`response`)return;let n=this.pending.get(t.requestId);if(n===void 0)return;this.pending.delete(t.requestId),clearTimeout(n.timer),t.ok?n.resolve(t.result):n.reject(l(t))}catch(e){this.pending.forEach(t=>t.reject(e)),this.pending.clear()}}};function c(e){return typeof e==`object`&&!!e&&`state`in e&&(e.state===`connected`||e.state===`reconnecting`)}function l(t){let n=t.error;return new e.t(n?.code??`SDK_INTERNAL_ERROR`,n?.category??`internal`,n?.retryable??!1,{requestId:t.requestId,...n?.message===void 0?{}:{cause:n.message}})}function u(t={}){if((t.enabled??`auto`)===!1)return{mode:`single-tab`,reason:`disabled`};let n=t.locationHref??f(),r=d(t.url,n),i=n=>{if(t.fallback===`error`)throw new e.t(`CONFIG_INVALID`,`configuration`,!1,{cause:n});return{mode:`single-tab`,reason:n}};if(r===void 0)return i(`SharedWorker URL is unavailable`);if(!m(r,n))return i(`SharedWorker URL must be same-origin`);let a=t.workerCtor??p();if(a===void 0)return i(`SharedWorker is not supported`);let o;try{o=new a(r,t.name===void 0?void 0:{name:t.name})}catch(e){return i(`SharedWorker construction failed: ${e instanceof Error?e.message:String(e)}`)}let c=t.tabId??h(),l=new s(o.port),u={version:1,type:`attach`,requestId:g(),tabId:c},_=l.request(u).then(()=>void 0).catch(e=>{throw l.close(),e});return{mode:`shared`,worker:o,client:l,tabId:c,workerUrl:r,ready:_}}function d(e,t=f()){try{return t===void 0?void 0:new URL(e??`./shared-worker.js`,t).toString()}catch{return}}function f(){return typeof location>`u`?void 0:location.href}function p(){if(typeof SharedWorker==`function`)return SharedWorker}function m(e,t){if(t===void 0)return!0;try{return new URL(e,t).origin===new URL(t).origin}catch{return!1}}function h(){return`tab-${typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():Math.random().toString(36).slice(2)}`}function g(){return`attach-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function _(e={}){return{version:`0.1.0`,options:e}}var v=`0.1.0`;exports.CCBarCall=t.r,exports.CCBarClient=t.t,exports.CCBarError=e.t,exports.CallManager=t.n,exports.CallStateError=t.o,exports.Diagnostics=n.t,exports.RingBuffer=n.n,exports.TokenManager=t.a,exports.TypedEventBus=t.d,exports.WebPhoneApi=t.i,exports.assertCallTransition=t.s,exports.canTransition=t.c,exports.createSdk=_,exports.createSharedWorkerSelection=u,exports.diagnosticsVersion=i.diagnosticsVersion,exports.parseSessionResponse=o,exports.redactText=r.t,exports.redactValue=r.n,exports.resolveWorkerUrl=d,exports.transition=t.l,exports.transitions=t.u,exports.version=v;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./SharedWorkerProtocol-V_x8Erjv.cjs"),t=require("./CCBarClient-DdLM2NKm.cjs"),n=require("./Diagnostics-CvH6cjih.cjs"),r=require("./redact-Bq26pObO.cjs");require("./diagnostics/index.cjs"),require("./createJsSipFactory-2X4FBIU2.cjs");function i(e){if(e.code!==`OK`)throw TypeError(`Unexpected session response code: ${e.code}`);if(e.data===void 0||e.data===null)throw TypeError(`Unexpected session response: missing data`);return e.data}function a(e={}){return{version:`0.1.0`,options:e}}var o=`0.1.0`;exports.CCBarCall=t.a,exports.CCBarClient=t.t,exports.CCBarError=e.i,exports.CallManager=t.i,exports.CallStateError=t.c,exports.Diagnostics=n.t,exports.RingBuffer=n.n,exports.TokenManager=t.s,exports.TypedEventBus=t.p,exports.WebPhoneApi=t.o,exports.assertCallTransition=t.l,exports.canTransition=t.u,exports.createSdk=a,exports.createSharedWorkerSelection=t.n,exports.diagnosticsVersion=n.r,exports.parseSessionResponse=i,exports.redactText=r.t,exports.redactValue=r.n,exports.resolveWorkerUrl=t.r,exports.transition=t.d,exports.transitions=t.f,exports.version=o;
package/dist/index.js CHANGED
@@ -1,152 +1,22 @@
1
- import { t as e } from "./CCBarError-DSbPw2dA.js";
2
- import { a as t, c as n, d as r, i, l as a, n as o, o as s, r as c, s as l, t as u, u as d } from "./CCBarClient-BdbynNBi.js";
3
- import { n as f, t as p } from "./Diagnostics-Cw2HVrCD.js";
4
- import { n as m, t as h } from "./redact-DB3CMbsK.js";
5
- import { diagnosticsVersion as g } from "./diagnostics/index.js";
6
- import { t as _ } from "./SharedWorkerProtocol-BqUafs8d.js";
1
+ import { i as e } from "./SharedWorkerProtocol-jfo9N5wa.js";
2
+ import { a as t, c as n, d as r, f as i, i as a, l as o, n as s, o as c, p as l, r as u, s as d, t as f, u as p } from "./CCBarClient-xC63i3Qd.js";
3
+ import { n as m, r as h, t as g } from "./Diagnostics-BhsVHELt.js";
4
+ import { n as _, t as v } from "./redact-DB3CMbsK.js";
5
+ import "./diagnostics/index.js";
7
6
  //#region src/api/contracts.ts
8
- function v(e) {
7
+ function y(e) {
9
8
  if (e.code !== "OK") throw TypeError(`Unexpected session response code: ${e.code}`);
10
9
  if (e.data === void 0 || e.data === null) throw TypeError("Unexpected session response: missing data");
11
10
  return e.data;
12
11
  }
13
12
  //#endregion
14
- //#region src/shared/SharedWorkerClient.ts
15
- var y = class {
16
- port;
17
- timeoutMs;
18
- pending = /* @__PURE__ */ new Map();
19
- eventHandlers = /* @__PURE__ */ new Set();
20
- closed = !1;
21
- lifecycleState = "connected";
22
- constructor(e, t = {}) {
23
- this.port = e, this.timeoutMs = t.timeoutMs ?? 15e3, this.port.onmessage = (e) => this.handleMessage(e.data), this.port.start();
24
- }
25
- request(t) {
26
- return this.closed ? Promise.reject(new e("SDK_ALREADY_DISPOSED", "internal", !1)) : this.pending.has(t.requestId) ? Promise.reject(new e("SDK_INTERNAL_ERROR", "internal", !1, { requestId: t.requestId })) : this.lifecycleState === "reconnecting" && t.type === "command" && (t.command === "dial" || t.command === "answer") ? Promise.reject(new e("CALL_OPERATION_NOT_ALLOWED", "call", !0, { callId: t.payload?.callId })) : new Promise((n, r) => {
27
- let i = setTimeout(() => {
28
- this.pending.delete(t.requestId), r(new e("NETWORK_TIMEOUT", "network", !0, { requestId: t.requestId }));
29
- }, this.timeoutMs);
30
- this.pending.set(t.requestId, {
31
- resolve: (e) => n(e),
32
- reject: r,
33
- timer: i
34
- }), this.port.postMessage(t);
35
- });
36
- }
37
- onEvent(e) {
38
- return this.closed ? () => void 0 : (this.eventHandlers.add(e), () => this.eventHandlers.delete(e));
39
- }
40
- getLifecycleState() {
41
- return this.lifecycleState;
42
- }
43
- close() {
44
- this.closed || (this.closed = !0, this.pending.forEach((t) => {
45
- clearTimeout(t.timer), t.reject(new e("SDK_ALREADY_DISPOSED", "internal", !1));
46
- }), this.pending.clear(), this.eventHandlers.clear(), this.port.close());
47
- }
48
- handleMessage(e) {
49
- try {
50
- let t = _(e);
51
- if (t.type === "event") {
52
- t.event === "connection.stateChanged" && b(t.payload) && (this.lifecycleState = t.payload.state), this.eventHandlers.forEach((e) => e(t));
53
- return;
54
- }
55
- if (t.type !== "response") return;
56
- let n = this.pending.get(t.requestId);
57
- if (n === void 0) return;
58
- this.pending.delete(t.requestId), clearTimeout(n.timer), t.ok ? n.resolve(t.result) : n.reject(x(t));
59
- } catch (e) {
60
- this.pending.forEach((t) => t.reject(e)), this.pending.clear();
61
- }
62
- }
63
- };
64
- function b(e) {
65
- return typeof e == "object" && !!e && "state" in e && (e.state === "connected" || e.state === "reconnecting");
66
- }
67
- function x(t) {
68
- let n = t.error;
69
- return new e(n?.code ?? "SDK_INTERNAL_ERROR", n?.category ?? "internal", n?.retryable ?? !1, {
70
- requestId: t.requestId,
71
- ...n?.message === void 0 ? {} : { cause: n.message }
72
- });
73
- }
74
- //#endregion
75
- //#region src/shared/SharedWorkerFactory.ts
76
- function S(t = {}) {
77
- if ((t.enabled ?? "auto") === !1) return {
78
- mode: "single-tab",
79
- reason: "disabled"
80
- };
81
- let n = t.locationHref ?? w(), r = C(t.url, n), i = (n) => {
82
- if (t.fallback === "error") throw new e("CONFIG_INVALID", "configuration", !1, { cause: n });
83
- return {
84
- mode: "single-tab",
85
- reason: n
86
- };
87
- };
88
- if (r === void 0) return i("SharedWorker URL is unavailable");
89
- if (!E(r, n)) return i("SharedWorker URL must be same-origin");
90
- let a = t.workerCtor ?? T();
91
- if (a === void 0) return i("SharedWorker is not supported");
92
- let o;
93
- try {
94
- o = new a(r, t.name === void 0 ? void 0 : { name: t.name });
95
- } catch (e) {
96
- return i(`SharedWorker construction failed: ${e instanceof Error ? e.message : String(e)}`);
97
- }
98
- let s = t.tabId ?? D(), c = new y(o.port), l = {
99
- version: 1,
100
- type: "attach",
101
- requestId: O(),
102
- tabId: s
103
- }, u = c.request(l).then(() => void 0).catch((e) => {
104
- throw c.close(), e;
105
- });
106
- return {
107
- mode: "shared",
108
- worker: o,
109
- client: c,
110
- tabId: s,
111
- workerUrl: r,
112
- ready: u
113
- };
114
- }
115
- function C(e, t = w()) {
116
- try {
117
- return t === void 0 ? void 0 : new URL(e ?? "./shared-worker.js", t).toString();
118
- } catch {
119
- return;
120
- }
121
- }
122
- function w() {
123
- return typeof location > "u" ? void 0 : location.href;
124
- }
125
- function T() {
126
- if (typeof SharedWorker == "function") return SharedWorker;
127
- }
128
- function E(e, t) {
129
- if (t === void 0) return !0;
130
- try {
131
- return new URL(e, t).origin === new URL(t).origin;
132
- } catch {
133
- return !1;
134
- }
135
- }
136
- function D() {
137
- return `tab-${typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : Math.random().toString(36).slice(2)}`;
138
- }
139
- function O() {
140
- return `attach-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
141
- }
142
- //#endregion
143
13
  //#region src/index.ts
144
- function k(e = {}) {
14
+ function b(e = {}) {
145
15
  return {
146
16
  version: "0.1.0",
147
17
  options: e
148
18
  };
149
19
  }
150
- var A = "0.1.0";
20
+ var x = "0.1.0";
151
21
  //#endregion
152
- export { c as CCBarCall, u as CCBarClient, e as CCBarError, o as CallManager, s as CallStateError, p as Diagnostics, f as RingBuffer, t as TokenManager, r as TypedEventBus, i as WebPhoneApi, l as assertCallTransition, n as canTransition, k as createSdk, S as createSharedWorkerSelection, g as diagnosticsVersion, v as parseSessionResponse, h as redactText, m as redactValue, C as resolveWorkerUrl, a as transition, d as transitions, A as version };
22
+ export { t as CCBarCall, f as CCBarClient, e as CCBarError, a as CallManager, n as CallStateError, g as Diagnostics, m as RingBuffer, d as TokenManager, l as TypedEventBus, c as WebPhoneApi, o as assertCallTransition, p as canTransition, b as createSdk, s as createSharedWorkerSelection, h as diagnosticsVersion, y as parseSessionResponse, v as redactText, _ as redactValue, u as resolveWorkerUrl, r as transition, i as transitions, x as version };