@coventia/softphone 0.1.0
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/3x2-2HQTJDKZ.js +6583 -0
- package/dist/3x2-2HQTJDKZ.js.map +1 -0
- package/dist/3x2-INKWPNLA.js +6585 -0
- package/dist/3x2-INKWPNLA.js.map +1 -0
- package/dist/call-BTYlT2SU.d.cts +680 -0
- package/dist/call-BTYlT2SU.d.ts +680 -0
- package/dist/chunk-2ZSOGGPO.js +169 -0
- package/dist/chunk-2ZSOGGPO.js.map +1 -0
- package/dist/chunk-3V2L6UTK.js +129 -0
- package/dist/chunk-3V2L6UTK.js.map +1 -0
- package/dist/chunk-5BGEHMPP.js +945 -0
- package/dist/chunk-5BGEHMPP.js.map +1 -0
- package/dist/chunk-5WRI5ZAA.js +29 -0
- package/dist/chunk-5WRI5ZAA.js.map +1 -0
- package/dist/chunk-KAXEMJ7E.js +11 -0
- package/dist/chunk-KAXEMJ7E.js.map +1 -0
- package/dist/chunk-MHOJHG5E.js +39 -0
- package/dist/chunk-MHOJHG5E.js.map +1 -0
- package/dist/chunk-MP7CSA24.js +299 -0
- package/dist/chunk-MP7CSA24.js.map +1 -0
- package/dist/chunk-N2N2EQQJ.js +29 -0
- package/dist/chunk-N2N2EQQJ.js.map +1 -0
- package/dist/element/index.d.ts +853 -0
- package/dist/element/index.js +9635 -0
- package/dist/element/index.js.map +1 -0
- package/dist/engine-D9nbeY08.d.cts +115 -0
- package/dist/engine-Doa6Brkm.d.ts +115 -0
- package/dist/index.cjs +2133 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +62 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.js +630 -0
- package/dist/index.js.map +1 -0
- package/dist/min-64GIMWWL.js +5456 -0
- package/dist/min-64GIMWWL.js.map +1 -0
- package/dist/min-ATXYR23R.js +5458 -0
- package/dist/min-ATXYR23R.js.map +1 -0
- package/dist/react/index.cjs +138 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.cts +68 -0
- package/dist/react/index.d.ts +68 -0
- package/dist/react/index.js +4 -0
- package/dist/react/index.js.map +1 -0
- package/dist/softphone-DHmhotbf.d.ts +128 -0
- package/dist/softphone-DhuhcKCy.d.cts +128 -0
- package/dist/softphone.css +1923 -0
- package/dist/sources-N4BOEDRL.js +226 -0
- package/dist/sources-N4BOEDRL.js.map +1 -0
- package/dist/testing/index.cjs +345 -0
- package/dist/testing/index.cjs.map +1 -0
- package/dist/testing/index.d.cts +66 -0
- package/dist/testing/index.d.ts +66 -0
- package/dist/testing/index.js +186 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/ui/index.cjs +15428 -0
- package/dist/ui/index.cjs.map +1 -0
- package/dist/ui/index.d.cts +188 -0
- package/dist/ui/index.d.ts +188 -0
- package/dist/ui/index.js +2256 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/zadarma/index.cjs +1144 -0
- package/dist/zadarma/index.cjs.map +1 -0
- package/dist/zadarma/index.d.cts +86 -0
- package/dist/zadarma/index.d.ts +86 -0
- package/dist/zadarma/index.js +5 -0
- package/dist/zadarma/index.js.map +1 -0
- package/dist/zadarma-engine-DN2SZSQ3.js +5 -0
- package/dist/zadarma-engine-DN2SZSQ3.js.map +1 -0
- package/package.json +123 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { e as CallOptions, b as CallDirection, H as HangupReason, i as HoldOriginator, o as SoftphoneState, k as SoftphoneError } from './call-BTYlT2SU.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The `CallEngine` seam — INTERNAL, not exported from src/index.ts.
|
|
5
|
+
*
|
|
6
|
+
* This is the boundary `Softphone` and `Call` delegate to. It is DISTINCT from `SipProvider`
|
|
7
|
+
* (transports/providers/provider.ts), and the distinction is the whole reason S2 works:
|
|
8
|
+
*
|
|
9
|
+
* - `SipProvider` provisions CREDENTIALS (provision / registrationMode / quirks). It is a
|
|
10
|
+
* sub-component of the real SIP engine — Zadarma vs. our own infrastructure.
|
|
11
|
+
* - `CallEngine` places and drives CALLS. The SIP engine (S3) implements it *using* a SipProvider;
|
|
12
|
+
* the mock (S2) implements it directly, replacing the SIP layer wholesale.
|
|
13
|
+
*
|
|
14
|
+
* Softphone/Call therefore know nothing about JsSIP, SIP, or credentials — only about this engine.
|
|
15
|
+
* A mock that scripts a call lifecycle and the real JsSIP engine both satisfy it, and the contract
|
|
16
|
+
* suite (SPEC §9) runs against both so the playground can never drift from production.
|
|
17
|
+
*
|
|
18
|
+
* The engine speaks in RAW SIGNALS (`EngineCallEvent`), not call states. Translating those into the
|
|
19
|
+
* public state machine (SPEC §5.3) is `Call`'s job, and lives in exactly one place.
|
|
20
|
+
*/
|
|
21
|
+
/** What the engine tells `Call` happened. Raw; not yet a state. */
|
|
22
|
+
type EngineCallEvent =
|
|
23
|
+
/** Outbound: a provisional response. `early` may carry ringback media. */
|
|
24
|
+
{
|
|
25
|
+
readonly type: 'progress';
|
|
26
|
+
readonly response: 'ringing' | 'early';
|
|
27
|
+
}
|
|
28
|
+
/** Media is up (200 OK + ACK, or inbound answer confirmed). */
|
|
29
|
+
| {
|
|
30
|
+
readonly type: 'accepted';
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Terminal. Fires exactly once.
|
|
34
|
+
*
|
|
35
|
+
* `cause` is the transport's own raw reason (for SIP, the JsSIP cause — `'Unavailable'`,
|
|
36
|
+
* `'Not Found'`…) and is present only when one ended the call. `reason` is the coarse outcome the
|
|
37
|
+
* UI acts on; several causes map onto each, and the specific one is what makes a `call/failed`
|
|
38
|
+
* diagnosable after the fact. Never show it to a user: it is untranslated protocol vocabulary.
|
|
39
|
+
*/
|
|
40
|
+
| {
|
|
41
|
+
readonly type: 'ended';
|
|
42
|
+
readonly reason: HangupReason;
|
|
43
|
+
readonly cause?: string | undefined;
|
|
44
|
+
} | {
|
|
45
|
+
readonly type: 'held';
|
|
46
|
+
readonly originator: HoldOriginator;
|
|
47
|
+
} | {
|
|
48
|
+
readonly type: 'unheld';
|
|
49
|
+
readonly originator: HoldOriginator;
|
|
50
|
+
} | {
|
|
51
|
+
readonly type: 'reconnecting';
|
|
52
|
+
} | {
|
|
53
|
+
readonly type: 'reconnected';
|
|
54
|
+
}
|
|
55
|
+
/** Media stream to route to the call audio element. */
|
|
56
|
+
| {
|
|
57
|
+
readonly type: 'stream';
|
|
58
|
+
readonly stream: MediaStream;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* The engine's handle to one live call: the command surface plus its raw event source.
|
|
62
|
+
*
|
|
63
|
+
* Commands are effects only — they never mutate call state directly. State moves only in response to
|
|
64
|
+
* an `EngineCallEvent`, so the real (async, provider-confirmed) transitions and the mock's scripted
|
|
65
|
+
* ones travel the exact same path through `Call`.
|
|
66
|
+
*/
|
|
67
|
+
interface EngineCall {
|
|
68
|
+
readonly id: string;
|
|
69
|
+
readonly direction: CallDirection;
|
|
70
|
+
readonly remoteNumber: string;
|
|
71
|
+
answer(): Promise<void>;
|
|
72
|
+
reject(): Promise<void>;
|
|
73
|
+
hangup(): Promise<void>;
|
|
74
|
+
mute(muted: boolean): void;
|
|
75
|
+
hold(): Promise<void>;
|
|
76
|
+
unhold(): Promise<void>;
|
|
77
|
+
sendDigits(digits: string): void;
|
|
78
|
+
transfer(target: string): Promise<void>;
|
|
79
|
+
/** Attended transfer: dial the consult target. Returns the consult leg as its own EngineCall. */
|
|
80
|
+
startConsult(target: string): Promise<EngineCall>;
|
|
81
|
+
completeTransfer(consult: EngineCall): Promise<void>;
|
|
82
|
+
onEvent(listener: (event: EngineCallEvent) => void): () => void;
|
|
83
|
+
}
|
|
84
|
+
interface CallEngine {
|
|
85
|
+
/** Bring the engine to a reachable state (presence up / able to register). */
|
|
86
|
+
start(): Promise<void>;
|
|
87
|
+
stop(): Promise<void>;
|
|
88
|
+
placeCall(destination: string, options?: CallOptions): Promise<EngineCall>;
|
|
89
|
+
/** Fires when an inbound INVITE lands — NOT on a mere presence signal (SPEC §3.3). */
|
|
90
|
+
onIncoming(listener: (call: EngineCall) => void): () => void;
|
|
91
|
+
onStateChange(listener: (state: SoftphoneState) => void): () => void;
|
|
92
|
+
readonly state: SoftphoneState;
|
|
93
|
+
/**
|
|
94
|
+
* Report a failure the engine cannot recover from silently. Returns an unsubscribe function.
|
|
95
|
+
*
|
|
96
|
+
* **Optional**, so an engine that never fails interestingly — `MockProvider`, or one written before
|
|
97
|
+
* this existed — still satisfies the interface. `SoftphoneImpl` subscribes only when it is present.
|
|
98
|
+
*
|
|
99
|
+
* Without this the engine had the diagnosis and no way to pass it on: a failed registration knew
|
|
100
|
+
* the cause, the status code and the registrar domain, and could do nothing but `console.warn`
|
|
101
|
+
* while the widget went on claiming the phone was fine.
|
|
102
|
+
*/
|
|
103
|
+
onError?(listener: (error: SoftphoneError) => void): () => void;
|
|
104
|
+
/**
|
|
105
|
+
* Switch the microphone (SPEC §7 Phase 2, device management): stored for every future call's own
|
|
106
|
+
* capture, and — if a call is live right now — swapped onto it immediately.
|
|
107
|
+
*
|
|
108
|
+
* **Optional**, same reasoning as `onError`: `MockProvider` scripts calls with no real media at
|
|
109
|
+
* all, so there is nothing for it to swap, and it satisfies the interface by simply not having this
|
|
110
|
+
* method. `AudioDevices.setInput` only calls it when present.
|
|
111
|
+
*/
|
|
112
|
+
setInputDevice?(deviceId: string | null): Promise<void>;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export type { CallEngine as C, EngineCall as E };
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { e as CallOptions, b as CallDirection, H as HangupReason, i as HoldOriginator, o as SoftphoneState, k as SoftphoneError } from './call-BTYlT2SU.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The `CallEngine` seam — INTERNAL, not exported from src/index.ts.
|
|
5
|
+
*
|
|
6
|
+
* This is the boundary `Softphone` and `Call` delegate to. It is DISTINCT from `SipProvider`
|
|
7
|
+
* (transports/providers/provider.ts), and the distinction is the whole reason S2 works:
|
|
8
|
+
*
|
|
9
|
+
* - `SipProvider` provisions CREDENTIALS (provision / registrationMode / quirks). It is a
|
|
10
|
+
* sub-component of the real SIP engine — Zadarma vs. our own infrastructure.
|
|
11
|
+
* - `CallEngine` places and drives CALLS. The SIP engine (S3) implements it *using* a SipProvider;
|
|
12
|
+
* the mock (S2) implements it directly, replacing the SIP layer wholesale.
|
|
13
|
+
*
|
|
14
|
+
* Softphone/Call therefore know nothing about JsSIP, SIP, or credentials — only about this engine.
|
|
15
|
+
* A mock that scripts a call lifecycle and the real JsSIP engine both satisfy it, and the contract
|
|
16
|
+
* suite (SPEC §9) runs against both so the playground can never drift from production.
|
|
17
|
+
*
|
|
18
|
+
* The engine speaks in RAW SIGNALS (`EngineCallEvent`), not call states. Translating those into the
|
|
19
|
+
* public state machine (SPEC §5.3) is `Call`'s job, and lives in exactly one place.
|
|
20
|
+
*/
|
|
21
|
+
/** What the engine tells `Call` happened. Raw; not yet a state. */
|
|
22
|
+
type EngineCallEvent =
|
|
23
|
+
/** Outbound: a provisional response. `early` may carry ringback media. */
|
|
24
|
+
{
|
|
25
|
+
readonly type: 'progress';
|
|
26
|
+
readonly response: 'ringing' | 'early';
|
|
27
|
+
}
|
|
28
|
+
/** Media is up (200 OK + ACK, or inbound answer confirmed). */
|
|
29
|
+
| {
|
|
30
|
+
readonly type: 'accepted';
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Terminal. Fires exactly once.
|
|
34
|
+
*
|
|
35
|
+
* `cause` is the transport's own raw reason (for SIP, the JsSIP cause — `'Unavailable'`,
|
|
36
|
+
* `'Not Found'`…) and is present only when one ended the call. `reason` is the coarse outcome the
|
|
37
|
+
* UI acts on; several causes map onto each, and the specific one is what makes a `call/failed`
|
|
38
|
+
* diagnosable after the fact. Never show it to a user: it is untranslated protocol vocabulary.
|
|
39
|
+
*/
|
|
40
|
+
| {
|
|
41
|
+
readonly type: 'ended';
|
|
42
|
+
readonly reason: HangupReason;
|
|
43
|
+
readonly cause?: string | undefined;
|
|
44
|
+
} | {
|
|
45
|
+
readonly type: 'held';
|
|
46
|
+
readonly originator: HoldOriginator;
|
|
47
|
+
} | {
|
|
48
|
+
readonly type: 'unheld';
|
|
49
|
+
readonly originator: HoldOriginator;
|
|
50
|
+
} | {
|
|
51
|
+
readonly type: 'reconnecting';
|
|
52
|
+
} | {
|
|
53
|
+
readonly type: 'reconnected';
|
|
54
|
+
}
|
|
55
|
+
/** Media stream to route to the call audio element. */
|
|
56
|
+
| {
|
|
57
|
+
readonly type: 'stream';
|
|
58
|
+
readonly stream: MediaStream;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* The engine's handle to one live call: the command surface plus its raw event source.
|
|
62
|
+
*
|
|
63
|
+
* Commands are effects only — they never mutate call state directly. State moves only in response to
|
|
64
|
+
* an `EngineCallEvent`, so the real (async, provider-confirmed) transitions and the mock's scripted
|
|
65
|
+
* ones travel the exact same path through `Call`.
|
|
66
|
+
*/
|
|
67
|
+
interface EngineCall {
|
|
68
|
+
readonly id: string;
|
|
69
|
+
readonly direction: CallDirection;
|
|
70
|
+
readonly remoteNumber: string;
|
|
71
|
+
answer(): Promise<void>;
|
|
72
|
+
reject(): Promise<void>;
|
|
73
|
+
hangup(): Promise<void>;
|
|
74
|
+
mute(muted: boolean): void;
|
|
75
|
+
hold(): Promise<void>;
|
|
76
|
+
unhold(): Promise<void>;
|
|
77
|
+
sendDigits(digits: string): void;
|
|
78
|
+
transfer(target: string): Promise<void>;
|
|
79
|
+
/** Attended transfer: dial the consult target. Returns the consult leg as its own EngineCall. */
|
|
80
|
+
startConsult(target: string): Promise<EngineCall>;
|
|
81
|
+
completeTransfer(consult: EngineCall): Promise<void>;
|
|
82
|
+
onEvent(listener: (event: EngineCallEvent) => void): () => void;
|
|
83
|
+
}
|
|
84
|
+
interface CallEngine {
|
|
85
|
+
/** Bring the engine to a reachable state (presence up / able to register). */
|
|
86
|
+
start(): Promise<void>;
|
|
87
|
+
stop(): Promise<void>;
|
|
88
|
+
placeCall(destination: string, options?: CallOptions): Promise<EngineCall>;
|
|
89
|
+
/** Fires when an inbound INVITE lands — NOT on a mere presence signal (SPEC §3.3). */
|
|
90
|
+
onIncoming(listener: (call: EngineCall) => void): () => void;
|
|
91
|
+
onStateChange(listener: (state: SoftphoneState) => void): () => void;
|
|
92
|
+
readonly state: SoftphoneState;
|
|
93
|
+
/**
|
|
94
|
+
* Report a failure the engine cannot recover from silently. Returns an unsubscribe function.
|
|
95
|
+
*
|
|
96
|
+
* **Optional**, so an engine that never fails interestingly — `MockProvider`, or one written before
|
|
97
|
+
* this existed — still satisfies the interface. `SoftphoneImpl` subscribes only when it is present.
|
|
98
|
+
*
|
|
99
|
+
* Without this the engine had the diagnosis and no way to pass it on: a failed registration knew
|
|
100
|
+
* the cause, the status code and the registrar domain, and could do nothing but `console.warn`
|
|
101
|
+
* while the widget went on claiming the phone was fine.
|
|
102
|
+
*/
|
|
103
|
+
onError?(listener: (error: SoftphoneError) => void): () => void;
|
|
104
|
+
/**
|
|
105
|
+
* Switch the microphone (SPEC §7 Phase 2, device management): stored for every future call's own
|
|
106
|
+
* capture, and — if a call is live right now — swapped onto it immediately.
|
|
107
|
+
*
|
|
108
|
+
* **Optional**, same reasoning as `onError`: `MockProvider` scripts calls with no real media at
|
|
109
|
+
* all, so there is nothing for it to swap, and it satisfies the interface by simply not having this
|
|
110
|
+
* method. `AudioDevices.setInput` only calls it when present.
|
|
111
|
+
*/
|
|
112
|
+
setInputDevice?(deviceId: string | null): Promise<void>;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export type { CallEngine as C, EngineCall as E };
|