@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.
Files changed (69) hide show
  1. package/dist/3x2-2HQTJDKZ.js +6583 -0
  2. package/dist/3x2-2HQTJDKZ.js.map +1 -0
  3. package/dist/3x2-INKWPNLA.js +6585 -0
  4. package/dist/3x2-INKWPNLA.js.map +1 -0
  5. package/dist/call-BTYlT2SU.d.cts +680 -0
  6. package/dist/call-BTYlT2SU.d.ts +680 -0
  7. package/dist/chunk-2ZSOGGPO.js +169 -0
  8. package/dist/chunk-2ZSOGGPO.js.map +1 -0
  9. package/dist/chunk-3V2L6UTK.js +129 -0
  10. package/dist/chunk-3V2L6UTK.js.map +1 -0
  11. package/dist/chunk-5BGEHMPP.js +945 -0
  12. package/dist/chunk-5BGEHMPP.js.map +1 -0
  13. package/dist/chunk-5WRI5ZAA.js +29 -0
  14. package/dist/chunk-5WRI5ZAA.js.map +1 -0
  15. package/dist/chunk-KAXEMJ7E.js +11 -0
  16. package/dist/chunk-KAXEMJ7E.js.map +1 -0
  17. package/dist/chunk-MHOJHG5E.js +39 -0
  18. package/dist/chunk-MHOJHG5E.js.map +1 -0
  19. package/dist/chunk-MP7CSA24.js +299 -0
  20. package/dist/chunk-MP7CSA24.js.map +1 -0
  21. package/dist/chunk-N2N2EQQJ.js +29 -0
  22. package/dist/chunk-N2N2EQQJ.js.map +1 -0
  23. package/dist/element/index.d.ts +853 -0
  24. package/dist/element/index.js +9635 -0
  25. package/dist/element/index.js.map +1 -0
  26. package/dist/engine-D9nbeY08.d.cts +115 -0
  27. package/dist/engine-Doa6Brkm.d.ts +115 -0
  28. package/dist/index.cjs +2133 -0
  29. package/dist/index.cjs.map +1 -0
  30. package/dist/index.d.cts +62 -0
  31. package/dist/index.d.ts +62 -0
  32. package/dist/index.js +630 -0
  33. package/dist/index.js.map +1 -0
  34. package/dist/min-64GIMWWL.js +5456 -0
  35. package/dist/min-64GIMWWL.js.map +1 -0
  36. package/dist/min-ATXYR23R.js +5458 -0
  37. package/dist/min-ATXYR23R.js.map +1 -0
  38. package/dist/react/index.cjs +138 -0
  39. package/dist/react/index.cjs.map +1 -0
  40. package/dist/react/index.d.cts +68 -0
  41. package/dist/react/index.d.ts +68 -0
  42. package/dist/react/index.js +4 -0
  43. package/dist/react/index.js.map +1 -0
  44. package/dist/softphone-DHmhotbf.d.ts +128 -0
  45. package/dist/softphone-DhuhcKCy.d.cts +128 -0
  46. package/dist/softphone.css +1923 -0
  47. package/dist/sources-N4BOEDRL.js +226 -0
  48. package/dist/sources-N4BOEDRL.js.map +1 -0
  49. package/dist/testing/index.cjs +345 -0
  50. package/dist/testing/index.cjs.map +1 -0
  51. package/dist/testing/index.d.cts +66 -0
  52. package/dist/testing/index.d.ts +66 -0
  53. package/dist/testing/index.js +186 -0
  54. package/dist/testing/index.js.map +1 -0
  55. package/dist/ui/index.cjs +15428 -0
  56. package/dist/ui/index.cjs.map +1 -0
  57. package/dist/ui/index.d.cts +188 -0
  58. package/dist/ui/index.d.ts +188 -0
  59. package/dist/ui/index.js +2256 -0
  60. package/dist/ui/index.js.map +1 -0
  61. package/dist/zadarma/index.cjs +1144 -0
  62. package/dist/zadarma/index.cjs.map +1 -0
  63. package/dist/zadarma/index.d.cts +86 -0
  64. package/dist/zadarma/index.d.ts +86 -0
  65. package/dist/zadarma/index.js +5 -0
  66. package/dist/zadarma/index.js.map +1 -0
  67. package/dist/zadarma-engine-DN2SZSQ3.js +5 -0
  68. package/dist/zadarma-engine-DN2SZSQ3.js.map +1 -0
  69. 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 };