@16x/webphone-sdk 3.0.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/CHANGELOG.md +22 -0
- package/LICENSE +2 -0
- package/README.md +113 -0
- package/dist/CCBarClient-BdbynNBi.js +2515 -0
- package/dist/CCBarClient-DKWdvgf5.cjs +1 -0
- package/dist/CCBarError-CIqJE8zK.cjs +1 -0
- package/dist/CCBarError-DSbPw2dA.js +14 -0
- package/dist/Diagnostics-BYVvmxil.cjs +1 -0
- package/dist/Diagnostics-Cw2HVrCD.js +123 -0
- package/dist/JsSipAdapter-GHzVSCDh.js +304 -0
- package/dist/JsSipAdapter-jtGdoXrm.cjs +1 -0
- package/dist/SharedWorkerProtocol-BqUafs8d.js +73 -0
- package/dist/SharedWorkerProtocol-CYN0AprP.cjs +1 -0
- package/dist/api/WebPhoneApi.d.ts +28 -0
- package/dist/api/contracts.d.ts +94 -0
- package/dist/auth/TokenManager.d.ts +22 -0
- package/dist/core/CCBarCall.d.ts +94 -0
- package/dist/core/CCBarClient.d.ts +113 -0
- package/dist/core/CallManager.d.ts +93 -0
- package/dist/core/callId.d.ts +1 -0
- package/dist/core/mediaBridge.d.ts +17 -0
- package/dist/createJsSipFactory-2X4FBIU2.cjs +75 -0
- package/dist/createJsSipFactory-yttVU3d6.js +9662 -0
- package/dist/diagnostics/Diagnostics.d.ts +74 -0
- package/dist/diagnostics/RingBuffer.d.ts +7 -0
- package/dist/diagnostics/index.cjs +1 -0
- package/dist/diagnostics/index.d.ts +4 -0
- package/dist/diagnostics/index.js +6 -0
- package/dist/diagnostics/redact.d.ts +5 -0
- package/dist/errors/CCBarError.d.ts +15 -0
- package/dist/events/TypedEventBus.d.ts +9 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +152 -0
- package/dist/index.umd.js +75 -0
- package/dist/legacy/CCBarSDK.d.ts +29 -0
- package/dist/legacy/index.cjs +1 -0
- package/dist/legacy/index.d.ts +8 -0
- package/dist/legacy/index.js +108 -0
- package/dist/redact-Bq26pObO.cjs +1 -0
- package/dist/redact-DB3CMbsK.js +21 -0
- package/dist/shared/SharedCallTransport.d.ts +55 -0
- package/dist/shared/SharedWorkerClient.d.ts +20 -0
- package/dist/shared/SharedWorkerEntry.d.ts +3 -0
- package/dist/shared/SharedWorkerFactory.d.ts +29 -0
- package/dist/shared/SharedWorkerProtocol.d.ts +47 -0
- package/dist/shared/SharedWorkerRuntime.d.ts +35 -0
- package/dist/shared-worker.cjs +1 -0
- package/dist/shared-worker.d.ts +1 -0
- package/dist/shared-worker.js +185 -0
- package/dist/state/callStateMachine.d.ts +9 -0
- package/dist/styles.css +7 -0
- package/dist/types.d.ts +134 -0
- package/dist/ui/XCallCCBarElement.d.ts +23 -0
- package/dist/ui/controllers/mobileLifecycle.d.ts +18 -0
- package/dist/ui/controllers/phoneActions.d.ts +27 -0
- package/dist/ui/i18n/en-US.d.ts +2 -0
- package/dist/ui/i18n/index.d.ts +6 -0
- package/dist/ui/i18n/types.d.ts +53 -0
- package/dist/ui/i18n/zh-CN.d.ts +2 -0
- package/dist/ui/icons/index.d.ts +5 -0
- package/dist/ui/index.cjs +1 -0
- package/dist/ui/index.d.ts +3 -0
- package/dist/ui/index.js +1044 -0
- package/dist/ui/state/toPhoneViewModel.d.ts +54 -0
- package/dist/ui/views/dom.d.ts +11 -0
- package/dist/ui/views/messages.d.ts +5 -0
- package/dist/ui/views/renderActiveCall.d.ts +8 -0
- package/dist/ui/views/renderDesktop.d.ts +24 -0
- package/dist/ui/views/renderDialpad.d.ts +4 -0
- package/dist/ui/views/renderError.d.ts +6 -0
- package/dist/ui/views/renderIncoming.d.ts +8 -0
- package/dist/ui/views/renderMobile.d.ts +15 -0
- package/dist/ui/views/renderSetup.d.ts +6 -0
- package/package.json +107 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { CallState } from '../types.js';
|
|
2
|
+
export type DiagnosticPermission = 'granted' | 'denied' | 'prompt' | 'unsupported' | 'unknown';
|
|
3
|
+
export type DiagnosticConnectionState = 'idle' | 'offline' | 'connecting' | 'connected' | 'reconnecting' | 'failed' | 'disconnected';
|
|
4
|
+
export type DiagnosticLogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
5
|
+
export interface DiagnosticsOptions {
|
|
6
|
+
readonly includeRecentLogs?: boolean;
|
|
7
|
+
readonly includeDeviceNames?: boolean;
|
|
8
|
+
readonly maskPhoneNumbers?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface DiagnosticsResourceCounts {
|
|
11
|
+
readonly timers: number;
|
|
12
|
+
readonly listeners: number;
|
|
13
|
+
readonly tracks: number;
|
|
14
|
+
readonly peerConnections: number;
|
|
15
|
+
readonly audioElements: number;
|
|
16
|
+
readonly webSockets: number;
|
|
17
|
+
}
|
|
18
|
+
export interface DiagnosticCallSnapshot {
|
|
19
|
+
readonly callId: string;
|
|
20
|
+
readonly state: CallState;
|
|
21
|
+
readonly destination?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface DiagnosticIceSummary {
|
|
24
|
+
readonly configured: boolean;
|
|
25
|
+
readonly serverCount: number;
|
|
26
|
+
readonly stunServerCount: number;
|
|
27
|
+
readonly turnServerCount: number;
|
|
28
|
+
}
|
|
29
|
+
export interface DiagnosticWssSummary {
|
|
30
|
+
readonly configured: boolean;
|
|
31
|
+
readonly secure: boolean;
|
|
32
|
+
readonly state: DiagnosticConnectionState;
|
|
33
|
+
}
|
|
34
|
+
export interface DiagnosticsSnapshot {
|
|
35
|
+
readonly connectionState: DiagnosticConnectionState;
|
|
36
|
+
readonly calls: readonly DiagnosticCallSnapshot[];
|
|
37
|
+
readonly permission: DiagnosticPermission;
|
|
38
|
+
readonly ice: DiagnosticIceSummary;
|
|
39
|
+
readonly wss: DiagnosticWssSummary;
|
|
40
|
+
readonly resources: DiagnosticsResourceCounts;
|
|
41
|
+
}
|
|
42
|
+
export interface DiagnosticRuntimeComponent {
|
|
43
|
+
readonly name: string;
|
|
44
|
+
readonly version: string;
|
|
45
|
+
}
|
|
46
|
+
export interface DiagnosticLogEntry {
|
|
47
|
+
readonly timestamp: string;
|
|
48
|
+
readonly level: DiagnosticLogLevel;
|
|
49
|
+
readonly message: string;
|
|
50
|
+
readonly context?: unknown;
|
|
51
|
+
}
|
|
52
|
+
export interface DiagnosticsReport extends DiagnosticsSnapshot {
|
|
53
|
+
readonly generatedAt: string;
|
|
54
|
+
readonly sdk: DiagnosticRuntimeComponent;
|
|
55
|
+
readonly browser: DiagnosticRuntimeComponent;
|
|
56
|
+
readonly os: DiagnosticRuntimeComponent;
|
|
57
|
+
readonly recentLogs: readonly DiagnosticLogEntry[];
|
|
58
|
+
readonly deviceNames?: readonly string[];
|
|
59
|
+
}
|
|
60
|
+
export interface DiagnosticsDependencies {
|
|
61
|
+
readonly getSnapshot: () => DiagnosticsSnapshot;
|
|
62
|
+
readonly getPermission?: () => Promise<DiagnosticPermission>;
|
|
63
|
+
readonly getDeviceNames?: () => Promise<readonly string[]>;
|
|
64
|
+
readonly getUserAgent?: () => string;
|
|
65
|
+
readonly now?: () => Date;
|
|
66
|
+
}
|
|
67
|
+
export declare class Diagnostics {
|
|
68
|
+
private readonly dependencies;
|
|
69
|
+
private readonly logs;
|
|
70
|
+
private readonly now;
|
|
71
|
+
constructor(dependencies: DiagnosticsDependencies);
|
|
72
|
+
log(level: DiagnosticLogLevel, message: string, context?: unknown): void;
|
|
73
|
+
getReport(options?: DiagnosticsOptions): Promise<DiagnosticsReport>;
|
|
74
|
+
}
|
|
@@ -0,0 +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;
|
|
@@ -0,0 +1,6 @@
|
|
|
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 };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CCBarErrorCategory, CCBarErrorCode } from '../types.js';
|
|
2
|
+
export interface CCBarErrorOptions {
|
|
3
|
+
requestId?: string;
|
|
4
|
+
callId?: string;
|
|
5
|
+
cause?: unknown;
|
|
6
|
+
}
|
|
7
|
+
export declare class CCBarError extends Error {
|
|
8
|
+
readonly code: CCBarErrorCode;
|
|
9
|
+
readonly category: CCBarErrorCategory;
|
|
10
|
+
readonly retryable: boolean;
|
|
11
|
+
readonly requestId?: string;
|
|
12
|
+
readonly callId?: string;
|
|
13
|
+
readonly cause?: unknown;
|
|
14
|
+
constructor(code: CCBarErrorCode, category: CCBarErrorCategory, retryable: boolean, options?: CCBarErrorOptions);
|
|
15
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type EventHandler<T> = (payload: T) => void;
|
|
2
|
+
export declare class TypedEventBus<Events extends Record<string, unknown>> {
|
|
3
|
+
private readonly handlers;
|
|
4
|
+
on<K extends keyof Events>(event: K, handler: EventHandler<Events[K]>): () => void;
|
|
5
|
+
off<K extends keyof Events>(event: K, handler: EventHandler<Events[K]>): void;
|
|
6
|
+
emit<K extends keyof Events>(event: K, payload: Events[K]): void;
|
|
7
|
+
listenerCount(): number;
|
|
8
|
+
clear(): void;
|
|
9
|
+
}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +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;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface CcBarSdkOptions {
|
|
2
|
+
readonly debug?: boolean;
|
|
3
|
+
}
|
|
4
|
+
export interface CcBarSdk {
|
|
5
|
+
readonly version: string;
|
|
6
|
+
readonly options: CcBarSdkOptions;
|
|
7
|
+
}
|
|
8
|
+
export declare function createSdk(options?: CcBarSdkOptions): CcBarSdk;
|
|
9
|
+
export declare const version = "0.1.0";
|
|
10
|
+
export * from './types.js';
|
|
11
|
+
export * from './errors/CCBarError.js';
|
|
12
|
+
export * from './events/TypedEventBus.js';
|
|
13
|
+
export * from './state/callStateMachine.js';
|
|
14
|
+
export * from './auth/TokenManager.js';
|
|
15
|
+
export * from './api/contracts.js';
|
|
16
|
+
export * from './api/WebPhoneApi.js';
|
|
17
|
+
export * from './core/CCBarCall.js';
|
|
18
|
+
export * from './core/CallManager.js';
|
|
19
|
+
export * from './core/CCBarClient.js';
|
|
20
|
+
export * from './diagnostics/index.js';
|
|
21
|
+
export * from './shared/SharedWorkerFactory.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
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";
|
|
7
|
+
//#region src/api/contracts.ts
|
|
8
|
+
function v(e) {
|
|
9
|
+
if (e.code !== "OK") throw TypeError(`Unexpected session response code: ${e.code}`);
|
|
10
|
+
if (e.data === void 0 || e.data === null) throw TypeError("Unexpected session response: missing data");
|
|
11
|
+
return e.data;
|
|
12
|
+
}
|
|
13
|
+
//#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
|
+
//#region src/index.ts
|
|
144
|
+
function k(e = {}) {
|
|
145
|
+
return {
|
|
146
|
+
version: "0.1.0",
|
|
147
|
+
options: e
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
var A = "0.1.0";
|
|
151
|
+
//#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 };
|